be->max_sz = 0;
}
+static void
+buffer_ext_exit(struct buffer_ext *be)
+{
+ free(be->data);
+}
+
static inline size_t
buffer_ext_size(struct buffer_ext *be)
{
Elf_Scn *scn;
Elf_Shdr *shdr;
struct buffer_ext dl, di, da;
- int ret;
+ int ret = -1;
buffer_ext_init(&dl);
buffer_ext_init(&di);
buffer_ext_init(&da);
- ret = jit_process_debug_info(code_addr, debug, nr_debug_entries, &dl, &da, &di);
- if (ret)
- return -1;
+ if (jit_process_debug_info(code_addr, debug, nr_debug_entries, &dl, &da, &di))
+ goto out;
+
/*
* setup .debug_line section
*/
scn = elf_newscn(e);
if (!scn) {
warnx("cannot create section");
- return -1;
+ goto out;
}
d = elf_newdata(scn);
if (!d) {
warnx("cannot get new data");
- return -1;
+ goto out;
}
d->d_align = 1;
shdr = elf_getshdr(scn);
if (!shdr) {
warnx("cannot get section header");
- return -1;
+ goto out;
}
shdr->sh_name = 52; /* .debug_line */
scn = elf_newscn(e);
if (!scn) {
warnx("cannot create section");
- return -1;
+ goto out;
}
d = elf_newdata(scn);
if (!d) {
warnx("cannot get new data");
- return -1;
+ goto out;
}
d->d_align = 1;
shdr = elf_getshdr(scn);
if (!shdr) {
warnx("cannot get section header");
- return -1;
+ goto out;
}
shdr->sh_name = 64; /* .debug_info */
scn = elf_newscn(e);
if (!scn) {
warnx("cannot create section");
- return -1;
+ goto out;
}
d = elf_newdata(scn);
if (!d) {
warnx("cannot get new data");
- return -1;
+ goto out;
}
d->d_align = 1;
shdr = elf_getshdr(scn);
if (!shdr) {
warnx("cannot get section header");
- return -1;
+ goto out;
}
shdr->sh_name = 76; /* .debug_info */
/*
* now we update the ELF image with all the sections
*/
- if (elf_update(e, ELF_C_WRITE) < 0) {
+ if (elf_update(e, ELF_C_WRITE) < 0)
warnx("elf_update debug failed");
- return -1;
- }
- return 0;
+ else
+ ret = 0;
+
+out:
+ buffer_ext_exit(&dl);
+ buffer_ext_exit(&di);
+ buffer_ext_exit(&da);
+ return ret;
}
*/
strcpy(jd->dir, name);
dirname(jd->dir);
+ free(buf);
return 0;
error:
+ free(buf);
funlockfile(jd->in);
fclose(jd->in);
return retval;
ret = perf_event__process_mmap2(tool, event, &sample, jd->machine);
if (ret)
- return ret;
+ goto out;
ret = jit_inject_event(jd, event);
/*
if (!ret)
build_id__mark_dso_hit(tool, event, &sample, NULL, jd->machine);
+out:
+ free(event);
return ret;
}
}
nsinfo__put(jd.nsi);
+ free(jd.buf);
return ret;
}