apple / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. This fork is used to manage Apple’s stable releases of Clang as well as support the Swift project.
https://llvm.org
Other
1.1k stars 320 forks source link

[Cherry-pick into next] Improve error handling in SwiftUserExpression. #8816

Closed adrian-prantl closed 1 month ago

adrian-prantl commented 1 month ago
commit 176b5d011d6b189084a0e7ad7928e02701f56e83
Author: Adrian Prantl <aprantl@apple.com>
Date:   Tue May 28 10:50:48 2024 -0700

    Improve error handling in SwiftUserExpression.

    Previously this
$ swiftc test.swift -g -o test
$ lldb -o 'b main' -o 'b test' -o r -o 'e -i0 -- test()' ./test
(lldb) ^D
```

resulted in
```
Can't execute a swift expression without a runtime
UNREACHABLE executed at llvm-project/lldb/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp:90!
```

after this patch it's

```
(lldb) ^D
error: Could not finish swift expression because the process is being torn down
```

Unfortunately catching this error in a test case is tricky.