[Lldb-commits] [PATCH] D13202: [LLDB] Fix display of value of a vector variables in watchpoint operations

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 5 11:44:30 PDT 2015


clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Back from vacation, sorry for the delay.

One quick fix as noted in inlined comments.


================
Comment at: source/Breakpoint/Watchpoint.cpp:224-235
@@ -223,7 +223,14 @@
     {
-        s->Printf("\n%sold value: %s", prefix, m_old_value_sp->GetValueAsCString());
+        if (m_old_value_sp->GetValueAsCString())
+            s->Printf("\n%sold value: %s", prefix, m_old_value_sp->GetValueAsCString());
+        else
+            s->Printf("\n%sold value: %s", prefix, m_old_value_sp->GetSummaryAsCString());
     }
+
     if (m_new_value_sp)
     {
-        s->Printf("\n%snew value: %s", prefix, m_new_value_sp->GetValueAsCString());
+        if (m_new_value_sp->GetValueAsCString())
+            s->Printf("\n%snew value: %s", prefix, m_new_value_sp->GetValueAsCString());
+        else
+            s->Printf("\n%snew value: %s", prefix, m_new_value_sp->GetSummaryAsCString());
     }
----------------
It would be nice to store these in local variables and clean up the code a bit like:

```
const char *old_value_cstr =  m_old_value_sp->GetValueAsCString();
if (old_value_cstr && old_value_cstr[0])
    s->Printf("\n%sold value: %s", prefix, old_value_cstr);
else
{
    const char *old_summary_cstr =  m_old_value_sp-> GetSummaryAsCString();
    if (old_summary_cstr && old_summary_cstr[0])
        s->Printf("\n%sold value: %s", prefix, old_summary_cstr);
}

```

This way we don't ever print "old value: " when there is no value or summary...


Repository:
  rL LLVM

http://reviews.llvm.org/D13202





More information about the lldb-commits mailing list