[llvm-branch-commits] [compiler-rt] [NFC][sanitizer] Add Debug utility to print thread history (PR #111948)
Vitaly Buka via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Oct 11 16:18:37 PDT 2024
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/111948
>From 12f4a2f8ad0583d7494b21a460b131f53541022a Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Fri, 11 Oct 2024 11:47:10 -0700
Subject: [PATCH] prev is context
Created using spr 1.3.4
---
.../sanitizer_common/sanitizer_thread_history.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_thread_history.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_thread_history.cpp
index 8d1b9ea3030eac..6a4d9bf231811f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_thread_history.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_thread_history.cpp
@@ -54,11 +54,11 @@ void PrintThreadHistory(ThreadRegistry ®istry, InternalScopedString &out) {
return parent;
};
- u32 stack_id = 0;
+ const ThreadContextBase *prev = nullptr;
for (const ThreadContextBase *context : stacks) {
- if (stack_id != context->stack_id) {
- StackDepotGet(stack_id).PrintTo(&out);
- stack_id = context->stack_id;
+ if (prev->stack_id != context->stack_id) {
+ StackDepotGet(prev->stack_id).PrintTo(&out);
+ prev = context;
}
out.Append("Thread ");
describe_thread(context);
@@ -66,8 +66,8 @@ void PrintThreadHistory(ThreadRegistry ®istry, InternalScopedString &out) {
describe_thread(get_parent(context));
out.Append("\n");
}
- if (!stacks.empty())
- StackDepotGet(stack_id).PrintTo(&out);
+ if (prev)
+ StackDepotGet(prev->stack_id).PrintTo(&out);
}
} // namespace __sanitizer
More information about the llvm-branch-commits
mailing list