forked from luck/tmp_suning_uos_patched
631c9def80
Add --line option to support showing probable source-code lines. perf probe --line SRC:LN[-LN|+NUM] or perf probe --line FUNC[:LN[-LN|+NUM]] This option shows source-code with line number if the line can be probed. Lines without line number (and blue color) means that the line can not be probed, because debuginfo doesn't have the information of those lines. The argument specifies the range of lines, "source.c:100-120" shows lines between 100th to l20th in source.c file. And "func:10+20" shows 20 lines from 10th line of func function. e.g. # ./perf probe --line kernel/sched.c:1080 <kernel/sched.c:1080> * * called with rq->lock held and irqs disabled */ static void hrtick_start(struct rq *rq, u64 delay) { struct hrtimer *timer = &rq->hrtick_timer; 1086 ktime_t time = ktime_add_ns(timer->base->get_time(), delay); hrtimer_set_expires(timer, time); 1090 if (rq == this_rq()) { 1091 hrtimer_restart(timer); 1092 } else if (!rq->hrtick_csd_pending) { 1093 __smp_call_function_single(cpu_of(rq), &rq->hrtick_csd, 1094 rq->hrtick_csd_pending = 1; If you specifying function name, this shows function-relative line number. # ./perf probe --line schedule <schedule:0> asmlinkage void __sched schedule(void) 1 { struct task_struct *prev, *next; unsigned long *switch_count; struct rq *rq; int cpu; need_resched: preempt_disable(); 9 cpu = smp_processor_id(); 10 rq = cpu_rq(cpu); 11 rcu_sched_qs(cpu); 12 prev = rq->curr; 13 switch_count = &prev->nivcsw; Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: systemtap <systemtap@sources.redhat.com> Cc: DLE <dle-develop@lists.sourceforge.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Mike Galbraith <efault@gmx.de> LKML-Reference: <20100106144534.27218.77939.stgit@dhcp-100-2-132.bos.redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
99 lines
2.4 KiB
C
99 lines
2.4 KiB
C
#ifndef _PROBE_FINDER_H
|
|
#define _PROBE_FINDER_H
|
|
|
|
#include "util.h"
|
|
|
|
#define MAX_PATH_LEN 256
|
|
#define MAX_PROBE_BUFFER 1024
|
|
#define MAX_PROBES 128
|
|
|
|
static inline int is_c_varname(const char *name)
|
|
{
|
|
/* TODO */
|
|
return isalpha(name[0]) || name[0] == '_';
|
|
}
|
|
|
|
struct probe_point {
|
|
char *event; /* Event name */
|
|
char *group; /* Event group */
|
|
|
|
/* Inputs */
|
|
char *file; /* File name */
|
|
int line; /* Line number */
|
|
|
|
char *function; /* Function name */
|
|
int offset; /* Offset bytes */
|
|
|
|
int nr_args; /* Number of arguments */
|
|
char **args; /* Arguments */
|
|
|
|
int retprobe; /* Return probe */
|
|
|
|
/* Output */
|
|
int found; /* Number of found probe points */
|
|
char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
|
|
};
|
|
|
|
/* Line number container */
|
|
struct line_node {
|
|
struct list_head list;
|
|
unsigned int line;
|
|
};
|
|
|
|
/* Line range */
|
|
struct line_range {
|
|
char *file; /* File name */
|
|
char *function; /* Function name */
|
|
unsigned int start; /* Start line number */
|
|
unsigned int end; /* End line number */
|
|
unsigned int offset; /* Start line offset */
|
|
char *path; /* Real path name */
|
|
struct list_head line_list; /* Visible lines */
|
|
};
|
|
|
|
#ifndef NO_LIBDWARF
|
|
extern int find_probepoint(int fd, struct probe_point *pp);
|
|
extern int find_line_range(int fd, struct line_range *lr);
|
|
|
|
/* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */
|
|
#ifndef _MIPS_SZLONG
|
|
# define _MIPS_SZLONG 0
|
|
#endif
|
|
|
|
#include <dwarf.h>
|
|
#include <libdwarf.h>
|
|
|
|
struct probe_finder {
|
|
struct probe_point *pp; /* Target probe point */
|
|
|
|
/* For function searching */
|
|
Dwarf_Addr addr; /* Address */
|
|
Dwarf_Unsigned fno; /* File number */
|
|
Dwarf_Unsigned lno; /* Line number */
|
|
Dwarf_Off inl_offs; /* Inline offset */
|
|
Dwarf_Die cu_die; /* Current CU */
|
|
|
|
/* For variable searching */
|
|
Dwarf_Addr cu_base; /* Current CU base address */
|
|
Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
|
|
const char *var; /* Current variable name */
|
|
char *buf; /* Current output buffer */
|
|
int len; /* Length of output buffer */
|
|
};
|
|
|
|
struct line_finder {
|
|
struct line_range *lr; /* Target line range */
|
|
|
|
Dwarf_Unsigned fno; /* File number */
|
|
Dwarf_Unsigned lno_s; /* Start line number */
|
|
Dwarf_Unsigned lno_e; /* End line number */
|
|
Dwarf_Addr addr_s; /* Start address */
|
|
Dwarf_Addr addr_e; /* End address */
|
|
Dwarf_Die cu_die; /* Current CU */
|
|
int found;
|
|
};
|
|
|
|
#endif /* NO_LIBDWARF */
|
|
|
|
#endif /*_PROBE_FINDER_H */
|