Lines Matching refs:jd

109 jit_close(struct jit_buf_desc *jd)
111 if (!(jd && jd->in))
113 funlockfile(jd->in);
114 fclose(jd->in);
115 jd->in = NULL;
134 jit_open(struct jit_buf_desc *jd, const char *name)
142 jd->in = fopen(name, "r");
143 if (!jd->in)
155 flockfile(jd->in);
157 ret = fread(buf, sizeof(header), 1, jd->in);
166 jd->needs_bswap = true;
169 if (jd->needs_bswap) {
178 jd->use_arch_timestamp = header.flags & JITDUMP_FLAGS_ARCH_TIMESTAMP;
187 jd->use_arch_timestamp);
201 if (jd->use_arch_timestamp && !jd->session->time_conv.time_mult) {
209 if (!jd->use_arch_timestamp && jit_validate_events(jd->session)) {
223 ret = fread(buf, bs - bsz, 1, jd->in);
230 strcpy(jd->dir, name);
231 dirname(jd->dir);
235 funlockfile(jd->in);
236 fclose(jd->in);
241 jit_get_next_entry(struct jit_buf_desc *jd)
249 if (!(jd && jd->in))
252 if (jd->buf == NULL) {
257 jd->buf = malloc(sz);
258 if (jd->buf == NULL)
261 jd->bufsize = sz;
264 prefix = jd->buf;
269 ret = fread(prefix, sizeof(*prefix), 1, jd->in);
273 if (jd->needs_bswap) {
288 if (bs > jd->bufsize) {
290 n = realloc(jd->buf, bs);
293 jd->buf = n;
294 jd->bufsize = bs;
297 addr = ((void *)jd->buf) + sizeof(*prefix);
299 ret = fread(addr, bs - sizeof(*prefix), 1, jd->in);
303 jr = (union jr_entry *)jd->buf;
307 if (jd->needs_bswap) {
319 if (jd->needs_bswap) {
328 if (jd->needs_bswap) {
336 jd->code_load_count++;
339 if (jd->needs_bswap) {
358 jit_inject_event(struct jit_buf_desc *jd, union perf_event *event)
362 size = perf_data__write(jd->output, event, event->header.size);
366 jd->bytes_written += size;
370 static uint64_t convert_timestamp(struct jit_buf_desc *jd, uint64_t timestamp)
373 struct perf_record_time_conv *time_conv = &jd->session->time_conv;
375 if (!jd->use_arch_timestamp)
401 static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr)
405 struct perf_tool *tool = jd->session->tool;
424 usize = jd->unwinding_mapped_size;
429 idr_size = jd->machine->id_hdr_size;
437 jd->dir,
445 ret = jit_emit_elf(filename, sym, addr, (const void *)uaddr, csize, jd->debug_data, jd->nr_debug_entries,
446 jd->unwinding_data, jd->eh_frame_hdr_size, jd->unwinding_size);
448 if (jd->debug_data && jd->nr_debug_entries) {
449 zfree(&jd->debug_data);
450 jd->nr_debug_entries = 0;
453 if (jd->unwinding_data && jd->eh_frame_hdr_size) {
454 zfree(&jd->unwinding_data);
455 jd->eh_frame_hdr_size = 0;
456 jd->unwinding_mapped_size = 0;
457 jd->unwinding_size = 0;
485 if (jd->sample_type & PERF_SAMPLE_TID) {
489 if (jd->sample_type & PERF_SAMPLE_TIME)
490 id->time = convert_timestamp(jd, jr->load.p.timestamp);
503 ret = perf_event__process_mmap2(tool, event, &sample, jd->machine);
507 ret = jit_inject_event(jd, event);
512 build_id__mark_dso_hit(tool, event, &sample, NULL, jd->machine);
517 static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr)
521 struct perf_tool *tool = jd->session->tool;
536 usize = jd->unwinding_mapped_size;
537 idr_size = jd->machine->id_hdr_size;
548 jd->dir,
577 if (jd->sample_type & PERF_SAMPLE_TID) {
581 if (jd->sample_type & PERF_SAMPLE_TIME)
582 id->time = convert_timestamp(jd, jr->load.p.timestamp);
595 ret = perf_event__process_mmap2(tool, event, &sample, jd->machine);
599 ret = jit_inject_event(jd, event);
601 build_id__mark_dso_hit(tool, event, &sample, NULL, jd->machine);
606 static int jit_repipe_debug_info(struct jit_buf_desc *jd, union jr_entry *jr)
611 if (!(jd && jr))
621 jd->debug_data = data;
627 jd->nr_debug_entries = jr->info.nr_entry;
633 jit_repipe_unwinding_info(struct jit_buf_desc *jd, union jr_entry *jr)
638 if (!(jd && jr))
649 jd->eh_frame_hdr_size = jr->unwinding.eh_frame_hdr_size;
650 jd->unwinding_size = jr->unwinding.unwinding_size;
651 jd->unwinding_mapped_size = jr->unwinding.mapped_size;
652 jd->unwinding_data = unwinding_data;
658 jit_process_dump(struct jit_buf_desc *jd)
663 while ((jr = jit_get_next_entry(jd))) {
666 ret = jit_repipe_code_load(jd, jr);
669 ret = jit_repipe_code_move(jd, jr);
672 ret = jit_repipe_debug_info(jd, jr);
675 ret = jit_repipe_unwinding_info(jd, jr);
686 jit_inject(struct jit_buf_desc *jd, char *path)
693 ret = jit_open(jd, path);
697 ret = jit_process_dump(jd);
699 jit_close(jd);
798 struct jit_buf_desc jd;
812 memset(&jd, 0, sizeof(jd));
814 jd.session = session;
815 jd.output = output;
816 jd.machine = machine;
823 jd.sample_type = first->core.attr.sample_type;
827 ret = jit_inject(&jd, filename);
830 *nbytes = jd.bytes_written;