From 8fa27ae59c8a073969ef6c7aa4c430c4a8058043 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 7 Apr 2026 17:04:08 +0800 Subject: [PATCH] Enhance spc-debug script to support Xdebug profiling mode --- bin/spc-debug | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/spc-debug b/bin/spc-debug index d5a18c83..2c536003 100755 --- a/bin/spc-debug +++ b/bin/spc-debug @@ -1,4 +1,12 @@ #!/usr/bin/env bash +# Use SPC_XDEBUG=profile to enable Xdebug profiling mode, which will generate profiling files in /tmp. +# Otherwise, it will enable Xdebug debugging mode, which allows you to connect a debugger to port 9003. +if [ "$SPC_XDEBUG" = "profile" ]; then + XDEBUG_PREFIX="-d xdebug.mode=profile -d xdebug.start_with_request=yes -d xdebug.output_dir=/tmp -d xdebug.output_name=spc-profile.%t.%p.%r" +else + XDEBUG_PREFIX="-d xdebug.mode=debug -d xdebug.client_host=127.0.0.1 -d xdebug.client_port=9003 -d xdebug.start_with_request=yes" +fi + # This script runs the 'spc' command with Xdebug enabled for debugging purposes. -php -d xdebug.mode=debug -d xdebug.client_host=127.0.0.1 -d xdebug.client_port=9003 -d xdebug.start_with_request=yes "$(dirname "$0")/../bin/spc" "$@" +php $XDEBUG_PREFIX "$(dirname "$0")/../bin/spc" "$@"