From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4774 invoked by alias); 21 May 2018 03:23:03 -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 4756 invoked by uid 89); 21 May 2018 03:23:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=H*RU:sk:barracu, Hx-spam-relays-external:sk:barracu, H*r:sk:barracu, HX-HELO:sk:barracu X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 May 2018 03:22:59 +0000 X-ASG-Debug-ID: 1526872966-0c856e5f3680790001-fS2M51 Received: from smtp.ebox.ca (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id FEfGWujmP924rUh5 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 20 May 2018 23:22:46 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id 2589A441B21; Sun, 20 May 2018 23:22:46 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-164-54.qc.cable.ebox.net[192.222.164.54] X-Barracuda-Apparent-Source-IP: 192.222.164.54 X-Barracuda-RBL-IP: 192.222.164.54 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [pushed] Fix copy-pasto, allocate objfile_per_bfd_storage with obstack_new Date: Mon, 21 May 2018 08:53:00 -0000 X-ASG-Orig-Subj: [pushed] Fix copy-pasto, allocate objfile_per_bfd_storage with obstack_new Message-Id: <20180521032245.2129-1-simon.marchi@polymtl.ca> In-Reply-To: References: X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1526872966 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 3187 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.51088 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-IsSubscribed: yes X-SW-Source: 2018-05/txt/msg00458.txt.bz2 I realized after pushing that I made a copy-pasto, I had: # define HAVE_IS_TRIVIALLY_COPYABLE 1 instead of # define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1 with the consequence that IsMallocable was always std::true_type (and was therefore not enforcing anything). Fixing that mistake triggered a build failure: /home/simark/src/binutils-gdb/gdb/objfiles.c:150:12: required from here /home/simark/src/binutils-gdb/gdb/common/poison.h:228:3: error: static assertion failed: Trying to use XOBNEW with a non-POD data type. I am not sure why I did not see this when I originally wrote the patch (but I saw and fixed other failures). In any case, I swapped XOBNEW with obstack_new to get rid of it. Regtested on the buildbot. gdb/ChangeLog: * common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Rename the wrong instance to... (HAVE_IS_TRIVIALLY_CONSTRUCTIBLE): ... this. * objfiles.c (get_objfile_bfd_data): Allocate objfile_per_bfd_storage with obstack_new when allocating on obstack. --- gdb/ChangeLog | 9 +++++++++ gdb/common/traits.h | 2 +- gdb/objfiles.c | 10 +++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5eb5eeaa9ad9..45e6ff719492 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2018-05-20 Simon Marchi + + * common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Rename the wrong + instance to... + (HAVE_IS_TRIVIALLY_CONSTRUCTIBLE): ... this. + * objfiles.c (get_objfile_bfd_data): Allocate + objfile_per_bfd_storage with obstack_new when allocating on + obstack. + 2018-05-20 Simon Marchi * ada-lang.c (cache_symbol): Use XOBNEW and/or XOBNEWVEC and/or diff --git a/gdb/common/traits.h b/gdb/common/traits.h index 070ef159e5b9..e1066e0d97e5 100644 --- a/gdb/common/traits.h +++ b/gdb/common/traits.h @@ -38,7 +38,7 @@ in GCC 5. */ #if (__has_feature(is_trivially_constructible) \ || (defined __GNUC__ && __GNUC__ >= 5)) -# define HAVE_IS_TRIVIALLY_COPYABLE 1 +# define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1 #endif namespace gdb { diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 2ec358ad4dbb..f57f4f58b008 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -144,14 +144,14 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd) storage = ((struct objfile_per_bfd_storage *) bfd_alloc (abfd, sizeof (struct objfile_per_bfd_storage))); + /* objfile_per_bfd_storage is not trivially constructible, must + call the ctor manually. */ + storage = new (storage) objfile_per_bfd_storage (); set_bfd_data (abfd, objfiles_bfd_data, storage); } else - storage = XOBNEW (&objfile->objfile_obstack, objfile_per_bfd_storage); - - /* objfile_per_bfd_storage is not trivially constructible, must - call the ctor manually. */ - storage = new (storage) objfile_per_bfd_storage (); + storage + = obstack_new (&objfile->objfile_obstack); /* Look up the gdbarch associated with the BFD. */ if (abfd != NULL) -- 2.17.0