On Sun, Dec 26, 2021 at 12:04:48PM +0100, Stefan Hagen wrote:

> Otto Moerbeek wrote:
> > On Sat, Dec 25, 2021 at 04:44:11PM -0800, Greg Steuck wrote:
> > 
> > > The separator doesn't get printed when I use this script on OpenBSD. It
> > > does get printed on FreeBSD or if I used GNU grep. The issue appears to
> > > be an off-by-one of some sort because removing the empty line makes the
> > > separator disappear on both systems.
> > > 
> > > #!/bin/sh
> > > 
> > > grep -E -A6 '^(.w)?g' <<'EOF'
> > > $wg
> > > a
> > > b
> > > c
> > > d
> > > e
> > > f
> > > 
> > > g = \ ds ->
> > > h
> > > i
> > > j
> > > EOF
> > > 
> > 
> > Hi,
> > 
> > please include the expected output and the output seen in bug reports,
> > it makes the initial diagnosis much easier. I now had to run your
> > testcase on another system to see what you meant. 
> > 
> > BTW, on MacOS I do see the separator with your test, both with the
> > empty line and without it.
> > 
> > ANyway, here's an attempt at a fix. Without much coffee, so beware.
> > 
> >     -Otto
> 
> Hi,
> 
> the fix works as intended here and is consistent with what I see on
> Linux and FreeBSD.
> 
> Unfortunately the separator dashes are also printed in non-interactive 
> mode (also on Linux and FreeBSD), so we need to check our grep usage.
> 
> I only found one in src (I haven't checked ports):
> ./sys/arch/amd64/conf/Makefile.amd64: \
>     @[[ -n `objdump -D $@ | grep -A1 doreti_iret | sort | uniq -d` ]] || \
> 
> Attached is a regress test based on your fix (also for -B and -C) that
> shows the behavior we have now and I think it's correct.
> 
> Best Regards,
> Stefan
> 
> Index: regress/usr.bin/grep/Makefile
> ===================================================================
> RCS file: /home/cvs/src/regress/usr.bin/grep/Makefile,v
> retrieving revision 1.17
> diff -u -p -u -p -r1.17 Makefile
> --- regress/usr.bin/grep/Makefile     12 Dec 2012 15:11:25 -0000      1.17
> +++ regress/usr.bin/grep/Makefile     26 Dec 2021 10:15:02 -0000
> @@ -1,7 +1,7 @@
>  # $OpenBSD: Makefile,v 1.17 2012/12/12 15:11:25 weerd Exp $
>  
>  REGRESS_TARGETS=t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 \
> -     t18 t19 t20 t21 t22 t23 t24 t25 t26
> +     t18 t19 t20 t21 t22 t23 t24 t25 t26 t27
>  
>  t1:
>       grep t.s ${.CURDIR}/in | diff - ${.CURDIR}/t1.out
> @@ -102,8 +102,13 @@ t25:
>  t26:
>       echo 'aaab' | grep -o 'a*' | head -n 10 | diff - ${.CURDIR}/t26.out
>  
> +t27:
> +     grep -A1 'C' ${.CURDIR}/t27.in | diff - ${.CURDIR}/t27a.out
> +     grep -B1 'C' ${.CURDIR}/t27.in | diff - ${.CURDIR}/t27b.out
> +     grep -C1 'C' ${.CURDIR}/t27.in | diff - ${.CURDIR}/t27c.out
> +
>  
>  .PHONY: t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 
> t20
> -.PHONY: t21 t22 t23 t24 t25 t26
> +.PHONY: t21 t22 t23 t24 t25 t26 t27
>  
>  .include <bsd.regress.mk>
> Index: regress/usr.bin/grep/t27.in
> ===================================================================
> RCS file: regress/usr.bin/grep/t27.in
> diff -N regress/usr.bin/grep/t27.in
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ regress/usr.bin/grep/t27.in       26 Dec 2021 10:32:02 -0000
> @@ -0,0 +1,12 @@
> +A
> +B
> +C
> +D
> +A
> +B
> +C
> +D
> +A
> +B
> +C
> +D
> Index: regress/usr.bin/grep/t27a.out
> ===================================================================
> RCS file: regress/usr.bin/grep/t27a.out
> diff -N regress/usr.bin/grep/t27a.out
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ regress/usr.bin/grep/t27a.out     26 Dec 2021 10:07:48 -0000
> @@ -0,0 +1,8 @@
> +C
> +D
> +--
> +C
> +D
> +--
> +C
> +D
> Index: regress/usr.bin/grep/t27b.out
> ===================================================================
> RCS file: regress/usr.bin/grep/t27b.out
> diff -N regress/usr.bin/grep/t27b.out
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ regress/usr.bin/grep/t27b.out     26 Dec 2021 10:10:21 -0000
> @@ -0,0 +1,8 @@
> +B
> +C
> +--
> +B
> +C
> +--
> +B
> +C
> Index: regress/usr.bin/grep/t27c.out
> ===================================================================
> RCS file: regress/usr.bin/grep/t27c.out
> diff -N regress/usr.bin/grep/t27c.out
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ regress/usr.bin/grep/t27c.out     26 Dec 2021 10:07:48 -0000
> @@ -0,0 +1,11 @@
> +B
> +C
> +D
> +--
> +B
> +C
> +D
> +--
> +B
> +C
> +D
> 

Thanks, something like this is needed to make the doreti_iret test
work as (multipe) -- lines in the output should be ignored:

        -Otto

Index: Makefile.amd64
===================================================================
RCS file: /cvs/src/sys/arch/amd64/conf/Makefile.amd64,v
retrieving revision 1.123
diff -u -p -r1.123 Makefile.amd64
--- Makefile.amd64      17 Dec 2021 14:59:22 -0000      1.123
+++ Makefile.amd64      26 Dec 2021 14:49:57 -0000
@@ -158,7 +158,8 @@ ioconf.o: ioconf.c
 
 locore.o: assym.h
        ${NORMAL_S}
-       @[[ -n `objdump -D $@ | grep -A1 doreti_iret | sort | uniq -d` ]] || \
+       @[[ -n `objdump -D $@ | grep -A1 doreti_iret | grep -v ^-- | sort | \
+        uniq -d` ]] || \
         { rm -f $@; echo "ERROR: overlaid iretq instructions don't line up"; \
           echo "#GP-on-iretq fault handling would be broken"; exit 1; }
 


 


Reply via email to