blob: 972b386116f1b080bb96c5f38b96739ba0307f49 [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 Hiramatsu631c9de2010-01-06 09:45:34 -050037/* Line number container */
38struct line_node {
39 struct list_head list;
40 unsigned int line;
41};
42
43/* Line range */
44struct line_range {
45 char *file; /* File name */
46 char *function; /* Function name */
47 unsigned int start; /* Start line number */
48 unsigned int end; /* End line number */
49 unsigned int offset; /* Start line offset */
50 char *path; /* Real path name */
51 struct list_head line_list; /* Visible lines */
52};
53
Masami Hiramatsu23e8ec02009-10-07 18:28:30 -040054#ifndef NO_LIBDWARF
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040055extern int find_probepoint(int fd, struct probe_point *pp);
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050056extern int find_line_range(int fd, struct line_range *lr);
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040057
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050058/* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */
59#ifndef _MIPS_SZLONG
60# define _MIPS_SZLONG 0
61#endif
62
63#include <dwarf.h>
64#include <libdwarf.h>
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040065
66struct probe_finder {
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050067 struct probe_point *pp; /* Target probe point */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040068
69 /* For function searching */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050070 Dwarf_Addr addr; /* Address */
71 Dwarf_Unsigned fno; /* File number */
72 Dwarf_Unsigned lno; /* Line number */
73 Dwarf_Off inl_offs; /* Inline offset */
74 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040075
76 /* For variable searching */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050077 Dwarf_Addr cu_base; /* Current CU base address */
78 Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
79 const char *var; /* Current variable name */
80 char *buf; /* Current output buffer */
81 int len; /* Length of output buffer */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040082};
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050083
84struct line_finder {
85 struct line_range *lr; /* Target line range */
86
87 Dwarf_Unsigned fno; /* File number */
88 Dwarf_Unsigned lno_s; /* Start line number */
89 Dwarf_Unsigned lno_e; /* End line number */
90 Dwarf_Addr addr_s; /* Start address */
91 Dwarf_Addr addr_e; /* End address */
92 Dwarf_Die cu_die; /* Current CU */
93 int found;
94};
95
Masami Hiramatsu23e8ec02009-10-07 18:28:30 -040096#endif /* NO_LIBDWARF */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040097
98#endif /*_PROBE_FINDER_H */