2015-05-13 23:41:11 -07:00
|
|
|
/* EINA - EFL data type library
|
|
|
|
* Copyright (C) 2015 Carsten Haitzler
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-05-10 03:05:54 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2018-01-11 09:59:34 -08:00
|
|
|
#ifdef HAVE_VALGRIND
|
|
|
|
# include <valgrind.h>
|
|
|
|
# include <memcheck.h>
|
|
|
|
#endif
|
|
|
|
|
2015-05-10 03:05:54 -07:00
|
|
|
#include "Eina.h"
|
|
|
|
#include "eina_evlog.h"
|
|
|
|
#include "eina_debug.h"
|
|
|
|
|
2015-10-12 05:42:18 -07:00
|
|
|
#if defined(__APPLE__) && defined(__MACH__)
|
|
|
|
# include <mach/mach_time.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <time.h>
|
2016-11-26 21:48:10 -08:00
|
|
|
#include <unistd.h>
|
2015-10-12 05:42:18 -07:00
|
|
|
|
2019-08-19 06:55:12 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
# include <evil_private.h> /* mmap */
|
|
|
|
#else
|
|
|
|
# include <sys/mman.h>
|
|
|
|
#endif
|
2015-05-10 03:05:54 -07:00
|
|
|
|
2017-06-03 09:33:58 -07:00
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
|
|
#define SWAP_64(x) x
|
|
|
|
#define SWAP_32(x) x
|
|
|
|
#define SWAP_16(x) x
|
|
|
|
#define SWAP_DBL(x) x
|
|
|
|
#else
|
|
|
|
#define SWAP_64(x) eina_swap64(x)
|
|
|
|
#define SWAP_32(x) eina_swap32(x)
|
|
|
|
#define SWAP_16(x) eina_swap16(x)
|
|
|
|
#define SWAP_DBL(x) SWAP_64(x)
|
|
|
|
#endif
|
|
|
|
|
2015-05-10 03:05:54 -07:00
|
|
|
# define EVLOG_BUF_SIZE (4 * (1024 * 1024))
|
|
|
|
|
|
|
|
static Eina_Spinlock _evlog_lock;
|
|
|
|
static int _evlog_go = 0;
|
|
|
|
|
|
|
|
static Eina_Evlog_Buf *buf; // current event log we are writing events to
|
|
|
|
static Eina_Evlog_Buf buffers[2]; // double-buffer our event log buffers
|
|
|
|
|
2019-11-28 00:59:41 -08:00
|
|
|
#if defined (HAVE_CLOCK_GETTIME)
|
2015-10-12 05:42:18 -07:00
|
|
|
static clockid_t _eina_evlog_time_clock_id = -1;
|
|
|
|
#elif defined(__APPLE__) && defined(__MACH__)
|
|
|
|
static double _eina_evlog_time_clock_conversion = 1e-9;
|
|
|
|
#endif
|
|
|
|
|
2016-11-26 21:48:10 -08:00
|
|
|
static int _evlog_get_opcode = EINA_DEBUG_OPCODE_INVALID;
|
|
|
|
|
2015-05-10 03:05:54 -07:00
|
|
|
static inline double
|
|
|
|
get_time(void)
|
|
|
|
{
|
2019-11-28 00:59:41 -08:00
|
|
|
#if defined (HAVE_CLOCK_GETTIME)
|
2015-10-12 05:42:18 -07:00
|
|
|
struct timespec t;
|
|
|
|
|
|
|
|
if (EINA_UNLIKELY(clock_gettime(_eina_evlog_time_clock_id, &t)))
|
|
|
|
{
|
|
|
|
struct timeval timev;
|
|
|
|
gettimeofday(&timev, NULL);
|
|
|
|
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000.0);
|
|
|
|
}
|
|
|
|
return (double)t.tv_sec + (((double)t.tv_nsec) / 1000000000.0);
|
2017-09-22 03:06:10 -07:00
|
|
|
#elif defined(_WIN32)
|
2015-10-12 05:42:18 -07:00
|
|
|
return evil_time_get();
|
|
|
|
#elif defined(__APPLE__) && defined(__MACH__)
|
|
|
|
return _eina_evlog_time_clock_conversion * (double)mach_absolute_time();
|
|
|
|
#else
|
2015-05-10 03:05:54 -07:00
|
|
|
struct timeval timev;
|
|
|
|
gettimeofday(&timev, NULL);
|
|
|
|
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000.0);
|
2015-10-12 05:42:18 -07:00
|
|
|
#endif
|
2015-05-10 03:05:54 -07:00
|
|
|
}
|
|
|
|
|
2021-09-06 02:03:22 -07:00
|
|
|
static int no_anon = -1;
|
|
|
|
|
2015-05-10 03:05:54 -07:00
|
|
|
static void
|
|
|
|
alloc_buf(Eina_Evlog_Buf *b, unsigned int size)
|
|
|
|
{
|
|
|
|
if (b->buf) return;
|
|
|
|
b->size = size;
|
|
|
|
b->top = 0;
|
2018-01-11 09:59:34 -08:00
|
|
|
#ifdef HAVE_MMAP
|
|
|
|
# ifdef HAVE_VALGRIND
|
|
|
|
if (RUNNING_ON_VALGRIND) b->buf = malloc(size);
|
|
|
|
else
|
2015-05-10 03:05:54 -07:00
|
|
|
# endif
|
2018-01-11 09:59:34 -08:00
|
|
|
{
|
2021-09-06 02:03:22 -07:00
|
|
|
if (no_anon == -1)
|
|
|
|
{
|
|
|
|
if (getenv("EFL_NO_MMAP_ANON")) no_anon = 1;
|
|
|
|
else no_anon = 0;
|
|
|
|
}
|
|
|
|
if (no_anon == 1) b->buf = malloc(size);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
b->buf = mmap(NULL, size, PROT_READ | PROT_WRITE,
|
|
|
|
MAP_PRIVATE | MAP_ANON, -1, 0);
|
|
|
|
if (b->buf == MAP_FAILED) b->buf = NULL;
|
|
|
|
}
|
2018-01-11 09:59:34 -08:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
b->buf = malloc(size);
|
|
|
|
#endif
|
2015-05-10 03:05:54 -07:00
|
|
|
b->overflow = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_buf(Eina_Evlog_Buf *b)
|
|
|
|
{
|
|
|
|
if (!b->buf) return;
|
2018-01-11 09:59:34 -08:00
|
|
|
#ifdef HAVE_MMAP
|
|
|
|
# ifdef HAVE_VALGRIND
|
|
|
|
if (RUNNING_ON_VALGRIND) free(b->buf);
|
|
|
|
else
|
|
|
|
# endif
|
2021-09-06 02:03:22 -07:00
|
|
|
{
|
|
|
|
if (no_anon == 1) free(b->buf);
|
|
|
|
else munmap(b->buf, b->size);
|
|
|
|
}
|
2018-01-11 09:59:34 -08:00
|
|
|
#else
|
2015-05-10 03:05:54 -07:00
|
|
|
free(b->buf);
|
2018-01-11 09:59:34 -08:00
|
|
|
#endif
|
2015-05-10 03:05:54 -07:00
|
|
|
b->buf = NULL;
|
2017-07-28 05:12:57 -07:00
|
|
|
b->size = 0;
|
|
|
|
b->top = 0;
|
2015-05-10 03:05:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *
|
|
|
|
push_buf(Eina_Evlog_Buf *b, unsigned int size)
|
|
|
|
{
|
|
|
|
void *ptr;
|
|
|
|
|
|
|
|
if (b->size < size) abort();
|
|
|
|
if ((b->top + size) > (b->size))
|
|
|
|
{
|
|
|
|
b->overflow++;
|
|
|
|
b->top = 0;
|
|
|
|
}
|
|
|
|
ptr = (b->buf + b->top);
|
|
|
|
b->top += size;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API void
|
2015-05-10 03:05:54 -07:00
|
|
|
eina_evlog(const char *event, void *obj, double srctime, const char *detail)
|
|
|
|
{
|
|
|
|
Eina_Evlog_Item *item;
|
|
|
|
char *strings;
|
2017-01-30 13:28:29 -08:00
|
|
|
double now;
|
2017-02-01 17:13:24 -08:00
|
|
|
int size;
|
2017-01-30 21:48:36 -08:00
|
|
|
unsigned short detail_offset, event_size;
|
2015-05-10 03:05:54 -07:00
|
|
|
|
2016-11-09 21:32:56 -08:00
|
|
|
if (!_evlog_go) return;
|
2017-02-01 17:13:24 -08:00
|
|
|
now = get_time();
|
|
|
|
event_size = strlen(event) + 1;
|
|
|
|
size = sizeof(Eina_Evlog_Item) + event_size;
|
|
|
|
detail_offset = 0;
|
2015-05-10 03:05:54 -07:00
|
|
|
if (detail)
|
|
|
|
{
|
2017-01-30 21:48:36 -08:00
|
|
|
detail_offset = size;
|
|
|
|
size += strlen(detail) + 1;
|
2015-05-10 03:05:54 -07:00
|
|
|
}
|
2017-02-01 17:13:24 -08:00
|
|
|
size = sizeof(double) * ((size + sizeof(double) - 1)
|
|
|
|
/ sizeof(double));
|
2017-01-30 21:48:36 -08:00
|
|
|
eina_spinlock_take(&_evlog_lock);
|
2017-02-01 17:13:24 -08:00
|
|
|
strings = push_buf(buf, size);
|
|
|
|
item = (Eina_Evlog_Item *)strings;
|
2017-06-03 09:33:58 -07:00
|
|
|
item->tim = SWAP_DBL(now);
|
|
|
|
item->srctim = SWAP_DBL(srctime);
|
|
|
|
item->thread = SWAP_64((unsigned long long)(uintptr_t)pthread_self());
|
|
|
|
item->obj = SWAP_64((unsigned long long)(uintptr_t)obj);
|
|
|
|
item->event_offset = SWAP_16(sizeof(Eina_Evlog_Item));
|
|
|
|
item->detail_offset = SWAP_16(detail_offset);
|
|
|
|
item->event_next = SWAP_16(size);
|
2017-02-01 17:13:24 -08:00
|
|
|
strcpy(strings + sizeof(Eina_Evlog_Item), event);
|
2015-05-10 03:05:54 -07:00
|
|
|
if (detail_offset > 0) strcpy(strings + detail_offset, detail);
|
|
|
|
eina_spinlock_release(&_evlog_lock);
|
|
|
|
}
|
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API Eina_Evlog_Buf *
|
2015-05-10 03:05:54 -07:00
|
|
|
eina_evlog_steal(void)
|
|
|
|
{
|
|
|
|
Eina_Evlog_Buf *stolen = NULL;
|
|
|
|
|
|
|
|
eina_spinlock_take(&_evlog_lock);
|
|
|
|
if (buf == &(buffers[0]))
|
|
|
|
{
|
|
|
|
buf = &(buffers[1]);
|
|
|
|
buf->top = 0;
|
2015-05-11 00:55:23 -07:00
|
|
|
buf->overflow = 0;
|
2015-05-10 03:05:54 -07:00
|
|
|
stolen = &(buffers[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf = &(buffers[0]);
|
|
|
|
buf->top = 0;
|
2015-05-11 00:55:23 -07:00
|
|
|
buf->overflow = 0;
|
2015-05-10 03:05:54 -07:00
|
|
|
stolen = &(buffers[1]);
|
|
|
|
}
|
|
|
|
eina_spinlock_release(&_evlog_lock);
|
|
|
|
return stolen;
|
|
|
|
}
|
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API void
|
2015-05-10 03:05:54 -07:00
|
|
|
eina_evlog_start(void)
|
|
|
|
{
|
|
|
|
eina_spinlock_take(&_evlog_lock);
|
|
|
|
_evlog_go++;
|
|
|
|
if (_evlog_go == 1)
|
|
|
|
{
|
|
|
|
// alloc 2 buffers for spinning around in
|
|
|
|
alloc_buf(&(buffers[0]), EVLOG_BUF_SIZE);
|
|
|
|
alloc_buf(&(buffers[1]), EVLOG_BUF_SIZE);
|
|
|
|
}
|
|
|
|
eina_spinlock_release(&_evlog_lock);
|
|
|
|
}
|
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API void
|
2015-05-10 03:05:54 -07:00
|
|
|
eina_evlog_stop(void)
|
|
|
|
{
|
|
|
|
eina_spinlock_take(&_evlog_lock);
|
|
|
|
_evlog_go--;
|
|
|
|
if (_evlog_go == 0)
|
|
|
|
{
|
|
|
|
free_buf(&(buffers[0]));
|
|
|
|
free_buf(&(buffers[1]));
|
|
|
|
}
|
|
|
|
eina_spinlock_release(&_evlog_lock);
|
|
|
|
}
|
|
|
|
|
2016-11-26 21:48:10 -08:00
|
|
|
// get evlog
|
2017-05-30 04:14:59 -07:00
|
|
|
static Eina_Bool
|
2016-11-26 21:48:10 -08:00
|
|
|
_get_cb(Eina_Debug_Session *session EINA_UNUSED, int cid EINA_UNUSED, void *buffer EINA_UNUSED, int size EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Eina_Evlog_Buf *evlog = eina_evlog_steal();
|
|
|
|
int resp_size = 0;
|
|
|
|
unsigned char *resp_buf = NULL;
|
|
|
|
|
|
|
|
if ((evlog) && (evlog->buf))
|
|
|
|
{
|
2017-06-03 09:33:58 -07:00
|
|
|
int ovf = SWAP_32(evlog->overflow);
|
2016-11-26 21:48:10 -08:00
|
|
|
resp_size = evlog->top + sizeof(evlog->overflow);
|
2017-06-03 09:33:58 -07:00
|
|
|
resp_buf = malloc(resp_size);
|
|
|
|
memcpy(resp_buf, &ovf, sizeof(ovf));
|
2016-11-26 21:48:10 -08:00
|
|
|
memcpy(resp_buf + sizeof(evlog->overflow), evlog->buf, evlog->top);
|
|
|
|
}
|
|
|
|
printf("send evlog size %d\n", resp_size);
|
|
|
|
eina_debug_session_send(session, cid, _evlog_get_opcode, resp_buf, resp_size);
|
2017-06-03 09:33:58 -07:00
|
|
|
free(resp_buf);
|
2016-11-26 21:48:10 -08:00
|
|
|
|
2017-05-30 04:14:59 -07:00
|
|
|
return EINA_TRUE;
|
2016-11-26 21:48:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// enable evlog
|
2017-05-30 04:14:59 -07:00
|
|
|
static Eina_Bool
|
2016-11-26 21:48:10 -08:00
|
|
|
_start_cb(Eina_Debug_Session *session EINA_UNUSED, int cid EINA_UNUSED, void *buffer EINA_UNUSED, int size EINA_UNUSED)
|
|
|
|
{
|
|
|
|
eina_evlog_start();
|
2017-05-30 04:14:59 -07:00
|
|
|
return EINA_TRUE;
|
2016-11-26 21:48:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// stop evlog
|
2017-05-30 04:14:59 -07:00
|
|
|
static Eina_Bool
|
2016-11-26 21:48:10 -08:00
|
|
|
_stop_cb(Eina_Debug_Session *session EINA_UNUSED, int cid EINA_UNUSED, void *buffer EINA_UNUSED, int size EINA_UNUSED)
|
|
|
|
{
|
|
|
|
eina_evlog_stop();
|
2017-05-30 04:14:59 -07:00
|
|
|
return EINA_TRUE;
|
2016-11-26 21:48:10 -08:00
|
|
|
}
|
|
|
|
|
2017-06-02 02:13:31 -07:00
|
|
|
EINA_DEBUG_OPCODES_ARRAY_DEFINE(_EINA_DEBUG_EVLOG_OPS,
|
|
|
|
{"EvLog/on", NULL, &_start_cb},
|
|
|
|
{"EvLog/off", NULL, &_stop_cb},
|
|
|
|
{"EvLog/get", &_evlog_get_opcode, &_get_cb},
|
|
|
|
{NULL, NULL, NULL}
|
|
|
|
);
|
2016-11-26 21:48:10 -08:00
|
|
|
|
2015-05-10 03:05:54 -07:00
|
|
|
Eina_Bool
|
|
|
|
eina_evlog_init(void)
|
|
|
|
{
|
|
|
|
eina_spinlock_new(&_evlog_lock);
|
|
|
|
buf = &(buffers[0]);
|
2019-11-28 00:59:41 -08:00
|
|
|
#if defined (HAVE_CLOCK_GETTIME)
|
2016-11-09 21:36:10 -08:00
|
|
|
{
|
|
|
|
struct timespec t;
|
|
|
|
|
|
|
|
if (!clock_gettime(CLOCK_MONOTONIC, &t))
|
|
|
|
_eina_evlog_time_clock_id = CLOCK_MONOTONIC;
|
|
|
|
else
|
|
|
|
_eina_evlog_time_clock_id = CLOCK_REALTIME;
|
|
|
|
}
|
|
|
|
#endif
|
2015-05-10 03:05:54 -07:00
|
|
|
eina_evlog("+eina_init", NULL, 0.0, NULL);
|
2017-06-02 02:13:31 -07:00
|
|
|
eina_debug_opcodes_register(NULL, _EINA_DEBUG_EVLOG_OPS(), NULL, NULL);
|
2015-05-10 03:05:54 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
eina_evlog_shutdown(void)
|
|
|
|
{
|
|
|
|
// yes - we don't free tyhe evlog buffers. they may be in used by debug th
|
|
|
|
eina_spinlock_free(&_evlog_lock);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|