Skip to content

Instantly share code, notes, and snippets.

@leoadberg
Created July 13, 2022 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoadberg/3ba413fbb6d8ee7b8dcc5006eda6e84e to your computer and use it in GitHub Desktop.
Save leoadberg/3ba413fbb6d8ee7b8dcc5006eda6e84e to your computer and use it in GitHub Desktop.
Patches the VTune Profiler to run on M1 Macs when profiling remotely
#! /bin/bash -e
# Change these as needed for other VTune versions
VTUNE="/Applications/Intel VTune Profiler 2020.app"
TOPATCH=(
"$VTUNE/Contents/Frameworks/libamplxe_dpihelpers_1.42.dylib"
)
for FILE in "${TOPATCH[@]}"; do
# Get addresses of all xacquire or xrelease instructions in binary
ADDRS=$(otool -xv "${FILE}" | egrep "xacquire|xrelease" | awk '{print $1}')
for ADDR in $ADDRS; do
# Overwrite each xacquire/xrelease with a 0x90 (NOP in x86)
printf '\x90' | dd bs=1 seek=$((16#$ADDR)) conv=notrunc of="${FILE}"
done
done
# Need to re-codesign the app
codesign -s - -f --deep "${VTUNE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment