This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Small patch to enable build of gdb-7.6 for GNU/Hurd


> 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.

Is the domain name above really valid?

> Attached is an updated patch for the build problems on systems where
> PATH_MAX is not defined.

In this case, I think you need to use what we call a "cleanup",
because execute_command might trigger an "error" (GDB's poor man's
exception mechanism), thus prevening the last xfree from releasing
buf.

A formatting nit: The GNU Coding Standard, which we follow in GDB,
requires a space before opening parens.

While looking at this code, I don't think you'll need 2 xstrprintf
either. Can you try the attached patch?

-- 
Joel
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 *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);
+  old_chain = make_cleanup (xfree, buf);
   execute_command (buf, 0);
+  make_cleanup (old_chain);
 }
 
 char **

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]