Created
January 20, 2024 13:01
-
-
Save weliveindetail/a197b4fb8b3279cfdabaef1e93bc390e to your computer and use it in GitHub Desktop.
Pre-populate LLDB module cache with existing binaries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: $0 <executable> [remote-linux]" | |
exit 1 | |
fi | |
executable_path="$1" | |
echo "Pre-caching executable: $executable_path" | |
build_id_str=$(readelf -n "$executable_path" | grep "Build") | |
build_id=$(echo "$build_id_str" | awk '{print $NF}') | |
echo "Build ID: $build_id" | |
build_id_subdir=$(echo "$build_id" | sed -E 's/(.{8})(.{4})(.{4})(.{4})(.{12})(.{8})/\1-\2-\3-\4-\5-\6/' | tr 'a-f' 'A-F') | |
# Default to remote-linux | |
remote="${2:-remote-linux}" | |
lldb_cache_dir="$HOME/.lldb/module_cache/$remote/.cache" | |
echo "Cache root for remote '$remote': $lldb_cache_dir" | |
# Don't mess with existing cache files | |
build_id_fullpath="$lldb_cache_dir/$build_id_subdir" | |
if [ -d "$build_id_fullpath" ]; then | |
echo "Cache directory '$build_id_fullpath' already exists. Please remove it manually and try again." | |
exit 1 | |
fi | |
mkdir -p "$build_id_fullpath" | |
executable_name=$(basename "$executable_path") | |
echo "Copy executable to cache: $build_id_fullpath/$executable_name" | |
cp "$executable_path" "$build_id_fullpath/$executable_name" | |
echo "Done" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ lldb-precache build-ubuntu20.04-aarch32/bin/clang-repl | |
Pre-caching executable: build-ubuntu20.04-aarch32/bin/clang-repl | |
Build ID: 86e7de5facfac1e6a55a50003c4a44dd7bf9a10d | |
Cache root for remote 'remote-linux': /home/ez/.lldb/module_cache/remote-linux/.cache | |
Copy executable to cache: /home/ez/.lldb/module_cache/remote-linux/.cache/86E7DE5F-ACFA-C1E6-A55A-50003C4A44DD-7BF9A10D/clang-repl | |
Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment