llvm-project
f8cb6cd9 - [lldb][Android] Fix platform process list regression (#164333)

Commit
169 days ago
[lldb][Android] Fix platform process list regression (#164333) ## Summary Fix `FindProcesses` to respect Android's `hidepid=2` security model and enable name matching for Android apps. ## Problem 1. Called `adb shell pidof` or `adb shell ps` directly, bypassing Android's process visibility restrictions 2. Name matching failed for Android apps - searched for `com.example.myapp` but GDB Remote Protocol reports `app_process64` Android apps fork from Zygote, so `/proc/PID/exe` points to `app_process64` for all apps. The actual package name is only in `/proc/PID/cmdline`. The previous implementation applied name filters without supplementing with cmdline, so searches failed. ## Fix - Delegate to lldb-server via GDB Remote Protocol (respects `hidepid=2`) - Get all visible processes, supplement zygote/app_process entries with cmdline, then apply name matching - Only fetch cmdline for zygote apps (performance), parallelize with `xargs -P 8` - Remove redundant code (GDB Remote Protocol already provides GID/arch) ## Test Results ### Before this fix: ``` (lldb) platform process list error: no processes were found on the "remote-android" platform (lldb) platform process list -n com.example.hellojni 1 matching process was found on "remote-android" PID PARENT USER TRIPLE NAME ====== ====== ========== ============================== ============================ 5276 359 u0_a192 com.example.hellojni ^^^^^^^^ Missing triple! ``` ### After this fix: ``` (lldb) platform process list PID PARENT USER TRIPLE NAME ====== ====== ========== ============================== ============================ 1 0 root aarch64-unknown-linux-android init 2 0 root [kthreadd] 359 1 system aarch64-unknown-linux-android app_process64 5276 359 u0_a192 aarch64-unknown-linux-android com.example.hellojni 5357 5355 u0_a192 aarch64-unknown-linux-android sh 5377 5370 u0_a192 aarch64-unknown-linux-android lldb-server ^^^^^^^^ User-space processes now have triples! (lldb) platform process list -n com.example.hellojni 1 matching process was found on "remote-android" PID PARENT USER TRIPLE NAME ====== ====== ========== ============================== ============================ 5276 359 u0_a192 aarch64-unknown-linux-android com.example.hellojni (lldb) process attach -n com.example.hellojni Process 5276 stopped * thread #1, name = 'example.hellojni', stop reason = signal SIGSTOP ``` ## Test Plan With an Android device/emulator connected: 1. Start lldb-server on device: ```bash adb push lldb-server /data/local/tmp/ adb shell chmod +x /data/local/tmp/lldb-server adb shell /data/local/tmp/lldb-server platform --listen 127.0.0.1:9500 --server ``` 2. Connect from LLDB: ``` (lldb) platform select remote-android (lldb) platform connect connect://127.0.0.1:9500 (lldb) platform process list ``` 3. Verify: - `platform process list` returns all processes with triple information - `platform process list -n com.example.app` finds Android apps by package name - `process attach -n com.example.app` successfully attaches to Android apps ## Impact Restores `platform process list` on Android with architecture information and package name lookup. All name matching modes now work correctly. Fixes https://github.com/llvm/llvm-project/issues/164192
Author
Parents
Loading