1d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes#!/bin/sh 2d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# 3d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# Check -i option. 4d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# 5d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org> 639bac055674d23770b9a724221b728e443196ea7Elliott Hughes# Copyright (c) 2015-2017 The strace developers. 7d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# All rights reserved. 8d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# 9d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# Redistribution and use in source and binary forms, with or without 10d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# modification, are permitted provided that the following conditions 11d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# are met: 12d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# 1. Redistributions of source code must retain the above copyright 13d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# notice, this list of conditions and the following disclaimer. 14d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# 2. Redistributions in binary form must reproduce the above copyright 15d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# notice, this list of conditions and the following disclaimer in the 16d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# documentation and/or other materials provided with the distribution. 17d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# 3. The name of the author may not be used to endorse or promote products 18d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# derived from this software without specific prior written permission. 19d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# 20d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes 31d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes. "${srcdir=.}/init.sh" 32d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes 33d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughescheck_prog sed 34d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes 35d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughesrun_prog > /dev/null 36d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes 37d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughesargs="-if $args" 38d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes$STRACE $args 2> "$LOG" || 39d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes dump_log_and_fail_with "$STRACE $args failed" 40d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes 41d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hugheslen="$(sed -r -n 's/^\[[[:xdigit:]]+\] write\(-1, NULL, ([[:digit:]]{1,2})\)[[:space:]]+= -1 .*/\1/p' "$LOG")" && 42d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes[ -n "$len" ] && 43d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughespid="$(sed -r -n 's/^\[[[:xdigit:]]{'"$len"'}\] --- SIGCHLD \{si_signo=SIGCHLD, si_code=CLD_(KILLED|DUMPED), si_pid=([[:digit:]]+), .*/\2/p' "$LOG")" && 44d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes[ -n "$pid" ] && 45d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughesip="$(sed -r -n 's/^\[pid +'"$pid"'\] \[([[:xdigit:]]{'"$len"'})] --- SIGSEGV \{.*\} ---$/\1/p' "$LOG")" && 46d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes[ -n "$ip" ] && 47d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughesaddr="$(echo "$ip" |sed -r 's/^0+//')" && 48d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes[ -n "$addr" ] || 49d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes dump_log_and_fail_with 50d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes 5139bac055674d23770b9a724221b728e443196ea7Elliott Hughescat > "$EXP" << __EOF__ 52d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes\\[[[:xdigit:]]{$len}\\] munmap\\(0x[[:xdigit:]]+, 0\\) += -1 .* 53d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes\\[pid +$pid\\] \\[$ip\\] --- SIGSEGV \\{si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x$addr\\} --- 54d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes\\[pid +$pid\\] \\[\\?{$len}\\] \\+\\+\\+ killed by SIGSEGV( \\(core dumped\\))? \\+\\+\\+ 55d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes\\[\\?{$len}\\] \\+\\+\\+ exited with 0 \\+\\+\\+ 56d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes__EOF__ 57d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes 5839bac055674d23770b9a724221b728e443196ea7Elliott Hughesmatch_grep "$LOG" "$EXP" 59