Created
April 3, 2022 02:33
-
-
Save tqinli/e49cf8b0d21481089c8f196b303810b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/debug/createdump/crashinfo.cpp b/src/debug/createdump/crashinfo.cpp | |
index 7b5c20bf64..7902c7b5c2 100644 | |
--- a/src/debug/createdump/crashinfo.cpp | |
+++ b/src/debug/createdump/crashinfo.cpp | |
@@ -99,6 +99,22 @@ CrashInfo::EnumMemoryRegion( | |
// | |
bool | |
CrashInfo::EnumerateAndSuspendThreads() | |
+{ | |
+ std::set<pid_t> suspendedTaskIds; | |
+ int beforeSize, afterSize; | |
+ do | |
+ { | |
+ beforeSize = suspendedTaskIds.size(); | |
+ bool ret = EnumerateAndSuspendThreadsOneIteration(suspendedTaskIds); | |
+ if (!ret) return false; | |
+ afterSize = suspendedTaskIds.size(); | |
+ } | |
+ while (beforeSize < afterSize); | |
+ return beforeSize == afterSize; | |
+} | |
+ | |
+bool | |
+CrashInfo::EnumerateAndSuspendThreadsOneIteration(std::set<pid_t> &suspendedTaskIds) | |
{ | |
char taskPath[128]; | |
snprintf(taskPath, sizeof(taskPath), "/proc/%d/task", m_pid); | |
@@ -116,6 +132,12 @@ CrashInfo::EnumerateAndSuspendThreads() | |
pid_t tid = static_cast<pid_t>(strtol(entry->d_name, nullptr, 10)); | |
if (tid != 0) | |
{ | |
+ if (suspendedTaskIds.find(tid) != suspendedTaskIds.end()) | |
+ { | |
+ // already suspended, continue | |
+ continue; | |
+ } | |
+ | |
// Don't suspend the threads if running under sos | |
if (!m_sos) | |
{ | |
diff --git a/src/debug/createdump/crashinfo.h b/src/debug/createdump/crashinfo.h | |
index 096f933af0..1be44b7d7a 100644 | |
--- a/src/debug/createdump/crashinfo.h | |
+++ b/src/debug/createdump/crashinfo.h | |
@@ -91,4 +91,5 @@ private: | |
uint32_t GetMemoryRegionFlags(uint64_t start); | |
bool ValidRegion(const MemoryRegion& region); | |
void CombineMemoryRegions(); | |
+ bool EnumerateAndSuspendThreadsOneIteration(std::set<pid_t> &suspendedTaskIds); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment