xref: /third_party/mesa3d/src/gallium/tools/addr2line.sh
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/mesa3d/src/gallium/tools/
1bf215546Sopenharmony_ci#!/usr/bin/env bash
2bf215546Sopenharmony_ci# This script processes symbols output by Gallium using glibc to human-readable function names
3bf215546Sopenharmony_ci
4bf215546Sopenharmony_cilastbin=
5bf215546Sopenharmony_cii=-1
6bf215546Sopenharmony_cidir="$(mktemp -d)"
7bf215546Sopenharmony_ciinput="$1"
8bf215546Sopenharmony_ci
9bf215546Sopenharmony_ci# Gather all unique addresses for each binary
10bf215546Sopenharmony_cised -nre 's|([^ ]*/[^ ]*)\(\+0x([^)]*).*|\1 \2|p' "$input"|sort|uniq|while read bin addr; do
11bf215546Sopenharmony_ci	if test "$lastbin" != "$bin"; then
12bf215546Sopenharmony_ci		((++i))
13bf215546Sopenharmony_ci		lastbin="$bin"
14bf215546Sopenharmony_ci		echo "$bin" > "$dir/$i.addrs.bin"
15bf215546Sopenharmony_ci	fi
16bf215546Sopenharmony_ci	echo "$addr" >> "$dir/$i.addrs"
17bf215546Sopenharmony_cidone
18bf215546Sopenharmony_ci
19bf215546Sopenharmony_ci# Construct a sed script to convert hex address to human readable form, and apply it
20bf215546Sopenharmony_cifor i in "$dir"/*.addrs; do
21bf215546Sopenharmony_ci	bin="$(<"$i.bin")"
22bf215546Sopenharmony_ci	addr2line -p -e "$bin" -a -f < "$i"|sed -nre 's@^0x0*([^:]*): ([^?]*)$@s|'"$bin"'(+0x\1)|\2|g@gp'
23bf215546Sopenharmony_ci	rm -f "$i" "$i.bin"
24bf215546Sopenharmony_cidone|sed -f - "$input"
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_cirmdir "$dir"
27

Indexes created Thu Nov 07 10:32:03 CST 2024