blob: 21f7354397b459414bcc438813411fa901fe19ff [file] [log] [blame]
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -04001#ifndef _PROBE_FINDER_H
2#define _PROBE_FINDER_H
3
Masami Hiramatsu804b3602010-02-25 08:35:42 -05004#include <stdbool.h>
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -02005#include "util.h"
6
Masami Hiramatsu27f3b242009-12-16 17:16:19 -05007#define MAX_PATH_LEN 256
8#define MAX_PROBE_BUFFER 1024
9#define MAX_PROBES 128
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040010
11static inline int is_c_varname(const char *name)
12{
13 /* TODO */
14 return isalpha(name[0]) || name[0] == '_';
15}
16
17struct probe_point {
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050018 char *event; /* Event name */
19 char *group; /* Event group */
Masami Hiramatsuaf663d72009-12-15 10:32:18 -050020
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040021 /* Inputs */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050022 char *file; /* File name */
23 int line; /* Line number */
Masami Hiramatsu2a9c8c32010-02-25 08:36:12 -050024 char *lazy_line; /* Lazy line pattern */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040025
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050026 char *function; /* Function name */
27 int offset; /* Offset bytes */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040028
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050029 int nr_args; /* Number of arguments */
30 char **args; /* Arguments */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040031
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050032 int retprobe; /* Return probe */
Masami Hiramatsu253977b2009-10-27 16:43:10 -040033
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040034 /* Output */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050035 int found; /* Number of found probe points */
36 char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040037};
38
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050039/* Line number container */
40struct line_node {
41 struct list_head list;
42 unsigned int line;
43};
44
45/* Line range */
46struct line_range {
47 char *file; /* File name */
48 char *function; /* Function name */
49 unsigned int start; /* Start line number */
50 unsigned int end; /* End line number */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050051 int offset; /* Start line offset */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050052 char *path; /* Real path name */
53 struct list_head line_list; /* Visible lines */
54};
55
Masami Hiramatsu804b3602010-02-25 08:35:42 -050056#ifndef NO_DWARF_SUPPORT
Masami Hiramatsu81cb8aa2010-02-25 08:35:34 -050057extern int find_probe_point(int fd, struct probe_point *pp);
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050058extern int find_line_range(int fd, struct line_range *lr);
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040059
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050060#include <dwarf.h>
Masami Hiramatsu804b3602010-02-25 08:35:42 -050061#include <libdw.h>
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040062
63struct probe_finder {
Masami Hiramatsu804b3602010-02-25 08:35:42 -050064 struct probe_point *pp; /* Target probe point */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040065
66 /* For function searching */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050067 Dwarf_Addr addr; /* Address */
68 const char *fname; /* File name */
69 int lno; /* Line number */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050070 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040071
72 /* For variable searching */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050073 Dwarf_Op *fb_ops; /* Frame base attribute */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050074 const char *var; /* Current variable name */
75 char *buf; /* Current output buffer */
76 int len; /* Length of output buffer */
Masami Hiramatsu2a9c8c32010-02-25 08:36:12 -050077 struct list_head lcache; /* Line cache for lazy match */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040078};
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050079
80struct line_finder {
Masami Hiramatsu804b3602010-02-25 08:35:42 -050081 struct line_range *lr; /* Target line range */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050082
Masami Hiramatsu804b3602010-02-25 08:35:42 -050083 const char *fname; /* File name */
84 int lno_s; /* Start line number */
85 int lno_e; /* End line number */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050086 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050087 int found;
88};
89
Masami Hiramatsu804b3602010-02-25 08:35:42 -050090#endif /* NO_DWARF_SUPPORT */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040091
92#endif /*_PROBE_FINDER_H */