static int
osf_open_symbol_file_object (void *from_ttyp)
{
  struct read_map_ctxt ctxt;
  struct so_list so;
  int found;

  if (symfile_objfile)
    if (!query ("Attempt to reload symbols from process? "))
      return 0;

  /* The first module after /sbin/loader is the main program.  */
  if (!open_map (&ctxt))
    return 0;
  for (found = 0; !found;)
    {
      if (!read_map (&ctxt, &so))
	break;
      found = !so.lm_info->isloader;
      osf_free_so (&so);
    }
  close_map (&ctxt);

  if (found)
    symbol_file_add_main (so.so_name, *(int *) from_ttyp);
  return found;
}
예제 #2
0
파일: exec.c 프로젝트: xkfz007/binutils-gdb
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);
}