LLDB remote debugging issues

(Maksim) #1

Hi,

I'm having an issue debugging the most basic swift program on a remote AWS Ubuntu 16.04 instance using lldb-server. This is the program code:
import Foundation
var count = 0
while true {
print("count = (count)")
count = count + 1
Thread.sleep(forTimeInterval: 1.0)
}
I compile this file with this command: $ swiftc -g basicswift.swift
Using swift-DEVELOPMENT-SNAPSHOT-2018-07-16-a-ubuntu16.04 build.

On a remote system:
1] I setup a few symlinks in /usr/lib to point to ~/swift-DEVELOPMENT-SNAPSHOT-2018-07-16-a-ubuntu16.04/usr/lib/swift/linux/ (ie, libFoundation, libswiftCore, etc)
2] I can run the compiled basicswift program on AWS instance no problem.
3] I launch $ lldb-server platform --listen "*:1234" --server --min-gdbserver-port 1235 --max-gdbserver-port 1240

On a local system:
1] I launch $ lldb
1a] platform select remote-linux
1b] platform connect connect://myhost:1234
1c] file ./basicswift
1d] run

On the remote system I can see basicswift was launched and I get the corresponding message on my local system (after about 20 seconds) stating as such and after that nothing happens. At first, I thought it just takes a while... and in fact, one time I saw the counter in my local system's lldb and I was able to set breakpoints/debug. But after a dozen tries, my local lldb just refuses to do anything.

Another observation, if I kill lldb-server on the remote system, basicswift keeps running and on remote system I can run $ sudo lldb, and attach to the process and verify that the counter is high, meaning all the while I was waiting for my local lldb to show something, remote process was indeed running.

I know for a fact that this is not a firewall issue as building and running an equivalent C program works just fine, lldb is able to connect and debug.
#include <stdio.h>
#include <unistd.h>
int main() {
int count = 0;
while (1) {
printf("count = %d\n", count);
count = count + 1;
sleep(1);
}
return 0;
}

I tried connecting to the remote lldb-server from both Mac OS laptop and Ubuntu 16.04 running in VMWare Fusion. When I run the same binary on another VM on my laptop, I can use lldb to launch + debug it inside the VM. So, the issue appears to be related to either specific AWS Ubuntu 16.04 configuration, or perhaps the network latency? By the way, local lldb basically stops responding after launching $ run command.

Sometimes I'm also getting error:
error: Failed to halt process: Halt timed out. State = running

There is a similar bug for this: https://bugs.swift.org/browse/SR-3596