void MR_trace_report_raw(int fd) { char buf[80]; /* that ought to be more than long enough */ int ret; if (MR_trace_event_number > 0) { /* ** This means that the executable was compiled with tracing, ** which implies that the user wants trace info on abort. */ if (MR_trace_report_msg != NULL) { do { /* XXX we don't handle successful but partial writes */ ret = write(fd, MR_trace_report_msg, strlen(MR_trace_report_msg)); } while (ret == -1 && MR_is_eintr(errno)); } if (MR_standardize_event_details) { sprintf(buf, "Last trace event was event #E%ld.\n", (long) MR_standardize_event_num(MR_trace_event_number)); } else { sprintf(buf, "Last trace event was event #%ld.\n", (long) MR_trace_event_number); } do { /* XXX we don't handle successful but partial writes */ ret = write(fd, buf, strlen(buf)); } while (ret == -1 && MR_is_eintr(errno)); } }
void MR_trace_report(FILE *fp) { if (MR_trace_event_number > 0) { // This means that the executable was compiled with tracing, // which implies that the user wants trace info on abort. if (MR_trace_report_msg != NULL) { fprintf(fp, "%s\n", MR_trace_report_msg); } if (MR_standardize_event_details) { fprintf(fp, "Last trace event was event #E%ld.\n", (long) MR_standardize_event_num(MR_trace_event_number)); } else { fprintf(fp, "Last trace event was event #%ld.\n", (long) MR_trace_event_number); } #ifdef MR_TRACE_HISTOGRAM { FILE *hfp; char errbuf[MR_STRERROR_BUF_SIZE]; hfp = fopen(MR_TRACE_HISTOGRAM_FILENAME, "w"); if (hfp != NULL) { MR_trace_print_histogram(hfp, "All-inclusive", MR_trace_histogram_all, MR_trace_histogram_hwm); if (fclose(hfp) == 0) { fprintf(fp, "Event histogram put into file `%s'.\n", MR_TRACE_HISTOGRAM_FILENAME); } else { fprintf(fp, "Cannot put event histogram into `%s': %s." MR_TRACE_HISTOGRAM_FILENAME, MR_strerror(errno, errbuf, sizeof(errbuf))); } } else { fprintf(fp, "Cannot open `%s': %s.\n" MR_TRACE_HISTOGRAM_FILENAME, MR_strerror(errno, errbuf, sizeof(errbuf))); } } #endif // MR_TRACE_HISTOGRAM } }