Ejemplo n.º 1
0
void
module_table_print(module_table_t *table, file_t log, bool print_all_info)
{
    uint i;
    module_entry_t *entry;
    if (log == INVALID_FILE) {
        /* It is possible that failure on log file creation is caused by the
         * running process not having enough privilege, so this is not a
         * release-build fatal error
         */
        ASSERT(false, "invalid log file");
        return;
    }
    drvector_lock(&table->vector);
    dr_fprintf(log, "Module Table: %u\n", table->vector.entries);

    if (print_all_info) {
        dr_fprintf(log, "Module Table: id, base, end, entry, unload, name, path");
#ifdef WINDOWS
        dr_fprintf(log, ", checksum, timestamp");
#endif
        dr_fprintf(log, "\n");
    }

    for (i = 0; i < table->vector.entries; i++) {
        entry = drvector_get_entry(&table->vector, i);
        module_table_entry_print(entry, log, print_all_info);
    }
    drvector_unlock(&table->vector);
}
Ejemplo n.º 2
0
drcovlib_status_t
drmodtrack_dump_buf(char *buf, size_t size) {
    uint i;
    module_entry_t *entry;
    int len;
    if (buf == NULL || size == 0)
        return DRCOVLIB_ERROR_INVALID_PARAMETER;
    size--;  /* for the terminating null character */
    drvector_lock(&module_table.vector);
    len = dr_snprintf(buf, size, "Module Table: version %u, count %u\n",
                      MODULE_FILE_VERSION, module_table.vector.entries);
    if (len == -1) {
        drvector_unlock(&module_table.vector);
        return DRCOVLIB_ERROR_BUF_TOO_SMALL;
    }
    buf += len;
    size -= len;

    len = dr_snprintf(buf, size, "Columns: id, base, end, entry");
    if (len == -1) {
        drvector_unlock(&module_table.vector);
        return DRCOVLIB_ERROR_BUF_TOO_SMALL;
    }
#ifdef WINDOWS
    buf += len;
    size -= len;

    len = dr_snprintf(buf, size, ", checksum, timestamp");
    if (len == -1) {
        drvector_unlock(&module_table.vector);
        return DRCOVLIB_ERROR_BUF_TOO_SMALL;
    }
#endif

    buf += len;
    size -= len;
    len = dr_snprintf(buf, size, ", path\n");
    if (len == -1) {
        drvector_unlock(&module_table.vector);
        return DRCOVLIB_ERROR_BUF_TOO_SMALL;
    }

    buf += len;
    size -= len;
    for (i = 0; i < module_table.vector.entries; i++) {
        entry = drvector_get_entry(&module_table.vector, i);
        len = module_table_entry_print(entry, buf, size);
        if (len == -1) {
            drvector_unlock(&module_table.vector);
            return DRCOVLIB_ERROR_BUF_TOO_SMALL;
        }
        buf += len;
        size -= len;
     }
    buf[0] = '\0';
    drvector_unlock(&module_table.vector);
    return DRCOVLIB_SUCCESS;
}