/* 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.
#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. */
static void
auto_load_safe_path_vec_update (void)
{
- VEC (char_ptr) *dir_vec = NULL;
unsigned len;
int ix;
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. */
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
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"),
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"),
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))
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)