Beispiel #1
0
static void
exec_file_command (char *args, int from_tty)
{
  char **argv;
  char *filename;

  if (from_tty && target_has_execution
      && !query (_("A program is being debugged already.\n"
		   "Are you sure you want to change the file? ")))
    error (_("File not changed."));

  if (args)
    {
      /* Scan through the args and pick up the first non option arg
         as the filename.  */

      argv = buildargv (args);
      if (argv == NULL)
        nomem (0);

      make_cleanup_freeargv (argv);

      for (; (*argv != NULL) && (**argv == '-'); argv++)
        {;
        }
      if (*argv == NULL)
        error (_("No executable file name was specified"));

      filename = tilde_expand (*argv);
      make_cleanup (xfree, filename);
      exec_file_attach (filename, from_tty);
    }
  else
    exec_file_attach (NULL, from_tty);
}
Beispiel #2
0
static void
exec_file_command (char *args, int from_tty)
{
  char **argv;
  char *filename;
  
  target_preopen (from_tty);

  if (args)
    {
      /* Scan through the args and pick up the first non option arg
         as the filename.  */

      argv = buildargv (args);
      if (argv == NULL)
        nomem (0);

      make_cleanup_freeargv (argv);

      for (; (*argv != NULL) && (**argv == '-'); argv++)
        {;
        }
      if (*argv == NULL)
        error (_("No executable file name was specified"));

      filename = tilde_expand (*argv);
      make_cleanup (xfree, filename);
      exec_file_attach (filename, from_tty);
    }
  else
    exec_file_attach (NULL, from_tty);
}
Beispiel #3
0
void
exec_file_locate_attach (int pid, int from_tty)
{
  char *exec_file, *full_exec_path = NULL;

  /* Do nothing if we already have an executable filename.  */
  exec_file = (char *) get_exec_file (0);
  if (exec_file != NULL)
    return;

  /* Try to determine a filename from the process itself.  */
  exec_file = target_pid_to_exec_file (pid);
  if (exec_file == NULL)
    return;

  /* If gdb_sysroot is not empty and the discovered filename
     is absolute then prefix the filename with gdb_sysroot.  */
  if (gdb_sysroot != NULL && *gdb_sysroot != '\0'
      && IS_ABSOLUTE_PATH (exec_file))
    {
      int fd = -1;

      full_exec_path = exec_file_find (exec_file, &fd);
      if (fd >= 0)
	close (fd);
    }

  if (full_exec_path == NULL)
    {
      /* It's possible we don't have a full path, but rather just a
	 filename.  Some targets, such as HP-UX, don't provide the
	 full path, sigh.

	 Attempt to qualify the filename against the source path.
	 (If that fails, we'll just fall back on the original
	 filename.  Not much more we can do...)  */
      if (!source_full_path_of (exec_file, &full_exec_path))
	full_exec_path = xstrdup (exec_file);
    }

  exec_file_attach (full_exec_path, from_tty);
  symbol_file_add_main (full_exec_path, from_tty);
}
Beispiel #4
0
static void
exec_open (char *args, int from_tty)
{
  target_preopen (from_tty);
  exec_file_attach (args, from_tty);
}