MCPcopy Create free account
hub / github.com/coreboot/coreboot / dump_coverage

Function dump_coverage

util/cbmem/cbmem.c:991–1039  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

989}
990
991static void dump_coverage(void)
992{
993 uint64_t start;
994 uint8_t *coverage;
995 unsigned long phys_offset;
996#define phys_to_virt(x) ((void *)(unsigned long)(x) + phys_offset)
997
998 if (!cbmem_drv_get_cbmem_entry(CBMEM_ID_COVERAGE, &coverage, NULL, &start))
999 die("No coverage information found\n");
1000
1001 /* Map coverage area */
1002 phys_offset = (unsigned long)coverage - (unsigned long)start;
1003
1004 printf("Dumping coverage data...\n");
1005
1006 struct file *file = (struct file *)coverage;
1007 while (file && file->magic == COVERAGE_MAGIC) {
1008 FILE *f;
1009 char *filename;
1010
1011 debug(" -> %s\n", (char *)phys_to_virt(file->filename));
1012 filename = strdup((char *)phys_to_virt(file->filename));
1013 if (mkpath(filename, 0755) == -1) {
1014 perror("Directory for coverage data could "
1015 "not be created");
1016 exit(1);
1017 }
1018 f = fopen(filename, "wb");
1019 if (!f) {
1020 printf("Could not open %s: %s\n",
1021 filename, strerror(errno));
1022 exit(1);
1023 }
1024 if (fwrite((void *)phys_to_virt(file->data),
1025 file->len, 1, f) != 1) {
1026 printf("Could not write to %s: %s\n",
1027 filename, strerror(errno));
1028 exit(1);
1029 }
1030 fclose(f);
1031 free(filename);
1032
1033 if (file->next)
1034 file = (struct file *)phys_to_virt(file->next);
1035 else
1036 file = NULL;
1037 }
1038 free(coverage);
1039}
1040
1041static void print_version(void)
1042{

Callers 1

mainFunction · 0.85

Calls 12

printfFunction · 0.85
mkpathFunction · 0.85
perrorFunction · 0.85
exitFunction · 0.85
fopenFunction · 0.85
strerrorFunction · 0.85
fwriteFunction · 0.85
fcloseFunction · 0.85
dieFunction · 0.50
strdupFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected