#!/bin/bash
#set -v
# 获取进程的pid, xxx为可执行文件的名称
targetPid=$(pidof xxx)
# 获取线程号 grep -E根据线程名过滤线程,awk指定打印输出的第二列
# tr命令将换行符替换为","供性能分析工具perf使用
tids=$(ps -T -p "${targetPid}"| grep -E "X1|x2" | awk '{print $2}' | tr -s "\n" "," )
# perf record -p "${targetPid}" -t "${tids}" -g --sleep 30
# perf script | FlameGraph/stackcollapse-perf.pl | FlameGraph/flamegraph.pl > process.svg