Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only sudo if you aren't already the user running the jvm process #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/create-java-perf-map.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fi
[ -d "$JAVA_HOME" ] || (echo "JAVA_HOME directory at '$JAVA_HOME' does not exist." && false)


if [[ "$LINUX" == "1" ]]; then
if [[ "$LINUX" == "1" ]] && [[ $EUID -ne $TARGET_UID ]]; then
sudo rm $PERF_MAP_FILE -f
(cd $PERF_MAP_DIR/out && sudo -u \#$TARGET_UID -g \#$TARGET_GID $JAVA_HOME/bin/java -cp $ATTACH_JAR_PATH:$JAVA_HOME/lib/tools.jar net.virtualvoid.perf.AttachOnce $PID "$OPTIONS")
sudo chown root:root $PERF_MAP_FILE
Expand Down
2 changes: 1 addition & 1 deletion bin/perf-java-flames
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ if [ -z "$PERF_FLAME_OPTS" ]; then
fi

$PERF_MAP_DIR/bin/perf-java-record-stack $*
sudo perf script -i $PERF_DATA_FILE > $STACKS
sudo perf script --force -i $PERF_DATA_FILE > $STACKS
$FLAMEGRAPH_DIR/stackcollapse-perf.pl $PERF_COLLAPSE_OPTS $STACKS | tee $COLLAPSED | $FLAMEGRAPH_DIR/flamegraph.pl $PERF_FLAME_OPTS > $PERF_FLAME_OUTPUT
echo "Flame graph SVG written to PERF_FLAME_OUTPUT='`readlink -f $PERF_FLAME_OUTPUT`'."
2 changes: 1 addition & 1 deletion bin/perf-java-report-stack
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ if [ -z "$PERF_DATA_FILE" ]; then
fi

$PERF_MAP_DIR/bin/perf-java-record-stack $*
sudo perf report -i $PERF_DATA_FILE
sudo perf report --force -i $PERF_DATA_FILE
2 changes: 1 addition & 1 deletion bin/perf-java-top
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ PERF_MAP_DIR=$(dirname $(readlink -f $0))/..

PID=$1
$PERF_MAP_DIR/bin/create-java-perf-map.sh $PID "$PERF_MAP_OPTIONS"
sudo perf top -p $*
sudo perf top --force -p $*