diff options
12 files changed, 54 insertions, 93 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 39f22fd747c..81633d38283 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -53,10 +53,8 @@ OptionDefinition CommandObjectExpression::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "all-threads", 'a', required_argument, NULL, 0, eArgTypeBoolean, "Should we run all threads if the execution doesn't complete on one thread."}, - { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "dynamic-value", 'd', required_argument, NULL, 0, eArgTypeBoolean, "Upcast the value resulting from the expression to its dynamic type if available."}, { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "timeout", 't', required_argument, NULL, 0, eArgTypeUnsignedInteger, "Timeout value for running the expression."}, { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error", 'u', required_argument, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, breakpoint hit or signal."}, - { LLDB_OPT_SET_2 , false, "object-description", 'O', no_argument, NULL, 0, eArgTypeNone, "Print the object description of the value resulting from the expression."}, }; @@ -96,27 +94,6 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int } break; - case 'd': - { - bool success; - bool result; - result = Args::StringToBoolean(option_arg, true, &success); - if (!success) - error.SetErrorStringWithFormat("invalid dynamic value setting: \"%s\"", option_arg); - else - { - if (result) - use_dynamic = eLazyBoolYes; - else - use_dynamic = eLazyBoolNo; - } - } - break; - - case 'O': - print_object = true; - break; - case 't': { bool success; @@ -148,10 +125,7 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int void CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpreter &interpreter) { - use_dynamic = eLazyBoolCalculate; - print_object = false; unwind_on_error = true; - show_types = true; show_summary = true; try_all_threads = true; timeout = 0; @@ -212,6 +186,7 @@ Examples: \n\ // Add the "--format" and "--gdb-format" m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_GDB_FMT, LLDB_OPT_SET_1); m_option_group.Append (&m_command_options); + m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_2); m_option_group.Finalize(); } @@ -327,26 +302,12 @@ CommandObjectExpression::EvaluateExpression ExecutionResults exe_results; bool keep_in_memory = true; - lldb::DynamicValueType use_dynamic; - // If use dynamic is not set, get it from the target: - switch (m_command_options.use_dynamic) - { - case eLazyBoolCalculate: - use_dynamic = target->GetPreferDynamicValue(); - break; - case eLazyBoolYes: - use_dynamic = lldb::eDynamicCanRunTarget; - break; - case eLazyBoolNo: - use_dynamic = lldb::eNoDynamicValues; - break; - } - + EvaluateExpressionOptions options; - options.SetCoerceToId(m_command_options.print_object) + options.SetCoerceToId(m_varobj_options.use_objc) .SetUnwindOnError(m_command_options.unwind_on_error) .SetKeepInMemory(keep_in_memory) - .SetUseDynamic(use_dynamic) + .SetUseDynamic(m_varobj_options.use_dynamic) .SetRunOthers(m_command_options.try_all_threads) .SetTimeoutUsec(m_command_options.timeout); @@ -395,21 +356,21 @@ CommandObjectExpression::EvaluateExpression result_valobj_sp->SetFormat (format); ValueObject::DumpValueObjectOptions options; - options.SetMaximumPointerDepth(0) - .SetMaximumDepth(UINT32_MAX) - .SetShowLocation(false) - .SetShowTypes(m_command_options.show_types) - .SetUseObjectiveC(m_command_options.print_object) - .SetUseDynamicType(use_dynamic) - .SetScopeChecked(true) - .SetFlatOutput(false) - .SetUseSyntheticValue(true) - .SetIgnoreCap(false) + options.SetMaximumPointerDepth(m_varobj_options.ptr_depth) + .SetMaximumDepth(m_varobj_options.max_depth) + .SetShowTypes(m_varobj_options.show_types) + .SetShowLocation(m_varobj_options.show_location) + .SetUseObjectiveC(m_varobj_options.use_objc) + .SetUseDynamicType(m_varobj_options.use_dynamic) + .SetUseSyntheticValue(m_varobj_options.use_synth) + .SetFlatOutput(m_varobj_options.flat_output) + .SetOmitSummaryDepth(m_varobj_options.no_summary_depth) + .SetIgnoreCap(m_varobj_options.ignore_cap) .SetFormat(format) .SetSummary() - .SetShowSummary(!m_command_options.print_object) - .SetHideRootType(m_command_options.print_object); - + .SetShowSummary(!m_varobj_options.use_objc) + .SetHideRootType(m_varobj_options.use_objc); + ValueObject::DumpValueObject (*(output_stream), result_valobj_sp.get(), // Variable object to dump options); diff --git a/lldb/source/Commands/CommandObjectExpression.h b/lldb/source/Commands/CommandObjectExpression.h index 4ccadfcd8c1..b10e20889ee 100644 --- a/lldb/source/Commands/CommandObjectExpression.h +++ b/lldb/source/Commands/CommandObjectExpression.h @@ -16,6 +16,7 @@ // Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/OptionGroupFormat.h" +#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" #include "lldb/Target/ExecutionContext.h" namespace lldb_private { @@ -50,8 +51,6 @@ public: // Options table: Required for subclasses of Options. static OptionDefinition g_option_table[]; - bool print_object; - LazyBool use_dynamic; bool unwind_on_error; bool show_types; bool show_summary; @@ -88,6 +87,7 @@ protected: OptionGroupOptions m_option_group; OptionGroupFormat m_format_options; + OptionGroupValueObjectDisplay m_varobj_options; CommandOptions m_command_options; uint32_t m_expr_line_count; std::string m_expr_lines; // Multi-line expression support diff --git a/lldb/test/expression_command/formatters/TestFormatters.py b/lldb/test/expression_command/formatters/TestFormatters.py index 83b7720bfcf..e706e2989ee 100644 --- a/lldb/test/expression_command/formatters/TestFormatters.py +++ b/lldb/test/expression_command/formatters/TestFormatters.py @@ -56,7 +56,7 @@ class ExprFormattersTestCase(TestBase): self.runCmd("frame variable foo1.b --show-types") self.runCmd("frame variable foo1.b.b_ref --show-types") - self.expect("expression *(new foo(47))", + self.expect("expression --show-types -- *(new foo(47))", substrs = ['(int) a = 47', '(bar) b = {', '(int) i = 94', '(baz) b = {', '(int) k = 99']) self.runCmd("type summary add -F formatters.foo_SummaryProvider foo") @@ -94,7 +94,7 @@ class ExprFormattersTestCase(TestBase): self.runCmd("type summary delete foo") self.runCmd("type synthetic add --python-class foosynth.FooSyntheticProvider foo") - self.expect("expression $" + object_name, + self.expect("expression --show-types -- $" + object_name, substrs = ['(foo) $', ' = {', '(int) *i_ptr = 243']) self.runCmd("n") @@ -118,7 +118,7 @@ class ExprFormattersTestCase(TestBase): self.runCmd("type summary delete foo") self.runCmd("type synthetic add --python-class foosynth.FooSyntheticProvider foo") - self.expect("expression $" + object_name, + self.expect("expression --show-types -- $" + object_name, substrs = ['(foo) $', ' = {', '(int) *i_ptr = 8888']) self.runCmd("n") diff --git a/lldb/test/expression_command/issue_11588/Test11588.py b/lldb/test/expression_command/issue_11588/Test11588.py index 0919bbc7025..424716729a6 100644 --- a/lldb/test/expression_command/issue_11588/Test11588.py +++ b/lldb/test/expression_command/issue_11588/Test11588.py @@ -40,7 +40,7 @@ class Issue11581TestCase(TestBase): self.runCmd("command script import --allow-reload s11588.py") self.runCmd("type synthetic add --python-class s11588.Issue11581SyntheticProvider StgClosure") - self.expect("print *((StgClosure*)(r14-1))", + self.expect("expr --show-types -- *((StgClosure*)(r14-1))", substrs = ["(StgClosure) $", "(StgClosure *) &$","0x", "addr = ", @@ -60,7 +60,7 @@ class Issue11581TestCase(TestBase): self.runCmd("register write r14 %d" % addr) self.expect("register read r14", substrs = ["0x",hex(addr)[2:].rstrip("L")]) # Remove trailing 'L' if it exists - self.expect("print *(StgClosure*)$r14", + self.expect("expr --show-types -- *(StgClosure*)$r14", substrs = ["(StgClosure) $", "(StgClosure *) &$","0x", "addr = ", diff --git a/lldb/test/functionalities/alias/TestAliases.py b/lldb/test/functionalities/alias/TestAliases.py index bf8fc3719fb..902fcc3c270 100644 --- a/lldb/test/functionalities/alias/TestAliases.py +++ b/lldb/test/functionalities/alias/TestAliases.py @@ -142,16 +142,16 @@ class AliasTestCase(TestBase): "= 0x000004d2" ]) self.expect ('exprf2 c "Hi there!"', - substrs = [ "(const char) [0] = 'H'", - "(const char) [1] = 'i'", - "(const char) [2] = ' '", - "(const char) [3] = 't'", - "(const char) [4] = 'h'", - "(const char) [5] = 'e'", - "(const char) [6] = 'r'", - "(const char) [7] = 'e'", - "(const char) [8] = '!'", - "(const char) [9] = '\\0'" ]) + substrs = [ "[0] = 'H'", + "[1] = 'i'", + "[2] = ' '", + "[3] = 't'", + "[4] = 'h'", + "[5] = 'e'", + "[6] = 'r'", + "[7] = 'e'", + "[8] = '!'", + "[9] = '\\0'" ]) self.expect ("exprf x 1234", diff --git a/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py index 1c45e76421b..6f550438d51 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py @@ -270,7 +270,7 @@ class ObjCDataFormatterTestCase(TestBase): '(NSAttributedString *) mutableAttrString = ',' @"hello world from foo"', '(NSString *) mutableGetConst = ',' @"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear foo"']) - self.expect('frame variable -d run-target path',substrs = ['usr/blah/stuff']) + self.expect('expr -d run-target -- path',substrs = ['usr/blah/stuff']) self.expect('frame variable path',substrs = ['usr/blah/stuff']) self.expect('frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref', @@ -411,18 +411,18 @@ class ObjCDataFormatterTestCase(TestBase): self.expect('expression ((id)@"Hello")', matching=False, substrs = ['Hello']) - self.expect('expression -d true -- ((id)@"Hello")', + self.expect('expression -d run -- ((id)@"Hello")', substrs = ['Hello']) - self.expect('expr -d true -- label1', + self.expect('expr -d run -- label1', substrs = ['Process Name']) - self.expect('expr -d true -- @"Hello"', + self.expect('expr -d run -- @"Hello"', substrs = ['Hello']) - self.expect('expr -d true --object-description -- @"Hello"', + self.expect('expr -d run --object-description -- @"Hello"', substrs = ['Hello']) - self.expect('expr -d true --object-description -- @"Hello"', matching=False, + self.expect('expr -d run --object-description -- @"Hello"', matching=False, substrs = ['@"Hello" Hello']) diff --git a/lldb/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py b/lldb/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py index eed7b1196dd..aeffd6ba2fb 100644 --- a/lldb/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py +++ b/lldb/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py @@ -64,8 +64,8 @@ class DataFormatterRdar12437442TestCase(TestBase): id_x.SetPreferSyntheticValue(True) if self.TraceOn(): - self.runCmd("frame variable x --dynamic-type run-target --ptr-depth 1") - + self.runCmd("expr --dynamic-type run-target --ptr-depth 1 -- x") + self.assertTrue(id_x.GetSummary() == '@"5 objects"', "array does not get correct summary") self.runCmd("next") @@ -75,7 +75,7 @@ class DataFormatterRdar12437442TestCase(TestBase): id_x.SetPreferSyntheticValue(True) if self.TraceOn(): - self.runCmd("frame variable x --dynamic-type run-target --ptr-depth 1") + self.runCmd("expr --dynamic-type run-target --ptr-depth 1 -- x") self.assertTrue(id_x.GetNumChildren() == 7, "dictionary does not have 7 children") id_x.SetPreferSyntheticValue(False) diff --git a/lldb/test/lang/c/forward/TestForwardDeclaration.py b/lldb/test/lang/c/forward/TestForwardDeclaration.py index 9ae1fe063cc..7ded56c824e 100644 --- a/lldb/test/lang/c/forward/TestForwardDeclaration.py +++ b/lldb/test/lang/c/forward/TestForwardDeclaration.py @@ -54,7 +54,7 @@ class ForwardDeclarationTestCase(TestBase): '(int) b = 2']) # And so should this. - self.expect("expression *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("expression --show-types -- *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['(bar)', '(int) a = 1', '(int) b = 2']) diff --git a/lldb/test/lang/c/shared_lib/TestSharedLib.py b/lldb/test/lang/c/shared_lib/TestSharedLib.py index eb9a4c0a078..8ef7bdef682 100644 --- a/lldb/test/lang/c/shared_lib/TestSharedLib.py +++ b/lldb/test/lang/c/shared_lib/TestSharedLib.py @@ -66,7 +66,7 @@ class SharedLibTestCase(TestBase): self.common_setup() # This should display correctly. - self.expect("expression *my_foo_ptr", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("expression --show-types -- *my_foo_ptr", VARIABLES_DISPLAYED_CORRECTLY, substrs = ["(foo)", "(sub_foo)", "other_element = 3"]) @unittest2.expectedFailure @@ -76,7 +76,7 @@ class SharedLibTestCase(TestBase): self.common_setup() # This should display correctly. - self.expect("frame variable *my_foo_ptr", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types -- *my_foo_ptr", VARIABLES_DISPLAYED_CORRECTLY, substrs = ["(foo)", "(sub_foo)", "other_element = 3"]) if __name__ == '__main__': diff --git a/lldb/test/lang/c/strings/TestCStrings.py b/lldb/test/lang/c/strings/TestCStrings.py index 089e23e86eb..0a1a826674a 100644 --- a/lldb/test/lang/c/strings/TestCStrings.py +++ b/lldb/test/lang/c/strings/TestCStrings.py @@ -53,9 +53,9 @@ class CStringsTestCase(TestBase): startstr = "(const char) $4 = '\\0'") self.expect("p \"hello\"", - substrs = ['(const char [6]) $', 'hello', - '(const char) [0] = \'h\'', - '(const char) [5] = \'\\0\'']) + substrs = ['[6]) $', 'hello', + '[0] = \'h\'', + '[5] = \'\\0\'']) self.expect("p (char*)\"hello\"", substrs = ['(char *) $', ' = 0x', diff --git a/lldb/test/lang/objc/foundation/TestObjCMethods2.py b/lldb/test/lang/objc/foundation/TestObjCMethods2.py index 7b899aa433c..6854b8d5fe8 100644 --- a/lldb/test/lang/objc/foundation/TestObjCMethods2.py +++ b/lldb/test/lang/objc/foundation/TestObjCMethods2.py @@ -200,7 +200,7 @@ class FoundationTestCase2(TestBase): self.runCmd("run", RUN_SUCCEEDED) - self.expect("expression *my", + self.expect("expression --show-types -- *my", patterns = ["\(MyString\) \$.* = ", "\(MyBase\)", "\(NSObject\)", "\(Class\)"]) self.runCmd("process continue") diff --git a/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py b/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py index 16466d68cbb..1dbf680d675 100644 --- a/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py +++ b/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py @@ -51,13 +51,13 @@ class Rdar10967107TestCase(TestBase): self.expect("frame variable my_string --dynamic-type run-target", substrs = ['const char *']) # check that expr also gets it right self.expect("expr my_string", substrs = ['const char *']) - self.expect("expr -d true -- my_string", substrs = ['const char *']) + self.expect("expr -d run -- my_string", substrs = ['const char *']) # but check that we get the real Foolie as such self.expect("frame variable my_foolie", substrs = ['FoolMeOnce *']) self.expect("frame variable my_foolie --dynamic-type run-target", substrs = ['FoolMeOnce *']) # check that expr also gets it right self.expect("expr my_foolie", substrs = ['FoolMeOnce *']) - self.expect("expr -d true -- my_foolie", substrs = ['FoolMeOnce *']) + self.expect("expr -d run -- my_foolie", substrs = ['FoolMeOnce *']) # now check that assigning a true string does not break anything self.runCmd("next") # check that we correctly see the const char*, even with dynamic types on @@ -65,13 +65,13 @@ class Rdar10967107TestCase(TestBase): self.expect("frame variable my_string --dynamic-type run-target", substrs = ['const char *']) # check that expr also gets it right self.expect("expr my_string", substrs = ['const char *']) - self.expect("expr -d true -- my_string", substrs = ['const char *']) + self.expect("expr -d run -- my_string", substrs = ['const char *']) # but check that we get the real Foolie as such self.expect("frame variable my_foolie", substrs = ['FoolMeOnce *']) self.expect("frame variable my_foolie --dynamic-type run-target", substrs = ['FoolMeOnce *']) # check that expr also gets it right self.expect("expr my_foolie", substrs = ['FoolMeOnce *']) - self.expect("expr -d true -- my_foolie", substrs = ['FoolMeOnce *']) + self.expect("expr -d run -- my_foolie", substrs = ['FoolMeOnce *']) if __name__ == '__main__': import atexit |