Attaching debugger to test using llvm-lit

How can I attach to a test launched by llvm-lit?

For example, running bin/llvm-lit test --filter TestSwiftLetInt -D dotest-args='-d' starts the test in a paused state, but I can't find in the running processes the one corresponding to the file that should be debugged in that test.

The answer depends on what the test is actually doing. If the test is invoking dotest.py, you should directly call the dotest.py invocation printed by the test. Then you can do

lldb /path/to/python -- /path/to/dotest.py dotest-py-args ...

These tests work by loading LLDB as a library into python.

Note that python may re-execute itself, so it is important to attach to the inner python, not the outer one.

If the test is a "shell" test, you an just extract the actual command that is executed and attach to that.