/* * Ftrace header. For implementation details beyond the random comments * scattered below, see: Documentation/trace/ftrace-design.txt */ #ifndef _LINUX_FTRACE_H #define _LINUX_FTRACE_H #include #include #include #include #include #include #include #include #include #include #include /* * If the arch supports passing the variable contents of * function_trace_op as the third parameter back from the * mcount call, then the arch should define this as 1. */ #ifndef ARCH_SUPPORTS_FTRACE_OPS #define ARCH_SUPPORTS_FTRACE_OPS 0 #endif /* * If the arch's mcount caller does not support all of ftrace's * features, then it must call an indirect function that * does. Or at least does enough to prevent any unwelcomed side effects. */ #if !ARCH_SUPPORTS_FTRACE_OPS # define FTRACE_FORCE_LIST_FUNC 1 #else # define FTRACE_FORCE_LIST_FUNC 0 #endif /* Main tracing buffer and events set up */ #ifdef CONFIG_TRACING void trace_init(void); #else static inline void trace_init(void) { } #endif struct module; struct ftrace_hash; #ifdef CONFIG_FUNCTION_TRACER extern int ftrace_enabled; extern int ftrace_enable_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos); struct ftrace_ops; typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct pt_regs *regs); ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops); /* * FTRACE_OPS_FL_* bits denote the state of ftrace_ops struct and are * set in the flags member. * CONTROL, SAVE_REGS, SAVE_REGS_IF_SUPPORTED, RECURSION_SAFE, STUB and * IPMODIFY are a kind of attribute flags which can be set only before * registering the ftrace_ops, and can not be modified while registered. * Changing those attribute flags after regsitering ftrace_ops will * cause unexpected results. * * ENABLED - set/unset when ftrace_ops is registered/unregistered * DYNAMIC - set when ftrace_ops is registered to denote dynamically * allocated ftrace_ops which need special care * CONTROL - set manualy by ftrace_ops user to denote the ftrace_ops * could be controled by following calls: * ftrace_function_local_enable * ftrace_function_local_disable * SAVE_REGS - The ftrace_ops wants regs saved at each function called * and passed to the callback. If this flag is set, but the * architecture does not support passing regs * (CONFIG_DYNAMIC_FTRACE_WITH_REGS is not defined), then the * ftrace_ops will fail to register, unless the next flag * is set. * SAVE_REGS_IF_SUPPORTED - This is the same as SAVE_REGS, but if the * handler can handle an arch that does not save regs * (the handler tests if regs == NULL), then it can set * this flag instead. It will not fail registering the ftrace_ops * but, the regs field will be NULL if the arch does not support * passing regs to the handler. * Note, if this flag is set, the SAVE_REGS flag will automatically * get set upon registering the ftrace_ops, if the arch supports it. * RECURSION_SAFE - The ftrace_ops can set this to tell the ftrace infrastructure * that the call back has its own recursion protection. If it does * not set this, then the ftrace infrastructure will add recursion * protection for the caller. * STUB - The ftrace_ops is just a place holder. * INITIALIZED - The ftrace_ops has already been initialized (first use time * register_ftrace_function() is called, it will initialized the ops) * DELETED - The ops are being deleted, do not let them be registered again. * ADDING - The ops is in the process of being added. * REMOVING - The ops is in the process of being removed. * MODIFYING - The ops is in the process of changing its filter functions. * ALLOC_TRAMP - A dynamic trampoline was allocated by the core code. * The arch specific code sets this flag when it allocated a * trampoline. This lets the arch know that it can update the * trampoline in case the callback function changes. * The ftrace_ops trampoline can be set by the ftrace users, and * in such cases the arch must not modify it. Only the arch ftrace * core code should set this flag. * IPMODIFY - The ops can modify the IP register. This can only
{ 'enum': 'TestEnum',
  'data': [ 'value1', 'value2' ] }

{ 'struct': 'TestBase',
  'data': { 'enum1': 'TestEnum', 'kind': 'str' } }

{ 'struct': 'TestTypeA',
  'data': { 'string': 'str' } }

{ 'struct': 'TestTypeB',
  'data': { 'integer': 'int' } }

