From 2837b766f594f6aa0ec17c96bc8d257e2569d65e Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Wed, 4 May 2011 03:43:18 +0000 Subject: [PATCH] Change "frame var" over to using OptionGroups (and thus the OptionGroupVariableObjectDisplay). Change the boolean "use_dynamic" over to a tri-state, no-dynamic, dynamic-w/o running target, and dynamic with running target. llvm-svn: 130832 --- lldb/include/lldb/API/SBFrame.h | 8 +- lldb/include/lldb/API/SBValue.h | 4 +- lldb/include/lldb/Core/ValueObject.h | 6 +- .../lldb/Core/ValueObjectConstResult.h | 11 +- .../lldb/Core/ValueObjectDynamicValue.h | 3 +- .../OptionGroupValueObjectDisplay.h | 1 + lldb/include/lldb/Target/LanguageRuntime.h | 5 +- lldb/include/lldb/Target/StackFrame.h | 13 +- lldb/include/lldb/Target/Target.h | 10 +- lldb/include/lldb/lldb-enumerations.h | 8 +- lldb/source/API/SBFrame.cpp | 18 +- lldb/source/API/SBValue.cpp | 16 +- .../Commands/CommandObjectExpression.cpp | 15 +- lldb/source/Commands/CommandObjectFrame.cpp | 283 +++++++----------- lldb/source/Commands/CommandObjectMemory.cpp | 3 +- lldb/source/Core/ValueObject.cpp | 24 +- lldb/source/Core/ValueObjectDynamicValue.cpp | 19 +- .../OptionGroupValueObjectDisplay.cpp | 27 +- .../ItaniumABI/ItaniumABILanguageRuntime.cpp | 5 +- .../ItaniumABI/ItaniumABILanguageRuntime.h | 5 +- .../AppleObjCRuntime/AppleObjCRuntime.cpp | 11 +- .../ObjC/AppleObjCRuntime/AppleObjCRuntime.h | 5 +- .../AppleObjCRuntime/AppleObjCRuntimeV1.cpp | 5 +- .../AppleObjCRuntime/AppleObjCRuntimeV1.h | 5 +- .../AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 7 +- .../AppleObjCRuntime/AppleObjCRuntimeV2.h | 5 +- .../AppleObjCTrampolineHandler.cpp | 3 +- lldb/source/Target/StackFrame.cpp | 30 +- lldb/source/Target/Target.cpp | 47 +-- lldb/test/array_types/TestArrayTypes.py | 8 +- lldb/test/bitfields/TestBitfields.py | 4 +- .../TestBreakpointCommand.py | 4 +- .../TestBreakpointConditions.py | 8 +- lldb/test/class_types/TestClassTypes.py | 6 +- .../cpp/dynamic-value/TestDynamicValue.py | 31 +- lldb/test/forward/TestForwardDeclaration.py | 2 +- lldb/test/foundation/TestObjCMethods.py | 8 +- lldb/test/function_types/TestFunctionTypes.py | 2 +- .../global_variables/TestGlobalVariables.py | 2 +- .../TestObjCDynamicValue.py | 14 +- lldb/test/set_values/TestSetValues.py | 30 +- lldb/test/signed_types/TestSignedTypes.py | 2 +- lldb/test/types/AbstractBase.py | 14 +- lldb/test/unique-types/TestUniqueTypes.py | 8 +- lldb/test/unsigned_types/TestUnsignedTypes.py | 2 +- 45 files changed, 393 insertions(+), 354 deletions(-) diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h index d3222e4c3250..90199b6e847e 100644 --- a/lldb/include/lldb/API/SBFrame.h +++ b/lldb/include/lldb/API/SBFrame.h @@ -76,7 +76,7 @@ public: EvaluateExpression (const char *expr); lldb::SBValue - EvaluateExpression (const char *expr, bool fetch_dynamic_value); + EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic); // Gets the lexical block that defines the stack frame. Another way to think // of this is it will return the block that contains all of the variables @@ -126,7 +126,7 @@ public: bool locals, bool statics, bool in_scope_only, - bool use_dynamic); + lldb::DynamicValueType use_dynamic); lldb::SBValueList GetRegisters (); @@ -136,7 +136,7 @@ public: FindVariable (const char *var_name); lldb::SBValue - FindVariable (const char *var_name, bool use_dynamic); + FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic); // Find variables, register sets, registers, or persistent variables using // the frame as the scope @@ -144,7 +144,7 @@ public: FindValue (const char *name, ValueType value_type); lldb::SBValue - FindValue (const char *name, ValueType value_type, bool use_dynamic); + FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic); bool GetDescription (lldb::SBStream &description); diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index b8ac830f675f..5187c4726dca 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -100,7 +100,7 @@ public: GetChildAtIndex (uint32_t idx); lldb::SBValue - GetChildAtIndex (uint32_t idx, bool use_dynamic); + GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic); // Matches children of this object only and will match base classes and // member names if this is a clang typed object. @@ -115,7 +115,7 @@ public: // Matches child members of this object and child members of any base // classes. lldb::SBValue - GetChildMemberWithName (const char *name, bool use_dynamic); + GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic); uint32_t GetNumChildren (); diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 0346d92720a7..a40069d3d9b5 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -366,7 +366,7 @@ public: GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create); lldb::ValueObjectSP - GetDynamicValue (bool can_create); + GetDynamicValue (lldb::DynamicValueType valueType); virtual lldb::ValueObjectSP CreateConstantValue (const ConstString &name); @@ -403,7 +403,7 @@ public: bool show_types, bool show_location, bool use_objc, - bool use_dynamic, + lldb::DynamicValueType use_dynamic, bool scope_already_checked, bool flat_output); @@ -533,7 +533,7 @@ protected: UpdateValue () = 0; virtual void - CalculateDynamicValue (); + CalculateDynamicValue (lldb::DynamicValueType use_dynamic); // Should only be called by ValueObject::GetChildAtIndex() // Returns a ValueObject managed by this ValueObject's manager. diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index 559005981f14..e82f28c71363 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -96,12 +96,13 @@ protected: virtual bool UpdateValue (); + // CalculateDynamicValue doesn't change the dynamic value, since this can get + // called at any time and you can't reliably fetch the dynamic value at any time. + // If we want to have dynamic values for ConstResults, then we'll need to make them + // up when we make the const result & stuff them in by hand. virtual void - CalculateDynamicValue () {} // CalculateDynamicValue doesn't change the dynamic value, since this can get - // called at any time and you can't reliably fetch the dynamic value at any time. - // If we want to have dynamic values for ConstResults, then we'll need to make them - // up when we make the const result & stuff them in by hand. - + CalculateDynamicValue (lldb::DynamicValueType use_dynamic) {} + clang::ASTContext *m_clang_ast; // The clang AST that the clang type comes from ConstString m_type_name; uint32_t m_byte_size; diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index 3e702fc6b06a..85c604df91d9 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -90,10 +90,11 @@ protected: Address m_address; ///< The variable that this value object is based upon lldb::TypeSP m_type_sp; lldb::ValueObjectSP m_owning_valobj_sp; + lldb::DynamicValueType m_use_dynamic; private: friend class ValueObject; - ValueObjectDynamicValue (ValueObject &parent); + ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic); //------------------------------------------------------------------ // For ValueObject only diff --git a/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h index b2230aa17697..e36d0080b70e 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h +++ b/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h @@ -53,6 +53,7 @@ public: bool use_objc; uint32_t max_depth; uint32_t ptr_depth; + lldb::DynamicValueType use_dynamic; }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h index 3be0409f4989..e6c4fe3a0bd0 100644 --- a/lldb/include/lldb/Target/LanguageRuntime.h +++ b/lldb/include/lldb/Target/LanguageRuntime.h @@ -43,7 +43,10 @@ public: GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) = 0; virtual bool - GetDynamicTypeAndAddress (ValueObject &in_value, TypeAndOrName &class_type_or_name, Address &address) = 0; + GetDynamicTypeAndAddress (ValueObject &in_value, + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &address) = 0; // This should be a fast test to determine whether it is likely that this value would // have a dynamic type. diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h index b1df63073ae6..c93ec5b47859 100644 --- a/lldb/include/lldb/Target/StackFrame.h +++ b/lldb/include/lldb/Target/StackFrame.h @@ -33,8 +33,7 @@ public: enum ExpressionPathOption { eExpressionPathOptionCheckPtrVsMember = (1u << 0), - eExpressionPathOptionsNoFragileObjcIvar = (1u << 1), - eExpressionPathOptionsDynamicValue = (1u << 2) + eExpressionPathOptionsNoFragileObjcIvar = (1u << 1) }; //------------------------------------------------------------------ // Constructors and Destructors @@ -104,7 +103,11 @@ public: // See ExpressionPathOption enumeration for "options" values lldb::ValueObjectSP - GetValueForVariableExpressionPath (const char *var_expr, uint32_t options, Error &error); + GetValueForVariableExpressionPath (const char *var_expr, + lldb::DynamicValueType use_dynamic, + uint32_t options, + lldb::VariableSP &var_sp, + Error &error); bool HasDebugInformation (); @@ -134,10 +137,10 @@ public: } lldb::ValueObjectSP - GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp, bool use_dynamic); + GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic); lldb::ValueObjectSP - TrackGlobalVariable (const lldb::VariableSP &variable_sp, bool use_dynamic); + TrackGlobalVariable (const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic); //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 7343384b65a0..5c57952b78c1 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -40,6 +40,7 @@ namespace lldb_private { class TargetInstanceSettings : public InstanceSettings { public: + static OptionEnumValueElement g_dynamic_value_types[]; TargetInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL); @@ -67,10 +68,10 @@ public: StringList &value, Error *err); - bool + lldb::DynamicValueType GetPreferDynamicValue() { - return m_prefer_dynamic_value; + return (lldb::DynamicValueType) g_dynamic_value_types[m_prefer_dynamic_value].value; } bool @@ -96,9 +97,10 @@ protected: OptionValueFileSpec m_expr_prefix_file; lldb::DataBufferSP m_expr_prefix_contents_sp; - OptionValueBoolean m_prefer_dynamic_value; + int m_prefer_dynamic_value; OptionValueBoolean m_skip_prologue; PathMappingList m_source_map; + }; @@ -483,7 +485,7 @@ public: StackFrame *frame, bool unwind_on_error, bool keep_in_memory, - bool fetch_dynamic_value, + lldb::DynamicValueType use_dynamic, lldb::ValueObjectSP &result_valobj_sp); ClangPersistentVariables & diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index f37b83293eb7..bdb0162e4531 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -316,7 +316,13 @@ namespace lldb { eLanguageTypePython = 0x0014 ///< Python. } LanguageType; - + typedef enum DynamicValueType + { + eNoDynamicValues = 0, + eDynamicCanRunTarget = 1, + eDynamicDontRunTarget = 2 + } DynamicValueType; + typedef enum AccessType { eAccessNone, diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 9a42ae0cdd90..0a5988e17953 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -343,12 +343,12 @@ SBFrame::Clear() SBValue SBFrame::FindVariable (const char *name) { - bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); return FindVariable (name, use_dynamic); } SBValue -SBFrame::FindVariable (const char *name, bool use_dynamic) +SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic) { VariableSP var_sp; SBValue sb_value; @@ -389,12 +389,12 @@ SBFrame::FindVariable (const char *name, bool use_dynamic) SBValue SBFrame::FindValue (const char *name, ValueType value_type) { - bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); return FindValue (name, value_type, use_dynamic); } SBValue -SBFrame::FindValue (const char *name, ValueType value_type, bool use_dynamic) +SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic) { SBValue sb_value; if (m_opaque_sp && name && name[0]) @@ -579,7 +579,7 @@ SBFrame::GetVariables (bool arguments, bool statics, bool in_scope_only) { - bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); return GetVariables (arguments, locals, statics, in_scope_only, use_dynamic); } @@ -588,7 +588,7 @@ SBFrame::GetVariables (bool arguments, bool locals, bool statics, bool in_scope_only, - bool use_dynamic) + lldb::DynamicValueType use_dynamic) { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -706,12 +706,12 @@ SBFrame::GetDescription (SBStream &description) SBValue SBFrame::EvaluateExpression (const char *expr) { - bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); return EvaluateExpression (expr, use_dynamic); } SBValue -SBFrame::EvaluateExpression (const char *expr, bool fetch_dynamic_value) +SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value) { Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); @@ -732,8 +732,8 @@ SBFrame::EvaluateExpression (const char *expr, bool fetch_dynamic_value) exe_results = m_opaque_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr, m_opaque_sp.get(), unwind_on_error, - fetch_dynamic_value, keep_in_memory, + fetch_dynamic_value, *expr_result); } diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index f499fae145f2..4ed2c7d1ffe6 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -339,12 +339,12 @@ SBValue::SetValueFromCString (const char *value_str) SBValue SBValue::GetChildAtIndex (uint32_t idx) { - bool use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue(); + lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue(); return GetChildAtIndex (idx, use_dynamic_value); } SBValue -SBValue::GetChildAtIndex (uint32_t idx, bool use_dynamic_value) +SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic) { lldb::ValueObjectSP child_sp; @@ -353,11 +353,11 @@ SBValue::GetChildAtIndex (uint32_t idx, bool use_dynamic_value) child_sp = m_opaque_sp->GetChildAtIndex (idx, true); } - if (use_dynamic_value) + if (use_dynamic != lldb::eNoDynamicValues) { if (child_sp) { - lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (true); + lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic); if (dynamic_sp) child_sp = dynamic_sp; } @@ -391,12 +391,12 @@ SBValue::GetIndexOfChildWithName (const char *name) SBValue SBValue::GetChildMemberWithName (const char *name) { - bool use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue(); + lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue(); return GetChildMemberWithName (name, use_dynamic_value); } SBValue -SBValue::GetChildMemberWithName (const char *name, bool use_dynamic_value) +SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic_value) { lldb::ValueObjectSP child_sp; const ConstString str_name (name); @@ -406,11 +406,11 @@ SBValue::GetChildMemberWithName (const char *name, bool use_dynamic_value) child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true); } - if (use_dynamic_value) + if (use_dynamic_value != lldb::eNoDynamicValues) { if (child_sp) { - lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (true); + lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic_value); if (dynamic_sp) child_sp = dynamic_sp; } diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index fa578f499879..f8facfd1ba4d 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -260,27 +260,22 @@ CommandObjectExpression::EvaluateExpression ExecutionResults exe_results; bool keep_in_memory = true; - bool use_dynamic; + lldb::DynamicValueType use_dynamic; // If use dynamic is not set, get it from the target: switch (m_options.use_dynamic) { case eLazyBoolCalculate: - { - if (m_exe_ctx.target->GetPreferDynamicValue()) - use_dynamic = true; - else - use_dynamic = false; - } + use_dynamic = m_exe_ctx.target->GetPreferDynamicValue(); break; case eLazyBoolYes: - use_dynamic = true; + use_dynamic = lldb::eDynamicCanRunTarget; break; case eLazyBoolNo: - use_dynamic = false; + use_dynamic = lldb::eNoDynamicValues; break; } - exe_results = m_exe_ctx.target->EvaluateExpression(expr, m_exe_ctx.frame, m_options.unwind_on_error, use_dynamic, keep_in_memory, result_valobj_sp); + exe_results = m_exe_ctx.target->EvaluateExpression(expr, m_exe_ctx.frame, m_options.unwind_on_error, keep_in_memory, use_dynamic, result_valobj_sp); if (exe_results == eExecutionInterrupted && !m_options.unwind_on_error) { diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 652141653603..33e735ac81d1 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -25,6 +25,7 @@ #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" #include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" @@ -285,73 +286,46 @@ class CommandObjectFrameVariable : public CommandObject { public: - class CommandOptions : public Options + class OptionGroupFrameVariable : public OptionGroup { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + OptionGroupFrameVariable () { - OptionParsingStarting (); } virtual - ~CommandOptions () + ~OptionGroupFrameVariable () { } + virtual uint32_t + GetNumDefinitions (); + + virtual const OptionDefinition* + GetDefinitions () + { + return g_option_table; + } + virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) { Error error; - bool success; - char short_option = (char) m_getopt_table[option_idx].val; + char short_option = (char) g_option_table[option_idx].short_option; switch (short_option) { - case 'o': use_objc = true; break; - case 'd': - { - bool success; - bool result; - result = Args::StringToBoolean(option_arg, true, &success); - if (!success) - error.SetErrorStringWithFormat("Invalid dynamic value setting: \"%s\".\n", option_arg); - else - { - if (result) - use_dynamic = eLazyBoolYes; - else - use_dynamic = eLazyBoolNo; - } - } - break; case 'r': use_regex = true; break; case 'a': show_args = false; break; case 'l': show_locals = false; break; case 'g': show_globals = true; break; - case 't': show_types = true; break; - case 'y': show_summary = false; break; - case 'L': show_location= true; break; case 'c': show_decl = true; break; - case 'D': debug = true; break; case 'f': error = Args::StringToFormat(option_arg, format, NULL); break; - case 'F': flat_output = true; break; - case 'A': - max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); - if (!success) - error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg); - break; - - case 'p': - ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); - if (!success) - error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); - break; - case 'G': globals.push_back(ConstString (option_arg)); break; - case 's': show_scope = true; break; @@ -364,52 +338,29 @@ public: return error; } - void - OptionParsingStarting () + virtual void + OptionParsingStarting (CommandInterpreter &interpreter) { - use_objc = false; - use_regex = false; show_args = true; - show_locals = true; - show_globals = false; - show_types = false; - show_scope = false; - show_summary = true; - show_location = false; show_decl = false; - debug = false; - flat_output = false; - use_dynamic = eLazyBoolCalculate; - max_depth = UINT32_MAX; - ptr_depth = 0; format = eFormatDefault; + show_globals = false; + show_locals = true; + use_regex = false; + show_scope = false; globals.clear(); } - const OptionDefinition* - GetDefinitions () - { - return g_option_table; - } - // Options table: Required for subclasses of Options. static OptionDefinition g_option_table[]; - bool use_objc:1, - use_regex:1, + + bool use_regex:1, show_args:1, show_locals:1, show_globals:1, - show_types:1, show_scope:1, - show_summary:1, - show_location:1, - show_decl:1, - debug:1, - flat_output:1; - LazyBool use_dynamic; - uint32_t max_depth; // The depth to print when dumping concrete (not pointers) aggreate values - uint32_t ptr_depth; // The default depth that is dumped when we find pointers + show_decl:1; lldb::Format format; // The format to use when dumping variables or children of variables std::vector globals; // Instance variables to hold the values for command options. @@ -426,7 +377,9 @@ public: "'var->child.x'.", NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), - m_options (interpreter) + m_option_group (interpreter), + m_frame_var_options(), + m_varobj_options() { CommandArgumentEntry arg; CommandArgumentData var_name_arg; @@ -440,6 +393,10 @@ public: // Push the data for the first argument into the m_arguments vector. m_arguments.push_back (arg); + + m_option_group.Append (&m_frame_var_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); + m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); + m_option_group.Finalize(); } virtual @@ -451,7 +408,7 @@ public: Options * GetOptions () { - return &m_options; + return &m_option_group; } @@ -479,40 +436,19 @@ public: VariableSP var_sp; ValueObjectSP valobj_sp; - bool use_dynamic; - - // If use dynamic is not set, get it from the target: - switch (m_options.use_dynamic) - { - case eLazyBoolCalculate: - { - if (exe_ctx.target->GetPreferDynamicValue()) - use_dynamic = true; - else - use_dynamic = false; - } - break; - case eLazyBoolYes: - use_dynamic = true; - break; - case eLazyBoolNo: - use_dynamic = false; - break; - } - const char *name_cstr = NULL; size_t idx; - if (!m_options.globals.empty()) + if (!m_frame_var_options.globals.empty()) { uint32_t fail_count = 0; if (exe_ctx.target) { - const size_t num_globals = m_options.globals.size(); + const size_t num_globals = m_frame_var_options.globals.size(); for (idx = 0; idx < num_globals; ++idx) { VariableList global_var_list; const uint32_t num_matching_globals - = exe_ctx.target->GetImages().FindGlobalVariables (m_options.globals[idx], + = exe_ctx.target->GetImages().FindGlobalVariables (m_frame_var_options.globals[idx], true, UINT32_MAX, global_var_list); @@ -521,7 +457,7 @@ public: { ++fail_count; result.GetErrorStream().Printf ("error: can't find global variable '%s'\n", - m_options.globals[idx].AsCString()); + m_frame_var_options.globals[idx].AsCString()); } else { @@ -530,16 +466,18 @@ public: var_sp = global_var_list.GetVariableAtIndex(global_idx); if (var_sp) { - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, use_dynamic); + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, + m_varobj_options.use_dynamic); if (!valobj_sp) - valobj_sp = exe_ctx.frame->TrackGlobalVariable (var_sp, use_dynamic); + valobj_sp = exe_ctx.frame->TrackGlobalVariable (var_sp, + m_varobj_options.use_dynamic); if (valobj_sp) { - if (m_options.format != eFormatDefault) - valobj_sp->SetFormat (m_options.format); + if (m_frame_var_options.format != eFormatDefault) + valobj_sp->SetFormat (m_frame_var_options.format); - if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + if (m_frame_var_options.show_decl && var_sp->GetDeclaration ().GetFile()) { var_sp->GetDeclaration ().DumpStopContext (&s, false); s.PutCString (": "); @@ -548,15 +486,15 @@ public: ValueObject::DumpValueObject (result.GetOutputStream(), valobj_sp.get(), name_cstr, - m_options.ptr_depth, + m_varobj_options.ptr_depth, 0, - m_options.max_depth, - m_options.show_types, - m_options.show_location, - m_options.use_objc, - use_dynamic, + m_varobj_options.max_depth, + m_varobj_options.show_types, + m_varobj_options.show_location, + m_varobj_options.use_objc, + m_varobj_options.use_dynamic, false, - m_options.flat_output); + m_varobj_options.flat_output); } } } @@ -576,9 +514,9 @@ public: // variable objects from them... for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != NULL; ++idx) { - uint32_t ptr_depth = m_options.ptr_depth; + uint32_t ptr_depth = m_varobj_options.ptr_depth; - if (m_options.use_regex) + if (m_frame_var_options.use_regex) { const uint32_t regex_start_index = regex_var_list.GetSize(); RegularExpression regex (name_cstr); @@ -597,13 +535,13 @@ public: var_sp = regex_var_list.GetVariableAtIndex (regex_idx); if (var_sp) { - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, use_dynamic); + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); if (valobj_sp) { - if (m_options.format != eFormatDefault) - valobj_sp->SetFormat (m_options.format); + if (m_frame_var_options.format != eFormatDefault) + valobj_sp->SetFormat (m_frame_var_options.format); - if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + if (m_frame_var_options.show_decl && var_sp->GetDeclaration ().GetFile()) { var_sp->GetDeclaration ().DumpStopContext (&s, false); s.PutCString (": "); @@ -612,15 +550,15 @@ public: ValueObject::DumpValueObject (result.GetOutputStream(), valobj_sp.get(), var_sp->GetName().AsCString(), - m_options.ptr_depth, + m_varobj_options.ptr_depth, 0, - m_options.max_depth, - m_options.show_types, - m_options.show_location, - m_options.use_objc, - use_dynamic, + m_varobj_options.max_depth, + m_varobj_options.show_types, + m_varobj_options.show_location, + m_varobj_options.use_objc, + m_varobj_options.use_dynamic, false, - m_options.flat_output); + m_varobj_options.flat_output); } } } @@ -643,16 +581,17 @@ public: { Error error; uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember; - if (use_dynamic) - expr_path_options |= StackFrame::eExpressionPathOptionsDynamicValue; - - valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, expr_path_options, error); + lldb::VariableSP var_sp; + valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, + m_varobj_options.use_dynamic, + expr_path_options, + var_sp, + error); if (valobj_sp) { - if (m_options.format != eFormatDefault) - valobj_sp->SetFormat (m_options.format); - - if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + if (m_frame_var_options.format != eFormatDefault) + valobj_sp->SetFormat (m_frame_var_options.format); + if (m_frame_var_options.show_decl && var_sp && var_sp->GetDeclaration ().GetFile()) { var_sp->GetDeclaration ().DumpStopContext (&s, false); s.PutCString (": "); @@ -662,13 +601,13 @@ public: valobj_sp->GetParent() ? name_cstr : NULL, ptr_depth, 0, - m_options.max_depth, - m_options.show_types, - m_options.show_location, - m_options.use_objc, - use_dynamic, + m_varobj_options.max_depth, + m_varobj_options.show_types, + m_varobj_options.show_location, + m_varobj_options.use_objc, + m_varobj_options.use_dynamic, false, - m_options.flat_output); + m_varobj_options.flat_output); } else { @@ -696,26 +635,26 @@ public: switch (var_sp->GetScope()) { case eValueTypeVariableGlobal: - dump_variable = m_options.show_globals; - if (dump_variable && m_options.show_scope) + dump_variable = m_frame_var_options.show_globals; + if (dump_variable && m_frame_var_options.show_scope) s.PutCString("GLOBAL: "); break; case eValueTypeVariableStatic: - dump_variable = m_options.show_globals; - if (dump_variable && m_options.show_scope) + dump_variable = m_frame_var_options.show_globals; + if (dump_variable && m_frame_var_options.show_scope) s.PutCString("STATIC: "); break; case eValueTypeVariableArgument: - dump_variable = m_options.show_args; - if (dump_variable && m_options.show_scope) + dump_variable = m_frame_var_options.show_args; + if (dump_variable && m_frame_var_options.show_scope) s.PutCString(" ARG: "); break; case eValueTypeVariableLocal: - dump_variable = m_options.show_locals; - if (dump_variable && m_options.show_scope) + dump_variable = m_frame_var_options.show_locals; + if (dump_variable && m_frame_var_options.show_scope) s.PutCString(" LOCAL: "); break; @@ -729,17 +668,18 @@ public: // Use the variable object code to make sure we are // using the same APIs as the the public API will be // using... - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, use_dynamic); + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, + m_varobj_options.use_dynamic); if (valobj_sp) { - if (m_options.format != eFormatDefault) - valobj_sp->SetFormat (m_options.format); + if (m_frame_var_options.format != eFormatDefault) + valobj_sp->SetFormat (m_frame_var_options.format); // When dumping all variables, don't print any variables // that are not in scope to avoid extra unneeded output if (valobj_sp->IsInScope ()) { - if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + if (m_frame_var_options.show_decl && var_sp->GetDeclaration ().GetFile()) { var_sp->GetDeclaration ().DumpStopContext (&s, false); s.PutCString (": "); @@ -747,15 +687,15 @@ public: ValueObject::DumpValueObject (result.GetOutputStream(), valobj_sp.get(), name_cstr, - m_options.ptr_depth, + m_varobj_options.ptr_depth, 0, - m_options.max_depth, - m_options.show_types, - m_options.show_location, - m_options.use_objc, - use_dynamic, + m_varobj_options.max_depth, + m_varobj_options.show_types, + m_varobj_options.show_location, + m_varobj_options.use_objc, + m_varobj_options.use_dynamic, false, - m_options.flat_output); + m_varobj_options.flat_output); } } } @@ -769,31 +709,32 @@ public: } protected: - CommandOptions m_options; + OptionGroupOptions m_option_group; + OptionGroupFrameVariable m_frame_var_options; + OptionGroupValueObjectDisplay m_varobj_options; }; OptionDefinition -CommandObjectFrameVariable::CommandOptions::g_option_table[] = +CommandObjectFrameVariable::OptionGroupFrameVariable::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "aggregate-depth", 'A', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, { LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."}, { LLDB_OPT_SET_1, false, "show-declaration",'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."}, -{ LLDB_OPT_SET_1, false, "debug", 'D', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug information."}, -{ LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, NULL, 0, eArgTypeBoolean, "Show the object as its full dynamic type, not its static type, if available."}, { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the variable output should use."}, -{ LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."}, { LLDB_OPT_SET_1, false, "show-globals", 'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."}, { LLDB_OPT_SET_1, false, "find-global", 'G', required_argument, NULL, 0, eArgTypeVarName, "Find a global variable by name (which might not be in the current stack frame source file)."}, -{ LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, { LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."}, -{ LLDB_OPT_SET_1, false, "objc", 'o', no_argument, NULL, 0, eArgTypeNone, "When looking up a variable by name, print as an Objective-C object."}, -{ LLDB_OPT_SET_1, false, "ptr-depth", 'p', required_argument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."}, { LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The argument for name lookups are regular expressions."}, { LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."}, -{ LLDB_OPT_SET_1, false, "show-types", 't', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, -{ LLDB_OPT_SET_1, false, "no-summary", 'y', no_argument, NULL, 0, eArgTypeNone, "Omit summary information."}, { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; + +uint32_t +CommandObjectFrameVariable::OptionGroupFrameVariable::GetNumDefinitions () +{ + return sizeof(CommandObjectFrameVariable::OptionGroupFrameVariable::g_option_table)/sizeof(OptionDefinition); +} + + #pragma mark CommandObjectMultiwordFrame //------------------------------------------------------------------------- diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 85b939cfc364..91144e5d7b4a 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -643,7 +643,6 @@ public: if (format != eFormatDefault) valobj_sp->SetFormat (format); - bool use_dynamic = false; bool scope_already_checked = true; ValueObject::DumpValueObject (*output_stream, @@ -655,7 +654,7 @@ public: m_varobj_options.show_types, m_varobj_options.show_location, m_varobj_options.use_objc, - use_dynamic, + m_varobj_options.use_dynamic, scope_already_checked, m_varobj_options.flat_output); } diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 521d3eb58801..819e67a1e9c6 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -986,8 +986,11 @@ ValueObject::GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create) } void -ValueObject::CalculateDynamicValue () +ValueObject::CalculateDynamicValue (lldb::DynamicValueType use_dynamic) { + if (use_dynamic == lldb::eNoDynamicValues) + return; + if (!m_dynamic_value && !IsDynamic()) { Process *process = m_update_point.GetProcess(); @@ -1013,12 +1016,12 @@ ValueObject::CalculateDynamicValue () { LanguageRuntime *objc_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeObjC); if (objc_runtime) - worth_having_dynamic_value = cpp_runtime->CouldHaveDynamicValue(*this); + worth_having_dynamic_value = objc_runtime->CouldHaveDynamicValue(*this); } } if (worth_having_dynamic_value) - m_dynamic_value = new ValueObjectDynamicValue (*this); + m_dynamic_value = new ValueObjectDynamicValue (*this, use_dynamic); // if (worth_having_dynamic_value) // printf ("Adding dynamic value %s (%p) to (%p) - manager %p.\n", m_name.GetCString(), m_dynamic_value, this, m_manager); @@ -1027,11 +1030,14 @@ ValueObject::CalculateDynamicValue () } ValueObjectSP -ValueObject::GetDynamicValue (bool can_create) +ValueObject::GetDynamicValue (DynamicValueType use_dynamic) { - if (!IsDynamic() && m_dynamic_value == NULL && can_create) + if (use_dynamic == lldb::eNoDynamicValues) + return ValueObjectSP(); + + if (!IsDynamic() && m_dynamic_value == NULL) { - CalculateDynamicValue(); + CalculateDynamicValue(use_dynamic); } if (m_dynamic_value) return m_dynamic_value->GetSP(); @@ -1137,16 +1143,16 @@ ValueObject::DumpValueObject bool show_types, bool show_location, bool use_objc, - bool use_dynamic, + lldb::DynamicValueType use_dynamic, bool scope_already_checked, bool flat_output ) { if (valobj && valobj->UpdateValueIfNeeded ()) { - if (use_dynamic) + if (use_dynamic != lldb::eNoDynamicValues) { - ValueObject *dynamic_value = valobj->GetDynamicValue(true).get(); + ValueObject *dynamic_value = valobj->GetDynamicValue(use_dynamic).get(); if (dynamic_value) valobj = dynamic_value; } diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp index b43c6519baf1..ee50d45433f3 100644 --- a/lldb/source/Core/ValueObjectDynamicValue.cpp +++ b/lldb/source/Core/ValueObjectDynamicValue.cpp @@ -34,10 +34,11 @@ using namespace lldb_private; -ValueObjectDynamicValue::ValueObjectDynamicValue (ValueObject &parent) : +ValueObjectDynamicValue::ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic) : ValueObject(parent), m_address (), - m_type_sp() + m_type_sp(), + m_use_dynamic (use_dynamic) { SetName (parent.GetName().AsCString()); } @@ -122,6 +123,14 @@ ValueObjectDynamicValue::UpdateValue () return false; } + // Setting our type_sp to NULL will route everything back through our + // parent which is equivalent to not using dynamic values. + if (m_use_dynamic == lldb::eNoDynamicValues) + { + m_type_sp.reset(); + return true; + } + ExecutionContext exe_ctx (GetExecutionContextScope()); if (exe_ctx.target) @@ -144,19 +153,19 @@ ValueObjectDynamicValue::UpdateValue () { LanguageRuntime *runtime = process->GetLanguageRuntime (known_type); if (runtime) - found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, class_type_or_name, dynamic_address); + found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address); } else { LanguageRuntime *cpp_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeC_plus_plus); if (cpp_runtime) - found_dynamic_type = cpp_runtime->GetDynamicTypeAndAddress (*m_parent, class_type_or_name, dynamic_address); + found_dynamic_type = cpp_runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address); if (!found_dynamic_type) { LanguageRuntime *objc_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeObjC); if (objc_runtime) - found_dynamic_type = cpp_runtime->GetDynamicTypeAndAddress (*m_parent, class_type_or_name, dynamic_address); + found_dynamic_type = cpp_runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address); } } diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp index dac44b10f84e..3150ea77f89b 100644 --- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp +++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp @@ -13,6 +13,8 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/Target.h" +#include "lldb/Interpreter/CommandInterpreter.h" using namespace lldb; using namespace lldb_private; @@ -28,6 +30,8 @@ OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay () static OptionDefinition g_option_table[] = { + { LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, TargetInstanceSettings::g_dynamic_value_types, + 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."}, { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, { LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."}, { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, @@ -64,6 +68,17 @@ OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, switch (short_option) { + case 'd': + { + bool success; + int32_t result; + result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, &success); + if (!success) + error.SetErrorStringWithFormat("Invalid dynamic value setting: \"%s\".\n", option_arg); + else + use_dynamic = (lldb::DynamicValueType) result; + } + break; case 'T': show_types = true; break; case 'Y': show_summary = false; break; case 'L': show_location= true; break; @@ -99,5 +114,13 @@ OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interp use_objc = false; max_depth = UINT32_MAX; ptr_depth = 0; -} - + + Target *target = interpreter.GetExecutionContext().target; + if (target != NULL) + use_dynamic = target->GetPreferDynamicValue(); + else + { + // If we don't have any targets, then dynamic values won't do us much good. + use_dynamic = lldb::eNoDynamicValues; + } +} \ No newline at end of file diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index 20b608eb401d..76a549a1735f 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -41,7 +41,10 @@ ItaniumABILanguageRuntime::CouldHaveDynamicValue (ValueObject &in_value) } bool -ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value, TypeAndOrName &class_type_or_name, Address &dynamic_address) +ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value, + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &dynamic_address) { // For Itanium, if the type has a vtable pointer in the object, it will be at offset 0 // in the object. That will point to the "address point" within the vtable (not the beginning of the diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h index 966090d4aea8..d9d260087612 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h @@ -31,7 +31,10 @@ namespace lldb_private { IsVTableName (const char *name); virtual bool - GetDynamicTypeAndAddress (ValueObject &in_value, TypeAndOrName &class_type_or_name, Address &address); + GetDynamicTypeAndAddress (ValueObject &in_value, + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &address); virtual bool CouldHaveDynamicValue (ValueObject &in_value); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 62eac38e6e21..0d9d0bcf6a3e 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -194,11 +194,18 @@ AppleObjCRuntime::GetPrintForDebuggerAddr() bool AppleObjCRuntime::CouldHaveDynamicValue (ValueObject &in_value) { - return in_value.IsPointerType(); + lldb::LanguageType known_type = in_value.GetObjectRuntimeLanguage(); + if (known_type == lldb::eLanguageTypeObjC) + return true; + else + return in_value.IsPointerType(); } bool -AppleObjCRuntime::GetDynamicTypeAndAddress (ValueObject &in_value, TypeAndOrName &class_type_or_name, Address &address) +AppleObjCRuntime::GetDynamicTypeAndAddress (ValueObject &in_value, + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &address) { return false; } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h index f3eb074cedbb..eff3af139cb6 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h @@ -41,7 +41,10 @@ public: CouldHaveDynamicValue (ValueObject &in_value); virtual bool - GetDynamicTypeAndAddress (ValueObject &in_value, TypeAndOrName &class_type_or_name, Address &address); + GetDynamicTypeAndAddress (ValueObject &in_value, + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &address); // These are the ObjC specific functions. diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index fe29b628aaef..a30e8e3fd80a 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -41,7 +41,10 @@ static const char *pluginDesc = "Apple Objective C Language Runtime - Version 1" static const char *pluginShort = "language.apple.objc.v1"; bool -AppleObjCRuntimeV1::GetDynamicTypeAndAddress (ValueObject &in_value, TypeAndOrName &class_type_or_name, Address &address) +AppleObjCRuntimeV1::GetDynamicTypeAndAddress (ValueObject &in_value, + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &address) { return false; } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h index 7a43ca33c851..bbcc9c80804e 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h @@ -32,7 +32,10 @@ public: // These are generic runtime functions: virtual bool - GetDynamicTypeAndAddress (ValueObject &in_value, TypeAndOrName &class_type_or_name, Address &address); + GetDynamicTypeAndAddress (ValueObject &in_value, + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &address); virtual ClangUtilityFunction * CreateObjectChecker (const char *); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 42e7aee8c88a..4d315f5c1867 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -219,7 +219,10 @@ AppleObjCRuntimeV2::RunFunctionToFindClassName(lldb::addr_t object_addr, Thread } bool -AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value, TypeAndOrName &class_type_or_name, Address &address) +AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value, + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &address) { // The Runtime is attached to a particular process, you shouldn't pass in a value from another process. assert (in_value.GetUpdatePoint().GetProcess() == m_process); @@ -316,7 +319,7 @@ AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value, TypeAndOrNa } char class_buffer[1024]; - if (class_name == NULL) + if (class_name == NULL && use_dynamic != lldb::eDynamicDontRunTarget) { // If the class address didn't point into the binary, or // it points into the right section but there wasn't a symbol diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index 93395ff2ab56..0b45d7d6f187 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -32,7 +32,10 @@ public: // These are generic runtime functions: virtual bool - GetDynamicTypeAndAddress (ValueObject &in_value, TypeAndOrName &class_type_or_name, Address &address); + GetDynamicTypeAndAddress (ValueObject &in_value, + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &address); virtual ClangUtilityFunction * CreateObjectChecker (const char *); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index 77a8318afbd9..9de258e33818 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -807,7 +807,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool sto dispatch_values.PushValue (*(argument_values.GetValueAtIndex(sel_index))); Value flag_value; - lldb::clang_type_t clang_int_type = clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(lldb::eEncodingSint, 32); + lldb::clang_type_t clang_int_type + = clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(lldb::eEncodingSint, 32); flag_value.SetValueType (Value::eValueTypeScalar); flag_value.SetContext (Value::eContextTypeClangType, clang_int_type); diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 169497ad047f..cb4bbd47ceea 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -486,14 +486,17 @@ StackFrame::GetVariableList (bool get_file_globals) } ValueObjectSP -StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, uint32_t options, Error &error) +StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, + lldb::DynamicValueType use_dynamic, + uint32_t options, + lldb::VariableSP &var_sp, + Error &error) { if (var_expr_cstr && var_expr_cstr[0]) { const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0; const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0; - const bool dynamic_value = (options & eExpressionPathOptionsDynamicValue) != 0; error.Clear(); bool deref = false; bool address_of = false; @@ -526,10 +529,10 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, uint32 else name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); - VariableSP var_sp (variable_list->FindVariable(name_const_string)); + var_sp = variable_list->FindVariable(name_const_string); if (var_sp) { - valobj_sp = GetValueObjectForFrameVariable (var_sp, dynamic_value); + valobj_sp = GetValueObjectForFrameVariable (var_sp, use_dynamic); if (!valobj_sp) return valobj_sp; @@ -626,9 +629,9 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, uint32 } // Remove the child name from the path var_path.erase(0, child_name.GetLength()); - if (dynamic_value) + if (use_dynamic != lldb::eNoDynamicValues) { - ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(true)); + ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic)); if (dynamic_value_sp) child_valobj_sp = dynamic_value_sp; } @@ -688,9 +691,9 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, uint32 // %i is the array index var_path.erase(0, (end - var_path.c_str()) + 1); separator_idx = var_path.find_first_of(".-["); - if (dynamic_value) + if (use_dynamic != lldb::eNoDynamicValues) { - ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(true)); + ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic)); if (dynamic_value_sp) child_valobj_sp = dynamic_value_sp; } @@ -738,7 +741,8 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, uint32 } else { - error.SetErrorStringWithFormat("no variable named '%s' found in this frame", name_const_string.GetCString()); + error.SetErrorStringWithFormat("no variable named '%s' found in this frame", + name_const_string.GetCString()); } } } @@ -809,7 +813,7 @@ StackFrame::HasDebugInformation () ValueObjectSP -StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, bool use_dynamic) +StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, lldb::DynamicValueType use_dynamic) { ValueObjectSP valobj_sp; VariableList *var_list = GetVariableList (true); @@ -830,9 +834,9 @@ StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, bool } } } - if (use_dynamic && valobj_sp) + if (use_dynamic != lldb::eNoDynamicValues && valobj_sp) { - ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (true); + ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (use_dynamic); if (dynamic_sp) return dynamic_sp; } @@ -840,7 +844,7 @@ StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, bool } ValueObjectSP -StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, bool use_dynamic) +StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, lldb::DynamicValueType use_dynamic) { // Check to make sure we aren't already tracking this variable? ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp, use_dynamic)); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index a023bf5b7641..9f3a45e31c74 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -890,7 +890,7 @@ Target::EvaluateExpression StackFrame *frame, bool unwind_on_error, bool keep_in_memory, - bool fetch_dynamic_value, + lldb::DynamicValueType use_dynamic, lldb::ValueObjectSP &result_valobj_sp ) { @@ -905,7 +905,12 @@ Target::EvaluateExpression Error error; const uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember | StackFrame::eExpressionPathOptionsNoFragileObjcIvar; - result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr, expr_path_options, error); + lldb::VariableSP var_sp; + result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr, + use_dynamic, + expr_path_options, + var_sp, + error); } else if (m_process_sp) { @@ -932,9 +937,9 @@ Target::EvaluateExpression } else { - if (fetch_dynamic_value) + if (use_dynamic != lldb::eNoDynamicValues) { - ValueObjectSP dynamic_sp = result_valobj_sp->GetDynamicValue(true); + ValueObjectSP dynamic_sp = result_valobj_sp->GetDynamicValue(use_dynamic); if (dynamic_sp) result_valobj_sp = dynamic_sp; } @@ -1390,7 +1395,7 @@ TargetInstanceSettings::TargetInstanceSettings InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance), m_expr_prefix_file (), m_expr_prefix_contents_sp (), - m_prefer_dynamic_value (true, true), + m_prefer_dynamic_value (2), m_skip_prologue (true, true), m_source_map (NULL, NULL) { @@ -1486,7 +1491,10 @@ TargetInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_n } else if (var_name == GetSettingNameForPreferDynamicValue()) { - err = UserSettingsController::UpdateBooleanOptionValue (value, op, m_prefer_dynamic_value); + int new_value; + UserSettingsController::UpdateEnumVariable (g_dynamic_value_types, &new_value, value, err); + if (err.Success()) + m_prefer_dynamic_value = new_value; } else if (var_name == GetSettingNameForSkipPrologue()) { @@ -1579,10 +1587,7 @@ TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, } else if (var_name == GetSettingNameForPreferDynamicValue()) { - if (m_prefer_dynamic_value) - value.AppendString ("true"); - else - value.AppendString ("false"); + value.AppendString (g_dynamic_value_types[m_prefer_dynamic_value].string_value); } else if (var_name == GetSettingNameForSkipPrologue()) { @@ -1620,6 +1625,14 @@ TargetInstanceSettings::CreateInstanceName () //-------------------------------------------------- // Target::SettingsController Variable Tables //-------------------------------------------------- +OptionEnumValueElement +TargetInstanceSettings::g_dynamic_value_types[] = +{ +{ eNoDynamicValues, "no-dynamic-values", "Don't calculate the dynamic type of values"}, +{ eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values even if you have to run the target."}, +{ eDynamicDontRunTarget, "no-run-target", "Calculate the dynamic type of values, but don't run the target."}, +{ 0, NULL, NULL } +}; SettingEntry Target::SettingsController::global_settings_table[] = @@ -1633,11 +1646,11 @@ Target::SettingsController::global_settings_table[] = SettingEntry Target::SettingsController::instance_settings_table[] = { - // var-name var-type default enum init'd hidden help-text - // ================= ================== =========== ==== ====== ====== ========================================================================= - { TSC_EXPR_PREFIX , eSetVarTypeString , NULL , NULL, false, false, "Path to a file containing expressions to be prepended to all expressions." }, - { TSC_PREFER_DYNAMIC, eSetVarTypeBoolean ,"true" , NULL, false, false, "Should printed values be shown as their dynamic value." }, - { TSC_SKIP_PROLOGUE , eSetVarTypeBoolean ,"true" , NULL, false, false, "Skip function prologues when setting breakpoints by name." }, - { TSC_SOURCE_MAP , eSetVarTypeArray ,NULL , NULL, false, false, "Source path remappings to use when locating source files from debug information." }, - { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL } + // var-name var-type default enum init'd hidden help-text + // ================= ================== =============== ======================= ====== ====== ========================================================================= + { TSC_EXPR_PREFIX , eSetVarTypeString , NULL , NULL, false, false, "Path to a file containing expressions to be prepended to all expressions." }, + { TSC_PREFER_DYNAMIC, eSetVarTypeEnum , "no-run-target", g_dynamic_value_types, false, false, "Should printed values be shown as their dynamic value." }, + { TSC_SKIP_PROLOGUE , eSetVarTypeBoolean ,"true" , NULL, false, false, "Skip function prologues when setting breakpoints by name." }, + { TSC_SOURCE_MAP , eSetVarTypeArray ,NULL , NULL, false, false, "Source path remappings to use when locating source files from debug information." }, + { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL } }; diff --git a/lldb/test/array_types/TestArrayTypes.py b/lldb/test/array_types/TestArrayTypes.py index f4540b6c0a91..ec243208c3f9 100644 --- a/lldb/test/array_types/TestArrayTypes.py +++ b/lldb/test/array_types/TestArrayTypes.py @@ -69,7 +69,7 @@ class ArrayTypesTestCase(TestBase): # Issue 'variable list' command on several array-type variables. - self.expect("frame variable -t strings", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T strings", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(char *[4])', substrs = ['(char *) [0]', '(char *) [1]', @@ -80,14 +80,14 @@ class ArrayTypesTestCase(TestBase): 'Bonjour', 'Guten Tag']) - self.expect("frame variable -t char_16", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T char_16", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['(char) [0]', '(char) [15]']) - self.expect("frame variable -t ushort_matrix", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T ushort_matrix", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(unsigned short [2][3])') - self.expect("frame variable -t long_6", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T long_6", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(long [6])') def array_types_python(self): diff --git a/lldb/test/bitfields/TestBitfields.py b/lldb/test/bitfields/TestBitfields.py index f99c6e6e3bf1..7381f7c7ca65 100644 --- a/lldb/test/bitfields/TestBitfields.py +++ b/lldb/test/bitfields/TestBitfields.py @@ -62,7 +62,7 @@ class BitfieldsTestCase(TestBase): substrs = [' resolved, hit count = 1']) # This should display correctly. - self.expect("frame variable -t bits", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T bits", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['(uint32_t:1) b1 = 1', '(uint32_t:2) b2 = 3', '(uint32_t:3) b3 = 7', @@ -74,7 +74,7 @@ class BitfieldsTestCase(TestBase): # And so should this. # rdar://problem/8348251 - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['(uint32_t:1) b1 = 1', '(uint32_t:2) b2 = 3', '(uint32_t:3) b3 = 7', diff --git a/lldb/test/breakpoint_command/TestBreakpointCommand.py b/lldb/test/breakpoint_command/TestBreakpointCommand.py index 30a384286866..c892ea115735 100644 --- a/lldb/test/breakpoint_command/TestBreakpointCommand.py +++ b/lldb/test/breakpoint_command/TestBreakpointCommand.py @@ -51,7 +51,7 @@ class BreakpointCommandTestCase(TestBase): self.line) # Now add callbacks for the breakpoints just created. - self.runCmd("breakpoint command add -s command -o 'frame variable -t -s' 1") + self.runCmd("breakpoint command add -s command -o 'frame variable -T -s' 1") self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); print >> here, \"lldb\"; here.close()' 2") # Check that the breakpoint commands are correctly set. @@ -69,7 +69,7 @@ class BreakpointCommandTestCase(TestBase): self.expect("breakpoint command list 1", "Breakpoint 1 command ok", substrs = ["Breakpoint commands:", - "frame variable -t -s"]) + "frame variable -T -s"]) self.expect("breakpoint command list 2", "Breakpoint 2 command ok", substrs = ["Breakpoint commands:", "here = open", diff --git a/lldb/test/breakpoint_conditions/TestBreakpointConditions.py b/lldb/test/breakpoint_conditions/TestBreakpointConditions.py index aa87630ab17a..b3a550c22469 100644 --- a/lldb/test/breakpoint_conditions/TestBreakpointConditions.py +++ b/lldb/test/breakpoint_conditions/TestBreakpointConditions.py @@ -62,8 +62,8 @@ class BreakpointConditionsTestCase(TestBase): self.expect("process status", PROCESS_STOPPED, patterns = ['Process .* stopped']) - # 'frame variable -t val' should return 3 due to breakpoint condition. - self.expect("frame variable -t val", VARIABLES_DISPLAYED_CORRECTLY, + # 'frame variable -T val' should return 3 due to breakpoint condition. + self.expect("frame variable -T val", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int) val = 3') # Also check the hit count, which should be 3, by design. @@ -93,8 +93,8 @@ class BreakpointConditionsTestCase(TestBase): self.expect("process status", PROCESS_STOPPED, patterns = ['Process .* stopped']) - # 'frame variable -t val' should return 1 since it is the first breakpoint hit. - self.expect("frame variable -t val", VARIABLES_DISPLAYED_CORRECTLY, + # 'frame variable -T val' should return 1 since it is the first breakpoint hit. + self.expect("frame variable -T val", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int) val = 1') diff --git a/lldb/test/class_types/TestClassTypes.py b/lldb/test/class_types/TestClassTypes.py index a1fdd63df800..0205cc9362ed 100644 --- a/lldb/test/class_types/TestClassTypes.py +++ b/lldb/test/class_types/TestClassTypes.py @@ -88,7 +88,7 @@ class ClassTypesTestCase(TestBase): substrs = [' resolved, hit count = 1']) # We should be stopped on the ctor function of class C. - self.expect("frame variable -t this", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T this", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['C *', ' this = ']) @@ -182,8 +182,8 @@ class ClassTypesTestCase(TestBase): self.expect("frame variable this",VARIABLES_DISPLAYED_CORRECTLY, substrs = ['C *']) - # Verify that frame variable -t this->m_c_int behaves correctly. - self.expect("frame variable -t this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, + # Verify that frame variable -T this->m_c_int behaves correctly. + self.expect("frame variable -T this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int) this->m_c_int = 66') # Verify that 'expression this' gets the data type correct. diff --git a/lldb/test/cpp/dynamic-value/TestDynamicValue.py b/lldb/test/cpp/dynamic-value/TestDynamicValue.py index 93a47d5008c2..369ce1c0f46c 100644 --- a/lldb/test/cpp/dynamic-value/TestDynamicValue.py +++ b/lldb/test/cpp/dynamic-value/TestDynamicValue.py @@ -61,7 +61,10 @@ class DynamicValueTestCase(TestBase): # Now read m_b_value which is only in the dynamic value: - this_dynamic_m_b_value = this_dynamic.GetChildMemberWithName('m_b_value', True) + use_dynamic = lldb.eDynamicCanRunTarget + no_dynamic = lldb.eNoDynamicValues + + this_dynamic_m_b_value = this_dynamic.GetChildMemberWithName('m_b_value', use_dynamic) self.assertTrue (this_dynamic_m_b_value.IsValid()) m_b_value = int (this_dynamic_m_b_value.GetValue(), 0) @@ -69,17 +72,17 @@ class DynamicValueTestCase(TestBase): # Make sure it is not in the static version - this_static_m_b_value = this_static.GetChildMemberWithName('m_b_value', False) + this_static_m_b_value = this_static.GetChildMemberWithName('m_b_value', no_dynamic) self.assertTrue (this_static_m_b_value.IsValid() == False) # Okay, now let's make sure that we can get the dynamic type of a child element: - contained_auto_ptr = this_dynamic.GetChildMemberWithName ('m_client_A', True) + contained_auto_ptr = this_dynamic.GetChildMemberWithName ('m_client_A', use_dynamic) self.assertTrue (contained_auto_ptr.IsValid()) - contained_b = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', True) + contained_b = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', use_dynamic) self.assertTrue (contained_b.IsValid()) - contained_b_static = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', False) + contained_b_static = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', no_dynamic) self.assertTrue (contained_b_static.IsValid()) contained_b_addr = int (contained_b.GetValue(), 16) @@ -128,14 +131,14 @@ class DynamicValueTestCase(TestBase): # Now find the dynamic addresses of myB and otherB so we can compare them # with the dynamic values we get in doSomething: - noDynamic = False - useDynamic = True + use_dynamic = lldb.eDynamicCanRunTarget + no_dynamic = lldb.eNoDynamicValues - myB = frame.FindVariable ('myB', noDynamic); + myB = frame.FindVariable ('myB', no_dynamic); self.assertTrue (myB.IsValid()) myB_loc = int (myB.GetLocation(), 16) - otherB = frame.FindVariable('otherB', noDynamic) + otherB = frame.FindVariable('otherB', no_dynamic) self.assertTrue (otherB.IsValid()) otherB_loc = int (otherB.GetLocation(), 16) @@ -149,13 +152,13 @@ class DynamicValueTestCase(TestBase): # Get "this" using FindVariable: - this_static = frame.FindVariable ('this', noDynamic) - this_dynamic = frame.FindVariable ('this', useDynamic) + this_static = frame.FindVariable ('this', no_dynamic) + this_dynamic = frame.FindVariable ('this', use_dynamic) self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) # Get "this" using FindValue, make sure that works too: - this_static = frame.FindValue ('this', lldb.eValueTypeVariableArgument, noDynamic) - this_dynamic = frame.FindValue ('this', lldb.eValueTypeVariableArgument, useDynamic) + this_static = frame.FindValue ('this', lldb.eValueTypeVariableArgument, no_dynamic) + this_dynamic = frame.FindValue ('this', lldb.eValueTypeVariableArgument, use_dynamic) self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) # Get "this" using the EvaluateExpression: @@ -167,7 +170,7 @@ class DynamicValueTestCase(TestBase): # The "frame var" code uses another path to get into children, so let's # make sure that works as well: - self.expect('frame var -d 1 anotherA.m_client_A._M_ptr', 'frame var finds its way into a child member', + self.expect('frame var -d run-target anotherA.m_client_A._M_ptr', 'frame var finds its way into a child member', patterns = ['\(.* B \*\)']) # Now make sure we also get it right for a reference as well: diff --git a/lldb/test/forward/TestForwardDeclaration.py b/lldb/test/forward/TestForwardDeclaration.py index 6f324fa86f0c..cf8d7ceef83b 100644 --- a/lldb/test/forward/TestForwardDeclaration.py +++ b/lldb/test/forward/TestForwardDeclaration.py @@ -46,7 +46,7 @@ class ForwardDeclarationTestCase(TestBase): # This should display correctly. # Note that the member fields of a = 1 and b = 2 is by design. - self.expect("frame variable -t *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['(struct bar) *bar_ptr = ', '(int) a = 1', '(int) b = 2']) diff --git a/lldb/test/foundation/TestObjCMethods.py b/lldb/test/foundation/TestObjCMethods.py index 9bbf1c088822..a51be3d28d30 100644 --- a/lldb/test/foundation/TestObjCMethods.py +++ b/lldb/test/foundation/TestObjCMethods.py @@ -140,7 +140,7 @@ class FoundationTestCase(TestBase): 'NSString * str;', 'NSDate * date;']) - self.expect("frame variable -t -s", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T -s", VARIABLES_DISPLAYED_CORRECTLY, substrs = ["ARG: (MyString *) self"], patterns = ["ARG: \(.*\) _cmd", "(struct objc_selector *)|(SEL)"]) @@ -152,16 +152,16 @@ class FoundationTestCase(TestBase): # rdar://problem/8492646 # test/foundation fails after updating to tot r115023 # self->str displays nothing as output - self.expect("frame variable -t self->str", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T self->str", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(NSString *) self->str") # rdar://problem/8447030 # 'frame variable self->date' displays the wrong data member - self.expect("frame variable -t self->date", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T self->date", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(NSDate *) self->date") # This should display the str and date member fields as well. - self.expect("frame variable -t *self", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T *self", VARIABLES_DISPLAYED_CORRECTLY, substrs = ["(MyString) *self", "(NSString *) str", "(NSDate *) date"]) diff --git a/lldb/test/function_types/TestFunctionTypes.py b/lldb/test/function_types/TestFunctionTypes.py index eb696ec2f134..4a05f18ab272 100644 --- a/lldb/test/function_types/TestFunctionTypes.py +++ b/lldb/test/function_types/TestFunctionTypes.py @@ -49,7 +49,7 @@ class FunctionTypesTestCase(TestBase): substrs = [' resolved, hit count = 1']) # Check that the 'callback' variable display properly. - self.expect("frame variable -t callback", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T callback", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int (*)(const char *)) callback =') # And that we can break on the callback function. diff --git a/lldb/test/global_variables/TestGlobalVariables.py b/lldb/test/global_variables/TestGlobalVariables.py index 4faab4001e9f..d403d76672d5 100644 --- a/lldb/test/global_variables/TestGlobalVariables.py +++ b/lldb/test/global_variables/TestGlobalVariables.py @@ -49,7 +49,7 @@ class GlobalVariablesTestCase(TestBase): substrs = [' resolved, hit count = 1']) # Check that GLOBAL scopes are indicated for the variables. - self.expect("frame variable -t -s -g -a", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T -s -g -a", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['GLOBAL: (int) g_file_global_int = 42', 'GLOBAL: (const char *) g_file_global_cstr', '"g_file_global_cstr"', diff --git a/lldb/test/objc-dynamic-value/TestObjCDynamicValue.py b/lldb/test/objc-dynamic-value/TestObjCDynamicValue.py index f0b2ce34034b..56ceb49bef43 100644 --- a/lldb/test/objc-dynamic-value/TestObjCDynamicValue.py +++ b/lldb/test/objc-dynamic-value/TestObjCDynamicValue.py @@ -81,9 +81,9 @@ class ObjCDynamicValueTestCase(TestBase): # make sure we can get that properly: frame = thread.GetFrameAtIndex(0) - myObserver = frame.FindVariable('myObserver') + myObserver = frame.FindVariable('myObserver', lldb.eDynamicCanRunTarget) self.assertTrue (myObserver.IsValid()) - myObserver_source = myObserver.GetChildMemberWithName ('_source') + myObserver_source = myObserver.GetChildMemberWithName ('_source', lldb.eDynamicCanRunTarget) self.examine_SourceDerived_ptr (myObserver_source) # The "frame var" code uses another path to get into children, so let's @@ -91,7 +91,7 @@ class ObjCDynamicValueTestCase(TestBase): result = lldb.SBCommandReturnObject() - self.expect('frame var -d 1 myObserver->_source', 'frame var finds its way into a child member', + self.expect('frame var -d run-target myObserver->_source', 'frame var finds its way into a child member', patterns = ['\(SourceDerived \*\)']) # This test is not entirely related to the main thrust of this test case, but since we're here, @@ -115,8 +115,8 @@ class ObjCDynamicValueTestCase(TestBase): # Get "object" using FindVariable: - noDynamic = False - useDynamic = True + noDynamic = lldb.eNoDynamicValues + useDynamic = lldb.eDynamicCanRunTarget object_static = frame.FindVariable ('object', noDynamic) object_dynamic = frame.FindVariable ('object', useDynamic) @@ -134,8 +134,8 @@ class ObjCDynamicValueTestCase(TestBase): # Get "this" using the EvaluateExpression: # These tests fail for now because EvaluateExpression doesn't currently support dynamic typing... - #object_static = frame.EvaluateExpression ('object', False) - #object_dynamic = frame.EvaluateExpression ('object', True) + #object_static = frame.EvaluateExpression ('object', noDynamic) + #object_dynamic = frame.EvaluateExpression ('object', useDynamic) #self.examine_value_object_of_object_ptr (object_static, object_dynamic, myB_loc) # Continue again to the handle_SourceBase and make sure we get the correct dynamic value. diff --git a/lldb/test/set_values/TestSetValues.py b/lldb/test/set_values/TestSetValues.py index e17eb7143296..1e480f5d4c94 100644 --- a/lldb/test/set_values/TestSetValues.py +++ b/lldb/test/set_values/TestSetValues.py @@ -73,63 +73,63 @@ class SetValuesTestCase(TestBase): substrs = [' resolved, hit count = 1']) # main.c:15 - # Check that 'frame variable -t' displays the correct data type and value. - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + # Check that 'frame variable -T' displays the correct data type and value. + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(char) i = 'a'") # Now set variable 'i' and check that it is correctly displayed. self.runCmd("expression i = 'b'") - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(char) i = 'b'") self.runCmd("continue") # main.c:36 - # Check that 'frame variable -t' displays the correct data type and value. - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + # Check that 'frame variable -T' displays the correct data type and value. + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, patterns = ["\((short unsigned int|unsigned short)\) i = 33"]) # Now set variable 'i' and check that it is correctly displayed. self.runCmd("expression i = 333") - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, patterns = ["\((short unsigned int|unsigned short)\) i = 333"]) self.runCmd("continue") # main.c:57 - # Check that 'frame variable -t' displays the correct data type and value. - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + # Check that 'frame variable -T' displays the correct data type and value. + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(long int) i = 33") # Now set variable 'i' and check that it is correctly displayed. self.runCmd("expression i = 33333") - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(long int) i = 33333") self.runCmd("continue") # main.c:78 - # Check that 'frame variable -t' displays the correct data type and value. - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + # Check that 'frame variable -T' displays the correct data type and value. + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(double) i = 3.14159") # Now set variable 'i' and check that it is correctly displayed. self.runCmd("expression i = 3.14") - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(double) i = 3.14") self.runCmd("continue") # main.c:85 - # Check that 'frame variable -t' displays the correct data type and value. + # Check that 'frame variable -T' displays the correct data type and value. # rdar://problem/8422727 # set_values test directory: 'frame variable' shows only (long double) i = - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(long double) i = 3.14159") # Now set variable 'i' and check that it is correctly displayed. self.runCmd("expression i = 3.1") - self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(long double) i = 3.1") diff --git a/lldb/test/signed_types/TestSignedTypes.py b/lldb/test/signed_types/TestSignedTypes.py index 6dde6906f66c..2f7933fa31c2 100644 --- a/lldb/test/signed_types/TestSignedTypes.py +++ b/lldb/test/signed_types/TestSignedTypes.py @@ -54,7 +54,7 @@ class UnsignedTypesTestCase(TestBase): self.runCmd("thread step-over") # Test that signed types display correctly. - self.expect("frame variable -t -a", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T -a", VARIABLES_DISPLAYED_CORRECTLY, patterns = ["\((short int|short)\) the_signed_short = 99"], substrs = ["(signed char) the_signed_char = 'c'", "(int) the_signed_int = 99", diff --git a/lldb/test/types/AbstractBase.py b/lldb/test/types/AbstractBase.py index 53b26b982b60..559fa7f803ca 100644 --- a/lldb/test/types/AbstractBase.py +++ b/lldb/test/types/AbstractBase.py @@ -9,7 +9,7 @@ from lldbtest import * def Msg(var, val, using_frame_variable): return "'%s %s' matches the output (from compiled code): %s" % ( - 'frame variable -t' if using_frame_variable else 'expression' ,var, val) + 'frame variable -T' if using_frame_variable else 'expression' ,var, val) class GenericTester(TestBase): @@ -42,25 +42,25 @@ class GenericTester(TestBase): #print "golden list:", gl # Bring the program to the point where we can issue a series of - # 'frame variable -t' command. + # 'frame variable -T' command. self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) self.runCmd("breakpoint set --name Puts") self.runCmd("run", RUN_SUCCEEDED) self.runCmd("thread step-out", STEP_OUT_SUCCEEDED) - #self.runCmd("frame variable -t") + #self.runCmd("frame variable -T") # Now iterate through the golden list, comparing against the output from - # 'frame variable -t var'. + # 'frame variable -T var'. for var, val in gl: - self.runCmd("frame variable -t %s" % var) + self.runCmd("frame variable -T %s" % var) output = self.res.GetOutput() # The input type is in a canonical form as a set of named atoms. # The display type string must conatin each and every element. # # Example: - # runCmd: frame variable -t a_array_bounded[0] + # runCmd: frame variable -T a_array_bounded[0] # output: (char) a_array_bounded[0] = 'a' # try: @@ -108,7 +108,7 @@ class GenericTester(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.runCmd("thread step-out", STEP_OUT_SUCCEEDED) - #self.runCmd("frame variable -t") + #self.runCmd("frame variable -T") # Now iterate through the golden list, comparing against the output from # 'expr var'. diff --git a/lldb/test/unique-types/TestUniqueTypes.py b/lldb/test/unique-types/TestUniqueTypes.py index 7562e33263e6..4d7083884efb 100644 --- a/lldb/test/unique-types/TestUniqueTypes.py +++ b/lldb/test/unique-types/TestUniqueTypes.py @@ -59,8 +59,8 @@ class UniqueTypesTestCase(TestBase): if clang_version < 3: self.skipTest("rdar://problem/9173060 lldb hangs while running unique-types for clang version < 3") - # Do a "frame variable -t longs" and verify "long" is in each line of output. - self.runCmd("frame variable -t longs") + # Do a "frame variable -T longs" and verify "long" is in each line of output. + self.runCmd("frame variable -T longs") output = self.res.GetOutput() for x in [line.strip() for line in output.split(os.linesep)]: # Skip empty line or closing brace. @@ -69,8 +69,8 @@ class UniqueTypesTestCase(TestBase): self.expect(x, "Expect type 'long'", exe=False, substrs = ['long']) - # Do a "frame variable -t shorts" and verify "short" is in each line of output. - self.runCmd("frame variable -t shorts") + # Do a "frame variable -T shorts" and verify "short" is in each line of output. + self.runCmd("frame variable -T shorts") output = self.res.GetOutput() for x in [line.strip() for line in output.split(os.linesep)]: # Skip empty line or closing brace. diff --git a/lldb/test/unsigned_types/TestUnsignedTypes.py b/lldb/test/unsigned_types/TestUnsignedTypes.py index 9b47b66cd313..e8156b5b922c 100644 --- a/lldb/test/unsigned_types/TestUnsignedTypes.py +++ b/lldb/test/unsigned_types/TestUnsignedTypes.py @@ -51,7 +51,7 @@ class UnsignedTypesTestCase(TestBase): substrs = [' resolved, hit count = 1']) # Test that unsigned types display correctly. - self.expect("frame variable -t -a", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable -T -a", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(unsigned char) the_unsigned_char = 'c'", patterns = ["\((short unsigned int|unsigned short)\) the_unsigned_short = 99"], substrs = ["(unsigned int) the_unsigned_int = 99",