blob: e3f396806e6e5a738fa439c994ee379274e2af7e [file] [log] [blame]
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -04001#ifndef _PROBE_FINDER_H
2#define _PROBE_FINDER_H
3
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -02004#include "util.h"
5
Masami Hiramatsu27f3b242009-12-16 17:16:19 -05006#define MAX_PATH_LEN 256
7#define MAX_PROBE_BUFFER 1024
8#define MAX_PROBES 128
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -04009
10static inline int is_c_varname(const char *name)
11{
12 /* TODO */
13 return isalpha(name[0]) || name[0] == '_';
14}
15
16struct probe_point {
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050017 char *event; /* Event name */
18 char *group; /* Event group */
Masami Hiramatsuaf663d72009-12-15 10:32:18 -050019
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040020 /* Inputs */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050021 char *file; /* File name */
22 int line; /* Line number */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040023
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050024 char *function; /* Function name */
25 int offset; /* Offset bytes */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040026
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050027 int nr_args; /* Number of arguments */
28 char **args; /* Arguments */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040029
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050030 int retprobe; /* Return probe */
Masami Hiramatsu253977b2009-10-27 16:43:10 -040031
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040032 /* Output */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050033 int found; /* Number of found probe points */
34 char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040035};
36
Masami Hiramatsu23e8ec02009-10-07 18:28:30 -040037#ifndef NO_LIBDWARF
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040038extern int find_probepoint(int fd, struct probe_point *pp);
39
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050040/* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */
41#ifndef _MIPS_SZLONG
42# define _MIPS_SZLONG 0
43#endif
44
45#include <dwarf.h>
46#include <libdwarf.h>
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040047
48struct probe_finder {
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050049 struct probe_point *pp; /* Target probe point */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040050
51 /* For function searching */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050052 Dwarf_Addr addr; /* Address */
53 Dwarf_Unsigned fno; /* File number */
54 Dwarf_Unsigned lno; /* Line number */
55 Dwarf_Off inl_offs; /* Inline offset */
56 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040057
58 /* For variable searching */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050059 Dwarf_Addr cu_base; /* Current CU base address */
60 Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
61 const char *var; /* Current variable name */
62 char *buf; /* Current output buffer */
63 int len; /* Length of output buffer */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040064};
Masami Hiramatsu23e8ec02009-10-07 18:28:30 -040065#endif /* NO_LIBDWARF */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040066
67#endif /*_PROBE_FINDER_H */