Skip to content

Commit

Permalink
add a variant of http://poormansprofile.org/
Browse files Browse the repository at this point in the history
  • Loading branch information
devyn committed Aug 16, 2023
1 parent 4fa4cd7 commit 70936b6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tools/profile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Credit: Mark Callaghan, Domas Mituzas
# http://poormansprofiler.org/

# Modified to connect to remote target

if [[ -z "$GDB" ]]; then
export GDB="${CROSS_COMPILE}gdb"
fi

nsamples=$1
sleeptime=$2
file=$3

[[ -z "$nsamples" ]] && nsamples=1
[[ -z "$sleeptime" ]] && sleeptime=0
[[ -z "$file" ]] && file=stage1.elf

for x in $(seq 1 $nsamples)
do
$GDB -ex "file $file" -ex "target remote localhost:1234" -ex "set pagination 0" -ex "thread apply all bt" -batch
sleep $sleeptime
done | \
awk '
BEGIN { s = ""; }
/^Thread/ { print s; s = ""; }
/^#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
END { print s }' | \
sort | uniq -c | sort -r -n -k 1,1

0 comments on commit 70936b6

Please sign in to comment.