Lines Matching refs:jd

108 jit_close(struct jit_buf_desc *jd)  in jit_close()  argument
110 if (!(jd && jd->in)) in jit_close()
112 funlockfile(jd->in); in jit_close()
113 fclose(jd->in); in jit_close()
114 jd->in = NULL; in jit_close()
133 jit_open(struct jit_buf_desc *jd, const char *name) in jit_open() argument
141 jd->in = fopen(name, "r"); in jit_open()
142 if (!jd->in) in jit_open()
154 flockfile(jd->in); in jit_open()
156 ret = fread(buf, sizeof(header), 1, jd->in); in jit_open()
165 jd->needs_bswap = true; in jit_open()
168 if (jd->needs_bswap) { in jit_open()
177 jd->use_arch_timestamp = header.flags & JITDUMP_FLAGS_ARCH_TIMESTAMP; in jit_open()
186 jd->use_arch_timestamp); in jit_open()
200 if (jd->use_arch_timestamp && !jd->session->time_conv.time_mult) { in jit_open()
208 if (!jd->use_arch_timestamp && jit_validate_events(jd->session)) { in jit_open()
222 ret = fread(buf, bs - bsz, 1, jd->in); in jit_open()
229 strcpy(jd->dir, name); in jit_open()
230 dirname(jd->dir); in jit_open()
234 funlockfile(jd->in); in jit_open()
235 fclose(jd->in); in jit_open()
240 jit_get_next_entry(struct jit_buf_desc *jd) in jit_get_next_entry() argument
248 if (!(jd && jd->in)) in jit_get_next_entry()
251 if (jd->buf == NULL) { in jit_get_next_entry()
256 jd->buf = malloc(sz); in jit_get_next_entry()
257 if (jd->buf == NULL) in jit_get_next_entry()
260 jd->bufsize = sz; in jit_get_next_entry()
263 prefix = jd->buf; in jit_get_next_entry()
268 ret = fread(prefix, sizeof(*prefix), 1, jd->in); in jit_get_next_entry()
272 if (jd->needs_bswap) { in jit_get_next_entry()
287 if (bs > jd->bufsize) { in jit_get_next_entry()
289 n = realloc(jd->buf, bs); in jit_get_next_entry()
292 jd->buf = n; in jit_get_next_entry()
293 jd->bufsize = bs; in jit_get_next_entry()
296 addr = ((void *)jd->buf) + sizeof(*prefix); in jit_get_next_entry()
298 ret = fread(addr, bs - sizeof(*prefix), 1, jd->in); in jit_get_next_entry()
302 jr = (union jr_entry *)jd->buf; in jit_get_next_entry()
306 if (jd->needs_bswap) { in jit_get_next_entry()
318 if (jd->needs_bswap) { in jit_get_next_entry()
327 if (jd->needs_bswap) { in jit_get_next_entry()
335 jd->code_load_count++; in jit_get_next_entry()
338 if (jd->needs_bswap) { in jit_get_next_entry()
357 jit_inject_event(struct jit_buf_desc *jd, union perf_event *event) in jit_inject_event() argument
361 size = perf_data__write(jd->output, event, event->header.size); in jit_inject_event()
365 jd->bytes_written += size; in jit_inject_event()
369 static uint64_t convert_timestamp(struct jit_buf_desc *jd, uint64_t timestamp) in convert_timestamp() argument
373 if (!jd->use_arch_timestamp) in convert_timestamp()
376 tc.time_shift = jd->session->time_conv.time_shift; in convert_timestamp()
377 tc.time_mult = jd->session->time_conv.time_mult; in convert_timestamp()
378 tc.time_zero = jd->session->time_conv.time_zero; in convert_timestamp()
386 static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) in jit_repipe_code_load() argument
390 struct perf_tool *tool = jd->session->tool; in jit_repipe_code_load()
409 usize = jd->unwinding_mapped_size; in jit_repipe_code_load()
414 idr_size = jd->machine->id_hdr_size; in jit_repipe_code_load()
422 jd->dir, in jit_repipe_code_load()
430 …ret = jit_emit_elf(filename, sym, addr, (const void *)uaddr, csize, jd->debug_data, jd->nr_debug_e… in jit_repipe_code_load()
431 jd->unwinding_data, jd->eh_frame_hdr_size, jd->unwinding_size); in jit_repipe_code_load()
433 if (jd->debug_data && jd->nr_debug_entries) { in jit_repipe_code_load()
434 zfree(&jd->debug_data); in jit_repipe_code_load()
435 jd->nr_debug_entries = 0; in jit_repipe_code_load()
438 if (jd->unwinding_data && jd->eh_frame_hdr_size) { in jit_repipe_code_load()
439 zfree(&jd->unwinding_data); in jit_repipe_code_load()
440 jd->eh_frame_hdr_size = 0; in jit_repipe_code_load()
441 jd->unwinding_mapped_size = 0; in jit_repipe_code_load()
442 jd->unwinding_size = 0; in jit_repipe_code_load()
470 if (jd->sample_type & PERF_SAMPLE_TID) { in jit_repipe_code_load()
474 if (jd->sample_type & PERF_SAMPLE_TIME) in jit_repipe_code_load()
475 id->time = convert_timestamp(jd, jr->load.p.timestamp); in jit_repipe_code_load()
488 ret = perf_event__process_mmap2(tool, event, &sample, jd->machine); in jit_repipe_code_load()
492 ret = jit_inject_event(jd, event); in jit_repipe_code_load()
497 build_id__mark_dso_hit(tool, event, &sample, NULL, jd->machine); in jit_repipe_code_load()
502 static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr) in jit_repipe_code_move() argument
506 struct perf_tool *tool = jd->session->tool; in jit_repipe_code_move()
521 usize = jd->unwinding_mapped_size; in jit_repipe_code_move()
522 idr_size = jd->machine->id_hdr_size; in jit_repipe_code_move()
533 jd->dir, in jit_repipe_code_move()
562 if (jd->sample_type & PERF_SAMPLE_TID) { in jit_repipe_code_move()
566 if (jd->sample_type & PERF_SAMPLE_TIME) in jit_repipe_code_move()
567 id->time = convert_timestamp(jd, jr->load.p.timestamp); in jit_repipe_code_move()
580 ret = perf_event__process_mmap2(tool, event, &sample, jd->machine); in jit_repipe_code_move()
584 ret = jit_inject_event(jd, event); in jit_repipe_code_move()
586 build_id__mark_dso_hit(tool, event, &sample, NULL, jd->machine); in jit_repipe_code_move()
591 static int jit_repipe_debug_info(struct jit_buf_desc *jd, union jr_entry *jr) in jit_repipe_debug_info() argument
596 if (!(jd && jr)) in jit_repipe_debug_info()
606 jd->debug_data = data; in jit_repipe_debug_info()
612 jd->nr_debug_entries = jr->info.nr_entry; in jit_repipe_debug_info()
618 jit_repipe_unwinding_info(struct jit_buf_desc *jd, union jr_entry *jr) in jit_repipe_unwinding_info() argument
623 if (!(jd && jr)) in jit_repipe_unwinding_info()
634 jd->eh_frame_hdr_size = jr->unwinding.eh_frame_hdr_size; in jit_repipe_unwinding_info()
635 jd->unwinding_size = jr->unwinding.unwinding_size; in jit_repipe_unwinding_info()
636 jd->unwinding_mapped_size = jr->unwinding.mapped_size; in jit_repipe_unwinding_info()
637 jd->unwinding_data = unwinding_data; in jit_repipe_unwinding_info()
643 jit_process_dump(struct jit_buf_desc *jd) in jit_process_dump() argument
648 while ((jr = jit_get_next_entry(jd))) { in jit_process_dump()
651 ret = jit_repipe_code_load(jd, jr); in jit_process_dump()
654 ret = jit_repipe_code_move(jd, jr); in jit_process_dump()
657 ret = jit_repipe_debug_info(jd, jr); in jit_process_dump()
660 ret = jit_repipe_unwinding_info(jd, jr); in jit_process_dump()
671 jit_inject(struct jit_buf_desc *jd, char *path) in jit_inject() argument
678 ret = jit_open(jd, path); in jit_inject()
682 ret = jit_process_dump(jd); in jit_inject()
684 jit_close(jd); in jit_inject()
761 struct jit_buf_desc jd; in jit_process() local
770 memset(&jd, 0, sizeof(jd)); in jit_process()
772 jd.session = session; in jit_process()
773 jd.output = output; in jit_process()
774 jd.machine = machine; in jit_process()
781 jd.sample_type = first->core.attr.sample_type; in jit_process()
785 ret = jit_inject(&jd, filename); in jit_process()
787 *nbytes = jd.bytes_written; in jit_process()