androidlinuxdebugginglldb

Lldb debugging using lldb-server on android?


I currently dont have a pc. I have two rooted devices Arm64 host device with Debian rootfs and the device to be debugged which contains the lldb-server binary armv7. I am trying to remote debug my android device using lldb. I pulled the lldb-server binary from àndroid ndk24 and put it in /data/local/tmp. Installed Debian Sid on Another term and apt installed lldb.

I then wifi hotspoted the client device(one with lldb-server) using the host with the linux rootfs.

The commands i ran on server device

./data/local/tmp/lldb-server platform --listen "*:2000"  --server

Checked using netstat and the lldb-server had bound to all addresses(0.0.0.0:2000)

On host(client lldb) device in debian sid terminal i ran:

apt install lldb
lldb
platform select remote-android
platform connect connect://192.168.201.132:2000

Then i get error failed connect port.

However, using Gdb and gdbserver everything worked perfectly. I have tried installing lldb on debian buster but same result and even ran the lldb-server binary on the host(device with debian sid) but same result. Right now im stuck here. How do I solve this?

Help will be greatly appreciated. Thank you.


Solution

  • I dont know why, but lldb-server platform command is broken(mabe in my case) and should have used lldb-server gdbserver like this:

    On lldb-server gdbserver command, the stub doesnt allow connections from other ips except the one it is bound to so do this:

    iptables -I INPUT -t nat -p tcp -d 192.168.43.1 --dport 2000 -j SNAT --to-source 192.168.43.1:50000
    ./data/local/tmp/lldb-server g 192.168.43.1:2000
    

    On lldb client do

    gdb-remote 192.168.43.1:2000
    

    Then do normal remote debugging.

    EDIT:

    When using the lldb platform command to connect to an android device, the machine with the lldb client should have adb installed. The adb server should be running on port 5037 and have one client connected. If you have adb then you can use

    platform select remote-android
    

    else use gdb-remote command.