[Lldb-commits] [lldb] r171993 - in /lldb/trunk: source/Commands/ test/expression_command/formatters/ test/expression_command/issue_11588/ test/functionalities/alias/ test/functionalities/data-formatter/data-formatter-objc/ test/functionalities/data-formatter/rdar-12437442/ test/lang/c/forward/ test/lang/c/shared_lib/ test/lang/c/strings/ test/lang/objc/foundation/ test/lang/objc/rdar-11355592/
Enrico Granata
egranata at apple.com
Wed Jan 9 12:12:54 PST 2013
Author: enrico
Date: Wed Jan 9 14:12:53 2013
New Revision: 171993
URL: http://llvm.org/viewvc/llvm-project?rev=171993&view=rev
Log:
<rdar://problem/12028723>
Adding useful formatting options to the expression (expr) command.
As a side effect of this change, the -d option now supports the same three-values enumeration that frame variables uses (run, don't run, none) instead of a boolean like it did previously
These options do not apply to print, p or po because these are aliased to not take any options.
In order to use them, use expression or expr.
Modified:
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectExpression.h
lldb/trunk/test/expression_command/formatters/TestFormatters.py
lldb/trunk/test/expression_command/issue_11588/Test11588.py
lldb/trunk/test/functionalities/alias/TestAliases.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
lldb/trunk/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py
lldb/trunk/test/lang/c/forward/TestForwardDeclaration.py
lldb/trunk/test/lang/c/shared_lib/TestSharedLib.py
lldb/trunk/test/lang/c/strings/TestCStrings.py
lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py
lldb/trunk/test/lang/objc/rdar-11355592/TestRdar11355592.py
Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Wed Jan 9 14:12:53 2013
@@ -53,10 +53,8 @@
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 @@
}
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 @@
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 @@
// 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 @@
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 @@
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);
Modified: lldb/trunk/source/Commands/CommandObjectExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.h (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.h Wed Jan 9 14:12:53 2013
@@ -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 @@
// 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 @@
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
Modified: lldb/trunk/test/expression_command/formatters/TestFormatters.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/formatters/TestFormatters.py?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/test/expression_command/formatters/TestFormatters.py (original)
+++ lldb/trunk/test/expression_command/formatters/TestFormatters.py Wed Jan 9 14:12:53 2013
@@ -56,7 +56,7 @@
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 @@
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 @@
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")
Modified: lldb/trunk/test/expression_command/issue_11588/Test11588.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/issue_11588/Test11588.py?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/test/expression_command/issue_11588/Test11588.py (original)
+++ lldb/trunk/test/expression_command/issue_11588/Test11588.py Wed Jan 9 14:12:53 2013
@@ -40,7 +40,7 @@
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 @@
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 = ",
Modified: lldb/trunk/test/functionalities/alias/TestAliases.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/TestAliases.py?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/alias/TestAliases.py (original)
+++ lldb/trunk/test/functionalities/alias/TestAliases.py Wed Jan 9 14:12:53 2013
@@ -142,16 +142,16 @@
"= 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",
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Wed Jan 9 14:12:53 2013
@@ -270,7 +270,7 @@
'(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 @@
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'])
Modified: lldb/trunk/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py Wed Jan 9 14:12:53 2013
@@ -64,8 +64,8 @@
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 @@
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)
Modified: lldb/trunk/test/lang/c/forward/TestForwardDeclaration.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/forward/TestForwardDeclaration.py?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/test/lang/c/forward/TestForwardDeclaration.py (original)
+++ lldb/trunk/test/lang/c/forward/TestForwardDeclaration.py Wed Jan 9 14:12:53 2013
@@ -54,7 +54,7 @@
'(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'])
Modified: lldb/trunk/test/lang/c/shared_lib/TestSharedLib.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/shared_lib/TestSharedLib.py?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/test/lang/c/shared_lib/TestSharedLib.py (original)
+++ lldb/trunk/test/lang/c/shared_lib/TestSharedLib.py Wed Jan 9 14:12:53 2013
@@ -66,7 +66,7 @@
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 @@
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__':
Modified: lldb/trunk/test/lang/c/strings/TestCStrings.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/strings/TestCStrings.py?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/test/lang/c/strings/TestCStrings.py (original)
+++ lldb/trunk/test/lang/c/strings/TestCStrings.py Wed Jan 9 14:12:53 2013
@@ -53,9 +53,9 @@
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',
Modified: lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py (original)
+++ lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py Wed Jan 9 14:12:53 2013
@@ -200,7 +200,7 @@
self.runCmd("run", RUN_SUCCEEDED)
- self.expect("expression *my",
+ self.expect("expression --show-types -- *my",
patterns = ["\(MyString\) \$.* = ", "\(MyBase\)", "\(NSObject\)", "\(Class\)"])
self.runCmd("process continue")
Modified: lldb/trunk/test/lang/objc/rdar-11355592/TestRdar11355592.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/rdar-11355592/TestRdar11355592.py?rev=171993&r1=171992&r2=171993&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/rdar-11355592/TestRdar11355592.py (original)
+++ lldb/trunk/test/lang/objc/rdar-11355592/TestRdar11355592.py Wed Jan 9 14:12:53 2013
@@ -51,13 +51,13 @@
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 @@
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
More information about the lldb-commits
mailing list