aboutsummaryrefslogtreecommitdiff
path: root/gdb/auto-load.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2012-08-27 16:50:54 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2012-08-27 16:50:54 +0000
commite96877996081948d7f0f9ee2152b2e409781def3 (patch)
treedfd3d2d9a261ba608855b8942f8194ca5105b2de /gdb/auto-load.c
parent7afa16426aa2d92b2b59d4b7ce1e4d3e4421ff31 (diff)
downloadgdb-e96877996081948d7f0f9ee2152b2e409781def3.zip
gdb-e96877996081948d7f0f9ee2152b2e409781def3.tar.gz
gdb-e96877996081948d7f0f9ee2152b2e409781def3.tar.bz2
gdb/
* 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.
Diffstat (limited to 'gdb/auto-load.c')
-rw-r--r--gdb/auto-load.c54
1 files changed, 45 insertions, 9 deletions
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 2971183..b314ad6 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -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);