common-debug.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Debug printing functions.
  2. Copyright (C) 2014-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #include "common-defs.h"
  15. #include "common-debug.h"
  16. /* See gdbsupport/common-debug.h. */
  17. bool show_debug_regs;
  18. /* See gdbsupport/common-debug.h. */
  19. void
  20. debug_printf (const char *fmt, ...)
  21. {
  22. va_list ap;
  23. va_start (ap, fmt);
  24. debug_vprintf (fmt, ap);
  25. va_end (ap);
  26. }
  27. /* See gdbsupport/common-debug.h. */
  28. void
  29. debug_prefixed_printf (const char *module, const char *func,
  30. const char *format, ...)
  31. {
  32. va_list ap;
  33. va_start (ap, format);
  34. debug_prefixed_vprintf (module, func, format, ap);
  35. va_end (ap);
  36. }
  37. /* See gdbsupport/common-debug.h. */
  38. void
  39. debug_prefixed_vprintf (const char *module, const char *func,
  40. const char *format, va_list args)
  41. {
  42. if (func != nullptr)
  43. debug_printf ("%*s[%s] %s: ", debug_print_depth * 2, "", module, func);
  44. else
  45. debug_printf ("%*s[%s] ", debug_print_depth * 2, "", module);
  46. debug_vprintf (format, args);
  47. debug_printf ("\n");
  48. }