@@ -699,6 +699,8 @@ static inline void __ftrace_enabled_restore(int enabled)
# define trace_preempt_off(a0, a1) do { } while (0)
#endif
+extern unsigned long ftrace_lookup_mcount(unsigned long addr);
+
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
extern void ftrace_init(void);
#else
@@ -4857,6 +4857,32 @@ static int ftrace_process_locs(struct module *mod,
return ret;
}
+unsigned long ftrace_lookup_mcount(unsigned long addr)
+{
+ struct ftrace_page *pg;
+ struct dyn_ftrace *rec;
+ char str[KSYM_SYMBOL_LEN];
+ char *modname;
+ const char *name;
+ unsigned long mcount = 0;
+ unsigned long offset;
+
+ mutex_lock(&ftrace_lock);
+
+ do_for_each_ftrace_rec(pg, rec) {
+ name = kallsyms_lookup(rec->ip, NULL, &offset, &modname, str);
+ if (name && rec->ip == (addr + offset)) {
+ mcount = rec->ip;
+ goto out_unlock;
+ }
+ } while_for_each_ftrace_rec();
+
+ out_unlock:
+ mutex_unlock(&ftrace_lock);
+
+ return mcount;
+}
+
#ifdef CONFIG_MODULES
#define next_to_ftrace_page(p) container_of(p, struct ftrace_page, next)
ftrace_lookup_mcount() will return an address of mcount call in a function. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> --- include/linux/ftrace.h | 2 ++ kernel/trace/ftrace.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+)