OBJS += ../src/drivers/scan_helpers.o
CFLAGS += -DHOSTAPD
+ifdef CONFIG_WPA_TRACE
+CFLAGS += -DWPA_TRACE
+OBJS += ../src/utils/trace.o
+endif
+
OBJS += ../src/utils/eloop.o
OBJS += ../src/utils/common.o
OBJS += ../src/utils/wpa_debug.o
include ../lib.rules
+#CFLAGS += -DWPA_TRACE
+
LIB_OBJS= \
base64.o \
common.o \
ip_addr.o \
radiotap.o \
+ trace.o \
uuid.o \
wpa_debug.o \
wpabuf.o
#include "includes.h"
#include "common.h"
+#include "trace.h"
#include "eloop.h"
void *eloop_data;
void *user_data;
eloop_sock_handler handler;
+ WPA_TRACE_INFO
};
struct eloop_timeout {
void *user_data;
eloop_timeout_handler handler;
struct eloop_timeout *next;
+ WPA_TRACE_INFO
};
struct eloop_signal {
static struct eloop_data eloop;
+#ifdef WPA_TRACE
+static void eloop_sigsegv_handler(int sig)
+{
+ wpa_trace_show("eloop SIGSEGV");
+ abort();
+}
+#endif /* WPA_TRACE */
+
+
int eloop_init(void *user_data)
{
os_memset(&eloop, 0, sizeof(eloop));
eloop.user_data = user_data;
+#ifdef WPA_TRACE
+ signal(SIGSEGV, eloop_sigsegv_handler);
+#endif /* WPA_TRACE */
return 0;
}
tmp[table->count].eloop_data = eloop_data;
tmp[table->count].user_data = user_data;
tmp[table->count].handler = handler;
+ wpa_trace_record(&tmp[table->count]);
table->count++;
table->table = tmp;
if (sock > eloop.max_sock)
table->table[i].eloop_data,
table->table[i].user_data,
table->table[i].handler);
+ wpa_trace_dump("eloop sock", &table->table[i]);
}
os_free(table->table);
}
timeout->user_data = user_data;
timeout->handler = handler;
timeout->next = NULL;
+ wpa_trace_record(timeout);
if (eloop.timeout == NULL) {
eloop.timeout = timeout;
"user_data=%p handler=%p\n",
sec, usec, prev->eloop_data, prev->user_data,
prev->handler);
+ wpa_trace_dump("eloop timeout", prev);
os_free(prev);
}
eloop_sock_table_destroy(&eloop.readers);
--- /dev/null
+/*
+ * Backtrace debugging
+ * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#include "includes.h"
+
+#include "common.h"
+#include "trace.h"
+
+#ifdef WPA_TRACE
+
+void wpa_trace_dump_func(const char *title, void **btrace, int btrace_num)
+{
+ char **sym;
+ int i;
+
+ wpa_printf(MSG_INFO, "WPA_TRACE: %s - START", title);
+ sym = backtrace_symbols(btrace, btrace_num);
+ for (i = 0; i < btrace_num; i++)
+ wpa_printf(MSG_INFO, "[%d]: %p: %s",
+ i, btrace[i], sym ? sym[i] : "");
+ os_free(sym);
+ wpa_printf(MSG_INFO, "WPA_TRACE: %s - END", title);
+}
+
+
+void wpa_trace_show(const char *title)
+{
+ struct info {
+ WPA_TRACE_INFO
+ } info;
+ wpa_trace_record(&info);
+ wpa_trace_dump(title, &info);
+}
+
+#endif /* WPA_TRACE */
--- /dev/null
+/*
+ * Backtrace debugging
+ * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#ifndef TRACE_H
+#define TRACE_H
+
+#define WPA_TRACE_LEN 16
+
+#ifdef WPA_TRACE
+#include <execinfo.h>
+
+#define WPA_TRACE_INFO void *btrace[WPA_TRACE_LEN]; int btrace_num;
+#define wpa_trace_dump(title, ptr) \
+ wpa_trace_dump_func((title), (ptr)->btrace, (ptr)->btrace_num)
+void wpa_trace_dump_func(const char *title, void **btrace, int btrace_num);
+#define wpa_trace_record(ptr) \
+ (ptr)->btrace_num = backtrace((ptr)->btrace, WPA_TRACE_LEN)
+void wpa_trace_show(const char *title);
+
+#else /* WPA_TRACE */
+
+#define WPA_TRACE_INFO
+#define wpa_trace_dump(title, ptr) do { } while (0)
+#define wpa_trace_record(ptr) do { } while (0)
+#define wpa_trace_show(title) do { } while (0)
+
+#endif /* WPA_TRACE */
+
+#endif /* TRACE_H */
OBJS_p += ../src/utils/os_$(CONFIG_OS).o
OBJS_c += ../src/utils/os_$(CONFIG_OS).o
+ifdef CONFIG_WPA_TRACE
+CFLAGS += -DWPA_TRACE
+OBJS += ../src/utils/trace.o
+endif
+
ifndef CONFIG_ELOOP
CONFIG_ELOOP=eloop
endif