diff --git a/flight_profiler/client.py b/flight_profiler/client.py index 0912535..b1cf316 100644 --- a/flight_profiler/client.py +++ b/flight_profiler/client.py @@ -291,8 +291,13 @@ def get_base_addr(current_directory: str, server_pid: str, platform: str) -> int base_addr_locate_shell_path = os.path.join( current_directory, f"shell/{platform}/py_bin_base_addr_locate.sh" ) + # Pass the lsof-resolved client binary path so the script compares the same + # path representation as it derives from the server pid. On macOS framework + # Pythons, sys.executable points at bin/pythonX.Y while lsof reports the + # Python.app/Contents/MacOS/Python launcher — comparing them directly fails. + client_bin_path = get_py_bin_path(os.getpid()) base_addr = execute_shell( - base_addr_locate_shell_path, ["bash", base_addr_locate_shell_path, server_pid, str(sys.executable)] + base_addr_locate_shell_path, ["bash", base_addr_locate_shell_path, server_pid, client_bin_path] ) if base_addr is None or len(base_addr) == 0: show_error_info( diff --git a/flight_profiler/shell/resolve_symbol.sh b/flight_profiler/shell/resolve_symbol.sh index 56c1dbf..6cee273 100755 --- a/flight_profiler/shell/resolve_symbol.sh +++ b/flight_profiler/shell/resolve_symbol.sh @@ -12,6 +12,22 @@ fi shell_bin_dir="$(dirname "$0")" symbol_bin_path=$(sh $shell_bin_dir/resolve_bin_path.sh $pid) + +# On macOS framework Pythons (Homebrew, python.org installer), the running +# executable is the tiny `Python.app/Contents/MacOS/Python` launcher with no +# Python symbols. The actual symbols live in the sibling framework dylib at +# `Python.framework/Versions/X.Y/Python`. Fall back to that for nm lookup, +# while keeping resolve_bin_path.sh returning the real running executable +# (lldb needs the launcher for `process attach -p` to succeed). +case "$symbol_bin_path" in + */Python.framework/Versions/*/Resources/Python.app/Contents/MacOS/Python) + framework_dylib=$(echo "$symbol_bin_path" | sed -E 's|/Resources/Python.app/Contents/MacOS/Python$||')/Python + if [ -f "$framework_dylib" ]; then + symbol_bin_path="$framework_dylib" + fi + ;; +esac + line=$(nm $symbol_bin_path| grep $symbol| head -n 1) if [ -z "$line" ]; then exit 1