Don't update target_dcache if it is not initialized
[deliverable/binutils-gdb.git] / gdb / auto-load.c
index c5eb8d129583f12f7dbf65bba09ca01d0e57d5ac..2c534c79088bb562e17d40008b8fe6c9b66d069d 100644 (file)
@@ -1,6 +1,6 @@
 /* GDB routines for supporting auto-loaded scripts.
 
-   Copyright (C) 2012 Free Software Foundation, Inc.
+   Copyright (C) 2012-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -38,6 +38,7 @@
 #include "observer.h"
 #include "fnmatch.h"
 #include "top.h"
+#include "filestuff.h"
 
 /* The suffix of per-objfile scripts to auto-load as non-Python command files.
    E.g. When the program loads libfoo.so, look for libfoo-gdb.gdb.  */
@@ -178,7 +179,6 @@ auto_load_expand_dir_vars (const char *string)
 static void
 auto_load_safe_path_vec_update (void)
 {
-  VEC (char_ptr) *dir_vec = NULL;
   unsigned len;
   int ix;
 
@@ -516,7 +516,7 @@ source_gdb_script_for_objfile (struct objfile *objfile, FILE *file,
   is_safe = file_is_auto_load_safe (filename, _("auto-load: Loading canned "
                                                "sequences of commands script "
                                                "\"%s\" for objfile \"%s\".\n"),
-                                   filename, objfile->name);
+                                   filename, objfile_name (objfile));
 
   /* Add this script to the hash table too so "info auto-load gdb-scripts"
      can print it.  */
@@ -572,15 +572,11 @@ static const struct program_space_data *auto_load_pspace_data;
 static void
 auto_load_pspace_data_cleanup (struct program_space *pspace, void *arg)
 {
-  struct auto_load_pspace_info *info;
+  struct auto_load_pspace_info *info = arg;
 
-  info = program_space_data (pspace, auto_load_pspace_data);
-  if (info != NULL)
-    {
-      if (info->loaded_scripts)
-       htab_delete (info->loaded_scripts);
-      xfree (info);
-    }
+  if (info->loaded_scripts)
+    htab_delete (info->loaded_scripts);
+  xfree (info);
 }
 
 /* Get the current autoload data.  If none is found yet, add it now.  This
@@ -739,7 +735,7 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
 
   cleanups = make_cleanup (xfree, filename);
 
-  input = fopen (filename, "r");
+  input = gdb_fopen_cloexec (filename, "r");
   debugfile = filename;
   if (debug_auto_load)
     fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file \"%s\" %s.\n"),
@@ -771,7 +767,7 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
          strcat (debugfile, filename);
 
          make_cleanup (xfree, debugfile);
-         input = fopen (debugfile, "r");
+         input = gdb_fopen_cloexec (debugfile, "r");
          if (debug_auto_load)
            fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file "
                                              "\"%s\" %s.\n"),
@@ -809,7 +805,7 @@ void
 auto_load_objfile_script (struct objfile *objfile,
                          const struct script_language *language)
 {
-  char *realname = gdb_realpath (objfile->name);
+  char *realname = gdb_realpath (objfile_name (objfile));
   struct cleanup *cleanups = make_cleanup (xfree, realname);
 
   if (!auto_load_objfile_script_1 (objfile, realname, language))
@@ -840,7 +836,7 @@ auto_load_objfile_script (struct objfile *objfile,
 void
 load_auto_scripts_for_objfile (struct objfile *objfile)
 {
-  if (!global_auto_load)
+  if (!global_auto_load || (objfile->flags & OBJF_NOT_FILENAME) != 0)
     return;
 
   if (auto_load_gdb_scripts)
This page took 0.025595 seconds and 4 git commands to generate.