Skip to content

[SR-3380] Cannot attach to a local Swift process using lldb on Linux #4649

Closed
@swift-ci

Description

@swift-ci
Previous ID SR-3380
Radar None
Original Reporter rolivieri (JIRA User)
Type Bug
Status Closed
Resolution Invalid

Attachment: Download

Environment

Linux flavor: Ubuntu 14.04 LTS
Swift flavor: Swift Release v3.0.1

Additional Detail from JIRA
Votes 6
Component/s LLDB for Swift
Labels Bug, Linux
Assignee morlovich (JIRA)
Priority Medium

md5: 00df5ccc367db981486f9ef5a740241e

Issue Description:

Linux flavor: Ubuntu 14.04 LTS
Swift flavor: Swift Release v3.0.1

Using lldb and trying to attach using a valid process name or process ID always results in the following error:
error: attach failed: unable to attach

Here are the steps to reproduce this problem:

1) Unzip the sample project and build it on an Ubuntu 14.04 system (swift build).
2) Start the sample app by executing: .build/debug/swift-tst (note: this program is just an infinite loop that prints a "hello world" message).
3) Obtain the process ID for the sample program.
4) Launch the lldb program and execute these commands:

(lldb) platform select host
Platform: host
Triple: x86_64-*-linux-gnu
OS Version: 4.2.0
Hostname: 127.0.0.1
WorkingDir: /home/ricardo/tmp/swift-tst
Kernel: Linux
Release: 4.2.0-42-generic
Version: #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016
(lldb) process attach --name swift-tst
error: attach failed: unable to attach
(lldb) process attach —pid <process pid>
error: attach failed: unable to attach

It is worth mentioning that attempting to attach to a remote Swift process on Linux also fails with the same error… but our guess is that remote debugging+attaching won’t work given that the attaching locally to a local process does not work. Having said that, we are documenting here the steps we attempted for remote debugging+attaching (Linux to Linux), which also resulted in a failure:

1) On remote Linux server (Ubuntu 14.04), we started lldb-server:
lldb-server platform --listen *:8000

2) On remote Linux server, started sample program: .build/debug/swift-tst

3) On local Linux server, starter lldb:

$ lldb
(lldb) platform select remote-linux
Platform: remote-linux
Connected: no
(lldb) platform connect connect://localhost:8000
Platform: remote-linux
Triple: x86_64-*-linux-gnu
OS Version: 4.2.0 (4.2.0-42-generic)
Kernel: #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016
Hostname: ricardo-ubuntu14.04
Connected: yes
WorkingDir: /home/ricardo
(lldb) process list
invalid command 'process list'.
(lldb) platform process list
75 matching processes were found on "remote-linux"
PID PARENT USER TRIPLE NAME
====== ====== ========== ======================== ============================
1261 1256 ricardo x86_64-*-linux init
...
3626 2682 ricardo x86_64-*-linux swift-tst
...
23682 1261 ricardo x86_64-*-linux upstart-file-bridge
(lldb) process attach --name swift-tst
error: attach failed: unable to attach
(lldb) process attach --pid 3626
error: attach failed: unable to attach

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions