[Lldb-commits] [lldb] r281534 - Cleaned up a little bit of redundant code in 'frame diagnose.`

Sean Callanan via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 14 13:29:58 PDT 2016


Author: spyffe
Date: Wed Sep 14 15:29:57 2016
New Revision: 281534

URL: http://llvm.org/viewvc/llvm-project?rev=281534&view=rev
Log:
Cleaned up a little bit of redundant code in 'frame diagnose.`

Modified:
    lldb/trunk/source/Target/StackFrame.cpp

Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=281534&r1=281533&r2=281534&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Wed Sep 14 15:29:57 2016
@@ -1492,6 +1492,12 @@ lldb::ValueObjectSP DoGuessValueAt(Stack
 
   using namespace OperandMatchers;
 
+  const RegisterInfo *reg_info =
+      frame.GetRegisterContext()->GetRegisterInfoByName(reg.AsCString());
+  if (!reg_info) {
+    return ValueObjectSP();
+  }
+
   Instruction::Operand op =
       offset ? Instruction::Operand::BuildDereference(
                    Instruction::Operand::BuildSum(
@@ -1517,9 +1523,9 @@ lldb::ValueObjectSP DoGuessValueAt(Stack
 
   for (uint32_t ii = current_inst - 1; ii != (uint32_t)-1; --ii) {
     // This is not an exact algorithm, and it sacrifices accuracy for
-    // generality.
-    // Recognizing "mov" and "ld" instructions –– and which are their source and
-    // destination operands -- is something the disassembler should do for us.
+    // generality.  Recognizing "mov" and "ld" instructions –– and which are
+    // their source and destination operands -- is something the disassembler
+    // should do for us.
     InstructionSP instruction_sp =
         disassembler.GetInstructionList().GetInstructionAtIndex(ii);
 
@@ -1602,16 +1608,18 @@ lldb::ValueObjectSP DoGuessValueAt(Stack
     }
 
     Instruction::Operand *origin_operand = nullptr;
-    if (operands[0].m_type == Instruction::Operand::Type::Register &&
-        operands[0].m_clobbered == true && operands[0].m_register == reg) {
-      // operands[0] is a register operand
+    std::function<bool(const Instruction::Operand &)> clobbered_reg_matcher =
+        [reg_info](const Instruction::Operand &op) {
+          return MatchRegOp(*reg_info)(op) && op.m_clobbered;
+        };
+
+    if (clobbered_reg_matcher(operands[0])) {
       origin_operand = &operands[1];
-    } else if (operands[1].m_type == Instruction::Operand::Type::Register &&
-               operands[1].m_clobbered == true &&
-               operands[1].m_register == reg) {
+    }
+    else if (clobbered_reg_matcher(operands[1])) {
       origin_operand = &operands[0];
-      // operands[1] is a register operand
-    } else {
+    }
+    else {
       continue;
     }
 




More information about the lldb-commits mailing list