17d62b00eSchristos /* Debug printing functions. 27d62b00eSchristos 3*6881a400Schristos Copyright (C) 2014-2023 Free Software Foundation, Inc. 47d62b00eSchristos 57d62b00eSchristos This file is part of GDB. 67d62b00eSchristos 77d62b00eSchristos This program is free software; you can redistribute it and/or modify 87d62b00eSchristos it under the terms of the GNU General Public License as published by 97d62b00eSchristos the Free Software Foundation; either version 3 of the License, or 107d62b00eSchristos (at your option) any later version. 117d62b00eSchristos 127d62b00eSchristos This program is distributed in the hope that it will be useful, 137d62b00eSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 147d62b00eSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 157d62b00eSchristos GNU General Public License for more details. 167d62b00eSchristos 177d62b00eSchristos You should have received a copy of the GNU General Public License 187d62b00eSchristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 197d62b00eSchristos 207d62b00eSchristos #include "common-defs.h" 217d62b00eSchristos #include "common-debug.h" 227d62b00eSchristos 237d62b00eSchristos /* See gdbsupport/common-debug.h. */ 247d62b00eSchristos 257d62b00eSchristos bool show_debug_regs; 267d62b00eSchristos 277d62b00eSchristos /* See gdbsupport/common-debug.h. */ 287d62b00eSchristos 297d62b00eSchristos void 307d62b00eSchristos debug_printf (const char *fmt, ...) 317d62b00eSchristos { 327d62b00eSchristos va_list ap; 337d62b00eSchristos 347d62b00eSchristos va_start (ap, fmt); 357d62b00eSchristos debug_vprintf (fmt, ap); 367d62b00eSchristos va_end (ap); 377d62b00eSchristos } 38*6881a400Schristos 39*6881a400Schristos /* See gdbsupport/common-debug.h. */ 40*6881a400Schristos 41*6881a400Schristos void 42*6881a400Schristos debug_prefixed_printf (const char *module, const char *func, 43*6881a400Schristos const char *format, ...) 44*6881a400Schristos { 45*6881a400Schristos va_list ap; 46*6881a400Schristos 47*6881a400Schristos va_start (ap, format); 48*6881a400Schristos debug_prefixed_vprintf (module, func, format, ap); 49*6881a400Schristos va_end (ap); 50*6881a400Schristos } 51*6881a400Schristos 52*6881a400Schristos /* See gdbsupport/common-debug.h. */ 53*6881a400Schristos 54*6881a400Schristos void 55*6881a400Schristos debug_prefixed_vprintf (const char *module, const char *func, 56*6881a400Schristos const char *format, va_list args) 57*6881a400Schristos { 58*6881a400Schristos if (func != nullptr) 59*6881a400Schristos debug_printf ("%*s[%s] %s: ", debug_print_depth * 2, "", module, func); 60*6881a400Schristos else 61*6881a400Schristos debug_printf ("%*s[%s] ", debug_print_depth * 2, "", module); 62*6881a400Schristos 63*6881a400Schristos debug_vprintf (format, args); 64*6881a400Schristos debug_printf ("\n"); 65*6881a400Schristos } 66