Skip to content

Commit

Permalink
tools/btdecode.sh: make grep overridable
Browse files Browse the repository at this point in the history
This script seems to assume GNU grep, which is not commonly
available as "grep" on some platforms.  For examples, it's
more common to have it named "ggrep" on BSD-based systems
including macOS.

Ideally, I suppose we should avoid GNU dependencies like this
in general.  But I'm not motivated enough to rewrite this script
in a portable way today.

cf. https://www.gnu.org/software/grep/manual/grep.html#grep-Programs-1
  • Loading branch information
yamt committed Sep 26, 2024
1 parent 44e8772 commit 3ec2667
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/btdecode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ USAGE="USAGE: ${0} chip|toolchain-addr2line backtrace_file
If the first argument contains 'addr2line', it will be used as the toolchain's addr2line tool.
Otherwise, the script will try to identify the toolchain based on the chip name."

GREP=${GREP:-grep}

VALID_CHIPS=(
"esp32"
"esp32s2"
Expand Down Expand Up @@ -119,8 +121,8 @@ while read -r line; do
fi

if [[ $line =~ (\[CPU[0-9]+\]\ )?sched_dumpstack: ]]; then
task_id=$(echo $line | grep -oP 'backtrace\|\s*\K\d+')
addresses=$(echo $line | grep -oP '0x[0-9a-fA-F]+')
task_id=$(echo $line | ${GREP} -oP 'backtrace\|\s*\K\d+')
addresses=$(echo $line | ${GREP} -oP '0x[0-9a-fA-F]+')
if $in_dump_tasks_section; then
if [[ -n "${backtraces_after[$task_id]}" ]]; then
backtraces_after[$task_id]="${backtraces_after[$task_id]} $addresses"
Expand Down Expand Up @@ -155,4 +157,4 @@ if $in_dump_tasks_section; then
done
echo ""
done
fi
fi

0 comments on commit 3ec2667

Please sign in to comment.