Lines Matching refs:jd

70 jit_emit_elf(struct jit_buf_desc *jd,  in jit_emit_elf()  argument
88 nsinfo__mountns_enter(jd->nsi, &nsc); in jit_emit_elf()
103 nsinfo__mountns_enter(jd->nsi, &nsc); in jit_emit_elf()
112 jit_close(struct jit_buf_desc *jd) in jit_close() argument
114 if (!(jd && jd->in)) in jit_close()
116 funlockfile(jd->in); in jit_close()
117 fclose(jd->in); in jit_close()
118 jd->in = NULL; in jit_close()
137 jit_open(struct jit_buf_desc *jd, const char *name) in jit_open() argument
146 nsinfo__mountns_enter(jd->nsi, &nsc); in jit_open()
147 jd->in = fopen(name, "r"); in jit_open()
149 if (!jd->in) in jit_open()
161 flockfile(jd->in); in jit_open()
163 ret = fread(buf, sizeof(header), 1, jd->in); in jit_open()
172 jd->needs_bswap = true; in jit_open()
175 if (jd->needs_bswap) { in jit_open()
184 jd->use_arch_timestamp = header.flags & JITDUMP_FLAGS_ARCH_TIMESTAMP; in jit_open()
193 jd->use_arch_timestamp); in jit_open()
207 if (jd->use_arch_timestamp && !jd->session->time_conv.time_mult) { in jit_open()
215 if (!jd->use_arch_timestamp && jit_validate_events(jd->session)) { in jit_open()
229 ret = fread(buf, bs - bsz, 1, jd->in); in jit_open()
236 strcpy(jd->dir, name); in jit_open()
237 dirname(jd->dir); in jit_open()
243 funlockfile(jd->in); in jit_open()
244 fclose(jd->in); in jit_open()
249 jit_get_next_entry(struct jit_buf_desc *jd) in jit_get_next_entry() argument
257 if (!(jd && jd->in)) in jit_get_next_entry()
260 if (jd->buf == NULL) { in jit_get_next_entry()
265 jd->buf = malloc(sz); in jit_get_next_entry()
266 if (jd->buf == NULL) in jit_get_next_entry()
269 jd->bufsize = sz; in jit_get_next_entry()
272 prefix = jd->buf; in jit_get_next_entry()
277 ret = fread(prefix, sizeof(*prefix), 1, jd->in); in jit_get_next_entry()
281 if (jd->needs_bswap) { in jit_get_next_entry()
296 if (bs > jd->bufsize) { in jit_get_next_entry()
298 n = realloc(jd->buf, bs); in jit_get_next_entry()
301 jd->buf = n; in jit_get_next_entry()
302 jd->bufsize = bs; in jit_get_next_entry()
305 addr = ((void *)jd->buf) + sizeof(*prefix); in jit_get_next_entry()
307 ret = fread(addr, bs - sizeof(*prefix), 1, jd->in); in jit_get_next_entry()
311 jr = (union jr_entry *)jd->buf; in jit_get_next_entry()
315 if (jd->needs_bswap) { in jit_get_next_entry()
327 if (jd->needs_bswap) { in jit_get_next_entry()
336 if (jd->needs_bswap) { in jit_get_next_entry()
344 jd->code_load_count++; in jit_get_next_entry()
347 if (jd->needs_bswap) { in jit_get_next_entry()
366 jit_inject_event(struct jit_buf_desc *jd, union perf_event *event) in jit_inject_event() argument
370 size = perf_data__write(jd->output, event, event->header.size); in jit_inject_event()
374 jd->bytes_written += size; in jit_inject_event()
378 static pid_t jr_entry_pid(struct jit_buf_desc *jd, union jr_entry *jr) in jr_entry_pid() argument
380 if (jd->nsi && nsinfo__in_pidns(jd->nsi)) in jr_entry_pid()
381 return nsinfo__tgid(jd->nsi); in jr_entry_pid()
385 static pid_t jr_entry_tid(struct jit_buf_desc *jd, union jr_entry *jr) in jr_entry_tid() argument
387 if (jd->nsi && nsinfo__in_pidns(jd->nsi)) in jr_entry_tid()
388 return nsinfo__pid(jd->nsi); in jr_entry_tid()
392 static uint64_t convert_timestamp(struct jit_buf_desc *jd, uint64_t timestamp) in convert_timestamp() argument
395 struct perf_record_time_conv *time_conv = &jd->session->time_conv; in convert_timestamp()
397 if (!jd->use_arch_timestamp) in convert_timestamp()
423 static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) in jit_repipe_code_load() argument
427 struct perf_tool *tool = jd->session->tool; in jit_repipe_code_load()
444 pid = jr_entry_pid(jd, jr); in jit_repipe_code_load()
445 tid = jr_entry_tid(jd, jr); in jit_repipe_code_load()
447 usize = jd->unwinding_mapped_size; in jit_repipe_code_load()
452 idr_size = jd->machine->id_hdr_size; in jit_repipe_code_load()
460 jd->dir, in jit_repipe_code_load()
468 …ret = jit_emit_elf(jd, filename, sym, addr, (const void *)uaddr, csize, jd->debug_data, jd->nr_deb… in jit_repipe_code_load()
469 jd->unwinding_data, jd->eh_frame_hdr_size, jd->unwinding_size); in jit_repipe_code_load()
471 if (jd->debug_data && jd->nr_debug_entries) { in jit_repipe_code_load()
472 zfree(&jd->debug_data); in jit_repipe_code_load()
473 jd->nr_debug_entries = 0; in jit_repipe_code_load()
476 if (jd->unwinding_data && jd->eh_frame_hdr_size) { in jit_repipe_code_load()
477 zfree(&jd->unwinding_data); in jit_repipe_code_load()
478 jd->eh_frame_hdr_size = 0; in jit_repipe_code_load()
479 jd->unwinding_mapped_size = 0; in jit_repipe_code_load()
480 jd->unwinding_size = 0; in jit_repipe_code_load()
487 if (nsinfo__stat(filename, &st, jd->nsi)) in jit_repipe_code_load()
508 if (jd->sample_type & PERF_SAMPLE_TID) { in jit_repipe_code_load()
512 if (jd->sample_type & PERF_SAMPLE_TIME) in jit_repipe_code_load()
513 id->time = convert_timestamp(jd, jr->load.p.timestamp); in jit_repipe_code_load()
526 ret = perf_event__process_mmap2(tool, event, &sample, jd->machine); in jit_repipe_code_load()
530 ret = jit_inject_event(jd, event); in jit_repipe_code_load()
535 build_id__mark_dso_hit(tool, event, &sample, NULL, jd->machine); in jit_repipe_code_load()
542 static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr) in jit_repipe_code_move() argument
546 struct perf_tool *tool = jd->session->tool; in jit_repipe_code_move()
560 pid = jr_entry_pid(jd, jr); in jit_repipe_code_move()
561 tid = jr_entry_tid(jd, jr); in jit_repipe_code_move()
562 usize = jd->unwinding_mapped_size; in jit_repipe_code_move()
563 idr_size = jd->machine->id_hdr_size; in jit_repipe_code_move()
574 jd->dir, in jit_repipe_code_move()
580 if (nsinfo__stat(filename, &st, jd->nsi)) in jit_repipe_code_move()
603 if (jd->sample_type & PERF_SAMPLE_TID) { in jit_repipe_code_move()
607 if (jd->sample_type & PERF_SAMPLE_TIME) in jit_repipe_code_move()
608 id->time = convert_timestamp(jd, jr->load.p.timestamp); in jit_repipe_code_move()
621 ret = perf_event__process_mmap2(tool, event, &sample, jd->machine); in jit_repipe_code_move()
625 ret = jit_inject_event(jd, event); in jit_repipe_code_move()
627 build_id__mark_dso_hit(tool, event, &sample, NULL, jd->machine); in jit_repipe_code_move()
632 static int jit_repipe_debug_info(struct jit_buf_desc *jd, union jr_entry *jr) in jit_repipe_debug_info() argument
637 if (!(jd && jr)) in jit_repipe_debug_info()
647 jd->debug_data = data; in jit_repipe_debug_info()
653 jd->nr_debug_entries = jr->info.nr_entry; in jit_repipe_debug_info()
659 jit_repipe_unwinding_info(struct jit_buf_desc *jd, union jr_entry *jr) in jit_repipe_unwinding_info() argument
664 if (!(jd && jr)) in jit_repipe_unwinding_info()
675 jd->eh_frame_hdr_size = jr->unwinding.eh_frame_hdr_size; in jit_repipe_unwinding_info()
676 jd->unwinding_size = jr->unwinding.unwinding_size; in jit_repipe_unwinding_info()
677 jd->unwinding_mapped_size = jr->unwinding.mapped_size; in jit_repipe_unwinding_info()
678 jd->unwinding_data = unwinding_data; in jit_repipe_unwinding_info()
684 jit_process_dump(struct jit_buf_desc *jd) in jit_process_dump() argument
689 while ((jr = jit_get_next_entry(jd))) { in jit_process_dump()
692 ret = jit_repipe_code_load(jd, jr); in jit_process_dump()
695 ret = jit_repipe_code_move(jd, jr); in jit_process_dump()
698 ret = jit_repipe_debug_info(jd, jr); in jit_process_dump()
701 ret = jit_repipe_unwinding_info(jd, jr); in jit_process_dump()
712 jit_inject(struct jit_buf_desc *jd, char *path) in jit_inject() argument
719 ret = jit_open(jd, path); in jit_inject()
723 ret = jit_process_dump(jd); in jit_inject()
725 jit_close(jd); in jit_inject()
831 struct jit_buf_desc jd; in jit_process() local
861 memset(&jd, 0, sizeof(jd)); in jit_process()
863 jd.session = session; in jit_process()
864 jd.output = output; in jit_process()
865 jd.machine = machine; in jit_process()
866 jd.nsi = nsi; in jit_process()
873 jd.sample_type = first->core.attr.sample_type; in jit_process()
877 ret = jit_inject(&jd, filename); in jit_process()
880 *nbytes = jd.bytes_written; in jit_process()
884 nsinfo__put(jd.nsi); in jit_process()
885 free(jd.buf); in jit_process()