Add a little more event loop debug output

This commit is contained in:
Kovid Goyal 2019-07-07 06:10:59 +05:30
parent e7173f8145
commit 003cd0a203
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 25 additions and 0 deletions

View File

@ -21,6 +21,12 @@
#include <signal.h>
extern PyTypeObject Screen_Type;
#ifdef DEBUG_EVENT_LOOP
#define EVDBG(...) log_event(__VA_ARGS__)
#else
#define EVDBG(...)
#endif
#define EXTRA_FDS 2
#ifndef MSG_NOSIGNAL
// Apple does not implement MSG_NOSIGNAL
@ -884,6 +890,7 @@ static void process_global_state(void *data);
static void
do_state_check(id_type timer_id UNUSED, void *data UNUSED) {
EVDBG("State check timer fired");
#ifdef __APPLE__
process_global_state(data);
#endif
@ -896,6 +903,7 @@ static id_type state_check_timer = 0;
static void
process_global_state(void *data) {
EVDBG("Processing global state");
ChildMonitor *self = data;
maximum_wait = -1;
bool state_check_timer_enabled = false;

View File

@ -313,3 +313,4 @@ SPRITE_MAP_HANDLE alloc_sprite_map(unsigned int, unsigned int);
SPRITE_MAP_HANDLE free_sprite_map(SPRITE_MAP_HANDLE);
static inline void safe_close(int fd) { while(close(fd) != 0 && errno == EINTR); }
void log_event(const char *format, ...) __attribute__((format(printf, 1, 2)));

View File

@ -66,6 +66,22 @@ update_os_window_viewport(OSWindow *window, bool notify_boss) {
}
}
void
log_event(const char *format, ...) {
if (format)
{
va_list vl;
fprintf(stderr, "[%.4f] ", glfwGetTime());
va_start(vl, format);
vfprintf(stderr, format, vl);
va_end(vl);
fprintf(stderr, "\n");
}
}
// callbacks {{{
void