From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21649 invoked by alias); 6 Aug 2014 17:08:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 21631 invoked by uid 89); 6 Aug 2014 17:08:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ie0-f201.google.com Received: from mail-ie0-f201.google.com (HELO mail-ie0-f201.google.com) (209.85.223.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 06 Aug 2014 17:08:07 +0000 Received: by mail-ie0-f201.google.com with SMTP id tr6so523849ieb.0 for ; Wed, 06 Aug 2014 10:08:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:cc:subject:in-reply-to :references; bh=K9JR6hov2RF6Hb/o9CPqwfvhE2xOoVNu7ObWL3rTYq0=; b=PHsiBiAt9hWb2yR1ivkpboQOt5I69/fduJQe9V5OdWbw7WHjUcHviskD64IVqCQs8Q 8kuoLoSRGlMynqOkliNSYUZ0u9d3V5oKUpYDlwntxvzTBq0WayEFzSQG9AbKSlgEXPgG KVbqaIk0o5rnV3WH4wD21ro7MtdYBUm+l+eF1XDMqqFxLhvhjfWuhcVQdE0Ijq2H7WQQ f/BRG6bOpEjoyHF8m8p+UE2Q1USjFYT1eK2G9GlqnJQHL28GX+PwwU71QMDmMgDV031Y aJvb7Pb+PH+3SS2XkHJcpTwBeuEQ19zaQjMhR2c81JG7EZyD68qklJgdO+kbb0Qn4V2n DzUQ== X-Gm-Message-State: ALoCoQn+zgYAkYAlVaGaKq01iv+VlFSgzI5bl0ZybRO/mPc88DByntIK9xij8TsGW6DZFi4Sccl5 X-Received: by 10.182.45.162 with SMTP id o2mr6509905obm.20.1407344885388; Wed, 06 Aug 2014 10:08:05 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id a66si100425yhg.7.2014.08.06.10.08.05 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Aug 2014 10:08:05 -0700 (PDT) Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.17.128.44]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 7EB4B5A4332; Wed, 6 Aug 2014 10:08:04 -0700 (PDT) From: Doug Evans MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <21474.24819.964899.502265@ruffy.mtv.corp.google.com> Date: Wed, 06 Aug 2014 17:08:00 -0000 To: Gary Benson Cc: gdb-patches@sourceware.org, Pedro Alves , Tom Tromey Subject: Re: [PATCH 04/11 v5] Introduce and use debug_printf and debug_vprintf In-Reply-To: <1406888377-25795-5-git-send-email-gbenson@redhat.com> References: <1406888377-25795-1-git-send-email-gbenson@redhat.com> <1406888377-25795-5-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00106.txt.bz2 Gary Benson writes: > This introduces debug_vprintf (a function that clients of "common" are > expected to implement) and debug_printf (a wrapper for debug_vprintf). > A debug_vprintf function is written from scratch for GDB; gdbserver's > existing debug_printf is repurposed as debug_vprintf. > > common/agent.c is changed to use debug_vprintf rather than > defining the macro DEBUG_AGENT depending on GDBSERVER. > > nat/i386-dregs.c is changed to use the externally-implemented > debug_printf, rather than defining it itself. > > gdb/ > 2014-08-01 Tom Tromey > Gary Benson > > * common/common-debug.h: New file. > * common/common-debug.c: Likewise. > * debug.c: Likewise. > * Makefile.in (HFILES_NO_SRCDIR): Add common/common-debug.h. > (COMMON_OBS): Add common-debug.o and debug.o. > (common-debug.o): New rule. > * common/common-defs.h: Include common-debug.h. > * common/agent.c (debug_agent_print): New function. > (DEBUG_AGENT): Redefine. > * nat/i386-dregs.c (debug_printf): Undefine. > > gdb/gdbserver/ > 2014-08-01 Tom Tromey > Gary Benson > > * Makefile.in (SFILES): Add common/common-debug.c. > (OBS): Add common-debug.o. > (common-debug.o): New rule. > * debug.h (debug_printf): Don't declare. > * debug.c (debug_printf): Renamed and rewritten as... > (debug_vprintf): New function. > --- > gdb/ChangeLog | 14 ++++++++++++++ > gdb/Makefile.in | 9 +++++++-- > gdb/common/agent.c | 24 +++++++++++++++--------- > gdb/common/common-debug.c | 37 +++++++++++++++++++++++++++++++++++++ > gdb/common/common-debug.h | 35 +++++++++++++++++++++++++++++++++++ > gdb/common/common-defs.h | 1 + > gdb/debug.c | 28 ++++++++++++++++++++++++++++ > gdb/gdbserver/ChangeLog | 10 ++++++++++ > gdb/gdbserver/Makefile.in | 10 +++++++--- > gdb/gdbserver/debug.c | 11 ++++------- > gdb/gdbserver/debug.h | 1 - > gdb/nat/i386-dregs.c | 4 ---- > 12 files changed, 158 insertions(+), 26 deletions(-) > create mode 100644 gdb/common/common-debug.c > create mode 100644 gdb/common/common-debug.h > create mode 100644 gdb/debug.c > > diff --git a/gdb/Makefile.in b/gdb/Makefile.in > index 2fac59d..8429ebc 100644 > --- a/gdb/Makefile.in > +++ b/gdb/Makefile.in > @@ -935,7 +935,8 @@ gdb_bfd.h sparc-ravenscar-thread.h ppc-ravenscar-thread.h nat/linux-btrace.h \ > ctf.h nat/i386-cpuid.h nat/i386-gcc-cpuid.h target/resume.h \ > target/wait.h target/waitstatus.h nat/linux-nat.h nat/linux-waitpid.h \ > common/print-utils.h common/rsp-low.h nat/i386-dregs.h x86-linux-nat.h \ > -i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h > +i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \ > +common/common-debug.h > > # Header files that already have srcdir in them, or which are in objdir. > > @@ -1034,7 +1035,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ > gdb_vecs.o jit.o progspace.o skip.o probe.o \ > common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o \ > format.o registry.o btrace.o record-btrace.o waitstatus.o \ > - print-utils.o rsp-low.o errors.o > + print-utils.o rsp-low.o errors.o common-debug.o debug.o > > TSOBS = inflow.o > > @@ -2148,6 +2149,10 @@ errors.o: ${srcdir}/common/errors.c > $(COMPILE) $(srcdir)/common/errors.c > $(POSTCOMPILE) > > +common-debug.o: ${srcdir}/common/common-debug.c > + $(COMPILE) $(srcdir)/common/common-debug.c > + $(POSTCOMPILE) > + > # > # gdb/target/ dependencies > # > diff --git a/gdb/common/agent.c b/gdb/common/agent.c > index 3f868ba..7071ce6 100644 > --- a/gdb/common/agent.c > +++ b/gdb/common/agent.c > @@ -31,15 +31,21 @@ > > int debug_agent = 0; > > -#ifdef GDBSERVER > -#define DEBUG_AGENT(fmt, args...) \ > - if (debug_agent) \ > - fprintf (stderr, fmt, ##args); > -#else > -#define DEBUG_AGENT(fmt, args...) \ > - if (debug_agent) \ > - fprintf_unfiltered (gdb_stdlog, fmt, ##args); > -#endif > +/* A stdarg wrapper for debug_vprintf. */ > + > +static void ATTRIBUTE_PRINTF (1, 2) > +debug_agent_print (const char *fmt, ...) Nit: debug_agent_printf ? > +{ > + va_list ap; > + > + if (!debug_agent) > + return; > + va_start (ap, fmt); > + debug_vprintf (fmt, ap); > + va_end (ap); > +} > + > +#define DEBUG_AGENT debug_agent_print > > /* Global flag to determine using agent or not. */ > int use_agent = 0; > [...] > diff --git a/gdb/common/common-debug.h b/gdb/common/common-debug.h > new file mode 100644 > index 0000000..0467610 > --- /dev/null > +++ b/gdb/common/common-debug.h > @@ -0,0 +1,35 @@ > +/* Declarations for debug printing functions. > + > + Copyright (C) 2014 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 COMMON_DEBUG_H > +#define COMMON_DEBUG_H > + > +/* Print a formatted message to the appropriate channel for debugging > + output for the client. */ > + > +extern void debug_printf (const char *format, ...) > + ATTRIBUTE_PRINTF (1, 2); > + > +/* Print a formatted message to the appropriate channel for debugging > + output for the client. */ IWBN to include mention that this function must be provided by the client. [I'm not sure what other similar decls do, but IWBN if they all had a similar comment.] > + > +extern void debug_vprintf (const char *format, va_list ap) > + ATTRIBUTE_PRINTF (1, 0); > + > +#endif /* COMMON_DEBUG_H */ > [...] The rest of the patch LGTM.