Commit Graph

33 Commits

Author SHA1 Message Date
Tom Tromey 1a5c25988e Normalize include guards in gdb
While working on my other scripts to deal with gdb headers, I noticed
that some files were missing include guards.  I wrote a script to add
the missing ones, but found that using the obvious names for the
guards ran into clashes -- for example, gdb/nat/linux-nat.h used
"LINUX_NAT_H", but this was also the script's choice for
gdb/linux-nat.h.

So, I changed the script to normalize all include guards in gdb.  This
patch is the result.

As usual the script is available here:

    https://github.com/tromey/gdb-refactoring-scripts

Tested by rebuilding; I also ran it through "Fedora-x86_64-m64" on the
buildbot.

gdb/ChangeLog
2019-02-07  Tom Tromey  <tom@tromey.com>

	* yy-remap.h: Add include guard.
	* xtensa-tdep.h: Add include guard.
	* xcoffread.h: Rename include guard.
	* varobj-iter.h: Add include guard.
	* tui/tui.h: Rename include guard.
	* tui/tui-winsource.h: Rename include guard.
	* tui/tui-wingeneral.h: Rename include guard.
	* tui/tui-windata.h: Rename include guard.
	* tui/tui-win.h: Rename include guard.
	* tui/tui-stack.h: Rename include guard.
	* tui/tui-source.h: Rename include guard.
	* tui/tui-regs.h: Rename include guard.
	* tui/tui-out.h: Rename include guard.
	* tui/tui-layout.h: Rename include guard.
	* tui/tui-io.h: Rename include guard.
	* tui/tui-hooks.h: Rename include guard.
	* tui/tui-file.h: Rename include guard.
	* tui/tui-disasm.h: Rename include guard.
	* tui/tui-data.h: Rename include guard.
	* tui/tui-command.h: Rename include guard.
	* tic6x-tdep.h: Add include guard.
	* target/waitstatus.h: Rename include guard.
	* target/wait.h: Rename include guard.
	* target/target.h: Rename include guard.
	* target/resume.h: Rename include guard.
	* target-float.h: Rename include guard.
	* stabsread.h: Add include guard.
	* rs6000-tdep.h: Add include guard.
	* riscv-fbsd-tdep.h: Add include guard.
	* regformats/regdef.h: Rename include guard.
	* record.h: Rename include guard.
	* python/python.h: Rename include guard.
	* python/python-internal.h: Rename include guard.
	* python/py-stopevent.h: Rename include guard.
	* python/py-ref.h: Rename include guard.
	* python/py-record.h: Rename include guard.
	* python/py-record-full.h: Rename include guard.
	* python/py-record-btrace.h: Rename include guard.
	* python/py-instruction.h: Rename include guard.
	* python/py-events.h: Rename include guard.
	* python/py-event.h: Rename include guard.
	* procfs.h: Add include guard.
	* proc-utils.h: Add include guard.
	* p-lang.h: Add include guard.
	* or1k-tdep.h: Rename include guard.
	* observable.h: Rename include guard.
	* nto-tdep.h: Rename include guard.
	* nat/x86-linux.h: Rename include guard.
	* nat/x86-linux-dregs.h: Rename include guard.
	* nat/x86-gcc-cpuid.h: Add include guard.
	* nat/x86-dregs.h: Rename include guard.
	* nat/x86-cpuid.h: Rename include guard.
	* nat/ppc-linux.h: Rename include guard.
	* nat/mips-linux-watch.h: Rename include guard.
	* nat/linux-waitpid.h: Rename include guard.
	* nat/linux-ptrace.h: Rename include guard.
	* nat/linux-procfs.h: Rename include guard.
	* nat/linux-osdata.h: Rename include guard.
	* nat/linux-nat.h: Rename include guard.
	* nat/linux-namespaces.h: Rename include guard.
	* nat/linux-btrace.h: Rename include guard.
	* nat/glibc_thread_db.h: Rename include guard.
	* nat/gdb_thread_db.h: Rename include guard.
	* nat/gdb_ptrace.h: Rename include guard.
	* nat/fork-inferior.h: Rename include guard.
	* nat/amd64-linux-siginfo.h: Rename include guard.
	* nat/aarch64-sve-linux-sigcontext.h: Rename include guard.
	* nat/aarch64-sve-linux-ptrace.h: Rename include guard.
	* nat/aarch64-linux.h: Rename include guard.
	* nat/aarch64-linux-hw-point.h: Rename include guard.
	* mn10300-tdep.h: Add include guard.
	* mips-linux-tdep.h: Add include guard.
	* mi/mi-parse.h: Rename include guard.
	* mi/mi-out.h: Rename include guard.
	* mi/mi-main.h: Rename include guard.
	* mi/mi-interp.h: Rename include guard.
	* mi/mi-getopt.h: Rename include guard.
	* mi/mi-console.h: Rename include guard.
	* mi/mi-common.h: Rename include guard.
	* mi/mi-cmds.h: Rename include guard.
	* mi/mi-cmd-break.h: Rename include guard.
	* m2-lang.h: Add include guard.
	* location.h: Rename include guard.
	* linux-record.h: Rename include guard.
	* linux-nat.h: Add include guard.
	* linux-fork.h: Add include guard.
	* i386-darwin-tdep.h: Rename include guard.
	* hppa-linux-offsets.h: Add include guard.
	* guile/guile.h: Rename include guard.
	* guile/guile-internal.h: Rename include guard.
	* gnu-nat.h: Rename include guard.
	* gdb-stabs.h: Rename include guard.
	* frv-tdep.h: Add include guard.
	* f-lang.h: Add include guard.
	* event-loop.h: Add include guard.
	* darwin-nat.h: Rename include guard.
	* cp-abi.h: Rename include guard.
	* config/sparc/nm-sol2.h: Rename include guard.
	* config/nm-nto.h: Rename include guard.
	* config/nm-linux.h: Add include guard.
	* config/i386/nm-i386gnu.h: Rename include guard.
	* config/djgpp/nl_types.h: Rename include guard.
	* config/djgpp/langinfo.h: Rename include guard.
	* compile/gcc-cp-plugin.h: Add include guard.
	* compile/gcc-c-plugin.h: Add include guard.
	* compile/compile.h: Rename include guard.
	* compile/compile-object-run.h: Rename include guard.
	* compile/compile-object-load.h: Rename include guard.
	* compile/compile-internal.h: Rename include guard.
	* compile/compile-cplus.h: Rename include guard.
	* compile/compile-c.h: Rename include guard.
	* common/xml-utils.h: Rename include guard.
	* common/x86-xstate.h: Rename include guard.
	* common/version.h: Rename include guard.
	* common/vec.h: Rename include guard.
	* common/tdesc.h: Rename include guard.
	* common/selftest.h: Rename include guard.
	* common/scoped_restore.h: Rename include guard.
	* common/scoped_mmap.h: Rename include guard.
	* common/scoped_fd.h: Rename include guard.
	* common/safe-iterator.h: Rename include guard.
	* common/run-time-clock.h: Rename include guard.
	* common/refcounted-object.h: Rename include guard.
	* common/queue.h: Rename include guard.
	* common/ptid.h: Rename include guard.
	* common/print-utils.h: Rename include guard.
	* common/preprocessor.h: Rename include guard.
	* common/pathstuff.h: Rename include guard.
	* common/observable.h: Rename include guard.
	* common/netstuff.h: Rename include guard.
	* common/job-control.h: Rename include guard.
	* common/host-defs.h: Rename include guard.
	* common/gdb_wait.h: Rename include guard.
	* common/gdb_vecs.h: Rename include guard.
	* common/gdb_unlinker.h: Rename include guard.
	* common/gdb_unique_ptr.h: Rename include guard.
	* common/gdb_tilde_expand.h: Rename include guard.
	* common/gdb_sys_time.h: Rename include guard.
	* common/gdb_string_view.h: Rename include guard.
	* common/gdb_splay_tree.h: Rename include guard.
	* common/gdb_setjmp.h: Rename include guard.
	* common/gdb_ref_ptr.h: Rename include guard.
	* common/gdb_optional.h: Rename include guard.
	* common/gdb_locale.h: Rename include guard.
	* common/gdb_assert.h: Rename include guard.
	* common/filtered-iterator.h: Rename include guard.
	* common/filestuff.h: Rename include guard.
	* common/fileio.h: Rename include guard.
	* common/environ.h: Rename include guard.
	* common/common-utils.h: Rename include guard.
	* common/common-types.h: Rename include guard.
	* common/common-regcache.h: Rename include guard.
	* common/common-inferior.h: Rename include guard.
	* common/common-gdbthread.h: Rename include guard.
	* common/common-exceptions.h: Rename include guard.
	* common/common-defs.h: Rename include guard.
	* common/common-debug.h: Rename include guard.
	* common/cleanups.h: Rename include guard.
	* common/buffer.h: Rename include guard.
	* common/btrace-common.h: Rename include guard.
	* common/break-common.h: Rename include guard.
	* cli/cli-utils.h: Rename include guard.
	* cli/cli-style.h: Rename include guard.
	* cli/cli-setshow.h: Rename include guard.
	* cli/cli-script.h: Rename include guard.
	* cli/cli-interp.h: Rename include guard.
	* cli/cli-decode.h: Rename include guard.
	* cli/cli-cmds.h: Rename include guard.
	* charset-list.h: Add include guard.
	* buildsym-legacy.h: Rename include guard.
	* bfin-tdep.h: Add include guard.
	* ax.h: Rename include guard.
	* arm-linux-tdep.h: Add include guard.
	* arm-fbsd-tdep.h: Add include guard.
	* arch/xtensa.h: Rename include guard.
	* arch/tic6x.h: Add include guard.
	* arch/i386.h: Add include guard.
	* arch/arm.h: Rename include guard.
	* arch/arm-linux.h: Rename include guard.
	* arch/arm-get-next-pcs.h: Rename include guard.
	* arch/amd64.h: Add include guard.
	* arch/aarch64-insn.h: Rename include guard.
	* arch-utils.h: Rename include guard.
	* annotate.h: Add include guard.
	* amd64-darwin-tdep.h: Rename include guard.
	* aarch64-linux-tdep.h: Add include guard.
	* aarch64-fbsd-tdep.h: Add include guard.
	* aarch32-linux-nat.h: Add include guard.