{ 'union': 'TestUnion',
  'base': 'TestBase',
  'discriminator': 'kind',
  'data': { 'kind1': 'TestTypeA',
            'kind2': 'TestTypeB' } }
d * by the function graph tracer to jump directly to its own * trampoline, then they can define FTRACE_GRAPH_TRAMP_ADDR * to be that address to jump to. */ #ifndef FTRACE_GRAPH_TRAMP_ADDR #define FTRACE_GRAPH_TRAMP_ADDR ((unsigned long) 0) #endif #ifdef CONFIG_FUNCTION_GRAPH_TRACER extern void ftrace_graph_caller(void); extern int ftrace_enable_ftrace_graph_caller(void); extern int ftrace_disable_ftrace_graph_caller(void); #else static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; } static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; } #endif /** * ftrace_make_nop - convert code into nop * @mod: module structure if called by module load initialization * @rec: the mcount call site record * @addr: the address that the call site should be calling * * This is a very sensitive operation and great care needs * to be taken by the arch. The operation should carefully * read the location, check to see if what is read is indeed * what we expect it to be, and then on success of the compare, * it should write to the location. * * The code segment at @rec->ip should be a caller to @addr * * Return must be: * 0 on success * -EFAULT on error reading the location * -EINVAL on a failed compare of the contents * -EPERM on error writing to the location * Any other value will be considered a failure. */ extern int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, unsigned long addr); /** * ftrace_make_call - convert a nop call site into a call to addr * @rec: the mcount call site record * @addr: the address that the call site should call * * This is a very sensitive operation and great care needs * to be taken by the arch. The operation should carefully * read the location, check to see if what is read is indeed * what we expect it to be, and then on success of the compare, * it should write to the location. * * The code segment at @rec->ip should be a nop * * Return must be: * 0 on success * -EFAULT on error reading the location * -EINVAL on a failed compare of the contents * -EPERM on error writing to the location * Any other value will be considered a failure. */ extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr); #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS /** * ftrace_modify_call - convert from one addr to another (no nop) * @rec: the mcount call site record * @old_addr: the address expected to be currently called to * @addr: the address to change to * * This is a very sensitive operation and great care needs * to be taken by the arch. The operation should carefully * read the location, check to see if what is read is indeed * what we expect it to be, and then on success of the compare, * it should write to the location. * * The code segment at @rec->ip should be a caller to @old_addr * * Return must be: * 0 on success * -EFAULT on error reading the location * -EINVAL on a failed compare of the contents * -EPERM on error writing to the location * Any other value will be considered a failure. */ extern int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, unsigned long addr); #else /* Should never be called */ static inline int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, unsigned long addr) { return -EINVAL; } #endif /* May be defined in arch */ extern int ftrace_arch_read_dyn_info(char *buf, int size); extern int skip_trace(unsigned long ip); extern void ftrace_module_init(struct module *mod); extern void ftrace_release_mod(struct module *mod); extern void ftrace_disable_daemon(void); extern void ftrace_enable_daemon(void); #else /* CONFIG_DYNAMIC_FTRACE */ static inline int skip_trace(unsigned long ip) { return 0; } static inline int ftrace_force_update(void) { return 0; } static inline void ftrace_disable_daemon(void) { } static inline void ftrace_enable_daemon(void) { } static inline void ftrace_release_mod(struct module *mod) {} static inline void ftrace_module_init(struct module *mod) {} static inline __init int register_ftrace_command(struct ftrace_func_command *cmd) { return -EINVAL; } static inline __init int unregister_ftrace_command(char *cmd_name) { return -EINVAL; } static inline int ftrace_text_reserved(const void *start, const void *end) { return 0; } static inline unsigned long ftrace_location(unsigned long ip) { return 0; } /* * Again users of functions that have ftrace_ops may not * have them defined when ftrace is not enabled, but these * functions may still be called. Use a macro instead of inline. */ #define ftrace_regex_open(ops, flag, inod, file) ({ -ENODEV; }) #define ftrace_set_early_filter(ops, buf, enable) do { } while (0) #define ftrace_set_filter_ip(ops, ip, remove, reset) ({ -ENODEV; }) #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; }) #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; }) #define ftrace_free_filter(ops) do { } while (0) static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf, size_t cnt, loff_t *ppos) { return -ENODEV; } static inline ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf, size_t cnt, loff_t *ppos) { return -ENODEV; } static inline int ftrace_regex_release(struct inode *inode, struct file *file) { return -ENODEV; } static inline bool is_ftrace_trampoline(unsigned long addr) { return false; } #endif /* CONFIG_DYNAMIC_FTRACE */ /* totally disable ftrace - can not re-enable after this */ void ftrace_kill(void); static inline void tracer_disable(void) { #ifdef CONFIG_FUNCTION_TRACER ftrace_enabled = 0; #endif } /* * Ftrace disable/restore without lock. Some synchronization mechanism * must be used to prevent ftrace_enabled to be changed between * disable/restore. */ static inline int __ftrace_enabled_save(void) { #ifdef CONFIG_FUNCTION_TRACER int saved_ftrace_enabled = ftrace_enabled; ftrace_enabled = 0; return saved_ftrace_enabled; #else return 0; #endif } static inline void __ftrace_enabled_restore(int enabled) { #ifdef CONFIG_FUNCTION_TRACER ftrace_enabled = enabled; #endif } /* All archs should have this, but we define it for consistency */ #ifndef ftrace_return_address0 # define ftrace_return_address0 __builtin_return_address(0) #endif /* Archs may use other ways for ADDR1 and beyond */ #ifndef ftrace_return_address # ifdef CONFIG_FRAME_POINTER # define ftrace_return_address(n) __builtin_return_address(n) # else # define ftrace_return_address(n) 0UL # endif #endif #define CALLER_ADDR0 ((unsigned long)ftrace_return_address0) #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) #define CALLER_ADDR2 ((unsigned long)ftrace_return_address(2)) #define CALLER_ADDR3 ((unsigned long)ftrace_return_address(3)) #define CALLER_ADDR4 ((unsigned long)ftrace_return_address(4)) #define CALLER_ADDR5 ((unsigned long)ftrace_return_address(5)) #define CALLER_ADDR6 ((unsigned long)ftrace_return_address(6)) static inline unsigned long get_lock_parent_ip(void) { unsigned long addr = CALLER_ADDR0; if (!in_lock_functions(addr)) return addr; addr = CALLER_ADDR1; if (!in_lock_functions(addr)) return addr; return CALLER_ADDR2; } #ifdef CONFIG_IRQSOFF_TRACER extern void time_hardirqs_on(unsigned long a0, unsigned long a1); extern void time_hardirqs_off(unsigned long a0, unsigned long a1); #else static inline void time_hardirqs_on(unsigned long a0, unsigned long a1) { } static inline void time_hardirqs_off(unsigned long a0, unsigned long a1) { } #endif #ifdef CONFIG_PREEMPT_TRACER extern void trace_preempt_on(unsigned long a0, unsigned long a1); extern void trace_preempt_off(unsigned long a0, unsigned long a1); #else /* * Use defines instead of static inlines because some arches will make code out * of the CALLER_ADDR, when we really want these to be a real nop. */ # define trace_preempt_on(a0, a1) do { } while (0) # define trace_preempt_off(a0, a1) do { } while (0) #endif #ifdef CONFIG_FTRACE_MCOUNT_RECORD extern void ftrace_init(void); #else static inline void ftrace_init(void) { } #endif /* * Structure that defines an entry function trace. */ struct ftrace_graph_ent { unsigned long func; /* Current function */ int depth; }; /* * Structure that defines a return function trace. */ struct ftrace_graph_ret { unsigned long func; /* Current function */ unsigned long long calltime; unsigned long long rettime; /* Number of functions that overran the depth limit for current task */ unsigned long overrun; int depth; }; /* Type of the callback handlers for tracing function graph*/ typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */ typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER /* for init task */ #define INIT_FTRACE_GRAPH .ret_stack = NULL, /* * Stack of return addresses for functions * of a thread. * Used in struct thread_info */ struct ftrace_ret_stack { unsigned long ret; unsigned long func; unsigned long long calltime; unsigned long long subtime; unsigned long fp; }; /* * Primary handler of a function return. * It relays on ftrace_return_to_handler. * Defined in entry_32/64.S */ extern void return_to_handler(void); extern int ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth, unsigned long frame_pointer); /* * Sometimes we don't want to trace a function with the function * graph tracer but we want them to keep traced by the usual function * tracer if the function graph tracer is not configured. */ #define __notrace_funcgraph notrace /* * We want to which function is an entrypoint of a hardirq. * That will help us to put a signal on output. */ #define __irq_entry __attribute__((__section__(".irqentry.text"))) /* Limits of hardirq entrypoints */ extern char __irqentry_text_start[]; extern char __irqentry_text_end[]; #define FTRACE_NOTRACE_DEPTH 65536 #define FTRACE_RETFUNC_DEPTH 50 #define FTRACE_RETSTACK_ALLOC_SIZE 32 extern int register_ftrace_graph(trace_func_graph_ret_t retfunc, trace_func_graph_ent_t entryfunc); extern bool ftrace_graph_is_dead(void); extern void ftrace_graph_stop(void); /* The current handlers in use */ extern trace_func_graph_ret_t ftrace_graph_return; extern trace_func_graph_ent_t ftrace_graph_entry; extern void unregister_ftrace_graph(void); extern void ftrace_graph_init_task(struct task_struct *t); extern void ftrace_graph_exit_task(struct task_struct *t); extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu); static inline int task_curr_ret_stack(struct task_struct *t) { return t->curr_ret_stack; } static inline void pause_graph_tracing(void) { atomic_inc(¤t->tracing_graph_pause); } static inline void unpause_graph_tracing(void) { atomic_dec(¤t->tracing_graph_pause); } #else /* !CONFIG_FUNCTION_GRAPH_TRACER */ #define __notrace_funcgraph #define __irq_entry #define INIT_FTRACE_GRAPH static inline void ftrace_graph_init_task(struct task_struct *t) { } static inline void ftrace_graph_exit_task(struct task_struct *t) { } static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { } static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc, trace_func_graph_ent_t entryfunc) { return -1; } static inline void unregister_ftrace_graph(void) { } static inline int task_curr_ret_stack(struct task_struct *tsk) { return -1; } static inline void pause_graph_tracing(void) { } static inline void unpause_graph_tracing(void) { } #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ #ifdef CONFIG_TRACING /* flags for current->trace */ enum { TSK_TRACE_FL_TRACE_BIT = 0, TSK_TRACE_FL_GRAPH_BIT = 1, }; enum { TSK_TRACE_FL_TRACE = 1 << TSK_TRACE_FL_TRACE_BIT, TSK_TRACE_FL_GRAPH = 1 << TSK_TRACE_FL_GRAPH_BIT, }; static inline void set_tsk_trace_trace(struct task_struct *tsk) { set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace); } static inline void clear_tsk_trace_trace(struct task_struct *tsk) { clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace); } static inline int test_tsk_trace_trace(struct task_struct *tsk) { return tsk->trace & TSK_TRACE_FL_TRACE; } static inline void set_tsk_trace_graph(struct task_struct *tsk) { set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace); } static inline void clear_tsk_trace_graph(struct task_struct *tsk) { clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace); } static inline int test_tsk_trace_graph(struct task_struct *tsk) { return tsk->trace & TSK_TRACE_FL_GRAPH; } enum ftrace_dump_mode; extern enum ftrace_dump_mode ftrace_dump_on_oops; extern int tracepoint_printk; extern void disable_trace_on_warning(void); extern int __disable_trace_on_warning; #ifdef CONFIG_PREEMPT #define INIT_TRACE_RECURSION .trace_recursion = 0, #endif #else /* CONFIG_TRACING */ static inline void disable_trace_on_warning(void) { } #endif /* CONFIG_TRACING */ #ifndef INIT_TRACE_RECURSION #define INIT_TRACE_RECURSION #endif #ifdef CONFIG_FTRACE_SYSCALLS unsigned long arch_syscall_addr(int nr); #endif /* CONFIG_FTRACE_SYSCALLS */ #endif /* _LINUX_FTRACE_H */