Debian Codegraph @

gcc/testsuite/g++.dg/contracts/backtrace_handler/prettytrace.sh

raw
1 #!/bin/bash
2
3 inViolation="false"
4 sed 's/^/:/' /dev/stdin | while read -r line; do
5 line="$(echo "$line" | sed 's/^://')"
6
7 if [[ "${inViolation}" == "false" ]]; then
8 echo "$line"
9 if [[ -n "$(echo "$line" | grep 'violation occurs here:')" ]]; then
10 inViolation="true"
11 fi
12 continue
13 fi
14
15 if [[ -n "$(echo "$line" | grep 'end of violation')" ]]; then
16 inViolation="false"
17 continue
18 fi
19
20 addr="$(echo "$line" | sed -r 's/.*\[0x([a-f0-9]+)\]$/\1/')"
21 bin="$(echo "$line" | sed -r 's/^([^([]*).*/\1/')"
22 [[ -n "${bin}" ]] || continue
23 t="$(addr2line -e "$bin" "$addr" -f)"
24 file="$(echo "$t" | tail -1 | tr ':' '\n' | head -1)"
25 file="$(echo "$file" | sed -r "s:^$(pwd)/?::")"
26 line="$(echo "$t" | tail -1 | tr ':' '\n' | tail -1 | cut -d' ' -f1)"
27 func="$(echo "$t" | head -1 | c++filt)"
28 [[ $file != "??" ]] && echo " $file:$func:$line"
29 done
30