Lines Matching full:jd

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