summaryrefslogtreecommitdiff
path: root/src/lib/cov_preload.c
blob: 3b5a0b5d058f80f695055ca99b71838cc8e7181d (plain)
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
#define _GNU_SOURCE
#include <dlfcn.h>

#ifndef ELM_INTERNAL_API_ARGESFSDFEFC
#define ELM_INTERNAL_API_ARGESFSDFEFC
#endif
#include <Elementary.h>

#include "stats_common.h"

static int _init_count = 0;
static Eina_Bool _exit_required = EINA_FALSE;

Stat_Infos infos;

EAPI int
evas_init(void)
{
   _init_count++;
   int (*foo)() = dlsym(RTLD_NEXT, __func__);
   if (_init_count == 1)
     {
        infos.l = NULL;
        eina_init();
        eet_init();
     }
   return foo();
}

EAPI int
evas_shutdown()
{
   Stat_Info *info;
   int (*foo)() = dlsym(RTLD_NEXT, __func__);
   _init_count--;

   if (!_init_count && !_exit_required)
     {
        stats_save(&infos, "espion_stats.eet", STATS_EET_FORMAT);

        EINA_LIST_FREE(infos.l, info)
          {
             free(info);
          }
        infos.l = NULL;
        _exit_required = EINA_TRUE;
        eet_shutdown();
        eina_shutdown();
     }

   return foo();
}

static Stat_Info *
_info_update(const char *func, Stat_Info *info)
{
   if (_exit_required) return info;
   if (!info)
     {
        info = calloc(1, sizeof(*info));
        info->api_name = func;
        infos.l = eina_list_append(infos.l, info);
     }
   info->counter++;
   return info;
}

#include "covers.c"