MCPcopy Create free account
hub / github.com/F-Stack/f-stack / kcov_thread_dtor

Function kcov_thread_dtor

freebsd/kern/kern_kcov.c:517–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

515}
516
517static void
518kcov_thread_dtor(void *arg __unused, struct thread *td)
519{
520 struct kcov_info *info;
521
522 info = td->td_kcov_info;
523 if (info == NULL)
524 return;
525
526 mtx_lock_spin(&kcov_lock);
527 KASSERT(active_count > 0, ("%s: Open count is zero", __func__));
528 active_count--;
529 if (active_count == 0) {
530 cov_unregister_pc();
531 cov_unregister_cmp();
532 }
533 td->td_kcov_info = NULL;
534 if (info->state != KCOV_STATE_DYING) {
535 /*
536 * The kcov file is still open. Mark it as unused and
537 * wait for it to be closed before cleaning up.
538 */
539 atomic_store_int(&info->state, KCOV_STATE_READY);
540 atomic_thread_fence_seq_cst();
541 /* This info struct is unused */
542 info->thread = NULL;
543 mtx_unlock_spin(&kcov_lock);
544 return;
545 }
546 mtx_unlock_spin(&kcov_lock);
547
548 /*
549 * We can safely clean up the info struct as it is in the
550 * KCOV_STATE_DYING state where the info struct is associated with
551 * the current thread that's about to exit.
552 *
553 * The KCOV_STATE_DYING stops new threads from using it.
554 * It also stops the current thread from trying to use the info struct.
555 */
556 kcov_free(info);
557}
558
559static void
560kcov_init(const void *unused)

Callers

nothing calls this directly

Calls 4

cov_unregister_pcFunction · 0.85
cov_unregister_cmpFunction · 0.85
kcov_freeFunction · 0.85

Tested by

no test coverage detected