guile disassembly hardcode TARGET_XFER_E_IO
[deliverable/binutils-gdb.git] / gdb / source.c
index fab974c2119a76916ffc2d12616f0abfa61532c7..194b044f44432370236f822ca1f5cf9af1587628 100644 (file)
@@ -746,6 +746,9 @@ openp (const char *path, int opts, const char *string,
   struct cleanup *back_to;
   int ix;
   char *dir;
+  /* The errno set for the last name we tried to open (and
+     failed).  */
+  int last_errno = 0;
 
   /* The open syscall MODE parameter is not specified.  */
   gdb_assert ((mode & O_CREAT) == 0);
@@ -775,7 +778,7 @@ openp (const char *path, int opts, const char *string,
 
       if (is_regular_file (string))
        {
-         filename = alloca (strlen (string) + 1);
+         filename = (char *) alloca (strlen (string) + 1);
          strcpy (filename, string);
          fd = gdb_open_cloexec (filename, mode, 0);
          if (fd >= 0)
@@ -786,6 +789,7 @@ openp (const char *path, int opts, const char *string,
          filename = NULL;
          fd = -1;
        }
+      last_errno = errno;
 
       if (!(opts & OPF_SEARCH_IN_PATH))
        for (i = 0; string[i]; i++)
@@ -806,8 +810,9 @@ openp (const char *path, int opts, const char *string,
     string += 2;
 
   alloclen = strlen (path) + strlen (string) + 2;
-  filename = alloca (alloclen);
+  filename = (char *) alloca (alloclen);
   fd = -1;
+  last_errno = ENOENT;
 
   dir_vec = dirnames_to_char_ptr_vec (path);
   back_to = make_cleanup_free_char_ptr_vec (dir_vec);
@@ -827,7 +832,7 @@ openp (const char *path, int opts, const char *string,
          if (newlen > alloclen)
            {
              alloclen = newlen;
-             filename = alloca (alloclen);
+             filename = (char *) alloca (alloclen);
            }
          strcpy (filename, current_directory);
        }
@@ -845,7 +850,7 @@ openp (const char *path, int opts, const char *string,
          if (newlen > alloclen)
            {
              alloclen = newlen;
-             filename = alloca (alloclen);
+             filename = (char *) alloca (alloclen);
            }
          strcpy (filename, tilde_expanded);
          xfree (tilde_expanded);
@@ -878,6 +883,7 @@ openp (const char *path, int opts, const char *string,
          fd = gdb_open_cloexec (filename, mode, 0);
          if (fd >= 0)
            break;
+         last_errno = errno;
        }
     }
 
@@ -895,6 +901,7 @@ done:
        *filename_opened = gdb_abspath (filename);
     }
 
+  errno = last_errno;
   return fd;
 }
 
@@ -1366,7 +1373,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
        {
          const char *filename = symtab_to_filename_for_display (s);
          int len = strlen (filename) + 100;
-         char *name = alloca (len);
+         char *name = (char *) alloca (len);
 
          xsnprintf (name, len, "%d\t%s", line, filename);
          print_sys_errmsg (name, errno);
@@ -1393,7 +1400,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
              /* ui_out_field_string may free S_FULLNAME by calling
                 open_source_file for it again.  See e.g.,
                 tui_field_string->tui_show_source.  */
-             local_fullname = alloca (strlen (s_fullname) + 1);
+             local_fullname = (char *) alloca (strlen (s_fullname) + 1);
              strcpy (local_fullname, s_fullname);
 
              ui_out_field_string (uiout, "fullname", local_fullname);
@@ -1644,7 +1651,7 @@ forward_search_command (char *regex, int from_tty)
       int cursize, newsize;
 
       cursize = 256;
-      buf = xmalloc (cursize);
+      buf = (char *) xmalloc (cursize);
       p = buf;
 
       c = fgetc (stream);
@@ -1656,7 +1663,7 @@ forward_search_command (char *regex, int from_tty)
          if (p - buf == cursize)
            {
              newsize = cursize + cursize / 2;
-             buf = xrealloc (buf, newsize);
+             buf = (char *) xrealloc (buf, newsize);
              p = buf + cursize;
              cursize = newsize;
            }
This page took 0.027091 seconds and 4 git commands to generate.