contrib/gdb-7/gdb/python/py-auto-load.c
static void
auto_load_objfile_script (struct objfile *objfile, const char *suffix)
{
  char *realname;
  char *filename, *debugfile;
  int len;
  FILE *input;
  struct cleanup *cleanups;

  realname = gdb_realpath (objfile->name);
  len = strlen (realname);
  filename = xmalloc (len + strlen (suffix) + 1);
  memcpy (filename, realname, len);
  strcpy (filename + len, suffix);

  cleanups = make_cleanup (xfree, filename);
  make_cleanup (xfree, realname);

  input = fopen (filename, "r");
  debugfile = filename;

  if (!input && debug_file_directory)
    {
      /* Also try the same file in the separate debug info directory.  */
      debugfile = xmalloc (strlen (filename)
			   + strlen (debug_file_directory) + 1);
      strcpy (debugfile, debug_file_directory);
      /* FILENAME is absolute, so we don't need a "/" here.  */
      strcat (debugfile, filename);

      make_cleanup (xfree, debugfile);
      input = fopen (debugfile, "r");
    }

  if (!input && gdb_datadir)
    {
      /* Also try the same file in a subdirectory of gdb's data
	 directory.  */
      debugfile = xmalloc (strlen (gdb_datadir) + strlen (filename)
			   + strlen ("/auto-load") + 1);
      strcpy (debugfile, gdb_datadir);
      strcat (debugfile, "/auto-load");
      /* FILENAME is absolute, so we don't need a "/" here.  */
      strcat (debugfile, filename);

      make_cleanup (xfree, debugfile);
      input = fopen (debugfile, "r");
    }

  if (input)
    {
      struct auto_load_pspace_info *pspace_info;

      /* Add this script to the hash table too so "info auto-load-scripts"
	 can print it.  */
      pspace_info =
	get_auto_load_pspace_data_for_loading (current_program_space);
      maybe_add_script (pspace_info->loaded_scripts, debugfile, debugfile);

      /* To preserve existing behaviour we don't check for whether the
	 script was already in the table, and always load it.
	 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, debugfile);
      fclose (input);
    }

  do_cleanups (cleanups);
}
/* Look for the auto-load script associated with OBJFILE and load it.  */
Look for the auto-load script associated with OBJFILE and load it.
Look for the auto - load script associated with OBJFILE and load it .
static void
auto_load_objfile_script (struct objfile *objfile, const char *suffix)
{
  char *realname;
  char *filename, *debugfile;
  int len;
  FILE *input;
  struct cleanup *cleanups;
  realname = gdb_realpath (objfile->name);
  len = strlen (realname);
  filename = xmalloc (len + strlen (suffix) + 1);
  memcpy (filename, realname, len);
  strcpy (filename + len, suffix);
  cleanups = make_cleanup (xfree, filename);
  make_cleanup (xfree, realname);
  input = fopen (filename, "r");
  debugfile = filename;
  if (!input && debug_file_directory)
    {
      debugfile = xmalloc (strlen (filename)
			   + strlen (debug_file_directory) + 1);
      strcpy (debugfile, debug_file_directory);
      strcat (debugfile, filename);
      make_cleanup (xfree, debugfile);
      input = fopen (debugfile, "r");
    }
  if (!input && gdb_datadir)
    {
      debugfile = xmalloc (strlen (gdb_datadir) + strlen (filename)
			   + strlen ("/auto-load") + 1);
      strcpy (debugfile, gdb_datadir);
      strcat (debugfile, "/auto-load");
      strcat (debugfile, filename);
      make_cleanup (xfree, debugfile);
      input = fopen (debugfile, "r");
    }
  if (input)
    {
      struct auto_load_pspace_info *pspace_info;
      pspace_info =
	get_auto_load_pspace_data_for_loading (current_program_space);
      maybe_add_script (pspace_info->loaded_scripts, debugfile, debugfile);
      source_python_script_for_objfile (objfile, debugfile);
      fclose (input);
    }
  do_cleanups (cleanups);
}
static void auto_load_objfile_script ( struct objfile * objfile , const char * suffix ) { char * realname ; char * filename , * debugfile ; int len ; FILE * input ; struct cleanup * cleanups ; realname = gdb_realpath ( objfile -> name ) ; len = strlen ( realname ) ; filename = xmalloc ( len + strlen ( suffix ) + 1 ) ; memcpy ( filename , realname , len ) ; strcpy ( filename + len , suffix ) ; cleanups = make_cleanup ( xfree , filename ) ; make_cleanup ( xfree , realname ) ; input = fopen ( filename , " " ) ; debugfile = filename ; if ( ! input && debug_file_directory ) { debugfile = xmalloc ( strlen ( filename ) + strlen ( debug_file_directory ) + 1 ) ; strcpy ( debugfile , debug_file_directory ) ; strcat ( debugfile , filename ) ; make_cleanup ( xfree , debugfile ) ; input = fopen ( debugfile , " " ) ; } if ( ! input && gdb_datadir ) { debugfile = xmalloc ( strlen ( gdb_datadir ) + strlen ( filename ) + strlen ( " " ) + 1 ) ; strcpy ( debugfile , gdb_datadir ) ; strcat ( debugfile , " " ) ; strcat ( debugfile , filename ) ; make_cleanup ( xfree , debugfile ) ; input = fopen ( debugfile , " " ) ; } if ( input ) { struct auto_load_pspace_info * pspace_info ; pspace_info = get_auto_load_pspace_data_for_loading ( current_program_space ) ; maybe_add_script ( pspace_info -> loaded_scripts , debugfile , debugfile ) ; source_python_script_for_objfile ( objfile , debugfile ) ; fclose ( input ) ; } do_cleanups ( cleanups ) ; }
Look for the auto-load script associated with OBJFILE and load it.
Look for the auto - load script associated with OBJFILE and load it .
/* Also try the same file in the separate debug info directory.  */ /* FILENAME is absolute, so we don't need a "/" here.  */ /* Also try the same file in a subdirectory of gdb's data
	 directory.  */ /* FILENAME is absolute, so we don't need a "/" here.  */ /* Add this script to the hash table too so "info auto-load-scripts"
	 can print it.  */ /* To preserve existing behaviour we don't check for whether the
	 script was already in the table, and always load it.
	 It's highly unlikely that we'd ever load it twice,
	 and these scripts are required to be idempotent under multiple
	 loads anyway.  */