From owner-svn-ports-head@freebsd.org Mon Sep 24 17:23:37 2018 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5949310B2BB4; Mon, 24 Sep 2018 17:23:37 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 101038AD01; Mon, 24 Sep 2018 17:23:37 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E49411C67F; Mon, 24 Sep 2018 17:23:36 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w8OHNalW019594; Mon, 24 Sep 2018 17:23:36 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w8OHNZ6q019587; Mon, 24 Sep 2018 17:23:35 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201809241723.w8OHNZ6q019587@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 24 Sep 2018 17:23:35 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r480613 - in head/devel/gdb: . files files/kgdb X-SVN-Group: ports-head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head/devel/gdb: . files files/kgdb X-SVN-Commit-Revision: 480613 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 17:23:37 -0000 Author: jhb (src,doc committer) Date: Mon Sep 24 17:23:35 2018 New Revision: 480613 URL: https://svnweb.freebsd.org/changeset/ports/480613 Log: Upgrade to 8.2. - Remove patches for upstream commits in 8.2. - Add an upstream patch to include NT_PROCSTAT_AUXV, NT_PROCSTAT_PS_STRINGS, and NT_PROCSTAT_VMMAP notes in core dumps generated by 'gcore'. - Update kgdb for changes in 8.2. - Add 'USES=gettext-runtime' Reviewed by: pizzamig (maintainer) Differential Revision: https://reviews.freebsd.org/D17085 Added: head/devel/gdb/files/commit-8aa0243d54 (contents, props changed) Deleted: head/devel/gdb/files/commit-12279366d7 head/devel/gdb/files/commit-262f62f57d head/devel/gdb/files/commit-2d97a5d9d3 head/devel/gdb/files/commit-386a867618 head/devel/gdb/files/commit-7efba073e2 head/devel/gdb/files/commit-906b4aac4c head/devel/gdb/files/commit-92fce24de2 head/devel/gdb/files/commit-b999e2038d head/devel/gdb/files/commit-d2176225dc head/devel/gdb/files/commit-f169cfdc08 head/devel/gdb/files/patch-gdb_corelow.c Modified: head/devel/gdb/Makefile head/devel/gdb/distinfo head/devel/gdb/files/extrapatch-kgdb head/devel/gdb/files/kgdb/amd64fbsd-kern.c head/devel/gdb/files/kgdb/fbsd-kld.c head/devel/gdb/files/kgdb/fbsd-kvm.c head/devel/gdb/files/kgdb/i386fbsd-kern.c head/devel/gdb/files/kgdb/kgdb-main.c head/devel/gdb/files/kgdb/kgdb.h head/devel/gdb/files/patch-gdb_configure head/devel/gdb/files/patch-gdb_fbsd-nat.c head/devel/gdb/files/patch-gdb_i386-fbsd-nat.c head/devel/gdb/files/patch-gdb_python_python-config.py Modified: head/devel/gdb/Makefile ============================================================================== --- head/devel/gdb/Makefile Mon Sep 24 17:08:41 2018 (r480612) +++ head/devel/gdb/Makefile Mon Sep 24 17:23:35 2018 (r480613) @@ -2,7 +2,7 @@ # $FreeBSD$ PORTNAME= gdb -PORTVERSION= 8.1.1 +PORTVERSION= 8.2 CATEGORIES= devel MASTER_SITES= GNU @@ -23,7 +23,7 @@ TEST_TARGET= check # C++14. However, clang in 10.3 crashes while building this port. # Requiring C++14 forces 10.3 to use an external version of clang while # still using the base system clang on 11.0 and later. -USES= compiler:c++14-lang cpe gmake libtool tar:xz +USES= compiler:c++14-lang cpe gettext-runtime gmake libtool tar:xz USE_CSTD= gnu89 CPE_VENDOR= gnu GNU_CONFIGURE= yes @@ -40,16 +40,7 @@ CFLAGS+= -DRL_NO_COMPAT -Wno-unused-function -Wno-unus CFLAGS+= -Wno-unknown-warning-option EXCLUDE= dejagnu expect sim texinfo intl EXTRACT_AFTER_ARGS= ${EXCLUDE:S/^/--exclude /} -EXTRA_PATCHES= ${FILESDIR}/commit-d2176225dc \ - ${FILESDIR}/commit-b999e2038d \ - ${FILESDIR}/commit-262f62f57d \ - ${FILESDIR}/commit-92fce24de2 \ - ${FILESDIR}/commit-2d97a5d9d3 \ - ${FILESDIR}/commit-906b4aac4c \ - ${FILESDIR}/commit-f169cfdc08 \ - ${FILESDIR}/commit-12279366d7 \ - ${FILESDIR}/commit-386a867618 \ - ${FILESDIR}/commit-7efba073e2 +EXTRA_PATCHES= ${FILESDIR}/commit-8aa0243d54 LIB_DEPENDS+= libexpat.so:textproc/expat2 VER= ${PORTVERSION:S/.//g} Modified: head/devel/gdb/distinfo ============================================================================== --- head/devel/gdb/distinfo Mon Sep 24 17:08:41 2018 (r480612) +++ head/devel/gdb/distinfo Mon Sep 24 17:23:35 2018 (r480613) @@ -1,3 +1,3 @@ -TIMESTAMP = 1533926440 -SHA256 (gdb-8.1.1.tar.xz) = 97dcc3169bd430270fc29adb65145846a58c1b55cdbb73382a4a89307bdad03c -SIZE (gdb-8.1.1.tar.xz) = 20064728 +TIMESTAMP = 1536418789 +SHA256 (gdb-8.2.tar.xz) = c3a441a29c7c89720b734e5a9c6289c0a06be7e0c76ef538f7bbcef389347c39 +SIZE (gdb-8.2.tar.xz) = 20173112 Added: head/devel/gdb/files/commit-8aa0243d54 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/gdb/files/commit-8aa0243d54 Mon Sep 24 17:23:35 2018 (r480613) @@ -0,0 +1,197 @@ +commit 739ab2e92e1840c9285f3cfce1f1236c0fa68730 +Author: Simon Ser +Date: Thu Sep 6 15:03:19 2018 -0700 + + Generate NT_PROCSTAT_{AUXV,VMMAP,PS_STRINGS} in FreeBSD coredumps + + gcore generates NT_AUXV and NT_FILE notes for Linux targets. On + FreeBSD auxv is stored in a NT_PROCSTAT_AUXV section, virtual memory + mappings are stored in a NT_PROCSTAT_VMMAP, and both are prefixed with + the struct size. In addition, store a NT_PROCSTAT_PS_STRINGS note + saving the initial location of the argv[] and environment[] arrays. + + gdb/ChangeLog: + + PR gdb/23105 + * fbsd-nat.c (fbsd_nat_target::xfer_partial): Add support for + TARGET_OBJECT_FREEBSD_VMMAP and TARGET_OBJECT_FREEBSD_PS_STRINGS. + * fbsd-tdep.c (fbsd_make_note_desc): New. + (fbsd_make_corefile_notes): Write NT_PROCSTAT_AUXV, + NT_PROCSTAT_VMMAP and NT_PROCSTAT_PS_STRINGS notes. + * target.h (enum target_object) Add FreeBSD-specific + TARGET_OBJECT_FREEBSD_VMMAP and TARGET_OBJECT_FREEBSD_PS_STRINGS. + +diff --git gdb/ChangeLog gdb/ChangeLog +index 410fbef920..e6f44a3ac2 100644 +--- gdb/ChangeLog ++++ gdb/ChangeLog +@@ -1,3 +1,14 @@ ++2018-09-06 Simon Ser ++ ++ PR gdb/23105 ++ * fbsd-nat.c (fbsd_nat_target::xfer_partial): Add support for ++ TARGET_OBJECT_FREEBSD_VMMAP and TARGET_OBJECT_FREEBSD_PS_STRINGS. ++ * fbsd-tdep.c (fbsd_make_note_desc): New. ++ (fbsd_make_corefile_notes): Write NT_PROCSTAT_AUXV, ++ NT_PROCSTAT_VMMAP and NT_PROCSTAT_PS_STRINGS notes. ++ * target.h (enum target_object) Add FreeBSD-specific ++ TARGET_OBJECT_FREEBSD_VMMAP and TARGET_OBJECT_FREEBSD_PS_STRINGS. ++ + 2018-09-06 Simon Marchi + + * compile/compile-c.h (generate_c_for_variable_locations): +diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c +index 115deac070..a255318d14 100644 +--- gdb/fbsd-nat.c ++++ gdb/fbsd-nat.c +@@ -751,6 +751,61 @@ fbsd_nat_target::xfer_partial (enum target_object object, + } + return TARGET_XFER_E_IO; + } ++ case TARGET_OBJECT_FREEBSD_VMMAP: ++ case TARGET_OBJECT_FREEBSD_PS_STRINGS: ++ { ++ gdb::byte_vector buf_storage; ++ gdb_byte *buf; ++ size_t buflen; ++ int mib[4]; ++ ++ int proc_target; ++ uint32_t struct_size; ++ switch (object) ++ { ++ case TARGET_OBJECT_FREEBSD_VMMAP: ++ proc_target = KERN_PROC_VMMAP; ++ struct_size = sizeof (struct kinfo_vmentry); ++ break; ++ case TARGET_OBJECT_FREEBSD_PS_STRINGS: ++ proc_target = KERN_PROC_PS_STRINGS; ++ struct_size = sizeof (void *); ++ break; ++ } ++ ++ if (writebuf != NULL) ++ return TARGET_XFER_E_IO; ++ ++ mib[0] = CTL_KERN; ++ mib[1] = KERN_PROC; ++ mib[2] = proc_target; ++ mib[3] = pid; ++ ++ if (sysctl (mib, 4, NULL, &buflen, NULL, 0) != 0) ++ return TARGET_XFER_E_IO; ++ buflen += sizeof (struct_size); ++ ++ if (offset >= buflen) ++ { ++ *xfered_len = 0; ++ return TARGET_XFER_EOF; ++ } ++ ++ buf_storage.resize (buflen); ++ buf = buf_storage.data (); ++ ++ memcpy (buf, &struct_size, sizeof (struct_size)); ++ buflen -= sizeof (struct_size); ++ if (sysctl (mib, 4, buf + sizeof (struct_size), &buflen, NULL, 0) != 0) ++ return TARGET_XFER_E_IO; ++ buflen += sizeof (struct_size); ++ ++ if (buflen - offset < len) ++ len = buflen - offset; ++ memcpy (readbuf, buf + offset, len); ++ *xfered_len = len; ++ return TARGET_XFER_OK; ++ } + default: + return inf_ptrace_target::xfer_partial (object, annex, + readbuf, writebuf, offset, +diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c +index 78d0c3d830..ed43087169 100644 +--- gdb/fbsd-tdep.c ++++ gdb/fbsd-tdep.c +@@ -512,6 +512,28 @@ fbsd_corefile_thread (struct thread_info *info, + args->note_size, args->stop_signal); + } + ++/* Return a byte_vector containing the contents of a core dump note ++ for the target object of type OBJECT. If STRUCTSIZE is non-zero, ++ the data is prefixed with a 32-bit integer size to match the format ++ used in FreeBSD NT_PROCSTAT_* notes. */ ++ ++static gdb::optional ++fbsd_make_note_desc (enum target_object object, uint32_t structsize) ++{ ++ gdb::optional buf = ++ target_read_alloc (current_top_target (), object, NULL); ++ if (!buf || buf->empty ()) ++ return {}; ++ ++ if (structsize == 0) ++ return buf; ++ ++ gdb::byte_vector desc (sizeof (structsize) + buf->size ()); ++ memcpy (desc.data (), &structsize, sizeof (structsize)); ++ memcpy (desc.data () + sizeof (structsize), buf->data (), buf->size ()); ++ return desc; ++} ++ + /* Create appropriate note sections for a corefile, returning them in + allocated memory. */ + +@@ -586,6 +608,40 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) + + note_data = thread_args.note_data; + ++ /* Auxiliary vector. */ ++ uint32_t structsize = gdbarch_ptr_bit (gdbarch) / 4; /* Elf_Auxinfo */ ++ gdb::optional note_desc = ++ fbsd_make_note_desc (TARGET_OBJECT_AUXV, structsize); ++ if (note_desc && !note_desc->empty ()) ++ { ++ note_data = elfcore_write_note (obfd, note_data, note_size, "FreeBSD", ++ NT_FREEBSD_PROCSTAT_AUXV, ++ note_desc->data (), note_desc->size ()); ++ if (!note_data) ++ return NULL; ++ } ++ ++ /* Virtual memory mappings. */ ++ note_desc = fbsd_make_note_desc (TARGET_OBJECT_FREEBSD_VMMAP, 0); ++ if (note_desc && !note_desc->empty ()) ++ { ++ note_data = elfcore_write_note (obfd, note_data, note_size, "FreeBSD", ++ NT_FREEBSD_PROCSTAT_VMMAP, ++ note_desc->data (), note_desc->size ()); ++ if (!note_data) ++ return NULL; ++ } ++ ++ note_desc = fbsd_make_note_desc (TARGET_OBJECT_FREEBSD_PS_STRINGS, 0); ++ if (note_desc && !note_desc->empty ()) ++ { ++ note_data = elfcore_write_note (obfd, note_data, note_size, "FreeBSD", ++ NT_FREEBSD_PROCSTAT_PSSTRINGS, ++ note_desc->data (), note_desc->size ()); ++ if (!note_data) ++ return NULL; ++ } ++ + return note_data; + } + +diff --git gdb/target.h gdb/target.h +index 229b5d0551..a3000c80c6 100644 +--- gdb/target.h ++++ gdb/target.h +@@ -202,6 +202,10 @@ enum target_object + of the process ID of the process in question, in hexadecimal + format. */ + TARGET_OBJECT_EXEC_FILE, ++ /* FreeBSD virtual memory mappings. */ ++ TARGET_OBJECT_FREEBSD_VMMAP, ++ /* FreeBSD process strings. */ ++ TARGET_OBJECT_FREEBSD_PS_STRINGS, + /* Possible future objects: TARGET_OBJECT_FILE, ... */ + }; + Modified: head/devel/gdb/files/extrapatch-kgdb ============================================================================== --- head/devel/gdb/files/extrapatch-kgdb Mon Sep 24 17:08:41 2018 (r480612) +++ head/devel/gdb/files/extrapatch-kgdb Mon Sep 24 17:23:35 2018 (r480613) @@ -1,8 +1,8 @@ diff --git gdb/Makefile.in gdb/Makefile.in -index 17b71c6e7c..95e92d08b4 100644 +index 13627e07e0..a72fd8fe0f 100644 --- gdb/Makefile.in +++ gdb/Makefile.in -@@ -230,7 +230,8 @@ INCGNU = -I$(srcdir)/gnulib/import -I$(GNULIB_BUILDDIR)/import +@@ -236,7 +236,8 @@ INCGNU = -I$(srcdir)/gnulib/import -I$(GNULIB_BUILDDIR)/import # Generated headers in the gnulib directory. These must be listed # so that they are generated before other files are compiled. @@ -12,7 +12,7 @@ index 17b71c6e7c..95e92d08b4 100644 # # CLI sub directory definitons -@@ -629,6 +630,7 @@ TARGET_OBS = @TARGET_OBS@ +@@ -643,6 +644,7 @@ TARGET_OBS = @TARGET_OBS@ # All target-dependent objects files that require 64-bit CORE_ADDR # (used with --enable-targets=all --enable-64-bit-bfd). ALL_64_TARGET_OBS = \ @@ -20,7 +20,7 @@ index 17b71c6e7c..95e92d08b4 100644 aarch64-fbsd-tdep.o \ aarch64-linux-tdep.o \ aarch64-newlib-tdep.o \ -@@ -642,6 +644,7 @@ ALL_64_TARGET_OBS = \ +@@ -656,6 +658,7 @@ ALL_64_TARGET_OBS = \ amd64-darwin-tdep.o \ amd64-dicos-tdep.o \ amd64-fbsd-tdep.o \ @@ -28,7 +28,7 @@ index 17b71c6e7c..95e92d08b4 100644 amd64-linux-tdep.o \ amd64-nbsd-tdep.o \ amd64-obsd-tdep.o \ -@@ -656,6 +659,7 @@ ALL_64_TARGET_OBS = \ +@@ -670,6 +673,7 @@ ALL_64_TARGET_OBS = \ ia64-vms-tdep.o \ mips64-obsd-tdep.o \ sparc64-fbsd-tdep.o \ @@ -36,15 +36,15 @@ index 17b71c6e7c..95e92d08b4 100644 sparc64-linux-tdep.o \ sparc64-nbsd-tdep.o \ sparc64-obsd-tdep.o \ -@@ -670,6 +674,7 @@ ALL_TARGET_OBS = \ - arch/arm-linux.o \ +@@ -685,6 +689,7 @@ ALL_TARGET_OBS = \ arch/i386.o \ + arch/ppc-linux-common.o \ arm-bsd-tdep.o \ + arm-fbsd-kern.o \ arm-fbsd-tdep.o \ arm-linux-tdep.o \ arm-nbsd-tdep.o \ -@@ -684,6 +689,8 @@ ALL_TARGET_OBS = \ +@@ -699,6 +704,8 @@ ALL_TARGET_OBS = \ cris-linux-tdep.o \ cris-tdep.o \ dicos-tdep.o \ @@ -53,7 +53,7 @@ index 17b71c6e7c..95e92d08b4 100644 fbsd-tdep.o \ frv-linux-tdep.o \ frv-tdep.o \ -@@ -700,6 +707,7 @@ ALL_TARGET_OBS = \ +@@ -715,6 +722,7 @@ ALL_TARGET_OBS = \ i386-darwin-tdep.o \ i386-dicos-tdep.o \ i386-fbsd-tdep.o \ @@ -61,7 +61,7 @@ index 17b71c6e7c..95e92d08b4 100644 i386-gnu-tdep.o \ i386-go32-tdep.o \ i386-linux-tdep.o \ -@@ -724,6 +732,7 @@ ALL_TARGET_OBS = \ +@@ -738,6 +746,7 @@ ALL_TARGET_OBS = \ mep-tdep.o \ microblaze-linux-tdep.o \ microblaze-tdep.o \ @@ -69,26 +69,26 @@ index 17b71c6e7c..95e92d08b4 100644 mips-fbsd-tdep.o \ mips-linux-tdep.o \ mips-nbsd-tdep.o \ -@@ -741,6 +750,7 @@ ALL_TARGET_OBS = \ - nto-tdep.o \ +@@ -755,6 +764,7 @@ ALL_TARGET_OBS = \ obsd-tdep.o \ + or1k-tdep.o \ ppc-fbsd-tdep.o \ + ppcfbsd-kern.o \ ppc-linux-tdep.o \ ppc-nbsd-tdep.o \ ppc-obsd-tdep.o \ -@@ -1610,7 +1620,7 @@ generated_files = \ +@@ -1611,7 +1621,7 @@ generated_files = \ # Flags needed to compile Python code PYTHON_CFLAGS = @PYTHON_CFLAGS@ --all: gdb$(EXEEXT) $(CONFIG_ALL) -+all: gdb$(EXEEXT) kgdb$(EXEEXT) $(CONFIG_ALL) +-all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb ++all: gdb$(EXEEXT) kgdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb @$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do # Rule for compiling .c files in the top-level gdb directory. -@@ -1920,6 +1930,12 @@ gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS) - -o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \ - $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES) +@@ -1924,6 +1934,12 @@ ifneq ($(CODESIGN_CERT),) + $(ECHO_SIGN) $(CODESIGN) -s $(CODESIGN_CERT) gdb$(EXEEXT) + endif +kgdb$(EXEEXT): kgdb-main.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS) + rm -f kgdb$(EXEEXT) @@ -99,16 +99,16 @@ index 17b71c6e7c..95e92d08b4 100644 # Convenience rule to handle recursion. $(LIBGNU) $(GNULIB_H): all-lib all-lib: $(GNULIB_BUILDDIR)/Makefile -@@ -1964,7 +1980,7 @@ clean mostlyclean: $(CONFIG_CLEAN) +@@ -1968,7 +1984,7 @@ clean mostlyclean: $(CONFIG_CLEAN) @$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do rm -f *.o *.a $(ADD_FILES) *~ init.c-tmp init.l-tmp version.c-tmp - rm -f init.c version.c observer.h observer.inc + rm -f init.c version.c - rm -f gdb$(EXEEXT) core make.log + rm -f gdb$(EXEEXT) core make.log kgdb$(EXEEXT) rm -f gdb[0-9]$(EXEEXT) rm -f test-cp-name-parser$(EXEEXT) rm -f xml-builtin.c stamp-xml -@@ -2178,6 +2194,7 @@ MAKEOVERRIDES = +@@ -2183,6 +2199,7 @@ MAKEOVERRIDES = ALLDEPFILES = \ aarch64-fbsd-nat.c \ @@ -116,7 +116,7 @@ index 17b71c6e7c..95e92d08b4 100644 aarch64-fbsd-tdep.c \ aarch64-linux-nat.c \ aarch64-linux-tdep.c \ -@@ -2195,6 +2212,7 @@ ALLDEPFILES = \ +@@ -2200,6 +2217,7 @@ ALLDEPFILES = \ amd64-bsd-nat.c \ amd64-darwin-tdep.c \ amd64-dicos-tdep.c \ @@ -124,7 +124,7 @@ index 17b71c6e7c..95e92d08b4 100644 amd64-fbsd-nat.c \ amd64-fbsd-tdep.c \ amd64-linux-nat.c \ -@@ -2209,6 +2227,7 @@ ALLDEPFILES = \ +@@ -2214,6 +2232,7 @@ ALLDEPFILES = \ arc-tdep.c \ arm.c \ arm-bsd-tdep.c \ @@ -132,7 +132,7 @@ index 17b71c6e7c..95e92d08b4 100644 arm-fbsd-nat.c \ arm-fbsd-tdep.c \ arm-get-next-pcs.c \ -@@ -2228,6 +2247,9 @@ ALLDEPFILES = \ +@@ -2233,6 +2252,9 @@ ALLDEPFILES = \ darwin-nat.c \ dicos-tdep.c \ exec.c \ @@ -142,7 +142,7 @@ index 17b71c6e7c..95e92d08b4 100644 fbsd-nat.c \ fbsd-tdep.c \ fork-child.c \ -@@ -2249,6 +2271,7 @@ ALLDEPFILES = \ +@@ -2254,6 +2276,7 @@ ALLDEPFILES = \ i386-darwin-nat.c \ i386-darwin-tdep.c \ i386-dicos-tdep.c \ @@ -150,7 +150,7 @@ index 17b71c6e7c..95e92d08b4 100644 i386-fbsd-nat.c \ i386-fbsd-tdep.c \ i386-gnu-nat.c \ -@@ -2290,6 +2313,7 @@ ALLDEPFILES = \ +@@ -2293,6 +2316,7 @@ ALLDEPFILES = \ mingw-hdep.c \ mips-fbsd-nat.c \ mips-fbsd-tdep.c \ @@ -158,7 +158,7 @@ index 17b71c6e7c..95e92d08b4 100644 mips-linux-nat.c \ mips-linux-tdep.c \ mips-nbsd-nat.c \ -@@ -2307,6 +2331,7 @@ ALLDEPFILES = \ +@@ -2310,6 +2334,7 @@ ALLDEPFILES = \ obsd-nat.c \ obsd-tdep.c \ posix-hdep.c \ @@ -166,7 +166,7 @@ index 17b71c6e7c..95e92d08b4 100644 ppc-fbsd-nat.c \ ppc-fbsd-tdep.c \ ppc-linux-nat.c \ -@@ -2351,6 +2376,7 @@ ALLDEPFILES = \ +@@ -2355,6 +2380,7 @@ ALLDEPFILES = \ sparc-sol2-nat.c \ sparc-sol2-tdep.c \ sparc-tdep.c \ @@ -174,7 +174,7 @@ index 17b71c6e7c..95e92d08b4 100644 sparc64-fbsd-nat.c \ sparc64-fbsd-tdep.c \ sparc64-linux-nat.c \ -@@ -2638,7 +2664,7 @@ endif +@@ -2643,7 +2669,7 @@ endif # A list of all the objects we might care about in this build, for # dependency tracking. @@ -184,10 +184,10 @@ index 17b71c6e7c..95e92d08b4 100644 # All the .deps files to include. diff --git gdb/config.in gdb/config.in -index 1d11a97080..50a5a5b322 100644 +index 527290296e..8e0e90fd67 100644 --- gdb/config.in +++ gdb/config.in -@@ -222,6 +222,9 @@ +@@ -228,6 +228,9 @@ /* Define to 1 if your system has the kinfo_getvmmap function. */ #undef HAVE_KINFO_GETVMMAP @@ -198,10 +198,10 @@ index 1d11a97080..50a5a5b322 100644 #undef HAVE_LANGINFO_CODESET diff --git gdb/configure gdb/configure -index 84a0790c0d..f4c323d4ab 100755 +index 3849b9494f..18d2e363dc 100755 --- gdb/configure +++ gdb/configure -@@ -7927,6 +7927,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h +@@ -8082,6 +8082,66 @@ $as_echo "#define HAVE_KINFO_GETFILE 1" >>confdefs.h fi @@ -269,12 +269,12 @@ index 84a0790c0d..f4c323d4ab 100755 if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" diff --git gdb/configure.ac gdb/configure.ac -index d4133ea71e..bac85c53e0 100644 +index 4c20ea5178..df156b484f 100644 --- gdb/configure.ac +++ gdb/configure.ac -@@ -523,6 +523,11 @@ AC_SEARCH_LIBS(kinfo_getvmmap, util util-freebsd, - [AC_DEFINE(HAVE_KINFO_GETVMMAP, 1, - [Define to 1 if your system has the kinfo_getvmmap function. ])]) +@@ -534,6 +534,11 @@ AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd, + [AC_DEFINE(HAVE_KINFO_GETFILE, 1, + [Define to 1 if your system has the kinfo_getfile function. ])]) +# kgdb needs kvm_open2 for cross-debugging +AC_SEARCH_LIBS(kvm_open2, kvm, @@ -285,7 +285,7 @@ index d4133ea71e..bac85c53e0 100644 # GDB may fork/exec the iconv program to get the list of supported character diff --git gdb/configure.nat gdb/configure.nat -index 8e14892722..ada205f34d 100644 +index 7611266d86..8656015365 100644 --- gdb/configure.nat +++ gdb/configure.nat @@ -62,7 +62,8 @@ case ${gdb_host} in @@ -299,10 +299,10 @@ index 8e14892722..ada205f34d 100644 LOADLIBES='-lkvm' ;; diff --git gdb/configure.tgt gdb/configure.tgt -index fb8014a8e8..4bb43e366c 100644 +index f197160896..ced1140328 100644 --- gdb/configure.tgt +++ gdb/configure.tgt -@@ -92,7 +92,7 @@ esac +@@ -94,7 +94,7 @@ esac case "${targ}" in *-*-freebsd* | *-*-kfreebsd*-gnu) @@ -311,7 +311,7 @@ index fb8014a8e8..4bb43e366c 100644 *-*-netbsd* | *-*-knetbsd*-gnu) os_obs="nbsd-tdep.o solib-svr4.o";; *-*-openbsd*) -@@ -109,7 +109,7 @@ aarch64*-*-elf | aarch64*-*-rtems*) +@@ -111,7 +111,7 @@ aarch64*-*-elf | aarch64*-*-rtems*) aarch64*-*-freebsd*) # Target: FreeBSD/aarch64 @@ -320,7 +320,7 @@ index fb8014a8e8..4bb43e366c 100644 ;; aarch64*-*-linux*) -@@ -162,7 +162,7 @@ arm*-*-linux*) +@@ -164,7 +164,7 @@ arm*-*-linux*) ;; arm*-*-freebsd*) # Target: FreeBSD/arm @@ -329,7 +329,7 @@ index fb8014a8e8..4bb43e366c 100644 ;; arm*-*-netbsd* | arm*-*-knetbsd*-gnu) # Target: NetBSD/arm -@@ -249,7 +249,11 @@ i[34567]86-*-dicos*) +@@ -251,7 +251,11 @@ i[34567]86-*-dicos*) ;; i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu) # Target: FreeBSD/i386 @@ -342,7 +342,7 @@ index fb8014a8e8..4bb43e366c 100644 ;; i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu) # Target: NetBSD/i386 -@@ -408,7 +412,7 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu) +@@ -405,7 +409,7 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu) ;; mips*-*-freebsd*) # Target: MIPS running FreeBSD @@ -351,7 +351,7 @@ index fb8014a8e8..4bb43e366c 100644 gdb_sim=../sim/mips/libsim.a ;; mips64*-*-openbsd*) -@@ -472,7 +476,7 @@ or1k-*-* | or1knd-*-*) +@@ -464,7 +468,7 @@ or1k-*-* | or1knd-*-*) powerpc*-*-freebsd*) # Target: FreeBSD/powerpc gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \ @@ -360,7 +360,7 @@ index fb8014a8e8..4bb43e366c 100644 ravenscar-thread.o ppc-ravenscar-thread.o" ;; -@@ -594,6 +598,7 @@ sparc64-*-linux*) +@@ -587,6 +591,7 @@ sparc64-*-linux*) sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu) # Target: FreeBSD/sparc64 gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64-fbsd-tdep.o \ @@ -368,7 +368,7 @@ index fb8014a8e8..4bb43e366c 100644 ravenscar-thread.o sparc-ravenscar-thread.o" ;; sparc-*-netbsd* | sparc-*-knetbsd*-gnu) -@@ -716,8 +721,8 @@ x86_64-*-linux*) +@@ -709,8 +714,8 @@ x86_64-*-linux*) ;; x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu) # Target: FreeBSD/amd64 @@ -380,10 +380,10 @@ index fb8014a8e8..4bb43e366c 100644 x86_64-*-mingw* | x86_64-*-cygwin*) # Target: MingW/amd64 diff --git gdb/defs.h gdb/defs.h -index 4fb2129b30..0cb0bad5c5 100644 +index fc4217005a..3d2eb6b1e9 100644 --- gdb/defs.h +++ gdb/defs.h -@@ -516,6 +516,7 @@ enum gdb_osabi +@@ -481,6 +481,7 @@ enum gdb_osabi GDB_OSABI_SOLARIS, GDB_OSABI_LINUX, GDB_OSABI_FREEBSD, @@ -392,10 +392,10 @@ index 4fb2129b30..0cb0bad5c5 100644 GDB_OSABI_OPENBSD, GDB_OSABI_WINCE, diff --git gdb/gnulib/configure gdb/gnulib/configure -index 37efd06b67..a23fc0a81c 100644 +index a152abcb76..140c4ad6a8 100644 --- gdb/gnulib/configure +++ gdb/gnulib/configure -@@ -16790,6 +16790,7 @@ else +@@ -17214,6 +17214,7 @@ else case "$host_os" in # Guess all is fine on glibc systems. *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;; @@ -404,34 +404,33 @@ index 37efd06b67..a23fc0a81c 100644 *) gl_cv_func_gettimeofday_clobber="guessing yes" ;; esac diff --git gdb/osabi.c gdb/osabi.c -index 129164f51e..4eacc074a3 100644 +index 7d0540b181..c61c518652 100644 --- gdb/osabi.c +++ gdb/osabi.c -@@ -65,6 +65,7 @@ static const struct osabi_names gdb_osabi_names[] = +@@ -66,6 +66,7 @@ static const struct osabi_names gdb_osabi_names[] = { "Solaris", NULL }, - { "GNU/Linux", "linux(-gnu)?" }, + { "GNU/Linux", "linux(-gnu[^-]*)?" }, { "FreeBSD", NULL }, + { "FreeBSD/kernel", NULL }, { "NetBSD", NULL }, { "OpenBSD", NULL }, { "WindowsCE", NULL }, diff --git gdb/regcache.c gdb/regcache.c -index fb6a904dec..f9b7105b8f 100644 +index f3f845aad6..7ca007a422 100644 --- gdb/regcache.c +++ gdb/regcache.c -@@ -1079,6 +1079,23 @@ regcache::raw_supply_zeroed (int regnum) +@@ -1035,6 +1035,22 @@ reg_buffer::raw_supply_zeroed (int regnum) m_register_status[regnum] = REG_VALID; } +void -+regcache::raw_supply_unsigned (int regnum, ULONGEST val) ++reg_buffer::raw_supply_unsigned (int regnum, ULONGEST val) +{ + enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch); + gdb_byte *regbuf; + size_t regsize; + + assert_regnum (regnum); -+ gdb_assert (!m_readonly_p); + + regbuf = register_buffer (regnum); + regsize = m_descr->sizeof_register[regnum]; @@ -440,19 +439,19 @@ index fb6a904dec..f9b7105b8f 100644 + m_register_status[regnum] = REG_VALID; +} + - /* Collect register REGNUM from REGCACHE and store its contents in BUF. */ + /* See common/common-regcache.h. */ void diff --git gdb/regcache.h gdb/regcache.h -index 9e3da8c3fc..5c65a9be1e 100644 +index 4a45f33871..94f542c087 100644 --- gdb/regcache.h +++ gdb/regcache.h -@@ -294,6 +294,8 @@ public: - void raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len, - bool is_signed); +@@ -207,6 +207,8 @@ public: + only LEN, without editing the rest of the register. */ + void raw_supply_part (int regnum, int offset, int len, const gdb_byte *in); + void raw_supply_unsigned (int regnum, ULONGEST val); + - void raw_supply_zeroed (int regnum); + void invalidate (int regnum); - enum register_status get_register_status (int regnum) const; + virtual ~reg_buffer () = default; Modified: head/devel/gdb/files/kgdb/amd64fbsd-kern.c ============================================================================== --- head/devel/gdb/files/kgdb/amd64fbsd-kern.c Mon Sep 24 17:08:41 2018 (r480612) +++ head/devel/gdb/files/kgdb/amd64fbsd-kern.c Mon Sep 24 17:23:35 2018 (r480613) @@ -231,7 +231,7 @@ amd64fbsd_kernel_init_abi(struct gdbarch_info info, st { amd64_init_abi(info, gdbarch, - amd64_target_description (X86_XSTATE_SSE_MASK)); + amd64_target_description (X86_XSTATE_SSE_MASK, true)); frame_unwind_prepend_unwinder(gdbarch, &amd64fbsd_trapframe_unwind); Modified: head/devel/gdb/files/kgdb/fbsd-kld.c ============================================================================== --- head/devel/gdb/files/kgdb/fbsd-kld.c Mon Sep 24 17:08:41 2018 (r480612) +++ head/devel/gdb/files/kgdb/fbsd-kld.c Mon Sep 24 17:23:35 2018 (r480613) @@ -139,7 +139,7 @@ find_kld_path (const char *filename, char *path, size_ { struct kld_info *info; struct cleanup *cleanup; - char *module_path; + gdb::unique_xmalloc_ptr module_path; char *module_dir, *cp; int error; @@ -157,17 +157,13 @@ find_kld_path (const char *filename, char *path, size_ target_read_string(info->module_path_addr, &module_path, PATH_MAX, &error); if (error == 0) { - cleanup = make_cleanup(xfree, module_path); - cp = module_path; + cp = module_path.get(); while ((module_dir = strsep(&cp, ";")) != NULL) { snprintf(path, path_size, "%s/%s", module_dir, filename); - if (check_kld_path(path, path_size)) { - do_cleanups(cleanup); + if (check_kld_path(path, path_size)) return (1); - } } - do_cleanups(cleanup); } } return (0); @@ -200,7 +196,7 @@ find_kld_address (const char *arg, CORE_ADDR *address) { struct kld_info *info; CORE_ADDR kld; - char *kld_filename; + gdb::unique_xmalloc_ptr kld_filename; const char *filename; int error; @@ -219,11 +215,8 @@ find_kld_address (const char *arg, CORE_ADDR *address) continue; /* Compare this kld's filename against our passed in name. */ - if (strcmp(kld_filename, filename) != 0) { - xfree(kld_filename); + if (strcmp(kld_filename.get(), filename) != 0) continue; - } - xfree(kld_filename); /* * We found a match, use its address as the base @@ -259,7 +252,6 @@ adjust_section_address (struct target_section *sec, CO static void load_kld (char *path, CORE_ADDR base_addr, int from_tty) { - struct section_addr_info *sap; struct target_section *sections = NULL, *sections_end = NULL, *s; struct cleanup *cleanup; gdb_bfd_ref_ptr bfd; @@ -289,14 +281,14 @@ load_kld (char *path, CORE_ADDR base_addr, int from_tt adjust_section_address(s, &curr_addr); /* Build a section addr info to pass to symbol_file_add(). */ - sap = build_section_addr_info_from_section_table (sections, - sections_end); - make_cleanup((make_cleanup_ftype *)free_section_addr_info, sap); + section_addr_info sap + = build_section_addr_info_from_section_table (sections, + sections_end); printf_unfiltered("add symbol table from file \"%s\" at\n", path); - for (i = 0; i < sap->num_sections; i++) - printf_unfiltered("\t%s_addr = %s\n", sap->other[i].name, - paddress(target_gdbarch(), sap->other[i].addr)); + for (i = 0; i < sap.size(); i++) + printf_unfiltered("\t%s_addr = %s\n", sap[i].name.c_str(), + paddress(target_gdbarch(), sap[i].addr)); if (from_tty && (!query("%s", ""))) error("Not confirmed."); @@ -304,7 +296,7 @@ load_kld (char *path, CORE_ADDR base_addr, int from_tt add_flags = 0; if (from_tty) add_flags |= SYMFILE_VERBOSE; - symbol_file_add_from_bfd(bfd.get(), path, add_flags, sap, + symbol_file_add_from_bfd(bfd.get(), path, add_flags, &sap, OBJF_USERLOADED, NULL); do_cleanups(cleanup); @@ -436,7 +428,7 @@ kld_current_sos (void) struct so_list *head, **prev, *newobj; struct kld_info *info; CORE_ADDR kld, kernel; - char *path; + gdb::unique_xmalloc_ptr path; int error; info = get_kld_info(); @@ -475,9 +467,8 @@ kld_current_sos (void) free_so(newobj); continue; } - strlcpy(newobj->so_original_name, path, + strlcpy(newobj->so_original_name, path.get(), sizeof(newobj->so_original_name)); - xfree(path); /* * Try to read the pathname (if it exists) and store @@ -498,9 +489,8 @@ kld_current_sos (void) strlcpy(newobj->so_name, newobj->so_original_name, sizeof(newobj->so_name)); } else { - strlcpy(newobj->so_name, path, + strlcpy(newobj->so_name, path.get(), sizeof(newobj->so_name)); - xfree(path); } } else strlcpy(newobj->so_name, newobj->so_original_name, @@ -540,19 +530,19 @@ kld_in_dynsym_resolve_code (CORE_ADDR pc) static int kld_find_and_open_solib (const char *solib, unsigned o_flags, - char **temp_pathname) + gdb::unique_xmalloc_ptr *temp_pathname) { char path[PATH_MAX]; int fd; - *temp_pathname = NULL; + temp_pathname->reset (NULL); if (!find_kld_path(solib, path, sizeof(path))) { errno = ENOENT; return (-1); } fd = open(path, o_flags, 0); if (fd >= 0) - *temp_pathname = xstrdup(path); + temp_pathname->reset(xstrdup(path)); return (fd); } Modified: head/devel/gdb/files/kgdb/fbsd-kvm.c ============================================================================== --- head/devel/gdb/files/kgdb/fbsd-kvm.c Mon Sep 24 17:08:41 2018 (r480612) +++ head/devel/gdb/files/kgdb/fbsd-kvm.c Mon Sep 24 17:23:35 2018 (r480613) @@ -51,10 +51,7 @@ __FBSDID("$FreeBSD$"); static CORE_ADDR stoppcbs; static LONGEST pcb_size; -static void kgdb_core_cleanup(void *); - static char *vmcore; -struct target_ops kgdb_trgt_ops; /* Per-architecture data key. */ static struct gdbarch_data *fbsd_vmcore_data; @@ -105,7 +102,6 @@ fbsd_vmcore_set_cpu_pcb_addr (struct gdbarch *gdbarch, static CORE_ADDR kernstart; static kvm_t *kvm; -static char kvm_err[_POSIX2_LINE_MAX]; int kgdb_quiet; static ptid_t @@ -116,14 +112,14 @@ fbsd_vmcore_ptid(int tid) * The remote target stores the 'tid' in the lwp * field. */ - return ptid_build(ptid_get_pid(inferior_ptid), tid, 0); + return ptid_t(inferior_ptid.pid(), tid, 0); /* * This follows the model described in bsd-kvm.c except that * in kernel tids are used as the tid of the ptid instead of a * process ID. */ - return ptid_build(1, 1, tid); + return ptid_t(1, 1, tid); } #define MSGBUF_SEQ_TO_POS(size, seq) ((seq) % (size)) @@ -212,6 +208,49 @@ fbsd_kernel_osabi_sniffer(bfd *abfd) return (GDB_OSABI_UNKNOWN); } +/* The FreeBSD libkvm target. */ + +static const target_info fbsd_kvm_target_info = { + "vmcore", + N_("Kernel core dump file"), + N_("Use a vmcore file as a target.\n\ +If no filename is specified, /dev/mem is used to examine the running kernel.\n\ +target vmcore [-w] [filename]") +}; + +class fbsd_kvm_target final : public target_ops +{ +public: + fbsd_kvm_target () + { this->to_stratum = process_stratum; } + + const target_info &info () const override + { return fbsd_kvm_target_info; } + + void close () override; + + void fetch_registers (struct regcache *, int) override; + enum target_xfer_status xfer_partial (enum target_object object, + const char *annex, + gdb_byte *readbuf, + const gdb_byte *writebuf, + ULONGEST offset, ULONGEST len, + ULONGEST *xfered_len) override; + + void files_info () override; + bool thread_alive (ptid_t ptid) override; + void update_thread_list () override; + const char *pid_to_str (ptid_t) override; + const char *extra_thread_info (thread_info *) override; + + bool has_memory () override { return true; } + bool has_stack () override { return true; } + bool has_registers () override { return true; } +}; + +/* Target ops for libkvm interface. */ +static fbsd_kvm_target fbsd_kvm_ops; + #ifdef HAVE_KVM_OPEN2 static int kgdb_resolve_symbol(const char *name, kvaddr_t *kva) @@ -227,10 +266,11 @@ kgdb_resolve_symbol(const char *name, kvaddr_t *kva) #endif static void -kgdb_trgt_open(const char *args, int from_tty) +fbsd_kvm_target_open (const char *args, int from_tty) { struct fbsd_vmcore_ops *ops = (struct fbsd_vmcore_ops *) gdbarch_data (target_gdbarch(), fbsd_vmcore_data); + char kvm_err[_POSIX2_LINE_MAX]; struct inferior *inf; struct cleanup *old_chain; struct thread_info *ti; @@ -288,7 +328,7 @@ kgdb_trgt_open(const char *args, int from_tty) /* Don't free the filename now and close any previous vmcore. */ discard_cleanups(old_chain); - unpush_target(&kgdb_trgt_ops); + unpush_target(&fbsd_kvm_ops); /* * Determine the first address in KVA. Newer kernels export @@ -331,11 +371,8 @@ kgdb_trgt_open(const char *args, int from_tty) kvm = nkvm; vmcore = filename; - old_chain = make_cleanup(kgdb_core_cleanup, NULL); + push_target (&fbsd_kvm_ops); - push_target (&kgdb_trgt_ops); - discard_cleanups (old_chain); - kgdb_dmesg(); inf = current_inferior(); @@ -359,8 +396,8 @@ kgdb_trgt_open(const char *args, int from_tty) print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1); } -static void -kgdb_trgt_close(struct target_ops *self) +void +fbsd_kvm_target::close() { if (kvm != NULL) { @@ -376,14 +413,8 @@ kgdb_trgt_close(struct target_ops *self) inferior_ptid = null_ptid; } +#if 0 static void -kgdb_core_cleanup(void *arg) -{ - - kgdb_trgt_close(0); -} - -static void kgdb_trgt_detach(struct target_ops *ops, const char *args, int from_tty) { @@ -394,16 +425,17 @@ kgdb_trgt_detach(struct target_ops *ops, const char *a if (from_tty) printf_filtered("No vmcore file now.\n"); } +#endif -static const char * -kgdb_trgt_extra_thread_info(struct target_ops *ops, struct thread_info *ti) +const char * +fbsd_kvm_target::extra_thread_info(thread_info *ti) { - return (kgdb_thr_extra_thread_info(ptid_get_tid(ti->ptid))); + return (kgdb_thr_extra_thread_info(ti->ptid.tid())); } -static void -kgdb_trgt_files_info(struct target_ops *target) +void +fbsd_kvm_target::files_info() { *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***