$search
00001 /* 00002 * Backtrace debugging 00003 * Copyright (c) 2009, Jouni Malinen <j@w1.fi> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation. 00008 * 00009 * Alternatively, this software may be distributed under the terms of BSD 00010 * license. 00011 * 00012 * See README and COPYING for more details. 00013 */ 00014 00015 #ifndef TRACE_H 00016 #define TRACE_H 00017 00018 #define WPA_TRACE_LEN 16 00019 00020 #ifdef WPA_TRACE 00021 #include <execinfo.h> 00022 00023 #include "list.h" 00024 00025 #define WPA_TRACE_INFO void *btrace[WPA_TRACE_LEN]; int btrace_num; 00026 00027 struct wpa_trace_ref { 00028 struct dl_list list; 00029 const void *addr; 00030 WPA_TRACE_INFO 00031 }; 00032 #define WPA_TRACE_REF(name) struct wpa_trace_ref wpa_trace_ref_##name 00033 00034 #define wpa_trace_dump(title, ptr) \ 00035 wpa_trace_dump_func((title), (ptr)->btrace, (ptr)->btrace_num) 00036 void wpa_trace_dump_func(const char *title, void **btrace, int btrace_num); 00037 #define wpa_trace_record(ptr) \ 00038 (ptr)->btrace_num = backtrace((ptr)->btrace, WPA_TRACE_LEN) 00039 void wpa_trace_show(const char *title); 00040 #define wpa_trace_add_ref(ptr, name, addr) \ 00041 wpa_trace_add_ref_func(&(ptr)->wpa_trace_ref_##name, (addr)) 00042 void wpa_trace_add_ref_func(struct wpa_trace_ref *ref, const void *addr); 00043 #define wpa_trace_remove_ref(ptr, name, addr) \ 00044 do { \ 00045 if ((addr)) \ 00046 dl_list_del(&(ptr)->wpa_trace_ref_##name.list); \ 00047 } while (0) 00048 void wpa_trace_check_ref(const void *addr); 00049 00050 #else /* WPA_TRACE */ 00051 00052 #define WPA_TRACE_INFO 00053 #define WPA_TRACE_REF(n) 00054 #define wpa_trace_dump(title, ptr) do { } while (0) 00055 #define wpa_trace_record(ptr) do { } while (0) 00056 #define wpa_trace_show(title) do { } while (0) 00057 #define wpa_trace_add_ref(ptr, name, addr) do { } while (0) 00058 #define wpa_trace_remove_ref(ptr, name, addr) do { } while (0) 00059 #define wpa_trace_check_ref(addr) do { } while (0) 00060 00061 #endif /* WPA_TRACE */ 00062 00063 00064 #ifdef WPA_TRACE_BFD 00065 00066 void wpa_trace_dump_funcname(const char *title, void *pc); 00067 00068 #else /* WPA_TRACE_BFD */ 00069 00070 #define wpa_trace_dump_funcname(title, pc) do { } while (0) 00071 00072 #endif /* WPA_TRACE_BFD */ 00073 00074 #endif /* TRACE_H */