This is an archive of the discontinued LLVM Phabricator instance.

[lldb/interpreter] Add REPL-specific init file
ClosedPublic

Authored by mib on Aug 19 2020, 1:13 PM.

Details

Summary

This patch adds the infrastructure to have language specific REPL init
files. It's the foundation work to a following patch that will introduce
Swift REPL init file.

When lldb is launched with the --repl option, it will look for a REPL
init file in the home directory and source it. This overrides the
default ~/.lldbinit, which content might make the REPL behave
unexpectedly. If the REPL init file doesn't exists, lldb will fall back
to the default init file.

rdar://65836048

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>

Diff Detail

Event Timeline

mib created this revision.Aug 19 2020, 1:13 PM
mib requested review of this revision.Aug 19 2020, 1:13 PM
mib updated this revision to Diff 286648.Aug 19 2020, 1:15 PM

Fixed typo.

JDevlieghere added inline comments.Aug 19 2020, 1:30 PM
lldb/docs/man/lldb.rst
307–308

I wonder if we should have the description here, and refer to it from the REPL section.

lldb/include/lldb/API/SBCommandInterpreter.h
150

nit: How about is_repl as this is not really something you turn on and off?

150

I'd also give it a default argument (false).

lldb/source/API/SBDebugger.cpp
223

This can go with the default arg.

mib added inline comments.Aug 19 2020, 1:37 PM
lldb/docs/man/lldb.rst
307–308

Sounds good.

lldb/include/lldb/API/SBCommandInterpreter.h
150

Giving it a default argument caused ambiguity in some cases (mainly when generating the bindings) that's why I left it like this.

mib updated this revision to Diff 286660.Aug 19 2020, 2:01 PM
mib marked an inline comment as done.
mib retitled this revision from [lldb/interpreter] Add REPL-specific init file. to [lldb/interpreter] Add REPL-specific init file.
mib edited the summary of this revision. (Show Details)

Addressed @JDevlieghere comments.

mib marked 2 inline comments as done.Aug 19 2020, 2:02 PM
JDevlieghere added inline comments.Aug 19 2020, 2:28 PM
lldb/source/Interpreter/CommandInterpreter.cpp
2183–2186

This is wrong, you check the REPL file first, fi that works you use that, otherwise you fall back to the app specific one, and finally to the global one.

mib added inline comments.Aug 19 2020, 2:51 PM
lldb/source/Interpreter/CommandInterpreter.cpp
2183–2186

Yes, but the application init file overrides the REPL init file that also override the global one, that's why I put it this way in the comment.

mib updated this revision to Diff 286673.EditedAug 19 2020, 3:23 PM

Updated man page to reflect current implementation.

mib updated this revision to Diff 286674.Aug 19 2020, 3:25 PM
JDevlieghere accepted this revision.Aug 19 2020, 3:28 PM
JDevlieghere added inline comments.
lldb/docs/man/lldb.rst
314

:program:lldb

323

Spurious newline

lldb/source/Interpreter/CommandInterpreter.cpp
2183–2186

Cool, now the docs and the comment are in sync. That code is really confusing though but I think I was the last to touch it so that's my bad :-)

This revision is now accepted and ready to land.Aug 19 2020, 3:28 PM
mib marked 5 inline comments as done.Aug 19 2020, 3:36 PM
This revision was landed with ongoing or failed builds.Aug 19 2020, 3:37 PM
This revision was automatically updated to reflect the committed changes.