mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 07:01:03 +08:00
[lldb/interpreter] Add REPL-specific init file
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 Differential Revision: https://reviews.llvm.org/D86242 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
@@ -478,6 +478,24 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory(
|
||||
}
|
||||
}
|
||||
|
||||
void SBCommandInterpreter::SourceInitFileInHomeDirectory(
|
||||
SBCommandReturnObject &result, bool is_repl) {
|
||||
LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
|
||||
(lldb::SBCommandReturnObject &, bool), result, is_repl);
|
||||
|
||||
result.Clear();
|
||||
if (IsValid()) {
|
||||
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
|
||||
std::unique_lock<std::recursive_mutex> lock;
|
||||
if (target_sp)
|
||||
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
|
||||
m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
|
||||
} else {
|
||||
result->AppendError("SBCommandInterpreter is not valid");
|
||||
result->SetStatus(eReturnStatusFailed);
|
||||
}
|
||||
}
|
||||
|
||||
void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
|
||||
SBCommandReturnObject &result) {
|
||||
LLDB_RECORD_METHOD(void, SBCommandInterpreter,
|
||||
@@ -806,6 +824,9 @@ template <> void RegisterMethods<SBCommandInterpreter>(Registry &R) {
|
||||
LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
|
||||
SourceInitFileInHomeDirectory,
|
||||
(lldb::SBCommandReturnObject &));
|
||||
LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
|
||||
SourceInitFileInHomeDirectory,
|
||||
(lldb::SBCommandReturnObject &, bool));
|
||||
LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
|
||||
SourceInitFileInCurrentWorkingDirectory,
|
||||
(lldb::SBCommandReturnObject &));
|
||||
|
||||
Reference in New Issue
Block a user