[Lldb-commits] [lldb] 7f3fc2e - [lldb/API] Add a way to check if the CommandInterpreter is interactive

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 16 11:45:14 PST 2022


Author: Med Ismail Bennani
Date: 2022-02-16T11:44:07-08:00
New Revision: 7f3fc2eee8ff13f6922a16331870fc57cd022773

URL: https://github.com/llvm/llvm-project/commit/7f3fc2eee8ff13f6922a16331870fc57cd022773
DIFF: https://github.com/llvm/llvm-project/commit/7f3fc2eee8ff13f6922a16331870fc57cd022773.diff

LOG: [lldb/API] Add a way to check if the CommandInterpreter is interactive

This patch adds the ability for the user to check if the command
interpreter's IOHandler is interactive.

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

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

Added: 
    

Modified: 
    lldb/bindings/interface/SBCommandInterpreter.i
    lldb/include/lldb/API/SBCommandInterpreter.h
    lldb/include/lldb/Interpreter/CommandInterpreter.h
    lldb/source/API/SBCommandInterpreter.cpp
    lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/bindings/interface/SBCommandInterpreter.i b/lldb/bindings/interface/SBCommandInterpreter.i
index b9a32716cfd61..cad79248d0a2c 100644
--- a/lldb/bindings/interface/SBCommandInterpreter.i
+++ b/lldb/bindings/interface/SBCommandInterpreter.i
@@ -125,6 +125,9 @@ public:
     bool
     HasAliasOptions ();
 
+    bool
+    IsInteractive ();
+
     lldb::SBProcess
     GetProcess ();
 

diff  --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h
index 2364a8dae88c7..4ebcc797d5bb6 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -59,6 +59,8 @@ class SBCommandInterpreter {
 
   bool HasAliasOptions();
 
+  bool IsInteractive();
+
   lldb::SBProcess GetProcess();
 
   lldb::SBDebugger GetDebugger();

diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 85eefcc899724..af4117fcc4867 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -605,6 +605,8 @@ class CommandInterpreter : public Broadcaster,
 
   FileSpec GetCurrentSourceDir();
 
+  bool IsInteractive();
+
 protected:
   friend class Debugger;
 

diff  --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp
index c9a63bae0cb11..0a8c83f51f207 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -329,6 +329,12 @@ bool SBCommandInterpreter::HasAliasOptions() {
   return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false);
 }
 
+bool SBCommandInterpreter::IsInteractive() {
+  LLDB_INSTRUMENT_VA(this);
+
+  return (IsValid() ? m_opaque_ptr->IsInteractive() : false);
+}
+
 SBProcess SBCommandInterpreter::GetProcess() {
   LLDB_INSTRUMENT_VA(this);
 

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 087e8b4a3ccac..622f36e2a67ff 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3162,6 +3162,10 @@ bool CommandInterpreter::SaveTranscript(
   return true;
 }
 
+bool CommandInterpreter::IsInteractive() {
+  return (GetIOHandler() ? GetIOHandler()->GetIsInteractive() : false);
+}
+
 FileSpec CommandInterpreter::GetCurrentSourceDir() {
   if (m_command_source_dirs.empty())
     return {};


        


More information about the lldb-commits mailing list