forked from OSchip/llvm-project
[lldb] Include thread id in the reproducer trace (NFC)
Include the current thread ID in the reproducer trace during capture/recording.
This commit is contained in:
parent
6e614b0c7e
commit
33e3b07af3
|
@ -17,6 +17,7 @@
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <thread>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
template <typename T,
|
template <typename T,
|
||||||
|
@ -78,6 +79,13 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
|
||||||
// is initialized or enabled.
|
// is initialized or enabled.
|
||||||
// #define LLDB_REPRO_INSTR_TRACE
|
// #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) \
|
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature) \
|
||||||
R.Register<Class * Signature>(&construct<Class Signature>::record, "", \
|
R.Register<Class * Signature>(&construct<Class Signature>::record, "", \
|
||||||
#Class, #Class, #Signature)
|
#Class, #Class, #Signature)
|
||||||
|
@ -600,8 +608,8 @@ private:
|
||||||
/// objects (in which case we serialize their index).
|
/// objects (in which case we serialize their index).
|
||||||
template <typename T> void Serialize(T *t) {
|
template <typename T> void Serialize(T *t) {
|
||||||
#ifdef LLDB_REPRO_INSTR_TRACE
|
#ifdef LLDB_REPRO_INSTR_TRACE
|
||||||
llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
|
this_thread_id() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
|
||||||
<< stringify_args(t) << "\n";
|
<< stringify_args(t) << "\n";
|
||||||
#endif
|
#endif
|
||||||
if (std::is_fundamental<T>::value) {
|
if (std::is_fundamental<T>::value) {
|
||||||
Serialize(*t);
|
Serialize(*t);
|
||||||
|
@ -616,8 +624,8 @@ private:
|
||||||
/// to objects (in which case we serialize their index).
|
/// to objects (in which case we serialize their index).
|
||||||
template <typename T> void Serialize(T &t) {
|
template <typename T> void Serialize(T &t) {
|
||||||
#ifdef LLDB_REPRO_INSTR_TRACE
|
#ifdef LLDB_REPRO_INSTR_TRACE
|
||||||
llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
|
this_thread_id() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
|
||||||
<< stringify_args(t) << "\n";
|
<< stringify_args(t) << "\n";
|
||||||
#endif
|
#endif
|
||||||
if (is_trivially_serializable<T>::value) {
|
if (is_trivially_serializable<T>::value) {
|
||||||
m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T));
|
m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T));
|
||||||
|
@ -637,8 +645,8 @@ private:
|
||||||
|
|
||||||
void Serialize(const char *t) {
|
void Serialize(const char *t) {
|
||||||
#ifdef LLDB_REPRO_INSTR_TRACE
|
#ifdef LLDB_REPRO_INSTR_TRACE
|
||||||
llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
|
this_thread_id() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
|
||||||
<< stringify_args(t) << "\n";
|
<< stringify_args(t) << "\n";
|
||||||
#endif
|
#endif
|
||||||
const size_t size = t ? strlen(t) : std::numeric_limits<size_t>::max();
|
const size_t size = t ? strlen(t) : std::numeric_limits<size_t>::max();
|
||||||
Serialize(size);
|
Serialize(size);
|
||||||
|
@ -842,8 +850,8 @@ private:
|
||||||
|
|
||||||
#ifdef LLDB_REPRO_INSTR_TRACE
|
#ifdef LLDB_REPRO_INSTR_TRACE
|
||||||
void Log(unsigned id) {
|
void Log(unsigned id) {
|
||||||
llvm::errs() << "Recording " << id << ": " << m_pretty_func << " ("
|
this_thread_id() << "Recording " << id << ": " << m_pretty_func << " ("
|
||||||
<< m_pretty_args << ")\n";
|
<< m_pretty_args << ")\n";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue