pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
gdb-netbsd: Sync with 2019-02-02
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Mon Sep 2 22:07:53 2019 +0200
Changeset: 4bdef9a128ec4590146fb1ef662a7161ca46836e
Modified Files:
gdb-netbsd/distinfo
gdb-netbsd/patches/patch-gdb_configure.tgt
gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-low.c
gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-low.h
gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-x86__64-low.c
Added Files:
gdb-netbsd/patches/patch-bfd_config.bfd
gdb-netbsd/patches/patch-bfd_configure
gdb-netbsd/patches/patch-bfd_doc_Makefile.in
gdb-netbsd/patches/patch-bfd_elf.c
gdb-netbsd/patches/patch-bfd_merge.c
gdb-netbsd/patches/patch-bfd_netbsd-core.c
gdb-netbsd/patches/patch-config_acinclude.m4
gdb-netbsd/patches/patch-cpu_epiphany.opc
gdb-netbsd/patches/patch-gdb_Makefile.in
gdb-netbsd/patches/patch-gdb_aarch64-nbsd-nat.c
gdb-netbsd/patches/patch-gdb_aarch64-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_aarch64-nbsd-tdep.h
gdb-netbsd/patches/patch-gdb_alpha-bsd-nat.c
gdb-netbsd/patches/patch-gdb_alpha-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_alpha-tdep.c
gdb-netbsd/patches/patch-gdb_amd64-bsd-nat.c
gdb-netbsd/patches/patch-gdb_amd64-nbsd-nat.c
gdb-netbsd/patches/patch-gdb_amd64-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_arm-nbsd-nat.c
gdb-netbsd/patches/patch-gdb_arm-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_auxv.c
gdb-netbsd/patches/patch-gdb_bsd-kvm.c
gdb-netbsd/patches/patch-gdb_config_aarch64_nbsd.mh
gdb-netbsd/patches/patch-gdb_config_ia64_netbsd.mh
gdb-netbsd/patches/patch-gdb_config_powerpc_ppc64-nbsd.mh
gdb-netbsd/patches/patch-gdb_configure
gdb-netbsd/patches/patch-gdb_configure.host
gdb-netbsd/patches/patch-gdb_configure.nat
gdb-netbsd/patches/patch-gdb_contrib_ari_gdb__ari.sh
gdb-netbsd/patches/patch-gdb_contrib_expect-read1.sh
gdb-netbsd/patches/patch-gdb_doc_stabs.texinfo
gdb-netbsd/patches/patch-gdb_features_feature__to__c.sh
gdb-netbsd/patches/patch-gdb_gdbsupport_agent.c
gdb-netbsd/patches/patch-gdb_gdbsupport_common-defs.h
gdb-netbsd/patches/patch-gdb_gdbsupport_pathstuff.h
gdb-netbsd/patches/patch-gdb_hppa-nbsd-nat.c
gdb-netbsd/patches/patch-gdb_hppa-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_hppa-tdep.c
gdb-netbsd/patches/patch-gdb_hppa-tdep.h
gdb-netbsd/patches/patch-gdb_i386-bsd-nat.c
gdb-netbsd/patches/patch-gdb_i386-bsd-nat.h
gdb-netbsd/patches/patch-gdb_i386-nbsd-nat.c
gdb-netbsd/patches/patch-gdb_i386-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_ia64-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_inf-ptrace.c
gdb-netbsd/patches/patch-gdb_m68k-bsd-nat.c
gdb-netbsd/patches/patch-gdb_mips-nbsd-nat.c
gdb-netbsd/patches/patch-gdb_mips-tdep.h
gdb-netbsd/patches/patch-gdb_nbsd-nat.c
gdb-netbsd/patches/patch-gdb_nbsd-nat.h
gdb-netbsd/patches/patch-gdb_nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_nbsd-tdep.h
gdb-netbsd/patches/patch-gdb_objfiles.c
gdb-netbsd/patches/patch-gdb_p-exp.y
gdb-netbsd/patches/patch-gdb_ppc-nbsd-nat.c
gdb-netbsd/patches/patch-gdb_ppc-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_ppc-nbsd-tdep.h
gdb-netbsd/patches/patch-gdb_sh-nbsd-nat.c
gdb-netbsd/patches/patch-gdb_sh-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_sh-nbsd-tdep.h
gdb-netbsd/patches/patch-gdb_sparc-nat.c
gdb-netbsd/patches/patch-gdb_sparc-nat.h
gdb-netbsd/patches/patch-gdb_sparc-nbsd-nat.c
gdb-netbsd/patches/patch-gdb_sparc-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_sparc-nbsd-tdep.h
gdb-netbsd/patches/patch-gdb_sparc-tdep.h
gdb-netbsd/patches/patch-gdb_sparc64-nbsd-nat.c
gdb-netbsd/patches/patch-gdb_sparc64-nbsd-tdep.c
gdb-netbsd/patches/patch-gdb_testsuite_gdb.ada_uninitialized__vars_parse__controlled.ads
gdb-netbsd/patches/patch-gdb_testsuite_gdb.base_testenv.c
gdb-netbsd/patches/patch-gdb_testsuite_lib_compiler.cc
gdb-netbsd/patches/patch-gdb_testsuite_lib_pdtrace.in
gdb-netbsd/patches/patch-gdb_tui_tui-winsource.c
gdb-netbsd/patches/patch-gdb_user-regs.c
gdb-netbsd/patches/patch-gdb_vax-bsd-nat.c
gdb-netbsd/patches/patch-gdb_x86-bsd-nat.c
gdb-netbsd/patches/patch-include_elf_common.h
gdb-netbsd/patches/patch-include_elf_epiphany.h
gdb-netbsd/patches/patch-include_opcode_bfin.h
gdb-netbsd/patches/patch-intl_Makefile.in
gdb-netbsd/patches/patch-libiberty_make-temp-file.c
gdb-netbsd/patches/patch-libiberty_strerror.c
gdb-netbsd/patches/patch-opcodes_cgen.sh
gdb-netbsd/patches/patch-readline_display.c
gdb-netbsd/patches/patch-readline_doc_texi2dvi
gdb-netbsd/patches/patch-readline_doc_texi2html
gdb-netbsd/patches/patch-readline_examples_readlinebuf.h
gdb-netbsd/patches/patch-readline_examples_rlfe_config.h.in
gdb-netbsd/patches/patch-readline_examples_rlfe_extern.h
gdb-netbsd/patches/patch-readline_examples_rlfe_os.h
gdb-netbsd/patches/patch-readline_rltty.c
gdb-netbsd/patches/patch-readline_support_config.guess
gdb-netbsd/patches/patch-readline_support_config.sub
gdb-netbsd/patches/patch-readline_terminal.c
gdb-netbsd/patches/patch-readline_util.c
gdb-netbsd/patches/patch-sim_common_callback.c
gdb-netbsd/patches/patch-sim_common_cgen.sh
gdb-netbsd/patches/patch-sim_common_genmloop.sh
gdb-netbsd/patches/patch-sim_common_gennltvals.sh
gdb-netbsd/patches/patch-sim_common_gentvals.sh
gdb-netbsd/patches/patch-sim_configure
gdb-netbsd/patches/patch-sim_cr16_configure
gdb-netbsd/patches/patch-sim_ft32_configure
gdb-netbsd/patches/patch-sim_lm32_ChangeLog
gdb-netbsd/patches/patch-sim_microblaze_configure
gdb-netbsd/patches/patch-sim_mips_Makefile.in
gdb-netbsd/patches/patch-sim_mn10300_Makefile.in
gdb-netbsd/patches/patch-sim_moxie_configure
gdb-netbsd/patches/patch-sim_ppc_emul__netbsd.c
gdb-netbsd/patches/patch-sim_ppc_events.c
gdb-netbsd/patches/patch-sim_ppc_hw__memory.c
gdb-netbsd/patches/patch-sim_testsuite_sim_bfin_run-tests.sh
gdb-netbsd/patches/patch-sim_v850_Makefile.in
gdb-netbsd/patches/patch-src-release.sh
Removed Files:
gdb-netbsd/patches/patch-Makefile.in
gdb-netbsd/patches/patch-sim_ppc_emul_netbsd.c
Log Message:
gdb-netbsd: Sync with 2019-02-02
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=4bdef9a128ec4590146fb1ef662a7161ca46836e
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
gdb-netbsd/distinfo | 124 ++++-
gdb-netbsd/patches/patch-Makefile.in | 32 --
gdb-netbsd/patches/patch-bfd_config.bfd | 127 +++++
gdb-netbsd/patches/patch-bfd_configure | 39 ++
gdb-netbsd/patches/patch-bfd_doc_Makefile.in | 13 +
gdb-netbsd/patches/patch-bfd_elf.c | 12 +
gdb-netbsd/patches/patch-bfd_merge.c | 13 +
gdb-netbsd/patches/patch-bfd_netbsd-core.c | 13 +
gdb-netbsd/patches/patch-config_acinclude.m4 | 0
gdb-netbsd/patches/patch-cpu_epiphany.opc | 0
gdb-netbsd/patches/patch-gdb_Makefile.in | 13 +
gdb-netbsd/patches/patch-gdb_aarch64-nbsd-nat.c | 188 +++++++
gdb-netbsd/patches/patch-gdb_aarch64-nbsd-tdep.c | 207 ++++++++
gdb-netbsd/patches/patch-gdb_aarch64-nbsd-tdep.h | 38 ++
gdb-netbsd/patches/patch-gdb_alpha-bsd-nat.c | 132 +++++
gdb-netbsd/patches/patch-gdb_alpha-nbsd-tdep.c | 184 +++++++
gdb-netbsd/patches/patch-gdb_alpha-tdep.c | 36 ++
gdb-netbsd/patches/patch-gdb_amd64-bsd-nat.c | 75 +++
gdb-netbsd/patches/patch-gdb_amd64-nbsd-nat.c | 81 +++
gdb-netbsd/patches/patch-gdb_amd64-nbsd-tdep.c | 219 ++++++++
gdb-netbsd/patches/patch-gdb_arm-nbsd-nat.c | 568 +++++++++++++++++++++
gdb-netbsd/patches/patch-gdb_arm-nbsd-tdep.c | 56 ++
gdb-netbsd/patches/patch-gdb_auxv.c | 19 +
gdb-netbsd/patches/patch-gdb_bsd-kvm.c | 61 +++
.../patches/patch-gdb_config_aarch64_nbsd.mh | 10 +
gdb-netbsd/patches/patch-gdb_config_ia64_netbsd.mh | 10 +
.../patches/patch-gdb_config_powerpc_ppc64-nbsd.mh | 9 +
gdb-netbsd/patches/patch-gdb_configure | 22 +
gdb-netbsd/patches/patch-gdb_configure.host | 30 ++
gdb-netbsd/patches/patch-gdb_configure.nat | 100 ++++
gdb-netbsd/patches/patch-gdb_configure.tgt | 69 ++-
.../patches/patch-gdb_contrib_ari_gdb__ari.sh | 0
.../patches/patch-gdb_contrib_expect-read1.sh | 0
gdb-netbsd/patches/patch-gdb_doc_stabs.texinfo | 5 +
.../patches/patch-gdb_features_feature__to__c.sh | 0
.../patches/patch-gdb_gdbserver_netbsd-low.c | 2 +-
.../patches/patch-gdb_gdbserver_netbsd-low.h | 2 +-
.../patch-gdb_gdbserver_netbsd-x86__64-low.c | 2 +-
gdb-netbsd/patches/patch-gdb_gdbsupport_agent.c | 12 +
.../patches/patch-gdb_gdbsupport_common-defs.h | 23 +
.../patches/patch-gdb_gdbsupport_pathstuff.h | 11 +
gdb-netbsd/patches/patch-gdb_hppa-nbsd-nat.c | 112 ++++
gdb-netbsd/patches/patch-gdb_hppa-nbsd-tdep.c | 69 +++
gdb-netbsd/patches/patch-gdb_hppa-tdep.c | 13 +
gdb-netbsd/patches/patch-gdb_hppa-tdep.h | 11 +
gdb-netbsd/patches/patch-gdb_i386-bsd-nat.c | 110 ++++
gdb-netbsd/patches/patch-gdb_i386-bsd-nat.h | 13 +
gdb-netbsd/patches/patch-gdb_i386-nbsd-nat.c | 51 ++
gdb-netbsd/patches/patch-gdb_i386-nbsd-tdep.c | 183 +++++++
gdb-netbsd/patches/patch-gdb_ia64-nbsd-tdep.c | 51 ++
gdb-netbsd/patches/patch-gdb_inf-ptrace.c | 68 +++
gdb-netbsd/patches/patch-gdb_m68k-bsd-nat.c | 110 ++++
gdb-netbsd/patches/patch-gdb_mips-nbsd-nat.c | 141 +++++
gdb-netbsd/patches/patch-gdb_mips-tdep.h | 24 +
gdb-netbsd/patches/patch-gdb_nbsd-nat.c | 533 +++++++++++++++++++
gdb-netbsd/patches/patch-gdb_nbsd-nat.h | 32 ++
gdb-netbsd/patches/patch-gdb_nbsd-tdep.c | 41 ++
gdb-netbsd/patches/patch-gdb_nbsd-tdep.h | 11 +
gdb-netbsd/patches/patch-gdb_objfiles.c | 26 +
gdb-netbsd/patches/patch-gdb_p-exp.y | 13 +
gdb-netbsd/patches/patch-gdb_ppc-nbsd-nat.c | 130 +++++
gdb-netbsd/patches/patch-gdb_ppc-nbsd-tdep.c | 13 +
gdb-netbsd/patches/patch-gdb_ppc-nbsd-tdep.h | 10 +
gdb-netbsd/patches/patch-gdb_sh-nbsd-nat.c | 81 +++
gdb-netbsd/patches/patch-gdb_sh-nbsd-tdep.c | 197 +++++++
gdb-netbsd/patches/patch-gdb_sh-nbsd-tdep.h | 33 ++
gdb-netbsd/patches/patch-gdb_sparc-nat.c | 80 +++
gdb-netbsd/patches/patch-gdb_sparc-nat.h | 13 +
gdb-netbsd/patches/patch-gdb_sparc-nbsd-nat.c | 39 ++
gdb-netbsd/patches/patch-gdb_sparc-nbsd-tdep.c | 41 ++
gdb-netbsd/patches/patch-gdb_sparc-nbsd-tdep.h | 40 ++
gdb-netbsd/patches/patch-gdb_sparc-tdep.h | 25 +
gdb-netbsd/patches/patch-gdb_sparc64-nbsd-nat.c | 36 ++
gdb-netbsd/patches/patch-gdb_sparc64-nbsd-tdep.c | 12 +
...b.ada_uninitialized__vars_parse__controlled.ads | 0
.../patches/patch-gdb_testsuite_gdb.base_testenv.c | 0
.../patches/patch-gdb_testsuite_lib_compiler.cc | 0
.../patches/patch-gdb_testsuite_lib_pdtrace.in | 0
gdb-netbsd/patches/patch-gdb_tui_tui-winsource.c | 14 +
gdb-netbsd/patches/patch-gdb_user-regs.c | 79 +++
gdb-netbsd/patches/patch-gdb_vax-bsd-nat.c | 80 +++
gdb-netbsd/patches/patch-gdb_x86-bsd-nat.c | 31 ++
gdb-netbsd/patches/patch-include_elf_common.h | 12 +
gdb-netbsd/patches/patch-include_elf_epiphany.h | 0
gdb-netbsd/patches/patch-include_opcode_bfin.h | 0
gdb-netbsd/patches/patch-intl_Makefile.in | 17 +
.../patches/patch-libiberty_make-temp-file.c | 17 +
gdb-netbsd/patches/patch-libiberty_strerror.c | 13 +
gdb-netbsd/patches/patch-opcodes_cgen.sh | 12 +
gdb-netbsd/patches/patch-readline_display.c | 12 +
gdb-netbsd/patches/patch-readline_doc_texi2dvi | 6 +
gdb-netbsd/patches/patch-readline_doc_texi2html | 7 +
.../patches/patch-readline_examples_readlinebuf.h | 7 +
.../patch-readline_examples_rlfe_config.h.in | 5 +
.../patches/patch-readline_examples_rlfe_extern.h | 5 +
.../patches/patch-readline_examples_rlfe_os.h | 5 +
gdb-netbsd/patches/patch-readline_rltty.c | 16 +
.../patches/patch-readline_support_config.guess | 24 +
.../patches/patch-readline_support_config.sub | 35 ++
gdb-netbsd/patches/patch-readline_terminal.c | 15 +
gdb-netbsd/patches/patch-readline_util.c | 13 +
gdb-netbsd/patches/patch-sim_common_callback.c | 17 +
gdb-netbsd/patches/patch-sim_common_cgen.sh | 110 ++++
gdb-netbsd/patches/patch-sim_common_genmloop.sh | 0
gdb-netbsd/patches/patch-sim_common_gennltvals.sh | 0
gdb-netbsd/patches/patch-sim_common_gentvals.sh | 0
gdb-netbsd/patches/patch-sim_configure | 13 +
gdb-netbsd/patches/patch-sim_cr16_configure | 0
gdb-netbsd/patches/patch-sim_ft32_configure | 0
gdb-netbsd/patches/patch-sim_lm32_ChangeLog | 0
gdb-netbsd/patches/patch-sim_microblaze_configure | 0
gdb-netbsd/patches/patch-sim_mips_Makefile.in | 13 +
gdb-netbsd/patches/patch-sim_mn10300_Makefile.in | 13 +
gdb-netbsd/patches/patch-sim_moxie_configure | 0
gdb-netbsd/patches/patch-sim_ppc_emul__netbsd.c | 539 +++++++++++++++++++
gdb-netbsd/patches/patch-sim_ppc_emul_netbsd.c | 39 --
gdb-netbsd/patches/patch-sim_ppc_events.c | 12 +
gdb-netbsd/patches/patch-sim_ppc_hw__memory.c | 13 +
.../patch-sim_testsuite_sim_bfin_run-tests.sh | 0
gdb-netbsd/patches/patch-sim_v850_Makefile.in | 13 +
gdb-netbsd/patches/patch-src-release.sh | 0
121 files changed, 6045 insertions(+), 81 deletions(-)
diffs:
diff --git a/gdb-netbsd/distinfo b/gdb-netbsd/distinfo
index 71511c1f8d..394e246599 100644
--- a/gdb-netbsd/distinfo
+++ b/gdb-netbsd/distinfo
@@ -4,18 +4,130 @@ SHA1 (gdb-8.2.1-7e24fb63e7db33d3627623629b0e99fe322e26f9.tar.gz) = a8ae54700e1f2
RMD160 (gdb-8.2.1-7e24fb63e7db33d3627623629b0e99fe322e26f9.tar.gz) = 96040eb8f7eccd8c7dd157473b781144701754a0
SHA512 (gdb-8.2.1-7e24fb63e7db33d3627623629b0e99fe322e26f9.tar.gz) = d7a8692ee1b27aecac64bf4176e5fa3e44e315e88da079c24107f3e5318e0e335f35b38426e72c118bd044d547fdd94650781fb1dd1297d33dd5a54c77e78988
Size (gdb-8.2.1-7e24fb63e7db33d3627623629b0e99fe322e26f9.tar.gz) = 59113538 bytes
-SHA1 (patch-Makefile.in) = 48f65798f96fdda2a35eb8b18a7cc2993023bcc7
-SHA1 (patch-gdb_configure.tgt) = 06a6cb8fc9453a0a56e3e3c7ba9c3012653b4f5c
+SHA1 (patch-bfd_config.bfd) = 0fd42301a1577e353381a0bf677a7bcb5d32c3d8
+SHA1 (patch-bfd_configure) = 2345b0527e83debbfffd574eee74d10feecf2a00
+SHA1 (patch-bfd_doc_Makefile.in) = 63a289d492cbf51b3ce39969b67dfebf86096715
+SHA1 (patch-bfd_elf.c) = c62b91aeb3c607648fb379865e7ad22f0aa4a115
+SHA1 (patch-bfd_merge.c) = dcb36bfd014e0b5bec17d6b6d475bf988021daee
+SHA1 (patch-bfd_netbsd-core.c) = 0aa8039b5734575b89e33a9ece4ab3f76b326eba
+SHA1 (patch-config_acinclude.m4) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-cpu_epiphany.opc) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-gdb_Makefile.in) = dc465eda202863a23ce660ae5f8065a74e5c8fb4
+SHA1 (patch-gdb_aarch64-nbsd-nat.c) = 04ffc8ed696cb2349a67d302c2f8fa596484a9e6
+SHA1 (patch-gdb_aarch64-nbsd-tdep.c) = 7720b954f12031b60e1fa0a48ce668b104e09d41
+SHA1 (patch-gdb_aarch64-nbsd-tdep.h) = 814627b2b2ce5dc0dc095451183fbe03789f1513
+SHA1 (patch-gdb_alpha-bsd-nat.c) = 4d74177d2255c81fb91c293daaebfc29c4cb8398
+SHA1 (patch-gdb_alpha-nbsd-tdep.c) = 8fe9d1f08baa252b61b49c2672391c3349768444
+SHA1 (patch-gdb_alpha-tdep.c) = 9030c31dcef6660f58fc27e7979f0dae26e4f970
+SHA1 (patch-gdb_amd64-bsd-nat.c) = dea0bd38155f2a39f89f4f62dcbaf3e54ccd654f
+SHA1 (patch-gdb_amd64-nbsd-nat.c) = 26ad634a79441949c076cee07e4e5baaaa1402f1
+SHA1 (patch-gdb_amd64-nbsd-tdep.c) = 99328cdd390281ff298c08010907195738a85489
+SHA1 (patch-gdb_arm-nbsd-nat.c) = 09a21d2eed39dc4e74a1f442c6ee59dfbf9c6f54
+SHA1 (patch-gdb_arm-nbsd-tdep.c) = 63009d506e2f92e681529d96150b1c4d04a7afbe
+SHA1 (patch-gdb_auxv.c) = b238b9bc4b598a96feed4a64e7c2f5120e2d3367
+SHA1 (patch-gdb_bsd-kvm.c) = d04c44fb4c779dd3ecd12c3179ad8a63351e5239
+SHA1 (patch-gdb_config_aarch64_nbsd.mh) = 6d7793009bda1568717ed897c02e77137e47b83b
+SHA1 (patch-gdb_config_ia64_netbsd.mh) = ed89b31ad808e15e1823af1a022ce37194e6f78e
+SHA1 (patch-gdb_config_powerpc_ppc64-nbsd.mh) = bef62de0ebc162aeac12939d4f4fb220be99efe2
+SHA1 (patch-gdb_configure) = 681e095fdd15432dbc094bf70e5a5b7c67637ad7
+SHA1 (patch-gdb_configure.host) = 427f6dbc2f4373e7e9bede77ccb7a3cd28c74d14
+SHA1 (patch-gdb_configure.nat) = ba5ad6fe4c31b5f5e81bd69c81feb70c36b0f7df
+SHA1 (patch-gdb_configure.tgt) = 6e32066a87234a90c905a0ab17a32ef84a903d0a
+SHA1 (patch-gdb_contrib_ari_gdb__ari.sh) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-gdb_contrib_expect-read1.sh) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-gdb_doc_stabs.texinfo) = 42e4864a3e5725b139aaabcadd4b982e39826f8a
+SHA1 (patch-gdb_features_feature__to__c.sh) = da39a3ee5e6b4b0d3255bfef95601890afd80709
SHA1 (patch-gdb_gdbserver_Makefile.in) = c14e0e580515b849b1ddac65d50b2f757645cea6
SHA1 (patch-gdb_gdbserver_configure.srv) = d492edda5a6f7e70a2279ebe7409e557672b92aa
SHA1 (patch-gdb_gdbserver_debug.c) = 8226f32fd7df152b7aa6109621c9b162639ed657
-SHA1 (patch-gdb_gdbserver_netbsd-low.c) = cf86c64eb64bcde237677844c3e79cbea8e72b57
-SHA1 (patch-gdb_gdbserver_netbsd-low.h) = c2d11d0e6c0a1b3317eb8313436de0e202233e1a
-SHA1 (patch-gdb_gdbserver_netbsd-x86__64-low.c) = 4d328f54051bfbc7c6678e0360a175ac3d004022
+SHA1 (patch-gdb_gdbserver_netbsd-low.c) = 6b79896787cfde6b1c7029e4ad7cd62e274dd23d
+SHA1 (patch-gdb_gdbserver_netbsd-low.h) = 4f4fe50c18f9d10ac842927860ab6418600881f3
+SHA1 (patch-gdb_gdbserver_netbsd-x86__64-low.c) = 487374f6ef2d8943b4b413b86f613411a3811f40
SHA1 (patch-gdb_gdbserver_regcache.c) = 4967ab4c63b057d9b26c52be6e25d90e57a9fa06
SHA1 (patch-gdb_gdbserver_tdesc.c) = 9682dafab7a4ff6870afb93d5979cc48a3512b88
SHA1 (patch-gdb_gdbserver_tdesc.h) = dc701c237ec1102910ecd0dde47d23057a0d8f19
+SHA1 (patch-gdb_gdbsupport_agent.c) = d2ce6030a8c7d4fe84c74f3a44dc5c49f970547e
+SHA1 (patch-gdb_gdbsupport_common-defs.h) = 940d3489c2fac85defff29a0886f1c6d54bee020
+SHA1 (patch-gdb_gdbsupport_pathstuff.h) = 1eef4a97e827bc06fd4c11824435de0ccce076f8
+SHA1 (patch-gdb_hppa-nbsd-nat.c) = eb5fb4b69f0ba69a4a7e8152bc97762a5b2cf1ba
+SHA1 (patch-gdb_hppa-nbsd-tdep.c) = 2b0552b3a8cb820daaf1fa3960cbbf6a31ad1c79
+SHA1 (patch-gdb_hppa-tdep.c) = 57e3a1cc1718aee0f70797804e8859af6c3c7840
+SHA1 (patch-gdb_hppa-tdep.h) = 6cda8a222cd10340ae54878998543e66f4455fd6
+SHA1 (patch-gdb_i386-bsd-nat.c) = b07545ddfd92b1ff479a42d28d21f2713748fa69
+SHA1 (patch-gdb_i386-bsd-nat.h) = f6688e75d80058832bbe12356399eec723f30328
+SHA1 (patch-gdb_i386-nbsd-nat.c) = 12583799f643f31849063acf10cb0dc36c68101f
+SHA1 (patch-gdb_i386-nbsd-tdep.c) = 002ece7989025a4bed1ce1eece9d225faf02c538
+SHA1 (patch-gdb_ia64-nbsd-tdep.c) = 4d1795b806b1b957f7959d57cdab7090c9510fe5
+SHA1 (patch-gdb_inf-ptrace.c) = caef41fb10c585b7b403a3dc6e82a924cc90becb
+SHA1 (patch-gdb_m68k-bsd-nat.c) = 5740879c53ea6db0ac9c54dd2426014493e03014
+SHA1 (patch-gdb_mips-nbsd-nat.c) = 1f71cb0d0c8792bfc80a456d294dad6d75b526b5
+SHA1 (patch-gdb_mips-tdep.h) = 24b3cf83513716492297645b2d5c4281ab12b493
SHA1 (patch-gdb_nat_fork-inferior.c) = c15d3964c448e010958d8977825d6d46f8708e09
+SHA1 (patch-gdb_nbsd-nat.c) = 60b1b2164206e52254e743cca3de762770f7ab9d
+SHA1 (patch-gdb_nbsd-nat.h) = 4188f1edfb1b0b437c931fa60049221164a6e59e
+SHA1 (patch-gdb_nbsd-tdep.c) = d375084ca0895e71a4f7b837cb633a11eb260884
+SHA1 (patch-gdb_nbsd-tdep.h) = ca419a41fa2e7c41c4a84521700dcfae279f4bfc
+SHA1 (patch-gdb_objfiles.c) = 25bcbc07b2a919db28c1145489e30dcb38b5a230
+SHA1 (patch-gdb_p-exp.y) = 36098acb5eea8adc57160f84342b69abe53c5814
+SHA1 (patch-gdb_ppc-nbsd-nat.c) = 9986c45717729ffc4db04068296543e3449495a7
+SHA1 (patch-gdb_ppc-nbsd-tdep.c) = af7dd8000489c281be69f52d9c56662aff0f5ba5
+SHA1 (patch-gdb_ppc-nbsd-tdep.h) = bc6e015d61b5d6d5e98a370295caf45170fe8e56
SHA1 (patch-gdb_regformats_regdef.h) = a126d2537ade44f669a7a6bcd59dcd89188554d1
+SHA1 (patch-gdb_sh-nbsd-nat.c) = f316feea0192b6926ebe01d0fc83effe632ae063
+SHA1 (patch-gdb_sh-nbsd-tdep.c) = 868d765ebf6c2d4dfb1319653c9312da1ce45a8e
+SHA1 (patch-gdb_sh-nbsd-tdep.h) = 6dca499544ec3e95cd2c10a07926d1e80ab6d109
+SHA1 (patch-gdb_sparc-nat.c) = 31a214f01f734add664fba4a462bd9f8e8686c92
+SHA1 (patch-gdb_sparc-nat.h) = 1a10f19afb13dd25eb0aef1486a48d8c6c4ac647
+SHA1 (patch-gdb_sparc-nbsd-nat.c) = 4aa8d16cf1210125f9117680014f2d8eaa36e681
+SHA1 (patch-gdb_sparc-nbsd-tdep.c) = c61b63a6673402852a2e95b06d382b8eda1653e9
+SHA1 (patch-gdb_sparc-nbsd-tdep.h) = 7520c8d0d465883abc4a302f1efabd9e52492acc
+SHA1 (patch-gdb_sparc-tdep.h) = 74eb0364017aa8b41ef1a06dcb35d8b4a2a31852
+SHA1 (patch-gdb_sparc64-nbsd-nat.c) = d7b9988c09f483d9d57dccc36610cb52751dac0b
+SHA1 (patch-gdb_sparc64-nbsd-tdep.c) = 1e4562ab7f7a2c8b61b2becc70c9d6aa35140598
+SHA1 (patch-gdb_testsuite_gdb.ada_uninitialized__vars_parse__controlled.ads) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-gdb_testsuite_gdb.base_testenv.c) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-gdb_testsuite_lib_compiler.cc) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-gdb_testsuite_lib_pdtrace.in) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-gdb_tui_tui-winsource.c) = fc0eb13c8c367bed20630921a6bacce186a80fd8
+SHA1 (patch-gdb_user-regs.c) = ced798a4bb8765193bbde67811cea5b98e41d56f
+SHA1 (patch-gdb_vax-bsd-nat.c) = 999589c89a2db8a4b38435aa6e9263e72791f60c
+SHA1 (patch-gdb_x86-bsd-nat.c) = 615cbfb2b8b00a79fe94b2538d1b1dfc404b3262
+SHA1 (patch-include_elf_common.h) = 60e8ee09e6c4727af20686808a637e6d84758e5a
+SHA1 (patch-include_elf_epiphany.h) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-include_opcode_bfin.h) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-intl_Makefile.in) = cb9c50bbdfc086a59a549799254365a27d52feec
SHA1 (patch-libctf_swap.h) = b4755fa27f4d3d98aec03ea4c13a8e3985496d8b
-SHA1 (patch-sim_ppc_emul_netbsd.c) = 34fcb884c3c82e8eae6cd6f8c87ce42e9354c347
+SHA1 (patch-libiberty_make-temp-file.c) = 6e5c3fc9dde722a263cdbe3d51a714538a0c6cd1
+SHA1 (patch-libiberty_strerror.c) = 16ffa959c95aed579747566cc9ce7d80a1435432
+SHA1 (patch-opcodes_cgen.sh) = ace9d4c93194da654e27af63d045c3220879ade6
+SHA1 (patch-readline_display.c) = daa5bd3dc68c2ef4f5b5cfb412df888317d92c8b
+SHA1 (patch-readline_doc_texi2dvi) = dc857093f77a95413151a54e1186322f98f6c489
+SHA1 (patch-readline_doc_texi2html) = ec274dc687f2ba70a287b2fc0bc7bade9a5c12f2
+SHA1 (patch-readline_examples_readlinebuf.h) = 11b00683f95d77092fc8b7b701c7bfcaf40ca01c
+SHA1 (patch-readline_examples_rlfe_config.h.in) = 69f34cc628efe30542248e7ac7458be59d5fab94
+SHA1 (patch-readline_examples_rlfe_extern.h) = 69f34cc628efe30542248e7ac7458be59d5fab94
+SHA1 (patch-readline_examples_rlfe_os.h) = 69f34cc628efe30542248e7ac7458be59d5fab94
+SHA1 (patch-readline_rltty.c) = ffaa8b2d8acd01cfc2f6c087c72f897a976bcbd9
+SHA1 (patch-readline_support_config.guess) = bbb5df37baf85c8d5ca80acee340af3bab341936
+SHA1 (patch-readline_support_config.sub) = cb78431c434b1a727c56a368cc02099f63e21fd5
+SHA1 (patch-readline_terminal.c) = f68a1f69c2e1fde60ed07e76635ec56c68766cde
+SHA1 (patch-readline_util.c) = 2012356216efe9416dc2fbc02d33c927640f2df4
+SHA1 (patch-sim_common_callback.c) = ac55e639ed6ba51c5daef5fffccc3413abeb1df2
+SHA1 (patch-sim_common_cgen.sh) = 2d3dba22472ae9b7b3fcf1462ce2f7870a837cff
+SHA1 (patch-sim_common_genmloop.sh) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-sim_common_gennltvals.sh) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-sim_common_gentvals.sh) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-sim_configure) = 438ab3cfdae78a73cd05a9689133bce8739562ef
+SHA1 (patch-sim_cr16_configure) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-sim_ft32_configure) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-sim_lm32_ChangeLog) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-sim_microblaze_configure) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-sim_mips_Makefile.in) = 21db438aba5935cccc744b0f9d65992f32a9aa69
+SHA1 (patch-sim_mn10300_Makefile.in) = 9ef75b2651ca1813b2a09dc7f327af4ee045458f
+SHA1 (patch-sim_moxie_configure) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-sim_ppc_emul__netbsd.c) = c89ffc38760acedb55c211f946c86dc12bdc6d4a
+SHA1 (patch-sim_ppc_events.c) = a32cee946443c5f6ca4a6a1aab2ee2081d40472d
+SHA1 (patch-sim_ppc_hw__memory.c) = 1bb1788515ac1aa90192a4d6680cff7363bcaddc
+SHA1 (patch-sim_testsuite_sim_bfin_run-tests.sh) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-sim_v850_Makefile.in) = 910357bba7ec1c97e0eba1286c31534a2746d854
+SHA1 (patch-src-release.sh) = da39a3ee5e6b4b0d3255bfef95601890afd80709
diff --git a/gdb-netbsd/patches/patch-Makefile.in b/gdb-netbsd/patches/patch-Makefile.in
deleted file mode 100644
index 88cfa27f1f..0000000000
--- a/gdb-netbsd/patches/patch-Makefile.in
+++ /dev/null
@@ -1,32 +0,0 @@
-$NetBSD: patch-Makefile.in,v 1.2 2016/04/14 08:40:44 fhajny Exp $
-
-Do not install bfd and opcodes. Conflicts with devel/binutils.
-
---- Makefile.in.orig 2016-02-24 09:57:08.000000000 +0000
-+++ Makefile.in
-@@ -1596,7 +1596,6 @@ do-install-info:
-
- .PHONY: install-info-host
-
--install-info-host: maybe-install-info-bfd
- install-info-host: maybe-install-info-opcodes
- install-info-host: maybe-install-info-binutils
- install-info-host: maybe-install-info-bison
-@@ -2482,8 +2481,6 @@ install:
-
- .PHONY: install-host-nogcc
- install-host-nogcc: \
-- maybe-install-bfd \
-- maybe-install-opcodes \
- maybe-install-binutils \
- maybe-install-bison \
- maybe-install-cgen \
-@@ -2530,8 +2527,6 @@ install-host-nogcc: \
-
- .PHONY: install-host
- install-host: \
-- maybe-install-bfd \
-- maybe-install-opcodes \
- maybe-install-binutils \
- maybe-install-bison \
- maybe-install-cgen \
diff --git a/gdb-netbsd/patches/patch-bfd_config.bfd b/gdb-netbsd/patches/patch-bfd_config.bfd
new file mode 100644
index 0000000000..9f87130cd7
--- /dev/null
+++ b/gdb-netbsd/patches/patch-bfd_config.bfd
@@ -0,0 +1,127 @@
+$NetBSD$
+
+--- bfd/config.bfd.orig 2019-07-16 00:00:27.000000000 +0000
++++ bfd/config.bfd
+@@ -178,6 +178,7 @@ hppa*) targ_archs=bfd_hppa_arch ;;
+ i[3-7]86) targ_archs=bfd_i386_arch ;;
+ ia16) targ_archs=bfd_i386_arch ;;
+ lm32) targ_archs=bfd_lm32_arch ;;
++m5200|m5407) targ_archs=bfd_m68k_arch ;;
+ m6811*|m68hc11*) targ_archs="bfd_m68hc11_arch bfd_m68hc12_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;;
+ m6812*|m68hc12*) targ_archs="bfd_m68hc12_arch bfd_m68hc11_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;;
+ m68*) targ_archs=bfd_m68k_arch ;;
+@@ -241,6 +242,11 @@ case "${targ}" in
+ targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
+ want64=true
+ ;;
++ aarch64-*-netbsd*)
++ targ_defvec=aarch64_elf64_le_vec
++ targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
++ want64=true
++ ;;
+ aarch64-*-fuchsia*)
+ targ_defvec=aarch64_elf64_le_vec
+ targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
+@@ -261,6 +267,16 @@ case "${targ}" in
+ targ_selvecs="aarch64_elf64_le_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_be_vec arm_elf32_le_vec"
+ want64=true
+ ;;
++ aarch64-*-netbsd*)
++ targ_defvec=aarch64_elf64_le_vec
++ targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec"
++ want64=true
++ ;;
++ aarch64_be-*-netbsd*)
++ targ_defvec=aarch64_elf64_be_vec
++ targ_selvecs="aarch64_elf64_le_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_be_vec arm_elf32_le_vec"
++ want64=true
++ ;;
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ targ_defvec=alpha_elf64_fbsd_vec
+ targ_selvecs="alpha_elf64_vec alpha_ecoff_le_vec"
+@@ -347,11 +363,11 @@ case "${targ}" in
+ targ64_selvecs="x86_64_elf32_nacl_vec x86_64_elf64_nacl_vec"
+ targ_archs="$targ_archs bfd_i386_arch"
+ ;;
+- armeb-*-netbsdelf*)
++ arm*eb-*-netbsdelf*)
+ targ_defvec=arm_elf32_be_vec
+ targ_selvecs="arm_elf32_le_vec"
+ ;;
+- arm-*-netbsdelf*)
++ arm*-*-netbsdelf*)
+ targ_defvec=arm_elf32_le_vec
+ targ_selvecs="arm_elf32_be_vec"
+ ;;
+@@ -820,6 +836,10 @@ case "${targ}" in
+ m68*-*-*)
+ targ_defvec=m68k_elf32_vec
+ ;;
++ m68*-*-netbsdelf* | m5407-*-netbsdelf*)
++ targ_defvec=m68k_elf32_vec
++ targ_selvecs="m68k_aout_nbsd_vec m68k_aout_4knbsd_vec m68k_aout_hp300bsd_vec sparc_aout_sunos_be_vec"
++ ;;
+
+ s12z-*-*)
+ targ_defvec=s12z_elf32_vec
+@@ -853,14 +873,35 @@ case "${targ}" in
+ targ_selvecs=microblaze_elf32_le_vec
+ ;;
+
++ mips*-big-*)
++ targ_defvec=mips_ecoff_be_vec
++ targ_selvecs=mips_ecoff_le_vec
++ ;;
++
++ mips*-dec-* | mips*el-*-ecoff*)
++ targ_defvec=mips_ecoff_le_vec
++ targ_selvecs=mips_ecoff_be_vec
++ ;;
++ mips*-*-ecoff*)
++ targ_defvec=mips_ecoff_be_vec
++ targ_selvecs=mips_ecoff_le_vec
++ ;;
+ #ifdef BFD64
++ mips64*el-*-netbsd*)
++ targ_defvec=mips_elf32_ntrad_le_vec
++ targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec"
++ ;;
++ mips64*-*-netbsd*)
++ targ_defvec=mips_elf32_ntrad_be_vec
++ targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec"
++ ;;
+ mips*el-*-netbsd*)
+ targ_defvec=mips_elf32_trad_le_vec
+- targ_selvecs="mips_elf32_trad_be_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec mips_ecoff_le_vec mips_ecoff_be_vec"
++ targ_selvecs="mips_elf32_trad_be_vec mips_elf32_ntrad_le_vec mips_elf32_ntrad_be_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec mips_ecoff_le_vec mips_ecoff_be_vec"
+ ;;
+ mips*-*-netbsd*)
+ targ_defvec=mips_elf32_trad_be_vec
+- targ_selvecs="mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec mips_ecoff_be_vec mips_ecoff_le_vec"
++ targ_selvecs="mips_elf32_trad_le_vec mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec mips_ecoff_be_vec mips_ecoff_le_vec"
+ ;;
+ mips*-*-irix6*)
+ targ_defvec=mips_elf32_n_be_vec
+@@ -902,6 +943,22 @@ case "${targ}" in
+ targ_defvec=mips_elf32_be_vec
+ targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec"
+ ;;
++ mips64*el-*-netbsd*)
++ targ_defvec=mips_elf32_ntrad_le_vec
++ targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec"
++ ;;
++ mips64*-*-netbsd*)
++ targ_defvec=mips_elf32_ntrad_be_vec
++ targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec"
++ ;;
++ mips*el-*-netbsd*)
++ targ_defvec=mips_elf32_trad_le_vec
++ targ_selvecs="mips_elf32_trad_be_vec mips_elf32_ntrad_le_vec mips_elf32_ntrad_be_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec mips_ecoff_le_vec mips_ecoff_be_vec"
++ ;;
++ mips*-*-netbsd*)
++ targ_defvec=mips_elf32_trad_be_vec
++ targ_selvecs="mips_elf32_trad_le_vec mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec mips_ecoff_be_vec mips_ecoff_le_vec"
++ ;;
+ mips64*-*-openbsd*)
+ targ_defvec=mips_elf64_trad_be_vec
+ targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec"
diff --git a/gdb-netbsd/patches/patch-bfd_configure b/gdb-netbsd/patches/patch-bfd_configure
new file mode 100644
index 0000000000..bf386fc6a1
--- /dev/null
+++ b/gdb-netbsd/patches/patch-bfd_configure
@@ -0,0 +1,39 @@
+$NetBSD$
+
+--- bfd/configure.orig 2019-07-16 00:00:27.000000000 +0000
++++ bfd/configure
+@@ -474,6 +474,7 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
+ as_lineno_2=$LINENO as_lineno_2a=$LINENO
+ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
++ as_me=bfd_$as_me # XXX don't overwrite our caller's configure.lineno
+ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+@@ -12461,7 +12462,7 @@ if test "${enable_secureplt+set}" = set;
+ *) as_fn_error $? "bad value ${enableval} for secureplt option" "$LINENO" 5 ;;
+ esac
+ else
+- use_secureplt=true
++ use_secureplt=false
+ fi
+ if test $use_secureplt = true; then
+
+@@ -15116,7 +15117,7 @@ if test "${target}" = "${host}"; then
+ ;;
+ arm-*-freebsd* | arm-*-kfreebsd*-gnu)
+ COREFILE='' ;;
+- arm-*-netbsd* | arm-*-openbsd*)
++ arm*-*-netbsd* | arm-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ arm-*-riscix) COREFILE=trad-core.lo ;;
+@@ -15177,7 +15178,7 @@ if test "${target}" = "${host}"; then
+ ;;
+ i[3-7]86-*-isc*) COREFILE=trad-core.lo ;;
+ i[3-7]86-*-aix*) COREFILE=aix386-core.lo ;;
+- mips-*-netbsd* | mips*-*-openbsd*)
++ mips*-*-netbsd* | mips*-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ mips-sgi-irix4*) COREFILE=irix-core.lo ;;
diff --git a/gdb-netbsd/patches/patch-bfd_doc_Makefile.in b/gdb-netbsd/patches/patch-bfd_doc_Makefile.in
new file mode 100644
index 0000000000..3a3e19bf8a
--- /dev/null
+++ b/gdb-netbsd/patches/patch-bfd_doc_Makefile.in
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- bfd/doc/Makefile.in.orig 2019-07-16 00:00:27.000000000 +0000
++++ bfd/doc/Makefile.in
+@@ -538,6 +538,8 @@ clean-libtool:
+ -rm -rf .libs _libs
+
+ bfd.info: bfd.texi $(bfd_TEXINFOS)
++ @echo "NOT REBUILDING $@"
++NetBSD_DISABLED_bfd.info:
+ $(AM_V_MAKEINFO)restore=: && backupdir="$(am__leading_dot)am$$$$" && \
+ rm -rf $$backupdir && mkdir $$backupdir && \
+ if ($(MAKEINFO) --version) >/dev/null 2>&1; then \
diff --git a/gdb-netbsd/patches/patch-bfd_elf.c b/gdb-netbsd/patches/patch-bfd_elf.c
new file mode 100644
index 0000000000..9edb5e31f1
--- /dev/null
+++ b/gdb-netbsd/patches/patch-bfd_elf.c
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- bfd/elf.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ bfd/elf.c
+@@ -10582,6 +10582,7 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf
+ /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0 and
+ PT_GETFPREGS == mach+2. */
+
++ case bfd_arch_aarch64:
+ case bfd_arch_alpha:
+ case bfd_arch_sparc:
+ switch (note->type)
diff --git a/gdb-netbsd/patches/patch-bfd_merge.c b/gdb-netbsd/patches/patch-bfd_merge.c
new file mode 100644
index 0000000000..ed7c9f262c
--- /dev/null
+++ b/gdb-netbsd/patches/patch-bfd_merge.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- bfd/merge.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ bfd/merge.c
+@@ -338,7 +338,7 @@ sec_merge_emit (bfd *abfd, struct sec_me
+
+ /* Trailing alignment needed? */
+ off = sec->size - off;
+- if (off != 0)
++ if (pad != NULL && off != 0)
+ {
+ BFD_ASSERT (off <= pad_len);
+ if (contents)
diff --git a/gdb-netbsd/patches/patch-bfd_netbsd-core.c b/gdb-netbsd/patches/patch-bfd_netbsd-core.c
new file mode 100644
index 0000000000..7b06b86fc4
--- /dev/null
+++ b/gdb-netbsd/patches/patch-bfd_netbsd-core.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- bfd/netbsd-core.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ bfd/netbsd-core.c
+@@ -275,7 +275,7 @@ const bfd_target core_netbsd_vec =
+ 0, /* Symbol prefix. */
+ ' ', /* ar_pad_char. */
+ 16, /* ar_max_namelen. */
+- 0, /* Match priority. */
++ 0, /* match priority. */
+ NO_GET64, NO_GETS64, NO_PUT64, /* 64 bit data. */
+ NO_GET, NO_GETS, NO_PUT, /* 32 bit data. */
+ NO_GET, NO_GETS, NO_PUT, /* 16 bit data. */
diff --git a/gdb-netbsd/patches/patch-config_acinclude.m4 b/gdb-netbsd/patches/patch-config_acinclude.m4
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-cpu_epiphany.opc b/gdb-netbsd/patches/patch-cpu_epiphany.opc
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-gdb_Makefile.in b/gdb-netbsd/patches/patch-gdb_Makefile.in
new file mode 100644
index 0000000000..ac5c30eafb
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_Makefile.in
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- gdb/Makefile.in.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/Makefile.in
+@@ -2137,6 +2137,8 @@ ALLDEPFILES = \
+ aarch64-fbsd-tdep.c \
+ aarch64-linux-nat.c \
+ aarch64-linux-tdep.c \
++ aarch64-nbsd-nat.c \
++ aarch64-nbsd-tdep.c \
+ aarch64-newlib-tdep.c \
+ aarch64-ravenscar-thread.c \
+ aarch64-tdep.c \
diff --git a/gdb-netbsd/patches/patch-gdb_aarch64-nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_aarch64-nbsd-nat.c
new file mode 100644
index 0000000000..80bbd2fb9f
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_aarch64-nbsd-nat.c
@@ -0,0 +1,188 @@
+$NetBSD$
+
+--- gdb/aarch64-nbsd-nat.c.orig 2019-09-02 20:02:23.493799588 +0000
++++ gdb/aarch64-nbsd-nat.c
+@@ -0,0 +1,183 @@
++/* Native-dependent code for NetBSD/aarch64.
++
++ Copyright (C) 2017-2018 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 "defs.h"
++#include "target.h"
++
++#include <sys/types.h>
++#include <sys/ptrace.h>
++
++#include <machine/frame.h>
++#include <machine/pcb.h>
++
++#include "nbsd-nat.h"
++#include "aarch64-tdep.h"
++#include "aarch64-nbsd-tdep.h"
++#include "regcache.h"
++#include "gdbcore.h"
++#include "bsd-kvm.h"
++#include "inf-ptrace.h"
++
++/* Determine if PT_GETREGS fetches REGNUM. */
++
++struct aarch64_nbsd_nat_target final : public nbsd_nat_target
++{
++ void fetch_registers (struct regcache *, int) override;
++ void store_registers (struct regcache *, int) override;
++};
++
++static aarch64_nbsd_nat_target the_aarch64_nbsd_nat_target;
++
++static bool
++getregs_supplies (struct gdbarch *gdbarch, int regnum)
++{
++ return (regnum >= AARCH64_X0_REGNUM && regnum <= AARCH64_CPSR_REGNUM);
++}
++
++/* Determine if PT_GETFPREGS fetches REGNUM. */
++
++static bool
++getfpregs_supplies (struct gdbarch *gdbarch, int regnum)
++{
++ return (regnum >= AARCH64_V0_REGNUM && regnum <= AARCH64_FPCR_REGNUM);
++}
++
++void
++aarch64_nbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
++{
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
++
++ struct gdbarch *gdbarch = regcache->arch ();
++ if (regnum == -1 || getregs_supplies (gdbarch, regnum))
++ {
++ struct reg regs;
++
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
++ perror_with_name (_("Couldn't get registers"));
++
++ regcache_supply_regset (&aarch64_nbsd_gregset, regcache, regnum, ®s,
++ sizeof (regs));
++ }
++
++ if (regnum == -1 || getfpregs_supplies (gdbarch, regnum))
++ {
++ struct fpreg fpregs;
++
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
++ perror_with_name (_("Couldn't get floating point status"));
++
++ regcache_supply_regset (&aarch64_nbsd_fpregset, regcache, regnum, &fpregs,
++ sizeof (fpregs));
++ }
++}
++
++/* Store register REGNUM back into the inferior. If REGNUM is -1, do
++ this for all registers. */
++
++void
++aarch64_nbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
++{
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
++
++ struct gdbarch *gdbarch = regcache->arch ();
++ if (regnum == -1 || getregs_supplies (gdbarch, regnum))
++ {
++ struct reg regs;
++
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
++ perror_with_name (_("Couldn't get registers"));
++
++ regcache_collect_regset (&aarch64_nbsd_gregset, regcache,regnum, ®s,
++ sizeof (regs));
++
++ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
++ perror_with_name (_("Couldn't write registers"));
++ }
++
++ if (regnum == -1 || getfpregs_supplies (gdbarch, regnum))
++ {
++ struct fpreg fpregs;
++
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
++ perror_with_name (_("Couldn't get floating point status"));
++
++ regcache_collect_regset (&aarch64_nbsd_fpregset, regcache,regnum, &fpregs,
++ sizeof (fpregs));
++
++ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
++ perror_with_name (_("Couldn't write floating point status"));
++ }
++}
++
++static int
++aarch64_nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
++{
++ struct trapframe tf;
++ int i;
++
++ /* The following is true for NetBSD/arm64:
++
++ The pcb contains the frame pointer at the point of the context
++ switch in cpu_switchto(). At that point we have a stack frame as
++ described by `struct trapframe', which has the following layout:
++
++ x0..x30
++ sp
++ pc
++ spsr
++ tpidr
++
++ This accounts for all callee-saved registers specified by the psABI.
++ From this information we reconstruct the register state as it would
++ look when we just returned from cpu_switchto().
++
++ For kernel core dumps, dumpsys() builds a fake trapframe for us. */
++
++ /* The trapframe pointer shouldn't be zero. */
++ if (pcb->pcb_tf == 0)
++ return 0;
++
++ /* Read the stack frame, and check its validity. */
++ read_memory ((uintptr_t)pcb->pcb_tf, (gdb_byte *) &tf, sizeof tf);
++
++ for (i = 0; i <= 30; i++)
++ {
++ regcache->raw_supply (AARCH64_X0_REGNUM + i, &tf.tf_reg[i]);
++ }
++ regcache->raw_supply (AARCH64_SP_REGNUM, &tf.tf_sp);
++ regcache->raw_supply (AARCH64_PC_REGNUM, &tf.tf_pc);
++
++ regcache->raw_supply (AARCH64_FPCR_REGNUM, &pcb->pcb_fpregs.fpcr);
++ regcache->raw_supply (AARCH64_FPSR_REGNUM, &pcb->pcb_fpregs.fpsr);
++
++ return 1;
++}
++
++void
++_initialize_aarch64_nbsd_nat (void)
++{
++ add_inf_child_target (&the_aarch64_nbsd_nat_target);
++
++ /* Support debugging kernel virtual memory images. */
++ bsd_kvm_add_target (aarch64_nbsd_supply_pcb);
++}
diff --git a/gdb-netbsd/patches/patch-gdb_aarch64-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_aarch64-nbsd-tdep.c
new file mode 100644
index 0000000000..8bf92eb260
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_aarch64-nbsd-tdep.c
@@ -0,0 +1,207 @@
+$NetBSD$
+
+--- gdb/aarch64-nbsd-tdep.c.orig 2019-09-02 20:02:23.494088395 +0000
++++ gdb/aarch64-nbsd-tdep.c
+@@ -0,0 +1,202 @@
++/* Target-dependent code for NetBSD/aarch64.
++
++ Copyright (C) 2017-2018 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 "defs.h"
++
++#include "gdbarch.h"
++#include "nbsd-tdep.h"
++#include "aarch64-tdep.h"
++#include "aarch64-nbsd-tdep.h"
++#include "osabi.h"
++#include "solib-svr4.h"
++#include "target.h"
++#include "tramp-frame.h"
++#include "trad-frame.h"
++
++/* In a signal frame, sp points to a 'struct sigframe' which is
++ defined as:
++
++ struct sigframe {
++ siginfo_t sf_si;
++ ucontext_t sf_uc;
++ };
++
++ ucontext_t is defined as:
++
++ struct __ucontext {
++ sigset_t uc_sigmask;
++ mcontext_t uc_mcontext;
++ ...
++ };
++
++ The mcontext_t contains the general purpose register set followed
++ by the floating point register set. The floating point register
++ set is only valid if the _MC_FP_VALID flag is set in mc_flags. */
++
++#define AARCH64_MCONTEXT_REG_SIZE 8
++#define AARCH64_MCONTEXT_FPREG_SIZE 16
++#define AARCH64_SIGFRAME_UCONTEXT_OFFSET 80
++#define AARCH64_UCONTEXT_MCONTEXT_OFFSET 16
++#define AARCH64_MCONTEXT_FPREGS_OFFSET 272
++#define AARCH64_MCONTEXT_FLAGS_OFFSET 800
++#define AARCH64_MCONTEXT_FLAG_FP_VALID 0x1
++
++/* Implement the "init" method of struct tramp_frame. */
++
++static void
++aarch64_nbsd_sigframe_init (const struct tramp_frame *self,
++ struct frame_info *this_frame,
++ struct trad_frame_cache *this_cache,
++ CORE_ADDR func)
++{
++ struct gdbarch *gdbarch = get_frame_arch (this_frame);
++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
++ CORE_ADDR sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM);
++ CORE_ADDR mcontext_addr =
++ sp
++ + AARCH64_SIGFRAME_UCONTEXT_OFFSET
++ + AARCH64_UCONTEXT_MCONTEXT_OFFSET;
++ gdb_byte buf[4];
++ int i;
++
++ for (i = 0; i < 30; i++)
++ {
++ trad_frame_set_reg_addr (this_cache,
++ AARCH64_X0_REGNUM + i,
++ mcontext_addr + i * AARCH64_MCONTEXT_REG_SIZE);
++ }
++ trad_frame_set_reg_addr (this_cache, AARCH64_LR_REGNUM,
++ mcontext_addr + 30 * AARCH64_MCONTEXT_REG_SIZE);
++ trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM,
++ mcontext_addr + 31 * AARCH64_MCONTEXT_REG_SIZE);
++ trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM,
++ mcontext_addr + 32 * AARCH64_MCONTEXT_REG_SIZE);
++ trad_frame_set_reg_addr (this_cache, AARCH64_CPSR_REGNUM,
++ mcontext_addr + 33 * AARCH64_MCONTEXT_REG_SIZE);
++
++ if (target_read_memory (mcontext_addr + AARCH64_MCONTEXT_FLAGS_OFFSET, buf,
++ 4) == 0
++ && (extract_unsigned_integer (buf, 4, byte_order)
++ & AARCH64_MCONTEXT_FLAG_FP_VALID))
++ {
++ for (i = 0; i < 32; i++)
++ {
++ trad_frame_set_reg_addr (this_cache, AARCH64_V0_REGNUM + i,
++ mcontext_addr
++ + AARCH64_MCONTEXT_FPREGS_OFFSET
++ + i * AARCH64_MCONTEXT_FPREG_SIZE);
++ }
++ trad_frame_set_reg_addr (this_cache, AARCH64_FPSR_REGNUM,
++ mcontext_addr + AARCH64_MCONTEXT_FPREGS_OFFSET
++ + 32 * AARCH64_MCONTEXT_FPREG_SIZE);
++ trad_frame_set_reg_addr (this_cache, AARCH64_FPCR_REGNUM,
++ mcontext_addr + AARCH64_MCONTEXT_FPREGS_OFFSET
++ + 32 * AARCH64_MCONTEXT_FPREG_SIZE + 4);
++ }
++
++ trad_frame_set_id (this_cache, frame_id_build (sp, func));
++}
++
++static const struct tramp_frame aarch64_nbsd_sigframe =
++{
++ SIGTRAMP_FRAME,
++ 4,
++ {
++ {0x910003e0, ULONGEST_MAX}, /* mov x0, sp */
++ {0x91014000, ULONGEST_MAX}, /* add x0, x0, #SF_UC */
++ {0xd2803428, ULONGEST_MAX}, /* mov x8, #SYS_sigreturn */
++ {0xd4000001, ULONGEST_MAX}, /* svc 0x0 */
++ {(ULONGEST)TRAMP_SENTINEL_INSN, ULONGEST_MAX}
++ },
++ aarch64_nbsd_sigframe_init
++};
++
++/* Register maps. */
++
++static const struct regcache_map_entry aarch64_nbsd_gregmap[] =
++ {
++ { 30, AARCH64_X0_REGNUM, 8 }, /* x0 ... x29 */
++ { 1, AARCH64_LR_REGNUM, 8 },
++ { 1, AARCH64_SP_REGNUM, 8 },
++ { 1, AARCH64_PC_REGNUM, 8 },
++ { 1, AARCH64_CPSR_REGNUM, 4 },
++ { 0 }
++ };
++
++static const struct regcache_map_entry aarch64_nbsd_fpregmap[] =
++ {
++ { 32, AARCH64_V0_REGNUM, 16 }, /* v0 ... v31 */
++ { 1, AARCH64_FPSR_REGNUM, 4 },
++ { 1, AARCH64_FPCR_REGNUM, 4 },
++ { 0 }
++ };
++
++/* Register set definitions. */
++
++const struct regset aarch64_nbsd_gregset =
++ {
++ aarch64_nbsd_gregmap,
++ regcache_supply_regset, regcache_collect_regset
++ };
++
++const struct regset aarch64_nbsd_fpregset =
++ {
++ aarch64_nbsd_fpregmap,
++ regcache_supply_regset, regcache_collect_regset
++ };
++
++/* Implement the "regset_from_core_section" gdbarch method. */
++
++static void
++aarch64_nbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
++ iterate_over_regset_sections_cb *cb,
++ void *cb_data,
++ const struct regcache *regcache)
++{
++ cb (".reg", AARCH64_NBSD_SIZEOF_GREGSET, AARCH64_NBSD_SIZEOF_GREGSET,
++ &aarch64_nbsd_gregset, NULL, cb_data);
++ cb (".reg2", AARCH64_NBSD_SIZEOF_FPREGSET, AARCH64_NBSD_SIZEOF_FPREGSET,
++ &aarch64_nbsd_fpregset, NULL, cb_data);
++}
++
++/* Implement the 'init_osabi' method of struct gdb_osabi_handler. */
++
++static void
++aarch64_nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
++{
++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
++
++ set_solib_svr4_fetch_link_map_offsets (gdbarch,
++ svr4_lp64_fetch_link_map_offsets);
++
++ tramp_frame_prepend_unwinder (gdbarch, &aarch64_nbsd_sigframe);
++
++ /* Enable longjmp. */
++ tdep->jb_pc = 13;
++
++ set_gdbarch_iterate_over_regset_sections
++ (gdbarch, aarch64_nbsd_iterate_over_regset_sections);
++}
++
++void
++_initialize_aarch64_nbsd_tdep (void)
++{
++ gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_NETBSD,
++ aarch64_nbsd_init_abi);
++}
diff --git a/gdb-netbsd/patches/patch-gdb_aarch64-nbsd-tdep.h b/gdb-netbsd/patches/patch-gdb_aarch64-nbsd-tdep.h
new file mode 100644
index 0000000000..3ae9a0e0e4
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_aarch64-nbsd-tdep.h
@@ -0,0 +1,38 @@
+$NetBSD$
+
+--- gdb/aarch64-nbsd-tdep.h.orig 2019-09-02 20:02:23.494326453 +0000
++++ gdb/aarch64-nbsd-tdep.h
+@@ -0,0 +1,33 @@
++/* NetBSD/aarch64 target support, prototypes.
++
++ Copyright (C) 2017-2018 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 "regset.h"
++
++/* The general-purpose regset consists of 31 registers (30 X , plus LR), SP,
++ ELR (PC), SPSR register, and TPIDR. SPSR is 32 bits but the structure is
++ passed to 64 bit alignment. */
++#define AARCH64_NBSD_SIZEOF_GREGSET (35 * X_REGISTER_SIZE)
++
++/* The fp regset consists of 32 V registers, plus FPSR and FPCR which
++ are 4 bytes wide each, and the whole structure is padded to 128 bit
++ alignment. */
++#define AARCH64_NBSD_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE)
++
++extern const struct regset aarch64_nbsd_gregset;
++extern const struct regset aarch64_nbsd_fpregset;
diff --git a/gdb-netbsd/patches/patch-gdb_alpha-bsd-nat.c b/gdb-netbsd/patches/patch-gdb_alpha-bsd-nat.c
new file mode 100644
index 0000000000..b97a757c85
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_alpha-bsd-nat.c
@@ -0,0 +1,132 @@
+$NetBSD$
+
+--- gdb/alpha-bsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/alpha-bsd-nat.c
+@@ -33,17 +33,12 @@
+ #include <sys/procfs.h>
+ #endif
+
+-#ifndef HAVE_GREGSET_T
+-typedef struct reg gregset_t;
+-#endif
+-
+-#ifndef HAVE_FPREGSET_T
+-typedef struct fpreg fpregset_t;
+-#endif
+-
+-#include "gregset.h"
+-
++#ifdef __NetBSD__
++#include "nbsd-nat.h"
++struct alpha_bsd_nat_target final : public nbsd_nat_target
++#else
+ struct alpha_bsd_nat_target final : public inf_ptrace_target
++#endif
+ {
+ void fetch_registers (struct regcache *, int) override;
+ void store_registers (struct regcache *, int) override;
+@@ -51,33 +46,6 @@ struct alpha_bsd_nat_target final : publ
+
+ static alpha_bsd_nat_target the_alpha_bsd_nat_target;
+
+-/* Provide *regset() wrappers around the generic Alpha BSD register
+- supply/fill routines. */
+-
+-void
+-supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
+-{
+- alphabsd_supply_reg (regcache, (const char *) gregsetp, -1);
+-}
+-
+-void
+-fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno)
+-{
+- alphabsd_fill_reg (regcache, (char *) gregsetp, regno);
+-}
+-
+-void
+-supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
+-{
+- alphabsd_supply_fpreg (regcache, (const char *) fpregsetp, -1);
+-}
+-
+-void
+-fill_fpregset (const struct regcache *regcache,
+- fpregset_t *fpregsetp, int regno)
+-{
+- alphabsd_fill_fpreg (regcache, (char *) fpregsetp, regno);
+-}
+
+ /* Determine if PT_GETREGS fetches this register. */
+
+@@ -94,12 +62,15 @@ getregs_supplies (int regno)
+ void
+ alpha_bsd_nat_target::fetch_registers (struct regcache *regcache, int regno)
+ {
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
++
+ if (regno == -1 || getregs_supplies (regno))
+ {
+ struct reg gregs;
+
+- if (ptrace (PT_GETREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &gregs, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ alphabsd_supply_reg (regcache, (char *) &gregs, regno);
+@@ -112,8 +83,7 @@ alpha_bsd_nat_target::fetch_registers (s
+ {
+ struct fpreg fpregs;
+
+- if (ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ alphabsd_supply_fpreg (regcache, (char *) &fpregs, regno);
+@@ -126,17 +96,20 @@ alpha_bsd_nat_target::fetch_registers (s
+ void
+ alpha_bsd_nat_target::store_registers (struct regcache *regcache, int regno)
+ {
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
++
+ if (regno == -1 || getregs_supplies (regno))
+ {
+ struct reg gregs;
+- if (ptrace (PT_GETREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
++ if (ptrace (PT_GETREGS, pid,
++ (PTRACE_TYPE_ARG3) &gregs, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ alphabsd_fill_reg (regcache, (char *) &gregs, regno);
+
+- if (ptrace (PT_SETREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
++ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &gregs, lwp) == -1)
+ perror_with_name (_("Couldn't write registers"));
+
+ if (regno != -1)
+@@ -148,14 +121,13 @@ alpha_bsd_nat_target::store_registers (s
+ {
+ struct fpreg fpregs;
+
+- if (ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ alphabsd_fill_fpreg (regcache, (char *) &fpregs, regno);
+
+- if (ptrace (PT_SETFPREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_SETFPREGS, pid,
++ (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't write floating point status"));
+ }
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_alpha-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_alpha-nbsd-tdep.c
new file mode 100644
index 0000000000..e7dfeeb9b2
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_alpha-nbsd-tdep.c
@@ -0,0 +1,184 @@
+$NetBSD$
+
+--- gdb/alpha-nbsd-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/alpha-nbsd-tdep.c
+@@ -28,13 +28,18 @@
+ #include "value.h"
+
+ #include "alpha-tdep.h"
+-#include "alpha-bsd-tdep.h"
+ #include "nbsd-tdep.h"
+ #include "solib-svr4.h"
++#include "trad-frame.h"
++#include "frame-unwind.h"
++#include "tramp-frame.h"
+ #include "target.h"
+
+ /* Core file support. */
+
++/* Even though NetBSD/alpha used ELF since day one, it used the
++ traditional a.out-style core dump format before NetBSD 1.6. */
++
+ /* Sizeof `struct reg' in <machine/reg.h>. */
+ #define ALPHANBSD_SIZEOF_GREGS (32 * 8)
+
+@@ -170,31 +175,95 @@ alphanbsd_iterate_over_regset_sections (
+
+ /* Signal trampolines. */
+
++static void
++alphanbsd_sigtramp_cache_init (const struct tramp_frame *,
++ struct frame_info *,
++ struct trad_frame_cache *,
++ CORE_ADDR);
+ /* Under NetBSD/alpha, signal handler invocations can be identified by the
+ designated code sequence that is used to return from a signal handler.
+ In particular, the return address of a signal handler points to the
+- following code sequence:
++ following code sequences: */
++static const struct tramp_frame alphanbsd_sigtramp_sc1 = {
++ SIGTRAMP_FRAME,
++ 4,
++ {
++ { 0xa61e0000, 0xffffffff }, /* ldq a0, 0(sp) */
++ { 0x23de0010, 0xffffffff }, /* lda sp, 16(sp) */
++ { 0x201f0127, 0xffffffff }, /* lda v0, 295 */
++ { 0x00000083, 0xffffffff }, /* call_pal callsys */
++ { TRAMP_SENTINEL_INSN, ULONGEST_MAX }
++ },
++ alphanbsd_sigtramp_cache_init
++};
+
+- ldq a0, 0(sp)
+- lda sp, 16(sp)
+- lda v0, 295(zero) # __sigreturn14
+- call_pal callsys
+-
+- Each instruction has a unique encoding, so we simply attempt to match
+- the instruction the PC is pointing to with any of the above instructions.
+- If there is a hit, we know the offset to the start of the designated
+- sequence and can then check whether we really are executing in the
+- signal trampoline. If not, -1 is returned, otherwise the offset from the
+- start of the return sequence is returned. */
+-static const gdb_byte sigtramp_retcode[] =
+-{
+- 0x00, 0x00, 0x1e, 0xa6, /* ldq a0, 0(sp) */
+- 0x10, 0x00, 0xde, 0x23, /* lda sp, 16(sp) */
+- 0x27, 0x01, 0x1f, 0x20, /* lda v0, 295(zero) */
+- 0x83, 0x00, 0x00, 0x00, /* call_pal callsys */
++/* The siginfo signal trampoline for NetBSD/alpha introduced in 2.0 */
++static const struct tramp_frame alphanbsd_sigtramp_si2 =
++{
++ SIGTRAMP_FRAME,
++ 4,
++ {
++ { 0x221e0080, ULONGEST_MAX }, /* lda a0,128(sp) */
++ { 0x201f0134, ULONGEST_MAX }, /* lda v0,308 */
++ { 0x00000083, ULONGEST_MAX }, /* callsys */
++ { 0x47e00410, ULONGEST_MAX }, /* mov v0,a0 */
++ { 0x201f0001, ULONGEST_MAX }, /* lda v0,1 */
++ { 0x00000083, ULONGEST_MAX }, /* callsys */
++ { TRAMP_SENTINEL_INSN, ULONGEST_MAX }
++ },
++ alphanbsd_sigtramp_cache_init
++};
++/* The siginfo signal trampoline for NetBSD/alpha introduced in 4.0 */
++static const struct tramp_frame alphanbsd_sigtramp_si4 =
++{
++ SIGTRAMP_FRAME,
++ 4,
++ {
++ { 0x27ba0000, 0xffff0000 },
++ { 0x23bd0000, 0xffff0000 }, /* ldgp gp,0(ra) */
++ { 0x221e0080, ULONGEST_MAX }, /* lda a0,128(sp) */
++ { 0x201f0134, ULONGEST_MAX }, /* lda v0,308 */
++ { 0x00000083, ULONGEST_MAX }, /* callsys */
++ { 0x221fffff, ULONGEST_MAX }, /* lda a0,-1 */
++ { 0x201f0001, ULONGEST_MAX }, /* lda v0,1 */
++ { 0x00000083, ULONGEST_MAX }, /* callsys */
++ { TRAMP_SENTINEL_INSN, ULONGEST_MAX }
++ },
++ alphanbsd_sigtramp_cache_init
+ };
+-#define RETCODE_NWORDS 4
+-#define RETCODE_SIZE (RETCODE_NWORDS * 4)
++
++static void
++alphanbsd_sigtramp_cache_init (const struct tramp_frame *self,
++ struct frame_info *this_frame,
++ struct trad_frame_cache *this_cache,
++ CORE_ADDR func)
++{
++ struct gdbarch *gdbarch = get_frame_arch (this_frame);
++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
++ CORE_ADDR addr, sp;
++ int i;
++
++ sp = get_frame_register_unsigned (this_frame, ALPHA_SP_REGNUM);
++
++ if (self == &alphanbsd_sigtramp_sc1) {
++ addr = sp;
++ } else {
++ addr = sp + 128 + 56;
++ }
++
++ for (i = 0; i < 32; i++, addr += ALPHA_REGISTER_SIZE)
++ {
++ trad_frame_set_reg_addr (this_cache, i, addr);
++ }
++ trad_frame_set_reg_addr (this_cache, ALPHA_PC_REGNUM, addr);
++
++ /* Construct the frame ID using the function start. */
++ trad_frame_set_id (this_cache, frame_id_build (sp, func));
++}
++
++#ifdef notyet
++#define RETCODE_NWORDS 4
++#define RETCODE_SIZE (RETCODE_NWORDS * 4)
+
+ static LONGEST
+ alphanbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
+@@ -244,6 +313,7 @@ alphanbsd_sigcontext_addr (struct frame_
+ return 0;
+ return get_frame_base (get_next_frame (frame));
+ }
++#endif
+
+
+ static void
+@@ -261,18 +331,24 @@ alphanbsd_init_abi (struct gdbarch_info
+ /* NetBSD/alpha does not provide single step support via ptrace(2); we
+ must use software single-stepping. */
+ set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
+-
+ /* NetBSD/alpha has SVR4-style shared libraries. */
+ set_solib_svr4_fetch_link_map_offsets
+ (gdbarch, svr4_lp64_fetch_link_map_offsets);
++ set_gdbarch_skip_solib_resolver (gdbarch, nbsd_skip_solib_resolver);
+
++#ifdef notyet
+ tdep->dynamic_sigtramp_offset = alphanbsd_sigtramp_offset;
+ tdep->pc_in_sigtramp = alphanbsd_pc_in_sigtramp;
+ tdep->sigcontext_addr = alphanbsd_sigcontext_addr;
++#endif
+
+ tdep->jb_pc = 2;
+ tdep->jb_elt_size = 8;
+
++ tramp_frame_prepend_unwinder (gdbarch, &alphanbsd_sigtramp_sc1);
++ tramp_frame_prepend_unwinder (gdbarch, &alphanbsd_sigtramp_si2);
++ tramp_frame_prepend_unwinder (gdbarch, &alphanbsd_sigtramp_si4);
++
+ set_gdbarch_iterate_over_regset_sections
+ (gdbarch, alphanbsd_iterate_over_regset_sections);
+ }
+@@ -281,9 +357,6 @@ alphanbsd_init_abi (struct gdbarch_info
+ void
+ _initialize_alphanbsd_tdep (void)
+ {
+- /* Even though NetBSD/alpha used ELF since day one, it used the
+- traditional a.out-style core dump format before NetBSD 1.6, but
+- we don't support those. */
+ gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_NETBSD,
+ alphanbsd_init_abi);
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_alpha-tdep.c b/gdb-netbsd/patches/patch-gdb_alpha-tdep.c
new file mode 100644
index 0000000000..7082f1dcba
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_alpha-tdep.c
@@ -0,0 +1,36 @@
+$NetBSD$
+
+--- gdb/alpha-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/alpha-tdep.c
+@@ -754,6 +754,31 @@ alpha_skip_prologue (struct gdbarch *gdb
+ return pc + offset;
+ }
+
++/* GNU ld for alpha is so clever that the redundant GP load in function
++ entrypoint is skipped. We must therefore skip initial GP loads; otherwise
++ breakpoints in function entrypoints can also be skipped. */
++
++static CORE_ADDR
++alpha_skip_entrypoint (struct gdbarch *gdbarch, CORE_ADDR pc)
++{
++ unsigned long inst;
++ gdb_byte buf[ALPHA_INSN_SIZE];
++
++ /* Refer to the comment in alpha_skip_prologue above. */
++ if (target_read_memory (pc, buf, sizeof (buf)))
++ return pc;
++
++ /* Skip a GP load in the first two words in the function entrypoint. */
++ inst = alpha_read_insn (gdbarch, pc);
++ if ((inst & 0xffff0000) != 0x27bb0000) /* ldah $gp,n($t12) */
++ return pc;
++ inst = alpha_read_insn (gdbarch, pc + ALPHA_INSN_SIZE);
++ if ((inst & 0xffff0000) != 0x23bd0000) /* lda $gp,n($gp) */
++ return pc;
++
++ return pc + 2 * ALPHA_INSN_SIZE;
++}
++
+
+ static const int ldl_l_opcode = 0x2a;
+ static const int ldq_l_opcode = 0x2b;
diff --git a/gdb-netbsd/patches/patch-gdb_amd64-bsd-nat.c b/gdb-netbsd/patches/patch-gdb_amd64-bsd-nat.c
new file mode 100644
index 0000000000..ec06f76e9d
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_amd64-bsd-nat.c
@@ -0,0 +1,75 @@
+$NetBSD$
+
+--- gdb/amd64-bsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/amd64-bsd-nat.c
+@@ -51,7 +51,7 @@ amd64bsd_fetch_inferior_registers (struc
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ amd64_supply_native_gregset (regcache, ®s, -1);
+@@ -95,7 +95,7 @@ amd64bsd_fetch_inferior_registers (struc
+ if (x86bsd_xsave_len != 0)
+ {
+ xstateregs = alloca (x86bsd_xsave_len);
+- if (ptrace (PT_GETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, 0)
++ if (ptrace (PT_GETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, inferior_ptid.lwp ())
+ == -1)
+ perror_with_name (_("Couldn't get extended state status"));
+
+@@ -104,7 +104,7 @@ amd64bsd_fetch_inferior_registers (struc
+ }
+ #endif
+
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ amd64_supply_fxsave (regcache, -1, &fpregs);
+@@ -127,12 +127,12 @@ amd64bsd_store_inferior_registers (struc
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ amd64_collect_native_gregset (regcache, ®s, regnum);
+
+- if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't write registers"));
+
+ if (regnum != -1)
+@@ -179,11 +179,11 @@ amd64bsd_store_inferior_registers (struc
+ if (x86bsd_xsave_len != 0)
+ {
+ xstateregs = alloca (x86bsd_xsave_len);
+- if (ptrace (PT_GETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, 0)
++ if (ptrace (PT_GETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, inferior_ptid.lwp ())
+ == -1)
+ perror_with_name (_("Couldn't get extended state status"));
+
+- amd64_collect_xsave (regcache, regnum, xstateregs, 0);
++ amd64_collect_xsave (regcache, regnum, xstateregs, inferior_ptid.lwp ());
+
+ if (ptrace (PT_SETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs,
+ x86bsd_xsave_len) == -1)
+@@ -192,12 +192,12 @@ amd64bsd_store_inferior_registers (struc
+ }
+ #endif
+
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ amd64_collect_fxsave (regcache, regnum, &fpregs);
+
+- if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't write floating point status"));
+ }
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_amd64-nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_amd64-nbsd-nat.c
new file mode 100644
index 0000000000..72202df156
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_amd64-nbsd-nat.c
@@ -0,0 +1,81 @@
+$NetBSD$
+
+--- gdb/amd64-nbsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/amd64-nbsd-nat.c
+@@ -24,6 +24,13 @@
+ #include "amd64-tdep.h"
+ #include "amd64-bsd-nat.h"
+ #include "amd64-nat.h"
++#include "regcache.h"
++#include "gdbcore.h"
++#include "bsd-kvm.h"
++
++#include <machine/frame.h>
++#include <machine/pcb.h>
++#include <machine/reg.h>
+
+ /* Mapping between the general-purpose registers in NetBSD/amd64
+ `struct reg' format and GDB's register cache layout for
+@@ -54,6 +61,55 @@ static int amd64nbsd32_r_reg_offset[] =
+ 15 * 8 /* %gs */
+ };
+
++static int
++amd64nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
++{
++ struct switchframe sf;
++
++ /* The following is true for NetBSD/amd64:
++
++ The pcb contains the stack pointer at the point of the context
++ switch in cpu_switchto(). At that point we have a stack frame as
++ described by `struct switchframe', which for NetBSD/amd64 has the
++ following layout:
++
++ interrupt level
++ %r15
++ %r14
++ %r13
++ %r12
++ %rbx
++ return address
++
++ Together with %rsp in the pcb, this accounts for all callee-saved
++ registers specified by the psABI. From this information we
++ reconstruct the register state as it would look when we just
++ returned from cpu_switchto().
++
++ For kernel core dumps, dumpsys() builds a fake switchframe for us. */
++
++ /* The stack pointer shouldn't be zero. */
++ if (pcb->pcb_rsp == 0)
++ return 0;
++
++ /* Read the stack frame, and check its validity. */
++ read_memory (pcb->pcb_rsp, (gdb_byte *) &sf, sizeof sf);
++ pcb->pcb_rsp += sizeof (struct switchframe);
++ regcache->raw_supply (12, &sf.sf_r12);
++ regcache->raw_supply (13, &sf.sf_r13);
++ regcache->raw_supply (14, &sf.sf_r14);
++ regcache->raw_supply (15, &sf.sf_r15);
++ regcache->raw_supply (AMD64_RBX_REGNUM, &sf.sf_rbx);
++ regcache->raw_supply (AMD64_RIP_REGNUM, &sf.sf_rip);
++
++ regcache->raw_supply (AMD64_RSP_REGNUM, &pcb->pcb_rsp);
++ regcache->raw_supply (AMD64_RBP_REGNUM, &pcb->pcb_rbp);
++ regcache->raw_supply (AMD64_FS_REGNUM, &pcb->pcb_fs);
++ regcache->raw_supply (AMD64_GS_REGNUM, &pcb->pcb_gs);
++
++ return 1;
++}
++
+ static amd64_bsd_nat_target<nbsd_nat_target> the_amd64_nbsd_nat_target;
+
+ void
+@@ -64,4 +120,6 @@ _initialize_amd64nbsd_nat (void)
+ amd64_native_gregset64_reg_offset = amd64nbsd_r_reg_offset;
+
+ add_inf_child_target (&the_amd64_nbsd_nat_target);
++
++ bsd_kvm_add_target (amd64nbsd_supply_pcb);
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_amd64-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_amd64-nbsd-tdep.c
new file mode 100644
index 0000000000..dd95f1084a
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_amd64-nbsd-tdep.c
@@ -0,0 +1,219 @@
+$NetBSD$
+
+--- gdb/amd64-nbsd-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/amd64-nbsd-tdep.c
+@@ -28,6 +28,8 @@
+ #include "gdbsupport/x86-xstate.h"
+ #include "nbsd-tdep.h"
+ #include "solib-svr4.h"
++#include "trad-frame.h"
++#include "frame-unwind.h"
+
+ /* Support for signal handlers. */
+
+@@ -94,6 +96,196 @@ int amd64nbsd_r_reg_offset[] =
+ 15 * 8 /* %gs */
+ };
+
++/* Kernel debugging support */
++static const int amd64nbsd_tf_reg_offset[] =
++{
++ 18 * 8, /* %rax */
++ 17 * 8, /* %rbx */
++ 10 * 8, /* %rcx */
++ 2 * 8, /* %rdx */
++ 1 * 8, /* %rsi */
++ 0 * 8, /* %rdi */
++ 16 * 8, /* %rbp */
++ 28 * 8, /* %rsp */
++ 4 * 8, /* %r8 .. */
++ 5 * 8,
++ 3 * 8,
++ 11 * 8,
++ 12 * 8,
++ 13 * 8,
++ 14 * 8,
++ 15 * 8, /* ... %r15 */
++ 25 * 8, /* %rip */
++ 27 * 8, /* %eflags */
++ 26 * 8, /* %cs */
++ 29 * 8, /* %ss */
++ 22 * 8, /* %ds */
++ 21 * 8, /* %es */
++ 20 * 8, /* %fs */
++ 19 * 8, /* %gs */
++};
++
++static struct trad_frame_cache *
++amd64nbsd_trapframe_cache(struct frame_info *this_frame, void **this_cache)
++{
++ struct trad_frame_cache *cache;
++ CORE_ADDR func, sp, addr;
++ ULONGEST cs = 0, rip = 0;
++ const char *name;
++ int i;
++ struct gdbarch *gdbarch = get_frame_arch (this_frame);
++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
++
++ if (*this_cache)
++ return (struct trad_frame_cache *)*this_cache;
++
++ cache = trad_frame_cache_zalloc (this_frame);
++ *this_cache = cache;
++
++ func = get_frame_func (this_frame);
++ sp = get_frame_register_unsigned (this_frame, AMD64_RSP_REGNUM);
++
++ find_pc_partial_function (func, &name, NULL, NULL);
++
++ /* There is an extra 'call' in the interrupt sequence - ignore the extra
++ * return address */
++
++ addr = sp;
++ if (name) {
++ if (strncmp (name, "Xintr", 5) == 0
++ || strncmp (name, "Xhandle", 7) == 0) {
++ addr += 8; /* It's an interrupt frame. */
++ }
++ }
++
++#ifdef DEBUG_TRAPFRAME
++ for (i = 0; i < 50; i++) {
++ cs = read_memory_unsigned_integer (addr + i * 8, 8, byte_order);
++ printf("%s i=%d r=%#jx\n", name, i, (intmax_t)cs);
++ }
++#endif
++
++ for (i = 0; i < ARRAY_SIZE (amd64nbsd_tf_reg_offset); i++)
++ if (amd64nbsd_tf_reg_offset[i] != -1)
++ trad_frame_set_reg_addr (cache, i, addr + amd64nbsd_tf_reg_offset[i]);
++
++ /* Read %cs and %rip when we have the addresses to hand */
++ cs = read_memory_unsigned_integer (addr
++ + amd64nbsd_tf_reg_offset[AMD64_CS_REGNUM], 8, byte_order);
++ rip = read_memory_unsigned_integer (addr
++ + amd64nbsd_tf_reg_offset[AMD64_RIP_REGNUM], 8, byte_order);
++
++#ifdef DEBUG_TRAPFRAME
++ printf("%s cs=%#jx rip=%#jx\n", name, (intmax_t)cs, (intmax_t)rip);
++#endif
++
++ /* The trap frame layout was changed lf the %rip value is less than 2^16 it
++ * is almost certainly the %ss of the old format. */
++ if (rip < (1 << 16))
++ {
++
++ for (i = 0; i < ARRAY_SIZE (amd64nbsd_tf_reg_offset); i++)
++ {
++
++ if (amd64nbsd_tf_reg_offset[i] == -1)
++ continue;
++
++ trad_frame_set_reg_addr (cache, i, addr + amd64nbsd_r_reg_offset[i]);
++
++ /* Read %cs when we have the address to hand */
++ if (i == AMD64_CS_REGNUM)
++ cs = read_memory_unsigned_integer (addr + amd64nbsd_r_reg_offset[i],
++ 8, byte_order);
++ }
++ }
++
++ if ((cs & I386_SEL_RPL) == I386_SEL_UPL ||
++ (name && strncmp(name, "Xsoft", 5) == 0))
++ {
++ /* Trap from user space or soft interrupt; terminate backtrace. */
++ trad_frame_set_id (cache, outer_frame_id);
++ }
++ else
++ {
++ /* Construct the frame ID using the function start. */
++ trad_frame_set_id (cache, frame_id_build (sp + 16, func));
++ }
++
++ return cache;
++}
++
++static void
++amd64nbsd_trapframe_this_id (struct frame_info *this_frame,
++ void **this_cache,
++ struct frame_id *this_id)
++{
++ struct trad_frame_cache *cache =
++ amd64nbsd_trapframe_cache (this_frame, this_cache);
++
++ trad_frame_get_id (cache, this_id);
++}
++
++static struct value *
++amd64nbsd_trapframe_prev_register (struct frame_info *this_frame,
++ void **this_cache, int regnum)
++{
++ struct trad_frame_cache *cache =
++ amd64nbsd_trapframe_cache (this_frame, this_cache);
++
++ return trad_frame_get_register (cache, this_frame, regnum);
++}
++
++static int
++amd64nbsd_trapframe_sniffer (const struct frame_unwind *self,
++ struct frame_info *this_frame,
++ void **this_prologue_cache)
++{
++ ULONGEST cs = 0;
++ const char *name;
++
++ try
++ {
++ cs = get_frame_register_unsigned (this_frame, AMD64_CS_REGNUM);
++ }
++ catch (gdb_exception_error &except)
++ {
++ if (except.reason < 0 && except.error != NOT_AVAILABLE_ERROR)
++ throw_exception (std::move (except));
++ }
++
++ if ((cs & I386_SEL_RPL) == I386_SEL_UPL)
++ return 0;
++
++ find_pc_partial_function (get_frame_pc (this_frame), &name, NULL, NULL);
++ return (name && ((strcmp (name, "alltraps") == 0)
++ || (strcmp (name, "calltrap") == 0)
++ || (strcmp (name, "handle_syscall") == 0)
++ || (strcmp (name, "Xdoreti") == 0)
++ || (strcmp (name, "Xspllower") == 0)
++ || (strncmp (name, "Xhandle", 7) == 0)
++ || (strncmp (name, "Xintr", 5) == 0)
++ || (strncmp (name, "Xpreempt", 8) == 0)
++ || (strncmp (name, "Xrecurse", 8) == 0)
++ || (strncmp (name, "Xresume", 7) == 0)
++ || (strncmp (name, "Xsoft", 5) == 0)
++ || (strncmp (name, "Xstray", 6) == 0)
++ || (strncmp (name, "Xsyscall", 8) == 0)
++ || (strncmp (name, "Xtrap", 5) == 0)
++ ));
++}
++
++static const struct frame_unwind amd64nbsd_trapframe_unwind = {
++ /* FIXME: kettenis/20051219: This really is more like an interrupt
++ frame, but SIGTRAMP_FRAME would print <signal handler called>,
++ which really is not what we want here. */
++ NORMAL_FRAME,
++ default_frame_unwind_stop_reason,
++ amd64nbsd_trapframe_this_id,
++ amd64nbsd_trapframe_prev_register,
++ NULL,
++ amd64nbsd_trapframe_sniffer
++};
++
+ static void
+ amd64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ {
+@@ -118,6 +310,8 @@ amd64nbsd_init_abi (struct gdbarch_info
+ /* NetBSD uses SVR4-style shared libraries. */
+ set_solib_svr4_fetch_link_map_offsets
+ (gdbarch, svr4_lp64_fetch_link_map_offsets);
++ /* Unwind kernel trap frames correctly. */
++ frame_unwind_prepend_unwinder (gdbarch, &amd64nbsd_trapframe_unwind);
+ }
+
+ void
diff --git a/gdb-netbsd/patches/patch-gdb_arm-nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_arm-nbsd-nat.c
new file mode 100644
index 0000000000..c5e5fc280a
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_arm-nbsd-nat.c
@@ -0,0 +1,568 @@
+$NetBSD$
+
+--- gdb/arm-nbsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/arm-nbsd-nat.c
+@@ -1,5 +1,4 @@
+-/* Native-dependent code for BSD Unix running on ARM's, for GDB.
+-
++/*
+ Copyright (C) 1988-2019 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+@@ -17,20 +16,30 @@
+ 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 _KERNTYPES
++#define _KERNTYPES
++#endif
+ #include "defs.h"
+ #include "gdbcore.h"
+ #include "inferior.h"
+ #include "regcache.h"
+ #include "target.h"
++
++#include "nbsd-nat.h"
+ #include <sys/types.h>
+ #include <sys/ptrace.h>
+ #include <machine/reg.h>
+ #include <machine/frame.h>
++#include <arm/arm32/frame.h>
++
++/* Support for debugging kernel virtual memory images. */
++#include <machine/pcb.h>
+
+ #include "arm-tdep.h"
+ #include "inf-ptrace.h"
++#include "bsd-kvm.h"
+
+-class arm_netbsd_nat_target final : public inf_ptrace_target
++class arm_nbsd_nat_target final : public nbsd_nat_target
+ {
+ public:
+ /* Add our register access methods. */
+@@ -38,10 +47,60 @@ public:
+ void store_registers (struct regcache *, int) override;
+ };
+
+-static arm_netbsd_nat_target the_arm_netbsd_nat_target;
++static arm_nbsd_nat_target the_arm_nbsd_nat_target;
+
+ extern int arm_apcs_32;
+
++#define FPSCR(r) ((char *) &(r)->fpr_vfp.vfp_fpscr)
++#define FPREG(r, regno) \
++ ((char *) (r)->fpr_vfp.vfp_regs + 8 * ((regno) - ARM_D0_REGNUM))
++
++static int
++armnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
++{
++ struct switchframe sf;
++
++ /* The following is true for NetBSD/arm32 in 5.0 and after:
++
++ The pcb contains r8-r13 (sp) at the point of context switch in
++ cpu_switchto() or call of dumpsys(). At that point we have a
++ stack frame as described by `struct switchframe', which for
++ NetBSD/arm32 has the following layout:
++
++ r4 ascending.
++ r5 |
++ r6 |
++ r7 \|/
++ old sp
++ pc
++
++ we reconstruct the register state as it would look when we just
++ returned from cpu_switchto() or dumpsys(). */
++
++ if (!arm_apcs_32)
++ return 0;
++
++ /* The stack pointer shouldn't be zero. */
++ if (pcb->pcb_sp == 0)
++ return 0;
++
++ read_memory (pcb->pcb_sp, (gdb_byte *) &sf, sizeof sf);
++
++ regcache->raw_supply (ARM_PC_REGNUM, &sf.sf_pc);
++ regcache->raw_supply (ARM_SP_REGNUM, &pcb->pcb_sp);
++ regcache->raw_supply (12, &pcb->pcb_r12);
++ regcache->raw_supply (11, &pcb->pcb_r11);
++ regcache->raw_supply (10, &pcb->pcb_r10);
++ regcache->raw_supply (9, &pcb->pcb_r9);
++ regcache->raw_supply (8, &pcb->pcb_r8);
++ regcache->raw_supply (7, &sf.sf_r7);
++ regcache->raw_supply (6, &sf.sf_r6);
++ regcache->raw_supply (5, &sf.sf_r5);
++ regcache->raw_supply (4, &sf.sf_r4);
++
++ return 1;
++}
++
+ static void
+ arm_supply_gregset (struct regcache *regcache, struct reg *gregset)
+ {
+@@ -65,25 +124,26 @@ arm_supply_gregset (struct regcache *reg
+ }
+
+ static void
+-arm_supply_fparegset (struct regcache *regcache, struct fpreg *fparegset)
++arm_supply_vfpregset (struct regcache *regcache, struct fpreg *vfpregset)
+ {
+ int regno;
+
+- for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++)
+- regcache->raw_supply (regno,
+- (char *) &fparegset->fpr[regno - ARM_F0_REGNUM]);
++ for (regno = ARM_D0_REGNUM; regno < 16 + ARM_D0_REGNUM; regno++)
++ regcache->raw_supply (regno, FPREG(vfpregset, regno));
+
+- regcache->raw_supply (ARM_FPS_REGNUM, (char *) &fparegset->fpr_fpsr);
++ regcache->raw_supply (ARM_FPSCR_REGNUM, FPSCR(vfpregset));
+ }
+
+ static void
+ fetch_register (struct regcache *regcache, int regno)
+ {
+- struct reg inferior_registers;
++ struct reg regs;
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+ int ret;
+
+- ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &inferior_registers, 0);
++ ret = ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp);
+
+ if (ret < 0)
+ {
+@@ -94,32 +154,28 @@ fetch_register (struct regcache *regcach
+ switch (regno)
+ {
+ case ARM_SP_REGNUM:
+- regcache->raw_supply (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp);
++ regcache->raw_supply (ARM_SP_REGNUM, (char *) ®s.r_sp);
+ break;
+
+ case ARM_LR_REGNUM:
+- regcache->raw_supply (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr);
++ regcache->raw_supply (ARM_LR_REGNUM, (char *) ®s.r_lr);
+ break;
+
+ case ARM_PC_REGNUM:
+ /* This is ok: we're running native... */
+- inferior_registers.r_pc = gdbarch_addr_bits_remove
+- (regcache->arch (),
+- inferior_registers.r_pc);
+- regcache->raw_supply (ARM_PC_REGNUM, (char *) &inferior_registers.r_pc);
++ regs.r_pc = gdbarch_addr_bits_remove (regcache->arch (), regs.r_pc);
++ regcache->raw_supply (ARM_PC_REGNUM, (char *) ®s.r_pc);
+ break;
+
+ case ARM_PS_REGNUM:
+ if (arm_apcs_32)
+- regcache->raw_supply (ARM_PS_REGNUM,
+- (char *) &inferior_registers.r_cpsr);
++ regcache->raw_supply (ARM_PS_REGNUM, (char *) ®s.r_cpsr);
+ else
+- regcache->raw_supply (ARM_PS_REGNUM,
+- (char *) &inferior_registers.r_pc);
++ regcache->raw_supply (ARM_PS_REGNUM, (char *) ®s.r_pc);
+ break;
+
+ default:
+- regcache->raw_supply (regno, (char *) &inferior_registers.r[regno]);
++ regcache->raw_supply (regno, (char *) ®s.r[regno]);
+ break;
+ }
+ }
+@@ -127,12 +183,14 @@ fetch_register (struct regcache *regcach
+ static void
+ fetch_regs (struct regcache *regcache)
+ {
+- struct reg inferior_registers;
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
++ struct reg regs;
+ int ret;
+ int regno;
+
+- ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &inferior_registers, 0);
++ ret = ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp);
+
+ if (ret < 0)
+ {
+@@ -140,17 +198,19 @@ fetch_regs (struct regcache *regcache)
+ return;
+ }
+
+- arm_supply_gregset (regcache, &inferior_registers);
++ arm_supply_gregset (regcache, ®s);
+ }
+
+ static void
+ fetch_fp_register (struct regcache *regcache, int regno)
+ {
+- struct fpreg inferior_fp_registers;
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
++ struct fpreg fpregs;
+ int ret;
+
+- ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
++ ret = ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp);
+
+ if (ret < 0)
+ {
+@@ -160,14 +220,13 @@ fetch_fp_register (struct regcache *regc
+
+ switch (regno)
+ {
+- case ARM_FPS_REGNUM:
+- regcache->raw_supply (ARM_FPS_REGNUM,
+- (char *) &inferior_fp_registers.fpr_fpsr);
++ case ARM_FPSCR_REGNUM:
++ regcache->raw_supply (ARM_FPSCR_REGNUM, FPSCR(&fpregs));
+ break;
+
+ default:
+- regcache->raw_supply
+- (regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]);
++ regno += ARM_D0_REGNUM;
++ regcache->raw_supply (regno, FPREG(&fpregs, regno));
+ break;
+ }
+ }
+@@ -175,20 +234,21 @@ fetch_fp_register (struct regcache *regc
+ static void
+ fetch_fp_regs (struct regcache *regcache)
+ {
+- struct fpreg inferior_fp_registers;
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
++ struct fpreg fpregs;
+ int ret;
+- int regno;
+
+- ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
++ ret = ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp);
+
+ if (ret < 0)
+ {
+- warning (_("unable to fetch general registers"));
++ warning (_("unable to fetch floating-point registers"));
+ return;
+ }
+
+- arm_supply_fparegset (regcache, &inferior_fp_registers);
++ arm_supply_vfpregset (regcache, &fpregs);
+ }
+
+ void
+@@ -196,10 +256,10 @@ arm_nbsd_nat_target::fetch_registers (st
+ {
+ if (regno >= 0)
+ {
+- if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM)
+- fetch_register (regcache, regno);
+- else
++ if (regno >= ARM_D0_REGNUM && regno <= ARM_FPSCR_REGNUM)
+ fetch_fp_register (regcache, regno);
++ else
++ fetch_register (regcache, regno);
+ }
+ else
+ {
+@@ -213,11 +273,13 @@ static void
+ store_register (const struct regcache *regcache, int regno)
+ {
+ struct gdbarch *gdbarch = regcache->arch ();
+- struct reg inferior_registers;
++ struct reg regs;
+ int ret;
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+- ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &inferior_registers, 0);
++ ret = ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp);
+
+ if (ret < 0)
+ {
+@@ -228,17 +290,16 @@ store_register (const struct regcache *r
+ switch (regno)
+ {
+ case ARM_SP_REGNUM:
+- regcache->raw_collect (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp);
++ regcache->raw_collect (ARM_SP_REGNUM, (char *) ®s.r_sp);
+ break;
+
+ case ARM_LR_REGNUM:
+- regcache->raw_collect (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr);
++ regcache->raw_collect (ARM_LR_REGNUM, (char *) ®s.r_lr);
+ break;
+
+ case ARM_PC_REGNUM:
+ if (arm_apcs_32)
+- regcache->raw_collect (ARM_PC_REGNUM,
+- (char *) &inferior_registers.r_pc);
++ regcache->raw_collect (ARM_PC_REGNUM, (char *) ®s.r_pc);
+ else
+ {
+ unsigned pc_val;
+@@ -246,16 +307,14 @@ store_register (const struct regcache *r
+ regcache->raw_collect (ARM_PC_REGNUM, (char *) &pc_val);
+
+ pc_val = gdbarch_addr_bits_remove (gdbarch, pc_val);
+- inferior_registers.r_pc ^= gdbarch_addr_bits_remove
+- (gdbarch, inferior_registers.r_pc);
+- inferior_registers.r_pc |= pc_val;
++ regs.r_pc ^= gdbarch_addr_bits_remove (gdbarch, regs.r_pc);
++ regs.r_pc |= pc_val;
+ }
+ break;
+
+ case ARM_PS_REGNUM:
+ if (arm_apcs_32)
+- regcache->raw_collect (ARM_PS_REGNUM,
+- (char *) &inferior_registers.r_cpsr);
++ regcache->raw_collect (ARM_PS_REGNUM, (char *) ®s.r_cpsr);
+ else
+ {
+ unsigned psr_val;
+@@ -263,19 +322,17 @@ store_register (const struct regcache *r
+ regcache->raw_collect (ARM_PS_REGNUM, (char *) &psr_val);
+
+ psr_val ^= gdbarch_addr_bits_remove (gdbarch, psr_val);
+- inferior_registers.r_pc = gdbarch_addr_bits_remove
+- (gdbarch, inferior_registers.r_pc);
+- inferior_registers.r_pc |= psr_val;
++ regs.r_pc = gdbarch_addr_bits_remove (gdbarch, regs.r_pc);
++ regs.r_pc |= psr_val;
+ }
+ break;
+
+ default:
+- regcache->raw_collect (regno, (char *) &inferior_registers.r[regno]);
++ regcache->raw_collect (regno, (char *) ®s.r[regno]);
+ break;
+ }
+
+- ret = ptrace (PT_SETREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &inferior_registers, 0);
++ ret = ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp);
+
+ if (ret < 0)
+ warning (_("unable to write register %d to inferior"), regno);
+@@ -285,22 +342,24 @@ static void
+ store_regs (const struct regcache *regcache)
+ {
+ struct gdbarch *gdbarch = regcache->arch ();
+- struct reg inferior_registers;
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
++ struct reg regs;
+ int ret;
+ int regno;
+
+
+ for (regno = ARM_A1_REGNUM; regno < ARM_SP_REGNUM; regno++)
+- regcache->raw_collect (regno, (char *) &inferior_registers.r[regno]);
++ regcache->raw_collect (regno, (char *) ®s.r[regno]);
+
+- regcache->raw_collect (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp);
+- regcache->raw_collect (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr);
++ regcache->raw_collect (ARM_SP_REGNUM, (char *) ®s.r_sp);
++ regcache->raw_collect (ARM_LR_REGNUM, (char *) ®s.r_lr);
+
+ if (arm_apcs_32)
+ {
+- regcache->raw_collect (ARM_PC_REGNUM, (char *) &inferior_registers.r_pc);
+- regcache->raw_collect (ARM_PS_REGNUM,
+- (char *) &inferior_registers.r_cpsr);
++ regcache->raw_collect (ARM_PC_REGNUM, (char *) ®s.r_pc);
++ regcache->raw_collect (ARM_PS_REGNUM, (char *) ®s.r_cpsr);
+ }
+ else
+ {
+@@ -313,11 +372,10 @@ store_regs (const struct regcache *regca
+ pc_val = gdbarch_addr_bits_remove (gdbarch, pc_val);
+ psr_val ^= gdbarch_addr_bits_remove (gdbarch, psr_val);
+
+- inferior_registers.r_pc = pc_val | psr_val;
++ regs.r_pc = pc_val | psr_val;
+ }
+
+- ret = ptrace (PT_SETREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &inferior_registers, 0);
++ ret = ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp);
+
+ if (ret < 0)
+ warning (_("unable to store general registers"));
+@@ -326,11 +384,13 @@ store_regs (const struct regcache *regca
+ static void
+ store_fp_register (const struct regcache *regcache, int regno)
+ {
+- struct fpreg inferior_fp_registers;
++ struct fpreg fpregs;
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+ int ret;
+
+- ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
++ ret = ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp);
+
+ if (ret < 0)
+ {
+@@ -341,18 +401,15 @@ store_fp_register (const struct regcache
+ switch (regno)
+ {
+ case ARM_FPS_REGNUM:
+- regcache->raw_collect (ARM_FPS_REGNUM,
+- (char *) &inferior_fp_registers.fpr_fpsr);
++ regcache->raw_collect (ARM_FPS_REGNUM, FPSCR(&fpregs));
+ break;
+
+ default:
+- regcache->raw_collect
+- (regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]);
++ regcache->raw_collect (regno, FPREG(&fpregs, regno));
+ break;
+ }
+
+- ret = ptrace (PT_SETFPREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
++ ret = ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp);
+
+ if (ret < 0)
+ warning (_("unable to write register %d to inferior"), regno);
+@@ -361,20 +418,20 @@ store_fp_register (const struct regcache
+ static void
+ store_fp_regs (const struct regcache *regcache)
+ {
+- struct fpreg inferior_fp_registers;
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
++ struct fpreg fpregs;
+ int ret;
+ int regno;
+
+
+- for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++)
+- regcache->raw_collect
+- (regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]);
++ for (regno = ARM_D0_REGNUM; regno < 16 + ARM_D0_REGNUM; regno++)
++ regcache->raw_collect (regno, FPREG(&fpregs, regno));
+
+- regcache->raw_collect (ARM_FPS_REGNUM,
+- (char *) &inferior_fp_registers.fpr_fpsr);
++ regcache->raw_collect (ARM_FPSCR_REGNUM, FPSCR(&fpregs));
+
+- ret = ptrace (PT_SETFPREGS, regcache->ptid ().pid (),
+- (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
++ ret = ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp);
+
+ if (ret < 0)
+ warning (_("unable to store floating-point registers"));
+@@ -385,10 +442,10 @@ arm_nbsd_nat_target::store_registers (st
+ {
+ if (regno >= 0)
+ {
+- if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM)
+- store_register (regcache, regno);
+- else
++ if (regno >= ARM_D0_REGNUM && regno <= ARM_FPSCR_REGNUM)
+ store_fp_register (regcache, regno);
++ else
++ store_register (regcache, regno);
+ }
+ else
+ {
+@@ -397,13 +454,32 @@ arm_nbsd_nat_target::store_registers (st
+ }
+ }
+
++struct md_core
++{
++ struct reg intreg;
++ struct fpreg freg;
++};
++
++static void
++fetch_core_registers (struct regcache *regcache,
++ char *core_reg_sect, unsigned core_reg_size,
++ int which, CORE_ADDR ignore)
++{
++ struct md_core *core_reg = (struct md_core *) core_reg_sect;
++ int regno;
++ CORE_ADDR r_pc;
++
++ arm_supply_gregset (regcache, &core_reg->intreg);
++ arm_supply_vfpregset (regcache, &core_reg->freg);
++}
++
+ static void
+ fetch_elfcore_registers (struct regcache *regcache,
+ char *core_reg_sect, unsigned core_reg_size,
+ int which, CORE_ADDR ignore)
+ {
+ struct reg gregset;
+- struct fpreg fparegset;
++ struct fpreg vfpregset;
+
+ switch (which)
+ {
+@@ -426,8 +502,8 @@ fetch_elfcore_registers (struct regcache
+ {
+ /* The memcpy may be unnecessary, but we can't really be sure
+ of the alignment of the data in the core file. */
+- memcpy (&fparegset, core_reg_sect, sizeof (fparegset));
+- arm_supply_fparegset (regcache, &fparegset);
++ memcpy (&vfpregset, core_reg_sect, sizeof (vfpregset));
++ arm_supply_vfpregset (regcache, &vfpregset);
+ }
+ break;
+
+@@ -437,9 +513,18 @@ fetch_elfcore_registers (struct regcache
+ }
+ }
+
++static struct core_fns arm_netbsd_core_fns =
++{
++ bfd_target_unknown_flavour, /* core_flavour. */
++ default_check_format, /* check_format. */
++ default_core_sniffer, /* core_sniffer. */
++ fetch_core_registers, /* core_read_registers. */
++ NULL
++};
++
+ static struct core_fns arm_netbsd_elfcore_fns =
+ {
+- bfd_target_elf_flavour, /* core_flovour. */
++ bfd_target_elf_flavour, /* core_flavour. */
+ default_check_format, /* check_format. */
+ default_core_sniffer, /* core_sniffer. */
+ fetch_elfcore_registers, /* core_read_registers. */
+@@ -449,7 +534,8 @@ static struct core_fns arm_netbsd_elfcor
+ void
+ _initialize_arm_netbsd_nat (void)
+ {
+- add_inf_child_target (&the_arm_netbsd_nat_target);
++ add_inf_child_target (&the_arm_nbsd_nat_target);
+
++ deprecated_add_core_fns (&arm_netbsd_core_fns);
+ deprecated_add_core_fns (&arm_netbsd_elfcore_fns);
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_arm-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_arm-nbsd-tdep.c
new file mode 100644
index 0000000000..6a60cb73e9
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_arm-nbsd-tdep.c
@@ -0,0 +1,56 @@
+$NetBSD$
+
+--- gdb/arm-nbsd-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/arm-nbsd-tdep.c
+@@ -22,6 +22,7 @@
+
+ #include "arch/arm.h"
+ #include "arm-tdep.h"
++#include "nbsd-tdep.h"
+ #include "solib-svr4.h"
+
+ /* Description of the longjmp buffer. */
+@@ -42,7 +43,7 @@ arm_netbsd_init_abi_common (struct gdbar
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ tdep->lowest_pc = 0x8000;
+- switch (info.byte_order)
++ switch (info.byte_order_for_code)
+ {
+ case BFD_ENDIAN_LITTLE:
+ tdep->arm_breakpoint = arm_nbsd_arm_le_breakpoint;
+@@ -68,8 +69,23 @@ arm_netbsd_init_abi_common (struct gdbar
+
+ /* Single stepping. */
+ set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
++ /* Core support */
++ set_gdbarch_iterate_over_regset_sections
++ (gdbarch, armbsd_iterate_over_regset_sections);
++
+ }
+-
++
++static void
++arm_netbsd_aout_init_abi (struct gdbarch_info info,
++ struct gdbarch *gdbarch)
++{
++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
++
++ arm_netbsd_init_abi_common (info, gdbarch);
++ if (tdep->fp_model == ARM_FLOAT_AUTO)
++ tdep->fp_model = ARM_FLOAT_SOFT_FPA;
++}
++
+ static void
+ arm_netbsd_elf_init_abi (struct gdbarch_info info,
+ struct gdbarch *gdbarch)
+@@ -83,6 +99,9 @@ arm_netbsd_elf_init_abi (struct gdbarch_
+ /* NetBSD ELF uses SVR4-style shared libraries. */
+ set_solib_svr4_fetch_link_map_offsets
+ (gdbarch, svr4_ilp32_fetch_link_map_offsets);
++
++ /* for single stepping; see PR/50773 */
++ set_gdbarch_skip_solib_resolver (gdbarch, nbsd_skip_solib_resolver);
+ }
+
+ void
diff --git a/gdb-netbsd/patches/patch-gdb_auxv.c b/gdb-netbsd/patches/patch-gdb_auxv.c
new file mode 100644
index 0000000000..c2757b8509
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_auxv.c
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- gdb/auxv.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/auxv.c
+@@ -266,8 +266,12 @@ default_auxv_parse (struct target_ops *o
+
+ if (endptr - ptr < sizeof_auxv_field * 2)
+ return -1;
+-
+- *typep = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
++#ifdef __NetBSD__
++ const int sizeof_auxv_type = 4;
++#else
++ const int sizeof_auxv_type = sizeof_auxv_field;
++#endif
++ *typep = extract_unsigned_integer (ptr, sizeof_auxv_type, byte_order);
+ ptr += sizeof_auxv_field;
+ *valp = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
+ ptr += sizeof_auxv_field;
diff --git a/gdb-netbsd/patches/patch-gdb_bsd-kvm.c b/gdb-netbsd/patches/patch-gdb_bsd-kvm.c
new file mode 100644
index 0000000000..55f22ca045
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_bsd-kvm.c
@@ -0,0 +1,61 @@
+$NetBSD$
+
+--- gdb/bsd-kvm.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/bsd-kvm.c
+@@ -29,6 +29,7 @@
+ #include "gdbcore.h"
+ #include "inferior.h" /* for get_exec_file */
+ #include "gdbthread.h"
++#include "arch-utils.h"
+
+ #include <fcntl.h>
+ #include <kvm.h>
+@@ -108,6 +109,7 @@ bsd_kvm_target_open (const char *arg, in
+ char errbuf[_POSIX2_LINE_MAX];
+ char *execfile = NULL;
+ kvm_t *temp_kd;
++ struct inferior *inf;
+ char *filename = NULL;
+
+ target_preopen (from_tty);
+@@ -136,6 +138,12 @@ bsd_kvm_target_open (const char *arg, in
+ core_kd = temp_kd;
+ push_target (&bsd_kvm_ops);
+
++ inf = add_inferior_silent (bsd_kvm_ptid.pid ());
++ inf->aspace = maybe_new_address_space ();
++ inf->pspace = new program_space (inf->aspace);
++
++ inf->gdbarch = get_current_arch ();
++
+ add_thread_silent (bsd_kvm_ptid);
+ inferior_ptid = bsd_kvm_ptid;
+
+@@ -273,6 +281,27 @@ bsd_kvm_target::fetch_registers (struct
+ return;
+ }
+
++#if 1 /* TODO: HAVE_STRUCT_LWP_L_ADDR */
++ memset (nl, 0, sizeof nl);
++ nl[0].n_name = "_lwp0";
++
++ if (kvm_nlist (core_kd, nl) == -1)
++ error (("%s"), kvm_geterr (core_kd));
++
++ if (nl[0].n_value != 0)
++ {
++ struct pcb *paddr;
++
++ /* Found lwp0. */
++ nl[0].n_value += offsetof (struct lwp, l_addr);
++ if (kvm_read (core_kd, nl[0].n_value, &paddr, sizeof paddr) == -1)
++ error (("%s"), kvm_geterr (core_kd));
++
++ bsd_kvm_fetch_pcb (regcache, paddr);
++ return;
++ }
++#endif
++
+ #ifdef HAVE_STRUCT_THREAD_TD_PCB
+ /* In FreeBSD kernels for 5.0-RELEASE and later, the PCB no longer
+ lives in `struct proc' but in `struct thread'. The `struct
diff --git a/gdb-netbsd/patches/patch-gdb_config_aarch64_nbsd.mh b/gdb-netbsd/patches/patch-gdb_config_aarch64_nbsd.mh
new file mode 100644
index 0000000000..fdfc4dedf1
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_config_aarch64_nbsd.mh
@@ -0,0 +1,10 @@
+$NetBSD$
+
+--- gdb/config/aarch64/nbsd.mh.orig 2019-09-02 20:02:23.496700950 +0000
++++ gdb/config/aarch64/nbsd.mh
+@@ -0,0 +1,5 @@
++# Host: NetBSD/arm64
++NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o aarch64-nbsd-nat.o \
++ bsd-kvm.o
++
++LOADLIBES= -lkvm
diff --git a/gdb-netbsd/patches/patch-gdb_config_ia64_netbsd.mh b/gdb-netbsd/patches/patch-gdb_config_ia64_netbsd.mh
new file mode 100644
index 0000000000..b938e25af4
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_config_ia64_netbsd.mh
@@ -0,0 +1,10 @@
+$NetBSD$
+
+--- gdb/config/ia64/netbsd.mh.orig 2019-09-02 20:02:23.496835039 +0000
++++ gdb/config/ia64/netbsd.mh
+@@ -0,0 +1,5 @@
++# Host: NetBSD/ia64 ELF
++NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o ia64-bsd-nat.o bsd-kvm.o \
++ ia64-nbsd-tdep.o
++
++LOADLIBES= -lkvm
diff --git a/gdb-netbsd/patches/patch-gdb_config_powerpc_ppc64-nbsd.mh b/gdb-netbsd/patches/patch-gdb_config_powerpc_ppc64-nbsd.mh
new file mode 100644
index 0000000000..7ef6d88a89
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_config_powerpc_ppc64-nbsd.mh
@@ -0,0 +1,9 @@
+$NetBSD$
+
+--- gdb/config/powerpc/ppc64-nbsd.mh.orig 2019-09-02 20:02:23.496966514 +0000
++++ gdb/config/powerpc/ppc64-nbsd.mh
+@@ -0,0 +1,4 @@
++# Host: NetBSD/powerpc64
++NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o ppc-nbsd-nat.o bsd-kvm.o
++
++LOADLIBES= -lkvm
diff --git a/gdb-netbsd/patches/patch-gdb_configure b/gdb-netbsd/patches/patch-gdb_configure
new file mode 100644
index 0000000000..6d56e67e2a
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_configure
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- gdb/configure.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/configure
+@@ -13532,6 +13532,9 @@ if ${am_cv_langinfo_codeset+:} false; th
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
++#include <sys/param.h>
++#define _KMEMUSER
++#include <sys/lwp.h>
+ #include <langinfo.h>
+ int
+ main ()
+@@ -13998,6 +14001,7 @@ if ${gdb_cv_struct_lwp+:} false; then :
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
++#define _KMEMUSER
+ #include <sys/param.h>
+ #define _KMEMUSER
+ #include <sys/lwp.h>
diff --git a/gdb-netbsd/patches/patch-gdb_configure.host b/gdb-netbsd/patches/patch-gdb_configure.host
new file mode 100644
index 0000000000..9f7c50a62f
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_configure.host
@@ -0,0 +1,30 @@
+$NetBSD$
+
+--- gdb/configure.host.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/configure.host
+@@ -84,6 +84,7 @@ case "${host}" in
+ *-*-darwin*) gdb_host=darwin ;;
+
+ aarch64*-*-linux*) gdb_host=linux ;;
++aarch64*-*-netbsd*) gdb_host=nbsd ;;
+ aarch64*-*-freebsd*) gdb_host=fbsd ;;
+
+ alpha*-*-linux*) gdb_host=alpha-linux ;;
+@@ -121,7 +122,7 @@ i[34567]86-*-cygwin*) gdb_host=cygwin ;;
+ ia64-*-linux*) gdb_host=linux ;;
+
+ m68*-*-linux*) gdb_host=linux ;;
+-m68*-*-netbsdelf* | m68*-*-knetbsd*-gnu)
++m68*-*-netbsdelf* | m68*-*-knetbsd*-gnu | m5407-*-netbsdelf*)
+ gdb_host=nbsdelf ;;
+ m68*-*-openbsd*) gdb_host=obsd ;;
+
+@@ -138,6 +139,8 @@ powerpc-*-aix* | rs6000-*-* | powerpc64-
+ powerpc*-*-freebsd*) gdb_host=fbsd ;;
+ powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
+ gdb_host=nbsd ;;
++powerpc64-*-netbsd* | powerpc64-*-knetbsd*-gnu)
++ gdb_host=ppc64-nbsd ;;
+ powerpc-*-openbsd*) gdb_host=obsd ;;
+
+ powerpc64*-*-linux*) gdb_host=ppc64-linux
diff --git a/gdb-netbsd/patches/patch-gdb_configure.nat b/gdb-netbsd/patches/patch-gdb_configure.nat
new file mode 100644
index 0000000000..599f31082b
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_configure.nat
@@ -0,0 +1,100 @@
+$NetBSD$
+
+--- gdb/configure.nat.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/configure.nat
+@@ -329,11 +329,16 @@ case ${gdb_host} in
+ esac
+ ;;
+ nbsd)
++ NATDEPFILES="${NATDEPFILES} nbsd-nat.o bsd-kvm.o"
++ LOADLIBES='-lkvm'
+ case ${gdb_host_cpu} in
++ aarch64)
++ # Host: NetBSD/aarch64
++ NATDEPFILES="${NATDEPFILES} aarch64-nbsd-nat.o"
++ ;;
+ alpha)
+ # Host: NetBSD/alpha
+- NATDEPFILES="${NATDEPFILES} alpha-bsd-nat.o bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} alpha-bsd-nat.o"
+ ;;
+ mips)
+ # Host: NetBSD/mips
+@@ -341,12 +346,11 @@ case ${gdb_host} in
+ ;;
+ pa)
+ # Host: NetBSD/hppa
+- NATDEPFILES="${NATDEPFILES} nbsd-nat.o hppa-nbsd-nat.o"
++ NATDEPFILES="${NATDEPFILES} hppa-nbsd-nat.o"
+ ;;
+ powerpc)
+ # Host: NetBSD/powerpc
+- NATDEPFILES="${NATDEPFILES} ppc-nbsd-nat.o bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} ppc-nbsd-nat.o"
+ ;;
+ sh)
+ # Host: NetBSD/sh
+@@ -356,22 +360,24 @@ case ${gdb_host} in
+ esac
+ ;;
+ nbsd64)
++ NATDEPFILES="${NATDEPFILES} nbsd-nat.o bsd-kvm.o"
++ LOADLIBES='-lkvm'
+ case ${gdb_host_cpu} in
+ i386)
+ # Host: NetBSD/amd64
+- NATDEPFILES="${NATDEPFILES} nbsd-nat.o amd64-nat.o x86-nat.o \
+- nat/x86-dregs.o x86-bsd-nat.o amd64-bsd-nat.o amd64-nbsd-nat.o"
++ NATDEPFILES="${NATDEPFILES} amd64-nbsd-nat.o amd64-bsd-nat.o \
++ amd64-nat.o x86-bsd-nat.o x86-nat.o nat/x86-dregs.o"
+ ;;
+ sparc)
+ # Host: NetBSD/sparc64
+- NATDEPFILES="${NATDEPFILES} sparc64-nbsd-nat.o sparc-nat.o \
+- bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} sparc64-nbsd-nat.o sparc-nat.o"
+ ;;
+
+ esac
+ ;;
+ nbsdelf)
++ NATDEPFILES="${NATDEPFILES} nbsd-nat.o bsd-kvm.o"
++ LOADLIBES='-lkvm'
+ case ${gdb_host_cpu} in
+ arm)
+ # Host: NetBSD/arm
+@@ -379,26 +385,20 @@ case ${gdb_host} in
+ ;;
+ i386)
+ # Host: NetBSD/i386 ELF
+- NATDEPFILES="${NATDEPFILES} nbsd-nat.o x86-nat.o \
+- nat/x86-dregs.o \
+- x86-bsd-nat.o i386-bsd-nat.o i386-nbsd-nat.o bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} i386-nbsd-nat.o i386-bsd-nat.o \
++ x86-bsd-nat.o x86-nat.o nat/x86-dregs.o"
+ ;;
+ m68k)
+ # Host: NetBSD/m68k ELF
+- NATDEPFILES="${NATDEPFILES} m68k-bsd-nat.o bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} m68k-bsd-nat.o"
+ ;;
+ sparc)
+ # Host: NetBSD/sparc ELF
+- NATDEPFILES="${NATDEPFILES} sparc-nat.o sparc-nbsd-nat.o \
+- bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} sparc-nat.o sparc-nbsd-nat.o"
+ ;;
+ vax)
+ # Host: NetBSD/vax ELF
+- NATDEPFILES="${NATDEPFILES} vax-bsd-nat.o bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} vax-bsd-nat.o"
+ ;;
+
+ esac
diff --git a/gdb-netbsd/patches/patch-gdb_configure.tgt b/gdb-netbsd/patches/patch-gdb_configure.tgt
index c32ad9a56c..b4d0e35b70 100644
--- a/gdb-netbsd/patches/patch-gdb_configure.tgt
+++ b/gdb-netbsd/patches/patch-gdb_configure.tgt
@@ -2,7 +2,74 @@ $NetBSD$
--- gdb/configure.tgt.orig 2019-07-16 00:00:27.000000000 +0000
+++ gdb/configure.tgt
-@@ -762,6 +762,7 @@ x86_64-*-mingw* | x86_64-*-cygwin*)
+@@ -128,6 +128,16 @@ aarch64*-*-linux*)
+ build_gdbserver=yes
+ ;;
+
++aarch64*-*-netbsd*)
++ # Target: AArch64 NetBSD
++ gdb_target_obs="aarch64-tdep.o aarch64-nbsd-tdep.o \
++ arch/aarch64-insn.o"
++ ;;
++
++alpha*-*-osf*)
++ # Target: Little-endian Alpha running OSF/1
++ gdb_target_obs="alpha-tdep.o alpha-osf1-tdep.o alpha-mdebug-tdep.o"
++ ;;
+ alpha*-*-linux*)
+ # Target: Little-endian Alpha running Linux
+ gdb_target_obs="alpha-mdebug-tdep.o alpha-linux-tdep.o \
+@@ -172,7 +182,7 @@ arm*-*-freebsd*)
+ ;;
+ arm*-*-netbsd* | arm*-*-knetbsd*-gnu)
+ # Target: NetBSD/arm
+- gdb_target_obs="arm-nbsd-tdep.o"
++ gdb_target_obs="arm-bsd-tdep.o arm-nbsd-tdep.o"
+ ;;
+ arm*-*-openbsd*)
+ # Target: OpenBSD/arm
+@@ -246,11 +256,11 @@ hppa*-*-linux*)
+ ;;
+ hppa*-*-netbsd*)
+ # Target: NetBSD/hppa
+- gdb_target_obs="hppa-bsd-tdep.o hppa-nbsd-tdep.o solib-svr4.o"
++ gdb_target_obs="hppa-bsd-tdep.o hppa-nbsd-tdep.o"
+ ;;
+ hppa*-*-openbsd*)
+ # Target: OpenBSD/hppa
+- gdb_target_obs="hppa-bsd-tdep.o hppa-obsd-tdep.o solib-svr4.o"
++ gdb_target_obs="hppa-bsd-tdep.o hppa-obsd-tdep.o"
+ ;;
+
+ i[34567]86-*-darwin*)
+@@ -380,7 +390,7 @@ m68*-*-linux*)
+ linux-tdep.o glibc-tdep.o symfile-mem.o"
+ build_gdbserver=yes
+ ;;
+-m68*-*-netbsd* | m68*-*-knetbsd*-gnu)
++m68*-*-netbsd* | m68*-*-knetbsd*-gnu | m5407-*-netbsdelf*)
+ # Target: NetBSD/m68k
+ gdb_target_obs="m68k-tdep.o m68k-bsd-tdep.o"
+ ;;
+@@ -492,7 +502,7 @@ powerpc*-*-freebsd*)
+ ravenscar-thread.o ppc-ravenscar-thread.o"
+ ;;
+
+-powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
++powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu | powerpc64-*-netbsd*)
+ # Target: NetBSD/powerpc
+ gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc-nbsd-tdep.o \
+ ravenscar-thread.o ppc-ravenscar-thread.o"
+@@ -714,7 +724,7 @@ v850*-*-elf | v850*-*-rtems*)
+
+ vax-*-netbsd* | vax-*-knetbsd*-gnu)
+ # Target: NetBSD/vax
+- gdb_target_obs="vax-tdep.o solib-svr4.o"
++ gdb_target_obs="vax-tdep.o"
+ ;;
+ vax-*-openbsd*)
+ # Target: OpenBSD/vax
+@@ -762,6 +772,7 @@ x86_64-*-mingw* | x86_64-*-cygwin*)
x86_64-*-netbsd* | x86_64-*-knetbsd*-gnu)
# Target: NetBSD/amd64
gdb_target_obs="amd64-nbsd-tdep.o ${i386_tobjs}"
diff --git a/gdb-netbsd/patches/patch-gdb_contrib_ari_gdb__ari.sh b/gdb-netbsd/patches/patch-gdb_contrib_ari_gdb__ari.sh
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-gdb_contrib_expect-read1.sh b/gdb-netbsd/patches/patch-gdb_contrib_expect-read1.sh
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-gdb_doc_stabs.texinfo b/gdb-netbsd/patches/patch-gdb_doc_stabs.texinfo
new file mode 100644
index 0000000000..bf87235536
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_doc_stabs.texinfo
@@ -0,0 +1,5 @@
+Cannot strip away RCS IDs, please handle manually!
+These are the matching lines:
+ -\xdef\manvers{\$Revision$} % For use in headers, footers too
+Setting PKGDIFF_FMT might help.
+Otherwise you may need to run diff by hand.
diff --git a/gdb-netbsd/patches/patch-gdb_features_feature__to__c.sh b/gdb-netbsd/patches/patch-gdb_features_feature__to__c.sh
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-low.c b/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-low.c
index 7ed507416a..df5ad2f4ca 100644
--- a/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-low.c
+++ b/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-low.c
@@ -1,6 +1,6 @@
$NetBSD$
---- gdb/gdbserver/netbsd-low.c.orig 2019-08-12 16:19:29.741607490 +0000
+--- gdb/gdbserver/netbsd-low.c.orig 2019-09-02 20:02:23.503085722 +0000
+++ gdb/gdbserver/netbsd-low.c
@@ -0,0 +1,2084 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
diff --git a/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-low.h b/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-low.h
index 4e3a830552..a325013c0b 100644
--- a/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-low.h
+++ b/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-low.h
@@ -1,6 +1,6 @@
$NetBSD$
---- gdb/gdbserver/netbsd-low.h.orig 2019-08-12 16:19:29.741747438 +0000
+--- gdb/gdbserver/netbsd-low.h.orig 2019-09-02 20:02:23.503235772 +0000
+++ gdb/gdbserver/netbsd-low.h
@@ -0,0 +1,61 @@
+/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
diff --git a/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-x86__64-low.c b/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-x86__64-low.c
index 59b081cf89..55fc14c1f5 100644
--- a/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-x86__64-low.c
+++ b/gdb-netbsd/patches/patch-gdb_gdbserver_netbsd-x86__64-low.c
@@ -1,6 +1,6 @@
$NetBSD$
---- gdb/gdbserver/netbsd-x86_64-low.c.orig 2019-08-12 16:19:29.741931595 +0000
+--- gdb/gdbserver/netbsd-x86_64-low.c.orig 2019-09-02 20:02:23.503455942 +0000
+++ gdb/gdbserver/netbsd-x86_64-low.c
@@ -0,0 +1,383 @@
+/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
diff --git a/gdb-netbsd/patches/patch-gdb_gdbsupport_agent.c b/gdb-netbsd/patches/patch-gdb_gdbsupport_agent.c
new file mode 100644
index 0000000000..6b405a5c66
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_gdbsupport_agent.c
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- gdb/gdbsupport/agent.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/gdbsupport/agent.c
+@@ -155,6 +155,7 @@ gdb_connect_sync_socket (int pid)
+ return -1;
+ }
+
++ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+
+ res = xsnprintf (addr.sun_path, UNIX_PATH_MAX, "%s", path);
diff --git a/gdb-netbsd/patches/patch-gdb_gdbsupport_common-defs.h b/gdb-netbsd/patches/patch-gdb_gdbsupport_common-defs.h
new file mode 100644
index 0000000000..5ac7452fc5
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_gdbsupport_common-defs.h
@@ -0,0 +1,23 @@
+$NetBSD$
+
+--- gdb/gdbsupport/common-defs.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/gdbsupport/common-defs.h
+@@ -96,9 +96,9 @@
+ #include <strings.h> /* for strcasecmp and strncasecmp */
+ #endif
+ #include <errno.h>
+-#include <alloca.h>
+
+ #include "ansidecl.h"
++#ifndef __NetBSD__
+ /* 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
+@@ -106,6 +106,7 @@
+ is compatible with ATTRIBUTE_PRINTF, simply use it. */
+ #undef ATTRIBUTE_PRINTF
+ #define ATTRIBUTE_PRINTF _GL_ATTRIBUTE_FORMAT_PRINTF
++#endif
+
+ #if GCC_VERSION >= 3004
+ #define ATTRIBUTE_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
diff --git a/gdb-netbsd/patches/patch-gdb_gdbsupport_pathstuff.h b/gdb-netbsd/patches/patch-gdb_gdbsupport_pathstuff.h
new file mode 100644
index 0000000000..42515c202b
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_gdbsupport_pathstuff.h
@@ -0,0 +1,11 @@
+$NetBSD$
+
+--- gdb/gdbsupport/pathstuff.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/gdbsupport/pathstuff.h
+@@ -92,4 +92,6 @@ extern const char *get_shell ();
+
+ extern gdb::char_vector make_temp_filename (const std::string &f);
+
++extern "C" char *canonicalize_file_name (const char *path);
++
+ #endif /* COMMON_PATHSTUFF_H */
diff --git a/gdb-netbsd/patches/patch-gdb_hppa-nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_hppa-nbsd-nat.c
new file mode 100644
index 0000000000..a744537642
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_hppa-nbsd-nat.c
@@ -0,0 +1,112 @@
+$NetBSD$
+
+--- gdb/hppa-nbsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/hppa-nbsd-nat.c
+@@ -58,8 +58,7 @@ hppanbsd_fpregset_supplies_p (int regnum
+ static void
+ hppanbsd_supply_gregset (struct regcache *regcache, const void *gregs)
+ {
+- const char *regs = gregs;
+- const int *r = gregs;
++ const char *regs = (const char *) gregs;
+ int regnum;
+
+ for (regnum = HPPA_R1_REGNUM; regnum <= HPPA_R31_REGNUM; regnum++)
+@@ -83,7 +82,7 @@ hppanbsd_supply_gregset (struct regcache
+ static void
+ hppanbsd_supply_fpregset (struct regcache *regcache, const void *fpregs)
+ {
+- const char *regs = fpregs;
++ const char *regs = (const char *) fpregs;
+ int regnum;
+
+ for (regnum = HPPA_FP0_REGNUM; regnum <= HPPA_FP31R_REGNUM;
+@@ -101,8 +100,7 @@ static void
+ hppanbsd_collect_gregset (const struct regcache *regcache,
+ void *gregs, int regnum)
+ {
+- char *regs = gregs;
+- int *r = gregs;
++ char *regs = (char *) gregs;
+ int i;
+
+ for (i = HPPA_R1_REGNUM; i <= HPPA_R31_REGNUM; i++)
+@@ -146,10 +144,10 @@ hppanbsd_collect_gregset (const struct r
+ in FPREGS. */
+
+ static void
+-hppanbsd_collect_fpregset (struct regcache *regcache,
++hppanbsd_collect_fpregset (const struct regcache *regcache,
+ void *fpregs, int regnum)
+ {
+- char *regs = fpregs;
++ char *regs = (char *) fpregs;
+ int i;
+
+ for (i = HPPA_FP0_REGNUM; i <= HPPA_FP31R_REGNUM; i += 2, regs += 8)
+@@ -170,13 +168,15 @@ void
+ hppa_nbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
+
+ {
+- pid_t pid = regcache->ptid ().pid ();
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+ if (regnum == -1 || hppanbsd_gregset_supplies_p (regnum))
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ hppanbsd_supply_gregset (regcache, ®s);
+@@ -186,7 +186,7 @@ hppa_nbsd_nat_target::fetch_registers (s
+ {
+ struct fpreg fpregs;
+
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ hppanbsd_supply_fpregset (regcache, &fpregs);
+@@ -199,18 +199,20 @@ hppa_nbsd_nat_target::fetch_registers (s
+ void
+ hppa_nbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
+ {
+- pid_t pid = regcache->ptid ().pid ();
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+ if (regnum == -1 || hppanbsd_gregset_supplies_p (regnum))
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ hppanbsd_collect_gregset (regcache, ®s, regnum);
+
+- if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't write registers"));
+ }
+
+@@ -218,12 +220,12 @@ hppa_nbsd_nat_target::store_registers (s
+ {
+ struct fpreg fpregs;
+
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ hppanbsd_collect_fpregset (regcache, &fpregs, regnum);
+
+- if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't write floating point status"));
+ }
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_hppa-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_hppa-nbsd-tdep.c
new file mode 100644
index 0000000000..3ca179efbf
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_hppa-nbsd-tdep.c
@@ -0,0 +1,69 @@
+$NetBSD$
+
+--- gdb/hppa-nbsd-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/hppa-nbsd-tdep.c
+@@ -25,8 +25,8 @@
+ #include "trad-frame.h"
+ #include "tramp-frame.h"
+
+-#include "hppa-tdep.h"
+ #include "hppa-bsd-tdep.h"
++#include "hppa-tdep.h"
+ #include "gdbarch.h"
+
+ /* From <machine/mcontext.h>. */
+@@ -58,6 +58,19 @@ static int hppanbsd_mc_reg_offset[] =
+ 38 * 4, /* sr1 */
+ 39 * 4, /* sr2 */
+ 40 * 4, /* sr3 */
++ -1, /* 48 */
++ -1, /* 49 */
++ -1, /* 50 */
++ -1, /* 51 */
++ -1, /* 52 */
++ -1, /* 53 */
++ -1, /* 54 */
++ -1, /* 55 */
++ -1, /* 56 */
++ -1, /* 57 CR24 */
++ -1, /* 58 CR25 */
++ -1, /* 59 CR26 */
++ 43 * 4, /* HPPA_CR27_REGNUM */
+
+ /* more tbd */
+ };
+@@ -129,7 +142,7 @@ hppanbsd_sigtramp_cache_init (const stru
+ /* Core file support. */
+
+ /* Sizeof `struct reg' in <machine/reg.h>. */
+-#define HPPANBSD_SIZEOF_GREGS (44 * 4)
++#define HPPANBSD_SIZEOF_GREGS (47 * 4)
+
+ static int hppanbsd_reg_offset[] =
+ {
+@@ -153,6 +166,25 @@ static int hppanbsd_reg_offset[] =
+ -1, /* HPPA_ISR_REGNUM */
+ -1, /* HPPA_IOR_REGNUM */
+ 0 * 4, /* HPPA_IPSW_REGNUM */
++ -1, /* spare? */
++ 41 * 4, /* HPPA_SR4_REGNUM */
++ 37 * 4, /* sr0 */
++ 38 * 4, /* sr1 */
++ 39 * 4, /* sr2 */
++ 40 * 4, /* sr3 */
++ -1, /* 48 */
++ -1, /* 49 */
++ -1, /* 50 */
++ -1, /* 51 */
++ -1, /* 52 */
++ -1, /* 53 */
++ -1, /* 54 */
++ -1, /* 55 */
++ -1, /* 56 */
++ -1, /* 57 */
++ -1, /* 58 */
++ -1, /* 59 */
++ 46 * 4, /* HPPA_CR27_REGNUM */
+ };
+
+ /* Supply register REGNUM from the buffer specified by GREGS and LEN
diff --git a/gdb-netbsd/patches/patch-gdb_hppa-tdep.c b/gdb-netbsd/patches/patch-gdb_hppa-tdep.c
new file mode 100644
index 0000000000..7586c4df3a
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_hppa-tdep.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- gdb/hppa-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/hppa-tdep.c
+@@ -624,7 +624,7 @@ hppa32_register_name (struct gdbarch *gd
+ "sr5", "sr6", "sr7", "cr0",
+ "cr8", "cr9", "ccr", "cr12",
+ "cr13", "cr24", "cr25", "cr26",
+- "mpsfu_high","mpsfu_low","mpsfu_ovflo","pad",
++ "cr27", "cr28", "cr29", "cr30",
+ "fpsr", "fpe1", "fpe2", "fpe3",
+ "fpe4", "fpe5", "fpe6", "fpe7",
+ "fr4", "fr4R", "fr5", "fr5R",
diff --git a/gdb-netbsd/patches/patch-gdb_hppa-tdep.h b/gdb-netbsd/patches/patch-gdb_hppa-tdep.h
new file mode 100644
index 0000000000..fd68417d82
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_hppa-tdep.h
@@ -0,0 +1,11 @@
+$NetBSD$
+
+--- gdb/hppa-tdep.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/hppa-tdep.h
+@@ -215,4 +215,6 @@ extern int hppa_in_solib_call_trampoline
+ CORE_ADDR pc);
+ extern CORE_ADDR hppa_skip_trampoline_code (struct frame_info *, CORE_ADDR pc);
+
++void _initialize_hppabsd_tdep (void);
++
+ #endif /* hppa-tdep.h */
diff --git a/gdb-netbsd/patches/patch-gdb_i386-bsd-nat.c b/gdb-netbsd/patches/patch-gdb_i386-bsd-nat.c
new file mode 100644
index 0000000000..da5169e35d
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_i386-bsd-nat.c
@@ -0,0 +1,110 @@
+$NetBSD$
+
+--- gdb/i386-bsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/i386-bsd-nat.c
+@@ -131,12 +131,13 @@ void
+ i386bsd_fetch_inferior_registers (struct regcache *regcache, int regnum)
+ {
+ pid_t pid = get_ptrace_pid (regcache->ptid ());
++ int lwp = regcache->ptid ().lwp ();
+
+ if (regnum == -1 || GETREGS_SUPPLIES (regnum))
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ i386bsd_supply_gregset (regcache, ®s);
+@@ -185,7 +186,7 @@ i386bsd_fetch_inferior_registers (struct
+
+ xstateregs = alloca (x86bsd_xsave_len);
+ if (ptrace (PT_GETXSTATE, pid,
+- (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
++ (PTRACE_TYPE_ARG3) xstateregs, lwp) == -1)
+ perror_with_name (_("Couldn't get extended state status"));
+
+ i387_supply_xsave (regcache, -1, xstateregs);
+@@ -195,7 +196,7 @@ i386bsd_fetch_inferior_registers (struct
+
+ #ifdef HAVE_PT_GETXMMREGS
+ if (have_ptrace_xmmregs != 0
+- && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
++ && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, lwp) == 0)
+ {
+ have_ptrace_xmmregs = 1;
+ i387_supply_fxsave (regcache, -1, xmmregs);
+@@ -204,7 +205,7 @@ i386bsd_fetch_inferior_registers (struct
+ {
+ have_ptrace_xmmregs = 0;
+ #endif
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ i387_supply_fsave (regcache, -1, &fpregs);
+@@ -221,17 +222,18 @@ void
+ i386bsd_store_inferior_registers (struct regcache *regcache, int regnum)
+ {
+ pid_t pid = get_ptrace_pid (regcache->ptid ());
++ int lwp = regcache->ptid ().lwp ();
+
+ if (regnum == -1 || GETREGS_SUPPLIES (regnum))
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ i386bsd_collect_gregset (regcache, ®s, regnum);
+
+- if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't write registers"));
+
+ if (regnum != -1)
+@@ -279,10 +281,10 @@ i386bsd_store_inferior_registers (struct
+
+ xstateregs = alloca (x86bsd_xsave_len);
+ if (ptrace (PT_GETXSTATE, pid,
+- (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
++ (PTRACE_TYPE_ARG3) xstateregs, lwp) == -1)
+ perror_with_name (_("Couldn't get extended state status"));
+
+- i387_collect_xsave (regcache, -1, xstateregs, 0);
++ i387_collect_xsave (regcache, -1, xstateregs, lwp);
+
+ if (ptrace (PT_SETXSTATE, pid,
+ (PTRACE_TYPE_ARG3) xstateregs, x86bsd_xsave_len) == -1)
+@@ -293,25 +295,25 @@ i386bsd_store_inferior_registers (struct
+
+ #ifdef HAVE_PT_GETXMMREGS
+ if (have_ptrace_xmmregs != 0
+- && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
++ && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, lwp) == 0)
+ {
+ have_ptrace_xmmregs = 1;
+
+ i387_collect_fxsave (regcache, regnum, xmmregs);
+
+- if (ptrace (PT_SETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == -1)
++ if (ptrace (PT_SETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, lwp) == -1)
+ perror_with_name (_("Couldn't write XMM registers"));
+ }
+ else
+ {
+ have_ptrace_xmmregs = 0;
+ #endif
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ i387_collect_fsave (regcache, regnum, &fpregs);
+
+- if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't write floating point status"));
+ #ifdef HAVE_PT_GETXMMREGS
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_i386-bsd-nat.h b/gdb-netbsd/patches/patch-gdb_i386-bsd-nat.h
new file mode 100644
index 0000000000..f2d85b382e
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_i386-bsd-nat.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- gdb/i386-bsd-nat.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/i386-bsd-nat.h
+@@ -20,6 +20,8 @@
+ #ifndef I386_BSD_NAT_H
+ #define I386_BSD_NAT_H
+
++#include "x86-bsd-nat.h"
++
+ /* Helper functions. See definitions. */
+ extern void i386bsd_fetch_inferior_registers (struct regcache *regcache,
+ int regnum);
diff --git a/gdb-netbsd/patches/patch-gdb_i386-nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_i386-nbsd-nat.c
new file mode 100644
index 0000000000..e2047a0b12
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_i386-nbsd-nat.c
@@ -0,0 +1,51 @@
+$NetBSD$
+
+--- gdb/i386-nbsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/i386-nbsd-nat.c
+@@ -23,11 +23,13 @@
+ #include "target.h"
+
+ #include "i386-tdep.h"
++#include "i387-tdep.h"
+ #include "i386-bsd-nat.h"
+
+ /* Support for debugging kernel virtual memory images. */
+
+ #include <sys/types.h>
++#include <machine/reg.h>
+ #include <machine/frame.h>
+ #include <machine/pcb.h>
+
+@@ -39,21 +41,25 @@ i386nbsd_supply_pcb (struct regcache *re
+ {
+ struct switchframe sf;
+
+- /* The following is true for NetBSD 1.6.2:
++ /* The following is true for NetBSD 1.6.2 and after:
+
+ The pcb contains %esp and %ebp at the point of the context switch
+- in cpu_switch(). At that point we have a stack frame as
+- described by `struct switchframe', which for NetBSD 1.6.2 has the
+- following layout:
++ in cpu_switch()/cpu_switchto(). At that point we have a stack frame as
++ described by `struct switchframe', which for NetBSD (2.0 and later) has
++ the following layout:
+
+- interrupt level
+ %edi
+ %esi
+ %ebx
+- %eip
++ return address
+
+ we reconstruct the register state as it would look when we just
+- returned from cpu_switch(). */
++ returned from cpu_switch()/cpu_switchto().
++
++ For core dumps the pcb is saved by savectx()/dumpsys() and contains the
++ stack pointer and frame pointer. A new dumpsys() fakes a switchframe
++ whereas older code isn't reliable so use an iffy heuristic to detect this
++ and use the frame pointer to recover enough state. */
+
+ /* The stack pointer shouldn't be zero. */
+ if (pcb->pcb_esp == 0)
diff --git a/gdb-netbsd/patches/patch-gdb_i386-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_i386-nbsd-tdep.c
new file mode 100644
index 0000000000..bc79bac8d5
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_i386-nbsd-tdep.c
@@ -0,0 +1,183 @@
+$NetBSD$
+
+--- gdb/i386-nbsd-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/i386-nbsd-tdep.c
+@@ -33,6 +33,11 @@
+ #include "nbsd-tdep.h"
+ #include "solib-svr4.h"
+
++#include "elf-bfd.h" /* for header hack */
++#include "trad-frame.h" /* signal trampoline/kernel frame support */
++#include "frame-unwind.h" /* kernel frame support */
++#include "tramp-frame.h" /* signal trampoline/kernel frame support */
++
+ /* From <machine/reg.h>. */
+ static int i386nbsd_r_reg_offset[] =
+ {
+@@ -369,6 +374,156 @@ i386nbsd_sigtramp_cache_init (const stru
+ }
+
+
++/* From <machine/frame.h>. Note that %esp and %ess are only saved in
++ a trap frame when entering the kernel from user space. */
++static int i386nbsd_tf_reg_offset[] =
++{
++ 10 * 4, /* %eax */
++ 9 * 4, /* %ecx */
++ 8 * 4, /* %edx */
++ 7 * 4, /* %ebx */
++ -1, /* %esp */
++ 6 * 4, /* %ebp */
++ 5 * 4, /* %esi */
++ 4 * 4, /* %edi */
++ 13 * 4, /* %eip */
++ 15 * 4, /* %eflags */
++ 14 * 4, /* %cs */
++ -1, /* %ss */
++ 3 * 4, /* %ds */
++ 2 * 4, /* %es */
++ 1 * 4, /* %fs */
++ 0 * 4 /* %gs */
++};
++
++static struct trad_frame_cache *
++i386nbsd_trapframe_cache(struct frame_info *this_frame, void **this_cache)
++{
++ struct trad_frame_cache *cache;
++ CORE_ADDR func, sp, addr, tmp;
++ ULONGEST cs;
++ const char *name;
++ int i;
++ struct gdbarch *gdbarch = get_frame_arch (this_frame);
++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
++
++ if (*this_cache)
++ return (struct trad_frame_cache *)*this_cache;
++
++ cache = trad_frame_cache_zalloc (this_frame);
++ *this_cache = cache;
++
++ func = get_frame_func (this_frame);
++ sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM);
++
++ find_pc_partial_function (func, &name, NULL, NULL);
++ if (name && (strncmp (name, "Xintr", 5) == 0 ||
++ strncmp (name, "Xhandle", 7) == 0))
++ {
++ /* It's an interrupt frame. */
++ tmp = read_memory_unsigned_integer (sp + 4, 4, byte_order);
++ if (tmp < 15)
++ {
++ /* Reasonable value for 'ppl': already on interrupt stack. */
++ addr = sp + 8;
++ }
++ else
++ {
++ /* Switch to previous stack. */
++ addr = tmp + 4;
++ }
++ }
++ else
++ {
++ /* It's a trap frame. */
++ addr = sp + 4;
++ }
++
++ for (i = 0; i < ARRAY_SIZE (i386nbsd_tf_reg_offset); i++)
++ if (i386nbsd_tf_reg_offset[i] != -1)
++ trad_frame_set_reg_addr (cache, i, addr + i386nbsd_tf_reg_offset[i]);
++
++ /* Read %cs from trap frame. */
++ addr += i386nbsd_tf_reg_offset[I386_CS_REGNUM];
++ cs = read_memory_unsigned_integer (addr, 4, byte_order);
++ if ((cs & I386_SEL_RPL) == I386_SEL_UPL)
++ {
++ /* Trap from user space; terminate backtrace. */
++ trad_frame_set_id (cache, outer_frame_id);
++ }
++ else
++ {
++ /* Construct the frame ID using the function start. */
++ trad_frame_set_id (cache, frame_id_build (sp + 8, func));
++ }
++
++ return cache;
++}
++
++static void
++i386nbsd_trapframe_this_id (struct frame_info *this_frame,
++ void **this_cache, struct frame_id *this_id)
++{
++ struct trad_frame_cache *cache =
++ i386nbsd_trapframe_cache (this_frame, this_cache);
++
++ trad_frame_get_id (cache, this_id);
++}
++
++static struct value *
++i386nbsd_trapframe_prev_register (struct frame_info *this_frame,
++ void **this_cache, int regnum)
++{
++ struct trad_frame_cache *cache =
++ i386nbsd_trapframe_cache (this_frame, this_cache);
++
++ return trad_frame_get_register (cache, this_frame, regnum);
++}
++
++static int
++i386nbsd_trapframe_sniffer (const struct frame_unwind *self,
++ struct frame_info *this_frame,
++ void **this_prologue_cache)
++{
++ ULONGEST cs;
++ const char *name;
++
++ /* Check Current Privilege Level and bail out if we're not executing
++ in kernel space. */
++ cs = get_frame_register_unsigned (this_frame, I386_CS_REGNUM);
++ if ((cs & I386_SEL_RPL) == I386_SEL_UPL)
++ return 0;
++
++
++ find_pc_partial_function (get_frame_pc (this_frame), &name, NULL, NULL);
++ return (name && ((strcmp (name, "alltraps") == 0)
++ || (strcmp (name, "calltrap") == 0)
++ || (strcmp (name, "syscall1") == 0)
++ || (strcmp (name, "Xdoreti") == 0)
++ || (strncmp (name, "Xintr", 5) == 0)
++ || (strncmp (name, "Xhandle", 7) == 0)
++ || (strncmp (name, "Xpreempt", 8) == 0)
++ || (strncmp (name, "Xrecurse", 8) == 0)
++ || (strncmp (name, "Xresume", 7) == 0)
++ || (strncmp (name, "Xsoft", 5) == 0)
++ || (strncmp (name, "Xstray", 6) == 0)
++ || (strncmp (name, "Xsyscall", 8) == 0)
++ || (strncmp (name, "Xtrap", 5) == 0)
++ ));
++}
++
++const struct frame_unwind i386nbsd_trapframe_unwind = {
++ /* FIXME: kettenis/20051219: This really is more like an interrupt
++ frame, but SIGTRAMP_FRAME would print <signal handler called>,
++ which really is not what we want here. */
++ NORMAL_FRAME,
++ default_frame_unwind_stop_reason,
++ i386nbsd_trapframe_this_id,
++ i386nbsd_trapframe_prev_register,
++ NULL,
++ i386nbsd_trapframe_sniffer
++};
++
+ static void
+ i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ {
+@@ -398,6 +553,9 @@ i386nbsd_init_abi (struct gdbarch_info i
+ tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_si2);
+ tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_si31);
+ tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_si4);
++
++ /* Unwind kernel trap frames correctly. */
++ frame_unwind_prepend_unwinder (gdbarch, &i386nbsd_trapframe_unwind);
+ }
+
+ /* NetBSD ELF. */
diff --git a/gdb-netbsd/patches/patch-gdb_ia64-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_ia64-nbsd-tdep.c
new file mode 100644
index 0000000000..0ba4f1f1ed
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_ia64-nbsd-tdep.c
@@ -0,0 +1,51 @@
+$NetBSD$
+
+--- gdb/ia64-nbsd-tdep.c.orig 2019-09-02 20:02:23.506067905 +0000
++++ gdb/ia64-nbsd-tdep.c
+@@ -0,0 +1,46 @@
++/* Target-dependent code for NetBSD/ia64.
++
++ Copyright (C) 2004-2017 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 "defs.h"
++#include "arch-utils.h"
++#include "osabi.h"
++
++#include "ia64-tdep.h"
++#include "solib-svr4.h"
++
++/* NetBSD ELF. */
++
++static void
++ia64nbsd_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
++{
++ /* NetBSD ELF uses SVR4-style shared libraries. */
++ set_solib_svr4_fetch_link_map_offsets
++ (gdbarch, svr4_ilp32_fetch_link_map_offsets);
++}
++
++
++/* Provide a prototype to silence -Wmissing-prototypes. */
++void _initialize_ia64nbsd_tdep (void);
++
++void
++_initialize_ia64nbsd_tdep (void)
++{
++ gdbarch_register_osabi (bfd_arch_ia64, 0, GDB_OSABI_NETBSD,
++ ia64nbsd_elf_init_abi);
++}
diff --git a/gdb-netbsd/patches/patch-gdb_inf-ptrace.c b/gdb-netbsd/patches/patch-gdb_inf-ptrace.c
new file mode 100644
index 0000000000..7460c33c7f
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_inf-ptrace.c
@@ -0,0 +1,68 @@
+$NetBSD$
+
+--- gdb/inf-ptrace.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/inf-ptrace.c
+@@ -322,10 +322,12 @@ get_ptrace_pid (ptid_t ptid)
+ {
+ pid_t pid;
+
++#ifndef __NetBSD__
+ /* If we have an LWPID to work with, use it. Otherwise, we're
+ dealing with a non-threaded program/target. */
+ pid = ptid.lwp ();
+ if (pid == 0)
++#endif
+ pid = ptid.pid ();
+ return pid;
+ }
+@@ -338,7 +340,7 @@ void
+ inf_ptrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
+ {
+ pid_t pid;
+- int request;
++ int request, sig;
+
+ if (minus_one_ptid == ptid)
+ /* Resume all threads. Traditionally ptrace() only supports
+@@ -360,13 +362,23 @@ inf_ptrace_target::resume (ptid_t ptid,
+ all possible successor instructions), so we don't have to
+ worry about that here. */
+ request = PT_STEP;
+- }
++#if __NetBSD__
++ /*
++ * On NetBSD the data field of PT_STEP contains the thread
++ * to be stepped; all other threads are continued if this value is > 0
++ */
++ sig = ptid.lwp ();
++#else
++ sig = 0;
++#endif
++ } else
++ sig = gdb_signal_to_host (signal);
+
+ /* An address of (PTRACE_TYPE_ARG3)1 tells ptrace to continue from
+ where it was. If GDB wanted it to start some other way, we have
+ already written a new program counter value to the child. */
+ errno = 0;
+- ptrace (request, pid, (PTRACE_TYPE_ARG3)1, gdb_signal_to_host (signal));
++ ptrace (request, pid, (PTRACE_TYPE_ARG3)1, sig);
+ if (errno != 0)
+ perror_with_name (("ptrace"));
+ }
+@@ -562,6 +574,15 @@ inf_ptrace_target::xfer_partial (enum ta
+ /* If the PT_IO request is somehow not supported, fallback on
+ using PT_WRITE_D/PT_READ_D. Otherwise we will return zero
+ to indicate failure. */
++ if (errno == EACCES)
++ {
++ fprintf_unfiltered (gdb_stderr, "Cannot %s process at %p (%s). "
++ "Is PaX MPROTECT active? See security(7), "
++ "sysctl(7), paxctl(8)\n", writebuf ? "write to" :
++ "read from", piod.piod_offs,
++ strerror(errno));
++ return TARGET_XFER_E_IO; /* Some other error perhaps? */
++ }
+ if (errno != EINVAL)
+ return TARGET_XFER_EOF;
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_m68k-bsd-nat.c b/gdb-netbsd/patches/patch-gdb_m68k-bsd-nat.c
new file mode 100644
index 0000000000..ea7fb7e605
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_m68k-bsd-nat.c
@@ -0,0 +1,110 @@
+$NetBSD$
+
+--- gdb/m68k-bsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/m68k-bsd-nat.c
+@@ -29,7 +29,12 @@
+ #include "m68k-tdep.h"
+ #include "inf-ptrace.h"
+
++#ifdef __NetBSD__
++#include "nbsd-nat.h"
++struct m68k_bsd_nat_target final : public nbsd_nat_target
++#else
+ struct m68k_bsd_nat_target final : public inf_ptrace_target
++#endif
+ {
+ void fetch_registers (struct regcache *, int) override;
+ void store_registers (struct regcache *, int) override;
+@@ -54,7 +59,7 @@ m68kbsd_fpregset_supplies_p (int regnum)
+ static void
+ m68kbsd_supply_gregset (struct regcache *regcache, const void *gregs)
+ {
+- const char *regs = gregs;
++ const gdb_byte *regs = (const gdb_byte *)gregs;
+ int regnum;
+
+ for (regnum = M68K_D0_REGNUM; regnum <= M68K_PC_REGNUM; regnum++)
+@@ -67,7 +72,7 @@ static void
+ m68kbsd_supply_fpregset (struct regcache *regcache, const void *fpregs)
+ {
+ struct gdbarch *gdbarch = regcache->arch ();
+- const char *regs = fpregs;
++ const gdb_byte *regs = (const gdb_byte *)fpregs;
+ int regnum;
+
+ for (regnum = M68K_FP0_REGNUM; regnum <= M68K_FPI_REGNUM; regnum++)
+@@ -82,7 +87,7 @@ static void
+ m68kbsd_collect_gregset (const struct regcache *regcache,
+ void *gregs, int regnum)
+ {
+- char *regs = gregs;
++ gdb_byte *regs = (gdb_byte *)gregs;
+ int i;
+
+ for (i = M68K_D0_REGNUM; i <= M68K_PC_REGNUM; i++)
+@@ -100,7 +105,7 @@ m68kbsd_collect_fpregset (struct regcach
+ void *fpregs, int regnum)
+ {
+ struct gdbarch *gdbarch = regcache->arch ();
+- char *regs = fpregs;
++ gdb_byte *regs = (gdb_byte *)fpregs;
+ int i;
+
+ for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++)
+@@ -123,7 +128,7 @@ m68k_bsd_nat_target::fetch_registers (st
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ m68kbsd_supply_gregset (regcache, ®s);
+@@ -133,7 +138,7 @@ m68k_bsd_nat_target::fetch_registers (st
+ {
+ struct fpreg fpregs;
+
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ m68kbsd_supply_fpregset (regcache, &fpregs);
+@@ -152,12 +157,12 @@ m68k_bsd_nat_target::store_registers (st
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ m68kbsd_collect_gregset (regcache, ®s, regnum);
+
+- if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't write registers"));
+ }
+
+@@ -165,12 +170,12 @@ m68k_bsd_nat_target::store_registers (st
+ {
+ struct fpreg fpregs;
+
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ m68kbsd_collect_fpregset (regcache, &fpregs, regnum);
+
+- if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't write floating point status"));
+ }
+ }
+@@ -215,7 +220,7 @@ m68kbsd_supply_pcb (struct regcache *reg
+ tmp = pcb->pcb_ps & 0xffff;
+ regcache->raw_supply (M68K_PS_REGNUM, &tmp);
+
+- read_memory (pcb->pcb_regs[PCB_REGS_FP] + 4, (char *) &tmp, sizeof tmp);
++ read_memory (pcb->pcb_regs[PCB_REGS_FP] + 4, (gdb_byte *) &tmp, sizeof tmp);
+ regcache->raw_supply (M68K_PC_REGNUM, &tmp);
+
+ return 1;
diff --git a/gdb-netbsd/patches/patch-gdb_mips-nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_mips-nbsd-nat.c
new file mode 100644
index 0000000000..87b19b600e
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_mips-nbsd-nat.c
@@ -0,0 +1,141 @@
+$NetBSD$
+
+--- gdb/mips-nbsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/mips-nbsd-nat.c
+@@ -16,7 +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/>. */
+-
++#ifndef _KERNTYPES
++#define _KERNTYPES
++#endif
+ #include "defs.h"
+ #include "inferior.h"
+ #include "regcache.h"
+@@ -27,10 +29,14 @@
+ #include <machine/reg.h>
+
+ #include "mips-tdep.h"
++#include "nbsd-nat.h"
+ #include "mips-nbsd-tdep.h"
+ #include "inf-ptrace.h"
++#include "bsd-kvm.h"
++
++#include "machine/pcb.h"
+
+-class mips_nbsd_nat_target final : public inf_ptrace_target
++class mips_nbsd_nat_target final : public nbsd_nat_target
+ {
+ void fetch_registers (struct regcache *, int) override;
+ void store_registers (struct regcache *, int) override;
+@@ -49,14 +55,16 @@ getregs_supplies (struct gdbarch *gdbarc
+ void
+ mips_nbsd_nat_target::fetch_registers (struct regcache *regcache, int regno)
+ {
+- pid_t pid = regcache->ptid ().pid ();
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+ struct gdbarch *gdbarch = regcache->arch ();
+ if (regno == -1 || getregs_supplies (gdbarch, regno))
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ mipsnbsd_supply_reg (regcache, (char *) ®s, regno);
+@@ -69,7 +77,7 @@ mips_nbsd_nat_target::fetch_registers (s
+ {
+ struct fpreg fpregs;
+
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ mipsnbsd_supply_fpreg (regcache, (char *) &fpregs, regno);
+@@ -79,19 +87,21 @@ mips_nbsd_nat_target::fetch_registers (s
+ void
+ mips_nbsd_nat_target::store_registers (struct regcache *regcache, int regno)
+ {
+- pid_t pid = regcache->ptid ().pid ();
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+ struct gdbarch *gdbarch = regcache->arch ();
+ if (regno == -1 || getregs_supplies (gdbarch, regno))
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ mipsnbsd_fill_reg (regcache, (char *) ®s, regno);
+
+- if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't write registers"));
+
+ if (regno != -1)
+@@ -103,18 +113,54 @@ mips_nbsd_nat_target::store_registers (s
+ {
+ struct fpreg fpregs;
+
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ mipsnbsd_fill_fpreg (regcache, (char *) &fpregs, regno);
+
+- if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't write floating point status"));
+ }
+ }
+
++static int
++mipsnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
++{
++ struct label_t sf;
++
++ sf = pcb->pcb_context;
++
++ /* really should test for n{32,64} abi for this register
++ unless this is purely the "n" ABI */
++
++ regcache->raw_supply (MIPS_S0_REGNUM, &sf.val[_L_S0]);
++ regcache->raw_supply (MIPS_S1_REGNUM, &sf.val[_L_S1]);
++ regcache->raw_supply (MIPS_S2_REGNUM, &sf.val[_L_S2]);
++ regcache->raw_supply (MIPS_S3_REGNUM, &sf.val[_L_S3]);
++ regcache->raw_supply (MIPS_S4_REGNUM, &sf.val[_L_S4]);
++ regcache->raw_supply (MIPS_S5_REGNUM, &sf.val[_L_S5]);
++ regcache->raw_supply (MIPS_S6_REGNUM, &sf.val[_L_S6]);
++ regcache->raw_supply (MIPS_S7_REGNUM, &sf.val[_L_S7]);
++
++ regcache->raw_supply (MIPS_S8_REGNUM, &sf.val[_L_S8]);
++
++ regcache->raw_supply (MIPS_T8_REGNUM, &sf.val[_L_T8]);
++
++ regcache->raw_supply (MIPS_GP_REGNUM, &sf.val[_L_GP]);
++
++ regcache->raw_supply (MIPS_SP_REGNUM, &sf.val[_L_SP]);
++ regcache->raw_supply (MIPS_RA_REGNUM, &sf.val[_L_RA]);
++ regcache->raw_supply (MIPS_PS_REGNUM, &sf.val[_L_SR]);
++
++ /* provide the return address of the savectx as the current pc */
++ regcache->raw_supply (MIPS_EMBED_PC_REGNUM, &sf.val[_L_RA]);
++
++ return 0;
++}
++
+ void
+ _initialize_mipsnbsd_nat (void)
+ {
+ add_inf_child_target (&the_mips_nbsd_nat_target);
++ bsd_kvm_add_target (mipsnbsd_supply_pcb);
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_mips-tdep.h b/gdb-netbsd/patches/patch-gdb_mips-tdep.h
new file mode 100644
index 0000000000..ad5893e27e
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_mips-tdep.h
@@ -0,0 +1,24 @@
+$NetBSD$
+
+--- gdb/mips-tdep.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/mips-tdep.h
+@@ -126,10 +126,19 @@ enum
+ MIPS_AT_REGNUM = 1,
+ MIPS_V0_REGNUM = 2, /* Function integer return value. */
+ MIPS_A0_REGNUM = 4, /* Loc of first arg during a subr call. */
++ MIPS_S0_REGNUM = 16,
++ MIPS_S1_REGNUM = 17,
+ MIPS_S2_REGNUM = 18, /* Contains return address in MIPS16 thunks. */
++ MIPS_S3_REGNUM = 19,
++ MIPS_S4_REGNUM = 20,
++ MIPS_S5_REGNUM = 21,
++ MIPS_S6_REGNUM = 22,
++ MIPS_S7_REGNUM = 23,
++ MIPS_T8_REGNUM = 24,
+ MIPS_T9_REGNUM = 25, /* Contains address of callee in PIC. */
+ MIPS_GP_REGNUM = 28,
+ MIPS_SP_REGNUM = 29,
++ MIPS_S8_REGNUM = 30,
+ MIPS_RA_REGNUM = 31,
+ MIPS_PS_REGNUM = 32, /* Contains processor status. */
+ MIPS_EMBED_LO_REGNUM = 33,
diff --git a/gdb-netbsd/patches/patch-gdb_nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_nbsd-nat.c
new file mode 100644
index 0000000000..c32c6812d7
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_nbsd-nat.c
@@ -0,0 +1,533 @@
+$NetBSD$
+
+--- gdb/nbsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/nbsd-nat.c
+@@ -1,4 +1,4 @@
+-/* Native-dependent code for NetBSD.
++/* Native-dependent code for NetBSD
+
+ Copyright (C) 2006-2019 Free Software Foundation, Inc.
+
+@@ -18,7 +18,21 @@
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+ #include "defs.h"
++#include "gdbcore.h"
++#include "inferior.h"
++#include "regcache.h"
++#include "regset.h"
++#include "gdbcmd.h"
++#include "gdbthread.h"
++#include "gdbsupport/gdb_wait.h"
++#include <sys/types.h>
++#include <sys/ptrace.h>
++#include <sys/sysctl.h>
++#ifdef HAVE_KINFO_GETVMMAP
++#include <util.h>
++#endif
+
++#include "elf-bfd.h"
+ #include "nbsd-nat.h"
+
+ /* Return the name of a file that can be opened to get the symbols for
+@@ -31,6 +45,17 @@ nbsd_nat_target::pid_to_exec_file (int p
+ static char buf[PATH_MAX];
+ char name[PATH_MAX];
+
++ size_t buflen;
++ int mib[4];
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC_ARGS;
++ mib[2] = pid;
++ mib[3] = KERN_PROC_PATHNAME;
++ buflen = sizeof buf;
++ if (sysctl (mib, 4, buf, &buflen, NULL, 0) == 0)
++ return buf;
++
+ xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
+ len = readlink (name, buf, PATH_MAX - 1);
+ if (len != -1)
+@@ -41,3 +66,482 @@ nbsd_nat_target::pid_to_exec_file (int p
+
+ return NULL;
+ }
++
++/* Iterate over all the memory regions in the current inferior,
++ calling FUNC for each memory region. OBFD is passed as the last
++ argument to FUNC. */
++
++int
++nbsd_nat_target::find_memory_regions (find_memory_region_ftype func,
++ void *obfd)
++{
++ pid_t pid = inferior_ptid.pid ();
++ struct kinfo_vmentry *vmentl, *kve;
++ uint64_t size;
++ int i;
++ size_t nitems;
++
++ vmentl = kinfo_getvmmap (pid, &nitems);
++ if (vmentl == NULL)
++ perror_with_name (_("Couldn't fetch VM map entries."));
++
++ for (i = 0; i < nitems; i++)
++ {
++ kve = &vmentl[i];
++
++ /* Skip unreadable segments and those where MAP_NOCORE has been set. */
++ if (!(kve->kve_protection & KVME_PROT_READ)
++ || kve->kve_flags & KVME_FLAG_NOCOREDUMP)
++ continue;
++
++ /* Skip segments with an invalid type. */
++ switch (kve->kve_type) {
++ case KVME_TYPE_VNODE:
++ case KVME_TYPE_ANON:
++ case KVME_TYPE_SUBMAP:
++ case KVME_TYPE_OBJECT:
++ break;
++ default:
++ continue;
++ }
++
++ size = kve->kve_end - kve->kve_start;
++ if (info_verbose)
++ {
++ fprintf_filtered (gdb_stdout,
++ "Save segment, %ld bytes at %llx (%c%c%c)\n",
++ (long) size,
++ (long long int)kve->kve_start,
++ kve->kve_protection & KVME_PROT_READ ? 'r' : '-',
++ kve->kve_protection & KVME_PROT_WRITE ? 'w' : '-',
++ kve->kve_protection & KVME_PROT_EXEC ? 'x' : '-');
++ }
++
++ /* Invoke the callback function to create the corefile segment.
++ Pass MODIFIED as true, we do not know the real modification state. */
++ func (kve->kve_start, size, kve->kve_protection & KVME_PROT_READ,
++ kve->kve_protection & KVME_PROT_WRITE,
++ kve->kve_protection & KVME_PROT_EXEC, 1, obfd);
++ }
++ free(vmentl);
++ return 0;
++}
++
++static int debug_nbsd_lwp;
++
++static void
++show_nbsd_lwp_debug (struct ui_file *file, int from_tty,
++ struct cmd_list_element *c, const char *value)
++{
++ fprintf_filtered (file, _("Debugging of NetBSD lwp module is %s.\n"), value);
++}
++
++/* Return true if PTID is still active in the inferior. */
++
++bool
++nbsd_nat_target::thread_alive (ptid_t ptid)
++{
++ if (ptid.lwp_p ())
++ {
++ struct ptrace_lwpinfo pl;
++
++ pl.pl_lwpid = ptid.lwp ();
++ if (ptrace (PT_LWPINFO, ptid.pid (), (caddr_t) &pl, sizeof pl)
++ == -1)
++ return 0;
++ }
++
++ return 1;
++}
++
++/* Convert PTID to a string. Returns the string in a static
++ buffer. */
++
++std::string
++nbsd_nat_target::pid_to_str (ptid_t ptid)
++{
++ lwpid_t lwp;
++
++ lwp = ptid.lwp ();
++ if (lwp != 0)
++ {
++ static char buf[64];
++ int pid = ptid.pid ();
++
++ xsnprintf (buf, sizeof buf, "LWP %d of process %d", lwp, pid);
++ return buf;
++ }
++
++ return normal_pid_to_str (ptid);
++}
++
++/* Return the name assigned to a thread by an application. Returns
++ the string in a static buffer. */
++
++const char *
++nbsd_nat_target::thread_name (struct thread_info *thr)
++{
++ struct kinfo_lwp *kl;
++ pid_t pid = thr->ptid.pid ();
++ lwpid_t lwp = thr->ptid.lwp ();
++ static char buf[KI_LNAMELEN];
++ int mib[5];
++ size_t i, nlwps;
++ size_t size;
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_LWP;
++ mib[2] = pid;
++ mib[3] = sizeof(struct kinfo_lwp);
++ mib[4] = 0;
++
++ if (sysctl(mib, 5, NULL, &size, NULL, 0) == -1 || size == 0)
++ perror_with_name (("sysctl"));
++
++ mib[4] = size / sizeof(size_t);
++
++ kl = (struct kinfo_lwp *) xmalloc (size);
++ if (kl == NULL)
++ perror_with_name (("malloc"));
++
++ if (sysctl(mib, 5, kl, &size, NULL, 0) == -1 || size == 0)
++ perror_with_name (("sysctl"));
++
++ nlwps = size / sizeof(struct kinfo_lwp);
++ buf[0] = '\0';
++ for (i = 0; i < nlwps; i++) {
++ if (kl[i].l_lid == lwp) {
++ xsnprintf (buf, sizeof buf, "%s", kl[i].l_name);
++ break;
++ }
++ }
++ xfree(kl);
++
++ return buf;
++}
++
++/* Enable additional event reporting on new processes. */
++
++static void
++nbsd_enable_proc_events (pid_t pid)
++{
++ int events;
++
++ if (ptrace (PT_GET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events,
++ sizeof (events)) == -1)
++ perror_with_name (("ptrace"));
++ events |= PTRACE_FORK;
++ events |= PTRACE_VFORK;
++ events |= PTRACE_VFORK_DONE;
++ events |= PTRACE_LWP_CREATE;
++ events |= PTRACE_LWP_EXIT;
++#if notyet
++ events |= PTRACE_POSIX_SPAWN;
++#endif
++ if (ptrace (PT_SET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events,
++ sizeof (events)) == -1)
++ perror_with_name (("ptrace"));
++}
++
++/* Add threads for any new LWPs in a process.
++
++ When LWP events are used, this function is only used to detect existing
++ threads when attaching to a process. On older systems, this function is
++ called to discover new threads each time the thread list is updated. */
++
++static void
++nbsd_add_threads (pid_t pid)
++{
++ int val;
++ struct ptrace_lwpinfo pl;
++
++ pl.pl_lwpid = 0;
++ while ((val = ptrace (PT_LWPINFO, pid, (void *)&pl, sizeof(pl))) != -1
++ && pl.pl_lwpid != 0)
++ {
++ ptid_t ptid = ptid_t (pid, pl.pl_lwpid, 0);
++ if (!in_thread_list (ptid))
++ {
++ if (inferior_ptid.lwp () == 0)
++ thread_change_ptid (inferior_ptid, ptid);
++ else
++ add_thread (ptid);
++ }
++ }
++}
++
++/* Implement the "to_update_thread_list" target_ops method. */
++
++void
++nbsd_nat_target::update_thread_list ()
++{
++ prune_threads ();
++
++ nbsd_add_threads (inferior_ptid.pid ());
++}
++
++
++struct nbsd_fork_info
++{
++ struct nbsd_fork_info *next;
++ ptid_t ptid;
++};
++
++void
++nbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
++{
++ if (debug_nbsd_lwp)
++ fprintf_unfiltered (gdb_stdlog,
++ "NLWP: nbsd_resume for ptid (%d, %ld, %ld)\n",
++ ptid.pid (), ptid.lwp (), ptid.tid ());
++ if (ptid.pid () == -1)
++ ptid = inferior_ptid;
++ inf_ptrace_target::resume (ptid, step, signo);
++}
++
++/* Wait for the child specified by PTID to do something. Return the
++ process ID of the child, or MINUS_ONE_PTID in case of error; store
++ the status in *OURSTATUS. */
++
++ptid_t
++nbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
++ int target_options)
++{
++ ptid_t wptid;
++
++ /*
++ * Always perform polling on exact PID, overwrite the default polling on
++ * WAIT_ANY.
++ *
++ * This avoids events reported in random order reported for FORK / VFORK.
++ *
++ * Polling on traced parent always simplifies the code.
++ */
++ ptid = inferior_ptid;
++
++ if (debug_nbsd_lwp)
++ fprintf_unfiltered (gdb_stdlog, "NLWP: calling super_wait (%d, %ld, %ld) target_options=%#x\n",
++ ptid.pid (), ptid.lwp (), ptid.tid (), target_options);
++
++ wptid = inf_ptrace_target::wait (ptid, ourstatus, target_options);
++
++ if (debug_nbsd_lwp)
++ fprintf_unfiltered (gdb_stdlog, "NLWP: returned from super_wait (%d, %ld, %ld) target_options=%#x with ourstatus->kind=%d\n",
++ ptid.pid (), ptid.lwp (), ptid.tid (),
++ target_options, ourstatus->kind);
++
++ if (ourstatus->kind == TARGET_WAITKIND_STOPPED)
++ {
++ ptrace_state_t pst;
++ ptrace_siginfo_t psi, child_psi;
++ int status;
++ pid_t pid, child, wchild;
++ ptid_t child_ptid;
++ lwpid_t lwp;
++
++ pid = wptid.pid ();
++ // Find the lwp that caused the wait status change
++ if (ptrace(PT_GET_SIGINFO, pid, &psi, sizeof(psi)) == -1)
++ perror_with_name (("ptrace"));
++
++ /* For whole-process signals pick random thread */
++ if (psi.psi_lwpid == 0) {
++ // XXX: Is this always valid?
++ lwp = inferior_ptid.lwp ();
++ } else {
++ lwp = psi.psi_lwpid;
++ }
++
++ wptid = ptid_t (pid, lwp, 0);
++
++ /* Set LWP in the process */
++ if (in_thread_list (ptid_t (pid))) {
++ if (debug_nbsd_lwp)
++ fprintf_unfiltered (gdb_stdlog,
++ "NLWP: using LWP %d for first thread\n",
++ lwp);
++ thread_change_ptid (ptid_t (pid), wptid);
++ }
++
++ if (debug_nbsd_lwp)
++ fprintf_unfiltered (gdb_stdlog,
++ "NLWP: received signal=%d si_code=%d in process=%d lwp=%d\n",
++ psi.psi_siginfo.si_signo, psi.psi_siginfo.si_code, pid, lwp);
++
++ switch (psi.psi_siginfo.si_signo) {
++ case SIGTRAP:
++ switch (psi.psi_siginfo.si_code) {
++ case TRAP_BRKPT:
++// lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
++ break;
++ case TRAP_DBREG:
++// if (hardware_breakpoint_inserted_here_p (get_regcache_aspace (regcache), pc))
++// lp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
++// else
++// lp->stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
++ break;
++ case TRAP_TRACE:
++// lp->stop_reason = TARGET_STOPPED_BY_SINGLE_STEP;
++ break;
++ case TRAP_SCE:
++ ourstatus->kind = TARGET_WAITKIND_SYSCALL_ENTRY;
++ ourstatus->value.syscall_number = psi.psi_siginfo.si_sysnum;
++ break;
++ case TRAP_SCX:
++ ourstatus->kind = TARGET_WAITKIND_SYSCALL_RETURN;
++ ourstatus->value.syscall_number = psi.psi_siginfo.si_sysnum;
++ break;
++ case TRAP_EXEC:
++ ourstatus->kind = TARGET_WAITKIND_EXECD;
++ ourstatus->value.execd_pathname = xstrdup(pid_to_exec_file (pid));
++ break;
++ case TRAP_LWP:
++ case TRAP_CHLD:
++ if (ptrace(PT_GET_PROCESS_STATE, pid, &pst, sizeof(pst)) == -1)
++ perror_with_name (("ptrace"));
++ switch (pst.pe_report_event) {
++ case PTRACE_FORK:
++ case PTRACE_VFORK:
++ if (pst.pe_report_event == PTRACE_FORK)
++ ourstatus->kind = TARGET_WAITKIND_FORKED;
++ else
++ ourstatus->kind = TARGET_WAITKIND_VFORKED;
++ child = pst.pe_other_pid;
++
++ if (debug_nbsd_lwp)
++ fprintf_unfiltered (gdb_stdlog,
++ "NLWP: registered %s event for PID %d\n",
++ (pst.pe_report_event == PTRACE_FORK) ? "FORK" : "VFORK", child);
++
++ wchild = waitpid (child, &status, 0);
++
++ if (wchild == -1)
++ perror_with_name (("waitpid"));
++
++ gdb_assert (wchild == child);
++
++ if (!WIFSTOPPED(status)) {
++ /* Abnormal situation (SIGKILLed?).. bail out */
++ ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
++ return wptid;
++ }
++
++ if (ptrace(PT_GET_SIGINFO, child, &child_psi, sizeof(child_psi)) == -1)
++ perror_with_name (("ptrace"));
++
++ if (child_psi.psi_siginfo.si_signo != SIGTRAP) {
++ /* Abnormal situation.. bail out */
++ ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
++ return wptid;
++ }
++
++ if (child_psi.psi_siginfo.si_code != TRAP_CHLD) {
++ /* Abnormal situation.. bail out */
++ ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
++ return wptid;
++ }
++
++ child_ptid = ptid_t (child, child_psi.psi_lwpid, 0);
++ nbsd_enable_proc_events (child_ptid.pid ());
++ ourstatus->value.related_pid = child_ptid;
++ break;
++ case PTRACE_VFORK_DONE:
++ ourstatus->kind = TARGET_WAITKIND_VFORK_DONE;
++ if (debug_nbsd_lwp)
++ fprintf_unfiltered (gdb_stdlog, "NLWP: reported VFORK_DONE parent=%d child=%d\n", pid, pst.pe_other_pid);
++ break;
++ case PTRACE_LWP_CREATE:
++ wptid = ptid_t (pid, pst.pe_lwp, 0);
++ if (in_thread_list (wptid)) {
++ /* Newborn reported after attach? */
++ ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
++ return wptid;
++ }
++ if (inferior_ptid.lwp () == 0)
++ thread_change_ptid (inferior_ptid, wptid);
++ else
++ add_thread (wptid);
++ ourstatus->kind = TARGET_WAITKIND_THREAD_CREATED;
++ if (debug_nbsd_lwp)
++ fprintf_unfiltered (gdb_stdlog, "NLWP: created LWP %d\n", pst.pe_lwp);
++ break;
++ case PTRACE_LWP_EXIT:
++ wptid = ptid_t (pid, pst.pe_lwp, 0);
++ if (!in_thread_list (wptid)) {
++ /* Dead child reported after attach? */
++ ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
++ return wptid;
++ }
++ delete_thread (find_thread_ptid (wptid));
++ ourstatus->kind = TARGET_WAITKIND_THREAD_EXITED;
++ if (debug_nbsd_lwp)
++ fprintf_unfiltered (gdb_stdlog, "NLWP: exited LWP %d\n", pst.pe_lwp);
++ if (ptrace (PT_CONTINUE, pid, (void *)1, 0) == -1)
++ perror_with_name (("ptrace"));
++ break;
++ }
++ break;
++ }
++ break;
++ }
++
++ if (debug_nbsd_lwp)
++ fprintf_unfiltered (gdb_stdlog,
++ "NLWP: nbsd_wait returned (%d, %ld, %ld)\n",
++ wptid.pid (), wptid.lwp (),
++ wptid.tid ());
++ inferior_ptid = wptid;
++
++ }
++ return wptid;
++}
++
++/* Target hook for follow_fork. On entry and at return inferior_ptid is
++ the ptid of the followed inferior. */
++
++int
++nbsd_nat_target::follow_fork (int follow_child, int detach_fork)
++{
++ if (!follow_child && detach_fork)
++ {
++ struct thread_info *tp = inferior_thread ();
++ pid_t child_pid = tp->pending_follow.value.related_pid.pid ();
++
++ /* Breakpoints have already been detached from the child by
++ infrun.c. */
++
++ if (ptrace (PT_DETACH, child_pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
++ perror_with_name (("ptrace"));
++ }
++
++ return 0;
++}
++
++void
++nbsd_nat_target::post_startup_inferior (ptid_t pid)
++{
++ nbsd_enable_proc_events (pid.pid ());
++}
++
++void
++nbsd_nat_target::post_attach (int pid)
++{
++ nbsd_enable_proc_events (pid);
++ nbsd_add_threads (pid);
++}
++
++/* Provide a prototype to silence -Wmissing-prototypes. */
++extern initialize_file_ftype _initialize_nbsd_nat;
++
++void
++_initialize_nbsd_nat (void)
++{
++ add_setshow_boolean_cmd ("nbsd-lwp", class_maintenance,
++ &debug_nbsd_lwp, _("\
++Set debugging of NetBSD lwp module."), _("\
++Show debugging of NetBSD lwp module."), _("\
++Enables printf debugging output."),
++ NULL,
++ &show_nbsd_lwp_debug,
++ &setdebuglist, &showdebuglist);
++}
diff --git a/gdb-netbsd/patches/patch-gdb_nbsd-nat.h b/gdb-netbsd/patches/patch-gdb_nbsd-nat.h
new file mode 100644
index 0000000000..4bd269081b
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_nbsd-nat.h
@@ -0,0 +1,32 @@
+$NetBSD$
+
+--- gdb/nbsd-nat.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/nbsd-nat.h
+@@ -27,6 +27,27 @@
+ struct nbsd_nat_target : public inf_ptrace_target
+ {
+ char *pid_to_exec_file (int pid) override;
++ int find_memory_regions (find_memory_region_ftype func, void *data) override;
++
++ bool thread_alive (ptid_t ptid) override;
++ std::string pid_to_str (ptid_t) override;
++
++ const char *thread_name (struct thread_info *) override;
++
++ void update_thread_list () override;
++
++ thread_control_capabilities get_thread_control_capabilities () override
++ { return tc_schedlock; }
++
++ void resume (ptid_t, int, enum gdb_signal) override;
++
++ ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
++
++ void post_startup_inferior (ptid_t) override;
++ void post_attach (int) override;
++
++ int follow_fork (int, int) override;
++
+ };
+
+ #endif /* nbsd-nat.h */
diff --git a/gdb-netbsd/patches/patch-gdb_nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_nbsd-tdep.c
new file mode 100644
index 0000000000..2b307d0017
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_nbsd-tdep.c
@@ -0,0 +1,41 @@
+$NetBSD$
+
+--- gdb/nbsd-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/nbsd-tdep.c
+@@ -3,9 +3,9 @@
+ Copyright (C) 2002-2019 Free Software Foundation, Inc.
+
+ Contributed by Wasabi Systems, 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
+@@ -20,6 +20,7 @@
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+ #include "defs.h"
++#include "objfiles.h"
+ #include "solib-svr4.h"
+ #include "nbsd-tdep.h"
+
+@@ -47,3 +48,16 @@ nbsd_pc_in_sigtramp (CORE_ADDR pc, const
+ return (func_name != NULL
+ && startswith (func_name, "__sigtramp"));
+ }
++
++CORE_ADDR
++nbsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
++{
++ struct bound_minimal_symbol msym;
++
++ msym = lookup_minimal_symbol("_rtld_bind_start", NULL, NULL);
++ if (msym.minsym && BMSYMBOL_VALUE_ADDRESS (msym) == pc)
++ return frame_unwind_caller_pc (get_current_frame ());
++ else
++ return find_solib_trampoline_target (get_current_frame (), pc);
++}
++
diff --git a/gdb-netbsd/patches/patch-gdb_nbsd-tdep.h b/gdb-netbsd/patches/patch-gdb_nbsd-tdep.h
new file mode 100644
index 0000000000..6df845d3de
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_nbsd-tdep.h
@@ -0,0 +1,11 @@
+$NetBSD$
+
+--- gdb/nbsd-tdep.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/nbsd-tdep.h
+@@ -25,4 +25,6 @@ struct link_map_offsets *nbsd_lp64_solib
+
+ int nbsd_pc_in_sigtramp (CORE_ADDR, const char *);
+
++CORE_ADDR nbsd_skip_solib_resolver (struct gdbarch *gdbarch,
++ CORE_ADDR pc);
+ #endif /* NBSD_TDEP_H */
diff --git a/gdb-netbsd/patches/patch-gdb_objfiles.c b/gdb-netbsd/patches/patch-gdb_objfiles.c
new file mode 100644
index 0000000000..10df850cc9
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_objfiles.c
@@ -0,0 +1,26 @@
+$NetBSD$
+
+--- gdb/objfiles.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/objfiles.c
+@@ -1123,6 +1123,13 @@ static int
+ insert_section_p (const struct bfd *abfd,
+ const struct bfd_section *section)
+ {
++#ifndef __NetBSD__
++ /*
++ * On NetBSD we don't typically have overlay sections and in some of
++ * our kernels (i386 vma = lma | 0xc0000000), so the following test
++ * makes kernels not load any symbols. There must be a better way to
++ * detect overlays.
++ */
+ const bfd_vma lma = bfd_section_lma (abfd, section);
+
+ if (overlay_debugging && lma != 0 && lma != bfd_section_vma (abfd, section)
+@@ -1131,6 +1138,7 @@ insert_section_p (const struct bfd *abfd
+ discarding sections from the "system supplied DSO" (aka vdso)
+ on some Linux systems (e.g. Fedora 11). */
+ return 0;
++#endif
+ if ((bfd_get_section_flags (abfd, section) & SEC_THREAD_LOCAL) != 0)
+ /* This is a TLS section. */
+ return 0;
diff --git a/gdb-netbsd/patches/patch-gdb_p-exp.y b/gdb-netbsd/patches/patch-gdb_p-exp.y
new file mode 100644
index 0000000000..6650598d99
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_p-exp.y
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- gdb/p-exp.y.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/p-exp.y
+@@ -1516,7 +1516,7 @@ yylex (void)
+ {
+ std::string tmp = copy_name (yylval.sval);
+ struct symbol *sym;
+- struct field_of_this_result is_a_field_of_this;
++ struct field_of_this_result is_a_field_of_this = { .type = NULL };
+ int is_a_field = 0;
+ int hextype;
+
diff --git a/gdb-netbsd/patches/patch-gdb_ppc-nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_ppc-nbsd-nat.c
new file mode 100644
index 0000000000..ac03c8e043
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_ppc-nbsd-nat.c
@@ -0,0 +1,130 @@
+$NetBSD$
+
+--- gdb/ppc-nbsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/ppc-nbsd-nat.c
+@@ -19,6 +19,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/>. */
+
++#define _KMEMUSER
+ #include "defs.h"
+
+ #include <sys/types.h>
+@@ -31,12 +32,15 @@
+ #include "inferior.h"
+ #include "regcache.h"
+
++#include "common/gdb_assert.h"
++
++#include "nbsd-nat.h"
+ #include "ppc-tdep.h"
+ #include "ppc-nbsd-tdep.h"
+ #include "bsd-kvm.h"
+ #include "inf-ptrace.h"
+
+-struct ppc_nbsd_nat_target final : public inf_ptrace_target
++struct ppc_nbsd_nat_target final : public nbsd_nat_target
+ {
+ void fetch_registers (struct regcache *, int) override;
+ void store_registers (struct regcache *, int) override;
+@@ -88,13 +92,15 @@ void
+ ppc_nbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
+ {
+ struct gdbarch *gdbarch = regcache->arch ();
+- pid_t pid = regcache->ptid ().pid ();
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+ if (regnum == -1 || getregs_supplies (gdbarch, regnum))
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ ppc_supply_gregset (&ppcnbsd_gregset, regcache,
+@@ -105,7 +111,7 @@ ppc_nbsd_nat_target::fetch_registers (st
+ {
+ struct fpreg fpregs;
+
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get FP registers"));
+
+ ppc_supply_fpregset (&ppcnbsd_fpregset, regcache,
+@@ -117,19 +123,21 @@ void
+ ppc_nbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
+ {
+ struct gdbarch *gdbarch = regcache->arch ();
+- pid_t pid = regcache->ptid ().pid ();
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+ if (regnum == -1 || getregs_supplies (gdbarch, regnum))
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ ppc_collect_gregset (&ppcnbsd_gregset, regcache,
+ regnum, ®s, sizeof regs);
+
+- if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't write registers"));
+ }
+
+@@ -137,13 +145,13 @@ ppc_nbsd_nat_target::store_registers (st
+ {
+ struct fpreg fpregs;
+
+- if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get FP registers"));
+
+ ppc_collect_fpregset (&ppcnbsd_fpregset, regcache,
+ regnum, &fpregs, sizeof fpregs);
+
+- if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't set FP registers"));
+ }
+ }
+@@ -161,20 +169,20 @@ ppcnbsd_supply_pcb (struct regcache *reg
+ if (pcb->pcb_sp == 0)
+ return 0;
+
+- read_memory (pcb->pcb_sp, (gdb_byte *)&sf, sizeof sf);
+- regcache->raw_supply (tdep->ppc_cr_regnum, &sf.cr);
+- regcache->raw_supply (tdep->ppc_gp0_regnum + 2, &sf.fixreg2);
++ read_memory (pcb->pcb_sp, (gdb_byte *)&sf, sizeof(sf));
++ regcache->raw_supply (tdep->ppc_cr_regnum, &sf.sf_cr);
++ regcache->raw_supply (tdep->ppc_gp0_regnum + 2, &sf.sf_fixreg2);
+ for (i = 0 ; i < 19 ; i++)
+- regcache->raw_supply (tdep->ppc_gp0_regnum + 13 + i, &sf.fixreg[i]);
++ regcache->raw_supply (tdep->ppc_gp0_regnum + 13 + i, &sf.sf_fixreg[i]);
+
+- read_memory(sf.sp, (gdb_byte *)&cf, sizeof(cf));
+- regcache->raw_supply (tdep->ppc_gp0_regnum + 30, &cf.r30);
+- regcache->raw_supply (tdep->ppc_gp0_regnum + 31, &cf.r31);
+- regcache->raw_supply (tdep->ppc_gp0_regnum + 1, &cf.sp);
+-
+- read_memory(cf.sp, (gdb_byte *)&cf, sizeof(cf));
+- regcache->raw_supply (tdep->ppc_lr_regnum, &cf.lr);
+- regcache->raw_supply (gdbarch_pc_regnum (gdbarch), &cf.lr);
++ read_memory(sf.sf_sp, (gdb_byte *)&cf, sizeof(cf));
++ regcache->raw_supply (tdep->ppc_gp0_regnum + 30, &cf.cf_r30);
++ regcache->raw_supply (tdep->ppc_gp0_regnum + 31, &cf.cf_r31);
++ regcache->raw_supply (tdep->ppc_gp0_regnum + 1, &cf.cf_sp);
++
++ read_memory(cf.cf_sp, (gdb_byte *)&cf, sizeof(cf));
++ regcache->raw_supply (tdep->ppc_lr_regnum, &cf.cf_lr);
++ regcache->raw_supply (gdbarch_pc_regnum (gdbarch), &cf.cf_lr);
+
+ return 1;
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_ppc-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_ppc-nbsd-tdep.c
new file mode 100644
index 0000000000..6bf54339f3
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_ppc-nbsd-tdep.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- gdb/ppc-nbsd-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/ppc-nbsd-tdep.c
+@@ -195,7 +195,7 @@ _initialize_ppcnbsd_tdep (void)
+ ppcnbsd_init_abi);
+
+ /* Avoid initializing the register offsets again if they were
+- already initialized by ppcnbsd-nat.c. */
++ already initailized by ppcnbsd-nat.c. */
+ if (ppcnbsd_reg_offsets.pc_offset == 0)
+ {
+ /* General-purpose registers. */
diff --git a/gdb-netbsd/patches/patch-gdb_ppc-nbsd-tdep.h b/gdb-netbsd/patches/patch-gdb_ppc-nbsd-tdep.h
new file mode 100644
index 0000000000..a228346993
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_ppc-nbsd-tdep.h
@@ -0,0 +1,10 @@
+$NetBSD$
+
+--- gdb/ppc-nbsd-tdep.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/ppc-nbsd-tdep.h
+@@ -29,4 +29,4 @@ extern struct ppc_reg_offsets ppcnbsd_re
+ extern const struct regset ppcnbsd_gregset;
+ extern const struct regset ppcnbsd_fpregset;
+
+-#endif /* ppc-nbsd-tdep.h */
++#endif /* PPC_NBSD_TDEP_H */
diff --git a/gdb-netbsd/patches/patch-gdb_sh-nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_sh-nbsd-nat.c
new file mode 100644
index 0000000000..dcd9a534ec
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sh-nbsd-nat.c
@@ -0,0 +1,81 @@
+$NetBSD$
+
+--- gdb/sh-nbsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/sh-nbsd-nat.c
+@@ -29,8 +29,10 @@
+ #include "sh-tdep.h"
+ #include "inf-ptrace.h"
+ #include "regcache.h"
++#include "inf-ptrace.h"
++#include "nbsd-nat.h"
+
+-struct sh_nbsd_nat_target final : public inf_ptrace_target
++struct sh_nbsd_nat_target final : public nbsd_nat_target
+ {
+ void fetch_registers (struct regcache *, int) override;
+ void store_registers (struct regcache *, int) override;
+@@ -43,26 +45,27 @@ static sh_nbsd_nat_target the_sh_nbsd_na
+ (((regno) >= R0_REGNUM && (regno) <= (R0_REGNUM + 15)) \
+ || (regno) == gdbarch_pc_regnum (gdbarch) || (regno) == PR_REGNUM \
+ || (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \
+-|| (regno) == SR_REGNUM)
++|| (regno) == SR_REGNUM || (regno) == GBR_REGNUM)
+
+ /* Sizeof `struct reg' in <machine/reg.h>. */
+-#define SHNBSD_SIZEOF_GREGS (21 * 4)
++#define SHNBSD_SIZEOF_GREGS (22 * 4)
+
+ void
+ sh_nbsd_nat_target::fetch_registers (struct regcache *regcache, int regno)
+ {
+- pid_t pid = regcache->ptid ().pid ();
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+ if (regno == -1 || GETREGS_SUPPLIES (regcache->arch (), regno))
+ {
+- struct reg inferior_registers;
++ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid,
+- (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ sh_corefile_supply_regset (&sh_corefile_gregset, regcache, regno,
+- (char *) &inferior_registers,
++ (char *) ®s,
+ SHNBSD_SIZEOF_GREGS);
+
+ if (regno != -1)
+@@ -73,22 +76,22 @@ sh_nbsd_nat_target::fetch_registers (str
+ void
+ sh_nbsd_nat_target::store_registers (struct regcache *regcache, int regno)
+ {
+- pid_t pid = regcache->ptid ().pid ();
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+ if (regno == -1 || GETREGS_SUPPLIES (regcache->arch (), regno))
+ {
+- struct reg inferior_registers;
++ struct reg regs;
+
+- if (ptrace (PT_GETREGS, pid,
+- (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ sh_corefile_collect_regset (&sh_corefile_gregset, regcache, regno,
+- (char *) &inferior_registers,
++ (char *) ®s,
+ SHNBSD_SIZEOF_GREGS);
+
+- if (ptrace (PT_SETREGS, pid,
+- (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
++ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't set registers"));
+
+ if (regno != -1)
diff --git a/gdb-netbsd/patches/patch-gdb_sh-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_sh-nbsd-tdep.c
new file mode 100644
index 0000000000..eeba3725fa
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sh-nbsd-tdep.c
@@ -0,0 +1,197 @@
+$NetBSD$
+
+--- gdb/sh-nbsd-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/sh-nbsd-tdep.c
+@@ -21,17 +21,26 @@
+
+ #include "defs.h"
+ #include "gdbcore.h"
++#include "inferior.h"
++#include "regcache.h"
+ #include "regset.h"
+ #include "value.h"
+ #include "osabi.h"
+
+-#include "sh-tdep.h"
++#include "trad-frame.h"
++#include "tramp-frame.h"
++
++#include "common/gdb_assert.h"
+ #include "solib-svr4.h"
++#include "sh-tdep.h"
++#include "sh-nbsd-tdep.h"
++#include "nbsd-tdep.h"
++
+ #include "gdbarch.h"
+
+ /* Convert a register number into an offset into a ptrace
+ register structure. */
+-static const struct sh_corefile_regmap regmap[] =
++static const struct sh_corefile_regmap gregs_table[] =
+ {
+ {R0_REGNUM, 20 * 4},
+ {R0_REGNUM + 1, 19 * 4},
+@@ -54,9 +63,136 @@ static const struct sh_corefile_regmap r
+ {PR_REGNUM, 2 * 4},
+ {MACH_REGNUM, 3 * 4},
+ {MACL_REGNUM, 4 * 4},
++ {GBR_REGNUM, 21 * 4},
+ {-1 /* Terminator. */, 0}
+ };
++
++
++#define REGSx16(base) \
++ {(base), 0}, \
++ {(base) + 1, 4}, \
++ {(base) + 2, 8}, \
++ {(base) + 3, 12}, \
++ {(base) + 4, 16}, \
++ {(base) + 5, 20}, \
++ {(base) + 6, 24}, \
++ {(base) + 7, 28}, \
++ {(base) + 8, 32}, \
++ {(base) + 9, 36}, \
++ {(base) + 10, 40}, \
++ {(base) + 11, 44}, \
++ {(base) + 12, 48}, \
++ {(base) + 13, 52}, \
++ {(base) + 14, 56}, \
++ {(base) + 15, 60}
++
++/* Convert an FPU register number into an offset into a ptrace
++ register structure. */
++static const struct sh_corefile_regmap fpregs_table[] =
++{
++ REGSx16 (FR0_REGNUM),
++ /* XXX: REGSx16(XF0_REGNUM) omitted. */
++ {FPSCR_REGNUM, 128},
++ {FPUL_REGNUM, 132},
++ {-1 /* Terminator. */, 0}
++};
++
++
++/* From <machine/mcontext.h>. */
++static const int shnbsd_mc_reg_offset[] =
++{
++ (20 * 4), /* r0 */
++ (19 * 4), /* r1 */
++ (18 * 4), /* r2 */
++ (17 * 4), /* r3 */
++ (16 * 4), /* r4 */
++ (15 * 4), /* r5 */
++ (14 * 4), /* r6 */
++ (13 * 4), /* r7 */
++ (12 * 4), /* r8 */
++ (11 * 4), /* r9 */
++ (10 * 4), /* r10 */
++ ( 9 * 4), /* r11 */
++ ( 8 * 4), /* r12 */
++ ( 7 * 4), /* r13 */
++ ( 6 * 4), /* r14 */
++ (21 * 4), /* r15/sp */
++ ( 1 * 4), /* pc */
++ ( 5 * 4), /* pr */
++ ( 0 * 4), /* gbr */
++ -1,
++ ( 4 * 4), /* mach */
++ ( 3 * 4), /* macl */
++ ( 2 * 4), /* sr */
++};
++
++/* SH register sets. */
++
+
++static void
++shnbsd_sigtramp_cache_init (const struct tramp_frame *,
++ struct frame_info *,
++ struct trad_frame_cache *,
++ CORE_ADDR);
++
++/* The siginfo signal trampoline for NetBSD/sh3 versions 2.0 and later */
++static const struct tramp_frame shnbsd_sigtramp_si2 =
++{
++ SIGTRAMP_FRAME,
++ 2,
++ {
++ { 0x64f3, ULONGEST_MAX }, /* mov r15,r4 */
++ { 0xd002, ULONGEST_MAX }, /* mov.l .LSYS_setcontext */
++ { 0xc380, ULONGEST_MAX }, /* trapa #-128 */
++ { 0xa003, ULONGEST_MAX }, /* bra .Lskip1 */
++ { 0x0009, ULONGEST_MAX }, /* nop */
++ { 0x0009, ULONGEST_MAX }, /* nop */
++ /* .LSYS_setcontext */
++ { 0x0134, ULONGEST_MAX }, { 0x0000, ULONGEST_MAX }, /* 0x134 */
++ /* .Lskip1 */
++ { 0x6403, ULONGEST_MAX }, /* mov r0,r4 */
++ { 0xd002, ULONGEST_MAX }, /* mov.l .LSYS_exit */
++ { 0xc380, ULONGEST_MAX }, /* trapa #-128 */
++ { 0xa003, ULONGEST_MAX }, /* bra .Lskip2 */
++ { 0x0009, ULONGEST_MAX }, /* nop */
++ { 0x0009, ULONGEST_MAX }, /* nop */
++ /* .LSYS_exit */
++ { 0x0001, ULONGEST_MAX }, { 0x0000, ULONGEST_MAX }, /* 0x1 */
++/* .Lskip2 */
++ { TRAMP_SENTINEL_INSN, ULONGEST_MAX }
++ },
++ shnbsd_sigtramp_cache_init
++};
++
++static void
++shnbsd_sigtramp_cache_init (const struct tramp_frame *self,
++ struct frame_info *next_frame,
++ struct trad_frame_cache *this_cache,
++ CORE_ADDR func)
++{
++ struct gdbarch *gdbarch = get_frame_arch (next_frame);
++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
++ int sp_regnum = gdbarch_sp_regnum (gdbarch);
++ CORE_ADDR sp = get_frame_register_unsigned (next_frame, sp_regnum);
++ CORE_ADDR base;
++ const int *reg_offset;
++ int num_regs;
++ int i;
++
++ reg_offset = shnbsd_mc_reg_offset;
++ num_regs = ARRAY_SIZE (shnbsd_mc_reg_offset);
++ /* SP already points at the ucontext. */
++ base = sp;
++ /* offsetof(ucontext_t, uc_mcontext) == 36 */
++ base += 36;
++
++ for (i = 0; i < num_regs; i++)
++ if (reg_offset[i] != -1)
++ trad_frame_set_reg_addr (this_cache, i, base + reg_offset[i]);
++
++ /* Construct the frame ID using the function start. */
++ trad_frame_set_id (this_cache, frame_id_build (sp, func));
++}
+
+ static void
+ shnbsd_init_abi (struct gdbarch_info info,
+@@ -64,11 +200,16 @@ shnbsd_init_abi (struct gdbarch_info inf
+ {
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+- tdep->core_gregmap = (struct sh_corefile_regmap *)regmap;
+- tdep->sizeof_gregset = 84;
++ tdep->core_gregmap = (struct sh_corefile_regmap *)gregs_table;
++ tdep->sizeof_gregset = 88;
++
++ tdep->core_fpregmap = (struct sh_corefile_regmap *)fpregs_table;
++ tdep->sizeof_fpregset = 0; /* XXX */
+
+ set_solib_svr4_fetch_link_map_offsets
+- (gdbarch, svr4_ilp32_fetch_link_map_offsets);
++ (gdbarch, nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
++
++ tramp_frame_prepend_unwinder (gdbarch, &shnbsd_sigtramp_si2);
+ }
+
+ void
+@@ -76,6 +217,4 @@ _initialize_shnbsd_tdep (void)
+ {
+ gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_NETBSD,
+ shnbsd_init_abi);
+- gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_OPENBSD,
+- shnbsd_init_abi);
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_sh-nbsd-tdep.h b/gdb-netbsd/patches/patch-gdb_sh-nbsd-tdep.h
new file mode 100644
index 0000000000..765138b2b3
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sh-nbsd-tdep.h
@@ -0,0 +1,33 @@
+$NetBSD$
+
+--- gdb/sh-nbsd-tdep.h.orig 2019-09-02 20:02:23.509331057 +0000
++++ gdb/sh-nbsd-tdep.h
+@@ -0,0 +1,28 @@
++/* Target-dependent definitions for SuperH running NetBSD, for GDB.
++ Copyright (C) 2002 Free Software Foundation, Inc.
++ Contributed by Wasabi Systems, 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 2 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, write to the Free Software
++ Foundation, Inc., 51 Franklin Street, Fifth Floor,
++ Boston, MA 02110-1301, USA. */
++
++#ifndef SH_NBSD_TDEP_H
++#define SH_NBSD_TDEP_H
++
++void shnbsd_supply_reg (struct regcache *, const char *, int);
++void shnbsd_fill_reg (const struct regcache *, char *, int);
++
++#endif /* SH_NBSD_TDEP_H */
diff --git a/gdb-netbsd/patches/patch-gdb_sparc-nat.c b/gdb-netbsd/patches/patch-gdb_sparc-nat.c
new file mode 100644
index 0000000000..c8810537d5
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sparc-nat.c
@@ -0,0 +1,80 @@
+$NetBSD$
+
+--- gdb/sparc-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/sparc-nat.c
+@@ -138,6 +138,7 @@ sparc_fetch_inferior_registers (struct r
+ {
+ struct gdbarch *gdbarch = regcache->arch ();
+ pid_t pid;
++ int lwp = regcache->ptid ().lwp ();
+
+ /* NOTE: cagney/2002-12-03: This code assumes that the currently
+ selected light weight processes' registers can be written
+@@ -166,7 +167,7 @@ sparc_fetch_inferior_registers (struct r
+ {
+ gregset_t regs;
+
+- if (ptrace (PTRACE_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PTRACE_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ sparc_supply_gregset (sparc_gregmap, regcache, -1, ®s);
+@@ -178,7 +179,7 @@ sparc_fetch_inferior_registers (struct r
+ {
+ fpregset_t fpregs;
+
+- if (ptrace (PTRACE_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PTRACE_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ sparc_supply_fpregset (sparc_fpregmap, regcache, -1, &fpregs);
+@@ -190,6 +191,7 @@ sparc_store_inferior_registers (struct r
+ {
+ struct gdbarch *gdbarch = regcache->arch ();
+ pid_t pid;
++ int lwp = regcache->ptid ().lwp ();
+
+ /* NOTE: cagney/2002-12-02: See comment in fetch_inferior_registers
+ about threaded assumptions. */
+@@ -199,12 +201,12 @@ sparc_store_inferior_registers (struct r
+ {
+ gregset_t regs;
+
+- if (ptrace (PTRACE_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PTRACE_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ sparc_collect_gregset (sparc_gregmap, regcache, regnum, ®s);
+
+- if (ptrace (PTRACE_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PTRACE_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't write registers"));
+
+ /* Deal with the stack regs. */
+@@ -225,7 +227,7 @@ sparc_store_inferior_registers (struct r
+ {
+ fpregset_t fpregs, saved_fpregs;
+
+- if (ptrace (PTRACE_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ if (ptrace (PTRACE_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't get floating-point registers"));
+
+ memcpy (&saved_fpregs, &fpregs, sizeof (fpregs));
+@@ -238,7 +240,7 @@ sparc_store_inferior_registers (struct r
+ if (memcmp (&saved_fpregs, &fpregs, sizeof (fpregs)) != 0)
+ {
+ if (ptrace (PTRACE_SETFPREGS, pid,
+- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
++ (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
+ perror_with_name (_("Couldn't write floating-point registers"));
+ }
+
+@@ -252,7 +254,7 @@ sparc_store_inferior_registers (struct r
+ TARGET_OBJECT_WCOOKIE. Fetch StackGhost Per-Process XOR cookie. */
+
+ enum target_xfer_status
+-sparc_xfer_wcookie (struct target_ops *ops, enum target_object object,
++sparc_xfer_wcookie (enum target_object object,
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
+ ULONGEST *xfered_len)
diff --git a/gdb-netbsd/patches/patch-gdb_sparc-nat.h b/gdb-netbsd/patches/patch-gdb_sparc-nat.h
new file mode 100644
index 0000000000..9c8ba2ee94
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sparc-nat.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- gdb/sparc-nat.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/sparc-nat.h
+@@ -75,7 +75,7 @@ struct sparc_target : public BaseTarget
+ return sparc_xfer_wcookie (object, annex, readbuf, writebuf,
+ offset, len, xfered_len);
+
+- return BaseTarget (object, annex, readbuf, writebuf,
++ return BaseTarget::xfer_partial (object, annex, readbuf, writebuf,
+ offset, len, xfered_len);
+ }
+ };
diff --git a/gdb-netbsd/patches/patch-gdb_sparc-nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_sparc-nbsd-nat.c
new file mode 100644
index 0000000000..22540751c7
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sparc-nbsd-nat.c
@@ -0,0 +1,39 @@
+$NetBSD$
+
+--- gdb/sparc-nbsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/sparc-nbsd-nat.c
+@@ -21,13 +21,16 @@
+ #include "regcache.h"
+ #include "target.h"
+
++#include "nbsd-nat.h"
+ #include "sparc-tdep.h"
++#include "sparc-nbsd-tdep.h"
+ #include "sparc-nat.h"
+
+ /* Support for debugging kernel virtual memory images. */
+
+ #include <sys/types.h>
+ #include <machine/pcb.h>
++#include <machine/reg.h>
+
+ #include "bsd-kvm.h"
+
+@@ -55,7 +58,7 @@ sparc32nbsd_supply_pcb (struct regcache
+ return 1;
+ }
+
+-static sparc_target<inf_ptrace_target> the_sparc_nbsd_nat_target;
++static sparc_target<nbsd_nat_target> the_sparc_nbsd_nat_target;
+
+ void
+ _initialize_sparcnbsd_nat (void)
+@@ -63,7 +66,7 @@ _initialize_sparcnbsd_nat (void)
+ sparc_gregmap = &sparc32nbsd_gregmap;
+ sparc_fpregmap = &sparc32_bsd_fpregmap;
+
+- add_inf_child_target (&sparc_nbsd_nat_target);
++ add_inf_child_target (&the_sparc_nbsd_nat_target);
+
+ /* Support debugging kernel virtual memory images. */
+ bsd_kvm_add_target (sparc32nbsd_supply_pcb);
diff --git a/gdb-netbsd/patches/patch-gdb_sparc-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_sparc-nbsd-tdep.c
new file mode 100644
index 0000000000..2c7e45d722
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sparc-nbsd-tdep.c
@@ -0,0 +1,41 @@
+$NetBSD$
+
+--- gdb/sparc-nbsd-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/sparc-nbsd-tdep.c
+@@ -32,6 +32,7 @@
+ #include "gdbarch.h"
+
+ #include "sparc-tdep.h"
++#include "sparc-nbsd-tdep.h"
+ #include "nbsd-tdep.h"
+
+ /* Macros to extract fields from SPARC instructions. */
+@@ -291,7 +292,7 @@ static const struct regset sparc32nbsd_f
+ NULL, sparc32nbsd_supply_fpregset, NULL
+ };
+
+-void
++static void
+ sparc32nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ {
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+@@ -310,6 +311,12 @@ sparc32nbsd_init_abi (struct gdbarch_inf
+ tdep->step_trap = sparcnbsd_step_trap;
+
+ frame_unwind_append_unwinder (gdbarch, &sparc32nbsd_sigcontext_frame_unwind);
++}
++
++void
++sparc32nbsd_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
++{
++ sparc32nbsd_init_abi (info, gdbarch);
+
+ set_solib_svr4_fetch_link_map_offsets
+ (gdbarch, svr4_ilp32_fetch_link_map_offsets);
+@@ -319,5 +326,5 @@ void
+ _initialize_sparcnbsd_tdep (void)
+ {
+ gdbarch_register_osabi (bfd_arch_sparc, 0, GDB_OSABI_NETBSD,
+- sparc32nbsd_init_abi);
++ sparc32nbsd_elf_init_abi);
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_sparc-nbsd-tdep.h b/gdb-netbsd/patches/patch-gdb_sparc-nbsd-tdep.h
new file mode 100644
index 0000000000..5a0b8bd0f8
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sparc-nbsd-tdep.h
@@ -0,0 +1,40 @@
+$NetBSD$
+
+--- gdb/sparc-nbsd-tdep.h.orig 2019-09-02 20:02:23.510217820 +0000
++++ gdb/sparc-nbsd-tdep.h
+@@ -0,0 +1,35 @@
++/* Target-dependent definitions for sparc running NetBSD, for GDB.
++ Copyright (C) 2017 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 2 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, write to the Free Software
++ Foundation, Inc., 51 Franklin Street, Fifth Floor,
++ Boston, MA 02110-1301, USA. */
++
++#ifndef SPARC_NBSD_TDEP_H
++#define SPARC_NBSD_TDEP_H
++
++/* Register offsets for NetBSD. */
++extern const struct sparc_gregmap sparc32nbsd_gregmap;
++
++/* Return the address of a system call's alternative return
++ address. */
++extern CORE_ADDR sparcnbsd_step_trap (struct frame_info *frame,
++ unsigned long insn);
++
++extern struct trad_frame_saved_reg *
++ sparc32nbsd_sigcontext_saved_regs (struct frame_info *next_frame);
++
++#endif /* SPARC_NBSD_TDEP_H */
diff --git a/gdb-netbsd/patches/patch-gdb_sparc-tdep.h b/gdb-netbsd/patches/patch-gdb_sparc-tdep.h
new file mode 100644
index 0000000000..b43c35da85
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sparc-tdep.h
@@ -0,0 +1,25 @@
+$NetBSD$
+
+--- gdb/sparc-tdep.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/sparc-tdep.h
+@@ -252,20 +252,4 @@ extern const char *sparc_sol2_static_tra
+ extern void sparc32_sol2_init_abi (struct gdbarch_info info,
+ struct gdbarch *gdbarch);
+
+-/* Functions and variables exported from sparcnbsd-tdep.c. */
+-
+-/* Register offsets for NetBSD. */
+-extern const struct sparc_gregmap sparc32nbsd_gregmap;
+-
+-/* Return the address of a system call's alternative return
+- address. */
+-extern CORE_ADDR sparcnbsd_step_trap (struct frame_info *frame,
+- unsigned long insn);
+-
+-extern void sparc32nbsd_init_abi (struct gdbarch_info info,
+- struct gdbarch *gdbarch);
+-
+-extern struct trad_frame_saved_reg *
+- sparc32nbsd_sigcontext_saved_regs (struct frame_info *next_frame);
+-
+ #endif /* sparc-tdep.h */
diff --git a/gdb-netbsd/patches/patch-gdb_sparc64-nbsd-nat.c b/gdb-netbsd/patches/patch-gdb_sparc64-nbsd-nat.c
new file mode 100644
index 0000000000..bb2066b0a2
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sparc64-nbsd-nat.c
@@ -0,0 +1,36 @@
+$NetBSD$
+
+--- gdb/sparc64-nbsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/sparc64-nbsd-nat.c
+@@ -20,9 +20,13 @@
+ #include "defs.h"
+ #include "gdbcore.h"
+ #include "regcache.h"
++#include "inferior.h"
++#include "inf-ptrace.h"
+ #include "target.h"
+
++#include "nbsd-nat.h"
+ #include "sparc64-tdep.h"
++#include "sparc-nbsd-tdep.h"
+ #include "sparc-nat.h"
+
+ /* NetBSD is different from the other OSes that support both SPARC and
+@@ -106,8 +110,6 @@ sparc64nbsd_gregset_supplies_p (struct g
+ return 0;
+ }
+
+-/* Determine whether `fpregset_t' contains register REGNUM. */
+-
+ static int
+ sparc64nbsd_fpregset_supplies_p (struct gdbarch *gdbarch, int regnum)
+ {
+@@ -168,7 +170,7 @@ sparc64nbsd_supply_pcb (struct regcache
+ }
+
+ /* We've got nothing to add to the generic SPARC target. */
+-static sparc_target<inf_ptrace_target> the_sparc64_nbsd_nat_target;
++static sparc_target<nbsd_nat_target> the_sparc64_nbsd_nat_target;
+
+ void
+ _initialize_sparc64nbsd_nat (void)
diff --git a/gdb-netbsd/patches/patch-gdb_sparc64-nbsd-tdep.c b/gdb-netbsd/patches/patch-gdb_sparc64-nbsd-tdep.c
new file mode 100644
index 0000000000..16168be83f
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_sparc64-nbsd-tdep.c
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- gdb/sparc64-nbsd-tdep.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/sparc64-nbsd-tdep.c
+@@ -31,6 +31,7 @@
+ #include "trad-frame.h"
+
+ #include "sparc64-tdep.h"
++#include "sparc-nbsd-tdep.h"
+ #include "nbsd-tdep.h"
+
+ /* From <machine/reg.h>. */
diff --git a/gdb-netbsd/patches/patch-gdb_testsuite_gdb.ada_uninitialized__vars_parse__controlled.ads b/gdb-netbsd/patches/patch-gdb_testsuite_gdb.ada_uninitialized__vars_parse__controlled.ads
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-gdb_testsuite_gdb.base_testenv.c b/gdb-netbsd/patches/patch-gdb_testsuite_gdb.base_testenv.c
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-gdb_testsuite_lib_compiler.cc b/gdb-netbsd/patches/patch-gdb_testsuite_lib_compiler.cc
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-gdb_testsuite_lib_pdtrace.in b/gdb-netbsd/patches/patch-gdb_testsuite_lib_pdtrace.in
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-gdb_tui_tui-winsource.c b/gdb-netbsd/patches/patch-gdb_tui_tui-winsource.c
new file mode 100644
index 0000000000..c801c96bf6
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_tui_tui-winsource.c
@@ -0,0 +1,14 @@
+$NetBSD$
+
+--- gdb/tui/tui-winsource.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/tui/tui-winsource.c
+@@ -545,6 +545,9 @@ tui_erase_exec_info_content (struct tui_
+ {
+ struct tui_gen_win_info *exec_info = win_info->execution_info;
+
++ if (exec_info->handle == NULL)
++ return;
++
+ werase (exec_info->handle);
+ exec_info->refresh_window ();
+ }
diff --git a/gdb-netbsd/patches/patch-gdb_user-regs.c b/gdb-netbsd/patches/patch-gdb_user-regs.c
new file mode 100644
index 0000000000..7bd4d4c6d4
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_user-regs.c
@@ -0,0 +1,79 @@
+$NetBSD$
+
+--- gdb/user-regs.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/user-regs.c
+@@ -41,7 +41,7 @@
+ struct user_reg
+ {
+ const char *name;
+- struct value *(*read) (struct frame_info * frame, const void *baton);
++ struct value *(*xread) (struct frame_info * frame, const void *baton);
+ const void *baton;
+ struct user_reg *next;
+ };
+@@ -60,7 +60,7 @@ struct gdb_user_regs
+
+ static void
+ append_user_reg (struct gdb_user_regs *regs, const char *name,
+- user_reg_read_ftype *read, const void *baton,
++ user_reg_read_ftype *xread, const void *baton,
+ struct user_reg *reg)
+ {
+ /* The caller is responsible for allocating memory needed to store
+@@ -68,7 +68,7 @@ append_user_reg (struct gdb_user_regs *r
+ register list stored in the common heap or a specific obstack. */
+ gdb_assert (reg != NULL);
+ reg->name = name;
+- reg->read = read;
++ reg->xread = xread;
+ reg->baton = baton;
+ reg->next = NULL;
+ (*regs->last) = reg;
+@@ -82,10 +82,10 @@ static struct gdb_user_regs builtin_user
+ };
+
+ void
+-user_reg_add_builtin (const char *name, user_reg_read_ftype *read,
++user_reg_add_builtin (const char *name, user_reg_read_ftype *xread,
+ const void *baton)
+ {
+- append_user_reg (&builtin_user_regs, name, read, baton,
++ append_user_reg (&builtin_user_regs, name, xread, baton,
+ XNEW (struct user_reg));
+ }
+
+@@ -103,14 +103,14 @@ user_regs_init (struct gdbarch *gdbarch)
+
+ regs->last = ®s->first;
+ for (reg = builtin_user_regs.first; reg != NULL; reg = reg->next)
+- append_user_reg (regs, reg->name, reg->read, reg->baton,
++ append_user_reg (regs, reg->name, reg->xread, reg->baton,
+ GDBARCH_OBSTACK_ZALLOC (gdbarch, struct user_reg));
+ return regs;
+ }
+
+ void
+ user_reg_add (struct gdbarch *gdbarch, const char *name,
+- user_reg_read_ftype *read, const void *baton)
++ user_reg_read_ftype *xread, const void *baton)
+ {
+ struct gdb_user_regs *regs
+ = (struct gdb_user_regs *) gdbarch_data (gdbarch, user_regs_data);
+@@ -122,7 +122,7 @@ user_reg_add (struct gdbarch *gdbarch, c
+ regs = (struct gdb_user_regs *) user_regs_init (gdbarch);
+ deprecated_set_gdbarch_data (gdbarch, user_regs_data, regs);
+ }
+- append_user_reg (regs, name, read, baton,
++ append_user_reg (regs, name, xread, baton,
+ GDBARCH_OBSTACK_ZALLOC (gdbarch, struct user_reg));
+ }
+
+@@ -214,7 +214,7 @@ value_of_user_reg (int regnum, struct fr
+ struct user_reg *reg = usernum_to_user_reg (gdbarch, regnum - maxregs);
+
+ gdb_assert (reg != NULL);
+- return reg->read (frame, reg->baton);
++ return reg->xread (frame, reg->baton);
+ }
+
+ static void
diff --git a/gdb-netbsd/patches/patch-gdb_vax-bsd-nat.c b/gdb-netbsd/patches/patch-gdb_vax-bsd-nat.c
new file mode 100644
index 0000000000..c5a22f2db8
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_vax-bsd-nat.c
@@ -0,0 +1,80 @@
+$NetBSD$
+
+--- gdb/vax-bsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/vax-bsd-nat.c
+@@ -17,6 +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/>. */
+
++#ifndef _KERNTYPES
++#define _KERNTYPES
++#endif
+ #include "defs.h"
+ #include "inferior.h"
+ #include "regcache.h"
+@@ -29,7 +32,13 @@
+ #include "vax-tdep.h"
+ #include "inf-ptrace.h"
+
++#ifdef __NetBSD__
++#include "nbsd-nat.h"
++struct vax_bsd_nat_target final : public nbsd_nat_target
++#else
+ struct vax_bsd_nat_target final : public inf_ptrace_target
++#endif
++
+ {
+ void fetch_registers (struct regcache *, int) override;
+ void store_registers (struct regcache *, int) override;
+@@ -42,7 +51,7 @@ static vax_bsd_nat_target the_vax_bsd_na
+ static void
+ vaxbsd_supply_gregset (struct regcache *regcache, const void *gregs)
+ {
+- const gdb_byte *regs = gregs;
++ const gdb_byte *regs = (const gdb_byte *)gregs;
+ int regnum;
+
+ for (regnum = 0; regnum < VAX_NUM_REGS; regnum++)
+@@ -56,7 +65,7 @@ static void
+ vaxbsd_collect_gregset (const struct regcache *regcache,
+ void *gregs, int regnum)
+ {
+- gdb_byte *regs = gregs;
++ gdb_byte *regs = (gdb_byte *)gregs;
+ int i;
+
+ for (i = 0; i <= VAX_NUM_REGS; i++)
+@@ -74,9 +83,11 @@ void
+ vax_bsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
+ {
+ struct reg regs;
+- pid_t pid = regcache->ptid ().pid ();
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ vaxbsd_supply_gregset (regcache, ®s);
+@@ -89,14 +100,16 @@ void
+ vax_bsd_nat_target::store_registers (struct regcache *regcache, int regnum)
+ {
+ struct reg regs;
+- pid_t pid = regcache->ptid ().pid ();
++ ptid_t ptid = regcache->ptid ();
++ pid_t pid = ptid.pid ();
++ int lwp = ptid.lwp ();
+
+- if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ vaxbsd_collect_gregset (regcache, ®s, regnum);
+
+- if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1)
+ perror_with_name (_("Couldn't write registers"));
+ }
+
diff --git a/gdb-netbsd/patches/patch-gdb_x86-bsd-nat.c b/gdb-netbsd/patches/patch-gdb_x86-bsd-nat.c
new file mode 100644
index 0000000000..7332e37d89
--- /dev/null
+++ b/gdb-netbsd/patches/patch-gdb_x86-bsd-nat.c
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- gdb/x86-bsd-nat.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ gdb/x86-bsd-nat.c
+@@ -58,7 +58,7 @@ x86bsd_dr_get (ptid_t ptid, int regnum)
+ struct dbreg dbregs;
+
+ if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid),
+- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
++ (PTRACE_TYPE_ARG3) &dbregs, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't read debug registers"));
+
+ return DBREG_DRX ((&dbregs), regnum);
+@@ -70,7 +70,7 @@ x86bsd_dr_set (int regnum, unsigned long
+ struct dbreg dbregs;
+
+ if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid),
+- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
++ (PTRACE_TYPE_ARG3) &dbregs, inferior_ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't get debug registers"));
+
+ /* For some mysterious reason, some of the reserved bits in the
+@@ -83,7 +83,7 @@ x86bsd_dr_set (int regnum, unsigned long
+ for (thread_info *thread : current_inferior ()->non_exited_threads ())
+ {
+ if (ptrace (PT_SETDBREGS, get_ptrace_pid (thread->ptid),
+- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
++ (PTRACE_TYPE_ARG3) &dbregs, thread->ptid.lwp ()) == -1)
+ perror_with_name (_("Couldn't write debug registers"));
+ }
+ }
diff --git a/gdb-netbsd/patches/patch-include_elf_common.h b/gdb-netbsd/patches/patch-include_elf_common.h
new file mode 100644
index 0000000000..512691a0d6
--- /dev/null
+++ b/gdb-netbsd/patches/patch-include_elf_common.h
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- include/elf/common.h.orig 2019-07-16 00:00:27.000000000 +0000
++++ include/elf/common.h
+@@ -686,6 +686,7 @@
+ must start with "NetBSD-CORE". */
+
+ #define NT_NETBSDCORE_PROCINFO 1 /* Has a struct procinfo */
++#define NT_NETBSDCORE_AUXV 2 /* Has a copy of Elfxx_auxv_t */
+ #define NT_NETBSDCORE_FIRSTMACH 32 /* start of machdep note types */
+
+
diff --git a/gdb-netbsd/patches/patch-include_elf_epiphany.h b/gdb-netbsd/patches/patch-include_elf_epiphany.h
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-include_opcode_bfin.h b/gdb-netbsd/patches/patch-include_opcode_bfin.h
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-intl_Makefile.in b/gdb-netbsd/patches/patch-intl_Makefile.in
new file mode 100644
index 0000000000..6860182fe9
--- /dev/null
+++ b/gdb-netbsd/patches/patch-intl_Makefile.in
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- intl/Makefile.in.orig 2019-07-16 00:00:27.000000000 +0000
++++ intl/Makefile.in
+@@ -133,8 +133,10 @@ libintl.h: $(srcdir)/libgnuintl.h
+ $(COMPILE) $<
+
+ .y.c:
+- $(YACC) $(YFLAGS) --output $@ $<
+- rm -f $*.h
++ @echo "Not rebuilding yacc output"
++ cp -p $(srcdir)/$@ $@
++# $(YACC) $(YFLAGS) --output $@ $<
++# rm -f $*.h
+
+ INCLUDES = -I. -I$(srcdir)
+
diff --git a/gdb-netbsd/patches/patch-libiberty_make-temp-file.c b/gdb-netbsd/patches/patch-libiberty_make-temp-file.c
new file mode 100644
index 0000000000..4b6a8b6373
--- /dev/null
+++ b/gdb-netbsd/patches/patch-libiberty_make-temp-file.c
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- libiberty/make-temp-file.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ libiberty/make-temp-file.c
+@@ -129,10 +129,10 @@ choose_tmpdir (void)
+ base = try_dir (P_tmpdir, base);
+ #endif
+
+- /* Try /var/tmp, /usr/tmp, then /tmp. */
++ /* Try /tmp, /var/tmp, then /usr/tmp. */
++ base = try_dir (tmp, base);
+ base = try_dir (vartmp, base);
+ base = try_dir (usrtmp, base);
+- base = try_dir (tmp, base);
+
+ /* If all else fails, use the current directory! */
+ if (base == 0)
diff --git a/gdb-netbsd/patches/patch-libiberty_strerror.c b/gdb-netbsd/patches/patch-libiberty_strerror.c
new file mode 100644
index 0000000000..833efd3d1f
--- /dev/null
+++ b/gdb-netbsd/patches/patch-libiberty_strerror.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- libiberty/strerror.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ libiberty/strerror.c
+@@ -347,7 +347,7 @@ static const struct error_info error_tab
+ ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"),
+ #endif
+ #if defined (ENOPROTOOPT)
+- ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"),
++ ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol option not available"),
+ #endif
+ #if defined (EPROTONOSUPPORT)
+ ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"),
diff --git a/gdb-netbsd/patches/patch-opcodes_cgen.sh b/gdb-netbsd/patches/patch-opcodes_cgen.sh
new file mode 100644
index 0000000000..85fc124db1
--- /dev/null
+++ b/gdb-netbsd/patches/patch-opcodes_cgen.sh
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- opcodes/cgen.sh.orig 2019-07-16 00:00:27.000000000 +0000
++++ opcodes/cgen.sh
+@@ -61,6 +61,7 @@ shift ; options=$9
+ shift ; extrafiles=$9
+
+ rootdir=${srcdir}/..
++move_if_change="${CONFIG_SHELL:-/bin/sh} ${rootdir}/move-if-change"
+
+ # $arch is $6, as passed on the command line.
+ # $ARCH is the same argument but in all uppercase.
diff --git a/gdb-netbsd/patches/patch-readline_display.c b/gdb-netbsd/patches/patch-readline_display.c
new file mode 100644
index 0000000000..92d9e4d384
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_display.c
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- readline/display.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ readline/display.c
+@@ -47,6 +47,7 @@
+
+ /* System-specific feature definitions and include files. */
+ #include "rldefs.h"
++#include "rltty.h"
+ #include "rlmbutil.h"
+
+ /* Termcap library stuff. */
diff --git a/gdb-netbsd/patches/patch-readline_doc_texi2dvi b/gdb-netbsd/patches/patch-readline_doc_texi2dvi
new file mode 100644
index 0000000000..026dc0c016
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_doc_texi2dvi
@@ -0,0 +1,6 @@
+Cannot strip away RCS IDs, please handle manually!
+These are the matching lines:
+ -# $Id$
+ -rcs_revision='$Revision$'
+Setting PKGDIFF_FMT might help.
+Otherwise you may need to run diff by hand.
diff --git a/gdb-netbsd/patches/patch-readline_doc_texi2html b/gdb-netbsd/patches/patch-readline_doc_texi2html
new file mode 100644
index 0000000000..34b3a27fe0
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_doc_texi2html
@@ -0,0 +1,7 @@
+Cannot strip away RCS IDs, please handle manually!
+These are the matching lines:
+ -# $Id$
+ -# $Id$
+ -# $Id$
+Setting PKGDIFF_FMT might help.
+Otherwise you may need to run diff by hand.
diff --git a/gdb-netbsd/patches/patch-readline_examples_readlinebuf.h b/gdb-netbsd/patches/patch-readline_examples_readlinebuf.h
new file mode 100644
index 0000000000..29139b69ed
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_examples_readlinebuf.h
@@ -0,0 +1,7 @@
+Cannot strip away RCS IDs, please handle manually!
+These are the matching lines:
+ - * $Revision$
+ - * $Date$
+ - * $Author$
+Setting PKGDIFF_FMT might help.
+Otherwise you may need to run diff by hand.
diff --git a/gdb-netbsd/patches/patch-readline_examples_rlfe_config.h.in b/gdb-netbsd/patches/patch-readline_examples_rlfe_config.h.in
new file mode 100644
index 0000000000..961ed9ed1e
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_examples_rlfe_config.h.in
@@ -0,0 +1,5 @@
+Cannot strip away RCS IDs, please handle manually!
+These are the matching lines:
+ - * $Id$ FAU
+Setting PKGDIFF_FMT might help.
+Otherwise you may need to run diff by hand.
diff --git a/gdb-netbsd/patches/patch-readline_examples_rlfe_extern.h b/gdb-netbsd/patches/patch-readline_examples_rlfe_extern.h
new file mode 100644
index 0000000000..961ed9ed1e
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_examples_rlfe_extern.h
@@ -0,0 +1,5 @@
+Cannot strip away RCS IDs, please handle manually!
+These are the matching lines:
+ - * $Id$ FAU
+Setting PKGDIFF_FMT might help.
+Otherwise you may need to run diff by hand.
diff --git a/gdb-netbsd/patches/patch-readline_examples_rlfe_os.h b/gdb-netbsd/patches/patch-readline_examples_rlfe_os.h
new file mode 100644
index 0000000000..961ed9ed1e
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_examples_rlfe_os.h
@@ -0,0 +1,5 @@
+Cannot strip away RCS IDs, please handle manually!
+These are the matching lines:
+ - * $Id$ FAU
+Setting PKGDIFF_FMT might help.
+Otherwise you may need to run diff by hand.
diff --git a/gdb-netbsd/patches/patch-readline_rltty.c b/gdb-netbsd/patches/patch-readline_rltty.c
new file mode 100644
index 0000000000..4fcb9590e1
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_rltty.c
@@ -0,0 +1,16 @@
+$NetBSD$
+
+--- readline/rltty.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ readline/rltty.c
+@@ -37,9 +37,9 @@
+
+ #include "rldefs.h"
+
+-#if defined (GWINSZ_IN_SYS_IOCTL)
++#if defined (HAVE_SYS_IOCTL_H)
+ # include <sys/ioctl.h>
+-#endif /* GWINSZ_IN_SYS_IOCTL */
++#endif /* HAVE_SYS_IOCTL_H */
+
+ #include "rltty.h"
+ #include "readline.h"
diff --git a/gdb-netbsd/patches/patch-readline_support_config.guess b/gdb-netbsd/patches/patch-readline_support_config.guess
new file mode 100644
index 0000000000..b909041e95
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_support_config.guess
@@ -0,0 +1,24 @@
+$NetBSD$
+
+--- readline/support/config.guess.orig 2019-07-16 00:00:27.000000000 +0000
++++ readline/support/config.guess
+@@ -1297,6 +1297,9 @@ EOF
+ x86_64:Haiku:*:*)
+ echo x86_64-unknown-haiku
+ exit ;;
++ x86_64:Haiku:*:*)
++ echo x86_64-unknown-haiku
++ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux"$UNAME_RELEASE"
+ exit ;;
+@@ -1318,6 +1321,9 @@ EOF
+ SX-ACE:SUPER-UX:*:*)
+ echo sxace-nec-superux"$UNAME_RELEASE"
+ exit ;;
++ SX-ACE:SUPER-UX:*:*)
++ echo sxace-nec-superux${UNAME_RELEASE}
++ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody"$UNAME_RELEASE"
+ exit ;;
diff --git a/gdb-netbsd/patches/patch-readline_support_config.sub b/gdb-netbsd/patches/patch-readline_support_config.sub
new file mode 100644
index 0000000000..357d9406f7
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_support_config.sub
@@ -0,0 +1,35 @@
+$NetBSD$
+
+--- readline/support/config.sub.orig 2019-07-16 00:00:27.000000000 +0000
++++ readline/support/config.sub
+@@ -1125,6 +1125,9 @@ case $cpu-$vendor in
+ cpu=neo
+ vendor=tandem
+ ;;
++ neo-tandem)
++ basic_machine=neo-tandem
++ ;;
+ nse-tandem)
+ cpu=nse
+ vendor=tandem
+@@ -1512,6 +1515,10 @@ case $os in
+ ;;
+ ios)
+ ;;
++ z80-*-coff)
++ basic_machine=z80-unknown
++ os=-sim
++ ;;
+ none)
+ ;;
+ *-eabi)
+@@ -1613,6 +1620,9 @@ case $cpu-$vendor in
+ pru-*)
+ os=elf
+ ;;
++ pru-*)
++ os=-elf
++ ;;
+ *-be)
+ os=beos
+ ;;
diff --git a/gdb-netbsd/patches/patch-readline_terminal.c b/gdb-netbsd/patches/patch-readline_terminal.c
new file mode 100644
index 0000000000..285735697f
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_terminal.c
@@ -0,0 +1,15 @@
+$NetBSD$
+
+--- readline/terminal.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ readline/terminal.c
+@@ -32,6 +32,10 @@
+ # include <sys/file.h>
+ #endif /* HAVE_SYS_FILE_H */
+
++#if defined (HAVE_SYS_IOCTL_H)
++#include <sys/ioctl.h>
++#endif /* HAVE_SYS_IOCTL_H */
++
+ #if defined (HAVE_UNISTD_H)
+ # include <unistd.h>
+ #endif /* HAVE_UNISTD_H */
diff --git a/gdb-netbsd/patches/patch-readline_util.c b/gdb-netbsd/patches/patch-readline_util.c
new file mode 100644
index 0000000000..619f017d8d
--- /dev/null
+++ b/gdb-netbsd/patches/patch-readline_util.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- readline/util.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ readline/util.c
+@@ -517,7 +517,7 @@ _rl_tropen ()
+ : "."),
+ getpid ());
+ #else
+- sprintf (fnbuf, "/var/tmp/rltrace.%ld", (long) getpid ());
++ snprintf (fnbuf, sizeof(fnbuf), "/var/tmp/rltrace.%ld", (long)getpid());
+ #endif
+ unlink (fnbuf);
+ _rl_tracefp = fopen (fnbuf, "w+");
diff --git a/gdb-netbsd/patches/patch-sim_common_callback.c b/gdb-netbsd/patches/patch-sim_common_callback.c
new file mode 100644
index 0000000000..391bb030c1
--- /dev/null
+++ b/gdb-netbsd/patches/patch-sim_common_callback.c
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- sim/common/callback.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ sim/common/callback.c
+@@ -424,7 +424,11 @@ os_system (host_callback *p, const char
+ static long
+ os_time (host_callback *p, long *t)
+ {
+- return wrap (p, time (t));
++ long v = (long)time(NULL);
++
++ if (t != NULL)
++ *t = v;
++ return wrap (p, v);
+ }
+
+
diff --git a/gdb-netbsd/patches/patch-sim_common_cgen.sh b/gdb-netbsd/patches/patch-sim_common_cgen.sh
new file mode 100644
index 0000000000..f81cd3ed16
--- /dev/null
+++ b/gdb-netbsd/patches/patch-sim_common_cgen.sh
@@ -0,0 +1,110 @@
+$NetBSD$
+
+--- sim/common/cgen.sh.orig 2019-07-16 00:00:27.000000000 +0000
++++ sim/common/cgen.sh
+@@ -29,6 +29,7 @@ shift ; extrafiles=$9
+ shift ; opcfile=$9
+
+ rootdir=${srcdir}/../..
++move_if_change="${CONFIG_SHELL:-/bin/sh} ${rootdir}/move-if-change"
+
+ test -z "${opcfile}" && opcfile=/dev/null
+
+@@ -70,11 +71,11 @@ arch)
+ -B ${tmp}-arch.c1 \
+ -N ${tmp}-all.h1
+ sed $sedscript < ${tmp}-arch.h1 > ${tmp}-arch.h
+- ${rootdir}/move-if-change ${tmp}-arch.h ${srcdir}/arch.h
++ ${move_if_change} ${tmp}-arch.h ${srcdir}/arch.h
+ sed $sedscript < ${tmp}-arch.c1 > ${tmp}-arch.c
+- ${rootdir}/move-if-change ${tmp}-arch.c ${srcdir}/arch.c
++ ${move_if_change} ${tmp}-arch.c ${srcdir}/arch.c
+ sed $sedscript < ${tmp}-all.h1 > ${tmp}-all.h
+- ${rootdir}/move-if-change ${tmp}-all.h ${srcdir}/cpuall.h
++ ${move_if_change} ${tmp}-all.h ${srcdir}/cpuall.h
+
+ rm -f ${tmp}-arch.h1 ${tmp}-arch.c1 ${tmp}-all.h1
+ ;;
+@@ -136,11 +137,11 @@ cpu | decode | cpu-decode)
+ case $action in
+ *cpu*)
+ sed $sedscript < ${tmp}-cpu.h1 > ${tmp}-cpu.h
+- ${rootdir}/move-if-change ${tmp}-cpu.h ${srcdir}/cpu${suffix}.h
++ ${move_if_change} ${tmp}-cpu.h ${srcdir}/cpu${suffix}.h
+ sed $sedscript < ${tmp}-cpu.c1 > ${tmp}-cpu.c
+- ${rootdir}/move-if-change ${tmp}-cpu.c ${srcdir}/cpu${suffix}.c
++ ${move_if_change} ${tmp}-cpu.c ${srcdir}/cpu${suffix}.c
+ sed $sedscript < ${tmp}-mod.c1 > ${tmp}-mod.c
+- ${rootdir}/move-if-change ${tmp}-mod.c ${srcdir}/model${suffix}.c
++ ${move_if_change} ${tmp}-mod.c ${srcdir}/model${suffix}.c
+ rm -f ${tmp}-cpu.h1 ${tmp}-cpu.c1 ${tmp}-mod.c1
+ ;;
+ esac
+@@ -148,36 +149,36 @@ cpu | decode | cpu-decode)
+ case $action in
+ *decode*)
+ sed $sedscript < ${tmp}-dec.h1 > ${tmp}-dec.h
+- ${rootdir}/move-if-change ${tmp}-dec.h ${srcdir}/decode${suffix}.h
++ ${move_if_change} ${tmp}-dec.h ${srcdir}/decode${suffix}.h
+ sed $sedscript < ${tmp}-dec.c1 > ${tmp}-dec.c
+- ${rootdir}/move-if-change ${tmp}-dec.c ${srcdir}/decode${suffix}.c
++ ${move_if_change} ${tmp}-dec.c ${srcdir}/decode${suffix}.c
+ rm -f ${tmp}-dec.h1 ${tmp}-dec.c1
+ ;;
+ esac
+
+ if test -f ${tmp}-ext.c1 ; then \
+ sed $sedscript < ${tmp}-ext.c1 > ${tmp}-ext.c ; \
+- ${rootdir}/move-if-change ${tmp}-ext.c ${srcdir}/extract${suffix}.c ; \
++ ${move_if_change} ${tmp}-ext.c ${srcdir}/extract${suffix}.c ; \
+ rm -f ${tmp}-ext.c1
+ fi
+ if test -f ${tmp}-read.c1 ; then \
+ sed $sedscript < ${tmp}-read.c1 > ${tmp}-read.c ; \
+- ${rootdir}/move-if-change ${tmp}-read.c ${srcdir}/read${suffix}.c ; \
++ ${move_if_change} ${tmp}-read.c ${srcdir}/read${suffix}.c ; \
+ rm -f ${tmp}-read.c1
+ fi
+ if test -f ${tmp}-write.c1 ; then \
+ sed $sedscript < ${tmp}-write.c1 > ${tmp}-write.c ; \
+- ${rootdir}/move-if-change ${tmp}-write.c ${srcdir}/write${suffix}.c ; \
++ ${move_if_change} ${tmp}-write.c ${srcdir}/write${suffix}.c ; \
+ rm -f ${tmp}-write.c1
+ fi
+ if test -f ${tmp}-sem.c1 ; then \
+ sed $sedscript < ${tmp}-sem.c1 > ${tmp}-sem.c ; \
+- ${rootdir}/move-if-change ${tmp}-sem.c ${srcdir}/sem${suffix}.c ; \
++ ${move_if_change} ${tmp}-sem.c ${srcdir}/sem${suffix}.c ; \
+ rm -f ${tmp}-sem.c1
+ fi
+ if test -f ${tmp}-semsw.c1 ; then \
+ sed $sedscript < ${tmp}-semsw.c1 > ${tmp}-semsw.c ; \
+- ${rootdir}/move-if-change ${tmp}-semsw.c ${srcdir}/sem${suffix}-switch.c ; \
++ ${move_if_change} ${tmp}-semsw.c ${srcdir}/sem${suffix}-switch.c ; \
+ rm -f ${tmp}-semsw.c1
+ fi
+
+@@ -195,7 +196,7 @@ defs)
+ -i ${isa} \
+ -G ${tmp}-defs.h1
+ sed $sedscript < ${tmp}-defs.h1 > ${tmp}-defs.h
+- ${rootdir}/move-if-change ${tmp}-defs.h ${srcdir}/defs${suffix}.h
++ ${move_if_change} ${tmp}-defs.h ${srcdir}/defs${suffix}.h
+ rm -f ${tmp}-defs.h1
+ ;;
+
+@@ -216,11 +217,11 @@ desc)
+ -C ${tmp}-desc.c1 \
+ -O ${tmp}-opc.h1
+ sed $sedscript < ${tmp}-desc.h1 > ${tmp}-desc.h
+- ${rootdir}/move-if-change ${tmp}-desc.h ${srcdir}/${arch}-desc.h
++ ${move_if_change} ${tmp}-desc.h ${srcdir}/${arch}-desc.h
+ sed $sedscript < ${tmp}-desc.c1 > ${tmp}-desc.c
+- ${rootdir}/move-if-change ${tmp}-desc.c ${srcdir}/${arch}-desc.c
++ ${move_if_change} ${tmp}-desc.c ${srcdir}/${arch}-desc.c
+ sed $sedscript < ${tmp}-opc.h1 > ${tmp}-opc.h
+- ${rootdir}/move-if-change ${tmp}-opc.h ${srcdir}/${arch}-opc.h
++ ${move_if_change} ${tmp}-opc.h ${srcdir}/${arch}-opc.h
+
+ rm -f ${tmp}-desc.h1 ${tmp}-desc.c1 ${tmp}-opc.h1
+ ;;
diff --git a/gdb-netbsd/patches/patch-sim_common_genmloop.sh b/gdb-netbsd/patches/patch-sim_common_genmloop.sh
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-sim_common_gennltvals.sh b/gdb-netbsd/patches/patch-sim_common_gennltvals.sh
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-sim_common_gentvals.sh b/gdb-netbsd/patches/patch-sim_common_gentvals.sh
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-sim_configure b/gdb-netbsd/patches/patch-sim_configure
new file mode 100644
index 0000000000..aaf7bd8e1e
--- /dev/null
+++ b/gdb-netbsd/patches/patch-sim_configure
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- sim/configure.orig 2019-07-16 00:00:27.000000000 +0000
++++ sim/configure
+@@ -3852,7 +3852,7 @@ subdirs="$subdirs aarch64"
+
+
+ ;;
+- sh64*-*-*)
++ sh64*-*-* | sh5*-*-*)
+
+ sim_arch=sh64
+ subdirs="$subdirs sh64"
diff --git a/gdb-netbsd/patches/patch-sim_cr16_configure b/gdb-netbsd/patches/patch-sim_cr16_configure
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-sim_ft32_configure b/gdb-netbsd/patches/patch-sim_ft32_configure
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-sim_lm32_ChangeLog b/gdb-netbsd/patches/patch-sim_lm32_ChangeLog
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-sim_microblaze_configure b/gdb-netbsd/patches/patch-sim_microblaze_configure
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-sim_mips_Makefile.in b/gdb-netbsd/patches/patch-sim_mips_Makefile.in
new file mode 100644
index 0000000000..d02d43bb9f
--- /dev/null
+++ b/gdb-netbsd/patches/patch-sim_mips_Makefile.in
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- sim/mips/Makefile.in.orig 2019-07-16 00:00:27.000000000 +0000
++++ sim/mips/Makefile.in
+@@ -152,7 +152,7 @@ BUILT_SRC_FROM_IGEN = \
+ $(BUILT_SRC_FROM_IGEN): tmp-igen
+
+ tmp-igen: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
+- cd ../igen && $(MAKE)
++# cd ../igen && $(MAKE)
+ ../igen/igen \
+ $(IGEN_TRACE) \
+ -I $(srcdir) \
diff --git a/gdb-netbsd/patches/patch-sim_mn10300_Makefile.in b/gdb-netbsd/patches/patch-sim_mn10300_Makefile.in
new file mode 100644
index 0000000000..835baaaddf
--- /dev/null
+++ b/gdb-netbsd/patches/patch-sim_mn10300_Makefile.in
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- sim/mn10300/Makefile.in.orig 2019-07-16 00:00:27.000000000 +0000
++++ sim/mn10300/Makefile.in
+@@ -72,7 +72,7 @@ IGEN_TRACE= # -G omit-line-numbers # -G
+ IGEN_INSN=$(srcdir)/mn10300.igen $(srcdir)/am33.igen $(srcdir)/am33-2.igen
+ IGEN_DC=$(srcdir)/mn10300.dc
+ tmp-igen: $(IGEN_INSN) $(IGEN_DC) ../igen/igen
+- cd ../igen && $(MAKE)
++# cd ../igen && $(MAKE)
+ ../igen/igen \
+ $(IGEN_TRACE) \
+ -G gen-direct-access \
diff --git a/gdb-netbsd/patches/patch-sim_moxie_configure b/gdb-netbsd/patches/patch-sim_moxie_configure
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-sim_ppc_emul__netbsd.c b/gdb-netbsd/patches/patch-sim_ppc_emul__netbsd.c
new file mode 100644
index 0000000000..8260431d34
--- /dev/null
+++ b/gdb-netbsd/patches/patch-sim_ppc_emul__netbsd.c
@@ -0,0 +1,539 @@
+$NetBSD$
+
+--- sim/ppc/emul_netbsd.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ sim/ppc/emul_netbsd.c
+@@ -41,6 +41,7 @@
+ #include <stdio.h>
+ #include <signal.h>
+ #include <fcntl.h>
++#include <dirent.h>
+ #include <errno.h>
+ #include <sys/param.h>
+ #include <sys/time.h>
+@@ -783,7 +784,7 @@ do_gettimeofday(os_emul_data *emul,
+ if (WITH_TRACE && ppc_trace[trace_os_emul])
+ printf_filtered ("0x%lx, 0x%lx", (long)t_addr, (long)tz_addr);
+
+- SYS(gettimeofday);
++ SYS(__gettimeofday50);
+ emul_write_status(processor, status, err);
+ if (status == 0) {
+ if (t_addr != 0)
+@@ -813,7 +814,7 @@ do_getrusage(os_emul_data *emul,
+ if (WITH_TRACE && ppc_trace[trace_os_emul])
+ printf_filtered ("%d, 0x%lx", who, (long)rusage_addr);
+
+- SYS(getrusage);
++ SYS(__getrusage50);
+ emul_write_status(processor, status, err);
+ if (status == 0) {
+ if (rusage_addr != 0)
+@@ -1090,21 +1091,21 @@ static emul_syscall_descriptor netbsd_de
+ /* 4 */ { do_write, "write" },
+ /* 5 */ { do_open, "open" },
+ /* 6 */ { do_close, "close" },
+- /* 7 */ { 0, "wait4" },
++ { 0, }, /* 7 is old wait4 */
+ { 0, }, /* 8 is old creat */
+ /* 9 */ { 0, "link" },
+ /* 10 */ { 0, "unlink" },
+ { 0, }, /* 11 is obsolete execv */
+ /* 12 */ { 0, "chdir" },
+ /* 13 */ { 0, "fchdir" },
+- /* 14 */ { 0, "mknod" },
++ { 0, }, /* 14 is old mknod */
+ /* 15 */ { 0, "chmod" },
+ /* 16 */ { 0, "chown" },
+ /* 17 */ { do_break, "break" },
+- /* 18 */ { 0, "getfsstat" },
++ { 0, }, /* 18 is old getfsstat */
+ { 0, }, /* 19 is old lseek */
+ /* 20 */ { do_getpid, "getpid" },
+- /* 21 */ { 0, "mount" },
++ { 0, }, /* 21 is old mount */
+ /* 22 */ { 0, "unmount" },
+ /* 23 */ { 0, "setuid" },
+ /* 24 */ { do_getuid, "getuid" },
+@@ -1129,16 +1130,16 @@ static emul_syscall_descriptor netbsd_de
+ /* 43 */ { do_getegid, "getegid" },
+ /* 44 */ { 0, "profil" },
+ /* 45 */ { 0, "ktrace" },
+- /* 46 */ { 0, "sigaction" },
++ { 0, }, /* 46 is old sigaction */
+ /* 47 */ { do_getgid, "getgid" },
+- /* 48 */ { do_sigprocmask, "sigprocmask" },
++ { 0, }, /* 48 is old sigprocmask */
+ /* 49 */ { 0, "getlogin" },
+ /* 50 */ { 0, "setlogin" },
+ /* 51 */ { 0, "acct" },
+- /* 52 */ { 0, "sigpending" },
+- /* 53 */ { 0, "sigaltstack" },
++ { 0, }, /* 52 is old sigpending */
++ { 0, }, /* 53 is old sigaltstack */
+ /* 54 */ { do_ioctl, "ioctl" },
+- /* 55 */ { 0, "reboot" },
++ { 0, }, /* 55 is old reboot */
+ /* 56 */ { 0, "revoke" },
+ /* 57 */ { 0, "symlink" },
+ /* 58 */ { 0, "readlink" },
+@@ -1148,14 +1149,14 @@ static emul_syscall_descriptor netbsd_de
+ { 0, }, /* 62 is old fstat */
+ { 0, }, /* 63 is old getkerninfo */
+ { 0, }, /* 64 is old getpagesize */
+- /* 65 */ { 0, "msync" },
++ { 0, }, /* 65 is old msync */
+ /* 66 */ { 0, "vfork" },
+ { 0, }, /* 67 is obsolete vread */
+ { 0, }, /* 68 is obsolete vwrite */
+ /* 69 */ { 0, "sbrk" },
+- /* 70 */ { 0, "sstk" },
++ { 0, }, /* 70 is obsolete sstk */
+ { 0, }, /* 71 is old mmap */
+- /* 72 */ { 0, "vadvise" },
++ { 0, }, /* 72 is obsolete vadvise */
+ /* 73 */ { 0, "munmap" },
+ /* 74 */ { 0, "mprotect" },
+ /* 75 */ { 0, "madvise" },
+@@ -1166,27 +1167,27 @@ static emul_syscall_descriptor netbsd_de
+ /* 80 */ { 0, "setgroups" },
+ /* 81 */ { 0, "getpgrp" },
+ /* 82 */ { 0, "setpgid" },
+- /* 83 */ { 0, "setitimer" },
++ { 0, }, /* 83 is old setitimer */
+ { 0, }, /* 84 is old wait */
+- /* 85 */ { 0, "swapon" },
+- /* 86 */ { 0, "getitimer" },
++ { 0, }, /* 85 is old swapon */
++ { 0, }, /* 86 is old getitimer */
+ { 0, }, /* 87 is old gethostname */
+ { 0, }, /* 88 is old sethostname */
+ { 0, }, /* 89 is old getdtablesize */
+ { do_dup2, "dup2" },
+ { 0, }, /* 91 */
+ /* 92 */ { do_fcntl, "fcntl" },
+- /* 93 */ { 0, "select" },
++ { 0, }, /* 93 is old select */
+ { 0, }, /* 94 */
+ /* 95 */ { 0, "fsync" },
+ /* 96 */ { 0, "setpriority" },
+- /* 97 */ { 0, "socket" },
+- /* 98 */ { 0, "connect" },
++ { 0, }, /* 97 is old socket */
++ { 0, }, /* 98 is old connect */
+ { 0, }, /* 99 is old accept */
+ /* 100 */ { 0, "getpriority" },
+ { 0, }, /* 101 is old send */
+ { 0, }, /* 102 is old recv */
+- /* 103 */ { 0, "sigreturn" },
++ { 0, }, /* 103 is old sigreturn */
+ /* 104 */ { 0, "bind" },
+ /* 105 */ { 0, "setsockopt" },
+ /* 106 */ { 0, "listen" },
+@@ -1194,23 +1195,25 @@ static emul_syscall_descriptor netbsd_de
+ { 0, }, /* 108 is old sigvec */
+ { 0, }, /* 109 is old sigblock */
+ { 0, }, /* 110 is old sigsetmask */
+- /* 111 */ { 0, "sigsuspend" },
++ { 0, }, /* 111 is old sigsuspend */
+ { 0, }, /* 112 is old sigstack */
+ { 0, }, /* 113 is old recvmsg */
+ { 0, }, /* 114 is old sendmsg */
+ /* - is obsolete vtrace */ { 0, "vtrace 115" },
+- /* 116 */ { do_gettimeofday, "gettimeofday" },
+- /* 117 */ { do_getrusage, "getrusage" },
++ { 0, }, /* 116 is old gettimeofday */
++ { 0, }, /* 117 is old getrusage */
+ /* 118 */ { 0, "getsockopt" },
+- /* 119 */ { 0, "resuba" },
++ /* - is obsolete resuba */ { 0, "resuba 119" },
+ /* 120 */ { 0, "readv" },
+ /* 121 */ { 0, "writev" },
+- /* 122 */ { 0, "settimeofday" },
++ { 0, }, /* 122 is old settimeofday */
+ /* 123 */ { 0, "fchown" },
+ /* 124 */ { 0, "fchmod" },
+ { 0, }, /* 125 is old recvfrom */
+ { 0, }, /* 126 is old setreuid */
+ { 0, }, /* 127 is old setregid */
++ /* 126 */ { 0, "setreuid" },
++ /* 127 */ { 0, "setregid" },
+ /* 128 */ { 0, "rename" },
+ { 0, }, /* 129 is old truncate */
+ { 0, }, /* 130 is old ftruncate */
+@@ -1221,9 +1224,9 @@ static emul_syscall_descriptor netbsd_de
+ /* 135 */ { 0, "socketpair" },
+ /* 136 */ { 0, "mkdir" },
+ /* 137 */ { 0, "rmdir" },
+- /* 138 */ { 0, "utimes" },
++ { 0, }, /* 138 is old utimes */
+ { 0, }, /* 139 is obsolete 4.2 sigreturn */
+- /* 140 */ { 0, "adjtime" },
++ { 0, }, /* 140 is old adjtime */
+ { 0, }, /* 141 is old getpeername */
+ { 0, }, /* 142 is old gethostid */
+ { 0, }, /* 143 is old sethostid */
+@@ -1240,11 +1243,11 @@ static emul_syscall_descriptor netbsd_de
+ { 0, }, /* 154 */
+ /* 155 */ { 0, "nfssvc" },
+ { 0, }, /* 156 is old getdirentries */
+- /* 157 */ { 0, "statfs" },
+- /* 158 */ { do_fstatfs, "fstatfs" },
++ { 0, }, /* 157 is old statfs */
++ { 0, }, /* 158 is old fstatfs */
+ { 0, }, /* 159 */
+ { 0, }, /* 160 */
+- /* 161 */ { 0, "getfh" },
++ { 0, }, /* 161 is old getfh */
+ { 0, }, /* 162 is old getdomainname */
+ { 0, }, /* 163 is old setdomainname */
+ { 0, }, /* 164 is old uname */
+@@ -1252,14 +1255,14 @@ static emul_syscall_descriptor netbsd_de
+ { 0, }, /* 166 */
+ { 0, }, /* 167 */
+ { 0, }, /* 168 */
+- /* 169 */ { 0, "semsys" },
+- /* 170 */ { 0, "msgsys" },
+- /* 171 */ { 0, "shmsys" },
++ { 0, }, /* 169 is old semsys */
++ { 0, }, /* 170 is old msgsys */
++ { 0, }, /* 171 is old shmsys */
+ { 0, }, /* 172 */
+- { 0, }, /* 173 */
+- { 0, }, /* 174 */
+- { 0, }, /* 175 */
+- { 0, }, /* 176 */
++ /* 173 */ { 0, "pread" },
++ /* 174 */ { 0, "pwrite" },
++ { 0, }, /* 175 is old ntp_gettime */
++ /* 176 */ { 0, "ntp_adjtime" },
+ { 0, }, /* 177 */
+ { 0, }, /* 178 */
+ { 0, }, /* 179 */
+@@ -1271,15 +1274,15 @@ static emul_syscall_descriptor netbsd_de
+ /* 185 */ { 0, "lfs_markv" },
+ /* 186 */ { 0, "lfs_segclean" },
+ /* 187 */ { 0, "lfs_segwait" },
+- /* 188 */ { do_stat, "stat" },
+- /* 189 */ { do_fstat, "fstat" },
+- /* 190 */ { do_lstat, "lstat" },
++ { 0, }, /* 188 is old stat" */
++ { 0, }, /* 189 is old fstat */
++ { 0, }, /* 190 is old lstat */
+ /* 191 */ { 0, "pathconf" },
+ /* 192 */ { 0, "fpathconf" },
+ { 0, }, /* 193 */
+ /* 194 */ { 0, "getrlimit" },
+ /* 195 */ { 0, "setrlimit" },
+- /* 196 */ { do_getdirentries, "getdirentries" },
++ { 0, }, /* 196 is old getdirentries */
+ /* 197 */ { 0, "mmap" },
+ /* 198 */ { do___syscall, "__syscall" },
+ /* 199 */ { do_lseek, "lseek" },
+@@ -1288,6 +1291,275 @@ static emul_syscall_descriptor netbsd_de
+ /* 202 */ { do___sysctl, "__sysctl" },
+ /* 203 */ { 0, "mlock" },
+ /* 204 */ { 0, "munlock" },
++ /* 205 */ { 0, "undelete" },
++ { 0, }, /* 206 is old futimes */
++ /* 207 */ { 0, "getpgid" },
++ /* 208 */ { 0, "reboot" },
++ /* 209 */ { 0, "poll" },
++ { 0, }, /* 210 */
++ { 0, }, /* 211 */
++ { 0, }, /* 212 */
++ { 0, }, /* 213 */
++ { 0, }, /* 214 */
++ { 0, }, /* 215 */
++ { 0, }, /* 216 */
++ { 0, }, /* 217 */
++ { 0, }, /* 218 */
++ { 0, }, /* 219 */
++ { 0, }, /* 220 is old semctl */
++ /* 221 */ { 0, "semget" },
++ /* 222 */ { 0, "semop" },
++ /* 223 */ { 0, "semconfig" },
++ { 0, }, /* 224 is old msgctl */
++ /* 225 */ { 0, "msgget" },
++ /* 226 */ { 0, "msgsnd" },
++ /* 227 */ { 0, "msgrcv" },
++ /* 228 */ { 0, "shmat" },
++ { 0, }, /* 229 is old shmctl */
++ /* 230 */ { 0, "shmdt" },
++ /* 231 */ { 0, "shmget" },
++ { 0, }, /* 232 is old clock_gettime */
++ { 0, }, /* 233 is old clock_settime */
++ { 0, }, /* 234 is old clock_getres */
++ /* 235 */ { 0, "timer_create" },
++ /* 236 */ { 0, "timer_delete" },
++ { 0, }, /* 237 is old timer_settime */
++ { 0, }, /* 238 is old timer_gettime */
++ /* 239 */ { 0, "timer_getoverrun" },
++ { 0, }, /* 240 is old nanosleep */
++ /* 241 */ { 0, "fdatasync" },
++ /* 242 */ { 0, "mlockall" },
++ /* 243 */ { 0, "munlockall" },
++ { 0, }, /* 244 is old sigtimedwait */
++ { 0, }, /* 245 */
++ /* 246 */ { 0, "modctl" },
++ /* 247 */ { 0, "_ksem_init" },
++ /* 248 */ { 0, "_ksem_open" },
++ /* 249 */ { 0, "_ksem_unlink" },
++ /* 250 */ { 0, "_ksem_close" },
++ /* 251 */ { 0, "_ksem_post" },
++ /* 252 */ { 0, "_ksem_wait" },
++ /* 253 */ { 0, "_ksem_trywait" },
++ /* 254 */ { 0, "_ksem_getvalue" },
++ /* 255 */ { 0, "_ksem_destroy" },
++ /* 256 */ { 0, "_ksem_timedwait" },
++ /* 257 */ { 0, "mq_open" },
++ /* 258 */ { 0, "mq_close" },
++ /* 259 */ { 0, "mq_unlink" },
++ /* 260 */ { 0, "mq_getattr" },
++ /* 261 */ { 0, "mq_setattr" },
++ /* 262 */ { 0, "mq_notify" },
++ /* 263 */ { 0, "mq_send" },
++ /* 264 */ { 0, "mq_receive" },
++ { 0, }, /* 265 is old mq_timedsend */
++ { 0, }, /* 266 is old mq_timedrecive */
++ { 0, }, /* 267 */
++ { 0, }, /* 268 */
++ { 0, }, /* 269 */
++ /* 270 */ { 0, "__posix_rename" },
++ /* 271 */ { 0, "swapctl" },
++ { 0, }, /* 272 is old getdents */
++ /* 273 */ { 0, "minherit" },
++ /* 274 */ { 0, "lchmod" },
++ /* 275 */ { 0, "lchown" },
++ { 0, }, /* 276 is old lutimes */
++ /* 277 */ { 0, "__msync13" },
++ { 0, }, /* 278 is old stat */
++ { 0, }, /* 279 is old fstat */
++ { 0, }, /* 280 is old lstat */
++ /* 281 */ { 0, "__sigaltstack13" },
++ /* 282 */ { 0, "__vfork14" },
++ /* 283 */ { 0, "__posix_chown" },
++ /* 284 */ { 0, "__posix_fchown" },
++ /* 285 */ { 0, "__posix_lchown" },
++ /* 286 */ { 0, "getsid" },
++ /* 287 */ { 0, "__clone" },
++ /* 288 */ { 0, "fktrace" },
++ /* 289 */ { 0, "preadv" },
++ /* 290 */ { 0, "pwritev" },
++ { 0, }, /* 291 is old sigaction */
++ /* 292 */ { 0, "__sigpending14" },
++ /* 293 */ { do_sigprocmask, "__sigprocmask14" },
++ /* 294 */ { 0, "__sigsuspend14" },
++ /* 295 */ { 0, "__sigreturn14" },
++ /* 296 */ { 0, "__getcwd" },
++ /* 297 */ { 0, "fchroot" },
++ { 0, }, /* 298 is old fhopen */
++ { 0, }, /* 299 is old fhstat */
++ { 0, }, /* 300 is old fhstatfs */
++ { 0, }, /* 301 is old semctl */
++ { 0, }, /* 302 is old msgctl */
++ { 0, }, /* 303 is old shmctl */
++ /* 304 */ { 0, "lchflags" },
++ /* 305 */ { 0, "issetugid" },
++ /* 306 */ { 0, "utrace" },
++ /* 307 */ { 0, "getcontext" },
++ /* 308 */ { 0, "setcontext" },
++ /* 309 */ { 0, "_lwp_create" },
++ /* 310 */ { 0, "_lwp_exit" },
++ /* 311 */ { 0, "_lwp_self" },
++ /* 312 */ { 0, "_lwp_wait" },
++ /* 313 */ { 0, "_lwp_suspend" },
++ /* 314 */ { 0, "_lwp_continue" },
++ /* 315 */ { 0, "_lwp_wakeup" },
++ /* 316 */ { 0, "_lwp_getprivate" },
++ /* 317 */ { 0, "_lwp_setprivate" },
++ /* 318 */ { 0, "_lwp_kill" },
++ /* 319 */ { 0, "_lwp_detach" },
++ { 0, }, /* 320 is old _lwp_park */
++ /* 321 */ { 0, "_lwp_unpark" },
++ /* 322 */ { 0, "_lwp_unpark_all" },
++ /* 323 */ { 0, "_lwp_setname" },
++ /* 324 */ { 0, "_lwp_getname" },
++ /* 325 */ { 0, "_lwp_ctl" },
++ { 0, }, /* 326 */
++ { 0, }, /* 327 */
++ { 0, }, /* 328 */
++ { 0, }, /* 329 */
++ /* 330 */ { 0, "sa_register" },
++ /* 331 */ { 0, "sa_stacks" },
++ /* 332 */ { 0, "sa_enable" },
++ /* 333 */ { 0, "sa_setconcurrency" },
++ /* 334 */ { 0, "sa_yield" },
++ /* 335 */ { 0, "sa_preempt" },
++ { 0, }, /* 336 */
++ { 0, }, /* 337 */
++ { 0, }, /* 338 */
++ { 0, }, /* 339 */
++ /* 340 */ { 0, "__sigaction_sigtramp" },
++ /* 341 */ { 0, "pmc_get_info" },
++ /* 342 */ { 0, "pmc_control" },
++ /* 343 */ { 0, "rasctl" },
++ /* 344 */ { 0, "kqueue" },
++ { 0, }, /* 345 is old kevent */
++ /* 346 */ { 0, "_sched_setparam" },
++ /* 347 */ { 0, "_sched_getparam" },
++ /* 348 */ { 0, "_sched_setaffinity" },
++ /* 349 */ { 0, "_sched_getaffinity" },
++ /* 350 */ { 0, "sched_yield" },
++ { 0, }, /* 351 */
++ { 0, }, /* 352 */
++ { 0, }, /* 353 */
++ /* 354 */ { 0, "fsync_range" },
++ /* 355 */ { 0, "uuidgen" },
++ /* 356 */ { 0, "getvfsstat" },
++ /* 357 */ { 0, "statvfs1" },
++ /* 358 */ { 0, "fstatvfs1" },
++ { 0, }, /* 359 is old fhstatvfs1 */
++ /* 360 */ { 0, "extattrctl" },
++ /* 361 */ { 0, "extattr_set_file" },
++ /* 362 */ { 0, "extattr_get_file" },
++ /* 363 */ { 0, "extattr_delete_file" },
++ /* 364 */ { 0, "extattr_set_fd" },
++ /* 365 */ { 0, "extattr_get_fd" },
++ /* 366 */ { 0, "extattr_delete_fd" },
++ /* 367 */ { 0, "extattr_set_link" },
++ /* 368 */ { 0, "extattr_get_link" },
++ /* 369 */ { 0, "extattr_delete_link" },
++ /* 370 */ { 0, "extattr_list_fd" },
++ /* 371 */ { 0, "extattr_list_file" },
++ /* 372 */ { 0, "extattr_list_link" },
++ { 0, }, /* 373 is old pselect */
++ { 0, }, /* 374 is old pollts */
++ /* 375 */ { 0, "setxattr" },
++ /* 376 */ { 0, "lsetxattr" },
++ /* 377 */ { 0, "fsetxattr" },
++ /* 378 */ { 0, "getxattr" },
++ /* 379 */ { 0, "lgetxattr" },
++ /* 380 */ { 0, "fgetxattr" },
++ /* 381 */ { 0, "listxattr" },
++ /* 382 */ { 0, "llistxattr" },
++ /* 383 */ { 0, "flistxattr" },
++ /* 384 */ { 0, "removexattr" },
++ /* 385 */ { 0, "lremovexattr" },
++ /* 386 */ { 0, "fremovexattr" },
++ { 0, }, /* 387 is old stat */
++ { 0, }, /* 388 is old fstat */
++ { 0, }, /* 389 is old lstat */
++ /* 390 */ { do_getdirentries, "__getdents30" },
++ { 0, }, /* 391 is old posix_fadvise */
++ { 0, }, /* 392 is old fhstat */
++ { 0, }, /* 393 is old ntp_gettime */
++ /* 394 */ { 0, "__socket30" },
++ /* 395 */ { 0, "__getfh30" },
++ /* 396 */ { 0, "__fhopen40" },
++ /* 397 */ { 0, "__fhstatvfs140" },
++ { 0, }, /* 398 is old fhstat */
++ /* 399 */ { 0, "aio_cancel" },
++ /* 400 */ { 0, "aio_error" },
++ /* 401 */ { 0, "aio_fsync" },
++ /* 402 */ { 0, "aio_read" },
++ /* 403 */ { 0, "aio_return" },
++ { 0, }, /* 404 is old aio_suspend */
++ /* 405 */ { 0, "aio_write" },
++ /* 406 */ { 0, "lio_listio" },
++ { 0, }, /* 407 */
++ { 0, }, /* 408 */
++ { 0, }, /* 409 */
++ /* 410 */ { 0, "__mount50" },
++ /* 411 */ { 0, "mremap" },
++ /* 412 */ { 0, "pset_create" },
++ /* 413 */ { 0, "pset_destroy" },
++ /* 414 */ { 0, "pset_assign" },
++ /* 415 */ { 0, "_pset_bind" },
++ /* 416 */ { 0, "__posix_fadvise50" },
++ /* 417 */ { 0, "__select50" },
++ /* 418 */ { do_gettimeofday, "__gettimeofday50" },
++ /* 419 */ { 0, "__settimeofday50" },
++ /* 420 */ { 0, "__utimes50" },
++ /* 421 */ { 0, "__adjtime50" },
++ /* 422 */ { 0, "__lfs_segwait50" },
++ /* 423 */ { 0, "__futimes50" },
++ /* 424 */ { 0, "__lutimes50" },
++ /* 425 */ { 0, "__setitimer50" },
++ /* 426 */ { 0, "__getitimer50" },
++ /* 427 */ { 0, "__clock_gettime50" },
++ /* 428 */ { 0, "__clock_settime50" },
++ /* 429 */ { 0, "__clock_getres50" },
++ /* 430 */ { 0, "__nanosleep50" },
++ /* 431 */ { 0, "____sigtimedwait50" },
++ /* 432 */ { 0, "__mq_timedsend50" },
++ /* 433 */ { 0, "__mq_timedreceive50" },
++ /* 434 */ { 0, "____lwp_park50" },
++ /* 435 */ { 0, "__kevent50" },
++ /* 436 */ { 0, "__pselect50" },
++ /* 437 */ { 0, "__pollts50" },
++ /* 438 */ { 0, "__aio_suspend50" },
++ /* 439 */ { do_stat, "__stat50" },
++ /* 440 */ { do_fstat, "__fstat50" },
++ /* 441 */ { do_lstat, "__lstat50" },
++ /* 442 */ { 0, "____semctl50" },
++ /* 443 */ { 0, "__shmctl50" },
++ /* 444 */ { 0, "__msgctl50" },
++ /* 445 */ { do_getrusage, "__getrusage50" },
++ /* 446 */ { 0, "__timer_settime50" },
++ /* 447 */ { 0, "__timer_gettime50" },
++ /* 448 */ { 0, "__ntp_gettime50" },
++ /* 449 */ { 0, "__wait450" },
++ /* 450 */ { 0, "__mknod50" },
++ /* 451 */ { 0, "__fhstat50" },
++ { 0, }, /* 452 is obsolete 5.99 __quotactl50 */
++ /* 453 */ { 0, "pipe2" },
++ /* 454 */ { 0, "dup3" },
++ /* 455 */ { 0, "kqueue1" },
++ /* 456 */ { 0, "paccept" },
++ /* 457 */ { 0, "linkat" },
++ /* 458 */ { 0, "renameat" },
++ /* 459 */ { 0, "mkfifoat" },
++ /* 460 */ { 0, "mknodat" },
++ /* 461 */ { 0, "mkdirat" },
++ /* 462 */ { 0, "faccessat" },
++ /* 463 */ { 0, "fchmodat" },
++ /* 464 */ { 0, "fchownat" },
++ /* 465 */ { 0, "fexecve" },
++ /* 466 */ { 0, "fstatat" },
++ /* 467 */ { 0, "utimensat" },
++ /* 468 */ { 0, "openat" },
++ /* 469 */ { 0, "readlinkat" },
++ /* 470 */ { 0, "symlinkat" },
++ /* 471 */ { 0, "unlinkat" },
++ /* 472 */ { 0, "futimens" },
++ /* 473 */ { 0, "__quotactl" },
+ };
+
+ static char *(netbsd_error_names[]) = {
+@@ -1373,7 +1645,22 @@ static char *(netbsd_error_names[]) = {
+ /* 79 */ "EFTYPE",
+ /* 80 */ "EAUTH",
+ /* 81 */ "ENEEDAUTH",
+- /* 81 */ "ELAST",
++ /* 82 */ "EIDRM",
++ /* 83 */ "ENOMSG",
++ /* 84 */ "EOVERFLOW",
++ /* 85 */ "EILSEQ",
++ /* 86 */ "ENOTSUP",
++ /* 87 */ "ECANCELED",
++ /* 88 */ "EBADMSG",
++ /* 89 */ "ENODATA",
++ /* 90 */ "ENOSR",
++ /* 91 */ "ENOSTR",
++ /* 92 */ "ETIME",
++ /* 93 */ "ENOATTR",
++ /* 94 */ "EMULTIHOP",
++ /* 95 */ "ENOLINK",
++ /* 96 */ "EPROTO",
++ /* 96 */ "ELAST",
+ };
+
+ static char *(netbsd_signal_names[]) = {
+@@ -1409,6 +1696,7 @@ static char *(netbsd_signal_names[]) = {
+ /* 29 */ "SIGINFO",
+ /* 30 */ "SIGUSR1",
+ /* 31 */ "SIGUSR2",
++ /* 32 */ "SIGPWR",
+ };
+
+ static emul_syscall emul_netbsd_syscalls = {
diff --git a/gdb-netbsd/patches/patch-sim_ppc_emul_netbsd.c b/gdb-netbsd/patches/patch-sim_ppc_emul_netbsd.c
deleted file mode 100644
index d2feed94f6..0000000000
--- a/gdb-netbsd/patches/patch-sim_ppc_emul_netbsd.c
+++ /dev/null
@@ -1,39 +0,0 @@
-$NetBSD: patch-sim_ppc_emul_netbsd.c,v 1.1 2015/03/15 14:56:46 bsiegert Exp $
-
-time_t conversion compatibility, experimental.
-Please correct the naming, thank you.
-
---- sim/ppc/emul_netbsd.c.orig 2014-06-11 16:34:42.000000000 +0000
-+++ sim/ppc/emul_netbsd.c
-@@ -118,6 +118,7 @@ extern int errno;
-
- #if WITH_NetBSD_HOST
- #define SYS(X) ASSERT(call == (SYS_##X))
-+#define SYSSYS(X) ASSERT(call == (SYS___##X50))
- #else
- #define SYS(X)
- #endif
-@@ -737,7 +738,11 @@ do_gettimeofday(os_emul_data *emul,
- if (WITH_TRACE && ppc_trace[trace_os_emul])
- printf_filtered ("0x%lx, 0x%lx", (long)t_addr, (long)tz_addr);
-
-+#if 0
- SYS(gettimeofday);
-+#else
-+ SYS___gettimeofday50;
-+#endif
- emul_write_status(processor, status, err);
- if (status == 0) {
- if (t_addr != 0)
-@@ -767,7 +772,11 @@ do_getrusage(os_emul_data *emul,
- if (WITH_TRACE && ppc_trace[trace_os_emul])
- printf_filtered ("%d, 0x%lx", who, (long)rusage_addr);
-
-+#if 0
- SYS(getrusage);
-+#else
-+ SYS___getrusage50;
-+#endif
- emul_write_status(processor, status, err);
- if (status == 0) {
- if (rusage_addr != 0)
diff --git a/gdb-netbsd/patches/patch-sim_ppc_events.c b/gdb-netbsd/patches/patch-sim_ppc_events.c
new file mode 100644
index 0000000000..94d8666b31
--- /dev/null
+++ b/gdb-netbsd/patches/patch-sim_ppc_events.c
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- sim/ppc/events.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ sim/ppc/events.c
+@@ -24,6 +24,7 @@
+ #include "basics.h"
+ #include "events.h"
+
++#include <stdlib.h>
+ #include <signal.h>
+ #include <stdlib.h>
+
diff --git a/gdb-netbsd/patches/patch-sim_ppc_hw__memory.c b/gdb-netbsd/patches/patch-sim_ppc_hw__memory.c
new file mode 100644
index 0000000000..5ecf25e8d1
--- /dev/null
+++ b/gdb-netbsd/patches/patch-sim_ppc_hw__memory.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- sim/ppc/hw_memory.c.orig 2019-07-16 00:00:27.000000000 +0000
++++ sim/ppc/hw_memory.c
+@@ -29,6 +29,8 @@
+
+ #include "device_table.h"
+
++#include <stdlib.h>
++
+ /* DEVICE
+
+
diff --git a/gdb-netbsd/patches/patch-sim_testsuite_sim_bfin_run-tests.sh b/gdb-netbsd/patches/patch-sim_testsuite_sim_bfin_run-tests.sh
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdb-netbsd/patches/patch-sim_v850_Makefile.in b/gdb-netbsd/patches/patch-sim_v850_Makefile.in
new file mode 100644
index 0000000000..0c6c6d63b7
--- /dev/null
+++ b/gdb-netbsd/patches/patch-sim_v850_Makefile.in
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- sim/v850/Makefile.in.orig 2019-07-16 00:00:27.000000000 +0000
++++ sim/v850/Makefile.in
+@@ -72,7 +72,7 @@ IGEN_TRACE= # -G omit-line-numbers # -G
+ IGEN_INSN=$(srcdir)/v850.igen
+ IGEN_DC=$(srcdir)/v850-dc
+ tmp-igen: $(IGEN_INSN) $(IGEN_DC) ../igen/igen
+- cd ../igen && $(MAKE)
++# cd ../igen && $(MAKE)
+ ../igen/igen \
+ $(IGEN_TRACE) \
+ -G gen-direct-access \
diff --git a/gdb-netbsd/patches/patch-src-release.sh b/gdb-netbsd/patches/patch-src-release.sh
new file mode 100644
index 0000000000..e69de29bb2
Home |
Main Index |
Thread Index |
Old Index