[Lldb-commits] [lldb] r161623 - in /lldb/trunk: include/lldb/Interpreter/NamedOptionValue.h include/lldb/Interpreter/OptionGroupVariable.h source/Commands/CommandObjectFrame.cpp source/Interpreter/OptionGroupVariable.cpp test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py

Enrico Granata egranata at apple.com
Thu Aug 9 15:02:52 PDT 2012


Author: enrico
Date: Thu Aug  9 17:02:51 2012
New Revision: 161623

URL: http://llvm.org/viewvc/llvm-project?rev=161623&view=rev
Log:
<rdar://problem/11578397> Adding a new --summary-string option for the frame variable command which allows the user to provide a summary string with which he wants to display the variables without having to make a named summary first

Modified:
    lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h
    lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
    lldb/trunk/source/Commands/CommandObjectFrame.cpp
    lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
    lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py

Modified: lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h?rev=161623&r1=161622&r2=161623&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h (original)
+++ lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h Thu Aug  9 17:02:51 2012
@@ -522,11 +522,23 @@
             return m_current_value.c_str();
         }
         
+        bool
+        IsCurrentValueEmpty () const
+        {
+            return m_current_value.empty();
+        }
+        
         const char *
         GetDefaultValue() const
         {
             return m_default_value.c_str();
         }
+
+        bool
+        IsDefaultValueEmpty () const
+        {
+            return m_default_value.empty();
+        }
         
         void
         SetCurrentValue (const char *value)

Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h?rev=161623&r1=161622&r2=161623&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h Thu Aug  9 17:02:51 2012
@@ -14,6 +14,7 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Interpreter/NamedOptionValue.h"
 #include "lldb/Interpreter/Options.h"
 
 namespace lldb_private {
@@ -52,7 +53,8 @@
              use_regex:1,
              show_scope:1,
              show_decl:1;
-        std::string summary;
+        OptionValueString summary;            // the name of a named summary
+        OptionValueString summary_string;     // a summary string
 
     private:
         DISALLOW_COPY_AND_ASSIGN(OptionGroupVariable);

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=161623&r1=161622&r2=161623&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Thu Aug  9 17:02:51 2012
@@ -394,8 +394,10 @@
         size_t idx;
         
         TypeSummaryImplSP summary_format_sp;
-        if (!m_option_variable.summary.empty())
-            DataVisualization::NamedSummaryFormats::GetSummaryFormat(ConstString(m_option_variable.summary.c_str()), summary_format_sp);
+        if (!m_option_variable.summary.IsCurrentValueEmpty())
+            DataVisualization::NamedSummaryFormats::GetSummaryFormat(ConstString(m_option_variable.summary.GetCurrentValue()), summary_format_sp);
+        else if (!m_option_variable.summary_string.IsCurrentValueEmpty())
+            summary_format_sp.reset(new StringSummaryFormat(TypeSummaryImpl::Flags(),m_option_variable.summary_string.GetCurrentValue()));
         
         ValueObject::DumpValueObjectOptions options;
         

Modified: lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupVariable.cpp?rev=161623&r1=161622&r2=161623&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupVariable.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupVariable.cpp Thu Aug  9 17:02:51 2012
@@ -24,13 +24,14 @@
 static OptionDefinition
 g_option_table[] =
 {
-    { LLDB_OPT_SET_1, false, "no-args",         'a', no_argument,       NULL, 0, eArgTypeNone,    "Omit function arguments."},
-    { LLDB_OPT_SET_1, false, "no-locals",       'l', no_argument,       NULL, 0, eArgTypeNone,    "Omit local variables."},
-    { 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, "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, "regex",           'r', no_argument,       NULL, 0, eArgTypeRegularExpression,    "The <variable-name> 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 | LLDB_OPT_SET_2, false, "no-args",         'a', no_argument,       NULL, 0, eArgTypeNone,    "Omit function arguments."},
+    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-locals",       'l', no_argument,       NULL, 0, eArgTypeNone,    "Omit local variables."},
+    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-globals",    'g', no_argument,       NULL, 0, eArgTypeNone,    "Show the current frame source file global and static variables."},
+    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, 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 | LLDB_OPT_SET_2, false, "regex",           'r', no_argument,       NULL, 0, eArgTypeRegularExpression,    "The <variable-name> argument for name lookups are regular expressions."},
+    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "scope",           's', no_argument,       NULL, 0, eArgTypeNone,    "Show variable scope (argument, local, global, static)."},
     { LLDB_OPT_SET_1, false, "summary",         'y', required_argument, NULL, 0, eArgTypeName,  "Specify the summary that the variable output should use."},
+    { LLDB_OPT_SET_2, false, "summary-string",  'z', required_argument, NULL, 0, eArgTypeName,  "Specify a summary string to use to format the variable output."},
 };
 
 
@@ -64,7 +65,10 @@
             show_scope = true;
             break;
         case 'y':
-            summary = std::string(option_arg);
+            summary.SetCurrentValue(option_arg);
+            break;
+        case 'z':
+            summary_string.SetCurrentValue(option_arg);
             break;
         default:
             error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
@@ -83,7 +87,8 @@
     show_decl     = false;
     use_regex     = false;
     show_scope    = false;
-    summary       = "";
+    summary.Clear();
+    summary_string.Clear();
 }
 
 #define NUM_FRAME_OPTS 3

Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py?rev=161623&r1=161622&r2=161623&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py Thu Aug  9 17:02:51 2012
@@ -119,9 +119,7 @@
             substrs = ['low bits are',
                        'tgt is 6'])
 
-        self.runCmd("type summary add --summary-string \"${*var[0-1]}\" -x \"int \[[0-9]\]\"")
-
-        self.expect("frame variable int_array",
+        self.expect("frame variable int_array --summary-string \"${*var[0-1]}\"",
             substrs = ['3'])
 
         self.runCmd("type summary clear")
@@ -162,21 +160,25 @@
 
         self.runCmd("type summary clear")
 
-        self.runCmd("type summary add --summary-string \"${var[0][0-2]%hex}\" -x \"int \[[0-9]\]\"")
-
-        self.expect("frame variable int_array",
+        self.expect("frame variable int_array --summary-string \"${var[0][0-2]%hex}\"",
             substrs = ['0x',
                        '7'])
 
         self.runCmd("type summary clear")
 
         self.runCmd("type summary add --summary-string \"${*var[].x[0-3]%hex} is a bitfield on a set of integers\" -x \"SimpleWithPointers \[[0-9]\]\"")
-        self.runCmd("type summary add --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\" Couple")
 
-        self.expect("frame variable couple",
+        self.expect("frame variable couple --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\"",
             substrs = ['1 are low bits of integer 9.',
                        'If I pretend it is an array I get [9,'])
 
+        # if the summary has an error, we still display the value
+        self.expect("frame variable couple --summary-string \"${*var.sp.foo[0-2]\"",
+            substrs = ['(Couple) couple =  {','sp = {','z =','"X"'])
+
+
+        self.runCmd("type summary add --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\" Couple")
+
         self.expect("frame variable sparray",
             substrs = ['[0x0000000f,0x0000000c,0x00000009]'])
         





More information about the lldb-commits mailing list