svn commit: r332856 - head/usr.bin/grep

2018-04-21 Thread Kyle Evans
Author: kevans
Date: Sat Apr 21 13:46:07 2018
New Revision: 332856
URL: https://svnweb.freebsd.org/changeset/base/332856

Log:
  bsdgrep: Fix --include/--exclude ordering issues
  
  Prior to r332851:
  * --exclude always win out over --include
  * --exclude-dir always wins out over --include-dir
  
  r332851 broke that behavior, resulting in:
  * First of --exclude, --include wins
  * First of --exclude-dir, --include-dir wins
  
  As it turns out, both behaviors are wrong by modern grep standards- the
  latest rule wins. e.g.:
  
  `grep --exclude foo --include foo 'thing' foo`
  foo is included
  
  `grep --include foo --exclude foo 'thing' foo`
  foo is excluded
  
  As tested with GNU grep 3.1.
  
  This commit makes bsdgrep follow this behavior.
  
  Reported by:  se

Modified:
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/util.c
==
--- head/usr.bin/grep/util.cSat Apr 21 09:58:00 2018(r332855)
+++ head/usr.bin/grep/util.cSat Apr 21 13:46:07 2018(r332856)
@@ -109,10 +109,12 @@ file_matching(const char *fname)
 
for (unsigned int i = 0; i < fpatterns; ++i) {
if (fnmatch(fpattern[i].pat, fname, 0) == 0 ||
-   fnmatch(fpattern[i].pat, fname_base, 0) == 0) {
+   fnmatch(fpattern[i].pat, fname_base, 0) == 0)
+   /*
+* The last pattern matched wins exclusion/inclusion
+* rights, so we can't reasonably bail out early here.
+*/
ret = (fpattern[i].mode != EXCL_PAT);
-   break;
-   }
}
free(fname_buf);
return (ret);
@@ -127,7 +129,11 @@ dir_matching(const char *dname)
 
for (unsigned int i = 0; i < dpatterns; ++i) {
if (dname != NULL && fnmatch(dpattern[i].pat, dname, 0) == 0)
-   return (dpattern[i].mode != EXCL_PAT);
+   /*
+* The last pattern matched wins exclusion/inclusion
+* rights, so we can't reasonably bail out early here.
+*/
+   ret = (dpattern[i].mode != EXCL_PAT);
}
return (ret);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332856 - head/usr.bin/grep

2018-04-21 Thread Kyle Evans
On Sat, Apr 21, 2018 at 8:46 AM, Kyle Evans  wrote:
> Author: kevans
> Date: Sat Apr 21 13:46:07 2018
> New Revision: 332856
> URL: https://svnweb.freebsd.org/changeset/base/332856
>
> Log:
>   bsdgrep: Fix --include/--exclude ordering issues
>
>   Prior to r332851:
>   * --exclude always win out over --include
>   * --exclude-dir always wins out over --include-dir
>
>   r332851 broke that behavior, resulting in:
>   * First of --exclude, --include wins
>   * First of --exclude-dir, --include-dir wins
>
>   As it turns out, both behaviors are wrong by modern grep standards- the
>   latest rule wins. e.g.:
>
>   `grep --exclude foo --include foo 'thing' foo`
>   foo is included
>
>   `grep --include foo --exclude foo 'thing' foo`
>   foo is excluded
>
>   As tested with GNU grep 3.1.
>
>   This commit makes bsdgrep follow this behavior.
>
>   Reported by:  se
>

Just to be clear, because I don't want to mislead- se's report was
specifically that I broke the previous behavior. Later investigation
found that both behaviors were wrong.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332857 - in head: etc/defaults etc/rc.d share/man/man4 share/man/man5

2018-04-21 Thread Edward Tomasz Napierala
Author: trasz
Date: Sat Apr 21 14:56:41 2018
New Revision: 332857
URL: https://svnweb.freebsd.org/changeset/base/332857

Log:
  Add cfumass rc script, to create a LUN for cfumass(4).
  
  MFC after:2 weeks
  Relnotes: yes
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D14844

Added:
  head/etc/rc.d/cfumass   (contents, props changed)
Modified:
  head/etc/defaults/rc.conf
  head/etc/rc.d/Makefile
  head/share/man/man4/cfumass.4
  head/share/man/man5/rc.conf.5

Modified: head/etc/defaults/rc.conf
==
--- head/etc/defaults/rc.conf   Sat Apr 21 13:46:07 2018(r332856)
+++ head/etc/defaults/rc.conf   Sat Apr 21 14:56:41 2018(r332857)
@@ -592,6 +592,9 @@ cron_enable="YES"   # Run the periodic job daemon.
 cron_program="/usr/sbin/cron"  # Which cron executable to run (if enabled).
 cron_dst="YES" # Handle DST transitions intelligently (YES/NO)
 cron_flags=""  # Which options to pass to the cron daemon.
+cfumass_enable="NO"# Create default LUN for cfumass(4).
+cfumass_dir="/var/cfumass" # File to LUN's contents.
+cfumass_image="/var/tmp/cfumass.img"   # LUN's backing file path.
 lpd_enable="NO"# Run the line printer daemon.
 lpd_program="/usr/sbin/lpd"# path to lpd, if you want a different one.
 lpd_flags=""   # Flags to lpd (if enabled).

Modified: head/etc/rc.d/Makefile
==
--- head/etc/rc.d/Makefile  Sat Apr 21 13:46:07 2018(r332856)
+++ head/etc/rc.d/Makefile  Sat Apr 21 14:56:41 2018(r332857)
@@ -21,6 +21,7 @@ FILES=DAEMON \
${_bluetooth} \
bridge \
${_bthidd} \
+   cfumass \
cleanvar \
cleartmp \
cron \

Added: head/etc/rc.d/cfumass
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/etc/rc.d/cfumass   Sat Apr 21 14:56:41 2018(r332857)
@@ -0,0 +1,125 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: cfumass
+# REQUIRE: var
+# KEYWORD: nojail
+
+. /etc/rc.subr
+
+name="cfumass"
+desc="Configure the LUN for device mode USB mass storage"
+rcvar="cfumass_enable"
+
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+
+extra_commands="reload"
+reload_cmd="${name}_start"
+
+: ${cfumass_dir:=/var/cfumass}
+: ${cfumass_image:=/var/tmp/cfumass.img}
+: ${cfumass_vendor:="FreeBSD"}
+: ${cfumass_product:="cfumass(4)"}
+
+remove_luns()
+{
+   local _lun _luns
+
+   _luns=`ctladm devlist -b block -v | awk '
+
+   $1 ~ /^[0-9]+$/ {
+   lun = $1
+   }
+
+   $1 == "file='"${cfumass_image}"'" {
+   print lun
+   }'`
+
+   for _lun in ${_luns}; do
+   ctladm remove -b block -l "${_lun}" > /dev/null
+   done
+}
+
+cfumass_start()
+{
+   local err _files _template
+
+   if [ ! -d "${cfumass_dir}" ]; then
+   warn "${cfumass_dir} does not exist"
+   return 1
+   fi
+
+   _files=`find "${cfumass_dir}" -newer "${cfumass_image}" -print 2> 
/dev/null`
+   if [ ! -e "${cfumass_image}" -o -n "${_files}" ]; then
+   # The image doesn't exist or is out of date.
+   makefs -t cd9660 -o rockridge "${cfumass_image}" 
"${cfumass_dir}"
+   err=$?
+   if [ "${err}" -ne 0 ]; then
+   warn "unable to create ${cfumass_image}"
+   return "${err}"
+   fi
+   fi
+
+   remove_luns
+
+   ctladm create -b block -o file="${cfumass_image}" -o readonly=on \
+   -o vendor="${cfumass_vendor}" -o product="${cfumass_product}" \
+   -t 5 -S 0 > /dev/null
+   err=$?
+   if [ "${err}" -ne 0 ]; then
+   warn "unable to create CTL LUN"
+   return "${err}"
+   fi
+
+   load_kld -e cfumass cfumass
+
+   # If the template is already switched to Mass Storage, then reset
+   # it to -1 to force the host to reenumerate it; otherwise it might
+   # not notice the new LUN.
+   _template=`sysctl -n hw.usb.template`
+   if [ "${_template}" -eq 0 ]; then
+   sysctl hw.usb.template=-1 > /dev/null
+   err=$?
+   if [ "${err}" -ne 0 ]; then
+   warn "unable to set hw.usb.template sysctl"
+   return "${err}"
+   fi
+   fi
+
+   _template=`sysctl -n hw.usb.template`
+   if [ "${_template}" -lt 0 ]; then
+   sysctl hw.usb.template=0 > /dev/null
+   err=$?
+   if [ "${err}" -ne 0 ]; then
+   warn "unable to set hw.usb.template sysctl"
+   return "${err}"
+   fi
+   else
+   # Otherwise don't touch the sysctl - we could lo

svn commit: r332858 - head/usr.bin/grep

2018-04-21 Thread Kyle Evans
Author: kevans
Date: Sat Apr 21 14:58:45 2018
New Revision: 332858
URL: https://svnweb.freebsd.org/changeset/base/332858

Log:
  bsdgrep: Use grep_strdup instead of grep_malloc+strcpy

Modified:
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/util.c
==
--- head/usr.bin/grep/util.cSat Apr 21 14:56:41 2018(r332857)
+++ head/usr.bin/grep/util.cSat Apr 21 14:58:45 2018(r332858)
@@ -323,8 +323,7 @@ procfile(const char *fn)
return (0);
}
 
-   pc.ln.file = grep_malloc(strlen(fn) + 1);
-   strcpy(pc.ln.file, fn);
+   pc.ln.file = grep_strdup(fn);
pc.ln.line_no = 0;
pc.ln.len = 0;
pc.ln.boff = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332859 - head/sys/powerpc/powerpc

2018-04-21 Thread Justin Hibbits
Author: jhibbits
Date: Sat Apr 21 15:15:47 2018
New Revision: 332859
URL: https://svnweb.freebsd.org/changeset/base/332859

Log:
  Export powerpc CPU features for auxvec
  
  FreeBSD exports the AT_HWCAP* auxvec items if provided by the ELF sysentvec
  structure.  Add the CPU features to be exported, so user space can more
  easily check for them without using the hw.cpu_features and hw.cpu_features2
  sysctls.

Modified:
  head/sys/powerpc/powerpc/elf32_machdep.c
  head/sys/powerpc/powerpc/elf64_machdep.c

Modified: head/sys/powerpc/powerpc/elf32_machdep.c
==
--- head/sys/powerpc/powerpc/elf32_machdep.cSat Apr 21 14:58:45 2018
(r332858)
+++ head/sys/powerpc/powerpc/elf32_machdep.cSat Apr 21 15:15:47 2018
(r332859)
@@ -123,6 +123,8 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_schedtail   = NULL,
.sv_thread_detach = NULL,
.sv_trap= NULL,
+   .sv_hwcap   = &cpu_features,
+   .sv_hwcap2  = &cpu_features2,
 };
 INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
 

Modified: head/sys/powerpc/powerpc/elf64_machdep.c
==
--- head/sys/powerpc/powerpc/elf64_machdep.cSat Apr 21 14:58:45 2018
(r332858)
+++ head/sys/powerpc/powerpc/elf64_machdep.cSat Apr 21 15:15:47 2018
(r332859)
@@ -88,6 +88,8 @@ struct sysentvec elf64_freebsd_sysvec_v1 = {
.sv_schedtail   = NULL,
.sv_thread_detach = NULL,
.sv_trap= NULL,
+   .sv_hwcap   = &cpu_features,
+   .sv_hwcap2  = &cpu_features2,
 };
 INIT_SYSENTVEC(elf64_sysvec_v1, &elf64_freebsd_sysvec_v1);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332860 - head/sys/kern

2018-04-21 Thread Jonathan T. Looney
Author: jtl
Date: Sat Apr 21 17:05:00 2018
New Revision: 332860
URL: https://svnweb.freebsd.org/changeset/base/332860

Log:
  When running with INVARIANTS, the kernel contains extra checks.  However,
  these assumptions may not hold true once we've panic'd. Therefore, the
  checks hold less value after a panic.  Additionally, if one of the checks
  fails while we are already panic'd, this creates a double-panic which can
  interfere with debugging the original panic.
  
  Therefore, this commit allows an administrator to suppress a response to
  KASSERT checks after a panic by setting a tunable/sysctl.  The
  tunable/sysctl (debug.kassert.suppress_in_panic) defaults to being
  enabled.
  
  Reviewed by:  kib
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D12920

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Sat Apr 21 15:15:47 2018
(r332859)
+++ head/sys/kern/kern_shutdown.c   Sat Apr 21 17:05:00 2018
(r332860)
@@ -642,6 +642,7 @@ static int kassert_do_log = 1;
 static int kassert_log_pps_limit = 4;
 static int kassert_log_mute_at = 0;
 static int kassert_log_panic_at = 0;
+static int kassert_suppress_in_panic = 1;
 static int kassert_warnings = 0;
 
 SYSCTL_NODE(_debug, OID_AUTO, kassert, CTLFLAG_RW, NULL, "kassert options");
