forked from OSchip/llvm-project
[NFC] Extract ForEachDVT
This commit is contained in:
parent
e27e3ba9c9
commit
adfefa5553
|
@ -315,15 +315,15 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
|
|||
__libc_iterate_dynamic_tls(os_id, cb, frontier);
|
||||
#else
|
||||
if (dtls && !DTLSInDestruction(dtls)) {
|
||||
for (uptr j = 0; j < dtls->dtv_size; ++j) {
|
||||
uptr dtls_beg = dtls->dtv[j].beg;
|
||||
uptr dtls_end = dtls_beg + dtls->dtv[j].size;
|
||||
ForEachDVT(dtls, [&](const DTLS::DTV &dtv, int id) {
|
||||
uptr dtls_beg = dtv.beg;
|
||||
uptr dtls_end = dtls_beg + dtv.size;
|
||||
if (dtls_beg < dtls_end) {
|
||||
LOG_THREADS("DTLS %zu at %p-%p.\n", j, dtls_beg, dtls_end);
|
||||
LOG_THREADS("DTLS %zu at %p-%p.\n", id, dtls_beg, dtls_end);
|
||||
ScanRangeForPointers(dtls_beg, dtls_end, frontier, "DTLS",
|
||||
kReachable);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// We are handling a thread with DTLS under destruction. Log about
|
||||
// this and continue.
|
||||
|
|
|
@ -37,8 +37,9 @@ void MsanThread::ClearShadowForThreadStackAndTLS() {
|
|||
__msan_unpoison((void *)tls_begin_, tls_end_ - tls_begin_);
|
||||
DTLS *dtls = DTLS_Get();
|
||||
CHECK_NE(dtls, 0);
|
||||
for (uptr i = 0; i < dtls->dtv_size; ++i)
|
||||
__msan_unpoison((void *)(dtls->dtv[i].beg), dtls->dtv[i].size);
|
||||
ForEachDVT(dtls, [](const DTLS::DTV &dtv, int id) {
|
||||
__msan_unpoison((void *)(dtv.beg), dtv.size);
|
||||
});
|
||||
}
|
||||
|
||||
void MsanThread::Init() {
|
||||
|
|
|
@ -47,6 +47,11 @@ struct DTLS {
|
|||
uptr last_memalign_ptr;
|
||||
};
|
||||
|
||||
template <typename Fn>
|
||||
void ForEachDVT(DTLS *dtls, const Fn &fn) {
|
||||
for (uptr j = 0; j < dtls->dtv_size; ++j) fn(dtls->dtv[j], j);
|
||||
}
|
||||
|
||||
// Returns pointer and size of a linker-allocated TLS block.
|
||||
// Each block is returned exactly once.
|
||||
DTLS::DTV *DTLS_on_tls_get_addr(void *arg, void *res, uptr static_tls_begin,
|
||||
|
|
Loading…
Reference in New Issue