[llvm-branch-commits] [lsan] Log thread history (PR #111949)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Oct 10 21:46:15 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
Only with high verbosity, if logging requested, and leak reports.
---
Full diff: https://github.com/llvm/llvm-project/pull/111949.diff
5 Files Affected:
- (modified) compiler-rt/lib/asan/asan_thread.cpp (+7)
- (modified) compiler-rt/lib/hwasan/hwasan_thread.cpp (+6-1)
- (modified) compiler-rt/lib/lsan/lsan_common.cpp (+2)
- (modified) compiler-rt/lib/lsan/lsan_common.h (+1)
- (modified) compiler-rt/lib/lsan/lsan_thread.cpp (+4)
``````````diff
diff --git a/compiler-rt/lib/asan/asan_thread.cpp b/compiler-rt/lib/asan/asan_thread.cpp
index 0779daa107682b..37fb6f2b07f276 100644
--- a/compiler-rt/lib/asan/asan_thread.cpp
+++ b/compiler-rt/lib/asan/asan_thread.cpp
@@ -21,6 +21,7 @@
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
+#include "sanitizer_common/sanitizer_thread_history.h"
#include "sanitizer_common/sanitizer_tls_get_addr.h"
namespace __asan {
@@ -555,6 +556,12 @@ void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) {
threads);
}
+void PrintThreads() {
+ InternalScopedString out;
+ PrintThreadHistory(__asan::asanThreadRegistry(), out);
+ Report("%s\n", out.data());
+}
+
} // namespace __lsan
// ---------------------- Interface ---------------- {{{1
diff --git a/compiler-rt/lib/hwasan/hwasan_thread.cpp b/compiler-rt/lib/hwasan/hwasan_thread.cpp
index 3e14a718513d7f..8b32e4e760e2fa 100644
--- a/compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -218,6 +218,11 @@ void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) {
__hwasan::hwasanThreadArgRetval().GetAllPtrsLocked(ptrs);
}
-void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) {}
+void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) {
+ // TODO: implement.
+}
+void PrintThreads() {
+ // TODO: implement.
+}
} // namespace __lsan
diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp
index 6776598651ae9b..4fd93d4edc5639 100644
--- a/compiler-rt/lib/lsan/lsan_common.cpp
+++ b/compiler-rt/lib/lsan/lsan_common.cpp
@@ -775,6 +775,8 @@ static bool PrintResults(LeakReport &report) {
report.PrintSummary();
return true;
}
+ if (common_flags()->verbosity >= 2 && flags()->log_threads)
+ PrintThreads();
return false;
}
diff --git a/compiler-rt/lib/lsan/lsan_common.h b/compiler-rt/lib/lsan/lsan_common.h
index c598b62105873e..f990c7850497a5 100644
--- a/compiler-rt/lib/lsan/lsan_common.h
+++ b/compiler-rt/lib/lsan/lsan_common.h
@@ -111,6 +111,7 @@ void GetThreadExtraStackRangesLocked(tid_t os_id,
InternalMmapVector<Range> *ranges);
void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs);
void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads);
+void PrintThreads();
//// --------------------------------------------------------------------------
//// Allocator prototypes.
diff --git a/compiler-rt/lib/lsan/lsan_thread.cpp b/compiler-rt/lib/lsan/lsan_thread.cpp
index 07c7b923623fa9..9e481e97ac4731 100644
--- a/compiler-rt/lib/lsan/lsan_thread.cpp
+++ b/compiler-rt/lib/lsan/lsan_thread.cpp
@@ -109,6 +109,10 @@ void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) {
threads);
}
+void PrintThreads() {
+ // TODO: implement.
+}
+
void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) {
GetThreadArgRetval().GetAllPtrsLocked(ptrs);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/111949
More information about the llvm-branch-commits
mailing list