@@ -676,6 +677,10 @@ SYSCTL_INT(_debug_kassert, OID_AUTO, log_pps_limit, CT
 SYSCTL_INT(_debug_kassert, OID_AUTO, log_mute_at, CTLFLAG_RWTUN,
 &kassert_log_mute_at, 0, "max number of KASSERTS to log");
 
+SYSCTL_INT(_debug_kassert, OID_AUTO, suppress_in_panic, CTLFLAG_RWTUN,
+&kassert_suppress_in_panic, 0,
+"KASSERTs will be suppressed while handling a panic");
+
 static int kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS);
 
 SYSCTL_PROC(_debug_kassert, OID_AUTO, kassert,
@@ -707,6 +712,10 @@ kassert_panic(const char *fmt, ...)
 {
static char buf[256];
va_list ap;
+
+   /* If we already panic'd, don't create a double-fault. */
+   if (panicstr != NULL && kassert_suppress_in_panic)
+   return;
 
va_start(ap, fmt);
(void)vsnprintf(buf, sizeof(buf), fmt, ap);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332860 - head/sys/kern

2018-04-21 Thread Bruce Evans

On Sat, 21 Apr 2018, Jonathan T. Looney wrote:


Log:
 When running with INVARIANTS, the kernel contains extra checks.  However,
 these assumptions may not hold true once we've panic'd. Therefore, the
 checks hold less value after a panic.  Additionally, if one of the checks
 fails while we are already panic'd, this creates a double-panic which can
 interfere with debugging the original panic.

 Therefore, this commit allows an administrator to suppress a response to
 KASSERT checks after a panic by setting a tunable/sysctl.  The
 tunable/sysctl (debug.kassert.suppress_in_panic) defaults to being
 enabled.
...
Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Sat Apr 21 15:15:47 2018
(r332859)
+++ head/sys/kern/kern_shutdown.c   Sat Apr 21 17:05:00 2018
(r332860)
@@ -642,6 +642,7 @@ static int kassert_do_log = 1;
static int kassert_log_pps_limit = 4;
static int kassert_log_mute_at = 0;
static int kassert_log_panic_at = 0;
+static int kassert_suppress_in_panic = 1;
static int kassert_warnings = 0;

SYSCTL_NODE(_debug, OID_AUTO, kassert, CTLFLAG_RW, NULL, "kassert options");
@@ -676,6 +677,10 @@ SYSCTL_INT(_debug_kassert, OID_AUTO, log_pps_limit, CT
SYSCTL_INT(_debug_kassert, OID_AUTO, log_mute_at, CTLFLAG_RWTUN,
&kassert_log_mute_at, 0, "max number of KASSERTS to log");

+SYSCTL_INT(_debug_kassert, OID_AUTO, suppress_in_panic, CTLFLAG_RWTUN,
+&kassert_suppress_in_panic, 0,
+"KASSERTs will be suppressed while handling a panic");
+
static int kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS);

SYSCTL_PROC(_debug_kassert, OID_AUTO, kassert,
@@ -707,6 +712,10 @@ kassert_panic(const char *fmt, ...)
{
static char buf[256];
va_list ap;
+
+   /* If we already panic'd, don't create a double-fault. */
+   if (panicstr != NULL && kassert_suppress_in_panic)
+   return;

va_start(ap, fmt);
(void)vsnprintf(buf, sizeof(buf), fmt, ap);


panic() can't return, but I see that KASSERT() has already been broken
to use kassert_panic() which does return in some cases including this
new one.

KASSERT(9) is still documented to call panic(), and none of the options
to break it including this new one, or kassert_panic() itself are
documented in KASSERT(9) or in any other section 9 man page.

Lots of code was and still is written under the assumption that KASSERT()
works as documented.  E.g., after a null pointer check using KASSERT(),
the pointer is normally used and the page fault for this should cause a
panic anyway.  This is actually a feature -- it works around KASSERT()
breaking restartability of the fault.  Other cases are not so good.  There
man be a cascade of KASSERT() failures, and the new option prevents even
printing a message about even one of them.  If you are lucky then you get
a clean null pointer recursive panic.

The only example in KASSERT(9) is to give the worst use of it (for breaking
clean null pointer panics when KASSERT() works as documented, but now doesn't
even break them when KASSERT() returns).

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332860 - head/sys/kern

2018-04-21 Thread Conrad Meyer
On Sat, Apr 21, 2018 at 10:05 AM, Jonathan T. Looney  wrote:
> Author: jtl
> Date: Sat Apr 21 17:05:00 2018
> New Revision: 332860
> URL: https://svnweb.freebsd.org/changeset/base/332860
>
> Log:
>   When running with INVARIANTS, the kernel contains extra checks.  However,
>   these assumptions may not hold true once we've panic'd. Therefore, the
>   checks hold less value after a panic.  Additionally, if one of the checks
>   fails while we are already panic'd, this creates a double-panic which can
>   interfere with debugging the original panic.
>
>   Therefore, this commit allows an administrator to suppress a response to
>   KASSERT checks after a panic by setting a tunable/sysctl.  The
>   tunable/sysctl (debug.kassert.suppress_in_panic) defaults to being
>   enabled.

Hi Jonathan,

I don't think this should be enabled by default.  Can we leave it
disabled by default and let consumers opt-in?

To expand on this a little: this is a big hammer.  We already disable
specific invariants in a few cases during panic (lock assertions come
to mind).  If there are specific assertions that do not hold during
panic, we can/should selectively weaken them.  But in general,
invariants are invariant, and we should not proceed past violated ones
by default.

Thanks,
Conrad
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332860 - head/sys/kern

2018-04-21 Thread Conrad Meyer
On Sat, Apr 21, 2018 at 10:41 AM, Bruce Evans  wrote:
> panic() can't return, but I see that KASSERT() has already been broken
> to use kassert_panic() which does return in some cases including this
> new one.

Oddly enough, I find myself agreeing with Bruce on this.  That
kassert_panic does not always assert, during ordinary (non-panic)
runtime, based on a runtime configurable toggle breaks the concept of
invariants and confuses the heck out of static analyzers like
Coverity.

Ideally, we just remove it.  IMO it is a crappy hack that should have
remained in iX's local tree.

If we want to be really generous, we can make it an off-by-default
build option.  Is anyone clamoring for allowing violation of multiple
assertions without panic, other than Linus Torvalds?

> KASSERT(9) is still documented to call panic(), and none of the options
> to break it including this new one, or kassert_panic() itself are
> documented in KASSERT(9) or in any other section 9 man page.

Yeah.  This is unfortunate :-(.

Best,
Conrad
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332860 - head/sys/kern

2018-04-21 Thread Eitan Adler
On 21 April 2018 at 10:05, Jonathan T. Looney  wrote:
> Author: jtl
> Date: Sat Apr 21 17:05:00 2018
> New Revision: 332860
> URL: https://svnweb.freebsd.org/changeset/base/332860
>
> Log:
>   When running with INVARIANTS, the kernel contains extra checks.  However,
>   these assumptions may not hold true once we've panic'd. Therefore, the
>   checks hold less value after a panic.  Additionally, if one of the checks
>   fails while we are already panic'd, this creates a double-panic which can
>   interfere with debugging the original panic.

Rather than do this I'd rather we modify the invariants to more
explicitly state under what conditions it holds.
This might be something like

KASSERT(!panic && ...)
or
KASSERT_NOT_IN_PANIC(...)
or some other spelling.



-- 
Eitan Adler
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332861 - head/sys/dev/bktr

2018-04-21 Thread Thomas Zander
Author: riggs (ports committer)
Date: Sat Apr 21 18:43:09 2018
New Revision: 332861
URL: https://svnweb.freebsd.org/changeset/base/332861

Log:
  Remove unused definition bl_dfp; fix build with bktr compiled into kernel
  
  PR:   216566
  Submitted by: m...@fbsd.e4m.org
  Reviewed by:  riggs, cognet
  Approved by:  cognet
  MFC after:3 days

Modified:
  head/sys/dev/bktr/msp34xx.c

Modified: head/sys/dev/bktr/msp34xx.c
==
--- head/sys/dev/bktr/msp34xx.c Sat Apr 21 17:05:00 2018(r332860)
+++ head/sys/dev/bktr/msp34xx.c Sat Apr 21 18:43:09 2018(r332861)
@@ -111,10 +111,6 @@
 #define VIDEO_SOUND_LANG2  8
 
 #define DFP_COUNT 0x41
-static const int bl_dfp[] = {
-   0x00, 0x01, 0x02, 0x03,  0x06, 0x08, 0x09, 0x0a,
-   0x0b, 0x0d, 0x0e, 0x10
-};
 
 struct msp3400c {
int simple;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332860 - head/sys/kern

2018-04-21 Thread Jonathan Looney
On Sat, Apr 21, 2018 at 1:53 PM, Conrad Meyer  wrote:
>
> I don't think this should be enabled by default.  Can we leave it
> disabled by default and let consumers opt-in?

I'm willing to change the default if there's a good reason or consensus for
that. However, it is not obvious to me that the default is actually wrong.

I think its important that we remember where we are when we hit this code.

By the time we hit this code, we've already panic'd (whether due to a
"true" panic or a violated assertion). At this point, the system is already
in an unknown/unexpected state and we want to preserve our ability to
troubleshoot and/or recover. (And, since we're running a system with
INVARIANTS, presumably the ability to troubleshoot is important.)

We may well violate a second assertion simply because the system is in an
unknown/unexpected state. Once we do that, the question is whether we
should try to preserve the ability to troubleshoot, or should give up and
reset the system.

All too often, my ability to debug assertion violations is hindered because
the system trips over yet another assertion while dumping the core. If we
skip the assertion, nothing bad happens. (The post-panic debugging code
already needs to deal with systems that are inconsistent, and it does a
pretty good job at it.)

On the other hand, I really am not sure what you are worried might happen
if we skip checking assertions after we've already panic'd. As far as I can
tell, the likely worst case is that we hit a true panic of some kind. In
that case, we're no worse off than before.

I think the one obvious exception is when we're purposely trying to
validate the post-panic debugging code. In that case, you can change the
sysctl/tunable to enable troubleshooting.

I would honestly appreciate someone explaining the dangers in disabling a
response to assertion violations after we've already panic'd and are simply
trying to troubleshoot, because they are not obvious to me. But, I could
simply be missing them.

Jonathan
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332865 - head/cddl/usr.sbin/dwatch

2018-04-21 Thread Devin Teske
Author: dteske
Date: Sun Apr 22 02:20:17 2018
New Revision: 332865
URL: https://svnweb.freebsd.org/changeset/base/332865

Log:
  dwatch(1): Add `-dev' option to aid debugging of profiles
  
  The options `-d' (debug), `-e' (exit after compile), and `-v' (verbose)
  when combined in any order (though best remembered as `-dev') will run
  the conflated script through dtrace(1), test for error conditions, and
  show the line that dtrace(1) failed at (with context).
  
  If no errors are found, the output is the same as `-e[v]'.
  
  When writing a new profile for dwatch(1), you can quickly test to
  make sure it compiles by running `dwatch -devX profile_name' where
  profiles live in /usr/libexec/dwatch or /usr/local/libexec/dwatch
  (the latter being where profiles installed via ports should go).
  
  Sponsored by: Smule, Inc.

Modified:
  head/cddl/usr.sbin/dwatch/dwatch

Modified: head/cddl/usr.sbin/dwatch/dwatch
==
--- head/cddl/usr.sbin/dwatch/dwatchSun Apr 22 00:26:35 2018
(r332864)
+++ head/cddl/usr.sbin/dwatch/dwatchSun Apr 22 02:20:17 2018
(r332865)
@@ -47,7 +47,7 @@ DTRACE_PRAGMA="
 
  GLOBALS
 
-VERSION='$Version: 1.0 $' # -V
+VERSION='$Version: 1.1 $' # -V
 
 pgm="${0##*/}" # Program basename
 
@@ -67,6 +67,7 @@ CUSTOM_DETAILS=   # -E code
 CUSTOM_TEST=   # -t test
 DEBUG= # -d
 DESTRUCTIVE_ACTIONS=   # -w
+DEVELOPER= # -dev
 EXECNAME=  # -k name
 EXECREGEX= # -z regex
 EXIT_AFTER_COMPILE=# -e
@@ -835,6 +836,11 @@ if [ "$PROBE_ARG" ]; then
 fi
 
 #
+# Developer switch
+#
+[ "$DEBUG" -a "$EXIT_AFTER_COMPILE" -a "$VERBOSE" ] && DEVELOPER=1 DEBUG=
+
+#
 # Set default event details if `-E code' was not given
 #
 [ "$CUSTOM_DETAILS" ] || EVENT_DETAILS=$( pproc_dump 0 )
@@ -966,6 +972,61 @@ PSARGS_ACTION=$( cat <&9 )
exec 3>&1
console_stdout=3
 
+   #
+   # Developer debugging aide
+   #
+   if [ "$DEVELOPER" ]; then
+   #
+   # Run, capture the error line, and focus it
+   #
+   # Example error text to capture line number from:
+   #   dtrace: failed to compile script /dev/stdin: line 669: 
...
+   #
+   errline=
+   stdin_buf=$( cat )
+   stderr_buf=$( echo "$stdin_buf" |
+   dtrace_cmd -t -es /dev/stdin "$@" 2>&1 > /dev/null )
+   status=$?
+   if [ "$stderr_buf" ]; then
+   errline=$( echo "$stderr_buf" | awk '
+   BEGIN {
+   ti = "\033[31m"
+   te = "\033[39m"
+   }
+   { line = $0 }
+   sub(/.*: line /, "") && sub(/:.*/, "") {
+   print # to errline
+   sub("line " $0, ti "&" te, line)
+   }
+   { print line > "/dev/stderr" }
+   ' 2>&3 )
+   fi
+   if  [ "$errline" ]; then
+   echo "$stdin_buf" | awk -v line="${errline%%[^0-9]*}" '
+   BEGIN {
+   start = line < 10 ? 1 : line - 10
+   end = line + 10
+   slen = length(sprintf("%u", start))
+   elen = length(sprintf("%u", end))
+   N = elen > slen ? elen : slen
+   for (i = start; i <= end; i++) {
+   ti[i] = "\033[2m"
+   te[i] = "\033[22m"
+   }
+   ti[line] = "\033[31m"
+   te[line] = "\033[39m"
+   fmt = "%s%*u %s%s\n"
+   }
+   NR < start { next }
+   NR == start, NR == end {
+   printf(fmt, ti[NR], N, NR, $0, te[NR])
+   }
+   NR > end { exit }
+   ' # END-QUOTE
+   fi
+   exit $status
+   fi
+
if [ $COUNT -eq 0 -a ! "$EXECREGEX$FILTER$GROUP$OUTPUT_CMD$PID$USER" ]
then
case "$OUTPUT" in
@@ -1285,6 +1346,7 @@ $(pproc_dump -v 3
 )}
 }
 EOF
+# NOTREACHED
 
 

 # END
___
svn-src-head@freebsd.o

svn commit: r332866 - head/cddl/usr.sbin/dwatch/libexec

2018-04-21 Thread Devin Teske
Author: dteske
Date: Sun Apr 22 02:36:06 2018
New Revision: 332866
URL: https://svnweb.freebsd.org/changeset/base/332866

Log:
  dwatch(1): Add profile for send(2)/recv(2) syscalls
  
  Sponsored by: Smule, Inc.

Added:
  head/cddl/usr.sbin/dwatch/libexec/sendrecv   (contents, props changed)
Modified:
  head/cddl/usr.sbin/dwatch/libexec/Makefile

Modified: head/cddl/usr.sbin/dwatch/libexec/Makefile
==
--- head/cddl/usr.sbin/dwatch/libexec/Makefile  Sun Apr 22 02:20:17 2018
(r332865)
+++ head/cddl/usr.sbin/dwatch/libexec/Makefile  Sun Apr 22 02:36:06 2018
(r332866)
@@ -11,6 +11,7 @@ FILES=chmod \
proc \
rw \
sched \
+   sendrecv \
tcp \
udp \
vop_create \
@@ -54,6 +55,12 @@ LINKS+=  ${LIBEXECDIR}/dwatch/sched ${LIBEXECDIR}/dwatc
 LINKS+=${LIBEXECDIR}/dwatch/sched ${LIBEXECDIR}/dwatch/sched-surrender
 LINKS+=${LIBEXECDIR}/dwatch/sched ${LIBEXECDIR}/dwatch/sched-tick
 LINKS+=${LIBEXECDIR}/dwatch/sched ${LIBEXECDIR}/dwatch/sched-wakeup
+LINKS+=${LIBEXECDIR}/dwatch/sendrecv ${LIBEXECDIR}/dwatch/recv
+LINKS+=${LIBEXECDIR}/dwatch/sendrecv ${LIBEXECDIR}/dwatch/recvfrom
+LINKS+=${LIBEXECDIR}/dwatch/sendrecv ${LIBEXECDIR}/dwatch/recvmsg
+LINKS+=${LIBEXECDIR}/dwatch/sendrecv ${LIBEXECDIR}/dwatch/send
+LINKS+=${LIBEXECDIR}/dwatch/sendrecv ${LIBEXECDIR}/dwatch/sendmsg
+LINKS+=${LIBEXECDIR}/dwatch/sendrecv ${LIBEXECDIR}/dwatch/sendto
 LINKS+=${LIBEXECDIR}/dwatch/tcp ${LIBEXECDIR}/dwatch/tcp-accept
 LINKS+=${LIBEXECDIR}/dwatch/tcp 
${LIBEXECDIR}/dwatch/tcp-accept-established
 LINKS+=${LIBEXECDIR}/dwatch/tcp ${LIBEXECDIR}/dwatch/tcp-accept-refused

Added: head/cddl/usr.sbin/dwatch/libexec/sendrecv
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/cddl/usr.sbin/dwatch/libexec/sendrecv  Sun Apr 22 02:36:06 2018
(r332866)
@@ -0,0 +1,216 @@
+# -*- tab-width: 4 -*- ;; Emacs
+# vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM
+ IDENT(1)
+#
+# $Title: dwatch(8) module for send(2)/recv(2) $
+# $Copyright: 2014-2018 Devin Teske. All rights reserved. $
+# $FreeBSD$
+#
+ DESCRIPTION
+#
+# Print details from send(2)/recv(2)
+#
+ PROBE
+
+case "$PROFILE" in
+sendrecv)
+   : ${PROBE:=$( echo \
+   syscall::recvfrom:return, \
+   syscall::recvmsg:return, \
+   syscall::sendmsg:entry, \
+   syscall::sendto:entry )} ;;
+send)
+   : ${PROBE:=$( echo \
+   syscall::sendmsg:entry, \
+   syscall::sendto:entry )} ;;
+recv)
+   : ${PROBE:=$( echo \
+   syscall::recvfrom:return, \
+   syscall::recvmsg:return )} ;;
+*)
+   : ${PROBE:=syscall::$PROFILE}
+esac
+
+ EVENT ACTION
+
+#[ "$CUSTOM_TEST" ] || EVENT_TEST="this->from != NULL"
+
+ ACTIONS
+
+exec 9<
+ */
+#pragma D binding "1.13" address_family_string
+inline string address_family_string[sa_family_t af] =
+   af == AF_UNSPEC ?   "AF_UNSPEC" :
+   af == AF_LOCAL ?"AF_UNIX" :
+   af == AF_UNIX ? "AF_UNIX" :
+   af == AF_INET ? "AF_INET" :
+   af == AF_IMPLINK ?  "AF_IMPLINK" :
+   af == AF_PUP ?  "AF_PUP" :
+   af == AF_CHAOS ?"AF_CHAOS" :
+   af == AF_NETBIOS ?  "AF_NETBIOS" :
+   af == AF_ISO ?  "AF_ISO" :
+   af == AF_OSI ?  "AF_ISO" :
+   af == AF_ECMA ? "AF_ECMA" :
+   af == AF_DATAKIT ?  "AF_DATAKIT" :
+   af == AF_CCITT ?"AF_CCITT" :
+   af == AF_SNA ?  "AF_SNA" :
+   af == AF_DECnet ?   "AF_DECnet" :
+   af == AF_DLI ?  "AF_DLI" :
+   af == AF_LAT ?  "AF_LAT" :
+   af == AF_HYLINK ?   "AF_HYLINK" :
+   af == AF_APPLETALK ?"AF_APPLETALK" :
+   af == AF_ROUTE ?"AF_ROUTE" :
+   af == AF_LINK ? "AF_LINK" :
+   af == pseudo_AF_XTP ?   "pseudo_AF_XTP" :
+   af == AF_COIP ? "AF_COIP" :
+   af == AF_CNT ?  "AF_CNT" :
+   af == pseudo_AF_RTIP ?  "pseudo_AF_RTIP" :
+   af == AF_IPX ?  "AF_IPX" :
+   af == AF_SIP ?  "AF_SIP" :
+   af == pseudo_AF_PIP ?   "

svn commit: r332867 - head/cddl/usr.sbin/dwatch/libexec

2018-04-21 Thread Devin Teske
Author: dteske
Date: Sun Apr 22 02:40:21 2018
New Revision: 332867
URL: https://svnweb.freebsd.org/changeset/base/332867

Log:
  dwatch(1): Remove the line used to demonstrate `-dev' option
  
  In recently added sendrecv profile, there was a line purposefully
  added to introduce a compilation error in which `-dev' is used to
  debug the entry. Removing the entry.
  
  Sponsored by: Smule, Inc.

Modified:
  head/cddl/usr.sbin/dwatch/libexec/sendrecv

Modified: head/cddl/usr.sbin/dwatch/libexec/sendrecv
==
--- head/cddl/usr.sbin/dwatch/libexec/sendrecv  Sun Apr 22 02:36:06 2018
(r332866)
+++ head/cddl/usr.sbin/dwatch/libexec/sendrecv  Sun Apr 22 02:40:21 2018
(r332867)
@@ -154,7 +154,6 @@ syscall::recvfrom:entry /* probe ID $(( $ID + 1 )) */
(struct sockaddr *)alloca(sizeof(struct sockaddr)) :
(struct sockaddr *)copyin(arg4, sizeof(struct sockaddr));
this->sainfo = xlate  ((struct sockaddr *)this->sa);
-   printf("missing closing paren\n";
 }
 
 syscall::recvfrom:return /* probe ID $(( $ID + 2 )) */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332868 - in head/sys/powerpc: include powerpc

2018-04-21 Thread Justin Hibbits
Author: jhibbits
Date: Sun Apr 22 03:58:04 2018
New Revision: 332868
URL: https://svnweb.freebsd.org/changeset/base/332868

Log:
  Fix the build post r332859
  
  sysentvec::sv_hwcap/sv_hwcap2 are pointers to  u_long, so cpu_features* need
  to be u_long to use the pointers.  This also requires a temporary cast in
  printing the bitfields, which is fine because the feature flag fields are
  only 32 bits anyway.

Modified:
  head/sys/powerpc/include/cpu.h
  head/sys/powerpc/powerpc/cpu.c

Modified: head/sys/powerpc/include/cpu.h
==
--- head/sys/powerpc/include/cpu.h  Sun Apr 22 02:40:21 2018
(r332867)
+++ head/sys/powerpc/include/cpu.h  Sun Apr 22 03:58:04 2018
(r332868)
@@ -49,8 +49,8 @@
  * sysctl.
  */
 
-extern int cpu_features;
-extern int cpu_features2;
+extern u_long cpu_features;
+extern u_long cpu_features2;
 
 #definePPC_FEATURE_32  0x8000  /* Always true */
 #definePPC_FEATURE_64  0x4000  /* Defined on a 64-bit 
CPU */

Modified: head/sys/powerpc/powerpc/cpu.c
==
--- head/sys/powerpc/powerpc/cpu.c  Sun Apr 22 02:40:21 2018
(r332867)
+++ head/sys/powerpc/powerpc/cpu.c  Sun Apr 22 03:58:04 2018
(r332868)
@@ -231,12 +231,12 @@ static intcpu_feature_bit(SYSCTL_HANDLER_ARGS);
 static char model[64];
 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, model, 0, "");
 
-int cpu_features = PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU;
-int cpu_features2 = 0;
+u_long cpu_features = PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU;
+u_long cpu_features2 = 0;
 SYSCTL_OPAQUE(_hw, OID_AUTO, cpu_features, CTLFLAG_RD,
-&cpu_features, sizeof(cpu_features), "IX", "PowerPC CPU features");
+&cpu_features, sizeof(cpu_features), "LX", "PowerPC CPU features");
 SYSCTL_OPAQUE(_hw, OID_AUTO, cpu_features2, CTLFLAG_RD,
-&cpu_features2, sizeof(cpu_features2), "IX", "PowerPC CPU features 2");
+&cpu_features2, sizeof(cpu_features2), "LX", "PowerPC CPU features 2");
 
 /* Provide some user-friendly aliases for bits in cpu_features */
 SYSCTL_PROC(_hw, OID_AUTO, floatingpoint, CTLTYPE_INT | CTLFLAG_RD,
@@ -307,10 +307,10 @@ cpu_setup(u_int cpuid)
 
cpu_features |= cp->features;
cpu_features2 |= cp->features2;
-   printf("cpu%d: Features %b\n", cpuid, cpu_features,
+   printf("cpu%d: Features %b\n", cpuid, (int)cpu_features,
PPC_FEATURE_BITMASK);
if (cpu_features2 != 0)
-   printf("cpu%d: Features2 %b\n", cpuid, cpu_features2,
+   printf("cpu%d: Features2 %b\n", cpuid, (int)cpu_features2,
PPC_FEATURE2_BITMASK);
 
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"