bool gcov_read_record(int fd, struct gcov_record *rec) { ssize_t r; r = gcov_read(fd, &rec->hdr, sizeof rec->hdr); if (r < sizeof rec->hdr) { return false; } r = gcov_read(fd, &rec->data.u8[0], rec->hdr.length * 4); if (r < rec->hdr.length * 4) { return false; } return true; }
int main(int argc, char **argv) { int opt; while ((opt = getopt(argc, argv, "h")) != -1) { switch (opt) { case 'h': usage(0); break; default: usage(1); } } argv += optind; argc -= optind; if (argc <= 0) usage(1); xch = xc_interface_open(NULL, NULL, 0); if (!xch) err(1, "opening xc interface"); if (strcmp(argv[0], "reset") == 0) gcov_reset(); else if (strcmp(argv[0], "read") == 0) gcov_read(argc > 1 ? argv[1] : "-"); else usage(1); xc_interface_close(xch); return 0; }
bool gcov_read_file_header(int fd, struct gcov_file_header *h) { ssize_t r; r = gcov_read(fd, h, sizeof *h); if (r < 0) return false; return true; }