summaryrefslogtreecommitdiff
path: root/tests/pc.test
blob: 7da0d6b0c28f0c45ed97a9cc17200652bd3159fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
#
# Check -i option.
#
# Copyright (c) 2015 Dmitry V. Levin <ldv@strace.io>
# Copyright (c) 2015-2020 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later

. "${srcdir=.}/init.sh"

check_prog sed

run_prog > /dev/null

args="--quiet=attach,personality -if $args"
$STRACE $args 2> "$LOG" ||
	dump_log_and_fail_with "$STRACE $args failed"

len="$(sed -r -n 's/^\[[[:xdigit:]]+\] write\(-1, 0x8, ([[:digit:]]{1,2})\)[[:space:]]+= -1 .*/\1/p' "$LOG")" &&
[ -n "$len" ] &&
pid="$(sed -r -n 's/^\[[[:xdigit:]]{'"$len"'}\] --- SIGCHLD \{si_signo=SIGCHLD, si_code=CLD_(KILLED|DUMPED), si_pid=([[:digit:]]+), .*/\2/p' "$LOG")" &&
[ -n "$pid" ] &&
ip="$(sed -r -n 's/^\[pid +'"$pid"'\] \[([[:xdigit:]]{'"$len"'})] --- SIGSEGV \{.*\} ---$/\1/p' "$LOG")" &&
[ -n "$ip" ] &&
# strip the last nibble of the address. On hppa the lowest 2 bits encode the address space.
addr="$(echo "$ip" |sed -r 's/^0+//')" && addr=${addr%?} &&
[ -n "$addr" ] ||
	dump_log_and_fail_with

cat > "$EXP" << __EOF__
\\[[[:xdigit:]]{$len}\\] munmap\\(0x[[:xdigit:]]+, 0\\) += -1 .*
\\[pid +$pid\\] \\[\\?{$len}\\] \\+\\+\\+ killed by SIGSEGV( \\(core dumped\\))? \\+\\+\\+
\\[pid +$pid\\] \\[$ip\\] --- SIGSEGV \\{si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x$addr[[:xdigit:]]\\} ---
\\[\\?{$len}\\] \\+\\+\\+ exited with 0 \\+\\+\\+
__EOF__

match_grep "$LOG" "$EXP"