MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / tf_coverage_fork_child

Function tf_coverage_fork_child

tests/test_main.c:1539–1563  ·  view source on GitHub ↗

Runs in the child of every fork() of this image. Only what is safe between * fork and exec of a threaded process: no allocation, static buffers. */

Source from the content-addressed store, hash-verified

1537/* Runs in the child of every fork() of this image. Only what is safe between
1538 * fork and exec of a threaded process: no allocation, static buffers. */
1539static void tf_coverage_fork_child(void) {
1540 static const char tail[] = ".%p%c.profraw";
1541 tf_coverage_fork_marker[0] = '\0';
1542 if (tf_coverage_continuous) {
1543 return; /* the counters are mapped onto the file of the parent */
1544 }
1545 const char *pattern = getenv("LLVM_PROFILE_FILE");
1546 size_t length = pattern ? strlen(pattern) : 0;
1547 if (length <= sizeof(tail) - 1 || strcmp(pattern + length - (sizeof(tail) - 1), tail) != 0) {
1548 return; /* not a coverage run */
1549 }
1550 int stem = (int)(length - (sizeof(tail) - 1));
1551 long pid = (long)getpid();
1552 int profile_length = snprintf(tf_coverage_fork_profile, sizeof(tf_coverage_fork_profile),
1553 "%.*s.%ld.profraw", stem, pattern, pid);
1554 int marker_length = snprintf(tf_coverage_fork_marker, sizeof(tf_coverage_fork_marker),
1555 "%.*s.%ld.forked", stem, pattern, pid);
1556 if (profile_length <= 0 || (size_t)profile_length >= sizeof(tf_coverage_fork_profile) ||
1557 marker_length <= 0 || (size_t)marker_length >= sizeof(tf_coverage_fork_marker)) {
1558 tf_coverage_fork_marker[0] = '\0';
1559 return;
1560 }
1561 __llvm_profile_set_filename(tf_coverage_fork_profile);
1562 tf_coverage_fork_marker_place();
1563}
1564
1565static void tf_coverage_exit_now(int status) __attribute__((noreturn));
1566static void tf_coverage_exit_now(int status) {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected