Author: Jonas Devlieghere Date: 2020-02-04T16:24:38-08:00 New Revision: 7ac9443002949a01c992691760588eaaf88e4f41
URL: https://github.com/llvm/llvm-project/commit/7ac9443002949a01c992691760588eaaf88e4f41 DIFF: https://github.com/llvm/llvm-project/commit/7ac9443002949a01c992691760588eaaf88e4f41.diff LOG: [lldb/Reproducers] Change record logging to mirror replay logging Pretty printing the return value, although a good idea in theory, turned out to be more confusing than anything else because they require printing the log statement after the arguments and resulting value have been serialized. This changes the logging to behave more like how deserialization is traced, although a bit more verbose because some of the serializers are are calling each other. Added: Modified: lldb/include/lldb/Utility/ReproducerInstrumentation.h Removed: ################################################################################ diff --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h index 2f8de5cbd3db..0bb12047f1ff 100644 --- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h +++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h @@ -571,6 +571,10 @@ class Serializer { /// fundamental types (in which case we serialize its value) and pointer to /// objects (in which case we serialize their index). template <typename T> void Serialize(T *t) { +#ifdef LLDB_REPRO_INSTR_TRACE + llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> " + << stringify_args(t) << "\n"; +#endif if (std::is_fundamental<T>::value) { Serialize(*t); } else { @@ -583,6 +587,10 @@ class Serializer { /// fundamental types (in which case we serialize its value) and references /// to objects (in which case we serialize their index). template <typename T> void Serialize(T &t) { +#ifdef LLDB_REPRO_INSTR_TRACE + llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> " + << stringify_args(t) << "\n"; +#endif if (is_trivially_serializable<T>::value) { m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T)); } else { @@ -597,6 +605,10 @@ class Serializer { } void Serialize(const char *t) { +#ifdef LLDB_REPRO_INSTR_TRACE + llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> " + << stringify_args(t) << "\n"; +#endif const size_t size = t ? strlen(t) : std::numeric_limits<size_t>::max(); Serialize(size); if (t) { @@ -673,6 +685,10 @@ class Recorder { unsigned id = registry.GetID(uintptr_t(f)); +#ifdef LLDB_REPRO_INSTR_TRACE + Log(id); +#endif + serializer.SerializeAll(id); serializer.SerializeAll(args...); @@ -684,9 +700,6 @@ class Recorder { m_result_recorded = true; } -#ifdef LLDB_REPRO_INSTR_TRACE - Log(id, m_result_recorded); -#endif } /// Records a single function call. @@ -699,6 +712,10 @@ class Recorder { unsigned id = registry.GetID(uintptr_t(f)); +#ifdef LLDB_REPRO_INSTR_TRACE + Log(id); +#endif + serializer.SerializeAll(id); serializer.SerializeAll(args...); @@ -706,9 +723,6 @@ class Recorder { serializer.SerializeAll(0); m_result_recorded = true; -#ifdef LLDB_REPRO_INSTR_TRACE - Log(id, true); -#endif } /// Record the result of a function call. @@ -726,9 +740,6 @@ class Recorder { assert(!m_result_recorded); m_serializer->SerializeAll(r); m_result_recorded = true; -#ifdef LLDB_REPRO_INSTR_TRACE - llvm::errs() << " -> " << stringify_args(r) << '\n'; -#endif } return std::forward<Result>(r); } @@ -742,11 +753,9 @@ class Recorder { bool ShouldCapture() { return m_local_boundary; } #ifdef LLDB_REPRO_INSTR_TRACE - void Log(unsigned id, bool newline) { + void Log(unsigned id) { llvm::errs() << "Recording " << id << ": " << m_pretty_func << " (" - << m_pretty_args << ")"; - if (newline) - llvm::errs() << '\n'; + << m_pretty_args << ")\n"; } #endif _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits