trace.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Backtrace debugging
  3. * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #include "includes.h"
  15. #include "common.h"
  16. #include "trace.h"
  17. #ifdef WPA_TRACE
  18. void wpa_trace_dump_func(const char *title, void **btrace, int btrace_num)
  19. {
  20. char **sym;
  21. int i;
  22. wpa_printf(MSG_INFO, "WPA_TRACE: %s - START", title);
  23. sym = backtrace_symbols(btrace, btrace_num);
  24. for (i = 0; i < btrace_num; i++)
  25. wpa_printf(MSG_INFO, "[%d]: %p: %s",
  26. i, btrace[i], sym ? sym[i] : "");
  27. os_free(sym);
  28. wpa_printf(MSG_INFO, "WPA_TRACE: %s - END", title);
  29. }
  30. void wpa_trace_show(const char *title)
  31. {
  32. struct info {
  33. WPA_TRACE_INFO
  34. } info;
  35. wpa_trace_record(&info);
  36. wpa_trace_dump(title, &info);
  37. }
  38. #endif /* WPA_TRACE */