When trying to take snapshots of a watched variable, if the frame is unable to evaluate the variable expression,
do not take the sanpshot and forget about the stop info.  It is possible that the variable expression has gone
out of scope, we'll revise the hit count due to the false alarms.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@161892 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 5732ed6..434b006 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -498,6 +498,7 @@
             StackFrame *frame = exe_ctx.GetFramePtr();
             if (frame)
             {
+                bool snapshot_taken = true;
                 if (!wp_sp->IsWatchVariable())
                 {
                     // We are not watching a variable, just read from the process memory for the watched location.
@@ -535,18 +536,29 @@
                         wp_sp->SetNewSnapshot(ss.GetString());
                     }
                     else
-                        wp_sp->SetNewSnapshot("snapshot attempt failed.");
+                    {
+                        // The variable expression has become out of scope?
+                        // Let us forget about this stop info.
+                        if (log)
+                            log->Printf("Snapshot attempt failed.  Variable expression has become out of scope?");
+                        snapshot_taken = false;
+                        m_should_stop = false;
+                        wp_sp->IncrementFalseAlarmsAndReviseHitCount();
+                    }
 
-                    if (log)
+                    if (log && snapshot_taken)
                         log->Printf("Watchpoint snapshot taken: '%s'\n", wp_sp->GetNewSnapshot().c_str());
                 }
 
                 // Now dump the snapshots we have taken.
-                Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
-                StreamSP output_sp = debugger.GetAsyncOutputStream ();
-                wp_sp->DumpSnapshots(output_sp.get());
-                output_sp->EOL();
-                output_sp->Flush();
+                if (snapshot_taken)
+                {
+                    Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
+                    StreamSP output_sp = debugger.GetAsyncOutputStream ();
+                    wp_sp->DumpSnapshots(output_sp.get());
+                    output_sp->EOL();
+                    output_sp->Flush();
+                }
             }
 
             if (m_should_stop && wp_sp->GetConditionText() != NULL)