aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/API/SBCommandInterpreter.cpp
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2020-08-19 22:04:35 +0200
committerMed Ismail Bennani <medismail.bennani@gmail.com>2020-08-20 00:36:32 +0200
commit868b45b5b31d1203cab09ae0306f4c47e6070f68 (patch)
tree1b88ba2908e420de8fe11a187da6b5250b41af9d /lldb/source/API/SBCommandInterpreter.cpp
parent428bebaf10e177db5e42206ca8f871f0bcbef058 (diff)
downloadllvm-868b45b5b31d1203cab09ae0306f4c47e6070f68.zip
llvm-868b45b5b31d1203cab09ae0306f4c47e6070f68.tar.gz
llvm-868b45b5b31d1203cab09ae0306f4c47e6070f68.tar.bz2
[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>
Diffstat (limited to 'lldb/source/API/SBCommandInterpreter.cpp')
-rw-r--r--lldb/source/API/SBCommandInterpreter.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp
index f4f1957..31e7da8 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -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,
@@ -807,6 +825,9 @@ template <> void RegisterMethods<SBCommandInterpreter>(Registry &R) {
SourceInitFileInHomeDirectory,
(lldb::SBCommandReturnObject &));
LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
+ SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &, bool));
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
SourceInitFileInCurrentWorkingDirectory,
(lldb::SBCommandReturnObject &));
LLDB_REGISTER_METHOD(lldb::SBBroadcaster, SBCommandInterpreter,