[Lldb-commits] [lldb] r157647 - in /lldb/trunk: source/Commands/CommandObjectRegister.cpp test/functionalities/register/TestRegisters.py

Johnny Chen johnny.chen at apple.com
Tue May 29 14:55:09 PDT 2012


Author: johnny
Date: Tue May 29 16:55:08 2012
New Revision: 157647

URL: http://llvm.org/viewvc/llvm-project?rev=157647&view=rev
Log:
rdar://problem/11541676
Do not show the derived registers like "eax", ... for the vanilla "register read" command.
Also add a test scenario for that.

Modified:
    lldb/trunk/source/Commands/CommandObjectRegister.cpp
    lldb/trunk/test/functionalities/register/TestRegisters.py

Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=157647&r1=157646&r2=157647&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Tue May 29 16:55:08 2012
@@ -124,7 +124,8 @@
     DumpRegisterSet (const ExecutionContext &exe_ctx,
                      Stream &strm,
                      RegisterContext *reg_ctx,
-                     uint32_t set_idx)
+                     uint32_t set_idx,
+                     bool primitive_only=false)
     {
         uint32_t unavailable_count = 0;
         uint32_t available_count = 0;
@@ -137,7 +138,11 @@
             for (uint32_t reg_idx = 0; reg_idx < num_registers; ++reg_idx)
             {
                 const uint32_t reg = reg_set->registers[reg_idx];
-                if (DumpRegister (exe_ctx, strm, reg_ctx, reg_ctx->GetRegisterInfoAtIndex(reg)))
+                const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg);
+                // Skip the dumping of derived register if primitive_only is true.
+                if (primitive_only && reg_info && reg_info->value_regs)
+                    continue;
+                if (DumpRegister (exe_ctx, strm, reg_ctx, reg_info))
                     ++available_count;
                 else
                     ++unavailable_count;
@@ -202,7 +207,8 @@
 
                     for (set_idx = 0; set_idx < num_register_sets; ++set_idx)
                     {
-                        DumpRegisterSet (exe_ctx, strm, reg_ctx, set_idx);
+                        // When dump_all_sets option is set, dump primitive as well as derived registers.
+                        DumpRegisterSet (exe_ctx, strm, reg_ctx, set_idx, !m_command_options.dump_all_sets.GetCurrentValue());
                     }
                 }
             }

Modified: lldb/trunk/test/functionalities/register/TestRegisters.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/register/TestRegisters.py?rev=157647&r1=157646&r2=157647&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/register/TestRegisters.py (original)
+++ lldb/trunk/test/functionalities/register/TestRegisters.py Tue May 29 16:55:08 2012
@@ -71,6 +71,13 @@
         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
             substrs = ['stopped', 'stop reason = breakpoint'])
 
+        # The vanilla "register read" command does not output derived register like eax.
+        self.expect("register read", matching=False,
+            substrs = ['eax'])
+        # While "register read -a" does output derived register like eax.
+        self.expect("register read -a", matching=True,
+            substrs = ['eax'])
+        
         # Test reading of rax and eax.
         self.runCmd("register read rax eax")
 





More information about the lldb-commits mailing list