[llvm-branch-commits] [lldb] 33e3b07 - [lldb] Include thread id in the reproducer trace (NFC)
Jonas Devlieghere via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Dec 7 20:39:38 PST 2020
Author: Jonas Devlieghere
Date: 2020-12-07T20:35:34-08:00
New Revision: 33e3b07af3ce9595f49c75a8af559bdec5cc19fa
URL: https://github.com/llvm/llvm-project/commit/33e3b07af3ce9595f49c75a8af559bdec5cc19fa
DIFF: https://github.com/llvm/llvm-project/commit/33e3b07af3ce9595f49c75a8af559bdec5cc19fa.diff
LOG: [lldb] Include thread id in the reproducer trace (NFC)
Include the current thread ID in the reproducer trace during
capture/recording.
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 5fc33ad1a17b..8e319d749231 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -17,6 +17,7 @@
#include "llvm/Support/ErrorHandling.h"
#include <map>
+#include <thread>
#include <type_traits>
template <typename T,
@@ -78,6 +79,13 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
// is initialized or enabled.
// #define LLDB_REPRO_INSTR_TRACE
+#ifdef LLDB_REPRO_INSTR_TRACE
+inline llvm::raw_ostream &this_thread_id() {
+ size_t tid = std::hash<std::thread::id>{}(std::this_thread::get_id());
+ return llvm::errs().write_hex(tid) << " :: ";
+}
+#endif
+
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature) \
R.Register<Class * Signature>(&construct<Class Signature>::record, "", \
#Class, #Class, #Signature)
@@ -600,8 +608,8 @@ class Serializer {
/// 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";
+ this_thread_id() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
+ << stringify_args(t) << "\n";
#endif
if (std::is_fundamental<T>::value) {
Serialize(*t);
@@ -616,8 +624,8 @@ class Serializer {
/// 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";
+ this_thread_id() << "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));
@@ -637,8 +645,8 @@ class Serializer {
void Serialize(const char *t) {
#ifdef LLDB_REPRO_INSTR_TRACE
- llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
- << stringify_args(t) << "\n";
+ this_thread_id() << "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);
@@ -842,8 +850,8 @@ class Recorder {
#ifdef LLDB_REPRO_INSTR_TRACE
void Log(unsigned id) {
- llvm::errs() << "Recording " << id << ": " << m_pretty_func << " ("
- << m_pretty_args << ")\n";
+ this_thread_id() << "Recording " << id << ": " << m_pretty_func << " ("
+ << m_pretty_args << ")\n";
}
#endif
More information about the llvm-branch-commits
mailing list