Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Mar 2018 14:33:22 +0000 (UTC)
From:      Luca Pizzamiglio <pizzamig@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r464493 - in head/devel/gdb: . files files/kgdb
Message-ID:  <201803141433.w2EEXMGn079353@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pizzamig
Date: Wed Mar 14 14:33:21 2018
New Revision: 464493
URL: https://svnweb.freebsd.org/changeset/ports/464493

Log:
  devel/gdb: Update to version 8.1
  
  The official annoucement is available here:
  https://www.gnu.org/software/gdb/download/ANNOUNCEMENT
  
  Moreover:
  * support for 'info proc' is added (jhb@)
  * update kgdb to use gdb 8.1
  
  Reviewed by:	jhb@
  Differential Revision:	https://reviews.freebsd.org/D14148

Added:
  head/devel/gdb/files/commit-12279366d7   (contents, props changed)
  head/devel/gdb/files/commit-262f62f57d   (contents, props changed)
  head/devel/gdb/files/commit-2d97a5d9d3   (contents, props changed)
  head/devel/gdb/files/commit-386a867618   (contents, props changed)
  head/devel/gdb/files/commit-7efba073e2   (contents, props changed)
  head/devel/gdb/files/commit-906b4aac4c   (contents, props changed)
  head/devel/gdb/files/commit-92fce24de2   (contents, props changed)
  head/devel/gdb/files/commit-b999e2038d   (contents, props changed)
  head/devel/gdb/files/commit-d2176225dc   (contents, props changed)
  head/devel/gdb/files/commit-f169cfdc08   (contents, props changed)
Deleted:
  head/devel/gdb/files/commit-0335ac6d12
  head/devel/gdb/files/commit-0aa37b654c
  head/devel/gdb/files/commit-0b9305edf1
  head/devel/gdb/files/commit-12c4bd7f53
  head/devel/gdb/files/commit-2af9fc4432
  head/devel/gdb/files/commit-382b69bbb7
  head/devel/gdb/files/commit-3c3ae77e68
  head/devel/gdb/files/commit-45eba0ab7d
  head/devel/gdb/files/commit-48aeef91c2
  head/devel/gdb/files/commit-4b654465bf
  head/devel/gdb/files/commit-544c67cda1
  head/devel/gdb/files/commit-6d5be5d6b8
  head/devel/gdb/files/commit-6e5eab33ab
  head/devel/gdb/files/commit-762c974a09
  head/devel/gdb/files/commit-929edea98d
  head/devel/gdb/files/commit-a181c0bf74
  head/devel/gdb/files/commit-a80a647180
  head/devel/gdb/files/commit-b30ff123fb
  head/devel/gdb/files/commit-b5430a3ced
  head/devel/gdb/files/commit-e6f3b9c319
  head/devel/gdb/files/patch-aarch64-fbsd
  head/devel/gdb/files/patch-armfbsd
  head/devel/gdb/files/patch-gdb_configure.host
  head/devel/gdb/files/patch-nowarning
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/mipsfbsd-kern.c
  head/devel/gdb/files/kgdb/ppcfbsd-kern.c
  head/devel/gdb/files/kgdb/sparc64fbsd-kern.c
  head/devel/gdb/files/patch-gdb_configure

Modified: head/devel/gdb/Makefile
==============================================================================
--- head/devel/gdb/Makefile	Wed Mar 14 13:58:03 2018	(r464492)
+++ head/devel/gdb/Makefile	Wed Mar 14 14:33:21 2018	(r464493)
@@ -2,8 +2,7 @@
 # $FreeBSD$
 
 PORTNAME=	gdb
-PORTVERSION=	8.0.1
-PORTREVISION=	2
+PORTVERSION=	8.1
 CATEGORIES=	devel
 MASTER_SITES=	GNU
 
@@ -39,26 +38,16 @@ CFLAGS:=	${CFLAGS:C/ +$//}	# blanks at EOL creep in so
 CFLAGS+=	-DRL_NO_COMPAT -Wno-unused-function -Wno-unused-variable
 EXCLUDE=	dejagnu expect sim texinfo intl
 EXTRACT_AFTER_ARGS=	${EXCLUDE:S/^/--exclude /}
-EXTRA_PATCHES=	${FILESDIR}/commit-45eba0ab7d \
-		${FILESDIR}/commit-3c3ae77e68 \
-		${FILESDIR}/commit-b5430a3ced \
-		${FILESDIR}/commit-762c974a09 \
-		${FILESDIR}/commit-929edea98d \
-		${FILESDIR}/commit-6e5eab33ab \
-		${FILESDIR}/commit-382b69bbb7 \
-		${FILESDIR}/commit-2af9fc4432 \
-		${FILESDIR}/commit-0b9305edf1 \
-		${FILESDIR}/commit-e6f3b9c319 \
-		${FILESDIR}/commit-4b654465bf \
-		${FILESDIR}/commit-b30ff123fb \
-		${FILESDIR}/commit-48aeef91c2 \
-		${FILESDIR}/commit-0aa37b654c \
-		${FILESDIR}/commit-0335ac6d12 \
-		${FILESDIR}/commit-12c4bd7f53 \
-		${FILESDIR}/commit-6d5be5d6b8 \
-		${FILESDIR}/commit-a80a647180 \
-		${FILESDIR}/commit-544c67cda1 \
-		${FILESDIR}/commit-a181c0bf74
+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
 LIB_DEPENDS+=	libexpat.so:textproc/expat2
 
 VER=		${PORTVERSION:S/.//g}

Modified: head/devel/gdb/distinfo
==============================================================================
--- head/devel/gdb/distinfo	Wed Mar 14 13:58:03 2018	(r464492)
+++ head/devel/gdb/distinfo	Wed Mar 14 14:33:21 2018	(r464493)
@@ -1,3 +1,3 @@
-TIMESTAMP = 1505207991
-SHA256 (gdb-8.0.1.tar.xz) = 3dbd5f93e36ba2815ad0efab030dcd0c7b211d7b353a40a53f4c02d7d56295e3
-SIZE (gdb-8.0.1.tar.xz) = 19583920
+TIMESTAMP = 1517392551
+SHA256 (gdb-8.1.tar.xz) = af61a0263858e69c5dce51eab26662ff3d2ad9aa68da9583e8143b5426be4b34
+SIZE (gdb-8.1.tar.xz) = 20095080

Added: head/devel/gdb/files/commit-12279366d7
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-12279366d7	Wed Mar 14 14:33:21 2018	(r464493)
@@ -0,0 +1,121 @@
+commit 12279366d71627bfbdd74d1a6675dca825d8feca
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Sat Mar 3 21:25:33 2018 -0800
+
+    Implement "to_stopped_by_hw_breakpoint" for x86 debug registers.
+    
+    Report that a thread is stopped by a hardware breakpoint if a non-data
+    watchpoint is set in DR6.  This change should be a no-op since a target
+    still needs to implement the "to_supports_stopped_by_hw_breakpoint"
+    method before this function is used.
+    
+    gdb/ChangeLog:
+    
+            * nat/x86-dregs.c (x86_dr_stopped_by_hw_breakpoint): New function.
+            * nat/x86-dregs.h (x86_dr_stopped_by_hw_breakpoint): New
+            prototype.
+            * x86-nat.c (x86_stopped_by_hw_breakpoint): New function.
+            (x86_use_watchpoints): Set "stopped_by_hw_breakpoint" target
+            method.
+
+diff --git gdb/nat/x86-dregs.c gdb/nat/x86-dregs.c
+index c816473628..f11a708e27 100644
+--- gdb/nat/x86-dregs.c
++++ gdb/nat/x86-dregs.c
+@@ -649,3 +649,48 @@ x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state)
+   CORE_ADDR addr = 0;
+   return x86_dr_stopped_data_address (state, &addr);
+ }
++
++/* Return non-zero if the inferior has some hardware breakpoint that
++   triggered.  Otherwise return zero.  */
++
++int
++x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state)
++{
++  CORE_ADDR addr = 0;
++  int i;
++  int rc = 0;
++  /* The current thread's DR_STATUS.  We always need to read this to
++     check whether some watchpoint caused the trap.  */
++  unsigned status;
++  /* We need DR_CONTROL as well, but only iff DR_STATUS indicates a
++     breakpoint trap.  Only fetch it when necessary, to avoid an
++     unnecessary extra syscall when no watchpoint triggered.  */
++  int control_p = 0;
++  unsigned control = 0;
++
++  /* As above, always read the current thread's debug registers rather
++     than trusting dr_mirror.  */
++  status = x86_dr_low_get_status ();
++
++  ALL_DEBUG_ADDRESS_REGISTERS (i)
++    {
++      if (!X86_DR_WATCH_HIT (status, i))
++	continue;
++
++      if (!control_p)
++	{
++	  control = x86_dr_low_get_control ();
++	  control_p = 1;
++	}
++
++      if (X86_DR_GET_RW_LEN (control, i) == 0)
++	{
++	  addr = x86_dr_low_get_addr (i);
++	  rc = 1;
++	  if (show_debug_regs)
++	    x86_show_dr (state, "watchpoint_hit", addr, -1, hw_execute);
++	}
++    }
++
++  return rc;
++}
+diff --git gdb/nat/x86-dregs.h gdb/nat/x86-dregs.h
+index dd6242eda9..e86e83aea0 100644
+--- gdb/nat/x86-dregs.h
++++ gdb/nat/x86-dregs.h
+@@ -128,4 +128,8 @@ extern int x86_dr_stopped_data_address (struct x86_debug_reg_state *state,
+    Otherwise return false.  */
+ extern int x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state);
+ 
++/* Return true if the inferior has some hardware breakpoint that
++   triggered.  Otherwise return false.  */
++extern int x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state);
++
+ #endif /* X86_DREGS_H */
+diff --git gdb/x86-nat.c gdb/x86-nat.c
+index b126c47c94..bec51373a6 100644
+--- gdb/x86-nat.c
++++ gdb/x86-nat.c
+@@ -260,6 +260,18 @@ x86_can_use_hw_breakpoint (struct target_ops *self,
+   return 1;
+ }
+ 
++/* Return non-zero if the inferior has some breakpoint that triggered.
++   Otherwise return zero.  */
++
++static int
++x86_stopped_by_hw_breakpoint (struct target_ops *ops)
++{
++  struct x86_debug_reg_state *state
++    = x86_debug_reg_state (ptid_get_pid (inferior_ptid));
++
++  return x86_dr_stopped_by_hw_breakpoint (state);
++}
++
+ static void
+ add_show_debug_regs_command (void)
+ {
+@@ -297,6 +309,11 @@ x86_use_watchpoints (struct target_ops *t)
+   t->to_remove_watchpoint = x86_remove_watchpoint;
+   t->to_insert_hw_breakpoint = x86_insert_hw_breakpoint;
+   t->to_remove_hw_breakpoint = x86_remove_hw_breakpoint;
++
++  /* A target must provide an implementation of the
++     "to_supports_stopped_by_hw_breakpoint" target method before this
++     callback will be used.  */
++  t->to_stopped_by_hw_breakpoint = x86_stopped_by_hw_breakpoint;
+ }
+ 
+ void

Added: head/devel/gdb/files/commit-262f62f57d
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-262f62f57d	Wed Mar 14 14:33:21 2018	(r464493)
@@ -0,0 +1,43 @@
+commit 262f62f57d987269152412a55c458a03adc6ddd6
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Tue Jan 9 13:35:17 2018 -0800
+
+    Use gdb::unique_xmalloc_ptr<> instead of a deleter that invokes free().
+    
+    Since xfree() always wraps free(), it is safe to use the xfree deleter
+    for buffers allocated by library routines such as kinfo_getvmmap() that
+    must be released via free().
+    
+    gdb/ChangeLog:
+    
+            * fbsd-nat.c (struct free_deleter): Remove.
+            (fbsd_find_memory_regions): Use gdb::unique_xmalloc_ptr<>.
+
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index d0aaf89145..81f8e27a2d 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -81,14 +81,6 @@ fbsd_pid_to_exec_file (struct target_ops *self, int pid)
+ }
+ 
+ #ifdef HAVE_KINFO_GETVMMAP
+-/* Deleter for std::unique_ptr that invokes free.  */
+-
+-template <typename T>
+-struct free_deleter
+-{
+-  void operator() (T *ptr) const { free (ptr); }
+-};
+-
+ /* 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.  */
+@@ -102,7 +94,7 @@ fbsd_find_memory_regions (struct target_ops *self,
+   uint64_t size;
+   int i, nitems;
+ 
+-  std::unique_ptr<struct kinfo_vmentry, free_deleter<struct kinfo_vmentry>>
++  gdb::unique_xmalloc_ptr<struct kinfo_vmentry>
+     vmentl (kinfo_getvmmap (pid, &nitems));
+   if (vmentl == NULL)
+     perror_with_name (_("Couldn't fetch VM map entries."));

Added: head/devel/gdb/files/commit-2d97a5d9d3
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-2d97a5d9d3	Wed Mar 14 14:33:21 2018	(r464493)
@@ -0,0 +1,169 @@
+commit 2d97a5d9d33aea87c3bd02fd1fa417f5d4e1fa05
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Tue Jan 9 13:35:17 2018 -0800
+
+    Document support for 'info proc' on FreeBSD.
+    
+    Since the 'info proc' support on FreeBSD does not use /proc, reword
+    the documentation for 'info proc' to not assume /proc.  This includes
+    renaming the node to 'Process Information' and suggesting that
+    additional process information can be queried via different
+    OS-specific interfaces.  This is also cleans up the description of
+    'info proc' support for core files a bit as /proc is not used for core
+    file support on any current platform.
+    
+    gdb/ChangeLog:
+    
+            * NEWS: Document that 'info proc' now works on FreeBSD.
+    
+    gdb/doc/ChangeLog:
+    
+            * gdb.texinfo (pwd): Update cross-reference for Process Information
+            node and remove explicit /proc reference.
+            (Native): Rename subsection from SVR4 Process Information to
+            Process Information.
+            (Process Information): Reword introduction to be less /proc
+            centric.  Document support for "info proc" on FreeBSD.
+
+diff --git gdb/NEWS gdb/NEWS
+index 2f834c6ff4..f69173a245 100644
+--- gdb/NEWS
++++ gdb/NEWS
+@@ -3,6 +3,9 @@
+ 
+ *** Changes since GDB 8.1
+ 
++* 'info proc' now works on running processes on FreeBSD systems and core
++  files created on FreeBSD systems.
++
+ *** Changes in GDB 8.1
+ 
+ * GDB now supports dynamically creating arbitrary register groups specified
+diff --git gdb/doc/gdb.texinfo gdb/doc/gdb.texinfo
+index 8bdafb0ba4..096c82cc82 100644
+--- gdb/doc/gdb.texinfo
++++ gdb/doc/gdb.texinfo
+@@ -2523,9 +2523,9 @@ Print the @value{GDBN} working directory.
+ 
+ It is generally impossible to find the current working directory of
+ the process being debugged (since a program can change its directory
+-during its run).  If you work on a system where @value{GDBN} is
+-configured with the @file{/proc} support, you can use the @code{info
+-proc} command (@pxref{SVR4 Process Information}) to find out the
++during its run).  If you work on a system where @value{GDBN} supports
++the @code {info proc} command (@pxref{Process Information}), you can
++use the @code{info proc} command to find out the
+ current working directory of the debuggee.
+ 
+ @node Input/Output
+@@ -21712,7 +21712,7 @@ configurations.
+ 
+ @menu
+ * BSD libkvm Interface::	Debugging BSD kernel memory images
+-* SVR4 Process Information::    SVR4 process information
++* Process Information::         Process information
+ * DJGPP Native::                Features specific to the DJGPP port
+ * Cygwin Native::		Features specific to the Cygwin port
+ * Hurd Native::                 Features specific to @sc{gnu} Hurd
+@@ -21759,24 +21759,32 @@ Set current context from proc address.  This command isn't available on
+ modern FreeBSD systems.
+ @end table
+ 
+-@node SVR4 Process Information
+-@subsection SVR4 Process Information
++@node Process Information
++@subsection Process Information
+ @cindex /proc
+ @cindex examine process image
+ @cindex process info via @file{/proc}
+ 
+-Many versions of SVR4 and compatible systems provide a facility called
+-@samp{/proc} that can be used to examine the image of a running
+-process using file-system subroutines.
++Some operating systems provide interfaces to fetch additional
++information about running processes beyond memory and per-thread
++register state.  If @value{GDBN} is configured for an operating system
++with a supported interface, the command @code{info proc} is available
++to report information about the process running your program, or about
++any process running on your system.
+ 
+-If @value{GDBN} is configured for an operating system with this
+-facility, the command @code{info proc} is available to report
+-information about the process running your program, or about any
+-process running on your system.  This includes, as of this writing,
+-@sc{gnu}/Linux and Solaris, for example.
++One supported interface is a facility called @samp{/proc} that can be
++used to examine the image of a running process using file-system
++subroutines.  This facility is supported on @sc{gnu}/Linux and Solaris
++systems.
+ 
+-This command may also work on core files that were created on a system
+-that has the @samp{/proc} facility.
++On FreeBSD systems, system control nodes are used to query process
++information.
++
++In addition, some systems may provide additional process information
++in core files.  Note that a core file may include a subset of the
++information available from a live process.  Process information is
++currently avaiable from cores created on @sc{gnu}/Linux and FreeBSD
++systems.
+ 
+ @table @code
+ @kindex info proc
+@@ -21800,36 +21808,40 @@ a process ID rather than a thread ID).
+ @item info proc cmdline
+ @cindex info proc cmdline
+ Show the original command line of the process.  This command is
+-specific to @sc{gnu}/Linux.
++supported on @sc{gnu}/Linux and FreeBSD.
+ 
+ @item info proc cwd
+ @cindex info proc cwd
+ Show the current working directory of the process.  This command is
+-specific to @sc{gnu}/Linux.
++supported on @sc{gnu}/Linux and FreeBSD.
+ 
+ @item info proc exe
+ @cindex info proc exe
+-Show the name of executable of the process.  This command is specific
+-to @sc{gnu}/Linux.
++Show the name of executable of the process.  This command is supported
++on @sc{gnu}/Linux and FreeBSD.
+ 
+ @item info proc mappings
+ @cindex memory address space mappings
+-Report the memory address space ranges accessible in the program, with
+-information on whether the process has read, write, or execute access
+-rights to each range.  On @sc{gnu}/Linux systems, each memory range
+-includes the object file which is mapped to that range, instead of the
+-memory access rights to that range.
++Report the memory address space ranges accessible in the program.  On
++Solaris and FreeBSD systems, each memory range includes information on
++whether the process has read, write, or execute access rights to each
++range.  On @sc{gnu}/Linux and FreeBSD systems, each memory range
++includes the object file which is mapped to that range.
+ 
+ @item info proc stat
+ @itemx info proc status
+ @cindex process detailed status information
+-These subcommands are specific to @sc{gnu}/Linux systems.  They show
+-the process-related information, including the user ID and group ID;
+-how many threads are there in the process; its virtual memory usage;
+-the signals that are pending, blocked, and ignored; its TTY; its
+-consumption of system and user time; its stack size; its @samp{nice}
+-value; etc.  For more information, see the @samp{proc} man page
+-(type @kbd{man 5 proc} from your shell prompt).
++Show additional process-related information, including the user ID and
++group ID; virtual memory usage; the signals that are pending, blocked,
++and ignored; its TTY; its consumption of system and user time; its
++stack size; its @samp{nice} value; etc.  These commands are supported
++on @sc{gnu}/Linux and FreeBSD.
++
++For @sc{gnu}/Linux systems, see the @samp{proc} man page for more
++information (type @kbd{man 5 proc} from your shell prompt).
++
++For FreeBSD systems, @code{info proc stat} is an alias for @code{info
++proc status}.
+ 
+ @item info proc all
+ Show all the information about the process described under all of the

Added: head/devel/gdb/files/commit-386a867618
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-386a867618	Wed Mar 14 14:33:21 2018	(r464493)
@@ -0,0 +1,115 @@
+commit 386a86761838df16c1459275d465ed21a1c35d9f
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Sat Mar 3 21:25:33 2018 -0800
+
+    Add a new debug knob for the FreeBSD native target.
+    
+    For now this just logs information about the state of the current LWP
+    for each STOPPED event in fbsd_wait().
+    
+    gdb/ChangeLog:
+    
+            * NEWS (Changes since GDB 8.1): Add "set/show debug fbsd-nat".
+            * fbsd-nat.c (debug_fbsd_nat): New variable.
+            (show_fbsd_nat_debug): New function.
+            (fbsd_wait): Log LWP info if "debug_fbsd_nat" is enabled.
+            (_initialize_fbsd_nat): Add "fbsd-nat" debug boolean command.
+    
+    gdb/doc/ChangeLog:
+    
+            * gdb.texinfo (Debugging Output): Document "set/show debug
+            fbsd-nat".
+
+diff --git gdb/NEWS gdb/NEWS
+index 1767cef920..867e268a2a 100644
+--- gdb/NEWS
++++ gdb/NEWS
+@@ -6,6 +6,12 @@
+ * 'info proc' now works on running processes on FreeBSD systems and core
+   files created on FreeBSD systems.
+ 
++* New commands
++
++set debug fbsd-nat
++show debug fbsd-nat
++  Control display of debugging info regarding the FreeBSD native target.
++
+ *** Changes in GDB 8.1
+ 
+ * GDB now supports dynamically creating arbitrary register groups specified
+diff --git gdb/doc/gdb.texinfo gdb/doc/gdb.texinfo
+index ee7adc8df2..74e0fdb4a4 100644
+--- gdb/doc/gdb.texinfo
++++ gdb/doc/gdb.texinfo
+@@ -24554,6 +24554,11 @@ Displays the current state of displaying debugging info about
+ Turns on or off debugging messages from the FreeBSD LWP debug support.
+ @item show debug fbsd-lwp
+ Show the current state of FreeBSD LWP debugging messages.
++@item set debug fbsd-nat
++@cindex FreeBSD native target debug messages
++Turns on or off debugging messages from the FreeBSD native target.
++@item show debug fbsd-nat
++Show the current state of FreeBSD native target debugging messages.
+ @item set debug frame
+ @cindex frame debugging info
+ Turns on or off display of @value{GDBN} frame debugging info.  The
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index 3a216abf18..2516ac5552 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -765,6 +765,7 @@ fbsd_xfer_partial (struct target_ops *ops, enum target_object object,
+ 
+ #ifdef PT_LWPINFO
+ static int debug_fbsd_lwp;
++static int debug_fbsd_nat;
+ 
+ static void (*super_resume) (struct target_ops *,
+ 			     ptid_t,
+@@ -782,6 +783,14 @@ show_fbsd_lwp_debug (struct ui_file *file, int from_tty,
+   fprintf_filtered (file, _("Debugging of FreeBSD lwp module is %s.\n"), value);
+ }
+ 
++static void
++show_fbsd_nat_debug (struct ui_file *file, int from_tty,
++		     struct cmd_list_element *c, const char *value)
++{
++  fprintf_filtered (file, _("Debugging of FreeBSD native target is %s.\n"),
++		    value);
++}
++
+ /*
+   FreeBSD's first thread support was via a "reentrant" version of libc
+   (libc_r) that first shipped in 2.2.7.  This library multiplexed all
+@@ -1212,6 +1221,18 @@ fbsd_wait (struct target_ops *ops,
+ 
+ 	  wptid = ptid_build (pid, pl.pl_lwpid, 0);
+ 
++	  if (debug_fbsd_nat)
++	    {
++	      fprintf_unfiltered (gdb_stdlog,
++				  "FNAT: stop for LWP %u event %d flags %#x\n",
++				  pl.pl_lwpid, pl.pl_event, pl.pl_flags);
++	      if (pl.pl_flags & PL_FLAG_SI)
++		fprintf_unfiltered (gdb_stdlog,
++				    "FNAT: si_signo %u si_code %u\n",
++				    pl.pl_siginfo.si_signo,
++				    pl.pl_siginfo.si_code);
++	    }
++
+ #ifdef PT_LWP_EVENTS
+ 	  if (pl.pl_flags & PL_FLAG_EXITED)
+ 	    {
+@@ -1569,5 +1590,13 @@ Enables printf debugging output."),
+ 			   NULL,
+ 			   &show_fbsd_lwp_debug,
+ 			   &setdebuglist, &showdebuglist);
++  add_setshow_boolean_cmd ("fbsd-nat", class_maintenance,
++			   &debug_fbsd_nat, _("\
++Set debugging of FreeBSD native target."), _("\
++Show debugging of FreeBSD native target."), _("\
++Enables printf debugging output."),
++			   NULL,
++			   &show_fbsd_nat_debug,
++			   &setdebuglist, &showdebuglist);
+ #endif
+ }

Added: head/devel/gdb/files/commit-7efba073e2
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-7efba073e2	Wed Mar 14 14:33:21 2018	(r464493)
@@ -0,0 +1,184 @@
+commit 7efba073e2b83803a47fd89e701fe60b98f2debc
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Sat Mar 3 21:25:33 2018 -0800
+
+    Use signal information to determine SIGTRAP type for FreeBSD.
+    
+    Use the signal code from siginfo_t to distinguish SIGTRAP events due
+    to trace traps (TRAP_TRACE) and software breakpoints (TRAP_BRKPT).
+    For software breakpoints, adjust the PC when the event is reported as
+    part of the API when supplying "stopped_by_sw_breakpoint".  Currently
+    FreeBSD only supports hardware watchpoints and breakpoints on x86
+    which are reported as trace traps.  Signal information is not used on
+    MIPS and sparc64 kernels which do not reliably report TRAP_BRKPT for
+    software breakpoints.
+    
+    gdb/ChangeLog:
+    
+            * fbsd-nat.c: Include "inf-ptrace.h".
+            (USE_SIGTRAP_SIGINFO): Conditionally define.
+            [USE_SIGTRAP_SIGINFO] (fbsd_handle_debug_trap): New function.
+            (fbsd_wait) [USE_SIGTRAP_SIGINFO]: Call "fbsd_handle_debug_trap".
+            [USE_SIGTRAP_SIGINFO] (fbsd_stopped_by_sw_breakpoint): New
+            function.
+            [USE_SIGTRAP_SIGINFO] (fbsd_supports_stopped_by_sw_breakpoint):
+            Likewise.
+            [USE_SIGTRAP_SIGINFO] (fbsd_supports_stopped_by_hw_breakpoint):
+            Likewise.
+            (fbsd_nat_add_target) [USE_SIGTRAP_SIGINFO]: Set
+            "stopped_by_sw_breakpoint", "supports_stopped_by_sw_breakpoint",
+            "supports_stopped_by_hw_breakpoint" target methods.
+
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index 2516ac5552..bea7f42c7e 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -26,6 +26,7 @@
+ #include "gdbcmd.h"
+ #include "gdbthread.h"
+ #include "gdb_wait.h"
++#include "inf-ptrace.h"
+ #include <sys/types.h>
+ #include <sys/procfs.h>
+ #include <sys/ptrace.h>
+@@ -45,6 +46,14 @@
+ 
+ #include <list>
+ 
++#ifdef TRAP_BRKPT
++/* MIPS does not set si_code for SIGTRAP.  sparc64 reports
++   non-standard values in si_code for SIGTRAP.  */
++# if !defined(__mips__) && !defined(__sparc64__)
++#  define USE_SIGTRAP_SIGINFO
++# endif
++#endif
++
+ /* Return the name of a file that can be opened to get the symbols for
+    the child process identified by PID.  */
+ 
+@@ -1187,6 +1196,56 @@ fbsd_resume (struct target_ops *ops,
+   super_resume (ops, ptid, step, signo);
+ }
+ 
++#ifdef USE_SIGTRAP_SIGINFO
++/* Handle breakpoint and trace traps reported via SIGTRAP.  If the
++   trap was a breakpoint or trace trap that should be reported to the
++   core, return true.  */
++
++static bool
++fbsd_handle_debug_trap (struct target_ops *ops, ptid_t ptid,
++			const struct ptrace_lwpinfo &pl)
++{
++
++  /* Ignore traps without valid siginfo or for signals other than
++     SIGTRAP.  */
++  if (! (pl.pl_flags & PL_FLAG_SI) || pl.pl_siginfo.si_signo != SIGTRAP)
++    return false;
++
++  /* Trace traps are either a single step or a hardware watchpoint or
++     breakpoint.  */
++  if (pl.pl_siginfo.si_code == TRAP_TRACE)
++    {
++      if (debug_fbsd_nat)
++	fprintf_unfiltered (gdb_stdlog,
++			    "FNAT: trace trap for LWP %ld\n", ptid.lwp ());
++      return true;
++    }
++
++  if (pl.pl_siginfo.si_code == TRAP_BRKPT)
++    {
++      /* Fixup PC for the software breakpoint.  */
++      struct regcache *regcache = get_thread_regcache (ptid);
++      struct gdbarch *gdbarch = regcache->arch ();
++      int decr_pc = gdbarch_decr_pc_after_break (gdbarch);
++
++      if (debug_fbsd_nat)
++	fprintf_unfiltered (gdb_stdlog,
++			    "FNAT: sw breakpoint trap for LWP %ld\n",
++			    ptid.lwp ());
++      if (decr_pc != 0)
++	{
++	  CORE_ADDR pc;
++
++	  pc = regcache_read_pc (regcache);
++	  regcache_write_pc (regcache, pc - decr_pc);
++	}
++      return true;
++    }
++
++  return false;
++}
++#endif
++
+ /* 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.  */
+@@ -1372,6 +1431,11 @@ fbsd_wait (struct target_ops *ops,
+ 	    }
+ #endif
+ 
++#ifdef USE_SIGTRAP_SIGINFO
++	  if (fbsd_handle_debug_trap (ops, wptid, pl))
++	    return wptid;
++#endif
++
+ 	  /* Note that PL_FLAG_SCE is set for any event reported while
+ 	     a thread is executing a system call in the kernel.  In
+ 	     particular, signals that interrupt a sleep in a system
+@@ -1410,6 +1474,42 @@ fbsd_wait (struct target_ops *ops,
+     }
+ }
+ 
++#ifdef USE_SIGTRAP_SIGINFO
++/* Implement the "to_stopped_by_sw_breakpoint" target_ops method.  */
++
++static int
++fbsd_stopped_by_sw_breakpoint (struct target_ops *ops)
++{
++  struct ptrace_lwpinfo pl;
++
++  if (ptrace (PT_LWPINFO, get_ptrace_pid (inferior_ptid), (caddr_t) &pl,
++	      sizeof pl) == -1)
++    return 0;
++
++  return ((pl.pl_flags & PL_FLAG_SI)
++	  && pl.pl_siginfo.si_signo == SIGTRAP
++	  && pl.pl_siginfo.si_code == TRAP_BRKPT);
++}
++
++/* Implement the "to_supports_stopped_by_sw_breakpoint" target_ops
++   method.  */
++
++static int
++fbsd_supports_stopped_by_sw_breakpoint (struct target_ops *ops)
++{
++  return 1;
++}
++
++/* Implement the "to_supports_stopped_by_hw_breakpoint" target_ops
++   method.  */
++
++static int
++fbsd_supports_stopped_by_hw_breakpoint (struct target_ops *ops)
++{
++  return ops->to_stopped_by_hw_breakpoint != NULL;
++}
++#endif
++
+ #ifdef TDP_RFPPWAIT
+ /* Target hook for follow_fork.  On entry and at return inferior_ptid is
+    the ptid of the followed inferior.  */
+@@ -1560,6 +1660,13 @@ fbsd_nat_add_target (struct target_ops *t)
+   t->to_wait = fbsd_wait;
+   t->to_post_startup_inferior = fbsd_post_startup_inferior;
+   t->to_post_attach = fbsd_post_attach;
++#ifdef USE_SIGTRAP_SIGINFO
++  t->to_stopped_by_sw_breakpoint = fbsd_stopped_by_sw_breakpoint;
++  t->to_supports_stopped_by_sw_breakpoint
++    = fbsd_supports_stopped_by_sw_breakpoint;
++  t->to_supports_stopped_by_hw_breakpoint
++    = fbsd_supports_stopped_by_hw_breakpoint;
++#endif
+ #ifdef TDP_RFPPWAIT
+   t->to_follow_fork = fbsd_follow_fork;
+   t->to_insert_fork_catchpoint = fbsd_insert_fork_catchpoint;

Added: head/devel/gdb/files/commit-906b4aac4c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-906b4aac4c	Wed Mar 14 14:33:21 2018	(r464493)
@@ -0,0 +1,29 @@
+commit 906b4aac4c1d3cdb2b1ea7105133cfbe25e04e14
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Fri Jan 12 12:05:50 2018 -0800
+
+    Use the correct value for the offset of 'kve_protection'.
+    
+    I had forgotten to convert the decimal output of 'ptype /o' to hex
+    (but still used a 0x prefix) for the KVE_PROTECTION constant defining
+    the offset of the 'kve_protection' field in the 'kinfo_vmentry'
+    structure.  This resulted in garbage permissions for entries in 'info
+    proc mappings' for FreeBSD core dumps.
+    
+    gdb/ChangeLog:
+    
+            * fbsd-tdep.c (KVE_PROTECTION): Correct value.
+
+diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c
+index 8aa0243d54..e49a9aff09 100644
+--- gdb/fbsd-tdep.c
++++ gdb/fbsd-tdep.c
+@@ -62,7 +62,7 @@
+ #define	KVE_END			0x10
+ #define	KVE_OFFSET		0x18
+ #define	KVE_FLAGS		0x2c
+-#define	KVE_PROTECTION		0x56
++#define	KVE_PROTECTION		0x38
+ #define	KVE_PATH		0x88
+ 
+ /* Flags in the 'kve_protection' field in struct kinfo_vmentry.  These

Added: head/devel/gdb/files/commit-92fce24de2
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-92fce24de2	Wed Mar 14 14:33:21 2018	(r464493)
@@ -0,0 +1,548 @@
+commit 92fce24de299a8b9a9a1c0c6b98e0e9c1656f99c
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Tue Jan 9 13:35:17 2018 -0800
+
+    Support 'info proc' for native FreeBSD processes.
+    
+    - Command line arguments are fetched via the kern.proc.args.<pid>
+      sysctl.
+    - The 'cwd' and 'exe' values are obtained from the per-process
+      file descriptor table returned by kinfo_getfile() from libutil.
+    - 'mappings' is implemented by walking the array of VM map entries
+      returned by kinfo_getvmmap() from libutil.
+    - 'status' output is generated by outputting fields from the structure
+      returned by the kern.proc.pid.<pid> sysctl.
+    - 'stat' is aliased to 'status'.
+    
+    gdb/ChangeLog:
+    
+            * configure.ac: Check for kinfo_getfile in libutil.
+            * configure: Regenerate.
+            * config.in: Regenerate.
+            * fbsd-nat.c: Include "fbsd-tdep.h".
+            (fbsd_fetch_cmdline): New.
+            (fbsd_fetch_kinfo_proc): Move earlier and change to return a bool
+            rather than calling error.
+            (fbsd_info_proc): New.
+            (fbsd_thread_name): Report error if fbsd_fetch_kinfo_proc fails.
+            (fbsd_wait): Report warning if fbsd_fetch_kinfo_proc fails.
+            (fbsd_nat_add_target): Set "to_info_proc" to "fbsd_info_proc".
+
+diff --git gdb/config.in gdb/config.in
+index 1d11a97080..ad2cc1754e 100644
+--- gdb/config.in
++++ gdb/config.in
+@@ -219,6 +219,9 @@
+ /* Define to 1 if you have the <inttypes.h> header file. */
+ #undef HAVE_INTTYPES_H
+ 
++/* Define to 1 if your system has the kinfo_getfile function. */
++#undef HAVE_KINFO_GETFILE
++
+ /* Define to 1 if your system has the kinfo_getvmmap function. */
+ #undef HAVE_KINFO_GETVMMAP
+ 
+diff --git gdb/configure gdb/configure
+index db610f32fc..68b9aad02d 100755
+--- gdb/configure
++++ gdb/configure
+@@ -7927,6 +7927,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h
+ fi
+ 
+ 
++# fbsd-nat.c can also use kinfo_getfile.
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing kinfo_getfile" >&5
++$as_echo_n "checking for library containing kinfo_getfile... " >&6; }
++if test "${ac_cv_search_kinfo_getfile+set}" = set; then :
++  $as_echo_n "(cached) " >&6
++else
++  ac_func_search_save_LIBS=$LIBS
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++
++/* Override any GCC internal prototype to avoid an error.
++   Use char because int might match the return type of a GCC
++   builtin and then its argument prototype would still apply.  */
++#ifdef __cplusplus
++extern "C"
++#endif
++char kinfo_getfile ();
++int
++main ()
++{
++return kinfo_getfile ();
++  ;
++  return 0;
++}
++_ACEOF
++for ac_lib in '' util util-freebsd; do
++  if test -z "$ac_lib"; then
++    ac_res="none required"
++  else
++    ac_res=-l$ac_lib
++    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
++  fi
++  if ac_fn_c_try_link "$LINENO"; then :
++  ac_cv_search_kinfo_getfile=$ac_res
++fi
++rm -f core conftest.err conftest.$ac_objext \
++    conftest$ac_exeext
++  if test "${ac_cv_search_kinfo_getfile+set}" = set; then :
++  break
++fi
++done
++if test "${ac_cv_search_kinfo_getfile+set}" = set; then :
++
++else
++  ac_cv_search_kinfo_getfile=no
++fi
++rm conftest.$ac_ext
++LIBS=$ac_func_search_save_LIBS
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_kinfo_getfile" >&5
++$as_echo "$ac_cv_search_kinfo_getfile" >&6; }
++ac_res=$ac_cv_search_kinfo_getfile
++if test "$ac_res" != no; then :
++  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
++
++$as_echo "#define HAVE_KINFO_GETFILE 1" >>confdefs.h
++
++fi
++
++
+ 
+       if test "X$prefix" = "XNONE"; then
+     acl_final_prefix="$ac_default_prefix"
+diff --git gdb/configure.ac gdb/configure.ac
+index 3db44ae758..551afc727e 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. ])])
+ 
++# fbsd-nat.c can also use kinfo_getfile.
++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. ])])
++
+ AM_ICONV
+ 
+ # GDB may fork/exec the iconv program to get the list of supported character
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index 81f8e27a2d..b352418813 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -32,14 +32,16 @@
+ #include <sys/signal.h>
+ #include <sys/sysctl.h>
+ #include <sys/user.h>
+-#ifdef HAVE_KINFO_GETVMMAP
++#if defined(HAVE_KINFO_GETFILE) || defined(HAVE_KINFO_GETVMMAP)
+ #include <libutil.h>
+-#else
++#endif
++#if !defined(HAVE_KINFO_GETVMMAP)
+ #include "filestuff.h"
+ #endif
+ 
+ #include "elf-bfd.h"
+ #include "fbsd-nat.h"
++#include "fbsd-tdep.h"
+ 
+ #include <list>
+ 
+@@ -205,6 +207,331 @@ fbsd_find_memory_regions (struct target_ops *self,
+ }
+ #endif
+ 
++/* Fetch the command line for a running process.  */
++
++static gdb::unique_xmalloc_ptr<char>
++fbsd_fetch_cmdline (pid_t pid)
++{
++  size_t len;
++  int mib[4];
++
++  len = 0;
++  mib[0] = CTL_KERN;
++  mib[1] = KERN_PROC;
++  mib[2] = KERN_PROC_ARGS;
++  mib[3] = pid;
++  if (sysctl (mib, 4, NULL, &len, NULL, 0) == -1)
++    return nullptr;
++
++  if (len == 0)
++    return nullptr;
++
++  gdb::unique_xmalloc_ptr<char> cmdline ((char *) xmalloc (len));
++  if (sysctl (mib, 4, cmdline.get (), &len, NULL, 0) == -1)
++    return nullptr;
++
++  return cmdline;
++}
++
++/* Fetch the external variant of the kernel's internal process
++   structure for the process PID into KP.  */
++
++static bool
++fbsd_fetch_kinfo_proc (pid_t pid, struct kinfo_proc *kp)
++{
++  size_t len;
++  int mib[4];
++
++  len = sizeof *kp;
++  mib[0] = CTL_KERN;
++  mib[1] = KERN_PROC;
++  mib[2] = KERN_PROC_PID;
++  mib[3] = pid;
++  return (sysctl (mib, 4, kp, &len, NULL, 0) == 0);
++}
++
++/* Implement the "to_info_proc target_ops" method.  */
++
++static void
++fbsd_info_proc (struct target_ops *ops, const char *args,
++		enum info_proc_what what)
++{
++#ifdef HAVE_KINFO_GETFILE
++  gdb::unique_xmalloc_ptr<struct kinfo_file> fdtbl;
++  int nfd = 0;
++#endif
++  struct kinfo_proc kp;
++  char *tmp;
++  pid_t pid;
++  bool do_cmdline = false;
++  bool do_cwd = false;
++  bool do_exe = false;
++#ifdef HAVE_KINFO_GETVMMAP
++  bool do_mappings = false;
++#endif
++  bool do_status = false;
++
++  switch (what)
++    {
++    case IP_MINIMAL:
++      do_cmdline = true;
++      do_cwd = true;
++      do_exe = true;
++      break;
++#ifdef HAVE_KINFO_GETVMMAP
++    case IP_MAPPINGS:
++      do_mappings = true;
++      break;
++#endif
++    case IP_STATUS:
++    case IP_STAT:
++      do_status = true;
++      break;
++    case IP_CMDLINE:
++      do_cmdline = true;
++      break;
++    case IP_EXE:
++      do_exe = true;
++      break;
++    case IP_CWD:
++      do_cwd = true;
++      break;
++    case IP_ALL:
++      do_cmdline = true;
++      do_cwd = true;
++      do_exe = true;
++#ifdef HAVE_KINFO_GETVMMAP
++      do_mappings = true;
++#endif
++      do_status = true;
++      break;
++    default:
++      error (_("Not supported on this target."));
++    }
++

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803141433.w2EEXMGn079353>