From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFC 2/2] Move gdb's xmalloc and friends to new file
Date: Wed, 05 Jun 2019 09:40:00 -0000 [thread overview]
Message-ID: <df6ca8a5-ea43-60ad-8010-6c44e21a9f31@redhat.com> (raw)
In-Reply-To: <20190530213046.20542-3-tom@tromey.com>
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 <tom@tromey.com>
>
> * 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 <tom@tromey.com>
>
> * 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 <cstdlib>
Including <cstdlib> 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
next prev parent reply other threads:[~2019-06-05 9:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-30 21:30 [RFC 0/2] Let's discuss moving gdbserver to top-level Tom Tromey
2019-05-30 21:30 ` [RFC 2/2] Move gdb's xmalloc and friends to new file Tom Tromey
2019-06-03 15:03 ` Simon Marchi
2019-06-03 16:33 ` Tom Tromey
2019-06-05 9:40 ` Pedro Alves [this message]
2019-06-05 22:33 ` Tom Tromey
2019-06-17 15:45 ` Alan Hayward
2019-06-17 17:43 ` Tom Tromey
2019-06-17 18:37 ` Pedro Alves
2019-06-18 9:31 ` Alan Hayward
2019-07-03 16:18 ` Alan Hayward
2019-07-13 16:04 ` Tom Tromey
2019-07-16 19:47 ` Pedro Alves
2019-05-30 21:30 ` [RFC 1/2] Remove linux-waitpid.c debugging code Tom Tromey
2019-06-03 14:57 ` Simon Marchi
2019-06-03 16:32 ` Tom Tromey
2019-06-05 9:32 ` Pedro Alves
2019-06-03 10:24 ` [RFC 0/2] Let's discuss moving gdbserver to top-level Alan Hayward
2019-06-03 14:27 ` Simon Marchi
2019-06-03 16:30 ` Tom Tromey
2019-06-05 9:16 ` Pedro Alves
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=df6ca8a5-ea43-60ad-8010-6c44e21a9f31@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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