#ifndef __DUMP_LOG_H #define __DUMP_LOG_H #include #define TASK_COMM_LEN 16 /* Random numbers out of my head used for MAGIC */ #define LOGDEV_CUSTOM 0x1afb #define LOGDEV_SWITCH_ID 0x2afc #define LOGDEV_PRINT 0x4adb #define LOGDEV_PRINT_TIME 0x4adc #define LOGDEV_PRINT_TIME_FUNC 0x4add #define LOGDEV_HDR_DONE 0xbbbb /* internal use only */ #define LOGDEV_VALID_ID(id) (((id) == LOGDEV_SWITCH_ID) || \ ((id) == LOGDEV_PRINT) || \ ((id) == LOGDEV_PRINT_TIME) || \ ((id) == LOGDEV_PRINT_TIME_FUNC) || \ ((id) == LOGDEV_CUSTOM)) struct logdev_switch_struct { unsigned long long t; short pid_prev; short pid_next; int prev_prio; int prev_static_prio; int prev_normal_prio; int prev_state; int next_prio; int next_static_prio; int next_normal_prio; char prev_comm[TASK_COMM_LEN]; char next_comm[TASK_COMM_LEN]; }; struct logdev_print { char str[0]; }; struct logdev_print_time { unsigned long long t; char str[0]; }; struct logdev_print_time_func { const char *file; int line; /* need to be after line, since we use this with print_time. */ unsigned long long t; char str[0]; }; struct logdev_custom { int id; char data[0]; }; struct logdev_header { long counter; int id; int size; }; struct logdev_item { struct logdev_header hdr; union { struct logdev_switch_struct sw; struct logdev_print print; struct logdev_print_time print_time; struct logdev_print_time_func print_time_func; struct logdev_custom custom; char data[0]; } u; }; typedef void (*logdev_callback_func)(struct logdev_header *hdr, struct logdev_custom *custom, int cpu, void *rec); int logdev_register_callback(int custom_id, logdev_callback_func func); int logdev_unregister_callback(int custom_id); char *dump_log_version(void); void process_switch(int cpu, struct logdev_item *buf); void process_print(int cpu, struct logdev_item *buf); char *find_sys(unsigned long key); void load_sys(FILE *fp); struct logdev_item *read_dump(int fd, struct logdev_header *hdr); int open_logdev_cpu(char *uname, mode_t mode, int cpu); int close_logdev(int fd); int logdev_files(int **_fds, int **_cpus); int process_buf (struct logdev_item *buf, int id, int cpu); int process_dump(int *fd, int *cpus, int nr_cpus); int logdev_print(int fd,const char *fmt, ...); int logdev_switch_set(int on); int logdev_switch_read(void); int logdev_print_set(int on); int logdev_print_read(void); int logdev_probe_del(int id); int logdev_probe_watch(const char *func, const char *var, unsigned long addr, unsigned long watch); int logdev_probe_func(const char *func, const char *fmt); int logdev_probe_curr(const char *func, unsigned long addr, int index, const char *fmt); int logdev_probe_var(const char *func, unsigned long addr, const char *type); int logdev_open_probe(void); int logdev_open_marker(void); int logdev_close_probe(int fd); int logdev_close_marker(int fd); struct logdev_item *read_record(int fd); void free_record(struct logdev_item *rec); /* ------------------- probe cut place here ---------------------- */ #define LOGPROBE_IOCTL_BASE 'l' #define PROBE_IOW(nr, type) _IOW(LOGPROBE_IOCTL_BASE, nr, type) #define LOGPROBE_DELPOINT PROBE_IOW(0, unsigned long) #define LOGPROBE_ADDWATCH PROBE_IOW(1, struct logdev_probe_watch) #define LOGPROBE_ADDFUNC PROBE_IOW(2, struct logdev_probe_func) #define LOGPROBE_ADDCURR PROBE_IOW(3, struct logdev_probe_curr) #define LOGPROBE_ADDVAR PROBE_IOW(4, struct logdev_probe_var) #define LOGPROBE_ID_WATCH 0x56570001 #define LOGPROBE_ID_FUNC 0x56570002 #define LOGPROBE_ID_CURR 0x56570003 #define LOGPROBE_ID_VAR 0x56570004 #define LOGPROBE_TYPE_PREEMPT 0x1111 struct logdev_probe_hdr_log { unsigned long long t; char comm[TASK_COMM_LEN]; int pid; unsigned long addr; unsigned long offset; int func_symbol_size; }; struct logdev_probe_watch_log { struct logdev_probe_hdr_log hdr; unsigned long var; unsigned long value; int var_symbol_size; char symbols[]; }; struct logdev_probe_func_log { struct logdev_probe_hdr_log hdr; int str_size; char symbols[]; }; struct logdev_probe_curr_log { struct logdev_probe_hdr_log hdr; int index; unsigned long value; int prefix_size; char symbols[]; }; struct logdev_probe_var_log { struct logdev_probe_hdr_log hdr; int type; unsigned long value; int prefix_size; char symbols[]; }; struct logdev_probe_watch { unsigned long addr; unsigned long watch; const char *func; const char *var; int func_size; int var_size; }; struct logdev_probe_func { const char *func; const char *fmt1; const char *fmt2; int func_size; int fmt1_size; int fmt2_size; }; struct logdev_probe_curr { unsigned long addr; const char *func; const char *prefix; int offset; int func_size; int prefix_size; }; struct logdev_probe_var { unsigned long addr; const char *func; const char *prefix; int type; int func_size; int prefix_size; }; /* ---------------------- end probe cut ------------------------ */ /* -------------- start marker cut ------------------------- */ #define LOGMARK_IOCTL_BASE 'm' #define MARK_IO(nr) _IO(LOGMARK_IOCTL_BASE, nr) #define MARK_IOW(nr, type) _IOW(LOGMARK_IOCTL_BASE, nr, type) #define LOGMARK_START MARK_IO(0) #define LOGMARK_STOP MARK_IO(1) #define LOGMARK_ID_MARK 0x56580000 #define LOGMARK_CNTXTSW 0xffff0001 #define LOGMARK_MM_FAULT 0xffff0002 #define LOGMARK_GETRES 0xffff0003 struct logdev_mark_hdr { unsigned long long t; int id; }; struct logdev_mark_switch { struct logdev_mark_hdr hdr; short pid_prev; short pid_next; int prev_prio; int prev_static_prio; int prev_normal_prio; int prev_rt_prio; int prev_state; int next_prio; int next_static_prio; int next_normal_prio; int next_rt_prio; char prev_comm[TASK_COMM_LEN]; char next_comm[TASK_COMM_LEN]; }; struct logdev_mark_mm_fault { struct logdev_mark_hdr hdr; short pid; char comm[TASK_COMM_LEN]; struct mm_struct *mm; struct vm_area_struct *vma; unsigned long address; int write_access; }; struct logdev_mark_getres { struct logdev_mark_hdr hdr; short pid; clockid_t clock; char comm[TASK_COMM_LEN]; }; /* ---------------- end marker cut ------------------------- */ #endif