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. */
| 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. */ |
| 1539 | static 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 | |
| 1565 | static void tf_coverage_exit_now(int status) __attribute__((noreturn)); |
| 1566 | static void tf_coverage_exit_now(int status) { |
nothing calls this directly
no test coverage detected