Skip to content
Merged
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
7 changes: 6 additions & 1 deletion flight_profiler/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions flight_profiler/shell/resolve_symbol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading