tools/perf/util/jitdump.c
Source file repositories/reference/linux-study-clean/tools/perf/util/jitdump.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/jitdump.c- Extension
.c- Size
- 21191 bytes
- Lines
- 918
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sys/sysmacros.hsys/types.herrno.hlibgen.hstdio.hstdlib.hstring.hfcntl.hunistd.hinttypes.hbyteswap.hsys/stat.hsys/mman.hlinux/stringify.hevent.hdebug.hdso.hevlist.hnamespaces.hsymbol.helf.htsc.hsession.hjit.hjitdump.hgenelf.hthread.hlinux/ctype.hlinux/zalloc.h
Detected Declarations
struct jit_buf_descstruct jit_toolfunction jit_emit_elffunction jit_closefunction jit_validate_eventsfunction jit_openfunction jit_get_next_entryfunction jit_inject_eventfunction jr_entry_pidfunction jr_entry_tidfunction convert_timestampfunction jit_repipe_code_loadfunction jit_repipe_code_movefunction jit_repipe_debug_infofunction jit_repipe_unwinding_infofunction jit_process_dumpfunction jit_injectfunction mmapfunction jit_add_pidfunction jit_has_pidfunction jit_process
Annotated Snippet
struct jit_buf_desc {
struct perf_data *output;
struct perf_session *session;
struct machine *machine;
struct nsinfo *nsi;
union jr_entry *entry;
void *buf;
uint64_t sample_type;
size_t bufsize;
FILE *in;
bool needs_bswap; /* handles cross-endianness */
bool use_arch_timestamp;
void *debug_data;
void *unwinding_data;
uint64_t unwinding_size;
uint64_t unwinding_mapped_size;
uint64_t eh_frame_hdr_size;
size_t nr_debug_entries;
uint32_t code_load_count;
u64 bytes_written;
struct rb_root code_root;
char dir[PATH_MAX];
};
struct jit_tool {
struct perf_tool tool;
struct perf_data output;
struct perf_data input;
u64 bytes_written;
};
#define hmax(a, b) ((a) > (b) ? (a) : (b))
#define get_jit_tool(t) (container_of(tool, struct jit_tool, tool))
static int
jit_emit_elf(struct jit_buf_desc *jd,
char *filename,
const char *sym,
uint64_t code_addr,
const void *code,
int csize,
void *debug,
int nr_debug_entries,
void *unwinding,
uint32_t unwinding_header_size,
uint32_t unwinding_size)
{
int ret, fd, saved_errno;
struct nscookie nsc;
if (verbose > 0)
fprintf(stderr, "write ELF image %s\n", filename);
nsinfo__mountns_enter(jd->nsi, &nsc);
fd = open(filename, O_CREAT|O_TRUNC|O_WRONLY, 0644);
saved_errno = errno;
nsinfo__mountns_exit(&nsc);
if (fd == -1) {
errno = saved_errno;
pr_warning("cannot create jit ELF %s: %m\n", filename);
return -1;
}
ret = jit_write_elf(fd, code_addr, sym, (const void *)code, csize, debug, nr_debug_entries,
unwinding, unwinding_header_size, unwinding_size);
close(fd);
if (ret) {
nsinfo__mountns_enter(jd->nsi, &nsc);
unlink(filename);
nsinfo__mountns_exit(&nsc);
}
return ret;
}
static void
jit_close(struct jit_buf_desc *jd)
{
if (!(jd && jd->in))
return;
funlockfile(jd->in);
fclose(jd->in);
jd->in = NULL;
}
static int
jit_validate_events(struct perf_session *session)
{
Annotation
- Immediate include surface: `sys/sysmacros.h`, `sys/types.h`, `errno.h`, `libgen.h`, `stdio.h`, `stdlib.h`, `string.h`, `fcntl.h`.
- Detected declarations: `struct jit_buf_desc`, `struct jit_tool`, `function jit_emit_elf`, `function jit_close`, `function jit_validate_events`, `function jit_open`, `function jit_get_next_entry`, `function jit_inject_event`, `function jr_entry_pid`, `function jr_entry_tid`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.