aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/trace.h
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-12-22 01:11:15 +0200
committerJouni Malinen <j@w1.fi>2009-12-22 01:11:15 +0200
commita6ff0e0810b49c8f8901406a42e3c975f3aed85e (patch)
tree91acf59c33689f248a8f5878e7ade92b873ac6f3 /src/utils/trace.h
parenta698d28415e9d510321954673b4a76b862b4066d (diff)
downloadexternal_wpa_supplicant_8_ti-a6ff0e0810b49c8f8901406a42e3c975f3aed85e.zip
external_wpa_supplicant_8_ti-a6ff0e0810b49c8f8901406a42e3c975f3aed85e.tar.gz
external_wpa_supplicant_8_ti-a6ff0e0810b49c8f8901406a42e3c975f3aed85e.tar.bz2
trace: Add active reference tracking
This WPA_TRACE=y additions allows components to register active references to memory that has been provided to them as a pointer. If such an actively referenced memory area is freed, tracer will report this as an error and backtraces of both the invalid free and the location where this pointer was marked referenced are shown.
Diffstat (limited to 'src/utils/trace.h')
-rw-r--r--src/utils/trace.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/utils/trace.h b/src/utils/trace.h
index 8074d25..009b6e3 100644
--- a/src/utils/trace.h
+++ b/src/utils/trace.h
@@ -20,20 +20,43 @@
#ifdef WPA_TRACE
#include <execinfo.h>
+#include "list.h"
+
#define WPA_TRACE_INFO void *btrace[WPA_TRACE_LEN]; int btrace_num;
+
+struct wpa_trace_ref {
+ struct dl_list list;
+ const void *addr;
+ WPA_TRACE_INFO
+};
+#define WPA_TRACE_REF(name) struct wpa_trace_ref wpa_trace_ref_##name
+
#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);
+#define wpa_trace_add_ref(ptr, name, addr) \
+ wpa_trace_add_ref_func(&(ptr)->wpa_trace_ref_##name, (addr))
+void wpa_trace_add_ref_func(struct wpa_trace_ref *ref, const void *addr);
+#define wpa_trace_remove_ref(ptr, name, addr) \
+ do { \
+ if ((addr)) \
+ dl_list_del(&(ptr)->wpa_trace_ref_##name.list); \
+ } while (0)
+void wpa_trace_check_ref(const void *addr);
#else /* WPA_TRACE */
#define WPA_TRACE_INFO
+#define WPA_TRACE_REF(n)
#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)
+#define wpa_trace_add_ref(ptr, name, addr) do { } while (0)
+#define wpa_trace_remove_ref(ptr, name, addr) do { } while (0)
+#define wpa_trace_check_ref(addr) do { } while (0)
#endif /* WPA_TRACE */