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]

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


On Mon, 2013-05-27 at 18:30 +0400, Joel Brobecker wrote:

> Clearly lots of errors in the patch I sent. Can you apply the changes
> you suggested, recompile to make sure it at least builds, and post
> again here. Because there is no testing involved, I'd like more people
> to have a chance to review it before it gets checked in.
> 
> Thank you,

Note: Separate patch for another function: find_and_open_solib as
requested.

Attaching a patch and Chengelog entry for the function
nto_find_and_open_solib preceding nto_init_solib_absolute_prefix. There
I did not see any use of the make_cleanup/do_cleanups functions
(assuming open and openp always return). Therefore xfree is used
directly. (Maybe line break of the first xsnprintf statement is not
correctly placed, what does GCS say here?)

Attachment: ChangeLog.use_xstrprintf
Description: Text document

--- a/gdb/nto-tdep.c	2013-05-27 15:58:07.000000000 +0200
+++ b/gdb/nto-tdep.c	2013-05-27 16:23:50.000000000 +0200
@@ -89,9 +89,7 @@ nto_find_and_open_solib (char *solib, un
   char *buf, *arch_path, *nto_root, *endian;
   const char *base;
   const char *arch;
-  int arch_len, len, ret;
-#define PATH_FMT \
-  "%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
+  int ret;
 
   nto_root = nto_target ();
   if (strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name, "i386") == 0)
@@ -117,22 +115,20 @@ nto_find_and_open_solib (char *solib, un
   /* In case nto_root is short, add strlen(solib)
      so we can reuse arch_path below.  */
 
-  arch_len = (strlen (nto_root) + strlen (arch) + strlen (endian) + 2
-	      + strlen (solib));
-  arch_path = alloca (arch_len);
-  xsnprintf (arch_path, arch_len, "%s/%s%s", nto_root, arch, endian);
+  arch_path = xstrprintf (arch_path, arch_len, "%s/%s%s", nto_root, arch, endian);
 
-  len = strlen (PATH_FMT) + strlen (arch_path) * 5 + 1;
-  buf = alloca (len);
-  xsnprintf (buf, len, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
+  buf = xstrprintf ("\"%s\"/lib:\"%s\"/usr/lib:\"%s\"/usr/photon/lib:\"%s\"/usr/photon/dll:\"%s\"/lib/dll", arch_path, arch_path, arch_path, arch_path,
 	     arch_path);
+  xfree (arch_path);
 
   base = lbasename (solib);
   ret = openp (buf, 1, base, o_flags, temp_pathname);
+  xfree (buf);
   if (ret < 0 && base != solib)
     {
-      xsnprintf (arch_path, arch_len, "/%s", solib);
+      arch_path = xstrprintf ("/%s", solib);
       ret = open (arch_path, o_flags, 0);
+      xfree (arch_path);
       if (temp_pathname)
 	{
 	  if (ret >= 0)

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