Tidy dwarf1 cached section contents
[binutils-gdb.git] / gdb / linux-nat.c
index 1d207c4e31d87ac2a9ad747f5f870150c69530e2..fd537d7a1d36e1b3675ca877f9fbaf27bb2f413e 100644 (file)
@@ -1,6 +1,6 @@
 /* GNU/Linux native-dependent code common to multiple platforms.
 
-   Copyright (C) 2001-2022 Free Software Foundation, Inc.
+   Copyright (C) 2001-2023 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -60,7 +60,6 @@
 #include "symfile.h"
 #include "gdbsupport/agent.h"
 #include "tracepoint.h"
-#include "gdbsupport/buffer.h"
 #include "target-descriptions.h"
 #include "gdbsupport/filestuff.h"
 #include "objfiles.h"
@@ -372,6 +371,7 @@ linux_init_ptrace_procfs (pid_t pid, int attached)
   linux_enable_event_reporting (pid, options);
   linux_ptrace_init_warnings ();
   linux_proc_init_warnings ();
+  proc_mem_file_is_writable ();
 }
 
 linux_nat_target::~linux_nat_target ()
@@ -1226,7 +1226,7 @@ get_detach_signal (struct lwp_info *lp)
          if (tp->has_pending_waitstatus ())
            {
              /* If the thread has a pending event, and it was stopped with a
-                signal, use that signal to resume it.  If it has a pending
+                signal, use that signal to resume it.  If it has a pending
                 event of another kind, it was not stopped with a signal, so
                 resume it without a signal.  */
              if (tp->pending_waitstatus ().kind () == TARGET_WAITKIND_STOPPED)
@@ -3955,7 +3955,11 @@ linux_proc_xfer_memory_partial (int pid, gdb_byte *readbuf,
    return true if so.  It wasn't writable before Linux 2.6.39, but
    there's no way to know whether the feature was backported to older
    kernels.  So we check to see if it works.  The result is cached,
-   and this is garanteed to be called once early at startup.  */
+   and this is garanteed to be called once early during inferior
+   startup, so that any warning is printed out consistently between
+   GDB invocations.  Note we don't call it during GDB startup instead
+   though, because then we might warn with e.g. just "gdb --version"
+   on sandboxed systems.  See PR gdb/29907.  */
 
 static bool
 proc_mem_file_is_writable ()
@@ -4109,9 +4113,7 @@ linux_nat_target::static_tracepoint_markers_by_strid (const char *strid)
   /* Pause all */
   target_stop (ptid);
 
-  memcpy (s, "qTfSTM", sizeof ("qTfSTM"));
-  s[sizeof ("qTfSTM")] = 0;
-
+  strcpy (s, "qTfSTM");
   agent_run_command (pid, s, strlen (s) + 1);
 
   /* Unpause all.  */
@@ -4128,8 +4130,7 @@ linux_nat_target::static_tracepoint_markers_by_strid (const char *strid)
        }
       while (*p++ == ',');     /* comma-separated list */
 
-      memcpy (s, "qTsSTM", sizeof ("qTsSTM"));
-      s[sizeof ("qTsSTM")] = 0;
+      strcpy (s, "qTsSTM");
       agent_run_command (pid, s, strlen (s) + 1);
       p = s;
     }
@@ -4490,8 +4491,6 @@ Enables printf debugging output."),
   sigemptyset (&blocked_mask);
 
   lwp_lwpid_htab_create ();
-
-  proc_mem_file_is_writable ();
 }
 \f