Issues with LLDB and modules


(Dmitry Shevchenko) #1

Hello, I would like to ask a couple of implementation questions about LLDB
and Swift.

We are building swift in a custom build system (bazel.org) where we try to
use Swift static libraries to compose our programs. In other words, we
build multiple Swift targets into a pair of (.a, .switfmodule) and then
link static libraries together into the final executable.

It works pretty well, but there are issues when it comes to debugging.
Ideally, we would like to debug with and without dSYM to speedup
compilations.

From reading SwiftASTContext.cpp, it looks like LLDB needs to load the

corresponding .swiftmodule to work.
It does so by looking at the AST tag in the symbol table of the executable.
Is this correct, or is there another way that LLDB can find the module?

Additionally, there can only be one such tag, since LLDB reads the first
one it finds and stops.
However, if a program is composed from multiple modules, it's not possible
to tell the debugger to load them all. For example, if the app is written
mostly in ObjC, but has multiple helper Swift libraries where each has its
own module, and those modules do not import each other (so there's no clear
way to say what is the "main" module), how would we tell LLDB to load all
of them?

Thank you!


(Dmitry Shevchenko) #2

My apologies, the url should read http://bazel.io.

···

On Fri, Sep 9, 2016 at 2:04 PM Dmitry Shevchenko <dmishe@google.com> wrote:

Hello, I would like to ask a couple of implementation questions about LLDB
and Swift.

We are building swift in a custom build system (bazel.org) where we try
to use Swift static libraries to compose our programs. In other words, we
build multiple Swift targets into a pair of (.a, .switfmodule) and then
link static libraries together into the final executable.

It works pretty well, but there are issues when it comes to debugging.
Ideally, we would like to debug with and without dSYM to speedup
compilations.

From reading SwiftASTContext.cpp, it looks like LLDB needs to load the
corresponding .swiftmodule to work.
It does so by looking at the AST tag in the symbol table of the
executable.
Is this correct, or is there another way that LLDB can find the module?

Additionally, there can only be one such tag, since LLDB reads the first
one it finds and stops.
However, if a program is composed from multiple modules, it's not possible
to tell the debugger to load them all. For example, if the app is written
mostly in ObjC, but has multiple helper Swift libraries where each has its
own module, and those modules do not import each other (so there's no clear
way to say what is the "main" module), how would we tell LLDB to load all
of them?

Thank you!


(Dmitry Shevchenko) #3

Added a functional test project on a bug here
https://bugs.swift.org/browse/SR-2637

Hopefully this makes things a bit more clear.

···

On Mon, Sep 12, 2016 at 12:13 PM Dmitry Shevchenko <dmishe@google.com> wrote:

My apologies, the url should read http://bazel.io.

On Fri, Sep 9, 2016 at 2:04 PM Dmitry Shevchenko <dmishe@google.com> > wrote:

Hello, I would like to ask a couple of implementation questions about LLDB
and Swift.

We are building swift in a custom build system (bazel.org) where we try
to use Swift static libraries to compose our programs. In other words, we
build multiple Swift targets into a pair of (.a, .switfmodule) and then
link static libraries together into the final executable.

It works pretty well, but there are issues when it comes to debugging.
Ideally, we would like to debug with and without dSYM to speedup
compilations.

From reading SwiftASTContext.cpp, it looks like LLDB needs to load the
corresponding .swiftmodule to work.
It does so by looking at the AST tag in the symbol table of the
executable.
Is this correct, or is there another way that LLDB can find the module?

Additionally, there can only be one such tag, since LLDB reads the first
one it finds and stops.
However, if a program is composed from multiple modules, it's not possible
to tell the debugger to load them all. For example, if the app is written
mostly in ObjC, but has multiple helper Swift libraries where each has its
own module, and those modules do not import each other (so there's no clear
way to say what is the "main" module), how would we tell LLDB to load all
of them?

Thank you!