blob: a4086aaddb73da2458047d13209a897e7faec172 [file] [log] [blame]
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -04001#ifndef _PROBE_FINDER_H
2#define _PROBE_FINDER_H
3
Masami Hiramatsu27f3b242009-12-16 17:16:19 -05004#define MAX_PATH_LEN 256
5#define MAX_PROBE_BUFFER 1024
6#define MAX_PROBES 128
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -04007
8static inline int is_c_varname(const char *name)
9{
10 /* TODO */
11 return isalpha(name[0]) || name[0] == '_';
12}
13
14struct probe_point {
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050015 char *event; /* Event name */
16 char *group; /* Event group */
Masami Hiramatsuaf663d72009-12-15 10:32:18 -050017
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040018 /* Inputs */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050019 char *file; /* File name */
20 int line; /* Line number */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040021
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050022 char *function; /* Function name */
23 int offset; /* Offset bytes */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040024
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050025 int nr_args; /* Number of arguments */
26 char **args; /* Arguments */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040027
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050028 int retprobe; /* Return probe */
Masami Hiramatsu253977b2009-10-27 16:43:10 -040029
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040030 /* Output */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050031 int found; /* Number of found probe points */
32 char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040033};
34
Masami Hiramatsu23e8ec02009-10-07 18:28:30 -040035#ifndef NO_LIBDWARF
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040036extern int find_probepoint(int fd, struct probe_point *pp);
37
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050038/* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */
39#ifndef _MIPS_SZLONG
40# define _MIPS_SZLONG 0
41#endif
42
43#include <dwarf.h>
44#include <libdwarf.h>
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040045
46struct probe_finder {
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050047 struct probe_point *pp; /* Target probe point */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040048
49 /* For function searching */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050050 Dwarf_Addr addr; /* Address */
51 Dwarf_Unsigned fno; /* File number */
52 Dwarf_Unsigned lno; /* Line number */
53 Dwarf_Off inl_offs; /* Inline offset */
54 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040055
56 /* For variable searching */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050057 Dwarf_Addr cu_base; /* Current CU base address */
58 Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
59 const char *var; /* Current variable name */
60 char *buf; /* Current output buffer */
61 int len; /* Length of output buffer */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040062};
Masami Hiramatsu23e8ec02009-10-07 18:28:30 -040063#endif /* NO_LIBDWARF */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040064
65#endif /*_PROBE_FINDER_H */