From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 9E64E3857820 for ; Fri, 25 Sep 2020 15:48:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9E64E3857820 X-ASG-Debug-ID: 1601048914-0c856e1c4549500001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id d6wwg8EqnLG8ZFKA (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 25 Sep 2020 11:48:34 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) by smtp.ebox.ca (Postfix) with ESMTP id A3342441D65; Fri, 25 Sep 2020 11:48:34 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 173.246.6.90 X-Barracuda-Effective-Source-IP: 173-246-6-90.qc.cable.ebox.net[173.246.6.90] X-Barracuda-Apparent-Source-IP: 173.246.6.90 To: gdb-patches@sourceware.org Subject: [PATCH 3/4] gdb: move debug_prefixed_vprintf to gdbsupport Date: Fri, 25 Sep 2020 11:48:30 -0400 X-ASG-Orig-Subj: [PATCH 3/4] gdb: move debug_prefixed_vprintf to gdbsupport Message-Id: <20200925154831.2759299-4-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200925154831.2759299-1-simon.marchi@polymtl.ca> References: <20200925154831.2759299-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1601048914 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 4752 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.84871 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2020 15:48:46 -0000 The following patch needs to output debug prints in gdbsupport code. Move debug_prefixed_vprintf so that it is possible to use it from there gdb/ChangeLog: * debug.c (debug_prefixed_vprintf): Move to gdbsupport. * debug.h: Remove. * infrun.c: Include gdbsupport/common-debug.h. * linux-nat.c: Likewise. gdbsupport/ChangeLog: * common-debug.cc (debug_prefixed_vprintf): Move here. * common-debug.h (debug_prefixed_vprintf): Move here. Change-Id: I5170065fc10a7a49c0f1bba67c691decb2cf3bcb --- gdb/debug.c | 13 +------------ gdb/debug.h | 32 -------------------------------- gdb/infrun.c | 2 +- gdb/linux-nat.c | 2 +- gdbsupport/common-debug.cc | 11 +++++++++++ gdbsupport/common-debug.h | 6 ++++++ 6 files changed, 20 insertions(+), 46 deletions(-) delete mode 100644 gdb/debug.h diff --git a/gdb/debug.c b/gdb/debug.c index f845a7e3b1e7..fe571aaae393 100644 --- a/gdb/debug.c +++ b/gdb/debug.c @@ -19,7 +19,7 @@ #include "defs.h" -#include "debug.h" +#include "gdbsupport/common-debug.h" /* See gdbsupport/common-debug.h. */ @@ -28,14 +28,3 @@ debug_vprintf (const char *fmt, va_list ap) { vfprintf_unfiltered (gdb_stdlog, fmt, ap); } - -/* See debug.h. */ - -void -debug_prefixed_vprintf (const char *module, const char *func, const char *format, - va_list args) -{ - debug_printf ("[%s] %s: ", module, func); - debug_vprintf (format, args); - debug_printf ("\n"); -} diff --git a/gdb/debug.h b/gdb/debug.h deleted file mode 100644 index 1d98fbebec6c..000000000000 --- a/gdb/debug.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Helpers to format and print debug statements - - Copyright (C) 2020 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef DEBUG_H -#define DEBUG_H - -/* Print a debug statement prefixed with the module and function name, and - with a newline at the end. */ - -void ATTRIBUTE_PRINTF (3, 0) -debug_prefixed_vprintf (const char *module, const char *func, const char *format, - va_list args); - -#endif /* DEBUG_H */ - - diff --git a/gdb/infrun.c b/gdb/infrun.c index 4e9492b35961..03ca333c38a2 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -70,7 +70,7 @@ #include "gdbsupport/selftest.h" #include "scoped-mock-context.h" #include "test-target.h" -#include "debug.h" +#include "gdbsupport/common-debug.h" /* Prototypes for local functions */ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index e47a23454bf6..5d616293196e 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -68,7 +68,7 @@ #include "gdbsupport/fileio.h" #include "gdbsupport/scope-exit.h" #include "gdbsupport/gdb-sigmask.h" -#include "debug.h" +#include "gdbsupport/common-debug.h" /* This comment documents high-level logic of this file. diff --git a/gdbsupport/common-debug.cc b/gdbsupport/common-debug.cc index d1131a0a8796..b8fd133159fb 100644 --- a/gdbsupport/common-debug.cc +++ b/gdbsupport/common-debug.cc @@ -35,3 +35,14 @@ debug_printf (const char *fmt, ...) debug_vprintf (fmt, ap); va_end (ap); } + +/* See gdbsupport/common-debug.h. */ + +void +debug_prefixed_vprintf (const char *module, const char *func, const char *format, + va_list args) +{ + debug_printf ("[%s] %s: ", module, func); + debug_vprintf (format, args); + debug_printf ("\n"); +} diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h index 9934ec543d28..afb427e18005 100644 --- a/gdbsupport/common-debug.h +++ b/gdbsupport/common-debug.h @@ -38,4 +38,10 @@ extern void debug_printf (const char *format, ...) extern void debug_vprintf (const char *format, va_list ap) ATTRIBUTE_PRINTF (1, 0); +/* Print a debug statement prefixed with the module and function name, and + with a newline at the end. */ + +extern void ATTRIBUTE_PRINTF (3, 0) debug_prefixed_vprintf + (const char *module, const char *func, const char *format, va_list args); + #endif /* COMMON_COMMON_DEBUG_H */ -- 2.28.0