blob: 9dd4a884d0e6a9dc3f8e36996468a40821b16e50 [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 Hiramatsu4ea42b12009-10-08 17:17:38 -040024
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050025 char *function; /* Function name */
26 int offset; /* Offset bytes */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040027
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050028 int nr_args; /* Number of arguments */
29 char **args; /* Arguments */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040030
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050031 int retprobe; /* Return probe */
Masami Hiramatsu253977b2009-10-27 16:43:10 -040032
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040033 /* Output */
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050034 int found; /* Number of found probe points */
35 char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040036};
37
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050038/* Line number container */
39struct line_node {
40 struct list_head list;
41 unsigned int line;
42};
43
44/* Line range */
45struct line_range {
46 char *file; /* File name */
47 char *function; /* Function name */
48 unsigned int start; /* Start line number */
49 unsigned int end; /* End line number */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050050 int offset; /* Start line offset */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050051 char *path; /* Real path name */
52 struct list_head line_list; /* Visible lines */
53};
54
Masami Hiramatsu804b3602010-02-25 08:35:42 -050055#ifndef NO_DWARF_SUPPORT
Masami Hiramatsu81cb8aa2010-02-25 08:35:34 -050056extern int find_probe_point(int fd, struct probe_point *pp);
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050057extern int find_line_range(int fd, struct line_range *lr);
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040058
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050059#include <dwarf.h>
Masami Hiramatsu804b3602010-02-25 08:35:42 -050060#include <libdw.h>
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040061
62struct probe_finder {
Masami Hiramatsu804b3602010-02-25 08:35:42 -050063 struct probe_point *pp; /* Target probe point */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040064
65 /* For function searching */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050066 Dwarf_Addr addr; /* Address */
67 const char *fname; /* File name */
68 int lno; /* Line number */
69 void *origin; /* Inline origin addr */
70 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 */
74 Dwarf_Addr cu_base; /* Current CU base address */
75 const char *var; /* Current variable name */
76 char *buf; /* Current output buffer */
77 int len; /* Length of output buffer */
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 */
86 Dwarf_Addr addr_s; /* Start address */
87 Dwarf_Addr addr_e; /* End address */
88 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050089 int found;
90};
91
Masami Hiramatsu804b3602010-02-25 08:35:42 -050092#endif /* NO_DWARF_SUPPORT */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040093
94#endif /*_PROBE_FINDER_H */