17
17
#include " llvm/Support/ErrorHandling.h"
18
18
19
19
#include < map>
20
+ #include < thread>
20
21
#include < type_traits>
21
22
22
23
template <typename T,
@@ -78,6 +79,13 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
78
79
// is initialized or enabled.
79
80
// #define LLDB_REPRO_INSTR_TRACE
80
81
82
+ #ifdef LLDB_REPRO_INSTR_TRACE
83
+ inline llvm::raw_ostream &this_thread_id () {
84
+ size_t tid = std::hash<std::thread::id>{}(std::this_thread::get_id ());
85
+ return llvm::errs ().write_hex (tid) << " :: " ;
86
+ }
87
+ #endif
88
+
81
89
#define LLDB_REGISTER_CONSTRUCTOR (Class, Signature ) \
82
90
R.Register<Class * Signature>(&construct<Class Signature>::record, " " , \
83
91
#Class, #Class, #Signature)
@@ -600,8 +608,8 @@ class Serializer {
600
608
// / objects (in which case we serialize their index).
601
609
template <typename T> void Serialize (T *t) {
602
610
#ifdef LLDB_REPRO_INSTR_TRACE
603
- llvm::errs () << " Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
604
- << stringify_args (t) << " \n " ;
611
+ this_thread_id () << " Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
612
+ << stringify_args (t) << " \n " ;
605
613
#endif
606
614
if (std::is_fundamental<T>::value) {
607
615
Serialize (*t);
@@ -616,8 +624,8 @@ class Serializer {
616
624
// / to objects (in which case we serialize their index).
617
625
template <typename T> void Serialize (T &t) {
618
626
#ifdef LLDB_REPRO_INSTR_TRACE
619
- llvm::errs () << " Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
620
- << stringify_args (t) << " \n " ;
627
+ this_thread_id () << " Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
628
+ << stringify_args (t) << " \n " ;
621
629
#endif
622
630
if (is_trivially_serializable<T>::value) {
623
631
m_stream.write (reinterpret_cast <const char *>(&t), sizeof (T));
@@ -637,8 +645,8 @@ class Serializer {
637
645
638
646
void Serialize (const char *t) {
639
647
#ifdef LLDB_REPRO_INSTR_TRACE
640
- llvm::errs () << " Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
641
- << stringify_args (t) << " \n " ;
648
+ this_thread_id () << " Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
649
+ << stringify_args (t) << " \n " ;
642
650
#endif
643
651
const size_t size = t ? strlen (t) : std::numeric_limits<size_t >::max ();
644
652
Serialize (size);
@@ -842,8 +850,8 @@ class Recorder {
842
850
843
851
#ifdef LLDB_REPRO_INSTR_TRACE
844
852
void Log (unsigned id) {
845
- llvm::errs () << " Recording " << id << " : " << m_pretty_func << " ("
846
- << m_pretty_args << " )\n " ;
853
+ this_thread_id () << " Recording " << id << " : " << m_pretty_func << " ("
854
+ << m_pretty_args << " )\n " ;
847
855
}
848
856
#endif
849
857
0 commit comments