[Lldb-commits] [lldb] c964741 - [lldb/API] Add CommandInterpreter::{Get, Set}PrintErrors to SBAPI (NFC)
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 5 10:33:50 PST 2021
Author: Med Ismail Bennani
Date: 2021-03-05T19:33:33+01:00
New Revision: c964741996bcc3550c3598bb7237bd4551b03016
URL: https://github.com/llvm/llvm-project/commit/c964741996bcc3550c3598bb7237bd4551b03016
DIFF: https://github.com/llvm/llvm-project/commit/c964741996bcc3550c3598bb7237bd4551b03016.diff
LOG: [lldb/API] Add CommandInterpreter::{Get,Set}PrintErrors to SBAPI (NFC)
This patch exposes the getter and setter methods for the command
interpreter `print_errors` run option.
rdar://74816984
Differential Revision: https://reviews.llvm.org/D98001
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Added:
Modified:
lldb/bindings/interface/SBCommandInterpreterRunOptions.i
lldb/include/lldb/API/SBCommandInterpreterRunOptions.h
lldb/source/API/SBCommandInterpreterRunOptions.cpp
lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py
Removed:
################################################################################
diff --git a/lldb/bindings/interface/SBCommandInterpreterRunOptions.i b/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
index 1a618a228bbe..28437abb60c6 100644
--- a/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
+++ b/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
@@ -18,6 +18,7 @@ A default SBCommandInterpreterRunOptions object has:
* StopOnCrash: false
* EchoCommands: true
* PrintResults: true
+* PrintErrors: true
* AddToHistory: true
") SBCommandInterpreterRunOptions;
@@ -58,6 +59,12 @@ public:
void
SetPrintResults (bool);
+ bool
+ GetPrintErrors () const;
+
+ void
+ SetPrintErrors (bool);
+
bool
GetAddToHistory () const;
diff --git a/lldb/include/lldb/API/SBCommandInterpreterRunOptions.h b/lldb/include/lldb/API/SBCommandInterpreterRunOptions.h
index 3c00513faaa7..efaacd39eb0f 100644
--- a/lldb/include/lldb/API/SBCommandInterpreterRunOptions.h
+++ b/lldb/include/lldb/API/SBCommandInterpreterRunOptions.h
@@ -56,6 +56,10 @@ class LLDB_API SBCommandInterpreterRunOptions {
void SetPrintResults(bool);
+ bool GetPrintErrors() const;
+
+ void SetPrintErrors(bool);
+
bool GetAddToHistory() const;
void SetAddToHistory(bool);
diff --git a/lldb/source/API/SBCommandInterpreterRunOptions.cpp b/lldb/source/API/SBCommandInterpreterRunOptions.cpp
index da800e8b7804..317ec6d37127 100644
--- a/lldb/source/API/SBCommandInterpreterRunOptions.cpp
+++ b/lldb/source/API/SBCommandInterpreterRunOptions.cpp
@@ -131,6 +131,20 @@ void SBCommandInterpreterRunOptions::SetPrintResults(bool print_results) {
m_opaque_up->SetPrintResults(print_results);
}
+bool SBCommandInterpreterRunOptions::GetPrintErrors() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetPrintErrors);
+
+ return m_opaque_up->GetPrintErrors();
+}
+
+void SBCommandInterpreterRunOptions::SetPrintErrors(bool print_errors) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintErrors,
+ (bool), print_errors);
+
+ m_opaque_up->SetPrintErrors(print_errors);
+}
+
bool SBCommandInterpreterRunOptions::GetAddToHistory() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
GetAddToHistory);
@@ -269,6 +283,10 @@ template <> void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) {
GetPrintResults, ());
LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults,
(bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetPrintErrors, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintErrors,
+ (bool));
LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
GetAddToHistory, ());
LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory,
diff --git a/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py b/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py
index 86d7f7822772..2db7fdd66133 100644
--- a/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py
+++ b/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py
@@ -73,3 +73,40 @@ def test_run_session_with_error_and_quit(self):
self.assertGreater(n_errors, 0)
self.assertTrue(quit_requested)
self.assertFalse(has_crashed)
+
+class SBCommandInterpreterRunOptionsCase(TestBase):
+
+ NO_DEBUG_INFO_TESTCASE = True
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_command_interpreter_run_options(self):
+ """Test SBCommandInterpreterRunOptions default values, getters & setters """
+
+ opts = lldb.SBCommandInterpreterRunOptions()
+
+ # Check getters with default values
+ self.assertEqual(opts.GetStopOnContinue(), False)
+ self.assertEqual(opts.GetStopOnError(), False)
+ self.assertEqual(opts.GetStopOnCrash(), False)
+ self.assertEqual(opts.GetEchoCommands(), True)
+ self.assertEqual(opts.GetPrintResults(), True)
+ self.assertEqual(opts.GetPrintErrors(), True)
+ self.assertEqual(opts.GetAddToHistory(), True)
+
+ # Invert values
+ opts.SetStopOnContinue(not opts.GetStopOnContinue())
+ opts.SetStopOnError(not opts.GetStopOnError())
+ opts.SetStopOnCrash(not opts.GetStopOnCrash())
+ opts.SetEchoCommands(not opts.GetEchoCommands())
+ opts.SetPrintResults(not opts.GetPrintResults())
+ opts.SetPrintErrors(not opts.GetPrintErrors())
+ opts.SetAddToHistory(not opts.GetAddToHistory())
+
+ # Check the value changed
+ self.assertEqual(opts.GetStopOnContinue(), True)
+ self.assertEqual(opts.GetStopOnError(), True)
+ self.assertEqual(opts.GetStopOnCrash(), True)
+ self.assertEqual(opts.GetEchoCommands(), False)
+ self.assertEqual(opts.GetPrintResults(), False)
+ self.assertEqual(opts.GetPrintErrors(), False)
+ self.assertEqual(opts.GetAddToHistory(), False)
More information about the lldb-commits
mailing list