Index: include/lldb/API/SBTarget.h =================================================================== --- include/lldb/API/SBTarget.h +++ include/lldb/API/SBTarget.h @@ -903,6 +903,7 @@ friend class SBSourceManager; friend class SBSymbol; friend class SBValue; + friend class SBVariablesOptions; //------------------------------------------------------------------ // Constructors are private, use static Target::Create function to create an Index: include/lldb/API/SBVariablesOptions.h =================================================================== --- include/lldb/API/SBVariablesOptions.h +++ include/lldb/API/SBVariablesOptions.h @@ -33,7 +33,7 @@ void SetIncludeArguments(bool); - bool GetIncludeRecognizedArguments() const; + bool GetIncludeRecognizedArguments(const lldb::SBTarget &) const; void SetIncludeRecognizedArguments(bool); Index: include/lldb/Target/Target.h =================================================================== --- include/lldb/Target/Target.h +++ include/lldb/Target/Target.h @@ -188,6 +188,10 @@ void SetDisplayRuntimeSupportValues(bool b); + bool GetDisplayRecognizedArguments() const; + + void SetDisplayRecognizedArguments(bool b); + const ProcessLaunchInfo &GetProcessLaunchInfo(); void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info); Index: packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py =================================================================== --- packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py +++ packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py @@ -67,9 +67,24 @@ self.expect("frame variable", substrs=['(int) a = 42', '(int) b = 56']) - opts = lldb.SBVariablesOptions(); - opts.SetIncludeRecognizedArguments(True); - variables = frame.GetVariables(opts); + # Recognized arguments don't show up by default... + variables = frame.GetVariables(lldb.SBVariablesOptions()) + self.assertEqual(variables.GetSize(), 0) + + # ...unless you set target.display-recognized-arguments to 1... + self.runCmd("settings set target.display-recognized-arguments 1") + variables = frame.GetVariables(lldb.SBVariablesOptions()) + self.assertEqual(variables.GetSize(), 2) + + # ...and you can reset it back to 0 to hide them again... + self.runCmd("settings set target.display-recognized-arguments 0") + variables = frame.GetVariables(lldb.SBVariablesOptions()) + self.assertEqual(variables.GetSize(), 0) + + # ... or explicitly ask for them with SetIncludeRecognizedArguments(True). + opts = lldb.SBVariablesOptions() + opts.SetIncludeRecognizedArguments(True) + variables = frame.GetVariables(opts) self.assertEqual(variables.GetSize(), 2) self.assertEqual(variables.GetValueAtIndex(0).name, "a") Index: scripts/interface/SBVariablesOptions.i =================================================================== --- scripts/interface/SBVariablesOptions.i +++ scripts/interface/SBVariablesOptions.i @@ -28,7 +28,7 @@ SetIncludeArguments (bool); bool - GetIncludeRecognizedArguments () const; + GetIncludeRecognizedArguments (const lldb::SBTarget &) const; void SetIncludeRecognizedArguments (bool); Index: source/API/SBFrame.cpp =================================================================== --- source/API/SBFrame.cpp +++ source/API/SBFrame.cpp @@ -957,7 +957,8 @@ const bool statics = options.GetIncludeStatics(); const bool arguments = options.GetIncludeArguments(); - const bool recognized_arguments = options.GetIncludeRecognizedArguments(); + const bool recognized_arguments = + options.GetIncludeRecognizedArguments(SBTarget(exe_ctx.GetTargetSP())); const bool locals = options.GetIncludeLocals(); const bool in_scope_only = options.GetInScopeOnly(); const bool include_runtime_support_values = Index: source/API/SBVariablesOptions.cpp =================================================================== --- source/API/SBVariablesOptions.cpp +++ source/API/SBVariablesOptions.cpp @@ -9,6 +9,10 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBVariablesOptions.h" +#include "lldb/API/SBTarget.h" +#include "lldb/Target/Target.h" + +#include "lldb/lldb-private.h" using namespace lldb; using namespace lldb_private; @@ -16,9 +20,10 @@ class VariablesOptionsImpl { public: VariablesOptionsImpl() - : m_include_arguments(false), m_include_recognized_arguments(false), - m_include_locals(false), m_include_statics(false), - m_in_scope_only(false), m_include_runtime_support_values(false), + : m_include_arguments(false), m_include_locals(false), + m_include_statics(false), m_in_scope_only(false), + m_include_runtime_support_values(false), + m_include_recognized_arguments(eLazyBoolCalculate), m_use_dynamic(lldb::eNoDynamicValues) {} VariablesOptionsImpl(const VariablesOptionsImpl &) = default; @@ -31,12 +36,14 @@ void SetIncludeArguments(bool b) { m_include_arguments = b; } - bool GetIncludeRecognizedArguments() const { - return m_include_recognized_arguments; + bool GetIncludeRecognizedArguments(const lldb::TargetSP &target_sp) const { + if (m_include_recognized_arguments != eLazyBoolCalculate) + return m_include_recognized_arguments; + return target_sp ? target_sp->GetDisplayRecognizedArguments() : false; } void SetIncludeRecognizedArguments(bool b) { - m_include_recognized_arguments = b; + m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo; } bool GetIncludeLocals() const { return m_include_locals; } @@ -65,11 +72,11 @@ private: bool m_include_arguments : 1; - bool m_include_recognized_arguments : 1; bool m_include_locals : 1; bool m_include_statics : 1; bool m_in_scope_only : 1; bool m_include_runtime_support_values : 1; + LazyBool m_include_recognized_arguments; // can be overridden with a setting lldb::DynamicValueType m_use_dynamic; }; @@ -99,8 +106,9 @@ m_opaque_ap->SetIncludeArguments(arguments); } -bool SBVariablesOptions::GetIncludeRecognizedArguments() const { - return m_opaque_ap->GetIncludeRecognizedArguments(); +bool SBVariablesOptions::GetIncludeRecognizedArguments( + const lldb::SBTarget &target) const { + return m_opaque_ap->GetIncludeRecognizedArguments(target.GetSP()); } void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) { Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -3356,6 +3356,8 @@ {"display-runtime-support-values", OptionValue::eTypeBoolean, false, false, nullptr, {}, "If true, LLDB will show variables that are meant to " "support the operation of a language's runtime support."}, + {"display-recognized-arguments", OptionValue::eTypeBoolean, false, false, + nullptr, {}, "Show recognized arguments in variable listings by default."}, {"non-stop-mode", OptionValue::eTypeBoolean, false, 0, nullptr, {}, "Disable lock-step debugging, instead control threads independently."}, {"require-hardware-breakpoint", OptionValue::eTypeBoolean, false, 0, @@ -3404,6 +3406,7 @@ ePropertyDisplayExpressionsInCrashlogs, ePropertyTrapHandlerNames, ePropertyDisplayRuntimeSupportValues, + ePropertyDisplayRecognizedArguments, ePropertyNonStopModeEnabled, ePropertyRequireHardwareBreakpoints, ePropertyExperimental, @@ -3963,6 +3966,16 @@ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); } +bool TargetProperties::GetDisplayRecognizedArguments() const { + const uint32_t idx = ePropertyDisplayRecognizedArguments; + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false); +} + +void TargetProperties::SetDisplayRecognizedArguments(bool b) { + const uint32_t idx = ePropertyDisplayRecognizedArguments; + m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); +} + bool TargetProperties::GetNonStopModeEnabled() const { const uint32_t idx = ePropertyNonStopModeEnabled; return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);