From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17095 invoked by alias); 11 Jan 2013 20:34:23 -0000 Received: (qmail 16975 invoked by uid 22791); 11 Jan 2013 20:34:22 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_YM X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Jan 2013 20:34:08 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0BKY8uR023514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 11 Jan 2013 15:34:08 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0BKY6Ks019933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 11 Jan 2013 15:34:07 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Subject: Re: [8/8] move obconcat out of symfile References: <87ip73qzu6.fsf@fleche.redhat.com> Date: Fri, 11 Jan 2013 20:34:00 -0000 In-Reply-To: <87ip73qzu6.fsf@fleche.redhat.com> (Tom Tromey's message of "Fri, 11 Jan 2013 12:33:37 -0700") Message-ID: <87bocvqx1d.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 X-SW-Source: 2013-01/txt/msg00251.txt.bz2 >>>>> "Tom" == Tom Tromey writes: Tom> Right now obconcat is declared in symfile.h and defined in symfile.c. I Tom> found this pretty surprising -- actually I only tripped over it by Tom> accident. Tom> This patch moves the declaration to gdb_obstack.h and the definition to Tom> utils.c. Let me know what you think. On irc, Pedro said he'd prefer a gdb_obstack.c. Here's a patch to do that. Tom * gdb_obstack.h (obconcat): Move declaration here, from... * symfile.h (obconcat): ... here. * gdb_obstack.c: New file. (obconcat): Move from... * symfile.c (obconcat): ... here. * Makefile.in (SFILES): Add gdb_obstack.c. (COMMON_OBS): Add gdb_obstack.o. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index b065d41..45733ac 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -713,7 +713,8 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \ exceptions.c expprint.c \ f-exp.y f-lang.c f-typeprint.c f-valprint.c filesystem.c \ findcmd.c findvar.c frame.c frame-base.c frame-unwind.c \ - gdbarch.c arch-utils.c gdb_bfd.c gdbtypes.c gnu-v2-abi.c gnu-v3-abi.c \ + gdbarch.c arch-utils.c gdb_bfd.c gdb_obstack.c \ + gdbtypes.c gnu-v2-abi.c gnu-v3-abi.c \ go-exp.y go-lang.c go-typeprint.c go-valprint.c \ inf-loop.c \ infcall.c \ @@ -882,7 +883,8 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ macrotab.o macrocmd.o macroexp.o macroscope.o \ mi-common.o \ event-loop.o event-top.o inf-loop.o completer.o \ - gdbarch.o arch-utils.o gdbtypes.o gdb_bfd.o osabi.o copying.o \ + gdbarch.o arch-utils.o gdbtypes.o gdb_bfd.o gdb_obstack.o \ + osabi.o copying.o \ memattr.o mem-break.o target.o parse.o language.o buildsym.o \ findcmd.o \ std-regs.o \ diff --git a/gdb/gdb_obstack.c b/gdb/gdb_obstack.c new file mode 100644 index 0000000..df34968 --- /dev/null +++ b/gdb/gdb_obstack.c @@ -0,0 +1,47 @@ +/* Obstack wrapper for GDB. + + Copyright (C) 2013 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 . */ + +#include "defs.h" +#include "gdb_obstack.h" + +/* Concatenate NULL terminated variable argument list of `const char *' + strings; return the new string. Space is found in the OBSTACKP. + Argument list must be terminated by a sentinel expression `(char *) + NULL'. */ + +char * +obconcat (struct obstack *obstackp, ...) +{ + va_list ap; + + va_start (ap, obstackp); + for (;;) + { + const char *s = va_arg (ap, const char *); + + if (s == NULL) + break; + + obstack_grow_str (obstackp, s); + } + va_end (ap); + obstack_1grow (obstackp, 0); + + return obstack_finish (obstackp); +} diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h index 96196b7..1459ee9 100644 --- a/gdb/gdb_obstack.h +++ b/gdb/gdb_obstack.h @@ -51,4 +51,11 @@ #define obstack_grow_wstr(OBSTACK, WSTRING) \ obstack_grow (OBSTACK, WSTRING, sizeof (gdb_wchar_t) * gdb_wcslen (WSTRING)) +/* Concatenate NULL terminated variable argument list of `const char + *' strings; return the new string. Space is found in the OBSTACKP. + Argument list must be terminated by a sentinel expression `(char *) + NULL'. */ + +extern char *obconcat (struct obstack *obstackp, ...) ATTRIBUTE_SENTINEL; + #endif diff --git a/gdb/symfile.c b/gdb/symfile.c index f610e67..2f87260 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -151,32 +151,6 @@ static VEC (sym_fns_ptr) *symtab_fns = NULL; int auto_solib_add = 1; -/* Concatenate NULL terminated variable argument list of `const char *' - strings; return the new string. Space is found in the OBSTACKP. - Argument list must be terminated by a sentinel expression `(char *) - NULL'. */ - -char * -obconcat (struct obstack *obstackp, ...) -{ - va_list ap; - - va_start (ap, obstackp); - for (;;) - { - const char *s = va_arg (ap, const char *); - - if (s == NULL) - break; - - obstack_grow_str (obstackp, s); - } - va_end (ap); - obstack_1grow (obstackp, 0); - - return obstack_finish (obstackp); -} - /* True if we are reading a symbol table. */ int currently_reading_symtab = 0; diff --git a/gdb/symfile.h b/gdb/symfile.h index ad9a4e2..8caec8e 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -506,13 +506,6 @@ extern struct section_addr_info extern void free_section_addr_info (struct section_addr_info *); -/* Concatenate NULL terminated variable argument list of `const char - *' strings; return the new string. Space is found in the OBSTACKP. - Argument list must be terminated by a sentinel expression `(char *) - NULL'. */ - -extern char *obconcat (struct obstack *obstackp, ...) ATTRIBUTE_SENTINEL; - /* Variables */ /* If non-zero, shared library symbols will be added automatically