* if not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <unistd.h>
-#include <sys/epoll.h>
+#ifdef HAVE_SYS_EPOLL_H
+# include <sys/epoll.h>
+#endif
#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
#include <fcntl.h>
#include "eina_debug_private.h"
static Eina_Bool
_server_launch()
{
+#ifndef _WIN32
struct epoll_event event = {0};
_epfd = epoll_create (MAX_EVENTS);
-#ifndef _WIN32
_listening_unix_fd = _listening_unix_socket_create();
-#else
- _listening_unix_fd = -1;
-#endif
if (_listening_unix_fd <= 0) goto err;
event.data.fd = _listening_unix_fd;
event.events = EPOLLIN;
_listening_unix_fd = -1;
if (_listening_tcp_fd >= 0) close(_listening_tcp_fd);
_listening_tcp_fd = -1;
+#endif
return EINA_FALSE;
}
# define _GNU_SOURCE 1
# endif
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
-#include <sys/epoll.h>
+#ifdef HAVE_SYS_EPOLL_H
+# include <sys/epoll.h>
+#endif
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
#include <fcntl.h>
+#ifdef _WIN32
+# include <winsock2.h>
+# include <Evil.h>
+#endif
+
#include "eina_debug.h"
#include "eina_types.h"
#include "eina_list.h"
#include "eina_stringshare.h"
#include "eina_debug_private.h"
-#ifdef __CYGWIN__
+#if defined(__CYGWIN__) || defined (_WIN32)
# define LIBEXT ".dll"
#else
# define LIBEXT ".so"
int fd; /* File descriptor */
};
+#ifndef _WIN32
static void _opcodes_register_all(Eina_Debug_Session *session);
+#endif
static void _thread_start(Eina_Debug_Session *session);
EAPI int
/* Sending payload */
if (size) write(session->fd, data, size);
eina_spinlock_release(&_eina_debug_lock);
+#else
+ (void)data;
#endif
return size;
}
+#ifndef _WIN32
static void
_daemon_greet(Eina_Debug_Session *session)
{
eina_debug_session_send(session, 0, EINA_DEBUG_OPCODE_HELLO, buf, size);
}
-#ifndef _WIN32
static int
_packet_receive(Eina_Debug_Session *session, unsigned char **buffer)
{
else return NULL;
}
+#ifndef _WIN32
static void
_static_opcode_register(Eina_Debug_Session *session,
int op_id, Eina_Debug_Cb cb)
return EINA_FALSE;
}
+#endif
static void
_opcodes_registration_send(Eina_Debug_Session *session,
buf = malloc(size);
- uint64_t info_64 = (uint64_t)info;
+ uint64_t info_64 = (uint64_t)(uintptr_t)info;
info_64 = SWAP_64(info_64);
memcpy(buf, &info_64, sizeof(uint64_t));
int size_curr = sizeof(uint64_t);
free(buf);
}
+#ifndef _WIN32
static void
_opcodes_register_all(Eina_Debug_Session *session)
{
return dir;
}
-#ifndef _WIN32
#define LENGTH_OF_SOCKADDR_UN(s) \
(strlen((s)->sun_path) + (size_t)(((struct sockaddr_un *)NULL)->sun_path))
#endif
// even if the mainloop is blocked or the app otherwise deadlocked in some
// way. this is an alternative to using external debuggers so we can get
// users or developers to get useful information about an app at all times
+
+#ifndef _WIN32
static void *
_monitor(void *_data)
{
}
return NULL;
}
+#endif
// start up the debug monitor if we haven't already
static void
_thread_start(Eina_Debug_Session *session)
{
+#ifndef _WIN32
pthread_t monitor_thread;
int err;
sigset_t oldset, newset;
e_debug("EINA DEBUG ERROR: Can't create monitor debug thread!");
abort();
}
+#else
+ (void)session;
+#endif
}
/*
# endif
#ifdef HAVE_DLADDR
-# include <dlfcn.h>
+# ifdef _WIN32
+# include <Evil.h>
+# else
+# include <dlfcn.h>
+# endif
#endif
+
+#ifdef HAVE_UNWIND
#include <libunwind.h>
+#endif
#include "eina_debug.h"
#include "eina_debug_private.h"
-#define SIG SIGPROF
+#ifndef _WIN32
+# define SIG SIGPROF
+#endif
static Eina_Semaphore _wait_for_bts_sem;
void
_eina_debug_dump_fhandle_bt(FILE *f, void **bt, int btlen)
{
+#ifndef _WIN32
int i;
Dl_info info;
const char *file;
if (file) fprintf(f, "%s\t 0x%llx 0x%llx\n", file, offset, base);
else fprintf(f, "??\t -\n");
}
+#else
+ (void)f;
+ (void)bt;
+ (void)btlen;
+#endif
}
// a backtracer that uses libunwind to do the job
static inline int
_eina_debug_unwind_bt(void **bt, int max)
{
+#ifdef HAVE_UNWIND
unw_cursor_t cursor;
unw_context_t uc;
unw_word_t p;
}
// return our total backtrace stack size
return total;
+#else
+ (void)bt;
+ (void)max;
+ return 0;
+#endif
}
// a quick and dirty local time point getter func - not portable
#endif
}
+#ifndef _WIN32
static void
_signal_handler(int sig EINA_UNUSED,
siginfo_t *si EINA_UNUSED, void *foo EINA_UNUSED)
// backtrace info
eina_semaphore_release(&_wait_for_bts_sem, 1);
}
+#endif
static void
_signal_init(void)
{
+#ifndef _WIN32
struct sigaction sa;
// set up signal handler for our profiling signal - eevery thread should
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
if (sigaction(SIGPIPE, &sa, 0) == -1) perror(0);
+#endif
}
static void
{
// this async signals the thread to switch to the deebug signal handler
// and collect a backtrace and other info from inside the thread
+#ifndef _WIN32
pthread_kill(pth, SIG);
+#endif
}
static Eina_Bool
eina_semaphore_free(&_wait_for_bts_sem);
return EINA_TRUE;
}
+
const char *_eina_debug_file_get(const char *fname);
void _eina_debug_dump_fhandle_bt(FILE *f, void **bt, int btlen);
+
#define EINA_MAX_BT 256
+#ifdef HAVE_BACKTRACE
#define EINA_BT(file) \
do { \
void *bt[EINA_MAX_BT]; \
int btlen = backtrace((void **)bt, EINA_MAX_BT); \
_eina_debug_dump_fhandle_bt(file, bt, btlen); \
} while (0)
+#else
+#define EINA_BT(file) do { } while (0)
+#endif
+
Eina_Bool _eina_debug_cpu_init(void);
Eina_Bool _eina_debug_cpu_shutdown(void);
# define _GNU_SOURCE 1
# endif
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
-#include <sys/epoll.h>
+#ifdef HAVE_SYS_EPOLL_H
+# include <sys/epoll.h>
+#endif
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
_eina_debug_timer_init(void)
{
eina_spinlock_new(&_lock);
+#ifndef _WIN32
pipe(pipeToThread);
+#endif
return EINA_TRUE;
}