drcovlib_status_t drmodtrack_dump(file_t log) { drcovlib_status_t res; size_t size = 200 + module_table.vector.entries * (MAXIMUM_PATH + 40); char *buf; do { buf = dr_global_alloc(size); res = drmodtrack_dump_buf(buf, size); if (res == DRCOVLIB_SUCCESS) dr_write_file(log, buf, strlen(buf)); dr_global_free(buf, size); size *= 2; } while (res == DRCOVLIB_ERROR_BUF_TOO_SMALL); return res; }
offline_instru_t::~offline_instru_t() { drcovlib_status_t res; size_t size = 8192; char *buf; size_t wrote; do { buf = (char *)dr_global_alloc(size); res = drmodtrack_dump_buf(buf, size, &wrote); if (res == DRCOVLIB_SUCCESS) { ssize_t written = write_file_func(modfile, buf, wrote - 1/*no null*/); DR_ASSERT(written == (ssize_t)strlen(buf)); } dr_global_free(buf, size); size *= 2; } while (res == DRCOVLIB_ERROR_BUF_TOO_SMALL); res = drmodtrack_exit(); DR_ASSERT(res == DRCOVLIB_SUCCESS); }