-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.cpp
35 lines (32 loc) · 834 Bytes
/
app.cpp
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
#include "dr_api.h"
#include "droption.h"
#include "app.h"
static droption_t<bool> only_from_app
(DROPTION_SCOPE_CLIENT, "only_from_app", false,
"Only count app, not lib, instructions", "");
static app_pc exe_start;
void
app_init(void)
{
/* Get main module address */
if (only_from_app.get_value()) {
module_data_t *exe = dr_get_main_module();
if (exe != NULL)
exe_start = exe->start;
dr_free_module_data(exe);
}
}
bool
app_should_ignore_tag(void *tag)
{
/* Only count in app BBs */
if (only_from_app.get_value()) {
module_data_t *mod = dr_lookup_module(dr_fragment_app_pc(tag));
if (mod != NULL) {
bool from_exe = (mod->start == exe_start);
dr_free_module_data(mod);
return !from_exe;
}
}
return false;
}