[Lldb-commits] [PATCH] [LLDB][MIPS] Handle false positives for MIPS hardware watchpoints

Mohit Bhakkad mohit.bhakkad at gmail.com
Thu Jun 25 23:44:42 PDT 2015


Hi clayborg, jingham,

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D10761

Files:
  source/Breakpoint/Watchpoint.cpp
  source/Target/StopInfo.cpp

Index: source/Breakpoint/Watchpoint.cpp
===================================================================
--- source/Breakpoint/Watchpoint.cpp
+++ source/Breakpoint/Watchpoint.cpp
@@ -154,6 +154,23 @@
     }
     m_new_value_sp = ValueObjectMemory::Create (exe_ctx.GetBestExecutionContextScope(), watch_name.AsCString(), watch_address, m_type);
     m_new_value_sp = m_new_value_sp->CreateConstantValue(watch_name);
+
+    // In MIPS while storing the address of watchpoint, last 3 bits are anded with watch flags,so its possible 
+    // to get a false positive from processor for a variable with same address that of watched variable except
+    // last 3 bits. So to check such false positive we check if value of watched variable is actually changed.
+    // For now mips-lldb supports hardware watches with 'write' type only. 
+    if (m_target.GetArchitecture().GetMachine() == llvm::Triple::mips ||
+        m_target.GetArchitecture().GetMachine() == llvm::Triple::mipsel ||
+        m_target.GetArchitecture().GetMachine() == llvm::Triple::mips64 ||
+        m_target.GetArchitecture().GetMachine() == llvm::Triple::mips64el)
+    {
+        if (m_old_value_sp)
+        {
+            if (m_old_value_sp->GetValueAsSigned(NULL,NULL) == m_new_value_sp->GetValueAsSigned(NULL,NULL))
+                return false;
+        }
+    }
+
     if (m_new_value_sp && m_new_value_sp->GetError().Success())
         return true;
     else
Index: source/Target/StopInfo.cpp
===================================================================
--- source/Target/StopInfo.cpp
+++ source/Target/StopInfo.cpp
@@ -830,13 +830,14 @@
                 // Finally, if we are going to stop, print out the new & old values:
                 if (m_should_stop)
                 {
-                    wp_sp->CaptureWatchedValue(exe_ctx);
-                    
-                    Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
-                    StreamSP output_sp = debugger.GetAsyncOutputStream ();
-                    wp_sp->DumpSnapshots(output_sp.get());
-                    output_sp->EOL();
-                    output_sp->Flush();
+                    if(wp_sp->CaptureWatchedValue(exe_ctx))
+                    {
+                        Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
+                        StreamSP output_sp = debugger.GetAsyncOutputStream ();
+                        wp_sp->DumpSnapshots(output_sp.get());
+                        output_sp->EOL();
+                        output_sp->Flush();
+                    }
                 }
                 
             }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10761.28538.patch
Type: text/x-patch
Size: 2618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150626/ed5eaabd/attachment.bin>


More information about the lldb-commits mailing list