xref: /netbsd-src/external/gpl3/gdb/dist/gdbsupport/common-debug.cc (revision 5ba1f45f2a09259cc846f20c7c5501604d633c90)
18dffb485Schristos /* Debug printing functions.
28dffb485Schristos 
3*5ba1f45fSchristos    Copyright (C) 2014-2024 Free Software Foundation, Inc.
48dffb485Schristos 
58dffb485Schristos    This file is part of GDB.
68dffb485Schristos 
78dffb485Schristos    This program is free software; you can redistribute it and/or modify
88dffb485Schristos    it under the terms of the GNU General Public License as published by
98dffb485Schristos    the Free Software Foundation; either version 3 of the License, or
108dffb485Schristos    (at your option) any later version.
118dffb485Schristos 
128dffb485Schristos    This program is distributed in the hope that it will be useful,
138dffb485Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
148dffb485Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
158dffb485Schristos    GNU General Public License for more details.
168dffb485Schristos 
178dffb485Schristos    You should have received a copy of the GNU General Public License
188dffb485Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
198dffb485Schristos 
208dffb485Schristos #include "common-debug.h"
218dffb485Schristos 
228dffb485Schristos /* See gdbsupport/common-debug.h.  */
238dffb485Schristos 
248dffb485Schristos bool show_debug_regs;
258dffb485Schristos 
268dffb485Schristos /* See gdbsupport/common-debug.h.  */
278dffb485Schristos 
288dffb485Schristos void
298dffb485Schristos debug_printf (const char *fmt, ...)
308dffb485Schristos {
318dffb485Schristos   va_list ap;
328dffb485Schristos 
338dffb485Schristos   va_start (ap, fmt);
348dffb485Schristos   debug_vprintf (fmt, ap);
358dffb485Schristos   va_end (ap);
368dffb485Schristos }
374b169a6bSchristos 
384b169a6bSchristos /* See gdbsupport/common-debug.h.  */
394b169a6bSchristos 
404b169a6bSchristos void
414b169a6bSchristos debug_prefixed_printf (const char *module, const char *func,
424b169a6bSchristos 		       const char *format, ...)
434b169a6bSchristos {
444b169a6bSchristos   va_list ap;
454b169a6bSchristos 
464b169a6bSchristos   va_start (ap, format);
474b169a6bSchristos   debug_prefixed_vprintf (module, func, format, ap);
484b169a6bSchristos   va_end (ap);
494b169a6bSchristos }
504b169a6bSchristos 
514b169a6bSchristos /* See gdbsupport/common-debug.h.  */
524b169a6bSchristos 
534b169a6bSchristos void
544b169a6bSchristos debug_prefixed_vprintf (const char *module, const char *func,
554b169a6bSchristos 			const char *format, va_list args)
564b169a6bSchristos {
574b169a6bSchristos   if (func != nullptr)
584b169a6bSchristos     debug_printf ("%*s[%s] %s: ", debug_print_depth * 2, "", module, func);
594b169a6bSchristos   else
604b169a6bSchristos     debug_printf ("%*s[%s] ", debug_print_depth * 2, "", module);
614b169a6bSchristos 
624b169a6bSchristos   debug_vprintf (format, args);
634b169a6bSchristos   debug_printf ("\n");
644b169a6bSchristos }
65