[Lldb-commits] [lldb] r349856 - [lldb] Add a "display-recognized-arguments" target setting to show recognized arguments by default

Kuba Mracek via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 20 15:38:19 PST 2018


Author: kuba.brecka
Date: Thu Dec 20 15:38:19 2018
New Revision: 349856

URL: http://llvm.org/viewvc/llvm-project?rev=349856&view=rev
Log:
[lldb] Add a "display-recognized-arguments" target setting to show recognized arguments by default

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


Modified:
    lldb/trunk/include/lldb/API/SBTarget.h
    lldb/trunk/include/lldb/API/SBVariablesOptions.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
    lldb/trunk/scripts/interface/SBVariablesOptions.i
    lldb/trunk/source/API/SBFrame.cpp
    lldb/trunk/source/API/SBVariablesOptions.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=349856&r1=349855&r2=349856&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Thu Dec 20 15:38:19 2018
@@ -903,6 +903,7 @@ protected:
   friend class SBSourceManager;
   friend class SBSymbol;
   friend class SBValue;
+  friend class SBVariablesOptions;
 
   //------------------------------------------------------------------
   // Constructors are private, use static Target::Create function to create an

Modified: lldb/trunk/include/lldb/API/SBVariablesOptions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBVariablesOptions.h?rev=349856&r1=349855&r2=349856&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBVariablesOptions.h (original)
+++ lldb/trunk/include/lldb/API/SBVariablesOptions.h Thu Dec 20 15:38:19 2018
@@ -33,7 +33,7 @@ public:
 
   void SetIncludeArguments(bool);
 
-  bool GetIncludeRecognizedArguments() const;
+  bool GetIncludeRecognizedArguments(const lldb::SBTarget &) const;
 
   void SetIncludeRecognizedArguments(bool);
 

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=349856&r1=349855&r2=349856&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Thu Dec 20 15:38:19 2018
@@ -188,6 +188,10 @@ public:
 
   void SetDisplayRuntimeSupportValues(bool b);
 
+  bool GetDisplayRecognizedArguments() const;
+
+  void SetDisplayRecognizedArguments(bool b);
+
   const ProcessLaunchInfo &GetProcessLaunchInfo();
 
   void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info);

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py?rev=349856&r1=349855&r2=349856&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py Thu Dec 20 15:38:19 2018
@@ -67,9 +67,24 @@ class FrameRecognizerTestCase(TestBase):
         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")

Modified: lldb/trunk/scripts/interface/SBVariablesOptions.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBVariablesOptions.i?rev=349856&r1=349855&r2=349856&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBVariablesOptions.i (original)
+++ lldb/trunk/scripts/interface/SBVariablesOptions.i Thu Dec 20 15:38:19 2018
@@ -28,7 +28,7 @@ public:
     SetIncludeArguments (bool);
 
     bool
-    GetIncludeRecognizedArguments ()  const;
+    GetIncludeRecognizedArguments (const lldb::SBTarget &)  const;
 
     void
     SetIncludeRecognizedArguments (bool);

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=349856&r1=349855&r2=349856&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Thu Dec 20 15:38:19 2018
@@ -957,7 +957,8 @@ SBValueList SBFrame::GetVariables(const
 
   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 =

Modified: lldb/trunk/source/API/SBVariablesOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBVariablesOptions.cpp?rev=349856&r1=349855&r2=349856&view=diff
==============================================================================
--- lldb/trunk/source/API/SBVariablesOptions.cpp (original)
+++ lldb/trunk/source/API/SBVariablesOptions.cpp Thu Dec 20 15:38:19 2018
@@ -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 @@ using namespace lldb_private;
 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 @@ public:
 
   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 @@ public:
 
 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;
 };
 
@@ -97,8 +104,9 @@ void SBVariablesOptions::SetIncludeArgum
   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) {

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=349856&r1=349855&r2=349856&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Dec 20 15:38:19 2018
@@ -3356,6 +3356,8 @@ static constexpr PropertyDefinition g_pr
     {"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 @@ enum {
   ePropertyDisplayExpressionsInCrashlogs,
   ePropertyTrapHandlerNames,
   ePropertyDisplayRuntimeSupportValues,
+  ePropertyDisplayRecognizedArguments,
   ePropertyNonStopModeEnabled,
   ePropertyRequireHardwareBreakpoints,
   ePropertyExperimental,
@@ -3963,6 +3966,16 @@ void TargetProperties::SetDisplayRuntime
   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);




More information about the lldb-commits mailing list