gdb/gdbserver/ChangeLog
2019-02-07  Tom Tromey  <tom@tromey.com>

	* x86-tdesc.h: Rename include guard.
	* x86-low.h: Add include guard.
	* wincecompat.h: Rename include guard.
	* win32-low.h: Add include guard.
	* utils.h: Rename include guard.
	* tracepoint.h: Rename include guard.
	* tdesc.h: Rename include guard.
	* target.h: Rename include guard.
	* server.h: Rename include guard.
	* remote-utils.h: Rename include guard.
	* regcache.h: Rename include guard.
	* nto-low.h: Rename include guard.
	* notif.h: Add include guard.
	* mem-break.h: Rename include guard.
	* lynx-low.h: Add include guard.
	* linux-x86-tdesc.h: Add include guard.
	* linux-s390-tdesc.h: Add include guard.
	* linux-ppc-tdesc-init.h: Add include guard.
	* linux-low.h: Add include guard.
	* linux-aarch64-tdesc.h: Add include guard.
	* linux-aarch32-low.h: Add include guard.
	* inferiors.h: Rename include guard.
	* i387-fp.h: Rename include guard.
	* hostio.h: Rename include guard.
	* gdbthread.h: Rename include guard.
	* gdb_proc_service.h: Rename include guard.
	* event-loop.h: Rename include guard.
	* dll.h: Rename include guard.
	* debug.h: Rename include guard.
	* ax.h: Rename include guard.
2019-02-07 03:27:23 -07:00
Tom Tromey 0747795c08 Normalize includes to use common/
This changes all includes to use the form "common/filename.h" rather
than just "filename.h".  This was written by a script.

gdb/ChangeLog
2019-01-25  Tom Tromey  <tom@tromey.com>

	* xtensa-linux-nat.c: Fix common/ includes.
	* xml-support.h: Fix common/ includes.
	* xml-support.c: Fix common/ includes.
	* x86-linux-nat.c: Fix common/ includes.
	* windows-nat.c: Fix common/ includes.
	* varobj.h: Fix common/ includes.
	* varobj.c: Fix common/ includes.
	* value.c: Fix common/ includes.
	* valops.c: Fix common/ includes.
	* utils.c: Fix common/ includes.
	* unittests/xml-utils-selftests.c: Fix common/ includes.
	* unittests/utils-selftests.c: Fix common/ includes.
	* unittests/unpack-selftests.c: Fix common/ includes.
	* unittests/tracepoint-selftests.c: Fix common/ includes.
	* unittests/style-selftests.c: Fix common/ includes.
	* unittests/string_view-selftests.c: Fix common/ includes.
	* unittests/scoped_restore-selftests.c: Fix common/ includes.
	* unittests/scoped_mmap-selftests.c: Fix common/ includes.
	* unittests/scoped_fd-selftests.c: Fix common/ includes.
	* unittests/rsp-low-selftests.c: Fix common/ includes.
	* unittests/parse-connection-spec-selftests.c: Fix common/
	includes.
	* unittests/optional-selftests.c: Fix common/ includes.
	* unittests/offset-type-selftests.c: Fix common/ includes.
	* unittests/observable-selftests.c: Fix common/ includes.
	* unittests/mkdir-recursive-selftests.c: Fix common/ includes.
	* unittests/memrange-selftests.c: Fix common/ includes.
	* unittests/memory-map-selftests.c: Fix common/ includes.
	* unittests/lookup_name_info-selftests.c: Fix common/ includes.
	* unittests/function-view-selftests.c: Fix common/ includes.
	* unittests/environ-selftests.c: Fix common/ includes.
	* unittests/copy_bitwise-selftests.c: Fix common/ includes.
	* unittests/common-utils-selftests.c: Fix common/ includes.
	* unittests/cli-utils-selftests.c: Fix common/ includes.
	* unittests/array-view-selftests.c: Fix common/ includes.
	* ui-file.c: Fix common/ includes.
	* tui/tui-io.c: Fix common/ includes.
	* tracepoint.h: Fix common/ includes.
	* tracepoint.c: Fix common/ includes.
	* tracefile-tfile.c: Fix common/ includes.
	* top.h: Fix common/ includes.
	* top.c: Fix common/ includes.
	* thread.c: Fix common/ includes.
	* target/waitstatus.h: Fix common/ includes.
	* target/waitstatus.c: Fix common/ includes.
	* target.h: Fix common/ includes.
	* target.c: Fix common/ includes.
	* target-memory.c: Fix common/ includes.
	* target-descriptions.c: Fix common/ includes.
	* symtab.h: Fix common/ includes.
	* symfile.c: Fix common/ includes.
	* stap-probe.c: Fix common/ includes.
	* spu-linux-nat.c: Fix common/ includes.
	* sparc-nat.c: Fix common/ includes.
	* source.c: Fix common/ includes.
	* solib.c: Fix common/ includes.
	* solib-target.c: Fix common/ includes.
	* ser-unix.c: Fix common/ includes.
	* ser-tcp.c: Fix common/ includes.
	* ser-pipe.c: Fix common/ includes.
	* ser-base.c: Fix common/ includes.
	* selftest-arch.c: Fix common/ includes.
	* s12z-tdep.c: Fix common/ includes.
	* rust-exp.y: Fix common/ includes.
	* rs6000-aix-tdep.c: Fix common/ includes.
	* riscv-tdep.c: Fix common/ includes.
	* remote.c: Fix common/ includes.
	* remote-notif.h: Fix common/ includes.
	* remote-fileio.h: Fix common/ includes.
	* remote-fileio.c: Fix common/ includes.
	* regcache.h: Fix common/ includes.
	* regcache.c: Fix common/ includes.
	* record-btrace.c: Fix common/ includes.
	* python/python.c: Fix common/ includes.
	* python/py-type.c: Fix common/ includes.
	* python/py-inferior.c: Fix common/ includes.
	* progspace.h: Fix common/ includes.
	* producer.c: Fix common/ includes.
	* procfs.c: Fix common/ includes.
	* proc-api.c: Fix common/ includes.
	* printcmd.c: Fix common/ includes.
	* ppc-linux-nat.c: Fix common/ includes.
	* parser-defs.h: Fix common/ includes.
	* osdata.c: Fix common/ includes.
	* obsd-nat.c: Fix common/ includes.
	* nat/x86-linux.c: Fix common/ includes.
	* nat/x86-linux-dregs.c: Fix common/ includes.
	* nat/x86-dregs.h: Fix common/ includes.
	* nat/x86-dregs.c: Fix common/ includes.
	* nat/ppc-linux.c: Fix common/ includes.
	* nat/mips-linux-watch.h: Fix common/ includes.
	* nat/mips-linux-watch.c: Fix common/ includes.
	* nat/linux-waitpid.c: Fix common/ includes.
	* nat/linux-ptrace.h: Fix common/ includes.
	* nat/linux-ptrace.c: Fix common/ includes.
	* nat/linux-procfs.c: Fix common/ includes.
	* nat/linux-personality.c: Fix common/ includes.
	* nat/linux-osdata.c: Fix common/ includes.
	* nat/linux-namespaces.c: Fix common/ includes.
	* nat/linux-btrace.h: Fix common/ includes.
	* nat/linux-btrace.c: Fix common/ includes.
	* nat/fork-inferior.c: Fix common/ includes.
	* nat/amd64-linux-siginfo.c: Fix common/ includes.
	* nat/aarch64-sve-linux-ptrace.c: Fix common/ includes.
	* nat/aarch64-linux.c: Fix common/ includes.
	* nat/aarch64-linux-hw-point.h: Fix common/ includes.
	* nat/aarch64-linux-hw-point.c: Fix common/ includes.
	* namespace.h: Fix common/ includes.
	* mips-linux-tdep.c: Fix common/ includes.
	* minsyms.c: Fix common/ includes.
	* mi/mi-parse.h: Fix common/ includes.
	* mi/mi-main.c: Fix common/ includes.
	* mi/mi-cmd-env.c: Fix common/ includes.
	* memrange.h: Fix common/ includes.
	* memattr.c: Fix common/ includes.
	* maint.h: Fix common/ includes.
	* maint.c: Fix common/ includes.
	* main.c: Fix common/ includes.
	* machoread.c: Fix common/ includes.
	* location.c: Fix common/ includes.
	* linux-thread-db.c: Fix common/ includes.
	* linux-nat.c: Fix common/ includes.
	* linux-fork.c: Fix common/ includes.
	* inline-frame.c: Fix common/ includes.
	* infrun.c: Fix common/ includes.
	* inflow.c: Fix common/ includes.
	* inferior.h: Fix common/ includes.
	* inferior.c: Fix common/ includes.
	* infcmd.c: Fix common/ includes.
	* inf-ptrace.c: Fix common/ includes.
	* inf-child.c: Fix common/ includes.
	* ia64-linux-nat.c: Fix common/ includes.
	* i387-tdep.c: Fix common/ includes.
	* i386-tdep.c: Fix common/ includes.
	* i386-linux-tdep.c: Fix common/ includes.
	* i386-linux-nat.c: Fix common/ includes.
	* i386-go32-tdep.c: Fix common/ includes.
	* i386-fbsd-tdep.c: Fix common/ includes.
	* i386-fbsd-nat.c: Fix common/ includes.
	* guile/scm-type.c: Fix common/ includes.
	* guile/guile.c: Fix common/ includes.
	* go32-nat.c: Fix common/ includes.
	* gnu-nat.c: Fix common/ includes.
	* gdbthread.h: Fix common/ includes.
	* gdbarch-selftests.c: Fix common/ includes.
	* gdb_usleep.c: Fix common/ includes.
	* gdb_select.h: Fix common/ includes.
	* gdb_bfd.c: Fix common/ includes.
	* gcore.c: Fix common/ includes.
	* fork-child.c: Fix common/ includes.
	* findvar.c: Fix common/ includes.
	* fbsd-nat.c: Fix common/ includes.
	* event-top.c: Fix common/ includes.
	* event-loop.c: Fix common/ includes.
	* dwarf2read.c: Fix common/ includes.
	* dwarf2loc.c: Fix common/ includes.
	* dwarf2-frame.c: Fix common/ includes.
	* dwarf-index-cache.c: Fix common/ includes.
	* dtrace-probe.c: Fix common/ includes.
	* disasm-selftests.c: Fix common/ includes.
	* defs.h: Fix common/ includes.
	* csky-tdep.c: Fix common/ includes.
	* cp-valprint.c: Fix common/ includes.
	* cp-support.h: Fix common/ includes.
	* cp-support.c: Fix common/ includes.
	* corelow.c: Fix common/ includes.
	* completer.h: Fix common/ includes.
	* completer.c: Fix common/ includes.
	* compile/compile.c: Fix common/ includes.
	* compile/compile-loc2c.c: Fix common/ includes.
	* compile/compile-cplus-types.c: Fix common/ includes.
	* compile/compile-cplus-symbols.c: Fix common/ includes.
	* command.h: Fix common/ includes.
	* cli/cli-dump.c: Fix common/ includes.
	* cli/cli-cmds.c: Fix common/ includes.
	* charset.c: Fix common/ includes.
	* build-id.c: Fix common/ includes.
	* btrace.h: Fix common/ includes.
	* btrace.c: Fix common/ includes.
	* breakpoint.h: Fix common/ includes.
	* breakpoint.c: Fix common/ includes.
	* ax.h:
	(enum agent_op): Fix common/ includes.
	* ax-general.c (struct aop_map): Fix common/ includes.
	* ax-gdb.c: Fix common/ includes.
	* auxv.c: Fix common/ includes.
	* auto-load.c: Fix common/ includes.
	* arm-tdep.c: Fix common/ includes.
	* arch/riscv.c: Fix common/ includes.
	* arch/ppc-linux-common.c: Fix common/ includes.
	* arch/i386.c: Fix common/ includes.
	* arch/arm.c: Fix common/ includes.
	* arch/arm-linux.c: Fix common/ includes.
	* arch/arm-get-next-pcs.c: Fix common/ includes.
	* arch/amd64.c: Fix common/ includes.
	* arch/aarch64.c: Fix common/ includes.
	* arch/aarch64-insn.c: Fix common/ includes.
	* arch-utils.c: Fix common/ includes.
	* amd64-windows-tdep.c: Fix common/ includes.
	* amd64-tdep.c: Fix common/ includes.
	* amd64-sol2-tdep.c: Fix common/ includes.
	* amd64-obsd-tdep.c: Fix common/ includes.
	* amd64-nbsd-tdep.c: Fix common/ includes.
	* amd64-linux-tdep.c: Fix common/ includes.
	* amd64-linux-nat.c: Fix common/ includes.
	* amd64-fbsd-tdep.c: Fix common/ includes.
	* amd64-fbsd-nat.c: Fix common/ includes.
	* amd64-dicos-tdep.c: Fix common/ includes.
	* amd64-darwin-tdep.c: Fix common/ includes.
	* agent.c: Fix common/ includes.
	* ada-lang.h: Fix common/ includes.
	* ada-lang.c: Fix common/ includes.
	* aarch64-tdep.c: Fix common/ includes.

