Re: [PATCH v4 3/4] perf inject: add jitdump mmap injection support

From: Adrian Hunter
Date: Thu Mar 26 2015 - 04:02:26 EST


<SNIP>

> +static int
> +jit_open(struct jit_buf_desc *jd, const char *name)
> +{
> + struct jitheader header;
> + struct jr_prefix *prefix;
> + ssize_t bs, bsz = 0;
> + void *n, *buf = NULL;
> + int ret, retval = -1;
> +
> + jd->in = fopen(name, "r");
> + if (!jd->in)
> + return -1;
> +
> + bsz = hmax(sizeof(header), sizeof(*prefix));
> +
> + buf = malloc(bsz);
> + if (!buf)
> + goto error;
> +
> + ret = fread(buf, sizeof(header), 1, jd->in);
> + if (ret != 1)
> + goto error;
> +
> + memcpy(&header, buf, sizeof(header));
> +
> + if (header.magic != JITHEADER_MAGIC) {
> + if (header.magic != JITHEADER_MAGIC_SW)
> + goto error;
> + jd->needs_bswap = 1;
> + }
> +
> + if (jd->needs_bswap) {
> + header.version = bswap_32(header.version);
> + header.total_size = bswap_32(header.total_size);
> + header.pid = bswap_32(header.pid);
> + header.elf_mach = bswap_32(header.elf_mach);
> + header.timestamp = bswap_32(header.timestamp);

timestamp is 64-bit


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/