-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.h
164 lines (143 loc) · 4.35 KB
/
parse.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
Copyright (C) 2013
Baptiste Lepers <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Main File, should be included by all plugins.
*/
#ifndef PARSE_H
#define PARSE_H 1
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <sched.h>
#define PAGE_SIZE (4*1024)
#define PAGE_MASK (~(PAGE_SIZE-1))
#define ONE_GB (1LL*1024*1024*1024LL)
#include "machine.h"
#include "memprof-structs.h"
#include "rbtree.h"
#include "list.h"
#include "pqueue.h"
#include "symbols.h"
#include "process.h"
#include "perf.h"
#include "data.h"
#include "mmap.h"
/*
* All plugins should declare these three functions
* See parse.c to register a plugin.
*/
typedef void (*buffer_parser_t) (struct s*);
typedef void (*results_shower_t) (void);
typedef void (*init_function_t) (void);
typedef void (*modifier_function_t) (int);
/*
* Functions you may use on samples
*/
struct symbol *get_function(struct s *s);
struct symbol *get_object(struct s *s);
struct dyn_lib* get_mmap(struct s *s);
char *get_function_name(struct s *s);
char *get_app(struct s *s);
int is_distant(struct s *s);
int is_user(struct s *s);
int is_kernel(struct s *s);
int is_softirq(struct s *s); /* not implemented */
int get_pid(struct s *s);
int get_tid(struct s *s);
int get_addr_node(struct s *s);
int get_latency(struct s *s);
FILE* open_file(char *f);
int is_store(struct s *s);
int is_load(struct s *s);
int hit_dram(struct s *s);
int hit_locall1l2(struct s *s);
int hit_dist_cache(struct s *s);
int hit_stack(struct s *s);
extern int verbose;
extern char* path_to_binaries;
typedef struct {
union {
uint64_t val;
struct {
uint64_t ibsldop:1;
uint64_t ibsstop:1;
uint64_t ibsdcl1tlbmiss:1;
uint64_t ibsdcl2tlbmiss:1;
uint64_t ibsdcl1tlbhit2m:1;
uint64_t ibsdcl1tlbhit1g:1;
uint64_t ibsdcl2tlbhit2m:1;
uint64_t ibsdcmiss:1;
uint64_t ibsdcmissacc:1;
uint64_t ibsdcldbnkcon:1;
uint64_t ibsdcstbnkcon:1;
uint64_t ibsdcsttoldfwd:1;
uint64_t ibsdcsttoldcan:1;
uint64_t ibsdcucmemacc:1;
uint64_t ibsdcwcmemacc:1;
uint64_t ibsdclockedop:1;
uint64_t ibsdcmabhit:1;
uint64_t ibsdclinaddrvalid:1;
uint64_t ibsdcphyaddrvalid:1;
uint64_t reserved1:13;
uint64_t ibsdcmisslat:16;
uint64_t reserved2:16;
};
};
} ibs_op_data3_t;
typedef struct {
union {
uint64_t val;
struct {
uint64_t ibscomptoretctr:16;
uint64_t ibstagtoretctr:16;
uint64_t ibsopbrnresync:1;
uint64_t ibsopmispreturn:1;
uint64_t ibsopreturn:1;
uint64_t ibsopbrntaken:1;
uint64_t ibsopbrnmisp:1;
uint64_t ibsopbrnret:1;
uint64_t reserved:26;
};
};
} ibs_op_data_t;
extern struct i i;
extern char *open_file_error;
extern char* opt_machine;
#define __unused __attribute__((unused))
#define max(a,b) ({ typeof (a) _a = (a); typeof (b) _b = (b); _a > _b ? _a : _b; })
#define min(a,b) ({ typeof (a) _a = (a); typeof (b) _b = (b); _a < _b ? _a : _b; })
#define RESET "\033[0m"
#define BLACK "\033[30m" /* Black */
#define RED "\033[31m" /* Red */
#define GREEN "\033[32m" /* Green */
#define BLUE "\033[34m" /* Blue */
#define die(msg, args...) \
do { \
fprintf(stderr,"(%s,%d) " msg "\n", __FUNCTION__ , __LINE__, ##args); \
exit(-1); \
} while(0)
#endif