Skip to content

[lldb/interpreter] Add Swift REPL init file support #1717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

medismailben
Copy link

Some users complained that when using the Swift REPL (LLDB launched with
--repl option), it would try to read their home init file, which can cause
unintended behaviour.

To solve this issue, this patch introduces a new, more specific, Swift
REPL init file, conveniently named .lldbinit-swift-repl. If the user
creates this file in his home directory, and launches LLDB in REPL mode,
it will override the default init file.

This behaviour only applies when REPL mode is enabled.

rdar://65836048

Signed-off-by: Med Ismail Bennani [email protected]

@medismailben medismailben self-assigned this Aug 28, 2020
@medismailben
Copy link
Author

@swift-ci test

@medismailben
Copy link
Author

@swift-ci test linux platform

@medismailben
Copy link
Author

@swift-ci test

@JDevlieghere
Copy link

@swift-ci please test linux

Copy link

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are users supposed to know what file LLDB will read for the Swift REPL. You probably want to mention this in the man page. If you decide to go with the .lldbinit-language-repl scheme you could even do this on llvm.org.

@medismailben medismailben force-pushed the swift/master-rebranch branch 3 times, most recently from cc8b780 to 19953a1 Compare September 1, 2020 21:20
@medismailben
Copy link
Author

I'll move this to llvm.org, and cherrypick it afterwards.

@medismailben medismailben reopened this Sep 3, 2020
@medismailben medismailben removed the request for review from JDevlieghere September 3, 2020 05:46
Provider a wrapper around llvm::sys::path::home_directory in the
FileSystem class. This will make it possible for the reproducers to
intercept the call in a central place.
@medismailben medismailben changed the base branch from swift/master-rebranch to swift/master September 3, 2020 09:29
This patch changes the command interpreter sourcing logic for the REPL
init file. Instead of looking for a arbitrary file name, it standardizes
the REPL init file name to match to following scheme:

                          `.lldbinit-<language>-repl`

This will make the naming more homogenous and the sourcing logic future-proof.

rdar://65836048

Differential Revision: https://reviews.llvm.org/D86987

Signed-off-by: Med Ismail Bennani <[email protected]>
Previously, before loading the REPL language-specific init file, lldb
checked the selected target language in which case it returned an unknown
language type with the REPL target.

Instead, the patch calls `Language::GetLanguagesSupportingREPLs` and
look for the first element of that set. In case lldb was not configured
with a REPL language, then, it will just stop sourcing the REPL init
file and fallback to the original logic (continuing with the default
init file).

rdar://65836048

Differential Revision: https://reviews.llvm.org/D87076

Signed-off-by: Med Ismail Bennani <[email protected]>
This test adds `breakpoint set` commands with different source locations
to a temporary `.lldbinit-swift-repl` and `.lldbinit` and after launching
lldb, it checks that the breakpoint set in the debugger matches the
source location from the SwiftREPL initfile.

rdar://65836048

Signed-off-by: Med Ismail Bennani <[email protected]>
@medismailben medismailben dismissed JDevlieghere’s stale review September 3, 2020 09:33

52d43e1 handles the change on llvm.org

@medismailben
Copy link
Author

@swift-ci test

@medismailben medismailben merged commit fd6439e into swiftlang:swift/master Sep 3, 2020
@JDevlieghere
Copy link

Did you also cherry-pick the llvm.org patches to the Bastille branch?

@medismailben
Copy link
Author

Did you also cherry-pick the llvm.org patches to the Bastille branch?

Yep, in #1736 and #1739 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants