Rename common to gdbsupport
authorTom Tromey <tom@tromey.com>
Mon, 6 May 2019 02:29:24 +0000 (20:29 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 9 Jul 2019 13:45:38 +0000 (07:45 -0600)
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.

597 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/aarch64-tdep.c
gdb/acinclude.m4
gdb/ada-lang.c
gdb/ada-lang.h
gdb/agent.c
gdb/alloc.c
gdb/amd64-darwin-tdep.c
gdb/amd64-dicos-tdep.c
gdb/amd64-fbsd-nat.c
gdb/amd64-fbsd-tdep.c
gdb/amd64-linux-nat.c
gdb/amd64-linux-tdep.c
gdb/amd64-nbsd-tdep.c
gdb/amd64-obsd-tdep.c
gdb/amd64-sol2-tdep.c
gdb/amd64-tdep.c
gdb/amd64-windows-tdep.c
gdb/arch-utils.c
gdb/arch/aarch64-insn.c
gdb/arch/aarch64.c
gdb/arch/aarch64.h
gdb/arch/amd64.c
gdb/arch/amd64.h
gdb/arch/arm-get-next-pcs.c
gdb/arch/arm-linux.c
gdb/arch/arm.c
gdb/arch/i386.c
gdb/arch/i386.h
gdb/arch/ppc-linux-common.c
gdb/arch/riscv.c
gdb/arch/riscv.h
gdb/arch/tic6x.c
gdb/arm-tdep.c
gdb/auto-load.c
gdb/auxv.c
gdb/ax-gdb.c
gdb/ax-general.c
gdb/ax.h
gdb/breakpoint.c
gdb/breakpoint.h
gdb/btrace.c
gdb/btrace.h
gdb/build-id.c
gdb/build-id.h
gdb/c-lang.h
gdb/charset.c
gdb/charset.h
gdb/cli/cli-cmds.c
gdb/cli/cli-cmds.h
gdb/cli/cli-decode.c
gdb/cli/cli-dump.c
gdb/cli/cli-option.h
gdb/cli/cli-script.c
gdb/coff-pe-read.c
gdb/command.h
gdb/common/agent.c [deleted file]
gdb/common/agent.h [deleted file]
gdb/common/array-view.h [deleted file]
gdb/common/ax.def [deleted file]
gdb/common/break-common.h [deleted file]
gdb/common/btrace-common.c [deleted file]
gdb/common/btrace-common.h [deleted file]
gdb/common/buffer.c [deleted file]
gdb/common/buffer.h [deleted file]
gdb/common/byte-vector.h [deleted file]
gdb/common/cleanups.c [deleted file]
gdb/common/cleanups.h [deleted file]
gdb/common/common-debug.c [deleted file]
gdb/common/common-debug.h [deleted file]
gdb/common/common-defs.h [deleted file]
gdb/common/common-exceptions.c [deleted file]
gdb/common/common-exceptions.h [deleted file]
gdb/common/common-gdbthread.h [deleted file]
gdb/common/common-inferior.h [deleted file]
gdb/common/common-regcache.c [deleted file]
gdb/common/common-regcache.h [deleted file]
gdb/common/common-types.h [deleted file]
gdb/common/common-utils.c [deleted file]
gdb/common/common-utils.h [deleted file]
gdb/common/common.host [deleted file]
gdb/common/common.m4 [deleted file]
gdb/common/create-version.sh [deleted file]
gdb/common/def-vector.h [deleted file]
gdb/common/default-init-alloc.h [deleted file]
gdb/common/enum-flags.h [deleted file]
gdb/common/environ.c [deleted file]
gdb/common/environ.h [deleted file]
gdb/common/errors.c [deleted file]
gdb/common/errors.h [deleted file]
gdb/common/fileio.c [deleted file]
gdb/common/fileio.h [deleted file]
gdb/common/filestuff.c [deleted file]
gdb/common/filestuff.h [deleted file]
gdb/common/filtered-iterator.h [deleted file]
gdb/common/format.c [deleted file]
gdb/common/format.h [deleted file]
gdb/common/forward-scope-exit.h [deleted file]
gdb/common/function-view.h [deleted file]
gdb/common/gdb_assert.h [deleted file]
gdb/common/gdb_locale.h [deleted file]
gdb/common/gdb_optional.h [deleted file]
gdb/common/gdb_proc_service.h [deleted file]
gdb/common/gdb_ref_ptr.h [deleted file]
gdb/common/gdb_setjmp.h [deleted file]
gdb/common/gdb_signals.h [deleted file]
gdb/common/gdb_splay_tree.h [deleted file]
gdb/common/gdb_string_view.h [deleted file]
gdb/common/gdb_string_view.tcc [deleted file]
gdb/common/gdb_sys_time.h [deleted file]
gdb/common/gdb_tilde_expand.c [deleted file]
gdb/common/gdb_tilde_expand.h [deleted file]
gdb/common/gdb_unique_ptr.h [deleted file]
gdb/common/gdb_unlinker.h [deleted file]
gdb/common/gdb_vecs.c [deleted file]
gdb/common/gdb_vecs.h [deleted file]
gdb/common/gdb_wait.h [deleted file]
gdb/common/hash_enum.h [deleted file]
gdb/common/host-defs.h [deleted file]
gdb/common/job-control.c [deleted file]
gdb/common/job-control.h [deleted file]
gdb/common/mingw-strerror.c [deleted file]
gdb/common/netstuff.c [deleted file]
gdb/common/netstuff.h [deleted file]
gdb/common/new-op.c [deleted file]
gdb/common/next-iterator.h [deleted file]
gdb/common/observable.h [deleted file]
gdb/common/offset-type.h [deleted file]
gdb/common/pathstuff.c [deleted file]
gdb/common/pathstuff.h [deleted file]
gdb/common/poison.h [deleted file]
gdb/common/posix-strerror.c [deleted file]
gdb/common/preprocessor.h [deleted file]
gdb/common/print-utils.c [deleted file]
gdb/common/print-utils.h [deleted file]
gdb/common/ptid.c [deleted file]
gdb/common/ptid.h [deleted file]
gdb/common/refcounted-object.h [deleted file]
gdb/common/rsp-low.c [deleted file]
gdb/common/rsp-low.h [deleted file]
gdb/common/run-time-clock.c [deleted file]
gdb/common/run-time-clock.h [deleted file]
gdb/common/safe-iterator.h [deleted file]
gdb/common/scope-exit.h [deleted file]
gdb/common/scoped_fd.h [deleted file]
gdb/common/scoped_mmap.c [deleted file]
gdb/common/scoped_mmap.h [deleted file]
gdb/common/scoped_restore.h [deleted file]
gdb/common/selftest.c [deleted file]
gdb/common/selftest.h [deleted file]
gdb/common/signals-state-save-restore.c [deleted file]
gdb/common/signals-state-save-restore.h [deleted file]
gdb/common/signals.c [deleted file]
gdb/common/symbol.h [deleted file]
gdb/common/tdesc.c [deleted file]
gdb/common/tdesc.h [deleted file]
gdb/common/traits.h [deleted file]
gdb/common/underlying.h [deleted file]
gdb/common/valid-expr.h [deleted file]
gdb/common/vec.c [deleted file]
gdb/common/vec.h [deleted file]
gdb/common/version.h [deleted file]
gdb/common/x86-xstate.h [deleted file]
gdb/common/xml-utils.c [deleted file]
gdb/common/xml-utils.h [deleted file]
gdb/compile/compile-c-support.c
gdb/compile/compile-c.h
gdb/compile/compile-cplus-symbols.c
gdb/compile/compile-cplus-types.c
gdb/compile/compile-cplus.h
gdb/compile/compile-loc2c.c
gdb/compile/compile.c
gdb/completer.c
gdb/completer.h
gdb/configure
gdb/configure.ac
gdb/contrib/ari/gdb_ari.sh
gdb/corefile.c
gdb/corelow.c
gdb/cp-support.c
gdb/cp-support.h
gdb/cp-valprint.c
gdb/csky-tdep.c
gdb/ctf.c
gdb/darwin-nat.c
gdb/debug.c
gdb/defs.h
gdb/disasm-selftests.c
gdb/disasm.c
gdb/disasm.h
gdb/dtrace-probe.c
gdb/dwarf-index-cache.c
gdb/dwarf-index-cache.h
gdb/dwarf-index-write.c
gdb/dwarf2-frame.c
gdb/dwarf2expr.c
gdb/dwarf2loc.c
gdb/dwarf2read.c
gdb/dwarf2read.h
gdb/event-loop.c
gdb/event-top.c
gdb/exceptions.c
gdb/exec.c
gdb/extension.h
gdb/fbsd-nat.c
gdb/features/aarch64-core.c
gdb/features/aarch64-fpu.c
gdb/features/aarch64-pauth.c
gdb/features/aarch64-sve.c
gdb/features/i386/32bit-avx.c
gdb/features/i386/32bit-avx512.c
gdb/features/i386/32bit-core.c
gdb/features/i386/32bit-linux.c
gdb/features/i386/32bit-mpx.c
gdb/features/i386/32bit-pkeys.c
gdb/features/i386/32bit-segments.c
gdb/features/i386/32bit-sse.c
gdb/features/i386/64bit-avx.c
gdb/features/i386/64bit-avx512.c
gdb/features/i386/64bit-core.c
gdb/features/i386/64bit-linux.c
gdb/features/i386/64bit-mpx.c
gdb/features/i386/64bit-pkeys.c
gdb/features/i386/64bit-segments.c
gdb/features/i386/64bit-sse.c
gdb/features/i386/x32-core.c
gdb/features/riscv/32bit-cpu.c
gdb/features/riscv/32bit-csr.c
gdb/features/riscv/32bit-fpu.c
gdb/features/riscv/64bit-cpu.c
gdb/features/riscv/64bit-csr.c
gdb/features/riscv/64bit-fpu.c
gdb/features/tic6x-c6xp.c
gdb/features/tic6x-core.c
gdb/features/tic6x-gp.c
gdb/filename-seen-cache.h
gdb/findcmd.c
gdb/findvar.c
gdb/fork-child.c
gdb/gcore.c
gdb/gdb_bfd.c
gdb/gdb_bfd.h
gdb/gdb_proc_service.h
gdb/gdb_regex.c
gdb/gdb_select.h
gdb/gdb_usleep.c
gdb/gdbarch-selftests.c
gdb/gdbserver/ChangeLog
gdb/gdbserver/Makefile.in
gdb/gdbserver/acinclude.m4
gdb/gdbserver/ax.c
gdb/gdbserver/configure
gdb/gdbserver/configure.ac
gdb/gdbserver/event-loop.c
gdb/gdbserver/fork-child.c
gdb/gdbserver/gdb_proc_service.h
gdb/gdbserver/gdbreplay.c
gdb/gdbserver/gdbthread.h
gdb/gdbserver/hostio-errno.c
gdb/gdbserver/hostio.c
gdb/gdbserver/i387-fp.c
gdb/gdbserver/inferiors.c
gdb/gdbserver/inferiors.h
gdb/gdbserver/linux-amd64-ipa.c
gdb/gdbserver/linux-i386-ipa.c
gdb/gdbserver/linux-low.c
gdb/gdbserver/linux-tic6x-low.c
gdb/gdbserver/linux-x86-low.c
gdb/gdbserver/linux-x86-tdesc.c
gdb/gdbserver/lynx-i386-low.c
gdb/gdbserver/lynx-low.c
gdb/gdbserver/mem-break.h
gdb/gdbserver/nto-x86-low.c
gdb/gdbserver/regcache.c
gdb/gdbserver/regcache.h
gdb/gdbserver/remote-utils.c
gdb/gdbserver/server.c
gdb/gdbserver/server.h
gdb/gdbserver/spu-low.c
gdb/gdbserver/symbol.c
gdb/gdbserver/target.h
gdb/gdbserver/tdesc.c
gdb/gdbserver/tdesc.h
gdb/gdbserver/thread-db.c
gdb/gdbserver/tracepoint.c
gdb/gdbserver/win32-i386-low.c
gdb/gdbserver/win32-low.c
gdb/gdbsupport/agent.c [new file with mode: 0644]
gdb/gdbsupport/agent.h [new file with mode: 0644]
gdb/gdbsupport/array-view.h [new file with mode: 0644]
gdb/gdbsupport/ax.def [new file with mode: 0644]
gdb/gdbsupport/break-common.h [new file with mode: 0644]
gdb/gdbsupport/btrace-common.c [new file with mode: 0644]
gdb/gdbsupport/btrace-common.h [new file with mode: 0644]
gdb/gdbsupport/buffer.c [new file with mode: 0644]
gdb/gdbsupport/buffer.h [new file with mode: 0644]
gdb/gdbsupport/byte-vector.h [new file with mode: 0644]
gdb/gdbsupport/cleanups.c [new file with mode: 0644]
gdb/gdbsupport/cleanups.h [new file with mode: 0644]
gdb/gdbsupport/common-debug.c [new file with mode: 0644]
gdb/gdbsupport/common-debug.h [new file with mode: 0644]
gdb/gdbsupport/common-defs.h [new file with mode: 0644]
gdb/gdbsupport/common-exceptions.c [new file with mode: 0644]
gdb/gdbsupport/common-exceptions.h [new file with mode: 0644]
gdb/gdbsupport/common-gdbthread.h [new file with mode: 0644]
gdb/gdbsupport/common-inferior.h [new file with mode: 0644]
gdb/gdbsupport/common-regcache.c [new file with mode: 0644]
gdb/gdbsupport/common-regcache.h [new file with mode: 0644]
gdb/gdbsupport/common-types.h [new file with mode: 0644]
gdb/gdbsupport/common-utils.c [new file with mode: 0644]
gdb/gdbsupport/common-utils.h [new file with mode: 0644]
gdb/gdbsupport/common.host [new file with mode: 0644]
gdb/gdbsupport/common.m4 [new file with mode: 0644]
gdb/gdbsupport/create-version.sh [new file with mode: 0755]
gdb/gdbsupport/def-vector.h [new file with mode: 0644]
gdb/gdbsupport/default-init-alloc.h [new file with mode: 0644]
gdb/gdbsupport/enum-flags.h [new file with mode: 0644]
gdb/gdbsupport/environ.c [new file with mode: 0644]
gdb/gdbsupport/environ.h [new file with mode: 0644]
gdb/gdbsupport/errors.c [new file with mode: 0644]
gdb/gdbsupport/errors.h [new file with mode: 0644]
gdb/gdbsupport/fileio.c [new file with mode: 0644]
gdb/gdbsupport/fileio.h [new file with mode: 0644]
gdb/gdbsupport/filestuff.c [new file with mode: 0644]
gdb/gdbsupport/filestuff.h [new file with mode: 0644]
gdb/gdbsupport/filtered-iterator.h [new file with mode: 0644]
gdb/gdbsupport/format.c [new file with mode: 0644]
gdb/gdbsupport/format.h [new file with mode: 0644]
gdb/gdbsupport/forward-scope-exit.h [new file with mode: 0644]
gdb/gdbsupport/function-view.h [new file with mode: 0644]
gdb/gdbsupport/gdb_assert.h [new file with mode: 0644]
gdb/gdbsupport/gdb_locale.h [new file with mode: 0644]
gdb/gdbsupport/gdb_optional.h [new file with mode: 0644]
gdb/gdbsupport/gdb_proc_service.h [new file with mode: 0644]
gdb/gdbsupport/gdb_ref_ptr.h [new file with mode: 0644]
gdb/gdbsupport/gdb_setjmp.h [new file with mode: 0644]
gdb/gdbsupport/gdb_signals.h [new file with mode: 0644]
gdb/gdbsupport/gdb_splay_tree.h [new file with mode: 0644]
gdb/gdbsupport/gdb_string_view.h [new file with mode: 0644]
gdb/gdbsupport/gdb_string_view.tcc [new file with mode: 0644]
gdb/gdbsupport/gdb_sys_time.h [new file with mode: 0644]
gdb/gdbsupport/gdb_tilde_expand.c [new file with mode: 0644]
gdb/gdbsupport/gdb_tilde_expand.h [new file with mode: 0644]
gdb/gdbsupport/gdb_unique_ptr.h [new file with mode: 0644]
gdb/gdbsupport/gdb_unlinker.h [new file with mode: 0644]
gdb/gdbsupport/gdb_vecs.c [new file with mode: 0644]
gdb/gdbsupport/gdb_vecs.h [new file with mode: 0644]
gdb/gdbsupport/gdb_wait.h [new file with mode: 0644]
gdb/gdbsupport/hash_enum.h [new file with mode: 0644]
gdb/gdbsupport/host-defs.h [new file with mode: 0644]
gdb/gdbsupport/job-control.c [new file with mode: 0644]
gdb/gdbsupport/job-control.h [new file with mode: 0644]
gdb/gdbsupport/mingw-strerror.c [new file with mode: 0644]
gdb/gdbsupport/netstuff.c [new file with mode: 0644]
gdb/gdbsupport/netstuff.h [new file with mode: 0644]
gdb/gdbsupport/new-op.c [new file with mode: 0644]
gdb/gdbsupport/next-iterator.h [new file with mode: 0644]
gdb/gdbsupport/observable.h [new file with mode: 0644]
gdb/gdbsupport/offset-type.h [new file with mode: 0644]
gdb/gdbsupport/pathstuff.c [new file with mode: 0644]
gdb/gdbsupport/pathstuff.h [new file with mode: 0644]
gdb/gdbsupport/poison.h [new file with mode: 0644]
gdb/gdbsupport/posix-strerror.c [new file with mode: 0644]
gdb/gdbsupport/preprocessor.h [new file with mode: 0644]
gdb/gdbsupport/print-utils.c [new file with mode: 0644]
gdb/gdbsupport/print-utils.h [new file with mode: 0644]
gdb/gdbsupport/ptid.c [new file with mode: 0644]
gdb/gdbsupport/ptid.h [new file with mode: 0644]
gdb/gdbsupport/refcounted-object.h [new file with mode: 0644]
gdb/gdbsupport/rsp-low.c [new file with mode: 0644]
gdb/gdbsupport/rsp-low.h [new file with mode: 0644]
gdb/gdbsupport/run-time-clock.c [new file with mode: 0644]
gdb/gdbsupport/run-time-clock.h [new file with mode: 0644]
gdb/gdbsupport/safe-iterator.h [new file with mode: 0644]
gdb/gdbsupport/scope-exit.h [new file with mode: 0644]
gdb/gdbsupport/scoped_fd.h [new file with mode: 0644]
gdb/gdbsupport/scoped_mmap.c [new file with mode: 0644]
gdb/gdbsupport/scoped_mmap.h [new file with mode: 0644]
gdb/gdbsupport/scoped_restore.h [new file with mode: 0644]
gdb/gdbsupport/selftest.c [new file with mode: 0644]
gdb/gdbsupport/selftest.h [new file with mode: 0644]
gdb/gdbsupport/signals-state-save-restore.c [new file with mode: 0644]
gdb/gdbsupport/signals-state-save-restore.h [new file with mode: 0644]
gdb/gdbsupport/signals.c [new file with mode: 0644]
gdb/gdbsupport/symbol.h [new file with mode: 0644]
gdb/gdbsupport/tdesc.c [new file with mode: 0644]
gdb/gdbsupport/tdesc.h [new file with mode: 0644]
gdb/gdbsupport/traits.h [new file with mode: 0644]
gdb/gdbsupport/underlying.h [new file with mode: 0644]
gdb/gdbsupport/valid-expr.h [new file with mode: 0644]
gdb/gdbsupport/vec.c [new file with mode: 0644]
gdb/gdbsupport/vec.h [new file with mode: 0644]
gdb/gdbsupport/version.h [new file with mode: 0644]
gdb/gdbsupport/x86-xstate.h [new file with mode: 0644]
gdb/gdbsupport/xml-utils.c [new file with mode: 0644]
gdb/gdbsupport/xml-utils.h [new file with mode: 0644]
gdb/gdbthread.h
gdb/gdbtypes.h
gdb/gnu-nat.c
gdb/go32-nat.c
gdb/guile/guile.c
gdb/guile/scm-ports.c
gdb/guile/scm-safe-call.c
gdb/guile/scm-type.c
gdb/i386-fbsd-nat.c
gdb/i386-fbsd-tdep.c
gdb/i386-go32-tdep.c
gdb/i386-linux-nat.c
gdb/i386-linux-tdep.c
gdb/i386-tdep.c
gdb/i387-tdep.c
gdb/ia64-libunwind-tdep.c
gdb/ia64-linux-nat.c
gdb/inf-child.c
gdb/inf-ptrace.c
gdb/infcall.c
gdb/infcall.h
gdb/infcmd.c
gdb/inferior-iter.h
gdb/inferior.c
gdb/inferior.h
gdb/inflow.c
gdb/inflow.h
gdb/infrun.c
gdb/infrun.h
gdb/inline-frame.c
gdb/language.h
gdb/linespec.c
gdb/linux-fork.c
gdb/linux-nat.c
gdb/linux-tdep.c
gdb/linux-thread-db.c
gdb/location.c
gdb/machoread.c
gdb/macrotab.h
gdb/main.c
gdb/maint.c
gdb/maint.h
gdb/memattr.c
gdb/memrange.h
gdb/mi/mi-cmd-break.h
gdb/mi/mi-cmd-env.c
gdb/mi/mi-cmd-stack.c
gdb/mi/mi-cmd-var.c
gdb/mi/mi-interp.c
gdb/mi/mi-main.c
gdb/mi/mi-parse.h
gdb/minsyms.c
gdb/mips-linux-tdep.c
gdb/namespace.h
gdb/nat/aarch64-linux-hw-point.c
gdb/nat/aarch64-linux-hw-point.h
gdb/nat/aarch64-linux.c
gdb/nat/aarch64-sve-linux-ptrace.c
gdb/nat/amd64-linux-siginfo.c
gdb/nat/fork-inferior.c
gdb/nat/linux-btrace.c
gdb/nat/linux-btrace.h
gdb/nat/linux-namespaces.c
gdb/nat/linux-nat.h
gdb/nat/linux-osdata.c
gdb/nat/linux-personality.c
gdb/nat/linux-procfs.c
gdb/nat/linux-ptrace.c
gdb/nat/linux-ptrace.h
gdb/nat/linux-waitpid.c
gdb/nat/mips-linux-watch.c
gdb/nat/mips-linux-watch.h
gdb/nat/ppc-linux.c
gdb/nat/x86-dregs.c
gdb/nat/x86-dregs.h
gdb/nat/x86-linux-dregs.c
gdb/nat/x86-linux.c
gdb/nto-procfs.c
gdb/nto-tdep.c
gdb/objfile-flags.h
gdb/objfiles.c
gdb/objfiles.h
gdb/obsd-nat.c
gdb/observable.h
gdb/osdata.c
gdb/p-valprint.c
gdb/parse.c
gdb/parser-defs.h
gdb/ppc-linux-nat.c
gdb/printcmd.c
gdb/probe.c
gdb/proc-api.c
gdb/procfs.c
gdb/producer.c
gdb/progspace.h
gdb/psymtab.h
gdb/python/py-framefilter.c
gdb/python/py-inferior.c
gdb/python/py-ref.h
gdb/python/py-type.c
gdb/python/python.c
gdb/record-btrace.c
gdb/record-full.c
gdb/record.c
gdb/record.h
gdb/regcache-dump.c
gdb/regcache.c
gdb/regcache.h
gdb/remote-fileio.c
gdb/remote-fileio.h
gdb/remote-sim.c
gdb/remote.c
gdb/riscv-tdep.c
gdb/rs6000-aix-tdep.c
gdb/rust-exp.y
gdb/s12z-tdep.c
gdb/selftest-arch.c
gdb/ser-base.c
gdb/ser-event.c
gdb/ser-pipe.c
gdb/ser-tcp.c
gdb/ser-unix.c
gdb/skip.c
gdb/solib-aix.c
gdb/solib-target.c
gdb/solib.c
gdb/source-cache.c
gdb/source.c
gdb/source.h
gdb/sparc-nat.c
gdb/spu-linux-nat.c
gdb/stack.c
gdb/stap-probe.c
gdb/symfile-add-flags.h
gdb/symfile.c
gdb/symfile.h
gdb/symtab.c
gdb/symtab.h
gdb/target-descriptions.c
gdb/target-descriptions.h
gdb/target-memory.c
gdb/target.c
gdb/target.h
gdb/target/waitstatus.c
gdb/target/waitstatus.h
gdb/thread-iter.h
gdb/thread.c
gdb/tilegx-tdep.c
gdb/top.c
gdb/top.h
gdb/tracefile-tfile.c
gdb/tracefile.c
gdb/tracepoint.c
gdb/tracepoint.h
gdb/tui/tui-io.c
gdb/ui-file.c
gdb/ui-out.h
gdb/unittests/array-view-selftests.c
gdb/unittests/child-path-selftests.c
gdb/unittests/cli-utils-selftests.c
gdb/unittests/common-utils-selftests.c
gdb/unittests/copy_bitwise-selftests.c
gdb/unittests/environ-selftests.c
gdb/unittests/format_pieces-selftests.c
gdb/unittests/function-view-selftests.c
gdb/unittests/lookup_name_info-selftests.c
gdb/unittests/memory-map-selftests.c
gdb/unittests/memrange-selftests.c
gdb/unittests/mkdir-recursive-selftests.c
gdb/unittests/observable-selftests.c
gdb/unittests/offset-type-selftests.c
gdb/unittests/optional-selftests.c
gdb/unittests/parse-connection-spec-selftests.c
gdb/unittests/ptid-selftests.c
gdb/unittests/rsp-low-selftests.c
gdb/unittests/scoped_fd-selftests.c
gdb/unittests/scoped_mmap-selftests.c
gdb/unittests/scoped_restore-selftests.c
gdb/unittests/string_view-selftests.c
gdb/unittests/style-selftests.c
gdb/unittests/tracepoint-selftests.c
gdb/unittests/unpack-selftests.c
gdb/unittests/utils-selftests.c
gdb/unittests/xml-utils-selftests.c
gdb/utils.c
gdb/utils.h
gdb/valarith.c
gdb/valops.c
gdb/valprint.c
gdb/value.c
gdb/value.h
gdb/varobj.c
gdb/varobj.h
gdb/windows-nat.c
gdb/x86-linux-nat.c
gdb/xml-support.c
gdb/xml-support.h
gdb/xml-tdesc.h
gdb/xstormy16-tdep.c
gdb/xtensa-linux-nat.c

index 0ad7576c4b270bfb1c28f61df70387d05a6d3270..b1200e9a87b0be48a9304a13a764ef936b33222e 100644 (file)
@@ -1,3 +1,119 @@
+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.
+
 2019-07-09  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * linespec.c (decode_digits_list_mode): Set explicit_line to a
index 7308ea5767424b5bb095b531ed8f99a7d26465a5..b6680b9afd3d50b5165fb577ca94a4ae8e3373e1 100644 (file)
@@ -529,7 +529,7 @@ CONFIG_INSTALL = @CONFIG_INSTALL@
 CONFIG_UNINSTALL = @CONFIG_UNINSTALL@
 HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
 
-CONFIG_SRC_SUBDIR = arch cli mi common compile tui unittests guile python \
+CONFIG_SRC_SUBDIR = arch cli mi gdbsupport compile tui unittests guile python \
        target nat
 CONFIG_DEP_SUBDIR = $(addsuffix /$(DEPDIR),$(CONFIG_SRC_SUBDIR))
 
@@ -948,35 +948,35 @@ COMMON_SFILES = \
        cli-out.c \
        coff-pe-read.c \
        coffread.c \
-       common/agent.c \
-       common/btrace-common.c \
-       common/buffer.c \
-       common/cleanups.c \
-       common/common-debug.c \
-       common/common-exceptions.c \
-       common/common-regcache.c \
-       common/common-utils.c \
-       common/errors.c \
-       common/environ.c \
-       common/fileio.c \
-       common/filestuff.c \
-       common/format.c \
-       common/job-control.c \
-       common/gdb_tilde_expand.c \
-       common/gdb_vecs.c \
-       common/netstuff.c \
-       common/new-op.c \
-       common/pathstuff.c \
-       common/print-utils.c \
-       common/ptid.c \
-       common/rsp-low.c \
-       common/run-time-clock.c \
-       common/scoped_mmap.c \
-       common/signals.c \
-       common/signals-state-save-restore.c \
-       common/tdesc.c \
-       common/vec.c \
-       common/xml-utils.c \
+       gdbsupport/agent.c \
+       gdbsupport/btrace-common.c \
+       gdbsupport/buffer.c \
+       gdbsupport/cleanups.c \
+       gdbsupport/common-debug.c \
+       gdbsupport/common-exceptions.c \
+       gdbsupport/common-regcache.c \
+       gdbsupport/common-utils.c \
+       gdbsupport/errors.c \
+       gdbsupport/environ.c \
+       gdbsupport/fileio.c \
+       gdbsupport/filestuff.c \
+       gdbsupport/format.c \
+       gdbsupport/job-control.c \
+       gdbsupport/gdb_tilde_expand.c \
+       gdbsupport/gdb_vecs.c \
+       gdbsupport/netstuff.c \
+       gdbsupport/new-op.c \
+       gdbsupport/pathstuff.c \
+       gdbsupport/print-utils.c \
+       gdbsupport/ptid.c \
+       gdbsupport/rsp-low.c \
+       gdbsupport/run-time-clock.c \
+       gdbsupport/scoped_mmap.c \
+       gdbsupport/signals.c \
+       gdbsupport/signals-state-save-restore.c \
+       gdbsupport/tdesc.c \
+       gdbsupport/vec.c \
+       gdbsupport/xml-utils.c \
        complaints.c \
        completer.c \
        continuations.c \
@@ -1442,45 +1442,45 @@ HFILES_NO_SRCDIR = \
        cli/cli-setshow.h \
        cli/cli-style.h \
        cli/cli-utils.h \
-       common/buffer.h \
-       common/cleanups.h \
-       common/common-debug.h \
-       common/common-defs.h \
-       common/common-exceptions.h \
-       common/common-gdbthread.h \
-       common/common-regcache.h \
-       common/common-types.h \
-       common/common-utils.h \
-       common/job-control.h \
-       common/errors.h \
-       common/environ.h \
-       common/fileio.h \
-       common/format.h \
-       common/gdb_assert.h \
-       common/gdb_tilde_expand.h \
-       common/gdb_locale.h \
-       common/gdb_proc_service.h \
-       common/gdb_setjmp.h \
-       common/gdb_signals.h \
-       common/gdb_sys_time.h \
-       common/gdb_vecs.h \
-       common/gdb_wait.h \
-       common/common-inferior.h \
-       common/netstuff.h \
-       common/host-defs.h \
-       common/pathstuff.h \
-       common/print-utils.h \
-       common/ptid.h \
-       common/queue.h \
-       common/rsp-low.h \
-       common/run-time-clock.h \
-       common/signals-state-save-restore.h \
-       common/symbol.h \
-       common/tdesc.h \
-       common/vec.h \
-       common/version.h \
-       common/x86-xstate.h \
-       common/xml-utils.h \
+       gdbsupport/buffer.h \
+       gdbsupport/cleanups.h \
+       gdbsupport/common-debug.h \
+       gdbsupport/common-defs.h \
+       gdbsupport/common-exceptions.h \
+       gdbsupport/common-gdbthread.h \
+       gdbsupport/common-regcache.h \
+       gdbsupport/common-types.h \
+       gdbsupport/common-utils.h \
+       gdbsupport/job-control.h \
+       gdbsupport/errors.h \
+       gdbsupport/environ.h \
+       gdbsupport/fileio.h \
+       gdbsupport/format.h \
+       gdbsupport/gdb_assert.h \
+       gdbsupport/gdb_tilde_expand.h \
+       gdbsupport/gdb_locale.h \
+       gdbsupport/gdb_proc_service.h \
+       gdbsupport/gdb_setjmp.h \
+       gdbsupport/gdb_signals.h \
+       gdbsupport/gdb_sys_time.h \
+       gdbsupport/gdb_vecs.h \
+       gdbsupport/gdb_wait.h \
+       gdbsupport/common-inferior.h \
+       gdbsupport/netstuff.h \
+       gdbsupport/host-defs.h \
+       gdbsupport/pathstuff.h \
+       gdbsupport/print-utils.h \
+       gdbsupport/ptid.h \
+       gdbsupport/queue.h \
+       gdbsupport/rsp-low.h \
+       gdbsupport/run-time-clock.h \
+       gdbsupport/signals-state-save-restore.h \
+       gdbsupport/symbol.h \
+       gdbsupport/tdesc.h \
+       gdbsupport/vec.h \
+       gdbsupport/version.h \
+       gdbsupport/x86-xstate.h \
+       gdbsupport/xml-utils.h \
        compile/compile.h \
        compile/compile-c.h \
        compile/compile-cplus.h \
@@ -2109,8 +2109,8 @@ $(srcdir)/copying.c: @MAINTAINER_MODE_TRUE@ $(srcdir)/../COPYING3 $(srcdir)/copy
 version.c: stamp-version; @true
 # Note that the obvious names for the temp file are taken by
 # create-version.sh.
-stamp-version: Makefile version.in $(srcdir)/../bfd/version.h $(srcdir)/common/create-version.sh
-       $(ECHO_GEN) $(SHELL) $(srcdir)/common/create-version.sh $(srcdir) \
+stamp-version: Makefile version.in $(srcdir)/../bfd/version.h $(srcdir)/gdbsupport/create-version.sh
+       $(ECHO_GEN) $(SHELL) $(srcdir)/gdbsupport/create-version.sh $(srcdir) \
            $(host_alias) $(target_alias) version-t.t
        @$(SHELL) $(srcdir)/../move-if-change version-t.t version.c
        @echo stamp > stamp-version
@@ -2344,8 +2344,8 @@ ALLDEPFILES = \
        xtensa-linux-tdep.c \
        xtensa-tdep.c \
        xtensa-xtregs.c \
-       common/mingw-strerror.c \
-       common/posix-strerror.c
+       gdbsupport/mingw-strerror.c \
+       gdbsupport/posix-strerror.c
 
 # Some files need explicit build rules (due to -Werror problems) or due
 # to sub-directory fun 'n' games.
index 17f5e1ee4580f1a0104981924e0a5af9786bab9a..757465828a1bbdb732b792cea27d406599641841 100644 (file)
@@ -44,7 +44,7 @@
 #include "infcall.h"
 #include "ax.h"
 #include "ax-gdb.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 
 #include "aarch64-tdep.h"
 #include "aarch64-ravenscar-thread.h"
@@ -52,7 +52,7 @@
 #include "elf-bfd.h"
 #include "elf/aarch64.h"
 
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 
 #include "record.h"
 #include "record-full.h"
index 0719d422a71677ddb8d910942d97dd89690ee133..b32dcf58c25391f8d329c571a1485837e1c32838 100644 (file)
@@ -66,7 +66,7 @@ sinclude([../config/iconv.m4])
 
 sinclude([../config/zlib.m4])
 
-m4_include([common/common.m4])
+m4_include([gdbsupport/common.m4])
 
 dnl For libiberty_INIT.
 m4_include(libiberty.m4)
index 332363b1ecc9a827a9496b99b8ba96cbe553708a..ae28265d496603ee0925eaa2fea99e7cbea1b4c6 100644 (file)
@@ -49,9 +49,9 @@
 #include "valprint.h"
 #include "source.h"
 #include "observable.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "stack.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 #include "typeprint.h"
 #include "namespace.h"
 
@@ -60,8 +60,8 @@
 #include "mi/mi-common.h"
 #include "arch-utils.h"
 #include "cli/cli-utils.h"
-#include "common/function-view.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/function-view.h"
+#include "gdbsupport/byte-vector.h"
 #include <algorithm>
 #include <map>
 
index b10c680ac1c5ec60ef103253b42706230cfcc1ea..788f7a6d3a33b57d0db9690f021faf4c6995b95f 100644 (file)
@@ -28,7 +28,7 @@ struct parser_state;
 #include "value.h"
 #include "gdbtypes.h"
 #include "breakpoint.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 
 /* Names of specific files known to be part of the runtime
    system and that might consider (confusing) debugging information.
index 8b777d0b3b703166469dea02a9204d54beeda143..bc71860864a7087f679293953d8d79e664f143db 100644 (file)
@@ -19,7 +19,7 @@
 #include "command.h"
 #include "gdbcmd.h"
 #include "target.h"
-#include "common/agent.h"
+#include "gdbsupport/agent.h"
 
 /* Enum strings for "set|show agent".  */
 
index 95488a72cf2c73ed6a70cfa6d773a07d26ba9149..8323dd6dd4ae939a3249f86adc0877781f0ad389 100644 (file)
@@ -34,9 +34,9 @@
    GDBSERVER define when possible, and for this file it seemed
    simple to do so.  */
 
-#include "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "libiberty.h"
-#include "common/errors.h"
+#include "gdbsupport/errors.h"
 
 /* The xmalloc() (libiberty.h) family of memory management routines.
 
index 46867f40a38b188bc0424fda5a0c145305f018f3..f1aa72a3b5dae6c378194f57c3b563d225d07b76 100644 (file)
@@ -28,7 +28,7 @@
 #include "objfiles.h"
 
 #include "i387-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "amd64-tdep.h"
 #include "osabi.h"
 #include "ui-out.h"
index 8ca838e3c83e0ae6dbf48df49bc55ce18e4cb733..e797843bc9f514fa6de1fb1d6456b7de85447183 100644 (file)
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "osabi.h"
 #include "amd64-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "dicos-tdep.h"
 
 static void
index cc676d3214f49c9c20af054e50a177bf2df4ca0e..718ebd9ac1daa11444eebf6e812fbdf345baf4d5 100644 (file)
@@ -34,7 +34,7 @@
 #include "amd64-nat.h"
 #include "amd64-bsd-nat.h"
 #include "x86-nat.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 \f
 
 class amd64_fbsd_nat_target final
index 7e2e9edf21de3b8fa4e43c21046db8171c9da719..493e630974d46e4bfbad0c310021b28c688f54b0 100644 (file)
@@ -25,7 +25,7 @@
 #include "osabi.h"
 #include "regset.h"
 #include "i386-fbsd-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 
 #include "amd64-tdep.h"
 #include "fbsd-tdep.h"
index 8d0e8eb35cd2bd3af599cae48f888044d3393663..4f1c98a0d1e17125b02d64453230eb6e06989aa5 100644 (file)
@@ -33,7 +33,7 @@
 #include "amd64-tdep.h"
 #include "amd64-linux-tdep.h"
 #include "i386-linux-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 
 #include "x86-linux-nat.h"
 #include "nat/linux-ptrace.h"
index 008817c38d3bcfd13f41ed12ede215ebd60bb44c..7ec08c7fc49ff24d6d438162da2e6084529460cc 100644 (file)
@@ -33,7 +33,7 @@
 #include "amd64-linux-tdep.h"
 #include "i386-linux-tdep.h"
 #include "linux-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 
 #include "amd64-tdep.h"
 #include "solib-svr4.h"
index 06905d65dfda9890f743e19a15ee7799c4417913..331cb8a73f942225a605dde6b347989d9f060a54 100644 (file)
@@ -25,7 +25,7 @@
 #include "symtab.h"
 
 #include "amd64-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "nbsd-tdep.h"
 #include "solib-svr4.h"
 
index cd1a1c31b886b51feab3db2c8d847c5638fa9c4f..67f9f88f522b951673358d92f4b0810a44667fae 100644 (file)
@@ -32,7 +32,7 @@
 #include "obsd-tdep.h"
 #include "amd64-tdep.h"
 #include "i387-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "solib-svr4.h"
 #include "bsd-uthread.h"
 
index 56d2e22582278e87c7e9ea91c2b12a4dd8347ec4..74358d88f43e902ad93127f2d2b34a9152454cd8 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "sol2-tdep.h"
 #include "amd64-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "solib-svr4.h"
 
 /* Mapping between the general-purpose registers in gregset_t format
index f02b007afdaca86e6bf7d474f94fbbab26df850e..232d16d7345ae46ce149587039ad63d54be08730 100644 (file)
 #include "disasm.h"
 #include "amd64-tdep.h"
 #include "i387-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include <algorithm>
 #include "target-descriptions.h"
 #include "arch/amd64.h"
 #include "producer.h"
 #include "ax.h"
 #include "ax-gdb.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 #include "osabi.h"
 #include "x86-tdep.h"
 
index 922da9e48bcbcba08eb4fbd45c013117606bcd24..3eb1f1493cd3e6a04bc74a617b4d42f5c8ae709e 100644 (file)
@@ -18,7 +18,7 @@
 #include "defs.h"
 #include "osabi.h"
 #include "amd64-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
 #include "regcache.h"
index 43f5834b3833c5f59011206ccdb07ca3c411efd4..bfcb58207a79747fc05a662fcf920884063ef872 100644 (file)
@@ -32,7 +32,7 @@
 #include "language.h"
 #include "symtab.h"
 
-#include "common/version.h"
+#include "gdbsupport/version.h"
 
 #include "floatformat.h"
 
index cf6e669f99c624e80500e4e7b997e4b701b9b393..e04ad87fefbe2078a4f85470fd25fe61241d6043 100644 (file)
@@ -16,7 +16,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "aarch64-insn.h"
 
 /* Toggle this file's internal debugging dump.  */
index 11a15dd94cb145a5d0d67fbce6e8809891fabec6..30c5f8ad066fc99c41d97fb9a7cced453670f34a 100644 (file)
@@ -15,7 +15,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "aarch64.h"
 #include <stdlib.h>
 
index 309fe75273ef5175f11ebb6b111e260ac5da2aef..aed10353ad83447ac349c6879ab05609e7fa783a 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef ARCH_AARCH64_H
 #define ARCH_AARCH64_H
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 /* Create the aarch64 target description.  A non zero VQ value indicates both
    the presence of SVE and the Vector Quotient - the number of 128bit chunks in
index b7e6332d773a2f962d618571b8dbb7d803d0f799..3158ab5c0d8c6a9589b9ba99e6178355be3fafbf 100644 (file)
@@ -15,9 +15,9 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "amd64.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include <stdlib.h>
 
 #include "../features/i386/64bit-avx.c"
index 1e02c5235f113f2f072c2a6977f582ccb3713f9c..96b52a9ace63833853119d4585fdf8b9cfc586ef 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef ARCH_AMD64_H
 #define ARCH_AMD64_H
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 #include <stdint.h>
 
 target_desc *amd64_create_target_description (uint64_t xcr0, bool is_x32,
index 00c7064d8b7fae201fbf3b1d49642308904bfe36..e1335703ace96c01c02ad2dfa249912a3b71544f 100644 (file)
@@ -17,9 +17,9 @@
    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 "common/common-defs.h"
-#include "common/gdb_vecs.h"
-#include "common/common-regcache.h"
+#include "gdbsupport/common-defs.h"
+#include "gdbsupport/gdb_vecs.h"
+#include "gdbsupport/common-regcache.h"
 #include "arm.h"
 #include "arm-get-next-pcs.h"
 
index 180228fe8978c3a40e81e243da47030491e31d3d..d23c196a6a3dadc0dd42254fdbc123b8a0207f80 100644 (file)
@@ -17,8 +17,8 @@
    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 "common/common-defs.h"
-#include "common/common-regcache.h"
+#include "gdbsupport/common-defs.h"
+#include "gdbsupport/common-regcache.h"
 #include "arch/arm.h"
 #include "arm-linux.h"
 #include "arch/arm-get-next-pcs.h"
index 93738f0a0f86f84b58c340f9da783c24fe6173fc..860ce028587eb1403b896195b866aa648665e12a 100644 (file)
@@ -17,8 +17,8 @@
    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 "common/common-defs.h"
-#include "common/common-regcache.h"
+#include "gdbsupport/common-defs.h"
+#include "gdbsupport/common-regcache.h"
 #include "arm.h"
 
 /* See arm.h.  */
index ab24cf71cb59f51b33b3f04e98950c4d955ab624..d08ac6a5e8632457ee6dc8642195da89780102de 100644 (file)
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "i386.h"
-#include "common/tdesc.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/tdesc.h"
+#include "gdbsupport/x86-xstate.h"
 #include <stdlib.h>
 
 #include "../features/i386/32bit-core.c"
index 9a831cea30029b923f5182b3c2ac6f40b232fbe6..1caa0ae2eec79cf66171b768a549ba763d497cea 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef ARCH_I386_H
 #define ARCH_I386_H
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 #include <stdint.h>
 
 target_desc *i386_create_target_description (uint64_t xcr0, bool is_linux,
index 6badd2f7d261731e35ab0099c92c4c4c742b609f..8af30e3cd4292daa7d8788aeae70e0f0f0fa98cc 100644 (file)
@@ -17,7 +17,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "arch/ppc-linux-common.h"
 #include "arch/ppc-linux-tdesc.h"
 
index 5ed1d47ac51b14fe6dc5a26389e6750b673d4966..68ff711bacea2b57e411b5c52c81c79e08b1d18d 100644 (file)
@@ -15,7 +15,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "riscv.h"
 #include <stdlib.h>
 #include <unordered_map>
index 05c19054dce00da97f44bb6cce00a3ee800707cd..7917bdf4b4c796450bed348ec57c19b5e4a96fe9 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef ARCH_RISCV_H
 #define ARCH_RISCV_H
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 /* The set of RISC-V architectural features that we track that impact how
    we configure the actual gdbarch instance.  We hold one of these in the
index dd2257c97a4725bd8c3f0c5149344f951988b8d0..03aacfaf48056c8a6230728fcf70b745b8f7baad 100644 (file)
@@ -15,9 +15,9 @@
    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 "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 #include "tic6x.h"
-#include "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 
 #include "../features/tic6x-core.c"
 #include "../features/tic6x-gp.c"
index 8e3607cdea5fab983c9bd2caa649aaf8e5e50c84..fe6251924f9ca586f468b6b7c3edf7714ca1a46b 100644 (file)
@@ -55,7 +55,7 @@
 #include "coff/internal.h"
 #include "elf/arm.h"
 
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 
 #include "record.h"
 #include "record-full.h"
@@ -70,7 +70,7 @@
 #include "features/arm/arm-with-neon.c"
 
 #if GDB_SELF_TEST
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #endif
 
 static int arm_debug;
index 6833c21323ae93ee7914979095f3e17bfb26bc89..7e417994e8f17a9a67cec5312c9149f513916c0f 100644 (file)
 #include "completer.h"
 #include "fnmatch.h"
 #include "top.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "extension.h"
 #include "gdb/section-scripts.h"
 #include <algorithm>
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 
 /* The section to look in for auto-loaded scripts (in file formats that
    support sections).
index 5e0ff26ab1a9ce32a05d06d09067b842b2e87511..53958011c81941c7cef35db50811b5b59fd6fb7f 100644 (file)
@@ -25,7 +25,7 @@
 #include "valprint.h"
 #include "gdbcore.h"
 #include "observable.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "objfiles.h"
 
 #include "auxv.h"
index d3eb4cb53ae4abc0afa14ff931cbd6bece9ff4ec..9f1b7a1e88b181d6e1617b0bce84fe45c115ff64 100644 (file)
@@ -46,7 +46,7 @@
 #include "valprint.h"
 #include "c-lang.h"
 
-#include "common/format.h"
+#include "gdbsupport/format.h"
 
 /* To make sense of this file, you should read doc/agentexpr.texi.
    Then look at the types and enums in ax-gdb.h.  For the code itself,
index f956dfc2f530948d06811ccb5d9784f7bde0c0f6..d0fdc621f88ea9b92c2349c54d21778924386ce0 100644 (file)
@@ -353,7 +353,7 @@ struct aop_map aop_map[] =
   {0, 0, 0, 0, 0}
 #define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) \
   , { # NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED }
-#include "common/ax.def"
+#include "gdbsupport/ax.def"
 #undef DEFOP
 };
 
index d16098b8c9cf5e95a4248c408826ac79c1124279..112c21b6217606e7340dc793657f0a6787352bfe 100644 (file)
--- a/gdb/ax.h
+++ b/gdb/ax.h
@@ -19,7 +19,7 @@
 #ifndef AX_H
 #define AX_H
 
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 
 /* It's sometimes useful to be able to debug programs that you can't
    really stop for more than a fraction of a second.  To this end, the
@@ -164,7 +164,7 @@ enum agent_op
   {
 #define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE)  \
     aop_ ## NAME = VALUE,
-#include "common/ax.def"
+#include "gdbsupport/ax.def"
 #undef DEFOP
     aop_last
   };
index 9bae0a0254605b5156240341d331ee3cc0163a4d..00fd76220e272432c3744888d13be71aba9434ca 100644 (file)
@@ -65,7 +65,7 @@
 #include "ax-gdb.h"
 #include "dummy-frame.h"
 #include "interps.h"
-#include "common/format.h"
+#include "gdbsupport/format.h"
 #include "thread-fsm.h"
 #include "tid-parse.h"
 #include "cli/cli-style.h"
@@ -82,8 +82,8 @@
 #include "extension.h"
 #include <algorithm>
 #include "progspace-and-thread.h"
-#include "common/array-view.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/array-view.h"
+#include "gdbsupport/gdb_optional.h"
 
 /* Prototypes for local functions.  */
 
index 75f19785cb1d636701c33159905d9ffa45a0d449..3c9d5069b76bbd94e14e7bde1df8d5885c4d6850 100644 (file)
 
 #include "frame.h"
 #include "value.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "ax.h"
 #include "command.h"
-#include "common/break-common.h"
+#include "gdbsupport/break-common.h"
 #include "probe.h"
 #include "location.h"
 #include <vector>
-#include "common/array-view.h"
+#include "gdbsupport/array-view.h"
 #include "cli/cli-script.h"
 
 struct block;
index 2806b8c69d54df4f3e75e1c9148715cfdab74f60..08096adeb1daf881cdaf77819ebe507fcc6d16f4 100644 (file)
@@ -31,7 +31,7 @@
 #include "filenames.h"
 #include "xml-support.h"
 #include "regcache.h"
-#include "common/rsp-low.h"
+#include "gdbsupport/rsp-low.h"
 #include "gdbcmd.h"
 #include "cli/cli-utils.h"
 
@@ -2074,7 +2074,7 @@ parse_xml_raw (struct gdb_xml_parser *parser, const char *body_text,
   gdb::unique_xmalloc_ptr<gdb_byte> data ((gdb_byte *) xmalloc (size));
   bin = data.get ();
 
-  /* We use hex encoding - see common/rsp-low.h.  */
+  /* We use hex encoding - see gdbsupport/rsp-low.h.  */
   while (len > 0)
     {
       char hi, lo;
index 7b38b14ac01ee6ee07abefa9ed86c02c0115a551..ba8d27c879c1713bfe439217012b6166a5b6f203 100644 (file)
@@ -26,9 +26,9 @@
    inferior.  For presentation purposes, the branch trace is represented as a
    list of sequential control-flow blocks, one such list per thread.  */
 
-#include "common/btrace-common.h"
+#include "gdbsupport/btrace-common.h"
 #include "target/waitstatus.h" /* For enum target_stop_reason.  */
-#include "common/enum-flags.h"
+#include "gdbsupport/enum-flags.h"
 
 #if defined (HAVE_LIBIPT)
 #  include <intel-pt.h>
index 27f29cd044234430dd8e2565c13bf260920386dd..048da2af86f099c3268b895779540ba9142c3ef5 100644 (file)
@@ -21,7 +21,7 @@
 #include "bfd.h"
 #include "gdb_bfd.h"
 #include "build-id.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 #include "symfile.h"
 #include "objfiles.h"
 #include "filenames.h"
index b8b033e62aae1653916313fb389fd6a401a8955a..2835a760fae9e312b87cb4e7aaf9e9da8f192a24 100644 (file)
@@ -21,7 +21,7 @@
 #define BUILD_ID_H
 
 #include "gdb_bfd.h"
-#include "common/rsp-low.h"
+#include "gdbsupport/rsp-low.h"
 
 /* Locate NT_GNU_BUILD_ID from ABFD and return its content.  */
 
index 70a95eadbf8e176b59313ee34e344e790c40d4dd..d95df54c83e3e1bec46af20a9d938ea661578295 100644 (file)
@@ -29,7 +29,7 @@ struct parser_state;
 #include "value.h"
 #include "macroexp.h"
 #include "parser-defs.h"
-#include "common/enum-flags.h"
+#include "gdbsupport/enum-flags.h"
 
 
 /* The various kinds of C string and character.  Note that these
index 5d8a99660319d7ecec4816cdaf443ca450298d4d..9df46c0c74dd7d15b6ae83be91a2e59e1c73829e 100644 (file)
 #include "charset.h"
 #include "gdbcmd.h"
 #include "gdb_obstack.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include "charset-list.h"
-#include "common/vec.h"
-#include "common/environ.h"
+#include "gdbsupport/vec.h"
+#include "gdbsupport/environ.h"
 #include "arch-utils.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 #include <ctype.h>
 
 #ifdef USE_WIN32API
index d7cf247db71f0e6448765fc375ce67bf1f9004d3..623a40a955f999f2a1c9e92132b5561cb00218ca 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef CHARSET_H
 #define CHARSET_H
 
-#include "common/def-vector.h"
+#include "gdbsupport/def-vector.h"
 
 /* If the target program uses a different character set than the host,
    GDB has some support for translating between the two; GDB converts
index 368ddf526d1f184485f686d7c7328faf43e5373e..e689c0ff64edaa8a2ee0456609b204478dedfcd8 100644 (file)
@@ -23,7 +23,7 @@
 #include "readline/tilde.h"
 #include "completer.h"
 #include "target.h"    /* For baud_rate, remote_debug and remote_timeout.  */
-#include "common/gdb_wait.h"   /* For shell escape implementation.  */
+#include "gdbsupport/gdb_wait.h"       /* For shell escape implementation.  */
 #include "gdbcmd.h"
 #include "gdb_regex.h" /* Used by apropos_command.  */
 #include "gdb_vfork.h"
@@ -37,7 +37,7 @@
 #include "source.h"
 #include "disasm.h"
 #include "tracepoint.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "location.h"
 #include "block.h"
 
@@ -52,7 +52,7 @@
 #include "cli/cli-utils.h"
 
 #include "extension.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 
 #ifdef TUI
 #include "tui/tui.h"   /* For tui_active et.al.  */
index 94e210a84ebb444445527fccf795506bead8487c..188df05febd68c3e88edd8703bc6663eacc37ce1 100644 (file)
@@ -17,8 +17,8 @@
 #ifndef CLI_CLI_CMDS_H
 #define CLI_CLI_CMDS_H
 
-#include "common/filestuff.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/gdb_optional.h"
 
 /* Chain containing all defined commands.  */
 
index a6ddd8cc6d848361983f1a7259b1bb94058a2c15..edea3ad021ebbc0388ac00a8a4da8eb910107ec1 100644 (file)
@@ -24,7 +24,7 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-style.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 
 /* Prototypes for local functions.  */
 
index 621bc9373ff76e7d9efef81c0e1b164430d2470a..1910ca27659db40edf1a4b755ca3494f1907ed0a 100644 (file)
@@ -30,8 +30,8 @@
 #include "gdbcore.h"
 #include "cli/cli-utils.h"
 #include "gdb_bfd.h"
-#include "common/filestuff.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/byte-vector.h"
 
 static gdb::unique_xmalloc_ptr<char>
 scan_expression (const char **cmd, const char *def)
index a26b52f7f29c92fb21bd7deab49442d99a2a5034..d231d8b1adbf9a5713aae1f97c3a02b395fd574e 100644 (file)
@@ -20,8 +20,8 @@
 #ifndef CLI_OPTION_H
 #define CLI_OPTION_H 1
 
-#include "common/gdb_optional.h"
-#include "common/array-view.h"
+#include "gdbsupport/gdb_optional.h"
+#include "gdbsupport/array-view.h"
 #include "completer.h"
 #include <string>
 #include "command.h"
index 361ead472508a2dcbab30c24a979c6ec9091d29b..4fc9c70259ca537fc1c4cbd38ebee3f68ca8105f 100644 (file)
@@ -33,7 +33,7 @@
 #include "extension.h"
 #include "interps.h"
 #include "compile/compile.h"
-#include "common/gdb_string_view.h"
+#include "gdbsupport/gdb_string_view.h"
 #include "python/python.h"
 #include "guile/guile.h"
 
index f5721382f4c7b28aaf5c752cc7fba6f1bf9f5e9c..9f7384bc146643c7af9bce65b1a2c0258a0ce461 100644 (file)
@@ -33,7 +33,7 @@
 #include "symtab.h"
 #include "symfile.h"
 #include "objfiles.h"
-#include "common/common-utils.h"
+#include "gdbsupport/common-utils.h"
 #include "coff/internal.h"
 
 #include <ctype.h>
index 648950b5a448043cf244eca14153ca33cdc31ad1..2c608048d5471daa37bd245b65335982abb86785 100644 (file)
@@ -18,8 +18,8 @@
 #if !defined (COMMAND_H)
 #define COMMAND_H 1
 
-#include "common/gdb_vecs.h"
-#include "common/scoped_restore.h"
+#include "gdbsupport/gdb_vecs.h"
+#include "gdbsupport/scoped_restore.h"
 
 struct completion_tracker;
 
diff --git a/gdb/common/agent.c b/gdb/common/agent.c
deleted file mode 100644 (file)
index ae495a8..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-/* Shared utility routines for GDB to interact with agent.
-
-   Copyright (C) 2009-2019 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 "common-defs.h"
-#include "target/target.h"
-#include "common/symbol.h"
-#include <unistd.h>
-#include "filestuff.h"
-
-#define IPA_SYM_STRUCT_NAME ipa_sym_addresses_common
-#include "agent.h"
-
-int debug_agent = 0;
-
-/* A stdarg wrapper for debug_vprintf.  */
-
-static void ATTRIBUTE_PRINTF (1, 2)
-debug_agent_printf (const char *fmt, ...)
-{
-  va_list ap;
-
-  if (!debug_agent)
-    return;
-  va_start (ap, fmt);
-  debug_vprintf (fmt, ap);
-  va_end (ap);
-}
-
-#define DEBUG_AGENT debug_agent_printf
-
-/* Global flag to determine using agent or not.  */
-int use_agent = 0;
-
-/* Addresses of in-process agent's symbols both GDB and GDBserver cares
-   about.  */
-
-struct ipa_sym_addresses_common
-{
-  CORE_ADDR addr_helper_thread_id;
-  CORE_ADDR addr_cmd_buf;
-  CORE_ADDR addr_capability;
-};
-
-/* Cache of the helper thread id.  FIXME: this global should be made
-   per-process.  */
-static uint32_t helper_thread_id = 0;
-
-static struct
-{
-  const char *name;
-  int offset;
-} symbol_list[] = {
-  IPA_SYM(helper_thread_id),
-  IPA_SYM(cmd_buf),
-  IPA_SYM(capability),
-};
-
-static struct ipa_sym_addresses_common ipa_sym_addrs;
-
-static int all_agent_symbols_looked_up = 0;
-
-int
-agent_loaded_p (void)
-{
-  return all_agent_symbols_looked_up;
-}
-
-/* Look up all symbols needed by agent.  Return 0 if all the symbols are
-   found, return non-zero otherwise.  */
-
-int
-agent_look_up_symbols (void *arg)
-{
-  int i;
-
-  all_agent_symbols_looked_up = 0;
-
-  for (i = 0; i < sizeof (symbol_list) / sizeof (symbol_list[0]); i++)
-    {
-      CORE_ADDR *addrp =
-       (CORE_ADDR *) ((char *) &ipa_sym_addrs + symbol_list[i].offset);
-      struct objfile *objfile = (struct objfile *) arg;
-
-      if (find_minimal_symbol_address (symbol_list[i].name, addrp,
-                                      objfile) != 0)
-       {
-         DEBUG_AGENT ("symbol `%s' not found\n", symbol_list[i].name);
-         return -1;
-       }
-    }
-
-  all_agent_symbols_looked_up = 1;
-  return 0;
-}
-
-static unsigned int
-agent_get_helper_thread_id (void)
-{
-  if  (helper_thread_id == 0)
-    {
-      if (target_read_uint32 (ipa_sym_addrs.addr_helper_thread_id,
-                             &helper_thread_id))
-       warning (_("Error reading helper thread's id in lib"));
-    }
-
-  return helper_thread_id;
-}
-
-#ifdef HAVE_SYS_UN_H
-#include <sys/socket.h>
-#include <sys/un.h>
-#define SOCK_DIR P_tmpdir
-
-#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *) NULL)->sun_path)
-#endif
-
-#endif
-
-/* Connects to synchronization socket.  PID is the pid of inferior, which is
-   used to set up the connection socket.  */
-
-static int
-gdb_connect_sync_socket (int pid)
-{
-#ifdef HAVE_SYS_UN_H
-  struct sockaddr_un addr;
-  int res, fd;
-  char path[UNIX_PATH_MAX];
-
-  res = xsnprintf (path, UNIX_PATH_MAX, "%s/gdb_ust%d", P_tmpdir, pid);
-  if (res >= UNIX_PATH_MAX)
-    return -1;
-
-  res = fd = gdb_socket_cloexec (PF_UNIX, SOCK_STREAM, 0);
-  if (res == -1)
-    {
-      warning (_("error opening sync socket: %s"), strerror (errno));
-      return -1;
-    }
-
-  addr.sun_family = AF_UNIX;
-
-  res = xsnprintf (addr.sun_path, UNIX_PATH_MAX, "%s", path);
-  if (res >= UNIX_PATH_MAX)
-    {
-      warning (_("string overflow allocating socket name"));
-      close (fd);
-      return -1;
-    }
-
-  res = connect (fd, (struct sockaddr *) &addr, sizeof (addr));
-  if (res == -1)
-    {
-      warning (_("error connecting sync socket (%s): %s. "
-                "Make sure the directory exists and that it is writable."),
-                path, strerror (errno));
-      close (fd);
-      return -1;
-    }
-
-  return fd;
-#else
-  return -1;
-#endif
-}
-
-/* Execute an agent command in the inferior.  PID is the value of pid of the
-   inferior.  CMD is the buffer for command.  GDB or GDBserver will store the
-   command into it and fetch the return result from CMD.  The interaction
-   between GDB/GDBserver and the agent is synchronized by a synchronization
-   socket.  Return zero if success, otherwise return non-zero.  */
-
-int
-agent_run_command (int pid, const char *cmd, int len)
-{
-  int fd;
-  int tid = agent_get_helper_thread_id ();
-  ptid_t ptid = ptid_t (pid, tid, 0);
-
-  int ret = target_write_memory (ipa_sym_addrs.addr_cmd_buf,
-                                (gdb_byte *) cmd, len);
-
-  if (ret != 0)
-    {
-      warning (_("unable to write"));
-      return -1;
-    }
-
-  DEBUG_AGENT ("agent: resumed helper thread\n");
-
-  /* Resume helper thread.  */
-  target_continue_no_signal (ptid);
-
-  fd = gdb_connect_sync_socket (pid);
-  if (fd >= 0)
-    {
-      char buf[1] = "";
-
-      DEBUG_AGENT ("agent: signalling helper thread\n");
-
-      do
-       {
-         ret = write (fd, buf, 1);
-       } while (ret == -1 && errno == EINTR);
-
-       DEBUG_AGENT ("agent: waiting for helper thread's response\n");
-
-      do
-       {
-         ret = read (fd, buf, 1);
-       } while (ret == -1 && errno == EINTR);
-
-      close (fd);
-
-      DEBUG_AGENT ("agent: helper thread's response received\n");
-    }
-  else
-    return -1;
-
-  /* Need to read response with the inferior stopped.  */
-  if (ptid != null_ptid)
-    {
-      /* Stop thread PTID.  */
-      DEBUG_AGENT ("agent: stop helper thread\n");
-      target_stop_and_wait (ptid);
-    }
-
-  if (fd >= 0)
-    {
-      if (target_read_memory (ipa_sym_addrs.addr_cmd_buf, (gdb_byte *) cmd,
-                             IPA_CMD_BUF_SIZE))
-       {
-         warning (_("Error reading command response"));
-         return -1;
-       }
-    }
-
-  return 0;
-}
-
-/* Each bit of it stands for a capability of agent.  */
-static uint32_t agent_capability = 0;
-
-/* Return true if agent has capability AGENT_CAP, otherwise return false.  */
-
-int
-agent_capability_check (enum agent_capa agent_capa)
-{
-  if (agent_capability == 0)
-    {
-      if (target_read_uint32 (ipa_sym_addrs.addr_capability,
-                             &agent_capability))
-       warning (_("Error reading capability of agent"));
-    }
-  return agent_capability & agent_capa;
-}
-
-/* Invalidate the cache of agent capability, so we'll read it from inferior
-   again.  Call it when launches a new program or reconnect to remote stub.  */
-
-void
-agent_capability_invalidate (void)
-{
-  agent_capability = 0;
-}
diff --git a/gdb/common/agent.h b/gdb/common/agent.h
deleted file mode 100644 (file)
index 0927faa..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Shared utility routines for GDB to interact with agent.
-
-   Copyright (C) 2009-2019 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/>.  */
-
-#ifndef COMMON_AGENT_H
-#define COMMON_AGENT_H
-
-#include "common/preprocessor.h"
-
-int agent_run_command (int pid, const char *cmd, int len);
-
-int agent_look_up_symbols (void *);
-
-#define IPA_SYM_EXPORTED_NAME(SYM) gdb_agent_ ## SYM
-
-/* Define an entry in an IPA symbol list array.  If IPA_SYM is used, the macro
-   IPA_SYM_STRUCT_NAME must be defined to the structure name holding the IPA
-   symbol addresses in that particular file, before including
-   common/agent.h.  */
-#define IPA_SYM(SYM)                                   \
-  {                                                    \
-    STRINGIFY (IPA_SYM_EXPORTED_NAME (SYM)),           \
-    offsetof (IPA_SYM_STRUCT_NAME, addr_ ## SYM)       \
-  }
-
-/* The size in bytes of the buffer used to talk to the IPA helper
-   thread.  */
-#define IPA_CMD_BUF_SIZE 1024
-
-int agent_loaded_p (void);
-
-extern int debug_agent;
-
-extern int use_agent;
-
-/* Capability of agent.  Different agents may have different capabilities,
-   such as installing fast tracepoint or evaluating breakpoint conditions.
-   Capabilities are represented by bit-maps, and each capability occupies one
-   bit.  */
-
-enum agent_capa
-{
-  /* Capability to install fast tracepoint.  */
-  AGENT_CAPA_FAST_TRACE = 0x1,
-  /* Capability to install static tracepoint.  */
-  AGENT_CAPA_STATIC_TRACE = (0x1 << 1),
-};
-
-int agent_capability_check (enum agent_capa);
-
-void agent_capability_invalidate (void);
-
-#endif /* COMMON_AGENT_H */
diff --git a/gdb/common/array-view.h b/gdb/common/array-view.h
deleted file mode 100644 (file)
index ad7933b..0000000
+++ /dev/null
@@ -1,259 +0,0 @@
-/* Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_ARRAY_VIEW_H
-#define COMMON_ARRAY_VIEW_H
-
-#include "traits.h"
-#include <type_traits>
-
-/* An array_view is an abstraction that provides a non-owning view
-   over a sequence of contiguous objects.
-
-   A way to put it is that array_view is to std::vector (and
-   std::array and built-in arrays with rank==1) like std::string_view
-   is to std::string.
-
-   The main intent of array_view is to use it as function input
-   parameter type, making it possible to pass in any sequence of
-   contiguous objects, irrespective of whether the objects live on the
-   stack or heap and what actual container owns them.  Implicit
-   construction from the element type is supported too, making it easy
-   to call functions that expect an array of elements when you only
-   have one element (usually on the stack).  For example:
-
-    struct A { .... };
-    void function (gdb::array_view<A> as);
-
-    std::vector<A> std_vec = ...;
-    std::array<A, N> std_array = ...;
-    A array[] = {...};
-    A elem;
-
-    function (std_vec);
-    function (std_array);
-    function (array);
-    function (elem);
-
-   Views can be either mutable or const.  A const view is simply
-   created by specifying a const T as array_view template parameter,
-   in which case operator[] of non-const array_view objects ends up
-   returning const references.  Making the array_view itself const is
-   analogous to making a pointer itself be const.  I.e., disables
-   re-seating the view/pointer.
-
-   Since array_view objects are small (pointer plus size), and
-   designed to be trivially copyable, they should generally be passed
-   around by value.
-
-   You can find unit tests covering the whole API in
-   unittests/array-view-selftests.c.  */
-
-namespace gdb {
-
-template <typename T>
-class array_view
-{
-  /* True iff decayed T is the same as decayed U.  E.g., we want to
-     say that 'T&' is the same as 'const T'.  */
-  template <typename U>
-  using IsDecayedT = typename std::is_same<typename std::decay<T>::type,
-                                          typename std::decay<U>::type>;
-
-  /* True iff decayed T is the same as decayed U, and 'U *' is
-     implicitly convertible to 'T *'.  This is a requirement for
-     several methods.  */
-  template <typename U>
-  using DecayedConvertible = gdb::And<IsDecayedT<U>,
-                                     std::is_convertible<U *, T *>>;
-
-public:
-  using value_type = T;
-  using reference = T &;
-  using const_reference = const T &;
-  using size_type = size_t;
-
-  /* Default construction creates an empty view.  */
-  constexpr array_view () noexcept
-    : m_array (nullptr), m_size (0)
-  {}
-
-  /* Create an array view over a single object of the type of an
-     array_view element.  The created view as size==1.  This is
-     templated on U to allow constructing a array_view<const T> over a
-     (non-const) T.  The "convertible" requirement makes sure that you
-     can't create an array_view<T> over a const T.  */
-  template<typename U,
-          typename = Requires<DecayedConvertible<U>>>
-  constexpr array_view (U &elem) noexcept
-    : m_array (&elem), m_size (1)
-  {}
-
-  /* Same as above, for rvalue references.  */
-  template<typename U,
-          typename = Requires<DecayedConvertible<U>>>
-  constexpr array_view (U &&elem) noexcept
-    : m_array (&elem), m_size (1)
-  {}
-
-  /* Create an array view from a pointer to an array and an element
-     count.  */
-  template<typename U,
-          typename = Requires<DecayedConvertible<U>>>
-  constexpr array_view (U *array, size_t size) noexcept
-    : m_array (array), m_size (size)
-  {}
-
-  /* Create an array view from a range.  This is templated on both U
-     an V to allow passing in a mix of 'const T *' and 'T *'.  */
-  template<typename U, typename V,
-          typename = Requires<DecayedConvertible<U>>,
-          typename = Requires<DecayedConvertible<V>>>
-  constexpr array_view (U *begin, V *end) noexcept
-    : m_array (begin), m_size (end - begin)
-  {}
-
-  /* Create an array view from an array.  */
-  template<typename U, size_t Size,
-          typename = Requires<DecayedConvertible<U>>>
-  constexpr array_view (U (&array)[Size]) noexcept
-    : m_array (array), m_size (Size)
-  {}
-
-  /* Create an array view from a contiguous container.  E.g.,
-     std::vector and std::array.  */
-  template<typename Container,
-          typename = Requires<gdb::Not<IsDecayedT<Container>>>,
-          typename
-            = Requires<std::is_convertible
-                       <decltype (std::declval<Container> ().data ()),
-                        T *>>,
-          typename
-            = Requires<std::is_convertible
-                       <decltype (std::declval<Container> ().size ()),
-                        size_type>>>
-  constexpr array_view (Container &&c) noexcept
-    : m_array (c.data ()), m_size (c.size ())
-  {}
-
-  /* Observer methods.  Some of these can't be constexpr until we
-     require C++14.  */
-  /*constexpr14*/ T *data () noexcept { return m_array; }
-  constexpr const T *data () const noexcept { return m_array; }
-
-  /*constexpr14*/ T *begin () noexcept { return m_array; }
-  constexpr const T *begin () const noexcept { return m_array; }
-
-  /*constexpr14*/ T *end () noexcept { return m_array + m_size; }
-  constexpr const T *end () const noexcept { return m_array + m_size; }
-
-  /*constexpr14*/ reference operator[] (size_t index) noexcept
-  { return m_array[index]; }
-  constexpr const_reference operator[] (size_t index) const noexcept
-  { return m_array[index]; }
-
-  constexpr size_type size () const noexcept { return m_size; }
-  constexpr bool empty () const noexcept { return m_size == 0; }
-
-  /* Slice an array view.  */
-
-  /* Return a new array view over SIZE elements starting at START.  */
-  constexpr array_view<T> slice (size_type start, size_type size) const noexcept
-  { return {m_array + start, size}; }
-
-  /* Return a new array view over all the elements after START,
-     inclusive.  */
-  constexpr array_view<T> slice (size_type start) const noexcept
-  { return {m_array + start, size () - start}; }
-
-private:
-  T *m_array;
-  size_type m_size;
-};
-
-/* Compare LHS and RHS for (deep) equality.  That is, whether LHS and
-   RHS have the same sizes, and whether each pair of elements of LHS
-   and RHS at the same position compares equal.  */
-
-template <typename T>
-bool
-operator== (const gdb::array_view<T> &lhs, const gdb::array_view<T> &rhs)
-{
-  if (lhs.size () != rhs.size ())
-    return false;
-
-  for (size_t i = 0; i < lhs.size (); i++)
-    if (!(lhs[i] == rhs[i]))
-      return false;
-
-  return true;
-}
-
-/* Compare two array_views for inequality.  */
-
-template <typename T>
-bool
-operator!= (const gdb::array_view<T> &lhs, const gdb::array_view<T> &rhs)
-{
-  return !(lhs == rhs);
-}
-
-/* Create an array view from a pointer to an array and an element
-   count.
-
-   This is useful as alternative to constructing an array_view using
-   brace initialization when the size variable you have handy is of
-   signed type, since otherwise without an explicit cast the code
-   would be ill-formed.
-
-   For example, with:
-
-     extern void foo (int, int, gdb::array_view<value *>);
-
-     value *args[2];
-     int nargs;
-     foo (1, 2, {values, nargs});
-
-   You'd get:
-
-     source.c:10: error: narrowing conversion of â€˜nargs’ from â€˜int’ to
-     â€˜size_t {aka long unsigned int}’ inside { } [-Werror=narrowing]
-
-   You could fix it by writing the somewhat distracting explicit cast:
-
-     foo (1, 2, {values, (size_t) nargs});
-
-   Or by instantiating an array_view explicitly:
-
-     foo (1, 2, gdb::array_view<value *>(values, nargs));
-
-   Or, better, using make_array_view, which has the advantage of
-   inferring the arrav_view element's type:
-
-     foo (1, 2, gdb::make_array_view (values, nargs));
-*/
-
-template<typename U>
-constexpr inline array_view<U>
-make_array_view (U *array, size_t size) noexcept
-{
-  return {array, size};
-}
-
-} /* namespace gdb */
-
-#endif
diff --git a/gdb/common/ax.def b/gdb/common/ax.def
deleted file mode 100644 (file)
index 7b4c5ed..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Definition of agent opcode values.   -*- c -*-
-   Copyright (C) 1998-2019 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/>.  */
-
-/* The actual values of the various bytecode operations.
-
-   Other independent implementations of the agent bytecode engine will
-   rely on the exact values of these enums, and may not be recompiled
-   when we change this table.  The numeric values should remain fixed
-   whenever possible.  Thus, we assign them values explicitly here (to
-   allow gaps to form safely), and the disassembly table in
-   agentexpr.h behaves like an opcode map.  If you want to see them
-   grouped logically, see doc/agentexpr.texi.
-
-   Each line is of the form:
-   
-   DEFOP (name, size, data_size, consumed, produced, opcode)
-   
-   NAME is the name of the operation.
-   SIZE is the number of argument bytes that the operation takes from
-   the bytecode stream.
-   DATA_SIZE is the size of data operated on, in bits, for operations
-   that care (ref and const).  It is zero otherwise.
-   CONSUMED is the number of stack elements consumed.
-   PRODUCED is the number of stack elements produced.
-   OPCODE is the operation's encoding.  */
-
-DEFOP (float, 0, 0, 0, 0, 0x01)
-DEFOP (add, 0, 0, 2, 1, 0x02)
-DEFOP (sub, 0, 0, 2, 1, 0x03)
-DEFOP (mul, 0, 0, 2, 1, 0x04)
-DEFOP (div_signed, 0, 0, 2, 1, 0x05)
-DEFOP (div_unsigned, 0, 0, 2, 1, 0x06)
-DEFOP (rem_signed, 0, 0, 2, 1, 0x07)
-DEFOP (rem_unsigned, 0, 0, 2, 1, 0x08)
-DEFOP (lsh, 0, 0, 2, 1, 0x09)
-DEFOP (rsh_signed, 0, 0, 2, 1, 0x0a)
-DEFOP (rsh_unsigned, 0, 0, 2, 1, 0x0b)
-DEFOP (trace, 0, 0, 2, 0, 0x0c)
-DEFOP (trace_quick, 1, 0, 1, 1, 0x0d)
-DEFOP (log_not, 0, 0, 1, 1, 0x0e)
-DEFOP (bit_and, 0, 0, 2, 1, 0x0f)
-DEFOP (bit_or, 0, 0, 2, 1, 0x10)
-DEFOP (bit_xor, 0, 0, 2, 1, 0x11)
-DEFOP (bit_not, 0, 0, 1, 1, 0x12)
-DEFOP (equal, 0, 0, 2, 1, 0x13)
-DEFOP (less_signed, 0, 0, 2, 1, 0x14)
-DEFOP (less_unsigned, 0, 0, 2, 1, 0x15)
-DEFOP (ext, 1, 0, 1, 1, 0x16)
-DEFOP (ref8, 0, 8, 1, 1, 0x17)
-DEFOP (ref16, 0, 16, 1, 1, 0x18)
-DEFOP (ref32, 0, 32, 1, 1, 0x19)
-DEFOP (ref64, 0, 64, 1, 1, 0x1a)
-DEFOP (ref_float, 0, 0, 1, 1, 0x1b)
-DEFOP (ref_double, 0, 0, 1, 1, 0x1c)
-DEFOP (ref_long_double, 0, 0, 1, 1, 0x1d)
-DEFOP (l_to_d, 0, 0, 1, 1, 0x1e)
-DEFOP (d_to_l, 0, 0, 1, 1, 0x1f)
-DEFOP (if_goto, 2, 0, 1, 0, 0x20)
-DEFOP (goto, 2, 0, 0, 0, 0x21)
-DEFOP (const8, 1, 8, 0, 1, 0x22)
-DEFOP (const16, 2, 16, 0, 1, 0x23)
-DEFOP (const32, 4, 32, 0, 1, 0x24)
-DEFOP (const64, 8, 64, 0, 1, 0x25)
-DEFOP (reg, 2, 0, 0, 1, 0x26)
-DEFOP (end, 0, 0, 0, 0, 0x27)
-DEFOP (dup, 0, 0, 1, 2, 0x28)
-DEFOP (pop, 0, 0, 1, 0, 0x29)
-DEFOP (zero_ext, 1, 0, 1, 1, 0x2a)
-DEFOP (swap, 0, 0, 2, 2, 0x2b)
-DEFOP (getv, 2, 0, 0, 1, 0x2c)
-DEFOP (setv, 2, 0, 1, 1, 0x2d)
-DEFOP (tracev, 2, 0, 0, 1, 0x2e)
-DEFOP (tracenz, 0, 0, 2, 0, 0x2f)
-DEFOP (trace16, 2, 0, 1, 1, 0x30)
-/* We need something here just to make the tables come out ok.  */
-DEFOP (invalid2, 0, 0, 0, 0, 0x31)
-/* The "consumed" number for pick is wrong, but there's no way to
-   express the right thing.  */
-DEFOP (pick, 1, 0, 0, 1, 0x32)
-DEFOP (rot, 0, 0, 3, 3, 0x33)
-/* Both the argument and consumed numbers are dynamic for this one.  */
-DEFOP (printf, 0, 0, 0, 0, 0x34)
diff --git a/gdb/common/break-common.h b/gdb/common/break-common.h
deleted file mode 100644 (file)
index d85cadf..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Data structures associated with breakpoints shared in both GDB and
-   GDBserver.
-   Copyright (C) 1992-2019 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/>.  */
-
-#ifndef COMMON_BREAK_COMMON_H
-#define COMMON_BREAK_COMMON_H
-
-enum target_hw_bp_type
-  {
-    hw_write   = 0,            /* Common  HW watchpoint */
-    hw_read    = 1,            /* Read    HW watchpoint */
-    hw_access  = 2,            /* Access  HW watchpoint */
-    hw_execute = 3             /* Execute HW breakpoint */
-  };
-
-#endif /* COMMON_BREAK_COMMON_H */
diff --git a/gdb/common/btrace-common.c b/gdb/common/btrace-common.c
deleted file mode 100644 (file)
index 13f1f1a..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/* Copyright (C) 2014-2019 Free Software Foundation, Inc.
-
-   Contributed by Intel Corp. <markus.t.metzger@intel.com>
-
-   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 "common-defs.h"
-#include "btrace-common.h"
-
-
-/* See btrace-common.h.  */
-
-const char *
-btrace_format_string (enum btrace_format format)
-{
-  switch (format)
-    {
-    case BTRACE_FORMAT_NONE:
-      return _("No or unknown format");
-
-    case BTRACE_FORMAT_BTS:
-      return _("Branch Trace Store");
-
-    case BTRACE_FORMAT_PT:
-      return _("Intel Processor Trace");
-    }
-
-  internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
-}
-
-/* See btrace-common.h.  */
-
-const char *
-btrace_format_short_string (enum btrace_format format)
-{
-  switch (format)
-    {
-    case BTRACE_FORMAT_NONE:
-      return "unknown";
-
-    case BTRACE_FORMAT_BTS:
-      return "bts";
-
-    case BTRACE_FORMAT_PT:
-      return "pt";
-    }
-
-  internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
-}
-
-/* See btrace-common.h.  */
-
-void
-btrace_data::fini ()
-{
-  switch (format)
-    {
-    case BTRACE_FORMAT_NONE:
-      /* Nothing to do.  */
-      return;
-
-    case BTRACE_FORMAT_BTS:
-      VEC_free (btrace_block_s, variant.bts.blocks);
-      return;
-
-    case BTRACE_FORMAT_PT:
-      xfree (variant.pt.data);
-      return;
-    }
-
-  internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
-}
-
-/* See btrace-common.h.  */
-
-bool
-btrace_data::empty () const
-{
-  switch (format)
-    {
-    case BTRACE_FORMAT_NONE:
-      return true;
-
-    case BTRACE_FORMAT_BTS:
-      return VEC_empty (btrace_block_s, variant.bts.blocks);
-
-    case BTRACE_FORMAT_PT:
-      return (variant.pt.size == 0);
-    }
-
-  internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
-}
-
-/* See btrace-common.h.  */
-
-void
-btrace_data::clear ()
-{
-  fini ();
-  format = BTRACE_FORMAT_NONE;
-}
-
-/* See btrace-common.h.  */
-
-int
-btrace_data_append (struct btrace_data *dst,
-                   const struct btrace_data *src)
-{
-  switch (src->format)
-    {
-    case BTRACE_FORMAT_NONE:
-      return 0;
-
-    case BTRACE_FORMAT_BTS:
-      switch (dst->format)
-       {
-       default:
-         return -1;
-
-       case BTRACE_FORMAT_NONE:
-         dst->format = BTRACE_FORMAT_BTS;
-         dst->variant.bts.blocks = NULL;
-
-         /* Fall-through.  */
-       case BTRACE_FORMAT_BTS:
-         {
-           unsigned int blk;
-
-           /* We copy blocks in reverse order to have the oldest block at
-              index zero.  */
-           blk = VEC_length (btrace_block_s, src->variant.bts.blocks);
-           while (blk != 0)
-             {
-               btrace_block_s *block;
-
-               block = VEC_index (btrace_block_s, src->variant.bts.blocks,
-                                  --blk);
-
-               VEC_safe_push (btrace_block_s, dst->variant.bts.blocks, block);
-             }
-         }
-       }
-      return 0;
-
-    case BTRACE_FORMAT_PT:
-      switch (dst->format)
-       {
-       default:
-         return -1;
-
-       case BTRACE_FORMAT_NONE:
-         dst->format = BTRACE_FORMAT_PT;
-         dst->variant.pt.data = NULL;
-         dst->variant.pt.size = 0;
-
-         /* fall-through.  */
-       case BTRACE_FORMAT_PT:
-         {
-           gdb_byte *data;
-           size_t size;
-
-           size = src->variant.pt.size + dst->variant.pt.size;
-           data = (gdb_byte *) xmalloc (size);
-
-           memcpy (data, dst->variant.pt.data, dst->variant.pt.size);
-           memcpy (data + dst->variant.pt.size, src->variant.pt.data,
-                   src->variant.pt.size);
-
-           xfree (dst->variant.pt.data);
-
-           dst->variant.pt.data = data;
-           dst->variant.pt.size = size;
-         }
-       }
-      return 0;
-    }
-
-  internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
-}
diff --git a/gdb/common/btrace-common.h b/gdb/common/btrace-common.h
deleted file mode 100644 (file)
index 0b18924..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/* Branch trace support for GDB, the GNU debugger.
-
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-
-   Contributed by Intel Corp. <markus.t.metzger@intel.com>.
-
-   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/>.  */
-
-#ifndef COMMON_BTRACE_COMMON_H
-#define COMMON_BTRACE_COMMON_H
-
-/* Branch tracing (btrace) is a per-thread control-flow execution trace of the
-   inferior.  For presentation purposes, the branch trace is represented as a
-   list of sequential control-flow blocks, one such list per thread.  */
-
-#include "vec.h"
-
-/* A branch trace block.
-
-   This represents a block of sequential control-flow.  Adjacent blocks will be
-   connected via calls, returns, or jumps.  The latter can be direct or
-   indirect, conditional or unconditional.  Branches can further be
-   asynchronous, e.g. interrupts.  */
-struct btrace_block
-{
-  /* The address of the first byte of the first instruction in the block.
-     The address may be zero if we do not know the beginning of this block,
-     such as for the first block in a delta trace.  */
-  CORE_ADDR begin;
-
-  /* The address of the first byte of the last instruction in the block.  */
-  CORE_ADDR end;
-};
-
-/* Define functions operating on a vector of branch trace blocks.  */
-typedef struct btrace_block btrace_block_s;
-DEF_VEC_O (btrace_block_s);
-
-/* Enumeration of btrace formats.  */
-
-enum btrace_format
-{
-  /* No branch trace format.  */
-  BTRACE_FORMAT_NONE,
-
-  /* Branch trace is in Branch Trace Store (BTS) format.
-     Actually, the format is a sequence of blocks derived from BTS.  */
-  BTRACE_FORMAT_BTS,
-
-  /* Branch trace is in Intel Processor Trace format.  */
-  BTRACE_FORMAT_PT
-};
-
-/* An enumeration of cpu vendors.  */
-
-enum btrace_cpu_vendor
-{
-  /* We do not know this vendor.  */
-  CV_UNKNOWN,
-
-  /* Intel.  */
-  CV_INTEL
-};
-
-/* A cpu identifier.  */
-
-struct btrace_cpu
-{
-  /* The processor vendor.  */
-  enum btrace_cpu_vendor vendor;
-
-  /* The cpu family.  */
-  unsigned short family;
-
-  /* The cpu model.  */
-  unsigned char model;
-
-  /* The cpu stepping.  */
-  unsigned char stepping;
-};
-
-/* A BTS configuration.  */
-
-struct btrace_config_bts
-{
-  /* The size of the branch trace buffer in bytes.
-
-     This is unsigned int and not size_t since it is registered as
-     control variable for "set record btrace bts buffer-size".  */
-  unsigned int size;
-};
-
-/* An Intel Processor Trace configuration.  */
-
-struct btrace_config_pt
-{
-  /* The size of the branch trace buffer in bytes.
-
-     This is unsigned int and not size_t since it is registered as
-     control variable for "set record btrace pt buffer-size".  */
-  unsigned int size;
-};
-
-/* A branch tracing configuration.
-
-   This describes the requested configuration as well as the actually
-   obtained configuration.
-   We describe the configuration for all different formats so we can
-   easily switch between formats.  */
-
-struct btrace_config
-{
-  /* The branch tracing format.  */
-  enum btrace_format format;
-
-  /* The BTS format configuration.  */
-  struct btrace_config_bts bts;
-
-  /* The Intel Processor Trace format configuration.  */
-  struct btrace_config_pt pt;
-};
-
-/* Branch trace in BTS format.  */
-struct btrace_data_bts
-{
-  /* Branch trace is represented as a vector of branch trace blocks starting
-     with the most recent block.  */
-  VEC (btrace_block_s) *blocks;
-};
-
-/* Configuration information to go with the trace data.  */
-struct btrace_data_pt_config
-{
-  /* The processor on which the trace has been collected.  */
-  struct btrace_cpu cpu;
-};
-
-/* Branch trace in Intel Processor Trace format.  */
-struct btrace_data_pt
-{
-  /* Some configuration information to go with the data.  */
-  struct btrace_data_pt_config config;
-
-  /* The trace data.  */
-  gdb_byte *data;
-
-  /* The size of DATA in bytes.  */
-  size_t size;
-};
-
-/* The branch trace data.  */
-struct btrace_data
-{
-  btrace_data () = default;
-
-  ~btrace_data ()
-  {
-    fini ();
-  }
-
-  btrace_data &operator= (btrace_data &&other)
-  {
-    if (this != &other)
-      {
-       fini ();
-       format = other.format;
-       variant = other.variant;
-       other.format = BTRACE_FORMAT_NONE;
-      }
-    return *this;
-  }
-
-  /* Return true if this is empty; false otherwise.  */
-  bool empty () const;
-
-  /* Clear this object.  */
-  void clear ();
-
-  enum btrace_format format = BTRACE_FORMAT_NONE;
-
-  union
-  {
-    /* Format == BTRACE_FORMAT_BTS.  */
-    struct btrace_data_bts bts;
-
-    /* Format == BTRACE_FORMAT_PT.  */
-    struct btrace_data_pt pt;
-  } variant;
-
-private:
-
-  DISABLE_COPY_AND_ASSIGN (btrace_data);
-
-  void fini ();
-};
-
-/* Target specific branch trace information.  */
-struct btrace_target_info;
-
-/* Enumeration of btrace read types.  */
-
-enum btrace_read_type
-{
-  /* Send all available trace.  */
-  BTRACE_READ_ALL,
-
-  /* Send all available trace, if it changed.  */
-  BTRACE_READ_NEW,
-
-  /* Send the trace since the last request.  This will fail if the trace
-     buffer overflowed.  */
-  BTRACE_READ_DELTA
-};
-
-/* Enumeration of btrace errors.  */
-
-enum btrace_error
-{
-  /* No error.  Everything is OK.  */
-  BTRACE_ERR_NONE,
-
-  /* An unknown error.  */
-  BTRACE_ERR_UNKNOWN,
-
-  /* Branch tracing is not supported on this system.  */
-  BTRACE_ERR_NOT_SUPPORTED,
-
-  /* The branch trace buffer overflowed; no delta read possible.  */
-  BTRACE_ERR_OVERFLOW
-};
-
-/* Return a string representation of FORMAT.  */
-extern const char *btrace_format_string (enum btrace_format format);
-
-/* Return an abbreviation string representation of FORMAT.  */
-extern const char *btrace_format_short_string (enum btrace_format format);
-
-/* Append the branch trace data from SRC to the end of DST.
-   Both SRC and DST must use the same format.
-   Returns zero on success; a negative number otherwise.  */
-extern int btrace_data_append (struct btrace_data *dst,
-                              const struct btrace_data *src);
-
-#endif /* COMMON_BTRACE_COMMON_H */
diff --git a/gdb/common/buffer.c b/gdb/common/buffer.c
deleted file mode 100644 (file)
index 3c919e7..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/* A simple growing buffer for GDB.
-  
-   Copyright (C) 2009-2019 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 "common-defs.h"
-#include "xml-utils.h"
-#include "buffer.h"
-#include "inttypes.h"
-void
-buffer_grow (struct buffer *buffer, const char *data, size_t size)
-{
-  char *new_buffer;
-  size_t new_buffer_size;
-
-  if (size == 0)
-    return;
-
-  new_buffer_size = buffer->buffer_size;
-
-  if (new_buffer_size == 0)
-    new_buffer_size = 1;
-
-  while (buffer->used_size + size > new_buffer_size)
-    new_buffer_size *= 2;
-  new_buffer = (char *) xrealloc (buffer->buffer, new_buffer_size);
-  memcpy (new_buffer + buffer->used_size, data, size);
-  buffer->buffer = new_buffer;
-  buffer->buffer_size = new_buffer_size;
-  buffer->used_size += size;
-}
-
-void
-buffer_free (struct buffer *buffer)
-{
-  if (!buffer)
-    return;
-
-  xfree (buffer->buffer);
-  buffer->buffer = NULL;
-  buffer->buffer_size = 0;
-  buffer->used_size = 0;
-}
-
-void
-buffer_init (struct buffer *buffer)
-{
-  memset (buffer, 0, sizeof (*buffer));
-}
-
-char*
-buffer_finish (struct buffer *buffer)
-{
-  char *ret = buffer->buffer;
-  buffer->buffer = NULL;
-  buffer->buffer_size = 0;
-  buffer->used_size = 0;
-  return ret;
-}
-
-void
-buffer_xml_printf (struct buffer *buffer, const char *format, ...)
-{
-  va_list ap;
-  const char *f;
-  const char *prev;
-  int percent = 0;
-
-  va_start (ap, format);
-
-  prev = format;
-  for (f = format; *f; f++)
-    {
-      if (percent)
-       {
-         char buf[32];
-         char *str = buf;
-         const char *f_old = f;
-         
-         switch (*f)
-           {
-           case 's':
-             str = va_arg (ap, char *);
-             break;
-           case 'd':
-             sprintf (str, "%d", va_arg (ap, int));
-             break;
-           case 'u':
-             sprintf (str, "%u", va_arg (ap, unsigned int));
-             break;
-           case 'x':
-             sprintf (str, "%x", va_arg (ap, unsigned int));
-             break;
-           case 'o':
-             sprintf (str, "%o", va_arg (ap, unsigned int));
-             break;
-           case 'l':
-             f++;
-             switch (*f)
-               {
-               case 'd':
-                 sprintf (str, "%ld", va_arg (ap, long));
-                 break;
-               case 'u':
-                 sprintf (str, "%lu", va_arg (ap, unsigned long));
-                 break;
-               case 'x':
-                 sprintf (str, "%lx", va_arg (ap, unsigned long));
-                 break;
-               case 'o':
-                 sprintf (str, "%lo", va_arg (ap, unsigned long));
-                 break;
-               case 'l':
-                 f++;
-                 switch (*f)
-                   {
-                   case 'd':
-                     sprintf (str, "%" PRId64,
-                              (int64_t) va_arg (ap, long long));
-                     break;
-                   case 'u':
-                     sprintf (str, "%" PRIu64,
-                              (uint64_t) va_arg (ap, unsigned long long));
-                     break;
-                   case 'x':
-                     sprintf (str, "%" PRIx64,
-                              (uint64_t) va_arg (ap, unsigned long long));
-                     break;
-                   case 'o':
-                     sprintf (str, "%" PRIo64,
-                              (uint64_t) va_arg (ap, unsigned long long));
-                     break;
-                   default:
-                     str = 0;
-                     break;
-                   }
-                 break;
-               default:
-                 str = 0;
-                 break;
-               }
-             break;
-           default:
-             str = 0;
-             break;
-           }
-
-         if (str)
-           {
-             buffer_grow (buffer, prev, f_old - prev - 1);
-             std::string p = xml_escape_text (str);
-             buffer_grow_str (buffer, p.c_str ());
-             prev = f + 1;
-           }
-         percent = 0;
-       }
-      else if (*f == '%')
-       percent = 1;
-    }
-
-  buffer_grow_str (buffer, prev);
-  va_end (ap);
-}
-
diff --git a/gdb/common/buffer.h b/gdb/common/buffer.h
deleted file mode 100644 (file)
index 8b24b54..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* A simple growing buffer for GDB.
-  
-   Copyright (C) 2009-2019 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/>.  */
-
-#ifndef COMMON_BUFFER_H
-#define COMMON_BUFFER_H
-
-struct buffer
-{
-  char *buffer;
-  size_t buffer_size; /* allocated size */
-  size_t used_size; /* actually used size */
-};
-
-/* Append DATA of size SIZE to the end of BUFFER.  Grows the buffer to
-   accommodate the new data.  */
-void buffer_grow (struct buffer *buffer, const char *data, size_t size);
-
-/* Append C to the end of BUFFER.  Grows the buffer to accommodate the
-   new data.  */
-
-static inline void
-buffer_grow_char (struct buffer *buffer, char c)
-{
-  buffer_grow (buffer, &c, 1);
-}
-
-/* Release any memory held by BUFFER.  */
-void buffer_free (struct buffer *buffer);
-
-/* Initialize BUFFER.  BUFFER holds no memory afterwards.  */
-void buffer_init (struct buffer *buffer);
-
-/* Return a pointer into BUFFER data, effectively transferring
-   ownership of the buffer memory to the caller.  Calling buffer_free
-   afterwards has no effect on the returned data.  */
-char* buffer_finish (struct buffer *buffer);
-
-/* Simple printf to buffer function.  Current implemented formatters:
-   %s - grow an xml escaped text in BUFFER.
-   %d - grow an signed integer in BUFFER.
-   %u - grow an unsigned integer in BUFFER.
-   %x - grow an unsigned integer formatted in hexadecimal in BUFFER.
-   %o - grow an unsigned integer formatted in octal in BUFFER.  */
-void buffer_xml_printf (struct buffer *buffer, const char *format, ...)
-  ATTRIBUTE_PRINTF (2, 3);
-
-#define buffer_grow_str(BUFFER,STRING)         \
-  buffer_grow (BUFFER, STRING, strlen (STRING))
-#define buffer_grow_str0(BUFFER,STRING)                        \
-  buffer_grow (BUFFER, STRING, strlen (STRING) + 1)
-
-#endif /* COMMON_BUFFER_H */
diff --git a/gdb/common/byte-vector.h b/gdb/common/byte-vector.h
deleted file mode 100644 (file)
index bc18c04..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_BYTE_VECTOR_H
-#define COMMON_BYTE_VECTOR_H
-
-#include "common/def-vector.h"
-
-namespace gdb {
-
-/* byte_vector is a gdb_byte std::vector with a custom allocator that
-   unlike std::vector<gdb_byte> does not zero-initialize new elements
-   by default when the vector is created/resized.  This is what you
-   usually want when working with byte buffers, since if you're
-   creating or growing a buffer you'll most surely want to fill it in
-   with data, in which case zero-initialization would be a
-   pessimization.  For example:
-
-     gdb::byte_vector buf (some_large_size);
-     fill_with_data (buf.data (), buf.size ());
-
-   On the odd case you do need zero initialization, then you can still
-   call the overloads that specify an explicit value, like:
-
-     gdb::byte_vector buf (some_initial_size, 0);
-     buf.resize (a_bigger_size, 0);
-
-   (Or use std::vector<gdb_byte> instead.)
-
-   Note that unlike std::vector<gdb_byte>, function local
-   gdb::byte_vector objects constructed with an initial size like:
-
-     gdb::byte_vector buf (some_size);
-     fill_with_data (buf.data (), buf.size ());
-
-   usually compile down to the exact same as:
-
-     std::unique_ptr<byte[]> buf (new gdb_byte[some_size]);
-     fill_with_data (buf.get (), some_size);
-
-   with the former having the advantage of being a bit more readable,
-   and providing the whole std::vector API, if you end up needing it.
-*/
-using byte_vector = gdb::def_vector<gdb_byte>;
-using char_vector = gdb::def_vector<char>;
-
-} /* namespace gdb */
-
-#endif /* COMMON_DEF_VECTOR_H */
diff --git a/gdb/common/cleanups.c b/gdb/common/cleanups.c
deleted file mode 100644 (file)
index 121720d..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/* Cleanup routines for GDB, the GNU debugger.
-
-   Copyright (C) 1986-2019 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 "common-defs.h"
-#include "cleanups.h"
-
-/* The cleanup list records things that have to be undone
-   if an error happens (descriptors to be closed, memory to be freed, etc.)
-   Each link in the chain records a function to call and an
-   argument to give it.
-
-   Use make_cleanup to add an element to the cleanup chain.
-   Use do_cleanups to do all cleanup actions back to a given
-   point in the chain.  Use discard_cleanups to remove cleanups
-   from the chain back to a given point, not doing them.
-
-   If the argument is pointer to allocated memory, then you need
-   to additionally set the 'free_arg' member to a function that will
-   free that memory.  This function will be called both when the cleanup
-   is executed and when it's discarded.  */
-
-struct cleanup
-{
-  struct cleanup *next;
-  void (*function) (void *);
-  void (*free_arg) (void *);
-  void *arg;
-};
-
-/* Used to mark the end of a cleanup chain.
-   The value is chosen so that it:
-   - is non-NULL so that make_cleanup never returns NULL,
-   - causes a segv if dereferenced
-     [though this won't catch errors that a value of, say,
-     ((struct cleanup *) -1) will]
-   - displays as something useful when printed in gdb.
-   This is const for a bit of extra robustness.
-   It is initialized to coax gcc into putting it into .rodata.
-   All fields are initialized to survive -Wextra.  */
-static const struct cleanup sentinel_cleanup = { 0, 0, 0, 0 };
-
-/* Handy macro to use when referring to sentinel_cleanup.  */
-#define SENTINEL_CLEANUP ((struct cleanup *) &sentinel_cleanup)
-
-/* Chain of cleanup actions established with make_final_cleanup,
-   to be executed when gdb exits.  */
-static struct cleanup *final_cleanup_chain = SENTINEL_CLEANUP;
-
-/* Main worker routine to create a cleanup.
-   PMY_CHAIN is a pointer to either cleanup_chain or final_cleanup_chain.
-   FUNCTION is the function to call to perform the cleanup.
-   ARG is passed to FUNCTION when called.
-   FREE_ARG, if non-NULL, is called after the cleanup is performed.
-
-   The result is a pointer to the previous chain pointer
-   to be passed later to do_cleanups or discard_cleanups.  */
-
-static struct cleanup *
-make_my_cleanup2 (struct cleanup **pmy_chain, make_cleanup_ftype *function,
-                 void *arg,  void (*free_arg) (void *))
-{
-  struct cleanup *newobj = XNEW (struct cleanup);
-  struct cleanup *old_chain = *pmy_chain;
-
-  newobj->next = *pmy_chain;
-  newobj->function = function;
-  newobj->free_arg = free_arg;
-  newobj->arg = arg;
-  *pmy_chain = newobj;
-
-  gdb_assert (old_chain != NULL);
-  return old_chain;
-}
-
-/* Worker routine to create a cleanup without a destructor.
-   PMY_CHAIN is a pointer to either cleanup_chain or final_cleanup_chain.
-   FUNCTION is the function to call to perform the cleanup.
-   ARG is passed to FUNCTION when called.
-
-   The result is a pointer to the previous chain pointer
-   to be passed later to do_cleanups or discard_cleanups.  */
-
-static struct cleanup *
-make_my_cleanup (struct cleanup **pmy_chain, make_cleanup_ftype *function,
-                void *arg)
-{
-  return make_my_cleanup2 (pmy_chain, function, arg, NULL);
-}
-
-/* Add a new cleanup to the final cleanup_chain,
-   and return the previous chain pointer
-   to be passed later to do_cleanups or discard_cleanups.
-   Args are FUNCTION to clean up with, and ARG to pass to it.  */
-
-struct cleanup *
-make_final_cleanup (make_cleanup_ftype *function, void *arg)
-{
-  return make_my_cleanup (&final_cleanup_chain, function, arg);
-}
-
-/* Worker routine to perform cleanups.
-   PMY_CHAIN is a pointer to either cleanup_chain or final_cleanup_chain.
-   OLD_CHAIN is the result of a "make" cleanup routine.
-   Cleanups are performed until we get back to the old end of the chain.  */
-
-static void
-do_my_cleanups (struct cleanup **pmy_chain,
-               struct cleanup *old_chain)
-{
-  struct cleanup *ptr;
-
-  while ((ptr = *pmy_chain) != old_chain)
-    {
-      *pmy_chain = ptr->next;  /* Do this first in case of recursion.  */
-      (*ptr->function) (ptr->arg);
-      if (ptr->free_arg)
-       (*ptr->free_arg) (ptr->arg);
-      xfree (ptr);
-    }
-}
-
-/* Discard final cleanups and do the actions they describe.  */
-
-void
-do_final_cleanups ()
-{
-  do_my_cleanups (&final_cleanup_chain, SENTINEL_CLEANUP);
-}
diff --git a/gdb/common/cleanups.h b/gdb/common/cleanups.h
deleted file mode 100644 (file)
index e676076..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Cleanups.
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_CLEANUPS_H
-#define COMMON_CLEANUPS_H
-
-/* Outside of cleanups.c, this is an opaque type.  */
-struct cleanup;
-
-/* NOTE: cagney/2000-03-04: This typedef is strictly for the
-   make_cleanup function declarations below.  Do not use this typedef
-   as a cast when passing functions into the make_cleanup() code.
-   Instead either use a bounce function or add a wrapper function.
-   Calling a f(char*) function with f(void*) is non-portable.  */
-typedef void (make_cleanup_ftype) (void *);
-
-/* Function type for the dtor in make_cleanup_dtor.  */
-typedef void (make_cleanup_dtor_ftype) (void *);
-
-extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
-
-extern void do_final_cleanups ();
-
-#endif /* COMMON_CLEANUPS_H */
diff --git a/gdb/common/common-debug.c b/gdb/common/common-debug.c
deleted file mode 100644 (file)
index 11aee3a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Debug printing functions.
-
-   Copyright (C) 2014-2019 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 "common-defs.h"
-#include "common-debug.h"
-
-/* See common/common-debug.h.  */
-
-int show_debug_regs;
-
-/* See common/common-debug.h.  */
-
-void
-debug_printf (const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start (ap, fmt);
-  debug_vprintf (fmt, ap);
-  va_end (ap);
-}
diff --git a/gdb/common/common-debug.h b/gdb/common/common-debug.h
deleted file mode 100644 (file)
index d5bfc9e..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Declarations for debug printing functions.
-
-   Copyright (C) 2014-2019 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/>.  */
-
-#ifndef COMMON_COMMON_DEBUG_H
-#define COMMON_COMMON_DEBUG_H
-
-/* Set to nonzero to enable debugging of hardware breakpoint/
-   watchpoint support code.  */
-
-extern int show_debug_regs;
-
-/* Print a formatted message to the appropriate channel for
-   debugging output for the client.  */
-
-extern void debug_printf (const char *format, ...)
-     ATTRIBUTE_PRINTF (1, 2);
-
-/* Print a formatted message to the appropriate channel for
-   debugging output for the client.  This function must be
-   provided by the client.  */
-
-extern void debug_vprintf (const char *format, va_list ap)
-     ATTRIBUTE_PRINTF (1, 0);
-
-#endif /* COMMON_COMMON_DEBUG_H */
diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
deleted file mode 100644 (file)
index 92badd5..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/* Common definitions.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_COMMON_DEFS_H
-#define COMMON_COMMON_DEFS_H
-
-#include "config.h"
-
-#undef PACKAGE_NAME
-#undef PACKAGE_VERSION
-#undef PACKAGE_STRING
-#undef PACKAGE_TARNAME
-
-#ifdef GDBSERVER
-#include "build-gnulib-gdbserver/config.h"
-#else
-#include "../../gnulib/config.h"
-#endif
-
-#undef PACKAGE_NAME
-#undef PACKAGE_VERSION
-#undef PACKAGE_STRING
-#undef PACKAGE_TARNAME
-
-/* From:
-    https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html
-
-   "On some hosts that predate C++11, when using C++ one must define
-   __STDC_CONSTANT_MACROS to make visible the definitions of constant
-   macros such as INTMAX_C, and one must define __STDC_LIMIT_MACROS to
-   make visible the definitions of limit macros such as INTMAX_MAX.".
-
-   And:
-    https://www.gnu.org/software/gnulib/manual/html_node/inttypes_002eh.html
-
-   "On some hosts that predate C++11, when using C++ one must define
-   __STDC_FORMAT_MACROS to make visible the declarations of format
-   macros such as PRIdMAX."
-
-   Must do this before including any system header, since other system
-   headers may include stdint.h/inttypes.h.  */
-#define __STDC_CONSTANT_MACROS 1
-#define __STDC_LIMIT_MACROS 1
-#define __STDC_FORMAT_MACROS 1
-
-/* Some distros enable _FORTIFY_SOURCE by default, which on occasion
-   has caused build failures with -Wunused-result when a patch is
-   developed on a distro that does not enable _FORTIFY_SOURCE.  We
-   enable it here in order to try to catch these problems earlier;
-   plus this seems like a reasonable safety measure.  The check for
-   optimization is required because _FORTIFY_SOURCE only works when
-   optimization is enabled.  If _FORTIFY_SOURCE is already defined,
-   then we don't do anything.  */
-
-#if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
-#define _FORTIFY_SOURCE 2
-#endif
-
-/* We don't support Windows versions before XP, so we define
-   _WIN32_WINNT correspondingly to ensure the Windows API headers
-   expose the required symbols.  */
-#if defined (__MINGW32__) || defined (__CYGWIN__)
-# ifdef _WIN32_WINNT
-#  if _WIN32_WINNT < 0x0501
-#   undef _WIN32_WINNT
-#   define _WIN32_WINNT 0x0501
-#  endif
-# else
-#  define _WIN32_WINNT 0x0501
-# endif
-#endif /* __MINGW32__ || __CYGWIN__ */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <string.h>
-#ifdef HAVE_STRINGS_H
-#include <strings.h>   /* for strcasecmp and strncasecmp */
-#endif
-#include <errno.h>
-#include <alloca.h>
-
-#include "ansidecl.h"
-/* This is defined by ansidecl.h, but we prefer gnulib's version.  On
-   MinGW, gnulib might enable __USE_MINGW_ANSI_STDIO, which may or not
-   require use of attribute gnu_printf instead of printf.  gnulib
-   checks that at configure time.  Since _GL_ATTRIBUTE_FORMAT_PRINTF
-   is compatible with ATTRIBUTE_PRINTF, simply use it.  */
-#undef ATTRIBUTE_PRINTF
-#define ATTRIBUTE_PRINTF _GL_ATTRIBUTE_FORMAT_PRINTF
-
-#if GCC_VERSION >= 3004
-#define ATTRIBUTE_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
-#else
-#define ATTRIBUTE_UNUSED_RESULT
-#endif
-
-#include "libiberty.h"
-#include "pathmax.h"
-#include "gdb/signals.h"
-#include "gdb_locale.h"
-#include "ptid.h"
-#include "common-types.h"
-#include "common-utils.h"
-#include "gdb_assert.h"
-#include "errors.h"
-#include "print-utils.h"
-#include "common-debug.h"
-#include "cleanups.h"
-#include "common-exceptions.h"
-#include "common/poison.h"
-
-#define EXTERN_C extern "C"
-#define EXTERN_C_PUSH extern "C" {
-#define EXTERN_C_POP }
-
-/* Pull in gdb::unique_xmalloc_ptr.  */
-#include "common/gdb_unique_ptr.h"
-
-/* String containing the current directory (what getwd would return).  */
-extern char *current_directory;
-
-/* sbrk on macOS is not useful for our purposes, since sbrk(0) always
-   returns the same value.  brk/sbrk on macOS is just an emulation
-   that always returns a pointer to a 4MB section reserved for
-   that.  */
-
-#if defined (HAVE_SBRK) && !__APPLE__
-#define HAVE_USEFUL_SBRK 1
-#endif
-
-#endif /* COMMON_COMMON_DEFS_H */
diff --git a/gdb/common/common-exceptions.c b/gdb/common/common-exceptions.c
deleted file mode 100644 (file)
index 9f21025..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/* Exception (throw catch) mechanism, for GDB, the GNU debugger.
-
-   Copyright (C) 1986-2019 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 "common-defs.h"
-#include "common-exceptions.h"
-#include <forward_list>
-
-/* Possible catcher states.  */
-enum catcher_state {
-  /* Initial state, a new catcher has just been created.  */
-  CATCHER_CREATED,
-  /* The catch code is running.  */
-  CATCHER_RUNNING,
-  CATCHER_RUNNING_1,
-  /* The catch code threw an exception.  */
-  CATCHER_ABORTING
-};
-
-/* Possible catcher actions.  */
-enum catcher_action {
-  CATCH_ITER,
-  CATCH_ITER_1,
-  CATCH_THROWING
-};
-
-struct catcher
-{
-  enum catcher_state state = CATCHER_CREATED;
-  /* Jump buffer pointing back at the exception handler.  */
-  jmp_buf buf;
-  /* Status buffer belonging to the exception handler.  */
-  struct gdb_exception exception;
-};
-
-/* Where to go for throw_exception().  */
-static std::forward_list<struct catcher> catchers;
-
-jmp_buf *
-exceptions_state_mc_init ()
-{
-  catchers.emplace_front ();
-  return &catchers.front ().buf;
-}
-
-/* Catcher state machine.  Returns non-zero if the m/c should be run
-   again, zero if it should abort.  */
-
-static int
-exceptions_state_mc (enum catcher_action action)
-{
-  switch (catchers.front ().state)
-    {
-    case CATCHER_CREATED:
-      switch (action)
-       {
-       case CATCH_ITER:
-         /* Allow the code to run the catcher.  */
-         catchers.front ().state = CATCHER_RUNNING;
-         return 1;
-       default:
-         internal_error (__FILE__, __LINE__, _("bad state"));
-       }
-    case CATCHER_RUNNING:
-      switch (action)
-       {
-       case CATCH_ITER:
-         /* No error/quit has occured.  */
-         return 0;
-       case CATCH_ITER_1:
-         catchers.front ().state = CATCHER_RUNNING_1;
-         return 1;
-       case CATCH_THROWING:
-         catchers.front ().state = CATCHER_ABORTING;
-         /* See also throw_exception.  */
-         return 1;
-       default:
-         internal_error (__FILE__, __LINE__, _("bad switch"));
-       }
-    case CATCHER_RUNNING_1:
-      switch (action)
-       {
-       case CATCH_ITER:
-         /* The did a "break" from the inner while loop.  */
-         return 0;
-       case CATCH_ITER_1:
-         catchers.front ().state = CATCHER_RUNNING;
-         return 0;
-       case CATCH_THROWING:
-         catchers.front ().state = CATCHER_ABORTING;
-         /* See also throw_exception.  */
-         return 1;
-       default:
-         internal_error (__FILE__, __LINE__, _("bad switch"));
-       }
-    case CATCHER_ABORTING:
-      switch (action)
-       {
-       case CATCH_ITER:
-         {
-           /* Exit normally if this catcher can handle this
-              exception.  The caller analyses the func return
-              values.  */
-           return 0;
-         }
-       default:
-         internal_error (__FILE__, __LINE__, _("bad state"));
-       }
-    default:
-      internal_error (__FILE__, __LINE__, _("bad switch"));
-    }
-}
-
-int
-exceptions_state_mc_catch (struct gdb_exception *exception,
-                          int mask)
-{
-  *exception = std::move (catchers.front ().exception);
-  catchers.pop_front ();
-
-  if (exception->reason < 0)
-    {
-      if (mask & RETURN_MASK (exception->reason))
-       {
-         /* Exit normally and let the caller handle the
-            exception.  */
-         return 1;
-       }
-
-      /* The caller didn't request that the event be caught, relay the
-        event to the next exception_catch/CATCH_SJLJ.  */
-      throw_exception_sjlj (*exception);
-    }
-
-  /* No exception was thrown.  */
-  return 0;
-}
-
-int
-exceptions_state_mc_action_iter (void)
-{
-  return exceptions_state_mc (CATCH_ITER);
-}
-
-int
-exceptions_state_mc_action_iter_1 (void)
-{
-  return exceptions_state_mc (CATCH_ITER_1);
-}
-
-/* Return EXCEPTION to the nearest containing CATCH_SJLJ block.  */
-
-void
-throw_exception_sjlj (const struct gdb_exception &exception)
-{
-  /* Jump to the nearest CATCH_SJLJ block, communicating REASON to
-     that call via setjmp's return value.  Note that REASON can't be
-     zero, by definition in common-exceptions.h.  */
-  exceptions_state_mc (CATCH_THROWING);
-  enum return_reason reason = exception.reason;
-  catchers.front ().exception = exception;
-  longjmp (catchers.front ().buf, reason);
-}
-
-/* Implementation of throw_exception that uses C++ try/catch.  */
-
-void
-throw_exception (gdb_exception &&exception)
-{
-  if (exception.reason == RETURN_QUIT)
-    throw gdb_exception_quit (std::move (exception));
-  else if (exception.reason == RETURN_ERROR)
-    throw gdb_exception_error (std::move (exception));
-  else
-    gdb_assert_not_reached ("invalid return reason");
-}
-
-static void ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0)
-throw_it (enum return_reason reason, enum errors error, const char *fmt,
-         va_list ap)
-{
-  if (reason == RETURN_QUIT)
-    throw gdb_exception_quit (fmt, ap);
-  else if (reason == RETURN_ERROR)
-    throw gdb_exception_error (error, fmt, ap);
-  else
-    gdb_assert_not_reached ("invalid return reason");
-}
-
-void
-throw_verror (enum errors error, const char *fmt, va_list ap)
-{
-  throw_it (RETURN_ERROR, error, fmt, ap);
-}
-
-void
-throw_vquit (const char *fmt, va_list ap)
-{
-  throw_it (RETURN_QUIT, GDB_NO_ERROR, fmt, ap);
-}
-
-void
-throw_error (enum errors error, const char *fmt, ...)
-{
-  va_list args;
-
-  va_start (args, fmt);
-  throw_verror (error, fmt, args);
-  va_end (args);
-}
-
-void
-throw_quit (const char *fmt, ...)
-{
-  va_list args;
-
-  va_start (args, fmt);
-  throw_vquit (fmt, args);
-  va_end (args);
-}
diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
deleted file mode 100644 (file)
index ebcaf03..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-/* Exception (throw catch) mechanism, for GDB, the GNU debugger.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_COMMON_EXCEPTIONS_H
-#define COMMON_COMMON_EXCEPTIONS_H
-
-#include <setjmp.h>
-#include <new>
-#include <memory>
-#include <string>
-
-/* Reasons for calling throw_exceptions().  NOTE: all reason values
-   must be different from zero.  enum value 0 is reserved for internal
-   use as the return value from an initial setjmp().  */
-
-enum return_reason
-  {
-    /* User interrupt.  */
-    RETURN_QUIT = -2,
-    /* Any other error.  */
-    RETURN_ERROR
-  };
-
-#define RETURN_MASK(reason)    (1 << (int)(-reason))
-
-typedef enum
-{
-  RETURN_MASK_QUIT = RETURN_MASK (RETURN_QUIT),
-  RETURN_MASK_ERROR = RETURN_MASK (RETURN_ERROR),
-  RETURN_MASK_ALL = (RETURN_MASK_QUIT | RETURN_MASK_ERROR)
-} return_mask;
-
-/* Describe all exceptions.  */
-
-enum errors {
-  GDB_NO_ERROR,
-
-  /* Any generic error, the corresponding text is in
-     exception.message.  */
-  GENERIC_ERROR,
-
-  /* Something requested was not found.  */
-  NOT_FOUND_ERROR,
-
-  /* Thread library lacks support necessary for finding thread local
-     storage.  */
-  TLS_NO_LIBRARY_SUPPORT_ERROR,
-
-  /* Load module not found while attempting to find thread local storage.  */
-  TLS_LOAD_MODULE_NOT_FOUND_ERROR,
-
-  /* Thread local storage has not been allocated yet.  */
-  TLS_NOT_ALLOCATED_YET_ERROR,
-
-  /* Something else went wrong while attempting to find thread local
-     storage.  The ``struct gdb_exception'' message field provides
-     more detail.  */
-  TLS_GENERIC_ERROR,
-
-  /* Problem parsing an XML document.  */
-  XML_PARSE_ERROR,
-
-  /* Error accessing memory.  */
-  MEMORY_ERROR,
-
-  /* Value not available.  E.g., a register was not collected in a
-     traceframe.  */
-  NOT_AVAILABLE_ERROR,
-
-  /* Value was optimized out.  Note: if the value was a register, this
-     means the register was not saved in the frame.  */
-  OPTIMIZED_OUT_ERROR,
-
-  /* DW_OP_entry_value resolving failed.  */
-  NO_ENTRY_VALUE_ERROR,
-
-  /* Target throwing an error has been closed.  Current command should be
-     aborted as the inferior state is no longer valid.  */
-  TARGET_CLOSE_ERROR,
-
-  /* An undefined command was executed.  */
-  UNDEFINED_COMMAND_ERROR,
-
-  /* Requested feature, method, mechanism, etc. is not supported.  */
-  NOT_SUPPORTED_ERROR,
-
-  /* The number of candidates generated during line completion has
-     reached the user's specified limit.  This isn't an error, this exception
-     is used to halt searching for more completions, but for consistency
-     "_ERROR" is appended to the name.  */
-  MAX_COMPLETIONS_REACHED_ERROR,
-
-  /* Add more errors here.  */
-  NR_ERRORS
-};
-
-struct gdb_exception
-{
-  gdb_exception ()
-    : reason ((enum return_reason) 0),
-      error (GDB_NO_ERROR)
-  {
-  }
-
-  gdb_exception (enum return_reason r, enum errors e)
-    : reason (r),
-      error (e)
-  {
-  }
-
-  gdb_exception (enum return_reason r, enum errors e,
-                const char *fmt, va_list ap)
-    ATTRIBUTE_PRINTF (4, 0)
-    : reason (r),
-      error (e),
-      message (std::make_shared<std::string> (string_vprintf (fmt, ap)))
-  {
-  }
-
-  /* The move constructor exists so that we can mark it "noexcept",
-     which is a good practice for any sort of exception object.  */
-  explicit gdb_exception (gdb_exception &&other) noexcept = default;
-
-  /* The copy constructor exists so that we can mark it "noexcept",
-     which is a good practice for any sort of exception object.  */
-  gdb_exception (const gdb_exception &other) noexcept
-    : reason (other.reason),
-      error (other.error),
-      message (other.message)
-  {
-  }
-
-  /* The assignment operator exists so that we can mark it "noexcept",
-     which is a good practice for any sort of exception object.  */
-  gdb_exception &operator= (const gdb_exception &other) noexcept
-  {
-    reason = other.reason;
-    error = other.error;
-    message = other.message;
-    return *this;
-  }
-
-  gdb_exception &operator= (gdb_exception &&other) noexcept = default;
-
-  /* Return the contents of the exception message, as a C string.  The
-     string remains owned by the exception object.  */
-  const char *what () const noexcept
-  {
-    return message->c_str ();
-  }
-
-  enum return_reason reason;
-  enum errors error;
-  std::shared_ptr<std::string> message;
-};
-
-/* Functions to drive the sjlj-based exceptions state machine.  Though
-   declared here by necessity, these functions should be considered
-   internal to the exceptions subsystem and not used other than via
-   the TRY/CATCH (or TRY_SJLJ/CATCH_SJLJ) macros defined below.  */
-
-extern jmp_buf *exceptions_state_mc_init (void);
-extern int exceptions_state_mc_action_iter (void);
-extern int exceptions_state_mc_action_iter_1 (void);
-extern int exceptions_state_mc_catch (struct gdb_exception *, int);
-
-/* Macro to wrap up standard try/catch behavior.
-
-   The double loop lets us correctly handle code "break"ing out of the
-   try catch block.  (It works as the "break" only exits the inner
-   "while" loop, the outer for loop detects this handling it
-   correctly.)  Of course "return" and "goto" are not so lucky.
-
-   For instance:
-
-   *INDENT-OFF*
-
-   TRY_SJLJ
-     {
-     }
-   CATCH_SJLJ (e, RETURN_MASK_ERROR)
-     {
-       switch (e.reason)
-         {
-           case RETURN_ERROR: ...
-         }
-     }
-   END_CATCH_SJLJ
-
-   The SJLJ variants are needed in some cases where gdb exceptions
-   need to cross third-party library code compiled without exceptions
-   support (e.g., readline).  */
-
-#define TRY_SJLJ \
-     { \
-       jmp_buf *buf = \
-        exceptions_state_mc_init (); \
-       setjmp (*buf); \
-     } \
-     while (exceptions_state_mc_action_iter ()) \
-       while (exceptions_state_mc_action_iter_1 ())
-
-#define CATCH_SJLJ(EXCEPTION, MASK)                            \
-  {                                                    \
-    struct gdb_exception EXCEPTION;                            \
-    if (exceptions_state_mc_catch (&(EXCEPTION), MASK))
-
-#define END_CATCH_SJLJ                         \
-  }
-
-/* The exception types client code may catch.  They're just shims
-   around gdb_exception that add nothing but type info.  Which is used
-   is selected depending on the MASK argument passed to CATCH.  */
-
-struct gdb_exception_error : public gdb_exception
-{
-  gdb_exception_error (enum errors e, const char *fmt, va_list ap)
-    ATTRIBUTE_PRINTF (3, 0)
-    : gdb_exception (RETURN_ERROR, e, fmt, ap)
-  {
-  }
-
-  explicit gdb_exception_error (gdb_exception &&ex) noexcept
-    : gdb_exception (std::move (ex))
-  {
-    gdb_assert (ex.reason == RETURN_ERROR);
-  }
-};
-
-struct gdb_exception_quit : public gdb_exception
-{
-  gdb_exception_quit (const char *fmt, va_list ap)
-    ATTRIBUTE_PRINTF (2, 0)
-    : gdb_exception (RETURN_QUIT, GDB_NO_ERROR, fmt, ap)
-  {
-  }
-
-  explicit gdb_exception_quit (gdb_exception &&ex) noexcept
-    : gdb_exception (std::move (ex))
-  {
-    gdb_assert (ex.reason == RETURN_QUIT);
-  }
-};
-
-/* An exception type that inherits from both std::bad_alloc and a gdb
-   exception.  This is necessary because operator new can only throw
-   std::bad_alloc, and OTOH, we want exceptions thrown due to memory
-   allocation error to be caught by all the CATCH/RETURN_MASK_ALL
-   spread around the codebase.  */
-
-struct gdb_quit_bad_alloc
-  : public gdb_exception_quit,
-    public std::bad_alloc
-{
-  explicit gdb_quit_bad_alloc (gdb_exception &&ex) noexcept
-    : gdb_exception_quit (std::move (ex)),
-      std::bad_alloc ()
-  {
-  }
-};
-
-/* *INDENT-ON* */
-
-/* Throw an exception (as described by "struct gdb_exception"),
-   landing in the inner most containing exception handler established
-   using TRY/CATCH.  */
-extern void throw_exception (gdb_exception &&exception)
-     ATTRIBUTE_NORETURN;
-
-/* Throw an exception by executing a LONG JUMP to the inner most
-   containing exception handler established using TRY_SJLJ.  Necessary
-   in some cases where we need to throw GDB exceptions across
-   third-party library code (e.g., readline).  */
-extern void throw_exception_sjlj (const struct gdb_exception &exception)
-     ATTRIBUTE_NORETURN;
-
-/* Convenience wrappers around throw_exception that throw GDB
-   errors.  */
-extern void throw_verror (enum errors, const char *fmt, va_list ap)
-     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 0);
-extern void throw_vquit (const char *fmt, va_list ap)
-     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
-extern void throw_error (enum errors error, const char *fmt, ...)
-     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
-extern void throw_quit (const char *fmt, ...)
-     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
-
-#endif /* COMMON_COMMON_EXCEPTIONS_H */
diff --git a/gdb/common/common-gdbthread.h b/gdb/common/common-gdbthread.h
deleted file mode 100644 (file)
index d692be2..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Common multi-process/thread control defs for GDB and gdbserver.
-   Copyright (C) 1987-2019 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/>.  */
-
-#ifndef COMMON_COMMON_GDBTHREAD_H
-#define COMMON_COMMON_GDBTHREAD_H
-
-/* Switch from one thread to another.  */
-extern void switch_to_thread (ptid_t ptid);
-
-#endif /* COMMON_COMMON_GDBTHREAD_H */
diff --git a/gdb/common/common-inferior.h b/gdb/common/common-inferior.h
deleted file mode 100644 (file)
index 72e4bd9..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Functions to deal with the inferior being executed on GDB or
-   GDBserver.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_COMMON_INFERIOR_H
-#define COMMON_COMMON_INFERIOR_H
-
-/* Return the exec wrapper to be used when starting the inferior, or NULL
-   otherwise.  */
-extern const char *get_exec_wrapper ();
-
-/* Return the name of the executable file as a string.
-   ERR nonzero means get error if there is none specified;
-   otherwise return 0 in that case.  */
-extern char *get_exec_file (int err);
-
-/* Return the inferior's current working directory.  If nothing has
-   been set, then return NULL.  */
-extern const char *get_inferior_cwd ();
-
-/* Set the inferior current working directory.  If CWD is NULL, unset
-   the directory.  */
-extern void set_inferior_cwd (const char *cwd);
-
-#endif /* COMMON_COMMON_INFERIOR_H */
diff --git a/gdb/common/common-regcache.c b/gdb/common/common-regcache.c
deleted file mode 100644 (file)
index 4bdadff..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Cache and manage the values of registers for GDB, the GNU debugger.
-
-   Copyright (C) 2015-2019 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 "common-defs.h"
-#include "common-regcache.h"
-
-/* Return the register's value or throw if it's not available.  */
-
-ULONGEST
-regcache_raw_get_unsigned (struct regcache *regcache, int regnum)
-{
-  ULONGEST value;
-  enum register_status status;
-
-  status = regcache_raw_read_unsigned (regcache, regnum, &value);
-  if (status == REG_UNAVAILABLE)
-    throw_error (NOT_AVAILABLE_ERROR,
-                _("Register %d is not available"), regnum);
-  return value;
-}
diff --git a/gdb/common/common-regcache.h b/gdb/common/common-regcache.h
deleted file mode 100644 (file)
index 95ce64a..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Cache and manage the values of registers
-
-   Copyright (C) 2014-2019 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/>.  */
-
-#ifndef COMMON_COMMON_REGCACHE_H
-#define COMMON_COMMON_REGCACHE_H
-
-/* This header is a stopgap until we have an independent regcache.  */
-
-enum register_status : signed char
-  {
-    /* The register value is not in the cache, and we don't know yet
-       whether it's available in the target (or traceframe).  */
-    REG_UNKNOWN = 0,
-
-    /* The register value is valid and cached.  */
-    REG_VALID = 1,
-
-    /* The register value is unavailable.  E.g., we're inspecting a
-       traceframe, and this register wasn't collected.  Note that this
-       is different a different "unavailable" from saying the register
-       does not exist in the target's architecture --- in that case,
-       the target should have given us a target description that does
-       not include the register in the first place.  */
-    REG_UNAVAILABLE = -1
-  };
-
-/* Return a pointer to the register cache associated with the
-   thread specified by PTID.  This function must be provided by
-   the client.  */
-
-extern struct regcache *get_thread_regcache_for_ptid (ptid_t ptid);
-
-/* Return the size of register numbered N in REGCACHE.  This function
-   must be provided by the client.  */
-
-extern int regcache_register_size (const struct regcache *regcache, int n);
-
-/* Read the PC register.  This function must be provided by the
-   client.  */
-
-extern CORE_ADDR regcache_read_pc (struct regcache *regcache);
-
-/* Read a raw register into a unsigned integer.  */
-extern enum register_status regcache_raw_read_unsigned
-  (struct regcache *regcache, int regnum, ULONGEST *val);
-
-ULONGEST regcache_raw_get_unsigned (struct regcache *regcache, int regnum);
-
-struct reg_buffer_common
-{
-  virtual ~reg_buffer_common () = default;
-
-  /* Get the availability status of the value of register REGNUM in this
-     buffer.  */
-  virtual register_status get_register_status (int regnum) const = 0;
-
-  /* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE.  */
-  virtual void raw_supply (int regnum, const void *buf) = 0;
-
-  /* Collect register REGNUM from REGCACHE and store its contents in BUF.  */
-  virtual void raw_collect (int regnum, void *buf) const = 0;
-
-  /* Compare the contents of the register stored in the regcache (ignoring the
-     first OFFSET bytes) to the contents of BUF (without any offset).  Returns
-     true if the same.  */
-  virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0;
-};
-
-#endif /* COMMON_COMMON_REGCACHE_H */
diff --git a/gdb/common/common-types.h b/gdb/common/common-types.h
deleted file mode 100644 (file)
index ed73f6f..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Declarations for common types.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_COMMON_TYPES_H
-#define COMMON_COMMON_TYPES_H
-
-#ifdef GDBSERVER
-
-/* * A byte from the program being debugged.  */
-typedef unsigned char gdb_byte;
-
-typedef unsigned long long CORE_ADDR;
-
-typedef long long LONGEST;
-typedef unsigned long long ULONGEST;
-
-#else /* GDBSERVER */
-
-#include "bfd.h"
-
-/* * A byte from the program being debugged.  */
-typedef bfd_byte gdb_byte;
-
-/* * An address in the program being debugged.  Host byte order.  */
-typedef bfd_vma CORE_ADDR;
-
-/* This is to make sure that LONGEST is at least as big as CORE_ADDR.  */
-
-#ifdef BFD64
-
-typedef BFD_HOST_64_BIT LONGEST;
-typedef BFD_HOST_U_64_BIT ULONGEST;
-
-#else /* No BFD64 */
-
-typedef long long LONGEST;
-typedef unsigned long long ULONGEST;
-
-#endif /* No BFD64 */
-#endif /* GDBSERVER */
-
-/* * The largest CORE_ADDR value.  */
-#define CORE_ADDR_MAX (~(CORE_ADDR) 0)
-
-/* * The largest ULONGEST value.  */
-#define ULONGEST_MAX (~(ULONGEST) 0)
-
-enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 };
-
-#endif /* COMMON_COMMON_TYPES_H */
diff --git a/gdb/common/common-utils.c b/gdb/common/common-utils.c
deleted file mode 100644 (file)
index dd839a0..0000000
+++ /dev/null
@@ -1,358 +0,0 @@
-/* Shared general utility routines for GDB, the GNU debugger.
-
-   Copyright (C) 1986-2019 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 "common-defs.h"
-#include "common-utils.h"
-#include "host-defs.h"
-#include <ctype.h>
-
-void *
-xzalloc (size_t size)
-{
-  return xcalloc (1, size);
-}
-
-/* Like asprintf/vasprintf but get an internal_error if the call
-   fails. */
-
-char *
-xstrprintf (const char *format, ...)
-{
-  char *ret;
-  va_list args;
-
-  va_start (args, format);
-  ret = xstrvprintf (format, args);
-  va_end (args);
-  return ret;
-}
-
-char *
-xstrvprintf (const char *format, va_list ap)
-{
-  char *ret = NULL;
-  int status = vasprintf (&ret, format, ap);
-
-  /* NULL is returned when there was a memory allocation problem, or
-     any other error (for instance, a bad format string).  A negative
-     status (the printed length) with a non-NULL buffer should never
-     happen, but just to be sure.  */
-  if (ret == NULL || status < 0)
-    internal_error (__FILE__, __LINE__, _("vasprintf call failed"));
-  return ret;
-}
-
-int
-xsnprintf (char *str, size_t size, const char *format, ...)
-{
-  va_list args;
-  int ret;
-
-  va_start (args, format);
-  ret = vsnprintf (str, size, format, args);
-  gdb_assert (ret < size);
-  va_end (args);
-
-  return ret;
-}
-
-/* See documentation in common-utils.h.  */
-
-std::string
-string_printf (const char* fmt, ...)
-{
-  va_list vp;
-  int size;
-
-  va_start (vp, fmt);
-  size = vsnprintf (NULL, 0, fmt, vp);
-  va_end (vp);
-
-  std::string str (size, '\0');
-
-  /* C++11 and later guarantee std::string uses contiguous memory and
-     always includes the terminating '\0'.  */
-  va_start (vp, fmt);
-  vsprintf (&str[0], fmt, vp);
-  va_end (vp);
-
-  return str;
-}
-
-/* See documentation in common-utils.h.  */
-
-std::string
-string_vprintf (const char* fmt, va_list args)
-{
-  va_list vp;
-  size_t size;
-
-  va_copy (vp, args);
-  size = vsnprintf (NULL, 0, fmt, vp);
-  va_end (vp);
-
-  std::string str (size, '\0');
-
-  /* C++11 and later guarantee std::string uses contiguous memory and
-     always includes the terminating '\0'.  */
-  vsprintf (&str[0], fmt, args);
-
-  return str;
-}
-
-
-/* See documentation in common-utils.h.  */
-
-void
-string_appendf (std::string &str, const char *fmt, ...)
-{
-  va_list vp;
-
-  va_start (vp, fmt);
-  string_vappendf (str, fmt, vp);
-  va_end (vp);
-}
-
-
-/* See documentation in common-utils.h.  */
-
-void
-string_vappendf (std::string &str, const char *fmt, va_list args)
-{
-  va_list vp;
-  int grow_size;
-
-  va_copy (vp, args);
-  grow_size = vsnprintf (NULL, 0, fmt, vp);
-  va_end (vp);
-
-  size_t curr_size = str.size ();
-  str.resize (curr_size + grow_size);
-
-  /* C++11 and later guarantee std::string uses contiguous memory and
-     always includes the terminating '\0'.  */
-  vsprintf (&str[curr_size], fmt, args);
-}
-
-char *
-savestring (const char *ptr, size_t len)
-{
-  char *p = (char *) xmalloc (len + 1);
-
-  memcpy (p, ptr, len);
-  p[len] = 0;
-  return p;
-}
-
-/* The bit offset of the highest byte in a ULONGEST, for overflow
-   checking.  */
-
-#define HIGH_BYTE_POSN ((sizeof (ULONGEST) - 1) * HOST_CHAR_BIT)
-
-/* True (non-zero) iff DIGIT is a valid digit in radix BASE,
-   where 2 <= BASE <= 36.  */
-
-static int
-is_digit_in_base (unsigned char digit, int base)
-{
-  if (!isalnum (digit))
-    return 0;
-  if (base <= 10)
-    return (isdigit (digit) && digit < base + '0');
-  else
-    return (isdigit (digit) || tolower (digit) < base - 10 + 'a');
-}
-
-static int
-digit_to_int (unsigned char c)
-{
-  if (isdigit (c))
-    return c - '0';
-  else
-    return tolower (c) - 'a' + 10;
-}
-
-/* As for strtoul, but for ULONGEST results.  */
-
-ULONGEST
-strtoulst (const char *num, const char **trailer, int base)
-{
-  unsigned int high_part;
-  ULONGEST result;
-  int minus = 0;
-  int i = 0;
-
-  /* Skip leading whitespace.  */
-  while (isspace (num[i]))
-    i++;
-
-  /* Handle prefixes.  */
-  if (num[i] == '+')
-    i++;
-  else if (num[i] == '-')
-    {
-      minus = 1;
-      i++;
-    }
-
-  if (base == 0 || base == 16)
-    {
-      if (num[i] == '0' && (num[i + 1] == 'x' || num[i + 1] == 'X'))
-       {
-         i += 2;
-         if (base == 0)
-           base = 16;
-       }
-    }
-
-  if (base == 0 && num[i] == '0')
-    base = 8;
-
-  if (base == 0)
-    base = 10;
-
-  if (base < 2 || base > 36)
-    {
-      errno = EINVAL;
-      return 0;
-    }
-
-  result = high_part = 0;
-  for (; is_digit_in_base (num[i], base); i += 1)
-    {
-      result = result * base + digit_to_int (num[i]);
-      high_part = high_part * base + (unsigned int) (result >> HIGH_BYTE_POSN);
-      result &= ((ULONGEST) 1 << HIGH_BYTE_POSN) - 1;
-      if (high_part > 0xff)
-       {
-         errno = ERANGE;
-         result = ~ (ULONGEST) 0;
-         high_part = 0;
-         minus = 0;
-         break;
-       }
-    }
-
-  if (trailer != NULL)
-    *trailer = &num[i];
-
-  result = result + ((ULONGEST) high_part << HIGH_BYTE_POSN);
-  if (minus)
-    return -result;
-  else
-    return result;
-}
-
-/* See documentation in common-utils.h.  */
-
-char *
-skip_spaces (char *chp)
-{
-  if (chp == NULL)
-    return NULL;
-  while (*chp && isspace (*chp))
-    chp++;
-  return chp;
-}
-
-/* A const-correct version of the above.  */
-
-const char *
-skip_spaces (const char *chp)
-{
-  if (chp == NULL)
-    return NULL;
-  while (*chp && isspace (*chp))
-    chp++;
-  return chp;
-}
-
-/* See documentation in common-utils.h.  */
-
-const char *
-skip_to_space (const char *chp)
-{
-  if (chp == NULL)
-    return NULL;
-  while (*chp && !isspace (*chp))
-    chp++;
-  return chp;
-}
-
-/* See documentation in common-utils.h.  */
-
-char *
-skip_to_space (char *chp)
-{
-  return (char *) skip_to_space ((const char *) chp);
-}
-
-/* See common/common-utils.h.  */
-
-void
-free_vector_argv (std::vector<char *> &v)
-{
-  for (char *el : v)
-    xfree (el);
-
-  v.clear ();
-}
-
-/* See common/common-utils.h.  */
-
-std::string
-stringify_argv (const std::vector<char *> &args)
-{
-  std::string ret;
-
-  if (!args.empty () && args[0] != NULL)
-    {
-      for (auto s : args)
-       if (s != NULL)
-         {
-           ret += s;
-           ret += ' ';
-         }
-
-      /* Erase the last whitespace.  */
-      ret.erase (ret.end () - 1);
-    }
-
-  return ret;
-}
-
-/* See common/common-utils.h.  */
-
-ULONGEST
-align_up (ULONGEST v, int n)
-{
-  /* Check that N is really a power of two.  */
-  gdb_assert (n && (n & (n-1)) == 0);
-  return (v + n - 1) & -n;
-}
-
-/* See common/common-utils.h.  */
-
-ULONGEST
-align_down (ULONGEST v, int n)
-{
-  /* Check that N is really a power of two.  */
-  gdb_assert (n && (n & (n-1)) == 0);
-  return (v & -n);
-}
diff --git a/gdb/common/common-utils.h b/gdb/common/common-utils.h
deleted file mode 100644 (file)
index 52bf343..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/* Shared general utility routines for GDB, the GNU debugger.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_COMMON_UTILS_H
-#define COMMON_COMMON_UTILS_H
-
-#include <string>
-#include <vector>
-
-#include "poison.h"
-
-/* If possible, define FUNCTION_NAME, a macro containing the name of
-   the function being defined.  Since this macro may not always be
-   defined, all uses must be protected by appropriate macro definition
-   checks (Eg: "#ifdef FUNCTION_NAME").
-
-   Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
-   which contains the name of the function currently being defined.
-   This is broken in G++ before version 2.6.
-   C9x has a similar variable called __func__, but prefer the GCC one since
-   it demangles C++ function names.  */
-#if (GCC_VERSION >= 2004)
-#define FUNCTION_NAME          __PRETTY_FUNCTION__
-#else
-#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
-#define FUNCTION_NAME          __func__  /* ARI: func */
-#endif
-#endif
-
-/* xmalloc(), xrealloc() and xcalloc() have already been declared in
-   "libiberty.h". */
-
-/* Like xmalloc, but zero the memory.  */
-void *xzalloc (size_t);
-
-template <typename T>
-static void
-xfree (T *ptr)
-{
-  static_assert (IsFreeable<T>::value, "Trying to use xfree with a non-POD \
-data type.  Use operator delete instead.");
-
-  if (ptr != NULL)
-    free (ptr);                /* ARI: free */
-}
-
-
-/* Like asprintf and vasprintf, but return the string, throw an error
-   if no memory.  */
-char *xstrprintf (const char *format, ...) ATTRIBUTE_PRINTF (1, 2);
-char *xstrvprintf (const char *format, va_list ap)
-     ATTRIBUTE_PRINTF (1, 0);
-
-/* Like snprintf, but throw an error if the output buffer is too small.  */
-int xsnprintf (char *str, size_t size, const char *format, ...)
-     ATTRIBUTE_PRINTF (3, 4);
-
-/* Returns a std::string built from a printf-style format string.  */
-std::string string_printf (const char* fmt, ...)
-  ATTRIBUTE_PRINTF (1, 2);
-
-/* Like string_printf, but takes a va_list.  */
-std::string string_vprintf (const char* fmt, va_list args)
-  ATTRIBUTE_PRINTF (1, 0);
-
-/* Like string_printf, but appends to DEST instead of returning a new
-   std::string.  */
-void string_appendf (std::string &dest, const char* fmt, ...)
-  ATTRIBUTE_PRINTF (2, 3);
-
-/* Like string_appendf, but takes a va_list.  */
-void string_vappendf (std::string &dest, const char* fmt, va_list args)
-  ATTRIBUTE_PRINTF (2, 0);
-
-/* Make a copy of the string at PTR with LEN characters
-   (and add a null character at the end in the copy).
-   Uses malloc to get the space.  Returns the address of the copy.  */
-
-char *savestring (const char *ptr, size_t len);
-
-/* The strerror() function can return NULL for errno values that are
-   out of range.  Provide a "safe" version that always returns a
-   printable string.  */
-
-extern char *safe_strerror (int);
-
-/* Return non-zero if the start of STRING matches PATTERN, zero
-   otherwise.  */
-
-static inline int
-startswith (const char *string, const char *pattern)
-{
-  return strncmp (string, pattern, strlen (pattern)) == 0;
-}
-
-ULONGEST strtoulst (const char *num, const char **trailer, int base);
-
-/* Skip leading whitespace characters in INP, returning an updated
-   pointer.  If INP is NULL, return NULL.  */
-
-extern char *skip_spaces (char *inp);
-
-/* A const-correct version of the above.  */
-
-extern const char *skip_spaces (const char *inp);
-
-/* Skip leading non-whitespace characters in INP, returning an updated
-   pointer.  If INP is NULL, return NULL.  */
-
-extern char *skip_to_space (char *inp);
-
-/* A const-correct version of the above.  */
-
-extern const char *skip_to_space (const char *inp);
-
-/* Assumes that V is an argv for a program, and iterates through
-   freeing all the elements.  */
-extern void free_vector_argv (std::vector<char *> &v);
-
-/* Given a vector of arguments ARGV, return a string equivalent to
-   joining all the arguments with a whitespace separating them.  */
-extern std::string stringify_argv (const std::vector<char *> &argv);
-
-/* Return true if VALUE is in [LOW, HIGH].  */
-
-template <typename T>
-static bool
-in_inclusive_range (T value, T low, T high)
-{
-  return value >= low && value <= high;
-}
-
-/* Ensure that V is aligned to an N byte boundary (B's assumed to be a
-   power of 2).  Round up/down when necessary.  Examples of correct
-   use include:
-
-    addr = align_up (addr, 8); -- VALUE needs 8 byte alignment
-    write_memory (addr, value, len);
-    addr += len;
-
-   and:
-
-    sp = align_down (sp - len, 16); -- Keep SP 16 byte aligned
-    write_memory (sp, value, len);
-
-   Note that uses such as:
-
-    write_memory (addr, value, len);
-    addr += align_up (len, 8);
-
-   and:
-
-    sp -= align_up (len, 8);
-    write_memory (sp, value, len);
-
-   are typically not correct as they don't ensure that the address (SP
-   or ADDR) is correctly aligned (relying on previous alignment to
-   keep things right).  This is also why the methods are called
-   "align_..." instead of "round_..." as the latter reads better with
-   this incorrect coding style.  */
-
-extern ULONGEST align_up (ULONGEST v, int n);
-extern ULONGEST align_down (ULONGEST v, int n);
-
-#endif /* COMMON_COMMON_UTILS_H */
diff --git a/gdb/common/common.host b/gdb/common/common.host
deleted file mode 100644 (file)
index 83fa184..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# Common object files to include for each host.
-#
-# Copyright (C) 2015-2019 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/>.
-
-# Map host triplet into the common object files to be included by
-# GDB/gdbserver.  This is invoked from the autoconf generated
-# configure script.
-
-# This file sets the following shell variables:
-#  common_host_obs             host-specific .o files to include when building
-#                              GDB/gdbserver
-
-case "${host}" in
-
-*-mingw*)      common_host_obs=common/mingw-strerror.o
-               ;;
-*)
-               common_host_obs=common/posix-strerror.o
-               ;;
-
-esac
diff --git a/gdb/common/common.m4 b/gdb/common/common.m4
deleted file mode 100644 (file)
index 5701dd9..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-dnl Autoconf configure snippets for common.
-dnl Copyright (C) 1995-2019 Free Software Foundation, Inc.
-dnl
-dnl This file is part of GDB.
-dnl 
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 3 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-dnl Invoke configury needed by the files in 'common'.
-AC_DEFUN([GDB_AC_COMMON], [
-  AC_HEADER_STDC
-  AC_FUNC_ALLOCA
-
-  dnl Note that this requires codeset.m4, which is included
-  dnl by the users of common.m4.
-  AM_LANGINFO_CODESET
-
-  AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl
-                  sys/resource.h sys/socket.h dnl
-                  sys/un.h sys/wait.h dnl
-                  thread_db.h wait.h dnl
-                  termios.h)
-
-  AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair sigaction])
-
-  AC_CHECK_DECLS([strerror, strstr])
-
-  dnl Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't
-  dnl do since sigsetjmp might only be defined as a macro.
-AC_CACHE_CHECK([for sigsetjmp], gdb_cv_func_sigsetjmp,
-[AC_TRY_COMPILE([
-#include <setjmp.h>
-], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);],
-gdb_cv_func_sigsetjmp=yes, gdb_cv_func_sigsetjmp=no)])
-if test $gdb_cv_func_sigsetjmp = yes; then
-  AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
-fi
-])
diff --git a/gdb/common/create-version.sh b/gdb/common/create-version.sh
deleted file mode 100755 (executable)
index 6e67a61..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 1989-2019 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/>.
-
-# Create version.c from version.in.
-# Usage:
-#    create-version.sh PATH-TO-GDB-SRCDIR HOST_ALIAS \
-#        TARGET_ALIAS OUTPUT-FILE-NAME
-
-srcdir="$1"
-host_alias="$2"
-target_alias="$3"
-output="$4"
-
-rm -f version.c-tmp $output version.tmp
-date=`sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$/\1/p' $srcdir/../bfd/version.h`
-sed -e "s/DATE/$date/" < $srcdir/version.in > version.tmp
-echo '#include "common/version.h"' >> version.c-tmp
-echo 'const char version[] = "'"`sed q version.tmp`"'";' >> version.c-tmp
-echo 'const char host_name[] = "'"$host_alias"'";' >> version.c-tmp
-echo 'const char target_name[] = "'"$target_alias"'";' >> version.c-tmp
-mv version.c-tmp $output
-rm -f version.tmp
diff --git a/gdb/common/def-vector.h b/gdb/common/def-vector.h
deleted file mode 100644 (file)
index 90c9ff5..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_DEF_VECTOR_H
-#define COMMON_DEF_VECTOR_H
-
-#include <vector>
-#include "common/default-init-alloc.h"
-
-namespace gdb {
-
-/* A vector that uses an allocator that default constructs using
-   default-initialization rather than value-initialization.  The idea
-   is to use this when you don't want zero-initialization of elements
-   of vectors of trivial types.  E.g., byte buffers.  */
-
-template<typename T> using def_vector
-  = std::vector<T, gdb::default_init_allocator<T>>;
-
-} /* namespace gdb */
-
-#endif /* COMMON_DEF_VECTOR_H */
diff --git a/gdb/common/default-init-alloc.h b/gdb/common/default-init-alloc.h
deleted file mode 100644 (file)
index 2d739c9..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_DEFAULT_INIT_ALLOC_H
-#define COMMON_DEFAULT_INIT_ALLOC_H
-
-namespace gdb {
-
-/* An allocator that default constructs using default-initialization
-   rather than value-initialization.  The idea is to use this when you
-   don't want to default construct elements of containers of trivial
-   types using zero-initialization.  */
-
-/* Mostly as implementation convenience, this is implemented as an
-   adapter that given an allocator A, overrides 'A::construct()'.  'A'
-   defaults to std::allocator<T>.  */
-
-template<typename T, typename A = std::allocator<T>>
-class default_init_allocator : public A
-{
-public:
-  /* Pull in A's ctors.  */
-  using A::A;
-
-  /* Override rebind.  */
-  template<typename U>
-  struct rebind
-  {
-    /* A couple helpers just to make it a bit more readable.  */
-    typedef std::allocator_traits<A> traits_;
-    typedef typename traits_::template rebind_alloc<U> alloc_;
-
-    /* This is what we're after.  */
-    typedef default_init_allocator<U, alloc_> other;
-  };
-
-  /* Make the base allocator's construct method(s) visible.  */
-  using A::construct;
-
-  /* .. and provide an override/overload for the case of default
-     construction (i.e., no arguments).  This is where we construct
-     with default-init.  */
-  template <typename U>
-  void construct (U *ptr)
-    noexcept (std::is_nothrow_default_constructible<U>::value)
-  {
-    ::new ((void *) ptr) U; /* default-init */
-  }
-};
-
-} /* namespace gdb */
-
-#endif /* COMMON_DEFAULT_INIT_ALLOC_H */
diff --git a/gdb/common/enum-flags.h b/gdb/common/enum-flags.h
deleted file mode 100644 (file)
index 88ba591..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/* Copyright (C) 2015-2019 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/>.  */
-
-#ifndef COMMON_ENUM_FLAGS_H
-#define COMMON_ENUM_FLAGS_H
-
-/* Type-safe wrapper for enum flags.  enum flags are enums where the
-   values are bits that are meant to be ORed together.
-
-   This allows writing code like the below, while with raw enums this
-   would fail to compile without casts to enum type at the assignments
-   to 'f':
-
-    enum some_flag
-    {
-       flag_val1 = 1 << 1,
-       flag_val2 = 1 << 2,
-       flag_val3 = 1 << 3,
-       flag_val4 = 1 << 4,
-    };
-    DEF_ENUM_FLAGS_TYPE(enum some_flag, some_flags);
-
-    some_flags f = flag_val1 | flag_val2;
-    f |= flag_val3;
-
-   It's also possible to assign literal zero to an enum flags variable
-   (meaning, no flags), dispensing adding an awkward explicit "no
-   value" value to the enumeration.  For example:
-
-    some_flags f = 0;
-    f |= flag_val3 | flag_val4;
-
-   Note that literal integers other than zero fail to compile:
-
-    some_flags f = 1; // error
-*/
-
-#ifdef __cplusplus
-
-/* Traits type used to prevent the global operator overloads from
-   instantiating for non-flag enums.  */
-template<typename T> struct enum_flags_type {};
-
-/* Use this to mark an enum as flags enum.  It defines FLAGS as
-   enum_flags wrapper class for ENUM, and enables the global operator
-   overloads for ENUM.  */
-#define DEF_ENUM_FLAGS_TYPE(enum_type, flags_type)     \
-  typedef enum_flags<enum_type> flags_type;            \
-  template<>                                           \
-  struct enum_flags_type<enum_type>                    \
-  {                                                    \
-    typedef enum_flags<enum_type> type;                        \
-  }
-
-/* Until we can rely on std::underlying type being universally
-   available (C++11), roll our own for enums.  */
-template<int size, bool sign> class integer_for_size { typedef void type; };
-template<> struct integer_for_size<1, 0> { typedef uint8_t type; };
-template<> struct integer_for_size<2, 0> { typedef uint16_t type; };
-template<> struct integer_for_size<4, 0> { typedef uint32_t type; };
-template<> struct integer_for_size<8, 0> { typedef uint64_t type; };
-template<> struct integer_for_size<1, 1> { typedef int8_t type; };
-template<> struct integer_for_size<2, 1> { typedef int16_t type; };
-template<> struct integer_for_size<4, 1> { typedef int32_t type; };
-template<> struct integer_for_size<8, 1> { typedef int64_t type; };
-
-template<typename T>
-struct enum_underlying_type
-{
-  typedef typename
-    integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
-    type;
-};
-
-template <typename E>
-class enum_flags
-{
-public:
-  typedef E enum_type;
-  typedef typename enum_underlying_type<enum_type>::type underlying_type;
-
-private:
-  /* Private type used to support initializing flag types with zero:
-
-       foo_flags f = 0;
-
-     but not other integers:
-
-       foo_flags f = 1;
-
-     The way this works is that we define an implicit constructor that
-     takes a pointer to this private type.  Since nothing can
-     instantiate an object of this type, the only possible pointer to
-     pass to the constructor is the NULL pointer, or, zero.  */
-  struct zero_type;
-
-  underlying_type
-  underlying_value () const
-  {
-    return m_enum_value;
-  }
-
-public:
-  /* Allow default construction.  */
-  enum_flags ()
-    : m_enum_value ((enum_type) 0)
-  {}
-
-  /* If you get an error saying these two overloads are ambiguous,
-     then you tried to mix values of different enum types.  */
-  enum_flags (enum_type e)
-    : m_enum_value (e)
-  {}
-  enum_flags (struct enum_flags::zero_type *zero)
-    : m_enum_value ((enum_type) 0)
-  {}
-
-  enum_flags &operator&= (enum_type e)
-  {
-    m_enum_value = (enum_type) (underlying_value () & e);
-    return *this;
-  }
-  enum_flags &operator|= (enum_type e)
-  {
-    m_enum_value = (enum_type) (underlying_value () | e);
-    return *this;
-  }
-  enum_flags &operator^= (enum_type e)
-  {
-    m_enum_value = (enum_type) (underlying_value () ^ e);
-    return *this;
-  }
-
-  operator enum_type () const
-  {
-    return m_enum_value;
-  }
-
-  enum_flags operator& (enum_type e) const
-  {
-    return (enum_type) (underlying_value () & e);
-  }
-  enum_flags operator| (enum_type e) const
-  {
-    return (enum_type) (underlying_value () | e);
-  }
-  enum_flags operator^ (enum_type e) const
-  {
-    return (enum_type) (underlying_value () ^ e);
-  }
-  enum_flags operator~ () const
-  {
-    // We only the underlying type to be unsigned when actually using
-    // operator~ -- if it were not unsigned, undefined behavior could
-    // result.  However, asserting this in the class itself would
-    // require too many unnecessary changes to otherwise ok enum
-    // types.
-    gdb_static_assert (std::is_unsigned<underlying_type>::value);
-    return (enum_type) ~underlying_value ();
-  }
-
-private:
-  /* Stored as enum_type because GDB knows to print the bit flags
-     neatly if the enum values look like bit flags.  */
-  enum_type m_enum_value;
-};
-
-/* Global operator overloads.  */
-
-template <typename enum_type>
-typename enum_flags_type<enum_type>::type
-operator& (enum_type e1, enum_type e2)
-{
-  return enum_flags<enum_type> (e1) & e2;
-}
-
-template <typename enum_type>
-typename enum_flags_type<enum_type>::type
-operator| (enum_type e1, enum_type e2)
-{
-  return enum_flags<enum_type> (e1) | e2;
-}
-
-template <typename enum_type>
-typename enum_flags_type<enum_type>::type
-operator^ (enum_type e1, enum_type e2)
-{
-  return enum_flags<enum_type> (e1) ^ e2;
-}
-
-template <typename enum_type>
-typename enum_flags_type<enum_type>::type
-operator~ (enum_type e)
-{
-  return ~enum_flags<enum_type> (e);
-}
-
-#else /* __cplusplus */
-
-/* In C, the flags type is just a typedef for the enum type.  */
-
-#define DEF_ENUM_FLAGS_TYPE(enum_type, flags_type) \
-  typedef enum_type flags_type
-
-#endif /* __cplusplus */
-
-#endif /* COMMON_ENUM_FLAGS_H */
diff --git a/gdb/common/environ.c b/gdb/common/environ.c
deleted file mode 100644 (file)
index 0c4106c..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/* environ.c -- library for manipulating environments for GNU.
-
-   Copyright (C) 1986-2019 Free Software Foundation, Inc.
-
-   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 "common-defs.h"
-#include "environ.h"
-#include <algorithm>
-#include <utility>
-
-/* See common/environ.h.  */
-
-gdb_environ &
-gdb_environ::operator= (gdb_environ &&e)
-{
-  /* Are we self-moving?  */
-  if (&e == this)
-    return *this;
-
-  m_environ_vector = std::move (e.m_environ_vector);
-  m_user_set_env = std::move (e.m_user_set_env);
-  m_user_unset_env = std::move (e.m_user_unset_env);
-  e.m_environ_vector.clear ();
-  e.m_environ_vector.push_back (NULL);
-  e.m_user_set_env.clear ();
-  e.m_user_unset_env.clear ();
-  return *this;
-}
-
-/* See common/environ.h.  */
-
-gdb_environ gdb_environ::from_host_environ ()
-{
-  extern char **environ;
-  gdb_environ e;
-
-  if (environ == NULL)
-    return e;
-
-  for (int i = 0; environ[i] != NULL; ++i)
-    {
-      /* Make sure we add the element before the last (NULL).  */
-      e.m_environ_vector.insert (e.m_environ_vector.end () - 1,
-                                xstrdup (environ[i]));
-    }
-
-  return e;
-}
-
-/* See common/environ.h.  */
-
-void
-gdb_environ::clear ()
-{
-  for (char *v : m_environ_vector)
-    xfree (v);
-  m_environ_vector.clear ();
-  /* Always add the NULL element.  */
-  m_environ_vector.push_back (NULL);
-  m_user_set_env.clear ();
-  m_user_unset_env.clear ();
-}
-
-/* Helper function to check if STRING contains an environment variable
-   assignment of VAR, i.e., if STRING starts with 'VAR='.  Return true
-   if it contains, false otherwise.  */
-
-static bool
-match_var_in_string (const char *string, const char *var, size_t var_len)
-{
-  if (strncmp (string, var, var_len) == 0 && string[var_len] == '=')
-    return true;
-
-  return false;
-}
-
-/* See common/environ.h.  */
-
-const char *
-gdb_environ::get (const char *var) const
-{
-  size_t len = strlen (var);
-
-  for (char *el : m_environ_vector)
-    if (el != NULL && match_var_in_string (el, var, len))
-      return &el[len + 1];
-
-  return NULL;
-}
-
-/* See common/environ.h.  */
-
-void
-gdb_environ::set (const char *var, const char *value)
-{
-  char *fullvar = concat (var, "=", value, NULL);
-
-  /* We have to unset the variable in the vector if it exists.  */
-  unset (var, false);
-
-  /* Insert the element before the last one, which is always NULL.  */
-  m_environ_vector.insert (m_environ_vector.end () - 1, fullvar);
-
-  /* Mark this environment variable as having been set by the user.
-     This will be useful when we deal with setting environment
-     variables on the remote target.  */
-  m_user_set_env.insert (std::string (fullvar));
-
-  /* If this environment variable is marked as unset by the user, then
-     remove it from the list, because now the user wants to set
-     it.  */
-  m_user_unset_env.erase (std::string (var));
-}
-
-/* See common/environ.h.  */
-
-void
-gdb_environ::unset (const char *var, bool update_unset_list)
-{
-  size_t len = strlen (var);
-  std::vector<char *>::iterator it_env;
-
-  /* We iterate until '.end () - 1' because the last element is
-     always NULL.  */
-  for (it_env = m_environ_vector.begin ();
-       it_env != m_environ_vector.end () - 1;
-       ++it_env)
-    if (match_var_in_string (*it_env, var, len))
-      break;
-
-  if (it_env != m_environ_vector.end () - 1)
-    {
-      m_user_set_env.erase (std::string (*it_env));
-      xfree (*it_env);
-
-      m_environ_vector.erase (it_env);
-    }
-
-  if (update_unset_list)
-    m_user_unset_env.insert (std::string (var));
-}
-
-/* See common/environ.h.  */
-
-void
-gdb_environ::unset (const char *var)
-{
-  unset (var, true);
-}
-
-/* See common/environ.h.  */
-
-char **
-gdb_environ::envp () const
-{
-  return const_cast<char **> (&m_environ_vector[0]);
-}
-
-/* See common/environ.h.  */
-
-const std::set<std::string> &
-gdb_environ::user_set_env () const
-{
-  return m_user_set_env;
-}
-
-const std::set<std::string> &
-gdb_environ::user_unset_env () const
-{
-  return m_user_unset_env;
-}
diff --git a/gdb/common/environ.h b/gdb/common/environ.h
deleted file mode 100644 (file)
index 8a6b907..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Header for environment manipulation library.
-   Copyright (C) 1989-2019 Free Software Foundation, Inc.
-
-   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/>.  */
-
-#ifndef COMMON_ENVIRON_H
-#define COMMON_ENVIRON_H
-
-#include <vector>
-#include <set>
-
-/* Class that represents the environment variables as seen by the
-   inferior.  */
-
-class gdb_environ
-{
-public:
-  /* Regular constructor and destructor.  */
-  gdb_environ ()
-  {
-    /* Make sure that the vector contains at least a NULL element.
-       If/when we add more variables to it, NULL will always be the
-       last element.  */
-    m_environ_vector.push_back (NULL);
-  }
-
-  ~gdb_environ ()
-  {
-    clear ();
-  }
-
-  /* Move constructor.  */
-  gdb_environ (gdb_environ &&e)
-    : m_environ_vector (std::move (e.m_environ_vector)),
-      m_user_set_env (std::move (e.m_user_set_env)),
-      m_user_unset_env (std::move (e.m_user_unset_env))
-  {
-    /* Make sure that the moved-from vector is left at a valid
-       state (only one NULL element).  */
-    e.m_environ_vector.clear ();
-    e.m_environ_vector.push_back (NULL);
-    e.m_user_set_env.clear ();
-    e.m_user_unset_env.clear ();
-  }
-
-  /* Move assignment.  */
-  gdb_environ &operator= (gdb_environ &&e);
-
-  /* Create a gdb_environ object using the host's environment
-     variables.  */
-  static gdb_environ from_host_environ ();
-
-  /* Clear the environment variables stored in the object.  */
-  void clear ();
-
-  /* Return the value in the environment for the variable VAR.  The
-     returned pointer is only valid as long as the gdb_environ object
-     is not modified.  */
-  const char *get (const char *var) const;
-
-  /* Store VAR=VALUE in the environment.  */
-  void set (const char *var, const char *value);
-
-  /* Unset VAR in environment.  */
-  void unset (const char *var);
-
-  /* Return the environment vector represented as a 'char **'.  */
-  char **envp () const;
-
-  /* Return the user-set environment vector.  */
-  const std::set<std::string> &user_set_env () const;
-
-  /* Return the user-unset environment vector.  */
-  const std::set<std::string> &user_unset_env () const;
-
-private:
-  /* Unset VAR in environment.  If UPDATE_UNSET_LIST is true, then
-     also update M_USER_UNSET_ENV to reflect the unsetting of the
-     environment variable.  */
-  void unset (const char *var, bool update_unset_list);
-
-  /* A vector containing the environment variables.  */
-  std::vector<char *> m_environ_vector;
-
-  /* The environment variables explicitly set by the user.  */
-  std::set<std::string> m_user_set_env;
-
-  /* The environment variables explicitly unset by the user.  */
-  std::set<std::string> m_user_unset_env;
-};
-
-#endif /* COMMON_ENVIRON_H */
diff --git a/gdb/common/errors.c b/gdb/common/errors.c
deleted file mode 100644 (file)
index 2208012..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Error reporting facilities.
-
-   Copyright (C) 1986-2019 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 "common-defs.h"
-#include "errors.h"
-
-/* See common/errors.h.  */
-
-void
-warning (const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start (ap, fmt);
-  vwarning (fmt, ap);
-  va_end (ap);
-}
-
-/* See common/errors.h.  */
-
-void
-error (const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start (ap, fmt);
-  verror (fmt, ap);
-  va_end (ap);
-}
-
-/* See common/errors.h.  */
-
-void
-internal_error (const char *file, int line, const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start (ap, fmt);
-  internal_verror (file, line, fmt, ap);
-  va_end (ap);
-}
-
-/* See common/errors.h.  */
-
-void
-internal_warning (const char *file, int line, const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start (ap, fmt);
-  internal_vwarning (file, line, fmt, ap);
-  va_end (ap);
-}
diff --git a/gdb/common/errors.h b/gdb/common/errors.h
deleted file mode 100644 (file)
index 8dbc6cf..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Declarations for error-reporting facilities.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_ERRORS_H
-#define COMMON_ERRORS_H
-
-/* A problem was detected, but the requested operation can still
-   proceed.  A warning message is constructed using a printf- or
-   vprintf-style argument list.  The function "vwarning" must be
-   provided by the client.  */
-
-extern void warning (const char *fmt, ...)
-     ATTRIBUTE_PRINTF (1, 2);
-
-extern void vwarning (const char *fmt, va_list args)
-     ATTRIBUTE_PRINTF (1, 0);
-
-/* A non-predictable, non-fatal error was detected.  The requested
-   operation cannot proceed.  An error message is constructed using
-   a printf- or vprintf-style argument list.  These functions do not
-   return.  The function "verror" must be provided by the client.  */
-
-extern void error (const char *fmt, ...)
-     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
-
-extern void verror (const char *fmt, va_list args)
-     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
-
-/* An internal error was detected.  Internal errors indicate
-   programming errors such as assertion failures, as opposed to
-   more general errors beyond the application's control.  These
-   functions do not return.  An error message is constructed using
-   a printf- or vprintf-style argument list.  FILE and LINE
-   indicate the file and line number where the programming error
-   was detected.  The function "internal_verror" must be provided
-   by the client.  */
-
-extern void internal_error (const char *file, int line,
-                           const char *fmt, ...)
-     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4);
-
-extern void internal_verror (const char *file, int line,
-                            const char *fmt, va_list args)
-     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0);
-
-/* An internal problem was detected, but the requested operation can
-   still proceed.  Internal warnings indicate programming errors as
-   opposed to more general issues beyond the application's control.
-   A warning message is constructed using a printf- or vprintf-style
-   argument list.  The function "internal_vwarning" must be provided
-   by the client.  */
-
-extern void internal_warning (const char *file, int line,
-                             const char *fmt, ...)
-     ATTRIBUTE_PRINTF (3, 4);
-
-extern void internal_vwarning (const char *file, int line,
-                              const char *fmt, va_list args)
-     ATTRIBUTE_PRINTF (3, 0);
-\f
-
-/* Like "error", but the error message is constructed by combining
-   STRING with the system error message for errno.  This function does
-   not return.  This function must be provided by the client.  */
-
-extern void perror_with_name (const char *string) ATTRIBUTE_NORETURN;
-
-/* Call this function to handle memory allocation failures.  This
-   function does not return.  This function must be provided by the
-   client.  */
-
-extern void malloc_failure (long size) ATTRIBUTE_NORETURN;
-
-#endif /* COMMON_ERRORS_H */
diff --git a/gdb/common/fileio.c b/gdb/common/fileio.c
deleted file mode 100644 (file)
index 28d97fc..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-/* File-I/O functions for GDB, the GNU debugger.
-
-   Copyright (C) 2003-2019 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 "common-defs.h"
-#include "fileio.h"
-#include <sys/stat.h>
-#include <fcntl.h>
-
-/* See fileio.h.  */
-
-int
-host_to_fileio_error (int error)
-{
-  switch (error)
-    {
-      case EPERM:
-        return FILEIO_EPERM;
-      case ENOENT:
-        return FILEIO_ENOENT;
-      case EINTR:
-        return FILEIO_EINTR;
-      case EIO:
-        return FILEIO_EIO;
-      case EBADF:
-        return FILEIO_EBADF;
-      case EACCES:
-        return FILEIO_EACCES;
-      case EFAULT:
-        return FILEIO_EFAULT;
-      case EBUSY:
-        return FILEIO_EBUSY;
-      case EEXIST:
-        return FILEIO_EEXIST;
-      case ENODEV:
-        return FILEIO_ENODEV;
-      case ENOTDIR:
-        return FILEIO_ENOTDIR;
-      case EISDIR:
-        return FILEIO_EISDIR;
-      case EINVAL:
-        return FILEIO_EINVAL;
-      case ENFILE:
-        return FILEIO_ENFILE;
-      case EMFILE:
-        return FILEIO_EMFILE;
-      case EFBIG:
-        return FILEIO_EFBIG;
-      case ENOSPC:
-        return FILEIO_ENOSPC;
-      case ESPIPE:
-        return FILEIO_ESPIPE;
-      case EROFS:
-        return FILEIO_EROFS;
-      case ENOSYS:
-        return FILEIO_ENOSYS;
-      case ENAMETOOLONG:
-        return FILEIO_ENAMETOOLONG;
-    }
-  return FILEIO_EUNKNOWN;
-}
-
-/* See fileio.h.  */
-
-int
-fileio_to_host_openflags (int fileio_open_flags, int *open_flags_p)
-{
-  int open_flags = 0;
-
-  if (fileio_open_flags & ~FILEIO_O_SUPPORTED)
-    return -1;
-
-  if (fileio_open_flags & FILEIO_O_CREAT)
-    open_flags |= O_CREAT;
-  if (fileio_open_flags & FILEIO_O_EXCL)
-    open_flags |= O_EXCL;
-  if (fileio_open_flags & FILEIO_O_TRUNC)
-    open_flags |= O_TRUNC;
-  if (fileio_open_flags & FILEIO_O_APPEND)
-    open_flags |= O_APPEND;
-  if (fileio_open_flags & FILEIO_O_RDONLY)
-    open_flags |= O_RDONLY;
-  if (fileio_open_flags & FILEIO_O_WRONLY)
-    open_flags |= O_WRONLY;
-  if (fileio_open_flags & FILEIO_O_RDWR)
-    open_flags |= O_RDWR;
-  /* On systems supporting binary and text mode, always open files
-     in binary mode. */
-#ifdef O_BINARY
-  open_flags |= O_BINARY;
-#endif
-
-  *open_flags_p = open_flags;
-  return 0;
-}
-
-/* See fileio.h.  */
-
-int
-fileio_to_host_mode (int fileio_mode, mode_t *mode_p)
-{
-  mode_t mode = 0;
-
-  if (fileio_mode & ~FILEIO_S_SUPPORTED)
-    return -1;
-
-  if (fileio_mode & FILEIO_S_IFREG)
-    mode |= S_IFREG;
-  if (fileio_mode & FILEIO_S_IFDIR)
-    mode |= S_IFDIR;
-  if (fileio_mode & FILEIO_S_IFCHR)
-    mode |= S_IFCHR;
-  if (fileio_mode & FILEIO_S_IRUSR)
-    mode |= S_IRUSR;
-  if (fileio_mode & FILEIO_S_IWUSR)
-    mode |= S_IWUSR;
-  if (fileio_mode & FILEIO_S_IXUSR)
-    mode |= S_IXUSR;
-#ifdef S_IRGRP
-  if (fileio_mode & FILEIO_S_IRGRP)
-    mode |= S_IRGRP;
-#endif
-#ifdef S_IWGRP
-  if (fileio_mode & FILEIO_S_IWGRP)
-    mode |= S_IWGRP;
-#endif
-#ifdef S_IXGRP
-  if (fileio_mode & FILEIO_S_IXGRP)
-    mode |= S_IXGRP;
-#endif
-  if (fileio_mode & FILEIO_S_IROTH)
-    mode |= S_IROTH;
-#ifdef S_IWOTH
-  if (fileio_mode & FILEIO_S_IWOTH)
-    mode |= S_IWOTH;
-#endif
-#ifdef S_IXOTH
-  if (fileio_mode & FILEIO_S_IXOTH)
-    mode |= S_IXOTH;
-#endif
-
-  *mode_p = mode;
-  return 0;
-}
-
-/* Convert a host-format mode_t into a bitmask of File-I/O flags.  */
-
-static LONGEST
-fileio_mode_pack (mode_t mode)
-{
-  mode_t tmode = 0;
-
-  if (S_ISREG (mode))
-    tmode |= FILEIO_S_IFREG;
-  if (S_ISDIR (mode))
-    tmode |= FILEIO_S_IFDIR;
-  if (S_ISCHR (mode))
-    tmode |= FILEIO_S_IFCHR;
-  if (mode & S_IRUSR)
-    tmode |= FILEIO_S_IRUSR;
-  if (mode & S_IWUSR)
-    tmode |= FILEIO_S_IWUSR;
-  if (mode & S_IXUSR)
-    tmode |= FILEIO_S_IXUSR;
-#ifdef S_IRGRP
-  if (mode & S_IRGRP)
-    tmode |= FILEIO_S_IRGRP;
-#endif
-#ifdef S_IWGRP
-  if (mode & S_IWGRP)
-    tmode |= FILEIO_S_IWGRP;
-#endif
-#ifdef S_IXGRP
-  if (mode & S_IXGRP)
-    tmode |= FILEIO_S_IXGRP;
-#endif
-  if (mode & S_IROTH)
-    tmode |= FILEIO_S_IROTH;
-#ifdef S_IWOTH
-  if (mode & S_IWOTH)
-    tmode |= FILEIO_S_IWOTH;
-#endif
-#ifdef S_IXOTH
-  if (mode & S_IXOTH)
-    tmode |= FILEIO_S_IXOTH;
-#endif
-  return tmode;
-}
-
-/* Pack a host-format mode_t into an fio_mode_t.  */
-
-static void
-host_to_fileio_mode (mode_t num, fio_mode_t fnum)
-{
-  host_to_bigendian (fileio_mode_pack (num), (char *) fnum, 4);
-}
-
-/* Pack a host-format integer into an fio_ulong_t.  */
-
-static void
-host_to_fileio_ulong (LONGEST num, fio_ulong_t fnum)
-{
-  host_to_bigendian (num, (char *) fnum, 8);
-}
-
-/* See fileio.h.  */
-
-void
-host_to_fileio_stat (struct stat *st, struct fio_stat *fst)
-{
-  LONGEST blksize;
-
-  host_to_fileio_uint ((long) st->st_dev, fst->fst_dev);
-  host_to_fileio_uint ((long) st->st_ino, fst->fst_ino);
-  host_to_fileio_mode (st->st_mode, fst->fst_mode);
-  host_to_fileio_uint ((long) st->st_nlink, fst->fst_nlink);
-  host_to_fileio_uint ((long) st->st_uid, fst->fst_uid);
-  host_to_fileio_uint ((long) st->st_gid, fst->fst_gid);
-  host_to_fileio_uint ((long) st->st_rdev, fst->fst_rdev);
-  host_to_fileio_ulong ((LONGEST) st->st_size, fst->fst_size);
-#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
-  blksize = st->st_blksize;
-#else
-  blksize = 512;
-#endif
-  host_to_fileio_ulong (blksize, fst->fst_blksize);
-#if HAVE_STRUCT_STAT_ST_BLOCKS
-  host_to_fileio_ulong ((LONGEST) st->st_blocks, fst->fst_blocks);
-#else
-  /* FIXME: This is correct for DJGPP, but other systems that don't
-     have st_blocks, if any, might prefer 512 instead of st_blksize.
-     (eliz, 30-12-2003)  */
-  host_to_fileio_ulong (((LONGEST) st->st_size + blksize - 1)
-                       / blksize,
-                       fst->fst_blocks);
-#endif
-  host_to_fileio_time (st->st_atime, fst->fst_atime);
-  host_to_fileio_time (st->st_mtime, fst->fst_mtime);
-  host_to_fileio_time (st->st_ctime, fst->fst_ctime);
-}
diff --git a/gdb/common/fileio.h b/gdb/common/fileio.h
deleted file mode 100644 (file)
index 7a2e7c2..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* File-I/O functions for GDB, the GNU debugger.
-
-   Copyright (C) 2003-2019 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/>.  */
-
-#ifndef COMMON_FILEIO_H
-#define COMMON_FILEIO_H
-
-#include "gdb/fileio.h"
-#include <sys/stat.h>
-
-/* Convert a host-format errno value to a File-I/O error number.  */
-
-extern int host_to_fileio_error (int error);
-
-/* Convert File-I/O open flags FFLAGS to host format, storing
-   the result in *FLAGS.  Return 0 on success, -1 on error.  */
-
-extern int fileio_to_host_openflags (int fflags, int *flags);
-
-/* Convert File-I/O mode FMODE to host format, storing
-   the result in *MODE.  Return 0 on success, -1 on error.  */
-
-extern int fileio_to_host_mode (int fmode, mode_t *mode);
-
-/* Pack a host-format integer into a byte buffer in big-endian
-   format.  BYTES specifies the size of the integer to pack in
-   bytes.  */
-
-static inline void
-host_to_bigendian (LONGEST num, char *buf, int bytes)
-{
-  int i;
-
-  for (i = 0; i < bytes; ++i)
-    buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff;
-}
-
-/* Pack a host-format integer into an fio_uint_t.  */
-
-static inline void
-host_to_fileio_uint (long num, fio_uint_t fnum)
-{
-  host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
-}
-
-/* Pack a host-format time_t into an fio_time_t.  */
-
-static inline void
-host_to_fileio_time (time_t num, fio_time_t fnum)
-{
-  host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
-}
-
-/* Pack a host-format struct stat into a struct fio_stat.  */
-
-extern void host_to_fileio_stat (struct stat *st, struct fio_stat *fst);
-
-#endif /* COMMON_FILEIO_H */
diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c
deleted file mode 100644 (file)
index c7b8c69..0000000
+++ /dev/null
@@ -1,503 +0,0 @@
-/* Low-level file-handling.
-   Copyright (C) 2012-2019 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 "common-defs.h"
-#include "filestuff.h"
-#include "gdb_vecs.h"
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <algorithm>
-
-#ifdef USE_WIN32API
-#include <winsock2.h>
-#include <windows.h>
-#define HAVE_SOCKETS 1
-#elif defined HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-/* Define HAVE_F_GETFD if we plan to use F_GETFD.  */
-#define HAVE_F_GETFD F_GETFD
-#define HAVE_SOCKETS 1
-#endif
-
-#ifdef HAVE_KINFO_GETFILE
-#include <sys/user.h>
-#include <libutil.h>
-#endif
-
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif /* HAVE_SYS_RESOURCE_H */
-
-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0
-#endif
-
-#ifndef O_NOINHERIT
-#define O_NOINHERIT 0
-#endif
-
-#ifndef SOCK_CLOEXEC
-#define SOCK_CLOEXEC 0
-#endif
-
-\f
-
-#ifndef HAVE_FDWALK
-
-#include <dirent.h>
-
-/* Replacement for fdwalk, if the system doesn't define it.  Walks all
-   open file descriptors (though this implementation may walk closed
-   ones as well, depending on the host platform's capabilities) and
-   call FUNC with ARG.  If FUNC returns non-zero, stops immediately
-   and returns the same value.  Otherwise, returns zero when
-   finished.  */
-
-static int
-fdwalk (int (*func) (void *, int), void *arg)
-{
-  /* Checking __linux__ isn't great but it isn't clear what would be
-     better.  There doesn't seem to be a good way to check for this in
-     configure.  */
-#ifdef __linux__
-  DIR *dir;
-
-  dir = opendir ("/proc/self/fd");
-  if (dir != NULL)
-    {
-      struct dirent *entry;
-      int result = 0;
-
-      for (entry = readdir (dir); entry != NULL; entry = readdir (dir))
-       {
-         long fd;
-         char *tail;
-
-         errno = 0;
-         fd = strtol (entry->d_name, &tail, 10);
-         if (*tail != '\0' || errno != 0)
-           continue;
-         if ((int) fd != fd)
-           {
-             /* What can we do here really?  */
-             continue;
-           }
-
-         if (fd == dirfd (dir))
-           continue;
-
-         result = func (arg, fd);
-         if (result != 0)
-           break;
-       }
-
-      closedir (dir);
-      return result;
-    }
-  /* We may fall through to the next case.  */
-#endif
-#ifdef HAVE_KINFO_GETFILE
-  int nfd;
-  gdb::unique_xmalloc_ptr<struct kinfo_file[]> fdtbl
-    (kinfo_getfile (getpid (), &nfd));
-  if (fdtbl != NULL)
-    {
-      for (int i = 0; i < nfd; i++)
-       {
-         if (fdtbl[i].kf_fd >= 0)
-           {
-             int result = func (arg, fdtbl[i].kf_fd);
-             if (result != 0)
-               return result;
-           }
-       }
-      return 0;
-    }
-  /* We may fall through to the next case.  */
-#endif
-
-  {
-    int max, fd;
-
-#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
-    struct rlimit rlim;
-
-    if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 && rlim.rlim_max != RLIM_INFINITY)
-      max = rlim.rlim_max;
-    else
-#endif
-      {
-#ifdef _SC_OPEN_MAX
-       max = sysconf (_SC_OPEN_MAX);
-#else
-       /* Whoops.  */
-       return 0;
-#endif /* _SC_OPEN_MAX */
-      }
-
-    for (fd = 0; fd < max; ++fd)
-      {
-       struct stat sb;
-       int result;
-
-       /* Only call FUNC for open fds.  */
-       if (fstat (fd, &sb) == -1)
-         continue;
-
-       result = func (arg, fd);
-       if (result != 0)
-         return result;
-      }
-
-    return 0;
-  }
-}
-
-#endif /* HAVE_FDWALK */
-
-\f
-
-/* A vector holding all the fds open when notice_open_fds was called.  We
-   don't use a hashtab because we don't expect there to be many open fds.  */
-
-static std::vector<int> open_fds;
-
-/* An fdwalk callback function used by notice_open_fds.  It puts the
-   given file descriptor into the vec.  */
-
-static int
-do_mark_open_fd (void *ignore, int fd)
-{
-  open_fds.push_back (fd);
-  return 0;
-}
-
-/* See filestuff.h.  */
-
-void
-notice_open_fds (void)
-{
-  fdwalk (do_mark_open_fd, NULL);
-}
-
-/* See filestuff.h.  */
-
-void
-mark_fd_no_cloexec (int fd)
-{
-  do_mark_open_fd (NULL, fd);
-}
-
-/* See filestuff.h.  */
-
-void
-unmark_fd_no_cloexec (int fd)
-{
-  auto it = std::remove (open_fds.begin (), open_fds.end (), fd);
-
-  if (it != open_fds.end ())
-    open_fds.erase (it);
-  else
-    gdb_assert_not_reached (_("fd not found in open_fds"));
-}
-
-/* Helper function for close_most_fds that closes the file descriptor
-   if appropriate.  */
-
-static int
-do_close (void *ignore, int fd)
-{
-  for (int val : open_fds)
-    {
-      if (fd == val)
-       {
-         /* Keep this one open.  */
-         return 0;
-       }
-    }
-
-  close (fd);
-  return 0;
-}
-
-/* See filestuff.h.  */
-
-void
-close_most_fds (void)
-{
-  fdwalk (do_close, NULL);
-}
-
-\f
-
-/* This is a tri-state flag.  When zero it means we haven't yet tried
-   O_CLOEXEC.  When positive it means that O_CLOEXEC works on this
-   host.  When negative, it means that O_CLOEXEC doesn't work.  We
-   track this state because, while gdb might have been compiled
-   against a libc that supplies O_CLOEXEC, there is no guarantee that
-   the kernel supports it.  */
-
-static int trust_o_cloexec;
-
-/* Mark FD as close-on-exec, ignoring errors.  Update
-   TRUST_O_CLOEXEC.  */
-
-static void
-mark_cloexec (int fd)
-{
-#ifdef HAVE_F_GETFD
-  int old = fcntl (fd, F_GETFD, 0);
-
-  if (old != -1)
-    {
-      fcntl (fd, F_SETFD, old | FD_CLOEXEC);
-
-      if (trust_o_cloexec == 0)
-       {
-         if ((old & FD_CLOEXEC) != 0)
-           trust_o_cloexec = 1;
-         else
-           trust_o_cloexec = -1;
-       }
-    }
-#endif /* HAVE_F_GETFD */
-}
-
-/* Depending on TRUST_O_CLOEXEC, mark FD as close-on-exec.  */
-
-static void
-maybe_mark_cloexec (int fd)
-{
-  if (trust_o_cloexec <= 0)
-    mark_cloexec (fd);
-}
-
-#ifdef HAVE_SOCKETS
-
-/* Like maybe_mark_cloexec, but for callers that use SOCK_CLOEXEC.  */
-
-static void
-socket_mark_cloexec (int fd)
-{
-  if (SOCK_CLOEXEC == 0 || trust_o_cloexec <= 0)
-    mark_cloexec (fd);
-}
-
-#endif
-
-\f
-
-/* See filestuff.h.  */
-
-int
-gdb_open_cloexec (const char *filename, int flags, unsigned long mode)
-{
-  int fd = open (filename, flags | O_CLOEXEC, mode);
-
-  if (fd >= 0)
-    maybe_mark_cloexec (fd);
-
-  return fd;
-}
-
-/* See filestuff.h.  */
-
-gdb_file_up
-gdb_fopen_cloexec (const char *filename, const char *opentype)
-{
-  FILE *result;
-  /* Probe for "e" support once.  But, if we can tell the operating
-     system doesn't know about close on exec mode "e" without probing,
-     skip it.  E.g., the Windows runtime issues an "Invalid parameter
-     passed to C runtime function" OutputDebugString warning for
-     unknown modes.  Assume that if O_CLOEXEC is zero, then "e" isn't
-     supported.  On MinGW, O_CLOEXEC is an alias of O_NOINHERIT, and
-     "e" isn't supported.  */
-  static int fopen_e_ever_failed_einval =
-    O_CLOEXEC == 0 || O_CLOEXEC == O_NOINHERIT;
-
-  if (!fopen_e_ever_failed_einval)
-    {
-      char *copy;
-
-      copy = (char *) alloca (strlen (opentype) + 2);
-      strcpy (copy, opentype);
-      /* This is a glibc extension but we try it unconditionally on
-        this path.  */
-      strcat (copy, "e");
-      result = fopen (filename, copy);
-
-      if (result == NULL && errno == EINVAL)
-       {
-         result = fopen (filename, opentype);
-         if (result != NULL)
-           fopen_e_ever_failed_einval = 1;
-       }
-    }
-  else
-    result = fopen (filename, opentype);
-
-  if (result != NULL)
-    maybe_mark_cloexec (fileno (result));
-
-  return gdb_file_up (result);
-}
-
-#ifdef HAVE_SOCKETS
-/* See filestuff.h.  */
-
-int
-gdb_socketpair_cloexec (int domain, int style, int protocol,
-                       int filedes[2])
-{
-#ifdef HAVE_SOCKETPAIR
-  int result = socketpair (domain, style | SOCK_CLOEXEC, protocol, filedes);
-
-  if (result != -1)
-    {
-      socket_mark_cloexec (filedes[0]);
-      socket_mark_cloexec (filedes[1]);
-    }
-
-  return result;
-#else
-  gdb_assert_not_reached (_("socketpair not available on this host"));
-#endif
-}
-
-/* See filestuff.h.  */
-
-int
-gdb_socket_cloexec (int domain, int style, int protocol)
-{
-  int result = socket (domain, style | SOCK_CLOEXEC, protocol);
-
-  if (result != -1)
-    socket_mark_cloexec (result);
-
-  return result;
-}
-#endif
-
-/* See filestuff.h.  */
-
-int
-gdb_pipe_cloexec (int filedes[2])
-{
-  int result;
-
-#ifdef HAVE_PIPE2
-  result = pipe2 (filedes, O_CLOEXEC);
-  if (result != -1)
-    {
-      maybe_mark_cloexec (filedes[0]);
-      maybe_mark_cloexec (filedes[1]);
-    }
-#else
-#ifdef HAVE_PIPE
-  result = pipe (filedes);
-  if (result != -1)
-    {
-      mark_cloexec (filedes[0]);
-      mark_cloexec (filedes[1]);
-    }
-#else /* HAVE_PIPE */
-  gdb_assert_not_reached (_("pipe not available on this host"));
-#endif /* HAVE_PIPE */
-#endif /* HAVE_PIPE2 */
-
-  return result;
-}
-
-/* See common/filestuff.h.  */
-
-bool
-is_regular_file (const char *name, int *errno_ptr)
-{
-  struct stat st;
-  const int status = stat (name, &st);
-
-  /* Stat should never fail except when the file does not exist.
-     If stat fails, analyze the source of error and return true
-     unless the file does not exist, to avoid returning false results
-     on obscure systems where stat does not work as expected.  */
-
-  if (status != 0)
-    {
-      if (errno != ENOENT)
-       return true;
-      *errno_ptr = ENOENT;
-      return false;
-    }
-
-  if (S_ISREG (st.st_mode))
-    return true;
-
-  if (S_ISDIR (st.st_mode))
-    *errno_ptr = EISDIR;
-  else
-    *errno_ptr = EINVAL;
-  return false;
-}
-
-/* See common/filestuff.h.  */
-
-bool
-mkdir_recursive (const char *dir)
-{
-  auto holder = make_unique_xstrdup (dir);
-  char * const start = holder.get ();
-  char *component_start = start;
-  char *component_end = start;
-
-  while (1)
-    {
-      /* Find the beginning of the next component.  */
-      while (*component_start == '/')
-       component_start++;
-
-      /* Are we done?  */
-      if (*component_start == '\0')
-       return true;
-
-      /* Find the slash or null-terminator after this component.  */
-      component_end = component_start;
-      while (*component_end != '/' && *component_end != '\0')
-       component_end++;
-
-      /* Temporarily replace the slash with a null terminator, so we can create
-         the directory up to this component.  */
-      char saved_char = *component_end;
-      *component_end = '\0';
-
-      /* If we get EEXIST and the existing path is a directory, then we're
-         happy.  If it exists, but it's a regular file and this is not the last
-         component, we'll fail at the next component.  If this is the last
-         component, the caller will fail with ENOTDIR when trying to
-         open/create a file under that path.  */
-      if (mkdir (start, 0700) != 0)
-       if (errno != EEXIST)
-         return false;
-
-      /* Restore the overwritten char.  */
-      *component_end = saved_char;
-      component_start = component_end;
-    }
-}
diff --git a/gdb/common/filestuff.h b/gdb/common/filestuff.h
deleted file mode 100644 (file)
index c50781d..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/* Low-level file-handling.
-   Copyright (C) 2012-2019 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/>.  */
-
-#ifndef COMMON_FILESTUFF_H
-#define COMMON_FILESTUFF_H
-
-#include <dirent.h>
-#include <fcntl.h>
-
-/* Note all the file descriptors which are open when this is called.
-   These file descriptors will not be closed by close_most_fds.  */
-
-extern void notice_open_fds (void);
-
-/* Mark a file descriptor as inheritable across an exec.  */
-
-extern void mark_fd_no_cloexec (int fd);
-
-/* Mark a file descriptor as no longer being inheritable across an
-   exec.  This is only meaningful when FD was previously passed to
-   mark_fd_no_cloexec.  */
-
-extern void unmark_fd_no_cloexec (int fd);
-
-/* Close all open file descriptors other than those marked by
-   'notice_open_fds', and stdin, stdout, and stderr.  Errors that
-   occur while closing are ignored.  */
-
-extern void close_most_fds (void);
-
-/* Like 'open', but ensures that the returned file descriptor has the
-   close-on-exec flag set.  */
-
-extern int gdb_open_cloexec (const char *filename, int flags,
-                            /* mode_t */ unsigned long mode);
-
-/* Like mkstemp, but ensures that the file descriptor is
-   close-on-exec.  */
-
-static inline int
-gdb_mkostemp_cloexec (char *name_template, int flags = 0)
-{
-  /* gnulib provides a mkostemp replacement if needed.  */
-  return mkostemp (name_template, flags | O_CLOEXEC);
-}
-
-/* Convenience wrapper for the above, which takes the filename as an
-   std::string.  */
-
-static inline int
-gdb_open_cloexec (const std::string &filename, int flags,
-                 /* mode_t */ unsigned long mode)
-{
-  return gdb_open_cloexec (filename.c_str (), flags, mode);
-}
-
-struct gdb_file_deleter
-{
-  void operator() (FILE *file) const
-  {
-    fclose (file);
-  }
-};
-
-/* A unique pointer to a FILE.  */
-
-typedef std::unique_ptr<FILE, gdb_file_deleter> gdb_file_up;
-
-/* Like 'fopen', but ensures that the returned file descriptor has the
-   close-on-exec flag set.  */
-
-extern gdb_file_up gdb_fopen_cloexec (const char *filename,
-                                     const char *opentype);
-
-/* Convenience wrapper for the above, which takes the filename as an
-   std::string.  */
-
-static inline gdb_file_up
-gdb_fopen_cloexec (const std::string &filename, const char *opentype)
-{
-  return gdb_fopen_cloexec (filename.c_str (), opentype);
-}
-
-/* Like 'socketpair', but ensures that the returned file descriptors
-   have the close-on-exec flag set.  */
-
-extern int gdb_socketpair_cloexec (int domain, int style, int protocol,
-                                  int filedes[2]);
-
-/* Like 'socket', but ensures that the returned file descriptor has
-   the close-on-exec flag set.  */
-
-extern int gdb_socket_cloexec (int domain, int style, int protocol);
-
-/* Like 'pipe', but ensures that the returned file descriptors have
-   the close-on-exec flag set.  */
-
-extern int gdb_pipe_cloexec (int filedes[2]);
-
-struct gdb_dir_deleter
-{
-  void operator() (DIR *dir) const
-  {
-    closedir (dir);
-  }
-};
-
-/* A unique pointer to a DIR.  */
-
-typedef std::unique_ptr<DIR, gdb_dir_deleter> gdb_dir_up;
-
-/* Return true if the file NAME exists and is a regular file.
-   If the result is false then *ERRNO_PTR is set to a useful value assuming
-   we're expecting a regular file.  */
-extern bool is_regular_file (const char *name, int *errno_ptr);
-
-
-/* A cheap (as in low-quality) recursive mkdir.  Try to create all the
-   parents directories up to DIR and DIR itself.  Stop if we hit an
-   error along the way.  There is no attempt to remove created
-   directories in case of failure.
-
-   Returns false on failure and sets errno.  */
-
-extern bool mkdir_recursive (const char *dir);
-
-#endif /* COMMON_FILESTUFF_H */
diff --git a/gdb/common/filtered-iterator.h b/gdb/common/filtered-iterator.h
deleted file mode 100644 (file)
index e1b486d..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* A forward filtered iterator for GDB, the GNU debugger.
-   Copyright (C) 2018-2019 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/>.  */
-
-#ifndef COMMON_FILTERED_ITERATOR_H
-#define COMMON_FILTERED_ITERATOR_H
-
-/* A filtered iterator.  This wraps BaseIterator and automatically
-   skips elements that FilterFunc filters out.  Requires that
-   default-constructing a BaseIterator creates a valid one-past-end
-   iterator.  */
-
-template<typename BaseIterator, typename FilterFunc>
-class filtered_iterator
-{
-public:
-  typedef filtered_iterator self_type;
-  typedef typename BaseIterator::value_type value_type;
-  typedef typename BaseIterator::reference reference;
-  typedef typename BaseIterator::pointer pointer;
-  typedef typename BaseIterator::iterator_category iterator_category;
-  typedef typename BaseIterator::difference_type difference_type;
-
-  /* Construct by forwarding all arguments to the underlying
-     iterator.  */
-  template<typename... Args>
-  explicit filtered_iterator (Args &&...args)
-    : m_it (std::forward<Args> (args)...)
-  { skip_filtered (); }
-
-  /* Create a one-past-end iterator.  */
-  filtered_iterator () = default;
-
-  /* Need these as the variadic constructor would be a better match
-     otherwise.  */
-  filtered_iterator (filtered_iterator &) = default;
-  filtered_iterator (const filtered_iterator &) = default;
-  filtered_iterator (filtered_iterator &&) = default;
-  filtered_iterator (const filtered_iterator &&other)
-    : filtered_iterator (static_cast<const filtered_iterator &> (other))
-  {}
-
-  value_type operator* () const { return *m_it; }
-
-  self_type &operator++ ()
-  {
-    ++m_it;
-    skip_filtered ();
-    return *this;
-  }
-
-  bool operator== (const self_type &other) const
-  { return *m_it == *other.m_it; }
-
-  bool operator!= (const self_type &other) const
-  { return *m_it != *other.m_it; }
-
-private:
-
-  void skip_filtered ()
-  {
-    for (; m_it != m_end; ++m_it)
-      if (m_filter (*m_it))
-       break;
-  }
-
-private:
-  FilterFunc m_filter {};
-  BaseIterator m_it {};
-  BaseIterator m_end {};
-};
-
-#endif /* COMMON_FILTERED_ITERATOR_H */
diff --git a/gdb/common/format.c b/gdb/common/format.c
deleted file mode 100644 (file)
index fb3421e..0000000
+++ /dev/null
@@ -1,350 +0,0 @@
-/* Parse a printf-style format string.
-
-   Copyright (C) 1986-2019 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 "common-defs.h"
-#include "format.h"
-
-format_pieces::format_pieces (const char **arg)
-{
-  const char *s;
-  char *f, *string;
-  const char *prev_start;
-  const char *percent_loc;
-  char *sub_start, *current_substring;
-  enum argclass this_argclass;
-
-  s = *arg;
-
-  /* Parse the format-control string and copy it into the string STRING,
-     processing some kinds of escape sequence.  */
-
-  f = string = (char *) alloca (strlen (s) + 1);
-
-  while (*s != '"' && *s != '\0')
-    {
-      int c = *s++;
-      switch (c)
-       {
-       case '\0':
-         continue;
-
-       case '\\':
-         switch (c = *s++)
-           {
-           case '\\':
-             *f++ = '\\';
-             break;
-           case 'a':
-             *f++ = '\a';
-             break;
-           case 'b':
-             *f++ = '\b';
-             break;
-           case 'e':
-             *f++ = '\e';
-             break;
-           case 'f':
-             *f++ = '\f';
-             break;
-           case 'n':
-             *f++ = '\n';
-             break;
-           case 'r':
-             *f++ = '\r';
-             break;
-           case 't':
-             *f++ = '\t';
-             break;
-           case 'v':
-             *f++ = '\v';
-             break;
-           case '"':
-             *f++ = '"';
-             break;
-           default:
-             /* ??? TODO: handle other escape sequences.  */
-             error (_("Unrecognized escape character \\%c in format string."),
-                    c);
-           }
-         break;
-
-       default:
-         *f++ = c;
-       }
-    }
-
-  /* Terminate our escape-processed copy.  */
-  *f++ = '\0';
-
-  /* Whether the format string ended with double-quote or zero, we're
-     done with it; it's up to callers to complain about syntax.  */
-  *arg = s;
-
-  /* Need extra space for the '\0's.  Doubling the size is sufficient.  */
-
-  current_substring = (char *) xmalloc (strlen (string) * 2 + 1000);
-  m_storage.reset (current_substring);
-
-  /* Now scan the string for %-specs and see what kinds of args they want.
-     argclass classifies the %-specs so we can give printf-type functions
-     something of the right size.  */
-
-  f = string;
-  prev_start = string;
-  while (*f)
-    if (*f++ == '%')
-      {
-       int seen_hash = 0, seen_zero = 0, lcount = 0, seen_prec = 0;
-       int seen_space = 0, seen_plus = 0;
-       int seen_big_l = 0, seen_h = 0, seen_big_h = 0;
-       int seen_big_d = 0, seen_double_big_d = 0;
-       int bad = 0;
-
-       /* Skip over "%%", it will become part of a literal piece.  */
-       if (*f == '%')
-         {
-           f++;
-           continue;
-         }
-
-       sub_start = current_substring;
-
-       strncpy (current_substring, prev_start, f - 1 - prev_start);
-       current_substring += f - 1 - prev_start;
-       *current_substring++ = '\0';
-
-       m_pieces.emplace_back (sub_start, literal_piece);
-
-       percent_loc = f - 1;
-
-       /* Check the validity of the format specifier, and work
-          out what argument it expects.  We only accept C89
-          format strings, with the exception of long long (which
-          we autoconf for).  */
-
-       /* The first part of a format specifier is a set of flag
-          characters.  */
-       while (*f != '\0' && strchr ("0-+ #", *f))
-         {
-           if (*f == '#')
-             seen_hash = 1;
-           else if (*f == '0')
-             seen_zero = 1;
-           else if (*f == ' ')
-             seen_space = 1;
-           else if (*f == '+')
-             seen_plus = 1;
-           f++;
-         }
-
-       /* The next part of a format specifier is a width.  */
-       while (*f != '\0' && strchr ("0123456789", *f))
-         f++;
-
-       /* The next part of a format specifier is a precision.  */
-       if (*f == '.')
-         {
-           seen_prec = 1;
-           f++;
-           while (*f != '\0' && strchr ("0123456789", *f))
-             f++;
-         }
-
-       /* The next part of a format specifier is a length modifier.  */
-       if (*f == 'h')
-         {
-           seen_h = 1;
-           f++;
-         }
-       else if (*f == 'l')
-         {
-           f++;
-           lcount++;
-           if (*f == 'l')
-             {
-               f++;
-               lcount++;
-             }
-         }
-       else if (*f == 'L')
-         {
-           seen_big_l = 1;
-           f++;
-         }
-       /* Decimal32 modifier.  */
-       else if (*f == 'H')
-         {
-           seen_big_h = 1;
-           f++;
-         }
-       /* Decimal64 and Decimal128 modifiers.  */
-       else if (*f == 'D')
-         {
-           f++;
-
-           /* Check for a Decimal128.  */
-           if (*f == 'D')
-             {
-               f++;
-               seen_double_big_d = 1;
-             }
-           else
-             seen_big_d = 1;
-         }
-
-       switch (*f)
-         {
-         case 'u':
-           if (seen_hash)
-             bad = 1;
-           /* FALLTHROUGH */
-
-         case 'o':
-         case 'x':
-         case 'X':
-           if (seen_space || seen_plus)
-             bad = 1;
-         /* FALLTHROUGH */
-
-         case 'd':
-         case 'i':
-           if (lcount == 0)
-             this_argclass = int_arg;
-           else if (lcount == 1)
-             this_argclass = long_arg;
-           else
-             this_argclass = long_long_arg;
-
-           if (seen_big_l)
-             bad = 1;
-           break;
-
-         case 'c':
-           this_argclass = lcount == 0 ? int_arg : wide_char_arg;
-           if (lcount > 1 || seen_h || seen_big_l)
-             bad = 1;
-           if (seen_prec || seen_zero || seen_space || seen_plus)
-             bad = 1;
-           break;
-
-         case 'p':
-           this_argclass = ptr_arg;
-           if (lcount || seen_h || seen_big_l)
-             bad = 1;
-           if (seen_prec)
-             bad = 1;
-           if (seen_hash || seen_zero || seen_space || seen_plus)
-             bad = 1;
-           break;
-
-         case 's':
-           this_argclass = lcount == 0 ? string_arg : wide_string_arg;
-           if (lcount > 1 || seen_h || seen_big_l)
-             bad = 1;
-           if (seen_zero || seen_space || seen_plus)
-             bad = 1;
-           break;
-
-         case 'e':
-         case 'f':
-         case 'g':
-         case 'E':
-         case 'G':
-           if (seen_double_big_d)
-             this_argclass = dec128float_arg;
-           else if (seen_big_d)
-             this_argclass = dec64float_arg;
-           else if (seen_big_h)
-             this_argclass = dec32float_arg;
-           else if (seen_big_l)
-             this_argclass = long_double_arg;
-           else
-             this_argclass = double_arg;
-
-           if (lcount || seen_h)
-             bad = 1;
-           break;
-
-         case '*':
-           error (_("`*' not supported for precision or width in printf"));
-
-         case 'n':
-           error (_("Format specifier `n' not supported in printf"));
-
-         case '\0':
-           error (_("Incomplete format specifier at end of format string"));
-
-         default:
-           error (_("Unrecognized format specifier '%c' in printf"), *f);
-         }
-
-       if (bad)
-         error (_("Inappropriate modifiers to "
-                  "format specifier '%c' in printf"),
-                *f);
-
-       f++;
-
-       sub_start = current_substring;
-
-       if (lcount > 1 && USE_PRINTF_I64)
-         {
-           /* Windows' printf does support long long, but not the usual way.
-              Convert %lld to %I64d.  */
-           int length_before_ll = f - percent_loc - 1 - lcount;
-
-           strncpy (current_substring, percent_loc, length_before_ll);
-           strcpy (current_substring + length_before_ll, "I64");
-           current_substring[length_before_ll + 3] =
-             percent_loc[length_before_ll + lcount];
-           current_substring += length_before_ll + 4;
-         }
-       else if (this_argclass == wide_string_arg
-                || this_argclass == wide_char_arg)
-         {
-           /* Convert %ls or %lc to %s.  */
-           int length_before_ls = f - percent_loc - 2;
-
-           strncpy (current_substring, percent_loc, length_before_ls);
-           strcpy (current_substring + length_before_ls, "s");
-           current_substring += length_before_ls + 2;
-         }
-       else
-         {
-           strncpy (current_substring, percent_loc, f - percent_loc);
-           current_substring += f - percent_loc;
-         }
-
-       *current_substring++ = '\0';
-
-       prev_start = f;
-
-       m_pieces.emplace_back (sub_start, this_argclass);
-      }
-
-  /* Record the remainder of the string.  */
-
-  sub_start = current_substring;
-
-  strncpy (current_substring, prev_start, f - prev_start);
-  current_substring += f - prev_start;
-  *current_substring++ = '\0';
-
-  m_pieces.emplace_back (sub_start, literal_piece);
-}
diff --git a/gdb/common/format.h b/gdb/common/format.h
deleted file mode 100644 (file)
index 058844c..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Parse a printf-style format string.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_FORMAT_H
-#define COMMON_FORMAT_H
-
-#include "common/gdb_string_view.h"
-
-#if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
-# define USE_PRINTF_I64 1
-# define PRINTF_HAS_LONG_LONG
-#else
-# define USE_PRINTF_I64 0
-#endif
-
-/* The argclass represents the general type of data that goes with a
-   format directive; int_arg for %d, long_arg for %l, and so forth.
-   Note that these primarily distinguish types by size and need for
-   special handling, so for instance %u and %x are (at present) also
-   classed as int_arg.  */
-
-enum argclass
-  {
-    literal_piece,
-    int_arg, long_arg, long_long_arg, ptr_arg,
-    string_arg, wide_string_arg, wide_char_arg,
-    double_arg, long_double_arg,
-    dec32float_arg, dec64float_arg, dec128float_arg
-  };
-
-/* A format piece is a section of the format string that may include a
-   single print directive somewhere in it, and the associated class
-   for the argument.  */
-
-struct format_piece
-{
-  format_piece (const char *str, enum argclass argc)
-    : string (str),
-      argclass (argc)
-  {
-  }
-
-  bool operator== (const format_piece &other) const
-  {
-    return (this->argclass == other.argclass
-           && gdb::string_view (this->string) == other.string);
-  }
-
-  const char *string;
-  enum argclass argclass;
-};
-
-class format_pieces
-{
-public:
-
-  format_pieces (const char **arg);
-  ~format_pieces () = default;
-
-  DISABLE_COPY_AND_ASSIGN (format_pieces);
-
-  typedef std::vector<format_piece>::iterator iterator;
-
-  iterator begin ()
-  {
-    return m_pieces.begin ();
-  }
-
-  iterator end ()
-  {
-    return m_pieces.end ();
-  }
-
-private:
-
-  std::vector<format_piece> m_pieces;
-  gdb::unique_xmalloc_ptr<char> m_storage;
-};
-
-#endif /* COMMON_FORMAT_H */
diff --git a/gdb/common/forward-scope-exit.h b/gdb/common/forward-scope-exit.h
deleted file mode 100644 (file)
index bffc6e6..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Copyright (C) 2019 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/>.  */
-
-#ifndef COMMON_FORWARD_SCOPE_EXIT_H
-#define COMMON_FORWARD_SCOPE_EXIT_H
-
-#include "common/scope-exit.h"
-#include <functional>
-
-/* A forward_scope_exit is like scope_exit, but instead of giving it a
-   callable, you instead specialize it for a given cleanup function,
-   and the generated class automatically has a constructor with the
-   same interface as the cleanup function.  forward_scope_exit
-   captures the arguments passed to the ctor, and in turn passes those
-   as arguments to the wrapped cleanup function, when it is called at
-   scope exit time, from within the forward_scope_exit dtor.  The
-   forward_scope_exit class can take any number of arguments, and is
-   cancelable if needed.
-
-   This allows usage like this:
-
-      void
-      delete_longjmp_breakpoint (int arg)
-      {
-       // Blah, blah, blah...
-      }
-
-      using longjmp_breakpoint_cleanup
-       = FORWARD_SCOPE_EXIT (delete_longjmp_breakpoint);
-
-   This above created a new cleanup class `longjmp_breakpoint_cleanup`
-   than can then be used like this:
-
-      longjmp_breakpoint_cleanup obj (thread);
-
-      // Blah, blah, blah...
-
-      obj.release ();  // Optional cancel if needed.
-
-   forward_scope_exit is also handy when you would need to wrap a
-   scope_exit in a gdb::optional:
-
-      gdb::optional<longjmp_breakpoint_cleanup> cleanup;
-      if (some condition)
-       cleanup.emplace (thread);
-      ...
-      if (cleanup)
-       cleanup->release ();
-
-   since with scope exit, you would have to know the scope_exit's
-   callable template type when you create the gdb::optional:
-
-     gdb:optional<scope_exit<what goes here?>>
-
-   The "forward" naming fits both purposes shown above -- the class
-   "forwards" ctor arguments to the wrapped cleanup function at scope
-   exit time, and can also be used to "forward declare"
-   scope_exit-like objects.  */
-
-namespace detail
-{
-
-/* Function and Signature are passed in the same type, in order to
-   extract Function's arguments' types in the specialization below.
-   Those are used to generate the constructor.  */
-
-template<typename Function, Function *function, typename Signature>
-struct forward_scope_exit;
-
-template<typename Function, Function *function,
-        typename Res, typename... Args>
-class forward_scope_exit<Function, function, Res (Args...)>
-  : public scope_exit_base<forward_scope_exit<Function,
-                                             function,
-                                             Res (Args...)>>
-{
-  /* For access to on_exit().  */
-  friend scope_exit_base<forward_scope_exit<Function,
-                                           function,
-                                           Res (Args...)>>;
-
-public:
-  explicit forward_scope_exit (Args ...args)
-    : m_bind_function (function, args...)
-  {
-    /* Nothing.  */
-  }
-
-private:
-  void on_exit ()
-  {
-    m_bind_function ();
-  }
-
-  /* The function and the arguments passed to the ctor, all packed in
-     a std::bind.  */
-  decltype (std::bind (function, std::declval<Args> ()...))
-    m_bind_function;
-};
-
-} /* namespace detail */
-
-/* This is the "public" entry point.  It's a macro to avoid having to
-   name FUNC more than once.  */
-
-#define FORWARD_SCOPE_EXIT(FUNC) \
-  detail::forward_scope_exit<decltype (FUNC), FUNC, decltype (FUNC)>
-
-#endif /* COMMON_FORWARD_SCOPE_EXIT_H */
diff --git a/gdb/common/function-view.h b/gdb/common/function-view.h
deleted file mode 100644 (file)
index 1a577ba..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-/* Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_FUNCTION_VIEW_H
-#define COMMON_FUNCTION_VIEW_H
-
-/* function_view is a polymorphic type-erasing wrapper class that
-   encapsulates a non-owning reference to arbitrary callable objects.
-
-   A way to put it is that function_view is to std::function like
-   std::string_view is to std::string.  While std::function stores a
-   type-erased callable object internally, function_view holds a
-   type-erased reference to an external callable object.
-
-   This is meant to be used as callback type of a function that:
-
-     #1 - Takes a callback as parameter.
-
-     #2 - Wants to support arbitrary callable objects as callback type
-         (e.g., stateful function objects, lambda closures, free
-         functions).
-
-     #3 - Does not store the callback anywhere; instead the function
-         just calls the callback directly or forwards it to some
-         other function that calls it.
-
-     #4 - Can't be, or we don't want it to be, a template function
-         with the callable type as template parameter.  For example,
-         when the callback is a parameter of a virtual member
-         function, or when putting the function template in a header
-         would expose too much implementation detail.
-
-   Note that the C-style "function pointer" + "void *data" callback
-   parameter idiom fails requirement #2 above.  Please don't add new
-   uses of that idiom.  I.e., something like this wouldn't work;
-
-    typedef bool (iterate_over_foos_cb) (foo *f, void *user_data),
-    void iterate_over_foos (iterate_over_foos_cb *callback, void *user_data);
-
-    foo *find_foo_by_type (int type)
-    {
-      foo *found = nullptr;
-
-      iterate_over_foos ([&] (foo *f, void *data)
-       {
-         if (foo->type == type)
-           {
-             found = foo;
-             return true; // stop iterating
-           }
-         return false; // continue iterating
-       }, NULL);
-
-      return found;
-    }
-
-   The above wouldn't compile, because lambdas with captures can't be
-   implicitly converted to a function pointer (because a capture means
-   some context data must be passed to the lambda somehow).
-
-   C++11 gave us std::function as type-erased wrapper around arbitrary
-   callables, however, std::function is not an ideal fit for transient
-   callbacks such as the use case above.  For this use case, which is
-   quite pervasive, a function_view is a better choice, because while
-   function_view is light and does not require any heap allocation,
-   std::function is a heavy-weight object with value semantics that
-   generally requires a heap allocation on construction/assignment of
-   the target callable.  In addition, while it is possible to use
-   std::function in such a way that avoids most of the overhead by
-   making sure to only construct it with callables of types that fit
-   std::function's small object optimization, such as function
-   pointers and std::reference_wrapper callables, that is quite
-   inconvenient in practice, because restricting to free-function
-   callables would imply no state/capture/closure, which we need in
-   most cases, and std::reference_wrapper implies remembering to use
-   std::ref/std::cref where the callable is constructed, with the
-   added inconvenience that std::ref/std::cref have deleted rvalue-ref
-   overloads, meaning you can't use unnamed/temporary lambdas with
-   them.
-
-   Note that because function_view is a non-owning view of a callable,
-   care must be taken to ensure that the callable outlives the
-   function_view that calls it.  This is not really a problem for the
-   use case function_view is intended for, such as passing a temporary
-   function object / lambda to a function that accepts a callback,
-   because in those cases, the temporary is guaranteed to be live
-   until the called function returns.
-
-   Calling a function_view with no associated target is undefined,
-   unlike with std::function, which throws std::bad_function_call.
-   This is by design, to avoid the otherwise necessary NULL check in
-   function_view::operator().
-
-   Since function_view objects are small (a pair of pointers), they
-   should generally be passed around by value.
-
-   Usage:
-
-   Given this function that accepts a callback:
-
-    void
-    iterate_over_foos (gdb::function_view<void (foo *)> callback)
-    {
-       for (auto &foo : foos)
-        callback (&foo);
-    }
-
-   you can call it like this, passing a lambda as callback:
-
-    iterate_over_foos ([&] (foo *f)
-      {
-       process_one_foo (f);
-      });
-
-   or like this, passing a function object as callback:
-
-    struct function_object
-    {
-      void operator() (foo *f)
-      {
-       if (s->check ())
-         process_one_foo (f);
-      }
-
-      // some state
-      state *s;
-    };
-
-    state mystate;
-    function_object matcher {&mystate};
-    iterate_over_foos (matcher);
-
-  or like this, passing a function pointer as callback:
-
-    iterate_over_foos (process_one_foo);
-
-  You can find unit tests covering the whole API in
-  unittests/function-view-selftests.c.  */
-
-namespace gdb {
-
-namespace fv_detail {
-/* Bits shared by all function_view instantiations that do not depend
-   on the template parameters.  */
-
-/* Storage for the erased callable.  This is a union in order to be
-   able to save both a function object (data) pointer or a function
-   pointer without triggering undefined behavior.  */
-union erased_callable
-{
-  /* For function objects.  */
-  void *data;
-
-    /* For function pointers.  */
-  void (*fn) ();
-};
-
-} /* namespace fv_detail */
-
-/* Use partial specialization to get access to the callable's
-   signature. */
-template<class Signature>
-struct function_view;
-
-template<typename Res, typename... Args>
-class function_view<Res (Args...)>
-{
-  template<typename From, typename To>
-  using CompatibleReturnType
-    = Or<std::is_void<To>,
-        std::is_same<From, To>,
-        std::is_convertible<From, To>>;
-
-  /* True if Func can be called with Args, and either the result is
-     Res, convertible to Res or Res is void.  */
-  template<typename Callable,
-          typename Res2 = typename std::result_of<Callable &(Args...)>::type>
-  struct IsCompatibleCallable : CompatibleReturnType<Res2, Res>
-  {};
-
-  /* True if Callable is a function_view.  Used to avoid hijacking the
-     copy ctor.  */
-  template <typename Callable>
-  struct IsFunctionView
-    : std::is_same<function_view, typename std::decay<Callable>::type>
-  {};
-
- public:
-
-  /* NULL by default.  */
-  constexpr function_view () noexcept
-    : m_erased_callable {},
-      m_invoker {}
-  {}
-
-  /* Default copy/assignment is fine.  */
-  function_view (const function_view &) = default;
-  function_view &operator= (const function_view &) = default;
-
-  /* This is the main entry point.  Use SFINAE to avoid hijacking the
-     copy constructor and to ensure that the target type is
-     compatible.  */
-  template
-    <typename Callable,
-     typename = Requires<Not<IsFunctionView<Callable>>>,
-     typename = Requires<IsCompatibleCallable<Callable>>>
-  function_view (Callable &&callable) noexcept
-  {
-    bind (callable);
-  }
-
-  /* Construct a NULL function_view.  */
-  constexpr function_view (std::nullptr_t) noexcept
-    : m_erased_callable {},
-      m_invoker {}
-  {}
-
-  /* Clear a function_view.  */
-  function_view &operator= (std::nullptr_t) noexcept
-  {
-    m_invoker = nullptr;
-    return *this;
-  }
-
-  /* Return true if the wrapper has a target, false otherwise.  Note
-     we check M_INVOKER instead of M_ERASED_CALLABLE because we don't
-     know which member of the union is active right now.  */
-  constexpr explicit operator bool () const noexcept
-  { return m_invoker != nullptr; }
-
-  /* Call the callable.  */
-  Res operator () (Args... args) const
-  { return m_invoker (m_erased_callable, std::forward<Args> (args)...); }
-
- private:
-
-  /* Bind this function_view to a compatible function object
-     reference.  */
-  template <typename Callable>
-  void bind (Callable &callable) noexcept
-  {
-    m_erased_callable.data = (void *) std::addressof (callable);
-    m_invoker = [] (fv_detail::erased_callable ecall, Args... args)
-      noexcept (noexcept (callable (std::forward<Args> (args)...))) -> Res
-      {
-       auto &restored_callable = *static_cast<Callable *> (ecall.data);
-       /* The explicit cast to Res avoids a compile error when Res is
-          void and the callable returns non-void.  */
-       return (Res) restored_callable (std::forward<Args> (args)...);
-      };
-  }
-
-  /* Bind this function_view to a compatible function pointer.
-
-     Making this a separate function allows avoiding one indirection,
-     by storing the function pointer directly in the storage, instead
-     of a pointer to pointer.  erased_callable is then a union in
-     order to avoid storing a function pointer as a data pointer here,
-     which would be undefined.  */
-  template<class Res2, typename... Args2>
-  void bind (Res2 (*fn) (Args2...)) noexcept
-  {
-    m_erased_callable.fn = reinterpret_cast<void (*) ()> (fn);
-    m_invoker = [] (fv_detail::erased_callable ecall, Args... args)
-      noexcept (noexcept (fn (std::forward<Args> (args)...))) -> Res
-      {
-       auto restored_fn = reinterpret_cast<Res2 (*) (Args2...)> (ecall.fn);
-       /* The explicit cast to Res avoids a compile error when Res is
-          void and the callable returns non-void.  */
-       return (Res) restored_fn (std::forward<Args> (args)...);
-      };
-  }
-
-  /* Storage for the erased callable.  */
-  fv_detail::erased_callable m_erased_callable;
-
-  /* The invoker.  This is set to a capture-less lambda by one of the
-     'bind' overloads.  The lambda restores the right type of the
-     callable (which is passed as first argument), and forwards the
-     args.  */
-  Res (*m_invoker) (fv_detail::erased_callable, Args...);
-};
-
-/* Allow comparison with NULL.  Defer the work to the in-class
-   operator bool implementation.  */
-
-template<typename Res, typename... Args>
-constexpr inline bool
-operator== (const function_view<Res (Args...)> &f, std::nullptr_t) noexcept
-{ return !static_cast<bool> (f); }
-
-template<typename Res, typename... Args>
-constexpr inline bool
-operator== (std::nullptr_t, const function_view<Res (Args...)> &f) noexcept
-{ return !static_cast<bool> (f); }
-
-template<typename Res, typename... Args>
-constexpr inline bool
-operator!= (const function_view<Res (Args...)> &f, std::nullptr_t) noexcept
-{ return static_cast<bool> (f); }
-
-template<typename Res, typename... Args>
-constexpr inline bool
-operator!= (std::nullptr_t, const function_view<Res (Args...)> &f) noexcept
-{ return static_cast<bool> (f); }
-
-} /* namespace gdb */
-
-#endif
diff --git a/gdb/common/gdb_assert.h b/gdb/common/gdb_assert.h
deleted file mode 100644 (file)
index a719d87..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* GDB-friendly replacement for <assert.h>.
-   Copyright (C) 2000-2019 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/>.  */
-
-#ifndef COMMON_GDB_ASSERT_H
-#define COMMON_GDB_ASSERT_H
-
-/* A static assertion.  This will cause a compile-time error if EXPR,
-   which must be a compile-time constant, is false.  */
-
-#define gdb_static_assert(expr) static_assert (expr, "")
-
-/* PRAGMATICS: "gdb_assert.h":gdb_assert() is a lower case (rather
-   than upper case) macro since that provides the closest fit to the
-   existing lower case macro <assert.h>:assert() that it is
-   replacing.  */
-
-#define gdb_assert(expr)                                                      \
-  ((void) ((expr) ? 0 :                                                       \
-          (gdb_assert_fail (#expr, __FILE__, __LINE__, FUNCTION_NAME), 0)))
-
-/* This prints an "Assertion failed" message, asking the user if they
-   want to continue, dump core, or just exit.  */
-#if defined (FUNCTION_NAME)
-#define gdb_assert_fail(assertion, file, line, function)                      \
-  internal_error (file, line, _("%s: Assertion `%s' failed."),                \
-                 function, assertion)
-#else
-#define gdb_assert_fail(assertion, file, line, function)                      \
-  internal_error (file, line, _("Assertion `%s' failed."),                    \
-                 assertion)
-#endif
-
-/* The canonical form of gdb_assert (0).
-   MESSAGE is a string to include in the error message.  */
-
-#if defined (FUNCTION_NAME)
-#define gdb_assert_not_reached(message) \
-  internal_error (__FILE__, __LINE__, "%s: %s", FUNCTION_NAME, _(message))
-#else
-#define gdb_assert_not_reached(message) \
-  internal_error (__FILE__, __LINE__, _(message))
-#endif
-
-#endif /* COMMON_GDB_ASSERT_H */
diff --git a/gdb/common/gdb_locale.h b/gdb/common/gdb_locale.h
deleted file mode 100644 (file)
index 4e59b4f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* GDB-friendly replacement for <locale.h>.
-   Copyright (C) 2002-2019 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/>.  */
-
-#ifndef COMMON_GDB_LOCALE_H
-#define COMMON_GDB_LOCALE_H
-
-#ifdef HAVE_LOCALE_H
-# include <locale.h>
-#endif
-
-#ifdef ENABLE_NLS
-# include <libintl.h>
-# define _(String) gettext (String)
-# ifdef gettext_noop
-#  define N_(String) gettext_noop (String)
-# else
-#  define N_(String) (String)
-# endif
-#else
-# define _(String) (String)
-# define N_(String) (String)
-#endif
-
-#ifdef HAVE_LANGINFO_CODESET
-#include <langinfo.h>
-#endif
-
-#endif /* COMMON_GDB_LOCALE_H */
diff --git a/gdb/common/gdb_optional.h b/gdb/common/gdb_optional.h
deleted file mode 100644 (file)
index 7ca5725..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/* An optional object.
-
-   Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_GDB_OPTIONAL_H
-#define COMMON_GDB_OPTIONAL_H
-
-#include "common/traits.h"
-
-namespace gdb
-{
-
-struct in_place_t
-{
-  explicit in_place_t () = default;
-};
-
-constexpr gdb::in_place_t in_place {};
-
-/* This class attempts to be a compatible subset of std::optional,
-   which is slated to be available in C++17.  This class optionally
-   holds an object of some type -- by default it is constructed not
-   holding an object, but later the object can be "emplaced".  This is
-   similar to using std::unique_ptr, but in-object allocation is
-   guaranteed.
-
-   Unlike std::optional, we currently only support copy/move
-   construction/assignment of an optional<T> from either exactly
-   optional<T> or T.  I.e., we don't support copy/move
-   construction/assignment from optional<U> or U, when U is a type
-   convertible to T.  Making that work depending on the definitions of
-   T and U is somewhat complicated, and currently the users of this
-   class don't need it.  */
-
-template<typename T>
-class optional
-{
-public:
-
-  constexpr optional ()
-    : m_dummy ()
-  {}
-
-  template<typename... Args>
-  constexpr optional (in_place_t, Args &&... args)
-    : m_item (std::forward<Args> (args)...),
-      m_instantiated (true)
-  {}
-
-  ~optional ()
-  { this->reset (); }
-
-  /* Copy and move constructors.  */
-
-  optional (const optional &other)
-  {
-    if (other.m_instantiated)
-      this->emplace (other.get ());
-  }
-
-  optional (optional &&other)
-    noexcept(std::is_nothrow_move_constructible<T> ())
-  {
-    if (other.m_instantiated)
-      this->emplace (std::move (other.get ()));
-  }
-
-  constexpr optional (const T &other)
-    : m_item (other),
-      m_instantiated (true)
-  {}
-
-  constexpr optional (T &&other)
-    noexcept (std::is_nothrow_move_constructible<T> ())
-    : m_item (std::move (other)),
-      m_instantiated (true)
-  {}
-
-  /* Assignment operators.  */
-
-  optional &
-  operator= (const optional &other)
-  {
-    if (m_instantiated && other.m_instantiated)
-      this->get () = other.get ();
-    else
-      {
-       if (other.m_instantiated)
-         this->emplace (other.get ());
-       else
-         this->reset ();
-      }
-
-    return *this;
-  }
-
-  optional &
-  operator= (optional &&other)
-    noexcept (And<std::is_nothrow_move_constructible<T>,
-             std::is_nothrow_move_assignable<T>> ())
-  {
-    if (m_instantiated && other.m_instantiated)
-      this->get () = std::move (other.get ());
-    else
-      {
-       if (other.m_instantiated)
-         this->emplace (std::move (other.get ()));
-       else
-         this->reset ();
-      }
-    return *this;
-  }
-
-  optional &
-  operator= (const T &other)
-  {
-    if (m_instantiated)
-      this->get () = other;
-    else
-      this->emplace (other);
-    return *this;
-  }
-
-  optional &
-  operator= (T &&other)
-    noexcept (And<std::is_nothrow_move_constructible<T>,
-             std::is_nothrow_move_assignable<T>> ())
-  {
-    if (m_instantiated)
-      this->get () = std::move (other);
-    else
-      this->emplace (std::move (other));
-    return *this;
-  }
-
-  template<typename... Args>
-  T &emplace (Args &&... args)
-  {
-    this->reset ();
-    new (&m_item) T (std::forward<Args>(args)...);
-    m_instantiated = true;
-    return this->get ();
-  }
-
-  /* Observers.  */
-  constexpr const T *operator-> () const
-  { return std::addressof (this->get ()); }
-
-  T *operator-> ()
-  { return std::addressof (this->get ()); }
-
-  constexpr const T &operator* () const &
-  { return this->get (); }
-
-  T &operator* () &
-  { return this->get (); }
-
-  T &&operator* () &&
-  { return std::move (this->get ()); }
-
-  constexpr const T &&operator* () const &&
-  { return std::move (this->get ()); }
-
-  constexpr explicit operator bool () const noexcept
-  { return m_instantiated; }
-
-  constexpr bool has_value () const noexcept
-  { return m_instantiated; }
-
-  /* 'reset' is a 'safe' operation with no precondition.  */
-  void reset () noexcept
-  {
-    if (m_instantiated)
-      this->destroy ();
-  }
-
-private:
-
-  /* Destroy the object.  */
-  void destroy ()
-  {
-    gdb_assert (m_instantiated);
-    m_instantiated = false;
-    m_item.~T ();
-  }
-
-  /* The get operations have m_instantiated as a precondition.  */
-  T &get () noexcept { return m_item; }
-  constexpr const T &get () const noexcept { return m_item; }
-
-  /* The object.  */
-  union
-  {
-    struct { } m_dummy;
-    T m_item;
-  };
-
-  /* True if the object was ever emplaced.  */
-  bool m_instantiated = false;
-};
-
-}
-
-#endif /* COMMON_GDB_OPTIONAL_H */
diff --git a/gdb/common/gdb_proc_service.h b/gdb/common/gdb_proc_service.h
deleted file mode 100644 (file)
index 8565da3..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/* <proc_service.h> replacement for systems that don't have it.
-   Copyright (C) 2000-2019 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/>.  */
-
-#ifndef COMMON_GDB_PROC_SERVICE_H
-#define COMMON_GDB_PROC_SERVICE_H
-
-#include <sys/types.h>
-
-#ifdef HAVE_PROC_SERVICE_H
-
-/* glibc's proc_service.h doesn't wrap itself with extern "C".  Need
-   to do it ourselves.  */
-EXTERN_C_PUSH
-
-#include <proc_service.h>
-
-EXTERN_C_POP
-
-#else /* HAVE_PROC_SERVICE_H */
-
-/* The following fallback definitions have been imported and adjusted
-   from glibc's proc_service.h  */
-
-/* Callback interface for libthread_db, functions users must define.
-   Copyright (C) 1999,2002,2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library 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
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* The definitions in this file must correspond to those in the debugger.  */
-
-#ifdef HAVE_SYS_PROCFS_H
-#include <sys/procfs.h>
-#endif
-
-/* Not all platforms bring in <linux/elf.h> via <sys/procfs.h>.  If
-   <sys/procfs.h> wasn't enough to find elf_fpregset_t, try the kernel
-   headers also (but don't if we don't need to).  */
-#ifndef HAVE_ELF_FPREGSET_T
-# ifdef HAVE_LINUX_ELF_H
-#  include <linux/elf.h>
-# endif
-#endif
-
-EXTERN_C_PUSH
-
-/* Functions in this interface return one of these status codes.  */
-typedef enum
-{
-  PS_OK,               /* Generic "call succeeded".  */
-  PS_ERR,              /* Generic error.  */
-  PS_BADPID,           /* Bad process handle.  */
-  PS_BADLID,           /* Bad LWP identifier.  */
-  PS_BADADDR,          /* Bad address.  */
-  PS_NOSYM,            /* Could not find given symbol.  */
-  PS_NOFREGS           /* FPU register set not available for given LWP.  */
-} ps_err_e;
-
-#ifndef HAVE_LWPID_T
-typedef unsigned int lwpid_t;
-#endif
-
-#ifndef HAVE_PSADDR_T
-typedef void *psaddr_t;
-#endif
-
-#ifndef HAVE_PRGREGSET_T
-typedef elf_gregset_t prgregset_t;
-#endif
-
-#ifndef HAVE_PRFPREGSET_T
-typedef elf_fpregset_t prfpregset_t;
-#endif
-
-/* This type is opaque in this interface.  It's defined by the user of
-   libthread_db.  GDB's version is defined below.  */
-struct ps_prochandle;
-
-
-/* Read or write process memory at the given address.  */
-extern ps_err_e ps_pdread (struct ps_prochandle *,
-                          psaddr_t, void *, size_t);
-extern ps_err_e ps_pdwrite (struct ps_prochandle *,
-                           psaddr_t, const void *, size_t);
-extern ps_err_e ps_ptread (struct ps_prochandle *,
-                          psaddr_t, void *, size_t);
-extern ps_err_e ps_ptwrite (struct ps_prochandle *,
-                           psaddr_t, const void *, size_t);
-
-
-/* Get and set the given LWP's general or FPU register set.  */
-extern ps_err_e ps_lgetregs (struct ps_prochandle *,
-                            lwpid_t, prgregset_t);
-extern ps_err_e ps_lsetregs (struct ps_prochandle *,
-                            lwpid_t, const prgregset_t);
-extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
-                              lwpid_t, prfpregset_t *);
-extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
-                              lwpid_t, const prfpregset_t *);
-
-/* Return the PID of the process.  */
-extern pid_t ps_getpid (struct ps_prochandle *);
-
-/* Fetch the special per-thread address associated with the given LWP.
-   This call is only used on a few platforms (most use a normal register).
-   The meaning of the `int' parameter is machine-dependent.  */
-extern ps_err_e ps_get_thread_area (struct ps_prochandle *,
-                                   lwpid_t, int, psaddr_t *);
-
-
-/* Look up the named symbol in the named DSO in the symbol tables
-   associated with the process being debugged, filling in *SYM_ADDR
-   with the corresponding run-time address.  */
-extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
-                                  const char *object_name,
-                                  const char *sym_name,
-                                  psaddr_t *sym_addr);
-
-
-/* Stop or continue the entire process.  */
-extern ps_err_e ps_pstop (struct ps_prochandle *);
-extern ps_err_e ps_pcontinue (struct ps_prochandle *);
-
-/* Stop or continue the given LWP alone.  */
-extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
-extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
-
-/* The following are only defined in/called by Solaris.  */
-
-/* Get size of extra register set.  */
-extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph,
-                                lwpid_t lwpid, int *xregsize);
-/* Get extra register set.  */
-extern ps_err_e ps_lgetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
-                             caddr_t xregset);
-extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
-                             caddr_t xregset);
-
-/* Log a message (sends to gdb_stderr).  */
-extern void ps_plog (const char *fmt, ...);
-
-EXTERN_C_POP
-
-#endif /* HAVE_PROC_SERVICE_H */
-
-#endif /* COMMON_GDB_PROC_SERVICE_H */
diff --git a/gdb/common/gdb_ref_ptr.h b/gdb/common/gdb_ref_ptr.h
deleted file mode 100644 (file)
index c31c9a2..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/* Reference-counted smart pointer class
-
-   Copyright (C) 2016-2019 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/>.  */
-
-#ifndef COMMON_GDB_REF_PTR_H
-#define COMMON_GDB_REF_PTR_H
-
-#include <cstddef>
-
-namespace gdb
-{
-
-/* An instance of this class either holds a reference to a
-   reference-counted object or is "NULL".  Reference counting is
-   handled externally by a policy class.  If the object holds a
-   reference, then when the object is destroyed, the reference is
-   decref'd.
-
-   Normally an instance is constructed using a pointer.  This sort of
-   initialization lets this class manage the lifetime of that
-   reference.
-
-   Assignment and copy construction will make a new reference as
-   appropriate.  Assignment from a plain pointer is disallowed to
-   avoid confusion about whether this acquires a new reference;
-   instead use the "reset" method -- which, like the pointer
-   constructor, transfers ownership.
-
-   The policy class must provide two static methods:
-   void incref (T *);
-   void decref (T *);
-*/
-template<typename T, typename Policy>
-class ref_ptr
-{
- public:
-
-  /* Create a new NULL instance.  */
-  ref_ptr ()
-    : m_obj (NULL)
-  {
-  }
-
-  /* Create a new NULL instance.  Note that this is not explicit.  */
-  ref_ptr (const std::nullptr_t)
-    : m_obj (NULL)
-  {
-  }
-
-  /* Create a new instance.  OBJ is a reference, management of which
-     is now transferred to this class.  */
-  explicit ref_ptr (T *obj)
-    : m_obj (obj)
-  {
-  }
-
-  /* Copy another instance.  */
-  ref_ptr (const ref_ptr &other)
-    : m_obj (other.m_obj)
-  {
-    if (m_obj != NULL)
-      Policy::incref (m_obj);
-  }
-
-  /* Transfer ownership from OTHER.  */
-  ref_ptr (ref_ptr &&other)
-    : m_obj (other.m_obj)
-  {
-    other.m_obj = NULL;
-  }
-
-  /* Destroy this instance.  */
-  ~ref_ptr ()
-  {
-    if (m_obj != NULL)
-      Policy::decref (m_obj);
-  }
-
-  /* Copy another instance.  */
-  ref_ptr &operator= (const ref_ptr &other)
-  {
-    /* Do nothing on self-assignment.  */
-    if (this != &other)
-      {
-       reset (other.m_obj);
-       if (m_obj != NULL)
-         Policy::incref (m_obj);
-      }
-    return *this;
-  }
-
-  /* Transfer ownership from OTHER.  */
-  ref_ptr &operator= (ref_ptr &&other)
-  {
-    /* Do nothing on self-assignment.  */
-    if (this != &other)
-      {
-       reset (other.m_obj);
-       other.m_obj = NULL;
-      }
-    return *this;
-  }
-
-  /* Change this instance's referent.  OBJ is a reference, management
-     of which is now transferred to this class.  */
-  void reset (T *obj)
-  {
-    if (m_obj != NULL)
-      Policy::decref (m_obj);
-    m_obj = obj;
-  }
-
-  /* Return this instance's referent without changing the state of
-     this class.  */
-  T *get () const
-  {
-    return m_obj;
-  }
-
-  /* Return this instance's referent, and stop managing this
-     reference.  The caller is now responsible for the ownership of
-     the reference.  */
-  ATTRIBUTE_UNUSED_RESULT T *release ()
-  {
-    T *result = m_obj;
-
-    m_obj = NULL;
-    return result;
-  }
-
-  /* Let users refer to members of the underlying pointer.  */
-  T *operator-> () const
-  {
-    return m_obj;
-  }
-
-  /* Acquire a new reference and return a ref_ptr that owns it.  */
-  static ref_ptr<T, Policy> new_reference (T *obj)
-  {
-    Policy::incref (obj);
-    return ref_ptr<T, Policy> (obj);
-  }
-
- private:
-
-  T *m_obj;
-};
-
-template<typename T, typename Policy>
-inline bool operator== (const ref_ptr<T, Policy> &lhs,
-                       const ref_ptr<T, Policy> &rhs)
-{
-  return lhs.get () == rhs.get ();
-}
-
-template<typename T, typename Policy>
-inline bool operator== (const ref_ptr<T, Policy> &lhs, const T *rhs)
-{
-  return lhs.get () == rhs;
-}
-
-template<typename T, typename Policy>
-inline bool operator== (const ref_ptr<T, Policy> &lhs, const std::nullptr_t)
-{
-  return lhs.get () == nullptr;
-}
-
-template<typename T, typename Policy>
-inline bool operator== (const T *lhs, const ref_ptr<T, Policy> &rhs)
-{
-  return lhs == rhs.get ();
-}
-
-template<typename T, typename Policy>
-inline bool operator== (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
-{
-  return nullptr == rhs.get ();
-}
-
-template<typename T, typename Policy>
-inline bool operator!= (const ref_ptr<T, Policy> &lhs,
-                       const ref_ptr<T, Policy> &rhs)
-{
-  return lhs.get () != rhs.get ();
-}
-
-template<typename T, typename Policy>
-inline bool operator!= (const ref_ptr<T, Policy> &lhs, const T *rhs)
-{
-  return lhs.get () != rhs;
-}
-
-template<typename T, typename Policy>
-inline bool operator!= (const ref_ptr<T, Policy> &lhs, const std::nullptr_t)
-{
-  return lhs.get () != nullptr;
-}
-
-template<typename T, typename Policy>
-inline bool operator!= (const T *lhs, const ref_ptr<T, Policy> &rhs)
-{
-  return lhs != rhs.get ();
-}
-
-template<typename T, typename Policy>
-inline bool operator!= (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
-{
-  return nullptr != rhs.get ();
-}
-
-}
-
-#endif /* COMMON_GDB_REF_PTR_H */
diff --git a/gdb/common/gdb_setjmp.h b/gdb/common/gdb_setjmp.h
deleted file mode 100644 (file)
index d4ebbfa..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Portability wrappers for setjmp and longjmp.
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_GDB_SETJMP_H
-#define COMMON_GDB_SETJMP_H
-
-#include <setjmp.h>
-
-#ifdef HAVE_SIGSETJMP
-#define SIGJMP_BUF             sigjmp_buf
-#define SIGSETJMP(buf)         sigsetjmp((buf), 1)
-#define SIGLONGJMP(buf,val)    siglongjmp((buf), (val))
-#else
-#define SIGJMP_BUF             jmp_buf
-#define SIGSETJMP(buf)         setjmp(buf)
-#define SIGLONGJMP(buf,val)    longjmp((buf), (val))
-#endif
-
-#endif /* COMMON_GDB_SETJMP_H */
diff --git a/gdb/common/gdb_signals.h b/gdb/common/gdb_signals.h
deleted file mode 100644 (file)
index da99f57..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Target signal translation functions for GDB.
-   Copyright (C) 1990-2019 Free Software Foundation, Inc.
-   Contributed by Cygnus Support.
-
-   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/>.  */
-
-#ifndef COMMON_GDB_SIGNALS_H
-#define COMMON_GDB_SIGNALS_H
-
-#include "gdb/signals.h"
-
-/* Predicate to gdb_signal_to_host(). Return non-zero if the enum
-   targ_signal SIGNO has an equivalent ``host'' representation.  */
-/* FIXME: cagney/1999-11-22: The name below was chosen in preference
-   to the shorter gdb_signal_p() because it is far less ambigious.
-   In this context ``gdb_signal'' refers to GDB's internal
-   representation of the target's set of signals while ``host signal''
-   refers to the target operating system's signal.  Confused?  */
-extern int gdb_signal_to_host_p (enum gdb_signal signo);
-
-/* Convert between host signal numbers and enum gdb_signal's.
-   gdb_signal_to_host() returns 0 and prints a warning() on GDB's
-   console if SIGNO has no equivalent host representation.  */
-/* FIXME: cagney/1999-11-22: Here ``host'' is used incorrectly, it is
-   refering to the target operating system's signal numbering.
-   Similarly, ``enum gdb_signal'' is named incorrectly, ``enum
-   gdb_signal'' would probably be better as it is refering to GDB's
-   internal representation of a target operating system's signal.  */
-extern enum gdb_signal gdb_signal_from_host (int);
-extern int gdb_signal_to_host (enum gdb_signal);
-
-/* Return the enum symbol name of SIG as a string, to use in debug
-   output.  */
-extern const char *gdb_signal_to_symbol_string (enum gdb_signal sig);
-
-/* Return the string for a signal.  */
-extern const char *gdb_signal_to_string (enum gdb_signal);
-
-/* Return the name (SIGHUP, etc.) for a signal.  */
-extern const char *gdb_signal_to_name (enum gdb_signal);
-
-/* Given a name (SIGHUP, etc.), return its signal.  */
-enum gdb_signal gdb_signal_from_name (const char *);
-
-#endif /* COMMON_GDB_SIGNALS_H */
diff --git a/gdb/common/gdb_splay_tree.h b/gdb/common/gdb_splay_tree.h
deleted file mode 100644 (file)
index 90b05cd..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* GDB wrapper for splay trees.
-
-   Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_GDB_SPLAY_TREE_H
-#define COMMON_GDB_SPLAY_TREE_H
-
-#include "splay-tree.h"
-
-namespace gdb {
-
-struct splay_tree_deleter
-{
-  void operator() (splay_tree tree) const
-  {
-    splay_tree_delete (tree);
-  }
-};
-
-} /* namespace gdb */
-
-/* A unique pointer to a splay tree.  */
-
-typedef std::unique_ptr<splay_tree_s, gdb::splay_tree_deleter>
-    gdb_splay_tree_up;
-
-#endif /* COMMON_GDB_SPLAY_TREE_H */
diff --git a/gdb/common/gdb_string_view.h b/gdb/common/gdb_string_view.h
deleted file mode 100644 (file)
index 68f7f7d..0000000
+++ /dev/null
@@ -1,562 +0,0 @@
-// Components for manipulating non-owning sequences of characters -*- C++ -*-
-
-
-#ifndef COMMON_GDB_STRING_VIEW_H
-#define COMMON_GDB_STRING_VIEW_H
-
-// Note: This file has been stolen from the gcc repo
-// (libstdc++-v3/include/experimental/string_view) and has local modifications.
-
-// Copyright (C) 2013-2019 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library 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, or (at your option)
-// any later version.
-
-// This library 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.
-
-// Under Section 7 of GPL version 3, you are granted additional
-// permissions described in the GCC Runtime Library Exception, version
-// 3.1, as published by the Free Software Foundation.
-
-// You should have received a copy of the GNU General Public License and
-// a copy of the GCC Runtime Library Exception along with this program;
-// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
-// <http://www.gnu.org/licenses/>.
-
-//
-// N3762 basic_string_view library
-//
-
-
-#if __cplusplus >= 201703L
-
-#include <string_view>
-
-namespace gdb {
-  using string_view = std::string_view;
-} /* namespace gdb */
-
-#else /* __cplusplus < 201703L */
-
-#include <string>
-#include <limits>
-
-namespace gdb {
-
-  /**
-   *  @class basic_string_view <experimental/string_view>
-   *  @brief  A non-owning reference to a string.
-   *
-   *  @ingroup strings
-   *  @ingroup sequences
-   *  @ingroup experimental
-   *
-   *  @tparam _CharT  Type of character
-   *  @tparam _Traits  Traits for character type, defaults to
-   *                   char_traits<_CharT>.
-   *
-   *  A basic_string_view looks like this:
-   *
-   *  @code
-   *    _CharT*    _M_str
-   *    size_t     _M_len
-   *  @endcode
-   */
-  template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
-    class basic_string_view
-    {
-    public:
-
-      // types
-      using traits_type = _Traits;
-      using value_type = _CharT;
-      using pointer = const _CharT*;
-      using const_pointer = const _CharT*;
-      using reference = const _CharT&;
-      using const_reference = const _CharT&;
-      using const_iterator = const _CharT*;
-      using iterator = const_iterator;
-      using const_reverse_iterator = std::reverse_iterator<const_iterator>;
-      using reverse_iterator = const_reverse_iterator;
-      using size_type = size_t;
-      using difference_type = ptrdiff_t;
-      static constexpr size_type npos = size_type(-1);
-
-      // [string.view.cons], construct/copy
-
-      constexpr
-      basic_string_view() noexcept
-      : _M_len{0}, _M_str{nullptr}
-      { }
-
-      constexpr basic_string_view(const basic_string_view&) noexcept = default;
-
-      template<typename _Allocator>
-        basic_string_view(const std::basic_string<_CharT, _Traits,
-                         _Allocator>& __str) noexcept
-        : _M_len{__str.length()}, _M_str{__str.data()}
-        { }
-
-      /*constexpr*/ basic_string_view(const _CharT* __str)
-      : _M_len{__str == nullptr ? 0 : traits_type::length(__str)},
-       _M_str{__str}
-      { }
-
-      constexpr basic_string_view(const _CharT* __str, size_type __len)
-      : _M_len{__len},
-        _M_str{__str}
-      { }
-
-      basic_string_view&
-      operator=(const basic_string_view&) noexcept = default;
-
-      // [string.view.iterators], iterators
-
-      constexpr const_iterator
-      begin() const noexcept
-      { return this->_M_str; }
-
-      constexpr const_iterator
-      end() const noexcept
-      { return this->_M_str + this->_M_len; }
-
-      constexpr const_iterator
-      cbegin() const noexcept
-      { return this->_M_str; }
-
-      constexpr const_iterator
-      cend() const noexcept
-      { return this->_M_str + this->_M_len; }
-
-      const_reverse_iterator
-      rbegin() const noexcept
-      { return const_reverse_iterator(this->end()); }
-
-      const_reverse_iterator
-      rend() const noexcept
-      { return const_reverse_iterator(this->begin()); }
-
-      const_reverse_iterator
-      crbegin() const noexcept
-      { return const_reverse_iterator(this->end()); }
-
-      const_reverse_iterator
-      crend() const noexcept
-      { return const_reverse_iterator(this->begin()); }
-
-      // [string.view.capacity], capacity
-
-      constexpr size_type
-      size() const noexcept
-      { return this->_M_len; }
-
-      constexpr size_type
-      length() const noexcept
-      { return _M_len; }
-
-      constexpr size_type
-      max_size() const noexcept
-      {
-       return (npos - sizeof(size_type) - sizeof(void*))
-               / sizeof(value_type) / 4;
-      }
-
-      constexpr bool
-      empty() const noexcept
-      { return this->_M_len == 0; }
-
-      // [string.view.access], element access
-
-      constexpr const _CharT&
-      operator[](size_type __pos) const
-      {
-       // TODO: Assert to restore in a way compatible with the constexpr.
-       // __glibcxx_assert(__pos < this->_M_len);
-       return *(this->_M_str + __pos);
-      }
-
-      constexpr const _CharT&
-      at(size_type __pos) const
-      {
-       return __pos < this->_M_len
-            ? *(this->_M_str + __pos)
-            : (error (_("basic_string_view::at: __pos "
-                        "(which is %zu) >= this->size() "
-                        "(which is %zu)"),
-                      __pos, this->size()),
-               *this->_M_str);
-      }
-
-      constexpr const _CharT&
-      front() const
-      {
-       // TODO: Assert to restore in a way compatible with the constexpr.
-       // __glibcxx_assert(this->_M_len > 0);
-       return *this->_M_str;
-      }
-
-      constexpr const _CharT&
-      back() const
-      {
-       // TODO: Assert to restore in a way compatible with the constexpr.
-       // __glibcxx_assert(this->_M_len > 0);
-       return *(this->_M_str + this->_M_len - 1);
-      }
-
-      constexpr const _CharT*
-      data() const noexcept
-      { return this->_M_str; }
-
-      // [string.view.modifiers], modifiers:
-
-      /*constexpr*/ void
-      remove_prefix(size_type __n)
-      {
-       gdb_assert (this->_M_len >= __n);
-       this->_M_str += __n;
-       this->_M_len -= __n;
-      }
-
-      /*constexpr*/ void
-      remove_suffix(size_type __n)
-      { this->_M_len -= __n; }
-
-      /*constexpr*/ void
-      swap(basic_string_view& __sv) noexcept
-      {
-       auto __tmp = *this;
-       *this = __sv;
-       __sv = __tmp;
-      }
-
-
-      // [string.view.ops], string operations:
-
-      template<typename _Allocator>
-        explicit operator std::basic_string<_CharT, _Traits, _Allocator>() const
-        {
-         return { this->_M_str, this->_M_len };
-       }
-
-      template<typename _Allocator = std::allocator<_CharT>>
-       std::basic_string<_CharT, _Traits, _Allocator>
-       to_string(const _Allocator& __alloc = _Allocator()) const
-       {
-         return { this->_M_str, this->_M_len, __alloc };
-       }
-
-      size_type
-      copy(_CharT* __str, size_type __n, size_type __pos = 0) const
-      {
-       gdb_assert (__str != nullptr || __n == 0);
-       if (__pos > this->_M_len)
-         error (_("basic_string_view::copy: __pos "
-                  "(which is %zu) > this->size() "
-                  "(which is %zu)"),
-                __pos, this->size());
-       size_type __rlen{std::min(__n, size_type{this->_M_len  - __pos})};
-       for (auto __begin = this->_M_str + __pos,
-            __end = __begin + __rlen; __begin != __end;)
-         *__str++ = *__begin++;
-       return __rlen;
-      }
-
-
-      // [string.view.ops], string operations:
-
-      /*constexpr*/ basic_string_view
-      substr(size_type __pos, size_type __n=npos) const
-      {
-       return __pos <= this->_M_len
-            ? basic_string_view{this->_M_str + __pos,
-                               std::min(__n, size_type{this->_M_len  - __pos})}
-            : (error (_("basic_string_view::substr: __pos "
-                        "(which is %zu) > this->size() "
-                        "(which is %zu)"),
-                      __pos, this->size()), basic_string_view{});
-      }
-
-      /*constexpr*/ int
-      compare(basic_string_view __str) const noexcept
-      {
-       int __ret = traits_type::compare(this->_M_str, __str._M_str,
-                                        std::min(this->_M_len, __str._M_len));
-       if (__ret == 0)
-         __ret = _S_compare(this->_M_len, __str._M_len);
-       return __ret;
-      }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1, basic_string_view __str) const
-      { return this->substr(__pos1, __n1).compare(__str); }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1,
-             basic_string_view __str, size_type __pos2, size_type __n2) const
-      { return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); }
-
-      /*constexpr*/ int
-      compare(const _CharT* __str) const noexcept
-      { return this->compare(basic_string_view{__str}); }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1, const _CharT* __str) const
-      { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1,
-             const _CharT* __str, size_type __n2) const
-      {
-       return this->substr(__pos1, __n1)
-                  .compare(basic_string_view(__str, __n2));
-      }
-
-      /*constexpr*/ size_type
-      find(basic_string_view __str, size_type __pos = 0) const noexcept
-      { return this->find(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find(_CharT __c, size_type __pos=0) const noexcept;
-
-      /*constexpr*/ size_type
-      find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
-
-      /*constexpr*/ size_type
-      find(const _CharT* __str, size_type __pos=0) const noexcept
-      { return this->find(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      rfind(basic_string_view __str, size_type __pos = npos) const noexcept
-      { return this->rfind(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      rfind(_CharT __c, size_type __pos = npos) const noexcept;
-
-      /*constexpr*/ size_type
-      rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
-
-      /*constexpr*/ size_type
-      rfind(const _CharT* __str, size_type __pos = npos) const noexcept
-      { return this->rfind(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
-      { return this->find_first_of(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find_first_of(_CharT __c, size_type __pos = 0) const noexcept
-      { return this->find(__c, __pos); }
-
-      /*constexpr*/ size_type
-      find_first_of(const _CharT* __str, size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
-      { return this->find_first_of(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      find_last_of(basic_string_view __str,
-                  size_type __pos = npos) const noexcept
-      { return this->find_last_of(__str._M_str, __pos, __str._M_len); }
-
-      size_type
-      find_last_of(_CharT __c, size_type __pos=npos) const noexcept
-      { return this->rfind(__c, __pos); }
-
-      /*constexpr*/ size_type
-      find_last_of(const _CharT* __str, size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
-      { return this->find_last_of(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      find_first_not_of(basic_string_view __str,
-                       size_type __pos = 0) const noexcept
-      { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
-
-      /*constexpr*/ size_type
-      find_first_not_of(const _CharT* __str,
-                       size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
-      {
-       return this->find_first_not_of(__str, __pos,
-                                      traits_type::length(__str));
-      }
-
-      /*constexpr*/ size_type
-      find_last_not_of(basic_string_view __str,
-                      size_type __pos = npos) const noexcept
-      { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
-
-      /*constexpr*/ size_type
-      find_last_not_of(const _CharT* __str,
-                      size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_last_not_of(const _CharT* __str,
-                      size_type __pos = npos) const noexcept
-      {
-       return this->find_last_not_of(__str, __pos,
-                                     traits_type::length(__str));
-      }
-
-    private:
-
-      static constexpr int
-      _S_compare(size_type __n1, size_type __n2) noexcept
-      {
-       return difference_type(__n1 - __n2) > std::numeric_limits<int>::max()
-            ? std::numeric_limits<int>::max()
-            : difference_type(__n1 - __n2) < std::numeric_limits<int>::min()
-            ? std::numeric_limits<int>::min()
-            : static_cast<int>(difference_type(__n1 - __n2));
-      }
-
-      size_t       _M_len;
-      const _CharT* _M_str;
-    };
-
-  // [string.view.comparison], non-member basic_string_view comparison functions
-
-  namespace __detail
-  {
-    // Identity transform to create a non-deduced context, so that only one
-    // argument participates in template argument deduction and the other
-    // argument gets implicitly converted to the deduced type. See n3766.html.
-    template<typename _Tp>
-      using __idt = typename std::common_type<_Tp>::type;
-  }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator==(basic_string_view<_CharT, _Traits> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator==(basic_string_view<_CharT, _Traits> __x,
-               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator!=(basic_string_view<_CharT, _Traits> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return !(__x == __y); }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator!=(basic_string_view<_CharT, _Traits> __x,
-               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return !(__x == __y); }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return !(__x == __y); }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator< (basic_string_view<_CharT, _Traits> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) < 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator< (basic_string_view<_CharT, _Traits> __x,
-               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) < 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) < 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator> (basic_string_view<_CharT, _Traits> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) > 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator> (basic_string_view<_CharT, _Traits> __x,
-               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) > 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) > 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator<=(basic_string_view<_CharT, _Traits> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) <= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator<=(basic_string_view<_CharT, _Traits> __x,
-               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) <= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) <= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator>=(basic_string_view<_CharT, _Traits> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) >= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator>=(basic_string_view<_CharT, _Traits> __x,
-               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) >= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-               basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) >= 0; }
-
-  // basic_string_view typedef names
-
-  using string_view = basic_string_view<char>;
-} /* namespace gdb */
-
-#include "gdb_string_view.tcc"
-
-#endif // __cplusplus < 201703L
-
-#endif /* COMMON_GDB_STRING_VIEW_H */
diff --git a/gdb/common/gdb_string_view.tcc b/gdb/common/gdb_string_view.tcc
deleted file mode 100644 (file)
index c30aafa..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-// Components for manipulating non-owning sequences of characters -*- C++ -*-
-
-// Note: This file has been stolen from the gcc repo
-// (libstdc++-v3/include/experimental/bits/string_view.tcc) and has local
-// modifications.
-
-// Copyright (C) 2013-2019 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library 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, or (at your option)
-// any later version.
-
-// This library 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.
-
-// Under Section 7 of GPL version 3, you are granted additional
-// permissions described in the GCC Runtime Library Exception, version
-// 3.1, as published by the Free Software Foundation.
-
-// You should have received a copy of the GNU General Public License and
-// a copy of the GCC Runtime Library Exception along with this program;
-// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
-// <http://www.gnu.org/licenses/>.
-
-/** @file experimental/bits/string_view.tcc
- *  This is an internal header file, included by other library headers.
- *  Do not attempt to use it directly. @headername{experimental/string_view}
- */
-
-//
-// N3762 basic_string_view library
-//
-
-#ifndef GDB_STRING_VIEW_TCC
-#define GDB_STRING_VIEW_TCC 1
-
-namespace gdb
-{
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find(const _CharT* __str, size_type __pos, size_type __n) const noexcept
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-
-      if (__n == 0)
-       return __pos <= this->_M_len ? __pos : npos;
-
-      if (__n <= this->_M_len)
-       {
-         for (; __pos <= this->_M_len - __n; ++__pos)
-           if (traits_type::eq(this->_M_str[__pos], __str[0])
-               && traits_type::compare(this->_M_str + __pos + 1,
-                                       __str + 1, __n - 1) == 0)
-             return __pos;
-       }
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find(_CharT __c, size_type __pos) const noexcept
-    {
-      size_type __ret = npos;
-      if (__pos < this->_M_len)
-       {
-         const size_type __n = this->_M_len - __pos;
-         const _CharT* __p = traits_type::find(this->_M_str + __pos, __n, __c);
-         if (__p)
-           __ret = __p - this->_M_str;
-       }
-      return __ret;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-
-      if (__n <= this->_M_len)
-       {
-         __pos = std::min(size_type(this->_M_len - __n), __pos);
-         do
-           {
-             if (traits_type::compare(this->_M_str + __pos, __str, __n) == 0)
-               return __pos;
-           }
-         while (__pos-- > 0);
-       }
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    rfind(_CharT __c, size_type __pos) const noexcept
-    {
-      size_type __size = this->_M_len;
-      if (__size > 0)
-       {
-         if (--__size > __pos)
-           __size = __pos;
-         for (++__size; __size-- > 0; )
-           if (traits_type::eq(this->_M_str[__size], __c))
-             return __size;
-       }
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_first_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      for (; __n && __pos < this->_M_len; ++__pos)
-       {
-         const _CharT* __p = traits_type::find(__str, __n,
-                                               this->_M_str[__pos]);
-         if (__p)
-           return __pos;
-       }
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_last_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      size_type __size = this->size();
-      if (__size && __n)
-       {
-         if (--__size > __pos)
-           __size = __pos;
-         do
-           {
-             if (traits_type::find(__str, __n, this->_M_str[__size]))
-               return __size;
-           }
-         while (__size-- != 0);
-       }
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      for (; __pos < this->_M_len; ++__pos)
-       if (!traits_type::find(__str, __n, this->_M_str[__pos]))
-         return __pos;
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_first_not_of(_CharT __c, size_type __pos) const noexcept
-    {
-      for (; __pos < this->_M_len; ++__pos)
-       if (!traits_type::eq(this->_M_str[__pos], __c))
-         return __pos;
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      size_type __size = this->_M_len;
-      if (__size)
-       {
-         if (--__size > __pos)
-           __size = __pos;
-         do
-           {
-             if (!traits_type::find(__str, __n, this->_M_str[__size]))
-               return __size;
-           }
-         while (__size--);
-       }
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_last_not_of(_CharT __c, size_type __pos) const noexcept
-    {
-      size_type __size = this->_M_len;
-      if (__size)
-       {
-         if (--__size > __pos)
-           __size = __pos;
-         do
-           {
-             if (!traits_type::eq(this->_M_str[__size], __c))
-               return __size;
-           }
-         while (__size--);
-       }
-      return npos;
-    }
-} // namespace gdb
-
-#endif // GDB_STRING_VIEW_TCC
diff --git a/gdb/common/gdb_sys_time.h b/gdb/common/gdb_sys_time.h
deleted file mode 100644 (file)
index 66c2bb3..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 2015-2019 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/>.  */
-
-#ifndef COMMON_GDB_SYS_TIME_H
-#define COMMON_GDB_SYS_TIME_H
-
-#include <sys/time.h>
-
-/* On MinGW-w64, gnulib's sys/time.h replaces 'struct timeval' and
-   gettimeofday with versions that support 64-bit time_t, for POSIX
-   compliance.  However, the gettimeofday replacement does not ever
-   return time_t values larger than 31-bit, as it simply returns the
-   system's gettimeofday's (signed) 32-bit result as (signed) 64-bit.
-   Because we don't really need the POSIX compliance, and it ends up
-   causing conflicts with other libraries we use that don't use gnulib
-   and thus work with the native struct timeval, such as Winsock2's
-   native 'select' and libiberty, simply undefine away gnulib's
-   replacements.  */
-#if GNULIB_defined_struct_timeval
-# undef timeval
-# undef gettimeofday
-#endif
-
-#endif /* COMMON_GDB_SYS_TIME_H */
diff --git a/gdb/common/gdb_tilde_expand.c b/gdb/common/gdb_tilde_expand.c
deleted file mode 100644 (file)
index 326df8f..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Perform tilde expansion on paths for GDB and gdbserver.
-
-   Copyright (C) 2017-2019 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 "common-defs.h"
-#include "gdb_tilde_expand.h"
-#include <glob.h>
-
-/* RAII-style class wrapping "glob".  */
-
-class gdb_glob
-{
-public:
-  /* Construct a "gdb_glob" object by calling "glob" with the provided
-     parameters.  This function can throw if "glob" fails.  */
-  gdb_glob (const char *pattern, int flags,
-           int (*errfunc) (const char *epath, int eerrno))
-  {
-    int ret = glob (pattern, flags, errfunc, &m_glob);
-
-    if (ret != 0)
-      {
-       if (ret == GLOB_NOMATCH)
-         error (_("Could not find a match for '%s'."), pattern);
-       else
-         error (_("glob could not process pattern '%s'."),
-                pattern);
-      }
-  }
-
-  /* Destroy the object and free M_GLOB.  */
-  ~gdb_glob ()
-  {
-    globfree (&m_glob);
-  }
-
-  /* Return the GL_PATHC component of M_GLOB.  */
-  int pathc () const
-  {
-    return m_glob.gl_pathc;
-  }
-
-  /* Return the GL_PATHV component of M_GLOB.  */
-  char **pathv () const
-  {
-    return m_glob.gl_pathv;
-  }
-
-private:
-  /* The actual glob object we're dealing with.  */
-  glob_t m_glob;
-};
-
-/* See common/gdb_tilde_expand.h.  */
-
-std::string
-gdb_tilde_expand (const char *dir)
-{
-  gdb_glob glob (dir, GLOB_TILDE_CHECK, NULL);
-
-  gdb_assert (glob.pathc () > 0);
-  /* "glob" may return more than one match to the path provided by the
-     user, but we are only interested in the first match.  */
-  std::string expanded_dir = glob.pathv ()[0];
-
-  return expanded_dir;
-}
-
-/* See common/gdb_tilde_expand.h.  */
-
-gdb::unique_xmalloc_ptr<char>
-gdb_tilde_expand_up (const char *dir)
-{
-  gdb_glob glob (dir, GLOB_TILDE_CHECK, NULL);
-
-  gdb_assert (glob.pathc () > 0);
-  /* "glob" may return more than one match to the path provided by the
-     user, but we are only interested in the first match.  */
-  return make_unique_xstrdup (glob.pathv ()[0]);
-}
diff --git a/gdb/common/gdb_tilde_expand.h b/gdb/common/gdb_tilde_expand.h
deleted file mode 100644 (file)
index b181b6a..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Perform tilde expansion on paths for GDB and gdbserver.
-
-   Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_GDB_TILDE_EXPAND_H
-#define COMMON_GDB_TILDE_EXPAND_H
-
-/* Perform path expansion (i.e., tilde expansion) on DIR, and return
-   the full path.  */
-extern std::string gdb_tilde_expand (const char *dir);
-
-/* Same as GDB_TILDE_EXPAND, but return the full path as a
-   gdb::unique_xmalloc_ptr<char>.  */
-extern gdb::unique_xmalloc_ptr<char> gdb_tilde_expand_up (const char *dir);
-
-#endif /* COMMON_GDB_TILDE_EXPAND_H */
diff --git a/gdb/common/gdb_unique_ptr.h b/gdb/common/gdb_unique_ptr.h
deleted file mode 100644 (file)
index 67a5f26..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* std::unique_ptr specializations for GDB.
-
-   Copyright (C) 2016-2019 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/>.  */
-
-#ifndef COMMON_GDB_UNIQUE_PTR_H
-#define COMMON_GDB_UNIQUE_PTR_H
-
-#include <memory>
-
-namespace gdb
-{
-/* Define gdb::unique_xmalloc_ptr, a std::unique_ptr that manages
-   xmalloc'ed memory.  */
-
-/* The deleter for std::unique_xmalloc_ptr.  Uses xfree.  */
-template <typename T>
-struct xfree_deleter
-{
-  void operator() (T *ptr) const { xfree (ptr); }
-};
-
-/* Same, for arrays.  */
-template <typename T>
-struct xfree_deleter<T[]>
-{
-  void operator() (T *ptr) const { xfree (ptr); }
-};
-
-/* Import the standard unique_ptr to our namespace with a custom
-   deleter.  */
-
-template<typename T> using unique_xmalloc_ptr
-  = std::unique_ptr<T, xfree_deleter<T>>;
-
-/* A no-op deleter.  */
-template<typename T>
-struct noop_deleter
-{
-  void operator() (T *ptr) const { }
-};
-
-} /* namespace gdb */
-
-/* Dup STR and return a unique_xmalloc_ptr for the result.  */
-
-static inline gdb::unique_xmalloc_ptr<char>
-make_unique_xstrdup (const char *str)
-{
-  return gdb::unique_xmalloc_ptr<char> (xstrdup (str));
-}
-
-#endif /* COMMON_GDB_UNIQUE_PTR_H */
diff --git a/gdb/common/gdb_unlinker.h b/gdb/common/gdb_unlinker.h
deleted file mode 100644 (file)
index 193c2f8..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Unlinking class
-
-   Copyright (C) 2016-2019 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/>.  */
-
-#ifndef COMMON_GDB_UNLINKER_H
-#define COMMON_GDB_UNLINKER_H
-
-namespace gdb
-{
-
-/* An object of this class holds a filename and, when the object goes
-   of scope, the file is removed using unlink.
-
-   A user of this class can request that the file be preserved using
-   the "keep" method.  */
-class unlinker
-{
- public:
-
-  unlinker (const char *filename) ATTRIBUTE_NONNULL (2)
-    : m_filename (filename)
-  {
-    gdb_assert (filename != NULL);
-  }
-
-  ~unlinker ()
-  {
-    if (m_filename != NULL)
-      unlink (m_filename);
-  }
-
-  /* Keep the file, rather than unlink it.  */
-  void keep ()
-  {
-    m_filename = NULL;
-  }
-
- private:
-
-  const char *m_filename;
-};
-
-}
-
-#endif /* COMMON_GDB_UNLINKER_H */
diff --git a/gdb/common/gdb_vecs.c b/gdb/common/gdb_vecs.c
deleted file mode 100644 (file)
index 38f42f5..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* Some commonly-used VEC types.
-
-   Copyright (C) 2012-2019 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 "common-defs.h"
-#include "gdb_vecs.h"
-#include "host-defs.h"
-
-/* Worker function to split character delimiter separated string of fields
-   STR into a char pointer vector.  */
-
-static void
-delim_string_to_char_ptr_vec_append
-  (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *str,
-   char delimiter)
-{
-  do
-    {
-      size_t this_len;
-      const char *next_field;
-      char *this_field;
-
-      next_field = strchr (str, delimiter);
-      if (next_field == NULL)
-       this_len = strlen (str);
-      else
-       {
-         this_len = next_field - str;
-         next_field++;
-       }
-
-      this_field = (char *) xmalloc (this_len + 1);
-      memcpy (this_field, str, this_len);
-      this_field[this_len] = '\0';
-      vecp->emplace_back (this_field);
-
-      str = next_field;
-    }
-  while (str != NULL);
-}
-
-/* See gdb_vecs.h.  */
-
-std::vector<gdb::unique_xmalloc_ptr<char>>
-delim_string_to_char_ptr_vec (const char *str, char delimiter)
-{
-  std::vector<gdb::unique_xmalloc_ptr<char>> retval;
-  
-  delim_string_to_char_ptr_vec_append (&retval, str, delimiter);
-
-  return retval;
-}
-
-/* See gdb_vecs.h.  */
-
-void
-dirnames_to_char_ptr_vec_append
-  (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames)
-{
-  delim_string_to_char_ptr_vec_append (vecp, dirnames, DIRNAME_SEPARATOR);
-}
-
-/* See gdb_vecs.h.  */
-
-std::vector<gdb::unique_xmalloc_ptr<char>>
-dirnames_to_char_ptr_vec (const char *dirnames)
-{
-  std::vector<gdb::unique_xmalloc_ptr<char>> retval;
-  
-  dirnames_to_char_ptr_vec_append (&retval, dirnames);
-
-  return retval;
-}
diff --git a/gdb/common/gdb_vecs.h b/gdb/common/gdb_vecs.h
deleted file mode 100644 (file)
index 017bf93..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Some commonly-used VEC types.
-
-   Copyright (C) 2012-2019 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/>.  */
-
-#ifndef COMMON_GDB_VECS_H
-#define COMMON_GDB_VECS_H
-
-#include "vec.h"
-
-/* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
-
-   You may modify the returned strings.  */
-
-extern std::vector<gdb::unique_xmalloc_ptr<char>>
-  delim_string_to_char_ptr_vec (const char *str, char delimiter);
-
-/* Like dirnames_to_char_ptr_vec, but append the directories to *VECP.  */
-
-extern void dirnames_to_char_ptr_vec_append
-  (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames);
-
-/* Split DIRNAMES by DIRNAME_SEPARATOR delimiter and return a list of all the
-   elements in their original order.  For empty string ("") DIRNAMES return
-   list of one empty string ("") element.
-
-   You may modify the returned strings.  */
-
-extern std::vector<gdb::unique_xmalloc_ptr<char>>
-  dirnames_to_char_ptr_vec (const char *dirnames);
-
-/* Remove the element pointed by iterator IT from VEC, not preserving the order
-   of the remaining elements.  Return the removed element.  */
-
-template <typename T>
-T
-unordered_remove (std::vector<T> &vec, typename std::vector<T>::iterator it)
-{
-  gdb_assert (it >= vec.begin () && it < vec.end ());
-
-  T removed = std::move (*it);
-  *it = std::move (vec.back ());
-  vec.pop_back ();
-
-  return removed;
-}
-
-/* Remove the element at position IX from VEC, not preserving the order of the
-   remaining elements.  Return the removed element.  */
-
-template <typename T>
-T
-unordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
-{
-  gdb_assert (ix < vec.size ());
-
-  return unordered_remove (vec, vec.begin () + ix);
-}
-
-/* Remove the element at position IX from VEC, preserving the order the
-   remaining elements.  Return the removed element.  */
-
-template <typename T>
-T
-ordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
-{
-  gdb_assert (ix < vec.size ());
-
-  T removed = std::move (vec[ix]);
-  vec.erase (vec.begin () + ix);
-
-  return removed;
-}
-
-#endif /* COMMON_GDB_VECS_H */
diff --git a/gdb/common/gdb_wait.h b/gdb/common/gdb_wait.h
deleted file mode 100644 (file)
index b3b752c..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Standard wait macros.
-   Copyright (C) 2000-2019 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/>.  */
-
-#ifndef COMMON_GDB_WAIT_H
-#define COMMON_GDB_WAIT_H
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h> /* POSIX */
-#else
-#ifdef HAVE_WAIT_H
-#include <wait.h> /* legacy */
-#endif
-#endif
-
-/* Define how to access the int that the wait system call stores.
-   This has been compatible in all Unix systems since time immemorial,
-   but various well-meaning people have defined various different
-   words for the same old bits in the same old int (sometimes claimed
-   to be a struct).  We just know it's an int and we use these macros
-   to access the bits.  */
-
-/* The following macros are defined equivalently to their definitions
-   in POSIX.1.  We fail to define WNOHANG and WUNTRACED, which POSIX.1
-   <sys/wait.h> defines, since our code does not use waitpid() (but
-   NOTE exception for GNU/Linux below).  We also fail to declare
-   wait() and waitpid().  */
-
-#ifndef        WIFEXITED
-#define WIFEXITED(w)   (((w)&0377) == 0)
-#endif
-
-#ifndef        WIFSIGNALED
-#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
-#endif
-
-#ifndef        WIFSTOPPED
-#ifdef IBM6000
-
-/* Unfortunately, the above comment (about being compatible in all Unix 
-   systems) is not quite correct for AIX, sigh.  And AIX 3.2 can generate
-   status words like 0x57c (sigtrap received after load), and gdb would
-   choke on it.  */
-
-#define WIFSTOPPED(w)  ((w)&0x40)
-
-#else
-#define WIFSTOPPED(w)  (((w)&0377) == 0177)
-#endif
-#endif
-
-#ifndef        WEXITSTATUS
-#define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */
-#endif
-
-#ifndef        WTERMSIG
-#define WTERMSIG(w)    ((w) & 0177)
-#endif
-
-#ifndef        WSTOPSIG
-#define WSTOPSIG       WEXITSTATUS
-#endif
-
-/* These are not defined in POSIX, but are used by our programs.  */
-
-#ifndef        WSETEXIT
-# ifdef        W_EXITCODE
-#define        WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
-# else
-#define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
-# endif
-#endif
-
-#ifndef W_STOPCODE
-#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
-#endif
-
-#ifndef        WSETSTOP
-#define        WSETSTOP(w,sig)    ((w) = W_STOPCODE(sig))
-#endif
-
-/* For native GNU/Linux we may use waitpid and the __WCLONE option.
-  <GRIPE> It is of course dangerous not to use the REAL header file...
-  </GRIPE>.  */
-
-/* Bits in the third argument to `waitpid'.  */
-#ifndef WNOHANG
-#define        WNOHANG         1       /* Don't block waiting.  */
-#endif
-
-#ifndef WUNTRACED
-#define        WUNTRACED       2       /* Report status of stopped children.  */
-#endif
-
-#ifndef __WCLONE
-#define __WCLONE       0x80000000 /* Wait for cloned process.  */
-#endif
-
-#endif /* COMMON_GDB_WAIT_H */
diff --git a/gdb/common/hash_enum.h b/gdb/common/hash_enum.h
deleted file mode 100644 (file)
index 4baf01e..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/* A hasher for enums.
-
-   Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_HASH_ENUM_H
-#define COMMON_HASH_ENUM_H
-
-/* A hasher for enums, which was missing in C++11:
-    http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148
-*/
-
-namespace gdb {
-
-/* Helper struct for hashing enum types.  */
-template<typename T>
-struct hash_enum
-{
-  typedef size_t result_type;
-  typedef T argument_type;
-
-  size_t operator() (T val) const noexcept
-  {
-    using underlying = typename std::underlying_type<T>::type;
-    return std::hash<underlying> () (static_cast<underlying> (val));
-  }
-};
-
-} /* namespace gdb */
-
-#endif /* COMMON_HASH_ENUM_H */
diff --git a/gdb/common/host-defs.h b/gdb/common/host-defs.h
deleted file mode 100644 (file)
index dedd9b6..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Basic host-specific definitions for GDB.
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_HOST_DEFS_H
-#define COMMON_HOST_DEFS_H
-
-#include <limits.h>
-
-/* Static host-system-dependent parameters for GDB.  */
-
-/* * Number of bits in a char or unsigned char for the target machine.
-   Just like CHAR_BIT in <limits.h> but describes the target machine.  */
-#if !defined (TARGET_CHAR_BIT)
-#define TARGET_CHAR_BIT 8
-#endif
-
-/* * If we picked up a copy of CHAR_BIT from a configuration file
-   (which may get it by including <limits.h>) then use it to set
-   the number of bits in a host char.  If not, use the same size
-   as the target.  */
-
-#if defined (CHAR_BIT)
-#define HOST_CHAR_BIT CHAR_BIT
-#else
-#define HOST_CHAR_BIT TARGET_CHAR_BIT
-#endif
-
-#ifdef __MSDOS__
-# define CANT_FORK
-# define GLOBAL_CURDIR
-# define DIRNAME_SEPARATOR ';'
-#endif
-
-#if !defined (__CYGWIN__) && defined (_WIN32)
-# define DIRNAME_SEPARATOR ';'
-#endif
-
-#ifndef DIRNAME_SEPARATOR
-#define DIRNAME_SEPARATOR ':'
-#endif
-
-#ifndef SLASH_STRING
-#define SLASH_STRING "/"
-#endif
-
-#endif /* COMMON_HOST_DEFS_H */
diff --git a/gdb/common/job-control.c b/gdb/common/job-control.c
deleted file mode 100644 (file)
index fc3de68..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Job control and terminal related functions, for GDB and gdbserver
-   when running under Unix.
-
-   Copyright (C) 1986-2019 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 "common-defs.h"
-#include "job-control.h"
-#ifdef HAVE_TERMIOS_H
-#include <termios.h>
-#endif
-#include <unistd.h>
-
-/* Nonzero if we have job control.  */
-int job_control;
-
-/* Set the process group ID of the inferior.
-
-   Just using job_control only does part of it because setpgid or
-   setpgrp might not exist on a system without job control.
-
-   For a more clean implementation, in libiberty, put a setpgid which merely
-   calls setpgrp and a setpgrp which does nothing (any system with job control
-   will have one or the other).  */
-
-int
-gdb_setpgid ()
-{
-  int retval = 0;
-
-  if (job_control)
-    {
-#ifdef HAVE_SETPGID
-      /* The call setpgid (0, 0) is supposed to work and mean the same
-         thing as this, but on Ultrix 4.2A it fails with EPERM (and
-         setpgid (getpid (), getpid ()) succeeds).  */
-      retval = setpgid (getpid (), getpid ());
-#else
-#ifdef HAVE_SETPGRP
-#ifdef SETPGRP_VOID
-      retval = setpgrp ();
-#else
-      retval = setpgrp (getpid (), getpid ());
-#endif
-#endif /* HAVE_SETPGRP */
-#endif /* HAVE_SETPGID */
-    }
-
-  return retval;
-}
-
-/* See common/common-terminal.h.  */
-
-void
-have_job_control ()
-{
-  /* OK, figure out whether we have job control.  If termios is not
-     available, leave job_control 0.  */
-#if defined (HAVE_TERMIOS_H)
-  /* Do all systems with termios have the POSIX way of identifying job
-     control?  I hope so.  */
-#ifdef _POSIX_JOB_CONTROL
-  job_control = 1;
-#else
-#ifdef _SC_JOB_CONTROL
-  job_control = sysconf (_SC_JOB_CONTROL);
-#else
-  job_control = 0;             /* Have to assume the worst.  */
-#endif /* _SC_JOB_CONTROL */
-#endif /* _POSIX_JOB_CONTROL */
-#endif /* HAVE_TERMIOS_H */
-}
diff --git a/gdb/common/job-control.h b/gdb/common/job-control.h
deleted file mode 100644 (file)
index 56eba97..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Job control and terminal related functions, for GDB and gdbserver
-   when running under Unix.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_JOB_CONTROL_H
-#define COMMON_JOB_CONTROL_H
-
-/* Do we have job control?  Can be assumed to always be the same
-   within a given run of GDB.  Use in gdb/inflow.c and
-   common/common-inflow.c.  */
-extern int job_control;
-
-/* Set the process group of the caller to its own pid, or do nothing
-   if we lack job control.  */
-extern int gdb_setpgid ();
-
-/* Determine whether we have job control, and set variable JOB_CONTROL
-   accordingly.  This function must be called before any use of
-   JOB_CONTROL.  */
-extern void have_job_control ();
-
-#endif /* COMMON_JOB_CONTROL_H */
diff --git a/gdb/common/mingw-strerror.c b/gdb/common/mingw-strerror.c
deleted file mode 100644 (file)
index 6386330..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Safe version of strerror for MinGW, for GDB, the GNU debugger.
-
-   Copyright (C) 2006-2019 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 "common-defs.h"
-
-#include <windows.h>
-
-/* Implementation of safe_strerror as defined in common-utils.h.
-
-   The Windows runtime implementation of strerror never returns NULL,
-   but does return a useless string for anything above sys_nerr;
-   unfortunately this includes all socket-related error codes.
-   This replacement tries to find a system-provided error message.  */
-
-char *
-safe_strerror (int errnum)
-{
-  static char *buffer;
-  int len;
-
-  if (errnum >= 0 && errnum < sys_nerr)
-    return strerror (errnum);
-
-  if (buffer)
-    {
-      LocalFree (buffer);
-      buffer = NULL;
-    }
-
-  if (FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
-                    | FORMAT_MESSAGE_FROM_SYSTEM,
-                    NULL, errnum,
-                    MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
-                    (LPTSTR) &buffer, 0, NULL) == 0)
-    {
-      static char buf[32];
-      xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum);
-      return buf;
-    }
-
-  /* Windows error messages end with a period and a CR-LF; strip that
-     out.  */
-  len = strlen (buffer);
-  if (len > 3 && strcmp (buffer + len - 3, ".\r\n") == 0)
-    buffer[len - 3] = '\0';
-
-  return buffer;
-}
diff --git a/gdb/common/netstuff.c b/gdb/common/netstuff.c
deleted file mode 100644 (file)
index b192de7..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Operations on network stuff.
-   Copyright (C) 2018-2019 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 "common-defs.h"
-#include "netstuff.h"
-#include <algorithm>
-
-#ifdef USE_WIN32API
-#include <ws2tcpip.h>
-#else
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <netinet/tcp.h>
-#endif
-
-/* See common/netstuff.h.  */
-
-scoped_free_addrinfo::~scoped_free_addrinfo ()
-{
-  freeaddrinfo (m_res);
-}
-
-/* See common/netstuff.h.  */
-
-parsed_connection_spec
-parse_connection_spec_without_prefix (std::string spec, struct addrinfo *hint)
-{
-  parsed_connection_spec ret;
-  size_t last_colon_pos = 0;
-  /* We're dealing with IPv6 if:
-
-     - ai_family is AF_INET6, or
-     - ai_family is not AF_INET, and
-       - spec[0] is '[', or
-       - the number of ':' on spec is greater than 1.  */
-  bool is_ipv6 = (hint->ai_family == AF_INET6
-                 || (hint->ai_family != AF_INET
-                     && (spec[0] == '['
-                         || std::count (spec.begin (),
-                                        spec.end (), ':') > 1)));
-
-  if (is_ipv6)
-    {
-      if (spec[0] == '[')
-       {
-         /* IPv6 addresses can be written as '[ADDR]:PORT', and we
-            support this notation.  */
-         size_t close_bracket_pos = spec.find_first_of (']');
-
-         if (close_bracket_pos == std::string::npos)
-           error (_("Missing close bracket in hostname '%s'"),
-                  spec.c_str ());
-
-         hint->ai_family = AF_INET6;
-
-         const char c = spec[close_bracket_pos + 1];
-
-         if (c == '\0')
-           last_colon_pos = std::string::npos;
-         else if (c != ':')
-           error (_("Invalid cruft after close bracket in '%s'"),
-                  spec.c_str ());
-
-         /* Erase both '[' and ']'.  */
-         spec.erase (0, 1);
-         spec.erase (close_bracket_pos - 1, 1);
-       }
-      else if (spec.find_first_of (']') != std::string::npos)
-       error (_("Missing open bracket in hostname '%s'"),
-              spec.c_str ());
-    }
-
-  if (last_colon_pos == 0)
-    last_colon_pos = spec.find_last_of (':');
-
-  /* The length of the hostname part.  */
-  size_t host_len;
-
-  if (last_colon_pos != std::string::npos)
-    {
-      /* The user has provided a port.  */
-      host_len = last_colon_pos;
-      ret.port_str = spec.substr (last_colon_pos + 1);
-    }
-  else
-    host_len = spec.size ();
-
-  ret.host_str = spec.substr (0, host_len);
-
-  /* Default hostname is localhost.  */
-  if (ret.host_str.empty ())
-    ret.host_str = "localhost";
-
-  return ret;
-}
-
-/* See common/netstuff.h.  */
-
-parsed_connection_spec
-parse_connection_spec (const char *spec, struct addrinfo *hint)
-{
-  /* Struct to hold the association between valid prefixes, their
-     family and socktype.  */
-  struct host_prefix
-    {
-      /* The prefix.  */
-      const char *prefix;
-
-      /* The 'ai_family'.  */
-      int family;
-
-      /* The 'ai_socktype'.  */
-      int socktype;
-    };
-  static const struct host_prefix prefixes[] =
-    {
-      { "udp:",  AF_UNSPEC, SOCK_DGRAM },
-      { "tcp:",  AF_UNSPEC, SOCK_STREAM },
-      { "udp4:", AF_INET,   SOCK_DGRAM },
-      { "tcp4:", AF_INET,   SOCK_STREAM },
-      { "udp6:", AF_INET6,  SOCK_DGRAM },
-      { "tcp6:", AF_INET6,  SOCK_STREAM },
-    };
-
-  for (const host_prefix prefix : prefixes)
-    if (startswith (spec, prefix.prefix))
-      {
-       spec += strlen (prefix.prefix);
-       hint->ai_family = prefix.family;
-       hint->ai_socktype = prefix.socktype;
-       hint->ai_protocol
-         = hint->ai_socktype == SOCK_DGRAM ? IPPROTO_UDP : IPPROTO_TCP;
-       break;
-      }
-
-  return parse_connection_spec_without_prefix (spec, hint);
-}
diff --git a/gdb/common/netstuff.h b/gdb/common/netstuff.h
deleted file mode 100644 (file)
index 0d39fb5..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Operations on network stuff.
-   Copyright (C) 2018-2019 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/>.  */
-
-#ifndef COMMON_NETSTUFF_H
-#define COMMON_NETSTUFF_H
-
-#include <string>
-
-/* Like NI_MAXHOST/NI_MAXSERV, but enough for numeric forms.  */
-#define GDB_NI_MAX_ADDR 64
-#define GDB_NI_MAX_PORT 16
-
-/* Helper class to guarantee that we always call 'freeaddrinfo'.  */
-
-class scoped_free_addrinfo
-{
-public:
-  /* Default constructor.  */
-  explicit scoped_free_addrinfo (struct addrinfo *ainfo)
-    : m_res (ainfo)
-  {
-  }
-
-  /* Destructor responsible for free'ing M_RES by calling
-     'freeaddrinfo'.  */
-  ~scoped_free_addrinfo ();
-
-  DISABLE_COPY_AND_ASSIGN (scoped_free_addrinfo);
-
-private:
-  /* The addrinfo resource.  */
-  struct addrinfo *m_res;
-};
-
-/* The struct we return after parsing the connection spec.  */
-
-struct parsed_connection_spec
-{
-  /* The hostname.  */
-  std::string host_str;
-
-  /* The port, if any.  */
-  std::string port_str;
-};
-
-
-/* Parse SPEC (which is a string in the form of "ADDR:PORT") and
-   return a 'parsed_connection_spec' structure with the proper fields
-   filled in.  Also adjust HINT accordingly.  */
-extern parsed_connection_spec
-  parse_connection_spec_without_prefix (std::string spec,
-                                       struct addrinfo *hint);
-
-/* Parse SPEC (which is a string in the form of
-   "[tcp[6]:|udp[6]:]ADDR:PORT") and return a 'parsed_connection_spec'
-   structure with the proper fields filled in.  Also adjust HINT
-   accordingly.  */
-extern parsed_connection_spec parse_connection_spec (const char *spec,
-                                                    struct addrinfo *hint);
-
-#endif /* COMMON_NETSTUFF_H */
diff --git a/gdb/common/new-op.c b/gdb/common/new-op.c
deleted file mode 100644 (file)
index 7c5dba0..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Replace operator new/new[], for GDB, the GNU debugger.
-
-   Copyright (C) 2016-2019 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/>.  */
-
-/* GCC does not understand __has_feature.  */
-#if !defined(__has_feature)
-# define __has_feature(x) 0
-#endif
-
-#if !__has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__)
-#include "common-defs.h"
-#include "host-defs.h"
-#include <new>
-
-/* Override operator new / operator new[], in order to internal_error
-   on allocation failure and thus query the user for abort/core
-   dump/continue, just like xmalloc does.  We don't do this from a
-   new-handler function instead (std::set_new_handler) because we want
-   to catch allocation errors from within global constructors too.
-
-   Skip overriding if building with -fsanitize=address though.
-   Address sanitizer wants to override operator new/delete too in
-   order to detect malloc+delete and new+free mismatches.  Our
-   versions would mask out ASan's, with the result of losing that
-   useful mismatch detection.
-
-   Note that C++ implementations could either have their throw
-   versions call the nothrow versions (libstdc++), or the other way
-   around (clang/libc++).  For that reason, we replace both throw and
-   nothrow variants and call malloc directly.  */
-
-void *
-operator new (std::size_t sz)
-{
-  /* malloc (0) is unpredictable; avoid it.  */
-  if (sz == 0)
-    sz = 1;
-
-  void *p = malloc (sz);       /* ARI: malloc */
-  if (p == NULL)
-    {
-      /* If the user decides to continue debugging, throw a
-        gdb_quit_bad_alloc exception instead of a regular QUIT
-        gdb_exception.  The former extends both std::bad_alloc and a
-        QUIT gdb_exception.  This is necessary because operator new
-        can only ever throw std::bad_alloc, or something that extends
-        it.  */
-      try
-       {
-         malloc_failure (sz);
-       }
-      catch (gdb_exception &ex)
-       {
-         throw gdb_quit_bad_alloc (std::move (ex));
-       }
-    }
-  return p;
-}
-
-void *
-operator new (std::size_t sz, const std::nothrow_t&) noexcept
-{
-  /* malloc (0) is unpredictable; avoid it.  */
-  if (sz == 0)
-    sz = 1;
-  return malloc (sz);          /* ARI: malloc */
-}
-
-void *
-operator new[] (std::size_t sz)
-{
-   return ::operator new (sz);
-}
-
-void*
-operator new[] (std::size_t sz, const std::nothrow_t&) noexcept
-{
-  return ::operator new (sz, std::nothrow);
-}
-#endif
diff --git a/gdb/common/next-iterator.h b/gdb/common/next-iterator.h
deleted file mode 100644 (file)
index b61b253..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/* A "next" iterator for GDB, the GNU debugger.
-   Copyright (C) 2019 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/>.  */
-
-#ifndef COMMON_NEXT_ITERATOR_H
-#define COMMON_NEXT_ITERATOR_H
-
-/* An iterator that uses the 'next' field of a type to iterate.  This
-   can be used with various GDB types that are stored as linked
-   lists.  */
-
-template<typename T>
-struct next_iterator
-{
-  typedef next_iterator self_type;
-  typedef T *value_type;
-  typedef T *&reference;
-  typedef T **pointer;
-  typedef std::forward_iterator_tag iterator_category;
-  typedef int difference_type;
-
-  explicit next_iterator (T *item)
-    : m_item (item)
-  {
-  }
-
-  /* Create a one-past-the-end iterator.  */
-  next_iterator ()
-    : m_item (nullptr)
-  {
-  }
-
-  value_type operator* () const
-  {
-    return m_item;
-  }
-
-  bool operator== (const self_type &other) const
-  {
-    return m_item == other.m_item;
-  }
-
-  bool operator!= (const self_type &other) const
-  {
-    return m_item != other.m_item;
-  }
-
-  self_type &operator++ ()
-  {
-    m_item = m_item->next;
-    return *this;
-  }
-
-private:
-
-  T *m_item;
-};
-
-/* A range adapter that allows iterating over a linked list.  */
-
-template<typename T, typename Iterator = next_iterator<T>>
-class next_adapter
-{
-public:
-
-  explicit next_adapter (T *item)
-    : m_item (item)
-  {
-  }
-
-  using iterator = Iterator;
-
-  iterator begin () const
-  {
-    return iterator (m_item);
-  }
-
-  iterator end () const
-  {
-    return iterator ();
-  }
-
-private:
-
-  T *m_item;
-};
-
-#endif /* COMMON_NEXT_ITERATOR_H */
diff --git a/gdb/common/observable.h b/gdb/common/observable.h
deleted file mode 100644 (file)
index 205c303..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Observers
-
-   Copyright (C) 2016-2019 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/>.  */
-
-#ifndef COMMON_OBSERVABLE_H
-#define COMMON_OBSERVABLE_H
-
-#include <algorithm>
-#include <functional>
-#include <vector>
-
-namespace gdb
-{
-
-namespace observers
-{
-
-extern unsigned int observer_debug;
-
-/* An observer is an entity which is interested in being notified
-   when GDB reaches certain states, or certain events occur in GDB.
-   The entity being observed is called the observable.  To receive
-   notifications, the observer attaches a callback to the observable.
-   One observable can have several observers.
-
-   The observer implementation is also currently not reentrant.  In
-   particular, it is therefore not possible to call the attach or
-   detach routines during a notification.  */
-
-/* The type of a key that can be passed to attach, which can be passed
-   to detach to remove associated observers.  Tokens have address
-   identity, and are thus usually const globals.  */
-struct token
-{
-  token () = default;
-
-  DISABLE_COPY_AND_ASSIGN (token);
-};
-
-template<typename... T>
-class observable
-{
-public:
-
-  typedef std::function<void (T...)> func_type;
-
-  explicit observable (const char *name)
-    : m_name (name)
-  {
-  }
-
-  DISABLE_COPY_AND_ASSIGN (observable);
-
-  /* Attach F as an observer to this observable.  F cannot be
-     detached.  */
-  void attach (const func_type &f)
-  {
-    m_observers.emplace_back (nullptr, f);
-  }
-
-  /* Attach F as an observer to this observable.  T is a reference to
-     a token that can be used to later remove F.  */
-  void attach (const func_type &f, const token &t)
-  {
-    m_observers.emplace_back (&t, f);
-  }
-
-  /* Remove observers associated with T from this observable.  T is
-     the token that was previously passed to any number of "attach"
-     calls.  */
-  void detach (const token &t)
-  {
-    auto iter = std::remove_if (m_observers.begin (),
-                               m_observers.end (),
-                               [&] (const std::pair<const token *,
-                                    func_type> &e)
-                               {
-                                 return e.first == &t;
-                               });
-
-    m_observers.erase (iter, m_observers.end ());
-  }
-
-  /* Notify all observers that are attached to this observable.  */
-  void notify (T... args) const
-  {
-    if (observer_debug)
-      fprintf_unfiltered (gdb_stdlog, "observable %s notify() called\n",
-                         m_name);
-    for (auto &&e : m_observers)
-      e.second (args...);
-  }
-
-private:
-
-  std::vector<std::pair<const token *, func_type>> m_observers;
-  const char *m_name;
-};
-
-} /* namespace observers */
-
-} /* namespace gdb */
-
-#endif /* COMMON_OBSERVABLE_H */
diff --git a/gdb/common/offset-type.h b/gdb/common/offset-type.h
deleted file mode 100644 (file)
index e1495b2..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Offset types for GDB.
-
-   Copyright (C) 2017-2019 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/>.  */
-
-/* Define an "offset" type.  Offset types are distinct integer types
-   that are used to represent an offset into anything that is
-   addressable.  For example, an offset into a DWARF debug section.
-   The idea is catch mixing unrelated offset types at compile time, in
-   code that needs to manipulate multiple different kinds of offsets
-   that are easily confused.  They're safer to use than native
-   integers, because they have no implicit conversion to anything.
-   And also, since they're implemented as "enum class" strong
-   typedefs, they're still integers ABI-wise, making them a bit more
-   efficient than wrapper structs on some ABIs.
-
-   Some properties of offset types, loosely modeled on pointers:
-
-   - You can compare offsets of the same type for equality and order.
-     You can't compare an offset with an unrelated type.
-
-   - You can add/substract an integer to/from an offset, which gives
-     you back a shifted offset.
-
-   - You can subtract two offsets of the same type, which gives you
-     back the delta as an integer (of the enum class's underlying
-     type), not as an offset type.
-
-   - You can't add two offsets of the same type, as that would not
-     make sense.
-
-   However, unlike pointers, you can't deference offset types.  */
-
-#ifndef COMMON_OFFSET_TYPE_H
-#define COMMON_OFFSET_TYPE_H
-
-/* Declare TYPE as being an offset type.  This declares the type and
-   enables the operators defined below.  */
-#define DEFINE_OFFSET_TYPE(TYPE, UNDERLYING)   \
-  enum class TYPE : UNDERLYING {};             \
-  void is_offset_type (TYPE)
-
-/* The macro macro is all you need to know use offset types.  The rest
-   below is all implementation detail.  */
-
-/* For each enum class type that you want to support arithmetic
-   operators, declare an "is_offset_type" overload that has exactly
-   one parameter, of type that enum class.  E.g.,:
-
-     void is_offset_type (sect_offset);
-
-   The function does not need to be defined, only declared.
-   DEFINE_OFFSET_TYPE declares this.
-
-   A function declaration is preferred over a traits type, because the
-   former allows calling the DEFINE_OFFSET_TYPE macro inside a
-   namespace to define the corresponding offset type in that
-   namespace.  The compiler finds the corresponding is_offset_type
-   function via ADL.
-*/
-
-/* Adding or subtracting an integer to an offset type shifts the
-   offset.  This is like "PTR = PTR + INT" and "PTR += INT".  */
-
-#define DEFINE_OFFSET_ARITHM_OP(OP)                                    \
-  template<typename E,                                                 \
-          typename = decltype (is_offset_type (std::declval<E> ()))>   \
-  constexpr E                                                          \
-  operator OP (E lhs, typename std::underlying_type<E>::type rhs)      \
-  {                                                                    \
-    using underlying = typename std::underlying_type<E>::type;         \
-    return (E) (static_cast<underlying> (lhs) OP rhs);                 \
-  }                                                                    \
-                                                                       \
-  template<typename E,                                                 \
-          typename = decltype (is_offset_type (std::declval<E> ()))>   \
-  constexpr E                                                          \
-  operator OP (typename std::underlying_type<E>::type lhs, E rhs)      \
-  {                                                                    \
-    using underlying = typename std::underlying_type<E>::type;         \
-    return (E) (lhs OP static_cast<underlying> (rhs));                 \
-  }                                                                    \
-                                                                       \
-  template<typename E,                                                 \
-          typename = decltype (is_offset_type (std::declval<E> ()))>   \
-  E &                                                                  \
-  operator OP ## = (E &lhs, typename std::underlying_type<E>::type rhs)        \
-  {                                                                    \
-    using underlying = typename std::underlying_type<E>::type;         \
-    lhs = (E) (static_cast<underlying> (lhs) OP rhs);                  \
-    return lhs;                                                                \
-  }
-
-DEFINE_OFFSET_ARITHM_OP(+)
-DEFINE_OFFSET_ARITHM_OP(-)
-
-/* Adding two offset types doesn't make sense, just like "PTR + PTR"
-   doesn't make sense.  This is defined as a deleted function so that
-   a compile error easily brings you to this comment.  */
-
-template<typename E,
-        typename = decltype (is_offset_type (std::declval<E> ()))>
-constexpr typename std::underlying_type<E>::type
-operator+ (E lhs, E rhs) = delete;
-
-/* Subtracting two offset types, however, gives you back the
-   difference between the offsets, as an underlying type.  Similar to
-   how "PTR2 - PTR1" returns a ptrdiff_t.  */
-
-template<typename E,
-        typename = decltype (is_offset_type (std::declval<E> ()))>
-constexpr typename std::underlying_type<E>::type
-operator- (E lhs, E rhs)
-{
-  using underlying = typename std::underlying_type<E>::type;
-  return static_cast<underlying> (lhs) - static_cast<underlying> (rhs);
-}
-
-#endif /* COMMON_OFFSET_TYPE_H */
diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c
deleted file mode 100644 (file)
index b295e73..0000000
+++ /dev/null
@@ -1,290 +0,0 @@
-/* Path manipulation routines for GDB and gdbserver.
-
-   Copyright (C) 1986-2019 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 "common-defs.h"
-#include "pathstuff.h"
-#include "host-defs.h"
-#include "filenames.h"
-#include "gdb_tilde_expand.h"
-
-#ifdef USE_WIN32API
-#include <windows.h>
-#endif
-
-/* See common/pathstuff.h.  */
-
-gdb::unique_xmalloc_ptr<char>
-gdb_realpath (const char *filename)
-{
-/* On most hosts, we rely on canonicalize_file_name to compute
-   the FILENAME's realpath.
-
-   But the situation is slightly more complex on Windows, due to some
-   versions of GCC which were reported to generate paths where
-   backlashes (the directory separator) were doubled.  For instance:
-      c:\\some\\double\\slashes\\dir
-   ... instead of ...
-      c:\some\double\slashes\dir
-   Those double-slashes were getting in the way when comparing paths,
-   for instance when trying to insert a breakpoint as follow:
-      (gdb) b c:/some/double/slashes/dir/foo.c:4
-      No source file named c:/some/double/slashes/dir/foo.c:4.
-      (gdb) b c:\some\double\slashes\dir\foo.c:4
-      No source file named c:\some\double\slashes\dir\foo.c:4.
-   To prevent this from happening, we need this function to always
-   strip those extra backslashes.  While canonicalize_file_name does
-   perform this simplification, it only works when the path is valid.
-   Since the simplification would be useful even if the path is not
-   valid (one can always set a breakpoint on a file, even if the file
-   does not exist locally), we rely instead on GetFullPathName to
-   perform the canonicalization.  */
-
-#if defined (_WIN32)
-  {
-    char buf[MAX_PATH];
-    DWORD len = GetFullPathName (filename, MAX_PATH, buf, NULL);
-
-    /* The file system is case-insensitive but case-preserving.
-       So it is important we do not lowercase the path.  Otherwise,
-       we might not be able to display the original casing in a given
-       path.  */
-    if (len > 0 && len < MAX_PATH)
-      return make_unique_xstrdup (buf);
-  }
-#else
-  {
-    char *rp = canonicalize_file_name (filename);
-
-    if (rp != NULL)
-      return gdb::unique_xmalloc_ptr<char> (rp);
-  }
-#endif
-
-  /* This system is a lost cause, just dup the buffer.  */
-  return make_unique_xstrdup (filename);
-}
-
-/* See common/pathstuff.h.  */
-
-gdb::unique_xmalloc_ptr<char>
-gdb_realpath_keepfile (const char *filename)
-{
-  const char *base_name = lbasename (filename);
-  char *dir_name;
-  char *result;
-
-  /* Extract the basename of filename, and return immediately
-     a copy of filename if it does not contain any directory prefix.  */
-  if (base_name == filename)
-    return make_unique_xstrdup (filename);
-
-  dir_name = (char *) alloca ((size_t) (base_name - filename + 2));
-  /* Allocate enough space to store the dir_name + plus one extra
-     character sometimes needed under Windows (see below), and
-     then the closing \000 character.  */
-  strncpy (dir_name, filename, base_name - filename);
-  dir_name[base_name - filename] = '\000';
-
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
-  /* We need to be careful when filename is of the form 'd:foo', which
-     is equivalent of d:./foo, which is totally different from d:/foo.  */
-  if (strlen (dir_name) == 2 && isalpha (dir_name[0]) && dir_name[1] == ':')
-    {
-      dir_name[2] = '.';
-      dir_name[3] = '\000';
-    }
-#endif
-
-  /* Canonicalize the directory prefix, and build the resulting
-     filename.  If the dirname realpath already contains an ending
-     directory separator, avoid doubling it.  */
-  gdb::unique_xmalloc_ptr<char> path_storage = gdb_realpath (dir_name);
-  const char *real_path = path_storage.get ();
-  if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1]))
-    result = concat (real_path, base_name, (char *) NULL);
-  else
-    result = concat (real_path, SLASH_STRING, base_name, (char *) NULL);
-
-  return gdb::unique_xmalloc_ptr<char> (result);
-}
-
-/* See common/pathstuff.h.  */
-
-gdb::unique_xmalloc_ptr<char>
-gdb_abspath (const char *path)
-{
-  gdb_assert (path != NULL && path[0] != '\0');
-
-  if (path[0] == '~')
-    return gdb_tilde_expand_up (path);
-
-  if (IS_ABSOLUTE_PATH (path))
-    return make_unique_xstrdup (path);
-
-  /* Beware the // my son, the Emacs barfs, the botch that catch...  */
-  return gdb::unique_xmalloc_ptr<char>
-    (concat (current_directory,
-            IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
-            ? "" : SLASH_STRING,
-            path, (char *) NULL));
-}
-
-/* See common/pathstuff.h.  */
-
-const char *
-child_path (const char *parent, const char *child)
-{
-  /* The child path must start with the parent path.  */
-  size_t parent_len = strlen (parent);
-  if (filename_ncmp (parent, child, parent_len) != 0)
-    return NULL;
-
-  /* The parent path must be a directory and the child must contain at
-     least one component underneath the parent.  */
-  const char *child_component;
-  if (parent_len > 0 && IS_DIR_SEPARATOR (parent[parent_len - 1]))
-    {
-      /* The parent path ends in a directory separator, so it is a
-        directory.  The first child component starts after the common
-        prefix.  */
-      child_component = child + parent_len;
-    }
-  else
-    {
-      /* The parent path does not end in a directory separator.  The
-        first character in the child after the common prefix must be
-        a directory separator.
-
-        Note that CHILD must hold at least parent_len characters for
-        filename_ncmp to return zero.  If the character at parent_len
-        is nul due to CHILD containing the same path as PARENT, the
-        IS_DIR_SEPARATOR check will fail here.  */
-      if (!IS_DIR_SEPARATOR (child[parent_len]))
-       return NULL;
-
-      /* The first child component starts after the separator after the
-        common prefix.  */
-      child_component = child + parent_len + 1;
-    }
-
-  /* The child must contain at least one non-separator character after
-     the parent.  */
-  while (*child_component != '\0')
-    {
-      if (!IS_DIR_SEPARATOR (*child_component))
-       return child_component;
-
-      child_component++;
-    }
-  return NULL;
-}
-
-/* See common/pathstuff.h.  */
-
-bool
-contains_dir_separator (const char *path)
-{
-  for (; *path != '\0'; path++)
-    {
-      if (IS_DIR_SEPARATOR (*path))
-       return true;
-    }
-
-  return false;
-}
-
-/* See common/pathstuff.h.  */
-
-std::string
-get_standard_cache_dir ()
-{
-#ifdef __APPLE__
-#define HOME_CACHE_DIR "Library/Caches"
-#else
-#define HOME_CACHE_DIR ".cache"
-#endif
-
-#ifndef __APPLE__
-  const char *xdg_cache_home = getenv ("XDG_CACHE_HOME");
-  if (xdg_cache_home != NULL)
-    {
-      /* Make sure the path is absolute and tilde-expanded.  */
-      gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (xdg_cache_home));
-      return string_printf ("%s/gdb", abs.get ());
-    }
-#endif
-
-  const char *home = getenv ("HOME");
-  if (home != NULL)
-    {
-      /* Make sure the path is absolute and tilde-expanded.  */
-      gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (home));
-      return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.get ());
-    }
-
-  return {};
-}
-
-/* See common/pathstuff.h.  */
-
-std::string
-get_standard_temp_dir ()
-{
-#ifdef WIN32
-  const char *tmp = getenv ("TMP");
-  if (tmp != nullptr)
-    return tmp;
-
-  tmp = getenv ("TEMP");
-  if (tmp != nullptr)
-    return tmp;
-
-  error (_("Couldn't find temp dir path, both TMP and TEMP are unset."));
-
-#else
-  const char *tmp = getenv ("TMPDIR");
-  if (tmp != nullptr)
-    return tmp;
-
-  return "/tmp";
-#endif
-}
-
-/* See common/pathstuff.h.  */
-
-const char *
-get_shell ()
-{
-  const char *ret = getenv ("SHELL");
-  if (ret == NULL)
-    ret = "/bin/sh";
-
-  return ret;
-}
-
-/* See common/pathstuff.h.  */
-
-gdb::char_vector
-make_temp_filename (const std::string &f)
-{
-  gdb::char_vector filename_temp (f.length () + 8);
-  strcpy (filename_temp.data (), f.c_str ());
-  strcat (filename_temp.data () + f.size (), "-XXXXXX");
-  return filename_temp;
-}
diff --git a/gdb/common/pathstuff.h b/gdb/common/pathstuff.h
deleted file mode 100644 (file)
index 67072a4..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Path manipulation routines for GDB and gdbserver.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_PATHSTUFF_H
-#define COMMON_PATHSTUFF_H
-
-#include "common/byte-vector.h"
-
-/* Path utilities.  */
-
-/* Return the real path of FILENAME, expanding all the symbolic links.
-
-   Contrary to "gdb_abspath", this function does not use
-   CURRENT_DIRECTORY for path expansion.  Instead, it relies on the
-   current working directory (CWD) of GDB or gdbserver.  */
-
-extern gdb::unique_xmalloc_ptr<char> gdb_realpath (const char *filename);
-
-/* Return a copy of FILENAME, with its directory prefix canonicalized
-   by gdb_realpath.  */
-
-extern gdb::unique_xmalloc_ptr<char>
-  gdb_realpath_keepfile (const char *filename);
-
-/* Return PATH in absolute form, performing tilde-expansion if necessary.
-   PATH cannot be NULL or the empty string.
-   This does not resolve symlinks however, use gdb_realpath for that.
-
-   Contrary to "gdb_realpath", this function uses CURRENT_DIRECTORY
-   for the path expansion.  This may lead to scenarios the current
-   working directory (CWD) is different than CURRENT_DIRECTORY.  */
-
-extern gdb::unique_xmalloc_ptr<char> gdb_abspath (const char *path);
-
-/* If the path in CHILD is a child of the path in PARENT, return a
-   pointer to the first component in the CHILD's pathname below the
-   PARENT.  Otherwise, return NULL.  */
-
-extern const char *child_path (const char *parent, const char *child);
-
-/* Return whether PATH contains a directory separator character.  */
-
-extern bool contains_dir_separator (const char *path);
-
-/* Get the usual user cache directory for the current platform.
-
-   On Linux, it follows the XDG Base Directory specification: use
-   $XDG_CACHE_HOME/gdb if the XDG_CACHE_HOME environment variable is
-   defined, otherwise $HOME/.cache.
-
-   On macOS, it follows the local convention and uses
-   ~/Library/Caches/gdb.
-
-  The return value is absolute and tilde-expanded.  Return an empty
-  string if neither XDG_CACHE_HOME (on Linux) or HOME are defined.  */
-
-extern std::string get_standard_cache_dir ();
-
-/* Get the usual temporary directory for the current platform.
-
-   On Windows, this is the TMP or TEMP environment variable.
-
-   On the rest, this is the TMPDIR environment variable, if defined, else /tmp.
-
-   Throw an exception on error.  */
-
-extern std::string get_standard_temp_dir ();
-
-/* Return the file name of the user's shell.  Normally this comes from
-   the SHELL environment variable.  */
-
-extern const char *get_shell ();
-
-/* Make a filename suitable to pass to mkstemp based on F (e.g.
-   /tmp/foo -> /tmp/foo-XXXXXX).  */
-
-extern gdb::char_vector make_temp_filename (const std::string &f);
-
-#endif /* COMMON_PATHSTUFF_H */
diff --git a/gdb/common/poison.h b/gdb/common/poison.h
deleted file mode 100644 (file)
index 699de51..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-/* Poison symbols at compile time.
-
-   Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_POISON_H
-#define COMMON_POISON_H
-
-#include "traits.h"
-#include "obstack.h"
-
-/* Poison memset of non-POD types.  The idea is catching invalid
-   initialization of non-POD structs that is easy to be introduced as
-   side effect of refactoring.  For example, say this:
-
- struct S { VEC(foo_s) *m_data; };
-
-is converted to this at some point:
-
- struct S {
-   S() { m_data.reserve (10); }
-   std::vector<foo> m_data;
- };
-
-and old code was initializing S objects like this:
-
- struct S s;
- memset (&s, 0, sizeof (S)); // whoops, now wipes vector.
-
-Declaring memset as deleted for non-POD types makes the memset above
-be a compile-time error.  */
-
-/* Helper for SFINAE.  True if "T *" is memsettable.  I.e., if T is
-   either void, or POD.  */
-template<typename T>
-struct IsMemsettable
-  : gdb::Or<std::is_void<T>,
-           std::is_pod<T>>
-{};
-
-template <typename T,
-         typename = gdb::Requires<gdb::Not<IsMemsettable<T>>>>
-void *memset (T *s, int c, size_t n) = delete;
-
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
-/* Similarly, poison memcpy and memmove of non trivially-copyable
-   types, which is undefined.  */
-
-/* True if "T *" is relocatable.  I.e., copyable with memcpy/memmove.
-   I.e., T is either trivially copyable, or void.  */
-template<typename T>
-struct IsRelocatable
-  : gdb::Or<std::is_void<T>,
-           std::is_trivially_copyable<T>>
-{};
-
-/* True if both source and destination are relocatable.  */
-
-template <typename D, typename S>
-using BothAreRelocatable
-  = gdb::And<IsRelocatable<D>, IsRelocatable<S>>;
-
-template <typename D, typename S,
-         typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
-void *memcpy (D *dest, const S *src, size_t n) = delete;
-
-template <typename D, typename S,
-         typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
-void *memmove (D *dest, const S *src, size_t n) = delete;
-
-#endif /* HAVE_IS_TRIVIALLY_COPYABLE */
-
-/* Poison XNEW and friends to catch usages of malloc-style allocations on
-   objects that require new/delete.  */
-
-template<typename T>
-#if HAVE_IS_TRIVIALLY_CONSTRUCTIBLE
-using IsMallocable = std::is_trivially_constructible<T>;
-#else
-using IsMallocable = std::true_type;
-#endif
-
-template<typename T>
-using IsFreeable = gdb::Or<std::is_trivially_destructible<T>, std::is_void<T>>;
-
-template <typename T, typename = gdb::Requires<gdb::Not<IsFreeable<T>>>>
-void free (T *ptr) = delete;
-
-template<typename T>
-static T *
-xnew ()
-{
-  static_assert (IsMallocable<T>::value, "Trying to use XNEW with a non-POD \
-data type.  Use operator new instead.");
-  return XNEW (T);
-}
-
-#undef XNEW
-#define XNEW(T) xnew<T>()
-
-template<typename T>
-static T *
-xcnew ()
-{
-  static_assert (IsMallocable<T>::value, "Trying to use XCNEW with a non-POD \
-data type.  Use operator new instead.");
-  return XCNEW (T);
-}
-
-#undef XCNEW
-#define XCNEW(T) xcnew<T>()
-
-template<typename T>
-static void
-xdelete (T *p)
-{
-  static_assert (IsFreeable<T>::value, "Trying to use XDELETE with a non-POD \
-data type.  Use operator delete instead.");
-  XDELETE (p);
-}
-
-#undef XDELETE
-#define XDELETE(P) xdelete (P)
-
-template<typename T>
-static T *
-xnewvec (size_t n)
-{
-  static_assert (IsMallocable<T>::value, "Trying to use XNEWVEC with a \
-non-POD data type.  Use operator new[] (or std::vector) instead.");
-  return XNEWVEC (T, n);
-}
-
-#undef XNEWVEC
-#define XNEWVEC(T, N) xnewvec<T> (N)
-
-template<typename T>
-static T *
-xcnewvec (size_t n)
-{
-  static_assert (IsMallocable<T>::value, "Trying to use XCNEWVEC with a \
-non-POD data type.  Use operator new[] (or std::vector) instead.");
-  return XCNEWVEC (T, n);
-}
-
-#undef XCNEWVEC
-#define XCNEWVEC(T, N) xcnewvec<T> (N)
-
-template<typename T>
-static T *
-xresizevec (T *p, size_t n)
-{
-  static_assert (IsMallocable<T>::value, "Trying to use XRESIZEVEC with a \
-non-POD data type.");
-  return XRESIZEVEC (T, p, n);
-}
-
-#undef XRESIZEVEC
-#define XRESIZEVEC(T, P, N) xresizevec<T> (P, N)
-
-template<typename T>
-static void
-xdeletevec (T *p)
-{
-  static_assert (IsFreeable<T>::value, "Trying to use XDELETEVEC with a \
-non-POD data type.  Use operator delete[] (or std::vector) instead.");
-  XDELETEVEC (p);
-}
-
-#undef XDELETEVEC
-#define XDELETEVEC(P) xdeletevec (P)
-
-template<typename T>
-static T *
-xnewvar (size_t s)
-{
-  static_assert (IsMallocable<T>::value, "Trying to use XNEWVAR with a \
-non-POD data type.");
-  return XNEWVAR (T, s);;
-}
-
-#undef XNEWVAR
-#define XNEWVAR(T, S) xnewvar<T> (S)
-
-template<typename T>
-static T *
-xcnewvar (size_t s)
-{
-  static_assert (IsMallocable<T>::value, "Trying to use XCNEWVAR with a \
-non-POD data type.");
-  return XCNEWVAR (T, s);
-}
-
-#undef XCNEWVAR
-#define XCNEWVAR(T, S) xcnewvar<T> (S)
-
-template<typename T>
-static T *
-xresizevar (T *p, size_t s)
-{
-  static_assert (IsMallocable<T>::value, "Trying to use XRESIZEVAR with a \
-non-POD data type.");
-  return XRESIZEVAR (T, p, s);
-}
-
-#undef XRESIZEVAR
-#define XRESIZEVAR(T, P, S) xresizevar<T> (P, S)
-
-template<typename T>
-static T *
-xobnew (obstack *ob)
-{
-  static_assert (IsMallocable<T>::value, "Trying to use XOBNEW with a \
-non-POD data type.");
-  return XOBNEW (ob, T);
-}
-
-#undef XOBNEW
-#define XOBNEW(O, T) xobnew<T> (O)
-
-template<typename T>
-static T *
-xobnewvec (obstack *ob, size_t n)
-{
-  static_assert (IsMallocable<T>::value, "Trying to use XOBNEWVEC with a \
-non-POD data type.");
-  return XOBNEWVEC (ob, T, n);
-}
-
-#undef XOBNEWVEC
-#define XOBNEWVEC(O, T, N) xobnewvec<T> (O, N)
-
-#endif /* COMMON_POISON_H */
diff --git a/gdb/common/posix-strerror.c b/gdb/common/posix-strerror.c
deleted file mode 100644 (file)
index a8651b7..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Safe version of strerror for POSIX systems for GDB, the GNU debugger.
-
-   Copyright (C) 2006-2019 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 "common-defs.h"
-
-/* Implementation of safe_strerror as defined in common-utils.h.  */
-
-char *
-safe_strerror (int errnum)
-{
-  char *msg;
-
-  msg = strerror (errnum);
-  if (msg == NULL)
-    {
-      static char buf[32];
-
-      xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum);
-      msg = buf;
-    }
-  return (msg);
-}
diff --git a/gdb/common/preprocessor.h b/gdb/common/preprocessor.h
deleted file mode 100644 (file)
index cb735c3..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_PREPROCESSOR_H
-#define COMMON_PREPROCESSOR_H
-
-/* Generally useful preprocessor bits.  */
-
-/* Concatenate two tokens.  */
-#define CONCAT_1(a, b) a ## b
-#define CONCAT(a, b) CONCAT_1 (a, b)
-
-/* Stringification.  */
-#define STRINGIFY_1(x) #x
-#define STRINGIFY(x) STRINGIFY_1 (x)
-
-/* Escape parens out.  Useful if you need to pass an argument that
-   includes commas to another macro.  */
-#define ESC_PARENS(...) __VA_ARGS__
-
-#endif /* COMMON_PREPROCESSOR_H */
diff --git a/gdb/common/print-utils.c b/gdb/common/print-utils.c
deleted file mode 100644 (file)
index 051c454..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-/* Cell-based print utility routines for GDB, the GNU debugger.
-
-   Copyright (C) 1986-2019 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 "common-defs.h"
-#include "print-utils.h"
-/* Temporary storage using circular buffer.  */
-
-/* Number of cells in the circular buffer.  */
-#define NUMCELLS 16
-
-/* Return the next entry in the circular buffer.  */
-
-char *
-get_print_cell (void)
-{
-  static char buf[NUMCELLS][PRINT_CELL_SIZE];
-  static int cell = 0;
-
-  if (++cell >= NUMCELLS)
-    cell = 0;
-  return buf[cell];
-}
-
-static char *
-decimal2str (const char *sign, ULONGEST addr, int width)
-{
-  /* Steal code from valprint.c:print_decimal().  Should this worry
-     about the real size of addr as the above does?  */
-  unsigned long temp[3];
-  char *str = get_print_cell ();
-  int i = 0;
-
-  do
-    {
-      temp[i] = addr % (1000 * 1000 * 1000);
-      addr /= (1000 * 1000 * 1000);
-      i++;
-      width -= 9;
-    }
-  while (addr != 0 && i < (sizeof (temp) / sizeof (temp[0])));
-
-  width += 9;
-  if (width < 0)
-    width = 0;
-
-  switch (i)
-    {
-    case 1:
-      xsnprintf (str, PRINT_CELL_SIZE, "%s%0*lu", sign, width, temp[0]);
-      break;
-    case 2:
-      xsnprintf (str, PRINT_CELL_SIZE, "%s%0*lu%09lu", sign, width,
-                temp[1], temp[0]);
-      break;
-    case 3:
-      xsnprintf (str, PRINT_CELL_SIZE, "%s%0*lu%09lu%09lu", sign, width,
-                temp[2], temp[1], temp[0]);
-      break;
-    default:
-      internal_error (__FILE__, __LINE__,
-                     _("failed internal consistency check"));
-    }
-
-  return str;
-}
-
-static char *
-octal2str (ULONGEST addr, int width)
-{
-  unsigned long temp[3];
-  char *str = get_print_cell ();
-  int i = 0;
-
-  do
-    {
-      temp[i] = addr % (0100000 * 0100000);
-      addr /= (0100000 * 0100000);
-      i++;
-      width -= 10;
-    }
-  while (addr != 0 && i < (sizeof (temp) / sizeof (temp[0])));
-
-  width += 10;
-  if (width < 0)
-    width = 0;
-
-  switch (i)
-    {
-    case 1:
-      if (temp[0] == 0)
-       xsnprintf (str, PRINT_CELL_SIZE, "%*o", width, 0);
-      else
-       xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo", width, temp[0]);
-      break;
-    case 2:
-      xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo%010lo", width, temp[1], temp[0]);
-      break;
-    case 3:
-      xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo%010lo%010lo", width,
-                temp[2], temp[1], temp[0]);
-      break;
-    default:
-      internal_error (__FILE__, __LINE__,
-                     _("failed internal consistency check"));
-    }
-
-  return str;
-}
-
-/* See print-utils.h.  */
-
-char *
-pulongest (ULONGEST u)
-{
-  return decimal2str ("", u, 0);
-}
-
-/* See print-utils.h.  */
-
-char *
-plongest (LONGEST l)
-{
-  if (l < 0)
-    return decimal2str ("-", -l, 0);
-  else
-    return decimal2str ("", l, 0);
-}
-
-/* Eliminate warning from compiler on 32-bit systems.  */
-static int thirty_two = 32;
-
-/* See print-utils.h.  */
-
-char *
-phex (ULONGEST l, int sizeof_l)
-{
-  char *str;
-
-  switch (sizeof_l)
-    {
-    case 8:
-      str = get_print_cell ();
-      xsnprintf (str, PRINT_CELL_SIZE, "%08lx%08lx",
-                (unsigned long) (l >> thirty_two),
-                (unsigned long) (l & 0xffffffff));
-      break;
-    case 4:
-      str = get_print_cell ();
-      xsnprintf (str, PRINT_CELL_SIZE, "%08lx", (unsigned long) l);
-      break;
-    case 2:
-      str = get_print_cell ();
-      xsnprintf (str, PRINT_CELL_SIZE, "%04x", (unsigned short) (l & 0xffff));
-      break;
-    default:
-      str = phex (l, sizeof (l));
-      break;
-    }
-
-  return str;
-}
-
-/* See print-utils.h.  */
-
-char *
-phex_nz (ULONGEST l, int sizeof_l)
-{
-  char *str;
-
-  switch (sizeof_l)
-    {
-    case 8:
-      {
-       unsigned long high = (unsigned long) (l >> thirty_two);
-
-       str = get_print_cell ();
-       if (high == 0)
-         xsnprintf (str, PRINT_CELL_SIZE, "%lx",
-                    (unsigned long) (l & 0xffffffff));
-       else
-         xsnprintf (str, PRINT_CELL_SIZE, "%lx%08lx", high,
-                    (unsigned long) (l & 0xffffffff));
-       break;
-      }
-    case 4:
-      str = get_print_cell ();
-      xsnprintf (str, PRINT_CELL_SIZE, "%lx", (unsigned long) l);
-      break;
-    case 2:
-      str = get_print_cell ();
-      xsnprintf (str, PRINT_CELL_SIZE, "%x", (unsigned short) (l & 0xffff));
-      break;
-    default:
-      str = phex_nz (l, sizeof (l));
-      break;
-    }
-
-  return str;
-}
-
-/* See print-utils.h.  */
-
-char *
-hex_string (LONGEST num)
-{
-  char *result = get_print_cell ();
-
-  xsnprintf (result, PRINT_CELL_SIZE, "0x%s", phex_nz (num, sizeof (num)));
-  return result;
-}
-
-/* See print-utils.h.  */
-
-char *
-hex_string_custom (LONGEST num, int width)
-{
-  char *result = get_print_cell ();
-  char *result_end = result + PRINT_CELL_SIZE - 1;
-  const char *hex = phex_nz (num, sizeof (num));
-  int hex_len = strlen (hex);
-
-  if (hex_len > width)
-    width = hex_len;
-  if (width + 2 >= PRINT_CELL_SIZE)
-    internal_error (__FILE__, __LINE__, _("\
-hex_string_custom: insufficient space to store result"));
-
-  strcpy (result_end - width - 2, "0x");
-  memset (result_end - width, '0', width);
-  strcpy (result_end - hex_len, hex);
-  return result_end - width - 2;
-}
-
-/* See print-utils.h.  */
-
-char *
-int_string (LONGEST val, int radix, int is_signed, int width,
-           int use_c_format)
-{
-  switch (radix)
-    {
-    case 16:
-      {
-       char *result;
-
-       if (width == 0)
-         result = hex_string (val);
-       else
-         result = hex_string_custom (val, width);
-       if (! use_c_format)
-         result += 2;
-       return result;
-      }
-    case 10:
-      {
-       if (is_signed && val < 0)
-         return decimal2str ("-", -val, width);
-       else
-         return decimal2str ("", val, width);
-      }
-    case 8:
-      {
-       char *result = octal2str (val, width);
-
-       if (use_c_format || val == 0)
-         return result;
-       else
-         return result + 1;
-      }
-    default:
-      internal_error (__FILE__, __LINE__,
-                     _("failed internal consistency check"));
-    }
-}
-
-/* See print-utils.h.  */
-
-const char *
-core_addr_to_string (const CORE_ADDR addr)
-{
-  char *str = get_print_cell ();
-
-  strcpy (str, "0x");
-  strcat (str, phex (addr, sizeof (addr)));
-  return str;
-}
-
-/* See print-utils.h.  */
-
-const char *
-core_addr_to_string_nz (const CORE_ADDR addr)
-{
-  char *str = get_print_cell ();
-
-  strcpy (str, "0x");
-  strcat (str, phex_nz (addr, sizeof (addr)));
-  return str;
-}
-
-/* See print-utils.h.  */
-
-const char *
-host_address_to_string_1 (const void *addr)
-{
-  char *str = get_print_cell ();
-
-  xsnprintf (str, PRINT_CELL_SIZE, "0x%s",
-            phex_nz ((uintptr_t) addr, sizeof (addr)));
-  return str;
-}
diff --git a/gdb/common/print-utils.h b/gdb/common/print-utils.h
deleted file mode 100644 (file)
index 815b14c..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Cell-based print utility routines for GDB, the GNU debugger.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_PRINT_UTILS_H
-#define COMMON_PRINT_UTILS_H
-
-/* How many characters (including the terminating null byte) fit in a
-   cell.  */
-#define PRINT_CELL_SIZE 50
-
-/* %d for LONGEST.  The result is stored in a circular static buffer,
-   NUMCELLS deep.  */
-
-extern char *pulongest (ULONGEST u);
-
-/* %u for ULONGEST.  The result is stored in a circular static buffer,
-   NUMCELLS deep.  */
-
-extern char *plongest (LONGEST l);
-
-extern char *phex (ULONGEST l, int sizeof_l);
-
-/* Convert a ULONGEST into a HEX string, like %lx.  The result is
-   stored in a circular static buffer, NUMCELLS deep.  */
-
-extern char *phex_nz (ULONGEST l, int sizeof_l);
-
-/* Converts a LONGEST to a C-format hexadecimal literal and stores it
-   in a static string.  Returns a pointer to this string.  */
-
-extern char *hex_string (LONGEST num);
-
-/* Converts a LONGEST number to a C-format hexadecimal literal and
-   stores it in a static string.  Returns a pointer to this string
-   that is valid until the next call.  The number is padded on the
-   left with 0s to at least WIDTH characters.  */
-
-extern char *hex_string_custom (LONGEST num, int width);
-
-/* Convert VAL to a numeral in the given radix.  For
- * radix 10, IS_SIGNED may be true, indicating a signed quantity;
- * otherwise VAL is interpreted as unsigned.  If WIDTH is supplied, 
- * it is the minimum width (0-padded if needed).  USE_C_FORMAT means
- * to use C format in all cases.  If it is false, then 'x' 
- * and 'o' formats do not include a prefix (0x or leading 0).  */
-
-extern char *int_string (LONGEST val, int radix, int is_signed, int width, 
-                        int use_c_format);     
-
-/* Convert a CORE_ADDR into a string.  */
-
-extern const char *core_addr_to_string (const CORE_ADDR addr);
-
-extern const char *core_addr_to_string_nz (const CORE_ADDR addr);
-
-extern const char *host_address_to_string_1 (const void *addr);
-
-/* Wrapper that avoids adding a pointless cast to all callers.  */
-#define host_address_to_string(ADDR) \
-  host_address_to_string_1 ((const void *) (ADDR))
-
-/* Return the next entry in the circular print buffer.  */
-
-extern char *get_print_cell (void);
-
-#endif /* COMMON_PRINT_UTILS_H */
diff --git a/gdb/common/ptid.c b/gdb/common/ptid.c
deleted file mode 100644 (file)
index c025511..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* The ptid_t type and common functions operating on it.
-
-   Copyright (C) 1986-2019 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 "common-defs.h"
-#include "ptid.h"
-
-/* See ptid.h for these.  */
-
-ptid_t const null_ptid = ptid_t::make_null ();
-ptid_t const minus_one_ptid = ptid_t::make_minus_one ();
diff --git a/gdb/common/ptid.h b/gdb/common/ptid.h
deleted file mode 100644 (file)
index f5625a6..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/* The ptid_t type and common functions operating on it.
-
-   Copyright (C) 1986-2019 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/>.  */
-
-#ifndef COMMON_PTID_H
-#define COMMON_PTID_H
-
-/* The ptid struct is a collection of the various "ids" necessary for
-   identifying the inferior process/thread being debugged.  This
-   consists of the process id (pid), lightweight process id (lwp) and
-   thread id (tid).  When manipulating ptids, the constructors,
-   accessors, and predicates declared in this file should be used.  Do
-   NOT access the struct ptid members directly.
-
-   process_stratum targets that handle threading themselves should
-   prefer using the ptid.lwp field, leaving the ptid.tid field for any
-   thread_stratum target that might want to sit on top.
-*/
-
-class ptid_t
-{
-public:
-  /* Must have a trivial defaulted default constructor so that the
-     type remains POD.  */
-  ptid_t () noexcept = default;
-
-  /* Make a ptid given the necessary PID, LWP, and TID components.
-
-     A ptid with only a PID (LWP and TID equal to zero) is usually used to
-     represent a whole process, including all its lwps/threads.  */
-
-  explicit constexpr ptid_t (int pid, long lwp = 0, long tid = 0)
-    : m_pid (pid), m_lwp (lwp), m_tid (tid)
-  {}
-
-  /* Fetch the pid (process id) component from the ptid.  */
-
-  constexpr int pid () const
-  { return m_pid; }
-
-  /* Return true if the ptid's lwp member is non-zero.  */
-
-  constexpr bool lwp_p () const
-  { return m_lwp != 0; }
-
-  /* Fetch the lwp (lightweight process) component from the ptid.  */
-
-  constexpr long lwp () const
-  { return m_lwp; }
-
-  /* Return true if the ptid's tid member is non-zero.  */
-
-  constexpr bool tid_p () const
-  { return m_tid != 0; }
-
-  /* Fetch the tid (thread id) component from a ptid.  */
-
-  constexpr long tid () const
-  { return m_tid; }
-
-  /* Return true if the ptid represents a whole process, including all its
-     lwps/threads.  Such ptids have the form of (pid, 0, 0), with
-     pid != -1.  */
-
-  constexpr bool is_pid () const
-  {
-    return (*this != make_null ()
-           && *this != make_minus_one ()
-           && m_lwp == 0
-           && m_tid == 0);
-  }
-
-  /* Compare two ptids to see if they are equal.  */
-
-  constexpr bool operator== (const ptid_t &other) const
-  {
-    return (m_pid == other.m_pid
-           && m_lwp == other.m_lwp
-           && m_tid == other.m_tid);
-  }
-
-  /* Compare two ptids to see if they are different.  */
-
-  constexpr bool operator!= (const ptid_t &other) const
-  {
-    return !(*this == other);
-  }
-
-  /* Return true if the ptid matches FILTER.  FILTER can be the wild
-     card MINUS_ONE_PTID (all ptids match it); can be a ptid representing
-     a process (ptid.is_pid () returns true), in which case, all lwps and
-     threads of that given process match, lwps and threads of other
-     processes do not; or, it can represent a specific thread, in which
-     case, only that thread will match true.  The ptid must represent a
-     specific LWP or THREAD, it can never be a wild card.  */
-
-  constexpr bool matches (const ptid_t &filter) const
-  {
-    return (/* If filter represents any ptid, it's always a match.  */
-           filter == make_minus_one ()
-           /* If filter is only a pid, any ptid with that pid
-              matches.  */
-           || (filter.is_pid () && m_pid == filter.pid ())
-
-           /* Otherwise, this ptid only matches if it's exactly equal
-              to filter.  */
-           || *this == filter);
-  }
-
-  /* Make a null ptid.  */
-
-  static constexpr ptid_t make_null ()
-  { return ptid_t (0, 0, 0); }
-
-  /* Make a minus one ptid.  */
-
-  static constexpr ptid_t make_minus_one ()
-  { return ptid_t (-1, 0, 0); }
-
-private:
-  /* Process id.  */
-  int m_pid;
-
-  /* Lightweight process id.  */
-  long m_lwp;
-
-  /* Thread id.  */
-  long m_tid;
-};
-
-/* The null or zero ptid, often used to indicate no process. */
-
-extern const ptid_t null_ptid;
-
-/* The (-1,0,0) ptid, often used to indicate either an error condition
-   or a "don't care" condition, i.e, "run all threads."  */
-
-extern const ptid_t minus_one_ptid;
-
-#endif /* COMMON_PTID_H */
diff --git a/gdb/common/refcounted-object.h b/gdb/common/refcounted-object.h
deleted file mode 100644 (file)
index 4bf7fcf..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Base class of intrusively reference-counted objects.
-   Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_REFCOUNTED_OBJECT_H
-#define COMMON_REFCOUNTED_OBJECT_H
-
-/* Base class of intrusively reference-countable objects.
-   Incrementing and decrementing the reference count is an external
-   responsibility.  */
-
-class refcounted_object
-{
-public:
-  refcounted_object () = default;
-
-  /* Increase the refcount.  */
-  void incref ()
-  {
-    gdb_assert (m_refcount >= 0);
-    m_refcount++;
-  }
-
-  /* Decrease the refcount.  */
-  void decref ()
-  {
-    m_refcount--;
-    gdb_assert (m_refcount >= 0);
-  }
-
-  int refcount () const { return m_refcount; }
-
-private:
-  DISABLE_COPY_AND_ASSIGN (refcounted_object);
-
-  /* The reference count.  */
-  int m_refcount = 0;
-};
-
-/* A policy class to interface gdb::ref_ptr with a
-   refcounted_object.  */
-
-struct refcounted_object_ref_policy
-{
-  static void incref (refcounted_object *ptr)
-  {
-    ptr->incref ();
-  }
-
-  static void decref (refcounted_object *ptr)
-  {
-    ptr->decref ();
-  }
-};
-
-#endif /* COMMON_REFCOUNTED_OBJECT_H */
diff --git a/gdb/common/rsp-low.c b/gdb/common/rsp-low.c
deleted file mode 100644 (file)
index 4bb4941..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-/* Low-level RSP routines for GDB, the GNU debugger.
-
-   Copyright (C) 1988-2019 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 "common-defs.h"
-#include "rsp-low.h"
-
-/* See rsp-low.h.  */
-
-int
-fromhex (int a)
-{
-  if (a >= '0' && a <= '9')
-    return a - '0';
-  else if (a >= 'a' && a <= 'f')
-    return a - 'a' + 10;
-  else if (a >= 'A' && a <= 'F')
-    return a - 'A' + 10;
-  else
-    error (_("Reply contains invalid hex digit %d"), a);
-}
-
-/* See rsp-low.h.  */
-
-int
-tohex (int nib)
-{
-  if (nib < 10)
-    return '0' + nib;
-  else
-    return 'a' + nib - 10;
-}
-
-/* Encode 64 bits in 16 chars of hex.  */
-
-static const char hexchars[] = "0123456789abcdef";
-
-static int
-ishex (int ch, int *val)
-{
-  if ((ch >= 'a') && (ch <= 'f'))
-    {
-      *val = ch - 'a' + 10;
-      return 1;
-    }
-  if ((ch >= 'A') && (ch <= 'F'))
-    {
-      *val = ch - 'A' + 10;
-      return 1;
-    }
-  if ((ch >= '0') && (ch <= '9'))
-    {
-      *val = ch - '0';
-      return 1;
-    }
-  return 0;
-}
-
-/* See rsp-low.h.  */
-
-char *
-pack_nibble (char *buf, int nibble)
-{
-  *buf++ = hexchars[(nibble & 0x0f)];
-  return buf;
-}
-
-/* See rsp-low.h.  */
-
-char *
-pack_hex_byte (char *pkt, int byte)
-{
-  *pkt++ = hexchars[(byte >> 4) & 0xf];
-  *pkt++ = hexchars[(byte & 0xf)];
-  return pkt;
-}
-
-/* See rsp-low.h.  */
-
-const char *
-unpack_varlen_hex (const char *buff,   /* packet to parse */
-                  ULONGEST *result)
-{
-  int nibble;
-  ULONGEST retval = 0;
-
-  while (ishex (*buff, &nibble))
-    {
-      buff++;
-      retval = retval << 4;
-      retval |= nibble & 0x0f;
-    }
-  *result = retval;
-  return buff;
-}
-
-/* See rsp-low.h.  */
-
-int
-hex2bin (const char *hex, gdb_byte *bin, int count)
-{
-  int i;
-
-  for (i = 0; i < count; i++)
-    {
-      if (hex[0] == 0 || hex[1] == 0)
-       {
-         /* Hex string is short, or of uneven length.
-            Return the count that has been converted so far.  */
-         return i;
-       }
-      *bin++ = fromhex (hex[0]) * 16 + fromhex (hex[1]);
-      hex += 2;
-    }
-  return i;
-}
-
-/* See rsp-low.h.  */
-
-gdb::byte_vector
-hex2bin (const char *hex)
-{
-  size_t bin_len = strlen (hex) / 2;
-  gdb::byte_vector bin (bin_len);
-
-  hex2bin (hex, bin.data (), bin_len);
-
-  return bin;
-}
-
-/* See rsp-low.h.  */
-
-std::string
-hex2str (const char *hex)
-{
-  return hex2str (hex, strlen (hex));
-}
-
-/* See rsp-low.h.  */
-
-std::string
-hex2str (const char *hex, int count)
-{
-  std::string ret;
-
-  ret.reserve (count);
-  for (size_t i = 0; i < count; ++i)
-    {
-      if (hex[0] == '\0' || hex[1] == '\0')
-       {
-         /* Hex string is short, or of uneven length.  Return what we
-            have so far.  */
-         return ret;
-       }
-      ret += fromhex (hex[0]) * 16 + fromhex (hex[1]);
-      hex += 2;
-    }
-
-  return ret;
-}
-
-/* See rsp-low.h.  */
-
-int
-bin2hex (const gdb_byte *bin, char *hex, int count)
-{
-  int i;
-
-  for (i = 0; i < count; i++)
-    {
-      *hex++ = tohex ((*bin >> 4) & 0xf);
-      *hex++ = tohex (*bin++ & 0xf);
-    }
-  *hex = 0;
-  return i;
-}
-
-/* See rsp-low.h.  */
-
-std::string
-bin2hex (const gdb_byte *bin, int count)
-{
-  std::string ret;
-
-  ret.reserve (count * 2);
-  for (int i = 0; i < count; ++i)
-    {
-      ret += tohex ((*bin >> 4) & 0xf);
-      ret += tohex (*bin++ & 0xf);
-    }
-
-  return ret;
-}
-
-/* Return whether byte B needs escaping when sent as part of binary data.  */
-
-static int
-needs_escaping (gdb_byte b)
-{
-  return b == '$' || b == '#' || b == '}' || b == '*';
-}
-
-/* See rsp-low.h.  */
-
-int
-remote_escape_output (const gdb_byte *buffer, int len_units, int unit_size,
-                     gdb_byte *out_buf, int *out_len_units,
-                     int out_maxlen_bytes)
-{
-  int input_unit_index, output_byte_index = 0, byte_index_in_unit;
-  int number_escape_bytes_needed;
-
-  /* Try to copy integral addressable memory units until
-     (1) we run out of space or
-     (2) we copied all of them.  */
-  for (input_unit_index = 0;
-       input_unit_index < len_units;
-       input_unit_index++)
-    {
-      /* Find out how many escape bytes we need for this unit.  */
-      number_escape_bytes_needed = 0;
-      for (byte_index_in_unit = 0;
-          byte_index_in_unit < unit_size;
-          byte_index_in_unit++)
-       {
-         int idx = input_unit_index * unit_size + byte_index_in_unit;
-         gdb_byte b = buffer[idx];
-         if (needs_escaping (b))
-           number_escape_bytes_needed++;
-       }
-
-      /* Check if we have room to fit this escaped unit.  */
-      if (output_byte_index + unit_size + number_escape_bytes_needed >
-           out_maxlen_bytes)
-         break;
-
-      /* Copy the unit byte per byte, adding escapes.  */
-      for (byte_index_in_unit = 0;
-          byte_index_in_unit < unit_size;
-          byte_index_in_unit++)
-       {
-         int idx = input_unit_index * unit_size + byte_index_in_unit;
-         gdb_byte b = buffer[idx];
-         if (needs_escaping (b))
-           {
-             out_buf[output_byte_index++] = '}';
-             out_buf[output_byte_index++] = b ^ 0x20;
-           }
-         else
-           out_buf[output_byte_index++] = b;
-       }
-    }
-
-  *out_len_units = input_unit_index;
-  return output_byte_index;
-}
-
-/* See rsp-low.h.  */
-
-int
-remote_unescape_input (const gdb_byte *buffer, int len,
-                      gdb_byte *out_buf, int out_maxlen)
-{
-  int input_index, output_index;
-  int escaped;
-
-  output_index = 0;
-  escaped = 0;
-  for (input_index = 0; input_index < len; input_index++)
-    {
-      gdb_byte b = buffer[input_index];
-
-      if (output_index + 1 > out_maxlen)
-       error (_("Received too much data from the target."));
-
-      if (escaped)
-       {
-         out_buf[output_index++] = b ^ 0x20;
-         escaped = 0;
-       }
-      else if (b == '}')
-       escaped = 1;
-      else
-       out_buf[output_index++] = b;
-    }
-
-  if (escaped)
-    error (_("Unmatched escape character in target response."));
-
-  return output_index;
-}
-
diff --git a/gdb/common/rsp-low.h b/gdb/common/rsp-low.h
deleted file mode 100644 (file)
index 979b326..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Low-level RSP routines for GDB, the GNU debugger.
-
-   Copyright (C) 1988-2019 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/>.  */
-
-#ifndef COMMON_RSP_LOW_H
-#define COMMON_RSP_LOW_H
-
-#include "common/byte-vector.h"
-
-/* Convert hex digit A to a number, or throw an exception.  */
-
-extern int fromhex (int a);
-
-/* Convert number NIB to a hex digit.  */
-
-extern int tohex (int nib);
-
-/* Write a character representing the low order four bits of NIBBLE in
-   hex to *BUF.  Returns BUF+1.  */
-
-extern char *pack_nibble (char *buf, int nibble);
-
-/* Write the low byte of BYTE in hex to *BUF.  Returns BUF+2.  */
-
-extern char *pack_hex_byte (char *pkt, int byte);
-
-/* Read hex digits from BUFF and convert to a number, which is stored
-   in RESULT.  Reads until a non-hex digit is seen.  Returns a pointer
-   to the terminating character.  */
-
-extern const char *unpack_varlen_hex (const char *buff, ULONGEST *result);
-
-/* HEX is a string of characters representing hexadecimal digits.
-   Convert pairs of hex digits to bytes and store sequentially into
-   BIN.  COUNT is the maximum number of characters to convert.  This
-   will convert fewer characters if the number of hex characters
-   actually seen is odd, or if HEX terminates before COUNT characters.
-   Returns the number of characters actually converted.  */
-
-extern int hex2bin (const char *hex, gdb_byte *bin, int count);
-
-/* Like the above, but return a gdb::byte_vector.  */
-
-gdb::byte_vector hex2bin (const char *hex);
-
-/* Like hex2bin, but return a std::string.  */
-
-extern std::string hex2str (const char *hex);
-
-/* Like hex2bin, but return a std::string.  */
-
-extern std::string hex2str (const char *hex, int count);
-
-/* Convert some bytes to a hexadecimal representation.  BIN holds the
-   bytes to convert.  COUNT says how many bytes to convert.  The
-   resulting characters are stored in HEX, followed by a NUL
-   character.  Returns the number of bytes actually converted.  */
-
-extern int bin2hex (const gdb_byte *bin, char *hex, int count);
-
-/* Overloaded version of bin2hex that returns a std::string.  */
-
-extern std::string bin2hex (const gdb_byte *bin, int count);
-
-/* Convert BUFFER, binary data at least LEN_UNITS addressable memory units
-   long, into escaped binary data in OUT_BUF.  Only copy memory units that fit
-   completely in OUT_BUF.  Set *OUT_LEN_UNITS to the number of units from
-   BUFFER successfully encoded in OUT_BUF, and return the number of bytes used
-   in OUT_BUF.  The total number of bytes in the output buffer will be at most
-   OUT_MAXLEN_BYTES.  This function properly escapes '*', and so is suitable
-   for the server side as well as the client.  */
-
-extern int remote_escape_output (const gdb_byte *buffer, int len_units,
-                                int unit_size, gdb_byte *out_buf,
-                                int *out_len_units, int out_maxlen_bytes);
-
-/* Convert BUFFER, escaped data LEN bytes long, into binary data
-   in OUT_BUF.  Return the number of bytes written to OUT_BUF.
-   Raise an error if the total number of bytes exceeds OUT_MAXLEN.
-
-   This function reverses remote_escape_output.  */
-
-extern int remote_unescape_input (const gdb_byte *buffer, int len,
-                                 gdb_byte *out_buf, int out_maxlen);
-
-#endif /* COMMON_RSP_LOW_H */
diff --git a/gdb/common/run-time-clock.c b/gdb/common/run-time-clock.c
deleted file mode 100644 (file)
index 26378a0..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* User/system CPU time clocks that follow the std::chrono interface.
-   Copyright (C) 2016-2019 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 "common-defs.h"
-#include "run-time-clock.h"
-#if defined HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
-
-using namespace std::chrono;
-
-run_time_clock::time_point
-run_time_clock::now () noexcept
-{
-  return time_point (microseconds (get_run_time ()));
-}
-
-#ifdef HAVE_GETRUSAGE
-static std::chrono::microseconds
-timeval_to_microseconds (struct timeval *tv)
-{
-  return (seconds (tv->tv_sec) + microseconds (tv->tv_usec));
-}
-#endif
-
-void
-run_time_clock::now (user_cpu_time_clock::time_point &user,
-                    system_cpu_time_clock::time_point &system) noexcept
-{
-#ifdef HAVE_GETRUSAGE
-  struct rusage rusage;
-
-  getrusage (RUSAGE_SELF, &rusage);
-
-  microseconds utime = timeval_to_microseconds (&rusage.ru_utime);
-  microseconds stime = timeval_to_microseconds (&rusage.ru_stime);
-  user = user_cpu_time_clock::time_point (utime);
-  system = system_cpu_time_clock::time_point (stime);
-#else
-  user = user_cpu_time_clock::time_point (microseconds (get_run_time ()));
-  system = system_cpu_time_clock::time_point (microseconds::zero ());
-#endif
-}
diff --git a/gdb/common/run-time-clock.h b/gdb/common/run-time-clock.h
deleted file mode 100644 (file)
index 9c15dd7..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* User/system CPU time clocks that follow the std::chrono interface.
-   Copyright (C) 2016-2019 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/>.  */
-
-#ifndef COMMON_RUN_TIME_CLOCK_H
-#define COMMON_RUN_TIME_CLOCK_H
-
-#include <chrono>
-
-/* Count the total amount of time spent executing in user mode.  */
-
-struct user_cpu_time_clock
-{
-  using duration = std::chrono::microseconds;
-  using rep = duration::rep;
-  using period = duration::period;
-  using time_point = std::chrono::time_point<user_cpu_time_clock>;
-
-  static constexpr bool is_steady = true;
-
-  /* Use run_time_clock::now instead.  */
-  static time_point now () noexcept = delete;
-};
-
-/* Count the total amount of time spent executing in kernel mode.  */
-
-struct system_cpu_time_clock
-{
-  using duration = std::chrono::microseconds;
-  using rep = duration::rep;
-  using period = duration::period;
-  using time_point = std::chrono::time_point<system_cpu_time_clock>;
-
-  static constexpr bool is_steady = true;
-
-  /* Use run_time_clock::now instead.  */
-  static time_point now () noexcept = delete;
-};
-
-/* Count the total amount of time spent executing in userspace+kernel
-   mode.  */
-
-struct run_time_clock
-{
-  using duration = std::chrono::microseconds;
-  using rep = duration::rep;
-  using period = duration::period;
-  using time_point = std::chrono::time_point<run_time_clock>;
-
-  static constexpr bool is_steady = true;
-
-  static time_point now () noexcept;
-
-  /* Return the user/system time as separate time points, if
-     supported.  If not supported, then the combined user+kernel time
-     is returned in USER and SYSTEM is set to zero.  */
-  static void now (user_cpu_time_clock::time_point &user,
-                  system_cpu_time_clock::time_point &system) noexcept;
-};
-
-#endif /* COMMON_RUN_TIME_CLOCK_H */
diff --git a/gdb/common/safe-iterator.h b/gdb/common/safe-iterator.h
deleted file mode 100644 (file)
index 89aec01..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/* A safe iterator for GDB, the GNU debugger.
-   Copyright (C) 2018-2019 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/>.  */
-
-#ifndef COMMON_SAFE_ITERATOR_H
-#define COMMON_SAFE_ITERATOR_H
-
-/* A forward iterator that wraps Iterator, such that when iterating
-   with iterator IT, it is possible to delete *IT without invalidating
-   IT.  Suitably wrapped in a range type and used with range-for, this
-   allow convenient patterns like this:
-
-     // range_safe() returns a range type whose begin()/end() methods
-     // return safe iterators.
-     for (foo *f : range_safe ())
-       {
-        if (f->should_delete ())
-          {
-            // The ++it operation implicitly done by the range-for is
-            // still OK after this.
-            delete f;
-          }
-       }
-*/
-
-template<typename Iterator>
-class basic_safe_iterator
-{
-public:
-  typedef basic_safe_iterator self_type;
-  typedef typename Iterator::value_type value_type;
-  typedef typename Iterator::reference reference;
-  typedef typename Iterator::pointer pointer;
-  typedef typename Iterator::iterator_category iterator_category;
-  typedef typename Iterator::difference_type difference_type;
-
-  /* Construct by forwarding all arguments to the underlying
-     iterator.  */
-  template<typename... Args>
-  explicit basic_safe_iterator (Args &&...args)
-    : m_it (std::forward<Args> (args)...),
-      m_next (m_it)
-  {
-    if (m_it != m_end)
-      ++m_next;
-  }
-
-  /* Create a one-past-end iterator.  */
-  basic_safe_iterator ()
-  {}
-
-  value_type operator* () const { return *m_it; }
-
-  self_type &operator++ ()
-  {
-    m_it = m_next;
-    if (m_it != m_end)
-      ++m_next;
-    return *this;
-  }
-
-  bool operator== (const self_type &other) const
-  { return m_it == other.m_it; }
-
-  bool operator!= (const self_type &other) const
-  { return m_it != other.m_it; }
-
-private:
-  /* The current element.  */
-  Iterator m_it {};
-
-  /* The next element.  Always one element ahead of M_IT.  */
-  Iterator m_next {};
-
-  /* A one-past-end iterator.  */
-  Iterator m_end {};
-};
-
-#endif /* COMMON_SAFE_ITERATOR_H */
diff --git a/gdb/common/scope-exit.h b/gdb/common/scope-exit.h
deleted file mode 100644 (file)
index 8cdbec3..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Copyright (C) 2019 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/>.  */
-
-#ifndef COMMON_SCOPE_EXIT_H
-#define COMMON_SCOPE_EXIT_H
-
-#include <functional>
-#include <type_traits>
-#include "common/preprocessor.h"
-
-/* scope_exit is a general-purpose scope guard that calls its exit
-   function at the end of the current scope.  A scope_exit may be
-   canceled by calling the "release" method.  The API is modeled on
-   P0052R5 - Generic Scope Guard and RAII Wrapper for the Standard
-   Library, which is itself based on Andrej Alexandrescu's
-   ScopeGuard/SCOPE_EXIT.
-
-   There are two forms available:
-
-   - The "make_scope_exit" form allows canceling the scope guard.  Use
-     it like this:
-
-     auto cleanup = make_scope_exit ( <function, function object, lambda> );
-     ...
-     cleanup.release (); // cancel
-
-   - If you don't need to cancel the guard, you can use the SCOPE_EXIT
-     macro, like this:
-
-     SCOPE_EXIT
-       {
-        // any code you like here.
-       }
-
-   See also forward_scope_exit.
-*/
-
-/* CRTP base class for cancelable scope_exit-like classes.  Implements
-   the common call-custom-function-from-dtor functionality.  Classes
-   that inherit this implement the on_exit() method, which is called
-   from scope_exit_base's dtor.  */
-
-template <typename CRTP>
-class scope_exit_base
-{
-public:
-  scope_exit_base () = default;
-
-  ~scope_exit_base ()
-  {
-    if (!m_released)
-      {
-       auto *self = static_cast<CRTP *> (this);
-       self->on_exit ();
-      }
-  }
-
-  /* This is needed for make_scope_exit because copy elision isn't
-     guaranteed until C++17.  An optimizing compiler will usually skip
-     calling this, but it must exist.  */
-  scope_exit_base (const scope_exit_base &other)
-    : m_released (other.m_released)
-  {
-    other.m_released = true;
-  }
-
-  void operator= (const scope_exit_base &) = delete;
-
-  /* If this is called, then the wrapped function will not be called
-     on destruction.  */
-  void release () noexcept
-  {
-    m_released = true;
-  }
-
-private:
-
-  /* True if released.  Mutable because of the copy ctor hack
-     above.  */
-  mutable bool m_released = false;
-};
-
-/* The scope_exit class.  */
-
-template<typename EF>
-class scope_exit : public scope_exit_base<scope_exit<EF>>
-{
-  /* For access to on_exit().  */
-  friend scope_exit_base<scope_exit<EF>>;
-
-public:
-
-  template<typename EFP,
-          typename = gdb::Requires<std::is_constructible<EF, EFP>>>
-  scope_exit (EFP &&f)
-    try : m_exit_function ((!std::is_lvalue_reference<EFP>::value
-                           && std::is_nothrow_constructible<EF, EFP>::value)
-                          ? std::move (f)
-                          : f)
-  {
-  }
-  catch (...)
-    {
-      /* "If the initialization of exit_function throws an exception,
-        calls f()."  */
-      f ();
-    }
-
-  template<typename EFP,
-          typename = gdb::Requires<std::is_constructible<EF, EFP>>>
-  scope_exit (scope_exit &&rhs)
-    noexcept (std::is_nothrow_move_constructible<EF>::value
-             || std::is_nothrow_copy_constructible<EF>::value)
-    : m_exit_function (std::is_nothrow_constructible<EFP>::value
-                      ? std::move (rhs)
-                      : rhs)
-  {
-    rhs.release ();
-  }
-
-  /* This is needed for make_scope_exit because copy elision isn't
-     guaranteed until C++17.  An optimizing compiler will usually skip
-     calling this, but it must exist.  */
-  scope_exit (const scope_exit &other)
-    : scope_exit_base<scope_exit<EF>> (other),
-      m_exit_function (other.m_exit_function)
-  {
-  }
-
-  void operator= (const scope_exit &) = delete;
-  void operator= (scope_exit &&) = delete;
-
-private:
-  void on_exit ()
-  {
-    m_exit_function ();
-  }
-
-  /* The function to call on scope exit.  */
-  EF m_exit_function;
-};
-
-template <typename EF>
-scope_exit<typename std::decay<EF>::type>
-make_scope_exit (EF &&f)
-{
-  return scope_exit<typename std::decay<EF>::type> (std::forward<EF> (f));
-}
-
-namespace detail
-{
-
-enum class scope_exit_lhs {};
-
-template<typename EF>
-scope_exit<typename std::decay<EF>::type>
-operator+ (scope_exit_lhs, EF &&rhs)
-{
-  return scope_exit<typename std::decay<EF>::type> (std::forward<EF> (rhs));
-}
-
-}
-
-/* Register a block of code to run on scope exit.  Note that the local
-   context is captured by reference, which means you should be careful
-   to avoid inadvertently changing a captured local's value before the
-   scope exit runs.  */
-
-#define SCOPE_EXIT \
-  auto CONCAT(scope_exit_, __LINE__) = ::detail::scope_exit_lhs () + [&] ()
-
-#endif /* COMMON_SCOPE_EXIT_H */
diff --git a/gdb/common/scoped_fd.h b/gdb/common/scoped_fd.h
deleted file mode 100644 (file)
index c4a494b..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* scoped_fd, automatically close a file descriptor
-
-   Copyright (C) 2018-2019 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/>.  */
-
-#ifndef COMMON_SCOPED_FD_H
-#define COMMON_SCOPED_FD_H
-
-#include <unistd.h>
-#include "filestuff.h"
-
-/* A smart-pointer-like class to automatically close a file descriptor.  */
-
-class scoped_fd
-{
-public:
-  explicit scoped_fd (int fd = -1) noexcept : m_fd (fd) {}
-
-  scoped_fd (scoped_fd &&other)
-    : m_fd (other.m_fd)
-  {
-    other.m_fd = -1;
-  }
-
-  ~scoped_fd ()
-  {
-    if (m_fd >= 0)
-      close (m_fd);
-  }
-
-  scoped_fd &operator= (scoped_fd &&other)
-  {
-    if (m_fd != other.m_fd)
-      {
-       if (m_fd >= 0)
-         close (m_fd);
-       m_fd = other.m_fd;
-       other.m_fd = -1;
-      }
-    return *this;
-  }
-
-  DISABLE_COPY_AND_ASSIGN (scoped_fd);
-
-  ATTRIBUTE_UNUSED_RESULT int release () noexcept
-  {
-    int fd = m_fd;
-    m_fd = -1;
-    return fd;
-  }
-
-  /* Like release, but return a gdb_file_up that owns the file
-     descriptor.  On success, this scoped_fd will be released.  On
-     failure, return NULL and leave this scoped_fd in possession of
-     the fd.  */
-  gdb_file_up to_file (const char *mode) noexcept
-  {
-    gdb_file_up result (fdopen (m_fd, mode));
-    if (result != nullptr)
-      m_fd = -1;
-    return result;
-  }
-
-  int get () const noexcept
-  {
-    return m_fd;
-  }
-
-private:
-  int m_fd;
-};
-
-#endif /* COMMON_SCOPED_FD_H */
diff --git a/gdb/common/scoped_mmap.c b/gdb/common/scoped_mmap.c
deleted file mode 100644 (file)
index 19175e4..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* scoped_mmap, automatically unmap files
-
-   Copyright (C) 2018-2019 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 "common-defs.h"
-#include "scoped_mmap.h"
-#include "scoped_fd.h"
-#include "common/filestuff.h"
-
-#ifdef HAVE_SYS_MMAN_H
-
-scoped_mmap
-mmap_file (const char *filename)
-{
-  scoped_fd fd (gdb_open_cloexec (filename, O_RDONLY, 0));
-  if (fd.get () < 0)
-    perror_with_name (("open"));
-
-  off_t size = lseek (fd.get (), 0, SEEK_END);
-  if (size < 0)
-    perror_with_name (("lseek"));
-
-  /* We can't map an empty file.  */
-  if (size == 0)
-    error (_("file to mmap is empty"));
-
-  scoped_mmap mmapped_file (nullptr, size, PROT_READ, MAP_PRIVATE, fd.get (), 0);
-  if (mmapped_file.get () == MAP_FAILED)
-    perror_with_name (("mmap"));
-
-  return mmapped_file;
-}
-
-#endif /* HAVE_SYS_MMAN_H */
diff --git a/gdb/common/scoped_mmap.h b/gdb/common/scoped_mmap.h
deleted file mode 100644 (file)
index 05cca9e..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* scoped_mmap, automatically unmap files
-
-   Copyright (C) 2018-2019 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/>.  */
-
-#ifndef COMMON_SCOPED_MMAP_H
-#define COMMON_SCOPED_MMAP_H
-
-#ifdef HAVE_SYS_MMAN_H
-
-#include <sys/mman.h>
-
-/* A smart-pointer-like class to mmap() and automatically munmap() a memory
-   mapping.  */
-
-class scoped_mmap
-{
-public:
-  scoped_mmap () noexcept : m_mem (MAP_FAILED), m_length (0) {}
-  scoped_mmap (void *addr, size_t length, int prot, int flags, int fd,
-              off_t offset) noexcept : m_length (length)
-  {
-    m_mem = mmap (addr, m_length, prot, flags, fd, offset);
-  }
-
-  ~scoped_mmap ()
-  {
-    destroy ();
-  }
-
-  scoped_mmap (scoped_mmap &&rhs)
-  {
-    destroy ();
-
-    m_mem = rhs.m_mem;
-    m_length = rhs.m_length;
-
-    rhs.m_mem = MAP_FAILED;
-    rhs.m_length = 0;
-  }
-
-  DISABLE_COPY_AND_ASSIGN (scoped_mmap);
-
-  ATTRIBUTE_UNUSED_RESULT void *release () noexcept
-  {
-    void *mem = m_mem;
-    m_mem = MAP_FAILED;
-    m_length = 0;
-    return mem;
-  }
-
-  void reset (void *addr, size_t length, int prot, int flags, int fd,
-             off_t offset) noexcept
-  {
-    destroy ();
-
-    m_length = length;
-    m_mem = mmap (addr, m_length, prot, flags, fd, offset);
-  }
-
-  size_t size () const noexcept { return m_length; }
-  void *get () const noexcept { return m_mem; }
-
-private:
-  void destroy ()
-  {
-    if (m_mem != MAP_FAILED)
-      munmap (m_mem, m_length);
-  }
-
-  void *m_mem;
-  size_t m_length;
-};
-
-/* Map FILENAME in memory.  Throw an error if anything goes wrong.  */
-scoped_mmap mmap_file (const char *filename);
-
-#endif /* HAVE_SYS_MMAN_H */
-
-#endif /* COMMON_SCOPED_MMAP_H */
diff --git a/gdb/common/scoped_restore.h b/gdb/common/scoped_restore.h
deleted file mode 100644 (file)
index 54c3ff5..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/* scoped_restore, a simple class for saving and restoring a value
-
-   Copyright (C) 2016-2019 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/>.  */
-
-#ifndef COMMON_SCOPED_RESTORE_H
-#define COMMON_SCOPED_RESTORE_H
-
-/* Base class for scoped_restore_tmpl.  */
-class scoped_restore_base
-{
-public:
-  /* This informs the (scoped_restore_tmpl<T>) dtor that you no longer
-     want the original value restored.  */
-  void release () const
-  { m_saved_var = NULL; }
-
-protected:
-  scoped_restore_base (void *saved_var)
-    : m_saved_var (saved_var)
-  {}
-
-  /* The type-erased saved variable.  This is here so that clients can
-     call release() on a "scoped_restore" local, which is a typedef to
-     a scoped_restore_base.  See below.  */
-  mutable void *m_saved_var;
-};
-
-/* A convenience typedef.  Users of make_scoped_restore declare the
-   local RAII object as having this type.  */
-typedef const scoped_restore_base &scoped_restore;
-
-/* An RAII-based object that saves a variable's value, and then
-   restores it again when this object is destroyed. */
-template<typename T>
-class scoped_restore_tmpl : public scoped_restore_base
-{
- public:
-
-  /* Create a new scoped_restore object that saves the current value
-     of *VAR.  *VAR will be restored when this scoped_restore object
-     is destroyed.  */
-  scoped_restore_tmpl (T *var)
-    : scoped_restore_base (var),
-      m_saved_value (*var)
-  {
-  }
-
-  /* Create a new scoped_restore object that saves the current value
-     of *VAR, and sets *VAR to VALUE.  *VAR will be restored when this
-     scoped_restore object is destroyed.  This is templated on T2 to
-     allow passing VALUEs of types convertible to T.
-     E.g.: T='base'; T2='derived'.  */
-  template <typename T2>
-  scoped_restore_tmpl (T *var, T2 value)
-    : scoped_restore_base (var),
-      m_saved_value (*var)
-  {
-    *var = value;
-  }
-
-  scoped_restore_tmpl (const scoped_restore_tmpl<T> &other)
-    : scoped_restore_base {other.m_saved_var},
-      m_saved_value (other.m_saved_value)
-  {
-    other.m_saved_var = NULL;
-  }
-
-  ~scoped_restore_tmpl ()
-  {
-    if (saved_var () != NULL)
-      *saved_var () = m_saved_value;
-  }
-
-private:
-  /* Return a pointer to the saved variable with its type
-     restored.  */
-  T *saved_var ()
-  { return static_cast<T *> (m_saved_var); }
-
-  /* No need for this.  It is intentionally not defined anywhere.  */
-  scoped_restore_tmpl &operator= (const scoped_restore_tmpl &);
-
-  /* The saved value.  */
-  const T m_saved_value;
-};
-
-/* Make a scoped_restore.  This is useful because it lets template
-   argument deduction work.  */
-template<typename T>
-scoped_restore_tmpl<T> make_scoped_restore (T *var)
-{
-  return scoped_restore_tmpl<T> (var);
-}
-
-/* Make a scoped_restore.  This is useful because it lets template
-   argument deduction work.  */
-template<typename T, typename T2>
-scoped_restore_tmpl<T> make_scoped_restore (T *var, T2 value)
-{
-  return scoped_restore_tmpl<T> (var, value);
-}
-
-#endif /* COMMON_SCOPED_RESTORE_H */
diff --git a/gdb/common/selftest.c b/gdb/common/selftest.c
deleted file mode 100644 (file)
index f5a7b3c..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/* GDB self-testing.
-   Copyright (C) 2016-2019 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 "common-defs.h"
-#include "common-exceptions.h"
-#include "common-debug.h"
-#include "selftest.h"
-#include <map>
-
-namespace selftests
-{
-/* All the tests that have been registered.  Using an std::map allows keeping
-   the order of tests stable and easily looking up whether a test name
-   exists.  */
-
-static std::map<std::string, std::unique_ptr<selftest>> tests;
-
-/* A selftest that calls the test function without arguments.  */
-
-struct simple_selftest : public selftest
-{
-  simple_selftest (self_test_function *function_)
-  : function (function_)
-  {}
-
-  void operator() () const override
-  {
-    function ();
-  }
-
-  self_test_function *function;
-};
-
-/* See selftest.h.  */
-
-void
-register_test (const std::string &name, selftest *test)
-{
-  /* Check that no test with this name already exist.  */
-  gdb_assert (tests.find (name) == tests.end ());
-
-  tests[name] = std::unique_ptr<selftest> (test);
-}
-
-/* See selftest.h.  */
-
-void
-register_test (const std::string &name, self_test_function *function)
-{
-  register_test (name, new simple_selftest (function));
-}
-
-/* See selftest.h.  */
-
-void
-run_tests (const char *filter)
-{
-  int ran = 0, failed = 0;
-
-  for (const auto &pair : tests)
-    {
-      const std::string &name = pair.first;
-      const std::unique_ptr<selftest> &test = pair.second;
-
-      if (filter != NULL && *filter != '\0'
-         && name.find (filter) == std::string::npos)
-       continue;
-
-      try
-       {
-         debug_printf (_("Running selftest %s.\n"), name.c_str ());
-         ++ran;
-         (*test) ();
-       }
-      catch (const gdb_exception_error &ex)
-       {
-         ++failed;
-         debug_printf ("Self test failed: %s\n", ex.what ());
-       }
-
-      reset ();
-    }
-
-  debug_printf (_("Ran %d unit tests, %d failed\n"),
-               ran, failed);
-}
-
-/* See selftest.h.  */
-
-void for_each_selftest (for_each_selftest_ftype func)
-{
-  for (const auto &pair : tests)
-    func (pair.first);
-}
-
-} // namespace selftests
diff --git a/gdb/common/selftest.h b/gdb/common/selftest.h
deleted file mode 100644 (file)
index c566ec5..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* GDB self-testing.
-   Copyright (C) 2016-2019 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/>.  */
-
-#ifndef COMMON_SELFTEST_H
-#define COMMON_SELFTEST_H
-
-/* A test is just a function that does some checks and throws an
-   exception if something has gone wrong.  */
-
-typedef void self_test_function (void);
-
-namespace selftests
-{
-
-/* Interface for the various kinds of selftests.  */
-
-struct selftest
-{
-  virtual ~selftest () = default;
-  virtual void operator() () const = 0;
-};
-
-/* Register a new self-test.  */
-
-extern void register_test (const std::string &name, selftest *test);
-
-/* Register a new self-test.  */
-
-extern void register_test (const std::string &name,
-                          self_test_function *function);
-
-/* Run all the self tests.  This print a message describing the number
-   of test and the number of failures.
-
-   If FILTER is not NULL and not empty, only tests with names containing FILTER
-   will be ran.  */
-
-extern void run_tests (const char *filter);
-
-/* Reset GDB or GDBserver's internal state.  */
-extern void reset ();
-
-typedef void for_each_selftest_ftype (const std::string &name);
-
-/* Call FUNC for each registered selftest.  */
-
-extern void for_each_selftest (for_each_selftest_ftype func);
-}
-
-/* Check that VALUE is true, and, if not, throw an exception.  */
-
-#define SELF_CHECK(VALUE)                                              \
-  do {                                                                 \
-    if (!(VALUE))                                                      \
-      error (_("self-test failed at %s:%d"), __FILE__, __LINE__);      \
-  } while (0)
-
-#endif /* COMMON_SELFTEST_H */
diff --git a/gdb/common/signals-state-save-restore.c b/gdb/common/signals-state-save-restore.c
deleted file mode 100644 (file)
index c66d2dd..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Copyright (C) 2016-2019 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 "common-defs.h"
-#include "signals-state-save-restore.h"
-
-#include <signal.h>
-
-/* The original signal actions and mask.  */
-
-#ifdef HAVE_SIGACTION
-static struct sigaction original_signal_actions[NSIG];
-
-/* Note that we use sigprocmask without worrying about threads because
-   the save/restore functions are called either from main, or after a
-   fork.  In both cases, we know the calling process is single
-   threaded.  */
-static sigset_t original_signal_mask;
-#endif
-
-/* See signals-state-save-restore.h.   */
-
-void
-save_original_signals_state (bool quiet)
-{
-#ifdef HAVE_SIGACTION
-  int i;
-  int res;
-
-  res = sigprocmask (0,  NULL, &original_signal_mask);
-  if (res == -1)
-    perror_with_name (("sigprocmask"));
-
-  bool found_preinstalled = false;
-
-  for (i = 1; i < NSIG; i++)
-    {
-      struct sigaction *oldact = &original_signal_actions[i];
-
-      res = sigaction (i, NULL, oldact);
-      if (res == -1 && errno == EINVAL)
-       {
-         /* Some signal numbers in the range are invalid.  */
-         continue;
-       }
-      else if (res == -1)
-       perror_with_name (("sigaction"));
-
-      /* If we find a custom signal handler already installed, then
-        this function was called too late.  This is a warning instead
-        of an internal error because this can also happen if you
-        LD_PRELOAD a library that installs a signal handler early via
-        __attribute__((constructor)), like libSegFault.so.  */
-      if (!quiet
-         && oldact->sa_handler != SIG_DFL
-         && oldact->sa_handler != SIG_IGN)
-       {
-         found_preinstalled = true;
-
-         /* Use raw fprintf here because we're being called in early
-            startup, before GDB's filtered streams are created.  */
-         fprintf (stderr,
-                  _("warning: Found custom handler for signal "
-                    "%d (%s) preinstalled.\n"), i,
-                  strsignal (i));
-       }
-    }
-
-  if (found_preinstalled)
-    {
-      fprintf (stderr, _("\
-Some signal dispositions inherited from the environment (SIG_DFL/SIG_IGN)\n\
-won't be propagated to spawned programs.\n"));
-    }
-#endif
-}
-
-/* See signals-state-save-restore.h.   */
-
-void
-restore_original_signals_state (void)
-{
-#ifdef HAVE_SIGACTION
-  int i;
-  int res;
-
-  for (i = 1; i < NSIG; i++)
-    {
-      res = sigaction (i, &original_signal_actions[i], NULL);
-      if (res == -1 && errno == EINVAL)
-       {
-         /* Some signal numbers in the range are invalid.  */
-         continue;
-       }
-      else if (res == -1)
-       perror_with_name (("sigaction"));
-    }
-
-  res = sigprocmask (SIG_SETMASK,  &original_signal_mask, NULL);
-  if (res == -1)
-    perror_with_name (("sigprocmask"));
-#endif
-}
diff --git a/gdb/common/signals-state-save-restore.h b/gdb/common/signals-state-save-restore.h
deleted file mode 100644 (file)
index de3d896..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Copyright (C) 2016-2019 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/>.  */
-
-#ifndef COMMON_SIGNALS_STATE_SAVE_RESTORE_H
-#define COMMON_SIGNALS_STATE_SAVE_RESTORE_H
-
-/* Save/restore the signal actions of all signals, and the signal
-   mask.
-
-   Since the exec family of functions does not reset the signal
-   disposition of signals set to SIG_IGN, nor does it reset the signal
-   mask, in order to be transparent, when spawning new child processes
-   to debug (with "run", etc.), we must reset signal actions and mask
-   back to what was originally inherited from gdb/gdbserver's parent,
-   just before execing the target program to debug.  */
-
-/* Save the signal state of all signals.  If !QUIET, warn if we detect
-   a custom signal handler preinstalled.  */
-
-extern void save_original_signals_state (bool quiet);
-
-/* Restore the signal state of all signals.  */
-
-extern void restore_original_signals_state (void);
-
-#endif /* COMMON_SIGNALS_STATE_SAVE_RESTORE_H */
diff --git a/gdb/common/signals.c b/gdb/common/signals.c
deleted file mode 100644 (file)
index 707bbe9..0000000
+++ /dev/null
@@ -1,653 +0,0 @@
-/* Target signal translation functions for GDB.
-   Copyright (C) 1990-2019 Free Software Foundation, Inc.
-   Contributed by Cygnus Support.
-
-   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 "common-defs.h"
-
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-
-#include "gdb_signals.h"
-
-struct gdbarch;
-
-/* Always use __SIGRTMIN if it's available.  SIGRTMIN is the lowest
-   _available_ realtime signal, not the lowest supported; glibc takes
-   several for its own use.  */
-
-#ifndef REALTIME_LO
-# if defined(__SIGRTMIN)
-#  define REALTIME_LO __SIGRTMIN
-#  define REALTIME_HI (__SIGRTMAX + 1)
-# elif defined(SIGRTMIN)
-#  define REALTIME_LO SIGRTMIN
-#  define REALTIME_HI (SIGRTMAX + 1)
-# endif
-#endif
-
-/* This table must match in order and size the signals in enum
-   gdb_signal.  */
-
-static const struct {
-  const char *symbol;
-  const char *name;
-  const char *string;
-  } signals [] =
-{
-#define SET(symbol, constant, name, string) { #symbol, name, string },
-#include "gdb/signals.def"
-#undef SET
-};
-
-const char *
-gdb_signal_to_symbol_string (enum gdb_signal sig)
-{
-  gdb_assert ((int) sig >= GDB_SIGNAL_FIRST && (int) sig <= GDB_SIGNAL_LAST);
-
-  return signals[sig].symbol;
-}
-
-/* Return the string for a signal.  */
-const char *
-gdb_signal_to_string (enum gdb_signal sig)
-{
-  if ((int) sig >= GDB_SIGNAL_FIRST && (int) sig <= GDB_SIGNAL_LAST)
-    return signals[sig].string;
-  else
-    return signals[GDB_SIGNAL_UNKNOWN].string;
-}
-
-/* Return the name for a signal.  */
-const char *
-gdb_signal_to_name (enum gdb_signal sig)
-{
-  if ((int) sig >= GDB_SIGNAL_FIRST && (int) sig <= GDB_SIGNAL_LAST
-      && signals[sig].name != NULL)
-    return signals[sig].name;
-  else
-    /* I think the code which prints this will always print it along
-       with the string, so no need to be verbose (very old comment).  */
-    return "?";
-}
-
-/* Given a name, return its signal.  */
-enum gdb_signal
-gdb_signal_from_name (const char *name)
-{
-  enum gdb_signal sig;
-
-  /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
-     for GDB_SIGNAL_SIGCHLD.  SIGIOT, on the other hand, is more
-     questionable; seems like by now people should call it SIGABRT
-     instead.  */
-
-  /* This ugly cast brought to you by the native VAX compiler.  */
-  for (sig = GDB_SIGNAL_HUP;
-       sig < GDB_SIGNAL_LAST;
-       sig = (enum gdb_signal) ((int) sig + 1))
-    if (signals[sig].name != NULL
-       && strcmp (name, signals[sig].name) == 0)
-      return sig;
-  return GDB_SIGNAL_UNKNOWN;
-}
-\f
-/* The following functions are to help certain targets deal
-   with the signal/waitstatus stuff.  They could just as well be in
-   a file called native-utils.c or unixwaitstatus-utils.c or whatever.  */
-
-/* Convert host signal to our signals.  */
-enum gdb_signal
-gdb_signal_from_host (int hostsig)
-{
-  /* A switch statement would make sense but would require special
-     kludges to deal with the cases where more than one signal has the
-     same number.  Signals are ordered ANSI-standard signals first,
-     other signals second, with signals in each block ordered by their
-     numerical values on a typical POSIX platform.  */
-
-  if (hostsig == 0)
-    return GDB_SIGNAL_0;
-
-  /* SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM
-     are ANSI-standard signals and are always available.  */
-  if (hostsig == SIGINT)
-    return GDB_SIGNAL_INT;
-  if (hostsig == SIGILL)
-    return GDB_SIGNAL_ILL;
-  if (hostsig == SIGABRT)
-    return GDB_SIGNAL_ABRT;
-  if (hostsig == SIGFPE)
-    return GDB_SIGNAL_FPE;
-  if (hostsig == SIGSEGV)
-    return GDB_SIGNAL_SEGV;
-  if (hostsig == SIGTERM)
-    return GDB_SIGNAL_TERM;
-
-  /* All other signals need preprocessor conditionals.  */
-#if defined (SIGHUP)
-  if (hostsig == SIGHUP)
-    return GDB_SIGNAL_HUP;
-#endif
-#if defined (SIGQUIT)
-  if (hostsig == SIGQUIT)
-    return GDB_SIGNAL_QUIT;
-#endif
-#if defined (SIGTRAP)
-  if (hostsig == SIGTRAP)
-    return GDB_SIGNAL_TRAP;
-#endif
-#if defined (SIGEMT)
-  if (hostsig == SIGEMT)
-    return GDB_SIGNAL_EMT;
-#endif
-#if defined (SIGKILL)
-  if (hostsig == SIGKILL)
-    return GDB_SIGNAL_KILL;
-#endif
-#if defined (SIGBUS)
-  if (hostsig == SIGBUS)
-    return GDB_SIGNAL_BUS;
-#endif
-#if defined (SIGSYS)
-  if (hostsig == SIGSYS)
-    return GDB_SIGNAL_SYS;
-#endif
-#if defined (SIGPIPE)
-  if (hostsig == SIGPIPE)
-    return GDB_SIGNAL_PIPE;
-#endif
-#if defined (SIGALRM)
-  if (hostsig == SIGALRM)
-    return GDB_SIGNAL_ALRM;
-#endif
-#if defined (SIGUSR1)
-  if (hostsig == SIGUSR1)
-    return GDB_SIGNAL_USR1;
-#endif
-#if defined (SIGUSR2)
-  if (hostsig == SIGUSR2)
-    return GDB_SIGNAL_USR2;
-#endif
-#if defined (SIGCLD)
-  if (hostsig == SIGCLD)
-    return GDB_SIGNAL_CHLD;
-#endif
-#if defined (SIGCHLD)
-  if (hostsig == SIGCHLD)
-    return GDB_SIGNAL_CHLD;
-#endif
-#if defined (SIGPWR)
-  if (hostsig == SIGPWR)
-    return GDB_SIGNAL_PWR;
-#endif
-#if defined (SIGWINCH)
-  if (hostsig == SIGWINCH)
-    return GDB_SIGNAL_WINCH;
-#endif
-#if defined (SIGURG)
-  if (hostsig == SIGURG)
-    return GDB_SIGNAL_URG;
-#endif
-#if defined (SIGIO)
-  if (hostsig == SIGIO)
-    return GDB_SIGNAL_IO;
-#endif
-#if defined (SIGPOLL)
-  if (hostsig == SIGPOLL)
-    return GDB_SIGNAL_POLL;
-#endif
-#if defined (SIGSTOP)
-  if (hostsig == SIGSTOP)
-    return GDB_SIGNAL_STOP;
-#endif
-#if defined (SIGTSTP)
-  if (hostsig == SIGTSTP)
-    return GDB_SIGNAL_TSTP;
-#endif
-#if defined (SIGCONT)
-  if (hostsig == SIGCONT)
-    return GDB_SIGNAL_CONT;
-#endif
-#if defined (SIGTTIN)
-  if (hostsig == SIGTTIN)
-    return GDB_SIGNAL_TTIN;
-#endif
-#if defined (SIGTTOU)
-  if (hostsig == SIGTTOU)
-    return GDB_SIGNAL_TTOU;
-#endif
-#if defined (SIGVTALRM)
-  if (hostsig == SIGVTALRM)
-    return GDB_SIGNAL_VTALRM;
-#endif
-#if defined (SIGPROF)
-  if (hostsig == SIGPROF)
-    return GDB_SIGNAL_PROF;
-#endif
-#if defined (SIGXCPU)
-  if (hostsig == SIGXCPU)
-    return GDB_SIGNAL_XCPU;
-#endif
-#if defined (SIGXFSZ)
-  if (hostsig == SIGXFSZ)
-    return GDB_SIGNAL_XFSZ;
-#endif
-#if defined (SIGWIND)
-  if (hostsig == SIGWIND)
-    return GDB_SIGNAL_WIND;
-#endif
-#if defined (SIGPHONE)
-  if (hostsig == SIGPHONE)
-    return GDB_SIGNAL_PHONE;
-#endif
-#if defined (SIGLOST)
-  if (hostsig == SIGLOST)
-    return GDB_SIGNAL_LOST;
-#endif
-#if defined (SIGWAITING)
-  if (hostsig == SIGWAITING)
-    return GDB_SIGNAL_WAITING;
-#endif
-#if defined (SIGCANCEL)
-  if (hostsig == SIGCANCEL)
-    return GDB_SIGNAL_CANCEL;
-#endif
-#if defined (SIGLWP)
-  if (hostsig == SIGLWP)
-    return GDB_SIGNAL_LWP;
-#endif
-#if defined (SIGDANGER)
-  if (hostsig == SIGDANGER)
-    return GDB_SIGNAL_DANGER;
-#endif
-#if defined (SIGGRANT)
-  if (hostsig == SIGGRANT)
-    return GDB_SIGNAL_GRANT;
-#endif
-#if defined (SIGRETRACT)
-  if (hostsig == SIGRETRACT)
-    return GDB_SIGNAL_RETRACT;
-#endif
-#if defined (SIGMSG)
-  if (hostsig == SIGMSG)
-    return GDB_SIGNAL_MSG;
-#endif
-#if defined (SIGSOUND)
-  if (hostsig == SIGSOUND)
-    return GDB_SIGNAL_SOUND;
-#endif
-#if defined (SIGSAK)
-  if (hostsig == SIGSAK)
-    return GDB_SIGNAL_SAK;
-#endif
-#if defined (SIGPRIO)
-  if (hostsig == SIGPRIO)
-    return GDB_SIGNAL_PRIO;
-#endif
-
-  /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
-#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_BAD_ACCESS)
-    return GDB_EXC_BAD_ACCESS;
-#endif
-#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
-    return GDB_EXC_BAD_INSTRUCTION;
-#endif
-#if defined (EXC_ARITHMETIC) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_ARITHMETIC)
-    return GDB_EXC_ARITHMETIC;
-#endif
-#if defined (EXC_EMULATION) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_EMULATION)
-    return GDB_EXC_EMULATION;
-#endif
-#if defined (EXC_SOFTWARE) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_SOFTWARE)
-    return GDB_EXC_SOFTWARE;
-#endif
-#if defined (EXC_BREAKPOINT) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_BREAKPOINT)
-    return GDB_EXC_BREAKPOINT;
-#endif
-
-#if defined (SIGINFO)
-  if (hostsig == SIGINFO)
-    return GDB_SIGNAL_INFO;
-#endif
-#if defined (SIGLIBRT)
-  if (hostsig == SIGLIBRT)
-    return GDB_SIGNAL_LIBRT;
-#endif
-
-#if defined (REALTIME_LO)
-  if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
-    {
-      /* This block of GDB_SIGNAL_REALTIME value is in order.  */
-      if (33 <= hostsig && hostsig <= 63)
-       return (enum gdb_signal)
-         (hostsig - 33 + (int) GDB_SIGNAL_REALTIME_33);
-      else if (hostsig == 32)
-       return GDB_SIGNAL_REALTIME_32;
-      else if (64 <= hostsig && hostsig <= 127)
-       return (enum gdb_signal)
-         (hostsig - 64 + (int) GDB_SIGNAL_REALTIME_64);
-      else
-       error (_("GDB bug: target.c (gdb_signal_from_host): "
-              "unrecognized real-time signal"));
-    }
-#endif
-
-  return GDB_SIGNAL_UNKNOWN;
-}
-
-/* Convert a OURSIG (an enum gdb_signal) to the form used by the
-   target operating system (refered to as the ``host'') or zero if the
-   equivalent host signal is not available.  Set/clear OURSIG_OK
-   accordingly. */
-
-static int
-do_gdb_signal_to_host (enum gdb_signal oursig,
-                         int *oursig_ok)
-{
-  int retsig;
-  /* Silence the 'not used' warning, for targets that
-     do not support signals.  */
-  (void) retsig;
-
-  /* Signals are ordered ANSI-standard signals first, other signals
-     second, with signals in each block ordered by their numerical
-     values on a typical POSIX platform.  */
-
-  *oursig_ok = 1;
-  switch (oursig)
-    {
-    case GDB_SIGNAL_0:
-      return 0;
-
-      /* SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM
-        are ANSI-standard signals and are always available.  */
-    case GDB_SIGNAL_INT:
-      return SIGINT;
-    case GDB_SIGNAL_ILL:
-      return SIGILL;
-    case GDB_SIGNAL_ABRT:
-      return SIGABRT;
-    case GDB_SIGNAL_FPE:
-      return SIGFPE;
-    case GDB_SIGNAL_SEGV:
-      return SIGSEGV;
-    case GDB_SIGNAL_TERM:
-      return SIGTERM;
-
-      /* All other signals need preprocessor conditionals.  */
-#if defined (SIGHUP)
-    case GDB_SIGNAL_HUP:
-      return SIGHUP;
-#endif
-#if defined (SIGQUIT)
-    case GDB_SIGNAL_QUIT:
-      return SIGQUIT;
-#endif
-#if defined (SIGTRAP)
-    case GDB_SIGNAL_TRAP:
-      return SIGTRAP;
-#endif
-#if defined (SIGEMT)
-    case GDB_SIGNAL_EMT:
-      return SIGEMT;
-#endif
-#if defined (SIGKILL)
-    case GDB_SIGNAL_KILL:
-      return SIGKILL;
-#endif
-#if defined (SIGBUS)
-    case GDB_SIGNAL_BUS:
-      return SIGBUS;
-#endif
-#if defined (SIGSYS)
-    case GDB_SIGNAL_SYS:
-      return SIGSYS;
-#endif
-#if defined (SIGPIPE)
-    case GDB_SIGNAL_PIPE:
-      return SIGPIPE;
-#endif
-#if defined (SIGALRM)
-    case GDB_SIGNAL_ALRM:
-      return SIGALRM;
-#endif
-#if defined (SIGUSR1)
-    case GDB_SIGNAL_USR1:
-      return SIGUSR1;
-#endif
-#if defined (SIGUSR2)
-    case GDB_SIGNAL_USR2:
-      return SIGUSR2;
-#endif
-#if defined (SIGCHLD) || defined (SIGCLD)
-    case GDB_SIGNAL_CHLD:
-#if defined (SIGCHLD)
-      return SIGCHLD;
-#else
-      return SIGCLD;
-#endif
-#endif /* SIGCLD or SIGCHLD */
-#if defined (SIGPWR)
-    case GDB_SIGNAL_PWR:
-      return SIGPWR;
-#endif
-#if defined (SIGWINCH)
-    case GDB_SIGNAL_WINCH:
-      return SIGWINCH;
-#endif
-#if defined (SIGURG)
-    case GDB_SIGNAL_URG:
-      return SIGURG;
-#endif
-#if defined (SIGIO)
-    case GDB_SIGNAL_IO:
-      return SIGIO;
-#endif
-#if defined (SIGPOLL)
-    case GDB_SIGNAL_POLL:
-      return SIGPOLL;
-#endif
-#if defined (SIGSTOP)
-    case GDB_SIGNAL_STOP:
-      return SIGSTOP;
-#endif
-#if defined (SIGTSTP)
-    case GDB_SIGNAL_TSTP:
-      return SIGTSTP;
-#endif
-#if defined (SIGCONT)
-    case GDB_SIGNAL_CONT:
-      return SIGCONT;
-#endif
-#if defined (SIGTTIN)
-    case GDB_SIGNAL_TTIN:
-      return SIGTTIN;
-#endif
-#if defined (SIGTTOU)
-    case GDB_SIGNAL_TTOU:
-      return SIGTTOU;
-#endif
-#if defined (SIGVTALRM)
-    case GDB_SIGNAL_VTALRM:
-      return SIGVTALRM;
-#endif
-#if defined (SIGPROF)
-    case GDB_SIGNAL_PROF:
-      return SIGPROF;
-#endif
-#if defined (SIGXCPU)
-    case GDB_SIGNAL_XCPU:
-      return SIGXCPU;
-#endif
-#if defined (SIGXFSZ)
-    case GDB_SIGNAL_XFSZ:
-      return SIGXFSZ;
-#endif
-#if defined (SIGWIND)
-    case GDB_SIGNAL_WIND:
-      return SIGWIND;
-#endif
-#if defined (SIGPHONE)
-    case GDB_SIGNAL_PHONE:
-      return SIGPHONE;
-#endif
-#if defined (SIGLOST)
-    case GDB_SIGNAL_LOST:
-      return SIGLOST;
-#endif
-#if defined (SIGWAITING)
-    case GDB_SIGNAL_WAITING:
-      return SIGWAITING;
-#endif
-#if defined (SIGCANCEL)
-    case GDB_SIGNAL_CANCEL:
-      return SIGCANCEL;
-#endif
-#if defined (SIGLWP)
-    case GDB_SIGNAL_LWP:
-      return SIGLWP;
-#endif
-#if defined (SIGDANGER)
-    case GDB_SIGNAL_DANGER:
-      return SIGDANGER;
-#endif
-#if defined (SIGGRANT)
-    case GDB_SIGNAL_GRANT:
-      return SIGGRANT;
-#endif
-#if defined (SIGRETRACT)
-    case GDB_SIGNAL_RETRACT:
-      return SIGRETRACT;
-#endif
-#if defined (SIGMSG)
-    case GDB_SIGNAL_MSG:
-      return SIGMSG;
-#endif
-#if defined (SIGSOUND)
-    case GDB_SIGNAL_SOUND:
-      return SIGSOUND;
-#endif
-#if defined (SIGSAK)
-    case GDB_SIGNAL_SAK:
-      return SIGSAK;
-#endif
-#if defined (SIGPRIO)
-    case GDB_SIGNAL_PRIO:
-      return SIGPRIO;
-#endif
-
-      /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
-#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
-    case GDB_EXC_BAD_ACCESS:
-      return _NSIG + EXC_BAD_ACCESS;
-#endif
-#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
-    case GDB_EXC_BAD_INSTRUCTION:
-      return _NSIG + EXC_BAD_INSTRUCTION;
-#endif
-#if defined (EXC_ARITHMETIC) && defined (_NSIG)
-    case GDB_EXC_ARITHMETIC:
-      return _NSIG + EXC_ARITHMETIC;
-#endif
-#if defined (EXC_EMULATION) && defined (_NSIG)
-    case GDB_EXC_EMULATION:
-      return _NSIG + EXC_EMULATION;
-#endif
-#if defined (EXC_SOFTWARE) && defined (_NSIG)
-    case GDB_EXC_SOFTWARE:
-      return _NSIG + EXC_SOFTWARE;
-#endif
-#if defined (EXC_BREAKPOINT) && defined (_NSIG)
-    case GDB_EXC_BREAKPOINT:
-      return _NSIG + EXC_BREAKPOINT;
-#endif
-
-#if defined (SIGINFO)
-    case GDB_SIGNAL_INFO:
-      return SIGINFO;
-#endif
-#if defined (SIGLIBRT)
-    case GDB_SIGNAL_LIBRT:
-      return SIGLIBRT;
-#endif
-
-    default:
-#if defined (REALTIME_LO)
-      retsig = 0;
-
-      if (oursig >= GDB_SIGNAL_REALTIME_33
-         && oursig <= GDB_SIGNAL_REALTIME_63)
-       {
-         /* This block of signals is continuous, and
-             GDB_SIGNAL_REALTIME_33 is 33 by definition.  */
-         retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_33 + 33;
-       }
-      else if (oursig == GDB_SIGNAL_REALTIME_32)
-       {
-         /* GDB_SIGNAL_REALTIME_32 isn't contiguous with
-             GDB_SIGNAL_REALTIME_33.  It is 32 by definition.  */
-         retsig = 32;
-       }
-      else if (oursig >= GDB_SIGNAL_REALTIME_64
-         && oursig <= GDB_SIGNAL_REALTIME_127)
-       {
-         /* This block of signals is continuous, and
-             GDB_SIGNAL_REALTIME_64 is 64 by definition.  */
-         retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_64 + 64;
-       }
-
-      if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
-       return retsig;
-#endif
-
-      *oursig_ok = 0;
-      return 0;
-    }
-}
-
-int
-gdb_signal_to_host_p (enum gdb_signal oursig)
-{
-  int oursig_ok;
-  do_gdb_signal_to_host (oursig, &oursig_ok);
-  return oursig_ok;
-}
-
-int
-gdb_signal_to_host (enum gdb_signal oursig)
-{
-  int oursig_ok;
-  int targ_signo = do_gdb_signal_to_host (oursig, &oursig_ok);
-  if (!oursig_ok)
-    {
-      /* The user might be trying to do "signal SIGSAK" where this system
-         doesn't have SIGSAK.  */
-      warning (_("Signal %s does not exist on this system."),
-              gdb_signal_to_name (oursig));
-      return 0;
-    }
-  else
-    return targ_signo;
-}
diff --git a/gdb/common/symbol.h b/gdb/common/symbol.h
deleted file mode 100644 (file)
index a42d50a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Declarations of common symbol functions.
-
-   Copyright (C) 2014-2019 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/>.  */
-
-#ifndef COMMON_SYMBOL_H
-#define COMMON_SYMBOL_H
-
-struct objfile;
-
-/* Find a symbol that matches NAME.  Limit the search to OBJFILE if
-   OBJFILE is non-NULL and the implementation supports limiting the
-   search to specific object files.  NAME may be mangled or demangled.
-   If a match is found, store the matching symbol's address in ADDR
-   and return zero.  Returns nonzero if no symbol matching NAME is
-   found.  Raise an exception if OBJFILE is non-NULL and the
-   implementation does not support limiting searches to specific
-   object files.  This function must be provided by the client.  */
-
-extern int find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
-                                       struct objfile *objfile);
-
-#endif /* COMMON_SYMBOL_H */
diff --git a/gdb/common/tdesc.c b/gdb/common/tdesc.c
deleted file mode 100644 (file)
index f946a53..0000000
+++ /dev/null
@@ -1,401 +0,0 @@
-/* Target description support for GDB.
-
-   Copyright (C) 2018-2019 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 "common-defs.h"
-#include "common/tdesc.h"
-
-tdesc_reg::tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
-                     int regnum, int save_restore_, const char *group_,
-                     int bitsize_, const char *type_)
-  : name (name_), target_regnum (regnum),
-    save_restore (save_restore_),
-    group (group_ != NULL ? group_ : ""),
-    bitsize (bitsize_),
-    type (type_ != NULL ? type_ : "<unknown>")
-{
-  /* If the register's type is target-defined, look it up now.  We may not
-     have easy access to the containing feature when we want it later.  */
-  tdesc_type = tdesc_named_type (feature, type.c_str ());
-}
-
-/* Predefined types.  */
-static tdesc_type_builtin tdesc_predefined_types[] =
-{
-  { "bool", TDESC_TYPE_BOOL },
-  { "int8", TDESC_TYPE_INT8 },
-  { "int16", TDESC_TYPE_INT16 },
-  { "int32", TDESC_TYPE_INT32 },
-  { "int64", TDESC_TYPE_INT64 },
-  { "int128", TDESC_TYPE_INT128 },
-  { "uint8", TDESC_TYPE_UINT8 },
-  { "uint16", TDESC_TYPE_UINT16 },
-  { "uint32", TDESC_TYPE_UINT32 },
-  { "uint64", TDESC_TYPE_UINT64 },
-  { "uint128", TDESC_TYPE_UINT128 },
-  { "code_ptr", TDESC_TYPE_CODE_PTR },
-  { "data_ptr", TDESC_TYPE_DATA_PTR },
-  { "ieee_half", TDESC_TYPE_IEEE_HALF },
-  { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
-  { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
-  { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
-  { "i387_ext", TDESC_TYPE_I387_EXT }
-};
-
-void tdesc_feature::accept (tdesc_element_visitor &v) const
-{
-  v.visit_pre (this);
-
-  for (const tdesc_type_up &type : types)
-    type->accept (v);
-
-  for (const tdesc_reg_up &reg : registers)
-    reg->accept (v);
-
-  v.visit_post (this);
-}
-
-bool tdesc_feature::operator== (const tdesc_feature &other) const
-{
-  if (name != other.name)
-    return false;
-
-  if (registers.size () != other.registers.size ())
-    return false;
-
-  for (int ix = 0; ix < registers.size (); ix++)
-    {
-      const tdesc_reg_up &reg1 = registers[ix];
-      const tdesc_reg_up &reg2 = other.registers[ix];
-
-      if (reg1 != reg2 && *reg1 != *reg2)
-       return false;
-      }
-
-  if (types.size () != other.types.size ())
-    return false;
-
-  for (int ix = 0; ix < types.size (); ix++)
-    {
-      const tdesc_type_up &type1 = types[ix];
-      const tdesc_type_up &type2 = other.types[ix];
-
-      if (type1 != type2 && *type1 != *type2)
-       return false;
-    }
-
-  return true;
-}
-
-/* Lookup a predefined type.  */
-
-static struct tdesc_type *
-tdesc_predefined_type (enum tdesc_type_kind kind)
-{
-  for (int ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
-    if (tdesc_predefined_types[ix].kind == kind)
-      return &tdesc_predefined_types[ix];
-
-  gdb_assert_not_reached ("bad predefined tdesc type");
-}
-
-/* See common/tdesc.h.  */
-
-struct tdesc_type *
-tdesc_named_type (const struct tdesc_feature *feature, const char *id)
-{
-  /* First try target-defined types.  */
-  for (const tdesc_type_up &type : feature->types)
-    if (type->name == id)
-      return type.get ();
-
-  /* Next try the predefined types.  */
-  for (int ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
-    if (tdesc_predefined_types[ix].name == id)
-      return &tdesc_predefined_types[ix];
-
-  return NULL;
-}
-
-/* See common/tdesc.h.  */
-
-void
-tdesc_create_reg (struct tdesc_feature *feature, const char *name,
-                 int regnum, int save_restore, const char *group,
-                 int bitsize, const char *type)
-{
-  tdesc_reg *reg = new tdesc_reg (feature, name, regnum, save_restore,
-                                 group, bitsize, type);
-
-  feature->registers.emplace_back (reg);
-}
-
-/* See common/tdesc.h.  */
-
-struct tdesc_type *
-tdesc_create_vector (struct tdesc_feature *feature, const char *name,
-                    struct tdesc_type *field_type, int count)
-{
-  tdesc_type_vector *type = new tdesc_type_vector (name, field_type, count);
-  feature->types.emplace_back (type);
-
-  return type;
-}
-
-/* See common/tdesc.h.  */
-
-tdesc_type_with_fields *
-tdesc_create_struct (struct tdesc_feature *feature, const char *name)
-{
-  tdesc_type_with_fields *type
-    = new tdesc_type_with_fields (name, TDESC_TYPE_STRUCT);
-  feature->types.emplace_back (type);
-
-  return type;
-}
-
-/* See common/tdesc.h.  */
-
-void
-tdesc_set_struct_size (tdesc_type_with_fields *type, int size)
-{
-  gdb_assert (type->kind == TDESC_TYPE_STRUCT);
-  gdb_assert (size > 0);
-  type->size = size;
-}
-
-/* See common/tdesc.h.  */
-
-tdesc_type_with_fields *
-tdesc_create_union (struct tdesc_feature *feature, const char *name)
-{
-  tdesc_type_with_fields *type
-    = new tdesc_type_with_fields (name, TDESC_TYPE_UNION);
-  feature->types.emplace_back (type);
-
-  return type;
-}
-
-/* See common/tdesc.h.  */
-
-tdesc_type_with_fields *
-tdesc_create_flags (struct tdesc_feature *feature, const char *name,
-                   int size)
-{
-  gdb_assert (size > 0);
-
-  tdesc_type_with_fields *type
-    = new tdesc_type_with_fields (name, TDESC_TYPE_FLAGS, size);
-  feature->types.emplace_back (type);
-
-  return type;
-}
-
-/* See common/tdesc.h.  */
-
-tdesc_type_with_fields *
-tdesc_create_enum (struct tdesc_feature *feature, const char *name,
-                  int size)
-{
-  gdb_assert (size > 0);
-
-  tdesc_type_with_fields *type
-    = new tdesc_type_with_fields (name, TDESC_TYPE_ENUM, size);
-  feature->types.emplace_back (type);
-
-  return type;
-}
-
-/* See common/tdesc.h.  */
-
-void
-tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
-                struct tdesc_type *field_type)
-{
-  gdb_assert (type->kind == TDESC_TYPE_UNION
-             || type->kind == TDESC_TYPE_STRUCT);
-
-  /* Initialize start and end so we know this is not a bit-field
-     when we print-c-tdesc.  */
-  type->fields.emplace_back (field_name, field_type, -1, -1);
-}
-
-/* See common/tdesc.h.  */
-
-void
-tdesc_add_typed_bitfield (tdesc_type_with_fields *type, const char *field_name,
-                         int start, int end, struct tdesc_type *field_type)
-{
-  gdb_assert (type->kind == TDESC_TYPE_STRUCT
-             || type->kind == TDESC_TYPE_FLAGS);
-  gdb_assert (start >= 0 && end >= start);
-
-  type->fields.emplace_back (field_name, field_type, start, end);
-}
-
-/* See common/tdesc.h.  */
-
-void
-tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
-                   int start, int end)
-{
-  struct tdesc_type *field_type;
-
-  gdb_assert (start >= 0 && end >= start);
-
-  if (type->size > 4)
-    field_type = tdesc_predefined_type (TDESC_TYPE_UINT64);
-  else
-    field_type = tdesc_predefined_type (TDESC_TYPE_UINT32);
-
-  tdesc_add_typed_bitfield (type, field_name, start, end, field_type);
-}
-
-/* See common/tdesc.h.  */
-
-void
-tdesc_add_flag (tdesc_type_with_fields *type, int start,
-               const char *flag_name)
-{
-  gdb_assert (type->kind == TDESC_TYPE_FLAGS
-             || type->kind == TDESC_TYPE_STRUCT);
-
-  type->fields.emplace_back (flag_name,
-                            tdesc_predefined_type (TDESC_TYPE_BOOL),
-                            start, start);
-}
-
-/* See common/tdesc.h.  */
-
-void
-tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
-                     const char *name)
-{
-  gdb_assert (type->kind == TDESC_TYPE_ENUM);
-  type->fields.emplace_back (name,
-                            tdesc_predefined_type (TDESC_TYPE_INT32),
-                            value, -1);
-}
-
-void print_xml_feature::visit_pre (const tdesc_feature *e)
-{
-  string_appendf (*m_buffer, "<feature name=\"%s\">\n", e->name.c_str ());
-}
-
-void print_xml_feature::visit_post (const tdesc_feature *e)
-{
-  string_appendf (*m_buffer, "</feature>\n");
-}
-
-void print_xml_feature::visit (const tdesc_type_builtin *t)
-{
-  error (_("xml output is not supported for type \"%s\"."), t->name.c_str ());
-}
-
-void print_xml_feature::visit (const tdesc_type_vector *t)
-{
-  string_appendf (*m_buffer, "<vector id=\"%s\" type=\"%s\" count=\"%d\"/>\n",
-                 t->name.c_str (), t->element_type->name.c_str (), t->count);
-}
-
-void print_xml_feature::visit (const tdesc_type_with_fields *t)
-{
-  const static char *types[] = { "struct", "union", "flags", "enum" };
-
-  gdb_assert (t->kind >= TDESC_TYPE_STRUCT && t->kind <= TDESC_TYPE_ENUM);
-
-  string_appendf (*m_buffer,
-                 "<%s id=\"%s\"", types[t->kind - TDESC_TYPE_STRUCT],
-                 t->name.c_str ());
-
-  switch (t->kind)
-    {
-    case TDESC_TYPE_STRUCT:
-    case TDESC_TYPE_FLAGS:
-      if (t->size > 0)
-       string_appendf (*m_buffer, " size=\"%d\"", t->size);
-      string_appendf (*m_buffer, ">\n");
-
-      for (const tdesc_type_field &f : t->fields)
-       {
-         string_appendf (*m_buffer, "  <field name=\"%s\" ", f.name.c_str ());
-         if (f.start == -1)
-           string_appendf (*m_buffer, "type=\"%s\"/>\n",
-                           f.type->name.c_str ());
-         else
-           string_appendf (*m_buffer, "start=\"%d\" end=\"%d\"/>\n", f.start,
-                           f.end);
-       }
-      break;
-
-    case TDESC_TYPE_ENUM:
-      string_appendf (*m_buffer, ">\n");
-      for (const tdesc_type_field &f : t->fields)
-       string_appendf (*m_buffer, "  <field name=\"%s\" start=\"%d\"/>\n",
-                       f.name.c_str (), f.start);
-      break;
-
-    case TDESC_TYPE_UNION:
-      string_appendf (*m_buffer, ">\n");
-      for (const tdesc_type_field &f : t->fields)
-       string_appendf (*m_buffer, "  <field name=\"%s\" type=\"%s\"/>\n",
-                       f.name.c_str (), f.type->name.c_str ());
-      break;
-
-    default:
-      error (_("xml output is not supported for type \"%s\"."),
-            t->name.c_str ());
-    }
-
-  string_appendf (*m_buffer, "</%s>\n", types[t->kind - TDESC_TYPE_STRUCT]);
-}
-
-void print_xml_feature::visit (const tdesc_reg *r)
-{
-  string_appendf (*m_buffer,
-                 "<reg name=\"%s\" bitsize=\"%d\" type=\"%s\" regnum=\"%ld\"",
-                 r->name.c_str (), r->bitsize, r->type.c_str (),
-                 r->target_regnum);
-
-  if (r->group.length () > 0)
-    string_appendf (*m_buffer, " group=\"%s\"", r->group.c_str ());
-
-  if (r->save_restore == 0)
-    string_appendf (*m_buffer, " save-restore=\"no\"");
-
-  string_appendf (*m_buffer, "/>\n");
-}
-
-void print_xml_feature::visit_pre (const target_desc *e)
-{
-#ifndef IN_PROCESS_AGENT
-  string_appendf (*m_buffer, "<?xml version=\"1.0\"?>\n");
-  string_appendf (*m_buffer, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">\n");
-  string_appendf (*m_buffer, "<target>\n<architecture>%s</architecture>\n",
-                 tdesc_architecture_name (e));
-
-  const char *osabi = tdesc_osabi_name (e);
-  if (osabi != nullptr)
-    string_appendf (*m_buffer, "<osabi>%s</osabi>", osabi);
-#endif
-}
-
-void print_xml_feature::visit_post (const target_desc *e)
-{
-  string_appendf (*m_buffer, "</target>\n");
-}
diff --git a/gdb/common/tdesc.h b/gdb/common/tdesc.h
deleted file mode 100644 (file)
index 9eb3d5e..0000000
+++ /dev/null
@@ -1,408 +0,0 @@
-/* Copyright (C) 2006-2019 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/>.  */
-
-#ifndef COMMON_TDESC_H
-#define COMMON_TDESC_H
-
-struct tdesc_feature;
-struct tdesc_type;
-struct tdesc_type_builtin;
-struct tdesc_type_vector;
-struct tdesc_type_with_fields;
-struct tdesc_reg;
-struct target_desc;
-
-/* The interface to visit different elements of target description.  */
-
-class tdesc_element_visitor
-{
-public:
-  virtual void visit_pre (const target_desc *e)
-  {}
-
-  virtual void visit_post (const target_desc *e)
-  {}
-
-  virtual void visit_pre (const tdesc_feature *e)
-  {}
-
-  virtual void visit_post (const tdesc_feature *e)
-  {}
-
-  virtual void visit (const tdesc_type_builtin *e)
-  {}
-
-  virtual void visit (const tdesc_type_vector *e)
-  {}
-
-  virtual void visit (const tdesc_type_with_fields *e)
-  {}
-
-  virtual void visit (const tdesc_reg *e)
-  {}
-};
-
-class tdesc_element
-{
-public:
-  virtual void accept (tdesc_element_visitor &v) const = 0;
-};
-
-/* An individual register from a target description.  */
-
-struct tdesc_reg : tdesc_element
-{
-  tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
-            int regnum, int save_restore_, const char *group_,
-            int bitsize_, const char *type_);
-
-  virtual ~tdesc_reg () = default;
-
-  DISABLE_COPY_AND_ASSIGN (tdesc_reg);
-
-  /* The name of this register.  In standard features, it may be
-     recognized by the architecture support code, or it may be purely
-     for the user.  */
-  std::string name;
-
-  /* The register number used by this target to refer to this
-     register.  This is used for remote p/P packets and to determine
-     the ordering of registers in the remote g/G packets.  */
-  long target_regnum;
-
-  /* If this flag is set, GDB should save and restore this register
-     around calls to an inferior function.  */
-  int save_restore;
-
-  /* The name of the register group containing this register, or empty
-     if the group should be automatically determined from the
-     register's type.  If this is "general", "float", or "vector", the
-     corresponding "info" command should display this register's
-     value.  It can be an arbitrary string, but should be limited to
-     alphanumeric characters and internal hyphens.  Currently other
-     strings are ignored (treated as empty).  */
-  std::string group;
-
-  /* The size of the register, in bits.  */
-  int bitsize;
-
-  /* The type of the register.  This string corresponds to either
-     a named type from the target description or a predefined
-     type from GDB.  */
-  std::string type;
-
-  /* The target-described type corresponding to TYPE, if found.  */
-  struct tdesc_type *tdesc_type;
-
-  void accept (tdesc_element_visitor &v) const override
-  {
-    v.visit (this);
-  }
-
-  bool operator== (const tdesc_reg &other) const
-  {
-    return (name == other.name
-       && target_regnum == other.target_regnum
-       && save_restore == other.save_restore
-       && bitsize == other.bitsize
-       && group == other.group
-       && type == other.type);
-  }
-
-  bool operator!= (const tdesc_reg &other) const
-  {
-    return !(*this == other);
-  }
-};
-
-typedef std::unique_ptr<tdesc_reg> tdesc_reg_up;
-
-enum tdesc_type_kind
-{
-  /* Predefined types.  */
-  TDESC_TYPE_BOOL,
-  TDESC_TYPE_INT8,
-  TDESC_TYPE_INT16,
-  TDESC_TYPE_INT32,
-  TDESC_TYPE_INT64,
-  TDESC_TYPE_INT128,
-  TDESC_TYPE_UINT8,
-  TDESC_TYPE_UINT16,
-  TDESC_TYPE_UINT32,
-  TDESC_TYPE_UINT64,
-  TDESC_TYPE_UINT128,
-  TDESC_TYPE_CODE_PTR,
-  TDESC_TYPE_DATA_PTR,
-  TDESC_TYPE_IEEE_HALF,
-  TDESC_TYPE_IEEE_SINGLE,
-  TDESC_TYPE_IEEE_DOUBLE,
-  TDESC_TYPE_ARM_FPA_EXT,
-  TDESC_TYPE_I387_EXT,
-
-  /* Types defined by a target feature.  */
-  TDESC_TYPE_VECTOR,
-  TDESC_TYPE_STRUCT,
-  TDESC_TYPE_UNION,
-  TDESC_TYPE_FLAGS,
-  TDESC_TYPE_ENUM
-};
-
-struct tdesc_type : tdesc_element
-{
-  tdesc_type (const std::string &name_, enum tdesc_type_kind kind_)
-    : name (name_), kind (kind_)
-  {}
-
-  virtual ~tdesc_type () = default;
-
-  DISABLE_COPY_AND_ASSIGN (tdesc_type);
-
-  /* The name of this type.  */
-  std::string name;
-
-  /* Identify the kind of this type.  */
-  enum tdesc_type_kind kind;
-
-  bool operator== (const tdesc_type &other) const
-  {
-    return name == other.name && kind == other.kind;
-  }
-
-  bool operator!= (const tdesc_type &other) const
-  {
-    return !(*this == other);
-  }
-};
-
-typedef std::unique_ptr<tdesc_type> tdesc_type_up;
-
-struct tdesc_type_builtin : tdesc_type
-{
-  tdesc_type_builtin (const std::string &name, enum tdesc_type_kind kind)
-  : tdesc_type (name, kind)
-  {}
-
-  void accept (tdesc_element_visitor &v) const override
-  {
-    v.visit (this);
-  }
-};
-
-/* tdesc_type for vector types.  */
-
-struct tdesc_type_vector : tdesc_type
-{
-  tdesc_type_vector (const std::string &name, tdesc_type *element_type_,
-                    int count_)
-  : tdesc_type (name, TDESC_TYPE_VECTOR),
-    element_type (element_type_), count (count_)
-  {}
-
-  void accept (tdesc_element_visitor &v) const override
-  {
-    v.visit (this);
-  }
-
-  struct tdesc_type *element_type;
-  int count;
-};
-
-/* A named type from a target description.  */
-
-struct tdesc_type_field
-{
-  tdesc_type_field (const std::string &name_, tdesc_type *type_,
-                   int start_, int end_)
-  : name (name_), type (type_), start (start_), end (end_)
-  {}
-
-  std::string name;
-  struct tdesc_type *type;
-  /* For non-enum-values, either both are -1 (non-bitfield), or both are
-     not -1 (bitfield).  For enum values, start is the value (which could be
-     -1), end is -1.  */
-  int start, end;
-};
-
-/* tdesc_type for struct, union, flags, and enum types.  */
-
-struct tdesc_type_with_fields : tdesc_type
-{
-  tdesc_type_with_fields (const std::string &name, tdesc_type_kind kind,
-                         int size_ = 0)
-  : tdesc_type (name, kind), size (size_)
-  {}
-
-  void accept (tdesc_element_visitor &v) const override
-  {
-    v.visit (this);
-  }
-
-  std::vector<tdesc_type_field> fields;
-  int size;
-};
-
-/* A feature from a target description.  Each feature is a collection
-   of other elements, e.g. registers and types.  */
-
-struct tdesc_feature : tdesc_element
-{
-  tdesc_feature (const std::string &name_)
-    : name (name_)
-  {}
-
-  virtual ~tdesc_feature () = default;
-
-  DISABLE_COPY_AND_ASSIGN (tdesc_feature);
-
-  /* The name of this feature.  It may be recognized by the architecture
-     support code.  */
-  std::string name;
-
-  /* The registers associated with this feature.  */
-  std::vector<tdesc_reg_up> registers;
-
-  /* The types associated with this feature.  */
-  std::vector<tdesc_type_up> types;
-
-  void accept (tdesc_element_visitor &v) const override;
-
-  bool operator== (const tdesc_feature &other) const;
-
-  bool operator!= (const tdesc_feature &other) const
-  {
-    return !(*this == other);
-  }
-};
-
-typedef std::unique_ptr<tdesc_feature> tdesc_feature_up;
-
-/* Allocate a new target_desc.  */
-target_desc *allocate_target_description (void);
-
-/* Set TARGET_DESC's architecture by NAME.  */
-void set_tdesc_architecture (target_desc *target_desc,
-                            const char *name);
-
-/* Return the architecture associated with this target description as a string,
-   or NULL if no architecture was specified.  */
-const char *tdesc_architecture_name (const struct target_desc *target_desc);
-
-/* Set TARGET_DESC's osabi by NAME.  */
-void set_tdesc_osabi (target_desc *target_desc, const char *name);
-
-/* Return the osabi associated with this target description as a string,
-   or NULL if no osabi was specified.  */
-const char *tdesc_osabi_name (const struct target_desc *target_desc);
-
-/* Return the type associated with ID in the context of FEATURE, or
-   NULL if none.  */
-struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature,
-                                    const char *id);
-
-/* Return the created feature named NAME in target description TDESC.  */
-struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc,
-                                           const char *name);
-
-/* Return the created vector tdesc_type named NAME in FEATURE.  */
-struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature,
-                                       const char *name,
-                                       struct tdesc_type *field_type,
-                                       int count);
-
-/* Return the created struct tdesc_type named NAME in FEATURE.  */
-tdesc_type_with_fields *tdesc_create_struct (struct tdesc_feature *feature,
-                                            const char *name);
-
-/* Return the created union tdesc_type named NAME in FEATURE.  */
-tdesc_type_with_fields *tdesc_create_union (struct tdesc_feature *feature,
-                                           const char *name);
-
-/* Return the created flags tdesc_type named NAME in FEATURE.  */
-tdesc_type_with_fields *tdesc_create_flags (struct tdesc_feature *feature,
-                                           const char *name,
-                                           int size);
-
-/* Return the created enum tdesc_type named NAME in FEATURE.  */
-tdesc_type_with_fields *tdesc_create_enum (struct tdesc_feature *feature,
-                                          const char *name,
-                                          int size);
-
-/* Add a new field to TYPE.  FIELD_NAME is its name, and FIELD_TYPE is
-   its type.  */
-void tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
-                     struct tdesc_type *field_type);
-
-/* Add a new bitfield to TYPE, with range START to END.  FIELD_NAME is its name,
-   and FIELD_TYPE is its type.  */
-void tdesc_add_typed_bitfield (tdesc_type_with_fields *type,
-                              const char *field_name,
-                              int start, int end,
-                              struct tdesc_type *field_type);
-
-/* Set the total length of TYPE.  Structs which contain bitfields may
-   omit the reserved bits, so the end of the last field may not
-   suffice.  */
-void tdesc_set_struct_size (tdesc_type_with_fields *type, int size);
-
-/* Add a new untyped bitfield to TYPE.
-   Untyped bitfields become either uint32 or uint64 depending on the size
-   of the underlying type.  */
-void tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
-                        int start, int end);
-
-/* A flag is just a typed(bool) single-bit bitfield.
-   This function is kept to minimize changes in generated files.  */
-void tdesc_add_flag (tdesc_type_with_fields *type, int start,
-                    const char *flag_name);
-
-/* Add field with VALUE and NAME to the enum TYPE.  */
-void tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
-                          const char *name);
-
-/* Create a register in feature FEATURE.  */
-void tdesc_create_reg (struct tdesc_feature *feature, const char *name,
-                      int regnum, int save_restore, const char *group,
-                      int bitsize, const char *type);
-
-/* Return the tdesc in string XML format.  */
-
-const char *tdesc_get_features_xml (const target_desc *tdesc);
-
-/* Print target description as xml.  */
-
-class print_xml_feature : public tdesc_element_visitor
-{
-public:
-  print_xml_feature (std::string *buffer_)
-    : m_buffer (buffer_)
-  {}
-
-  void visit_pre (const target_desc *e) override;
-  void visit_post (const target_desc *e) override;
-  void visit_pre (const tdesc_feature *e) override;
-  void visit_post (const tdesc_feature *e) override;
-  void visit (const tdesc_type_builtin *type) override;
-  void visit (const tdesc_type_vector *type) override;
-  void visit (const tdesc_type_with_fields *type) override;
-  void visit (const tdesc_reg *reg) override;
-
-private:
-  std::string *m_buffer;
-};
-
-#endif /* COMMON_TDESC_H */
diff --git a/gdb/common/traits.h b/gdb/common/traits.h
deleted file mode 100644 (file)
index de57c19..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_TRAITS_H
-#define COMMON_TRAITS_H
-
-#include <type_traits>
-
-/* GCC does not understand __has_feature.  */
-#if !defined(__has_feature)
-# define __has_feature(x) 0
-#endif
-
-/* HAVE_IS_TRIVIALLY_COPYABLE is defined as 1 iff
-   std::is_trivially_copyable is available.  GCC only implemented it
-   in GCC 5.  */
-#if (__has_feature(is_trivially_copyable) \
-     || (defined __GNUC__ && __GNUC__ >= 5))
-# define HAVE_IS_TRIVIALLY_COPYABLE 1
-#endif
-
-/* HAVE_IS_TRIVIALLY_CONSTRUCTIBLE is defined as 1 iff
-   std::is_trivially_constructible is available.  GCC only implemented it
-   in GCC 5.  */
-#if (__has_feature(is_trivially_constructible) \
-     || (defined __GNUC__ && __GNUC__ >= 5))
-# define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1
-#endif
-
-namespace gdb {
-
-/* Pre C++14-safe (CWG 1558) version of C++17's std::void_t.  See
-   <http://en.cppreference.com/w/cpp/types/void_t>.  */
-
-template<typename... Ts>
-struct make_void { typedef void type; };
-
-template<typename... Ts>
-using void_t = typename make_void<Ts...>::type;
-
-/* A few trait helpers, mainly stolen from libstdc++.  Uppercase
-   because "and/or", etc. are reserved keywords.  */
-
-template<typename Predicate>
-struct Not : public std::integral_constant<bool, !Predicate::value>
-{};
-
-template<typename...>
-struct Or;
-
-template<>
-struct Or<> : public std::false_type
-{};
-
-template<typename B1>
-struct Or<B1> : public B1
-{};
-
-template<typename B1, typename B2>
-struct Or<B1, B2>
-  : public std::conditional<B1::value, B1, B2>::type
-{};
-
-template<typename B1,typename B2,typename B3, typename... Bn>
-struct Or<B1, B2, B3, Bn...>
-  : public std::conditional<B1::value, B1, Or<B2, B3, Bn...>>::type
-{};
-
-template<typename...>
-struct And;
-
-template<>
-struct And<> : public std::true_type
-{};
-
-template<typename B1>
-struct And<B1> : public B1
-{};
-
-template<typename B1, typename B2>
-struct And<B1, B2>
-  : public std::conditional<B1::value, B2, B1>::type
-{};
-
-template<typename B1, typename B2, typename B3, typename... Bn>
-struct And<B1, B2, B3, Bn...>
-  : public std::conditional<B1::value, And<B2, B3, Bn...>, B1>::type
-{};
-
-/* Concepts-light-like helper to make SFINAE logic easier to read.  */
-template<typename Condition>
-using Requires = typename std::enable_if<Condition::value, void>::type;
-}
-
-#endif /* COMMON_TRAITS_H */
diff --git a/gdb/common/underlying.h b/gdb/common/underlying.h
deleted file mode 100644 (file)
index af14a36..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2017-2019 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/>.  */
-
-#ifndef COMMON_UNDERLYING_H
-#define COMMON_UNDERLYING_H
-
-#include <type_traits>
-
-/* Convert an enum to its underlying value.  */
-
-template<typename E>
-constexpr typename std::underlying_type<E>::type
-to_underlying (E val) noexcept
-{
-  return static_cast<typename std::underlying_type<E>::type> (val);
-}
-
-#endif
diff --git a/gdb/common/valid-expr.h b/gdb/common/valid-expr.h
deleted file mode 100644 (file)
index 603c76e..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* Compile-time valid expression checker for GDB, the GNU debugger.
-
-   Copyright (C) 2017-2019 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/>.  */
-
-/* Helper macros used to build compile-time unit tests that make sure
-   that invalid expressions that should not compile would not compile,
-   and that expressions that should compile do compile, and have the
-   right type.  This is mainly used to verify that some utility's API
-   is really as safe as intended.  */
-
-#ifndef COMMON_VALID_EXPR_H
-#define COMMON_VALID_EXPR_H
-
-#include "common/preprocessor.h"
-#include "common/traits.h"
-
-/* Macro that uses SFINAE magic to detect whether the EXPR expression
-   is either valid or ill-formed, at compile time, without actually
-   producing compile-time errors.  I.e., check that bad uses of the
-   types (e.g., involving mismatching types) would be caught at
-   compile time.  If the expression is valid, also check whether the
-   expression has the right type.
-
-   EXPR must be defined in terms of some of the template parameters,
-   so that template substitution failure discards the overload instead
-   of causing a real compile error.  TYPES is thus the list of types
-   involved in the expression, and TYPENAMES is the same list, but
-   with each element prefixed by "typename".  These are passed as
-   template parameter types to the templates within the macro.
-
-   VALID is a boolean that indicates whether the expression is
-   supposed to be valid or invalid.
-
-   EXPR_TYPE is the expected type of EXPR.  Only meaningful iff VALID
-   is true.  If VALID is false, then you must pass "void" as expected
-   type.
-
-   Each invocation of the macro is wrapped in its own namespace to
-   avoid ODR violations.  The generated namespace only includes the
-   line number, so client code should wrap sets of calls in a
-   test-specific namespace too, to fully guarantee uniqueness between
-   the multiple clients in the codebase.  */
-#define CHECK_VALID_EXPR_INT(TYPENAMES, TYPES, VALID, EXPR_TYPE, EXPR) \
-  namespace CONCAT (check_valid_expr, __LINE__) {                      \
-                                                                       \
-  template<typename, typename, typename = void>                                \
-  struct is_valid_expression                                           \
-    : std::false_type {};                                              \
-                                                                       \
-  template <TYPENAMES>                                                 \
-    struct is_valid_expression<TYPES, gdb::void_t<decltype (EXPR)>>    \
-    : std::true_type {};                                               \
-                                                                       \
-  static_assert (is_valid_expression<TYPES>::value == VALID,           \
-                "");                                                   \
-                                                                       \
-  template<TYPENAMES, typename = void>                                 \
-  struct is_same_type                                                  \
-    : std::is_same<EXPR_TYPE, void> {};                                        \
-                                                                       \
-  template <TYPENAMES>                                                 \
-    struct is_same_type<TYPES, gdb::void_t<decltype (EXPR)>>           \
-    : std::is_same<EXPR_TYPE, decltype (EXPR)> {};                     \
-                                                                       \
-  static_assert (is_same_type<TYPES>::value, "");                      \
-  } /* namespace */
-
-/* A few convenience macros that support expressions involving a
-   varying numbers of types.  If you need more types, feel free to add
-   another variant.  */
-
-#define CHECK_VALID_EXPR_1(T1, VALID, EXPR_TYPE, EXPR)                 \
-  CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1),                      \
-                       ESC_PARENS (T1),                                \
-                       VALID, EXPR_TYPE, EXPR)
-
-#define CHECK_VALID_EXPR_2(T1, T2, VALID, EXPR_TYPE, EXPR)             \
-  CHECK_VALID_EXPR_INT (ESC_PARENS(typename T1, typename T2),          \
-                       ESC_PARENS (T1, T2),                            \
-                       VALID, EXPR_TYPE, EXPR)
-
-#define CHECK_VALID_EXPR_3(T1, T2, T3, VALID, EXPR_TYPE, EXPR)         \
-  CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, typename T3), \
-                       ESC_PARENS (T1, T2, T3),                                \
-                       VALID, EXPR_TYPE, EXPR)
-
-#define CHECK_VALID_EXPR_4(T1, T2, T3, T4, VALID, EXPR_TYPE, EXPR)     \
-  CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2,          \
-                                   typename T3, typename T4),          \
-                       ESC_PARENS (T1, T2, T3, T4),                    \
-                       VALID, EXPR_TYPE, EXPR)
-
-#endif /* COMMON_VALID_EXPR_H */
diff --git a/gdb/common/vec.c b/gdb/common/vec.c
deleted file mode 100644 (file)
index a889544..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Vector API for GDB.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   Contributed by Nathan Sidwell <nathan@codesourcery.com>
-
-   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 "common-defs.h"
-#include "vec.h"
-
-struct vec_prefix
-{
-  unsigned num;
-  unsigned alloc;
-  void *vec[1];
-};
-
-/* Calculate the new ALLOC value, making sure that abs(RESERVE) slots
-   are free.  If RESERVE < 0 grow exactly, otherwise grow
-   exponentially.  */
-
-static inline unsigned
-calculate_allocation (const struct vec_prefix *pfx, int reserve)
-{
-  unsigned alloc = 0;
-  unsigned num = 0;
-
-  if (pfx)
-    {
-      alloc = pfx->alloc;
-      num = pfx->num;
-    }
-  else if (!reserve)
-    /* If there's no prefix, and we've not requested anything, then we
-       will create a NULL vector.  */
-    return 0;
-
-  /* We must have run out of room.  */
-  gdb_assert (alloc - num < (unsigned)(reserve < 0 ? -reserve : reserve));
-
-  if (reserve < 0)
-    /* Exact size.  */
-    alloc = num + -reserve;
-  else
-    {
-      /* Exponential growth.  */
-      if (!alloc)
-       alloc = 4;
-      else if (alloc < 16)
-       /* Double when small.  */
-       alloc = alloc * 2;
-      else
-       /* Grow slower when large.  */
-       alloc = (alloc * 3 / 2);
-
-      /* If this is still too small, set it to the right size.  */
-      if (alloc < num + reserve)
-       alloc = num + reserve;
-    }
-  return alloc;
-}
-
-/* Ensure there are at least abs(RESERVE) free slots in VEC.  If
-   RESERVE < 0 grow exactly, else grow exponentially.  As a special
-   case, if VEC is NULL, and RESERVE is 0, no vector will be created.  */
-
-void *
-vec_p_reserve (void *vec, int reserve)
-{
-  return vec_o_reserve (vec, reserve,
-                       offsetof (struct vec_prefix, vec), sizeof (void *));
-}
-
-/* As vec_p_reserve, but for object vectors.  The vector's trailing
-   array is at VEC_OFFSET offset and consists of ELT_SIZE sized
-   elements.  */
-
-void *
-vec_o_reserve (void *vec, int reserve, size_t vec_offset, size_t elt_size)
-{
-  struct vec_prefix *pfx = (struct vec_prefix *) vec;
-  unsigned alloc = calculate_allocation (pfx, reserve);
-
-  if (!alloc)
-    return NULL;
-
-  vec = xrealloc (vec, vec_offset + alloc * elt_size);
-  ((struct vec_prefix *)vec)->alloc = alloc;
-  if (!pfx)
-    ((struct vec_prefix *)vec)->num = 0;
-
-  return vec;
-}
-
-#if 0
-/* Example uses.  */
-DEF_VEC_I (int);
-typedef struct X
-{
-  int i;
-} obj_t;
-typedef obj_t *ptr_t;
-
-DEF_VEC_P (ptr_t);
-DEF_VEC_O (obj_t);
-#endif
diff --git a/gdb/common/vec.h b/gdb/common/vec.h
deleted file mode 100644 (file)
index 8ac146d..0000000
+++ /dev/null
@@ -1,1150 +0,0 @@
-/* Vector API for GDB.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   Contributed by Nathan Sidwell <nathan@codesourcery.com>
-
-   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/>.  */
-
-#ifndef COMMON_VEC_H
-#define COMMON_VEC_H
-
-#include "diagnostics.h"
-
-/* clang has a bug that makes it warn (-Wunused-function) about unused functions
-   that are the result of the DEF_VEC_* macro expansion.  See:
-
-     https://bugs.llvm.org/show_bug.cgi?id=22712
-
-   We specifically ignore this warning for the vec functions when the compiler
-   is clang.  */
-#ifdef __clang__
-# define DIAGNOSTIC_IGNORE_UNUSED_VEC_FUNCTION \
-    DIAGNOSTIC_IGNORE_UNUSED_FUNCTION
-#else
-# define DIAGNOSTIC_IGNORE_UNUSED_VEC_FUNCTION
-#endif
-
-/* The macros here implement a set of templated vector types and
-   associated interfaces.  These templates are implemented with
-   macros, as we're not in C++ land.  The interface functions are
-   typesafe and use static inline functions, sometimes backed by
-   out-of-line generic functions.
-
-   Because of the different behavior of structure objects, scalar
-   objects and of pointers, there are three flavors, one for each of
-   these variants.  Both the structure object and pointer variants
-   pass pointers to objects around -- in the former case the pointers
-   are stored into the vector and in the latter case the pointers are
-   dereferenced and the objects copied into the vector.  The scalar
-   object variant is suitable for int-like objects, and the vector
-   elements are returned by value.
-
-   There are both 'index' and 'iterate' accessors.  The iterator
-   returns a boolean iteration condition and updates the iteration
-   variable passed by reference.  Because the iterator will be
-   inlined, the address-of can be optimized away.
-
-   The vectors are implemented using the trailing array idiom, thus
-   they are not resizeable without changing the address of the vector
-   object itself.  This means you cannot have variables or fields of
-   vector type -- always use a pointer to a vector.  The one exception
-   is the final field of a structure, which could be a vector type.
-   You will have to use the embedded_size & embedded_init calls to
-   create such objects, and they will probably not be resizeable (so
-   don't use the 'safe' allocation variants).  The trailing array
-   idiom is used (rather than a pointer to an array of data), because,
-   if we allow NULL to also represent an empty vector, empty vectors
-   occupy minimal space in the structure containing them.
-
-   Each operation that increases the number of active elements is
-   available in 'quick' and 'safe' variants.  The former presumes that
-   there is sufficient allocated space for the operation to succeed
-   (it dies if there is not).  The latter will reallocate the
-   vector, if needed.  Reallocation causes an exponential increase in
-   vector size.  If you know you will be adding N elements, it would
-   be more efficient to use the reserve operation before adding the
-   elements with the 'quick' operation.  This will ensure there are at
-   least as many elements as you ask for, it will exponentially
-   increase if there are too few spare slots.  If you want reserve a
-   specific number of slots, but do not want the exponential increase
-   (for instance, you know this is the last allocation), use a
-   negative number for reservation.  You can also create a vector of a
-   specific size from the get go.
-
-   You should prefer the push and pop operations, as they append and
-   remove from the end of the vector.  If you need to remove several
-   items in one go, use the truncate operation.  The insert and remove
-   operations allow you to change elements in the middle of the
-   vector.  There are two remove operations, one which preserves the
-   element ordering 'ordered_remove', and one which does not
-   'unordered_remove'.  The latter function copies the end element
-   into the removed slot, rather than invoke a memmove operation.  The
-   'lower_bound' function will determine where to place an item in the
-   array using insert that will maintain sorted order.
-
-   If you need to directly manipulate a vector, then the 'address'
-   accessor will return the address of the start of the vector.  Also
-   the 'space' predicate will tell you whether there is spare capacity
-   in the vector.  You will not normally need to use these two functions.
-
-   Vector types are defined using a DEF_VEC_{O,P,I}(TYPEDEF) macro.
-   Variables of vector type are declared using a VEC(TYPEDEF) macro.
-   The characters O, P and I indicate whether TYPEDEF is a pointer
-   (P), object (O) or integral (I) type.  Be careful to pick the
-   correct one, as you'll get an awkward and inefficient API if you
-   use the wrong one.  There is a check, which results in a
-   compile-time warning, for the P and I versions, but there is no
-   check for the O versions, as that is not possible in plain C.
-
-   An example of their use would be,
-
-   DEF_VEC_P(tree);   // non-managed tree vector.
-
-   struct my_struct {
-     VEC(tree) *v;      // A (pointer to) a vector of tree pointers.
-   };
-
-   struct my_struct *s;
-
-   if (VEC_length(tree, s->v)) { we have some contents }
-   VEC_safe_push(tree, s->v, decl); // append some decl onto the end
-   for (ix = 0; VEC_iterate(tree, s->v, ix, elt); ix++)
-     { do something with elt }
-
-*/
-
-/* Macros to invoke API calls.  A single macro works for both pointer
-   and object vectors, but the argument and return types might well be
-   different.  In each macro, T is the typedef of the vector elements.
-   Some of these macros pass the vector, V, by reference (by taking
-   its address), this is noted in the descriptions.  */
-
-/* Length of vector
-   unsigned VEC_T_length(const VEC(T) *v);
-
-   Return the number of active elements in V.  V can be NULL, in which
-   case zero is returned.  */
-
-#define VEC_length(T,V)        (VEC_OP(T,length)(V))
-
-
-/* Check if vector is empty
-   int VEC_T_empty(const VEC(T) *v);
-
-   Return nonzero if V is an empty vector (or V is NULL), zero otherwise.  */
-
-#define VEC_empty(T,V) (VEC_length (T,V) == 0)
-
-
-/* Get the final element of the vector.
-   T VEC_T_last(VEC(T) *v); // Integer
-   T VEC_T_last(VEC(T) *v); // Pointer
-   T *VEC_T_last(VEC(T) *v); // Object
-
-   Return the final element.  V must not be empty.  */
-
-#define VEC_last(T,V)  (VEC_OP(T,last)(V VEC_ASSERT_INFO))
-
-/* Index into vector
-   T VEC_T_index(VEC(T) *v, unsigned ix); // Integer
-   T VEC_T_index(VEC(T) *v, unsigned ix); // Pointer
-   T *VEC_T_index(VEC(T) *v, unsigned ix); // Object
-
-   Return the IX'th element.  If IX must be in the domain of V.  */
-
-#define VEC_index(T,V,I) (VEC_OP(T,index)(V,I VEC_ASSERT_INFO))
-
-/* Iterate over vector
-   int VEC_T_iterate(VEC(T) *v, unsigned ix, T &ptr); // Integer
-   int VEC_T_iterate(VEC(T) *v, unsigned ix, T &ptr); // Pointer
-   int VEC_T_iterate(VEC(T) *v, unsigned ix, T *&ptr); // Object
-
-   Return iteration condition and update PTR to point to the IX'th
-   element.  At the end of iteration, sets PTR to NULL.  Use this to
-   iterate over the elements of a vector as follows,
-
-     for (ix = 0; VEC_iterate(T,v,ix,ptr); ix++)
-       continue;  */
-
-#define VEC_iterate(T,V,I,P)   (VEC_OP(T,iterate)(V,I,&(P)))
-
-/* Allocate new vector.
-   VEC(T,A) *VEC_T_alloc(int reserve);
-
-   Allocate a new vector with space for RESERVE objects.  If RESERVE
-   is zero, NO vector is created.  */
-
-#define VEC_alloc(T,N) (VEC_OP(T,alloc)(N))
-
-/* Free a vector.
-   void VEC_T_free(VEC(T,A) *&);
-
-   Free a vector and set it to NULL.  */
-
-#define VEC_free(T,V)  (VEC_OP(T,free)(&V))
-
-/* A cleanup function for a vector.
-   void VEC_T_cleanup(void *);
-   
-   Clean up a vector.  */
-
-#define VEC_cleanup(T) (VEC_OP(T,cleanup))
-
-/* Use these to determine the required size and initialization of a
-   vector embedded within another structure (as the final member).
-
-   size_t VEC_T_embedded_size(int reserve);
-   void VEC_T_embedded_init(VEC(T) *v, int reserve);
-
-   These allow the caller to perform the memory allocation.  */
-
-#define VEC_embedded_size(T,N)  (VEC_OP(T,embedded_size)(N))
-#define VEC_embedded_init(T,O,N) (VEC_OP(T,embedded_init)(VEC_BASE(O),N))
-
-/* Copy a vector.
-   VEC(T,A) *VEC_T_copy(VEC(T) *);
-
-   Copy the live elements of a vector into a new vector.  The new and
-   old vectors need not be allocated by the same mechanism.  */
-
-#define VEC_copy(T,V) (VEC_OP(T,copy)(V))
-
-/* Merge two vectors.
-   VEC(T,A) *VEC_T_merge(VEC(T) *, VEC(T) *);
-
-   Copy the live elements of both vectors into a new vector.  The new
-   and old vectors need not be allocated by the same mechanism.  */
-#define VEC_merge(T,V1,V2) (VEC_OP(T,merge)(V1, V2))
-
-/* Determine if a vector has additional capacity.
-
-   int VEC_T_space (VEC(T) *v,int reserve)
-
-   If V has space for RESERVE additional entries, return nonzero.  You
-   usually only need to use this if you are doing your own vector
-   reallocation, for instance on an embedded vector.  This returns
-   nonzero in exactly the same circumstances that VEC_T_reserve
-   will.  */
-
-#define VEC_space(T,V,R) (VEC_OP(T,space)(V,R VEC_ASSERT_INFO))
-
-/* Reserve space.
-   int VEC_T_reserve(VEC(T,A) *&v, int reserve);
-
-   Ensure that V has at least abs(RESERVE) slots available.  The
-   signedness of RESERVE determines the reallocation behavior.  A
-   negative value will not create additional headroom beyond that
-   requested.  A positive value will create additional headroom.  Note
-   this can cause V to be reallocated.  Returns nonzero iff
-   reallocation actually occurred.  */
-
-#define VEC_reserve(T,V,R) (VEC_OP(T,reserve)(&(V),R VEC_ASSERT_INFO))
-
-/* Push object with no reallocation
-   T *VEC_T_quick_push (VEC(T) *v, T obj); // Integer
-   T *VEC_T_quick_push (VEC(T) *v, T obj); // Pointer
-   T *VEC_T_quick_push (VEC(T) *v, T *obj); // Object
-
-   Push a new element onto the end, returns a pointer to the slot
-   filled in.  For object vectors, the new value can be NULL, in which
-   case NO initialization is performed.  There must
-   be sufficient space in the vector.  */
-
-#define VEC_quick_push(T,V,O) (VEC_OP(T,quick_push)(V,O VEC_ASSERT_INFO))
-
-/* Push object with reallocation
-   T *VEC_T_safe_push (VEC(T,A) *&v, T obj); // Integer
-   T *VEC_T_safe_push (VEC(T,A) *&v, T obj); // Pointer
-   T *VEC_T_safe_push (VEC(T,A) *&v, T *obj); // Object
-
-   Push a new element onto the end, returns a pointer to the slot
-   filled in.  For object vectors, the new value can be NULL, in which
-   case NO initialization is performed.  Reallocates V, if needed.  */
-
-#define VEC_safe_push(T,V,O) (VEC_OP(T,safe_push)(&(V),O VEC_ASSERT_INFO))
-
-/* Pop element off end
-   T VEC_T_pop (VEC(T) *v);            // Integer
-   T VEC_T_pop (VEC(T) *v);            // Pointer
-   void VEC_T_pop (VEC(T) *v);         // Object
-
-   Pop the last element off the end.  Returns the element popped, for
-   pointer vectors.  */
-
-#define VEC_pop(T,V)   (VEC_OP(T,pop)(V VEC_ASSERT_INFO))
-
-/* Truncate to specific length
-   void VEC_T_truncate (VEC(T) *v, unsigned len);
-
-   Set the length as specified.  The new length must be less than or
-   equal to the current length.  This is an O(1) operation.  */
-
-#define VEC_truncate(T,V,I)            \
-       (VEC_OP(T,truncate)(V,I VEC_ASSERT_INFO))
-
-/* Grow to a specific length.
-   void VEC_T_safe_grow (VEC(T,A) *&v, int len);
-
-   Grow the vector to a specific length.  The LEN must be as
-   long or longer than the current length.  The new elements are
-   uninitialized.  */
-
-#define VEC_safe_grow(T,V,I)           \
-       (VEC_OP(T,safe_grow)(&(V),I VEC_ASSERT_INFO))
-
-/* Replace element
-   T VEC_T_replace (VEC(T) *v, unsigned ix, T val); // Integer
-   T VEC_T_replace (VEC(T) *v, unsigned ix, T val); // Pointer
-   T *VEC_T_replace (VEC(T) *v, unsigned ix, T *val);  // Object
-
-   Replace the IXth element of V with a new value, VAL.  For pointer
-   vectors returns the original value.  For object vectors returns a
-   pointer to the new value.  For object vectors the new value can be
-   NULL, in which case no overwriting of the slot is actually
-   performed.  */
-
-#define VEC_replace(T,V,I,O) (VEC_OP(T,replace)(V,I,O VEC_ASSERT_INFO))
-
-/* Insert object with no reallocation
-   T *VEC_T_quick_insert (VEC(T) *v, unsigned ix, T val); // Integer
-   T *VEC_T_quick_insert (VEC(T) *v, unsigned ix, T val); // Pointer
-   T *VEC_T_quick_insert (VEC(T) *v, unsigned ix, T *val); // Object
-
-   Insert an element, VAL, at the IXth position of V.  Return a pointer
-   to the slot created.  For vectors of object, the new value can be
-   NULL, in which case no initialization of the inserted slot takes
-   place.  There must be sufficient space.  */
-
-#define VEC_quick_insert(T,V,I,O) \
-       (VEC_OP(T,quick_insert)(V,I,O VEC_ASSERT_INFO))
-
-/* Insert object with reallocation
-   T *VEC_T_safe_insert (VEC(T,A) *&v, unsigned ix, T val); // Integer
-   T *VEC_T_safe_insert (VEC(T,A) *&v, unsigned ix, T val); // Pointer
-   T *VEC_T_safe_insert (VEC(T,A) *&v, unsigned ix, T *val); // Object
-
-   Insert an element, VAL, at the IXth position of V.  Return a pointer
-   to the slot created.  For vectors of object, the new value can be
-   NULL, in which case no initialization of the inserted slot takes
-   place.  Reallocate V, if necessary.  */
-
-#define VEC_safe_insert(T,V,I,O)       \
-       (VEC_OP(T,safe_insert)(&(V),I,O VEC_ASSERT_INFO))
-
-/* Remove element retaining order
-   T VEC_T_ordered_remove (VEC(T) *v, unsigned ix); // Integer
-   T VEC_T_ordered_remove (VEC(T) *v, unsigned ix); // Pointer
-   void VEC_T_ordered_remove (VEC(T) *v, unsigned ix); // Object
-
-   Remove an element from the IXth position of V.  Ordering of
-   remaining elements is preserved.  For pointer vectors returns the
-   removed object.  This is an O(N) operation due to a memmove.  */
-
-#define VEC_ordered_remove(T,V,I)      \
-       (VEC_OP(T,ordered_remove)(V,I VEC_ASSERT_INFO))
-
-/* Remove element destroying order
-   T VEC_T_unordered_remove (VEC(T) *v, unsigned ix); // Integer
-   T VEC_T_unordered_remove (VEC(T) *v, unsigned ix); // Pointer
-   void VEC_T_unordered_remove (VEC(T) *v, unsigned ix); // Object
-
-   Remove an element from the IXth position of V.  Ordering of
-   remaining elements is destroyed.  For pointer vectors returns the
-   removed object.  This is an O(1) operation.  */
-
-#define VEC_unordered_remove(T,V,I)    \
-       (VEC_OP(T,unordered_remove)(V,I VEC_ASSERT_INFO))
-
-/* Remove a block of elements
-   void VEC_T_block_remove (VEC(T) *v, unsigned ix, unsigned len);
-
-   Remove LEN elements starting at the IXth.  Ordering is retained.
-   This is an O(N) operation due to memmove.  */
-
-#define VEC_block_remove(T,V,I,L)      \
-       (VEC_OP(T,block_remove)(V,I,L VEC_ASSERT_INFO))
-
-/* Get the address of the array of elements
-   T *VEC_T_address (VEC(T) v)
-
-   If you need to directly manipulate the array (for instance, you
-   want to feed it to qsort), use this accessor.  */
-
-#define VEC_address(T,V)               (VEC_OP(T,address)(V))
-
-/* Find the first index in the vector not less than the object.
-   unsigned VEC_T_lower_bound (VEC(T) *v, const T val,
-                               int (*lessthan) (const T, const T)); // Integer
-   unsigned VEC_T_lower_bound (VEC(T) *v, const T val,
-                               int (*lessthan) (const T, const T)); // Pointer
-   unsigned VEC_T_lower_bound (VEC(T) *v, const T *val,
-                               int (*lessthan) (const T*, const T*)); // Object
-
-   Find the first position in which VAL could be inserted without
-   changing the ordering of V.  LESSTHAN is a function that returns
-   true if the first argument is strictly less than the second.  */
-
-#define VEC_lower_bound(T,V,O,LT)    \
-       (VEC_OP(T,lower_bound)(V,O,LT VEC_ASSERT_INFO))
-
-/* Reallocate an array of elements with prefix.  */
-extern void *vec_p_reserve (void *, int);
-extern void *vec_o_reserve (void *, int, size_t, size_t);
-#define vec_free_(V) xfree (V)
-
-#define VEC_ASSERT_INFO ,__FILE__,__LINE__
-#define VEC_ASSERT_DECL ,const char *file_,unsigned line_
-#define VEC_ASSERT_PASS ,file_,line_
-#define vec_assert(expr, op) \
-  ((void)((expr) ? 0 : (gdb_assert_fail (op, file_, line_, \
-                                        FUNCTION_NAME), 0)))
-
-#define VEC(T) VEC_##T
-#define VEC_OP(T,OP) VEC_##T##_##OP
-
-#define VEC_T(T)                                                         \
-typedef struct VEC(T)                                                    \
-{                                                                        \
-  unsigned num;                                                                  \
-  unsigned alloc;                                                        \
-  T vec[1];                                                              \
-} VEC(T)
-
-/* Vector of integer-like object.  */
-#define DEF_VEC_I(T)                                                     \
-DIAGNOSTIC_PUSH                                                          \
-DIAGNOSTIC_IGNORE_UNUSED_VEC_FUNCTION                                    \
-static inline void VEC_OP (T,must_be_integral_type) (void)               \
-{                                                                        \
-  (void)~(T)0;                                                           \
-}                                                                        \
-                                                                         \
-VEC_T(T);                                                                \
-DEF_VEC_FUNC_P(T)                                                        \
-DEF_VEC_ALLOC_FUNC_I(T)                                                          \
-DIAGNOSTIC_POP                                                           \
-struct vec_swallow_trailing_semi
-
-/* Vector of pointer to object.  */
-#define DEF_VEC_P(T)                                                     \
-DIAGNOSTIC_PUSH                                                          \
-DIAGNOSTIC_IGNORE_UNUSED_VEC_FUNCTION                                    \
-static inline void VEC_OP (T,must_be_pointer_type) (void)                \
-{                                                                        \
-  (void)((T)1 == (void *)1);                                             \
-}                                                                        \
-                                                                         \
-VEC_T(T);                                                                \
-DEF_VEC_FUNC_P(T)                                                        \
-DEF_VEC_ALLOC_FUNC_P(T)                                                          \
-DIAGNOSTIC_POP                                                           \
-struct vec_swallow_trailing_semi
-
-/* Vector of object.  */
-#define DEF_VEC_O(T)                                                     \
-DIAGNOSTIC_PUSH                                                          \
-DIAGNOSTIC_IGNORE_UNUSED_VEC_FUNCTION                                    \
-VEC_T(T);                                                                \
-DEF_VEC_FUNC_O(T)                                                        \
-DEF_VEC_ALLOC_FUNC_O(T)                                                          \
-DIAGNOSTIC_POP                                                           \
-struct vec_swallow_trailing_semi
-
-/* Avoid offsetof (or its usual C implementation) as it triggers
-   -Winvalid-offsetof warnings with enum_flags types with G++ <= 4.4,
-   even though those types are memcpyable.  This requires allocating a
-   dummy local VEC in all routines that use this, but that has the
-   advantage that it only works if T is default constructible, which
-   is exactly a check we want, to keep C compatibility.  */
-#define vec_offset(T, VPTR) ((size_t) ((char *) &(VPTR)->vec - (char *) VPTR))
-
-#define DEF_VEC_ALLOC_FUNC_I(T)                                                  \
-static inline VEC(T) *VEC_OP (T,alloc)                                   \
-     (int alloc_)                                                        \
-{                                                                        \
-  VEC(T) dummy;                                                                  \
-                                                                         \
-  /* We must request exact size allocation, hence the negation.  */      \
-  return (VEC(T) *) vec_o_reserve (NULL, -alloc_,                        \
-                                   vec_offset (T, &dummy), sizeof (T));          \
-}                                                                        \
-                                                                         \
-static inline VEC(T) *VEC_OP (T,copy) (VEC(T) *vec_)                     \
-{                                                                        \
-  size_t len_ = vec_ ? vec_->num : 0;                                    \
-  VEC (T) *new_vec_ = NULL;                                              \
-                                                                         \
-  if (len_)                                                              \
-    {                                                                    \
-      VEC(T) dummy;                                                      \
-                                                                         \
-      /* We must request exact size allocation, hence the negation.  */          \
-      new_vec_ = (VEC (T) *)                                             \
-       vec_o_reserve (NULL, -len_, vec_offset (T, &dummy), sizeof (T));        \
-                                                                         \
-      new_vec_->num = len_;                                              \
-      memcpy (new_vec_->vec, vec_->vec, sizeof (T) * len_);              \
-    }                                                                    \
-  return new_vec_;                                                       \
-}                                                                        \
-                                                                         \
-static inline VEC(T) *VEC_OP (T,merge) (VEC(T) *vec1_, VEC(T) *vec2_)    \
-{                                                                        \
-  if (vec1_ && vec2_)                                                    \
-    {                                                                    \
-      VEC(T) dummy;                                                      \
-      size_t len_ = vec1_->num + vec2_->num;                             \
-      VEC (T) *new_vec_ = NULL;                                                  \
-                                                                         \
-      /* We must request exact size allocation, hence the negation.  */          \
-      new_vec_ = (VEC (T) *)                                             \
-       vec_o_reserve (NULL, -len_, vec_offset (T, &dummy), sizeof (T));          \
-                                                                         \
-      new_vec_->num = len_;                                              \
-      memcpy (new_vec_->vec, vec1_->vec, sizeof (T) * vec1_->num);       \
-      memcpy (new_vec_->vec + vec1_->num, vec2_->vec,                    \
-             sizeof (T) * vec2_->num);                                   \
-                                                                         \
-      return new_vec_;                                                   \
-    }                                                                    \
-  else                                                                   \
-    return VEC_copy (T, vec1_ ? vec1_ : vec2_);                                  \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,free)                                       \
-     (VEC(T) **vec_)                                                     \
-{                                                                        \
-  if (*vec_)                                                             \
-    vec_free_ (*vec_);                                                   \
-  *vec_ = NULL;                                                                  \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,cleanup)                                    \
-     (void *arg_)                                                        \
-{                                                                        \
-  VEC(T) **vec_ = (VEC(T) **) arg_;                                      \
-  if (*vec_)                                                             \
-    vec_free_ (*vec_);                                                   \
-  *vec_ = NULL;                                                                  \
-}                                                                        \
-                                                                         \
-static inline int VEC_OP (T,reserve)                                     \
-     (VEC(T) **vec_, int alloc_ VEC_ASSERT_DECL)                         \
-{                                                                        \
-  VEC(T) dummy;                                                                  \
-  int extend = !VEC_OP (T,space)                                         \
-       (*vec_, alloc_ < 0 ? -alloc_ : alloc_ VEC_ASSERT_PASS);           \
-                                                                         \
-  if (extend)                                                            \
-    *vec_ = (VEC(T) *) vec_o_reserve (*vec_, alloc_,                     \
-                                     vec_offset (T, &dummy), sizeof (T)); \
-                                                                         \
-  return extend;                                                         \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,safe_grow)                                          \
-     (VEC(T) **vec_, int size_ VEC_ASSERT_DECL)                                  \
-{                                                                        \
-  vec_assert (size_ >= 0 && VEC_OP(T,length) (*vec_) <= (unsigned)size_,  \
-       "safe_grow");                                                     \
-  VEC_OP (T,reserve) (vec_, (int)(*vec_ ? (*vec_)->num : 0) - size_      \
-                       VEC_ASSERT_PASS);                                 \
-  (*vec_)->num = size_;                                                          \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,safe_push)                                    \
-     (VEC(T) **vec_, const T obj_ VEC_ASSERT_DECL)                       \
-{                                                                        \
-  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
-                                                                         \
-  return VEC_OP (T,quick_push) (*vec_, obj_ VEC_ASSERT_PASS);            \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,safe_insert)                                          \
-     (VEC(T) **vec_, unsigned ix_, const T obj_ VEC_ASSERT_DECL)         \
-{                                                                        \
-  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
-                                                                         \
-  return VEC_OP (T,quick_insert) (*vec_, ix_, obj_ VEC_ASSERT_PASS);     \
-}
-
-#define DEF_VEC_FUNC_P(T)                                                \
-static inline unsigned VEC_OP (T,length) (const VEC(T) *vec_)            \
-{                                                                        \
-  return vec_ ? vec_->num : 0;                                           \
-}                                                                        \
-                                                                         \
-static inline T VEC_OP (T,last)                                                  \
-       (const VEC(T) *vec_ VEC_ASSERT_DECL)                              \
-{                                                                        \
-  vec_assert (vec_ && vec_->num, "last");                                \
-                                                                         \
-  return vec_->vec[vec_->num - 1];                                       \
-}                                                                        \
-                                                                         \
-static inline T VEC_OP (T,index)                                         \
-     (const VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                          \
-{                                                                        \
-  vec_assert (vec_ && ix_ < vec_->num, "index");                         \
-                                                                         \
-  return vec_->vec[ix_];                                                 \
-}                                                                        \
-                                                                         \
-static inline int VEC_OP (T,iterate)                                     \
-     (const VEC(T) *vec_, unsigned ix_, T *ptr)                                  \
-{                                                                        \
-  if (vec_ && ix_ < vec_->num)                                           \
-    {                                                                    \
-      *ptr = vec_->vec[ix_];                                             \
-      return 1;                                                                  \
-    }                                                                    \
-  else                                                                   \
-    {                                                                    \
-      *ptr = (T) 0;                                                      \
-      return 0;                                                                  \
-    }                                                                    \
-}                                                                        \
-                                                                         \
-static inline size_t VEC_OP (T,embedded_size)                            \
-     (int alloc_)                                                        \
-{                                                                        \
-  VEC(T) dummy;                                                                  \
-                                                                         \
-  return vec_offset (T, &dummy) + alloc_ * sizeof(T);                    \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,embedded_init)                              \
-     (VEC(T) *vec_, int alloc_)                                                  \
-{                                                                        \
-  vec_->num = 0;                                                         \
-  vec_->alloc = alloc_;                                                          \
-}                                                                        \
-                                                                         \
-static inline int VEC_OP (T,space)                                       \
-     (VEC(T) *vec_, int alloc_ VEC_ASSERT_DECL)                                  \
-{                                                                        \
-  vec_assert (alloc_ >= 0, "space");                                     \
-  return vec_ ? vec_->alloc - vec_->num >= (unsigned)alloc_ : !alloc_;   \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,quick_push)                                   \
-     (VEC(T) *vec_, T obj_ VEC_ASSERT_DECL)                              \
-{                                                                        \
-  T *slot_;                                                              \
-                                                                         \
-  vec_assert (vec_->num < vec_->alloc, "quick_push");                    \
-  slot_ = &vec_->vec[vec_->num++];                                       \
-  *slot_ = obj_;                                                         \
-                                                                         \
-  return slot_;                                                                  \
-}                                                                        \
-                                                                         \
-static inline T VEC_OP (T,pop) (VEC(T) *vec_ VEC_ASSERT_DECL)            \
-{                                                                        \
-  T obj_;                                                                \
-                                                                         \
-  vec_assert (vec_->num, "pop");                                         \
-  obj_ = vec_->vec[--vec_->num];                                         \
-                                                                         \
-  return obj_;                                                           \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,truncate)                                   \
-     (VEC(T) *vec_, unsigned size_ VEC_ASSERT_DECL)                      \
-{                                                                        \
-  vec_assert (vec_ ? vec_->num >= size_ : !size_, "truncate");           \
-  if (vec_)                                                              \
-    vec_->num = size_;                                                   \
-}                                                                        \
-                                                                         \
-static inline T VEC_OP (T,replace)                                       \
-     (VEC(T) *vec_, unsigned ix_, T obj_ VEC_ASSERT_DECL)                \
-{                                                                        \
-  T old_obj_;                                                            \
-                                                                         \
-  vec_assert (ix_ < vec_->num, "replace");                               \
-  old_obj_ = vec_->vec[ix_];                                             \
-  vec_->vec[ix_] = obj_;                                                 \
-                                                                         \
-  return old_obj_;                                                       \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,quick_insert)                                 \
-     (VEC(T) *vec_, unsigned ix_, T obj_ VEC_ASSERT_DECL)                \
-{                                                                        \
-  T *slot_;                                                              \
-                                                                         \
-  vec_assert (vec_->num < vec_->alloc && ix_ <= vec_->num, "quick_insert"); \
-  slot_ = &vec_->vec[ix_];                                               \
-  memmove (slot_ + 1, slot_, (vec_->num++ - ix_) * sizeof (T));                  \
-  *slot_ = obj_;                                                         \
-                                                                         \
-  return slot_;                                                                  \
-}                                                                        \
-                                                                         \
-static inline T VEC_OP (T,ordered_remove)                                \
-     (VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                        \
-{                                                                        \
-  T *slot_;                                                              \
-  T obj_;                                                                \
-                                                                         \
-  vec_assert (ix_ < vec_->num, "ordered_remove");                        \
-  slot_ = &vec_->vec[ix_];                                               \
-  obj_ = *slot_;                                                         \
-  memmove (slot_, slot_ + 1, (--vec_->num - ix_) * sizeof (T));                  \
-                                                                         \
-  return obj_;                                                           \
-}                                                                        \
-                                                                         \
-static inline T VEC_OP (T,unordered_remove)                              \
-     (VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                        \
-{                                                                        \
-  T *slot_;                                                              \
-  T obj_;                                                                \
-                                                                         \
-  vec_assert (ix_ < vec_->num, "unordered_remove");                      \
-  slot_ = &vec_->vec[ix_];                                               \
-  obj_ = *slot_;                                                         \
-  *slot_ = vec_->vec[--vec_->num];                                       \
-                                                                         \
-  return obj_;                                                           \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,block_remove)                               \
-     (VEC(T) *vec_, unsigned ix_, unsigned len_ VEC_ASSERT_DECL)         \
-{                                                                        \
-  T *slot_;                                                              \
-                                                                         \
-  vec_assert (ix_ + len_ <= vec_->num, "block_remove");                          \
-  slot_ = &vec_->vec[ix_];                                               \
-  vec_->num -= len_;                                                     \
-  memmove (slot_, slot_ + len_, (vec_->num - ix_) * sizeof (T));         \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,address)                                      \
-     (VEC(T) *vec_)                                                      \
-{                                                                        \
-  return vec_ ? vec_->vec : 0;                                           \
-}                                                                        \
-                                                                         \
-static inline unsigned VEC_OP (T,lower_bound)                            \
-     (VEC(T) *vec_, const T obj_,                                        \
-      int (*lessthan_)(const T, const T) VEC_ASSERT_DECL)                \
-{                                                                        \
-   unsigned int len_ = VEC_OP (T, length) (vec_);                        \
-   unsigned int half_, middle_;                                                  \
-   unsigned int first_ = 0;                                              \
-   while (len_ > 0)                                                      \
-     {                                                                   \
-        T middle_elem_;                                                          \
-        half_ = len_ >> 1;                                               \
-        middle_ = first_;                                                \
-        middle_ += half_;                                                \
-        middle_elem_ = VEC_OP (T,index) (vec_, middle_ VEC_ASSERT_PASS);  \
-        if (lessthan_ (middle_elem_, obj_))                              \
-          {                                                              \
-             first_ = middle_;                                           \
-             ++first_;                                                   \
-             len_ = len_ - half_ - 1;                                    \
-          }                                                              \
-        else                                                             \
-          len_ = half_;                                                          \
-     }                                                                   \
-   return first_;                                                        \
-}
-
-#define DEF_VEC_ALLOC_FUNC_P(T)                                                  \
-static inline VEC(T) *VEC_OP (T,alloc)                                   \
-     (int alloc_)                                                        \
-{                                                                        \
-  /* We must request exact size allocation, hence the negation.  */      \
-  return (VEC(T) *) vec_p_reserve (NULL, -alloc_);                       \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,free)                                       \
-     (VEC(T) **vec_)                                                     \
-{                                                                        \
-  if (*vec_)                                                             \
-    vec_free_ (*vec_);                                                   \
-  *vec_ = NULL;                                                                  \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,cleanup)                                    \
-     (void *arg_)                                                        \
-{                                                                        \
-  VEC(T) **vec_ = (VEC(T) **) arg_;                                      \
-  if (*vec_)                                                             \
-    vec_free_ (*vec_);                                                   \
-  *vec_ = NULL;                                                                  \
-}                                                                        \
-                                                                         \
-static inline VEC(T) *VEC_OP (T,copy) (VEC(T) *vec_)                     \
-{                                                                        \
-  size_t len_ = vec_ ? vec_->num : 0;                                    \
-  VEC (T) *new_vec_ = NULL;                                              \
-                                                                         \
-  if (len_)                                                              \
-    {                                                                    \
-      /* We must request exact size allocation, hence the negation.  */          \
-      new_vec_ = (VEC (T) *)(vec_p_reserve (NULL, -len_));               \
-                                                                         \
-      new_vec_->num = len_;                                              \
-      memcpy (new_vec_->vec, vec_->vec, sizeof (T) * len_);              \
-    }                                                                    \
-  return new_vec_;                                                       \
-}                                                                        \
-                                                                         \
-static inline VEC(T) *VEC_OP (T,merge) (VEC(T) *vec1_, VEC(T) *vec2_)    \
-{                                                                        \
-  if (vec1_ && vec2_)                                                    \
-    {                                                                    \
-      size_t len_ = vec1_->num + vec2_->num;                             \
-      VEC (T) *new_vec_ = NULL;                                                  \
-                                                                         \
-      /* We must request exact size allocation, hence the negation.  */          \
-      new_vec_ = (VEC (T) *)(vec_p_reserve (NULL, -len_));               \
-                                                                         \
-      new_vec_->num = len_;                                              \
-      memcpy (new_vec_->vec, vec1_->vec, sizeof (T) * vec1_->num);       \
-      memcpy (new_vec_->vec + vec1_->num, vec2_->vec,                    \
-             sizeof (T) * vec2_->num);                                   \
-                                                                         \
-      return new_vec_;                                                   \
-    }                                                                    \
-  else                                                                   \
-    return VEC_copy (T, vec1_ ? vec1_ : vec2_);                                  \
-}                                                                        \
-                                                                         \
-static inline int VEC_OP (T,reserve)                                     \
-     (VEC(T) **vec_, int alloc_ VEC_ASSERT_DECL)                         \
-{                                                                        \
-  int extend = !VEC_OP (T,space)                                         \
-       (*vec_, alloc_ < 0 ? -alloc_ : alloc_ VEC_ASSERT_PASS);           \
-                                                                         \
-  if (extend)                                                            \
-    *vec_ = (VEC(T) *) vec_p_reserve (*vec_, alloc_);                    \
-                                                                         \
-  return extend;                                                         \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,safe_grow)                                          \
-     (VEC(T) **vec_, int size_ VEC_ASSERT_DECL)                                  \
-{                                                                        \
-  vec_assert (size_ >= 0 && VEC_OP(T,length) (*vec_) <= (unsigned)size_,  \
-       "safe_grow");                                                     \
-  VEC_OP (T,reserve)                                                     \
-       (vec_, (int)(*vec_ ? (*vec_)->num : 0) - size_ VEC_ASSERT_PASS);  \
-  (*vec_)->num = size_;                                                          \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,safe_push)                                    \
-     (VEC(T) **vec_, T obj_ VEC_ASSERT_DECL)                             \
-{                                                                        \
-  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
-                                                                         \
-  return VEC_OP (T,quick_push) (*vec_, obj_ VEC_ASSERT_PASS);            \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,safe_insert)                                          \
-     (VEC(T) **vec_, unsigned ix_, T obj_ VEC_ASSERT_DECL)               \
-{                                                                        \
-  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
-                                                                         \
-  return VEC_OP (T,quick_insert) (*vec_, ix_, obj_ VEC_ASSERT_PASS);     \
-}
-
-#define DEF_VEC_FUNC_O(T)                                                \
-static inline unsigned VEC_OP (T,length) (const VEC(T) *vec_)            \
-{                                                                        \
-  return vec_ ? vec_->num : 0;                                           \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,last) (VEC(T) *vec_ VEC_ASSERT_DECL)                  \
-{                                                                        \
-  vec_assert (vec_ && vec_->num, "last");                                \
-                                                                         \
-  return &vec_->vec[vec_->num - 1];                                      \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,index)                                        \
-     (VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                        \
-{                                                                        \
-  vec_assert (vec_ && ix_ < vec_->num, "index");                         \
-                                                                         \
-  return &vec_->vec[ix_];                                                \
-}                                                                        \
-                                                                         \
-static inline int VEC_OP (T,iterate)                                     \
-     (VEC(T) *vec_, unsigned ix_, T **ptr)                               \
-{                                                                        \
-  if (vec_ && ix_ < vec_->num)                                           \
-    {                                                                    \
-      *ptr = &vec_->vec[ix_];                                            \
-      return 1;                                                                  \
-    }                                                                    \
-  else                                                                   \
-    {                                                                    \
-      *ptr = 0;                                                                  \
-      return 0;                                                                  \
-    }                                                                    \
-}                                                                        \
-                                                                         \
-static inline size_t VEC_OP (T,embedded_size)                            \
-     (int alloc_)                                                        \
-{                                                                        \
-  VEC(T) dummy;                                                                  \
-                                                                         \
-  return vec_offset (T, &dummy) + alloc_ * sizeof(T);                    \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,embedded_init)                              \
-     (VEC(T) *vec_, int alloc_)                                                  \
-{                                                                        \
-  vec_->num = 0;                                                         \
-  vec_->alloc = alloc_;                                                          \
-}                                                                        \
-                                                                         \
-static inline int VEC_OP (T,space)                                       \
-     (VEC(T) *vec_, int alloc_ VEC_ASSERT_DECL)                                  \
-{                                                                        \
-  vec_assert (alloc_ >= 0, "space");                                     \
-  return vec_ ? vec_->alloc - vec_->num >= (unsigned)alloc_ : !alloc_;   \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,quick_push)                                   \
-     (VEC(T) *vec_, const T *obj_ VEC_ASSERT_DECL)                       \
-{                                                                        \
-  T *slot_;                                                              \
-                                                                         \
-  vec_assert (vec_->num < vec_->alloc, "quick_push");                    \
-  slot_ = &vec_->vec[vec_->num++];                                       \
-  if (obj_)                                                              \
-    *slot_ = *obj_;                                                      \
-                                                                         \
-  return slot_;                                                                  \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,pop) (VEC(T) *vec_ VEC_ASSERT_DECL)         \
-{                                                                        \
-  vec_assert (vec_->num, "pop");                                         \
-  --vec_->num;                                                           \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,truncate)                                   \
-     (VEC(T) *vec_, unsigned size_ VEC_ASSERT_DECL)                      \
-{                                                                        \
-  vec_assert (vec_ ? vec_->num >= size_ : !size_, "truncate");           \
-  if (vec_)                                                              \
-    vec_->num = size_;                                                   \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,replace)                                      \
-     (VEC(T) *vec_, unsigned ix_, const T *obj_ VEC_ASSERT_DECL)         \
-{                                                                        \
-  T *slot_;                                                              \
-                                                                         \
-  vec_assert (ix_ < vec_->num, "replace");                               \
-  slot_ = &vec_->vec[ix_];                                               \
-  if (obj_)                                                              \
-    *slot_ = *obj_;                                                      \
-                                                                         \
-  return slot_;                                                                  \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,quick_insert)                                 \
-     (VEC(T) *vec_, unsigned ix_, const T *obj_ VEC_ASSERT_DECL)         \
-{                                                                        \
-  T *slot_;                                                              \
-                                                                         \
-  vec_assert (vec_->num < vec_->alloc && ix_ <= vec_->num, "quick_insert"); \
-  slot_ = &vec_->vec[ix_];                                               \
-  memmove (slot_ + 1, slot_, (vec_->num++ - ix_) * sizeof (T));                  \
-  if (obj_)                                                              \
-    *slot_ = *obj_;                                                      \
-                                                                         \
-  return slot_;                                                                  \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,ordered_remove)                             \
-     (VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                        \
-{                                                                        \
-  T *slot_;                                                              \
-                                                                         \
-  vec_assert (ix_ < vec_->num, "ordered_remove");                        \
-  slot_ = &vec_->vec[ix_];                                               \
-  memmove (slot_, slot_ + 1, (--vec_->num - ix_) * sizeof (T));                  \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,unordered_remove)                           \
-     (VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                        \
-{                                                                        \
-  vec_assert (ix_ < vec_->num, "unordered_remove");                      \
-  vec_->vec[ix_] = vec_->vec[--vec_->num];                               \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,block_remove)                               \
-     (VEC(T) *vec_, unsigned ix_, unsigned len_ VEC_ASSERT_DECL)         \
-{                                                                        \
-  T *slot_;                                                              \
-                                                                         \
-  vec_assert (ix_ + len_ <= vec_->num, "block_remove");                          \
-  slot_ = &vec_->vec[ix_];                                               \
-  vec_->num -= len_;                                                     \
-  memmove (slot_, slot_ + len_, (vec_->num - ix_) * sizeof (T));         \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,address)                                      \
-     (VEC(T) *vec_)                                                      \
-{                                                                        \
-  return vec_ ? vec_->vec : 0;                                           \
-}                                                                        \
-                                                                         \
-static inline unsigned VEC_OP (T,lower_bound)                            \
-     (VEC(T) *vec_, const T *obj_,                                       \
-      int (*lessthan_)(const T *, const T *) VEC_ASSERT_DECL)            \
-{                                                                        \
-   unsigned int len_ = VEC_OP (T, length) (vec_);                        \
-   unsigned int half_, middle_;                                                  \
-   unsigned int first_ = 0;                                              \
-   while (len_ > 0)                                                      \
-     {                                                                   \
-        T *middle_elem_;                                                 \
-        half_ = len_ >> 1;                                               \
-        middle_ = first_;                                                \
-        middle_ += half_;                                                \
-        middle_elem_ = VEC_OP (T,index) (vec_, middle_ VEC_ASSERT_PASS);  \
-        if (lessthan_ (middle_elem_, obj_))                              \
-          {                                                              \
-             first_ = middle_;                                           \
-             ++first_;                                                   \
-             len_ = len_ - half_ - 1;                                    \
-          }                                                              \
-        else                                                             \
-          len_ = half_;                                                          \
-     }                                                                   \
-   return first_;                                                        \
-}
-
-#define DEF_VEC_ALLOC_FUNC_O(T)                                                  \
-static inline VEC(T) *VEC_OP (T,alloc)                                   \
-     (int alloc_)                                                        \
-{                                                                        \
-  VEC(T) dummy;                                                                  \
-                                                                         \
-  /* We must request exact size allocation, hence the negation.  */      \
-  return (VEC(T) *) vec_o_reserve (NULL, -alloc_,                        \
-                                   vec_offset (T, &dummy), sizeof (T));          \
-}                                                                        \
-                                                                         \
-static inline VEC(T) *VEC_OP (T,copy) (VEC(T) *vec_)                     \
-{                                                                        \
-  size_t len_ = vec_ ? vec_->num : 0;                                    \
-  VEC (T) *new_vec_ = NULL;                                              \
-                                                                         \
-  if (len_)                                                              \
-    {                                                                    \
-      VEC(T) dummy;                                                      \
-                                                                         \
-      /* We must request exact size allocation, hence the negation.  */          \
-      new_vec_ = (VEC (T) *)                                             \
-       vec_o_reserve  (NULL, -len_, vec_offset (T, &dummy), sizeof (T)); \
-                                                                         \
-      new_vec_->num = len_;                                              \
-      memcpy (new_vec_->vec, vec_->vec, sizeof (T) * len_);              \
-    }                                                                    \
-  return new_vec_;                                                       \
-}                                                                        \
-                                                                         \
-static inline VEC(T) *VEC_OP (T,merge) (VEC(T) *vec1_, VEC(T) *vec2_)    \
-{                                                                        \
-  if (vec1_ && vec2_)                                                    \
-    {                                                                    \
-      VEC(T) dummy;                                                      \
-      size_t len_ = vec1_->num + vec2_->num;                             \
-      VEC (T) *new_vec_ = NULL;                                                  \
-                                                                         \
-      /* We must request exact size allocation, hence the negation.  */          \
-      new_vec_ = (VEC (T) *)                                             \
-       vec_o_reserve (NULL, -len_, vec_offset (T, &dummy), sizeof (T));  \
-                                                                         \
-      new_vec_->num = len_;                                              \
-      memcpy (new_vec_->vec, vec1_->vec, sizeof (T) * vec1_->num);       \
-      memcpy (new_vec_->vec + vec1_->num, vec2_->vec,                    \
-             sizeof (T) * vec2_->num);                                   \
-                                                                         \
-      return new_vec_;                                                   \
-    }                                                                    \
-  else                                                                   \
-    return VEC_copy (T, vec1_ ? vec1_ : vec2_);                                  \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,free)                                       \
-     (VEC(T) **vec_)                                                     \
-{                                                                        \
-  if (*vec_)                                                             \
-    vec_free_ (*vec_);                                                   \
-  *vec_ = NULL;                                                                  \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,cleanup)                                    \
-     (void *arg_)                                                        \
-{                                                                        \
-  VEC(T) **vec_ = (VEC(T) **) arg_;                                      \
-  if (*vec_)                                                             \
-    vec_free_ (*vec_);                                                   \
-  *vec_ = NULL;                                                                  \
-}                                                                        \
-                                                                         \
-static inline int VEC_OP (T,reserve)                                     \
-     (VEC(T) **vec_, int alloc_ VEC_ASSERT_DECL)                         \
-{                                                                        \
-  VEC(T) dummy;                                                                  \
-  int extend = !VEC_OP (T,space) (*vec_, alloc_ < 0 ? -alloc_ : alloc_   \
-                                 VEC_ASSERT_PASS);                       \
-                                                                         \
-  if (extend)                                                            \
-    *vec_ = (VEC(T) *)                                                   \
-      vec_o_reserve (*vec_, alloc_, vec_offset (T, &dummy), sizeof (T));  \
-                                                                         \
-  return extend;                                                         \
-}                                                                        \
-                                                                         \
-static inline void VEC_OP (T,safe_grow)                                          \
-     (VEC(T) **vec_, int size_ VEC_ASSERT_DECL)                                  \
-{                                                                        \
-  vec_assert (size_ >= 0 && VEC_OP(T,length) (*vec_) <= (unsigned)size_,  \
-       "safe_grow");                                                     \
-  VEC_OP (T,reserve)                                                     \
-       (vec_, (int)(*vec_ ? (*vec_)->num : 0) - size_ VEC_ASSERT_PASS);  \
-  (*vec_)->num = size_;                                                          \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,safe_push)                                    \
-     (VEC(T) **vec_, const T *obj_ VEC_ASSERT_DECL)                      \
-{                                                                        \
-  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
-                                                                         \
-  return VEC_OP (T,quick_push) (*vec_, obj_ VEC_ASSERT_PASS);            \
-}                                                                        \
-                                                                         \
-static inline T *VEC_OP (T,safe_insert)                                          \
-     (VEC(T) **vec_, unsigned ix_, const T *obj_ VEC_ASSERT_DECL)        \
-{                                                                        \
-  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
-                                                                         \
-  return VEC_OP (T,quick_insert) (*vec_, ix_, obj_ VEC_ASSERT_PASS);     \
-}
-
-#endif /* COMMON_VEC_H */
diff --git a/gdb/common/version.h b/gdb/common/version.h
deleted file mode 100644 (file)
index 9e840e7..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Version information for GDB.
-   Copyright (C) 1999-2019 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/>.  */
-
-#ifndef COMMON_VERSION_H
-#define COMMON_VERSION_H
-
-/* Version number of GDB, as a string.  */
-extern const char version[];
-
-/* Canonical host name as a string.  */
-extern const char host_name[];
-
-/* Canonical target name as a string.  */
-extern const char target_name[];
-
-#endif /* COMMON_VERSION_H */
diff --git a/gdb/common/x86-xstate.h b/gdb/common/x86-xstate.h
deleted file mode 100644 (file)
index 4ce8f61..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* Common code for x86 XSAVE extended state.
-
-   Copyright (C) 2010-2019 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/>.  */
-
-#ifndef COMMON_X86_XSTATE_H
-#define COMMON_X86_XSTATE_H
-
-/* The extended state feature bits.  */
-#define X86_XSTATE_X87         (1ULL << 0)
-#define X86_XSTATE_SSE         (1ULL << 1)
-#define X86_XSTATE_AVX         (1ULL << 2)
-#define X86_XSTATE_BNDREGS     (1ULL << 3)
-#define X86_XSTATE_BNDCFG      (1ULL << 4)
-#define X86_XSTATE_MPX         (X86_XSTATE_BNDREGS | X86_XSTATE_BNDCFG)
-
-/* AVX 512 adds three feature bits.  All three must be enabled.  */
-#define X86_XSTATE_K           (1ULL << 5)
-#define X86_XSTATE_ZMM_H       (1ULL << 6)
-#define X86_XSTATE_ZMM         (1ULL << 7)
-#define X86_XSTATE_AVX512      (X86_XSTATE_K | X86_XSTATE_ZMM_H \
-                                | X86_XSTATE_ZMM)
-
-#define X86_XSTATE_PKRU                (1ULL << 9)
-
-/* Supported mask and size of the extended state.  */
-#define X86_XSTATE_X87_MASK    X86_XSTATE_X87
-#define X86_XSTATE_SSE_MASK    (X86_XSTATE_X87 | X86_XSTATE_SSE)
-#define X86_XSTATE_AVX_MASK    (X86_XSTATE_SSE_MASK | X86_XSTATE_AVX)
-#define X86_XSTATE_MPX_MASK    (X86_XSTATE_SSE_MASK | X86_XSTATE_MPX)
-#define X86_XSTATE_AVX_MPX_MASK        (X86_XSTATE_AVX_MASK | X86_XSTATE_MPX)
-#define X86_XSTATE_AVX_AVX512_MASK     (X86_XSTATE_AVX_MASK | X86_XSTATE_AVX512)
-#define X86_XSTATE_AVX_MPX_AVX512_PKU_MASK     (X86_XSTATE_AVX_MPX_MASK\
-                                       | X86_XSTATE_AVX512 | X86_XSTATE_PKRU)
-
-#define X86_XSTATE_ALL_MASK            (X86_XSTATE_AVX_MPX_AVX512_PKU_MASK)
-
-
-#define X86_XSTATE_SSE_SIZE    576
-#define X86_XSTATE_AVX_SIZE    832
-#define X86_XSTATE_BNDREGS_SIZE        1024
-#define X86_XSTATE_BNDCFG_SIZE 1088
-#define X86_XSTATE_AVX512_SIZE 2688
-#define X86_XSTATE_PKRU_SIZE   2696
-#define X86_XSTATE_MAX_SIZE    2696
-
-
-/* In case one of the MPX XCR0 bits is set we consider we have MPX.  */
-#define HAS_MPX(XCR0) (((XCR0) & X86_XSTATE_MPX) != 0)
-#define HAS_AVX(XCR0) (((XCR0) & X86_XSTATE_AVX) != 0)
-#define HAS_AVX512(XCR0) (((XCR0) & X86_XSTATE_AVX512) != 0)
-#define HAS_PKRU(XCR0) (((XCR0) & X86_XSTATE_PKRU) != 0)
-
-/* Get I386 XSAVE extended state size.  */
-#define X86_XSTATE_SIZE(XCR0) \
-    (HAS_PKRU (XCR0) ? X86_XSTATE_PKRU_SIZE : \
-     (HAS_AVX512 (XCR0) ? X86_XSTATE_AVX512_SIZE : \
-      (HAS_MPX (XCR0) ? X86_XSTATE_BNDCFG_SIZE : \
-       (HAS_AVX (XCR0) ? X86_XSTATE_AVX_SIZE : X86_XSTATE_SSE_SIZE))))
-
-/* Initial value for fctrl register, as defined in the X86 manual, and
-   confirmed in the (Linux) kernel source.  When the x87 floating point
-   feature is not enabled in an inferior we use this as the value of the
-   fcrtl register.  */
-
-#define I387_FCTRL_INIT_VAL 0x037f
-
-/* Initial value for mxcsr register.  When the avx and sse floating point
-   features are not enabled in an inferior we use this as the value of the
-   mxcsr register.  */
-
-#define I387_MXCSR_INIT_VAL 0x1f80
-
-#endif /* COMMON_X86_XSTATE_H */
diff --git a/gdb/common/xml-utils.c b/gdb/common/xml-utils.c
deleted file mode 100644 (file)
index 79f040e..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Shared helper routines for manipulating XML.
-
-   Copyright (C) 2006-2019 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 "common-defs.h"
-#include "xml-utils.h"
-
-/* See xml-utils.h.  */
-
-std::string
-xml_escape_text (const char *text)
-{
-  std::string result;
-
-  xml_escape_text_append (&result, text);
-
-  return result;
-}
-
-/* See xml-utils.h.  */
-
-void
-xml_escape_text_append (std::string *result, const char *text)
-{
-  /* Expand the result.  */
-  for (int i = 0; text[i] != '\0'; i++)
-    switch (text[i])
-      {
-      case '\'':
-       *result += "&apos;";
-       break;
-      case '\"':
-       *result += "&quot;";
-       break;
-      case '&':
-       *result += "&amp;";
-       break;
-      case '<':
-       *result += "&lt;";
-       break;
-      case '>':
-       *result += "&gt;";
-       break;
-      default:
-       *result += text[i];
-       break;
-      }
-}
diff --git a/gdb/common/xml-utils.h b/gdb/common/xml-utils.h
deleted file mode 100644 (file)
index 747e8c8..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Shared helper routines for manipulating XML.
-
-   Copyright (C) 2006-2019 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/>.  */
-
-#ifndef COMMON_XML_UTILS_H
-#define COMMON_XML_UTILS_H
-
-/* Return a string with special characters from TEXT replaced by entity
-   references.  */
-
-extern std::string xml_escape_text (const char *text);
-
-/* Append TEXT to RESULT, with special characters replaced by entity
-   references.  */
-
-extern void xml_escape_text_append (std::string *result, const char *text);
-
-#endif /* COMMON_XML_UTILS_H */
index d1947da6570bc655f578e3eb87d98d462dd5ede0..0f50c0910387b8d9e8c399196a48b9a781b7d46b 100644 (file)
@@ -27,8 +27,8 @@
 #include "macrotab.h"
 #include "macroscope.h"
 #include "regcache.h"
-#include "common/function-view.h"
-#include "common/preprocessor.h"
+#include "gdbsupport/function-view.h"
+#include "gdbsupport/preprocessor.h"
 
 /* See compile-internal.h.  */
 
index b5a2194dbbbd5ae6461f3ddb44c3f4d59ee39489..4b65d46d5c6fb1113d3fd492c3cc3676d7436c1d 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef COMPILE_COMPILE_C_H
 #define COMPILE_COMPILE_C_H
 
-#include "common/enum-flags.h"
+#include "gdbsupport/enum-flags.h"
 #include "gcc-c-plugin.h"
 
 /* enum-flags wrapper.  */
index 98133afd7cda12854b4aac0f4986c84028d99242..201c4479f0936367bbce31f0f0e76294c034f15a 100644 (file)
@@ -21,7 +21,7 @@
 #include "defs.h"
 #include "compile-internal.h"
 #include "compile-cplus.h"
-#include "common/gdb_assert.h"
+#include "gdbsupport/gdb_assert.h"
 #include "symtab.h"
 #include "parser-defs.h"
 #include "block.h"
index d7aef265cf820800e6671f9ccef0712f7f4c162f..3a7c8b01f7d0906c87bcdc92262684e845f2c1b8 100644 (file)
 
 
 #include "defs.h"
-#include "common/preprocessor.h"
+#include "gdbsupport/preprocessor.h"
 #include "gdbtypes.h"
 #include "compile-internal.h"
 #include "compile-cplus.h"
-#include "common/gdb_assert.h"
+#include "gdbsupport/gdb_assert.h"
 #include "symtab.h"
 #include "source.h"
 #include "cp-support.h"
index e5ea7d7c81acd446f66360728af82e6faf673048..d58e030b5a2345837ef72dbf9d342a350fc659c9 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef COMPILE_COMPILE_CPLUS_H
 #define COMPILE_COMPILE_CPLUS_H
 
-#include "common/enum-flags.h"
+#include "gdbsupport/enum-flags.h"
 #include "gcc-cp-plugin.h"
 
 struct type;
index b5682d80a5537674e504a5e3ca7433a2dc6d44c0..9ca10b772105c438ca6f07b3d0b67000fcf8e24c 100644 (file)
@@ -28,7 +28,7 @@
 #include "compile.h"
 #include "block.h"
 #include "dwarf2-frame.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 #include "value.h"
 
 \f
index 25d0bfe60223a4d3f7214a03fc901fb40dcf1c34..4c0721daa677df31cef3d893f58b1e319ea0df68 100644 (file)
 #include "source.h"
 #include "block.h"
 #include "arch-utils.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "target.h"
 #include "osabi.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include "valprint.h"
-#include "common/gdb_optional.h"
-#include "common/gdb_unlinker.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/gdb_optional.h"
+#include "gdbsupport/gdb_unlinker.h"
+#include "gdbsupport/pathstuff.h"
 
 \f
 
index 6892a62bb914ff55f9762322750676ad5a29d757..07facfb012c1e0a196c784cb65108d028640338b 100644 (file)
@@ -22,7 +22,7 @@
 #include "expression.h"
 #include "filenames.h"         /* For DOSish file names.  */
 #include "language.h"
-#include "common/gdb_signals.h"
+#include "gdbsupport/gdb_signals.h"
 #include "target.h"
 #include "reggroups.h"
 #include "user-regs.h"
index 9f8ec47c9f13326073132cd1809318c077af0a89..313010fce2280c1b90aa637453deff7b0ad4f5ce 100644 (file)
@@ -17,7 +17,7 @@
 #if !defined (COMPLETER_H)
 #define COMPLETER_H 1
 
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 #include "command.h"
 
 /* Types of functions in struct match_list_displayer.  */
index 361f3cc95bb3ffb8f2dfba87f502baa10f538a15..12954d1f74ae570b2bba27ecf1ff70b3ea1ae820 100755 (executable)
@@ -6545,7 +6545,7 @@ fi
 . $srcdir/configure.host
 
 # Add in the common host objects.
-. $srcdir/common/common.host
+. $srcdir/gdbsupport/common.host
 gdb_host_obs="$gdb_host_obs $common_host_obs"
 
 # Accumulate some settings from configure.tgt over all enabled targets
@@ -17715,8 +17715,8 @@ if $enable_unittests; then
 $as_echo "#define GDB_SELF_TEST 1" >>confdefs.h
 
 
-  CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) common/selftest.o selftest-arch.o"
-  CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) common/selftest.c selftest-arch.c"
+  CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) gdbsupport/selftest.o selftest-arch.o"
+  CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) gdbsupport/selftest.c selftest-arch.c"
 
 fi
 
index 275f08d2a70fbc7c269b964050548328c42a13a8..2a43d12df761aa445ba086a8797e69f19c2daa2d 100644 (file)
@@ -178,7 +178,7 @@ fi
 . $srcdir/configure.host
 
 # Add in the common host objects.
-. $srcdir/common/common.host
+. $srcdir/gdbsupport/common.host
 gdb_host_obs="$gdb_host_obs $common_host_obs"
 
 # Accumulate some settings from configure.tgt over all enabled targets
@@ -2256,8 +2256,8 @@ AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
           [Define to be a string naming the default host character set.])
 
 GDB_AC_SELFTEST([
-  CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) common/selftest.o selftest-arch.o"
-  CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) common/selftest.c selftest-arch.c"
+  CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) gdbsupport/selftest.o selftest-arch.o"
+  CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) gdbsupport/selftest.c selftest-arch.c"
 ])
 
 GDB_AC_TRANSFORM([gdb], [GDB_TRANSFORM_NAME])
index 597d08849e5022b202ff2e72aaaef2a1555e92a2..895654150b37a833fb43a391478d56da4f4bc66c 100755 (executable)
@@ -334,7 +334,7 @@ Do not include gnu-regex.h, instead include gdb_regex.h"
 
 BEGIN { doc["wait.h"] = "\
 Do not include wait.h or sys/wait.h, instead include gdb_wait.h"
-    fix("wait.h", "common/gdb_wait.h", 2);
+    fix("wait.h", "gdbsupport/gdb_wait.h", 2);
     category["wait.h"] = ari_regression
 }
 /^#[[:space:]]*include[[:space:]]*.wait\.h./ \
@@ -446,7 +446,7 @@ Do not use PARAMS(), ISO C 90 implies prototypes"
 BEGIN { doc["__func__"] = "\
 Do not use __func__, ISO C 90 does not support this macro"
     category["__func__"] = ari_regression
-    fix("__func__", "common/gdb_assert.h", 1)
+    fix("__func__", "gdbsupport/gdb_assert.h", 1)
 }
 /(^|[^_[:alnum:]])__func__([^_[:alnum:]]|$)/ {
     fail("__func__")
@@ -593,8 +593,8 @@ BEGIN { doc["strerror"] = "\
 Do not use strerror(), instead use safe_strerror()"
     category["strerror"] = ari_regression
     fix("strerror", "gdb/gdb_string.h", 1)
-    fix("strerror", "gdb/common/mingw-strerror.c", 1)
-    fix("strerror", "gdb/common/posix-strerror.c", 1)
+    fix("strerror", "gdb/gdbsupport/mingw-strerror.c", 1)
+    fix("strerror", "gdb/gdbsupport/posix-strerror.c", 1)
 }
 /(^|[^_[:alnum:]])strerror[[:space:]]*\(/ {
     fail("strerror")
@@ -1080,7 +1080,7 @@ Do not use asprintf(), instead use xstrprintf()"
 
 BEGIN { doc["vasprintf"] = "\
 Do not use vasprintf(), instead use xstrvprintf"
-    fix("vasprintf", "common/common-utils.c", 1)
+    fix("vasprintf", "gdbsupport/common-utils.c", 1)
     category["vasprintf"] = ari_regression
 }
 /(^|[^_[:alnum:]])vasprintf[[:space:]]*\(/ {
index bf859fbbb8d8641f9c631aa510e6ed59fdfe78be..4fe8606a22dec09f922058d6ed1a37422e406b30 100644 (file)
@@ -138,7 +138,7 @@ validate_files (void)
     }
 }
 
-/* See common/common-inferior.h.  */
+/* See gdbsupport/common-inferior.h.  */
 
 char *
 get_exec_file (int err)
index 9fcc2d23727203a9b788bfa3b7503b2ffd92a11a..c0e5ad12eab012a306bd8ed0406bd64ca44f1bf5 100644 (file)
@@ -42,7 +42,7 @@
 #include "objfiles.h"
 #include "gdb_bfd.h"
 #include "completer.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 
 #ifndef O_LARGEFILE
 #define O_LARGEFILE 0
index 9ba6ee3ede537f2383f73ba9473905f9cfefc278..562c6f155c7f48fc6dbf445ca0447213b13eb845 100644 (file)
@@ -34,9 +34,9 @@
 #include "cp-abi.h"
 #include "namespace.h"
 #include <signal.h>
-#include "common/gdb_setjmp.h"
+#include "gdbsupport/gdb_setjmp.h"
 #include "safe-ctype.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 
 #define d_left(dc) (dc)->u.s_binary.left
 #define d_right(dc) (dc)->u.s_binary.right
index c2e63ea0de3f3b1d8973113df3d1a4a6afa33144..987850730ac10ddf559f5109a3a543f82ab06aa0 100644 (file)
 /* We need this for 'domain_enum', alas...  */
 
 #include "symtab.h"
-#include "common/vec.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/vec.h"
+#include "gdbsupport/gdb_vecs.h"
 #include "gdb_obstack.h"
-#include "common/array-view.h"
+#include "gdbsupport/array-view.h"
 #include <vector>
 
 /* Opaque declarations.  */
index d3a38d885d86639044420d9112a048a9a6d15b71..c8472d94b24c49a6bce704b41692f1520474e536 100644 (file)
@@ -35,7 +35,7 @@
 #include "language.h"
 #include "extension.h"
 #include "typeprint.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 
 static struct obstack dont_print_vb_obstack;
 static struct obstack dont_print_statmem_obstack;
index cd7d8c5a0b116e48fa8a66f3ef181f35c3005f80..54b856af067ddc23589a486d9c6ab835defe8f49 100644 (file)
@@ -20,7 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/gdb_assert.h"
+#include "gdbsupport/gdb_assert.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
index 7a95df781524eab179888b99ab06a5ea18be5de4..cc714f00e2c349d5a32395a1b7b49e3ef4a0b08d 100644 (file)
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -31,7 +31,7 @@
 #include "tracefile.h"
 #include <ctype.h>
 #include <algorithm>
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 
 /* The CTF target.  */
 
index d2cb683c572c914a3e6f4c591cd5e36ead4b6c8c..f890e13944c5e52cbbad6258ba2ea4e0be32de0e 100644 (file)
 
 #include "darwin-nat.h"
 #include "filenames.h"
-#include "common/filestuff.h"
-#include "common/gdb_unlinker.h"
-#include "common/pathstuff.h"
-#include "common/scoped_fd.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/gdb_unlinker.h"
+#include "gdbsupport/pathstuff.h"
+#include "gdbsupport/scoped_fd.h"
 #include "nat/fork-inferior.h"
 
 /* Quick overview.
index 5926503e742e68e1f389a22dd89a21cb8aab0444..5907ed1510454f388c1e7f33aa421fa17360e3b4 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "defs.h"
 
-/* See common/common-debug.h.  */
+/* See gdbsupport/common-debug.h.  */
 
 void
 debug_vprintf (const char *fmt, va_list ap)
index 81ab74c27f5df7da5558d19f07cf6e4922bfaf6c..a400722a970108da1b6224ed65b92f06e372245b 100644 (file)
@@ -25,7 +25,7 @@
 #  error gdbserver should not include gdb/defs.h
 #endif
 
-#include "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 
 #include <sys/types.h>
 #include <limits.h>
@@ -52,8 +52,8 @@
 
 #include "ui-file.h"
 
-#include "common/host-defs.h"
-#include "common/enum-flags.h"
+#include "gdbsupport/host-defs.h"
+#include "gdbsupport/enum-flags.h"
 
 /* Scope types enumerator.  List the types of scopes the compiler will
    accept.  */
index e0d84d981eebc603ace6a954a5173b84220d8ab3..9991796cc0af69ad0bf47fd24a9b491daac7fe5a 100644 (file)
@@ -21,7 +21,7 @@
 #include "disasm.h"
 
 #if GDB_SELF_TEST
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 
 namespace selftests {
index 4e58cb67f9310c17017e68486fda33eb91891f9d..4e51bc5f6f665d7e33efdc0e2c8473b6c521c55c 100644 (file)
@@ -29,7 +29,7 @@
 #include "source.h"
 #include "safe-ctype.h"
 #include <algorithm>
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 #include "valprint.h"
 
 /* Disassemble functions.
index d3cc6312093c53dc40d8043960a3eed2b9854f31..a9cfb21f8723f9117f74aa8211b66a653889dc78 100644 (file)
@@ -20,7 +20,7 @@
 #define DISASM_H
 
 #include "dis-asm.h"
-#include "common/enum-flags.h"
+#include "gdbsupport/enum-flags.h"
 
 enum gdb_disassembly_flag
   {
index 2a2eae1f709ba53f2448d6bb53074024cbbc75d0..2d92edb11cd37ffab01c6e45d2b4e5c32ca611d2 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "defs.h"
 #include "probe.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "elf-bfd.h"
 #include "gdbtypes.h"
 #include "obstack.h"
index d01790149351187f0b220d69eed081658c47c81a..f003022b72a3acc9010c1d19c95110f114fa9bd5 100644 (file)
 #include "build-id.h"
 #include "cli/cli-cmds.h"
 #include "command.h"
-#include "common/scoped_mmap.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/scoped_mmap.h"
+#include "gdbsupport/pathstuff.h"
 #include "dwarf-index-write.h"
 #include "dwarf2read.h"
 #include "objfiles.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include <string>
 #include <stdlib.h>
 
index 2f2676321410b1b41c678dc711cd56e7ca17de64..5ff09ff551ccba61b9918aab10dfc7c3be73fc72 100644 (file)
@@ -21,7 +21,7 @@
 #define DWARF_INDEX_CACHE_H
 
 #include "dwarf-index-common.h"
-#include "common/array-view.h"
+#include "gdbsupport/array-view.h"
 #include "symfile.h"
 
 /* Base of the classes used to hold the resources of the indices loaded from
index 3f5862aeb4ca2167babbb22a87d08e183752539d..7d59a1ba160aafac7aeff9093b0f46338413706e 100644 (file)
 
 #include "addrmap.h"
 #include "cli/cli-decode.h"
-#include "common/byte-vector.h"
-#include "common/filestuff.h"
-#include "common/gdb_unlinker.h"
-#include "common/pathstuff.h"
-#include "common/scoped_fd.h"
+#include "gdbsupport/byte-vector.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/gdb_unlinker.h"
+#include "gdbsupport/pathstuff.h"
+#include "gdbsupport/scoped_fd.h"
 #include "complaints.h"
 #include "dwarf-index-common.h"
 #include "dwarf2.h"
index 0f2502b4c6830ecbbbaee0add10d69ace21b285c..cad6b7b0ce0d4ada72d919ccd0f581a4fdc2e5ea 100644 (file)
@@ -40,7 +40,7 @@
 #include "dwarf2loc.h"
 #include "dwarf2-frame-tailcall.h"
 #if GDB_SELF_TEST
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #endif
 
index 3bd9abc4401e4d555704bb27987c9487a72571e1..6d919600e84b195889cfa98e15ebc1b70d9f811f 100644 (file)
@@ -27,7 +27,7 @@
 #include "dwarf2.h"
 #include "dwarf2expr.h"
 #include "dwarf2loc.h"
-#include "common/underlying.h"
+#include "gdbsupport/underlying.h"
 
 /* Cookie for gdbarch data.  */
 
index 37cda40ecf35e8f9257b0e8899ed67477a215fbf..83ff1f45d5a9752a6aba25aadce2e78f0efa5bf7 100644 (file)
 #include "dwarf2read.h"
 #include "dwarf2-frame.h"
 #include "compile/compile.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include <algorithm>
 #include <vector>
 #include <unordered_set>
-#include "common/underlying.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/underlying.h"
+#include "gdbsupport/byte-vector.h"
 
 extern int dwarf_always_disassemble;
 
index f1fbba43fade3db9b68ca2d66e07193b357ee615..f4796776db8349c646892afe93361ed6e45ad830 100644 (file)
@@ -58,7 +58,7 @@
 #include "psympriv.h"
 #include <sys/stat.h>
 #include "completer.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "c-lang.h"
 #include "go-lang.h"
 #include "valprint.h"
 #include "gdb_bfd.h"
 #include "f-lang.h"
 #include "source.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "build-id.h"
 #include "namespace.h"
-#include "common/gdb_unlinker.h"
-#include "common/function-view.h"
-#include "common/gdb_optional.h"
-#include "common/underlying.h"
-#include "common/byte-vector.h"
-#include "common/hash_enum.h"
+#include "gdbsupport/gdb_unlinker.h"
+#include "gdbsupport/function-view.h"
+#include "gdbsupport/gdb_optional.h"
+#include "gdbsupport/underlying.h"
+#include "gdbsupport/byte-vector.h"
+#include "gdbsupport/hash_enum.h"
 #include "filename-seen-cache.h"
 #include "producer.h"
 #include <fcntl.h>
 #include <algorithm>
 #include <unordered_set>
 #include <unordered_map>
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include <cmath>
 #include <set>
 #include <forward_list>
 #include "rust-lang.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 
 /* When == 1, print basic high level tracing messages.
    When > 1, be more verbose.
index 9251bde125926bcb7d5d81d0a664f2b65012f47c..8939f97af5306bb7524b56335df83bd470edd0bf 100644 (file)
@@ -24,7 +24,7 @@
 #include "dwarf-index-cache.h"
 #include "filename-seen-cache.h"
 #include "gdb_obstack.h"
-#include "common/hash_enum.h"
+#include "gdbsupport/hash_enum.h"
 
 /* Hold 'maintenance (set|show) dwarf' commands.  */
 extern struct cmd_list_element *set_dwarf_cmdlist;
index caeb5f38d9b5b65f467dc8610724c2b9b71d9aaa..affa00b4aa960ac50e168517e977e23ee4d807bd 100644 (file)
@@ -31,7 +31,7 @@
 #endif
 
 #include <sys/types.h>
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 #include "gdb_select.h"
 #include "observable.h"
 #include "top.h"
index 3facb38aae8282acf160d45301eaef525f7e98cf..2132fb550dc261825914d51a7da28ea8c6bce02c 100644 (file)
@@ -37,7 +37,7 @@
 #include "gdbcmd.h"            /* for dont_repeat() */
 #include "annotate.h"
 #include "maint.h"
-#include "common/buffer.h"
+#include "gdbsupport/buffer.h"
 #include "ser-event.h"
 #include "gdb_select.h"
 
index ebdc71d98d40af59b086fceb4bccbc3bc710b3df..a4059472574b6958a6218eaac7e9c69423d940b0 100644 (file)
@@ -27,7 +27,7 @@
 #include "serial.h"
 #include "gdbthread.h"
 #include "top.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 
 static void
 print_flush (void)
index 7de92347f2eee516cb8db2aa6b70a89c7ffd8947..3098fcaadd5c5ca5e8819d8ccbfcc57ec4a5765a 100644 (file)
@@ -45,7 +45,7 @@
 #include <sys/stat.h>
 #include "solist.h"
 #include <algorithm>
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 
 void (*deprecated_file_changed_hook) (const char *);
 
index 2f1b71851c67665c83125b905ac9ba4accfa3e2c..5e914f5d011bbcc7f396101363553f7c91172301 100644 (file)
@@ -21,8 +21,8 @@
 #define EXTENSION_H
 
 #include "mi/mi-cmds.h" /* For PRINT_NO_VALUES, etc.  */
-#include "common/vec.h"
-#include "common/array-view.h"
+#include "gdbsupport/vec.h"
+#include "gdbsupport/array-view.h"
 
 struct breakpoint;
 struct command_line;
index d4f4c8cf3592b5eaf61ccdd7b3514287feef9d54..b5be0b7a3df1be9799664a6314b6dff706b8d612 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "regset.h"
 #include "gdbcmd.h"
 #include "gdbthread.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include "inf-ptrace.h"
 #include <sys/types.h>
 #include <sys/procfs.h>
@@ -37,7 +37,7 @@
 #include <libutil.h>
 #endif
 #if !defined(HAVE_KINFO_GETVMMAP)
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #endif
 
 #include "elf-bfd.h"
index c6e1910be07553e19d5c80bd6742896bdfe931cb..a080a641c45f55cb020f85da5411475c1d13ac44 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: aarch64-core.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_aarch64_core (struct target_desc *result, long regnum)
index b73d12ebe4880e0c03cc8cd01e24dd3efe2c040a..87e394656fccc5803456d358cc147efe52dd2ebc 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: aarch64-fpu.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_aarch64_fpu (struct target_desc *result, long regnum)
index e4b84ffb552fcf8b2939b288bc615d3c52598a92..931e6cb28410eb9b81759d77057396bb7e867af7 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: aarch64-pauth.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_aarch64_pauth (struct target_desc *result, long regnum)
index ae292d2f3da50291587a6cdfbca6bc789430ce19..9c7f56d80d855044239d65cc4f14281236a7803f 100644 (file)
@@ -15,7 +15,7 @@
    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 "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 /* This function is NOT auto generated from xml.  Create the aarch64 with SVE
    feature into RESULT, where SCALE is the number of 128 bit chunks in a Z
index b9feac377cf696efbabc417895788081ac3bfb32..32ca7a0f0788d64665da6111ff188700a624e424 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-avx.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_32bit_avx (struct target_desc *result, long regnum)
index 51a403259db2dbae7524df606f6c03bd0f03f5cb..96d0e068bd253f2a26d37f3f98889f4468730bae 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-avx512.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_32bit_avx512 (struct target_desc *result, long regnum)
index 098c2ca31c6bb63d51c77aa75bc46061966403be..8f9fbad717b614c66a741e1c01d0cdc2af8a3f25 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-core.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_32bit_core (struct target_desc *result, long regnum)
index 3bc593739c9bcbda7e7a8b0a9ca830ed2cc51e39..3289f07d332fe190fcde73f538e675f295f148b3 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-linux.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_32bit_linux (struct target_desc *result, long regnum)
index 8288e9d758f2718465621ed55b3514145cf1dd3b..40b34ed73b716ce60dec39e999bb46d83f0c54e1 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-mpx.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_32bit_mpx (struct target_desc *result, long regnum)
index a2a72f40a31005153b2bd7ba35625ca39fa99b87..5e9087e43037dea9b72fc9e66e50538296e69011 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-pkeys.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_32bit_pkeys (struct target_desc *result, long regnum)
index c22c3dfbc3cb6c03ae0758d44b08188098497b18..209d434ba872bf7e22a681f6526e275ac576da6d 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-segments.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_32bit_segments (struct target_desc *result, long regnum)
index 68fbab06a4003f0df9040a880968350d5b84f1dd..e5eaf8feb59e6efe55ba8fd9ac59e3cfb6493215 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-sse.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_32bit_sse (struct target_desc *result, long regnum)
index 7e45c980dbc1ed25e22c116119b0c784b551a962..f44af9ffed6a45ab2484a9f5f1f5a5b092dc0e25 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-avx.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_64bit_avx (struct target_desc *result, long regnum)
index acc07a3628b2fb7e01b839eb063eabbf99ad42a7..d12234c41ce109489cae0df0fd3a3842379af0c0 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-avx512.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_64bit_avx512 (struct target_desc *result, long regnum)
index 617425da217da0823dd1c49440312d86d54a778f..2418fe54e80c4b872231103b57292b284d90b8f9 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-core.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_64bit_core (struct target_desc *result, long regnum)
index 68de9d27e8bb495b5cdb0a9e681171ed0f811284..661ce6b88336af7b1cb5f5b3d0543e932c275e7e 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-linux.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_64bit_linux (struct target_desc *result, long regnum)
index ce4d611d9c11aa5e63a33e304f99b66d9e63fb87..3eabc9d33c5af9107bf7fe768a4873d5d8aa9140 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-mpx.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_64bit_mpx (struct target_desc *result, long regnum)
index 70b88cf74db40f341a9c7195d897604d96b58d8b..83001d4a876db240e4c7da885dfdaae73439c10a 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-pkeys.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_64bit_pkeys (struct target_desc *result, long regnum)
index b06d40fbda3b9a5aa0bcea01831e23399cad27d6..d85717046d443a8cb84c37e2ff7fd22c95feff81 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-segments.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_64bit_segments (struct target_desc *result, long regnum)
index e08309374115d16ee19c6b5bba63abbbf65ae821..48b5aa097938a5a9941d91ccd00ed45eaefaa6c1 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-sse.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_64bit_sse (struct target_desc *result, long regnum)
index dd6e1a2ed6a9234aec1c8472e2f811dfa6efc13b..740eb658a5f0ab5c0bb65e051d918f3ec702ef1d 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: x32-core.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_i386_x32_core (struct target_desc *result, long regnum)
index 64686db5cdd60ab36b07a9019c6d67f253f0af22..26e6dc1b3221a499dcd9815a3faf17e30402634c 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-cpu.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_riscv_32bit_cpu (struct target_desc *result, long regnum)
index 711e958ddae4f3e21b1e5ffa4e4c2e1759d09bf7..d306bc8d293449fbe696f57a95f31c2e709af2f1 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-csr.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_riscv_32bit_csr (struct target_desc *result, long regnum)
index a19780aab0c5315e590caf1d52559e198d60d20a..d92407fb9e06df0717c227157eac0cebd3d793fd 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 32bit-fpu.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_riscv_32bit_fpu (struct target_desc *result, long regnum)
index 910089805ee22346444a05fe32e617ad8d017b38..96ecce0896212758f90c9e412304bb6044a6d61a 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-cpu.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_riscv_64bit_cpu (struct target_desc *result, long regnum)
index 7c777406254e344454f3c17ffc47021d406b2364..e46a77f305181ff8d133ba50df374d315669ce0b 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-csr.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_riscv_64bit_csr (struct target_desc *result, long regnum)
index b93cb4ec03b36cb42e2f8ef8a077cafbcfda112d..4fd8ee1e41baba642614b5e977c006d23271a87e 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: 64bit-fpu.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_riscv_64bit_fpu (struct target_desc *result, long regnum)
index bfd69d7fd52cf028c623bc32b0ea5e7377335411..c295051cfacad1b89449c57466c2e4b121b9078f 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: tic6x-c6xp.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_tic6x_c6xp (struct target_desc *result, long regnum)
index 0415209275a792f0ad287e35ab40674b164eb786..2dc9655323628e2385979857c49e7190fd504891 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: tic6x-core.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_tic6x_core (struct target_desc *result, long regnum)
index 4a0734c04a477e38b21b4b59a7055eade4db515a..fcc4cbc345a5ec5e24ae0eb74c5bc98f8a9685be 100644 (file)
@@ -1,7 +1,7 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: tic6x-gp.xml */
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 static int
 create_feature_tic6x_gp (struct target_desc *result, long regnum)
index 824245e77e619070b954334075f122fcea27cb7d..90bd564e57cf5e5047ba07d9e89d3a94cbcdceda 100644 (file)
@@ -21,7 +21,7 @@
 #define FILENAME_SEEN_CACHE_H
 
 #include "defs.h"
-#include "common/function-view.h"
+#include "gdbsupport/function-view.h"
 
 /* Cache to watch for file names already seen.  */
 
index 52f8f80aaae8f50d5068d5f0c669f62b4e6d208d..5a1fa89938aebfab14ee46e3238da95a43d21bbd 100644 (file)
@@ -25,7 +25,7 @@
 #include "target.h"
 #include "cli/cli-utils.h"
 #include <algorithm>
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 
 /* Copied from bfd_put_bits.  */
 
index e89ee37ffc7e788e10e0c87494fcc190e646203a..e52ec8d7c92d2ea5f4e73b6302c60c941e73c539 100644 (file)
@@ -32,7 +32,7 @@
 #include "objfiles.h"
 #include "language.h"
 #include "dwarf2loc.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 
 /* Basic byte-swapping routines.  All 'extract' functions return a
    host-format integer from a target-format integer at ADDR which is
index 4c49848830ae9ba527b193a75677c0f43a6cc663..edfb6a3c5a1cd0cec3e94b44ee9b0f2fe7275af2 100644 (file)
 #include "terminal.h"
 #include "gdbthread.h"
 #include "top.h"
-#include "common/job-control.h"
-#include "common/filestuff.h"
+#include "gdbsupport/job-control.h"
+#include "gdbsupport/filestuff.h"
 #include "nat/fork-inferior.h"
-#include "common/common-inferior.h"
+#include "gdbsupport/common-inferior.h"
 
 /* The exec-wrapper, if any, that will be used when starting the
    inferior.  */
 
 static char *exec_wrapper = NULL;
 
-/* See common/common-inferior.h.  */
+/* See gdbsupport/common-inferior.h.  */
 
 const char *
 get_exec_wrapper ()
index 21d9ee886718e71b3ae6e6c180e53574bced6e52..eb108feb790c3c7d61c6c74fcfacdb2f20935f23 100644 (file)
@@ -35,9 +35,9 @@
 #include "gdb_bfd.h"
 #include "readline/tilde.h"
 #include <algorithm>
-#include "common/gdb_unlinker.h"
-#include "common/byte-vector.h"
-#include "common/scope-exit.h"
+#include "gdbsupport/gdb_unlinker.h"
+#include "gdbsupport/byte-vector.h"
+#include "gdbsupport/scope-exit.h"
 
 /* The largest amount of memory to read from the target at once.  We
    must throttle it to limit the amount of memory used by GDB during
index 29e6a67adcda12b37678de25cb8d6e85657e7b5e..132cb6f4705877a08ce5ebf6142ce3f590c9a03b 100644 (file)
@@ -22,8 +22,8 @@
 #include "ui-out.h"
 #include "gdbcmd.h"
 #include "hashtab.h"
-#include "common/filestuff.h"
-#include "common/vec.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/vec.h"
 #ifdef HAVE_MMAP
 #include <sys/mman.h>
 #ifndef MAP_FAILED
index 87b48f51f7c3c6e9832df51e7a979a2e14dc2b0f..aa67fc0a1403ec88d3972d712c2af6099680c3b9 100644 (file)
@@ -21,7 +21,7 @@
 #define GDB_BFD_H
 
 #include "registry.h"
-#include "common/gdb_ref_ptr.h"
+#include "gdbsupport/gdb_ref_ptr.h"
 
 DECLARE_REGISTRY (bfd);
 
index ad69e1dde00dac0d09ef396f23796dcde6224c00..24e2463fc621e82b6ddffc6d616080bb2f965759 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef GDB_PROC_SERVICE_H
 #define GDB_PROC_SERVICE_H
 
-#include "common/gdb_proc_service.h"
+#include "gdbsupport/gdb_proc_service.h"
 
 struct thread_info;
 
index 711f121c1dc2407e4cc14d84d2958eb0b8b0aac1..ce8444361ce308c996acc34dc6f2e84409494eed 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "defs.h"
 #include "gdb_regex.h"
-#include "common/def-vector.h"
+#include "gdbsupport/def-vector.h"
 
 compiled_regex::compiled_regex (const char *regex, int cflags,
                                const char *message)
index ec4547bde2a63a9265870784dd59d95d79c293b9..00a972ec84c9889ea0218e5b223439ecaefd0870 100644 (file)
@@ -23,7 +23,7 @@
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #else
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 #endif
 
 #ifdef USE_WIN32API
index 25cc8e1b16c62fbd96b55304ebc5f5921f9c0e4f..9a92ced34a886b51516ae3a5bd198ea5b8b541d1 100644 (file)
@@ -18,7 +18,7 @@
 #include "defs.h"
 #include "gdb_usleep.h"
 #include "gdb_select.h"
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 
 int
 gdb_usleep (int usec)
index 0efd4bc13055c6ef33a1a193ccf18b1a3d8d76de..bc8d9bda7aa460a131b7f5e809eb11609918f8e3 100644 (file)
 
 #include "defs.h"
 #if GDB_SELF_TEST
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "inferior.h"
 #include "gdbthread.h"
 #include "target.h"
 #include "test-target.h"
 #include "target-float.h"
-#include "common/def-vector.h"
+#include "gdbsupport/def-vector.h"
 
 namespace selftests {
 
index 0bd61131cbcb509f9b3d42f6d11f064374321232..0a48ad5b79243c7aa69f07154aec6a11b7c013d4 100644 (file)
@@ -1,3 +1,22 @@
+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-07-04  Alan Hayward  <alan.hayward@arm.com>
 
        * linux-aarch32-low.c (arm_read_description, arm_regsets): Use new
index b9df2be9df187a97ada3db28a0f264a9cdc56d83..ba0356b1d5bff9b1b5ce3675e2c242ed4dee50f1 100644 (file)
@@ -198,29 +198,29 @@ SFILES = \
        $(srcdir)/arch/arm-linux.c \
        $(srcdir)/arch/ppc-linux-common.c \
        $(srcdir)/../alloc.c \
-       $(srcdir)/common/btrace-common.c \
-       $(srcdir)/common/buffer.c \
-       $(srcdir)/common/cleanups.c \
-       $(srcdir)/common/common-debug.c \
-       $(srcdir)/common/common-exceptions.c \
-       $(srcdir)/common/common-regcache.c \
-       $(srcdir)/common/common-utils.c \
-       $(srcdir)/common/errors.c \
-       $(srcdir)/common/environ.c \
-       $(srcdir)/common/fileio.c \
-       $(srcdir)/common/filestuff.c \
-       $(srcdir)/common/job-control.c \
-       $(srcdir)/common/gdb_tilde_expand.c \
-       $(srcdir)/common/gdb_vecs.c \
-       $(srcdir)/common/netstuff.c \
-       $(srcdir)/common/new-op.c \
-       $(srcdir)/common/pathstuff.c \
-       $(srcdir)/common/print-utils.c \
-       $(srcdir)/common/ptid.c \
-       $(srcdir)/common/rsp-low.c \
-       $(srcdir)/common/tdesc.c \
-       $(srcdir)/common/vec.c \
-       $(srcdir)/common/xml-utils.c \
+       $(srcdir)/gdbsupport/btrace-common.c \
+       $(srcdir)/gdbsupport/buffer.c \
+       $(srcdir)/gdbsupport/cleanups.c \
+       $(srcdir)/gdbsupport/common-debug.c \
+       $(srcdir)/gdbsupport/common-exceptions.c \
+       $(srcdir)/gdbsupport/common-regcache.c \
+       $(srcdir)/gdbsupport/common-utils.c \
+       $(srcdir)/gdbsupport/errors.c \
+       $(srcdir)/gdbsupport/environ.c \
+       $(srcdir)/gdbsupport/fileio.c \
+       $(srcdir)/gdbsupport/filestuff.c \
+       $(srcdir)/gdbsupport/job-control.c \
+       $(srcdir)/gdbsupport/gdb_tilde_expand.c \
+       $(srcdir)/gdbsupport/gdb_vecs.c \
+       $(srcdir)/gdbsupport/netstuff.c \
+       $(srcdir)/gdbsupport/new-op.c \
+       $(srcdir)/gdbsupport/pathstuff.c \
+       $(srcdir)/gdbsupport/print-utils.c \
+       $(srcdir)/gdbsupport/ptid.c \
+       $(srcdir)/gdbsupport/rsp-low.c \
+       $(srcdir)/gdbsupport/tdesc.c \
+       $(srcdir)/gdbsupport/vec.c \
+       $(srcdir)/gdbsupport/xml-utils.c \
        $(srcdir)/nat/aarch64-sve-linux-ptrace.c \
        $(srcdir)/nat/linux-btrace.c \
        $(srcdir)/nat/linux-namespaces.c \
@@ -241,33 +241,33 @@ TAGFILES = $(SOURCES) ${HFILES} ${ALLPARAM} ${POSSLIBS}
 OBS = \
        alloc.o \
        ax.o \
-       common/agent.o \
-       common/btrace-common.o \
-       common/buffer.o \
-       common/cleanups.o \
-       common/common-debug.o \
-       common/common-exceptions.o \
-       common/job-control.o \
-       common/common-regcache.o \
-       common/common-utils.o \
-       common/errors.o \
-       common/environ.o \
-       common/fileio.o \
-       common/filestuff.o \
-       common/format.o \
-       common/gdb_tilde_expand.o \
-       common/gdb_vecs.o \
-       common/netstuff.o \
-       common/new-op.o \
-       common/pathstuff.o \
-       common/print-utils.o \
-       common/ptid.o \
-       common/rsp-low.o \
-       common/signals.o \
-       common/signals-state-save-restore.o \
-       common/tdesc.o \
-       common/vec.o \
-       common/xml-utils.o \
+       gdbsupport/agent.o \
+       gdbsupport/btrace-common.o \
+       gdbsupport/buffer.o \
+       gdbsupport/cleanups.o \
+       gdbsupport/common-debug.o \
+       gdbsupport/common-exceptions.o \
+       gdbsupport/job-control.o \
+       gdbsupport/common-regcache.o \
+       gdbsupport/common-utils.o \
+       gdbsupport/errors.o \
+       gdbsupport/environ.o \
+       gdbsupport/fileio.o \
+       gdbsupport/filestuff.o \
+       gdbsupport/format.o \
+       gdbsupport/gdb_tilde_expand.o \
+       gdbsupport/gdb_vecs.o \
+       gdbsupport/netstuff.o \
+       gdbsupport/new-op.o \
+       gdbsupport/pathstuff.o \
+       gdbsupport/print-utils.o \
+       gdbsupport/ptid.o \
+       gdbsupport/rsp-low.o \
+       gdbsupport/signals.o \
+       gdbsupport/signals-state-save-restore.o \
+       gdbsupport/tdesc.o \
+       gdbsupport/vec.o \
+       gdbsupport/xml-utils.o \
        debug.o \
        dll.o \
        event-loop.o \
@@ -290,13 +290,13 @@ OBS = \
        $(XML_BUILTIN)
 
 GDBREPLAY_OBS = \
-       common/cleanups.o \
-       common/common-exceptions.o \
-       common/common-utils.o \
-       common/rsp-low.o \
-       common/errors.o \
-       common/netstuff.o \
-       common/print-utils.o \
+       gdbsupport/cleanups.o \
+       gdbsupport/common-exceptions.o \
+       gdbsupport/common-utils.o \
+       gdbsupport/rsp-low.o \
+       gdbsupport/errors.o \
+       gdbsupport/netstuff.o \
+       gdbsupport/print-utils.o \
        gdbreplay.o \
        utils.o \
        version.o
@@ -418,13 +418,13 @@ gdbreplay$(EXEEXT): $(sort $(GDBREPLAY_OBS)) $(LIBGNU) $(LIBIBERTY)
 IPA_OBJS = \
        alloc-ipa.o \
        ax-ipa.o \
-       common/common-utils-ipa.o \
-       common/errors-ipa.o \
-       common/format-ipa.o \
-       common/print-utils-ipa.o \
-       common/rsp-low-ipa.o \
-       common/tdesc-ipa.o \
-       common/vec-ipa.o \
+       gdbsupport/common-utils-ipa.o \
+       gdbsupport/errors-ipa.o \
+       gdbsupport/format-ipa.o \
+       gdbsupport/print-utils-ipa.o \
+       gdbsupport/rsp-low-ipa.o \
+       gdbsupport/tdesc-ipa.o \
+       gdbsupport/vec-ipa.o \
        regcache-ipa.o \
        remote-utils-ipa.o \
        tdesc-ipa.o \
@@ -519,8 +519,8 @@ am--refresh:
 
 force:
 
-version-generated.c: Makefile $(srcdir)/../version.in $(srcdir)/../../bfd/version.h $(srcdir)/../common/create-version.sh
-       $(ECHO_GEN) $(SHELL) $(srcdir)/../common/create-version.sh $(srcdir)/.. \
+version-generated.c: Makefile $(srcdir)/../version.in $(srcdir)/../../bfd/version.h $(srcdir)/../gdbsupport/create-version.sh
+       $(ECHO_GEN) $(SHELL) $(srcdir)/../gdbsupport/create-version.sh $(srcdir)/.. \
                $(host_alias) $(target_alias) $@
 
 xml-builtin-generated.c: stamp-xml; @true
@@ -582,7 +582,7 @@ arch/%-ipa.o: ../arch/%.c
        $(IPAGENT_COMPILE) $<
        $(POSTCOMPILE)
 
-common/%-ipa.o: ../common/%.c
+gdbsupport/%-ipa.o: ../gdbsupport/%.c
        $(IPAGENT_COMPILE) $<
        $(POSTCOMPILE)
 
@@ -611,7 +611,7 @@ arch/%.o: ../arch/%.c
        $(COMPILE) $<
        $(POSTCOMPILE)
 
-common/%.o: ../common/%.c
+gdbsupport/%.o: ../gdbsupport/%.c
        $(COMPILE) $<
        $(POSTCOMPILE)
 
index fc3e344a611a12e0a77563289d164aaf2dc11781..96ded3d7d3900e84a9612ed8e7e3e55522c32c9a 100644 (file)
@@ -21,7 +21,7 @@ m4_include(../../config/lead-dot.m4)
 dnl codeset.m4 is needed for common.m4, but not for
 dnl anything else in gdbserver.
 m4_include(../../config/codeset.m4)
-m4_include(../common/common.m4)
+m4_include(../gdbsupport/common.m4)
 
 dnl For libiberty_INIT.
 m4_include(../libiberty.m4)
index 7b8df917492debf251c4eba54f944d02d83a5798..2c096ef0cff200122ab8fd049d84aef4c4a699b2 100644 (file)
@@ -18,9 +18,9 @@
 
 #include "server.h"
 #include "ax.h"
-#include "common/format.h"
+#include "gdbsupport/format.h"
 #include "tracepoint.h"
-#include "common/rsp-low.h"
+#include "gdbsupport/rsp-low.h"
 
 static void ax_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
 
@@ -60,7 +60,7 @@ enum gdb_agent_op
   {
 #define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE)  \
     gdb_agent_op_ ## NAME = VALUE,
-#include "common/ax.def"
+#include "gdbsupport/ax.def"
 #undef DEFOP
     gdb_agent_op_last
   };
@@ -69,7 +69,7 @@ static const char *gdb_agent_op_names [gdb_agent_op_last] =
   {
     "?undef?"
 #define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE)  , # NAME
-#include "common/ax.def"
+#include "gdbsupport/ax.def"
 #undef DEFOP
   };
 
@@ -78,7 +78,7 @@ static const unsigned char gdb_agent_op_sizes [gdb_agent_op_last] =
   {
     0
 #define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE)  , SIZE
-#include "common/ax.def"
+#include "gdbsupport/ax.def"
 #undef DEFOP
   };
 #endif
index e89f2d06c14f5ea6c9a9277c33decb4a4adaac1d..0c04fcc8ae6a52b51cce6fd457788493692cd60e 100755 (executable)
@@ -5916,7 +5916,7 @@ if $enable_unittests; then
 $as_echo "#define GDB_SELF_TEST 1" >>confdefs.h
 
 
-  srv_selftest_objs="common/selftest.o"
+  srv_selftest_objs="gdbsupport/selftest.o"
 
 fi
 
@@ -5958,7 +5958,7 @@ ac_config_commands="$ac_config_commands depdir"
 
 
 # Create sub-directories for objects and dependencies.
-CONFIG_SRC_SUBDIR="arch common"
+CONFIG_SRC_SUBDIR="arch gdbsupport"
 
 
 ac_config_commands="$ac_config_commands gdbdepdir"
@@ -7892,7 +7892,7 @@ esac
 . ${srcdir}/configure.srv
 
 # Add in the common host objects.
-. ${srcdir}/../common/common.host
+. ${srcdir}/../gdbsupport/common.host
 srv_host_obs="$common_host_obs"
 
 if test "${srv_mingwce}" = "yes"; then
index d943269377b77ebb7cd57ab192e803dbfcdbd0b9..574b7c5b287917575a632baa7dd27700f65b90b7 100644 (file)
@@ -55,7 +55,7 @@ fi
 GDB_AC_LIBMCHECK(${libmcheck_default})
 
 GDB_AC_SELFTEST([
-  srv_selftest_objs="common/selftest.o"
+  srv_selftest_objs="gdbsupport/selftest.o"
 ])
 
 ACX_NONCANONICAL_TARGET
@@ -65,7 +65,7 @@ ACX_NONCANONICAL_HOST
 ZW_CREATE_DEPDIR
 
 # Create sub-directories for objects and dependencies.
-CONFIG_SRC_SUBDIR="arch common"
+CONFIG_SRC_SUBDIR="arch gdbsupport"
 AC_SUBST(CONFIG_SRC_SUBDIR)
 
 AC_CONFIG_COMMANDS([gdbdepdir],[
@@ -255,7 +255,7 @@ esac
 . ${srcdir}/configure.srv
 
 # Add in the common host objects.
-. ${srcdir}/../common/common.host
+. ${srcdir}/../gdbsupport/common.host
 srv_host_obs="$common_host_obs"
 
 if test "${srv_mingwce}" = "yes"; then
index 0442680c23793af9c6f117ed9030fcb19fafb841..bcc496eee0faf6fcf721e1f31885f8efe31d8473 100644 (file)
@@ -21,7 +21,7 @@
 #include "server.h"
 
 #include <sys/types.h>
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 
 #ifdef USE_WIN32API
 #include <windows.h>
index a8bd0403780b2f9e71d00b5ba77643d4489322e0..ddd73094e6cbb1fa5e25c5d3e5e6c31cf5b37750 100644 (file)
@@ -17,7 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "server.h"
-#include "common/job-control.h"
+#include "gdbsupport/job-control.h"
 #include "nat/fork-inferior.h"
 #ifdef HAVE_SIGNAL_H
 #include <signal.h>
index 626bc164fe35aecbe2195feff0074b3b8fec4489..f0d0c1b189d787976f5617fc74c82ef4b2a6a0aa 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef GDBSERVER_GDB_PROC_SERVICE_H
 #define GDBSERVER_GDB_PROC_SERVICE_H
 
-#include "common/gdb_proc_service.h"
+#include "gdbsupport/gdb_proc_service.h"
 
 /* Structure that identifies the target process.  */
 struct ps_prochandle
index f4fd5686ef7f98e55c4a43383ba7c43ff0eb6e67..325291479391adc78d5f47f5c651dcad2340bbc0 100644 (file)
@@ -17,8 +17,8 @@
    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 "common/common-defs.h"
-#include "common/version.h"
+#include "gdbsupport/common-defs.h"
+#include "gdbsupport/version.h"
 
 #if HAVE_SYS_FILE_H
 #include <sys/file.h>
@@ -48,8 +48,8 @@
 #include <ws2tcpip.h>
 #endif
 
-#include "common/netstuff.h"
-#include "common/rsp-low.h"
+#include "gdbsupport/netstuff.h"
+#include "gdbsupport/rsp-low.h"
 
 #ifndef HAVE_SOCKLEN_T
 typedef int socklen_t;
index 44ed3c4723c2dd59861a38576366ef48b6b78dab..825a7f6b51007d890ba60e9cc74b61c93f79a1c3 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef GDBSERVER_GDBTHREAD_H
 #define GDBSERVER_GDBTHREAD_H
 
-#include "common/common-gdbthread.h"
+#include "gdbsupport/common-gdbthread.h"
 #include "inferiors.h"
 
 #include <list>
index 6325fee3ffdb966d73ac9315e7e26a075d218928..737331bbfcd5842e6524d47720094029543a5f31 100644 (file)
@@ -22,7 +22,7 @@
    on top of errno.  */
 
 #include "server.h"
-#include "common/fileio.h"
+#include "gdbsupport/fileio.h"
 
 void
 hostio_last_error_from_errno (char *buf)
index eedf6d9fe7212b5fa266c11553370313a710fa6d..e35a2249be92cd6cd32a71c8f198ef6e63a7456b 100644 (file)
@@ -27,7 +27,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include "common/fileio.h"
+#include "gdbsupport/fileio.h"
 
 struct fd_list
 {
index 7dde85a61e5eff448b969d4b82b137046b7eb52c..3b92feedb3970a3e083add2d623a9f751d41c357 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "server.h"
 #include "i387-fp.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 
 static const int num_mpx_bnd_registers = 4;
 static const int num_mpx_cfg_registers = 2;
index 17bfd1f6ec8c0fded687406c01176d5df035bd25..e35186bda14eb90a91fe897d59aa1f5199ca798f 100644 (file)
@@ -213,7 +213,7 @@ current_process (void)
   return get_thread_process (current_thread);
 }
 
-/* See common/common-gdbthread.h.  */
+/* See gdbsupport/common-gdbthread.h.  */
 
 void
 switch_to_thread (ptid_t ptid)
@@ -222,7 +222,7 @@ switch_to_thread (ptid_t ptid)
   current_thread = find_thread_ptid (ptid);
 }
 
-/* See common/common-inferior.h.  */
+/* See gdbsupport/common-inferior.h.  */
 
 const char *
 get_inferior_cwd ()
@@ -230,7 +230,7 @@ get_inferior_cwd ()
   return current_inferior_cwd;
 }
 
-/* See common/common-inferior.h.  */
+/* See gdbsupport/common-inferior.h.  */
 
 void
 set_inferior_cwd (const char *cwd)
index cf284b807bb27231220e7b04f48bb4a505711341..f4ab9fddb54c58c96967d9d9fb0ebfe8820bf744 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef GDBSERVER_INFERIORS_H
 #define GDBSERVER_INFERIORS_H
 
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 #include <list>
 
 struct thread_info;
index 99206536ca81930d53650eb8b74e0db29971876f..6bab392bbbb7d78ae208baebb0650ca3b728a01b 100644 (file)
@@ -22,7 +22,7 @@
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include "linux-x86-tdesc.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 
 /* Defined in auto-generated file amd64-linux.c.  */
 void init_registers_amd64_linux (void);
index f5fd227505ab9b57726790a54892ac27eed8d2d4..2e3d1ac7feed95eaace72454ca83423a534ff485 100644 (file)
@@ -22,7 +22,7 @@
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include "linux-x86-tdesc.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 
 /* GDB register numbers.  */
 
index 917b1c290bcdc0dde742a405907eb920d9f8ae90..3113017ae67837aa7a5de3097b4f7224d1dee82a 100644 (file)
 #include "server.h"
 #include "linux-low.h"
 #include "nat/linux-osdata.h"
-#include "common/agent.h"
+#include "gdbsupport/agent.h"
 #include "tdesc.h"
-#include "common/rsp-low.h"
-#include "common/signals-state-save-restore.h"
+#include "gdbsupport/rsp-low.h"
+#include "gdbsupport/signals-state-save-restore.h"
 #include "nat/linux-nat.h"
 #include "nat/linux-waitpid.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include "nat/gdb_ptrace.h"
 #include "nat/linux-ptrace.h"
 #include "nat/linux-procfs.h"
 #include <sys/stat.h>
 #include <sys/vfs.h>
 #include <sys/uio.h>
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "tracepoint.h"
 #include "hostio.h"
 #include <inttypes.h>
-#include "common/common-inferior.h"
+#include "gdbsupport/common-inferior.h"
 #include "nat/fork-inferior.h"
-#include "common/environ.h"
-#include "common/scoped_restore.h"
+#include "gdbsupport/environ.h"
+#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
 
 #ifdef HAVE_LINUX_BTRACE
 # include "nat/linux-btrace.h"
-# include "common/btrace-common.h"
+# include "gdbsupport/btrace-common.h"
 #endif
 
 #ifndef HAVE_ELF32_AUXV_T
@@ -7189,7 +7189,7 @@ linux_low_encode_raw (struct buffer *buffer, const gdb_byte *data,
   if (size == 0)
     return;
 
-  /* We use hex encoding - see common/rsp-low.h.  */
+  /* We use hex encoding - see gdbsupport/rsp-low.h.  */
   buffer_grow_str (buffer, "<raw>\n");
 
   while (size-- > 0)
index 7eecdeb798669616b0c36081d81db1a9d42f9c3c..6682e1bda4056f4a569bec2b95f3dcfc4342d6ee 100644 (file)
@@ -424,7 +424,7 @@ struct linux_target_ops the_low_target = {
 };
 
 #if GDB_SELF_TEST
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 
 namespace selftests {
 namespace tdesc {
index db240e2bc46ce3ada2c981490947d41668f66e00..cb0169c4bd5649b82b87497738dbba26d4a6e36b 100644 (file)
@@ -24,7 +24,7 @@
 #include "linux-low.h"
 #include "i387-fp.h"
 #include "x86-low.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "nat/gdb_ptrace.h"
 
 #ifdef __x86_64__
@@ -38,7 +38,7 @@
 #include "elf/common.h"
 #endif
 
-#include "common/agent.h"
+#include "gdbsupport/agent.h"
 #include "tdesc.h"
 #include "tracepoint.h"
 #include "ax.h"
index 8f24a3d72d161e960ef1119aba04ac13fb53c949..b39ed53549bdd4b6a6adea2f30ec3ad75c2bda0b 100644 (file)
@@ -21,7 +21,7 @@
 #include "tdesc.h"
 #include "linux-x86-tdesc.h"
 #include "arch/i386.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #ifdef __x86_64__
 #include "arch/amd64.h"
 #endif
index e47f6b92f637695cced3eaa9d96bf08d84ef528b..ca707acf43bf700d939815bf82ae86b936080110 100644 (file)
@@ -19,7 +19,7 @@
 #include "lynx-low.h"
 #include <limits.h>
 #include <sys/ptrace.h>
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "arch/i386.h"
 #include "x86-tdesc.h"
 
index 4f6314669eb571c6aede9aba278700bb5e3b1c76..0a8b258e87d11c086a47359ff22963b5ee2de2cf 100644 (file)
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include <signal.h>
-#include "common/filestuff.h"
-#include "common/common-inferior.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/common-inferior.h"
 #include "nat/fork-inferior.h"
 
 int using_threads = 1;
index d2d75104f339b2fc3022c706c68851006ef9055b..4984a555d546798d8f76ff1f9c59d50cc41f5966 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef GDBSERVER_MEM_BREAK_H
 #define GDBSERVER_MEM_BREAK_H
 
-#include "common/break-common.h"
+#include "gdbsupport/break-common.h"
 
 /* Breakpoints are opaque.  */
 struct breakpoint;
index cfbe7ba6d810c1f116a833797f5134cd71a7f687..b51f424fb46fd4507fd76fbd7ecef8b89de01d82 100644 (file)
@@ -23,7 +23,7 @@
 #include "regcache.h"
 
 #include <x86/context.h>
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "arch/i386.h"
 #include "x86-tdesc.h"
 
index a56b580654da61a482186cec79c311a091b67e67..98c7511c6824473834b382f1d2e8bd3df7875b8f 100644 (file)
@@ -20,7 +20,7 @@
 #include "regdef.h"
 #include "gdbthread.h"
 #include "tdesc.h"
-#include "common/rsp-low.h"
+#include "gdbsupport/rsp-low.h"
 #ifndef IN_PROCESS_AGENT
 
 struct regcache *
@@ -63,7 +63,7 @@ get_thread_regcache (struct thread_info *thread, int fetch)
   return regcache;
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 struct regcache *
 get_thread_regcache_for_ptid (ptid_t ptid)
@@ -291,7 +291,7 @@ register_size (const struct target_desc *tdesc, int n)
   return find_register_by_number (tdesc, n).size / 8;
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 int
 regcache_register_size (const struct regcache *regcache, int n)
@@ -312,7 +312,7 @@ supply_register (struct regcache *regcache, int n, const void *buf)
   return regcache->raw_supply (n, buf);
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 void
 regcache::raw_supply (int n, const void *buf)
@@ -415,7 +415,7 @@ collect_register (struct regcache *regcache, int n, void *buf)
   regcache->raw_collect (n, buf);
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 void
 regcache::raw_collect (int n, void *buf) const
@@ -500,7 +500,7 @@ regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
 
 #endif
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 enum register_status
 regcache::get_register_status (int regnum) const
@@ -513,7 +513,7 @@ regcache::get_register_status (int regnum) const
 #endif
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 bool
 regcache::raw_compare (int regnum, const void *buf, int offset) const
index 5ee44788dcd32b323331f69a9e78be022202fe6e..d3a350aff9783d730c4bf825a98f7ee865d81a9f 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef GDBSERVER_REGCACHE_H
 #define GDBSERVER_REGCACHE_H
 
-#include "common/common-regcache.h"
+#include "gdbsupport/common-regcache.h"
 
 struct thread_info;
 struct target_desc;
@@ -46,16 +46,16 @@ struct regcache : public reg_buffer_common
   unsigned char *register_status = nullptr;
 #endif
 
-  /* See common/common-regcache.h.  */
+  /* See gdbsupport/common-regcache.h.  */
   enum register_status get_register_status (int regnum) const override;
 
-  /* See common/common-regcache.h.  */
+  /* See gdbsupport/common-regcache.h.  */
   void raw_supply (int regnum, const void *buf) override;
 
-  /* See common/common-regcache.h.  */
+  /* See gdbsupport/common-regcache.h.  */
   void raw_collect (int regnum, void *buf) const override;
 
-  /* See common/common-regcache.h.  */
+  /* See gdbsupport/common-regcache.h.  */
   bool raw_compare (int regnum, const void *buf, int offset) const override;
 };
 
@@ -102,7 +102,7 @@ void registers_to_string (struct regcache *regcache, char *buf);
 
 void registers_from_string (struct regcache *regcache, char *buf);
 
-/* For regcache_read_pc see common/common-regcache.h.  */
+/* For regcache_read_pc see gdbsupport/common-regcache.h.  */
 
 void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
 
index 7c495beb7cd9a6f6704c51190b5903a21606f652..d965b6fe644d4e2786bf5ea75002abfb837935f5 100644 (file)
@@ -24,9 +24,9 @@
 #include "gdbthread.h"
 #include "tdesc.h"
 #include "dll.h"
-#include "common/rsp-low.h"
-#include "common/netstuff.h"
-#include "common/filestuff.h"
+#include "gdbsupport/rsp-low.h"
+#include "gdbsupport/netstuff.h"
+#include "gdbsupport/filestuff.h"
 #include <ctype.h>
 #if HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
@@ -55,7 +55,7 @@
 #if HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 #include <unistd.h>
 #if HAVE_ARPA_INET_H
 #include <arpa/inet.h>
index 5e93a58fd6bf23d1b3fe35d55409ef0a1deadb50..5b14883f7a8a88af89c8f9d12109d045792031db 100644 (file)
 
 #include "server.h"
 #include "gdbthread.h"
-#include "common/agent.h"
+#include "gdbsupport/agent.h"
 #include "notif.h"
 #include "tdesc.h"
-#include "common/rsp-low.h"
-#include "common/signals-state-save-restore.h"
+#include "gdbsupport/rsp-low.h"
+#include "gdbsupport/signals-state-save-restore.h"
 #include <ctype.h>
 #include <unistd.h>
 #if HAVE_SIGNAL_H
 #include <signal.h>
 #endif
-#include "common/gdb_vecs.h"
-#include "common/gdb_wait.h"
-#include "common/btrace-common.h"
-#include "common/filestuff.h"
+#include "gdbsupport/gdb_vecs.h"
+#include "gdbsupport/gdb_wait.h"
+#include "gdbsupport/btrace-common.h"
+#include "gdbsupport/filestuff.h"
 #include "tracepoint.h"
 #include "dll.h"
 #include "hostio.h"
 #include <vector>
-#include "common/common-inferior.h"
-#include "common/job-control.h"
-#include "common/environ.h"
+#include "gdbsupport/common-inferior.h"
+#include "gdbsupport/job-control.h"
+#include "gdbsupport/environ.h"
 #include "filenames.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 
-#include "common/selftest.h"
-#include "common/scope-exit.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/scope-exit.h"
 
 #define require_running_or_return(BUF)         \
   if (!target_running ())                      \
@@ -258,7 +258,7 @@ target_running (void)
   return get_first_thread () != NULL;
 }
 
-/* See common/common-inferior.h.  */
+/* See gdbsupport/common-inferior.h.  */
 
 const char *
 get_exec_wrapper ()
@@ -266,7 +266,7 @@ get_exec_wrapper ()
   return !wrapper_argv.empty () ? wrapper_argv.c_str () : NULL;
 }
 
-/* See common/common-inferior.h.  */
+/* See gdbsupport/common-inferior.h.  */
 
 char *
 get_exec_file (int err)
index 400001addd3bd3d3dc2084e4f319434aecb59ff1..520969453ac40004e80c33020f8eb2d759d59e1d 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef GDBSERVER_SERVER_H
 #define GDBSERVER_SERVER_H
 
-#include "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 
 gdb_static_assert (sizeof (CORE_ADDR) >= sizeof (void *));
 
@@ -27,7 +27,7 @@ gdb_static_assert (sizeof (CORE_ADDR) >= sizeof (void *));
 #include "wincecompat.h"
 #endif
 
-#include "common/version.h"
+#include "gdbsupport/version.h"
 
 #if !HAVE_DECL_STRERROR
 #ifndef strerror
@@ -54,13 +54,13 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap);
 #  define PROG "gdbserver"
 #endif
 
-#include "common/buffer.h"
-#include "common/xml-utils.h"
+#include "gdbsupport/buffer.h"
+#include "gdbsupport/xml-utils.h"
 #include "regcache.h"
-#include "common/gdb_signals.h"
+#include "gdbsupport/gdb_signals.h"
 #include "target.h"
 #include "mem-break.h"
-#include "common/environ.h"
+#include "gdbsupport/environ.h"
 
 /* Target-specific functions */
 
@@ -104,7 +104,7 @@ extern int in_queued_stop_replies (ptid_t ptid);
 
 #include "utils.h"
 #include "debug.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 
 /* Maximum number of bytes to read/write at once.  The value here
    is chosen to fill up a packet (the headers account for the 32).  */
index 97f985ae8f832c975fd31cdd22b7996f5aa575b3..4930c59d73005a83df52f6c435fa62b50b5eedf4 100644 (file)
 
 #include "server.h"
 
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include <sys/ptrace.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/syscall.h>
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "hostio.h"
 #include "nat/fork-inferior.h"
 
index 20eb492f6be3bcdd1dc75b9de0ca0ce6dce41ff7..56a5d3e753debe6d230864f42cab4a750569801e 100644 (file)
@@ -18,9 +18,9 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "server.h"
-#include "common/symbol.h"
+#include "gdbsupport/symbol.h"
 
-/* See common/symbol.h.  */
+/* See gdbsupport/symbol.h.  */
 
 int
 find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
index a4c9ad49106208e9d065388ae1b278e2cbdba5fe..434bfa9f3cbe668d8d28ef3b7bb68c5bc9cd1ecd 100644 (file)
@@ -27,7 +27,7 @@
 #include "target/wait.h"
 #include "target/waitstatus.h"
 #include "mem-break.h"
-#include "common/btrace-common.h"
+#include "gdbsupport/btrace-common.h"
 #include <vector>
 
 struct emit_ops;
index 04c702fa033651a83c8c438ce5d156ac36eb9371..92a0a6005f3f4fccdca964f7e981d26deb07ae04 100644 (file)
@@ -122,7 +122,7 @@ current_target_desc (void)
   return current_process ()->tdesc;
 }
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 const char *
 tdesc_architecture_name (const struct target_desc *target_desc)
@@ -130,7 +130,7 @@ tdesc_architecture_name (const struct target_desc *target_desc)
   return target_desc->arch;
 }
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 void
 set_tdesc_architecture (struct target_desc *target_desc,
@@ -139,7 +139,7 @@ set_tdesc_architecture (struct target_desc *target_desc,
   target_desc->arch = xstrdup (name);
 }
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 const char *
 tdesc_osabi_name (const struct target_desc *target_desc)
@@ -147,7 +147,7 @@ tdesc_osabi_name (const struct target_desc *target_desc)
   return target_desc->osabi;
 }
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 void
 set_tdesc_osabi (struct target_desc *target_desc, const char *name)
@@ -155,7 +155,7 @@ set_tdesc_osabi (struct target_desc *target_desc, const char *name)
   target_desc->osabi = xstrdup (name);
 }
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 const char *
 tdesc_get_features_xml (const target_desc *tdesc)
@@ -177,7 +177,7 @@ tdesc_get_features_xml (const target_desc *tdesc)
 }
 #endif
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 struct tdesc_feature *
 tdesc_create_feature (struct target_desc *tdesc, const char *name)
index 8ccacbb7ed4ec42ca863d6eaa3019197d39dab91..b93f53c8d44592b95bbe1cf23c712709736f7a33 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef GDBSERVER_TDESC_H
 #define GDBSERVER_TDESC_H
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 #include "regdef.h"
 #include <vector>
index 387f22f487e9e85ce57ac8a5747e333ffd780062..b2791b0513a69bb603dd03081b10294a43cde4fd 100644 (file)
@@ -26,9 +26,9 @@ extern int debug_threads;
 
 #include "gdb_proc_service.h"
 #include "nat/gdb_thread_db.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 #include "nat/linux-procfs.h"
-#include "common/scoped_restore.h"
+#include "gdbsupport/scoped_restore.h"
 
 #ifndef USE_LIBTHREAD_DB_DIRECTLY
 #include <dlfcn.h>
index 98d28e9bb281ab77b4a842ca2f73be1eb1aae46a..09e7d5f8fec440487f7b7bc8065c3a9c4c95c2d1 100644 (file)
@@ -19,7 +19,7 @@
 #include "server.h"
 #include "tracepoint.h"
 #include "gdbthread.h"
-#include "common/rsp-low.h"
+#include "gdbsupport/rsp-low.h"
 
 #include <ctype.h>
 #include <fcntl.h>
@@ -30,7 +30,7 @@
 #include "tdesc.h"
 
 #define IPA_SYM_STRUCT_NAME ipa_sym_addresses
-#include "common/agent.h"
+#include "gdbsupport/agent.h"
 
 #define DEFAULT_TRACE_BUFFER_SIZE 5242880 /* 5*1024*1024 */
 
index 7b187d3bea3e5da8b39244d5bfce8ee0f69fedde..399520c11dc094ce0a085f1fc082e60a9e9a5e63 100644 (file)
@@ -18,7 +18,7 @@
 #include "server.h"
 #include "win32-low.h"
 #include "x86-low.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #ifdef __x86_64__
 #include "arch/amd64.h"
 #endif
index 1a50141c123faf158c30a772686e805a5b43ff07..49c6cf1b7c9d68f735f5f24a8990e8f2989aa8c4 100644 (file)
@@ -32,8 +32,8 @@
 #include <tlhelp32.h>
 #include <psapi.h>
 #include <process.h>
-#include "common/gdb_tilde_expand.h"
-#include "common/common-inferior.h"
+#include "gdbsupport/gdb_tilde_expand.h"
+#include "gdbsupport/common-inferior.h"
 
 #ifndef USE_WIN32API
 #include <sys/cygwin.h>
diff --git a/gdb/gdbsupport/agent.c b/gdb/gdbsupport/agent.c
new file mode 100644 (file)
index 0000000..02cad46
--- /dev/null
@@ -0,0 +1,282 @@
+/* Shared utility routines for GDB to interact with agent.
+
+   Copyright (C) 2009-2019 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 "common-defs.h"
+#include "target/target.h"
+#include "gdbsupport/symbol.h"
+#include <unistd.h>
+#include "filestuff.h"
+
+#define IPA_SYM_STRUCT_NAME ipa_sym_addresses_common
+#include "agent.h"
+
+int debug_agent = 0;
+
+/* A stdarg wrapper for debug_vprintf.  */
+
+static void ATTRIBUTE_PRINTF (1, 2)
+debug_agent_printf (const char *fmt, ...)
+{
+  va_list ap;
+
+  if (!debug_agent)
+    return;
+  va_start (ap, fmt);
+  debug_vprintf (fmt, ap);
+  va_end (ap);
+}
+
+#define DEBUG_AGENT debug_agent_printf
+
+/* Global flag to determine using agent or not.  */
+int use_agent = 0;
+
+/* Addresses of in-process agent's symbols both GDB and GDBserver cares
+   about.  */
+
+struct ipa_sym_addresses_common
+{
+  CORE_ADDR addr_helper_thread_id;
+  CORE_ADDR addr_cmd_buf;
+  CORE_ADDR addr_capability;
+};
+
+/* Cache of the helper thread id.  FIXME: this global should be made
+   per-process.  */
+static uint32_t helper_thread_id = 0;
+
+static struct
+{
+  const char *name;
+  int offset;
+} symbol_list[] = {
+  IPA_SYM(helper_thread_id),
+  IPA_SYM(cmd_buf),
+  IPA_SYM(capability),
+};
+
+static struct ipa_sym_addresses_common ipa_sym_addrs;
+
+static int all_agent_symbols_looked_up = 0;
+
+int
+agent_loaded_p (void)
+{
+  return all_agent_symbols_looked_up;
+}
+
+/* Look up all symbols needed by agent.  Return 0 if all the symbols are
+   found, return non-zero otherwise.  */
+
+int
+agent_look_up_symbols (void *arg)
+{
+  int i;
+
+  all_agent_symbols_looked_up = 0;
+
+  for (i = 0; i < sizeof (symbol_list) / sizeof (symbol_list[0]); i++)
+    {
+      CORE_ADDR *addrp =
+       (CORE_ADDR *) ((char *) &ipa_sym_addrs + symbol_list[i].offset);
+      struct objfile *objfile = (struct objfile *) arg;
+
+      if (find_minimal_symbol_address (symbol_list[i].name, addrp,
+                                      objfile) != 0)
+       {
+         DEBUG_AGENT ("symbol `%s' not found\n", symbol_list[i].name);
+         return -1;
+       }
+    }
+
+  all_agent_symbols_looked_up = 1;
+  return 0;
+}
+
+static unsigned int
+agent_get_helper_thread_id (void)
+{
+  if  (helper_thread_id == 0)
+    {
+      if (target_read_uint32 (ipa_sym_addrs.addr_helper_thread_id,
+                             &helper_thread_id))
+       warning (_("Error reading helper thread's id in lib"));
+    }
+
+  return helper_thread_id;
+}
+
+#ifdef HAVE_SYS_UN_H
+#include <sys/socket.h>
+#include <sys/un.h>
+#define SOCK_DIR P_tmpdir
+
+#ifndef UNIX_PATH_MAX
+#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *) NULL)->sun_path)
+#endif
+
+#endif
+
+/* Connects to synchronization socket.  PID is the pid of inferior, which is
+   used to set up the connection socket.  */
+
+static int
+gdb_connect_sync_socket (int pid)
+{
+#ifdef HAVE_SYS_UN_H
+  struct sockaddr_un addr;
+  int res, fd;
+  char path[UNIX_PATH_MAX];
+
+  res = xsnprintf (path, UNIX_PATH_MAX, "%s/gdb_ust%d", P_tmpdir, pid);
+  if (res >= UNIX_PATH_MAX)
+    return -1;
+
+  res = fd = gdb_socket_cloexec (PF_UNIX, SOCK_STREAM, 0);
+  if (res == -1)
+    {
+      warning (_("error opening sync socket: %s"), strerror (errno));
+      return -1;
+    }
+
+  addr.sun_family = AF_UNIX;
+
+  res = xsnprintf (addr.sun_path, UNIX_PATH_MAX, "%s", path);
+  if (res >= UNIX_PATH_MAX)
+    {
+      warning (_("string overflow allocating socket name"));
+      close (fd);
+      return -1;
+    }
+
+  res = connect (fd, (struct sockaddr *) &addr, sizeof (addr));
+  if (res == -1)
+    {
+      warning (_("error connecting sync socket (%s): %s. "
+                "Make sure the directory exists and that it is writable."),
+                path, strerror (errno));
+      close (fd);
+      return -1;
+    }
+
+  return fd;
+#else
+  return -1;
+#endif
+}
+
+/* Execute an agent command in the inferior.  PID is the value of pid of the
+   inferior.  CMD is the buffer for command.  GDB or GDBserver will store the
+   command into it and fetch the return result from CMD.  The interaction
+   between GDB/GDBserver and the agent is synchronized by a synchronization
+   socket.  Return zero if success, otherwise return non-zero.  */
+
+int
+agent_run_command (int pid, const char *cmd, int len)
+{
+  int fd;
+  int tid = agent_get_helper_thread_id ();
+  ptid_t ptid = ptid_t (pid, tid, 0);
+
+  int ret = target_write_memory (ipa_sym_addrs.addr_cmd_buf,
+                                (gdb_byte *) cmd, len);
+
+  if (ret != 0)
+    {
+      warning (_("unable to write"));
+      return -1;
+    }
+
+  DEBUG_AGENT ("agent: resumed helper thread\n");
+
+  /* Resume helper thread.  */
+  target_continue_no_signal (ptid);
+
+  fd = gdb_connect_sync_socket (pid);
+  if (fd >= 0)
+    {
+      char buf[1] = "";
+
+      DEBUG_AGENT ("agent: signalling helper thread\n");
+
+      do
+       {
+         ret = write (fd, buf, 1);
+       } while (ret == -1 && errno == EINTR);
+
+       DEBUG_AGENT ("agent: waiting for helper thread's response\n");
+
+      do
+       {
+         ret = read (fd, buf, 1);
+       } while (ret == -1 && errno == EINTR);
+
+      close (fd);
+
+      DEBUG_AGENT ("agent: helper thread's response received\n");
+    }
+  else
+    return -1;
+
+  /* Need to read response with the inferior stopped.  */
+  if (ptid != null_ptid)
+    {
+      /* Stop thread PTID.  */
+      DEBUG_AGENT ("agent: stop helper thread\n");
+      target_stop_and_wait (ptid);
+    }
+
+  if (fd >= 0)
+    {
+      if (target_read_memory (ipa_sym_addrs.addr_cmd_buf, (gdb_byte *) cmd,
+                             IPA_CMD_BUF_SIZE))
+       {
+         warning (_("Error reading command response"));
+         return -1;
+       }
+    }
+
+  return 0;
+}
+
+/* Each bit of it stands for a capability of agent.  */
+static uint32_t agent_capability = 0;
+
+/* Return true if agent has capability AGENT_CAP, otherwise return false.  */
+
+int
+agent_capability_check (enum agent_capa agent_capa)
+{
+  if (agent_capability == 0)
+    {
+      if (target_read_uint32 (ipa_sym_addrs.addr_capability,
+                             &agent_capability))
+       warning (_("Error reading capability of agent"));
+    }
+  return agent_capability & agent_capa;
+}
+
+/* Invalidate the cache of agent capability, so we'll read it from inferior
+   again.  Call it when launches a new program or reconnect to remote stub.  */
+
+void
+agent_capability_invalidate (void)
+{
+  agent_capability = 0;
+}
diff --git a/gdb/gdbsupport/agent.h b/gdb/gdbsupport/agent.h
new file mode 100644 (file)
index 0000000..4f05498
--- /dev/null
@@ -0,0 +1,68 @@
+/* Shared utility routines for GDB to interact with agent.
+
+   Copyright (C) 2009-2019 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/>.  */
+
+#ifndef COMMON_AGENT_H
+#define COMMON_AGENT_H
+
+#include "gdbsupport/preprocessor.h"
+
+int agent_run_command (int pid, const char *cmd, int len);
+
+int agent_look_up_symbols (void *);
+
+#define IPA_SYM_EXPORTED_NAME(SYM) gdb_agent_ ## SYM
+
+/* Define an entry in an IPA symbol list array.  If IPA_SYM is used, the macro
+   IPA_SYM_STRUCT_NAME must be defined to the structure name holding the IPA
+   symbol addresses in that particular file, before including
+   gdbsupport/agent.h.  */
+#define IPA_SYM(SYM)                                   \
+  {                                                    \
+    STRINGIFY (IPA_SYM_EXPORTED_NAME (SYM)),           \
+    offsetof (IPA_SYM_STRUCT_NAME, addr_ ## SYM)       \
+  }
+
+/* The size in bytes of the buffer used to talk to the IPA helper
+   thread.  */
+#define IPA_CMD_BUF_SIZE 1024
+
+int agent_loaded_p (void);
+
+extern int debug_agent;
+
+extern int use_agent;
+
+/* Capability of agent.  Different agents may have different capabilities,
+   such as installing fast tracepoint or evaluating breakpoint conditions.
+   Capabilities are represented by bit-maps, and each capability occupies one
+   bit.  */
+
+enum agent_capa
+{
+  /* Capability to install fast tracepoint.  */
+  AGENT_CAPA_FAST_TRACE = 0x1,
+  /* Capability to install static tracepoint.  */
+  AGENT_CAPA_STATIC_TRACE = (0x1 << 1),
+};
+
+int agent_capability_check (enum agent_capa);
+
+void agent_capability_invalidate (void);
+
+#endif /* COMMON_AGENT_H */
diff --git a/gdb/gdbsupport/array-view.h b/gdb/gdbsupport/array-view.h
new file mode 100644 (file)
index 0000000..ad7933b
--- /dev/null
@@ -0,0 +1,259 @@
+/* Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_ARRAY_VIEW_H
+#define COMMON_ARRAY_VIEW_H
+
+#include "traits.h"
+#include <type_traits>
+
+/* An array_view is an abstraction that provides a non-owning view
+   over a sequence of contiguous objects.
+
+   A way to put it is that array_view is to std::vector (and
+   std::array and built-in arrays with rank==1) like std::string_view
+   is to std::string.
+
+   The main intent of array_view is to use it as function input
+   parameter type, making it possible to pass in any sequence of
+   contiguous objects, irrespective of whether the objects live on the
+   stack or heap and what actual container owns them.  Implicit
+   construction from the element type is supported too, making it easy
+   to call functions that expect an array of elements when you only
+   have one element (usually on the stack).  For example:
+
+    struct A { .... };
+    void function (gdb::array_view<A> as);
+
+    std::vector<A> std_vec = ...;
+    std::array<A, N> std_array = ...;
+    A array[] = {...};
+    A elem;
+
+    function (std_vec);
+    function (std_array);
+    function (array);
+    function (elem);
+
+   Views can be either mutable or const.  A const view is simply
+   created by specifying a const T as array_view template parameter,
+   in which case operator[] of non-const array_view objects ends up
+   returning const references.  Making the array_view itself const is
+   analogous to making a pointer itself be const.  I.e., disables
+   re-seating the view/pointer.
+
+   Since array_view objects are small (pointer plus size), and
+   designed to be trivially copyable, they should generally be passed
+   around by value.
+
+   You can find unit tests covering the whole API in
+   unittests/array-view-selftests.c.  */
+
+namespace gdb {
+
+template <typename T>
+class array_view
+{
+  /* True iff decayed T is the same as decayed U.  E.g., we want to
+     say that 'T&' is the same as 'const T'.  */
+  template <typename U>
+  using IsDecayedT = typename std::is_same<typename std::decay<T>::type,
+                                          typename std::decay<U>::type>;
+
+  /* True iff decayed T is the same as decayed U, and 'U *' is
+     implicitly convertible to 'T *'.  This is a requirement for
+     several methods.  */
+  template <typename U>
+  using DecayedConvertible = gdb::And<IsDecayedT<U>,
+                                     std::is_convertible<U *, T *>>;
+
+public:
+  using value_type = T;
+  using reference = T &;
+  using const_reference = const T &;
+  using size_type = size_t;
+
+  /* Default construction creates an empty view.  */
+  constexpr array_view () noexcept
+    : m_array (nullptr), m_size (0)
+  {}
+
+  /* Create an array view over a single object of the type of an
+     array_view element.  The created view as size==1.  This is
+     templated on U to allow constructing a array_view<const T> over a
+     (non-const) T.  The "convertible" requirement makes sure that you
+     can't create an array_view<T> over a const T.  */
+  template<typename U,
+          typename = Requires<DecayedConvertible<U>>>
+  constexpr array_view (U &elem) noexcept
+    : m_array (&elem), m_size (1)
+  {}
+
+  /* Same as above, for rvalue references.  */
+  template<typename U,
+          typename = Requires<DecayedConvertible<U>>>
+  constexpr array_view (U &&elem) noexcept
+    : m_array (&elem), m_size (1)
+  {}
+
+  /* Create an array view from a pointer to an array and an element
+     count.  */
+  template<typename U,
+          typename = Requires<DecayedConvertible<U>>>
+  constexpr array_view (U *array, size_t size) noexcept
+    : m_array (array), m_size (size)
+  {}
+
+  /* Create an array view from a range.  This is templated on both U
+     an V to allow passing in a mix of 'const T *' and 'T *'.  */
+  template<typename U, typename V,
+          typename = Requires<DecayedConvertible<U>>,
+          typename = Requires<DecayedConvertible<V>>>
+  constexpr array_view (U *begin, V *end) noexcept
+    : m_array (begin), m_size (end - begin)
+  {}
+
+  /* Create an array view from an array.  */
+  template<typename U, size_t Size,
+          typename = Requires<DecayedConvertible<U>>>
+  constexpr array_view (U (&array)[Size]) noexcept
+    : m_array (array), m_size (Size)
+  {}
+
+  /* Create an array view from a contiguous container.  E.g.,
+     std::vector and std::array.  */
+  template<typename Container,
+          typename = Requires<gdb::Not<IsDecayedT<Container>>>,
+          typename
+            = Requires<std::is_convertible
+                       <decltype (std::declval<Container> ().data ()),
+                        T *>>,
+          typename
+            = Requires<std::is_convertible
+                       <decltype (std::declval<Container> ().size ()),
+                        size_type>>>
+  constexpr array_view (Container &&c) noexcept
+    : m_array (c.data ()), m_size (c.size ())
+  {}
+
+  /* Observer methods.  Some of these can't be constexpr until we
+     require C++14.  */
+  /*constexpr14*/ T *data () noexcept { return m_array; }
+  constexpr const T *data () const noexcept { return m_array; }
+
+  /*constexpr14*/ T *begin () noexcept { return m_array; }
+  constexpr const T *begin () const noexcept { return m_array; }
+
+  /*constexpr14*/ T *end () noexcept { return m_array + m_size; }
+  constexpr const T *end () const noexcept { return m_array + m_size; }
+
+  /*constexpr14*/ reference operator[] (size_t index) noexcept
+  { return m_array[index]; }
+  constexpr const_reference operator[] (size_t index) const noexcept
+  { return m_array[index]; }
+
+  constexpr size_type size () const noexcept { return m_size; }
+  constexpr bool empty () const noexcept { return m_size == 0; }
+
+  /* Slice an array view.  */
+
+  /* Return a new array view over SIZE elements starting at START.  */
+  constexpr array_view<T> slice (size_type start, size_type size) const noexcept
+  { return {m_array + start, size}; }
+
+  /* Return a new array view over all the elements after START,
+     inclusive.  */
+  constexpr array_view<T> slice (size_type start) const noexcept
+  { return {m_array + start, size () - start}; }
+
+private:
+  T *m_array;
+  size_type m_size;
+};
+
+/* Compare LHS and RHS for (deep) equality.  That is, whether LHS and
+   RHS have the same sizes, and whether each pair of elements of LHS
+   and RHS at the same position compares equal.  */
+
+template <typename T>
+bool
+operator== (const gdb::array_view<T> &lhs, const gdb::array_view<T> &rhs)
+{
+  if (lhs.size () != rhs.size ())
+    return false;
+
+  for (size_t i = 0; i < lhs.size (); i++)
+    if (!(lhs[i] == rhs[i]))
+      return false;
+
+  return true;
+}
+
+/* Compare two array_views for inequality.  */
+
+template <typename T>
+bool
+operator!= (const gdb::array_view<T> &lhs, const gdb::array_view<T> &rhs)
+{
+  return !(lhs == rhs);
+}
+
+/* Create an array view from a pointer to an array and an element
+   count.
+
+   This is useful as alternative to constructing an array_view using
+   brace initialization when the size variable you have handy is of
+   signed type, since otherwise without an explicit cast the code
+   would be ill-formed.
+
+   For example, with:
+
+     extern void foo (int, int, gdb::array_view<value *>);
+
+     value *args[2];
+     int nargs;
+     foo (1, 2, {values, nargs});
+
+   You'd get:
+
+     source.c:10: error: narrowing conversion of â€˜nargs’ from â€˜int’ to
+     â€˜size_t {aka long unsigned int}’ inside { } [-Werror=narrowing]
+
+   You could fix it by writing the somewhat distracting explicit cast:
+
+     foo (1, 2, {values, (size_t) nargs});
+
+   Or by instantiating an array_view explicitly:
+
+     foo (1, 2, gdb::array_view<value *>(values, nargs));
+
+   Or, better, using make_array_view, which has the advantage of
+   inferring the arrav_view element's type:
+
+     foo (1, 2, gdb::make_array_view (values, nargs));
+*/
+
+template<typename U>
+constexpr inline array_view<U>
+make_array_view (U *array, size_t size) noexcept
+{
+  return {array, size};
+}
+
+} /* namespace gdb */
+
+#endif
diff --git a/gdb/gdbsupport/ax.def b/gdb/gdbsupport/ax.def
new file mode 100644 (file)
index 0000000..7b4c5ed
--- /dev/null
@@ -0,0 +1,97 @@
+/* Definition of agent opcode values.   -*- c -*-
+   Copyright (C) 1998-2019 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/>.  */
+
+/* The actual values of the various bytecode operations.
+
+   Other independent implementations of the agent bytecode engine will
+   rely on the exact values of these enums, and may not be recompiled
+   when we change this table.  The numeric values should remain fixed
+   whenever possible.  Thus, we assign them values explicitly here (to
+   allow gaps to form safely), and the disassembly table in
+   agentexpr.h behaves like an opcode map.  If you want to see them
+   grouped logically, see doc/agentexpr.texi.
+
+   Each line is of the form:
+   
+   DEFOP (name, size, data_size, consumed, produced, opcode)
+   
+   NAME is the name of the operation.
+   SIZE is the number of argument bytes that the operation takes from
+   the bytecode stream.
+   DATA_SIZE is the size of data operated on, in bits, for operations
+   that care (ref and const).  It is zero otherwise.
+   CONSUMED is the number of stack elements consumed.
+   PRODUCED is the number of stack elements produced.
+   OPCODE is the operation's encoding.  */
+
+DEFOP (float, 0, 0, 0, 0, 0x01)
+DEFOP (add, 0, 0, 2, 1, 0x02)
+DEFOP (sub, 0, 0, 2, 1, 0x03)
+DEFOP (mul, 0, 0, 2, 1, 0x04)
+DEFOP (div_signed, 0, 0, 2, 1, 0x05)
+DEFOP (div_unsigned, 0, 0, 2, 1, 0x06)
+DEFOP (rem_signed, 0, 0, 2, 1, 0x07)
+DEFOP (rem_unsigned, 0, 0, 2, 1, 0x08)
+DEFOP (lsh, 0, 0, 2, 1, 0x09)
+DEFOP (rsh_signed, 0, 0, 2, 1, 0x0a)
+DEFOP (rsh_unsigned, 0, 0, 2, 1, 0x0b)
+DEFOP (trace, 0, 0, 2, 0, 0x0c)
+DEFOP (trace_quick, 1, 0, 1, 1, 0x0d)
+DEFOP (log_not, 0, 0, 1, 1, 0x0e)
+DEFOP (bit_and, 0, 0, 2, 1, 0x0f)
+DEFOP (bit_or, 0, 0, 2, 1, 0x10)
+DEFOP (bit_xor, 0, 0, 2, 1, 0x11)
+DEFOP (bit_not, 0, 0, 1, 1, 0x12)
+DEFOP (equal, 0, 0, 2, 1, 0x13)
+DEFOP (less_signed, 0, 0, 2, 1, 0x14)
+DEFOP (less_unsigned, 0, 0, 2, 1, 0x15)
+DEFOP (ext, 1, 0, 1, 1, 0x16)
+DEFOP (ref8, 0, 8, 1, 1, 0x17)
+DEFOP (ref16, 0, 16, 1, 1, 0x18)
+DEFOP (ref32, 0, 32, 1, 1, 0x19)
+DEFOP (ref64, 0, 64, 1, 1, 0x1a)
+DEFOP (ref_float, 0, 0, 1, 1, 0x1b)
+DEFOP (ref_double, 0, 0, 1, 1, 0x1c)
+DEFOP (ref_long_double, 0, 0, 1, 1, 0x1d)
+DEFOP (l_to_d, 0, 0, 1, 1, 0x1e)
+DEFOP (d_to_l, 0, 0, 1, 1, 0x1f)
+DEFOP (if_goto, 2, 0, 1, 0, 0x20)
+DEFOP (goto, 2, 0, 0, 0, 0x21)
+DEFOP (const8, 1, 8, 0, 1, 0x22)
+DEFOP (const16, 2, 16, 0, 1, 0x23)
+DEFOP (const32, 4, 32, 0, 1, 0x24)
+DEFOP (const64, 8, 64, 0, 1, 0x25)
+DEFOP (reg, 2, 0, 0, 1, 0x26)
+DEFOP (end, 0, 0, 0, 0, 0x27)
+DEFOP (dup, 0, 0, 1, 2, 0x28)
+DEFOP (pop, 0, 0, 1, 0, 0x29)
+DEFOP (zero_ext, 1, 0, 1, 1, 0x2a)
+DEFOP (swap, 0, 0, 2, 2, 0x2b)
+DEFOP (getv, 2, 0, 0, 1, 0x2c)
+DEFOP (setv, 2, 0, 1, 1, 0x2d)
+DEFOP (tracev, 2, 0, 0, 1, 0x2e)
+DEFOP (tracenz, 0, 0, 2, 0, 0x2f)
+DEFOP (trace16, 2, 0, 1, 1, 0x30)
+/* We need something here just to make the tables come out ok.  */
+DEFOP (invalid2, 0, 0, 0, 0, 0x31)
+/* The "consumed" number for pick is wrong, but there's no way to
+   express the right thing.  */
+DEFOP (pick, 1, 0, 0, 1, 0x32)
+DEFOP (rot, 0, 0, 3, 3, 0x33)
+/* Both the argument and consumed numbers are dynamic for this one.  */
+DEFOP (printf, 0, 0, 0, 0, 0x34)
diff --git a/gdb/gdbsupport/break-common.h b/gdb/gdbsupport/break-common.h
new file mode 100644 (file)
index 0000000..d85cadf
--- /dev/null
@@ -0,0 +1,31 @@
+/* Data structures associated with breakpoints shared in both GDB and
+   GDBserver.
+   Copyright (C) 1992-2019 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/>.  */
+
+#ifndef COMMON_BREAK_COMMON_H
+#define COMMON_BREAK_COMMON_H
+
+enum target_hw_bp_type
+  {
+    hw_write   = 0,            /* Common  HW watchpoint */
+    hw_read    = 1,            /* Read    HW watchpoint */
+    hw_access  = 2,            /* Access  HW watchpoint */
+    hw_execute = 3             /* Execute HW breakpoint */
+  };
+
+#endif /* COMMON_BREAK_COMMON_H */
diff --git a/gdb/gdbsupport/btrace-common.c b/gdb/gdbsupport/btrace-common.c
new file mode 100644 (file)
index 0000000..13f1f1a
--- /dev/null
@@ -0,0 +1,192 @@
+/* Copyright (C) 2014-2019 Free Software Foundation, Inc.
+
+   Contributed by Intel Corp. <markus.t.metzger@intel.com>
+
+   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 "common-defs.h"
+#include "btrace-common.h"
+
+
+/* See btrace-common.h.  */
+
+const char *
+btrace_format_string (enum btrace_format format)
+{
+  switch (format)
+    {
+    case BTRACE_FORMAT_NONE:
+      return _("No or unknown format");
+
+    case BTRACE_FORMAT_BTS:
+      return _("Branch Trace Store");
+
+    case BTRACE_FORMAT_PT:
+      return _("Intel Processor Trace");
+    }
+
+  internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
+}
+
+/* See btrace-common.h.  */
+
+const char *
+btrace_format_short_string (enum btrace_format format)
+{
+  switch (format)
+    {
+    case BTRACE_FORMAT_NONE:
+      return "unknown";
+
+    case BTRACE_FORMAT_BTS:
+      return "bts";
+
+    case BTRACE_FORMAT_PT:
+      return "pt";
+    }
+
+  internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
+}
+
+/* See btrace-common.h.  */
+
+void
+btrace_data::fini ()
+{
+  switch (format)
+    {
+    case BTRACE_FORMAT_NONE:
+      /* Nothing to do.  */
+      return;
+
+    case BTRACE_FORMAT_BTS:
+      VEC_free (btrace_block_s, variant.bts.blocks);
+      return;
+
+    case BTRACE_FORMAT_PT:
+      xfree (variant.pt.data);
+      return;
+    }
+
+  internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
+}
+
+/* See btrace-common.h.  */
+
+bool
+btrace_data::empty () const
+{
+  switch (format)
+    {
+    case BTRACE_FORMAT_NONE:
+      return true;
+
+    case BTRACE_FORMAT_BTS:
+      return VEC_empty (btrace_block_s, variant.bts.blocks);
+
+    case BTRACE_FORMAT_PT:
+      return (variant.pt.size == 0);
+    }
+
+  internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
+}
+
+/* See btrace-common.h.  */
+
+void
+btrace_data::clear ()
+{
+  fini ();
+  format = BTRACE_FORMAT_NONE;
+}
+
+/* See btrace-common.h.  */
+
+int
+btrace_data_append (struct btrace_data *dst,
+                   const struct btrace_data *src)
+{
+  switch (src->format)
+    {
+    case BTRACE_FORMAT_NONE:
+      return 0;
+
+    case BTRACE_FORMAT_BTS:
+      switch (dst->format)
+       {
+       default:
+         return -1;
+
+       case BTRACE_FORMAT_NONE:
+         dst->format = BTRACE_FORMAT_BTS;
+         dst->variant.bts.blocks = NULL;
+
+         /* Fall-through.  */
+       case BTRACE_FORMAT_BTS:
+         {
+           unsigned int blk;
+
+           /* We copy blocks in reverse order to have the oldest block at
+              index zero.  */
+           blk = VEC_length (btrace_block_s, src->variant.bts.blocks);
+           while (blk != 0)
+             {
+               btrace_block_s *block;
+
+               block = VEC_index (btrace_block_s, src->variant.bts.blocks,
+                                  --blk);
+
+               VEC_safe_push (btrace_block_s, dst->variant.bts.blocks, block);
+             }
+         }
+       }
+      return 0;
+
+    case BTRACE_FORMAT_PT:
+      switch (dst->format)
+       {
+       default:
+         return -1;
+
+       case BTRACE_FORMAT_NONE:
+         dst->format = BTRACE_FORMAT_PT;
+         dst->variant.pt.data = NULL;
+         dst->variant.pt.size = 0;
+
+         /* fall-through.  */
+       case BTRACE_FORMAT_PT:
+         {
+           gdb_byte *data;
+           size_t size;
+
+           size = src->variant.pt.size + dst->variant.pt.size;
+           data = (gdb_byte *) xmalloc (size);
+
+           memcpy (data, dst->variant.pt.data, dst->variant.pt.size);
+           memcpy (data + dst->variant.pt.size, src->variant.pt.data,
+                   src->variant.pt.size);
+
+           xfree (dst->variant.pt.data);
+
+           dst->variant.pt.data = data;
+           dst->variant.pt.size = size;
+         }
+       }
+      return 0;
+    }
+
+  internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
+}
diff --git a/gdb/gdbsupport/btrace-common.h b/gdb/gdbsupport/btrace-common.h
new file mode 100644 (file)
index 0000000..0b18924
--- /dev/null
@@ -0,0 +1,257 @@
+/* Branch trace support for GDB, the GNU debugger.
+
+   Copyright (C) 2013-2019 Free Software Foundation, Inc.
+
+   Contributed by Intel Corp. <markus.t.metzger@intel.com>.
+
+   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/>.  */
+
+#ifndef COMMON_BTRACE_COMMON_H
+#define COMMON_BTRACE_COMMON_H
+
+/* Branch tracing (btrace) is a per-thread control-flow execution trace of the
+   inferior.  For presentation purposes, the branch trace is represented as a
+   list of sequential control-flow blocks, one such list per thread.  */
+
+#include "vec.h"
+
+/* A branch trace block.
+
+   This represents a block of sequential control-flow.  Adjacent blocks will be
+   connected via calls, returns, or jumps.  The latter can be direct or
+   indirect, conditional or unconditional.  Branches can further be
+   asynchronous, e.g. interrupts.  */
+struct btrace_block
+{
+  /* The address of the first byte of the first instruction in the block.
+     The address may be zero if we do not know the beginning of this block,
+     such as for the first block in a delta trace.  */
+  CORE_ADDR begin;
+
+  /* The address of the first byte of the last instruction in the block.  */
+  CORE_ADDR end;
+};
+
+/* Define functions operating on a vector of branch trace blocks.  */
+typedef struct btrace_block btrace_block_s;
+DEF_VEC_O (btrace_block_s);
+
+/* Enumeration of btrace formats.  */
+
+enum btrace_format
+{
+  /* No branch trace format.  */
+  BTRACE_FORMAT_NONE,
+
+  /* Branch trace is in Branch Trace Store (BTS) format.
+     Actually, the format is a sequence of blocks derived from BTS.  */
+  BTRACE_FORMAT_BTS,
+
+  /* Branch trace is in Intel Processor Trace format.  */
+  BTRACE_FORMAT_PT
+};
+
+/* An enumeration of cpu vendors.  */
+
+enum btrace_cpu_vendor
+{
+  /* We do not know this vendor.  */
+  CV_UNKNOWN,
+
+  /* Intel.  */
+  CV_INTEL
+};
+
+/* A cpu identifier.  */
+
+struct btrace_cpu
+{
+  /* The processor vendor.  */
+  enum btrace_cpu_vendor vendor;
+
+  /* The cpu family.  */
+  unsigned short family;
+
+  /* The cpu model.  */
+  unsigned char model;
+
+  /* The cpu stepping.  */
+  unsigned char stepping;
+};
+
+/* A BTS configuration.  */
+
+struct btrace_config_bts
+{
+  /* The size of the branch trace buffer in bytes.
+
+     This is unsigned int and not size_t since it is registered as
+     control variable for "set record btrace bts buffer-size".  */
+  unsigned int size;
+};
+
+/* An Intel Processor Trace configuration.  */
+
+struct btrace_config_pt
+{
+  /* The size of the branch trace buffer in bytes.
+
+     This is unsigned int and not size_t since it is registered as
+     control variable for "set record btrace pt buffer-size".  */
+  unsigned int size;
+};
+
+/* A branch tracing configuration.
+
+   This describes the requested configuration as well as the actually
+   obtained configuration.
+   We describe the configuration for all different formats so we can
+   easily switch between formats.  */
+
+struct btrace_config
+{
+  /* The branch tracing format.  */
+  enum btrace_format format;
+
+  /* The BTS format configuration.  */
+  struct btrace_config_bts bts;
+
+  /* The Intel Processor Trace format configuration.  */
+  struct btrace_config_pt pt;
+};
+
+/* Branch trace in BTS format.  */
+struct btrace_data_bts
+{
+  /* Branch trace is represented as a vector of branch trace blocks starting
+     with the most recent block.  */
+  VEC (btrace_block_s) *blocks;
+};
+
+/* Configuration information to go with the trace data.  */
+struct btrace_data_pt_config
+{
+  /* The processor on which the trace has been collected.  */
+  struct btrace_cpu cpu;
+};
+
+/* Branch trace in Intel Processor Trace format.  */
+struct btrace_data_pt
+{
+  /* Some configuration information to go with the data.  */
+  struct btrace_data_pt_config config;
+
+  /* The trace data.  */
+  gdb_byte *data;
+
+  /* The size of DATA in bytes.  */
+  size_t size;
+};
+
+/* The branch trace data.  */
+struct btrace_data
+{
+  btrace_data () = default;
+
+  ~btrace_data ()
+  {
+    fini ();
+  }
+
+  btrace_data &operator= (btrace_data &&other)
+  {
+    if (this != &other)
+      {
+       fini ();
+       format = other.format;
+       variant = other.variant;
+       other.format = BTRACE_FORMAT_NONE;
+      }
+    return *this;
+  }
+
+  /* Return true if this is empty; false otherwise.  */
+  bool empty () const;
+
+  /* Clear this object.  */
+  void clear ();
+
+  enum btrace_format format = BTRACE_FORMAT_NONE;
+
+  union
+  {
+    /* Format == BTRACE_FORMAT_BTS.  */
+    struct btrace_data_bts bts;
+
+    /* Format == BTRACE_FORMAT_PT.  */
+    struct btrace_data_pt pt;
+  } variant;
+
+private:
+
+  DISABLE_COPY_AND_ASSIGN (btrace_data);
+
+  void fini ();
+};
+
+/* Target specific branch trace information.  */
+struct btrace_target_info;
+
+/* Enumeration of btrace read types.  */
+
+enum btrace_read_type
+{
+  /* Send all available trace.  */
+  BTRACE_READ_ALL,
+
+  /* Send all available trace, if it changed.  */
+  BTRACE_READ_NEW,
+
+  /* Send the trace since the last request.  This will fail if the trace
+     buffer overflowed.  */
+  BTRACE_READ_DELTA
+};
+
+/* Enumeration of btrace errors.  */
+
+enum btrace_error
+{
+  /* No error.  Everything is OK.  */
+  BTRACE_ERR_NONE,
+
+  /* An unknown error.  */
+  BTRACE_ERR_UNKNOWN,
+
+  /* Branch tracing is not supported on this system.  */
+  BTRACE_ERR_NOT_SUPPORTED,
+
+  /* The branch trace buffer overflowed; no delta read possible.  */
+  BTRACE_ERR_OVERFLOW
+};
+
+/* Return a string representation of FORMAT.  */
+extern const char *btrace_format_string (enum btrace_format format);
+
+/* Return an abbreviation string representation of FORMAT.  */
+extern const char *btrace_format_short_string (enum btrace_format format);
+
+/* Append the branch trace data from SRC to the end of DST.
+   Both SRC and DST must use the same format.
+   Returns zero on success; a negative number otherwise.  */
+extern int btrace_data_append (struct btrace_data *dst,
+                              const struct btrace_data *src);
+
+#endif /* COMMON_BTRACE_COMMON_H */
diff --git a/gdb/gdbsupport/buffer.c b/gdb/gdbsupport/buffer.c
new file mode 100644 (file)
index 0000000..3c919e7
--- /dev/null
@@ -0,0 +1,178 @@
+/* A simple growing buffer for GDB.
+  
+   Copyright (C) 2009-2019 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 "common-defs.h"
+#include "xml-utils.h"
+#include "buffer.h"
+#include "inttypes.h"
+void
+buffer_grow (struct buffer *buffer, const char *data, size_t size)
+{
+  char *new_buffer;
+  size_t new_buffer_size;
+
+  if (size == 0)
+    return;
+
+  new_buffer_size = buffer->buffer_size;
+
+  if (new_buffer_size == 0)
+    new_buffer_size = 1;
+
+  while (buffer->used_size + size > new_buffer_size)
+    new_buffer_size *= 2;
+  new_buffer = (char *) xrealloc (buffer->buffer, new_buffer_size);
+  memcpy (new_buffer + buffer->used_size, data, size);
+  buffer->buffer = new_buffer;
+  buffer->buffer_size = new_buffer_size;
+  buffer->used_size += size;
+}
+
+void
+buffer_free (struct buffer *buffer)
+{
+  if (!buffer)
+    return;
+
+  xfree (buffer->buffer);
+  buffer->buffer = NULL;
+  buffer->buffer_size = 0;
+  buffer->used_size = 0;
+}
+
+void
+buffer_init (struct buffer *buffer)
+{
+  memset (buffer, 0, sizeof (*buffer));
+}
+
+char*
+buffer_finish (struct buffer *buffer)
+{
+  char *ret = buffer->buffer;
+  buffer->buffer = NULL;
+  buffer->buffer_size = 0;
+  buffer->used_size = 0;
+  return ret;
+}
+
+void
+buffer_xml_printf (struct buffer *buffer, const char *format, ...)
+{
+  va_list ap;
+  const char *f;
+  const char *prev;
+  int percent = 0;
+
+  va_start (ap, format);
+
+  prev = format;
+  for (f = format; *f; f++)
+    {
+      if (percent)
+       {
+         char buf[32];
+         char *str = buf;
+         const char *f_old = f;
+         
+         switch (*f)
+           {
+           case 's':
+             str = va_arg (ap, char *);
+             break;
+           case 'd':
+             sprintf (str, "%d", va_arg (ap, int));
+             break;
+           case 'u':
+             sprintf (str, "%u", va_arg (ap, unsigned int));
+             break;
+           case 'x':
+             sprintf (str, "%x", va_arg (ap, unsigned int));
+             break;
+           case 'o':
+             sprintf (str, "%o", va_arg (ap, unsigned int));
+             break;
+           case 'l':
+             f++;
+             switch (*f)
+               {
+               case 'd':
+                 sprintf (str, "%ld", va_arg (ap, long));
+                 break;
+               case 'u':
+                 sprintf (str, "%lu", va_arg (ap, unsigned long));
+                 break;
+               case 'x':
+                 sprintf (str, "%lx", va_arg (ap, unsigned long));
+                 break;
+               case 'o':
+                 sprintf (str, "%lo", va_arg (ap, unsigned long));
+                 break;
+               case 'l':
+                 f++;
+                 switch (*f)
+                   {
+                   case 'd':
+                     sprintf (str, "%" PRId64,
+                              (int64_t) va_arg (ap, long long));
+                     break;
+                   case 'u':
+                     sprintf (str, "%" PRIu64,
+                              (uint64_t) va_arg (ap, unsigned long long));
+                     break;
+                   case 'x':
+                     sprintf (str, "%" PRIx64,
+                              (uint64_t) va_arg (ap, unsigned long long));
+                     break;
+                   case 'o':
+                     sprintf (str, "%" PRIo64,
+                              (uint64_t) va_arg (ap, unsigned long long));
+                     break;
+                   default:
+                     str = 0;
+                     break;
+                   }
+                 break;
+               default:
+                 str = 0;
+                 break;
+               }
+             break;
+           default:
+             str = 0;
+             break;
+           }
+
+         if (str)
+           {
+             buffer_grow (buffer, prev, f_old - prev - 1);
+             std::string p = xml_escape_text (str);
+             buffer_grow_str (buffer, p.c_str ());
+             prev = f + 1;
+           }
+         percent = 0;
+       }
+      else if (*f == '%')
+       percent = 1;
+    }
+
+  buffer_grow_str (buffer, prev);
+  va_end (ap);
+}
+
diff --git a/gdb/gdbsupport/buffer.h b/gdb/gdbsupport/buffer.h
new file mode 100644 (file)
index 0000000..8b24b54
--- /dev/null
@@ -0,0 +1,68 @@
+/* A simple growing buffer for GDB.
+  
+   Copyright (C) 2009-2019 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/>.  */
+
+#ifndef COMMON_BUFFER_H
+#define COMMON_BUFFER_H
+
+struct buffer
+{
+  char *buffer;
+  size_t buffer_size; /* allocated size */
+  size_t used_size; /* actually used size */
+};
+
+/* Append DATA of size SIZE to the end of BUFFER.  Grows the buffer to
+   accommodate the new data.  */
+void buffer_grow (struct buffer *buffer, const char *data, size_t size);
+
+/* Append C to the end of BUFFER.  Grows the buffer to accommodate the
+   new data.  */
+
+static inline void
+buffer_grow_char (struct buffer *buffer, char c)
+{
+  buffer_grow (buffer, &c, 1);
+}
+
+/* Release any memory held by BUFFER.  */
+void buffer_free (struct buffer *buffer);
+
+/* Initialize BUFFER.  BUFFER holds no memory afterwards.  */
+void buffer_init (struct buffer *buffer);
+
+/* Return a pointer into BUFFER data, effectively transferring
+   ownership of the buffer memory to the caller.  Calling buffer_free
+   afterwards has no effect on the returned data.  */
+char* buffer_finish (struct buffer *buffer);
+
+/* Simple printf to buffer function.  Current implemented formatters:
+   %s - grow an xml escaped text in BUFFER.
+   %d - grow an signed integer in BUFFER.
+   %u - grow an unsigned integer in BUFFER.
+   %x - grow an unsigned integer formatted in hexadecimal in BUFFER.
+   %o - grow an unsigned integer formatted in octal in BUFFER.  */
+void buffer_xml_printf (struct buffer *buffer, const char *format, ...)
+  ATTRIBUTE_PRINTF (2, 3);
+
+#define buffer_grow_str(BUFFER,STRING)         \
+  buffer_grow (BUFFER, STRING, strlen (STRING))
+#define buffer_grow_str0(BUFFER,STRING)                        \
+  buffer_grow (BUFFER, STRING, strlen (STRING) + 1)
+
+#endif /* COMMON_BUFFER_H */
diff --git a/gdb/gdbsupport/byte-vector.h b/gdb/gdbsupport/byte-vector.h
new file mode 100644 (file)
index 0000000..5dec301
--- /dev/null
@@ -0,0 +1,63 @@
+/* Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_BYTE_VECTOR_H
+#define COMMON_BYTE_VECTOR_H
+
+#include "gdbsupport/def-vector.h"
+
+namespace gdb {
+
+/* byte_vector is a gdb_byte std::vector with a custom allocator that
+   unlike std::vector<gdb_byte> does not zero-initialize new elements
+   by default when the vector is created/resized.  This is what you
+   usually want when working with byte buffers, since if you're
+   creating or growing a buffer you'll most surely want to fill it in
+   with data, in which case zero-initialization would be a
+   pessimization.  For example:
+
+     gdb::byte_vector buf (some_large_size);
+     fill_with_data (buf.data (), buf.size ());
+
+   On the odd case you do need zero initialization, then you can still
+   call the overloads that specify an explicit value, like:
+
+     gdb::byte_vector buf (some_initial_size, 0);
+     buf.resize (a_bigger_size, 0);
+
+   (Or use std::vector<gdb_byte> instead.)
+
+   Note that unlike std::vector<gdb_byte>, function local
+   gdb::byte_vector objects constructed with an initial size like:
+
+     gdb::byte_vector buf (some_size);
+     fill_with_data (buf.data (), buf.size ());
+
+   usually compile down to the exact same as:
+
+     std::unique_ptr<byte[]> buf (new gdb_byte[some_size]);
+     fill_with_data (buf.get (), some_size);
+
+   with the former having the advantage of being a bit more readable,
+   and providing the whole std::vector API, if you end up needing it.
+*/
+using byte_vector = gdb::def_vector<gdb_byte>;
+using char_vector = gdb::def_vector<char>;
+
+} /* namespace gdb */
+
+#endif /* COMMON_DEF_VECTOR_H */
diff --git a/gdb/gdbsupport/cleanups.c b/gdb/gdbsupport/cleanups.c
new file mode 100644 (file)
index 0000000..121720d
--- /dev/null
@@ -0,0 +1,144 @@
+/* Cleanup routines for GDB, the GNU debugger.
+
+   Copyright (C) 1986-2019 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 "common-defs.h"
+#include "cleanups.h"
+
+/* The cleanup list records things that have to be undone
+   if an error happens (descriptors to be closed, memory to be freed, etc.)
+   Each link in the chain records a function to call and an
+   argument to give it.
+
+   Use make_cleanup to add an element to the cleanup chain.
+   Use do_cleanups to do all cleanup actions back to a given
+   point in the chain.  Use discard_cleanups to remove cleanups
+   from the chain back to a given point, not doing them.
+
+   If the argument is pointer to allocated memory, then you need
+   to additionally set the 'free_arg' member to a function that will
+   free that memory.  This function will be called both when the cleanup
+   is executed and when it's discarded.  */
+
+struct cleanup
+{
+  struct cleanup *next;
+  void (*function) (void *);
+  void (*free_arg) (void *);
+  void *arg;
+};
+
+/* Used to mark the end of a cleanup chain.
+   The value is chosen so that it:
+   - is non-NULL so that make_cleanup never returns NULL,
+   - causes a segv if dereferenced
+     [though this won't catch errors that a value of, say,
+     ((struct cleanup *) -1) will]
+   - displays as something useful when printed in gdb.
+   This is const for a bit of extra robustness.
+   It is initialized to coax gcc into putting it into .rodata.
+   All fields are initialized to survive -Wextra.  */
+static const struct cleanup sentinel_cleanup = { 0, 0, 0, 0 };
+
+/* Handy macro to use when referring to sentinel_cleanup.  */
+#define SENTINEL_CLEANUP ((struct cleanup *) &sentinel_cleanup)
+
+/* Chain of cleanup actions established with make_final_cleanup,
+   to be executed when gdb exits.  */
+static struct cleanup *final_cleanup_chain = SENTINEL_CLEANUP;
+
+/* Main worker routine to create a cleanup.
+   PMY_CHAIN is a pointer to either cleanup_chain or final_cleanup_chain.
+   FUNCTION is the function to call to perform the cleanup.
+   ARG is passed to FUNCTION when called.
+   FREE_ARG, if non-NULL, is called after the cleanup is performed.
+
+   The result is a pointer to the previous chain pointer
+   to be passed later to do_cleanups or discard_cleanups.  */
+
+static struct cleanup *
+make_my_cleanup2 (struct cleanup **pmy_chain, make_cleanup_ftype *function,
+                 void *arg,  void (*free_arg) (void *))
+{
+  struct cleanup *newobj = XNEW (struct cleanup);
+  struct cleanup *old_chain = *pmy_chain;
+
+  newobj->next = *pmy_chain;
+  newobj->function = function;
+  newobj->free_arg = free_arg;
+  newobj->arg = arg;
+  *pmy_chain = newobj;
+
+  gdb_assert (old_chain != NULL);
+  return old_chain;
+}
+
+/* Worker routine to create a cleanup without a destructor.
+   PMY_CHAIN is a pointer to either cleanup_chain or final_cleanup_chain.
+   FUNCTION is the function to call to perform the cleanup.
+   ARG is passed to FUNCTION when called.
+
+   The result is a pointer to the previous chain pointer
+   to be passed later to do_cleanups or discard_cleanups.  */
+
+static struct cleanup *
+make_my_cleanup (struct cleanup **pmy_chain, make_cleanup_ftype *function,
+                void *arg)
+{
+  return make_my_cleanup2 (pmy_chain, function, arg, NULL);
+}
+
+/* Add a new cleanup to the final cleanup_chain,
+   and return the previous chain pointer
+   to be passed later to do_cleanups or discard_cleanups.
+   Args are FUNCTION to clean up with, and ARG to pass to it.  */
+
+struct cleanup *
+make_final_cleanup (make_cleanup_ftype *function, void *arg)
+{
+  return make_my_cleanup (&final_cleanup_chain, function, arg);
+}
+
+/* Worker routine to perform cleanups.
+   PMY_CHAIN is a pointer to either cleanup_chain or final_cleanup_chain.
+   OLD_CHAIN is the result of a "make" cleanup routine.
+   Cleanups are performed until we get back to the old end of the chain.  */
+
+static void
+do_my_cleanups (struct cleanup **pmy_chain,
+               struct cleanup *old_chain)
+{
+  struct cleanup *ptr;
+
+  while ((ptr = *pmy_chain) != old_chain)
+    {
+      *pmy_chain = ptr->next;  /* Do this first in case of recursion.  */
+      (*ptr->function) (ptr->arg);
+      if (ptr->free_arg)
+       (*ptr->free_arg) (ptr->arg);
+      xfree (ptr);
+    }
+}
+
+/* Discard final cleanups and do the actions they describe.  */
+
+void
+do_final_cleanups ()
+{
+  do_my_cleanups (&final_cleanup_chain, SENTINEL_CLEANUP);
+}
diff --git a/gdb/gdbsupport/cleanups.h b/gdb/gdbsupport/cleanups.h
new file mode 100644 (file)
index 0000000..e676076
--- /dev/null
@@ -0,0 +1,39 @@
+/* Cleanups.
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_CLEANUPS_H
+#define COMMON_CLEANUPS_H
+
+/* Outside of cleanups.c, this is an opaque type.  */
+struct cleanup;
+
+/* NOTE: cagney/2000-03-04: This typedef is strictly for the
+   make_cleanup function declarations below.  Do not use this typedef
+   as a cast when passing functions into the make_cleanup() code.
+   Instead either use a bounce function or add a wrapper function.
+   Calling a f(char*) function with f(void*) is non-portable.  */
+typedef void (make_cleanup_ftype) (void *);
+
+/* Function type for the dtor in make_cleanup_dtor.  */
+typedef void (make_cleanup_dtor_ftype) (void *);
+
+extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
+
+extern void do_final_cleanups ();
+
+#endif /* COMMON_CLEANUPS_H */
diff --git a/gdb/gdbsupport/common-debug.c b/gdb/gdbsupport/common-debug.c
new file mode 100644 (file)
index 0000000..97c9003
--- /dev/null
@@ -0,0 +1,37 @@
+/* Debug printing functions.
+
+   Copyright (C) 2014-2019 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 "common-defs.h"
+#include "common-debug.h"
+
+/* See gdbsupport/common-debug.h.  */
+
+int show_debug_regs;
+
+/* See gdbsupport/common-debug.h.  */
+
+void
+debug_printf (const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start (ap, fmt);
+  debug_vprintf (fmt, ap);
+  va_end (ap);
+}
diff --git a/gdb/gdbsupport/common-debug.h b/gdb/gdbsupport/common-debug.h
new file mode 100644 (file)
index 0000000..d5bfc9e
--- /dev/null
@@ -0,0 +1,41 @@
+/* Declarations for debug printing functions.
+
+   Copyright (C) 2014-2019 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/>.  */
+
+#ifndef COMMON_COMMON_DEBUG_H
+#define COMMON_COMMON_DEBUG_H
+
+/* Set to nonzero to enable debugging of hardware breakpoint/
+   watchpoint support code.  */
+
+extern int show_debug_regs;
+
+/* Print a formatted message to the appropriate channel for
+   debugging output for the client.  */
+
+extern void debug_printf (const char *format, ...)
+     ATTRIBUTE_PRINTF (1, 2);
+
+/* Print a formatted message to the appropriate channel for
+   debugging output for the client.  This function must be
+   provided by the client.  */
+
+extern void debug_vprintf (const char *format, va_list ap)
+     ATTRIBUTE_PRINTF (1, 0);
+
+#endif /* COMMON_COMMON_DEBUG_H */
diff --git a/gdb/gdbsupport/common-defs.h b/gdb/gdbsupport/common-defs.h
new file mode 100644 (file)
index 0000000..203bd89
--- /dev/null
@@ -0,0 +1,150 @@
+/* Common definitions.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_COMMON_DEFS_H
+#define COMMON_COMMON_DEFS_H
+
+#include "config.h"
+
+#undef PACKAGE_NAME
+#undef PACKAGE_VERSION
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+
+#ifdef GDBSERVER
+#include "build-gnulib-gdbserver/config.h"
+#else
+#include "../../gnulib/config.h"
+#endif
+
+#undef PACKAGE_NAME
+#undef PACKAGE_VERSION
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+
+/* From:
+    https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html
+
+   "On some hosts that predate C++11, when using C++ one must define
+   __STDC_CONSTANT_MACROS to make visible the definitions of constant
+   macros such as INTMAX_C, and one must define __STDC_LIMIT_MACROS to
+   make visible the definitions of limit macros such as INTMAX_MAX.".
+
+   And:
+    https://www.gnu.org/software/gnulib/manual/html_node/inttypes_002eh.html
+
+   "On some hosts that predate C++11, when using C++ one must define
+   __STDC_FORMAT_MACROS to make visible the declarations of format
+   macros such as PRIdMAX."
+
+   Must do this before including any system header, since other system
+   headers may include stdint.h/inttypes.h.  */
+#define __STDC_CONSTANT_MACROS 1
+#define __STDC_LIMIT_MACROS 1
+#define __STDC_FORMAT_MACROS 1
+
+/* Some distros enable _FORTIFY_SOURCE by default, which on occasion
+   has caused build failures with -Wunused-result when a patch is
+   developed on a distro that does not enable _FORTIFY_SOURCE.  We
+   enable it here in order to try to catch these problems earlier;
+   plus this seems like a reasonable safety measure.  The check for
+   optimization is required because _FORTIFY_SOURCE only works when
+   optimization is enabled.  If _FORTIFY_SOURCE is already defined,
+   then we don't do anything.  */
+
+#if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
+#define _FORTIFY_SOURCE 2
+#endif
+
+/* We don't support Windows versions before XP, so we define
+   _WIN32_WINNT correspondingly to ensure the Windows API headers
+   expose the required symbols.  */
+#if defined (__MINGW32__) || defined (__CYGWIN__)
+# ifdef _WIN32_WINNT
+#  if _WIN32_WINNT < 0x0501
+#   undef _WIN32_WINNT
+#   define _WIN32_WINNT 0x0501
+#  endif
+# else
+#  define _WIN32_WINNT 0x0501
+# endif
+#endif /* __MINGW32__ || __CYGWIN__ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#ifdef HAVE_STRINGS_H
+#include <strings.h>   /* for strcasecmp and strncasecmp */
+#endif
+#include <errno.h>
+#include <alloca.h>
+
+#include "ansidecl.h"
+/* This is defined by ansidecl.h, but we prefer gnulib's version.  On
+   MinGW, gnulib might enable __USE_MINGW_ANSI_STDIO, which may or not
+   require use of attribute gnu_printf instead of printf.  gnulib
+   checks that at configure time.  Since _GL_ATTRIBUTE_FORMAT_PRINTF
+   is compatible with ATTRIBUTE_PRINTF, simply use it.  */
+#undef ATTRIBUTE_PRINTF
+#define ATTRIBUTE_PRINTF _GL_ATTRIBUTE_FORMAT_PRINTF
+
+#if GCC_VERSION >= 3004
+#define ATTRIBUTE_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
+#else
+#define ATTRIBUTE_UNUSED_RESULT
+#endif
+
+#include "libiberty.h"
+#include "pathmax.h"
+#include "gdb/signals.h"
+#include "gdb_locale.h"
+#include "ptid.h"
+#include "common-types.h"
+#include "common-utils.h"
+#include "gdb_assert.h"
+#include "errors.h"
+#include "print-utils.h"
+#include "common-debug.h"
+#include "cleanups.h"
+#include "common-exceptions.h"
+#include "gdbsupport/poison.h"
+
+#define EXTERN_C extern "C"
+#define EXTERN_C_PUSH extern "C" {
+#define EXTERN_C_POP }
+
+/* Pull in gdb::unique_xmalloc_ptr.  */
+#include "gdbsupport/gdb_unique_ptr.h"
+
+/* String containing the current directory (what getwd would return).  */
+extern char *current_directory;
+
+/* sbrk on macOS is not useful for our purposes, since sbrk(0) always
+   returns the same value.  brk/sbrk on macOS is just an emulation
+   that always returns a pointer to a 4MB section reserved for
+   that.  */
+
+#if defined (HAVE_SBRK) && !__APPLE__
+#define HAVE_USEFUL_SBRK 1
+#endif
+
+#endif /* COMMON_COMMON_DEFS_H */
diff --git a/gdb/gdbsupport/common-exceptions.c b/gdb/gdbsupport/common-exceptions.c
new file mode 100644 (file)
index 0000000..9f21025
--- /dev/null
@@ -0,0 +1,235 @@
+/* Exception (throw catch) mechanism, for GDB, the GNU debugger.
+
+   Copyright (C) 1986-2019 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 "common-defs.h"
+#include "common-exceptions.h"
+#include <forward_list>
+
+/* Possible catcher states.  */
+enum catcher_state {
+  /* Initial state, a new catcher has just been created.  */
+  CATCHER_CREATED,
+  /* The catch code is running.  */
+  CATCHER_RUNNING,
+  CATCHER_RUNNING_1,
+  /* The catch code threw an exception.  */
+  CATCHER_ABORTING
+};
+
+/* Possible catcher actions.  */
+enum catcher_action {
+  CATCH_ITER,
+  CATCH_ITER_1,
+  CATCH_THROWING
+};
+
+struct catcher
+{
+  enum catcher_state state = CATCHER_CREATED;
+  /* Jump buffer pointing back at the exception handler.  */
+  jmp_buf buf;
+  /* Status buffer belonging to the exception handler.  */
+  struct gdb_exception exception;
+};
+
+/* Where to go for throw_exception().  */
+static std::forward_list<struct catcher> catchers;
+
+jmp_buf *
+exceptions_state_mc_init ()
+{
+  catchers.emplace_front ();
+  return &catchers.front ().buf;
+}
+
+/* Catcher state machine.  Returns non-zero if the m/c should be run
+   again, zero if it should abort.  */
+
+static int
+exceptions_state_mc (enum catcher_action action)
+{
+  switch (catchers.front ().state)
+    {
+    case CATCHER_CREATED:
+      switch (action)
+       {
+       case CATCH_ITER:
+         /* Allow the code to run the catcher.  */
+         catchers.front ().state = CATCHER_RUNNING;
+         return 1;
+       default:
+         internal_error (__FILE__, __LINE__, _("bad state"));
+       }
+    case CATCHER_RUNNING:
+      switch (action)
+       {
+       case CATCH_ITER:
+         /* No error/quit has occured.  */
+         return 0;
+       case CATCH_ITER_1:
+         catchers.front ().state = CATCHER_RUNNING_1;
+         return 1;
+       case CATCH_THROWING:
+         catchers.front ().state = CATCHER_ABORTING;
+         /* See also throw_exception.  */
+         return 1;
+       default:
+         internal_error (__FILE__, __LINE__, _("bad switch"));
+       }
+    case CATCHER_RUNNING_1:
+      switch (action)
+       {
+       case CATCH_ITER:
+         /* The did a "break" from the inner while loop.  */
+         return 0;
+       case CATCH_ITER_1:
+         catchers.front ().state = CATCHER_RUNNING;
+         return 0;
+       case CATCH_THROWING:
+         catchers.front ().state = CATCHER_ABORTING;
+         /* See also throw_exception.  */
+         return 1;
+       default:
+         internal_error (__FILE__, __LINE__, _("bad switch"));
+       }
+    case CATCHER_ABORTING:
+      switch (action)
+       {
+       case CATCH_ITER:
+         {
+           /* Exit normally if this catcher can handle this
+              exception.  The caller analyses the func return
+              values.  */
+           return 0;
+         }
+       default:
+         internal_error (__FILE__, __LINE__, _("bad state"));
+       }
+    default:
+      internal_error (__FILE__, __LINE__, _("bad switch"));
+    }
+}
+
+int
+exceptions_state_mc_catch (struct gdb_exception *exception,
+                          int mask)
+{
+  *exception = std::move (catchers.front ().exception);
+  catchers.pop_front ();
+
+  if (exception->reason < 0)
+    {
+      if (mask & RETURN_MASK (exception->reason))
+       {
+         /* Exit normally and let the caller handle the
+            exception.  */
+         return 1;
+       }
+
+      /* The caller didn't request that the event be caught, relay the
+        event to the next exception_catch/CATCH_SJLJ.  */
+      throw_exception_sjlj (*exception);
+    }
+
+  /* No exception was thrown.  */
+  return 0;
+}
+
+int
+exceptions_state_mc_action_iter (void)
+{
+  return exceptions_state_mc (CATCH_ITER);
+}
+
+int
+exceptions_state_mc_action_iter_1 (void)
+{
+  return exceptions_state_mc (CATCH_ITER_1);
+}
+
+/* Return EXCEPTION to the nearest containing CATCH_SJLJ block.  */
+
+void
+throw_exception_sjlj (const struct gdb_exception &exception)
+{
+  /* Jump to the nearest CATCH_SJLJ block, communicating REASON to
+     that call via setjmp's return value.  Note that REASON can't be
+     zero, by definition in common-exceptions.h.  */
+  exceptions_state_mc (CATCH_THROWING);
+  enum return_reason reason = exception.reason;
+  catchers.front ().exception = exception;
+  longjmp (catchers.front ().buf, reason);
+}
+
+/* Implementation of throw_exception that uses C++ try/catch.  */
+
+void
+throw_exception (gdb_exception &&exception)
+{
+  if (exception.reason == RETURN_QUIT)
+    throw gdb_exception_quit (std::move (exception));
+  else if (exception.reason == RETURN_ERROR)
+    throw gdb_exception_error (std::move (exception));
+  else
+    gdb_assert_not_reached ("invalid return reason");
+}
+
+static void ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0)
+throw_it (enum return_reason reason, enum errors error, const char *fmt,
+         va_list ap)
+{
+  if (reason == RETURN_QUIT)
+    throw gdb_exception_quit (fmt, ap);
+  else if (reason == RETURN_ERROR)
+    throw gdb_exception_error (error, fmt, ap);
+  else
+    gdb_assert_not_reached ("invalid return reason");
+}
+
+void
+throw_verror (enum errors error, const char *fmt, va_list ap)
+{
+  throw_it (RETURN_ERROR, error, fmt, ap);
+}
+
+void
+throw_vquit (const char *fmt, va_list ap)
+{
+  throw_it (RETURN_QUIT, GDB_NO_ERROR, fmt, ap);
+}
+
+void
+throw_error (enum errors error, const char *fmt, ...)
+{
+  va_list args;
+
+  va_start (args, fmt);
+  throw_verror (error, fmt, args);
+  va_end (args);
+}
+
+void
+throw_quit (const char *fmt, ...)
+{
+  va_list args;
+
+  va_start (args, fmt);
+  throw_vquit (fmt, args);
+  va_end (args);
+}
diff --git a/gdb/gdbsupport/common-exceptions.h b/gdb/gdbsupport/common-exceptions.h
new file mode 100644 (file)
index 0000000..ebcaf03
--- /dev/null
@@ -0,0 +1,304 @@
+/* Exception (throw catch) mechanism, for GDB, the GNU debugger.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_COMMON_EXCEPTIONS_H
+#define COMMON_COMMON_EXCEPTIONS_H
+
+#include <setjmp.h>
+#include <new>
+#include <memory>
+#include <string>
+
+/* Reasons for calling throw_exceptions().  NOTE: all reason values
+   must be different from zero.  enum value 0 is reserved for internal
+   use as the return value from an initial setjmp().  */
+
+enum return_reason
+  {
+    /* User interrupt.  */
+    RETURN_QUIT = -2,
+    /* Any other error.  */
+    RETURN_ERROR
+  };
+
+#define RETURN_MASK(reason)    (1 << (int)(-reason))
+
+typedef enum
+{
+  RETURN_MASK_QUIT = RETURN_MASK (RETURN_QUIT),
+  RETURN_MASK_ERROR = RETURN_MASK (RETURN_ERROR),
+  RETURN_MASK_ALL = (RETURN_MASK_QUIT | RETURN_MASK_ERROR)
+} return_mask;
+
+/* Describe all exceptions.  */
+
+enum errors {
+  GDB_NO_ERROR,
+
+  /* Any generic error, the corresponding text is in
+     exception.message.  */
+  GENERIC_ERROR,
+
+  /* Something requested was not found.  */
+  NOT_FOUND_ERROR,
+
+  /* Thread library lacks support necessary for finding thread local
+     storage.  */
+  TLS_NO_LIBRARY_SUPPORT_ERROR,
+
+  /* Load module not found while attempting to find thread local storage.  */
+  TLS_LOAD_MODULE_NOT_FOUND_ERROR,
+
+  /* Thread local storage has not been allocated yet.  */
+  TLS_NOT_ALLOCATED_YET_ERROR,
+
+  /* Something else went wrong while attempting to find thread local
+     storage.  The ``struct gdb_exception'' message field provides
+     more detail.  */
+  TLS_GENERIC_ERROR,
+
+  /* Problem parsing an XML document.  */
+  XML_PARSE_ERROR,
+
+  /* Error accessing memory.  */
+  MEMORY_ERROR,
+
+  /* Value not available.  E.g., a register was not collected in a
+     traceframe.  */
+  NOT_AVAILABLE_ERROR,
+
+  /* Value was optimized out.  Note: if the value was a register, this
+     means the register was not saved in the frame.  */
+  OPTIMIZED_OUT_ERROR,
+
+  /* DW_OP_entry_value resolving failed.  */
+  NO_ENTRY_VALUE_ERROR,
+
+  /* Target throwing an error has been closed.  Current command should be
+     aborted as the inferior state is no longer valid.  */
+  TARGET_CLOSE_ERROR,
+
+  /* An undefined command was executed.  */
+  UNDEFINED_COMMAND_ERROR,
+
+  /* Requested feature, method, mechanism, etc. is not supported.  */
+  NOT_SUPPORTED_ERROR,
+
+  /* The number of candidates generated during line completion has
+     reached the user's specified limit.  This isn't an error, this exception
+     is used to halt searching for more completions, but for consistency
+     "_ERROR" is appended to the name.  */
+  MAX_COMPLETIONS_REACHED_ERROR,
+
+  /* Add more errors here.  */
+  NR_ERRORS
+};
+
+struct gdb_exception
+{
+  gdb_exception ()
+    : reason ((enum return_reason) 0),
+      error (GDB_NO_ERROR)
+  {
+  }
+
+  gdb_exception (enum return_reason r, enum errors e)
+    : reason (r),
+      error (e)
+  {
+  }
+
+  gdb_exception (enum return_reason r, enum errors e,
+                const char *fmt, va_list ap)
+    ATTRIBUTE_PRINTF (4, 0)
+    : reason (r),
+      error (e),
+      message (std::make_shared<std::string> (string_vprintf (fmt, ap)))
+  {
+  }
+
+  /* The move constructor exists so that we can mark it "noexcept",
+     which is a good practice for any sort of exception object.  */
+  explicit gdb_exception (gdb_exception &&other) noexcept = default;
+
+  /* The copy constructor exists so that we can mark it "noexcept",
+     which is a good practice for any sort of exception object.  */
+  gdb_exception (const gdb_exception &other) noexcept
+    : reason (other.reason),
+      error (other.error),
+      message (other.message)
+  {
+  }
+
+  /* The assignment operator exists so that we can mark it "noexcept",
+     which is a good practice for any sort of exception object.  */
+  gdb_exception &operator= (const gdb_exception &other) noexcept
+  {
+    reason = other.reason;
+    error = other.error;
+    message = other.message;
+    return *this;
+  }
+
+  gdb_exception &operator= (gdb_exception &&other) noexcept = default;
+
+  /* Return the contents of the exception message, as a C string.  The
+     string remains owned by the exception object.  */
+  const char *what () const noexcept
+  {
+    return message->c_str ();
+  }
+
+  enum return_reason reason;
+  enum errors error;
+  std::shared_ptr<std::string> message;
+};
+
+/* Functions to drive the sjlj-based exceptions state machine.  Though
+   declared here by necessity, these functions should be considered
+   internal to the exceptions subsystem and not used other than via
+   the TRY/CATCH (or TRY_SJLJ/CATCH_SJLJ) macros defined below.  */
+
+extern jmp_buf *exceptions_state_mc_init (void);
+extern int exceptions_state_mc_action_iter (void);
+extern int exceptions_state_mc_action_iter_1 (void);
+extern int exceptions_state_mc_catch (struct gdb_exception *, int);
+
+/* Macro to wrap up standard try/catch behavior.
+
+   The double loop lets us correctly handle code "break"ing out of the
+   try catch block.  (It works as the "break" only exits the inner
+   "while" loop, the outer for loop detects this handling it
+   correctly.)  Of course "return" and "goto" are not so lucky.
+
+   For instance:
+
+   *INDENT-OFF*
+
+   TRY_SJLJ
+     {
+     }
+   CATCH_SJLJ (e, RETURN_MASK_ERROR)
+     {
+       switch (e.reason)
+         {
+           case RETURN_ERROR: ...
+         }
+     }
+   END_CATCH_SJLJ
+
+   The SJLJ variants are needed in some cases where gdb exceptions
+   need to cross third-party library code compiled without exceptions
+   support (e.g., readline).  */
+
+#define TRY_SJLJ \
+     { \
+       jmp_buf *buf = \
+        exceptions_state_mc_init (); \
+       setjmp (*buf); \
+     } \
+     while (exceptions_state_mc_action_iter ()) \
+       while (exceptions_state_mc_action_iter_1 ())
+
+#define CATCH_SJLJ(EXCEPTION, MASK)                            \
+  {                                                    \
+    struct gdb_exception EXCEPTION;                            \
+    if (exceptions_state_mc_catch (&(EXCEPTION), MASK))
+
+#define END_CATCH_SJLJ                         \
+  }
+
+/* The exception types client code may catch.  They're just shims
+   around gdb_exception that add nothing but type info.  Which is used
+   is selected depending on the MASK argument passed to CATCH.  */
+
+struct gdb_exception_error : public gdb_exception
+{
+  gdb_exception_error (enum errors e, const char *fmt, va_list ap)
+    ATTRIBUTE_PRINTF (3, 0)
+    : gdb_exception (RETURN_ERROR, e, fmt, ap)
+  {
+  }
+
+  explicit gdb_exception_error (gdb_exception &&ex) noexcept
+    : gdb_exception (std::move (ex))
+  {
+    gdb_assert (ex.reason == RETURN_ERROR);
+  }
+};
+
+struct gdb_exception_quit : public gdb_exception
+{
+  gdb_exception_quit (const char *fmt, va_list ap)
+    ATTRIBUTE_PRINTF (2, 0)
+    : gdb_exception (RETURN_QUIT, GDB_NO_ERROR, fmt, ap)
+  {
+  }
+
+  explicit gdb_exception_quit (gdb_exception &&ex) noexcept
+    : gdb_exception (std::move (ex))
+  {
+    gdb_assert (ex.reason == RETURN_QUIT);
+  }
+};
+
+/* An exception type that inherits from both std::bad_alloc and a gdb
+   exception.  This is necessary because operator new can only throw
+   std::bad_alloc, and OTOH, we want exceptions thrown due to memory
+   allocation error to be caught by all the CATCH/RETURN_MASK_ALL
+   spread around the codebase.  */
+
+struct gdb_quit_bad_alloc
+  : public gdb_exception_quit,
+    public std::bad_alloc
+{
+  explicit gdb_quit_bad_alloc (gdb_exception &&ex) noexcept
+    : gdb_exception_quit (std::move (ex)),
+      std::bad_alloc ()
+  {
+  }
+};
+
+/* *INDENT-ON* */
+
+/* Throw an exception (as described by "struct gdb_exception"),
+   landing in the inner most containing exception handler established
+   using TRY/CATCH.  */
+extern void throw_exception (gdb_exception &&exception)
+     ATTRIBUTE_NORETURN;
+
+/* Throw an exception by executing a LONG JUMP to the inner most
+   containing exception handler established using TRY_SJLJ.  Necessary
+   in some cases where we need to throw GDB exceptions across
+   third-party library code (e.g., readline).  */
+extern void throw_exception_sjlj (const struct gdb_exception &exception)
+     ATTRIBUTE_NORETURN;
+
+/* Convenience wrappers around throw_exception that throw GDB
+   errors.  */
+extern void throw_verror (enum errors, const char *fmt, va_list ap)
+     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 0);
+extern void throw_vquit (const char *fmt, va_list ap)
+     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
+extern void throw_error (enum errors error, const char *fmt, ...)
+     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
+extern void throw_quit (const char *fmt, ...)
+     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+
+#endif /* COMMON_COMMON_EXCEPTIONS_H */
diff --git a/gdb/gdbsupport/common-gdbthread.h b/gdb/gdbsupport/common-gdbthread.h
new file mode 100644 (file)
index 0000000..d692be2
--- /dev/null
@@ -0,0 +1,25 @@
+/* Common multi-process/thread control defs for GDB and gdbserver.
+   Copyright (C) 1987-2019 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/>.  */
+
+#ifndef COMMON_COMMON_GDBTHREAD_H
+#define COMMON_COMMON_GDBTHREAD_H
+
+/* Switch from one thread to another.  */
+extern void switch_to_thread (ptid_t ptid);
+
+#endif /* COMMON_COMMON_GDBTHREAD_H */
diff --git a/gdb/gdbsupport/common-inferior.h b/gdb/gdbsupport/common-inferior.h
new file mode 100644 (file)
index 0000000..72e4bd9
--- /dev/null
@@ -0,0 +1,41 @@
+/* Functions to deal with the inferior being executed on GDB or
+   GDBserver.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_COMMON_INFERIOR_H
+#define COMMON_COMMON_INFERIOR_H
+
+/* Return the exec wrapper to be used when starting the inferior, or NULL
+   otherwise.  */
+extern const char *get_exec_wrapper ();
+
+/* Return the name of the executable file as a string.
+   ERR nonzero means get error if there is none specified;
+   otherwise return 0 in that case.  */
+extern char *get_exec_file (int err);
+
+/* Return the inferior's current working directory.  If nothing has
+   been set, then return NULL.  */
+extern const char *get_inferior_cwd ();
+
+/* Set the inferior current working directory.  If CWD is NULL, unset
+   the directory.  */
+extern void set_inferior_cwd (const char *cwd);
+
+#endif /* COMMON_COMMON_INFERIOR_H */
diff --git a/gdb/gdbsupport/common-regcache.c b/gdb/gdbsupport/common-regcache.c
new file mode 100644 (file)
index 0000000..4bdadff
--- /dev/null
@@ -0,0 +1,36 @@
+/* Cache and manage the values of registers for GDB, the GNU debugger.
+
+   Copyright (C) 2015-2019 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 "common-defs.h"
+#include "common-regcache.h"
+
+/* Return the register's value or throw if it's not available.  */
+
+ULONGEST
+regcache_raw_get_unsigned (struct regcache *regcache, int regnum)
+{
+  ULONGEST value;
+  enum register_status status;
+
+  status = regcache_raw_read_unsigned (regcache, regnum, &value);
+  if (status == REG_UNAVAILABLE)
+    throw_error (NOT_AVAILABLE_ERROR,
+                _("Register %d is not available"), regnum);
+  return value;
+}
diff --git a/gdb/gdbsupport/common-regcache.h b/gdb/gdbsupport/common-regcache.h
new file mode 100644 (file)
index 0000000..95ce64a
--- /dev/null
@@ -0,0 +1,85 @@
+/* Cache and manage the values of registers
+
+   Copyright (C) 2014-2019 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/>.  */
+
+#ifndef COMMON_COMMON_REGCACHE_H
+#define COMMON_COMMON_REGCACHE_H
+
+/* This header is a stopgap until we have an independent regcache.  */
+
+enum register_status : signed char
+  {
+    /* The register value is not in the cache, and we don't know yet
+       whether it's available in the target (or traceframe).  */
+    REG_UNKNOWN = 0,
+
+    /* The register value is valid and cached.  */
+    REG_VALID = 1,
+
+    /* The register value is unavailable.  E.g., we're inspecting a
+       traceframe, and this register wasn't collected.  Note that this
+       is different a different "unavailable" from saying the register
+       does not exist in the target's architecture --- in that case,
+       the target should have given us a target description that does
+       not include the register in the first place.  */
+    REG_UNAVAILABLE = -1
+  };
+
+/* Return a pointer to the register cache associated with the
+   thread specified by PTID.  This function must be provided by
+   the client.  */
+
+extern struct regcache *get_thread_regcache_for_ptid (ptid_t ptid);
+
+/* Return the size of register numbered N in REGCACHE.  This function
+   must be provided by the client.  */
+
+extern int regcache_register_size (const struct regcache *regcache, int n);
+
+/* Read the PC register.  This function must be provided by the
+   client.  */
+
+extern CORE_ADDR regcache_read_pc (struct regcache *regcache);
+
+/* Read a raw register into a unsigned integer.  */
+extern enum register_status regcache_raw_read_unsigned
+  (struct regcache *regcache, int regnum, ULONGEST *val);
+
+ULONGEST regcache_raw_get_unsigned (struct regcache *regcache, int regnum);
+
+struct reg_buffer_common
+{
+  virtual ~reg_buffer_common () = default;
+
+  /* Get the availability status of the value of register REGNUM in this
+     buffer.  */
+  virtual register_status get_register_status (int regnum) const = 0;
+
+  /* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE.  */
+  virtual void raw_supply (int regnum, const void *buf) = 0;
+
+  /* Collect register REGNUM from REGCACHE and store its contents in BUF.  */
+  virtual void raw_collect (int regnum, void *buf) const = 0;
+
+  /* Compare the contents of the register stored in the regcache (ignoring the
+     first OFFSET bytes) to the contents of BUF (without any offset).  Returns
+     true if the same.  */
+  virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0;
+};
+
+#endif /* COMMON_COMMON_REGCACHE_H */
diff --git a/gdb/gdbsupport/common-types.h b/gdb/gdbsupport/common-types.h
new file mode 100644 (file)
index 0000000..ed73f6f
--- /dev/null
@@ -0,0 +1,66 @@
+/* Declarations for common types.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_COMMON_TYPES_H
+#define COMMON_COMMON_TYPES_H
+
+#ifdef GDBSERVER
+
+/* * A byte from the program being debugged.  */
+typedef unsigned char gdb_byte;
+
+typedef unsigned long long CORE_ADDR;
+
+typedef long long LONGEST;
+typedef unsigned long long ULONGEST;
+
+#else /* GDBSERVER */
+
+#include "bfd.h"
+
+/* * A byte from the program being debugged.  */
+typedef bfd_byte gdb_byte;
+
+/* * An address in the program being debugged.  Host byte order.  */
+typedef bfd_vma CORE_ADDR;
+
+/* This is to make sure that LONGEST is at least as big as CORE_ADDR.  */
+
+#ifdef BFD64
+
+typedef BFD_HOST_64_BIT LONGEST;
+typedef BFD_HOST_U_64_BIT ULONGEST;
+
+#else /* No BFD64 */
+
+typedef long long LONGEST;
+typedef unsigned long long ULONGEST;
+
+#endif /* No BFD64 */
+#endif /* GDBSERVER */
+
+/* * The largest CORE_ADDR value.  */
+#define CORE_ADDR_MAX (~(CORE_ADDR) 0)
+
+/* * The largest ULONGEST value.  */
+#define ULONGEST_MAX (~(ULONGEST) 0)
+
+enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 };
+
+#endif /* COMMON_COMMON_TYPES_H */
diff --git a/gdb/gdbsupport/common-utils.c b/gdb/gdbsupport/common-utils.c
new file mode 100644 (file)
index 0000000..384029d
--- /dev/null
@@ -0,0 +1,358 @@
+/* Shared general utility routines for GDB, the GNU debugger.
+
+   Copyright (C) 1986-2019 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 "common-defs.h"
+#include "common-utils.h"
+#include "host-defs.h"
+#include <ctype.h>
+
+void *
+xzalloc (size_t size)
+{
+  return xcalloc (1, size);
+}
+
+/* Like asprintf/vasprintf but get an internal_error if the call
+   fails. */
+
+char *
+xstrprintf (const char *format, ...)
+{
+  char *ret;
+  va_list args;
+
+  va_start (args, format);
+  ret = xstrvprintf (format, args);
+  va_end (args);
+  return ret;
+}
+
+char *
+xstrvprintf (const char *format, va_list ap)
+{
+  char *ret = NULL;
+  int status = vasprintf (&ret, format, ap);
+
+  /* NULL is returned when there was a memory allocation problem, or
+     any other error (for instance, a bad format string).  A negative
+     status (the printed length) with a non-NULL buffer should never
+     happen, but just to be sure.  */
+  if (ret == NULL || status < 0)
+    internal_error (__FILE__, __LINE__, _("vasprintf call failed"));
+  return ret;
+}
+
+int
+xsnprintf (char *str, size_t size, const char *format, ...)
+{
+  va_list args;
+  int ret;
+
+  va_start (args, format);
+  ret = vsnprintf (str, size, format, args);
+  gdb_assert (ret < size);
+  va_end (args);
+
+  return ret;
+}
+
+/* See documentation in common-utils.h.  */
+
+std::string
+string_printf (const char* fmt, ...)
+{
+  va_list vp;
+  int size;
+
+  va_start (vp, fmt);
+  size = vsnprintf (NULL, 0, fmt, vp);
+  va_end (vp);
+
+  std::string str (size, '\0');
+
+  /* C++11 and later guarantee std::string uses contiguous memory and
+     always includes the terminating '\0'.  */
+  va_start (vp, fmt);
+  vsprintf (&str[0], fmt, vp);
+  va_end (vp);
+
+  return str;
+}
+
+/* See documentation in common-utils.h.  */
+
+std::string
+string_vprintf (const char* fmt, va_list args)
+{
+  va_list vp;
+  size_t size;
+
+  va_copy (vp, args);
+  size = vsnprintf (NULL, 0, fmt, vp);
+  va_end (vp);
+
+  std::string str (size, '\0');
+
+  /* C++11 and later guarantee std::string uses contiguous memory and
+     always includes the terminating '\0'.  */
+  vsprintf (&str[0], fmt, args);
+
+  return str;
+}
+
+
+/* See documentation in common-utils.h.  */
+
+void
+string_appendf (std::string &str, const char *fmt, ...)
+{
+  va_list vp;
+
+  va_start (vp, fmt);
+  string_vappendf (str, fmt, vp);
+  va_end (vp);
+}
+
+
+/* See documentation in common-utils.h.  */
+
+void
+string_vappendf (std::string &str, const char *fmt, va_list args)
+{
+  va_list vp;
+  int grow_size;
+
+  va_copy (vp, args);
+  grow_size = vsnprintf (NULL, 0, fmt, vp);
+  va_end (vp);
+
+  size_t curr_size = str.size ();
+  str.resize (curr_size + grow_size);
+
+  /* C++11 and later guarantee std::string uses contiguous memory and
+     always includes the terminating '\0'.  */
+  vsprintf (&str[curr_size], fmt, args);
+}
+
+char *
+savestring (const char *ptr, size_t len)
+{
+  char *p = (char *) xmalloc (len + 1);
+
+  memcpy (p, ptr, len);
+  p[len] = 0;
+  return p;
+}
+
+/* The bit offset of the highest byte in a ULONGEST, for overflow
+   checking.  */
+
+#define HIGH_BYTE_POSN ((sizeof (ULONGEST) - 1) * HOST_CHAR_BIT)
+
+/* True (non-zero) iff DIGIT is a valid digit in radix BASE,
+   where 2 <= BASE <= 36.  */
+
+static int
+is_digit_in_base (unsigned char digit, int base)
+{
+  if (!isalnum (digit))
+    return 0;
+  if (base <= 10)
+    return (isdigit (digit) && digit < base + '0');
+  else
+    return (isdigit (digit) || tolower (digit) < base - 10 + 'a');
+}
+
+static int
+digit_to_int (unsigned char c)
+{
+  if (isdigit (c))
+    return c - '0';
+  else
+    return tolower (c) - 'a' + 10;
+}
+
+/* As for strtoul, but for ULONGEST results.  */
+
+ULONGEST
+strtoulst (const char *num, const char **trailer, int base)
+{
+  unsigned int high_part;
+  ULONGEST result;
+  int minus = 0;
+  int i = 0;
+
+  /* Skip leading whitespace.  */
+  while (isspace (num[i]))
+    i++;
+
+  /* Handle prefixes.  */
+  if (num[i] == '+')
+    i++;
+  else if (num[i] == '-')
+    {
+      minus = 1;
+      i++;
+    }
+
+  if (base == 0 || base == 16)
+    {
+      if (num[i] == '0' && (num[i + 1] == 'x' || num[i + 1] == 'X'))
+       {
+         i += 2;
+         if (base == 0)
+           base = 16;
+       }
+    }
+
+  if (base == 0 && num[i] == '0')
+    base = 8;
+
+  if (base == 0)
+    base = 10;
+
+  if (base < 2 || base > 36)
+    {
+      errno = EINVAL;
+      return 0;
+    }
+
+  result = high_part = 0;
+  for (; is_digit_in_base (num[i], base); i += 1)
+    {
+      result = result * base + digit_to_int (num[i]);
+      high_part = high_part * base + (unsigned int) (result >> HIGH_BYTE_POSN);
+      result &= ((ULONGEST) 1 << HIGH_BYTE_POSN) - 1;
+      if (high_part > 0xff)
+       {
+         errno = ERANGE;
+         result = ~ (ULONGEST) 0;
+         high_part = 0;
+         minus = 0;
+         break;
+       }
+    }
+
+  if (trailer != NULL)
+    *trailer = &num[i];
+
+  result = result + ((ULONGEST) high_part << HIGH_BYTE_POSN);
+  if (minus)
+    return -result;
+  else
+    return result;
+}
+
+/* See documentation in common-utils.h.  */
+
+char *
+skip_spaces (char *chp)
+{
+  if (chp == NULL)
+    return NULL;
+  while (*chp && isspace (*chp))
+    chp++;
+  return chp;
+}
+
+/* A const-correct version of the above.  */
+
+const char *
+skip_spaces (const char *chp)
+{
+  if (chp == NULL)
+    return NULL;
+  while (*chp && isspace (*chp))
+    chp++;
+  return chp;
+}
+
+/* See documentation in common-utils.h.  */
+
+const char *
+skip_to_space (const char *chp)
+{
+  if (chp == NULL)
+    return NULL;
+  while (*chp && !isspace (*chp))
+    chp++;
+  return chp;
+}
+
+/* See documentation in common-utils.h.  */
+
+char *
+skip_to_space (char *chp)
+{
+  return (char *) skip_to_space ((const char *) chp);
+}
+
+/* See gdbsupport/common-utils.h.  */
+
+void
+free_vector_argv (std::vector<char *> &v)
+{
+  for (char *el : v)
+    xfree (el);
+
+  v.clear ();
+}
+
+/* See gdbsupport/common-utils.h.  */
+
+std::string
+stringify_argv (const std::vector<char *> &args)
+{
+  std::string ret;
+
+  if (!args.empty () && args[0] != NULL)
+    {
+      for (auto s : args)
+       if (s != NULL)
+         {
+           ret += s;
+           ret += ' ';
+         }
+
+      /* Erase the last whitespace.  */
+      ret.erase (ret.end () - 1);
+    }
+
+  return ret;
+}
+
+/* See gdbsupport/common-utils.h.  */
+
+ULONGEST
+align_up (ULONGEST v, int n)
+{
+  /* Check that N is really a power of two.  */
+  gdb_assert (n && (n & (n-1)) == 0);
+  return (v + n - 1) & -n;
+}
+
+/* See gdbsupport/common-utils.h.  */
+
+ULONGEST
+align_down (ULONGEST v, int n)
+{
+  /* Check that N is really a power of two.  */
+  gdb_assert (n && (n & (n-1)) == 0);
+  return (v & -n);
+}
diff --git a/gdb/gdbsupport/common-utils.h b/gdb/gdbsupport/common-utils.h
new file mode 100644 (file)
index 0000000..52bf343
--- /dev/null
@@ -0,0 +1,181 @@
+/* Shared general utility routines for GDB, the GNU debugger.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_COMMON_UTILS_H
+#define COMMON_COMMON_UTILS_H
+
+#include <string>
+#include <vector>
+
+#include "poison.h"
+
+/* If possible, define FUNCTION_NAME, a macro containing the name of
+   the function being defined.  Since this macro may not always be
+   defined, all uses must be protected by appropriate macro definition
+   checks (Eg: "#ifdef FUNCTION_NAME").
+
+   Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
+   which contains the name of the function currently being defined.
+   This is broken in G++ before version 2.6.
+   C9x has a similar variable called __func__, but prefer the GCC one since
+   it demangles C++ function names.  */
+#if (GCC_VERSION >= 2004)
+#define FUNCTION_NAME          __PRETTY_FUNCTION__
+#else
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#define FUNCTION_NAME          __func__  /* ARI: func */
+#endif
+#endif
+
+/* xmalloc(), xrealloc() and xcalloc() have already been declared in
+   "libiberty.h". */
+
+/* Like xmalloc, but zero the memory.  */
+void *xzalloc (size_t);
+
+template <typename T>
+static void
+xfree (T *ptr)
+{
+  static_assert (IsFreeable<T>::value, "Trying to use xfree with a non-POD \
+data type.  Use operator delete instead.");
+
+  if (ptr != NULL)
+    free (ptr);                /* ARI: free */
+}
+
+
+/* Like asprintf and vasprintf, but return the string, throw an error
+   if no memory.  */
+char *xstrprintf (const char *format, ...) ATTRIBUTE_PRINTF (1, 2);
+char *xstrvprintf (const char *format, va_list ap)
+     ATTRIBUTE_PRINTF (1, 0);
+
+/* Like snprintf, but throw an error if the output buffer is too small.  */
+int xsnprintf (char *str, size_t size, const char *format, ...)
+     ATTRIBUTE_PRINTF (3, 4);
+
+/* Returns a std::string built from a printf-style format string.  */
+std::string string_printf (const char* fmt, ...)
+  ATTRIBUTE_PRINTF (1, 2);
+
+/* Like string_printf, but takes a va_list.  */
+std::string string_vprintf (const char* fmt, va_list args)
+  ATTRIBUTE_PRINTF (1, 0);
+
+/* Like string_printf, but appends to DEST instead of returning a new
+   std::string.  */
+void string_appendf (std::string &dest, const char* fmt, ...)
+  ATTRIBUTE_PRINTF (2, 3);
+
+/* Like string_appendf, but takes a va_list.  */
+void string_vappendf (std::string &dest, const char* fmt, va_list args)
+  ATTRIBUTE_PRINTF (2, 0);
+
+/* Make a copy of the string at PTR with LEN characters
+   (and add a null character at the end in the copy).
+   Uses malloc to get the space.  Returns the address of the copy.  */
+
+char *savestring (const char *ptr, size_t len);
+
+/* The strerror() function can return NULL for errno values that are
+   out of range.  Provide a "safe" version that always returns a
+   printable string.  */
+
+extern char *safe_strerror (int);
+
+/* Return non-zero if the start of STRING matches PATTERN, zero
+   otherwise.  */
+
+static inline int
+startswith (const char *string, const char *pattern)
+{
+  return strncmp (string, pattern, strlen (pattern)) == 0;
+}
+
+ULONGEST strtoulst (const char *num, const char **trailer, int base);
+
+/* Skip leading whitespace characters in INP, returning an updated
+   pointer.  If INP is NULL, return NULL.  */
+
+extern char *skip_spaces (char *inp);
+
+/* A const-correct version of the above.  */
+
+extern const char *skip_spaces (const char *inp);
+
+/* Skip leading non-whitespace characters in INP, returning an updated
+   pointer.  If INP is NULL, return NULL.  */
+
+extern char *skip_to_space (char *inp);
+
+/* A const-correct version of the above.  */
+
+extern const char *skip_to_space (const char *inp);
+
+/* Assumes that V is an argv for a program, and iterates through
+   freeing all the elements.  */
+extern void free_vector_argv (std::vector<char *> &v);
+
+/* Given a vector of arguments ARGV, return a string equivalent to
+   joining all the arguments with a whitespace separating them.  */
+extern std::string stringify_argv (const std::vector<char *> &argv);
+
+/* Return true if VALUE is in [LOW, HIGH].  */
+
+template <typename T>
+static bool
+in_inclusive_range (T value, T low, T high)
+{
+  return value >= low && value <= high;
+}
+
+/* Ensure that V is aligned to an N byte boundary (B's assumed to be a
+   power of 2).  Round up/down when necessary.  Examples of correct
+   use include:
+
+    addr = align_up (addr, 8); -- VALUE needs 8 byte alignment
+    write_memory (addr, value, len);
+    addr += len;
+
+   and:
+
+    sp = align_down (sp - len, 16); -- Keep SP 16 byte aligned
+    write_memory (sp, value, len);
+
+   Note that uses such as:
+
+    write_memory (addr, value, len);
+    addr += align_up (len, 8);
+
+   and:
+
+    sp -= align_up (len, 8);
+    write_memory (sp, value, len);
+
+   are typically not correct as they don't ensure that the address (SP
+   or ADDR) is correctly aligned (relying on previous alignment to
+   keep things right).  This is also why the methods are called
+   "align_..." instead of "round_..." as the latter reads better with
+   this incorrect coding style.  */
+
+extern ULONGEST align_up (ULONGEST v, int n);
+extern ULONGEST align_down (ULONGEST v, int n);
+
+#endif /* COMMON_COMMON_UTILS_H */
diff --git a/gdb/gdbsupport/common.host b/gdb/gdbsupport/common.host
new file mode 100644 (file)
index 0000000..4839059
--- /dev/null
@@ -0,0 +1,36 @@
+# Common object files to include for each host.
+#
+# Copyright (C) 2015-2019 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/>.
+
+# Map host triplet into the common object files to be included by
+# GDB/gdbserver.  This is invoked from the autoconf generated
+# configure script.
+
+# This file sets the following shell variables:
+#  common_host_obs             host-specific .o files to include when building
+#                              GDB/gdbserver
+
+case "${host}" in
+
+*-mingw*)      common_host_obs=gdbsupport/mingw-strerror.o
+               ;;
+*)
+               common_host_obs=gdbsupport/posix-strerror.o
+               ;;
+
+esac
diff --git a/gdb/gdbsupport/common.m4 b/gdb/gdbsupport/common.m4
new file mode 100644 (file)
index 0000000..5701dd9
--- /dev/null
@@ -0,0 +1,48 @@
+dnl Autoconf configure snippets for common.
+dnl Copyright (C) 1995-2019 Free Software Foundation, Inc.
+dnl
+dnl This file is part of GDB.
+dnl 
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl Invoke configury needed by the files in 'common'.
+AC_DEFUN([GDB_AC_COMMON], [
+  AC_HEADER_STDC
+  AC_FUNC_ALLOCA
+
+  dnl Note that this requires codeset.m4, which is included
+  dnl by the users of common.m4.
+  AM_LANGINFO_CODESET
+
+  AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl
+                  sys/resource.h sys/socket.h dnl
+                  sys/un.h sys/wait.h dnl
+                  thread_db.h wait.h dnl
+                  termios.h)
+
+  AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair sigaction])
+
+  AC_CHECK_DECLS([strerror, strstr])
+
+  dnl Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't
+  dnl do since sigsetjmp might only be defined as a macro.
+AC_CACHE_CHECK([for sigsetjmp], gdb_cv_func_sigsetjmp,
+[AC_TRY_COMPILE([
+#include <setjmp.h>
+], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);],
+gdb_cv_func_sigsetjmp=yes, gdb_cv_func_sigsetjmp=no)])
+if test $gdb_cv_func_sigsetjmp = yes; then
+  AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
+fi
+])
diff --git a/gdb/gdbsupport/create-version.sh b/gdb/gdbsupport/create-version.sh
new file mode 100755 (executable)
index 0000000..30525ba
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Copyright (C) 1989-2019 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/>.
+
+# Create version.c from version.in.
+# Usage:
+#    create-version.sh PATH-TO-GDB-SRCDIR HOST_ALIAS \
+#        TARGET_ALIAS OUTPUT-FILE-NAME
+
+srcdir="$1"
+host_alias="$2"
+target_alias="$3"
+output="$4"
+
+rm -f version.c-tmp $output version.tmp
+date=`sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$/\1/p' $srcdir/../bfd/version.h`
+sed -e "s/DATE/$date/" < $srcdir/version.in > version.tmp
+echo '#include "gdbsupport/version.h"' >> version.c-tmp
+echo 'const char version[] = "'"`sed q version.tmp`"'";' >> version.c-tmp
+echo 'const char host_name[] = "'"$host_alias"'";' >> version.c-tmp
+echo 'const char target_name[] = "'"$target_alias"'";' >> version.c-tmp
+mv version.c-tmp $output
+rm -f version.tmp
diff --git a/gdb/gdbsupport/def-vector.h b/gdb/gdbsupport/def-vector.h
new file mode 100644 (file)
index 0000000..fb933b8
--- /dev/null
@@ -0,0 +1,36 @@
+/* Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_DEF_VECTOR_H
+#define COMMON_DEF_VECTOR_H
+
+#include <vector>
+#include "gdbsupport/default-init-alloc.h"
+
+namespace gdb {
+
+/* A vector that uses an allocator that default constructs using
+   default-initialization rather than value-initialization.  The idea
+   is to use this when you don't want zero-initialization of elements
+   of vectors of trivial types.  E.g., byte buffers.  */
+
+template<typename T> using def_vector
+  = std::vector<T, gdb::default_init_allocator<T>>;
+
+} /* namespace gdb */
+
+#endif /* COMMON_DEF_VECTOR_H */
diff --git a/gdb/gdbsupport/default-init-alloc.h b/gdb/gdbsupport/default-init-alloc.h
new file mode 100644 (file)
index 0000000..2d739c9
--- /dev/null
@@ -0,0 +1,67 @@
+/* Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_DEFAULT_INIT_ALLOC_H
+#define COMMON_DEFAULT_INIT_ALLOC_H
+
+namespace gdb {
+
+/* An allocator that default constructs using default-initialization
+   rather than value-initialization.  The idea is to use this when you
+   don't want to default construct elements of containers of trivial
+   types using zero-initialization.  */
+
+/* Mostly as implementation convenience, this is implemented as an
+   adapter that given an allocator A, overrides 'A::construct()'.  'A'
+   defaults to std::allocator<T>.  */
+
+template<typename T, typename A = std::allocator<T>>
+class default_init_allocator : public A
+{
+public:
+  /* Pull in A's ctors.  */
+  using A::A;
+
+  /* Override rebind.  */
+  template<typename U>
+  struct rebind
+  {
+    /* A couple helpers just to make it a bit more readable.  */
+    typedef std::allocator_traits<A> traits_;
+    typedef typename traits_::template rebind_alloc<U> alloc_;
+
+    /* This is what we're after.  */
+    typedef default_init_allocator<U, alloc_> other;
+  };
+
+  /* Make the base allocator's construct method(s) visible.  */
+  using A::construct;
+
+  /* .. and provide an override/overload for the case of default
+     construction (i.e., no arguments).  This is where we construct
+     with default-init.  */
+  template <typename U>
+  void construct (U *ptr)
+    noexcept (std::is_nothrow_default_constructible<U>::value)
+  {
+    ::new ((void *) ptr) U; /* default-init */
+  }
+};
+
+} /* namespace gdb */
+
+#endif /* COMMON_DEFAULT_INIT_ALLOC_H */
diff --git a/gdb/gdbsupport/enum-flags.h b/gdb/gdbsupport/enum-flags.h
new file mode 100644 (file)
index 0000000..88ba591
--- /dev/null
@@ -0,0 +1,221 @@
+/* Copyright (C) 2015-2019 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/>.  */
+
+#ifndef COMMON_ENUM_FLAGS_H
+#define COMMON_ENUM_FLAGS_H
+
+/* Type-safe wrapper for enum flags.  enum flags are enums where the
+   values are bits that are meant to be ORed together.
+
+   This allows writing code like the below, while with raw enums this
+   would fail to compile without casts to enum type at the assignments
+   to 'f':
+
+    enum some_flag
+    {
+       flag_val1 = 1 << 1,
+       flag_val2 = 1 << 2,
+       flag_val3 = 1 << 3,
+       flag_val4 = 1 << 4,
+    };
+    DEF_ENUM_FLAGS_TYPE(enum some_flag, some_flags);
+
+    some_flags f = flag_val1 | flag_val2;
+    f |= flag_val3;
+
+   It's also possible to assign literal zero to an enum flags variable
+   (meaning, no flags), dispensing adding an awkward explicit "no
+   value" value to the enumeration.  For example:
+
+    some_flags f = 0;
+    f |= flag_val3 | flag_val4;
+
+   Note that literal integers other than zero fail to compile:
+
+    some_flags f = 1; // error
+*/
+
+#ifdef __cplusplus
+
+/* Traits type used to prevent the global operator overloads from
+   instantiating for non-flag enums.  */
+template<typename T> struct enum_flags_type {};
+
+/* Use this to mark an enum as flags enum.  It defines FLAGS as
+   enum_flags wrapper class for ENUM, and enables the global operator
+   overloads for ENUM.  */
+#define DEF_ENUM_FLAGS_TYPE(enum_type, flags_type)     \
+  typedef enum_flags<enum_type> flags_type;            \
+  template<>                                           \
+  struct enum_flags_type<enum_type>                    \
+  {                                                    \
+    typedef enum_flags<enum_type> type;                        \
+  }
+
+/* Until we can rely on std::underlying type being universally
+   available (C++11), roll our own for enums.  */
+template<int size, bool sign> class integer_for_size { typedef void type; };
+template<> struct integer_for_size<1, 0> { typedef uint8_t type; };
+template<> struct integer_for_size<2, 0> { typedef uint16_t type; };
+template<> struct integer_for_size<4, 0> { typedef uint32_t type; };
+template<> struct integer_for_size<8, 0> { typedef uint64_t type; };
+template<> struct integer_for_size<1, 1> { typedef int8_t type; };
+template<> struct integer_for_size<2, 1> { typedef int16_t type; };
+template<> struct integer_for_size<4, 1> { typedef int32_t type; };
+template<> struct integer_for_size<8, 1> { typedef int64_t type; };
+
+template<typename T>
+struct enum_underlying_type
+{
+  typedef typename
+    integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
+    type;
+};
+
+template <typename E>
+class enum_flags
+{
+public:
+  typedef E enum_type;
+  typedef typename enum_underlying_type<enum_type>::type underlying_type;
+
+private:
+  /* Private type used to support initializing flag types with zero:
+
+       foo_flags f = 0;
+
+     but not other integers:
+
+       foo_flags f = 1;
+
+     The way this works is that we define an implicit constructor that
+     takes a pointer to this private type.  Since nothing can
+     instantiate an object of this type, the only possible pointer to
+     pass to the constructor is the NULL pointer, or, zero.  */
+  struct zero_type;
+
+  underlying_type
+  underlying_value () const
+  {
+    return m_enum_value;
+  }
+
+public:
+  /* Allow default construction.  */
+  enum_flags ()
+    : m_enum_value ((enum_type) 0)
+  {}
+
+  /* If you get an error saying these two overloads are ambiguous,
+     then you tried to mix values of different enum types.  */
+  enum_flags (enum_type e)
+    : m_enum_value (e)
+  {}
+  enum_flags (struct enum_flags::zero_type *zero)
+    : m_enum_value ((enum_type) 0)
+  {}
+
+  enum_flags &operator&= (enum_type e)
+  {
+    m_enum_value = (enum_type) (underlying_value () & e);
+    return *this;
+  }
+  enum_flags &operator|= (enum_type e)
+  {
+    m_enum_value = (enum_type) (underlying_value () | e);
+    return *this;
+  }
+  enum_flags &operator^= (enum_type e)
+  {
+    m_enum_value = (enum_type) (underlying_value () ^ e);
+    return *this;
+  }
+
+  operator enum_type () const
+  {
+    return m_enum_value;
+  }
+
+  enum_flags operator& (enum_type e) const
+  {
+    return (enum_type) (underlying_value () & e);
+  }
+  enum_flags operator| (enum_type e) const
+  {
+    return (enum_type) (underlying_value () | e);
+  }
+  enum_flags operator^ (enum_type e) const
+  {
+    return (enum_type) (underlying_value () ^ e);
+  }
+  enum_flags operator~ () const
+  {
+    // We only the underlying type to be unsigned when actually using
+    // operator~ -- if it were not unsigned, undefined behavior could
+    // result.  However, asserting this in the class itself would
+    // require too many unnecessary changes to otherwise ok enum
+    // types.
+    gdb_static_assert (std::is_unsigned<underlying_type>::value);
+    return (enum_type) ~underlying_value ();
+  }
+
+private:
+  /* Stored as enum_type because GDB knows to print the bit flags
+     neatly if the enum values look like bit flags.  */
+  enum_type m_enum_value;
+};
+
+/* Global operator overloads.  */
+
+template <typename enum_type>
+typename enum_flags_type<enum_type>::type
+operator& (enum_type e1, enum_type e2)
+{
+  return enum_flags<enum_type> (e1) & e2;
+}
+
+template <typename enum_type>
+typename enum_flags_type<enum_type>::type
+operator| (enum_type e1, enum_type e2)
+{
+  return enum_flags<enum_type> (e1) | e2;
+}
+
+template <typename enum_type>
+typename enum_flags_type<enum_type>::type
+operator^ (enum_type e1, enum_type e2)
+{
+  return enum_flags<enum_type> (e1) ^ e2;
+}
+
+template <typename enum_type>
+typename enum_flags_type<enum_type>::type
+operator~ (enum_type e)
+{
+  return ~enum_flags<enum_type> (e);
+}
+
+#else /* __cplusplus */
+
+/* In C, the flags type is just a typedef for the enum type.  */
+
+#define DEF_ENUM_FLAGS_TYPE(enum_type, flags_type) \
+  typedef enum_type flags_type
+
+#endif /* __cplusplus */
+
+#endif /* COMMON_ENUM_FLAGS_H */
diff --git a/gdb/gdbsupport/environ.c b/gdb/gdbsupport/environ.c
new file mode 100644 (file)
index 0000000..006d80a
--- /dev/null
@@ -0,0 +1,183 @@
+/* environ.c -- library for manipulating environments for GNU.
+
+   Copyright (C) 1986-2019 Free Software Foundation, Inc.
+
+   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 "common-defs.h"
+#include "environ.h"
+#include <algorithm>
+#include <utility>
+
+/* See gdbsupport/environ.h.  */
+
+gdb_environ &
+gdb_environ::operator= (gdb_environ &&e)
+{
+  /* Are we self-moving?  */
+  if (&e == this)
+    return *this;
+
+  m_environ_vector = std::move (e.m_environ_vector);
+  m_user_set_env = std::move (e.m_user_set_env);
+  m_user_unset_env = std::move (e.m_user_unset_env);
+  e.m_environ_vector.clear ();
+  e.m_environ_vector.push_back (NULL);
+  e.m_user_set_env.clear ();
+  e.m_user_unset_env.clear ();
+  return *this;
+}
+
+/* See gdbsupport/environ.h.  */
+
+gdb_environ gdb_environ::from_host_environ ()
+{
+  extern char **environ;
+  gdb_environ e;
+
+  if (environ == NULL)
+    return e;
+
+  for (int i = 0; environ[i] != NULL; ++i)
+    {
+      /* Make sure we add the element before the last (NULL).  */
+      e.m_environ_vector.insert (e.m_environ_vector.end () - 1,
+                                xstrdup (environ[i]));
+    }
+
+  return e;
+}
+
+/* See gdbsupport/environ.h.  */
+
+void
+gdb_environ::clear ()
+{
+  for (char *v : m_environ_vector)
+    xfree (v);
+  m_environ_vector.clear ();
+  /* Always add the NULL element.  */
+  m_environ_vector.push_back (NULL);
+  m_user_set_env.clear ();
+  m_user_unset_env.clear ();
+}
+
+/* Helper function to check if STRING contains an environment variable
+   assignment of VAR, i.e., if STRING starts with 'VAR='.  Return true
+   if it contains, false otherwise.  */
+
+static bool
+match_var_in_string (const char *string, const char *var, size_t var_len)
+{
+  if (strncmp (string, var, var_len) == 0 && string[var_len] == '=')
+    return true;
+
+  return false;
+}
+
+/* See gdbsupport/environ.h.  */
+
+const char *
+gdb_environ::get (const char *var) const
+{
+  size_t len = strlen (var);
+
+  for (char *el : m_environ_vector)
+    if (el != NULL && match_var_in_string (el, var, len))
+      return &el[len + 1];
+
+  return NULL;
+}
+
+/* See gdbsupport/environ.h.  */
+
+void
+gdb_environ::set (const char *var, const char *value)
+{
+  char *fullvar = concat (var, "=", value, NULL);
+
+  /* We have to unset the variable in the vector if it exists.  */
+  unset (var, false);
+
+  /* Insert the element before the last one, which is always NULL.  */
+  m_environ_vector.insert (m_environ_vector.end () - 1, fullvar);
+
+  /* Mark this environment variable as having been set by the user.
+     This will be useful when we deal with setting environment
+     variables on the remote target.  */
+  m_user_set_env.insert (std::string (fullvar));
+
+  /* If this environment variable is marked as unset by the user, then
+     remove it from the list, because now the user wants to set
+     it.  */
+  m_user_unset_env.erase (std::string (var));
+}
+
+/* See gdbsupport/environ.h.  */
+
+void
+gdb_environ::unset (const char *var, bool update_unset_list)
+{
+  size_t len = strlen (var);
+  std::vector<char *>::iterator it_env;
+
+  /* We iterate until '.end () - 1' because the last element is
+     always NULL.  */
+  for (it_env = m_environ_vector.begin ();
+       it_env != m_environ_vector.end () - 1;
+       ++it_env)
+    if (match_var_in_string (*it_env, var, len))
+      break;
+
+  if (it_env != m_environ_vector.end () - 1)
+    {
+      m_user_set_env.erase (std::string (*it_env));
+      xfree (*it_env);
+
+      m_environ_vector.erase (it_env);
+    }
+
+  if (update_unset_list)
+    m_user_unset_env.insert (std::string (var));
+}
+
+/* See gdbsupport/environ.h.  */
+
+void
+gdb_environ::unset (const char *var)
+{
+  unset (var, true);
+}
+
+/* See gdbsupport/environ.h.  */
+
+char **
+gdb_environ::envp () const
+{
+  return const_cast<char **> (&m_environ_vector[0]);
+}
+
+/* See gdbsupport/environ.h.  */
+
+const std::set<std::string> &
+gdb_environ::user_set_env () const
+{
+  return m_user_set_env;
+}
+
+const std::set<std::string> &
+gdb_environ::user_unset_env () const
+{
+  return m_user_unset_env;
+}
diff --git a/gdb/gdbsupport/environ.h b/gdb/gdbsupport/environ.h
new file mode 100644 (file)
index 0000000..8a6b907
--- /dev/null
@@ -0,0 +1,103 @@
+/* Header for environment manipulation library.
+   Copyright (C) 1989-2019 Free Software Foundation, Inc.
+
+   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/>.  */
+
+#ifndef COMMON_ENVIRON_H
+#define COMMON_ENVIRON_H
+
+#include <vector>
+#include <set>
+
+/* Class that represents the environment variables as seen by the
+   inferior.  */
+
+class gdb_environ
+{
+public:
+  /* Regular constructor and destructor.  */
+  gdb_environ ()
+  {
+    /* Make sure that the vector contains at least a NULL element.
+       If/when we add more variables to it, NULL will always be the
+       last element.  */
+    m_environ_vector.push_back (NULL);
+  }
+
+  ~gdb_environ ()
+  {
+    clear ();
+  }
+
+  /* Move constructor.  */
+  gdb_environ (gdb_environ &&e)
+    : m_environ_vector (std::move (e.m_environ_vector)),
+      m_user_set_env (std::move (e.m_user_set_env)),
+      m_user_unset_env (std::move (e.m_user_unset_env))
+  {
+    /* Make sure that the moved-from vector is left at a valid
+       state (only one NULL element).  */
+    e.m_environ_vector.clear ();
+    e.m_environ_vector.push_back (NULL);
+    e.m_user_set_env.clear ();
+    e.m_user_unset_env.clear ();
+  }
+
+  /* Move assignment.  */
+  gdb_environ &operator= (gdb_environ &&e);
+
+  /* Create a gdb_environ object using the host's environment
+     variables.  */
+  static gdb_environ from_host_environ ();
+
+  /* Clear the environment variables stored in the object.  */
+  void clear ();
+
+  /* Return the value in the environment for the variable VAR.  The
+     returned pointer is only valid as long as the gdb_environ object
+     is not modified.  */
+  const char *get (const char *var) const;
+
+  /* Store VAR=VALUE in the environment.  */
+  void set (const char *var, const char *value);
+
+  /* Unset VAR in environment.  */
+  void unset (const char *var);
+
+  /* Return the environment vector represented as a 'char **'.  */
+  char **envp () const;
+
+  /* Return the user-set environment vector.  */
+  const std::set<std::string> &user_set_env () const;
+
+  /* Return the user-unset environment vector.  */
+  const std::set<std::string> &user_unset_env () const;
+
+private:
+  /* Unset VAR in environment.  If UPDATE_UNSET_LIST is true, then
+     also update M_USER_UNSET_ENV to reflect the unsetting of the
+     environment variable.  */
+  void unset (const char *var, bool update_unset_list);
+
+  /* A vector containing the environment variables.  */
+  std::vector<char *> m_environ_vector;
+
+  /* The environment variables explicitly set by the user.  */
+  std::set<std::string> m_user_set_env;
+
+  /* The environment variables explicitly unset by the user.  */
+  std::set<std::string> m_user_unset_env;
+};
+
+#endif /* COMMON_ENVIRON_H */
diff --git a/gdb/gdbsupport/errors.c b/gdb/gdbsupport/errors.c
new file mode 100644 (file)
index 0000000..96be038
--- /dev/null
@@ -0,0 +1,69 @@
+/* Error reporting facilities.
+
+   Copyright (C) 1986-2019 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 "common-defs.h"
+#include "errors.h"
+
+/* See gdbsupport/errors.h.  */
+
+void
+warning (const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start (ap, fmt);
+  vwarning (fmt, ap);
+  va_end (ap);
+}
+
+/* See gdbsupport/errors.h.  */
+
+void
+error (const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start (ap, fmt);
+  verror (fmt, ap);
+  va_end (ap);
+}
+
+/* See gdbsupport/errors.h.  */
+
+void
+internal_error (const char *file, int line, const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start (ap, fmt);
+  internal_verror (file, line, fmt, ap);
+  va_end (ap);
+}
+
+/* See gdbsupport/errors.h.  */
+
+void
+internal_warning (const char *file, int line, const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start (ap, fmt);
+  internal_vwarning (file, line, fmt, ap);
+  va_end (ap);
+}
diff --git a/gdb/gdbsupport/errors.h b/gdb/gdbsupport/errors.h
new file mode 100644 (file)
index 0000000..8dbc6cf
--- /dev/null
@@ -0,0 +1,90 @@
+/* Declarations for error-reporting facilities.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_ERRORS_H
+#define COMMON_ERRORS_H
+
+/* A problem was detected, but the requested operation can still
+   proceed.  A warning message is constructed using a printf- or
+   vprintf-style argument list.  The function "vwarning" must be
+   provided by the client.  */
+
+extern void warning (const char *fmt, ...)
+     ATTRIBUTE_PRINTF (1, 2);
+
+extern void vwarning (const char *fmt, va_list args)
+     ATTRIBUTE_PRINTF (1, 0);
+
+/* A non-predictable, non-fatal error was detected.  The requested
+   operation cannot proceed.  An error message is constructed using
+   a printf- or vprintf-style argument list.  These functions do not
+   return.  The function "verror" must be provided by the client.  */
+
+extern void error (const char *fmt, ...)
+     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+
+extern void verror (const char *fmt, va_list args)
+     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
+
+/* An internal error was detected.  Internal errors indicate
+   programming errors such as assertion failures, as opposed to
+   more general errors beyond the application's control.  These
+   functions do not return.  An error message is constructed using
+   a printf- or vprintf-style argument list.  FILE and LINE
+   indicate the file and line number where the programming error
+   was detected.  The function "internal_verror" must be provided
+   by the client.  */
+
+extern void internal_error (const char *file, int line,
+                           const char *fmt, ...)
+     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4);
+
+extern void internal_verror (const char *file, int line,
+                            const char *fmt, va_list args)
+     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0);
+
+/* An internal problem was detected, but the requested operation can
+   still proceed.  Internal warnings indicate programming errors as
+   opposed to more general issues beyond the application's control.
+   A warning message is constructed using a printf- or vprintf-style
+   argument list.  The function "internal_vwarning" must be provided
+   by the client.  */
+
+extern void internal_warning (const char *file, int line,
+                             const char *fmt, ...)
+     ATTRIBUTE_PRINTF (3, 4);
+
+extern void internal_vwarning (const char *file, int line,
+                              const char *fmt, va_list args)
+     ATTRIBUTE_PRINTF (3, 0);
+\f
+
+/* Like "error", but the error message is constructed by combining
+   STRING with the system error message for errno.  This function does
+   not return.  This function must be provided by the client.  */
+
+extern void perror_with_name (const char *string) ATTRIBUTE_NORETURN;
+
+/* Call this function to handle memory allocation failures.  This
+   function does not return.  This function must be provided by the
+   client.  */
+
+extern void malloc_failure (long size) ATTRIBUTE_NORETURN;
+
+#endif /* COMMON_ERRORS_H */
diff --git a/gdb/gdbsupport/fileio.c b/gdb/gdbsupport/fileio.c
new file mode 100644 (file)
index 0000000..28d97fc
--- /dev/null
@@ -0,0 +1,255 @@
+/* File-I/O functions for GDB, the GNU debugger.
+
+   Copyright (C) 2003-2019 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 "common-defs.h"
+#include "fileio.h"
+#include <sys/stat.h>
+#include <fcntl.h>
+
+/* See fileio.h.  */
+
+int
+host_to_fileio_error (int error)
+{
+  switch (error)
+    {
+      case EPERM:
+        return FILEIO_EPERM;
+      case ENOENT:
+        return FILEIO_ENOENT;
+      case EINTR:
+        return FILEIO_EINTR;
+      case EIO:
+        return FILEIO_EIO;
+      case EBADF:
+        return FILEIO_EBADF;
+      case EACCES:
+        return FILEIO_EACCES;
+      case EFAULT:
+        return FILEIO_EFAULT;
+      case EBUSY:
+        return FILEIO_EBUSY;
+      case EEXIST:
+        return FILEIO_EEXIST;
+      case ENODEV:
+        return FILEIO_ENODEV;
+      case ENOTDIR:
+        return FILEIO_ENOTDIR;
+      case EISDIR:
+        return FILEIO_EISDIR;
+      case EINVAL:
+        return FILEIO_EINVAL;
+      case ENFILE:
+        return FILEIO_ENFILE;
+      case EMFILE:
+        return FILEIO_EMFILE;
+      case EFBIG:
+        return FILEIO_EFBIG;
+      case ENOSPC:
+        return FILEIO_ENOSPC;
+      case ESPIPE:
+        return FILEIO_ESPIPE;
+      case EROFS:
+        return FILEIO_EROFS;
+      case ENOSYS:
+        return FILEIO_ENOSYS;
+      case ENAMETOOLONG:
+        return FILEIO_ENAMETOOLONG;
+    }
+  return FILEIO_EUNKNOWN;
+}
+
+/* See fileio.h.  */
+
+int
+fileio_to_host_openflags (int fileio_open_flags, int *open_flags_p)
+{
+  int open_flags = 0;
+
+  if (fileio_open_flags & ~FILEIO_O_SUPPORTED)
+    return -1;
+
+  if (fileio_open_flags & FILEIO_O_CREAT)
+    open_flags |= O_CREAT;
+  if (fileio_open_flags & FILEIO_O_EXCL)
+    open_flags |= O_EXCL;
+  if (fileio_open_flags & FILEIO_O_TRUNC)
+    open_flags |= O_TRUNC;
+  if (fileio_open_flags & FILEIO_O_APPEND)
+    open_flags |= O_APPEND;
+  if (fileio_open_flags & FILEIO_O_RDONLY)
+    open_flags |= O_RDONLY;
+  if (fileio_open_flags & FILEIO_O_WRONLY)
+    open_flags |= O_WRONLY;
+  if (fileio_open_flags & FILEIO_O_RDWR)
+    open_flags |= O_RDWR;
+  /* On systems supporting binary and text mode, always open files
+     in binary mode. */
+#ifdef O_BINARY
+  open_flags |= O_BINARY;
+#endif
+
+  *open_flags_p = open_flags;
+  return 0;
+}
+
+/* See fileio.h.  */
+
+int
+fileio_to_host_mode (int fileio_mode, mode_t *mode_p)
+{
+  mode_t mode = 0;
+
+  if (fileio_mode & ~FILEIO_S_SUPPORTED)
+    return -1;
+
+  if (fileio_mode & FILEIO_S_IFREG)
+    mode |= S_IFREG;
+  if (fileio_mode & FILEIO_S_IFDIR)
+    mode |= S_IFDIR;
+  if (fileio_mode & FILEIO_S_IFCHR)
+    mode |= S_IFCHR;
+  if (fileio_mode & FILEIO_S_IRUSR)
+    mode |= S_IRUSR;
+  if (fileio_mode & FILEIO_S_IWUSR)
+    mode |= S_IWUSR;
+  if (fileio_mode & FILEIO_S_IXUSR)
+    mode |= S_IXUSR;
+#ifdef S_IRGRP
+  if (fileio_mode & FILEIO_S_IRGRP)
+    mode |= S_IRGRP;
+#endif
+#ifdef S_IWGRP
+  if (fileio_mode & FILEIO_S_IWGRP)
+    mode |= S_IWGRP;
+#endif
+#ifdef S_IXGRP
+  if (fileio_mode & FILEIO_S_IXGRP)
+    mode |= S_IXGRP;
+#endif
+  if (fileio_mode & FILEIO_S_IROTH)
+    mode |= S_IROTH;
+#ifdef S_IWOTH
+  if (fileio_mode & FILEIO_S_IWOTH)
+    mode |= S_IWOTH;
+#endif
+#ifdef S_IXOTH
+  if (fileio_mode & FILEIO_S_IXOTH)
+    mode |= S_IXOTH;
+#endif
+
+  *mode_p = mode;
+  return 0;
+}
+
+/* Convert a host-format mode_t into a bitmask of File-I/O flags.  */
+
+static LONGEST
+fileio_mode_pack (mode_t mode)
+{
+  mode_t tmode = 0;
+
+  if (S_ISREG (mode))
+    tmode |= FILEIO_S_IFREG;
+  if (S_ISDIR (mode))
+    tmode |= FILEIO_S_IFDIR;
+  if (S_ISCHR (mode))
+    tmode |= FILEIO_S_IFCHR;
+  if (mode & S_IRUSR)
+    tmode |= FILEIO_S_IRUSR;
+  if (mode & S_IWUSR)
+    tmode |= FILEIO_S_IWUSR;
+  if (mode & S_IXUSR)
+    tmode |= FILEIO_S_IXUSR;
+#ifdef S_IRGRP
+  if (mode & S_IRGRP)
+    tmode |= FILEIO_S_IRGRP;
+#endif
+#ifdef S_IWGRP
+  if (mode & S_IWGRP)
+    tmode |= FILEIO_S_IWGRP;
+#endif
+#ifdef S_IXGRP
+  if (mode & S_IXGRP)
+    tmode |= FILEIO_S_IXGRP;
+#endif
+  if (mode & S_IROTH)
+    tmode |= FILEIO_S_IROTH;
+#ifdef S_IWOTH
+  if (mode & S_IWOTH)
+    tmode |= FILEIO_S_IWOTH;
+#endif
+#ifdef S_IXOTH
+  if (mode & S_IXOTH)
+    tmode |= FILEIO_S_IXOTH;
+#endif
+  return tmode;
+}
+
+/* Pack a host-format mode_t into an fio_mode_t.  */
+
+static void
+host_to_fileio_mode (mode_t num, fio_mode_t fnum)
+{
+  host_to_bigendian (fileio_mode_pack (num), (char *) fnum, 4);
+}
+
+/* Pack a host-format integer into an fio_ulong_t.  */
+
+static void
+host_to_fileio_ulong (LONGEST num, fio_ulong_t fnum)
+{
+  host_to_bigendian (num, (char *) fnum, 8);
+}
+
+/* See fileio.h.  */
+
+void
+host_to_fileio_stat (struct stat *st, struct fio_stat *fst)
+{
+  LONGEST blksize;
+
+  host_to_fileio_uint ((long) st->st_dev, fst->fst_dev);
+  host_to_fileio_uint ((long) st->st_ino, fst->fst_ino);
+  host_to_fileio_mode (st->st_mode, fst->fst_mode);
+  host_to_fileio_uint ((long) st->st_nlink, fst->fst_nlink);
+  host_to_fileio_uint ((long) st->st_uid, fst->fst_uid);
+  host_to_fileio_uint ((long) st->st_gid, fst->fst_gid);
+  host_to_fileio_uint ((long) st->st_rdev, fst->fst_rdev);
+  host_to_fileio_ulong ((LONGEST) st->st_size, fst->fst_size);
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
+  blksize = st->st_blksize;
+#else
+  blksize = 512;
+#endif
+  host_to_fileio_ulong (blksize, fst->fst_blksize);
+#if HAVE_STRUCT_STAT_ST_BLOCKS
+  host_to_fileio_ulong ((LONGEST) st->st_blocks, fst->fst_blocks);
+#else
+  /* FIXME: This is correct for DJGPP, but other systems that don't
+     have st_blocks, if any, might prefer 512 instead of st_blksize.
+     (eliz, 30-12-2003)  */
+  host_to_fileio_ulong (((LONGEST) st->st_size + blksize - 1)
+                       / blksize,
+                       fst->fst_blocks);
+#endif
+  host_to_fileio_time (st->st_atime, fst->fst_atime);
+  host_to_fileio_time (st->st_mtime, fst->fst_mtime);
+  host_to_fileio_time (st->st_ctime, fst->fst_ctime);
+}
diff --git a/gdb/gdbsupport/fileio.h b/gdb/gdbsupport/fileio.h
new file mode 100644 (file)
index 0000000..7a2e7c2
--- /dev/null
@@ -0,0 +1,73 @@
+/* File-I/O functions for GDB, the GNU debugger.
+
+   Copyright (C) 2003-2019 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/>.  */
+
+#ifndef COMMON_FILEIO_H
+#define COMMON_FILEIO_H
+
+#include "gdb/fileio.h"
+#include <sys/stat.h>
+
+/* Convert a host-format errno value to a File-I/O error number.  */
+
+extern int host_to_fileio_error (int error);
+
+/* Convert File-I/O open flags FFLAGS to host format, storing
+   the result in *FLAGS.  Return 0 on success, -1 on error.  */
+
+extern int fileio_to_host_openflags (int fflags, int *flags);
+
+/* Convert File-I/O mode FMODE to host format, storing
+   the result in *MODE.  Return 0 on success, -1 on error.  */
+
+extern int fileio_to_host_mode (int fmode, mode_t *mode);
+
+/* Pack a host-format integer into a byte buffer in big-endian
+   format.  BYTES specifies the size of the integer to pack in
+   bytes.  */
+
+static inline void
+host_to_bigendian (LONGEST num, char *buf, int bytes)
+{
+  int i;
+
+  for (i = 0; i < bytes; ++i)
+    buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff;
+}
+
+/* Pack a host-format integer into an fio_uint_t.  */
+
+static inline void
+host_to_fileio_uint (long num, fio_uint_t fnum)
+{
+  host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
+}
+
+/* Pack a host-format time_t into an fio_time_t.  */
+
+static inline void
+host_to_fileio_time (time_t num, fio_time_t fnum)
+{
+  host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
+}
+
+/* Pack a host-format struct stat into a struct fio_stat.  */
+
+extern void host_to_fileio_stat (struct stat *st, struct fio_stat *fst);
+
+#endif /* COMMON_FILEIO_H */
diff --git a/gdb/gdbsupport/filestuff.c b/gdb/gdbsupport/filestuff.c
new file mode 100644 (file)
index 0000000..b8fca15
--- /dev/null
@@ -0,0 +1,503 @@
+/* Low-level file-handling.
+   Copyright (C) 2012-2019 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 "common-defs.h"
+#include "filestuff.h"
+#include "gdb_vecs.h"
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <algorithm>
+
+#ifdef USE_WIN32API
+#include <winsock2.h>
+#include <windows.h>
+#define HAVE_SOCKETS 1
+#elif defined HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+/* Define HAVE_F_GETFD if we plan to use F_GETFD.  */
+#define HAVE_F_GETFD F_GETFD
+#define HAVE_SOCKETS 1
+#endif
+
+#ifdef HAVE_KINFO_GETFILE
+#include <sys/user.h>
+#include <libutil.h>
+#endif
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif /* HAVE_SYS_RESOURCE_H */
+
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+
+#ifndef O_NOINHERIT
+#define O_NOINHERIT 0
+#endif
+
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 0
+#endif
+
+\f
+
+#ifndef HAVE_FDWALK
+
+#include <dirent.h>
+
+/* Replacement for fdwalk, if the system doesn't define it.  Walks all
+   open file descriptors (though this implementation may walk closed
+   ones as well, depending on the host platform's capabilities) and
+   call FUNC with ARG.  If FUNC returns non-zero, stops immediately
+   and returns the same value.  Otherwise, returns zero when
+   finished.  */
+
+static int
+fdwalk (int (*func) (void *, int), void *arg)
+{
+  /* Checking __linux__ isn't great but it isn't clear what would be
+     better.  There doesn't seem to be a good way to check for this in
+     configure.  */
+#ifdef __linux__
+  DIR *dir;
+
+  dir = opendir ("/proc/self/fd");
+  if (dir != NULL)
+    {
+      struct dirent *entry;
+      int result = 0;
+
+      for (entry = readdir (dir); entry != NULL; entry = readdir (dir))
+       {
+         long fd;
+         char *tail;
+
+         errno = 0;
+         fd = strtol (entry->d_name, &tail, 10);
+         if (*tail != '\0' || errno != 0)
+           continue;
+         if ((int) fd != fd)
+           {
+             /* What can we do here really?  */
+             continue;
+           }
+
+         if (fd == dirfd (dir))
+           continue;
+
+         result = func (arg, fd);
+         if (result != 0)
+           break;
+       }
+
+      closedir (dir);
+      return result;
+    }
+  /* We may fall through to the next case.  */
+#endif
+#ifdef HAVE_KINFO_GETFILE
+  int nfd;
+  gdb::unique_xmalloc_ptr<struct kinfo_file[]> fdtbl
+    (kinfo_getfile (getpid (), &nfd));
+  if (fdtbl != NULL)
+    {
+      for (int i = 0; i < nfd; i++)
+       {
+         if (fdtbl[i].kf_fd >= 0)
+           {
+             int result = func (arg, fdtbl[i].kf_fd);
+             if (result != 0)
+               return result;
+           }
+       }
+      return 0;
+    }
+  /* We may fall through to the next case.  */
+#endif
+
+  {
+    int max, fd;
+
+#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
+    struct rlimit rlim;
+
+    if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 && rlim.rlim_max != RLIM_INFINITY)
+      max = rlim.rlim_max;
+    else
+#endif
+      {
+#ifdef _SC_OPEN_MAX
+       max = sysconf (_SC_OPEN_MAX);
+#else
+       /* Whoops.  */
+       return 0;
+#endif /* _SC_OPEN_MAX */
+      }
+
+    for (fd = 0; fd < max; ++fd)
+      {
+       struct stat sb;
+       int result;
+
+       /* Only call FUNC for open fds.  */
+       if (fstat (fd, &sb) == -1)
+         continue;
+
+       result = func (arg, fd);
+       if (result != 0)
+         return result;
+      }
+
+    return 0;
+  }
+}
+
+#endif /* HAVE_FDWALK */
+
+\f
+
+/* A vector holding all the fds open when notice_open_fds was called.  We
+   don't use a hashtab because we don't expect there to be many open fds.  */
+
+static std::vector<int> open_fds;
+
+/* An fdwalk callback function used by notice_open_fds.  It puts the
+   given file descriptor into the vec.  */
+
+static int
+do_mark_open_fd (void *ignore, int fd)
+{
+  open_fds.push_back (fd);
+  return 0;
+}
+
+/* See filestuff.h.  */
+
+void
+notice_open_fds (void)
+{
+  fdwalk (do_mark_open_fd, NULL);
+}
+
+/* See filestuff.h.  */
+
+void
+mark_fd_no_cloexec (int fd)
+{
+  do_mark_open_fd (NULL, fd);
+}
+
+/* See filestuff.h.  */
+
+void
+unmark_fd_no_cloexec (int fd)
+{
+  auto it = std::remove (open_fds.begin (), open_fds.end (), fd);
+
+  if (it != open_fds.end ())
+    open_fds.erase (it);
+  else
+    gdb_assert_not_reached (_("fd not found in open_fds"));
+}
+
+/* Helper function for close_most_fds that closes the file descriptor
+   if appropriate.  */
+
+static int
+do_close (void *ignore, int fd)
+{
+  for (int val : open_fds)
+    {
+      if (fd == val)
+       {
+         /* Keep this one open.  */
+         return 0;
+       }
+    }
+
+  close (fd);
+  return 0;
+}
+
+/* See filestuff.h.  */
+
+void
+close_most_fds (void)
+{
+  fdwalk (do_close, NULL);
+}
+
+\f
+
+/* This is a tri-state flag.  When zero it means we haven't yet tried
+   O_CLOEXEC.  When positive it means that O_CLOEXEC works on this
+   host.  When negative, it means that O_CLOEXEC doesn't work.  We
+   track this state because, while gdb might have been compiled
+   against a libc that supplies O_CLOEXEC, there is no guarantee that
+   the kernel supports it.  */
+
+static int trust_o_cloexec;
+
+/* Mark FD as close-on-exec, ignoring errors.  Update
+   TRUST_O_CLOEXEC.  */
+
+static void
+mark_cloexec (int fd)
+{
+#ifdef HAVE_F_GETFD
+  int old = fcntl (fd, F_GETFD, 0);
+
+  if (old != -1)
+    {
+      fcntl (fd, F_SETFD, old | FD_CLOEXEC);
+
+      if (trust_o_cloexec == 0)
+       {
+         if ((old & FD_CLOEXEC) != 0)
+           trust_o_cloexec = 1;
+         else
+           trust_o_cloexec = -1;
+       }
+    }
+#endif /* HAVE_F_GETFD */
+}
+
+/* Depending on TRUST_O_CLOEXEC, mark FD as close-on-exec.  */
+
+static void
+maybe_mark_cloexec (int fd)
+{
+  if (trust_o_cloexec <= 0)
+    mark_cloexec (fd);
+}
+
+#ifdef HAVE_SOCKETS
+
+/* Like maybe_mark_cloexec, but for callers that use SOCK_CLOEXEC.  */
+
+static void
+socket_mark_cloexec (int fd)
+{
+  if (SOCK_CLOEXEC == 0 || trust_o_cloexec <= 0)
+    mark_cloexec (fd);
+}
+
+#endif
+
+\f
+
+/* See filestuff.h.  */
+
+int
+gdb_open_cloexec (const char *filename, int flags, unsigned long mode)
+{
+  int fd = open (filename, flags | O_CLOEXEC, mode);
+
+  if (fd >= 0)
+    maybe_mark_cloexec (fd);
+
+  return fd;
+}
+
+/* See filestuff.h.  */
+
+gdb_file_up
+gdb_fopen_cloexec (const char *filename, const char *opentype)
+{
+  FILE *result;
+  /* Probe for "e" support once.  But, if we can tell the operating
+     system doesn't know about close on exec mode "e" without probing,
+     skip it.  E.g., the Windows runtime issues an "Invalid parameter
+     passed to C runtime function" OutputDebugString warning for
+     unknown modes.  Assume that if O_CLOEXEC is zero, then "e" isn't
+     supported.  On MinGW, O_CLOEXEC is an alias of O_NOINHERIT, and
+     "e" isn't supported.  */
+  static int fopen_e_ever_failed_einval =
+    O_CLOEXEC == 0 || O_CLOEXEC == O_NOINHERIT;
+
+  if (!fopen_e_ever_failed_einval)
+    {
+      char *copy;
+
+      copy = (char *) alloca (strlen (opentype) + 2);
+      strcpy (copy, opentype);
+      /* This is a glibc extension but we try it unconditionally on
+        this path.  */
+      strcat (copy, "e");
+      result = fopen (filename, copy);
+
+      if (result == NULL && errno == EINVAL)
+       {
+         result = fopen (filename, opentype);
+         if (result != NULL)
+           fopen_e_ever_failed_einval = 1;
+       }
+    }
+  else
+    result = fopen (filename, opentype);
+
+  if (result != NULL)
+    maybe_mark_cloexec (fileno (result));
+
+  return gdb_file_up (result);
+}
+
+#ifdef HAVE_SOCKETS
+/* See filestuff.h.  */
+
+int
+gdb_socketpair_cloexec (int domain, int style, int protocol,
+                       int filedes[2])
+{
+#ifdef HAVE_SOCKETPAIR
+  int result = socketpair (domain, style | SOCK_CLOEXEC, protocol, filedes);
+
+  if (result != -1)
+    {
+      socket_mark_cloexec (filedes[0]);
+      socket_mark_cloexec (filedes[1]);
+    }
+
+  return result;
+#else
+  gdb_assert_not_reached (_("socketpair not available on this host"));
+#endif
+}
+
+/* See filestuff.h.  */
+
+int
+gdb_socket_cloexec (int domain, int style, int protocol)
+{
+  int result = socket (domain, style | SOCK_CLOEXEC, protocol);
+
+  if (result != -1)
+    socket_mark_cloexec (result);
+
+  return result;
+}
+#endif
+
+/* See filestuff.h.  */
+
+int
+gdb_pipe_cloexec (int filedes[2])
+{
+  int result;
+
+#ifdef HAVE_PIPE2
+  result = pipe2 (filedes, O_CLOEXEC);
+  if (result != -1)
+    {
+      maybe_mark_cloexec (filedes[0]);
+      maybe_mark_cloexec (filedes[1]);
+    }
+#else
+#ifdef HAVE_PIPE
+  result = pipe (filedes);
+  if (result != -1)
+    {
+      mark_cloexec (filedes[0]);
+      mark_cloexec (filedes[1]);
+    }
+#else /* HAVE_PIPE */
+  gdb_assert_not_reached (_("pipe not available on this host"));
+#endif /* HAVE_PIPE */
+#endif /* HAVE_PIPE2 */
+
+  return result;
+}
+
+/* See gdbsupport/filestuff.h.  */
+
+bool
+is_regular_file (const char *name, int *errno_ptr)
+{
+  struct stat st;
+  const int status = stat (name, &st);
+
+  /* Stat should never fail except when the file does not exist.
+     If stat fails, analyze the source of error and return true
+     unless the file does not exist, to avoid returning false results
+     on obscure systems where stat does not work as expected.  */
+
+  if (status != 0)
+    {
+      if (errno != ENOENT)
+       return true;
+      *errno_ptr = ENOENT;
+      return false;
+    }
+
+  if (S_ISREG (st.st_mode))
+    return true;
+
+  if (S_ISDIR (st.st_mode))
+    *errno_ptr = EISDIR;
+  else
+    *errno_ptr = EINVAL;
+  return false;
+}
+
+/* See gdbsupport/filestuff.h.  */
+
+bool
+mkdir_recursive (const char *dir)
+{
+  auto holder = make_unique_xstrdup (dir);
+  char * const start = holder.get ();
+  char *component_start = start;
+  char *component_end = start;
+
+  while (1)
+    {
+      /* Find the beginning of the next component.  */
+      while (*component_start == '/')
+       component_start++;
+
+      /* Are we done?  */
+      if (*component_start == '\0')
+       return true;
+
+      /* Find the slash or null-terminator after this component.  */
+      component_end = component_start;
+      while (*component_end != '/' && *component_end != '\0')
+       component_end++;
+
+      /* Temporarily replace the slash with a null terminator, so we can create
+         the directory up to this component.  */
+      char saved_char = *component_end;
+      *component_end = '\0';
+
+      /* If we get EEXIST and the existing path is a directory, then we're
+         happy.  If it exists, but it's a regular file and this is not the last
+         component, we'll fail at the next component.  If this is the last
+         component, the caller will fail with ENOTDIR when trying to
+         open/create a file under that path.  */
+      if (mkdir (start, 0700) != 0)
+       if (errno != EEXIST)
+         return false;
+
+      /* Restore the overwritten char.  */
+      *component_end = saved_char;
+      component_start = component_end;
+    }
+}
diff --git a/gdb/gdbsupport/filestuff.h b/gdb/gdbsupport/filestuff.h
new file mode 100644 (file)
index 0000000..c50781d
--- /dev/null
@@ -0,0 +1,142 @@
+/* Low-level file-handling.
+   Copyright (C) 2012-2019 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/>.  */
+
+#ifndef COMMON_FILESTUFF_H
+#define COMMON_FILESTUFF_H
+
+#include <dirent.h>
+#include <fcntl.h>
+
+/* Note all the file descriptors which are open when this is called.
+   These file descriptors will not be closed by close_most_fds.  */
+
+extern void notice_open_fds (void);
+
+/* Mark a file descriptor as inheritable across an exec.  */
+
+extern void mark_fd_no_cloexec (int fd);
+
+/* Mark a file descriptor as no longer being inheritable across an
+   exec.  This is only meaningful when FD was previously passed to
+   mark_fd_no_cloexec.  */
+
+extern void unmark_fd_no_cloexec (int fd);
+
+/* Close all open file descriptors other than those marked by
+   'notice_open_fds', and stdin, stdout, and stderr.  Errors that
+   occur while closing are ignored.  */
+
+extern void close_most_fds (void);
+
+/* Like 'open', but ensures that the returned file descriptor has the
+   close-on-exec flag set.  */
+
+extern int gdb_open_cloexec (const char *filename, int flags,
+                            /* mode_t */ unsigned long mode);
+
+/* Like mkstemp, but ensures that the file descriptor is
+   close-on-exec.  */
+
+static inline int
+gdb_mkostemp_cloexec (char *name_template, int flags = 0)
+{
+  /* gnulib provides a mkostemp replacement if needed.  */
+  return mkostemp (name_template, flags | O_CLOEXEC);
+}
+
+/* Convenience wrapper for the above, which takes the filename as an
+   std::string.  */
+
+static inline int
+gdb_open_cloexec (const std::string &filename, int flags,
+                 /* mode_t */ unsigned long mode)
+{
+  return gdb_open_cloexec (filename.c_str (), flags, mode);
+}
+
+struct gdb_file_deleter
+{
+  void operator() (FILE *file) const
+  {
+    fclose (file);
+  }
+};
+
+/* A unique pointer to a FILE.  */
+
+typedef std::unique_ptr<FILE, gdb_file_deleter> gdb_file_up;
+
+/* Like 'fopen', but ensures that the returned file descriptor has the
+   close-on-exec flag set.  */
+
+extern gdb_file_up gdb_fopen_cloexec (const char *filename,
+                                     const char *opentype);
+
+/* Convenience wrapper for the above, which takes the filename as an
+   std::string.  */
+
+static inline gdb_file_up
+gdb_fopen_cloexec (const std::string &filename, const char *opentype)
+{
+  return gdb_fopen_cloexec (filename.c_str (), opentype);
+}
+
+/* Like 'socketpair', but ensures that the returned file descriptors
+   have the close-on-exec flag set.  */
+
+extern int gdb_socketpair_cloexec (int domain, int style, int protocol,
+                                  int filedes[2]);
+
+/* Like 'socket', but ensures that the returned file descriptor has
+   the close-on-exec flag set.  */
+
+extern int gdb_socket_cloexec (int domain, int style, int protocol);
+
+/* Like 'pipe', but ensures that the returned file descriptors have
+   the close-on-exec flag set.  */
+
+extern int gdb_pipe_cloexec (int filedes[2]);
+
+struct gdb_dir_deleter
+{
+  void operator() (DIR *dir) const
+  {
+    closedir (dir);
+  }
+};
+
+/* A unique pointer to a DIR.  */
+
+typedef std::unique_ptr<DIR, gdb_dir_deleter> gdb_dir_up;
+
+/* Return true if the file NAME exists and is a regular file.
+   If the result is false then *ERRNO_PTR is set to a useful value assuming
+   we're expecting a regular file.  */
+extern bool is_regular_file (const char *name, int *errno_ptr);
+
+
+/* A cheap (as in low-quality) recursive mkdir.  Try to create all the
+   parents directories up to DIR and DIR itself.  Stop if we hit an
+   error along the way.  There is no attempt to remove created
+   directories in case of failure.
+
+   Returns false on failure and sets errno.  */
+
+extern bool mkdir_recursive (const char *dir);
+
+#endif /* COMMON_FILESTUFF_H */
diff --git a/gdb/gdbsupport/filtered-iterator.h b/gdb/gdbsupport/filtered-iterator.h
new file mode 100644 (file)
index 0000000..e1b486d
--- /dev/null
@@ -0,0 +1,87 @@
+/* A forward filtered iterator for GDB, the GNU debugger.
+   Copyright (C) 2018-2019 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/>.  */
+
+#ifndef COMMON_FILTERED_ITERATOR_H
+#define COMMON_FILTERED_ITERATOR_H
+
+/* A filtered iterator.  This wraps BaseIterator and automatically
+   skips elements that FilterFunc filters out.  Requires that
+   default-constructing a BaseIterator creates a valid one-past-end
+   iterator.  */
+
+template<typename BaseIterator, typename FilterFunc>
+class filtered_iterator
+{
+public:
+  typedef filtered_iterator self_type;
+  typedef typename BaseIterator::value_type value_type;
+  typedef typename BaseIterator::reference reference;
+  typedef typename BaseIterator::pointer pointer;
+  typedef typename BaseIterator::iterator_category iterator_category;
+  typedef typename BaseIterator::difference_type difference_type;
+
+  /* Construct by forwarding all arguments to the underlying
+     iterator.  */
+  template<typename... Args>
+  explicit filtered_iterator (Args &&...args)
+    : m_it (std::forward<Args> (args)...)
+  { skip_filtered (); }
+
+  /* Create a one-past-end iterator.  */
+  filtered_iterator () = default;
+
+  /* Need these as the variadic constructor would be a better match
+     otherwise.  */
+  filtered_iterator (filtered_iterator &) = default;
+  filtered_iterator (const filtered_iterator &) = default;
+  filtered_iterator (filtered_iterator &&) = default;
+  filtered_iterator (const filtered_iterator &&other)
+    : filtered_iterator (static_cast<const filtered_iterator &> (other))
+  {}
+
+  value_type operator* () const { return *m_it; }
+
+  self_type &operator++ ()
+  {
+    ++m_it;
+    skip_filtered ();
+    return *this;
+  }
+
+  bool operator== (const self_type &other) const
+  { return *m_it == *other.m_it; }
+
+  bool operator!= (const self_type &other) const
+  { return *m_it != *other.m_it; }
+
+private:
+
+  void skip_filtered ()
+  {
+    for (; m_it != m_end; ++m_it)
+      if (m_filter (*m_it))
+       break;
+  }
+
+private:
+  FilterFunc m_filter {};
+  BaseIterator m_it {};
+  BaseIterator m_end {};
+};
+
+#endif /* COMMON_FILTERED_ITERATOR_H */
diff --git a/gdb/gdbsupport/format.c b/gdb/gdbsupport/format.c
new file mode 100644 (file)
index 0000000..fb3421e
--- /dev/null
@@ -0,0 +1,350 @@
+/* Parse a printf-style format string.
+
+   Copyright (C) 1986-2019 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 "common-defs.h"
+#include "format.h"
+
+format_pieces::format_pieces (const char **arg)
+{
+  const char *s;
+  char *f, *string;
+  const char *prev_start;
+  const char *percent_loc;
+  char *sub_start, *current_substring;
+  enum argclass this_argclass;
+
+  s = *arg;
+
+  /* Parse the format-control string and copy it into the string STRING,
+     processing some kinds of escape sequence.  */
+
+  f = string = (char *) alloca (strlen (s) + 1);
+
+  while (*s != '"' && *s != '\0')
+    {
+      int c = *s++;
+      switch (c)
+       {
+       case '\0':
+         continue;
+
+       case '\\':
+         switch (c = *s++)
+           {
+           case '\\':
+             *f++ = '\\';
+             break;
+           case 'a':
+             *f++ = '\a';
+             break;
+           case 'b':
+             *f++ = '\b';
+             break;
+           case 'e':
+             *f++ = '\e';
+             break;
+           case 'f':
+             *f++ = '\f';
+             break;
+           case 'n':
+             *f++ = '\n';
+             break;
+           case 'r':
+             *f++ = '\r';
+             break;
+           case 't':
+             *f++ = '\t';
+             break;
+           case 'v':
+             *f++ = '\v';
+             break;
+           case '"':
+             *f++ = '"';
+             break;
+           default:
+             /* ??? TODO: handle other escape sequences.  */
+             error (_("Unrecognized escape character \\%c in format string."),
+                    c);
+           }
+         break;
+
+       default:
+         *f++ = c;
+       }
+    }
+
+  /* Terminate our escape-processed copy.  */
+  *f++ = '\0';
+
+  /* Whether the format string ended with double-quote or zero, we're
+     done with it; it's up to callers to complain about syntax.  */
+  *arg = s;
+
+  /* Need extra space for the '\0's.  Doubling the size is sufficient.  */
+
+  current_substring = (char *) xmalloc (strlen (string) * 2 + 1000);
+  m_storage.reset (current_substring);
+
+  /* Now scan the string for %-specs and see what kinds of args they want.
+     argclass classifies the %-specs so we can give printf-type functions
+     something of the right size.  */
+
+  f = string;
+  prev_start = string;
+  while (*f)
+    if (*f++ == '%')
+      {
+       int seen_hash = 0, seen_zero = 0, lcount = 0, seen_prec = 0;
+       int seen_space = 0, seen_plus = 0;
+       int seen_big_l = 0, seen_h = 0, seen_big_h = 0;
+       int seen_big_d = 0, seen_double_big_d = 0;
+       int bad = 0;
+
+       /* Skip over "%%", it will become part of a literal piece.  */
+       if (*f == '%')
+         {
+           f++;
+           continue;
+         }
+
+       sub_start = current_substring;
+
+       strncpy (current_substring, prev_start, f - 1 - prev_start);
+       current_substring += f - 1 - prev_start;
+       *current_substring++ = '\0';
+
+       m_pieces.emplace_back (sub_start, literal_piece);
+
+       percent_loc = f - 1;
+
+       /* Check the validity of the format specifier, and work
+          out what argument it expects.  We only accept C89
+          format strings, with the exception of long long (which
+          we autoconf for).  */
+
+       /* The first part of a format specifier is a set of flag
+          characters.  */
+       while (*f != '\0' && strchr ("0-+ #", *f))
+         {
+           if (*f == '#')
+             seen_hash = 1;
+           else if (*f == '0')
+             seen_zero = 1;
+           else if (*f == ' ')
+             seen_space = 1;
+           else if (*f == '+')
+             seen_plus = 1;
+           f++;
+         }
+
+       /* The next part of a format specifier is a width.  */
+       while (*f != '\0' && strchr ("0123456789", *f))
+         f++;
+
+       /* The next part of a format specifier is a precision.  */
+       if (*f == '.')
+         {
+           seen_prec = 1;
+           f++;
+           while (*f != '\0' && strchr ("0123456789", *f))
+             f++;
+         }
+
+       /* The next part of a format specifier is a length modifier.  */
+       if (*f == 'h')
+         {
+           seen_h = 1;
+           f++;
+         }
+       else if (*f == 'l')
+         {
+           f++;
+           lcount++;
+           if (*f == 'l')
+             {
+               f++;
+               lcount++;
+             }
+         }
+       else if (*f == 'L')
+         {
+           seen_big_l = 1;
+           f++;
+         }
+       /* Decimal32 modifier.  */
+       else if (*f == 'H')
+         {
+           seen_big_h = 1;
+           f++;
+         }
+       /* Decimal64 and Decimal128 modifiers.  */
+       else if (*f == 'D')
+         {
+           f++;
+
+           /* Check for a Decimal128.  */
+           if (*f == 'D')
+             {
+               f++;
+               seen_double_big_d = 1;
+             }
+           else
+             seen_big_d = 1;
+         }
+
+       switch (*f)
+         {
+         case 'u':
+           if (seen_hash)
+             bad = 1;
+           /* FALLTHROUGH */
+
+         case 'o':
+         case 'x':
+         case 'X':
+           if (seen_space || seen_plus)
+             bad = 1;
+         /* FALLTHROUGH */
+
+         case 'd':
+         case 'i':
+           if (lcount == 0)
+             this_argclass = int_arg;
+           else if (lcount == 1)
+             this_argclass = long_arg;
+           else
+             this_argclass = long_long_arg;
+
+           if (seen_big_l)
+             bad = 1;
+           break;
+
+         case 'c':
+           this_argclass = lcount == 0 ? int_arg : wide_char_arg;
+           if (lcount > 1 || seen_h || seen_big_l)
+             bad = 1;
+           if (seen_prec || seen_zero || seen_space || seen_plus)
+             bad = 1;
+           break;
+
+         case 'p':
+           this_argclass = ptr_arg;
+           if (lcount || seen_h || seen_big_l)
+             bad = 1;
+           if (seen_prec)
+             bad = 1;
+           if (seen_hash || seen_zero || seen_space || seen_plus)
+             bad = 1;
+           break;
+
+         case 's':
+           this_argclass = lcount == 0 ? string_arg : wide_string_arg;
+           if (lcount > 1 || seen_h || seen_big_l)
+             bad = 1;
+           if (seen_zero || seen_space || seen_plus)
+             bad = 1;
+           break;
+
+         case 'e':
+         case 'f':
+         case 'g':
+         case 'E':
+         case 'G':
+           if (seen_double_big_d)
+             this_argclass = dec128float_arg;
+           else if (seen_big_d)
+             this_argclass = dec64float_arg;
+           else if (seen_big_h)
+             this_argclass = dec32float_arg;
+           else if (seen_big_l)
+             this_argclass = long_double_arg;
+           else
+             this_argclass = double_arg;
+
+           if (lcount || seen_h)
+             bad = 1;
+           break;
+
+         case '*':
+           error (_("`*' not supported for precision or width in printf"));
+
+         case 'n':
+           error (_("Format specifier `n' not supported in printf"));
+
+         case '\0':
+           error (_("Incomplete format specifier at end of format string"));
+
+         default:
+           error (_("Unrecognized format specifier '%c' in printf"), *f);
+         }
+
+       if (bad)
+         error (_("Inappropriate modifiers to "
+                  "format specifier '%c' in printf"),
+                *f);
+
+       f++;
+
+       sub_start = current_substring;
+
+       if (lcount > 1 && USE_PRINTF_I64)
+         {
+           /* Windows' printf does support long long, but not the usual way.
+              Convert %lld to %I64d.  */
+           int length_before_ll = f - percent_loc - 1 - lcount;
+
+           strncpy (current_substring, percent_loc, length_before_ll);
+           strcpy (current_substring + length_before_ll, "I64");
+           current_substring[length_before_ll + 3] =
+             percent_loc[length_before_ll + lcount];
+           current_substring += length_before_ll + 4;
+         }
+       else if (this_argclass == wide_string_arg
+                || this_argclass == wide_char_arg)
+         {
+           /* Convert %ls or %lc to %s.  */
+           int length_before_ls = f - percent_loc - 2;
+
+           strncpy (current_substring, percent_loc, length_before_ls);
+           strcpy (current_substring + length_before_ls, "s");
+           current_substring += length_before_ls + 2;
+         }
+       else
+         {
+           strncpy (current_substring, percent_loc, f - percent_loc);
+           current_substring += f - percent_loc;
+         }
+
+       *current_substring++ = '\0';
+
+       prev_start = f;
+
+       m_pieces.emplace_back (sub_start, this_argclass);
+      }
+
+  /* Record the remainder of the string.  */
+
+  sub_start = current_substring;
+
+  strncpy (current_substring, prev_start, f - prev_start);
+  current_substring += f - prev_start;
+  *current_substring++ = '\0';
+
+  m_pieces.emplace_back (sub_start, literal_piece);
+}
diff --git a/gdb/gdbsupport/format.h b/gdb/gdbsupport/format.h
new file mode 100644 (file)
index 0000000..08ef66a
--- /dev/null
@@ -0,0 +1,96 @@
+/* Parse a printf-style format string.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_FORMAT_H
+#define COMMON_FORMAT_H
+
+#include "gdbsupport/gdb_string_view.h"
+
+#if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
+# define USE_PRINTF_I64 1
+# define PRINTF_HAS_LONG_LONG
+#else
+# define USE_PRINTF_I64 0
+#endif
+
+/* The argclass represents the general type of data that goes with a
+   format directive; int_arg for %d, long_arg for %l, and so forth.
+   Note that these primarily distinguish types by size and need for
+   special handling, so for instance %u and %x are (at present) also
+   classed as int_arg.  */
+
+enum argclass
+  {
+    literal_piece,
+    int_arg, long_arg, long_long_arg, ptr_arg,
+    string_arg, wide_string_arg, wide_char_arg,
+    double_arg, long_double_arg,
+    dec32float_arg, dec64float_arg, dec128float_arg
+  };
+
+/* A format piece is a section of the format string that may include a
+   single print directive somewhere in it, and the associated class
+   for the argument.  */
+
+struct format_piece
+{
+  format_piece (const char *str, enum argclass argc)
+    : string (str),
+      argclass (argc)
+  {
+  }
+
+  bool operator== (const format_piece &other) const
+  {
+    return (this->argclass == other.argclass
+           && gdb::string_view (this->string) == other.string);
+  }
+
+  const char *string;
+  enum argclass argclass;
+};
+
+class format_pieces
+{
+public:
+
+  format_pieces (const char **arg);
+  ~format_pieces () = default;
+
+  DISABLE_COPY_AND_ASSIGN (format_pieces);
+
+  typedef std::vector<format_piece>::iterator iterator;
+
+  iterator begin ()
+  {
+    return m_pieces.begin ();
+  }
+
+  iterator end ()
+  {
+    return m_pieces.end ();
+  }
+
+private:
+
+  std::vector<format_piece> m_pieces;
+  gdb::unique_xmalloc_ptr<char> m_storage;
+};
+
+#endif /* COMMON_FORMAT_H */
diff --git a/gdb/gdbsupport/forward-scope-exit.h b/gdb/gdbsupport/forward-scope-exit.h
new file mode 100644 (file)
index 0000000..bba4027
--- /dev/null
@@ -0,0 +1,123 @@
+/* Copyright (C) 2019 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/>.  */
+
+#ifndef COMMON_FORWARD_SCOPE_EXIT_H
+#define COMMON_FORWARD_SCOPE_EXIT_H
+
+#include "gdbsupport/scope-exit.h"
+#include <functional>
+
+/* A forward_scope_exit is like scope_exit, but instead of giving it a
+   callable, you instead specialize it for a given cleanup function,
+   and the generated class automatically has a constructor with the
+   same interface as the cleanup function.  forward_scope_exit
+   captures the arguments passed to the ctor, and in turn passes those
+   as arguments to the wrapped cleanup function, when it is called at
+   scope exit time, from within the forward_scope_exit dtor.  The
+   forward_scope_exit class can take any number of arguments, and is
+   cancelable if needed.
+
+   This allows usage like this:
+
+      void
+      delete_longjmp_breakpoint (int arg)
+      {
+       // Blah, blah, blah...
+      }
+
+      using longjmp_breakpoint_cleanup
+       = FORWARD_SCOPE_EXIT (delete_longjmp_breakpoint);
+
+   This above created a new cleanup class `longjmp_breakpoint_cleanup`
+   than can then be used like this:
+
+      longjmp_breakpoint_cleanup obj (thread);
+
+      // Blah, blah, blah...
+
+      obj.release ();  // Optional cancel if needed.
+
+   forward_scope_exit is also handy when you would need to wrap a
+   scope_exit in a gdb::optional:
+
+      gdb::optional<longjmp_breakpoint_cleanup> cleanup;
+      if (some condition)
+       cleanup.emplace (thread);
+      ...
+      if (cleanup)
+       cleanup->release ();
+
+   since with scope exit, you would have to know the scope_exit's
+   callable template type when you create the gdb::optional:
+
+     gdb:optional<scope_exit<what goes here?>>
+
+   The "forward" naming fits both purposes shown above -- the class
+   "forwards" ctor arguments to the wrapped cleanup function at scope
+   exit time, and can also be used to "forward declare"
+   scope_exit-like objects.  */
+
+namespace detail
+{
+
+/* Function and Signature are passed in the same type, in order to
+   extract Function's arguments' types in the specialization below.
+   Those are used to generate the constructor.  */
+
+template<typename Function, Function *function, typename Signature>
+struct forward_scope_exit;
+
+template<typename Function, Function *function,
+        typename Res, typename... Args>
+class forward_scope_exit<Function, function, Res (Args...)>
+  : public scope_exit_base<forward_scope_exit<Function,
+                                             function,
+                                             Res (Args...)>>
+{
+  /* For access to on_exit().  */
+  friend scope_exit_base<forward_scope_exit<Function,
+                                           function,
+                                           Res (Args...)>>;
+
+public:
+  explicit forward_scope_exit (Args ...args)
+    : m_bind_function (function, args...)
+  {
+    /* Nothing.  */
+  }
+
+private:
+  void on_exit ()
+  {
+    m_bind_function ();
+  }
+
+  /* The function and the arguments passed to the ctor, all packed in
+     a std::bind.  */
+  decltype (std::bind (function, std::declval<Args> ()...))
+    m_bind_function;
+};
+
+} /* namespace detail */
+
+/* This is the "public" entry point.  It's a macro to avoid having to
+   name FUNC more than once.  */
+
+#define FORWARD_SCOPE_EXIT(FUNC) \
+  detail::forward_scope_exit<decltype (FUNC), FUNC, decltype (FUNC)>
+
+#endif /* COMMON_FORWARD_SCOPE_EXIT_H */
diff --git a/gdb/gdbsupport/function-view.h b/gdb/gdbsupport/function-view.h
new file mode 100644 (file)
index 0000000..1a577ba
--- /dev/null
@@ -0,0 +1,323 @@
+/* Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_FUNCTION_VIEW_H
+#define COMMON_FUNCTION_VIEW_H
+
+/* function_view is a polymorphic type-erasing wrapper class that
+   encapsulates a non-owning reference to arbitrary callable objects.
+
+   A way to put it is that function_view is to std::function like
+   std::string_view is to std::string.  While std::function stores a
+   type-erased callable object internally, function_view holds a
+   type-erased reference to an external callable object.
+
+   This is meant to be used as callback type of a function that:
+
+     #1 - Takes a callback as parameter.
+
+     #2 - Wants to support arbitrary callable objects as callback type
+         (e.g., stateful function objects, lambda closures, free
+         functions).
+
+     #3 - Does not store the callback anywhere; instead the function
+         just calls the callback directly or forwards it to some
+         other function that calls it.
+
+     #4 - Can't be, or we don't want it to be, a template function
+         with the callable type as template parameter.  For example,
+         when the callback is a parameter of a virtual member
+         function, or when putting the function template in a header
+         would expose too much implementation detail.
+
+   Note that the C-style "function pointer" + "void *data" callback
+   parameter idiom fails requirement #2 above.  Please don't add new
+   uses of that idiom.  I.e., something like this wouldn't work;
+
+    typedef bool (iterate_over_foos_cb) (foo *f, void *user_data),
+    void iterate_over_foos (iterate_over_foos_cb *callback, void *user_data);
+
+    foo *find_foo_by_type (int type)
+    {
+      foo *found = nullptr;
+
+      iterate_over_foos ([&] (foo *f, void *data)
+       {
+         if (foo->type == type)
+           {
+             found = foo;
+             return true; // stop iterating
+           }
+         return false; // continue iterating
+       }, NULL);
+
+      return found;
+    }
+
+   The above wouldn't compile, because lambdas with captures can't be
+   implicitly converted to a function pointer (because a capture means
+   some context data must be passed to the lambda somehow).
+
+   C++11 gave us std::function as type-erased wrapper around arbitrary
+   callables, however, std::function is not an ideal fit for transient
+   callbacks such as the use case above.  For this use case, which is
+   quite pervasive, a function_view is a better choice, because while
+   function_view is light and does not require any heap allocation,
+   std::function is a heavy-weight object with value semantics that
+   generally requires a heap allocation on construction/assignment of
+   the target callable.  In addition, while it is possible to use
+   std::function in such a way that avoids most of the overhead by
+   making sure to only construct it with callables of types that fit
+   std::function's small object optimization, such as function
+   pointers and std::reference_wrapper callables, that is quite
+   inconvenient in practice, because restricting to free-function
+   callables would imply no state/capture/closure, which we need in
+   most cases, and std::reference_wrapper implies remembering to use
+   std::ref/std::cref where the callable is constructed, with the
+   added inconvenience that std::ref/std::cref have deleted rvalue-ref
+   overloads, meaning you can't use unnamed/temporary lambdas with
+   them.
+
+   Note that because function_view is a non-owning view of a callable,
+   care must be taken to ensure that the callable outlives the
+   function_view that calls it.  This is not really a problem for the
+   use case function_view is intended for, such as passing a temporary
+   function object / lambda to a function that accepts a callback,
+   because in those cases, the temporary is guaranteed to be live
+   until the called function returns.
+
+   Calling a function_view with no associated target is undefined,
+   unlike with std::function, which throws std::bad_function_call.
+   This is by design, to avoid the otherwise necessary NULL check in
+   function_view::operator().
+
+   Since function_view objects are small (a pair of pointers), they
+   should generally be passed around by value.
+
+   Usage:
+
+   Given this function that accepts a callback:
+
+    void
+    iterate_over_foos (gdb::function_view<void (foo *)> callback)
+    {
+       for (auto &foo : foos)
+        callback (&foo);
+    }
+
+   you can call it like this, passing a lambda as callback:
+
+    iterate_over_foos ([&] (foo *f)
+      {
+       process_one_foo (f);
+      });
+
+   or like this, passing a function object as callback:
+
+    struct function_object
+    {
+      void operator() (foo *f)
+      {
+       if (s->check ())
+         process_one_foo (f);
+      }
+
+      // some state
+      state *s;
+    };
+
+    state mystate;
+    function_object matcher {&mystate};
+    iterate_over_foos (matcher);
+
+  or like this, passing a function pointer as callback:
+
+    iterate_over_foos (process_one_foo);
+
+  You can find unit tests covering the whole API in
+  unittests/function-view-selftests.c.  */
+
+namespace gdb {
+
+namespace fv_detail {
+/* Bits shared by all function_view instantiations that do not depend
+   on the template parameters.  */
+
+/* Storage for the erased callable.  This is a union in order to be
+   able to save both a function object (data) pointer or a function
+   pointer without triggering undefined behavior.  */
+union erased_callable
+{
+  /* For function objects.  */
+  void *data;
+
+    /* For function pointers.  */
+  void (*fn) ();
+};
+
+} /* namespace fv_detail */
+
+/* Use partial specialization to get access to the callable's
+   signature. */
+template<class Signature>
+struct function_view;
+
+template<typename Res, typename... Args>
+class function_view<Res (Args...)>
+{
+  template<typename From, typename To>
+  using CompatibleReturnType
+    = Or<std::is_void<To>,
+        std::is_same<From, To>,
+        std::is_convertible<From, To>>;
+
+  /* True if Func can be called with Args, and either the result is
+     Res, convertible to Res or Res is void.  */
+  template<typename Callable,
+          typename Res2 = typename std::result_of<Callable &(Args...)>::type>
+  struct IsCompatibleCallable : CompatibleReturnType<Res2, Res>
+  {};
+
+  /* True if Callable is a function_view.  Used to avoid hijacking the
+     copy ctor.  */
+  template <typename Callable>
+  struct IsFunctionView
+    : std::is_same<function_view, typename std::decay<Callable>::type>
+  {};
+
+ public:
+
+  /* NULL by default.  */
+  constexpr function_view () noexcept
+    : m_erased_callable {},
+      m_invoker {}
+  {}
+
+  /* Default copy/assignment is fine.  */
+  function_view (const function_view &) = default;
+  function_view &operator= (const function_view &) = default;
+
+  /* This is the main entry point.  Use SFINAE to avoid hijacking the
+     copy constructor and to ensure that the target type is
+     compatible.  */
+  template
+    <typename Callable,
+     typename = Requires<Not<IsFunctionView<Callable>>>,
+     typename = Requires<IsCompatibleCallable<Callable>>>
+  function_view (Callable &&callable) noexcept
+  {
+    bind (callable);
+  }
+
+  /* Construct a NULL function_view.  */
+  constexpr function_view (std::nullptr_t) noexcept
+    : m_erased_callable {},
+      m_invoker {}
+  {}
+
+  /* Clear a function_view.  */
+  function_view &operator= (std::nullptr_t) noexcept
+  {
+    m_invoker = nullptr;
+    return *this;
+  }
+
+  /* Return true if the wrapper has a target, false otherwise.  Note
+     we check M_INVOKER instead of M_ERASED_CALLABLE because we don't
+     know which member of the union is active right now.  */
+  constexpr explicit operator bool () const noexcept
+  { return m_invoker != nullptr; }
+
+  /* Call the callable.  */
+  Res operator () (Args... args) const
+  { return m_invoker (m_erased_callable, std::forward<Args> (args)...); }
+
+ private:
+
+  /* Bind this function_view to a compatible function object
+     reference.  */
+  template <typename Callable>
+  void bind (Callable &callable) noexcept
+  {
+    m_erased_callable.data = (void *) std::addressof (callable);
+    m_invoker = [] (fv_detail::erased_callable ecall, Args... args)
+      noexcept (noexcept (callable (std::forward<Args> (args)...))) -> Res
+      {
+       auto &restored_callable = *static_cast<Callable *> (ecall.data);
+       /* The explicit cast to Res avoids a compile error when Res is
+          void and the callable returns non-void.  */
+       return (Res) restored_callable (std::forward<Args> (args)...);
+      };
+  }
+
+  /* Bind this function_view to a compatible function pointer.
+
+     Making this a separate function allows avoiding one indirection,
+     by storing the function pointer directly in the storage, instead
+     of a pointer to pointer.  erased_callable is then a union in
+     order to avoid storing a function pointer as a data pointer here,
+     which would be undefined.  */
+  template<class Res2, typename... Args2>
+  void bind (Res2 (*fn) (Args2...)) noexcept
+  {
+    m_erased_callable.fn = reinterpret_cast<void (*) ()> (fn);
+    m_invoker = [] (fv_detail::erased_callable ecall, Args... args)
+      noexcept (noexcept (fn (std::forward<Args> (args)...))) -> Res
+      {
+       auto restored_fn = reinterpret_cast<Res2 (*) (Args2...)> (ecall.fn);
+       /* The explicit cast to Res avoids a compile error when Res is
+          void and the callable returns non-void.  */
+       return (Res) restored_fn (std::forward<Args> (args)...);
+      };
+  }
+
+  /* Storage for the erased callable.  */
+  fv_detail::erased_callable m_erased_callable;
+
+  /* The invoker.  This is set to a capture-less lambda by one of the
+     'bind' overloads.  The lambda restores the right type of the
+     callable (which is passed as first argument), and forwards the
+     args.  */
+  Res (*m_invoker) (fv_detail::erased_callable, Args...);
+};
+
+/* Allow comparison with NULL.  Defer the work to the in-class
+   operator bool implementation.  */
+
+template<typename Res, typename... Args>
+constexpr inline bool
+operator== (const function_view<Res (Args...)> &f, std::nullptr_t) noexcept
+{ return !static_cast<bool> (f); }
+
+template<typename Res, typename... Args>
+constexpr inline bool
+operator== (std::nullptr_t, const function_view<Res (Args...)> &f) noexcept
+{ return !static_cast<bool> (f); }
+
+template<typename Res, typename... Args>
+constexpr inline bool
+operator!= (const function_view<Res (Args...)> &f, std::nullptr_t) noexcept
+{ return static_cast<bool> (f); }
+
+template<typename Res, typename... Args>
+constexpr inline bool
+operator!= (std::nullptr_t, const function_view<Res (Args...)> &f) noexcept
+{ return static_cast<bool> (f); }
+
+} /* namespace gdb */
+
+#endif
diff --git a/gdb/gdbsupport/gdb_assert.h b/gdb/gdbsupport/gdb_assert.h
new file mode 100644 (file)
index 0000000..a719d87
--- /dev/null
@@ -0,0 +1,59 @@
+/* GDB-friendly replacement for <assert.h>.
+   Copyright (C) 2000-2019 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/>.  */
+
+#ifndef COMMON_GDB_ASSERT_H
+#define COMMON_GDB_ASSERT_H
+
+/* A static assertion.  This will cause a compile-time error if EXPR,
+   which must be a compile-time constant, is false.  */
+
+#define gdb_static_assert(expr) static_assert (expr, "")
+
+/* PRAGMATICS: "gdb_assert.h":gdb_assert() is a lower case (rather
+   than upper case) macro since that provides the closest fit to the
+   existing lower case macro <assert.h>:assert() that it is
+   replacing.  */
+
+#define gdb_assert(expr)                                                      \
+  ((void) ((expr) ? 0 :                                                       \
+          (gdb_assert_fail (#expr, __FILE__, __LINE__, FUNCTION_NAME), 0)))
+
+/* This prints an "Assertion failed" message, asking the user if they
+   want to continue, dump core, or just exit.  */
+#if defined (FUNCTION_NAME)
+#define gdb_assert_fail(assertion, file, line, function)                      \
+  internal_error (file, line, _("%s: Assertion `%s' failed."),                \
+                 function, assertion)
+#else
+#define gdb_assert_fail(assertion, file, line, function)                      \
+  internal_error (file, line, _("Assertion `%s' failed."),                    \
+                 assertion)
+#endif
+
+/* The canonical form of gdb_assert (0).
+   MESSAGE is a string to include in the error message.  */
+
+#if defined (FUNCTION_NAME)
+#define gdb_assert_not_reached(message) \
+  internal_error (__FILE__, __LINE__, "%s: %s", FUNCTION_NAME, _(message))
+#else
+#define gdb_assert_not_reached(message) \
+  internal_error (__FILE__, __LINE__, _(message))
+#endif
+
+#endif /* COMMON_GDB_ASSERT_H */
diff --git a/gdb/gdbsupport/gdb_locale.h b/gdb/gdbsupport/gdb_locale.h
new file mode 100644 (file)
index 0000000..4e59b4f
--- /dev/null
@@ -0,0 +1,43 @@
+/* GDB-friendly replacement for <locale.h>.
+   Copyright (C) 2002-2019 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/>.  */
+
+#ifndef COMMON_GDB_LOCALE_H
+#define COMMON_GDB_LOCALE_H
+
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
+
+#ifdef ENABLE_NLS
+# include <libintl.h>
+# define _(String) gettext (String)
+# ifdef gettext_noop
+#  define N_(String) gettext_noop (String)
+# else
+#  define N_(String) (String)
+# endif
+#else
+# define _(String) (String)
+# define N_(String) (String)
+#endif
+
+#ifdef HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+
+#endif /* COMMON_GDB_LOCALE_H */
diff --git a/gdb/gdbsupport/gdb_optional.h b/gdb/gdbsupport/gdb_optional.h
new file mode 100644 (file)
index 0000000..94300e4
--- /dev/null
@@ -0,0 +1,219 @@
+/* An optional object.
+
+   Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_GDB_OPTIONAL_H
+#define COMMON_GDB_OPTIONAL_H
+
+#include "gdbsupport/traits.h"
+
+namespace gdb
+{
+
+struct in_place_t
+{
+  explicit in_place_t () = default;
+};
+
+constexpr gdb::in_place_t in_place {};
+
+/* This class attempts to be a compatible subset of std::optional,
+   which is slated to be available in C++17.  This class optionally
+   holds an object of some type -- by default it is constructed not
+   holding an object, but later the object can be "emplaced".  This is
+   similar to using std::unique_ptr, but in-object allocation is
+   guaranteed.
+
+   Unlike std::optional, we currently only support copy/move
+   construction/assignment of an optional<T> from either exactly
+   optional<T> or T.  I.e., we don't support copy/move
+   construction/assignment from optional<U> or U, when U is a type
+   convertible to T.  Making that work depending on the definitions of
+   T and U is somewhat complicated, and currently the users of this
+   class don't need it.  */
+
+template<typename T>
+class optional
+{
+public:
+
+  constexpr optional ()
+    : m_dummy ()
+  {}
+
+  template<typename... Args>
+  constexpr optional (in_place_t, Args &&... args)
+    : m_item (std::forward<Args> (args)...),
+      m_instantiated (true)
+  {}
+
+  ~optional ()
+  { this->reset (); }
+
+  /* Copy and move constructors.  */
+
+  optional (const optional &other)
+  {
+    if (other.m_instantiated)
+      this->emplace (other.get ());
+  }
+
+  optional (optional &&other)
+    noexcept(std::is_nothrow_move_constructible<T> ())
+  {
+    if (other.m_instantiated)
+      this->emplace (std::move (other.get ()));
+  }
+
+  constexpr optional (const T &other)
+    : m_item (other),
+      m_instantiated (true)
+  {}
+
+  constexpr optional (T &&other)
+    noexcept (std::is_nothrow_move_constructible<T> ())
+    : m_item (std::move (other)),
+      m_instantiated (true)
+  {}
+
+  /* Assignment operators.  */
+
+  optional &
+  operator= (const optional &other)
+  {
+    if (m_instantiated && other.m_instantiated)
+      this->get () = other.get ();
+    else
+      {
+       if (other.m_instantiated)
+         this->emplace (other.get ());
+       else
+         this->reset ();
+      }
+
+    return *this;
+  }
+
+  optional &
+  operator= (optional &&other)
+    noexcept (And<std::is_nothrow_move_constructible<T>,
+             std::is_nothrow_move_assignable<T>> ())
+  {
+    if (m_instantiated && other.m_instantiated)
+      this->get () = std::move (other.get ());
+    else
+      {
+       if (other.m_instantiated)
+         this->emplace (std::move (other.get ()));
+       else
+         this->reset ();
+      }
+    return *this;
+  }
+
+  optional &
+  operator= (const T &other)
+  {
+    if (m_instantiated)
+      this->get () = other;
+    else
+      this->emplace (other);
+    return *this;
+  }
+
+  optional &
+  operator= (T &&other)
+    noexcept (And<std::is_nothrow_move_constructible<T>,
+             std::is_nothrow_move_assignable<T>> ())
+  {
+    if (m_instantiated)
+      this->get () = std::move (other);
+    else
+      this->emplace (std::move (other));
+    return *this;
+  }
+
+  template<typename... Args>
+  T &emplace (Args &&... args)
+  {
+    this->reset ();
+    new (&m_item) T (std::forward<Args>(args)...);
+    m_instantiated = true;
+    return this->get ();
+  }
+
+  /* Observers.  */
+  constexpr const T *operator-> () const
+  { return std::addressof (this->get ()); }
+
+  T *operator-> ()
+  { return std::addressof (this->get ()); }
+
+  constexpr const T &operator* () const &
+  { return this->get (); }
+
+  T &operator* () &
+  { return this->get (); }
+
+  T &&operator* () &&
+  { return std::move (this->get ()); }
+
+  constexpr const T &&operator* () const &&
+  { return std::move (this->get ()); }
+
+  constexpr explicit operator bool () const noexcept
+  { return m_instantiated; }
+
+  constexpr bool has_value () const noexcept
+  { return m_instantiated; }
+
+  /* 'reset' is a 'safe' operation with no precondition.  */
+  void reset () noexcept
+  {
+    if (m_instantiated)
+      this->destroy ();
+  }
+
+private:
+
+  /* Destroy the object.  */
+  void destroy ()
+  {
+    gdb_assert (m_instantiated);
+    m_instantiated = false;
+    m_item.~T ();
+  }
+
+  /* The get operations have m_instantiated as a precondition.  */
+  T &get () noexcept { return m_item; }
+  constexpr const T &get () const noexcept { return m_item; }
+
+  /* The object.  */
+  union
+  {
+    struct { } m_dummy;
+    T m_item;
+  };
+
+  /* True if the object was ever emplaced.  */
+  bool m_instantiated = false;
+};
+
+}
+
+#endif /* COMMON_GDB_OPTIONAL_H */
diff --git a/gdb/gdbsupport/gdb_proc_service.h b/gdb/gdbsupport/gdb_proc_service.h
new file mode 100644 (file)
index 0000000..8565da3
--- /dev/null
@@ -0,0 +1,173 @@
+/* <proc_service.h> replacement for systems that don't have it.
+   Copyright (C) 2000-2019 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/>.  */
+
+#ifndef COMMON_GDB_PROC_SERVICE_H
+#define COMMON_GDB_PROC_SERVICE_H
+
+#include <sys/types.h>
+
+#ifdef HAVE_PROC_SERVICE_H
+
+/* glibc's proc_service.h doesn't wrap itself with extern "C".  Need
+   to do it ourselves.  */
+EXTERN_C_PUSH
+
+#include <proc_service.h>
+
+EXTERN_C_POP
+
+#else /* HAVE_PROC_SERVICE_H */
+
+/* The following fallback definitions have been imported and adjusted
+   from glibc's proc_service.h  */
+
+/* Callback interface for libthread_db, functions users must define.
+   Copyright (C) 1999,2002,2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* The definitions in this file must correspond to those in the debugger.  */
+
+#ifdef HAVE_SYS_PROCFS_H
+#include <sys/procfs.h>
+#endif
+
+/* Not all platforms bring in <linux/elf.h> via <sys/procfs.h>.  If
+   <sys/procfs.h> wasn't enough to find elf_fpregset_t, try the kernel
+   headers also (but don't if we don't need to).  */
+#ifndef HAVE_ELF_FPREGSET_T
+# ifdef HAVE_LINUX_ELF_H
+#  include <linux/elf.h>
+# endif
+#endif
+
+EXTERN_C_PUSH
+
+/* Functions in this interface return one of these status codes.  */
+typedef enum
+{
+  PS_OK,               /* Generic "call succeeded".  */
+  PS_ERR,              /* Generic error.  */
+  PS_BADPID,           /* Bad process handle.  */
+  PS_BADLID,           /* Bad LWP identifier.  */
+  PS_BADADDR,          /* Bad address.  */
+  PS_NOSYM,            /* Could not find given symbol.  */
+  PS_NOFREGS           /* FPU register set not available for given LWP.  */
+} ps_err_e;
+
+#ifndef HAVE_LWPID_T
+typedef unsigned int lwpid_t;
+#endif
+
+#ifndef HAVE_PSADDR_T
+typedef void *psaddr_t;
+#endif
+
+#ifndef HAVE_PRGREGSET_T
+typedef elf_gregset_t prgregset_t;
+#endif
+
+#ifndef HAVE_PRFPREGSET_T
+typedef elf_fpregset_t prfpregset_t;
+#endif
+
+/* This type is opaque in this interface.  It's defined by the user of
+   libthread_db.  GDB's version is defined below.  */
+struct ps_prochandle;
+
+
+/* Read or write process memory at the given address.  */
+extern ps_err_e ps_pdread (struct ps_prochandle *,
+                          psaddr_t, void *, size_t);
+extern ps_err_e ps_pdwrite (struct ps_prochandle *,
+                           psaddr_t, const void *, size_t);
+extern ps_err_e ps_ptread (struct ps_prochandle *,
+                          psaddr_t, void *, size_t);
+extern ps_err_e ps_ptwrite (struct ps_prochandle *,
+                           psaddr_t, const void *, size_t);
+
+
+/* Get and set the given LWP's general or FPU register set.  */
+extern ps_err_e ps_lgetregs (struct ps_prochandle *,
+                            lwpid_t, prgregset_t);
+extern ps_err_e ps_lsetregs (struct ps_prochandle *,
+                            lwpid_t, const prgregset_t);
+extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
+                              lwpid_t, prfpregset_t *);
+extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
+                              lwpid_t, const prfpregset_t *);
+
+/* Return the PID of the process.  */
+extern pid_t ps_getpid (struct ps_prochandle *);
+
+/* Fetch the special per-thread address associated with the given LWP.
+   This call is only used on a few platforms (most use a normal register).
+   The meaning of the `int' parameter is machine-dependent.  */
+extern ps_err_e ps_get_thread_area (struct ps_prochandle *,
+                                   lwpid_t, int, psaddr_t *);
+
+
+/* Look up the named symbol in the named DSO in the symbol tables
+   associated with the process being debugged, filling in *SYM_ADDR
+   with the corresponding run-time address.  */
+extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
+                                  const char *object_name,
+                                  const char *sym_name,
+                                  psaddr_t *sym_addr);
+
+
+/* Stop or continue the entire process.  */
+extern ps_err_e ps_pstop (struct ps_prochandle *);
+extern ps_err_e ps_pcontinue (struct ps_prochandle *);
+
+/* Stop or continue the given LWP alone.  */
+extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
+extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
+
+/* The following are only defined in/called by Solaris.  */
+
+/* Get size of extra register set.  */
+extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph,
+                                lwpid_t lwpid, int *xregsize);
+/* Get extra register set.  */
+extern ps_err_e ps_lgetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
+                             caddr_t xregset);
+extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
+                             caddr_t xregset);
+
+/* Log a message (sends to gdb_stderr).  */
+extern void ps_plog (const char *fmt, ...);
+
+EXTERN_C_POP
+
+#endif /* HAVE_PROC_SERVICE_H */
+
+#endif /* COMMON_GDB_PROC_SERVICE_H */
diff --git a/gdb/gdbsupport/gdb_ref_ptr.h b/gdb/gdbsupport/gdb_ref_ptr.h
new file mode 100644 (file)
index 0000000..c31c9a2
--- /dev/null
@@ -0,0 +1,228 @@
+/* Reference-counted smart pointer class
+
+   Copyright (C) 2016-2019 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/>.  */
+
+#ifndef COMMON_GDB_REF_PTR_H
+#define COMMON_GDB_REF_PTR_H
+
+#include <cstddef>
+
+namespace gdb
+{
+
+/* An instance of this class either holds a reference to a
+   reference-counted object or is "NULL".  Reference counting is
+   handled externally by a policy class.  If the object holds a
+   reference, then when the object is destroyed, the reference is
+   decref'd.
+
+   Normally an instance is constructed using a pointer.  This sort of
+   initialization lets this class manage the lifetime of that
+   reference.
+
+   Assignment and copy construction will make a new reference as
+   appropriate.  Assignment from a plain pointer is disallowed to
+   avoid confusion about whether this acquires a new reference;
+   instead use the "reset" method -- which, like the pointer
+   constructor, transfers ownership.
+
+   The policy class must provide two static methods:
+   void incref (T *);
+   void decref (T *);
+*/
+template<typename T, typename Policy>
+class ref_ptr
+{
+ public:
+
+  /* Create a new NULL instance.  */
+  ref_ptr ()
+    : m_obj (NULL)
+  {
+  }
+
+  /* Create a new NULL instance.  Note that this is not explicit.  */
+  ref_ptr (const std::nullptr_t)
+    : m_obj (NULL)
+  {
+  }
+
+  /* Create a new instance.  OBJ is a reference, management of which
+     is now transferred to this class.  */
+  explicit ref_ptr (T *obj)
+    : m_obj (obj)
+  {
+  }
+
+  /* Copy another instance.  */
+  ref_ptr (const ref_ptr &other)
+    : m_obj (other.m_obj)
+  {
+    if (m_obj != NULL)
+      Policy::incref (m_obj);
+  }
+
+  /* Transfer ownership from OTHER.  */
+  ref_ptr (ref_ptr &&other)
+    : m_obj (other.m_obj)
+  {
+    other.m_obj = NULL;
+  }
+
+  /* Destroy this instance.  */
+  ~ref_ptr ()
+  {
+    if (m_obj != NULL)
+      Policy::decref (m_obj);
+  }
+
+  /* Copy another instance.  */
+  ref_ptr &operator= (const ref_ptr &other)
+  {
+    /* Do nothing on self-assignment.  */
+    if (this != &other)
+      {
+       reset (other.m_obj);
+       if (m_obj != NULL)
+         Policy::incref (m_obj);
+      }
+    return *this;
+  }
+
+  /* Transfer ownership from OTHER.  */
+  ref_ptr &operator= (ref_ptr &&other)
+  {
+    /* Do nothing on self-assignment.  */
+    if (this != &other)
+      {
+       reset (other.m_obj);
+       other.m_obj = NULL;
+      }
+    return *this;
+  }
+
+  /* Change this instance's referent.  OBJ is a reference, management
+     of which is now transferred to this class.  */
+  void reset (T *obj)
+  {
+    if (m_obj != NULL)
+      Policy::decref (m_obj);
+    m_obj = obj;
+  }
+
+  /* Return this instance's referent without changing the state of
+     this class.  */
+  T *get () const
+  {
+    return m_obj;
+  }
+
+  /* Return this instance's referent, and stop managing this
+     reference.  The caller is now responsible for the ownership of
+     the reference.  */
+  ATTRIBUTE_UNUSED_RESULT T *release ()
+  {
+    T *result = m_obj;
+
+    m_obj = NULL;
+    return result;
+  }
+
+  /* Let users refer to members of the underlying pointer.  */
+  T *operator-> () const
+  {
+    return m_obj;
+  }
+
+  /* Acquire a new reference and return a ref_ptr that owns it.  */
+  static ref_ptr<T, Policy> new_reference (T *obj)
+  {
+    Policy::incref (obj);
+    return ref_ptr<T, Policy> (obj);
+  }
+
+ private:
+
+  T *m_obj;
+};
+
+template<typename T, typename Policy>
+inline bool operator== (const ref_ptr<T, Policy> &lhs,
+                       const ref_ptr<T, Policy> &rhs)
+{
+  return lhs.get () == rhs.get ();
+}
+
+template<typename T, typename Policy>
+inline bool operator== (const ref_ptr<T, Policy> &lhs, const T *rhs)
+{
+  return lhs.get () == rhs;
+}
+
+template<typename T, typename Policy>
+inline bool operator== (const ref_ptr<T, Policy> &lhs, const std::nullptr_t)
+{
+  return lhs.get () == nullptr;
+}
+
+template<typename T, typename Policy>
+inline bool operator== (const T *lhs, const ref_ptr<T, Policy> &rhs)
+{
+  return lhs == rhs.get ();
+}
+
+template<typename T, typename Policy>
+inline bool operator== (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
+{
+  return nullptr == rhs.get ();
+}
+
+template<typename T, typename Policy>
+inline bool operator!= (const ref_ptr<T, Policy> &lhs,
+                       const ref_ptr<T, Policy> &rhs)
+{
+  return lhs.get () != rhs.get ();
+}
+
+template<typename T, typename Policy>
+inline bool operator!= (const ref_ptr<T, Policy> &lhs, const T *rhs)
+{
+  return lhs.get () != rhs;
+}
+
+template<typename T, typename Policy>
+inline bool operator!= (const ref_ptr<T, Policy> &lhs, const std::nullptr_t)
+{
+  return lhs.get () != nullptr;
+}
+
+template<typename T, typename Policy>
+inline bool operator!= (const T *lhs, const ref_ptr<T, Policy> &rhs)
+{
+  return lhs != rhs.get ();
+}
+
+template<typename T, typename Policy>
+inline bool operator!= (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
+{
+  return nullptr != rhs.get ();
+}
+
+}
+
+#endif /* COMMON_GDB_REF_PTR_H */
diff --git a/gdb/gdbsupport/gdb_setjmp.h b/gdb/gdbsupport/gdb_setjmp.h
new file mode 100644 (file)
index 0000000..d4ebbfa
--- /dev/null
@@ -0,0 +1,34 @@
+/* Portability wrappers for setjmp and longjmp.
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_GDB_SETJMP_H
+#define COMMON_GDB_SETJMP_H
+
+#include <setjmp.h>
+
+#ifdef HAVE_SIGSETJMP
+#define SIGJMP_BUF             sigjmp_buf
+#define SIGSETJMP(buf)         sigsetjmp((buf), 1)
+#define SIGLONGJMP(buf,val)    siglongjmp((buf), (val))
+#else
+#define SIGJMP_BUF             jmp_buf
+#define SIGSETJMP(buf)         setjmp(buf)
+#define SIGLONGJMP(buf,val)    longjmp((buf), (val))
+#endif
+
+#endif /* COMMON_GDB_SETJMP_H */
diff --git a/gdb/gdbsupport/gdb_signals.h b/gdb/gdbsupport/gdb_signals.h
new file mode 100644 (file)
index 0000000..da99f57
--- /dev/null
@@ -0,0 +1,58 @@
+/* Target signal translation functions for GDB.
+   Copyright (C) 1990-2019 Free Software Foundation, Inc.
+   Contributed by Cygnus Support.
+
+   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/>.  */
+
+#ifndef COMMON_GDB_SIGNALS_H
+#define COMMON_GDB_SIGNALS_H
+
+#include "gdb/signals.h"
+
+/* Predicate to gdb_signal_to_host(). Return non-zero if the enum
+   targ_signal SIGNO has an equivalent ``host'' representation.  */
+/* FIXME: cagney/1999-11-22: The name below was chosen in preference
+   to the shorter gdb_signal_p() because it is far less ambigious.
+   In this context ``gdb_signal'' refers to GDB's internal
+   representation of the target's set of signals while ``host signal''
+   refers to the target operating system's signal.  Confused?  */
+extern int gdb_signal_to_host_p (enum gdb_signal signo);
+
+/* Convert between host signal numbers and enum gdb_signal's.
+   gdb_signal_to_host() returns 0 and prints a warning() on GDB's
+   console if SIGNO has no equivalent host representation.  */
+/* FIXME: cagney/1999-11-22: Here ``host'' is used incorrectly, it is
+   refering to the target operating system's signal numbering.
+   Similarly, ``enum gdb_signal'' is named incorrectly, ``enum
+   gdb_signal'' would probably be better as it is refering to GDB's
+   internal representation of a target operating system's signal.  */
+extern enum gdb_signal gdb_signal_from_host (int);
+extern int gdb_signal_to_host (enum gdb_signal);
+
+/* Return the enum symbol name of SIG as a string, to use in debug
+   output.  */
+extern const char *gdb_signal_to_symbol_string (enum gdb_signal sig);
+
+/* Return the string for a signal.  */
+extern const char *gdb_signal_to_string (enum gdb_signal);
+
+/* Return the name (SIGHUP, etc.) for a signal.  */
+extern const char *gdb_signal_to_name (enum gdb_signal);
+
+/* Given a name (SIGHUP, etc.), return its signal.  */
+enum gdb_signal gdb_signal_from_name (const char *);
+
+#endif /* COMMON_GDB_SIGNALS_H */
diff --git a/gdb/gdbsupport/gdb_splay_tree.h b/gdb/gdbsupport/gdb_splay_tree.h
new file mode 100644 (file)
index 0000000..90b05cd
--- /dev/null
@@ -0,0 +1,42 @@
+/* GDB wrapper for splay trees.
+
+   Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_GDB_SPLAY_TREE_H
+#define COMMON_GDB_SPLAY_TREE_H
+
+#include "splay-tree.h"
+
+namespace gdb {
+
+struct splay_tree_deleter
+{
+  void operator() (splay_tree tree) const
+  {
+    splay_tree_delete (tree);
+  }
+};
+
+} /* namespace gdb */
+
+/* A unique pointer to a splay tree.  */
+
+typedef std::unique_ptr<splay_tree_s, gdb::splay_tree_deleter>
+    gdb_splay_tree_up;
+
+#endif /* COMMON_GDB_SPLAY_TREE_H */
diff --git a/gdb/gdbsupport/gdb_string_view.h b/gdb/gdbsupport/gdb_string_view.h
new file mode 100644 (file)
index 0000000..68f7f7d
--- /dev/null
@@ -0,0 +1,562 @@
+// Components for manipulating non-owning sequences of characters -*- C++ -*-
+
+
+#ifndef COMMON_GDB_STRING_VIEW_H
+#define COMMON_GDB_STRING_VIEW_H
+
+// Note: This file has been stolen from the gcc repo
+// (libstdc++-v3/include/experimental/string_view) and has local modifications.
+
+// Copyright (C) 2013-2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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, or (at your option)
+// any later version.
+
+// This library 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// N3762 basic_string_view library
+//
+
+
+#if __cplusplus >= 201703L
+
+#include <string_view>
+
+namespace gdb {
+  using string_view = std::string_view;
+} /* namespace gdb */
+
+#else /* __cplusplus < 201703L */
+
+#include <string>
+#include <limits>
+
+namespace gdb {
+
+  /**
+   *  @class basic_string_view <experimental/string_view>
+   *  @brief  A non-owning reference to a string.
+   *
+   *  @ingroup strings
+   *  @ingroup sequences
+   *  @ingroup experimental
+   *
+   *  @tparam _CharT  Type of character
+   *  @tparam _Traits  Traits for character type, defaults to
+   *                   char_traits<_CharT>.
+   *
+   *  A basic_string_view looks like this:
+   *
+   *  @code
+   *    _CharT*    _M_str
+   *    size_t     _M_len
+   *  @endcode
+   */
+  template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
+    class basic_string_view
+    {
+    public:
+
+      // types
+      using traits_type = _Traits;
+      using value_type = _CharT;
+      using pointer = const _CharT*;
+      using const_pointer = const _CharT*;
+      using reference = const _CharT&;
+      using const_reference = const _CharT&;
+      using const_iterator = const _CharT*;
+      using iterator = const_iterator;
+      using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+      using reverse_iterator = const_reverse_iterator;
+      using size_type = size_t;
+      using difference_type = ptrdiff_t;
+      static constexpr size_type npos = size_type(-1);
+
+      // [string.view.cons], construct/copy
+
+      constexpr
+      basic_string_view() noexcept
+      : _M_len{0}, _M_str{nullptr}
+      { }
+
+      constexpr basic_string_view(const basic_string_view&) noexcept = default;
+
+      template<typename _Allocator>
+        basic_string_view(const std::basic_string<_CharT, _Traits,
+                         _Allocator>& __str) noexcept
+        : _M_len{__str.length()}, _M_str{__str.data()}
+        { }
+
+      /*constexpr*/ basic_string_view(const _CharT* __str)
+      : _M_len{__str == nullptr ? 0 : traits_type::length(__str)},
+       _M_str{__str}
+      { }
+
+      constexpr basic_string_view(const _CharT* __str, size_type __len)
+      : _M_len{__len},
+        _M_str{__str}
+      { }
+
+      basic_string_view&
+      operator=(const basic_string_view&) noexcept = default;
+
+      // [string.view.iterators], iterators
+
+      constexpr const_iterator
+      begin() const noexcept
+      { return this->_M_str; }
+
+      constexpr const_iterator
+      end() const noexcept
+      { return this->_M_str + this->_M_len; }
+
+      constexpr const_iterator
+      cbegin() const noexcept
+      { return this->_M_str; }
+
+      constexpr const_iterator
+      cend() const noexcept
+      { return this->_M_str + this->_M_len; }
+
+      const_reverse_iterator
+      rbegin() const noexcept
+      { return const_reverse_iterator(this->end()); }
+
+      const_reverse_iterator
+      rend() const noexcept
+      { return const_reverse_iterator(this->begin()); }
+
+      const_reverse_iterator
+      crbegin() const noexcept
+      { return const_reverse_iterator(this->end()); }
+
+      const_reverse_iterator
+      crend() const noexcept
+      { return const_reverse_iterator(this->begin()); }
+
+      // [string.view.capacity], capacity
+
+      constexpr size_type
+      size() const noexcept
+      { return this->_M_len; }
+
+      constexpr size_type
+      length() const noexcept
+      { return _M_len; }
+
+      constexpr size_type
+      max_size() const noexcept
+      {
+       return (npos - sizeof(size_type) - sizeof(void*))
+               / sizeof(value_type) / 4;
+      }
+
+      constexpr bool
+      empty() const noexcept
+      { return this->_M_len == 0; }
+
+      // [string.view.access], element access
+
+      constexpr const _CharT&
+      operator[](size_type __pos) const
+      {
+       // TODO: Assert to restore in a way compatible with the constexpr.
+       // __glibcxx_assert(__pos < this->_M_len);
+       return *(this->_M_str + __pos);
+      }
+
+      constexpr const _CharT&
+      at(size_type __pos) const
+      {
+       return __pos < this->_M_len
+            ? *(this->_M_str + __pos)
+            : (error (_("basic_string_view::at: __pos "
+                        "(which is %zu) >= this->size() "
+                        "(which is %zu)"),
+                      __pos, this->size()),
+               *this->_M_str);
+      }
+
+      constexpr const _CharT&
+      front() const
+      {
+       // TODO: Assert to restore in a way compatible with the constexpr.
+       // __glibcxx_assert(this->_M_len > 0);
+       return *this->_M_str;
+      }
+
+      constexpr const _CharT&
+      back() const
+      {
+       // TODO: Assert to restore in a way compatible with the constexpr.
+       // __glibcxx_assert(this->_M_len > 0);
+       return *(this->_M_str + this->_M_len - 1);
+      }
+
+      constexpr const _CharT*
+      data() const noexcept
+      { return this->_M_str; }
+
+      // [string.view.modifiers], modifiers:
+
+      /*constexpr*/ void
+      remove_prefix(size_type __n)
+      {
+       gdb_assert (this->_M_len >= __n);
+       this->_M_str += __n;
+       this->_M_len -= __n;
+      }
+
+      /*constexpr*/ void
+      remove_suffix(size_type __n)
+      { this->_M_len -= __n; }
+
+      /*constexpr*/ void
+      swap(basic_string_view& __sv) noexcept
+      {
+       auto __tmp = *this;
+       *this = __sv;
+       __sv = __tmp;
+      }
+
+
+      // [string.view.ops], string operations:
+
+      template<typename _Allocator>
+        explicit operator std::basic_string<_CharT, _Traits, _Allocator>() const
+        {
+         return { this->_M_str, this->_M_len };
+       }
+
+      template<typename _Allocator = std::allocator<_CharT>>
+       std::basic_string<_CharT, _Traits, _Allocator>
+       to_string(const _Allocator& __alloc = _Allocator()) const
+       {
+         return { this->_M_str, this->_M_len, __alloc };
+       }
+
+      size_type
+      copy(_CharT* __str, size_type __n, size_type __pos = 0) const
+      {
+       gdb_assert (__str != nullptr || __n == 0);
+       if (__pos > this->_M_len)
+         error (_("basic_string_view::copy: __pos "
+                  "(which is %zu) > this->size() "
+                  "(which is %zu)"),
+                __pos, this->size());
+       size_type __rlen{std::min(__n, size_type{this->_M_len  - __pos})};
+       for (auto __begin = this->_M_str + __pos,
+            __end = __begin + __rlen; __begin != __end;)
+         *__str++ = *__begin++;
+       return __rlen;
+      }
+
+
+      // [string.view.ops], string operations:
+
+      /*constexpr*/ basic_string_view
+      substr(size_type __pos, size_type __n=npos) const
+      {
+       return __pos <= this->_M_len
+            ? basic_string_view{this->_M_str + __pos,
+                               std::min(__n, size_type{this->_M_len  - __pos})}
+            : (error (_("basic_string_view::substr: __pos "
+                        "(which is %zu) > this->size() "
+                        "(which is %zu)"),
+                      __pos, this->size()), basic_string_view{});
+      }
+
+      /*constexpr*/ int
+      compare(basic_string_view __str) const noexcept
+      {
+       int __ret = traits_type::compare(this->_M_str, __str._M_str,
+                                        std::min(this->_M_len, __str._M_len));
+       if (__ret == 0)
+         __ret = _S_compare(this->_M_len, __str._M_len);
+       return __ret;
+      }
+
+      /*constexpr*/ int
+      compare(size_type __pos1, size_type __n1, basic_string_view __str) const
+      { return this->substr(__pos1, __n1).compare(__str); }
+
+      /*constexpr*/ int
+      compare(size_type __pos1, size_type __n1,
+             basic_string_view __str, size_type __pos2, size_type __n2) const
+      { return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); }
+
+      /*constexpr*/ int
+      compare(const _CharT* __str) const noexcept
+      { return this->compare(basic_string_view{__str}); }
+
+      /*constexpr*/ int
+      compare(size_type __pos1, size_type __n1, const _CharT* __str) const
+      { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
+
+      /*constexpr*/ int
+      compare(size_type __pos1, size_type __n1,
+             const _CharT* __str, size_type __n2) const
+      {
+       return this->substr(__pos1, __n1)
+                  .compare(basic_string_view(__str, __n2));
+      }
+
+      /*constexpr*/ size_type
+      find(basic_string_view __str, size_type __pos = 0) const noexcept
+      { return this->find(__str._M_str, __pos, __str._M_len); }
+
+      /*constexpr*/ size_type
+      find(_CharT __c, size_type __pos=0) const noexcept;
+
+      /*constexpr*/ size_type
+      find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
+
+      /*constexpr*/ size_type
+      find(const _CharT* __str, size_type __pos=0) const noexcept
+      { return this->find(__str, __pos, traits_type::length(__str)); }
+
+      /*constexpr*/ size_type
+      rfind(basic_string_view __str, size_type __pos = npos) const noexcept
+      { return this->rfind(__str._M_str, __pos, __str._M_len); }
+
+      /*constexpr*/ size_type
+      rfind(_CharT __c, size_type __pos = npos) const noexcept;
+
+      /*constexpr*/ size_type
+      rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
+
+      /*constexpr*/ size_type
+      rfind(const _CharT* __str, size_type __pos = npos) const noexcept
+      { return this->rfind(__str, __pos, traits_type::length(__str)); }
+
+      /*constexpr*/ size_type
+      find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
+      { return this->find_first_of(__str._M_str, __pos, __str._M_len); }
+
+      /*constexpr*/ size_type
+      find_first_of(_CharT __c, size_type __pos = 0) const noexcept
+      { return this->find(__c, __pos); }
+
+      /*constexpr*/ size_type
+      find_first_of(const _CharT* __str, size_type __pos, size_type __n) const;
+
+      /*constexpr*/ size_type
+      find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
+      { return this->find_first_of(__str, __pos, traits_type::length(__str)); }
+
+      /*constexpr*/ size_type
+      find_last_of(basic_string_view __str,
+                  size_type __pos = npos) const noexcept
+      { return this->find_last_of(__str._M_str, __pos, __str._M_len); }
+
+      size_type
+      find_last_of(_CharT __c, size_type __pos=npos) const noexcept
+      { return this->rfind(__c, __pos); }
+
+      /*constexpr*/ size_type
+      find_last_of(const _CharT* __str, size_type __pos, size_type __n) const;
+
+      /*constexpr*/ size_type
+      find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
+      { return this->find_last_of(__str, __pos, traits_type::length(__str)); }
+
+      /*constexpr*/ size_type
+      find_first_not_of(basic_string_view __str,
+                       size_type __pos = 0) const noexcept
+      { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
+
+      /*constexpr*/ size_type
+      find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
+
+      /*constexpr*/ size_type
+      find_first_not_of(const _CharT* __str,
+                       size_type __pos, size_type __n) const;
+
+      /*constexpr*/ size_type
+      find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
+      {
+       return this->find_first_not_of(__str, __pos,
+                                      traits_type::length(__str));
+      }
+
+      /*constexpr*/ size_type
+      find_last_not_of(basic_string_view __str,
+                      size_type __pos = npos) const noexcept
+      { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
+
+      /*constexpr*/ size_type
+      find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
+
+      /*constexpr*/ size_type
+      find_last_not_of(const _CharT* __str,
+                      size_type __pos, size_type __n) const;
+
+      /*constexpr*/ size_type
+      find_last_not_of(const _CharT* __str,
+                      size_type __pos = npos) const noexcept
+      {
+       return this->find_last_not_of(__str, __pos,
+                                     traits_type::length(__str));
+      }
+
+    private:
+
+      static constexpr int
+      _S_compare(size_type __n1, size_type __n2) noexcept
+      {
+       return difference_type(__n1 - __n2) > std::numeric_limits<int>::max()
+            ? std::numeric_limits<int>::max()
+            : difference_type(__n1 - __n2) < std::numeric_limits<int>::min()
+            ? std::numeric_limits<int>::min()
+            : static_cast<int>(difference_type(__n1 - __n2));
+      }
+
+      size_t       _M_len;
+      const _CharT* _M_str;
+    };
+
+  // [string.view.comparison], non-member basic_string_view comparison functions
+
+  namespace __detail
+  {
+    // Identity transform to create a non-deduced context, so that only one
+    // argument participates in template argument deduction and the other
+    // argument gets implicitly converted to the deduced type. See n3766.html.
+    template<typename _Tp>
+      using __idt = typename std::common_type<_Tp>::type;
+  }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator==(basic_string_view<_CharT, _Traits> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator==(basic_string_view<_CharT, _Traits> __x,
+               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator!=(basic_string_view<_CharT, _Traits> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return !(__x == __y); }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator!=(basic_string_view<_CharT, _Traits> __x,
+               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+    { return !(__x == __y); }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return !(__x == __y); }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator< (basic_string_view<_CharT, _Traits> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return __x.compare(__y) < 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator< (basic_string_view<_CharT, _Traits> __x,
+               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+    { return __x.compare(__y) < 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return __x.compare(__y) < 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator> (basic_string_view<_CharT, _Traits> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return __x.compare(__y) > 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator> (basic_string_view<_CharT, _Traits> __x,
+               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+    { return __x.compare(__y) > 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return __x.compare(__y) > 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator<=(basic_string_view<_CharT, _Traits> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return __x.compare(__y) <= 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator<=(basic_string_view<_CharT, _Traits> __x,
+               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+    { return __x.compare(__y) <= 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return __x.compare(__y) <= 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator>=(basic_string_view<_CharT, _Traits> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return __x.compare(__y) >= 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator>=(basic_string_view<_CharT, _Traits> __x,
+               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+    { return __x.compare(__y) >= 0; }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ bool
+    operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+               basic_string_view<_CharT, _Traits> __y) noexcept
+    { return __x.compare(__y) >= 0; }
+
+  // basic_string_view typedef names
+
+  using string_view = basic_string_view<char>;
+} /* namespace gdb */
+
+#include "gdb_string_view.tcc"
+
+#endif // __cplusplus < 201703L
+
+#endif /* COMMON_GDB_STRING_VIEW_H */
diff --git a/gdb/gdbsupport/gdb_string_view.tcc b/gdb/gdbsupport/gdb_string_view.tcc
new file mode 100644 (file)
index 0000000..c30aafa
--- /dev/null
@@ -0,0 +1,219 @@
+// Components for manipulating non-owning sequences of characters -*- C++ -*-
+
+// Note: This file has been stolen from the gcc repo
+// (libstdc++-v3/include/experimental/bits/string_view.tcc) and has local
+// modifications.
+
+// Copyright (C) 2013-2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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, or (at your option)
+// any later version.
+
+// This library 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file experimental/bits/string_view.tcc
+ *  This is an internal header file, included by other library headers.
+ *  Do not attempt to use it directly. @headername{experimental/string_view}
+ */
+
+//
+// N3762 basic_string_view library
+//
+
+#ifndef GDB_STRING_VIEW_TCC
+#define GDB_STRING_VIEW_TCC 1
+
+namespace gdb
+{
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
+    basic_string_view<_CharT, _Traits>::
+    find(const _CharT* __str, size_type __pos, size_type __n) const noexcept
+    {
+      gdb_assert (__str != nullptr || __n == 0);
+
+      if (__n == 0)
+       return __pos <= this->_M_len ? __pos : npos;
+
+      if (__n <= this->_M_len)
+       {
+         for (; __pos <= this->_M_len - __n; ++__pos)
+           if (traits_type::eq(this->_M_str[__pos], __str[0])
+               && traits_type::compare(this->_M_str + __pos + 1,
+                                       __str + 1, __n - 1) == 0)
+             return __pos;
+       }
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
+    basic_string_view<_CharT, _Traits>::
+    find(_CharT __c, size_type __pos) const noexcept
+    {
+      size_type __ret = npos;
+      if (__pos < this->_M_len)
+       {
+         const size_type __n = this->_M_len - __pos;
+         const _CharT* __p = traits_type::find(this->_M_str + __pos, __n, __c);
+         if (__p)
+           __ret = __p - this->_M_str;
+       }
+      return __ret;
+    }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
+    basic_string_view<_CharT, _Traits>::
+    rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept
+    {
+      gdb_assert (__str != nullptr || __n == 0);
+
+      if (__n <= this->_M_len)
+       {
+         __pos = std::min(size_type(this->_M_len - __n), __pos);
+         do
+           {
+             if (traits_type::compare(this->_M_str + __pos, __str, __n) == 0)
+               return __pos;
+           }
+         while (__pos-- > 0);
+       }
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
+    basic_string_view<_CharT, _Traits>::
+    rfind(_CharT __c, size_type __pos) const noexcept
+    {
+      size_type __size = this->_M_len;
+      if (__size > 0)
+       {
+         if (--__size > __pos)
+           __size = __pos;
+         for (++__size; __size-- > 0; )
+           if (traits_type::eq(this->_M_str[__size], __c))
+             return __size;
+       }
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
+    basic_string_view<_CharT, _Traits>::
+    find_first_of(const _CharT* __str, size_type __pos, size_type __n) const
+    {
+      gdb_assert (__str != nullptr || __n == 0);
+      for (; __n && __pos < this->_M_len; ++__pos)
+       {
+         const _CharT* __p = traits_type::find(__str, __n,
+                                               this->_M_str[__pos]);
+         if (__p)
+           return __pos;
+       }
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
+    basic_string_view<_CharT, _Traits>::
+    find_last_of(const _CharT* __str, size_type __pos, size_type __n) const
+    {
+      gdb_assert (__str != nullptr || __n == 0);
+      size_type __size = this->size();
+      if (__size && __n)
+       {
+         if (--__size > __pos)
+           __size = __pos;
+         do
+           {
+             if (traits_type::find(__str, __n, this->_M_str[__size]))
+               return __size;
+           }
+         while (__size-- != 0);
+       }
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
+    basic_string_view<_CharT, _Traits>::
+    find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const
+    {
+      gdb_assert (__str != nullptr || __n == 0);
+      for (; __pos < this->_M_len; ++__pos)
+       if (!traits_type::find(__str, __n, this->_M_str[__pos]))
+         return __pos;
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
+    basic_string_view<_CharT, _Traits>::
+    find_first_not_of(_CharT __c, size_type __pos) const noexcept
+    {
+      for (; __pos < this->_M_len; ++__pos)
+       if (!traits_type::eq(this->_M_str[__pos], __c))
+         return __pos;
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
+    basic_string_view<_CharT, _Traits>::
+    find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const
+    {
+      gdb_assert (__str != nullptr || __n == 0);
+      size_type __size = this->_M_len;
+      if (__size)
+       {
+         if (--__size > __pos)
+           __size = __pos;
+         do
+           {
+             if (!traits_type::find(__str, __n, this->_M_str[__size]))
+               return __size;
+           }
+         while (__size--);
+       }
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits>
+    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
+    basic_string_view<_CharT, _Traits>::
+    find_last_not_of(_CharT __c, size_type __pos) const noexcept
+    {
+      size_type __size = this->_M_len;
+      if (__size)
+       {
+         if (--__size > __pos)
+           __size = __pos;
+         do
+           {
+             if (!traits_type::eq(this->_M_str[__size], __c))
+               return __size;
+           }
+         while (__size--);
+       }
+      return npos;
+    }
+} // namespace gdb
+
+#endif // GDB_STRING_VIEW_TCC
diff --git a/gdb/gdbsupport/gdb_sys_time.h b/gdb/gdbsupport/gdb_sys_time.h
new file mode 100644 (file)
index 0000000..66c2bb3
--- /dev/null
@@ -0,0 +1,38 @@
+/* Copyright (C) 2015-2019 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/>.  */
+
+#ifndef COMMON_GDB_SYS_TIME_H
+#define COMMON_GDB_SYS_TIME_H
+
+#include <sys/time.h>
+
+/* On MinGW-w64, gnulib's sys/time.h replaces 'struct timeval' and
+   gettimeofday with versions that support 64-bit time_t, for POSIX
+   compliance.  However, the gettimeofday replacement does not ever
+   return time_t values larger than 31-bit, as it simply returns the
+   system's gettimeofday's (signed) 32-bit result as (signed) 64-bit.
+   Because we don't really need the POSIX compliance, and it ends up
+   causing conflicts with other libraries we use that don't use gnulib
+   and thus work with the native struct timeval, such as Winsock2's
+   native 'select' and libiberty, simply undefine away gnulib's
+   replacements.  */
+#if GNULIB_defined_struct_timeval
+# undef timeval
+# undef gettimeofday
+#endif
+
+#endif /* COMMON_GDB_SYS_TIME_H */
diff --git a/gdb/gdbsupport/gdb_tilde_expand.c b/gdb/gdbsupport/gdb_tilde_expand.c
new file mode 100644 (file)
index 0000000..7e4b06d
--- /dev/null
@@ -0,0 +1,95 @@
+/* Perform tilde expansion on paths for GDB and gdbserver.
+
+   Copyright (C) 2017-2019 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 "common-defs.h"
+#include "gdb_tilde_expand.h"
+#include <glob.h>
+
+/* RAII-style class wrapping "glob".  */
+
+class gdb_glob
+{
+public:
+  /* Construct a "gdb_glob" object by calling "glob" with the provided
+     parameters.  This function can throw if "glob" fails.  */
+  gdb_glob (const char *pattern, int flags,
+           int (*errfunc) (const char *epath, int eerrno))
+  {
+    int ret = glob (pattern, flags, errfunc, &m_glob);
+
+    if (ret != 0)
+      {
+       if (ret == GLOB_NOMATCH)
+         error (_("Could not find a match for '%s'."), pattern);
+       else
+         error (_("glob could not process pattern '%s'."),
+                pattern);
+      }
+  }
+
+  /* Destroy the object and free M_GLOB.  */
+  ~gdb_glob ()
+  {
+    globfree (&m_glob);
+  }
+
+  /* Return the GL_PATHC component of M_GLOB.  */
+  int pathc () const
+  {
+    return m_glob.gl_pathc;
+  }
+
+  /* Return the GL_PATHV component of M_GLOB.  */
+  char **pathv () const
+  {
+    return m_glob.gl_pathv;
+  }
+
+private:
+  /* The actual glob object we're dealing with.  */
+  glob_t m_glob;
+};
+
+/* See gdbsupport/gdb_tilde_expand.h.  */
+
+std::string
+gdb_tilde_expand (const char *dir)
+{
+  gdb_glob glob (dir, GLOB_TILDE_CHECK, NULL);
+
+  gdb_assert (glob.pathc () > 0);
+  /* "glob" may return more than one match to the path provided by the
+     user, but we are only interested in the first match.  */
+  std::string expanded_dir = glob.pathv ()[0];
+
+  return expanded_dir;
+}
+
+/* See gdbsupport/gdb_tilde_expand.h.  */
+
+gdb::unique_xmalloc_ptr<char>
+gdb_tilde_expand_up (const char *dir)
+{
+  gdb_glob glob (dir, GLOB_TILDE_CHECK, NULL);
+
+  gdb_assert (glob.pathc () > 0);
+  /* "glob" may return more than one match to the path provided by the
+     user, but we are only interested in the first match.  */
+  return make_unique_xstrdup (glob.pathv ()[0]);
+}
diff --git a/gdb/gdbsupport/gdb_tilde_expand.h b/gdb/gdbsupport/gdb_tilde_expand.h
new file mode 100644 (file)
index 0000000..b181b6a
--- /dev/null
@@ -0,0 +1,31 @@
+/* Perform tilde expansion on paths for GDB and gdbserver.
+
+   Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_GDB_TILDE_EXPAND_H
+#define COMMON_GDB_TILDE_EXPAND_H
+
+/* Perform path expansion (i.e., tilde expansion) on DIR, and return
+   the full path.  */
+extern std::string gdb_tilde_expand (const char *dir);
+
+/* Same as GDB_TILDE_EXPAND, but return the full path as a
+   gdb::unique_xmalloc_ptr<char>.  */
+extern gdb::unique_xmalloc_ptr<char> gdb_tilde_expand_up (const char *dir);
+
+#endif /* COMMON_GDB_TILDE_EXPAND_H */
diff --git a/gdb/gdbsupport/gdb_unique_ptr.h b/gdb/gdbsupport/gdb_unique_ptr.h
new file mode 100644 (file)
index 0000000..67a5f26
--- /dev/null
@@ -0,0 +1,67 @@
+/* std::unique_ptr specializations for GDB.
+
+   Copyright (C) 2016-2019 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/>.  */
+
+#ifndef COMMON_GDB_UNIQUE_PTR_H
+#define COMMON_GDB_UNIQUE_PTR_H
+
+#include <memory>
+
+namespace gdb
+{
+/* Define gdb::unique_xmalloc_ptr, a std::unique_ptr that manages
+   xmalloc'ed memory.  */
+
+/* The deleter for std::unique_xmalloc_ptr.  Uses xfree.  */
+template <typename T>
+struct xfree_deleter
+{
+  void operator() (T *ptr) const { xfree (ptr); }
+};
+
+/* Same, for arrays.  */
+template <typename T>
+struct xfree_deleter<T[]>
+{
+  void operator() (T *ptr) const { xfree (ptr); }
+};
+
+/* Import the standard unique_ptr to our namespace with a custom
+   deleter.  */
+
+template<typename T> using unique_xmalloc_ptr
+  = std::unique_ptr<T, xfree_deleter<T>>;
+
+/* A no-op deleter.  */
+template<typename T>
+struct noop_deleter
+{
+  void operator() (T *ptr) const { }
+};
+
+} /* namespace gdb */
+
+/* Dup STR and return a unique_xmalloc_ptr for the result.  */
+
+static inline gdb::unique_xmalloc_ptr<char>
+make_unique_xstrdup (const char *str)
+{
+  return gdb::unique_xmalloc_ptr<char> (xstrdup (str));
+}
+
+#endif /* COMMON_GDB_UNIQUE_PTR_H */
diff --git a/gdb/gdbsupport/gdb_unlinker.h b/gdb/gdbsupport/gdb_unlinker.h
new file mode 100644 (file)
index 0000000..193c2f8
--- /dev/null
@@ -0,0 +1,60 @@
+/* Unlinking class
+
+   Copyright (C) 2016-2019 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/>.  */
+
+#ifndef COMMON_GDB_UNLINKER_H
+#define COMMON_GDB_UNLINKER_H
+
+namespace gdb
+{
+
+/* An object of this class holds a filename and, when the object goes
+   of scope, the file is removed using unlink.
+
+   A user of this class can request that the file be preserved using
+   the "keep" method.  */
+class unlinker
+{
+ public:
+
+  unlinker (const char *filename) ATTRIBUTE_NONNULL (2)
+    : m_filename (filename)
+  {
+    gdb_assert (filename != NULL);
+  }
+
+  ~unlinker ()
+  {
+    if (m_filename != NULL)
+      unlink (m_filename);
+  }
+
+  /* Keep the file, rather than unlink it.  */
+  void keep ()
+  {
+    m_filename = NULL;
+  }
+
+ private:
+
+  const char *m_filename;
+};
+
+}
+
+#endif /* COMMON_GDB_UNLINKER_H */
diff --git a/gdb/gdbsupport/gdb_vecs.c b/gdb/gdbsupport/gdb_vecs.c
new file mode 100644 (file)
index 0000000..38f42f5
--- /dev/null
@@ -0,0 +1,88 @@
+/* Some commonly-used VEC types.
+
+   Copyright (C) 2012-2019 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 "common-defs.h"
+#include "gdb_vecs.h"
+#include "host-defs.h"
+
+/* Worker function to split character delimiter separated string of fields
+   STR into a char pointer vector.  */
+
+static void
+delim_string_to_char_ptr_vec_append
+  (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *str,
+   char delimiter)
+{
+  do
+    {
+      size_t this_len;
+      const char *next_field;
+      char *this_field;
+
+      next_field = strchr (str, delimiter);
+      if (next_field == NULL)
+       this_len = strlen (str);
+      else
+       {
+         this_len = next_field - str;
+         next_field++;
+       }
+
+      this_field = (char *) xmalloc (this_len + 1);
+      memcpy (this_field, str, this_len);
+      this_field[this_len] = '\0';
+      vecp->emplace_back (this_field);
+
+      str = next_field;
+    }
+  while (str != NULL);
+}
+
+/* See gdb_vecs.h.  */
+
+std::vector<gdb::unique_xmalloc_ptr<char>>
+delim_string_to_char_ptr_vec (const char *str, char delimiter)
+{
+  std::vector<gdb::unique_xmalloc_ptr<char>> retval;
+  
+  delim_string_to_char_ptr_vec_append (&retval, str, delimiter);
+
+  return retval;
+}
+
+/* See gdb_vecs.h.  */
+
+void
+dirnames_to_char_ptr_vec_append
+  (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames)
+{
+  delim_string_to_char_ptr_vec_append (vecp, dirnames, DIRNAME_SEPARATOR);
+}
+
+/* See gdb_vecs.h.  */
+
+std::vector<gdb::unique_xmalloc_ptr<char>>
+dirnames_to_char_ptr_vec (const char *dirnames)
+{
+  std::vector<gdb::unique_xmalloc_ptr<char>> retval;
+  
+  dirnames_to_char_ptr_vec_append (&retval, dirnames);
+
+  return retval;
+}
diff --git a/gdb/gdbsupport/gdb_vecs.h b/gdb/gdbsupport/gdb_vecs.h
new file mode 100644 (file)
index 0000000..017bf93
--- /dev/null
@@ -0,0 +1,89 @@
+/* Some commonly-used VEC types.
+
+   Copyright (C) 2012-2019 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/>.  */
+
+#ifndef COMMON_GDB_VECS_H
+#define COMMON_GDB_VECS_H
+
+#include "vec.h"
+
+/* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
+
+   You may modify the returned strings.  */
+
+extern std::vector<gdb::unique_xmalloc_ptr<char>>
+  delim_string_to_char_ptr_vec (const char *str, char delimiter);
+
+/* Like dirnames_to_char_ptr_vec, but append the directories to *VECP.  */
+
+extern void dirnames_to_char_ptr_vec_append
+  (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames);
+
+/* Split DIRNAMES by DIRNAME_SEPARATOR delimiter and return a list of all the
+   elements in their original order.  For empty string ("") DIRNAMES return
+   list of one empty string ("") element.
+
+   You may modify the returned strings.  */
+
+extern std::vector<gdb::unique_xmalloc_ptr<char>>
+  dirnames_to_char_ptr_vec (const char *dirnames);
+
+/* Remove the element pointed by iterator IT from VEC, not preserving the order
+   of the remaining elements.  Return the removed element.  */
+
+template <typename T>
+T
+unordered_remove (std::vector<T> &vec, typename std::vector<T>::iterator it)
+{
+  gdb_assert (it >= vec.begin () && it < vec.end ());
+
+  T removed = std::move (*it);
+  *it = std::move (vec.back ());
+  vec.pop_back ();
+
+  return removed;
+}
+
+/* Remove the element at position IX from VEC, not preserving the order of the
+   remaining elements.  Return the removed element.  */
+
+template <typename T>
+T
+unordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
+{
+  gdb_assert (ix < vec.size ());
+
+  return unordered_remove (vec, vec.begin () + ix);
+}
+
+/* Remove the element at position IX from VEC, preserving the order the
+   remaining elements.  Return the removed element.  */
+
+template <typename T>
+T
+ordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
+{
+  gdb_assert (ix < vec.size ());
+
+  T removed = std::move (vec[ix]);
+  vec.erase (vec.begin () + ix);
+
+  return removed;
+}
+
+#endif /* COMMON_GDB_VECS_H */
diff --git a/gdb/gdbsupport/gdb_wait.h b/gdb/gdbsupport/gdb_wait.h
new file mode 100644 (file)
index 0000000..b3b752c
--- /dev/null
@@ -0,0 +1,113 @@
+/* Standard wait macros.
+   Copyright (C) 2000-2019 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/>.  */
+
+#ifndef COMMON_GDB_WAIT_H
+#define COMMON_GDB_WAIT_H
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h> /* POSIX */
+#else
+#ifdef HAVE_WAIT_H
+#include <wait.h> /* legacy */
+#endif
+#endif
+
+/* Define how to access the int that the wait system call stores.
+   This has been compatible in all Unix systems since time immemorial,
+   but various well-meaning people have defined various different
+   words for the same old bits in the same old int (sometimes claimed
+   to be a struct).  We just know it's an int and we use these macros
+   to access the bits.  */
+
+/* The following macros are defined equivalently to their definitions
+   in POSIX.1.  We fail to define WNOHANG and WUNTRACED, which POSIX.1
+   <sys/wait.h> defines, since our code does not use waitpid() (but
+   NOTE exception for GNU/Linux below).  We also fail to declare
+   wait() and waitpid().  */
+
+#ifndef        WIFEXITED
+#define WIFEXITED(w)   (((w)&0377) == 0)
+#endif
+
+#ifndef        WIFSIGNALED
+#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
+#endif
+
+#ifndef        WIFSTOPPED
+#ifdef IBM6000
+
+/* Unfortunately, the above comment (about being compatible in all Unix 
+   systems) is not quite correct for AIX, sigh.  And AIX 3.2 can generate
+   status words like 0x57c (sigtrap received after load), and gdb would
+   choke on it.  */
+
+#define WIFSTOPPED(w)  ((w)&0x40)
+
+#else
+#define WIFSTOPPED(w)  (((w)&0377) == 0177)
+#endif
+#endif
+
+#ifndef        WEXITSTATUS
+#define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */
+#endif
+
+#ifndef        WTERMSIG
+#define WTERMSIG(w)    ((w) & 0177)
+#endif
+
+#ifndef        WSTOPSIG
+#define WSTOPSIG       WEXITSTATUS
+#endif
+
+/* These are not defined in POSIX, but are used by our programs.  */
+
+#ifndef        WSETEXIT
+# ifdef        W_EXITCODE
+#define        WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
+# else
+#define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
+# endif
+#endif
+
+#ifndef W_STOPCODE
+#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
+#endif
+
+#ifndef        WSETSTOP
+#define        WSETSTOP(w,sig)    ((w) = W_STOPCODE(sig))
+#endif
+
+/* For native GNU/Linux we may use waitpid and the __WCLONE option.
+  <GRIPE> It is of course dangerous not to use the REAL header file...
+  </GRIPE>.  */
+
+/* Bits in the third argument to `waitpid'.  */
+#ifndef WNOHANG
+#define        WNOHANG         1       /* Don't block waiting.  */
+#endif
+
+#ifndef WUNTRACED
+#define        WUNTRACED       2       /* Report status of stopped children.  */
+#endif
+
+#ifndef __WCLONE
+#define __WCLONE       0x80000000 /* Wait for cloned process.  */
+#endif
+
+#endif /* COMMON_GDB_WAIT_H */
diff --git a/gdb/gdbsupport/hash_enum.h b/gdb/gdbsupport/hash_enum.h
new file mode 100644 (file)
index 0000000..4baf01e
--- /dev/null
@@ -0,0 +1,45 @@
+/* A hasher for enums.
+
+   Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_HASH_ENUM_H
+#define COMMON_HASH_ENUM_H
+
+/* A hasher for enums, which was missing in C++11:
+    http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148
+*/
+
+namespace gdb {
+
+/* Helper struct for hashing enum types.  */
+template<typename T>
+struct hash_enum
+{
+  typedef size_t result_type;
+  typedef T argument_type;
+
+  size_t operator() (T val) const noexcept
+  {
+    using underlying = typename std::underlying_type<T>::type;
+    return std::hash<underlying> () (static_cast<underlying> (val));
+  }
+};
+
+} /* namespace gdb */
+
+#endif /* COMMON_HASH_ENUM_H */
diff --git a/gdb/gdbsupport/host-defs.h b/gdb/gdbsupport/host-defs.h
new file mode 100644 (file)
index 0000000..dedd9b6
--- /dev/null
@@ -0,0 +1,61 @@
+/* Basic host-specific definitions for GDB.
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_HOST_DEFS_H
+#define COMMON_HOST_DEFS_H
+
+#include <limits.h>
+
+/* Static host-system-dependent parameters for GDB.  */
+
+/* * Number of bits in a char or unsigned char for the target machine.
+   Just like CHAR_BIT in <limits.h> but describes the target machine.  */
+#if !defined (TARGET_CHAR_BIT)
+#define TARGET_CHAR_BIT 8
+#endif
+
+/* * If we picked up a copy of CHAR_BIT from a configuration file
+   (which may get it by including <limits.h>) then use it to set
+   the number of bits in a host char.  If not, use the same size
+   as the target.  */
+
+#if defined (CHAR_BIT)
+#define HOST_CHAR_BIT CHAR_BIT
+#else
+#define HOST_CHAR_BIT TARGET_CHAR_BIT
+#endif
+
+#ifdef __MSDOS__
+# define CANT_FORK
+# define GLOBAL_CURDIR
+# define DIRNAME_SEPARATOR ';'
+#endif
+
+#if !defined (__CYGWIN__) && defined (_WIN32)
+# define DIRNAME_SEPARATOR ';'
+#endif
+
+#ifndef DIRNAME_SEPARATOR
+#define DIRNAME_SEPARATOR ':'
+#endif
+
+#ifndef SLASH_STRING
+#define SLASH_STRING "/"
+#endif
+
+#endif /* COMMON_HOST_DEFS_H */
diff --git a/gdb/gdbsupport/job-control.c b/gdb/gdbsupport/job-control.c
new file mode 100644 (file)
index 0000000..cd3dde1
--- /dev/null
@@ -0,0 +1,86 @@
+/* Job control and terminal related functions, for GDB and gdbserver
+   when running under Unix.
+
+   Copyright (C) 1986-2019 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 "common-defs.h"
+#include "job-control.h"
+#ifdef HAVE_TERMIOS_H
+#include <termios.h>
+#endif
+#include <unistd.h>
+
+/* Nonzero if we have job control.  */
+int job_control;
+
+/* Set the process group ID of the inferior.
+
+   Just using job_control only does part of it because setpgid or
+   setpgrp might not exist on a system without job control.
+
+   For a more clean implementation, in libiberty, put a setpgid which merely
+   calls setpgrp and a setpgrp which does nothing (any system with job control
+   will have one or the other).  */
+
+int
+gdb_setpgid ()
+{
+  int retval = 0;
+
+  if (job_control)
+    {
+#ifdef HAVE_SETPGID
+      /* The call setpgid (0, 0) is supposed to work and mean the same
+         thing as this, but on Ultrix 4.2A it fails with EPERM (and
+         setpgid (getpid (), getpid ()) succeeds).  */
+      retval = setpgid (getpid (), getpid ());
+#else
+#ifdef HAVE_SETPGRP
+#ifdef SETPGRP_VOID
+      retval = setpgrp ();
+#else
+      retval = setpgrp (getpid (), getpid ());
+#endif
+#endif /* HAVE_SETPGRP */
+#endif /* HAVE_SETPGID */
+    }
+
+  return retval;
+}
+
+/* See gdbsupport/common-terminal.h.  */
+
+void
+have_job_control ()
+{
+  /* OK, figure out whether we have job control.  If termios is not
+     available, leave job_control 0.  */
+#if defined (HAVE_TERMIOS_H)
+  /* Do all systems with termios have the POSIX way of identifying job
+     control?  I hope so.  */
+#ifdef _POSIX_JOB_CONTROL
+  job_control = 1;
+#else
+#ifdef _SC_JOB_CONTROL
+  job_control = sysconf (_SC_JOB_CONTROL);
+#else
+  job_control = 0;             /* Have to assume the worst.  */
+#endif /* _SC_JOB_CONTROL */
+#endif /* _POSIX_JOB_CONTROL */
+#endif /* HAVE_TERMIOS_H */
+}
diff --git a/gdb/gdbsupport/job-control.h b/gdb/gdbsupport/job-control.h
new file mode 100644 (file)
index 0000000..e4660ae
--- /dev/null
@@ -0,0 +1,38 @@
+/* Job control and terminal related functions, for GDB and gdbserver
+   when running under Unix.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_JOB_CONTROL_H
+#define COMMON_JOB_CONTROL_H
+
+/* Do we have job control?  Can be assumed to always be the same
+   within a given run of GDB.  Use in gdb/inflow.c and
+   gdbsupport/common-inflow.c.  */
+extern int job_control;
+
+/* Set the process group of the caller to its own pid, or do nothing
+   if we lack job control.  */
+extern int gdb_setpgid ();
+
+/* Determine whether we have job control, and set variable JOB_CONTROL
+   accordingly.  This function must be called before any use of
+   JOB_CONTROL.  */
+extern void have_job_control ();
+
+#endif /* COMMON_JOB_CONTROL_H */
diff --git a/gdb/gdbsupport/mingw-strerror.c b/gdb/gdbsupport/mingw-strerror.c
new file mode 100644 (file)
index 0000000..6386330
--- /dev/null
@@ -0,0 +1,64 @@
+/* Safe version of strerror for MinGW, for GDB, the GNU debugger.
+
+   Copyright (C) 2006-2019 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 "common-defs.h"
+
+#include <windows.h>
+
+/* Implementation of safe_strerror as defined in common-utils.h.
+
+   The Windows runtime implementation of strerror never returns NULL,
+   but does return a useless string for anything above sys_nerr;
+   unfortunately this includes all socket-related error codes.
+   This replacement tries to find a system-provided error message.  */
+
+char *
+safe_strerror (int errnum)
+{
+  static char *buffer;
+  int len;
+
+  if (errnum >= 0 && errnum < sys_nerr)
+    return strerror (errnum);
+
+  if (buffer)
+    {
+      LocalFree (buffer);
+      buffer = NULL;
+    }
+
+  if (FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
+                    | FORMAT_MESSAGE_FROM_SYSTEM,
+                    NULL, errnum,
+                    MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
+                    (LPTSTR) &buffer, 0, NULL) == 0)
+    {
+      static char buf[32];
+      xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum);
+      return buf;
+    }
+
+  /* Windows error messages end with a period and a CR-LF; strip that
+     out.  */
+  len = strlen (buffer);
+  if (len > 3 && strcmp (buffer + len - 3, ".\r\n") == 0)
+    buffer[len - 3] = '\0';
+
+  return buffer;
+}
diff --git a/gdb/gdbsupport/netstuff.c b/gdb/gdbsupport/netstuff.c
new file mode 100644 (file)
index 0000000..a7dc346
--- /dev/null
@@ -0,0 +1,154 @@
+/* Operations on network stuff.
+   Copyright (C) 2018-2019 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 "common-defs.h"
+#include "netstuff.h"
+#include <algorithm>
+
+#ifdef USE_WIN32API
+#include <ws2tcpip.h>
+#else
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/tcp.h>
+#endif
+
+/* See gdbsupport/netstuff.h.  */
+
+scoped_free_addrinfo::~scoped_free_addrinfo ()
+{
+  freeaddrinfo (m_res);
+}
+
+/* See gdbsupport/netstuff.h.  */
+
+parsed_connection_spec
+parse_connection_spec_without_prefix (std::string spec, struct addrinfo *hint)
+{
+  parsed_connection_spec ret;
+  size_t last_colon_pos = 0;
+  /* We're dealing with IPv6 if:
+
+     - ai_family is AF_INET6, or
+     - ai_family is not AF_INET, and
+       - spec[0] is '[', or
+       - the number of ':' on spec is greater than 1.  */
+  bool is_ipv6 = (hint->ai_family == AF_INET6
+                 || (hint->ai_family != AF_INET
+                     && (spec[0] == '['
+                         || std::count (spec.begin (),
+                                        spec.end (), ':') > 1)));
+
+  if (is_ipv6)
+    {
+      if (spec[0] == '[')
+       {
+         /* IPv6 addresses can be written as '[ADDR]:PORT', and we
+            support this notation.  */
+         size_t close_bracket_pos = spec.find_first_of (']');
+
+         if (close_bracket_pos == std::string::npos)
+           error (_("Missing close bracket in hostname '%s'"),
+                  spec.c_str ());
+
+         hint->ai_family = AF_INET6;
+
+         const char c = spec[close_bracket_pos + 1];
+
+         if (c == '\0')
+           last_colon_pos = std::string::npos;
+         else if (c != ':')
+           error (_("Invalid cruft after close bracket in '%s'"),
+                  spec.c_str ());
+
+         /* Erase both '[' and ']'.  */
+         spec.erase (0, 1);
+         spec.erase (close_bracket_pos - 1, 1);
+       }
+      else if (spec.find_first_of (']') != std::string::npos)
+       error (_("Missing open bracket in hostname '%s'"),
+              spec.c_str ());
+    }
+
+  if (last_colon_pos == 0)
+    last_colon_pos = spec.find_last_of (':');
+
+  /* The length of the hostname part.  */
+  size_t host_len;
+
+  if (last_colon_pos != std::string::npos)
+    {
+      /* The user has provided a port.  */
+      host_len = last_colon_pos;
+      ret.port_str = spec.substr (last_colon_pos + 1);
+    }
+  else
+    host_len = spec.size ();
+
+  ret.host_str = spec.substr (0, host_len);
+
+  /* Default hostname is localhost.  */
+  if (ret.host_str.empty ())
+    ret.host_str = "localhost";
+
+  return ret;
+}
+
+/* See gdbsupport/netstuff.h.  */
+
+parsed_connection_spec
+parse_connection_spec (const char *spec, struct addrinfo *hint)
+{
+  /* Struct to hold the association between valid prefixes, their
+     family and socktype.  */
+  struct host_prefix
+    {
+      /* The prefix.  */
+      const char *prefix;
+
+      /* The 'ai_family'.  */
+      int family;
+
+      /* The 'ai_socktype'.  */
+      int socktype;
+    };
+  static const struct host_prefix prefixes[] =
+    {
+      { "udp:",  AF_UNSPEC, SOCK_DGRAM },
+      { "tcp:",  AF_UNSPEC, SOCK_STREAM },
+      { "udp4:", AF_INET,   SOCK_DGRAM },
+      { "tcp4:", AF_INET,   SOCK_STREAM },
+      { "udp6:", AF_INET6,  SOCK_DGRAM },
+      { "tcp6:", AF_INET6,  SOCK_STREAM },
+    };
+
+  for (const host_prefix prefix : prefixes)
+    if (startswith (spec, prefix.prefix))
+      {
+       spec += strlen (prefix.prefix);
+       hint->ai_family = prefix.family;
+       hint->ai_socktype = prefix.socktype;
+       hint->ai_protocol
+         = hint->ai_socktype == SOCK_DGRAM ? IPPROTO_UDP : IPPROTO_TCP;
+       break;
+      }
+
+  return parse_connection_spec_without_prefix (spec, hint);
+}
diff --git a/gdb/gdbsupport/netstuff.h b/gdb/gdbsupport/netstuff.h
new file mode 100644 (file)
index 0000000..0d39fb5
--- /dev/null
@@ -0,0 +1,76 @@
+/* Operations on network stuff.
+   Copyright (C) 2018-2019 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/>.  */
+
+#ifndef COMMON_NETSTUFF_H
+#define COMMON_NETSTUFF_H
+
+#include <string>
+
+/* Like NI_MAXHOST/NI_MAXSERV, but enough for numeric forms.  */
+#define GDB_NI_MAX_ADDR 64
+#define GDB_NI_MAX_PORT 16
+
+/* Helper class to guarantee that we always call 'freeaddrinfo'.  */
+
+class scoped_free_addrinfo
+{
+public:
+  /* Default constructor.  */
+  explicit scoped_free_addrinfo (struct addrinfo *ainfo)
+    : m_res (ainfo)
+  {
+  }
+
+  /* Destructor responsible for free'ing M_RES by calling
+     'freeaddrinfo'.  */
+  ~scoped_free_addrinfo ();
+
+  DISABLE_COPY_AND_ASSIGN (scoped_free_addrinfo);
+
+private:
+  /* The addrinfo resource.  */
+  struct addrinfo *m_res;
+};
+
+/* The struct we return after parsing the connection spec.  */
+
+struct parsed_connection_spec
+{
+  /* The hostname.  */
+  std::string host_str;
+
+  /* The port, if any.  */
+  std::string port_str;
+};
+
+
+/* Parse SPEC (which is a string in the form of "ADDR:PORT") and
+   return a 'parsed_connection_spec' structure with the proper fields
+   filled in.  Also adjust HINT accordingly.  */
+extern parsed_connection_spec
+  parse_connection_spec_without_prefix (std::string spec,
+                                       struct addrinfo *hint);
+
+/* Parse SPEC (which is a string in the form of
+   "[tcp[6]:|udp[6]:]ADDR:PORT") and return a 'parsed_connection_spec'
+   structure with the proper fields filled in.  Also adjust HINT
+   accordingly.  */
+extern parsed_connection_spec parse_connection_spec (const char *spec,
+                                                    struct addrinfo *hint);
+
+#endif /* COMMON_NETSTUFF_H */
diff --git a/gdb/gdbsupport/new-op.c b/gdb/gdbsupport/new-op.c
new file mode 100644 (file)
index 0000000..7c5dba0
--- /dev/null
@@ -0,0 +1,95 @@
+/* Replace operator new/new[], for GDB, the GNU debugger.
+
+   Copyright (C) 2016-2019 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/>.  */
+
+/* GCC does not understand __has_feature.  */
+#if !defined(__has_feature)
+# define __has_feature(x) 0
+#endif
+
+#if !__has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__)
+#include "common-defs.h"
+#include "host-defs.h"
+#include <new>
+
+/* Override operator new / operator new[], in order to internal_error
+   on allocation failure and thus query the user for abort/core
+   dump/continue, just like xmalloc does.  We don't do this from a
+   new-handler function instead (std::set_new_handler) because we want
+   to catch allocation errors from within global constructors too.
+
+   Skip overriding if building with -fsanitize=address though.
+   Address sanitizer wants to override operator new/delete too in
+   order to detect malloc+delete and new+free mismatches.  Our
+   versions would mask out ASan's, with the result of losing that
+   useful mismatch detection.
+
+   Note that C++ implementations could either have their throw
+   versions call the nothrow versions (libstdc++), or the other way
+   around (clang/libc++).  For that reason, we replace both throw and
+   nothrow variants and call malloc directly.  */
+
+void *
+operator new (std::size_t sz)
+{
+  /* malloc (0) is unpredictable; avoid it.  */
+  if (sz == 0)
+    sz = 1;
+
+  void *p = malloc (sz);       /* ARI: malloc */
+  if (p == NULL)
+    {
+      /* If the user decides to continue debugging, throw a
+        gdb_quit_bad_alloc exception instead of a regular QUIT
+        gdb_exception.  The former extends both std::bad_alloc and a
+        QUIT gdb_exception.  This is necessary because operator new
+        can only ever throw std::bad_alloc, or something that extends
+        it.  */
+      try
+       {
+         malloc_failure (sz);
+       }
+      catch (gdb_exception &ex)
+       {
+         throw gdb_quit_bad_alloc (std::move (ex));
+       }
+    }
+  return p;
+}
+
+void *
+operator new (std::size_t sz, const std::nothrow_t&) noexcept
+{
+  /* malloc (0) is unpredictable; avoid it.  */
+  if (sz == 0)
+    sz = 1;
+  return malloc (sz);          /* ARI: malloc */
+}
+
+void *
+operator new[] (std::size_t sz)
+{
+   return ::operator new (sz);
+}
+
+void*
+operator new[] (std::size_t sz, const std::nothrow_t&) noexcept
+{
+  return ::operator new (sz, std::nothrow);
+}
+#endif
diff --git a/gdb/gdbsupport/next-iterator.h b/gdb/gdbsupport/next-iterator.h
new file mode 100644 (file)
index 0000000..b61b253
--- /dev/null
@@ -0,0 +1,102 @@
+/* A "next" iterator for GDB, the GNU debugger.
+   Copyright (C) 2019 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/>.  */
+
+#ifndef COMMON_NEXT_ITERATOR_H
+#define COMMON_NEXT_ITERATOR_H
+
+/* An iterator that uses the 'next' field of a type to iterate.  This
+   can be used with various GDB types that are stored as linked
+   lists.  */
+
+template<typename T>
+struct next_iterator
+{
+  typedef next_iterator self_type;
+  typedef T *value_type;
+  typedef T *&reference;
+  typedef T **pointer;
+  typedef std::forward_iterator_tag iterator_category;
+  typedef int difference_type;
+
+  explicit next_iterator (T *item)
+    : m_item (item)
+  {
+  }
+
+  /* Create a one-past-the-end iterator.  */
+  next_iterator ()
+    : m_item (nullptr)
+  {
+  }
+
+  value_type operator* () const
+  {
+    return m_item;
+  }
+
+  bool operator== (const self_type &other) const
+  {
+    return m_item == other.m_item;
+  }
+
+  bool operator!= (const self_type &other) const
+  {
+    return m_item != other.m_item;
+  }
+
+  self_type &operator++ ()
+  {
+    m_item = m_item->next;
+    return *this;
+  }
+
+private:
+
+  T *m_item;
+};
+
+/* A range adapter that allows iterating over a linked list.  */
+
+template<typename T, typename Iterator = next_iterator<T>>
+class next_adapter
+{
+public:
+
+  explicit next_adapter (T *item)
+    : m_item (item)
+  {
+  }
+
+  using iterator = Iterator;
+
+  iterator begin () const
+  {
+    return iterator (m_item);
+  }
+
+  iterator end () const
+  {
+    return iterator ();
+  }
+
+private:
+
+  T *m_item;
+};
+
+#endif /* COMMON_NEXT_ITERATOR_H */
diff --git a/gdb/gdbsupport/observable.h b/gdb/gdbsupport/observable.h
new file mode 100644 (file)
index 0000000..205c303
--- /dev/null
@@ -0,0 +1,119 @@
+/* Observers
+
+   Copyright (C) 2016-2019 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/>.  */
+
+#ifndef COMMON_OBSERVABLE_H
+#define COMMON_OBSERVABLE_H
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+
+namespace gdb
+{
+
+namespace observers
+{
+
+extern unsigned int observer_debug;
+
+/* An observer is an entity which is interested in being notified
+   when GDB reaches certain states, or certain events occur in GDB.
+   The entity being observed is called the observable.  To receive
+   notifications, the observer attaches a callback to the observable.
+   One observable can have several observers.
+
+   The observer implementation is also currently not reentrant.  In
+   particular, it is therefore not possible to call the attach or
+   detach routines during a notification.  */
+
+/* The type of a key that can be passed to attach, which can be passed
+   to detach to remove associated observers.  Tokens have address
+   identity, and are thus usually const globals.  */
+struct token
+{
+  token () = default;
+
+  DISABLE_COPY_AND_ASSIGN (token);
+};
+
+template<typename... T>
+class observable
+{
+public:
+
+  typedef std::function<void (T...)> func_type;
+
+  explicit observable (const char *name)
+    : m_name (name)
+  {
+  }
+
+  DISABLE_COPY_AND_ASSIGN (observable);
+
+  /* Attach F as an observer to this observable.  F cannot be
+     detached.  */
+  void attach (const func_type &f)
+  {
+    m_observers.emplace_back (nullptr, f);
+  }
+
+  /* Attach F as an observer to this observable.  T is a reference to
+     a token that can be used to later remove F.  */
+  void attach (const func_type &f, const token &t)
+  {
+    m_observers.emplace_back (&t, f);
+  }
+
+  /* Remove observers associated with T from this observable.  T is
+     the token that was previously passed to any number of "attach"
+     calls.  */
+  void detach (const token &t)
+  {
+    auto iter = std::remove_if (m_observers.begin (),
+                               m_observers.end (),
+                               [&] (const std::pair<const token *,
+                                    func_type> &e)
+                               {
+                                 return e.first == &t;
+                               });
+
+    m_observers.erase (iter, m_observers.end ());
+  }
+
+  /* Notify all observers that are attached to this observable.  */
+  void notify (T... args) const
+  {
+    if (observer_debug)
+      fprintf_unfiltered (gdb_stdlog, "observable %s notify() called\n",
+                         m_name);
+    for (auto &&e : m_observers)
+      e.second (args...);
+  }
+
+private:
+
+  std::vector<std::pair<const token *, func_type>> m_observers;
+  const char *m_name;
+};
+
+} /* namespace observers */
+
+} /* namespace gdb */
+
+#endif /* COMMON_OBSERVABLE_H */
diff --git a/gdb/gdbsupport/offset-type.h b/gdb/gdbsupport/offset-type.h
new file mode 100644 (file)
index 0000000..e1495b2
--- /dev/null
@@ -0,0 +1,133 @@
+/* Offset types for GDB.
+
+   Copyright (C) 2017-2019 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/>.  */
+
+/* Define an "offset" type.  Offset types are distinct integer types
+   that are used to represent an offset into anything that is
+   addressable.  For example, an offset into a DWARF debug section.
+   The idea is catch mixing unrelated offset types at compile time, in
+   code that needs to manipulate multiple different kinds of offsets
+   that are easily confused.  They're safer to use than native
+   integers, because they have no implicit conversion to anything.
+   And also, since they're implemented as "enum class" strong
+   typedefs, they're still integers ABI-wise, making them a bit more
+   efficient than wrapper structs on some ABIs.
+
+   Some properties of offset types, loosely modeled on pointers:
+
+   - You can compare offsets of the same type for equality and order.
+     You can't compare an offset with an unrelated type.
+
+   - You can add/substract an integer to/from an offset, which gives
+     you back a shifted offset.
+
+   - You can subtract two offsets of the same type, which gives you
+     back the delta as an integer (of the enum class's underlying
+     type), not as an offset type.
+
+   - You can't add two offsets of the same type, as that would not
+     make sense.
+
+   However, unlike pointers, you can't deference offset types.  */
+
+#ifndef COMMON_OFFSET_TYPE_H
+#define COMMON_OFFSET_TYPE_H
+
+/* Declare TYPE as being an offset type.  This declares the type and
+   enables the operators defined below.  */
+#define DEFINE_OFFSET_TYPE(TYPE, UNDERLYING)   \
+  enum class TYPE : UNDERLYING {};             \
+  void is_offset_type (TYPE)
+
+/* The macro macro is all you need to know use offset types.  The rest
+   below is all implementation detail.  */
+
+/* For each enum class type that you want to support arithmetic
+   operators, declare an "is_offset_type" overload that has exactly
+   one parameter, of type that enum class.  E.g.,:
+
+     void is_offset_type (sect_offset);
+
+   The function does not need to be defined, only declared.
+   DEFINE_OFFSET_TYPE declares this.
+
+   A function declaration is preferred over a traits type, because the
+   former allows calling the DEFINE_OFFSET_TYPE macro inside a
+   namespace to define the corresponding offset type in that
+   namespace.  The compiler finds the corresponding is_offset_type
+   function via ADL.
+*/
+
+/* Adding or subtracting an integer to an offset type shifts the
+   offset.  This is like "PTR = PTR + INT" and "PTR += INT".  */
+
+#define DEFINE_OFFSET_ARITHM_OP(OP)                                    \
+  template<typename E,                                                 \
+          typename = decltype (is_offset_type (std::declval<E> ()))>   \
+  constexpr E                                                          \
+  operator OP (E lhs, typename std::underlying_type<E>::type rhs)      \
+  {                                                                    \
+    using underlying = typename std::underlying_type<E>::type;         \
+    return (E) (static_cast<underlying> (lhs) OP rhs);                 \
+  }                                                                    \
+                                                                       \
+  template<typename E,                                                 \
+          typename = decltype (is_offset_type (std::declval<E> ()))>   \
+  constexpr E                                                          \
+  operator OP (typename std::underlying_type<E>::type lhs, E rhs)      \
+  {                                                                    \
+    using underlying = typename std::underlying_type<E>::type;         \
+    return (E) (lhs OP static_cast<underlying> (rhs));                 \
+  }                                                                    \
+                                                                       \
+  template<typename E,                                                 \
+          typename = decltype (is_offset_type (std::declval<E> ()))>   \
+  E &                                                                  \
+  operator OP ## = (E &lhs, typename std::underlying_type<E>::type rhs)        \
+  {                                                                    \
+    using underlying = typename std::underlying_type<E>::type;         \
+    lhs = (E) (static_cast<underlying> (lhs) OP rhs);                  \
+    return lhs;                                                                \
+  }
+
+DEFINE_OFFSET_ARITHM_OP(+)
+DEFINE_OFFSET_ARITHM_OP(-)
+
+/* Adding two offset types doesn't make sense, just like "PTR + PTR"
+   doesn't make sense.  This is defined as a deleted function so that
+   a compile error easily brings you to this comment.  */
+
+template<typename E,
+        typename = decltype (is_offset_type (std::declval<E> ()))>
+constexpr typename std::underlying_type<E>::type
+operator+ (E lhs, E rhs) = delete;
+
+/* Subtracting two offset types, however, gives you back the
+   difference between the offsets, as an underlying type.  Similar to
+   how "PTR2 - PTR1" returns a ptrdiff_t.  */
+
+template<typename E,
+        typename = decltype (is_offset_type (std::declval<E> ()))>
+constexpr typename std::underlying_type<E>::type
+operator- (E lhs, E rhs)
+{
+  using underlying = typename std::underlying_type<E>::type;
+  return static_cast<underlying> (lhs) - static_cast<underlying> (rhs);
+}
+
+#endif /* COMMON_OFFSET_TYPE_H */
diff --git a/gdb/gdbsupport/pathstuff.c b/gdb/gdbsupport/pathstuff.c
new file mode 100644 (file)
index 0000000..fafecd5
--- /dev/null
@@ -0,0 +1,290 @@
+/* Path manipulation routines for GDB and gdbserver.
+
+   Copyright (C) 1986-2019 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 "common-defs.h"
+#include "pathstuff.h"
+#include "host-defs.h"
+#include "filenames.h"
+#include "gdb_tilde_expand.h"
+
+#ifdef USE_WIN32API
+#include <windows.h>
+#endif
+
+/* See gdbsupport/pathstuff.h.  */
+
+gdb::unique_xmalloc_ptr<char>
+gdb_realpath (const char *filename)
+{
+/* On most hosts, we rely on canonicalize_file_name to compute
+   the FILENAME's realpath.
+
+   But the situation is slightly more complex on Windows, due to some
+   versions of GCC which were reported to generate paths where
+   backlashes (the directory separator) were doubled.  For instance:
+      c:\\some\\double\\slashes\\dir
+   ... instead of ...
+      c:\some\double\slashes\dir
+   Those double-slashes were getting in the way when comparing paths,
+   for instance when trying to insert a breakpoint as follow:
+      (gdb) b c:/some/double/slashes/dir/foo.c:4
+      No source file named c:/some/double/slashes/dir/foo.c:4.
+      (gdb) b c:\some\double\slashes\dir\foo.c:4
+      No source file named c:\some\double\slashes\dir\foo.c:4.
+   To prevent this from happening, we need this function to always
+   strip those extra backslashes.  While canonicalize_file_name does
+   perform this simplification, it only works when the path is valid.
+   Since the simplification would be useful even if the path is not
+   valid (one can always set a breakpoint on a file, even if the file
+   does not exist locally), we rely instead on GetFullPathName to
+   perform the canonicalization.  */
+
+#if defined (_WIN32)
+  {
+    char buf[MAX_PATH];
+    DWORD len = GetFullPathName (filename, MAX_PATH, buf, NULL);
+
+    /* The file system is case-insensitive but case-preserving.
+       So it is important we do not lowercase the path.  Otherwise,
+       we might not be able to display the original casing in a given
+       path.  */
+    if (len > 0 && len < MAX_PATH)
+      return make_unique_xstrdup (buf);
+  }
+#else
+  {
+    char *rp = canonicalize_file_name (filename);
+
+    if (rp != NULL)
+      return gdb::unique_xmalloc_ptr<char> (rp);
+  }
+#endif
+
+  /* This system is a lost cause, just dup the buffer.  */
+  return make_unique_xstrdup (filename);
+}
+
+/* See gdbsupport/pathstuff.h.  */
+
+gdb::unique_xmalloc_ptr<char>
+gdb_realpath_keepfile (const char *filename)
+{
+  const char *base_name = lbasename (filename);
+  char *dir_name;
+  char *result;
+
+  /* Extract the basename of filename, and return immediately
+     a copy of filename if it does not contain any directory prefix.  */
+  if (base_name == filename)
+    return make_unique_xstrdup (filename);
+
+  dir_name = (char *) alloca ((size_t) (base_name - filename + 2));
+  /* Allocate enough space to store the dir_name + plus one extra
+     character sometimes needed under Windows (see below), and
+     then the closing \000 character.  */
+  strncpy (dir_name, filename, base_name - filename);
+  dir_name[base_name - filename] = '\000';
+
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  /* We need to be careful when filename is of the form 'd:foo', which
+     is equivalent of d:./foo, which is totally different from d:/foo.  */
+  if (strlen (dir_name) == 2 && isalpha (dir_name[0]) && dir_name[1] == ':')
+    {
+      dir_name[2] = '.';
+      dir_name[3] = '\000';
+    }
+#endif
+
+  /* Canonicalize the directory prefix, and build the resulting
+     filename.  If the dirname realpath already contains an ending
+     directory separator, avoid doubling it.  */
+  gdb::unique_xmalloc_ptr<char> path_storage = gdb_realpath (dir_name);
+  const char *real_path = path_storage.get ();
+  if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1]))
+    result = concat (real_path, base_name, (char *) NULL);
+  else
+    result = concat (real_path, SLASH_STRING, base_name, (char *) NULL);
+
+  return gdb::unique_xmalloc_ptr<char> (result);
+}
+
+/* See gdbsupport/pathstuff.h.  */
+
+gdb::unique_xmalloc_ptr<char>
+gdb_abspath (const char *path)
+{
+  gdb_assert (path != NULL && path[0] != '\0');
+
+  if (path[0] == '~')
+    return gdb_tilde_expand_up (path);
+
+  if (IS_ABSOLUTE_PATH (path))
+    return make_unique_xstrdup (path);
+
+  /* Beware the // my son, the Emacs barfs, the botch that catch...  */
+  return gdb::unique_xmalloc_ptr<char>
+    (concat (current_directory,
+            IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
+            ? "" : SLASH_STRING,
+            path, (char *) NULL));
+}
+
+/* See gdbsupport/pathstuff.h.  */
+
+const char *
+child_path (const char *parent, const char *child)
+{
+  /* The child path must start with the parent path.  */
+  size_t parent_len = strlen (parent);
+  if (filename_ncmp (parent, child, parent_len) != 0)
+    return NULL;
+
+  /* The parent path must be a directory and the child must contain at
+     least one component underneath the parent.  */
+  const char *child_component;
+  if (parent_len > 0 && IS_DIR_SEPARATOR (parent[parent_len - 1]))
+    {
+      /* The parent path ends in a directory separator, so it is a
+        directory.  The first child component starts after the common
+        prefix.  */
+      child_component = child + parent_len;
+    }
+  else
+    {
+      /* The parent path does not end in a directory separator.  The
+        first character in the child after the common prefix must be
+        a directory separator.
+
+        Note that CHILD must hold at least parent_len characters for
+        filename_ncmp to return zero.  If the character at parent_len
+        is nul due to CHILD containing the same path as PARENT, the
+        IS_DIR_SEPARATOR check will fail here.  */
+      if (!IS_DIR_SEPARATOR (child[parent_len]))
+       return NULL;
+
+      /* The first child component starts after the separator after the
+        common prefix.  */
+      child_component = child + parent_len + 1;
+    }
+
+  /* The child must contain at least one non-separator character after
+     the parent.  */
+  while (*child_component != '\0')
+    {
+      if (!IS_DIR_SEPARATOR (*child_component))
+       return child_component;
+
+      child_component++;
+    }
+  return NULL;
+}
+
+/* See gdbsupport/pathstuff.h.  */
+
+bool
+contains_dir_separator (const char *path)
+{
+  for (; *path != '\0'; path++)
+    {
+      if (IS_DIR_SEPARATOR (*path))
+       return true;
+    }
+
+  return false;
+}
+
+/* See gdbsupport/pathstuff.h.  */
+
+std::string
+get_standard_cache_dir ()
+{
+#ifdef __APPLE__
+#define HOME_CACHE_DIR "Library/Caches"
+#else
+#define HOME_CACHE_DIR ".cache"
+#endif
+
+#ifndef __APPLE__
+  const char *xdg_cache_home = getenv ("XDG_CACHE_HOME");
+  if (xdg_cache_home != NULL)
+    {
+      /* Make sure the path is absolute and tilde-expanded.  */
+      gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (xdg_cache_home));
+      return string_printf ("%s/gdb", abs.get ());
+    }
+#endif
+
+  const char *home = getenv ("HOME");
+  if (home != NULL)
+    {
+      /* Make sure the path is absolute and tilde-expanded.  */
+      gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (home));
+      return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.get ());
+    }
+
+  return {};
+}
+
+/* See gdbsupport/pathstuff.h.  */
+
+std::string
+get_standard_temp_dir ()
+{
+#ifdef WIN32
+  const char *tmp = getenv ("TMP");
+  if (tmp != nullptr)
+    return tmp;
+
+  tmp = getenv ("TEMP");
+  if (tmp != nullptr)
+    return tmp;
+
+  error (_("Couldn't find temp dir path, both TMP and TEMP are unset."));
+
+#else
+  const char *tmp = getenv ("TMPDIR");
+  if (tmp != nullptr)
+    return tmp;
+
+  return "/tmp";
+#endif
+}
+
+/* See gdbsupport/pathstuff.h.  */
+
+const char *
+get_shell ()
+{
+  const char *ret = getenv ("SHELL");
+  if (ret == NULL)
+    ret = "/bin/sh";
+
+  return ret;
+}
+
+/* See gdbsupport/pathstuff.h.  */
+
+gdb::char_vector
+make_temp_filename (const std::string &f)
+{
+  gdb::char_vector filename_temp (f.length () + 8);
+  strcpy (filename_temp.data (), f.c_str ());
+  strcat (filename_temp.data () + f.size (), "-XXXXXX");
+  return filename_temp;
+}
diff --git a/gdb/gdbsupport/pathstuff.h b/gdb/gdbsupport/pathstuff.h
new file mode 100644 (file)
index 0000000..7d7c8cd
--- /dev/null
@@ -0,0 +1,95 @@
+/* Path manipulation routines for GDB and gdbserver.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_PATHSTUFF_H
+#define COMMON_PATHSTUFF_H
+
+#include "gdbsupport/byte-vector.h"
+
+/* Path utilities.  */
+
+/* Return the real path of FILENAME, expanding all the symbolic links.
+
+   Contrary to "gdb_abspath", this function does not use
+   CURRENT_DIRECTORY for path expansion.  Instead, it relies on the
+   current working directory (CWD) of GDB or gdbserver.  */
+
+extern gdb::unique_xmalloc_ptr<char> gdb_realpath (const char *filename);
+
+/* Return a copy of FILENAME, with its directory prefix canonicalized
+   by gdb_realpath.  */
+
+extern gdb::unique_xmalloc_ptr<char>
+  gdb_realpath_keepfile (const char *filename);
+
+/* Return PATH in absolute form, performing tilde-expansion if necessary.
+   PATH cannot be NULL or the empty string.
+   This does not resolve symlinks however, use gdb_realpath for that.
+
+   Contrary to "gdb_realpath", this function uses CURRENT_DIRECTORY
+   for the path expansion.  This may lead to scenarios the current
+   working directory (CWD) is different than CURRENT_DIRECTORY.  */
+
+extern gdb::unique_xmalloc_ptr<char> gdb_abspath (const char *path);
+
+/* If the path in CHILD is a child of the path in PARENT, return a
+   pointer to the first component in the CHILD's pathname below the
+   PARENT.  Otherwise, return NULL.  */
+
+extern const char *child_path (const char *parent, const char *child);
+
+/* Return whether PATH contains a directory separator character.  */
+
+extern bool contains_dir_separator (const char *path);
+
+/* Get the usual user cache directory for the current platform.
+
+   On Linux, it follows the XDG Base Directory specification: use
+   $XDG_CACHE_HOME/gdb if the XDG_CACHE_HOME environment variable is
+   defined, otherwise $HOME/.cache.
+
+   On macOS, it follows the local convention and uses
+   ~/Library/Caches/gdb.
+
+  The return value is absolute and tilde-expanded.  Return an empty
+  string if neither XDG_CACHE_HOME (on Linux) or HOME are defined.  */
+
+extern std::string get_standard_cache_dir ();
+
+/* Get the usual temporary directory for the current platform.
+
+   On Windows, this is the TMP or TEMP environment variable.
+
+   On the rest, this is the TMPDIR environment variable, if defined, else /tmp.
+
+   Throw an exception on error.  */
+
+extern std::string get_standard_temp_dir ();
+
+/* Return the file name of the user's shell.  Normally this comes from
+   the SHELL environment variable.  */
+
+extern const char *get_shell ();
+
+/* Make a filename suitable to pass to mkstemp based on F (e.g.
+   /tmp/foo -> /tmp/foo-XXXXXX).  */
+
+extern gdb::char_vector make_temp_filename (const std::string &f);
+
+#endif /* COMMON_PATHSTUFF_H */
diff --git a/gdb/gdbsupport/poison.h b/gdb/gdbsupport/poison.h
new file mode 100644 (file)
index 0000000..699de51
--- /dev/null
@@ -0,0 +1,248 @@
+/* Poison symbols at compile time.
+
+   Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_POISON_H
+#define COMMON_POISON_H
+
+#include "traits.h"
+#include "obstack.h"
+
+/* Poison memset of non-POD types.  The idea is catching invalid
+   initialization of non-POD structs that is easy to be introduced as
+   side effect of refactoring.  For example, say this:
+
+ struct S { VEC(foo_s) *m_data; };
+
+is converted to this at some point:
+
+ struct S {
+   S() { m_data.reserve (10); }
+   std::vector<foo> m_data;
+ };
+
+and old code was initializing S objects like this:
+
+ struct S s;
+ memset (&s, 0, sizeof (S)); // whoops, now wipes vector.
+
+Declaring memset as deleted for non-POD types makes the memset above
+be a compile-time error.  */
+
+/* Helper for SFINAE.  True if "T *" is memsettable.  I.e., if T is
+   either void, or POD.  */
+template<typename T>
+struct IsMemsettable
+  : gdb::Or<std::is_void<T>,
+           std::is_pod<T>>
+{};
+
+template <typename T,
+         typename = gdb::Requires<gdb::Not<IsMemsettable<T>>>>
+void *memset (T *s, int c, size_t n) = delete;
+
+#if HAVE_IS_TRIVIALLY_COPYABLE
+
+/* Similarly, poison memcpy and memmove of non trivially-copyable
+   types, which is undefined.  */
+
+/* True if "T *" is relocatable.  I.e., copyable with memcpy/memmove.
+   I.e., T is either trivially copyable, or void.  */
+template<typename T>
+struct IsRelocatable
+  : gdb::Or<std::is_void<T>,
+           std::is_trivially_copyable<T>>
+{};
+
+/* True if both source and destination are relocatable.  */
+
+template <typename D, typename S>
+using BothAreRelocatable
+  = gdb::And<IsRelocatable<D>, IsRelocatable<S>>;
+
+template <typename D, typename S,
+         typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
+void *memcpy (D *dest, const S *src, size_t n) = delete;
+
+template <typename D, typename S,
+         typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
+void *memmove (D *dest, const S *src, size_t n) = delete;
+
+#endif /* HAVE_IS_TRIVIALLY_COPYABLE */
+
+/* Poison XNEW and friends to catch usages of malloc-style allocations on
+   objects that require new/delete.  */
+
+template<typename T>
+#if HAVE_IS_TRIVIALLY_CONSTRUCTIBLE
+using IsMallocable = std::is_trivially_constructible<T>;
+#else
+using IsMallocable = std::true_type;
+#endif
+
+template<typename T>
+using IsFreeable = gdb::Or<std::is_trivially_destructible<T>, std::is_void<T>>;
+
+template <typename T, typename = gdb::Requires<gdb::Not<IsFreeable<T>>>>
+void free (T *ptr) = delete;
+
+template<typename T>
+static T *
+xnew ()
+{
+  static_assert (IsMallocable<T>::value, "Trying to use XNEW with a non-POD \
+data type.  Use operator new instead.");
+  return XNEW (T);
+}
+
+#undef XNEW
+#define XNEW(T) xnew<T>()
+
+template<typename T>
+static T *
+xcnew ()
+{
+  static_assert (IsMallocable<T>::value, "Trying to use XCNEW with a non-POD \
+data type.  Use operator new instead.");
+  return XCNEW (T);
+}
+
+#undef XCNEW
+#define XCNEW(T) xcnew<T>()
+
+template<typename T>
+static void
+xdelete (T *p)
+{
+  static_assert (IsFreeable<T>::value, "Trying to use XDELETE with a non-POD \
+data type.  Use operator delete instead.");
+  XDELETE (p);
+}
+
+#undef XDELETE
+#define XDELETE(P) xdelete (P)
+
+template<typename T>
+static T *
+xnewvec (size_t n)
+{
+  static_assert (IsMallocable<T>::value, "Trying to use XNEWVEC with a \
+non-POD data type.  Use operator new[] (or std::vector) instead.");
+  return XNEWVEC (T, n);
+}
+
+#undef XNEWVEC
+#define XNEWVEC(T, N) xnewvec<T> (N)
+
+template<typename T>
+static T *
+xcnewvec (size_t n)
+{
+  static_assert (IsMallocable<T>::value, "Trying to use XCNEWVEC with a \
+non-POD data type.  Use operator new[] (or std::vector) instead.");
+  return XCNEWVEC (T, n);
+}
+
+#undef XCNEWVEC
+#define XCNEWVEC(T, N) xcnewvec<T> (N)
+
+template<typename T>
+static T *
+xresizevec (T *p, size_t n)
+{
+  static_assert (IsMallocable<T>::value, "Trying to use XRESIZEVEC with a \
+non-POD data type.");
+  return XRESIZEVEC (T, p, n);
+}
+
+#undef XRESIZEVEC
+#define XRESIZEVEC(T, P, N) xresizevec<T> (P, N)
+
+template<typename T>
+static void
+xdeletevec (T *p)
+{
+  static_assert (IsFreeable<T>::value, "Trying to use XDELETEVEC with a \
+non-POD data type.  Use operator delete[] (or std::vector) instead.");
+  XDELETEVEC (p);
+}
+
+#undef XDELETEVEC
+#define XDELETEVEC(P) xdeletevec (P)
+
+template<typename T>
+static T *
+xnewvar (size_t s)
+{
+  static_assert (IsMallocable<T>::value, "Trying to use XNEWVAR with a \
+non-POD data type.");
+  return XNEWVAR (T, s);;
+}
+
+#undef XNEWVAR
+#define XNEWVAR(T, S) xnewvar<T> (S)
+
+template<typename T>
+static T *
+xcnewvar (size_t s)
+{
+  static_assert (IsMallocable<T>::value, "Trying to use XCNEWVAR with a \
+non-POD data type.");
+  return XCNEWVAR (T, s);
+}
+
+#undef XCNEWVAR
+#define XCNEWVAR(T, S) xcnewvar<T> (S)
+
+template<typename T>
+static T *
+xresizevar (T *p, size_t s)
+{
+  static_assert (IsMallocable<T>::value, "Trying to use XRESIZEVAR with a \
+non-POD data type.");
+  return XRESIZEVAR (T, p, s);
+}
+
+#undef XRESIZEVAR
+#define XRESIZEVAR(T, P, S) xresizevar<T> (P, S)
+
+template<typename T>
+static T *
+xobnew (obstack *ob)
+{
+  static_assert (IsMallocable<T>::value, "Trying to use XOBNEW with a \
+non-POD data type.");
+  return XOBNEW (ob, T);
+}
+
+#undef XOBNEW
+#define XOBNEW(O, T) xobnew<T> (O)
+
+template<typename T>
+static T *
+xobnewvec (obstack *ob, size_t n)
+{
+  static_assert (IsMallocable<T>::value, "Trying to use XOBNEWVEC with a \
+non-POD data type.");
+  return XOBNEWVEC (ob, T, n);
+}
+
+#undef XOBNEWVEC
+#define XOBNEWVEC(O, T, N) xobnewvec<T> (O, N)
+
+#endif /* COMMON_POISON_H */
diff --git a/gdb/gdbsupport/posix-strerror.c b/gdb/gdbsupport/posix-strerror.c
new file mode 100644 (file)
index 0000000..a8651b7
--- /dev/null
@@ -0,0 +1,38 @@
+/* Safe version of strerror for POSIX systems for GDB, the GNU debugger.
+
+   Copyright (C) 2006-2019 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 "common-defs.h"
+
+/* Implementation of safe_strerror as defined in common-utils.h.  */
+
+char *
+safe_strerror (int errnum)
+{
+  char *msg;
+
+  msg = strerror (errnum);
+  if (msg == NULL)
+    {
+      static char buf[32];
+
+      xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum);
+      msg = buf;
+    }
+  return (msg);
+}
diff --git a/gdb/gdbsupport/preprocessor.h b/gdb/gdbsupport/preprocessor.h
new file mode 100644 (file)
index 0000000..cb735c3
--- /dev/null
@@ -0,0 +1,35 @@
+/* Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_PREPROCESSOR_H
+#define COMMON_PREPROCESSOR_H
+
+/* Generally useful preprocessor bits.  */
+
+/* Concatenate two tokens.  */
+#define CONCAT_1(a, b) a ## b
+#define CONCAT(a, b) CONCAT_1 (a, b)
+
+/* Stringification.  */
+#define STRINGIFY_1(x) #x
+#define STRINGIFY(x) STRINGIFY_1 (x)
+
+/* Escape parens out.  Useful if you need to pass an argument that
+   includes commas to another macro.  */
+#define ESC_PARENS(...) __VA_ARGS__
+
+#endif /* COMMON_PREPROCESSOR_H */
diff --git a/gdb/gdbsupport/print-utils.c b/gdb/gdbsupport/print-utils.c
new file mode 100644 (file)
index 0000000..051c454
--- /dev/null
@@ -0,0 +1,326 @@
+/* Cell-based print utility routines for GDB, the GNU debugger.
+
+   Copyright (C) 1986-2019 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 "common-defs.h"
+#include "print-utils.h"
+/* Temporary storage using circular buffer.  */
+
+/* Number of cells in the circular buffer.  */
+#define NUMCELLS 16
+
+/* Return the next entry in the circular buffer.  */
+
+char *
+get_print_cell (void)
+{
+  static char buf[NUMCELLS][PRINT_CELL_SIZE];
+  static int cell = 0;
+
+  if (++cell >= NUMCELLS)
+    cell = 0;
+  return buf[cell];
+}
+
+static char *
+decimal2str (const char *sign, ULONGEST addr, int width)
+{
+  /* Steal code from valprint.c:print_decimal().  Should this worry
+     about the real size of addr as the above does?  */
+  unsigned long temp[3];
+  char *str = get_print_cell ();
+  int i = 0;
+
+  do
+    {
+      temp[i] = addr % (1000 * 1000 * 1000);
+      addr /= (1000 * 1000 * 1000);
+      i++;
+      width -= 9;
+    }
+  while (addr != 0 && i < (sizeof (temp) / sizeof (temp[0])));
+
+  width += 9;
+  if (width < 0)
+    width = 0;
+
+  switch (i)
+    {
+    case 1:
+      xsnprintf (str, PRINT_CELL_SIZE, "%s%0*lu", sign, width, temp[0]);
+      break;
+    case 2:
+      xsnprintf (str, PRINT_CELL_SIZE, "%s%0*lu%09lu", sign, width,
+                temp[1], temp[0]);
+      break;
+    case 3:
+      xsnprintf (str, PRINT_CELL_SIZE, "%s%0*lu%09lu%09lu", sign, width,
+                temp[2], temp[1], temp[0]);
+      break;
+    default:
+      internal_error (__FILE__, __LINE__,
+                     _("failed internal consistency check"));
+    }
+
+  return str;
+}
+
+static char *
+octal2str (ULONGEST addr, int width)
+{
+  unsigned long temp[3];
+  char *str = get_print_cell ();
+  int i = 0;
+
+  do
+    {
+      temp[i] = addr % (0100000 * 0100000);
+      addr /= (0100000 * 0100000);
+      i++;
+      width -= 10;
+    }
+  while (addr != 0 && i < (sizeof (temp) / sizeof (temp[0])));
+
+  width += 10;
+  if (width < 0)
+    width = 0;
+
+  switch (i)
+    {
+    case 1:
+      if (temp[0] == 0)
+       xsnprintf (str, PRINT_CELL_SIZE, "%*o", width, 0);
+      else
+       xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo", width, temp[0]);
+      break;
+    case 2:
+      xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo%010lo", width, temp[1], temp[0]);
+      break;
+    case 3:
+      xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo%010lo%010lo", width,
+                temp[2], temp[1], temp[0]);
+      break;
+    default:
+      internal_error (__FILE__, __LINE__,
+                     _("failed internal consistency check"));
+    }
+
+  return str;
+}
+
+/* See print-utils.h.  */
+
+char *
+pulongest (ULONGEST u)
+{
+  return decimal2str ("", u, 0);
+}
+
+/* See print-utils.h.  */
+
+char *
+plongest (LONGEST l)
+{
+  if (l < 0)
+    return decimal2str ("-", -l, 0);
+  else
+    return decimal2str ("", l, 0);
+}
+
+/* Eliminate warning from compiler on 32-bit systems.  */
+static int thirty_two = 32;
+
+/* See print-utils.h.  */
+
+char *
+phex (ULONGEST l, int sizeof_l)
+{
+  char *str;
+
+  switch (sizeof_l)
+    {
+    case 8:
+      str = get_print_cell ();
+      xsnprintf (str, PRINT_CELL_SIZE, "%08lx%08lx",
+                (unsigned long) (l >> thirty_two),
+                (unsigned long) (l & 0xffffffff));
+      break;
+    case 4:
+      str = get_print_cell ();
+      xsnprintf (str, PRINT_CELL_SIZE, "%08lx", (unsigned long) l);
+      break;
+    case 2:
+      str = get_print_cell ();
+      xsnprintf (str, PRINT_CELL_SIZE, "%04x", (unsigned short) (l & 0xffff));
+      break;
+    default:
+      str = phex (l, sizeof (l));
+      break;
+    }
+
+  return str;
+}
+
+/* See print-utils.h.  */
+
+char *
+phex_nz (ULONGEST l, int sizeof_l)
+{
+  char *str;
+
+  switch (sizeof_l)
+    {
+    case 8:
+      {
+       unsigned long high = (unsigned long) (l >> thirty_two);
+
+       str = get_print_cell ();
+       if (high == 0)
+         xsnprintf (str, PRINT_CELL_SIZE, "%lx",
+                    (unsigned long) (l & 0xffffffff));
+       else
+         xsnprintf (str, PRINT_CELL_SIZE, "%lx%08lx", high,
+                    (unsigned long) (l & 0xffffffff));
+       break;
+      }
+    case 4:
+      str = get_print_cell ();
+      xsnprintf (str, PRINT_CELL_SIZE, "%lx", (unsigned long) l);
+      break;
+    case 2:
+      str = get_print_cell ();
+      xsnprintf (str, PRINT_CELL_SIZE, "%x", (unsigned short) (l & 0xffff));
+      break;
+    default:
+      str = phex_nz (l, sizeof (l));
+      break;
+    }
+
+  return str;
+}
+
+/* See print-utils.h.  */
+
+char *
+hex_string (LONGEST num)
+{
+  char *result = get_print_cell ();
+
+  xsnprintf (result, PRINT_CELL_SIZE, "0x%s", phex_nz (num, sizeof (num)));
+  return result;
+}
+
+/* See print-utils.h.  */
+
+char *
+hex_string_custom (LONGEST num, int width)
+{
+  char *result = get_print_cell ();
+  char *result_end = result + PRINT_CELL_SIZE - 1;
+  const char *hex = phex_nz (num, sizeof (num));
+  int hex_len = strlen (hex);
+
+  if (hex_len > width)
+    width = hex_len;
+  if (width + 2 >= PRINT_CELL_SIZE)
+    internal_error (__FILE__, __LINE__, _("\
+hex_string_custom: insufficient space to store result"));
+
+  strcpy (result_end - width - 2, "0x");
+  memset (result_end - width, '0', width);
+  strcpy (result_end - hex_len, hex);
+  return result_end - width - 2;
+}
+
+/* See print-utils.h.  */
+
+char *
+int_string (LONGEST val, int radix, int is_signed, int width,
+           int use_c_format)
+{
+  switch (radix)
+    {
+    case 16:
+      {
+       char *result;
+
+       if (width == 0)
+         result = hex_string (val);
+       else
+         result = hex_string_custom (val, width);
+       if (! use_c_format)
+         result += 2;
+       return result;
+      }
+    case 10:
+      {
+       if (is_signed && val < 0)
+         return decimal2str ("-", -val, width);
+       else
+         return decimal2str ("", val, width);
+      }
+    case 8:
+      {
+       char *result = octal2str (val, width);
+
+       if (use_c_format || val == 0)
+         return result;
+       else
+         return result + 1;
+      }
+    default:
+      internal_error (__FILE__, __LINE__,
+                     _("failed internal consistency check"));
+    }
+}
+
+/* See print-utils.h.  */
+
+const char *
+core_addr_to_string (const CORE_ADDR addr)
+{
+  char *str = get_print_cell ();
+
+  strcpy (str, "0x");
+  strcat (str, phex (addr, sizeof (addr)));
+  return str;
+}
+
+/* See print-utils.h.  */
+
+const char *
+core_addr_to_string_nz (const CORE_ADDR addr)
+{
+  char *str = get_print_cell ();
+
+  strcpy (str, "0x");
+  strcat (str, phex_nz (addr, sizeof (addr)));
+  return str;
+}
+
+/* See print-utils.h.  */
+
+const char *
+host_address_to_string_1 (const void *addr)
+{
+  char *str = get_print_cell ();
+
+  xsnprintf (str, PRINT_CELL_SIZE, "0x%s",
+            phex_nz ((uintptr_t) addr, sizeof (addr)));
+  return str;
+}
diff --git a/gdb/gdbsupport/print-utils.h b/gdb/gdbsupport/print-utils.h
new file mode 100644 (file)
index 0000000..815b14c
--- /dev/null
@@ -0,0 +1,82 @@
+/* Cell-based print utility routines for GDB, the GNU debugger.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_PRINT_UTILS_H
+#define COMMON_PRINT_UTILS_H
+
+/* How many characters (including the terminating null byte) fit in a
+   cell.  */
+#define PRINT_CELL_SIZE 50
+
+/* %d for LONGEST.  The result is stored in a circular static buffer,
+   NUMCELLS deep.  */
+
+extern char *pulongest (ULONGEST u);
+
+/* %u for ULONGEST.  The result is stored in a circular static buffer,
+   NUMCELLS deep.  */
+
+extern char *plongest (LONGEST l);
+
+extern char *phex (ULONGEST l, int sizeof_l);
+
+/* Convert a ULONGEST into a HEX string, like %lx.  The result is
+   stored in a circular static buffer, NUMCELLS deep.  */
+
+extern char *phex_nz (ULONGEST l, int sizeof_l);
+
+/* Converts a LONGEST to a C-format hexadecimal literal and stores it
+   in a static string.  Returns a pointer to this string.  */
+
+extern char *hex_string (LONGEST num);
+
+/* Converts a LONGEST number to a C-format hexadecimal literal and
+   stores it in a static string.  Returns a pointer to this string
+   that is valid until the next call.  The number is padded on the
+   left with 0s to at least WIDTH characters.  */
+
+extern char *hex_string_custom (LONGEST num, int width);
+
+/* Convert VAL to a numeral in the given radix.  For
+ * radix 10, IS_SIGNED may be true, indicating a signed quantity;
+ * otherwise VAL is interpreted as unsigned.  If WIDTH is supplied, 
+ * it is the minimum width (0-padded if needed).  USE_C_FORMAT means
+ * to use C format in all cases.  If it is false, then 'x' 
+ * and 'o' formats do not include a prefix (0x or leading 0).  */
+
+extern char *int_string (LONGEST val, int radix, int is_signed, int width, 
+                        int use_c_format);     
+
+/* Convert a CORE_ADDR into a string.  */
+
+extern const char *core_addr_to_string (const CORE_ADDR addr);
+
+extern const char *core_addr_to_string_nz (const CORE_ADDR addr);
+
+extern const char *host_address_to_string_1 (const void *addr);
+
+/* Wrapper that avoids adding a pointless cast to all callers.  */
+#define host_address_to_string(ADDR) \
+  host_address_to_string_1 ((const void *) (ADDR))
+
+/* Return the next entry in the circular print buffer.  */
+
+extern char *get_print_cell (void);
+
+#endif /* COMMON_PRINT_UTILS_H */
diff --git a/gdb/gdbsupport/ptid.c b/gdb/gdbsupport/ptid.c
new file mode 100644 (file)
index 0000000..c025511
--- /dev/null
@@ -0,0 +1,26 @@
+/* The ptid_t type and common functions operating on it.
+
+   Copyright (C) 1986-2019 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 "common-defs.h"
+#include "ptid.h"
+
+/* See ptid.h for these.  */
+
+ptid_t const null_ptid = ptid_t::make_null ();
+ptid_t const minus_one_ptid = ptid_t::make_minus_one ();
diff --git a/gdb/gdbsupport/ptid.h b/gdb/gdbsupport/ptid.h
new file mode 100644 (file)
index 0000000..f5625a6
--- /dev/null
@@ -0,0 +1,155 @@
+/* The ptid_t type and common functions operating on it.
+
+   Copyright (C) 1986-2019 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/>.  */
+
+#ifndef COMMON_PTID_H
+#define COMMON_PTID_H
+
+/* The ptid struct is a collection of the various "ids" necessary for
+   identifying the inferior process/thread being debugged.  This
+   consists of the process id (pid), lightweight process id (lwp) and
+   thread id (tid).  When manipulating ptids, the constructors,
+   accessors, and predicates declared in this file should be used.  Do
+   NOT access the struct ptid members directly.
+
+   process_stratum targets that handle threading themselves should
+   prefer using the ptid.lwp field, leaving the ptid.tid field for any
+   thread_stratum target that might want to sit on top.
+*/
+
+class ptid_t
+{
+public:
+  /* Must have a trivial defaulted default constructor so that the
+     type remains POD.  */
+  ptid_t () noexcept = default;
+
+  /* Make a ptid given the necessary PID, LWP, and TID components.
+
+     A ptid with only a PID (LWP and TID equal to zero) is usually used to
+     represent a whole process, including all its lwps/threads.  */
+
+  explicit constexpr ptid_t (int pid, long lwp = 0, long tid = 0)
+    : m_pid (pid), m_lwp (lwp), m_tid (tid)
+  {}
+
+  /* Fetch the pid (process id) component from the ptid.  */
+
+  constexpr int pid () const
+  { return m_pid; }
+
+  /* Return true if the ptid's lwp member is non-zero.  */
+
+  constexpr bool lwp_p () const
+  { return m_lwp != 0; }
+
+  /* Fetch the lwp (lightweight process) component from the ptid.  */
+
+  constexpr long lwp () const
+  { return m_lwp; }
+
+  /* Return true if the ptid's tid member is non-zero.  */
+
+  constexpr bool tid_p () const
+  { return m_tid != 0; }
+
+  /* Fetch the tid (thread id) component from a ptid.  */
+
+  constexpr long tid () const
+  { return m_tid; }
+
+  /* Return true if the ptid represents a whole process, including all its
+     lwps/threads.  Such ptids have the form of (pid, 0, 0), with
+     pid != -1.  */
+
+  constexpr bool is_pid () const
+  {
+    return (*this != make_null ()
+           && *this != make_minus_one ()
+           && m_lwp == 0
+           && m_tid == 0);
+  }
+
+  /* Compare two ptids to see if they are equal.  */
+
+  constexpr bool operator== (const ptid_t &other) const
+  {
+    return (m_pid == other.m_pid
+           && m_lwp == other.m_lwp
+           && m_tid == other.m_tid);
+  }
+
+  /* Compare two ptids to see if they are different.  */
+
+  constexpr bool operator!= (const ptid_t &other) const
+  {
+    return !(*this == other);
+  }
+
+  /* Return true if the ptid matches FILTER.  FILTER can be the wild
+     card MINUS_ONE_PTID (all ptids match it); can be a ptid representing
+     a process (ptid.is_pid () returns true), in which case, all lwps and
+     threads of that given process match, lwps and threads of other
+     processes do not; or, it can represent a specific thread, in which
+     case, only that thread will match true.  The ptid must represent a
+     specific LWP or THREAD, it can never be a wild card.  */
+
+  constexpr bool matches (const ptid_t &filter) const
+  {
+    return (/* If filter represents any ptid, it's always a match.  */
+           filter == make_minus_one ()
+           /* If filter is only a pid, any ptid with that pid
+              matches.  */
+           || (filter.is_pid () && m_pid == filter.pid ())
+
+           /* Otherwise, this ptid only matches if it's exactly equal
+              to filter.  */
+           || *this == filter);
+  }
+
+  /* Make a null ptid.  */
+
+  static constexpr ptid_t make_null ()
+  { return ptid_t (0, 0, 0); }
+
+  /* Make a minus one ptid.  */
+
+  static constexpr ptid_t make_minus_one ()
+  { return ptid_t (-1, 0, 0); }
+
+private:
+  /* Process id.  */
+  int m_pid;
+
+  /* Lightweight process id.  */
+  long m_lwp;
+
+  /* Thread id.  */
+  long m_tid;
+};
+
+/* The null or zero ptid, often used to indicate no process. */
+
+extern const ptid_t null_ptid;
+
+/* The (-1,0,0) ptid, often used to indicate either an error condition
+   or a "don't care" condition, i.e, "run all threads."  */
+
+extern const ptid_t minus_one_ptid;
+
+#endif /* COMMON_PTID_H */
diff --git a/gdb/gdbsupport/refcounted-object.h b/gdb/gdbsupport/refcounted-object.h
new file mode 100644 (file)
index 0000000..4bf7fcf
--- /dev/null
@@ -0,0 +1,70 @@
+/* Base class of intrusively reference-counted objects.
+   Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_REFCOUNTED_OBJECT_H
+#define COMMON_REFCOUNTED_OBJECT_H
+
+/* Base class of intrusively reference-countable objects.
+   Incrementing and decrementing the reference count is an external
+   responsibility.  */
+
+class refcounted_object
+{
+public:
+  refcounted_object () = default;
+
+  /* Increase the refcount.  */
+  void incref ()
+  {
+    gdb_assert (m_refcount >= 0);
+    m_refcount++;
+  }
+
+  /* Decrease the refcount.  */
+  void decref ()
+  {
+    m_refcount--;
+    gdb_assert (m_refcount >= 0);
+  }
+
+  int refcount () const { return m_refcount; }
+
+private:
+  DISABLE_COPY_AND_ASSIGN (refcounted_object);
+
+  /* The reference count.  */
+  int m_refcount = 0;
+};
+
+/* A policy class to interface gdb::ref_ptr with a
+   refcounted_object.  */
+
+struct refcounted_object_ref_policy
+{
+  static void incref (refcounted_object *ptr)
+  {
+    ptr->incref ();
+  }
+
+  static void decref (refcounted_object *ptr)
+  {
+    ptr->decref ();
+  }
+};
+
+#endif /* COMMON_REFCOUNTED_OBJECT_H */
diff --git a/gdb/gdbsupport/rsp-low.c b/gdb/gdbsupport/rsp-low.c
new file mode 100644 (file)
index 0000000..4bb4941
--- /dev/null
@@ -0,0 +1,307 @@
+/* Low-level RSP routines for GDB, the GNU debugger.
+
+   Copyright (C) 1988-2019 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 "common-defs.h"
+#include "rsp-low.h"
+
+/* See rsp-low.h.  */
+
+int
+fromhex (int a)
+{
+  if (a >= '0' && a <= '9')
+    return a - '0';
+  else if (a >= 'a' && a <= 'f')
+    return a - 'a' + 10;
+  else if (a >= 'A' && a <= 'F')
+    return a - 'A' + 10;
+  else
+    error (_("Reply contains invalid hex digit %d"), a);
+}
+
+/* See rsp-low.h.  */
+
+int
+tohex (int nib)
+{
+  if (nib < 10)
+    return '0' + nib;
+  else
+    return 'a' + nib - 10;
+}
+
+/* Encode 64 bits in 16 chars of hex.  */
+
+static const char hexchars[] = "0123456789abcdef";
+
+static int
+ishex (int ch, int *val)
+{
+  if ((ch >= 'a') && (ch <= 'f'))
+    {
+      *val = ch - 'a' + 10;
+      return 1;
+    }
+  if ((ch >= 'A') && (ch <= 'F'))
+    {
+      *val = ch - 'A' + 10;
+      return 1;
+    }
+  if ((ch >= '0') && (ch <= '9'))
+    {
+      *val = ch - '0';
+      return 1;
+    }
+  return 0;
+}
+
+/* See rsp-low.h.  */
+
+char *
+pack_nibble (char *buf, int nibble)
+{
+  *buf++ = hexchars[(nibble & 0x0f)];
+  return buf;
+}
+
+/* See rsp-low.h.  */
+
+char *
+pack_hex_byte (char *pkt, int byte)
+{
+  *pkt++ = hexchars[(byte >> 4) & 0xf];
+  *pkt++ = hexchars[(byte & 0xf)];
+  return pkt;
+}
+
+/* See rsp-low.h.  */
+
+const char *
+unpack_varlen_hex (const char *buff,   /* packet to parse */
+                  ULONGEST *result)
+{
+  int nibble;
+  ULONGEST retval = 0;
+
+  while (ishex (*buff, &nibble))
+    {
+      buff++;
+      retval = retval << 4;
+      retval |= nibble & 0x0f;
+    }
+  *result = retval;
+  return buff;
+}
+
+/* See rsp-low.h.  */
+
+int
+hex2bin (const char *hex, gdb_byte *bin, int count)
+{
+  int i;
+
+  for (i = 0; i < count; i++)
+    {
+      if (hex[0] == 0 || hex[1] == 0)
+       {
+         /* Hex string is short, or of uneven length.
+            Return the count that has been converted so far.  */
+         return i;
+       }
+      *bin++ = fromhex (hex[0]) * 16 + fromhex (hex[1]);
+      hex += 2;
+    }
+  return i;
+}
+
+/* See rsp-low.h.  */
+
+gdb::byte_vector
+hex2bin (const char *hex)
+{
+  size_t bin_len = strlen (hex) / 2;
+  gdb::byte_vector bin (bin_len);
+
+  hex2bin (hex, bin.data (), bin_len);
+
+  return bin;
+}
+
+/* See rsp-low.h.  */
+
+std::string
+hex2str (const char *hex)
+{
+  return hex2str (hex, strlen (hex));
+}
+
+/* See rsp-low.h.  */
+
+std::string
+hex2str (const char *hex, int count)
+{
+  std::string ret;
+
+  ret.reserve (count);
+  for (size_t i = 0; i < count; ++i)
+    {
+      if (hex[0] == '\0' || hex[1] == '\0')
+       {
+         /* Hex string is short, or of uneven length.  Return what we
+            have so far.  */
+         return ret;
+       }
+      ret += fromhex (hex[0]) * 16 + fromhex (hex[1]);
+      hex += 2;
+    }
+
+  return ret;
+}
+
+/* See rsp-low.h.  */
+
+int
+bin2hex (const gdb_byte *bin, char *hex, int count)
+{
+  int i;
+
+  for (i = 0; i < count; i++)
+    {
+      *hex++ = tohex ((*bin >> 4) & 0xf);
+      *hex++ = tohex (*bin++ & 0xf);
+    }
+  *hex = 0;
+  return i;
+}
+
+/* See rsp-low.h.  */
+
+std::string
+bin2hex (const gdb_byte *bin, int count)
+{
+  std::string ret;
+
+  ret.reserve (count * 2);
+  for (int i = 0; i < count; ++i)
+    {
+      ret += tohex ((*bin >> 4) & 0xf);
+      ret += tohex (*bin++ & 0xf);
+    }
+
+  return ret;
+}
+
+/* Return whether byte B needs escaping when sent as part of binary data.  */
+
+static int
+needs_escaping (gdb_byte b)
+{
+  return b == '$' || b == '#' || b == '}' || b == '*';
+}
+
+/* See rsp-low.h.  */
+
+int
+remote_escape_output (const gdb_byte *buffer, int len_units, int unit_size,
+                     gdb_byte *out_buf, int *out_len_units,
+                     int out_maxlen_bytes)
+{
+  int input_unit_index, output_byte_index = 0, byte_index_in_unit;
+  int number_escape_bytes_needed;
+
+  /* Try to copy integral addressable memory units until
+     (1) we run out of space or
+     (2) we copied all of them.  */
+  for (input_unit_index = 0;
+       input_unit_index < len_units;
+       input_unit_index++)
+    {
+      /* Find out how many escape bytes we need for this unit.  */
+      number_escape_bytes_needed = 0;
+      for (byte_index_in_unit = 0;
+          byte_index_in_unit < unit_size;
+          byte_index_in_unit++)
+       {
+         int idx = input_unit_index * unit_size + byte_index_in_unit;
+         gdb_byte b = buffer[idx];
+         if (needs_escaping (b))
+           number_escape_bytes_needed++;
+       }
+
+      /* Check if we have room to fit this escaped unit.  */
+      if (output_byte_index + unit_size + number_escape_bytes_needed >
+           out_maxlen_bytes)
+         break;
+
+      /* Copy the unit byte per byte, adding escapes.  */
+      for (byte_index_in_unit = 0;
+          byte_index_in_unit < unit_size;
+          byte_index_in_unit++)
+       {
+         int idx = input_unit_index * unit_size + byte_index_in_unit;
+         gdb_byte b = buffer[idx];
+         if (needs_escaping (b))
+           {
+             out_buf[output_byte_index++] = '}';
+             out_buf[output_byte_index++] = b ^ 0x20;
+           }
+         else
+           out_buf[output_byte_index++] = b;
+       }
+    }
+
+  *out_len_units = input_unit_index;
+  return output_byte_index;
+}
+
+/* See rsp-low.h.  */
+
+int
+remote_unescape_input (const gdb_byte *buffer, int len,
+                      gdb_byte *out_buf, int out_maxlen)
+{
+  int input_index, output_index;
+  int escaped;
+
+  output_index = 0;
+  escaped = 0;
+  for (input_index = 0; input_index < len; input_index++)
+    {
+      gdb_byte b = buffer[input_index];
+
+      if (output_index + 1 > out_maxlen)
+       error (_("Received too much data from the target."));
+
+      if (escaped)
+       {
+         out_buf[output_index++] = b ^ 0x20;
+         escaped = 0;
+       }
+      else if (b == '}')
+       escaped = 1;
+      else
+       out_buf[output_index++] = b;
+    }
+
+  if (escaped)
+    error (_("Unmatched escape character in target response."));
+
+  return output_index;
+}
+
diff --git a/gdb/gdbsupport/rsp-low.h b/gdb/gdbsupport/rsp-low.h
new file mode 100644 (file)
index 0000000..b2b62c9
--- /dev/null
@@ -0,0 +1,101 @@
+/* Low-level RSP routines for GDB, the GNU debugger.
+
+   Copyright (C) 1988-2019 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/>.  */
+
+#ifndef COMMON_RSP_LOW_H
+#define COMMON_RSP_LOW_H
+
+#include "gdbsupport/byte-vector.h"
+
+/* Convert hex digit A to a number, or throw an exception.  */
+
+extern int fromhex (int a);
+
+/* Convert number NIB to a hex digit.  */
+
+extern int tohex (int nib);
+
+/* Write a character representing the low order four bits of NIBBLE in
+   hex to *BUF.  Returns BUF+1.  */
+
+extern char *pack_nibble (char *buf, int nibble);
+
+/* Write the low byte of BYTE in hex to *BUF.  Returns BUF+2.  */
+
+extern char *pack_hex_byte (char *pkt, int byte);
+
+/* Read hex digits from BUFF and convert to a number, which is stored
+   in RESULT.  Reads until a non-hex digit is seen.  Returns a pointer
+   to the terminating character.  */
+
+extern const char *unpack_varlen_hex (const char *buff, ULONGEST *result);
+
+/* HEX is a string of characters representing hexadecimal digits.
+   Convert pairs of hex digits to bytes and store sequentially into
+   BIN.  COUNT is the maximum number of characters to convert.  This
+   will convert fewer characters if the number of hex characters
+   actually seen is odd, or if HEX terminates before COUNT characters.
+   Returns the number of characters actually converted.  */
+
+extern int hex2bin (const char *hex, gdb_byte *bin, int count);
+
+/* Like the above, but return a gdb::byte_vector.  */
+
+gdb::byte_vector hex2bin (const char *hex);
+
+/* Like hex2bin, but return a std::string.  */
+
+extern std::string hex2str (const char *hex);
+
+/* Like hex2bin, but return a std::string.  */
+
+extern std::string hex2str (const char *hex, int count);
+
+/* Convert some bytes to a hexadecimal representation.  BIN holds the
+   bytes to convert.  COUNT says how many bytes to convert.  The
+   resulting characters are stored in HEX, followed by a NUL
+   character.  Returns the number of bytes actually converted.  */
+
+extern int bin2hex (const gdb_byte *bin, char *hex, int count);
+
+/* Overloaded version of bin2hex that returns a std::string.  */
+
+extern std::string bin2hex (const gdb_byte *bin, int count);
+
+/* Convert BUFFER, binary data at least LEN_UNITS addressable memory units
+   long, into escaped binary data in OUT_BUF.  Only copy memory units that fit
+   completely in OUT_BUF.  Set *OUT_LEN_UNITS to the number of units from
+   BUFFER successfully encoded in OUT_BUF, and return the number of bytes used
+   in OUT_BUF.  The total number of bytes in the output buffer will be at most
+   OUT_MAXLEN_BYTES.  This function properly escapes '*', and so is suitable
+   for the server side as well as the client.  */
+
+extern int remote_escape_output (const gdb_byte *buffer, int len_units,
+                                int unit_size, gdb_byte *out_buf,
+                                int *out_len_units, int out_maxlen_bytes);
+
+/* Convert BUFFER, escaped data LEN bytes long, into binary data
+   in OUT_BUF.  Return the number of bytes written to OUT_BUF.
+   Raise an error if the total number of bytes exceeds OUT_MAXLEN.
+
+   This function reverses remote_escape_output.  */
+
+extern int remote_unescape_input (const gdb_byte *buffer, int len,
+                                 gdb_byte *out_buf, int out_maxlen);
+
+#endif /* COMMON_RSP_LOW_H */
diff --git a/gdb/gdbsupport/run-time-clock.c b/gdb/gdbsupport/run-time-clock.c
new file mode 100644 (file)
index 0000000..26378a0
--- /dev/null
@@ -0,0 +1,58 @@
+/* User/system CPU time clocks that follow the std::chrono interface.
+   Copyright (C) 2016-2019 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 "common-defs.h"
+#include "run-time-clock.h"
+#if defined HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+using namespace std::chrono;
+
+run_time_clock::time_point
+run_time_clock::now () noexcept
+{
+  return time_point (microseconds (get_run_time ()));
+}
+
+#ifdef HAVE_GETRUSAGE
+static std::chrono::microseconds
+timeval_to_microseconds (struct timeval *tv)
+{
+  return (seconds (tv->tv_sec) + microseconds (tv->tv_usec));
+}
+#endif
+
+void
+run_time_clock::now (user_cpu_time_clock::time_point &user,
+                    system_cpu_time_clock::time_point &system) noexcept
+{
+#ifdef HAVE_GETRUSAGE
+  struct rusage rusage;
+
+  getrusage (RUSAGE_SELF, &rusage);
+
+  microseconds utime = timeval_to_microseconds (&rusage.ru_utime);
+  microseconds stime = timeval_to_microseconds (&rusage.ru_stime);
+  user = user_cpu_time_clock::time_point (utime);
+  system = system_cpu_time_clock::time_point (stime);
+#else
+  user = user_cpu_time_clock::time_point (microseconds (get_run_time ()));
+  system = system_cpu_time_clock::time_point (microseconds::zero ());
+#endif
+}
diff --git a/gdb/gdbsupport/run-time-clock.h b/gdb/gdbsupport/run-time-clock.h
new file mode 100644 (file)
index 0000000..9c15dd7
--- /dev/null
@@ -0,0 +1,75 @@
+/* User/system CPU time clocks that follow the std::chrono interface.
+   Copyright (C) 2016-2019 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/>.  */
+
+#ifndef COMMON_RUN_TIME_CLOCK_H
+#define COMMON_RUN_TIME_CLOCK_H
+
+#include <chrono>
+
+/* Count the total amount of time spent executing in user mode.  */
+
+struct user_cpu_time_clock
+{
+  using duration = std::chrono::microseconds;
+  using rep = duration::rep;
+  using period = duration::period;
+  using time_point = std::chrono::time_point<user_cpu_time_clock>;
+
+  static constexpr bool is_steady = true;
+
+  /* Use run_time_clock::now instead.  */
+  static time_point now () noexcept = delete;
+};
+
+/* Count the total amount of time spent executing in kernel mode.  */
+
+struct system_cpu_time_clock
+{
+  using duration = std::chrono::microseconds;
+  using rep = duration::rep;
+  using period = duration::period;
+  using time_point = std::chrono::time_point<system_cpu_time_clock>;
+
+  static constexpr bool is_steady = true;
+
+  /* Use run_time_clock::now instead.  */
+  static time_point now () noexcept = delete;
+};
+
+/* Count the total amount of time spent executing in userspace+kernel
+   mode.  */
+
+struct run_time_clock
+{
+  using duration = std::chrono::microseconds;
+  using rep = duration::rep;
+  using period = duration::period;
+  using time_point = std::chrono::time_point<run_time_clock>;
+
+  static constexpr bool is_steady = true;
+
+  static time_point now () noexcept;
+
+  /* Return the user/system time as separate time points, if
+     supported.  If not supported, then the combined user+kernel time
+     is returned in USER and SYSTEM is set to zero.  */
+  static void now (user_cpu_time_clock::time_point &user,
+                  system_cpu_time_clock::time_point &system) noexcept;
+};
+
+#endif /* COMMON_RUN_TIME_CLOCK_H */
diff --git a/gdb/gdbsupport/safe-iterator.h b/gdb/gdbsupport/safe-iterator.h
new file mode 100644 (file)
index 0000000..89aec01
--- /dev/null
@@ -0,0 +1,93 @@
+/* A safe iterator for GDB, the GNU debugger.
+   Copyright (C) 2018-2019 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/>.  */
+
+#ifndef COMMON_SAFE_ITERATOR_H
+#define COMMON_SAFE_ITERATOR_H
+
+/* A forward iterator that wraps Iterator, such that when iterating
+   with iterator IT, it is possible to delete *IT without invalidating
+   IT.  Suitably wrapped in a range type and used with range-for, this
+   allow convenient patterns like this:
+
+     // range_safe() returns a range type whose begin()/end() methods
+     // return safe iterators.
+     for (foo *f : range_safe ())
+       {
+        if (f->should_delete ())
+          {
+            // The ++it operation implicitly done by the range-for is
+            // still OK after this.
+            delete f;
+          }
+       }
+*/
+
+template<typename Iterator>
+class basic_safe_iterator
+{
+public:
+  typedef basic_safe_iterator self_type;
+  typedef typename Iterator::value_type value_type;
+  typedef typename Iterator::reference reference;
+  typedef typename Iterator::pointer pointer;
+  typedef typename Iterator::iterator_category iterator_category;
+  typedef typename Iterator::difference_type difference_type;
+
+  /* Construct by forwarding all arguments to the underlying
+     iterator.  */
+  template<typename... Args>
+  explicit basic_safe_iterator (Args &&...args)
+    : m_it (std::forward<Args> (args)...),
+      m_next (m_it)
+  {
+    if (m_it != m_end)
+      ++m_next;
+  }
+
+  /* Create a one-past-end iterator.  */
+  basic_safe_iterator ()
+  {}
+
+  value_type operator* () const { return *m_it; }
+
+  self_type &operator++ ()
+  {
+    m_it = m_next;
+    if (m_it != m_end)
+      ++m_next;
+    return *this;
+  }
+
+  bool operator== (const self_type &other) const
+  { return m_it == other.m_it; }
+
+  bool operator!= (const self_type &other) const
+  { return m_it != other.m_it; }
+
+private:
+  /* The current element.  */
+  Iterator m_it {};
+
+  /* The next element.  Always one element ahead of M_IT.  */
+  Iterator m_next {};
+
+  /* A one-past-end iterator.  */
+  Iterator m_end {};
+};
+
+#endif /* COMMON_SAFE_ITERATOR_H */
diff --git a/gdb/gdbsupport/scope-exit.h b/gdb/gdbsupport/scope-exit.h
new file mode 100644 (file)
index 0000000..e2e6818
--- /dev/null
@@ -0,0 +1,186 @@
+/* Copyright (C) 2019 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/>.  */
+
+#ifndef COMMON_SCOPE_EXIT_H
+#define COMMON_SCOPE_EXIT_H
+
+#include <functional>
+#include <type_traits>
+#include "gdbsupport/preprocessor.h"
+
+/* scope_exit is a general-purpose scope guard that calls its exit
+   function at the end of the current scope.  A scope_exit may be
+   canceled by calling the "release" method.  The API is modeled on
+   P0052R5 - Generic Scope Guard and RAII Wrapper for the Standard
+   Library, which is itself based on Andrej Alexandrescu's
+   ScopeGuard/SCOPE_EXIT.
+
+   There are two forms available:
+
+   - The "make_scope_exit" form allows canceling the scope guard.  Use
+     it like this:
+
+     auto cleanup = make_scope_exit ( <function, function object, lambda> );
+     ...
+     cleanup.release (); // cancel
+
+   - If you don't need to cancel the guard, you can use the SCOPE_EXIT
+     macro, like this:
+
+     SCOPE_EXIT
+       {
+        // any code you like here.
+       }
+
+   See also forward_scope_exit.
+*/
+
+/* CRTP base class for cancelable scope_exit-like classes.  Implements
+   the common call-custom-function-from-dtor functionality.  Classes
+   that inherit this implement the on_exit() method, which is called
+   from scope_exit_base's dtor.  */
+
+template <typename CRTP>
+class scope_exit_base
+{
+public:
+  scope_exit_base () = default;
+
+  ~scope_exit_base ()
+  {
+    if (!m_released)
+      {
+       auto *self = static_cast<CRTP *> (this);
+       self->on_exit ();
+      }
+  }
+
+  /* This is needed for make_scope_exit because copy elision isn't
+     guaranteed until C++17.  An optimizing compiler will usually skip
+     calling this, but it must exist.  */
+  scope_exit_base (const scope_exit_base &other)
+    : m_released (other.m_released)
+  {
+    other.m_released = true;
+  }
+
+  void operator= (const scope_exit_base &) = delete;
+
+  /* If this is called, then the wrapped function will not be called
+     on destruction.  */
+  void release () noexcept
+  {
+    m_released = true;
+  }
+
+private:
+
+  /* True if released.  Mutable because of the copy ctor hack
+     above.  */
+  mutable bool m_released = false;
+};
+
+/* The scope_exit class.  */
+
+template<typename EF>
+class scope_exit : public scope_exit_base<scope_exit<EF>>
+{
+  /* For access to on_exit().  */
+  friend scope_exit_base<scope_exit<EF>>;
+
+public:
+
+  template<typename EFP,
+          typename = gdb::Requires<std::is_constructible<EF, EFP>>>
+  scope_exit (EFP &&f)
+    try : m_exit_function ((!std::is_lvalue_reference<EFP>::value
+                           && std::is_nothrow_constructible<EF, EFP>::value)
+                          ? std::move (f)
+                          : f)
+  {
+  }
+  catch (...)
+    {
+      /* "If the initialization of exit_function throws an exception,
+        calls f()."  */
+      f ();
+    }
+
+  template<typename EFP,
+          typename = gdb::Requires<std::is_constructible<EF, EFP>>>
+  scope_exit (scope_exit &&rhs)
+    noexcept (std::is_nothrow_move_constructible<EF>::value
+             || std::is_nothrow_copy_constructible<EF>::value)
+    : m_exit_function (std::is_nothrow_constructible<EFP>::value
+                      ? std::move (rhs)
+                      : rhs)
+  {
+    rhs.release ();
+  }
+
+  /* This is needed for make_scope_exit because copy elision isn't
+     guaranteed until C++17.  An optimizing compiler will usually skip
+     calling this, but it must exist.  */
+  scope_exit (const scope_exit &other)
+    : scope_exit_base<scope_exit<EF>> (other),
+      m_exit_function (other.m_exit_function)
+  {
+  }
+
+  void operator= (const scope_exit &) = delete;
+  void operator= (scope_exit &&) = delete;
+
+private:
+  void on_exit ()
+  {
+    m_exit_function ();
+  }
+
+  /* The function to call on scope exit.  */
+  EF m_exit_function;
+};
+
+template <typename EF>
+scope_exit<typename std::decay<EF>::type>
+make_scope_exit (EF &&f)
+{
+  return scope_exit<typename std::decay<EF>::type> (std::forward<EF> (f));
+}
+
+namespace detail
+{
+
+enum class scope_exit_lhs {};
+
+template<typename EF>
+scope_exit<typename std::decay<EF>::type>
+operator+ (scope_exit_lhs, EF &&rhs)
+{
+  return scope_exit<typename std::decay<EF>::type> (std::forward<EF> (rhs));
+}
+
+}
+
+/* Register a block of code to run on scope exit.  Note that the local
+   context is captured by reference, which means you should be careful
+   to avoid inadvertently changing a captured local's value before the
+   scope exit runs.  */
+
+#define SCOPE_EXIT \
+  auto CONCAT(scope_exit_, __LINE__) = ::detail::scope_exit_lhs () + [&] ()
+
+#endif /* COMMON_SCOPE_EXIT_H */
diff --git a/gdb/gdbsupport/scoped_fd.h b/gdb/gdbsupport/scoped_fd.h
new file mode 100644 (file)
index 0000000..c4a494b
--- /dev/null
@@ -0,0 +1,87 @@
+/* scoped_fd, automatically close a file descriptor
+
+   Copyright (C) 2018-2019 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/>.  */
+
+#ifndef COMMON_SCOPED_FD_H
+#define COMMON_SCOPED_FD_H
+
+#include <unistd.h>
+#include "filestuff.h"
+
+/* A smart-pointer-like class to automatically close a file descriptor.  */
+
+class scoped_fd
+{
+public:
+  explicit scoped_fd (int fd = -1) noexcept : m_fd (fd) {}
+
+  scoped_fd (scoped_fd &&other)
+    : m_fd (other.m_fd)
+  {
+    other.m_fd = -1;
+  }
+
+  ~scoped_fd ()
+  {
+    if (m_fd >= 0)
+      close (m_fd);
+  }
+
+  scoped_fd &operator= (scoped_fd &&other)
+  {
+    if (m_fd != other.m_fd)
+      {
+       if (m_fd >= 0)
+         close (m_fd);
+       m_fd = other.m_fd;
+       other.m_fd = -1;
+      }
+    return *this;
+  }
+
+  DISABLE_COPY_AND_ASSIGN (scoped_fd);
+
+  ATTRIBUTE_UNUSED_RESULT int release () noexcept
+  {
+    int fd = m_fd;
+    m_fd = -1;
+    return fd;
+  }
+
+  /* Like release, but return a gdb_file_up that owns the file
+     descriptor.  On success, this scoped_fd will be released.  On
+     failure, return NULL and leave this scoped_fd in possession of
+     the fd.  */
+  gdb_file_up to_file (const char *mode) noexcept
+  {
+    gdb_file_up result (fdopen (m_fd, mode));
+    if (result != nullptr)
+      m_fd = -1;
+    return result;
+  }
+
+  int get () const noexcept
+  {
+    return m_fd;
+  }
+
+private:
+  int m_fd;
+};
+
+#endif /* COMMON_SCOPED_FD_H */
diff --git a/gdb/gdbsupport/scoped_mmap.c b/gdb/gdbsupport/scoped_mmap.c
new file mode 100644 (file)
index 0000000..9e0af57
--- /dev/null
@@ -0,0 +1,49 @@
+/* scoped_mmap, automatically unmap files
+
+   Copyright (C) 2018-2019 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 "common-defs.h"
+#include "scoped_mmap.h"
+#include "scoped_fd.h"
+#include "gdbsupport/filestuff.h"
+
+#ifdef HAVE_SYS_MMAN_H
+
+scoped_mmap
+mmap_file (const char *filename)
+{
+  scoped_fd fd (gdb_open_cloexec (filename, O_RDONLY, 0));
+  if (fd.get () < 0)
+    perror_with_name (("open"));
+
+  off_t size = lseek (fd.get (), 0, SEEK_END);
+  if (size < 0)
+    perror_with_name (("lseek"));
+
+  /* We can't map an empty file.  */
+  if (size == 0)
+    error (_("file to mmap is empty"));
+
+  scoped_mmap mmapped_file (nullptr, size, PROT_READ, MAP_PRIVATE, fd.get (), 0);
+  if (mmapped_file.get () == MAP_FAILED)
+    perror_with_name (("mmap"));
+
+  return mmapped_file;
+}
+
+#endif /* HAVE_SYS_MMAN_H */
diff --git a/gdb/gdbsupport/scoped_mmap.h b/gdb/gdbsupport/scoped_mmap.h
new file mode 100644 (file)
index 0000000..05cca9e
--- /dev/null
@@ -0,0 +1,94 @@
+/* scoped_mmap, automatically unmap files
+
+   Copyright (C) 2018-2019 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/>.  */
+
+#ifndef COMMON_SCOPED_MMAP_H
+#define COMMON_SCOPED_MMAP_H
+
+#ifdef HAVE_SYS_MMAN_H
+
+#include <sys/mman.h>
+
+/* A smart-pointer-like class to mmap() and automatically munmap() a memory
+   mapping.  */
+
+class scoped_mmap
+{
+public:
+  scoped_mmap () noexcept : m_mem (MAP_FAILED), m_length (0) {}
+  scoped_mmap (void *addr, size_t length, int prot, int flags, int fd,
+              off_t offset) noexcept : m_length (length)
+  {
+    m_mem = mmap (addr, m_length, prot, flags, fd, offset);
+  }
+
+  ~scoped_mmap ()
+  {
+    destroy ();
+  }
+
+  scoped_mmap (scoped_mmap &&rhs)
+  {
+    destroy ();
+
+    m_mem = rhs.m_mem;
+    m_length = rhs.m_length;
+
+    rhs.m_mem = MAP_FAILED;
+    rhs.m_length = 0;
+  }
+
+  DISABLE_COPY_AND_ASSIGN (scoped_mmap);
+
+  ATTRIBUTE_UNUSED_RESULT void *release () noexcept
+  {
+    void *mem = m_mem;
+    m_mem = MAP_FAILED;
+    m_length = 0;
+    return mem;
+  }
+
+  void reset (void *addr, size_t length, int prot, int flags, int fd,
+             off_t offset) noexcept
+  {
+    destroy ();
+
+    m_length = length;
+    m_mem = mmap (addr, m_length, prot, flags, fd, offset);
+  }
+
+  size_t size () const noexcept { return m_length; }
+  void *get () const noexcept { return m_mem; }
+
+private:
+  void destroy ()
+  {
+    if (m_mem != MAP_FAILED)
+      munmap (m_mem, m_length);
+  }
+
+  void *m_mem;
+  size_t m_length;
+};
+
+/* Map FILENAME in memory.  Throw an error if anything goes wrong.  */
+scoped_mmap mmap_file (const char *filename);
+
+#endif /* HAVE_SYS_MMAN_H */
+
+#endif /* COMMON_SCOPED_MMAP_H */
diff --git a/gdb/gdbsupport/scoped_restore.h b/gdb/gdbsupport/scoped_restore.h
new file mode 100644 (file)
index 0000000..54c3ff5
--- /dev/null
@@ -0,0 +1,118 @@
+/* scoped_restore, a simple class for saving and restoring a value
+
+   Copyright (C) 2016-2019 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/>.  */
+
+#ifndef COMMON_SCOPED_RESTORE_H
+#define COMMON_SCOPED_RESTORE_H
+
+/* Base class for scoped_restore_tmpl.  */
+class scoped_restore_base
+{
+public:
+  /* This informs the (scoped_restore_tmpl<T>) dtor that you no longer
+     want the original value restored.  */
+  void release () const
+  { m_saved_var = NULL; }
+
+protected:
+  scoped_restore_base (void *saved_var)
+    : m_saved_var (saved_var)
+  {}
+
+  /* The type-erased saved variable.  This is here so that clients can
+     call release() on a "scoped_restore" local, which is a typedef to
+     a scoped_restore_base.  See below.  */
+  mutable void *m_saved_var;
+};
+
+/* A convenience typedef.  Users of make_scoped_restore declare the
+   local RAII object as having this type.  */
+typedef const scoped_restore_base &scoped_restore;
+
+/* An RAII-based object that saves a variable's value, and then
+   restores it again when this object is destroyed. */
+template<typename T>
+class scoped_restore_tmpl : public scoped_restore_base
+{
+ public:
+
+  /* Create a new scoped_restore object that saves the current value
+     of *VAR.  *VAR will be restored when this scoped_restore object
+     is destroyed.  */
+  scoped_restore_tmpl (T *var)
+    : scoped_restore_base (var),
+      m_saved_value (*var)
+  {
+  }
+
+  /* Create a new scoped_restore object that saves the current value
+     of *VAR, and sets *VAR to VALUE.  *VAR will be restored when this
+     scoped_restore object is destroyed.  This is templated on T2 to
+     allow passing VALUEs of types convertible to T.
+     E.g.: T='base'; T2='derived'.  */
+  template <typename T2>
+  scoped_restore_tmpl (T *var, T2 value)
+    : scoped_restore_base (var),
+      m_saved_value (*var)
+  {
+    *var = value;
+  }
+
+  scoped_restore_tmpl (const scoped_restore_tmpl<T> &other)
+    : scoped_restore_base {other.m_saved_var},
+      m_saved_value (other.m_saved_value)
+  {
+    other.m_saved_var = NULL;
+  }
+
+  ~scoped_restore_tmpl ()
+  {
+    if (saved_var () != NULL)
+      *saved_var () = m_saved_value;
+  }
+
+private:
+  /* Return a pointer to the saved variable with its type
+     restored.  */
+  T *saved_var ()
+  { return static_cast<T *> (m_saved_var); }
+
+  /* No need for this.  It is intentionally not defined anywhere.  */
+  scoped_restore_tmpl &operator= (const scoped_restore_tmpl &);
+
+  /* The saved value.  */
+  const T m_saved_value;
+};
+
+/* Make a scoped_restore.  This is useful because it lets template
+   argument deduction work.  */
+template<typename T>
+scoped_restore_tmpl<T> make_scoped_restore (T *var)
+{
+  return scoped_restore_tmpl<T> (var);
+}
+
+/* Make a scoped_restore.  This is useful because it lets template
+   argument deduction work.  */
+template<typename T, typename T2>
+scoped_restore_tmpl<T> make_scoped_restore (T *var, T2 value)
+{
+  return scoped_restore_tmpl<T> (var, value);
+}
+
+#endif /* COMMON_SCOPED_RESTORE_H */
diff --git a/gdb/gdbsupport/selftest.c b/gdb/gdbsupport/selftest.c
new file mode 100644 (file)
index 0000000..f5a7b3c
--- /dev/null
@@ -0,0 +1,111 @@
+/* GDB self-testing.
+   Copyright (C) 2016-2019 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 "common-defs.h"
+#include "common-exceptions.h"
+#include "common-debug.h"
+#include "selftest.h"
+#include <map>
+
+namespace selftests
+{
+/* All the tests that have been registered.  Using an std::map allows keeping
+   the order of tests stable and easily looking up whether a test name
+   exists.  */
+
+static std::map<std::string, std::unique_ptr<selftest>> tests;
+
+/* A selftest that calls the test function without arguments.  */
+
+struct simple_selftest : public selftest
+{
+  simple_selftest (self_test_function *function_)
+  : function (function_)
+  {}
+
+  void operator() () const override
+  {
+    function ();
+  }
+
+  self_test_function *function;
+};
+
+/* See selftest.h.  */
+
+void
+register_test (const std::string &name, selftest *test)
+{
+  /* Check that no test with this name already exist.  */
+  gdb_assert (tests.find (name) == tests.end ());
+
+  tests[name] = std::unique_ptr<selftest> (test);
+}
+
+/* See selftest.h.  */
+
+void
+register_test (const std::string &name, self_test_function *function)
+{
+  register_test (name, new simple_selftest (function));
+}
+
+/* See selftest.h.  */
+
+void
+run_tests (const char *filter)
+{
+  int ran = 0, failed = 0;
+
+  for (const auto &pair : tests)
+    {
+      const std::string &name = pair.first;
+      const std::unique_ptr<selftest> &test = pair.second;
+
+      if (filter != NULL && *filter != '\0'
+         && name.find (filter) == std::string::npos)
+       continue;
+
+      try
+       {
+         debug_printf (_("Running selftest %s.\n"), name.c_str ());
+         ++ran;
+         (*test) ();
+       }
+      catch (const gdb_exception_error &ex)
+       {
+         ++failed;
+         debug_printf ("Self test failed: %s\n", ex.what ());
+       }
+
+      reset ();
+    }
+
+  debug_printf (_("Ran %d unit tests, %d failed\n"),
+               ran, failed);
+}
+
+/* See selftest.h.  */
+
+void for_each_selftest (for_each_selftest_ftype func)
+{
+  for (const auto &pair : tests)
+    func (pair.first);
+}
+
+} // namespace selftests
diff --git a/gdb/gdbsupport/selftest.h b/gdb/gdbsupport/selftest.h
new file mode 100644 (file)
index 0000000..c566ec5
--- /dev/null
@@ -0,0 +1,73 @@
+/* GDB self-testing.
+   Copyright (C) 2016-2019 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/>.  */
+
+#ifndef COMMON_SELFTEST_H
+#define COMMON_SELFTEST_H
+
+/* A test is just a function that does some checks and throws an
+   exception if something has gone wrong.  */
+
+typedef void self_test_function (void);
+
+namespace selftests
+{
+
+/* Interface for the various kinds of selftests.  */
+
+struct selftest
+{
+  virtual ~selftest () = default;
+  virtual void operator() () const = 0;
+};
+
+/* Register a new self-test.  */
+
+extern void register_test (const std::string &name, selftest *test);
+
+/* Register a new self-test.  */
+
+extern void register_test (const std::string &name,
+                          self_test_function *function);
+
+/* Run all the self tests.  This print a message describing the number
+   of test and the number of failures.
+
+   If FILTER is not NULL and not empty, only tests with names containing FILTER
+   will be ran.  */
+
+extern void run_tests (const char *filter);
+
+/* Reset GDB or GDBserver's internal state.  */
+extern void reset ();
+
+typedef void for_each_selftest_ftype (const std::string &name);
+
+/* Call FUNC for each registered selftest.  */
+
+extern void for_each_selftest (for_each_selftest_ftype func);
+}
+
+/* Check that VALUE is true, and, if not, throw an exception.  */
+
+#define SELF_CHECK(VALUE)                                              \
+  do {                                                                 \
+    if (!(VALUE))                                                      \
+      error (_("self-test failed at %s:%d"), __FILE__, __LINE__);      \
+  } while (0)
+
+#endif /* COMMON_SELFTEST_H */
diff --git a/gdb/gdbsupport/signals-state-save-restore.c b/gdb/gdbsupport/signals-state-save-restore.c
new file mode 100644 (file)
index 0000000..c66d2dd
--- /dev/null
@@ -0,0 +1,117 @@
+/* Copyright (C) 2016-2019 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 "common-defs.h"
+#include "signals-state-save-restore.h"
+
+#include <signal.h>
+
+/* The original signal actions and mask.  */
+
+#ifdef HAVE_SIGACTION
+static struct sigaction original_signal_actions[NSIG];
+
+/* Note that we use sigprocmask without worrying about threads because
+   the save/restore functions are called either from main, or after a
+   fork.  In both cases, we know the calling process is single
+   threaded.  */
+static sigset_t original_signal_mask;
+#endif
+
+/* See signals-state-save-restore.h.   */
+
+void
+save_original_signals_state (bool quiet)
+{
+#ifdef HAVE_SIGACTION
+  int i;
+  int res;
+
+  res = sigprocmask (0,  NULL, &original_signal_mask);
+  if (res == -1)
+    perror_with_name (("sigprocmask"));
+
+  bool found_preinstalled = false;
+
+  for (i = 1; i < NSIG; i++)
+    {
+      struct sigaction *oldact = &original_signal_actions[i];
+
+      res = sigaction (i, NULL, oldact);
+      if (res == -1 && errno == EINVAL)
+       {
+         /* Some signal numbers in the range are invalid.  */
+         continue;
+       }
+      else if (res == -1)
+       perror_with_name (("sigaction"));
+
+      /* If we find a custom signal handler already installed, then
+        this function was called too late.  This is a warning instead
+        of an internal error because this can also happen if you
+        LD_PRELOAD a library that installs a signal handler early via
+        __attribute__((constructor)), like libSegFault.so.  */
+      if (!quiet
+         && oldact->sa_handler != SIG_DFL
+         && oldact->sa_handler != SIG_IGN)
+       {
+         found_preinstalled = true;
+
+         /* Use raw fprintf here because we're being called in early
+            startup, before GDB's filtered streams are created.  */
+         fprintf (stderr,
+                  _("warning: Found custom handler for signal "
+                    "%d (%s) preinstalled.\n"), i,
+                  strsignal (i));
+       }
+    }
+
+  if (found_preinstalled)
+    {
+      fprintf (stderr, _("\
+Some signal dispositions inherited from the environment (SIG_DFL/SIG_IGN)\n\
+won't be propagated to spawned programs.\n"));
+    }
+#endif
+}
+
+/* See signals-state-save-restore.h.   */
+
+void
+restore_original_signals_state (void)
+{
+#ifdef HAVE_SIGACTION
+  int i;
+  int res;
+
+  for (i = 1; i < NSIG; i++)
+    {
+      res = sigaction (i, &original_signal_actions[i], NULL);
+      if (res == -1 && errno == EINVAL)
+       {
+         /* Some signal numbers in the range are invalid.  */
+         continue;
+       }
+      else if (res == -1)
+       perror_with_name (("sigaction"));
+    }
+
+  res = sigprocmask (SIG_SETMASK,  &original_signal_mask, NULL);
+  if (res == -1)
+    perror_with_name (("sigprocmask"));
+#endif
+}
diff --git a/gdb/gdbsupport/signals-state-save-restore.h b/gdb/gdbsupport/signals-state-save-restore.h
new file mode 100644 (file)
index 0000000..de3d896
--- /dev/null
@@ -0,0 +1,40 @@
+/* Copyright (C) 2016-2019 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/>.  */
+
+#ifndef COMMON_SIGNALS_STATE_SAVE_RESTORE_H
+#define COMMON_SIGNALS_STATE_SAVE_RESTORE_H
+
+/* Save/restore the signal actions of all signals, and the signal
+   mask.
+
+   Since the exec family of functions does not reset the signal
+   disposition of signals set to SIG_IGN, nor does it reset the signal
+   mask, in order to be transparent, when spawning new child processes
+   to debug (with "run", etc.), we must reset signal actions and mask
+   back to what was originally inherited from gdb/gdbserver's parent,
+   just before execing the target program to debug.  */
+
+/* Save the signal state of all signals.  If !QUIET, warn if we detect
+   a custom signal handler preinstalled.  */
+
+extern void save_original_signals_state (bool quiet);
+
+/* Restore the signal state of all signals.  */
+
+extern void restore_original_signals_state (void);
+
+#endif /* COMMON_SIGNALS_STATE_SAVE_RESTORE_H */
diff --git a/gdb/gdbsupport/signals.c b/gdb/gdbsupport/signals.c
new file mode 100644 (file)
index 0000000..707bbe9
--- /dev/null
@@ -0,0 +1,653 @@
+/* Target signal translation functions for GDB.
+   Copyright (C) 1990-2019 Free Software Foundation, Inc.
+   Contributed by Cygnus Support.
+
+   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 "common-defs.h"
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+#include "gdb_signals.h"
+
+struct gdbarch;
+
+/* Always use __SIGRTMIN if it's available.  SIGRTMIN is the lowest
+   _available_ realtime signal, not the lowest supported; glibc takes
+   several for its own use.  */
+
+#ifndef REALTIME_LO
+# if defined(__SIGRTMIN)
+#  define REALTIME_LO __SIGRTMIN
+#  define REALTIME_HI (__SIGRTMAX + 1)
+# elif defined(SIGRTMIN)
+#  define REALTIME_LO SIGRTMIN
+#  define REALTIME_HI (SIGRTMAX + 1)
+# endif
+#endif
+
+/* This table must match in order and size the signals in enum
+   gdb_signal.  */
+
+static const struct {
+  const char *symbol;
+  const char *name;
+  const char *string;
+  } signals [] =
+{
+#define SET(symbol, constant, name, string) { #symbol, name, string },
+#include "gdb/signals.def"
+#undef SET
+};
+
+const char *
+gdb_signal_to_symbol_string (enum gdb_signal sig)
+{
+  gdb_assert ((int) sig >= GDB_SIGNAL_FIRST && (int) sig <= GDB_SIGNAL_LAST);
+
+  return signals[sig].symbol;
+}
+
+/* Return the string for a signal.  */
+const char *
+gdb_signal_to_string (enum gdb_signal sig)
+{
+  if ((int) sig >= GDB_SIGNAL_FIRST && (int) sig <= GDB_SIGNAL_LAST)
+    return signals[sig].string;
+  else
+    return signals[GDB_SIGNAL_UNKNOWN].string;
+}
+
+/* Return the name for a signal.  */
+const char *
+gdb_signal_to_name (enum gdb_signal sig)
+{
+  if ((int) sig >= GDB_SIGNAL_FIRST && (int) sig <= GDB_SIGNAL_LAST
+      && signals[sig].name != NULL)
+    return signals[sig].name;
+  else
+    /* I think the code which prints this will always print it along
+       with the string, so no need to be verbose (very old comment).  */
+    return "?";
+}
+
+/* Given a name, return its signal.  */
+enum gdb_signal
+gdb_signal_from_name (const char *name)
+{
+  enum gdb_signal sig;
+
+  /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
+     for GDB_SIGNAL_SIGCHLD.  SIGIOT, on the other hand, is more
+     questionable; seems like by now people should call it SIGABRT
+     instead.  */
+
+  /* This ugly cast brought to you by the native VAX compiler.  */
+  for (sig = GDB_SIGNAL_HUP;
+       sig < GDB_SIGNAL_LAST;
+       sig = (enum gdb_signal) ((int) sig + 1))
+    if (signals[sig].name != NULL
+       && strcmp (name, signals[sig].name) == 0)
+      return sig;
+  return GDB_SIGNAL_UNKNOWN;
+}
+\f
+/* The following functions are to help certain targets deal
+   with the signal/waitstatus stuff.  They could just as well be in
+   a file called native-utils.c or unixwaitstatus-utils.c or whatever.  */
+
+/* Convert host signal to our signals.  */
+enum gdb_signal
+gdb_signal_from_host (int hostsig)
+{
+  /* A switch statement would make sense but would require special
+     kludges to deal with the cases where more than one signal has the
+     same number.  Signals are ordered ANSI-standard signals first,
+     other signals second, with signals in each block ordered by their
+     numerical values on a typical POSIX platform.  */
+
+  if (hostsig == 0)
+    return GDB_SIGNAL_0;
+
+  /* SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM
+     are ANSI-standard signals and are always available.  */
+  if (hostsig == SIGINT)
+    return GDB_SIGNAL_INT;
+  if (hostsig == SIGILL)
+    return GDB_SIGNAL_ILL;
+  if (hostsig == SIGABRT)
+    return GDB_SIGNAL_ABRT;
+  if (hostsig == SIGFPE)
+    return GDB_SIGNAL_FPE;
+  if (hostsig == SIGSEGV)
+    return GDB_SIGNAL_SEGV;
+  if (hostsig == SIGTERM)
+    return GDB_SIGNAL_TERM;
+
+  /* All other signals need preprocessor conditionals.  */
+#if defined (SIGHUP)
+  if (hostsig == SIGHUP)
+    return GDB_SIGNAL_HUP;
+#endif
+#if defined (SIGQUIT)
+  if (hostsig == SIGQUIT)
+    return GDB_SIGNAL_QUIT;
+#endif
+#if defined (SIGTRAP)
+  if (hostsig == SIGTRAP)
+    return GDB_SIGNAL_TRAP;
+#endif
+#if defined (SIGEMT)
+  if (hostsig == SIGEMT)
+    return GDB_SIGNAL_EMT;
+#endif
+#if defined (SIGKILL)
+  if (hostsig == SIGKILL)
+    return GDB_SIGNAL_KILL;
+#endif
+#if defined (SIGBUS)
+  if (hostsig == SIGBUS)
+    return GDB_SIGNAL_BUS;
+#endif
+#if defined (SIGSYS)
+  if (hostsig == SIGSYS)
+    return GDB_SIGNAL_SYS;
+#endif
+#if defined (SIGPIPE)
+  if (hostsig == SIGPIPE)
+    return GDB_SIGNAL_PIPE;
+#endif
+#if defined (SIGALRM)
+  if (hostsig == SIGALRM)
+    return GDB_SIGNAL_ALRM;
+#endif
+#if defined (SIGUSR1)
+  if (hostsig == SIGUSR1)
+    return GDB_SIGNAL_USR1;
+#endif
+#if defined (SIGUSR2)
+  if (hostsig == SIGUSR2)
+    return GDB_SIGNAL_USR2;
+#endif
+#if defined (SIGCLD)
+  if (hostsig == SIGCLD)
+    return GDB_SIGNAL_CHLD;
+#endif
+#if defined (SIGCHLD)
+  if (hostsig == SIGCHLD)
+    return GDB_SIGNAL_CHLD;
+#endif
+#if defined (SIGPWR)
+  if (hostsig == SIGPWR)
+    return GDB_SIGNAL_PWR;
+#endif
+#if defined (SIGWINCH)
+  if (hostsig == SIGWINCH)
+    return GDB_SIGNAL_WINCH;
+#endif
+#if defined (SIGURG)
+  if (hostsig == SIGURG)
+    return GDB_SIGNAL_URG;
+#endif
+#if defined (SIGIO)
+  if (hostsig == SIGIO)
+    return GDB_SIGNAL_IO;
+#endif
+#if defined (SIGPOLL)
+  if (hostsig == SIGPOLL)
+    return GDB_SIGNAL_POLL;
+#endif
+#if defined (SIGSTOP)
+  if (hostsig == SIGSTOP)
+    return GDB_SIGNAL_STOP;
+#endif
+#if defined (SIGTSTP)
+  if (hostsig == SIGTSTP)
+    return GDB_SIGNAL_TSTP;
+#endif
+#if defined (SIGCONT)
+  if (hostsig == SIGCONT)
+    return GDB_SIGNAL_CONT;
+#endif
+#if defined (SIGTTIN)
+  if (hostsig == SIGTTIN)
+    return GDB_SIGNAL_TTIN;
+#endif
+#if defined (SIGTTOU)
+  if (hostsig == SIGTTOU)
+    return GDB_SIGNAL_TTOU;
+#endif
+#if defined (SIGVTALRM)
+  if (hostsig == SIGVTALRM)
+    return GDB_SIGNAL_VTALRM;
+#endif
+#if defined (SIGPROF)
+  if (hostsig == SIGPROF)
+    return GDB_SIGNAL_PROF;
+#endif
+#if defined (SIGXCPU)
+  if (hostsig == SIGXCPU)
+    return GDB_SIGNAL_XCPU;
+#endif
+#if defined (SIGXFSZ)
+  if (hostsig == SIGXFSZ)
+    return GDB_SIGNAL_XFSZ;
+#endif
+#if defined (SIGWIND)
+  if (hostsig == SIGWIND)
+    return GDB_SIGNAL_WIND;
+#endif
+#if defined (SIGPHONE)
+  if (hostsig == SIGPHONE)
+    return GDB_SIGNAL_PHONE;
+#endif
+#if defined (SIGLOST)
+  if (hostsig == SIGLOST)
+    return GDB_SIGNAL_LOST;
+#endif
+#if defined (SIGWAITING)
+  if (hostsig == SIGWAITING)
+    return GDB_SIGNAL_WAITING;
+#endif
+#if defined (SIGCANCEL)
+  if (hostsig == SIGCANCEL)
+    return GDB_SIGNAL_CANCEL;
+#endif
+#if defined (SIGLWP)
+  if (hostsig == SIGLWP)
+    return GDB_SIGNAL_LWP;
+#endif
+#if defined (SIGDANGER)
+  if (hostsig == SIGDANGER)
+    return GDB_SIGNAL_DANGER;
+#endif
+#if defined (SIGGRANT)
+  if (hostsig == SIGGRANT)
+    return GDB_SIGNAL_GRANT;
+#endif
+#if defined (SIGRETRACT)
+  if (hostsig == SIGRETRACT)
+    return GDB_SIGNAL_RETRACT;
+#endif
+#if defined (SIGMSG)
+  if (hostsig == SIGMSG)
+    return GDB_SIGNAL_MSG;
+#endif
+#if defined (SIGSOUND)
+  if (hostsig == SIGSOUND)
+    return GDB_SIGNAL_SOUND;
+#endif
+#if defined (SIGSAK)
+  if (hostsig == SIGSAK)
+    return GDB_SIGNAL_SAK;
+#endif
+#if defined (SIGPRIO)
+  if (hostsig == SIGPRIO)
+    return GDB_SIGNAL_PRIO;
+#endif
+
+  /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
+#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
+  if (hostsig == _NSIG + EXC_BAD_ACCESS)
+    return GDB_EXC_BAD_ACCESS;
+#endif
+#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
+  if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
+    return GDB_EXC_BAD_INSTRUCTION;
+#endif
+#if defined (EXC_ARITHMETIC) && defined (_NSIG)
+  if (hostsig == _NSIG + EXC_ARITHMETIC)
+    return GDB_EXC_ARITHMETIC;
+#endif
+#if defined (EXC_EMULATION) && defined (_NSIG)
+  if (hostsig == _NSIG + EXC_EMULATION)
+    return GDB_EXC_EMULATION;
+#endif
+#if defined (EXC_SOFTWARE) && defined (_NSIG)
+  if (hostsig == _NSIG + EXC_SOFTWARE)
+    return GDB_EXC_SOFTWARE;
+#endif
+#if defined (EXC_BREAKPOINT) && defined (_NSIG)
+  if (hostsig == _NSIG + EXC_BREAKPOINT)
+    return GDB_EXC_BREAKPOINT;
+#endif
+
+#if defined (SIGINFO)
+  if (hostsig == SIGINFO)
+    return GDB_SIGNAL_INFO;
+#endif
+#if defined (SIGLIBRT)
+  if (hostsig == SIGLIBRT)
+    return GDB_SIGNAL_LIBRT;
+#endif
+
+#if defined (REALTIME_LO)
+  if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
+    {
+      /* This block of GDB_SIGNAL_REALTIME value is in order.  */
+      if (33 <= hostsig && hostsig <= 63)
+       return (enum gdb_signal)
+         (hostsig - 33 + (int) GDB_SIGNAL_REALTIME_33);
+      else if (hostsig == 32)
+       return GDB_SIGNAL_REALTIME_32;
+      else if (64 <= hostsig && hostsig <= 127)
+       return (enum gdb_signal)
+         (hostsig - 64 + (int) GDB_SIGNAL_REALTIME_64);
+      else
+       error (_("GDB bug: target.c (gdb_signal_from_host): "
+              "unrecognized real-time signal"));
+    }
+#endif
+
+  return GDB_SIGNAL_UNKNOWN;
+}
+
+/* Convert a OURSIG (an enum gdb_signal) to the form used by the
+   target operating system (refered to as the ``host'') or zero if the
+   equivalent host signal is not available.  Set/clear OURSIG_OK
+   accordingly. */
+
+static int
+do_gdb_signal_to_host (enum gdb_signal oursig,
+                         int *oursig_ok)
+{
+  int retsig;
+  /* Silence the 'not used' warning, for targets that
+     do not support signals.  */
+  (void) retsig;
+
+  /* Signals are ordered ANSI-standard signals first, other signals
+     second, with signals in each block ordered by their numerical
+     values on a typical POSIX platform.  */
+
+  *oursig_ok = 1;
+  switch (oursig)
+    {
+    case GDB_SIGNAL_0:
+      return 0;
+
+      /* SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM
+        are ANSI-standard signals and are always available.  */
+    case GDB_SIGNAL_INT:
+      return SIGINT;
+    case GDB_SIGNAL_ILL:
+      return SIGILL;
+    case GDB_SIGNAL_ABRT:
+      return SIGABRT;
+    case GDB_SIGNAL_FPE:
+      return SIGFPE;
+    case GDB_SIGNAL_SEGV:
+      return SIGSEGV;
+    case GDB_SIGNAL_TERM:
+      return SIGTERM;
+
+      /* All other signals need preprocessor conditionals.  */
+#if defined (SIGHUP)
+    case GDB_SIGNAL_HUP:
+      return SIGHUP;
+#endif
+#if defined (SIGQUIT)
+    case GDB_SIGNAL_QUIT:
+      return SIGQUIT;
+#endif
+#if defined (SIGTRAP)
+    case GDB_SIGNAL_TRAP:
+      return SIGTRAP;
+#endif
+#if defined (SIGEMT)
+    case GDB_SIGNAL_EMT:
+      return SIGEMT;
+#endif
+#if defined (SIGKILL)
+    case GDB_SIGNAL_KILL:
+      return SIGKILL;
+#endif
+#if defined (SIGBUS)
+    case GDB_SIGNAL_BUS:
+      return SIGBUS;
+#endif
+#if defined (SIGSYS)
+    case GDB_SIGNAL_SYS:
+      return SIGSYS;
+#endif
+#if defined (SIGPIPE)
+    case GDB_SIGNAL_PIPE:
+      return SIGPIPE;
+#endif
+#if defined (SIGALRM)
+    case GDB_SIGNAL_ALRM:
+      return SIGALRM;
+#endif
+#if defined (SIGUSR1)
+    case GDB_SIGNAL_USR1:
+      return SIGUSR1;
+#endif
+#if defined (SIGUSR2)
+    case GDB_SIGNAL_USR2:
+      return SIGUSR2;
+#endif
+#if defined (SIGCHLD) || defined (SIGCLD)
+    case GDB_SIGNAL_CHLD:
+#if defined (SIGCHLD)
+      return SIGCHLD;
+#else
+      return SIGCLD;
+#endif
+#endif /* SIGCLD or SIGCHLD */
+#if defined (SIGPWR)
+    case GDB_SIGNAL_PWR:
+      return SIGPWR;
+#endif
+#if defined (SIGWINCH)
+    case GDB_SIGNAL_WINCH:
+      return SIGWINCH;
+#endif
+#if defined (SIGURG)
+    case GDB_SIGNAL_URG:
+      return SIGURG;
+#endif
+#if defined (SIGIO)
+    case GDB_SIGNAL_IO:
+      return SIGIO;
+#endif
+#if defined (SIGPOLL)
+    case GDB_SIGNAL_POLL:
+      return SIGPOLL;
+#endif
+#if defined (SIGSTOP)
+    case GDB_SIGNAL_STOP:
+      return SIGSTOP;
+#endif
+#if defined (SIGTSTP)
+    case GDB_SIGNAL_TSTP:
+      return SIGTSTP;
+#endif
+#if defined (SIGCONT)
+    case GDB_SIGNAL_CONT:
+      return SIGCONT;
+#endif
+#if defined (SIGTTIN)
+    case GDB_SIGNAL_TTIN:
+      return SIGTTIN;
+#endif
+#if defined (SIGTTOU)
+    case GDB_SIGNAL_TTOU:
+      return SIGTTOU;
+#endif
+#if defined (SIGVTALRM)
+    case GDB_SIGNAL_VTALRM:
+      return SIGVTALRM;
+#endif
+#if defined (SIGPROF)
+    case GDB_SIGNAL_PROF:
+      return SIGPROF;
+#endif
+#if defined (SIGXCPU)
+    case GDB_SIGNAL_XCPU:
+      return SIGXCPU;
+#endif
+#if defined (SIGXFSZ)
+    case GDB_SIGNAL_XFSZ:
+      return SIGXFSZ;
+#endif
+#if defined (SIGWIND)
+    case GDB_SIGNAL_WIND:
+      return SIGWIND;
+#endif
+#if defined (SIGPHONE)
+    case GDB_SIGNAL_PHONE:
+      return SIGPHONE;
+#endif
+#if defined (SIGLOST)
+    case GDB_SIGNAL_LOST:
+      return SIGLOST;
+#endif
+#if defined (SIGWAITING)
+    case GDB_SIGNAL_WAITING:
+      return SIGWAITING;
+#endif
+#if defined (SIGCANCEL)
+    case GDB_SIGNAL_CANCEL:
+      return SIGCANCEL;
+#endif
+#if defined (SIGLWP)
+    case GDB_SIGNAL_LWP:
+      return SIGLWP;
+#endif
+#if defined (SIGDANGER)
+    case GDB_SIGNAL_DANGER:
+      return SIGDANGER;
+#endif
+#if defined (SIGGRANT)
+    case GDB_SIGNAL_GRANT:
+      return SIGGRANT;
+#endif
+#if defined (SIGRETRACT)
+    case GDB_SIGNAL_RETRACT:
+      return SIGRETRACT;
+#endif
+#if defined (SIGMSG)
+    case GDB_SIGNAL_MSG:
+      return SIGMSG;
+#endif
+#if defined (SIGSOUND)
+    case GDB_SIGNAL_SOUND:
+      return SIGSOUND;
+#endif
+#if defined (SIGSAK)
+    case GDB_SIGNAL_SAK:
+      return SIGSAK;
+#endif
+#if defined (SIGPRIO)
+    case GDB_SIGNAL_PRIO:
+      return SIGPRIO;
+#endif
+
+      /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
+#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
+    case GDB_EXC_BAD_ACCESS:
+      return _NSIG + EXC_BAD_ACCESS;
+#endif
+#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
+    case GDB_EXC_BAD_INSTRUCTION:
+      return _NSIG + EXC_BAD_INSTRUCTION;
+#endif
+#if defined (EXC_ARITHMETIC) && defined (_NSIG)
+    case GDB_EXC_ARITHMETIC:
+      return _NSIG + EXC_ARITHMETIC;
+#endif
+#if defined (EXC_EMULATION) && defined (_NSIG)
+    case GDB_EXC_EMULATION:
+      return _NSIG + EXC_EMULATION;
+#endif
+#if defined (EXC_SOFTWARE) && defined (_NSIG)
+    case GDB_EXC_SOFTWARE:
+      return _NSIG + EXC_SOFTWARE;
+#endif
+#if defined (EXC_BREAKPOINT) && defined (_NSIG)
+    case GDB_EXC_BREAKPOINT:
+      return _NSIG + EXC_BREAKPOINT;
+#endif
+
+#if defined (SIGINFO)
+    case GDB_SIGNAL_INFO:
+      return SIGINFO;
+#endif
+#if defined (SIGLIBRT)
+    case GDB_SIGNAL_LIBRT:
+      return SIGLIBRT;
+#endif
+
+    default:
+#if defined (REALTIME_LO)
+      retsig = 0;
+
+      if (oursig >= GDB_SIGNAL_REALTIME_33
+         && oursig <= GDB_SIGNAL_REALTIME_63)
+       {
+         /* This block of signals is continuous, and
+             GDB_SIGNAL_REALTIME_33 is 33 by definition.  */
+         retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_33 + 33;
+       }
+      else if (oursig == GDB_SIGNAL_REALTIME_32)
+       {
+         /* GDB_SIGNAL_REALTIME_32 isn't contiguous with
+             GDB_SIGNAL_REALTIME_33.  It is 32 by definition.  */
+         retsig = 32;
+       }
+      else if (oursig >= GDB_SIGNAL_REALTIME_64
+         && oursig <= GDB_SIGNAL_REALTIME_127)
+       {
+         /* This block of signals is continuous, and
+             GDB_SIGNAL_REALTIME_64 is 64 by definition.  */
+         retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_64 + 64;
+       }
+
+      if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
+       return retsig;
+#endif
+
+      *oursig_ok = 0;
+      return 0;
+    }
+}
+
+int
+gdb_signal_to_host_p (enum gdb_signal oursig)
+{
+  int oursig_ok;
+  do_gdb_signal_to_host (oursig, &oursig_ok);
+  return oursig_ok;
+}
+
+int
+gdb_signal_to_host (enum gdb_signal oursig)
+{
+  int oursig_ok;
+  int targ_signo = do_gdb_signal_to_host (oursig, &oursig_ok);
+  if (!oursig_ok)
+    {
+      /* The user might be trying to do "signal SIGSAK" where this system
+         doesn't have SIGSAK.  */
+      warning (_("Signal %s does not exist on this system."),
+              gdb_signal_to_name (oursig));
+      return 0;
+    }
+  else
+    return targ_signo;
+}
diff --git a/gdb/gdbsupport/symbol.h b/gdb/gdbsupport/symbol.h
new file mode 100644 (file)
index 0000000..a42d50a
--- /dev/null
@@ -0,0 +1,37 @@
+/* Declarations of common symbol functions.
+
+   Copyright (C) 2014-2019 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/>.  */
+
+#ifndef COMMON_SYMBOL_H
+#define COMMON_SYMBOL_H
+
+struct objfile;
+
+/* Find a symbol that matches NAME.  Limit the search to OBJFILE if
+   OBJFILE is non-NULL and the implementation supports limiting the
+   search to specific object files.  NAME may be mangled or demangled.
+   If a match is found, store the matching symbol's address in ADDR
+   and return zero.  Returns nonzero if no symbol matching NAME is
+   found.  Raise an exception if OBJFILE is non-NULL and the
+   implementation does not support limiting searches to specific
+   object files.  This function must be provided by the client.  */
+
+extern int find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
+                                       struct objfile *objfile);
+
+#endif /* COMMON_SYMBOL_H */
diff --git a/gdb/gdbsupport/tdesc.c b/gdb/gdbsupport/tdesc.c
new file mode 100644 (file)
index 0000000..1e2a314
--- /dev/null
@@ -0,0 +1,401 @@
+/* Target description support for GDB.
+
+   Copyright (C) 2018-2019 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 "common-defs.h"
+#include "gdbsupport/tdesc.h"
+
+tdesc_reg::tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
+                     int regnum, int save_restore_, const char *group_,
+                     int bitsize_, const char *type_)
+  : name (name_), target_regnum (regnum),
+    save_restore (save_restore_),
+    group (group_ != NULL ? group_ : ""),
+    bitsize (bitsize_),
+    type (type_ != NULL ? type_ : "<unknown>")
+{
+  /* If the register's type is target-defined, look it up now.  We may not
+     have easy access to the containing feature when we want it later.  */
+  tdesc_type = tdesc_named_type (feature, type.c_str ());
+}
+
+/* Predefined types.  */
+static tdesc_type_builtin tdesc_predefined_types[] =
+{
+  { "bool", TDESC_TYPE_BOOL },
+  { "int8", TDESC_TYPE_INT8 },
+  { "int16", TDESC_TYPE_INT16 },
+  { "int32", TDESC_TYPE_INT32 },
+  { "int64", TDESC_TYPE_INT64 },
+  { "int128", TDESC_TYPE_INT128 },
+  { "uint8", TDESC_TYPE_UINT8 },
+  { "uint16", TDESC_TYPE_UINT16 },
+  { "uint32", TDESC_TYPE_UINT32 },
+  { "uint64", TDESC_TYPE_UINT64 },
+  { "uint128", TDESC_TYPE_UINT128 },
+  { "code_ptr", TDESC_TYPE_CODE_PTR },
+  { "data_ptr", TDESC_TYPE_DATA_PTR },
+  { "ieee_half", TDESC_TYPE_IEEE_HALF },
+  { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
+  { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
+  { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
+  { "i387_ext", TDESC_TYPE_I387_EXT }
+};
+
+void tdesc_feature::accept (tdesc_element_visitor &v) const
+{
+  v.visit_pre (this);
+
+  for (const tdesc_type_up &type : types)
+    type->accept (v);
+
+  for (const tdesc_reg_up &reg : registers)
+    reg->accept (v);
+
+  v.visit_post (this);
+}
+
+bool tdesc_feature::operator== (const tdesc_feature &other) const
+{
+  if (name != other.name)
+    return false;
+
+  if (registers.size () != other.registers.size ())
+    return false;
+
+  for (int ix = 0; ix < registers.size (); ix++)
+    {
+      const tdesc_reg_up &reg1 = registers[ix];
+      const tdesc_reg_up &reg2 = other.registers[ix];
+
+      if (reg1 != reg2 && *reg1 != *reg2)
+       return false;
+      }
+
+  if (types.size () != other.types.size ())
+    return false;
+
+  for (int ix = 0; ix < types.size (); ix++)
+    {
+      const tdesc_type_up &type1 = types[ix];
+      const tdesc_type_up &type2 = other.types[ix];
+
+      if (type1 != type2 && *type1 != *type2)
+       return false;
+    }
+
+  return true;
+}
+
+/* Lookup a predefined type.  */
+
+static struct tdesc_type *
+tdesc_predefined_type (enum tdesc_type_kind kind)
+{
+  for (int ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
+    if (tdesc_predefined_types[ix].kind == kind)
+      return &tdesc_predefined_types[ix];
+
+  gdb_assert_not_reached ("bad predefined tdesc type");
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+struct tdesc_type *
+tdesc_named_type (const struct tdesc_feature *feature, const char *id)
+{
+  /* First try target-defined types.  */
+  for (const tdesc_type_up &type : feature->types)
+    if (type->name == id)
+      return type.get ();
+
+  /* Next try the predefined types.  */
+  for (int ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
+    if (tdesc_predefined_types[ix].name == id)
+      return &tdesc_predefined_types[ix];
+
+  return NULL;
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+void
+tdesc_create_reg (struct tdesc_feature *feature, const char *name,
+                 int regnum, int save_restore, const char *group,
+                 int bitsize, const char *type)
+{
+  tdesc_reg *reg = new tdesc_reg (feature, name, regnum, save_restore,
+                                 group, bitsize, type);
+
+  feature->registers.emplace_back (reg);
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+struct tdesc_type *
+tdesc_create_vector (struct tdesc_feature *feature, const char *name,
+                    struct tdesc_type *field_type, int count)
+{
+  tdesc_type_vector *type = new tdesc_type_vector (name, field_type, count);
+  feature->types.emplace_back (type);
+
+  return type;
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+tdesc_type_with_fields *
+tdesc_create_struct (struct tdesc_feature *feature, const char *name)
+{
+  tdesc_type_with_fields *type
+    = new tdesc_type_with_fields (name, TDESC_TYPE_STRUCT);
+  feature->types.emplace_back (type);
+
+  return type;
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+void
+tdesc_set_struct_size (tdesc_type_with_fields *type, int size)
+{
+  gdb_assert (type->kind == TDESC_TYPE_STRUCT);
+  gdb_assert (size > 0);
+  type->size = size;
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+tdesc_type_with_fields *
+tdesc_create_union (struct tdesc_feature *feature, const char *name)
+{
+  tdesc_type_with_fields *type
+    = new tdesc_type_with_fields (name, TDESC_TYPE_UNION);
+  feature->types.emplace_back (type);
+
+  return type;
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+tdesc_type_with_fields *
+tdesc_create_flags (struct tdesc_feature *feature, const char *name,
+                   int size)
+{
+  gdb_assert (size > 0);
+
+  tdesc_type_with_fields *type
+    = new tdesc_type_with_fields (name, TDESC_TYPE_FLAGS, size);
+  feature->types.emplace_back (type);
+
+  return type;
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+tdesc_type_with_fields *
+tdesc_create_enum (struct tdesc_feature *feature, const char *name,
+                  int size)
+{
+  gdb_assert (size > 0);
+
+  tdesc_type_with_fields *type
+    = new tdesc_type_with_fields (name, TDESC_TYPE_ENUM, size);
+  feature->types.emplace_back (type);
+
+  return type;
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+void
+tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
+                struct tdesc_type *field_type)
+{
+  gdb_assert (type->kind == TDESC_TYPE_UNION
+             || type->kind == TDESC_TYPE_STRUCT);
+
+  /* Initialize start and end so we know this is not a bit-field
+     when we print-c-tdesc.  */
+  type->fields.emplace_back (field_name, field_type, -1, -1);
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+void
+tdesc_add_typed_bitfield (tdesc_type_with_fields *type, const char *field_name,
+                         int start, int end, struct tdesc_type *field_type)
+{
+  gdb_assert (type->kind == TDESC_TYPE_STRUCT
+             || type->kind == TDESC_TYPE_FLAGS);
+  gdb_assert (start >= 0 && end >= start);
+
+  type->fields.emplace_back (field_name, field_type, start, end);
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+void
+tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
+                   int start, int end)
+{
+  struct tdesc_type *field_type;
+
+  gdb_assert (start >= 0 && end >= start);
+
+  if (type->size > 4)
+    field_type = tdesc_predefined_type (TDESC_TYPE_UINT64);
+  else
+    field_type = tdesc_predefined_type (TDESC_TYPE_UINT32);
+
+  tdesc_add_typed_bitfield (type, field_name, start, end, field_type);
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+void
+tdesc_add_flag (tdesc_type_with_fields *type, int start,
+               const char *flag_name)
+{
+  gdb_assert (type->kind == TDESC_TYPE_FLAGS
+             || type->kind == TDESC_TYPE_STRUCT);
+
+  type->fields.emplace_back (flag_name,
+                            tdesc_predefined_type (TDESC_TYPE_BOOL),
+                            start, start);
+}
+
+/* See gdbsupport/tdesc.h.  */
+
+void
+tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
+                     const char *name)
+{
+  gdb_assert (type->kind == TDESC_TYPE_ENUM);
+  type->fields.emplace_back (name,
+                            tdesc_predefined_type (TDESC_TYPE_INT32),
+                            value, -1);
+}
+
+void print_xml_feature::visit_pre (const tdesc_feature *e)
+{
+  string_appendf (*m_buffer, "<feature name=\"%s\">\n", e->name.c_str ());
+}
+
+void print_xml_feature::visit_post (const tdesc_feature *e)
+{
+  string_appendf (*m_buffer, "</feature>\n");
+}
+
+void print_xml_feature::visit (const tdesc_type_builtin *t)
+{
+  error (_("xml output is not supported for type \"%s\"."), t->name.c_str ());
+}
+
+void print_xml_feature::visit (const tdesc_type_vector *t)
+{
+  string_appendf (*m_buffer, "<vector id=\"%s\" type=\"%s\" count=\"%d\"/>\n",
+                 t->name.c_str (), t->element_type->name.c_str (), t->count);
+}
+
+void print_xml_feature::visit (const tdesc_type_with_fields *t)
+{
+  const static char *types[] = { "struct", "union", "flags", "enum" };
+
+  gdb_assert (t->kind >= TDESC_TYPE_STRUCT && t->kind <= TDESC_TYPE_ENUM);
+
+  string_appendf (*m_buffer,
+                 "<%s id=\"%s\"", types[t->kind - TDESC_TYPE_STRUCT],
+                 t->name.c_str ());
+
+  switch (t->kind)
+    {
+    case TDESC_TYPE_STRUCT:
+    case TDESC_TYPE_FLAGS:
+      if (t->size > 0)
+       string_appendf (*m_buffer, " size=\"%d\"", t->size);
+      string_appendf (*m_buffer, ">\n");
+
+      for (const tdesc_type_field &f : t->fields)
+       {
+         string_appendf (*m_buffer, "  <field name=\"%s\" ", f.name.c_str ());
+         if (f.start == -1)
+           string_appendf (*m_buffer, "type=\"%s\"/>\n",
+                           f.type->name.c_str ());
+         else
+           string_appendf (*m_buffer, "start=\"%d\" end=\"%d\"/>\n", f.start,
+                           f.end);
+       }
+      break;
+
+    case TDESC_TYPE_ENUM:
+      string_appendf (*m_buffer, ">\n");
+      for (const tdesc_type_field &f : t->fields)
+       string_appendf (*m_buffer, "  <field name=\"%s\" start=\"%d\"/>\n",
+                       f.name.c_str (), f.start);
+      break;
+
+    case TDESC_TYPE_UNION:
+      string_appendf (*m_buffer, ">\n");
+      for (const tdesc_type_field &f : t->fields)
+       string_appendf (*m_buffer, "  <field name=\"%s\" type=\"%s\"/>\n",
+                       f.name.c_str (), f.type->name.c_str ());
+      break;
+
+    default:
+      error (_("xml output is not supported for type \"%s\"."),
+            t->name.c_str ());
+    }
+
+  string_appendf (*m_buffer, "</%s>\n", types[t->kind - TDESC_TYPE_STRUCT]);
+}
+
+void print_xml_feature::visit (const tdesc_reg *r)
+{
+  string_appendf (*m_buffer,
+                 "<reg name=\"%s\" bitsize=\"%d\" type=\"%s\" regnum=\"%ld\"",
+                 r->name.c_str (), r->bitsize, r->type.c_str (),
+                 r->target_regnum);
+
+  if (r->group.length () > 0)
+    string_appendf (*m_buffer, " group=\"%s\"", r->group.c_str ());
+
+  if (r->save_restore == 0)
+    string_appendf (*m_buffer, " save-restore=\"no\"");
+
+  string_appendf (*m_buffer, "/>\n");
+}
+
+void print_xml_feature::visit_pre (const target_desc *e)
+{
+#ifndef IN_PROCESS_AGENT
+  string_appendf (*m_buffer, "<?xml version=\"1.0\"?>\n");
+  string_appendf (*m_buffer, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">\n");
+  string_appendf (*m_buffer, "<target>\n<architecture>%s</architecture>\n",
+                 tdesc_architecture_name (e));
+
+  const char *osabi = tdesc_osabi_name (e);
+  if (osabi != nullptr)
+    string_appendf (*m_buffer, "<osabi>%s</osabi>", osabi);
+#endif
+}
+
+void print_xml_feature::visit_post (const target_desc *e)
+{
+  string_appendf (*m_buffer, "</target>\n");
+}
diff --git a/gdb/gdbsupport/tdesc.h b/gdb/gdbsupport/tdesc.h
new file mode 100644 (file)
index 0000000..9eb3d5e
--- /dev/null
@@ -0,0 +1,408 @@
+/* Copyright (C) 2006-2019 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/>.  */
+
+#ifndef COMMON_TDESC_H
+#define COMMON_TDESC_H
+
+struct tdesc_feature;
+struct tdesc_type;
+struct tdesc_type_builtin;
+struct tdesc_type_vector;
+struct tdesc_type_with_fields;
+struct tdesc_reg;
+struct target_desc;
+
+/* The interface to visit different elements of target description.  */
+
+class tdesc_element_visitor
+{
+public:
+  virtual void visit_pre (const target_desc *e)
+  {}
+
+  virtual void visit_post (const target_desc *e)
+  {}
+
+  virtual void visit_pre (const tdesc_feature *e)
+  {}
+
+  virtual void visit_post (const tdesc_feature *e)
+  {}
+
+  virtual void visit (const tdesc_type_builtin *e)
+  {}
+
+  virtual void visit (const tdesc_type_vector *e)
+  {}
+
+  virtual void visit (const tdesc_type_with_fields *e)
+  {}
+
+  virtual void visit (const tdesc_reg *e)
+  {}
+};
+
+class tdesc_element
+{
+public:
+  virtual void accept (tdesc_element_visitor &v) const = 0;
+};
+
+/* An individual register from a target description.  */
+
+struct tdesc_reg : tdesc_element
+{
+  tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
+            int regnum, int save_restore_, const char *group_,
+            int bitsize_, const char *type_);
+
+  virtual ~tdesc_reg () = default;
+
+  DISABLE_COPY_AND_ASSIGN (tdesc_reg);
+
+  /* The name of this register.  In standard features, it may be
+     recognized by the architecture support code, or it may be purely
+     for the user.  */
+  std::string name;
+
+  /* The register number used by this target to refer to this
+     register.  This is used for remote p/P packets and to determine
+     the ordering of registers in the remote g/G packets.  */
+  long target_regnum;
+
+  /* If this flag is set, GDB should save and restore this register
+     around calls to an inferior function.  */
+  int save_restore;
+
+  /* The name of the register group containing this register, or empty
+     if the group should be automatically determined from the
+     register's type.  If this is "general", "float", or "vector", the
+     corresponding "info" command should display this register's
+     value.  It can be an arbitrary string, but should be limited to
+     alphanumeric characters and internal hyphens.  Currently other
+     strings are ignored (treated as empty).  */
+  std::string group;
+
+  /* The size of the register, in bits.  */
+  int bitsize;
+
+  /* The type of the register.  This string corresponds to either
+     a named type from the target description or a predefined
+     type from GDB.  */
+  std::string type;
+
+  /* The target-described type corresponding to TYPE, if found.  */
+  struct tdesc_type *tdesc_type;
+
+  void accept (tdesc_element_visitor &v) const override
+  {
+    v.visit (this);
+  }
+
+  bool operator== (const tdesc_reg &other) const
+  {
+    return (name == other.name
+       && target_regnum == other.target_regnum
+       && save_restore == other.save_restore
+       && bitsize == other.bitsize
+       && group == other.group
+       && type == other.type);
+  }
+
+  bool operator!= (const tdesc_reg &other) const
+  {
+    return !(*this == other);
+  }
+};
+
+typedef std::unique_ptr<tdesc_reg> tdesc_reg_up;
+
+enum tdesc_type_kind
+{
+  /* Predefined types.  */
+  TDESC_TYPE_BOOL,
+  TDESC_TYPE_INT8,
+  TDESC_TYPE_INT16,
+  TDESC_TYPE_INT32,
+  TDESC_TYPE_INT64,
+  TDESC_TYPE_INT128,
+  TDESC_TYPE_UINT8,
+  TDESC_TYPE_UINT16,
+  TDESC_TYPE_UINT32,
+  TDESC_TYPE_UINT64,
+  TDESC_TYPE_UINT128,
+  TDESC_TYPE_CODE_PTR,
+  TDESC_TYPE_DATA_PTR,
+  TDESC_TYPE_IEEE_HALF,
+  TDESC_TYPE_IEEE_SINGLE,
+  TDESC_TYPE_IEEE_DOUBLE,
+  TDESC_TYPE_ARM_FPA_EXT,
+  TDESC_TYPE_I387_EXT,
+
+  /* Types defined by a target feature.  */
+  TDESC_TYPE_VECTOR,
+  TDESC_TYPE_STRUCT,
+  TDESC_TYPE_UNION,
+  TDESC_TYPE_FLAGS,
+  TDESC_TYPE_ENUM
+};
+
+struct tdesc_type : tdesc_element
+{
+  tdesc_type (const std::string &name_, enum tdesc_type_kind kind_)
+    : name (name_), kind (kind_)
+  {}
+
+  virtual ~tdesc_type () = default;
+
+  DISABLE_COPY_AND_ASSIGN (tdesc_type);
+
+  /* The name of this type.  */
+  std::string name;
+
+  /* Identify the kind of this type.  */
+  enum tdesc_type_kind kind;
+
+  bool operator== (const tdesc_type &other) const
+  {
+    return name == other.name && kind == other.kind;
+  }
+
+  bool operator!= (const tdesc_type &other) const
+  {
+    return !(*this == other);
+  }
+};
+
+typedef std::unique_ptr<tdesc_type> tdesc_type_up;
+
+struct tdesc_type_builtin : tdesc_type
+{
+  tdesc_type_builtin (const std::string &name, enum tdesc_type_kind kind)
+  : tdesc_type (name, kind)
+  {}
+
+  void accept (tdesc_element_visitor &v) const override
+  {
+    v.visit (this);
+  }
+};
+
+/* tdesc_type for vector types.  */
+
+struct tdesc_type_vector : tdesc_type
+{
+  tdesc_type_vector (const std::string &name, tdesc_type *element_type_,
+                    int count_)
+  : tdesc_type (name, TDESC_TYPE_VECTOR),
+    element_type (element_type_), count (count_)
+  {}
+
+  void accept (tdesc_element_visitor &v) const override
+  {
+    v.visit (this);
+  }
+
+  struct tdesc_type *element_type;
+  int count;
+};
+
+/* A named type from a target description.  */
+
+struct tdesc_type_field
+{
+  tdesc_type_field (const std::string &name_, tdesc_type *type_,
+                   int start_, int end_)
+  : name (name_), type (type_), start (start_), end (end_)
+  {}
+
+  std::string name;
+  struct tdesc_type *type;
+  /* For non-enum-values, either both are -1 (non-bitfield), or both are
+     not -1 (bitfield).  For enum values, start is the value (which could be
+     -1), end is -1.  */
+  int start, end;
+};
+
+/* tdesc_type for struct, union, flags, and enum types.  */
+
+struct tdesc_type_with_fields : tdesc_type
+{
+  tdesc_type_with_fields (const std::string &name, tdesc_type_kind kind,
+                         int size_ = 0)
+  : tdesc_type (name, kind), size (size_)
+  {}
+
+  void accept (tdesc_element_visitor &v) const override
+  {
+    v.visit (this);
+  }
+
+  std::vector<tdesc_type_field> fields;
+  int size;
+};
+
+/* A feature from a target description.  Each feature is a collection
+   of other elements, e.g. registers and types.  */
+
+struct tdesc_feature : tdesc_element
+{
+  tdesc_feature (const std::string &name_)
+    : name (name_)
+  {}
+
+  virtual ~tdesc_feature () = default;
+
+  DISABLE_COPY_AND_ASSIGN (tdesc_feature);
+
+  /* The name of this feature.  It may be recognized by the architecture
+     support code.  */
+  std::string name;
+
+  /* The registers associated with this feature.  */
+  std::vector<tdesc_reg_up> registers;
+
+  /* The types associated with this feature.  */
+  std::vector<tdesc_type_up> types;
+
+  void accept (tdesc_element_visitor &v) const override;
+
+  bool operator== (const tdesc_feature &other) const;
+
+  bool operator!= (const tdesc_feature &other) const
+  {
+    return !(*this == other);
+  }
+};
+
+typedef std::unique_ptr<tdesc_feature> tdesc_feature_up;
+
+/* Allocate a new target_desc.  */
+target_desc *allocate_target_description (void);
+
+/* Set TARGET_DESC's architecture by NAME.  */
+void set_tdesc_architecture (target_desc *target_desc,
+                            const char *name);
+
+/* Return the architecture associated with this target description as a string,
+   or NULL if no architecture was specified.  */
+const char *tdesc_architecture_name (const struct target_desc *target_desc);
+
+/* Set TARGET_DESC's osabi by NAME.  */
+void set_tdesc_osabi (target_desc *target_desc, const char *name);
+
+/* Return the osabi associated with this target description as a string,
+   or NULL if no osabi was specified.  */
+const char *tdesc_osabi_name (const struct target_desc *target_desc);
+
+/* Return the type associated with ID in the context of FEATURE, or
+   NULL if none.  */
+struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature,
+                                    const char *id);
+
+/* Return the created feature named NAME in target description TDESC.  */
+struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc,
+                                           const char *name);
+
+/* Return the created vector tdesc_type named NAME in FEATURE.  */
+struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature,
+                                       const char *name,
+                                       struct tdesc_type *field_type,
+                                       int count);
+
+/* Return the created struct tdesc_type named NAME in FEATURE.  */
+tdesc_type_with_fields *tdesc_create_struct (struct tdesc_feature *feature,
+                                            const char *name);
+
+/* Return the created union tdesc_type named NAME in FEATURE.  */
+tdesc_type_with_fields *tdesc_create_union (struct tdesc_feature *feature,
+                                           const char *name);
+
+/* Return the created flags tdesc_type named NAME in FEATURE.  */
+tdesc_type_with_fields *tdesc_create_flags (struct tdesc_feature *feature,
+                                           const char *name,
+                                           int size);
+
+/* Return the created enum tdesc_type named NAME in FEATURE.  */
+tdesc_type_with_fields *tdesc_create_enum (struct tdesc_feature *feature,
+                                          const char *name,
+                                          int size);
+
+/* Add a new field to TYPE.  FIELD_NAME is its name, and FIELD_TYPE is
+   its type.  */
+void tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
+                     struct tdesc_type *field_type);
+
+/* Add a new bitfield to TYPE, with range START to END.  FIELD_NAME is its name,
+   and FIELD_TYPE is its type.  */
+void tdesc_add_typed_bitfield (tdesc_type_with_fields *type,
+                              const char *field_name,
+                              int start, int end,
+                              struct tdesc_type *field_type);
+
+/* Set the total length of TYPE.  Structs which contain bitfields may
+   omit the reserved bits, so the end of the last field may not
+   suffice.  */
+void tdesc_set_struct_size (tdesc_type_with_fields *type, int size);
+
+/* Add a new untyped bitfield to TYPE.
+   Untyped bitfields become either uint32 or uint64 depending on the size
+   of the underlying type.  */
+void tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
+                        int start, int end);
+
+/* A flag is just a typed(bool) single-bit bitfield.
+   This function is kept to minimize changes in generated files.  */
+void tdesc_add_flag (tdesc_type_with_fields *type, int start,
+                    const char *flag_name);
+
+/* Add field with VALUE and NAME to the enum TYPE.  */
+void tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
+                          const char *name);
+
+/* Create a register in feature FEATURE.  */
+void tdesc_create_reg (struct tdesc_feature *feature, const char *name,
+                      int regnum, int save_restore, const char *group,
+                      int bitsize, const char *type);
+
+/* Return the tdesc in string XML format.  */
+
+const char *tdesc_get_features_xml (const target_desc *tdesc);
+
+/* Print target description as xml.  */
+
+class print_xml_feature : public tdesc_element_visitor
+{
+public:
+  print_xml_feature (std::string *buffer_)
+    : m_buffer (buffer_)
+  {}
+
+  void visit_pre (const target_desc *e) override;
+  void visit_post (const target_desc *e) override;
+  void visit_pre (const tdesc_feature *e) override;
+  void visit_post (const tdesc_feature *e) override;
+  void visit (const tdesc_type_builtin *type) override;
+  void visit (const tdesc_type_vector *type) override;
+  void visit (const tdesc_type_with_fields *type) override;
+  void visit (const tdesc_reg *reg) override;
+
+private:
+  std::string *m_buffer;
+};
+
+#endif /* COMMON_TDESC_H */
diff --git a/gdb/gdbsupport/traits.h b/gdb/gdbsupport/traits.h
new file mode 100644 (file)
index 0000000..de57c19
--- /dev/null
@@ -0,0 +1,109 @@
+/* Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_TRAITS_H
+#define COMMON_TRAITS_H
+
+#include <type_traits>
+
+/* GCC does not understand __has_feature.  */
+#if !defined(__has_feature)
+# define __has_feature(x) 0
+#endif
+
+/* HAVE_IS_TRIVIALLY_COPYABLE is defined as 1 iff
+   std::is_trivially_copyable is available.  GCC only implemented it
+   in GCC 5.  */
+#if (__has_feature(is_trivially_copyable) \
+     || (defined __GNUC__ && __GNUC__ >= 5))
+# define HAVE_IS_TRIVIALLY_COPYABLE 1
+#endif
+
+/* HAVE_IS_TRIVIALLY_CONSTRUCTIBLE is defined as 1 iff
+   std::is_trivially_constructible is available.  GCC only implemented it
+   in GCC 5.  */
+#if (__has_feature(is_trivially_constructible) \
+     || (defined __GNUC__ && __GNUC__ >= 5))
+# define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1
+#endif
+
+namespace gdb {
+
+/* Pre C++14-safe (CWG 1558) version of C++17's std::void_t.  See
+   <http://en.cppreference.com/w/cpp/types/void_t>.  */
+
+template<typename... Ts>
+struct make_void { typedef void type; };
+
+template<typename... Ts>
+using void_t = typename make_void<Ts...>::type;
+
+/* A few trait helpers, mainly stolen from libstdc++.  Uppercase
+   because "and/or", etc. are reserved keywords.  */
+
+template<typename Predicate>
+struct Not : public std::integral_constant<bool, !Predicate::value>
+{};
+
+template<typename...>
+struct Or;
+
+template<>
+struct Or<> : public std::false_type
+{};
+
+template<typename B1>
+struct Or<B1> : public B1
+{};
+
+template<typename B1, typename B2>
+struct Or<B1, B2>
+  : public std::conditional<B1::value, B1, B2>::type
+{};
+
+template<typename B1,typename B2,typename B3, typename... Bn>
+struct Or<B1, B2, B3, Bn...>
+  : public std::conditional<B1::value, B1, Or<B2, B3, Bn...>>::type
+{};
+
+template<typename...>
+struct And;
+
+template<>
+struct And<> : public std::true_type
+{};
+
+template<typename B1>
+struct And<B1> : public B1
+{};
+
+template<typename B1, typename B2>
+struct And<B1, B2>
+  : public std::conditional<B1::value, B2, B1>::type
+{};
+
+template<typename B1, typename B2, typename B3, typename... Bn>
+struct And<B1, B2, B3, Bn...>
+  : public std::conditional<B1::value, And<B2, B3, Bn...>, B1>::type
+{};
+
+/* Concepts-light-like helper to make SFINAE logic easier to read.  */
+template<typename Condition>
+using Requires = typename std::enable_if<Condition::value, void>::type;
+}
+
+#endif /* COMMON_TRAITS_H */
diff --git a/gdb/gdbsupport/underlying.h b/gdb/gdbsupport/underlying.h
new file mode 100644 (file)
index 0000000..af14a36
--- /dev/null
@@ -0,0 +1,32 @@
+/* Copyright (C) 2017-2019 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/>.  */
+
+#ifndef COMMON_UNDERLYING_H
+#define COMMON_UNDERLYING_H
+
+#include <type_traits>
+
+/* Convert an enum to its underlying value.  */
+
+template<typename E>
+constexpr typename std::underlying_type<E>::type
+to_underlying (E val) noexcept
+{
+  return static_cast<typename std::underlying_type<E>::type> (val);
+}
+
+#endif
diff --git a/gdb/gdbsupport/valid-expr.h b/gdb/gdbsupport/valid-expr.h
new file mode 100644 (file)
index 0000000..c622d35
--- /dev/null
@@ -0,0 +1,108 @@
+/* Compile-time valid expression checker for GDB, the GNU debugger.
+
+   Copyright (C) 2017-2019 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/>.  */
+
+/* Helper macros used to build compile-time unit tests that make sure
+   that invalid expressions that should not compile would not compile,
+   and that expressions that should compile do compile, and have the
+   right type.  This is mainly used to verify that some utility's API
+   is really as safe as intended.  */
+
+#ifndef COMMON_VALID_EXPR_H
+#define COMMON_VALID_EXPR_H
+
+#include "gdbsupport/preprocessor.h"
+#include "gdbsupport/traits.h"
+
+/* Macro that uses SFINAE magic to detect whether the EXPR expression
+   is either valid or ill-formed, at compile time, without actually
+   producing compile-time errors.  I.e., check that bad uses of the
+   types (e.g., involving mismatching types) would be caught at
+   compile time.  If the expression is valid, also check whether the
+   expression has the right type.
+
+   EXPR must be defined in terms of some of the template parameters,
+   so that template substitution failure discards the overload instead
+   of causing a real compile error.  TYPES is thus the list of types
+   involved in the expression, and TYPENAMES is the same list, but
+   with each element prefixed by "typename".  These are passed as
+   template parameter types to the templates within the macro.
+
+   VALID is a boolean that indicates whether the expression is
+   supposed to be valid or invalid.
+
+   EXPR_TYPE is the expected type of EXPR.  Only meaningful iff VALID
+   is true.  If VALID is false, then you must pass "void" as expected
+   type.
+
+   Each invocation of the macro is wrapped in its own namespace to
+   avoid ODR violations.  The generated namespace only includes the
+   line number, so client code should wrap sets of calls in a
+   test-specific namespace too, to fully guarantee uniqueness between
+   the multiple clients in the codebase.  */
+#define CHECK_VALID_EXPR_INT(TYPENAMES, TYPES, VALID, EXPR_TYPE, EXPR) \
+  namespace CONCAT (check_valid_expr, __LINE__) {                      \
+                                                                       \
+  template<typename, typename, typename = void>                                \
+  struct is_valid_expression                                           \
+    : std::false_type {};                                              \
+                                                                       \
+  template <TYPENAMES>                                                 \
+    struct is_valid_expression<TYPES, gdb::void_t<decltype (EXPR)>>    \
+    : std::true_type {};                                               \
+                                                                       \
+  static_assert (is_valid_expression<TYPES>::value == VALID,           \
+                "");                                                   \
+                                                                       \
+  template<TYPENAMES, typename = void>                                 \
+  struct is_same_type                                                  \
+    : std::is_same<EXPR_TYPE, void> {};                                        \
+                                                                       \
+  template <TYPENAMES>                                                 \
+    struct is_same_type<TYPES, gdb::void_t<decltype (EXPR)>>           \
+    : std::is_same<EXPR_TYPE, decltype (EXPR)> {};                     \
+                                                                       \
+  static_assert (is_same_type<TYPES>::value, "");                      \
+  } /* namespace */
+
+/* A few convenience macros that support expressions involving a
+   varying numbers of types.  If you need more types, feel free to add
+   another variant.  */
+
+#define CHECK_VALID_EXPR_1(T1, VALID, EXPR_TYPE, EXPR)                 \
+  CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1),                      \
+                       ESC_PARENS (T1),                                \
+                       VALID, EXPR_TYPE, EXPR)
+
+#define CHECK_VALID_EXPR_2(T1, T2, VALID, EXPR_TYPE, EXPR)             \
+  CHECK_VALID_EXPR_INT (ESC_PARENS(typename T1, typename T2),          \
+                       ESC_PARENS (T1, T2),                            \
+                       VALID, EXPR_TYPE, EXPR)
+
+#define CHECK_VALID_EXPR_3(T1, T2, T3, VALID, EXPR_TYPE, EXPR)         \
+  CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, typename T3), \
+                       ESC_PARENS (T1, T2, T3),                                \
+                       VALID, EXPR_TYPE, EXPR)
+
+#define CHECK_VALID_EXPR_4(T1, T2, T3, T4, VALID, EXPR_TYPE, EXPR)     \
+  CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2,          \
+                                   typename T3, typename T4),          \
+                       ESC_PARENS (T1, T2, T3, T4),                    \
+                       VALID, EXPR_TYPE, EXPR)
+
+#endif /* COMMON_VALID_EXPR_H */
diff --git a/gdb/gdbsupport/vec.c b/gdb/gdbsupport/vec.c
new file mode 100644 (file)
index 0000000..a889544
--- /dev/null
@@ -0,0 +1,118 @@
+/* Vector API for GDB.
+   Copyright (C) 2004-2019 Free Software Foundation, Inc.
+   Contributed by Nathan Sidwell <nathan@codesourcery.com>
+
+   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 "common-defs.h"
+#include "vec.h"
+
+struct vec_prefix
+{
+  unsigned num;
+  unsigned alloc;
+  void *vec[1];
+};
+
+/* Calculate the new ALLOC value, making sure that abs(RESERVE) slots
+   are free.  If RESERVE < 0 grow exactly, otherwise grow
+   exponentially.  */
+
+static inline unsigned
+calculate_allocation (const struct vec_prefix *pfx, int reserve)
+{
+  unsigned alloc = 0;
+  unsigned num = 0;
+
+  if (pfx)
+    {
+      alloc = pfx->alloc;
+      num = pfx->num;
+    }
+  else if (!reserve)
+    /* If there's no prefix, and we've not requested anything, then we
+       will create a NULL vector.  */
+    return 0;
+
+  /* We must have run out of room.  */
+  gdb_assert (alloc - num < (unsigned)(reserve < 0 ? -reserve : reserve));
+
+  if (reserve < 0)
+    /* Exact size.  */
+    alloc = num + -reserve;
+  else
+    {
+      /* Exponential growth.  */
+      if (!alloc)
+       alloc = 4;
+      else if (alloc < 16)
+       /* Double when small.  */
+       alloc = alloc * 2;
+      else
+       /* Grow slower when large.  */
+       alloc = (alloc * 3 / 2);
+
+      /* If this is still too small, set it to the right size.  */
+      if (alloc < num + reserve)
+       alloc = num + reserve;
+    }
+  return alloc;
+}
+
+/* Ensure there are at least abs(RESERVE) free slots in VEC.  If
+   RESERVE < 0 grow exactly, else grow exponentially.  As a special
+   case, if VEC is NULL, and RESERVE is 0, no vector will be created.  */
+
+void *
+vec_p_reserve (void *vec, int reserve)
+{
+  return vec_o_reserve (vec, reserve,
+                       offsetof (struct vec_prefix, vec), sizeof (void *));
+}
+
+/* As vec_p_reserve, but for object vectors.  The vector's trailing
+   array is at VEC_OFFSET offset and consists of ELT_SIZE sized
+   elements.  */
+
+void *
+vec_o_reserve (void *vec, int reserve, size_t vec_offset, size_t elt_size)
+{
+  struct vec_prefix *pfx = (struct vec_prefix *) vec;
+  unsigned alloc = calculate_allocation (pfx, reserve);
+
+  if (!alloc)
+    return NULL;
+
+  vec = xrealloc (vec, vec_offset + alloc * elt_size);
+  ((struct vec_prefix *)vec)->alloc = alloc;
+  if (!pfx)
+    ((struct vec_prefix *)vec)->num = 0;
+
+  return vec;
+}
+
+#if 0
+/* Example uses.  */
+DEF_VEC_I (int);
+typedef struct X
+{
+  int i;
+} obj_t;
+typedef obj_t *ptr_t;
+
+DEF_VEC_P (ptr_t);
+DEF_VEC_O (obj_t);
+#endif
diff --git a/gdb/gdbsupport/vec.h b/gdb/gdbsupport/vec.h
new file mode 100644 (file)
index 0000000..8ac146d
--- /dev/null
@@ -0,0 +1,1150 @@
+/* Vector API for GDB.
+   Copyright (C) 2004-2019 Free Software Foundation, Inc.
+   Contributed by Nathan Sidwell <nathan@codesourcery.com>
+
+   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/>.  */
+
+#ifndef COMMON_VEC_H
+#define COMMON_VEC_H
+
+#include "diagnostics.h"
+
+/* clang has a bug that makes it warn (-Wunused-function) about unused functions
+   that are the result of the DEF_VEC_* macro expansion.  See:
+
+     https://bugs.llvm.org/show_bug.cgi?id=22712
+
+   We specifically ignore this warning for the vec functions when the compiler
+   is clang.  */
+#ifdef __clang__
+# define DIAGNOSTIC_IGNORE_UNUSED_VEC_FUNCTION \
+    DIAGNOSTIC_IGNORE_UNUSED_FUNCTION
+#else
+# define DIAGNOSTIC_IGNORE_UNUSED_VEC_FUNCTION
+#endif
+
+/* The macros here implement a set of templated vector types and
+   associated interfaces.  These templates are implemented with
+   macros, as we're not in C++ land.  The interface functions are
+   typesafe and use static inline functions, sometimes backed by
+   out-of-line generic functions.
+
+   Because of the different behavior of structure objects, scalar
+   objects and of pointers, there are three flavors, one for each of
+   these variants.  Both the structure object and pointer variants
+   pass pointers to objects around -- in the former case the pointers
+   are stored into the vector and in the latter case the pointers are
+   dereferenced and the objects copied into the vector.  The scalar
+   object variant is suitable for int-like objects, and the vector
+   elements are returned by value.
+
+   There are both 'index' and 'iterate' accessors.  The iterator
+   returns a boolean iteration condition and updates the iteration
+   variable passed by reference.  Because the iterator will be
+   inlined, the address-of can be optimized away.
+
+   The vectors are implemented using the trailing array idiom, thus
+   they are not resizeable without changing the address of the vector
+   object itself.  This means you cannot have variables or fields of
+   vector type -- always use a pointer to a vector.  The one exception
+   is the final field of a structure, which could be a vector type.
+   You will have to use the embedded_size & embedded_init calls to
+   create such objects, and they will probably not be resizeable (so
+   don't use the 'safe' allocation variants).  The trailing array
+   idiom is used (rather than a pointer to an array of data), because,
+   if we allow NULL to also represent an empty vector, empty vectors
+   occupy minimal space in the structure containing them.
+
+   Each operation that increases the number of active elements is
+   available in 'quick' and 'safe' variants.  The former presumes that
+   there is sufficient allocated space for the operation to succeed
+   (it dies if there is not).  The latter will reallocate the
+   vector, if needed.  Reallocation causes an exponential increase in
+   vector size.  If you know you will be adding N elements, it would
+   be more efficient to use the reserve operation before adding the
+   elements with the 'quick' operation.  This will ensure there are at
+   least as many elements as you ask for, it will exponentially
+   increase if there are too few spare slots.  If you want reserve a
+   specific number of slots, but do not want the exponential increase
+   (for instance, you know this is the last allocation), use a
+   negative number for reservation.  You can also create a vector of a
+   specific size from the get go.
+
+   You should prefer the push and pop operations, as they append and
+   remove from the end of the vector.  If you need to remove several
+   items in one go, use the truncate operation.  The insert and remove
+   operations allow you to change elements in the middle of the
+   vector.  There are two remove operations, one which preserves the
+   element ordering 'ordered_remove', and one which does not
+   'unordered_remove'.  The latter function copies the end element
+   into the removed slot, rather than invoke a memmove operation.  The
+   'lower_bound' function will determine where to place an item in the
+   array using insert that will maintain sorted order.
+
+   If you need to directly manipulate a vector, then the 'address'
+   accessor will return the address of the start of the vector.  Also
+   the 'space' predicate will tell you whether there is spare capacity
+   in the vector.  You will not normally need to use these two functions.
+
+   Vector types are defined using a DEF_VEC_{O,P,I}(TYPEDEF) macro.
+   Variables of vector type are declared using a VEC(TYPEDEF) macro.
+   The characters O, P and I indicate whether TYPEDEF is a pointer
+   (P), object (O) or integral (I) type.  Be careful to pick the
+   correct one, as you'll get an awkward and inefficient API if you
+   use the wrong one.  There is a check, which results in a
+   compile-time warning, for the P and I versions, but there is no
+   check for the O versions, as that is not possible in plain C.
+
+   An example of their use would be,
+
+   DEF_VEC_P(tree);   // non-managed tree vector.
+
+   struct my_struct {
+     VEC(tree) *v;      // A (pointer to) a vector of tree pointers.
+   };
+
+   struct my_struct *s;
+
+   if (VEC_length(tree, s->v)) { we have some contents }
+   VEC_safe_push(tree, s->v, decl); // append some decl onto the end
+   for (ix = 0; VEC_iterate(tree, s->v, ix, elt); ix++)
+     { do something with elt }
+
+*/
+
+/* Macros to invoke API calls.  A single macro works for both pointer
+   and object vectors, but the argument and return types might well be
+   different.  In each macro, T is the typedef of the vector elements.
+   Some of these macros pass the vector, V, by reference (by taking
+   its address), this is noted in the descriptions.  */
+
+/* Length of vector
+   unsigned VEC_T_length(const VEC(T) *v);
+
+   Return the number of active elements in V.  V can be NULL, in which
+   case zero is returned.  */
+
+#define VEC_length(T,V)        (VEC_OP(T,length)(V))
+
+
+/* Check if vector is empty
+   int VEC_T_empty(const VEC(T) *v);
+
+   Return nonzero if V is an empty vector (or V is NULL), zero otherwise.  */
+
+#define VEC_empty(T,V) (VEC_length (T,V) == 0)
+
+
+/* Get the final element of the vector.
+   T VEC_T_last(VEC(T) *v); // Integer
+   T VEC_T_last(VEC(T) *v); // Pointer
+   T *VEC_T_last(VEC(T) *v); // Object
+
+   Return the final element.  V must not be empty.  */
+
+#define VEC_last(T,V)  (VEC_OP(T,last)(V VEC_ASSERT_INFO))
+
+/* Index into vector
+   T VEC_T_index(VEC(T) *v, unsigned ix); // Integer
+   T VEC_T_index(VEC(T) *v, unsigned ix); // Pointer
+   T *VEC_T_index(VEC(T) *v, unsigned ix); // Object
+
+   Return the IX'th element.  If IX must be in the domain of V.  */
+
+#define VEC_index(T,V,I) (VEC_OP(T,index)(V,I VEC_ASSERT_INFO))
+
+/* Iterate over vector
+   int VEC_T_iterate(VEC(T) *v, unsigned ix, T &ptr); // Integer
+   int VEC_T_iterate(VEC(T) *v, unsigned ix, T &ptr); // Pointer
+   int VEC_T_iterate(VEC(T) *v, unsigned ix, T *&ptr); // Object
+
+   Return iteration condition and update PTR to point to the IX'th
+   element.  At the end of iteration, sets PTR to NULL.  Use this to
+   iterate over the elements of a vector as follows,
+
+     for (ix = 0; VEC_iterate(T,v,ix,ptr); ix++)
+       continue;  */
+
+#define VEC_iterate(T,V,I,P)   (VEC_OP(T,iterate)(V,I,&(P)))
+
+/* Allocate new vector.
+   VEC(T,A) *VEC_T_alloc(int reserve);
+
+   Allocate a new vector with space for RESERVE objects.  If RESERVE
+   is zero, NO vector is created.  */
+
+#define VEC_alloc(T,N) (VEC_OP(T,alloc)(N))
+
+/* Free a vector.
+   void VEC_T_free(VEC(T,A) *&);
+
+   Free a vector and set it to NULL.  */
+
+#define VEC_free(T,V)  (VEC_OP(T,free)(&V))
+
+/* A cleanup function for a vector.
+   void VEC_T_cleanup(void *);
+   
+   Clean up a vector.  */
+
+#define VEC_cleanup(T) (VEC_OP(T,cleanup))
+
+/* Use these to determine the required size and initialization of a
+   vector embedded within another structure (as the final member).
+
+   size_t VEC_T_embedded_size(int reserve);
+   void VEC_T_embedded_init(VEC(T) *v, int reserve);
+
+   These allow the caller to perform the memory allocation.  */
+
+#define VEC_embedded_size(T,N)  (VEC_OP(T,embedded_size)(N))
+#define VEC_embedded_init(T,O,N) (VEC_OP(T,embedded_init)(VEC_BASE(O),N))
+
+/* Copy a vector.
+   VEC(T,A) *VEC_T_copy(VEC(T) *);
+
+   Copy the live elements of a vector into a new vector.  The new and
+   old vectors need not be allocated by the same mechanism.  */
+
+#define VEC_copy(T,V) (VEC_OP(T,copy)(V))
+
+/* Merge two vectors.
+   VEC(T,A) *VEC_T_merge(VEC(T) *, VEC(T) *);
+
+   Copy the live elements of both vectors into a new vector.  The new
+   and old vectors need not be allocated by the same mechanism.  */
+#define VEC_merge(T,V1,V2) (VEC_OP(T,merge)(V1, V2))
+
+/* Determine if a vector has additional capacity.
+
+   int VEC_T_space (VEC(T) *v,int reserve)
+
+   If V has space for RESERVE additional entries, return nonzero.  You
+   usually only need to use this if you are doing your own vector
+   reallocation, for instance on an embedded vector.  This returns
+   nonzero in exactly the same circumstances that VEC_T_reserve
+   will.  */
+
+#define VEC_space(T,V,R) (VEC_OP(T,space)(V,R VEC_ASSERT_INFO))
+
+/* Reserve space.
+   int VEC_T_reserve(VEC(T,A) *&v, int reserve);
+
+   Ensure that V has at least abs(RESERVE) slots available.  The
+   signedness of RESERVE determines the reallocation behavior.  A
+   negative value will not create additional headroom beyond that
+   requested.  A positive value will create additional headroom.  Note
+   this can cause V to be reallocated.  Returns nonzero iff
+   reallocation actually occurred.  */
+
+#define VEC_reserve(T,V,R) (VEC_OP(T,reserve)(&(V),R VEC_ASSERT_INFO))
+
+/* Push object with no reallocation
+   T *VEC_T_quick_push (VEC(T) *v, T obj); // Integer
+   T *VEC_T_quick_push (VEC(T) *v, T obj); // Pointer
+   T *VEC_T_quick_push (VEC(T) *v, T *obj); // Object
+
+   Push a new element onto the end, returns a pointer to the slot
+   filled in.  For object vectors, the new value can be NULL, in which
+   case NO initialization is performed.  There must
+   be sufficient space in the vector.  */
+
+#define VEC_quick_push(T,V,O) (VEC_OP(T,quick_push)(V,O VEC_ASSERT_INFO))
+
+/* Push object with reallocation
+   T *VEC_T_safe_push (VEC(T,A) *&v, T obj); // Integer
+   T *VEC_T_safe_push (VEC(T,A) *&v, T obj); // Pointer
+   T *VEC_T_safe_push (VEC(T,A) *&v, T *obj); // Object
+
+   Push a new element onto the end, returns a pointer to the slot
+   filled in.  For object vectors, the new value can be NULL, in which
+   case NO initialization is performed.  Reallocates V, if needed.  */
+
+#define VEC_safe_push(T,V,O) (VEC_OP(T,safe_push)(&(V),O VEC_ASSERT_INFO))
+
+/* Pop element off end
+   T VEC_T_pop (VEC(T) *v);            // Integer
+   T VEC_T_pop (VEC(T) *v);            // Pointer
+   void VEC_T_pop (VEC(T) *v);         // Object
+
+   Pop the last element off the end.  Returns the element popped, for
+   pointer vectors.  */
+
+#define VEC_pop(T,V)   (VEC_OP(T,pop)(V VEC_ASSERT_INFO))
+
+/* Truncate to specific length
+   void VEC_T_truncate (VEC(T) *v, unsigned len);
+
+   Set the length as specified.  The new length must be less than or
+   equal to the current length.  This is an O(1) operation.  */
+
+#define VEC_truncate(T,V,I)            \
+       (VEC_OP(T,truncate)(V,I VEC_ASSERT_INFO))
+
+/* Grow to a specific length.
+   void VEC_T_safe_grow (VEC(T,A) *&v, int len);
+
+   Grow the vector to a specific length.  The LEN must be as
+   long or longer than the current length.  The new elements are
+   uninitialized.  */
+
+#define VEC_safe_grow(T,V,I)           \
+       (VEC_OP(T,safe_grow)(&(V),I VEC_ASSERT_INFO))
+
+/* Replace element
+   T VEC_T_replace (VEC(T) *v, unsigned ix, T val); // Integer
+   T VEC_T_replace (VEC(T) *v, unsigned ix, T val); // Pointer
+   T *VEC_T_replace (VEC(T) *v, unsigned ix, T *val);  // Object
+
+   Replace the IXth element of V with a new value, VAL.  For pointer
+   vectors returns the original value.  For object vectors returns a
+   pointer to the new value.  For object vectors the new value can be
+   NULL, in which case no overwriting of the slot is actually
+   performed.  */
+
+#define VEC_replace(T,V,I,O) (VEC_OP(T,replace)(V,I,O VEC_ASSERT_INFO))
+
+/* Insert object with no reallocation
+   T *VEC_T_quick_insert (VEC(T) *v, unsigned ix, T val); // Integer
+   T *VEC_T_quick_insert (VEC(T) *v, unsigned ix, T val); // Pointer
+   T *VEC_T_quick_insert (VEC(T) *v, unsigned ix, T *val); // Object
+
+   Insert an element, VAL, at the IXth position of V.  Return a pointer
+   to the slot created.  For vectors of object, the new value can be
+   NULL, in which case no initialization of the inserted slot takes
+   place.  There must be sufficient space.  */
+
+#define VEC_quick_insert(T,V,I,O) \
+       (VEC_OP(T,quick_insert)(V,I,O VEC_ASSERT_INFO))
+
+/* Insert object with reallocation
+   T *VEC_T_safe_insert (VEC(T,A) *&v, unsigned ix, T val); // Integer
+   T *VEC_T_safe_insert (VEC(T,A) *&v, unsigned ix, T val); // Pointer
+   T *VEC_T_safe_insert (VEC(T,A) *&v, unsigned ix, T *val); // Object
+
+   Insert an element, VAL, at the IXth position of V.  Return a pointer
+   to the slot created.  For vectors of object, the new value can be
+   NULL, in which case no initialization of the inserted slot takes
+   place.  Reallocate V, if necessary.  */
+
+#define VEC_safe_insert(T,V,I,O)       \
+       (VEC_OP(T,safe_insert)(&(V),I,O VEC_ASSERT_INFO))
+
+/* Remove element retaining order
+   T VEC_T_ordered_remove (VEC(T) *v, unsigned ix); // Integer
+   T VEC_T_ordered_remove (VEC(T) *v, unsigned ix); // Pointer
+   void VEC_T_ordered_remove (VEC(T) *v, unsigned ix); // Object
+
+   Remove an element from the IXth position of V.  Ordering of
+   remaining elements is preserved.  For pointer vectors returns the
+   removed object.  This is an O(N) operation due to a memmove.  */
+
+#define VEC_ordered_remove(T,V,I)      \
+       (VEC_OP(T,ordered_remove)(V,I VEC_ASSERT_INFO))
+
+/* Remove element destroying order
+   T VEC_T_unordered_remove (VEC(T) *v, unsigned ix); // Integer
+   T VEC_T_unordered_remove (VEC(T) *v, unsigned ix); // Pointer
+   void VEC_T_unordered_remove (VEC(T) *v, unsigned ix); // Object
+
+   Remove an element from the IXth position of V.  Ordering of
+   remaining elements is destroyed.  For pointer vectors returns the
+   removed object.  This is an O(1) operation.  */
+
+#define VEC_unordered_remove(T,V,I)    \
+       (VEC_OP(T,unordered_remove)(V,I VEC_ASSERT_INFO))
+
+/* Remove a block of elements
+   void VEC_T_block_remove (VEC(T) *v, unsigned ix, unsigned len);
+
+   Remove LEN elements starting at the IXth.  Ordering is retained.
+   This is an O(N) operation due to memmove.  */
+
+#define VEC_block_remove(T,V,I,L)      \
+       (VEC_OP(T,block_remove)(V,I,L VEC_ASSERT_INFO))
+
+/* Get the address of the array of elements
+   T *VEC_T_address (VEC(T) v)
+
+   If you need to directly manipulate the array (for instance, you
+   want to feed it to qsort), use this accessor.  */
+
+#define VEC_address(T,V)               (VEC_OP(T,address)(V))
+
+/* Find the first index in the vector not less than the object.
+   unsigned VEC_T_lower_bound (VEC(T) *v, const T val,
+                               int (*lessthan) (const T, const T)); // Integer
+   unsigned VEC_T_lower_bound (VEC(T) *v, const T val,
+                               int (*lessthan) (const T, const T)); // Pointer
+   unsigned VEC_T_lower_bound (VEC(T) *v, const T *val,
+                               int (*lessthan) (const T*, const T*)); // Object
+
+   Find the first position in which VAL could be inserted without
+   changing the ordering of V.  LESSTHAN is a function that returns
+   true if the first argument is strictly less than the second.  */
+
+#define VEC_lower_bound(T,V,O,LT)    \
+       (VEC_OP(T,lower_bound)(V,O,LT VEC_ASSERT_INFO))
+
+/* Reallocate an array of elements with prefix.  */
+extern void *vec_p_reserve (void *, int);
+extern void *vec_o_reserve (void *, int, size_t, size_t);
+#define vec_free_(V) xfree (V)
+
+#define VEC_ASSERT_INFO ,__FILE__,__LINE__
+#define VEC_ASSERT_DECL ,const char *file_,unsigned line_
+#define VEC_ASSERT_PASS ,file_,line_
+#define vec_assert(expr, op) \
+  ((void)((expr) ? 0 : (gdb_assert_fail (op, file_, line_, \
+                                        FUNCTION_NAME), 0)))
+
+#define VEC(T) VEC_##T
+#define VEC_OP(T,OP) VEC_##T##_##OP
+
+#define VEC_T(T)                                                         \
+typedef struct VEC(T)                                                    \
+{                                                                        \
+  unsigned num;                                                                  \
+  unsigned alloc;                                                        \
+  T vec[1];                                                              \
+} VEC(T)
+
+/* Vector of integer-like object.  */
+#define DEF_VEC_I(T)                                                     \
+DIAGNOSTIC_PUSH                                                          \
+DIAGNOSTIC_IGNORE_UNUSED_VEC_FUNCTION                                    \
+static inline void VEC_OP (T,must_be_integral_type) (void)               \
+{                                                                        \
+  (void)~(T)0;                                                           \
+}                                                                        \
+                                                                         \
+VEC_T(T);                                                                \
+DEF_VEC_FUNC_P(T)                                                        \
+DEF_VEC_ALLOC_FUNC_I(T)                                                          \
+DIAGNOSTIC_POP                                                           \
+struct vec_swallow_trailing_semi
+
+/* Vector of pointer to object.  */
+#define DEF_VEC_P(T)                                                     \
+DIAGNOSTIC_PUSH                                                          \
+DIAGNOSTIC_IGNORE_UNUSED_VEC_FUNCTION                                    \
+static inline void VEC_OP (T,must_be_pointer_type) (void)                \
+{                                                                        \
+  (void)((T)1 == (void *)1);                                             \
+}                                                                        \
+                                                                         \
+VEC_T(T);                                                                \
+DEF_VEC_FUNC_P(T)                                                        \
+DEF_VEC_ALLOC_FUNC_P(T)                                                          \
+DIAGNOSTIC_POP                                                           \
+struct vec_swallow_trailing_semi
+
+/* Vector of object.  */
+#define DEF_VEC_O(T)                                                     \
+DIAGNOSTIC_PUSH                                                          \
+DIAGNOSTIC_IGNORE_UNUSED_VEC_FUNCTION                                    \
+VEC_T(T);                                                                \
+DEF_VEC_FUNC_O(T)                                                        \
+DEF_VEC_ALLOC_FUNC_O(T)                                                          \
+DIAGNOSTIC_POP                                                           \
+struct vec_swallow_trailing_semi
+
+/* Avoid offsetof (or its usual C implementation) as it triggers
+   -Winvalid-offsetof warnings with enum_flags types with G++ <= 4.4,
+   even though those types are memcpyable.  This requires allocating a
+   dummy local VEC in all routines that use this, but that has the
+   advantage that it only works if T is default constructible, which
+   is exactly a check we want, to keep C compatibility.  */
+#define vec_offset(T, VPTR) ((size_t) ((char *) &(VPTR)->vec - (char *) VPTR))
+
+#define DEF_VEC_ALLOC_FUNC_I(T)                                                  \
+static inline VEC(T) *VEC_OP (T,alloc)                                   \
+     (int alloc_)                                                        \
+{                                                                        \
+  VEC(T) dummy;                                                                  \
+                                                                         \
+  /* We must request exact size allocation, hence the negation.  */      \
+  return (VEC(T) *) vec_o_reserve (NULL, -alloc_,                        \
+                                   vec_offset (T, &dummy), sizeof (T));          \
+}                                                                        \
+                                                                         \
+static inline VEC(T) *VEC_OP (T,copy) (VEC(T) *vec_)                     \
+{                                                                        \
+  size_t len_ = vec_ ? vec_->num : 0;                                    \
+  VEC (T) *new_vec_ = NULL;                                              \
+                                                                         \
+  if (len_)                                                              \
+    {                                                                    \
+      VEC(T) dummy;                                                      \
+                                                                         \
+      /* We must request exact size allocation, hence the negation.  */          \
+      new_vec_ = (VEC (T) *)                                             \
+       vec_o_reserve (NULL, -len_, vec_offset (T, &dummy), sizeof (T));        \
+                                                                         \
+      new_vec_->num = len_;                                              \
+      memcpy (new_vec_->vec, vec_->vec, sizeof (T) * len_);              \
+    }                                                                    \
+  return new_vec_;                                                       \
+}                                                                        \
+                                                                         \
+static inline VEC(T) *VEC_OP (T,merge) (VEC(T) *vec1_, VEC(T) *vec2_)    \
+{                                                                        \
+  if (vec1_ && vec2_)                                                    \
+    {                                                                    \
+      VEC(T) dummy;                                                      \
+      size_t len_ = vec1_->num + vec2_->num;                             \
+      VEC (T) *new_vec_ = NULL;                                                  \
+                                                                         \
+      /* We must request exact size allocation, hence the negation.  */          \
+      new_vec_ = (VEC (T) *)                                             \
+       vec_o_reserve (NULL, -len_, vec_offset (T, &dummy), sizeof (T));          \
+                                                                         \
+      new_vec_->num = len_;                                              \
+      memcpy (new_vec_->vec, vec1_->vec, sizeof (T) * vec1_->num);       \
+      memcpy (new_vec_->vec + vec1_->num, vec2_->vec,                    \
+             sizeof (T) * vec2_->num);                                   \
+                                                                         \
+      return new_vec_;                                                   \
+    }                                                                    \
+  else                                                                   \
+    return VEC_copy (T, vec1_ ? vec1_ : vec2_);                                  \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,free)                                       \
+     (VEC(T) **vec_)                                                     \
+{                                                                        \
+  if (*vec_)                                                             \
+    vec_free_ (*vec_);                                                   \
+  *vec_ = NULL;                                                                  \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,cleanup)                                    \
+     (void *arg_)                                                        \
+{                                                                        \
+  VEC(T) **vec_ = (VEC(T) **) arg_;                                      \
+  if (*vec_)                                                             \
+    vec_free_ (*vec_);                                                   \
+  *vec_ = NULL;                                                                  \
+}                                                                        \
+                                                                         \
+static inline int VEC_OP (T,reserve)                                     \
+     (VEC(T) **vec_, int alloc_ VEC_ASSERT_DECL)                         \
+{                                                                        \
+  VEC(T) dummy;                                                                  \
+  int extend = !VEC_OP (T,space)                                         \
+       (*vec_, alloc_ < 0 ? -alloc_ : alloc_ VEC_ASSERT_PASS);           \
+                                                                         \
+  if (extend)                                                            \
+    *vec_ = (VEC(T) *) vec_o_reserve (*vec_, alloc_,                     \
+                                     vec_offset (T, &dummy), sizeof (T)); \
+                                                                         \
+  return extend;                                                         \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,safe_grow)                                          \
+     (VEC(T) **vec_, int size_ VEC_ASSERT_DECL)                                  \
+{                                                                        \
+  vec_assert (size_ >= 0 && VEC_OP(T,length) (*vec_) <= (unsigned)size_,  \
+       "safe_grow");                                                     \
+  VEC_OP (T,reserve) (vec_, (int)(*vec_ ? (*vec_)->num : 0) - size_      \
+                       VEC_ASSERT_PASS);                                 \
+  (*vec_)->num = size_;                                                          \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,safe_push)                                    \
+     (VEC(T) **vec_, const T obj_ VEC_ASSERT_DECL)                       \
+{                                                                        \
+  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
+                                                                         \
+  return VEC_OP (T,quick_push) (*vec_, obj_ VEC_ASSERT_PASS);            \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,safe_insert)                                          \
+     (VEC(T) **vec_, unsigned ix_, const T obj_ VEC_ASSERT_DECL)         \
+{                                                                        \
+  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
+                                                                         \
+  return VEC_OP (T,quick_insert) (*vec_, ix_, obj_ VEC_ASSERT_PASS);     \
+}
+
+#define DEF_VEC_FUNC_P(T)                                                \
+static inline unsigned VEC_OP (T,length) (const VEC(T) *vec_)            \
+{                                                                        \
+  return vec_ ? vec_->num : 0;                                           \
+}                                                                        \
+                                                                         \
+static inline T VEC_OP (T,last)                                                  \
+       (const VEC(T) *vec_ VEC_ASSERT_DECL)                              \
+{                                                                        \
+  vec_assert (vec_ && vec_->num, "last");                                \
+                                                                         \
+  return vec_->vec[vec_->num - 1];                                       \
+}                                                                        \
+                                                                         \
+static inline T VEC_OP (T,index)                                         \
+     (const VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                          \
+{                                                                        \
+  vec_assert (vec_ && ix_ < vec_->num, "index");                         \
+                                                                         \
+  return vec_->vec[ix_];                                                 \
+}                                                                        \
+                                                                         \
+static inline int VEC_OP (T,iterate)                                     \
+     (const VEC(T) *vec_, unsigned ix_, T *ptr)                                  \
+{                                                                        \
+  if (vec_ && ix_ < vec_->num)                                           \
+    {                                                                    \
+      *ptr = vec_->vec[ix_];                                             \
+      return 1;                                                                  \
+    }                                                                    \
+  else                                                                   \
+    {                                                                    \
+      *ptr = (T) 0;                                                      \
+      return 0;                                                                  \
+    }                                                                    \
+}                                                                        \
+                                                                         \
+static inline size_t VEC_OP (T,embedded_size)                            \
+     (int alloc_)                                                        \
+{                                                                        \
+  VEC(T) dummy;                                                                  \
+                                                                         \
+  return vec_offset (T, &dummy) + alloc_ * sizeof(T);                    \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,embedded_init)                              \
+     (VEC(T) *vec_, int alloc_)                                                  \
+{                                                                        \
+  vec_->num = 0;                                                         \
+  vec_->alloc = alloc_;                                                          \
+}                                                                        \
+                                                                         \
+static inline int VEC_OP (T,space)                                       \
+     (VEC(T) *vec_, int alloc_ VEC_ASSERT_DECL)                                  \
+{                                                                        \
+  vec_assert (alloc_ >= 0, "space");                                     \
+  return vec_ ? vec_->alloc - vec_->num >= (unsigned)alloc_ : !alloc_;   \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,quick_push)                                   \
+     (VEC(T) *vec_, T obj_ VEC_ASSERT_DECL)                              \
+{                                                                        \
+  T *slot_;                                                              \
+                                                                         \
+  vec_assert (vec_->num < vec_->alloc, "quick_push");                    \
+  slot_ = &vec_->vec[vec_->num++];                                       \
+  *slot_ = obj_;                                                         \
+                                                                         \
+  return slot_;                                                                  \
+}                                                                        \
+                                                                         \
+static inline T VEC_OP (T,pop) (VEC(T) *vec_ VEC_ASSERT_DECL)            \
+{                                                                        \
+  T obj_;                                                                \
+                                                                         \
+  vec_assert (vec_->num, "pop");                                         \
+  obj_ = vec_->vec[--vec_->num];                                         \
+                                                                         \
+  return obj_;                                                           \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,truncate)                                   \
+     (VEC(T) *vec_, unsigned size_ VEC_ASSERT_DECL)                      \
+{                                                                        \
+  vec_assert (vec_ ? vec_->num >= size_ : !size_, "truncate");           \
+  if (vec_)                                                              \
+    vec_->num = size_;                                                   \
+}                                                                        \
+                                                                         \
+static inline T VEC_OP (T,replace)                                       \
+     (VEC(T) *vec_, unsigned ix_, T obj_ VEC_ASSERT_DECL)                \
+{                                                                        \
+  T old_obj_;                                                            \
+                                                                         \
+  vec_assert (ix_ < vec_->num, "replace");                               \
+  old_obj_ = vec_->vec[ix_];                                             \
+  vec_->vec[ix_] = obj_;                                                 \
+                                                                         \
+  return old_obj_;                                                       \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,quick_insert)                                 \
+     (VEC(T) *vec_, unsigned ix_, T obj_ VEC_ASSERT_DECL)                \
+{                                                                        \
+  T *slot_;                                                              \
+                                                                         \
+  vec_assert (vec_->num < vec_->alloc && ix_ <= vec_->num, "quick_insert"); \
+  slot_ = &vec_->vec[ix_];                                               \
+  memmove (slot_ + 1, slot_, (vec_->num++ - ix_) * sizeof (T));                  \
+  *slot_ = obj_;                                                         \
+                                                                         \
+  return slot_;                                                                  \
+}                                                                        \
+                                                                         \
+static inline T VEC_OP (T,ordered_remove)                                \
+     (VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                        \
+{                                                                        \
+  T *slot_;                                                              \
+  T obj_;                                                                \
+                                                                         \
+  vec_assert (ix_ < vec_->num, "ordered_remove");                        \
+  slot_ = &vec_->vec[ix_];                                               \
+  obj_ = *slot_;                                                         \
+  memmove (slot_, slot_ + 1, (--vec_->num - ix_) * sizeof (T));                  \
+                                                                         \
+  return obj_;                                                           \
+}                                                                        \
+                                                                         \
+static inline T VEC_OP (T,unordered_remove)                              \
+     (VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                        \
+{                                                                        \
+  T *slot_;                                                              \
+  T obj_;                                                                \
+                                                                         \
+  vec_assert (ix_ < vec_->num, "unordered_remove");                      \
+  slot_ = &vec_->vec[ix_];                                               \
+  obj_ = *slot_;                                                         \
+  *slot_ = vec_->vec[--vec_->num];                                       \
+                                                                         \
+  return obj_;                                                           \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,block_remove)                               \
+     (VEC(T) *vec_, unsigned ix_, unsigned len_ VEC_ASSERT_DECL)         \
+{                                                                        \
+  T *slot_;                                                              \
+                                                                         \
+  vec_assert (ix_ + len_ <= vec_->num, "block_remove");                          \
+  slot_ = &vec_->vec[ix_];                                               \
+  vec_->num -= len_;                                                     \
+  memmove (slot_, slot_ + len_, (vec_->num - ix_) * sizeof (T));         \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,address)                                      \
+     (VEC(T) *vec_)                                                      \
+{                                                                        \
+  return vec_ ? vec_->vec : 0;                                           \
+}                                                                        \
+                                                                         \
+static inline unsigned VEC_OP (T,lower_bound)                            \
+     (VEC(T) *vec_, const T obj_,                                        \
+      int (*lessthan_)(const T, const T) VEC_ASSERT_DECL)                \
+{                                                                        \
+   unsigned int len_ = VEC_OP (T, length) (vec_);                        \
+   unsigned int half_, middle_;                                                  \
+   unsigned int first_ = 0;                                              \
+   while (len_ > 0)                                                      \
+     {                                                                   \
+        T middle_elem_;                                                          \
+        half_ = len_ >> 1;                                               \
+        middle_ = first_;                                                \
+        middle_ += half_;                                                \
+        middle_elem_ = VEC_OP (T,index) (vec_, middle_ VEC_ASSERT_PASS);  \
+        if (lessthan_ (middle_elem_, obj_))                              \
+          {                                                              \
+             first_ = middle_;                                           \
+             ++first_;                                                   \
+             len_ = len_ - half_ - 1;                                    \
+          }                                                              \
+        else                                                             \
+          len_ = half_;                                                          \
+     }                                                                   \
+   return first_;                                                        \
+}
+
+#define DEF_VEC_ALLOC_FUNC_P(T)                                                  \
+static inline VEC(T) *VEC_OP (T,alloc)                                   \
+     (int alloc_)                                                        \
+{                                                                        \
+  /* We must request exact size allocation, hence the negation.  */      \
+  return (VEC(T) *) vec_p_reserve (NULL, -alloc_);                       \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,free)                                       \
+     (VEC(T) **vec_)                                                     \
+{                                                                        \
+  if (*vec_)                                                             \
+    vec_free_ (*vec_);                                                   \
+  *vec_ = NULL;                                                                  \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,cleanup)                                    \
+     (void *arg_)                                                        \
+{                                                                        \
+  VEC(T) **vec_ = (VEC(T) **) arg_;                                      \
+  if (*vec_)                                                             \
+    vec_free_ (*vec_);                                                   \
+  *vec_ = NULL;                                                                  \
+}                                                                        \
+                                                                         \
+static inline VEC(T) *VEC_OP (T,copy) (VEC(T) *vec_)                     \
+{                                                                        \
+  size_t len_ = vec_ ? vec_->num : 0;                                    \
+  VEC (T) *new_vec_ = NULL;                                              \
+                                                                         \
+  if (len_)                                                              \
+    {                                                                    \
+      /* We must request exact size allocation, hence the negation.  */          \
+      new_vec_ = (VEC (T) *)(vec_p_reserve (NULL, -len_));               \
+                                                                         \
+      new_vec_->num = len_;                                              \
+      memcpy (new_vec_->vec, vec_->vec, sizeof (T) * len_);              \
+    }                                                                    \
+  return new_vec_;                                                       \
+}                                                                        \
+                                                                         \
+static inline VEC(T) *VEC_OP (T,merge) (VEC(T) *vec1_, VEC(T) *vec2_)    \
+{                                                                        \
+  if (vec1_ && vec2_)                                                    \
+    {                                                                    \
+      size_t len_ = vec1_->num + vec2_->num;                             \
+      VEC (T) *new_vec_ = NULL;                                                  \
+                                                                         \
+      /* We must request exact size allocation, hence the negation.  */          \
+      new_vec_ = (VEC (T) *)(vec_p_reserve (NULL, -len_));               \
+                                                                         \
+      new_vec_->num = len_;                                              \
+      memcpy (new_vec_->vec, vec1_->vec, sizeof (T) * vec1_->num);       \
+      memcpy (new_vec_->vec + vec1_->num, vec2_->vec,                    \
+             sizeof (T) * vec2_->num);                                   \
+                                                                         \
+      return new_vec_;                                                   \
+    }                                                                    \
+  else                                                                   \
+    return VEC_copy (T, vec1_ ? vec1_ : vec2_);                                  \
+}                                                                        \
+                                                                         \
+static inline int VEC_OP (T,reserve)                                     \
+     (VEC(T) **vec_, int alloc_ VEC_ASSERT_DECL)                         \
+{                                                                        \
+  int extend = !VEC_OP (T,space)                                         \
+       (*vec_, alloc_ < 0 ? -alloc_ : alloc_ VEC_ASSERT_PASS);           \
+                                                                         \
+  if (extend)                                                            \
+    *vec_ = (VEC(T) *) vec_p_reserve (*vec_, alloc_);                    \
+                                                                         \
+  return extend;                                                         \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,safe_grow)                                          \
+     (VEC(T) **vec_, int size_ VEC_ASSERT_DECL)                                  \
+{                                                                        \
+  vec_assert (size_ >= 0 && VEC_OP(T,length) (*vec_) <= (unsigned)size_,  \
+       "safe_grow");                                                     \
+  VEC_OP (T,reserve)                                                     \
+       (vec_, (int)(*vec_ ? (*vec_)->num : 0) - size_ VEC_ASSERT_PASS);  \
+  (*vec_)->num = size_;                                                          \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,safe_push)                                    \
+     (VEC(T) **vec_, T obj_ VEC_ASSERT_DECL)                             \
+{                                                                        \
+  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
+                                                                         \
+  return VEC_OP (T,quick_push) (*vec_, obj_ VEC_ASSERT_PASS);            \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,safe_insert)                                          \
+     (VEC(T) **vec_, unsigned ix_, T obj_ VEC_ASSERT_DECL)               \
+{                                                                        \
+  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
+                                                                         \
+  return VEC_OP (T,quick_insert) (*vec_, ix_, obj_ VEC_ASSERT_PASS);     \
+}
+
+#define DEF_VEC_FUNC_O(T)                                                \
+static inline unsigned VEC_OP (T,length) (const VEC(T) *vec_)            \
+{                                                                        \
+  return vec_ ? vec_->num : 0;                                           \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,last) (VEC(T) *vec_ VEC_ASSERT_DECL)                  \
+{                                                                        \
+  vec_assert (vec_ && vec_->num, "last");                                \
+                                                                         \
+  return &vec_->vec[vec_->num - 1];                                      \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,index)                                        \
+     (VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                        \
+{                                                                        \
+  vec_assert (vec_ && ix_ < vec_->num, "index");                         \
+                                                                         \
+  return &vec_->vec[ix_];                                                \
+}                                                                        \
+                                                                         \
+static inline int VEC_OP (T,iterate)                                     \
+     (VEC(T) *vec_, unsigned ix_, T **ptr)                               \
+{                                                                        \
+  if (vec_ && ix_ < vec_->num)                                           \
+    {                                                                    \
+      *ptr = &vec_->vec[ix_];                                            \
+      return 1;                                                                  \
+    }                                                                    \
+  else                                                                   \
+    {                                                                    \
+      *ptr = 0;                                                                  \
+      return 0;                                                                  \
+    }                                                                    \
+}                                                                        \
+                                                                         \
+static inline size_t VEC_OP (T,embedded_size)                            \
+     (int alloc_)                                                        \
+{                                                                        \
+  VEC(T) dummy;                                                                  \
+                                                                         \
+  return vec_offset (T, &dummy) + alloc_ * sizeof(T);                    \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,embedded_init)                              \
+     (VEC(T) *vec_, int alloc_)                                                  \
+{                                                                        \
+  vec_->num = 0;                                                         \
+  vec_->alloc = alloc_;                                                          \
+}                                                                        \
+                                                                         \
+static inline int VEC_OP (T,space)                                       \
+     (VEC(T) *vec_, int alloc_ VEC_ASSERT_DECL)                                  \
+{                                                                        \
+  vec_assert (alloc_ >= 0, "space");                                     \
+  return vec_ ? vec_->alloc - vec_->num >= (unsigned)alloc_ : !alloc_;   \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,quick_push)                                   \
+     (VEC(T) *vec_, const T *obj_ VEC_ASSERT_DECL)                       \
+{                                                                        \
+  T *slot_;                                                              \
+                                                                         \
+  vec_assert (vec_->num < vec_->alloc, "quick_push");                    \
+  slot_ = &vec_->vec[vec_->num++];                                       \
+  if (obj_)                                                              \
+    *slot_ = *obj_;                                                      \
+                                                                         \
+  return slot_;                                                                  \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,pop) (VEC(T) *vec_ VEC_ASSERT_DECL)         \
+{                                                                        \
+  vec_assert (vec_->num, "pop");                                         \
+  --vec_->num;                                                           \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,truncate)                                   \
+     (VEC(T) *vec_, unsigned size_ VEC_ASSERT_DECL)                      \
+{                                                                        \
+  vec_assert (vec_ ? vec_->num >= size_ : !size_, "truncate");           \
+  if (vec_)                                                              \
+    vec_->num = size_;                                                   \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,replace)                                      \
+     (VEC(T) *vec_, unsigned ix_, const T *obj_ VEC_ASSERT_DECL)         \
+{                                                                        \
+  T *slot_;                                                              \
+                                                                         \
+  vec_assert (ix_ < vec_->num, "replace");                               \
+  slot_ = &vec_->vec[ix_];                                               \
+  if (obj_)                                                              \
+    *slot_ = *obj_;                                                      \
+                                                                         \
+  return slot_;                                                                  \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,quick_insert)                                 \
+     (VEC(T) *vec_, unsigned ix_, const T *obj_ VEC_ASSERT_DECL)         \
+{                                                                        \
+  T *slot_;                                                              \
+                                                                         \
+  vec_assert (vec_->num < vec_->alloc && ix_ <= vec_->num, "quick_insert"); \
+  slot_ = &vec_->vec[ix_];                                               \
+  memmove (slot_ + 1, slot_, (vec_->num++ - ix_) * sizeof (T));                  \
+  if (obj_)                                                              \
+    *slot_ = *obj_;                                                      \
+                                                                         \
+  return slot_;                                                                  \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,ordered_remove)                             \
+     (VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                        \
+{                                                                        \
+  T *slot_;                                                              \
+                                                                         \
+  vec_assert (ix_ < vec_->num, "ordered_remove");                        \
+  slot_ = &vec_->vec[ix_];                                               \
+  memmove (slot_, slot_ + 1, (--vec_->num - ix_) * sizeof (T));                  \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,unordered_remove)                           \
+     (VEC(T) *vec_, unsigned ix_ VEC_ASSERT_DECL)                        \
+{                                                                        \
+  vec_assert (ix_ < vec_->num, "unordered_remove");                      \
+  vec_->vec[ix_] = vec_->vec[--vec_->num];                               \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,block_remove)                               \
+     (VEC(T) *vec_, unsigned ix_, unsigned len_ VEC_ASSERT_DECL)         \
+{                                                                        \
+  T *slot_;                                                              \
+                                                                         \
+  vec_assert (ix_ + len_ <= vec_->num, "block_remove");                          \
+  slot_ = &vec_->vec[ix_];                                               \
+  vec_->num -= len_;                                                     \
+  memmove (slot_, slot_ + len_, (vec_->num - ix_) * sizeof (T));         \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,address)                                      \
+     (VEC(T) *vec_)                                                      \
+{                                                                        \
+  return vec_ ? vec_->vec : 0;                                           \
+}                                                                        \
+                                                                         \
+static inline unsigned VEC_OP (T,lower_bound)                            \
+     (VEC(T) *vec_, const T *obj_,                                       \
+      int (*lessthan_)(const T *, const T *) VEC_ASSERT_DECL)            \
+{                                                                        \
+   unsigned int len_ = VEC_OP (T, length) (vec_);                        \
+   unsigned int half_, middle_;                                                  \
+   unsigned int first_ = 0;                                              \
+   while (len_ > 0)                                                      \
+     {                                                                   \
+        T *middle_elem_;                                                 \
+        half_ = len_ >> 1;                                               \
+        middle_ = first_;                                                \
+        middle_ += half_;                                                \
+        middle_elem_ = VEC_OP (T,index) (vec_, middle_ VEC_ASSERT_PASS);  \
+        if (lessthan_ (middle_elem_, obj_))                              \
+          {                                                              \
+             first_ = middle_;                                           \
+             ++first_;                                                   \
+             len_ = len_ - half_ - 1;                                    \
+          }                                                              \
+        else                                                             \
+          len_ = half_;                                                          \
+     }                                                                   \
+   return first_;                                                        \
+}
+
+#define DEF_VEC_ALLOC_FUNC_O(T)                                                  \
+static inline VEC(T) *VEC_OP (T,alloc)                                   \
+     (int alloc_)                                                        \
+{                                                                        \
+  VEC(T) dummy;                                                                  \
+                                                                         \
+  /* We must request exact size allocation, hence the negation.  */      \
+  return (VEC(T) *) vec_o_reserve (NULL, -alloc_,                        \
+                                   vec_offset (T, &dummy), sizeof (T));          \
+}                                                                        \
+                                                                         \
+static inline VEC(T) *VEC_OP (T,copy) (VEC(T) *vec_)                     \
+{                                                                        \
+  size_t len_ = vec_ ? vec_->num : 0;                                    \
+  VEC (T) *new_vec_ = NULL;                                              \
+                                                                         \
+  if (len_)                                                              \
+    {                                                                    \
+      VEC(T) dummy;                                                      \
+                                                                         \
+      /* We must request exact size allocation, hence the negation.  */          \
+      new_vec_ = (VEC (T) *)                                             \
+       vec_o_reserve  (NULL, -len_, vec_offset (T, &dummy), sizeof (T)); \
+                                                                         \
+      new_vec_->num = len_;                                              \
+      memcpy (new_vec_->vec, vec_->vec, sizeof (T) * len_);              \
+    }                                                                    \
+  return new_vec_;                                                       \
+}                                                                        \
+                                                                         \
+static inline VEC(T) *VEC_OP (T,merge) (VEC(T) *vec1_, VEC(T) *vec2_)    \
+{                                                                        \
+  if (vec1_ && vec2_)                                                    \
+    {                                                                    \
+      VEC(T) dummy;                                                      \
+      size_t len_ = vec1_->num + vec2_->num;                             \
+      VEC (T) *new_vec_ = NULL;                                                  \
+                                                                         \
+      /* We must request exact size allocation, hence the negation.  */          \
+      new_vec_ = (VEC (T) *)                                             \
+       vec_o_reserve (NULL, -len_, vec_offset (T, &dummy), sizeof (T));  \
+                                                                         \
+      new_vec_->num = len_;                                              \
+      memcpy (new_vec_->vec, vec1_->vec, sizeof (T) * vec1_->num);       \
+      memcpy (new_vec_->vec + vec1_->num, vec2_->vec,                    \
+             sizeof (T) * vec2_->num);                                   \
+                                                                         \
+      return new_vec_;                                                   \
+    }                                                                    \
+  else                                                                   \
+    return VEC_copy (T, vec1_ ? vec1_ : vec2_);                                  \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,free)                                       \
+     (VEC(T) **vec_)                                                     \
+{                                                                        \
+  if (*vec_)                                                             \
+    vec_free_ (*vec_);                                                   \
+  *vec_ = NULL;                                                                  \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,cleanup)                                    \
+     (void *arg_)                                                        \
+{                                                                        \
+  VEC(T) **vec_ = (VEC(T) **) arg_;                                      \
+  if (*vec_)                                                             \
+    vec_free_ (*vec_);                                                   \
+  *vec_ = NULL;                                                                  \
+}                                                                        \
+                                                                         \
+static inline int VEC_OP (T,reserve)                                     \
+     (VEC(T) **vec_, int alloc_ VEC_ASSERT_DECL)                         \
+{                                                                        \
+  VEC(T) dummy;                                                                  \
+  int extend = !VEC_OP (T,space) (*vec_, alloc_ < 0 ? -alloc_ : alloc_   \
+                                 VEC_ASSERT_PASS);                       \
+                                                                         \
+  if (extend)                                                            \
+    *vec_ = (VEC(T) *)                                                   \
+      vec_o_reserve (*vec_, alloc_, vec_offset (T, &dummy), sizeof (T));  \
+                                                                         \
+  return extend;                                                         \
+}                                                                        \
+                                                                         \
+static inline void VEC_OP (T,safe_grow)                                          \
+     (VEC(T) **vec_, int size_ VEC_ASSERT_DECL)                                  \
+{                                                                        \
+  vec_assert (size_ >= 0 && VEC_OP(T,length) (*vec_) <= (unsigned)size_,  \
+       "safe_grow");                                                     \
+  VEC_OP (T,reserve)                                                     \
+       (vec_, (int)(*vec_ ? (*vec_)->num : 0) - size_ VEC_ASSERT_PASS);  \
+  (*vec_)->num = size_;                                                          \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,safe_push)                                    \
+     (VEC(T) **vec_, const T *obj_ VEC_ASSERT_DECL)                      \
+{                                                                        \
+  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
+                                                                         \
+  return VEC_OP (T,quick_push) (*vec_, obj_ VEC_ASSERT_PASS);            \
+}                                                                        \
+                                                                         \
+static inline T *VEC_OP (T,safe_insert)                                          \
+     (VEC(T) **vec_, unsigned ix_, const T *obj_ VEC_ASSERT_DECL)        \
+{                                                                        \
+  VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS);                                  \
+                                                                         \
+  return VEC_OP (T,quick_insert) (*vec_, ix_, obj_ VEC_ASSERT_PASS);     \
+}
+
+#endif /* COMMON_VEC_H */
diff --git a/gdb/gdbsupport/version.h b/gdb/gdbsupport/version.h
new file mode 100644 (file)
index 0000000..9e840e7
--- /dev/null
@@ -0,0 +1,31 @@
+/* Version information for GDB.
+   Copyright (C) 1999-2019 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/>.  */
+
+#ifndef COMMON_VERSION_H
+#define COMMON_VERSION_H
+
+/* Version number of GDB, as a string.  */
+extern const char version[];
+
+/* Canonical host name as a string.  */
+extern const char host_name[];
+
+/* Canonical target name as a string.  */
+extern const char target_name[];
+
+#endif /* COMMON_VERSION_H */
diff --git a/gdb/gdbsupport/x86-xstate.h b/gdb/gdbsupport/x86-xstate.h
new file mode 100644 (file)
index 0000000..4ce8f61
--- /dev/null
@@ -0,0 +1,88 @@
+/* Common code for x86 XSAVE extended state.
+
+   Copyright (C) 2010-2019 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/>.  */
+
+#ifndef COMMON_X86_XSTATE_H
+#define COMMON_X86_XSTATE_H
+
+/* The extended state feature bits.  */
+#define X86_XSTATE_X87         (1ULL << 0)
+#define X86_XSTATE_SSE         (1ULL << 1)
+#define X86_XSTATE_AVX         (1ULL << 2)
+#define X86_XSTATE_BNDREGS     (1ULL << 3)
+#define X86_XSTATE_BNDCFG      (1ULL << 4)
+#define X86_XSTATE_MPX         (X86_XSTATE_BNDREGS | X86_XSTATE_BNDCFG)
+
+/* AVX 512 adds three feature bits.  All three must be enabled.  */
+#define X86_XSTATE_K           (1ULL << 5)
+#define X86_XSTATE_ZMM_H       (1ULL << 6)
+#define X86_XSTATE_ZMM         (1ULL << 7)
+#define X86_XSTATE_AVX512      (X86_XSTATE_K | X86_XSTATE_ZMM_H \
+                                | X86_XSTATE_ZMM)
+
+#define X86_XSTATE_PKRU                (1ULL << 9)
+
+/* Supported mask and size of the extended state.  */
+#define X86_XSTATE_X87_MASK    X86_XSTATE_X87
+#define X86_XSTATE_SSE_MASK    (X86_XSTATE_X87 | X86_XSTATE_SSE)
+#define X86_XSTATE_AVX_MASK    (X86_XSTATE_SSE_MASK | X86_XSTATE_AVX)
+#define X86_XSTATE_MPX_MASK    (X86_XSTATE_SSE_MASK | X86_XSTATE_MPX)
+#define X86_XSTATE_AVX_MPX_MASK        (X86_XSTATE_AVX_MASK | X86_XSTATE_MPX)
+#define X86_XSTATE_AVX_AVX512_MASK     (X86_XSTATE_AVX_MASK | X86_XSTATE_AVX512)
+#define X86_XSTATE_AVX_MPX_AVX512_PKU_MASK     (X86_XSTATE_AVX_MPX_MASK\
+                                       | X86_XSTATE_AVX512 | X86_XSTATE_PKRU)
+
+#define X86_XSTATE_ALL_MASK            (X86_XSTATE_AVX_MPX_AVX512_PKU_MASK)
+
+
+#define X86_XSTATE_SSE_SIZE    576
+#define X86_XSTATE_AVX_SIZE    832
+#define X86_XSTATE_BNDREGS_SIZE        1024
+#define X86_XSTATE_BNDCFG_SIZE 1088
+#define X86_XSTATE_AVX512_SIZE 2688
+#define X86_XSTATE_PKRU_SIZE   2696
+#define X86_XSTATE_MAX_SIZE    2696
+
+
+/* In case one of the MPX XCR0 bits is set we consider we have MPX.  */
+#define HAS_MPX(XCR0) (((XCR0) & X86_XSTATE_MPX) != 0)
+#define HAS_AVX(XCR0) (((XCR0) & X86_XSTATE_AVX) != 0)
+#define HAS_AVX512(XCR0) (((XCR0) & X86_XSTATE_AVX512) != 0)
+#define HAS_PKRU(XCR0) (((XCR0) & X86_XSTATE_PKRU) != 0)
+
+/* Get I386 XSAVE extended state size.  */
+#define X86_XSTATE_SIZE(XCR0) \
+    (HAS_PKRU (XCR0) ? X86_XSTATE_PKRU_SIZE : \
+     (HAS_AVX512 (XCR0) ? X86_XSTATE_AVX512_SIZE : \
+      (HAS_MPX (XCR0) ? X86_XSTATE_BNDCFG_SIZE : \
+       (HAS_AVX (XCR0) ? X86_XSTATE_AVX_SIZE : X86_XSTATE_SSE_SIZE))))
+
+/* Initial value for fctrl register, as defined in the X86 manual, and
+   confirmed in the (Linux) kernel source.  When the x87 floating point
+   feature is not enabled in an inferior we use this as the value of the
+   fcrtl register.  */
+
+#define I387_FCTRL_INIT_VAL 0x037f
+
+/* Initial value for mxcsr register.  When the avx and sse floating point
+   features are not enabled in an inferior we use this as the value of the
+   mxcsr register.  */
+
+#define I387_MXCSR_INIT_VAL 0x1f80
+
+#endif /* COMMON_X86_XSTATE_H */
diff --git a/gdb/gdbsupport/xml-utils.c b/gdb/gdbsupport/xml-utils.c
new file mode 100644 (file)
index 0000000..79f040e
--- /dev/null
@@ -0,0 +1,63 @@
+/* Shared helper routines for manipulating XML.
+
+   Copyright (C) 2006-2019 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 "common-defs.h"
+#include "xml-utils.h"
+
+/* See xml-utils.h.  */
+
+std::string
+xml_escape_text (const char *text)
+{
+  std::string result;
+
+  xml_escape_text_append (&result, text);
+
+  return result;
+}
+
+/* See xml-utils.h.  */
+
+void
+xml_escape_text_append (std::string *result, const char *text)
+{
+  /* Expand the result.  */
+  for (int i = 0; text[i] != '\0'; i++)
+    switch (text[i])
+      {
+      case '\'':
+       *result += "&apos;";
+       break;
+      case '\"':
+       *result += "&quot;";
+       break;
+      case '&':
+       *result += "&amp;";
+       break;
+      case '<':
+       *result += "&lt;";
+       break;
+      case '>':
+       *result += "&gt;";
+       break;
+      default:
+       *result += text[i];
+       break;
+      }
+}
diff --git a/gdb/gdbsupport/xml-utils.h b/gdb/gdbsupport/xml-utils.h
new file mode 100644 (file)
index 0000000..747e8c8
--- /dev/null
@@ -0,0 +1,33 @@
+/* Shared helper routines for manipulating XML.
+
+   Copyright (C) 2006-2019 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/>.  */
+
+#ifndef COMMON_XML_UTILS_H
+#define COMMON_XML_UTILS_H
+
+/* Return a string with special characters from TEXT replaced by entity
+   references.  */
+
+extern std::string xml_escape_text (const char *text);
+
+/* Append TEXT to RESULT, with special characters replaced by entity
+   references.  */
+
+extern void xml_escape_text_append (std::string *result, const char *text);
+
+#endif /* COMMON_XML_UTILS_H */
index ffd4bf5c822e8b29b303f568a8014f4d4248a059..04230d3c170e74afe8f16910c9448a035d2b5abe 100644 (file)
@@ -27,12 +27,12 @@ struct symtab;
 #include "frame.h"
 #include "ui-out.h"
 #include "btrace.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "target/waitstatus.h"
 #include "cli/cli-utils.h"
-#include "common/refcounted-object.h"
-#include "common/common-gdbthread.h"
-#include "common/forward-scope-exit.h"
+#include "gdbsupport/refcounted-object.h"
+#include "gdbsupport/common-gdbthread.h"
+#include "gdbsupport/forward-scope-exit.h"
 
 struct inferior;
 
index 49653ffcaf7d58f106689471c907e773e2f89f39..1a131e2279cafcefa6ee61a62db984605f9119ee 100644 (file)
  */
 
 #include "hashtab.h"
-#include "common/array-view.h"
-#include "common/offset-type.h"
-#include "common/enum-flags.h"
-#include "common/underlying.h"
-#include "common/print-utils.h"
+#include "gdbsupport/array-view.h"
+#include "gdbsupport/offset-type.h"
+#include "gdbsupport/enum-flags.h"
+#include "gdbsupport/underlying.h"
+#include "gdbsupport/print-utils.h"
 #include "gdbarch.h"
 
 /* Forward declarations for prototypes.  */
index 5eeac9270a9e3f8f95b6a69413f22f5761b8a8f0..9229f72a0960ac2055932baa626462a7922048e5 100644 (file)
@@ -63,7 +63,7 @@ extern "C"
 #include "value.h"
 #include "language.h"
 #include "target.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include "gdbcmd.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
index ea0872363d3c4b3c424181cf0d80cb2287358e7c..6a58565fef1c8717a0e0eba9b167a48ba989b66f 100644 (file)
@@ -89,7 +89,7 @@
 #include "inferior.h"
 #include "infrun.h"
 #include "gdbthread.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include "gdbcore.h"
 #include "command.h"
 #include "gdbcmd.h"
index a426c3c640b01de25dad10545651977ccf002017..39bec8724f46d5fa1d49878275d3f988fa7c4cab 100644 (file)
@@ -30,7 +30,7 @@
 #include "top.h"
 #include "extension-priv.h"
 #include "utils.h"
-#include "common/version.h"
+#include "gdbsupport/version.h"
 #ifdef HAVE_GUILE
 #include "guile.h"
 #include "guile-internal.h"
index 114b35846ed757932f1dc0ba71f236c001b7be1a..f0bb2444ca47ed4bfff89ac9b62a648468ac0455 100644 (file)
@@ -26,7 +26,7 @@
 #include "top.h"
 #include "target.h"
 #include "guile-internal.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 
 #ifdef HAVE_POLL
 #if defined (HAVE_POLL_H)
index 14eace5f9cdb56db3f1a14566dec62522cdcd732..fc5668fb52ef13a7850021c2088e5a377b97c0a1 100644 (file)
@@ -23,7 +23,7 @@
 #include "defs.h"
 #include "filenames.h"
 #include "guile-internal.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 
 /* Struct to marshall args to scscm_safe_call_body.  */
 
index 5b99da70e6eeb59e4cf9639f4ac018eb61df54be..b32ec4fad29310161814a8aeedd575e44850d8d4 100644 (file)
@@ -26,7 +26,7 @@
 #include "gdbtypes.h"
 #include "objfiles.h"
 #include "language.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "bcache.h"
 #include "dwarf2loc.h"
 #include "typeprint.h"
index be5d4c67be7462ee348c2143067b5c822d0a1fb4..15a30a4c2a913d6fb2d4e26949af194208df5f76 100644 (file)
@@ -30,7 +30,7 @@
 #include "fbsd-nat.h"
 #include "i386-tdep.h"
 #include "x86-nat.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "x86-bsd-nat.h"
 #include "i386-bsd-nat.h"
 
index f274847174cf37ed07589550e28e3af50d09ddc3..3848bf890d48f1792f54525917d6c83b2ccd625a 100644 (file)
@@ -24,7 +24,7 @@
 #include "regcache.h"
 #include "regset.h"
 #include "i386-fbsd-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 
 #include "i386-tdep.h"
 #include "i387-tdep.h"
index 30db72d880e0be0fd80e91c3c8ec6a7b2f7299d3..7a04a9647fa139faa2e0c3e1d9be61d3d009defd 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "defs.h"
 #include "i386-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "target-descriptions.h"
 #include "osabi.h"
 
index abcf72f8989835b55f2be998f6ea048a00ce6bae..dd8f141f23b118018a31aad4ca3889d0ecae436a 100644 (file)
@@ -31,7 +31,7 @@
 #include "i387-tdep.h"
 #include "i386-tdep.h"
 #include "i386-linux-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 
 #include "x86-linux-nat.h"
 #include "nat/linux-ptrace.h"
index 4d94ea659aa2365233ac0e03766eeccd62a02841..d0d339d7dcb803d4daf2fd97dffdcbf6bb1bf98d 100644 (file)
@@ -38,7 +38,7 @@
 #include "xml-syscall.h"
 
 #include "i387-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 
 /* The syscall's XML filename for i386.  */
 #define XML_SYSCALL_FILENAME_I386 "syscalls/i386-linux.xml"
index e3dd4b3238dcdd8c98f64449ccc0afb152d6876a..3b8dac73c6e87df5f3d81e0e341beeac81fcf989 100644 (file)
@@ -46,7 +46,7 @@
 #include "remote.h"
 #include "i386-tdep.h"
 #include "i387-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "x86-tdep.h"
 
 #include "record.h"
index 25786619bfaf152654fbb99b0bb721ee55b1cc0f..6c3763d037f0d76dc4e5095baa8f82a836afa6ae 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "i386-tdep.h"
 #include "i387-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 
 /* Print the floating point number specified by RAW.  */
 
index 00ebf638f4d5047ff6421028a6e1e93ea5114e57..0f890261a06a17a1ba8623f7b36f5b6f0bcb8d11 100644 (file)
@@ -36,7 +36,7 @@
 #include "ia64-libunwind-tdep.h"
 
 #include "complaints.h"
-#include "common/preprocessor.h"
+#include "gdbsupport/preprocessor.h"
 
 /* IA-64 is the only target that currently uses ia64-libunwind-tdep.
    Note how UNW_TARGET, UNW_OBJ, etc. are compile time constants below.
index a77a86f490c56dfdabbbc564f55ccddc8a8ca4d7..7faa0b6308696467e67f3a82901ff3b821ef0b5b 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <signal.h>
 #include "nat/gdb_ptrace.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #ifdef HAVE_SYS_REG_H
 #include <sys/reg.h>
 #endif
index 41e9e67252b7c29d7ac35c8b7c5a4f21892a2376..0a73965a0bfdc3038e0c108c3b929c915ae8c873 100644 (file)
 #include "inferior.h"
 #include <sys/stat.h>
 #include "inf-child.h"
-#include "common/fileio.h"
-#include "common/agent.h"
-#include "common/gdb_wait.h"
-#include "common/filestuff.h"
+#include "gdbsupport/fileio.h"
+#include "gdbsupport/agent.h"
+#include "gdbsupport/gdb_wait.h"
+#include "gdbsupport/filestuff.h"
 
 #include <sys/types.h>
 #include <fcntl.h>
index e1acd8dc9df7cb1faf00a346b0cf8685bff6b0c3..32c433e3eafc4dc471cc84a8b89eefb2f645cdf0 100644 (file)
@@ -25,7 +25,7 @@
 #include "gdbcore.h"
 #include "regcache.h"
 #include "nat/gdb_ptrace.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include <signal.h>
 
 #include "inf-ptrace.h"
index 84092d37e6418d00d2255a52947c1ecf1c7b9bb4..b2f8ed21dc92d10830f283c499887ec51ecc207f 100644 (file)
@@ -41,7 +41,7 @@
 #include "interps.h"
 #include "thread-fsm.h"
 #include <algorithm>
-#include "common/scope-exit.h"
+#include "gdbsupport/scope-exit.h"
 
 /* If we can't find a function's name from its address,
    we print this instead.  */
index 330fc92159362f7a4a4a7638019155f8a96aa6bb..9966fc671fb7a5e6aac89c239b09a725c0345e71 100644 (file)
@@ -21,7 +21,7 @@
 #define INFCALL_H
 
 #include "dummy-frame.h"
-#include "common/array-view.h"
+#include "gdbsupport/array-view.h"
 
 struct value;
 struct type;
index 0f941004384dbc94de61289d7f3c5dd9359cc993..0ad9b916779c9c8c2f3b57d69b804f87e9abd2dc 100644 (file)
@@ -25,7 +25,7 @@
 #include "frame.h"
 #include "inferior.h"
 #include "infrun.h"
-#include "common/environ.h"
+#include "gdbsupport/environ.h"
 #include "value.h"
 #include "gdbcmd.h"
 #include "symfile.h"
@@ -58,7 +58,7 @@
 #include "thread-fsm.h"
 #include "top.h"
 #include "interps.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 #include "source.h"
 
 /* Local functions: */
@@ -213,7 +213,7 @@ show_args_command (struct ui_file *file, int from_tty,
   deprecated_show_value_hack (file, from_tty, c, get_inferior_args ());
 }
 
-/* See common/common-inferior.h.  */
+/* See gdbsupport/common-inferior.h.  */
 
 void
 set_inferior_cwd (const char *cwd)
@@ -228,7 +228,7 @@ set_inferior_cwd (const char *cwd)
     inf->cwd.reset (xstrdup (cwd));
 }
 
-/* See common/common-inferior.h.  */
+/* See gdbsupport/common-inferior.h.  */
 
 const char *
 get_inferior_cwd ()
index f3c0fd811fa6c134ba44fa89c1c8b6c3ef8d4ac3..b1b595735b822621aab7655d9dd300899303f41e 100644 (file)
@@ -20,8 +20,8 @@
 #ifndef INFERIOR_ITER_H
 #define INFERIOR_ITER_H
 
-#include "common/filtered-iterator.h"
-#include "common/safe-iterator.h"
+#include "gdbsupport/filtered-iterator.h"
+#include "gdbsupport/safe-iterator.h"
 
 /* A forward iterator that iterates over all inferiors.  */
 
index abfef700c386f0a11c17e4619beebf50dbeb46df..1415670b26188ed955a0ab4aeaa18b82506c5c4f 100644 (file)
@@ -29,7 +29,7 @@
 #include "observable.h"
 #include "gdbcore.h"
 #include "symfile.h"
-#include "common/environ.h"
+#include "gdbsupport/environ.h"
 #include "cli/cli-utils.h"
 #include "continuations.h"
 #include "arch-utils.h"
index 9e0e3b30e882b061d42deb291d926acca552e3a6..9cfb03cdbb38eb63220cf16ff68729c1d04e24c8 100644 (file)
@@ -44,16 +44,16 @@ struct thread_info;
 #include "frame.h"
 
 /* For gdb_environ.  */
-#include "common/environ.h"
+#include "gdbsupport/environ.h"
 
 #include "progspace.h"
 #include "registry.h"
 
 #include "symfile-add-flags.h"
-#include "common/refcounted-object.h"
-#include "common/forward-scope-exit.h"
+#include "gdbsupport/refcounted-object.h"
+#include "gdbsupport/forward-scope-exit.h"
 
-#include "common/common-inferior.h"
+#include "gdbsupport/common-inferior.h"
 #include "gdbthread.h"
 
 struct infcall_suspend_state;
index 621f69aa40fbe7f2753b9e0de2730a1f9f19af9f..6d645d291a7ef056966b324c5b011a9de29c1cc4 100644 (file)
@@ -34,7 +34,7 @@
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
 #endif
-#include "common/job-control.h"
+#include "gdbsupport/job-control.h"
 
 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
index 5dd5c37bd2b708bcaeaf2155ed46540df12b2dff..73b1b01a27b1ccff2aaa2b39908b9b35b621b199 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <unistd.h>
 #include <signal.h>
-#include "common/job-control.h"
+#include "gdbsupport/job-control.h"
 
 /* RAII class used to ignore SIGTTOU in a scope.  */
 
index 4fd92f1bac25e50401f8a85e3630e322e7b14965..c60ed306bd1dab7f3a16b76d5ce50be0b77fca8e 100644 (file)
@@ -25,7 +25,7 @@
 #include "frame.h"
 #include "inferior.h"
 #include "breakpoint.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include "gdbcore.h"
 #include "gdbcmd.h"
 #include "cli/cli-script.h"
 #include "solist.h"
 #include "event-loop.h"
 #include "thread-fsm.h"
-#include "common/enum-flags.h"
+#include "gdbsupport/enum-flags.h"
 #include "progspace-and-thread.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 #include "arch-utils.h"
-#include "common/scope-exit.h"
-#include "common/forward-scope-exit.h"
+#include "gdbsupport/scope-exit.h"
+#include "gdbsupport/forward-scope-exit.h"
 
 /* Prototypes for local functions */
 
index e53fd81e71691b55b84f09a70052b11469ede64b..30374ee51c4116ed9798beb52b02d7b1deec1cc8 100644 (file)
@@ -19,7 +19,7 @@
 #define INFRUN_H 1
 
 #include "symtab.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 
 struct target_waitstatus;
 struct frame_info;
index 214cb824976168a320e468cb2ccf657afc7e6831..b039ab8fa23c21ce80d819f538f88dfdcb35a108 100644 (file)
@@ -27,7 +27,7 @@
 #include "gdbthread.h"
 #include "regcache.h"
 #include "symtab.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "frame.h"
 #include <algorithm>
 
index e7446efa07f843b9132a6ccdb207c0704fe798dd..2a100b04917acd370c8e58c6572dd18b4fb66495 100644 (file)
@@ -24,7 +24,7 @@
 #define LANGUAGE_H 1
 
 #include "symtab.h"
-#include "common/function-view.h"
+#include "gdbsupport/function-view.h"
 #include "expression.h"
 
 /* Forward decls for prototypes.  */
index 83468f83ed92f560774c392d1f5642f86f7ab646..ac7d34dfe96f898e74a534fad79324a3a6004932 100644 (file)
@@ -44,8 +44,8 @@
 #include "ada-lang.h"
 #include "stack.h"
 #include "location.h"
-#include "common/function-view.h"
-#include "common/def-vector.h"
+#include "gdbsupport/function-view.h"
+#include "gdbsupport/def-vector.h"
 #include <algorithm>
 
 /* An enumeration of the various things a user might attempt to
index d323a716e3992d33e520873674de79f651ccb678..fd79345fac143ee0e6a71dc542d53451d70b7302 100644 (file)
@@ -31,7 +31,7 @@
 #include "source.h"
 
 #include "nat/gdb_ptrace.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include <dirent.h>
 #include <ctype.h>
 
index 4b9eab31960376604f5b8cb4cea038b2582f89e3..945c19f6668d78c1838d7fae277d2f83cd19f506 100644 (file)
@@ -23,7 +23,7 @@
 #include "target.h"
 #include "nat/linux-nat.h"
 #include "nat/linux-waitpid.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include <unistd.h>
 #include <sys/syscall.h>
 #include "nat/gdb_ptrace.h"
 #include "nat/linux-osdata.h"
 #include "linux-tdep.h"
 #include "symfile.h"
-#include "common/agent.h"
+#include "gdbsupport/agent.h"
 #include "tracepoint.h"
-#include "common/buffer.h"
+#include "gdbsupport/buffer.h"
 #include "target-descriptions.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "objfiles.h"
 #include "nat/linux-namespaces.h"
-#include "common/fileio.h"
-#include "common/scope-exit.h"
+#include "gdbsupport/fileio.h"
+#include "gdbsupport/scope-exit.h"
 
 #ifndef SPUFS_MAGIC
 #define SPUFS_MAGIC 0x23c9b64e
index f32631f4acbfdab79f5f7ec9be8017324ed03a7a..7d0c3e9fc9577a5d2fbc45122dec4108ee3949e2 100644 (file)
@@ -37,8 +37,8 @@
 #include "infcall.h"
 #include "gdbcmd.h"
 #include "gdb_regex.h"
-#include "common/enum-flags.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/enum-flags.h"
+#include "gdbsupport/gdb_optional.h"
 
 #include <ctype.h>
 
index 5c8b76c9a76388f6cba45050fccea0b4cee6ff49..950be9ca5a98128fe2d2a0d744a934fdaa536b14 100644 (file)
@@ -21,7 +21,7 @@
 #include <dlfcn.h>
 #include "gdb_proc_service.h"
 #include "nat/gdb_thread_db.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 #include "bfd.h"
 #include "command.h"
 #include "gdbcmd.h"
@@ -46,7 +46,7 @@
 #include <ctype.h>
 #include "nat/linux-namespaces.h"
 #include <algorithm>
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 #include "valprint.h"
 
 /* GNU/Linux libthread_db support.
index 2b375872c7758c9c26f896cd0c1254f6f296517b..0af53995f92ef750a1ea1b716f8bd816116032bf 100644 (file)
@@ -17,7 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/gdb_assert.h"
+#include "gdbsupport/gdb_assert.h"
 #include "location.h"
 #include "symtab.h"
 #include "language.h"
index 84e39fdf88550bb128813866e7f1b7788eb2017b..d7471e9572c1283d5efe1a25be0fef53efe6623a 100644 (file)
@@ -28,7 +28,7 @@
 #include "gdbcore.h"
 #include "mach-o.h"
 #include "aout/stab_gnu.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "psympriv.h"
 #include "complaints.h"
 #include "gdb_bfd.h"
index d1e14537bd3f4200aadfabdb600935d7edcef2d6..045d1625a19ad810bbc1ac0ab6238eb862e84d71 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef MACROTAB_H
 #define MACROTAB_H
 
-#include "common/function-view.h"
+#include "gdbsupport/function-view.h"
 
 struct obstack;
 struct bcache;
index ef9bfe8fc6925c49725b70804544e43e8cbe0a62..540738e543d5e0b77126a7d2bd04ce2b72ae0254 100644 (file)
 #include "maint.h"
 
 #include "filenames.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include <signal.h>
 #include "event-top.h"
 #include "infrun.h"
-#include "common/signals-state-save-restore.h"
+#include "gdbsupport/signals-state-save-restore.h"
 #include <vector>
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 #include "cli/cli-style.h"
 
 /* The selected interpreter.  This will be used as a set command
index cecde84e9a205fafdbba99becfe4eae85d036528..96a1377e27888f93b2aaa63b560b807de1295405 100644 (file)
@@ -38,7 +38,7 @@
 #include "value.h"
 #include "top.h"
 #include "maint.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 
 #include "cli/cli-decode.h"
 #include "cli/cli-utils.h"
index 57f350ade8c69c7d2dc3c7d8c56f62f8ca0bc85d..827964d825324e1927f6544f956e7f62a0dd16b6 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef MAINT_H
 #define MAINT_H
 
-#include "common/run-time-clock.h"
+#include "gdbsupport/run-time-clock.h"
 #include <chrono>
 
 extern void set_per_command_time (int);
index 858a41abfb423ac66c1d4f3343682e23b1e62d33..4bfab9c021d2ee63ae8ac4b03d56e4496bee593d 100644 (file)
@@ -25,7 +25,7 @@
 #include "target-dcache.h"
 #include "value.h"
 #include "language.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "breakpoint.h"
 #include "cli/cli-utils.h"
 #include <algorithm>
index d751d3cf230f7aef0b47a970b16124fe5e8017c4..f2fd66461cec3005b18d340c5450dda5fb736c13 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef MEMRANGE_H
 #define MEMRANGE_H
 
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 
 /* Defines a [START, START + LENGTH) memory range.  */
 
index a68080d580b34594c65c786a38600d347e2c28b6..1fe930cc6fdc42fa54a1b34351b0542d94815b85 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef MI_MI_CMD_BREAK_H
 #define MI_MI_CMD_BREAK_H
 
-#include "common/scoped_restore.h"
+#include "gdbsupport/scoped_restore.h"
 
 /* Setup the reporting of the insertion of a new breakpoint or
    catchpoint.  */
index fcc49b9eb36117e8f9836d5e859b7be17fc61e6a..ee01afa4c9c23929b5e36f0d9129df3ada73a651 100644 (file)
@@ -26,7 +26,7 @@
 #include "mi-getopt.h"
 #include "symtab.h"
 #include "target.h"
-#include "common/environ.h"
+#include "gdbsupport/environ.h"
 #include "command.h"
 #include "ui-out.h"
 #include "top.h"
index 80bc7a1968edd32f494d5ee5667b1b350c8a878b..c8a4ce73c9789ca6be383a3e7f49d7a7ee6adff1 100644 (file)
@@ -34,7 +34,7 @@
 #include "extension.h"
 #include <ctype.h>
 #include "mi-parse.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 #include "safe-ctype.h"
 
 enum what_to_list { locals, arguments, all };
index 0c2e0c3b7bfc493ff68b6dd422e0ef2a6ef3bb6a..662ffa3f4d915c78fd7b3911907367cb8a8d52bd 100644 (file)
@@ -30,7 +30,7 @@
 #include "mi-getopt.h"
 #include "gdbthread.h"
 #include "mi-parse.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 #include "inferior.h"
 
 extern unsigned int varobjdebug;               /* defined in varobj.c.  */
index ad1a06cae0bd2bba2cafc772c6e24c3a6231ed4e..ab1f9138876ad00a1d487ea7f4d486e7543c9a91 100644 (file)
@@ -38,7 +38,7 @@
 #include "cli-out.h"
 #include "thread-fsm.h"
 #include "cli/cli-interp.h"
-#include "common/scope-exit.h"
+#include "gdbsupport/scope-exit.h"
 
 /* These are the interpreter setup, etc. functions for the MI
    interpreter.  */
index 13c310d494c0f348531db91f1c9da73f71c67af0..da8c81f9e2265a4c1edc56c32d14e8bad5199d60 100644 (file)
@@ -44,7 +44,7 @@
 #include "language.h"
 #include "valprint.h"
 #include "osdata.h"
-#include "common/gdb_splay_tree.h"
+#include "gdbsupport/gdb_splay_tree.h"
 #include "tracepoint.h"
 #include "ctf.h"
 #include "ada-lang.h"
 #include "extension.h"
 #include "gdbcmd.h"
 #include "observable.h"
-#include "common/gdb_optional.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/gdb_optional.h"
+#include "gdbsupport/byte-vector.h"
 
 #include <ctype.h>
-#include "common/run-time-clock.h"
+#include "gdbsupport/run-time-clock.h"
 #include <chrono>
 #include "progspace-and-thread.h"
-#include "common/rsp-low.h"
+#include "gdbsupport/rsp-low.h"
 #include <algorithm>
 #include <set>
 #include <map>
index 2262ff56f96a7c3ad86ed94c42838eac1227675e..6ee08b9a1842d5459a63833908a5e1b5c0de2f47 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef MI_MI_PARSE_H
 #define MI_MI_PARSE_H
 
-#include "common/run-time-clock.h"
+#include "gdbsupport/run-time-clock.h"
 #include <chrono>
 #include "mi-cmds.h"  /* For enum print_values.  */
 
index e64e5df1a18eb09f5538055800e18ec30e708597..0f734ebc76134dddc34d03aa9c587c377b58e2fc 100644 (file)
@@ -50,7 +50,7 @@
 #include "cp-support.h"
 #include "language.h"
 #include "cli/cli-utils.h"
-#include "common/symbol.h"
+#include "gdbsupport/symbol.h"
 #include <algorithm>
 #include "safe-ctype.h"
 
@@ -433,7 +433,7 @@ lookup_bound_minimal_symbol (const char *name)
   return lookup_minimal_symbol (name, NULL, NULL);
 }
 
-/* See common/symbol.h.  */
+/* See gdbsupport/symbol.h.  */
 
 int
 find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
index 13c5e06675f5878b85f50bd6835f0f3a4705b33f..08d027917d837f12463f9470559169dc5a76c159 100644 (file)
@@ -38,7 +38,7 @@
 #include "glibc-tdep.h"
 #include "linux-tdep.h"
 #include "xml-syscall.h"
-#include "common/gdb_signals.h"
+#include "gdbsupport/gdb_signals.h"
 
 #include "features/mips-linux.c"
 #include "features/mips-dsp-linux.c"
@@ -1437,7 +1437,7 @@ mips_gdb_signal_to_target (struct gdbarch *gdbarch,
 }
 
 /* Translate signals based on MIPS signal values.
-   Adapted from gdb/common/signals.c.  */
+   Adapted from gdb/gdbsupport/signals.c.  */
 
 static enum gdb_signal
 mips_gdb_signal_from_target (struct gdbarch *gdbarch, int signal)
index 2d395804961ba86722d296ad4f8b8f7a4dda7fcd..740d5b0d97c153c189c055470feb1ab7a84f348a 100644 (file)
@@ -19,8 +19,8 @@
 #ifndef NAMESPACE_H
 #define NAMESPACE_H
 
-#include "common/vec.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/vec.h"
+#include "gdbsupport/gdb_vecs.h"
 #include "gdb_obstack.h"
 
 /* This struct is designed to store data from using directives.  It
index 1efec9a268cc9a0dd2fda99fe362ee40c79a01fd..9f5a0f045e9c134e4338d3ba4cc88013a43f9334 100644 (file)
@@ -16,9 +16,9 @@
    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 "common/common-defs.h"
-#include "common/break-common.h"
-#include "common/common-regcache.h"
+#include "gdbsupport/common-defs.h"
+#include "gdbsupport/break-common.h"
+#include "gdbsupport/common-regcache.h"
 #include "nat/linux-nat.h"
 #include "aarch64-linux-hw-point.h"
 
index 5d9c2a1c80b356e95385b42e29c8456ed785a070..10b5e69515aa5662f4f20c96ff15cd780dd28d19 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef NAT_AARCH64_LINUX_HW_POINT_H
 #define NAT_AARCH64_LINUX_HW_POINT_H
 
-#include "common/break-common.h" /* For enum target_hw_bp_type.  */
+#include "gdbsupport/break-common.h" /* For enum target_hw_bp_type.  */
 
 /* Macro definitions, data structures, and code for the hardware
    breakpoint and hardware watchpoint support follow.  We use the
index 9c4c3ada7199ff99665b090cd5b0318e9e8ce275..94e07128834bf60cc18d7558f6276bd3b037fea9 100644 (file)
@@ -16,8 +16,8 @@
    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 "common/common-defs.h"
-#include "common/break-common.h"
+#include "gdbsupport/common-defs.h"
+#include "gdbsupport/break-common.h"
 #include "nat/linux-nat.h"
 #include "nat/aarch64-linux-hw-point.h"
 #include "nat/aarch64-linux.h"
index 635b4c9d68a7f90bd8f5e40efb6117fbb0d57f96..1383d4688c0a536f4dc1b61e5cfe0bb3409c063c 100644 (file)
 
 #include <sys/utsname.h>
 #include <sys/uio.h>
-#include "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "elf/external.h"
 #include "elf/common.h"
 #include "aarch64-sve-linux-ptrace.h"
 #include "arch/aarch64.h"
-#include "common/common-regcache.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/common-regcache.h"
+#include "gdbsupport/byte-vector.h"
 
 /* See nat/aarch64-sve-linux-ptrace.h.  */
 
index dab52684ad03331f26b3514f7aef0a054742f764..91460c02ca9a8a3333f7a8d70f7cf53f81c08c81 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <signal.h>
-#include "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "amd64-linux-siginfo.h"
 
 #define GDB_SI_SIZE 128
index 1179d01c04fafc5e4ce9ca7c78badfc0f2ec7ad0..68b51aa8146806d7b6620a2595278177986db3fd 100644 (file)
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "fork-inferior.h"
 #include "target/waitstatus.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "target/target.h"
-#include "common/common-inferior.h"
-#include "common/common-gdbthread.h"
-#include "common/pathstuff.h"
-#include "common/signals-state-save-restore.h"
-#include "common/gdb_tilde_expand.h"
+#include "gdbsupport/common-inferior.h"
+#include "gdbsupport/common-gdbthread.h"
+#include "gdbsupport/pathstuff.h"
+#include "gdbsupport/signals-state-save-restore.h"
+#include "gdbsupport/gdb_tilde_expand.h"
 #include <vector>
 
 extern char **environ;
index ef291ec2310353f99ccef9b52ec598d3dedc74e1..8625291cce987db8c5138ac2dc476bfde9c4e398 100644 (file)
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "linux-btrace.h"
-#include "common/common-regcache.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/common-regcache.h"
+#include "gdbsupport/gdb_wait.h"
 #include "x86-cpuid.h"
-#include "common/filestuff.h"
-#include "common/scoped_fd.h"
-#include "common/scoped_mmap.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/scoped_fd.h"
+#include "gdbsupport/scoped_mmap.h"
 
 #include <inttypes.h>
 
index df7b0d27c7e1fffa3896dce66b2f8fc3f1a20420..1d5c7457ee4d68ff69da97d69a844a6d4ed150bb 100644 (file)
@@ -22,8 +22,8 @@
 #ifndef NAT_LINUX_BTRACE_H
 #define NAT_LINUX_BTRACE_H
 
-#include "common/btrace-common.h"
-#include "common/vec.h"
+#include "gdbsupport/btrace-common.h"
+#include "gdbsupport/vec.h"
 #if HAVE_LINUX_PERF_EVENT_H
 #  include <linux/perf_event.h>
 #endif
index c0f326b9a1eda321d53f0faace0e6f87309ba3e9..503f755903c4dbacac6316a853f7a753577afe95 100644 (file)
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "nat/linux-namespaces.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include <fcntl.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include <signal.h>
 #include <sched.h>
-#include "common/scope-exit.h"
+#include "gdbsupport/scope-exit.h"
 
 /* See nat/linux-namespaces.h.  */
 int debug_linux_namespaces;
index 29f43d8dfa56de4645a65f175f31c0492a5feb50..13af248485504877abbfd3f8cca9983dc55043bc 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef NAT_LINUX_NAT_H
 #define NAT_LINUX_NAT_H
 
-#include "common/function-view.h"
+#include "gdbsupport/function-view.h"
 #include "target/waitstatus.h"
 
 struct lwp_info;
index 3599df7cbeb67908ab94067f4a9ee5ca4b738927..67f9f3a42515497232913f420ebc88e3b7892611 100644 (file)
@@ -17,7 +17,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "linux-osdata.h"
 
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
-#include "common/xml-utils.h"
-#include "common/buffer.h"
+#include "gdbsupport/xml-utils.h"
+#include "gdbsupport/buffer.h"
 #include <dirent.h>
 #include <sys/stat.h>
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include <algorithm>
 
 #define NAMELEN(dirent) strlen ((dirent)->d_name)
index 2ae84e51b0b965868d4efc1a2a798c72b8b7caba..6d209ae50a1e3ba68f79fbf4da0eea27f995ebc5 100644 (file)
@@ -17,7 +17,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "nat/linux-personality.h"
 
 #ifdef HAVE_PERSONALITY
index 929bc137dced52222c443337582e40a315f4a699..2afc53d27aae03b2869ffedc37f57eacd79e0e66 100644 (file)
@@ -16,9 +16,9 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "linux-procfs.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include <dirent.h>
 #include <sys/stat.h>
 
index 40919f77d7209ebd250a6c146675e99f73f7f200..c1ebc0a032dfce899aeeba0c7534c93508b7cc9a 100644 (file)
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "linux-ptrace.h"
 #include "linux-procfs.h"
 #include "linux-waitpid.h"
-#include "common/buffer.h"
+#include "gdbsupport/buffer.h"
 #ifdef HAVE_SYS_PROCFS_H
 #include <sys/procfs.h>
 #endif
index cfb12178a423b0c57257d002e7dacf0dc6d17a0a..fd2f12a342ce5a85cab20fc02772bec0caf1b280 100644 (file)
@@ -21,7 +21,7 @@
 struct buffer;
 
 #include "nat/gdb_ptrace.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 
 #ifdef __UCLIBC__
 #if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
index 298032dff9ab0b5769d3c01fea8d47165f4da701..4d3fe25fd3153e6c85b7f61d84268e821f967397 100644 (file)
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 
 #include "linux-nat.h"
 #include "linux-waitpid.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 
 /* Convert wait status STATUS to a string.  Used for printing debug
    messages only.  */
index 8add09c00fc30e5bcae07fb8fae00009d7e9701f..124752f7c2fe4d225066d930c0c26abe1aebc1c7 100644 (file)
@@ -15,7 +15,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "nat/gdb_ptrace.h"
 #include "mips-linux-watch.h"
 
index 35e8d9d461efe2f7dbd863a419c53dc6ec42cd59..7d255c89e470e6750d85deaa73797c28e7febdbe 100644 (file)
@@ -19,7 +19,7 @@
 #define NAT_MIPS_LINUX_WATCH_H
 
 #include <asm/ptrace.h>
-#include "common/break-common.h"
+#include "gdbsupport/break-common.h"
 
 #define MAX_DEBUG_REGISTER 8
 
index 27942fa2a5d60f8d8caaf45e8c017f2f51a29793..11f2a43122fcd076ef8a65baa69289dfa0b61889 100644 (file)
@@ -15,7 +15,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "ppc-linux.h"
 #include "nat/gdb_ptrace.h"
 #include <elf.h>
index fb35178965d83f5946644e01530a39eb77af054a..69cc47d4dd7e40f19f48c51f44ea59d38b0b9a42 100644 (file)
@@ -17,9 +17,9 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "x86-dregs.h"
-#include "common/break-common.h"
+#include "gdbsupport/break-common.h"
 
 /* Support for hardware watchpoints and breakpoints using the x86
    debug registers.
index e8a2e0099e864b911c33928379ec133fc9ac7de9..4d0602429b2fbcded3948aab31e7bda8a974ed3e 100644 (file)
@@ -33,7 +33,7 @@
    (32 bytes on 64 bit hosts).  */
 
 
-#include "common/break-common.h" /* target_hw_bp_type */
+#include "gdbsupport/break-common.h" /* target_hw_bp_type */
 
 /* Low-level function vector.  */
 
index 29b4ee16b60aeb6a8067f0b0308ef9dcf2e079a7..271e630a3f3436f18bcd4809eb6cd423b0c9c840 100644 (file)
@@ -17,7 +17,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "nat/gdb_ptrace.h"
 #include <sys/user.h>
 #include "target/waitstatus.h"
index be00a3b560a957a8ed0c1dc5482fc8513d32b560..55ff58118cf497adbfe37d17f47b27701c3e54bf 100644 (file)
@@ -17,7 +17,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "x86-linux.h"
 #include "x86-linux-dregs.h"
 
index 9dd35a4c8aafcce2e9c7bec459941dcb7831c47c..b9866c2259199a5b050a81050ffb5c50e641e22a 100644 (file)
@@ -42,8 +42,8 @@
 #include "regcache.h"
 #include "solib.h"
 #include "inf-child.h"
-#include "common/filestuff.h"
-#include "common/scoped_fd.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/scoped_fd.h"
 
 #define NULL_PID               0
 #define _DEBUG_FLAG_TRACE      (_DEBUG_FLAG_TRACE_EXEC|_DEBUG_FLAG_TRACE_RD|\
index 48e731acd05267d058bf455c27f98c0975fef70e..0c610d28419403393eec0ff05906ae9259d8711f 100644 (file)
@@ -32,7 +32,7 @@
 #include "gdbcore.h"
 #include "objfiles.h"
 #include "source.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 
 #define QNX_NOTE_NAME  "QNX"
 #define QNX_INFO_SECT_NAME "QNX_info"
index 38128ea62117a71c34dbee1ee9e0f076de8c285f..45c86a3ac09afedf67eb8d97778b4e035183388c 100644 (file)
@@ -20,7 +20,7 @@
 #if !defined (OBJFILE_FLAGS_H)
 #define OBJFILE_FLAGS_H
 
-#include "common/enum-flags.h"
+#include "gdbsupport/enum-flags.h"
 
 /* Defines for the objfile flags field.  Defined in a separate file to
    break circular header dependencies.  */
index b59db591d9fa73f9c8a23af337c0cf32e1846bfb..84d9681bf4ea69bd9181497f64e76d13521e7084 100644 (file)
@@ -52,7 +52,7 @@
 #include "solist.h"
 #include "gdb_bfd.h"
 #include "btrace.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 
 #include <vector>
 
index e0ff8343439d40542a8cfd4967a21e7ed39be687..3a7a8ba940bdc907e1953839e522cd666801f013 100644 (file)
@@ -30,8 +30,8 @@
 #include "psymtab.h"
 #include <bitset>
 #include <vector>
-#include "common/next-iterator.h"
-#include "common/safe-iterator.h"
+#include "gdbsupport/next-iterator.h"
+#include "gdbsupport/safe-iterator.h"
 #include "bcache.h"
 
 struct htab;
index 0a99bd021df6b2edfa8fe4bded96c1da6e0c3528..88c01df2a1ec4933034f9c9da9a5450bacbcb3d1 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <sys/types.h>
 #include <sys/ptrace.h>
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 
 #include "inf-child.h"
 #include "obsd-nat.h"
index edd1fffae0ac38223e01d5915f401bfd695f5be4..b58966ea90bd9145233530e1f54b2765e70aa86c 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef OBSERVABLE_H
 #define OBSERVABLE_H
 
-#include "common/observable.h"
+#include "gdbsupport/observable.h"
 
 struct bpstats;
 struct so_list;
index 0ee13d8ffa597ab6d46e5376160dd65bafa70122..ea3b7dce43b0c8a33400864c5a96880574cd3716 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "defs.h"
 #include "target.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "xml-support.h"
 #include "osdata.h"
 #include "ui-out.h"
index 62679ac4445b448f2215f171d3a1b4bc589c3fa7..a3738a9252d11104777802f42436be50f8c857be 100644 (file)
@@ -38,7 +38,7 @@
 #include "cp-abi.h"
 #include "cp-support.h"
 #include "objfiles.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 \f
 
 /* Decorations for Pascal.  */
index 6f777e6ed73f55a1b935842c456ee68f66908d6b..a1ab75297a161e07d579c644d52662fa09e9fd23 100644 (file)
@@ -50,7 +50,7 @@
 #include "objfiles.h"
 #include "user-regs.h"
 #include <algorithm>
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 
 /* Standard set of definitions for printing, dumping, prefixifying,
  * and evaluating expressions.  */
index 4254ef60e621b010797ded1d162823868c038e94..9c0341b556e10d26f93f8fc594b1be889a72b231 100644 (file)
@@ -23,7 +23,7 @@
 #if !defined (PARSER_DEFS_H)
 #define PARSER_DEFS_H 1
 
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "expression.h"
 
 struct block;
index 70e2962c99e409373e9fdae9f51a45311e653bb2..deb31d49890c7bee2e55ad373fbbeaa40649a109 100644 (file)
@@ -32,7 +32,7 @@
 #include <sys/user.h>
 #include <sys/ioctl.h>
 #include <sys/uio.h>
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include <fcntl.h>
 #include <sys/procfs.h>
 #include "nat/gdb_ptrace.h"
index 714a2e981ea705d3508b0a410007d3b67ecf9822..2081704bc4aec254c0758187e1ab89bd2491c7a5 100644 (file)
 #include "cli/cli-option.h"
 #include "cli/cli-script.h"
 #include "cli/cli-style.h"
-#include "common/format.h"
+#include "gdbsupport/format.h"
 #include "source.h"
-#include "common/byte-vector.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/byte-vector.h"
+#include "gdbsupport/gdb_optional.h"
 
 /* Last specified output format.  */
 
index 7bc75d8e879bd8cd0932827716cec46c1d13f6d1..cdc6e021d2e7682f23e1133c41a7bab97f6e249f 100644 (file)
@@ -36,7 +36,7 @@
 #include "location.h"
 #include <ctype.h>
 #include <algorithm>
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 
 /* Class that implements the static probe methods for "any" probe.  */
 
index c7ce82d23aff89362a512c7a03054aba75e07cbc..cb2eaf8cb190280139edda8049cb32d3061567d7 100644 (file)
@@ -35,7 +35,7 @@
 #include <sys/proc.h>  /* for struct proc */
 #include <sys/user.h>  /* for struct user */
 #include <fcntl.h>     /* for O_RDWR etc.  */
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 
 #include "proc-utils.h"
 
index 020336e5ba4b3bcf320e59a6a3192dcdeb9f7ad3..50e3e928425e47895ba7ae32b132c297c7d81474 100644 (file)
 #include "regcache.h"
 #include "inf-child.h"
 #include "nat/fork-inferior.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 
 #define _STRUCTURED_PROC 1     /* Should be done by configure script.  */
 
 #include <sys/procfs.h>
 #include <sys/fault.h>
 #include <sys/syscall.h>
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include <signal.h>
 #include <ctype.h>
 #include "gdb_bfd.h"
@@ -46,8 +46,8 @@
 #include "auxv.h"
 #include "procfs.h"
 #include "observable.h"
-#include "common/scoped_fd.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/scoped_fd.h"
+#include "gdbsupport/pathstuff.h"
 
 /* This module provides the interface between GDB and the
    /proc file system, which is used on many versions of Unix
index 362c5ef8b4f43af73f7931821e6dd3dd78236bbd..63ec2acb0d57b64554687e7c540b155729cb9af3 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "defs.h"
 #include "producer.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 
 /* See producer.h.  */
 
index 039f55517305f797909d817c6c0500ff6602f541..073da1fbc062dc4dc4923c4b5d2fd222085f0460 100644 (file)
 #define PROGSPACE_H
 
 #include "target.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "gdb_bfd.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 #include "registry.h"
-#include "common/next-iterator.h"
-#include "common/safe-iterator.h"
+#include "gdbsupport/next-iterator.h"
+#include "gdbsupport/safe-iterator.h"
 
 struct target_ops;
 struct bfd;
index c761fa72222603a0f1d6d3e0a584256c1c22f0f4..aed686258d4d54ed28185c872b8c3e23640bf625 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "gdb_obstack.h"
 #include "symfile.h"
-#include "common/next-iterator.h"
+#include "gdbsupport/next-iterator.h"
 #include "bcache.h"
 
 struct partial_symbol;
index 95ad410f23fd852c4172786731d1265a9e93dc67..a351ac5aec879c5d1995ef62598067dffee0ba3f 100644 (file)
@@ -30,7 +30,7 @@
 #include "demangle.h"
 #include "mi/mi-cmds.h"
 #include "python-internal.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 
 enum mi_print_types
 {
index 7e7d518c5577683d62324f7935e0851052a74a7e..161e6dcf3430850d2c4bc525430149e31ded2db8 100644 (file)
@@ -26,7 +26,7 @@
 #include "python-internal.h"
 #include "arch-utils.h"
 #include "language.h"
-#include "common/gdb_signals.h"
+#include "gdbsupport/gdb_signals.h"
 #include "py-event.h"
 #include "py-stopevent.h"
 
index 15280f6fbf55ad856de4b58363089be6997bad29..3f5514ee0113ef032f3e205e758262e23ecaea43 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef PYTHON_PY_REF_H
 #define PYTHON_PY_REF_H
 
-#include "common/gdb_ref_ptr.h"
+#include "gdbsupport/gdb_ref_ptr.h"
 
 /* A policy class for gdb::ref_ptr for Python reference counting.  */
 template<typename T>
index 7b99beacae02ad3b1e535aaf0fcb87c434dd4de4..e8af6f60e1e5a35db388355b337a12f2136cad44 100644 (file)
@@ -26,7 +26,7 @@
 #include "demangle.h"
 #include "objfiles.h"
 #include "language.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "typeprint.h"
 
 typedef struct pyty_type_object
index 2f5e94d86c7da34c12f8c1e6b44c7a8d27c97c23..96bee7c3b04f0c1fff1b3ea96bc9e08060230f36 100644 (file)
@@ -93,7 +93,7 @@ const struct extension_language_defn extension_language_python =
 #include "python-internal.h"
 #include "linespec.h"
 #include "source.h"
-#include "common/version.h"
+#include "gdbsupport/version.h"
 #include "target.h"
 #include "gdbthread.h"
 #include "interps.h"
index 21085d5c62c7ef7eeea0b420deb3a0f137f2ea94..ec06145585fd56436068def8f24167045359cbb4 100644 (file)
@@ -38,7 +38,7 @@
 #include "infrun.h"
 #include "event-loop.h"
 #include "inf-loop.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "inferior.h"
 #include <algorithm>
 
index 95a0353d754ee0c5b58e8f5727dffd46a598b70d..2fc6a2ef776cb33c0120bcd9975d7d8ecbe3c789 100644 (file)
@@ -36,8 +36,8 @@
 #include "gdb_bfd.h"
 #include "observable.h"
 #include "infrun.h"
-#include "common/gdb_unlinker.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/gdb_unlinker.h"
+#include "gdbsupport/byte-vector.h"
 
 #include <signal.h>
 
index 828c19968a3d9fb92f04fff12d66bec1abc164b2..7d46bf1617c611c913665523d55c830300c059de 100644 (file)
@@ -23,7 +23,7 @@
 #include "record.h"
 #include "observable.h"
 #include "inferior.h"
-#include "common/common-utils.h"
+#include "gdbsupport/common-utils.h"
 #include "cli/cli-utils.h"
 #include "disasm.h"
 
index 03f96e8ab78e540b4649687dec083e2f59b291c9..f371b7f7cc13d2eebeaff4be0bbb7c4193fc81a9 100644 (file)
@@ -21,7 +21,7 @@
 #define RECORD_H
 
 #include "target/waitstatus.h" /* For enum target_stop_reason.  */
-#include "common/enum-flags.h"
+#include "gdbsupport/enum-flags.h"
 
 struct cmd_list_element;
 struct inferior;
index 1bcf9c3d17adf81c8c81710e4b8ad72fb8648349..52ecbbe138731b93794f6c0e774120a18d1c02e4 100644 (file)
@@ -18,7 +18,7 @@
 #include "defs.h"
 #include "gdbcmd.h"
 #include "regcache.h"
-#include "common/def-vector.h"
+#include "gdbsupport/def-vector.h"
 #include "valprint.h"
 #include "remote.h"
 #include "reggroups.h"
index 323f0f5ab4e2342cda2dfc5f618f90e062e77020..bcced338fba4af5ad4efd3d8e52818268b154fe9 100644 (file)
@@ -168,7 +168,7 @@ register_size (struct gdbarch *gdbarch, int regnum)
   return size;
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 int
 regcache_register_size (const struct regcache *regcache, int n)
@@ -284,7 +284,7 @@ regcache::restore (readonly_detached_regcache *src)
     }
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 enum register_status
 reg_buffer::get_register_status (int regnum) const
@@ -372,7 +372,7 @@ get_current_regcache (void)
   return get_thread_regcache (inferior_thread ());
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 struct regcache *
 get_thread_regcache_for_ptid (ptid_t ptid)
@@ -931,7 +931,7 @@ regcache::cooked_write_part (int regnum, int offset, int len,
   write_part (regnum, offset, len, buf, false);
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 void
 reg_buffer::raw_supply (int regnum, const void *buf)
@@ -996,7 +996,7 @@ reg_buffer::raw_supply_zeroed (int regnum)
   m_register_status[regnum] = REG_VALID;
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 void
 reg_buffer::raw_collect (int regnum, void *buf) const
@@ -1148,7 +1148,7 @@ regcache::collect_regset (const struct regset *regset,
   transfer_regset (regset, nullptr, regnum, nullptr, (gdb_byte *) buf, size);
 }
 
-/* See common/common-regcache.h.  */
+/* See gdbsupport/common-regcache.h.  */
 
 bool
 reg_buffer::raw_compare (int regnum, const void *buf, int offset) const
@@ -1380,7 +1380,7 @@ register_dump::dump (ui_file *file)
 }
 
 #if GDB_SELF_TEST
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "target-float.h"
 
index 2b703ea4a4b84f7a4eb3d0ed398319efb95877c8..8d0c302ac3e559fa133769b8014f3c318d5c2b46 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef REGCACHE_H
 #define REGCACHE_H
 
-#include "common/common-regcache.h"
+#include "gdbsupport/common-regcache.h"
 #include <forward_list>
 
 struct regcache;
@@ -68,7 +68,7 @@ extern void regcache_cooked_write_unsigned (struct regcache *regcache,
 
 /* Special routines to read/write the PC.  */
 
-/* For regcache_read_pc see common/common-regcache.h.  */
+/* For regcache_read_pc see gdbsupport/common-regcache.h.  */
 extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
 
 /* Mapping between register numbers and offsets in a buffer, for use
@@ -181,10 +181,10 @@ public:
   /* Return regcache's architecture.  */
   gdbarch *arch () const;
 
-  /* See common/common-regcache.h.  */
+  /* See gdbsupport/common-regcache.h.  */
   enum register_status get_register_status (int regnum) const override;
 
-  /* See common/common-regcache.h.  */
+  /* See gdbsupport/common-regcache.h.  */
   void raw_collect (int regnum, void *buf) const override;
 
   /* Collect register REGNUM from REGCACHE.  Store collected value as an integer
@@ -199,7 +199,7 @@ public:
      reading only LEN.  */
   void raw_collect_part (int regnum, int offset, int len, gdb_byte *out) const;
 
-  /* See common/common-regcache.h.  */
+  /* See gdbsupport/common-regcache.h.  */
   void raw_supply (int regnum, const void *buf) override;
 
   void raw_supply (int regnum, const reg_buffer &src)
@@ -228,7 +228,7 @@ public:
 
   virtual ~reg_buffer () = default;
 
-  /* See common/common-regcache.h.  */
+  /* See gdbsupport/common-regcache.h.  */
   bool raw_compare (int regnum, const void *buf, int offset) const override;
 
 protected:
index 2f7ecf366c3e07beb4c6a08ee8b1cbb4ccb2cc4f..11c141e42c4d5565dd809e582675432a1b0890d8 100644 (file)
 #include "defs.h"
 #include "gdbcmd.h"
 #include "remote.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include <sys/stat.h>
 #include "remote-fileio.h"
 #include "event-loop.h"
 #include "target.h"
 #include "filenames.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 
 #include <fcntl.h>
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 #ifdef __CYGWIN__
 #include <sys/cygwin.h>                /* For cygwin_conv_path.  */
 #endif
index 184d2054dc1b2e49a223ec1969ff57a2c3f004c7..779b63ee291a68181dd4d70b906273a88033e029 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef REMOTE_FILEIO_H
 #define REMOTE_FILEIO_H
 
-#include "common/fileio.h"
+#include "gdbsupport/fileio.h"
 
 struct cmd_list_element;
 struct remote_target;
index 8a6cb6b18e3fe0cb7e2c9e9a83e5da4408f1dc8b..a22a59ed39958065eef6951b641d684ae9948df0 100644 (file)
@@ -41,7 +41,7 @@
 #include "arch-utils.h"
 #include "readline/readline.h"
 #include "gdbthread.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 
 /* Prototypes */
 
index 124d254478e17485829ed2948120ca4249cd19a8..42c730e48fb9f7d37dfd47e57accc961c3655690 100644 (file)
 #include "cli/cli-setshow.h"
 #include "target-descriptions.h"
 #include "gdb_bfd.h"
-#include "common/filestuff.h"
-#include "common/rsp-low.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/rsp-low.h"
 #include "disasm.h"
 #include "location.h"
 
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 
 #include "event-loop.h"
 #include "event-top.h"
 #include "tracepoint.h"
 #include "ax.h"
 #include "ax-gdb.h"
-#include "common/agent.h"
+#include "gdbsupport/agent.h"
 #include "btrace.h"
 #include "record-btrace.h"
 #include <algorithm>
-#include "common/scoped_restore.h"
-#include "common/environ.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/scoped_restore.h"
+#include "gdbsupport/environ.h"
+#include "gdbsupport/byte-vector.h"
 #include <unordered_map>
 
 /* The remote target.  */
index 828beea7e2bc3187a630e2d81900e3f1f544773a..7f3a1f6cbc36bffd5483a425b0964d5116dbe3e2 100644 (file)
@@ -50,7 +50,7 @@
 #include "dwarf2-frame.h"
 #include "user-regs.h"
 #include "valprint.h"
-#include "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "opcode/riscv-opc.h"
 #include "cli/cli-decode.h"
 #include "observable.h"
index e99865682fd28e992c675f70e59c22b0768da8b9..4964f591a5a916790900f83787449ce47f38ef1c 100644 (file)
@@ -37,7 +37,7 @@
 #include "solib.h"
 #include "solib-aix.h"
 #include "target-float.h"
-#include "common/xml-utils.h"
+#include "gdbsupport/xml-utils.h"
 #include "trad-frame.h"
 #include "frame-unwind.h"
 
index 15932638397d0854e41f2b73b359147076925189..ddbf1d4bba312769845ced9d79ebec058135cbe1 100644 (file)
@@ -38,9 +38,9 @@
 #include "gdb_regex.h"
 #include "rust-lang.h"
 #include "parser-defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "value.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 
 #define GDB_YY_REMAP_PREFIX rust
 #include "yy-remap.h"
index fa27b58e56efd0eef76e78bd893e91e3dafbb268..a9d20e809c17d72bfd15d0905b83cc89bdce8a65 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "arch-utils.h"
 #include "dwarf2-frame.h"
-#include "common/errors.h"
+#include "gdbsupport/errors.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
 #include "gdbcmd.h"
index 38cd6248d047f31585a3fd90b9e48ea75d6fad55..e440a300d4e58d4868446476b54bbcb045945078 100644 (file)
@@ -19,7 +19,7 @@
 #include "defs.h"
 
 #if GDB_SELF_TEST
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "arch-utils.h"
 
index 683d3f4252870a02ccf18dcb285300c12eb7228d..85429b68cbb1698dab22e43cd4f0522bf252bb5e 100644 (file)
@@ -23,7 +23,7 @@
 #include "event-loop.h"
 
 #include "gdb_select.h"
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 #ifdef USE_WIN32API
 #include <winsock2.h>
 #endif
index d3956346246db5cdf6667992050839584aac979a..a65a186526f24be2d8d46859c85fe702a6ca91ac 100644 (file)
@@ -19,7 +19,7 @@
 #include "defs.h"
 #include "ser-event.h"
 #include "serial.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 
 /* On POSIX hosts, a serial_event is basically an abstraction for the
    classical self-pipe trick.
index 702d97c551371e064f464b2f2a52d18ee21c8c2c..61d5708ea09cc490648e048c72fd3f480e999df9 100644 (file)
@@ -27,9 +27,9 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 #include <fcntl.h>
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 
 #include <signal.h>
 
index 5aa7105dc2cb4e8549f286994d918e3e7e4cd06a..cc96a52dc3e153b9417b3df7b68e48704f21c775 100644 (file)
@@ -24,8 +24,8 @@
 #include "gdbcmd.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-setshow.h"
-#include "common/filestuff.h"
-#include "common/netstuff.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/netstuff.h"
 
 #include <sys/types.h>
 
@@ -36,7 +36,7 @@
 #include <sys/ioctl.h>  /* For FIONBIO.  */
 #endif
 
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 
 #ifdef USE_WIN32API
 #include <ws2tcpip.h>
index 3492619f2d6e50d039b3432a1cb040e83a5fd03e..049dfd5261f78ec916debf3a3582e4a6a7e0256d 100644 (file)
 #include <sys/types.h>
 #include "terminal.h"
 #include <sys/socket.h>
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 
 #include "gdb_select.h"
 #include "gdbcmd.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include <termios.h>
 #include "inflow.h"
 
index 127b11dc4431b4d8fd192db8345f31cdcee83b4e..039d50cb117e90f023c840f7d190d171bc0f4475 100644 (file)
@@ -34,7 +34,7 @@
 #include "filenames.h"
 #include "fnmatch.h"
 #include "gdb_regex.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 #include <list>
 
 /* True if we want to print debug printouts related to file/function
index ab4f36262903ed2d2c7fa3de2c81d039a06ae3dd..bf2f30d01cd33c4314e25647cda67522338c466e 100644 (file)
@@ -26,7 +26,7 @@
 #include "xcoffread.h"
 #include "observable.h"
 #include "gdbcmd.h"
-#include "common/scope-exit.h"
+#include "gdbsupport/scope-exit.h"
 
 /* Variable controlling the output of the debugging traces for
    this module.  */
index a1cf94c42e6859caedf2f7a0a8eddc69b42c3699..1ccbc27b2bce09a9a81cde4b7759188f63c7a04a 100644 (file)
@@ -23,7 +23,7 @@
 #include "symtab.h"
 #include "symfile.h"
 #include "target.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "solib-target.h"
 #include <vector>
 
index e0b1a921f82c3247e45e27cdd1a60f5db85a01ea..29a17ad5d496bd6f4b68e4e978321d7037877842 100644 (file)
@@ -31,7 +31,7 @@
 #include "frame.h"
 #include "gdb_regex.h"
 #include "inferior.h"
-#include "common/environ.h"
+#include "gdbsupport/environ.h"
 #include "language.h"
 #include "gdbcmd.h"
 #include "completer.h"
@@ -45,7 +45,7 @@
 #include "interps.h"
 #include "filesystem.h"
 #include "gdb_bfd.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "source.h"
 
 /* Architecture-specific operations.  */
index 86efe83bf9a5679de9a58e2ff0ebe9a3dc37c11e..94d82073bccb06a327952794c01540890d6c3355 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "defs.h"
 #include "source-cache.h"
-#include "common/scoped_fd.h"
+#include "gdbsupport/scoped_fd.h"
 #include "source.h"
 #include "cli/cli-style.h"
 
index dec5a2f84bab5490c19a66b11f1e8bc0d1867457..8ebc4361e17104186db4d31ca738a276bd4a44be 100644 (file)
@@ -26,7 +26,7 @@
 #include "gdbcmd.h"
 #include "frame.h"
 #include "value.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 
 #include <sys/types.h>
 #include <fcntl.h>
 #include "completer.h"
 #include "ui-out.h"
 #include "readline/readline.h"
-#include "common/enum-flags.h"
-#include "common/scoped_fd.h"
+#include "gdbsupport/enum-flags.h"
+#include "gdbsupport/scoped_fd.h"
 #include <algorithm>
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 #include "source-cache.h"
 
 #define OPEN_MODE (O_RDONLY | O_BINARY)
index 1c45405774b830f673fc1703442cb42962a9ca5c..54d899a1d043a43b99f09e9421644bb509a34662 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef SOURCE_H
 #define SOURCE_H
 
-#include "common/scoped_fd.h"
+#include "gdbsupport/scoped_fd.h"
 
 struct symtab;
 
index 173fd0b639706ee240522667b36928fd2fc97b0f..3685e5af410a9bd7bdc7e33abb0a82faf27bc7c5 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <signal.h>
 #include <sys/ptrace.h>
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #ifdef HAVE_MACHINE_REG_H
 #include <machine/reg.h>
 #endif
index 90a9f002848b484a359956c76273a8b8414954cd..2f4b4d694642b2a4576f3c5f101489af6d906814 100644 (file)
@@ -26,7 +26,7 @@
 #include "inf-ptrace.h"
 #include "regcache.h"
 #include "symfile.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include "gdbthread.h"
 #include "gdb_bfd.h"
 
index b3d113d3b42a2df0384548e1cab7713b77465b28..f7df7a40d10e6140e4bbd2da68c0daef9461ccd7 100644 (file)
@@ -52,7 +52,7 @@
 #include "symfile.h"
 #include "extension.h"
 #include "observable.h"
-#include "common/def-vector.h"
+#include "gdbsupport/def-vector.h"
 #include "cli/cli-option.h"
 
 /* The possible choices of "set print frame-arguments", and the value
index aa1c8144d8a0b43c902fdb36d74659375366033f..866b41e7f04e367c1d94c81cbd783e3eae30017a 100644 (file)
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "stap-probe.h"
 #include "probe.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "ui-out.h"
 #include "objfiles.h"
 #include "arch-utils.h"
index b29baa15e390a940536f61f33b312402d287e2a1..9c6564d57c0dc6e37c56b441dcd1263a409e0560 100644 (file)
@@ -20,7 +20,7 @@
 #if !defined (SYMFILE_ADD_FLAGS_H)
 #define SYMFILE_ADD_FLAGS_H
 
-#include "common/enum-flags.h"
+#include "gdbsupport/enum-flags.h"
 
 /* This enum encodes bit-flags passed as ADD_FLAGS parameter to
    symbol_file_add, etc.  Defined in a separate file to break circular
index dc6bdf3fd4a49f7ae4268d15abc0c71742328f05..13a07e4dc0e57eff06680b25d921c5009dc20e07 100644 (file)
 #include "stack.h"
 #include "gdb_bfd.h"
 #include "cli/cli-utils.h"
-#include "common/byte-vector.h"
-#include "common/pathstuff.h"
-#include "common/selftest.h"
+#include "gdbsupport/byte-vector.h"
+#include "gdbsupport/pathstuff.h"
+#include "gdbsupport/selftest.h"
 #include "cli/cli-style.h"
-#include "common/forward-scope-exit.h"
+#include "gdbsupport/forward-scope-exit.h"
 
 #include <sys/types.h>
 #include <fcntl.h>
index 403dd165264e427db214644c347f5b0bceb67360..741b085e0c4f0cb5226aa68f45a60a441070d952 100644 (file)
@@ -26,7 +26,7 @@
 #include "symfile-add-flags.h"
 #include "objfile-flags.h"
 #include "gdb_bfd.h"
-#include "common/function-view.h"
+#include "gdbsupport/function-view.h"
 
 /* Opaque declarations.  */
 struct target_section;
index 6e7e32fb4d872d919beabbe9ca5588c22057e2ae..01118c62555cc33de975603f2974dc8c6370a1f8 100644 (file)
 #include "parser-defs.h"
 #include "completer.h"
 #include "progspace-and-thread.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 #include "filename-seen-cache.h"
 #include "arch-utils.h"
 #include <algorithm>
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 
 /* Forward declarations for local functions.  */
 
index e4ee7271a15f9d333fe584acd47fd2f9964aa64f..6780fa37be17b88a8cb7e2fb69441714912bd585 100644 (file)
 #include <array>
 #include <vector>
 #include <string>
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 #include "gdbtypes.h"
 #include "gdb_regex.h"
-#include "common/enum-flags.h"
-#include "common/function-view.h"
-#include "common/gdb_optional.h"
-#include "common/next-iterator.h"
+#include "gdbsupport/enum-flags.h"
+#include "gdbsupport/function-view.h"
+#include "gdbsupport/gdb_optional.h"
+#include "gdbsupport/next-iterator.h"
 #include "completer.h"
 
 /* Opaque declarations.  */
index bd33091ba9e4bcbad5efafe4fb6e211ca379bfe9..f422f2c14c235c46239716e35041e74608d0909b 100644 (file)
@@ -26,7 +26,7 @@
 #include "reggroups.h"
 #include "target.h"
 #include "target-descriptions.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "xml-support.h"
 #include "xml-tdesc.h"
 #include "osabi.h"
@@ -635,7 +635,7 @@ tdesc_architecture (const struct target_desc *target_desc)
   return target_desc->arch;
 }
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 const char *
 tdesc_architecture_name (const struct target_desc *target_desc)
@@ -652,7 +652,7 @@ tdesc_osabi (const struct target_desc *target_desc)
   return target_desc->osabi;
 }
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 const char *
 tdesc_osabi_name (const struct target_desc *target_desc)
@@ -1125,7 +1125,7 @@ tdesc_use_registers (struct gdbarch *gdbarch,
   set_gdbarch_register_reggroup_p (gdbarch, tdesc_register_reggroup_p);
 }
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 struct tdesc_feature *
 tdesc_create_feature (struct target_desc *tdesc, const char *name)
@@ -1182,7 +1182,7 @@ set_tdesc_property (struct target_desc *target_desc,
   target_desc->properties.emplace_back (key, value);
 }
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 void
 set_tdesc_architecture (struct target_desc *target_desc,
@@ -1198,7 +1198,7 @@ set_tdesc_architecture (struct target_desc *target_desc,
   target_desc->arch = arch;
 }
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 void
 set_tdesc_osabi (struct target_desc *target_desc, const char *name)
@@ -1563,7 +1563,7 @@ public:
     printf_unfiltered ("  Original: %s */\n\n",
                       lbasename (m_filename_after_features.c_str ()));
 
-    printf_unfiltered ("#include \"common/tdesc.h\"\n");
+    printf_unfiltered ("#include \"gdbsupport/tdesc.h\"\n");
     printf_unfiltered ("\n");
   }
 
@@ -1658,7 +1658,7 @@ private:
   int m_next_regnum = 0;
 };
 
-/* See common/tdesc.h.  */
+/* See gdbsupport/tdesc.h.  */
 
 const char *
 tdesc_get_features_xml (const target_desc *tdesc)
index fe07d425a5f9620ca6f53fa6da251a3af63b5063..5f27eed06dbb864d2df3aeaefff3fc71d5f36580 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef TARGET_DESCRIPTIONS_H
 #define TARGET_DESCRIPTIONS_H 1
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 struct tdesc_arch_data;
 struct target_ops;
index d04363c2a56ca67185d74c9f5c54cc1567eb4e0e..ce964babaace3bdd53c39ff4fb8dc8d7aa6893fe 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "target.h"
 #include "memory-map.h"
 
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 #include <algorithm>
 
 static bool
index 1c04095fd63c329a4d92331154280d2adf0b4e7b..de3706d75dc108d2c69ef769a8e4ce1293de62a3 100644 (file)
 #include "inline-frame.h"
 #include "tracepoint.h"
 #include "gdb/fileio.h"
-#include "common/agent.h"
+#include "gdbsupport/agent.h"
 #include "auxv.h"
 #include "target-debug.h"
 #include "top.h"
 #include "event-top.h"
 #include <algorithm>
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 #include "terminal.h"
 #include <unordered_map>
 
index 323357ca5503cea8f32f7bd5e4403214cf4b1034..4e2e75cb8067f5edf0d0f4f84b8de1f43122766a 100644 (file)
@@ -42,7 +42,7 @@ struct inferior;
 
 #include "infrun.h" /* For enum exec_direction_kind.  */
 #include "breakpoint.h" /* For enum bptype.  */
-#include "common/scoped_restore.h"
+#include "gdbsupport/scoped_restore.h"
 
 /* This include file defines the interface between the main part
    of the debugger, and the part which is target-specific, or
@@ -74,15 +74,15 @@ struct inferior;
 #include "bfd.h"
 #include "symtab.h"
 #include "memattr.h"
-#include "common/vec.h"
-#include "common/gdb_signals.h"
+#include "gdbsupport/vec.h"
+#include "gdbsupport/gdb_signals.h"
 #include "btrace.h"
 #include "record.h"
 #include "command.h"
 #include "disasm.h"
 #include "tracepoint.h"
 
-#include "common/break-common.h" /* For enum target_hw_bp_type.  */
+#include "gdbsupport/break-common.h" /* For enum target_hw_bp_type.  */
 
 enum strata
   {
index f86ce223739f5b01477622097c16341c7faf6d6a..0b74f788b7478de84d97f1b54fefb5148fa26dea 100644 (file)
@@ -17,7 +17,7 @@
    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 "common/common-defs.h"
+#include "gdbsupport/common-defs.h"
 #include "waitstatus.h"
 
 /* Return a pretty printed form of target_waitstatus.  */
index 8f48599e9e8c3d0ee9847ba475267a185cc62fd6..ec1abed7b4030587a88f4f51d1731fd777cf0b17 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef TARGET_WAITSTATUS_H
 #define TARGET_WAITSTATUS_H
 
-#include "common/gdb_signals.h"
+#include "gdbsupport/gdb_signals.h"
 
 /* Stuff for target_wait.  */
 
index be6ab73c6863a092c06d6ecb727d7c6d15442545..72ee9ddcb8441e873a85e0edc1528d0fc9103446 100644 (file)
@@ -19,9 +19,9 @@
 #ifndef THREAD_ITER_H
 #define THREAD_ITER_H
 
-#include "common/filtered-iterator.h"
-#include "common/next-iterator.h"
-#include "common/safe-iterator.h"
+#include "gdbsupport/filtered-iterator.h"
+#include "gdbsupport/next-iterator.h"
+#include "gdbsupport/safe-iterator.h"
 
 /* A forward iterator that iterates over a given inferior's
    threads.  */
index d13298f5c6f5401478c704ecebe9b197ac118408..2d25cee7cee7fed7a1fb01fadd342ebaf50f10e8 100644 (file)
@@ -23,7 +23,7 @@
 #include "symtab.h"
 #include "frame.h"
 #include "inferior.h"
-#include "common/environ.h"
+#include "gdbsupport/environ.h"
 #include "value.h"
 #include "target.h"
 #include "gdbthread.h"
@@ -45,7 +45,7 @@
 #include "thread-fsm.h"
 #include "tid-parse.h"
 #include <algorithm>
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 #include "inline-frame.h"
 #include "stack.h"
 
@@ -1307,7 +1307,7 @@ switch_to_thread (thread_info *thr)
   reinit_frame_cache ();
 }
 
-/* See common/common-gdbthread.h.  */
+/* See gdbsupport/common-gdbthread.h.  */
 
 void
 switch_to_thread (ptid_t ptid)
index a5f05ef15151103fb55f65831d0a82dc925ba6f2..aa2681e2127a27dc221984965ee79f128996ccb4 100644 (file)
@@ -40,7 +40,7 @@
 #include "tilegx-tdep.h"
 #include "opcode/tilegx.h"
 #include <algorithm>
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 
 struct tilegx_frame_cache
 {
index c5fc94f82951de115dab3588343b3aaa40ee4244..c28e660a057039d14fe2af5ff7e16b0efbaa42e3 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
 #include "value.h"
 #include "language.h"
 #include "terminal.h"
-#include "common/job-control.h"
+#include "gdbsupport/job-control.h"
 #include "annotate.h"
 #include "completer.h"
 #include "top.h"
-#include "common/version.h"
+#include "gdbsupport/version.h"
 #include "serial.h"
 #include "main.h"
 #include "event-loop.h"
@@ -50,9 +50,9 @@
 #include "maint.h"
 #include "filenames.h"
 #include "frame.h"
-#include "common/buffer.h"
+#include "gdbsupport/buffer.h"
 #include "gdb_select.h"
-#include "common/scope-exit.h"
+#include "gdbsupport/scope-exit.h"
 
 /* readline include files.  */
 #include "readline/readline.h"
index aab03c13d69b08460d37e46aae9ff30d5a1d20ac..e7659b65ffe4c619291d5fb5456546708ff85ae8 100644 (file)
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -20,7 +20,7 @@
 #ifndef TOP_H
 #define TOP_H
 
-#include "common/buffer.h"
+#include "gdbsupport/buffer.h"
 #include "event-loop.h"
 #include "value.h"
 
index 593556a8ba8935da475909fb6d82b57f2c15015d..2e61d83409046420793e3bb6d6250e764d0617c5 100644 (file)
@@ -20,8 +20,8 @@
 #include "defs.h"
 #include "tracefile.h"
 #include "readline/tilde.h"
-#include "common/filestuff.h"
-#include "common/rsp-low.h" /* bin2hex */
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/rsp-low.h" /* bin2hex */
 #include "regcache.h"
 #include "inferior.h"
 #include "gdbthread.h"
@@ -31,7 +31,7 @@
 #include "remote.h"
 #include "xml-tdesc.h"
 #include "target-descriptions.h"
-#include "common/buffer.h"
+#include "gdbsupport/buffer.h"
 #include <algorithm>
 
 #ifndef O_LARGEFILE
index bf886e06521a7ab38d56a2968306babe9650c823..7ed2fc08e4997b3a5dbf6e06881fbef02a2024ef 100644 (file)
@@ -22,7 +22,7 @@
 #include "ctf.h"
 #include "exec.h"
 #include "regcache.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 
 /* Helper macros.  */
 
index af5dcd1e339d9612a297c52d9e3577754dfc1113..5674400776a79d7243f411afca6e507066de665e 100644 (file)
@@ -52,8 +52,8 @@
 #include "cli/cli-utils.h"
 #include "probe.h"
 #include "ctf.h"
-#include "common/filestuff.h"
-#include "common/rsp-low.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/rsp-low.h"
 #include "tracefile.h"
 #include "location.h"
 #include <algorithm>
index ca9d2a779439933ca7f6e273b1f6eb02d8a4d42e..440effb39d6a08228ce373aa345c93048342e7a9 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "breakpoint.h"
 #include "memrange.h"
-#include "common/gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
 
 #include <vector>
 #include <string>
index 56d5974cb35774e8314ef51abd91ecade28fc12a..c9607d8f3c8d3589bc6489c8bbb0662e3455c645 100644 (file)
@@ -40,7 +40,7 @@
 #ifdef __MINGW32__
 #include <windows.h>
 #endif
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "completer.h"
 #include "gdb_curses.h"
 #include <map>
index 05d411aa3929f8fe8bca7582440cf7e5a2797203..042b13ca3b1890f0653a727848a768b8179dbf41 100644 (file)
@@ -23,7 +23,7 @@
 #include "ui-file.h"
 #include "gdb_obstack.h"
 #include "gdb_select.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 
 null_file null_stream;
 
index 9eba70eedac646911e137348298fbc27d41ec048..8574204b92aaece802af39880c6123763573d07b 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <vector>
 
-#include "common/enum-flags.h"
+#include "gdbsupport/enum-flags.h"
 
 class ui_out_level;
 class ui_out_table;
index d0d1128cd2a0452c2272c42d219c5fa635d6ab33..95a4cc799f01c5590a947a7a48b58be52391cb34 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
-#include "common/array-view.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/array-view.h"
 #include <array>
 
 namespace selftests {
index 4c436efa969ae593c42575486db194d7132a595d..2ed83faed66b868a650a6f6da7a4cc9ecd457b78 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/pathstuff.h"
-#include "common/selftest.h"
+#include "gdbsupport/pathstuff.h"
+#include "gdbsupport/selftest.h"
 
 namespace selftests {
 namespace child_path {
index a251a8e58f84a386b5b5cd2e2688cedb15db179f..6d8928fd6bcf2a27f89615190ae91a6bf613b718 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "defs.h"
 #include "cli/cli-utils.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 
 namespace selftests {
 namespace cli_utils {
index 996ab5e82d138f6d3046cd1e9fb0c7d25485e2a0..3d4211da86d1e6899a3abdd519fdaa17801ed2bf 100644 (file)
@@ -17,8 +17,8 @@
    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 "common/common-defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/common-defs.h"
+#include "gdbsupport/selftest.h"
 
 namespace selftests {
 
index 9dd9aeac00cf5e702d97bcbdc2d5e52e651ac1aa..aad4614ecf5d9f27a440cf03fdb32fe815ab7e36 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "utils.h"
 
 namespace selftests {
index 2bbff7039e69ee60740775c4d28fd76c3446fc50..c499f01cfae82c16abbc80e6e9c75b81cc2ec757 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
-#include "common/environ.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/environ.h"
 #include "diagnostics.h"
 
 static const char gdb_selftest_env_var[] = "GDB_SELFTEST_ENVIRON";
index 976af3d2fcd68c78e2aaac9dda9bd35ca0790949..7d31b3cb93fbaee60c395d215810f3114080fba2 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/format.h"
-#include "common/selftest.h"
+#include "gdbsupport/format.h"
+#include "gdbsupport/selftest.h"
 
 namespace selftests {
 namespace format_pieces {
index 2abaa1f99170b3d2aac31d7c06deccdef7440f11..f0d58d8778bad3dd3b33ac355a4e4493dff80e9c 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
-#include "common/function-view.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/function-view.h"
 
 namespace selftests {
 namespace function_view {
index 04fcd7e0b5a0cd2c38ba54adc52e2b71b1082b9e..747728158d8e18ebf2e6542f178fa618cd1e425b 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "symtab.h"
 
 namespace selftests {
index fc6f0fe57300b9081941146683851d9b4d054bc6..f64f050133519013cd1f6d41e5384455e865bd0e 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "memory-map.h"
 
 #if defined(HAVE_LIBEXPAT)
index ada8e3e43427418eba83643d0c5818b11cbce2bd..6fe1fe622f520227cc8f164d251cc8c22fcd995c 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "memrange.h"
 
 namespace selftests {
index a8b571f38c78d595097e4a503f32138ae9a997d1..8be4a922f712d29d102c7fa53279916ab07cfe5d 100644 (file)
 
 #include "defs.h"
 
-#include "common/filestuff.h"
-#include "common/selftest.h"
-#include "common/byte-vector.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/byte-vector.h"
+#include "gdbsupport/pathstuff.h"
 
 namespace selftests {
 namespace mkdir_recursive {
index 2a51a999561eada9ed83376bc706d7662a861498..f7a8e9606ae808b7dc2f29ba5966408a191bfde0 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
-#include "common/observable.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/observable.h"
 
 namespace selftests {
 namespace observers {
index 8222a94ad024f595d1f4c852170a1b6de828e5f1..57a1a27d1337d7d2e030207b2e3d90f270647f6f 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
-#include "common/offset-type.h"
-#include "common/underlying.h"
-#include "common/valid-expr.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/offset-type.h"
+#include "gdbsupport/underlying.h"
+#include "gdbsupport/valid-expr.h"
 
 namespace selftests {
 namespace offset_type {
index fdd4437b16edfde054e5fe11cbab7d17facf6adf..828b0e8577ac5adbd525d746b16729ef05b98acb 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/gdb_optional.h"
 
 /* Used by the included .cc files below.  Included here because the
    included test files are wrapped in a namespace.  */
index 915aa669f428600c9ce4eb5204a1670ad0619e90..b86ab4343f2812882816be7c1c5cf6a86ffc8648 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
-#include "common/netstuff.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/netstuff.h"
 #include "diagnostics.h"
 #ifdef USE_WIN32API
 #include <ws2tcpip.h>
index 0194d9a229f52baa5b1709e26920dce9893baa9b..1deb738e1bfd1574e6b97311878f2d25f6091098 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/ptid.h"
+#include "gdbsupport/ptid.h"
 #include <type_traits>
 
 namespace selftests {
index dc3e8f5205476551447a49eb86dd168285cdf6d4..e316a22c74c876d0743e83dd554b8f9bd3e191bc 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
-#include "common/rsp-low.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/rsp-low.h"
 
 namespace selftests {
 namespace rsp_low {
index 886ff261acb404a29204fe4a3b1c84cd48623dfe..c3d17102cd5d897fdaa97554c3c155a8e66351ac 100644 (file)
 
 #include "defs.h"
 
-#include "common/filestuff.h"
-#include "common/scoped_fd.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/scoped_fd.h"
 #include "config.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 
 namespace selftests {
 namespace scoped_fd {
index a3d2040b62ae38fe02b7ca79791bf648de4df7f2..37d91ae1f25f413c5f7e92f35715d5846326aa65 100644 (file)
 
 #include "defs.h"
 
-#include "common/filestuff.h"
-#include "common/scoped_mmap.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/scoped_mmap.h"
 #include "config.h"
 
 #if defined(HAVE_SYS_MMAN_H)
 
-#include "common/selftest.h"
-#include "common/gdb_unlinker.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/gdb_unlinker.h"
 
 #include <unistd.h>
 
index 564ca07a92075d7aa5df2d0e9c06ffde83c9293b..c05cccf04687ba843c83722b16cd1cb87072076d 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
-#include "common/scoped_restore.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/scoped_restore.h"
 
 namespace selftests {
 namespace scoped_restore_tests {
index b2a2bf7f2e95ca75f1ba51977a9e8f411f83b0b1..910f6588d7b4543cff9a9bf65e9a853e9c1bfa0a 100644 (file)
@@ -24,8 +24,8 @@
 #define GNULIB_NAMESPACE gnulib
 
 #include "defs.h"
-#include "common/selftest.h"
-#include "common/gdb_string_view.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/gdb_string_view.h"
 
 /* Used by the included .cc files below.  Included here because the
    included test files are wrapped in a namespace.  */
index 9682724b86fb597b6d32ac7500c0f8d1591c4a36..fc7f144c235f19272b6c632da5c53be08885ccdc 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "ui-style.h"
 
 namespace selftests {
index 1e2618453b4c3ab6d63bb54dc7bd4f58b1f004b2..1f04c7cea2412ffd518acc097ddd0a3efb9a3f73 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "tracepoint.h"
 
 namespace selftests {
index e85aa2180b7e83a9602e9c03c0ab637c7b7bbdf4..ffb6238445b39c174308f4922133194bc64caf4b 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "value.h"
 #include "gdbtypes.h"
index c874de3e181805952d4bbe56fee42d19ffa7b676..ec81124001f9ed5b6d2b2d49a78fd7e0f5891d88 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "defs.h"
 #include "utils.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 
 namespace selftests {
 namespace utils {
index 2c24056aacd7b12a018154a067007d55ee273574..99c431b236054ec696892c46ea1f5d35e33272de 100644 (file)
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "common/xml-utils.h"
-#include "common/selftest.h"
+#include "gdbsupport/xml-utils.h"
+#include "gdbsupport/selftest.h"
 
 namespace selftests {
 namespace xml_utils {
index 7120a92258445063e271ee2c802189fafc1c9314..94ce09118d8870a503c3911ae3378d9868af6ba9 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "defs.h"
 #include <ctype.h>
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include "event-top.h"
 #include "gdbthread.h"
 #include "fnmatch.h"
 #include "gdb_usleep.h"
 #include "interps.h"
 #include "gdb_regex.h"
-#include "common/job-control.h"
-#include "common/selftest.h"
-#include "common/gdb_optional.h"
+#include "gdbsupport/job-control.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/gdb_optional.h"
 #include "cp-support.h"
 #include <algorithm>
-#include "common/pathstuff.h"
+#include "gdbsupport/pathstuff.h"
 #include "cli/cli-style.h"
-#include "common/scope-exit.h"
+#include "gdbsupport/scope-exit.h"
 
 void (*deprecated_error_begin_hook) (void);
 
index 58b4a283447e03829274ed8e9c6370172274227e..3c0aee73eda6e7a3cb8eef58441179f6963f9220 100644 (file)
@@ -22,7 +22,7 @@
 #define UTILS_H
 
 #include "exceptions.h"
-#include "common/scoped_restore.h"
+#include "gdbsupport/scoped_restore.h"
 #include <chrono>
 
 extern void initialize_utils (void);
index 8d310b504a265e08170665d664b0dd501ab17c57..e730e5c55d5bafe509bb8951d7d48c35825e3871 100644 (file)
@@ -26,7 +26,7 @@
 #include "language.h"
 #include "target-float.h"
 #include "infcall.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 
 /* Define whether or not the C operator '/' truncates towards zero for
    differently signed operands (truncation direction is undefined in C).  */
index 948ad89fe9270b1e85f8242f7722b27fe946f8a9..663edae20340ed48f706618b49b238af5a78fd8c 100644 (file)
@@ -39,7 +39,7 @@
 #include "observable.h"
 #include "objfiles.h"
 #include "extension.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 
 extern unsigned int overload_debug;
 /* Local functions.  */
index 6f9b47da80c1101e60a67993c1b676ad5bb72244..7b2b79b53964d1a5d723dc88d1ec5d5015c226f9 100644 (file)
@@ -35,7 +35,7 @@
 #include "typeprint.h"
 #include <ctype.h>
 #include <algorithm>
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 #include "cli/cli-option.h"
 
 /* Maximum number of wchars returned from wchar_iterate.  */
index 1b22cf916e3c921bb33e7afcba016626621de1af..9103d8f41c345d20c437625fb82095985b64d37c 100644 (file)
@@ -41,8 +41,8 @@
 #include "user-regs.h"
 #include <algorithm>
 #include "completer.h"
-#include "common/selftest.h"
-#include "common/array-view.h"
+#include "gdbsupport/selftest.h"
+#include "gdbsupport/array-view.h"
 
 /* Definition of a user function.  */
 struct internal_function
index 0756d13b6d79f060e9ada774518092e49ec1a9d4..f96b095941a2471844c6cd0f1ec2db039ffa5815 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "frame.h"             /* For struct frame_id.  */
 #include "extension.h"
-#include "common/gdb_ref_ptr.h"
+#include "gdbsupport/gdb_ref_ptr.h"
 
 struct block;
 struct expression;
index 8ec8298a12c6d256df7bcf8f59fe18886f22a5a4..17f4ae06d8cae940779e999289d8f45442805329 100644 (file)
@@ -26,7 +26,7 @@
 #include "gdb_regex.h"
 
 #include "varobj.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "gdbthread.h"
 #include "inferior.h"
 #include "varobj-iter.h"
index 5d8c6876dd8f4ee8da794e587ef2e08f9a5d5d77..9067d2d6beb7f8c99e0ad05da79f16c4da47216e 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "symtab.h"
 #include "gdbtypes.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
 #include "value.h"
 
 /* Enumeration for the format types */
index ae4e3d55b308149b17e9606b0c6b9621498fbdf3..3431181a88cb630fc19dd8b68e9dfc37bb636a74 100644 (file)
@@ -67,8 +67,8 @@
 #include "x86-nat.h"
 #include "complaints.h"
 #include "inf-child.h"
-#include "common/gdb_tilde_expand.h"
-#include "common/pathstuff.h"
+#include "gdbsupport/gdb_tilde_expand.h"
+#include "gdbsupport/pathstuff.h"
 
 #define AdjustTokenPrivileges          dyn_AdjustTokenPrivileges
 #define DebugActiveProcessStop         dyn_DebugActiveProcessStop
index fe85358fa263adfee386b63d7950d6cb77d46f93..e1b592510fa6c810d941946e20189b7c353fe9d3 100644 (file)
@@ -35,7 +35,7 @@
 #ifdef __x86_64__
 #include "amd64-linux-tdep.h"
 #endif
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "nat/linux-btrace.h"
 #include "nat/linux-nat.h"
 #include "nat/x86-linux.h"
index ae727da03b360d0039c1f4fa70fd31fcb1f8a816..8b79d69a6d58e067cf627f753e04bb5895287fc0 100644 (file)
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "gdbcmd.h"
 #include "xml-support.h"
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "safe-ctype.h"
 #include <vector>
 #include <string>
index c5cf617050a1ec1ab11d3ea2cbfea526d8e3f544..eebd79d33a4e7eae9fda60402bcd9be5c8acf3d8 100644 (file)
@@ -22,9 +22,9 @@
 #define XML_SUPPORT_H
 
 #include "gdb_obstack.h"
-#include "common/vec.h"
-#include "common/xml-utils.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/vec.h"
+#include "gdbsupport/xml-utils.h"
+#include "gdbsupport/byte-vector.h"
 
 struct gdb_xml_parser;
 struct gdb_xml_element;
index 2137ee8a411fc12752d8d29a6c94c6f77e2811e1..902509b51f2eb565c0ecc21edba0d2e6027e91f3 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef XML_TDESC_H
 #define XML_TDESC_H
 
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 #include <string>
 
 struct target_ops;
index 1555eb1eb4a953ff41abc4122f6074b2b2d580cf..2dd76c3725170cc5ccc25f35e4025193f12b45bf 100644 (file)
@@ -33,7 +33,7 @@
 #include "regcache.h"
 #include "osabi.h"
 #include "objfiles.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 
 enum gdb_regnum
 {
index 13904069b3a796f794499bf98316ac689576a60c..3ff66d171a050fe6ca7722332819e8216e0a333c 100644 (file)
@@ -28,7 +28,7 @@
 #include <signal.h>
 #include <sys/user.h>
 #include <sys/ioctl.h>
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include <fcntl.h>
 #include <sys/procfs.h>
 #include "nat/gdb_ptrace.h"
This page took 0.635007 seconds and 4 git commands to generate.