Root/tools/perf/util/probe-finder.h

1#ifndef _PROBE_FINDER_H
2#define _PROBE_FINDER_H
3
4#include <stdbool.h>
5#include "util.h"
6
7#define MAX_PATH_LEN 256
8#define MAX_PROBE_BUFFER 1024
9#define MAX_PROBES 128
10
11static inline int is_c_varname(const char *name)
12{
13    /* TODO */
14    return isalpha(name[0]) || name[0] == '_';
15}
16
17struct probe_point {
18    char *event; /* Event name */
19    char *group; /* Event group */
20
21    /* Inputs */
22    char *file; /* File name */
23    int line; /* Line number */
24    char *lazy_line; /* Lazy line pattern */
25
26    char *function; /* Function name */
27    int offset; /* Offset bytes */
28
29    int nr_args; /* Number of arguments */
30    char **args; /* Arguments */
31
32    int retprobe; /* Return probe */
33
34    /* Output */
35    int found; /* Number of found probe points */
36    char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
37};
38
39/* 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 */
51    int offset; /* Start line offset */
52    char *path; /* Real path name */
53    struct list_head line_list; /* Visible lines */
54};
55
56#ifndef NO_DWARF_SUPPORT
57extern int find_probe_point(int fd, struct probe_point *pp);
58extern int find_line_range(int fd, struct line_range *lr);
59
60#include <dwarf.h>
61#include <libdw.h>
62
63struct probe_finder {
64    struct probe_point *pp; /* Target probe point */
65
66    /* For function searching */
67    Dwarf_Addr addr; /* Address */
68    const char *fname; /* File name */
69    int lno; /* Line number */
70    Dwarf_Die cu_die; /* Current CU */
71
72    /* For variable searching */
73    Dwarf_Op *fb_ops; /* Frame base attribute */
74    const char *var; /* Current variable name */
75    char *buf; /* Current output buffer */
76    int len; /* Length of output buffer */
77    struct list_head lcache; /* Line cache for lazy match */
78};
79
80struct line_finder {
81    struct line_range *lr; /* Target line range */
82
83    const char *fname; /* File name */
84    int lno_s; /* Start line number */
85    int lno_e; /* End line number */
86    Dwarf_Die cu_die; /* Current CU */
87    int found;
88};
89
90#endif /* NO_DWARF_SUPPORT */
91
92#endif /*_PROBE_FINDER_H */
93

Archive Download this file



interactive