Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * jitdump.h: jitted code info encapsulation file format
0004  *
0005  * Adapted from OProfile GPLv2 support jidump.h:
0006  * Copyright 2007 OProfile authors
0007  * Jens Wilke
0008  * Daniel Hansel
0009  * Copyright IBM Corporation 2007
0010  */
0011 #ifndef JITDUMP_H
0012 #define JITDUMP_H
0013 
0014 #include <sys/time.h>
0015 #include <time.h>
0016 #include <stdint.h>
0017 
0018 /* JiTD */
0019 #define JITHEADER_MAGIC     0x4A695444
0020 #define JITHEADER_MAGIC_SW  0x4454694A
0021 
0022 #define PADDING_8ALIGNED(x) ((((x) + 7) & 7) ^ 7)
0023 #define ALIGN_8(x) (((x) + 7) & (~7))
0024 
0025 #define JITHEADER_VERSION 1
0026 
0027 enum jitdump_flags_bits {
0028     JITDUMP_FLAGS_ARCH_TIMESTAMP_BIT,
0029     JITDUMP_FLAGS_MAX_BIT,
0030 };
0031 
0032 #define JITDUMP_FLAGS_ARCH_TIMESTAMP    (1ULL << JITDUMP_FLAGS_ARCH_TIMESTAMP_BIT)
0033 
0034 #define JITDUMP_FLAGS_RESERVED (JITDUMP_FLAGS_MAX_BIT < 64 ? \
0035                 (~((1ULL << JITDUMP_FLAGS_MAX_BIT) - 1)) : 0)
0036 
0037 struct jitheader {
0038     uint32_t magic;     /* characters "jItD" */
0039     uint32_t version;   /* header version */
0040     uint32_t total_size;    /* total size of header */
0041     uint32_t elf_mach;  /* elf mach target */
0042     uint32_t pad1;      /* reserved */
0043     uint32_t pid;       /* JIT process id */
0044     uint64_t timestamp; /* timestamp */
0045     uint64_t flags;     /* flags */
0046 };
0047 
0048 enum jit_record_type {
0049     JIT_CODE_LOAD       = 0,
0050         JIT_CODE_MOVE           = 1,
0051     JIT_CODE_DEBUG_INFO = 2,
0052     JIT_CODE_CLOSE      = 3,
0053     JIT_CODE_UNWINDING_INFO = 4,
0054 
0055     JIT_CODE_MAX,
0056 };
0057 
0058 /* record prefix (mandatory in each record) */
0059 struct jr_prefix {
0060     uint32_t id;
0061     uint32_t total_size;
0062     uint64_t timestamp;
0063 };
0064 
0065 struct jr_code_load {
0066     struct jr_prefix p;
0067 
0068     uint32_t pid;
0069     uint32_t tid;
0070     uint64_t vma;
0071     uint64_t code_addr;
0072     uint64_t code_size;
0073     uint64_t code_index;
0074 };
0075 
0076 struct jr_code_close {
0077     struct jr_prefix p;
0078 };
0079 
0080 struct jr_code_move {
0081     struct jr_prefix p;
0082 
0083     uint32_t pid;
0084     uint32_t tid;
0085     uint64_t vma;
0086     uint64_t old_code_addr;
0087     uint64_t new_code_addr;
0088     uint64_t code_size;
0089     uint64_t code_index;
0090 };
0091 
0092 struct debug_entry {
0093     uint64_t addr;
0094     int lineno;     /* source line number starting at 1 */
0095     int discrim;        /* column discriminator, 0 is default */
0096     const char name[]; /* null terminated filename, \xff\0 if same as previous entry */
0097 };
0098 
0099 struct jr_code_debug_info {
0100     struct jr_prefix p;
0101 
0102     uint64_t code_addr;
0103     uint64_t nr_entry;
0104     struct debug_entry entries[];
0105 };
0106 
0107 struct jr_code_unwinding_info {
0108     struct jr_prefix p;
0109 
0110     uint64_t unwinding_size;
0111     uint64_t eh_frame_hdr_size;
0112     uint64_t mapped_size;
0113     const char unwinding_data[];
0114 };
0115 
0116 union jr_entry {
0117         struct jr_code_debug_info info;
0118         struct jr_code_close close;
0119         struct jr_code_load load;
0120         struct jr_code_move move;
0121         struct jr_prefix prefix;
0122         struct jr_code_unwinding_info unwinding;
0123 };
0124 
0125 static inline struct debug_entry *
0126 debug_entry_next(struct debug_entry *ent)
0127 {
0128     void *a = ent + 1;
0129     size_t l = strlen(ent->name) + 1;
0130     return a + l;
0131 }
0132 
0133 static inline char *
0134 debug_entry_file(struct debug_entry *ent)
0135 {
0136     void *a = ent + 1;
0137     return a;
0138 }
0139 
0140 #endif /* !JITDUMP_H */