2

I currently don't 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 android ndk24 and put it in /data/local/tmp. Installed Debian sid on another term and apt installed lldb.

I connected client device via wifi-hotspot (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 got 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 I'm stuck here. How do I solve this?

Help will be greatly appreciated. Thank you.

Edit Here is output of telnet

root@localhost:~# telnet 192.168.43.1 2000
Trying 192.168.43.1...
Connected to 192.168.43.1.
Escape character is '^]'.
Connection closed by foreign host.
root@localhost:~# telnet 192.168.43.1 5555
Trying 192.168.43.1...
Connected to 192.168.43.1.
Escape character is '^]'.
Killed
root@localhost:~#

And heres same network output from lldb.

lldb) platform select remote-android
  Platform: remote-android
 Connected: no
(lldb) platform connect connect;//192.168.43.1:2000
error: Invalid URL: connect;//192.168.43.1:2000
(lldb) platform connect connect://192.168.43.1:2000
error: Failed to connect port
(lldb)

And now I dont really know the problem. Should i try installing on a different rootfs? Let me do that.

Edit 2

Installed ubuntu focal and still got same results on lldb 10.0.0.

5
  • May be a different program like Android Studio or Visual Studio has automatically connected to the remote lldb instance and thus the port is blocked (because only one connection is allowed)? Especially Android Studio is known to be "greedy" establishing connections automatically in background and thus blocking other programs. Have you checked on the Android device if there is already a network connection?
    – Robert
    Jun 9, 2022 at 8:13
  • i actually have neither of them installed. Its just a small Debian rootfs in a proot environment and from netstat output i found no established connection but listeners only.
    – Silent
    Jun 10, 2022 at 19:46
  • You wrote that gdb connection works, so in generat TCP seems to work. Just to be sure what happens if you try to connect to port 2000 using telnet instead of lldb? If that works then something is wrong in the communication between lldb and lldb-sever.
    – Robert
    Jun 10, 2022 at 21:31
  • Okay let me try and I will reply what happens. Although could it be a lldb-server problem maybe i should compile lldb-server myself maybe the android ndk provided one have been stripped off other features and cant be connected to using original lldb?
    – Silent
    Jun 11, 2022 at 17:17
  • @Robert I have edited the question
    – Silent
    Jun 11, 2022 at 18:09

1 Answer 1

1

I don't know if this should be an answer or not. I finally managed to use lldb remote debugging but again faced more challenges but eventually prevailed.

What I did was instead of using lldb platform command I used lldb gdbserver command which function correctly but had a caveat of accepting local connections only and rejecting connections from external addresses. So I had to use iptables' nat table to finally make it work.

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

Then on lldb client I did

gdb-remote 192.168.43.1:2000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.