Tuesday, January 28, 2020

Aggregate PMP call stacks for one thread

Putting this in a blog post because I want to find it again. I had N files. Each file had stack traces from one point in time. I wanted to know what one thread was doing so I extracted the stack for that thread from each of the N files and then aggregated the result. The thread was LWP 23839.

Step 1: extract traces for LWP 23839

for d in f.*; do
echo $d; awk '/\(LWP 23839/,/^$/' $d;
done > all.f

Step 2: aggregate stacks for LWP 23839. This is a slight variant of standard PMP.

cat all.f | awk 'BEGIN { s = ""; }  /^Thread/ { print s; s = ""; } /^\#/ { x=index($2, "0x"); if (x == 1) { n=$4 } else { n=$2 }; if (s != "" ) { s = s "," n} else { s = n } } END { print s }' -  | sort | uniq -c | sort -r -n -k 1,1


No comments:

Post a Comment