Add `set print repeats' tests for C/C++ arrays
[binutils-gdb.git] / gdb / auxv.c
index f13f90b153f5c5cf8899d4dccdfed34c4331c693..36ef51f3aed2d3394aadef2eaa65b643ad292fae 100644 (file)
@@ -1,6 +1,6 @@
 /* Auxiliary vector support for GDB, the GNU debugger.
 
-   Copyright (C) 2004-2021 Free Software Foundation, Inc.
+   Copyright (C) 2004-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -46,23 +46,21 @@ procfs_xfer_auxv (gdb_byte *readbuf,
                  ULONGEST len,
                  ULONGEST *xfered_len)
 {
-  int fd;
   ssize_t l;
 
   std::string pathname = string_printf ("/proc/%d/auxv", inferior_ptid.pid ());
-  fd = gdb_open_cloexec (pathname, writebuf != NULL ? O_WRONLY : O_RDONLY, 0);
-  if (fd < 0)
+  scoped_fd fd
+    = gdb_open_cloexec (pathname, writebuf != NULL ? O_WRONLY : O_RDONLY, 0);
+  if (fd.get () < 0)
     return TARGET_XFER_E_IO;
 
   if (offset != (ULONGEST) 0
-      && lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
+      && lseek (fd.get (), (off_t) offset, SEEK_SET) != (off_t) offset)
     l = -1;
   else if (readbuf != NULL)
-    l = read (fd, readbuf, (size_t) len);
+    l = read (fd.get (), readbuf, (size_t) len);
   else
-    l = write (fd, writebuf, (size_t) len);
-
-  (void) close (fd);
+    l = write (fd.get (), writebuf, (size_t) len);
 
   if (l < 0)
     return TARGET_XFER_E_IO;
@@ -320,7 +318,8 @@ target_auxv_parse (gdb_byte **readptr,
   if (gdbarch_auxv_parse_p (gdbarch))
     return gdbarch_auxv_parse (gdbarch, readptr, endptr, typep, valp);
 
-  return current_top_target ()->auxv_parse (readptr, endptr, typep, valp);
+  return current_inferior ()->top_target ()->auxv_parse (readptr, endptr,
+                                                        typep, valp);
 }
 
 
@@ -580,7 +579,8 @@ info_auxv_command (const char *cmd, int from_tty)
     error (_("The program has no auxiliary information now."));
   else
     {
-      int ents = fprint_target_auxv (gdb_stdout, current_top_target ());
+      int ents = fprint_target_auxv (gdb_stdout,
+                                    current_inferior ()->top_target ());
 
       if (ents < 0)
        error (_("No auxiliary vector found, or failed reading it."));
@@ -598,7 +598,7 @@ _initialize_auxv ()
 This is information provided by the operating system at program startup."));
 
   /* Observers used to invalidate the auxv cache when needed.  */
-  gdb::observers::inferior_exit.attach (invalidate_auxv_cache_inf);
-  gdb::observers::inferior_appeared.attach (invalidate_auxv_cache_inf);
-  gdb::observers::executable_changed.attach (invalidate_auxv_cache);
+  gdb::observers::inferior_exit.attach (invalidate_auxv_cache_inf, "auxv");
+  gdb::observers::inferior_appeared.attach (invalidate_auxv_cache_inf, "auxv");
+  gdb::observers::executable_changed.attach (invalidate_auxv_cache, "auxv");
 }