* python/py-auto-load.c (info_auto_load_scripts): Pass address of
[deliverable/binutils-gdb.git] / gdb / python / py-auto-load.c
index 4f31c2acb6a7ef9df2d7bc7469175ec6d4426e00..ef332ea8a1a15d25486592126680321d2bd7b543 100644 (file)
@@ -296,25 +296,26 @@ source_section_scripts (struct objfile *objfile, const char *source_name,
       in_hash_table = maybe_add_script (pspace_info->loaded_scripts, file,
                                        opened ? full_path : NULL);
 
-      if (opened)
-       free (full_path);
-
       if (! opened)
        {
          /* We don't throw an error, the program is still debuggable.  */
          if (! pspace_info->script_not_found_warning_printed)
            {
-             warning (_("Missing auto-load scripts referenced in %s.\n\
+             warning (_("Missing auto-load scripts referenced in section %s\n\
+of file %s\n\
 Use `info auto-load-scripts [REGEXP]' to list them."),
-                      GDBPY_AUTO_SECTION_NAME);
+                      GDBPY_AUTO_SECTION_NAME, objfile->name);
              pspace_info->script_not_found_warning_printed = TRUE;
            }
-         continue;
        }
-
-      /* If this file is not currently loaded, load it.  */
-      if (! in_hash_table)
-       source_python_script_for_objfile (objfile, stream, file);
+      else
+       {
+         /* If this file is not currently loaded, load it.  */
+         if (! in_hash_table)
+           source_python_script_for_objfile (objfile, full_path);
+         fclose (stream);
+         xfree (full_path);
+       }
     }
 }
 
@@ -430,7 +431,7 @@ auto_load_objfile_script (struct objfile *objfile, const char *suffix)
         It's highly unlikely that we'd ever load it twice,
         and these scripts are required to be idempotent under multiple
         loads anyway.  */
-      source_python_script_for_objfile (objfile, input, debugfile);
+      source_python_script_for_objfile (objfile, debugfile);
       fclose (input);
     }
 
@@ -480,10 +481,10 @@ static int
 collect_matching_scripts (void **slot, void *info)
 {
   struct loaded_script *script = *slot;
-  VEC (loaded_script_ptr) *scripts = info;
+  VEC (loaded_script_ptr) **scripts_ptr = info;
 
   if (re_exec (script->name))
-    VEC_safe_push (loaded_script_ptr, scripts, script);
+    VEC_safe_push (loaded_script_ptr, *scripts_ptr, script);
 
   return 1;
 }
@@ -493,11 +494,12 @@ collect_matching_scripts (void **slot, void *info)
 static void
 print_script (struct loaded_script *script)
 {
+  struct ui_out *uiout = current_uiout;
   struct cleanup *chain;
 
   chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
 
-  ui_out_field_string (uiout, "loaded", script->full_path ? "Yes" : "No");
+  ui_out_field_string (uiout, "loaded", script->full_path ? "Yes" : "Missing");
   ui_out_field_string (uiout, "script", script->name);
   ui_out_text (uiout, "\n");
 
@@ -529,6 +531,7 @@ sort_scripts_by_name (const void *ap, const void *bp)
 static void
 info_auto_load_scripts (char *pattern, int from_tty)
 {
+  struct ui_out *uiout = current_uiout;
   struct auto_load_pspace_info *pspace_info;
   struct cleanup *script_chain;
   VEC (loaded_script_ptr) *scripts;
@@ -560,8 +563,9 @@ info_auto_load_scripts (char *pattern, int from_tty)
   if (pspace_info != NULL && pspace_info->loaded_scripts != NULL)
     {
       immediate_quit++;
+      /* Pass a pointer to scripts as VEC_safe_push can realloc space.  */
       htab_traverse_noresize (pspace_info->loaded_scripts,
-                             collect_matching_scripts, scripts);
+                             collect_matching_scripts, &scripts);
       immediate_quit--;
     }
 
@@ -569,7 +573,7 @@ info_auto_load_scripts (char *pattern, int from_tty)
   make_cleanup_ui_out_table_begin_end (uiout, 2, nr_scripts,
                                       "AutoLoadedScriptsTable");
 
-  ui_out_table_header (uiout, 6, ui_center, "loaded", "Loaded");
+  ui_out_table_header (uiout, 7, ui_left, "loaded", "Loaded");
   ui_out_table_header (uiout, 70, ui_left, "script", "Script");
   ui_out_table_body (uiout);
 
This page took 0.025378 seconds and 4 git commands to generate.