gdb/gdbserver/ChangeLog
2019-01-25  Tom Tromey  <tom@tromey.com>

	* win32-low.c: Fix common/ includes.
	* win32-i386-low.c: Fix common/ includes.
	* tracepoint.c: Fix common/ includes.
	* thread-db.c: Fix common/ includes.
	* target.h: Fix common/ includes.
	* symbol.c: Fix common/ includes.
	* spu-low.c: Fix common/ includes.
	* server.h: Fix common/ includes.
	* server.c: Fix common/ includes.
	* remote-utils.c: Fix common/ includes.
	* regcache.h: Fix common/ includes.
	* regcache.c: Fix common/ includes.
	* nto-x86-low.c: Fix common/ includes.
	* notif.h: Fix common/ includes.
	* mem-break.h: Fix common/ includes.
	* lynx-low.c: Fix common/ includes.
	* lynx-i386-low.c: Fix common/ includes.
	* linux-x86-tdesc-selftest.c: Fix common/ includes.
	* linux-x86-low.c: Fix common/ includes.
	* linux-low.c: Fix common/ includes.
	* inferiors.h: Fix common/ includes.
	* i387-fp.c: Fix common/ includes.
	* hostio.c: Fix common/ includes.
	* hostio-errno.c: Fix common/ includes.
	* gdbthread.h: Fix common/ includes.
	* gdbreplay.c: Fix common/ includes.
	* fork-child.c: Fix common/ includes.
	* event-loop.c: Fix common/ includes.
	* ax.c:
	(enum gdb_agent_op): Fix common/ includes.
2019-01-25 15:28:16 -07:00
Joel Brobecker 42a4f53d2b Update copyright year range in all GDB files.
This commit applies all changes made after running the gdb/copyright.py
script.

Note that one file was flagged by the script, due to an invalid
copyright header
(gdb/unittests/basic_string_view/element_access/char/empty.cc).
As the file was copied from GCC's libstdc++-v3 testsuite, this commit
leaves this file untouched for the time being; a patch to fix the header
was sent to gcc-patches first.

gdb/ChangeLog:

	Update copyright year range in all GDB files.
2019-01-01 10:01:51 +04:00
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04:00
Simon Marchi c0e15c9bfd Remove for_each_inferior_with_data
Remove for_each_inferior_with_data, replacing its sole usage with
for_each_thread.

gdb/gdbserver/ChangeLog:

	* inferiors.c (for_each_inferior_with_data): Remove.
	* inferiors.h (for_each_inferior_with_data): Remove.
	* server.c (handle_qxfer_threads_worker): Change parameter type.
	(handle_qxfer_threads_proper): Use for_each_thread.
2017-12-02 20:38:37 -05:00
Simon Marchi f004534791 Remove for_each_inferior
This patch removes for_each_inferior, replacing all its usages with
for_each_thread.

gdb/gdbserver/ChangeLog:

	* inferiors.c (for_each_inferior): Remove.
	(clear_inferiors): Use for_each_thread.
	* inferiors.h (for_each_inferior): Remove.
	* linux-low.c (linux_wait_for_event_filtered): Use
	for_each_thread.
	(linux_stabilize_threads): Likewise.
	* regcache.c (regcache_release): Likewise.
	* server.c (gdb_wants_all_threads_stopped): Likewise.
	(clear_pending_status_callback): Remove.
	(handle_status): Use for_each_thread.
	(captured_main): Likewise.
	* win32-low.c (child_init_thread_list): Likewise.
	(win32_clear_inferiors): Likewise.
	(fake_breakpoint_event): Likewise.
2017-12-02 20:37:53 -05:00
Simon Marchi 9521758bf9 Remove find_inferior
All the usages of find_inferior were removed, so the function itself can
be removed.

gdb/gdbserver/ChangeLog:

	* inferiors.h (find_inferior): Remove.
	* inferiors.c (find_inferior): Remove.
2017-12-02 20:36:45 -05:00
Simon Marchi 83e1b6c13a Remove find_inferior_in_random
Replace with find_thread_in_random.

gdb/gdbserver/ChangeLog:

	* inferiors.c (find_inferior_in_random): Remove.
	* inferiors.h (find_inferior_in_random): Remove.
	* linux-low.c (status_pending_p_callback): Return bool, accept
	parameter ptid directly.
	(linux_wait_for_event_filtered): Use find_thread_in_random.
	(linux_wait_1): Likewise.
2017-12-02 20:36:35 -05:00
Simon Marchi 8dc7b443a6 Remove find_inferior_id
Remove find_inferior_id, replacing its usages with find_thread_ptid.
find_thread_ptid was implemented using find_inferior_id, so move the
implementation there instead.

gdb/gdbserver/ChangeLog:

	* inferiors.c (find_inferior_id): Remove.
	(find_thread_ptid): Move implemention from find_inferior_id to
	here.
	* inferiors.h (find_inferior_id): Remove.
	* server.c (handle_status): Use find_thread_ptid.
	(process_serial_event): Likewise.
	* thread-db.c (find_one_thread): Likewise.
	(thread_db_thread_handle): Likewise.
	* win32-low.c (thread_rec): Likewise.
	(child_delete_thread): Likewise.
	(win32_thread_alive): Likewise.
	(get_child_debug_event): Likewise.
2017-12-02 20:36:34 -05:00
Simon Marchi f27866ba9c Make process_info::syscalls_to_catch an std::vector
This patch makes the syscalls_to_catch field of process_info an
std::vector<int>.  The process_info structure must now be
newed/deleted.

In handle_extended_wait, the code that handles exec events destroys the
existing process_info and creates a new one.  It moves the content of
syscalls_to_catch from the old to the new vector.  I used std::move for
that (through an intermediary variable), which should have the same
behavior as the old code.

gdb/gdbserver/ChangeLog:

	* inferiors.h (struct process_info): Add constructor, initialize
	fields..
	<syscalls_to_catch>: Change type to std::vector<int>.
	* inferiors.c (add_process): Allocate process_info with new.
	(remove_process): Free process_info with delete.
	* linux-low.c (handle_extended_wait): Adjust.
	(gdb_catching_syscalls_p, gdb_catch_this_syscall_p): Adjust.
	* server.c (handle_general_set): Adjust.
2017-11-17 13:03:34 -05:00
Simon Marchi 9c80ecd646 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 09:11:12 -04:00
Simon Marchi 9179355e65 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 09:10:42 -04:00
Simon Marchi 124aceb46d gdbserver: Remove thread_to_gdb_id
As explained in the previous patch, the gdb_id concept is no longer
relevant.  The function thread_to_gdb_id is trivial, it returns the
thread's ptid.  Remove it and replace its usage with ptid_of.

The changes in nto-low.c and lynx-low.c are fairly straightforward, but
I was not able to build test them.

gdb/gdbserver/ChangeLog:

	* inferiors.h (thread_to_gdb_id): Remove.
	* inferiors.c (thread_to_gdb_id): Remove.
	* server.c (handle_qxfer_threads_worker, handle_query): Adjust.
	* lynx-low.c (lynx_resume, lynx_wait_1, lynx_fetch_registers,
	lynx_store_registers, lynx_read_memory, lynx_write_memory):
	Likewise.
	* nto-low.c (nto_fetch_registers, nto_store_registers,
	nto_stopped_by_watchpoint, nto_stopped_data_address): Likewise.
2017-09-15 18:02:51 +02:00
Simon Marchi 96cde54f0a gdbserver: Remove gdb_id_to_thread_id
From what I understand, this function is not doing anything useful as of
today.

Here's the result of my archeological research:

- The field thread_info::gdb_id was added in

  a06660f7  Use LWP IDs for thread IDs in gdbserver

  There was problem when using a 32-bits gdb with a 64-bits gdbserver.
  For some reason that I don't fully understand, the thread ids
  exchanged between gdb and gdbserver could overflow a 32 bits data
  type.  My guess is that they were the thread address (e.g. the
  0x7ffff7f20b40 in "Thread 0x7ffff7f20b40 (LWP 1058)" today).  This
  patch changed that so gdb/gdbserver would talk in terms of the OS
  assigned numerical id (as shown in ps).  It therefore added a way to
  convert between this gdb_id (the numerical id) and the thread id (the
  address).

- 95954743cb  Implement the multiprocess extensions, and add linux
              multiprocess supportNon-stop mode support.

  This patch made gdbserver deal with threads using their numerical ids
  and not the address-like id.  Starting from there, the gdb_id <->
  thread id conversion was not needed anymore, since the remote protocol
  and gdbserver were using the same kind of ids again.  The gdb_id field
  in the thread_info structure was also unused starting there.

- d50171e4  Teach linux gdbserver to step-over-breakpoints.

  This patch moved the thread_info structure around, and got rid of the
  gdb_id field (which was unused).

Looking at the implementation of gdb_id_to_thread_id, it is not doing
anything useful.  It is looking up a thread by ptid using
find_thread_ptid, which basically loops over all threads looking at
their entry.id field.  If a thread with that ptid is found, it returns
its entry.id field.  So it will always return the same thing as it input
(with the exception of if no thread exist with that ptid, then it will
return null_ptid).

gdb/gdbserver/ChangeLog:

	* inferiors.h (gdb_id_to_thread_id): Remove.
	* inferiors.c (gdb_id_to_thread_id): Remove.
	* server.c (process_serial_event): Adjust to gdb_id_to_thread_id
	removal.  Move pid declaration closer to where it's used.
2017-09-15 18:02:51 +02:00
Simon Marchi 6afd337d1a gdbserver: Rename some functions, thread -> inferior
These functions apply to thread, and not inferiors (in the gdbserver
sense, the abstraction for threads and processes, as in
inferior_list).  Therefore, it would make more sense if these functions
were named with "thread" rather than "inferior".

gdb/gdbserver/ChangeLog:

	* inferiors.h (inferior_target_data): Rename to ...
	(thread_target_data): ... this.
	(inferior_regcache_data): Rename to ...
	(thread_regcache_data): ... this.
	(set_inferior_regcache_data): Rename to ...
	(set_thread_regcache_data): ... this.
	* inferiors.c (inferior_target_data): Rename to ...
	(thread_target_data): ... this.
	(inferior_regcache_data): Rename to ...
	(thread_regcache_data): ... this.
	(set_inferior_regcache_data): Rename to ...
	(set_thread_regcache_data): ... this.
	(free_one_thread): Update.
	* linux-low.h (get_thread_lwp): Update.
	* regcache.c (get_thread_regcache): Update.
	(regcache_invalidate_thread): Update.
	(free_register_cache_thread): Update.
	* win32-i386-low.c (update_debug_registers_callback): Update.
	(win32_get_current_dr): Update.
	* win32-low.c (thread_rec): Update.
	(delete_thread_info): Update.
	(continue_one_thread): Update.
	(suspend_one_thread): Update.
2017-08-25 10:45:33 +02:00
Simon Marchi a160cc4628 Remove unused function set_inferior_target_data
The inferior (thread) target data is always set through add_thread.

gdb/gdbserver/ChangeLog:

	* inferiors.c (set_inferior_target_data): Remove.
	* inferiors.h (set_inferior_target_data): Remove.
2017-08-24 23:34:43 +02:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Yao Qi 8934261877 Get pending events in random
Nowadays, we select events to be reported to GDB in random, however
that is not enough when many GDBserver internal events (not reported
to GDB) are generated.

GDBserver pulls all events out of kernel via waitpid, and leave them
pending.  When goes through threads which have pending events,
GDBserver uses find_inferior to find the first thread which has
pending event, and consumes it.  Note that find_inferior always
iterate threads in a fixed order.  If multiple threads keep hitting
GDBserver breakpoints, range stepping with single-step breakpoint for
example, threads in the head of the thread list are more likely to be
processed and threads in the tail are starved.  This causes some timeout
fails in gdb.threads/non-stop-fair-events.exp when range stepping is
enabled on arm-linux.

This patch fixes this issue by randomly selecting pending events.  It
adds a new function find_inferior_in_random, which iterates threads
which have pending events randomly.

gdb/gdbserver:

2016-10-27  Yao Qi  <yao.qi@linaro.org>

	* inferiors.c (find_inferior_in_random): New function.
	* inferiors.h (find_inferior_in_random): Declare.
	* linux-low.c (linux_wait_for_event_filtered): Call
	find_inferior_in_random instead of find_inferior.
2016-10-27 16:05:06 +01:00
Yao Qi 63c40ec727 Refactor clone_all_breakpoints
This patch is to change the interface of clone_all_breakpoints, from
lists of breakpoints and raw_breakpoints to child thread and parent
thread.  I choose child thread to pass because we need the ptid of
the child thread in the following patch.

gdb/gdbserver:

2016-07-21  Yao Qi  <yao.qi@linaro.org>

	* inferiors.c (get_thread_process): Make parameter const.
	* inferiors.h (get_thread_process): Update declaration.
	* mem-break.c (clone_all_breakpoints): Remove all parameters.
	Add new parameters child_thread and parent_thread.  Callers
	updated.
	* mem-break.h (clone_all_breakpoints): Update declaration.
2016-07-21 12:12:18 +01:00
Josh Stone 82075af2c1 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 12:27:27 -08:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Pedro Alves 3d40fbb53b gdbserver crashes when multiprocess extensions aren't supported
Ref: https://sourceware.org/ml/gdb-patches/2015-08/msg00675.html

If multiprocess extensions are off (because specific gdbserver port
doesn't support them), then when gdbserver doesn't have a thread
selected yet, and GDB sends Hg packet to select one, gdbserver
crashes.  That's because extracting the desired thread id out of the
packet that GDB sent depends on the current thread to fill in the
missing process id ...  Fix this by getting the process id from the
first (and only) process in the processes list instead.

The GNU/Linux port doesn't trip on this because it always runs with
multiprocess extensions enabled.  To make it easier to catch such
regressions going forward, this commit also adds a new smoke test that
spawns gdbserver, connects to it and runs to main with the
multiprocess extensions force-disabled.

gdb/gdbserver/ChangeLog:
2015-08-24  Pedro Alves  <palves@redhat.com>

	* inferiors.c (get_first_process): New function.
	* inferiors.h (get_first_process): New declaration.
	* remote-utils.c (read_ptid): Default to the first process in the
	list, instead of to the current thread's process.

gdb/testsuite/ChangeLog:
2015-08-24  Pedro Alves  <palves@redhat.com>

	* gdb.server/connect-without-multi-process.c: New file.
	* gdb.server/connect-without-multi-process.exp: New file.
2015-08-24 19:58:31 +01:00
Pedro Alves a44892be35 gdbserver: no point in hiding the regcache type nowadays
The regcache used to be hidden inside inferiors.c, but since the
tracepoints support that it's a first class object.  This also fixes a
few implicit pointer conversion errors in C++ mode, caused by a few
places missing the explicit cast.

gdb/gdbserver/ChangeLog:
2015-08-06  Pedro Alves  <palves@redhat.com>

	* gdbthread.h (struct regcache): Forward declare.
	(struct thread_info) <regcache_data>: Now a struct regcache
	pointer.
	* inferiors.c (inferior_regcache_data)
	(set_inferior_regcache_data): Now work with struct regcache
	pointers.
	* inferiors.h (struct regcache): Forward declare.
	(inferior_regcache_data, set_inferior_regcache_data): Now work
	with struct regcache pointers.
	* regcache.c (get_thread_regcache, regcache_invalidate_thread)
	(free_register_cache_thread): Remove struct regcache pointer
	casts.
2015-08-06 17:29:01 +01:00
Pedro Alves fe978cb071 C++ keyword cleanliness, mostly auto-generated
This patch renames symbols that happen to have names which are
reserved keywords in C++.

Most of this was generated with Tromey's cxx-conversion.el script.
Some places where later hand massaged a bit, to fix formatting, etc.
And this was rebased several times meanwhile, along with re-running
the script, so re-running the script from scratch probably does not
result in the exact same output.  I don't think that matters anyway.

gdb/
2015-02-27  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	Rename symbols whose names are reserved C++ keywords throughout.

gdb/gdbserver/
2015-02-27  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	Rename symbols whose names are reserved C++ keywords throughout.
2015-02-27 16:33:07 +00:00
Joel Brobecker 32d0add0a6 Update year range in copyright notice of all files owned by the GDB project.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2015-01-01 13:32:14 +04:00
Gary Benson 0bfdf32fa1 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-16 15:57:13 +01:00
Pedro Alves fa96cb382c 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 14:30:08 +00:00
Doug Evans d86d4aafd4 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 12:25:18 -08:00
Doug Evans 649ebbcaef Replace code accessing list implementation details with API calls.
* dll.c (clear_dlls): Replace accessing list implemention details
	with API function.
	* gdbthread.h (get_first_thread): Declare.
	* inferiors.c (for_each_inferior_with_data): New function.
	(get_first_thread): New function.
	(find_thread_ptid): Simplify.
	(get_first_inferior): New function.
	(clear_list): Delete.
	(one_inferior_p): New function.
	(clear_inferior_list): New function.
	(clear_inferiors): Update.
	* inferiors.h (for_each_inferior_with_data): Declare.
	(clear_inferior_list): Declare.
	(one_inferior_p): Declare.
	(get_first_inferior): Declare.
	* linux-low.c (linux_wait_for_event): Replace accessing list
	implemention details with API function.
	* server.c (target_running): Ditto.
	(accumulate_file_name_length): New function.
	(emit_dll_description): New function.
	(handle_qxfer_libraries): Replace accessing list implemention
	details with API function.
	(handle_qxfer_threads_worker): New function.
	(handle_qxfer_threads_proper): Replace accessing list implemention
	details with API function.
	(handle_query): Ditto.
	(visit_actioned_threads_callback_ftype): New typedef.
	(visit_actioned_threads_data): New struct.
	(visit_actioned_threads): Rewrite to be find_inferior callback.
	(resume): Call find_inferior.
	(handle_status): Replace accessing list implemention
	details with API function.
	(process_serial_event): Replace accessing list implemention details
	with API function.
	* target.c (set_desired_inferior): Replace accessing list implemention
	details with API function.
	* tracepoint.c (same_process_p): New function.
	(gdb_agent_about_to_close): Replace accessing list implemention
	details with API function.
	* win32-low.c (child_delete_thread): Replace accessing list
	implemention details with API function.
	(match_dll_by_basename): New function.
	(dll_is_loaded_by_basename): New function.
	(win32_ensure_ntdll_loaded): Replace accessing list implemention
	details call to dll_is_loaded_by_basename.
2014-02-19 15:30:38 -08:00
Doug Evans 80894984a6 Rename inferior_list_entry uses from "head" to "entry" for consistency.
* dll.h (struct dll_info): Add comment.
	* gdbthread.h (struct thread_info): Add comment.
	(current_ptid): Simplify.
	* inferiors.c (add_process): Update.
	(remove_process): Update.
	* inferiors.h (struct process_info): Rename member "head" to "entry".
	* linux-low.c (delete_lwp): Update.
	(add_lwp): Update.
	(last_thread_of_process_p): Update.
	(kill_one_lwp_callback, linux_kill): Update.
	(status_pending_p_callback): Update.
	(wait_for_sigstop): Update.  Simplify read of ptid.
	(start_step_over): Update.
	* linux-low.h (ptid_of, pid_of, lwpid_of): Update.
	(get_lwp_thread): Update.
	(struct lwp_info): Rename member "head" to "entry".
	* regcache.h (inferior_list_entry): Delete.
	* server.c (kill_inferior_callback): Update.
	(detach_or_kill_inferior_callback): Update.
	(print_started_pid): Update.
	(print_attached_pid): Update.
	(process_serial_event): Simplify read of ptid.
	* thread-db.c (thread_db_create_event): Update.
	(thread_db_get_tls_address): Update.
	* win32-low.c (current_inferior_ptid): Simplify.
2014-02-19 14:51:55 -08:00
Doug Evans ab7f45ba10 delete thread_id_to_gdb_id, unused
* inferiors.c (thread_id_to_gdb_id): Delete.
	* inferiors.h (thread_id_to_gdb_id): Delete.
2014-01-15 16:35:37 -08:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Pedro Alves 270c6aeaf2 Add missing new files from these previous commits:
2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (handle_vFile, hostio_last_error_from_errno): Move
	to ...
	* hostio.h: ... this new file.
	* hostio.c, server.c, linux-low.c, nto-low.c, spu-low,
	win32-low.c: Include hostio.h.

2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (gdb_client_data, handler_func, callback_handler_func)
	(delete_file_handler, add_file_handler, append_callback_event)
	(delete_callback_event, start_event_loop, initialize_event_loop):
	Move to event-loop.h and include it.
	* event-loop.h: New file.

2013-09-05  Pedro Alves  <palves@redhat.com>

	* dll.c, inferiors.c, remote-utils.c, server.c: Include "dll.h".
	* server.h (struct dll_info, all_dlls, dlls_changed, clear_dlls)
	(loaded_dll, unloaded_dll): Move to ...
	* dll.h: ... this new file.
	* inferiors.c, remote-utils.c, win32-low.c: Include "dll.h".

2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (current_process, get_thread_process, all_processes)
	(add_inferior_to_list, for_each_inferior, current_inferior)
	(remove_inferior, add_process, remove_process, find_process_pid)
	(have_started_inferiors_p, have_attached_inferiors_p)
	(thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id)
	(clear_inferiors, find_inferior, find_inferior_id)
	(inferior_target_data, set_inferior_target_data)
	(inferior_regcache_data, set_inferior_regcache_data): Move to
	inferiors.h, and include it.
	* inferiors.h: New file.

2013-09-05  Pedro Alves  <palves@redhat.com>

	* ax.c, linux-low.c, linux-x86-low.c, server.c: Include
	tracepoint.h.
	* server.h (IPA_BUFSIZ, initialize_tracepoint, tracing)
	(disconnected_tracing, tracepoint_look_up_symbols, stop_tracing
	(handle_tracepoint_general_set, handle_tracepoint_query)
	(tracepoint_finished_step, tracepoint_was_hit)
	(release_while_stepping_state_list, current_traceframe)
	(in_readonly_region, traceframe_read_mem)
	(fetch_traceframe_registers, traceframe_read_sdata)
	(traceframe_read_info, struct fast_tpoint_collect_status)
	(fast_tracepoint_collecting, force_unlock_trace_buffer)
	(handle_tracepoit_bkpts, initialize_low_tracepoint)
	(supply_fast_tracepoint_registers)
	(supply_static_tracepoint_registers, set_trampoline_buffer_space)
	(ipa_tdesc, claim_trampoline_space)
	(have_fast_tracepoint_trampoline_buffer, gdb_agent_about_to_close)
	(agent_mem_read, agent_get_trace_state_variable_value)
	(agent_set_trace_state_variable_value, agent_tsv_read)
	(agent_mem_read_string, get_raw_reg_func_addr)
	(get_get_tsv_func_addr, get_set_tsv_func_addr): Move to ...
	* tracepoint.h: ... this new file.

2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (perror_with_name, error, fatal, warning, paddress)
	(pulongest, plongest, phex_nz, pfildes): Move to utils.h, and
	include it.
	* utils.h: New file.

2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (remote_debug, noack_mode, transport_is_reliable)
	(gdb_connected, STDIO_CONNECTION_NAME, remote_connection_is_stdio)
	(read_ptid, write_ptid, putpkt, putpkt_binary, putpkt_notif)
	(getpkt, remote_prepare, remote_open, remote_close, write_ok)
	(write_enn, initialize_async_io, enable_async_io)
	(disable_async_io, check_remote_input_interrupt_request)
	(convert_ascii_to_int, convert_int_to_ascii, new_thread_notify)
	(dead_thread_notify, prepare_resume_reply)
	(decode_address_to_semicolon, decode_address, decode_m_packet)
	(decode_M_packet, decode_X_packet, decode_xfer_write)
	(decode_search_memory_packet, unhexify, hexify)
	(remote_escape_output, unpack_varlen_hex, clear_symbol_cache)
	(look_up_one_symbol, relocate_instruction)
	(monitor_output): Move to remote-utils.h, and include it.
	* remote-utils.h: New file.
2013-09-05 22:18:48 +00:00