================ @@ -266,33 +268,73 @@ void Watchpoint::Dump(Stream *s) const { // If prefix is nullptr, we display the watch id and ignore the prefix // altogether. -void Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const { - if (!prefix) { - s->Printf("\nWatchpoint %u hit:", GetID()); - prefix = ""; - } +bool Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const { + bool printed_anything = false; + + // For read watchpoints, don't display any before/after value changes. + if (m_watch_read && !m_watch_modify && !m_watch_write) + return printed_anything; + + s->Printf("\n"); + s->Printf("Watchpoint %u hit:\n", GetID()); + + StreamString values_ss; + if (prefix) + values_ss.Indent(prefix); if (m_old_value_sp) { 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 { + if (old_value_cstr) { + values_ss.Printf("old value: %s", 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); + if (old_summary_cstr) + values_ss.Printf("old value: %s", old_summary_cstr); + else { + StreamString strm; + DumpValueObjectOptions options; + options.SetUseDynamicType(eNoDynamicValues) + .SetHideRootType(true) + .SetHideRootName(true) + .SetHideName(true); + m_old_value_sp->Dump(strm, options); + if (strm.GetData()) + values_ss.Printf("old value: %s", strm.GetData()); + } } } if (m_new_value_sp) { + if (values_ss.GetSize()) + values_ss.Printf("\n"); + const char *new_value_cstr = m_new_value_sp->GetValueAsCString(); - if (new_value_cstr && new_value_cstr[0]) - s->Printf("\n%snew value: %s", prefix, new_value_cstr); + if (new_value_cstr) + values_ss.Printf("new value: %s", new_value_cstr); ---------------- bulbazord wrote:
Same here https://github.com/llvm/llvm-project/pull/68845 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits