Path: blob/21.2-virgl/src/gallium/tools/addr2line.sh
4560 views
#!/usr/bin/env bash1# This script processes symbols output by Gallium using glibc to human-readable function names23lastbin=4i=-15dir="$(mktemp -d)"6input="$1"78# Gather all unique addresses for each binary9sed -nre 's|([^ ]*/[^ ]*)\(\+0x([^)]*).*|\1 \2|p' "$input"|sort|uniq|while read bin addr; do10if test "$lastbin" != "$bin"; then11((++i))12lastbin="$bin"13echo "$bin" > "$dir/$i.addrs.bin"14fi15echo "$addr" >> "$dir/$i.addrs"16done1718# Construct a sed script to convert hex address to human readable form, and apply it19for i in "$dir"/*.addrs; do20bin="$(<"$i.bin")"21addr2line -p -e "$bin" -a -f < "$i"|sed -nre 's@^0x0*([^:]*): ([^?]*)$@s|'"$bin"'(+0x\1)|\2|g@gp'22rm -f "$i" "$i.bin"23done|sed -f - "$input"2425rmdir "$dir"262728