gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 27 Aug 2012 16:50:54 +0000 (16:50 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 27 Aug 2012 16:50:54 +0000 (16:50 +0000)
* auto-load.c (auto_load_objfile_script): Rename to ...
(auto_load_objfile_script_1): ... here, change variable realname to
parameter realname, document it, add return value, add variable retval.
(auto_load_objfile_script): New function.

gdb/doc/
* gdb.texinfo (objfile-gdb.py file): New paragraph for .exe stripping.

gdb/ChangeLog
gdb/auto-load.c
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo

index 081e82bd6255e3cd496447627641e89654ffa8ca..1b478ea8f9022a0795cfd58d0a6098b4e8ee8599 100644 (file)
@@ -1,3 +1,11 @@
+2012-08-27  Eli Zaretskii  <eliz@gnu.org>
+           Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * auto-load.c (auto_load_objfile_script): Rename to ...
+       (auto_load_objfile_script_1): ... here, change variable realname to
+       parameter realname, document it, add return value, add variable retval.
+       (auto_load_objfile_script): New function.
+
 2012-08-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * cli/cli-decode.c (print_doc_line): Keep skipping '.' and ',' not
index 29711832b6b971733498f715658e88f1fdbf35c0..b314ad65b97d8ca5b3d456464c4ff3191fb5351f 100644 (file)
@@ -693,27 +693,25 @@ clear_section_scripts (void)
     }
 }
 
-/* Look for the auto-load script in LANGUAGE associated with OBJFILE and load
-   it.  */
+/* Look for the auto-load script in LANGUAGE associated with OBJFILE where
+   OBJFILE's gdb_realpath is REALNAME and load it.  Return 1 if we found any
+   matching script, return 0 otherwise.  */
 
-void
-auto_load_objfile_script (struct objfile *objfile,
-                         const struct script_language *language)
+static int
+auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
+                           const struct script_language *language)
 {
-  char *realname;
   char *filename, *debugfile;
-  int len;
+  int len, retval;
   FILE *input;
   struct cleanup *cleanups;
 
-  realname = gdb_realpath (objfile->name);
   len = strlen (realname);
   filename = xmalloc (len + strlen (language->suffix) + 1);
   memcpy (filename, realname, len);
   strcpy (filename + len, language->suffix);
 
   cleanups = make_cleanup (xfree, filename);
-  make_cleanup (xfree, realname);
 
   input = fopen (filename, "r");
   debugfile = filename;
@@ -768,6 +766,44 @@ auto_load_objfile_script (struct objfile *objfile,
         and these scripts are required to be idempotent under multiple
         loads anyway.  */
       language->source_script_for_objfile (objfile, input, debugfile);
+
+      retval = 1;
+    }
+  else
+    retval = 0;
+
+  do_cleanups (cleanups);
+  return retval;
+}
+
+/* Look for the auto-load script in LANGUAGE associated with OBJFILE and load
+   it.  */
+
+void
+auto_load_objfile_script (struct objfile *objfile,
+                         const struct script_language *language)
+{
+  char *realname = gdb_realpath (objfile->name);
+  struct cleanup *cleanups = make_cleanup (xfree, realname);
+
+  if (!auto_load_objfile_script_1 (objfile, realname, language))
+    {
+      /* For Windows/DOS .exe executables, strip the .exe suffix, so that
+        FOO-gdb.gdb could be used for FOO.exe, and try again.  */
+
+      size_t len = strlen (realname);
+      const size_t lexe = sizeof (".exe") - 1;
+
+      if (len > lexe && strcasecmp (realname + len - lexe, ".exe") == 0)
+       {
+         len -= lexe;
+         realname[len] = '\0';
+         if (debug_auto_load)
+           fprintf_unfiltered (gdb_stdlog, _("auto-load: Stripped .exe suffix, "
+                                             "retrying with \"%s\".\n"),
+                               realname);
+         auto_load_objfile_script_1 (objfile, realname, language);
+       }
     }
 
   do_cleanups (cleanups);
index 10fd3b57b6e205a93a4ed8ee139e4d2c6ffaa976..d6adef4c821a5684e8dae858db5842e29afa3048 100644 (file)
@@ -1,3 +1,7 @@
+2012-08-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gdb.texinfo (objfile-gdb.py file): New paragraph for .exe stripping.
+
 2012-08-23  Khoo Yit Phang <khooyp@cs.umd.edu>
 
        Document how to return from "python-interactive" to GDB.
index 534b2184cc774a17da7e495894a1f196af872e62..2d49e135091fa7e2c4b6abfc7e57a7a1ccaec3b1 100644 (file)
@@ -25784,6 +25784,13 @@ If this file does not exist, then @value{GDBN} will look for
 Note that loading of this script file also requires accordingly configured
 @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
 
+For object files using @file{.exe} suffix @value{GDBN} tries to load first the
+scripts normally according to its @file{.exe} filename.  But if no scripts are
+found @value{GDBN} also tries script filenames matching the object file without
+its @file{.exe} suffix.  This @file{.exe} stripping is case insensitive and it
+is attempted on any platform.  This makes the script filenames compatible
+between Unix and MS-Windows hosts.
+
 @table @code
 @anchor{set auto-load scripts-directory}
 @kindex set auto-load scripts-directory
This page took 0.06641 seconds and 4 git commands to generate.