public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Mark Mitchell <mark@codesourcery.com>
To: gdb@sources.redhat.com, gdb-patches@sources.redhat.com
Cc: ian@airs.com, dj@redhat.com
Subject: PATCH: Do not call xmalloc_failed in expandargv
Date: Tue, 27 Sep 2005 14:51:00 -0000	[thread overview]
Message-ID: <200509271451.j8REpKeg029702@sethra.codesourcery.com> (raw)


This patch fixes the link error when compiling GDB.  The cause of the
failure is that GDB's utils.c defines xmalloc, but not xmalloc_failed;
therefore, expandargv pulls in xmalloc.c to get xmalloc_failed, which
causes a duplicate symbol error for xmalloc.  Arguably, GDB should
define xmalloc_failed, so as to completely replace the interface.  (In
fact, GDB provides "nomem", which has almost the same signature.)
However, this patch to libiberty will be more robust if there are
other similar programs out there that, like GDB, replace only some of
the interface.  We could also split xmalloc_failed into its own file,
so as to decouple it from xmalloc.

In any case, is this patch OK, to get GDB back to linking?

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-09-27  Mark Mitchell  <mark@codesourcery.com>

	* argv.c (expandargv): Do not use xmalloc_failed.

Index: argv.c
===================================================================
RCS file: /cvs/src/src/libiberty/argv.c,v
retrieving revision 1.14
diff -c -5 -p -r1.14 argv.c
*** argv.c	26 Sep 2005 21:02:59 -0000	1.14
--- argv.c	27 Sep 2005 14:45:31 -0000
*************** expandargv (argcp, argvp)
*** 363,375 ****
        /* If *ARGVP is not already dynamically allocated, copy it.  */
        if (!argv_dynamic)
  	{
  	  *argvp = dupargv (*argvp);
  	  if (!*argvp)
! 	    /* We do not know exactly many bytes dupargv tried to
! 	       allocate, so make a guess.  */
! 	    xmalloc_failed (*argcp * 32);
  	}
        /* Count the number of arguments.  */
        file_argc = 0;
        while (file_argv[file_argc] && *file_argv[file_argc])
  	++file_argc;
--- 363,376 ----
        /* If *ARGVP is not already dynamically allocated, copy it.  */
        if (!argv_dynamic)
  	{
  	  *argvp = dupargv (*argvp);
  	  if (!*argvp)
! 	    {
! 	      fprintf (stderr, "\n%sout of memory\n");
! 	      xexit (1);
! 	    }
  	}
        /* Count the number of arguments.  */
        file_argc = 0;
        while (file_argv[file_argc] && *file_argv[file_argc])
  	++file_argc;

             reply	other threads:[~2005-09-27 14:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-27 14:51 Mark Mitchell [this message]
2005-09-27 15:17 ` Ian Lance Taylor
2005-09-27 15:22   ` Mark Mitchell
2005-09-27 15:40 ` DJ Delorie
2005-09-27 15:46   ` Mark Mitchell
2005-09-27 18:04     ` DJ Delorie
2005-09-27 18:33       ` Mark Mitchell
2005-09-27 18:35         ` DJ Delorie

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=200509271451.j8REpKeg029702@sethra.codesourcery.com \
    --to=mark@codesourcery.com \
    --cc=dj@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=gdb@sources.redhat.com \
    --cc=ian@airs.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).