From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [pushed] Fix copy-pasto, allocate objfile_per_bfd_storage with obstack_new
Date: Mon, 21 May 2018 08:53:00 -0000 [thread overview]
Message-ID: <20180521032245.2129-1-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <c6cc5e48-3c61-b36b-6daf-4080911677a1@polymtl.ca>
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 <simon.marchi@polymtl.ca>
+
+ * 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 <simon.marchi@ericsson.com>
* 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_per_bfd_storage> (&objfile->objfile_obstack);
/* Look up the gdbarch associated with the BFD. */
if (abfd != NULL)
--
2.17.0
prev parent reply other threads:[~2018-05-21 3:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-28 3:31 [PATCH v2 0/3] Poison obstack functions Simon Marchi
2018-04-28 3:31 ` [PATCH v2 2/3] Introduce obstack_new, poison other "typed" " Simon Marchi
2018-04-28 3:31 ` [PATCH v2 1/3] Don't allocate mapped_index on the objfile obstack Simon Marchi
2018-04-28 3:31 ` [PATCH v2 3/3] Use XOBNEW/XOBNEWVEC/OBSTACK_ZALLOC when possible Simon Marchi
2018-05-21 3:00 ` [PATCH v2 0/3] Poison obstack functions Simon Marchi
2018-05-21 3:23 ` Simon Marchi
2018-05-21 8:53 ` Simon Marchi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180521032245.2129-1-simon.marchi@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox