From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122308 invoked by alias); 5 Jun 2019 09:40:54 -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 122299 invoked by uid 89); 5 Jun 2019 09:40:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=obs, living X-HELO: mail-wr1-f48.google.com Received: from mail-wr1-f48.google.com (HELO mail-wr1-f48.google.com) (209.85.221.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Jun 2019 09:40:53 +0000 Received: by mail-wr1-f48.google.com with SMTP id p11so13907526wre.7 for ; Wed, 05 Jun 2019 02:40:52 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4eeb:42ff:feef:f164? ([2001:8a0:f913:f700:4eeb:42ff:feef:f164]) by smtp.gmail.com with ESMTPSA id k2sm33687834wrg.41.2019.06.05.02.40.50 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 02:40:50 -0700 (PDT) Subject: Re: [RFC 2/2] Move gdb's xmalloc and friends to new file To: Tom Tromey , gdb-patches@sourceware.org References: <20190530213046.20542-1-tom@tromey.com> <20190530213046.20542-3-tom@tromey.com> From: Pedro Alves Message-ID: Date: Wed, 05 Jun 2019 09:40:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190530213046.20542-3-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-06/txt/msg00121.txt.bz2 On 5/30/19 10:30 PM, Tom Tromey wrote: > When "common" becomes a library, linking will cause a symbol clash, > because "xmalloc" and some related symbols are defined in that > library, libiberty, and readline. > > To work around this problem, this patch moves the clashing symbols to > a new file, which is then compiled separately for both gdb and > gdbserver. > > gdb/ChangeLog > 2019-05-30 Tom Tromey > > * common/common-utils.c (xmalloc, xrealloc, xcalloc) > (xmalloc_failed): Move to alloc.c. > * alloc.c: New file. > * Makefile.in (COMMON_SFILES): Add alloc.c. > > gdb/gdbserver/ChangeLog > 2019-05-30 Tom Tromey > > * Makefile.in (SFILES): Add alloc.c. > (OBS): Add alloc.o. > (IPA_OBJS): Add alloc-ipa.o. > (alloc-ipa.o): New target. > (%.o: ../%.c): New pattern rule. This will be the first case of gdbserver building a file from gdb/ . I suppose we could preserve the gdb/common/ directory for such files. But I guess moving it out of the way until gdb/common/ moves to top level helps. > +++ b/gdb/alloc.c > @@ -0,0 +1,95 @@ > +/* Shared allocation functions for GDB, the GNU debugger. > + > + Copyright (C) 2019 Free Software Foundation, Inc. The file is new, but the contents aren't, and it's the contents that matter wrt to copyright years. There should be some comment here about why this is in a separate file instead of living in the common library, to help people that read the code from the tree without having this commit in context. > + > +#include "common/common-defs.h" There should also be a comment explaining why this includes common-defs.h instead of defs.h. > +#include "libiberty.h" > +#include Including looks strange, given common-defs.h includes stdlib.h. Why did you need this? > +#include "common/errors.h" > + > +/* The xmalloc() (libiberty.h) family of memory management routines. > + Thanks, Pedro Alves