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

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

llvm-svn: 349856
This commit is contained in:
Kuba Mracek 2018-12-20 23:38:19 +00:00
parent 3790029d97
commit 4c7f5d5c5a
8 changed files with 57 additions and 15 deletions

View File

@ -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

View File

@ -33,7 +33,7 @@ public:
void SetIncludeArguments(bool);
bool GetIncludeRecognizedArguments() const;
bool GetIncludeRecognizedArguments(const lldb::SBTarget &) const;
void SetIncludeRecognizedArguments(bool);

View File

@ -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);

View File

@ -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")

View File

@ -28,7 +28,7 @@ public:
SetIncludeArguments (bool);
bool
GetIncludeRecognizedArguments () const;
GetIncludeRecognizedArguments (const lldb::SBTarget &) const;
void
SetIncludeRecognizedArguments (bool);

View File

@ -957,7 +957,8 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) {
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 =

View File

@ -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::SetIncludeArguments(bool arguments) {
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) {

View File

@ -3356,6 +3356,8 @@ static constexpr PropertyDefinition g_properties[] = {
{"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::SetDisplayRuntimeSupportValues(bool b) {
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);