forked from luck/tmp_suning_uos_patched
23e8ec0d1c
Enables 'perf probe' even if libdwarf is not installed. If libdwarf is not found, 'perf probe' just disables dwarf support. Users can use 'perf probe' to set up new events by using kprobe_events format. Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Christoph Hellwig <hch@infradead.org> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Jim Keniston <jkenisto@us.ibm.com> Cc: Frank Ch. Eigler <fche@redhat.com> LKML-Reference: <20091007222830.1684.25665.stgit@dhcp-100-2-132.bos.redhat.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
71 lines
1.7 KiB
C
71 lines
1.7 KiB
C
#ifndef _PROBE_FINDER_H
|
|
#define _PROBE_FINDER_H
|
|
|
|
#define _stringify(n) #n
|
|
#define stringify(n) _stringify(n)
|
|
|
|
#ifdef DEBUG
|
|
#define debug(fmt ...) \
|
|
fprintf(stderr, "DBG(" __FILE__ ":" stringify(__LINE__) "): " fmt)
|
|
#else
|
|
#define debug(fmt ...) do {} while (0)
|
|
#endif
|
|
|
|
#define ERR_IF(cnd) \
|
|
do { if (cnd) { \
|
|
fprintf(stderr, "Error (" __FILE__ ":" stringify(__LINE__) \
|
|
"): " stringify(cnd) "\n"); \
|
|
exit(1); \
|
|
} } while (0)
|
|
|
|
#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 {
|
|
/* 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 */
|
|
|
|
/* Output */
|
|
int found; /* Number of found probe points */
|
|
char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
|
|
};
|
|
|
|
#ifndef NO_LIBDWARF
|
|
extern int find_probepoint(int fd, struct probe_point *pp);
|
|
|
|
#include <libdwarf/dwarf.h>
|
|
#include <libdwarf/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_Off inl_offs; /* Inline offset */
|
|
|
|
/* 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 */
|
|
};
|
|
#endif /* NO_LIBDWARF */
|
|
|
|
#endif /*_PROBE_FINDER_H */
|