Small patch to enable build of gdb-7.6 for GNU/Hurd
Thomas Schwinge
thomas@codesourcery.com
Mon May 27 14:55:00 GMT 2013
Hi!
On Mon, 27 May 2013 15:48:20 +0200, Svante Signell <svante.signell@gmail.com> wrote:
> On Mon, 2013-05-27 at 14:21 +0200, Svante Signell wrote:
> > On Mon, 2013-05-27 at 16:10 +0400, Joel Brobecker wrote:
> > > > 2013-05-27 Svante Signell <srs@hurd-2013.my.own.domain>
> > > >
> > > > * nto-tdep.c (nto_init_solib_absolute_prefix): Solve build
> > > > problems for systems not defining PATH_MAX by using xstrprintf and
> > > > a cleanup.
> > > While looking at this code, I don't think you'll need 2 xstrprintf
> > > either. Can you try the attached patch?
> I had to change the second make_cleanup call to do_cleanups instead, see
> the updated patch.
Right.
> 2013-05-27 Svante Signell <svante.signell@gmail.com>
>
> * nto-tdep.c (nto_init_solib_absolute_prefix): Solve build
> problems for systems not defining PATH_MAX by using xstrprintf
> followed by a cleanup.
GNU ChangeLogs are to describe what is changed, not why, so I'd use
something like: »Replace xsnprintf usage with fixed-size buffers with
xstrprintf«.
> diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
> index 748869f..cf4fd60 100644
> --- a/gdb/nto-tdep.c
> +++ b/gdb/nto-tdep.c
> @@ -147,9 +147,10 @@ nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
> void
> nto_init_solib_absolute_prefix (void)
> {
> - char buf[PATH_MAX * 2], arch_path[PATH_MAX];
> + char buf;
»char *buf«, as you already figured out.
> char *nto_root, *endian;
> const char *arch;
> + struct cleanup *old_chain;
>
> nto_root = nto_target ();
> if (strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name, "i386") == 0)
> @@ -172,10 +173,11 @@ nto_init_solib_absolute_prefix (void)
> == BFD_ENDIAN_BIG ? "be" : "le";
> }
>
> - xsnprintf (arch_path, sizeof (arch_path), "%s/%s%s", nto_root, arch, endian);
> -
> - xsnprintf (buf, sizeof (buf), "set solib-absolute-prefix %s", arch_path);
> + buf = xstrprintf ("set solib-absolute-prefix \"%s/%s%s\"",
> + nto_root, arch, endian);
The original code does not put double-quotes around the (former)
arch_path argument to »set solib-absolute-prefix«. Do we have to be
concerned here about quoting/path names containing double-quotes et al.?
> + old_chain = make_cleanup (xfree, buf);
> execute_command (buf, 0);
> + do_cleanups (old_chain);
> }
Grüße,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20130527/3f92f5d5/attachment.sig>
More information about the Gdb-patches
mailing list