forked from namhyung/uftrace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.h
88 lines (75 loc) · 2.11 KB
/
script.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Script binding for function entry and exit
*
* Copyright (C) 2017, LG Electronics, Honggyu Kim <[email protected]>
*
* Released under the GPL v2.
*/
#ifndef UFTRACE_SCRIPT_H
#define UFTRACE_SCRIPT_H
#include "libmcount/mcount.h"
#include "utils/script-luajit.h"
#include "utils/script-python.h"
#include "utils/utils.h"
#define SCRIPT_ENABLED (SCRIPT_LUAJIT_ENABLED || SCRIPT_PYTHON_ENABLED)
/* script type */
enum script_type_t {
SCRIPT_UNKNOWN = 0,
SCRIPT_PYTHON,
SCRIPT_LUAJIT,
SCRIPT_TESTING,
SCRIPT_TYPE_COUNT
};
/* informantion passed during initialization */
struct script_info {
char *name;
char *version;
bool record;
struct strv cmds;
};
/* context information passed to script */
struct script_context {
int tid;
int depth;
uint64_t timestamp;
uint64_t duration; /* exit only */
unsigned long address;
char *name;
/* for arguments and return value */
int arglen;
void *argbuf;
struct list_head *argspec;
};
union script_arg_val {
char c;
short s;
int i;
long l;
long long L;
/* libmcount should not access floating-point types. */
#ifndef LIBMCOUNT
float f;
double d;
long double D;
#endif
unsigned char v[16];
};
extern char *script_str;
typedef int (*script_uftrace_entry_t)(struct script_context *sc_ctx);
typedef int (*script_uftrace_exit_t)(struct script_context *sc_ctx);
typedef int (*script_uftrace_event_t)(struct script_context *sc_ctx);
typedef int (*script_uftrace_end_t)(void);
typedef int (*script_atfork_prepare_t)(void);
/* The below functions are used both in record time and script command. */
extern script_uftrace_entry_t script_uftrace_entry;
extern script_uftrace_exit_t script_uftrace_exit;
extern script_uftrace_event_t script_uftrace_event;
extern script_uftrace_end_t script_uftrace_end;
extern script_atfork_prepare_t script_atfork_prepare;
int script_init(struct script_info *info, enum uftrace_pattern_type ptype);
void script_finish(void);
void script_add_filter(char *func, enum uftrace_pattern_type ptype);
int script_match_filter(char *func);
void script_finish_filter(void);
enum script_type_t get_script_type(const char *str);
#endif /* UFTRACE_SCRIPT_H */