public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH v3] Add "error_message+" feature to qSupported
@ 2024-05-21 16:18  3% Alexandra Hájková
  0 siblings, 0 replies; 200+ results
From: Alexandra Hájková @ 2024-05-21 16:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: ahajkova, Tom Tromey

From: Alexandra Hájková <ahajkova@redhat.com>

Check if the gdbserver GDB is communicating with supports
responding with the error message in an E.errtext format to GDB's
packets.

Add a new 'error_message' feature to the qSupported packet. When GDB
supports this feature then gdbserver is able to send
errors in the E.errtext format for the qRcmd and m packets.

Update qRcmd packet and m packets documentation as qRcmd newly
accepts errors in a E.errtext format.
Previously these two packets didn't support E.errtext style errors.

Approved-By: Tom Tromey <tom@tromey.com>
---
v3: 
- Improved documentation.
- Simplified the handling of the feature, GDB send the feature request to the gdbserver, so gdbserver know
it can always reply with 'E.errtext', but I dropped sending a response if gdbserver is going to be sending errors in
such a way. GDB can handle both versions of the errors now and do not need to know if gdbserver supports E.errtext
response.

 gdb/doc/gdb.texinfo | 31 +++++++++++++++++--
 gdb/remote.c        | 75 +++++++++++++++++++++++++++------------------
 gdbserver/server.cc |  3 ++
 gdbserver/server.h  |  5 +++
 4 files changed, 82 insertions(+), 32 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 61f91ef4ad6..b15dca84cb9 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -42970,7 +42970,9 @@ server was able to read only part of the region of memory.
 
 Unlike most packets, this packet does not support
 @samp{E.@var{errtext}}-style textual error replies (@pxref{textual
-error reply}).
+error reply}) by default.  Stubs should be careful to only send such a
+reply if @value{GDBN} reported support for it with the
+@code{error-message} feature (@pxref{error-message}).
 
 @item M @var{addr},@var{length}:@var{XX@dots{}}
 @cindex @samp{M} packet
@@ -44480,7 +44482,9 @@ A command response with the hex encoded output string @var{OUTPUT}.
 
 Unlike most packets, this packet does not support
 @samp{E.@var{errtext}}-style textual error replies (@pxref{textual
-error reply}).
+error reply}) by default.  Stubs should be careful to only send such a
+reply if @value{GDBN} reported support for it with the
+@code{error-message} feature (@pxref{error-message}).
 
 (Note that the @code{qRcmd} packet's name is separated from the
 command by a @samp{,}, not a @samp{:}, contrary to the naming
@@ -44627,6 +44631,17 @@ including @samp{exec-events+} in its @samp{qSupported} reply.
 @item vContSupported
 This feature indicates whether @value{GDBN} wants to know the
 supported actions in the reply to @samp{vCont?} packet.
+
+@anchor{error-message}
+@item error-message
+This feature indicates whether @value{GDBN} supports accepting a reply
+in @samp{E.@var{errtext}} format (@xref{textual error reply}) from the
+@samp{qRcmd} and @samp{m} packets.  These packets, historically,
+didn't support @samp{E.@var{errtext}}, and older versions of
+@value{GDBN} didn't expect to see a reply in this format.
+
+New packets should be written to support @samp{E.@var{errtext}}
+regardless of this feature being true or not.
 @end table
 
 Stubs should ignore any unknown values for
@@ -44910,6 +44925,11 @@ These are the currently defined stub features and their properties:
 @tab @samp{-}
 @tab No
 
+@item @samp{error-message}
+@tab No
+@tab @samp{+}
+@tab No
+
 @end multitable
 
 These are the currently defined stub features, in more detail:
@@ -45143,6 +45163,13 @@ inspected, if @samp{qIsAddressTagged} (@pxref{qIsAddressTagged}) packet
 is not supported by the stub.  Access to the @file{/proc/@var{pid}/smaps}
 file is done via @samp{vFile} requests.
 
+@item error-message
+The remote stub supports replying with an error in a
+@samp{E.@var{errtext}} (@xref{textual error reply}) format from the
+@samp{m} and @samp{qRcmd} packets.  It is not usually necessary to
+send this feature back to @value{GDBN} in the @samp{qSupported} reply,
+@value{GDBN} will always support @samp{E.@var{errtext}} format replies
+if it sent the @samp{error-message} feature.
 @end table
 
 @item qSymbol::
diff --git a/gdb/remote.c b/gdb/remote.c
index 42b446c7e27..d4ddd3b2998 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -377,6 +377,18 @@ enum {
   /* Support for the qIsAddressTagged packet.  */
   PACKET_qIsAddressTagged,
 
+  /* Support for accepting error message in a E.errtext format.
+     This allows every remote packet to return E.errtext.
+
+     This feature only exists to fix a backwards compatibility issue
+     with the qRcmd and m packets.  Historically, these two packets didn't
+     support E.errtext style errors, but when this feature is on
+     these two packets can receive E.errtext style errors.
+
+     All new packets should be written to always accept E.errtext style
+     errors, and so they should not need to check for this feature.  */
+  PACKET_accept_error_message,
+
   PACKET_MAX
 };
 
@@ -2503,7 +2515,7 @@ add_packet_config_cmd (const unsigned int which_packet, const char *name,
    code).  When ACCEPT_MSG is true error messages can also take the
    form E.msg (where msg is any arbitrary string).  */
 static packet_result
-packet_check_result (const char *buf, bool accept_msg)
+packet_check_result (const char *buf)
 {
   if (buf[0] != '\0')
     {
@@ -2518,17 +2530,14 @@ packet_check_result (const char *buf, bool accept_msg)
       /* Not every request accepts an error in a E.msg form.
 	 Some packets accepts only Enn, in this case E. is not
 	 defined and E. is treated as PACKET_OK.  */
-      if (accept_msg)
+      /* Always treat "E." as an error.  This will be used for
+	 more verbose error messages, such as E.memtypes.  */
+      if (buf[0] == 'E' && buf[1] == '.')
 	{
-	  /* Always treat "E." as an error.  This will be used for
-	     more verbose error messages, such as E.memtypes.  */
-	  if (buf[0] == 'E' && buf[1] == '.')
-	    {
-	      if (buf[2] != '\0')
-		return packet_result::make_textual_error (buf + 2);
-	      else
-		return packet_result::make_textual_error ("no error provided");
-	    }
+	  if (buf[2] != '\0')
+	    return packet_result::make_textual_error (buf + 2);
+	  else
+	    return packet_result::make_textual_error ("no error provided");
 	}
 
       /* The packet may or may not be OK.  Just assume it is.  */
@@ -2542,9 +2551,9 @@ packet_check_result (const char *buf, bool accept_msg)
 }
 
 static packet_result
-packet_check_result (const gdb::char_vector &buf, bool accept_msg)
+packet_check_result (const gdb::char_vector &buf)
 {
-  return packet_check_result (buf.data (), accept_msg);
+  return packet_check_result (buf.data ());
 }
 
 packet_result
@@ -2557,7 +2566,7 @@ remote_features::packet_ok (const char *buf, const int which_packet)
       && config->support == PACKET_DISABLE)
     internal_error (_("packet_ok: attempt to use a disabled packet"));
 
-  packet_result result = packet_check_result (buf, true);
+  packet_result result = packet_check_result (buf);
   switch (result.status ())
     {
     case PACKET_OK:
@@ -5818,6 +5827,8 @@ static const struct protocol_feature remote_protocol_features[] = {
   { "no-resumed", PACKET_DISABLE, remote_supported_packet, PACKET_no_resumed },
   { "memory-tagging", PACKET_DISABLE, remote_supported_packet,
     PACKET_memory_tagging_feature },
+  { "error-message", PACKET_ENABLE, remote_supported_packet,
+    PACKET_accept_error_message },
 };
 
 static char *remote_support_xml;
@@ -5936,6 +5947,10 @@ remote_target::remote_query_supported ()
 	      != PACKET_DISABLE))
 	remote_query_supported_append (&q, remote_support_xml);
 
+      if (m_features.packet_set_cmd_state (PACKET_accept_error_message)
+	  != AUTO_BOOLEAN_FALSE)
+      remote_query_supported_append (&q, "error-message+");
+
       q = "qSupported:" + q;
       putpkt (q.c_str ());
 
@@ -8890,7 +8905,7 @@ remote_target::send_g_packet ()
   xsnprintf (rs->buf.data (), get_remote_packet_size (), "g");
   putpkt (rs->buf);
   getpkt (&rs->buf);
-  packet_result result = packet_check_result (rs->buf, true);
+  packet_result result = packet_check_result (rs->buf);
   if (result.status () == PACKET_ERROR)
     error (_("Could not read registers; remote failure reply '%s'"),
 	   result.err_msg ());
@@ -9200,7 +9215,7 @@ remote_target::store_registers_using_G (const struct regcache *regcache)
   bin2hex (regs, p, rsa->sizeof_g_packet);
   putpkt (rs->buf);
   getpkt (&rs->buf);
-  packet_result pkt_status = packet_check_result (rs->buf, true);
+  packet_result pkt_status = packet_check_result (rs->buf);
   if (pkt_status.status () == PACKET_ERROR)
     error (_("Could not write registers; remote failure reply '%s'"),
 	   pkt_status.err_msg ());
@@ -9652,7 +9667,7 @@ remote_target::remote_read_bytes_1 (CORE_ADDR memaddr, gdb_byte *myaddr,
   *p = '\0';
   putpkt (rs->buf);
   getpkt (&rs->buf);
-  packet_result result = packet_check_result (rs->buf, false);
+  packet_result result = packet_check_result (rs->buf);
   if (result.status () == PACKET_ERROR)
     return TARGET_XFER_E_IO;
   /* Reply describes memory byte by byte, each byte encoded as two hex
@@ -9807,7 +9822,7 @@ remote_target::remote_send_printf (const char *format, ...)
   rs->buf[0] = '\0';
   getpkt (&rs->buf);
 
-  return packet_check_result (rs->buf, true).status ();
+  return packet_check_result (rs->buf).status ();
 }
 
 /* Flash writing can take quite some time.  We'll set
@@ -12000,7 +12015,7 @@ remote_target::rcmd (const char *command, struct ui_file *outbuf)
 	  remote_console_output (buf + 1, outbuf);
 	  continue;
 	}
-      packet_result result = packet_check_result (buf, false);
+      packet_result result = packet_check_result (buf);
       switch (result.status ())
 	{
 	case PACKET_UNKNOWN:
@@ -15672,7 +15687,7 @@ remote_target::store_memtags (CORE_ADDR address, size_t len,
   getpkt (&rs->buf);
 
   /* Verify if the request was successful.  */
-  return packet_check_result (rs->buf, true).status () == PACKET_OK;
+  return packet_check_result (rs->buf).status () == PACKET_OK;
 }
 
 /* Implement the "is_address_tagged" target_ops method.  */
@@ -15873,29 +15888,26 @@ static void
 test_packet_check_result ()
 {
   std::string buf = "E.msg";
-  packet_result result = packet_check_result (buf.data (), true);
+  packet_result result = packet_check_result (buf.data ());
 
   SELF_CHECK (result.status () == PACKET_ERROR);
   SELF_CHECK (strcmp(result.err_msg (), "msg") == 0);
 
-  result = packet_check_result ("E01", true);
+  result = packet_check_result ("E01");
   SELF_CHECK (result.status () == PACKET_ERROR);
   SELF_CHECK (strcmp(result.err_msg (), "01") == 0);
 
-  SELF_CHECK (packet_check_result ("E1", true).status () == PACKET_OK);
+  SELF_CHECK (packet_check_result ("E1").status () == PACKET_OK);
 
-  SELF_CHECK (packet_check_result ("E000", true).status () == PACKET_OK);
+  SELF_CHECK (packet_check_result ("E000").status () == PACKET_OK);
 
-  result = packet_check_result ("E.", true);
+  result = packet_check_result ("E.");
   SELF_CHECK (result.status () == PACKET_ERROR);
   SELF_CHECK (strcmp(result.err_msg (), "no error provided") == 0);
 
-  SELF_CHECK (packet_check_result ("some response", true).status () == PACKET_OK);
+  SELF_CHECK (packet_check_result ("some response").status () == PACKET_OK);
 
-  SELF_CHECK (packet_check_result ("", true).status () == PACKET_UNKNOWN);
-
-  result = packet_check_result ("E.msg", false);
-  SELF_CHECK (result.status () == PACKET_OK);
+  SELF_CHECK (packet_check_result ("").status () == PACKET_UNKNOWN);
 }
 } // namespace selftests
 #endif /* GDB_SELF_TEST */
@@ -16264,6 +16276,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
   add_packet_config_cmd (PACKET_qIsAddressTagged,
 			 "qIsAddressTagged", "memory-tagging-address-check", 0);
 
+  add_packet_config_cmd (PACKET_accept_error_message,
+			 "error-message", "error-message", 0);
+
   /* Assert that we've registered "set remote foo-packet" commands
      for all packet configs.  */
   {
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 789af36d9a4..c306d51e848 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -2710,6 +2710,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
 		  if (target_supports_memory_tagging ())
 		    cs.memory_tagging_feature = true;
 		}
+	      else if (feature == "error-message+")
+		cs.error_message_supported = true;
 	      else
 		{
 		  /* Move the unknown features all together.  */
@@ -4375,6 +4377,7 @@ captured_main (int argc, char *argv[])
       cs.hwbreak_feature = 0;
       cs.vCont_supported = 0;
       cs.memory_tagging_feature = false;
+      cs.error_message_supported = false;
 
       remote_open (port);
 
diff --git a/gdbserver/server.h b/gdbserver/server.h
index 0074818c6df..c39241c960d 100644
--- a/gdbserver/server.h
+++ b/gdbserver/server.h
@@ -192,6 +192,11 @@ struct client_state
   /* If true, memory tagging features are supported.  */
   bool memory_tagging_feature = false;
 
+  /* If true then E.message style errors are supported everywhere,
+     including for the qRcmd and m packet.  When false E.message errors
+     are not supported with qRcmd and m packets, but are still supported
+     everywhere else.  This is for backward compatibility reasons.  */
+  bool error_message_supported = false;
 };
 
 client_state &get_client_state ();
-- 
2.45.0


^ permalink raw reply	[relevance 3%]

* [PATCH 11/11] [gdb/testsuite] Don't use readelf in gdb/contrib/cc-with-tweaks.sh
  @ 2024-05-21 15:44  5% ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-05-21 15:44 UTC (permalink / raw)
  To: gdb-patches

Readelf is used in gdb/contrib/cc-with-tweaks.sh to find the .dwo files to put
into a .dwp package.

Usage a more basic method for this: assume a .dwo file for each .o file in the
link line.

Verified using shellcheck.

PR/testsuite 31754
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31754
---
 gdb/contrib/cc-with-tweaks.sh | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh
index f760bd7c0a1..036f3e9d394 100755
--- a/gdb/contrib/cc-with-tweaks.sh
+++ b/gdb/contrib/cc-with-tweaks.sh
@@ -70,7 +70,6 @@ then
 fi
 
 OBJCOPY=${OBJCOPY:-objcopy}
-READELF=${READELF:-readelf}
 
 DWZ=${DWZ:-dwz}
 DWP=${DWP:-dwp}
@@ -280,14 +279,18 @@ elif [ "$want_multi" = true ]; then
 fi
 
 if [ "$want_dwp" = true ]; then
-    dwo_files=$($READELF -wi "${output_file}" | grep _dwo_name | \
-	sed -e 's/^.*: //' | sort | uniq)
+    dwo_files=()
+    for arg in "$@"; do
+	if echo "$arg" | grep -Eq "\.o$"; then
+	    dwo_files=("${dwo_files[@]}" "${arg/.o/.dwo}")
+	fi
+    done
     rc=0
-    if [ -n "$dwo_files" ]; then
-	$DWP -o "${output_file}.dwp" ${dwo_files} > /dev/null
+    if [ ${#dwo_files[@]} -ne 0 ]; then
+	$DWP -o "${output_file}.dwp" "${dwo_files[@]}" > /dev/null
 	rc=$?
 	[ $rc != 0 ] && exit $rc
-	rm -f ${dwo_files}
+	rm -f "${dwo_files[@]}"
     fi
 fi
 
-- 
2.35.3


^ permalink raw reply	[relevance 5%]

* [PATCH v2] sim: fix a warning in dv-sockser.c at connected_p()
@ 2024-05-21  4:46  4% Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-05-21  4:46 UTC (permalink / raw)
  To: gdb-patches

In some O/S e.g. windows there is a warning here about the
unused variable flags which triggers a -Werror build failure.

Fix that by making the variable declaration optional.
---
 sim/common/dv-sockser.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

v2: moved the variable declaration inside the #if block

diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c
index db81233e25b..8f7425658a9 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -218,7 +218,7 @@ sim_install_dv_sockser (SIM_DESC sd)
 static int
 connected_p (SIM_DESC sd)
 {
-  int numfds,flags;
+  int numfds;
   struct timeval tv;
   fd_set readfds;
   struct sockaddr sockaddr;
@@ -254,15 +254,17 @@ connected_p (SIM_DESC sd)
 
   /* Set non-blocking i/o.  */
 #if defined(F_GETFL) && defined(O_NONBLOCK)
-  flags = fcntl (sockser_fd, F_GETFL);
-  flags |= O_NONBLOCK;
-  if (fcntl (sockser_fd, F_SETFL, flags) == -1)
-    {
-      sim_io_eprintf (sd, "unable to set nonblocking i/o");
-      close (sockser_fd);
-      sockser_fd = -1;
-      return 0;
-    }
+  {
+    int flags = fcntl (sockser_fd, F_GETFL);
+    flags |= O_NONBLOCK;
+    if (fcntl (sockser_fd, F_SETFL, flags) == -1)
+      {
+	sim_io_eprintf (sd, "unable to set nonblocking i/o");
+	close (sockser_fd);
+	sockser_fd = -1;
+	return 0;
+      }
+  }
 #endif
   return 1;
 }
-- 
2.39.2


^ permalink raw reply	[relevance 4%]

* [PATCHv2 4/4] gdb: unify build-id to objfile lookup code
  @ 2024-05-20 13:08  6%   ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-05-20 13:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

There are 3 places where we currently call debuginfod_exec_query to
lookup an objfile for a given build-id.

In one of these places we first call build_id_to_exec_bfd which also
looks up an objfile given a build-id, but this function looks on disk
for a symlink in the .build-id/ sub-directory (within the
debug-file-directory).

I can't think of any reason why we shouldn't call build_id_to_exec_bfd
before every call to debuginfod_exec_query.

So, in this commit I have added a new function in build-id.c,
find_exec_by_build_id, this function calls build_id_to_exec_bfd, and
if that fails, then calls debuginfod_exec_query.

Everywhere we call debuginfod_exec_query is updated to call the new
function, and in locate_exec_from_corefile_build_id, the existing call
to build_id_to_exec_bfd is removed as calling find_exec_by_build_id
does this for us.

One slight weird thing is in core_target::build_file_mappings, here we
call find_exec_by_build_id which returns a gdb_bfd_ref_ptr for the
opened file, however we immediately reopen the file as "binary".  The
reason for this is that all the bfds opened in ::build_file_mappings
need to be opened as "binary" (see the function comments for why).

I did consider passing a target type into find_exec_by_build_id, which
could then be forwarded to build_id_to_exec_bfd and used to open the
BFD as "binary", however, if you follow the call chain you'll end up
in build_id_to_debug_bfd_1, where we actually open the bfd.  Notice in
here that we call build_id_verify to double check the build-id of the
file we found, this requires that the bfd not be opened as "binary".

What this means is that we always have to first open the bfd using the
gnutarget target type (for the build-id check), and then we would have
to reopen it as "binary".  There seems little point pushing the reopen
logic into find_exec_by_build_id, so we just do this in the
::build_file_mappings function.

I've extended the tests to cover the two cases which actually changed
in this commit.
---
 gdb/build-id.c                                | 42 ++++++++++++++++++-
 gdb/build-id.h                                | 21 ++++++----
 gdb/corelow.c                                 | 40 ++++++------------
 gdb/solib.c                                   | 22 ++++------
 .../gdb.debuginfod/corefile-mapped-file.exp   | 24 +++++++++++
 .../gdb.debuginfod/solib-with-soname.exp      | 32 +++++++++++++-
 gdb/testsuite/lib/gdb.exp                     |  7 +++-
 7 files changed, 134 insertions(+), 54 deletions(-)

diff --git a/gdb/build-id.c b/gdb/build-id.c
index 41667d5e5cf..27642b58d56 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -26,6 +26,8 @@
 #include "filenames.h"
 #include "gdbcore.h"
 #include "cli/cli-style.h"
+#include "gdbsupport/scoped_fd.h"
+#include "debuginfod-support.h"
 
 /* See build-id.h.  */
 
@@ -198,9 +200,11 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
   return build_id_to_bfd_suffix (build_id_len, build_id, ".debug");
 }
 
-/* See build-id.h.  */
+/* Find and open a BFD for an executable file given a build-id.  If no BFD
+   can be found, return NULL.  The returned reference to the BFD must be
+   released by the caller.  */
 
-gdb_bfd_ref_ptr
+static gdb_bfd_ref_ptr
 build_id_to_exec_bfd (size_t build_id_len, const bfd_byte *build_id)
 {
   return build_id_to_bfd_suffix (build_id_len, build_id, "");
@@ -243,3 +247,37 @@ find_separate_debug_file_by_buildid (struct objfile *objfile,
 
   return std::string ();
 }
+
+/* See build-id.h.  */
+
+gdb_bfd_ref_ptr
+find_exec_by_build_id (const bfd_build_id *build_id,
+		       const char *expected_filename)
+{
+  /* Try to find the executable (or shared object) by looking for a
+     (sym)link on disk from the build-id to the object file.  */
+  gdb_bfd_ref_ptr abfd = build_id_to_exec_bfd (build_id->size,
+					       build_id->data);
+
+  if (abfd != nullptr)
+    return abfd;
+
+  /* Attempt to query debuginfod for the executable.  */
+  gdb::unique_xmalloc_ptr<char> path;
+  scoped_fd fd = debuginfod_exec_query (build_id->data, build_id->size,
+					expected_filename, &path);
+  if (fd.get () >= 0)
+    {
+      abfd = gdb_bfd_open (path.get (), gnutarget);
+
+      if (abfd == nullptr)
+	warning (_("\"%ps\" from debuginfod cannot be opened as bfd: %s"),
+		 styled_string (file_name_style.style (), path.get ()),
+		 gdb_bfd_errmsg (bfd_get_error (), nullptr).c_str ());
+      else if (!build_id_verify (abfd.get (), build_id->size,
+				 build_id->data))
+	abfd = nullptr;
+    }
+
+  return abfd;
+}
diff --git a/gdb/build-id.h b/gdb/build-id.h
index c5f20f8782e..3df122a0cbf 100644
--- a/gdb/build-id.h
+++ b/gdb/build-id.h
@@ -40,13 +40,6 @@ extern int build_id_verify (bfd *abfd,
 extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len,
 					      const bfd_byte *build_id);
 
-/* Find and open a BFD for an executable file given a build-id.  If no BFD
-   can be found, return NULL.  The returned reference to the BFD must be
-   released by the caller.  */
-
-extern gdb_bfd_ref_ptr build_id_to_exec_bfd (size_t build_id_len,
-					     const bfd_byte *build_id);
-
 /* Find the separate debug file for OBJFILE, by using the build-id
    associated with OBJFILE's BFD.  If successful, returns the file name for the
    separate debug file, otherwise, return an empty string.
@@ -60,6 +53,20 @@ extern gdb_bfd_ref_ptr build_id_to_exec_bfd (size_t build_id_len,
 extern std::string find_separate_debug_file_by_buildid
   (struct objfile *objfile, deferred_warnings *warnings);
 
+/* Find an executable (or shared library) that matches BUILD_ID.  This is
+   done by first checking in the debug-file-directory for a .build-id/
+   sub-directory, and looking for a symlink in there that points to the
+   required file.
+
+   If that doesn't find us a file then we call to debuginfod to see if it
+   can provide the required file.
+
+   EXPECTED_FILENAME is used in output messages from debuginfod, this
+   should be the file we were looking for but couldn't find.  */
+
+extern gdb_bfd_ref_ptr find_exec_by_build_id (const bfd_build_id *build_id,
+					      const char *expected_filename);
+
 /* Return an hex-string representation of BUILD_ID.  */
 
 static inline std::string
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 85bc3c26bea..6975719c1f2 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -47,7 +47,6 @@
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/scoped_fd.h"
 #include "gdbsupport/x86-xstate.h"
-#include "debuginfod-support.h"
 #include <unordered_map>
 #include <unordered_set>
 #include "cli/cli-cmds.h"
@@ -407,13 +406,19 @@ core_target::build_file_mappings ()
 	   || !bfd_check_format (abfd.get (), bfd_object))
 	  && file_data.build_id != nullptr)
 	{
-	  expanded_fname = nullptr;
-	  debuginfod_exec_query (file_data.build_id->data,
-				 file_data.build_id->size,
-				 filename.c_str (), &expanded_fname);
-	  if (expanded_fname != nullptr)
+	  abfd = find_exec_by_build_id (file_data.build_id,
+					filename.c_str ());
+
+	  if (abfd != nullptr)
 	    {
+	      /* The find_exec_by_build_id will have opened ABFD using the
+		 GNUTARGET global bfd type, however, we need the bfd opened
+		 as the binary type (see the function's header comment), so
+		 now we reopen ABFD with the desired binary type.  */
+	      expanded_fname
+		= make_unique_xstrdup (bfd_get_filename (abfd.get ()));
 	      struct bfd *b = bfd_openr (expanded_fname.get (), "binary");
+	      gdb_assert (b != nullptr);
 	      abfd = gdb_bfd_ref_ptr::new_reference (b);
 	    }
 	}
@@ -774,28 +779,7 @@ locate_exec_from_corefile_build_id (bfd *abfd, int from_tty)
     return;
 
   gdb_bfd_ref_ptr execbfd
-    = build_id_to_exec_bfd (build_id->size, build_id->data);
-
-  if (execbfd == nullptr)
-    {
-      /* Attempt to query debuginfod for the executable.  */
-      gdb::unique_xmalloc_ptr<char> execpath;
-      scoped_fd fd = debuginfod_exec_query (build_id->data, build_id->size,
-					    abfd->filename, &execpath);
-
-      if (fd.get () >= 0)
-	{
-	  execbfd = gdb_bfd_open (execpath.get (), gnutarget);
-
-	  if (execbfd == nullptr)
-	    warning (_("\"%s\" from debuginfod cannot be opened as bfd: %s"),
-		     execpath.get (),
-		     gdb_bfd_errmsg (bfd_get_error (), nullptr).c_str ());
-	  else if (!build_id_verify (execbfd.get (), build_id->size,
-				     build_id->data))
-	    execbfd.reset (nullptr);
-	}
-    }
+    = find_exec_by_build_id (build_id, abfd->filename);
 
   if (execbfd != nullptr)
     {
diff --git a/gdb/solib.c b/gdb/solib.c
index c39dfbcc78e..3292f361176 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -45,7 +45,6 @@
 #include "gdb_bfd.h"
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/scoped_fd.h"
-#include "debuginfod-support.h"
 #include "source.h"
 #include "cli/cli-style.h"
 
@@ -826,20 +825,15 @@ solib_map_sections (solib &so)
 	    abfd = nullptr;
 
 	  if (abfd == nullptr)
-	    {
-	      scoped_fd fd = debuginfod_exec_query
-		(expected_build_id->data, expected_build_id->size,
-		 so.so_name.c_str (), &filename);
+	    abfd = find_exec_by_build_id (expected_build_id,
+					  so.so_name.c_str ());
 
-	      if (fd.get () >= 0)
-		abfd = ops->bfd_open (filename.get ());
-	      else if (mismatch)
-		{
-		  warning (_ ("Build-id of %ps does not match core file."),
-			   styled_string (file_name_style.style (),
-					  filename.get ()));
-		  abfd = nullptr;
-		}
+	  if (abfd == nullptr && mismatch)
+	    {
+	      warning (_ ("Build-id of %ps does not match core file."),
+		       styled_string (file_name_style.style (),
+				      filename.get ()));
+	      abfd = nullptr;
 	    }
 	}
     }
diff --git a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
index 6e3301e1c8d..b5dee228ca0 100644
--- a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
+++ b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
@@ -296,6 +296,30 @@ set ptr_value [read_ptr_value]
 gdb_assert { $ptr_value eq "unavailable" } \
     "check value of pointer is unavailable with library file missing"
 
+# Now symlink the .build-id/xx/xxx...xxx filename within the debug
+# directory to library we just moved aside.  Restart GDB and setup the
+# debug-file-directory before loading the core file.
+#
+# GDB should lookup the file to map via the build-id link in the
+# .build-id/ directory.
+set debugdir [standard_output_file "debugdir"]
+set build_id_filename \
+    $debugdir/[build_id_debug_filename_get $library_backup_filename ""]
+
+remote_exec build "mkdir -p [file dirname $build_id_filename]"
+remote_exec build "ln -sf $library_backup_filename $build_id_filename"
+
+clean_restart $binfile
+
+gdb_test_no_output "set debug-file-directory $debugdir" \
+    "set debug-file-directory"
+
+load_core_file "load corefile, lookup in debug-file-directory"
+
+set ptr_value [read_ptr_value]
+gdb_assert { $ptr_value == $ptr_expected_value } \
+    "check value of pointer variable from core-file, lookup in debug-file-directory"
+
 # Build a new version of the shared library, keep the library the same size,
 # but change the contents so the build-id changes.  Then restart GDB and load
 # the core-file again.  GDB should spot that the build-id for the shared
diff --git a/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp b/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp
index 44c4268edd3..cdd9730a22c 100644
--- a/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp
+++ b/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp
@@ -126,10 +126,19 @@ if {$corefile eq ""} {
 # If EXPECT_DOWNLOAD is true then we require a line indicating that
 # the shared library is being downloaded from debuginfod, otherwise
 # the shared library should not be downloaded.
-proc load_exec_and_core_file { expect_warning expect_download testname } {
+#
+# If DEBUGDIR is not the empty string then 'debug-file-directory' is
+# set to the value of DEBUGDIR.
+proc load_exec_and_core_file { expect_warning expect_download testname \
+				   {debugdir ""} } {
     with_test_prefix $testname {
 	clean_restart $::binfile
 
+	if { $debugdir ne "" } {
+	    gdb_test_no_output "set debug-file-directory $debugdir" \
+		"set debug directory"
+	}
+
 	set saw_warning false
 	set saw_download false
 	set saw_generated false
@@ -223,6 +232,27 @@ gdb_assert { [lindex $status 0] == 0 } \
 load_exec_and_core_file true false \
     "load core file, libfoo_1.so removed"
 
+# Symlink the .build-id/xx/xxx...xxx filename within the debug
+# directory to LIBRARY_1_BACKUP_FILENAME, now when we restart GDB it
+# should find the missing library within the debug directory.
+set debugdir [standard_output_file "debugdir"]
+set build_id_filename \
+    $debugdir/[build_id_debug_filename_get $library_1_backup_filename ""]
+set status \
+    [remote_exec build \
+	 "mkdir -p [file dirname $build_id_filename]"]
+gdb_assert { [lindex $status 0] == 0 } \
+    "create sub-directory within the debug directory"
+set status \
+    [remote_exec build \
+	 "ln -sf $library_1_backup_filename $build_id_filename"]
+gdb_assert { [lindex $status 0] == 0 } \
+    "create symlink within the debug directory "
+
+load_exec_and_core_file false false \
+    "load core file, find libfoo_1.so through debug-file-directory" \
+    $debugdir
+
 # Setup a debuginfod server which can serve the original shared
 # library file.
 if {![allow_debuginfod_tests]} {
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index c958ff18d2a..e369b0be96a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -8019,14 +8019,17 @@ proc get_build_id { filename } {
 
 # Return the build-id hex string (usually 160 bits as 40 hex characters)
 # converted to the form: .build-id/ab/cdef1234...89.debug
+#
+# The '.debug' suffix can be changed by passing the SUFFIX argument.
+#
 # Return "" if no build-id found.
-proc build_id_debug_filename_get { filename } {
+proc build_id_debug_filename_get { filename {suffix ".debug"} } {
     set data [get_build_id $filename]
     if { $data == "" } {
 	return ""
     }
     regsub {^..} $data {\0/} data
-    return ".build-id/${data}.debug"
+    return ".build-id/${data}${suffix}"
 }
 
 # DEST should be a file compiled with debug information.  This proc
-- 
2.25.4


^ permalink raw reply	[relevance 6%]

* [PATCH v3] Allow calling of user-defined function call operators
       [not found]     <20240518134123.1243-1-ssbssa.ref@yahoo.de>
@ 2024-05-18 13:41  6% ` Hannes Domani
  0 siblings, 0 replies; 200+ results
From: Hannes Domani @ 2024-05-18 13:41 UTC (permalink / raw)
  To: gdb-patches; +Cc: blarsen, tom

Currently it's not possible to call user-defined function call
operators, at least not without specifying operator() directly:
```
(gdb) l 1
1       struct S {
2         int operator() (int x) { return x + 5; }
3       };
4
5       int main () {
6         S s;
7
8         return s(23);
9       }
(gdb) p s(10)
Invalid data type for function to be called.
(gdb) p s.operator()(10)
$1 = 15
```

This now looks if an user-defined call operator is available when
trying to 'call' a struct value, and calls it instead, making this
possible:
```
(gdb) p s(10)
$1 = 15
```

The change in operation::evaluate_funcall is to make sure the type
fields are only used for function types, only they use them as the
argument types.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=12213
---
v2:
- Move the logic into evaluate_subexp_do_call, to avoid duplication in
  every evaluate_funcall of each operation subclass.
  This makes it now work for some cases it didn't in v1, like if it's
  called on a class member (`print c.m(5)` in the new test).
- Added tests for other (struct member) operations.

v3:
- Additional comments.
---
 gdb/eval.c                       | 32 +++++++++++++++++++++++++++++---
 gdb/testsuite/gdb.cp/userdef.cc  | 22 ++++++++++++++++++++++
 gdb/testsuite/gdb.cp/userdef.exp |  7 +++++++
 3 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index 6b752e70635..356e88b8d4e 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -588,14 +588,36 @@ evaluate_subexp_do_call (expression *exp, enum noside noside,
 {
   if (callee == NULL)
     error (_("Cannot evaluate function -- may be inlined"));
+
+  type *ftype = callee->type ();
+
+  /* If the callee is a struct, there might be a user-defined function call
+     operator that should be used instead.  */
+  std::vector<value *> vals;
+  if (overload_resolution
+      && exp->language_defn->la_language == language_cplus
+      && check_typedef (ftype)->code () == TYPE_CODE_STRUCT)
+    {
+      /* Include space for the `this' pointer at the start.  */
+      vals.resize (argvec.size () + 1);
+
+      vals[0] = value_addr (callee);
+      for (int i = 0; i < argvec.size (); ++i)
+	vals[i + 1] = argvec[i];
+
+      int static_memfuncp;
+      find_overload_match (vals, "operator()", METHOD, &vals[0], nullptr,
+			   &callee, nullptr, &static_memfuncp, 0, noside);
+      if (!static_memfuncp)
+	argvec = vals;
+    }
+
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     {
       /* If the return type doesn't look like a function type,
 	 call an error.  This can happen if somebody tries to turn
 	 a variable into a function call.  */
 
-      type *ftype = callee->type ();
-
       if (ftype->code () == TYPE_CODE_INTERNAL_FUNCTION)
 	{
 	  /* We don't know anything about what the internal
@@ -666,9 +688,13 @@ operation::evaluate_funcall (struct type *expect_type,
   struct type *type = callee->type ();
   if (type->code () == TYPE_CODE_PTR)
     type = type->target_type ();
+  /* If type is a struct, num_fields would refer to the number of
+     members in the type, not the number of arguments.  */
+  bool type_has_arguments
+    = type->code () == TYPE_CODE_FUNC || type->code () == TYPE_CODE_METHOD;
   for (int i = 0; i < args.size (); ++i)
     {
-      if (i < type->num_fields ())
+      if (type_has_arguments && i < type->num_fields ())
 	vals[i] = args[i]->evaluate (type->field (i).type (), exp, noside);
       else
 	vals[i] = args[i]->evaluate_with_coercion (exp, noside);
diff --git a/gdb/testsuite/gdb.cp/userdef.cc b/gdb/testsuite/gdb.cp/userdef.cc
index 774191726f3..7e045e46b3b 100644
--- a/gdb/testsuite/gdb.cp/userdef.cc
+++ b/gdb/testsuite/gdb.cp/userdef.cc
@@ -307,8 +307,21 @@ class Member
 {
 public:
   int z;
+
+  int operator() ();
+  int operator() (int);
 };
 
+int Member::operator() ()
+{
+  return z;
+}
+
+int Member::operator() (int value)
+{
+  return value * z;
+}
+
 bool operator== (const Member &m1, const Member &m2)
 {
   return m1.z == m2.z;
@@ -335,9 +348,11 @@ int main (void)
  Container c;
  Member mem1, mem2;
  int val;
+ Member Container::* mptr = &Container::m;
  
  mem1.z = 5;
  mem2.z = 7;
+ c.m.z = 8;
 
  marker1(); // marker1-returns-here
  cout << one; // marker1-returns-here
@@ -404,6 +419,13 @@ int main (void)
  ++three;
  cout << "preinc " << three;
 
+ val = mem1 ();
+ cout << "funcall " << val << endl;
+ val = mem1 (10);
+ cout << "funcall 2 " << val << endl;
+ val = (c.*mptr) (11);
+ cout << "funcall 3 " << val << endl;
+
  (*c).z = 1;
 
  return 0;
diff --git a/gdb/testsuite/gdb.cp/userdef.exp b/gdb/testsuite/gdb.cp/userdef.exp
index e96636bef0c..ce2781977e7 100644
--- a/gdb/testsuite/gdb.cp/userdef.exp
+++ b/gdb/testsuite/gdb.cp/userdef.exp
@@ -132,4 +132,11 @@ gdb_test "ptype &*c" "type = (struct|class) Member {(\[\r\n \]+public:)?\[\r\n \
 gdb_test "print operator== (mem1, mem2)" " = false"
 gdb_test "print operator== (mem1, mem1)" " = true"
 
+gdb_test "print mem1()" " = 5"
+gdb_test "print mem1(10)" " = 50"
+gdb_test "print (*&mem1)(2)" " = 10"
+gdb_test "print (c.*mptr)(3)" " = 24"
+gdb_test "print (&c)->m(4)" " = 32"
+gdb_test "print c.m(5)" " = 40"
+
 gdb_exit
-- 
2.35.1


^ permalink raw reply	[relevance 6%]

* [PING*2][PATCH v4] gdb/debuginfod: Ctrl-C asks to cancel further downloads
  @ 2024-05-17 14:11  0%   ` Aaron Merey
  0 siblings, 0 replies; 200+ results
From: Aaron Merey @ 2024-05-17 14:11 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom de Vries

Ping re. non-documentation parts of the patch

Thanks,
Aaron

On Thu, Feb 22, 2024 at 5:26 PM Aaron Merey <amerey@redhat.com> wrote:
>
> Ping
>
> Thanks,
> Aaron
>
> On Fri, Feb 2, 2024 at 9:15 PM Aaron Merey <amerey@redhat.com> wrote:
> >
> > v3: https://sourceware.org/pipermail/gdb-patches/2023-March/197679.html
> >
> > v4 includes changes needed to apply the patch to the current master branch.
> >
> > Currently gdb only allows for debuginfod downloads to be cancelled one at
> > a time via Ctrl-C.  This can be a burden if one wishes to cancel a large
> > series of downloads.  Additionally there can also be ambiguity between whether
> > Ctrl-C during a download was intended to cancel a download or interrupt the
> > inferior.
> >
> > This patch addresses these issues by adding a new debuginfod setting and
> > changing the behavior of Ctrl-C during a download.
> >
> > Add a new command "set debuginfod cancel one/all/ask", where:
> > - "one" means Ctrl-C cancels one download,
> > - "all" means Ctrl-C cancels all further downloads, and
> > - "ask" means Ctrl-C asks whether to cancel all further downloads.  A "yes"
> >   implies "set debuginfod cancel all", and a "no" implies "set debuginfod
> >   cancel one", so the question is only asked once.
> >
> > Note that the behaviour as it was before this patch is equivalent to
> > "set debuginfod cancel one".  Instead, the new default is "set debuginfod
> > cancel ask".  Note that cancelling all further downloads implies "set
> > debuginfod enabled off".
> >
> > A single Ctrl-C during downloading now sets the quit_flag and proceeds with
> > all downloads.  If the inferior has the terminal, then a second Ctrl-C during
> > downloading triggers a query asking whether to cancel the download or
> > interrupt the inferior.  If the user wishes to cancel the download then
> > the setting of 'set debuginfod cancel' determines whether one or all
> > downloads are cancelled.  In the case of "set debuginfod cancel ask",
> > there will be another query at this point asking whether to cancel one
> > or all downloads.
> >
> > If the inferior does not have the terminal, then a second Ctrl-C during
> > downloading simply cancels the download according to the setting of
> > "set debuginfod cancel".  In this case there is no query asking whether
> > to interrupt the inferior or cancel a download.
> >
> > Example session where inferior has terminal:
> >
> >     (gdb) run
> >     [...]
> >     Downloading separate debug info for /lib64/libxyz.so
> >     [###                                                            ]^C^C
> >     Cancel the current download?
> >     If no, then Ctrl-C will be sent to the target process. ([y] or n) y
> >     Cancelling download of separate debug info for /lib64/libxyz.so...
> >     Cancel further downloading for this session? (y or [n]) n
> >     Downloading separate debug info for /lib64/libabcd.so
> >
> > Example session where inferior does not have terminal:
> >
> >     (gdb) run
> >     [...]
> >     Downloading separate debug info for /lib64/libxyz.so
> >     [###                                                            ]^C^C
> >     Cancelling download of separate debug info for /lib64/libxyz.so...
> >     Cancel further downloading for this session? (y or [n]) y
> >     Debuginfod has been disabled.
> >     To re-enable use the 'set debuginfod enabled' command.
> >
> > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29582
> > Suggested-By: Martin Liška <mliska@suse.cz>
> > Co-Authored-By: Tom de Vries <tdevries@suse.de>
> > ---
> >  gdb/debuginfod-support.c | 183 +++++++++++++++++++++++++++++++++++++--
> >  gdb/doc/gdb.texinfo      |  21 +++++
> >  2 files changed, 199 insertions(+), 5 deletions(-)
> >
> > diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
> > index 7d8ada39e96..97d4b2f2bac 100644
> > --- a/gdb/debuginfod-support.c
> > +++ b/gdb/debuginfod-support.c
> > @@ -38,6 +38,8 @@ static cmd_list_element *maint_show_debuginfod_cmdlist;
> >  static const char debuginfod_on[] = "on";
> >  static const char debuginfod_off[] = "off";
> >  static const char debuginfod_ask[] = "ask";
> > +static const char debuginfod_one[] = "one";
> > +static const char debuginfod_all[] = "all";
> >
> >  static const char *debuginfod_enabled_enum[] =
> >  {
> > @@ -47,6 +49,20 @@ static const char *debuginfod_enabled_enum[] =
> >    nullptr
> >  };
> >
> > +/* Valid values for set debuginfod cancel command.  */
> > +
> > +static const char *debuginfod_cancel_enum[] =
> > +{
> > +  debuginfod_one,
> > +  debuginfod_all,
> > +  debuginfod_ask,
> > +  nullptr
> > +};
> > +
> > +/* Value of debuginfod cancellation mode.  */
> > +
> > +static const char *debuginfod_cancel = debuginfod_ask;
> > +
> >  static const char *debuginfod_enabled =
> >  #if defined(HAVE_LIBDEBUGINFOD)
> >    debuginfod_ask;
> > @@ -109,9 +125,11 @@ debuginfod_section_query (const unsigned char *build_id,
> >  struct user_data
> >  {
> >    user_data (const char *desc, const char *fname)
> > -    : desc (desc), fname (fname)
> > +    : pass_quit_flag (false), inf_had_term (false), desc (desc), fname (fname)
> >    { }
> >
> > +  bool pass_quit_flag;
> > +  bool inf_had_term;
> >    const char * const desc;
> >    const char * const fname;
> >    ui_out::progress_update progress;
> > @@ -156,10 +174,83 @@ progressfn (debuginfod_client *c, long cur, long total)
> >    if (check_quit_flag ())
> >      {
> >        ui_file *outstream = get_unbuffered (gdb_stdout);
> > -      gdb_printf (outstream, _("Cancelling download of %s %s...\n"),
> > -                 data->desc, styled_fname.c_str ());
> > -      return 1;
> > -    }
> > +
> > +      /* If a single Ctrl-C occurs during downloading, let it propagate to the
> > +        target.  If more than one Ctrl-C occurs, ask whether to cancel the
> > +        current download or interrupt the target.  If the download is
> > +        cancelled, the setting of debuginfod_cancel will determine whether
> > +        the current download is cancelled or debuginfod is disabled.  */
> > +      if (!data->pass_quit_flag)
> > +       data->pass_quit_flag = true;
> > +      else
> > +       {
> > +         int resp = 1;
> > +         bool extra_nl = false;
> > +
> > +         if (data->inf_had_term)
> > +           {
> > +             /* If Ctrl-C occurs during the following prompts, catch the
> > +                exception to prevent unsafe early returns to gdb's main
> > +                event loop.  During these prompts, Ctrl-C is equivalent to
> > +                answering 'y'.  */
> > +             try
> > +               {
> > +                 resp = yquery (_("Cancel the current download?\nIf no, "
> > +                                  "then Ctrl-C will be sent to the target "
> > +                                  "process. "));
> > +               }
> > +             catch (const gdb_exception &)
> > +               {
> > +                 /* If the query doesn't complete, then we need an additional
> > +                    newline to get "Cancelling download of..." printed on a
> > +                    separate line.  */
> > +                 extra_nl = true;
> > +               }
> > +           }
> > +         if (resp)
> > +           {
> > +             if (extra_nl)
> > +               {
> > +                 gdb_printf (outstream, "\n");
> > +                 extra_nl = false;
> > +               }
> > +
> > +             gdb_printf (outstream, _("Cancelling download of %s %s...\n"),
> > +                                      data->desc, styled_fname.c_str ());
> > +             if (debuginfod_cancel == debuginfod_ask)
> > +               {
> > +                 try
> > +                   {
> > +                     resp = nquery
> > +                       (_("Cancel further downloading for this session? "));
> > +                   }
> > +                 catch (const gdb_exception &)
> > +                   {
> > +                     resp = 1;
> > +                     extra_nl = true;
> > +                   }
> > +
> > +                 if (resp)
> > +                   debuginfod_cancel = debuginfod_all;
> > +                 else
> > +                   debuginfod_cancel = debuginfod_one;
> > +               }
> > +             if (debuginfod_cancel == debuginfod_all)
> > +               {
> > +                 if (extra_nl)
> > +                   gdb_printf (outstream, "\n");
> > +
> > +                 gdb_printf (outstream,
> > +                             _("Debuginfod has been disabled.\nTo re-enable "
> > +                               "use the 'set debuginfod enabled' command.\n"));
> > +                 debuginfod_enabled = debuginfod_off;
> > +               }
> > +
> > +           data->pass_quit_flag = false;
> > +           return 1;
> > +         }
> > +      }
> > +  }
> >
> >    if (debuginfod_verbose == 0)
> >      return 0;
> > @@ -330,6 +421,10 @@ debuginfod_source_query (const unsigned char *build_id,
> >      user_data data ("source file", srcpath);
> >
> >      debuginfod_set_user_data (c, &data);
> > +
> > +   if (!target_terminal::is_ours ())
> > +     data.inf_had_term = true;
> > +
> >      if (target_supports_terminal_ours ())
> >        {
> >         term_state.emplace ();
> > @@ -341,6 +436,11 @@ debuginfod_source_query (const unsigned char *build_id,
> >                                             build_id_len,
> >                                             srcpath,
> >                                             &dname));
> > +    if (data.pass_quit_flag)
> > +      set_quit_flag ();
> > +    if (data.inf_had_term && term_state.has_value ())
> > +      target_terminal::inferior ();
> > +
> >      debuginfod_set_user_data (c, nullptr);
> >    }
> >
> > @@ -376,6 +476,10 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
> >      user_data data ("separate debug info for", filename);
> >
> >      debuginfod_set_user_data (c, &data);
> > +
> > +    if (!target_terminal::is_ours ())
> > +      data.inf_had_term = true;
> > +
> >      if (target_supports_terminal_ours ())
> >        {
> >         term_state.emplace ();
> > @@ -384,6 +488,12 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
> >
> >      fd = scoped_fd (debuginfod_find_debuginfo (c, build_id, build_id_len,
> >                                                &dname));
> > +
> > +    if (data.pass_quit_flag)
> > +      set_quit_flag ();
> > +    if (data.inf_had_term && term_state.has_value ())
> > +      target_terminal::inferior ();
> > +
> >      debuginfod_set_user_data (c, nullptr);
> >    }
> >
> > @@ -419,6 +529,10 @@ debuginfod_exec_query (const unsigned char *build_id,
> >      user_data data ("executable for", filename);
> >
> >      debuginfod_set_user_data (c, &data);
> > +
> > +    if (!target_terminal::is_ours ())
> > +      data.inf_had_term = true;
> > +
> >      if (target_supports_terminal_ours ())
> >        {
> >         term_state.emplace ();
> > @@ -427,6 +541,11 @@ debuginfod_exec_query (const unsigned char *build_id,
> >
> >      fd = scoped_fd (debuginfod_find_executable (c, build_id, build_id_len,
> >                                                 &dname));
> > +    if (data.pass_quit_flag)
> > +      set_quit_flag ();
> > +    if (data.inf_had_term && term_state.has_value ())
> > +      target_terminal::inferior ();
> > +
> >      debuginfod_set_user_data (c, nullptr);
> >    }
> >
> > @@ -467,6 +586,10 @@ debuginfod_section_query (const unsigned char *build_id,
> >    {
> >      user_data data (desc.c_str (), filename);
> >      debuginfod_set_user_data (c, &data);
> > +
> > +    if (!target_terminal::is_ours ())
> > +      data.inf_had_term = true;
> > +
> >      if (target_supports_terminal_ours ())
> >        {
> >         term_state.emplace ();
> > @@ -475,6 +598,12 @@ debuginfod_section_query (const unsigned char *build_id,
> >
> >      fd = scoped_fd (debuginfod_find_section (c, build_id, build_id_len,
> >                                              section_name, &dname));
> > +
> > +    if (data.pass_quit_flag)
> > +      set_quit_flag ();
> > +    if (data.inf_had_term && term_state.has_value ())
> > +      target_terminal::inferior ();
> > +
> >      debuginfod_set_user_data (c, nullptr);
> >    }
> >
> > @@ -523,6 +652,33 @@ show_debuginfod_enabled (ui_file *file, int from_tty, cmd_list_element *cmd,
> >                 "\"%s\".\n"), debuginfod_enabled);
> >  }
> >
> > +/* Set callback for "set debuginfod cancel".  */
> > +
> > +static void
> > +set_debuginfod_cancel (const char *value)
> > +{
> > +  debuginfod_cancel = value;
> > +}
> > +
> > +/* Get callback for "set debuginfod cancel".  */
> > +
> > +static const char *
> > +get_debuginfod_cancel ()
> > +{
> > +  return debuginfod_cancel;
> > +}
> > +
> > +/* Show callback for "set debuginfod cancel".  */
> > +
> > +static void
> > +show_debuginfod_cancel (ui_file *file, int from_tty, cmd_list_element *cmd,
> > +                       const char *value)
> > +{
> > +  gdb_printf (file,
> > +             _("Debuginfod cancellation mode is currently set to "
> > +               "\"%s\".\n"), debuginfod_cancel);
> > +}
> > +
> >  /* Set callback for "set debuginfod urls".  */
> >
> >  static void
> > @@ -627,6 +783,23 @@ When set to \"ask\", prompt whether to enable or disable debuginfod." ),
> >                         &set_debuginfod_prefix_list,
> >                         &show_debuginfod_prefix_list);
> >
> > +  add_setshow_enum_cmd ("cancel", class_run, debuginfod_cancel_enum,
> > +                       _("Set Ctrl-C behaviour for debuginfod."),
> > +                       _("Show Ctrl-C behaviour for debuginfod."),
> > +                       _("\
> > +When set to \'one\', pressing Ctrl-C twice cancels a single \
> > +download.\nWhen set to \'all\', pressing Ctrl-C twice cancels all further downloads.\n\
> > +When set to \'ask\', pressing Ctrl-C twice asks what to do.\nA single Ctrl-C during \
> > +downloading is passed to the target process being debugged.\nA second Ctrl-C \
> > +during downloading may raise a prompt asking whether to cancel the download or \
> > +send Ctrl-C to the target.\nIf the download is cancelled, then no Ctrl-C is \
> > +sent to the target."),
> > +                       set_debuginfod_cancel,
> > +                       get_debuginfod_cancel,
> > +                       show_debuginfod_cancel,
> > +                       &set_debuginfod_prefix_list,
> > +                       &show_debuginfod_prefix_list);
> > +
> >    /* set/show debuginfod urls */
> >    add_setshow_string_noescape_cmd ("urls", class_run, _("\
> >  Set the list of debuginfod server URLs."), _("\
> > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> > index e98c15242bc..d6df28896b1 100644
> > --- a/gdb/doc/gdb.texinfo
> > +++ b/gdb/doc/gdb.texinfo
> > @@ -50259,6 +50259,27 @@ is set to @code{ask} for interactive sessions.
> >  Display whether @code{debuginfod enabled} is set to @code{on}, @code{off} or
> >  @code{ask}.
> >
> > +@kindex set debuginfod cancel
> > +@anchor{set debuginfod cancel}
> > +@item set debuginfod cancel
> > +@itemx set debuginfod cancel one
> > +@cindex debuginfod @kbd{Ctrl-C} behaviour
> > +Pressing @kbd{Ctrl-C} twice during downloading will cancel the current
> > +download.
> > +
> > +@item set debuginfod cancel all
> > +Pressing @kbd{Ctrl-C} twice during downloading will cancel this and all
> > +further downloads.
> > +
> > +@item set debuginfod cancel ask
> > +Pressing @kbd{Ctrl-C} twice during downloading will cancel the current
> > +download and prompt whether to cancel all further downloads.  By default,
> > +@code{debuginfod cancel} is set to @code{ask} for interactive sessions.
> > +
> > +@kindex show debuginfod cancel
> > +@item show debuginfod cancel
> > +Display the current setting of @code{debuginfod cancel}.
> > +
> >  @kindex set debuginfod urls
> >  @cindex configure debuginfod URLs
> >  @item set debuginfod urls
> > --
> > 2.43.0
> >


^ permalink raw reply	[relevance 0%]

* Re: [PATCH] Don't allow new-ui to start the TUI
  @ 2024-05-17 14:11  0% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-05-17 14:11 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: Tom Tromey

Tom Tromey <tromey@adacore.com> writes:

> The TUI can't really work properly with new-ui, at least not as
> currently written.  This patch changes new-ui to reject an attempt.
> Attempting to make a DAP ui this way is also now rejected.
>
> Regression tested on x86-64 Fedora 38.

LGTM.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29273
> ---
>  gdb/interps.c                     |  5 ++++-
>  gdb/interps.h                     | 10 ++++++++--
>  gdb/main.c                        |  2 +-
>  gdb/python/py-dap.c               |  3 +++
>  gdb/testsuite/gdb.base/new-ui.exp |  5 +++++
>  gdb/tui/tui-interp.c              |  3 +++
>  gdb/ui.c                          |  2 +-
>  7 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/gdb/interps.c b/gdb/interps.c
> index 94a982e97ab..59c4ec532a7 100644
> --- a/gdb/interps.c
> +++ b/gdb/interps.c
> @@ -187,13 +187,16 @@ interp_lookup (struct ui *ui, const char *name)
>  /* See interps.h.  */
>  
>  void
> -set_top_level_interpreter (const char *name)
> +set_top_level_interpreter (const char *name, bool for_new_ui)
>  {
>    /* Find it.  */
>    struct interp *interp = interp_lookup (current_ui, name);
>  
>    if (interp == NULL)
>      error (_("Interpreter `%s' unrecognized"), name);
> +  if (for_new_ui && !interp->supports_new_ui ())
> +    error (_("interpreter '%s' cannot be used with a new UI"), name);
> +
>    /* Install it.  */
>    interp_set (interp, true);
>  }
> diff --git a/gdb/interps.h b/gdb/interps.h
> index bd435d734af..8d80c005ded 100644
> --- a/gdb/interps.h
> +++ b/gdb/interps.h
> @@ -84,6 +84,10 @@ class interp : public intrusive_list_node<interp>
>    virtual bool supports_command_editing ()
>    { return false; }
>  
> +  /* Returns true if this interpreter supports new UIs.  */
> +  virtual bool supports_new_ui () const
> +  { return true; }
> +
>    const char *name () const
>    { return m_name; }
>  
> @@ -201,8 +205,10 @@ extern struct interp *interp_lookup (struct ui *ui, const char *name);
>  
>  /* Set the current UI's top level interpreter to the interpreter named
>     NAME.  Throws an error if NAME is not a known interpreter or the
> -   interpreter fails to initialize.  */
> -extern void set_top_level_interpreter (const char *name);
> +   interpreter fails to initialize.  FOR_NEW_UI is true when called
> +   from the 'new-ui' command, and causes an extra check to ensure the
> +   interpreter is valid for a new UI.  */
> +extern void set_top_level_interpreter (const char *name, bool for_new_ui);
>  
>  /* Temporarily set the current interpreter, and reset it on
>     destruction.  */
> diff --git a/gdb/main.c b/gdb/main.c
> index 8b81640e8d2..efc04a66bbb 100644
> --- a/gdb/main.c
> +++ b/gdb/main.c
> @@ -1147,7 +1147,7 @@ captured_main_1 (struct captured_main_args *context)
>  
>    /* Install the default UI.  All the interpreters should have had a
>       look at things by now.  Initialize the default interpreter.  */
> -  set_top_level_interpreter (interpreter_p.c_str ());
> +  set_top_level_interpreter (interpreter_p.c_str (), false);
>  
>    /* The interpreter should have installed the real uiout by now.  */
>    gdb_assert (current_uiout != temp_uiout.get ());
> diff --git a/gdb/python/py-dap.c b/gdb/python/py-dap.c
> index 861514d9002..d5555c90a11 100644
> --- a/gdb/python/py-dap.c
> +++ b/gdb/python/py-dap.c
> @@ -62,6 +62,9 @@ class dap_interp final : public interp
>  
>    void pre_command_loop () override;
>  
> +  bool supports_new_ui () const override
> +  { return false; }
> +
>  private:
>  
>    std::unique_ptr<ui_out> m_ui_out;
> diff --git a/gdb/testsuite/gdb.base/new-ui.exp b/gdb/testsuite/gdb.base/new-ui.exp
> index 97166925c1b..2dfcbf7e108 100644
> --- a/gdb/testsuite/gdb.base/new-ui.exp
> +++ b/gdb/testsuite/gdb.base/new-ui.exp
> @@ -183,6 +183,11 @@ proc_with_prefix do_test_invalid_args {} {
>  	     "Interpreter `bloop' unrecognized" \
>  	     "new-ui with bad interpreter name"
>  
> +    # Test that the TUI cannot be used for a new UI.
> +    gdb_test "new-ui tui $extra_tty_name" \
> +	"interpreter 'tui' cannot be used with a new UI" \
> +	"new-ui with tui"
> +
>      # Test that we can continue working normally.
>      if ![runto_main] {
>  	return
> diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
> index a75708ba662..7ebaf8f83f7 100644
> --- a/gdb/tui/tui-interp.c
> +++ b/gdb/tui/tui-interp.c
> @@ -50,6 +50,9 @@ class tui_interp final : public cli_interp_base
>    void suspend () override;
>    void exec (const char *command_str) override;
>    ui_out *interp_ui_out () override;
> +
> +  bool supports_new_ui () const override
> +  { return false; }
>  };
>  
>  /* Cleanup the tui before exiting.  */
> diff --git a/gdb/ui.c b/gdb/ui.c
> index 80ee67dbae5..e5c7965d8dc 100644
> --- a/gdb/ui.c
> +++ b/gdb/ui.c
> @@ -224,7 +224,7 @@ new_ui_command (const char *args, int from_tty)
>  
>      current_ui = ui.get ();
>  
> -    set_top_level_interpreter (interpreter_name);
> +    set_top_level_interpreter (interpreter_name, true);
>  
>      top_level_interpreter ()->pre_command_loop ();
>  
> -- 
> 2.44.0


^ permalink raw reply	[relevance 0%]

* [PING][PATCH 3/3 v6] gdb/debuginfod: Add .debug_line downloading
  @ 2024-05-17 14:10  0%   ` Aaron Merey
  0 siblings, 0 replies; 200+ results
From: Aaron Merey @ 2024-05-17 14:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

Ping

Thanks,
Aaron

On Fri, May 3, 2024 at 6:59 PM Aaron Merey <amerey@redhat.com> wrote:
>
> This is a repost of v6 from
> https://sourceware.org/pipermail/gdb-patches/2024-January/205956.html
>
> ELF/DWARF section downloading allows gdb to download .gdb_index files in
> order to defer full debuginfo downloads.  However .gdb_index does not
> contain any information regarding source filenames.  When a gdb command
> includes a filename argument (ex. 'break main.c:50'), this results in
> the mass downloading of all deferred debuginfo so that gdb can search the
> debuginfo for matching source filenames.  This can result in unnecessary
> downloads.
>
> To improve this, have gdb instead download each debuginfo's .debug_line
> (and .debug_line_str if using DWARF5) when executing these commands.
> Download full debuginfo only when its .debug_line contains a matching
> filename.
>
> Since the combined size of .debug_line and .debug_line_str is only about
> 1% the size of the corresponding debuginfo, significant time can be saved
> by checking these sections before choosing to download an entire debuginfo.
>
> This patch also redirects stdout and stderr of the debuginfod server
> used by testsuite/gdb.debuginfod tests to a server_log standard output
> file.  While adding tests for this patch I ran into an issue where the
> test server would block when logging to stderr, presumably because the
> stderr buffer filled up and wasn't being read from.  Redirecting the
> log to a file fixes this and also makes the server log more accessible
> when debugging test failures.
> ---
>  gdb/cli-out.c                            |  11 +-
>  gdb/completer.c                          |  18 +-
>  gdb/dwarf2/line-header.c                 | 161 ++++++++++++------
>  gdb/dwarf2/line-header.h                 |  10 ++
>  gdb/dwarf2/read-gdb-index.c              |  60 +++++++
>  gdb/dwarf2/read.c                        | 208 +++++++++++++++++++++++
>  gdb/dwarf2/read.h                        |  37 ++++
>  gdb/mi/mi-out.c                          |   9 +-
>  gdb/testsuite/gdb.debuginfod/section.exp |  27 +++
>  gdb/ui-out.c                             |   3 +
>  gdb/ui-out.h                             |  20 +++
>  11 files changed, 511 insertions(+), 53 deletions(-)
>
> diff --git a/gdb/cli-out.c b/gdb/cli-out.c
> index 1c303f09662..d65b69ebe01 100644
> --- a/gdb/cli-out.c
> +++ b/gdb/cli-out.c
> @@ -306,16 +306,23 @@ cli_ui_out::do_progress_notify (const std::string &msg,
>
>    if (info.state == progress_update::START)
>      {
> +      std::string prefix;
> +      if (cur_prefix_state == prefix_state_t::NEWLINE_NEEDED)
> +       {
> +         prefix = "\n";
> +         cur_prefix_state = prefix_state_t::NEWLINE_PRINTED;
> +       }
> +
>        if (stream->isatty ()
>           && current_ui->input_interactive_p ()
>           && chars_per_line >= MIN_CHARS_PER_LINE)
>         {
> -         gdb_printf (stream, "%s\n", msg.c_str ());
> +         gdb_printf (stream, "%s\n", (prefix + msg).c_str ());
>           info.state = progress_update::BAR;
>         }
>        else
>         {
> -         gdb_printf (stream, "%s...\n", msg.c_str ());
> +         gdb_printf (stream, "%s...\n", (prefix + msg).c_str ());
>           info.state = progress_update::WORKING;
>         }
>      }
> diff --git a/gdb/completer.c b/gdb/completer.c
> index f1f44109bdc..708081cf280 100644
> --- a/gdb/completer.c
> +++ b/gdb/completer.c
> @@ -1354,6 +1354,10 @@ complete_line_internal_1 (completion_tracker &tracker,
>      {
>        /* We've recognized a full command.  */
>
> +      /* Disable pagination since responding to the pagination prompt
> +        overwrites rl_line_buffer.  */
> +      scoped_restore pag_restore = make_scoped_restore (&pagination_enabled, false);
> +
>        if (p == tmp_command + point)
>         {
>           /* There is no non-whitespace in the line beyond the
> @@ -1453,7 +1457,8 @@ complete_line_internal_1 (completion_tracker &tracker,
>  }
>
>  /* Wrapper around complete_line_internal_1 to handle
> -   MAX_COMPLETIONS_REACHED_ERROR.  */
> +   MAX_COMPLETIONS_REACHED_ERROR and possible progress update
> +   interactions.  */
>
>  static void
>  complete_line_internal (completion_tracker &tracker,
> @@ -1461,6 +1466,11 @@ complete_line_internal (completion_tracker &tracker,
>                         const char *line_buffer, int point,
>                         complete_line_internal_reason reason)
>  {
> +  scoped_restore restore_prefix_state
> +    = make_scoped_restore
> +      (&cur_prefix_state,
> +       ui_out::progress_update::prefix_state::NEWLINE_NEEDED);
> +
>    try
>      {
>        complete_line_internal_1 (tracker, text, line_buffer, point, reason);
> @@ -1470,6 +1480,12 @@ complete_line_internal (completion_tracker &tracker,
>        if (except.error != MAX_COMPLETIONS_REACHED_ERROR)
>         throw;
>      }
> +
> +  /* If progress update messages printed, then the text being completed
> +     needs to be printed again.  */
> +  if (cur_prefix_state
> +      == ui_out::progress_update::prefix_state::NEWLINE_PRINTED)
> +    rl_forced_update_display ();
>  }
>
>  /* See completer.h.  */
> diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
> index eddb2ef7ae8..1d24386c0eb 100644
> --- a/gdb/dwarf2/line-header.c
> +++ b/gdb/dwarf2/line-header.c
> @@ -101,12 +101,15 @@ read_checked_initial_length_and_offset (bfd *abfd, const gdb_byte *buf,
>  {
>    LONGEST length = read_initial_length (abfd, buf, bytes_read);
>
> -  gdb_assert (cu_header->initial_length_size == 4
> -             || cu_header->initial_length_size == 8
> -             || cu_header->initial_length_size == 12);
> +  if (cu_header != nullptr)
> +    {
> +      gdb_assert (cu_header->initial_length_size == 4
> +                 || cu_header->initial_length_size == 8
> +                 || cu_header->initial_length_size == 12);
>
> -  if (cu_header->initial_length_size != *bytes_read)
> -    complaint (_("intermixed 32-bit and 64-bit DWARF sections"));
> +      if (cu_header->initial_length_size != *bytes_read)
> +       complaint (_("intermixed 32-bit and 64-bit DWARF sections"));
> +    }
>
>    *offset_size = (*bytes_read == 4) ? 4 : 8;
>    return length;
> @@ -115,21 +118,27 @@ read_checked_initial_length_and_offset (bfd *abfd, const gdb_byte *buf,
>  /* Read directory or file name entry format, starting with byte of
>     format count entries, ULEB128 pairs of entry formats, ULEB128 of
>     entries count and the entries themselves in the described entry
> -   format.  */
> +   format.
> +
> +   .debug_line and .debug_line_str sections are stored in LINE_BUFP
> +   and LINE_STR_DATA respectively.  */
>
>  static void
> -read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
> -                       const gdb_byte **bufp, struct line_header *lh,
> -                       unsigned int offset_size,
> -                       void (*callback) (struct line_header *lh,
> -                                         const char *name,
> -                                         dir_index d_index,
> -                                         unsigned int mod_time,
> -                                         unsigned int length))
> +read_formatted_entries
> +  (bfd *abfd, const gdb_byte **line_bufp,
> +   const gdb::array_view<const gdb_byte> line_str_data,
> +   struct line_header *lh,
> +   unsigned int offset_size,
> +   void (*callback) (struct line_header *lh,
> +                    const char *name,
> +                    dir_index d_index,
> +                    unsigned int mod_time,
> +                    unsigned int length))
>  {
>    gdb_byte format_count, formati;
>    ULONGEST data_count, datai;
> -  const gdb_byte *buf = *bufp;
> +  const gdb_byte *buf = *line_bufp;
> +  const gdb_byte *str_buf = line_str_data.data ();
>    const gdb_byte *format_header_data;
>    unsigned int bytes_read;
>
> @@ -156,7 +165,7 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
>           ULONGEST content_type = read_unsigned_leb128 (abfd, format, &bytes_read);
>           format += bytes_read;
>
> -         ULONGEST form  = read_unsigned_leb128 (abfd, format, &bytes_read);
> +         ULONGEST form = read_unsigned_leb128 (abfd, format, &bytes_read);
>           format += bytes_read;
>
>           std::optional<const char *> string;
> @@ -171,12 +180,24 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
>
>             case DW_FORM_line_strp:
>               {
> -               const char *str
> -                 = per_objfile->read_line_string (buf, offset_size);
> +               if (line_str_data.empty ())
> +                 warning (_("Dwarf Error: DW_FORM_line_strp used without " \
> +                            "required section"));
> +
> +               if (line_str_data.size () <= offset_size)
> +                 warning (_("Dwarf Error: DW_FORM_line_strp pointing outside " \
> +                            "of section .debug_line_str"));
> +
> +               ULONGEST str_offset = read_offset (abfd, buf, offset_size);
> +               const char *str;
> +               if (str_buf[str_offset] == '\0')
> +                 str = nullptr;
> +               else
> +                 str = (const char *) (str_buf + str_offset);
>                 string.emplace (str);
>                 buf += offset_size;
> +               break;
>               }
> -             break;
>
>             case DW_FORM_data1:
>               uint.emplace (read_1_byte (abfd, buf));
> @@ -247,28 +268,30 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
>        callback (lh, fe.name, fe.d_index, fe.mod_time, fe.length);
>      }
>
> -  *bufp = buf;
> +  *line_bufp = buf;
>  }
>
>  /* See line-header.h.  */
>
>  line_header_up
> -dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
> -                          dwarf2_per_objfile *per_objfile,
> -                          struct dwarf2_section_info *section,
> -                          const struct comp_unit_head *cu_header,
> -                          const char *comp_dir)
> +dwarf_decode_line_header (bfd *abfd,
> +                         gdb::array_view<const gdb_byte> line_data,
> +                         gdb::array_view<const gdb_byte> line_str_data,
> +                         const gdb_byte **debug_line_ptr,
> +                         bool is_dwz,
> +                         const struct comp_unit_head *cu_header,
> +                         const char *comp_dir)
>  {
> -  const gdb_byte *line_ptr;
> +  const gdb_byte *line_ptr, *buf;
>    unsigned int bytes_read, offset_size;
>    int i;
>    const char *cur_dir, *cur_file;
>
> -  bfd *abfd = section->get_bfd_owner ();
> +  buf = *debug_line_ptr;
>
>    /* Make sure that at least there's room for the total_length field.
>       That could be 12 bytes long, but we're just going to fudge that.  */
> -  if (to_underlying (sect_off) + 4 >= section->size)
> +  if (buf + 4 >= line_data.data () + line_data.size ())
>      {
>        dwarf2_statement_list_fits_in_line_number_section_complaint ();
>        return 0;
> @@ -276,24 +299,26 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>
>    line_header_up lh (new line_header (comp_dir));
>
> -  lh->sect_off = sect_off;
> +  lh->sect_off = (sect_offset) (buf - line_data.data ());
>    lh->offset_in_dwz = is_dwz;
>
> -  line_ptr = section->buffer + to_underlying (sect_off);
> +  line_ptr = buf;
>
>    /* Read in the header.  */
>    LONGEST unit_length
> -    = read_checked_initial_length_and_offset (abfd, line_ptr, cu_header,
> +    = read_checked_initial_length_and_offset (abfd, buf, cu_header,
>                                               &bytes_read, &offset_size);
> -  line_ptr += bytes_read;
>
> -  const gdb_byte *start_here = line_ptr;
> +  line_ptr += bytes_read;
>
> -  if (line_ptr + unit_length > (section->buffer + section->size))
> +  if (line_ptr + unit_length > buf + line_data.size ())
>      {
>        dwarf2_statement_list_fits_in_line_number_section_complaint ();
>        return 0;
>      }
> +
> +  const gdb_byte *start_here = line_ptr;
> +
>    lh->statement_program_end = start_here + unit_length;
>    lh->version = read_2_bytes (abfd, line_ptr);
>    line_ptr += 2;
> @@ -302,7 +327,7 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>        /* This is a version we don't understand.  The format could have
>          changed in ways we don't handle properly so just punt.  */
>        complaint (_("unsupported version in .debug_line section"));
> -      return NULL;
> +      return nullptr;
>      }
>    if (lh->version >= 5)
>      {
> @@ -319,13 +344,14 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>           complaint (_("unsupported segment selector size %u "
>                        "in .debug_line section"),
>                      segment_selector_size);
> -         return NULL;
> +         return nullptr;
>         }
>      }
>
>    LONGEST header_length = read_offset (abfd, line_ptr, offset_size);
>    line_ptr += offset_size;
>    lh->statement_program_start = line_ptr + header_length;
> +
>    lh->minimum_instruction_length = read_1_byte (abfd, line_ptr);
>    line_ptr += 1;
>
> @@ -346,12 +372,16 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>
>    lh->default_is_stmt = read_1_byte (abfd, line_ptr);
>    line_ptr += 1;
> +
>    lh->line_base = read_1_signed_byte (abfd, line_ptr);
>    line_ptr += 1;
> +
>    lh->line_range = read_1_byte (abfd, line_ptr);
>    line_ptr += 1;
> +
>    lh->opcode_base = read_1_byte (abfd, line_ptr);
>    line_ptr += 1;
> +
>    lh->standard_opcode_lengths.reset (new unsigned char[lh->opcode_base]);
>
>    lh->standard_opcode_lengths[0] = 1;  /* This should never be used anyway.  */
> @@ -364,21 +394,23 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>    if (lh->version >= 5)
>      {
>        /* Read directory table.  */
> -      read_formatted_entries (per_objfile, abfd, &line_ptr, lh.get (),
> -                             offset_size,
> -                             [] (struct line_header *header, const char *name,
> -                                 dir_index d_index, unsigned int mod_time,
> -                                 unsigned int length)
> +      read_formatted_entries
> +       (abfd, &line_ptr, line_str_data,
> +        lh.get (), offset_size,
> +        [] (struct line_header *header, const char *name,
> +            dir_index d_index, unsigned int mod_time,
> +            unsigned int length)
>         {
>           header->add_include_dir (name);
>         });
>
>        /* Read file name table.  */
> -      read_formatted_entries (per_objfile, abfd, &line_ptr, lh.get (),
> -                             offset_size,
> -                             [] (struct line_header *header, const char *name,
> -                                 dir_index d_index, unsigned int mod_time,
> -                                 unsigned int length)
> +      read_formatted_entries
> +       (abfd, &line_ptr, line_str_data,
> +        lh.get (), offset_size,
> +        [] (struct line_header *header, const char *name,
> +            dir_index d_index, unsigned int mod_time,
> +            unsigned int length)
>         {
>           header->add_file_name (name, d_index, mod_time, length);
>         });
> @@ -386,7 +418,7 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>    else
>      {
>        /* Read directory table.  */
> -      while ((cur_dir = read_direct_string (abfd, line_ptr, &bytes_read)) != NULL)
> +      while ((cur_dir = read_direct_string (abfd, line_ptr, &bytes_read)) != nullptr)
>         {
>           line_ptr += bytes_read;
>           lh->add_include_dir (cur_dir);
> @@ -394,7 +426,7 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>        line_ptr += bytes_read;
>
>        /* Read file name table.  */
> -      while ((cur_file = read_direct_string (abfd, line_ptr, &bytes_read)) != NULL)
> +      while ((cur_file = read_direct_string (abfd, line_ptr, &bytes_read)) != nullptr)
>         {
>           unsigned int mod_time, length;
>           dir_index d_index;
> @@ -412,9 +444,40 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>        line_ptr += bytes_read;
>      }
>
> -  if (line_ptr > (section->buffer + section->size))
> +  if (line_ptr > (buf + line_data.size ()))
>      complaint (_("line number info header doesn't "
>                  "fit in `.debug_line' section"));
>
> +  *debug_line_ptr += unit_length + offset_size;
>    return lh;
>  }
> +
> +line_header_up
> +dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
> +                          dwarf2_per_objfile *per_objfile,
> +                          struct dwarf2_section_info *section,
> +                          const struct comp_unit_head *cu_header,
> +                          const char *comp_dir)
> +{
> +  struct objfile *objfile = per_objfile->objfile;
> +  struct dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
> +
> +  /* Read .debug_line.  */
> +  dwarf2_section_info *line_sec = &per_bfd->line;
> +  bfd_size_type line_size = line_sec->get_size (objfile);
> +
> +  gdb::array_view<const gdb_byte> line (line_sec->buffer, line_size);
> +
> +  /* Read .debug_line_str.  */
> +  dwarf2_section_info *line_str_sec = &per_bfd->line_str;
> +  bfd_size_type line_str_size = line_str_sec->get_size (objfile);
> +
> +  gdb::array_view<const gdb_byte> line_str (line_str_sec->buffer,
> +                                           line_str_size);
> +
> +  const gdb_byte *line_ptr = line.data () + to_underlying (sect_off);
> +
> +  return dwarf_decode_line_header
> +    (per_bfd->obfd, line, line_str, &line_ptr,
> +     is_dwz, cu_header, comp_dir);
> +}
> diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
> index c068dff70a3..45011882321 100644
> --- a/gdb/dwarf2/line-header.h
> +++ b/gdb/dwarf2/line-header.h
> @@ -217,4 +217,14 @@ extern line_header_up dwarf_decode_line_header
>     struct dwarf2_section_info *section, const struct comp_unit_head *cu_header,
>     const char *comp_dir);
>
> +/* Like above but the .debug_line and .debug_line_str are stored in
> +   LINE_DATA and LINE_STR_DATA.  *DEBUG_LINE_PTR should point to a
> +   statement program header within LINE_DATA.  */
> +
> +extern line_header_up dwarf_decode_line_header
> +  (bfd *abfd, gdb::array_view<const gdb_byte> line_data,
> +   gdb::array_view<const gdb_byte> line_str_data,
> +   const gdb_byte **debug_line_ptr, bool is_dwz,
> +  const comp_unit_head *cu_header, const char *comp_dir);
> +
>  #endif /* DWARF2_LINE_HEADER_H */
> diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
> index 97b8137aabf..c52099d5f6a 100644
> --- a/gdb/dwarf2/read-gdb-index.c
> +++ b/gdb/dwarf2/read-gdb-index.c
> @@ -131,6 +131,9 @@ struct mapped_gdb_index final : public mapped_index_base
>    }
>  };
>
> +struct mapped_debug_line;
> +typedef std::unique_ptr<mapped_debug_line> mapped_debug_line_up;
> +
>  struct dwarf2_gdb_index : public dwarf2_base_index_functions
>  {
>    /* This dumps minimal information about the index.
> @@ -160,6 +163,15 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions
>       block_search_flags search_flags,
>       domain_search_flags domain);
>
> +  /* If OBJFILE's debuginfo download has been deferred, use a mapped_debug_line
> +     to generate filenames.
> +
> +     Otherwise call dwarf2_base_index_functions::map_symbol_filenames.  */
> +
> +  void map_symbol_filenames (struct objfile *objfile,
> +                            gdb::function_view<symbol_filename_ftype> fun,
> +                            bool need_fullname) override;
> +
>    /* Calls dwarf2_base_index_functions::expand_all_symtabs and downloads
>       debuginfo if necessary.  */
>    void expand_all_symtabs (struct objfile *objfile) override;
> @@ -167,6 +179,15 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions
>    /* Calls dwarf2_base_index_functions::find_last_source_symtab and downloads
>       debuginfo if necessary.  */
>    struct symtab *find_last_source_symtab (struct objfile *objfile) override;
> +
> +  /* Filename information related to this .gdb_index.  */
> +  mapped_debug_line_up mdl;
> +
> +  /* Return true if any of the filenames in this .gdb_index's .debug_line
> +     mapping match FILE_MATCHER.  Initializes the mapping if necessary.  */
> +  bool filename_in_debug_line
> +    (objfile *objfile,
> +     gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher);
>  };
>
>  void
> @@ -202,6 +223,30 @@ dwarf2_gdb_index::find_last_source_symtab (struct objfile *objfile)
>      }
>  }
>
> +void
> +dwarf2_gdb_index::map_symbol_filenames
> +     (struct objfile *objfile,
> +      gdb::function_view<symbol_filename_ftype> fun,
> +      bool need_fullname)
> +{
> +  try
> +    {
> +      dwarf2_base_index_functions::map_symbol_filenames (objfile, fun,
> +                                                        need_fullname);
> +    }
> +  catch (const gdb_exception &e)
> +    {
> +      if ((objfile->flags & OBJF_DOWNLOAD_DEFERRED) == 0)
> +       exception_print (gdb_stderr, e);
> +      else
> +       {
> +         if (mdl == nullptr)
> +           mdl.reset (new mapped_debug_line (objfile));
> +         mdl->map_filenames (fun, need_fullname);
> +       }
> +    }
> +}
> +
>  /* This dumps minimal information about the index.
>     It is called via "mt print objfiles".
>     One use is to verify .gdb_index has been loaded by the
> @@ -365,6 +410,17 @@ dwarf2_gdb_index::do_expand_symtabs_matching
>    return result;
>  }
>
> +bool
> +dwarf2_gdb_index::filename_in_debug_line
> +  (objfile *objfile,
> +   gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher)
> +{
> +  if (mdl == nullptr)
> +    mdl.reset (new mapped_debug_line (objfile));
> +
> +  return mdl->contains_matching_filename (file_matcher);
> +}
> +
>  bool
>  dwarf2_gdb_index::expand_symtabs_matching
>      (struct objfile *objfile,
> @@ -392,6 +448,10 @@ dwarf2_gdb_index::expand_symtabs_matching
>           return false;
>         }
>
> +      if (file_matcher != nullptr
> +         && !filename_in_debug_line (objfile, file_matcher))
> +       return true;
> +
>        read_full_dwarf_from_debuginfod (objfile, this);
>        return true;
>      }
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 4461c76347e..ca219c9b910 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -81,6 +81,7 @@
>  #include <optional>
>  #include "gdbsupport/underlying.h"
>  #include "gdbsupport/hash_enum.h"
> +#include "gdbsupport/scoped_mmap.h"
>  #include "filename-seen-cache.h"
>  #include "producer.h"
>  #include <fcntl.h>
> @@ -1967,6 +1968,213 @@ dw2_get_file_names (dwarf2_per_cu_data *this_cu,
>    return this_cu->file_names;
>  }
>
> +#if !HAVE_SYS_MMAN_H
> +
> +bool
> +mapped_debug_line::contains_matching_filename
> +  (gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher)
> +{
> +  return false;
> +}
> +
> +gdb::array_view<const gdb_byte>
> +mapped_debug_line::read_debug_line_separate
> +  (const char *filename, std::unique_ptr<index_cache_resource> *resource)
> +{
> +  return {};
> +}
> +
> +bool
> +mapped_debug_line::read_debug_line_from_debuginfod (objfile *objfile)
> +{
> +  return false;
> +}
> +
> +void
> +mapped_debug_line::map_filenames
> +  (gdb::function_view<symbol_filename_ftype> fun,
> +   bool need_fullname)
> +{
> +  return;
> +}
> +
> +#else /* !HAVE_SYS_MMAN_H */
> +
> +struct line_resource_mmap final : public index_cache_resource
> +{
> +  /* Try to mmap FILENAME.  Throw an exception on failure, including if the
> +     file doesn't exist.  */
> +  line_resource_mmap (const char *filename)
> +    : mapping (mmap_file (filename))
> +  {}
> +
> +  scoped_mmap mapping;
> +};
> +
> +/* See read.h.  */
> +
> +bool
> +mapped_debug_line::contains_matching_filename
> +  (gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher)
> +{
> +  for (line_header_up &lh : line_headers)
> +    for (file_entry &fe : lh->file_names ())
> +      {
> +       const char *filename = fe.name;
> +
> +       if (file_matcher (fe.name, false))
> +         return true;
> +
> +       bool basename_match = file_matcher (lbasename (fe.name), true);
> +
> +       if (!basenames_may_differ && !basename_match)
> +         continue;
> +
> +       /* DW_AT_comp_dir is not explicitly mentioned in the .debug_line
> +          until DWARF5.  Since we don't have access to the CU at this
> +          point we just check for a partial match on the filename.
> +          If there is a match, the full debuginfo will be downloaded
> +          ane the match will be re-evalute with DW_AT_comp_dir.  */
> +       if (lh->version < 5 && fe.d_index == 0)
> +         return basename_match;
> +
> +       const char *dirname = fe.include_dir (&*lh);
> +       std::string fullname;
> +
> +       if (dirname == nullptr || IS_ABSOLUTE_PATH (filename))
> +         fullname = filename;
> +       else
> +         fullname = std::string (dirname) + SLASH_STRING + filename;
> +
> +       gdb::unique_xmalloc_ptr<char> rewritten
> +         = rewrite_source_path (fullname.c_str ());
> +       if (rewritten != nullptr)
> +         fullname = rewritten.release ();
> +
> +       if (file_matcher (fullname.c_str (), false))
> +         return true;
> +      }
> +
> +  return false;
> +}
> +
> +/* See read.h.  */
> +
> +void
> +mapped_debug_line::map_filenames
> +  (gdb::function_view<symbol_filename_ftype> fun,
> +   bool need_fullname)
> +{
> +  for (line_header_up &lh : line_headers)
> +    for (file_entry &fe : lh->file_names ())
> +      {
> +       const char *filename = fe.name;
> +
> +       if (!need_fullname)
> +         {
> +           fun (filename, nullptr);
> +           continue;
> +         }
> +
> +       const char *dirname = fe.include_dir (&*lh);
> +       std::string fullname;
> +
> +       if (dirname == nullptr || IS_ABSOLUTE_PATH (filename))
> +         fullname = filename;
> +       else
> +         fullname = std::string (dirname) + SLASH_STRING + filename;
> +
> +       gdb::unique_xmalloc_ptr<char> rewritten
> +         = rewrite_source_path (fullname.c_str ());
> +       if (rewritten != nullptr)
> +         fullname = rewritten.release ();
> +
> +       fun (filename, fullname.c_str ());
> +      }
> +}
> +
> +/* See read.h.  */
> +
> +gdb::array_view<const gdb_byte>
> +mapped_debug_line::read_debug_line_separate
> +  (const char *filename, std::unique_ptr<index_cache_resource> *resource)
> +{
> +  if (filename == nullptr)
> +    return {};
> +
> +  try
> +  {
> +    line_resource_mmap *mmap_resource
> +      = new line_resource_mmap (filename);
> +
> +    resource->reset (mmap_resource);
> +
> +    return gdb::array_view<const gdb_byte>
> +      ((const gdb_byte *) mmap_resource->mapping.get (),
> +       mmap_resource->mapping.size ());
> +  }
> +  catch (const gdb_exception &except)
> +  {
> +    exception_print (gdb_stderr, except);
> +  }
> +
> +  return {};
> +}
> +
> +/* See read.h.  */
> +
> +bool
> +mapped_debug_line::read_debug_line_from_debuginfod (objfile *objfile)
> +{
> +  const bfd_build_id *build_id = build_id_bfd_get (objfile->obfd.get ());
> +  if (build_id == nullptr)
> +    return false;
> +
> +  gdb::unique_xmalloc_ptr<char> line_path;
> +  scoped_fd line_fd = debuginfod_section_query (build_id->data,
> +                                               build_id->size,
> +                                               bfd_get_filename
> +                                                 (objfile->obfd.get ()),
> +                                               ".debug_line",
> +                                               &line_path);
> +
> +  if (line_fd.get () < 0)
> +    return false;
> +
> +  gdb::unique_xmalloc_ptr<char> line_str_path;
> +  scoped_fd line_str_fd = debuginfod_section_query (build_id->data,
> +                                                   build_id->size,
> +                                                   bfd_get_filename
> +                                                     (objfile->obfd.get ()),
> +                                                   ".debug_line_str",
> +                                                   &line_str_path);
> +
> +  line_data = read_debug_line_separate (line_path.get (), &line_resource);
> +  line_str_data = read_debug_line_separate (line_str_path.get (),
> +                                           &line_str_resource);
> +
> +  const gdb_byte *line_ptr = line_data.data ();
> +
> +  while (line_ptr < line_data.data () + line_data.size ())
> +    {
> +      line_header_up lh
> +       = dwarf_decode_line_header (objfile->obfd.get (),
> +                                   line_data, line_str_data,
> +                                   &line_ptr, false,
> +                                   nullptr, nullptr);
> +      line_headers.emplace_back (std::move (lh));
> +    }
> +
> +  return true;
> +}
> +#endif /* !HAVE_SYS_MMAN_H */
> +
> +mapped_debug_line::mapped_debug_line (objfile *objfile)
> +{
> +  if (!read_debug_line_from_debuginfod (objfile))
> +    line_headers.clear ();
> +}
> +
>  /* A helper for the "quick" functions which computes and caches the
>     real path for a given file name from the line table.  */
>
> diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
> index 099d3d65c27..19d19a6edc1 100644
> --- a/gdb/dwarf2/read.h
> +++ b/gdb/dwarf2/read.h
> @@ -33,6 +33,7 @@
>  #include "gdbsupport/hash_enum.h"
>  #include "gdbsupport/function-view.h"
>  #include "gdbsupport/packed.h"
> +#include "dwarf2/line-header.h"
>
>  /* Hold 'maintenance (set|show) dwarf' commands.  */
>  extern struct cmd_list_element *set_dwarf_cmdlist;
> @@ -942,4 +943,40 @@ extern htab_up create_quick_file_names_table (unsigned int nr_initial_entries);
>  extern void read_full_dwarf_from_debuginfod (struct objfile *,
>                                              dwarf2_base_index_functions *);
>
> +struct mapped_debug_line
> +{
> +  mapped_debug_line (objfile *objfile);
> +
> +  /* Return true if any of the mapped .debug_line's filenames match
> +     FILE_MATCHER.  */
> +
> +  bool contains_matching_filename
> +    (gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher);
> +
> +  /* Call FUN with each filename in this mapped .debug_line.  Include
> +     each file's fullname if NEED_FULLNAME is true.  */
> +
> +  void map_filenames (gdb::function_view<symbol_filename_ftype> fun,
> +                     bool need_fullname);
> +
> +private:
> +  std::vector<line_header_up> line_headers;
> +
> +  gdb::array_view<const gdb_byte> line_data;
> +  gdb::array_view<const gdb_byte> line_str_data;
> +
> +  std::unique_ptr<index_cache_resource> line_resource;
> +  std::unique_ptr<index_cache_resource> line_str_resource;
> +
> +  /* Download the .debug_line and .debug_line_str associated with OBJFILE
> +     and populate line_headers.  */
> +
> +  bool read_debug_line_from_debuginfod (objfile *objfile);
> +
> +  /* Initialize line_data and line_str_data with the .debug_line and
> +    .debug_line_str downloaded read_debug_line_from_debuginfod.  */
> +
> +  gdb::array_view<const gdb_byte> read_debug_line_separate
> +    (const char *filename, std::unique_ptr<index_cache_resource> *resource);
> +};
>  #endif /* DWARF2READ_H */
> diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
> index ff93d2cd448..8ad2c7f4497 100644
> --- a/gdb/mi/mi-out.c
> +++ b/gdb/mi/mi-out.c
> @@ -277,7 +277,14 @@ mi_ui_out::do_progress_notify (const std::string &msg, const char *unit,
>
>    if (info.state == progress_update::START)
>      {
> -      gdb_printf ("%s...\n", msg.c_str ());
> +      std::string prefix;
> +      if (cur_prefix_state == prefix_state_t::NEWLINE_NEEDED)
> +       {
> +         prefix = "\n";
> +         cur_prefix_state = prefix_state_t::NEWLINE_PRINTED;
> +       }
> +
> +      gdb_printf ("%s...\n", (prefix + msg).c_str ());
>        info.state = progress_update::WORKING;
>      }
>  }
> diff --git a/gdb/testsuite/gdb.debuginfod/section.exp b/gdb/testsuite/gdb.debuginfod/section.exp
> index 35086d15705..a9dad927696 100644
> --- a/gdb/testsuite/gdb.debuginfod/section.exp
> +++ b/gdb/testsuite/gdb.debuginfod/section.exp
> @@ -18,6 +18,7 @@
>  standard_testfile
>
>  load_lib debuginfod-support.exp
> +load_lib completion-support.exp
>
>  clean_restart
>  require allow_debuginfod_tests
> @@ -144,6 +145,32 @@ proc_with_prefix local_url { } {
>      # Hit the breakpoint.
>      set res ".*Breakpoint 2, libsection2_test.*\"In ${libfile2}\\\\n\".*"
>      gdb_test "c" $res "break continue"
> +
> +    clean_restart_with_prompt $binfile "line 1"
> +
> +    # List source file using .debug_line download.
> +    set res ".*\.debug_line.*$lib_sl1.*21.*extern void libsection2_test.*"
> +    gdb_test "list $libsrc1:21" $res "line 1 list"
> +
> +    clean_restart_with_prompt $binfile "line 2"
> +
> +    # Set breakpoint using .debug_line download.
> +    set res ".*section \.debug_line for $lib_sl1.*Breakpoint 2 at.*$libsrc1.*"
> +    gdb_test "br $libsrc1:41" $res "line 2 br"
> +
> +    # Continue to breakpoint.
> +    set res "Breakpoint 2, libsection1_test.*\"Cancelling thread\\\\n\".*"
> +    gdb_test "c" $res "line 2 continue"
> +
> +    # Check that download progress message is correctly formatted
> +    # when printing threads.
> +    set res ".*separate debug info for $lib_sl2\.\.\.\r\n.* 2    Thread.*"
> +    gdb_test "info thr" $res "line thread"
> +
> +    clean_restart_with_prompt $binfile "autocomplete"
> +
> +    # Download debuginfo during autocompletion.
> +    test_gdb_complete_tab_unique "br lib" ".*Downloading separate debug.*" ""
>  }
>
>  # Create CACHE and DB directories ready for debuginfod to use.
> diff --git a/gdb/ui-out.c b/gdb/ui-out.c
> index b3a2fb7f4e5..52d36d5bbf8 100644
> --- a/gdb/ui-out.c
> +++ b/gdb/ui-out.c
> @@ -31,6 +31,9 @@
>  #include <memory>
>  #include <string>
>
> +/* Current state of newline prefixing for progress update messages.  */
> +prefix_state_t cur_prefix_state = prefix_state_t::NEWLINE_OFF;
> +
>  namespace {
>
>  /* A header of a ui_out_table.  */
> diff --git a/gdb/ui-out.h b/gdb/ui-out.h
> index 5b6ddd55063..7e885cb1d38 100644
> --- a/gdb/ui-out.h
> +++ b/gdb/ui-out.h
> @@ -296,6 +296,21 @@ class ui_out
>        BAR
>      };
>
> +    /* Used to communicate the status of a newline prefix for the next progress
> +       update message.  */
> +    enum prefix_state
> +    {
> +      /* Do not modify the next progress update message.  */
> +      NEWLINE_OFF,
> +
> +      /* The next progress update message should include a newline prefix.  */
> +      NEWLINE_NEEDED,
> +
> +      /* A newline prefix was included in a debuginfod progress update
> +        message.  */
> +      NEWLINE_PRINTED
> +    };
> +
>      /* SHOULD_PRINT indicates whether something should be printed for a tty.  */
>      progress_update ()
>      {
> @@ -393,6 +408,11 @@ class ui_out
>    ui_out_level *current_level () const;
>  };
>
> +typedef ui_out::progress_update::prefix_state prefix_state_t;
> +
> +/* Current state of the newline prefix.  */
> +extern prefix_state_t cur_prefix_state;
> +
>  /* Start a new tuple or list on construction, and end it on
>     destruction.  Normally this is used via the typedefs
>     ui_out_emit_tuple and ui_out_emit_list.  */
> --
> 2.43.0
>


^ permalink raw reply	[relevance 0%]

* RE: [PATCHv7 7/9] gdb/gdbserver: share some code relating to target description creation
  @ 2024-05-17 11:59  4%     ` Willgerodt, Felix
  0 siblings, 0 replies; 200+ results
From: Willgerodt, Felix @ 2024-05-17 11:59 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches; +Cc: jhb

Hi Andrew,

I mainly have some nits and one actual remark (the x32 check).
Thanks again for doing this and sorry for taking a bit to review this.

Felix
 
> diff --git a/gdb/nat/x86-linux-tdesc.c b/gdb/nat/x86-linux-tdesc.c
> new file mode 100644
> index 00000000000..b065928f8ba
> --- /dev/null
> +++ b/gdb/nat/x86-linux-tdesc.c
> @@ -0,0 +1,129 @@
> +/* Target description related code for GNU/Linux x86 (i386 and x86-64).
> +
> +   Copyright (C) 2024 Free Software Foundation, Inc.
> +
> +   This file is part of GDB.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#include "nat/x86-linux-tdesc.h"
> +#ifdef __x86_64__
> +#include "arch/amd64.h"
> +#include "arch/amd64-linux-tdesc.h"
> +#endif
> +#include "arch/i386.h"
> +#include "arch/i386-linux-tdesc.h"
> +
> +#include "nat/x86-linux.h"
> +#include "nat/gdb_ptrace.h"
> +#include "nat/x86-xstate.h"
> +#include "gdbsupport/x86-xstate.h"
> +
> +#ifndef __x86_64__
> +#include <sys/procfs.h>
> +#include "nat/i386-linux.h"
> +#endif
> +
> +#include <sys/uio.h>
> +#include <elf.h>
> +
> +#ifndef IN_PROCESS_AGENT
> +
> +/* See nat/x86-linux-tdesc.h.  */
> +
> +const target_desc *
> +x86_linux_tdesc_for_tid (int tid, const char *error_msg,
> +			 uint64_t *xcr0_storage,
> +			 x86_xsave_layout *xsave_layout_storage)
> +{
> +#ifdef __x86_64__
> +

It looks weird to me that there is an empty line here but not for the others.

> +  x86_linux_arch_size arch_size = x86_linux_ptrace_get_arch_size (tid);
> +  bool is_64bit = arch_size.is_64bit ();
> +  bool is_x32 = arch_size.is_x32 ();
> +
> +  if (sizeof (void *) == 4 && is_64bit && !is_x32)
> +    error ("%s", error_msg);
> +
> +#elif HAVE_PTRACE_GETFPXREGS
> +  if (have_ptrace_getfpxregs == TRIBOOL_UNKNOWN)
> +    {
> +      elf_fpxregset_t fpxregs;
> +
> +      if (ptrace (PTRACE_GETFPXREGS, tid, 0, (int) &fpxregs) < 0)
> +	{
> +	  have_ptrace_getfpxregs = TRIBOOL_FALSE;
> +	  have_ptrace_getregset = TRIBOOL_FALSE;
> +	}
> +      else
> +	have_ptrace_getfpxregs = TRIBOOL_TRUE;
> +    }
> +
> +  if (have_ptrace_getfpxregs == TRIBOOL_FALSE)
> +    return i386_linux_read_description (X86_XSTATE_X87_MASK);
> +#endif
> +
> +  if (have_ptrace_getregset == TRIBOOL_UNKNOWN)
> +    {
> +      uint64_t xstateregs[(X86_XSTATE_SSE_SIZE / sizeof (uint64_t))];
> +      struct iovec iov;
> +
> +      iov.iov_base = xstateregs;
> +      iov.iov_len = sizeof (xstateregs);
> +
> +      /* Check if PTRACE_GETREGSET works.  */
> +      if (ptrace (PTRACE_GETREGSET, tid,
> +		  (unsigned int) NT_X86_XSTATE, &iov) < 0)
> +	{
> +	  have_ptrace_getregset = TRIBOOL_FALSE;
> +	  *xcr0_storage = 0;
> +	}
> +      else
> +	{
> +	  have_ptrace_getregset = TRIBOOL_TRUE;
> +
> +	  /* Get XCR0 from XSAVE extended state.  */
> +	  *xcr0_storage = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
> +				      / sizeof (uint64_t))];
> +
> +#ifdef __x86_64__
> +	  /* No MPX on x32.  */
> +	  if (is_64bit && is_x32)
> +	    *xcr0_storage &= ~X86_XSTATE_MPX;
> +#endif /* __x86_64__ */
> +
> +	  *xsave_layout_storage
> +	    = x86_fetch_xsave_layout (*xcr0_storage, x86_xsave_length ());
> +	}
> +    }
> +
> +  /* Check the native XCR0 only if PTRACE_GETREGSET is available.  If
> +     PTRACE_GETREGSET is not available then set xcr0_features_bits to
> +     zero so that the "no-features" descriptions are returned by the
> +     code below.  */
> +  uint64_t xcr0_features_bits;
> +  if (have_ptrace_getregset == TRIBOOL_TRUE)
> +    xcr0_features_bits = *xcr0_storage & X86_XSTATE_ALL_MASK;
> +  else
> +    xcr0_features_bits = 0;
> +
> +#ifdef __x86_64__
> +  if (is_64bit)
> +    return amd64_linux_read_description (xcr0_features_bits, is_x32);
> +  else
> +#endif
> +    return i386_linux_read_description (xcr0_features_bits);
> +}
> +
> +#endif /* !IN_PROCESS_AGENT */
> diff --git a/gdb/nat/x86-linux-tdesc.h b/gdb/nat/x86-linux-tdesc.h
> new file mode 100644
> index 00000000000..4035c49fc06
> --- /dev/null
> +++ b/gdb/nat/x86-linux-tdesc.h
> @@ -0,0 +1,54 @@
> +/* Target description related code for GNU/Linux x86 (i386 and x86-64).
> +
> +   Copyright (C) 2024 Free Software Foundation, Inc.
> +
> +   This file is part of GDB.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#ifndef NAT_X86_LINUX_TDESC_H
> +#define NAT_X86_LINUX_TDESC_H
> +
> +#include "gdbsupport/function-view.h"
> +
> +struct target_desc;
> +struct x86_xsave_layout;
> +
> +/* Return the target description for Linux thread TID.
> +
> +   The storage pointed to by XCR0_STORAGE AND XSAVE_LAYOUT_STORAGE
> must

s/AND/and

> +   exist until the program (GDB or gdbserver) terminates, this storage is
> +   used to cache the xcr0 and xsave layout values.  The values pointed to
> +   by these arguments are only updated at most once, the first time this
> +   function is called.
> +
> +   This function returns a target description based on the extracted xcr0
> +   value along with other characteristics of the thread identified by TID.
> +
> +   This function can return nullptr if we encounter a machine configuration
> +   for which a target_desc cannot be created.  Ideally this would not be
> +   the case, we should be able to create a target description for every
> +   possible machine configuration.  See amd64_linux_read_description and
> +   i386_linux_read_description for cases when nullptr might be
> +   returned.
> +
> +   ERROR_MSG is using in an error() call if we try to create a target
> +   description for a 64-bit process but this is a 32-bit build of GDB.  */
> +
> +extern const target_desc *
> +x86_linux_tdesc_for_tid (int tid, const char *error_msg,
> +			 uint64_t *xcr0_storage,
> +			 x86_xsave_layout *xsave_layout_storage);
> +
> +#endif /* NAT_X86_LINUX_TDESC_H */
> diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
> index ed76c1760bc..7c97f84ef56 100644
> --- a/gdb/x86-linux-nat.c
> +++ b/gdb/x86-linux-nat.c
> @@ -41,6 +41,7 @@
>  #include "nat/x86-linux.h"
>  #include "nat/x86-linux-dregs.h"
>  #include "nat/linux-ptrace.h"
> +#include "nat/x86-linux-tdesc.h"
> 
>  /* linux_nat_target::low_new_fork implementation.  */
> 
> @@ -95,93 +96,18 @@ x86_linux_nat_target::post_startup_inferior (ptid_t ptid)
>  const struct target_desc *
>  x86_linux_nat_target::read_description ()
>  {
> -  int tid;
> -  int is_64bit = 0;
> -#ifdef __x86_64__
> -  int is_x32;
> -#endif
> -  static uint64_t xcr0;
> -  uint64_t xcr0_features_bits;
> +  static uint64_t xcr0_storage;
> 
>    if (inferior_ptid == null_ptid)
>      return this->beneath ()->read_description ();
> 
> -  tid = inferior_ptid.pid ();
> -
> -#ifdef __x86_64__
> -
> -  x86_linux_arch_size arch_size = x86_linux_ptrace_get_arch_size (tid);
> -  is_64bit = arch_size.is_64bit ();
> -  is_x32 = arch_size.is_x32 ();
> -
> -  if (sizeof (void *) == 4 && is_64bit && !is_x32)
> -    error (_("Can't debug 64-bit process with 32-bit GDB"));
> -
> -#elif HAVE_PTRACE_GETFPXREGS
> -  if (have_ptrace_getfpxregs == TRIBOOL_UNKNOWN)
> -    {
> -      elf_fpxregset_t fpxregs;
> -
> -      if (ptrace (PTRACE_GETFPXREGS, tid, 0, (int) &fpxregs) < 0)
> -	{
> -	  have_ptrace_getfpxregs = TRIBOOL_FALSE;
> -	  have_ptrace_getregset = TRIBOOL_FALSE;
> -	  return i386_linux_read_description (X86_XSTATE_X87_MASK);
> -	}
> -    }
> -#endif
> -
> -  if (have_ptrace_getregset == TRIBOOL_UNKNOWN)
> -    {
> -      uint64_t xstateregs[(X86_XSTATE_SSE_SIZE / sizeof (uint64_t))];
> -      struct iovec iov;
> -
> -      iov.iov_base = xstateregs;
> -      iov.iov_len = sizeof (xstateregs);
> -
> -      /* Check if PTRACE_GETREGSET works.  */
> -      if (ptrace (PTRACE_GETREGSET, tid,
> -		  (unsigned int) NT_X86_XSTATE, &iov) < 0)
> -	have_ptrace_getregset = TRIBOOL_FALSE;
> -      else
> -	{
> -	  have_ptrace_getregset = TRIBOOL_TRUE;
> -
> -	  /* Get XCR0 from XSAVE extended state.  */
> -	  xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
> -			     / sizeof (uint64_t))];
> -
> -	  m_xsave_layout = x86_fetch_xsave_layout (xcr0, x86_xsave_length ());
> -	}
> -    }
> -
> -  /* Check the native XCR0 only if PTRACE_GETREGSET is available.  If
> -     PTRACE_GETREGSET is not available then set xcr0_features_bits to
> -     zero so that the "no-features" descriptions are returned by the
> -     switches below.  */
> -  if (have_ptrace_getregset == TRIBOOL_TRUE)
> -    xcr0_features_bits = xcr0 & X86_XSTATE_ALL_MASK;
> -  else
> -    xcr0_features_bits = 0;
> +  int tid = inferior_ptid.pid ();
> 
> -  if (is_64bit)
> -    {
> -#ifdef __x86_64__
> -      return amd64_linux_read_description (xcr0_features_bits, is_x32);
> -#endif
> -    }
> -  else
> -    {
> -      const struct target_desc * tdesc
> -	= i386_linux_read_description (xcr0_features_bits);
> -
> -      if (tdesc == NULL)
> -	tdesc = i386_linux_read_description (X86_XSTATE_SSE_MASK);
> -
> -      return tdesc;
> -    }
> +  const char *error_msg
> +    = _("Can't debug 64-bit process with 32-bit GDB");

In gdbserver we pass "Can't debug 64-bit process with 32-bit GDBserver".
One could argue that something common like
"Can't debug 64-bit process with 32-bit GDB/gdbserver" is good enough.
Then we could avoid the function argument. Though being more explicit
can also be viewed as helpful for the remote scenario.

(Maybe this is solved by another comment below).

> 
> -  gdb_assert_not_reached ("failed to return tdesc");
> +  return x86_linux_tdesc_for_tid (tid, error_msg, &xcr0_storage,
> +				  &this->m_xsave_layout);
>  }
> 
> 
> 
> 
> diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
> index 8e882d2159b..538845b96d5 100644
> --- a/gdbserver/configure.srv
> +++ b/gdbserver/configure.srv
> @@ -110,6 +110,7 @@ case "${gdbserver_host}" in
>  			srv_tgtobj="${srv_tgtobj} nat/x86-linux.o"
>  			srv_tgtobj="${srv_tgtobj} nat/x86-linux-dregs.o"
>  			srv_tgtobj="${srv_tgtobj} nat/i386-linux.o"
> +			srv_tgtobj="${srv_tgtobj} nat/x86-linux-tdesc.o"
>  			srv_linux_usrregs=yes
>  			srv_linux_regsets=yes
>  			srv_linux_thread_db=yes
> @@ -372,6 +373,7 @@ case "${gdbserver_host}" in
>  			srv_tgtobj="${srv_tgtobj} nat/linux-btrace.o"
>  			srv_tgtobj="${srv_tgtobj} nat/x86-linux.o"
>  			srv_tgtobj="${srv_tgtobj} nat/x86-linux-dregs.o"
> +			srv_tgtobj="${srv_tgtobj} nat/x86-linux-tdesc.o"
>  			srv_tgtobj="${srv_tgtobj} nat/amd64-linux-siginfo.o"
>  			srv_linux_usrregs=yes # This is for i386 progs.
>  			srv_linux_regsets=yes
> diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
> index 62cafd87204..4d8bcb5edfa 100644
> --- a/gdbserver/i387-fp.cc
> +++ b/gdbserver/i387-fp.cc
> @@ -21,7 +21,7 @@
>  #include "nat/x86-xstate.h"
> 
>  /* Default to SSE.  */
> -static unsigned long long x86_xcr0 = X86_XSTATE_SSE_MASK;
> +static uint64_t x86_xcr0 = X86_XSTATE_SSE_MASK;
> 
>  static const int num_mpx_bnd_registers = 4;
>  static const int num_mpx_cfg_registers = 2;
> @@ -944,9 +944,8 @@ i387_xsave_to_cache (struct regcache *regcache, const
> void *buf)
> 
>  /* See i387-fp.h.  */
> 
> -void
> -i387_set_xsave_mask (uint64_t xcr0, int len)
> +std::pair<uint64_t *, x86_xsave_layout *>
> +i387_get_xsave_storage ()
>  {
> -  x86_xcr0 = xcr0;
> -  xsave_layout = x86_fetch_xsave_layout (xcr0, len);
> +  return { &x86_xcr0, &xsave_layout };
>  }
> diff --git a/gdbserver/i387-fp.h b/gdbserver/i387-fp.h
> index 450466efb75..4ee21da8461 100644
> --- a/gdbserver/i387-fp.h
> +++ b/gdbserver/i387-fp.h
> @@ -19,6 +19,8 @@
>  #ifndef GDBSERVER_I387_FP_H
>  #define GDBSERVER_I387_FP_H
> 
> +struct x86_xsave_layout;

Do we really save much from not including the header and doing
a forward declaration? But I guess GDB is already super inconsistent
on that front.

> +
>  void i387_cache_to_fsave (struct regcache *regcache, void *buf);
>  void i387_fsave_to_cache (struct regcache *regcache, const void *buf);
> 
> @@ -30,6 +32,6 @@ void i387_xsave_to_cache (struct regcache *regcache,
> const void *buf);
> 
>  /* Set the XSAVE mask and fetch the XSAVE layout via CPUID.  */
> 
> -void i387_set_xsave_mask (uint64_t xcr0, int len);
> +std::pair<uint64_t *, x86_xsave_layout *> i387_get_xsave_storage ();
> 
>  #endif /* GDBSERVER_I387_FP_H */
> diff --git a/gdbserver/linux-amd64-ipa.cc b/gdbserver/linux-amd64-ipa.cc
> index a6346750f49..df5e6aca081 100644
> --- a/gdbserver/linux-amd64-ipa.cc
> +++ b/gdbserver/linux-amd64-ipa.cc
> @@ -22,6 +22,7 @@
>  #include "tracepoint.h"
>  #include "linux-x86-tdesc.h"
>  #include "gdbsupport/x86-xstate.h"
> +#include "arch/amd64-linux-tdesc.h"
> 
>  /* fast tracepoints collect registers.  */
> 
> diff --git a/gdbserver/linux-i386-ipa.cc b/gdbserver/linux-i386-ipa.cc
> index 8f14e0937d4..aa346fc9bc3 100644
> --- a/gdbserver/linux-i386-ipa.cc
> +++ b/gdbserver/linux-i386-ipa.cc
> @@ -22,6 +22,7 @@
>  #include "tracepoint.h"
>  #include "linux-x86-tdesc.h"
>  #include "gdbsupport/x86-xstate.h"
> +#include "arch/i386-linux-tdesc.h"
> 
>  /* GDB register numbers.  */
> 
> diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
> index 2d99a82f566..1c3d55f17fc 100644
> --- a/gdbserver/linux-x86-low.cc
> +++ b/gdbserver/linux-x86-low.cc
> @@ -29,10 +29,13 @@
> 
>  #ifdef __x86_64__
>  #include "nat/amd64-linux-siginfo.h"
> +#include "arch/amd64-linux-tdesc.h"
>  #else
>  #include "nat/i386-linux.h"
>  #endif
> 
> +#include "arch/i386-linux-tdesc.h"
> +
>  #include "gdb_proc_service.h"
>  /* Don't include elf/common.h if linux/elf.h got included by
>     gdb_proc_service.h.  */
> @@ -48,6 +51,7 @@
>  #include "nat/x86-linux.h"
>  #include "nat/x86-linux-dregs.h"
>  #include "linux-x86-tdesc.h"
> +#include "nat/x86-linux-tdesc.h"
> 
>  #ifdef __x86_64__
>  static target_desc_up tdesc_amd64_linux_no_xml;
> @@ -836,29 +840,12 @@ static int use_xml;
>  /* Get Linux/x86 target description from running target.  */
> 
>  static const struct target_desc *
> -x86_linux_read_description (void)
> +x86_linux_read_description ()
>  {
> -  unsigned int machine;
> -  int is_elf64;
> -  int xcr0_features;
> -  int tid;
> -  static uint64_t xcr0;
> -  static int xsave_len;
> -  struct regset_info *regset;
> -
> -  tid = lwpid_of (current_thread);
> +  int tid = lwpid_of (current_thread);
> 
> -  is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine);
> -
> -  if (sizeof (void *) == 4)
> -    {
> -      if (is_elf64 > 0)
> -       error (_("Can't debug 64-bit process with 32-bit GDBserver"));
> -#ifndef __x86_64__
> -      else if (machine == EM_X86_64)
> -       error (_("Can't debug x86-64 process with 32-bit GDBserver"));
> -#endif
> -    }
> +  const char *error_msg
> +    = _("Can't debug 64-bit process with 32-bit GDBserver");
> 
>    /* If we are not allowed to send an XML target description then we need
>       to use the hard-wired target descriptions.  This corresponds to GDB's
> @@ -868,103 +855,53 @@ x86_linux_read_description (void)
>       generate some alternative target descriptions.  */
>    if (!use_xml)
>      {
> +      x86_linux_arch_size arch_size = x86_linux_ptrace_get_arch_size (tid);
> +      bool is_64bit = arch_size.is_64bit ();
> +      bool is_x32 = arch_size.is_x32 ();
> +
> +      if (sizeof (void *) == 4 && is_64bit && !is_x32)
> +	error ("%s", error_msg);

I am stumbling a bit on these x32 checks. So, we do this check twice in code
now anyway? If we did this unconditionally here (and once in GDB code)
we could get rid of this check and the error_msg argument in
x86_linux_tdesc_for_tid(). And still have this code just twice.

Factoring it out into a separate function would also be something that comes
to mind, though it might be less easy to do, I didn't really check.

Or maybe I am missing something.

> +
>  #ifdef __x86_64__
> -      if (machine == EM_X86_64)
> +      if (is_64bit && !is_x32)
>  	return tdesc_amd64_linux_no_xml.get ();
>        else
>  #endif
>  	return tdesc_i386_linux_no_xml.get ();
>      }
> 
> -#if !defined __x86_64__ && defined HAVE_PTRACE_GETFPXREGS
> -  if (machine == EM_386 && have_ptrace_getfpxregs == TRIBOOL_UNKNOWN)
> -    {
> -      elf_fpxregset_t fpxregs;
> -
> -      if (ptrace (PTRACE_GETFPXREGS, tid, 0, (long) &fpxregs) < 0)
> -	{
> -	  have_ptrace_getfpxregs = TRIBOOL_FALSE;
> -	  have_ptrace_getregset = TRIBOOL_FALSE;
> -	  return i386_linux_read_description (X86_XSTATE_X87);
> -	}
> -      else
> -	have_ptrace_getfpxregs = TRIBOOL_TRUE;
> -    }
> -#endif
> -
> -  if (have_ptrace_getregset == TRIBOOL_UNKNOWN)
> -    {
> -      uint64_t xstateregs[(X86_XSTATE_SSE_SIZE / sizeof (uint64_t))];
> -      struct iovec iov;
> -
> -      iov.iov_base = xstateregs;
> -      iov.iov_len = sizeof (xstateregs);
> -
> -      /* Check if PTRACE_GETREGSET works.  */
> -      if (ptrace (PTRACE_GETREGSET, tid,
> -		  (unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
> -	have_ptrace_getregset = TRIBOOL_FALSE;
> -      else
> -	{
> -	  have_ptrace_getregset = TRIBOOL_TRUE;
> -
> -	  /* Get XCR0 from XSAVE extended state.  */
> -	  xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
> -			     / sizeof (uint64_t))];
> -
> -	  /* No MPX on x32.  */
> -	  if (machine == EM_X86_64 && !is_elf64)
> -	    xcr0 &= ~X86_XSTATE_MPX;
> -
> -	  xsave_len = x86_xsave_length ();
> -
> -	  /* Use PTRACE_GETREGSET if it is available.  */
> -	  for (regset = x86_regsets;
> -	       regset->fill_function != NULL; regset++)
> -	    if (regset->get_request == PTRACE_GETREGSET)
> -	      regset->size = xsave_len;
> -	    else if (regset->type != GENERAL_REGS)
> -	      regset->size = 0;
> -	}
> -    }
> -
> -  /* Check the native XCR0 only if PTRACE_GETREGSET is available.  */
> -  xcr0_features = (have_ptrace_getregset == TRIBOOL_TRUE
> -		   && (xcr0 & X86_XSTATE_ALL_MASK));
> +  /* If have_ptrace_getregset is changed to true by calling
> +     x86_linux_tdesc_for_tid then we will perform some additional
> +     initialisation.  */
> +  bool have_ptrace_getregset_is_unknown
> +    = have_ptrace_getregset == TRIBOOL_UNKNOWN;
> 
> -  if (xcr0_features)
> -    i387_set_xsave_mask (xcr0, xsave_len);
> +  /* Get pointers to where we should store the xcr0 and xsave_layout
> +     values.  These will be filled in by x86_linux_tdesc_for_tid the first
> +     time that the function is called.  Subsequent calls will not modify
> +     the stored values.  */
> +  std::pair<uint64_t *, x86_xsave_layout *> storage
> +    = i387_get_xsave_storage ();
> 
> -  if (machine == EM_X86_64)
> -    {
> -#ifdef __x86_64__
> -      const target_desc *tdesc = NULL;
> +  const target_desc *tdesc
> +    = x86_linux_tdesc_for_tid (tid, error_msg, storage.first, storage.second);
> 
> -      if (xcr0_features)
> -	{
> -	  tdesc = amd64_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK,
> -						!is_elf64);
> -	}
> -
> -      if (tdesc == NULL)
> -	tdesc = amd64_linux_read_description (X86_XSTATE_SSE_MASK,
> !is_elf64);
> -      return tdesc;
> -#endif
> -    }
> -  else
> +  if (have_ptrace_getregset_is_unknown
> +      && have_ptrace_getregset == TRIBOOL_TRUE)
>      {
> -      const target_desc *tdesc = NULL;
> -
> -      if (xcr0_features)
> -	  tdesc = i386_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK);
> -
> -      if (tdesc == NULL)
> -	tdesc = i386_linux_read_description (X86_XSTATE_SSE);
> -
> -      return tdesc;
> +      int xsave_len = x86_xsave_length ();
> +
> +      /* Use PTRACE_GETREGSET if it is available.  */
> +      for (regset_info *regset = x86_regsets;
> +	   regset->fill_function != nullptr;
> +	   regset++)
> +	if (regset->get_request == PTRACE_GETREGSET)
> +	  regset->size = xsave_len;
> +	else if (regset->type != GENERAL_REGS)
> +	  regset->size = 0;

I know you copied this, but doesn't this somehow go against our coding
standards? Not having braces for loops that have more then one line?
Though we don't have this particular case written down it seems, only for
if statements.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[relevance 4%]

* [PATCH 1/2] [gdb/macro] Ignore in-file macro definition with 0 line complaint for clang
@ 2024-05-17 10:47  6% Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-05-17 10:47 UTC (permalink / raw)
  To: gdb-patches

When showing complaints for the exec of test-case
gdb.dwarf2/clang-cli-macro.exp, we get:
...
$ gdb -q -batch -iex "set complaints 5" clang-cli-macro -ex "p main"
During symbol reading: \
  debug info gives in-file macro definition with zero line 0: ONE 1
$1 = {int ()} 0x4004b7 <main>
...

The readelf output for the .debug_macro section looks like:
...
Contents of the .debug_macro section:

  Offset:                      0
  Version:                     5
  Offset size:                 4
  Offset into .debug_line:     0xe3

 DW_MACRO_start_file - lineno: 0 filenum: 1
 DW_MACRO_define - lineno : 1 macro : TWO 2
 DW_MACRO_end_file
 DW_MACRO_define - lineno : 0 macro : ONE 1
...

The complaint is that the DW_MACRO_define for ONE both:
- has lineno 0, so it's predefined or specified on the command line, and
- occurs after the first DW_MACRO_start_file.

In commit e7e7469e7a3 ("gdb: Fix issue with Clang CLI macros") we've added a
workaround to accept this style of .debug_macro section, and
gdb.dwarf2/clang-cli-macro.exp is the test-case for the workaround.

Given that we've added the workaround, it doesn't make sense to complain.

The warning is produced using the following condition in
dwarf_decode_macro_bytes:
...
	    if ((line == 0 && !at_commandline)
		|| (line != 0 && at_commandline))
...
using the variable at_commandline which is initially 1, and set to 0 when
encountering the first DW_MACRO_start_file.

The value of this variable doesn't make sense in the context of a clang-style
.debug_macro section.

We could try to fix this by changing the value of the variable to fit with the
clang-style .debug_macro section, but I don't think it's worth the effort.

Simply fix this by for a clang producer opting out of all complaints in the
function that use the at_commandline variable in the condition.

Tested on x86_64-linux.
---
 gdb/dwarf2/macro.c                           | 10 ++++++----
 gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp |  6 ++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c
index a511d0a3b44..66a40e88d3a 100644
--- a/gdb/dwarf2/macro.c
+++ b/gdb/dwarf2/macro.c
@@ -546,8 +546,9 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
 			   line, body);
 		break;
 	      }
-	    if ((line == 0 && !at_commandline)
-		|| (line != 0 && at_commandline))
+	    if (((line == 0 && !at_commandline)
+		 || (line != 0 && at_commandline))
+		&& !producer_is_clang (cu))
 	      complaint (_("debug info gives %s macro %s with %s line %d: %s"),
 			 at_commandline ? _("command-line") : _("in-file"),
 			 is_define ? _("definition") : _("undefinition"),
@@ -648,8 +649,9 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
 	    file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 
-	    if ((line == 0 && !at_commandline)
-		|| (line != 0 && at_commandline))
+	    if (((line == 0 && !at_commandline)
+		 || (line != 0 && at_commandline))
+		&& !producer_is_clang (cu))
 	      complaint (_("debug info gives source %d included "
 			   "from %s at %s line %d"),
 			 file, at_commandline ? _("command-line") : _("file"),
diff --git a/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp b/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp
index eafb75ad8d9..fdeaaff5afd 100644
--- a/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp
+++ b/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp
@@ -85,6 +85,12 @@ if {[prepare_for_testing "failed to prepare" $testfile [list $srcfile $asm_file]
     return
 }
 
+set re_result "[string_to_regexp $]$decimal = \[^\r\n\]+"
+
+with_complaints 5 {
+    gdb_test "print main" ^$re_result "no complaints"
+}
+
 if {![runto_main]} {
     return
 }

base-commit: 44fc9616c2e74396395f60c9a601317e4c4c4733
-- 
2.35.3


^ permalink raw reply	[relevance 6%]

* Re: [PATCH v3 1/1] gdb, testsuite: Handle unused compiler option fdiagnostics-color=never.
  @ 2024-05-16 16:10  0% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-05-16 16:10 UTC (permalink / raw)
  To: Abdul Basit Ijaz
  Cc: gdb-patches, christina.schimpe, felix.willgerodt, keiths, tom

>>>>> Abdul Basit Ijaz <abdul.b.ijaz@intel.com> writes:

> The 'univeral_compile_options' in gdb.exp file only verifies the support
> of '-fdiagnostics-color=never' for the "C" source file.  So while running
> tests with assembly source file (.s), many of them are not able to run
> on icx/clang compilers because '-fdiagnostics-color=never' option is not
> supported.

Thank you.
Approved-By: Tom Tromey <tom@tromey.com>
Tom

^ permalink raw reply	[relevance 0%]

* Re: [PATCH 1/1 V5] gdb : Signal to pstack/gdb kills the attached process.
  @ 2024-05-16  7:15  5%     ` Partha Satapathy
  0 siblings, 0 replies; 200+ results
From: Partha Satapathy @ 2024-05-16  7:15 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches, rajesh.sivaramasubramaniom, bert.barbe,
	blarsen, cupertino.miranda

On 5/13/2024 8:19 PM, Pedro Alves wrote:
> Adding another question to the list below.  (I haven't tried to reproduce this yet myself, btw.)
> 
> On 2024-05-10 21:19, Pedro Alves wrote:
>> Hi.
>>
>> Just wanted to let you know that I've read all the discussion around this until this
>> email I'm replying to, and started thinking about it a bit.  Unfortunately this is one of
>> those areas in GDB where the right change is rarely immediately obvious (to me).
>>
>> Some questions:
>>
>>   - If you ctrl-c to abort the attach, do we really abort the
>>     attach properly?  Or do we stay attached in some half broken state?
>>
>>   - Below you mention pstack, where can we find it?  And you mention
>>     that ctrl-c is pressed while that is printing a stack.  I'm assuming
>>     that's a backtrace command.  I'm confused in that case, as if that is
>>     so, then we should already be past the initial attach.  The question
>>     would then becomes, shouldn't gdb have the terminal at that point?
>>     How come it does not?
> 
> #3 - The patch description states:
> 
>   > Problem: While gdb is attaching an inferior, if ctrl-c is pressed in the
>   > middle of the process attach,  the sigint is passed to the debugged
>   > process.  This triggers the exit of the inferior.
> 
> This SIGINT passing is done with "kill(-pgrp, SIGINT)".  How does that manage
> to trigger the exit of the inferior at all?  ptrace should intercept the
> SIGINT before the inferior ever sees it.  Did it not?
> 
> Or could it be that the real issue is that because that sends the SIGINT
> to all the processes in the inferior's pgrp, we kill more processes than
> the one we're attaching to, and those processes exiting cause the inferior
> to exit as well.  If so, then this is orthogonal to the initial attach,
> and can happen after the attach as well.  There is a bug open about this
> on bugzilla.
> 
> Pedro Alves
> 
>>
>> I'm wondering whether Baris's patch to eliminate the inferior
>> continuations would help with this, as it probably makes the attaching
>> sequence synchronous.  I should probably look at that one.
>>
>> Pedro Alves
>>


Thanks Pedro and Tom for reviewing the problem.


Problem :
pstack,  dumps the stack of all threads in a process. In some cases 
printing of stack can take significant time and ctrl-c is pressed to 
abort pstack/gdb application. This in turn kills the debugged process, 
which can be  critical for the system. In this case the intention of 
“ctrl+c” to kill pstack/gdb, but not the target application.


# tail pstack -n 12

# Run GDB, strip out unwanted noise.
# --readnever is no longer used since .gdb_index is now in use.
$GDB --quiet -nx $GDBARGS /proc/$1/exe $1 <<EOF 2>&1 |
set width 0
set height 0
set pagination no
$backtrace
EOF
/bin/sed -n \
     -e 's/^\((gdb) \)*//' \
     -e '/^#/p' \
     -e '/^Thread/p'


This is the interest part in the pstack, rest is cosmetic.

pstack uses:
# pstack 1

#0  0x00007fa18cf44017 in epoll_wait () from /lib64/libc.so.6
#1  0x00007fa18e67e036 in sd_event_wait () from 
/usr/lib/systemd/libsystemd-shared-239.so
#2  0x00007fa18e67f33b in sd_event_run () from 
/usr/lib/systemd/libsystemd-shared-239.so
#3  0x000055c155da8c22 in manager_loop ()
#4  0x000055c155d5f133 in main ()

Reproduction:

The debugged application generally attached to process by:
gdb -p <<pid>>
or gdb /proc/<<pid>>/exe pid
pstack uses the latter  method to attach the debugged to gdb. If the
application is large or process of reading symbols is slow, gives a good
window to press the ctrl+c during attach. Spawning "gdb" under "strace
-k" makes gdb a lot slower and gives a larger window to easily press the
ctrl+c at the precise period i.e. during the attach of the debugged
process. The above strace hack will enhance rate of reproduction of the
issue. Testcase:

With GDB 13.1
ps aux | grep abrtd
root     2195168   /usr/sbin/abrtd -d -s

#strace -k -o log gdb -p 2195168
Attaching to process 2195168
[New LWP 2195177]
[New LWP 2195179]
^C[Thread debugging using libthread_db enabled]
<<<<   Note the ctrl+c is pressed after attach is initiated and it’s
still reading the symbols from library >>>> Using host libthread_db
library "/lib64/libthread_db.so.1".
0x00007fe3ed6d70d1 in poll () from /lib64/libc.so.6
(gdb) q
A debugging session is active.
            Inferior 1 [process 2195168] will be detached Quit anyway? (y
or n) y Detaching from program: /usr/sbin/abrtd, process 2195168

# ps aux | grep 2195168
<<<< Process exited >>>>

This is having a very narrow window to press the ctrlc.
Session1 :

]$ ps aux | grep abrtd
root        1329  0.0  0.0 602624 13076 ?        Ssl  May03   0:00 
/usr/sbin/abrtd -d -s

Session2:

# ./tpstack 1329

+ strace -o omlog -k ./gdb --quiet -nx -ex 'set width 0' -ex 'set height 
0' -ex 'set pagination no' -ex 'set confirm off' -ex 'thread apply all 
bt' -ex quit /proc/1329/exe 1329
Reading symbols from /proc/1329/exe...
Python Exception <class 'AttributeError'>: module 'gdb' has no attribute 
'_handle_missing_debuginfo'
Reading symbols from .gnu_debugdata for /usr/sbin/abrtd...
(No debugging symbols found in .gnu_debugdata for /usr/sbin/abrtd)
Attaching to program: /proc/1329/exe, process 1329
[New LWP 1399]
[New LWP 1349] ^C

Session1:
[opc@pssatapa-ol8 TEST]$ ps aux | grep abrtd
<<<1329 Is killed >>>

This is a very small window, so a heavy application is good for 
reproduction. I modified the the last part of pstack like:
# Run GDB, strip out unwanted noise.
# --readnever is no longer used since .gdb_index is now in use.
strace -o omlog -k  ./gdb  --quiet -nx  -ex 'set width 0' -ex 'set 
height 0' -ex 'set pagination no' -ex 'set confirm off' -ex 'thread 
apply all bt' -ex quit  /proc/$1/exe $1

The strace with -k on gdb make gdb slow and we get a window to press 
Ctrl+c.  otherwise the window is very small to time the signal. We 
observe the problem while the FileStsyem or Kernel or proc FS is slow.

The signal is not intended to the inferior.
The signal is passed from "gdb" to the inferior.

The SIGINT handler in gdb, marks the QUIT flag and
in some paths we check the quit flag and pass the signal to inferior.
That is killing the inferior.

On :
+  check_quit_flag();
This should be set only when inf->attach_flag is true.
I will add the check in next iteration.
The idea here is to clear any pending QUIT flag set by sigint
else, post we set the sync_flag , a check to QUIT Flag
and can kill the inferior.

Thanks
Partha

^ permalink raw reply	[relevance 5%]

* [PATCH v3 0/1] gdb, testsuite: Handle unused compiler option fdiagnostics-color=never.
@ 2024-05-15 20:30  6% Abdul Basit Ijaz
  0 siblings, 0 replies; 200+ results
From: Abdul Basit Ijaz @ 2024-05-15 20:30 UTC (permalink / raw)
  To: gdb-patches
  Cc: abdul.b.ijaz, christina.schimpe, felix.willgerodt, keiths, tom

From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>

Hi All,

This patch updates the handling of '-fdiagnostics-color=never' in the
function 'univeral_compile_options' of gdb.exp file.  Before this change
it only verifies the support of '-fdiagnostics-color=never' for the "C"
source file.  So while running tests with assembly source file (.s), many
of them are not able to run on icx/clang compilers because
'-fdiagnostics-color=never' option is not supported.  After this change,
this function is split into multiple functions to check the support for
different type of sources individually.

Changes since V2:

* Added reason in the comment about handling the option only for Assembly
  source files ".s" type and not for ".S" type files.

V2 patch:
https://sourceware.org/pipermail/gdb-patches/2024-May/209178.html

V1 patch:
https://sourceware.org/pipermail/gdb-patches/2024-March/207477.html

Thanks & Best Regards
Abdul Basit

Ijaz, Abdul B (1):
  gdb, testsuite: Handle unused compiler option
    fdiagnostics-color=never.

 gdb/testsuite/lib/gdb.exp | 54 +++++++++++++++++++++++++++++++--------
 1 file changed, 44 insertions(+), 10 deletions(-)

-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 6%]

* [PATCH^5] gdb: mips: Add MIPSR6 support
@ 2024-05-15 20:19  2% Milos Kalicanin
  0 siblings, 0 replies; 200+ results
From: Milos Kalicanin @ 2024-05-15 20:19 UTC (permalink / raw)
  To: gdb-patches
  Cc: Djordje Todorovic, Dragan Mladjenovic, Andrew Burgess,
	Simon Marchi, Maciej W . Rozycki, Chao-ying Fu

Introduce new instruction encodings from Release 6 of the MIPS
architecture [1]. Support breakpoints and single stepping with
compact branches, forbidden slots, new branch instruction and
new atomic load-store instruction encodings.

Changes from v4: Apply code formatting as Andrew Burgess suggested.

[1] "MIPS64 Architecture for Programmers Volume II-A: The MIPS64
    Instruction Set Reference Manual", Document Number: MD00087,
    Revision 6.06, December 15, 2016, Section 3 "The MIPS64
    Instruction Set", pp. 42-530
https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00087-2B-MIPS64BIS-AFP-6.06.pdf

2024-05-15
Andrew Bennett  <andrew.bennett@imgtec.com>
Matthew Fortune  <matthew.fortune@mips.com>
Faraz Shahbazker  <fshahbazker@wavecomp.com>

gdb/ChangeLog:
	* mips-tdep.c (is_mipsr6_isa): New.
	(b0s21_imm): New define.
	(mips32_relative_offset21, mips32_relative_offset26): New.
	(is_add32bit_overflow, is_add64bit_overflow): New.
	(mips32_next_pc): Handle r6 compact and fpu coprocessor branches.
	Move handling of BLEZ, BGTZ opcode into ...
	(mips32_blez_pc): New.
	(mips32_instruction_is_compact_branch): New.
	(mips32_insn_at_pc_has_forbidden_slot):  New.
	(mips32_scan_prologue): Ignore pre-r6 addi encoding on r6.
	Stop at compact branch also.
	(LLSC_R6_OPCODE,LL_R6_FUNCT,LLE_FUNCT,
	LLD_R6_FUNCT,SC_R6_FUNCT,SCE_FUNCT,
	SCD_R6_FUNCT: New defines.
	(is_ll_insn, is_sc_insn): New.
	(mips_deal_with_atomic_sequence): Use is_ll_insn/is_sc_insn.
	Handle compact branches.
	(mips_about_to_return): Handle jrc and macro jr.
	(mips32_stack_frame_destroyed_p): Likewise.
	(mips32_instruction_has_delay_slot): Don't handle JALX on r6.
	Handle compact branches and coprocessor branches.
	(mips_adjust_breakpoint_address): Skip forbidden slot for
	compact branches.
---
 gdb/mips-tdep.c                       | 532 +++++++++++++--
 gdb/testsuite/gdb.arch/mips-64-r6.c   | 918 ++++++++++++++++++++++++++
 gdb/testsuite/gdb.arch/mips-64-r6.exp |  76 +++
 3 files changed, 1483 insertions(+), 43 deletions(-)
 create mode 100644 gdb/testsuite/gdb.arch/mips-64-r6.c
 create mode 100644 gdb/testsuite/gdb.arch/mips-64-r6.exp

diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index ae58d7c8720..bdaeb6a8999 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -76,6 +76,10 @@ static int mips16_insn_at_pc_has_delay_slot (struct gdbarch *gdbarch,
 static void mips_print_float_info (struct gdbarch *, struct ui_file *,
 				   const frame_info_ptr &, const char *);
 
+static void
+mips_read_fp_register_single (const frame_info_ptr &frame, int regno,
+			      gdb_byte *rare_buffer);
+
 /* A useful bit in the CP0 status register (MIPS_PS_REGNUM).  */
 /* This bit is set if we are emulating 32-bit FPRs on a 64-bit chip.  */
 #define ST0_FR (1 << 26)
@@ -325,6 +329,16 @@ mips_abi_regsize (struct gdbarch *gdbarch)
     }
 }
 
+/* Return true if the gdbarch is based on MIPS Release 6.  */
+static bool
+is_mipsr6_isa (struct gdbarch *gdbarch)
+{
+  const struct bfd_arch_info *info = gdbarch_bfd_arch_info (gdbarch);
+
+  return (info->mach == bfd_mach_mipsisa32r6
+	  || info->mach == bfd_mach_mipsisa64r6);
+}
+
 /* MIPS16/microMIPS function addresses are odd (bit 0 is set).  Here
    are some functions to handle addresses associated with compressed
    code including but not limited to testing, setting, or clearing
@@ -1500,6 +1514,7 @@ mips_fetch_instruction (struct gdbarch *gdbarch,
   return extract_unsigned_integer (buf, instlen, byte_order);
 }
 
+
 /* These are the fields of 32 bit mips instructions.  */
 #define mips32_op(x) (x >> 26)
 #define itype_op(x) (x >> 26)
@@ -1542,6 +1557,7 @@ mips_fetch_instruction (struct gdbarch *gdbarch,
 #define b0s11_op(x) ((x) & 0x7ff)
 #define b0s12_imm(x) ((x) & 0xfff)
 #define b0s16_imm(x) ((x) & 0xffff)
+#define b0s21_imm(x) ((x) & 0x1fffff)
 #define b0s26_imm(x) ((x) & 0x3ffffff)
 #define b6s10_ext(x) (((x) >> 6) & 0x3ff)
 #define b11s5_reg(x) (((x) >> 11) & 0x1f)
@@ -1578,6 +1594,18 @@ mips32_relative_offset (ULONGEST inst)
   return ((itype_immediate (inst) ^ 0x8000) - 0x8000) << 2;
 }
 
+static LONGEST
+mips32_relative_offset21 (ULONGEST insn)
+{
+  return ((b0s21_imm (insn) ^ 0x100000) - 0x100000) << 2;
+}
+
+static LONGEST
+mips32_relative_offset26 (ULONGEST insn)
+{
+  return ((b0s26_imm (insn) ^ 0x2000000) - 0x2000000) << 2;
+}
+
 /* Determine the address of the next instruction executed after the INST
    floating condition branch instruction at PC.  COUNT specifies the
    number of the floating condition bits tested by the branch.  */
@@ -1636,6 +1664,71 @@ is_octeon_bbit_op (int op, struct gdbarch *gdbarch)
   return 0;
 }
 
+static int
+is_add32bit_overflow (int32_t a, int32_t b)
+{
+  int32_t r = (uint32_t) a + (uint32_t) b;
+  return (a < 0 && b < 0 && r >= 0) || (a >= 0 && b >= 0 && r < 0);
+}
+
+static int
+is_add64bit_overflow (int64_t a, int64_t b)
+{
+  if (a != (int32_t)a)
+    return 1;
+  if (b != (int32_t)b)
+    return 1;
+  return is_add32bit_overflow ((int32_t)a, (int32_t)b);
+}
+
+/* Calculate address of next instruction after BLEZ.  */
+
+static CORE_ADDR
+mips32_blez_pc (struct gdbarch *gdbarch, struct regcache *regcache,
+		ULONGEST inst, CORE_ADDR pc, int invert)
+{
+  int rs = itype_rs (inst);
+  int rt = itype_rt (inst);
+  LONGEST val_rs = regcache_raw_get_signed (regcache, rs);
+  LONGEST val_rt = regcache_raw_get_signed (regcache, rt);
+  ULONGEST uval_rs = regcache_raw_get_unsigned (regcache, rs);
+  ULONGEST uval_rt = regcache_raw_get_unsigned (regcache, rt);
+  int taken = 0;
+  int delay_slot_size = 4;
+
+  /* BLEZ, BLEZL, BGTZ, BGTZL  */
+  if (rt == 0)
+    taken = (val_rs <= 0);
+  else if (is_mipsr6_isa (gdbarch))
+    {
+      /* BLEZALC, BGTZALC  */
+      if (rs == 0 && rt != 0)
+	taken = (val_rt <= 0);
+      /* BGEZALC, BLTZALC  */
+      else if (rs == rt && rt != 0)
+	taken = (val_rt >= 0);
+      /* BGEUC, BLTUC  */
+      else if (rs != rt && rs != 0 && rt != 0)
+	taken = (uval_rs >= uval_rt);
+
+      /* Step through the forbidden slot to avoid repeated exceptions we do
+	 not currently have access to the BD bit when hitting a breakpoint
+	 and therefore cannot tell if the breakpoint hit on the branch or the
+	 forbidden slot.  */
+      /* delay_slot_size = 0;  */
+    }
+
+  if (invert)
+    taken = !taken;
+
+  /* Calculate branch target.  */
+  if (taken)
+    pc += mips32_relative_offset (inst);
+  else
+    pc += delay_slot_size;
+
+  return pc;
+}
 
 /* Determine where to set a single step breakpoint while considering
    branch prediction.  */
@@ -1646,12 +1739,17 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR pc)
   struct gdbarch *gdbarch = regcache->arch ();
   unsigned long inst;
   int op;
+  int mips64bitreg = 0;
+
+  if (mips_isa_regsize (gdbarch) == 8)
+    mips64bitreg = 1;
+
   inst = mips_fetch_instruction (gdbarch, ISA_MIPS, pc, NULL);
   op = itype_op (inst);
   if ((inst & 0xe0000000) != 0)		/* Not a special, jump or branch
 					   instruction.  */
     {
-      if (op >> 2 == 5)
+      if (op >> 2 == 5 && ((op & 0x02) == 0 || itype_rt (inst) == 0))
 	/* BEQL, BNEL, BLEZL, BGTZL: bits 0101xx */
 	{
 	  switch (op & 0x03)
@@ -1661,7 +1759,7 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR pc)
 	    case 1:		/* BNEL */
 	      goto neq_branch;
 	    case 2:		/* BLEZL */
-	      goto less_branch;
+	      goto lez_branch;
 	    case 3:		/* BGTZL */
 	      goto greater_branch;
 	    default:
@@ -1671,15 +1769,19 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR pc)
       else if (op == 17 && itype_rs (inst) == 8)
 	/* BC1F, BC1FL, BC1T, BC1TL: 010001 01000 */
 	pc = mips32_bc1_pc (gdbarch, regcache, inst, pc + 4, 1);
-      else if (op == 17 && itype_rs (inst) == 9
+      else if (!is_mipsr6_isa (gdbarch)
+	       && op == 17
+	       && itype_rs (inst) == 9
 	       && (itype_rt (inst) & 2) == 0)
 	/* BC1ANY2F, BC1ANY2T: 010001 01001 xxx0x */
 	pc = mips32_bc1_pc (gdbarch, regcache, inst, pc + 4, 2);
-      else if (op == 17 && itype_rs (inst) == 10
+      else if (!is_mipsr6_isa (gdbarch)
+	       && op == 17
+	       && itype_rs (inst) == 10
 	       && (itype_rt (inst) & 2) == 0)
 	/* BC1ANY4F, BC1ANY4T: 010001 01010 xxx0x */
 	pc = mips32_bc1_pc (gdbarch, regcache, inst, pc + 4, 4);
-      else if (op == 29)
+      else if (!is_mipsr6_isa (gdbarch) && op == 29)
 	/* JALX: 011101 */
 	/* The new PC will be alternate mode.  */
 	{
@@ -1707,7 +1809,128 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR pc)
 	  else
 	    pc += 8;        /* After the delay slot.  */
 	}
+      else if (is_mipsr6_isa (gdbarch))
+	{
+	  /* BOVC, BEQZALC, BEQC and BNVC, BNEZALC, BNEC  */
+	  if (op == 8 || op == 24)
+	    {
+	      int rs = rtype_rs (inst);
+	      int rt = rtype_rt (inst);
+	      LONGEST val_rs = regcache_raw_get_signed (regcache, rs);
+	      LONGEST val_rt = regcache_raw_get_signed (regcache, rt);
+	      int taken = 0;
+	      /* BOVC (BNVC)  */
+	      if (rs >= rt)
+		{
+		  if (mips64bitreg == 1)
+		    taken = is_add64bit_overflow (val_rs, val_rt);
+		  else
+		    taken = is_add32bit_overflow (val_rs, val_rt);
+		}
+	      /* BEQZALC (BNEZALC)  */
+	      else if (rs < rt && rs == 0)
+		taken = (val_rt == 0);
+	      /* BEQC (BNEC)  */
+	      else
+		taken = (val_rs == val_rt);
+
+	      /* BNVC, BNEZALC, BNEC  */
+	      if (op == 24)
+		taken = !taken;
 
+	      if (taken)
+		pc += mips32_relative_offset (inst) + 4;
+	      else
+		/* Step through the forbidden slot to avoid repeated exceptions
+		   we do not currently have access to the BD bit when hitting a
+		   breakpoint and therefore cannot tell if the breakpoint
+		   hit on the branch or the forbidden slot.  */
+		pc += 8;
+	    }
+	  /* BC1EQZ, BC1NEZ  */
+	  else if (op == 17 && (itype_rs (inst) == 9 || itype_rs (inst) == 13))
+	    {
+	      gdb_byte status;
+	      gdb_byte true_val = 0;
+	      unsigned int fp = (gdbarch_num_regs (gdbarch)
+				 + mips_regnum (gdbarch)->fp0
+				 + itype_rt (inst));
+	      struct frame_info_ptr frame = get_current_frame ();
+	      gdb_byte *raw_buffer = (gdb_byte *) alloca (sizeof (gdb_byte) * 4);
+	      mips_read_fp_register_single (frame, fp, raw_buffer);
+
+	      if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+		status = *(raw_buffer + 3);
+	      else
+		status = *(raw_buffer);
+
+	      if (itype_rs (inst) == 13)
+		true_val = 1;
+
+	      if ((status & 0x1) == true_val)
+		pc += mips32_relative_offset (inst) + 4;
+	      else
+		pc += 8;
+	    }
+	  else if (op == 22 || op == 23)
+	  /* BLEZC, BGEZC, BGEC, BGTZC, BLTZC, BLTC  */
+	    {
+	      int rs = rtype_rs (inst);
+	      int rt = rtype_rt (inst);
+	      LONGEST val_rs = regcache_raw_get_signed (regcache, rs);
+	      LONGEST val_rt = regcache_raw_get_signed (regcache, rt);
+	      int taken = 0;
+	      /* The R5 rt == 0 case is handled above so we treat it as
+		 an unknown instruction here for future ISA usage.  */
+	      if (rs == 0 && rt != 0)
+		taken = (val_rt <= 0);
+	      else if (rs == rt && rt != 0)
+		taken = (val_rt >= 0);
+	      else if (rs != rt && rs != 0 && rt != 0)
+		taken = (val_rs >= val_rt);
+
+	      if (op == 23)
+		taken = !taken;
+
+	      if (taken)
+		pc += mips32_relative_offset (inst) + 4;
+	      else
+		/* Step through the forbidden slot to avoid repeated exceptions
+		   we do not currently have access to the BD bit when hitting a
+		   breakpoint and therefore cannot tell if the breakpoint
+		   hit on the branch or the forbidden slot.  */
+		pc += 8;
+	    }
+	  else if (op == 50 || op == 58)
+	  /* BC, BALC  */
+	    pc += mips32_relative_offset26 (inst) + 4;
+	  else if ((op == 54 || op == 62)
+		   && rtype_rs (inst) == 0)
+	  /* JIC, JIALC  */
+	    {
+	      pc = regcache_raw_get_signed (regcache, itype_rt (inst));
+	      pc += (itype_immediate (inst) ^ 0x8000) - 0x8000;
+	    }
+	  else if (op == 54 || op == 62)
+	  /* BEQZC, BNEZC  */
+	    {
+	      int rs = itype_rs (inst);
+	      LONGEST rs_val = regcache_raw_get_signed (regcache, rs);
+	      int taken = (rs_val == 0);
+	      if (op == 62)
+		taken = !taken;
+	      if (taken)
+		pc += mips32_relative_offset21 (inst) + 4;
+	      else
+		/* Step through the forbidden slot to avoid repeated exceptions
+		   we do not currently have access to the BD bit when hitting a
+		   breakpoint and therefore cannot tell if the breakpoint
+		   hit on the branch or the forbidden slot.  */
+		pc += 8;
+	    }
+	  else
+	    pc += 4;		/* Not a branch, next instruction is easy.  */
+	}
       else
 	pc += 4;		/* Not a branch, next instruction is easy.  */
     }
@@ -1751,7 +1974,6 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR pc)
 	      case 2:		/* BLTZL */
 	      case 16:		/* BLTZAL */
 	      case 18:		/* BLTZALL */
-	      less_branch:
 		if (regcache_raw_get_signed (regcache, itype_rs (inst)) < 0)
 		  pc += mips32_relative_offset (inst) + 4;
 		else
@@ -1767,22 +1989,38 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR pc)
 		  pc += 8;	/* after the delay slot */
 		break;
 	      case 0x1c:	/* BPOSGE32 */
+	      case 0x1d:	/* BPOSGE32C  */
 	      case 0x1e:	/* BPOSGE64 */
 		pc += 4;
 		if (itype_rs (inst) == 0)
 		  {
 		    unsigned int pos = (op & 2) ? 64 : 32;
 		    int dspctl = mips_regnum (gdbarch)->dspctl;
+		    int delay_slot_size = 4;
 
 		    if (dspctl == -1)
 		      /* No way to handle; it'll most likely trap anyway.  */
 		      break;
 
+		    /* BPOSGE32C  */
+		    if (op == 0x1d)
+		      {
+			if (!is_mipsr6_isa (gdbarch))
+			  break;
+
+			/* Step through the forbidden slot to avoid repeated
+			   exceptions we do not currently have access to the BD
+			   bit when hitting a breakpoint and therefore cannot
+			   tell if the breakpoint hit on the branch or the
+			   forbidden slot.  */
+			/* delay_slot_size = 0;  */
+		      }
+
 		    if ((regcache_raw_get_unsigned (regcache,
 						    dspctl) & 0x7f) >= pos)
 		      pc += mips32_relative_offset (inst);
 		    else
-		      pc += 4;
+		      pc += delay_slot_size;
 		  }
 		break;
 		/* All of the other instructions in the REGIMM category */
@@ -1816,19 +2054,14 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR pc)
 	  else
 	    pc += 8;
 	  break;
-	case 6:		/* BLEZ, BLEZL */
-	  if (regcache_raw_get_signed (regcache, itype_rs (inst)) <= 0)
-	    pc += mips32_relative_offset (inst) + 4;
-	  else
-	    pc += 8;
+	case 6:		/* BLEZ, BLEZL, BLEZALC, BGEZALC, BGEUC  */
+	lez_branch:
+	  pc = mips32_blez_pc (gdbarch, regcache, inst, pc + 4, 0);
 	  break;
 	case 7:
 	default:
-	greater_branch:	/* BGTZ, BGTZL */
-	  if (regcache_raw_get_signed (regcache, itype_rs (inst)) > 0)
-	    pc += mips32_relative_offset (inst) + 4;
-	  else
-	    pc += 8;
+	greater_branch:	/* BGTZ, BGTZL, BGTZALC, BLTZALC, BLTUC  */
+	  pc = mips32_blez_pc (gdbarch, regcache, inst, pc + 4, 1);
 	  break;
 	}			/* switch */
     }				/* else */
@@ -2451,6 +2684,72 @@ micromips_instruction_is_compact_branch (unsigned short insn)
     }
 }
 
+/* Return non-zero if the MIPS instruction INSN is a compact branch
+   or jump.  A value of 1 indicates an unconditional compact branch
+   and a value of 2 indicates a conditional compact branch.  */
+
+static int
+mips32_instruction_is_compact_branch (struct gdbarch *gdbarch, ULONGEST insn)
+{
+  switch (itype_op (insn))
+    {
+    /* BC  */
+    case 50:
+    /* BALC  */
+    case 58:
+      if (is_mipsr6_isa (gdbarch))
+	return 1;
+      break;
+    /* BOVC, BEQZALC, BEQC  */
+    case 8:
+    /* BNVC, BNEZALC, BNEC  */
+    case 24:
+      if (is_mipsr6_isa (gdbarch))
+	return 2;
+      break;
+    /* BEQZC, JIC  */
+    case 54:
+    /* BNEZC, JIALC  */
+    case 62:
+      if (is_mipsr6_isa (gdbarch))
+	/* JIC, JIALC are unconditional  */
+	return (itype_rs (insn) == 0) ? 1 : 2;
+      break;
+    /* BLEZC, BGEZC, BGEC  */
+    case 22:
+    /* BGTZC, BLTZC, BLTC  */
+    case 23:
+    /* BLEZALC, BGEZALC, BGEUC  */
+    case 6:
+    /* BGTZALC, BLTZALC, BLTUC  */
+    case 7:
+      if (is_mipsr6_isa (gdbarch)
+	  && itype_rt (insn) != 0)
+	return 2;
+      break;
+    /* BPOSGE32C  */
+    case 1:
+      if (is_mipsr6_isa (gdbarch)
+	  && itype_rt (insn) == 0x1d && itype_rs (insn) == 0)
+	return 2;
+    }
+  return 0;
+}
+
+/* Return true if a standard MIPS instruction at ADDR has a branch
+   forbidden slot (i.e. it is a conditional compact branch instruction).  */
+
+static bool
+mips32_insn_at_pc_has_forbidden_slot (struct gdbarch *gdbarch, CORE_ADDR addr)
+{
+  int status;
+  ULONGEST insn = mips_fetch_instruction (gdbarch, ISA_MIPS, addr, &status);
+  if (status)
+    return false;
+
+  return mips32_instruction_is_compact_branch (gdbarch, insn) == 2;
+}
+
 struct mips_frame_cache
 {
   CORE_ADDR base;
@@ -3494,7 +3793,8 @@ mips32_scan_prologue (struct gdbarch *gdbarch,
       reg = high_word & 0x1f;
 
       if (high_word == 0x27bd		/* addiu $sp,$sp,-i */
-	  || high_word == 0x23bd	/* addi $sp,$sp,-i */
+	  || (high_word == 0x23bd	/* addi $sp,$sp,-i  */
+	      && !is_mipsr6_isa (gdbarch))
 	  || high_word == 0x67bd)	/* daddiu $sp,$sp,-i */
 	{
 	  if (offset < 0)		/* Negative stack adjustment?  */
@@ -3632,7 +3932,9 @@ mips32_scan_prologue (struct gdbarch *gdbarch,
 
       /* A jump or branch, or enough non-prologue insns seen?  If so,
 	 then we must have reached the end of the prologue by now.  */
-      if (prev_delay_slot || non_prologue_insns > 1)
+      if (prev_delay_slot
+	  || non_prologue_insns > 1
+	  || mips32_instruction_is_compact_branch (gdbarch, inst))
 	break;
 
       prev_non_prologue_insn = this_non_prologue_insn;
@@ -3938,6 +4240,67 @@ mips_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
 #define LLD_OPCODE 0x34
 #define SC_OPCODE 0x38
 #define SCD_OPCODE 0x3c
+#define LLSC_R6_OPCODE 0x1f
+#define LL_R6_FUNCT 0x36
+#define LLE_FUNCT 0x2e
+#define LLD_R6_FUNCT 0x37
+#define SC_R6_FUNCT 0x26
+#define SCE_FUNCT 0x1e
+#define SCD_R6_FUNCT 0x27
+
+/* Determine whether instruction 'insn' is of 'load linked X' type.
+   LL/SC instructions provide primitives to implement atomic 
+   read-modify-write operations for synchronizable memory locations.  */
+
+static bool
+is_ll_insn (struct gdbarch *gdbarch, ULONGEST insn)
+{
+  if (itype_op (insn) == LL_OPCODE
+      || itype_op (insn) == LLD_OPCODE)
+    return true;
+
+  if (rtype_op (insn) == LLSC_R6_OPCODE
+      && rtype_funct (insn) == LLE_FUNCT
+      && (insn & 0x40) == 0)
+    return true;
+
+  /* Handle LL and LLP varieties.  */
+  if (is_mipsr6_isa (gdbarch)
+      && rtype_op (insn) == LLSC_R6_OPCODE
+      && (rtype_funct (insn) == LL_R6_FUNCT
+	  || rtype_funct (insn) == LLD_R6_FUNCT
+	  || rtype_funct (insn) == LLE_FUNCT))
+    return true;
+
+  return false;
+}
+
+/* Determine whether instruction 'insn' is of 'store conditional X' type.
+   SC instructions and varieties perform completion of read-modify-write
+   atomic sequence.  */
+
+static bool
+is_sc_insn (struct gdbarch *gdbarch, ULONGEST insn)
+{
+  if (itype_op (insn) == SC_OPCODE
+      || itype_op (insn) == SCD_OPCODE)
+    return true;
+
+  if (rtype_op (insn) == LLSC_R6_OPCODE
+      && rtype_funct (insn) == SCE_FUNCT
+      && (insn & 0x40) == 0)
+    return true;
+
+  /* Handle SC and SCP varieties.  */
+  if (is_mipsr6_isa (gdbarch)
+      && rtype_op (insn) == LLSC_R6_OPCODE
+      && (rtype_funct (insn) == SC_R6_FUNCT
+	  || rtype_funct (insn) == SCD_R6_FUNCT
+	  || rtype_funct (insn) == SCE_FUNCT))
+    return true;
+
+  return false;
+}
 
 static std::vector<CORE_ADDR>
 mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
@@ -3950,10 +4313,11 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
   int index;
   int last_breakpoint = 0; /* Defaults to 0 (no breakpoints placed).  */  
   const int atomic_sequence_length = 16; /* Instruction sequence length.  */
+  bool is_mipsr6 = is_mipsr6_isa (gdbarch);
 
   insn = mips_fetch_instruction (gdbarch, ISA_MIPS, loc, NULL);
   /* Assume all atomic sequences start with a ll/lld instruction.  */
-  if (itype_op (insn) != LL_OPCODE && itype_op (insn) != LLD_OPCODE)
+  if (!is_ll_insn (gdbarch, insn))
     return {};
 
   /* Assume that no atomic sequence is longer than "atomic_sequence_length" 
@@ -3983,28 +4347,72 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
 	  return {}; /* fallback to the standard single-step code.  */
 	case 4: /* BEQ */
 	case 5: /* BNE */
-	case 6: /* BLEZ */
-	case 7: /* BGTZ */
 	case 20: /* BEQL */
 	case 21: /* BNEL */
-	case 22: /* BLEZL */
-	case 23: /* BGTTL */
+	case 22: /* BLEZL (BLEZC, BGEZC, BGEC)  */
+	case 23: /* BGTZL (BGTZC, BLTZC, BLTC)  */
 	  is_branch = 1;
 	  break;
+	case 6: /* BLEZ (BLEZALC, BGEZALC, BGEUC)  */
+	case 7: /* BGTZ (BGTZALC, BLTZALC, BLTUC)  */
+	  if (is_mipsr6)
+	    {
+	      /* BLEZALC, BGTZALC  */
+	      if (itype_rs (insn) == 0 && itype_rt (insn) != 0)
+		return {}; /* fallback to the standard single-step code.  */
+	      /* BGEZALC, BLTZALC  */
+	      else if (itype_rs (insn) == itype_rt (insn)
+		       && itype_rt (insn) != 0)
+		return {}; /* fallback to the standard single-step code.  */
+	    }
+	  is_branch = 1;
+	  break;
+	case 8: /* BOVC, BEQZALC, BEQC  */
+	case 24: /* BNVC, BNEZALC, BNEC  */
+	  if (is_mipsr6)
+	    is_branch = 1;
+	  break;
+	case 50: /* BC  */
+	case 58: /* BALC  */
+	  if (is_mipsr6)
+	    return {}; /* fallback to the standard single-step code.  */
+	  break;
+	case 54: /* BEQZC, JIC  */
+	case 62: /* BNEZC, JIALC  */
+	  if (is_mipsr6)
+	    {
+	      if (itype_rs (insn) == 0) /* JIC, JIALC  */
+		return {}; /* fallback to the standard single-step code.  */
+	      else
+		is_branch = 2; /* Marker for branches with a 21-bit offset.  */
+	    }
+	  break;
 	case 17: /* COP1 */
-	  is_branch = ((itype_rs (insn) == 9 || itype_rs (insn) == 10)
-		       && (itype_rt (insn) & 0x2) == 0);
-	  if (is_branch) /* BC1ANY2F, BC1ANY2T, BC1ANY4F, BC1ANY4T */
+	  is_branch = ((!is_mipsr6
+			/* BC1ANY2F, BC1ANY2T, BC1ANY4F, BC1ANY4T  */
+			&& (itype_rs (insn) == 9 || itype_rs (insn) == 10)
+			&& (itype_rt (insn) & 0x2) == 0)
+		       /* BZ.df:  010001 110xx  */
+		       || (itype_rs (insn) & 0x18) == 0x18);
+	  if (is_branch != 0)
 	    break;
 	  [[fallthrough]];
 	case 18: /* COP2 */
 	case 19: /* COP3 */
-	  is_branch = (itype_rs (insn) == 8); /* BCzF, BCzFL, BCzT, BCzTL */
+	  /* BCzF, BCzFL, BCzT, BCzTL, BC*EQZ, BC*NEZ  */
+	  is_branch = ((itype_rs (insn) == 8)
+		       || (is_mipsr6
+			   && (itype_rs (insn) == 9
+			       || itype_rs (insn) == 13)));
 	  break;
 	}
-      if (is_branch)
+      if (is_branch != 0)
 	{
-	  branch_bp = loc + mips32_relative_offset (insn) + 4;
+	  /* Is this a special PC21_S2 branch?  */
+	  if (is_branch == 2)
+	    branch_bp = loc + mips32_relative_offset21 (insn) + 4;
+	  else
+	    branch_bp = loc + mips32_relative_offset (insn) + 4;
 	  if (last_breakpoint >= 1)
 	    return {}; /* More than one branch found, fallback to the
 			  standard single-step code.  */
@@ -4012,12 +4420,12 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
 	  last_breakpoint++;
 	}
 
-      if (itype_op (insn) == SC_OPCODE || itype_op (insn) == SCD_OPCODE)
+      if (is_sc_insn (gdbarch, insn))
 	break;
     }
 
   /* Assume that the atomic sequence ends with a sc/scd instruction.  */
-  if (itype_op (insn) != SC_OPCODE && itype_op (insn) != SCD_OPCODE)
+  if (!is_sc_insn (gdbarch, insn))
     return {};
 
   loc += MIPS_INSN32_SIZE;
@@ -4166,7 +4574,7 @@ micromips_deal_with_atomic_sequence (struct gdbarch *gdbarch,
 	    }
 	  break;
 	}
-      if (is_branch)
+      if (is_branch != 0)
 	{
 	  if (last_breakpoint >= 1)
 	    return {}; /* More than one branch found, fallback to the
@@ -4242,8 +4650,14 @@ mips_about_to_return (struct gdbarch *gdbarch, CORE_ADDR pc)
   gdb_assert (mips_pc_is_mips (pc));
 
   insn = mips_fetch_instruction (gdbarch, ISA_MIPS, pc, NULL);
-  hint = 0x7c0;
-  return (insn & ~hint) == 0x3e00008;			/* jr(.hb) $ra */
+  /* Mask the hint and the jalr/jr bit.  */
+  hint = 0x7c1;
+
+  if (is_mipsr6_isa (gdbarch) && insn == 0xd81f0000) /* jrc $31  */
+    return 1;
+
+  /* jr(.hb) $ra and "jalr(.hb) $ra"  */
+  return ((insn & ~hint) == 0x3e00008);
 }
 
 
@@ -6760,7 +7174,9 @@ mips32_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 
 	  if (high_word != 0x27bd	/* addiu $sp,$sp,offset */
 	      && high_word != 0x67bd	/* daddiu $sp,$sp,offset */
-	      && inst != 0x03e00008	/* jr $ra */
+	      && (inst & ~0x1) != 0x03e00008 /* jr $31 or jalr $0, $31  */
+	      && (!is_mipsr6_isa (gdbarch)
+		  || inst != 0xd81f0000) /* jrc $31  */
 	      && inst != 0x00000000)	/* nop */
 	    return 0;
 	}
@@ -7139,22 +7555,31 @@ mips32_instruction_has_delay_slot (struct gdbarch *gdbarch, ULONGEST inst)
   int op;
   int rs;
   int rt;
+  bool is_mipsr6 = is_mipsr6_isa (gdbarch);
 
   op = itype_op (inst);
   if ((inst & 0xe0000000) != 0)
     {
       rs = itype_rs (inst);
       rt = itype_rt (inst);
-      return (is_octeon_bbit_op (op, gdbarch) 
-	      || op >> 2 == 5	/* BEQL, BNEL, BLEZL, BGTZL: bits 0101xx  */
-	      || op == 29	/* JALX: bits 011101  */
+      return (is_octeon_bbit_op (op, gdbarch)
+	      || (op >> 1 == 10) /* BEQL, BNEL: bits 01010x  */
+	      || (op >> 1 == 11 && rt == 0) /* BLEZL, BGTZL: bits 01011x  */
+	      || (!is_mipsr6 && op == 29)	/* JALX: bits 011101  */
 	      || (op == 17
 		  && (rs == 8
 				/* BC1F, BC1FL, BC1T, BC1TL: 010001 01000  */
-		      || (rs == 9 && (rt & 0x2) == 0)
+		      || (!is_mipsr6 && rs == 9 && (rt & 0x2) == 0)
 				/* BC1ANY2F, BC1ANY2T: bits 010001 01001  */
-		      || (rs == 10 && (rt & 0x2) == 0))));
+		      || (!is_mipsr6 && rs == 10 && (rt & 0x2) == 0)))
 				/* BC1ANY4F, BC1ANY4T: bits 010001 01010  */
+	      || (is_mipsr6
+		  && ((op == 17
+		       && (rs == 9  /* BC1EQZ: 010001 01001  */
+			   || rs == 13))  /* BC1NEZ: 010001 01101  */
+		      || (op == 18
+			  && (rs == 9  /* BC2EQZ: 010010 01001  */
+			      || rs == 13)))));  /* BC2NEZ: 010010 01101  */
     }
   else
     switch (op & 0x07)		/* extract bits 28,27,26  */
@@ -7173,7 +7598,11 @@ mips32_instruction_has_delay_slot (struct gdbarch *gdbarch, ULONGEST inst)
 		|| ((rt & 0x1e) == 0x1c && rs == 0));
 				/* BPOSGE32, BPOSGE64: bits 1110x  */
 	break;			/* end REGIMM  */
-      default:			/* J, JAL, BEQ, BNE, BLEZ, BGTZ  */
+	case 6:			/* BLEZ  */
+	case 7:			/* BGTZ  */
+	 return (itype_rt (inst) == 0);
+	 break;
+      default:			/* J, JAL, BEQ, BNE  */
 	return 1;
 	break;
       }
@@ -7385,7 +7814,18 @@ mips_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
 
      So, we'll use the second solution.  To do this we need to know if
      the instruction we're trying to set the breakpoint on is in the
-     branch delay slot.  */
+     branch delay slot.
+
+     A similar problem occurs for breakpoints on forbidden slots where
+     the trap will be reported for the branch with the BD bit set.
+     In this case it would be ideal to recover using solution 1 from
+     above as there is no problem with the branch being skipped
+     (since the forbidden slot only exists on not-taken branches).
+     However, the BD bit is not available in all scenarios currently
+     so instead we move the breakpoint on to the next instruction.
+     This means that it is not possible to stop on an instruction
+     that can be in a forbidden slot even if that instruction is
+     jumped to directly.  */
 
   boundary = mips_segment_boundary (bpaddr);
 
@@ -7407,6 +7847,12 @@ mips_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
       prev_addr = bpaddr - 4;
       if (mips32_insn_at_pc_has_delay_slot (gdbarch, prev_addr))
 	bpaddr = prev_addr;
+      /* If the previous instruction has a forbidden slot, we have to
+	 move the breakpoint to the following instruction to prevent
+	 breakpoints in forbidden slots being reported as unknown
+	 traps.  */
+      else if (mips32_insn_at_pc_has_forbidden_slot (gdbarch, prev_addr))
+	bpaddr += 4;
     }
   else
     {
diff --git a/gdb/testsuite/gdb.arch/mips-64-r6.c b/gdb/testsuite/gdb.arch/mips-64-r6.c
new file mode 100644
index 00000000000..13f43ee24d0
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/mips-64-r6.c
@@ -0,0 +1,918 @@
+/*
+   Copyright 2023-2024 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+/* ============ macros from sim/testutils/mips/utils-r6.inc ============= */
+
+/* 58 is local label to exit with errcode != 0, indicating error.  */
+#define fp_assert(a, b) "beq " xstr (a) ", " xstr (b) ", 1f \n\t" \
+  "nop \n\t" \
+  "b 58f \n\t" \
+  "nop \n\t" \
+  "1: \n\t"
+
+/* Clobbers: $4,$6,$7.  */
+#define r6ck_1r(inst, a, ret) \
+  "li $4, " xstr (a) "    \n\t" \
+  "li $6, " xstr (ret) "  \n\t" \
+  xstr (inst) " $7, $4    \n\t" \
+  fp_assert ($6, $7)
+
+/* Clobbers: $4,$6,$7.  */
+#define r6ck_1dr(inst, a, ret) \
+  "ld $4, " xstr (a) "   \n\t" \
+  "ld $6, " xstr (ret) " \n\t" \
+  xstr (inst) " $7, $4   \n\t" \
+  fp_assert ($6, $7)
+
+/* Clobbers: $4,$5,$6,$7.  */
+#define r6ck_2r(inst, a, b, ret) \
+  "li $4, " xstr (a) "   \n\t" \
+  "li $5, " xstr (b) "   \n\t" \
+  "li $6, " xstr (ret) " \n\t" \
+  xstr (inst) " $7, $4, $5   \n\t" \
+  fp_assert ($6, $7)
+
+/* Clobbers: $4,$5,$6,$7.  */
+#define r6ck_2dr(inst, a, b, ret) \
+  "ld $4, " xstr (a) "    \n\t" \
+  "ld $5, " xstr (b) "    \n\t" \
+  "ld $6, " xstr (ret) "  \n\t" \
+  xstr (inst) " $7, $4, $5  \n\t" \
+  fp_assert ($6, $7)
+
+/* Clobbers: $4,$5,$6,$7.  */
+#define r6ck_2dr1i(inst, a, b, imm, ret) \
+  "ld $4, " xstr (a) "      \n\t" \
+  "ld $5, " xstr (b) "      \n\t" \
+  "ld $6, " xstr (ret) "    \n\t" \
+  xstr (inst) " $7, $4, $5, " xstr (imm) "  \n\t" \
+  fp_assert ($6, $7)
+
+/* Clobbers: $4,$6,$7.  */
+#define r6ck_1r1i(inst, a, imm, ret) \
+  "li $4, " xstr (a) "      \n\t" \
+  "li $6, " xstr (ret) "    \n\t" \
+  xstr (inst) " $7, $4, " xstr (imm) "  \n\t" \
+  fp_assert ($6, $7)
+
+/* Clobbers: $4,$6,$7.  */
+#define r6ck_1dr1i(inst, a, imm, ret) \
+  "ld $4, " xstr (a) "     \n\t" \
+  "ld $6, " xstr (ret) "   \n\t" \
+  xstr (inst) " $7, $4, " xstr (imm) "  \n\t" \
+  fp_assert ($6, $7)
+
+/* Clobbers: $4,$6.  */
+#define r6ck_0dr1i(inst, a, imm, ret) \
+  "ld $4, " xstr (a) "     \n\t" \
+  "ld $6, " xstr (ret) "   \n\t" \
+  xstr (inst) " $4, $4, " xstr (imm) "   \n\t" \
+  fp_assert ($6, $4)
+
+/* Clobbers: $4,$5,$6,$7.  */
+#define r6ck_2r1i(inst, a, b, imm, ret) \
+  "li $4, " xstr (a) "     \n\t" \
+  "li $5, " xstr (b) "     \n\t" \
+  "li $6, " xstr (ret) "   \n\t" \
+  xstr (inst) " $7, $4, $5, " xstr (imm) "   \n\t" \
+  fp_assert ($6, $7)
+
+/* Clobbers: $4,$5,$6,$7,$8,$f2,$f4,$f6.  */
+#define r6ck_3s(inst, a, b, c, ret) \
+  "li $4, " xstr (a) "     \n\t" \
+  "li $5, " xstr (b) "     \n\t" \
+  "li $6, " xstr (c) "     \n\t" \
+  "li $7, " xstr (ret) "   \n\t" \
+  "mtc1 $4, $f2           \n\t" \
+  "mtc1 $5, $f4           \n\t" \
+  "mtc1 $6, $f6           \n\t" \
+  xstr (inst) " $f2, $f4, $f6       \n\t" \
+  "mfc1 $8, $f2           \n\t" \
+  fp_assert ($7, $8)
+
+/* Clobbers: $4,$5,$6,$7,$f2,$f4.  */
+#define r6ck_2s(inst, a, b, ret) \
+  "li $4, " xstr (a) "       \n\t" \
+  "li $5, " xstr (b) "       \n\t" \
+  "li $6, " xstr (ret) "     \n\t" \
+  "mtc1 $4, $f2             \n\t" \
+  "mtc1 $5, $f4             \n\t" \
+  xstr (inst) " $f2, $f4     \n\t" \
+  "mfc1 $7, $f2             \n\t" \
+  fp_assert ($6, $7)
+
+/* Clobbers: $4,$5,$6,$7,$8,$9,$10,$f2,$f4.  */
+#define r6ck_2d(inst, a, b, ret) \
+  ".data                  \n\t" \
+  "1: .dword " xstr (a) "    \n\t" \
+  "2: .dword " xstr (b) "    \n\t" \
+  "3: .dword " xstr (ret) "  \n\t" \
+  ".text                   \n\t" \
+  "dla $4, 1b              \n\t" \
+  "dla $5, 2b              \n\t" \
+  "dla $6, 3b              \n\t" \
+  "ldc1 $f2, 0($4)        \n\t" \
+  "ldc1 $f4, 0($5)        \n\t" \
+  "lw $7, 0($6)           \n\t" \
+  "lw $8, 4($6)           \n\t" \
+  xstr (inst) " $f2, $f4   \n\t" \
+  "mfhc1 $9, $f2          \n\t" \
+  "mfc1 $10, $f2          \n\t" \
+  fp_assert ($7, $9) \
+  fp_assert ($8, $10)
+
+/* Clobbers: $2,$4,$5,$6,$7,$8,$9,$10,$f2,$f4,$f6.  */
+#define r6ck_3d(inst, a, b, c, ret) \
+  ".data                                \n\t" \
+  "1: .dword " xstr (a) "                  \n\t" \
+  "2: .dword " xstr (b) "                  \n\t" \
+  "3: .dword " xstr (c) "                  \n\t" \
+  "4: .dword " xstr (ret) "                \n\t" \
+  ".text                                \n\t" \
+  "dla $4, 1b                            \n\t" \
+  "dla $5, 2b                            \n\t" \
+  "dla $6, 3b                            \n\t" \
+  "dla $2, 4b                            \n\t" \
+  "ldc1 $f2, 0($4)                      \n\t" \
+  "ldc1 $f4, 0($5)                      \n\t" \
+  "ldc1 $f6, 0($6)                      \n\t" \
+  "lw $7, 0($2)                         \n\t" \
+  "lw $8, 4($2)                         \n\t" \
+  xstr (inst) " $f2, $f4, $f6            \n\t" \
+  "mfhc1 $9, $f2                        \n\t" \
+  "mfc1 $10, $f2                        \n\t" \
+  fp_assert ($7, $9) \
+  fp_assert ($8, $10)
+
+
+/* ============ macros from sim/testutils/mips/testutils.inc ============= */
+
+/* Put value 'val' into register 'reg'.
+   Clobbers: None.  */
+#define load32(reg, val) \
+  "li  " xstr (reg) ", " xstr (val) "     \n\t"
+
+/* Check whether two registers contain the same value.
+   Clobbers: None.  */
+#define checkreg(reg, expreg) \
+  ".set push         \n\t" \
+  ".set noat         \n\t" \
+  ".set noreorder    \n\t" \
+  "beq "  xstr (expreg) ", " xstr (reg) ", 901f    \n\t" \
+  "nop               \n\t" \
+  "b 58f              \n\t" \
+  "nop                \n\t" \
+  "901:                   \n\t" \
+  ".set pop           \n\t"
+
+/* Check if register 'reg' contains value 'val'.
+   Clobbers: $1.  */
+#define check32(reg, val) \
+  ".set push         \n\t" \
+  ".set noat         \n\t" \
+  load32 ($1, val) \
+  checkreg (reg, $1) \
+  ".set pop          \n\t"
+
+/* Checkpair based on endianess
+   Clobbers: $1.  */
+#define checkpair_xendian(lo, hi, base, ec, w) \
+  ".set noat               \n\t" \
+  "lw   $1, " xstr (ec) "   \n\t" \
+  "andi $1, $1, 0x1        \n\t" \
+  "beqz  $1, 2f            \n\t" \
+  ".set at                 \n\t" \
+  "1:                          \n\t" \
+  checkpair_be_##w (lo, hi, base) \
+  "b 3f                    \n\t" \
+  "nop                     \n\t" \
+  "2:                          \n\t" \
+  checkpair_le_##w (lo, hi, base) \
+  "3:                          \n\t"
+
+
+/* Check hi-lo register pair against data stored at base+o1 and base+o2.
+   Clobbers: $1 - $5.  */
+#define  checkpair(lo, hi, base, w, o1, o2) \
+  "move  $2, " xstr (lo) "   \n\t" \
+  "move  $3, " xstr (hi) "   \n\t" \
+  ".set noat                \n\t" \
+  "dla   $1, " xstr (base) "  \n\t" \
+  "l" xstr (w) " $4, " xstr (o1) "($1)  \n\t" \
+  "l" xstr (w)  " $5, " xstr (o2) "($1)  \n\t" \
+  ".set at                  \n\t" \
+  checkreg ($2, $4) \
+  checkreg ($3, $5)
+
+#define checkpair_le_d(lo, hi, base) \
+  checkpair (lo, hi, base, w, 0, 4)
+
+#define checkpair_be_d(lo, hi, base) \
+  checkpair (lo, hi, base, w, 4, 0)
+
+
+#define checkpair_le_q(lo, hi, base) \
+  checkpair (lo, hi, base, d, 0, 8)
+
+#define checkpair_be_q(lo, hi, base) \
+  checkpair (lo, hi, base, d, 8, 0)
+
+#define checkpair_qword(lo, hi, base, oe) \
+  checkpair_xendian (lo, hi, base, oe, q)
+
+#define checkpair_dword(lo, hi, base, oe) \
+  checkpair_xendian (lo, hi, base, oe, d)
+
+void
+abort (void);
+
+/* Tests branch instructions.  */
+
+int
+test_r6_branch (void)
+{
+/* Using volatile to prevent certain optimizations which could cause
+ * instruction deletion.
+ * 'err' identifies instruction which (eventually) caused error.
+ * (err == 0) ==> all instructions executed successfully.  */
+
+  volatile int err = -1;
+  volatile int a14 = 0xffffffff;
+  volatile int a13 = 0x123;
+  volatile int a12 = 0x45;
+  volatile int a7 = 0x45;
+  volatile int a8 = 0xfffffffe;
+  volatile int a9 = 2147483647;
+  volatile int a11 = 0;
+  volatile int a10 = 0;
+
+  asm (
+  ".set push             \n\t" /* Create new scope for asm configuration.  */
+  ".set noreorder        \n\t" /* Don't allow reordering of instructions.  */
+  "li %[err], 1                  \n\t"
+  "bovc %[a12], %[a13], Lfail    \n\t" /* BOVC */
+  "nop                           \n\t"
+  "bovc %[a9], %[a13], L2        \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L2:                           \n\t"
+  "li %[err], 2                  \n\t"
+  "bnvc %[a9], %[a13], Lfail     \n\t" /* BNVC */
+  "nop                           \n\t"
+  "bnvc %[a12], %[a13], L3       \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L3:                           \n\t"
+  "li %[err], 3                  \n\t"
+  "beqc %[a12], %[a13], Lfail    \n\t" /* BEQC */
+  "nop                           \n\t"
+  "beqc %[a12], %[a7], L4        \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L4:                           \n\t"
+  "li %[err], 4                  \n\t"
+  "bnec %[a12], %[a7], Lfail     \n\t" /* BNEC */
+  "nop                           \n\t"
+  "bnec %[a12], %[a13], L5       \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L5:                           \n\t"
+  "li %[err], 5                  \n\t"
+  "bltc %[a13], %[a12], Lfail    \n\t" /* BLTC */
+  "nop                           \n\t"
+  "bltc %[a12], %[a13], L6       \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L6:                           \n\t"
+  "L7:                           \n\t"
+  "li %[err], 7                  \n\t"
+  "bgec %[a12], %[a13], Lfail    \n\t" /* BGEC */
+  "nop                           \n\t"
+  "bgec %[a13], %[a12], L8       \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L8:                           \n\t"
+  "L9:                           \n\t"
+  "li %[err], 9                  \n\t"
+  "bltuc %[a14], %[a13], Lfail   \n\t" /* BLTUC */
+  "nop                           \n\t"
+  "bltuc %[a8], %[a14], L10      \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L10:                          \n\t"
+  "L11:                          \n\t"
+  "li %[err], 11                 \n\t"
+  "bgeuc %[a13], %[a14], Lfail   \n\t" /* BGEUC */
+  "nop                           \n\t"
+  "bgeuc %[a14], %[a8], L12      \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L12:                          \n\t"
+  "L13:                          \n\t"
+  "li %[err], 13                 \n\t"
+  "bltzc %[a13], Lfail           \n\t" /* BLTZC */
+  "nop                           \n\t"
+  "bltzc %[a11], Lfail           \n\t"
+  "nop                           \n\t"
+  "bltzc %[a14], L14             \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L14:                          \n\t"
+  "li %[err], 14                 \n\t"
+  "blezc %[a13], Lfail           \n\t" /* BLEZC */
+  "nop                           \n\t"
+  "blezc %[a11], L145            \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L145:                         \n\t"
+  "blezc %[a14], L15             \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L15:                          \n\t"
+  "li %[err], 15                 \n\t"
+  "bgezc %[a8], Lfail            \n\t" /* BGEZC */
+  "nop                           \n\t"
+  "bgezc %[a11], L155            \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L155:                         \n\t"
+  "bgezc %[a13], L16             \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L16:                          \n\t"
+  "li %[err], 16                 \n\t"
+  "bgtzc %[a8], Lfail            \n\t" /* BGTZC */
+  "nop                           \n\t"
+  "bgtzc %[a11], Lfail           \n\t"
+  "nop                           \n\t"
+  "bgtzc %[a13], L17             \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "li %[a10], 0                  \n\t"
+  "L17:                          \n\t"
+  "li %[err], 17                 \n\t"
+  "blezalc %[a12], Lfail         \n\t" /* BLEZALC */
+  "nop                           \n\t"
+  "blezalc %[a11], Lret          \n\t"
+  "li %[a10], 1                  \n\t"
+  "beqzc %[a10], L175            \n\t" /* BEQZC */
+  "nop                           \n\t"
+  "li %[err], 8531               \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L175:                         \n\t"
+  "li %[err], 23531              \n\t"
+  "blezalc %[a14], Lret          \n\t"
+  "li %[a10], 1                  \n\t"
+  "beqzc %[a10], L18             \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L18:                          \n\t"
+  "li %[err], 18                 \n\t"
+  "bgezalc %[a14], Lfail         \n\t" /* BGEZALC */
+  "nop                           \n\t"
+  "bgezalc %[a11], Lret          \n\t"
+  "li %[a10], 1                  \n\t"
+  "beqzc %[a10], L185            \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L185:                         \n\t"
+  "bgezalc %[a12], Lret          \n\t"
+  "li %[a10], 1                  \n\t"
+  "beqzc %[a10], L19             \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L19:                          \n\t"
+  "li %[err], 19                 \n\t"
+  "bgtzalc %[a14], Lfail         \n\t" /* BGTZALC */
+  "nop                           \n\t"
+  "bgtzalc %[a11], Lfail         \n\t"
+  "nop                           \n\t"
+  "bgtzalc %[a12], Lret          \n\t"
+  "li %[a10], 1                  \n\t"
+  "beqzc %[a10], L20             \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L20:                          \n\t"
+  "li %[err], 20                 \n\t"
+  "bltzalc %[a12], Lfail         \n\t" /* BLTZALC */
+  "nop                           \n\t"
+  "bltzalc %[a11], Lfail         \n\t"
+  "nop                           \n\t"
+  "bltzalc %[a14], Lret          \n\t"
+  "li %[a10], 1                  \n\t"
+  "beqzc %[a10], L21             \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L21:                          \n\t"
+  "li %[err], 21                 \n\t"
+  "bc L22                        \n\t" /* BC */
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L22:                          \n\t"
+  "li %[err], 22                 \n\t"
+  "balc Lret                     \n\t" /* BALC */
+  "li %[a10], 1                  \n\t"
+  "beqzc %[a10], L23             \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L23:                          \n\t"
+  "li %[err], 23                 \n\t"
+  "jal GetPC                     \n\t" /* JAL */
+  "nop                           \n\t"
+  "jic $6, 4                     \n\t" /* JIC */
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L24:                          \n\t"
+  "li %[err], 24                 \n\t"
+  "li %[a10], 1                  \n\t"
+  "jal GetPC                     \n\t"
+  "nop                           \n\t"
+  "jialc $6, 20                  \n\t" /* JIALC */
+  "nop                           \n\t"
+  "beqzc %[a10], L25             \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "LJIALCRET:                    \n\t"
+  "li %[a10], 0                  \n\t"
+  "jr $31                        \n\t" /* JR */
+  "nop                           \n\t"
+  "L25:                          \n\t"
+  "li %[err], 25                 \n\t"
+  "jal GetPC                     \n\t"
+  "nop                           \n\t"
+  "move %[a11], $6               \n\t"
+  "nal                           \n\t"
+  "nop                           \n\t"
+  "addiu %[a11], 12              \n\t" /* ADDIU */
+  "beqc %[a11], $31, L26         \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "L26:                          \n\t"
+  "li %[err], 26                 \n\t"
+  "balc Lret                     \n\t"
+  "li %[a10], 1                  \n\t"
+  "beqzc %[a10], Lend            \n\t"
+  "nop                           \n\t"
+  "b Lfail                       \n\t"
+  "nop                           \n\t"
+  "Lret:                         \n\t"
+  "li %[a10], 0                  \n\t"
+  "daddiu $31, 4                 \n\t" /* DADDIU */
+  "jrc $31                       \n\t" /* JRC */
+  "nop                           \n\t"
+  "GetPC:                        \n\t"
+  "move $6, $31                  \n\t"
+  "jr $31                        \n\t"
+  "Lend:                         \n\t"
+  "li %[err], 0                  \n\t"
+  "Lfail:                        \n\t"
+  ".set pop                      \n\t" /* Restore previous config */
+  : [err] "+r"(err), [a14] "+r"(a14), [a13] "+r"(a13), [a12] "+r"(a12),
+    [a7] "+r"(a7), [a8] "+r"(a8), [a9] "+r"(a9), [a10] "+r"(a10), [a11] "+r"(a11)
+  : /* inputs */
+  : "$31", "$6" /* clobbers */
+  );
+
+  return err;
+}
+
+/* Tests forbidden slot branching i.e. conditional compact branch
+   instructions.  */
+
+int
+test_r6_forbidden (void)
+{
+  volatile int err = -1;
+  volatile int a4 = 0;
+  volatile int a2 = 0;
+  volatile int a1 = 0;
+
+  asm (
+  ".set push                         \n\t"
+  ".set noreorder                    \n\t"
+/* Test if FS is ignored when branch is taken */
+  "li %[err], 1                      \n\t"
+  "li %[a4], 0                       \n\t"
+  "beqzalc %[a4], L41                \n\t"
+  "li %[err], -85                    \n\t"
+  "L42:                              \n\t"
+  "b Lfail2                          \n\t"
+  "nop                               \n\t"
+  "L41:                              \n\t"
+  "blez %[err], Lfail2               \n\t"
+/* Test if FS is used when branch is not taken */
+  "li %[err], 2                      \n\t"
+  "li %[a4], 1                       \n\t"
+  "blezc %[a4], L43                  \n\t"
+  "addiu %[a4], %[a4], 1             \n\t"
+  "li %[a2], 2                       \n\t"
+  "beq %[a4], %[a2], L44             \n\t"
+  "nop                               \n\t"
+  "L43:                              \n\t"
+  "nop                               \n\t"
+  "b Lfail2                          \n\t"
+  "nop                               \n\t"
+  "L44:                              \n\t"
+  "li %[err], 3                      \n\t"
+  "li %[a4], 3                       \n\t"
+  "beqzalc %[a4], Lfail2             \n\t"
+/* Note: 'bc L45' instead nop would cause SegFault: Illegal instruction:
+   Forbidden slot causes an error when it contains a branch.  */
+  "nop                               \n\t"
+  "b Lend2                           \n\t"
+  "nop                               \n\t"
+  "L45:                              \n\t"
+  "nop                               \n\t"
+  "b Lfail2                          \n\t"
+  "nop                               \n\t"
+  "Lend2:                            \n\t"
+  "li %[err], 0                      \n\t"
+  "Lfail2:                           \n\t"
+  "nop                               \n\t"
+  ".set pop                          \n\t"
+  : [err] "+r" (err), [a4] "+r"(a4), [a2] "+r"(a2), [a1] "+r"(a1) /* outputs */
+  : /* inputs */
+  : "$31" /* clobbers */
+  );
+
+  return err;
+}
+
+int
+test_r6_64 (void)
+{
+  volatile int err = 0;
+
+  asm (
+  ".set push                                   \n\t"
+  ".set noreorder                              \n\t"
+  ".data                                       \n\t"
+  "dval: .dword 0xaa55bb66cc77dd88             \n\t"
+  "d1:   .dword 0xaaaabbbbccccdddd             \n\t"
+  "d5:   .dword 0x00000000000000dd             \n\t"
+  "d7:   .dword 0xeeeeffff00001111             \n\t"
+  "d8:   .dword 0xbbccccddddeeeeff             \n\t"
+  "d9:   .dword 0x000000ddaaaabbbb             \n\t"
+  "dval1: .word 0x1234abcd                     \n\t"
+  "dval2: .word 0xffee0000                     \n\t"
+  "dval3: .dword 0xffffffffffffffff            \n\t"
+  "  .fill 240,1,0                             \n\t"
+  "dval4: .dword 0x5555555555555555            \n\t"
+  "  .fill  264,1,0                            \n\t"
+
+/* Register $11 stores instruction currently being tested and hence
+ * identifies error if it occurs.  */
+  ".text                                       \n\t"
+
+  "li $11, 1                                   \n\t" /* Test DALIGN */
+  r6ck_2dr1i (dalign, d7, d1, 3, d8)
+  r6ck_2dr1i (dalign, d1, d5, 4, d9)
+
+  "li $11, 2                                   \n\t" /* Test LDPC */
+  "ld $5, dval                                 \n\t"
+  "nop                                         \n\t"
+  "ldpc $4, dval                               \n\t"
+  fp_assert ($4, $5)
+
+  "li $11, 3                                   \n\t" /* Test LWUPC */
+  "lwu $5, dval1                               \n\t"
+  "lwupc $4, dval1                             \n\t"
+  fp_assert ($4, $5)
+  "lwu $5, dval2                               \n\t"
+  "lwupc $4, dval2                             \n\t"
+  fp_assert ($4, $5)
+
+  "li $11, 4                                   \n\t" /* Test LLD */
+  "ld $5, dval3                                \n\t"
+  "dla $3, dval4                               \n\t"
+  "lld $4, -248($3)                            \n\t"
+  fp_assert ($4, $5)
+
+  "li $11, 5                                   \n\t" /* Test SCD */
+  "lld $4, -248($3)                            \n\t"
+  "dli $4, 0xafaf                              \n\t"
+  "scd $4, -248($3)                            \n\t"
+  "ld $5, dval3                                \n\t"
+  "dli $4, 0xafaf                              \n\t"
+  fp_assert ($4, $5)
+
+  "Lend3:                                      \n\t"
+  "li $11, 0                                   \n\t"
+  "58:                                         \n\t"
+  "move %[err], $11                            \n\t"
+  ".set pop                                    \n\t"
+   : [err] "+r" (err) /* outputs */
+   :                  /* inputs */
+   : "$3", "$4", "$5", "$6", "$7", "$11" /* clobbers */
+  );
+
+  return err;
+}
+
+int
+test_r6 (void)
+{
+  volatile int err = 0;
+
+  asm (
+  ".set push                                                   \n\t"
+  ".set noreorder                                              \n\t"
+  ".data                                                       \n\t"
+  "dval_1:  .word 0xabcd1234                                   \n\t"
+  "dval_2: .word 0x1234eeff                                    \n\t"
+  ".fill 248,1,0                                               \n\t"
+  "dval_3: .word 0x55555555                                    \n\t"
+  ".fill  260,1,0                                              \n\t"
+  "dval_4: .word 0xaaaaaaaa                                    \n\t"
+  ".text                                                       \n\t"
+  "li $11, 1            \n\t" /* ADDIUPC */
+  "jal GetPC_2                                               \n\t"
+  "nop                                                       \n\t"
+  "addiu $4, $6, 8                                           \n\t"
+  "addiupc $5, 4                                             \n\t"
+  fp_assert ($4, $5)
+
+  "li $11, 2            \n\t" /* AUIPC */
+  "jal GetPC_2                                               \n\t"
+  "nop                                                       \n\t"
+  "addiu $4, $6, 8                                           \n\t"
+  "aui $4, $4, 8                                             \n\t"
+  "auipc $5, 8                                               \n\t"
+  fp_assert ($4, $5)
+
+  "li $11, 3            \n\t" /* ALUIPC */
+  "jal GetPC_2                                               \n\t"
+  "nop                                                       \n\t"
+  "addiu $4, $6, 16                                          \n\t"
+  "aui $4, $4, 8                                             \n\t"
+  "li $7, 0xffff0000                                         \n\t"
+  "and $4, $4, $7                                            \n\t"
+  "aluipc $5, 8                                              \n\t"
+  fp_assert ($4, $5)
+
+  "li $11, 4            \n\t" /* LWPC */
+  "lw $5, dval_1                                             \n\t"
+  "lwpc $4, dval_1                                           \n\t"
+  fp_assert ($4, $5)
+  "lw $5, dval_2                                             \n\t"
+  "lwpc $4, dval_2                                           \n\t"
+  fp_assert ($4, $5)
+
+/* Testing LL follows.
+ * NOTE: May be redundant because SC already contains LL in its test.  */
+  "li $11, 5                                                \n\t"
+  "lw $5, dval_2                                             \n\t"
+  "dla $3, dval_3                                            \n\t"
+  "ll $4, -252($3)                                           \n\t"
+  fp_assert ($4, $5)
+
+  "li $11, 6        \n\t"    /* LL-SC sequence */
+  "ll $4, -252($3)                                           \n\t"
+  "li $4, 0xafaf                                             \n\t"
+  "sc $4, -252($3)                                           \n\t"
+  "lw $5, dval_2                                             \n\t"
+  "li $4, 0xafaf                                             \n\t"
+  fp_assert ($4, $5)
+  "b Lend4                                                   \n\t"
+  "nop                                                       \n\t"
+  "GetPC_2:                                                  \n\t"
+  "move $6, $31                                              \n\t"
+  "jr $31                                                    \n\t"
+  "Lend4:                                                    \n\t"
+  "li $11, 0                                                 \n\t"
+  "58:                                                       \n\t"
+  "move %[err], $11                                          \n\t"
+  ".set pop                                                  \n\t"
+  : [err] "+r"(err)  /* outputs */
+  : /* inputs */
+  : "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10",
+    "$11", "$31" /* clobbers */
+  );
+
+  return err;
+}
+
+/* For fpu-branching testing, bc1eq/eqz are enough.  */
+
+int
+test_r6_fpu (void)
+{
+  volatile int err = 0;
+
+  asm (
+  ".set push                               \n\t"
+  ".set noreorder                          \n\t"
+/* Test qNaN format is 754-2008 */
+  "li $11, 1                               \n\t"
+  "li $4, 0x0                              \n\t"
+  "li $5, 0x0                              \n\t"
+  "li $6, 0x7fc00000                       \n\t"
+  "mtc1 $4, $f2                            \n\t"
+  "mtc1 $5, $f4                            \n\t"
+  "div.s $f6, $f2, $f4                     \n\t"
+  "mfc1 $8, $f6                            \n\t"
+  fp_assert ($6, $8)
+
+  "li $11, 2                                \n\t"  /* bc1eqz */
+  "li $10, 0x01                             \n\t"
+  "mtc1 $10, $f2                            \n\t"
+  "mtc1 $0, $f4                             \n\t"
+  "bc1eqz $f2, 58f                          \n\t"
+  "nop                                      \n\t"
+  "bc1eqz $f4, L62                          \n\t"
+  "nop                                      \n\t"
+  "b 58f                                    \n\t"
+  "nop                                      \n\t"
+"L62:                                       \n\t"
+  "li $11, 3                                \n\t"  /* bc1nez */
+  "bc1nez $f4, 58f                          \n\t"
+  "nop                                      \n\t"
+  "bc1nez $f2, Lend8                        \n\t"
+  "nop                                      \n\t"
+  "b 58f                                    \n\t"
+  "nop                                      \n\t"
+"Lend8:                                     \n\t"
+  "li $11, 0                                \n\t"
+  "58:                                      \n\t"
+  "move %[err], $11                         \n\t"
+  ".set pop                                 \n\t"
+  : [err] "+r"(err)  /* outputs */
+  :                  /* inputs */
+  : "$4", "$5", "$6", "$8", "$10", "$11", "$31",
+    "$f2", "$f4", "$f6" /* clobbers */
+  );
+
+  return err;
+}
+
+/* R6 specific tests for mips64 (64-bit).  */
+
+int
+test_r6_llsc_dp (void)
+{
+  volatile int err = 0;
+
+  asm (
+  ".set push                                            \n\t"
+  ".set noreorder                                       \n\t"
+  ".data                                                \n\t"
+  ".align 16                                            \n\t"
+  "test_data:                                           \n\t"
+  ".word 0xaaaaaaaa                                     \n\t"
+  ".word 0xbbbbbbbb                                     \n\t"
+  ".word 0xcccccccc                                     \n\t"
+  ".word 0xdddddddd                                     \n\t"
+  ".align 16                                            \n\t"
+  "end_check:                                           \n\t"
+  ".byte 0                                              \n\t"
+  ".byte 0                                              \n\t"
+  ".byte 0                                              \n\t"
+  ".byte 0x1                                            \n\t"
+  ".text                                                \n\t"
+  "li $11, 1                                            \n\t" /* LLWP */
+  "llwp $2, $3, test_data                               \n\t"
+  checkpair_dword ($2, $3, test_data, end_check)
+  "sll $2, $2, 1                                        \n\t"
+  "srl $3, $3, 1                                        \n\t"
+  "move  $s0, $2                                        \n\t"
+  "scwp $2, $3, test_data                               \n\t"
+  check32 ($2, 1)
+  checkpair_dword ($s0, $3, test_data, end_check)
+  /* Test SCWP, done */
+  "li $11, 2                                            \n\t"
+  "li $11, 3                                            \n\t" /* LLDP */
+  "lldp $2, $3, test_data                               \n\t"
+  checkpair_qword ($2, $3, test_data, end_check)
+  "dsll $2, $2, 1                                       \n\t"
+  "dsrl $3, $3, 1                                       \n\t"
+  "move $s0, $2                                         \n\t"
+  "scdp $2, $3, test_data                               \n\t"
+  check32 ($2, 1)
+  checkpair_qword ($s0, $3, test_data, end_check)
+  "li $11, 4                                            \n\t" /* SCDP done */
+  "Lend5:                                               \n\t"
+  "li $11, 0                                            \n\t"
+  "58:                                                  \n\t"
+  "move %[err], $11                                     \n\t"
+  ".set pop                                             \n\t"
+  : [err] "+r"(err) /* outputs */
+  : /* inputs */
+  : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11",
+    "$31", "$s0"  /* clobbers */
+  );
+
+  return err;
+}
+
+/* R6 specific tests for mips32 (32-bit).  */
+
+int
+test_r6_llsc_wp (void)
+{
+  volatile int err = 0;
+
+  asm (
+  ".set push                                            \n\t"
+  ".set noreorder                                       \n\t"
+  ".data                                                \n\t"
+  ".align 8                                             \n\t"
+  "test_data_2:                                         \n\t"
+  ".word 0xaaaaaaaa                                     \n\t"
+  ".word 0xbbbbbbbb                                     \n\t"
+  ".align 8                                             \n\t"
+  "end_check_2:                                         \n\t"
+  ".byte 0                                              \n\t"
+  ".byte 0                                              \n\t"
+  ".byte 0                                              \n\t"
+  ".byte 0x1                                            \n\t"
+  ".text                                                \n\t"
+  "li $11, 1                                            \n\t" /* Test LLWP */
+  "llwp $2, $3, test_data_2                             \n\t"
+  checkpair_dword ($2, $3, test_data_2, end_check_2)
+  "sll $2, $2, 1                                        \n\t"
+  "srl $3, $3, 1                                        \n\t"
+  "move  $s0, $2                                        \n\t"
+  "scwp $2, $3, test_data_2                             \n\t"
+  check32 ($2, 1)
+  checkpair_dword ($s0, $3, test_data_2, end_check_2)
+/* Test SCWP, done.  */
+  "li $11, 2                                            \n\t"
+  "Lend6:                                               \n\t"
+  "li $11, 0                                            \n\t"
+  "58:                                                  \n\t"
+  "move %[err], $11                                     \n\t"
+  ".set pop                                             \n\t"
+  : [err] "+r"(err) /* outputs */
+  : /* inputs */
+  : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10",
+    "$11", "$31", "$s0"  /* clobbers */
+  );
+
+  return err;
+}
+
+/* Any test_r6_* function returns non-zero => failure.  */
+#define EXPECT(X) if ((X)) abort ();
+
+int
+main (void)
+{
+  EXPECT (test_r6_branch ());
+
+  EXPECT (test_r6_forbidden ());
+
+  EXPECT (test_r6_64 ());
+
+  EXPECT (test_r6 ());
+
+  EXPECT (test_r6_fpu ());
+
+  EXPECT (test_r6_llsc_dp ());
+
+  EXPECT (test_r6_llsc_wp ());
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/mips-64-r6.exp b/gdb/testsuite/gdb.arch/mips-64-r6.exp
new file mode 100644
index 00000000000..2cce6abc6fa
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/mips-64-r6.exp
@@ -0,0 +1,76 @@
+# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+################################################################
+################## MIPS Release 6 patch tests ##################
+################################################################
+
+# Send 'si' to gdb until inferior exits.
+proc stepi {} {
+    global gdb_prompt
+    set timeout [get_largest_timeout]
+    set start [timestamp]
+    while { [timestamp] - $start < 3*$timeout } {
+	gdb_test_multiple "stepi" ""  {
+	    -re ".*exited normally.*" {
+		pass "success"
+		return
+	    }
+	    -re ".*The program is not being run.*" {
+		fail "failure"
+		return
+	    }
+	    -re ".*Breakpoint.*test_.*$gdb_prompt $" {
+	    }
+	    -re "$gdb_prompt.*" {
+	    }
+	}
+    }
+    fail "test failed"
+    return
+}
+
+require {istarget "*mips*"}
+
+set testfile "mips-64-r6"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if {[prepare_for_testing "failed to prepare" "${binfile}" "${srcfile}" {debug nowarnings}]} {
+    untested "failed to prepare"
+    return
+}
+
+# Native needs run.
+if { ![runto_main] } {
+    untested "couldn't run to main"
+    return
+}
+
+set tests ""
+foreach n [list "r6_branch" "r6_forbidden" "r6_64" "r6" "r6_fpu" "r6_llsc_dp" "r6_llsc_wp"] {
+    lappend tests "test_$n"
+}
+
+# Put breakpoint on each test-function
+foreach func $tests {
+    if {![gdb_breakpoint "$func"]} {
+	untested "couldn't put breakpoint to $func"
+	return
+    }
+}
+
+# Step through the binary
+stepi
-- 
2.40.1


^ permalink raw reply	[relevance 2%]

* RE: [PATCH v2 1/1] gdb, testsuite: Handle unused compiler option fdiagnostics-color=never.
  @ 2024-05-15 19:06  6%     ` Ijaz, Abdul B
  0 siblings, 0 replies; 200+ results
From: Ijaz, Abdul B @ 2024-05-15 19:06 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches, Schimpe, Christina, Willgerodt, Felix, keiths

Hi Tom,

Thanks for the feedback.

>> +	if {[string match *.s $source] != 0} {
>> +	    set new_options [universal_compile_options_assembly]

> Should this also check for *.S files?  If so it needs a change, and if not it should probably have a comment explaining why not.

Icx/icpx/ifx/clang compilers does not support this compile option only for ".s" files while .S files does not have this issue. Sure I will add the comment here.

Best Regards
Abdul Basit

-----Original Message-----
From: Tom Tromey <tom@tromey.com> 
Sent: Wednesday, May 15, 2024 6:18 PM
To: Ijaz, Abdul B <abdul.b.ijaz@intel.com>
Cc: gdb-patches@sourceware.org; Schimpe, Christina <christina.schimpe@intel.com>; Willgerodt, Felix <felix.willgerodt@intel.com>; keiths@redhat.com
Subject: Re: [PATCH v2 1/1] gdb, testsuite: Handle unused compiler option fdiagnostics-color=never.

>>>>> Abdul Basit Ijaz <abdul.b.ijaz@intel.com> writes:

> The 'univeral_compile_options' in gdb.exp file only verifies the 
> support of '-fdiagnostics-color=never' for the "C" source file.  So 
> while running tests with assembly source file (.s), many of them are 
> not able to run on icx/clang compilers because 
> '-fdiagnostics-color=never' option is not supported.  After this 
> change, this function is split into multiple functions to check the support for different type of sources individually.

Thanks for the patch.

> -	set new_options [universal_compile_options]
> +	if {[string match *.s $source] != 0} {
> +	    set new_options [universal_compile_options_assembly]
> +	} else {
> +	    set new_options [universal_compile_options_c]

Should this also check for *.S files?  If so it needs a change, and if not it should probably have a comment explaining why not.

Tom
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[relevance 6%]

* RE: [PATCH 1/1] gdb, testsuite: Handle unused compiler option fdiagnostics-color=never.
  @ 2024-05-14 11:22  7%   ` Ijaz, Abdul B
  0 siblings, 0 replies; 200+ results
From: Ijaz, Abdul B @ 2024-05-14 11:22 UTC (permalink / raw)
  To: Keith Seitz, gdb-patches; +Cc: Schimpe, Christina, Willgerodt, Felix

Thanks Keith for the feedback.

Please see my comments inlined below.

>> 2024-03-22 Ijaz, Abdul B <abdul.b.ijaz@intel.com>_

>Was this (apparently) stray line the start of a ChangeLog entry? [We don't require those anymore.]
Will remove it.

> +    gdb_produce_source $src {
> +	int foo(void) { int arr[100]={0}; return 0; }

>This patch changes this from "int foo(void) { return 0; }".
>I don't see that documented why that was necessary?

This change is not needed so will remove it.

>> +    set src "$::srcdir/gdb.arch/amd64-entry-value.s"

> I don't think this is going to work anywhere except on x86.
> In fact, I tried this on aarch64, and (with below issue fixed), the log contains a bunch of errors (with "-v -v"
> verbosity to DejaGNU):

> Failing that, there is a relatively simple fallback for checking for clang specifically: "test_compiler_info {clang-*}".
> That might be safer than trying to write some generic asm code?

>> +	if {[string match *.s $source] != 0} {

Using test_compiler_info will fix the issue but only then the purpose to keep function universal_compile_options would not be justified.  Also I tried on aarch64 where c language test files works as expected for clang but as the existing .s assembly files are not supported on aarch64 so you are right in this case as asm files are not in the expected format there will be issue for it like you mentioned but I can replace it with some generic asm file which contains only "main:" clause and then it should be fine on all architectures. As i understood you also meant the same by using gdb_produce_source here.  I tested on x86 and aarch64 using such temp file generated by gdb_produce_source where it works then as expected. Will this solution  be fine with you ?

Here is an example output of .s file on AARCH 64:
builtin_spawn -ignore SIGHUP clang -fdiagnostics-color=never -c -o /home/builds/temp/11088/csymbol.o /home/gta/builds/temp/11171/ccopts.s
clang: warning: argument unused during compilation: '-fdiagnostics-color=never' [-Wunused-command-line-argument]
get_compiler_info: clang-14-0-0
Executing on host: clang   -Wno-unknown-warning-option -fno-pie -c -o /home/builds/outputs/gdb.arch/amd64-entry-value/amd64-entry-value0.o /home/builds/../src/gdb/testsuite/gdb.arch/amd64-entry-value.s

I am going to upstream new patch # 2 today please have a look and let me know if the latest changes looks fine to you.

>I don't think this is sufficient. A bunch of test cases use ".S", such as every aarch64 test using assembler. Perhaps add "-nocase"?
.s will small letter are already processed assembly files where as .S files are still processed via C preprocessor before assembly so we see this issue only for the .s files in gdb testsuite. This is why only .s files are handled here so should be fine.

Thanks & Best Regards,
Abdul Basit

-----Original Message-----
From: Keith Seitz <keiths@redhat.com> 
Sent: Friday, March 29, 2024 8:51 PM
To: Ijaz, Abdul B <abdul.b.ijaz@intel.com>; gdb-patches@sourceware.org
Cc: Schimpe, Christina <christina.schimpe@intel.com>; Willgerodt, Felix <felix.willgerodt@intel.com>
Subject: Re: [PATCH 1/1] gdb, testsuite: Handle unused compiler option fdiagnostics-color=never.

Hi,

Thanks for the patch! More clang compatibility is always good.

On 3/22/24 06:55, Abdul Basit Ijaz wrote:
> From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>
> 
> The 'univeral_compile_options' in gdb.exp file only verifies the 
> support of '-fdiagnostics-color=never' for the "C" source file.  So 
> while running tests with assembly source file (.s), many of them are 
> not able to run on icx/clang compilers because 
> '-fdiagnostics-color=never' option is not supported.  After this 
> change, this function is split into multiple functions to check the support for different type of sources individually.

I like this approach.

> Before this change, in the case of clang and ICX compiler, this error 
> is shown for assembly source files:
> 
> '''
> icx -fdiagnostics-color=never -Wno-unknown-warning-option -fno-pie -c 
> -O0 -o amd64-entry-value0.o gdb/testsuite/gdb.arch/amd64-entry-value.s 
> (timeout = 300)
> 
> icx: warning: argument unused during compilation: '-fdiagnostics-color=never'
> [-Wunused-command-line-argument]
> 
> gdb compile failed, icx: warning: argument unused during compilation:
> '-fdiagnostics-color=never' [-Wunused-command-line-argument]
> 
> UNTESTED: gdb.arch/amd64-entry-value.exp: failed to prepare '''
> 
> Similarly this error is shown for the clang compiler:
> 
> '''
> clang  -fdiagnostics-color=never -Wno-unknown-warning-option -fno-pie 
> -c -O0 -o amd64-entry-value0.o 
> gdb/testsuite/gdb.arch/amd64-entry-value.s
> 
> clang: warning: argument unused during compilation:
>   '-fdiagnostics-color=never' [-Wunused-command-line-argument] '''
> 
> 2024-03-22 Ijaz, Abdul B <abdul.b.ijaz@intel.com>_

Was this (apparently) stray line the start of a ChangeLog entry? [We don't require those anymore.]

> ---
>   gdb/testsuite/lib/gdb.exp | 48 +++++++++++++++++++++++++++++++--------
>   1 file changed, 38 insertions(+), 10 deletions(-)
> 
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp 
> index a0c4855ffc5..4f19162b3ce 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -5018,17 +5018,9 @@ proc gdb_wrapper_init { args } {
>   }
>   
>   # Determine options that we always want to pass to the compiler.
> -gdb_caching_proc universal_compile_options {} {
> -    set me "universal_compile_options"
> +proc universal_compile_options {src obj} {
>       set options {}
>   
> -    set src [standard_temp_file ccopts.c]
> -    set obj [standard_temp_file ccopts.o]
> -
> -    gdb_produce_source $src {
> -	int foo(void) { return 0; }
> -    }
> -
>       # Try an option for disabling colored diagnostics.  Some compilers
>       # yield colored diagnostics by default (when run from a tty) unless
>       # such an option is specified.
> @@ -5038,6 +5030,23 @@ gdb_caching_proc universal_compile_options {} {
>   	# Seems to have worked; use the option.
>   	lappend options $opt
>       }
> +
> +    return $options
> +}
> +
> +# Determine options that we always want to pass to the C compiler.
> +gdb_caching_proc universal_compile_options_c {} {
> +    set me "universal_compile_options_c"
> +
> +    set src [standard_temp_file ccopts.c]
> +    set obj [standard_temp_file ccopts.o]
> +
> +    gdb_produce_source $src {
> +	int foo(void) { int arr[100]={0}; return 0; }

This patch changes this from "int foo(void) { return 0; }".
I don't see that documented why that was necessary?

> +    }
> +
> +    set options [universal_compile_options $src $obj]
> +
>       file delete $src
>       file delete $obj
>   
> @@ -5045,6 +5054,21 @@ gdb_caching_proc universal_compile_options {} {
>       return $options
>   }
>   
> +# Determine options that we always want to pass to the compiler for # 
> +assembly source files with the extension ".s".
> +gdb_caching_proc universal_compile_options_assembly {} {
> +    set me "universal_compile_options_assembly"
> +
> +    set obj [standard_temp_file csymbol.o]
> +    set src "$::srcdir/gdb.arch/amd64-entry-value.s"

I don't think this is going to work anywhere except on x86.
In fact, I tried this on aarch64, and (with below issue fixed), the log contains a bunch of errors (with "-v -v"
verbosity to DejaGNU):

Executing on host: clang    -fdiagnostics-color=never -c -o 
/root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/temp/69953/csymbol.o
/root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/../../../gdb/testsuite/gdb.arch/amd64-entry-value.s 
    (timeout = 300)
builtin_spawn -ignore SIGHUP clang -fdiagnostics-color=never -c -o /root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/temp/69953/csymbol.o
/root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/../../../gdb/testsuite/gdb.arch/amd64-entry-value.s
pid is 70084 -70084
clang: warning: argument unused during compilation: 
'-fdiagnostics-color=never'
[-Wunused-command-line-argument]
/root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/../../../gdb/testsuite/gdb.arch/amd64-entry-value.s:37:16: 
error: unexpected token in argument list
         movl    $0, _ZL1v(%rip)
                          ^
/root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/../../../gdb/testsuite/gdb.arch/amd64-entry-value.s:57:12: 
error: unexpected token in argument list
         addsd   .LC0(%rip), %xmm0
                     ^
[8000+ lines deleted]

[I note that the output contained a bunch of terminal escape codes (which I've deleted for clarity).]

I think something more along the lines of using gdb_produce_source is needed, where we attempt to output really generic asm (if possible?).
I wonder if we could do something along the lines of

    gdb_produce_source $src {
            .text
            .globl main
            .type main, @function
        main:
             nop
    }

Warning: untested. This does compile with both gcc and clang on aarch64 and x86_64 (with -z noexecstack), but that's all I've attempted to verify.

Failing that, there is a relatively simple fallback for checking for clang specifically: "test_compiler_info {clang-*}".
That might be safer than trying to write some generic asm code?

> +
> +    set options [universal_compile_options $src $obj]
> +    file delete $obj
> +
> +    verbose "$me:  returning $options" 2
> +    return $options

I really appreciate the verbose statements. Helped me understand several of the questions I have!

> +}
> +
>   # Compile the code in $code to a file based on $name, using the flags
>   # $compile_flag as well as debug, nowarning and quiet  (unless otherwise
>   # specified in default_compile_flags).
> @@ -5224,7 +5248,11 @@ proc gdb_compile {source dest type options} {
>       if {[lsearch -exact $options rust] != -1} {
>   	# -fdiagnostics-color is not a rustcc option.
>       } else {
> -	set new_options [universal_compile_options]
> +	if {[string match *.s $source] != 0} {

I don't think this is sufficient. A bunch of test cases use ".S", such as every aarch64 test using assembler. Perhaps add "-nocase"?

> +	    set new_options [universal_compile_options_assembly]
> +	} else {
> +	    set new_options [universal_compile_options_c]
> +	}
>       }
>   
>       # C/C++ specific settings.

Thanks again for the patch!

Keith

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[relevance 7%]

* [PATCH v6] [gdb/testsuite] New test: gdb.base/errno.exp
@ 2024-05-11 21:45  1% Kevin Buettner
  0 siblings, 0 replies; 200+ results
From: Kevin Buettner @ 2024-05-11 21:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom de Vries, Pedro Alves, Kevin Buettner

Printing the value of 'errno' from GDB is sometimes problematic.  The
situation has improved in recent years, though there are still
scenarios for which "print errno" doesn't work.

The test, gdb.base/errno.exp, introduced by this commit, tests whether
or not GDB can print errno using a binary compiled in the following
different ways:

- default: no switches aside from -g (and whatever else is added by the
  testing framework)
- macros: macro info is included in the debuginfo; this is enabled by
  using -g3 when using gcc or clang
- static: statically linked binary
- static-macros: statically linked binary w/ macro definitions included
  in debuginfo
- pthreads: libpthread linked binary
- pthreads-macros: libpthread linked binary w/ macro definitions included
  in debuginfo
- pthreads-static: Statically linked against libpthread
- pthreads-static-macros: Statically linked against libpthread w/ macro
  definitions

For each of these, the test also creates a corefile, then loads the
corefile and attempts to print errno again.

Additionally, the test checks that a "masking" errno declared as a
local variable will print correctly.

On Linux, if the machine is missing glibc debuginfo (or you have
debuginfod disabled), it's likely you'll see:

    (gdb) print errno
    'errno' has unknown type; cast it to its declared type

But if you add a cast, the value of errno is often available:

    (gdb) print (int) errno
    $1 = 42

The test detects this situation along with several others and does
'setup_xfail' for tests that will almost certainly fail.  It could be
argued that some of these ought to be KFAILs due to deficiencies in
GDB, but I'm not entirely certain which, if any, are fixable yet.

On Fedora 39, without glibc debuginfo, there are no failures, but
I do see the following XFAILS:

XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: print errno
XFAIL: gdb.base/errno.exp: macros: print (int) errno
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: print errno
XFAIL: gdb.base/errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads: print errno
XFAIL: gdb.base/errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

On Fedora 39, with glibc debug info, but without libc.a (for static
linking), there are 2 XFAILs, 2 UNSUPPORTED tests, and 4 UNTESTED
tests.

So, even when testing in less than ideal conditions, either due to lack
of glibc debuginfo or lack of a libc to link against to make a static
binary, there are no failures.

With glibc debuginfo installed, on Fedora 38, Fedora 39, Fedora 40,
Fedora rawhide (41), and Ubuntu 22.04.1 LTS, I see these XFAILs:

XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: print errno
XFAIL: gdb.base/errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

On FreeBSD 13.1, the total number of XFAILs are fewer, and could be
even better still if it had debug info for glibc:

XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: print errno
XFAIL: gdb.base/errno.exp: macros: print (int) errno
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads: print errno
XFAIL: gdb.base/errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

Starting with glibc-2.34, most of the pthreads library has been
incorporated into libc, so finding thread-local variables using
libthread_db is possible for several scenarios in which it previously
wasn't.  But, prior to this, accessing errno for the default scenario
was a problem.  This is borne out by running this new test on Fedora
34, which uses glibc-2.33:

XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: print (int) errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: print errno
XFAIL: gdb.base/errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

In the v3 version of this test, Tom de Vries tested on openSUSE Leap
15.5 and found a number of cases which showed a FAIL instead of an
XFAIL.  The v4 version of this test fixed those problems.  On Leap
15.5, which uses glibc-2.31, with glibc debug info, I now see:

XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: print (int) errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

On Leap 15.5, with glibc debuginfo missing, the results are a little
worse:

XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: print (int) errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: print errno
XFAIL: gdb.base/errno.exp: macros: print (int) errno
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads: print errno
XFAIL: gdb.base/errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

The v5 version of this test fixed failures when testing with
check-read1.  (Thanks to Linaro CI for finding these.)  I revised the
regular expressions being used so that the failures were eliminated,
but the results mentioned above have not changed.

The v6 version of this test fixes some nits pointed out by both Tom
de Vries and Pedro Alves.  One of Pedro's suggestions was to rename the
test from check-errno.exp to errno.exp, so in v5, the name has
changed.  Tom also noticed that there were failures when using
--target_board=native-extended-gdbserver.  For v6, I've tested on 10
different Linux machines (F38, F39, F39 w/o glibc debuginfo, F39 w/o
static glibc, F40, rawhide, Ubuntu 22.04, Leap 15.5, Leap 15.5 w/o
glibc debuginfo, and Fedora 34) using "make check" and "make check-read1"
using target boards "unix", "native-extended-gdbserver", and
"native-gdbserver", with CC_FOR_TARGET set to both gcc and clang, for
a total of 12 distinct test runs on each machine.  I've also tested the
native-only cases on FreeBSD.  (Attempting to test against gdbserver
on FreeBSD resulted in hangs while running the test suite.)

So, bottom line, this test does not introduce any new failures on the
platforms on which I've tested, but the XFAILs are certainly unfortunate.
Some aren't fixable - e.g. when attempting to make a function call while
debugging a core file - but I think that some of them are.  I'm using
this new test case as a starting point for investigating problems with
printing errno.

Co-Authored-By: Jan Kratochvil
---
 gdb/testsuite/gdb.base/errno.c   |  37 +++++
 gdb/testsuite/gdb.base/errno.exp | 260 +++++++++++++++++++++++++++++++
 2 files changed, 297 insertions(+)
 create mode 100644 gdb/testsuite/gdb.base/errno.c
 create mode 100644 gdb/testsuite/gdb.base/errno.exp

diff --git a/gdb/testsuite/gdb.base/errno.c b/gdb/testsuite/gdb.base/errno.c
new file mode 100644
index 00000000000..c6835a866e8
--- /dev/null
+++ b/gdb/testsuite/gdb.base/errno.c
@@ -0,0 +1,37 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+
+static void shadow_errno ();
+
+int main ()
+{
+  errno = 42;
+
+  shadow_errno ();	/* main-breakpoint */
+  return 0;
+}
+
+#undef errno
+static void
+shadow_errno ()
+{
+  int errno = 36;
+
+  return;		/* shadow_errno-breakpoint */
+}
diff --git a/gdb/testsuite/gdb.base/errno.exp b/gdb/testsuite/gdb.base/errno.exp
new file mode 100644
index 00000000000..d7bdcc1d3d5
--- /dev/null
+++ b/gdb/testsuite/gdb.base/errno.exp
@@ -0,0 +1,260 @@
+# Copyright 2024 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# Check that errno can be accessed by GDB under a variety of
+# circumstances.
+#
+# The challenge with GDB accessing errno is that, on modern systems,
+# errno is a variable in thread-local storage.  So, if GDB's access to
+# thread local storage is broken or unavailable, some of these tests
+# could fail.  On Linux, this is/was known to happen on systems with
+# older versions of glibc as well as when debugging statically linked
+# binaries.
+#
+# Another possibility is that the environment lacks sufficient
+# type information to print errno.  This can happen for the errno
+# variable itself or when the debuginfo contains a macro for errno
+# which refers to a function lacking type information.
+#
+# When debugging core files, access to errno might not be possible
+# both due to the situations described earlier along with the fact
+# that inferior function calls are not possible (for the cases in
+# which errno is a macro which calls a function returning errno's
+# address).
+#
+# It's also possible for a program to declare errno in an inner scope
+# causing the thread-local errno to be shadowed.  GDB should still
+# correctly print the masking errno for this case.
+#
+# At the time that this test was written, on GNU/Linux and on FreeBSD,
+# there were always scenarios in which printing errno was problematic.
+# This test attempts to identify the problem cases and set up xfails
+# for them.  So, hopefully, there should be no actual failures.  But
+# the "expected" failures encountered by running this test do
+# genuinely illustrate problems that a user might encounter while
+# attempting to print errno.
+
+standard_testfile
+
+proc do_tests {{do_xfail_cast 0} {do_xfail 0} {do_xfail_core_test 0}} {
+    clean_restart $::binfile
+    if ![runto_main] {
+	return
+    }
+
+    gdb_breakpoint [gdb_get_line_number "main-breakpoint"]
+    gdb_continue_to_breakpoint "main-breakpoint"
+
+    # Whether or not "print errno" will work often depends on the
+    # debuginfo available.  We can make some inferences about whether
+    # some of the tests should have xfail set-up by looking at the
+    # output of "ptype errno".  This test is set up to always pass
+    # even for less than ideal outputs, because the point is to set up
+    # the xfail(s).
+    gdb_test_multiple "ptype errno" "check errno type availability" {
+	-re "type = int\r\n$::gdb_prompt $" {
+	    pass $gdb_test_name
+	}
+	-re "type = .*no debug info.*$::gdb_prompt $" {
+	    pass $gdb_test_name
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+	}
+	-re ".*Cannot find thread-local variables on this target.*$::gdb_prompt $" {
+	    pass $gdb_test_name
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+	    set do_xfail_cast 1
+	}
+	-re ".*Cannot find thread-local storage.*$::gdb_prompt $" {
+	    pass $gdb_test_name
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+	    set do_xfail_cast 1
+	}
+	-re ".*has unknown return type; cast the call to its declared return type.*$::gdb_prompt $" {
+
+	    # On systems which glibc as the C library, using -g3,
+	    # which causes macro information to be included in the
+	    # debuginfo, errno might be defined as follows:
+	    #
+	    #   #define errno (*__errno_location ())
+	    #
+	    # So, when we do "ptype errno", due to macro expansion,
+	    # this ends up being "ptype (*__errno_location ())".  So
+	    # the call to __errno_location (or something similar on
+	    # other OSes) is the call mentioned in the error message.
+
+	    pass $gdb_test_name
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+	    set do_xfail_cast 1
+	}
+    }
+
+    # If errno is defined as a macro that contains an obvious function
+    # call, it won't work when debugging a core file.
+    gdb_test_multiple "info macro errno" "check if errno is a macro" {
+	-re "Defined at.*\[\r\n\]#define.*\\\(\\\).*$::gdb_prompt $" {
+	    set do_xfail_core_test 1
+	    pass $gdb_test_name
+	}
+	-re "Defined at.*\[\r\n\]#define.*$::gdb_prompt $" {
+	    pass $gdb_test_name
+	}
+	-re "The symbol .errno. has no definition.*$::gdb_prompt $" {
+	    pass $gdb_test_name
+	}
+    }
+
+    # Sometimes, "ptype errno" will ferret out that thread local
+    # variables aren't accessible, but sometimes it won't.  Dig deeper
+    # by trying to access memory using the "x/d" command.  Again, the
+    # point here is to set up an xfail for the later tests, so we pass
+    # this test for other known outputs.
+    gdb_test_multiple "x/d &errno" "attempt to access errno memory" {
+	-re ".*Cannot find thread-local variables on this target.*$::gdb_prompt $" {
+	    pass $gdb_test_name
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+	    set do_xfail_cast 1
+	}
+	-re ".*Cannot find thread-local storage.*$::gdb_prompt $" {
+	    pass $gdb_test_name
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+	    set do_xfail_cast 1
+	}
+	-re ".*has unknown return type; cast the call to its declared return type.*$::gdb_prompt $" {
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+	    set do_xfail_cast 1
+	    pass $gdb_test_name
+	}
+	-re "$::hex.*?:\[\t \]$::decimal\[\r\n\]+$::gdb_prompt $" {
+	    pass $gdb_test_name
+	}
+    }
+
+    if $do_xfail {
+	setup_xfail *-*-*
+    }
+    gdb_test "print errno" ".* = 42"
+
+    if $do_xfail_cast {
+	setup_xfail *-*-*
+    }
+    gdb_test "print (int) errno" ".* = 42"
+
+    set corefile ${::binfile}.core
+    set core_supported [gdb_gcore_cmd $corefile "save corefile"]
+    # Normally, we'd check core_supported here and return if it's
+    # not, but we'll defer that until after the shadow test.
+
+    gdb_breakpoint [gdb_get_line_number "shadow_errno-breakpoint"]
+    gdb_continue_to_breakpoint "shadow_errno-breakpoint"
+
+    # This test demonstrates why a simple hack to GDB for printing
+    # errno is a bad idea.  (The hack was to intercept the string
+    # "errno" in process_print_command_args() and replace it with
+    # "*(*(int *(*)(void)) __errno_location) ()".)
+    gdb_test "print errno" ".* = 36" "print masking errno"
+
+    # Finish test early if no core file was made.
+    if !$core_supported {
+	return
+    }
+
+    clean_restart $::binfile
+
+    set core_loaded [gdb_core_cmd $corefile "load corefile"]
+    if { $core_loaded == -1 } {
+	return
+    }
+    if $do_xfail_core_test {
+	setup_xfail *-*-*
+    }
+    gdb_test "print errno" ".* = 42" "check errno value from corefile"
+}
+
+set binprefix $binfile
+
+with_test_prefix "default" {
+    set binfile $binprefix-default
+    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "macros" {
+    set binfile $binprefix-macros
+    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug macros}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "static" {
+    set binfile $binprefix-static
+    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-static"}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "static-macros" {
+    set binfile $binprefix-static-macros
+    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug macros "additional_flags=-static"}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "pthreads" {
+    set binfile $binprefix-pthreads
+    if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "pthreads-macros" {
+    set binfile $binprefix-pthreads-macros
+    if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug macros}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "pthreads-static" {
+    set binfile $binprefix-pthreads-static
+    if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-static"}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "pthreads-static-macros" {
+    set binfile $binprefix-pthreads-static-macros
+    if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug macros "additional_flags=-static"}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
-- 
2.44.0


^ permalink raw reply	[relevance 1%]

* Re: [PATCH v5] [gdb/testsuite] New test: gdb.base/check-errno.exp
  @ 2024-05-11 19:30  0%   ` Kevin Buettner
  0 siblings, 0 replies; 200+ results
From: Kevin Buettner @ 2024-05-11 19:30 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

On Fri, 10 May 2024 10:40:42 +0200
Tom de Vries <tdevries@suse.de> wrote:

> Hi Kevin,
> 
> I applied the patch and tested without and with debug info on leap 15.5, 
> and only got passes and xfails, so that looks good.  Likewise on tumbleweed.
> 
> One nit:
> ...
> $ git show --check --pretty=%s
> New test: gdb.base/check-errno.exp
> 
> gdb/testsuite/gdb.base/check-errno.exp:38: trailing whitespace.
> +# there were always scenarios in which printing errno was problematic.
> ...

Fixed (in my local tree).

> I tested this using make-check-all.sh, and got:
> ...
> (gdb) PASS: gdb.base/check-errno.exp: default: continue to breakpoint: 
> main-breakpoint
> ptype errno^M
> Cannot find thread-local storage for Thread 14233.14233, shared library 
> /lib64/libc.so.6:^M
> Remote target failed to process qGetTLSAddr request^M
> (gdb) FAIL: gdb.base/check-errno.exp: default: ptype errno
> ...
> with f.i. target board native-extended-gdbserver/native-gdbserver, I'm 
> hoping that's easy to fix in the test-case.

Fixed - and yes, it was easy.

Thanks for the review.

Kevin


^ permalink raw reply	[relevance 0%]

* [PATCH 2/4] gdb/doc: don't try to copy GDBvn.texi from the source tree
  @ 2024-05-11  9:37  7% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-05-11  9:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

Long ago we used to carry a copy of GDBvn.texi in the source tree.
The build recipe for gdb.dvi and gdb.pdf contained instructions for
copying this file from the source tree if the file had not been
generated.

That's right, we also have a rule that builds GDBvn.texi, and
GDBvn.texi is in the dependency list for both gdb.dvi and gdb.pdf.

On top of this, GDBvn.texi was removed from the source tree in 2000,
in this commit:

  commit 1171f8d754f71e35fd2f6c4e82b00f3c685e515f
  Date:   Tue Feb 8 03:37:34 2000 +0000

      2000-02-07  Jason Molenda  (jsm@bugshack.cygnus.com)

I think we can assume that everyone is happy generating GDBvn.texi, so
lets remove the redundant copying code.
---
 gdb/doc/Makefile.in | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
index 3f3fe7b7ed9..9e3ce018e86 100644
--- a/gdb/doc/Makefile.in
+++ b/gdb/doc/Makefile.in
@@ -477,15 +477,6 @@ gdb-cfg.texi: ${srcdir}/${DOC_CONFIG}-cfg.texi
 	ln ${srcdir}/${DOC_CONFIG}-cfg.texi gdb-cfg.texi || \
 	cp ${srcdir}/${DOC_CONFIG}-cfg.texi gdb-cfg.texi
 
-# GDB MANUAL: texinfo source, using @set/@clear/@value/@ifset/@ifclear
-# If your texinfo or makeinfo don't support these, get a new texinfo release
-#
-# The nonsense with GDBvn.texi gets this to run with both Sun and GNU make.
-#   Note that we can *generate* GDBvn.texi, but since we distribute one in the
-#   source directory for the benefit of people who *don't* use this makefile,
-#   VPATH will often tell make not to bother building it, because the one
-#   in the srcdir is up to date.  (if not, then make should build one here).
-
 # Clean these up before each run.  Avoids a catch 22 with not being
 # able to re-generate these files (to fix a corruption) because these
 # files contain a corruption.
@@ -494,10 +485,6 @@ GDB_TEX_TMPS = gdb.aux gdb.cp* gdb.fn* gdb.ky* gdb.log gdb.pg* gdb.toc \
 
 # GDB MANUAL: TeX dvi file
 gdb.dvi: ${GDB_DOC_FILES}
-	$(SILENCE) if [ ! -f ./GDBvn.texi ]; then \
-		(test "$(LN_S)" = "ln -s" && ln -s $(srcdir)/GDBvn.texi .) || \
-		ln $(srcdir)/GDBvn.texi . || \
-		cp $(srcdir)/GDBvn.texi . ; else true; fi
 	$(SILENCE) rm -f $(GDB_TEX_TMPS)
 	$(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) $(READLINE_TEXI_INCFLAG) \
 		-I ${GDBMI_DIR} -I $(srcdir) $(srcdir)/gdb.texinfo
@@ -506,10 +493,6 @@ gdb.ps: gdb.dvi
 	$(ECHO_DVIPS) $(DVIPS) $(SILENT_Q_FLAG) -o $@ $?
 
 gdb.pdf: ${GDB_DOC_FILES}
-	$(SILENCE) if [ ! -f ./GDBvn.texi ]; then \
-		(test "$(LN_S)" = "ln -s" && ln -s $(srcdir)/GDBvn.texi .) || \
-		ln $(srcdir)/GDBvn.texi . || \
-		cp $(srcdir)/GDBvn.texi . ; else true; fi
 	$(SILENCE) rm -f $(GDB_TEX_TMPS)
 	$(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) --pdf \
 		$(READLINE_TEXI_INCFLAG) -I ${GDBMI_DIR} -I $(srcdir) \
-- 
2.25.4


^ permalink raw reply	[relevance 7%]

* Re: [PATCH v3 4/5] gdb/testsuite: Add gdb.arch/aarch64-mops-single-step.exp
  @ 2024-05-10 13:07  4%   ` Luis Machado
  0 siblings, 0 replies; 200+ results
From: Luis Machado @ 2024-05-10 13:07 UTC (permalink / raw)
  To: Thiago Jung Bauermann, gdb-patches; +Cc: Christophe Lyon

Thanks. Just one nit.

On 5/10/24 06:24, Thiago Jung Bauermann wrote:
> The testcase verifies that MOPS sequences are correctly single-stepped.
> ---
>  .../gdb.arch/aarch64-mops-single-step.c       |  73 ++++++++++
>  .../gdb.arch/aarch64-mops-single-step.exp     | 132 ++++++++++++++++++
>  2 files changed, 205 insertions(+)
>  create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-single-step.c
>  create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-single-step.exp
> 
> Changes in v3:
> - Renamed gdb.arch/aarch64-mops-atomic-inst.exp to
>   gdb.arch/aarch64-mops-single-step.exp.
> - Adjusted test to expect the MOPS sequence to reset back to the prologue
>   instruction.
> - Set size variable before the cpyf and cpy sequences, because after each
>   sequence the variable is set to zero.  This bug didn't affect the
>   effectiveness of the test.
> 
> Changes in v2:
> - Add prfm instruction after each MOPS sequence and look for it in the
>   testcase to verify that the sequence was stepped through (Suggested by
>   Christophe).
> 
> diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-single-step.c b/gdb/testsuite/gdb.arch/aarch64-mops-single-step.c
> new file mode 100644
> index 000000000000..4a27867d4b57
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/aarch64-mops-single-step.c
> @@ -0,0 +1,73 @@
> +/* This file is part of GDB, the GNU debugger.
> +
> +   Copyright 2024 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#define TEST_STRING "Just a test string."
> +#define BUF_SIZE sizeof(TEST_STRING)
> +
> +int
> +main (void)
> +{
> +  char source[BUF_SIZE] = TEST_STRING;
> +  char dest[BUF_SIZE];
> +  char *p, *q;
> +  long size, zero;
> +
> +  /* Note: The prfm instruction in the asm statements below is there just
> +     to allow the testcase to recognize when the PC is at the instruction
> +     right after the MOPS sequence.  */
> +
> +  p = dest;
> +  size = sizeof (dest);
> +  zero = 0;
> +  /* Break memset.  */
> +  /* memset implemented in MOPS instructions.  */
> +  __asm__ volatile ("setp [%0]!, %1!, %2\n\t"
> +		    "setm [%0]!, %1!, %2\n\t"
> +		    "sete [%0]!, %1!, %2\n\t"
> +		    "prfm pldl3keep, [%0, #0]\n\t"
> +		    : "+&r"(p), "+&r"(size)
> +		    : "r"(zero)
> +		    : "memory");
> +
> +  p = dest;
> +  q = source;
> +  size = sizeof (dest);
> +  /* Break memcpy.  */
> +  /* memcpy implemented in MOPS instructions.  */
> +  __asm__ volatile ("cpyfp [%0]!, [%1]!, %2!\n\t"
> +		    "cpyfm [%0]!, [%1]!, %2!\n\t"
> +		    "cpyfe [%0]!, [%1]!, %2!\n\t"
> +		    "prfm pldl3keep, [%0, #0]\n\t"
> +		    : "+&r" (p), "+&r" (q), "+&r" (size)
> +		    :
> +		    : "memory");
> +
> +  p = dest;
> +  q = source;
> +  size = sizeof (dest);
> +  /* Break memmove.  */
> +  /* memmove implemented in MOPS instructions.  */
> +  __asm__ volatile ("cpyp [%0]!, [%1]!, %2!\n\t"
> +		    "cpym [%0]!, [%1]!, %2!\n\t"
> +		    "cpye [%0]!, [%1]!, %2!\n\t"
> +		    "prfm pldl3keep, [%0, #0]\n\t"
> +		    : "+&r" (p), "+&r" (q), "+&r" (size)
> +		    :
> +		    : "memory");
> +
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-single-step.exp b/gdb/testsuite/gdb.arch/aarch64-mops-single-step.exp
> new file mode 100644
> index 000000000000..a6390d4bff7e
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/aarch64-mops-single-step.exp
> @@ -0,0 +1,132 @@
> +# Copyright 2024 Free Software Foundation, Inc.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +#
> +# This file is part of the GDB testsuite.
> +
> +# Test single stepping through MOPS (memory operations) instruction sequences.
> +
> +require allow_aarch64_mops_tests
> +
> +standard_testfile
> +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
> +	  [list debug additional_flags=-march=armv9.3-a]] } {
> +    return -1
> +}
> +
> +# INSTRUCTION should be just its mnemonic, without any arguments.
> +proc is_at_instruction { instruction } {
> +    global gdb_prompt hex
> +
> +    set test "pc points to $instruction"
> +    gdb_test_multiple {x/i $pc} $test {
> +	-re -wrap "=> $hex \[^\r\n\]+:\t$instruction\t\[^\r\n\]+" {
> +	    return 1
> +	}
> +	-re "\r\n$gdb_prompt $" {
> +	    return 0
> +	}
> +    }
> +
> +    return 0
> +}
> +
> +proc arrive_at_instruction { instruction } {
> +    set count 0
> +
> +    while { [is_at_instruction $instruction] != 1 } {
> +	gdb_test -nopass "stepi" ".*__asm__ volatile.*" \
> +	    "stepi #$count to reach $instruction"
> +	incr count
> +
> +	if { $count > 50 } {
> +	    fail "didn't reach $instruction"
> +	    return 0
> +	}
> +    }
> +
> +    return 1
> +}
> +
> +# If the inferior is reschedule to another CPU while a main or epilogue

s/reschedule/rescheduled

> +# instruction is executed, the OS resets the inferior back to the prologue
> +# instruction, so we need to allow for that possibility.
> +proc step_through_sequence { prefix } {
> +    set count 0
> +
> +    while { [is_at_instruction ${prefix}p] == 1 && $count < 50 } {
> +	incr count
> +
> +	# The stepi output isn't useful to detect whether we stepped over
> +	# the instruction.
> +	gdb_test "stepi" "\[^\r\n\]+" "step over ${prefix}p"
> +	if { [is_at_instruction ${prefix}m] == 1 } {
> +	    pass "stepped over ${prefix}p"
> +	} else {
> +	    fail "stepped over ${prefix}e"
> +	    return 0
> +	}
> +
> +	gdb_test "stepi" "\[^\r\n\]+" "step over ${prefix}m"
> +	if { [is_at_instruction ${prefix}e] == 1 } {
> +	    pass "stepped over ${prefix}m"
> +	} elseif { [is_at_instruction ${prefix}p] == 1 } {
> +	    # The inferior was rescheduled to another CPU.
> +	    pass "${prefix}m: reset back to prologue"
> +	    continue
> +	} else {
> +	    fail "stepped over ${prefix}m"
> +	    return 0
> +	}
> +
> +	gdb_test "stepi" "\[^\r\n\]+" "step over ${prefix}e"
> +	if { [is_at_instruction prfm] == 1 } {
> +	    pass "stepped over ${prefix}e"
> +	    return 1
> +	} elseif { [is_at_instruction ${prefix}p] == 1 } {
> +	    # The inferior was rescheduled to another CPU.
> +	    pass "${prefix}e: reset back to prologue"
> +	    continue
> +	}
> +    }
> +
> +    fail "step through $prefix sequence"
> +    return 0
> +}
> +
> +if ![runto_main] {
> +    return -1
> +}
> +
> +gdb_breakpoint ${srcfile}:[gdb_get_line_number "Break memset"]
> +gdb_breakpoint ${srcfile}:[gdb_get_line_number "Break memcpy"]
> +gdb_breakpoint ${srcfile}:[gdb_get_line_number "Break memmove"]
> +
> +gdb_continue_to_breakpoint "memset breakpoint"
> +
> +if { [arrive_at_instruction setp] } {
> +    step_through_sequence set
> +}
> +
> +gdb_continue_to_breakpoint "memcpy breakpoint"
> +
> +if { [arrive_at_instruction cpyfp] } {
> +    step_through_sequence cpyf
> +}
> +
> +gdb_continue_to_breakpoint "memmove breakpoint"
> +
> +if { [arrive_at_instruction cpyp] } {
> +    step_through_sequence cpy
> +}


^ permalink raw reply	[relevance 4%]

* Re: [PATCH] Pass stream to remote_console_output
  @ 2024-05-10 11:01  0% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-05-10 11:01 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: Tom Tromey

Tom Tromey <tromey@adacore.com> writes:

> I noticed that remote_target::rcmd did not pass its ui_file argument
> down to remote_console_output.  This patch fixes this oversight.

LGTM.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

> ---
>  gdb/remote.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index 55069559a60..6e568eb47b2 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -1521,7 +1521,7 @@ static ptid_t read_ptid (const char *buf, const char **obuf);
>  
>  static bool remote_read_description_p (struct target_ops *target);
>  
> -static void remote_console_output (const char *msg);
> +static void remote_console_output (const char *msg, ui_file *stream);
>  
>  static void remote_btrace_reset (remote_state *rs);
>  
> @@ -1750,7 +1750,10 @@ remote_target::remote_get_noisy_reply ()
>  	    }
>  	}
>        else if (buf[0] == 'O' && buf[1] != 'K')
> -	remote_console_output (buf + 1);	/* 'O' message from stub */
> +	{
> +	  /* 'O' message from stub */
> +	  remote_console_output (buf + 1, gdb_stdtarg);
> +	}
>        else
>  	return buf;		/* Here's the actual reply.  */
>      }
> @@ -7642,7 +7645,7 @@ remote_target::terminal_ours ()
>  }
>  
>  static void
> -remote_console_output (const char *msg)
> +remote_console_output (const char *msg, ui_file *stream)
>  {
>    const char *p;
>  
> @@ -7653,9 +7656,9 @@ remote_console_output (const char *msg)
>  
>        tb[0] = c;
>        tb[1] = 0;
> -      gdb_stdtarg->puts (tb);
> +      stream->puts (tb);
>      }
> -  gdb_stdtarg->flush ();
> +  stream->flush ();
>  }
>  
>  /* Return the length of the stop reply queue.  */
> @@ -8583,7 +8586,7 @@ remote_target::wait_ns (ptid_t ptid, struct target_waitstatus *status,
>  	    warning (_("Remote failure reply: %s"), rs->buf.data ());
>  	    break;
>  	  case 'O':		/* Console output.  */
> -	    remote_console_output (&rs->buf[1]);
> +	    remote_console_output (&rs->buf[1], gdb_stdtarg);
>  	    break;
>  	  default:
>  	    warning (_("Invalid remote reply: %s"), rs->buf.data ());
> @@ -8717,7 +8720,7 @@ remote_target::wait_as (ptid_t ptid, target_waitstatus *status,
>  	    break;
>  	  }
>  	case 'O':		/* Console output.  */
> -	  remote_console_output (buf + 1);
> +	  remote_console_output (buf + 1, gdb_stdtarg);
>  	  break;
>  	case '\0':
>  	  if (rs->last_sent_signal != GDB_SIGNAL_0)
> @@ -11993,7 +11996,8 @@ remote_target::rcmd (const char *command, struct ui_file *outbuf)
>        buf = rs->buf.data ();
>        if (buf[0] == 'O' && buf[1] != 'K')
>  	{
> -	  remote_console_output (buf + 1); /* 'O' message from stub.  */
> +	  /* 'O' message from stub.  */
> +	  remote_console_output (buf + 1, outbuf);
>  	  continue;
>  	}
>        packet_result result = packet_check_result (buf, false);
> -- 
> 2.44.0


^ permalink raw reply	[relevance 0%]

* [PATCH v5] Add a test for the gcore script
@ 2024-05-10 10:52  4% Alexandra Hájková
  0 siblings, 0 replies; 200+ results
From: Alexandra Hájková @ 2024-05-10 10:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: ahajkova

From: Alexandra Hájková <ahajkova@redhat.com>

It also tests the gcore script being run without its accessible
terminal.

This test was written by Jan Kratochvil a long time ago. I modernized
the test making it use various procs from lib/gdb.exp, reoirganising it
and added some comments.

Modify the gcore script to make it possible to pass the --data-directory to
it. This prevents a lot of these warnings:

Python Exception <class 'AttributeError'>: module 'gdb' has no attribute
'_handle_missing_debuginfo'

Tested by using make check-all-boards.

Co-Authored-By: Jan Kratochvil
---
v5:
- Use lower case for the data_directory_opt.
- Create data_directory_opt as an array to handle filenames containing
  spaces properly.
- Add more comments.
 gdb/doc/gdb.texinfo                |  2 +-
 gdb/gcore.in                       | 12 +++-
 gdb/testsuite/gdb.base/gcorebg.c   | 86 +++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/gcorebg.exp | 88 ++++++++++++++++++++++++++++++
 gdb/testsuite/lib/gdb.exp          | 17 ++++++
 5 files changed, 201 insertions(+), 4 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/gcorebg.c
 create mode 100644 gdb/testsuite/gdb.base/gcorebg.exp

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 61f91ef4ad6..590d55c1d56 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -50976,7 +50976,7 @@ Richard M. Stallman and Roland H. Pesch, July 1991.
 
 @format
 @c man begin SYNOPSIS gcore
-gcore [-a] [-o @var{prefix}] @var{pid1} [@var{pid2}...@var{pidN}]
+gcore [-a] [-o @var{prefix}] [-d @var{path}] @var{pid1} [@var{pid2}...@var{pidN}]
 @c man end
 @end format
 
diff --git a/gdb/gcore.in b/gdb/gcore.in
index 982c854eb70..1592c555251 100644
--- a/gdb/gcore.in
+++ b/gdb/gcore.in
@@ -27,7 +27,9 @@ prefix=core
 # to ensure gdb dumps all mappings (OS dependent).
 dump_all_cmds=()
 
-while getopts :ao: opt; do
+data_directory_opt=()
+
+while getopts :ao:d: opt; do
     case "$opt" in
         a)
             case "$OSTYPE" in
@@ -40,8 +42,11 @@ while getopts :ao: opt; do
         o)
             prefix=$OPTARG
             ;;
+        d)
+            data_directory_opt=("--data-directory" "$OPTARG")
+            ;;
         *)
-            echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] pid1 [pid2...pidN]"
+            echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] [-d path] pid1 [pid2...pidN]"
             exit 2
             ;;
     esac
@@ -51,7 +56,7 @@ shift $((OPTIND-1))
 
 if [ "$#" -eq "0" ]
 then
-    echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] pid1 [pid2...pidN]"
+    echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] [-d path] pid1 [pid2...pidN]"
     exit 2
 fi
 
@@ -98,6 +103,7 @@ do
 	# `</dev/null' to avoid touching interactive terminal if it is
 	# available but not accessible as GDB would get stopped on SIGTTIN.
 	"$binary_path/@GDB_TRANSFORM_NAME@" </dev/null \
+            "${data_directory_opt[@]}" \
 	    --nx --batch --readnever -iex 'set debuginfod enabled off' \
 	    -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
 	    "${dump_all_cmds[@]}" \
diff --git a/gdb/testsuite/gdb.base/gcorebg.c b/gdb/testsuite/gdb.base/gcorebg.c
new file mode 100644
index 00000000000..1e9ddbd8649
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gcorebg.c
@@ -0,0 +1,86 @@
+/* Copyright 2007-2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+#include <assert.h>
+
+/* Expects 4 arguments:
+
+   1. Either 'standard' or 'detached', where 'standard' tests
+   a general gcore script spawn with its controlling terminal available
+   and 'detached' tests gcore script spawn without its controlling
+   terminal available.
+   2. Path to the gcore script.
+   3. Path to the data-directory to pass to the gcore script.
+   4. The core file output name.  */
+
+int
+main (int argc, char **argv)
+{
+  pid_t pid = 0;
+  pid_t ppid;
+  char buf[1024*2 + 500];
+  int gotint, res;
+  int fd[2];
+
+  assert (argc == 5);
+
+  if (pipe(fd) == -1)
+    {
+      perror ("pipe err\n");
+      exit (1);
+    }
+  pid = fork ();
+
+  switch (pid)
+    {
+    case 0:
+      close (fd[0]);
+      if (strcmp (argv[1], "detached") == 0)
+	setpgrp ();
+      ppid = getppid ();
+      gotint = snprintf (buf, sizeof (buf), "%s -d %s -o %s %d",
+			 argv[2], argv[3], argv[4], (int) ppid);
+      assert (gotint < sizeof (buf));
+      res = system (buf);
+      assert (res != -1);
+      close(fd[1]);
+      break;
+
+    case -1:
+      close (fd[0]);
+      close (fd[1]);
+      perror ("fork err\n");
+      exit (1);
+      break;
+
+    default:
+      close (fd[1]);
+      /* Wait here until the child is done with gcore-ing us.  When the
+	 child has finished it will close its end of the pipe and this read
+	 call will return.  */
+      res = read (fd[0], buf, 1);
+      assert (res == 0);
+      close (fd[0]);
+      break;
+    }
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/gcorebg.exp b/gdb/testsuite/gdb.base/gcorebg.exp
new file mode 100644
index 00000000000..6269988133c
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gcorebg.exp
@@ -0,0 +1,88 @@
+# Copyright 2007-2024 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# This is a test for the gcore script (not the gcore command form
+# inside GDB).  It also tests the gcore script being run without its
+# accessible terminal.
+
+standard_testfile
+require {!is_remote host}
+require {!is_remote target}
+require has_gcore_script
+
+set corefile [standard_output_file ${testfile}.core]
+
+if {[build_executable "failed to build" $testfile ${srcfile}] == -1 } {
+     return -1
+}
+
+# Cleanup.
+
+proc core_clean {} {
+    global corefile
+
+    foreach file [glob -nocomplain [join [list $corefile *] ""]] {
+	verbose "Delete file $file" 1
+	remote_file target delete $file
+    }
+}
+core_clean
+
+# Generate the core file.
+proc test_body { detached } {
+    global binfile
+    global GCORE
+    global corefile
+    global GDB_DATA_DIRECTORY
+
+    with_test_prefix "detached = $detached" {
+	# We can't use gdb_test_multiple here because GDB is not started.
+	set res [remote_spawn target "$binfile $detached $GCORE $GDB_DATA_DIRECTORY $corefile"]
+	if { $res < 0 || $res == "" } {
+	    fail "Spawning gcore"
+	    return 1
+	}
+	pass "Spawned gcore"
+
+	set saw_corefile_created false
+	set testname "Spawned gcore finished"
+	remote_expect target 20 {
+	    timeout {
+		fail "$testname (timeout)"
+		remote_exec target "kill -9 -[exp_pid -i $res]"
+		return
+	    }
+	    -re "Saved corefile \[^\r\n\]+\r\n" {
+		set saw_corefile_created true
+		exp_continue
+	    }
+	    eof {
+		gdb_assert { $saw_corefile_created } $testname
+	    }
+	}
+
+	gdb_assert {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} "Core file generated by gcore"
+	core_clean
+    }
+}
+
+# First a general gcore script spawn with its controlling terminal available.
+
+test_body standard
+
+# And now gcore script spawn without its controlling terminal available.
+# It is spawned through `gcorebg.c' using setpgrp ().
+
+test_body detached
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 0d78691c381..97f84803880 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -158,6 +158,23 @@ load_lib gdb-utils.exp
 load_lib memory.exp
 load_lib check-test-names.exp
 
+# The path to the GCORE script to test.
+global GCORE
+if {![info exists GCORE]} {
+    set GCORE [findfile $base_dir/../../gdb/gcore]
+} else {
+    set GCORE ""
+}
+verbose "using GCORE = $GCORE" 2
+
+proc has_gcore_script {} {
+    if {[info exists ::GCORE]} {
+	return 1
+    } else {
+	return 0
+    }
+}
+
 # The path to the GDB binary to test.
 global GDB
 
-- 
2.44.0


^ permalink raw reply	[relevance 4%]

* Re: [PATCH v3] gdb: Change "list ." command's error when no debuginfo is available
  @ 2024-05-10  6:26  0%     ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-05-10  6:26 UTC (permalink / raw)
  To: Guinevere Larsen, Andrew Burgess, gdb-patches; +Cc: Simon Marchi, Eli Zaretskii

On 5/8/24 19:13, Guinevere Larsen wrote:
> On 5/8/24 11:25, Andrew Burgess wrote:
>> Guinevere Larsen <blarsen@redhat.com> writes:
>>
>>> From: Simon Marchi <simark@simark.ca>
>>>
>>> Currently, when a user tries to list the current location, there are 2
>>> different error messages that can happen, either:
>>>
>>>      (gdb) list .
>>>      No symbol table is loaded.  Use the "file" command.
>>> or
>>>      (gdb) list .
>>>      No debug information available to print source lines.
>>>
>>> The difference here is if gdb can find any symtabs at all or not, which
>>> is not something too important for end-users - and isn't informative at
>>> all. This commit changes it so that the error always says that there
>>> isn't debug information available, with these two variants:
>>>
>>>      (gdb) list .
>>>      Insufficient debug info for showing source lines at current PC 
>>> (0x55555555511d).
>>> or
>>>      (gdb) list .
>>>      Insufficient debug info for showing source lines at default 
>>> location.
>>>
>>> The difference now is if the inferior has started already, which is
>>> controlled by the user and may be useful.
>>>
>>> Unfortunately, it isn't as easy to differentiate if the symtab found for
>>> other list parameters is correct, so other invocations, such as "list +"
>>> still retain their original error message.
>>>
>>> Co-Authored-By: Simon Marchi <simark@simark.ca>
>>> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
>>> ---
>>> Changes for v3:
>>>    Changed error message to use Eli's suggestion
>>>    Added Eli's RB tag since he approved documentation changes
>>>
>>> Changes for v2:
>>>    Added NEWS entry, should have done that from the start oops.
>>>    Added test. This test aims to roughly recreate a situation where the
>>>      current function is in a spot with no debuginfo, and being called
>>>      from somewhere that has debuginfo.
>>>
>>> ---
>>>   gdb/NEWS                                      |  6 ++
>>>   gdb/cli/cli-cmds.c                            | 47 +++++++++----
>>>   .../gdb.base/list-dot-nodebug-extra.c         | 24 +++++++
>>>   gdb/testsuite/gdb.base/list-dot-nodebug.c     | 33 +++++++++
>>>   gdb/testsuite/gdb.base/list-dot-nodebug.exp   | 67 +++++++++++++++++++
>>>   5 files changed, 163 insertions(+), 14 deletions(-)
>>>   create mode 100644 gdb/testsuite/gdb.base/list-dot-nodebug-extra.c
>>>   create mode 100644 gdb/testsuite/gdb.base/list-dot-nodebug.c
>>>   create mode 100644 gdb/testsuite/gdb.base/list-dot-nodebug.exp
>>>
>>> diff --git a/gdb/NEWS b/gdb/NEWS
>>> index feb3a37393a..99909414796 100644
>>> --- a/gdb/NEWS
>>> +++ b/gdb/NEWS
>>> @@ -36,6 +36,12 @@ set unwindonsignal on|off
>>>   show unwindonsignal
>>>     These commands are now aliases for the new set/show 
>>> unwind-on-signal.
>>> +list .
>>> +  When using the command "list ." in a location that has no debug 
>>> information
>>> +  or no file loaded, GDB now says that there is no debug information 
>>> to print
>>> +  lines.  This makes it more obvious that there is no information, 
>>> as opposed
>>> +  to implying there is no inferior loaded.
>>> +
>>>   * New commands
>>>   info missing-debug-handler
>>> diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
>>> index 3afe2178199..ee3318d7910 100644
>>> --- a/gdb/cli/cli-cmds.c
>>> +++ b/gdb/cli/cli-cmds.c
>>> @@ -1235,37 +1235,39 @@ list_command (const char *arg, int from_tty)
>>>     /* Pull in the current default source line if necessary.  */
>>>     if (arg == NULL || ((arg[0] == '+' || arg[0] == '-' || arg[0] == 
>>> '.') && arg[1] == '\0'))
>>>       {
>>> -      set_default_source_symtab_and_line ();
>>> -      symtab_and_line cursal = get_current_source_symtab_and_line ();
>>> -
>>>         /* If this is the first "list" since we've set the current
>>>        source line, center the listing around that line.  */
>>>         if (get_first_line_listed () == 0 && (arg == nullptr || 
>>> arg[0] != '.'))
>>>       {
>>> -      list_around_line (arg, cursal);
>>> +      set_default_source_symtab_and_line ();
>>> +      list_around_line (arg, get_current_source_symtab_and_line ());
>>>       }
>>>         /* "l" and "l +" lists the next few lines, unless we're 
>>> listing past
>>>        the end of the file.  */
>>>         else if (arg == nullptr || arg[0] == '+')
>>>       {
>>> +      set_default_source_symtab_and_line ();
>>> +      const symtab_and_line cursal = 
>>> get_current_source_symtab_and_line ();
>>>         if (last_symtab_line (cursal.symtab) >= cursal.line)
>>>           print_source_lines (cursal.symtab,
>>>                   source_lines_range (cursal.line), 0);
>>>         else
>>> -        {
>>> -          error (_("End of the file was already reached, use \"list 
>>> .\" to"
>>> -               " list the current location again"));
>>> -        }
>>> +        error (_("End of the file was already reached, use \"list 
>>> .\" to"
>>> +             " list the current location again"));
>>>       }
>>>         /* "l -" lists previous ten lines, the ones before the ten just
>>>        listed.  */
>>>         else if (arg[0] == '-')
>>>       {
>>> +      set_default_source_symtab_and_line ();
>>> +      const symtab_and_line cursal = 
>>> get_current_source_symtab_and_line ();
>>> +
>>>         if (get_first_line_listed () == 1)
>>>           error (_("Already at the start of %s."),
>>>              symtab_to_filename_for_display (cursal.symtab));
>>> +
>>>         source_lines_range range (get_first_line_listed (),
>>>                       source_lines_range::BACKWARD);
>>>         print_source_lines (cursal.symtab, range, 0);
>>> @@ -1274,25 +1276,42 @@ list_command (const char *arg, int from_tty)
>>>         /* "list ." lists the default location again.  */
>>>         else if (arg[0] == '.')
>>>       {
>>> +      std::optional<const symtab_and_line> cursal;
>>>         if (target_has_stack ())
>>>           {
>>>             /* Find the current line by getting the PC of the currently
>>>            selected frame, and finding the line associated to it.  */
>>>             frame_info_ptr frame = get_selected_frame (nullptr);
>>>             CORE_ADDR curr_pc = get_frame_pc (frame);
>>> -          cursal = find_pc_line (curr_pc, 0);
>>> +          cursal.emplace (find_pc_line (curr_pc, 0));
>>> +
>>> +          if (cursal->symtab == nullptr)
>>> +        error
>>> +          (_("Insufficient debug info for showing source lines at "
>>> +             "current PC (%s)."), paddress (get_frame_arch (frame),
>>> +                            curr_pc));
>>>           }
>>>         else
>>>           {
>>>             /* The inferior is not running, so reset the current source
>>>            location to the default (usually the main function).  */
>>>             clear_current_source_symtab_and_line ();
>>> -          set_default_source_symtab_and_line ();
>>> -          cursal = get_current_source_symtab_and_line ();
>>> +          try
>>> +        {
>>> +          set_default_source_symtab_and_line ();
>>> +        }
>>> +          catch (const gdb_exception &e)
>>> +        {
>>> +          error (_("Insufficient debug info for showing source "
>>> +               "lines at default location"));
>>> +        }
>>> +          cursal.emplace (get_current_source_symtab_and_line ());
>>> +
>>> +          gdb_assert (cursal->symtab != nullptr);
>>>           }
>>> -      if (cursal.symtab == nullptr)
>>> -        error (_("No debug information available to print source 
>>> lines."));
>>> -      list_around_line (arg, cursal);
>>> +
>>> +      list_around_line (arg, *cursal);
>>> +
>>>         /* Set the repeat args so just pressing "enter" after using 
>>> "list ."
>>>            will print the following lines instead of the same lines 
>>> again. */
>>>         if (from_tty)
>>> diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug-extra.c 
>>> b/gdb/testsuite/gdb.base/list-dot-nodebug-extra.c
>>> new file mode 100644
>>> index 00000000000..c3d2416e70d
>>> --- /dev/null
>>> +++ b/gdb/testsuite/gdb.base/list-dot-nodebug-extra.c
>>> @@ -0,0 +1,24 @@
>>> +/* This testcase is part of GDB, the GNU debugger.
>>> +
>>> +   Copyright 2024 Free Software Foundation, Inc.
>>> +
>>> +   This program is free software; you can redistribute it and/or modify
>>> +   it under the terms of the GNU General Public License as published by
>>> +   the Free Software Foundation; either version 3 of the License, or
>>> +   (at your option) any later version.
>>> +
>>> +   This program is distributed in the hope that it will be useful,
>>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> +   GNU General Public License for more details.
>>> +
>>> +   You should have received a copy of the GNU General Public License
>>> +   along with this program.  If not, see 
>>> <http://www.gnu.org/licenses/>.  */
>>> +
>>> +extern void bar(int *);
>> Space missing after 'bar' here.
>>
>>> +
>>> +void
>>> +foo (int *x)
>>> +{
>>> +  bar (x);
>>> +}
>>> diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug.c 
>>> b/gdb/testsuite/gdb.base/list-dot-nodebug.c
>>> new file mode 100644
>>> index 00000000000..b37c3561c41
>>> --- /dev/null
>>> +++ b/gdb/testsuite/gdb.base/list-dot-nodebug.c
>>> @@ -0,0 +1,33 @@
>>> +/* This testcase is part of GDB, the GNU debugger.
>>> +
>>> +   Copyright 2024 Free Software Foundation, Inc.
>>> +
>>> +   This program is free software; you can redistribute it and/or modify
>>> +   it under the terms of the GNU General Public License as published by
>>> +   the Free Software Foundation; either version 3 of the License, or
>>> +   (at your option) any later version.
>>> +
>>> +   This program is distributed in the hope that it will be useful,
>>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> +   GNU General Public License for more details.
>>> +
>>> +   You should have received a copy of the GNU General Public License
>>> +   along with this program.  If not, see 
>>> <http://www.gnu.org/licenses/>.  */
>>> +
>>> +extern void foo (int *x);
>>> +
>>> +int x;
>>> +
>>> +void
>>> +bar (int *p)
>>> +{
>>> +  *p++;
>>> +}
>>> +
>>> +int
>>> +main ()
>>> +{
>>> +  foo (&x);
>>> +  return 0;
>>> +}
>>> diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug.exp 
>>> b/gdb/testsuite/gdb.base/list-dot-nodebug.exp
>>> new file mode 100644
>>> index 00000000000..7c4144da8ab
>>> --- /dev/null
>>> +++ b/gdb/testsuite/gdb.base/list-dot-nodebug.exp
>>> @@ -0,0 +1,67 @@
>>> +# Copyright 2005-2024 Free Software Foundation, Inc.
>>> +
>>> +# This program is free software; you can redistribute it and/or modify
>>> +# it under the terms of the GNU General Public License as published by
>>> +# the Free Software Foundation; either version 3 of the License, or
>>> +# (at your option) any later version.
>>> +#
>>> +# This program is distributed in the hope that it will be useful,
>>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> +# GNU General Public License for more details.
>>> +#
>>> +# You should have received a copy of the GNU General Public License
>>> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
>>> +
>>> +# This test is here to confirm that the command "list ." will print the
>>> +# same message if GDB detects no debug information at all, or 
>>> detects some
>>> +# but nothing for the current objfile.
>>> +
>>> +require !use_gdb_stub
>>> +
>>> +set linkflags [list additional_flags="-static"]
>>> +
>>> +if { ![gdb_can_simple_compile static-libc \
>>> +       {
>>> +           void main (void) { return 0; }
>>> +       } \
>>> +       executable $linkflags] } {
>>> +    untested "Can't statically link"
>>> +    return -1
>>> +}
>>> +
>>> +standard_testfile .c -extra.c
>>> +set objmainfile [standard_output_file ${testfile}-main.o]
>>> +set objextrafile [standard_output_file ${testfile}-extra.o]
>>> +
>>> +if {[gdb_compile "$srcdir/$subdir/$srcfile" $objmainfile object 
>>> {nodebug}] != "" } {
>>> +    untested "couldn't compile main file into object"
>>> +    return -1
>>> +}
>> The gdb_compile line seems redundant, you recompile the test binary
>> within the foreach loop.  With this gone the objmainfile and
>> objextrafile variables seem redundant too.
>>
>>> +
>>> +foreach_with_prefix debug {"none" "some"} {
>>> +
>>> +    set flags "nodebug"
>>> +    if {$debug == "some"} {
>>> +    set flags "debug"
>>> +    }
>>> +
>>> +    if {[prepare_for_testing_full "failed to prepare" \
>>> +        [list ${testfile}-${debug} $linkflags \
>>> +        $srcfile [list nodebug] \
>>> +        $srcfile2 [list $debug]]]} {
>>> +    return -1
>>> +    }
>>> +
>>> +    gdb_test "list ." \
>>> +    "No debug information available to print source lines.*" \
>> I would replace this pattern with:
>>
>>     "^Insufficient debug info for showing source lines at default 
>> location" \
>>
>> this extends the text you used in your earlier reply, but avoids using
>> '.*'.  I think it's better to avoid '.*' unless it's essential.  With
>> this patter we're saying we expect that line, and that line only.
>> Absolutely no other output.
>>
>>> +    "print before start"
>>> +
>>> +    if { ![runto bar] } {
>>> +    return -1
>>> +    }
>>> +
>>> +    gdb_test "list ." \
>>> +    "No debug information available to print source lines at current 
>>> PC.*" \
>> And here:
>>
>>     "^Insufficient debug info for showing source lines at current PC 
>> \\($::hex\\)\\." \
>>
>> With these testsuite fixes, and the other things you changed in your
>> earlier reply:
>>
>> Approved-By: Andrew Burgess <aburgess@redhat.com>
> Thanks, pushed!
> 
 >

I run into fails in the new test-case:
...
FAIL: gdb.base/list-dot-nodebug.exp: debug=none: print before start
FAIL: gdb.base/list-dot-nodebug.exp: debug=some: print before start
...

Filed here ( https://sourceware.org/bugzilla/show_bug.cgi?id=31721 ).

Thanks,
- Tom


^ permalink raw reply	[relevance 0%]

* Re: [PATCH 09/12] gdb_target_is_native -> gdb_protocol_is_native
  @ 2024-05-09 18:44  0%                     ` Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-05-09 18:44 UTC (permalink / raw)
  To: Pedro Alves, Tom Tromey; +Cc: gdb-patches

On 5/9/24 17:49, Pedro Alves wrote:
> On 2024-05-09 16:01, Bernd Edlinger wrote:
>> On 5/9/24 15:31, Pedro Alves wrote:
>>>
>>> On 2024-05-09 14:19, Bernd Edlinger wrote:
>>>> Hmm, okay, it is better than now, 
>>>
>>> Indeed, seems strictly better.  Some tests that are meant for the native target are now properly
>>> skipped.
>>>
>>>> but the test casese that are affected, would probably
>>>> be broken by this change, if my target toolchain would either have the -linux in the name,
>>>> or the newlib would have a sleep and/or support the #include <sys/mman.h>.
>>>
>>> I am afraid I don't know what you mean by this.  Why would they be broken?  Can you clarify?
>>
>> What I mean is this:
>>
>> there are in total 44 test cases failed to compile because of undefined reference to sleep, usleep or nanosleep
>> with your patch it is now one less.
>>
>> But it would be piece of cake to implement some functions like
>> sleep(), usleep(), and nanosleep in the newlib, and then make the simulator simulate it.
>>
>> Likewise there are currently 5 test cases failed to compile because of missing sys/mman.h header,
>> and with your patch it will be one less, but what if we want to add that to the
>> simulator, why cant we simulate a linux O/S?
>>
>> What is so special in the one test case that changed the behavior, that
>> explains why the other 4 are good enough to try to include, and see if <sys/mman.h> works?
>>
> 
> The gdb.base/load-command.exp testcase just doesn't make sense to test with the native
> target, since with the native target, you don't use the "load" command to load programs.
> So the testcase checks for that:
> 
> if [gdb_protocol_is_native] {
>     unsupported "the native target does not support the load command"
>     return
> }
> 
> Normally, a testcase that checks whether it is testing with the native target does so because it is
> testing some feature of the native target (the ptrace support, etc.), and so such an early check
> isn't that much about whether sleep or sys/mman.h exists (they don't exist on native Windows,
> for example, and there are native-only tests that you'd still want to run there).
> 
> If a testcase should run against the sim target and would no longer run because we set
> gdb_protocol, then that would be a problem with the testcase itself, for using the wrong
> predicate to skip itself.  We've had plenty of cases of testcases using the wrong
> predicate over the years, that is something that we're fixing pretty frequently, so
> please don't be surprised if we need to do that after this change too.
> 
> Looking at gdb.base/many-headers.exp for example (the first in your previous message
> that shows compile errors), it has:
> 
> if { [target_info gdb_protocol] != "" } {
>     # Even though the feature under features being tested are supported by
>     # gdbserver, the way this test is written doesn't make it easy with a
>     # remote target.
>     unsupported "not native"
>     return
> }
> 
> Note the comment -- it is saying to skip testing on remote, but then it skips
> on any board that sets gdb_protocol to anything (meaning, not native).
> If this truly should only be skipped with remote targets, then it should instead
> do this:
> 
> require gdb_protocol_is_remote
> 
> which is equivalent to:
> 
>   if { [target_info gdb_protocol] == "remote" || [target_info gdb_protocol] == "extended-remote" } {
>      return
>   }
> 
> But, actually looking at the testcase, we see that it launches a program outside gdb, so that
> the program crashes and generates a core (core_find), and then debugs the core under gdb,
> with GDB stack limited to 4MB.  From the commit's log (31aceee86308), it's the equivalent
> of doing:
> 
>     $ ulimit -s 4096
>     $ gdb -batch ./a.out core.saved
>     [New LWP 19379]
>     Segmentation fault (core dumped)
>     ...
> 
> So, I don't really understand what the "features being tested are supported by gdbserver"
> remark is alluding to, since gdbserver does not support loading cores.  But then again,
> the test doesn't even connect to the native target nor the remote target anyhow.  So
> we could let the testcase run when testing against a gdbserver board anyhow.
> 
> Maybe what the comment is trying to say is, not easy to test with a "remote target"
> in dejagnu sense, i.e., when you have to connect to a remote host board running on a
> separate system, as in that scenario it's not easy to set ulimit.  Is so, a better
> predicate to check would be "require !is_remote host" or "require isnative".
> 
> A similar analysis would have to be done to the other testcases.

Ah, okay, thanks for the explanation.

I was probably confused that sim looks an feels like a kind of native target,
but it supports the load command, and the test cases can read and write
local files, etc.  Therefore it is of course easy to fix things in the wrong way.
So I agree with your patch, and that any fallout can be fixed later
in the test cases when necessary.


Thanks
Bernd.

^ permalink raw reply	[relevance 0%]

* [PATCH v4] [gdb/testsuite] New test: gdb.base/check-errno.exp
@ 2024-05-09  2:42  1% Kevin Buettner
  0 siblings, 0 replies; 200+ results
From: Kevin Buettner @ 2024-05-09  2:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner, Tom de Vries

Printing the value of 'errno' from GDB is sometimes problematic.  The
situation has improved in recent years, though there are still
scenarios for which "print errno" doesn't work.

The test, gdb.base/check-errno.exp, introduced by this commit,
tests whether or not GDB can print errno using a binary compiled
in the following different ways:

- default: no switches aside from -g (and whatever else is added by the
  testing framework)
- macros: macro info is included in the debuginfo; this is enabled by
  using -g3 when using gcc or clang
- static: statically linked binary
- static-macros: statically linked binary w/ macro definitions included
  in debuginfo
- pthreads: libpthread linked binary
- pthreads-macros: libpthread linked binary w/ macro definitions included
  in debuginfo
- pthreads-static: Statically linked against libpthread
- pthreads-static-macros: Statically linked against libpthread w/ macro
  definitions

For each of these, the test also creates a corefile, then loads the
corefile and attempts to print errno again.

Additionally, the test checks that a "masking" errno declared as a
local variable will print correctly.

On Linux, if the machine is missing glibc debuginfo (or you have
debuginfod disabled), it's likely you'll see:

    (gdb) print errno
    'errno' has unknown type; cast it to its declared type

But if you add a cast, the value of errno is often available:

    (gdb) print (int) errno
    $1 = 42

The test detects this situation along with several others and does
'setup_xfail' for tests that will almost certainly fail.  It could be
argued that some of these ought to be KFAILs due to deficiencies in
GDB, but I'm not entirely certain which, if any, are fixable yet.

On Fedora 39, without glibc debuginfo, there are no failures, but
I do see the following XFAILS:

XFAIL: gdb.base/check-errno.exp: default: print errno
XFAIL: gdb.base/check-errno.exp: default: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: macros: print errno
XFAIL: gdb.base/check-errno.exp: macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static: print errno
XFAIL: gdb.base/check-errno.exp: static: print (int) errno
XFAIL: gdb.base/check-errno.exp: static: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static-macros: print errno
XFAIL: gdb.base/check-errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads: print errno
XFAIL: gdb.base/check-errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/check-errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: check errno value from corefile

On Fedora 39, with glibc debug info, but without libc.a (for static
linking), there are 2 XFAILs, 2 UNSUPPORTED tests, and 4 UNTESTED
tests.

So, even when testing in less than ideal conditions, either due to lack
of glibc debuginfo or lack of a libc to link against to make a static
binary, there are no failures.

With glibc debuginfo installed, on Fedora 38, Fedora 39, Fedora 40,
Fedora rawhide (41), and Ubuntu 22.04.1 LTS, I see these XFAILs:

XFAIL: gdb.base/check-errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static: print errno
XFAIL: gdb.base/check-errno.exp: static: print (int) errno
XFAIL: gdb.base/check-errno.exp: static: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static-macros: print errno
XFAIL: gdb.base/check-errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/check-errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: check errno value from corefile

On FreeBSD 13.1, the total number of XFAILs are fewer, and could be
even better still if it had debug info for glibc:

XFAIL: gdb.base/check-errno.exp: default: print errno
XFAIL: gdb.base/check-errno.exp: default: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: macros: print errno
XFAIL: gdb.base/check-errno.exp: macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads: print errno
XFAIL: gdb.base/check-errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: check errno value from corefile

Starting with glibc-2.34, most of the pthreads library has been
incorporated into libc, so finding thread-local variables using
libthread_db is possible for several scenarios in which it previously
wasn't.  But, prior to this, accessing errno for the default scenario
was a problem.  This is borne out by running this new test on Fedora
33, which uses glibc-2.33:

XFAIL: gdb.base/check-errno.exp: default: print errno
XFAIL: gdb.base/check-errno.exp: default: print (int) errno
XFAIL: gdb.base/check-errno.exp: default: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static: print errno
XFAIL: gdb.base/check-errno.exp: static: print (int) errno
XFAIL: gdb.base/check-errno.exp: static: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static-macros: print errno
XFAIL: gdb.base/check-errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: check errno value from corefile

In the v3 version of this test, Tom de Vries tested on openSUSE Leap
15.5 and found a number of cases which showed a FAIL instead of an
XFAIL.  I've fixed those now.  On Leap 15.5, which uses glibc-2.31,
with glibc debug info, I now see:

XFAIL: gdb.base/check-errno.exp: default: print errno
XFAIL: gdb.base/check-errno.exp: default: print (int) errno
XFAIL: gdb.base/check-errno.exp: default: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static: print errno
XFAIL: gdb.base/check-errno.exp: static: print (int) errno
XFAIL: gdb.base/check-errno.exp: static: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/check-errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: check errno value from corefile

On Leap 15.5, with glibc debuginfo missing, the results are a little
worse:

XFAIL: gdb.base/check-errno.exp: default: print errno
XFAIL: gdb.base/check-errno.exp: default: print (int) errno
XFAIL: gdb.base/check-errno.exp: default: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: macros: print errno
XFAIL: gdb.base/check-errno.exp: macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static: print errno
XFAIL: gdb.base/check-errno.exp: static: print (int) errno
XFAIL: gdb.base/check-errno.exp: static: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads: print errno
XFAIL: gdb.base/check-errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/check-errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static: print errno
XFAIL: gdb.base/check-errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/check-errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/check-errno.exp: pthreads-static-macros: check errno value from corefile

So, bottom line, this test does not introduce any new failures on the
platforms on which I've tested, but the XFAILs are certainly unfortunate.
Some aren't fixable - e.g. when attempting to make a function call while
debugging a core file - but I think that some of them are.  I'm using
this new test case as a starting point for investigating problems with
printing errno.

Co-Authored-By: Jan Kratochvil
---
 gdb/testsuite/gdb.base/check-errno.c   |  37 ++++
 gdb/testsuite/gdb.base/check-errno.exp | 250 +++++++++++++++++++++++++
 2 files changed, 287 insertions(+)
 create mode 100644 gdb/testsuite/gdb.base/check-errno.c
 create mode 100644 gdb/testsuite/gdb.base/check-errno.exp

diff --git a/gdb/testsuite/gdb.base/check-errno.c b/gdb/testsuite/gdb.base/check-errno.c
new file mode 100644
index 00000000000..c6835a866e8
--- /dev/null
+++ b/gdb/testsuite/gdb.base/check-errno.c
@@ -0,0 +1,37 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+
+static void shadow_errno ();
+
+int main ()
+{
+  errno = 42;
+
+  shadow_errno ();	/* main-breakpoint */
+  return 0;
+}
+
+#undef errno
+static void
+shadow_errno ()
+{
+  int errno = 36;
+
+  return;		/* shadow_errno-breakpoint */
+}
diff --git a/gdb/testsuite/gdb.base/check-errno.exp b/gdb/testsuite/gdb.base/check-errno.exp
new file mode 100644
index 00000000000..7b3894c6fa1
--- /dev/null
+++ b/gdb/testsuite/gdb.base/check-errno.exp
@@ -0,0 +1,250 @@
+# Copyright 2024 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# GNU General Public License for more details.
+
+# Check that errno can be accessed by GDB under a variety of
+# circumstances.
+#
+# The challenge with GDB accessing errno is that, on modern systems,
+# errno is a variable in thread-local storage.  So, if GDB's access to
+# thread local storage is broken or unavailable, some of these tests
+# could fail.  On Linux, this is/was known to happen on systems with
+# older versions of glibc as well as when debugging statically linked
+# binaries.
+#
+# Another possibility is that the environment lacks sufficient
+# type information to print errno.  This can happen for the errno
+# variable itself or when the debuginfo contains a macro for errno
+# which refers to a function lacking type information.
+#
+# When debugging core files, access to errno might not be possible
+# both due to the situations described earlier along with the fact
+# that inferior function calls are not possible (for the cases in
+# which errno is a macro which calls a function returning errno's
+# address).
+#
+# It's also possible for a program to declare errno in an inner scope
+# causing the thread-local errno to be shadowed.  GDB should still
+# correctly print the masking errno for this case.
+#
+# At the time that this test was written, on GNU/Linux and on FreeBSD,
+# there were always scenarios in which printing errno was problematic. 
+# This test attempts to identify the problem cases and set up xfails
+# for them.  So, hopefully, there should be no actual failures.  But
+# the "expected" failures encountered by by running this test do
+# genuinely illustrate problems that a user might encounter while
+# attempting to print errno.
+
+standard_testfile
+
+proc do_tests {{do_xfail_cast 0} {do_xfail 0} {do_xfail_core_test 0}} {
+    clean_restart $::binfile
+    runto_main
+
+    gdb_breakpoint [gdb_get_line_number "main-breakpoint"]
+    gdb_continue_to_breakpoint "main-breakpoint"
+
+    # Whether or not "print errno" will work often depends on the
+    # debuginfo available.  We can make some inferences about whether
+    # some of the tests should have xfail set-up by looking at the
+    # output of "ptype errno".  This test is set up to always pass
+    # even for less than ideal outputs, because the point is to set up
+    # the xfail(s).
+    set test "ptype errno"
+    gdb_test_multiple $test $test {
+	-re "type = int\r\n$::gdb_prompt $" {
+	    pass $test
+	}
+	-re "type = .*no debug info.*$::gdb_prompt $" {
+	    pass $test
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+	}
+	-re ".*Cannot find thread-local variables on this target.*$::gdb_prompt $" {
+	    pass $test
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+	    set do_xfail_cast 1
+	}
+	-re ".*has unknown return type; cast the call to its declared return type.*$::gdb_prompt $" {
+
+	    # On Linux, using -g3, which causes macro information to
+	    # be included in the debuginfo, errno might be defined as
+	    # follows:
+	    #
+	    #   #define errno (*__errno_location ())
+	    #
+	    # So, when we do "ptype errno", due to macro expansion,
+	    # this ends up being "ptype (*__errno_location ())".  So
+	    # the call to __errno_location (or something similar on
+	    # other OSes) is the call mentioned in the error message.
+
+	    pass $test
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+
+	    set do_xfail_cast 1
+	}
+	-re "^.*$::gdb_prompt" {
+	    pass $test
+	}
+    }
+
+    # If errno is defined as a macro that contains an obvious function
+    # call, it won't work when debugging a core file.
+    set test "info macro errno"
+    gdb_test_multiple $test $test {
+	-re "Defined at.*\[\r\n\]#define.*\\\(\\\).*$::gdb_prompt $" {
+	    set do_xfail_core_test 1
+	    pass $test
+	}
+	-re "Defined at.*\[\r\n\]#define.*$::gdb_prompt $" {
+	    pass $test
+	}
+	-re "The symbol .errno. has no definition.*$::gdb_prompt $" {
+	    pass $test
+	}
+	-re "^.*$::gdb_prompt" {
+	    pass $test
+	}
+    }
+
+    # Sometimes, "ptype errno" will ferret out that thread local
+    # variables aren't accessible, but sometimes it won't.  Dig deeper
+    # by trying to access memory using the "x/d" command.  Again, the
+    # point here is to set up an xfail for the later tests, so we pass
+    # this test no matter what the output is.
+    set test "x/d &errno"
+    gdb_test_multiple $test $test {
+	-re ".*Cannot find thread-local variables on this target.*$::gdb_prompt $" {
+	    pass $test
+	    set do_xfail 1
+	    set do_xfail_core_test 1
+	    set do_xfail_cast 1
+	}
+	-re "^.*$::gdb_prompt" {
+	    pass $test
+	}
+    }
+
+    if $do_xfail {
+	setup_xfail *-*-*
+    }
+    gdb_test "print errno" ".* = 42"
+
+    if $do_xfail_cast {
+	setup_xfail *-*-*
+    }
+    gdb_test "print (int) errno" ".* = 42"
+
+    set corefile ${::binfile}.core
+    set core_supported [gdb_gcore_cmd $corefile "save corefile"]
+    # Normally, we'd check core_supported here and return if it's
+    # not, but we'll defer that until after the shadow test.
+
+    gdb_breakpoint [gdb_get_line_number "shadow_errno-breakpoint"]
+    gdb_continue_to_breakpoint "shadow_errno-breakpoint"
+
+    # This test demonstrates why a simple hack to GDB for printing
+    # errno is a bad idea.  (The hack was to intercept the string
+    # "errno" in process_print_command_args() and replace it with
+    # "*(*(int *(*)(void)) __errno_location) ()".)
+    gdb_test "print errno" ".* = 36" "print masking errno"
+
+    # Finish test early if no core file was made.
+    if !$core_supported {
+	return
+    }
+
+    clean_restart $::binfile
+
+    set core_loaded [gdb_core_cmd $corefile "load corefile"]
+    if { $core_loaded == -1 } {
+	return
+    }
+    if $do_xfail_core_test {
+	setup_xfail *-*-*
+    }
+    gdb_test "print errno" ".* = 42" "check errno value from corefile"
+}
+
+set binprefix $binfile
+
+with_test_prefix "default" {
+    set binfile $binprefix-default
+    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "macros" {
+    set binfile $binprefix-macros
+    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug macros}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "static" {
+    set binfile $binprefix-static
+    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-static"}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "static-macros" {
+    set binfile $binprefix-static-macros
+    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug macros "additional_flags=-static"}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "pthreads" {
+    set binfile $binprefix-pthreads
+    if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "pthreads-macros" {
+    set binfile $binprefix-pthreads-macros
+    if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug macros}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "pthreads-static" {
+    set binfile $binprefix-pthreads-static
+    if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-static"}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
+
+with_test_prefix "pthreads-static-macros" {
+    set binfile $binprefix-pthreads-static-macros
+    if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug macros "additional_flags=-static"}] != "" } {
+	untested "failed to compile"
+    } else {
+	do_tests
+    }
+}
-- 
2.44.0


^ permalink raw reply	[relevance 1%]

* [PATCH] gdb: add a new build_id_equal function
@ 2024-05-08 15:27  5% Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-05-08 15:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

Add two versions of a new function build_id_equal which can be used to
compare build-ids, then make use of these functions in GDB.  It seems
better to have a specific function for the task of comparing build-ids
rather than having a length check followed by a memcmp call.

There should be no user visible changes after this commit.
---
 gdb/build-id.c |  3 +--
 gdb/build-id.h | 26 ++++++++++++++++++++++++++
 gdb/exec.c     |  6 ++----
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/gdb/build-id.c b/gdb/build-id.c
index d1ebd8d37d7..e08a29ee1d3 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -62,8 +62,7 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
   if (found == NULL)
     warning (_("File \"%s\" has no build-id, file skipped"),
 	     bfd_get_filename (abfd));
-  else if (found->size != check_len
-	   || memcmp (found->data, check, found->size) != 0)
+  else if (!build_id_equal (found, check_len, check))
     warning (_("File \"%s\" has a different build-id, file skipped"),
 	     bfd_get_filename (abfd));
   else
diff --git a/gdb/build-id.h b/gdb/build-id.h
index 15bd8a964dc..c5f20f8782e 100644
--- a/gdb/build-id.h
+++ b/gdb/build-id.h
@@ -70,4 +70,30 @@ build_id_to_string (const bfd_build_id *build_id)
   return bin2hex (build_id->data, build_id->size);
 }
 
+/* Compare the content of two build-ids.  One build-id (A) is passed as a
+   build-id pointer, while the second is passed using BUILD_ID_LEN and
+   BUILD_ID_DATA.  Return true if the build-ids match, otherwise false.  */
+
+static inline bool
+build_id_equal (const bfd_build_id *a, const bfd_size_type build_id_len,
+		const bfd_byte *build_id_data)
+{
+  gdb_assert (a != nullptr);
+  gdb_assert (build_id_data != nullptr);
+
+  return (a->size == build_id_len
+	  && memcmp (a->data, build_id_data, a->size) == 0);
+}
+
+/* Like the above, but take two build-id pointers A and B.  */
+
+static inline bool
+build_id_equal (const bfd_build_id *a, const bfd_build_id *b)
+{
+  gdb_assert (a != nullptr);
+  gdb_assert (b != nullptr);
+
+  return build_id_equal (a, b->size, b->data);
+}
+
 #endif /* BUILD_ID_H */
diff --git a/gdb/exec.c b/gdb/exec.c
index 3d392b198a1..88915260d60 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -253,10 +253,8 @@ validate_exec_file (int from_tty)
 
 	  if (target_exec_file_build_id != nullptr)
 	    {
-	      if (exec_file_build_id->size == target_exec_file_build_id->size
-		  && memcmp (exec_file_build_id->data,
-			     target_exec_file_build_id->data,
-			     exec_file_build_id->size) == 0)
+	      if (build_id_equal (exec_file_build_id,
+				  target_exec_file_build_id))
 		{
 		  /* Match.  */
 		  return;

base-commit: 868883583e7520ff1bd99fcb224d2b33a990edff
-- 
2.25.4


^ permalink raw reply	[relevance 5%]

* [PATCH] gdb: more filename styling
@ 2024-05-08 15:00  7% Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-05-08 15:00 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

I spotted a few places in solib.c and build-id.c where we could apply
file name styling.

Other than the extra styling, there should be no user visible changes
after this commit.
---
 gdb/build-id.c | 10 ++++++----
 gdb/solib.c    | 16 ++++++++++------
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/gdb/build-id.c b/gdb/build-id.c
index d1ebd8d37d7..659801b0865 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -60,12 +60,14 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
   found = build_id_bfd_get (abfd);
 
   if (found == NULL)
-    warning (_("File \"%s\" has no build-id, file skipped"),
-	     bfd_get_filename (abfd));
+    warning (_("File \"%ps\" has no build-id, file skipped"),
+	     styled_string (file_name_style.style (),
+			    bfd_get_filename (abfd)));
   else if (found->size != check_len
 	   || memcmp (found->data, check, found->size) != 0)
-    warning (_("File \"%s\" has a different build-id, file skipped"),
-	     bfd_get_filename (abfd));
+    warning (_("File \"%ps\" has a different build-id, file skipped"),
+	     styled_string (file_name_style.style (),
+			    bfd_get_filename (abfd)));
   else
     retval = 1;
 
diff --git a/gdb/solib.c b/gdb/solib.c
index a656b623458..db2ff5ce9a3 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -903,16 +903,19 @@ update_solib_list (int from_tty)
 	 stand out well.  */
 
       if (not_found == 1)
-	warning (_ ("Could not load shared library symbols for %s.\n"
+	warning (_ ("Could not load shared library symbols for %ps.\n"
 		    "Do you need \"set solib-search-path\" "
 		    "or \"set sysroot\"?"),
-		 not_found_filename);
+		 styled_string (file_name_style.style (),
+				not_found_filename));
       else if (not_found > 1)
 	warning (_ ("\
-Could not load shared library symbols for %d libraries, e.g. %s.\n\
+Could not load shared library symbols for %d libraries, e.g. %ps.\n\
 Use the \"info sharedlibrary\" command to see the complete listing.\n\
 Do you need \"set solib-search-path\" or \"set sysroot\"?"),
-		 not_found, not_found_filename);
+		 not_found,
+		 styled_string (file_name_style.style (),
+				not_found_filename));
     }
 }
 
@@ -1005,8 +1008,9 @@ solib_add (const char *pattern, int from_tty, int readsyms)
 		  /* If no pattern was given, be quiet for shared
 		     libraries we have already loaded.  */
 		  if (pattern && (from_tty || info_verbose))
-		    gdb_printf (_ ("Symbols already loaded for %s\n"),
-				gdb.so_name.c_str ());
+		    gdb_printf (_ ("Symbols already loaded for %ps\n"),
+				styled_string (file_name_style.style (),
+					       gdb.so_name.c_str ()));
 		}
 	      else if (solib_read_symbols (gdb, add_flags))
 		loaded_any_symbols = true;

base-commit: 868883583e7520ff1bd99fcb224d2b33a990edff
-- 
2.25.4


^ permalink raw reply	[relevance 7%]

* [PATCH v3 4/5] gdb: introduce ability to disable frame unwinders
  @ 2024-05-08 14:54  5% ` Guinevere Larsen
  0 siblings, 0 replies; 200+ results
From: Guinevere Larsen @ 2024-05-08 14:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Guinevere Larsen, Eli Zaretskii

Sometimes, in the GDB testsuite, we want to test the ability of specific
unwinders to handle some piece of code. Usually this is done by trying
to outsmart GDB, or by coercing the compiler to remove information that
GDB would rely on.  Both approaches have problems as GDB gets smarter
with time, and that compilers might differ in version and behavior, or
simply introduce new useful information. This was requested back in 2003
in PR backtrace/8434.

To improve our ability to thoroughly test GDB, this patch introduces a
new maintenance command that allows a user to disable some unwinders,
based on either the name of the unwinder or on its class. With this
change, it will now be possible for GDB to not find any frame unwinders
for a given frame, which would previously cause GDB to assert. GDB will
now check if any frame unwinder has been disabled, and if some has, it
will just error out instead of asserting.

Unwinders can be disabled or re-enabled in 3 different ways:
* Disabling/enabling all at once (using '-all').
* By specifying an unwinder class to be disabled (option '-class').
* By specifying the name of an unwinder (option '-name').

If you give no options to the command, GDB assumes the input is an
unwinder class. '-class' would make no difference if used, is just here
for completeness.

This command is meant to be used once the inferior is already at the
desired location for the test. An example session would be:

(gdb) start
Temporary breakpoint 1, main () at omp.c:17
17          func();
(gdb) maint frame-unwinder disable ARCH
(gdb) bt
\#0  main () at omp.c:17
(gdb) maint frame-unwinder enable ARCH
(gdb) cont
Continuing.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=8434
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---
 gdb/NEWS                                      |   7 +
 gdb/doc/gdb.texinfo                           |  24 +++
 gdb/frame-unwind.c                            | 154 +++++++++++++++++-
 gdb/frame-unwind.h                            |  13 ++
 gdb/testsuite/gdb.base/frame-unwind-disable.c |  21 +++
 .../gdb.base/frame-unwind-disable.exp         | 114 +++++++++++++
 6 files changed, 329 insertions(+), 4 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/frame-unwind-disable.c
 create mode 100644 gdb/testsuite/gdb.base/frame-unwind-disable.exp

diff --git a/gdb/NEWS b/gdb/NEWS
index 679295f0507..58dcf262b63 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -62,6 +62,13 @@ disable missing-debug-handler LOCUS HANDLER
 maintenance info linux-lwps
   List all LWPs under control of the linux-nat target.
 
+maintenance frame-unwinder disable [-all | -name NAME | [-class] CLASS]
+maintenance frame-unwinder enable [-all | -name NAME | [-class] CLASS]
+  Enable or disable frame unwinders.  This is only meant to be used when
+  testing unwinders themselves, and you want to ensure that a fallback
+  algorithm won't obscure a regression.  GDB is not expected to behave
+  well if you try to execute the inferior with unwinders disabled.
+
 set remote thread-options-packet
 show remote thread-options-packet
   Set/show the use of the thread options packet.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 3fc0fafa3cd..a3226d98ff6 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -42096,6 +42096,30 @@ architecture, then enabling this flag does not cause them to be used.
 @item maint info frame-unwinders
 List the frame unwinders currently in effect, starting with the highest priority.  This also lists the unwinder class, which is mostly defined by which area  of @value{GDBN} uses it.
 
+@kindex maint frame-unwinder disable
+@kindex maint frame-unwinder enable
+@item maint frame-unwinder disable [@code{-all} | @code{-name} @var{name} | [@code{-class}] @var{class}]
+@item maint frame-unwinder enable [@code{-all} | @code{-name} @var{name} | [@code{-class}] @var{class}]
+Disable or enable frame unwinders.  This is meant only as a testing tool, and
+@value{GDBN} is not guaranteed to work properly if it is unable to find
+valid frame unwinders.
+
+The meaning of each of the invocations are as follows:
+
+@table @samp
+@item @code{-all}
+Disable or enable all unwinders.
+@item @code{-name} @var{name}
+@var{name} is the exact name of the unwinder to be disabled or enabled.
+@item [@code{-class}] @var{class}
+@var{class} is the class of frame unwinders to be disabled or enabled.
+The class may include the prefix @code{FRAME_UNWINDER_}, but it is not
+required.
+@end table
+
+@var{name} and @var{class} are always case insensitive.  If no option
+starting wth @code{-} is given, @value{GDBN} assumes @code{-class}.
+
 @kindex maint set worker-threads
 @kindex maint show worker-threads
 @item maint set worker-threads
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index b79caffbd2d..94d6760cd3b 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -88,6 +88,23 @@ frame_unwinder_class_str (frame_unwind_class uclass)
   return location->second;
 }
 
+/* Case insensitive search for a frame_unwind_class based on the given
+   string.  */
+static enum frame_unwind_class
+str_to_frame_unwind_class (const char *class_str)
+{
+  const char *prefix = "FRAME_UNWIND_";
+  /* Skip the prefix if present.  */
+  if (strncasecmp (class_str, prefix, strlen(prefix)) == 0)
+    class_str += strlen(prefix);
+  for (const auto& it : unwind_class_conversion)
+    {
+      if (strcasecmp(it.second, class_str) == 0)
+	return it.first;
+    }
+  error (_("Unknown frame unwind class: %s"), class_str);
+}
+
 void
 frame_unwind_prepend_unwinder (struct gdbarch *gdbarch,
 				const struct frame_unwind *unwinder)
@@ -185,25 +202,47 @@ frame_unwind_find_by_frame (const frame_info_ptr &this_frame, void **this_cache)
 
   const struct frame_unwind *unwinder_from_target;
 
+  /* If we see a disabled unwinder, we assume some test is being run on
+     GDB, and we don't want to assert at the end of this function.  */
+  bool seen_disabled_unwinder = false;
+
   unwinder_from_target = target_get_unwinder ();
   if (unwinder_from_target != NULL
+      && unwinder_from_target->enabled ()
       && frame_unwind_try_unwinder (this_frame, this_cache,
 				   unwinder_from_target))
     return;
+  else if (unwinder_from_target != nullptr
+	   && !unwinder_from_target->enabled ())
+    seen_disabled_unwinder = true;
 
   unwinder_from_target = target_get_tailcall_unwinder ();
   if (unwinder_from_target != NULL
+      && unwinder_from_target->enabled ()
       && frame_unwind_try_unwinder (this_frame, this_cache,
 				   unwinder_from_target))
     return;
+  else if (unwinder_from_target != nullptr
+	   && !unwinder_from_target->enabled ())
+    seen_disabled_unwinder |= true;
 
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   std::vector<const frame_unwind *> table = get_frame_unwind_table (gdbarch);
   for (auto unwinder: table)
-    if (frame_unwind_try_unwinder (this_frame, this_cache, unwinder))
-      return;
+    {
+      if (!unwinder->enabled ())
+	{
+	  seen_disabled_unwinder |= true;
+	  continue;
+	}
+      if (frame_unwind_try_unwinder (this_frame, this_cache, unwinder))
+	return;
+    }
 
-  internal_error (_("frame_unwind_find_by_frame failed"));
+  if (seen_disabled_unwinder)
+    error (_("frame_unwind_find_by_frame failed"));
+  else
+    internal_error (_("frame_unwind_find_by_frame failed"));
 }
 
 /* A default frame sniffer which always accepts the frame.  Used by
@@ -397,10 +436,11 @@ maintenance_info_frame_unwinders (const char *args, int from_tty)
   std::vector<const frame_unwind *> table = get_frame_unwind_table (gdbarch);
 
   ui_out *uiout = current_uiout;
-  ui_out_emit_table table_emitter (uiout, 3, -1, "FrameUnwinders");
+  ui_out_emit_table table_emitter (uiout, 4, -1, "FrameUnwinders");
   uiout->table_header (27, ui_left, "name", "Name");
   uiout->table_header (25, ui_left, "type", "Type");
   uiout->table_header (9, ui_left, "class", "Class");
+  uiout->table_header (8, ui_left, "enabled", "Enabled");
   uiout->table_body ();
 
   for (const struct frame_unwind *unwinder: table)
@@ -408,15 +448,88 @@ maintenance_info_frame_unwinders (const char *args, int from_tty)
       const char *name = unwinder->name ();
       const char *type = frame_type_str (unwinder->type ());
       const char *uclass = frame_unwinder_class_str (unwinder->unwinder_class ());
+      const char *enabled = (unwinder->enabled ()) ? "Y" : "N";
 
       ui_out_emit_list tuple_emitter (uiout, nullptr);
       uiout->field_string ("name", name);
       uiout->field_string ("type", type);
       uiout->field_string ("class", uclass);
+      uiout->field_string ("enabled", enabled);
       uiout->text ("\n");
     }
 }
 
+/* Helper function to both enable and disable frame unwinders.
+   if ENABLE is true, this call will be enabling unwinders,
+   otherwise the unwinders will be disabled.  */
+static void
+enable_disable_frame_unwinders (const char *args, int from_tty, bool enable)
+{
+  reinit_frame_cache ();
+  if (args == nullptr)
+    error (_("specify which frame unwinder(s) should be %s"),
+	   (enable)? "enabled" : "disabled");
+  struct gdbarch* gdbarch = current_inferior ()->arch ();
+  std::vector<const frame_unwind *> unwinder_list
+    = gdbarch_get_unwinder_list (gdbarch);
+
+  /* First see if the user wants to change all unwinders.  */
+  if (check_for_argument (&args, "-all"))
+    {
+      for (const frame_unwind *u : unwinder_list)
+	u->set_enabled (enable);
+      return;
+    }
+
+  /* If user entered a specific unwinder name, handle it here.  If the
+     unwinder is already at the expected state, error out.  */
+  if (check_for_argument (&args, "-name"))
+    {
+      bool did_something = false;
+      for (const frame_unwind *unwinder : unwinder_list)
+	{
+	  if (strcasecmp (unwinder->name (), args) == 0)
+	    {
+	      if (unwinder->enabled () == enable)
+		error (_("unwinder %s is already %s"),
+			 unwinder->name (),
+			 (unwinder->enabled ()) ? ("enabled") : ("disabled"));
+	      unwinder->set_enabled (enable);
+
+	      did_something = true;
+	      break;
+	    }
+	}
+      if (!did_something)
+	error (_("couldn't find unwinder named %s"),args);
+    }
+  else
+    {
+      /* Discard '-class' argument, if provided.  */
+      check_for_argument (&args, "-class");
+      enum frame_unwind_class dclass = str_to_frame_unwind_class (args);
+      for (auto unwinder: unwinder_list)
+	{
+	  if (unwinder->unwinder_class () == dclass)
+	    unwinder->set_enabled (enable);
+	}
+    }
+}
+
+/* Implement "maint frame-unwinders disable" command.  */
+static void
+maintenance_disable_frame_unwinders (const char *args, int from_tty)
+{
+  enable_disable_frame_unwinders (args, from_tty, false);
+}
+
+/* Implement "maint frame-unwinders disable" command.  */
+static void
+maintenance_enable_frame_unwinders (const char *args, int from_tty)
+{
+  enable_disable_frame_unwinders (args, from_tty, true);
+}
+
 void _initialize_frame_unwind ();
 void
 _initialize_frame_unwind ()
@@ -428,4 +541,37 @@ _initialize_frame_unwind ()
 	   _("List the frame unwinders currently in effect, "
 	     "starting with the highest priority."),
 	   &maintenanceinfolist);
+
+  /* Add "maint frame-unwinder disable/enable".  */
+  static struct cmd_list_element *maint_frame_unwinder;
+
+  add_basic_prefix_cmd ("frame-unwinder", class_maintenance,
+			_("Commands handling frame unwinders."),
+			&maint_frame_unwinder, 0, &maintenancelist);
+
+  add_cmd ("disable", class_maintenance, maintenance_disable_frame_unwinders,
+	   _("\
+Disable one or more frame unwinder(s).\n\
+Usage: maint frame-unwinder disable [-all | -name NAME | [-class] CLASS]\n\
+\n\
+These are the meanings of the options:\n\
+\t-all    - All available unwinders will be disabled\n\
+\t-name   - NAME is the exact name of the frame unwinder to be disabled\n\
+\t-class  - CLASS is the class of unwinders to be disabled.\n\
+\n\
+UNWINDER and NAME are case insensitive."),
+	   & maint_frame_unwinder);
+
+  add_cmd ("enable", class_maintenance, maintenance_enable_frame_unwinders,
+	   _("\
+Enable one or more frame unwinder(s).\n\
+Usage: maint frame-unwinder enable [-all | -name NAME | [-class] CLASS]\n\
+\n\
+These are the meanings of the options:\n\
+\t-all    - All available unwinders will be enabled\n\
+\t-name   - NAME is the exact name of the frame unwinder to be enabled\n\
+\t-class  - CLASS is the class of unwinders to be enabled.\n\
+\n\
+UNWINDER and NAME are case insensitive."),
+	   & maint_frame_unwinder);
 }
diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h
index 62da34b6ee8..ffb131310dc 100644
--- a/gdb/frame-unwind.h
+++ b/gdb/frame-unwind.h
@@ -180,6 +180,9 @@ class frame_unwind
      unwinding.  */
   enum frame_unwind_class m_unwinder_class;
   const struct frame_data *m_unwind_data;
+
+  /* Whether this unwinder can be used when sniffing.  */
+  mutable bool m_enabled = true;
 public:
   frame_unwind (const char *name, frame_type type, frame_unwind_class uclass,
 		       const struct frame_data *data)
@@ -207,6 +210,16 @@ class frame_unwind
     return m_unwind_data;
   }
 
+  bool enabled () const
+  {
+    return m_enabled;
+  }
+
+  void set_enabled (bool state) const
+  {
+    m_enabled = state;
+  }
+
   /* Default stop_reason function.  It reports NO_REASON, unless the
      frame is the outermost.  */
   virtual enum unwind_stop_reason stop_reason (const frame_info_ptr &this_frame,
diff --git a/gdb/testsuite/gdb.base/frame-unwind-disable.c b/gdb/testsuite/gdb.base/frame-unwind-disable.c
new file mode 100644
index 00000000000..078517c011e
--- /dev/null
+++ b/gdb/testsuite/gdb.base/frame-unwind-disable.c
@@ -0,0 +1,21 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int main ()
+{
+    return 0;
+}
diff --git a/gdb/testsuite/gdb.base/frame-unwind-disable.exp b/gdb/testsuite/gdb.base/frame-unwind-disable.exp
new file mode 100644
index 00000000000..4efc87ccfcf
--- /dev/null
+++ b/gdb/testsuite/gdb.base/frame-unwind-disable.exp
@@ -0,0 +1,114 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test multiple situations in which we may use the maintenance command to
+# disable and enable frame unwinders, and check that they really are
+# disabled when they say the are.
+
+standard_testfile .c
+
+# Proc to check if the unwinder of the given name is in the desired state.
+# STATE can be either Y or N.
+proc check_unwinder_state { unwinder_name state {testname ""} } {
+    if {${testname} == ""} {
+	set testname "checking state ${state} for ${unwinder_name}"
+    }
+    gdb_test "maint info frame-unwinders" \
+	".*${unwinder_name}\\s+\\w+\\s+\\w+.+${state}.*" \
+	"${testname}"
+}
+
+proc check_unwinder_class { unwinder_class state {testname ""} } {
+    set should_pass true
+    if {$testname == ""} {
+	set testname "checking if $unwinder_class state is $state"
+    }
+    gdb_test_multiple "maint info frame-unwinders" "collect for $testname" -lbl {
+	-re "^\\w+\\s+\\w+\\s+${unwinder_class}\\s+\(.\)\\s+" {
+	    set cur_state $expec_out(1, string)
+	    if {$cur_state != $state} {
+		set should_pass false
+	    }
+	    exp_continue
+	}
+	-re "${::gdb_prompt} $" {
+	    pass $gdb_test_name
+	}
+    }
+
+    gdb_assert {$should_pass == true} "$testname"
+}
+
+if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} ]} {
+    return -1
+}
+
+if {![runto_main]} {
+    untested "couldn't run to main"
+    return
+}
+
+# Test disabling all unwinders
+check_unwinder_class "FRAME_UNWIND_\\w+" "Y" \
+    "Checking all unwinders before any changes"
+gdb_test_no_output "maint frame-unwinder disable -all"
+check_unwinder_class "FRAME_UNWIND_\\w+" "N" \
+    "Checking all unwinders were properly disabled"
+
+# Test if GDB can still make a backtrace once all unwinders are disabled.
+# It should be impossible.
+gdb_test "backtrace" ".*frame_unwind_find_by_frame failed.*" \
+    "confirm that no suitable unwinders are found"
+
+# Reenable all unwinders
+gdb_test_no_output "maint frame-unwinder enable -all"
+check_unwinder_class "FRAME_UNWIND_\\w+" "Y" \
+    "Checking all unwinders after re-enabling them all"
+
+# Check that we are able to get backtraces once again.
+gdb_test "backtrace" ".0\\s+main .. at.*" \
+    "confirm we now get usable backtraces"
+
+# Check if we can disable an unwinder based on the name.
+check_unwinder_state "dummy" "Y"
+gdb_test_no_output "maint frame-unwinder disable -name dummy"
+check_unwinder_state "dummy" "N"
+# And verify what happens if you try to disable it again.
+gdb_test "maint frame-unwinder disable -name dummy" \
+    "unwinder dummy is already disabled" \
+    "disable already disabled unwinder"
+check_unwinder_state "dummy" "N" "check if dummy continues disabled"
+
+foreach class {GDB ARCH DEBUGINFO EXTENSION} {
+    # Disable all unwinders of type CLASS, and check that the command worked.
+    gdb_test_no_output "maint frame-unwinder disable ${class}"
+    check_unwinder_class "FRAME_UNWINDER_${class}" "N"
+}
+
+# Now check if we are able to enable a single unwinder, and what happens if we
+# enable it twice.
+gdb_test_no_output "maint frame-unwinder enable -name dummy"
+check_unwinder_state "dummy" "Y" "successfully enabled dummy unwinder"
+gdb_test "maint frame-unwinder enable -name dummy" \
+    "unwinder dummy is already enabled" \
+    "enable already enabled unwinder"
+check_unwinder_state "dummy" "Y" "check if dummy continues enabled"
+
+foreach class {GDB ARCH DEBUGINFO EXTENSION} {
+    # Enable all unwinders of type CLASS, and check that the command worked.
+    # using "-class" option to ensure it works.  Should make no difference.
+    gdb_test_no_output "maint frame-unwinder enable -class ${class}"
+    check_unwinder_class "FRAME_UNWINDER_${class}" "Y"
+}
-- 
2.45.0


^ permalink raw reply	[relevance 5%]

* [PATCH 2/2] gdb: Remove Itanium (IA-64) architecture
  @ 2024-05-08  9:29  7% ` Tiezhu Yang
  0 siblings, 0 replies; 200+ results
From: Tiezhu Yang @ 2024-05-08  9:29 UTC (permalink / raw)
  To: binutils, gdb-patches; +Cc: Jim Wilson, Jeff Johnston, Kevin Buettner

The Itanium architecture is obsolete, after the upstream Linux kernel
commit cf8e8658100d ("arch: Remove Itanium (IA-64) architecture"), the
IA-64 port has been removed from the Linux kernel, so also remove the
IA-64 specific code from gdb.

Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cf8e8658100d
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 gdb/MAINTAINERS                               |    5 -
 gdb/Makefile.in                               |   10 -
 gdb/NEWS                                      |    2 +
 gdb/README                                    |    5 -
 gdb/config.in                                 |    3 -
 gdb/config/djgpp/fnchange.lst                 |   19 -
 gdb/configure                                 |  238 +-
 gdb/configure.ac                              |   39 -
 gdb/configure.host                            |    3 -
 gdb/configure.nat                             |    4 -
 gdb/configure.tgt                             |   16 -
 gdb/disasm-selftests.c                        |    5 -
 gdb/doc/gdb.texinfo                           |    7 +-
 gdb/dwarf2/frame.c                            |    2 +-
 gdb/gdbtypes.c                                |    4 -
 gdb/gdbtypes.h                                |    1 -
 gdb/ia64-libunwind-tdep.c                     |  582 ---
 gdb/ia64-libunwind-tdep.h                     |   79 -
 gdb/ia64-linux-nat.c                          |  931 ----
 gdb/ia64-linux-tdep.c                         |  267 --
 gdb/ia64-tdep.c                               | 4024 -----------------
 gdb/ia64-tdep.h                               |  268 --
 gdb/ia64-vms-tdep.c                           |  162 -
 gdb/inf-ptrace.c                              |    3 -
 gdb/nat/linux-ptrace.c                        |    5 -
 gdb/regcache.c                                |    3 +-
 gdb/regformats/reg-ia64.dat                   |  475 --
 gdb/stubs/ia64vms-stub.c                      | 2601 -----------
 gdb/symtab.c                                  |    5 +-
 gdb/target.h                                  |    2 -
 gdb/testsuite/configure                       |    4 +-
 gdb/testsuite/configure.ac                    |    4 +-
 .../gdb.arch/ia64-breakpoint-shadow.S         |   44 -
 .../gdb.arch/ia64-breakpoint-shadow.exp       |   73 -
 gdb/testsuite/gdb.asm/asm-source.exp          |    4 -
 gdb/testsuite/gdb.asm/ia64.inc                |   51 -
 gdb/testsuite/gdb.base/callfuncs.exp          |    7 +-
 gdb/testsuite/gdb.base/float.exp              |    2 -
 gdb/testsuite/gdb.base/step-test.exp          |   10 +-
 gdb/testsuite/gdb.dwarf2/pr10770.c            |    1 -
 .../gdb.threads/clone-attach-detach.c         |    5 -
 gdb/testsuite/gdb.threads/clone-thread_db.c   |    5 -
 gdb/testsuite/gdb.threads/ia64-sigill.c       |  371 --
 gdb/testsuite/gdb.threads/ia64-sigill.exp     |   77 -
 gdb/testsuite/lib/gdb.exp                     |    2 -
 gdb/top.c                                     |   10 -
 gdbserver/configure.srv                       |    4 -
 gdbserver/linux-ia64-low.cc                   |  395 --
 48 files changed, 23 insertions(+), 10816 deletions(-)
 delete mode 100644 gdb/ia64-libunwind-tdep.c
 delete mode 100644 gdb/ia64-libunwind-tdep.h
 delete mode 100644 gdb/ia64-linux-nat.c
 delete mode 100644 gdb/ia64-linux-tdep.c
 delete mode 100644 gdb/ia64-tdep.c
 delete mode 100644 gdb/ia64-tdep.h
 delete mode 100644 gdb/ia64-vms-tdep.c
 delete mode 100644 gdb/regformats/reg-ia64.dat
 delete mode 100644 gdb/stubs/ia64vms-stub.c
 delete mode 100644 gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.S
 delete mode 100644 gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
 delete mode 100644 gdb/testsuite/gdb.asm/ia64.inc
 delete mode 100644 gdb/testsuite/gdb.threads/ia64-sigill.c
 delete mode 100644 gdb/testsuite/gdb.threads/ia64-sigill.exp
 delete mode 100644 gdbserver/linux-ia64-low.cc

diff --git a/gdb/MAINTAINERS b/gdb/MAINTAINERS
index 457dd4041c5..14979ff6e32 100644
--- a/gdb/MAINTAINERS
+++ b/gdb/MAINTAINERS
@@ -348,9 +348,6 @@ the native maintainer when resolving ABI issues.
 	i386		--target=i386-elf
 			Felix Willgerodt	felix.willgerodt@intel.com
 
-	ia64		--target=ia64-linux-gnu
-			(--target=ia64-elf broken)
-
 	lm32		--target=lm32-elf
 
 	loongarch	--target=loongarch32-elf
@@ -517,12 +514,10 @@ to do so!
 ARM			Richard Earnshaw	rearnsha@arm.com
 Blackfin		Mike Frysinger		vapier@gentoo.org
 CRIS			Hans-Peter Nilsson	hp@axis.com
-IA64			Jeff Johnston		jjohnstn@redhat.com
 PowerPC			Kevin Buettner		kevinb@redhat.com
 S390			Ulrich Weigand		uweigand@de.ibm.com
 djgpp			DJ Delorie		dj@delorie.com
 			[Please use this address to contact DJ about DJGPP]
-ia64			Kevin Buettner		kevinb@redhat.com
 AIX			Kevin Buettner		kevinb@redhat.com
 GNU/Linux PPC native	Kevin Buettner		kevinb@redhat.com
 Pascal support		Pierre Muller		muller@sourceware.org
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 234d0051f49..dde74a32ea3 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -751,9 +751,6 @@ ALL_64_TARGET_OBS = \
 	arch/amd64.o \
 	arch/riscv.o \
 	bpf-tdep.o \
-	ia64-linux-tdep.o \
-	ia64-tdep.o \
-	ia64-vms-tdep.o \
 	loongarch-linux-tdep.o \
 	loongarch-tdep.o \
 	mips-fbsd-tdep.o \
@@ -1401,8 +1398,6 @@ HFILES_NO_SRCDIR = \
 	i386-linux-tdep.h \
 	i386-tdep.h \
 	i387-tdep.h \
-	ia64-libunwind-tdep.h \
-	ia64-tdep.h \
 	inf-child.h \
 	inf-loop.h \
 	inf-ptrace.h \
@@ -1756,11 +1751,6 @@ ALLDEPFILES = \
 	i386-tdep.c \
 	i386-windows-tdep.c \
 	i387-tdep.c \
-	ia64-libunwind-tdep.c \
-	ia64-linux-nat.c \
-	ia64-linux-tdep.c \
-	ia64-tdep.c \
-	ia64-vms-tdep.c \
 	inf-ptrace.c \
 	linux-fork.c \
 	linux-record.c \
diff --git a/gdb/NEWS b/gdb/NEWS
index 050f6f96e62..3ead1172171 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -16,6 +16,8 @@
   the background, resulting in faster startup.  This can be controlled
   using "maint set dwarf synchronous".
 
+* Remove Itanium (IA-64) architecture.
+
 * Changed commands
 
 disassemble
diff --git a/gdb/README b/gdb/README
index 763089bb02d..9b833b908e1 100644
--- a/gdb/README
+++ b/gdb/README
@@ -441,11 +441,6 @@ more obscure GDB `configure' options are not listed here.
      with version 0.178.  You can get the latest version from
      'https://sourceware.org/elfutils/'.
 
-`--with-libunwind-ia64'
-     Use the libunwind library for unwinding function call stack on ia64
-     target platforms.
-     See http://www.nongnu.org/libunwind/index.html for details.
-
 `--with-system-readline'
      Use the readline library installed on the host, rather than the
      library supplied as part of GDB.  Readline 7 or newer is required;
diff --git a/gdb/config.in b/gdb/config.in
index 0c144c8918b..f7703bfdbcd 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -280,9 +280,6 @@
 /* Define to 1 if you have the `m' library (-lm). */
 #undef HAVE_LIBM
 
-/* Define to 1 if you have the <libunwind-ia64.h> header file. */
-#undef HAVE_LIBUNWIND_IA64_H
-
 /* Define if you have the xxhash library. */
 #undef HAVE_LIBXXHASH
 
diff --git a/gdb/config/djgpp/fnchange.lst b/gdb/config/djgpp/fnchange.lst
index 3e77bece2fc..562a0c096ae 100644
--- a/gdb/config/djgpp/fnchange.lst
+++ b/gdb/config/djgpp/fnchange.lst
@@ -17,16 +17,9 @@
 @V@/bfd/coff-tic80.c @V@/bfd/cofftic80.c
 @V@/bfd/cpu-cr16.c @V@/bfd/cpucr16.c
 @V@/bfd/cpu-cr16c.c @V@/bfd/cpucr16c.c
-@V@/bfd/cpu-ia64-opc.c @V@/bfd/cpuia64-opc.c
 @V@/bfd/cpu-microblaze.c @V@/bfd/cpumb.c
 @V@/bfd/cpu-m68hc11.c @V@/bfd/cm68hc11.c
 @V@/bfd/cpu-m68hc12.c @V@/bfd/cm68hc12.c
-@V@/bfd/efi-app-ia32.c @V@/bfd/efiia32app.c
-@V@/bfd/efi-app-ia64.c @V@/bfd/efiia64app.c
-@V@/bfd/efi-bsdrv-ia32.c @V@/bfd/efiia32bsdrv.c
-@V@/bfd/efi-bsdrv-ia64.c @V@/bfd/efiia64bsdrv.c
-@V@/bfd/efi-rtdrv-ia32.c @V@/bfd/efiia32rtdrv.c
-@V@/bfd/efi-rtdrv-ia64.c @V@/bfd/efiia64rtdrv.c
 @V@/bfd/elf32-arc.c @V@/bfd/elf32arc.c
 @V@/bfd/elf32-crx.c @V@/bfd/elf32crx.c
 @V@/bfd/elf32-cris.c @V@/bfd/elf32cris.c
@@ -297,10 +290,6 @@
 @V@/gdb/i386-obsd-tdep.c @V@/gdb/i3obsd-tdep.c
 @V@/gdb/i386-sol2-nat.c @V@/gdb/i3sol2-nat.c
 @V@/gdb/i386-sol2-tdep.c @V@/gdb/i3sol2-tdep.c
-@V@/gdb/ia64-aix-nat.c @V@/gdb/ia64ax-nat.c
-@V@/gdb/ia64-aix-tdep.c @V@/gdb/ia64ax-tdep.c
-@V@/gdb/ia64-linux-nat.c @V@/gdb/ia64lx-nat.c
-@V@/gdb/ia64-linux-tdep.c @V@/gdb/ia64lx-tdep.c
 @V@/gdb/jv-exp.tab.c @V@/gdb/jv-exp_tab.c
 @V@/gdb/m2-exp.tab.c @V@/gdb/m2-exp_tab.c
 @V@/gdb/m32r-linux-nat.c @V@/gdb/m32rlnxnat.c
@@ -551,14 +540,6 @@
 @V@/opcodes/ChangeLog-2006 @V@/opcodes/ChangeLog.006
 @V@/opcodes/ChangeLog-2007 @V@/opcodes/ChangeLog.007
 @V@/opcodes/ChangeLog-2008 @V@/opcodes/ChangeLog.008
-@V@/opcodes/ia64-opc-a.c @V@/opcodes/ia64opca.c
-@V@/opcodes/ia64-opc-b.c @V@/opcodes/ia64opcb.c
-@V@/opcodes/ia64-opc-d.c @V@/opcodes/ia64opcd.c
-@V@/opcodes/ia64-opc-f.c @V@/opcodes/ia64opcf.c
-@V@/opcodes/ia64-opc-i.c @V@/opcodes/ia64opci.c
-@V@/opcodes/ia64-opc-m.c @V@/opcodes/ia64opcm.c
-@V@/opcodes/ia64-opc-x.c @V@/opcodes/ia64opcx.c
-@V@/opcodes/ia64-opc.c @V@/opcodes/ia64-opc.c
 @V@/opcodes/iq2000-desc.c @V@/opcodes/iq2000desc.c
 @V@/opcodes/iq2000-dis.c @V@/opcodes/iq2000dis.c
 @V@/opcodes/microblaze-opc.h @V@/opcodes/mb-opc.h
diff --git a/gdb/configure b/gdb/configure
index 98cd488a737..2c78497e4c6 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -938,7 +938,6 @@ with_amd_dbgapi
 enable_tui
 enable_gdbtk
 with_debuginfod
-with_libunwind_ia64
 with_curses
 enable_profiling
 enable_codesign
@@ -1706,7 +1705,6 @@ Optional Packages:
   --with-amd-dbgapi       support for the amd-dbgapi target (yes / no / auto)
   --with-debuginfod       Enable debuginfo lookups with debuginfod
                           (auto/yes/no)
-  --with-libunwind-ia64   use libunwind frame unwinding for ia64 targets
   --with-curses           use the curses library instead of the termcap
                           library
   --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
@@ -6341,10 +6339,6 @@ haiku*)
 hpux10.20* | hpux11*)
   lt_cv_file_magic_cmd=/usr/bin/file
   case $host_cpu in
-  ia64*)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
-    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
-    ;;
   hppa*64*)
     lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
     lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
@@ -6945,11 +6939,6 @@ aix*)
 cygwin* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
-hpux*)
-  if test "$host_cpu" = ia64; then
-    symcode='[ABCDEGRST]'
-  fi
-  ;;
 irix* | nonstopux*)
   symcode='[BCDEGRST]'
   ;;
@@ -6980,7 +6969,7 @@ case `$NM -V 2>&1` in
 esac
 
 # Transform an extracted symbol line into a proper C declaration.
-# Some systems (esp. on ia64) link data and code symbols differently,
+# Some systems link data and code symbols differently,
 # so use this general approach.
 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
 
@@ -7180,25 +7169,6 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
-ia64-*-hpux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    case `/usr/bin/file conftest.$ac_objext` in
-      *ELF-32*)
-	HPUX_IA64_MODE="32"
-	;;
-      *ELF-64*)
-	HPUX_IA64_MODE="64"
-	;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
 *-*-irix6*)
   # Find out which ABI we are using.
   echo '#line '$LINENO' "configure"' > conftest.$ac_ext
@@ -8534,10 +8504,6 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static='-Bstatic'
-      fi
       lt_prog_compiler_pic='-fPIC'
       ;;
 
@@ -8634,12 +8600,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
     case $host_os in
     aix*)
       lt_prog_compiler_wl='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static='-Bstatic'
-      else
-	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
-      fi
+      lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
       ;;
 
     mingw* | cygwin* | pw32* | os2* | cegcc*)
@@ -8653,7 +8614,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
       case $host_cpu in
-      hppa*64*|ia64*)
+      hppa*64*)
 	# +Z the default
 	;;
       *)
@@ -9178,7 +9139,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     case $host_os in
     aix[3-9]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
@@ -9190,7 +9150,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 *** You will then need to restart the configuration process.
 
 _LT_EOF
-      fi
       ;;
 
     amigaos*)
@@ -9286,10 +9245,6 @@ _LT_EOF
 					# Portland Group f77 and f90 compilers
 	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
 	ifc* | ifort*)			# Intel Fortran compiler
 	  tmp_addflag=' -nofor_main' ;;
 	lf95*)				# Lahey Fortran 8.1
@@ -9443,13 +9398,6 @@ _LT_EOF
       ;;
 
     aix[4-9]*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
 	# If we're using GNU nm, then we don't want the "-C" option.
 	# -C means demangle to AIX nm, but means don't demangle with GNU nm
 	# Also, AIX nm treats weak defined symbols like other global
@@ -9476,7 +9424,6 @@ _LT_EOF
 
 	exp_sym_flag='-bexport'
 	no_entry_flag='-bnoentry'
-      fi
 
       # When large executables or shared objects are built, AIX ld can
       # have problems creating the table of contents.  If linking a library
@@ -9519,17 +9466,11 @@ _LT_EOF
 	fi
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
-	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
 	  if test "$aix_use_runtimelinking" = yes; then
 	    shared_flag='${wl}-G'
 	  else
 	    shared_flag='${wl}-bM:SRE'
 	  fi
-	fi
       fi
 
       export_dynamic_flag_spec='${wl}-bexpall'
@@ -9575,11 +9516,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
         hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
         archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
 	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -9627,7 +9563,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	  archive_cmds_need_lc=yes
 	  # This is similar to how AIX traditionally builds its shared libraries.
 	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
       fi
       ;;
 
@@ -9776,9 +9711,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	hppa*64*)
 	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
-	ia64*)
-	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
 	*)
 	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
@@ -9788,9 +9720,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	hppa*64*)
 	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
-	ia64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
 	*)
 
 	  # Older versions of the 11.00 compiler do not understand -b yet
@@ -9840,7 +9769,7 @@ fi
 	hardcode_libdir_separator=:
 
 	case $host_cpu in
-	hppa*64*|ia64*)
+	hppa*64*)
 	  hardcode_direct=no
 	  hardcode_shlibpath_var=no
 	  ;;
@@ -10477,11 +10406,6 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
     # the line `#! .'.  This would cause the generated library to
@@ -10513,7 +10437,6 @@ aix[4-9]*)
       soname_spec='${libname}${release}${shared_ext}$major'
     fi
     shlibpath_var=LIBPATH
-  fi
   ;;
 
 amigaos*)
@@ -10690,21 +10613,6 @@ hpux9* | hpux10* | hpux11*)
   need_lib_prefix=no
   need_version=no
   case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
   hppa*64*)
     shrext_cmds='.sl'
     hardcode_into_libs=yes
@@ -11795,7 +11703,7 @@ $as_echo_n "checking whether to build shared libraries... " >&6; }
     ;;
 
   aix[4-9]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    if test "$aix_use_runtimelinking" = no ; then
       test "$enable_shared" = yes && enable_static=no
     fi
     ;;
@@ -12251,13 +12159,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
         ld_shlibs_CXX=no
         ;;
       aix[4-9]*)
-        if test "$host_cpu" = ia64; then
-          # On IA64, the linker does run time linking by default, so we don't
-          # have to do anything special.
-          aix_use_runtimelinking=no
-          exp_sym_flag='-Bexport'
-          no_entry_flag=""
-        else
           aix_use_runtimelinking=no
 
           # Test if we are trying to use run time linking or normal
@@ -12277,7 +12178,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 
           exp_sym_flag='-bexport'
           no_entry_flag='-bnoentry'
-        fi
 
         # When large executables or shared objects are built, AIX ld can
         # have problems creating the table of contents.  If linking a library
@@ -12319,17 +12219,11 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 	  fi
         else
           # not using gcc
-          if test "$host_cpu" = ia64; then
-	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	  # chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-          else
 	    if test "$aix_use_runtimelinking" = yes; then
 	      shared_flag='${wl}-G'
 	    else
 	      shared_flag='${wl}-bM:SRE'
 	    fi
-          fi
         fi
 
         export_dynamic_flag_spec_CXX='${wl}-bexpall'
@@ -12377,11 +12271,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 
           archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
         else
-          if test "$host_cpu" = ia64; then
-	    hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
-	    allow_undefined_flag_CXX="-z nodefs"
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-          else
 	    # Determine the default libpath from the value encoded in an
 	    # empty executable.
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12430,7 +12319,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	    # This is similar to how AIX traditionally builds its shared
 	    # libraries.
 	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-          fi
         fi
         ;;
 
@@ -12598,7 +12486,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	  hardcode_libdir_separator_CXX=:
 
           case $host_cpu in
-            hppa*64*|ia64*)
+            hppa*64*)
               ;;
             *)
 	      export_dynamic_flag_spec_CXX='${wl}-E'
@@ -12606,7 +12494,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
           esac
         fi
         case $host_cpu in
-          hppa*64*|ia64*)
+          hppa*64*)
             hardcode_direct_CXX=no
             hardcode_shlibpath_var_CXX=no
             ;;
@@ -12629,9 +12517,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	      hppa*64*)
 	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
-	      ia64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	        ;;
 	      *)
 	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
@@ -12653,9 +12538,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	          hppa*64*)
 	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
-	          ia64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	            ;;
 	          *)
 	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
@@ -12751,9 +12633,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 		;;
 	      *)  # Version 8.0 or newer
 	        tmp_idyn=
-	        case $host_cpu in
-		  ia64*) tmp_idyn=' -i_dynamic';;
-		esac
 	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
@@ -13399,10 +13278,6 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
     case $host_os in
     aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_CXX='-Bstatic'
-      fi
       lt_prog_compiler_pic_CXX='-fPIC'
       ;;
 
@@ -13479,12 +13354,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
     case $host_os in
       aix[4-9]*)
 	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
-	  # AIX 5 now supports IA64 processor
-	  lt_prog_compiler_static_CXX='-Bstatic'
-	else
-	  lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
-	fi
+	lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
 	;;
       chorus*)
 	case $cc_basename in
@@ -13515,15 +13385,13 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
 	  CC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
-	      lt_prog_compiler_pic_CXX='+Z'
-	    fi
+	    lt_prog_compiler_pic_CXX='+Z'
 	    ;;
 	  aCC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
 	    case $host_cpu in
-	    hppa*64*|ia64*)
+	    hppa*64*)
 	      # +Z the default
 	      ;;
 	    *)
@@ -14154,11 +14022,6 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
     # the line `#! .'.  This would cause the generated library to
@@ -14190,7 +14053,6 @@ aix[4-9]*)
       soname_spec='${libname}${release}${shared_ext}$major'
     fi
     shlibpath_var=LIBPATH
-  fi
   ;;
 
 amigaos*)
@@ -14365,21 +14227,6 @@ hpux9* | hpux10* | hpux11*)
   need_lib_prefix=no
   need_version=no
   case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
   hppa*64*)
     shrext_cmds='.sl'
     hardcode_into_libs=yes
@@ -25411,71 +25258,6 @@ else
 $as_echo "$as_me: WARNING: debuginfod support disabled; some features may be unavailable." >&2;}
 fi
 
-
-# Libunwind support for ia64.
-
-# Check whether --with-libunwind-ia64 was given.
-if test "${with_libunwind_ia64+set}" = set; then :
-  withval=$with_libunwind_ia64;
-else
-  with_libunwind_ia64=auto
-fi
-
-
-# Backward compatibility option.
-if test "${with_libunwind+set}" = set; then
-  if test x"$with_libunwind_ia64" != xauto; then
-    as_fn_error $? "option --with-libunwind is deprecated, use --with-libunwind-ia64" "$LINENO" 5
-  fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: option --with-libunwind is deprecated, use --with-libunwind-ia64" >&5
-$as_echo "$as_me: WARNING: option --with-libunwind is deprecated, use --with-libunwind-ia64" >&2;}
-  with_libunwind_ia64="$with_libunwind"
-fi
-
-case "$with_libunwind_ia64" in
-  yes | no)
-    ;;
-  auto)
-    for ac_header in libunwind-ia64.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "libunwind-ia64.h" "ac_cv_header_libunwind_ia64_h" "$ac_includes_default"
-if test "x$ac_cv_header_libunwind_ia64_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBUNWIND_IA64_H 1
-_ACEOF
-
-fi
-
-done
-
-    with_libunwind_ia64=$ac_cv_header_libunwind_ia64_h
-    ;;
-  *)
-    as_fn_error $? "bad value $with_libunwind_ia64 for GDB --with-libunwind-ia64 option" "$LINENO" 5
-    ;;
-esac
-
-if test x"$with_libunwind_ia64" = xyes; then
-  for ac_header in libunwind-ia64.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "libunwind-ia64.h" "ac_cv_header_libunwind_ia64_h" "$ac_includes_default"
-if test "x$ac_cv_header_libunwind_ia64_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBUNWIND_IA64_H 1
-_ACEOF
-
-fi
-
-done
-
-  if test x"$ac_cv_header_libunwind_ia64_h" != xyes; then
-    as_fn_error $? "GDB option --with-libunwind-ia64 requires libunwind-ia64.h" "$LINENO" 5
-  fi
-  CONFIG_OBS="$CONFIG_OBS ia64-libunwind-tdep.o"
-  CONFIG_DEPS="$CONFIG_DEPS ia64-libunwind-tdep.o"
-  CONFIG_SRCS="$CONFIG_SRCS ia64-libunwind-tdep.c"
-fi
-
 opt_curses=no
 
 # Check whether --with-curses was given.
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 62ff09cea20..4243a7f43ad 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -354,45 +354,6 @@ esac
 # Handle optional debuginfod support
 AC_DEBUGINFOD
 
-# Libunwind support for ia64.
-AC_ARG_WITH(libunwind-ia64,
-AS_HELP_STRING([--with-libunwind-ia64],
-	       [use libunwind frame unwinding for ia64 targets]),,
-	    [with_libunwind_ia64=auto])
-
-# Backward compatibility option.
-if test "${with_libunwind+set}" = set; then
-  if test x"$with_libunwind_ia64" != xauto; then
-    AC_MSG_ERROR(
-      [option --with-libunwind is deprecated, use --with-libunwind-ia64])
-  fi
-  AC_MSG_WARN([option --with-libunwind is deprecated, use --with-libunwind-ia64])
-  with_libunwind_ia64="$with_libunwind"
-fi
-
-case "$with_libunwind_ia64" in
-  yes | no)
-    ;;
-  auto)
-    AC_CHECK_HEADERS(libunwind-ia64.h)
-    with_libunwind_ia64=$ac_cv_header_libunwind_ia64_h
-    ;;
-  *)
-    AC_MSG_ERROR(
-      [bad value $with_libunwind_ia64 for GDB --with-libunwind-ia64 option])
-    ;;
-esac
-
-if test x"$with_libunwind_ia64" = xyes; then
-  AC_CHECK_HEADERS(libunwind-ia64.h)
-  if test x"$ac_cv_header_libunwind_ia64_h" != xyes; then
-    AC_MSG_ERROR([GDB option --with-libunwind-ia64 requires libunwind-ia64.h])
-  fi
-  CONFIG_OBS="$CONFIG_OBS ia64-libunwind-tdep.o"
-  CONFIG_DEPS="$CONFIG_DEPS ia64-libunwind-tdep.o"
-  CONFIG_SRCS="$CONFIG_SRCS ia64-libunwind-tdep.c"
-fi
-
 opt_curses=no
 AC_ARG_WITH(curses, AS_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
 
diff --git a/gdb/configure.host b/gdb/configure.host
index da71675b201..d64939df3c1 100644
--- a/gdb/configure.host
+++ b/gdb/configure.host
@@ -42,7 +42,6 @@ case $host in
  vax-*-netbsdaout* | \
  vax-*-ultrix* | \
  hppa*-*-hpux* | \
- ia64-*-hpux* | \
  null)
     echo "*** Configuration $host is obsolete." >&2
     echo "*** Support has been REMOVED." >&2
@@ -116,8 +115,6 @@ i[34567]86-*-solaris2* | x86_64-*-solaris2*)
 			gdb_host=sol2 ;;
 i[34567]86-*-cygwin*)	gdb_host=cygwin ;;
 
-ia64-*-linux*)		gdb_host=linux ;;
-
 loongarch*-linux*)	gdb_host=linux ;;
 
 m68*-*-linux*)		gdb_host=linux ;;
diff --git a/gdb/configure.nat b/gdb/configure.nat
index 8b98511cef7..a3cb0eed2b3 100644
--- a/gdb/configure.nat
+++ b/gdb/configure.nat
@@ -258,10 +258,6 @@ case ${gdb_host} in
 		i386-linux-nat.o x86-linux-nat.o nat/linux-btrace.o \
 		nat/x86-linux.o nat/x86-linux-dregs.o"
 		;;
-	    ia64)
-		# Host: Intel IA-64 running GNU/Linux
-		NATDEPFILES="${NATDEPFILES} ia64-linux-nat.o"
-		;;
 	    loongarch)
 		# Host: LoongArch, running GNU/Linux.
 		NATDEPFILES="${NATDEPFILES} loongarch-linux-nat.o linux-nat-trad.o"
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 47a674201f9..0382e369c67 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -36,7 +36,6 @@ case $targ in
  score-*-* | \
  sh*-*-pe | \
  hppa*-*-hpux* | \
- ia64-*-hpux* | \
  *-*-vxworks* | \
  mt-*-* | \
  null)
@@ -94,11 +93,6 @@ ia16*-*-*)
 	cpu_obs="${i386_tobjs}"
 	;;
 
-ia64*-*-*)
-	# Target: Intel IA-64
-	cpu_obs="ia64-tdep.o"
-	;;
-
 loongarch*-*-*)
 	# Target: LoongArch baremetal
 	cpu_obs="loongarch-tdep.o arch/loongarch.o"
@@ -343,16 +337,6 @@ i[34567]86-*-go32* | i[34567]86-*-msdosdjgpp*)
 	gdb_target_obs="i386-go32-tdep.o"
 	;;
 
-ia64-*-linux*)
-	# Target: Intel IA-64 running GNU/Linux
-	gdb_target_obs="ia64-linux-tdep.o linux-tdep.o \
-			solib-svr4.o symfile-mem.o"
-	;;
-ia64-*-*vms*)
-	# Target: Intel IA-64 running OpenVMS
-	gdb_target_obs="ia64-vms-tdep.o"
-	;;
-
 iq2000-*-*)
 	gdb_target_obs="iq2000-tdep.o"
 	;;
diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c
index 14b7fb30bad..766b25a51ed 100644
--- a/gdb/disasm-selftests.c
+++ b/gdb/disasm-selftests.c
@@ -54,11 +54,6 @@ get_test_insn (struct gdbarch *gdbarch, size_t *len)
       insn = arm_insn;
       *len = sizeof (arm_insn);
       break;
-    case bfd_arch_ia64:
-      /* We get:
-	 internal-error: gdbarch_sw_breakpoint_from_kind:
-	 Assertion `gdbarch->sw_breakpoint_from_kind != NULL' failed.  */
-      return insn;
     case bfd_arch_mep:
       /* Disassembles as '*unknown*' insn, then len self-check fails.  */
       return insn;
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 61f91ef4ad6..5e86302bb0d 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -41183,11 +41183,6 @@ files.  Enabled by default if @file{libdebuginfod} is installed and found
 at configure time.  For more information regarding @code{debuginfod} see
 @ref{Debuginfod}.
 
-@item --with-libunwind-ia64
-Use the libunwind library for unwinding function call stack on ia64
-target platforms.  See @url{http://www.nongnu.org/libunwind/index.html} for
-details.
-
 @item --with-system-readline
 Use the readline library installed on the host, rather than the
 library supplied as part of @value{GDBN}.  Readline 7 or newer is
@@ -45450,7 +45445,7 @@ by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
 @anchor{qXfer unwind info block}
 
 Return the unwind information block for @var{pc}.  This packet is used
-on OpenVMS/ia64 to ask the kernel unwind information.
+on OpenVMS to ask the kernel unwind information.
 
 This packet is not probed by default.
 
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 9ebf3ac4ac4..54044500355 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -2152,7 +2152,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
 	  if (got)
 	    unit->dbase = got->vma;
 
-	  /* GCC emits the DW_EH_PE_textrel encoding type on sh and ia64
+	  /* GCC emits the DW_EH_PE_textrel encoding type on sh
 	     so far.  */
 	  txt = bfd_get_section_by_name (unit->abfd, ".text");
 	  if (txt)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 5b3c5ac8a02..e051f764497 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -110,10 +110,6 @@ const struct floatformat *floatformats_arm_ext[BFD_ENDIAN_UNKNOWN] = {
   &floatformat_arm_ext_big,
   &floatformat_arm_ext_littlebyte_bigword
 };
-const struct floatformat *floatformats_ia64_spill[BFD_ENDIAN_UNKNOWN] = {
-  &floatformat_ia64_spill_big,
-  &floatformat_ia64_spill_little
-};
 const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN] = {
   &floatformat_vax_f,
   &floatformat_vax_f
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index f80bd7e071a..f1370a3026e 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2198,7 +2198,6 @@ extern const struct floatformat *floatformats_ieee_double_littlebyte_bigword[BFD
 extern const struct floatformat *floatformats_i387_ext[BFD_ENDIAN_UNKNOWN];
 extern const struct floatformat *floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN];
 extern const struct floatformat *floatformats_arm_ext[BFD_ENDIAN_UNKNOWN];
-extern const struct floatformat *floatformats_ia64_spill[BFD_ENDIAN_UNKNOWN];
 extern const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN];
 extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
 extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN];
diff --git a/gdb/ia64-libunwind-tdep.c b/gdb/ia64-libunwind-tdep.c
deleted file mode 100644
index 72e4fae418d..00000000000
--- a/gdb/ia64-libunwind-tdep.c
+++ /dev/null
@@ -1,582 +0,0 @@
-/* Frame unwinder for ia64 frames using the libunwind library.
-
-   Copyright (C) 2003-2024 Free Software Foundation, Inc.
-
-   Written by Jeff Johnston, contributed by Red Hat Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-
-#include "inferior.h"
-#include "frame.h"
-#include "frame-base.h"
-#include "frame-unwind.h"
-#include "gdbcore.h"
-#include "gdbtypes.h"
-#include "symtab.h"
-#include "objfiles.h"
-#include "regcache.h"
-
-#include <dlfcn.h>
-
-#include "ia64-libunwind-tdep.h"
-
-#include "gdbsupport/preprocessor.h"
-
-/* IA-64 is the only target that currently uses ia64-libunwind-tdep.
-   Note how UNW_TARGET, UNW_OBJ, etc. are compile time constants below.
-   Those come from libunwind's headers, and are target dependent.
-   Also, some of libunwind's typedefs are target dependent, as e.g.,
-   unw_word_t.  If some other target wants to use this, we will need
-   to do some abstracting in order to make it possible to select which
-   libunwind we're talking to at runtime (and have one per arch).  */
-
-/* The following two macros are normally defined in <endian.h>.
-   But systems such as ia64-hpux do not provide such header, so
-   we just define them here if not already defined.  */
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN    4321
-#endif
-
-static int libunwind_initialized;
-static const registry<gdbarch>::key<libunwind_descr> libunwind_descr_handle;
-
-/* Required function pointers from libunwind.  */
-typedef int (unw_get_reg_p_ftype) (unw_cursor_t *, unw_regnum_t, unw_word_t *);
-static unw_get_reg_p_ftype *unw_get_reg_p;
-typedef int (unw_get_fpreg_p_ftype) (unw_cursor_t *, unw_regnum_t,
-				     unw_fpreg_t *);
-static unw_get_fpreg_p_ftype *unw_get_fpreg_p;
-typedef int (unw_get_saveloc_p_ftype) (unw_cursor_t *, unw_regnum_t,
-				       unw_save_loc_t *);
-static unw_get_saveloc_p_ftype *unw_get_saveloc_p;
-typedef int (unw_is_signal_frame_p_ftype) (unw_cursor_t *);
-static unw_is_signal_frame_p_ftype *unw_is_signal_frame_p;
-typedef int (unw_step_p_ftype) (unw_cursor_t *);
-static unw_step_p_ftype *unw_step_p;
-typedef int (unw_init_remote_p_ftype) (unw_cursor_t *, unw_addr_space_t,
-				       void *);
-static unw_init_remote_p_ftype *unw_init_remote_p;
-typedef unw_addr_space_t (unw_create_addr_space_p_ftype) (unw_accessors_t *,
-							  int);
-static unw_create_addr_space_p_ftype *unw_create_addr_space_p;
-typedef void (unw_destroy_addr_space_p_ftype) (unw_addr_space_t);
-static unw_destroy_addr_space_p_ftype *unw_destroy_addr_space_p;
-typedef int (unw_search_unwind_table_p_ftype) (unw_addr_space_t, unw_word_t,
-					       unw_dyn_info_t *,
-					       unw_proc_info_t *, int, void *);
-static unw_search_unwind_table_p_ftype *unw_search_unwind_table_p;
-typedef unw_word_t (unw_find_dyn_list_p_ftype) (unw_addr_space_t,
-						unw_dyn_info_t *, void *);
-static unw_find_dyn_list_p_ftype *unw_find_dyn_list_p;
-
-
-struct libunwind_frame_cache
-{
-  CORE_ADDR base;
-  CORE_ADDR func_addr;
-  unw_cursor_t cursor;
-  unw_addr_space_t as;
-};
-
-/* We need to qualify the function names with a platform-specific prefix
-   to match the names used by the libunwind library.  The UNW_OBJ macro is
-   provided by the libunwind.h header file.  */
-
-#ifndef LIBUNWIND_SO
-/* Use the stable ABI major version number.  `libunwind-ia64.so' is a link time
-   only library, not a runtime one.  */
-#define LIBUNWIND_SO "libunwind-" STRINGIFY(UNW_TARGET) ".so.8"
-
-/* Provide also compatibility with older .so.  The two APIs are compatible, .8
-   is only extended a bit, GDB does not use the extended API at all.  */
-#define LIBUNWIND_SO_7 "libunwind-" STRINGIFY(UNW_TARGET) ".so.7"
-#endif
-
-static const char *get_reg_name = STRINGIFY(UNW_OBJ(get_reg));
-static const char *get_fpreg_name = STRINGIFY(UNW_OBJ(get_fpreg));
-static const char *get_saveloc_name = STRINGIFY(UNW_OBJ(get_save_loc));
-static const char *is_signal_frame_name = STRINGIFY(UNW_OBJ(is_signal_frame));
-static const char *step_name = STRINGIFY(UNW_OBJ(step));
-static const char *init_remote_name = STRINGIFY(UNW_OBJ(init_remote));
-static const char *create_addr_space_name
-  = STRINGIFY(UNW_OBJ(create_addr_space));
-static const char *destroy_addr_space_name
-  = STRINGIFY(UNW_OBJ(destroy_addr_space));
-static const char *search_unwind_table_name
-  = STRINGIFY(UNW_OBJ(search_unwind_table));
-static const char *find_dyn_list_name = STRINGIFY(UNW_OBJ(find_dyn_list));
-
-static struct libunwind_descr *
-libunwind_descr (struct gdbarch *gdbarch)
-{
-  struct libunwind_descr *result = libunwind_descr_handle.get (gdbarch);
-  if (result == nullptr)
-    result = libunwind_descr_handle.emplace (gdbarch);
-  return result;
-}
-
-void
-libunwind_frame_set_descr (struct gdbarch *gdbarch,
-			   struct libunwind_descr *descr)
-{
-  struct libunwind_descr *arch_descr;
-
-  gdb_assert (gdbarch != NULL);
-
-  arch_descr = libunwind_descr (gdbarch);
-  gdb_assert (arch_descr != NULL);
-
-  /* Copy new descriptor info into arch descriptor.  */
-  arch_descr->gdb2uw = descr->gdb2uw;
-  arch_descr->uw2gdb = descr->uw2gdb;
-  arch_descr->is_fpreg = descr->is_fpreg;
-  arch_descr->accessors = descr->accessors;
-  arch_descr->special_accessors = descr->special_accessors;
-}
-
-static struct libunwind_frame_cache *
-libunwind_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
-{
-  unw_accessors_t *acc;
-  unw_addr_space_t as;
-  unw_word_t fp;
-  unw_regnum_t uw_sp_regnum;
-  struct libunwind_frame_cache *cache;
-  struct libunwind_descr *descr;
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  int ret;
-
-  if (*this_cache)
-    return (struct libunwind_frame_cache *) *this_cache;
-
-  /* Allocate a new cache.  */
-  cache = FRAME_OBSTACK_ZALLOC (struct libunwind_frame_cache);
-
-  cache->func_addr = get_frame_func (this_frame);
-  if (cache->func_addr == 0)
-    /* This can happen when the frame corresponds to a function for which
-       there is no debugging information nor any entry in the symbol table.
-       This is probably a static function for which an entry in the symbol
-       table was not created when the objfile got linked (observed in
-       libpthread.so on ia64-hpux).
-
-       The best we can do, in that case, is use the frame PC as the function
-       address.  We don't need to give up since we still have the unwind
-       record to help us perform the unwinding.  There is also another
-       compelling to continue, because abandoning now means stopping
-       the backtrace, which can never be helpful for the user.  */
-    cache->func_addr = get_frame_pc (this_frame);
-
-  /* Get a libunwind cursor to the previous frame.
-  
-     We do this by initializing a cursor.  Libunwind treats a new cursor
-     as the top of stack and will get the current register set via the
-     libunwind register accessor.  Now, we provide the platform-specific
-     accessors and we set up the register accessor to use the frame
-     register unwinding interfaces so that we properly get the registers
-     for the current frame rather than the top.  We then use the unw_step
-     function to move the libunwind cursor back one frame.  We can later
-     use this cursor to find previous registers via the unw_get_reg
-     interface which will invoke libunwind's special logic.  */
-  descr = libunwind_descr (gdbarch);
-  acc = (unw_accessors_t *) descr->accessors;
-  as =  unw_create_addr_space_p (acc,
-				 gdbarch_byte_order (gdbarch)
-				 == BFD_ENDIAN_BIG
-				 ? __BIG_ENDIAN
-				 : __LITTLE_ENDIAN);
-
-  unw_init_remote_p (&cache->cursor, as, this_frame);
-  if (unw_step_p (&cache->cursor) < 0)
-    {
-      unw_destroy_addr_space_p (as);
-      return NULL;
-    }
-
-  /* To get base address, get sp from previous frame.  */
-  uw_sp_regnum = descr->gdb2uw (gdbarch_sp_regnum (gdbarch));
-  ret = unw_get_reg_p (&cache->cursor, uw_sp_regnum, &fp);
-  if (ret < 0)
-    {
-      unw_destroy_addr_space_p (as);
-      error (_("Can't get libunwind sp register."));
-    }
-
-  cache->base = (CORE_ADDR)fp;
-  cache->as = as;
-
-  *this_cache = cache;
-  return cache;
-}
-
-void
-libunwind_frame_dealloc_cache (frame_info_ptr self, void *this_cache)
-{
-  struct libunwind_frame_cache *cache
-    = (struct libunwind_frame_cache *) this_cache;
-
-  if (cache->as)
-    unw_destroy_addr_space_p (cache->as);
-}
-
-unw_word_t
-libunwind_find_dyn_list (unw_addr_space_t as, unw_dyn_info_t *di, void *arg)
-{
-  return unw_find_dyn_list_p (as, di, arg);
-}
-
-/* Verify if there is sufficient libunwind information for the frame to use
-   libunwind frame unwinding.  */
-int
-libunwind_frame_sniffer (const struct frame_unwind *self,
-			 const frame_info_ptr &this_frame, void **this_cache)
-{
-  unw_cursor_t cursor;
-  unw_accessors_t *acc;
-  unw_addr_space_t as;
-  struct libunwind_descr *descr;
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  int ret;
-
-  /* To test for libunwind unwind support, initialize a cursor to
-     the current frame and try to back up.  We use this same method
-     when setting up the frame cache (see libunwind_frame_cache()).
-     If libunwind returns success for this operation, it means that
-     it has found sufficient libunwind unwinding information to do so.  */
-
-  descr = libunwind_descr (gdbarch);
-  acc = (unw_accessors_t *) descr->accessors;
-  as =  unw_create_addr_space_p (acc,
-				 gdbarch_byte_order (gdbarch)
-				 == BFD_ENDIAN_BIG
-				 ? __BIG_ENDIAN
-				 : __LITTLE_ENDIAN);
-
-  ret = unw_init_remote_p (&cursor, as, this_frame);
-
-  if (ret < 0)
-    {
-      unw_destroy_addr_space_p (as);
-      return 0;
-    }
-
- 
-  /* Check to see if we have libunwind info by checking if we are in a 
-     signal frame.  If it doesn't return an error, we have libunwind info
-     and can use libunwind.  */
-  ret = unw_is_signal_frame_p (&cursor);
-  unw_destroy_addr_space_p (as);
-
-  if (ret < 0)
-    return 0;
-
-  return 1;
-}
-
-void
-libunwind_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
-			 struct frame_id *this_id)
-{
-  struct libunwind_frame_cache *cache =
-    libunwind_frame_cache (this_frame, this_cache);
-
-  if (cache != NULL)
-    (*this_id) = frame_id_build (cache->base, cache->func_addr);
-}
-
-struct value *
-libunwind_frame_prev_register (const frame_info_ptr &this_frame,
-			       void **this_cache, int regnum)
-{
-  struct libunwind_frame_cache *cache =
-    libunwind_frame_cache (this_frame, this_cache);
-
-  unw_save_loc_t sl;
-  int ret;
-  unw_word_t intval;
-  unw_fpreg_t fpval;
-  unw_regnum_t uw_regnum;
-  struct libunwind_descr *descr;
-  struct value *val = NULL;
-
-  if (cache == NULL)
-    return frame_unwind_got_constant (this_frame, regnum, 0);
-  
-  /* Convert from gdb register number to libunwind register number.  */
-  descr = libunwind_descr (get_frame_arch (this_frame));
-  uw_regnum = descr->gdb2uw (regnum);
-
-  gdb_assert (regnum >= 0);
-
-  if (!target_has_registers ())
-    error (_("No registers."));
-
-  if (uw_regnum < 0)
-    return frame_unwind_got_constant (this_frame, regnum, 0);
-
-  if (unw_get_saveloc_p (&cache->cursor, uw_regnum, &sl) < 0)
-    return frame_unwind_got_constant (this_frame, regnum, 0);
-
-  switch (sl.type)
-    {
-    case UNW_SLT_MEMORY:
-      val = frame_unwind_got_memory (this_frame, regnum, sl.u.addr);
-      break;
-
-    case UNW_SLT_REG:
-      val = frame_unwind_got_register (this_frame, regnum,
-				       descr->uw2gdb (sl.u.regnum));
-      break;
-    case UNW_SLT_NONE:
-      {
-	/* The register is not stored at a specific memory address nor
-	   inside another register.  So use libunwind to fetch the register
-	   value for us, and create a constant value with the result.  */
-	if (descr->is_fpreg (uw_regnum))
-	  {
-	    ret = unw_get_fpreg_p (&cache->cursor, uw_regnum, &fpval);
-	    if (ret < 0)
-	      return frame_unwind_got_constant (this_frame, regnum, 0);
-	    val = frame_unwind_got_bytes (this_frame, regnum,
-					  (gdb_byte *) &fpval);
-	  }
-	else
-	  {
-	    ret = unw_get_reg_p (&cache->cursor, uw_regnum, &intval);
-	    if (ret < 0)
-	      return frame_unwind_got_constant (this_frame, regnum, 0);
-	    val = frame_unwind_got_constant (this_frame, regnum, intval);
-	  }
-	break;
-      }
-    }
-
-  return val;
-} 
-
-/* The following is a glue routine to call the libunwind unwind table
-   search function to get unwind information for a specified ip address.  */ 
-int
-libunwind_search_unwind_table (void *as, long ip, void *di,
-			       void *pi, int need_unwind_info, void *args)
-{
-  return unw_search_unwind_table_p (*(unw_addr_space_t *) as, (unw_word_t) ip,
-				    (unw_dyn_info_t *) di,
-				    (unw_proc_info_t *) pi, need_unwind_info,
-				    args);
-}
-
-/* Verify if we are in a sigtramp frame and we can use libunwind to unwind.  */
-int
-libunwind_sigtramp_frame_sniffer (const struct frame_unwind *self,
-				  const frame_info_ptr &this_frame,
-				  void **this_cache)
-{
-  unw_cursor_t cursor;
-  unw_accessors_t *acc;
-  unw_addr_space_t as;
-  struct libunwind_descr *descr;
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  int ret;
-
-  /* To test for libunwind unwind support, initialize a cursor to the
-     current frame and try to back up.  We use this same method when
-     setting up the frame cache (see libunwind_frame_cache()).  If
-     libunwind returns success for this operation, it means that it
-     has found sufficient libunwind unwinding information to do
-     so.  */
-
-  descr = libunwind_descr (gdbarch);
-  acc = (unw_accessors_t *) descr->accessors;
-  as =  unw_create_addr_space_p (acc,
-				 gdbarch_byte_order (gdbarch)
-				 == BFD_ENDIAN_BIG
-				 ? __BIG_ENDIAN
-				 : __LITTLE_ENDIAN);
-
-  ret = unw_init_remote_p (&cursor, as, this_frame);
-
-  if (ret < 0)
-    {
-      unw_destroy_addr_space_p (as);
-      return 0;
-    }
-
-  /* Check to see if we are in a signal frame.  */
-  ret = unw_is_signal_frame_p (&cursor);
-  unw_destroy_addr_space_p (as);
-  if (ret > 0)
-    return 1;
-
-  return 0;
-}
-
-/* The following routine is for accessing special registers of the top frame.
-   A special set of accessors must be given that work without frame info.
-   This is used by ia64 to access the rse registers r32-r127.  While they
-   are usually located at BOF, this is not always true and only the libunwind
-   info can decipher where they actually are.  */
-int
-libunwind_get_reg_special (struct gdbarch *gdbarch, readable_regcache *regcache,
-			   int regnum, void *buf)
-{
-  unw_cursor_t cursor;
-  unw_accessors_t *acc;
-  unw_addr_space_t as;
-  struct libunwind_descr *descr;
-  int ret;
-  unw_regnum_t uw_regnum;
-  unw_word_t intval;
-  unw_fpreg_t fpval;
-  void *ptr;
-
-
-  descr = libunwind_descr (gdbarch);
-  acc = (unw_accessors_t *) descr->special_accessors;
-  as =  unw_create_addr_space_p (acc,
-				 gdbarch_byte_order (gdbarch)
-				 == BFD_ENDIAN_BIG
-				 ? __BIG_ENDIAN
-				 : __LITTLE_ENDIAN);
-
-  ret = unw_init_remote_p (&cursor, as, regcache);
-  if (ret < 0)
-    {
-      unw_destroy_addr_space_p (as);
-      return -1;
-    }
-
-  uw_regnum = descr->gdb2uw (regnum);
-
-  if (descr->is_fpreg (uw_regnum))
-    {
-      ret = unw_get_fpreg_p (&cursor, uw_regnum, &fpval);
-      ptr = &fpval;
-    }
-  else
-    {
-      ret = unw_get_reg_p (&cursor, uw_regnum, &intval);
-      ptr = &intval;
-    }
-
-  unw_destroy_addr_space_p (as);
-
-  if (ret < 0)
-    return -1;
-
-  if (buf)
-    memcpy (buf, ptr, register_size (gdbarch, regnum));
-
-  return 0;
-}
-  
-static int
-libunwind_load (void)
-{
-  void *handle;
-  char *so_error = NULL;
-
-  handle = dlopen (LIBUNWIND_SO, RTLD_NOW);
-  if (handle == NULL)
-    {
-      so_error = xstrdup (dlerror ());
-#ifdef LIBUNWIND_SO_7
-      handle = dlopen (LIBUNWIND_SO_7, RTLD_NOW);
-#endif /* LIBUNWIND_SO_7 */
-    }
-  if (handle == NULL)
-    {
-      gdb_printf (gdb_stderr, _("[GDB failed to load %s: %s]\n"),
-		  LIBUNWIND_SO, so_error);
-#ifdef LIBUNWIND_SO_7
-      gdb_printf (gdb_stderr, _("[GDB failed to load %s: %s]\n"),
-		  LIBUNWIND_SO_7, dlerror ());
-#endif /* LIBUNWIND_SO_7 */
-    }
-  xfree (so_error);
-  if (handle == NULL)
-    return 0;
-
-  /* Initialize pointers to the dynamic library functions we will use.  */
-
-  unw_get_reg_p = (unw_get_reg_p_ftype *) dlsym (handle, get_reg_name);
-  if (unw_get_reg_p == NULL)
-    return 0;
-
-  unw_get_fpreg_p = (unw_get_fpreg_p_ftype *) dlsym (handle, get_fpreg_name);
-  if (unw_get_fpreg_p == NULL)
-    return 0;
-
-  unw_get_saveloc_p
-    = (unw_get_saveloc_p_ftype *) dlsym (handle, get_saveloc_name);
-  if (unw_get_saveloc_p == NULL)
-    return 0;
-
-  unw_is_signal_frame_p
-    = (unw_is_signal_frame_p_ftype *) dlsym (handle, is_signal_frame_name);
-  if (unw_is_signal_frame_p == NULL)
-    return 0;
-
-  unw_step_p = (unw_step_p_ftype *) dlsym (handle, step_name);
-  if (unw_step_p == NULL)
-    return 0;
-
-  unw_init_remote_p
-    = (unw_init_remote_p_ftype *) dlsym (handle, init_remote_name);
-  if (unw_init_remote_p == NULL)
-    return 0;
-
-  unw_create_addr_space_p
-    = (unw_create_addr_space_p_ftype *) dlsym (handle, create_addr_space_name);
-  if (unw_create_addr_space_p == NULL)
-    return 0;
-
-  unw_destroy_addr_space_p
-    = (unw_destroy_addr_space_p_ftype *) dlsym (handle,
-						destroy_addr_space_name);
-  if (unw_destroy_addr_space_p == NULL)
-    return 0;
-
-  unw_search_unwind_table_p
-    = (unw_search_unwind_table_p_ftype *) dlsym (handle,
-						 search_unwind_table_name);
-  if (unw_search_unwind_table_p == NULL)
-    return 0;
-
-  unw_find_dyn_list_p
-    = (unw_find_dyn_list_p_ftype *) dlsym (handle, find_dyn_list_name);
-  if (unw_find_dyn_list_p == NULL)
-    return 0;
-   
-  return 1;
-}
-
-int
-libunwind_is_initialized (void)
-{
-  return libunwind_initialized;
-}
-
-void _initialize_libunwind_frame ();
-void
-_initialize_libunwind_frame ()
-{
-  libunwind_initialized = libunwind_load ();
-}
diff --git a/gdb/ia64-libunwind-tdep.h b/gdb/ia64-libunwind-tdep.h
deleted file mode 100644
index 4f064bfc333..00000000000
--- a/gdb/ia64-libunwind-tdep.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Frame unwinder for ia64 frames with libunwind frame information.
-
-   Copyright (C) 2003-2024 Free Software Foundation, Inc.
-
-   Contributed by Jeff Johnston.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef IA64_LIBUNWIND_TDEP_H
-#define IA64_LIBUNWIND_TDEP_H 1
-
-class frame_info_ptr;
-struct frame_id;
-struct regcache;
-struct gdbarch;
-struct frame_unwind;
-
-/* IA-64 is the only target that currently uses libunwind.  If some
-   other target wants to use it, we will need to do some abstracting
-   in order to make it possible to have more than one
-   ia64-libunwind-tdep instance.  Including "libunwind.h" is wrong as
-   that ends up including the libunwind-$(arch).h for the host gdb is
-   running on.  */
-#include "libunwind-ia64.h"
-
-#include "gdbarch.h"
-
-struct libunwind_descr
-{
-  int (*gdb2uw) (int) = nullptr;
-  int (*uw2gdb) (int) = nullptr;
-  int (*is_fpreg) (int) = nullptr;
-  void *accessors = nullptr;
-  void *special_accessors = nullptr;
-};
-
-int libunwind_frame_sniffer (const struct frame_unwind *self,
-			     const frame_info_ptr &this_frame,
-			     void **this_cache);
-			  
-int libunwind_sigtramp_frame_sniffer (const struct frame_unwind *self,
-				      const frame_info_ptr &this_frame,
-				      void **this_cache);
-
-void libunwind_frame_set_descr (struct gdbarch *arch,
-				struct libunwind_descr *descr);
-
-void libunwind_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
-			      struct frame_id *this_id);
-struct value *libunwind_frame_prev_register (const frame_info_ptr &this_frame,
-					     void **this_cache, int regnum);
-void libunwind_frame_dealloc_cache (frame_info_ptr self, void *cache);
-
-int libunwind_is_initialized (void);
-
-int libunwind_search_unwind_table (void *as, long ip, void *di,
-				   void *pi, int need_unwind_info, void *args);
-
-unw_word_t libunwind_find_dyn_list (unw_addr_space_t, unw_dyn_info_t *,
-				    void *);
-
-int libunwind_get_reg_special (struct gdbarch *gdbarch,
-			       readable_regcache *regcache,
-			       int regnum, void *buf);
-
-#endif /* IA64_LIBUNWIND_TDEP_H */
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
deleted file mode 100644
index 7a8e742daea..00000000000
--- a/gdb/ia64-linux-nat.c
+++ /dev/null
@@ -1,931 +0,0 @@
-/* Functions specific to running gdb native on IA-64 running
-   GNU/Linux.
-
-   Copyright (C) 1999-2024 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "inferior.h"
-#include "target.h"
-#include "gdbarch.h"
-#include "gdbcore.h"
-#include "regcache.h"
-#include "ia64-tdep.h"
-#include "linux-nat.h"
-
-#include <signal.h>
-#include "nat/gdb_ptrace.h"
-#include "gdbsupport/gdb_wait.h"
-#ifdef HAVE_SYS_REG_H
-#include <sys/reg.h>
-#endif
-#include <sys/syscall.h>
-#include <sys/user.h>
-
-#include <asm/ptrace_offsets.h>
-#include <sys/procfs.h>
-
-/* Prototypes for supply_gregset etc.  */
-#include "gregset.h"
-
-#include "inf-ptrace.h"
-
-class ia64_linux_nat_target final : public linux_nat_target
-{
-public:
-  /* Add our register access methods.  */
-  void fetch_registers (struct regcache *, int) override;
-  void store_registers (struct regcache *, int) override;
-
-  enum target_xfer_status xfer_partial (enum target_object object,
-					const char *annex,
-					gdb_byte *readbuf,
-					const gdb_byte *writebuf,
-					ULONGEST offset, ULONGEST len,
-					ULONGEST *xfered_len) override;
-
-  /* Override watchpoint routines.  */
-
-  /* The IA-64 architecture can step over a watch point (without
-     triggering it again) if the "dd" (data debug fault disable) bit
-     in the processor status word is set.
-
-     This PSR bit is set in
-     ia64_linux_nat_target::stopped_by_watchpoint when the code there
-     has determined that a hardware watchpoint has indeed been hit.
-     The CPU will then be able to execute one instruction without
-     triggering a watchpoint.  */
-  bool have_steppable_watchpoint () override { return true; }
-
-  int can_use_hw_breakpoint (enum bptype, int, int) override;
-  bool stopped_by_watchpoint () override;
-  bool stopped_data_address (CORE_ADDR *) override;
-  int insert_watchpoint (CORE_ADDR, int, enum target_hw_bp_type,
-			 struct expression *) override;
-  int remove_watchpoint (CORE_ADDR, int, enum target_hw_bp_type,
-			 struct expression *) override;
-  /* Override linux_nat_target low methods.  */
-  void low_new_thread (struct lwp_info *lp) override;
-  bool low_status_is_event (int status) override;
-
-  void enable_watchpoints_in_psr (ptid_t ptid);
-};
-
-static ia64_linux_nat_target the_ia64_linux_nat_target;
-
-/* These must match the order of the register names.
-
-   Some sort of lookup table is needed because the offsets associated
-   with the registers are all over the board.  */
-
-static int u_offsets[] =
-  {
-    /* general registers */
-    -1,		/* gr0 not available; i.e, it's always zero.  */
-    PT_R1,
-    PT_R2,
-    PT_R3,
-    PT_R4,
-    PT_R5,
-    PT_R6,
-    PT_R7,
-    PT_R8,
-    PT_R9,
-    PT_R10,
-    PT_R11,
-    PT_R12,
-    PT_R13,
-    PT_R14,
-    PT_R15,
-    PT_R16,
-    PT_R17,
-    PT_R18,
-    PT_R19,
-    PT_R20,
-    PT_R21,
-    PT_R22,
-    PT_R23,
-    PT_R24,
-    PT_R25,
-    PT_R26,
-    PT_R27,
-    PT_R28,
-    PT_R29,
-    PT_R30,
-    PT_R31,
-    /* gr32 through gr127 not directly available via the ptrace interface.  */
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    /* Floating point registers */
-    -1, -1,	/* f0 and f1 not available (f0 is +0.0 and f1 is +1.0).  */
-    PT_F2,
-    PT_F3,
-    PT_F4,
-    PT_F5,
-    PT_F6,
-    PT_F7,
-    PT_F8,
-    PT_F9,
-    PT_F10,
-    PT_F11,
-    PT_F12,
-    PT_F13,
-    PT_F14,
-    PT_F15,
-    PT_F16,
-    PT_F17,
-    PT_F18,
-    PT_F19,
-    PT_F20,
-    PT_F21,
-    PT_F22,
-    PT_F23,
-    PT_F24,
-    PT_F25,
-    PT_F26,
-    PT_F27,
-    PT_F28,
-    PT_F29,
-    PT_F30,
-    PT_F31,
-    PT_F32,
-    PT_F33,
-    PT_F34,
-    PT_F35,
-    PT_F36,
-    PT_F37,
-    PT_F38,
-    PT_F39,
-    PT_F40,
-    PT_F41,
-    PT_F42,
-    PT_F43,
-    PT_F44,
-    PT_F45,
-    PT_F46,
-    PT_F47,
-    PT_F48,
-    PT_F49,
-    PT_F50,
-    PT_F51,
-    PT_F52,
-    PT_F53,
-    PT_F54,
-    PT_F55,
-    PT_F56,
-    PT_F57,
-    PT_F58,
-    PT_F59,
-    PT_F60,
-    PT_F61,
-    PT_F62,
-    PT_F63,
-    PT_F64,
-    PT_F65,
-    PT_F66,
-    PT_F67,
-    PT_F68,
-    PT_F69,
-    PT_F70,
-    PT_F71,
-    PT_F72,
-    PT_F73,
-    PT_F74,
-    PT_F75,
-    PT_F76,
-    PT_F77,
-    PT_F78,
-    PT_F79,
-    PT_F80,
-    PT_F81,
-    PT_F82,
-    PT_F83,
-    PT_F84,
-    PT_F85,
-    PT_F86,
-    PT_F87,
-    PT_F88,
-    PT_F89,
-    PT_F90,
-    PT_F91,
-    PT_F92,
-    PT_F93,
-    PT_F94,
-    PT_F95,
-    PT_F96,
-    PT_F97,
-    PT_F98,
-    PT_F99,
-    PT_F100,
-    PT_F101,
-    PT_F102,
-    PT_F103,
-    PT_F104,
-    PT_F105,
-    PT_F106,
-    PT_F107,
-    PT_F108,
-    PT_F109,
-    PT_F110,
-    PT_F111,
-    PT_F112,
-    PT_F113,
-    PT_F114,
-    PT_F115,
-    PT_F116,
-    PT_F117,
-    PT_F118,
-    PT_F119,
-    PT_F120,
-    PT_F121,
-    PT_F122,
-    PT_F123,
-    PT_F124,
-    PT_F125,
-    PT_F126,
-    PT_F127,
-    /* Predicate registers - we don't fetch these individually.  */
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    /* branch registers */
-    PT_B0,
-    PT_B1,
-    PT_B2,
-    PT_B3,
-    PT_B4,
-    PT_B5,
-    PT_B6,
-    PT_B7,
-    /* Virtual frame pointer and virtual return address pointer.  */
-    -1, -1,
-    /* other registers */
-    PT_PR,
-    PT_CR_IIP,	/* ip */
-    PT_CR_IPSR, /* psr */
-    PT_CFM,	/* cfm */
-    /* kernel registers not visible via ptrace interface (?)  */
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    /* hole */
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    PT_AR_RSC,
-    PT_AR_BSP,
-    PT_AR_BSPSTORE,
-    PT_AR_RNAT,
-    -1,
-    -1,		/* Not available: FCR, IA32 floating control register.  */
-    -1, -1,
-    -1,		/* Not available: EFLAG */
-    -1,		/* Not available: CSD */
-    -1,		/* Not available: SSD */
-    -1,		/* Not available: CFLG */
-    -1,		/* Not available: FSR */
-    -1,		/* Not available: FIR */
-    -1,		/* Not available: FDR */
-    -1,
-    PT_AR_CCV,
-    -1, -1, -1,
-    PT_AR_UNAT,
-    -1, -1, -1,
-    PT_AR_FPSR,
-    -1, -1, -1,
-    -1,		/* Not available: ITC */
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    PT_AR_PFS,
-    PT_AR_LC,
-    PT_AR_EC,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1,
-    /* nat bits - not fetched directly; instead we obtain these bits from
-       either rnat or unat or from memory.  */
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-  };
-
-static CORE_ADDR
-ia64_register_addr (struct gdbarch *gdbarch, int regno)
-{
-  CORE_ADDR addr;
-
-  if (regno < 0 || regno >= gdbarch_num_regs (gdbarch))
-    error (_("Invalid register number %d."), regno);
-
-  if (u_offsets[regno] == -1)
-    addr = 0;
-  else
-    addr = (CORE_ADDR) u_offsets[regno];
-
-  return addr;
-}
-
-static int
-ia64_cannot_fetch_register (struct gdbarch *gdbarch, int regno)
-{
-  return regno < 0
-	 || regno >= gdbarch_num_regs (gdbarch)
-	 || u_offsets[regno] == -1;
-}
-
-static int
-ia64_cannot_store_register (struct gdbarch *gdbarch, int regno)
-{
-  /* Rationale behind not permitting stores to bspstore...
-  
-     The IA-64 architecture provides bspstore and bsp which refer
-     memory locations in the RSE's backing store.  bspstore is the
-     next location which will be written when the RSE needs to write
-     to memory.  bsp is the address at which r32 in the current frame
-     would be found if it were written to the backing store.
-
-     The IA-64 architecture provides read-only access to bsp and
-     read/write access to bspstore (but only when the RSE is in
-     the enforced lazy mode).  It should be noted that stores
-     to bspstore also affect the value of bsp.  Changing bspstore
-     does not affect the number of dirty entries between bspstore
-     and bsp, so changing bspstore by N words will also cause bsp
-     to be changed by (roughly) N as well.  (It could be N-1 or N+1
-     depending upon where the NaT collection bits fall.)
-
-     OTOH, the Linux kernel provides read/write access to bsp (and
-     currently read/write access to bspstore as well).  But it
-     is definitely the case that if you change one, the other
-     will change at the same time.  It is more useful to gdb to
-     be able to change bsp.  So in order to prevent strange and
-     undesirable things from happening when a dummy stack frame
-     is popped (after calling an inferior function), we allow
-     bspstore to be read, but not written.  (Note that popping
-     a (generic) dummy stack frame causes all registers that
-     were previously read from the inferior process to be written
-     back.)  */
-
-  return regno < 0
-	 || regno >= gdbarch_num_regs (gdbarch)
-	 || u_offsets[regno] == -1
-	 || regno == IA64_BSPSTORE_REGNUM;
-}
-
-void
-supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
-{
-  int regi;
-  const greg_t *regp = (const greg_t *) gregsetp;
-
-  for (regi = IA64_GR0_REGNUM; regi <= IA64_GR31_REGNUM; regi++)
-    {
-      regcache->raw_supply (regi, regp + (regi - IA64_GR0_REGNUM));
-    }
-
-  /* FIXME: NAT collection bits are at index 32; gotta deal with these
-     somehow...  */
-
-  regcache->raw_supply (IA64_PR_REGNUM, regp + 33);
-
-  for (regi = IA64_BR0_REGNUM; regi <= IA64_BR7_REGNUM; regi++)
-    {
-      regcache->raw_supply (regi, regp + 34 + (regi - IA64_BR0_REGNUM));
-    }
-
-  regcache->raw_supply (IA64_IP_REGNUM, regp + 42);
-  regcache->raw_supply (IA64_CFM_REGNUM, regp + 43);
-  regcache->raw_supply (IA64_PSR_REGNUM, regp + 44);
-  regcache->raw_supply (IA64_RSC_REGNUM, regp + 45);
-  regcache->raw_supply (IA64_BSP_REGNUM, regp + 46);
-  regcache->raw_supply (IA64_BSPSTORE_REGNUM, regp + 47);
-  regcache->raw_supply (IA64_RNAT_REGNUM, regp + 48);
-  regcache->raw_supply (IA64_CCV_REGNUM, regp + 49);
-  regcache->raw_supply (IA64_UNAT_REGNUM, regp + 50);
-  regcache->raw_supply (IA64_FPSR_REGNUM, regp + 51);
-  regcache->raw_supply (IA64_PFS_REGNUM, regp + 52);
-  regcache->raw_supply (IA64_LC_REGNUM, regp + 53);
-  regcache->raw_supply (IA64_EC_REGNUM, regp + 54);
-}
-
-void
-fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno)
-{
-  int regi;
-  greg_t *regp = (greg_t *) gregsetp;
-
-#define COPY_REG(_idx_,_regi_) \
-  if ((regno == -1) || regno == _regi_) \
-    regcache->raw_collect (_regi_, regp + _idx_)
-
-  for (regi = IA64_GR0_REGNUM; regi <= IA64_GR31_REGNUM; regi++)
-    {
-      COPY_REG (regi - IA64_GR0_REGNUM, regi);
-    }
-
-  /* FIXME: NAT collection bits at index 32?  */
-
-  COPY_REG (33, IA64_PR_REGNUM);
-
-  for (regi = IA64_BR0_REGNUM; regi <= IA64_BR7_REGNUM; regi++)
-    {
-      COPY_REG (34 + (regi - IA64_BR0_REGNUM), regi);
-    }
-
-  COPY_REG (42, IA64_IP_REGNUM);
-  COPY_REG (43, IA64_CFM_REGNUM);
-  COPY_REG (44, IA64_PSR_REGNUM);
-  COPY_REG (45, IA64_RSC_REGNUM);
-  COPY_REG (46, IA64_BSP_REGNUM);
-  COPY_REG (47, IA64_BSPSTORE_REGNUM);
-  COPY_REG (48, IA64_RNAT_REGNUM);
-  COPY_REG (49, IA64_CCV_REGNUM);
-  COPY_REG (50, IA64_UNAT_REGNUM);
-  COPY_REG (51, IA64_FPSR_REGNUM);
-  COPY_REG (52, IA64_PFS_REGNUM);
-  COPY_REG (53, IA64_LC_REGNUM);
-  COPY_REG (54, IA64_EC_REGNUM);
-}
-
-/*  Given a pointer to a floating point register set in /proc format
-   (fpregset_t *), unpack the register contents and supply them as gdb's
-   idea of the current floating point register values.  */
-
-void
-supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
-{
-  int regi;
-  const char *from;
-  const gdb_byte f_zero[16] = { 0 };
-  const gdb_byte f_one[16] =
-    { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };
-
-  /* Kernel generated cores have fr1==0 instead of 1.0.  Older GDBs
-     did the same.  So ignore whatever might be recorded in fpregset_t
-     for fr0/fr1 and always supply their expected values.  */
-
-  /* fr0 is always read as zero.  */
-  regcache->raw_supply (IA64_FR0_REGNUM, f_zero);
-  /* fr1 is always read as one (1.0).  */
-  regcache->raw_supply (IA64_FR1_REGNUM, f_one);
-
-  for (regi = IA64_FR2_REGNUM; regi <= IA64_FR127_REGNUM; regi++)
-    {
-      from = (const char *) &((*fpregsetp)[regi - IA64_FR0_REGNUM]);
-      regcache->raw_supply (regi, from);
-    }
-}
-
-/*  Given a pointer to a floating point register set in /proc format
-   (fpregset_t *), update the register specified by REGNO from gdb's idea
-   of the current floating point register set.  If REGNO is -1, update
-   them all.  */
-
-void
-fill_fpregset (const struct regcache *regcache,
-	       fpregset_t *fpregsetp, int regno)
-{
-  int regi;
-
-  for (regi = IA64_FR0_REGNUM; regi <= IA64_FR127_REGNUM; regi++)
-    {
-      if ((regno == -1) || (regno == regi))
-	regcache->raw_collect (regi, &((*fpregsetp)[regi - IA64_FR0_REGNUM]));
-    }
-}
-
-#define IA64_PSR_DB (1UL << 24)
-#define IA64_PSR_DD (1UL << 39)
-
-void
-ia64_linux_nat_target::enable_watchpoints_in_psr (ptid_t ptid)
-{
-  struct regcache *regcache = get_thread_regcache (this, ptid);
-  ULONGEST psr;
-
-  regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr);
-  if (!(psr & IA64_PSR_DB))
-    {
-      psr |= IA64_PSR_DB;	/* Set the db bit - this enables hardware
-				   watchpoints and breakpoints.  */
-      regcache_cooked_write_unsigned (regcache, IA64_PSR_REGNUM, psr);
-    }
-}
-
-static long debug_registers[8];
-
-static void
-store_debug_register (ptid_t ptid, int idx, long val)
-{
-  int tid;
-
-  tid = ptid.lwp ();
-  if (tid == 0)
-    tid = ptid.pid ();
-
-  (void) ptrace (PT_WRITE_U, tid, (PTRACE_TYPE_ARG3) (PT_DBR + 8 * idx), val);
-}
-
-static void
-store_debug_register_pair (ptid_t ptid, int idx, long *dbr_addr,
-			   long *dbr_mask)
-{
-  if (dbr_addr)
-    store_debug_register (ptid, 2 * idx, *dbr_addr);
-  if (dbr_mask)
-    store_debug_register (ptid, 2 * idx + 1, *dbr_mask);
-}
-
-static int
-is_power_of_2 (int val)
-{
-  int i, onecount;
-
-  onecount = 0;
-  for (i = 0; i < 8 * sizeof (val); i++)
-    if (val & (1 << i))
-      onecount++;
-
-  return onecount <= 1;
-}
-
-int
-ia64_linux_nat_target::insert_watchpoint (CORE_ADDR addr, int len,
-					  enum target_hw_bp_type type,
-					  struct expression *cond)
-{
-  int idx;
-  long dbr_addr, dbr_mask;
-  int max_watchpoints = 4;
-
-  if (len <= 0 || !is_power_of_2 (len))
-    return -1;
-
-  for (idx = 0; idx < max_watchpoints; idx++)
-    {
-      dbr_mask = debug_registers[idx * 2 + 1];
-      if ((dbr_mask & (0x3UL << 62)) == 0)
-	{
-	  /* Exit loop if both r and w bits clear.  */
-	  break;
-	}
-    }
-
-  if (idx == max_watchpoints)
-    return -1;
-
-  dbr_addr = (long) addr;
-  dbr_mask = (~(len - 1) & 0x00ffffffffffffffL);  /* construct mask to match */
-  dbr_mask |= 0x0800000000000000L;           /* Only match privilege level 3 */
-  switch (type)
-    {
-    case hw_write:
-      dbr_mask |= (1L << 62);			/* Set w bit */
-      break;
-    case hw_read:
-      dbr_mask |= (1L << 63);			/* Set r bit */
-      break;
-    case hw_access:
-      dbr_mask |= (3L << 62);			/* Set both r and w bits */
-      break;
-    default:
-      return -1;
-    }
-
-  debug_registers[2 * idx] = dbr_addr;
-  debug_registers[2 * idx + 1] = dbr_mask;
-
-  for (const lwp_info *lp : all_lwps ())
-    {
-      store_debug_register_pair (lp->ptid, idx, &dbr_addr, &dbr_mask);
-      enable_watchpoints_in_psr (lp->ptid);
-    }
-
-  return 0;
-}
-
-int
-ia64_linux_nat_target::remove_watchpoint (CORE_ADDR addr, int len,
-					  enum target_hw_bp_type type,
-					  struct expression *cond)
-{
-  int idx;
-  long dbr_addr, dbr_mask;
-  int max_watchpoints = 4;
-
-  if (len <= 0 || !is_power_of_2 (len))
-    return -1;
-
-  for (idx = 0; idx < max_watchpoints; idx++)
-    {
-      dbr_addr = debug_registers[2 * idx];
-      dbr_mask = debug_registers[2 * idx + 1];
-      if ((dbr_mask & (0x3UL << 62)) && addr == (CORE_ADDR) dbr_addr)
-	{
-	  debug_registers[2 * idx] = 0;
-	  debug_registers[2 * idx + 1] = 0;
-	  dbr_addr = 0;
-	  dbr_mask = 0;
-
-	  for (const lwp_info *lp : all_lwps ())
-	    store_debug_register_pair (lp->ptid, idx, &dbr_addr, &dbr_mask);
-
-	  return 0;
-	}
-    }
-  return -1;
-}
-
-void
-ia64_linux_nat_target::low_new_thread (struct lwp_info *lp)
-{
-  int i, any;
-
-  any = 0;
-  for (i = 0; i < 8; i++)
-    {
-      if (debug_registers[i] != 0)
-	any = 1;
-      store_debug_register (lp->ptid, i, debug_registers[i]);
-    }
-
-  if (any)
-    enable_watchpoints_in_psr (lp->ptid);
-}
-
-bool
-ia64_linux_nat_target::stopped_data_address (CORE_ADDR *addr_p)
-{
-  CORE_ADDR psr;
-  siginfo_t siginfo;
-  regcache *regcache = get_thread_regcache (inferior_thread ());
-
-  if (!linux_nat_get_siginfo (inferior_ptid, &siginfo))
-    return false;
-
-  if (siginfo.si_signo != SIGTRAP
-      || (siginfo.si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */)
-    return false;
-
-  regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr);
-  psr |= IA64_PSR_DD;	/* Set the dd bit - this will disable the watchpoint
-			   for the next instruction.  */
-  regcache_cooked_write_unsigned (regcache, IA64_PSR_REGNUM, psr);
-
-  *addr_p = (CORE_ADDR) siginfo.si_addr;
-  return true;
-}
-
-bool
-ia64_linux_nat_target::stopped_by_watchpoint ()
-{
-  CORE_ADDR addr;
-  return stopped_data_address (&addr);
-}
-
-int
-ia64_linux_nat_target::can_use_hw_breakpoint (enum bptype type,
-					      int cnt, int othertype)
-{
-  return 1;
-}
-
-
-/* Fetch register REGNUM from the inferior.  */
-
-static void
-ia64_linux_fetch_register (struct regcache *regcache, int regnum)
-{
-  struct gdbarch *gdbarch = regcache->arch ();
-  CORE_ADDR addr;
-  size_t size;
-  PTRACE_TYPE_RET *buf;
-  pid_t pid;
-  int i;
-
-  /* r0 cannot be fetched but is always zero.  */
-  if (regnum == IA64_GR0_REGNUM)
-    {
-      const gdb_byte zero[8] = { 0 };
-
-      gdb_assert (sizeof (zero) == register_size (gdbarch, regnum));
-      regcache->raw_supply (regnum, zero);
-      return;
-    }
-
-  /* fr0 cannot be fetched but is always zero.  */
-  if (regnum == IA64_FR0_REGNUM)
-    {
-      const gdb_byte f_zero[16] = { 0 };
-
-      gdb_assert (sizeof (f_zero) == register_size (gdbarch, regnum));
-      regcache->raw_supply (regnum, f_zero);
-      return;
-    }
-
-  /* fr1 cannot be fetched but is always one (1.0).  */
-  if (regnum == IA64_FR1_REGNUM)
-    {
-      const gdb_byte f_one[16] =
-	{ 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };
-
-      gdb_assert (sizeof (f_one) == register_size (gdbarch, regnum));
-      regcache->raw_supply (regnum, f_one);
-      return;
-    }
-
-  if (ia64_cannot_fetch_register (gdbarch, regnum))
-    {
-      regcache->raw_supply (regnum, NULL);
-      return;
-    }
-
-  pid = get_ptrace_pid (regcache->ptid ());
-
-  /* This isn't really an address, but ptrace thinks of it as one.  */
-  addr = ia64_register_addr (gdbarch, regnum);
-  size = register_size (gdbarch, regnum);
-
-  gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
-  buf = (PTRACE_TYPE_RET *) alloca (size);
-
-  /* Read the register contents from the inferior a chunk at a time.  */
-  for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
-    {
-      errno = 0;
-      buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)addr, 0);
-      if (errno != 0)
-	error (_("Couldn't read register %s (#%d): %s."),
-	       gdbarch_register_name (gdbarch, regnum),
-	       regnum, safe_strerror (errno));
-
-      addr += sizeof (PTRACE_TYPE_RET);
-    }
-  regcache->raw_supply (regnum, buf);
-}
-
-/* Fetch register REGNUM from the inferior.  If REGNUM is -1, do this
-   for all registers.  */
-
-void
-ia64_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum)
-{
-  if (regnum == -1)
-    for (regnum = 0;
-	 regnum < gdbarch_num_regs (regcache->arch ());
-	 regnum++)
-      ia64_linux_fetch_register (regcache, regnum);
-  else
-    ia64_linux_fetch_register (regcache, regnum);
-}
-
-/* Store register REGNUM into the inferior.  */
-
-static void
-ia64_linux_store_register (const struct regcache *regcache, int regnum)
-{
-  struct gdbarch *gdbarch = regcache->arch ();
-  CORE_ADDR addr;
-  size_t size;
-  PTRACE_TYPE_RET *buf;
-  pid_t pid;
-  int i;
-
-  if (ia64_cannot_store_register (gdbarch, regnum))
-    return;
-
-  pid = get_ptrace_pid (regcache->ptid ());
-
-  /* This isn't really an address, but ptrace thinks of it as one.  */
-  addr = ia64_register_addr (gdbarch, regnum);
-  size = register_size (gdbarch, regnum);
-
-  gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
-  buf = (PTRACE_TYPE_RET *) alloca (size);
-
-  /* Write the register contents into the inferior a chunk at a time.  */
-  regcache->raw_collect (regnum, buf);
-  for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
-    {
-      errno = 0;
-      ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)addr, buf[i]);
-      if (errno != 0)
-	error (_("Couldn't write register %s (#%d): %s."),
-	       gdbarch_register_name (gdbarch, regnum),
-	       regnum, safe_strerror (errno));
-
-      addr += sizeof (PTRACE_TYPE_RET);
-    }
-}
-
-/* Store register REGNUM back into the inferior.  If REGNUM is -1, do
-   this for all registers.  */
-
-void
-ia64_linux_nat_target::store_registers (struct regcache *regcache, int regnum)
-{
-  if (regnum == -1)
-    for (regnum = 0;
-	 regnum < gdbarch_num_regs (regcache->arch ());
-	 regnum++)
-      ia64_linux_store_register (regcache, regnum);
-  else
-    ia64_linux_store_register (regcache, regnum);
-}
-
-/* Implement the xfer_partial target_ops method.  */
-
-enum target_xfer_status
-ia64_linux_nat_target::xfer_partial (enum target_object object,
-				     const char *annex,
-				     gdb_byte *readbuf, const gdb_byte *writebuf,
-				     ULONGEST offset, ULONGEST len,
-				     ULONGEST *xfered_len)
-{
-  if (object == TARGET_OBJECT_UNWIND_TABLE && readbuf != NULL)
-    {
-      static long gate_table_size;
-      gdb_byte *tmp_buf;
-      long res;
-
-      /* Probe for the table size once.  */
-      if (gate_table_size == 0)
-	gate_table_size = syscall (__NR_getunwind, NULL, 0);
-      if (gate_table_size < 0)
-	return TARGET_XFER_E_IO;
-
-      if (offset >= gate_table_size)
-	return TARGET_XFER_EOF;
-
-      tmp_buf = (gdb_byte *) alloca (gate_table_size);
-      res = syscall (__NR_getunwind, tmp_buf, gate_table_size);
-      if (res < 0)
-	return TARGET_XFER_E_IO;
-      gdb_assert (res == gate_table_size);
-
-      if (offset + len > gate_table_size)
-	len = gate_table_size - offset;
-
-      memcpy (readbuf, tmp_buf + offset, len);
-      *xfered_len = len;
-      return TARGET_XFER_OK;
-    }
-
-  return linux_nat_target::xfer_partial (object, annex, readbuf, writebuf,
-					 offset, len, xfered_len);
-}
-
-/* For break.b instruction ia64 CPU forgets the immediate value and generates
-   SIGILL with ILL_ILLOPC instead of more common SIGTRAP with TRAP_BRKPT.
-   ia64 does not use gdbarch_decr_pc_after_break so we do not have to make any
-   difference for the signals here.  */
-
-bool
-ia64_linux_nat_target::low_status_is_event (int status)
-{
-  return WIFSTOPPED (status) && (WSTOPSIG (status) == SIGTRAP
-				 || WSTOPSIG (status) == SIGILL);
-}
-
-void _initialize_ia64_linux_nat ();
-void
-_initialize_ia64_linux_nat ()
-{
-  /* Register the target.  */
-  linux_target = &the_ia64_linux_nat_target;
-  add_inf_child_target (&the_ia64_linux_nat_target);
-}
diff --git a/gdb/ia64-linux-tdep.c b/gdb/ia64-linux-tdep.c
deleted file mode 100644
index 12083e94ca3..00000000000
--- a/gdb/ia64-linux-tdep.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/* Target-dependent code for the IA-64 for GDB, the GNU debugger.
-
-   Copyright (C) 2000-2024 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "extract-store-integer.h"
-#include "ia64-tdep.h"
-#include "arch-utils.h"
-#include "gdbcore.h"
-#include "regcache.h"
-#include "osabi.h"
-#include "solib-svr4.h"
-#include "symtab.h"
-#include "linux-tdep.h"
-#include "regset.h"
-
-#include <ctype.h>
-
-/* The sigtramp code is in a non-readable (executable-only) region
-   of memory called the ``gate page''.  The addresses in question
-   were determined by examining the system headers.  They are
-   overly generous to allow for different pages sizes.  */
-
-#define GATE_AREA_START 0xa000000000000100LL
-#define GATE_AREA_END   0xa000000000020000LL
-
-/* Offset to sigcontext structure from frame of handler.  */
-#define IA64_LINUX_SIGCONTEXT_OFFSET 192
-
-static int
-ia64_linux_pc_in_sigtramp (CORE_ADDR pc)
-{
-  return (pc >= (CORE_ADDR) GATE_AREA_START && pc < (CORE_ADDR) GATE_AREA_END);
-}
-
-/* IA-64 GNU/Linux specific function which, given a frame address and
-   a register number, returns the address at which that register may be
-   found.  0 is returned for registers which aren't stored in the
-   sigcontext structure.  */
-
-static CORE_ADDR
-ia64_linux_sigcontext_register_address (struct gdbarch *gdbarch,
-					CORE_ADDR sp, int regno)
-{
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  gdb_byte buf[8];
-  CORE_ADDR sigcontext_addr = 0;
-
-  /* The address of the sigcontext area is found at offset 16 in the
-     sigframe.  */
-  read_memory (sp + 16, buf, 8);
-  sigcontext_addr = extract_unsigned_integer (buf, 8, byte_order);
-
-  if (IA64_GR0_REGNUM <= regno && regno <= IA64_GR31_REGNUM)
-    return sigcontext_addr + 200 + 8 * (regno - IA64_GR0_REGNUM);
-  else if (IA64_BR0_REGNUM <= regno && regno <= IA64_BR7_REGNUM)
-    return sigcontext_addr + 136 + 8 * (regno - IA64_BR0_REGNUM);
-  else if (IA64_FR0_REGNUM <= regno && regno <= IA64_FR127_REGNUM)
-    return sigcontext_addr + 464 + 16 * (regno - IA64_FR0_REGNUM);
-  else
-    switch (regno)
-      {
-      case IA64_IP_REGNUM :
-	return sigcontext_addr + 40;
-      case IA64_CFM_REGNUM :
-	return sigcontext_addr + 48;
-      case IA64_PSR_REGNUM :
-	return sigcontext_addr + 56;		/* user mask only */
-      /* sc_ar_rsc is provided, from which we could compute bspstore, but
-	 I don't think it's worth it.  Anyway, if we want it, it's at offset
-	 64.  */
-      case IA64_BSP_REGNUM :
-	return sigcontext_addr + 72;
-      case IA64_RNAT_REGNUM :
-	return sigcontext_addr + 80;
-      case IA64_CCV_REGNUM :
-	return sigcontext_addr + 88;
-      case IA64_UNAT_REGNUM :
-	return sigcontext_addr + 96;
-      case IA64_FPSR_REGNUM :
-	return sigcontext_addr + 104;
-      case IA64_PFS_REGNUM :
-	return sigcontext_addr + 112;
-      case IA64_LC_REGNUM :
-	return sigcontext_addr + 120;
-      case IA64_PR_REGNUM :
-	return sigcontext_addr + 128;
-      default :
-	return 0;
-      }
-}
-
-static void
-ia64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
-{
-  ia64_write_pc (regcache, pc);
-
-  /* We must be careful with modifying the instruction-pointer: if we
-     just interrupt a system call, the kernel would ordinarily try to
-     restart it when we resume the inferior, which typically results
-     in SIGSEGV or SIGILL.  We prevent this by clearing r10, which
-     will tell the kernel that r8 does NOT contain a valid error code
-     and hence it will skip system-call restart.
-
-     The clearing of r10 is safe as long as ia64_write_pc() is only
-     called as part of setting up an inferior call.  */
-  regcache_cooked_write_unsigned (regcache, IA64_GR10_REGNUM, 0);
-}
-
-/* Implementation of `gdbarch_stap_is_single_operand', as defined in
-   gdbarch.h.  */
-
-static int
-ia64_linux_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
-{
-  return ((isdigit (*s) && s[1] == '[' && s[2] == 'r') /* Displacement.  */
-	  || *s == 'r' /* Register value.  */
-	  || isdigit (*s));  /* Literal number.  */
-}
-
-/* Core file support. */
-
-static const struct regcache_map_entry ia64_linux_gregmap[] =
-  {
-    { 32, IA64_GR0_REGNUM, 8 },	/* r0 ... r31 */
-    { 1, REGCACHE_MAP_SKIP, 8 }, /* FIXME: NAT collection bits? */
-    { 1, IA64_PR_REGNUM, 8 },
-    { 8, IA64_BR0_REGNUM, 8 },	/* b0 ... b7 */
-    { 1, IA64_IP_REGNUM, 8 },
-    { 1, IA64_CFM_REGNUM, 8 },
-    { 1, IA64_PSR_REGNUM, 8 },
-    { 1, IA64_RSC_REGNUM, 8 },
-    { 1, IA64_BSP_REGNUM, 8 },
-    { 1, IA64_BSPSTORE_REGNUM, 8 },
-    { 1, IA64_RNAT_REGNUM, 8 },
-    { 1, IA64_CCV_REGNUM, 8 },
-    { 1, IA64_UNAT_REGNUM, 8 },
-    { 1, IA64_FPSR_REGNUM, 8 },
-    { 1, IA64_PFS_REGNUM, 8 },
-    { 1, IA64_LC_REGNUM, 8 },
-    { 1, IA64_EC_REGNUM, 8 },
-    { 0 }
-  };
-
-/* Size of 'gregset_t', as defined by the Linux kernel.  Note that
-   this is more than actually mapped in the regmap above.  */
-
-#define IA64_LINUX_GREGS_SIZE (128 * 8)
-
-static const struct regcache_map_entry ia64_linux_fpregmap[] =
-  {
-    { 128, IA64_FR0_REGNUM, 16 }, /* f0 ... f127 */
-    { 0 }
-  };
-
-#define IA64_LINUX_FPREGS_SIZE (128 * 16)
-
-static void
-ia64_linux_supply_fpregset (const struct regset *regset,
-			    struct regcache *regcache,
-			    int regnum, const void *regs, size_t len)
-{
-  const gdb_byte f_zero[16] = { 0 };
-  const gdb_byte f_one[16] =
-    { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };
-
-  regcache_supply_regset (regset, regcache, regnum, regs, len);
-
-  /* Kernel generated cores have fr1==0 instead of 1.0.  Older GDBs
-     did the same.  So ignore whatever might be recorded in fpregset_t
-     for fr0/fr1 and always supply their expected values.  */
-  if (regnum == -1 || regnum == IA64_FR0_REGNUM)
-    regcache->raw_supply (IA64_FR0_REGNUM, f_zero);
-  if (regnum == -1 || regnum == IA64_FR1_REGNUM)
-    regcache->raw_supply (IA64_FR1_REGNUM, f_one);
-}
-
-static const struct regset ia64_linux_gregset =
-  {
-    ia64_linux_gregmap,
-    regcache_supply_regset, regcache_collect_regset
-  };
-
-static const struct regset ia64_linux_fpregset =
-  {
-    ia64_linux_fpregmap,
-    ia64_linux_supply_fpregset, regcache_collect_regset
-  };
-
-static void
-ia64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
-					 iterate_over_regset_sections_cb *cb,
-					 void *cb_data,
-					 const struct regcache *regcache)
-{
-  cb (".reg", IA64_LINUX_GREGS_SIZE, IA64_LINUX_GREGS_SIZE, &ia64_linux_gregset,
-      NULL, cb_data);
-  cb (".reg2", IA64_LINUX_FPREGS_SIZE, IA64_LINUX_FPREGS_SIZE,
-      &ia64_linux_fpregset, NULL, cb_data);
-}
-
-static void
-ia64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
-{
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
-  static const char *const stap_register_prefixes[] = { "r", NULL };
-  static const char *const stap_register_indirection_prefixes[] = { "[",
-								    NULL };
-  static const char *const stap_register_indirection_suffixes[] = { "]",
-								    NULL };
-
-  linux_init_abi (info, gdbarch, 0);
-
-  /* Set the method of obtaining the sigcontext addresses at which
-     registers are saved.  */
-  tdep->sigcontext_register_address = ia64_linux_sigcontext_register_address;
-
-  /* Set the pc_in_sigtramp method.  */
-  tdep->pc_in_sigtramp = ia64_linux_pc_in_sigtramp;
-
-  set_gdbarch_write_pc (gdbarch, ia64_linux_write_pc);
-
-  set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
-
-  set_solib_svr4_fetch_link_map_offsets
-    (gdbarch, linux_lp64_fetch_link_map_offsets);
-
-  /* Enable TLS support.  */
-  set_gdbarch_fetch_tls_load_module_address (gdbarch,
-					     svr4_fetch_objfile_link_map);
-
-  /* Core file support. */
-  set_gdbarch_iterate_over_regset_sections
-    (gdbarch, ia64_linux_iterate_over_regset_sections);
-
-  /* SystemTap related.  */
-  set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes);
-  set_gdbarch_stap_register_indirection_prefixes (gdbarch,
-					  stap_register_indirection_prefixes);
-  set_gdbarch_stap_register_indirection_suffixes (gdbarch,
-					    stap_register_indirection_suffixes);
-  set_gdbarch_stap_gdb_register_prefix (gdbarch, "r");
-  set_gdbarch_stap_is_single_operand (gdbarch,
-				      ia64_linux_stap_is_single_operand);
-}
-
-void _initialize_ia64_linux_tdep ();
-void
-_initialize_ia64_linux_tdep ()
-{
-  gdbarch_register_osabi (bfd_arch_ia64, 0, GDB_OSABI_LINUX,
-			  ia64_linux_init_abi);
-}
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
deleted file mode 100644
index 6376cf8d069..00000000000
--- a/gdb/ia64-tdep.c
+++ /dev/null
@@ -1,4024 +0,0 @@
-/* Target-dependent code for the IA-64 for GDB, the GNU debugger.
-
-   Copyright (C) 1999-2024 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "extract-store-integer.h"
-#include "inferior.h"
-#include "gdbcore.h"
-#include "arch-utils.h"
-#include "floatformat.h"
-#include "gdbtypes.h"
-#include "regcache.h"
-#include "reggroups.h"
-#include "frame.h"
-#include "frame-base.h"
-#include "frame-unwind.h"
-#include "target-float.h"
-#include "value.h"
-#include "objfiles.h"
-#include "elf/common.h"
-#include "elf-bfd.h"
-#include "dis-asm.h"
-#include "infcall.h"
-#include "osabi.h"
-#include "ia64-tdep.h"
-#include "cp-abi.h"
-
-#ifdef HAVE_LIBUNWIND_IA64_H
-#include "elf/ia64.h"
-#include "ia64-libunwind-tdep.h"
-
-/* Note: KERNEL_START is supposed to be an address which is not going
-	 to ever contain any valid unwind info.  For ia64 linux, the choice
-	 of 0xc000000000000000 is fairly safe since that's uncached space.
- 
-	 We use KERNEL_START as follows: after obtaining the kernel's
-	 unwind table via getunwind(), we project its unwind data into
-	 address-range KERNEL_START-(KERNEL_START+ktab_size) and then
-	 when ia64_access_mem() sees a memory access to this
-	 address-range, we redirect it to ktab instead.
-
-	 None of this hackery is needed with a modern kernel/libcs
-	 which uses the kernel virtual DSO to provide access to the
-	 kernel's unwind info.  In that case, ktab_size remains 0 and
-	 hence the value of KERNEL_START doesn't matter.  */
-
-#define KERNEL_START 0xc000000000000000ULL
-
-static size_t ktab_size = 0;
-struct ia64_table_entry
-  {
-    uint64_t start_offset;
-    uint64_t end_offset;
-    uint64_t info_offset;
-  };
-
-static struct ia64_table_entry *ktab = NULL;
-static std::optional<gdb::byte_vector> ktab_buf;
-
-#endif
-
-/* An enumeration of the different IA-64 instruction types.  */
-
-enum ia64_instruction_type
-{
-  A,			/* Integer ALU ;    I-unit or M-unit */
-  I,			/* Non-ALU integer; I-unit */
-  M,			/* Memory ;         M-unit */
-  F,			/* Floating-point ; F-unit */
-  B,			/* Branch ;         B-unit */
-  L,			/* Extended (L+X) ; I-unit */
-  X,			/* Extended (L+X) ; I-unit */
-  undefined		/* undefined or reserved */
-};
-
-/* We represent IA-64 PC addresses as the value of the instruction
-   pointer or'd with some bit combination in the low nibble which
-   represents the slot number in the bundle addressed by the
-   instruction pointer.  The problem is that the Linux kernel
-   multiplies its slot numbers (for exceptions) by one while the
-   disassembler multiplies its slot numbers by 6.  In addition, I've
-   heard it said that the simulator uses 1 as the multiplier.
-   
-   I've fixed the disassembler so that the bytes_per_line field will
-   be the slot multiplier.  If bytes_per_line comes in as zero, it
-   is set to six (which is how it was set up initially). -- objdump
-   displays pretty disassembly dumps with this value.  For our purposes,
-   we'll set bytes_per_line to SLOT_MULTIPLIER. This is okay since we
-   never want to also display the raw bytes the way objdump does.  */
-
-#define SLOT_MULTIPLIER 1
-
-/* Length in bytes of an instruction bundle.  */
-
-#define BUNDLE_LEN 16
-
-/* See the saved memory layout comment for ia64_memory_insert_breakpoint.  */
-
-#if BREAKPOINT_MAX < BUNDLE_LEN - 2
-# error "BREAKPOINT_MAX < BUNDLE_LEN - 2"
-#endif
-
-static gdbarch_init_ftype ia64_gdbarch_init;
-
-static gdbarch_register_name_ftype ia64_register_name;
-static gdbarch_register_type_ftype ia64_register_type;
-static gdbarch_breakpoint_from_pc_ftype ia64_breakpoint_from_pc;
-static gdbarch_skip_prologue_ftype ia64_skip_prologue;
-static struct type *is_float_or_hfa_type (struct type *t);
-static CORE_ADDR ia64_find_global_pointer (struct gdbarch *gdbarch,
-					   CORE_ADDR faddr);
-
-#define NUM_IA64_RAW_REGS 462
-
-/* Big enough to hold a FP register in bytes.  */
-#define IA64_FP_REGISTER_SIZE 16
-
-static int sp_regnum = IA64_GR12_REGNUM;
-
-/* NOTE: we treat the register stack registers r32-r127 as
-   pseudo-registers because they may not be accessible via the ptrace
-   register get/set interfaces.  */
-
-enum pseudo_regs { FIRST_PSEUDO_REGNUM = NUM_IA64_RAW_REGS,
-		   VBOF_REGNUM = IA64_NAT127_REGNUM + 1, V32_REGNUM, 
-		   V127_REGNUM = V32_REGNUM + 95, 
-		   VP0_REGNUM, VP16_REGNUM = VP0_REGNUM + 16,
-		   VP63_REGNUM = VP0_REGNUM + 63, LAST_PSEUDO_REGNUM };
-
-/* Array of register names; There should be ia64_num_regs strings in
-   the initializer.  */
-
-static const char * const ia64_register_names[] =
-{ "r0",   "r1",   "r2",   "r3",   "r4",   "r5",   "r6",   "r7",
-  "r8",   "r9",   "r10",  "r11",  "r12",  "r13",  "r14",  "r15",
-  "r16",  "r17",  "r18",  "r19",  "r20",  "r21",  "r22",  "r23",
-  "r24",  "r25",  "r26",  "r27",  "r28",  "r29",  "r30",  "r31",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-
-  "f0",   "f1",   "f2",   "f3",   "f4",   "f5",   "f6",   "f7",
-  "f8",   "f9",   "f10",  "f11",  "f12",  "f13",  "f14",  "f15",
-  "f16",  "f17",  "f18",  "f19",  "f20",  "f21",  "f22",  "f23",
-  "f24",  "f25",  "f26",  "f27",  "f28",  "f29",  "f30",  "f31",
-  "f32",  "f33",  "f34",  "f35",  "f36",  "f37",  "f38",  "f39",
-  "f40",  "f41",  "f42",  "f43",  "f44",  "f45",  "f46",  "f47",
-  "f48",  "f49",  "f50",  "f51",  "f52",  "f53",  "f54",  "f55",
-  "f56",  "f57",  "f58",  "f59",  "f60",  "f61",  "f62",  "f63",
-  "f64",  "f65",  "f66",  "f67",  "f68",  "f69",  "f70",  "f71",
-  "f72",  "f73",  "f74",  "f75",  "f76",  "f77",  "f78",  "f79",
-  "f80",  "f81",  "f82",  "f83",  "f84",  "f85",  "f86",  "f87",
-  "f88",  "f89",  "f90",  "f91",  "f92",  "f93",  "f94",  "f95",
-  "f96",  "f97",  "f98",  "f99",  "f100", "f101", "f102", "f103",
-  "f104", "f105", "f106", "f107", "f108", "f109", "f110", "f111",
-  "f112", "f113", "f114", "f115", "f116", "f117", "f118", "f119",
-  "f120", "f121", "f122", "f123", "f124", "f125", "f126", "f127",
-
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-  "",     "",     "",     "",     "",     "",     "",     "",
-
-  "b0",   "b1",   "b2",   "b3",   "b4",   "b5",   "b6",   "b7",
-
-  "vfp", "vrap",
-
-  "pr", "ip", "psr", "cfm",
-
-  "kr0",   "kr1",   "kr2",   "kr3",   "kr4",   "kr5",   "kr6",   "kr7",
-  "", "", "", "", "", "", "", "",
-  "rsc", "bsp", "bspstore", "rnat",
-  "", "fcr", "", "",
-  "eflag", "csd", "ssd", "cflg", "fsr", "fir", "fdr",  "",
-  "ccv", "", "", "", "unat", "", "", "",
-  "fpsr", "", "", "", "itc",
-  "", "", "", "", "", "", "", "", "", "",
-  "", "", "", "", "", "", "", "", "",
-  "pfs", "lc", "ec",
-  "", "", "", "", "", "", "", "", "", "",
-  "", "", "", "", "", "", "", "", "", "",
-  "", "", "", "", "", "", "", "", "", "",
-  "", "", "", "", "", "", "", "", "", "",
-  "", "", "", "", "", "", "", "", "", "",
-  "", "", "", "", "", "", "", "", "", "",
-  "",
-  "nat0",  "nat1",  "nat2",  "nat3",  "nat4",  "nat5",  "nat6",  "nat7",
-  "nat8",  "nat9",  "nat10", "nat11", "nat12", "nat13", "nat14", "nat15",
-  "nat16", "nat17", "nat18", "nat19", "nat20", "nat21", "nat22", "nat23",
-  "nat24", "nat25", "nat26", "nat27", "nat28", "nat29", "nat30", "nat31",
-  "nat32", "nat33", "nat34", "nat35", "nat36", "nat37", "nat38", "nat39",
-  "nat40", "nat41", "nat42", "nat43", "nat44", "nat45", "nat46", "nat47",
-  "nat48", "nat49", "nat50", "nat51", "nat52", "nat53", "nat54", "nat55",
-  "nat56", "nat57", "nat58", "nat59", "nat60", "nat61", "nat62", "nat63",
-  "nat64", "nat65", "nat66", "nat67", "nat68", "nat69", "nat70", "nat71",
-  "nat72", "nat73", "nat74", "nat75", "nat76", "nat77", "nat78", "nat79",
-  "nat80", "nat81", "nat82", "nat83", "nat84", "nat85", "nat86", "nat87",
-  "nat88", "nat89", "nat90", "nat91", "nat92", "nat93", "nat94", "nat95",
-  "nat96", "nat97", "nat98", "nat99", "nat100","nat101","nat102","nat103",
-  "nat104","nat105","nat106","nat107","nat108","nat109","nat110","nat111",
-  "nat112","nat113","nat114","nat115","nat116","nat117","nat118","nat119",
-  "nat120","nat121","nat122","nat123","nat124","nat125","nat126","nat127",
-
-  "bof",
-  
-  "r32",  "r33",  "r34",  "r35",  "r36",  "r37",  "r38",  "r39",   
-  "r40",  "r41",  "r42",  "r43",  "r44",  "r45",  "r46",  "r47",
-  "r48",  "r49",  "r50",  "r51",  "r52",  "r53",  "r54",  "r55",
-  "r56",  "r57",  "r58",  "r59",  "r60",  "r61",  "r62",  "r63",
-  "r64",  "r65",  "r66",  "r67",  "r68",  "r69",  "r70",  "r71",
-  "r72",  "r73",  "r74",  "r75",  "r76",  "r77",  "r78",  "r79",
-  "r80",  "r81",  "r82",  "r83",  "r84",  "r85",  "r86",  "r87",
-  "r88",  "r89",  "r90",  "r91",  "r92",  "r93",  "r94",  "r95",
-  "r96",  "r97",  "r98",  "r99",  "r100", "r101", "r102", "r103",
-  "r104", "r105", "r106", "r107", "r108", "r109", "r110", "r111",
-  "r112", "r113", "r114", "r115", "r116", "r117", "r118", "r119",
-  "r120", "r121", "r122", "r123", "r124", "r125", "r126", "r127",
-
-  "p0",   "p1",   "p2",   "p3",   "p4",   "p5",   "p6",   "p7",
-  "p8",   "p9",   "p10",  "p11",  "p12",  "p13",  "p14",  "p15",
-  "p16",  "p17",  "p18",  "p19",  "p20",  "p21",  "p22",  "p23",
-  "p24",  "p25",  "p26",  "p27",  "p28",  "p29",  "p30",  "p31",
-  "p32",  "p33",  "p34",  "p35",  "p36",  "p37",  "p38",  "p39",
-  "p40",  "p41",  "p42",  "p43",  "p44",  "p45",  "p46",  "p47",
-  "p48",  "p49",  "p50",  "p51",  "p52",  "p53",  "p54",  "p55",
-  "p56",  "p57",  "p58",  "p59",  "p60",  "p61",  "p62",  "p63",
-};
-
-struct ia64_frame_cache
-{
-  CORE_ADDR base;       /* frame pointer base for frame */
-  CORE_ADDR pc;		/* function start pc for frame */
-  CORE_ADDR saved_sp;	/* stack pointer for frame */
-  CORE_ADDR bsp;	/* points at r32 for the current frame */
-  CORE_ADDR cfm;	/* cfm value for current frame */
-  CORE_ADDR prev_cfm;   /* cfm value for previous frame */
-  int   frameless;
-  int   sof;		/* Size of frame  (decoded from cfm value).  */
-  int	sol;		/* Size of locals (decoded from cfm value).  */
-  int	sor;		/* Number of rotating registers (decoded from
-			   cfm value).  */
-  CORE_ADDR after_prologue;
-  /* Address of first instruction after the last
-     prologue instruction;  Note that there may
-     be instructions from the function's body
-     intermingled with the prologue.  */
-  int mem_stack_frame_size;
-  /* Size of the memory stack frame (may be zero),
-     or -1 if it has not been determined yet.  */
-  int	fp_reg;		/* Register number (if any) used a frame pointer
-			   for this frame.  0 if no register is being used
-			   as the frame pointer.  */
-  
-  /* Saved registers.  */
-  CORE_ADDR saved_regs[NUM_IA64_RAW_REGS];
-
-};
-
-static int
-floatformat_valid (const struct floatformat *fmt, const void *from)
-{
-  return 1;
-}
-
-static const struct floatformat floatformat_ia64_ext_little =
-{
-  floatformat_little, 82, 0, 1, 17, 65535, 0x1ffff, 18, 64,
-  floatformat_intbit_yes, "floatformat_ia64_ext_little", floatformat_valid, NULL
-};
-
-static const struct floatformat floatformat_ia64_ext_big =
-{
-  floatformat_big, 82, 46, 47, 17, 65535, 0x1ffff, 64, 64,
-  floatformat_intbit_yes, "floatformat_ia64_ext_big", floatformat_valid
-};
-
-static const struct floatformat *floatformats_ia64_ext[2] =
-{
-  &floatformat_ia64_ext_big,
-  &floatformat_ia64_ext_little
-};
-
-static struct type *
-ia64_ext_type (struct gdbarch *gdbarch)
-{
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
-
-  if (!tdep->ia64_ext_type)
-    {
-      type_allocator alloc (gdbarch);
-      tdep->ia64_ext_type
-	= init_float_type (alloc, 128, "builtin_type_ia64_ext",
-			   floatformats_ia64_ext);
-    }
-
-  return tdep->ia64_ext_type;
-}
-
-static int
-ia64_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
-			  const struct reggroup *group)
-{
-  int vector_p;
-  int float_p;
-  int raw_p;
-  if (group == all_reggroup)
-    return 1;
-  vector_p = register_type (gdbarch, regnum)->is_vector ();
-  float_p = register_type (gdbarch, regnum)->code () == TYPE_CODE_FLT;
-  raw_p = regnum < NUM_IA64_RAW_REGS;
-  if (group == float_reggroup)
-    return float_p;
-  if (group == vector_reggroup)
-    return vector_p;
-  if (group == general_reggroup)
-    return (!vector_p && !float_p);
-  if (group == save_reggroup || group == restore_reggroup)
-    return raw_p; 
-  return 0;
-}
-
-static const char *
-ia64_register_name (struct gdbarch *gdbarch, int reg)
-{
-  return ia64_register_names[reg];
-}
-
-struct type *
-ia64_register_type (struct gdbarch *arch, int reg)
-{
-  if (reg >= IA64_FR0_REGNUM && reg <= IA64_FR127_REGNUM)
-    return ia64_ext_type (arch);
-  else
-    return builtin_type (arch)->builtin_long;
-}
-
-static int
-ia64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
-{
-  if (reg >= IA64_GR32_REGNUM && reg <= IA64_GR127_REGNUM)
-    return V32_REGNUM + (reg - IA64_GR32_REGNUM);
-  return reg;
-}
-
-
-/* Extract ``len'' bits from an instruction bundle starting at
-   bit ``from''.  */
-
-static long long
-extract_bit_field (const gdb_byte *bundle, int from, int len)
-{
-  long long result = 0LL;
-  int to = from + len;
-  int from_byte = from / 8;
-  int to_byte = to / 8;
-  unsigned char *b = (unsigned char *) bundle;
-  unsigned char c;
-  int lshift;
-  int i;
-
-  c = b[from_byte];
-  if (from_byte == to_byte)
-    c = ((unsigned char) (c << (8 - to % 8))) >> (8 - to % 8);
-  result = c >> (from % 8);
-  lshift = 8 - (from % 8);
-
-  for (i = from_byte+1; i < to_byte; i++)
-    {
-      result |= ((long long) b[i]) << lshift;
-      lshift += 8;
-    }
-
-  if (from_byte < to_byte && (to % 8 != 0))
-    {
-      c = b[to_byte];
-      c = ((unsigned char) (c << (8 - to % 8))) >> (8 - to % 8);
-      result |= ((long long) c) << lshift;
-    }
-
-  return result;
-}
-
-/* Replace the specified bits in an instruction bundle.  */
-
-static void
-replace_bit_field (gdb_byte *bundle, long long val, int from, int len)
-{
-  int to = from + len;
-  int from_byte = from / 8;
-  int to_byte = to / 8;
-  unsigned char *b = (unsigned char *) bundle;
-  unsigned char c;
-
-  if (from_byte == to_byte)
-    {
-      unsigned char left, right;
-      c = b[from_byte];
-      left = (c >> (to % 8)) << (to % 8);
-      right = ((unsigned char) (c << (8 - from % 8))) >> (8 - from % 8);
-      c = (unsigned char) (val & 0xff);
-      c = (unsigned char) (c << (from % 8 + 8 - to % 8)) >> (8 - to % 8);
-      c |= right | left;
-      b[from_byte] = c;
-    }
-  else
-    {
-      int i;
-      c = b[from_byte];
-      c = ((unsigned char) (c << (8 - from % 8))) >> (8 - from % 8);
-      c = c | (val << (from % 8));
-      b[from_byte] = c;
-      val >>= 8 - from % 8;
-
-      for (i = from_byte+1; i < to_byte; i++)
-	{
-	  c = val & 0xff;
-	  val >>= 8;
-	  b[i] = c;
-	}
-
-      if (to % 8 != 0)
-	{
-	  unsigned char cv = (unsigned char) val;
-	  c = b[to_byte];
-	  c = c >> (to % 8) << (to % 8);
-	  c |= ((unsigned char) (cv << (8 - to % 8))) >> (8 - to % 8);
-	  b[to_byte] = c;
-	}
-    }
-}
-
-/* Return the contents of slot N (for N = 0, 1, or 2) in
-   and instruction bundle.  */
-
-static long long
-slotN_contents (gdb_byte *bundle, int slotnum)
-{
-  return extract_bit_field (bundle, 5+41*slotnum, 41);
-}
-
-/* Store an instruction in an instruction bundle.  */
-
-static void
-replace_slotN_contents (gdb_byte *bundle, long long instr, int slotnum)
-{
-  replace_bit_field (bundle, instr, 5+41*slotnum, 41);
-}
-
-static const enum ia64_instruction_type template_encoding_table[32][3] =
-{
-  { M, I, I },				/* 00 */
-  { M, I, I },				/* 01 */
-  { M, I, I },				/* 02 */
-  { M, I, I },				/* 03 */
-  { M, L, X },				/* 04 */
-  { M, L, X },				/* 05 */
-  { undefined, undefined, undefined },  /* 06 */
-  { undefined, undefined, undefined },  /* 07 */
-  { M, M, I },				/* 08 */
-  { M, M, I },				/* 09 */
-  { M, M, I },				/* 0A */
-  { M, M, I },				/* 0B */
-  { M, F, I },				/* 0C */
-  { M, F, I },				/* 0D */
-  { M, M, F },				/* 0E */
-  { M, M, F },				/* 0F */
-  { M, I, B },				/* 10 */
-  { M, I, B },				/* 11 */
-  { M, B, B },				/* 12 */
-  { M, B, B },				/* 13 */
-  { undefined, undefined, undefined },  /* 14 */
-  { undefined, undefined, undefined },  /* 15 */
-  { B, B, B },				/* 16 */
-  { B, B, B },				/* 17 */
-  { M, M, B },				/* 18 */
-  { M, M, B },				/* 19 */
-  { undefined, undefined, undefined },  /* 1A */
-  { undefined, undefined, undefined },  /* 1B */
-  { M, F, B },				/* 1C */
-  { M, F, B },				/* 1D */
-  { undefined, undefined, undefined },  /* 1E */
-  { undefined, undefined, undefined },  /* 1F */
-};
-
-/* Fetch and (partially) decode an instruction at ADDR and return the
-   address of the next instruction to fetch.  */
-
-static CORE_ADDR
-fetch_instruction (CORE_ADDR addr, ia64_instruction_type *it, long long *instr)
-{
-  gdb_byte bundle[BUNDLE_LEN];
-  int slotnum = (int) (addr & 0x0f) / SLOT_MULTIPLIER;
-  long long templ;
-  int val;
-
-  /* Warn about slot numbers greater than 2.  We used to generate
-     an error here on the assumption that the user entered an invalid
-     address.  But, sometimes GDB itself requests an invalid address.
-     This can (easily) happen when execution stops in a function for
-     which there are no symbols.  The prologue scanner will attempt to
-     find the beginning of the function - if the nearest symbol
-     happens to not be aligned on a bundle boundary (16 bytes), the
-     resulting starting address will cause GDB to think that the slot
-     number is too large.
-
-     So we warn about it and set the slot number to zero.  It is
-     not necessarily a fatal condition, particularly if debugging
-     at the assembly language level.  */
-  if (slotnum > 2)
-    {
-      warning (_("Can't fetch instructions for slot numbers greater than 2.\n"
-	       "Using slot 0 instead"));
-      slotnum = 0;
-    }
-
-  addr &= ~0x0f;
-
-  val = target_read_memory (addr, bundle, BUNDLE_LEN);
-
-  if (val != 0)
-    return 0;
-
-  *instr = slotN_contents (bundle, slotnum);
-  templ = extract_bit_field (bundle, 0, 5);
-  *it = template_encoding_table[(int)templ][slotnum];
-
-  if (slotnum == 2 || (slotnum == 1 && *it == L))
-    addr += 16;
-  else
-    addr += (slotnum + 1) * SLOT_MULTIPLIER;
-
-  return addr;
-}
-
-/* There are 5 different break instructions (break.i, break.b,
-   break.m, break.f, and break.x), but they all have the same
-   encoding.  (The five bit template in the low five bits of the
-   instruction bundle distinguishes one from another.)
-   
-   The runtime architecture manual specifies that break instructions
-   used for debugging purposes must have the upper two bits of the 21
-   bit immediate set to a 0 and a 1 respectively.  A breakpoint
-   instruction encodes the most significant bit of its 21 bit
-   immediate at bit 36 of the 41 bit instruction.  The penultimate msb
-   is at bit 25 which leads to the pattern below.  
-   
-   Originally, I had this set up to do, e.g, a "break.i 0x80000"  But
-   it turns out that 0x80000 was used as the syscall break in the early
-   simulators.  So I changed the pattern slightly to do "break.i 0x080001"
-   instead.  But that didn't work either (I later found out that this
-   pattern was used by the simulator that I was using.)  So I ended up
-   using the pattern seen below.
-
-   SHADOW_CONTENTS has byte-based addressing (PLACED_ADDRESS and SHADOW_LEN)
-   while we need bit-based addressing as the instructions length is 41 bits and
-   we must not modify/corrupt the adjacent slots in the same bundle.
-   Fortunately we may store larger memory incl. the adjacent bits with the
-   original memory content (not the possibly already stored breakpoints there).
-   We need to be careful in ia64_memory_remove_breakpoint to always restore
-   only the specific bits of this instruction ignoring any adjacent stored
-   bits.
-
-   We use the original addressing with the low nibble in the range <0..2> which
-   gets incorrectly interpreted by generic non-ia64 breakpoint_restore_shadows
-   as the direct byte offset of SHADOW_CONTENTS.  We store whole BUNDLE_LEN
-   bytes just without these two possibly skipped bytes to not to exceed to the
-   next bundle.
-
-   If we would like to store the whole bundle to SHADOW_CONTENTS we would have
-   to store already the base address (`address & ~0x0f') into PLACED_ADDRESS.
-   In such case there is no other place where to store
-   SLOTNUM (`adress & 0x0f', value in the range <0..2>).  We need to know
-   SLOTNUM in ia64_memory_remove_breakpoint.
-
-   There is one special case where we need to be extra careful:
-   L-X instructions, which are instructions that occupy 2 slots
-   (The L part is always in slot 1, and the X part is always in
-   slot 2).  We must refuse to insert breakpoints for an address
-   that points at slot 2 of a bundle where an L-X instruction is
-   present, since there is logically no instruction at that address.
-   However, to make things more interesting, the opcode of L-X
-   instructions is located in slot 2.  This means that, to insert
-   a breakpoint at an address that points to slot 1, we actually
-   need to write the breakpoint in slot 2!  Slot 1 is actually
-   the extended operand, so writing the breakpoint there would not
-   have the desired effect.  Another side-effect of this issue
-   is that we need to make sure that the shadow contents buffer
-   does save byte 15 of our instruction bundle (this is the tail
-   end of slot 2, which wouldn't be saved if we were to insert
-   the breakpoint in slot 1).
-   
-   ia64 16-byte bundle layout:
-   | 5 bits | slot 0 with 41 bits | slot 1 with 41 bits | slot 2 with 41 bits |
-   
-   The current addressing used by the code below:
-   original PC   placed_address   placed_size             required    covered
-				  == bp_tgt->shadow_len   reqd \subset covered
-   0xABCDE0      0xABCDE0         0x10                    <0x0...0x5> <0x0..0xF>
-   0xABCDE1      0xABCDE1         0xF                     <0x5...0xA> <0x1..0xF>
-   0xABCDE2      0xABCDE2         0xE                     <0xA...0xF> <0x2..0xF>
-
-   L-X instructions are treated a little specially, as explained above:
-   0xABCDE1      0xABCDE1         0xF                     <0xA...0xF> <0x1..0xF>
-
-   `objdump -d' and some other tools show a bit unjustified offsets:
-   original PC   byte where starts the instruction   objdump offset
-   0xABCDE0      0xABCDE0                            0xABCDE0
-   0xABCDE1      0xABCDE5                            0xABCDE6
-   0xABCDE2      0xABCDEA                            0xABCDEC
-   */
-
-#define IA64_BREAKPOINT 0x00003333300LL
-
-static int
-ia64_memory_insert_breakpoint (struct gdbarch *gdbarch,
-			       struct bp_target_info *bp_tgt)
-{
-  CORE_ADDR addr = bp_tgt->placed_address = bp_tgt->reqstd_address;
-  gdb_byte bundle[BUNDLE_LEN];
-  int slotnum = (int) (addr & 0x0f) / SLOT_MULTIPLIER, shadow_slotnum;
-  long long instr_breakpoint;
-  int val;
-  int templ;
-
-  if (slotnum > 2)
-    error (_("Can't insert breakpoint for slot numbers greater than 2."));
-
-  addr &= ~0x0f;
-
-  /* Enable the automatic memory restoration from breakpoints while
-     we read our instruction bundle for the purpose of SHADOW_CONTENTS.
-     Otherwise, we could possibly store into the shadow parts of the adjacent
-     placed breakpoints.  It is due to our SHADOW_CONTENTS overlapping the real
-     breakpoint instruction bits region.  */
-  scoped_restore restore_memory_0
-    = make_scoped_restore_show_memory_breakpoints (0);
-  val = target_read_memory (addr, bundle, BUNDLE_LEN);
-  if (val != 0)
-    return val;
-
-  /* SHADOW_SLOTNUM saves the original slot number as expected by the caller
-     for addressing the SHADOW_CONTENTS placement.  */
-  shadow_slotnum = slotnum;
-
-  /* Always cover the last byte of the bundle in case we are inserting
-     a breakpoint on an L-X instruction.  */
-  bp_tgt->shadow_len = BUNDLE_LEN - shadow_slotnum;
-
-  templ = extract_bit_field (bundle, 0, 5);
-  if (template_encoding_table[templ][slotnum] == X)
-    {
-      /* X unit types can only be used in slot 2, and are actually
-	 part of a 2-slot L-X instruction.  We cannot break at this
-	 address, as this is the second half of an instruction that
-	 lives in slot 1 of that bundle.  */
-      gdb_assert (slotnum == 2);
-      error (_("Can't insert breakpoint for non-existing slot X"));
-    }
-  if (template_encoding_table[templ][slotnum] == L)
-    {
-      /* L unit types can only be used in slot 1.  But the associated
-	 opcode for that instruction is in slot 2, so bump the slot number
-	 accordingly.  */
-      gdb_assert (slotnum == 1);
-      slotnum = 2;
-    }
-
-  /* Store the whole bundle, except for the initial skipped bytes by the slot
-     number interpreted as bytes offset in PLACED_ADDRESS.  */
-  memcpy (bp_tgt->shadow_contents, bundle + shadow_slotnum,
-	  bp_tgt->shadow_len);
-
-  /* Re-read the same bundle as above except that, this time, read it in order
-     to compute the new bundle inside which we will be inserting the
-     breakpoint.  Therefore, disable the automatic memory restoration from
-     breakpoints while we read our instruction bundle.  Otherwise, the general
-     restoration mechanism kicks in and we would possibly remove parts of the
-     adjacent placed breakpoints.  It is due to our SHADOW_CONTENTS overlapping
-     the real breakpoint instruction bits region.  */
-  scoped_restore restore_memory_1
-    = make_scoped_restore_show_memory_breakpoints (1);
-  val = target_read_memory (addr, bundle, BUNDLE_LEN);
-  if (val != 0)
-    return val;
-
-  /* Breakpoints already present in the code will get detected and not get
-     reinserted by bp_loc_is_permanent.  Multiple breakpoints at the same
-     location cannot induce the internal error as they are optimized into
-     a single instance by update_global_location_list.  */
-  instr_breakpoint = slotN_contents (bundle, slotnum);
-  if (instr_breakpoint == IA64_BREAKPOINT)
-    internal_error (_("Address %s already contains a breakpoint."),
-		    paddress (gdbarch, bp_tgt->placed_address));
-  replace_slotN_contents (bundle, IA64_BREAKPOINT, slotnum);
-
-  val = target_write_memory (addr + shadow_slotnum, bundle + shadow_slotnum,
-			     bp_tgt->shadow_len);
-
-  return val;
-}
-
-static int
-ia64_memory_remove_breakpoint (struct gdbarch *gdbarch,
-			       struct bp_target_info *bp_tgt)
-{
-  CORE_ADDR addr = bp_tgt->placed_address;
-  gdb_byte bundle_mem[BUNDLE_LEN], bundle_saved[BUNDLE_LEN];
-  int slotnum = (addr & 0x0f) / SLOT_MULTIPLIER, shadow_slotnum;
-  long long instr_breakpoint, instr_saved;
-  int val;
-  int templ;
-
-  addr &= ~0x0f;
-
-  /* Disable the automatic memory restoration from breakpoints while
-     we read our instruction bundle.  Otherwise, the general restoration
-     mechanism kicks in and we would possibly remove parts of the adjacent
-     placed breakpoints.  It is due to our SHADOW_CONTENTS overlapping the real
-     breakpoint instruction bits region.  */
-  scoped_restore restore_memory_1
-    = make_scoped_restore_show_memory_breakpoints (1);
-  val = target_read_memory (addr, bundle_mem, BUNDLE_LEN);
-  if (val != 0)
-    return val;
-
-  /* SHADOW_SLOTNUM saves the original slot number as expected by the caller
-     for addressing the SHADOW_CONTENTS placement.  */
-  shadow_slotnum = slotnum;
-
-  templ = extract_bit_field (bundle_mem, 0, 5);
-  if (template_encoding_table[templ][slotnum] == X)
-    {
-      /* X unit types can only be used in slot 2, and are actually
-	 part of a 2-slot L-X instruction.  We refuse to insert
-	 breakpoints at this address, so there should be no reason
-	 for us attempting to remove one there, except if the program's
-	 code somehow got modified in memory.  */
-      gdb_assert (slotnum == 2);
-      warning (_("Cannot remove breakpoint at address %s from non-existing "
-		 "X-type slot, memory has changed underneath"),
-	       paddress (gdbarch, bp_tgt->placed_address));
-      return -1;
-    }
-  if (template_encoding_table[templ][slotnum] == L)
-    {
-      /* L unit types can only be used in slot 1.  But the breakpoint
-	 was actually saved using slot 2, so update the slot number
-	 accordingly.  */
-      gdb_assert (slotnum == 1);
-      slotnum = 2;
-    }
-
-  gdb_assert (bp_tgt->shadow_len == BUNDLE_LEN - shadow_slotnum);
-
-  instr_breakpoint = slotN_contents (bundle_mem, slotnum);
-  if (instr_breakpoint != IA64_BREAKPOINT)
-    {
-      warning (_("Cannot remove breakpoint at address %s, "
-		 "no break instruction at such address."),
-	       paddress (gdbarch, bp_tgt->placed_address));
-      return -1;
-    }
-
-  /* Extract the original saved instruction from SLOTNUM normalizing its
-     bit-shift for INSTR_SAVED.  */
-  memcpy (bundle_saved, bundle_mem, BUNDLE_LEN);
-  memcpy (bundle_saved + shadow_slotnum, bp_tgt->shadow_contents,
-	  bp_tgt->shadow_len);
-  instr_saved = slotN_contents (bundle_saved, slotnum);
-
-  /* In BUNDLE_MEM, be careful to modify only the bits belonging to SLOTNUM
-     and not any of the other ones that are stored in SHADOW_CONTENTS.  */
-  replace_slotN_contents (bundle_mem, instr_saved, slotnum);
-  val = target_write_raw_memory (addr, bundle_mem, BUNDLE_LEN);
-
-  return val;
-}
-
-/* Implement the breakpoint_kind_from_pc gdbarch method.  */
-
-static int
-ia64_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
-{
-  /* A place holder of gdbarch method breakpoint_kind_from_pc.   */
-  return 0;
-}
-
-/* As gdbarch_breakpoint_from_pc ranges have byte granularity and ia64
-   instruction slots ranges are bit-granular (41 bits) we have to provide an
-   extended range as described for ia64_memory_insert_breakpoint.  We also take
-   care of preserving the `break' instruction 21-bit (or 62-bit) parameter to
-   make a match for permanent breakpoints.  */
-
-static const gdb_byte *
-ia64_breakpoint_from_pc (struct gdbarch *gdbarch,
-			 CORE_ADDR *pcptr, int *lenptr)
-{
-  CORE_ADDR addr = *pcptr;
-  static gdb_byte bundle[BUNDLE_LEN];
-  int slotnum = (int) (*pcptr & 0x0f) / SLOT_MULTIPLIER, shadow_slotnum;
-  long long instr_fetched;
-  int val;
-  int templ;
-
-  if (slotnum > 2)
-    error (_("Can't insert breakpoint for slot numbers greater than 2."));
-
-  addr &= ~0x0f;
-
-  /* Enable the automatic memory restoration from breakpoints while
-     we read our instruction bundle to match bp_loc_is_permanent.  */
-  {
-    scoped_restore restore_memory_0
-      = make_scoped_restore_show_memory_breakpoints (0);
-    val = target_read_memory (addr, bundle, BUNDLE_LEN);
-  }
-
-  /* The memory might be unreachable.  This can happen, for instance,
-     when the user inserts a breakpoint at an invalid address.  */
-  if (val != 0)
-    return NULL;
-
-  /* SHADOW_SLOTNUM saves the original slot number as expected by the caller
-     for addressing the SHADOW_CONTENTS placement.  */
-  shadow_slotnum = slotnum;
-
-  /* Cover always the last byte of the bundle for the L-X slot case.  */
-  *lenptr = BUNDLE_LEN - shadow_slotnum;
-
-  /* Check for L type instruction in slot 1, if present then bump up the slot
-     number to the slot 2.  */
-  templ = extract_bit_field (bundle, 0, 5);
-  if (template_encoding_table[templ][slotnum] == X)
-    {
-      gdb_assert (slotnum == 2);
-      error (_("Can't insert breakpoint for non-existing slot X"));
-    }
-  if (template_encoding_table[templ][slotnum] == L)
-    {
-      gdb_assert (slotnum == 1);
-      slotnum = 2;
-    }
-
-  /* A break instruction has its all its opcode bits cleared except for
-     the parameter value.  For L+X slot pair we are at the X slot (slot 2) so
-     we should not touch the L slot - the upper 41 bits of the parameter.  */
-  instr_fetched = slotN_contents (bundle, slotnum);
-  instr_fetched &= 0x1003ffffc0LL;
-  replace_slotN_contents (bundle, instr_fetched, slotnum);
-
-  return bundle + shadow_slotnum;
-}
-
-static CORE_ADDR
-ia64_read_pc (readable_regcache *regcache)
-{
-  ULONGEST psr_value, pc_value;
-  int slot_num;
-
-  regcache->cooked_read (IA64_PSR_REGNUM, &psr_value);
-  regcache->cooked_read (IA64_IP_REGNUM, &pc_value);
-  slot_num = (psr_value >> 41) & 3;
-
-  return pc_value | (slot_num * SLOT_MULTIPLIER);
-}
-
-void
-ia64_write_pc (struct regcache *regcache, CORE_ADDR new_pc)
-{
-  int slot_num = (int) (new_pc & 0xf) / SLOT_MULTIPLIER;
-  ULONGEST psr_value;
-
-  regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr_value);
-  psr_value &= ~(3LL << 41);
-  psr_value |= (ULONGEST)(slot_num & 0x3) << 41;
-
-  new_pc &= ~0xfLL;
-
-  regcache_cooked_write_unsigned (regcache, IA64_PSR_REGNUM, psr_value);
-  regcache_cooked_write_unsigned (regcache, IA64_IP_REGNUM, new_pc);
-}
-
-#define IS_NaT_COLLECTION_ADDR(addr) ((((addr) >> 3) & 0x3f) == 0x3f)
-
-/* Returns the address of the slot that's NSLOTS slots away from
-   the address ADDR.  NSLOTS may be positive or negative.  */
-static CORE_ADDR
-rse_address_add(CORE_ADDR addr, int nslots)
-{
-  CORE_ADDR new_addr;
-  int mandatory_nat_slots = nslots / 63;
-  int direction = nslots < 0 ? -1 : 1;
-
-  new_addr = addr + 8 * (nslots + mandatory_nat_slots);
-
-  if ((new_addr >> 9)  != ((addr + 8 * 64 * mandatory_nat_slots) >> 9))
-    new_addr += 8 * direction;
-
-  if (IS_NaT_COLLECTION_ADDR(new_addr))
-    new_addr += 8 * direction;
-
-  return new_addr;
-}
-
-static enum register_status
-ia64_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache,
-			   int regnum, gdb_byte *buf)
-{
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  enum register_status status;
-
-  if (regnum >= V32_REGNUM && regnum <= V127_REGNUM)
-    {
-#ifdef HAVE_LIBUNWIND_IA64_H
-      /* First try and use the libunwind special reg accessor,
-	 otherwise fallback to standard logic.  */
-      if (!libunwind_is_initialized ()
-	  || libunwind_get_reg_special (gdbarch, regcache, regnum, buf) != 0)
-#endif
-	{
-	  /* The fallback position is to assume that r32-r127 are
-	     found sequentially in memory starting at $bof.  This
-	     isn't always true, but without libunwind, this is the
-	     best we can do.  */
-	  ULONGEST cfm;
-	  ULONGEST bsp;
-	  CORE_ADDR reg;
-
-	  status = regcache->cooked_read (IA64_BSP_REGNUM, &bsp);
-	  if (status != REG_VALID)
-	    return status;
-
-	  status = regcache->cooked_read (IA64_CFM_REGNUM, &cfm);
-	  if (status != REG_VALID)
-	    return status;
-
-	  /* The bsp points at the end of the register frame so we
-	     subtract the size of frame from it to get start of
-	     register frame.  */
-	  bsp = rse_address_add (bsp, -(cfm & 0x7f));
-	  
-	  if ((cfm & 0x7f) > regnum - V32_REGNUM) 
-	    {
-	      ULONGEST reg_addr = rse_address_add (bsp, (regnum - V32_REGNUM));
-	      reg = read_memory_integer ((CORE_ADDR)reg_addr, 8, byte_order);
-	      store_unsigned_integer (buf, register_size (gdbarch, regnum),
-				      byte_order, reg);
-	    }
-	  else
-	    store_unsigned_integer (buf, register_size (gdbarch, regnum),
-				    byte_order, 0);
-	}
-    }
-  else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT31_REGNUM)
-    {
-      ULONGEST unatN_val;
-      ULONGEST unat;
-
-      status = regcache->cooked_read (IA64_UNAT_REGNUM, &unat);
-      if (status != REG_VALID)
-	return status;
-      unatN_val = (unat & (1LL << (regnum - IA64_NAT0_REGNUM))) != 0;
-      store_unsigned_integer (buf, register_size (gdbarch, regnum),
-			      byte_order, unatN_val);
-    }
-  else if (IA64_NAT32_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
-    {
-      ULONGEST natN_val = 0;
-      ULONGEST bsp;
-      ULONGEST cfm;
-      CORE_ADDR gr_addr = 0;
-
-      status = regcache->cooked_read (IA64_BSP_REGNUM, &bsp);
-      if (status != REG_VALID)
-	return status;
-
-      status = regcache->cooked_read (IA64_CFM_REGNUM, &cfm);
-      if (status != REG_VALID)
-	return status;
-
-      /* The bsp points at the end of the register frame so we
-	 subtract the size of frame from it to get start of register frame.  */
-      bsp = rse_address_add (bsp, -(cfm & 0x7f));
- 
-      if ((cfm & 0x7f) > regnum - V32_REGNUM) 
-	gr_addr = rse_address_add (bsp, (regnum - V32_REGNUM));
-      
-      if (gr_addr != 0)
-	{
-	  /* Compute address of nat collection bits.  */
-	  CORE_ADDR nat_addr = gr_addr | 0x1f8;
-	  ULONGEST nat_collection;
-	  int nat_bit;
-	  /* If our nat collection address is bigger than bsp, we have to get
-	     the nat collection from rnat.  Otherwise, we fetch the nat
-	     collection from the computed address.  */
-	  if (nat_addr >= bsp)
-	    regcache->cooked_read (IA64_RNAT_REGNUM, &nat_collection);
-	  else
-	    nat_collection = read_memory_integer (nat_addr, 8, byte_order);
-	  nat_bit = (gr_addr >> 3) & 0x3f;
-	  natN_val = (nat_collection >> nat_bit) & 1;
-	}
-      
-      store_unsigned_integer (buf, register_size (gdbarch, regnum),
-			      byte_order, natN_val);
-    }
-  else if (regnum == VBOF_REGNUM)
-    {
-      /* A virtual register frame start is provided for user convenience.
-	 It can be calculated as the bsp - sof (sizeof frame).  */
-      ULONGEST bsp, vbsp;
-      ULONGEST cfm;
-
-      status = regcache->cooked_read (IA64_BSP_REGNUM, &bsp);
-      if (status != REG_VALID)
-	return status;
-      status = regcache->cooked_read (IA64_CFM_REGNUM, &cfm);
-      if (status != REG_VALID)
-	return status;
-
-      /* The bsp points at the end of the register frame so we
-	 subtract the size of frame from it to get beginning of frame.  */
-      vbsp = rse_address_add (bsp, -(cfm & 0x7f));
-      store_unsigned_integer (buf, register_size (gdbarch, regnum),
-			      byte_order, vbsp);
-    }
-  else if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
-    {
-      ULONGEST pr;
-      ULONGEST cfm;
-      ULONGEST prN_val;
-
-      status = regcache->cooked_read (IA64_PR_REGNUM, &pr);
-      if (status != REG_VALID)
-	return status;
-      status = regcache->cooked_read (IA64_CFM_REGNUM, &cfm);
-      if (status != REG_VALID)
-	return status;
-
-      if (VP16_REGNUM <= regnum && regnum <= VP63_REGNUM)
-	{
-	  /* Fetch predicate register rename base from current frame
-	     marker for this frame.  */
-	  int rrb_pr = (cfm >> 32) & 0x3f;
-
-	  /* Adjust the register number to account for register rotation.  */
-	  regnum = VP16_REGNUM 
-		 + ((regnum - VP16_REGNUM) + rrb_pr) % 48;
-	}
-      prN_val = (pr & (1LL << (regnum - VP0_REGNUM))) != 0;
-      store_unsigned_integer (buf, register_size (gdbarch, regnum),
-			      byte_order, prN_val);
-    }
-  else
-    memset (buf, 0, register_size (gdbarch, regnum));
-
-  return REG_VALID;
-}
-
-static void
-ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
-			    int regnum, const gdb_byte *buf)
-{
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-
-  if (regnum >= V32_REGNUM && regnum <= V127_REGNUM)
-    {
-      ULONGEST bsp;
-      ULONGEST cfm;
-      regcache_cooked_read_unsigned (regcache, IA64_BSP_REGNUM, &bsp);
-      regcache_cooked_read_unsigned (regcache, IA64_CFM_REGNUM, &cfm);
-
-      bsp = rse_address_add (bsp, -(cfm & 0x7f));
- 
-      if ((cfm & 0x7f) > regnum - V32_REGNUM) 
-	{
-	  ULONGEST reg_addr = rse_address_add (bsp, (regnum - V32_REGNUM));
-	  write_memory (reg_addr, buf, 8);
-	}
-    }
-  else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT31_REGNUM)
-    {
-      ULONGEST unatN_val, unat, unatN_mask;
-      regcache_cooked_read_unsigned (regcache, IA64_UNAT_REGNUM, &unat);
-      unatN_val = extract_unsigned_integer (buf, register_size (gdbarch,
-								regnum),
-					    byte_order);
-      unatN_mask = (1LL << (regnum - IA64_NAT0_REGNUM));
-      if (unatN_val == 0)
-	unat &= ~unatN_mask;
-      else if (unatN_val == 1)
-	unat |= unatN_mask;
-      regcache_cooked_write_unsigned (regcache, IA64_UNAT_REGNUM, unat);
-    }
-  else if (IA64_NAT32_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
-    {
-      ULONGEST natN_val;
-      ULONGEST bsp;
-      ULONGEST cfm;
-      CORE_ADDR gr_addr = 0;
-      regcache_cooked_read_unsigned (regcache, IA64_BSP_REGNUM, &bsp);
-      regcache_cooked_read_unsigned (regcache, IA64_CFM_REGNUM, &cfm);
-
-      /* The bsp points at the end of the register frame so we
-	 subtract the size of frame from it to get start of register frame.  */
-      bsp = rse_address_add (bsp, -(cfm & 0x7f));
- 
-      if ((cfm & 0x7f) > regnum - V32_REGNUM) 
-	gr_addr = rse_address_add (bsp, (regnum - V32_REGNUM));
-      
-      natN_val = extract_unsigned_integer (buf, register_size (gdbarch,
-							       regnum),
-					   byte_order);
-
-      if (gr_addr != 0 && (natN_val == 0 || natN_val == 1))
-	{
-	  /* Compute address of nat collection bits.  */
-	  CORE_ADDR nat_addr = gr_addr | 0x1f8;
-	  CORE_ADDR nat_collection;
-	  int natN_bit = (gr_addr >> 3) & 0x3f;
-	  ULONGEST natN_mask = (1LL << natN_bit);
-	  /* If our nat collection address is bigger than bsp, we have to get
-	     the nat collection from rnat.  Otherwise, we fetch the nat
-	     collection from the computed address.  */
-	  if (nat_addr >= bsp)
-	    {
-	      regcache_cooked_read_unsigned (regcache,
-					     IA64_RNAT_REGNUM,
-					     &nat_collection);
-	      if (natN_val)
-		nat_collection |= natN_mask;
-	      else
-		nat_collection &= ~natN_mask;
-	      regcache_cooked_write_unsigned (regcache, IA64_RNAT_REGNUM,
-					      nat_collection);
-	    }
-	  else
-	    {
-	      gdb_byte nat_buf[8];
-	      nat_collection = read_memory_integer (nat_addr, 8, byte_order);
-	      if (natN_val)
-		nat_collection |= natN_mask;
-	      else
-		nat_collection &= ~natN_mask;
-	      store_unsigned_integer (nat_buf, register_size (gdbarch, regnum),
-				      byte_order, nat_collection);
-	      write_memory (nat_addr, nat_buf, 8);
-	    }
-	}
-    }
-  else if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
-    {
-      ULONGEST pr;
-      ULONGEST cfm;
-      ULONGEST prN_val;
-      ULONGEST prN_mask;
-
-      regcache_cooked_read_unsigned (regcache, IA64_PR_REGNUM, &pr);
-      regcache_cooked_read_unsigned (regcache, IA64_CFM_REGNUM, &cfm);
-
-      if (VP16_REGNUM <= regnum && regnum <= VP63_REGNUM)
-	{
-	  /* Fetch predicate register rename base from current frame
-	     marker for this frame.  */
-	  int rrb_pr = (cfm >> 32) & 0x3f;
-
-	  /* Adjust the register number to account for register rotation.  */
-	  regnum = VP16_REGNUM 
-		 + ((regnum - VP16_REGNUM) + rrb_pr) % 48;
-	}
-      prN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum),
-					  byte_order);
-      prN_mask = (1LL << (regnum - VP0_REGNUM));
-      if (prN_val == 0)
-	pr &= ~prN_mask;
-      else if (prN_val == 1)
-	pr |= prN_mask;
-      regcache_cooked_write_unsigned (regcache, IA64_PR_REGNUM, pr);
-    }
-}
-
-/* The ia64 needs to convert between various ieee floating-point formats
-   and the special ia64 floating point register format.  */
-
-static int
-ia64_convert_register_p (struct gdbarch *gdbarch, int regno, struct type *type)
-{
-  return (regno >= IA64_FR0_REGNUM && regno <= IA64_FR127_REGNUM
-	  && type->code () == TYPE_CODE_FLT
-	  && type != ia64_ext_type (gdbarch));
-}
-
-static int
-ia64_register_to_value (const frame_info_ptr &frame, int regnum,
-			struct type *valtype, gdb_byte *out,
-			int *optimizedp, int *unavailablep)
-{
-  struct gdbarch *gdbarch = get_frame_arch (frame);
-  gdb_byte in[IA64_FP_REGISTER_SIZE];
-
-  /* Convert to TYPE.  */
-  auto in_view = gdb::make_array_view (in, register_size (gdbarch, regnum));
-  frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
-  if (!get_frame_register_bytes (next_frame, regnum, 0, in_view, optimizedp,
-				 unavailablep))
-    return 0;
-
-  target_float_convert (in, ia64_ext_type (gdbarch), out, valtype);
-  *optimizedp = *unavailablep = 0;
-  return 1;
-}
-
-static void
-ia64_value_to_register (const frame_info_ptr &frame, int regnum,
-			 struct type *valtype, const gdb_byte *in)
-{
-  struct gdbarch *gdbarch = get_frame_arch (frame);
-  gdb_byte out[IA64_FP_REGISTER_SIZE];
-  type *to_type = ia64_ext_type (gdbarch);
-  target_float_convert (in, valtype, out, to_type);
-  auto out_view = gdb::make_array_view (out, to_type->length ());
-  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, out_view);
-}
-
-
-/* Limit the number of skipped non-prologue instructions since examining
-   of the prologue is expensive.  */
-static int max_skip_non_prologue_insns = 40;
-
-/* Given PC representing the starting address of a function, and
-   LIM_PC which is the (sloppy) limit to which to scan when looking
-   for a prologue, attempt to further refine this limit by using
-   the line data in the symbol table.  If successful, a better guess
-   on where the prologue ends is returned, otherwise the previous
-   value of lim_pc is returned.  TRUST_LIMIT is a pointer to a flag
-   which will be set to indicate whether the returned limit may be
-   used with no further scanning in the event that the function is
-   frameless.  */
-
-/* FIXME: cagney/2004-02-14: This function and logic have largely been
-   superseded by skip_prologue_using_sal.  */
-
-static CORE_ADDR
-refine_prologue_limit (CORE_ADDR pc, CORE_ADDR lim_pc, int *trust_limit)
-{
-  struct symtab_and_line prologue_sal;
-  CORE_ADDR start_pc = pc;
-  CORE_ADDR end_pc;
-
-  /* The prologue can not possibly go past the function end itself,
-     so we can already adjust LIM_PC accordingly.  */
-  if (find_pc_partial_function (pc, NULL, NULL, &end_pc) && end_pc < lim_pc)
-    lim_pc = end_pc;
-
-  /* Start off not trusting the limit.  */
-  *trust_limit = 0;
-
-  prologue_sal = find_pc_line (pc, 0);
-  if (prologue_sal.line != 0)
-    {
-      int i;
-      CORE_ADDR addr = prologue_sal.end;
-
-      /* Handle the case in which compiler's optimizer/scheduler
-	 has moved instructions into the prologue.  We scan ahead
-	 in the function looking for address ranges whose corresponding
-	 line number is less than or equal to the first one that we
-	 found for the function.  (It can be less than when the
-	 scheduler puts a body instruction before the first prologue
-	 instruction.)  */
-      for (i = 2 * max_skip_non_prologue_insns; 
-	   i > 0 && (lim_pc == 0 || addr < lim_pc);
-	   i--)
-	{
-	  struct symtab_and_line sal;
-
-	  sal = find_pc_line (addr, 0);
-	  if (sal.line == 0)
-	    break;
-	  if (sal.line <= prologue_sal.line 
-	      && sal.symtab == prologue_sal.symtab)
-	    {
-	      prologue_sal = sal;
-	    }
-	  addr = sal.end;
-	}
-
-      if (lim_pc == 0 || prologue_sal.end < lim_pc)
-	{
-	  lim_pc = prologue_sal.end;
-	  if (start_pc == get_pc_function_start (lim_pc))
-	    *trust_limit = 1;
-	}
-    }
-  return lim_pc;
-}
-
-#define isScratch(_regnum_) ((_regnum_) == 2 || (_regnum_) == 3 \
-  || (8 <= (_regnum_) && (_regnum_) <= 11) \
-  || (14 <= (_regnum_) && (_regnum_) <= 31))
-#define imm9(_instr_) \
-  ( ((((_instr_) & 0x01000000000LL) ? -1 : 0) << 8) \
-   | (((_instr_) & 0x00008000000LL) >> 20) \
-   | (((_instr_) & 0x00000001fc0LL) >> 6))
-
-/* Allocate and initialize a frame cache.  */
-
-static struct ia64_frame_cache *
-ia64_alloc_frame_cache (void)
-{
-  struct ia64_frame_cache *cache;
-  int i;
-
-  cache = FRAME_OBSTACK_ZALLOC (struct ia64_frame_cache);
-
-  /* Base address.  */
-  cache->base = 0;
-  cache->pc = 0;
-  cache->cfm = 0;
-  cache->prev_cfm = 0;
-  cache->sof = 0;
-  cache->sol = 0;
-  cache->sor = 0;
-  cache->bsp = 0;
-  cache->fp_reg = 0;
-  cache->frameless = 1;
-
-  for (i = 0; i < NUM_IA64_RAW_REGS; i++)
-    cache->saved_regs[i] = 0;
-
-  return cache;
-}
-
-static CORE_ADDR
-examine_prologue (CORE_ADDR pc, CORE_ADDR lim_pc,
-		  const frame_info_ptr &this_frame,
-		  struct ia64_frame_cache *cache)
-{
-  CORE_ADDR next_pc;
-  CORE_ADDR last_prologue_pc = pc;
-  ia64_instruction_type it;
-  long long instr;
-  int cfm_reg  = 0;
-  int ret_reg  = 0;
-  int fp_reg   = 0;
-  int unat_save_reg = 0;
-  int pr_save_reg = 0;
-  int mem_stack_frame_size = 0;
-  int spill_reg   = 0;
-  CORE_ADDR spill_addr = 0;
-  char instores[8];
-  char infpstores[8];
-  char reg_contents[256];
-  int trust_limit;
-  int frameless = 1;
-  int i;
-  CORE_ADDR addr;
-  gdb_byte buf[8];
-  CORE_ADDR bof, sor, sol, sof, cfm, rrb_gr;
-
-  memset (instores, 0, sizeof instores);
-  memset (infpstores, 0, sizeof infpstores);
-  memset (reg_contents, 0, sizeof reg_contents);
-
-  if (cache->after_prologue != 0
-      && cache->after_prologue <= lim_pc)
-    return cache->after_prologue;
-
-  lim_pc = refine_prologue_limit (pc, lim_pc, &trust_limit);
-  next_pc = fetch_instruction (pc, &it, &instr);
-
-  /* We want to check if we have a recognizable function start before we
-     look ahead for a prologue.  */
-  if (pc < lim_pc && next_pc 
-      && it == M && ((instr & 0x1ee0000003fLL) == 0x02c00000000LL))
-    {
-      /* alloc - start of a regular function.  */
-      int sol_bits = (int) ((instr & 0x00007f00000LL) >> 20);
-      int sof_bits = (int) ((instr & 0x000000fe000LL) >> 13);
-      int rN = (int) ((instr & 0x00000001fc0LL) >> 6);
-
-      /* Verify that the current cfm matches what we think is the
-	 function start.  If we have somehow jumped within a function,
-	 we do not want to interpret the prologue and calculate the
-	 addresses of various registers such as the return address.
-	 We will instead treat the frame as frameless.  */
-      if (!this_frame ||
-	  (sof_bits == (cache->cfm & 0x7f) &&
-	   sol_bits == ((cache->cfm >> 7) & 0x7f)))
-	frameless = 0;
-
-      cfm_reg = rN;
-      last_prologue_pc = next_pc;
-      pc = next_pc;
-    }
-  else
-    {
-      /* Look for a leaf routine.  */
-      if (pc < lim_pc && next_pc
-	  && (it == I || it == M) 
-	  && ((instr & 0x1ee00000000LL) == 0x10800000000LL))
-	{
-	  /* adds rN = imm14, rM   (or mov rN, rM  when imm14 is 0) */
-	  int imm = (int) ((((instr & 0x01000000000LL) ? -1 : 0) << 13) 
-			   | ((instr & 0x001f8000000LL) >> 20)
-			   | ((instr & 0x000000fe000LL) >> 13));
-	  int rM = (int) ((instr & 0x00007f00000LL) >> 20);
-	  int rN = (int) ((instr & 0x00000001fc0LL) >> 6);
-	  int qp = (int) (instr & 0x0000000003fLL);
-	  if (qp == 0 && rN == 2 && imm == 0 && rM == 12 && fp_reg == 0)
-	    {
-	      /* mov r2, r12 - beginning of leaf routine.  */
-	      fp_reg = rN;
-	      last_prologue_pc = next_pc;
-	    }
-	} 
-
-      /* If we don't recognize a regular function or leaf routine, we are
-	 done.  */
-      if (!fp_reg)
-	{
-	  pc = lim_pc;	
-	  if (trust_limit)
-	    last_prologue_pc = lim_pc;
-	}
-    }
-
-  /* Loop, looking for prologue instructions, keeping track of
-     where preserved registers were spilled.  */
-  while (pc < lim_pc)
-    {
-      next_pc = fetch_instruction (pc, &it, &instr);
-      if (next_pc == 0)
-	break;
-
-      if (it == B && ((instr & 0x1e1f800003fLL) != 0x04000000000LL))
-	{
-	  /* Exit loop upon hitting a non-nop branch instruction.  */ 
-	  if (trust_limit)
-	    lim_pc = pc;
-	  break;
-	}
-      else if (((instr & 0x3fLL) != 0LL) && 
-	       (frameless || ret_reg != 0))
-	{
-	  /* Exit loop upon hitting a predicated instruction if
-	     we already have the return register or if we are frameless.  */ 
-	  if (trust_limit)
-	    lim_pc = pc;
-	  break;
-	}
-      else if (it == I && ((instr & 0x1eff8000000LL) == 0x00188000000LL))
-	{
-	  /* Move from BR */
-	  int b2 = (int) ((instr & 0x0000000e000LL) >> 13);
-	  int rN = (int) ((instr & 0x00000001fc0LL) >> 6);
-	  int qp = (int) (instr & 0x0000000003f);
-
-	  if (qp == 0 && b2 == 0 && rN >= 32 && ret_reg == 0)
-	    {
-	      ret_reg = rN;
-	      last_prologue_pc = next_pc;
-	    }
-	}
-      else if ((it == I || it == M) 
-	  && ((instr & 0x1ee00000000LL) == 0x10800000000LL))
-	{
-	  /* adds rN = imm14, rM   (or mov rN, rM  when imm14 is 0) */
-	  int imm = (int) ((((instr & 0x01000000000LL) ? -1 : 0) << 13) 
-			   | ((instr & 0x001f8000000LL) >> 20)
-			   | ((instr & 0x000000fe000LL) >> 13));
-	  int rM = (int) ((instr & 0x00007f00000LL) >> 20);
-	  int rN = (int) ((instr & 0x00000001fc0LL) >> 6);
-	  int qp = (int) (instr & 0x0000000003fLL);
-
-	  if (qp == 0 && rN >= 32 && imm == 0 && rM == 12 && fp_reg == 0)
-	    {
-	      /* mov rN, r12 */
-	      fp_reg = rN;
-	      last_prologue_pc = next_pc;
-	    }
-	  else if (qp == 0 && rN == 12 && rM == 12)
-	    {
-	      /* adds r12, -mem_stack_frame_size, r12 */
-	      mem_stack_frame_size -= imm;
-	      last_prologue_pc = next_pc;
-	    }
-	  else if (qp == 0 && rN == 2 
-		&& ((rM == fp_reg && fp_reg != 0) || rM == 12))
-	    {
-	      CORE_ADDR saved_sp = 0;
-	      /* adds r2, spilloffset, rFramePointer 
-		   or
-		 adds r2, spilloffset, r12
-
-		 Get ready for stf.spill or st8.spill instructions.
-		 The address to start spilling at is loaded into r2.
-		 FIXME:  Why r2?  That's what gcc currently uses; it
-		 could well be different for other compilers.  */
-
-	      /* Hmm...  whether or not this will work will depend on
-		 where the pc is.  If it's still early in the prologue
-		 this'll be wrong.  FIXME */
-	      if (this_frame)
-		saved_sp = get_frame_register_unsigned (this_frame,
-							sp_regnum);
-	      spill_addr  = saved_sp
-			  + (rM == 12 ? 0 : mem_stack_frame_size) 
-			  + imm;
-	      spill_reg   = rN;
-	      last_prologue_pc = next_pc;
-	    }
-	  else if (qp == 0 && rM >= 32 && rM < 40 && !instores[rM-32] && 
-		   rN < 256 && imm == 0)
-	    {
-	      /* mov rN, rM where rM is an input register.  */
-	      reg_contents[rN] = rM;
-	      last_prologue_pc = next_pc;
-	    }
-	  else if (frameless && qp == 0 && rN == fp_reg && imm == 0 && 
-		   rM == 2)
-	    {
-	      /* mov r12, r2 */
-	      last_prologue_pc = next_pc;
-	      break;
-	    }
-	}
-      else if (it == M 
-	    && (   ((instr & 0x1efc0000000LL) == 0x0eec0000000LL)
-		|| ((instr & 0x1ffc8000000LL) == 0x0cec0000000LL) ))
-	{
-	  /* stf.spill [rN] = fM, imm9
-	     or
-	     stf.spill [rN] = fM  */
-
-	  int imm = imm9(instr);
-	  int rN = (int) ((instr & 0x00007f00000LL) >> 20);
-	  int fM = (int) ((instr & 0x000000fe000LL) >> 13);
-	  int qp = (int) (instr & 0x0000000003fLL);
-	  if (qp == 0 && rN == spill_reg && spill_addr != 0
-	      && ((2 <= fM && fM <= 5) || (16 <= fM && fM <= 31)))
-	    {
-	      cache->saved_regs[IA64_FR0_REGNUM + fM] = spill_addr;
-
-	      if ((instr & 0x1efc0000000LL) == 0x0eec0000000LL)
-		spill_addr += imm;
-	      else
-		spill_addr = 0;		/* last one; must be done.  */
-	      last_prologue_pc = next_pc;
-	    }
-	}
-      else if ((it == M && ((instr & 0x1eff8000000LL) == 0x02110000000LL))
-	    || (it == I && ((instr & 0x1eff8000000LL) == 0x00050000000LL)) )
-	{
-	  /* mov.m rN = arM   
-	       or 
-	     mov.i rN = arM */
-
-	  int arM = (int) ((instr & 0x00007f00000LL) >> 20);
-	  int rN  = (int) ((instr & 0x00000001fc0LL) >> 6);
-	  int qp  = (int) (instr & 0x0000000003fLL);
-	  if (qp == 0 && isScratch (rN) && arM == 36 /* ar.unat */)
-	    {
-	      /* We have something like "mov.m r3 = ar.unat".  Remember the
-		 r3 (or whatever) and watch for a store of this register...  */
-	      unat_save_reg = rN;
-	      last_prologue_pc = next_pc;
-	    }
-	}
-      else if (it == I && ((instr & 0x1eff8000000LL) == 0x00198000000LL))
-	{
-	  /* mov rN = pr */
-	  int rN  = (int) ((instr & 0x00000001fc0LL) >> 6);
-	  int qp  = (int) (instr & 0x0000000003fLL);
-	  if (qp == 0 && isScratch (rN))
-	    {
-	      pr_save_reg = rN;
-	      last_prologue_pc = next_pc;
-	    }
-	}
-      else if (it == M 
-	    && (   ((instr & 0x1ffc8000000LL) == 0x08cc0000000LL)
-		|| ((instr & 0x1efc0000000LL) == 0x0acc0000000LL)))
-	{
-	  /* st8 [rN] = rM 
-	      or
-	     st8 [rN] = rM, imm9 */
-	  int rN = (int) ((instr & 0x00007f00000LL) >> 20);
-	  int rM = (int) ((instr & 0x000000fe000LL) >> 13);
-	  int qp = (int) (instr & 0x0000000003fLL);
-	  int indirect = rM < 256 ? reg_contents[rM] : 0;
-	  if (qp == 0 && rN == spill_reg && spill_addr != 0
-	      && (rM == unat_save_reg || rM == pr_save_reg))
-	    {
-	      /* We've found a spill of either the UNAT register or the PR
-		 register.  (Well, not exactly; what we've actually found is
-		 a spill of the register that UNAT or PR was moved to).
-		 Record that fact and move on...  */
-	      if (rM == unat_save_reg)
-		{
-		  /* Track UNAT register.  */
-		  cache->saved_regs[IA64_UNAT_REGNUM] = spill_addr;
-		  unat_save_reg = 0;
-		}
-	      else
-		{
-		  /* Track PR register.  */
-		  cache->saved_regs[IA64_PR_REGNUM] = spill_addr;
-		  pr_save_reg = 0;
-		}
-	      if ((instr & 0x1efc0000000LL) == 0x0acc0000000LL)
-		/* st8 [rN] = rM, imm9 */
-		spill_addr += imm9(instr);
-	      else
-		spill_addr = 0;		/* Must be done spilling.  */
-	      last_prologue_pc = next_pc;
-	    }
-	  else if (qp == 0 && 32 <= rM && rM < 40 && !instores[rM-32])
-	    {
-	      /* Allow up to one store of each input register.  */
-	      instores[rM-32] = 1;
-	      last_prologue_pc = next_pc;
-	    }
-	  else if (qp == 0 && 32 <= indirect && indirect < 40 && 
-		   !instores[indirect-32])
-	    {
-	      /* Allow an indirect store of an input register.  */
-	      instores[indirect-32] = 1;
-	      last_prologue_pc = next_pc;
-	    }
-	}
-      else if (it == M && ((instr & 0x1ff08000000LL) == 0x08c00000000LL))
-	{
-	  /* One of
-	       st1 [rN] = rM
-	       st2 [rN] = rM
-	       st4 [rN] = rM
-	       st8 [rN] = rM
-	     Note that the st8 case is handled in the clause above.
-	     
-	     Advance over stores of input registers.  One store per input
-	     register is permitted.  */
-	  int rM = (int) ((instr & 0x000000fe000LL) >> 13);
-	  int qp = (int) (instr & 0x0000000003fLL);
-	  int indirect = rM < 256 ? reg_contents[rM] : 0;
-	  if (qp == 0 && 32 <= rM && rM < 40 && !instores[rM-32])
-	    {
-	      instores[rM-32] = 1;
-	      last_prologue_pc = next_pc;
-	    }
-	  else if (qp == 0 && 32 <= indirect && indirect < 40 && 
-		   !instores[indirect-32])
-	    {
-	      /* Allow an indirect store of an input register.  */
-	      instores[indirect-32] = 1;
-	      last_prologue_pc = next_pc;
-	    }
-	}
-      else if (it == M && ((instr & 0x1ff88000000LL) == 0x0cc80000000LL))
-	{
-	  /* Either
-	       stfs [rN] = fM
-	     or
-	       stfd [rN] = fM
-
-	     Advance over stores of floating point input registers.  Again
-	     one store per register is permitted.  */
-	  int fM = (int) ((instr & 0x000000fe000LL) >> 13);
-	  int qp = (int) (instr & 0x0000000003fLL);
-	  if (qp == 0 && 8 <= fM && fM < 16 && !infpstores[fM - 8])
-	    {
-	      infpstores[fM-8] = 1;
-	      last_prologue_pc = next_pc;
-	    }
-	}
-      else if (it == M
-	    && (   ((instr & 0x1ffc8000000LL) == 0x08ec0000000LL)
-		|| ((instr & 0x1efc0000000LL) == 0x0aec0000000LL)))
-	{
-	  /* st8.spill [rN] = rM
-	       or
-	     st8.spill [rN] = rM, imm9 */
-	  int rN = (int) ((instr & 0x00007f00000LL) >> 20);
-	  int rM = (int) ((instr & 0x000000fe000LL) >> 13);
-	  int qp = (int) (instr & 0x0000000003fLL);
-	  if (qp == 0 && rN == spill_reg && 4 <= rM && rM <= 7)
-	    {
-	      /* We've found a spill of one of the preserved general purpose
-		 regs.  Record the spill address and advance the spill
-		 register if appropriate.  */
-	      cache->saved_regs[IA64_GR0_REGNUM + rM] = spill_addr;
-	      if ((instr & 0x1efc0000000LL) == 0x0aec0000000LL)
-		/* st8.spill [rN] = rM, imm9 */
-		spill_addr += imm9(instr);
-	      else
-		spill_addr = 0;		/* Done spilling.  */
-	      last_prologue_pc = next_pc;
-	    }
-	}
-
-      pc = next_pc;
-    }
-
-  /* If not frameless and we aren't called by skip_prologue, then we need
-     to calculate registers for the previous frame which will be needed
-     later.  */
-
-  if (!frameless && this_frame)
-    {
-      struct gdbarch *gdbarch = get_frame_arch (this_frame);
-      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-
-      /* Extract the size of the rotating portion of the stack
-	 frame and the register rename base from the current
-	 frame marker.  */
-      cfm = cache->cfm;
-      sor = cache->sor;
-      sof = cache->sof;
-      sol = cache->sol;
-      rrb_gr = (cfm >> 18) & 0x7f;
-
-      /* Find the bof (beginning of frame).  */
-      bof = rse_address_add (cache->bsp, -sof);
-      
-      for (i = 0, addr = bof;
-	   i < sof;
-	   i++, addr += 8)
-	{
-	  if (IS_NaT_COLLECTION_ADDR (addr))
-	    {
-	      addr += 8;
-	    }
-	  if (i+32 == cfm_reg)
-	    cache->saved_regs[IA64_CFM_REGNUM] = addr;
-	  if (i+32 == ret_reg)
-	    cache->saved_regs[IA64_VRAP_REGNUM] = addr;
-	  if (i+32 == fp_reg)
-	    cache->saved_regs[IA64_VFP_REGNUM] = addr;
-	}
-
-      /* For the previous argument registers we require the previous bof.
-	 If we can't find the previous cfm, then we can do nothing.  */
-      cfm = 0;
-      if (cache->saved_regs[IA64_CFM_REGNUM] != 0)
-	{
-	  cfm = read_memory_integer (cache->saved_regs[IA64_CFM_REGNUM],
-				     8, byte_order);
-	}
-      else if (cfm_reg != 0)
-	{
-	  get_frame_register (this_frame, cfm_reg, buf);
-	  cfm = extract_unsigned_integer (buf, 8, byte_order);
-	}
-      cache->prev_cfm = cfm;
-      
-      if (cfm != 0)
-	{
-	  sor = ((cfm >> 14) & 0xf) * 8;
-	  sof = (cfm & 0x7f);
-	  sol = (cfm >> 7) & 0x7f;
-	  rrb_gr = (cfm >> 18) & 0x7f;
-
-	  /* The previous bof only requires subtraction of the sol (size of
-	     locals) due to the overlap between output and input of
-	     subsequent frames.  */
-	  bof = rse_address_add (bof, -sol);
-	  
-	  for (i = 0, addr = bof;
-	       i < sof;
-	       i++, addr += 8)
-	    {
-	      if (IS_NaT_COLLECTION_ADDR (addr))
-		{
-		  addr += 8;
-		}
-	      if (i < sor)
-		cache->saved_regs[IA64_GR32_REGNUM
-				  + ((i + (sor - rrb_gr)) % sor)] 
-		  = addr;
-	      else
-		cache->saved_regs[IA64_GR32_REGNUM + i] = addr;
-	    }
-	  
-	}
-    }
-      
-  /* Try and trust the lim_pc value whenever possible.  */
-  if (trust_limit && lim_pc >= last_prologue_pc)
-    last_prologue_pc = lim_pc;
-
-  cache->frameless = frameless;
-  cache->after_prologue = last_prologue_pc;
-  cache->mem_stack_frame_size = mem_stack_frame_size;
-  cache->fp_reg = fp_reg;
-
-  return last_prologue_pc;
-}
-
-CORE_ADDR
-ia64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
-{
-  struct ia64_frame_cache cache;
-  cache.base = 0;
-  cache.after_prologue = 0;
-  cache.cfm = 0;
-  cache.bsp = 0;
-
-  /* Call examine_prologue with - as third argument since we don't
-     have a next frame pointer to send.  */
-  return examine_prologue (pc, pc+1024, 0, &cache);
-}
-
-
-/* Normal frames.  */
-
-static struct ia64_frame_cache *
-ia64_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
-{
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct ia64_frame_cache *cache;
-  gdb_byte buf[8];
-  CORE_ADDR cfm;
-
-  if (*this_cache)
-    return (struct ia64_frame_cache *) *this_cache;
-
-  cache = ia64_alloc_frame_cache ();
-  *this_cache = cache;
-
-  get_frame_register (this_frame, sp_regnum, buf);
-  cache->saved_sp = extract_unsigned_integer (buf, 8, byte_order);
-
-  /* We always want the bsp to point to the end of frame.
-     This way, we can always get the beginning of frame (bof)
-     by subtracting frame size.  */
-  get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-  cache->bsp = extract_unsigned_integer (buf, 8, byte_order);
-  
-  get_frame_register (this_frame, IA64_PSR_REGNUM, buf);
-
-  get_frame_register (this_frame, IA64_CFM_REGNUM, buf);
-  cfm = extract_unsigned_integer (buf, 8, byte_order);
-
-  cache->sof = (cfm & 0x7f);
-  cache->sol = (cfm >> 7) & 0x7f;
-  cache->sor = ((cfm >> 14) & 0xf) * 8;
-
-  cache->cfm = cfm;
-
-  cache->pc = get_frame_func (this_frame);
-
-  if (cache->pc != 0)
-    examine_prologue (cache->pc, get_frame_pc (this_frame), this_frame, cache);
-  
-  cache->base = cache->saved_sp + cache->mem_stack_frame_size;
-
-  return cache;
-}
-
-static void
-ia64_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
-		    struct frame_id *this_id)
-{
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct ia64_frame_cache *cache =
-    ia64_frame_cache (this_frame, this_cache);
-
-  /* If outermost frame, mark with null frame id.  */
-  if (cache->base != 0)
-    (*this_id) = frame_id_build_special (cache->base, cache->pc, cache->bsp);
-  if (gdbarch_debug >= 1)
-    gdb_printf (gdb_stdlog,
-		"regular frame id: code %s, stack %s, "
-		"special %s, this_frame %s\n",
-		paddress (gdbarch, this_id->code_addr),
-		paddress (gdbarch, this_id->stack_addr),
-		paddress (gdbarch, cache->bsp),
-		host_address_to_string (this_frame.get ()));
-}
-
-static struct value *
-ia64_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
-			  int regnum)
-{
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct ia64_frame_cache *cache = ia64_frame_cache (this_frame, this_cache);
-  gdb_byte buf[8];
-
-  gdb_assert (regnum >= 0);
-
-  if (!target_has_registers ())
-    error (_("No registers."));
-
-  if (regnum == gdbarch_sp_regnum (gdbarch))
-    return frame_unwind_got_constant (this_frame, regnum, cache->base);
-
-  else if (regnum == IA64_BSP_REGNUM)
-    {
-      struct value *val;
-      CORE_ADDR prev_cfm, bsp, prev_bsp;
-
-      /* We want to calculate the previous bsp as the end of the previous
-	 register stack frame.  This corresponds to what the hardware bsp
-	 register will be if we pop the frame back which is why we might
-	 have been called.  We know the beginning of the current frame is
-	 cache->bsp - cache->sof.  This value in the previous frame points
-	 to the start of the output registers.  We can calculate the end of
-	 that frame by adding the size of output:
-	    (sof (size of frame) - sol (size of locals)).  */
-      val = ia64_frame_prev_register (this_frame, this_cache, IA64_CFM_REGNUM);
-      prev_cfm = extract_unsigned_integer (val->contents_all ().data (),
-					   8, byte_order);
-      bsp = rse_address_add (cache->bsp, -(cache->sof));
-      prev_bsp =
-	rse_address_add (bsp, (prev_cfm & 0x7f) - ((prev_cfm >> 7) & 0x7f));
-
-      return frame_unwind_got_constant (this_frame, regnum, prev_bsp);
-    }
-
-  else if (regnum == IA64_CFM_REGNUM)
-    {
-      CORE_ADDR addr = cache->saved_regs[IA64_CFM_REGNUM];
-      
-      if (addr != 0)
-	return frame_unwind_got_memory (this_frame, regnum, addr);
-
-      if (cache->prev_cfm)
-	return frame_unwind_got_constant (this_frame, regnum, cache->prev_cfm);
-
-      if (cache->frameless)
-	return frame_unwind_got_register (this_frame, IA64_PFS_REGNUM,
-					  IA64_PFS_REGNUM);
-      return frame_unwind_got_register (this_frame, regnum, 0);
-    }
-
-  else if (regnum == IA64_VFP_REGNUM)
-    {
-      /* If the function in question uses an automatic register (r32-r127)
-	 for the frame pointer, it'll be found by ia64_find_saved_register()
-	 above.  If the function lacks one of these frame pointers, we can
-	 still provide a value since we know the size of the frame.  */
-      return frame_unwind_got_constant (this_frame, regnum, cache->base);
-    }
-
-  else if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
-    {
-      struct value *pr_val;
-      ULONGEST prN;
-      
-      pr_val = ia64_frame_prev_register (this_frame, this_cache,
-					 IA64_PR_REGNUM);
-      if (VP16_REGNUM <= regnum && regnum <= VP63_REGNUM)
-	{
-	  /* Fetch predicate register rename base from current frame
-	     marker for this frame.  */
-	  int rrb_pr = (cache->cfm >> 32) & 0x3f;
-
-	  /* Adjust the register number to account for register rotation.  */
-	  regnum = VP16_REGNUM + ((regnum - VP16_REGNUM) + rrb_pr) % 48;
-	}
-      prN = extract_bit_field (pr_val->contents_all ().data (),
-			       regnum - VP0_REGNUM, 1);
-      return frame_unwind_got_constant (this_frame, regnum, prN);
-    }
-
-  else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT31_REGNUM)
-    {
-      struct value *unat_val;
-      ULONGEST unatN;
-      unat_val = ia64_frame_prev_register (this_frame, this_cache,
-					   IA64_UNAT_REGNUM);
-      unatN = extract_bit_field (unat_val->contents_all ().data (),
-				 regnum - IA64_NAT0_REGNUM, 1);
-      return frame_unwind_got_constant (this_frame, regnum, unatN);
-    }
-
-  else if (IA64_NAT32_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
-    {
-      int natval = 0;
-      /* Find address of general register corresponding to nat bit we're
-	 interested in.  */
-      CORE_ADDR gr_addr;
-
-      gr_addr = cache->saved_regs[regnum - IA64_NAT0_REGNUM + IA64_GR0_REGNUM];
-
-      if (gr_addr != 0)
-	{
-	  /* Compute address of nat collection bits.  */
-	  CORE_ADDR nat_addr = gr_addr | 0x1f8;
-	  CORE_ADDR bsp;
-	  CORE_ADDR nat_collection;
-	  int nat_bit;
-
-	  /* If our nat collection address is bigger than bsp, we have to get
-	     the nat collection from rnat.  Otherwise, we fetch the nat
-	     collection from the computed address.  */
-	  get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-	  bsp = extract_unsigned_integer (buf, 8, byte_order);
-	  if (nat_addr >= bsp)
-	    {
-	      get_frame_register (this_frame, IA64_RNAT_REGNUM, buf);
-	      nat_collection = extract_unsigned_integer (buf, 8, byte_order);
-	    }
-	  else
-	    nat_collection = read_memory_integer (nat_addr, 8, byte_order);
-	  nat_bit = (gr_addr >> 3) & 0x3f;
-	  natval = (nat_collection >> nat_bit) & 1;
-	}
-
-      return frame_unwind_got_constant (this_frame, regnum, natval);
-    }
-
-  else if (regnum == IA64_IP_REGNUM)
-    {
-      CORE_ADDR pc = 0;
-      CORE_ADDR addr = cache->saved_regs[IA64_VRAP_REGNUM];
-
-      if (addr != 0)
-	{
-	  read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
-	  pc = extract_unsigned_integer (buf, 8, byte_order);
-	}
-      else if (cache->frameless)
-	{
-	  get_frame_register (this_frame, IA64_BR0_REGNUM, buf);
-	  pc = extract_unsigned_integer (buf, 8, byte_order);
-	}
-      pc &= ~0xf;
-      return frame_unwind_got_constant (this_frame, regnum, pc);
-    }
-
-  else if (regnum == IA64_PSR_REGNUM)
-    {
-      /* We don't know how to get the complete previous PSR, but we need it
-	 for the slot information when we unwind the pc (pc is formed of IP
-	 register plus slot information from PSR).  To get the previous
-	 slot information, we mask it off the return address.  */
-      ULONGEST slot_num = 0;
-      CORE_ADDR pc = 0;
-      CORE_ADDR psr = 0;
-      CORE_ADDR addr = cache->saved_regs[IA64_VRAP_REGNUM];
-
-      get_frame_register (this_frame, IA64_PSR_REGNUM, buf);
-      psr = extract_unsigned_integer (buf, 8, byte_order);
-
-      if (addr != 0)
-	{
-	  read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
-	  pc = extract_unsigned_integer (buf, 8, byte_order);
-	}
-      else if (cache->frameless)
-	{
-	  get_frame_register (this_frame, IA64_BR0_REGNUM, buf);
-	  pc = extract_unsigned_integer (buf, 8, byte_order);
-	}
-      psr &= ~(3LL << 41);
-      slot_num = pc & 0x3LL;
-      psr |= (CORE_ADDR)slot_num << 41;
-      return frame_unwind_got_constant (this_frame, regnum, psr);
-    }
-
-  else if (regnum == IA64_BR0_REGNUM)
-    {
-      CORE_ADDR addr = cache->saved_regs[IA64_BR0_REGNUM];
-
-      if (addr != 0)
-	return frame_unwind_got_memory (this_frame, regnum, addr);
-
-      return frame_unwind_got_constant (this_frame, regnum, 0);
-    }
-
-  else if ((regnum >= IA64_GR32_REGNUM && regnum <= IA64_GR127_REGNUM)
-	   || (regnum >= V32_REGNUM && regnum <= V127_REGNUM))
-    {
-      CORE_ADDR addr = 0;
-
-      if (regnum >= V32_REGNUM)
-	regnum = IA64_GR32_REGNUM + (regnum - V32_REGNUM);
-      addr = cache->saved_regs[regnum];
-      if (addr != 0)
-	return frame_unwind_got_memory (this_frame, regnum, addr);
-
-      if (cache->frameless)
-	{
-	  struct value *reg_val;
-	  CORE_ADDR prev_cfm, prev_bsp, prev_bof;
-
-	  /* FIXME: brobecker/2008-05-01: Doesn't this seem redundant
-	     with the same code above?  */
-	  if (regnum >= V32_REGNUM)
-	    regnum = IA64_GR32_REGNUM + (regnum - V32_REGNUM);
-	  reg_val = ia64_frame_prev_register (this_frame, this_cache,
-					      IA64_CFM_REGNUM);
-	  prev_cfm = extract_unsigned_integer
-	    (reg_val->contents_all ().data (), 8, byte_order);
-	  reg_val = ia64_frame_prev_register (this_frame, this_cache,
-					      IA64_BSP_REGNUM);
-	  prev_bsp = extract_unsigned_integer
-	    (reg_val->contents_all ().data (), 8, byte_order);
-	  prev_bof = rse_address_add (prev_bsp, -(prev_cfm & 0x7f));
-
-	  addr = rse_address_add (prev_bof, (regnum - IA64_GR32_REGNUM));
-	  return frame_unwind_got_memory (this_frame, regnum, addr);
-	}
-      
-      return frame_unwind_got_constant (this_frame, regnum, 0);
-    }
-
-  else /* All other registers.  */
-    {
-      CORE_ADDR addr = 0;
-
-      if (IA64_FR32_REGNUM <= regnum && regnum <= IA64_FR127_REGNUM)
-	{
-	  /* Fetch floating point register rename base from current
-	     frame marker for this frame.  */
-	  int rrb_fr = (cache->cfm >> 25) & 0x7f;
-
-	  /* Adjust the floating point register number to account for
-	     register rotation.  */
-	  regnum = IA64_FR32_REGNUM
-		 + ((regnum - IA64_FR32_REGNUM) + rrb_fr) % 96;
-	}
-
-      /* If we have stored a memory address, access the register.  */
-      addr = cache->saved_regs[regnum];
-      if (addr != 0)
-	return frame_unwind_got_memory (this_frame, regnum, addr);
-      /* Otherwise, punt and get the current value of the register.  */
-      else 
-	return frame_unwind_got_register (this_frame, regnum, regnum);
-    }
-}
- 
-static const struct frame_unwind ia64_frame_unwind =
-{
-  "ia64 prologue",
-  NORMAL_FRAME,
-  default_frame_unwind_stop_reason,
-  &ia64_frame_this_id,
-  &ia64_frame_prev_register,
-  NULL,
-  default_frame_sniffer
-};
-
-/* Signal trampolines.  */
-
-static void
-ia64_sigtramp_frame_init_saved_regs (const frame_info_ptr &this_frame,
-				     struct ia64_frame_cache *cache)
-{
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
-
-  if (tdep->sigcontext_register_address)
-    {
-      int regno;
-
-      cache->saved_regs[IA64_VRAP_REGNUM]
-	= tdep->sigcontext_register_address (gdbarch, cache->base,
-					     IA64_IP_REGNUM);
-      cache->saved_regs[IA64_CFM_REGNUM]
-	= tdep->sigcontext_register_address (gdbarch, cache->base,
-					     IA64_CFM_REGNUM);
-      cache->saved_regs[IA64_PSR_REGNUM]
-	= tdep->sigcontext_register_address (gdbarch, cache->base,
-					     IA64_PSR_REGNUM);
-      cache->saved_regs[IA64_BSP_REGNUM]
-	= tdep->sigcontext_register_address (gdbarch, cache->base,
-					     IA64_BSP_REGNUM);
-      cache->saved_regs[IA64_RNAT_REGNUM]
-	= tdep->sigcontext_register_address (gdbarch, cache->base,
-					     IA64_RNAT_REGNUM);
-      cache->saved_regs[IA64_CCV_REGNUM]
-	= tdep->sigcontext_register_address (gdbarch, cache->base,
-					     IA64_CCV_REGNUM);
-      cache->saved_regs[IA64_UNAT_REGNUM]
-	= tdep->sigcontext_register_address (gdbarch, cache->base,
-					     IA64_UNAT_REGNUM);
-      cache->saved_regs[IA64_FPSR_REGNUM]
-	= tdep->sigcontext_register_address (gdbarch, cache->base,
-					     IA64_FPSR_REGNUM);
-      cache->saved_regs[IA64_PFS_REGNUM]
-	= tdep->sigcontext_register_address (gdbarch, cache->base,
-					     IA64_PFS_REGNUM);
-      cache->saved_regs[IA64_LC_REGNUM]
-	= tdep->sigcontext_register_address (gdbarch, cache->base,
-					     IA64_LC_REGNUM);
-
-      for (regno = IA64_GR1_REGNUM; regno <= IA64_GR31_REGNUM; regno++)
-	cache->saved_regs[regno] =
-	  tdep->sigcontext_register_address (gdbarch, cache->base, regno);
-      for (regno = IA64_BR0_REGNUM; regno <= IA64_BR7_REGNUM; regno++)
-	cache->saved_regs[regno] =
-	  tdep->sigcontext_register_address (gdbarch, cache->base, regno);
-      for (regno = IA64_FR2_REGNUM; regno <= IA64_FR31_REGNUM; regno++)
-	cache->saved_regs[regno] =
-	  tdep->sigcontext_register_address (gdbarch, cache->base, regno);
-    }
-}
-
-static struct ia64_frame_cache *
-ia64_sigtramp_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
-{
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct ia64_frame_cache *cache;
-  gdb_byte buf[8];
-
-  if (*this_cache)
-    return (struct ia64_frame_cache *) *this_cache;
-
-  cache = ia64_alloc_frame_cache ();
-
-  get_frame_register (this_frame, sp_regnum, buf);
-  /* Note that frame size is hard-coded below.  We cannot calculate it
-     via prologue examination.  */
-  cache->base = extract_unsigned_integer (buf, 8, byte_order) + 16;
-
-  get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-  cache->bsp = extract_unsigned_integer (buf, 8, byte_order);
-
-  get_frame_register (this_frame, IA64_CFM_REGNUM, buf);
-  cache->cfm = extract_unsigned_integer (buf, 8, byte_order);
-  cache->sof = cache->cfm & 0x7f;
-
-  ia64_sigtramp_frame_init_saved_regs (this_frame, cache);
-
-  *this_cache = cache;
-  return cache;
-}
-
-static void
-ia64_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
-			     void **this_cache, struct frame_id *this_id)
-{
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct ia64_frame_cache *cache =
-    ia64_sigtramp_frame_cache (this_frame, this_cache);
-
-  (*this_id) = frame_id_build_special (cache->base,
-				       get_frame_pc (this_frame),
-				       cache->bsp);
-  if (gdbarch_debug >= 1)
-    gdb_printf (gdb_stdlog,
-		"sigtramp frame id: code %s, stack %s, "
-		"special %s, this_frame %s\n",
-		paddress (gdbarch, this_id->code_addr),
-		paddress (gdbarch, this_id->stack_addr),
-		paddress (gdbarch, cache->bsp),
-		host_address_to_string (this_frame.get ()));
-}
-
-static struct value *
-ia64_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
-				   void **this_cache, int regnum)
-{
-  struct ia64_frame_cache *cache =
-    ia64_sigtramp_frame_cache (this_frame, this_cache);
-
-  gdb_assert (regnum >= 0);
-
-  if (!target_has_registers ())
-    error (_("No registers."));
-
-  if (regnum == IA64_IP_REGNUM)
-    {
-      CORE_ADDR pc = 0;
-      CORE_ADDR addr = cache->saved_regs[IA64_VRAP_REGNUM];
-
-      if (addr != 0)
-	{
-	  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-	  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-	  pc = read_memory_unsigned_integer (addr, 8, byte_order);
-	}
-      pc &= ~0xf;
-      return frame_unwind_got_constant (this_frame, regnum, pc);
-    }
-
-  else if ((regnum >= IA64_GR32_REGNUM && regnum <= IA64_GR127_REGNUM)
-	   || (regnum >= V32_REGNUM && regnum <= V127_REGNUM))
-    {
-      CORE_ADDR addr = 0;
-
-      if (regnum >= V32_REGNUM)
-	regnum = IA64_GR32_REGNUM + (regnum - V32_REGNUM);
-      addr = cache->saved_regs[regnum];
-      if (addr != 0)
-	return frame_unwind_got_memory (this_frame, regnum, addr);
-
-      return frame_unwind_got_constant (this_frame, regnum, 0);
-    }
-
-  else  /* All other registers not listed above.  */
-    {
-      CORE_ADDR addr = cache->saved_regs[regnum];
-
-      if (addr != 0)
-	return frame_unwind_got_memory (this_frame, regnum, addr);
-
-      return frame_unwind_got_constant (this_frame, regnum, 0);
-    }
-}
-
-static int
-ia64_sigtramp_frame_sniffer (const struct frame_unwind *self,
-			     const frame_info_ptr &this_frame,
-			     void **this_cache)
-{
-  gdbarch *arch = get_frame_arch (this_frame);
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (arch);
-  if (tdep->pc_in_sigtramp)
-    {
-      CORE_ADDR pc = get_frame_pc (this_frame);
-
-      if (tdep->pc_in_sigtramp (pc))
-	return 1;
-    }
-
-  return 0;
-}
-
-static const struct frame_unwind ia64_sigtramp_frame_unwind =
-{
-  "ia64 sigtramp",
-  SIGTRAMP_FRAME,
-  default_frame_unwind_stop_reason,
-  ia64_sigtramp_frame_this_id,
-  ia64_sigtramp_frame_prev_register,
-  NULL,
-  ia64_sigtramp_frame_sniffer
-};
-
-\f
-
-static CORE_ADDR
-ia64_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
-{
-  struct ia64_frame_cache *cache = ia64_frame_cache (this_frame, this_cache);
-
-  return cache->base;
-}
-
-static const struct frame_base ia64_frame_base =
-{
-  &ia64_frame_unwind,
-  ia64_frame_base_address,
-  ia64_frame_base_address,
-  ia64_frame_base_address
-};
-
-#ifdef HAVE_LIBUNWIND_IA64_H
-
-struct ia64_unwind_table_entry
-  {
-    unw_word_t start_offset;
-    unw_word_t end_offset;
-    unw_word_t info_offset;
-  };
-
-static __inline__ uint64_t
-ia64_rse_slot_num (uint64_t addr)
-{
-  return (addr >> 3) & 0x3f;
-}
-
-/* Skip over a designated number of registers in the backing
-   store, remembering every 64th position is for NAT.  */
-static __inline__ uint64_t
-ia64_rse_skip_regs (uint64_t addr, long num_regs)
-{
-  long delta = ia64_rse_slot_num(addr) + num_regs;
-
-  if (num_regs < 0)
-    delta -= 0x3e;
-  return addr + ((num_regs + delta/0x3f) << 3);
-}
-  
-/* Gdb ia64-libunwind-tdep callback function to convert from an ia64 gdb
-   register number to a libunwind register number.  */
-static int
-ia64_gdb2uw_regnum (int regnum)
-{
-  if (regnum == sp_regnum)
-    return UNW_IA64_SP;
-  else if (regnum == IA64_BSP_REGNUM)
-    return UNW_IA64_BSP;
-  else if ((unsigned) (regnum - IA64_GR0_REGNUM) < 128)
-    return UNW_IA64_GR + (regnum - IA64_GR0_REGNUM);
-  else if ((unsigned) (regnum - V32_REGNUM) < 95)
-    return UNW_IA64_GR + 32 + (regnum - V32_REGNUM);
-  else if ((unsigned) (regnum - IA64_FR0_REGNUM) < 128)
-    return UNW_IA64_FR + (regnum - IA64_FR0_REGNUM);
-  else if ((unsigned) (regnum - IA64_PR0_REGNUM) < 64)
-    return -1;
-  else if ((unsigned) (regnum - IA64_BR0_REGNUM) < 8)
-    return UNW_IA64_BR + (regnum - IA64_BR0_REGNUM);
-  else if (regnum == IA64_PR_REGNUM)
-    return UNW_IA64_PR;
-  else if (regnum == IA64_IP_REGNUM)
-    return UNW_REG_IP;
-  else if (regnum == IA64_CFM_REGNUM)
-    return UNW_IA64_CFM;
-  else if ((unsigned) (regnum - IA64_AR0_REGNUM) < 128)
-    return UNW_IA64_AR + (regnum - IA64_AR0_REGNUM);
-  else if ((unsigned) (regnum - IA64_NAT0_REGNUM) < 128)
-    return UNW_IA64_NAT + (regnum - IA64_NAT0_REGNUM);
-  else
-    return -1;
-}
-  
-/* Gdb ia64-libunwind-tdep callback function to convert from a libunwind
-   register number to a ia64 gdb register number.  */
-static int
-ia64_uw2gdb_regnum (int uw_regnum)
-{
-  if (uw_regnum == UNW_IA64_SP)
-    return sp_regnum;
-  else if (uw_regnum == UNW_IA64_BSP)
-    return IA64_BSP_REGNUM;
-  else if ((unsigned) (uw_regnum - UNW_IA64_GR) < 32)
-    return IA64_GR0_REGNUM + (uw_regnum - UNW_IA64_GR);
-  else if ((unsigned) (uw_regnum - UNW_IA64_GR) < 128)
-    return V32_REGNUM + (uw_regnum - (IA64_GR0_REGNUM + 32));
-  else if ((unsigned) (uw_regnum - UNW_IA64_FR) < 128)
-    return IA64_FR0_REGNUM + (uw_regnum - UNW_IA64_FR);
-  else if ((unsigned) (uw_regnum - UNW_IA64_BR) < 8)
-    return IA64_BR0_REGNUM + (uw_regnum - UNW_IA64_BR);
-  else if (uw_regnum == UNW_IA64_PR)
-    return IA64_PR_REGNUM;
-  else if (uw_regnum == UNW_REG_IP)
-    return IA64_IP_REGNUM;
-  else if (uw_regnum == UNW_IA64_CFM)
-    return IA64_CFM_REGNUM;
-  else if ((unsigned) (uw_regnum - UNW_IA64_AR) < 128)
-    return IA64_AR0_REGNUM + (uw_regnum - UNW_IA64_AR);
-  else if ((unsigned) (uw_regnum - UNW_IA64_NAT) < 128)
-    return IA64_NAT0_REGNUM + (uw_regnum - UNW_IA64_NAT);
-  else
-    return -1;
-}
-
-/* Gdb ia64-libunwind-tdep callback function to reveal if register is
-   a float register or not.  */
-static int
-ia64_is_fpreg (int uw_regnum)
-{
-  return unw_is_fpreg (uw_regnum);
-}
-
-/* Libunwind callback accessor function for general registers.  */
-static int
-ia64_access_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *val, 
-		 int write, void *arg)
-{
-  int regnum = ia64_uw2gdb_regnum (uw_regnum);
-  unw_word_t bsp, sof, cfm, psr, ip;
-  struct frame_info *this_frame = (frame_info *) arg;
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
-  
-  /* We never call any libunwind routines that need to write registers.  */
-  gdb_assert (!write);
-
-  switch (uw_regnum)
-    {
-      case UNW_REG_IP:
-	/* Libunwind expects to see the pc value which means the slot number
-	   from the psr must be merged with the ip word address.  */
-	ip = get_frame_register_unsigned (this_frame, IA64_IP_REGNUM);
-	psr = get_frame_register_unsigned (this_frame, IA64_PSR_REGNUM);
-	*val = ip | ((psr >> 41) & 0x3);
-	break;
- 
-      case UNW_IA64_AR_BSP:
-	/* Libunwind expects to see the beginning of the current
-	   register frame so we must account for the fact that
-	   ptrace() will return a value for bsp that points *after*
-	   the current register frame.  */
-	bsp = get_frame_register_unsigned (this_frame, IA64_BSP_REGNUM);
-	cfm = get_frame_register_unsigned (this_frame, IA64_CFM_REGNUM);
-	sof = tdep->size_of_register_frame (this_frame, cfm);
-	*val = ia64_rse_skip_regs (bsp, -sof);
-	break;
-
-      case UNW_IA64_AR_BSPSTORE:
-	/* Libunwind wants bspstore to be after the current register frame.
-	   This is what ptrace() and gdb treats as the regular bsp value.  */
-	*val = get_frame_register_unsigned (this_frame, IA64_BSP_REGNUM);
-	break;
-
-      default:
-	/* For all other registers, just unwind the value directly.  */
-	*val = get_frame_register_unsigned (this_frame, regnum);
-	break;
-    }
-      
-  if (gdbarch_debug >= 1)
-    gdb_printf (gdb_stdlog, 
-		"  access_reg: from cache: %4s=%s\n",
-		(((unsigned) regnum <= IA64_NAT127_REGNUM)
-		 ? ia64_register_names[regnum] : "r??"), 
-		paddress (gdbarch, *val));
-  return 0;
-}
-
-/* Libunwind callback accessor function for floating-point registers.  */
-static int
-ia64_access_fpreg (unw_addr_space_t as, unw_regnum_t uw_regnum,
-		   unw_fpreg_t *val, int write, void *arg)
-{
-  int regnum = ia64_uw2gdb_regnum (uw_regnum);
-  frame_info_ptr this_frame = (const frame_info_ptr &) arg;
-  
-  /* We never call any libunwind routines that need to write registers.  */
-  gdb_assert (!write);
-
-  get_frame_register (this_frame, regnum, (gdb_byte *) val);
-
-  return 0;
-}
-
-/* Libunwind callback accessor function for top-level rse registers.  */
-static int
-ia64_access_rse_reg (unw_addr_space_t as, unw_regnum_t uw_regnum,
-		     unw_word_t *val, int write, void *arg)
-{
-  int regnum = ia64_uw2gdb_regnum (uw_regnum);
-  unw_word_t bsp, sof, cfm, psr, ip;
-  struct regcache *regcache = (struct regcache *) arg;
-  struct gdbarch *gdbarch = regcache->arch ();
-  
-  /* We never call any libunwind routines that need to write registers.  */
-  gdb_assert (!write);
-
-  switch (uw_regnum)
-    {
-      case UNW_REG_IP:
-	/* Libunwind expects to see the pc value which means the slot number
-	   from the psr must be merged with the ip word address.  */
-	regcache_cooked_read_unsigned (regcache, IA64_IP_REGNUM, &ip);
-	regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr);
-	*val = ip | ((psr >> 41) & 0x3);
-	break;
-	  
-      case UNW_IA64_AR_BSP:
-	/* Libunwind expects to see the beginning of the current
-	   register frame so we must account for the fact that
-	   ptrace() will return a value for bsp that points *after*
-	   the current register frame.  */
-	regcache_cooked_read_unsigned (regcache, IA64_BSP_REGNUM, &bsp);
-	regcache_cooked_read_unsigned (regcache, IA64_CFM_REGNUM, &cfm);
-	sof = (cfm & 0x7f);
-	*val = ia64_rse_skip_regs (bsp, -sof);
-	break;
-	  
-      case UNW_IA64_AR_BSPSTORE:
-	/* Libunwind wants bspstore to be after the current register frame.
-	   This is what ptrace() and gdb treats as the regular bsp value.  */
-	regcache_cooked_read_unsigned (regcache, IA64_BSP_REGNUM, val);
-	break;
-
-      default:
-	/* For all other registers, just unwind the value directly.  */
-	regcache_cooked_read_unsigned (regcache, regnum, val);
-	break;
-    }
-      
-  if (gdbarch_debug >= 1)
-    gdb_printf (gdb_stdlog, 
-		"  access_rse_reg: from cache: %4s=%s\n",
-		(((unsigned) regnum <= IA64_NAT127_REGNUM)
-		 ? ia64_register_names[regnum] : "r??"), 
-		paddress (gdbarch, *val));
-
-  return 0;
-}
-
-/* Libunwind callback accessor function for top-level fp registers.  */
-static int
-ia64_access_rse_fpreg (unw_addr_space_t as, unw_regnum_t uw_regnum,
-		       unw_fpreg_t *val, int write, void *arg)
-{
-  int regnum = ia64_uw2gdb_regnum (uw_regnum);
-  struct regcache *regcache = (struct regcache *) arg;
-  
-  /* We never call any libunwind routines that need to write registers.  */
-  gdb_assert (!write);
-
-  regcache->cooked_read (regnum, (gdb_byte *) val);
-
-  return 0;
-}
-
-/* Libunwind callback accessor function for accessing memory.  */
-static int
-ia64_access_mem (unw_addr_space_t as,
-		 unw_word_t addr, unw_word_t *val,
-		 int write, void *arg)
-{
-  if (addr - KERNEL_START < ktab_size)
-    {
-      unw_word_t *laddr = (unw_word_t*) ((char *) ktab
-			  + (addr - KERNEL_START));
-		
-      if (write)
-	*laddr = *val; 
-      else 
-	*val = *laddr;
-      return 0;
-    }
-
-  /* XXX do we need to normalize byte-order here?  */
-  if (write)
-    return target_write_memory (addr, (gdb_byte *) val, sizeof (unw_word_t));
-  else
-    return target_read_memory (addr, (gdb_byte *) val, sizeof (unw_word_t));
-}
-
-/* Call low-level function to access the kernel unwind table.  */
-static std::optional<gdb::byte_vector>
-getunwind_table ()
-{
-  /* FIXME drow/2005-09-10: This code used to call
-     ia64_linux_xfer_unwind_table directly to fetch the unwind table
-     for the currently running ia64-linux kernel.  That data should
-     come from the core file and be accessed via the auxv vector; if
-     we want to preserve fall back to the running kernel's table, then
-     we should find a way to override the corefile layer's
-     xfer_partial method.  */
-
-  return target_read_alloc (current_inferior ()->top_target (),
-			    TARGET_OBJECT_UNWIND_TABLE, NULL);
-}
-
-/* Get the kernel unwind table.  */				 
-static int
-get_kernel_table (unw_word_t ip, unw_dyn_info_t *di)
-{
-  static struct ia64_table_entry *etab;
-
-  if (!ktab) 
-    {
-      ktab_buf = getunwind_table ();
-      if (!ktab_buf)
-	return -UNW_ENOINFO;
-
-      ktab = (struct ia64_table_entry *) ktab_buf->data ();
-      ktab_size = ktab_buf->size ();
-
-      for (etab = ktab; etab->start_offset; ++etab)
-	etab->info_offset += KERNEL_START;
-    }
-  
-  if (ip < ktab[0].start_offset || ip >= etab[-1].end_offset)
-    return -UNW_ENOINFO;
-  
-  di->format = UNW_INFO_FORMAT_TABLE;
-  di->gp = 0;
-  di->start_ip = ktab[0].start_offset;
-  di->end_ip = etab[-1].end_offset;
-  di->u.ti.name_ptr = (unw_word_t) "<kernel>";
-  di->u.ti.segbase = 0;
-  di->u.ti.table_len = ((char *) etab - (char *) ktab) / sizeof (unw_word_t);
-  di->u.ti.table_data = (unw_word_t *) ktab;
-  
-  if (gdbarch_debug >= 1)
-    gdb_printf (gdb_stdlog, "get_kernel_table: found table `%s': "
-		"segbase=%s, length=%s, gp=%s\n",
-		(char *) di->u.ti.name_ptr, 
-		hex_string (di->u.ti.segbase),
-		pulongest (di->u.ti.table_len), 
-		hex_string (di->gp));
-  return 0;
-}
-
-/* Find the unwind table entry for a specified address.  */
-static int
-ia64_find_unwind_table (struct objfile *objfile, unw_word_t ip,
-			unw_dyn_info_t *dip, void **buf)
-{
-  Elf_Internal_Phdr *phdr, *p_text = NULL, *p_unwind = NULL;
-  Elf_Internal_Ehdr *ehdr;
-  unw_word_t segbase = 0;
-  CORE_ADDR load_base;
-  bfd *bfd;
-  int i;
-
-  bfd = objfile->obfd;
-  
-  ehdr = elf_tdata (bfd)->elf_header;
-  phdr = elf_tdata (bfd)->phdr;
-
-  load_base = objfile->text_section_offset ();
-
-  for (i = 0; i < ehdr->e_phnum; ++i)
-    {
-      switch (phdr[i].p_type)
-	{
-	case PT_LOAD:
-	  if ((unw_word_t) (ip - load_base - phdr[i].p_vaddr)
-	      < phdr[i].p_memsz)
-	    p_text = phdr + i;
-	  break;
-
-	case PT_IA_64_UNWIND:
-	  p_unwind = phdr + i;
-	  break;
-
-	default:
-	  break;
-	}
-    }
-
-  if (!p_text || !p_unwind)
-    return -UNW_ENOINFO;
-
-  /* Verify that the segment that contains the IP also contains
-     the static unwind table.  If not, we may be in the Linux kernel's
-     DSO gate page in which case the unwind table is another segment.
-     Otherwise, we are dealing with runtime-generated code, for which we 
-     have no info here.  */
-  segbase = p_text->p_vaddr + load_base;
-
-  if ((p_unwind->p_vaddr - p_text->p_vaddr) >= p_text->p_memsz)
-    {
-      int ok = 0;
-      for (i = 0; i < ehdr->e_phnum; ++i)
-	{
-	  if (phdr[i].p_type == PT_LOAD
-	      && (p_unwind->p_vaddr - phdr[i].p_vaddr) < phdr[i].p_memsz)
-	    {
-	      ok = 1;
-	      /* Get the segbase from the section containing the
-		 libunwind table.  */
-	      segbase = phdr[i].p_vaddr + load_base;
-	    }
-	}
-      if (!ok)
-	return -UNW_ENOINFO;
-    }
-
-  dip->start_ip = p_text->p_vaddr + load_base;
-  dip->end_ip = dip->start_ip + p_text->p_memsz;
-  dip->gp = ia64_find_global_pointer (objfile->arch (), ip);
-  dip->format = UNW_INFO_FORMAT_REMOTE_TABLE;
-  dip->u.rti.name_ptr = (unw_word_t) bfd_get_filename (bfd);
-  dip->u.rti.segbase = segbase;
-  dip->u.rti.table_len = p_unwind->p_memsz / sizeof (unw_word_t);
-  dip->u.rti.table_data = p_unwind->p_vaddr + load_base;
-
-  return 0;
-}
-
-/* Libunwind callback accessor function to acquire procedure unwind-info.  */
-static int
-ia64_find_proc_info_x (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
-		       int need_unwind_info, void *arg)
-{
-  struct obj_section *sec = find_pc_section (ip);
-  unw_dyn_info_t di;
-  int ret;
-  void *buf = NULL;
-
-  if (!sec)
-    {
-      /* XXX This only works if the host and the target architecture are
-	 both ia64 and if the have (more or less) the same kernel
-	 version.  */
-      if (get_kernel_table (ip, &di) < 0)
-	return -UNW_ENOINFO;
-
-      if (gdbarch_debug >= 1)
-	gdb_printf (gdb_stdlog, "ia64_find_proc_info_x: %s -> "
-		    "(name=`%s',segbase=%s,start=%s,end=%s,gp=%s,"
-		    "length=%s,data=%s)\n",
-		    hex_string (ip), (char *)di.u.ti.name_ptr,
-		    hex_string (di.u.ti.segbase),
-		    hex_string (di.start_ip), hex_string (di.end_ip),
-		    hex_string (di.gp),
-		    pulongest (di.u.ti.table_len), 
-		    hex_string ((CORE_ADDR)di.u.ti.table_data));
-    }
-  else
-    {
-      ret = ia64_find_unwind_table (sec->objfile, ip, &di, &buf);
-      if (ret < 0)
-	return ret;
-
-      if (gdbarch_debug >= 1)
-	gdb_printf (gdb_stdlog, "ia64_find_proc_info_x: %s -> "
-		    "(name=`%s',segbase=%s,start=%s,end=%s,gp=%s,"
-		    "length=%s,data=%s)\n",
-		    hex_string (ip), (char *)di.u.rti.name_ptr,
-		    hex_string (di.u.rti.segbase),
-		    hex_string (di.start_ip), hex_string (di.end_ip),
-		    hex_string (di.gp),
-		    pulongest (di.u.rti.table_len), 
-		    hex_string (di.u.rti.table_data));
-    }
-
-  ret = libunwind_search_unwind_table (&as, ip, &di, pi, need_unwind_info,
-				       arg);
-
-  /* We no longer need the dyn info storage so free it.  */
-  xfree (buf);
-
-  return ret;
-}
-
-/* Libunwind callback accessor function for cleanup.  */
-static void
-ia64_put_unwind_info (unw_addr_space_t as,
-		      unw_proc_info_t *pip, void *arg)
-{
-  /* Nothing required for now.  */
-}
-
-/* Libunwind callback accessor function to get head of the dynamic 
-   unwind-info registration list.  */ 
-static int
-ia64_get_dyn_info_list (unw_addr_space_t as,
-			unw_word_t *dilap, void *arg)
-{
-  struct obj_section *text_sec;
-  unw_word_t ip, addr;
-  unw_dyn_info_t di;
-  int ret;
-
-  if (!libunwind_is_initialized ())
-    return -UNW_ENOINFO;
-
-  for (objfile *objfile : current_program_space->objfiles ())
-    {
-      void *buf = NULL;
-
-      text_sec = objfile->sections + SECT_OFF_TEXT (objfile);
-      ip = text_sec->addr ();
-      ret = ia64_find_unwind_table (objfile, ip, &di, &buf);
-      if (ret >= 0)
-	{
-	  addr = libunwind_find_dyn_list (as, &di, arg);
-	  /* We no longer need the dyn info storage so free it.  */
-	  xfree (buf);
-
-	  if (addr)
-	    {
-	      if (gdbarch_debug >= 1)
-		gdb_printf (gdb_stdlog,
-			    "dynamic unwind table in objfile %s "
-			    "at %s (gp=%s)\n",
-			    bfd_get_filename (objfile->obfd),
-			    hex_string (addr), hex_string (di.gp));
-	      *dilap = addr;
-	      return 0;
-	    }
-	}
-    }
-  return -UNW_ENOINFO;
-}
-
-
-/* Frame interface functions for libunwind.  */
-
-static void
-ia64_libunwind_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
-			      struct frame_id *this_id)
-{
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct frame_id id = outer_frame_id;
-  gdb_byte buf[8];
-  CORE_ADDR bsp;
-
-  libunwind_frame_this_id (this_frame, this_cache, &id);
-  if (id == outer_frame_id)
-    {
-      (*this_id) = outer_frame_id;
-      return;
-    }
-
-  /* We must add the bsp as the special address for frame comparison 
-     purposes.  */
-  get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-  bsp = extract_unsigned_integer (buf, 8, byte_order);
-
-  (*this_id) = frame_id_build_special (id.stack_addr, id.code_addr, bsp);
-
-  if (gdbarch_debug >= 1)
-    gdb_printf (gdb_stdlog,
-		"libunwind frame id: code %s, stack %s, "
-		"special %s, this_frame %s\n",
-		paddress (gdbarch, id.code_addr),
-		paddress (gdbarch, id.stack_addr),
-		paddress (gdbarch, bsp),
-		host_address_to_string (this_frame));
-}
-
-static struct value *
-ia64_libunwind_frame_prev_register (const frame_info_ptr &this_frame,
-				    void **this_cache, int regnum)
-{
-  int reg = regnum;
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct value *val;
-
-  if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
-    reg = IA64_PR_REGNUM;
-  else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
-    reg = IA64_UNAT_REGNUM;
-
-  /* Let libunwind do most of the work.  */
-  val = libunwind_frame_prev_register (this_frame, this_cache, reg);
-
-  if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
-    {
-      ULONGEST prN_val;
-
-      if (VP16_REGNUM <= regnum && regnum <= VP63_REGNUM)
-	{
-	  int rrb_pr = 0;
-	  ULONGEST cfm;
-
-	  /* Fetch predicate register rename base from current frame
-	     marker for this frame.  */
-	  cfm = get_frame_register_unsigned (this_frame, IA64_CFM_REGNUM);
-	  rrb_pr = (cfm >> 32) & 0x3f;
-	  
-	  /* Adjust the register number to account for register rotation.  */
-	  regnum = VP16_REGNUM + ((regnum - VP16_REGNUM) + rrb_pr) % 48;
-	}
-      prN_val = extract_bit_field (val->contents_all ().data (),
-				   regnum - VP0_REGNUM, 1);
-      return frame_unwind_got_constant (this_frame, regnum, prN_val);
-    }
-
-  else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
-    {
-      ULONGEST unatN_val;
-
-      unatN_val = extract_bit_field (val->contents_all ().data (),
-				     regnum - IA64_NAT0_REGNUM, 1);
-      return frame_unwind_got_constant (this_frame, regnum, unatN_val);
-    }
-
-  else if (regnum == IA64_BSP_REGNUM)
-    {
-      struct value *cfm_val;
-      CORE_ADDR prev_bsp, prev_cfm;
-
-      /* We want to calculate the previous bsp as the end of the previous
-	 register stack frame.  This corresponds to what the hardware bsp
-	 register will be if we pop the frame back which is why we might
-	 have been called.  We know that libunwind will pass us back the
-	 beginning of the current frame so we should just add sof to it.  */
-      prev_bsp = extract_unsigned_integer (val->contents_all ().data (),
-					   8, byte_order);
-      cfm_val = libunwind_frame_prev_register (this_frame, this_cache,
-					       IA64_CFM_REGNUM);
-      prev_cfm = extract_unsigned_integer (cfm_val->contents_all ().data (),
-					   8, byte_order);
-      prev_bsp = rse_address_add (prev_bsp, (prev_cfm & 0x7f));
-
-      return frame_unwind_got_constant (this_frame, regnum, prev_bsp);
-    }
-  else
-    return val;
-}
-
-static int
-ia64_libunwind_frame_sniffer (const struct frame_unwind *self,
-			      const frame_info_ptr &this_frame,
-			      void **this_cache)
-{
-  if (libunwind_is_initialized ()
-      && libunwind_frame_sniffer (self, this_frame, this_cache))
-    return 1;
-
-  return 0;
-}
-
-static const struct frame_unwind ia64_libunwind_frame_unwind =
-{
-  "ia64 libunwind",
-  NORMAL_FRAME,
-  default_frame_unwind_stop_reason,
-  ia64_libunwind_frame_this_id,
-  ia64_libunwind_frame_prev_register,
-  NULL,
-  ia64_libunwind_frame_sniffer,
-  libunwind_frame_dealloc_cache
-};
-
-static void
-ia64_libunwind_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
-				       void **this_cache,
-				       struct frame_id *this_id)
-{
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  gdb_byte buf[8];
-  CORE_ADDR bsp;
-  struct frame_id id = outer_frame_id;
-
-  libunwind_frame_this_id (this_frame, this_cache, &id);
-  if (id == outer_frame_id)
-    {
-      (*this_id) = outer_frame_id;
-      return;
-    }
-
-  /* We must add the bsp as the special address for frame comparison 
-     purposes.  */
-  get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-  bsp = extract_unsigned_integer (buf, 8, byte_order);
-
-  /* For a sigtramp frame, we don't make the check for previous ip being 0.  */
-  (*this_id) = frame_id_build_special (id.stack_addr, id.code_addr, bsp);
-
-  if (gdbarch_debug >= 1)
-    gdb_printf (gdb_stdlog,
-		"libunwind sigtramp frame id: code %s, "
-		"stack %s, special %s, this_frame %s\n",
-		paddress (gdbarch, id.code_addr),
-		paddress (gdbarch, id.stack_addr),
-		paddress (gdbarch, bsp),
-		host_address_to_string (this_frame));
-}
-
-static struct value *
-ia64_libunwind_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
-					     void **this_cache, int regnum)
-{
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct value *prev_ip_val;
-  CORE_ADDR prev_ip;
-
-  /* If the previous frame pc value is 0, then we want to use the SIGCONTEXT
-     method of getting previous registers.  */
-  prev_ip_val = libunwind_frame_prev_register (this_frame, this_cache,
-					       IA64_IP_REGNUM);
-  prev_ip = extract_unsigned_integer (prev_ip_val->contents_all ().data (),
-				      8, byte_order);
-
-  if (prev_ip == 0)
-    {
-      void *tmp_cache = NULL;
-      return ia64_sigtramp_frame_prev_register (this_frame, &tmp_cache,
-						regnum);
-    }
-  else
-    return ia64_libunwind_frame_prev_register (this_frame, this_cache, regnum);
-}
-
-static int
-ia64_libunwind_sigtramp_frame_sniffer (const struct frame_unwind *self,
-				       const frame_info_ptr &this_frame,
-				       void **this_cache)
-{
-  if (libunwind_is_initialized ())
-    {
-      if (libunwind_sigtramp_frame_sniffer (self, this_frame, this_cache))
-	return 1;
-      return 0;
-    }
-  else
-    return ia64_sigtramp_frame_sniffer (self, this_frame, this_cache);
-}
-
-static const struct frame_unwind ia64_libunwind_sigtramp_frame_unwind =
-{
-  "ia64 libunwind sigtramp",
-  SIGTRAMP_FRAME,
-  default_frame_unwind_stop_reason,
-  ia64_libunwind_sigtramp_frame_this_id,
-  ia64_libunwind_sigtramp_frame_prev_register,
-  NULL,
-  ia64_libunwind_sigtramp_frame_sniffer
-};
-
-/* Set of libunwind callback acccessor functions.  */
-unw_accessors_t ia64_unw_accessors =
-{
-  ia64_find_proc_info_x,
-  ia64_put_unwind_info,
-  ia64_get_dyn_info_list,
-  ia64_access_mem,
-  ia64_access_reg,
-  ia64_access_fpreg,
-  /* resume */
-  /* get_proc_name */
-};
-
-/* Set of special libunwind callback acccessor functions specific for accessing
-   the rse registers.  At the top of the stack, we want libunwind to figure out
-   how to read r32 - r127.  Though usually they are found sequentially in
-   memory starting from $bof, this is not always true.  */
-unw_accessors_t ia64_unw_rse_accessors =
-{
-  ia64_find_proc_info_x,
-  ia64_put_unwind_info,
-  ia64_get_dyn_info_list,
-  ia64_access_mem,
-  ia64_access_rse_reg,
-  ia64_access_rse_fpreg,
-  /* resume */
-  /* get_proc_name */
-};
-
-/* Set of ia64-libunwind-tdep gdb callbacks and data for generic
-   ia64-libunwind-tdep code to use.  */
-struct libunwind_descr ia64_libunwind_descr =
-{
-  ia64_gdb2uw_regnum, 
-  ia64_uw2gdb_regnum, 
-  ia64_is_fpreg, 
-  &ia64_unw_accessors,
-  &ia64_unw_rse_accessors,
-};
-
-#endif /* HAVE_LIBUNWIND_IA64_H  */
-
-static int
-ia64_use_struct_convention (struct type *type)
-{
-  struct type *float_elt_type;
-
-  /* Don't use the struct convention for anything but structure,
-     union, or array types.  */
-  if (!(type->code () == TYPE_CODE_STRUCT
-	|| type->code () == TYPE_CODE_UNION
-	|| type->code () == TYPE_CODE_ARRAY))
-    return 0;
-
-  /* HFAs are structures (or arrays) consisting entirely of floating
-     point values of the same length.  Up to 8 of these are returned
-     in registers.  Don't use the struct convention when this is the
-     case.  */
-  float_elt_type = is_float_or_hfa_type (type);
-  if (float_elt_type != NULL
-      && type->length () / float_elt_type->length () <= 8)
-    return 0;
-
-  /* Other structs of length 32 or less are returned in r8-r11.
-     Don't use the struct convention for those either.  */
-  return type->length () > 32;
-}
-
-/* Return non-zero if TYPE is a structure or union type.  */
-
-static int
-ia64_struct_type_p (const struct type *type)
-{
-  return (type->code () == TYPE_CODE_STRUCT
-	  || type->code () == TYPE_CODE_UNION);
-}
-
-static void
-ia64_extract_return_value (struct type *type, struct regcache *regcache,
-			   gdb_byte *valbuf)
-{
-  struct gdbarch *gdbarch = regcache->arch ();
-  struct type *float_elt_type;
-
-  float_elt_type = is_float_or_hfa_type (type);
-  if (float_elt_type != NULL)
-    {
-      gdb_byte from[IA64_FP_REGISTER_SIZE];
-      int offset = 0;
-      int regnum = IA64_FR8_REGNUM;
-      int n = type->length () / float_elt_type->length ();
-
-      while (n-- > 0)
-	{
-	  regcache->cooked_read (regnum, from);
-	  target_float_convert (from, ia64_ext_type (gdbarch),
-				valbuf + offset, float_elt_type);
-	  offset += float_elt_type->length ();
-	  regnum++;
-	}
-    }
-  else if (!ia64_struct_type_p (type) && type->length () < 8)
-    {
-      /* This is an integral value, and its size is less than 8 bytes.
-	 These values are LSB-aligned, so extract the relevant bytes,
-	 and copy them into VALBUF.  */
-      /* brobecker/2005-12-30: Actually, all integral values are LSB aligned,
-	 so I suppose we should also add handling here for integral values
-	 whose size is greater than 8.  But I wasn't able to create such
-	 a type, neither in C nor in Ada, so not worrying about these yet.  */
-      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-      ULONGEST val;
-
-      regcache_cooked_read_unsigned (regcache, IA64_GR8_REGNUM, &val);
-      store_unsigned_integer (valbuf, type->length (), byte_order, val);
-    }
-  else
-    {
-      ULONGEST val;
-      int offset = 0;
-      int regnum = IA64_GR8_REGNUM;
-      int reglen = register_type (gdbarch, IA64_GR8_REGNUM)->length ();
-      int n = type->length () / reglen;
-      int m = type->length () % reglen;
-
-      while (n-- > 0)
-	{
-	  ULONGEST regval;
-	  regcache_cooked_read_unsigned (regcache, regnum, &regval);
-	  memcpy ((char *)valbuf + offset, &regval, reglen);
-	  offset += reglen;
-	  regnum++;
-	}
-
-      if (m)
-	{
-	  regcache_cooked_read_unsigned (regcache, regnum, &val);
-	  memcpy ((char *)valbuf + offset, &val, m);
-	}
-    }
-}
-
-static void
-ia64_store_return_value (struct type *type, struct regcache *regcache, 
-			 const gdb_byte *valbuf)
-{
-  struct gdbarch *gdbarch = regcache->arch ();
-  struct type *float_elt_type;
-
-  float_elt_type = is_float_or_hfa_type (type);
-  if (float_elt_type != NULL)
-    {
-      gdb_byte to[IA64_FP_REGISTER_SIZE];
-      int offset = 0;
-      int regnum = IA64_FR8_REGNUM;
-      int n = type->length () / float_elt_type->length ();
-
-      while (n-- > 0)
-	{
-	  target_float_convert (valbuf + offset, float_elt_type,
-				to, ia64_ext_type (gdbarch));
-	  regcache->cooked_write (regnum, to);
-	  offset += float_elt_type->length ();
-	  regnum++;
-	}
-    }
-  else
-    {
-      int offset = 0;
-      int regnum = IA64_GR8_REGNUM;
-      int reglen = register_type (gdbarch, IA64_GR8_REGNUM)->length ();
-      int n = type->length () / reglen;
-      int m = type->length () % reglen;
-
-      while (n-- > 0)
-	{
-	  ULONGEST val;
-	  memcpy (&val, (char *)valbuf + offset, reglen);
-	  regcache_cooked_write_unsigned (regcache, regnum, val);
-	  offset += reglen;
-	  regnum++;
-	}
-
-      if (m)
-	{
-	  ULONGEST val;
-	  memcpy (&val, (char *)valbuf + offset, m);
-	  regcache_cooked_write_unsigned (regcache, regnum, val);
-	}
-    }
-}
-  
-static enum return_value_convention
-ia64_return_value (struct gdbarch *gdbarch, struct value *function,
-		   struct type *valtype, struct regcache *regcache,
-		   gdb_byte *readbuf, const gdb_byte *writebuf)
-{
-  int struct_return = ia64_use_struct_convention (valtype);
-
-  if (writebuf != NULL)
-    {
-      gdb_assert (!struct_return);
-      ia64_store_return_value (valtype, regcache, writebuf);
-    }
-
-  if (readbuf != NULL)
-    {
-      gdb_assert (!struct_return);
-      ia64_extract_return_value (valtype, regcache, readbuf);
-    }
-
-  if (struct_return)
-    return RETURN_VALUE_STRUCT_CONVENTION;
-  else
-    return RETURN_VALUE_REGISTER_CONVENTION;
-}
-
-static int
-is_float_or_hfa_type_recurse (struct type *t, struct type **etp)
-{
-  switch (t->code ())
-    {
-    case TYPE_CODE_FLT:
-      if (*etp)
-	return (*etp)->length () == t->length ();
-      else
-	{
-	  *etp = t;
-	  return 1;
-	}
-      break;
-    case TYPE_CODE_ARRAY:
-      return
-	is_float_or_hfa_type_recurse (check_typedef (t->target_type ()),
-				      etp);
-      break;
-    case TYPE_CODE_STRUCT:
-      {
-	int i;
-
-	for (i = 0; i < t->num_fields (); i++)
-	  if (!is_float_or_hfa_type_recurse
-	      (check_typedef (t->field (i).type ()), etp))
-	    return 0;
-	return 1;
-      }
-      break;
-    default:
-      break;
-    }
-
-  return 0;
-}
-
-/* Determine if the given type is one of the floating point types or
-   and HFA (which is a struct, array, or combination thereof whose
-   bottom-most elements are all of the same floating point type).  */
-
-static struct type *
-is_float_or_hfa_type (struct type *t)
-{
-  struct type *et = 0;
-
-  return is_float_or_hfa_type_recurse (t, &et) ? et : 0;
-}
-
-
-/* Return 1 if the alignment of T is such that the next even slot
-   should be used.  Return 0, if the next available slot should
-   be used.  (See section 8.5.1 of the IA-64 Software Conventions
-   and Runtime manual).  */
-
-static int
-slot_alignment_is_next_even (struct type *t)
-{
-  switch (t->code ())
-    {
-    case TYPE_CODE_INT:
-    case TYPE_CODE_FLT:
-      if (t->length () > 8)
-	return 1;
-      else
-	return 0;
-    case TYPE_CODE_ARRAY:
-      return
-	slot_alignment_is_next_even (check_typedef (t->target_type ()));
-    case TYPE_CODE_STRUCT:
-      {
-	int i;
-
-	for (i = 0; i < t->num_fields (); i++)
-	  if (slot_alignment_is_next_even
-	      (check_typedef (t->field (i).type ())))
-	    return 1;
-	return 0;
-      }
-    default:
-      return 0;
-    }
-}
-
-/* Attempt to find (and return) the global pointer for the given
-   function.
-
-   This is a rather nasty bit of code searchs for the .dynamic section
-   in the objfile corresponding to the pc of the function we're trying
-   to call.  Once it finds the addresses at which the .dynamic section
-   lives in the child process, it scans the Elf64_Dyn entries for a
-   DT_PLTGOT tag.  If it finds one of these, the corresponding
-   d_un.d_ptr value is the global pointer.  */
-
-static CORE_ADDR
-ia64_find_global_pointer_from_dynamic_section (struct gdbarch *gdbarch,
-					       CORE_ADDR faddr)
-{
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct obj_section *faddr_sect;
-     
-  faddr_sect = find_pc_section (faddr);
-  if (faddr_sect != NULL)
-    {
-      for (obj_section *osect : faddr_sect->objfile->sections ())
-	{
-	  if (strcmp (osect->the_bfd_section->name, ".dynamic") == 0)
-	    {
-	      CORE_ADDR addr = osect->addr ();
-	      CORE_ADDR endaddr = osect->endaddr ();
-
-	      while (addr < endaddr)
-		{
-		  int status;
-		  LONGEST tag;
-		  gdb_byte buf[8];
-
-		  status = target_read_memory (addr, buf, sizeof (buf));
-		  if (status != 0)
-		    break;
-		  tag = extract_signed_integer (buf, byte_order);
-
-		  if (tag == DT_PLTGOT)
-		    {
-		      CORE_ADDR global_pointer;
-
-		      status = target_read_memory (addr + 8, buf,
-						   sizeof (buf));
-		      if (status != 0)
-			break;
-		      global_pointer
-			= extract_unsigned_integer (buf, sizeof (buf),
-						    byte_order);
-
-		      /* The payoff...  */
-		      return global_pointer;
-		    }
-
-		  if (tag == DT_NULL)
-		    break;
-
-		  addr += 16;
-		}
-
-	      break;
-	    }
-	}
-    }
-  return 0;
-}
-
-/* Attempt to find (and return) the global pointer for the given
-   function.  We first try the find_global_pointer_from_solib routine
-   from the gdbarch tdep vector, if provided.  And if that does not
-   work, then we try ia64_find_global_pointer_from_dynamic_section.  */
-
-static CORE_ADDR
-ia64_find_global_pointer (struct gdbarch *gdbarch, CORE_ADDR faddr)
-{
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
-  CORE_ADDR addr = 0;
-
-  if (tdep->find_global_pointer_from_solib)
-    addr = tdep->find_global_pointer_from_solib (gdbarch, faddr);
-  if (addr == 0)
-    addr = ia64_find_global_pointer_from_dynamic_section (gdbarch, faddr);
-  return addr;
-}
-
-/* Given a function's address, attempt to find (and return) the
-   corresponding (canonical) function descriptor.  Return 0 if
-   not found.  */
-static CORE_ADDR
-find_extant_func_descr (struct gdbarch *gdbarch, CORE_ADDR faddr)
-{
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct obj_section *faddr_sect;
-
-  /* Return early if faddr is already a function descriptor.  */
-  faddr_sect = find_pc_section (faddr);
-  if (faddr_sect && strcmp (faddr_sect->the_bfd_section->name, ".opd") == 0)
-    return faddr;
-
-  if (faddr_sect != NULL)
-    {
-      for (obj_section *osect : faddr_sect->objfile->sections ())
-	{
-	  if (strcmp (osect->the_bfd_section->name, ".opd") == 0)
-	    {
-	      CORE_ADDR addr = osect->addr ();
-	      CORE_ADDR endaddr = osect->endaddr ();
-
-	      while (addr < endaddr)
-		{
-		  int status;
-		  LONGEST faddr2;
-		  gdb_byte buf[8];
-
-		  status = target_read_memory (addr, buf, sizeof (buf));
-		  if (status != 0)
-		    break;
-		  faddr2 = extract_signed_integer (buf, byte_order);
-
-		  if (faddr == faddr2)
-		    return addr;
-
-		  addr += 16;
-		}
-
-	      break;
-	    }
-	}
-    }
-  return 0;
-}
-
-/* Attempt to find a function descriptor corresponding to the
-   given address.  If none is found, construct one on the
-   stack using the address at fdaptr.  */
-
-static CORE_ADDR
-find_func_descr (struct regcache *regcache, CORE_ADDR faddr, CORE_ADDR *fdaptr)
-{
-  struct gdbarch *gdbarch = regcache->arch ();
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  CORE_ADDR fdesc;
-
-  fdesc = find_extant_func_descr (gdbarch, faddr);
-
-  if (fdesc == 0)
-    {
-      ULONGEST global_pointer;
-      gdb_byte buf[16];
-
-      fdesc = *fdaptr;
-      *fdaptr += 16;
-
-      global_pointer = ia64_find_global_pointer (gdbarch, faddr);
-
-      if (global_pointer == 0)
-	regcache_cooked_read_unsigned (regcache,
-				       IA64_GR1_REGNUM, &global_pointer);
-
-      store_unsigned_integer (buf, 8, byte_order, faddr);
-      store_unsigned_integer (buf + 8, 8, byte_order, global_pointer);
-
-      write_memory (fdesc, buf, 16);
-    }
-
-  return fdesc; 
-}
-
-/* Use the following routine when printing out function pointers
-   so the user can see the function address rather than just the
-   function descriptor.  */
-static CORE_ADDR
-ia64_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
-				 struct target_ops *targ)
-{
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct obj_section *s;
-  gdb_byte buf[8];
-
-  s = find_pc_section (addr);
-
-  /* check if ADDR points to a function descriptor.  */
-  if (s && strcmp (s->the_bfd_section->name, ".opd") == 0)
-    return read_memory_unsigned_integer (addr, 8, byte_order);
-
-  /* Normally, functions live inside a section that is executable.
-     So, if ADDR points to a non-executable section, then treat it
-     as a function descriptor and return the target address iff
-     the target address itself points to a section that is executable.
-     Check first the memory of the whole length of 8 bytes is readable.  */
-  if (s && (s->the_bfd_section->flags & SEC_CODE) == 0
-      && target_read_memory (addr, buf, 8) == 0)
-    {
-      CORE_ADDR pc = extract_unsigned_integer (buf, 8, byte_order);
-      struct obj_section *pc_section = find_pc_section (pc);
-
-      if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE))
-	return pc;
-    }
-
-  /* There are also descriptors embedded in vtables.  */
-  if (s)
-    {
-      struct bound_minimal_symbol minsym;
-
-      minsym = lookup_minimal_symbol_by_pc (addr);
-
-      if (minsym.minsym
-	  && is_vtable_name (minsym.minsym->linkage_name ()))
-	return read_memory_unsigned_integer (addr, 8, byte_order);
-    }
-
-  return addr;
-}
-
-static CORE_ADDR
-ia64_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
-{
-  return sp & ~0xfLL;
-}
-
-/* The default "allocate_new_rse_frame" ia64_infcall_ops routine for ia64.  */
-
-static void
-ia64_allocate_new_rse_frame (struct regcache *regcache, ULONGEST bsp, int sof)
-{
-  ULONGEST cfm, pfs, new_bsp;
-
-  regcache_cooked_read_unsigned (regcache, IA64_CFM_REGNUM, &cfm);
-
-  new_bsp = rse_address_add (bsp, sof);
-  regcache_cooked_write_unsigned (regcache, IA64_BSP_REGNUM, new_bsp);
-
-  regcache_cooked_read_unsigned (regcache, IA64_PFS_REGNUM, &pfs);
-  pfs &= 0xc000000000000000LL;
-  pfs |= (cfm & 0xffffffffffffLL);
-  regcache_cooked_write_unsigned (regcache, IA64_PFS_REGNUM, pfs);
-
-  cfm &= 0xc000000000000000LL;
-  cfm |= sof;
-  regcache_cooked_write_unsigned (regcache, IA64_CFM_REGNUM, cfm);
-}
-
-/* The default "store_argument_in_slot" ia64_infcall_ops routine for
-   ia64.  */
-
-static void
-ia64_store_argument_in_slot (struct regcache *regcache, CORE_ADDR bsp,
-			     int slotnum, gdb_byte *buf)
-{
-  write_memory (rse_address_add (bsp, slotnum), buf, 8);
-}
-
-/* The default "set_function_addr" ia64_infcall_ops routine for ia64.  */
-
-static void
-ia64_set_function_addr (struct regcache *regcache, CORE_ADDR func_addr)
-{
-  /* Nothing needed.  */
-}
-
-static CORE_ADDR
-ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
-		      struct regcache *regcache, CORE_ADDR bp_addr,
-		      int nargs, struct value **args, CORE_ADDR sp,
-		      function_call_return_method return_method,
-		      CORE_ADDR struct_addr)
-{
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int argno;
-  struct value *arg;
-  struct type *type;
-  int len, argoffset;
-  int nslots, rseslots, memslots, slotnum, nfuncargs;
-  int floatreg;
-  ULONGEST bsp;
-  CORE_ADDR funcdescaddr, global_pointer;
-  CORE_ADDR func_addr = find_function_addr (function, NULL);
-
-  nslots = 0;
-  nfuncargs = 0;
-  /* Count the number of slots needed for the arguments.  */
-  for (argno = 0; argno < nargs; argno++)
-    {
-      arg = args[argno];
-      type = check_typedef (arg->type ());
-      len = type->length ();
-
-      if ((nslots & 1) && slot_alignment_is_next_even (type))
-	nslots++;
-
-      if (type->code () == TYPE_CODE_FUNC)
-	nfuncargs++;
-
-      nslots += (len + 7) / 8;
-    }
-
-  /* Divvy up the slots between the RSE and the memory stack.  */
-  rseslots = (nslots > 8) ? 8 : nslots;
-  memslots = nslots - rseslots;
-
-  /* Allocate a new RSE frame.  */
-  regcache_cooked_read_unsigned (regcache, IA64_BSP_REGNUM, &bsp);
-  tdep->infcall_ops.allocate_new_rse_frame (regcache, bsp, rseslots);
-  
-  /* We will attempt to find function descriptors in the .opd segment,
-     but if we can't we'll construct them ourselves.  That being the
-     case, we'll need to reserve space on the stack for them.  */
-  funcdescaddr = sp - nfuncargs * 16;
-  funcdescaddr &= ~0xfLL;
-
-  /* Adjust the stack pointer to it's new value.  The calling conventions
-     require us to have 16 bytes of scratch, plus whatever space is
-     necessary for the memory slots and our function descriptors.  */
-  sp = sp - 16 - (memslots + nfuncargs) * 8;
-  sp &= ~0xfLL;				/* Maintain 16 byte alignment.  */
-
-  /* Place the arguments where they belong.  The arguments will be
-     either placed in the RSE backing store or on the memory stack.
-     In addition, floating point arguments or HFAs are placed in
-     floating point registers.  */
-  slotnum = 0;
-  floatreg = IA64_FR8_REGNUM;
-  for (argno = 0; argno < nargs; argno++)
-    {
-      struct type *float_elt_type;
-
-      arg = args[argno];
-      type = check_typedef (arg->type ());
-      len = type->length ();
-
-      /* Special handling for function parameters.  */
-      if (len == 8
-	  && type->code () == TYPE_CODE_PTR
-	  && type->target_type ()->code () == TYPE_CODE_FUNC)
-	{
-	  gdb_byte val_buf[8];
-	  ULONGEST faddr = extract_unsigned_integer
-	    (arg->contents ().data (), 8, byte_order);
-	  store_unsigned_integer (val_buf, 8, byte_order,
-				  find_func_descr (regcache, faddr,
-						   &funcdescaddr));
-	  if (slotnum < rseslots)
-	    tdep->infcall_ops.store_argument_in_slot (regcache, bsp,
-						      slotnum, val_buf);
-	  else
-	    write_memory (sp + 16 + 8 * (slotnum - rseslots), val_buf, 8);
-	  slotnum++;
-	  continue;
-	}
-
-      /* Normal slots.  */
-
-      /* Skip odd slot if necessary...  */
-      if ((slotnum & 1) && slot_alignment_is_next_even (type))
-	slotnum++;
-
-      argoffset = 0;
-      while (len > 0)
-	{
-	  gdb_byte val_buf[8];
-
-	  memset (val_buf, 0, 8);
-	  if (!ia64_struct_type_p (type) && len < 8)
-	    {
-	      /* Integral types are LSB-aligned, so we have to be careful
-		 to insert the argument on the correct side of the buffer.
-		 This is why we use store_unsigned_integer.  */
-	      store_unsigned_integer
-		(val_buf, 8, byte_order,
-		 extract_unsigned_integer (arg->contents ().data (), len,
-					   byte_order));
-	    }
-	  else
-	    {
-	      /* This is either an 8bit integral type, or an aggregate.
-		 For 8bit integral type, there is no problem, we just
-		 copy the value over.
-
-		 For aggregates, the only potentially tricky portion
-		 is to write the last one if it is less than 8 bytes.
-		 In this case, the data is Byte0-aligned.  Happy news,
-		 this means that we don't need to differentiate the
-		 handling of 8byte blocks and less-than-8bytes blocks.  */
-	      memcpy (val_buf, arg->contents ().data () + argoffset,
-		      (len > 8) ? 8 : len);
-	    }
-
-	  if (slotnum < rseslots)
-	    tdep->infcall_ops.store_argument_in_slot (regcache, bsp,
-						      slotnum, val_buf);
-	  else
-	    write_memory (sp + 16 + 8 * (slotnum - rseslots), val_buf, 8);
-
-	  argoffset += 8;
-	  len -= 8;
-	  slotnum++;
-	}
-
-      /* Handle floating point types (including HFAs).  */
-      float_elt_type = is_float_or_hfa_type (type);
-      if (float_elt_type != NULL)
-	{
-	  argoffset = 0;
-	  len = type->length ();
-	  while (len > 0 && floatreg < IA64_FR16_REGNUM)
-	    {
-	      gdb_byte to[IA64_FP_REGISTER_SIZE];
-	      target_float_convert (arg->contents ().data () + argoffset,
-				    float_elt_type, to,
-				    ia64_ext_type (gdbarch));
-	      regcache->cooked_write (floatreg, to);
-	      floatreg++;
-	      argoffset += float_elt_type->length ();
-	      len -= float_elt_type->length ();
-	    }
-	}
-    }
-
-  /* Store the struct return value in r8 if necessary.  */
-  if (return_method == return_method_struct)
-    regcache_cooked_write_unsigned (regcache, IA64_GR8_REGNUM,
-				    (ULONGEST) struct_addr);
-
-  global_pointer = ia64_find_global_pointer (gdbarch, func_addr);
-
-  if (global_pointer != 0)
-    regcache_cooked_write_unsigned (regcache, IA64_GR1_REGNUM, global_pointer);
-
-  /* The following is not necessary on HP-UX, because we're using
-     a dummy code sequence pushed on the stack to make the call, and
-     this sequence doesn't need b0 to be set in order for our dummy
-     breakpoint to be hit.  Nonetheless, this doesn't interfere, and
-     it's needed for other OSes, so we do this unconditionaly.  */
-  regcache_cooked_write_unsigned (regcache, IA64_BR0_REGNUM, bp_addr);
-
-  regcache_cooked_write_unsigned (regcache, sp_regnum, sp);
-
-  tdep->infcall_ops.set_function_addr (regcache, func_addr);
-
-  return sp;
-}
-
-static const struct ia64_infcall_ops ia64_infcall_ops =
-{
-  ia64_allocate_new_rse_frame,
-  ia64_store_argument_in_slot,
-  ia64_set_function_addr
-};
-
-static struct frame_id
-ia64_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
-{
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  gdb_byte buf[8];
-  CORE_ADDR sp, bsp;
-
-  get_frame_register (this_frame, sp_regnum, buf);
-  sp = extract_unsigned_integer (buf, 8, byte_order);
-
-  get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-  bsp = extract_unsigned_integer (buf, 8, byte_order);
-
-  if (gdbarch_debug >= 1)
-    gdb_printf (gdb_stdlog,
-		"dummy frame id: code %s, stack %s, special %s\n",
-		paddress (gdbarch, get_frame_pc (this_frame)),
-		paddress (gdbarch, sp), paddress (gdbarch, bsp));
-
-  return frame_id_build_special (sp, get_frame_pc (this_frame), bsp);
-}
-
-static CORE_ADDR 
-ia64_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
-{
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  gdb_byte buf[8];
-  CORE_ADDR ip, psr, pc;
-
-  frame_unwind_register (next_frame, IA64_IP_REGNUM, buf);
-  ip = extract_unsigned_integer (buf, 8, byte_order);
-  frame_unwind_register (next_frame, IA64_PSR_REGNUM, buf);
-  psr = extract_unsigned_integer (buf, 8, byte_order);
- 
-  pc = (ip & ~0xf) | ((psr >> 41) & 3);
-  return pc;
-}
-
-static int
-ia64_print_insn (bfd_vma memaddr, struct disassemble_info *info)
-{
-  info->bytes_per_line = SLOT_MULTIPLIER;
-  return default_print_insn (memaddr, info);
-}
-
-/* The default "size_of_register_frame" gdbarch_tdep routine for ia64.  */
-
-static int
-ia64_size_of_register_frame (const frame_info_ptr &this_frame, ULONGEST cfm)
-{
-  return (cfm & 0x7f);
-}
-
-static struct gdbarch *
-ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
-{
-  /* If there is already a candidate, use it.  */
-  arches = gdbarch_list_lookup_by_info (arches, &info);
-  if (arches != NULL)
-    return arches->gdbarch;
-
-  gdbarch *gdbarch
-    = gdbarch_alloc (&info, gdbarch_tdep_up (new ia64_gdbarch_tdep));
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
-
-  tdep->size_of_register_frame = ia64_size_of_register_frame;
-
-  /* According to the ia64 specs, instructions that store long double
-     floats in memory use a long-double format different than that
-     used in the floating registers.  The memory format matches the
-     x86 extended float format which is 80 bits.  An OS may choose to
-     use this format (e.g. GNU/Linux) or choose to use a different
-     format for storing long doubles (e.g. HPUX).  In the latter case,
-     the setting of the format may be moved/overridden in an
-     OS-specific tdep file.  */
-  set_gdbarch_long_double_format (gdbarch, floatformats_i387_ext);
-
-  set_gdbarch_short_bit (gdbarch, 16);
-  set_gdbarch_int_bit (gdbarch, 32);
-  set_gdbarch_long_bit (gdbarch, 64);
-  set_gdbarch_long_long_bit (gdbarch, 64);
-  set_gdbarch_float_bit (gdbarch, 32);
-  set_gdbarch_double_bit (gdbarch, 64);
-  set_gdbarch_long_double_bit (gdbarch, 128);
-  set_gdbarch_ptr_bit (gdbarch, 64);
-
-  set_gdbarch_num_regs (gdbarch, NUM_IA64_RAW_REGS);
-  set_gdbarch_num_pseudo_regs (gdbarch,
-			       LAST_PSEUDO_REGNUM - FIRST_PSEUDO_REGNUM);
-  set_gdbarch_sp_regnum (gdbarch, sp_regnum);
-  set_gdbarch_fp0_regnum (gdbarch, IA64_FR0_REGNUM);
-
-  set_gdbarch_register_name (gdbarch, ia64_register_name);
-  set_gdbarch_register_type (gdbarch, ia64_register_type);
-
-  set_gdbarch_pseudo_register_read (gdbarch, ia64_pseudo_register_read);
-  set_gdbarch_deprecated_pseudo_register_write (gdbarch,
-						ia64_pseudo_register_write);
-  set_gdbarch_dwarf2_reg_to_regnum (gdbarch, ia64_dwarf_reg_to_regnum);
-  set_gdbarch_register_reggroup_p (gdbarch, ia64_register_reggroup_p);
-  set_gdbarch_convert_register_p (gdbarch, ia64_convert_register_p);
-  set_gdbarch_register_to_value (gdbarch, ia64_register_to_value);
-  set_gdbarch_value_to_register (gdbarch, ia64_value_to_register);
-
-  set_gdbarch_skip_prologue (gdbarch, ia64_skip_prologue);
-
-  set_gdbarch_return_value (gdbarch, ia64_return_value);
-
-  set_gdbarch_memory_insert_breakpoint (gdbarch,
-					ia64_memory_insert_breakpoint);
-  set_gdbarch_memory_remove_breakpoint (gdbarch,
-					ia64_memory_remove_breakpoint);
-  set_gdbarch_breakpoint_from_pc (gdbarch, ia64_breakpoint_from_pc);
-  set_gdbarch_breakpoint_kind_from_pc (gdbarch, ia64_breakpoint_kind_from_pc);
-  set_gdbarch_read_pc (gdbarch, ia64_read_pc);
-  set_gdbarch_write_pc (gdbarch, ia64_write_pc);
-
-  /* Settings for calling functions in the inferior.  */
-  set_gdbarch_push_dummy_call (gdbarch, ia64_push_dummy_call);
-  tdep->infcall_ops = ia64_infcall_ops;
-  set_gdbarch_frame_align (gdbarch, ia64_frame_align);
-  set_gdbarch_dummy_id (gdbarch, ia64_dummy_id);
-
-  set_gdbarch_unwind_pc (gdbarch, ia64_unwind_pc);
-#ifdef HAVE_LIBUNWIND_IA64_H
-  frame_unwind_append_unwinder (gdbarch,
-				&ia64_libunwind_sigtramp_frame_unwind);
-  frame_unwind_append_unwinder (gdbarch, &ia64_libunwind_frame_unwind);
-  frame_unwind_append_unwinder (gdbarch, &ia64_sigtramp_frame_unwind);
-  libunwind_frame_set_descr (gdbarch, &ia64_libunwind_descr);
-#else
-  frame_unwind_append_unwinder (gdbarch, &ia64_sigtramp_frame_unwind);
-#endif
-  frame_unwind_append_unwinder (gdbarch, &ia64_frame_unwind);
-  frame_base_set_default (gdbarch, &ia64_frame_base);
-
-  /* Settings that should be unnecessary.  */
-  set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
-
-  set_gdbarch_print_insn (gdbarch, ia64_print_insn);
-  set_gdbarch_convert_from_func_ptr_addr (gdbarch,
-					  ia64_convert_from_func_ptr_addr);
-
-  /* The virtual table contains 16-byte descriptors, not pointers to
-     descriptors.  */
-  set_gdbarch_vtable_function_descriptors (gdbarch, 1);
-
-  /* Hook in ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch);
-
-  return gdbarch;
-}
-
-void _initialize_ia64_tdep ();
-void
-_initialize_ia64_tdep ()
-{
-  gdbarch_register (bfd_arch_ia64, ia64_gdbarch_init, NULL);
-}
diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h
deleted file mode 100644
index 64be38b4d76..00000000000
--- a/gdb/ia64-tdep.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/* Target-dependent code for the ia64.
-
-   Copyright (C) 2004-2024 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef IA64_TDEP_H
-#define IA64_TDEP_H
-
-#include "gdbarch.h"
-
-#ifdef HAVE_LIBUNWIND_IA64_H
-#include "libunwind-ia64.h"
-#include "ia64-libunwind-tdep.h"
-#endif
-
-/* Register numbers of various important registers.  */
-
-/* General registers; there are 128 of these 64 bit wide registers.
-   The first 32 are static and the last 96 are stacked.  */
-#define IA64_GR0_REGNUM		0
-#define IA64_GR1_REGNUM		(IA64_GR0_REGNUM + 1)
-#define IA64_GR2_REGNUM		(IA64_GR0_REGNUM + 2)
-#define IA64_GR3_REGNUM		(IA64_GR0_REGNUM + 3)
-#define IA64_GR4_REGNUM		(IA64_GR0_REGNUM + 4)
-#define IA64_GR5_REGNUM		(IA64_GR0_REGNUM + 5)
-#define IA64_GR6_REGNUM		(IA64_GR0_REGNUM + 6)
-#define IA64_GR7_REGNUM		(IA64_GR0_REGNUM + 7)
-#define IA64_GR8_REGNUM		(IA64_GR0_REGNUM + 8)
-#define IA64_GR9_REGNUM		(IA64_GR0_REGNUM + 9)
-#define IA64_GR10_REGNUM	(IA64_GR0_REGNUM + 10)
-#define IA64_GR11_REGNUM	(IA64_GR0_REGNUM + 11)
-#define IA64_GR12_REGNUM	(IA64_GR0_REGNUM + 12)
-#define IA64_GR31_REGNUM	(IA64_GR0_REGNUM + 31)
-#define IA64_GR32_REGNUM	(IA64_GR0_REGNUM + 32)
-#define IA64_GR127_REGNUM	(IA64_GR0_REGNUM + 127)
-
-/* Floating point registers; 128 82-bit wide registers.  */
-#define IA64_FR0_REGNUM		128
-#define IA64_FR1_REGNUM		(IA64_FR0_REGNUM + 1)
-#define IA64_FR2_REGNUM		(IA64_FR0_REGNUM + 2)
-#define IA64_FR8_REGNUM		(IA64_FR0_REGNUM + 8)
-#define IA64_FR9_REGNUM		(IA64_FR0_REGNUM + 9)
-#define IA64_FR10_REGNUM	(IA64_FR0_REGNUM + 10)
-#define IA64_FR11_REGNUM	(IA64_FR0_REGNUM + 11)
-#define IA64_FR12_REGNUM	(IA64_FR0_REGNUM + 12)
-#define IA64_FR13_REGNUM	(IA64_FR0_REGNUM + 13)
-#define IA64_FR14_REGNUM	(IA64_FR0_REGNUM + 14)
-#define IA64_FR15_REGNUM	(IA64_FR0_REGNUM + 15)
-#define IA64_FR16_REGNUM	(IA64_FR0_REGNUM + 16)
-#define IA64_FR31_REGNUM	(IA64_FR0_REGNUM + 31)
-#define IA64_FR32_REGNUM	(IA64_FR0_REGNUM + 32)
-#define IA64_FR127_REGNUM	(IA64_FR0_REGNUM + 127)
-
-/* Predicate registers; There are 64 of these one bit registers.  It'd
-   be more convenient (implementation-wise) to use a single 64 bit
-   word with all of these register in them.  Note that there's also a
-   IA64_PR_REGNUM below which contains all the bits and is used for
-   communicating the actual values to the target.  */
-#define IA64_PR0_REGNUM		256
-#define IA64_PR1_REGNUM		(IA64_PR0_REGNUM + 1)
-#define IA64_PR2_REGNUM		(IA64_PR0_REGNUM + 2)
-#define IA64_PR3_REGNUM		(IA64_PR0_REGNUM + 3)
-#define IA64_PR4_REGNUM		(IA64_PR0_REGNUM + 4)
-#define IA64_PR5_REGNUM		(IA64_PR0_REGNUM + 5)
-#define IA64_PR6_REGNUM		(IA64_PR0_REGNUM + 6)
-#define IA64_PR7_REGNUM		(IA64_PR0_REGNUM + 7)
-#define IA64_PR8_REGNUM		(IA64_PR0_REGNUM + 8)
-#define IA64_PR9_REGNUM		(IA64_PR0_REGNUM + 9)
-#define IA64_PR10_REGNUM	(IA64_PR0_REGNUM + 10)
-#define IA64_PR11_REGNUM	(IA64_PR0_REGNUM + 11)
-#define IA64_PR12_REGNUM	(IA64_PR0_REGNUM + 12)
-#define IA64_PR13_REGNUM	(IA64_PR0_REGNUM + 13)
-#define IA64_PR14_REGNUM	(IA64_PR0_REGNUM + 14)
-#define IA64_PR15_REGNUM	(IA64_PR0_REGNUM + 15)
-#define IA64_PR16_REGNUM	(IA64_PR0_REGNUM + 16)
-#define IA64_PR17_REGNUM	(IA64_PR0_REGNUM + 17)
-#define IA64_PR18_REGNUM	(IA64_PR0_REGNUM + 18)
-#define IA64_PR19_REGNUM	(IA64_PR0_REGNUM + 19)
-#define IA64_PR20_REGNUM	(IA64_PR0_REGNUM + 20)
-#define IA64_PR21_REGNUM	(IA64_PR0_REGNUM + 21)
-#define IA64_PR22_REGNUM	(IA64_PR0_REGNUM + 22)
-#define IA64_PR23_REGNUM	(IA64_PR0_REGNUM + 23)
-#define IA64_PR24_REGNUM	(IA64_PR0_REGNUM + 24)
-#define IA64_PR25_REGNUM	(IA64_PR0_REGNUM + 25)
-#define IA64_PR26_REGNUM	(IA64_PR0_REGNUM + 26)
-#define IA64_PR27_REGNUM	(IA64_PR0_REGNUM + 27)
-#define IA64_PR28_REGNUM	(IA64_PR0_REGNUM + 28)
-#define IA64_PR29_REGNUM	(IA64_PR0_REGNUM + 29)
-#define IA64_PR30_REGNUM	(IA64_PR0_REGNUM + 30)
-#define IA64_PR31_REGNUM	(IA64_PR0_REGNUM + 31)
-#define IA64_PR32_REGNUM	(IA64_PR0_REGNUM + 32)
-#define IA64_PR33_REGNUM	(IA64_PR0_REGNUM + 33)
-#define IA64_PR34_REGNUM	(IA64_PR0_REGNUM + 34)
-#define IA64_PR35_REGNUM	(IA64_PR0_REGNUM + 35)
-#define IA64_PR36_REGNUM	(IA64_PR0_REGNUM + 36)
-#define IA64_PR37_REGNUM	(IA64_PR0_REGNUM + 37)
-#define IA64_PR38_REGNUM	(IA64_PR0_REGNUM + 38)
-#define IA64_PR39_REGNUM	(IA64_PR0_REGNUM + 39)
-#define IA64_PR40_REGNUM	(IA64_PR0_REGNUM + 40)
-#define IA64_PR41_REGNUM	(IA64_PR0_REGNUM + 41)
-#define IA64_PR42_REGNUM	(IA64_PR0_REGNUM + 42)
-#define IA64_PR43_REGNUM	(IA64_PR0_REGNUM + 43)
-#define IA64_PR44_REGNUM	(IA64_PR0_REGNUM + 44)
-#define IA64_PR45_REGNUM	(IA64_PR0_REGNUM + 45)
-#define IA64_PR46_REGNUM	(IA64_PR0_REGNUM + 46)
-#define IA64_PR47_REGNUM	(IA64_PR0_REGNUM + 47)
-#define IA64_PR48_REGNUM	(IA64_PR0_REGNUM + 48)
-#define IA64_PR49_REGNUM	(IA64_PR0_REGNUM + 49)
-#define IA64_PR50_REGNUM	(IA64_PR0_REGNUM + 50)
-#define IA64_PR51_REGNUM	(IA64_PR0_REGNUM + 51)
-#define IA64_PR52_REGNUM	(IA64_PR0_REGNUM + 52)
-#define IA64_PR53_REGNUM	(IA64_PR0_REGNUM + 53)
-#define IA64_PR54_REGNUM	(IA64_PR0_REGNUM + 54)
-#define IA64_PR55_REGNUM	(IA64_PR0_REGNUM + 55)
-#define IA64_PR56_REGNUM	(IA64_PR0_REGNUM + 56)
-#define IA64_PR57_REGNUM	(IA64_PR0_REGNUM + 57)
-#define IA64_PR58_REGNUM	(IA64_PR0_REGNUM + 58)
-#define IA64_PR59_REGNUM	(IA64_PR0_REGNUM + 59)
-#define IA64_PR60_REGNUM	(IA64_PR0_REGNUM + 60)
-#define IA64_PR61_REGNUM	(IA64_PR0_REGNUM + 61)
-#define IA64_PR62_REGNUM	(IA64_PR0_REGNUM + 62)
-#define IA64_PR63_REGNUM	(IA64_PR0_REGNUM + 63)
-
-/* Branch registers: 8 64-bit registers for holding branch targets.  */
-#define IA64_BR0_REGNUM		320
-#define IA64_BR1_REGNUM		(IA64_BR0_REGNUM + 1)
-#define IA64_BR2_REGNUM		(IA64_BR0_REGNUM + 2)
-#define IA64_BR3_REGNUM		(IA64_BR0_REGNUM + 3)
-#define IA64_BR4_REGNUM		(IA64_BR0_REGNUM + 4)
-#define IA64_BR5_REGNUM		(IA64_BR0_REGNUM + 5)
-#define IA64_BR6_REGNUM		(IA64_BR0_REGNUM + 6)
-#define IA64_BR7_REGNUM		(IA64_BR0_REGNUM + 7)
-
-/* Virtual frame pointer; this matches IA64_FRAME_POINTER_REGNUM in
-   gcc/config/ia64/ia64.h.  */
-#define IA64_VFP_REGNUM		328
-
-/* Virtual return address pointer; this matches
-   IA64_RETURN_ADDRESS_POINTER_REGNUM in gcc/config/ia64/ia64.h.  */
-#define IA64_VRAP_REGNUM	329
-
-/* Predicate registers: There are 64 of these 1-bit registers.  We
-   define a single register which is used to communicate these values
-   to/from the target.  We will somehow contrive to make it appear
-   that IA64_PR0_REGNUM thru IA64_PR63_REGNUM hold the actual values.  */
-#define IA64_PR_REGNUM		330
-
-/* Instruction pointer: 64 bits wide.  */
-#define IA64_IP_REGNUM		331
-
-/* Process Status Register.  */
-#define IA64_PSR_REGNUM		332
-
-/* Current Frame Marker (raw form may be the cr.ifs).  */
-#define IA64_CFM_REGNUM		333
-
-/* Application registers; 128 64-bit wide registers possible, but some
-   of them are reserved.  */
-#define IA64_AR0_REGNUM		334
-#define IA64_KR0_REGNUM		(IA64_AR0_REGNUM + 0)
-#define IA64_KR7_REGNUM		(IA64_KR0_REGNUM + 7)
-
-#define IA64_RSC_REGNUM		(IA64_AR0_REGNUM + 16)
-#define IA64_BSP_REGNUM		(IA64_AR0_REGNUM + 17)
-#define IA64_BSPSTORE_REGNUM	(IA64_AR0_REGNUM + 18)
-#define IA64_RNAT_REGNUM	(IA64_AR0_REGNUM + 19)
-#define IA64_FCR_REGNUM		(IA64_AR0_REGNUM + 21)
-#define IA64_EFLAG_REGNUM	(IA64_AR0_REGNUM + 24)
-#define IA64_CSD_REGNUM		(IA64_AR0_REGNUM + 25)
-#define IA64_SSD_REGNUM		(IA64_AR0_REGNUM + 26)
-#define IA64_CFLG_REGNUM	(IA64_AR0_REGNUM + 27)
-#define IA64_FSR_REGNUM		(IA64_AR0_REGNUM + 28)
-#define IA64_FIR_REGNUM		(IA64_AR0_REGNUM + 29)
-#define IA64_FDR_REGNUM		(IA64_AR0_REGNUM + 30)
-#define IA64_CCV_REGNUM		(IA64_AR0_REGNUM + 32)
-#define IA64_UNAT_REGNUM	(IA64_AR0_REGNUM + 36)
-#define IA64_FPSR_REGNUM	(IA64_AR0_REGNUM + 40)
-#define IA64_ITC_REGNUM		(IA64_AR0_REGNUM + 44)
-#define IA64_PFS_REGNUM		(IA64_AR0_REGNUM + 64)
-#define IA64_LC_REGNUM		(IA64_AR0_REGNUM + 65)
-#define IA64_EC_REGNUM		(IA64_AR0_REGNUM + 66)
-
-/* NAT (Not A Thing) Bits for the general registers; there are 128 of
-   these.  */
-#define IA64_NAT0_REGNUM	462
-#define IA64_NAT31_REGNUM	(IA64_NAT0_REGNUM + 31)
-#define IA64_NAT32_REGNUM	(IA64_NAT0_REGNUM + 32)
-#define IA64_NAT127_REGNUM	(IA64_NAT0_REGNUM + 127)
-
-class frame_info_ptr;
-struct regcache;
-
-/* A struct containing pointers to all the target-dependent operations
-   performed to setup an inferior function call. */
-
-struct ia64_infcall_ops
-{
-  /* Allocate a new register stack frame starting after the output
-     region of the current frame.  The new frame will contain SOF
-     registers, all in the output region.  This is one way of protecting
-     the stacked registers of the current frame.
-
-     Should do nothing if this operation is not permitted by the OS.  */
-  void (*allocate_new_rse_frame) (struct regcache *regcache, ULONGEST bsp,
-				  int sof);
-
-  /* Store the argument stored in BUF into the appropriate location
-     given the BSP and the SLOTNUM.  */
-  void (*store_argument_in_slot) (struct regcache *regcache, CORE_ADDR bsp,
-				  int slotnum, gdb_byte *buf);
-
-  /* For targets where we cannot call the function directly, store
-     the address of the function we want to call at the location
-     expected by the calling sequence.  */
-  void (*set_function_addr) (struct regcache *regcache, CORE_ADDR func_addr);
-};
-
-struct ia64_gdbarch_tdep : gdbarch_tdep_base
-{
-  CORE_ADDR (*sigcontext_register_address) (struct gdbarch *, CORE_ADDR, int)
-    = nullptr;
-  int (*pc_in_sigtramp) (CORE_ADDR) = nullptr;
-
-  /* Return the total size of THIS_FRAME's register frame.
-     CFM is THIS_FRAME's cfm register value.
-
-     Normally, the size of the register frame is always obtained by
-     extracting the lowest 7 bits ("cfm & 0x7f").  */
-  int (*size_of_register_frame) (const frame_info_ptr &this_frame, ULONGEST cfm)
-    = nullptr;
-
-  /* Determine the function address FADDR belongs to a shared library.
-     If it does, then return the associated global pointer.  If no shared
-     library was found to contain that function, then return zero.
-
-     This pointer may be NULL.  */
-  CORE_ADDR (*find_global_pointer_from_solib) (struct gdbarch *gdbarch,
-					       CORE_ADDR faddr) = nullptr;
-
-  /* ISA-specific data types.  */
-  struct type *ia64_ext_type = nullptr;
-
-  struct ia64_infcall_ops infcall_ops {};
-};
-
-extern void ia64_write_pc (struct regcache *, CORE_ADDR);
-
-#ifdef HAVE_LIBUNWIND_IA64_H
-extern unw_accessors_t ia64_unw_accessors;
-extern unw_accessors_t ia64_unw_rse_accessors;
-extern struct libunwind_descr ia64_libunwind_descr;
-#endif
-
-#endif /* ia64-tdep.h */
diff --git a/gdb/ia64-vms-tdep.c b/gdb/ia64-vms-tdep.c
deleted file mode 100644
index 20308c70720..00000000000
--- a/gdb/ia64-vms-tdep.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* Target-dependent code for OpenVMS IA-64.
-
-   Copyright (C) 2012-2024 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "frame-unwind.h"
-#include "ia64-tdep.h"
-#include "osabi.h"
-#include "gdbtypes.h"
-#include "gdbcore.h"
-#include "gdbarch.h"
-
-#ifdef HAVE_LIBUNWIND_IA64_H
-
-/* Libunwind callback accessor function to acquire procedure unwind-info.  */
-
-static int
-ia64_vms_find_proc_info_x (unw_addr_space_t as, unw_word_t ip,
-			   unw_proc_info_t *pi,
-			   int need_unwind_info, void *arg)
-{
-  bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
-  gdb_byte buf[32];
-  const char *annex = core_addr_to_string (ip);
-  LONGEST res;
-  CORE_ADDR table_addr;
-  unsigned int info_len;
-
-  res = target_read (current_inferior ()->top_target (),
-		     TARGET_OBJECT_OPENVMS_UIB,
-		     annex + 2, buf, 0, sizeof (buf));
-
-  if (res != sizeof (buf))
-    return -UNW_ENOINFO;
-
-  pi->format = UNW_INFO_FORMAT_REMOTE_TABLE;
-  pi->start_ip = extract_unsigned_integer (buf + 0, 8, byte_order);
-  pi->end_ip = extract_unsigned_integer (buf + 8, 8, byte_order);
-  pi->gp = extract_unsigned_integer (buf + 24, 8, byte_order);
-  table_addr = extract_unsigned_integer (buf + 16, 8, byte_order);
-
-  if (table_addr == 0)
-    {
-      /* No unwind data.  */
-      pi->unwind_info = NULL;
-      pi->unwind_info_size = 0;
-      return 0;
-    }
-
-  res = target_read_memory (table_addr, buf, 8);
-  if (res != 0)
-    return -UNW_ENOINFO;
-
-  /* Check version.  */
-  if (extract_unsigned_integer (buf + 6, 2, byte_order) != 1)
-    return -UNW_EBADVERSION;
-  info_len = extract_unsigned_integer (buf + 0, 4, byte_order);
-  pi->unwind_info_size = 8 * info_len;
-
-  /* Read info.  */
-  pi->unwind_info = xmalloc (pi->unwind_info_size);
-
-  res = target_read_memory (table_addr + 8,
-			    (gdb_byte *) pi->unwind_info, pi->unwind_info_size);
-  if (res != 0)
-    {
-      xfree (pi->unwind_info);
-      pi->unwind_info = NULL;
-      return -UNW_ENOINFO;
-    }
-
-  /* FIXME: Handle OSSD (OS Specific Data).  This extension to ia64 unwind
-     information by OpenVMS is currently not handled by libunwind, but
-     looks to be used only in very specific context, and is not generated by
-     GCC.  */
-
-  pi->lsda = table_addr + 8 + pi->unwind_info_size;
-  if (extract_unsigned_integer (buf + 4, 2, byte_order) & 3)
-    {
-      pi->lsda += 8;
-      /* There might be an handler, but this is not used for unwinding.  */
-      pi->handler = 0;
-    }
-
-  return 0;
-}
-
-/* Libunwind callback accessor function for cleanup.  */
-
-static void
-ia64_vms_put_unwind_info (unw_addr_space_t as,
-			  unw_proc_info_t *pip, void *arg)
-{
-  /* Nothing required for now.  */
-}
-
-/* Libunwind callback accessor function to get head of the dynamic
-   unwind-info registration list.  */
-
-static int
-ia64_vms_get_dyn_info_list (unw_addr_space_t as,
-			    unw_word_t *dilap, void *arg)
-{
-  return -UNW_ENOINFO;
-}
-
-/* Set of libunwind callback acccessor functions.  */
-static unw_accessors_t ia64_vms_unw_accessors;
-static unw_accessors_t ia64_vms_unw_rse_accessors;
-
-/* Set of ia64-libunwind-tdep gdb callbacks and data for generic
-   ia64-libunwind-tdep code to use.  */
-static struct libunwind_descr ia64_vms_libunwind_descr;
-
-#endif /* HAVE_LIBUNWIND_IA64_H */
-
-static void
-ia64_openvms_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
-{
-  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_quad);
-
-#ifdef HAVE_LIBUNWIND_IA64_H
-  /* Override the default descriptor.  */
-  ia64_vms_unw_accessors = ia64_unw_accessors;
-  ia64_vms_unw_accessors.find_proc_info = ia64_vms_find_proc_info_x;
-  ia64_vms_unw_accessors.put_unwind_info = ia64_vms_put_unwind_info;
-  ia64_vms_unw_accessors.get_dyn_info_list_addr = ia64_vms_get_dyn_info_list;
-
-  ia64_vms_unw_rse_accessors = ia64_unw_rse_accessors;
-  ia64_vms_unw_rse_accessors.find_proc_info = ia64_vms_find_proc_info_x;
-  ia64_vms_unw_rse_accessors.put_unwind_info = ia64_vms_put_unwind_info;
-  ia64_vms_unw_rse_accessors.get_dyn_info_list_addr = ia64_vms_get_dyn_info_list;
-
-  ia64_vms_libunwind_descr = ia64_libunwind_descr;
-  ia64_vms_libunwind_descr.accessors = &ia64_vms_unw_accessors;
-  ia64_vms_libunwind_descr.special_accessors = &ia64_vms_unw_rse_accessors;
-
-  libunwind_frame_set_descr (gdbarch, &ia64_vms_libunwind_descr);
-#endif
-}
-
-void _initialize_ia64_vms_tdep ();
-void
-_initialize_ia64_vms_tdep ()
-{
-  gdbarch_register_osabi (bfd_arch_ia64, 0, GDB_OSABI_OPENVMS,
-			  ia64_openvms_init_abi);
-}
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index ce303eb87ea..f75186fb945 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -466,9 +466,6 @@ inf_ptrace_target::xfer_partial (enum target_object object,
 					  offset, len);
       return *xfered_len != 0 ? TARGET_XFER_OK : TARGET_XFER_EOF;
 
-    case TARGET_OBJECT_UNWIND_TABLE:
-      return TARGET_XFER_E_IO;
-
     case TARGET_OBJECT_AUXV:
 #if defined (PT_IO) && defined (PIOD_READ_AUXV)
       /* OpenBSD 4.5 has a new PIOD_READ_AUXV operation for the PT_IO
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 9ea0e22913f..491df497e69 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -278,13 +278,8 @@ linux_fork_to_function (gdb_byte *child_stack, int (*function) (void *))
       child_stack = (gdb_byte *) xmalloc (STACK_SIZE * 4);
 
     /* Use CLONE_VM instead of fork, to support uClinux (no MMU).  */
-#ifdef __ia64__
-      child_pid = __clone2 (function, child_stack, STACK_SIZE,
-			    CLONE_VM | SIGCHLD, child_stack + STACK_SIZE * 2);
-#else /* !__ia64__ */
       child_pid = clone (function, child_stack + STACK_SIZE,
 			 CLONE_VM | SIGCHLD, child_stack + STACK_SIZE * 2);
-#endif /* !__ia64__ */
 #else /* !defined(__UCLIBC) && defined(HAS_NOMMU) */
   child_pid = fork ();
 
diff --git a/gdb/regcache.c b/gdb/regcache.c
index f04354d822f..69f194593b5 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -2132,8 +2132,7 @@ cooked_write_test (struct gdbarch *gdbarch)
 	       || type->code () == TYPE_CODE_UNION
 	       || type->code () == TYPE_CODE_STRUCT)
 	{
-	  if (bfd_arch == bfd_arch_ia64
-	      || (regnum >= gdbarch_num_regs (gdbarch)
+	  if ((regnum >= gdbarch_num_regs (gdbarch)
 		  && (bfd_arch == bfd_arch_xtensa
 		      || bfd_arch == bfd_arch_bfin
 		      || bfd_arch == bfd_arch_m32c
diff --git a/gdb/regformats/reg-ia64.dat b/gdb/regformats/reg-ia64.dat
deleted file mode 100644
index 21d56645d67..00000000000
--- a/gdb/regformats/reg-ia64.dat
+++ /dev/null
@@ -1,475 +0,0 @@
-name:ia64
-expedite:ip,psr,r12,bsp,cfm
-64:r0
-64:r1
-64:r2
-64:r3
-64:r4
-64:r5
-64:r6
-64:r7
-64:r8
-64:r9
-64:r10
-64:r11
-64:r12
-64:r13
-64:r14
-64:r15
-64:r16
-64:r17
-64:r18
-64:r19
-64:r20
-64:r21
-64:r22
-64:r23
-64:r24
-64:r25
-64:r26
-64:r27
-64:r28
-64:r29
-64:r30
-64:r31
-64:r32
-64:r33
-64:r34
-64:r35
-64:r36
-64:r37
-64:r38
-64:r39
-64:r40
-64:r41
-64:r42
-64:r43
-64:r44
-64:r45
-64:r46
-64:r47
-64:r48
-64:r49
-64:r50
-64:r51
-64:r52
-64:r53
-64:r54
-64:r55
-64:r56
-64:r57
-64:r58
-64:r59
-64:r60
-64:r61
-64:r62
-64:r63
-64:r64
-64:r65
-64:r66
-64:r67
-64:r68
-64:r69
-64:r70
-64:r71
-64:r72
-64:r73
-64:r74
-64:r75
-64:r76
-64:r77
-64:r78
-64:r79
-64:r80
-64:r81
-64:r82
-64:r83
-64:r84
-64:r85
-64:r86
-64:r87
-64:r88
-64:r89
-64:r90
-64:r91
-64:r92
-64:r93
-64:r94
-64:r95
-64:r96
-64:r97
-64:r98
-64:r99
-64:r100
-64:r101
-64:r102
-64:r103
-64:r104
-64:r105
-64:r106
-64:r107
-64:r108
-64:r109
-64:r110
-64:r111
-64:r112
-64:r113
-64:r114
-64:r115
-64:r116
-64:r117
-64:r118
-64:r119
-64:r120
-64:r121
-64:r122
-64:r123
-64:r124
-64:r125
-64:r126
-64:r127
-
-128:f0
-128:f1
-128:f2
-128:f3
-128:f4
-128:f5
-128:f6
-128:f7
-128:f8
-128:f9
-128:f10
-128:f11
-128:f12
-128:f13
-128:f14
-128:f15
-128:f16
-128:f17
-128:f18
-128:f19
-128:f20
-128:f21
-128:f22
-128:f23
-128:f24
-128:f25
-128:f26
-128:f27
-128:f28
-128:f29
-128:f30
-128:f31
-128:f32
-128:f33
-128:f34
-128:f35
-128:f36
-128:f37
-128:f38
-128:f39
-128:f40
-128:f41
-128:f42
-128:f43
-128:f44
-128:f45
-128:f46
-128:f47
-128:f48
-128:f49
-128:f50
-128:f51
-128:f52
-128:f53
-128:f54
-128:f55
-128:f56
-128:f57
-128:f58
-128:f59
-128:f60
-128:f61
-128:f62
-128:f63
-128:f64
-128:f65
-128:f66
-128:f67
-128:f68
-128:f69
-128:f70
-128:f71
-128:f72
-128:f73
-128:f74
-128:f75
-128:f76
-128:f77
-128:f78
-128:f79
-128:f80
-128:f81
-128:f82
-128:f83
-128:f84
-128:f85
-128:f86
-128:f87
-128:f88
-128:f89
-128:f90
-128:f91
-128:f92
-128:f93
-128:f94
-128:f95
-128:f96
-128:f97
-128:f98
-128:f99
-128:f100
-128:f101
-128:f102
-128:f103
-128:f104
-128:f105
-128:f106
-128:f107
-128:f108
-128:f109
-128:f110
-128:f111
-128:f112
-128:f113
-128:f114
-128:f115
-128:f116
-128:f117
-128:f118
-128:f119
-128:f120
-128:f121
-128:f122
-128:f123
-128:f124
-128:f125
-128:f126
-128:f127
-
-64:p0
-64:p1
-64:p2
-64:p3
-64:p4
-64:p5
-64:p6
-64:p7
-64:p8
-64:p9
-64:p10
-64:p11
-64:p12
-64:p13
-64:p14
-64:p15
-64:p16
-64:p17
-64:p18
-64:p19
-64:p20
-64:p21
-64:p22
-64:p23
-64:p24
-64:p25
-64:p26
-64:p27
-64:p28
-64:p29
-64:p30
-64:p31
-64:p32
-64:p33
-64:p34
-64:p35
-64:p36
-64:p37
-64:p38
-64:p39
-64:p40
-64:p41
-64:p42
-64:p43
-64:p44
-64:p45
-64:p46
-64:p47
-64:p48
-64:p49
-64:p50
-64:p51
-64:p52
-64:p53
-64:p54
-64:p55
-64:p56
-64:p57
-64:p58
-64:p59
-64:p60
-64:p61
-64:p62
-64:p63
-
-64:b0
-64:b1
-64:b2
-64:b3
-64:b4
-64:b5
-64:b6
-64:b7
-
-64:vfp
-64:vrap
-
-64:pr
-64:ip
-64:psr
-64:cfm
-
-64:kr0
-64:kr1
-64:kr2
-64:kr3
-64:kr4
-64:kr5
-64:kr6
-64:kr7
-
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-
-64:rsc
-64:bsp
-64:bspstore
-64:rnat
-
-64:
-64:fcr
-64:
-64:
-
-64:eflag
-64:csd
-64:ssd
-64:cflg
-64:fsr
-64:fir
-64:fdr
-64:
-64:ccv
-64:
-64:
-64:
-64:unat
-64:
-64:
-64:
-64:fpsr
-64:
-64:
-64:
-64:itc
-
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:pfs
-64:lc
-64:ec
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
-64:
diff --git a/gdb/stubs/ia64vms-stub.c b/gdb/stubs/ia64vms-stub.c
deleted file mode 100644
index e7578d80938..00000000000
--- a/gdb/stubs/ia64vms-stub.c
+++ /dev/null
@@ -1,2601 +0,0 @@
-/* GDB stub for Itanium OpenVMS
-   Copyright (C) 2012-2024 Free Software Foundation, Inc.
-
-   Contributed by Tristan Gingold, AdaCore.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* On VMS, the debugger (in our case the stub) is loaded in the process and
-   executed (via SYS$IMGSTA) before the main entry point of the executable.
-   In UNIX parlance, this is like using LD_PRELOAD and debug via installing
-   SIGTRAP, SIGSEGV... handlers.
-
-   This is currently a partial implementation.  In particular, modifying
-   registers is currently not implemented, as well as inferior procedure
-   calls.
-
-   This is written in very low-level C, in order not to use the C runtime,
-   because it may have weird consequences on the program being debugged.
-*/
-
-#if __INITIAL_POINTER_SIZE != 64
-#error "Must be compiled with 64 bit pointers"
-#endif
-
-#define __NEW_STARLET 1
-#include <descrip.h>
-#include <iledef.h>
-#include <efndef.h>
-#include <in.h>
-#include <inet.h>
-#include <iodef.h>
-#include <ssdef.h>
-#include <starlet.h>
-#include <stsdef.h>
-#include <tcpip$inetdef.h>
-
-#include <lib$routines.h>
-#include <ots$routines.h>
-#include <str$routines.h>
-#include <libdef.h>
-#include <clidef.h>
-#include <iosbdef.h>
-#include <dvidef.h>
-#include <lnmdef.h>
-#include <builtins.h>
-#include <prtdef.h>
-#include <psldef.h>
-#include <chfdef.h>
-
-#include <lib_c/imcbdef.h>
-#include <lib_c/ldrimgdef.h>
-#include <lib_c/intstkdef.h>
-#include <lib_c/psrdef.h>
-#include <lib_c/ifddef.h>
-#include <lib_c/eihddef.h>
-
-#include <stdarg.h>
-#include <pthread_debug.h>
-
-#define VMS_PAGE_SIZE 0x2000
-#define VMS_PAGE_MASK (VMS_PAGE_SIZE - 1)
-
-/* Declared in lib$ots.  */
-extern void ots$fill (void *addr, size_t len, unsigned char b);
-extern void ots$move (void *dst, size_t len, const void *src);
-extern int ots$strcmp_eql (const void *str1, size_t str1len,
-			   const void *str2, size_t str2len);
-
-/* Stub port number.  */
-static unsigned int serv_port = 1234;
-
-/* DBGEXT structure.  Not declared in any header.  */
-struct dbgext_control_block
-{
-  unsigned short dbgext$w_function_code;
-#define DBGEXT$K_NEXT_TASK	      3
-#define DBGEXT$K_STOP_ALL_OTHER_TASKS 31
-#define DBGEXT$K_GET_REGS 33
-  unsigned short dbgext$w_facility_id;
-#define CMA$_FACILITY 64
-  unsigned int dbgext$l_status;
-  unsigned int dbgext$l_flags;
-  unsigned int dbgext$l_print_routine;
-  unsigned int dbgext$l_evnt_code;
-  unsigned int dbgext$l_evnt_name;
-  unsigned int dbgext$l_evnt_entry;
-  unsigned int dbgext$l_task_value;
-  unsigned int dbgext$l_task_number;
-  unsigned int dbgext$l_ada_flags;
-  unsigned int dbgext$l_stop_value;
-#define dbgext$l_priority   dbgext$l_stop_value;
-#define dbgext$l_symb_addr  dbgext$l_stop_value;
-#define dbgext$l_time_slice dbgext$l_stop_value;
-  unsigned int dbgext$l_active_registers;
-};
-
-#pragma pointer_size save
-#pragma pointer_size 32
-
-/* Pthread handler.  */
-static int (*dbgext_func) (struct dbgext_control_block *blk);
-
-#pragma pointer_size restore
-
-/* Set to 1 if thread-aware.  */
-static int has_threads;
-
-/* Current thread.  */
-static pthread_t selected_thread;
-static pthreadDebugId_t selected_id;
-
-/* Internal debugging flags.  */
-struct debug_flag
-{
-  /* Name of the flag (as a string descriptor).  */
-  const struct dsc$descriptor_s name;
-  /* Value.  */
-  int val;
-};
-
-/* Macro to define a debugging flag.  */
-#define DEBUG_FLAG_ENTRY(str) \
-  { { sizeof (str) - 1, DSC$K_DTYPE_T, DSC$K_CLASS_S, str }, 0}
-
-static struct debug_flag debug_flags[] =
-{
-  /* Disp packets exchanged with gdb.  */
-  DEBUG_FLAG_ENTRY("packets"),
-#define trace_pkt (debug_flags[0].val)
-  /* Display entry point informations.  */
-  DEBUG_FLAG_ENTRY("entry"),
-#define trace_entry (debug_flags[1].val)
-  /* Be verbose about exceptions.  */
-  DEBUG_FLAG_ENTRY("excp"),
-#define trace_excp (debug_flags[2].val)
-  /* Be verbose about unwinding.  */
-  DEBUG_FLAG_ENTRY("unwind"),
-#define trace_unwind (debug_flags[3].val)
-  /* Display image at startup.  */
-  DEBUG_FLAG_ENTRY("images"),
-#define trace_images (debug_flags[4].val)
-  /* Display pthread_debug info.  */
-  DEBUG_FLAG_ENTRY("pthreaddbg")
-#define trace_pthreaddbg (debug_flags[5].val)
-};
-
-#define NBR_DEBUG_FLAGS (sizeof (debug_flags) / sizeof (debug_flags[0]))
-
-/* Connect inet device I/O channel.  */
-static unsigned short conn_channel;
-
-/* Widely used hex digit to ascii.  */
-static const char hex[] = "0123456789abcdef";
-
-/* Socket characteristics.  Apparently, there are no declaration for it in
-   standard headers.  */
-struct sockchar
-{
-  unsigned short prot;
-  unsigned char type;
-  unsigned char af;
-};
-
-/* Chain of images loaded.  */
-extern IMCB* ctl$gl_imglstptr;
-
-/* IA64 integer register representation.  */
-union ia64_ireg
-{
-  unsigned __int64 v;
-  unsigned char b[8];
-};
-
-/* IA64 register numbers, as defined by ia64-tdep.h.  */
-#define IA64_GR0_REGNUM		0
-#define IA64_GR32_REGNUM	(IA64_GR0_REGNUM + 32)
-
-/* Floating point registers; 128 82-bit wide registers.  */
-#define IA64_FR0_REGNUM		128
-
-/* Predicate registers; There are 64 of these one bit registers.  It'd
-   be more convenient (implementation-wise) to use a single 64 bit
-   word with all of these register in them.  Note that there's also a
-   IA64_PR_REGNUM below which contains all the bits and is used for
-   communicating the actual values to the target.  */
-#define IA64_PR0_REGNUM		256
-
-/* Branch registers: 8 64-bit registers for holding branch targets.  */
-#define IA64_BR0_REGNUM		320
-
-/* Virtual frame pointer; this matches IA64_FRAME_POINTER_REGNUM in
-   gcc/config/ia64/ia64.h.  */
-#define IA64_VFP_REGNUM		328
-
-/* Virtual return address pointer; this matches
-   IA64_RETURN_ADDRESS_POINTER_REGNUM in gcc/config/ia64/ia64.h.  */
-#define IA64_VRAP_REGNUM	329
-
-/* Predicate registers: There are 64 of these 1-bit registers.  We
-   define a single register which is used to communicate these values
-   to/from the target.  We will somehow contrive to make it appear
-   that IA64_PR0_REGNUM thru IA64_PR63_REGNUM hold the actual values.  */
-#define IA64_PR_REGNUM		330
-
-/* Instruction pointer: 64 bits wide.  */
-#define IA64_IP_REGNUM		331
-
-/* Process Status Register.  */
-#define IA64_PSR_REGNUM		332
-
-/* Current Frame Marker (raw form may be the cr.ifs).  */
-#define IA64_CFM_REGNUM		333
-
-/* Application registers; 128 64-bit wide registers possible, but some
-   of them are reserved.  */
-#define IA64_AR0_REGNUM		334
-#define IA64_KR0_REGNUM		(IA64_AR0_REGNUM + 0)
-#define IA64_KR7_REGNUM		(IA64_KR0_REGNUM + 7)
-
-#define IA64_RSC_REGNUM		(IA64_AR0_REGNUM + 16)
-#define IA64_BSP_REGNUM		(IA64_AR0_REGNUM + 17)
-#define IA64_BSPSTORE_REGNUM	(IA64_AR0_REGNUM + 18)
-#define IA64_RNAT_REGNUM	(IA64_AR0_REGNUM + 19)
-#define IA64_FCR_REGNUM		(IA64_AR0_REGNUM + 21)
-#define IA64_EFLAG_REGNUM	(IA64_AR0_REGNUM + 24)
-#define IA64_CSD_REGNUM		(IA64_AR0_REGNUM + 25)
-#define IA64_SSD_REGNUM		(IA64_AR0_REGNUM + 26)
-#define IA64_CFLG_REGNUM	(IA64_AR0_REGNUM + 27)
-#define IA64_FSR_REGNUM		(IA64_AR0_REGNUM + 28)
-#define IA64_FIR_REGNUM		(IA64_AR0_REGNUM + 29)
-#define IA64_FDR_REGNUM		(IA64_AR0_REGNUM + 30)
-#define IA64_CCV_REGNUM		(IA64_AR0_REGNUM + 32)
-#define IA64_UNAT_REGNUM	(IA64_AR0_REGNUM + 36)
-#define IA64_FPSR_REGNUM	(IA64_AR0_REGNUM + 40)
-#define IA64_ITC_REGNUM		(IA64_AR0_REGNUM + 44)
-#define IA64_PFS_REGNUM		(IA64_AR0_REGNUM + 64)
-#define IA64_LC_REGNUM		(IA64_AR0_REGNUM + 65)
-#define IA64_EC_REGNUM		(IA64_AR0_REGNUM + 66)
-
-/* NAT (Not A Thing) Bits for the general registers; there are 128 of
-   these.  */
-#define IA64_NAT0_REGNUM	462
-
-/* Process registers when a condition is caught.  */
-struct ia64_all_regs
-{
-  union ia64_ireg gr[32];
-  union ia64_ireg br[8];
-  union ia64_ireg ip;
-  union ia64_ireg psr;
-  union ia64_ireg bsp;
-  union ia64_ireg cfm;
-  union ia64_ireg pfs;
-  union ia64_ireg pr;
-};
-
-static struct ia64_all_regs excp_regs;
-static struct ia64_all_regs sel_regs;
-static pthread_t sel_regs_pthread;
-
-/* IO channel for the terminal.  */
-static unsigned short term_chan;
-
-/* Output buffer and length.  */
-static char term_buf[128];
-static int term_buf_len;
-
-/* Buffer for communication with gdb.  */
-static unsigned char gdb_buf[sizeof (struct ia64_all_regs) * 2 + 64];
-static unsigned int gdb_blen;
-
-/* Previous primary handler.  */
-static void *prevhnd;
-
-/* Entry point address and bundle.  */
-static unsigned __int64 entry_pc;
-static unsigned char entry_saved[16];
-
-/* Write on the terminal.  */
-
-static void
-term_raw_write (const char *str, unsigned int len)
-{
-  unsigned short status;
-  struct _iosb iosb;
-
-  status = sys$qiow (EFN$C_ENF,           /* Event flag.  */
-		     term_chan,           /* I/O channel.  */
-		     IO$_WRITEVBLK,       /* I/O function code.  */
-		     &iosb,               /* I/O status block.  */
-		     0,                   /* Ast service routine.  */
-		     0,                   /* Ast parameter.  */
-		     (char *)str,         /* P1 - buffer address.  */
-		     len,                 /* P2 - buffer length.  */
-		     0, 0, 0, 0);
-
-  if (status & STS$M_SUCCESS)
-    status = iosb.iosb$w_status;
-  if (!(status & STS$M_SUCCESS))
-    LIB$SIGNAL (status);
-}
-
-/* Flush ther term buffer.  */
-
-static void
-term_flush (void)
-{
-  if (term_buf_len != 0)
-    {
-      term_raw_write (term_buf, term_buf_len);
-      term_buf_len = 0;
-    }
-}
-
-/* Write a single character, without translation.  */
-
-static void
-term_raw_putchar (char c)
-{
-  if (term_buf_len == sizeof (term_buf))
-    term_flush ();
-  term_buf[term_buf_len++] = c;
-}
-
-/* Write character C.  Translate '\n' to '\n\r'.  */
-
-static void
-term_putc (char c)
-{
-  if (c < 32)
-    switch (c)
-      {
-      case '\r':
-      case '\n':
-	break;
-      default:
-	c = '.';
-	break;
-      }
-  term_raw_putchar (c);
-  if (c == '\n')
-    {
-      term_raw_putchar ('\r');
-      term_flush ();
-    }
-}
-
-/* Write a C string.  */
-
-static void
-term_puts (const char *str)
-{
-  while (*str)
-    term_putc (*str++);
-}
-
-/* Write LEN bytes from STR.  */
-
-static void
-term_write (const char *str, unsigned int len)
-{
-  for (; len > 0; len--)
-    term_putc (*str++);
-}
-
-/* Write using FAO formatting.  */
-
-static void
-term_fao (const char *str, unsigned int str_len, ...)
-{
-  int cnt;
-  va_list vargs;
-  int i;
-  __int64 *args;
-  int status;
-  struct dsc$descriptor_s dstr =
-    { str_len, DSC$K_DTYPE_T, DSC$K_CLASS_S, (__char_ptr32)str };
-  char buf[128];
-  $DESCRIPTOR (buf_desc, buf);
-
-  va_start (vargs, str_len);
-  va_count (cnt);
-  args = (__int64 *) __ALLOCA (cnt * sizeof (__int64));
-  cnt -= 2;
-  for (i = 0; i < cnt; i++)
-    args[i] = va_arg (vargs, __int64);
-
-  status = sys$faol_64 (&dstr, &buf_desc.dsc$w_length, &buf_desc, args);
-  if (status & 1)
-    {
-      /* FAO !/ already insert a line feed.  */
-      for (i = 0; i < buf_desc.dsc$w_length; i++)
-	{
-	  term_raw_putchar (buf[i]);
-	  if (buf[i] == '\n')
-	    term_flush ();
-	}
-    }
-      
-  va_end (vargs);
-}
-
-#define TERM_FAO(STR, ...) term_fao (STR, sizeof (STR) - 1, __VA_ARGS__)
-
-/* New line.  */
-
-static void
-term_putnl (void)
-{
-  term_putc ('\n');
-}
-
-/* Initialize terminal.  */
-
-static void
-term_init (void)
-{
-  unsigned int status,i;
-  unsigned short len;
-  char resstring[LNM$C_NAMLENGTH];
-  static const $DESCRIPTOR (tabdesc, "LNM$FILE_DEV");
-  static const $DESCRIPTOR (logdesc, "SYS$OUTPUT");
-  $DESCRIPTOR (term_desc, resstring);
-  ILE3 item_lst[2];
-
-  item_lst[0].ile3$w_length = LNM$C_NAMLENGTH;
-  item_lst[0].ile3$w_code = LNM$_STRING;
-  item_lst[0].ile3$ps_bufaddr = resstring;
-  item_lst[0].ile3$ps_retlen_addr = &len;
-  item_lst[1].ile3$w_length = 0;
-  item_lst[1].ile3$w_code = 0;
-
-  /* Translate the logical name.  */
-  status = SYS$TRNLNM (0,          	  /* Attr of the logical name.  */
-		       (void *) &tabdesc, /* Logical name table.  */
-		       (void *) &logdesc, /* Logical name.  */
-		       0,          /* Access mode.  */
-		       item_lst);  /* Item list.  */
-  if (!(status & STS$M_SUCCESS))
-    LIB$SIGNAL (status);
-
-  term_desc.dsc$w_length = len;
-
-  /* Examine 4-byte header.  Skip escape sequence.  */
-  if (resstring[0] == 0x1B)
-    {
-      term_desc.dsc$w_length -= 4;
-      term_desc.dsc$a_pointer += 4;
-    }
-
-  /* Assign a channel.  */
-  status = sys$assign (&term_desc,   /* Device name.  */
-		       &term_chan,   /* I/O channel.  */
-		       0,            /* Access mode.  */
-		       0);
-  if (!(status & STS$M_SUCCESS))
-    LIB$SIGNAL (status);
-}
-
-/* Convert from native endianness to network endianness (and vice-versa).  */
-
-static unsigned int
-wordswap (unsigned int v)
-{
-  return ((v & 0xff) << 8) | ((v >> 8) & 0xff);
-}
-
-/* Initialize the socket connection, and wait for a client.  */
-
-static void
-sock_init (void)
-{
-  struct _iosb iosb;
-  unsigned int status;
-
-  /* Listen channel and characteristics.  */
-  unsigned short listen_channel;
-  struct sockchar listen_sockchar;
-
-  /* Client address.  */
-  unsigned short cli_addrlen;
-  struct sockaddr_in cli_addr;
-  ILE3 cli_itemlst;
-
-  /* Our address.  */
-  struct sockaddr_in serv_addr;
-  ILE2 serv_itemlst;
-
-  /* Reuseaddr option value (on).  */
-  int optval = 1;
-  ILE2 sockopt_itemlst;
-  ILE2 reuseaddr_itemlst;
-
-  /* TCP/IP network pseudodevice.  */
-  static const $DESCRIPTOR (inet_device, "TCPIP$DEVICE:");
-
-  /* Initialize socket characteristics.  */
-  listen_sockchar.prot = TCPIP$C_TCP;
-  listen_sockchar.type = TCPIP$C_STREAM;
-  listen_sockchar.af   = TCPIP$C_AF_INET;
-
-  /* Assign I/O channels to network device.  */
-  status = sys$assign ((void *) &inet_device, &listen_channel, 0, 0);
-  if (status & STS$M_SUCCESS)
-    status = sys$assign ((void *) &inet_device, &conn_channel, 0, 0);
-  if (!(status & STS$M_SUCCESS))
-    {
-      term_puts ("Failed to assign I/O channel(s)\n");
-      LIB$SIGNAL (status);
-    }
-
-  /* Create a listen socket.  */
-  status = sys$qiow (EFN$C_ENF,           /* Event flag.  */
-		     listen_channel,      /* I/O channel.  */
-		     IO$_SETMODE,         /* I/O function code.  */
-		     &iosb,               /* I/O status block.  */
-		     0,                   /* Ast service routine.  */
-		     0,                   /* Ast parameter.  */
-		     &listen_sockchar,    /* P1 - socket characteristics.  */
-		     0, 0, 0, 0, 0);
-  if (status & STS$M_SUCCESS)
-    status = iosb.iosb$w_status;
-  if (!(status & STS$M_SUCCESS))
-    {
-      term_puts ("Failed to create socket\n");
-      LIB$SIGNAL (status);
-    }
-
-  /* Set reuse address option.  */
-  /* Initialize reuseaddr's item-list element.  */
-  reuseaddr_itemlst.ile2$w_length   = sizeof (optval);
-  reuseaddr_itemlst.ile2$w_code     = TCPIP$C_REUSEADDR;
-  reuseaddr_itemlst.ile2$ps_bufaddr = &optval;
-
-  /* Initialize setsockopt's item-list descriptor.  */
-  sockopt_itemlst.ile2$w_length   = sizeof (reuseaddr_itemlst);
-  sockopt_itemlst.ile2$w_code     = TCPIP$C_SOCKOPT;
-  sockopt_itemlst.ile2$ps_bufaddr = &reuseaddr_itemlst;
-
-  status = sys$qiow (EFN$C_ENF,       /* Event flag.  */
-		     listen_channel,  /* I/O channel.  */
-		     IO$_SETMODE,     /* I/O function code.  */
-		     &iosb,           /* I/O status block.  */
-		     0,               /* Ast service routine.  */
-		     0,               /* Ast parameter.  */
-		     0,               /* P1.  */
-		     0,               /* P2.  */
-		     0,               /* P3.  */
-		     0,               /* P4.  */
-		     (__int64) &sockopt_itemlst, /* P5 - socket options.  */
-		     0);
-  if (status & STS$M_SUCCESS)
-    status = iosb.iosb$w_status;
-  if (!(status & STS$M_SUCCESS))
-    {
-      term_puts ("Failed to set socket option\n");
-      LIB$SIGNAL (status);
-    }
-
-  /* Bind server's ip address and port number to listen socket.  */
-  /* Initialize server's socket address structure.  */
-  ots$fill (&serv_addr, sizeof (serv_addr), 0);
-  serv_addr.sin_family = TCPIP$C_AF_INET;
-  serv_addr.sin_port = wordswap (serv_port);
-  serv_addr.sin_addr.s_addr = TCPIP$C_INADDR_ANY;
-
-  /* Initialize server's item-list descriptor.  */
-  serv_itemlst.ile2$w_length   = sizeof (serv_addr);
-  serv_itemlst.ile2$w_code     = TCPIP$C_SOCK_NAME;
-  serv_itemlst.ile2$ps_bufaddr = &serv_addr;
-
-  status = sys$qiow (EFN$C_ENF,           /* Event flag.  */
-		     listen_channel,      /* I/O channel.  */
-		     IO$_SETMODE,         /* I/O function code.  */
-		     &iosb,               /* I/O status block.  */
-		     0,                   /* Ast service routine.  */
-		     0,                   /* Ast parameter.  */
-		     0,                   /* P1.  */
-		     0,                   /* P2.  */
-		     (__int64) &serv_itemlst, /* P3 - local socket name.  */
-		     0, 0, 0);
-  if (status & STS$M_SUCCESS)
-    status = iosb.iosb$w_status;
-  if (!(status & STS$M_SUCCESS))
-    {
-      term_puts ("Failed to bind socket\n");
-      LIB$SIGNAL (status);
-    }
-
-  /* Set socket as a listen socket.  */
-  status = sys$qiow (EFN$C_ENF,           /* Event flag.  */
-		     listen_channel,      /* I/O channel.  */
-		     IO$_SETMODE,         /* I/O function code.  */
-		     &iosb,               /* I/O status block.  */
-		     0,                   /* Ast service routine.  */
-		     0,                   /* Ast parameter.  */
-		     0,                   /* P1.  */
-		     0,                   /* P2.  */
-		     0,                   /* P3.  */
-		     1,                   /* P4 - connection backlog.  */
-		     0, 0);
-  if (status & STS$M_SUCCESS)
-    status = iosb.iosb$w_status;
-  if (!(status & STS$M_SUCCESS))
-    {
-      term_puts ("Failed to set socket passive\n");
-      LIB$SIGNAL (status);
-    }
-
-  /* Accept connection from a client.  */
-  TERM_FAO ("Waiting for a client connection on port: !ZW!/",
-	    wordswap (serv_addr.sin_port));
-
-  status = sys$qiow (EFN$C_ENF,              /* Event flag.  */
-		     listen_channel,         /* I/O channel.  */
-		     IO$_ACCESS|IO$M_ACCEPT, /* I/O function code.  */
-		     &iosb,                  /* I/O status block.  */
-		     0,                      /* Ast service routine.  */
-		     0,                      /* Ast parameter.  */
-		     0,                      /* P1.  */
-		     0,                      /* P2.  */
-		     0,                      /* P3.  */
-		     (__int64) &conn_channel, /* P4 - I/O channel for conn.  */
-		     0, 0);
-
-  if (status & STS$M_SUCCESS)
-    status = iosb.iosb$w_status;
-  if (!(status & STS$M_SUCCESS))
-    {
-      term_puts ("Failed to accept client connection\n");
-      LIB$SIGNAL (status);
-    }
-
-  /* Log client connection request.  */
-  cli_itemlst.ile3$w_length = sizeof (cli_addr);
-  cli_itemlst.ile3$w_code = TCPIP$C_SOCK_NAME;
-  cli_itemlst.ile3$ps_bufaddr = &cli_addr;
-  cli_itemlst.ile3$ps_retlen_addr = &cli_addrlen;
-  ots$fill (&cli_addr, sizeof(cli_addr), 0);
-  status = sys$qiow (EFN$C_ENF,           /* Event flag.  */
-		     conn_channel,        /* I/O channel.  */
-		     IO$_SENSEMODE,       /* I/O function code.  */
-		     &iosb,               /* I/O status block.  */
-		     0,                   /* Ast service routine.  */
-		     0,                   /* Ast parameter.  */
-		     0,                   /* P1.  */
-		     0,                   /* P2.  */
-		     0,                   /* P3.  */
-		     (__int64) &cli_itemlst,  /* P4 - peer socket name.  */
-		     0, 0);
-  if (status & STS$M_SUCCESS)
-    status = iosb.iosb$w_status;
-  if (!(status & STS$M_SUCCESS))
-    {
-      term_puts ("Failed to get client name\n");
-      LIB$SIGNAL (status);
-    }
-
-  TERM_FAO ("Accepted connection from host: !UB.!UB,!UB.!UB, port: !UW!/",
-	    (cli_addr.sin_addr.s_addr >> 0) & 0xff,
-	    (cli_addr.sin_addr.s_addr >> 8) & 0xff,
-	    (cli_addr.sin_addr.s_addr >> 16) & 0xff,
-	    (cli_addr.sin_addr.s_addr >> 24) & 0xff,
-	    wordswap (cli_addr.sin_port));
-}
-
-/* Close the socket.  */
-
-static void
-sock_close (void)
-{
-  struct _iosb iosb;
-  unsigned int status;
-
-  /* Close socket.  */
-  status = sys$qiow (EFN$C_ENF,           /* Event flag.  */
-		     conn_channel,        /* I/O channel.  */
-		     IO$_DEACCESS,        /* I/O function code.  */
-		     &iosb,               /* I/O status block.  */
-		     0,                   /* Ast service routine.  */
-		     0,                   /* Ast parameter.  */
-		     0, 0, 0, 0, 0, 0);
-
-  if (status & STS$M_SUCCESS)
-    status = iosb.iosb$w_status;
-  if (!(status & STS$M_SUCCESS))
-    {
-      term_puts ("Failed to close socket\n");
-      LIB$SIGNAL (status);
-    }
-
-  /* Deassign I/O channel to network device.  */
-  status = sys$dassgn (conn_channel);
-
-  if (!(status & STS$M_SUCCESS))
-    {
-      term_puts ("Failed to deassign I/O channel\n");
-      LIB$SIGNAL (status);
-    }
-}
-
-/* Mark a page as R/W.  Return old rights.  */
-
-static unsigned int
-page_set_rw (unsigned __int64 startva, unsigned __int64 len,
-	     unsigned int *oldprot)
-{
-  unsigned int status;
-  unsigned __int64 retva;
-  unsigned __int64 retlen;
-
-  status = SYS$SETPRT_64 ((void *)startva, len, PSL$C_USER, PRT$C_UW,
-			  (void *)&retva, &retlen, oldprot);
-  return status;
-}
-
-/* Restore page rights.  */
-
-static void
-page_restore_rw (unsigned __int64 startva, unsigned __int64 len,
-		unsigned int prot)
-{
-  unsigned int status;
-  unsigned __int64 retva;
-  unsigned __int64 retlen;
-  unsigned int oldprot;
-
-  status = SYS$SETPRT_64 ((void *)startva, len, PSL$C_USER, prot,
-			  (void *)&retva, &retlen, &oldprot);
-  if (!(status & STS$M_SUCCESS))
-    LIB$SIGNAL (status);
-}
-
-/* Get the TEB (thread environment block).  */
-
-static pthread_t
-get_teb (void)
-{
-  return (pthread_t)__getReg (_IA64_REG_TP);
-}
-
-/* Enable thread scheduling if VAL is true.  */
-
-static unsigned int
-set_thread_scheduling (int val)
-{
-  struct dbgext_control_block blk;
-  unsigned int status;
-
-  if (!dbgext_func)
-    return 0;
-
-  blk.dbgext$w_function_code = DBGEXT$K_STOP_ALL_OTHER_TASKS;
-  blk.dbgext$w_facility_id = CMA$_FACILITY;
-  blk.dbgext$l_stop_value = val;
-
-  status = dbgext_func (&blk);
-  if (!(status & STS$M_SUCCESS))
-    {
-      TERM_FAO ("set_thread_scheduling error, val=!SL, status=!XL!/",
-		val, blk.dbgext$l_status);
-      lib$signal (status);
-    }
-
-  return blk.dbgext$l_stop_value;
-}
-
-/* Get next thread (after THR).  Start with 0.  */
-
-static unsigned int
-thread_next (unsigned int thr)
-{
-  struct dbgext_control_block blk;
-  unsigned int status;
-
-  if (!dbgext_func)
-    return 0;
-
-  blk.dbgext$w_function_code = DBGEXT$K_NEXT_TASK;
-  blk.dbgext$w_facility_id = CMA$_FACILITY;
-  blk.dbgext$l_ada_flags = 0;
-  blk.dbgext$l_task_value = thr;
-
-  status = dbgext_func (&blk);
-  if (!(status & STS$M_SUCCESS))
-    lib$signal (status);
-
-  return blk.dbgext$l_task_value;
-}
-
-/* Pthread Debug callbacks.  */
-
-static int
-read_callback (pthreadDebugClient_t context,
-	       pthreadDebugTargetAddr_t addr,
-	       pthreadDebugAddr_t buf,
-	       size_t size)
-{
-  if (trace_pthreaddbg)
-    TERM_FAO ("read_callback (!XH, !XH, !SL)!/", addr, buf, size);
-  ots$move (buf, size, addr);
-  return 0;
-}
-
-static int
-write_callback (pthreadDebugClient_t context,
-		pthreadDebugTargetAddr_t addr,
-		pthreadDebugLongConstAddr_t buf,
-		size_t size)
-{
-  if (trace_pthreaddbg)
-    TERM_FAO ("write_callback (!XH, !XH, !SL)!/", addr, buf, size);
-  ots$move (addr, size, buf);
-  return 0;
-}
-
-static int
-suspend_callback (pthreadDebugClient_t context)
-{
-  /* Always suspended.  */
-  return 0;
-}
-
-static int
-resume_callback (pthreadDebugClient_t context)
-{
-  /* So no need to resume.  */
-  return 0;
-}
-
-static int
-kthdinfo_callback (pthreadDebugClient_t context,
-		   pthreadDebugKId_t kid,
-		   pthreadDebugKThreadInfo_p thread_info)
-{
-  if (trace_pthreaddbg)
-    term_puts ("kthinfo_callback");
-  return ENOSYS;
-}
-
-static int
-hold_callback (pthreadDebugClient_t context,
-	       pthreadDebugKId_t kid)
-{
-  if (trace_pthreaddbg)
-    term_puts ("hold_callback");
-  return ENOSYS;
-}
-
-static int
-unhold_callback (pthreadDebugClient_t context,
-		 pthreadDebugKId_t kid)
-{
-  if (trace_pthreaddbg)
-    term_puts ("unhold_callback");
-  return ENOSYS;
-}
-
-static int
-getfreg_callback (pthreadDebugClient_t context,
-		  pthreadDebugFregs_t *reg,
-		  pthreadDebugKId_t kid)
-{
-  if (trace_pthreaddbg)
-    term_puts ("getfreg_callback");
-  return ENOSYS;
-}
-
-static int
-setfreg_callback (pthreadDebugClient_t context,
-		  const pthreadDebugFregs_t *reg,
-		  pthreadDebugKId_t kid)
-{
-  if (trace_pthreaddbg)
-    term_puts ("setfreg_callback");
-  return ENOSYS;
-}
-
-static int
-getreg_callback (pthreadDebugClient_t context,
-		 pthreadDebugRegs_t *reg,
-		 pthreadDebugKId_t kid)
-{
-  if (trace_pthreaddbg)
-    term_puts ("getreg_callback");
-  return ENOSYS;
-}
-
-static int
-setreg_callback (pthreadDebugClient_t context,
-		 const pthreadDebugRegs_t *reg,
-		 pthreadDebugKId_t kid)
-{
-  if (trace_pthreaddbg)
-    term_puts ("setreg_callback");
-  return ENOSYS;
-}
-
-static int
-output_callback (pthreadDebugClient_t context, 
-		 pthreadDebugConstString_t line)
-{
-  term_puts (line);
-  term_putnl ();
-  return 0;
-}
-
-static int
-error_callback (pthreadDebugClient_t context, 
-		 pthreadDebugConstString_t line)
-{
-  term_puts (line);
-  term_putnl ();
-  return 0;
-}
-
-static pthreadDebugAddr_t
-malloc_callback (pthreadDebugClient_t caller_context, size_t size)
-{
-  unsigned int status;
-  unsigned int res;
-  int len;
-
-  len = size + 16;
-  status = lib$get_vm (&len, &res, 0);
-  if (!(status & STS$M_SUCCESS))
-    LIB$SIGNAL (status);
-  if (trace_pthreaddbg)
-    TERM_FAO ("malloc_callback (!UL) -> !XA!/", size, res);
-  *(unsigned int *)res = len;
-  return (char *)res + 16;
-}
-
-static void
-free_callback (pthreadDebugClient_t caller_context, pthreadDebugAddr_t address)
-{
-  unsigned int status;
-  unsigned int res;
-  int len;
-
-  res = (unsigned int)address - 16;
-  len = *(unsigned int *)res;
-  if (trace_pthreaddbg)
-    TERM_FAO ("free_callback (!XA)!/", address);
-  status = lib$free_vm (&len, &res, 0);
-  if (!(status & STS$M_SUCCESS))
-    LIB$SIGNAL (status);
-}
-
-static int
-speckthd_callback (pthreadDebugClient_t caller_context,
-		   pthreadDebugSpecialType_t type,
-		   pthreadDebugKId_t *kernel_tid)
-{
-  return ENOTSUP;
-}
-
-static pthreadDebugCallbacks_t pthread_debug_callbacks = {
-  PTHREAD_DEBUG_VERSION,
-  read_callback,
-  write_callback,
-  suspend_callback,
-  resume_callback,
-  kthdinfo_callback,
-  hold_callback,
-  unhold_callback,
-  getfreg_callback,
-  setfreg_callback,
-  getreg_callback,
-  setreg_callback,
-  output_callback,
-  error_callback,
-  malloc_callback,
-  free_callback,
-  speckthd_callback
-};
-
-/* Name of the pthread shared library.  */
-static const $DESCRIPTOR (pthread_rtl_desc, "PTHREAD$RTL");
-
-/* List of symbols to extract from pthread debug library.  */
-struct pthread_debug_entry
-{
-  const unsigned int namelen;
-  const __char_ptr32 name;
-  __void_ptr32 func;
-};
-
-#define DEBUG_ENTRY(str) { sizeof(str) - 1, str, 0 }
-
-static struct pthread_debug_entry pthread_debug_entries[] = {
-  DEBUG_ENTRY("pthreadDebugContextInit"),
-  DEBUG_ENTRY("pthreadDebugThdSeqInit"),
-  DEBUG_ENTRY("pthreadDebugThdSeqNext"),
-  DEBUG_ENTRY("pthreadDebugThdSeqDestroy"),
-  DEBUG_ENTRY("pthreadDebugThdGetInfo"),
-  DEBUG_ENTRY("pthreadDebugThdGetInfoAddr"),
-  DEBUG_ENTRY("pthreadDebugThdGetReg"),
-  DEBUG_ENTRY("pthreadDebugCmd")
-};
-
-/* Pthread debug context.  */
-static pthreadDebugContext_t debug_context;
-
-/* Wrapper around pthread debug entry points.  */
-
-static int
-pthread_debug_thd_seq_init (pthreadDebugId_t *id)
-{
-  return ((int (*)())pthread_debug_entries[1].func)
-    (debug_context, id);
-}
-
-static int
-pthread_debug_thd_seq_next (pthreadDebugId_t *id)
-{
-  return ((int (*)())pthread_debug_entries[2].func)
-    (debug_context, id);
-}
-
-static int
-pthread_debug_thd_seq_destroy (void)
-{
-  return ((int (*)())pthread_debug_entries[3].func)
-    (debug_context);
-}
-
-static int
-pthread_debug_thd_get_info (pthreadDebugId_t id,
-			    pthreadDebugThreadInfo_t *info)
-{
-  return ((int (*)())pthread_debug_entries[4].func)
-    (debug_context, id, info);
-}
-
-static int
-pthread_debug_thd_get_info_addr (pthread_t thr,
-				 pthreadDebugThreadInfo_t *info)
-{
-  return ((int (*)())pthread_debug_entries[5].func)
-    (debug_context, thr, info);
-}
-
-static int
-pthread_debug_thd_get_reg (pthreadDebugId_t thr,
-			   pthreadDebugRegs_t *regs)
-{
-  return ((int (*)())pthread_debug_entries[6].func)
-    (debug_context, thr, regs);
-}
-
-static int
-stub_pthread_debug_cmd (const char *cmd)
-{
-  return ((int (*)())pthread_debug_entries[7].func)
-    (debug_context, cmd);
-}
-
-/* Show all the threads.  */
-
-static void
-threads_show (void)
-{
-  pthreadDebugId_t id;
-  pthreadDebugThreadInfo_t info;
-  int res;
-
-  res = pthread_debug_thd_seq_init (&id);
-  if (res != 0)
-    {
-      TERM_FAO ("seq init failed, res=!SL!/", res);
-      return;
-    }
-  while (1)
-    {
-      if (pthread_debug_thd_get_info (id, &info) != 0)
-	{
-	  TERM_FAO ("thd_get_info !SL failed!/", id);
-	  break;
-	}
-      if (pthread_debug_thd_seq_next (&id) != 0)
-	break;
-    }
-  pthread_debug_thd_seq_destroy ();
-}
-
-/* Initialize pthread support.  */
-
-static void
-threads_init (void)
-{
-  static const $DESCRIPTOR (dbgext_desc, "PTHREAD$DBGEXT");
-  static const $DESCRIPTOR (pthread_debug_desc, "PTHREAD$DBGSHR");
-  static const $DESCRIPTOR (dbgsymtable_desc, "PTHREAD_DBG_SYMTABLE");
-  int pthread_dbgext;
-  int status;
-  void *dbg_symtable;
-  int i;
-  void *caller_context = 0;
-
-  status = lib$find_image_symbol
-    ((void *) &pthread_rtl_desc, (void *) &dbgext_desc,
-     (int *) &dbgext_func);
-  if (!(status & STS$M_SUCCESS))
-    LIB$SIGNAL (status);
-  
-  status = lib$find_image_symbol
-    ((void *) &pthread_rtl_desc, (void *) &dbgsymtable_desc,
-     (int *) &dbg_symtable);
-  if (!(status & STS$M_SUCCESS))
-    LIB$SIGNAL (status);
-
-  /* Find entry points in pthread_debug.  */
-  for (i = 0;
-       i < sizeof (pthread_debug_entries) / sizeof (pthread_debug_entries[0]);
-       i++)
-    {
-      struct dsc$descriptor_s sym =
-	{ pthread_debug_entries[i].namelen,
-	  DSC$K_DTYPE_T, DSC$K_CLASS_S,
-	  pthread_debug_entries[i].name };
-      status = lib$find_image_symbol
-	((void *) &pthread_debug_desc, (void *) &sym,
-	 (int *) &pthread_debug_entries[i].func);
-      if (!(status & STS$M_SUCCESS))
-	lib$signal (status);
-    }
-
-  if (trace_pthreaddbg)
-    TERM_FAO ("debug symtable: !XH!/", dbg_symtable);
-  status = ((int (*)()) pthread_debug_entries[0].func)
-    (&caller_context, &pthread_debug_callbacks, dbg_symtable, &debug_context);
-  if (status != 0)
-    TERM_FAO ("cannot initialize pthread_debug: !UL!/", status);
-  TERM_FAO ("pthread debug done!/", 0);
-}
-
-/* Convert an hexadecimal character to a nibble.  Return -1 in case of
-   error.  */
-
-static int
-hex2nibble (unsigned char h)
-{
-  if (h >= '0' && h <= '9')
-    return h - '0';
-  if (h >= 'A' && h <= 'F')
-    return h - 'A' + 10;
-  if (h >= 'a' && h <= 'f')
-    return h - 'a' + 10;
-  return -1;
-}
-
-/* Convert an hexadecimal 2 character string to a byte.  Return -1 in case
-   of error.  */
-
-static int
-hex2byte (const unsigned char *p)
-{
-  int h, l;
-
-  h = hex2nibble (p[0]);
-  l = hex2nibble (p[1]);
-  if (h == -1 || l == -1)
-    return -1;
-  return (h << 4) | l;
-}
-
-/* Convert a byte V to a 2 character strings P.  */
-
-static void
-byte2hex (unsigned char *p, unsigned char v)
-{
-  p[0] = hex[v >> 4];
-  p[1] = hex[v & 0xf];
-}
-
-/* Convert a quadword V to a 16 character strings P.  */
-
-static void
-quad2hex (unsigned char *p, unsigned __int64 v)
-{
-  int i;
-  for (i = 0; i < 16; i++)
-    {
-      p[i] = hex[v >> 60];
-      v <<= 4;
-    }
-}
-
-static void
-long2pkt (unsigned int v)
-{
-  int i;
-
-  for (i = 0; i < 8; i++)
-    {
-      gdb_buf[gdb_blen + i] = hex[(v >> 28) & 0x0f];
-      v <<= 4;
-    }
-  gdb_blen += 8;
-}
-
-/* Generate an error packet.  */
-
-static void
-packet_error (unsigned int err)
-{
-  gdb_buf[1] = 'E';
-  byte2hex (gdb_buf + 2, err);
-  gdb_blen = 4;
-}
-
-/* Generate an OK packet.  */
-
-static void
-packet_ok (void)
-{
-  gdb_buf[1] = 'O';
-  gdb_buf[2] = 'K';
-  gdb_blen = 3;
-}
-
-/* Append a register to the packet.  */
-
-static void
-ireg2pkt (const unsigned char *p)
-{
-  int i;
-
-  for (i = 0; i < 8; i++)
-    {
-      byte2hex (gdb_buf + gdb_blen, p[i]);
-      gdb_blen += 2;
-    }
-}
-
-/* Append a C string (ASCIZ) to the packet.  */
-
-static void
-str2pkt (const char *str)
-{
-  while (*str)
-    gdb_buf[gdb_blen++] = *str++;
-}
-
-/* Extract a number fro the packet.  */
-
-static unsigned __int64
-pkt2val (const unsigned char *pkt, unsigned int *pos)
-{
-  unsigned __int64 res = 0;
-  unsigned int i;
-
-  while (1)
-    {
-      int r = hex2nibble (pkt[*pos]);
-
-      if (r < 0)
-	return res;
-      res = (res << 4) | r;
-      (*pos)++;
-    }
-}
-
-/* Append LEN bytes from B to the current gdb packet (encode in binary).  */
-
-static void
-mem2bin (const unsigned char *b, unsigned int len)
-{
-  unsigned int i;
-  for (i = 0; i < len; i++)
-    switch (b[i])
-      {
-      case '#':
-      case '$':
-      case '}':
-      case '*':
-      case 0:
-	gdb_buf[gdb_blen++] = '}';
-	gdb_buf[gdb_blen++] = b[i] ^ 0x20;
-	break;
-      default:
-	gdb_buf[gdb_blen++] = b[i];
-	break;
-      }
-}
-
-/* Append LEN bytes from B to the current gdb packet (encode in hex).  */
-
-static void
-mem2hex (const unsigned char *b, unsigned int len)
-{
-  unsigned int i;
-  for (i = 0; i < len; i++)
-    {
-      byte2hex (gdb_buf + gdb_blen, b[i]);
-      gdb_blen += 2;
-    }
-}
-
-/* Handle the 'q' packet.  */
-
-static void
-handle_q_packet (const unsigned char *pkt, unsigned int pktlen)
-{
-  /* For qfThreadInfo and qsThreadInfo.  */
-  static unsigned int first_thread;
-  static unsigned int last_thread;
-
-  static const char xfer_uib[] = "qXfer:uib:read:";
-#define XFER_UIB_LEN (sizeof (xfer_uib) - 1)
-  static const char qfthreadinfo[] = "qfThreadInfo";
-#define QFTHREADINFO_LEN (sizeof (qfthreadinfo) - 1)
-  static const char qsthreadinfo[] = "qsThreadInfo";
-#define QSTHREADINFO_LEN (sizeof (qsthreadinfo) - 1)
-  static const char qthreadextrainfo[] = "qThreadExtraInfo,";
-#define QTHREADEXTRAINFO_LEN (sizeof (qthreadextrainfo) - 1)
-  static const char qsupported[] = "qSupported:";
-#define QSUPPORTED_LEN (sizeof (qsupported) - 1)
-
-  if (pktlen == 2 && pkt[1] == 'C')
-    {
-      /* Current thread.  */
-      gdb_buf[0] = '$';
-      gdb_buf[1] = 'Q';
-      gdb_buf[2] = 'C';
-      gdb_blen = 3;
-      if (has_threads)
-	long2pkt ((unsigned long) get_teb ());
-      return;
-    }
-  else if (pktlen > XFER_UIB_LEN
-      && ots$strcmp_eql (pkt, XFER_UIB_LEN, xfer_uib, XFER_UIB_LEN))
-    {
-      /* Get unwind information block.  */
-      unsigned __int64 pc;
-      unsigned int pos = XFER_UIB_LEN;
-      unsigned int off;
-      unsigned int len;
-      union
-      {
-	unsigned char bytes[32];
-	struct
-	{
-	  unsigned __int64 code_start_va;
-	  unsigned __int64 code_end_va;
-	  unsigned __int64 uib_start_va;
-	  unsigned __int64 gp_value;
-	} data;
-      } uei;
-      int res;
-      int i;
-
-      packet_error (0);
-
-      pc = pkt2val (pkt, &pos);
-      if (pkt[pos] != ':')
-	return;
-      pos++;
-      off = pkt2val (pkt, &pos);
-      if (pkt[pos] != ',' || off != 0)
-	return;
-      pos++;
-      len = pkt2val (pkt, &pos);
-      if (pkt[pos] != '#' || len != 0x20)
-	return;
-
-      res = SYS$GET_UNWIND_ENTRY_INFO (pc, &uei.data, 0);
-      if (res == SS$_NODATA || res != SS$_NORMAL)
-	ots$fill (uei.bytes, sizeof (uei.bytes), 0);
-
-      if (trace_unwind)
-	{
-	  TERM_FAO ("Unwind request for !XH, status=!XL, uib=!XQ, GP=!XQ!/",
-		    pc, res, uei.data.uib_start_va, uei.data.gp_value);
-	}
-
-      gdb_buf[0] = '$';
-      gdb_buf[1] = 'l';
-      gdb_blen = 2;
-      mem2bin (uei.bytes, sizeof (uei.bytes));
-    }
-  else if (pktlen == QFTHREADINFO_LEN
-	   && ots$strcmp_eql (pkt, QFTHREADINFO_LEN,
-			      qfthreadinfo, QFTHREADINFO_LEN))
-    {
-      /* Get first thread(s).  */
-      gdb_buf[0] = '$';
-      gdb_buf[1] = 'm';
-      gdb_blen = 2;
-
-      if (!has_threads)
-	{
-	  gdb_buf[1] = 'l';
-	  return;
-	}
-      first_thread = thread_next (0);
-      last_thread = first_thread;
-      long2pkt (first_thread);
-    }
-  else if (pktlen == QSTHREADINFO_LEN
-	   && ots$strcmp_eql (pkt, QSTHREADINFO_LEN,
-			      qsthreadinfo, QSTHREADINFO_LEN))
-    {
-      /* Get subsequent threads.  */
-      gdb_buf[0] = '$';
-      gdb_buf[1] = 'm';
-      gdb_blen = 2;
-      while (dbgext_func)
-	{
-	  unsigned int res;
-	  res = thread_next (last_thread);
-	  if (res == first_thread)
-	    break;
-	  if (gdb_blen > 2)
-	    gdb_buf[gdb_blen++] = ',';
-	  long2pkt (res);
-	  last_thread = res;
-	  if (gdb_blen > sizeof (gdb_buf) - 16)
-	    break;
-	}
-
-      if (gdb_blen == 2)
-	gdb_buf[1] = 'l';
-    }
-  else if (pktlen > QTHREADEXTRAINFO_LEN
-	   && ots$strcmp_eql (pkt, QTHREADEXTRAINFO_LEN,
-			      qthreadextrainfo, QTHREADEXTRAINFO_LEN))
-    {
-      /* Get extra info about a thread.  */
-      pthread_t thr;
-      unsigned int pos = QTHREADEXTRAINFO_LEN;
-      pthreadDebugThreadInfo_t info;
-      int res;
-
-      packet_error (0);
-      if (!has_threads)
-	return;
-
-      thr = (pthread_t) pkt2val (pkt, &pos);
-      if (pkt[pos] != '#')
-	return;
-      res = pthread_debug_thd_get_info_addr (thr, &info);
-      if (res != 0)
-	{
-	  TERM_FAO ("qThreadExtraInfo (!XH) failed: !SL!/", thr, res);
-	  return;
-	}
-      gdb_buf[0] = '$';
-      gdb_blen = 1;
-      mem2hex ((const unsigned char *)"VMS-thread", 11);
-    }
-  else if (pktlen > QSUPPORTED_LEN
-	   && ots$strcmp_eql (pkt, QSUPPORTED_LEN,
-			      qsupported, QSUPPORTED_LEN))
-    {
-      /* Get supported features.  */
-      pthread_t thr;
-      unsigned int pos = QSUPPORTED_LEN;
-      pthreadDebugThreadInfo_t info;
-      int res;
-      
-      /* Ignore gdb features.  */
-      gdb_buf[0] = '$';
-      gdb_blen = 1;
-
-      str2pkt ("qXfer:uib:read+");
-      return;
-    }
-  else
-    {
-      if (trace_pkt)
-	{
-	  term_puts ("unknown <: ");
-	  term_write ((char *)pkt, pktlen);
-	  term_putnl ();
-	}
-      return;
-    }
-}
-
-/* Handle the 'v' packet.  */
-
-static int
-handle_v_packet (const unsigned char *pkt, unsigned int pktlen)
-{
-  static const char vcontq[] = "vCont?";
-#define VCONTQ_LEN (sizeof (vcontq) - 1)
-
-  if (pktlen == VCONTQ_LEN
-      && ots$strcmp_eql (pkt, VCONTQ_LEN, vcontq, VCONTQ_LEN))
-    {
-      gdb_buf[0] = '$';
-      gdb_blen = 1;
-
-      str2pkt ("vCont;c;s");
-      return 0;
-    }
-  else
-    {
-      if (trace_pkt)
-	{
-	  term_puts ("unknown <: ");
-	  term_write ((char *)pkt, pktlen);
-	  term_putnl ();
-	}
-      return 0;
-    }
-}
-
-/* Get regs for the selected thread.  */
-
-static struct ia64_all_regs *
-get_selected_regs (void)
-{
-  pthreadDebugRegs_t regs;
-  int res;
-
-  if (selected_thread == 0 || selected_thread == get_teb ())
-    return &excp_regs;
-
-  if (selected_thread == sel_regs_pthread)
-    return &sel_regs;
-
-  /* Read registers.  */
-  res = pthread_debug_thd_get_reg (selected_id, &regs);
-  if (res != 0)
-    {
-      /* FIXME: return NULL ?  */
-      return &excp_regs;
-    }
-  sel_regs_pthread = selected_thread;
-  sel_regs.gr[1].v = regs.gp;
-  sel_regs.gr[4].v = regs.r4;
-  sel_regs.gr[5].v = regs.r5;
-  sel_regs.gr[6].v = regs.r6;
-  sel_regs.gr[7].v = regs.r7;
-  sel_regs.gr[12].v = regs.sp;
-  sel_regs.br[0].v = regs.rp;
-  sel_regs.br[1].v = regs.b1;
-  sel_regs.br[2].v = regs.b2;
-  sel_regs.br[3].v = regs.b3;
-  sel_regs.br[4].v = regs.b4;
-  sel_regs.br[5].v = regs.b5;
-  sel_regs.ip.v = regs.ip;
-  sel_regs.bsp.v = regs.bspstore; /* FIXME: it is correct ?  */
-  sel_regs.pfs.v = regs.pfs;
-  sel_regs.pr.v = regs.pr;
-  return &sel_regs;
-}
-
-/* Create a status packet.  */
-
-static void
-packet_status (void)
-{
-  gdb_blen = 0;
-  if (has_threads)
-    {
-      str2pkt ("$T05thread:");
-      long2pkt ((unsigned long) get_teb ());
-      gdb_buf[gdb_blen++] = ';';
-    }
-  else
-    str2pkt ("$S05");
-}
-
-/* Return 1 to continue.  */
-
-static int
-handle_packet (unsigned char *pkt, unsigned int len)
-{
-  unsigned int pos;
-
-  /* By default, reply unsupported.  */
-  gdb_buf[0] = '$';
-  gdb_blen = 1;
-
-  pos = 1;
-  switch (pkt[0])
-    {
-    case '?':
-      if (len == 1)
-	{
-	  packet_status ();
-	  return 0;
-	}
-      break;
-    case 'c':
-      if (len == 1)
-	{
-	  /* Clear psr.ss.  */
-	  excp_regs.psr.v &= ~(unsigned __int64)PSR$M_SS;
-	  return 1;
-	}
-      else
-	packet_error (0);
-      break;
-    case 'g':
-      if (len == 1)
-	{
-	  unsigned int i;
-	  struct ia64_all_regs *regs = get_selected_regs ();
-	  unsigned char *p = regs->gr[0].b;
-
-	  for (i = 0; i < 8 * 32; i++)
-	    byte2hex (gdb_buf + 1 + 2 * i, p[i]);
-	  gdb_blen += 2 * 8 * 32;
-	  return 0;
-	}
-      break;
-    case 'H':
-      if (pkt[1] == 'g')
-	{
-	  int res;
-	  unsigned __int64 val;
-	  pthreadDebugThreadInfo_t info;
-	  
-	  pos++;
-	  val = pkt2val (pkt, &pos);
-	  if (pos != len)
-	    {
-	      packet_error (0);
-	      return 0;
-	    }
-	  if (val == 0)
-	    {
-	      /* Default one.  */
-	      selected_thread = get_teb ();
-	      selected_id = 0;
-	    }
-	  else if (!has_threads)
-	    {
-	      packet_error (0);
-	      return 0;
-	    }
-	  else
-	    {
-	      res = pthread_debug_thd_get_info_addr ((pthread_t) val, &info);
-	      if (res != 0)
-		{
-		  TERM_FAO ("qThreadExtraInfo (!XH) failed: !SL!/", val, res);
-		  packet_error (0);
-		  return 0;
-		}
-	      selected_thread = info.teb;
-	      selected_id = info.sequence;
-	    }
-	  packet_ok ();
-	  break;
-	}
-      else if (pkt[1] == 'c'
-	       && ((pkt[2] == '-' && pkt[3] == '1' && len == 4)
-		   || (pkt[2] == '0' && len == 3)))
-	{
-	  /* Silently accept 'Hc0' and 'Hc-1'.  */
-	  packet_ok ();
-	  break;
-	}
-      else
-	{
-	  packet_error (0);
-	  return 0;
-	}
-    case 'k':
-      SYS$EXIT (SS$_NORMAL);
-      break;
-    case 'm':
-      {
-	unsigned __int64 addr;
-	unsigned __int64 paddr;
-	unsigned int l;
-	unsigned int i;
-
-	addr = pkt2val (pkt, &pos);
-	if (pkt[pos] != ',')
-	  {
-	    packet_error (0);
-	    return 0;
-	  }
-	pos++;
-	l = pkt2val (pkt, &pos);
-	if (pkt[pos] != '#')
-	  {
-	    packet_error (0);
-	    return 0;
-	  }
-
-	/* Check access.  */
-	i = l + (addr & VMS_PAGE_MASK);
-	paddr = addr & ~VMS_PAGE_MASK;
-	while (1)
-	  {
-	    if (__prober (paddr, 0) != 1)
-	      {
-		packet_error (2);
-		return 0;
-	      }
-	    if (i < VMS_PAGE_SIZE)
-	      break;
-	    i -= VMS_PAGE_SIZE;
-	    paddr += VMS_PAGE_SIZE;
-	  }
-
-	/* Transfer.  */
-	for (i = 0; i < l; i++)
-	  byte2hex (gdb_buf + 1 + 2 * i, ((unsigned char *)addr)[i]);
-	gdb_blen += 2 * l;
-      }
-      break;
-    case 'M':
-      {
-	unsigned __int64 addr;
-	unsigned __int64 paddr;
-	unsigned int l;
-	unsigned int i;
-	unsigned int oldprot;
-
-	addr = pkt2val (pkt, &pos);
-	if (pkt[pos] != ',')
-	  {
-	    packet_error (0);
-	    return 0;
-	  }
-	pos++;
-	l = pkt2val (pkt, &pos);
-	if (pkt[pos] != ':')
-	  {
-	    packet_error (0);
-	    return 0;
-	  }
-	pos++;
-	page_set_rw (addr, l, &oldprot);
-
-	/* Check access.  */
-	i = l + (addr & VMS_PAGE_MASK);
-	paddr = addr & ~VMS_PAGE_MASK;
-	while (1)
-	  {
-	    if (__probew (paddr, 0) != 1)
-	      {
-		page_restore_rw (addr, l, oldprot);
-		return 0;
-	      }
-	    if (i < VMS_PAGE_SIZE)
-	      break;
-	    i -= VMS_PAGE_SIZE;
-	    paddr += VMS_PAGE_SIZE;
-	  }
-
-	/* Write.  */
-	for (i = 0; i < l; i++)
-	  {
-	    int v = hex2byte (pkt + pos);
-	    pos += 2;
-	    ((unsigned char *)addr)[i] = v;
-	  }
-
-	/* Sync caches.  */
-	for (i = 0; i < l; i += 15)
-	  __fc (addr + i);
-	__fc (addr + l);
-
-	page_restore_rw (addr, l, oldprot);
-	packet_ok ();
-      }
-      break;
-    case 'p':
-      {
-	unsigned int num = 0;
-	unsigned int i;
-	struct ia64_all_regs *regs = get_selected_regs ();
-
-	num = pkt2val (pkt, &pos);
-	if (pos != len)
-	  {
-	    packet_error (0);
-	    return 0;
-	  }
-
-	switch (num)
-	  {
-	  case IA64_IP_REGNUM:
-	    ireg2pkt (regs->ip.b);
-	    break;
-	  case IA64_BR0_REGNUM:
-	    ireg2pkt (regs->br[0].b);
-	    break;
-	  case IA64_PSR_REGNUM:
-	    ireg2pkt (regs->psr.b);
-	    break;
-	  case IA64_BSP_REGNUM:
-	    ireg2pkt (regs->bsp.b);
-	    break;
-	  case IA64_CFM_REGNUM:
-	    ireg2pkt (regs->cfm.b);
-	    break;
-	  case IA64_PFS_REGNUM:
-	    ireg2pkt (regs->pfs.b);
-	    break;
-	  case IA64_PR_REGNUM:
-	    ireg2pkt (regs->pr.b);
-	    break;
-	  default:
-	    TERM_FAO ("gdbserv: unhandled reg !UW!/", num);
-	    packet_error (0);
-	    return 0;
-	  }
-      }
-      break;
-    case 'q':
-      handle_q_packet (pkt, len);
-      break;
-    case 's':
-      if (len == 1)
-	{
-	  /* Set psr.ss.  */
-	  excp_regs.psr.v |= (unsigned __int64)PSR$M_SS;
-	  return 1;
-	}
-      else
-	packet_error (0);
-      break;
-    case 'T':
-      /* Thread status.  */
-      if (!has_threads)
-	{
-	  packet_ok ();
-	  break;
-	}
-      else
-	{
-	  int res;
-	  unsigned __int64 val;
-	  unsigned int fthr, thr;
-	  
-	  val = pkt2val (pkt, &pos);
-	  /* Default is error (but only after parsing is complete).  */
-	  packet_error (0);
-	  if (pos != len)
-	    break;
-
-	  /* Follow the list.  This makes a O(n2) algorithm, but we don't really
-	     have the choice.  Note that pthread_debug_thd_get_info_addr
-	     doesn't look reliable.  */
-	  fthr = thread_next (0);
-	  thr = fthr;
-	  do
-	    {
-	      if (val == thr)
-		{
-		  packet_ok ();
-		  break;
-		}
-	      thr = thread_next (thr);
-	    }
-	  while (thr != fthr);
-	}
-      break;
-    case 'v':
-      return handle_v_packet (pkt, len);
-      break;
-    case 'V':
-      if (len > 3 && pkt[1] == 'M' && pkt[2] == 'S' && pkt[3] == ' ')
-	{
-	  /* Temporary extension.  */
-	  if (has_threads)
-	    {
-	      pkt[len] = 0;
-	      stub_pthread_debug_cmd ((char *)pkt + 4);
-	      packet_ok ();
-	    }
-	  else
-	    packet_error (0);
-	}
-      break;
-    default:
-      if (trace_pkt)
-	{
-	  term_puts ("unknown <: ");
-	  term_write ((char *)pkt, len);
-	  term_putnl ();
-	}
-      break;
-    }
-  return 0;
-}
-
-/* Raw write to gdb.  */
-
-static void
-sock_write (const unsigned char *buf, int len)
-{
-  struct _iosb iosb;
-  unsigned int status;
-
-  /* Write data to connection.  */
-  status = sys$qiow (EFN$C_ENF,           /* Event flag.  */
-		     conn_channel,        /* I/O channel.  */
-		     IO$_WRITEVBLK,       /* I/O function code.  */
-		     &iosb,               /* I/O status block.  */
-		     0,                   /* Ast service routine.  */
-		     0,                   /* Ast parameter.  */
-		     (char *)buf,         /* P1 - buffer address.  */
-		     len,                 /* P2 - buffer length.  */
-		     0, 0, 0, 0);
-  if (status & STS$M_SUCCESS)
-    status = iosb.iosb$w_status;
-  if (!(status & STS$M_SUCCESS))
-    {
-      term_puts ("Failed to write data to gdb\n");
-      LIB$SIGNAL (status);
-    }
-}
-
-/* Compute the checksum and send the packet.  */
-
-static void
-send_pkt (void)
-{
-  unsigned char chksum = 0;
-  unsigned int i;
-
-  for (i = 1; i < gdb_blen; i++)
-    chksum += gdb_buf[i];
-
-  gdb_buf[gdb_blen] = '#';
-  byte2hex (gdb_buf + gdb_blen + 1, chksum);
-
-  sock_write (gdb_buf, gdb_blen + 3);
-
-  if (trace_pkt > 1)
-    {
-      term_puts (">: ");
-      term_write ((char *)gdb_buf, gdb_blen + 3);
-      term_putnl ();
-    }
-}
-
-/* Read and handle one command.  Return 1 is execution must resume.  */
-
-static int
-one_command (void)
-{
-  struct _iosb iosb;
-  unsigned int status;
-  unsigned int off;
-  unsigned int dollar_off = 0;
-  unsigned int sharp_off = 0;
-  unsigned int cmd_off;
-  unsigned int cmd_len;
-
-  /* Wait for a packet.  */
-  while (1)
-    {
-      off = 0;
-      while (1)
-	{
-	  /* Read data from connection.  */
-	  status = sys$qiow (EFN$C_ENF,           /* Event flag.  */
-			     conn_channel,        /* I/O channel.  */
-			     IO$_READVBLK,        /* I/O function code.  */
-			     &iosb,               /* I/O status block.  */
-			     0,                   /* Ast service routine.  */
-			     0,                   /* Ast parameter.  */
-			     gdb_buf + off,       /* P1 - buffer address.  */
-			     sizeof (gdb_buf) - off, /* P2 - buffer leng.  */
-			     0, 0, 0, 0);
-	  if (status & STS$M_SUCCESS)
-	    status = iosb.iosb$w_status;
-	  if (!(status & STS$M_SUCCESS))
-	    {
-	      term_puts ("Failed to read data from connection\n" );
-	      LIB$SIGNAL (status);
-	    }
-
-#ifdef RAW_DUMP
-	  term_puts ("{: ");
-	  term_write ((char *)gdb_buf + off, iosb.iosb$w_bcnt);
-	  term_putnl ();
-#endif
-
-	  gdb_blen = off + iosb.iosb$w_bcnt;
-
-	  if (off == 0)
-	    {
-	      /* Search for '$'.  */
-	      for (dollar_off = 0; dollar_off < gdb_blen; dollar_off++)
-		if (gdb_buf[dollar_off] == '$')
-		  break;
-	      if (dollar_off >= gdb_blen)
-		{
-		  /* Not found, discard the data.  */
-		  off = 0;
-		  continue;
-		}
-	      /* Search for '#'.  */
-	      for (sharp_off = dollar_off + 1;
-		   sharp_off < gdb_blen;
-		   sharp_off++)
-		if (gdb_buf[sharp_off] == '#')
-		  break;
-	    }
-	  else if (sharp_off >= off)
-	    {
-	      /* Search for '#'.  */
-	      for (; sharp_off < gdb_blen; sharp_off++)
-		if (gdb_buf[sharp_off] == '#')
-		  break;
-	    }
-
-	  /* Got packet with checksum.  */
-	  if (sharp_off + 2 <= gdb_blen)
-	    break;
-
-	  off = gdb_blen;
-	  if (gdb_blen == sizeof (gdb_buf))
-	    {
-	      /* Packet too large, discard.  */
-	      off = 0;
-	    }
-	}
-
-      /* Validate and acknowledge a packet.  */
-      {
-	unsigned char chksum = 0;
-	unsigned int i;
-	int v;
-
-	for (i = dollar_off + 1; i < sharp_off; i++)
-	  chksum += gdb_buf[i];
-	v = hex2byte (gdb_buf + sharp_off + 1);
-	if (v != chksum)
-	  {
-	    term_puts ("Discard bad checksum packet\n");
-	    continue;
-	  }
-	else
-	  {
-	    sock_write ((const unsigned char *)"+", 1);
-	    break;
-	  }
-      }
-    }
-
-  if (trace_pkt > 1)
-    {
-      term_puts ("<: ");
-      term_write ((char *)gdb_buf + dollar_off, sharp_off - dollar_off + 1);
-      term_putnl ();
-    }
-
-  cmd_off = dollar_off + 1;
-  cmd_len = sharp_off - dollar_off - 1;
-
-  if (handle_packet (gdb_buf + dollar_off + 1, sharp_off - dollar_off - 1) == 1)
-    return 1;
-
-  send_pkt ();
-  return 0;
-}
-
-/* Display the condition given by SIG64.  */
-
-static void
-display_excp (struct chf64$signal_array *sig64, struct chf$mech_array *mech)
-{
-  unsigned int status;
-  char msg[160];
-  unsigned short msglen;
-  $DESCRIPTOR (msg_desc, msg);
-  unsigned char outadr[4];
-
-  status = SYS$GETMSG (sig64->chf64$q_sig_name, &msglen, &msg_desc, 0, outadr);
-  if (status & STS$M_SUCCESS)
-    {
-      char msg2[160];
-      unsigned short msg2len;
-      struct dsc$descriptor_s msg2_desc =
-	{ sizeof (msg2), DSC$K_DTYPE_T, DSC$K_CLASS_S, msg2};
-      msg_desc.dsc$w_length = msglen;
-      status = SYS$FAOL_64 (&msg_desc, &msg2len, &msg2_desc,
-			    &sig64->chf64$q_sig_arg1);
-      if (status & STS$M_SUCCESS)
-	term_write (msg2, msg2len);
-    }
-  else
-    term_puts ("no message");
-  term_putnl ();
-
-  if (trace_excp > 1)
-    {
-      TERM_FAO (" Frame: !XH, Depth: !4SL, Esf: !XH!/",
-		mech->chf$q_mch_frame, mech->chf$q_mch_depth,
-		mech->chf$q_mch_esf_addr);
-    }
-}
-
-/* Get all registers from current thread.  */
-
-static void
-read_all_registers (struct chf$mech_array *mech)
-{
-  struct _intstk *intstk =
-    (struct _intstk *)mech->chf$q_mch_esf_addr;
-  struct chf64$signal_array *sig64 =
-    (struct chf64$signal_array *)mech->chf$ph_mch_sig64_addr;
-  unsigned int cnt = sig64->chf64$w_sig_arg_count;
-  unsigned __int64 pc = (&sig64->chf64$q_sig_name)[cnt - 2];
-
-  excp_regs.ip.v = pc;
-  excp_regs.psr.v = intstk->intstk$q_ipsr;
-  /* GDB and linux expects bsp to point after the current register frame.
-     Adjust.  */
-  {
-    unsigned __int64 bsp = intstk->intstk$q_bsp;
-    unsigned int sof = intstk->intstk$q_ifs & 0x7f;
-    unsigned int delta = ((bsp >> 3) & 0x3f) + sof;
-    excp_regs.bsp.v = bsp + ((sof + delta / 0x3f) << 3);
-  }
-  excp_regs.cfm.v = intstk->intstk$q_ifs & 0x3fffffffff;
-  excp_regs.pfs.v = intstk->intstk$q_pfs;
-  excp_regs.pr.v = intstk->intstk$q_preds;
-  excp_regs.gr[0].v = 0;
-  excp_regs.gr[1].v = intstk->intstk$q_gp;
-  excp_regs.gr[2].v = intstk->intstk$q_r2;
-  excp_regs.gr[3].v = intstk->intstk$q_r3;
-  excp_regs.gr[4].v = intstk->intstk$q_r4;
-  excp_regs.gr[5].v = intstk->intstk$q_r5;
-  excp_regs.gr[6].v = intstk->intstk$q_r6;
-  excp_regs.gr[7].v = intstk->intstk$q_r7;
-  excp_regs.gr[8].v = intstk->intstk$q_r8;
-  excp_regs.gr[9].v = intstk->intstk$q_r9;
-  excp_regs.gr[10].v = intstk->intstk$q_r10;
-  excp_regs.gr[11].v = intstk->intstk$q_r11;
-  excp_regs.gr[12].v = (unsigned __int64)intstk + intstk->intstk$l_stkalign;
-  excp_regs.gr[13].v = intstk->intstk$q_r13;
-  excp_regs.gr[14].v = intstk->intstk$q_r14;
-  excp_regs.gr[15].v = intstk->intstk$q_r15;
-  excp_regs.gr[16].v = intstk->intstk$q_r16;
-  excp_regs.gr[17].v = intstk->intstk$q_r17;
-  excp_regs.gr[18].v = intstk->intstk$q_r18;
-  excp_regs.gr[19].v = intstk->intstk$q_r19;
-  excp_regs.gr[20].v = intstk->intstk$q_r20;
-  excp_regs.gr[21].v = intstk->intstk$q_r21;
-  excp_regs.gr[22].v = intstk->intstk$q_r22;
-  excp_regs.gr[23].v = intstk->intstk$q_r23;
-  excp_regs.gr[24].v = intstk->intstk$q_r24;
-  excp_regs.gr[25].v = intstk->intstk$q_r25;
-  excp_regs.gr[26].v = intstk->intstk$q_r26;
-  excp_regs.gr[27].v = intstk->intstk$q_r27;
-  excp_regs.gr[28].v = intstk->intstk$q_r28;
-  excp_regs.gr[29].v = intstk->intstk$q_r29;
-  excp_regs.gr[30].v = intstk->intstk$q_r30;
-  excp_regs.gr[31].v = intstk->intstk$q_r31;
-  excp_regs.br[0].v = intstk->intstk$q_b0;
-  excp_regs.br[1].v = intstk->intstk$q_b1;
-  excp_regs.br[2].v = intstk->intstk$q_b2;
-  excp_regs.br[3].v = intstk->intstk$q_b3;
-  excp_regs.br[4].v = intstk->intstk$q_b4;
-  excp_regs.br[5].v = intstk->intstk$q_b5;
-  excp_regs.br[6].v = intstk->intstk$q_b6;
-  excp_regs.br[7].v = intstk->intstk$q_b7;
-}
-
-/* Write all registers to current thread.  FIXME: not yet complete.  */
-
-static void
-write_all_registers (struct chf$mech_array *mech)
-{
-  struct _intstk *intstk =
-    (struct _intstk *)mech->chf$q_mch_esf_addr;
-
-  intstk->intstk$q_ipsr = excp_regs.psr.v;
-}
-
-/* Do debugging.  Report status to gdb and execute commands.  */
-
-static void
-do_debug (struct chf$mech_array *mech)
-{
-  struct _intstk *intstk =
-    (struct _intstk *)mech->chf$q_mch_esf_addr;
-  unsigned int old_ast;
-  unsigned int old_sch;
-  unsigned int status;
-
-  /* Disable ast.  */
-  status = sys$setast (0);
-  switch (status)
-    {
-    case SS$_WASCLR:
-      old_ast = 0;
-      break;
-    case SS$_WASSET:
-      old_ast = 1;
-      break;
-    default:
-      /* Should never happen!  */
-      lib$signal (status);
-    }
-
-  /* Disable thread scheduling.  */
-  if (has_threads)
-    old_sch = set_thread_scheduling (0);
-
-  read_all_registers (mech);
-
-  /* Send stop reply packet.  */
-  packet_status ();
-  send_pkt ();
-
-  while (one_command () == 0)
-    ;
-
-  write_all_registers (mech);
-
-  /* Re-enable scheduling.  */
-  if (has_threads)
-    set_thread_scheduling (old_sch);
-
-  /* Re-enable AST.  */
-  status = sys$setast (old_ast);
-  if (!(status & STS$M_SUCCESS))
-    LIB$SIGNAL (status);
-}
-
-/* The condition handler.  That's the core of the stub.  */
-
-static int
-excp_handler (struct chf$signal_array *sig,
-	      struct chf$mech_array *mech)
-{
-  struct chf64$signal_array *sig64 =
-    (struct chf64$signal_array *)mech->chf$ph_mch_sig64_addr;
-  unsigned int code = sig->chf$l_sig_name & STS$M_COND_ID;
-  unsigned int cnt = sig64->chf64$w_sig_arg_count;
-  unsigned __int64 pc;
-  unsigned int ret;
-  /* Self protection.  FIXME: Should be per thread ?  */
-  static int in_handler = 0;
-
-  /* Completely ignore some conditions (signaled indirectly by this stub).  */
-  switch (code)
-    {
-    case LIB$_KEYNOTFOU & STS$M_COND_ID:
-      return SS$_RESIGNAL_64;
-    default:
-      break;
-    }
-
-  /* Protect against recursion.  */
-  in_handler++;
-  if (in_handler > 1)
-    {
-      if (in_handler == 2)
-	TERM_FAO ("gdbstub: exception in handler (pc=!XH)!!!/",
-		  (&sig64->chf64$q_sig_name)[cnt - 2]);
-      sys$exit (sig->chf$l_sig_name);
-    }
-
-  pc = (&sig64->chf64$q_sig_name)[cnt - 2];
-  if (trace_excp)
-    TERM_FAO ("excp_handler: code: !XL, pc=!XH!/", code, pc);
-
-  /* If break on the entry point, restore the bundle.  */
-  if (code == (SS$_BREAK & STS$M_COND_ID)
-      && pc == entry_pc
-      && entry_pc != 0)
-    {
-      static unsigned int entry_prot;
-
-      if (trace_entry)
-	term_puts ("initial entry breakpoint\n");
-      page_set_rw (entry_pc, 16, &entry_prot);
-
-      ots$move ((void *)entry_pc, 16, entry_saved);
-      __fc (entry_pc);
-      page_restore_rw (entry_pc, 16, entry_prot);
-    }
-
-  switch (code)
-    {
-    case SS$_ACCVIO & STS$M_COND_ID:
-      if (trace_excp <= 1)
-	display_excp (sig64, mech);
-      /* Fall through.  */
-    case SS$_BREAK  & STS$M_COND_ID:
-    case SS$_OPCDEC & STS$M_COND_ID:
-    case SS$_TBIT   & STS$M_COND_ID:
-    case SS$_DEBUG  & STS$M_COND_ID:
-      if (trace_excp > 1)
-	{
-	  int i;
-	  struct _intstk *intstk =
-	    (struct _intstk *)mech->chf$q_mch_esf_addr;
-
-	  display_excp (sig64, mech);
-
-	  TERM_FAO (" intstk: !XH!/", intstk);
-	  for (i = 0; i < cnt + 1; i++)
-	    TERM_FAO ("   !XH!/", ((unsigned __int64 *)sig64)[i]);
-	}
-      do_debug (mech);
-      ret = SS$_CONTINUE_64;
-      break;
-
-    default:
-      display_excp (sig64, mech);
-      ret = SS$_RESIGNAL_64;
-      break;
-    }
-
-  in_handler--;
-  /* Discard selected thread registers.  */
-  sel_regs_pthread = 0;
-  return ret;
-}
-
-/* Setup internal trace flags according to GDBSTUB$TRACE logical.  */
-
-static void
-trace_init (void)
-{
-  unsigned int status, i, start;
-  unsigned short len;
-  char resstring[LNM$C_NAMLENGTH];
-  static const $DESCRIPTOR (tabdesc, "LNM$DCL_LOGICAL");
-  static const $DESCRIPTOR (logdesc, "GDBSTUB$TRACE");
-  $DESCRIPTOR (sub_desc, resstring);
-  ILE3 item_lst[2];
-
-  item_lst[0].ile3$w_length = LNM$C_NAMLENGTH;
-  item_lst[0].ile3$w_code = LNM$_STRING;
-  item_lst[0].ile3$ps_bufaddr = resstring;
-  item_lst[0].ile3$ps_retlen_addr = &len;
-  item_lst[1].ile3$w_length = 0;
-  item_lst[1].ile3$w_code = 0;
-
-  /* Translate the logical name.  */
-  status = SYS$TRNLNM (0,   		/* Attributes of the logical name.  */
-		       (void *)&tabdesc,       /* Logical name table.  */
-		       (void *)&logdesc,       /* Logical name.  */
-		       0,              	       /* Access mode.  */
-		       &item_lst);             /* Item list.  */
-  if (status == SS$_NOLOGNAM)
-    return;
-  if (!(status & STS$M_SUCCESS))
-    LIB$SIGNAL (status);
-
-  start = 0;
-  for (i = 0; i <= len; i++)
-    {
-      if ((i == len || resstring[i] == ',' || resstring[i] == ';')
-	  && i != start)
-	{
-	  int j;
-
-	  sub_desc.dsc$a_pointer = resstring + start;
-	  sub_desc.dsc$w_length = i - start;
-
-	  for (j = 0; j < NBR_DEBUG_FLAGS; j++)
-	    if (str$case_blind_compare (&sub_desc, 
-					(void *)&debug_flags[j].name) == 0)
-	      {
-		debug_flags[j].val++;
-		break;
-	      }
-	  if (j == NBR_DEBUG_FLAGS)
-	    TERM_FAO ("GDBSTUB$TRACE: unknown directive !AS!/", &sub_desc);
-
-	  start = i + 1;
-	}
-    }
-
-  TERM_FAO ("GDBSTUB$TRACE=!AD ->", len, resstring);
-  for (i = 0; i < NBR_DEBUG_FLAGS; i++)
-    if (debug_flags[i].val > 0)
-      TERM_FAO (" !AS=!ZL", &debug_flags[i].name, debug_flags[i].val);
-  term_putnl ();
-}
-
-
-/* Entry point.  */
-
-static int
-stub_start (unsigned __int64 *progxfer, void *cli_util,
-	    EIHD *imghdr, IFD *imgfile,
-	    unsigned int linkflag, unsigned int cliflag)
-{
-  static int initialized;
-  int i;
-  int cnt;
-  int is_attached;
-  IMCB *imcb;
-  if (initialized)
-    term_puts ("gdbstub: re-entry\n");
-  else
-    initialized = 1;
-
-  /* When attached (through SS$_DEBUG condition), the number of arguments
-     is 4 and PROGXFER is the PC at interruption.  */
-  va_count (cnt);
-  is_attached = cnt == 4;
-
-  term_init ();
-
-  /* Hello banner.  */
-  term_puts ("Hello from gdb stub\n");
-
-  trace_init ();
-
-  if (trace_entry && !is_attached)
-    {
-      TERM_FAO ("xfer: !XH, imghdr: !XH, ifd: !XH!/",
-		progxfer, imghdr, imgfile);
-      for (i = -2; i < 8; i++)
-	TERM_FAO ("  at !2SW: !XH!/", i, progxfer[i]);
-    }
-
-  /* Search for entry point.  */
-  if (!is_attached)
-    {
-      entry_pc = 0;
-      for (i = 0; progxfer[i]; i++)
-	entry_pc = progxfer[i];
-
-      if (trace_entry)
-	{
-	  if (entry_pc == 0)
-	    {
-	      term_puts ("No entry point\n");
-	      return 0;
-	    }
-	  else
-	    TERM_FAO ("Entry: !XH!/",entry_pc);
-	}
-    }
-  else
-    entry_pc = progxfer[0];
-
-  has_threads = 0;
-  for (imcb = ctl$gl_imglstptr->imcb$l_flink;
-       imcb != ctl$gl_imglstptr;
-       imcb = imcb->imcb$l_flink)
-    {
-      if (ots$strcmp_eql (pthread_rtl_desc.dsc$a_pointer,
-			  pthread_rtl_desc.dsc$w_length,
-			  imcb->imcb$t_log_image_name + 1,
-			  imcb->imcb$t_log_image_name[0]))
-	has_threads = 1;
-			  
-      if (trace_images)
-	{
-	  unsigned int j;
-	  LDRIMG *ldrimg = imcb->imcb$l_ldrimg;
-	  LDRISD *ldrisd;
-
-	  TERM_FAO ("!XA-!XA ",
-		    imcb->imcb$l_starting_address,
-		    imcb->imcb$l_end_address);
-
-	  switch (imcb->imcb$b_act_code)
-	    {
-	    case IMCB$K_MAIN_PROGRAM:
-	      term_puts ("prog");
-	      break;
-	    case IMCB$K_MERGED_IMAGE:
-	      term_puts ("mrge");
-	      break;
-	    case IMCB$K_GLOBAL_IMAGE_SECTION:
-	      term_puts ("glob");
-	      break;
-	    default:
-	      term_puts ("????");
-	    }
-	  TERM_FAO (" !AD !40AC!/",
-		    1, "KESU" + (imcb->imcb$b_access_mode & 3),
-		    imcb->imcb$t_log_image_name);
-
-	  if ((long) ldrimg < 0 || trace_images < 2)
-	    continue;
-	  ldrisd = ldrimg->ldrimg$l_segments;
-	  for (j = 0; j < ldrimg->ldrimg$l_segcount; j++)
-	    {
-	      unsigned int flags = ldrisd[j].ldrisd$i_flags;
-	      term_puts ("   ");
-	      term_putc (flags & 0x04 ? 'R' : '-');
-	      term_putc (flags & 0x02 ? 'W' : '-');
-	      term_putc (flags & 0x01 ? 'X' : '-');
-	      term_puts (flags & 0x01000000 ? " Prot" : "     ");
-	      term_puts (flags & 0x04000000 ? " Shrt" : "     ");
-	      term_puts (flags & 0x08000000 ? " Shrd" : "     ");
-	      TERM_FAO (" !XA-!XA!/",
-			ldrisd[j].ldrisd$p_base,
-			(unsigned __int64) ldrisd[j].ldrisd$p_base 
-			+ ldrisd[j].ldrisd$i_len - 1);
-	    }
-	  ldrisd = ldrimg->ldrimg$l_dyn_seg;
-	  if (ldrisd)
-	    TERM_FAO ("   dynamic            !XA-!XA!/",
-		      ldrisd->ldrisd$p_base,
-		      (unsigned __int64) ldrisd->ldrisd$p_base 
-		      + ldrisd->ldrisd$i_len - 1);
-	}
-    }
-
-  if (has_threads)
-    threads_init ();
-
-  /* Wait for connection.  */
-  sock_init ();
-
-  /* Set primary exception vector.  */
-  {
-    unsigned int status;
-    status = sys$setexv (0, excp_handler, PSL$C_USER, (__void_ptr32) &prevhnd);
-    if (!(status & STS$M_SUCCESS))
-      LIB$SIGNAL (status);
-  }
-
-  if (is_attached)
-    {
-      return excp_handler ((struct chf$signal_array *) progxfer[2],
-			   (struct chf$mech_array *) progxfer[3]);
-    }
-
-  /* Change first instruction to set a breakpoint.  */
-  {
-    /*
-      01 08 00 40 00 00 	[MII]       break.m 0x80001
-      00 00 00 02 00 00 	            nop.i 0x0
-      00 00 04 00       	            nop.i 0x0;;
-    */
-    static const unsigned char initbp[16] =
-      { 0x01, 0x08, 0x00, 0x40, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
-	0x00, 0x00, 0x04, 0x00 };
-    unsigned int entry_prot;
-    unsigned int status;
-    
-    status = page_set_rw (entry_pc, 16, &entry_prot);
-
-    if (!(status & STS$M_SUCCESS))
-      {
-	if ((status & STS$M_COND_ID) == (SS$_NOT_PROCESS_VA & STS$M_COND_ID))
-	  {
-	    /* Cannot write here.  This can happen when pthreads are
-	       used.  */
-	    entry_pc = 0;
-	    term_puts ("gdbstub: cannot set breakpoint on entry\n");
-	  }
-	else
-	  LIB$SIGNAL (status);
-      }
-    
-    if (entry_pc != 0)
-      {
-	ots$move (entry_saved, 16, (void *)entry_pc);
-	ots$move ((void *)entry_pc, 16, (void *)initbp);
-	__fc (entry_pc);
-	page_restore_rw (entry_pc, 16, entry_prot);
-      }
-  }
-
-  /* If it wasn't possible to set a breakpoint on the entry point,
-     accept gdb commands now.  Note that registers are not updated.  */
-  if (entry_pc == 0)
-    {
-      while (one_command () == 0)
-	;
-    }
-
-  /* We will see!  */
-  return SS$_CONTINUE;
-}
-
-/* Declare the entry point of this relocatable module.  */
-
-struct xfer_vector
-{
-  __int64 impure_start;
-  __int64 impure_end;
-  int (*entry) ();
-};
-
-#pragma __extern_model save
-#pragma __extern_model strict_refdef "XFER_PSECT"
-struct xfer_vector xfer_vector = {0, 0, stub_start};
-#pragma __extern_model restore
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 58648a8779d..bc926ee3021 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4040,10 +4040,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
    while not getting into the function body.
 
    The functions end point and an increasing SAL line are used as
-   indicators of the prologue's endpoint.
-
-   This code is based on the function refine_prologue_limit
-   (found in ia64).  */
+   indicators of the prologue's endpoint.  */
 
 CORE_ADDR
 skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
diff --git a/gdb/target.h b/gdb/target.h
index 394e377d034..9d88ee00ffa 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -154,8 +154,6 @@ enum target_object
   /* Memory known to be part of the target code.   This is cached even
      if it is not in a region marked as such.  */
   TARGET_OBJECT_CODE_MEMORY,
-  /* Kernel Unwind Table.  See "ia64-tdep.c".  */
-  TARGET_OBJECT_UNWIND_TABLE,
   /* Transfer auxilliary vector.  */
   TARGET_OBJECT_AUXV,
   /* StackGhost cookie.  See "sparc-tdep.c".  */
diff --git a/gdb/testsuite/configure b/gdb/testsuite/configure
index 3b0d4ed8ad3..7d6e9e8b8dd 100755
--- a/gdb/testsuite/configure
+++ b/gdb/testsuite/configure
@@ -2229,9 +2229,7 @@ else
   # The following exceptions are taken from Libtool 1.4.3.
   case $host_os in
     aix*)
-      if test $host_cpu != ia64; then
-        RPATH_ENVVAR=LIBPATH
-      fi ;;
+      RPATH_ENVVAR=LIBPATH ;;
     darwin* | rhapsody*)
       RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
   esac
diff --git a/gdb/testsuite/configure.ac b/gdb/testsuite/configure.ac
index 8c0b60502c7..93040e1878d 100644
--- a/gdb/testsuite/configure.ac
+++ b/gdb/testsuite/configure.ac
@@ -64,9 +64,7 @@ else
   # The following exceptions are taken from Libtool 1.4.3.
   case $host_os in
     aix*)
-      if test $host_cpu != ia64; then
-        RPATH_ENVVAR=LIBPATH
-      fi ;;
+      RPATH_ENVVAR=LIBPATH ;;
     darwin* | rhapsody*)
       RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
   esac
diff --git a/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.S b/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.S
deleted file mode 100644
index eec63e5144b..00000000000
--- a/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.S
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright 2009-2024 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-   This file is part of the gdb testsuite.
-   It tests displaced stepping over various insns that require special
-   handling.  */
-
-	.text
-	.align 16
-	.global main
-	.proc main
-main:
-	mov r2=r12
-	mov r14=1
-	;;
-bundle:
-	/* Store value 1 into `long' variable on stack.  */
-	st8.rel [r2]=r14
-	/* This long constant requires L-X slot in this bundle.  */
-	movl r14=0x7fffffff
-	;;
-	/* Store value 0x7fffffff into `long' variable on stack.  */
-	st8.rel [r2]=r14
-	mov r14=r0
-	;;
-	mov r8=r14
-	mov r12=r2
-	br.ret.sptk.many b0
-
-	.endp main
-
-	.section	.note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp b/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
deleted file mode 100644
index 7a1e529eb8c..00000000000
--- a/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright 2009-2024 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-require {istarget "ia64-*-*"}
-
-set testfile ia64-breakpoint-shadow
-set srcfile ${testfile}.S
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "failed to compile"
-    return -1
-}
-
-clean_restart $binfile
-
-# We need to start the inferior to place the breakpoints in the memory at all.
-if ![runto_main] {
-    return -1
-}
-
-# The default "auto" mode removes all the breakpoints when we stop (and not
-# running the nonstop mode).  We would not be able to test the shadow.
-gdb_test "set breakpoint always-inserted on"
-gdb_test "show breakpoint always-inserted" "Always inserted breakpoint mode is on."
-
-set match "\nDump of assembler code for function main:\r\n(.*)End of assembler dump.\r\n$gdb_prompt $"
-
-set test "disassembly without breakpoints"
-gdb_test_multiple "disass main" $test {
-    -re $match {
-    	set orig $expect_out(1,string)
-	pass $test
-    }
-}
-
-set test "slot 0 breakpoint placed"
-gdb_test_multiple "b bundle" $test {
-    -re "Breakpoint \[0-9\] at (0x\[0-9a-f\]*0):.*$gdb_prompt $" {
-	pass $test
-	set bpt2address $expect_out(1,string)
-    }
-}
-
-if ![info exists bpt2address] {
-    return -1
-}
-
-gdb_test "b *($bpt2address + 1)" "Breakpoint \[0-9\] at .*" "slot 1 breakpoint placed"
-gdb_test "b *($bpt2address + 2)" "Can't insert breakpoint for non-existing slot X" "slot 2 (slot X) breakpoint refusal"
-
-set test "disassembly with breakpoints"
-gdb_test_multiple "disass main" $test {
-    -re $match {
-    	set got $expect_out(1,string)
-	if [string equal -nocase $orig $got] {
-	    pass $test
-	} else {
-	    fail $test
-	}
-    }
-}
diff --git a/gdb/testsuite/gdb.asm/asm-source.exp b/gdb/testsuite/gdb.asm/asm-source.exp
index 80c48ea03bd..f51de71d3b9 100644
--- a/gdb/testsuite/gdb.asm/asm-source.exp
+++ b/gdb/testsuite/gdb.asm/asm-source.exp
@@ -139,10 +139,6 @@ switch -glob -- [istarget] {
     "m68k-*-*" {
         set asm-arch m68k
     }
-    "ia64-*-*" {
-        set asm-arch ia64
-	set debug-flags "-gdwarf-2"
-    }
     "iq2000-*-*" {
     	set asm-arch iq2000
     }
diff --git a/gdb/testsuite/gdb.asm/ia64.inc b/gdb/testsuite/gdb.asm/ia64.inc
deleted file mode 100644
index c42e398a40b..00000000000
--- a/gdb/testsuite/gdb.asm/ia64.inc
+++ /dev/null
@@ -1,51 +0,0 @@
-	comment "subroutine prologue"
-	.macro gdbasm_enter
-	alloc r33=ar.pfs,0,2,0,0
-	mov r32=b0
-	nop.i 0
-	.endm
-
-	comment "subroutine epilogue"
-	.macro gdbasm_leave
-	nop.m 0
-	mov ar.pfs=r33
-	mov b0=r32
-	nop.m 0
-	nop.f 0
-	br.ret.sptk.many b0
-	.endm
-
-	.macro gdbasm_call subr
-	nop.m 0
-	nop.f 0
-	br.call.sptk.many b0=\subr
-	.endm
-
-	.macro gdbasm_several_nops
-	nop.m 0
-	nop.i 0
-	nop.i 0
-	.endm
-
-	comment "exit (0)"
-	.macro gdbasm_exit0
-	break.m 0x0
-	nop.m 0
-	nop.i 0
-	.endm
-
-	comment "crt0 startup"
-	.macro gdbasm_startup
-	gdbasm_enter
-	mov r32=r0
-	nop.i 0
-	nop.i 0
-	.endm
-
-	comment "Declare a data variable"
-	.purgem gdbasm_datavar
-	.macro gdbasm_datavar name value
-	.data
-\name:
-	.long	\value
-	.endm
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index 494b6dfa96f..5e116139ceb 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -257,12 +257,7 @@ proc fetch_all_registers {test} {
 	    exp_continue
 	}
 	-re "^bspstore\[ \t\]+\[^\r\n\]+\r\n" {
-	    if [istarget "ia64-*-*"] {
-		# Filter out bspstore which is specially tied to bsp,
-		# giving spurious differences.
-	    } else {
-		lappend all_registers_lines $expect_out(0,string)
-	    }
+	    lappend all_registers_lines $expect_out(0,string)
 	    exp_continue
 	}
 	-re  "^pstate\[ \t\]+\[^\r\n\]+\r\n" {
diff --git a/gdb/testsuite/gdb.base/float.exp b/gdb/testsuite/gdb.base/float.exp
index 49dc0a3299c..304a5c7b5da 100644
--- a/gdb/testsuite/gdb.base/float.exp
+++ b/gdb/testsuite/gdb.base/float.exp
@@ -55,8 +55,6 @@ if {[is_aarch64_target]} {
     }
 } elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} {
     gdb_test "info float" "R7:.*Status Word:.*Opcode:.*"
-} elseif {[istarget "ia64-*-*"]} {
-    gdb_test "info float" "f0.*f1.*f127.*"
 } elseif {[istarget "m68k-*-*"]} {
     gdb_test_multiple "info float" "info_float" {
         -re "fp0.*fp1.*fp7.*$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.base/step-test.exp b/gdb/testsuite/gdb.base/step-test.exp
index 6e6f89b7872..dca752e7d0a 100644
--- a/gdb/testsuite/gdb.base/step-test.exp
+++ b/gdb/testsuite/gdb.base/step-test.exp
@@ -60,11 +60,10 @@ gdb_test "step" ".*${decimal}.*myglob.*"   "step into"
 # call?
 
 # On PA64, we end up at a different instruction than PA32.
-# On IA-64, we also end up on callee instead of on the next line due
+# On MIPS, we also end up on callee instead of on the next line due
 # to the restoration of the global pointer (which is a caller-save).
-# Similarly on MIPS PIC targets.
 set test "step out"
-if { [istarget "ia64-*-*"] || [istarget "mips*-*-*"]} {
+if { [istarget "mips*-*-*"]} {
     gdb_test_multiple "finish" "$test" {
         -re ".*${decimal}.*a.*5.*= a.*3.*$gdb_prompt $" {
 	    pass "$test"
@@ -153,10 +152,9 @@ gdb_test_multiple "finish" "$test" {
     }
     -re ".*${decimal}.*callee.*STEPI.*$gdb_prompt $" {
 	# On PA64, we end up at a different instruction than PA32.
-	# On IA-64, we end up on callee instead of on the following line due
+	# On MIPS, we end up on callee instead of on the following line due
 	# to the restoration of the global pointer.
-	# Similarly on MIPS PIC targets.
-	if { [istarget "ia64-*-*"] || [istarget "mips*-*-*"] } {
+	if { [istarget "mips*-*-*"] } {
 	    test_i "$test" "stepi" \
 		".*${decimal}.*callee.*STEPI"  ".*${decimal}.*callee.*NEXTI"
 	} else {
diff --git a/gdb/testsuite/gdb.dwarf2/pr10770.c b/gdb/testsuite/gdb.dwarf2/pr10770.c
index 64dfc91ce75..b7e0ed4aa8e 100644
--- a/gdb/testsuite/gdb.dwarf2/pr10770.c
+++ b/gdb/testsuite/gdb.dwarf2/pr10770.c
@@ -4,7 +4,6 @@
 /* HP-UX libunwind.so doesn't provide _UA_END_OF_STACK */
 /* { dg-do run } */
 /* { dg-options "-fexceptions" } */
-/* { dg-skip-if "" { "ia64-*-hpux11.*" }  { "*" } { "" } } */
 /* Verify DW_OP_* handling in the unwinder.  */
 
 #include <unwind.h>
diff --git a/gdb/testsuite/gdb.threads/clone-attach-detach.c b/gdb/testsuite/gdb.threads/clone-attach-detach.c
index b07f0963cf1..7e01b41685d 100644
--- a/gdb/testsuite/gdb.threads/clone-attach-detach.c
+++ b/gdb/testsuite/gdb.threads/clone-attach-detach.c
@@ -50,12 +50,7 @@ main (int argc, char **argv)
 
 #define CLONE_FLAGS (CLONE_THREAD | CLONE_SIGHAND | CLONE_VM)
 
-#ifdef __ia64__
-  clone_pid = __clone2 (clone_fn, stack, STACK_SIZE, CLONE_FLAGS, NULL);
-#else
   clone_pid = clone (clone_fn, stack + STACK_SIZE, CLONE_FLAGS, NULL);
-#endif
-
   assert (clone_pid > 0);
 
   /* Wait for alarm.  */
diff --git a/gdb/testsuite/gdb.threads/clone-thread_db.c b/gdb/testsuite/gdb.threads/clone-thread_db.c
index 50843def3e9..cdcb786a87b 100644
--- a/gdb/testsuite/gdb.threads/clone-thread_db.c
+++ b/gdb/testsuite/gdb.threads/clone-thread_db.c
@@ -46,12 +46,7 @@ thread_fn (void *arg)
   stack = malloc (STACK_SIZE);
   assert (stack != NULL);
 
-#ifdef __ia64__
-  clone_pid = __clone2 (clone_fn, stack, STACK_SIZE, CLONE_VM, NULL);
-#else
   clone_pid = clone (clone_fn, stack + STACK_SIZE, CLONE_VM, NULL);
-#endif
-
   assert (clone_pid > 0);
 
   /* Wait for child.  */
diff --git a/gdb/testsuite/gdb.threads/ia64-sigill.c b/gdb/testsuite/gdb.threads/ia64-sigill.c
deleted file mode 100644
index 183f376ce9b..00000000000
--- a/gdb/testsuite/gdb.threads/ia64-sigill.c
+++ /dev/null
@@ -1,371 +0,0 @@
-/* This testcase is part of GDB, the GNU debugger.
-
-   Copyright 2010-2024 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#define _GNU_SOURCE
-#include <pthread.h>
-#include <stdio.h>
-#include <limits.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <unistd.h>
-#include <asm/unistd.h>
-
-#define gettid() syscall (__NR_gettid)
-
-/* Terminate always in the main task, it can lock up with SIGSTOPped GDB
-   otherwise.  */
-#define TIMEOUT (gettid () == getpid() ? 10 : 15)
-
-static pid_t thread1_tid;
-static pthread_cond_t thread1_tid_cond = PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t thread1_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
-
-static pid_t thread2_tid;
-static pthread_cond_t thread2_tid_cond = PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t thread2_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
-
-static pthread_mutex_t terminate_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
-
-static pthread_barrier_t threads_started_barrier;
-
-/* Do not use alarm as it would create a ptrace event which would hang up us if
-   we are being traced by GDB which we stopped ourselves.  */
-
-static void timed_mutex_lock (pthread_mutex_t *mutex)
-{
-  int i;
-  struct timespec start, now;
-
-  i = clock_gettime (CLOCK_MONOTONIC, &start);
-  assert (i == 0);
-
-  do
-    {
-      i = pthread_mutex_trylock (mutex);
-      if (i == 0)
-	return;
-      assert (i == EBUSY);
-
-      i = clock_gettime (CLOCK_MONOTONIC, &now);
-      assert (i == 0);
-      assert (now.tv_sec >= start.tv_sec);
-    }
-  while (now.tv_sec - start.tv_sec < TIMEOUT);
-
-  fprintf (stderr, "Timed out waiting for internal lock!\n");
-  exit (EXIT_FAILURE);
-}
-
-static void *
-thread_func (void *threadno_voidp)
-{
-  int threadno = (intptr_t) threadno_voidp;
-  int i;
-
-  pthread_barrier_wait (&threads_started_barrier);
-
-  switch (threadno)
-  {
-    case 1:
-      timed_mutex_lock (&thread1_tid_mutex);
-
-      /* THREAD1_TID_MUTEX must be already locked to avoid race.  */
-      thread1_tid = gettid ();
-
-      i = pthread_cond_signal (&thread1_tid_cond);
-      assert (i == 0);
-      i = pthread_mutex_unlock (&thread1_tid_mutex);
-      assert (i == 0);
-
-      break;
-
-    case 2:
-      timed_mutex_lock (&thread2_tid_mutex);
-
-      /* THREAD2_TID_MUTEX must be already locked to avoid race.  */
-      thread2_tid = gettid ();
-
-      i = pthread_cond_signal (&thread2_tid_cond);
-      assert (i == 0);
-      i = pthread_mutex_unlock (&thread2_tid_mutex);
-      assert (i == 0);
-
-      break;
-
-    default:
-      assert (0);
-  }
-
-#ifdef __ia64__
-  asm volatile ("label:\n"
-		"nop.m 0\n"
-		"nop.i 0\n"
-		"nop.b 0\n");
-#endif
-  /* break-here */
-
-  /* Be sure the "t (tracing stop)" test can proceed for both threads.  */
-  timed_mutex_lock (&terminate_mutex);
-  i = pthread_mutex_unlock (&terminate_mutex);
-  assert (i == 0);
-
-  return NULL;
-}
-
-static const char *
-proc_string (const char *filename, const char *line)
-{
-  FILE *f;
-  static char buf[LINE_MAX];
-  size_t line_len = strlen (line);
-
-  f = fopen (filename, "r");
-  if (f == NULL)
-    {
-      fprintf (stderr, "fopen (\"%s\") for \"%s\": %s\n", filename, line,
-	       strerror (errno));
-      exit (EXIT_FAILURE);
-    }
-  while (errno = 0, fgets (buf, sizeof (buf), f))
-    {
-      char *s;
-
-      s = strchr (buf, '\n');
-      assert (s != NULL);
-      *s = 0;
-
-      if (strncmp (buf, line, line_len) != 0)
-	continue;
-
-      if (fclose (f))
-	{
-	  fprintf (stderr, "fclose (\"%s\") for \"%s\": %s\n", filename, line,
-		   strerror (errno));
-	  exit (EXIT_FAILURE);
-	}
-
-      return &buf[line_len];
-    }
-  if (errno != 0)
-    {
-      fprintf (stderr, "fgets (\"%s\": %s\n", filename, strerror (errno));
-      exit (EXIT_FAILURE);
-    }
-  fprintf (stderr, "\"%s\": No line \"%s\" found.\n", filename, line);
-  exit (EXIT_FAILURE);
-}
-
-static unsigned long
-proc_ulong (const char *filename, const char *line)
-{
-  const char *s = proc_string (filename, line);
-  long retval;
-  char *end;
-
-  errno = 0;
-  retval = strtol (s, &end, 10);
-  if (retval < 0 || retval >= LONG_MAX || (end && *end))
-    {
-      fprintf (stderr, "\"%s\":\"%s\": %ld, %s\n", filename, line, retval,
-	       strerror (errno));
-      exit (EXIT_FAILURE);
-    }
-  return retval;
-}
-
-static void
-state_wait (pid_t process, const char *wanted)
-{
-  char *filename;
-  int i;
-  struct timespec start, now;
-  const char *state;
-
-  i = asprintf (&filename, "/proc/%lu/status", (unsigned long) process);
-  assert (i > 0);
-
-  i = clock_gettime (CLOCK_MONOTONIC, &start);
-  assert (i == 0);
-
-  do
-    {
-      state = proc_string (filename, "State:\t");
-
-      /* torvalds/linux-2.6.git 464763cf1c6df632dccc8f2f4c7e50163154a2c0
-	 has changed "T (tracing stop)" to "t (tracing stop)".  Make the GDB
-	 testcase backward compatible with older Linux kernels.  */
-      if (strcmp (state, "T (tracing stop)") == 0)
-	state = "t (tracing stop)";
-
-      if (strcmp (state, wanted) == 0)
-	{
-	  free (filename);
-	  return;
-	}
-
-      if (sched_yield ())
-	{
-	  perror ("sched_yield()");
-	  exit (EXIT_FAILURE);
-	}
-
-      i = clock_gettime (CLOCK_MONOTONIC, &now);
-      assert (i == 0);
-      assert (now.tv_sec >= start.tv_sec);
-    }
-  while (now.tv_sec - start.tv_sec < TIMEOUT);
-
-  fprintf (stderr, "Timed out waiting for PID %lu \"%s\" (now it is \"%s\")!\n",
-	   (unsigned long) process, wanted, state);
-  exit (EXIT_FAILURE);
-}
-
-static volatile pid_t tracer = 0;
-static pthread_t thread1, thread2;
-
-static void
-cleanup (void)
-{
-  printf ("Resuming GDB PID %lu.\n", (unsigned long) tracer);
-
-  if (tracer)
-    {
-      int i;
-      int tracer_save = tracer;
-
-      tracer = 0;
-
-      i = kill (tracer_save, SIGCONT);
-      assert (i == 0);
-    }
-}
-
-int
-main (int argc, char **argv)
-{
-  int i;
-  int standalone = 0;
-
-  if (argc == 2 && strcmp (argv[1], "-s") == 0)
-    standalone = 1;
-  else
-    assert (argc == 1);
-
-  setbuf (stdout, NULL);
-
-  timed_mutex_lock (&thread1_tid_mutex);
-  timed_mutex_lock (&thread2_tid_mutex);
-
-  timed_mutex_lock (&terminate_mutex);
-
-  pthread_barrier_init (&threads_started_barrier, NULL, 3);
-
-  i = pthread_create (&thread1, NULL, thread_func, (void *) (intptr_t) 1);
-  assert (i == 0);
-
-  i = pthread_create (&thread2, NULL, thread_func, (void *) (intptr_t) 2);
-  assert (i == 0);
-
-  if (!standalone)
-    {
-      tracer = proc_ulong ("/proc/self/status", "TracerPid:\t");
-      if (tracer == 0)
-	{
-	  fprintf (stderr, "The testcase must be run by GDB!\n");
-	  exit (EXIT_FAILURE);
-	}
-      if (tracer != getppid ())
-	{
-	  fprintf (stderr, "The testcase parent must be our GDB tracer!\n");
-	  exit (EXIT_FAILURE);
-	}
-    }
-
-  /* SIGCONT our debugger in the case of our crash as we would deadlock
-     otherwise.  */
-
-  atexit (cleanup);
-
-  /* Wait until all threads are seen running.  On Linux (at least),
-     new threads start stopped, and the debugger must resume them.
-     Need to wait for that before stopping GDB.  */
-  pthread_barrier_wait (&threads_started_barrier);
-
-  printf ("Stopping GDB PID %lu.\n", (unsigned long) tracer);
-
-  if (tracer)
-    {
-      i = kill (tracer, SIGSTOP);
-      assert (i == 0);
-      state_wait (tracer, "T (stopped)");
-    }
-
-  /* Threads are now waiting at timed_mutex_lock (thread1_tid_mutex) and so
-     they could not trigger the breakpoint before GDB gets unstopped later.
-     Threads get resumed at pthread_cond_wait below.  Use `while' loops for
-     protection against spurious pthread_cond_wait wakeups.  */
-
-  printf ("Waiting till the threads initialize their TIDs.\n");
-
-  while (thread1_tid == 0)
-    {
-      i = pthread_cond_wait (&thread1_tid_cond, &thread1_tid_mutex);
-      assert (i == 0);
-    }
-
-  while (thread2_tid == 0)
-    {
-      i = pthread_cond_wait (&thread2_tid_cond, &thread2_tid_mutex);
-      assert (i == 0);
-    }
-
-  printf ("Thread 1 TID = %lu, thread 2 TID = %lu, PID = %lu.\n",
-	  (unsigned long) thread1_tid, (unsigned long) thread2_tid,
-	  (unsigned long) getpid ());
-
-  printf ("Waiting till the threads get trapped by the breakpoint.\n");
-
-  if (tracer)
-    {
-      /* s390x-unknown-linux-gnu will fail with "R (running)".  */
-
-      state_wait (thread1_tid, "t (tracing stop)");
-
-      state_wait (thread2_tid, "t (tracing stop)");
-    }
-
-  cleanup ();
-
-  printf ("Joining the threads.\n");
-
-  i = pthread_mutex_unlock (&terminate_mutex);
-  assert (i == 0);
-
-  i = pthread_join (thread1, NULL);
-  assert (i == 0);
-
-  i = pthread_join (thread2, NULL);
-  assert (i == 0);
-
-  printf ("Exiting.\n");	/* break-at-exit */
-
-  return EXIT_SUCCESS;
-}
diff --git a/gdb/testsuite/gdb.threads/ia64-sigill.exp b/gdb/testsuite/gdb.threads/ia64-sigill.exp
deleted file mode 100644
index 05f998244f6..00000000000
--- a/gdb/testsuite/gdb.threads/ia64-sigill.exp
+++ /dev/null
@@ -1,77 +0,0 @@
-# This testcase is part of GDB, the GNU debugger.
-
-# Copyright 2010-2024 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test SIGILL generated by some special cases of breakpoints on ia64.  Problem
-# was SIGILL being stored in non-current thread for later retrieval when its
-# breakpoint has been already deleted.  moribund locations are not active in
-# the default all-stop mode.
-
-standard_testfile
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" ${binfile} executable [list debug additional_flags=-lrt]] != "" } {
-    return -1
-}
-
-clean_restart $testfile
-
-if ![runto_main] {
-    return -1
-}
-
-set test "info addr label"
-gdb_test_multiple $test $test {
-    -re "Symbol \"label\" is at 0x\[0-9a-f\]+0 in .*\r\n$gdb_prompt $" {
-	# Verify the label really starts at the start of ia64 bundle.
-	pass $test
-
-	# ia64 generates SIGILL for breakpoint at B slot of an MIB bundle.
-	gdb_test "break *label+2" {Breakpoint [0-9]+ at 0x[0-9a-f]+2:.*}
-    }
-    -re "No symbol \"label\" in current context\\.\r\n$gdb_prompt $" {
-	pass $test
-
-	# Either this target never generates non-SIGTRAP signals or they do
-	# not depend on the breakpoint address.  Try any address.
-	gdb_breakpoint [gdb_get_line_number "break-here"]
-    }
-}
-
-gdb_test_no_output {set $sigill_bpnum=$bpnum}
-
-gdb_breakpoint [gdb_get_line_number "break-at-exit"]
-
-gdb_test_no_output "set debug infrun 1"
-
-# The ia64 SIGILL signal is visible only in the linux-nat debug output.
-
-set prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$"
-gdb_test_multiple "continue" "continue" -prompt $prompt {
-    -re "Breakpoint \[0-9\]+,( .* in)? thread_func .*$prompt$" {
-	pass $gdb_test_name
-    }
-}
-
-gdb_test_no_output {delete $sigill_bpnum}
-
-gdb_test_multiple "continue" "continue for the pending signal" -prompt $prompt {
-    -re "Breakpoint \[0-9\]+, .*break-at-exit.*\r\n$prompt$" {
-	# Breakpoint has been skipped in the other thread.
-	pass $gdb_test_name
-    }
-    -re " received signal .*\r\n$gdb_prompt $" {
-	fail $gdb_test_name
-    }
-}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 0d78691c381..9203ff5ab40 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4572,7 +4572,6 @@ proc allow_hw_breakpoint_tests {} {
     # These targets support hardware breakpoints natively
     if { [istarget "i?86-*-*"] 
 	 || [istarget "x86_64-*-*"]
-	 || [istarget "ia64-*-*"] 
 	 || [istarget "arm*-*-*"]
 	 || [istarget "aarch64*-*-*"]
 	 || [istarget "s390*-*-*"] } {
@@ -4596,7 +4595,6 @@ proc allow_hw_watchpoint_tests {} {
     # watchpoint support on Powerpc.
     if { [istarget "i?86-*-*"] 
 	 || [istarget "x86_64-*-*"]
-	 || [istarget "ia64-*-*"] 
 	 || [istarget "arm*-*-*"]
 	 || [istarget "aarch64*-*-*"]
 	 || ([istarget "powerpc*-*-linux*"] && [has_hw_wp_support])
diff --git a/gdb/top.c b/gdb/top.c
index b93ef0a69b5..2b4a6402e70 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1423,16 +1423,6 @@ This GDB was configured as follows:\n\
 	     --with-jit-reader-dir=%s%s\n\
 "), JIT_READER_DIR, JIT_READER_DIR_RELOCATABLE ? " (relocatable)" : "");
 
-#if HAVE_LIBUNWIND_IA64_H
-  gdb_printf (stream, _("\
-	     --with-libunwind-ia64\n\
-"));
-#else
-  gdb_printf (stream, _("\
-	     --without-libunwind-ia64\n\
-"));
-#endif
-
 #if HAVE_LIBLZMA
   gdb_printf (stream, _("\
 	     --with-lzma\n\
diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
index 9e861a75088..b9d47845d8d 100644
--- a/gdbserver/configure.srv
+++ b/gdbserver/configure.srv
@@ -129,10 +129,6 @@ case "${gdbserver_host}" in
 			srv_tgtobj="${srv_tgtobj} nat/netbsd-nat.o"
 			srv_tgtobj="${srv_tgtobj} arch/i386.o"
 			;;
-  ia64-*-linux*)	srv_regobj=reg-ia64.o
-			srv_tgtobj="$srv_linux_obj linux-ia64-low.o"
-			srv_linux_usrregs=yes
-			;;
   loongarch*-*-linux*)	srv_tgtobj="arch/loongarch.o linux-loongarch-low.o"
 			srv_tgtobj="${srv_tgtobj} ${srv_linux_obj}"
 			srv_linux_regsets=yes
diff --git a/gdbserver/linux-ia64-low.cc b/gdbserver/linux-ia64-low.cc
deleted file mode 100644
index b7c3c642eb3..00000000000
--- a/gdbserver/linux-ia64-low.cc
+++ /dev/null
@@ -1,395 +0,0 @@
-/* GNU/Linux/IA64 specific low level interface, for the remote server for GDB.
-   Copyright (C) 1995-2024 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "linux-low.h"
-
-#ifdef HAVE_SYS_REG_H
-#include <sys/reg.h>
-#endif
-
-/* Linux target op definitions for the IA64 architecture.  */
-
-class ia64_target : public linux_process_target
-{
-public:
-
-  const regs_info *get_regs_info () override;
-
-  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
-
-protected:
-
-  void low_arch_setup () override;
-
-  bool low_cannot_fetch_register (int regno) override;
-
-  bool low_cannot_store_register (int regno) override;
-
-  bool low_fetch_register (regcache *regcache, int regno) override;
-
-  bool low_breakpoint_at (CORE_ADDR pc) override;
-};
-
-/* The singleton target ops object.  */
-
-static ia64_target the_ia64_target;
-
-const gdb_byte *
-ia64_target::sw_breakpoint_from_kind (int kind, int *size)
-{
-  gdb_assert_not_reached ("target op sw_breakpoint_from_kind is not "
-			  "implemented by this target");
-}
-
-bool
-ia64_target::low_breakpoint_at (CORE_ADDR pc)
-{
-  gdb_assert_not_reached ("linux target op low_breakpoint_at is not "
-			  "implemented by this target");
-}
-
-/* Defined in auto-generated file reg-ia64.c.  */
-void init_registers_ia64 (void);
-extern const struct target_desc *tdesc_ia64;
-
-#define ia64_num_regs 462
-
-#include <asm/ptrace_offsets.h>
-
-static int ia64_regmap[] =
-  {
-    /* general registers */
-    -1,		/* gr0 not available; i.e, it's always zero */
-    PT_R1,
-    PT_R2,
-    PT_R3,
-    PT_R4,
-    PT_R5,
-    PT_R6,
-    PT_R7,
-    PT_R8,
-    PT_R9,
-    PT_R10,
-    PT_R11,
-    PT_R12,
-    PT_R13,
-    PT_R14,
-    PT_R15,
-    PT_R16,
-    PT_R17,
-    PT_R18,
-    PT_R19,
-    PT_R20,
-    PT_R21,
-    PT_R22,
-    PT_R23,
-    PT_R24,
-    PT_R25,
-    PT_R26,
-    PT_R27,
-    PT_R28,
-    PT_R29,
-    PT_R30,
-    PT_R31,
-    /* gr32 through gr127 not directly available via the ptrace interface */
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    /* Floating point registers */
-    -1, -1,	/* f0 and f1 not available (f0 is +0.0 and f1 is +1.0) */
-    PT_F2,
-    PT_F3,
-    PT_F4,
-    PT_F5,
-    PT_F6,
-    PT_F7,
-    PT_F8,
-    PT_F9,
-    PT_F10,
-    PT_F11,
-    PT_F12,
-    PT_F13,
-    PT_F14,
-    PT_F15,
-    PT_F16,
-    PT_F17,
-    PT_F18,
-    PT_F19,
-    PT_F20,
-    PT_F21,
-    PT_F22,
-    PT_F23,
-    PT_F24,
-    PT_F25,
-    PT_F26,
-    PT_F27,
-    PT_F28,
-    PT_F29,
-    PT_F30,
-    PT_F31,
-    PT_F32,
-    PT_F33,
-    PT_F34,
-    PT_F35,
-    PT_F36,
-    PT_F37,
-    PT_F38,
-    PT_F39,
-    PT_F40,
-    PT_F41,
-    PT_F42,
-    PT_F43,
-    PT_F44,
-    PT_F45,
-    PT_F46,
-    PT_F47,
-    PT_F48,
-    PT_F49,
-    PT_F50,
-    PT_F51,
-    PT_F52,
-    PT_F53,
-    PT_F54,
-    PT_F55,
-    PT_F56,
-    PT_F57,
-    PT_F58,
-    PT_F59,
-    PT_F60,
-    PT_F61,
-    PT_F62,
-    PT_F63,
-    PT_F64,
-    PT_F65,
-    PT_F66,
-    PT_F67,
-    PT_F68,
-    PT_F69,
-    PT_F70,
-    PT_F71,
-    PT_F72,
-    PT_F73,
-    PT_F74,
-    PT_F75,
-    PT_F76,
-    PT_F77,
-    PT_F78,
-    PT_F79,
-    PT_F80,
-    PT_F81,
-    PT_F82,
-    PT_F83,
-    PT_F84,
-    PT_F85,
-    PT_F86,
-    PT_F87,
-    PT_F88,
-    PT_F89,
-    PT_F90,
-    PT_F91,
-    PT_F92,
-    PT_F93,
-    PT_F94,
-    PT_F95,
-    PT_F96,
-    PT_F97,
-    PT_F98,
-    PT_F99,
-    PT_F100,
-    PT_F101,
-    PT_F102,
-    PT_F103,
-    PT_F104,
-    PT_F105,
-    PT_F106,
-    PT_F107,
-    PT_F108,
-    PT_F109,
-    PT_F110,
-    PT_F111,
-    PT_F112,
-    PT_F113,
-    PT_F114,
-    PT_F115,
-    PT_F116,
-    PT_F117,
-    PT_F118,
-    PT_F119,
-    PT_F120,
-    PT_F121,
-    PT_F122,
-    PT_F123,
-    PT_F124,
-    PT_F125,
-    PT_F126,
-    PT_F127,
-    /* predicate registers - we don't fetch these individually */
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    /* branch registers */
-    PT_B0,
-    PT_B1,
-    PT_B2,
-    PT_B3,
-    PT_B4,
-    PT_B5,
-    PT_B6,
-    PT_B7,
-    /* virtual frame pointer and virtual return address pointer */
-    -1, -1,
-    /* other registers */
-    PT_PR,
-    PT_CR_IIP,	/* ip */
-    PT_CR_IPSR, /* psr */
-    PT_CFM,	/* cfm */
-    /* kernel registers not visible via ptrace interface (?) */
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    /* hole */
-    -1, -1, -1, -1, -1, -1, -1, -1,
-    PT_AR_RSC,
-    PT_AR_BSP,
-    PT_AR_BSPSTORE,
-    PT_AR_RNAT,
-    -1,
-    -1,		/* Not available: FCR, IA32 floating control register */
-    -1, -1,
-    -1,		/* Not available: EFLAG */
-    -1,		/* Not available: CSD */
-    -1,		/* Not available: SSD */
-    -1,		/* Not available: CFLG */
-    -1,		/* Not available: FSR */
-    -1,		/* Not available: FIR */
-    -1,		/* Not available: FDR */
-    -1,
-    PT_AR_CCV,
-    -1, -1, -1,
-    PT_AR_UNAT,
-    -1, -1, -1,
-    PT_AR_FPSR,
-    -1, -1, -1,
-    -1,		/* Not available: ITC */
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    PT_AR_PFS,
-    PT_AR_LC,
-    PT_AR_EC,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    -1,
-  };
-
-bool
-ia64_target::low_cannot_store_register (int regno)
-{
-  return false;
-}
-
-bool
-ia64_target::low_cannot_fetch_register (int regno)
-{
-  return false;
-}
-
-/* GDB register numbers.  */
-#define IA64_GR0_REGNUM		0
-#define IA64_FR0_REGNUM		128
-#define IA64_FR1_REGNUM		129
-
-bool
-ia64_target::low_fetch_register (regcache *regcache, int regnum)
-{
-  /* r0 cannot be fetched but is always zero.  */
-  if (regnum == IA64_GR0_REGNUM)
-    {
-      const gdb_byte zero[8] = { 0 };
-
-      gdb_assert (sizeof (zero) == register_size (regcache->tdesc, regnum));
-      supply_register (regcache, regnum, zero);
-      return true;
-    }
-
-  /* fr0 cannot be fetched but is always zero.  */
-  if (regnum == IA64_FR0_REGNUM)
-    {
-      const gdb_byte f_zero[16] = { 0 };
-
-      gdb_assert (sizeof (f_zero) == register_size (regcache->tdesc, regnum));
-      supply_register (regcache, regnum, f_zero);
-      return true;
-    }
-
-  /* fr1 cannot be fetched but is always one (1.0).  */
-  if (regnum == IA64_FR1_REGNUM)
-    {
-      const gdb_byte f_one[16] =
-	{ 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };
-
-      gdb_assert (sizeof (f_one) == register_size (regcache->tdesc, regnum));
-      supply_register (regcache, regnum, f_one);
-      return true;
-    }
-
-  return false;
-}
-
-static struct usrregs_info ia64_usrregs_info =
-  {
-    ia64_num_regs,
-    ia64_regmap,
-  };
-
-static struct regs_info myregs_info =
-  {
-    NULL, /* regset_bitmap */
-    &ia64_usrregs_info
-  };
-
-const regs_info *
-ia64_target::get_regs_info ()
-{
-  return &myregs_info;
-}
-
-void
-ia64_target::low_arch_setup ()
-{
-  current_process ()->tdesc = tdesc_ia64;
-}
-
-/* The linux target ops object.  */
-
-linux_process_target *the_linux_target = &the_ia64_target;
-
-void
-initialize_low_arch (void)
-{
-  init_registers_ia64 ();
-}
-- 
2.42.0


^ permalink raw reply	[relevance 7%]

* [PATCH 33/34] Windows gdb: Watchpoints while running (internal vs external stops)
  @ 2024-05-07 23:42  2% ` Pedro Alves
  0 siblings, 0 replies; 200+ results
From: Pedro Alves @ 2024-05-07 23:42 UTC (permalink / raw)
  To: gdb-patches

Teach the Windows target to temporarily pause all threads when we
change the debug registers for a watchpoint.  Implements the same
logic as Linux uses:

    ~~~
      /*                             (...) if threads are running when the
         mirror changes, a temporary and transparent stop on all threads
         is forced so they can get their copy of the debug registers
         updated on re-resume.   (...)  */
    ~~~

On Linux, we send each thread a SIGSTOP to step them.  On Windows,
SuspendThread itself doesn't cause any asynchronous debug event to be
reported.  However, we've implemented windows_nat_target::stop such
that it uses SuspendThread, and then queues a pending GDB_SIGNAL_0
stop on the thread.  That results in a user-visible stop, while here
we want a non-user-visible stop.  So what we do is re-use that
windows_nat_target::stop stopping mechanism, but add an external vs
internal stopping kind distinction.  An internal stop results in
windows_nat_target::wait immediately re-resuming the thread.

Note we don't make the debug registers poking code SuspendThread ->
write debug registers -> ContinueThread itself, because SuspendThread
is actually asynchronous and may take a bit to stop the thread (a
following GetThreadContext blocks until the thread is actually
suspended), and, there will be several debug register writes when a
watchpoint is set, because we have to set all of DR0, DR1, DR2, DR3,
and DR7.  Defering the actualy writes to ::wait avoids a bunch of
SuspendThread/ResumeThread sequences, so in principle should be
faster.

Change-Id: I39c2492c7aac06d23ef8f287f4afe3747b7bc53f
---
 gdb/nat/windows-nat.h |  27 ++++++++--
 gdb/windows-nat.c     | 116 ++++++++++++++++++++++++++++++++++--------
 2 files changed, 119 insertions(+), 24 deletions(-)

diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index c6d0c4e98dd..8399ed7b3b7 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -34,6 +34,24 @@ namespace windows_nat
 
 struct windows_process_info;
 
+/* The reason for explicitly stopping a thread.  Note the enumerators
+   are ordered such that when comparing two stopping_kind's numerical
+   value, the highest should prevail.  */
+enum stopping_kind
+  {
+    /* Not really stopping the thread.  */
+    SK_NOT_STOPPING = 0,
+
+    /* We're stopping the thread for internal reasons, the stop should
+       not be reported as an event to the core.  */
+    SK_INTERNAL = 1,
+
+    /* We're stopping the thread for external reasons, meaning, the
+       core/user asked us to stop the thread, so we must report a stop
+       event to the core.  */
+    SK_EXTERNAL = 2,
+  };
+
 /* Thread information structure used to track extra information about
    each thread.  */
 struct windows_thread_info
@@ -117,9 +135,10 @@ struct windows_thread_info
   int suspended = 0;
 
   /* This flag indicates whether we are explicitly stopping this
-     thread in response to a target_stop request.  This allows
-     distinguishing between threads that are explicitly stopped by the
-     debugger and threads that are stopped due to other reasons.
+     thread in response to a target_stop request or for
+     backend-internal reasons.  This allows distinguishing between
+     threads that are explicitly stopped by the debugger and threads
+     that are stopped due to other reasons.
 
      Typically, when we want to stop a thread, we suspend it, enqueue
      a pending GDB_SIGNAL_0 stop status on the thread, and then set
@@ -128,7 +147,7 @@ struct windows_thread_info
      already has an event to report.  In such case, we simply set the
      'stopping' flag without suspending the thread or enqueueing a
      pending stop.  See stop_one_thread.  */
-  bool stopping = false;
+  stopping_kind stopping = SK_NOT_STOPPING;
 
 /* Info about a potential pending stop.
 
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index a33ef868566..cb1d030d12b 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -261,6 +261,10 @@ enum windows_continue_flag
        all-stop mode.  This flag indicates that windows_continue
        should call ContinueDebugEvent even in non-stop mode.  */
     WCONT_CONTINUE_DEBUG_EVENT = 4,
+
+    /* Skip calling ContinueDebugEvent even in all-stop mode.  This is
+       the default in non-stop mode.  */
+    WCONT_DONT_CONTINUE_DEBUG_EVENT = 8,
   };
 
 DEF_ENUM_FLAGS_TYPE (windows_continue_flag, windows_continue_flags);
@@ -521,6 +525,8 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>
     return serial_event_fd (m_wait_event);
   }
 
+  void debug_registers_changed_all_threads ();
+
 private:
 
   windows_thread_info *add_thread (ptid_t ptid, HANDLE h, void *tlb,
@@ -528,7 +534,8 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>
   void delete_thread (ptid_t ptid, DWORD exit_code, bool main_thread_p);
   DWORD fake_create_process (const DEBUG_EVENT &current_event);
 
-  void stop_one_thread (windows_thread_info *th);
+  void stop_one_thread (windows_thread_info *th,
+			enum stopping_kind stopping_kind);
 
   BOOL windows_continue (DWORD continue_status, int id,
 			 windows_continue_flags cont_flags = 0);
@@ -1294,7 +1301,7 @@ windows_per_inferior::handle_output_debug_string
 		 a pending event.  It will be picked up by
 		 windows_nat_target::wait.  */
 	      th->suspend ();
-	      th->stopping = true;
+	      th->stopping = SK_EXTERNAL;
 	      th->last_event = {};
 	      th->pending_status.set_stopped (gotasig);
 
@@ -1605,7 +1612,7 @@ windows_per_inferior::continue_one_thread (windows_thread_info *th,
     }
 
   th->resume ();
-  th->stopping = false;
+  th->stopping = SK_NOT_STOPPING;
   th->last_sig = GDB_SIGNAL_0;
 }
 
@@ -1680,8 +1687,19 @@ windows_nat_target::windows_continue (DWORD continue_status, int id,
 #endif
       }
 
-  if (!target_is_non_stop_p ()
-      || (cont_flags & WCONT_CONTINUE_DEBUG_EVENT) != 0)
+  /* WCONT_DONT_CONTINUE_DEBUG_EVENT and WCONT_CONTINUE_DEBUG_EVENT
+     can't both be enabled at the same time.  */
+  gdb_assert ((cont_flags & WCONT_DONT_CONTINUE_DEBUG_EVENT) == 0
+	      || (cont_flags & WCONT_CONTINUE_DEBUG_EVENT) == 0);
+
+  bool continue_debug_event;
+  if ((cont_flags & WCONT_CONTINUE_DEBUG_EVENT) != 0)
+    continue_debug_event = true;
+  else if ((cont_flags & WCONT_DONT_CONTINUE_DEBUG_EVENT) != 0)
+    continue_debug_event = false;
+  else
+    continue_debug_event = !target_is_non_stop_p ();
+  if (continue_debug_event)
     {
       DEBUG_EVENTS ("windows_continue -> continue_last_debug_event");
       continue_last_debug_event_main_thread
@@ -1876,11 +1894,13 @@ windows_nat_target::interrupt ()
 	     "Press Ctrl-c in the program console."));
 }
 
-/* Stop thread TH.  This leaves a GDB_SIGNAL_0 pending in the thread,
-   which is later consumed by windows_nat_target::wait.  */
+/* Stop thread TH, for STOPPING_KIND reason.  This leaves a
+   GDB_SIGNAL_0 pending in the thread, which is later consumed by
+   windows_nat_target::wait.  */
 
 void
-windows_nat_target::stop_one_thread (windows_thread_info *th)
+windows_nat_target::stop_one_thread (windows_thread_info *th,
+				     enum stopping_kind stopping_kind)
 {
   ptid_t thr_ptid (windows_process.process_id, th->tid);
 
@@ -1896,12 +1916,18 @@ windows_nat_target::stop_one_thread (windows_thread_info *th)
 #ifdef __CYGWIN__
   else if (th->suspended
 	   && th->signaled_thread != nullptr
-	   && th->pending_status.kind () == TARGET_WAITKIND_IGNORE)
+	   && th->pending_status.kind () == TARGET_WAITKIND_IGNORE
+	   /* If doing an internal stop to update debug registers,
+	      then just leave the "sig" thread suspended.  Otherwise
+	      windows_nat_target::wait would incorrectly break the
+	      signaled_thread lock when it later processes the pending
+	      stop and calls windows_continue on this thread.  */
+	   && stopping_kind == SK_EXTERNAL)
     {
       DEBUG_EVENTS ("explict stop for \"sig\" thread %s held for signal",
 		    thr_ptid.to_string ().c_str ());
 
-      th->stopping = true;
+      th->stopping = stopping_kind;
       th->pending_status.set_stopped (GDB_SIGNAL_0);
       th->last_event = {};
       serial_event_set (m_wait_event);
@@ -1915,7 +1941,9 @@ windows_nat_target::stop_one_thread (windows_thread_info *th)
 		    thr_ptid.to_string ().c_str (),
 		    th->suspended, th->stopping);
 
-      th->stopping = true;
+      /* Upgrade stopping.  */
+      if (stopping_kind > th->stopping)
+	th->stopping = stopping_kind;
     }
   else
     {
@@ -1924,9 +1952,13 @@ windows_nat_target::stop_one_thread (windows_thread_info *th)
       th->suspend ();
       gdb_assert (th->suspended);
 
-      th->stopping = true;
-      th->pending_status.set_stopped (GDB_SIGNAL_0);
-      th->last_event = {};
+      if (stopping_kind > th->stopping)
+	{
+	  th->stopping = stopping_kind;
+	  th->pending_status.set_stopped (GDB_SIGNAL_0);
+	  th->last_event = {};
+	}
+
       serial_event_set (m_wait_event);
     }
 }
@@ -1940,7 +1972,7 @@ windows_nat_target::stop (ptid_t ptid)
     {
       ptid_t thr_ptid (windows_process.process_id, th->tid);
       if (thr_ptid.matches (ptid))
-	stop_one_thread (th.get ());
+	stop_one_thread (th.get (), SK_EXTERNAL);
     }
 }
 
@@ -2367,6 +2399,17 @@ windows_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 	    {
 	      windows_thread_info *th = windows_process.find_thread (result);
 
+	      /* If this thread was temporarily stopped just so we
+		 could update its debug registers on the next
+		 resumption, do it now.  */
+	      if (th->stopping == SK_INTERNAL)
+		{
+		  gdb_assert (fake);
+		  windows_continue (DBG_CONTINUE, th->tid,
+				    WCONT_DONT_CONTINUE_DEBUG_EVENT);
+		  continue;
+		}
+
 	      th->stopped_at_software_breakpoint = false;
 	      if (current_event.dwDebugEventCode
 		  == EXCEPTION_DEBUG_EVENT
@@ -2419,7 +2462,7 @@ windows_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 		for (auto &thr : windows_process.thread_list)
 		  thr->suspend ();
 
-	      th->stopping = false;
+	      th->stopping = SK_NOT_STOPPING;
 	    }
 
 	  /* If something came out, assume there may be more.  This is
@@ -3902,6 +3945,41 @@ Use \"file\" or \"dll\" command to load executable/libraries directly."));
     }
 }
 
+/* For each thread, set the debug_registers_changed flag, and
+   temporarily stop it so we can update its debug registers.  */
+
+void
+windows_nat_target::debug_registers_changed_all_threads ()
+{
+  for (auto &th : windows_process.thread_list)
+    {
+      th->debug_registers_changed = true;
+
+      /* Note we don't SuspendThread => update debug regs =>
+	 ResumeThread, because SuspendThread is actually asynchronous
+	 (and GetThreadContext blocks until the thread really
+	 suspends), and doing that for all threads may take a bit.
+	 Also, the core does one call per DR register update, so that
+	 would result in a lot of suspend-resumes.  So instead, we
+	 suspend the thread if it wasn't already suspended, and queue
+	 a pending stop to be handled by windows_nat_target::wait.
+	 This means we only stop each thread once, and, we don't block
+	 waiting for each individual thread stop.  */
+      stop_one_thread (th.get (), SK_INTERNAL);
+    }
+}
+
+/* Trampoline helper to get at the
+   windows_nat_target::debug_registers_changed_all_threads method in
+   the native target.  */
+
+static void
+debug_registers_changed_all_threads ()
+{
+  auto *win_tgt = static_cast<windows_nat_target *> (get_native_target ());
+  win_tgt->debug_registers_changed_all_threads ();
+}
+
 /* Hardware watchpoint support, adapted from go32-nat.c code.  */
 
 /* Pass the address ADDR to the inferior in the I'th debug register.
@@ -3913,8 +3991,7 @@ windows_set_dr (int i, CORE_ADDR addr)
   if (i < 0 || i > 3)
     internal_error (_("Invalid register %d in windows_set_dr.\n"), i);
 
-  for (auto &th : windows_process.thread_list)
-    th->debug_registers_changed = true;
+  debug_registers_changed_all_threads ();
 }
 
 /* Pass the value VAL to the inferior in the DR7 debug control
@@ -3923,8 +4000,7 @@ windows_set_dr (int i, CORE_ADDR addr)
 static void
 windows_set_dr7 (unsigned long val)
 {
-  for (auto &th : windows_process.thread_list)
-    th->debug_registers_changed = true;
+  debug_registers_changed_all_threads ();
 }
 
 /* Get the value of debug register I from the inferior.  */
-- 
2.43.2


^ permalink raw reply	[relevance 2%]

* Re:  [PATCH v5] Fix AIX thread exit events not being reported and UI to show  kernel thread ID.
  @ 2024-05-07  9:57  5%   ` Aditya Kamath1
  0 siblings, 0 replies; 200+ results
From: Aditya Kamath1 @ 2024-05-07  9:57 UTC (permalink / raw)
  To: Aditya Vidyadhar Kamath, tom
  Cc: Ulrich Weigand, gdb-patches, Sangamesh Mallayya, jhb

[-- Attachment #1: Type: text/plain, Size: 21256 bytes --]

Respected community members,

Any update/feedback on this version of the patch. Kindly let me know.

Have a nice day ahead.

Thanks and regards,
Aditya.

From: Aditya Kamath1 <Aditya.Kamath1@ibm.com>
Date: Friday, 3 May 2024 at 8:44 PM
To: Aditya Vidyadhar Kamath <akamath996@gmail.com>, tom@tromey.com <tom@tromey.com>
Cc: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>, jhb@freebsd.org <jhb@freebsd.org>
Subject: Re: [EXTERNAL] [PATCH v5] Fix AIX thread exit events not being reported and UI to show kernel thread ID.
Respected Ulrich and community members,

Hi,

>+        if (get_signaled_thread (pid) == tid
>+              && in_thread_list (proc_target, ptid_t (pid)))
>Didn't you want to change this?

In enthusiasm I missed it. Sorry for the same. Please check now.

>+      auto itr = in_queue_threads.find (priv->pdtid);
>+      if (itr == in_queue_threads.end ()
>Why don't you use .count like elsewhere?

This also is done.

Kindly let me know if v5 is okay.

Pasting results of v5 patch.

Gdb.threads/thread_events.exp test case result after this patch

=== gdb Summary ===
 gmake check RUNTESTFLAGS='gdb.threads/thread_events.exp  CC_FOR_TARGET="/opt/freeware/bin/gcc" CXX_FOR_TARGET="/opt/freeware/bin/g++" CXXFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64" CFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64"'
gmake check-single
# of expected passes            11
/current_gdb/binutils-gdb/gdb/gdb version  15.0.50.20240325-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /current_gdb/binutils-gdb/gdb/data-directory

Output of program 1(Program 1 Pasted below this email)
Reading symbols from testsuite/gdb.threads/thread_events...
(gdb) b main
Breakpoint 1 at 0x100007dc: file gdb.threads/thread_events.c, line 41.
(gdb) r
Starting program: /current_gdb/binutils-gdb/gdb/testsuite/gdb.threads/thread_events

Breakpoint 1, main (argc=1, argv=0x2ff22940) at gdb.threads/thread_events.c:41
41        if (pthread_create (&thread, NULL, threadfunc, NULL) != 0)
(gdb) b threadfunc
Breakpoint 2 at 0x10000718: file gdb.threads/thread_events.c, line 27.
(gdb) b after_join_func
Breakpoint 3 at 0x10000778: file gdb.threads/thread_events.c, line 34.
(gdb) c
Continuing.
[New Thread 258 (tid 24969631)]
[Switching to Thread 258 (tid 24969631)]

Thread 2 hit Breakpoint 2, threadfunc (arg=0x0) at gdb.threads/thread_events.c:27
27        printf ("in threadfunc\n");
(gdb)
Continuing.
in threadfunc
[Thread 258 (tid 24969631) exited]
[Switching to Thread 1 (tid 34341137)]

Thread 1 hit Breakpoint 3, after_join_func () at gdb.threads/thread_events.c:34
34        printf ("finished\n");
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 34341137) ([running]) after_join_func () at gdb.threads/thread_events.c:34
(gdb) c
Continuing.
finished
[Thread 1 (tid 34341137) exited]
[Inferior 1 (process 11338122) exited normally]
(gdb) q

Program 1:

/*   This file was written by Chris Demetriou (cgd@google.com<mailto:cgd@google.com>).  */

/* Simple test to trigger thread events (thread start, thread exit).  */

#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

static void *
threadfunc (void *arg)
{
  printf ("in threadfunc\n");
  return NULL;
}

static void
after_join_func (void)
{
  printf ("finished\n");
}

int main (int argc, char *argv[])
{
  pthread_t thread;

  if (pthread_create (&thread, NULL, threadfunc, NULL) != 0)
    {
      printf ("pthread_create failed\n");
      exit (1);
    }

  if (pthread_join (thread, NULL) != 0)
    {
      printf ("pthread_join failed\n");
      exit (1);
    }

  after_join_func ();
  return 0;
}



Output of program 2 [Program 2 pasted below]

Reading symbols from //gdb_tests/continue-pending-status_exit_test...
(gdb) r
Starting program: /gdb_tests/continue-pending-status_exit_test
Hello World
Hello World
More threads
Hello World
Hello World
Hello World
Hello World
[New Thread 258 (tid 24969633)]
[Thread 258 (tid 24969633) exited]
[New Thread 515 (tid 30540067)]
[Thread 515 (tid 30540067) exited]
[New Thread 772 (tid 30671107)]
[Thread 772 (tid 30671107) exited]
[New Thread 1029 (tid 31588767)]
[Thread 1029 (tid 31588767) exited]
[New Thread 1286 (tid 30998947)]
[Thread 1286 (tid 30998947) exited]
[New Thread 1543 (tid 28967413)]
[Thread 1543 (tid 28967413) exited]

Thread 1 received signal SIGINT, Interrupt.
0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 34341139) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) q
A debugging session is active.

        Inferior 1 [process 11338126] will be killed.

Quit anyway? (y or n) y

Program 2:

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>

pthread_barrier_t barrier;

#define NUM_THREADS 3

void *
thread_function (void *arg)
{
  /* This ensures that the breakpoint is only hit after both threads
     are created, so the test can always switch to the non-event
     thread when the breakpoint triggers.  */
//  pthread_barrier_wait (&barrier);

  printf ("Hello World \n"); /* break here */
}

int
main (void)
{
  int i;

  alarm (300);

  pthread_barrier_init (&barrier, NULL, NUM_THREADS);

  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_t thread;
      int res;

      res = pthread_create (&thread, NULL,
                            thread_function, NULL);
      assert (res == 0);
    }

  printf ("More threads \n");
  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_t thread;
      int res;

      res = pthread_create (&thread, NULL,
                thread_function, NULL);
      assert (res == 0);
    }
  while (1)
    sleep (1);

  return 0;
}


From: Aditya Vidyadhar Kamath <akamath996@gmail.com>
Date: Friday, 3 May 2024 at 8:41 PM
To: tom@tromey.com <tom@tromey.com>
Cc: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>, jhb@freebsd.org <jhb@freebsd.org>
Subject: [EXTERNAL] [PATCH v5] Fix AIX thread exit events not being reported and UI to show kernel thread ID.
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>

In AIX when a thread exits we were not showing that a thread exit event happened
and GDB continued to keep the terminated threads.

If we have terminated threads then the UI on info threads command will look like
(gdb) info threads
  Id   Target Id                                          Frame
* 1    Thread 1 (tid 26607979, running)    0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
  2    Thread 258 (tid 30998799, finished) aix-thread: ptrace (52, 30998799) returned -1 (errno = 3 The process does not exist.)

If we see the frame is not getting displayed correctly.

The reason for the same is that in AIX we were not managing thread states. In particular we do not know
when a thread terminates.

The reason being in sync_threadlists () the pbuf and gbuf lists remain the same though certain threads exit.

This patch is a fix to the same.

Also certain UI is changed.

On a new thread born and exit the UI in AIX will be similar to Linux with both user and kernel thread information.

[New Thread 258 (tid 32178533)]
[New Thread 515 (tid 30343651)]
[New Thread 772 (tid 33554909)]
[New Thread 1029 (tid 24969489)]
[New Thread 1286 (tid 18153945)]
[New Thread 1543 (tid 30736739)]
[Thread 258 (tid 32178533) exited]
[Thread 515 (tid 30343651) exited]
[Thread 772 (tid 33554909) exited]
[Thread 1029 (tid 24969489) exited]
[Thread 1286 (tid 18153945) exited]
[Thread 1543 (tid 30736739) exited]

and info threads will look like
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 31326579) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)

Also a small change to testcase gdb.threads/thread_events.exp to make sure this test runs on AIX as well.
---
 gdb/aix-thread.c                            | 242 ++++++--------------
 gdb/testsuite/gdb.threads/thread_events.exp |   6 +-
 2 files changed, 78 insertions(+), 170 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index c70bd82bc24..a699a539598 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -55,6 +55,7 @@
 #include <sys/reg.h>
 #include <sched.h>
 #include <sys/pthdebug.h>
+#include <unordered_set>

 #if !HAVE_DECL_GETTHRDS
 extern int getthrds (pid_t, struct thrdsinfo64 *, int, tid_t *, int);
@@ -190,6 +191,9 @@ struct aix_thread_variables
   /* Whether the current architecture is 64-bit.
    Only valid when pd_able is true.  */
   int arch64;
+
+  /* Describes the number of thread exit events reported.  */
+  std::unordered_set<pthdb_pthread_t> exited_threads;
 };

 /* Key to our per-inferior data.  */
@@ -737,47 +741,6 @@ state2str (pthdb_state_t state)
     }
 }

-/* qsort() comparison function for sorting pd_thread structs by pthid.  */
-
-static int
-pcmp (const void *p1v, const void *p2v)
-{
-  struct pd_thread *p1 = (struct pd_thread *) p1v;
-  struct pd_thread *p2 = (struct pd_thread *) p2v;
-  return p1->pthid < p2->pthid ? -1 : p1->pthid > p2->pthid;
-}
-
-/* ptid comparison function */
-
-static int
-ptid_cmp (ptid_t ptid1, ptid_t ptid2)
-{
-  if (ptid1.pid () < ptid2.pid ())
-    return -1;
-  else if (ptid1.pid () > ptid2.pid ())
-    return 1;
-  else if (ptid1.tid () < ptid2.tid ())
-    return -1;
-  else if (ptid1.tid () > ptid2.tid ())
-    return 1;
-  else if (ptid1.lwp () < ptid2.lwp ())
-    return -1;
-  else if (ptid1.lwp () > ptid2.lwp ())
-    return 1;
-  else
-    return 0;
-}
-
-/* qsort() comparison function for sorting thread_info structs by pid.  */
-
-static int
-gcmp (const void *t1v, const void *t2v)
-{
-  struct thread_info *t1 = *(struct thread_info **) t1v;
-  struct thread_info *t2 = *(struct thread_info **) t2v;
-  return ptid_cmp (t1->ptid, t2->ptid);
-}
-
 /* Search through the list of all kernel threads for the thread
    that has stopped on a SIGTRAP signal, and return its TID.
    Return 0 if none found.  */
@@ -822,22 +785,17 @@ static void
 sync_threadlists (pid_t pid)
 {
   int cmd, status;
-  int pcount, psize, pi, gcount, gi;
-  struct pd_thread *pbuf;
-  struct thread_info **gbuf, **g, *thread;
   pthdb_pthread_t pdtid;
   pthread_t pthid;
   pthdb_tid_t tid;
   process_stratum_target *proc_target = current_inferior ()->process_target ();
   struct aix_thread_variables *data;
   data = get_thread_data_helper_for_pid (pid);
+  pthdb_state_t state;
+  std::set<pthdb_pthread_t> in_queue_threads;

   /* Accumulate an array of libpthdebug threads sorted by pthread id.  */

-  pcount = 0;
-  psize = 1;
-  pbuf = XNEWVEC (struct pd_thread, psize);
-
   for (cmd = PTHDB_LIST_FIRST;; cmd = PTHDB_LIST_NEXT)
     {
       status = pthdb_pthread (data->pd_session, &pdtid, cmd);
@@ -848,118 +806,66 @@ sync_threadlists (pid_t pid)
       if (status != PTHDB_SUCCESS || pthid == PTHDB_INVALID_PTID)
         continue;

-      if (pcount == psize)
-       {
-         psize *= 2;
-         pbuf = (struct pd_thread *) xrealloc (pbuf,
-                                               psize * sizeof *pbuf);
-       }
-      pbuf[pcount].pdtid = pdtid;
-      pbuf[pcount].pthid = pthid;
-      pcount++;
-    }
-
-  for (pi = 0; pi < pcount; pi++)
-    {
-      status = pthdb_pthread_tid (data->pd_session, pbuf[pi].pdtid, &tid);
-      if (status != PTHDB_SUCCESS)
-       tid = PTHDB_INVALID_TID;
-      pbuf[pi].tid = tid;
-    }
-
-  qsort (pbuf, pcount, sizeof *pbuf, pcmp);
-
-  /* Accumulate an array of GDB threads sorted by pid.  */
-
-  /* gcount is GDB thread count and pcount is pthreadlib thread count.  */
-
-  gcount = 0;
-  for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))
-    gcount++;
-  g = gbuf = XNEWVEC (struct thread_info *, gcount);
-  for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))
-    *g++ = tp;
-  qsort (gbuf, gcount, sizeof *gbuf, gcmp);
+      ptid_t ptid (pid, 0, pthid);
+      status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+      in_queue_threads.insert (pdtid);

-  /* Apply differences between the two arrays to GDB's thread list.  */
-
-  for (pi = gi = 0; pi < pcount || gi < gcount;)
-    {
-      if (pi == pcount)
+      /* If this thread has reported and exited, do not add it again.  */
+      if (state == PST_TERM)
         {
-         delete_thread (gbuf[gi]);
-         gi++;
+         if (data->exited_threads.count (pdtid) != 0)
+            continue;
         }
-      else if (gi == gcount)
-       {
-         aix_thread_info *priv = new aix_thread_info;
-         priv->pdtid = pbuf[pi].pdtid;
-         priv->tid = pbuf[pi].tid;

-         thread = add_thread_with_info (proc_target,
-                                        ptid_t (pid, 0, pbuf[pi].pthid),
-                                        private_thread_info_up (priv));
-
-         pi++;
-       }
-      else
+      /* If this thread has never been reported to GDB, add it.  */
+      if (!in_thread_list (proc_target, ptid))
         {
-         ptid_t pptid, gptid;
-         int cmp_result;
-
-         pptid = ptid_t (pid, 0, pbuf[pi].pthid);
-         gptid = gbuf[gi]->ptid;
-         pdtid = pbuf[pi].pdtid;
-         tid = pbuf[pi].tid;
-
-         cmp_result = ptid_cmp (pptid, gptid);
-
-         if (cmp_result == 0)
-           {
-             aix_thread_info *priv = get_aix_thread_info (gbuf[gi]);
-
-             priv->pdtid = pdtid;
-             priv->tid = tid;
-             pi++;
-             gi++;
-           }
-         else if (cmp_result > 0)
+         aix_thread_info *priv = new aix_thread_info;
+         /* init priv */
+         priv->pdtid = pdtid;
+         status = pthdb_pthread_tid (data->pd_session, pdtid, &tid);
+         priv->tid = tid;
+         /* Check if this is the main thread.  If it is, then change
+            its ptid and add its private data.  */
+         if (in_thread_list (proc_target, ptid_t (pid)))
             {
-             /* This is to make the main process thread now look
-                like a thread.  */
-
-             if (gptid.is_pid ())
-               {
-                 thread_info *tp = proc_target->find_thread (gptid);
-                 thread_change_ptid (proc_target, gptid, pptid);
-                 aix_thread_info *priv = new aix_thread_info;
-                 priv->pdtid = pbuf[pi].pdtid;
-                 priv->tid = pbuf[pi].tid;
-                 tp->priv.reset (priv);
-                 gi++;
-                 pi++;
-               }
-             else
-               {
-                 delete_thread (gbuf[gi]);
-                 gi++;
-               }
+             thread_info *tp = proc_target->find_thread (ptid_t (pid));
+             thread_change_ptid (proc_target, ptid_t (pid), ptid);
+             tp->priv.reset (priv);
             }
           else
-           {
-             thread = add_thread (proc_target, pptid);
+           add_thread_with_info (proc_target, ptid,
+               private_thread_info_up (priv));
+       }

-             aix_thread_info *priv = new aix_thread_info;
-             thread->priv.reset (priv);
-             priv->pdtid = pdtid;
-             priv->tid = tid;
-             pi++;
-           }
+      /* The thread is terminated. Remove it.  */
+      if (state == PST_TERM)
+       {
+         thread_info *thr = proc_target->find_thread (ptid);
+         gdb_assert (thr != nullptr);
+         delete_thread (thr);
+         data->exited_threads.insert (pdtid);
         }
     }

-  xfree (pbuf);
-  xfree (gbuf);
+    /* Sometimes there can be scenarios where the thread status is
+       unknown and we it will never iterate in the for loop above,
+       since cmd will be no longer be pointing to that threads.  One
+       such scenario is the gdb.threads/thread_events.exp testcase
+       where in the end after the threadfunc breakpoint is hit, the
+       thread exits and gets into a PST_UNKNOWN state.  So this thread
+       will not run in the above for loop.  Therefore the below for loop
+       is to manually delete such threads.  */
+    for (struct thread_info *it : all_threads ())
+      {
+       aix_thread_info *priv = get_aix_thread_info (it);
+       if (in_queue_threads.count (priv->pdtid) == 0
+               && in_thread_list (proc_target, it->ptid))
+         {
+           delete_thread (it);
+           data->exited_threads.insert (priv->pdtid);
+         }
+      }
 }

 /* Iterate_over_threads() callback for locating a thread, using
@@ -1013,8 +919,8 @@ pd_update (pid_t pid)
 }

 /* Try to start debugging threads in the current process.
-   If successful and there exists and we can find an event thread, return a ptid
-   for that thread.  Otherwise, return a ptid-only ptid using PID.  */
+   If successful and there exists and we can find an event thread, set
+   pd_active for that thread.  Otherwise, return.  */

 static void
 pd_activate (pid_t pid)
@@ -2084,10 +1990,17 @@ aix_thread_target::thread_alive (ptid_t ptid)
 std::string
 aix_thread_target::pid_to_str (ptid_t ptid)
 {
-  if (ptid.tid () == 0)
-    return beneath ()->pid_to_str (ptid);
+  thread_info *thread_info = current_inferior ()->find_thread (ptid);

-  return string_printf (_("Thread %s"), pulongest (ptid.tid ()));
+  if (thread_info != NULL && thread_info->priv != NULL)
+    {
+      aix_thread_info *priv = get_aix_thread_info (thread_info);
+
+      return string_printf (_("Thread %s (tid %s)"), pulongest (ptid.tid ()),
+               pulongest (priv->tid));
+    }
+
+  return beneath ()->pid_to_str (ptid);
 }

 /* Return a printable representation of extra information about
@@ -2098,7 +2011,6 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
 {
   int status;
   pthdb_pthread_t pdtid;
-  pthdb_tid_t tid;
   pthdb_state_t state;
   pthdb_suspendstate_t suspendstate;
   pthdb_detachstate_t detachstate;
@@ -2115,33 +2027,31 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
   aix_thread_info *priv = get_aix_thread_info (thread);

   pdtid = priv->pdtid;
-  tid = priv->tid;
-
-  if (tid != PTHDB_INVALID_TID)
-    /* i18n: Like "thread-identifier %d, [state] running, suspended" */
-    buf.printf (_("tid %d"), (int)tid);

   status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+
+  /* Output should look like Thread %d (tid %d) ([state]).  */
+  /* Example:- Thread 1 (tid 34144587) ([running]).  */
+  /* where state can be running, idle, sleeping, finished,
+     suspended, detached, cancel pending, ready or unknown.  */
+
   if (status != PTHDB_SUCCESS)
     state = PST_NOTSUP;
-  buf.printf (", %s", state2str (state));
+  buf.printf ("[%s]", state2str (state));

   status = pthdb_pthread_suspendstate (data->pd_session, pdtid,
                                        &suspendstate);
   if (status == PTHDB_SUCCESS && suspendstate == PSS_SUSPENDED)
-    /* i18n: Like "Thread-Id %d, [state] running, suspended" */
-    buf.printf (_(", suspended"));
+    buf.printf (_("[suspended]"));

   status = pthdb_pthread_detachstate (data->pd_session, pdtid,
                                       &detachstate);
   if (status == PTHDB_SUCCESS && detachstate == PDS_DETACHED)
-    /* i18n: Like "Thread-Id %d, [state] running, detached" */
-    buf.printf (_(", detached"));
+    buf.printf (_("[detached]"));

   pthdb_pthread_cancelpend (data->pd_session, pdtid, &cancelpend);
   if (status == PTHDB_SUCCESS && cancelpend)
-    /* i18n: Like "Thread-Id %d, [state] running, cancel pending" */
-    buf.printf (_(", cancel pending"));
+    buf.printf (_("[cancel pending]"));

   buf.write ("", 1);

diff --git a/gdb/testsuite/gdb.threads/thread_events.exp b/gdb/testsuite/gdb.threads/thread_events.exp
index 100205e5f58..ca51abeb545 100644
--- a/gdb/testsuite/gdb.threads/thread_events.exp
+++ b/gdb/testsuite/gdb.threads/thread_events.exp
@@ -21,11 +21,9 @@
 # messages are printed and can be disabled) is dependent on the target
 # thread support code.

-# This test has only been verified with Linux targets, and would need
+# This test has been verified with Linux targets and AIX target, and would need
 # to be generalized to support other targets
-if {![istarget *-*-linux*]} {
-    return
-}
+require {is_any_target "*-*-linux*" "*-*-aix*"}

 # When using the RSP, we don't get notifications about new threads.
 # This is expected, so don't test for that.
--
2.41.0

^ permalink raw reply	[relevance 5%]

* [PATCH v2 3/5] gdb/testsuite: Add gdb.arch/aarch64-mops-watchpoint.exp
  @ 2024-05-07  2:22  4% ` Thiago Jung Bauermann
  0 siblings, 0 replies; 200+ results
From: Thiago Jung Bauermann @ 2024-05-07  2:22 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christophe Lyon

Test behaviour of watchpoints triggered by MOPS instructions.  This test
is similar to gdb.base/memops-watchpoint.exp, but specifically for MOPS
instructions rather than whatever instructions are used in the libc's
implementation of memset/memcpy/memmove.

There's a separate watched variable for each set of instructions so that
the testcase can test whether GDB correctly identified the watchpoint
that triggered in each case.
---
 .../gdb.arch/aarch64-mops-watchpoint.c        | 66 ++++++++++++++++
 .../gdb.arch/aarch64-mops-watchpoint.exp      | 79 +++++++++++++++++++
 gdb/testsuite/lib/gdb.exp                     | 61 ++++++++++++++
 3 files changed, 206 insertions(+)
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp

No change in v2.

diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c
new file mode 100644
index 000000000000..b981f033d210
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c
@@ -0,0 +1,66 @@
+/* This test program is part of GDB, the GNU debugger.
+
+   Copyright 2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int
+main (void)
+{
+  char source[40] __attribute__ ((aligned (8)))
+    = "This is a relatively long string...";
+  char a[40] __attribute__ ((aligned (8)))
+    = "String to be overwritten with zeroes";
+  char b[40] __attribute__ ((aligned (8)))
+    = "Another string to be memcopied...";
+  char c[40] __attribute__ ((aligned (8)))
+    = "Another string to be memmoved...";
+  char *p, *q;
+  long size, zero;
+
+  /* Break here.  */
+  p = a;
+  size = sizeof (a);
+  zero = 0;
+  /* memset implemented in MOPS instructions.  */
+  __asm__ volatile ("setp [%0]!, %1!, %2\n\t"
+		    "setm [%0]!, %1!, %2\n\t"
+		    "sete [%0]!, %1!, %2\n\t"
+		    : "+&r"(p), "+&r"(size)
+		    : "r"(zero)
+		    : "memory");
+
+  p = b;
+  q = source;
+  size = sizeof (b);
+  /* memmove implemented in MOPS instructions.  */
+  __asm__ volatile ("cpyp   [%0]!, [%1]!, %2!\n\t"
+		    "cpym   [%0]!, [%1]!, %2!\n\t"
+		    "cpye   [%0]!, [%1]!, %2!\n\t"
+		    : "+&r" (p), "+&r" (q), "+&r" (size)
+		    :
+		    : "memory");
+  p = c;
+  q = source;
+  size = sizeof (c);
+  /* memcpy implemented in MOPS instructions.  */
+  __asm__ volatile ("cpyfp   [%0]!, [%1]!, %2!\n\t"
+		    "cpyfm   [%0]!, [%1]!, %2!\n\t"
+		    "cpyfe   [%0]!, [%1]!, %2!\n\t"
+		    : "+&r" (p), "+&r" (q), "+&r" (size)
+		    :
+		    : "memory");
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp
new file mode 100644
index 000000000000..9e210602d800
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp
@@ -0,0 +1,79 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test a binary that uses MOPS (Memory Operations) instructions.
+# This test is similar to gdb.base/memops-watchpoint.exp, but specifically
+# tests MOPS instructions rather than whatever instructions are used in the
+# system libc's implementation of memset/memcpy/memmove.
+
+require allow_hw_watchpoint_tests allow_aarch64_mops_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+	  [list debug additional_flags=-march=armv9.3-a]] } {
+    return -1
+}
+
+set linespec ${srcfile}:[gdb_get_line_number "Break here"]
+if ![runto ${linespec}] {
+    return -1
+}
+
+gdb_test "watch -location a\[28\]" \
+    "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \
+    "set watch on a"
+gdb_test "watch -location b\[28\]" \
+    "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
+    "set watchpoint on b"
+gdb_test "watch -location c\[28\]" \
+    "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \
+    "set watchpoint on c"
+
+gdb_test "continue" \
+    [multi_line \
+	 "Continuing\\." \
+	 "" \
+	 "Hardware watchpoint ${decimal}: -location a\\\[28\\\]" \
+	 "" \
+	 "Old value = 104 'h'" \
+	 "New value = 0 '\\\\000'" \
+	 "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
+	 "${decimal}\\s+__asm__ volatile \\(\"setp.*\\\\n\\\\t\""] \
+    "continue until set watchpoint hits"
+
+gdb_test "continue" \
+    [multi_line \
+	 "Continuing\\." \
+	 "" \
+	 "Hardware watchpoint ${decimal}: -location b\\\[28\\\]" \
+	 "" \
+	 "Old value = 101 'e'" \
+	 "New value = 114 'r'" \
+	 "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
+	 "${decimal}\\s+__asm__ volatile \\(\"cpyp.*\\\\n\\\\t\""] \
+    "continue until cpy watchpoint hits"
+
+gdb_test "continue" \
+    [multi_line \
+	 "Continuing\\." \
+	 "" \
+	 "Hardware watchpoint ${decimal}: -location c\\\[28\\\]" \
+	 "" \
+	 "Old value = 100 'd'" \
+	 "New value = 114 'r'" \
+	 "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
+	 "${decimal}\\s+__asm__ volatile \\(\"cpyfp.*\\\\n\\\\t\""] \
+    "continue until cpyf watchpoint hits"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fe3f05c18df9..78c926ac80b6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4497,6 +4497,67 @@ proc aarch64_supports_sme_svl { length } {
     return 1
 }
 
+# Run a test on the target to see if it supports Aarch64 MOPS (Memory
+# Operations) extensions.  Return 0 if so, 1 if it does not.  Note this causes
+# a restart of GDB.
+
+gdb_caching_proc allow_aarch64_mops_tests {} {
+    global srcdir subdir gdb_prompt inferior_exited_re
+
+    set me "allow_aarch64_mops_tests"
+
+    if { ![is_aarch64_target]} {
+	return 0
+    }
+
+    # ARMv9.3-A contains the MOPS extension.  The test program doesn't use it,
+    # but take the opportunity to check whether the toolchain knows about MOPS.
+    set compile_flags "{additional_flags=-march=armv9.3-a}"
+
+    # Compile a program that tests the MOPS feature.
+    set src {
+	#include <stdbool.h>
+	#include <sys/auxv.h>
+
+	#ifndef HWCAP2_MOPS
+	#define HWCAP2_MOPS (1UL << 43)
+	#endif
+
+	int main() {
+	    bool mops_supported = getauxval (AT_HWCAP2) & HWCAP2_MOPS;
+
+	    return !mops_supported;
+	}
+    }
+
+    if {![gdb_simple_compile $me $src executable $compile_flags]} {
+	return 0
+    }
+
+    # Compilation succeeded so now run it via gdb.
+    clean_restart $obj
+    gdb_run_cmd
+    gdb_expect {
+	-re ".*$inferior_exited_re with code 01.*${gdb_prompt} $" {
+	    verbose -log "\n$me mops support not detected"
+	    set allow_mops_tests 0
+	}
+	-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
+	    verbose -log "\n$me: mops support detected"
+	    set allow_mops_tests 1
+	}
+	default {
+	  warning "\n$me: default case taken"
+	    set allow_mops_tests 0
+	}
+    }
+    gdb_exit
+    remote_file build delete $obj
+
+    verbose "$me:  returning $allow_mops_tests" 2
+    return $allow_mops_tests
+}
+
 # A helper that compiles a test case to see if __int128 is supported.
 proc gdb_int128_helper {lang} {
     return [gdb_can_simple_compile "i128-for-$lang" {

^ permalink raw reply	[relevance 4%]

* Re: Optionally print source code to gdb console window
  @ 2024-05-06 22:18 10% ` Robert Rossi
  0 siblings, 0 replies; 200+ results
From: Robert Rossi @ 2024-05-06 22:18 UTC (permalink / raw)
  To: gdb-patches


[-- Attachment #1.1: Type: text/plain, Size: 2075 bytes --]

I got an automated email saying I broke a test.

This updated patch fixes the test and updates the code to the GNU standard,
hopefully.

Thanks,
Bob Rossi


On Sun, May 5, 2024 at 4:57 PM Robert Rossi <bob@brasko.net> wrote:

> A little history. When using --annotations, gdb did not print the source
> code to the gdb console window. When using mi with new-ui it does. When I
> reported this in the past, several people said it was a feature that gdb
> printed the source code lines to the console.
>
> I've had several users of cgdb say they do not want gdb to print the
> source code to the gdb console window as they can see the code in the code
> view.
>
> I've created and attached a patch that I hope makes it optional to have
> gdb print the source code to the gdb console window. Could I have some
> feedback?
>
> I've added a new print source option to control printing source code to
> the gdb console.
>
> (gdb) show print source
> Printing of source code to gdb console is on.
>
> You can turn the printing of the source code off as follows.
> (gdb) set print source off
> (gdb)
>
> When the printing of source code is on,
> (gdb) r
> Starting program: /home/bob/rcs/git/gdb/gdb-build/main
> ....
> Breakpoint 1, main (argc=1, argv=0x7fffffffe0c8) at test_main.cpp:42
> 42      {
> (gdb) n
> 43          int i = 3;
> (gdb) n
> 44          int j = 4;
> (gdb) n
> 47          long_func();
>
> When the printing of source code is off,
> (gdb) r
> Starting program: /home/bob/rcs/git/gdb/gdb-build/main
> ...
> Breakpoint 1, main (argc=1, argv=0x7fffffffe098) at test_main.cpp:42
> (gdb) n
> (gdb) n
> (gdb) n
> (gdb)
>
> I don't know gdb code well enough to understand if i've disabled
> functionality
> beyond what i was hoping to.
>
> I'm not sure how to control this from cgdb when using old versions of gdb.
> I get the following error when i run --ex "set print source off" when
> starting gdb.
> Undefined set print command: "source off".  Try "help set print".
>
> Thanks,
> Bob Rossi
>

[-- Attachment #2: sourceprint-round2.diff --]
[-- Type: text/x-patch, Size: 2735 bytes --]

diff --git a/gdb/stack.c b/gdb/stack.c
index c2323e1726d..a9f967113f6 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1154,7 +1154,8 @@ do_print_frame_info (struct ui_out *uiout, const frame_print_options &fp_opts,
 	      uiout->text ("\t");
 	    }
 
-	  print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
+	  if (opts.sourceprint)
+	    print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
 	}
 
       /* If disassemble-next-line is set to on and there is line debug
diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
index 841e603764c..ac0949cd084 100644
--- a/gdb/testsuite/gdb.base/options.exp
+++ b/gdb/testsuite/gdb.base/options.exp
@@ -182,6 +182,7 @@ proc_with_prefix test-print {{prefix ""}} {
 	"-pretty"
 	"-raw-values"
 	"-repeats"
+	"-source"
 	"-static-members"
 	"-symbol"
 	"-union"
diff --git a/gdb/valprint.c b/gdb/valprint.c
index db8affeb47a..4b178282050 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -114,6 +114,7 @@ struct value_print_options user_print_options =
   true,				/* addressprint */
   false,			/* nibblesprint */
   false,			/* objectprint */
+  true,				/* sourceprint */
   PRINT_MAX_DEFAULT,		/* print_max */
   PRINT_MAX_CHARS_DEFAULT,	/* print_max_chars */
   10,				/* repeat_count_threshold */
@@ -2873,6 +2874,16 @@ Printing of C++ virtual function tables is %s.\n"),
 	      value);
 }
 
+/* Controls printing of source code.  */
+static void
+show_sourceprint (struct ui_file *file, int from_tty,
+		struct cmd_list_element *c, const char *value)
+{
+  gdb_printf (file, _("\
+Printing of source code to gdb console is %s.\n"),
+	      value);
+}
+
 /* Controls looking up an object's derived type using what we find in
    its vtables.  */
 static void
@@ -3083,6 +3094,14 @@ pretty-printers for that value.")
     N_("Show printing of C++ virtual function tables."),
     NULL, /* help_doc */
   },
+  boolean_option_def {
+    "source",
+    [] (value_print_options *opt) { return &opt->sourceprint; },
+    show_sourceprint, /* show_cmd_cb */
+    N_("Set printing of source code to gdb console."),
+    N_("Show printing of source code to gdb console."),
+    NULL, /* help_doc */
+  },
 };
 
 /* See valprint.h.  */
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 4f194b77008..c4672c03a9f 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -62,6 +62,9 @@ struct value_print_options
      in its vtables.  */
   bool objectprint;
 
+  /* Controls printing of source to console.  */
+  bool sourceprint;
+
   /* Maximum number of elements to print for vector contents, or UINT_MAX
      for no limit.  Note that "set print elements 0" stores UINT_MAX in
      print_max, which displays in a show command as "unlimited".  */

^ permalink raw reply	[relevance 10%]

* Re: [PATCH v2] Allow calling of user-defined function call operators
  @ 2024-05-06 12:29  0%       ` Guinevere Larsen
  0 siblings, 0 replies; 200+ results
From: Guinevere Larsen @ 2024-05-06 12:29 UTC (permalink / raw)
  To: Hannes Domani, gdb-patches

On 5/3/24 15:51, Hannes Domani wrote:
>   Am Freitag, 3. Mai 2024 um 20:29:47 MESZ hat Guinevere Larsen <blarsen@redhat.com> Folgendes geschrieben:
>
>> On 4/27/24 13:36, Hannes Domani wrote:
>>> Currently it's not possible to call user-defined function call
>>> operators, at least not without specifying operator() directly:
>>> ```
>>> (gdb) l 1
>>> 1      struct S {
>>> 2        int operator() (int x) { return x + 5; }
>>> 3      };
>>> 4
>>> 5      int main () {
>>> 6        S s;
>>> 7
>>> 8        return s(23);
>>> 9      }
>>> (gdb) p s(10)
>>> Invalid data type for function to be called.
>>> (gdb) p s.operator()(10)
>>> $1 = 15
>>> ```
>>>
>>> This now looks if an user-defined call operator is available when
>>> trying to 'call' a struct value, and calls it instead, making this
>>> possible:
>>> ```
>>> (gdb) p s(10)
>>> $1 = 15
>>> ```
>>>
>>> The change in operation::evaluate_funcall is to make sure the type
>>> fields are only used for function types, only they use them as the
>>> argument types.
>>>
>>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=12213
>>> ---
>>> v2:
>>> - Move the logic into evaluate_subexp_do_call, to avoid duplication in
>>>      every evaluate_funcall of each operation subclass.
>>>      This makes it now work for some cases it didn't in v1, like if it's
>>>      called on a class member (`print c.m(5)` in the new test).
>>> - Added tests for other (struct member) operations.
>>> ---
>>>    gdb/eval.c                      | 29 ++++++++++++++++++++++++++---
>>>    gdb/testsuite/gdb.cp/userdef.cc  | 22 ++++++++++++++++++++++
>>>    gdb/testsuite/gdb.cp/userdef.exp |  7 +++++++
>>>    3 files changed, 55 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/gdb/eval.c b/gdb/eval.c
>>> index 6b752e70635..8d5c354f480 100644
>>> --- a/gdb/eval.c
>>> +++ b/gdb/eval.c
>>> @@ -588,14 +588,35 @@ evaluate_subexp_do_call (expression *exp, enum noside noside,
>>>    {
>>>      if (callee == NULL)
>>>        error (_("Cannot evaluate function -- may be inlined"));
>>> +
>>> +  type *ftype = callee->type ();
>>> +
>>> +  /* If the callee is a struct, there might be a user-defined function call
>>> +    operator that should be used instead.  */
>>> +  std::vector<value *> vals;
>>> +  if (overload_resolution
>>> +      && exp->language_defn->la_language == language_cplus
>>> +      && check_typedef (ftype)->code () == TYPE_CODE_STRUCT)
>>> +    {
>>> +      vals.resize (argvec.size () + 1);
>>> +
>>> +      vals[0] = value_addr (callee);
>>> +      for (int i = 0; i < argvec.size (); ++i)
>>> +    vals[i + 1] = argvec[i];
>>> +
>>> +      int static_memfuncp;
>>> +      find_overload_match (vals, "operator()", METHOD, &vals[0], nullptr,
>>> +              &callee, nullptr, &static_memfuncp, 0, noside);
>>> +      if (!static_memfuncp)
>>> +    argvec = vals;
>> I don't really understand this change. From what I can see in this
>> patch, you're just shifting all values in argvec one to the right, to
>> add the callee address. Wouldn't this necessitate a change in the logic
>> for the rest of the function?
> Yes, this adds the 'this' pointer as the first argument for operator().
Ah, thanks for explaining! I think a comment would be pretty helpful in 
this situation.
> I'm not sure why this would change the logic for the rest of the function.

My thinking is that, on some situations for the rest of the function, 
there may be one too many arguments. To give a concrete example, I 
thought that if you had foo.bar(), where bar is a regular method, this 
could be adding the "this" argument one too many times. But that would 
mean "callee" is 'foo', and re-reading with fresh eyes, callee is 
supposed to be "bar", right?

>
>
>>> +    }
>>> +
>>>      if (noside == EVAL_AVOID_SIDE_EFFECTS)
>>>        {
>>>          /* If the return type doesn't look like a function type,
>>>        call an error.  This can happen if somebody tries to turn
>>>        a variable into a function call.  */
>>>
>>> -      type *ftype = callee->type ();
>>> -
>>>          if (ftype->code () == TYPE_CODE_INTERNAL_FUNCTION)
>>>        {
>>>          /* We don't know anything about what the internal
>>> @@ -666,9 +687,11 @@ operation::evaluate_funcall (struct type *expect_type,
>>>      struct type *type = callee->type ();
>>>      if (type->code () == TYPE_CODE_PTR)
>>>        type = type->target_type ();
>>> +  bool type_has_arguments
>>> +    = type->code () == TYPE_CODE_FUNC || type->code () == TYPE_CODE_METHOD;
>>>      for (int i = 0; i < args.size (); ++i)
>>>        {
>>> -      if (i < type->num_fields ())
>>> +      if (type_has_arguments && i < type->num_fields ())
>> This change also looks to be unrelated to this patch?
> It's what I described here:
>
>> The change in operation::evaluate_funcall is to make sure the type
>> fields are only used for function types, only they use them as the
>> argument types.
>   
> Before this patch it didn't matter if it used the field types in the
> evaluate calls, but since the caller type could now also be a struct,
> these would be the struct fields types, not function arguments.

Ooohh, I see.

Again, I think a code comment would help a lot. Something above the if, 
saying for example:

     "If type is a struct, num_fields would refer to the number of 
members in the type, not the number of arguments"

or similar.

-- 
Cheers,
Guinevere Larsen
She/Her/Hers

>
>
> Hannes
>


^ permalink raw reply	[relevance 0%]

* [PATCH 3/5] gdb/testsuite: Add gdb.arch/aarch64-mops-watchpoint.exp
  @ 2024-05-04  0:05  4% ` Thiago Jung Bauermann
  0 siblings, 0 replies; 200+ results
From: Thiago Jung Bauermann @ 2024-05-04  0:05 UTC (permalink / raw)
  To: gdb-patches

Test behaviour of watchpoints triggered by MOPS instructions.  This test
is similar to gdb.base/memops-watchpoint.exp, but specifically for MOPS
instructions rather than whatever instructions are used in the libc's
implementation of memset/memcpy/memmove.

There's a separate watched variable for each set of instructions so that
the testcase can test whether GDB correctly identified the watchpoint
that triggered in each case.
---
 .../gdb.arch/aarch64-mops-watchpoint.c        | 66 ++++++++++++++++
 .../gdb.arch/aarch64-mops-watchpoint.exp      | 79 +++++++++++++++++++
 gdb/testsuite/lib/gdb.exp                     | 61 ++++++++++++++
 3 files changed, 206 insertions(+)
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp

diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c
new file mode 100644
index 000000000000..b981f033d210
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c
@@ -0,0 +1,66 @@
+/* This test program is part of GDB, the GNU debugger.
+
+   Copyright 2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int
+main (void)
+{
+  char source[40] __attribute__ ((aligned (8)))
+    = "This is a relatively long string...";
+  char a[40] __attribute__ ((aligned (8)))
+    = "String to be overwritten with zeroes";
+  char b[40] __attribute__ ((aligned (8)))
+    = "Another string to be memcopied...";
+  char c[40] __attribute__ ((aligned (8)))
+    = "Another string to be memmoved...";
+  char *p, *q;
+  long size, zero;
+
+  /* Break here.  */
+  p = a;
+  size = sizeof (a);
+  zero = 0;
+  /* memset implemented in MOPS instructions.  */
+  __asm__ volatile ("setp [%0]!, %1!, %2\n\t"
+		    "setm [%0]!, %1!, %2\n\t"
+		    "sete [%0]!, %1!, %2\n\t"
+		    : "+&r"(p), "+&r"(size)
+		    : "r"(zero)
+		    : "memory");
+
+  p = b;
+  q = source;
+  size = sizeof (b);
+  /* memmove implemented in MOPS instructions.  */
+  __asm__ volatile ("cpyp   [%0]!, [%1]!, %2!\n\t"
+		    "cpym   [%0]!, [%1]!, %2!\n\t"
+		    "cpye   [%0]!, [%1]!, %2!\n\t"
+		    : "+&r" (p), "+&r" (q), "+&r" (size)
+		    :
+		    : "memory");
+  p = c;
+  q = source;
+  size = sizeof (c);
+  /* memcpy implemented in MOPS instructions.  */
+  __asm__ volatile ("cpyfp   [%0]!, [%1]!, %2!\n\t"
+		    "cpyfm   [%0]!, [%1]!, %2!\n\t"
+		    "cpyfe   [%0]!, [%1]!, %2!\n\t"
+		    : "+&r" (p), "+&r" (q), "+&r" (size)
+		    :
+		    : "memory");
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp
new file mode 100644
index 000000000000..9e210602d800
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp
@@ -0,0 +1,79 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test a binary that uses MOPS (Memory Operations) instructions.
+# This test is similar to gdb.base/memops-watchpoint.exp, but specifically
+# tests MOPS instructions rather than whatever instructions are used in the
+# system libc's implementation of memset/memcpy/memmove.
+
+require allow_hw_watchpoint_tests allow_aarch64_mops_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+	  [list debug additional_flags=-march=armv9.3-a]] } {
+    return -1
+}
+
+set linespec ${srcfile}:[gdb_get_line_number "Break here"]
+if ![runto ${linespec}] {
+    return -1
+}
+
+gdb_test "watch -location a\[28\]" \
+    "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \
+    "set watch on a"
+gdb_test "watch -location b\[28\]" \
+    "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
+    "set watchpoint on b"
+gdb_test "watch -location c\[28\]" \
+    "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \
+    "set watchpoint on c"
+
+gdb_test "continue" \
+    [multi_line \
+	 "Continuing\\." \
+	 "" \
+	 "Hardware watchpoint ${decimal}: -location a\\\[28\\\]" \
+	 "" \
+	 "Old value = 104 'h'" \
+	 "New value = 0 '\\\\000'" \
+	 "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
+	 "${decimal}\\s+__asm__ volatile \\(\"setp.*\\\\n\\\\t\""] \
+    "continue until set watchpoint hits"
+
+gdb_test "continue" \
+    [multi_line \
+	 "Continuing\\." \
+	 "" \
+	 "Hardware watchpoint ${decimal}: -location b\\\[28\\\]" \
+	 "" \
+	 "Old value = 101 'e'" \
+	 "New value = 114 'r'" \
+	 "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
+	 "${decimal}\\s+__asm__ volatile \\(\"cpyp.*\\\\n\\\\t\""] \
+    "continue until cpy watchpoint hits"
+
+gdb_test "continue" \
+    [multi_line \
+	 "Continuing\\." \
+	 "" \
+	 "Hardware watchpoint ${decimal}: -location c\\\[28\\\]" \
+	 "" \
+	 "Old value = 100 'd'" \
+	 "New value = 114 'r'" \
+	 "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
+	 "${decimal}\\s+__asm__ volatile \\(\"cpyfp.*\\\\n\\\\t\""] \
+    "continue until cpyf watchpoint hits"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fe3f05c18df9..78c926ac80b6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4497,6 +4497,67 @@ proc aarch64_supports_sme_svl { length } {
     return 1
 }
 
+# Run a test on the target to see if it supports Aarch64 MOPS (Memory
+# Operations) extensions.  Return 0 if so, 1 if it does not.  Note this causes
+# a restart of GDB.
+
+gdb_caching_proc allow_aarch64_mops_tests {} {
+    global srcdir subdir gdb_prompt inferior_exited_re
+
+    set me "allow_aarch64_mops_tests"
+
+    if { ![is_aarch64_target]} {
+	return 0
+    }
+
+    # ARMv9.3-A contains the MOPS extension.  The test program doesn't use it,
+    # but take the opportunity to check whether the toolchain knows about MOPS.
+    set compile_flags "{additional_flags=-march=armv9.3-a}"
+
+    # Compile a program that tests the MOPS feature.
+    set src {
+	#include <stdbool.h>
+	#include <sys/auxv.h>
+
+	#ifndef HWCAP2_MOPS
+	#define HWCAP2_MOPS (1UL << 43)
+	#endif
+
+	int main() {
+	    bool mops_supported = getauxval (AT_HWCAP2) & HWCAP2_MOPS;
+
+	    return !mops_supported;
+	}
+    }
+
+    if {![gdb_simple_compile $me $src executable $compile_flags]} {
+	return 0
+    }
+
+    # Compilation succeeded so now run it via gdb.
+    clean_restart $obj
+    gdb_run_cmd
+    gdb_expect {
+	-re ".*$inferior_exited_re with code 01.*${gdb_prompt} $" {
+	    verbose -log "\n$me mops support not detected"
+	    set allow_mops_tests 0
+	}
+	-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
+	    verbose -log "\n$me: mops support detected"
+	    set allow_mops_tests 1
+	}
+	default {
+	  warning "\n$me: default case taken"
+	    set allow_mops_tests 0
+	}
+    }
+    gdb_exit
+    remote_file build delete $obj
+
+    verbose "$me:  returning $allow_mops_tests" 2
+    return $allow_mops_tests
+}
+
 # A helper that compiles a test case to see if __int128 is supported.
 proc gdb_int128_helper {lang} {
     return [gdb_can_simple_compile "i128-for-$lang" {

^ permalink raw reply	[relevance 4%]

* Re: [PATCH v3 3/3] Make thread_db_target::pid_to_str checkpoint-aware
  @ 2024-05-03 15:55  8%   ` Pedro Alves
  0 siblings, 0 replies; 200+ results
From: Pedro Alves @ 2024-05-03 15:55 UTC (permalink / raw)
  To: Kevin Buettner, gdb-patches

On 2024-04-14 20:44, Kevin Buettner wrote:
> This commit prevents thread_db_target::pid_to_str from considering
> a checkpoint as a thread.  The reason for doing this is that pids
> associated with checkpoints can never be a thread due to the fact
> that checkpoints (which are implemented by forking a process) can
> only work with single-threaded processes.

Well, that isn't strictly true, as a checkpoint can spawn a new
thread/clone.   Or even exec...  But let's not go there...

> 
> Without this commit, many of the "info checkpoints" commands
> in gdb.multi/checkpoint-multi.exp will incorrectly show some
> of the checkpoints as threads.  E.g...
> 
> *  1.0 A  Thread 0x7ffff7cd3740 (LWP 128534) at 0x401199, file hello.c, line 51
>    1.2    process 128546 at 0x401199, file hello.c, line 51
>    1.3    process 128547 at 0x401199, file hello.c, line 51
>    2.1    process 128538 at 0x401258, file goodbye.c, line 62
>    2.2 A  Thread 0x7ffff7cd3740 (LWP 128542) at 0x401258, file goodbye.c, line 62
>    3.0 A  Thread 0x7ffff7cd3740 (LWP 128543) at 0x40115c, file hangout.c, line 31
>    3.2    process 128545 at 0x40115c, file hangout.c, line 31
> 
> With this commit in place, the output looks like this instead:
> 
> *  1.0 A  process 129961 at 0x401199, file hello.c, line 51
>    1.2    process 129974 at 0x401199, file hello.c, line 51
>    1.3    process 129975 at 0x401199, file hello.c, line 51
>    2.1    process 129965 at 0x401258, file goodbye.c, line 62
>    2.2 A  process 129969 at 0x401258, file goodbye.c, line 62
>    3.0 A  process 129970 at 0x40115c, file hangout.c, line 31
>    3.2    process 129972 at 0x40115c, file hangout.c, line 31
> 
> (For brevity, I've removed the directory elements in each of the paths
> above.)
> 
> The testcase, gdb.multi/checkpoint-multi.exp, has been updated to
> reflect the fact that only "process" should now appear in output
> from "info checkpoints".
> ---
>  gdb/linux-thread-db.c                        | 4 +++-
>  gdb/testsuite/gdb.multi/checkpoint-multi.exp | 2 +-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
> index 65bf4a79fdf..488a7086acf 100644
> --- a/gdb/linux-thread-db.c
> +++ b/gdb/linux-thread-db.c
> @@ -48,6 +48,7 @@
>  #include "gdbsupport/pathstuff.h"
>  #include "valprint.h"
>  #include "cli/cli-style.h"
> +#include "linux-fork.h"
>  
>  /* GNU/Linux libthread_db support.
>  
> @@ -1657,7 +1658,8 @@ thread_db_target::pid_to_str (ptid_t ptid)
>  {
>    thread_info *thread_info = current_inferior ()->find_thread (ptid);
>  
> -  if (thread_info != NULL && thread_info->priv != NULL)
> +  if (thread_info != NULL && thread_info->priv != NULL
> +      && !forks_exist_p (current_inferior ()))
>      {
>        thread_db_thread_info *priv = get_thread_db_thread_info (thread_info);
>  

I think that it's better to change linux-fork.c, avoid special casing checkpoints
if we can.  If linux-fork.c wants to print a process, then it should pass down a
process ptid.  Like:

diff --git c/gdb/linux-fork.c w/gdb/linux-fork.c
index e35e438cabc..9003b43dc82 100644
--- c/gdb/linux-fork.c
+++ w/gdb/linux-fork.c
@@ -807,7 +807,8 @@ info_checkpoints_command (const char *arg, int from_tty)
          else
            gdb_printf ("   ");
 
-         gdb_printf ("%s", target_pid_to_str (fi.ptid).c_str ());
+         ptid_t pid_ptid (fi.ptid.pid ());
+         gdb_printf ("%s", target_pid_to_str (pid_ptid).c_str ());
 
          gdb_printf (_(" at "));
          ULONGEST pc



^ permalink raw reply	[relevance 8%]

* Re:  [PATCH v4] Fix AIX thread exit events not being reported and UI to show  kernel thread ID.
  @ 2024-05-03 14:34  5% ` Aditya Kamath1
  0 siblings, 0 replies; 200+ results
From: Aditya Kamath1 @ 2024-05-03 14:34 UTC (permalink / raw)
  To: Aditya Vidyadhar Kamath, tom
  Cc: Ulrich Weigand, gdb-patches, Sangamesh Mallayya, jhb

[-- Attachment #1: Type: text/plain, Size: 20220 bytes --]

Respected community members,

Please check out the v4 of this patch and review the same.

Thank you for the feedback so far.

This patch works.

Kindly let me know if any changes. Test cases changes also is done in this patch itself.

Kindly push this patch if there are no changes needed.

Have a nice day ahead.

Thanks and regards,
Aditya.



Gdb.threads/thread_events.exp test case result after this patch

=== gdb Summary ===

# of expected passes            11
/current_gdb/binutils-gdb/gdb/gdb version  15.0.50.20240325-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /current_gdb/binutils-gdb/gdb/data-directory

Output of program 1(Program 1 Pasted below this email)
Reading symbols from testsuite/gdb.threads/thread_events...
(gdb) b main
Breakpoint 1 at 0x100007dc: file gdb.threads/thread_events.c, line 41.
(gdb) r
Starting program: /current_gdb/binutils-gdb/gdb/testsuite/gdb.threads/thread_events

Breakpoint 1, main (argc=1, argv=0x2ff22940) at gdb.threads/thread_events.c:41
41        if (pthread_create (&thread, NULL, threadfunc, NULL) != 0)
(gdb) b threadfunc
Breakpoint 2 at 0x10000718: file gdb.threads/thread_events.c, line 27.
(gdb) b after_join_func
Breakpoint 3 at 0x10000778: file gdb.threads/thread_events.c, line 34.
(gdb) c
Continuing.
[New Thread 258 (tid 24969631)]
[Switching to Thread 258 (tid 24969631)]

Thread 2 hit Breakpoint 2, threadfunc (arg=0x0) at gdb.threads/thread_events.c:27
27        printf ("in threadfunc\n");
(gdb)
Continuing.
in threadfunc
[Thread 258 (tid 24969631) exited]
[Switching to Thread 1 (tid 34341137)]

Thread 1 hit Breakpoint 3, after_join_func () at gdb.threads/thread_events.c:34
34        printf ("finished\n");
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 34341137) ([running]) after_join_func () at gdb.threads/thread_events.c:34
(gdb) c
Continuing.
finished
[Thread 1 (tid 34341137) exited]
[Inferior 1 (process 11338122) exited normally]
(gdb) q

Program 1:

/*   This file was written by Chris Demetriou (cgd@google.com<mailto:cgd@google.com>).  */

/* Simple test to trigger thread events (thread start, thread exit).  */

#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

static void *
threadfunc (void *arg)
{
  printf ("in threadfunc\n");
  return NULL;
}

static void
after_join_func (void)
{
  printf ("finished\n");
}

int main (int argc, char *argv[])
{
  pthread_t thread;

  if (pthread_create (&thread, NULL, threadfunc, NULL) != 0)
    {
      printf ("pthread_create failed\n");
      exit (1);
    }

  if (pthread_join (thread, NULL) != 0)
    {
      printf ("pthread_join failed\n");
      exit (1);
    }

  after_join_func ();
  return 0;
}



Output of program 2 [Program 2 pasted below]

Reading symbols from //gdb_tests/continue-pending-status_exit_test...
(gdb) r
Starting program: /gdb_tests/continue-pending-status_exit_test
Hello World
Hello World
More threads
Hello World
Hello World
Hello World
Hello World
[New Thread 258 (tid 24969633)]
[Thread 258 (tid 24969633) exited]
[New Thread 515 (tid 30540067)]
[Thread 515 (tid 30540067) exited]
[New Thread 772 (tid 30671107)]
[Thread 772 (tid 30671107) exited]
[New Thread 1029 (tid 31588767)]
[Thread 1029 (tid 31588767) exited]
[New Thread 1286 (tid 30998947)]
[Thread 1286 (tid 30998947) exited]
[New Thread 1543 (tid 28967413)]
[Thread 1543 (tid 28967413) exited]

Thread 1 received signal SIGINT, Interrupt.
0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 34341139) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) q
A debugging session is active.

        Inferior 1 [process 11338126] will be killed.

Quit anyway? (y or n) y

Program 2:

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>

pthread_barrier_t barrier;

#define NUM_THREADS 3

void *
thread_function (void *arg)
{
  /* This ensures that the breakpoint is only hit after both threads
     are created, so the test can always switch to the non-event
     thread when the breakpoint triggers.  */
//  pthread_barrier_wait (&barrier);

  printf ("Hello World \n"); /* break here */
}

int
main (void)
{
  int i;

  alarm (300);

  pthread_barrier_init (&barrier, NULL, NUM_THREADS);

  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_t thread;
      int res;

      res = pthread_create (&thread, NULL,
                            thread_function, NULL);
      assert (res == 0);
    }

  printf ("More threads \n");
  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_t thread;
      int res;

      res = pthread_create (&thread, NULL,
                thread_function, NULL);
      assert (res == 0);
    }
  while (1)
    sleep (1);

  return 0;
}


From: Aditya Vidyadhar Kamath <akamath996@gmail.com>
Date: Friday, 3 May 2024 at 7:57 PM
To: tom@tromey.com <tom@tromey.com>
Cc: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>, jhb@FreeBSD.org <jhb@FreeBSD.org>
Subject: [EXTERNAL] [PATCH v4] Fix AIX thread exit events not being reported and UI to show kernel thread ID.
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>

In AIX when a thread exits we were not showing that a thread exit event happened
and GDB continued to keep the terminated threads.

If we have terminated threads then the UI on info threads command will look like
(gdb) info threads
  Id   Target Id                                          Frame
* 1    Thread 1 (tid 26607979, running)    0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
  2    Thread 258 (tid 30998799, finished) aix-thread: ptrace (52, 30998799) returned -1 (errno = 3 The process does not exist.)

If we see the frame is not getting displayed correctly.

The reason for the same is that in AIX we were not managing thread states. In particular we do not know
when a thread terminates.

The reason being in sync_threadlists () the pbuf and gbuf lists remain the same though certain threads exit.

This patch is a fix to the same.

Also certain UI is changed.

On a new thread born and exit the UI in AIX will be similar to Linux with both user and kernel thread information.

[New Thread 258 (tid 32178533)]
[New Thread 515 (tid 30343651)]
[New Thread 772 (tid 33554909)]
[New Thread 1029 (tid 24969489)]
[New Thread 1286 (tid 18153945)]
[New Thread 1543 (tid 30736739)]
[Thread 258 (tid 32178533) exited]
[Thread 515 (tid 30343651) exited]
[Thread 772 (tid 33554909) exited]
[Thread 1029 (tid 24969489) exited]
[Thread 1286 (tid 18153945) exited]
[Thread 1543 (tid 30736739) exited]

and info threads will look like
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 31326579) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)

Also a small change to testcase gdb.threads/thread_events.exp to make sure this test runs on AIX as well.
---
 gdb/aix-thread.c                            | 244 +++++++-------------
 gdb/testsuite/gdb.threads/thread_events.exp |   4 +-
 2 files changed, 80 insertions(+), 168 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index c70bd82bc24..c513e5e628f 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -55,6 +55,7 @@
 #include <sys/reg.h>
 #include <sched.h>
 #include <sys/pthdebug.h>
+#include <unordered_set>

 #if !HAVE_DECL_GETTHRDS
 extern int getthrds (pid_t, struct thrdsinfo64 *, int, tid_t *, int);
@@ -190,6 +191,9 @@ struct aix_thread_variables
   /* Whether the current architecture is 64-bit.
    Only valid when pd_able is true.  */
   int arch64;
+
+  /* Describes the number of thread exit events reported.  */
+  std::unordered_set<pthdb_pthread_t> exited_threads;
 };

 /* Key to our per-inferior data.  */
@@ -737,47 +741,6 @@ state2str (pthdb_state_t state)
     }
 }

-/* qsort() comparison function for sorting pd_thread structs by pthid.  */
-
-static int
-pcmp (const void *p1v, const void *p2v)
-{
-  struct pd_thread *p1 = (struct pd_thread *) p1v;
-  struct pd_thread *p2 = (struct pd_thread *) p2v;
-  return p1->pthid < p2->pthid ? -1 : p1->pthid > p2->pthid;
-}
-
-/* ptid comparison function */
-
-static int
-ptid_cmp (ptid_t ptid1, ptid_t ptid2)
-{
-  if (ptid1.pid () < ptid2.pid ())
-    return -1;
-  else if (ptid1.pid () > ptid2.pid ())
-    return 1;
-  else if (ptid1.tid () < ptid2.tid ())
-    return -1;
-  else if (ptid1.tid () > ptid2.tid ())
-    return 1;
-  else if (ptid1.lwp () < ptid2.lwp ())
-    return -1;
-  else if (ptid1.lwp () > ptid2.lwp ())
-    return 1;
-  else
-    return 0;
-}
-
-/* qsort() comparison function for sorting thread_info structs by pid.  */
-
-static int
-gcmp (const void *t1v, const void *t2v)
-{
-  struct thread_info *t1 = *(struct thread_info **) t1v;
-  struct thread_info *t2 = *(struct thread_info **) t2v;
-  return ptid_cmp (t1->ptid, t2->ptid);
-}
-
 /* Search through the list of all kernel threads for the thread
    that has stopped on a SIGTRAP signal, and return its TID.
    Return 0 if none found.  */
@@ -822,22 +785,17 @@ static void
 sync_threadlists (pid_t pid)
 {
   int cmd, status;
-  int pcount, psize, pi, gcount, gi;
-  struct pd_thread *pbuf;
-  struct thread_info **gbuf, **g, *thread;
   pthdb_pthread_t pdtid;
   pthread_t pthid;
   pthdb_tid_t tid;
   process_stratum_target *proc_target = current_inferior ()->process_target ();
   struct aix_thread_variables *data;
   data = get_thread_data_helper_for_pid (pid);
+  pthdb_state_t state;
+  std::set<pthdb_pthread_t> in_queue_threads;

   /* Accumulate an array of libpthdebug threads sorted by pthread id.  */

-  pcount = 0;
-  psize = 1;
-  pbuf = XNEWVEC (struct pd_thread, psize);
-
   for (cmd = PTHDB_LIST_FIRST;; cmd = PTHDB_LIST_NEXT)
     {
       status = pthdb_pthread (data->pd_session, &pdtid, cmd);
@@ -848,118 +806,68 @@ sync_threadlists (pid_t pid)
       if (status != PTHDB_SUCCESS || pthid == PTHDB_INVALID_PTID)
         continue;

-      if (pcount == psize)
-       {
-         psize *= 2;
-         pbuf = (struct pd_thread *) xrealloc (pbuf,
-                                               psize * sizeof *pbuf);
-       }
-      pbuf[pcount].pdtid = pdtid;
-      pbuf[pcount].pthid = pthid;
-      pcount++;
-    }
-
-  for (pi = 0; pi < pcount; pi++)
-    {
-      status = pthdb_pthread_tid (data->pd_session, pbuf[pi].pdtid, &tid);
-      if (status != PTHDB_SUCCESS)
-       tid = PTHDB_INVALID_TID;
-      pbuf[pi].tid = tid;
-    }
-
-  qsort (pbuf, pcount, sizeof *pbuf, pcmp);
-
-  /* Accumulate an array of GDB threads sorted by pid.  */
-
-  /* gcount is GDB thread count and pcount is pthreadlib thread count.  */
-
-  gcount = 0;
-  for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))
-    gcount++;
-  g = gbuf = XNEWVEC (struct thread_info *, gcount);
-  for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))
-    *g++ = tp;
-  qsort (gbuf, gcount, sizeof *gbuf, gcmp);
+      ptid_t ptid (pid, 0, pthid);
+      status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+      in_queue_threads.insert (pdtid);

-  /* Apply differences between the two arrays to GDB's thread list.  */
-
-  for (pi = gi = 0; pi < pcount || gi < gcount;)
-    {
-      if (pi == pcount)
+      /* If this thread has reported and exited, do not add it again.  */
+      if (state == PST_TERM)
         {
-         delete_thread (gbuf[gi]);
-         gi++;
+         if (data->exited_threads.count (pdtid) != 0)
+            continue;
         }
-      else if (gi == gcount)
-       {
-         aix_thread_info *priv = new aix_thread_info;
-         priv->pdtid = pbuf[pi].pdtid;
-         priv->tid = pbuf[pi].tid;

-         thread = add_thread_with_info (proc_target,
-                                        ptid_t (pid, 0, pbuf[pi].pthid),
-                                        private_thread_info_up (priv));
-
-         pi++;
-       }
-      else
+      /* If this thread has never been reported to GDB, add it.  */
+      if (!in_thread_list (proc_target, ptid))
         {
-         ptid_t pptid, gptid;
-         int cmp_result;
-
-         pptid = ptid_t (pid, 0, pbuf[pi].pthid);
-         gptid = gbuf[gi]->ptid;
-         pdtid = pbuf[pi].pdtid;
-         tid = pbuf[pi].tid;
-
-         cmp_result = ptid_cmp (pptid, gptid);
-
-         if (cmp_result == 0)
-           {
-             aix_thread_info *priv = get_aix_thread_info (gbuf[gi]);
-
-             priv->pdtid = pdtid;
-             priv->tid = tid;
-             pi++;
-             gi++;
-           }
-         else if (cmp_result > 0)
+         aix_thread_info *priv = new aix_thread_info;
+         /* init priv */
+         priv->pdtid = pdtid;
+         status = pthdb_pthread_tid (data->pd_session, pdtid, &tid);
+         priv->tid = tid;
+         /* Check if this is the main thread.  If it is, then change
+            its ptid and add its private data.  */
+         if (get_signaled_thread (pid) == tid
+               && in_thread_list (proc_target, ptid_t (pid)))
             {
-             /* This is to make the main process thread now look
-                like a thread.  */
-
-             if (gptid.is_pid ())
-               {
-                 thread_info *tp = proc_target->find_thread (gptid);
-                 thread_change_ptid (proc_target, gptid, pptid);
-                 aix_thread_info *priv = new aix_thread_info;
-                 priv->pdtid = pbuf[pi].pdtid;
-                 priv->tid = pbuf[pi].tid;
-                 tp->priv.reset (priv);
-                 gi++;
-                 pi++;
-               }
-             else
-               {
-                 delete_thread (gbuf[gi]);
-                 gi++;
-               }
+             thread_info *tp = proc_target->find_thread (ptid_t (pid));
+             thread_change_ptid (proc_target, ptid_t (pid), ptid);
+             tp->priv.reset (priv);
             }
           else
-           {
-             thread = add_thread (proc_target, pptid);
+           add_thread_with_info (proc_target, ptid,
+               private_thread_info_up (priv));
+       }

-             aix_thread_info *priv = new aix_thread_info;
-             thread->priv.reset (priv);
-             priv->pdtid = pdtid;
-             priv->tid = tid;
-             pi++;
-           }
+      /* The thread is terminated. Remove it.  */
+      if (state == PST_TERM)
+       {
+         thread_info *thr = proc_target->find_thread (ptid);
+         gdb_assert (thr != nullptr);
+         delete_thread (thr);
+         data->exited_threads.insert (pdtid);
         }
     }

-  xfree (pbuf);
-  xfree (gbuf);
+    /* Sometimes there can be scenarios where the thread status is
+       unknown and we it will never iterate in the for loop above,
+       since cmd will be no longer be pointing to that threads.  One
+       such scenario is the gdb.threads/thread_events.exp testcase
+       where in the end after the threadfunc breakpoint is hit, the
+       thread exits and gets into a PST_UNKNOWN state.  So this thread
+       will not run in the above for loop.  Therefore the below for loop
+       is to manually delete such threads.  */
+    for (struct thread_info *it : all_threads ())
+      {
+       aix_thread_info *priv = get_aix_thread_info (it);
+       auto itr = in_queue_threads.find (priv->pdtid);
+       if (itr == in_queue_threads.end ()
+               && in_thread_list (proc_target, it->ptid))
+         {
+           delete_thread (it);
+           data->exited_threads.insert (priv->pdtid);
+         }
+      }
 }

 /* Iterate_over_threads() callback for locating a thread, using
@@ -1013,8 +921,8 @@ pd_update (pid_t pid)
 }

 /* Try to start debugging threads in the current process.
-   If successful and there exists and we can find an event thread, return a ptid
-   for that thread.  Otherwise, return a ptid-only ptid using PID.  */
+   If successful and there exists and we can find an event thread, set
+   pd_active for that thread.  Otherwise, return.  */

 static void
 pd_activate (pid_t pid)
@@ -2084,10 +1992,17 @@ aix_thread_target::thread_alive (ptid_t ptid)
 std::string
 aix_thread_target::pid_to_str (ptid_t ptid)
 {
-  if (ptid.tid () == 0)
-    return beneath ()->pid_to_str (ptid);
+  thread_info *thread_info = current_inferior ()->find_thread (ptid);

-  return string_printf (_("Thread %s"), pulongest (ptid.tid ()));
+  if (thread_info != NULL && thread_info->priv != NULL)
+    {
+      aix_thread_info *priv = get_aix_thread_info (thread_info);
+
+      return string_printf (_("Thread %s (tid %s)"), pulongest (ptid.tid ()),
+               pulongest (priv->tid));
+    }
+
+  return beneath ()->pid_to_str (ptid);
 }

 /* Return a printable representation of extra information about
@@ -2098,7 +2013,6 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
 {
   int status;
   pthdb_pthread_t pdtid;
-  pthdb_tid_t tid;
   pthdb_state_t state;
   pthdb_suspendstate_t suspendstate;
   pthdb_detachstate_t detachstate;
@@ -2115,33 +2029,31 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
   aix_thread_info *priv = get_aix_thread_info (thread);

   pdtid = priv->pdtid;
-  tid = priv->tid;
-
-  if (tid != PTHDB_INVALID_TID)
-    /* i18n: Like "thread-identifier %d, [state] running, suspended" */
-    buf.printf (_("tid %d"), (int)tid);

   status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+
+  /* Output should look like Thread %d (tid %d) ([state]).  */
+  /* Example:- Thread 1 (tid 34144587) ([running]).  */
+  /* where state can be running, idle, sleeping, finished,
+     suspended, detached, cancel pending, ready or unknown.  */
+
   if (status != PTHDB_SUCCESS)
     state = PST_NOTSUP;
-  buf.printf (", %s", state2str (state));
+  buf.printf ("[%s]", state2str (state));

   status = pthdb_pthread_suspendstate (data->pd_session, pdtid,
                                        &suspendstate);
   if (status == PTHDB_SUCCESS && suspendstate == PSS_SUSPENDED)
-    /* i18n: Like "Thread-Id %d, [state] running, suspended" */
-    buf.printf (_(", suspended"));
+    buf.printf (_("[suspended]"));

   status = pthdb_pthread_detachstate (data->pd_session, pdtid,
                                       &detachstate);
   if (status == PTHDB_SUCCESS && detachstate == PDS_DETACHED)
-    /* i18n: Like "Thread-Id %d, [state] running, detached" */
-    buf.printf (_(", detached"));
+    buf.printf (_("[detached]"));

   pthdb_pthread_cancelpend (data->pd_session, pdtid, &cancelpend);
   if (status == PTHDB_SUCCESS && cancelpend)
-    /* i18n: Like "Thread-Id %d, [state] running, cancel pending" */
-    buf.printf (_(", cancel pending"));
+    buf.printf (_("[cancel pending]"));

   buf.write ("", 1);

diff --git a/gdb/testsuite/gdb.threads/thread_events.exp b/gdb/testsuite/gdb.threads/thread_events.exp
index 100205e5f58..9c3f9ce1708 100644
--- a/gdb/testsuite/gdb.threads/thread_events.exp
+++ b/gdb/testsuite/gdb.threads/thread_events.exp
@@ -21,9 +21,9 @@
 # messages are printed and can be disabled) is dependent on the target
 # thread support code.

-# This test has only been verified with Linux targets, and would need
+# This test has been verified with Linux targets and AIX target, and would need
 # to be generalized to support other targets
-if {![istarget *-*-linux*]} {
+if {!([istarget *-*-linux*] || [istarget *-*-aix*])} {
     return
 }

--
2.41.0

^ permalink raw reply	[relevance 5%]

* Re: [PATCH v2] sim: riscv: Fix Zicsr and fence instructions
  @ 2024-05-03 11:51  0%   ` Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-05-03 11:51 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 5/1/24 17:39, Andrew Burgess wrote:
> Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
> 
>> The Zicsr instructions were totally broken, and
>> some instructions like fence.tso were missing.
>>
>> Since the test coverage is not very good, add some
>> basic tests for fence and csrrw instructions.
>> ---
>>  sim/riscv/sim-main.c        | 82 ++++++++++++++++++++++++++++++++-----
>>  sim/testsuite/riscv/fence.s | 17 ++++++++
>>  sim/testsuite/riscv/zicsr.s | 24 +++++++++++
>>  3 files changed, 112 insertions(+), 11 deletions(-)
>>  create mode 100644 sim/testsuite/riscv/fence.s
>>  create mode 100644 sim/testsuite/riscv/zicsr.s
>>
>> v2: address review comments, make store_csr execution
>> only executed when rs1 != 0.
>>  
>> diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
>> index 1815d7f2a6c..d556e6f5bdd 100644
>> --- a/sim/riscv/sim-main.c
>> +++ b/sim/riscv/sim-main.c
>> @@ -535,45 +535,100 @@ execute_i (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>        break;
>>  
>>      case MATCH_CSRRC:
>> -      TRACE_INSN (cpu, "csrrc");
>> +      TRACE_INSN (cpu, "csrrc %s, %#x, %s;",
>> +		  rd_name, csr, rs1_name);
>> +      switch (csr)
>> +	{
>> +#define DECLARE_CSR(name, num, ...) \
>> +	case num: \
>> +	  tmp = fetch_csr (cpu, #name, num, &riscv_cpu->csr.name); \
>> +	  if (rs1) \
> 
> Could you be explicit about the comparisons added in this commit please,
> e.g.:
> 
>   if (rs1 != 0)
> 
> this is the GDB style, and given sim/ is maintained on the same list I
> figure the rules should carry over.
> 
> 

I wanted to follow the style in store_rd where we have this:

static INLINE void
store_rd (SIM_CPU *cpu, int rd, unsigned_word val)
{
  struct riscv_sim_cpu *riscv_cpu = RISCV_SIM_CPU (cpu);

  if (rd)
    {
      riscv_cpu->regs[rd] = val;
      TRACE_REG (cpu, rd);
    }
}



>> +	    store_csr (cpu, #name, num, &riscv_cpu->csr.name, \
>> +		       riscv_cpu->csr.name & ~riscv_cpu->regs[rs1]); \
>> +	  store_rd (cpu, rd, tmp); \
>> +	  break;
>> +#include "opcode/riscv-opc.h"
>> +#undef DECLARE_CSR
>> +	}
>> +      break;
>> +    case MATCH_CSRRS:
>> +      TRACE_INSN (cpu, "csrrs %s, %#x, %s;",
>> +		  rd_name, csr, rs1_name);
>> +      switch (csr)
>> +	{
>> +#define DECLARE_CSR(name, num, ...) \
>> +	case num: \
>> +	  tmp = fetch_csr (cpu, #name, num, &riscv_cpu->csr.name); \
>> +	  if (rs1) \
>> +	    store_csr (cpu, #name, num, &riscv_cpu->csr.name, \
>> +		       riscv_cpu->csr.name | riscv_cpu->regs[rs1]); \
>> +	  store_rd (cpu, rd, tmp); \
>> +	  break;
>> +#include "opcode/riscv-opc.h"
>> +#undef DECLARE_CSR
>> +	}
>> +      break;
>> +    case MATCH_CSRRW:
>> +      TRACE_INSN (cpu, "csrrw %s, %#x, %s;",
>> +		  rd_name, csr, rs1_name);
>> +      switch (csr)
>> +	{
>> +#define DECLARE_CSR(name, num, ...) \
>> +	case num: \
>> +	  tmp = fetch_csr (cpu, #name, num, &riscv_cpu->csr.name); \
> 
> For CSRRW the check is on the CSR read.  If 'rd == 0' then no CSR read
> is performed.
> 

That is a bit overkill, especially here.  If I add an if (rd != 0) here,
I need yet another if around the store_rd below, because the uninitalized
tmp will certainly generate warnings.  And here is also the reason why this
code got my attention in the first place: because previously a "csrrw a1, csr, a1"
could not work correctly, since rd == rs1 overwrote the rs1 register too early,
therefore I added the "tmp = ", and then I realized that the whole
instruction was not executable at all, due to the introduction of
INSN_CLASS_ZICSR.

But the spec says, there are no side effects except possible disallowed accesses:
"The CSRs defined so far do not have any architectural side effects on reads beyond raising illegal
instruction exceptions on disallowed accesses. Custom extensions might add CSRs with side
effects on reads. "

So since the write is unconditional that will create the exception
anyway, and custom extension CSRs are out of scope for the riscv simulator.


>> +	  store_csr (cpu, #name, num, &riscv_cpu->csr.name, \
>> +		     riscv_cpu->regs[rs1]); \
>> +	  store_rd (cpu, rd, tmp); \
>> +	  break;
>> +#include "opcode/riscv-opc.h"
>> +#undef DECLARE_CSR
>> +	}
>> +      break;
>> +
>> +    case MATCH_CSRRCI:
>> +      TRACE_INSN (cpu, "csrrci %s, %#x, %#x;",
>> +		  rd_name, csr, rs1);
>>        switch (csr)
>>  	{
>>  #define DECLARE_CSR(name, num, ...) \
>>  	case num: \
>>  	  store_rd (cpu, rd, \
>>  		    fetch_csr (cpu, #name, num, &riscv_cpu->csr.name)); \
>> -	  store_csr (cpu, #name, num, &riscv_cpu->csr.name, \
>> -		     riscv_cpu->csr.name & !riscv_cpu->regs[rs1]); \
>> +	  if (rs1) \
>> +	    store_csr (cpu, #name, num, &riscv_cpu->csr.name, \
>> +		       riscv_cpu->csr.name & ~rs1); \
>>  	  break;
>>  #include "opcode/riscv-opc.h"
>>  #undef DECLARE_CSR
>>  	}
>>        break;
>> -    case MATCH_CSRRS:
>> -      TRACE_INSN (cpu, "csrrs");
>> +    case MATCH_CSRRSI:
>> +      TRACE_INSN (cpu, "csrrsi %s, %#x, %#x;",
>> +		  rd_name, csr, rs1);
>>        switch (csr)
>>  	{
>>  #define DECLARE_CSR(name, num, ...) \
>>  	case num: \
>>  	  store_rd (cpu, rd, \
>>  		    fetch_csr (cpu, #name, num, &riscv_cpu->csr.name)); \
>> -	  store_csr (cpu, #name, num, &riscv_cpu->csr.name, \
>> -		     riscv_cpu->csr.name | riscv_cpu->regs[rs1]); \
>> +	  if (rs1) \
>> +	    store_csr (cpu, #name, num, &riscv_cpu->csr.name, \
>> +		       riscv_cpu->csr.name | rs1); \
>>  	  break;
>>  #include "opcode/riscv-opc.h"
>>  #undef DECLARE_CSR
>>  	}
>>        break;
>> -    case MATCH_CSRRW:
>> -      TRACE_INSN (cpu, "csrrw");
>> +    case MATCH_CSRRWI:
>> +      TRACE_INSN (cpu, "csrrwi %s, %#x, %#x;",
>> +		  rd_name, csr, rs1);
>>        switch (csr)
>>  	{
>>  #define DECLARE_CSR(name, num, ...) \
>>  	case num: \
>>  	  store_rd (cpu, rd, \
>>  		    fetch_csr (cpu, #name, num, &riscv_cpu->csr.name)); \
> 
> Here too the fetch_csr call should not be performed if 'rd == 0'.
> 

Same here.  I do not think that there will be any side effects that may be
worth this complication.


Thanks
Bernd.


> Thanks,
> Andrew
> 
> 
>> -	  store_csr (cpu, #name, num, &riscv_cpu->csr.name, \
>> -		     riscv_cpu->regs[rs1]); \
>> +	  store_csr (cpu, #name, num, &riscv_cpu->csr.name, rs1); \
>>  	  break;
>>  #include "opcode/riscv-opc.h"
>>  #undef DECLARE_CSR
>> @@ -622,6 +677,9 @@ execute_i (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>      case MATCH_FENCE_I:
>>        TRACE_INSN (cpu, "fence.i;");
>>        break;
>> +    case MATCH_FENCE_TSO:
>> +      TRACE_INSN (cpu, "fence.tso;");
>> +      break;
>>      case MATCH_EBREAK:
>>        TRACE_INSN (cpu, "ebreak;");
>>        sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc, sim_stopped, SIM_SIGTRAP);
>> @@ -1349,6 +1407,8 @@ execute_one (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>  			   SIM_SIGILL);
>>  	}
>>      case INSN_CLASS_I:
>> +    case INSN_CLASS_ZICSR:
>> +    case INSN_CLASS_ZIFENCEI:
>>        return execute_i (cpu, iw, op);
>>      case INSN_CLASS_M:
>>      case INSN_CLASS_ZMMUL:
>> diff --git a/sim/testsuite/riscv/fence.s b/sim/testsuite/riscv/fence.s
>> new file mode 100644
>> index 00000000000..25200891161
>> --- /dev/null
>> +++ b/sim/testsuite/riscv/fence.s
>> @@ -0,0 +1,17 @@
>> +# Check that various fence instructions run without any faults.
>> +# mach: riscv32 riscv64
>> +
>> +.include "testutils.inc"
>> +
>> +	start
>> +
>> +	fence
>> +	fence	rw,rw
>> +	fence	rw,w
>> +	fence	r,r
>> +	fence	w,w
>> +	fence	r,rw
>> +	fence.i
>> +	fence.tso
>> +
>> +	pass
>> diff --git a/sim/testsuite/riscv/zicsr.s b/sim/testsuite/riscv/zicsr.s
>> new file mode 100644
>> index 00000000000..7f1bd740230
>> --- /dev/null
>> +++ b/sim/testsuite/riscv/zicsr.s
>> @@ -0,0 +1,24 @@
>> +# Check that the Zicsr instructions run without any faults.
>> +# mach: riscv32 riscv64
>> +
>> +.include "testutils.inc"
>> +
>> +	start
>> +
>> +	csrrs	a0,frm,x0
>> +	csrrw	a1,frm,a0
>> +	bne	a1,a0,bad
>> +	csrrc	a2,frm,a1
>> +	bne	a2,x0,bad
>> +	csrrsi	a0,frm,1
>> +	bne	a0,x0,bad
>> +	csrrci	a0,frm,1
>> +	li	a1,1
>> +	bne	a0,a1,bad
>> +	csrrwi	a0,frm,1
>> +	bne	a0,x0,bad
>> +
>> +	pass
>> +
>> +bad:
>> +	fail
>> -- 
>> 2.39.2
> 

^ permalink raw reply	[relevance 0%]

* Re: [PATCH] sim: fix a warning in dv-sockser.c at connected_p()
  @ 2024-05-03  9:00  0%   ` Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-05-03  9:00 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches



On 5/2/24 18:15, Tom Tromey wrote:
>>>>>> "Bernd" == Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
> 
> Bernd> In some O/S e.g. windows there is a warning here about the
> Bernd> unused variable flags which triggers a -Werror build failure.
> 
> Bernd> Fix that by making the variable declaration optional.
> 
> I think this would be better if this declaration were just removed and
> then stuck into the condition, like:
> 
>   /* Set non-blocking i/o.  */
> #if defined(F_GETFL) && defined(O_NONBLOCK)
>   int flags = fcntl (sockser_fd, F_GETFL);
>   ^^^ add this here
> 
> What do you think?
> 

This would not be compliant to C99, and it would be the first use of this
C11 feature in this file.  Therefore I did not want to go that way.
I did also consider adding braces { } around this whole block, but
actually I do think that guarding the declaration with one #if is also
acceptable and is looking not too ugly, since the function is not too complex.

Thanks
Bernd.

> Tom

^ permalink raw reply	[relevance 0%]

* Re:  [PATCH v3] [RFC] Fix AIX thread exit events not being reported and UI to show  kernel thread ID.
  @ 2024-05-02 14:41  5% ` Aditya Kamath1
  0 siblings, 0 replies; 200+ results
From: Aditya Kamath1 @ 2024-05-02 14:41 UTC (permalink / raw)
  To: Aditya Vidyadhar Kamath, tom
  Cc: Ulrich Weigand, gdb-patches, Sangamesh Mallayya, jhb

[-- Attachment #1: Type: text/plain, Size: 19535 bytes --]

Respected community members,

This is the patch version 3 of the fix.

This patch clears the gdb.thread/thread_events.exp test case.

                === gdb Summary ===

# of expected passes            11
/current_gdb/binutils-gdb/gdb/gdb version  15.0.50.20240325-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /current_gdb/binutils-gdb/gdb/data-directory

And clears program 1 attached below this email as well. See the GDB output for the same as well in AIX.

We have only one small problem.

Consider the gdb.threads/thread_events.exp test case. See program 2 below this email (same as the .c file in the test case).

Here is the output of GDB in AIX.

Reading symbols from testsuite/gdb.threads/thread_events...
(gdb) b main
Breakpoint 1 at 0x100007dc: file gdb.threads/thread_events.c, line 41.
(gdb) r
Starting program: /current_gdb/binutils-gdb/gdb/testsuite/gdb.threads/thread_events
Breakpoint 1, main (argc=1, argv=0x2ff22940) at gdb.threads/thread_events.c:41
41        if (pthread_create (&thread, NULL, threadfunc, NULL) != 0)
(gdb) b after_join_func
Breakpoint 2 at 0x10000778: file gdb.threads/thread_events.c, line 34.
(gdb) b threadfunc
Breakpoint 3 at 0x10000718: file gdb.threads/thread_events.c, line 27.
(gdb) c
Continuing.
[New Thread 258 (tid 25231759)]
[Switching to Thread 258 (tid 25231759)]

Thread 2 hit Breakpoint 3, threadfunc (arg=0x0) at gdb.threads/thread_events.c:27
27        printf ("in threadfunc\n");
(gdb)
Continuing.
in threadfunc
[Thread 258 (tid 25231759) exited]
[Switching to Thread 1 (tid 28115323)]

Thread 1 hit Breakpoint 2, after_join_func () at gdb.threads/thread_events.c:34
34        printf ("finished\n");
(gdb) info threads
./../gdbsupport/intrusive_list.h:468: internal-error: erase_element: Assertion `elem_node->prev != nullptr' failed.
A problem internal to GDB has been detected,


When I do info threads here this fails. Did this happen because we delete the thread?? I am not sure why this happened??

Kindly let me know what we missed or where I went wrong in the patch. Awaiting a reply.

Have a nice day ahead.

Thanks and regards,
Aditya.

Program 1

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>

pthread_barrier_t barrier;

#define NUM_THREADS 3

void *
thread_function (void *arg)
{
  /* This ensures that the breakpoint is only hit after both threads
     are created, so the test can always switch to the non-event
     thread when the breakpoint triggers.  */
//  pthread_barrier_wait (&barrier);

  printf ("Hello World \n"); /* break here */
}

int
main (void)
{
  int i;

  alarm (300);

  pthread_barrier_init (&barrier, NULL, NUM_THREADS);

  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_t thread;
      int res;

      res = pthread_create (&thread, NULL,
                            thread_function, NULL);
      assert (res == 0);
    }

  printf ("More threads \n");
  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_t thread;
      int res;

      res = pthread_create (&thread, NULL,
                thread_function, NULL);
      assert (res == 0);
    }
  while (1)
    sleep (1);

  return 0;
}


GDB output for program 1:

Reading symbols from //gdb_tests/continue-pending-status_exit_test...
(gdb) r
Starting program: /gdb_tests/continue-pending-status_exit_test
More threads
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
[New Thread 258 (tid 28115345)]
[Thread 258 (tid 28115345) exited]
[New Thread 515 (tid 27001289)]
[Thread 515 (tid 27001289) exited]
[New Thread 772 (tid 19136771)]
[Thread 772 (tid 19136771) exited]
[New Thread 1029 (tid 18612569)]
[Thread 1029 (tid 18612569) exited]
[New Thread 1286 (tid 31457595)]
[Thread 1286 (tid 31457595) exited]
[New Thread 1543 (tid 30736823)]
[Thread 1543 (tid 30736823) exited]

Thread 1 received signal SIGINT, Interrupt.
0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 25231793) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)

Program 2:

This file was written by Chris Demetriou (cgd@google.com<mailto:cgd@google.com>).  */

/* Simple test to trigger thread events (thread start, thread exit).  */

#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

static void *
threadfunc (void *arg)
{
  printf ("in threadfunc\n");
  return NULL;
}

static void
after_join_func (void)
{
  printf ("finished\n");
}

int main (int argc, char *argv[])
{
  pthread_t thread;

  if (pthread_create (&thread, NULL, threadfunc, NULL) != 0)
    {
      printf ("pthread_create failed\n");
      exit (1);
    }

  if (pthread_join (thread, NULL) != 0)
    {
      printf ("pthread_join failed\n");
      exit (1);
    }

  after_join_func ();
  return 0;
}
From: Aditya Vidyadhar Kamath <akamath996@gmail.com>
Date: Thursday, 2 May 2024 at 8:01 PM
To: tom@tromey.com <tom@tromey.com>
Cc: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>, jhb@freebsd.org <jhb@freebsd.org>
Subject: [EXTERNAL] [PATCH v3] [RFC] Fix AIX thread exit events not being reported and UI to show kernel thread ID.
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>

In AIX when a thread exits we were not showing that a thread exit event happened
and GDB continued to keep the terminated threads.

If we have terminated threads then the UI on info threads command will look like
(gdb) info threads
  Id   Target Id                                          Frame
* 1    Thread 1 (tid 26607979, running)    0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
  2    Thread 258 (tid 30998799, finished) aix-thread: ptrace (52, 30998799) returned -1 (errno = 3 The process does not exist.)

If we see the frame is not getting displayed correctly.

The reason for the same is that in AIX we were not managing thread states. In particular we do not know
when a thread terminates.

The reason being in sync_threadlists () the pbuf and gbuf lists remain the same though certain threads exit.

This patch is a fix to the same.

Also certain UI is changed.

On a new thread born and exit the UI in AIX will be similar to Linux with both user and kernel thread information.

[New Thread 258 (tid 32178533)]
[New Thread 515 (tid 30343651)]
[New Thread 772 (tid 33554909)]
[New Thread 1029 (tid 24969489)]
[New Thread 1286 (tid 18153945)]
[New Thread 1543 (tid 30736739)]
[Thread 258 (tid 32178533) exited]
[Thread 515 (tid 30343651) exited]
[Thread 772 (tid 33554909) exited]
[Thread 1029 (tid 24969489) exited]
[Thread 1286 (tid 18153945) exited]
[Thread 1543 (tid 30736739) exited]

and info threads will look like
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 31326579) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
---
 gdb/aix-thread.c | 248 ++++++++++++++++-------------------------------
 1 file changed, 81 insertions(+), 167 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index c70bd82bc24..bd74c0c805b 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -55,6 +55,7 @@
 #include <sys/reg.h>
 #include <sched.h>
 #include <sys/pthdebug.h>
+#include <unordered_set>

 #if !HAVE_DECL_GETTHRDS
 extern int getthrds (pid_t, struct thrdsinfo64 *, int, tid_t *, int);
@@ -190,6 +191,12 @@ struct aix_thread_variables
   /* Whether the current architecture is 64-bit.
    Only valid when pd_able is true.  */
   int arch64;
+
+  /* Describes the number of thread exit events reported.  */
+  std::unordered_set<pthdb_pthread_t> exited_threads;
+
+  /* Describes if thread is still in queue and not in unknown state.  */
+  std::vector<pthdb_pthread_t> in_queue_threads;
 };

 /* Key to our per-inferior data.  */
@@ -737,47 +744,6 @@ state2str (pthdb_state_t state)
     }
 }

-/* qsort() comparison function for sorting pd_thread structs by pthid.  */
-
-static int
-pcmp (const void *p1v, const void *p2v)
-{
-  struct pd_thread *p1 = (struct pd_thread *) p1v;
-  struct pd_thread *p2 = (struct pd_thread *) p2v;
-  return p1->pthid < p2->pthid ? -1 : p1->pthid > p2->pthid;
-}
-
-/* ptid comparison function */
-
-static int
-ptid_cmp (ptid_t ptid1, ptid_t ptid2)
-{
-  if (ptid1.pid () < ptid2.pid ())
-    return -1;
-  else if (ptid1.pid () > ptid2.pid ())
-    return 1;
-  else if (ptid1.tid () < ptid2.tid ())
-    return -1;
-  else if (ptid1.tid () > ptid2.tid ())
-    return 1;
-  else if (ptid1.lwp () < ptid2.lwp ())
-    return -1;
-  else if (ptid1.lwp () > ptid2.lwp ())
-    return 1;
-  else
-    return 0;
-}
-
-/* qsort() comparison function for sorting thread_info structs by pid.  */
-
-static int
-gcmp (const void *t1v, const void *t2v)
-{
-  struct thread_info *t1 = *(struct thread_info **) t1v;
-  struct thread_info *t2 = *(struct thread_info **) t2v;
-  return ptid_cmp (t1->ptid, t2->ptid);
-}
-
 /* Search through the list of all kernel threads for the thread
    that has stopped on a SIGTRAP signal, and return its TID.
    Return 0 if none found.  */
@@ -822,22 +788,16 @@ static void
 sync_threadlists (pid_t pid)
 {
   int cmd, status;
-  int pcount, psize, pi, gcount, gi;
-  struct pd_thread *pbuf;
-  struct thread_info **gbuf, **g, *thread;
   pthdb_pthread_t pdtid;
   pthread_t pthid;
   pthdb_tid_t tid;
   process_stratum_target *proc_target = current_inferior ()->process_target ();
   struct aix_thread_variables *data;
   data = get_thread_data_helper_for_pid (pid);
-
+  pthdb_state_t state;
+  data->in_queue_threads.clear ();
   /* Accumulate an array of libpthdebug threads sorted by pthread id.  */

-  pcount = 0;
-  psize = 1;
-  pbuf = XNEWVEC (struct pd_thread, psize);
-
   for (cmd = PTHDB_LIST_FIRST;; cmd = PTHDB_LIST_NEXT)
     {
       status = pthdb_pthread (data->pd_session, &pdtid, cmd);
@@ -848,118 +808,68 @@ sync_threadlists (pid_t pid)
       if (status != PTHDB_SUCCESS || pthid == PTHDB_INVALID_PTID)
         continue;

-      if (pcount == psize)
-       {
-         psize *= 2;
-         pbuf = (struct pd_thread *) xrealloc (pbuf,
-                                               psize * sizeof *pbuf);
-       }
-      pbuf[pcount].pdtid = pdtid;
-      pbuf[pcount].pthid = pthid;
-      pcount++;
-    }
-
-  for (pi = 0; pi < pcount; pi++)
-    {
-      status = pthdb_pthread_tid (data->pd_session, pbuf[pi].pdtid, &tid);
-      if (status != PTHDB_SUCCESS)
-       tid = PTHDB_INVALID_TID;
-      pbuf[pi].tid = tid;
-    }
-
-  qsort (pbuf, pcount, sizeof *pbuf, pcmp);
-
-  /* Accumulate an array of GDB threads sorted by pid.  */
-
-  /* gcount is GDB thread count and pcount is pthreadlib thread count.  */
+      ptid_t ptid (pid, 0, pthid);
+      status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+      data->in_queue_threads.push_back (pdtid);

-  gcount = 0;
-  for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))
-    gcount++;
-  g = gbuf = XNEWVEC (struct thread_info *, gcount);
-  for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))
-    *g++ = tp;
-  qsort (gbuf, gcount, sizeof *gbuf, gcmp);
-
-  /* Apply differences between the two arrays to GDB's thread list.  */
-
-  for (pi = gi = 0; pi < pcount || gi < gcount;)
-    {
-      if (pi == pcount)
+      /* If this thread has reported and exited, do not add it again.  */
+      if (state == PST_TERM)
         {
-         delete_thread (gbuf[gi]);
-         gi++;
+         if (data->exited_threads.count (pdtid) != 0)
+            continue;
         }
-      else if (gi == gcount)
-       {
-         aix_thread_info *priv = new aix_thread_info;
-         priv->pdtid = pbuf[pi].pdtid;
-         priv->tid = pbuf[pi].tid;
-
-         thread = add_thread_with_info (proc_target,
-                                        ptid_t (pid, 0, pbuf[pi].pthid),
-                                        private_thread_info_up (priv));

-         pi++;
-       }
-      else
+      /* If this thread has never been reported to GDB, add it.  */
+      if (!in_thread_list (proc_target, ptid))
         {
-         ptid_t pptid, gptid;
-         int cmp_result;
-
-         pptid = ptid_t (pid, 0, pbuf[pi].pthid);
-         gptid = gbuf[gi]->ptid;
-         pdtid = pbuf[pi].pdtid;
-         tid = pbuf[pi].tid;
-
-         cmp_result = ptid_cmp (pptid, gptid);
-
-         if (cmp_result == 0)
-           {
-             aix_thread_info *priv = get_aix_thread_info (gbuf[gi]);
-
-             priv->pdtid = pdtid;
-             priv->tid = tid;
-             pi++;
-             gi++;
-           }
-         else if (cmp_result > 0)
+         aix_thread_info *priv = new aix_thread_info;
+         /* init priv */
+         priv->pdtid = pdtid;
+         status = pthdb_pthread_tid (data->pd_session, pdtid, &tid);
+         priv->tid = tid;
+         /* Check if this is the main thread.  If it is, then change
+            its ptid and add its private data.  */
+         if (get_signaled_thread (pid) == tid
+               && in_thread_list (proc_target, ptid_t (pid)))
             {
-             /* This is to make the main process thread now look
-                like a thread.  */
-
-             if (gptid.is_pid ())
-               {
-                 thread_info *tp = proc_target->find_thread (gptid);
-                 thread_change_ptid (proc_target, gptid, pptid);
-                 aix_thread_info *priv = new aix_thread_info;
-                 priv->pdtid = pbuf[pi].pdtid;
-                 priv->tid = pbuf[pi].tid;
-                 tp->priv.reset (priv);
-                 gi++;
-                 pi++;
-               }
-             else
-               {
-                 delete_thread (gbuf[gi]);
-                 gi++;
-               }
+             thread_info *tp = proc_target->find_thread (ptid_t (pid));
+             thread_change_ptid (proc_target, ptid_t (pid), ptid);
+             tp->priv.reset (priv);
             }
           else
-           {
-             thread = add_thread (proc_target, pptid);
+           add_thread_with_info (proc_target, ptid,
+               private_thread_info_up (priv));
+       }

-             aix_thread_info *priv = new aix_thread_info;
-             thread->priv.reset (priv);
-             priv->pdtid = pdtid;
-             priv->tid = tid;
-             pi++;
-           }
+      /* The thread is terminated. Remove it.  */
+      if (state == PST_TERM)
+       {
+         thread_info *thr = proc_target->find_thread (ptid);
+         gdb_assert (thr != nullptr);
+         delete_thread (thr);
+         data->exited_threads.insert (pdtid);
         }
     }

-  xfree (pbuf);
-  xfree (gbuf);
+    /* Sometimes there can be scenarios where the thread status is
+       unknown and we it will never iterate in the for loop above,
+       since cmd will be no longer be pointing to that threads.  One
+       such scenario is the gdb.threads/thread_events.exp testcase
+       where in the end after the threadfunc breakpoint is hit, the
+       thread exits and gets into a PST_UNKNOWN state.  So this thread
+       will not run in the above for loop.  Therefore the below for loop
+       is to manually delete such threads.  */
+    for (struct thread_info *it : all_threads ())
+      {
+       aix_thread_info *priv = get_aix_thread_info (it);
+       auto itr = std::find (data->in_queue_threads.begin (),
+                               data->in_queue_threads.end (), priv->pdtid);
+       if (itr == data->in_queue_threads.end ())
+         {
+           delete_thread (it);
+           data->exited_threads.insert (priv->pdtid);
+         }
+      }
 }

 /* Iterate_over_threads() callback for locating a thread, using
@@ -1013,8 +923,8 @@ pd_update (pid_t pid)
 }

 /* Try to start debugging threads in the current process.
-   If successful and there exists and we can find an event thread, return a ptid
-   for that thread.  Otherwise, return a ptid-only ptid using PID.  */
+   If successful and there exists and we can find an event thread, set
+   pd_active for that thread.  Otherwise, return.  */

 static void
 pd_activate (pid_t pid)
@@ -2084,10 +1994,17 @@ aix_thread_target::thread_alive (ptid_t ptid)
 std::string
 aix_thread_target::pid_to_str (ptid_t ptid)
 {
-  if (ptid.tid () == 0)
-    return beneath ()->pid_to_str (ptid);
+  thread_info *thread_info = current_inferior ()->find_thread (ptid);

-  return string_printf (_("Thread %s"), pulongest (ptid.tid ()));
+  if (thread_info != NULL && thread_info->priv != NULL)
+    {
+      aix_thread_info *priv = get_aix_thread_info (thread_info);
+
+      return string_printf (_("Thread %s (tid %s)"), pulongest (ptid.tid ()),
+               pulongest (priv->tid));
+    }
+
+  return beneath ()->pid_to_str (ptid);
 }

 /* Return a printable representation of extra information about
@@ -2098,7 +2015,6 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
 {
   int status;
   pthdb_pthread_t pdtid;
-  pthdb_tid_t tid;
   pthdb_state_t state;
   pthdb_suspendstate_t suspendstate;
   pthdb_detachstate_t detachstate;
@@ -2115,33 +2031,31 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
   aix_thread_info *priv = get_aix_thread_info (thread);

   pdtid = priv->pdtid;
-  tid = priv->tid;
-
-  if (tid != PTHDB_INVALID_TID)
-    /* i18n: Like "thread-identifier %d, [state] running, suspended" */
-    buf.printf (_("tid %d"), (int)tid);

   status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+
+  /* Output should look like Thread %d (tid %d) ([state]).  */
+  /* Example:- Thread 1 (tid 34144587) ([running]).  */
+  /* where state can be running, idle, sleeping, finished,
+     suspended, detached, cancel pending, ready or unknown.  */
+
   if (status != PTHDB_SUCCESS)
     state = PST_NOTSUP;
-  buf.printf (", %s", state2str (state));
+  buf.printf ("[%s]", state2str (state));

   status = pthdb_pthread_suspendstate (data->pd_session, pdtid,
                                        &suspendstate);
   if (status == PTHDB_SUCCESS && suspendstate == PSS_SUSPENDED)
-    /* i18n: Like "Thread-Id %d, [state] running, suspended" */
-    buf.printf (_(", suspended"));
+    buf.printf (_("[suspended]"));

   status = pthdb_pthread_detachstate (data->pd_session, pdtid,
                                       &detachstate);
   if (status == PTHDB_SUCCESS && detachstate == PDS_DETACHED)
-    /* i18n: Like "Thread-Id %d, [state] running, detached" */
-    buf.printf (_(", detached"));
+    buf.printf (_("[detached]"));

   pthdb_pthread_cancelpend (data->pd_session, pdtid, &cancelpend);
   if (status == PTHDB_SUCCESS && cancelpend)
-    /* i18n: Like "Thread-Id %d, [state] running, cancel pending" */
-    buf.printf (_(", cancel pending"));
+    buf.printf (_("[cancel pending]"));

   buf.write ("", 1);

--
2.41.0

^ permalink raw reply	[relevance 5%]

* Re: [PATCH] gdb: reject inserting breakpoints between functions
       [not found]     ` <6630b03f.050a0220.6a68d.6289SMTPIN_ADDED_BROKEN@mx.google.com>
@ 2024-05-01  9:47  9%   ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-05-01  9:47 UTC (permalink / raw)
  To: Klaus Gerlicher, simon.marchi; +Cc: Simon.Marchi, gdb-patches

Klaus Gerlicher <klaus.gerlicher@intel.com> writes:

> Hi Simon,
>
> I verified that your patch addresses many of the issues we would also
> like to solve in this area.
>
> It appears this has not published yet and it seems to be more than 2
> years old.
>
> Could you please tell me if there are any plans to commit this?

Given I reviewed this once upon a time, I still had my review branch
kicking around.

I rebased onto something close to HEAD of master.  I addressed the minor
nits I pointed out in my review.  I'd be happy to see this merged once
my full regression run (still on going) has completed.

I think I'd like Simon to give a +1 before I pushed this though.

Thanks,
Andrew

---

commit 245b55f774512a997139c15c43f068c55e0c532c
Author: Simon Marchi <Simon.Marchi@amd.com>
Date:   Fri Apr 8 16:05:36 2022 -0400

    gdb: reject inserting breakpoints between functions
    
    In the downstream ROCm-GDB port (to debug AMD GPUs), you can have code
    like this:
    
    Consider the following code:
    
      __global__ void kernel ()
      {
        ...
        // break here
        ...
      }
    
      int main ()
      {
        // Code to call `kernel`
      }
    
    ... where kernel is a function compiled to execute on the GPU.  It does
    not exist in the host x86-64 program that runs the main function, and
    GDB doesn't know about that function until it is called, at which point
    the runtime loads the corresponding code object and GDB learns about the
    "kernel" symbol.  Before the GPU code object is loaded, from the point
    of view of GDB, you might as well have blank lines instead of the
    "kernel" function.  The DWARF in the host program doesn't describe
    anything at these lines.
    
    So, a common problem that users face is:
    
     - Start GDB with the host binary
     - Place a breakpoint by line number at the "break here" line
     - At this point, GDB only knows about the host code, the lines of the
       `kernel` function are a big void.
     - GDB finds no code mapped to the "break here" line, searches for the
       first following line that has code mapped to it.
     - GDB finds that the line with the opening bracket of the `main`
       function (or around there) has code mapped to it, places breakpoint
       there.
     - User runs the program.
     - The programs hits the breakpoint at the start of main.
     - User is confused, because they didn't ask for a breakpoint in main.
    
    If they continue, the code object eventually gets loaded, GDB reads the
    debug info from it, re-evaluates the breakpoint locations, and at this
    point the breakpoint is placed at the expected location.
    
    The goal of this patch is to get rid of this annoyance.
    
    A case similar to the one shown above can actually be simulated without
    GPU-specific code: using a single source file used to generate a library
    and an executable loading that library (see the new test
    gdb.linespec/line-breakpoint-outside-function.c).  Before the library is
    loaded, trying to place a breakpoint in the library code results in the
    breakpoint "drifting" down to the main function.
    
    To address this problem, I suggest making it so that when a user
    requests a breakpoint outside a function, GDB makes a pending
    breakpoint, rather than placing a breakpoint at the next line with code,
    which happens to be in the next function.  When the GPU kernel or shared
    library gets loaded, the breakpoint resolves to a location in the kernel
    or library.
    
    Note that we still want breakpoints placed inside a function to
    "drift" down to the next line with code.  For example, here:
    
       9
      10 void foo()
      11 {
      12   int x;
      13
      14   x++;
    
    There is probably no code associated to lines 10, 12 and 13, but the
    user can still reasonably expect to be able to put a breakpoint there.
    In my experience, GCC maps the function prologue to the line with the
    opening curly bracket, so the user will be able to place a breakpoint
    there anyway (line 11 in the example).  But I don't really see a use
    case to put a breakpoint above line 10 and expect to get a breakpoint in
    foo.  So I think that is a reasonable behavior change for GDB.
    
    This is implemented using the following heuristic:
    
     - If a breakpoint is requested at line L but there is no code mapped to
       L, search for a following line with associated code (this already
       exists today).
     - However, if:
    
         1. the found location falls in a function symbol's block
         2. the found location's address is equal the entry PC of that
            function
         3. the found location's line is greater that the requested line
    
       ... then we don't place a breakpoint at the found location, we will
       end up with a pending breakpoint.
    
    Change the message "No line X in file..." to "No compiled code for line
    X in file...".  There is clearly a line 9 in the example above, so it
    would be weird to say "No line 9 in file...".  What we mean is that
    there is no code associated to line 9.
    
    All the regressions that I found this patch to cause were:
    
     1. tests specifically this behavior where placing a breakpoint before
        a function results in a breakpoint on that function, in which case I
        removed the tests or changed them to expect a pending breakpoint
     2. linespec tests expecting things like "break -line N garbage" to
        error out because of the following garbage, but we now got a
        different error because line N now doesn't resolve to something
        anymore.  For example, before:
    
          (gdb) break -line 3 if foofoofoo == 1
          No symbol "foofoofoo" in current context.
    
        became
    
          (gdb) break -line 3 if foofoofoo == 1
          No line 3 in the current file.
    
        These tests were modified to refer to a valid line with code, so
        that we can still test what we intended to test.
    
    Notes:
    
     - The CUDA compiler "solves" this problem by adding dummy function
       symbols between functions, that are never called.  So when you try to
       insert a breakpoint in the not-yet-loaded kernel, the breakpoint
       still drifts, but is placed on some dummy symbol.  For reasons that
       would be too long to explain here, the ROCm compiler does not do
       that, and it is not a desirable option.
    
     - You can have constructs like this:
    
       void host_function()
       {
         struct foo
         {
           static void __global__ kernel ()
           {
             // Place breakpoint here
           }
         };
    
         // Host code that calls `kernel`
       }
    
       The heuristic won't work then, as the breakpoint will drift somewhere
       inside the enclosing function, but won't be at the start of that
       function.  So a bogus breakpoint location will be created on the host
       side.  I don't think that people are going to use this kind of
       construct often though, so we can probably ignore it.
    
       ROCm doesn't support passing a lambda kernel function to
       hipLaunchKernelGGL (the function used to launch kernels on the
       device), but if it eventually does, there will be the same
       problem.
    
       I think that to properly support this, we will need some DWARF
       improvements to be able to say "there is really nothing at these
       lines" in the line table.
    
    Change-Id: I310b79af3009354e50d5a298b5ae32f90b72b9a3

diff --git a/gdb/linespec.c b/gdb/linespec.c
index ca154d2dcba..7caf89d4589 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -2081,12 +2081,19 @@ create_sals_line_offset (struct linespec_state *self,
       const linetable_entry *best_entry = NULL;
       int i, j;
 
+      /* True if the provided line gave an exact match.  False if we had to
+	 search for the next following line with code.  */
+      bool was_exact = true;
+
       std::vector<symtab_and_line> intermediate_results
 	= decode_digits_ordinary (self, ls, val.line, &best_entry);
       if (intermediate_results.empty () && best_entry != NULL)
-	intermediate_results = decode_digits_ordinary (self, ls,
-						       best_entry->line,
-						       &best_entry);
+	{
+	  was_exact = false;
+	  intermediate_results = decode_digits_ordinary (self, ls,
+							 best_entry->line,
+							 &best_entry);
+	}
 
       /* For optimized code, the compiler can scatter one source line
 	 across disjoint ranges of PC values, even when no duplicate
@@ -2129,11 +2136,45 @@ create_sals_line_offset (struct linespec_state *self,
 	    struct symbol *sym = (blocks[i]
 				  ? blocks[i]->containing_function ()
 				  : NULL);
+	    symtab_and_line *sal = &intermediate_results[i];
+
+	    /* Don't consider a match if:
+
+	       - the provided line did not give an exact match (so we
+		 started looking for lines below until we found one with
+		 code associated to it)
+	       - the found location is exactly the start of a function
+	       - the provided line is above the declaration line of the
+		 function
+
+	       Consider the following source:
+
+	       10 } // end of a previous function
+	       11
+	       12 int
+	       13 main (void)
+	       14 {
+	       15   int i = 1;
+	       16
+	       17   return 0;
+	       18 }
+
+	       The intent of this heuristic is that a breakpoint requested on
+	       line 11 and 12 will not result in a breakpoint on main, but a
+	       breakpoint on line 13 will.  A breakpoint requested on the empty
+	       line 16 will also result in a breakpoint in main, at line 17.  */
+	    if (!was_exact
+		&& sym != nullptr
+		&& sym->aclass () == LOC_BLOCK
+		&& sal->pc == sym->value_block ()->entry_pc ()
+		&& val.line < sym->line ())
+	      continue;
 
 	    if (self->funfirstline)
-	      skip_prologue_sal (&intermediate_results[i]);
-	    intermediate_results[i].symbol = sym;
-	    add_sal_to_sals (self, &values, &intermediate_results[i],
+	      skip_prologue_sal (sal);
+
+	    sal->symbol = sym;
+	    add_sal_to_sals (self, &values, sal,
 			     sym ? sym->natural_name () : NULL, 0);
 	  }
     }
@@ -2141,10 +2182,12 @@ create_sals_line_offset (struct linespec_state *self,
   if (values.empty ())
     {
       if (ls->explicit_loc.source_filename)
-	throw_error (NOT_FOUND_ERROR, _("No line %d in file \"%s\"."),
+	throw_error (NOT_FOUND_ERROR,
+		     _("No compiled code for line %d in file \"%s\"."),
 		     val.line, ls->explicit_loc.source_filename.get ());
       else
-	throw_error (NOT_FOUND_ERROR, _("No line %d in the current file."),
+	throw_error (NOT_FOUND_ERROR,
+		     _("No compiled code for line %d in the current file."),
 		     val.line);
     }
 
diff --git a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
index 613c9dc47e8..86572635d4c 100644
--- a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
+++ b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
@@ -40,10 +40,13 @@ proc set_breakpoint_on_gcd_function {} {
     # Single hex digit
     set xd {[0-9a-f]}
 
-    # This accepts e.g. "Breakpoint 1 at 0x40968a" (fixed GDB)
-    # but rejects e.g. "Breakpoint 1 at 0x4" (broken GDB).
-    gdb_test "b [gdb_get_line_number "gdb break here"]" \
-	"Breakpoint \[0-9\] at 0x${xd}${xd}+: .*"
+    set lineno [gdb_get_line_number "gdb break here"]
+    gdb_test "set breakpoint pending on"
+    gdb_test "b $lineno" \
+	[multi_line \
+	     "^No compiled code for line $lineno in the current file\\." \
+	     "Breakpoint $::decimal \\($lineno\\) pending\\."] \
+	"break on line in garbage collected function"
 }
 
 set_breakpoint_on_gcd_function
diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index cdb4c22a034..34ac21982ea 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -476,9 +476,6 @@ proc_with_prefix test_no_break_on_catchpoint {} {
 
 test_no_break_on_catchpoint
 
-# Verify that GDB responds gracefully when asked to set a breakpoint
-# on a nonexistent source line.
-
 proc_with_prefix test_break_nonexistent_line {} {
     clean_restart break
 
@@ -486,9 +483,11 @@ proc_with_prefix test_break_nonexistent_line {} {
 	return
     }
 
+    # Verify that GDB responds gracefully when asked to set a
+    # breakpoint on a nonexistent source line.
     gdb_test_no_output "set breakpoint pending off"
     gdb_test "break 999" \
-	"No line 999 in the current file." \
+	"^No compiled code for line 999 in the current file\\." \
 	"break on non-existent source line"
 }
 
diff --git a/gdb/testsuite/gdb.base/ending-run.exp b/gdb/testsuite/gdb.base/ending-run.exp
index b9a72b0e70e..90359fd8733 100644
--- a/gdb/testsuite/gdb.base/ending-run.exp
+++ b/gdb/testsuite/gdb.base/ending-run.exp
@@ -32,24 +32,15 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } {
 }
 remote_exec build "rm -f core"
 
-# CHFts23469: Test that you can "clear" a bp set at
-# a line _before_ the routine (which will default to the
-# first line in the routine, which turns out to correspond
-# to the prolog--that's another bug...)
-#
-
-gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \
-	"bpt at line before routine"
-
 set break1_line [gdb_get_line_number "-break1-"]
 gdb_test "b ending-run.c:$break1_line" \
-	".*Note.*also.*Breakpoint 2.*ending-run.c, line $break1_line.*" \
+	"Breakpoint 1 at ${::hex}.*" \
 	"b ending-run.c:$break1_line, one"
 
 # Set up to go to the next-to-last line of the program
 #
 set break2_line [gdb_get_line_number "-break2-"]
-gdb_test "b ending-run.c:$break2_line" ".*Breakpoint 3.*ending-run.c, line $break2_line.*"
+gdb_test "b ending-run.c:$break2_line" ".*Breakpoint 2.*ending-run.c, line $break2_line.*"
 
 # Expect to hit the bp at line "1", but symbolize this
 # as line "13".  Then try to clear it--this should work.
@@ -57,29 +48,28 @@ gdb_test "b ending-run.c:$break2_line" ".*Breakpoint 3.*ending-run.c, line $brea
 gdb_run_cmd
 gdb_test "" ".*Breakpoint.*1.*callee.*$break1_line.*" "run"
 
-gdb_test "cle" ".*Deleted breakpoints 1 2.*" "clear worked"
-gdb_test_multiple "i b" "cleared bp at line before routine" {
-    -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { 
-	fail "cleared bp at line before routine" 
+gdb_test "cle" "Deleted breakpoint 1 " "clear worked"
+gdb_test_multiple "i b" "cleared bp at stopped line" {
+    -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
+	fail $gdb_test_name
     }
-    -re ".*3.*main.*$break2_line.*$gdb_prompt $" {
-	pass "cleared bp at line before routine" 
+    -re ".*2.*main.*$break2_line.*$gdb_prompt $" {
+	pass $gdb_test_name
     }
 }
 
 # Test some other "clear" combinations
 #
-gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
-gdb_test "b ending-run.c:$break1_line" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:$break1_line, two"
+gdb_test "b ending-run.c:$break1_line" "Breakpoint 3 at ${::hex}.*" "b ending-run.c:$break1_line, two"
 gdb_test "cle ending-run.c:$break1_line" \
-	".*Deleted breakpoints 4 5.*" "Cleared 2 by line"
+	"Deleted breakpoint 3 " "Cleared 2 by line"
 
 gdb_test_multiple "info line ending-run.c:$break1_line" "" {
     -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
         set line_nine $expect_out(1,string)
-        gdb_test "b ending-run.c:$break1_line" ".*Breakpoint 6.*ending-run.c, line $break1_line.*"
-        gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 7.*" "breakpoint 7 at *ending-run.c:$break1_line"
-        gdb_test "cle" ".*Deleted breakpoints 6 7.*" "clear 2 by default"
+	gdb_test "b ending-run.c:$break1_line" ".*Breakpoint 4.*ending-run.c, line $break1_line.*"
+	gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 5.*" "breakpoint 7 at *ending-run.c:$break1_line"
+	gdb_test "cle" "Deleted breakpoints 4 5 " "clear 2 by default"
     }
     -re ".*$gdb_prompt $" {
         fail "need to fix test for new compile outcome"
@@ -90,7 +80,7 @@ gdb_test_multiple "i b" "all set to continue" {
     -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
         fail "all set to continue (didn't clear bps)" 
     }
-    -re ".*3.*main.*$break2_line.*$gdb_prompt $" {
+    -re ".*2.*main.*$break2_line.*$gdb_prompt $" {
         pass "all set to continue"
     }
     -re ".*$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.base/foll-exec-mode.exp b/gdb/testsuite/gdb.base/foll-exec-mode.exp
index 65054b530b3..56a2ffc723b 100644
--- a/gdb/testsuite/gdb.base/foll-exec-mode.exp
+++ b/gdb/testsuite/gdb.base/foll-exec-mode.exp
@@ -127,7 +127,7 @@ proc do_follow_exec_mode_tests { mode cmd infswitch } {
 	# past it.
 	#
 	if {$cmd == "continue"} {
-	    gdb_breakpoint "$execd_line"
+	    gdb_breakpoint "$execd_line" "allow-pending"
 	}
 
 	# Execute past the exec call.
diff --git a/gdb/testsuite/gdb.base/hbreak2.exp b/gdb/testsuite/gdb.base/hbreak2.exp
index 8f5735b790f..9bd5e2a0b41 100644
--- a/gdb/testsuite/gdb.base/hbreak2.exp
+++ b/gdb/testsuite/gdb.base/hbreak2.exp
@@ -296,7 +296,7 @@ if {![runto_main]} {
 #
 gdb_test_no_output "set breakpoint pending off"
 gdb_test "hbreak 999" \
-    "No line 999 in the current file." \
+    "^No compiled code for line 999 in the current file\\." \
     "hardware break on non-existent source line"
 
 # Run to the desired default location.  If not positioned here, the
diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp
index ee9bea2045a..eb3515b84ae 100644
--- a/gdb/testsuite/gdb.base/sepdebug.exp
+++ b/gdb/testsuite/gdb.base/sepdebug.exp
@@ -296,7 +296,7 @@ gdb_test "catch exec" "Catchpoint \[0-9\]+ \\(exec\\)" \
 #
 
 gdb_test_no_output "set breakpoint pending off"
-gdb_test "break 999" "No line 999 in the current file." \
+gdb_test "break 999" "^No compiled code for line 999 in the current file\\." \
     "break on non-existent source line"
 
 # Run to the desired default location. If not positioned here, the
diff --git a/gdb/testsuite/gdb.linespec/cpexplicit.exp b/gdb/testsuite/gdb.linespec/cpexplicit.exp
index 5c93c34ab4a..62033d5dac9 100644
--- a/gdb/testsuite/gdb.linespec/cpexplicit.exp
+++ b/gdb/testsuite/gdb.linespec/cpexplicit.exp
@@ -80,7 +80,7 @@ namespace eval $testfile {
     add linespecs "-function myclass::myfunction -line 3" $location(normal)
     add linespecs "-function myclass::myfunction -label top -line 3" \
 	$location(top)
-    add linespecs "-line 3" $location(normal)
+    add linespecs "-line 25" $location(normal)
     add linespecs "-function myclass::operator," $location(operator)
     add linespecs "-function 'myclass::operator,'" $location(operator)
     add linespecs "-function \"myclass::operator,\"" $location(operator)
diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
index 625f9cee0fc..60183e98e1e 100644
--- a/gdb/testsuite/gdb.linespec/explicit.exp
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -86,7 +86,7 @@ namespace eval $testfile {
     # These are also not yet supported; -line is silently ignored.
     add linespecs "-function myfunction -line 3" $location(normal)
     add linespecs "-function myfunction -label top -line 3" $location(top)
-    add linespecs "-line 3" $location(normal)
+    add linespecs "-line 25" $location(normal)
 
     # Fire up gdb.
     if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.c b/gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.c
new file mode 100644
index 00000000000..93c43838312
--- /dev/null
+++ b/gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.c
@@ -0,0 +1,51 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2022-2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* The section where THE_LIB_PATH is not defined is compiled as a shared
+   library.  The rest is compiled as the main executable (which loads the
+   shared library.  */
+
+#if !defined(THE_LIB_PATH)
+
+void
+the_lib_func (void)
+{
+  static int x;
+  /* break here */
+  x++;
+}
+
+#else
+#include <dlfcn.h>
+#include <assert.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  void *lib = dlopen (THE_LIB_PATH, RTLD_NOW);
+  assert (lib != NULL);
+
+  void (*the_lib_func) (void) = dlsym (lib, "the_lib_func");
+  assert (the_lib_func != NULL);
+
+  the_lib_func ();
+
+  return 0;
+}
+
+#endif
diff --git a/gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.exp b/gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.exp
new file mode 100644
index 00000000000..946304af84d
--- /dev/null
+++ b/gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.exp
@@ -0,0 +1,55 @@
+# Copyright 2022-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that placing a line breakpoint outside a function results in a pending
+# breakpoint.  More importantly, that it does "drift" and place a
+# breakpoint on the next function.
+#
+# See the .c file for more details.
+
+standard_testfile
+
+set shlib_path [standard_output_file ${testfile}-lib.so]
+if {[build_executable "build shlib" $shlib_path $srcfile {debug shlib}]} {
+    return
+}
+
+set opts [list debug shlib_load additional_flags=-DTHE_LIB_PATH="${shlib_path}"]
+if {[build_executable "failed to prepare" ${testfile} ${srcfile} $opts]} {
+    return
+}
+
+proc do_test {} {
+    clean_restart $::binfile
+
+    # To make things easier, just so we don't have to deal with the question.
+    gdb_test_no_output "set breakpoint pending on"
+
+    set lineno [gdb_get_line_number "break here"]
+    gdb_test "break $lineno" \
+	[multi_line \
+	     "No compiled code for line $lineno in the current file\\." \
+	     "Breakpoint 1 \\($lineno\\) pending\\."] \
+	"breakpoint on a line outside any function"
+
+    gdb_run_cmd
+    gdb_test_multiple "" "stop on lib function breakpoint" {
+	-re -wrap "Breakpoint 1, the_lib_func .*29.*x\\+\\+.*" {
+	    pass $gdb_test_name
+	}
+    }
+}
+
+do_test
diff --git a/gdb/testsuite/gdb.linespec/ls-errs.c b/gdb/testsuite/gdb.linespec/ls-errs.c
index 73b06fc7876..1dfccab2863 100644
--- a/gdb/testsuite/gdb.linespec/ls-errs.c
+++ b/gdb/testsuite/gdb.linespec/ls-errs.c
@@ -21,6 +21,16 @@ myfunction (int aa)
   int i;
 
   i = aa + 42;
+
+  /* These lines are intentionally left blank such that the tests trying
+     to place breakpoints at line -10 relative to the "set.breakpoint.here"
+     line below land on a valid breakpoint location, inside the function.  */
+
+
+
+
+
+
   return i;    /* set breakpoint here */
 }
 
diff --git a/gdb/testsuite/gdb.linespec/ls-errs.exp b/gdb/testsuite/gdb.linespec/ls-errs.exp
index 48c8a5ff056..58125f3626c 100644
--- a/gdb/testsuite/gdb.linespec/ls-errs.exp
+++ b/gdb/testsuite/gdb.linespec/ls-errs.exp
@@ -71,8 +71,8 @@ proc do_test {lang} {
 	    "Undefined convenience variable or function \"%s\" not defined in \"%s\"."
 	invalid_label "No label \"%s\" defined in function \"%s\"."
 	invalid_parm "invalid linespec argument, \"%s\""
-	invalid_offset "No line %d in the current file."
-	invalid_offset_f "No line %d in file \"%s\"."
+	invalid_offset "No compiled code for line %d in the current file."
+	invalid_offset_f "No compiled code for line %d in file \"%s\"."
 	malformed_line_offset "malformed line offset: \"%s\""
 	source_incomplete \
 	    "Source filename requires function, label, or line offset."
@@ -135,14 +135,14 @@ proc do_test {lang} {
 
     foreach x {1 +1 +100 -10} {
 	test_break "3 $x" unexpected_opt "number" $x
-	test_break "-line 3 $x" garbage $x
+	test_break "-line 34 $x" garbage $x
 	test_break "+10 $x" unexpected_opt "number" $x
 	test_break "-line +10 $x" garbage $x
 	test_break "-10 $x" unexpected_opt "number" $x
 	test_break "-line -10 $x" garbage $x
     }
 
-    foreach x {3 +10 -10} {
+    foreach x {34 +10 -10} {
 	test_break "$x foo" unexpected_opt "string" "foo"
 	test_break "-line $x foo" garbage "foo"
     }
@@ -207,12 +207,12 @@ proc do_test {lang} {
 
     test_break "${srcfile}::" invalid_function "${srcfile}::"
     test_break "$srcfile:3 1" unexpected_opt "number" "1"
-    test_break "-source $srcfile -line 3 1" garbage "1"
+    test_break "-source $srcfile -line 34 1" garbage "1"
     test_break "$srcfile:3 +100" unexpected_opt "number" "+100"
-    test_break "-source $srcfile -line 3 +100" garbage "+100"
+    test_break "-source $srcfile -line 34 +100" garbage "+100"
     test_break "$srcfile:3 -100" unexpected_opt "number" "-100"
     test_break "$srcfile:3 foo" unexpected_opt "string" "foo"
-    test_break "-source $srcfile -line 3 foo" garbage "foo"
+    test_break "-source $srcfile -line 34 foo" garbage "foo"
 
     foreach x $invalid_offsets {
 	test_break "$srcfile:$x" invalid_offset_f $x $srcfile
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
index c44477c326a..934690db2a1 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -743,7 +743,9 @@ proc_with_prefix test_bkpt_explicit_loc {} {
 	"No source file named foo.*" \
 	"set invalid explicit breakpoint by missing source and line"
     gdb_test "python bp1 = gdb.Breakpoint (source=\"$srcfile\", line=\"900\")" \
-	"No line 900 in file \"$srcfile\".*" \
+	[multi_line \
+	     "^No compiled code for line 900 in file \"$srcfile\"\\." \
+	     "Breakpoint $::decimal \[^\r\n\]+ pending\\."] \
 	"set invalid explicit breakpoint by source and invalid line"
     gdb_test "python bp1 = gdb.Breakpoint (function=\"blah\")" \
 	"Function \"blah\" not defined.*" \
diff --git a/gdb/testsuite/gdb.trace/tfind.exp b/gdb/testsuite/gdb.trace/tfind.exp
index 9d1f6e32426..c6ac80bfdb5 100644
--- a/gdb/testsuite/gdb.trace/tfind.exp
+++ b/gdb/testsuite/gdb.trace/tfind.exp
@@ -342,10 +342,10 @@ gdb_test "disassemble gdb_c_test" \
     "8.36: trace disassembly"
 
 gdb_test "tfind line 0" \
-	"out of range.*|failed to find.*|No line 0 in .*" \
+	"out of range.*|failed to find.*|No compiled code for line 0 in .*" \
 	"8.18: tfind line 0"
 gdb_test "tfind line 32767" \
-	"out of range.*|failed to find.*|No line 32767 in .*" \
+	"out of range.*|failed to find.*|No compiled code for line 32767 in .*" \
 	"8.27: tfind line 32767"
 gdb_test "tfind line NoSuChFiLe.c:$baseline" \
 	"No source file named.*" \
diff --git a/gdb/testsuite/gdb.trace/tracecmd.exp b/gdb/testsuite/gdb.trace/tracecmd.exp
index 96596ea0833..688980c78f7 100644
--- a/gdb/testsuite/gdb.trace/tracecmd.exp
+++ b/gdb/testsuite/gdb.trace/tracecmd.exp
@@ -64,7 +64,8 @@ gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2.
 # 1.2 trace invalid source line
 gdb_delete_tracepoints
 gdb_test_no_output "set breakpoint pending off"
-gdb_test "trace $srcfile:99999" "No line 99999 in file \".*$srcfile\"." \
+gdb_test "trace $srcfile:99999" \
+	"No compiled code for line 99999 in file \".*$srcfile\"\\." \
 	"1.2a: trace invalid line in sourcefile"
 gdb_test "info trace" "No tracepoints.*" \
 	"1.2b: reject invalid line in srcfile"


^ permalink raw reply	[relevance 9%]

* Re: [PATCH v2] [gdb/testsuite] Handle ptrace operation not permitted in can_spawn_for_attach
  @ 2024-05-01  8:42  0%       ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-05-01  8:42 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On 4/26/24 20:50, Pedro Alves wrote:
> On 2024-04-24 22:35, Tom de Vries wrote:
>> On 4/24/24 21:40, Pedro Alves wrote:
>>> On 2024-04-18 07:32, Tom de Vries wrote:
>>>> When running the testsuite on a system with kernel.yama.ptrace_scope set to 1,
>>>> we run into attach failures.
>>>>
>>>> Fix this by recognizing "ptrace: Operation not permitted" in
>>>> can_spawn_for_attach.
>>>>
>>>> Tested on aarch64-linux.
>>>
>>> I really don't like relying on "attach" 's behavior to decide whether to test attach.
>>> It's an inversion of responsibilities.
>>>
>>
>> Hi Pedro,
>>
>> I don't see it that way, I think this approach accurately handles that if there's no permission to attach to a spawned process, you cannot spawn-for-attach.
> 
> My inversion remark was more about of the risk of attach breaking/regressing, and attach
> testcases stop being exercised. 

I see.

> PASS -> UNSUPPORTED/UNTESTED regressions aren't that well
> noticed.

Agreed.

> But I suppose that if the procedure is written in a way that is very lax in its attach
> check, only really looking for the ptrace output case, and defaulting to return that yes,
> we can attach", that is mitigated.
> 

Yes, that was my intention.

>>
>>> can_spawn_for_attach means "can I spawn a process, such that I will attach to it later", a
>>> simple atomic thing.
>>>   > Also, with this change, it means, "can I spawn a process and does
>> attaching to it work?"
>>> So it ends up misnamed.
>>>
>>
>> I see what you mean, though I don't see it as misnamed, but if that bothers you I'm glad to rename it something else.  Can_spawn_and_attach? You have another suggestion?
> 
> 
> can_spawn_for_attach's name was originally derived from spawn_wait_for_attach.
> (git 60b3033e6e2936af6fcc37cf67cade99a89940ad).  It was more about
> "can I call spawn_wait_for_attach" than "can I attach".  But given the
> check for use_gdb_stub, I guess you could say that your check doesn't really
> change that aspect.  It's just my expectations that need to be adjusted.
> 
> Let's just leave it as you have it.
> 

Ack.

>>
>> I think the gdb_attach approach is problematic for the reasons that:
>> - it's not versatile enough to handle all the cases where it's needed,
>>    and
>> - it's required to be used in all the attach sites.
>>
>> On the contrary, the proposed patch very simply handles all the cases, and in only one proc which is already used in a trivial way in most test-cases that need it.  So it seems obvious to me that the proposed solution is preferable.
> 
> One issue I was concerned about is that for extended-remote testing, this change
> assumes the native-extended-gdbserver board's behavior of gdb_start spawning gdbserver
> and making gdb connect to it.  I don't know whether actually-remote extended-remote
> boards actually do that.  But I suppose it's a reasonable thing for them to do.
> 
> OK, I'm convinced.
> 

Great.

> Comments on the patch itself below.
> 
> On 2024-04-18 07:32, Tom de Vries wrote:
>> When running the testsuite on a system with kernel.yama.ptrace_scope set to 1,
>> we run into attach failures.
>>
>> Fix this by recognizing "ptrace: Operation not permitted" in
>> can_spawn_for_attach.
>>
>> Tested on aarch64-linux.
>> ---
>>   gdb/testsuite/gdb.base/break-interp.exp       |  4 +
>>   gdb/testsuite/gdb.base/dprintf-detach.exp     |  2 +-
>>   .../run-control-while-bg-execution.exp        | 10 ++-
>>   .../gdb.multi/attach-while-running.exp        |  2 +-
>>   .../gdb.threads/attach-into-signal.exp        |  3 +-
>>   .../gdb.threads/attach-slow-waitpid.exp       |  3 +-
>>   gdb/testsuite/gdb.threads/attach-stopped.exp  |  3 +-
>>   .../gdb.threads/check-libthread-db.exp        | 42 ++++-----
>>   gdb/testsuite/lib/gdb.exp                     | 87 ++++++++++++++++---
>>   9 files changed, 116 insertions(+), 40 deletions(-)
>>
>> diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
>> index addacde552d..d7f84db4770 100644
>> --- a/gdb/testsuite/gdb.base/break-interp.exp
>> +++ b/gdb/testsuite/gdb.base/break-interp.exp
>> @@ -318,6 +318,10 @@ proc test_attach_gdb {file pid displacement prefix} {
>>   }
>>   
>>   proc test_attach {file displacement {relink_args ""}} {
>> +    if { ![can_spawn_for_attach] } {
>> +	return
>> +    }
>> +
>>       global board_info
>>       global exec
>>   
>> diff --git a/gdb/testsuite/gdb.base/dprintf-detach.exp b/gdb/testsuite/gdb.base/dprintf-detach.exp
>> index 550d319a895..b4184d698df 100644
>> --- a/gdb/testsuite/gdb.base/dprintf-detach.exp
>> +++ b/gdb/testsuite/gdb.base/dprintf-detach.exp
>> @@ -21,7 +21,7 @@
>>   load_lib gdbserver-support.exp
>>   
>>   # The test relies on "detach/attach".
>> -require !use_gdb_stub
>> +require can_spawn_for_attach
>>   
>>   standard_testfile
>>   set escapedbinfile [string_to_regexp ${binfile}]
>> diff --git a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
>> index f1cbd9351d3..a36c4ee3614 100644
>> --- a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
>> +++ b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
>> @@ -108,8 +108,14 @@ proc do_test { action1 action2 } {
>>       }
>>   }
>>   
>> -foreach_with_prefix action1 { kill detach add none } {
>> -    foreach_with_prefix action2 { start run attach } {
>> +set actions1 { kill detach add none }
>> +set actions2 { start run }
>> +if { [can_spawn_for_attach] } {
>> +    lappend actions2 attach
>> +}
>> +
> 
> I suppose this isn't using the more typical form of:
> 
> foreach_with_prefix action1 { kill detach add none } {
>      foreach_with_prefix action2 { start run attach } {
>          if {$action2 == "attach" && ![can_spawn_for_attach]} {
>             continue
>          }
>    	do_test $action1 $action2
>      }
> }
> 
> ... to make sure the can_spawn_for_attach call is done early?
> Can you add a comment if this is important?

It's not important, since do_test starts with a clean_restart.

> Otherwise, I think
> the more typical form is a lot more readable.

I prefer it as I wrote it (and find that more readable), but ok, I've 
reworked it.

>> +foreach_with_prefix action1 $actions1 {
>> +    foreach_with_prefix action2 $actions2  {
>>   	do_test $action1 $action2
>>       }
>>   }
>> diff --git a/gdb/testsuite/gdb.multi/attach-while-running.exp b/gdb/testsuite/gdb.multi/attach-while-running.exp
>> index eade8b42a18..ca4fa635467 100644
>> --- a/gdb/testsuite/gdb.multi/attach-while-running.exp
>> +++ b/gdb/testsuite/gdb.multi/attach-while-running.exp
>> @@ -36,7 +36,7 @@
>>   
>>   standard_testfile
>>   
>> -require !use_gdb_stub
>> +require can_spawn_for_attach
>>   
>>   if { [build_executable "failed to prepare" ${testfile} ${srcfile}] } {
>>       return
>> diff --git a/gdb/testsuite/gdb.threads/attach-into-signal.exp b/gdb/testsuite/gdb.threads/attach-into-signal.exp
>> index 87e34070548..91da960e09a 100644
>> --- a/gdb/testsuite/gdb.threads/attach-into-signal.exp
>> +++ b/gdb/testsuite/gdb.threads/attach-into-signal.exp
>> @@ -17,7 +17,8 @@
>>   # This file was created by Jan Kratochvil <jan.kratochvil@redhat.com>.
>>   
>>   # This test only works on Linux
>> -require !use_gdb_stub isnative
>> +require can_spawn_for_attach
>> +require isnative
>>   require {!is_remote host}
>>   require {istarget *-linux*}
>>   
>> diff --git a/gdb/testsuite/gdb.threads/attach-slow-waitpid.exp b/gdb/testsuite/gdb.threads/attach-slow-waitpid.exp
>> index dc3e62a7b7e..28d70daad8c 100644
>> --- a/gdb/testsuite/gdb.threads/attach-slow-waitpid.exp
>> +++ b/gdb/testsuite/gdb.threads/attach-slow-waitpid.exp
>> @@ -37,7 +37,8 @@
>>   # during the attach phase.
>>   
>>   # This test only works on Linux
>> -require !use_gdb_stub isnative
>> +require can_spawn_for_attach
>> +require isnative
>>   require {!is_remote host}
>>   require {istarget *-linux*}
>>   
>> diff --git a/gdb/testsuite/gdb.threads/attach-stopped.exp b/gdb/testsuite/gdb.threads/attach-stopped.exp
>> index 78e194c992f..0421ffc3794 100644
>> --- a/gdb/testsuite/gdb.threads/attach-stopped.exp
>> +++ b/gdb/testsuite/gdb.threads/attach-stopped.exp
>> @@ -18,7 +18,8 @@
>>   # This file was updated by Jan Kratochvil <jan.kratochvil@redhat.com>.
>>   
>>   # This test only works on Linux
>> -require !use_gdb_stub isnative
>> +require can_spawn_for_attach
>> +require isnative
>>   require {!is_remote host}
>>   require {istarget *-linux*}
>>   
> 
> 
>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>> index d48ea37c0cc..937add7a272 100644
>> --- a/gdb/testsuite/lib/gdb.exp
>> +++ b/gdb/testsuite/lib/gdb.exp
>> @@ -6131,6 +6131,43 @@ proc gdb_exit { } {
>>       catch default_gdb_exit
>>   }
>>   
>> +# Helper function for can_spawn_for_attach.  Try to spawn and attach, and
>> +# return 0 only if we cannot attach because it's unsupported.
>> +
>> +gdb_caching_proc can_spawn_for_attach_1 {} {
>> +    # Assume yes.
>> +    set res 1
>> +
>> +    set me "can_spawn_for_attach"
>> +    set src { int main (void) { sleep (600); return 0; } }
> 
> Don't we need a header include for sleep?
> 

Indeed, added.

>> +    if {![gdb_simple_compile $me $src executable]} {
>> +	return $res
>> +    }
>> +
>> +    set test_spawn_id [spawn_wait_for_attach_1 $obj]
>> +    file delete $obj
> 
> I think this should be a remote_file call, not a build file delete.
> can_spawn_wait_for_attach returns false if the target is remote,
> not if the host is remote.
> 

AFAIU, with remote host, compiling mean copying sources to remote host, 
compiling on remote host and copying the artifact back to build.  This 
is all taken care of by dejagnu, and the file we're deleting is the file 
on build.

Anyway, I've changed this to use "remote_file build" to make this more 
clear.

>> +
>> +    gdb_start
>> +
>> +    set test_pid [spawn_id_get_pid $test_spawn_id]
>> +    set attaching_re "Attaching to process $test_pid"
>> +    gdb_test_multiple "attach $test_pid" "can spawn for attach" {
>> +	-re -wrap "$attaching_re\r\n.*ptrace: Operation not permitted\\." {
>> +	    # Not permitted.
>> +	    set res 0
>> +	}
>> +	-re -wrap "" {
>> +	    # Don't know.
>> +	}
>> +    }
>> +
>> +    gdb_exit
> 
> The comment below suggests this gdb_exit shouldn't be here.
> 

It does belong here.  Your comment means my comment is not good enough, 
I've updated it to make it more clear.

>> +
>> +    kill_wait_spawned_process $test_spawn_id
>> +
>> +    return $res
>> +}
>> +
>>   # Return true if we can spawn a program on the target and attach to
>>   # it.
>>   
> 
>> @@ -6151,8 +6188,25 @@ proc can_spawn_for_attach { } {
>>   	return 0
>>       }
>>   
>> -    # Assume yes.
>> -    return 1
>> +    # By making can_spawn_for_attach_1 a gdb_caching_proc, we make it
>> +    # unpredictable which test-case will call it first, and consequently a
>> +    # test-case may pass in say a full test run, but fail when run
>> +    # individually, due to a can_spawn_for_attach call in location where a
>> +    # gdb_exit (as can_spawn_for_attach_1 does) breaks things.
>> +    # To avoid this, we move the initial gdb_exit out of
>> +    # can_spawn_for_attach_1, guaranteeing that we end up in the same state
>> +    # regardless of whether can_spawn_for_attach_1 is called.  However, that
>> +    # is only necessary for the first call in a test-case, so cache the result
>> +    # in a global (which should be reset after each test-case) to keep track
>> +    # of that.
>> +    global cache_can_spawn_for_attach_1
>> +    if { [info exists cache_can_spawn_for_attach_1] } {
>> +	return $cache_can_spawn_for_attach_1
>> +    }
>> +    gdb_exit
> 
> There is still a gdb_exit call in can_spawn_for_attach_1.
> I guess you meant to remove it?
> 

There is, and it's intentional.  Again, I hope that the updated comment 
will clarify this.

> I think it'll also be good to document that can_spawn_for_attach calls gdb_exit.
> 

Done.

>> +
>> +    set cache_can_spawn_for_attach_1 [can_spawn_for_attach_1]
>> +    return $cache_can_spawn_for_attach_1
>>   }
>>   
>>   # Centralize the failure checking of "attach" command.
>> @@ -6265,20 +6319,12 @@ proc spawn_id_get_pid { spawn_id } {
>>       return $testpid
>>   }
>>   
>> -# Start a set of programs running and then wait for a bit, to be sure
>> -# that they can be attached to.  Return a list of processes spawn IDs,
>> -# one element for each process spawned.  It's a test error to call
>> -# this when [can_spawn_for_attach] is false.
>> +# Helper function for spawn_wait_for_attach
> 
> ... and can_spawn_for_attach_1.  Just spawn_wait_for_attach by itself
> wouldn't need the helper.
> 

Ack, updated.


I've submitted a v2 here ( 
https://sourceware.org/pipermail/gdb-patches/2024-May/208725.html ).

Thanks,
- Tom

>> As spawn_wait_for_attach, but
>> +# doesn't check for can_spawn_for_attach.
>>   
> 



^ permalink raw reply	[relevance 0%]

* Re: [PATCH] Fix AIX thread exit events not being reported and UI to show kernel thread ID.
  @ 2024-04-30 16:41  0%   ` John Baldwin
  0 siblings, 0 replies; 200+ results
From: John Baldwin @ 2024-04-30 16:41 UTC (permalink / raw)
  To: gdb-patches

On 4/29/24 4:48 AM, Aditya Kamath1 wrote:
> This is an older version of the patch. Sorry for resending this. Kindly ignore the same. I have sent the latest version in another git send-email.

Please use -v <n> (e.g. '-v 2') with a new version of n each time you use git send-email
to send a new version of a patch.  This makes includes the 'n' value in the e-mail
subject making it easier to see which version is the latest version.
  
> Have a nice day ahead.
> 
> Thanks and regards,
> Aditya.
> 
> From: Aditya Vidyadhar Kamath <akamath996@gmail.com>
> Date: Monday, 29 April 2024 at 5:11 PM
> To: tom@tromey.com <tom@tromey.com>
> Cc: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
> Subject: [EXTERNAL] [PATCH] Fix AIX thread exit events not being reported and UI to show kernel thread ID.
> From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
> 
> In AIX when a thread exits we were not showing that a thread exit event happened
> and GDB continued to keep the terminated threads.
> 
> If we have terminated threads then the UI on info threads command will look like
> (gdb) info threads
>    Id   Target Id                                          Frame
> * 1    Thread 1 (tid 26607979, running)    0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
>    2    Thread 258 (tid 30998799, finished) aix-thread: ptrace (52, 30998799) returned -1 (errno = 3 The process does not exist.)
> 
> If we see the frame is not getting displayed correctly.
> 
> The reason for the same is that in AIX we were not managing thread states. In particular we do not know
> when a thread terminates.
> 
> The reason being in sync_threadlists () the pbuf and gbuf lists remain the same though certain threads exit.
> 
> This patch is a fix to the same.
> 
> Also certain UI is changed.
> 
> On a new thread born and exit the UI in AIX will be similar to Linux with both user and kernel thread information.
> 
> [New Thread 258 (tid 32178533)]
> [New Thread 515 (tid 30343651)]
> [New Thread 772 (tid 33554909)]
> [New Thread 1029 (tid 24969489)]
> [New Thread 1286 (tid 18153945)]
> [New Thread 1543 (tid 30736739)]
> [Thread 258 (tid 32178533) exited]
> [Thread 515 (tid 30343651) exited]
> [Thread 772 (tid 33554909) exited]
> [Thread 1029 (tid 24969489) exited]
> [Thread 1286 (tid 18153945) exited]
> [Thread 1543 (tid 30736739) exited]
> 
> and info threads will look like
> (gdb) info threads
>    Id   Target Id                           Frame
> * 1    Thread 1 (tid 31326579) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
> ---
>   gdb/aix-thread.c | 91 ++++++++++++++++++++++++++++++------------------
>   1 file changed, 57 insertions(+), 34 deletions(-)
> 
> diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
> index c70bd82bc24..5ccccf02879 100644
> --- a/gdb/aix-thread.c
> +++ b/gdb/aix-thread.c
> @@ -55,6 +55,7 @@
>   #include <sys/reg.h>
>   #include <sched.h>
>   #include <sys/pthdebug.h>
> +#include <vector>
> 
>   #if !HAVE_DECL_GETTHRDS
>   extern int getthrds (pid_t, struct thrdsinfo64 *, int, tid_t *, int);
> @@ -190,6 +191,9 @@ struct aix_thread_variables
>     /* Whether the current architecture is 64-bit.
>      Only valid when pd_able is true.  */
>     int arch64;
> +
> +  /* Describes the number of thread born events have been reported.  */
> +  int threads_reported = 0;
>   };
> 
>   /* Key to our per-inferior data.  */
> @@ -740,11 +744,9 @@ state2str (pthdb_state_t state)
>   /* qsort() comparison function for sorting pd_thread structs by pthid.  */
> 
>   static int
> -pcmp (const void *p1v, const void *p2v)
> +pcmp (struct pd_thread p1v, struct pd_thread p2v)
>   {
> -  struct pd_thread *p1 = (struct pd_thread *) p1v;
> -  struct pd_thread *p2 = (struct pd_thread *) p2v;
> -  return p1->pthid < p2->pthid ? -1 : p1->pthid > p2->pthid;
> +  return p1v.pthid < p2v.pthid;
>   }
> 
>   /* ptid comparison function */
> @@ -823,7 +825,6 @@ sync_threadlists (pid_t pid)
>   {
>     int cmd, status;
>     int pcount, psize, pi, gcount, gi;
> -  struct pd_thread *pbuf;
>     struct thread_info **gbuf, **g, *thread;
>     pthdb_pthread_t pdtid;
>     pthread_t pthid;
> @@ -831,12 +832,13 @@ sync_threadlists (pid_t pid)
>     process_stratum_target *proc_target = current_inferior ()->process_target ();
>     struct aix_thread_variables *data;
>     data = get_thread_data_helper_for_pid (pid);
> +  std::vector<pd_thread> pbuf;
> +  struct pd_thread aix_pd_thread;
> 
>     /* Accumulate an array of libpthdebug threads sorted by pthread id.  */
> 
>     pcount = 0;
>     psize = 1;
> -  pbuf = XNEWVEC (struct pd_thread, psize);
> 
>     for (cmd = PTHDB_LIST_FIRST;; cmd = PTHDB_LIST_NEXT)
>       {
> @@ -848,27 +850,36 @@ sync_threadlists (pid_t pid)
>         if (status != PTHDB_SUCCESS || pthid == PTHDB_INVALID_PTID)
>           continue;
> 
> -      if (pcount == psize)
> -       {
> -         psize *= 2;
> -         pbuf = (struct pd_thread *) xrealloc (pbuf,
> -                                               psize * sizeof *pbuf);
> -       }
> -      pbuf[pcount].pdtid = pdtid;
> -      pbuf[pcount].pthid = pthid;
> +      aix_pd_thread.pdtid = pdtid;
> +      aix_pd_thread.pthid = pthid;
> +      pbuf.push_back (aix_pd_thread);
>         pcount++;
>       }
> 
> -  for (pi = 0; pi < pcount; pi++)
> +  for (auto it = pbuf.begin (); it != pbuf.end ();)
>       {
> -      status = pthdb_pthread_tid (data->pd_session, pbuf[pi].pdtid, &tid);
> +      status = pthdb_pthread_tid (data->pd_session, (*it).pdtid, &tid);
>         if (status != PTHDB_SUCCESS)
>           tid = PTHDB_INVALID_TID;
> -      pbuf[pi].tid = tid;
> -    }
> 
> -  qsort (pbuf, pcount, sizeof *pbuf, pcmp);
> +      (*it).tid = tid;
> +      pthdb_state_t state;
> +
> +      status = pthdb_pthread_state (data->pd_session, (*it).pdtid, &state);
> 
> +      /* If the thread is terminated and has not reported its existence
> +        or new thread event, then wait for it to report.  We want users
> +        to know threads were added and then delete. So first add them to
> +        pbuf and the next time sync_threadlists is called delete them since
> +        data->threads_reported is guarenteed to be greater than 0.  */
> +
> +      if (state == PST_TERM && data->threads_reported > 0)
> +       pbuf.erase (it);
> +      else
> +       ++it;
> +    }
> +
> +  std::sort (pbuf.begin (), pbuf.end (), pcmp);
>     /* Accumulate an array of GDB threads sorted by pid.  */
> 
>     /* gcount is GDB thread count and pcount is pthreadlib thread count.  */
> @@ -881,6 +892,7 @@ sync_threadlists (pid_t pid)
>       *g++ = tp;
>     qsort (gbuf, gcount, sizeof *gbuf, gcmp);
> 
> +  pcount = pbuf.size ();
>     /* Apply differences between the two arrays to GDB's thread list.  */
> 
>     for (pi = gi = 0; pi < pcount || gi < gcount;)
> @@ -889,6 +901,12 @@ sync_threadlists (pid_t pid)
>           {
>             delete_thread (gbuf[gi]);
>             gi++;
> +         data->threads_reported--;
> +
> +         /* Since main thread is reported.  */
> +
> +         if (data->threads_reported == 0)
> +           data->threads_reported = 1;
>           }
>         else if (gi == gcount)
>           {
> @@ -901,6 +919,7 @@ sync_threadlists (pid_t pid)
>                                            private_thread_info_up (priv));
> 
>             pi++;
> +         data->threads_reported++;
>           }
>         else
>           {
> @@ -913,7 +932,6 @@ sync_threadlists (pid_t pid)
>             tid = pbuf[pi].tid;
> 
>             cmp_result = ptid_cmp (pptid, gptid);
> -
>             if (cmp_result == 0)
>               {
>                 aix_thread_info *priv = get_aix_thread_info (gbuf[gi]);
> @@ -943,6 +961,10 @@ sync_threadlists (pid_t pid)
>                   {
>                     delete_thread (gbuf[gi]);
>                     gi++;
> +                 data->threads_reported--;
> +
> +                 if (data->threads_reported == 0)
> +                   data->threads_reported = 1;
>                   }
>               }
>             else
> @@ -954,11 +976,11 @@ sync_threadlists (pid_t pid)
>                 priv->pdtid = pdtid;
>                 priv->tid = tid;
>                 pi++;
> +             data->threads_reported++;
>               }
>           }
>       }
> 
> -  xfree (pbuf);
>     xfree (gbuf);
>   }
> 
> @@ -2084,10 +2106,17 @@ aix_thread_target::thread_alive (ptid_t ptid)
>   std::string
>   aix_thread_target::pid_to_str (ptid_t ptid)
>   {
> -  if (ptid.tid () == 0)
> -    return beneath ()->pid_to_str (ptid);
> +  thread_info *thread_info = current_inferior ()->find_thread (ptid);
> +
> +  if (thread_info != NULL && thread_info->priv != NULL)
> +    {
> +      aix_thread_info *priv = get_aix_thread_info (thread_info);
> +
> +      return string_printf (_("Thread %s (tid %s)"), pulongest (ptid.tid ()),
> +               pulongest (priv->tid));
> +    }
> 
> -  return string_printf (_("Thread %s"), pulongest (ptid.tid ()));
> +  return beneath ()->pid_to_str (ptid);
>   }
> 
>   /* Return a printable representation of extra information about
> @@ -2098,7 +2127,6 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
>   {
>     int status;
>     pthdb_pthread_t pdtid;
> -  pthdb_tid_t tid;
>     pthdb_state_t state;
>     pthdb_suspendstate_t suspendstate;
>     pthdb_detachstate_t detachstate;
> @@ -2115,33 +2143,28 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
>     aix_thread_info *priv = get_aix_thread_info (thread);
> 
>     pdtid = priv->pdtid;
> -  tid = priv->tid;
> -
> -  if (tid != PTHDB_INVALID_TID)
> -    /* i18n: Like "thread-identifier %d, [state] running, suspended" */
> -    buf.printf (_("tid %d"), (int)tid);
> 
>     status = pthdb_pthread_state (data->pd_session, pdtid, &state);
>     if (status != PTHDB_SUCCESS)
>       state = PST_NOTSUP;
> -  buf.printf (", %s", state2str (state));
> +  buf.printf ("[%s]", state2str (state));
> 
>     status = pthdb_pthread_suspendstate (data->pd_session, pdtid,
>                                          &suspendstate);
>     if (status == PTHDB_SUCCESS && suspendstate == PSS_SUSPENDED)
>       /* i18n: Like "Thread-Id %d, [state] running, suspended" */
> -    buf.printf (_(", suspended"));
> +    buf.printf (_("[suspended]"));
> 
>     status = pthdb_pthread_detachstate (data->pd_session, pdtid,
>                                         &detachstate);
>     if (status == PTHDB_SUCCESS && detachstate == PDS_DETACHED)
>       /* i18n: Like "Thread-Id %d, [state] running, detached" */
> -    buf.printf (_(", detached"));
> +    buf.printf (_("[detached]"));
> 
>     pthdb_pthread_cancelpend (data->pd_session, pdtid, &cancelpend);
>     if (status == PTHDB_SUCCESS && cancelpend)
>       /* i18n: Like "Thread-Id %d, [state] running, cancel pending" */
> -    buf.printf (_(", cancel pending"));
> +    buf.printf (_("[cancel pending]"));
> 
>     buf.write ("", 1);
> 
> --
> 2.41.0

-- 
John Baldwin


^ permalink raw reply	[relevance 0%]

* [PATCH v2 3/3] Add symbol, line, and location to DAP disassemble result
  @ 2024-04-30 13:15  5% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-30 13:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The DAP spec allows a number of attributes on the resulting
instructions that gdb currently does not emit.  A user requested some
of these, so this patch adds the 'symbol', 'line', and 'location'
attributes.  While the spec lets the implementation omit 'location' in
some cases, it was simpler in the code to just always emit it, as then
no extra tracking was needed.
---
 gdb/python/lib/gdb/dap/disassemble.py |  59 +++++++++++++--
 gdb/testsuite/gdb.dap/disassem.c      |  52 +++++++++++++
 gdb/testsuite/gdb.dap/disassem.exp    | 105 ++++++++++++++++++++++++++
 3 files changed, 209 insertions(+), 7 deletions(-)
 create mode 100644 gdb/testsuite/gdb.dap/disassem.c
 create mode 100644 gdb/testsuite/gdb.dap/disassem.exp

diff --git a/gdb/python/lib/gdb/dap/disassemble.py b/gdb/python/lib/gdb/dap/disassemble.py
index 65bf3d4457b..b99e4f83f84 100644
--- a/gdb/python/lib/gdb/dap/disassemble.py
+++ b/gdb/python/lib/gdb/dap/disassemble.py
@@ -16,6 +16,50 @@
 import gdb
 
 from .server import capability, request
+from .sources import make_source
+
+
+# This tracks labels associated with a disassembly request and helps
+# with updating individual instructions.
+class _BlockTracker:
+    def __init__(self):
+        # Map from PC to symbol names.  A given PC is assumed to have
+        # just one label -- DAP wouldn't let us return multiple labels
+        # anyway.
+        self.labels = {}
+        # List of blocks that have already been handled.  Note that
+        # blocks aren't hashable so a set is not used.
+        self.blocks = []
+
+    # Add a gdb.Block and its superblocks, ignoring the static and
+    # global block.  BLOCK can also be None, which is ignored.
+    def add_block(self, block):
+        while block is not None:
+            if block.is_static or block.is_global or block in self.blocks:
+                return
+            self.blocks.append(block)
+            if block.function is not None:
+                self.labels[block.start] = block.function.name
+            for sym in block:
+                if sym.addr_class == gdb.SYMBOL_LOC_LABEL:
+                    self.labels[int(sym.value())] = sym.name
+            block = block.superblock
+
+    # Add PC to this tracker.  Update RESULT as appropriate with
+    # information about the source and any label.
+    def add_pc(self, pc, result):
+        self.add_block(gdb.block_for_pc(pc))
+        if pc in self.labels:
+            result["symbol"] = self.labels[pc]
+        sal = gdb.find_pc_line(pc)
+        if sal.symtab is not None:
+            if sal.line != 0:
+                result["line"] = str(sal.line)
+            if sal.symtab.filename is not None:
+                # The spec says this can be omitted in some
+                # situations, but it's a little simpler to just always
+                # supply it.
+                result["location"] = make_source(sal.symtab.filename)
 
 
 @request("disassemble")
@@ -35,17 +79,18 @@ def disassemble(
     except gdb.error:
         # Maybe there was no frame.
         arch = inf.architecture()
+    tracker = _BlockTracker()
     result = []
     total_count = instructionOffset + instructionCount
     for elt in arch.disassemble(pc, count=total_count)[instructionOffset:]:
         mem = inf.read_memory(elt["addr"], elt["length"])
-        result.append(
-            {
-                "address": hex(elt["addr"]),
-                "instruction": elt["asm"],
-                "instructionBytes": mem.hex(),
-            }
-        )
+        insn = {
+            "address": hex(elt["addr"]),
+            "instruction": elt["asm"],
+            "instructionBytes": mem.hex(),
+        }
+        tracker.add_pc(elt["addr"], insn)
+        result.append(insn)
     return {
         "instructions": result,
     }
diff --git a/gdb/testsuite/gdb.dap/disassem.c b/gdb/testsuite/gdb.dap/disassem.c
new file mode 100644
index 00000000000..c0f5128c97d
--- /dev/null
+++ b/gdb/testsuite/gdb.dap/disassem.c
@@ -0,0 +1,52 @@
+/* Copyright 2024 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+__attribute__((__noinline__)) static int
+callee (int x)
+{
+  return x * 2;
+}
+
+static inline int __attribute__((__always_inline__))
+compute (int x)
+{
+  return callee (x);
+}
+
+static int
+return_value (int x)
+{
+  int accum = 0;
+
+  for (int i = 0; i < x; ++i)
+    {
+      int value = compute (i);
+      if (value < 0)
+	goto out_label;
+    }
+
+ out_label:
+
+  return accum;
+}
+
+int
+main ()
+{
+  int value = return_value (23);
+  return value > 0 ? 0 : 1;
+}
diff --git a/gdb/testsuite/gdb.dap/disassem.exp b/gdb/testsuite/gdb.dap/disassem.exp
new file mode 100644
index 00000000000..87fb516931a
--- /dev/null
+++ b/gdb/testsuite/gdb.dap/disassem.exp
@@ -0,0 +1,105 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test DAP disassembly.
+
+require allow_dap_tests
+
+load_lib dap-support.exp
+
+standard_testfile
+
+if {[build_executable ${testfile}.exp $testfile] == -1} {
+    return
+}
+
+if {[dap_initialize] == ""} {
+    return
+}
+
+set obj [dap_check_request_and_response "set breakpoint" \
+	     setFunctionBreakpoints \
+	     {o breakpoints [a [o name [s main]]]}]
+set fn_bpno [dap_get_breakpoint_number $obj]
+
+dap_check_request_and_response "configurationDone" configurationDone
+
+if {[dap_launch $testfile] == ""} {
+    return
+}
+dap_wait_for_event_and_check "inferior started" thread "body reason" started
+
+dap_wait_for_event_and_check "stopped at line breakpoint" stopped \
+    "body reason" breakpoint \
+    "body hitBreakpointIds" $fn_bpno
+
+# Find out how many lines of disassembly we should request.  This is
+# kind of lame but DAP doesn't really provide tools to do this, and
+# gdb's DAP implementation doesn't try to figure out what memory might
+# not really be part of a function.
+set obj [dap_check_request_and_response "disassemble using CLI" \
+	     evaluate {o expression [s {disassemble &return_value}] \
+			   context [s repl]}]
+set output [dict get [lindex $obj 0] body result]
+# The result will have literal "\" "n" sequences, turn these into
+# newlines.
+set with_nl [string map [list "\\n" "\n"] $output]
+# The value we want is the number of lines starting with an address.
+set insn_count 0
+foreach line [split $with_nl "\n"] {
+    if {[regexp "^ *0x" $line]} {
+	incr insn_count
+    }
+}
+
+set obj [dap_check_request_and_response "find function address" \
+	     evaluate {o expression [s "&return_value"]}]
+set pc [dict get [lindex $obj 0] body memoryReference]
+
+set obj [dap_check_request_and_response "disassemble the function" \
+	     disassemble \
+	     [format {o memoryReference [s %s] instructionCount [i %d]} \
+		  $pc $insn_count]]
+set response [lindex $obj 0]
+
+set seen_labels(_) _
+set insn_no 1
+foreach insn [dict get $response body instructions] {
+    with_test_prefix $insn_no {
+	gdb_assert {[dict exists $insn line]} \
+	    "line in disassemble output"
+	gdb_assert {[dict exists $insn location]} \
+	    "location in disassemble output"
+	if {[dict exists $insn symbol]} {
+	    set seen_labels([dict get $insn symbol]) 1
+	}
+    }
+    incr insn_no
+}
+
+proc require_label {name} {
+    global seen_labels
+    if {[info exists seen_labels($name)]} {
+	pass "saw label $name"
+    } else {
+	fail "saw label $name"
+    }
+}
+
+require_label return_value
+require_label compute
+require_label out_label
+
+dap_shutdown
-- 
2.44.0


^ permalink raw reply	[relevance 5%]

* Re: [PATCH] sim: riscv: Fix Zicsr and fence instructions
  @ 2024-04-29 13:30  0%   ` Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-29 13:30 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 4/29/24 12:01, Andrew Burgess wrote:
> Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
> 
>> The Zicsr instructions were totally broken, and
>> some instructions like fence.tso were missing.
>>
>> Since the test coverage is not very good, add some
>> basic tests for fence and csrrw instructions.
>> ---
>>  sim/riscv/sim-main.c        | 74 ++++++++++++++++++++++++++++++++-----
>>  sim/testsuite/riscv/fence.s | 17 +++++++++
>>  sim/testsuite/riscv/zicsr.s | 24 ++++++++++++
>>  3 files changed, 106 insertions(+), 9 deletions(-)
>>  create mode 100644 sim/testsuite/riscv/fence.s
>>  create mode 100644 sim/testsuite/riscv/zicsr.s
>>
>> diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
>> index 1815d7f2a6c..69007d3108e 100644
>> --- a/sim/riscv/sim-main.c
>> +++ b/sim/riscv/sim-main.c
>> @@ -535,37 +535,57 @@ execute_i (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>        break;
>>  
>>      case MATCH_CSRRC:
>> -      TRACE_INSN (cpu, "csrrc");
>> +      TRACE_INSN (cpu, "csrrc %s, %#x, %s;",
>> +		  rd_name, csr, rs1_name);
>>        switch (csr)
>>  	{
>>  #define DECLARE_CSR(name, num, ...) \
>>  	case num: \
>> -	  store_rd (cpu, rd, \
>> -		    fetch_csr (cpu, #name, num, &riscv_cpu->csr.name)); \
>> +	  tmp = fetch_csr (cpu, #name, num, &riscv_cpu->csr.name); \
>>  	  store_csr (cpu, #name, num, &riscv_cpu->csr.name, \
>> -		     riscv_cpu->csr.name & !riscv_cpu->regs[rs1]); \
>> +		     riscv_cpu->csr.name & ~riscv_cpu->regs[rs1]); \
>> +	  store_rd (cpu, rd, tmp); \
> 
> I know that store_csr doesn't support many CSRs, and doesn't do any
> checks for things like writing to read-only CSRs, but ....
> 
> ... I think it might be worth adding a check here for rs1 == x0.  The
> docs say:
> 
>   For both CSRRS and CSRRC, if rs1=x0, then the instruction will not
>   write to the CSR at all, and so shall not cause any of the side
>   effects that might otherwise occur on a CSR write, such as raising
>   illegal instruction exceptions on accesses to read-only CSRs.
> 
> Adding these checks now might mean things "just work" if we add support
> for more CSRs at a later date.
> 

Yeah, good point.

will add those checks and send a v2 version.

Thanks
Bernd.

^ permalink raw reply	[relevance 0%]

* Re: [PATCH v3] Add a test for the gcore script
  @ 2024-04-29 12:09  0% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-04-29 12:09 UTC (permalink / raw)
  To: Alexandra Hájková, gdb-patches; +Cc: ahajkova

Alexandra Hájková <ahajkova@khirnov.net> writes:

> From: Alexandra Hájková <ahajkova@redhat.com>
>
> It also tests the gcore script being run without its accessible
> terminal.
>
> This test was written by Jan Kratochvil a long time ago. I modernized
> the test making it use various procs from lib/gdb.exp, reoirganising it
> and added some comments.
>
> Modify the gcore script to make it possible to pass the --data-directory to
> it. This prevents a lot of these warnings:
>
> Python Exception <class 'AttributeError'>: module 'gdb' has no attribute
> '_handle_missing_debuginfo'
>
> Tested by using make check-all-boards.
>
> Co-Authored-By: Jan Kratochvil
> ---
> v3: - do not call sh explicitly to avoid "Syntax error: "(" unexpected"
>
>  gdb/gcore.in                       |  9 ++-
>  gdb/testsuite/gdb.base/gcorebg.c   | 85 +++++++++++++++++++++++++++++
>  gdb/testsuite/gdb.base/gcorebg.exp | 88 ++++++++++++++++++++++++++++++
>  gdb/testsuite/lib/gdb.exp          | 17 ++++++
>  4 files changed, 198 insertions(+), 1 deletion(-)
>  create mode 100644 gdb/testsuite/gdb.base/gcorebg.c
>  create mode 100644 gdb/testsuite/gdb.base/gcorebg.exp
>
> diff --git a/gdb/gcore.in b/gdb/gcore.in
> index 982c854eb70..291b807bed9 100644
> --- a/gdb/gcore.in
> +++ b/gdb/gcore.in
> @@ -27,7 +27,9 @@ prefix=core
>  # to ensure gdb dumps all mappings (OS dependent).
>  dump_all_cmds=()
>  
> -while getopts :ao: opt; do
> +DATA_DIRECTORY_OPT=""

All other variables are lower case, so think this should be too.

> +
> +while getopts :ao:d: opt; do
>      case "$opt" in
>          a)
>              case "$OSTYPE" in
> @@ -40,8 +42,12 @@ while getopts :ao: opt; do
>          o)
>              prefix=$OPTARG
>              ;;
> +        d)
> +            DATA_DIRECTORY_OPT="--data-directory $OPTARG"

I've been thinking about filenames containing spaces recently.  I wonder
if we should create data_directory_opt as an array, like we do with
dump_all_cmds?

So initialise it as:

  data_directory_opt=()

And here we'd do:

  data_directory_opt=("--data-directory", "$OPTARG")

Then, when we use it we can do:

  "${data_directory_opt[@]}"

which will enclose each array element in quotes.  In this way, I think
that if OPTARG contains a space, we should still correctly forward the
string to GDB.

> +            ;;
>          *)
>              echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] pid1 [pid2...pidN]"
> +            echo "DATA_DIRECTORY_OPT: $DATA_DIRECTORY_OPT"

I think this line was likely debug?  But that points out that you should
have updated the usage line.

You should also update the documentation I think, there's certainly some
docs for the gcore script, so they'll need updating.

>              exit 2
>              ;;
>      esac
> @@ -98,6 +104,7 @@ do
>  	# `</dev/null' to avoid touching interactive terminal if it is
>  	# available but not accessible as GDB would get stopped on SIGTTIN.
>  	"$binary_path/@GDB_TRANSFORM_NAME@" </dev/null \
> +            $DATA_DIRECTORY_OPT \

This is where I'd propose using:

  "${data_directory_opt[@]}"

to handle paths containing whitespace.

>  	    --nx --batch --readnever -iex 'set debuginfod enabled off' \
>  	    -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
>  	    "${dump_all_cmds[@]}" \
> diff --git a/gdb/testsuite/gdb.base/gcorebg.c b/gdb/testsuite/gdb.base/gcorebg.c
> new file mode 100644
> index 00000000000..a56ca743a98
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/gcorebg.c
> @@ -0,0 +1,85 @@
> +/* Copyright 2007-2024 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <signal.h>
> +#include <string.h>
> +#include <assert.h>
> +
> +/* Expects 4 arguments:
> +
> +   1. Either 'standard' or 'detached', where 'standard' tests
> +   a general gcore script spawn with its controlling terminal available
> +   and 'detached' tests gcore script spawn without its controlling
> +   terminal available.
> +   2. Path to the gcore script
> +   3. Path to the data-directory to pass to the gcore script
> +   4. The core file output name
> +
> +*/

Full stop at the end of each list entry, like you have for #1, and the
final '*/' should be on the line for entry number 4.

> +
> +int
> +main (int argc, char **argv)
> +{
> +  pid_t pid = 0;
> +  pid_t ppid;
> +  char buf[1024*2 + 500];
> +  int gotint, res;
> +  int fd[2];
> +
> +  assert (argc == 5);
> +
> +  if (pipe(fd) == -1)
> +    {
> +      perror ("pipe err\n");
> +      exit (1);
> +    }
> +  pid = fork ();
> +
> +  switch (pid)
> +    {
> +    case 0:
> +      close (fd[0]);
> +      if (strcmp (argv[1], "detached") == 0)
> +	setpgrp ();
> +      ppid = getppid ();
> +      gotint = snprintf (buf, sizeof (buf), "%s -d %s -o %s %d",
> +			 argv[2], argv[3], argv[4], (int) ppid);
> +      assert (gotint < sizeof (buf));
> +      res = system (buf);
> +      assert (res != -1);
> +      close(fd[1]);
> +      break;
> +
> +    case -1:
> +      close (fd[0]);
> +      close (fd[1]);
> +      perror ("fork err\n");
> +      exit (1);
> +      break;
> +
> +    default:
> +      close (fd[1]);

In Pedro's review of V1 he suggested adding some comments of the flow of
control.  The implementation has changed since V1, but I do think it
wouldn't hurt to add a comment here:

  /* Wait here until the child is done with gcore-ing us.  When the
     child has finished it will close its end of the pipe and this read
     call will return.  */

> +      res = read (fd[0], buf, 1);
> +      assert (res == 0);
> +      close (fd[0]);
> +      break;
> +    }
> +
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.base/gcorebg.exp b/gdb/testsuite/gdb.base/gcorebg.exp
> new file mode 100644
> index 00000000000..6269988133c
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/gcorebg.exp
> @@ -0,0 +1,88 @@
> +# Copyright 2007-2024 Free Software Foundation, Inc.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +#
> +# This is a test for the gcore script (not the gcore command form
> +# inside GDB).  It also tests the gcore script being run without its
> +# accessible terminal.
> +
> +standard_testfile
> +require {!is_remote host}
> +require {!is_remote target}
> +require has_gcore_script
> +
> +set corefile [standard_output_file ${testfile}.core]
> +
> +if {[build_executable "failed to build" $testfile ${srcfile}] == -1 } {
> +     return -1
> +}
> +
> +# Cleanup.
> +
> +proc core_clean {} {
> +    global corefile
> +
> +    foreach file [glob -nocomplain [join [list $corefile *] ""]] {
> +	verbose "Delete file $file" 1
> +	remote_file target delete $file
> +    }
> +}
> +core_clean
> +
> +# Generate the core file.
> +proc test_body { detached } {
> +    global binfile
> +    global GCORE
> +    global corefile
> +    global GDB_DATA_DIRECTORY
> +
> +    with_test_prefix "detached = $detached" {
> +	# We can't use gdb_test_multiple here because GDB is not started.
> +	set res [remote_spawn target "$binfile $detached $GCORE $GDB_DATA_DIRECTORY $corefile"]
> +	if { $res < 0 || $res == "" } {
> +	    fail "Spawning gcore"
> +	    return 1
> +	}
> +	pass "Spawned gcore"
> +
> +	set saw_corefile_created false
> +	set testname "Spawned gcore finished"
> +	remote_expect target 20 {
> +	    timeout {
> +		fail "$testname (timeout)"
> +		remote_exec target "kill -9 -[exp_pid -i $res]"
> +		return
> +	    }
> +	    -re "Saved corefile \[^\r\n\]+\r\n" {
> +		set saw_corefile_created true
> +		exp_continue
> +	    }
> +	    eof {
> +		gdb_assert { $saw_corefile_created } $testname
> +	    }
> +	}
> +
> +	gdb_assert {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} "Core file generated by gcore"
> +	core_clean
> +    }
> +}
> +
> +# First a general gcore script spawn with its controlling terminal available.
> +
> +test_body standard
> +
> +# And now gcore script spawn without its controlling terminal available.
> +# It is spawned through `gcorebg.c' using setpgrp ().
> +
> +test_body detached
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index cbd37fd3094..6b1c646bd23 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -158,6 +158,23 @@ load_lib gdb-utils.exp
>  load_lib memory.exp
>  load_lib check-test-names.exp
>  
> +# The path to the GCORE script to test.
> +global GCORE
> +if ![info exists GCORE] {

Please add {...} around the if expression:

  if {![info exists GCORE]} {

Thanks,
Andrew

> +    set GCORE [findfile $base_dir/../../gdb/gcore]
> +} else {
> +    set GCORE ""
> +}
> +verbose "using GCORE = $GCORE" 2
> +
> +proc has_gcore_script {} {
> +    if {[info exists ::GCORE]} {
> +	return 1
> +    } else {
> +	return 0
> +    }
> +}
> +
>  # The path to the GDB binary to test.
>  global GDB
>  
> -- 
> 2.44.0


^ permalink raw reply	[relevance 0%]

* [PATCH] Fix AIX thread exit events not being reported and UI to show  kernel thread ID.
@ 2024-04-29 11:46  9% Aditya Vidyadhar Kamath
  0 siblings, 0 replies; 200+ results
From: Aditya Vidyadhar Kamath @ 2024-04-29 11:46 UTC (permalink / raw)
  To: tom; +Cc: ulrich.weigand, gdb-patches, Aditya.Kamath1, sangamesh.swamy

From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>

In AIX when a thread exits we were not showing that a thread exit event happened
and GDB continued to keep the terminated threads.

If we have terminated threads then the UI on info threads command will look like
(gdb) info threads
  Id   Target Id                                          Frame
* 1    Thread 1 (tid 26607979, running)    0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
  2    Thread 258 (tid 30998799, finished) aix-thread: ptrace (52, 30998799) returned -1 (errno = 3 The process does not exist.)

If we see the frame is not getting displayed correctly.

The reason for the same is that in AIX we were not managing thread states. In particular we do not know
when a thread terminates.

The reason being in sync_threadlists () the pbuf and gbuf lists remain the same though certain threads exit.

This patch is a fix to the same.

Also certain UI is changed.

On a new thread born and exit the UI in AIX will be similar to Linux with both user and kernel thread information.

[New Thread 258 (tid 32178533)]
[New Thread 515 (tid 30343651)]
[New Thread 772 (tid 33554909)]
[New Thread 1029 (tid 24969489)]
[New Thread 1286 (tid 18153945)]
[New Thread 1543 (tid 30736739)]
[Thread 258 (tid 32178533) exited]
[Thread 515 (tid 30343651) exited]
[Thread 772 (tid 33554909) exited]
[Thread 1029 (tid 24969489) exited]
[Thread 1286 (tid 18153945) exited]
[Thread 1543 (tid 30736739) exited]

and info threads will look like
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 31326579) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
---
 gdb/aix-thread.c | 217 ++++++++++++-----------------------------------
 1 file changed, 52 insertions(+), 165 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index c70bd82bc24..73839243213 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -55,6 +55,7 @@
 #include <sys/reg.h>
 #include <sched.h>
 #include <sys/pthdebug.h>
+#include <unordered_set>
 
 #if !HAVE_DECL_GETTHRDS
 extern int getthrds (pid_t, struct thrdsinfo64 *, int, tid_t *, int);
@@ -190,6 +191,9 @@ struct aix_thread_variables
   /* Whether the current architecture is 64-bit.
    Only valid when pd_able is true.  */
   int arch64;
+
+  /* Describes the number of thread exit events reported.  */
+  std::unordered_set<pthdb_pthread_t> exited_threads;
 };
 
 /* Key to our per-inferior data.  */
@@ -737,47 +741,6 @@ state2str (pthdb_state_t state)
     }
 }
 
-/* qsort() comparison function for sorting pd_thread structs by pthid.  */
-
-static int
-pcmp (const void *p1v, const void *p2v)
-{
-  struct pd_thread *p1 = (struct pd_thread *) p1v;
-  struct pd_thread *p2 = (struct pd_thread *) p2v;
-  return p1->pthid < p2->pthid ? -1 : p1->pthid > p2->pthid;
-}
-
-/* ptid comparison function */
-
-static int
-ptid_cmp (ptid_t ptid1, ptid_t ptid2)
-{
-  if (ptid1.pid () < ptid2.pid ())
-    return -1;
-  else if (ptid1.pid () > ptid2.pid ())
-    return 1;
-  else if (ptid1.tid () < ptid2.tid ())
-    return -1;
-  else if (ptid1.tid () > ptid2.tid ())
-    return 1;
-  else if (ptid1.lwp () < ptid2.lwp ())
-    return -1;
-  else if (ptid1.lwp () > ptid2.lwp ())
-    return 1;
-  else
-    return 0;
-}
-
-/* qsort() comparison function for sorting thread_info structs by pid.  */
-
-static int
-gcmp (const void *t1v, const void *t2v)
-{
-  struct thread_info *t1 = *(struct thread_info **) t1v;
-  struct thread_info *t2 = *(struct thread_info **) t2v;
-  return ptid_cmp (t1->ptid, t2->ptid);
-}
-
 /* Search through the list of all kernel threads for the thread
    that has stopped on a SIGTRAP signal, and return its TID.
    Return 0 if none found.  */
@@ -822,22 +785,16 @@ static void
 sync_threadlists (pid_t pid)
 {
   int cmd, status;
-  int pcount, psize, pi, gcount, gi;
-  struct pd_thread *pbuf;
-  struct thread_info **gbuf, **g, *thread;
   pthdb_pthread_t pdtid;
   pthread_t pthid;
   pthdb_tid_t tid;
   process_stratum_target *proc_target = current_inferior ()->process_target ();
   struct aix_thread_variables *data;
   data = get_thread_data_helper_for_pid (pid);
+  pthdb_state_t state;
 
   /* Accumulate an array of libpthdebug threads sorted by pthread id.  */
 
-  pcount = 0;
-  psize = 1;
-  pbuf = XNEWVEC (struct pd_thread, psize);
-
   for (cmd = PTHDB_LIST_FIRST;; cmd = PTHDB_LIST_NEXT)
     {
       status = pthdb_pthread (data->pd_session, &pdtid, cmd);
@@ -848,118 +805,44 @@ sync_threadlists (pid_t pid)
       if (status != PTHDB_SUCCESS || pthid == PTHDB_INVALID_PTID)
 	continue;
 
-      if (pcount == psize)
+      ptid_t ptid (pid, 0, pthid);
+      status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+      if (state == PST_TERM)
 	{
-	  psize *= 2;
-	  pbuf = (struct pd_thread *) xrealloc (pbuf, 
-						psize * sizeof *pbuf);
+	  if (data->exited_threads.count (pdtid) != 0)
+	     continue;
 	}
-      pbuf[pcount].pdtid = pdtid;
-      pbuf[pcount].pthid = pthid;
-      pcount++;
-    }
-
-  for (pi = 0; pi < pcount; pi++)
-    {
-      status = pthdb_pthread_tid (data->pd_session, pbuf[pi].pdtid, &tid);
-      if (status != PTHDB_SUCCESS)
-	tid = PTHDB_INVALID_TID;
-      pbuf[pi].tid = tid;
-    }
-
-  qsort (pbuf, pcount, sizeof *pbuf, pcmp);
-
-  /* Accumulate an array of GDB threads sorted by pid.  */
-
-  /* gcount is GDB thread count and pcount is pthreadlib thread count.  */
-
-  gcount = 0;
-  for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))
-    gcount++;
-  g = gbuf = XNEWVEC (struct thread_info *, gcount);
-  for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))
-    *g++ = tp;
-  qsort (gbuf, gcount, sizeof *gbuf, gcmp);
 
-  /* Apply differences between the two arrays to GDB's thread list.  */
-
-  for (pi = gi = 0; pi < pcount || gi < gcount;)
-    {
-      if (pi == pcount)
-	{
-	  delete_thread (gbuf[gi]);
-	  gi++;
-	}
-      else if (gi == gcount)
+      /* If this thread has never been reported to GDB, add it.  */
+      if (!in_thread_list (proc_target, ptid))
 	{
 	  aix_thread_info *priv = new aix_thread_info;
-	  priv->pdtid = pbuf[pi].pdtid;
-	  priv->tid = pbuf[pi].tid;
-
-	  thread = add_thread_with_info (proc_target,
-					 ptid_t (pid, 0, pbuf[pi].pthid),
-					 private_thread_info_up (priv));
-
-	  pi++;
-	}
-      else
-	{
-	  ptid_t pptid, gptid;
-	  int cmp_result;
-
-	  pptid = ptid_t (pid, 0, pbuf[pi].pthid);
-	  gptid = gbuf[gi]->ptid;
-	  pdtid = pbuf[pi].pdtid;
-	  tid = pbuf[pi].tid;
-
-	  cmp_result = ptid_cmp (pptid, gptid);
-
-	  if (cmp_result == 0)
-	    {
-	      aix_thread_info *priv = get_aix_thread_info (gbuf[gi]);
-
-	      priv->pdtid = pdtid;
-	      priv->tid = tid;
-	      pi++;
-	      gi++;
-	    }
-	  else if (cmp_result > 0)
+	  /* init priv */
+	  priv->pdtid = pdtid;
+	  status = pthdb_pthread_tid (data->pd_session, pdtid, &tid);
+	  priv->tid = tid;
+	  /* Check if this is the main thread.  If it is, then change
+	     its ptid and add its private data.  */
+	  if (get_signaled_thread (pid) == tid
+		&& in_thread_list (proc_target, ptid_t (pid)))
 	    {
-	      /* This is to make the main process thread now look
-		 like a thread.  */
-
-	      if (gptid.is_pid ())
-		{
-		  thread_info *tp = proc_target->find_thread (gptid);
-		  thread_change_ptid (proc_target, gptid, pptid);
-		  aix_thread_info *priv = new aix_thread_info;
-		  priv->pdtid = pbuf[pi].pdtid;
-		  priv->tid = pbuf[pi].tid;
-		  tp->priv.reset (priv);
-		  gi++;
-		  pi++;
-		}
-	      else
-		{
-		  delete_thread (gbuf[gi]);
-		  gi++;
-		}
+	      thread_info *tp = proc_target->find_thread (ptid_t (pid));
+	      thread_change_ptid (proc_target, ptid_t (pid), ptid);
+	      tp->priv.reset (priv);
 	    }
 	  else
-	    {
-	      thread = add_thread (proc_target, pptid);
+	    add_thread_with_info (proc_target, ptid,
+		private_thread_info_up (priv));
+	}
 
-	      aix_thread_info *priv = new aix_thread_info;
-	      thread->priv.reset (priv);
-	      priv->pdtid = pdtid;
-	      priv->tid = tid;
-	      pi++;
-	    }
+      if (state == PST_TERM)
+	{
+	  thread_info *thr = proc_target->find_thread (ptid);
+	  gdb_assert (thr != nullptr);
+	  delete_thread (thr);
+	  data->exited_threads.insert (pdtid);
 	}
     }
-
-  xfree (pbuf);
-  xfree (gbuf);
 }
 
 /* Iterate_over_threads() callback for locating a thread, using
@@ -2084,10 +1967,17 @@ aix_thread_target::thread_alive (ptid_t ptid)
 std::string
 aix_thread_target::pid_to_str (ptid_t ptid)
 {
-  if (ptid.tid () == 0)
-    return beneath ()->pid_to_str (ptid);
+  thread_info *thread_info = current_inferior ()->find_thread (ptid);
+
+  if (thread_info != NULL && thread_info->priv != NULL)
+    {
+      aix_thread_info *priv = get_aix_thread_info (thread_info);
+
+      return string_printf (_("Thread %s (tid %s)"), pulongest (ptid.tid ()),
+		pulongest (priv->tid));
+    }
 
-  return string_printf (_("Thread %s"), pulongest (ptid.tid ()));
+  return beneath ()->pid_to_str (ptid);
 }
 
 /* Return a printable representation of extra information about
@@ -2098,7 +1988,6 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
 {
   int status;
   pthdb_pthread_t pdtid;
-  pthdb_tid_t tid;
   pthdb_state_t state;
   pthdb_suspendstate_t suspendstate;
   pthdb_detachstate_t detachstate;
@@ -2115,33 +2004,31 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
   aix_thread_info *priv = get_aix_thread_info (thread);
 
   pdtid = priv->pdtid;
-  tid = priv->tid;
-
-  if (tid != PTHDB_INVALID_TID)
-    /* i18n: Like "thread-identifier %d, [state] running, suspended" */
-    buf.printf (_("tid %d"), (int)tid);
 
   status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+
+  /* Output should look like Thread %d (tid %d) ([state]).  */
+  /* Example:- Thread 1 (tid 34144587) ([running]).  */
+  /* where state can be running, idle, sleeping, finished,
+     suspended, detached, cancel pending, ready or unknown.  */
+
   if (status != PTHDB_SUCCESS)
     state = PST_NOTSUP;
-  buf.printf (", %s", state2str (state));
+  buf.printf ("[%s]", state2str (state));
 
   status = pthdb_pthread_suspendstate (data->pd_session, pdtid,
 				       &suspendstate);
   if (status == PTHDB_SUCCESS && suspendstate == PSS_SUSPENDED)
-    /* i18n: Like "Thread-Id %d, [state] running, suspended" */
-    buf.printf (_(", suspended"));
+    buf.printf (_("[suspended]"));
 
   status = pthdb_pthread_detachstate (data->pd_session, pdtid,
 				      &detachstate);
   if (status == PTHDB_SUCCESS && detachstate == PDS_DETACHED)
-    /* i18n: Like "Thread-Id %d, [state] running, detached" */
-    buf.printf (_(", detached"));
+    buf.printf (_("[detached]"));
 
   pthdb_pthread_cancelpend (data->pd_session, pdtid, &cancelpend);
   if (status == PTHDB_SUCCESS && cancelpend)
-    /* i18n: Like "Thread-Id %d, [state] running, cancel pending" */
-    buf.printf (_(", cancel pending"));
+    buf.printf (_("[cancel pending]"));
 
   buf.write ("", 1);
 
-- 
2.41.0


^ permalink raw reply	[relevance 9%]

* Re: [PATCH] Allow calling of user-defined function call operators
  @ 2024-04-27 16:43  0%     ` Hannes Domani
  0 siblings, 0 replies; 200+ results
From: Hannes Domani @ 2024-04-27 16:43 UTC (permalink / raw)
  To: gdb-patches, Guinevere Larsen

 Am Donnerstag, 25. April 2024 um 20:34:19 MESZ hat Guinevere Larsen <blarsen@redhat.com> Folgendes geschrieben:

> On 4/21/24 09:49, Hannes Domani wrote:
> > Currently it's not possible to call user-defined function call
> > operators, at least not without specifying operator() directly:
> > ```
> > (gdb) l 1
> > 1      struct S {
> > 2        int operator() (int x) { return x + 5; }
> > 3      };
> > 4
> > 5      int main () {
> > 6        S s;
> > 7
> > 8        return s(23);
> > 9      }
> > (gdb) p s(10)
> > Invalid data type for function to be called.
> > (gdb) p s.operator()(10)
> > $1 = 15
> > ```
> >
> > This now looks if an user-defined call operator is available when
> > trying to 'call' a struct value, and calls it instead, making this
> > possible:
> > ```
> > (gdb) p s(10)
> > $1 = 15
> > ```
> >
> > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=12213
>
> Thanks for this fix, this has been a long time coming.
>
> I have one, possibly big, question.
>
> > ---
> >  gdb/eval.c                      | 46 +++++++++++++++++++++++++++-----
> >  gdb/testsuite/gdb.cp/userdef.cc  | 18 +++++++++++++
> >  gdb/testsuite/gdb.cp/userdef.exp |  4 +++
> >  3 files changed, 62 insertions(+), 6 deletions(-)
> >
> > diff --git a/gdb/eval.c b/gdb/eval.c
> > index 6b752e70635..e737774ca28 100644
> > --- a/gdb/eval.c
> > +++ b/gdb/eval.c
> > @@ -664,14 +664,34 @@ operation::evaluate_funcall (struct type *expect_type,
> >
> >    value *callee = evaluate_with_coercion (exp, noside);
> >    struct type *type = callee->type ();
> > -  if (type->code () == TYPE_CODE_PTR)
> > -    type = type->target_type ();
> > -  for (int i = 0; i < args.size (); ++i)
> > +
> > +  /* If the callee is a struct, there might be a user-defined function call
> > +    operator that should be used instead.  */
> > +  if (overload_resolution
> > +      && exp->language_defn->la_language == language_cplus
> > +      && check_typedef (type)->code () == TYPE_CODE_STRUCT)
> >      {
> > -      if (i < type->num_fields ())
> > -    vals[i] = args[i]->evaluate (type->field (i).type (), exp, noside);
> > -      else
> > +      for (int i = 0; i < args.size (); ++i)
> >      vals[i] = args[i]->evaluate_with_coercion (exp, noside);
> > +
> > +      vals.insert (vals.begin(), value_addr (callee));
> > +      int static_memfuncp;
> > +      find_overload_match (vals, "operator()", METHOD, &vals[0], nullptr,
> > +              &callee, nullptr, &static_memfuncp, 0, noside);
> > +      if (static_memfuncp)
> > +    vals.erase (vals.begin ());
> > +    }
> > +  else
> > +    {
> > +      if (type->code () == TYPE_CODE_PTR)
> > +    type = type->target_type ();
> > +      for (int i = 0; i < args.size (); ++i)
> > +    {
> > +      if (i < type->num_fields ())
> > +        vals[i] = args[i]->evaluate (type->field (i).type (), exp, noside);
> > +      else
> > +        vals[i] = args[i]->evaluate_with_coercion (exp, noside);
> > +    }
>
> This change had me confused for quite a bit. I couldn't figure out why
> the base operation::evaluate_funcall. The problem seems to be that if
> command used is something less straightforward, like "print (foo+bar)
> (args)", we will use the evaluate_funcall of the operation (in this
> case, add_operation) instead of var_value_operation's. Did I understand
> it correctly?
>
> Assuming I did, I don't think this code duplication is the best way to
> go. Especially seeing as there are some differences in those functions
> already, and if all that it takes to defeat out expression parser is use
> (*&foo) or (a + b) (), we probably already have latent bugs in this
> area. I don't know how to verify it, though, because I really don't
> understand the code differences.
>
> Ideally, I think the best way would be to put all the code in
> var_value_operation::evaluate_funcall, but to do this, you'd need to be
> able to find a way to call the resulting var_value_operation's function
> from all relevant operations, which is probably a lot.
>
> Another option is to just park all the logic in
> operation::evaluate_funcall, so we're always using the correct function.
> This comes with the cost of being very confusing in a couple of months
> to a year.
>
> Does this make sense?

Yes, it does.
And it turns out my patch already didn't work if you e.g. try to use the
operator() on struct members.

Not sure why I didn't see this before, but all evaluate_funcall variations
call evaluate_subexp_do_call at the end, so I just moved the logic there
in this v2: https://sourceware.org/pipermail/gdb-patches/2024-April/208663.html


Hannes

^ permalink raw reply	[relevance 0%]

* [PATCH] sim: riscv: Fix undefined behaviour in mulh and similar
@ 2024-04-26  7:50  7% Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-26  7:50 UTC (permalink / raw)
  To: gdb-patches

This fixes an undefined integer overflow bug in the mulh function,
which caused a test failure in the gcc test suite for riscv64 target:

FAIL: gcc.dg/ftrapv-3.c execution test

Fix that by casting to unsigned when an overflow is possible.

Also the __int128 multiplication in mulhu can overflow, and must be
done with unsigned __int128 to be safe.

And of course, the sign change in mulhsu can overflow too.

And also in execute_m there are a couple of possibly overflowing
multiplications in MULW, MULH and MULHSU.  The latter is probably
harmless, because the signed * unsigned type multiplication is done
in unsigned, but it is at least clearer what is intended, this way.
---
 sim/riscv/sim-main.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
index f6f6e2384e8..1815d7f2a6c 100644
--- a/sim/riscv/sim-main.c
+++ b/sim/riscv/sim-main.c
@@ -651,7 +651,7 @@ static uint64_t
 mulhu (uint64_t a, uint64_t b)
 {
 #ifdef HAVE___INT128
-  return ((__int128)a * b) >> 64;
+  return ((unsigned __int128)a * b) >> 64;
 #else
   uint64_t t;
   uint32_t y1, y2, y3;
@@ -677,16 +677,16 @@ static uint64_t
 mulh (int64_t a, int64_t b)
 {
   int negate = (a < 0) != (b < 0);
-  uint64_t res = mulhu (a < 0 ? -a : a, b < 0 ? -b : b);
-  return negate ? ~res + (a * b == 0) : res;
+  uint64_t res = mulhu (a < 0 ? -(uint64_t)a : a, b < 0 ? -(uint64_t)b : b);
+  return negate ? ~res + ((uint64_t)a * (uint64_t)b == 0) : res;
 }
 
 static uint64_t
 mulhsu (int64_t a, uint64_t b)
 {
   int negate = a < 0;
-  uint64_t res = mulhu (a < 0 ? -a : a, b);
-  return negate ? ~res + (a * b == 0) : res;
+  uint64_t res = mulhu (a < 0 ? -(uint64_t)a : a, b);
+  return negate ? ~res + ((uint64_t)a * b == 0) : res;
 }
 
 static sim_cia
@@ -757,16 +757,16 @@ execute_m (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
       TRACE_INSN (cpu, "mulw %s, %s, %s;  // %s = %s * %s",
 		  rd_name, rs1_name, rs2_name, rd_name, rs1_name, rs2_name);
       RISCV_ASSERT_RV64 (cpu, "insn: %s", op->name);
-      store_rd (cpu, rd, EXTEND32 ((int32_t) riscv_cpu->regs[rs1]
-				   * (int32_t) riscv_cpu->regs[rs2]));
+      store_rd (cpu, rd, EXTEND32 ((uint32_t) riscv_cpu->regs[rs1]
+				   * (uint32_t) riscv_cpu->regs[rs2]));
       break;
     case MATCH_MULH:
       TRACE_INSN (cpu, "mulh %s, %s, %s;  // %s = %s * %s",
 		  rd_name, rs1_name, rs2_name, rd_name, rs1_name, rs2_name);
       if (RISCV_XLEN (cpu) == 32)
 	store_rd (cpu, rd,
-		  ((int64_t)(signed_word) riscv_cpu->regs[rs1]
-		   * (int64_t)(signed_word) riscv_cpu->regs[rs2]) >> 32);
+		  ((uint64_t)(signed_word) riscv_cpu->regs[rs1]
+		   * (uint64_t)(signed_word) riscv_cpu->regs[rs2]) >> 32);
       else
 	store_rd (cpu, rd, mulh (riscv_cpu->regs[rs1], riscv_cpu->regs[rs2]));
       break;
@@ -783,7 +783,7 @@ execute_m (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
       TRACE_INSN (cpu, "mulhsu %s, %s, %s;  // %s = %s * %s",
 		  rd_name, rs1_name, rs2_name, rd_name, rs1_name, rs2_name);
       if (RISCV_XLEN (cpu) == 32)
-	store_rd (cpu, rd, ((int64_t)(signed_word) riscv_cpu->regs[rs1]
+	store_rd (cpu, rd, ((uint64_t)(signed_word) riscv_cpu->regs[rs1]
 			    * (uint64_t)riscv_cpu->regs[rs2]) >> 32);
       else
 	store_rd (cpu, rd, mulhsu (riscv_cpu->regs[rs1], riscv_cpu->regs[rs2]));
-- 
2.39.2


^ permalink raw reply	[relevance 7%]

* [PATCH v3] sim: riscv: Fix some issues with class-a instructions
@ 2024-04-26  7:49  6% Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-26  7:49 UTC (permalink / raw)
  To: gdb-patches

This fixes some issues with atomic instruction handling.  First the
instructions may have AQ and/or RL bits set, but the emulator has no
such concept, so we have to ignore those.

According to the spec the memory must be naturally aligned, otherwise
an exception shall be thrown, so do the sim_core read/write aligned.
In the case of riscv64 target, there were the LR_D and SC_D
64bit load and store instructions missing, so add those.
Additionally the LR_W instruction was missing the sign extension.

Also the AMOMIN/AMOMAX[U]_W instructions were not correct for riscv64
because the upper half word of the input registers were not ignored
as they should, so use explicit type-casts to uint32_t and int32_t
for those.

Furthermore the read value was written directly to the rd register,
but that can overwrite the value in rs1 or rs2.  In that case the
previous value must be still available and used instead.

And finally make the class-a instruction set only executable if a
riscv cpu model with A extension is selected.
---
 sim/riscv/sim-main.c | 84 ++++++++++++++++++++++++++++++--------------
 1 file changed, 57 insertions(+), 27 deletions(-)

v2: use sim_core_read/write_unaligned, but override current_alignment,
to raise an exception when the address is not aligned.

v3: fix an issue with instructions where the output value overwrites
the input register when both are the same register.  Typically
seen with instructions like amoswap.w a0, a0, (a1)
 
diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
index e4b15b533ba..f6f6e2384e8 100644
--- a/sim/riscv/sim-main.c
+++ b/sim/riscv/sim-main.c
@@ -841,6 +841,9 @@ execute_m (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
 static sim_cia
 execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
 {
+  unsigned_word mask_aq = OP_MASK_AQ << OP_SH_AQ;
+  unsigned_word mask_rl = OP_MASK_RL << OP_SH_RL;
+  unsigned_word mask_aqrl = mask_aq | mask_rl;
   struct riscv_sim_cpu *riscv_cpu = RISCV_SIM_CPU (cpu);
   SIM_DESC sd = CPU_STATE (cpu);
   struct riscv_sim_state *state = RISCV_SIM_STATE (sd);
@@ -851,17 +854,25 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
   const char *rs1_name = riscv_gpr_names_abi[rs1];
   const char *rs2_name = riscv_gpr_names_abi[rs2];
   struct atomic_mem_reserved_list *amo_prev, *amo_curr;
-  unsigned_word tmp;
+  unsigned_word tmp, res;
   sim_cia pc = riscv_cpu->pc + 4;
+  int prev_alignment = current_alignment;
+
+  if (current_alignment != FORCED_ALIGNMENT)
+    current_alignment = STRICT_ALIGNMENT;
 
   /* Handle these two load/store operations specifically.  */
-  switch (op->match)
+  switch (op->match & ~mask_aqrl)
     {
+    case MATCH_LR_D:
     case MATCH_LR_W:
       TRACE_INSN (cpu, "%s %s, (%s);", op->name, rd_name, rs1_name);
-      store_rd (cpu, rd,
-	sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map,
-				   riscv_cpu->regs[rs1]));
+      if (op->xlen_requirement == 64)
+	res = sim_core_read_unaligned_8 (cpu, riscv_cpu->pc, read_map,
+					 riscv_cpu->regs[rs1]);
+      else
+	res = EXTEND32 (sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map,
+						   riscv_cpu->regs[rs1]));
 
       /* Walk the reservation list to find an existing match.  */
       amo_curr = state->amo_reserved_list;
@@ -878,6 +889,7 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
       amo_curr->next = state->amo_reserved_list;
       state->amo_reserved_list = amo_curr;
       goto done;
+    case MATCH_SC_D:
     case MATCH_SC_W:
       TRACE_INSN (cpu, "%s %s, %s, (%s);", op->name, rd_name, rs2_name,
 		  rs1_name);
@@ -889,15 +901,20 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
 	  if (amo_curr->addr == riscv_cpu->regs[rs1])
 	    {
 	      /* We found a reservation, so operate it.  */
-	      sim_core_write_unaligned_4 (cpu, riscv_cpu->pc, write_map,
-					  riscv_cpu->regs[rs1],
-					  riscv_cpu->regs[rs2]);
-	      store_rd (cpu, rd, 0);
+	      if (op->xlen_requirement == 64)
+		sim_core_write_unaligned_8 (cpu, riscv_cpu->pc, write_map,
+					    riscv_cpu->regs[rs1],
+					    riscv_cpu->regs[rs2]);
+	      else
+		sim_core_write_unaligned_4 (cpu, riscv_cpu->pc, write_map,
+					    riscv_cpu->regs[rs1],
+					    riscv_cpu->regs[rs2]);
 	      if (amo_curr == state->amo_reserved_list)
 		state->amo_reserved_list = amo_curr->next;
 	      else
 		amo_prev->next = amo_curr->next;
 	      free (amo_curr);
+	      res = 0;
 	      goto done;
 	    }
 	  amo_prev = amo_curr;
@@ -905,7 +922,7 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
 	}
 
       /* If we're still here, then no reservation exists, so mark as failed.  */
-      store_rd (cpu, rd, 1);
+      res = 1;
       goto done;
     }
 
@@ -913,46 +930,49 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
   TRACE_INSN (cpu, "%s %s, %s, (%s);",
 	      op->name, rd_name, rs2_name, rs1_name);
   if (op->xlen_requirement == 64)
-    tmp = sim_core_read_unaligned_8 (cpu, riscv_cpu->pc, read_map,
+    res = sim_core_read_unaligned_8 (cpu, riscv_cpu->pc, read_map,
 				     riscv_cpu->regs[rs1]);
   else
-    tmp = EXTEND32 (sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map,
+    res = EXTEND32 (sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map,
 					       riscv_cpu->regs[rs1]));
-  store_rd (cpu, rd, tmp);
 
-  switch (op->match)
+  switch (op->match & ~mask_aqrl)
     {
     case MATCH_AMOADD_D:
     case MATCH_AMOADD_W:
-      tmp = riscv_cpu->regs[rd] + riscv_cpu->regs[rs2];
+      tmp = res + riscv_cpu->regs[rs2];
       break;
     case MATCH_AMOAND_D:
     case MATCH_AMOAND_W:
-      tmp = riscv_cpu->regs[rd] & riscv_cpu->regs[rs2];
+      tmp = res & riscv_cpu->regs[rs2];
       break;
     case MATCH_AMOMAX_D:
+      tmp = max ((signed_word) res, (signed_word) riscv_cpu->regs[rs2]);
+      break;
     case MATCH_AMOMAX_W:
-      tmp = max ((signed_word) riscv_cpu->regs[rd],
-		 (signed_word) riscv_cpu->regs[rs2]);
+      tmp = max ((int32_t) res, (int32_t) riscv_cpu->regs[rs2]);
       break;
     case MATCH_AMOMAXU_D:
+      tmp = max ((unsigned_word) res, (unsigned_word) riscv_cpu->regs[rs2]);
+      break;
     case MATCH_AMOMAXU_W:
-      tmp = max ((unsigned_word) riscv_cpu->regs[rd],
-		 (unsigned_word) riscv_cpu->regs[rs2]);
+      tmp = max ((uint32_t) res, (uint32_t) riscv_cpu->regs[rs2]);
       break;
     case MATCH_AMOMIN_D:
+      tmp = min ((signed_word) res, (signed_word) riscv_cpu->regs[rs2]);
+      break;
     case MATCH_AMOMIN_W:
-      tmp = min ((signed_word) riscv_cpu->regs[rd],
-		 (signed_word) riscv_cpu->regs[rs2]);
+      tmp = min ((int32_t) res, (int32_t) riscv_cpu->regs[rs2]);
       break;
     case MATCH_AMOMINU_D:
+      tmp = min ((unsigned_word) res, (unsigned_word) riscv_cpu->regs[rs2]);
+      break;
     case MATCH_AMOMINU_W:
-      tmp = min ((unsigned_word) riscv_cpu->regs[rd],
-		 (unsigned_word) riscv_cpu->regs[rs2]);
+      tmp = min ((uint32_t) res, (uint32_t) riscv_cpu->regs[rs2]);
       break;
     case MATCH_AMOOR_D:
     case MATCH_AMOOR_W:
-      tmp = riscv_cpu->regs[rd] | riscv_cpu->regs[rs2];
+      tmp = res | riscv_cpu->regs[rs2];
       break;
     case MATCH_AMOSWAP_D:
     case MATCH_AMOSWAP_W:
@@ -960,7 +980,7 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
       break;
     case MATCH_AMOXOR_D:
     case MATCH_AMOXOR_W:
-      tmp = riscv_cpu->regs[rd] ^ riscv_cpu->regs[rs2];
+      tmp = res ^ riscv_cpu->regs[rs2];
       break;
     default:
       TRACE_INSN (cpu, "UNHANDLED INSN: %s", op->name);
@@ -975,6 +995,8 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
 				riscv_cpu->regs[rs1], tmp);
 
  done:
+  store_rd (cpu, rd, res);
+  current_alignment = prev_alignment;
   return pc;
 }
 
@@ -1307,7 +1329,15 @@ execute_one (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
   switch (op->insn_class)
     {
     case INSN_CLASS_A:
-      return execute_a (cpu, iw, op);
+      /* Check whether model with A extension is selected.  */
+      if (riscv_cpu->csr.misa & 1)
+	return execute_a (cpu, iw, op);
+      else
+	{
+	  TRACE_INSN (cpu, "UNHANDLED EXTENSION: %d", op->insn_class);
+	  sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc, sim_signalled,
+			   SIM_SIGILL);
+	}
     case INSN_CLASS_C:
       /* Check whether model with C extension is selected.  */
       if (riscv_cpu->csr.misa & 4)
-- 
2.39.2


^ permalink raw reply	[relevance 6%]

* [PATCH v4] gdb/testsuite: Add gdb.base/memops-watchpoint.exp
@ 2024-04-26  1:46  5% Thiago Jung Bauermann
  0 siblings, 0 replies; 200+ results
From: Thiago Jung Bauermann @ 2024-04-26  1:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner, Luis Machado

Test behaviour of watchpoints triggered by libc's memset/memcpy/memmove.
These functions are frequently optimized with specialized instructions
that favor larger memory access operations, so make sure GDB behaves
correctly in their presence.

There's a separate watched variable for each function so that the testcase
can test whether GDB correctly identified the watchpoint that triggered.

Also, the watchpoint is 28 bytes away from the beginning of the buffer
being modified, so that large memory accesses (if present) are exercised.

PR testsuite/31484
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31484
---

Changes in v4:
- Also accept memmove symbol for memcpy watchpoint test (Suggested by Kevin).

Changes in v3:
- Reworked "continue until memset/memcpy/memmove watchpoint hits" tests to
  have a chance to work even without libc debug info (Suggested by Kevin).
- Dropped "require libc6_has_debug_info" call (Suggested by Kevin).

Changes in v2:
- Ensure watchpoints are aligned to 4 bytes.
- Add kfail for arm-linux.

 gdb/testsuite/gdb.base/memops-watchpoint.c   |  45 ++++++
 gdb/testsuite/gdb.base/memops-watchpoint.exp | 161 +++++++++++++++++++
 2 files changed, 206 insertions(+)
 create mode 100644 gdb/testsuite/gdb.base/memops-watchpoint.c
 create mode 100644 gdb/testsuite/gdb.base/memops-watchpoint.exp

diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.c b/gdb/testsuite/gdb.base/memops-watchpoint.c
new file mode 100644
index 000000000000..0255cfb43404
--- /dev/null
+++ b/gdb/testsuite/gdb.base/memops-watchpoint.c
@@ -0,0 +1,45 @@
+/* This test program is part of GDB, the GNU debugger.
+
+   Copyright 2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  /* Some targets need 4-byte alignment for hardware watchpoints.  */
+  char s[40] __attribute__ ((aligned (4)))
+    = "This is a relatively long string...";
+  char a[40] __attribute__ ((aligned (4)))
+    = "String to be overwritten with zeroes";
+  char b[40] __attribute__ ((aligned (4)))
+    = "Another string to be memcopied...";
+  char c[40] __attribute__ ((aligned (4)))
+    = "Another string to be memmoved...";
+
+  /* Break here.  */
+  memset (a, 0, sizeof (a));
+
+  memcpy (b, s, sizeof (b));
+
+  memmove (c, s, sizeof (c));
+
+  printf ("b = '%s'\n", b);
+  printf ("c = '%s'\n", c);
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.exp b/gdb/testsuite/gdb.base/memops-watchpoint.exp
new file mode 100644
index 000000000000..cee2d799c67a
--- /dev/null
+++ b/gdb/testsuite/gdb.base/memops-watchpoint.exp
@@ -0,0 +1,161 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test a binary that uses standard libc memory operation functions.  They are
+# frequently optimized with specialized instructions, so make sure GDB behaves
+# correctly in their presence.
+
+standard_testfile
+set options "-fno-builtin-memset -fno-builtin-memcpy -fno-builtin-memmove"
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+	  [list debug additional_flags=$options]] } {
+    return -1
+}
+
+set linespec ${srcfile}:[gdb_get_line_number "Break here"]
+if ![runto ${linespec}] {
+    return -1
+}
+
+gdb_test "watch -location a\[28\]" \
+    "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \
+    "set watch on a"
+gdb_test "watch -location b\[28\]" \
+    "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
+    "set watchpoint on b"
+gdb_test "watch -location c\[28\]" \
+    "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \
+    "set watchpoint on c"
+
+# For the tests below, split the pattern matching in two parts: one for the
+# watchpoint trigger, and another for the line showing the function name.
+# This is to allow the tests to work if there's a properly named symbol for
+# the function, even if there's no libc debug info.
+
+set saw_watch_trigger 0
+set saw_function 0
+set is_supported 1
+set message "continue until memset watchpoint hits"
+set watch_trigger \
+	[multi_line \
+	     "Continuing\\." \
+	     "" \
+	     "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \
+	     "" \
+	     "Old value = 104 'h'" \
+	     "New value = 0 '\\\\000'"]
+gdb_test_multiple "continue" $message {
+    -re $watch_trigger {
+	set saw_watch_trigger 1
+	exp_continue
+    }
+    -re ".*memset.* \\(\\) at .*:$decimal\r\n" {
+	set saw_function 1
+	exp_continue
+    }
+    -re ".*memset.* \\(\\) from .*libc\[^\r\n\]+\r\n" {
+	set saw_function 1
+	exp_continue
+    }
+    -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
+	set is_supported 0
+	unsupported "symbol for memset not found"
+	exp_continue
+    }
+    -re "$gdb_prompt $" {
+	if { $is_supported } {
+	    setup_kfail breakpoints/31665 arm*-*-linux*
+	    gdb_assert { $saw_watch_trigger && $saw_function } $message
+	}
+    }
+}
+
+# Note: Some architectures use memmove for memcpy.
+set saw_watch_trigger 0
+set saw_function 0
+set is_supported 1
+set message "continue until memcpy watchpoint hits"
+set watch_trigger \
+	[multi_line \
+	     "Continuing\\." \
+	     "" \
+	     "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
+	     "" \
+	     "Old value = 101 'e'" \
+	     "New value = 114 'r'"]
+gdb_test_multiple "continue" $message {
+    -re $watch_trigger {
+	set saw_watch_trigger 1
+	exp_continue
+    }
+    -re ".*(memcpy|memmove).* \\(\\) at .*:$decimal\r\n" {
+	set saw_function 1
+	exp_continue
+    }
+    -re ".*(memcpy|memmove).* \\(\\) from .*libc\[^\r\n\]+\r\n" {
+	set saw_function 1
+	exp_continue
+    }
+    -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
+	set is_supported 0
+	unsupported "symbol for memcpy not found"
+	exp_continue
+    }
+    -re "$gdb_prompt $" {
+	if { $is_supported } {
+	    setup_kfail breakpoints/31665 arm*-*-linux*
+	    gdb_assert { $saw_watch_trigger && $saw_function } $message
+	}
+    }
+}
+
+# Note: Some architectures use memcpy for memmove.
+set saw_watch_trigger 0
+set saw_function 0
+set is_supported 1
+set message "continue until memmove watchpoint hits"
+set watch_trigger \
+	[multi_line \
+	     "Continuing\\." \
+	     "" \
+	     "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \
+	     "" \
+	     "Old value = 100 'd'" \
+	     "New value = 114 'r'"]
+gdb_test_multiple "continue" $message {
+    -re $watch_trigger {
+	set saw_watch_trigger 1
+	exp_continue
+    }
+    -re ".*(memcpy|memmove).* \\(\\) at .*:$decimal\r\n" {
+	set saw_function 1
+	exp_continue
+    }
+    -re ".*(memcpy|memmove).* \\(\\) from .*libc\[^\r\n\]+\r\n" {
+	set saw_function 1
+	exp_continue
+    }
+    -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
+	set is_supported 0
+	unsupported "symbol for memmove not found"
+	exp_continue
+    }
+    -re "$gdb_prompt $" {
+	if { $is_supported } {
+	    setup_kfail breakpoints/31665 arm*-*-linux*
+	    gdb_assert { $saw_watch_trigger && $saw_function } $message
+	}
+    }
+}

base-commit: d3c2603167baf9f6fea006f8b747b8186f89b177

^ permalink raw reply	[relevance 5%]

* Re: [PATCH v3 2/2] gdb/testsuite: Add gdb.base/memops-watchpoint.exp
  @ 2024-04-26  1:42  0%         ` Thiago Jung Bauermann
  0 siblings, 0 replies; 200+ results
From: Thiago Jung Bauermann @ 2024-04-26  1:42 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches, Luis Machado

Kevin Buettner <kevinb@redhat.com> writes:

> On Wed, 24 Apr 2024 14:05:31 -0300
> Thiago Jung Bauermann <thiago.bauermann@linaro.org> wrote:
>
>> > I also have Fedora 39 (Asahi Remix) running on an M1 macbook.  When
>> > I try this test on that machine, I see some timeouts...
>> >
>> >     (gdb) watch -location a[28]
>> >     Hardware watchpoint 2: -location a[28]
>> >     (gdb) PASS: gdb.base/memops-watchpoint.exp: set watch on a
>> >     watch -location b[28]
>> >     Hardware watchpoint 3: -location b[28]
>> >     (gdb) PASS: gdb.base/memops-watchpoint.exp: set watchpoint on b
>> >     watch -location c[28]
>> >     Hardware watchpoint 4: -location c[28]
>> >     (gdb) PASS: gdb.base/memops-watchpoint.exp: set watchpoint on c
>> >     continue
>> >     Continuing.
>> >
>> >     Hardware watchpoint 2: -location a[28]
>> >
>> >     Old value = 104 'h'
>> >     New value = 0 '\000'
>> >     __GI___memset_generic () at ../sysdeps/aarch64/memset.S:67
>> >     67		tbz	count, 5, 1f
>> >     (gdb) PASS: gdb.base/memops-watchpoint.exp: continue until memset watchpoint hits
>> >     continue
>> >     Continuing.
>> >     FAIL: gdb.base/memops-watchpoint.exp: continue until memcpy watchpoint hits (timeout)
>> >     continue
>> >     FAIL: gdb.base/memops-watchpoint.exp: continue until memmove watchpoint hits (timeout)
>> >     testcase /ironwood1/sourceware-git/macbook-review/bld/../../worktree-review/gdb/testsuite/gdb.base/memops-watchpoint.exp completed in 20 seconds
>> >
>> > 		    === gdb Summary ===
>> >
>> >     # of expected passes		4
>> >     # of unexpected failures	2
>> >
>> > Is this demonstrating the bug (31484) ?  
>> 
>> Hm. Probably. I haven't seen this behaviour in my tests. It's hard to
>> say why GDB hung. Can you try to "set debug infrun on" at that point?
>
> I tried running the test again on my macbook and can no longer
> reproduce that failure.  I'm seeing 6 passes now.  (No reboots or
> updates either. uptime shows that it's been up for 111 days.)

Ah, interesting. I think it's unlikely to be an issue related to this
testcase then. I expect problems with watchpoints triggering with
memset/memcpy/memmove to be deterministic. E.g., the kernel doesn't
report a close enough data address because the hand-optimized memcpy
used some very specialized instruction with a very wide data access
range, and thus GDB doesn't recognize why the SIGTRAP happened.

As an example, this test did uncover a problem in arm-linux-gnueabihf,
and it manifested as the watchpoints triggering when the inferior
program is exiting:

continue
Continuing.
b = 'This is a relatively long string...'
c = 'This is a relatively long string...'

Hardware watchpoint 2: -location a[28]

Old value = 104 'h'
New value = 128 '\200'
0xf7fc27de in _dl_fini () at dl-fini.c:51
warning: 51	dl-fini.c: No such file or directory
(gdb) KFAIL: gdb.base/memops-watchpoint.exp: continue until memset watchpoint hits (PRMS: breakpoints/31665)

-- 
Thiago

^ permalink raw reply	[relevance 0%]

* [PATCH 3/3] Add symbol, line, and location to DAP disassemble result
  @ 2024-04-25 18:09  5% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-25 18:09 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The DAP spec allows a number of attributes on the resulting
instructions that gdb currently does not emit.  A user requested some
of these, so this patch adds the 'symbol', 'line', and 'location'
attributes.  While the spec lets the implementation omit 'location' in
some cases, it was simpler in the code to just always emit it, as then
no extra tracking was needed.
---
 gdb/python/lib/gdb/dap/disassemble.py |  64 ++++++++++++++--
 gdb/testsuite/gdb.dap/disassem.c      |  52 +++++++++++++
 gdb/testsuite/gdb.dap/disassem.exp    | 105 ++++++++++++++++++++++++++
 3 files changed, 214 insertions(+), 7 deletions(-)
 create mode 100644 gdb/testsuite/gdb.dap/disassem.c
 create mode 100644 gdb/testsuite/gdb.dap/disassem.exp

diff --git a/gdb/python/lib/gdb/dap/disassemble.py b/gdb/python/lib/gdb/dap/disassemble.py
index 65bf3d4457b..035bc3f9356 100644
--- a/gdb/python/lib/gdb/dap/disassemble.py
+++ b/gdb/python/lib/gdb/dap/disassemble.py
@@ -16,6 +16,55 @@
 import gdb
 
 from .server import capability, request
+from .sources import make_source
+
+
+# This tracks labels associated with a disassembly request and helps
+# with updating individual instructions.
+class _BlockTracker:
+    def __init__(self):
+        # Map from PC to symbol names.  A given PC is assumed to have
+        # just one label -- DAP wouldn't let us return multiple labels
+        # anyway.
+        self.labels = {}
+        # List of blocks that have already been handled.  Note that
+        # blocks aren't hashable so a set is not used.
+        self.blocks = []
+
+    # Add a gdb.Block and its superblocks, stopping before the static
+    # block.
+    def add_block(self, block):
+        if block in self.blocks:
+            return
+        self.blocks.append(block)
+        if block.function is not None:
+            self.labels[block.start] = block.function.name
+        for sym in block:
+            if sym.addr_class == gdb.SYMBOL_LOC_LABEL:
+                self.labels[int(sym.value())] = sym.name
+        sblock = block.superblock
+        if not sblock.is_static:
+            self.add_block(sblock)
+
+    # Add PC to this tracker.  Update RESULT as appropriate with
+    # information about the source and any label.
+    def add_pc(self, pc, result):
+        block = gdb.block_for_pc(pc)
+        if block is None:
+            # Nothing to do.
+            return
+        self.add_block(block)
+        if pc in self.labels:
+            result["symbol"] = self.labels[pc]
+        sal = gdb.find_pc_line(pc)
+        if sal.symtab is not None:
+            if sal.line != 0:
+                result["line"] = str(sal.line)
+            if sal.symtab.filename is not None:
+                # The spec says this can be omitted in some
+                # situations, but it's a little simpler to just always
+                # supply it.
+                result["location"] = make_source(sal.symtab.filename)
 
 
 @request("disassemble")
@@ -35,17 +84,18 @@ def disassemble(
     except gdb.error:
         # Maybe there was no frame.
         arch = inf.architecture()
+    tracker = _BlockTracker()
     result = []
     total_count = instructionOffset + instructionCount
     for elt in arch.disassemble(pc, count=total_count)[instructionOffset:]:
         mem = inf.read_memory(elt["addr"], elt["length"])
-        result.append(
-            {
-                "address": hex(elt["addr"]),
-                "instruction": elt["asm"],
-                "instructionBytes": mem.hex(),
-            }
-        )
+        insn = {
+            "address": hex(elt["addr"]),
+            "instruction": elt["asm"],
+            "instructionBytes": mem.hex(),
+        }
+        tracker.add_pc(elt["addr"], insn)
+        result.append(insn)
     return {
         "instructions": result,
     }
diff --git a/gdb/testsuite/gdb.dap/disassem.c b/gdb/testsuite/gdb.dap/disassem.c
new file mode 100644
index 00000000000..c0f5128c97d
--- /dev/null
+++ b/gdb/testsuite/gdb.dap/disassem.c
@@ -0,0 +1,52 @@
+/* Copyright 2024 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+__attribute__((__noinline__)) static int
+callee (int x)
+{
+  return x * 2;
+}
+
+static inline int __attribute__((__always_inline__))
+compute (int x)
+{
+  return callee (x);
+}
+
+static int
+return_value (int x)
+{
+  int accum = 0;
+
+  for (int i = 0; i < x; ++i)
+    {
+      int value = compute (i);
+      if (value < 0)
+	goto out_label;
+    }
+
+ out_label:
+
+  return accum;
+}
+
+int
+main ()
+{
+  int value = return_value (23);
+  return value > 0 ? 0 : 1;
+}
diff --git a/gdb/testsuite/gdb.dap/disassem.exp b/gdb/testsuite/gdb.dap/disassem.exp
new file mode 100644
index 00000000000..87fb516931a
--- /dev/null
+++ b/gdb/testsuite/gdb.dap/disassem.exp
@@ -0,0 +1,105 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test DAP disassembly.
+
+require allow_dap_tests
+
+load_lib dap-support.exp
+
+standard_testfile
+
+if {[build_executable ${testfile}.exp $testfile] == -1} {
+    return
+}
+
+if {[dap_initialize] == ""} {
+    return
+}
+
+set obj [dap_check_request_and_response "set breakpoint" \
+	     setFunctionBreakpoints \
+	     {o breakpoints [a [o name [s main]]]}]
+set fn_bpno [dap_get_breakpoint_number $obj]
+
+dap_check_request_and_response "configurationDone" configurationDone
+
+if {[dap_launch $testfile] == ""} {
+    return
+}
+dap_wait_for_event_and_check "inferior started" thread "body reason" started
+
+dap_wait_for_event_and_check "stopped at line breakpoint" stopped \
+    "body reason" breakpoint \
+    "body hitBreakpointIds" $fn_bpno
+
+# Find out how many lines of disassembly we should request.  This is
+# kind of lame but DAP doesn't really provide tools to do this, and
+# gdb's DAP implementation doesn't try to figure out what memory might
+# not really be part of a function.
+set obj [dap_check_request_and_response "disassemble using CLI" \
+	     evaluate {o expression [s {disassemble &return_value}] \
+			   context [s repl]}]
+set output [dict get [lindex $obj 0] body result]
+# The result will have literal "\" "n" sequences, turn these into
+# newlines.
+set with_nl [string map [list "\\n" "\n"] $output]
+# The value we want is the number of lines starting with an address.
+set insn_count 0
+foreach line [split $with_nl "\n"] {
+    if {[regexp "^ *0x" $line]} {
+	incr insn_count
+    }
+}
+
+set obj [dap_check_request_and_response "find function address" \
+	     evaluate {o expression [s "&return_value"]}]
+set pc [dict get [lindex $obj 0] body memoryReference]
+
+set obj [dap_check_request_and_response "disassemble the function" \
+	     disassemble \
+	     [format {o memoryReference [s %s] instructionCount [i %d]} \
+		  $pc $insn_count]]
+set response [lindex $obj 0]
+
+set seen_labels(_) _
+set insn_no 1
+foreach insn [dict get $response body instructions] {
+    with_test_prefix $insn_no {
+	gdb_assert {[dict exists $insn line]} \
+	    "line in disassemble output"
+	gdb_assert {[dict exists $insn location]} \
+	    "location in disassemble output"
+	if {[dict exists $insn symbol]} {
+	    set seen_labels([dict get $insn symbol]) 1
+	}
+    }
+    incr insn_no
+}
+
+proc require_label {name} {
+    global seen_labels
+    if {[info exists seen_labels($name)]} {
+	pass "saw label $name"
+    } else {
+	fail "saw label $name"
+    }
+}
+
+require_label return_value
+require_label compute
+require_label out_label
+
+dap_shutdown
-- 
2.44.0


^ permalink raw reply	[relevance 5%]

* Re: [PATCH v2] sim: riscv: Fix some issues with class-a instructions
  @ 2024-04-25 13:15  0% ` Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-25 13:15 UTC (permalink / raw)
  To: gdb-patches, Andrew Burgess

On 4/23/24 16:30, Bernd Edlinger wrote:
> This fixes some issues with atomic instruction handling.  First the
> instructions may have AQ and/or RL bits set, but the emulator has no
> such concept, so we have to ignore those.
> 
> According to the spec the memory must be naturally aligned, otherwise
> an exception shall be thrown, so do the sim_core read/write aligned.
> In the case of riscv64 target, there were the LR_D and SC_D
> 64bit load and store instructions missing, so add those.
> 
> Also the AMOMIN/AMOMAX[U]_W instructions were not correct for riscv64
> because the upper half word of the input registers were not ignored
> as they should, so use explicit type-casts to uint32_t and int32_t
> for those.
> 
> And finally make the class-a instruction set only executable if a
> riscv cpu model with A extension is selected.
> ---
>  sim/riscv/sim-main.c | 65 +++++++++++++++++++++++++++++++++++---------
>  1 file changed, 52 insertions(+), 13 deletions(-)
> 
> v2: use sim_core_read/write_unaligned, but override current_alignment,
> to raise an exception when the address is not aligned.
> 
> diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
> index e4b15b533ba..0c05b79dea4 100644
> --- a/sim/riscv/sim-main.c
> +++ b/sim/riscv/sim-main.c
> @@ -841,6 +841,9 @@ execute_m (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>  static sim_cia
>  execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>  {
> +  unsigned_word mask_aq = OP_MASK_AQ << OP_SH_AQ;
> +  unsigned_word mask_rl = OP_MASK_RL << OP_SH_RL;
> +  unsigned_word mask_aqrl = mask_aq | mask_rl;
>    struct riscv_sim_cpu *riscv_cpu = RISCV_SIM_CPU (cpu);
>    SIM_DESC sd = CPU_STATE (cpu);
>    struct riscv_sim_state *state = RISCV_SIM_STATE (sd);
> @@ -853,15 +856,24 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>    struct atomic_mem_reserved_list *amo_prev, *amo_curr;
>    unsigned_word tmp;
>    sim_cia pc = riscv_cpu->pc + 4;
> +  int prev_alignment = current_alignment;
> +
> +  if (current_alignment != FORCED_ALIGNMENT)
> +    current_alignment = STRICT_ALIGNMENT;
>  
>    /* Handle these two load/store operations specifically.  */
> -  switch (op->match)
> +  switch (op->match & ~mask_aqrl)
>      {
> +    case MATCH_LR_D:
>      case MATCH_LR_W:
>        TRACE_INSN (cpu, "%s %s, (%s);", op->name, rd_name, rs1_name);
> -      store_rd (cpu, rd,
> -	sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map,
> -				   riscv_cpu->regs[rs1]));
> +      if (op->xlen_requirement == 64)
> +	tmp = sim_core_read_unaligned_8 (cpu, riscv_cpu->pc, read_map,
> +					 riscv_cpu->regs[rs1]);
> +      else
> +	tmp = EXTEND32 (sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map,
> +						   riscv_cpu->regs[rs1]));
> +      store_rd (cpu, rd, tmp);
>  
>        /* Walk the reservation list to find an existing match.  */
>        amo_curr = state->amo_reserved_list;
> @@ -878,6 +890,7 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>        amo_curr->next = state->amo_reserved_list;
>        state->amo_reserved_list = amo_curr;
>        goto done;
> +    case MATCH_SC_D:
>      case MATCH_SC_W:
>        TRACE_INSN (cpu, "%s %s, %s, (%s);", op->name, rd_name, rs2_name,
>  		  rs1_name);
> @@ -889,9 +902,14 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>  	  if (amo_curr->addr == riscv_cpu->regs[rs1])
>  	    {
>  	      /* We found a reservation, so operate it.  */
> -	      sim_core_write_unaligned_4 (cpu, riscv_cpu->pc, write_map,
> -					  riscv_cpu->regs[rs1],
> -					  riscv_cpu->regs[rs2]);
> +	      if (op->xlen_requirement == 64)
> +		sim_core_write_unaligned_8 (cpu, riscv_cpu->pc, write_map,
> +					    riscv_cpu->regs[rs1],
> +					    riscv_cpu->regs[rs2]);
> +	      else
> +		sim_core_write_unaligned_4 (cpu, riscv_cpu->pc, write_map,
> +					    riscv_cpu->regs[rs1],
> +					    riscv_cpu->regs[rs2]);
>  	      store_rd (cpu, rd, 0);
>  	      if (amo_curr == state->amo_reserved_list)
>  		state->amo_reserved_list = amo_curr->next;
> @@ -920,7 +938,7 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>  					       riscv_cpu->regs[rs1]));
>    store_rd (cpu, rd, tmp);
>  
> -  switch (op->match)
> +  switch (op->match & ~mask_aqrl)
>      {
>      case MATCH_AMOADD_D:
>      case MATCH_AMOADD_W:

Oops, here is the ultimate bug...
when rd == rs1 or rd == rs2 this does not work right.
with this store_rd the rs1 and/or rs2 can be overwrittten.
e.g. amoswap.d r0, r0, (r1)
does not work correctly because rd is overwritten too early.
the old value of r0 should be written to memory at r1
r0 should get the value that was read from memory at r1
but due to this aliasing iossue the wrong value is writtenback.

I will have to think of a solution and send a v3 version
shortly.


Thanks
Bernd.

^ permalink raw reply	[relevance 0%]

* Re: [PATCH v3 2/3] gdb/nat: Factor linux_proc_get_stat_field out of linux_common_core_of_thread
  @ 2024-04-25 12:48  0%       ` Thiago Jung Bauermann
  0 siblings, 0 replies; 200+ results
From: Thiago Jung Bauermann @ 2024-04-25 12:48 UTC (permalink / raw)
  To: Luis Machado; +Cc: gdb-patches, Christophe Lyon, Pedro Alves

Hello Luis,

Luis Machado <luis.machado@arm.com> writes:

> On 4/25/24 09:59, Luis Machado wrote:
>> On 4/25/24 00:15, Thiago Jung Bauermann wrote:
>>> diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c
>>> index e2086952ce6b..c11eaf3cc6fd 100644
>>> --- a/gdb/nat/linux-procfs.c
>>> +++ b/gdb/nat/linux-procfs.c
>>> @@ -230,6 +230,50 @@ linux_proc_pid_is_zombie (pid_t pid)
>>>  
>>>  /* See linux-procfs.h.  */
>>>  
>>> +std::optional<std::string>
>>> +linux_proc_get_stat_field (ptid_t ptid, int field)
>>> +{
>>> +  /* We never need to read PID from the stat file, and there's
>>> +     command_from_pid to read the comm field.  */
>>> +  gdb_assert (field >= LINUX_PROC_STAT_STATE);
>>> +
>>> +  std::string filename = string_printf ("/proc/%ld/task/%ld/stat",
>>> +					(long) ptid.pid (), (long) ptid.lwp ());
>>> +
>>> +  std::optional<std::string> content
>>> +    = read_text_file_to_string (filename.c_str ());
>>> +  if (!content.has_value ())
>>> +    return {};
>>> +
>>> +  /* ps command also relies on no trailing fields ever contain ')'.  */
>> 
>> Probably an existing typo, but s/contain/containing?
>> 
>> No need to send a v5 for this though.
>> 
>
> Eh, or v4 rather. :-)

I think you're right. Fixed locally.

>>> +  std::string::size_type pos = content->find_last_of (')');
>>> +  if (pos == std::string::npos)
>>> +    return {};
>>> +
>>> +  /* The first field after program name is LINUX_PROC_STAT_STATE.  */
>>> +  for (int i = LINUX_PROC_STAT_STATE; i <= field; ++i)
>>> +    {
>>> +      /* Find separator.  */
>>> +      pos = content->find_first_of (' ', pos);
>>> +      if (pos == std::string::npos)
>>> +	return {};
>>> +
>>> +      /* Find beginning of field.  */
>>> +      pos = content->find_first_not_of (' ', pos);
>>> +      if (pos == std::string::npos)
>>> +	return {};
>>> +    }
>>> +
>>> +  /* Find end of field.  */
>>> +  std::string::size_type end_pos = content->find_first_of (' ', pos);
>>> +  if (end_pos == std::string::npos)
>>> +    return content->substr (pos);
>>> +  else
>>> +    return content->substr (pos, end_pos - pos);
>>> +}

<snip>

>> Otherwise looks OK.

Thanks!

-- 
Thiago

^ permalink raw reply	[relevance 0%]

* Re: [PATCH] sim: riscv: Fix some issues with class-a instructions
  @ 2024-04-23 13:56  0%   ` Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-23 13:56 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 4/22/24 17:01, Andrew Burgess wrote:
> Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
> 
>>      {
>> +    case MATCH_LR_D:
>>      case MATCH_LR_W:
>>        TRACE_INSN (cpu, "%s %s, (%s);", op->name, rd_name, rs1_name);
>> -      store_rd (cpu, rd,
>> -	sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map,
>> -				   riscv_cpu->regs[rs1]));
>> +      if (op->xlen_requirement == 64)
>> +	tmp = sim_core_read_aligned_8 (cpu, riscv_cpu->pc, read_map,
>> +				       riscv_cpu->regs[rs1]);
>> +      else
>> +	tmp = EXTEND32 (sim_core_read_aligned_4 (cpu, riscv_cpu->pc, read_map,
>> +						 riscv_cpu->regs[rs1]));
> 
> I might be completely off the mark here, but I'm unsure about this
> change from using 'unaligned' to 'aligned' here.
> 
> From my reading of common/sim-n-core.h, I believe the aligned/unaligned
> refers to the callers knowledge of the address.  So calling
> sim_core_read_aligned_* means that the common code should assume that
> the address is correctly aligned.  While sim_core_read_unaligned_*
> handles the case that the address might not be aligned, and raises the
> exception.
> 
> Please remember: I might be completely wrong here, and you just need to
> explain to me what's going on better.
> 
> 

Ah, you are right, the sim_core_read_aligned does hit an assertion:

sim-core.c:432: assertion failed - (addr & (nr_bytes - 1)) == 0
Aborted

That is of course not what I wanted. I think I should better tempoarily
change the value of "current_alignment".

> 
>> +      store_rd (cpu, rd, tmp);
>>  
>>        /* Walk the reservation list to find an existing match.  */
>>        amo_curr = state->amo_reserved_list;
>> @@ -878,6 +886,7 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>        amo_curr->next = state->amo_reserved_list;
>>        state->amo_reserved_list = amo_curr;
>>        goto done;
>> +    case MATCH_SC_D:
>>      case MATCH_SC_W:
>>        TRACE_INSN (cpu, "%s %s, %s, (%s);", op->name, rd_name, rs2_name,
>>  		  rs1_name);
>> @@ -889,7 +898,12 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>  	  if (amo_curr->addr == riscv_cpu->regs[rs1])
>>  	    {
>>  	      /* We found a reservation, so operate it.  */
>> -	      sim_core_write_unaligned_4 (cpu, riscv_cpu->pc, write_map,
>> +	      if (op->xlen_requirement == 64)
>> +		sim_core_write_aligned_8 (cpu, riscv_cpu->pc, write_map,
>> +					  riscv_cpu->regs[rs1],
>> +					  riscv_cpu->regs[rs2]);
>> +	      else
>> +		sim_core_write_aligned_4 (cpu, riscv_cpu->pc, write_map,
>>  					  riscv_cpu->regs[rs1],
>>  					  riscv_cpu->regs[rs2]);
>>  	      store_rd (cpu, rd, 0);
>> @@ -913,14 +927,14 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>    TRACE_INSN (cpu, "%s %s, %s, (%s);",
>>  	      op->name, rd_name, rs2_name, rs1_name);
>>    if (op->xlen_requirement == 64)
>> -    tmp = sim_core_read_unaligned_8 (cpu, riscv_cpu->pc, read_map,
>> -				     riscv_cpu->regs[rs1]);
>> +    tmp = sim_core_read_aligned_8 (cpu, riscv_cpu->pc, read_map,
>> +				   riscv_cpu->regs[rs1]);
>>    else
>> -    tmp = EXTEND32 (sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map,
>> -					       riscv_cpu->regs[rs1]));
>> +    tmp = EXTEND32 (sim_core_read_aligned_4 (cpu, riscv_cpu->pc, read_map,
>> +					     riscv_cpu->regs[rs1]));
>>    store_rd (cpu, rd, tmp);
>>  
>> -  switch (op->match)
>> +  switch (op->match & ~mask_aqrl)
>>      {
>>      case MATCH_AMOADD_D:
>>      case MATCH_AMOADD_W:
>> @@ -931,25 +945,37 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>        tmp = riscv_cpu->regs[rd] & riscv_cpu->regs[rs2];
>>        break;
>>      case MATCH_AMOMAX_D:
>> -    case MATCH_AMOMAX_W:
>>        tmp = max ((signed_word) riscv_cpu->regs[rd],
>>  		 (signed_word) riscv_cpu->regs[rs2]);
>>        break;
>> +    case MATCH_AMOMAX_W:
>> +      tmp = max ((int32_t) riscv_cpu->regs[rd],
>> +		 (int32_t) riscv_cpu->regs[rs2]);
> 
> I wonder if we should use EXTEND32 here?  There seems to be a mix of
> styles throughout the file.
> 

No that is not necessary, because the value is just used to write the
result back to memory using sim_core_write_unaligned_4/8 and that should
ignore the high word.  But I will better try that out before I send
the next version of this patch.
Other places pass the value to store_rd so the high word will be visible in
an riscv64 architecture register.

>> +      break;
>>      case MATCH_AMOMAXU_D:
>> -    case MATCH_AMOMAXU_W:
>>        tmp = max ((unsigned_word) riscv_cpu->regs[rd],
>>  		 (unsigned_word) riscv_cpu->regs[rs2]);
>>        break;
>> +    case MATCH_AMOMAXU_W:
>> +      tmp = max ((uint32_t) riscv_cpu->regs[rd],
>> +		 (uint32_t) riscv_cpu->regs[rs2]);
> 
> And maybe EXTEND32 again here, but I guess we'd still need the cast to
> unsigned_word.
> 

Same here, some kind of sign extension happens, but the high word should be
ignored and there is no ugly compiler warning either.

But I can try that out if it behaves correctly...


Thanks
Bernd.

^ permalink raw reply	[relevance 0%]

* [PATCH 1/7] gdb: move declarations of check_quit_flag and set_quit_flag to extension.h
  @ 2024-04-23 13:22  7% ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-04-23 13:22 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Move them out of defs.h, to extension.h, since the implementations are
in extension.c.

Change-Id: Ie7321468bd7fecc684d70b09f72c3ee8ac75d8f4
---
 gdb/defs.h      | 19 -------------------
 gdb/extension.c | 17 ++++-------------
 gdb/extension.h | 30 ++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index 91724d30195f..6f9c0d1f781a 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -94,25 +94,6 @@ extern std::string python_libdir;
 /* * Search path for separate debug files.  */
 extern std::string debug_file_directory;
 
-/* GDB's SIGINT handler basically sets a flag; code that might take a
-   long time before it gets back to the event loop, and which ought to
-   be interruptible, checks this flag using the QUIT macro, which, if
-   GDB has the terminal, throws a quit exception.
-
-   In addition to setting a flag, the SIGINT handler also marks a
-   select/poll-able file descriptor as read-ready.  That is used by
-   interruptible_select in order to support interrupting blocking I/O
-   in a race-free manner.
-
-   These functions use the extension_language_ops API to allow extension
-   language(s) and GDB SIGINT handling to coexist seamlessly.  */
-
-/* * Evaluate to non-zero if the quit flag is set, zero otherwise.  This
-   will clear the quit flag as a side effect.  */
-extern int check_quit_flag (void);
-/* * Set the quit flag.  */
-extern void set_quit_flag (void);
-
 /* The current quit handler (and its type).  This is called from the
    QUIT macro.  See default_quit_handler below for default behavior.
    Parts of GDB temporarily override this to e.g., completely suppress
diff --git a/gdb/extension.c b/gdb/extension.c
index f4bdcc1f6110..2d692d054315 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -863,16 +863,10 @@ restore_active_ext_lang (struct active_ext_lang_state *previous)
   xfree (previous);
 }
 
-/* Set the quit flag.
-   This only sets the flag in the currently active extension language.
-   If the currently active extension language does not have cooperative
-   SIGINT handling, then GDB's global flag is set, and it is up to the
-   extension language to call check_quit_flag.  The extension language
-   is free to install its own SIGINT handler, but we still need to handle
-   the transition.  */
+/* See extension.h.  */
 
 void
-set_quit_flag (void)
+set_quit_flag ()
 {
 #if CXX_STD_THREAD
   std::lock_guard guard (ext_lang_mutex);
@@ -894,13 +888,10 @@ set_quit_flag (void)
     }
 }
 
-/* Return true if the quit flag has been set, false otherwise.
-   Note: The flag is cleared as a side-effect.
-   The flag is checked in all extension languages that support cooperative
-   SIGINT handling, not just the current one.  This simplifies transitions.  */
+/* See extension.h.  */
 
 int
-check_quit_flag (void)
+check_quit_flag ()
 {
 #if CXX_STD_THREAD
   std::lock_guard guard (ext_lang_mutex);
diff --git a/gdb/extension.h b/gdb/extension.h
index 9ba1299f95e1..94a500d74586 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -429,4 +429,34 @@ class scoped_disable_cooperative_sigint_handling
   bool m_prev_cooperative_sigint_handling_disabled;
 };
 
+/* GDB's SIGINT handler basically sets a flag; code that might take a
+   long time before it gets back to the event loop, and which ought to
+   be interruptible, checks this flag using the QUIT macro, which, if
+   GDB has the terminal, throws a quit exception.
+
+   In addition to setting a flag, the SIGINT handler also marks a
+   select/poll-able file descriptor as read-ready.  That is used by
+   interruptible_select in order to support interrupting blocking I/O
+   in a race-free manner.
+
+   These functions use the extension_language_ops API to allow extension
+   language(s) and GDB SIGINT handling to coexist seamlessly.  */
+
+/* Return true if the quit flag has been set, false otherwise.
+   Note: The flag is cleared as a side-effect.
+   The flag is checked in all extension languages that support cooperative
+   SIGINT handling, not just the current one.  This simplifies transitions.  */
+
+extern int check_quit_flag ();
+
+/* Set the quit flag.
+   This only sets the flag in the currently active extension language.
+   If the currently active extension language does not have cooperative
+   SIGINT handling, then GDB's global flag is set, and it is up to the
+   extension language to call check_quit_flag.  The extension language
+   is free to install its own SIGINT handler, but we still need to handle
+   the transition.  */
+
+extern void set_quit_flag ();
+
 #endif /* EXTENSION_H */
-- 
2.44.0


^ permalink raw reply	[relevance 7%]

* Re: [PATCH 2/2] gdb/testsuite: Add gdb.base/memops-watchpoint.exp
  @ 2024-04-22 23:04  0%       ` Thiago Jung Bauermann
  0 siblings, 0 replies; 200+ results
From: Thiago Jung Bauermann @ 2024-04-22 23:04 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches

Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:

> Kevin Buettner <kevinb@redhat.com> writes:
>
>> On Sat, 20 Apr 2024 18:33:07 -0300
>> Thiago Jung Bauermann <thiago.bauermann@linaro.org> wrote:
>>
>>> +# It's not possible to check in which libc function the watchpoint triggers
>>> +# without its debug info.
>>> +require libc_has_debug_info
>>
>> I'm wondering about the need for this requirement.  When I comment it
>> out and run it on a machine without libc debuginfo, I do see 3 FAILs,
>> but it seems to me that those could be turned into PASSes by changing
>> the regular expressions for the "continue until..." tests.
>>
>> E.g. for the first one, with libc debuginfo, I see:
>>
>> continue
>> Continuing.
>>
>> Hardware watchpoint 2: -location a[31]
>>
>> Old value = 101 'e'
>> New value = 0 '\000'
>> __memset_avx2_unaligned () at
>> ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:146
>> 146		VMOVU	%VMM(0), (%rdi)
>> (gdb) PASS: gdb.base/memops-watchpoint.exp: continue until memset watchpoint hits
>>
>> But, without libc debuginfo, the watchpoint still works:
>>
>> continue
>> Continuing.
>>
>> Hardware watchpoint 2: -location a[31]
>>
>> Old value = 101 'e'
>> New value = 0 '\000'
>> 0x00007ffff7e3553a in __memset_avx2_unaligned () from /lib64/libc.so.6
>> (gdb) FAIL: gdb.base/memops-watchpoint.exp: continue until memset watchpoint hits
>>
>> As stated earlier, this could be turned into a PASS by tweaking the RE.
>>
>> In both cases, we know that it's in a "memset" function.  (The presence
>> of minimal symbols provides GDB with this information.)
>
> I added the requirement because in my aarch64-linux system without libc6
> debug info I get:
>
> continue
> Continuing.
>
> Hardware watchpoint 2: -location a[28]
>
> Old value = 104 'h'
> New value = 0 '\000'
> 0x0000fffff7e90664 in ?? () from /lib/aarch64-linux-gnu/libc.so.6
> (gdb) FAIL: gdb.base/memops-watchpoint.exp: continue until memset watchpoint hits

<snip>

> So it depends on the system.
>
> One alternative would be to not use the require statement and run the
> test until the watchpoint hits, and have a case in gdb_test_multiple to
> mark as UNRESOLVED if the function name is '??'.

I was able to do this in v3. But I mark the test as UNSUPPORTED rather
than UNRESOLVED. The difference between them isn't always clear in my
mind, but I think UNSUPPORTED is better in this case.

--
Thiago

^ permalink raw reply	[relevance 0%]

* Re: [PATCH v5 2/2] [gdb/symtab] Handle two-linetable function in find_epilogue_using_linetable
  @ 2024-04-22 13:39  0%   ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-04-22 13:39 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

Tom de Vries <tdevries@suse.de> writes:

> From: Bernd Edlinger <bernd.edlinger@hotmail.de>
>
> Consider the following test-case:
> ...
> $ cat hello.c
> int main()
> {
>   printf("hello ");
>   #include "world.inc"
> $ cat world.inc
>   printf("world\n");
>   return 0;
> }
> $ gcc -g hello.c
> ...
>
> The line table for the compilation unit, consisting just of
> function main, is translated into these two gdb line tables, one for hello.c
> and one for world.inc:
> ...
> compunit_symtab: hello.c
> symtab: hello.c
> INDEX  LINE   REL-ADDRESS UNREL-ADDRESS IS-STMT PROLOGUE-END EPILOGUE-BEGIN
> 0      3      0x400557    0x400557      Y
> 1      4      0x40055b    0x40055b      Y
> 2      END    0x40056a    0x40056a      Y
>
> compunit_symtab: hello.c
> symtab: world.inc
> INDEX  LINE   REL-ADDRESS UNREL-ADDRESS IS-STMT PROLOGUE-END EPILOGUE-BEGIN
> 0      1      0x40056a    0x40056a      Y
> 1      2      0x400574    0x400574      Y
> 2      3      0x400579    0x400579      Y
> 3      END    0x40057b    0x40057b      Y
> ...
>
> The epilogue of main starts at 0x400579:
> ...
>   400579:	5d                   	pop    %rbp
>   40057a:	c3                   	ret
> ...
>
> Now, say we have an epilogue_begin marker in the line table at 0x400579.
>
> We won't find it using find_epilogue_using_linetable, because it does:
> ...
>   const struct symtab_and_line sal = find_pc_line (start_pc, 0);
> ...
> which gets us the line table for hello.c.
>
> Fix this by using "find_pc_line (end_pc - 1, 0)" instead.
>
> Tested on x86_64-linux.
>
> Co-Authored-By: Tom de Vries <tdevries@suse.de>

LGTM.


Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

>
> PR symtab/31622
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31622
> ---
>  gdb/symtab.c                                  |  11 +-
>  .../gdb.dwarf2/dw2-epilogue-begin-2.exp       |  20 ++
>  .../gdb.dwarf2/dw2-epilogue-begin.c.inc       |  51 +++++
>  .../gdb.dwarf2/dw2-epilogue-begin.exp         | 157 +-------------
>  .../gdb.dwarf2/dw2-epilogue-begin.exp.tcl     | 199 ++++++++++++++++++
>  gdb/testsuite/lib/dwarf.exp                   |   5 +-
>  6 files changed, 284 insertions(+), 159 deletions(-)
>  create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin-2.exp
>  create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c.inc
>  create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl
>
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index e032178aaa6..034f71226b6 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -4158,8 +4158,15 @@ find_epilogue_using_linetable (CORE_ADDR func_addr)
>  
>    /* While the standard allows for multiple points marked with epilogue_begin
>       in the same function, for performance reasons, this function will only
> -     find the last address that sets this flag for a given block.  */
> -  const struct symtab_and_line sal = find_pc_line (start_pc, 0);
> +     find the last address that sets this flag for a given block.
> +
> +     The lines of a function can be described by several line tables in case
> +     there are different files involved.  There's a corner case where a
> +     function epilogue is in a different file than a function start, and using
> +     start_pc as argument to find_pc_line will mean we won't find the
> +     epilogue.  Instead, use "end_pc - 1" to maximize our changes of picking
> +     the line table containing an epilogue.  */
> +  const struct symtab_and_line sal = find_pc_line (end_pc - 1, 0);
>    if (sal.symtab != nullptr && sal.symtab->language () != language_asm)
>      {
>        struct objfile *objfile = sal.symtab->compunit ()->objfile ();
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin-2.exp
> new file mode 100644
> index 00000000000..6302ef1ad05
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin-2.exp
> @@ -0,0 +1,20 @@
> +# Copyright 2022-2024 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +standard_testfile dw2-epilogue-begin.c dw2-epilogue-begin.S
> +
> +set version 2
> +
> +source $srcdir/$subdir/dw2-epilogue-begin.exp.tcl
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c.inc b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c.inc
> new file mode 100644
> index 00000000000..4ff445cf37d
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c.inc
> @@ -0,0 +1,51 @@
> +/* Copyright 2023-2024 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +void
> +__attribute__((used))
> +trivial (void)
> +{
> +  asm ("trivial_label: .global trivial_label");		/* trivial function */
> +}
> +
> +char global;
> +
> +void
> +watch (void)
> +{							/* watch start */
> +  asm ("watch_label: .global watch_label");
> +  asm ("mov $0x0, %rax");
> +  int local = 0;					/* watch prologue */
> +
> +  asm ("watch_start: .global watch_start");
> +  asm ("mov $0x1, %rax");
> +  local = 1;						/* watch assign */
> +  asm ("watch_reassign: .global watch_reassign");
> +  asm ("mov $0x2, %rax");
> +  local = 2;						/* watch reassign */
> +  asm ("watch_end: .global watch_end");			/* watch end */
> +}
> +
> +int
> +main (void)
> +{							/* main prologue */
> +  asm ("main_label: .global main_label");
> +  global = 0;
> +  asm ("main_fun_call: .global main_fun_call");
> +  watch ();						/* main function call */
> +  asm ("main_epilogue: .global main_epilogue");
> +  global = 10;
> +  return 0;						/* main end */
> +}
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
> index f646e23da62..9b9d6c71de4 100644
> --- a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
> @@ -13,161 +13,8 @@
>  # You should have received a copy of the GNU General Public License
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
> -# Check that GDB can honor the epilogue_begin flag the compiler can place
> -# in the line-table data.
> -# We test 2 things: 1. that a software watchpoint triggered in an epilogue
> -# is correctly ignored
> -# 2. that GDB can mark the same line as both prologue and epilogue
> -
> -load_lib dwarf.exp
> -
> -# This test can only be run on targets which support DWARF-2 and use gas.
> -require dwarf2_support
> -# restricted to x86 to make it simpler to follow a variable
> -require is_x86_64_m64_target
> -
>  standard_testfile .c .S
>  
> -set trivial_line [gdb_get_line_number "trivial function"]
> -set main_prologue [gdb_get_line_number "main prologue"]
> -set main_epilogue [gdb_get_line_number "main end"]
> -set watch_start_line [gdb_get_line_number "watch start"]
> -
> -set asm_file [standard_output_file $srcfile2]
> -
> -# The producer will be set to clang because at the time of writing
> -# we only care about epilogues if the producer is clang.  When the
> -# producer is GCC, variables use CFA locations, so watchpoints can
> -# continue working even on epilogues.
> -Dwarf::assemble $asm_file {
> -    global srcdir subdir srcfile srcfile2
> -    global trivial_line main_prologue main_epilogue watch_start_line
> -    declare_labels lines_label
> -
> -    get_func_info main
> -    get_func_info trivial
> -    get_func_info watch
> -
> -    cu {} {
> -	compile_unit {
> -	    {language @DW_LANG_C}
> -	    {name dw2-prologue-end.c}
> -	    {stmt_list ${lines_label} DW_FORM_sec_offset}
> -	    {producer "clang version 17.0.1"}
> -	} {
> -	    declare_labels char_label
> -
> -	    char_label: base_type {
> -		{name char}
> -		{encoding @DW_ATE_signed}
> -		{byte_size 1 DW_FORM_sdata}
> -	    }
> -
> -	    subprogram {
> -		{external 1 flag}
> -		{name trivial}
> -		{low_pc $trivial_start addr}
> -		{high_pc "$trivial_start + $trivial_len" addr}
> -	    }
> -	    subprogram {
> -		{external 1 flag}
> -		{name watch}
> -		{low_pc $watch_start addr}
> -		{high_pc "$watch_start + $watch_len" addr}
> -	    } {
> -		DW_TAG_variable {
> -		    {name local}
> -		    {type :$char_label}
> -		    {DW_AT_location {DW_OP_reg0} SPECIAL_expr}
> -		}
> -	    }
> -	    subprogram {
> -		{external 1 flag}
> -		{name main}
> -		{low_pc $main_start addr}
> -		{high_pc "$main_start + $main_len" addr}
> -	    }
> -	}
> -    }
> -
> -    lines {version 5} lines_label {
> -	set diridx [include_dir "${srcdir}/${subdir}"]
> -	file_name "$srcfile" $diridx
> -
> -	program {
> -	    DW_LNS_set_file $diridx
> -	    DW_LNE_set_address $trivial_start
> -	    line $trivial_line
> -	    DW_LNS_set_prologue_end
> -	    DW_LNS_set_epilogue_begin
> -	    DW_LNS_copy
> -
> -	    DW_LNE_set_address watch
> -	    line $watch_start_line
> -	    DW_LNS_copy
> -
> -	    DW_LNE_set_address watch_start
> -	    line [gdb_get_line_number "watch assign"]
> -	    DW_LNS_set_prologue_end
> -	    DW_LNS_copy
> -
> -	    DW_LNE_set_address watch_reassign
> -	    line [gdb_get_line_number "watch reassign"]
> -	    DW_LNS_set_epilogue_begin
> -	    DW_LNS_copy
> -
> -	    DW_LNE_set_address watch_end
> -	    line [gdb_get_line_number "watch end"]
> -	    DW_LNS_copy
> -
> -	    DW_LNE_set_address $main_start
> -	    line $main_prologue
> -	    DW_LNS_set_prologue_end
> -	    DW_LNS_copy
> -
> -	    DW_LNE_set_address main_fun_call
> -	    line [gdb_get_line_number "main function call"]
> -	    DW_LNS_copy
> -
> -	    DW_LNE_set_address main_epilogue
> -	    line $main_epilogue
> -	    DW_LNS_set_epilogue_begin
> -	    DW_LNS_copy
> -
> -	    DW_LNE_end_sequence
> -	}
> -    }
> -}
> -
> -if { [prepare_for_testing "failed to prepare" ${testfile} \
> -	  [list $srcfile $asm_file] {nodebug}] } {
> -    return -1
> -}
> -
> -if ![runto_main] {
> -    return -1
> -}
> -
> -# Moving to the scope with a local variable.
> -gdb_breakpoint $watch_start_line
> -gdb_continue_to_breakpoint "continuing to function" ".*"
> -gdb_test "next" "local = 2.*" "stepping to epilogue"
> -
> -# Forcing software watchpoints because hardware ones don't care if we
> -# are in the epilogue or not.
> -gdb_test_no_output "set can-use-hw-watchpoints 0"
> -
> -# Test that the software watchpoint will not trigger in this case
> -gdb_test "watch local" "\[W|w\]atchpoint .: local" "set watchpoint"
> -gdb_test "continue" ".*\[W|w\]atchpoint . deleted.*" \
> -    "confirm watchpoint doesn't trigger"
> +set version 1
>  
> -# First we test that the trivial function has a line with both a prologue
> -# and an epilogue. Do this by finding a line that has 3 Y columns
> -set sep "\[ \t\]"
> -set hex_number "0x\[0-9a-f\]+"
> -gdb_test_multiple "maint info line-table" "test epilogue in linetable" -lbl {
> -    -re "\[0-9\]$sep+$trivial_line$sep+$hex_number$sep+$hex_number$sep+Y$sep+Y$sep+Y" {
> -	pass $gdb_test_name
> -    }
> -}
> +source $srcdir/$subdir/dw2-epilogue-begin.exp.tcl
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl
> new file mode 100644
> index 00000000000..155916b92df
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl
> @@ -0,0 +1,199 @@
> +# Copyright 2022-2024 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Check that GDB can honor the epilogue_begin flag the compiler can place
> +# in the line-table data.
> +# We test 2 things: 1. that a software watchpoint triggered in an epilogue
> +# is correctly ignored
> +# 2. that GDB can mark the same line as both prologue and epilogue
> +
> +load_lib dwarf.exp
> +
> +# This test can only be run on targets which support DWARF-2 and use gas.
> +require dwarf2_support
> +# restricted to x86 to make it simpler to follow a variable
> +require is_x86_64_m64_target
> +
> +set trivial_line [gdb_get_line_number "trivial function"]
> +set main_prologue [gdb_get_line_number "main prologue"]
> +set main_epilogue [gdb_get_line_number "main end"]
> +set watch_start_line [gdb_get_line_number "watch start"]
> +
> +set asm_file [standard_output_file $srcfile2]
> +
> +# The producer will be set to clang because at the time of writing
> +# we only care about epilogues if the producer is clang.  When the
> +# producer is GCC, variables use CFA locations, so watchpoints can
> +# continue working even on epilogues.
> +Dwarf::assemble $asm_file {
> +    global srcdir subdir srcfile srcfile2
> +    global trivial_line main_prologue main_epilogue watch_start_line
> +    declare_labels lines_label
> +
> +    get_func_info main
> +    get_func_info trivial
> +    get_func_info watch
> +
> +    if { $::version == 1 } {
> +	set switch_file {}
> +    } elseif { $::version == 2 } {
> +	set switch_file { set f $f2 }
> +    } else {
> +	error "Unhandled version: $::version"
> +    }
> +
> +    cu {} {
> +	compile_unit {
> +	    {language @DW_LANG_C}
> +	    {name dw2-prologue-end.c}
> +	    {stmt_list ${lines_label} DW_FORM_sec_offset}
> +	    {producer "clang version 17.0.1"}
> +	} {
> +	    declare_labels char_label
> +
> +	    char_label: base_type {
> +		{name char}
> +		{encoding @DW_ATE_signed}
> +		{byte_size 1 DW_FORM_sdata}
> +	    }
> +
> +	    subprogram {
> +		{external 1 flag}
> +		{name trivial}
> +		{low_pc $trivial_start addr}
> +		{high_pc "$trivial_start + $trivial_len" addr}
> +	    }
> +	    subprogram {
> +		{external 1 flag}
> +		{name watch}
> +		{low_pc $watch_start addr}
> +		{high_pc "$watch_start + $watch_len" addr}
> +	    } {
> +		DW_TAG_variable {
> +		    {name local}
> +		    {type :$char_label}
> +		    {DW_AT_location {DW_OP_reg0} SPECIAL_expr}
> +		}
> +	    }
> +	    subprogram {
> +		{external 1 flag}
> +		{name main}
> +		{low_pc $main_start addr}
> +		{high_pc "$main_start + $main_len" addr}
> +	    }
> +	}
> +    }
> +
> +    lines {version 5} lines_label {
> +	set diridx [include_dir "${srcdir}/${subdir}"]
> +	set f1 [file_name "$srcfile" $diridx]
> +	set f2 [file_name "$srcfile.inc" $diridx]
> +
> +	set f $f1
> +	program {
> +	    DW_LNS_set_file $f
> +
> +	    DW_LNE_set_address $trivial_start
> +	    line $trivial_line
> +	    DW_LNS_set_prologue_end
> +	    DW_LNS_set_epilogue_begin
> +	    DW_LNS_copy
> +
> +	    DW_LNE_set_address $trivial_end
> +	    DW_LNE_end_sequence
> +
> +
> +	    DW_LNS_set_file $f
> +
> +	    DW_LNE_set_address $watch_start
> +	    line $watch_start_line
> +	    DW_LNS_copy
> +
> +	    DW_LNE_set_address watch_start
> +	    line [gdb_get_line_number "watch assign"]
> +	    DW_LNS_set_prologue_end
> +	    DW_LNS_copy
> +
> +	    eval $switch_file
> +	    DW_LNS_set_file $f
> +
> +	    DW_LNE_set_address watch_reassign
> +	    line [gdb_get_line_number "watch reassign"]
> +	    DW_LNS_set_epilogue_begin
> +	    DW_LNS_copy
> +
> +	    DW_LNE_set_address watch_end
> +	    line [gdb_get_line_number "watch end"]
> +	    DW_LNS_copy
> +
> +	    DW_LNE_set_address $watch_end
> +	    DW_LNE_end_sequence
> +
> +
> +	    DW_LNS_set_file $f
> +
> +	    DW_LNE_set_address $main_start
> +	    line $main_prologue
> +	    DW_LNS_set_prologue_end
> +	    DW_LNS_copy
> +
> +	    DW_LNE_set_address main_fun_call
> +	    line [gdb_get_line_number "main function call"]
> +	    DW_LNS_copy
> +
> +	    DW_LNE_set_address main_epilogue
> +	    line $main_epilogue
> +	    DW_LNS_set_epilogue_begin
> +	    DW_LNS_copy
> +
> +	    DW_LNE_set_address $main_end
> +	    DW_LNE_end_sequence
> +	}
> +    }
> +}
> +
> +if { [prepare_for_testing "failed to prepare" ${testfile} \
> +	  [list $srcfile $asm_file] {nodebug}] } {
> +    return -1
> +}
> +
> +if ![runto_main] {
> +    return -1
> +}
> +
> +# Moving to the scope with a local variable.
> +
> +gdb_breakpoint $srcfile:$watch_start_line
> +gdb_continue_to_breakpoint "continuing to function" ".*"
> +gdb_test "next" "local = 2.*" "stepping to epilogue"
> +
> +# Forcing software watchpoints because hardware ones don't care if we
> +# are in the epilogue or not.
> +gdb_test_no_output "set can-use-hw-watchpoints 0"
> +
> +# Test that the software watchpoint will not trigger in this case
> +gdb_test "watch local" "\[W|w\]atchpoint .: local" "set watchpoint"
> +gdb_test "continue" ".*\[W|w\]atchpoint . deleted.*" \
> +    "confirm watchpoint doesn't trigger"
> +
> +# First we test that the trivial function has a line with both a prologue
> +# and an epilogue. Do this by finding a line that has 3 Y columns
> +set sep "\[ \t\]"
> +set hex_number "0x\[0-9a-f\]+"
> +gdb_test_multiple "maint info line-table" "test epilogue in linetable" -lbl {
> +    -re "\[0-9\]$sep+$trivial_line$sep+$hex_number$sep+$hex_number$sep+Y$sep+Y$sep+Y" {
> +	pass $gdb_test_name
> +    }
> +}
> diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
> index d085f835f07..adc3a18ee4f 100644
> --- a/gdb/testsuite/lib/dwarf.exp
> +++ b/gdb/testsuite/lib/dwarf.exp
> @@ -2427,10 +2427,11 @@ namespace eval Dwarf {
>  	    variable _line_file_names
>  	    lappend _line_file_names $filename $diridx
>  
> +	    set nr_filenames [expr [llength $_line_file_names] / 2]
>  	    if { $Dwarf::_line_unit_version >= 5 } {
> -		return [expr [llength $_line_file_names] - 1]
> +		return [expr $nr_filenames - 1]
>  	    } else {
> -		return [llength $_line_file_names]
> +		return $nr_filenames
>  	    }
>  	}
>  
> -- 
> 2.35.3


^ permalink raw reply	[relevance 0%]

* [Patch v2] Fix AIX thread exit events not being reported and UI to show   kernel thread ID.
@ 2024-04-22 14:33  5% Aditya Kamath1
  0 siblings, 0 replies; 200+ results
From: Aditya Kamath1 @ 2024-04-22 14:33 UTC (permalink / raw)
  To: Aditya Kamath1 via Gdb-patches, Ulrich Weigand, Tom Tromey, John Baldwin
  Cc: Sangamesh Mallayya

[-- Attachment #1: Type: text/plain, Size: 16580 bytes --]

Respected John, Tom, Ulrich, and community members,

Hi,

Thank you for the comments in the previous version of the patch.

>Next time can you please send the patch inline as a separate e-mail?  You can use a cover
>letter for the contents of this mail.  It is just easier to review in that case.

>One thing I think I'm not fully understanding: does a thread never get removed from the
>pth list once it has exited?  That is, is it on that list forever?  If so, I think
>you could simplify this quite a bit to remove the qsort and the gcount and associated
>list, etc.  Instead, I would keep track of exited threads whose exit has been reported
>via a new std::unordered_set<> class member in the target to avoid reporting duplicate
>events and then do something like:

Please see the patch pasted below this email. Thank you for this John. This makes it easy for us to maintain and keep track.

I have done a small clean-up of aix-thread.c to keep things simple.

Yes, a thread was never getting removed from pbuf. It was in it forever.

Output after applying this patch:-

Reading symbols from //gdb_tests/continue-pending-status_exit_test...
(gdb) r
Starting program: /gdb_tests/continue-pending-status_exit_test
More threads
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
[New Thread 258 (tid 19136989)]
[Thread 258 (tid 19136989) exited]
[New Thread 515 (tid 19464469)]
[Thread 515 (tid 19464469) exited]
[New Thread 772 (tid 34144651)]
[Thread 772 (tid 34144651) exited]
[New Thread 1029 (tid 25690595)]
[Thread 1029 (tid 25690595) exited]
[New Thread 1286 (tid 18547171)]
[Thread 1286 (tid 18547171) exited]
[New Thread 1543 (tid 32637297)]
[Thread 1543 (tid 32637297) exited]

Thread 1 received signal SIGINT, Interrupt.
0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) info thread
q  Id   Target Id                           Frame
* 1    Thread 1 (tid 31916313) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) q


Kindly let me know if this version is okay.

>> So, consider program 1 pasted below this email.

>Is there some existing gdb test case that is fixed by this patch?  If
>not then I think it would be better if the patch came with a new test.

Sure Tom. I will create another patch for this and send it soon.

For now I will attach the test program below.

Also, I have update the comments and removed the old ones.

>>I am planning to use
>>“status = pthdb_pthread_state (data->pd_session, pdtid, &state);”
>>
>>And if the state is PST_TERM then I want to remove the thread vector
>>from the pbuf list and make sure pcount is also reduced.
>>This can fix the issue.

>>This makes sense to me.

Thanks Ulrich. So as John suggested we will making use of unordered set and keeping track of exited threads using the state PST_TERM.

Have a nice day ahead.

Thanks and regards,
Aditya.

The patch:-

# cat patches/0001-Fix-AIX-thread-exit-events-not-being-reported-and-UI.patch
From ae736fe495c279d42e65f936bce0f9dab5ec703b Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath Aditya.Kamath1@ibm.com<mailto:Aditya.Kamath1@ibm.com>
Date: Mon, 22 Apr 2024 09:16:56 -0500
Subject: [PATCH] Fix AIX thread exit events not being reported and UI to show
 kernel thread ID.

In AIX when a thread exits we were not showing that a thread exit event happened
and GDB continued to keep the terminated threads.

If we have terminated threads then the UI on info threads command will look like
(gdb) info threads
  Id   Target Id                                          Frame
* 1    Thread 1 (tid 26607979, running)    0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
  2    Thread 258 (tid 30998799, finished) aix-thread: ptrace (52, 30998799) returned -1 (errno = 3 The process does not exist.)

If we see the frame is not getting displayed correctly.

The reason for the same is that in AIX we were not managing thread states. In particular we do not know
when a thread terminates.

The reason being in sync_threadlists () the pbuf and gbuf lists remain the same though certain threads exit.

This patch is a fix to the same.

Also certain UI is changed.

On a new thread born and exit the UI in AIX will be similar to Linux with both user and kernel thread information.

[New Thread 258 (tid 32178533)]
[New Thread 515 (tid 30343651)]
[New Thread 772 (tid 33554909)]
[New Thread 1029 (tid 24969489)]
[New Thread 1286 (tid 18153945)]
[New Thread 1543 (tid 30736739)]
[Thread 258 (tid 32178533) exited]
[Thread 515 (tid 30343651) exited]
[Thread 772 (tid 33554909) exited]
[Thread 1029 (tid 24969489) exited]
[Thread 1286 (tid 18153945) exited]
[Thread 1543 (tid 30736739) exited]

and info threads will look like
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 31326579) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
---
gdb/aix-thread.c | 217 ++++++++++++-----------------------------------
1 file changed, 52 insertions(+), 165 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index c70bd82bc24..73839243213 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -55,6 +55,7 @@
#include <sys/reg.h>
#include <sched.h>
#include <sys/pthdebug.h>
+#include <unordered_set>

#if !HAVE_DECL_GETTHRDS
extern int getthrds (pid_t, struct thrdsinfo64 *, int, tid_t *, int);
@@ -190,6 +191,9 @@ struct aix_thread_variables
   /* Whether the current architecture is 64-bit.
    Only valid when pd_able is true.  */
   int arch64;
+
+  /* Describes the number of thread exit events reported.  */
+  std::unordered_set<pthdb_pthread_t> exited_threads;
};

/* Key to our per-inferior data.  */
@@ -737,47 +741,6 @@ state2str (pthdb_state_t state)
     }
}

-/* qsort() comparison function for sorting pd_thread structs by pthid.  */
-
-static int
-pcmp (const void *p1v, const void *p2v)
-{
-  struct pd_thread *p1 = (struct pd_thread *) p1v;
-  struct pd_thread *p2 = (struct pd_thread *) p2v;
-  return p1->pthid < p2->pthid ? -1 : p1->pthid > p2->pthid;
-}
-
-/* ptid comparison function */
-
-static int
-ptid_cmp (ptid_t ptid1, ptid_t ptid2)
-{
-  if (ptid1.pid () < ptid2.pid ())
-    return -1;
-  else if (ptid1.pid () > ptid2.pid ())
-    return 1;
-  else if (ptid1.tid () < ptid2.tid ())
-    return -1;
-  else if (ptid1.tid () > ptid2.tid ())
-    return 1;
-  else if (ptid1.lwp () < ptid2.lwp ())
-    return -1;
-  else if (ptid1.lwp () > ptid2.lwp ())
-    return 1;
-  else
-    return 0;
-}
-
-/* qsort() comparison function for sorting thread_info structs by pid.  */
-
-static int
-gcmp (const void *t1v, const void *t2v)
-{
-  struct thread_info *t1 = *(struct thread_info **) t1v;
-  struct thread_info *t2 = *(struct thread_info **) t2v;
-  return ptid_cmp (t1->ptid, t2->ptid);
-}
-
/* Search through the list of all kernel threads for the thread
    that has stopped on a SIGTRAP signal, and return its TID.
    Return 0 if none found.  */
@@ -822,22 +785,16 @@ static void
sync_threadlists (pid_t pid)
{
   int cmd, status;
-  int pcount, psize, pi, gcount, gi;
-  struct pd_thread *pbuf;
-  struct thread_info **gbuf, **g, *thread;
   pthdb_pthread_t pdtid;
   pthread_t pthid;
   pthdb_tid_t tid;
   process_stratum_target *proc_target = current_inferior ()->process_target ();
   struct aix_thread_variables *data;
   data = get_thread_data_helper_for_pid (pid);
+  pthdb_state_t state;

   /* Accumulate an array of libpthdebug threads sorted by pthread id.  */

-  pcount = 0;
-  psize = 1;
-  pbuf = XNEWVEC (struct pd_thread, psize);
-
   for (cmd = PTHDB_LIST_FIRST;; cmd = PTHDB_LIST_NEXT)
     {
       status = pthdb_pthread (data->pd_session, &pdtid, cmd);
@@ -848,118 +805,44 @@ sync_threadlists (pid_t pid)
       if (status != PTHDB_SUCCESS || pthid == PTHDB_INVALID_PTID)
        continue;

-      if (pcount == psize)
+      ptid_t ptid (pid, 0, pthid);
+      status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+      if (state == PST_TERM)
        {
-         psize *= 2;
-         pbuf = (struct pd_thread *) xrealloc (pbuf,
-                                               psize * sizeof *pbuf);
+         if (data->exited_threads.count (pdtid) != 0)
+            continue;
        }
-      pbuf[pcount].pdtid = pdtid;
-      pbuf[pcount].pthid = pthid;
-      pcount++;
-    }
-
-  for (pi = 0; pi < pcount; pi++)
-    {
-      status = pthdb_pthread_tid (data->pd_session, pbuf[pi].pdtid, &tid);
-      if (status != PTHDB_SUCCESS)
-       tid = PTHDB_INVALID_TID;
-      pbuf[pi].tid = tid;
-    }
-
-  qsort (pbuf, pcount, sizeof *pbuf, pcmp);
-
-  /* Accumulate an array of GDB threads sorted by pid.  */
-
-  /* gcount is GDB thread count and pcount is pthreadlib thread count.  */
-
-  gcount = 0;
-  for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))
-    gcount++;
-  g = gbuf = XNEWVEC (struct thread_info *, gcount);
-  for (thread_info *tp : all_threads (proc_target, ptid_t (pid)))
-    *g++ = tp;
-  qsort (gbuf, gcount, sizeof *gbuf, gcmp);

-  /* Apply differences between the two arrays to GDB's thread list.  */
-
-  for (pi = gi = 0; pi < pcount || gi < gcount;)
-    {
-      if (pi == pcount)
-       {
-         delete_thread (gbuf[gi]);
-         gi++;
-       }
-      else if (gi == gcount)
+      /* If this thread has never been reported to GDB, add it.  */
+      if (!in_thread_list (proc_target, ptid))
        {
          aix_thread_info *priv = new aix_thread_info;
-         priv->pdtid = pbuf[pi].pdtid;
-         priv->tid = pbuf[pi].tid;
-
-         thread = add_thread_with_info (proc_target,
-                                        ptid_t (pid, 0, pbuf[pi].pthid),
-                                        private_thread_info_up (priv));
-
-         pi++;
-       }
-      else
-       {
-         ptid_t pptid, gptid;
-         int cmp_result;
-
-         pptid = ptid_t (pid, 0, pbuf[pi].pthid);
-         gptid = gbuf[gi]->ptid;
-         pdtid = pbuf[pi].pdtid;
-         tid = pbuf[pi].tid;
-
-         cmp_result = ptid_cmp (pptid, gptid);
-
-         if (cmp_result == 0)
-           {
-             aix_thread_info *priv = get_aix_thread_info (gbuf[gi]);
-
-             priv->pdtid = pdtid;
-             priv->tid = tid;
-             pi++;
-             gi++;
-           }
-         else if (cmp_result > 0)
+         /* init priv */
+         priv->pdtid = pdtid;
+         status = pthdb_pthread_tid (data->pd_session, pdtid, &tid);
+         priv->tid = tid;
+         /* Check if this is the main thread.  If it is, then change
+            its ptid and add its private data.  */
+         if (get_signaled_thread (pid) == tid
+               && in_thread_list (proc_target, ptid_t (pid)))
            {
-             /* This is to make the main process thread now look
-                like a thread.  */
-
-             if (gptid.is_pid ())
-               {
-                 thread_info *tp = proc_target->find_thread (gptid);
-                 thread_change_ptid (proc_target, gptid, pptid);
-                 aix_thread_info *priv = new aix_thread_info;
-                 priv->pdtid = pbuf[pi].pdtid;
-                 priv->tid = pbuf[pi].tid;
-                 tp->priv.reset (priv);
-                 gi++;
-                 pi++;
-               }
-             else
-               {
-                 delete_thread (gbuf[gi]);
-                 gi++;
-               }
+             thread_info *tp = proc_target->find_thread (ptid_t (pid));
+             thread_change_ptid (proc_target, ptid_t (pid), ptid);
+             tp->priv.reset (priv);
            }
          else
-           {
-             thread = add_thread (proc_target, pptid);
+           add_thread_with_info (proc_target, ptid,
+               private_thread_info_up (priv));
+       }

-             aix_thread_info *priv = new aix_thread_info;
-             thread->priv.reset (priv);
-             priv->pdtid = pdtid;
-             priv->tid = tid;
-             pi++;
-           }
+      if (state == PST_TERM)
+       {
+         thread_info *thr = proc_target->find_thread (ptid);
+         gdb_assert (thr != nullptr);
+         delete_thread (thr);
+         data->exited_threads.insert (pdtid);
        }
     }
-
-  xfree (pbuf);
-  xfree (gbuf);
}

/* Iterate_over_threads() callback for locating a thread, using
@@ -2084,10 +1967,17 @@ aix_thread_target::thread_alive (ptid_t ptid)
std::string
aix_thread_target::pid_to_str (ptid_t ptid)
{
-  if (ptid.tid () == 0)
-    return beneath ()->pid_to_str (ptid);
+  thread_info *thread_info = current_inferior ()->find_thread (ptid);
+
+  if (thread_info != NULL && thread_info->priv != NULL)
+    {
+      aix_thread_info *priv = get_aix_thread_info (thread_info);
+
+      return string_printf (_("Thread %s (tid %s)"), pulongest (ptid.tid ()),
+               pulongest (priv->tid));
+    }

-  return string_printf (_("Thread %s"), pulongest (ptid.tid ()));
+  return beneath ()->pid_to_str (ptid);
}

/* Return a printable representation of extra information about
@@ -2098,7 +1988,6 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
{
   int status;
   pthdb_pthread_t pdtid;
-  pthdb_tid_t tid;
   pthdb_state_t state;
   pthdb_suspendstate_t suspendstate;
   pthdb_detachstate_t detachstate;
@@ -2115,33 +2004,31 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
   aix_thread_info *priv = get_aix_thread_info (thread);

   pdtid = priv->pdtid;
-  tid = priv->tid;
-
-  if (tid != PTHDB_INVALID_TID)
-    /* i18n: Like "thread-identifier %d, [state] running, suspended" */
-    buf.printf (_("tid %d"), (int)tid);

   status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+
+  /* Output should look like Thread %d (tid %d) ([state]).  */
+  /* Example:- Thread 1 (tid 34144587) ([running]).  */
+  /* where state can be running, idle, sleeping, finished,
+     suspended, detached, cancel pending, ready or unknown.  */
+
   if (status != PTHDB_SUCCESS)
     state = PST_NOTSUP;
-  buf.printf (", %s", state2str (state));
+  buf.printf ("[%s]", state2str (state));

   status = pthdb_pthread_suspendstate (data->pd_session, pdtid,
                                       &suspendstate);
   if (status == PTHDB_SUCCESS && suspendstate == PSS_SUSPENDED)
-    /* i18n: Like "Thread-Id %d, [state] running, suspended" */
-    buf.printf (_(", suspended"));
+    buf.printf (_("[suspended]"));

   status = pthdb_pthread_detachstate (data->pd_session, pdtid,
                                      &detachstate);
   if (status == PTHDB_SUCCESS && detachstate == PDS_DETACHED)
-    /* i18n: Like "Thread-Id %d, [state] running, detached" */
-    buf.printf (_(", detached"));
+    buf.printf (_("[detached]"));

   pthdb_pthread_cancelpend (data->pd_session, pdtid, &cancelpend);
   if (status == PTHDB_SUCCESS && cancelpend)
-    /* i18n: Like "Thread-Id %d, [state] running, cancel pending" */
-    buf.printf (_(", cancel pending"));
+    buf.printf (_("[cancel pending]"));

   buf.write ("", 1);

--
2.41.0
Test Program 1:-

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>

pthread_barrier_t barrier;

#define NUM_THREADS 3

void *
thread_function (void *arg)
{
  /* This ensures that the breakpoint is only hit after both threads
     are created, so the test can always switch to the non-event
     thread when the breakpoint triggers.  */
//  pthread_barrier_wait (&barrier);

  printf ("Hello World \n"); /* break here */
}

int
main (void)
{
  int i;

  alarm (300);

  pthread_barrier_init (&barrier, NULL, NUM_THREADS);

  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_t thread;
      int res;

      res = pthread_create (&thread, NULL,
                            thread_function, NULL);
      assert (res == 0);
    }

  printf ("More threads \n");
  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_t thread;
      int res;

      res = pthread_create (&thread, NULL,
                thread_function, NULL);
      assert (res == 0);
    }
  while (1)
    sleep (1);

  return 0;
}

^ permalink raw reply	[relevance 5%]

* Re: [PATCH v2 2/2] gdb/testsuite: Add gdb.base/memops-watchpoint.exp
  @ 2024-04-22 14:39  0%   ` Luis Machado
  0 siblings, 0 replies; 200+ results
From: Luis Machado @ 2024-04-22 14:39 UTC (permalink / raw)
  To: Thiago Jung Bauermann, gdb-patches

Hi,

On 4/21/24 23:26, Thiago Jung Bauermann wrote:
> Test behaviour of watchpoints triggered by libc's memset/memcpy/memmove.
> These functions are frequently optimized with specialized instructions
> that favor larger memory access operations, so make sure GDB behaves
> correctly in their presence.
> 
> There's a separate watched variable for each function so that the testcase
> can test whether GDB correctly identified the watchpoint that triggered.
> 
> Also, the watchpoint is 28 bytes away from the beginning of the buffer
> being modified, so that large memory accesses (if present) are exercised.
> 
> PR testsuite/31484
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31484
> ---
>  gdb/testsuite/gdb.base/memops-watchpoint.c   | 45 ++++++++++
>  gdb/testsuite/gdb.base/memops-watchpoint.exp | 86 ++++++++++++++++++++
>  2 files changed, 131 insertions(+)
>  create mode 100644 gdb/testsuite/gdb.base/memops-watchpoint.c
>  create mode 100644 gdb/testsuite/gdb.base/memops-watchpoint.exp
> 
> NB: As with v1, please let me know if you think there are more interesting
> tests regarding watchpoint and memory accesses that can be done.  I tried
> to make it cover the interesting scenarios but the testcase is small, so
> maybe I'm not very creative.
> 
> Changes in v2:
> - Ensure watchpoints are aligned to 4 bytes.
> - Add kfail for arm-linux.
> 
> diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.c b/gdb/testsuite/gdb.base/memops-watchpoint.c
> new file mode 100644
> index 000000000000..0255cfb43404
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/memops-watchpoint.c
> @@ -0,0 +1,45 @@
> +/* This test program is part of GDB, the GNU debugger.
> +
> +   Copyright 2024 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#include <stdio.h>
> +#include <string.h>
> +
> +int
> +main (void)
> +{
> +  /* Some targets need 4-byte alignment for hardware watchpoints.  */
> +  char s[40] __attribute__ ((aligned (4)))
> +    = "This is a relatively long string...";
> +  char a[40] __attribute__ ((aligned (4)))
> +    = "String to be overwritten with zeroes";
> +  char b[40] __attribute__ ((aligned (4)))
> +    = "Another string to be memcopied...";
> +  char c[40] __attribute__ ((aligned (4)))
> +    = "Another string to be memmoved...";
> +
> +  /* Break here.  */
> +  memset (a, 0, sizeof (a));
> +
> +  memcpy (b, s, sizeof (b));
> +
> +  memmove (c, s, sizeof (c));
> +
> +  printf ("b = '%s'\n", b);
> +  printf ("c = '%s'\n", c);
> +
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.exp b/gdb/testsuite/gdb.base/memops-watchpoint.exp
> new file mode 100644
> index 000000000000..0edc646e67aa
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/memops-watchpoint.exp
> @@ -0,0 +1,86 @@
> +# Copyright 2024 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Test a binary that uses standard libc memory operation functions.  They are
> +# frequently optimized with specialized instructions, so make sure GDB behaves
> +# correctly in their presence.
> +
> +# It's not possible to check in which libc function the watchpoint triggers
> +# without its debug info.
> +require libc_has_debug_info
> +
> +standard_testfile
> +
> +set options "-fno-builtin-memset -fno-builtin-memcpy -fno-builtin-memmove"
> +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
> +	  [list debug additional_flags=$options]] } {
> +    return -1
> +}
> +
> +set linespec ${srcfile}:[gdb_get_line_number "Break here"]
> +
> +if ![runto ${linespec}] {
> +    return
> +}
> +
> +gdb_test "watch -location a\[28\]" \
> +    "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \
> +    "set watch on a"
> +gdb_test "watch -location b\[28\]" \
> +    "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
> +    "set watchpoint on b"
> +gdb_test "watch -location c\[28\]" \
> +    "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \
> +    "set watchpoint on c"
> +
> +setup_kfail breakpoints/31665 arm*-*-linux*
> +gdb_test "continue" \
> +    [multi_line \
> +	 "Continuing\\." \
> +	 "" \
> +	 "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \
> +	 "" \
> +	 "Old value = 104 'h'" \
> +	 "New value = 0 '\\\\000'" \
> +	 ".*memset.* \\(\\) at .*:$decimal" \
> +	 ".*"] \
> +    "continue until memset watchpoint hits"
> +
> +setup_kfail breakpoints/31665 arm*-*-linux*
> +gdb_test "continue" \
> +    [multi_line \
> +	 "Continuing\\." \
> +	 "" \
> +	 "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
> +	 "" \
> +	 "Old value = 101 'e'" \
> +	 "New value = 114 'r'" \
> +	 ".*memcpy.* \\(\\) at .*:$decimal" \
> +	".*"] \
> +    "continue until memcpy watchpoint hits"
> +
> +# Note: Some architectures use memcpy for memmove.
> +setup_kfail breakpoints/31665 arm*-*-linux*
> +gdb_test "continue" \
> +    [multi_line \
> +	 "Continuing\\." \
> +	 "" \
> +	 "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \
> +	 "" \
> +	 "Old value = 100 'd'" \
> +	 "New value = 114 'r'" \
> +	 ".*(memmove|memcpy).* \\(\\) at .*:$decimal" \
> +	".*"] \
> +    "continue until memmove watchpoint hits"

For this test, on aarch64 I see full passes, but on 32-bit Arm I see
3 passes and 3 kfail's.

Is that the expected outcome?

^ permalink raw reply	[relevance 0%]

* [PATCH v2] Add a test for the gcore script
@ 2024-04-22 12:12  4% Alexandra Hájková
  0 siblings, 0 replies; 200+ results
From: Alexandra Hájková @ 2024-04-22 12:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: ahajkova

From: Alexandra Hájková <ahajkova@redhat.com>

It also tests the gcore script being run without its accessible
terminal.

This test was written by Jan Kratochvil a long time ago. I modernized
the test making it use various procs from lib/gdb.exp, reoirganising it
and added some comments.

Modify the gcore script to make it possible to pass the --data-directory to
it. This prevents a lot of these warnings:

Python Exception <class 'AttributeError'>: module 'gdb' has no attribute
'_handle_missing_debuginfo'

Tested by using make check-all-boards.

Co-Authored-By: Jan Kratochvil
---
v2: - added a -d option to the gcore script to make
it possbile to pass the --data-directory to it
- changed the gcorebg.c to use pipe intead of sleep
- added more comments
- added has_gcore_script proc to the lib/gdb.exp

 gdb/gcore.in                       |  9 ++-
 gdb/testsuite/gdb.base/gcorebg.c   | 85 +++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/gcorebg.exp | 88 ++++++++++++++++++++++++++++++
 gdb/testsuite/lib/gdb.exp          | 17 ++++++
 4 files changed, 198 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.base/gcorebg.c
 create mode 100644 gdb/testsuite/gdb.base/gcorebg.exp

diff --git a/gdb/gcore.in b/gdb/gcore.in
index 982c854eb70..291b807bed9 100644
--- a/gdb/gcore.in
+++ b/gdb/gcore.in
@@ -27,7 +27,9 @@ prefix=core
 # to ensure gdb dumps all mappings (OS dependent).
 dump_all_cmds=()
 
-while getopts :ao: opt; do
+DATA_DIRECTORY_OPT=""
+
+while getopts :ao:d: opt; do
     case "$opt" in
         a)
             case "$OSTYPE" in
@@ -40,8 +42,12 @@ while getopts :ao: opt; do
         o)
             prefix=$OPTARG
             ;;
+        d)
+            DATA_DIRECTORY_OPT="--data-directory $OPTARG"
+            ;;
         *)
             echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] pid1 [pid2...pidN]"
+            echo "DATA_DIRECTORY_OPT: $DATA_DIRECTORY_OPT"
             exit 2
             ;;
     esac
@@ -98,6 +104,7 @@ do
 	# `</dev/null' to avoid touching interactive terminal if it is
 	# available but not accessible as GDB would get stopped on SIGTTIN.
 	"$binary_path/@GDB_TRANSFORM_NAME@" </dev/null \
+            $DATA_DIRECTORY_OPT \
 	    --nx --batch --readnever -iex 'set debuginfod enabled off' \
 	    -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
 	    "${dump_all_cmds[@]}" \
diff --git a/gdb/testsuite/gdb.base/gcorebg.c b/gdb/testsuite/gdb.base/gcorebg.c
new file mode 100644
index 00000000000..4b1f82a2f00
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gcorebg.c
@@ -0,0 +1,85 @@
+/* Copyright 2007-2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+#include <assert.h>
+
+/* Expects 4 arguments:
+
+   1. Either 'standard' or 'detached', where 'standard' tests
+   a general gcore script spawn with its controlling terminal available
+   and 'detached' tests gcore script spawn without its controlling
+   terminal available.
+   2. Path to the gcore script
+   3. Path to the data-directory to pass to the gcore script
+   4. The core file output name
+
+*/
+
+int
+main (int argc, char **argv)
+{
+  pid_t pid = 0;
+  pid_t ppid;
+  char buf[1024*2 + 500];
+  int gotint, res;
+  int fd[2];
+
+  assert (argc == 5);
+
+  if (pipe(fd) == -1)
+    {
+      perror ("pipe err\n");
+      exit (1);
+    }
+  pid = fork ();
+
+  switch (pid)
+    {
+    case 0:
+      close (fd[0]);
+      if (strcmp (argv[1], "detached") == 0)
+	setpgrp ();
+      ppid = getppid ();
+      gotint = snprintf (buf, sizeof (buf), "sh %s -d %s -o %s %d",
+			 argv[2], argv[3], argv[4], (int) ppid);
+      assert (gotint < sizeof (buf));
+      res = system (buf);
+      assert (res != -1);
+      close(fd[1]);
+      break;
+
+    case -1:
+      close (fd[0]);
+      close (fd[1]);
+      perror ("fork err\n");
+      exit (1);
+      break;
+
+    default:
+      close (fd[1]);
+      res = read (fd[0], buf, 1);
+      assert (res == 0);
+      close (fd[0]);
+      break;
+    }
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/gcorebg.exp b/gdb/testsuite/gdb.base/gcorebg.exp
new file mode 100644
index 00000000000..6269988133c
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gcorebg.exp
@@ -0,0 +1,88 @@
+# Copyright 2007-2024 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# This is a test for the gcore script (not the gcore command form
+# inside GDB).  It also tests the gcore script being run without its
+# accessible terminal.
+
+standard_testfile
+require {!is_remote host}
+require {!is_remote target}
+require has_gcore_script
+
+set corefile [standard_output_file ${testfile}.core]
+
+if {[build_executable "failed to build" $testfile ${srcfile}] == -1 } {
+     return -1
+}
+
+# Cleanup.
+
+proc core_clean {} {
+    global corefile
+
+    foreach file [glob -nocomplain [join [list $corefile *] ""]] {
+	verbose "Delete file $file" 1
+	remote_file target delete $file
+    }
+}
+core_clean
+
+# Generate the core file.
+proc test_body { detached } {
+    global binfile
+    global GCORE
+    global corefile
+    global GDB_DATA_DIRECTORY
+
+    with_test_prefix "detached = $detached" {
+	# We can't use gdb_test_multiple here because GDB is not started.
+	set res [remote_spawn target "$binfile $detached $GCORE $GDB_DATA_DIRECTORY $corefile"]
+	if { $res < 0 || $res == "" } {
+	    fail "Spawning gcore"
+	    return 1
+	}
+	pass "Spawned gcore"
+
+	set saw_corefile_created false
+	set testname "Spawned gcore finished"
+	remote_expect target 20 {
+	    timeout {
+		fail "$testname (timeout)"
+		remote_exec target "kill -9 -[exp_pid -i $res]"
+		return
+	    }
+	    -re "Saved corefile \[^\r\n\]+\r\n" {
+		set saw_corefile_created true
+		exp_continue
+	    }
+	    eof {
+		gdb_assert { $saw_corefile_created } $testname
+	    }
+	}
+
+	gdb_assert {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} "Core file generated by gcore"
+	core_clean
+    }
+}
+
+# First a general gcore script spawn with its controlling terminal available.
+
+test_body standard
+
+# And now gcore script spawn without its controlling terminal available.
+# It is spawned through `gcorebg.c' using setpgrp ().
+
+test_body detached
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index ddee928d510..e8c38869cee 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -158,6 +158,23 @@ load_lib gdb-utils.exp
 load_lib memory.exp
 load_lib check-test-names.exp
 
+# The path to the GCORE script to test.
+global GCORE
+if ![info exists GCORE] {
+    set GCORE [findfile $base_dir/../../gdb/gcore]
+} else {
+    set GCORE ""
+}
+verbose "using GCORE = $GCORE" 2
+
+proc has_gcore_script {} {
+    if {[info exists ::GCORE]} {
+	return 1
+    } else {
+	return 0
+    }
+}
+
 # The path to the GDB binary to test.
 global GDB
 
-- 
2.44.0


^ permalink raw reply	[relevance 4%]

* [PUSHED] gdb: fix unknown variable typo in c-exp.y
  @ 2024-04-22  9:41  4% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-04-22  9:41 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

Fix 'val' -> 'value' typo in c-exp.y which was breaking the build.
Introduced in commit:

  commit e6375bc8ebbbc177c79f08e9616eb0b131229f65
  Date:   Wed Apr 17 16:17:33 2024 -0600

      Remove some alloca uses
---
 gdb/c-exp.y | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 87aca4d59b1..5db63551d21 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -3430,7 +3430,7 @@ c_print_token (FILE *file, int type, YYSTYPE value)
     case CHAR:
     case STRING:
       parser_fprintf (file, "tsval<type=%d, %.*s>", value.tsval.type,
-		      value.tsval.length, val.tsval.ptr);
+		      value.tsval.length, value.tsval.ptr);
       break;
 
     case NSSTRING:

base-commit: 911cb006bf029ada9f6364619257dffe9218e92a
-- 
2.25.4


^ permalink raw reply	[relevance 4%]

* [PATCH] gdb/remote: fix qRcmd error handling
@ 2024-04-22  8:45  8% Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-04-22  8:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

This commit:

  commit 3623271997a5c0d79609aa6a1f35ef61b4469054
  Date:   Tue Jan 30 15:55:47 2024 +0100

      remote.c: Use packet_check_result

Introduced a bug in the error handling of the qRcmd packet.  Prior to
this commit if a packet had status PACKET_OK then, if the packet
contained the text "OK" we considered the packet handled.  But, if the
packet contained any other content (that was not an error message)
then the content was printed to the user.

After the above commit this was no longer the case, any non-error
packet that didn't contain "OK" would be treated as an error.

Currently, gdbserver doesn't exercise this path so it's not possible
to write a simple test for this case.  When gdbserver wishes to print
output it sends back an 'O' string output packet, these packets are
handled earlier in the process.  Then once gdbserver has finished
sending output an 'OK' packet is sent.
---
 gdb/remote.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index cfb54de157d..ee4b76e290b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11954,18 +11954,23 @@ remote_target::rcmd (const char *command, struct ui_file *outbuf)
 	  continue;
 	}
       packet_result result = packet_check_result (buf, false);
-      if (strcmp (buf, "OK") == 0)
-	break;
-      else if (result.status () == PACKET_UNKNOWN)
-	error (_("Target does not support this command."));
-      else
-	error (_("Protocol error with Rcmd: %s."), result.err_msg ());
-
-      for (p = buf; p[0] != '\0' && p[1] != '\0'; p += 2)
+      switch (result.status ())
 	{
-	  char c = (fromhex (p[0]) << 4) + fromhex (p[1]);
+	case PACKET_UNKNOWN:
+	  error (_("Target does not support this command."));
+	case PACKET_ERROR:
+	  error (_("Protocol error with Rcmd: %s."), result.err_msg ());
+	case PACKET_OK:
+	  break;
+	}
 
-	  gdb_putc (c, outbuf);
+      if (strcmp (buf, "OK") != 0)
+	{
+	  for (p = buf; p[0] != '\0' && p[1] != '\0'; p += 2)
+	    {
+	      char c = (fromhex (p[0]) << 4) + fromhex (p[1]);
+	      gdb_putc (c, outbuf);
+	    }
 	}
       break;
     }

base-commit: 1f984aabf17f558d04d3cf1c1b643fd44e8348e8
-- 
2.25.4


^ permalink raw reply	[relevance 8%]

* [PATCH 01/10] Remove test code from cp-name-parser.y
  @ 2024-04-21 17:00  6% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-21 17:00 UTC (permalink / raw)
  To: gdb-patches

This removes the current test 'main' from cp-name-parser.y.  There
aren't any tests using this, and nowadays it would be better as a unit
test.
---
 gdb/Makefile.in      |  15 +-----
 gdb/cp-name-parser.y | 135 ---------------------------------------------------
 gdb/yy-remap.h       |   4 --
 3 files changed, 1 insertion(+), 153 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 23894ea4a4d..2f7fc1ca249 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2147,16 +2147,6 @@ uninstall: force $(CONFIG_UNINSTALL)
 	rm -f $(DESTDIR)$(bindir)/$$transformed_name
 	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
-# The C++ name parser can be built standalone for testing.
-test-cp-name-parser.o: cp-name-parser.c
-	$(COMPILE) -DTEST_CPNAMES cp-name-parser.c
-	$(POSTCOMPILE)
-
-test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
-	$(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) \
-		-o test-cp-name-parser$(EXEEXT) test-cp-name-parser.o \
-		$(LIBIBERTY)
-
 # We do this by grepping through sources.  If that turns out to be too slow,
 # maybe we could just require every .o file to have an initialization routine
 # of a given name (top.o -> _initialize_top, etc.).
@@ -2168,7 +2158,6 @@ test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
 # computing the list of source files from the list of object files.
 
 INIT_FILES_FILTER_OUT = \
-	cp-name-parser.o \
 	init.o \
 	version.o \
 	xml-builtin.o \
@@ -2244,7 +2233,6 @@ clean mostlyclean: $(CONFIG_CLEAN)
 	rm -f init.c stamp-init version.c stamp-version
 	rm -f gdb$(EXEEXT) core make.log
 	rm -f gdb[0-9]$(EXEEXT)
-	rm -f test-cp-name-parser$(EXEEXT)
 	rm -f xml-builtin.c stamp-xml
 	rm -f $(DEPDIR)/*
 	for i in $(CONFIG_SRC_SUBDIR); do \
@@ -2677,8 +2665,7 @@ endif
 
 # A list of all the objects we might care about in this build, for
 # dependency tracking.
-all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o \
-	test-cp-name-parser.o
+all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o
 
 # All the .deps files to include.
 all_deps_files = $(foreach dep,$(patsubst %.o,%.Po,$(all_object_files)),\
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 87f13445bba..9f4561a36b4 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -171,11 +171,6 @@ cpname_state::d_grab ()
 #define INT_SIGNED	(1 << 4)
 #define INT_UNSIGNED	(1 << 5)
 
-/* Enable yydebug for the stand-alone parser.  */
-#ifdef TEST_CPNAMES
-# define YYDEBUG	1
-#endif
-
 /* Helper functions.  These wrap the demangler tree interface, handle
    allocation from our global store, and return the allocated component.  */
 
@@ -2051,133 +2046,3 @@ cp_demangled_name_to_comp (const char *demangled_name,
 
   return result;
 }
-
-#ifdef TEST_CPNAMES
-
-static void
-cp_print (struct demangle_component *result)
-{
-  char *str;
-  size_t err = 0;
-
-  str = gdb_cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI, result, 64, &err);
-  if (str == NULL)
-    return;
-
-  fputs (str, stdout);
-
-  free (str);
-}
-
-static char
-trim_chars (char *lexptr, char **extra_chars)
-{
-  char *p = (char *) symbol_end (lexptr);
-  char c = 0;
-
-  if (*p)
-    {
-      c = *p;
-      *p = 0;
-      *extra_chars = p + 1;
-    }
-
-  return c;
-}
-
-/* When this file is built as a standalone program, xmalloc comes from
-   libiberty --- in which case we have to provide xfree ourselves.  */
-
-void
-xfree (void *ptr)
-{
-  if (ptr != NULL)
-    {
-      /* Literal `free' would get translated back to xfree again.  */
-      CONCAT2 (fr,ee) (ptr);
-    }
-}
-
-/* GDB normally defines internal_error itself, but when this file is built
-   as a standalone program, we must also provide an implementation.  */
-
-void
-internal_error (const char *file, int line, const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start (ap, fmt);
-  fprintf (stderr, "%s:%d: internal error: ", file, line);
-  vfprintf (stderr, fmt, ap);
-  exit (1);
-}
-
-int
-main (int argc, char **argv)
-{
-  char *str2, *extra_chars, c;
-  char buf[65536];
-  int arg;
-
-  arg = 1;
-  if (argv[arg] && strcmp (argv[arg], "--debug") == 0)
-    {
-      yydebug = 1;
-      arg++;
-    }
-
-  if (argv[arg] == NULL)
-    while (fgets (buf, 65536, stdin) != NULL)
-      {
-	buf[strlen (buf) - 1] = 0;
-	/* Use DMGL_VERBOSE to get expanded standard substitutions.  */
-	c = trim_chars (buf, &extra_chars);
-	str2 = cplus_demangle (buf, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
-	if (str2 == NULL)
-	  {
-	    printf ("Demangling error\n");
-	    if (c)
-	      printf ("%s%c%s\n", buf, c, extra_chars);
-	    else
-	      printf ("%s\n", buf);
-	    continue;
-	  }
-
-	std::string errmsg;
-	std::unique_ptr<demangle_parse_info> result
-	  = cp_demangled_name_to_comp (str2, &errmsg);
-	if (result == NULL)
-	  {
-	    fputs (errmsg.c_str (), stderr);
-	    fputc ('\n', stderr);
-	    continue;
-	  }
-
-	cp_print (result->tree);
-
-	free (str2);
-	if (c)
-	  {
-	    putchar (c);
-	    fputs (extra_chars, stdout);
-	  }
-	putchar ('\n');
-      }
-  else
-    {
-      std::string errmsg;
-      std::unique_ptr<demangle_parse_info> result
-	= cp_demangled_name_to_comp (argv[arg], &errmsg);
-      if (result == NULL)
-	{
-	  fputs (errmsg.c_str (), stderr);
-	  fputc ('\n', stderr);
-	  return 0;
-	}
-      cp_print (result->tree);
-      putchar ('\n');
-    }
-  return 0;
-}
-
-#endif
diff --git a/gdb/yy-remap.h b/gdb/yy-remap.h
index d52a59d11b9..e32ce394339 100644
--- a/gdb/yy-remap.h
+++ b/gdb/yy-remap.h
@@ -93,8 +93,4 @@
 # define YYDEBUG 1  /* Default to yydebug support */
 #endif
 
-#ifndef TEST_CPNAMES
-# define YYFPRINTF parser_fprintf
-#endif
-
 #endif /* YY_REMAP_H */

-- 
2.44.0


^ permalink raw reply	[relevance 6%]

* [PATCHv2 7/8] gdb: apply escaping to filenames in 'complete' results
  @ 2024-04-20  9:10  2%   ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-04-20  9:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess, Lancelot SIX, Eli Zaretskii

Building on the mechanism added in the previous commit(s), this commit
applies escaping to filenames in the 'complete' command output.
Consider a file: /tmp/xxx/aa"bb -- that is a filename that contains a
double quote, currently the 'complete' command output looks like this:

  (gdb) complete file /tmp/xxx/a
  file /tmp/xxx/aa"bb

Notice that the double quote in the output is not escaped.  If we
passed this same output back to GDB then the double quote will be
treated as the start of a string.

After this commit then the output looks like this:

  (gdb) complete file /tmp/xxx/a
  file /tmp/xxx/aa\"bb

The double quote is now escaped.  If we feed this output back to GDB
then GDB will treat this as a single filename that contains a double
quote, exactly what we want.

To achieve this I've done a little refactoring, splitting out the core
of gdb_completer_file_name_quote, and then added a new call from the
filename_match_formatter function.

There are updates to the tests to cover this new functionality.
---
 gdb/completer.c                               |  98 ++++++++++++++---
 .../gdb.base/filename-completion.exp          | 100 +++++++++++-------
 2 files changed, 144 insertions(+), 54 deletions(-)

diff --git a/gdb/completer.c b/gdb/completer.c
index ee016cdc7f7..9c14e6a10ce 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -309,25 +309,24 @@ gdb_completer_file_name_dequote (char *filename, int quote_char)
   return strdup (tmp.c_str ());
 }
 
-/* Apply character escaping to the file name in TEXT.  QUOTE_PTR points to
-   the quote character surrounding TEXT, or points to the null-character if
-   there are no quotes around TEXT.  MATCH_TYPE will be one of the readline
-   constants SINGLE_MATCH or MULTI_MATCH depending on if there is one or
-   many completions.  */
+/* Apply character escaping to the filename in TEXT and return a newly
+   allocated buffer containing the possibly updated filename.
+
+   QUOTE_CHAR is the quote character surrounding TEXT, or the
+   null-character if there are no quotes around TEXT.  */
 
 static char *
-gdb_completer_file_name_quote (char *text, int match_type ATTRIBUTE_UNUSED,
-			       char *quote_ptr)
+gdb_completer_file_name_quote_1 (const char *text, char quote_char)
 {
   std::string str;
 
-  if (*quote_ptr == '\'')
+  if (quote_char == '\'')
     {
       /* There is no backslash escaping permitted within a single quoted
 	 string, so in this case we can just return the input sting.  */
       str = text;
     }
-  else if (*quote_ptr == '"')
+  else if (quote_char == '"')
     {
       /* Add escaping for a double quoted filename.  */
       for (const char *input = text;
@@ -341,7 +340,7 @@ gdb_completer_file_name_quote (char *text, int match_type ATTRIBUTE_UNUSED,
     }
   else
     {
-      gdb_assert (*quote_ptr == '\0');
+      gdb_assert (quote_char == '\0');
 
       /* Add escaping for an unquoted filename.  */
       for (const char *input = text;
@@ -358,6 +357,19 @@ gdb_completer_file_name_quote (char *text, int match_type ATTRIBUTE_UNUSED,
   return strdup (str.c_str ());
 }
 
+/* Apply character escaping to the filename in TEXT.  QUOTE_PTR points to
+   the quote character surrounding TEXT, or points to the null-character if
+   there are no quotes around TEXT.  MATCH_TYPE will be one of the readline
+   constants SINGLE_MATCH or MULTI_MATCH depending on if there is one or
+   many completions.  */
+
+static char *
+gdb_completer_file_name_quote (char *text, int match_type ATTRIBUTE_UNUSED,
+			       char *quote_ptr)
+{
+  return gdb_completer_file_name_quote_1 (text, *quote_ptr);
+}
+
 /* The function is used to update the completion word MATCH before
    displaying it to the user in the 'complete' command output.  This
    function is only used for formatting filename or directory names.
@@ -366,12 +378,28 @@ gdb_completer_file_name_quote (char *text, int match_type ATTRIBUTE_UNUSED,
    in which case a trailing "/" (forward-slash) is added, otherwise
    QUOTE_CHAR is added as a trailing quote.
 
+   When ADD_ESCAPES is true any special characters (e.g. whitespace,
+   quotes) will be escaped with a backslash.  See
+   gdb_completer_file_name_quote_1 for full details on escaping.  When
+   ADD_ESCAPES is false then no escaping will be added and MATCH (with the
+   correct trailing character) will be used unmodified.
+
    Return the updated completion word as a string.  */
 
 static std::string
-filename_match_formatter (const char *match, char quote_char)
+filename_match_formatter_1 (const char *match, char quote_char,
+			    bool add_escapes)
 {
-  std::string result (match);
+  std::string result;
+  if (add_escapes)
+    {
+      gdb::unique_xmalloc_ptr<char> quoted_match
+	(gdb_completer_file_name_quote_1 (match, quote_char));
+      result = quoted_match.get ();
+    }
+  else
+    result = match;
+
   if (std::filesystem::is_directory (gdb_tilde_expand (match)))
     result += "/";
   else
@@ -380,16 +408,52 @@ filename_match_formatter (const char *match, char quote_char)
   return result;
 }
 
+/* The formatting function used to format the results of a 'complete'
+   command when the result is a filename, but the filename should not have
+   any escape characters added.  Most commands that accept a filename don't
+   expect the filename to be quoted or to contain escape characters.
+
+   See filename_match_formatter_1 for more argument details.  */
+
+static std::string
+filename_unquoted_match_formatter (const char *match, char quote_char)
+{
+  return filename_match_formatter_1 (match, quote_char, false);
+}
+
+/* The formatting function used to format the results of a 'complete'
+   command when the result is a filename, and the filename should have any
+   special character (e.g. whitespace, quotes) within it escaped with a
+   backslash.  A limited number of commands accept this style of filename
+   argument.
+
+   See filename_match_formatter_1 for more argument details.  */
+
+static std::string
+filename_maybe_quoted_match_formatter (const char *match, char quote_char)
+{
+  return filename_match_formatter_1 (match, quote_char, true);
+}
+
 /* Generate filename completions of WORD, storing the completions into
    TRACKER.  This is used for generating completions for commands that
    only accept unquoted filenames as well as for commands that accept
-   quoted and escaped filenames.  */
+   quoted and escaped filenames.
+
+   When QUOTE_MATCHES is true TRACKER will be given a match formatter
+   function which will add escape characters (if needed) in the results.
+   When QUOTE_MATCHES is false the match formatter provided will not add
+   any escaping to the results.  */
 
 static void
 filename_completer_generate_completions (completion_tracker &tracker,
-					 const char *word)
+					 const char *word,
+					 bool quote_matches)
 {
-  tracker.set_match_format_func (filename_match_formatter);
+  if (quote_matches)
+    tracker.set_match_format_func (filename_maybe_quoted_match_formatter);
+  else
+    tracker.set_match_format_func (filename_unquoted_match_formatter);
 
   int subsequent_name = 0;
   while (1)
@@ -423,7 +487,7 @@ filename_maybe_quoted_completer (struct cmd_list_element *ignore,
 {
   rl_char_is_quoted_p = gdb_completer_file_name_char_is_quoted;
   rl_completer_quote_characters = gdb_completer_file_name_quote_characters;
-  filename_completer_generate_completions (tracker, word);
+  filename_completer_generate_completions (tracker, word, true);
 }
 
 /* The corresponding completer_handle_brkchars implementation.  */
@@ -449,7 +513,7 @@ filename_completer_handle_brkchars
 {
   gdb_assert (word == nullptr);
   tracker.set_use_custom_word_point (true);
-  filename_completer_generate_completions (tracker, text);
+  filename_completer_generate_completions (tracker, text, false);
 }
 
 /* Find the bounds of the current word for completion purposes, and
diff --git a/gdb/testsuite/gdb.base/filename-completion.exp b/gdb/testsuite/gdb.base/filename-completion.exp
index 0467d5c425e..3ded82431c8 100644
--- a/gdb/testsuite/gdb.base/filename-completion.exp
+++ b/gdb/testsuite/gdb.base/filename-completion.exp
@@ -82,10 +82,22 @@ proc test_gdb_complete_filename_multiple {
 	    $add_completed_line $completion_list $max_completions $testname
     }
 
-    if { $start_quote_char eq "" && $end_quote_char ne "" } {
+    if { $start_quote_char eq "" } {
 	set updated_completion_list {}
 
 	foreach entry $completion_list {
+	    # If ENTRY is quoted with double quotes, then any double
+	    # quotes within the entry need to be escaped.
+	    if { $end_quote_char eq "\"" } {
+		regsub -all "\"" $entry "\\\"" entry
+	    }
+
+	    if { $end_quote_char eq "" } {
+		regsub -all " " $entry "\\ " entry
+		regsub -all "\"" $entry "\\\"" entry
+		regsub -all "'" $entry "\\'" entry
+	    }
+
 	    if {[string range $entry end end] ne "/"} {
 		set entry $entry$end_quote_char
 	    }
@@ -147,47 +159,61 @@ proc run_quoting_and_escaping_tests { root } {
 		} "" "${qc}" false \
 		"expand mixed directory and file names"
 
-	    # GDB does not currently escape word break characters
-	    # (e.g. white space) correctly in unquoted filenames.
 	    if { $qc ne "" } {
 		set sp " "
-
-		test_gdb_complete_filename_multiple "file ${qc}${root}/aaa/" \
-		    "a" "a${sp}" {
-			"aa bb"
-			"aa cc"
-		    } "" "${qc}" false \
-		    "expand filenames containing spaces"
-
-		test_gdb_complete_filename_multiple "file ${qc}${root}/bb1/" \
-		    "a" "a" {
-			"aa\"bb"
-			"aa'bb"
-		    } "" "${qc}" false \
-		    "expand filenames containing quotes"
 	    } else {
 		set sp "\\ "
+	    }
+
+	    if { $qc eq "'" } {
+		set dq "\""
+		set dq_re "\""
+	    } else {
+		set dq "\\\""
+		set dq_re "\\\\\""
+	    }
+
+	    test_gdb_complete_filename_multiple "file ${qc}${root}/bb2/" \
+		"d" "ir${sp}" {
+		    "dir 1/"
+		    "dir 2/"
+		} "" "${qc}" false \
+		"expand multiple directory names containing spaces"
 
-		test_gdb_complete_tab_multiple "file ${qc}${root}/aaa/a" \
-		    "a${sp}" {
-			"aa bb"
-			"aa cc"
-		    } false \
-		    "expand filenames containing spaces"
-
-		test_gdb_complete_tab_multiple "file ${qc}${root}/bb1/a" \
-		    "a" {
-			"aa\"bb"
-			"aa'bb"
-		    } false \
-		    "expand filenames containing quotes"
-
-		test_gdb_complete_tab_unique "file ${qc}${root}/bb1/aa\\\"" \
-		    "file ${qc}${root}/bb1/aa\\\\\"bb${qc}" " " \
-		    "expand unique filename containing double quotes"
-
-		test_gdb_complete_tab_unique "file ${qc}${root}/bb1/aa\\'" \
-		    "file ${qc}${root}/bb1/aa\\\\'bb${qc}" " " \
+	    test_gdb_complete_filename_multiple "file ${qc}${root}/aaa/" \
+		"a" "a${sp}" {
+		    "aa bb"
+		    "aa cc"
+		} "" "${qc}" false \
+		"expand filenames containing spaces"
+
+	    test_gdb_complete_filename_multiple "file ${qc}${root}/bb1/" \
+		"a" "a" {
+		    "aa\"bb"
+		    "aa'bb"
+		} "" "${qc}" false \
+		"expand filenames containing quotes"
+
+	    test_gdb_complete_tab_unique "file ${qc}${root}/bb1/aa${dq}" \
+		"file ${qc}${root}/bb1/aa${dq_re}bb${qc}" " " \
+		"expand unique filename containing double quotes"
+
+	    # It is not possible to include a single quote character
+	    # within a single quoted string.  However, GDB does not do
+	    # anything smart if a user tries to do this.  Avoid testing
+	    # this case.  Maybe in the future we'll figure a way to avoid
+	    # this situation.
+	    if { $qc ne "'" } {
+		if { $qc eq "" } {
+		    set sq "\\'"
+		    set sq_re "\\\\'"
+		} else {
+		    set sq "'"
+		    set sq_re "'"
+		}
+
+		test_gdb_complete_tab_unique "file ${qc}${root}/bb1/aa${sq}" \
+		    "file ${qc}${root}/bb1/aa${sq_re}bb${qc}" " " \
 		    "expand unique filename containing single quote"
 	    }
 	}
-- 
2.25.4


^ permalink raw reply	[relevance 2%]

* [PATCH v2 4/4] gdb: add target_debug_printf and target_debug_printf_nofunc
  @ 2024-04-19 19:46 15% ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-04-19 19:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi, Tom Tromey

From: Simon Marchi <simon.marchi@efficios.com>

Add the `target_debug_printf` and `target_debug_printf_nofunc` macros
and use them when outputting debug messages depending on `targetdebug`.
I opted for `target_debug_printf_nofunc` to follow the current style
where the function name is already printed, along with the arguments.

Modify the debug printfs in the `debug_target` methods (generated by
`make-target-delegates.py`) to use `target_debug_printf_nofunc` as well.

This makes the "target" debug prints integrate nicely with the other
debug prints that use the "new" debug print system:

    [infrun] proceed: enter
      [infrun] follow_fork: enter
        [target] -> multi-thread->record_will_replay (...)
        [target] <- multi-thread->record_will_replay (-1, 0) = false
        [target] -> multi-thread->supports_multi_process (...)
        [target] <- multi-thread->supports_multi_process () = true
      [infrun] follow_fork: exit
      ...

Change-Id: Ide3c8c1b8a30e6d4c353a29cba911c7192de29ac
Approved-By: Tom Tromey <tom@tromey.com>
---
 gdb/make-target-delegates.py |  11 +-
 gdb/target-delegates.c       | 840 ++++++++++++++---------------------
 gdb/target.c                 | 129 +++---
 3 files changed, 390 insertions(+), 590 deletions(-)

diff --git a/gdb/make-target-delegates.py b/gdb/make-target-delegates.py
index f6f2bf004ff5..bfcf7faab7ae 100755
--- a/gdb/make-target-delegates.py
+++ b/gdb/make-target-delegates.py
@@ -274,9 +274,7 @@ def write_debugmethod(
     debugname = "debug_target::" + name
     names = write_function_header(f, False, debugname, return_type, argtypes)
     print(
-        '  gdb_printf (gdb_stdlog, "-> %s->'
-        + name
-        + ' (...)\\n", this->beneath ()->shortname ());',
+        f'  target_debug_printf_nofunc ("-> %s->{name} (...)", this->beneath ()->shortname ());',
         file=f,
     )
 
@@ -311,11 +309,8 @@ def write_debugmethod(
         ret = ""
 
     print(
-        (
-            "  gdb_printf (gdb_stdlog,\n"
-            '\t      "<- %s->{name} ({args_fmt}){ret_fmt}\\n",\n'
-            "\t      this->beneath ()->shortname (){args}{ret});"
-        ).format(name=name, args_fmt=args_fmt, args=args, ret_fmt=ret_fmt, ret=ret),
+        f'  target_debug_printf_nofunc ("<- %s->{name} ({args_fmt}){ret_fmt}",\n'
+        f"\t      this->beneath ()->shortname (){args}{ret});",
         file=f,
     )
 
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index b45b445c2c40..af6be0884a1b 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -392,10 +392,9 @@ dummy_target::post_attach (int arg0)
 void
 debug_target::post_attach (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->post_attach (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->post_attach (...)", this->beneath ()->shortname ());
   this->beneath ()->post_attach (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->post_attach (%s)\n",
+  target_debug_printf_nofunc ("<- %s->post_attach (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str ());
 }
@@ -414,10 +413,9 @@ dummy_target::detach (inferior *arg0, int arg1)
 void
 debug_target::detach (inferior *arg0, int arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->detach (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->detach (...)", this->beneath ()->shortname ());
   this->beneath ()->detach (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->detach (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->detach (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_inferior_p (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str ());
@@ -438,10 +436,9 @@ dummy_target::disconnect (const char *arg0, int arg1)
 void
 debug_target::disconnect (const char *arg0, int arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->disconnect (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->disconnect (...)", this->beneath ()->shortname ());
   this->beneath ()->disconnect (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->disconnect (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->disconnect (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str ());
@@ -462,10 +459,9 @@ dummy_target::resume (ptid_t arg0, int arg1, enum gdb_signal arg2)
 void
 debug_target::resume (ptid_t arg0, int arg1, enum gdb_signal arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->resume (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->resume (...)", this->beneath ()->shortname ());
   this->beneath ()->resume (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->resume (%s, %s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->resume (%s, %s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_step (arg1).c_str (),
@@ -486,10 +482,9 @@ dummy_target::commit_resumed ()
 void
 debug_target::commit_resumed ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->commit_resumed (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->commit_resumed (...)", this->beneath ()->shortname ());
   this->beneath ()->commit_resumed ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->commit_resumed ()\n",
+  target_debug_printf_nofunc ("<- %s->commit_resumed ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -508,11 +503,10 @@ dummy_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_fla
 ptid_t
 debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->wait (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->wait (...)", this->beneath ()->shortname ());
   ptid_t result
     = this->beneath ()->wait (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->wait (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->wait (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_target_waitstatus_p (arg1).c_str (),
@@ -535,10 +529,9 @@ dummy_target::fetch_registers (struct regcache *arg0, int arg1)
 void
 debug_target::fetch_registers (struct regcache *arg0, int arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->fetch_registers (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->fetch_registers (...)", this->beneath ()->shortname ());
   this->beneath ()->fetch_registers (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->fetch_registers (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->fetch_registers (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_regcache_p (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str ());
@@ -559,10 +552,9 @@ dummy_target::store_registers (struct regcache *arg0, int arg1)
 void
 debug_target::store_registers (struct regcache *arg0, int arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->store_registers (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->store_registers (...)", this->beneath ()->shortname ());
   this->beneath ()->store_registers (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->store_registers (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->store_registers (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_regcache_p (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str ());
@@ -583,10 +575,9 @@ dummy_target::prepare_to_store (struct regcache *arg0)
 void
 debug_target::prepare_to_store (struct regcache *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->prepare_to_store (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->prepare_to_store (...)", this->beneath ()->shortname ());
   this->beneath ()->prepare_to_store (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->prepare_to_store (%s)\n",
+  target_debug_printf_nofunc ("<- %s->prepare_to_store (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_regcache_p (arg0).c_str ());
 }
@@ -605,10 +596,9 @@ dummy_target::files_info ()
 void
 debug_target::files_info ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->files_info (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->files_info (...)", this->beneath ()->shortname ());
   this->beneath ()->files_info ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->files_info ()\n",
+  target_debug_printf_nofunc ("<- %s->files_info ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -627,11 +617,10 @@ dummy_target::insert_breakpoint (struct gdbarch *arg0, struct bp_target_info *ar
 int
 debug_target::insert_breakpoint (struct gdbarch *arg0, struct bp_target_info *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->insert_breakpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->insert_breakpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->insert_breakpoint (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->insert_breakpoint (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->insert_breakpoint (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_gdbarch_p (arg0).c_str (),
 	      target_debug_print_bp_target_info_p (arg1).c_str (),
@@ -654,11 +643,10 @@ dummy_target::remove_breakpoint (struct gdbarch *arg0, struct bp_target_info *ar
 int
 debug_target::remove_breakpoint (struct gdbarch *arg0, struct bp_target_info *arg1, enum remove_bp_reason arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->remove_breakpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->remove_breakpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->remove_breakpoint (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->remove_breakpoint (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->remove_breakpoint (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_gdbarch_p (arg0).c_str (),
 	      target_debug_print_bp_target_info_p (arg1).c_str (),
@@ -682,11 +670,10 @@ dummy_target::stopped_by_sw_breakpoint ()
 bool
 debug_target::stopped_by_sw_breakpoint ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->stopped_by_sw_breakpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->stopped_by_sw_breakpoint (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->stopped_by_sw_breakpoint ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->stopped_by_sw_breakpoint () = %s\n",
+  target_debug_printf_nofunc ("<- %s->stopped_by_sw_breakpoint () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -707,11 +694,10 @@ dummy_target::supports_stopped_by_sw_breakpoint ()
 bool
 debug_target::supports_stopped_by_sw_breakpoint ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_stopped_by_sw_breakpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_stopped_by_sw_breakpoint (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_stopped_by_sw_breakpoint ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_stopped_by_sw_breakpoint () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_stopped_by_sw_breakpoint () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -732,11 +718,10 @@ dummy_target::stopped_by_hw_breakpoint ()
 bool
 debug_target::stopped_by_hw_breakpoint ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->stopped_by_hw_breakpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->stopped_by_hw_breakpoint (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->stopped_by_hw_breakpoint ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->stopped_by_hw_breakpoint () = %s\n",
+  target_debug_printf_nofunc ("<- %s->stopped_by_hw_breakpoint () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -757,11 +742,10 @@ dummy_target::supports_stopped_by_hw_breakpoint ()
 bool
 debug_target::supports_stopped_by_hw_breakpoint ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_stopped_by_hw_breakpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_stopped_by_hw_breakpoint (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_stopped_by_hw_breakpoint ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_stopped_by_hw_breakpoint () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_stopped_by_hw_breakpoint () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -782,11 +766,10 @@ dummy_target::can_use_hw_breakpoint (enum bptype arg0, int arg1, int arg2)
 int
 debug_target::can_use_hw_breakpoint (enum bptype arg0, int arg1, int arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->can_use_hw_breakpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->can_use_hw_breakpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->can_use_hw_breakpoint (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->can_use_hw_breakpoint (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->can_use_hw_breakpoint (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bptype (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -810,11 +793,10 @@ dummy_target::ranged_break_num_registers ()
 int
 debug_target::ranged_break_num_registers ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->ranged_break_num_registers (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->ranged_break_num_registers (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->ranged_break_num_registers ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->ranged_break_num_registers () = %s\n",
+  target_debug_printf_nofunc ("<- %s->ranged_break_num_registers () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (result).c_str ());
   return result;
@@ -835,11 +817,10 @@ dummy_target::insert_hw_breakpoint (struct gdbarch *arg0, struct bp_target_info
 int
 debug_target::insert_hw_breakpoint (struct gdbarch *arg0, struct bp_target_info *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->insert_hw_breakpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->insert_hw_breakpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->insert_hw_breakpoint (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->insert_hw_breakpoint (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->insert_hw_breakpoint (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_gdbarch_p (arg0).c_str (),
 	      target_debug_print_bp_target_info_p (arg1).c_str (),
@@ -862,11 +843,10 @@ dummy_target::remove_hw_breakpoint (struct gdbarch *arg0, struct bp_target_info
 int
 debug_target::remove_hw_breakpoint (struct gdbarch *arg0, struct bp_target_info *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->remove_hw_breakpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->remove_hw_breakpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->remove_hw_breakpoint (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->remove_hw_breakpoint (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->remove_hw_breakpoint (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_gdbarch_p (arg0).c_str (),
 	      target_debug_print_bp_target_info_p (arg1).c_str (),
@@ -889,11 +869,10 @@ dummy_target::remove_watchpoint (CORE_ADDR arg0, int arg1, enum target_hw_bp_typ
 int
 debug_target::remove_watchpoint (CORE_ADDR arg0, int arg1, enum target_hw_bp_type arg2, struct expression *arg3)
 {
-  gdb_printf (gdb_stdlog, "-> %s->remove_watchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->remove_watchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->remove_watchpoint (arg0, arg1, arg2, arg3);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->remove_watchpoint (%s, %s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->remove_watchpoint (%s, %s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -918,11 +897,10 @@ dummy_target::insert_watchpoint (CORE_ADDR arg0, int arg1, enum target_hw_bp_typ
 int
 debug_target::insert_watchpoint (CORE_ADDR arg0, int arg1, enum target_hw_bp_type arg2, struct expression *arg3)
 {
-  gdb_printf (gdb_stdlog, "-> %s->insert_watchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->insert_watchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->insert_watchpoint (arg0, arg1, arg2, arg3);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->insert_watchpoint (%s, %s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->insert_watchpoint (%s, %s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -947,11 +925,10 @@ dummy_target::insert_mask_watchpoint (CORE_ADDR arg0, CORE_ADDR arg1, enum targe
 int
 debug_target::insert_mask_watchpoint (CORE_ADDR arg0, CORE_ADDR arg1, enum target_hw_bp_type arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->insert_mask_watchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->insert_mask_watchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->insert_mask_watchpoint (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->insert_mask_watchpoint (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->insert_mask_watchpoint (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_CORE_ADDR (arg1).c_str (),
@@ -975,11 +952,10 @@ dummy_target::remove_mask_watchpoint (CORE_ADDR arg0, CORE_ADDR arg1, enum targe
 int
 debug_target::remove_mask_watchpoint (CORE_ADDR arg0, CORE_ADDR arg1, enum target_hw_bp_type arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->remove_mask_watchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->remove_mask_watchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->remove_mask_watchpoint (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->remove_mask_watchpoint (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->remove_mask_watchpoint (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_CORE_ADDR (arg1).c_str (),
@@ -1003,11 +979,10 @@ dummy_target::stopped_by_watchpoint ()
 bool
 debug_target::stopped_by_watchpoint ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->stopped_by_watchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->stopped_by_watchpoint (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->stopped_by_watchpoint ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->stopped_by_watchpoint () = %s\n",
+  target_debug_printf_nofunc ("<- %s->stopped_by_watchpoint () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -1028,11 +1003,10 @@ dummy_target::have_steppable_watchpoint ()
 bool
 debug_target::have_steppable_watchpoint ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->have_steppable_watchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->have_steppable_watchpoint (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->have_steppable_watchpoint ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->have_steppable_watchpoint () = %s\n",
+  target_debug_printf_nofunc ("<- %s->have_steppable_watchpoint () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -1053,11 +1027,10 @@ dummy_target::stopped_data_address (CORE_ADDR *arg0)
 bool
 debug_target::stopped_data_address (CORE_ADDR *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->stopped_data_address (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->stopped_data_address (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->stopped_data_address (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->stopped_data_address (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->stopped_data_address (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR_p (arg0).c_str (),
 	      target_debug_print_bool (result).c_str ());
@@ -1079,11 +1052,10 @@ dummy_target::watchpoint_addr_within_range (CORE_ADDR arg0, CORE_ADDR arg1, int
 bool
 debug_target::watchpoint_addr_within_range (CORE_ADDR arg0, CORE_ADDR arg1, int arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->watchpoint_addr_within_range (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->watchpoint_addr_within_range (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->watchpoint_addr_within_range (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->watchpoint_addr_within_range (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->watchpoint_addr_within_range (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_CORE_ADDR (arg1).c_str (),
@@ -1107,11 +1079,10 @@ dummy_target::region_ok_for_hw_watchpoint (CORE_ADDR arg0, int arg1)
 int
 debug_target::region_ok_for_hw_watchpoint (CORE_ADDR arg0, int arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->region_ok_for_hw_watchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->region_ok_for_hw_watchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->region_ok_for_hw_watchpoint (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->region_ok_for_hw_watchpoint (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->region_ok_for_hw_watchpoint (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -1134,11 +1105,10 @@ dummy_target::can_accel_watchpoint_condition (CORE_ADDR arg0, int arg1, int arg2
 bool
 debug_target::can_accel_watchpoint_condition (CORE_ADDR arg0, int arg1, int arg2, struct expression *arg3)
 {
-  gdb_printf (gdb_stdlog, "-> %s->can_accel_watchpoint_condition (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->can_accel_watchpoint_condition (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->can_accel_watchpoint_condition (arg0, arg1, arg2, arg3);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->can_accel_watchpoint_condition (%s, %s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->can_accel_watchpoint_condition (%s, %s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -1163,11 +1133,10 @@ dummy_target::masked_watch_num_registers (CORE_ADDR arg0, CORE_ADDR arg1)
 int
 debug_target::masked_watch_num_registers (CORE_ADDR arg0, CORE_ADDR arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->masked_watch_num_registers (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->masked_watch_num_registers (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->masked_watch_num_registers (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->masked_watch_num_registers (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->masked_watch_num_registers (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_CORE_ADDR (arg1).c_str (),
@@ -1190,11 +1159,10 @@ dummy_target::can_do_single_step ()
 int
 debug_target::can_do_single_step ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->can_do_single_step (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->can_do_single_step (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->can_do_single_step ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->can_do_single_step () = %s\n",
+  target_debug_printf_nofunc ("<- %s->can_do_single_step () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (result).c_str ());
   return result;
@@ -1215,11 +1183,10 @@ dummy_target::supports_terminal_ours ()
 bool
 debug_target::supports_terminal_ours ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_terminal_ours (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_terminal_ours (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_terminal_ours ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_terminal_ours () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_terminal_ours () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -1239,10 +1206,9 @@ dummy_target::terminal_init ()
 void
 debug_target::terminal_init ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->terminal_init (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->terminal_init (...)", this->beneath ()->shortname ());
   this->beneath ()->terminal_init ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->terminal_init ()\n",
+  target_debug_printf_nofunc ("<- %s->terminal_init ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -1260,10 +1226,9 @@ dummy_target::terminal_inferior ()
 void
 debug_target::terminal_inferior ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->terminal_inferior (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->terminal_inferior (...)", this->beneath ()->shortname ());
   this->beneath ()->terminal_inferior ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->terminal_inferior ()\n",
+  target_debug_printf_nofunc ("<- %s->terminal_inferior ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -1281,10 +1246,9 @@ dummy_target::terminal_save_inferior ()
 void
 debug_target::terminal_save_inferior ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->terminal_save_inferior (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->terminal_save_inferior (...)", this->beneath ()->shortname ());
   this->beneath ()->terminal_save_inferior ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->terminal_save_inferior ()\n",
+  target_debug_printf_nofunc ("<- %s->terminal_save_inferior ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -1302,10 +1266,9 @@ dummy_target::terminal_ours_for_output ()
 void
 debug_target::terminal_ours_for_output ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->terminal_ours_for_output (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->terminal_ours_for_output (...)", this->beneath ()->shortname ());
   this->beneath ()->terminal_ours_for_output ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->terminal_ours_for_output ()\n",
+  target_debug_printf_nofunc ("<- %s->terminal_ours_for_output ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -1323,10 +1286,9 @@ dummy_target::terminal_ours ()
 void
 debug_target::terminal_ours ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->terminal_ours (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->terminal_ours (...)", this->beneath ()->shortname ());
   this->beneath ()->terminal_ours ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->terminal_ours ()\n",
+  target_debug_printf_nofunc ("<- %s->terminal_ours ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -1345,10 +1307,9 @@ dummy_target::terminal_info (const char *arg0, int arg1)
 void
 debug_target::terminal_info (const char *arg0, int arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->terminal_info (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->terminal_info (...)", this->beneath ()->shortname ());
   this->beneath ()->terminal_info (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->terminal_info (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->terminal_info (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str ());
@@ -1369,10 +1330,9 @@ dummy_target::kill ()
 void
 debug_target::kill ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->kill (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->kill (...)", this->beneath ()->shortname ());
   this->beneath ()->kill ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->kill ()\n",
+  target_debug_printf_nofunc ("<- %s->kill ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -1391,10 +1351,9 @@ dummy_target::load (const char *arg0, int arg1)
 void
 debug_target::load (const char *arg0, int arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->load (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->load (...)", this->beneath ()->shortname ());
   this->beneath ()->load (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->load (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->load (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str ());
@@ -1415,11 +1374,10 @@ dummy_target::insert_fork_catchpoint (int arg0)
 int
 debug_target::insert_fork_catchpoint (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->insert_fork_catchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->insert_fork_catchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->insert_fork_catchpoint (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->insert_fork_catchpoint (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->insert_fork_catchpoint (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -1441,11 +1399,10 @@ dummy_target::remove_fork_catchpoint (int arg0)
 int
 debug_target::remove_fork_catchpoint (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->remove_fork_catchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->remove_fork_catchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->remove_fork_catchpoint (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->remove_fork_catchpoint (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->remove_fork_catchpoint (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -1467,11 +1424,10 @@ dummy_target::insert_vfork_catchpoint (int arg0)
 int
 debug_target::insert_vfork_catchpoint (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->insert_vfork_catchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->insert_vfork_catchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->insert_vfork_catchpoint (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->insert_vfork_catchpoint (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->insert_vfork_catchpoint (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -1493,11 +1449,10 @@ dummy_target::remove_vfork_catchpoint (int arg0)
 int
 debug_target::remove_vfork_catchpoint (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->remove_vfork_catchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->remove_vfork_catchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->remove_vfork_catchpoint (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->remove_vfork_catchpoint (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->remove_vfork_catchpoint (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -1519,10 +1474,9 @@ dummy_target::follow_fork (inferior *arg0, ptid_t arg1, target_waitkind arg2, bo
 void
 debug_target::follow_fork (inferior *arg0, ptid_t arg1, target_waitkind arg2, bool arg3, bool arg4)
 {
-  gdb_printf (gdb_stdlog, "-> %s->follow_fork (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->follow_fork (...)", this->beneath ()->shortname ());
   this->beneath ()->follow_fork (arg0, arg1, arg2, arg3, arg4);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->follow_fork (%s, %s, %s, %s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->follow_fork (%s, %s, %s, %s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_inferior_p (arg0).c_str (),
 	      target_debug_print_ptid_t (arg1).c_str (),
@@ -1546,10 +1500,9 @@ dummy_target::follow_clone (ptid_t arg0)
 void
 debug_target::follow_clone (ptid_t arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->follow_clone (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->follow_clone (...)", this->beneath ()->shortname ());
   this->beneath ()->follow_clone (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->follow_clone (%s)\n",
+  target_debug_printf_nofunc ("<- %s->follow_clone (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str ());
 }
@@ -1569,11 +1522,10 @@ dummy_target::insert_exec_catchpoint (int arg0)
 int
 debug_target::insert_exec_catchpoint (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->insert_exec_catchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->insert_exec_catchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->insert_exec_catchpoint (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->insert_exec_catchpoint (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->insert_exec_catchpoint (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -1595,11 +1547,10 @@ dummy_target::remove_exec_catchpoint (int arg0)
 int
 debug_target::remove_exec_catchpoint (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->remove_exec_catchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->remove_exec_catchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->remove_exec_catchpoint (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->remove_exec_catchpoint (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->remove_exec_catchpoint (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -1620,10 +1571,9 @@ dummy_target::follow_exec (inferior *arg0, ptid_t arg1, const char *arg2)
 void
 debug_target::follow_exec (inferior *arg0, ptid_t arg1, const char *arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->follow_exec (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->follow_exec (...)", this->beneath ()->shortname ());
   this->beneath ()->follow_exec (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->follow_exec (%s, %s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->follow_exec (%s, %s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_inferior_p (arg0).c_str (),
 	      target_debug_print_ptid_t (arg1).c_str (),
@@ -1645,11 +1595,10 @@ dummy_target::set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_
 int
 debug_target::set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view<const int> arg3)
 {
-  gdb_printf (gdb_stdlog, "-> %s->set_syscall_catchpoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->set_syscall_catchpoint (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->set_syscall_catchpoint (arg0, arg1, arg2, arg3);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->set_syscall_catchpoint (%s, %s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->set_syscall_catchpoint (%s, %s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_bool (arg1).c_str (),
@@ -1674,10 +1623,9 @@ dummy_target::mourn_inferior ()
 void
 debug_target::mourn_inferior ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->mourn_inferior (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->mourn_inferior (...)", this->beneath ()->shortname ());
   this->beneath ()->mourn_inferior ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->mourn_inferior ()\n",
+  target_debug_printf_nofunc ("<- %s->mourn_inferior ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -1695,10 +1643,9 @@ dummy_target::pass_signals (gdb::array_view<const unsigned char> arg0)
 void
 debug_target::pass_signals (gdb::array_view<const unsigned char> arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->pass_signals (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->pass_signals (...)", this->beneath ()->shortname ());
   this->beneath ()->pass_signals (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->pass_signals (%s)\n",
+  target_debug_printf_nofunc ("<- %s->pass_signals (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_signals (arg0).c_str ());
 }
@@ -1717,10 +1664,9 @@ dummy_target::program_signals (gdb::array_view<const unsigned char> arg0)
 void
 debug_target::program_signals (gdb::array_view<const unsigned char> arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->program_signals (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->program_signals (...)", this->beneath ()->shortname ());
   this->beneath ()->program_signals (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->program_signals (%s)\n",
+  target_debug_printf_nofunc ("<- %s->program_signals (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_signals (arg0).c_str ());
 }
@@ -1740,11 +1686,10 @@ dummy_target::thread_alive (ptid_t arg0)
 bool
 debug_target::thread_alive (ptid_t arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->thread_alive (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->thread_alive (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->thread_alive (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->thread_alive (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->thread_alive (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_bool (result).c_str ());
@@ -1765,10 +1710,9 @@ dummy_target::update_thread_list ()
 void
 debug_target::update_thread_list ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->update_thread_list (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->update_thread_list (...)", this->beneath ()->shortname ());
   this->beneath ()->update_thread_list ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->update_thread_list ()\n",
+  target_debug_printf_nofunc ("<- %s->update_thread_list ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -1787,11 +1731,10 @@ dummy_target::pid_to_str (ptid_t arg0)
 std::string
 debug_target::pid_to_str (ptid_t arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->pid_to_str (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->pid_to_str (...)", this->beneath ()->shortname ());
   std::string result
     = this->beneath ()->pid_to_str (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->pid_to_str (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->pid_to_str (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_std_string (result).c_str ());
@@ -1813,11 +1756,10 @@ dummy_target::extra_thread_info (thread_info *arg0)
 const char *
 debug_target::extra_thread_info (thread_info *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->extra_thread_info (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->extra_thread_info (...)", this->beneath ()->shortname ());
   const char * result
     = this->beneath ()->extra_thread_info (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->extra_thread_info (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->extra_thread_info (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_thread_info_p (arg0).c_str (),
 	      target_debug_print_const_char_p (result).c_str ());
@@ -1839,11 +1781,10 @@ dummy_target::thread_name (thread_info *arg0)
 const char *
 debug_target::thread_name (thread_info *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->thread_name (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->thread_name (...)", this->beneath ()->shortname ());
   const char * result
     = this->beneath ()->thread_name (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->thread_name (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->thread_name (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_thread_info_p (arg0).c_str (),
 	      target_debug_print_const_char_p (result).c_str ());
@@ -1865,11 +1806,10 @@ dummy_target::thread_handle_to_thread_info (const gdb_byte *arg0, int arg1, infe
 thread_info *
 debug_target::thread_handle_to_thread_info (const gdb_byte *arg0, int arg1, inferior *arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->thread_handle_to_thread_info (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->thread_handle_to_thread_info (...)", this->beneath ()->shortname ());
   thread_info * result
     = this->beneath ()->thread_handle_to_thread_info (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->thread_handle_to_thread_info (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->thread_handle_to_thread_info (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_gdb_byte_p (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -1893,11 +1833,10 @@ dummy_target::thread_info_to_thread_handle (struct thread_info *arg0)
 gdb::array_view<const_gdb_byte>
 debug_target::thread_info_to_thread_handle (struct thread_info *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->thread_info_to_thread_handle (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->thread_info_to_thread_handle (...)", this->beneath ()->shortname ());
   gdb::array_view<const_gdb_byte> result
     = this->beneath ()->thread_info_to_thread_handle (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->thread_info_to_thread_handle (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->thread_info_to_thread_handle (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_thread_info_p (arg0).c_str (),
 	      target_debug_print_gdb_array_view_const_gdb_byte (result).c_str ());
@@ -1918,10 +1857,9 @@ dummy_target::stop (ptid_t arg0)
 void
 debug_target::stop (ptid_t arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->stop (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->stop (...)", this->beneath ()->shortname ());
   this->beneath ()->stop (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->stop (%s)\n",
+  target_debug_printf_nofunc ("<- %s->stop (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str ());
 }
@@ -1940,10 +1878,9 @@ dummy_target::interrupt ()
 void
 debug_target::interrupt ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->interrupt (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->interrupt (...)", this->beneath ()->shortname ());
   this->beneath ()->interrupt ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->interrupt ()\n",
+  target_debug_printf_nofunc ("<- %s->interrupt ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -1962,10 +1899,9 @@ dummy_target::pass_ctrlc ()
 void
 debug_target::pass_ctrlc ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->pass_ctrlc (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->pass_ctrlc (...)", this->beneath ()->shortname ());
   this->beneath ()->pass_ctrlc ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->pass_ctrlc ()\n",
+  target_debug_printf_nofunc ("<- %s->pass_ctrlc ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -1984,10 +1920,9 @@ dummy_target::rcmd (const char *arg0, struct ui_file *arg1)
 void
 debug_target::rcmd (const char *arg0, struct ui_file *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->rcmd (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->rcmd (...)", this->beneath ()->shortname ());
   this->beneath ()->rcmd (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->rcmd (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->rcmd (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str (),
 	      target_debug_print_ui_file_p (arg1).c_str ());
@@ -2008,11 +1943,10 @@ dummy_target::pid_to_exec_file (int arg0)
 const char *
 debug_target::pid_to_exec_file (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->pid_to_exec_file (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->pid_to_exec_file (...)", this->beneath ()->shortname ());
   const char * result
     = this->beneath ()->pid_to_exec_file (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->pid_to_exec_file (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->pid_to_exec_file (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_const_char_p (result).c_str ());
@@ -2033,10 +1967,9 @@ dummy_target::log_command (const char *arg0)
 void
 debug_target::log_command (const char *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->log_command (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->log_command (...)", this->beneath ()->shortname ());
   this->beneath ()->log_command (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->log_command (%s)\n",
+  target_debug_printf_nofunc ("<- %s->log_command (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str ());
 }
@@ -2056,11 +1989,10 @@ dummy_target::get_section_table ()
 const std::vector<target_section> *
 debug_target::get_section_table ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_section_table (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_section_table (...)", this->beneath ()->shortname ());
   const std::vector<target_section> * result
     = this->beneath ()->get_section_table ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_section_table () = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_section_table () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_std_vector_target_section_p (result).c_str ());
   return result;
@@ -2081,11 +2013,10 @@ dummy_target::get_thread_control_capabilities ()
 thread_control_capabilities
 debug_target::get_thread_control_capabilities ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_thread_control_capabilities (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_thread_control_capabilities (...)", this->beneath ()->shortname ());
   thread_control_capabilities result
     = this->beneath ()->get_thread_control_capabilities ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_thread_control_capabilities () = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_thread_control_capabilities () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_thread_control_capabilities (result).c_str ());
   return result;
@@ -2106,11 +2037,10 @@ dummy_target::attach_no_wait ()
 bool
 debug_target::attach_no_wait ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->attach_no_wait (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->attach_no_wait (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->attach_no_wait ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->attach_no_wait () = %s\n",
+  target_debug_printf_nofunc ("<- %s->attach_no_wait () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2131,11 +2061,10 @@ dummy_target::can_async_p ()
 bool
 debug_target::can_async_p ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->can_async_p (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->can_async_p (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->can_async_p ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->can_async_p () = %s\n",
+  target_debug_printf_nofunc ("<- %s->can_async_p () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2156,11 +2085,10 @@ dummy_target::is_async_p ()
 bool
 debug_target::is_async_p ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->is_async_p (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->is_async_p (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->is_async_p ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->is_async_p () = %s\n",
+  target_debug_printf_nofunc ("<- %s->is_async_p () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2181,10 +2109,9 @@ dummy_target::async (bool arg0)
 void
 debug_target::async (bool arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->async (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->async (...)", this->beneath ()->shortname ());
   this->beneath ()->async (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->async (%s)\n",
+  target_debug_printf_nofunc ("<- %s->async (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (arg0).c_str ());
 }
@@ -2204,11 +2131,10 @@ dummy_target::async_wait_fd ()
 int
 debug_target::async_wait_fd ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->async_wait_fd (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->async_wait_fd (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->async_wait_fd ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->async_wait_fd () = %s\n",
+  target_debug_printf_nofunc ("<- %s->async_wait_fd () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (result).c_str ());
   return result;
@@ -2229,11 +2155,10 @@ dummy_target::has_pending_events ()
 bool
 debug_target::has_pending_events ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->has_pending_events (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->has_pending_events (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->has_pending_events ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->has_pending_events () = %s\n",
+  target_debug_printf_nofunc ("<- %s->has_pending_events () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2253,10 +2178,9 @@ dummy_target::thread_events (int arg0)
 void
 debug_target::thread_events (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->thread_events (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->thread_events (...)", this->beneath ()->shortname ());
   this->beneath ()->thread_events (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->thread_events (%s)\n",
+  target_debug_printf_nofunc ("<- %s->thread_events (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str ());
 }
@@ -2276,11 +2200,10 @@ dummy_target::supports_set_thread_options (gdb_thread_options arg0)
 bool
 debug_target::supports_set_thread_options (gdb_thread_options arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_set_thread_options (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_set_thread_options (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_set_thread_options (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_set_thread_options (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_set_thread_options (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_gdb_thread_options (arg0).c_str (),
 	      target_debug_print_bool (result).c_str ());
@@ -2302,11 +2225,10 @@ dummy_target::supports_non_stop ()
 bool
 debug_target::supports_non_stop ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_non_stop (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_non_stop (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_non_stop ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_non_stop () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_non_stop () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2327,11 +2249,10 @@ dummy_target::always_non_stop_p ()
 bool
 debug_target::always_non_stop_p ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->always_non_stop_p (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->always_non_stop_p (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->always_non_stop_p ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->always_non_stop_p () = %s\n",
+  target_debug_printf_nofunc ("<- %s->always_non_stop_p () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2352,11 +2273,10 @@ dummy_target::find_memory_regions (find_memory_region_ftype arg0, void *arg1)
 int
 debug_target::find_memory_regions (find_memory_region_ftype arg0, void *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->find_memory_regions (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->find_memory_regions (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->find_memory_regions (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->find_memory_regions (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->find_memory_regions (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_find_memory_region_ftype (arg0).c_str (),
 	      target_debug_print_void_p (arg1).c_str (),
@@ -2379,11 +2299,10 @@ dummy_target::make_corefile_notes (bfd *arg0, int *arg1)
 gdb::unique_xmalloc_ptr<char>
 debug_target::make_corefile_notes (bfd *arg0, int *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->make_corefile_notes (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->make_corefile_notes (...)", this->beneath ()->shortname ());
   gdb::unique_xmalloc_ptr<char> result
     = this->beneath ()->make_corefile_notes (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->make_corefile_notes (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->make_corefile_notes (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bfd_p (arg0).c_str (),
 	      target_debug_print_int_p (arg1).c_str (),
@@ -2406,11 +2325,10 @@ dummy_target::get_bookmark (const char *arg0, int arg1)
 gdb_byte *
 debug_target::get_bookmark (const char *arg0, int arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_bookmark (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_bookmark (...)", this->beneath ()->shortname ());
   gdb_byte * result
     = this->beneath ()->get_bookmark (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_bookmark (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_bookmark (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -2433,10 +2351,9 @@ dummy_target::goto_bookmark (const gdb_byte *arg0, int arg1)
 void
 debug_target::goto_bookmark (const gdb_byte *arg0, int arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->goto_bookmark (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->goto_bookmark (...)", this->beneath ()->shortname ());
   this->beneath ()->goto_bookmark (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->goto_bookmark (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->goto_bookmark (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_gdb_byte_p (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str ());
@@ -2457,11 +2374,10 @@ dummy_target::get_thread_local_address (ptid_t arg0, CORE_ADDR arg1, CORE_ADDR a
 CORE_ADDR
 debug_target::get_thread_local_address (ptid_t arg0, CORE_ADDR arg1, CORE_ADDR arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_thread_local_address (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_thread_local_address (...)", this->beneath ()->shortname ());
   CORE_ADDR result
     = this->beneath ()->get_thread_local_address (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_thread_local_address (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_thread_local_address (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_CORE_ADDR (arg1).c_str (),
@@ -2485,11 +2401,10 @@ dummy_target::xfer_partial (enum target_object arg0, const char *arg1, gdb_byte
 enum target_xfer_status
 debug_target::xfer_partial (enum target_object arg0, const char *arg1, gdb_byte *arg2, const gdb_byte *arg3, ULONGEST arg4, ULONGEST arg5, ULONGEST *arg6)
 {
-  gdb_printf (gdb_stdlog, "-> %s->xfer_partial (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->xfer_partial (...)", this->beneath ()->shortname ());
   enum target_xfer_status result
     = this->beneath ()->xfer_partial (arg0, arg1, arg2, arg3, arg4, arg5, arg6);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->xfer_partial (%s, %s, %s, %s, %s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->xfer_partial (%s, %s, %s, %s, %s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_target_object (arg0).c_str (),
 	      target_debug_print_const_char_p (arg1).c_str (),
@@ -2517,11 +2432,10 @@ dummy_target::get_memory_xfer_limit ()
 ULONGEST
 debug_target::get_memory_xfer_limit ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_memory_xfer_limit (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_memory_xfer_limit (...)", this->beneath ()->shortname ());
   ULONGEST result
     = this->beneath ()->get_memory_xfer_limit ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_memory_xfer_limit () = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_memory_xfer_limit () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ULONGEST (result).c_str ());
   return result;
@@ -2542,11 +2456,10 @@ dummy_target::memory_map ()
 std::vector<mem_region>
 debug_target::memory_map ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->memory_map (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->memory_map (...)", this->beneath ()->shortname ());
   std::vector<mem_region> result
     = this->beneath ()->memory_map ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->memory_map () = %s\n",
+  target_debug_printf_nofunc ("<- %s->memory_map () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_std_vector_mem_region (result).c_str ());
   return result;
@@ -2567,10 +2480,9 @@ dummy_target::flash_erase (ULONGEST arg0, LONGEST arg1)
 void
 debug_target::flash_erase (ULONGEST arg0, LONGEST arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->flash_erase (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->flash_erase (...)", this->beneath ()->shortname ());
   this->beneath ()->flash_erase (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->flash_erase (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->flash_erase (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ULONGEST (arg0).c_str (),
 	      target_debug_print_LONGEST (arg1).c_str ());
@@ -2591,10 +2503,9 @@ dummy_target::flash_done ()
 void
 debug_target::flash_done ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->flash_done (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->flash_done (...)", this->beneath ()->shortname ());
   this->beneath ()->flash_done ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->flash_done ()\n",
+  target_debug_printf_nofunc ("<- %s->flash_done ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -2613,11 +2524,10 @@ dummy_target::read_description ()
 const struct target_desc *
 debug_target::read_description ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->read_description (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->read_description (...)", this->beneath ()->shortname ());
   const struct target_desc * result
     = this->beneath ()->read_description ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->read_description () = %s\n",
+  target_debug_printf_nofunc ("<- %s->read_description () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_target_desc_p (result).c_str ());
   return result;
@@ -2638,11 +2548,10 @@ dummy_target::get_ada_task_ptid (long arg0, ULONGEST arg1)
 ptid_t
 debug_target::get_ada_task_ptid (long arg0, ULONGEST arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_ada_task_ptid (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_ada_task_ptid (...)", this->beneath ()->shortname ());
   ptid_t result
     = this->beneath ()->get_ada_task_ptid (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_ada_task_ptid (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_ada_task_ptid (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_long (arg0).c_str (),
 	      target_debug_print_ULONGEST (arg1).c_str (),
@@ -2665,11 +2574,10 @@ dummy_target::auxv_parse (const gdb_byte **arg0, const gdb_byte *arg1, CORE_ADDR
 int
 debug_target::auxv_parse (const gdb_byte **arg0, const gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3)
 {
-  gdb_printf (gdb_stdlog, "-> %s->auxv_parse (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->auxv_parse (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->auxv_parse (arg0, arg1, arg2, arg3);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->auxv_parse (%s, %s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->auxv_parse (%s, %s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_gdb_byte_pp (arg0).c_str (),
 	      target_debug_print_const_gdb_byte_p (arg1).c_str (),
@@ -2694,11 +2602,10 @@ dummy_target::search_memory (CORE_ADDR arg0, ULONGEST arg1, const gdb_byte *arg2
 int
 debug_target::search_memory (CORE_ADDR arg0, ULONGEST arg1, const gdb_byte *arg2, ULONGEST arg3, CORE_ADDR *arg4)
 {
-  gdb_printf (gdb_stdlog, "-> %s->search_memory (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->search_memory (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->search_memory (arg0, arg1, arg2, arg3, arg4);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->search_memory (%s, %s, %s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->search_memory (%s, %s, %s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_ULONGEST (arg1).c_str (),
@@ -2724,11 +2631,10 @@ dummy_target::can_execute_reverse ()
 bool
 debug_target::can_execute_reverse ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->can_execute_reverse (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->can_execute_reverse (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->can_execute_reverse ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->can_execute_reverse () = %s\n",
+  target_debug_printf_nofunc ("<- %s->can_execute_reverse () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2749,11 +2655,10 @@ dummy_target::execution_direction ()
 enum exec_direction_kind
 debug_target::execution_direction ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->execution_direction (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->execution_direction (...)", this->beneath ()->shortname ());
   enum exec_direction_kind result
     = this->beneath ()->execution_direction ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->execution_direction () = %s\n",
+  target_debug_printf_nofunc ("<- %s->execution_direction () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_exec_direction_kind (result).c_str ());
   return result;
@@ -2774,11 +2679,10 @@ dummy_target::supports_multi_process ()
 bool
 debug_target::supports_multi_process ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_multi_process (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_multi_process (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_multi_process ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_multi_process () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_multi_process () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2799,11 +2703,10 @@ dummy_target::supports_enable_disable_tracepoint ()
 bool
 debug_target::supports_enable_disable_tracepoint ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_enable_disable_tracepoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_enable_disable_tracepoint (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_enable_disable_tracepoint ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_enable_disable_tracepoint () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_enable_disable_tracepoint () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2824,11 +2727,10 @@ dummy_target::supports_disable_randomization ()
 bool
 debug_target::supports_disable_randomization ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_disable_randomization (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_disable_randomization (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_disable_randomization ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_disable_randomization () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_disable_randomization () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2849,11 +2751,10 @@ dummy_target::supports_string_tracing ()
 bool
 debug_target::supports_string_tracing ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_string_tracing (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_string_tracing (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_string_tracing ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_string_tracing () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_string_tracing () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2874,11 +2775,10 @@ dummy_target::supports_evaluation_of_breakpoint_conditions ()
 bool
 debug_target::supports_evaluation_of_breakpoint_conditions ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_evaluation_of_breakpoint_conditions (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_evaluation_of_breakpoint_conditions (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_evaluation_of_breakpoint_conditions ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_evaluation_of_breakpoint_conditions () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_evaluation_of_breakpoint_conditions () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2899,11 +2799,10 @@ dummy_target::supports_dumpcore ()
 bool
 debug_target::supports_dumpcore ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_dumpcore (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_dumpcore (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_dumpcore ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_dumpcore () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_dumpcore () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2923,10 +2822,9 @@ dummy_target::dumpcore (const char *arg0)
 void
 debug_target::dumpcore (const char *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->dumpcore (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->dumpcore (...)", this->beneath ()->shortname ());
   this->beneath ()->dumpcore (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->dumpcore (%s)\n",
+  target_debug_printf_nofunc ("<- %s->dumpcore (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str ());
 }
@@ -2946,11 +2844,10 @@ dummy_target::can_run_breakpoint_commands ()
 bool
 debug_target::can_run_breakpoint_commands ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->can_run_breakpoint_commands (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->can_run_breakpoint_commands (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->can_run_breakpoint_commands ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->can_run_breakpoint_commands () = %s\n",
+  target_debug_printf_nofunc ("<- %s->can_run_breakpoint_commands () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -2971,11 +2868,10 @@ dummy_target::thread_architecture (ptid_t arg0)
 struct gdbarch *
 debug_target::thread_architecture (ptid_t arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->thread_architecture (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->thread_architecture (...)", this->beneath ()->shortname ());
   struct gdbarch * result
     = this->beneath ()->thread_architecture (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->thread_architecture (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->thread_architecture (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_gdbarch_p (result).c_str ());
@@ -2997,11 +2893,10 @@ dummy_target::filesystem_is_local ()
 bool
 debug_target::filesystem_is_local ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->filesystem_is_local (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->filesystem_is_local (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->filesystem_is_local ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->filesystem_is_local () = %s\n",
+  target_debug_printf_nofunc ("<- %s->filesystem_is_local () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -3022,10 +2917,9 @@ dummy_target::trace_init ()
 void
 debug_target::trace_init ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->trace_init (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->trace_init (...)", this->beneath ()->shortname ());
   this->beneath ()->trace_init ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->trace_init ()\n",
+  target_debug_printf_nofunc ("<- %s->trace_init ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -3044,10 +2938,9 @@ dummy_target::download_tracepoint (struct bp_location *arg0)
 void
 debug_target::download_tracepoint (struct bp_location *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->download_tracepoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->download_tracepoint (...)", this->beneath ()->shortname ());
   this->beneath ()->download_tracepoint (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->download_tracepoint (%s)\n",
+  target_debug_printf_nofunc ("<- %s->download_tracepoint (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bp_location_p (arg0).c_str ());
 }
@@ -3067,11 +2960,10 @@ dummy_target::can_download_tracepoint ()
 bool
 debug_target::can_download_tracepoint ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->can_download_tracepoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->can_download_tracepoint (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->can_download_tracepoint ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->can_download_tracepoint () = %s\n",
+  target_debug_printf_nofunc ("<- %s->can_download_tracepoint () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -3092,10 +2984,9 @@ dummy_target::download_trace_state_variable (const trace_state_variable &arg0)
 void
 debug_target::download_trace_state_variable (const trace_state_variable &arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->download_trace_state_variable (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->download_trace_state_variable (...)", this->beneath ()->shortname ());
   this->beneath ()->download_trace_state_variable (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->download_trace_state_variable (%s)\n",
+  target_debug_printf_nofunc ("<- %s->download_trace_state_variable (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_trace_state_variable_r (arg0).c_str ());
 }
@@ -3115,10 +3006,9 @@ dummy_target::enable_tracepoint (struct bp_location *arg0)
 void
 debug_target::enable_tracepoint (struct bp_location *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->enable_tracepoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->enable_tracepoint (...)", this->beneath ()->shortname ());
   this->beneath ()->enable_tracepoint (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->enable_tracepoint (%s)\n",
+  target_debug_printf_nofunc ("<- %s->enable_tracepoint (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bp_location_p (arg0).c_str ());
 }
@@ -3138,10 +3028,9 @@ dummy_target::disable_tracepoint (struct bp_location *arg0)
 void
 debug_target::disable_tracepoint (struct bp_location *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->disable_tracepoint (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->disable_tracepoint (...)", this->beneath ()->shortname ());
   this->beneath ()->disable_tracepoint (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->disable_tracepoint (%s)\n",
+  target_debug_printf_nofunc ("<- %s->disable_tracepoint (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bp_location_p (arg0).c_str ());
 }
@@ -3161,10 +3050,9 @@ dummy_target::trace_set_readonly_regions ()
 void
 debug_target::trace_set_readonly_regions ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->trace_set_readonly_regions (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->trace_set_readonly_regions (...)", this->beneath ()->shortname ());
   this->beneath ()->trace_set_readonly_regions ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->trace_set_readonly_regions ()\n",
+  target_debug_printf_nofunc ("<- %s->trace_set_readonly_regions ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -3183,10 +3071,9 @@ dummy_target::trace_start ()
 void
 debug_target::trace_start ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->trace_start (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->trace_start (...)", this->beneath ()->shortname ());
   this->beneath ()->trace_start ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->trace_start ()\n",
+  target_debug_printf_nofunc ("<- %s->trace_start ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -3205,11 +3092,10 @@ dummy_target::get_trace_status (struct trace_status *arg0)
 int
 debug_target::get_trace_status (struct trace_status *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_trace_status (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_trace_status (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->get_trace_status (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_trace_status (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_trace_status (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_trace_status_p (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -3231,10 +3117,9 @@ dummy_target::get_tracepoint_status (tracepoint *arg0, struct uploaded_tp *arg1)
 void
 debug_target::get_tracepoint_status (tracepoint *arg0, struct uploaded_tp *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_tracepoint_status (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_tracepoint_status (...)", this->beneath ()->shortname ());
   this->beneath ()->get_tracepoint_status (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_tracepoint_status (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->get_tracepoint_status (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_tracepoint_p (arg0).c_str (),
 	      target_debug_print_uploaded_tp_p (arg1).c_str ());
@@ -3255,10 +3140,9 @@ dummy_target::trace_stop ()
 void
 debug_target::trace_stop ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->trace_stop (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->trace_stop (...)", this->beneath ()->shortname ());
   this->beneath ()->trace_stop ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->trace_stop ()\n",
+  target_debug_printf_nofunc ("<- %s->trace_stop ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -3277,11 +3161,10 @@ dummy_target::trace_find (enum trace_find_type arg0, int arg1, CORE_ADDR arg2, C
 int
 debug_target::trace_find (enum trace_find_type arg0, int arg1, CORE_ADDR arg2, CORE_ADDR arg3, int *arg4)
 {
-  gdb_printf (gdb_stdlog, "-> %s->trace_find (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->trace_find (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->trace_find (arg0, arg1, arg2, arg3, arg4);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->trace_find (%s, %s, %s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->trace_find (%s, %s, %s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_trace_find_type (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -3307,11 +3190,10 @@ dummy_target::get_trace_state_variable_value (int arg0, LONGEST *arg1)
 bool
 debug_target::get_trace_state_variable_value (int arg0, LONGEST *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_trace_state_variable_value (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_trace_state_variable_value (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->get_trace_state_variable_value (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_trace_state_variable_value (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_trace_state_variable_value (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_LONGEST_p (arg1).c_str (),
@@ -3334,11 +3216,10 @@ dummy_target::save_trace_data (const char *arg0)
 int
 debug_target::save_trace_data (const char *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->save_trace_data (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->save_trace_data (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->save_trace_data (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->save_trace_data (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->save_trace_data (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -3360,11 +3241,10 @@ dummy_target::upload_tracepoints (struct uploaded_tp **arg0)
 int
 debug_target::upload_tracepoints (struct uploaded_tp **arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->upload_tracepoints (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->upload_tracepoints (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->upload_tracepoints (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->upload_tracepoints (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->upload_tracepoints (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_uploaded_tp_pp (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -3386,11 +3266,10 @@ dummy_target::upload_trace_state_variables (struct uploaded_tsv **arg0)
 int
 debug_target::upload_trace_state_variables (struct uploaded_tsv **arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->upload_trace_state_variables (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->upload_trace_state_variables (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->upload_trace_state_variables (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->upload_trace_state_variables (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->upload_trace_state_variables (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_uploaded_tsv_pp (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -3412,11 +3291,10 @@ dummy_target::get_raw_trace_data (gdb_byte *arg0, ULONGEST arg1, LONGEST arg2)
 LONGEST
 debug_target::get_raw_trace_data (gdb_byte *arg0, ULONGEST arg1, LONGEST arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_raw_trace_data (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_raw_trace_data (...)", this->beneath ()->shortname ());
   LONGEST result
     = this->beneath ()->get_raw_trace_data (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_raw_trace_data (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_raw_trace_data (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_gdb_byte_p (arg0).c_str (),
 	      target_debug_print_ULONGEST (arg1).c_str (),
@@ -3440,11 +3318,10 @@ dummy_target::get_min_fast_tracepoint_insn_len ()
 int
 debug_target::get_min_fast_tracepoint_insn_len ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_min_fast_tracepoint_insn_len (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_min_fast_tracepoint_insn_len (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->get_min_fast_tracepoint_insn_len ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_min_fast_tracepoint_insn_len () = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_min_fast_tracepoint_insn_len () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (result).c_str ());
   return result;
@@ -3464,10 +3341,9 @@ dummy_target::set_disconnected_tracing (int arg0)
 void
 debug_target::set_disconnected_tracing (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->set_disconnected_tracing (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->set_disconnected_tracing (...)", this->beneath ()->shortname ());
   this->beneath ()->set_disconnected_tracing (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->set_disconnected_tracing (%s)\n",
+  target_debug_printf_nofunc ("<- %s->set_disconnected_tracing (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str ());
 }
@@ -3486,10 +3362,9 @@ dummy_target::set_circular_trace_buffer (int arg0)
 void
 debug_target::set_circular_trace_buffer (int arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->set_circular_trace_buffer (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->set_circular_trace_buffer (...)", this->beneath ()->shortname ());
   this->beneath ()->set_circular_trace_buffer (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->set_circular_trace_buffer (%s)\n",
+  target_debug_printf_nofunc ("<- %s->set_circular_trace_buffer (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str ());
 }
@@ -3508,10 +3383,9 @@ dummy_target::set_trace_buffer_size (LONGEST arg0)
 void
 debug_target::set_trace_buffer_size (LONGEST arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->set_trace_buffer_size (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->set_trace_buffer_size (...)", this->beneath ()->shortname ());
   this->beneath ()->set_trace_buffer_size (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->set_trace_buffer_size (%s)\n",
+  target_debug_printf_nofunc ("<- %s->set_trace_buffer_size (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_LONGEST (arg0).c_str ());
 }
@@ -3531,11 +3405,10 @@ dummy_target::set_trace_notes (const char *arg0, const char *arg1, const char *a
 bool
 debug_target::set_trace_notes (const char *arg0, const char *arg1, const char *arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->set_trace_notes (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->set_trace_notes (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->set_trace_notes (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->set_trace_notes (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->set_trace_notes (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str (),
 	      target_debug_print_const_char_p (arg1).c_str (),
@@ -3559,11 +3432,10 @@ dummy_target::core_of_thread (ptid_t arg0)
 int
 debug_target::core_of_thread (ptid_t arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->core_of_thread (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->core_of_thread (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->core_of_thread (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->core_of_thread (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->core_of_thread (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_int (result).c_str ());
@@ -3585,11 +3457,10 @@ dummy_target::verify_memory (const gdb_byte *arg0, CORE_ADDR arg1, ULONGEST arg2
 int
 debug_target::verify_memory (const gdb_byte *arg0, CORE_ADDR arg1, ULONGEST arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->verify_memory (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->verify_memory (...)", this->beneath ()->shortname ());
   int result
     = this->beneath ()->verify_memory (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->verify_memory (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->verify_memory (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_gdb_byte_p (arg0).c_str (),
 	      target_debug_print_CORE_ADDR (arg1).c_str (),
@@ -3613,11 +3484,10 @@ dummy_target::get_tib_address (ptid_t arg0, CORE_ADDR *arg1)
 bool
 debug_target::get_tib_address (ptid_t arg0, CORE_ADDR *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_tib_address (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_tib_address (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->get_tib_address (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_tib_address (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_tib_address (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_CORE_ADDR_p (arg1).c_str (),
@@ -3639,10 +3509,9 @@ dummy_target::set_permissions ()
 void
 debug_target::set_permissions ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->set_permissions (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->set_permissions (...)", this->beneath ()->shortname ());
   this->beneath ()->set_permissions ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->set_permissions ()\n",
+  target_debug_printf_nofunc ("<- %s->set_permissions ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -3661,11 +3530,10 @@ dummy_target::static_tracepoint_marker_at (CORE_ADDR arg0, static_tracepoint_mar
 bool
 debug_target::static_tracepoint_marker_at (CORE_ADDR arg0, static_tracepoint_marker *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->static_tracepoint_marker_at (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->static_tracepoint_marker_at (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->static_tracepoint_marker_at (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->static_tracepoint_marker_at (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->static_tracepoint_marker_at (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_static_tracepoint_marker_p (arg1).c_str (),
@@ -3688,11 +3556,10 @@ dummy_target::static_tracepoint_markers_by_strid (const char *arg0)
 std::vector<static_tracepoint_marker>
 debug_target::static_tracepoint_markers_by_strid (const char *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->static_tracepoint_markers_by_strid (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->static_tracepoint_markers_by_strid (...)", this->beneath ()->shortname ());
   std::vector<static_tracepoint_marker> result
     = this->beneath ()->static_tracepoint_markers_by_strid (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->static_tracepoint_markers_by_strid (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->static_tracepoint_markers_by_strid (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str (),
 	      target_debug_print_std_vector_static_tracepoint_marker (result).c_str ());
@@ -3714,11 +3581,10 @@ dummy_target::traceframe_info ()
 traceframe_info_up
 debug_target::traceframe_info ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->traceframe_info (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->traceframe_info (...)", this->beneath ()->shortname ());
   traceframe_info_up result
     = this->beneath ()->traceframe_info ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->traceframe_info () = %s\n",
+  target_debug_printf_nofunc ("<- %s->traceframe_info () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_traceframe_info_up (result).c_str ());
   return result;
@@ -3739,11 +3605,10 @@ dummy_target::use_agent (bool arg0)
 bool
 debug_target::use_agent (bool arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->use_agent (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->use_agent (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->use_agent (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->use_agent (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->use_agent (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (arg0).c_str (),
 	      target_debug_print_bool (result).c_str ());
@@ -3765,11 +3630,10 @@ dummy_target::can_use_agent ()
 bool
 debug_target::can_use_agent ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->can_use_agent (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->can_use_agent (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->can_use_agent ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->can_use_agent () = %s\n",
+  target_debug_printf_nofunc ("<- %s->can_use_agent () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -3790,11 +3654,10 @@ dummy_target::enable_btrace (thread_info *arg0, const struct btrace_config *arg1
 struct btrace_target_info *
 debug_target::enable_btrace (thread_info *arg0, const struct btrace_config *arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->enable_btrace (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->enable_btrace (...)", this->beneath ()->shortname ());
   struct btrace_target_info * result
     = this->beneath ()->enable_btrace (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->enable_btrace (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->enable_btrace (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_thread_info_p (arg0).c_str (),
 	      target_debug_print_const_btrace_config_p (arg1).c_str (),
@@ -3817,10 +3680,9 @@ dummy_target::disable_btrace (struct btrace_target_info *arg0)
 void
 debug_target::disable_btrace (struct btrace_target_info *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->disable_btrace (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->disable_btrace (...)", this->beneath ()->shortname ());
   this->beneath ()->disable_btrace (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->disable_btrace (%s)\n",
+  target_debug_printf_nofunc ("<- %s->disable_btrace (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_btrace_target_info_p (arg0).c_str ());
 }
@@ -3840,10 +3702,9 @@ dummy_target::teardown_btrace (struct btrace_target_info *arg0)
 void
 debug_target::teardown_btrace (struct btrace_target_info *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->teardown_btrace (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->teardown_btrace (...)", this->beneath ()->shortname ());
   this->beneath ()->teardown_btrace (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->teardown_btrace (%s)\n",
+  target_debug_printf_nofunc ("<- %s->teardown_btrace (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_btrace_target_info_p (arg0).c_str ());
 }
@@ -3863,11 +3724,10 @@ dummy_target::read_btrace (struct btrace_data *arg0, struct btrace_target_info *
 enum btrace_error
 debug_target::read_btrace (struct btrace_data *arg0, struct btrace_target_info *arg1, enum btrace_read_type arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->read_btrace (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->read_btrace (...)", this->beneath ()->shortname ());
   enum btrace_error result
     = this->beneath ()->read_btrace (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->read_btrace (%s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->read_btrace (%s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_btrace_data_p (arg0).c_str (),
 	      target_debug_print_btrace_target_info_p (arg1).c_str (),
@@ -3891,11 +3751,10 @@ dummy_target::btrace_conf (const struct btrace_target_info *arg0)
 const struct btrace_config *
 debug_target::btrace_conf (const struct btrace_target_info *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->btrace_conf (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->btrace_conf (...)", this->beneath ()->shortname ());
   const struct btrace_config * result
     = this->beneath ()->btrace_conf (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->btrace_conf (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->btrace_conf (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_btrace_target_info_p (arg0).c_str (),
 	      target_debug_print_const_btrace_config_p (result).c_str ());
@@ -3917,11 +3776,10 @@ dummy_target::record_method (ptid_t arg0)
 enum record_method
 debug_target::record_method (ptid_t arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->record_method (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->record_method (...)", this->beneath ()->shortname ());
   enum record_method result
     = this->beneath ()->record_method (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->record_method (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->record_method (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_record_method (result).c_str ());
@@ -3942,10 +3800,9 @@ dummy_target::stop_recording ()
 void
 debug_target::stop_recording ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->stop_recording (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->stop_recording (...)", this->beneath ()->shortname ());
   this->beneath ()->stop_recording ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->stop_recording ()\n",
+  target_debug_printf_nofunc ("<- %s->stop_recording ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -3963,10 +3820,9 @@ dummy_target::info_record ()
 void
 debug_target::info_record ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->info_record (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->info_record (...)", this->beneath ()->shortname ());
   this->beneath ()->info_record ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->info_record ()\n",
+  target_debug_printf_nofunc ("<- %s->info_record ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -3985,10 +3841,9 @@ dummy_target::save_record (const char *arg0)
 void
 debug_target::save_record (const char *arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->save_record (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->save_record (...)", this->beneath ()->shortname ());
   this->beneath ()->save_record (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->save_record (%s)\n",
+  target_debug_printf_nofunc ("<- %s->save_record (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_char_p (arg0).c_str ());
 }
@@ -4008,11 +3863,10 @@ dummy_target::supports_delete_record ()
 bool
 debug_target::supports_delete_record ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_delete_record (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_delete_record (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_delete_record ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_delete_record () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_delete_record () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -4033,10 +3887,9 @@ dummy_target::delete_record ()
 void
 debug_target::delete_record ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->delete_record (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->delete_record (...)", this->beneath ()->shortname ());
   this->beneath ()->delete_record ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->delete_record ()\n",
+  target_debug_printf_nofunc ("<- %s->delete_record ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -4055,11 +3908,10 @@ dummy_target::record_is_replaying (ptid_t arg0)
 bool
 debug_target::record_is_replaying (ptid_t arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->record_is_replaying (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->record_is_replaying (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->record_is_replaying (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->record_is_replaying (%s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->record_is_replaying (%s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_bool (result).c_str ());
@@ -4081,11 +3933,10 @@ dummy_target::record_will_replay (ptid_t arg0, int arg1)
 bool
 debug_target::record_will_replay (ptid_t arg0, int arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->record_will_replay (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->record_will_replay (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->record_will_replay (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->record_will_replay (%s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->record_will_replay (%s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ptid_t (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -4107,10 +3958,9 @@ dummy_target::record_stop_replaying ()
 void
 debug_target::record_stop_replaying ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->record_stop_replaying (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->record_stop_replaying (...)", this->beneath ()->shortname ());
   this->beneath ()->record_stop_replaying ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->record_stop_replaying ()\n",
+  target_debug_printf_nofunc ("<- %s->record_stop_replaying ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -4129,10 +3979,9 @@ dummy_target::goto_record_begin ()
 void
 debug_target::goto_record_begin ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->goto_record_begin (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->goto_record_begin (...)", this->beneath ()->shortname ());
   this->beneath ()->goto_record_begin ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->goto_record_begin ()\n",
+  target_debug_printf_nofunc ("<- %s->goto_record_begin ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -4151,10 +4000,9 @@ dummy_target::goto_record_end ()
 void
 debug_target::goto_record_end ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->goto_record_end (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->goto_record_end (...)", this->beneath ()->shortname ());
   this->beneath ()->goto_record_end ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->goto_record_end ()\n",
+  target_debug_printf_nofunc ("<- %s->goto_record_end ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -4173,10 +4021,9 @@ dummy_target::goto_record (ULONGEST arg0)
 void
 debug_target::goto_record (ULONGEST arg0)
 {
-  gdb_printf (gdb_stdlog, "-> %s->goto_record (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->goto_record (...)", this->beneath ()->shortname ());
   this->beneath ()->goto_record (arg0);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->goto_record (%s)\n",
+  target_debug_printf_nofunc ("<- %s->goto_record (%s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ULONGEST (arg0).c_str ());
 }
@@ -4196,10 +4043,9 @@ dummy_target::insn_history (int arg0, gdb_disassembly_flags arg1)
 void
 debug_target::insn_history (int arg0, gdb_disassembly_flags arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->insn_history (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->insn_history (...)", this->beneath ()->shortname ());
   this->beneath ()->insn_history (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->insn_history (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->insn_history (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_gdb_disassembly_flags (arg1).c_str ());
@@ -4220,10 +4066,9 @@ dummy_target::insn_history_from (ULONGEST arg0, int arg1, gdb_disassembly_flags
 void
 debug_target::insn_history_from (ULONGEST arg0, int arg1, gdb_disassembly_flags arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->insn_history_from (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->insn_history_from (...)", this->beneath ()->shortname ());
   this->beneath ()->insn_history_from (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->insn_history_from (%s, %s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->insn_history_from (%s, %s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ULONGEST (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -4245,10 +4090,9 @@ dummy_target::insn_history_range (ULONGEST arg0, ULONGEST arg1, gdb_disassembly_
 void
 debug_target::insn_history_range (ULONGEST arg0, ULONGEST arg1, gdb_disassembly_flags arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->insn_history_range (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->insn_history_range (...)", this->beneath ()->shortname ());
   this->beneath ()->insn_history_range (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->insn_history_range (%s, %s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->insn_history_range (%s, %s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ULONGEST (arg0).c_str (),
 	      target_debug_print_ULONGEST (arg1).c_str (),
@@ -4270,10 +4114,9 @@ dummy_target::call_history (int arg0, record_print_flags arg1)
 void
 debug_target::call_history (int arg0, record_print_flags arg1)
 {
-  gdb_printf (gdb_stdlog, "-> %s->call_history (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->call_history (...)", this->beneath ()->shortname ());
   this->beneath ()->call_history (arg0, arg1);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->call_history (%s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->call_history (%s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_int (arg0).c_str (),
 	      target_debug_print_record_print_flags (arg1).c_str ());
@@ -4294,10 +4137,9 @@ dummy_target::call_history_from (ULONGEST arg0, int arg1, record_print_flags arg
 void
 debug_target::call_history_from (ULONGEST arg0, int arg1, record_print_flags arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->call_history_from (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->call_history_from (...)", this->beneath ()->shortname ());
   this->beneath ()->call_history_from (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->call_history_from (%s, %s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->call_history_from (%s, %s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ULONGEST (arg0).c_str (),
 	      target_debug_print_int (arg1).c_str (),
@@ -4319,10 +4161,9 @@ dummy_target::call_history_range (ULONGEST arg0, ULONGEST arg1, record_print_fla
 void
 debug_target::call_history_range (ULONGEST arg0, ULONGEST arg1, record_print_flags arg2)
 {
-  gdb_printf (gdb_stdlog, "-> %s->call_history_range (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->call_history_range (...)", this->beneath ()->shortname ());
   this->beneath ()->call_history_range (arg0, arg1, arg2);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->call_history_range (%s, %s, %s)\n",
+  target_debug_printf_nofunc ("<- %s->call_history_range (%s, %s, %s)",
 	      this->beneath ()->shortname (),
 	      target_debug_print_ULONGEST (arg0).c_str (),
 	      target_debug_print_ULONGEST (arg1).c_str (),
@@ -4344,11 +4185,10 @@ dummy_target::augmented_libraries_svr4_read ()
 bool
 debug_target::augmented_libraries_svr4_read ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->augmented_libraries_svr4_read (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->augmented_libraries_svr4_read (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->augmented_libraries_svr4_read ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->augmented_libraries_svr4_read () = %s\n",
+  target_debug_printf_nofunc ("<- %s->augmented_libraries_svr4_read () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -4369,11 +4209,10 @@ dummy_target::get_unwinder ()
 const struct frame_unwind *
 debug_target::get_unwinder ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_unwinder (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_unwinder (...)", this->beneath ()->shortname ());
   const struct frame_unwind * result
     = this->beneath ()->get_unwinder ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_unwinder () = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_unwinder () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_frame_unwind_p (result).c_str ());
   return result;
@@ -4394,11 +4233,10 @@ dummy_target::get_tailcall_unwinder ()
 const struct frame_unwind *
 debug_target::get_tailcall_unwinder ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->get_tailcall_unwinder (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->get_tailcall_unwinder (...)", this->beneath ()->shortname ());
   const struct frame_unwind * result
     = this->beneath ()->get_tailcall_unwinder ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->get_tailcall_unwinder () = %s\n",
+  target_debug_printf_nofunc ("<- %s->get_tailcall_unwinder () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_const_frame_unwind_p (result).c_str ());
   return result;
@@ -4418,10 +4256,9 @@ dummy_target::prepare_to_generate_core ()
 void
 debug_target::prepare_to_generate_core ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->prepare_to_generate_core (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->prepare_to_generate_core (...)", this->beneath ()->shortname ());
   this->beneath ()->prepare_to_generate_core ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->prepare_to_generate_core ()\n",
+  target_debug_printf_nofunc ("<- %s->prepare_to_generate_core ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -4439,10 +4276,9 @@ dummy_target::done_generating_core ()
 void
 debug_target::done_generating_core ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->done_generating_core (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->done_generating_core (...)", this->beneath ()->shortname ());
   this->beneath ()->done_generating_core ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->done_generating_core ()\n",
+  target_debug_printf_nofunc ("<- %s->done_generating_core ()",
 	      this->beneath ()->shortname ());
 }
 
@@ -4461,11 +4297,10 @@ dummy_target::supports_memory_tagging ()
 bool
 debug_target::supports_memory_tagging ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->supports_memory_tagging (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->supports_memory_tagging (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->supports_memory_tagging ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->supports_memory_tagging () = %s\n",
+  target_debug_printf_nofunc ("<- %s->supports_memory_tagging () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_bool (result).c_str ());
   return result;
@@ -4486,11 +4321,10 @@ dummy_target::fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2
 bool
 debug_target::fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2, int arg3)
 {
-  gdb_printf (gdb_stdlog, "-> %s->fetch_memtags (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->fetch_memtags (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->fetch_memtags (arg0, arg1, arg2, arg3);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->fetch_memtags (%s, %s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->fetch_memtags (%s, %s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_size_t (arg1).c_str (),
@@ -4515,11 +4349,10 @@ dummy_target::store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector
 bool
 debug_target::store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector &arg2, int arg3)
 {
-  gdb_printf (gdb_stdlog, "-> %s->store_memtags (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->store_memtags (...)", this->beneath ()->shortname ());
   bool result
     = this->beneath ()->store_memtags (arg0, arg1, arg2, arg3);
-  gdb_printf (gdb_stdlog,
-	      "<- %s->store_memtags (%s, %s, %s, %s) = %s\n",
+  target_debug_printf_nofunc ("<- %s->store_memtags (%s, %s, %s, %s) = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_CORE_ADDR (arg0).c_str (),
 	      target_debug_print_size_t (arg1).c_str (),
@@ -4572,11 +4405,10 @@ dummy_target::fetch_x86_xsave_layout ()
 x86_xsave_layout
 debug_target::fetch_x86_xsave_layout ()
 {
-  gdb_printf (gdb_stdlog, "-> %s->fetch_x86_xsave_layout (...)\n", this->beneath ()->shortname ());
+  target_debug_printf_nofunc ("-> %s->fetch_x86_xsave_layout (...)", this->beneath ()->shortname ());
   x86_xsave_layout result
     = this->beneath ()->fetch_x86_xsave_layout ();
-  gdb_printf (gdb_stdlog,
-	      "<- %s->fetch_x86_xsave_layout () = %s\n",
+  target_debug_printf_nofunc ("<- %s->fetch_x86_xsave_layout () = %s",
 	      this->beneath ()->shortname (),
 	      target_debug_print_x86_xsave_layout (result).c_str ());
   return result;
diff --git a/gdb/target.c b/gdb/target.c
index 0a836d1e146e..d9ff7d648252 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -110,6 +110,16 @@ bool may_stop = true;
 
 static unsigned int targetdebug = 0;
 
+/* Print a "target" debug statement with the function name prefix.  */
+
+#define target_debug_printf(fmt, ...) \
+  debug_prefixed_printf_cond (targetdebug > 0, "target", fmt, ##__VA_ARGS__)
+
+/* Print a "target" debug statement without the function name prefix.  */
+
+#define target_debug_printf_nofunc(fmt, ...) \
+  debug_prefixed_printf_cond_nofunc (targetdebug > 0, "target", fmt, ##__VA_ARGS__)
+
 static void
 set_targetdebug  (const char *args, int from_tty, struct cmd_list_element *c)
 {
@@ -822,15 +832,9 @@ open_target (const char *args, int from_tty, struct cmd_list_element *command)
   auto *ti = static_cast<target_info *> (command->context ());
   target_open_ftype *func = target_factories[ti];
 
-  if (targetdebug)
-    gdb_printf (gdb_stdlog, "-> %s->open (...)\n",
-		ti->shortname);
-
+  target_debug_printf_nofunc ("-> %s->open (...)", ti->shortname);
   func (args, from_tty);
-
-  if (targetdebug)
-    gdb_printf (gdb_stdlog, "<- %s->open (%s, %d)\n",
-		ti->shortname, args, from_tty);
+  target_debug_printf_nofunc ("<- %s->open (%s, %d)", ti->shortname, args, from_tty);
 }
 
 /* See target.h.  */
@@ -1157,8 +1161,7 @@ target_ops_ref_policy::decref (target_ops *t)
 
       t->close ();
 
-      if (targetdebug)
-	gdb_printf (gdb_stdlog, "closing target\n");
+      target_debug_printf_nofunc ("closing target");
     }
 }
 
@@ -1693,18 +1696,15 @@ target_xfer_partial (struct target_ops *ops,
   if (targetdebug)
     {
       const unsigned char *myaddr = NULL;
-
-      gdb_printf (gdb_stdlog,
-		  "%s:target_xfer_partial "
-		  "(%d, %s, %s, %s, %s, %s) = %d, %s",
-		  ops->shortname (),
-		  (int) object,
-		  (annex ? annex : "(null)"),
-		  host_address_to_string (readbuf),
-		  host_address_to_string (writebuf),
-		  core_addr_to_string_nz (offset),
-		  pulongest (len), retval,
-		  pulongest (*xfered_len));
+      std::string s
+	= string_printf ("%s:target_xfer_partial "
+			 "(%d, %s, %s, %s, %s, %s) = %d, %s",
+			 ops->shortname (), (int) object,
+			 (annex ? annex : "(null)"),
+			 host_address_to_string (readbuf),
+			 host_address_to_string (writebuf),
+			 core_addr_to_string_nz (offset), pulongest (len),
+			 retval, pulongest (*xfered_len));
 
       if (readbuf)
 	myaddr = readbuf;
@@ -1714,24 +1714,26 @@ target_xfer_partial (struct target_ops *ops,
 	{
 	  int i;
 
-	  gdb_puts (", bytes =", gdb_stdlog);
+	  string_appendf (s, ", bytes =");
 	  for (i = 0; i < *xfered_len; i++)
 	    {
 	      if ((((intptr_t) &(myaddr[i])) & 0xf) == 0)
 		{
 		  if (targetdebug < 2 && i > 0)
 		    {
-		      gdb_printf (gdb_stdlog, " ...");
+		      string_appendf (s, " ...");
 		      break;
 		    }
-		  gdb_printf (gdb_stdlog, "\n");
+
+		  target_debug_printf_nofunc ("%s", s.c_str ());
+		  s.clear();
 		}
 
-	      gdb_printf (gdb_stdlog, " %02x", myaddr[i] & 0xff);
+	      string_appendf (s, " %02x", myaddr[i] & 0xff);
 	    }
 	}
 
-      gdb_putc ('\n', gdb_stdlog);
+      target_debug_printf_nofunc ("%s", s.c_str ());
     }
 
   /* Check implementations of to_xfer_partial update *XFERED_LEN
@@ -2944,10 +2946,7 @@ target_info_proc (const char *args, enum info_proc_what what)
     {
       if (t->info_proc (args, what))
 	{
-	  if (targetdebug)
-	    gdb_printf (gdb_stdlog,
-			"target_info_proc (\"%s\", %d)\n", args, what);
-
+	  target_debug_printf_nofunc ("target_info_proc (\"%s\", %d)", args, what);
 	  return 1;
 	}
     }
@@ -3238,14 +3237,9 @@ target_fileio_open (struct inferior *inf, const char *filename,
       else
 	fd = acquire_fileio_fd (t, fd);
 
-      if (targetdebug)
-	gdb_printf (gdb_stdlog,
-		    "target_fileio_open (%d,%s,0x%x,0%o,%d)"
-		    " = %d (%d)\n",
-		    inf == NULL ? 0 : inf->num,
-		    filename, flags, mode,
-		    warn_if_slow, fd,
-		    fd != -1 ? 0 : *target_errno);
+      target_debug_printf_nofunc ("target_fileio_open (%d,%s,0x%x,0%o,%d) = %d (%d)",
+			   inf == NULL ? 0 : inf->num, filename, flags, mode,
+			   warn_if_slow, fd, fd != -1 ? 0 : *target_errno);
       return fd;
     }
 
@@ -3270,12 +3264,9 @@ target_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
     ret = fh->target->fileio_pwrite (fh->target_fd, write_buf,
 				     len, offset, target_errno);
 
-  if (targetdebug)
-    gdb_printf (gdb_stdlog,
-		"target_fileio_pwrite (%d,...,%d,%s) "
-		"= %d (%d)\n",
-		fd, len, pulongest (offset),
-		ret, ret != -1 ? 0 : *target_errno);
+  target_debug_printf_nofunc ("target_fileio_pwrite (%d,...,%d,%s) = %d (%d)", fd,
+		       len, pulongest (offset), ret,
+		       ret != -1 ? 0 : *target_errno);
   return ret;
 }
 
@@ -3296,12 +3287,8 @@ target_fileio_pread (int fd, gdb_byte *read_buf, int len,
     ret = fh->target->fileio_pread (fh->target_fd, read_buf,
 				    len, offset, target_errno);
 
-  if (targetdebug)
-    gdb_printf (gdb_stdlog,
-		"target_fileio_pread (%d,...,%d,%s) "
-		"= %d (%d)\n",
-		fd, len, pulongest (offset),
-		ret, ret != -1 ? 0 : *target_errno);
+  target_debug_printf_nofunc ("target_fileio_pread (%d,...,%d,%s) = %d (%d)", fd, len,
+		       pulongest (offset), ret, ret != -1 ? 0 : *target_errno);
   return ret;
 }
 
@@ -3320,10 +3307,8 @@ target_fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno)
   else
     ret = fh->target->fileio_fstat (fh->target_fd, sb, target_errno);
 
-  if (targetdebug)
-    gdb_printf (gdb_stdlog,
-		"target_fileio_fstat (%d) = %d (%d)\n",
-		fd, ret, ret != -1 ? 0 : *target_errno);
+  target_debug_printf_nofunc ("target_fileio_fstat (%d) = %d (%d)", fd, ret,
+		       ret != -1 ? 0 : *target_errno);
   return ret;
 }
 
@@ -3347,10 +3332,8 @@ target_fileio_close (int fd, fileio_error *target_errno)
       release_fileio_fd (fd, fh);
     }
 
-  if (targetdebug)
-    gdb_printf (gdb_stdlog,
-		"target_fileio_close (%d) = %d (%d)\n",
-		fd, ret, ret != -1 ? 0 : *target_errno);
+  target_debug_printf_nofunc ("target_fileio_close (%d) = %d (%d)", fd, ret,
+		       ret != -1 ? 0 : *target_errno);
   return ret;
 }
 
@@ -3367,12 +3350,9 @@ target_fileio_unlink (struct inferior *inf, const char *filename,
       if (ret == -1 && *target_errno == FILEIO_ENOSYS)
 	continue;
 
-      if (targetdebug)
-	gdb_printf (gdb_stdlog,
-		    "target_fileio_unlink (%d,%s)"
-		    " = %d (%d)\n",
-		    inf == NULL ? 0 : inf->num, filename,
-		    ret, ret != -1 ? 0 : *target_errno);
+      target_debug_printf_nofunc ("target_fileio_unlink (%d,%s) = %d (%d)",
+			   inf == NULL ? 0 : inf->num, filename, ret,
+			   ret != -1 ? 0 : *target_errno);
       return ret;
     }
 
@@ -3394,13 +3374,10 @@ target_fileio_readlink (struct inferior *inf, const char *filename,
       if (!ret.has_value () && *target_errno == FILEIO_ENOSYS)
 	continue;
 
-      if (targetdebug)
-	gdb_printf (gdb_stdlog,
-		    "target_fileio_readlink (%d,%s)"
-		    " = %s (%d)\n",
-		    inf == NULL ? 0 : inf->num,
-		    filename, ret ? ret->c_str () : "(nil)",
-		    ret ? 0 : *target_errno);
+      target_debug_printf_nofunc ("target_fileio_readlink (%d,%s) = %s (%d)",
+			   inf == NULL ? 0 : inf->num, filename,
+			   ret ? ret->c_str () : "(nil)",
+			   ret ? 0 : *target_errno);
       return ret;
     }
 
@@ -3894,9 +3871,7 @@ void
 target_fetch_registers (struct regcache *regcache, int regno)
 {
   current_inferior ()->top_target ()->fetch_registers (regcache, regno);
-  if (targetdebug)
-    gdb_printf (gdb_stdlog, "target_fetch_registers: %s",
-		regcache->register_debug_string (regno).c_str ());
+  target_debug_printf ("%s", regcache->register_debug_string (regno).c_str ());
 }
 
 void
@@ -3906,9 +3881,7 @@ target_store_registers (struct regcache *regcache, int regno)
     error (_("Writing to registers is not allowed (regno %d)"), regno);
 
   current_inferior ()->top_target ()->store_registers (regcache, regno);
-  if (targetdebug)
-    gdb_printf (gdb_stdlog, "target_store_registers: %s",
-		regcache->register_debug_string (regno).c_str ());
+  target_debug_printf ("%s", regcache->register_debug_string (regno).c_str ());
 }
 
 int
-- 
2.44.0


^ permalink raw reply	[relevance 15%]

* Re: [PATCH 3/6] gdb: make target debug functions return std::string
  @ 2024-04-19 19:41  0%     ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-04-19 19:41 UTC (permalink / raw)
  To: Tom Tromey, Simon Marchi; +Cc: gdb-patches

On 2024-04-19 15:20, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:
> 
> Simon> From: Simon Marchi <simon.marchi@efficios.com>
> Simon> Change the functions in target-debug.h to return string representations
> Simon> in an std::string, such that they don't need to know how the printing
> Simon> part is done.  This also helps the following patch that makes the debug
> Simon> prints in debug_target one-liners.
> 
> Simon> Update target-delegates.c (through make-target-delegates.py) to do the
> Simon> printing.
> 
> Simon> Add an overload of gdb_puts to avoid using `.c_str ()`.
> 
> Simon> +      string_appendf (s, " %s",
> Simon> +		      gdb_signal_to_name (static_cast<gdb_signal>(i)));
> Simon> +
> Simon> +  string_appendf (s, " }");
> 
> I think it would clearer if these were += instead of string_appendf.
> It would also mean avoiding a trip through the printf code.

Ok, I changed 3 instances of this to use += (I think you only meant
these cases that append constant strings, right?).

Simon

^ permalink raw reply	[relevance 0%]

* [PATCH v4 4/4] Run check-include-guards.py
  @ 2024-04-19 15:03  1% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-19 15:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch is the result of running check-include-guards.py on the
current tree.  Running it a second time causes no changes.
---
 gdb/aarch32-linux-nat.h                     | 6 +++---
 gdb/aarch32-tdep.h                          | 6 +++---
 gdb/aarch64-fbsd-tdep.h                     | 6 +++---
 gdb/aarch64-linux-tdep.h                    | 6 +++---
 gdb/aarch64-nat.h                           | 6 +++---
 gdb/aarch64-ravenscar-thread.h              | 6 +++---
 gdb/aarch64-tdep.h                          | 6 +++---
 gdb/ada-exp.h                               | 6 +++---
 gdb/ada-lang.h                              | 6 +++---
 gdb/addrmap.h                               | 6 +++---
 gdb/alpha-bsd-tdep.h                        | 6 +++---
 gdb/alpha-tdep.h                            | 6 +++---
 gdb/amd-dbgapi-target.h                     | 6 +++---
 gdb/amd64-bsd-nat.h                         | 6 +++---
 gdb/amd64-darwin-tdep.h                     | 6 +++---
 gdb/amd64-fbsd-tdep.h                       | 6 +++---
 gdb/amd64-linux-tdep.h                      | 6 +++---
 gdb/amd64-nat.h                             | 6 +++---
 gdb/amd64-ravenscar-thread.h                | 6 +++---
 gdb/amd64-tdep.h                            | 6 +++---
 gdb/amdgpu-tdep.h                           | 6 +++---
 gdb/annotate.h                              | 6 +++---
 gdb/arc-linux-tdep.h                        | 6 +++---
 gdb/arc-tdep.h                              | 6 +++---
 gdb/arch-utils.h                            | 6 +++---
 gdb/arch/aarch32.h                          | 6 +++---
 gdb/arch/aarch64-insn.h                     | 6 +++---
 gdb/arch/aarch64-mte-linux.h                | 6 +++---
 gdb/arch/aarch64-scalable-linux.h           | 6 +++---
 gdb/arch/aarch64.h                          | 6 +++---
 gdb/arch/amd64.h                            | 6 +++---
 gdb/arch/arc.h                              | 6 +++---
 gdb/arch/arm-get-next-pcs.h                 | 6 +++---
 gdb/arch/arm-linux.h                        | 6 +++---
 gdb/arch/arm.h                              | 6 +++---
 gdb/arch/csky.h                             | 6 +++---
 gdb/arch/i386.h                             | 6 +++---
 gdb/arch/loongarch.h                        | 6 +++---
 gdb/arch/ppc-linux-common.h                 | 6 +++---
 gdb/arch/ppc-linux-tdesc.h                  | 6 +++---
 gdb/arch/riscv.h                            | 6 +++---
 gdb/arch/tic6x.h                            | 6 +++---
 gdb/arch/xtensa.h                           | 6 +++---
 gdb/arm-fbsd-tdep.h                         | 6 +++---
 gdb/arm-linux-tdep.h                        | 6 +++---
 gdb/arm-netbsd-tdep.h                       | 6 +++---
 gdb/arm-tdep.h                              | 6 +++---
 gdb/async-event.h                           | 6 +++---
 gdb/auto-load.h                             | 6 +++---
 gdb/auxv.h                                  | 6 +++---
 gdb/ax-gdb.h                                | 6 +++---
 gdb/ax.h                                    | 6 +++---
 gdb/bcache.h                                | 6 +++---
 gdb/bfd-target.h                            | 6 +++---
 gdb/bfin-tdep.h                             | 6 +++---
 gdb/block.h                                 | 6 +++---
 gdb/breakpoint.h                            | 6 +++---
 gdb/bsd-kvm.h                               | 6 +++---
 gdb/bsd-uthread.h                           | 6 +++---
 gdb/bt-utils.h                              | 6 +++---
 gdb/btrace.h                                | 6 +++---
 gdb/build-id.h                              | 6 +++---
 gdb/buildsym-legacy.h                       | 6 +++---
 gdb/buildsym.h                              | 6 +++---
 gdb/c-exp.h                                 | 6 +++---
 gdb/c-lang.h                                | 6 +++---
 gdb/c-support.h                             | 6 +++---
 gdb/cgen-remap.h                            | 6 +++---
 gdb/charset-list.h                          | 6 +++---
 gdb/charset.h                               | 6 +++---
 gdb/cli-out.h                               | 6 +++---
 gdb/cli/cli-cmds.h                          | 6 +++---
 gdb/cli/cli-decode.h                        | 6 +++---
 gdb/cli/cli-interp.h                        | 6 +++---
 gdb/cli/cli-option.h                        | 6 +++---
 gdb/cli/cli-script.h                        | 6 +++---
 gdb/cli/cli-setshow.h                       | 6 +++---
 gdb/cli/cli-style.h                         | 6 +++---
 gdb/cli/cli-utils.h                         | 6 +++---
 gdb/coff-pe-read.h                          | 6 +++---
 gdb/command.h                               | 6 +++---
 gdb/compile/compile-c.h                     | 6 +++---
 gdb/compile/compile-cplus.h                 | 6 +++---
 gdb/compile/compile-internal.h              | 6 +++---
 gdb/compile/compile-object-load.h           | 6 +++---
 gdb/compile/compile-object-run.h            | 6 +++---
 gdb/compile/compile.h                       | 6 +++---
 gdb/compile/gcc-c-plugin.h                  | 6 +++---
 gdb/compile/gcc-cp-plugin.h                 | 6 +++---
 gdb/complaints.h                            | 6 +++---
 gdb/completer.h                             | 6 +++---
 gdb/config/nm-linux.h                       | 6 +++---
 gdb/config/nm-nto.h                         | 6 +++---
 gdb/cp-abi.h                                | 6 +++---
 gdb/cp-support.h                            | 6 +++---
 gdb/cris-tdep.h                             | 6 +++---
 gdb/csky-tdep.h                             | 6 +++---
 gdb/ctfread.h                               | 6 +++---
 gdb/d-lang.h                                | 6 +++---
 gdb/darwin-nat.h                            | 6 +++---
 gdb/dcache.h                                | 6 +++---
 gdb/debuginfod-support.h                    | 6 +++---
 gdb/defs.h                                  | 6 +++---
 gdb/dicos-tdep.h                            | 6 +++---
 gdb/dictionary.h                            | 6 +++---
 gdb/disasm-flags.h                          | 6 +++---
 gdb/disasm.h                                | 6 +++---
 gdb/displaced-stepping.h                    | 6 +++---
 gdb/dummy-frame.h                           | 6 +++---
 gdb/dwarf2/call-site.h                      | 6 +++---
 gdb/dwarf2/comp-unit-head.h                 | 6 +++---
 gdb/dwarf2/expr.h                           | 6 +++---
 gdb/dwarf2/frame-tailcall.h                 | 6 +++---
 gdb/dwarf2/frame.h                          | 6 +++---
 gdb/dwarf2/index-cache.h                    | 6 +++---
 gdb/dwarf2/index-common.h                   | 6 +++---
 gdb/dwarf2/index-write.h                    | 6 +++---
 gdb/dwarf2/line-header.h                    | 6 +++---
 gdb/dwarf2/loc.h                            | 6 +++---
 gdb/dwarf2/public.h                         | 6 +++---
 gdb/dwarf2/read-debug-names.h               | 6 +++---
 gdb/dwarf2/read-gdb-index.h                 | 6 +++---
 gdb/dwarf2/read.h                           | 6 +++---
 gdb/dwarf2/types.h                          | 6 +++---
 gdb/elf-none-tdep.h                         | 6 +++---
 gdb/event-top.h                             | 6 +++---
 gdb/exceptions.h                            | 6 +++---
 gdb/exec.h                                  | 6 +++---
 gdb/expop.h                                 | 6 +++---
 gdb/expression.h                            | 6 +++---
 gdb/extension-priv.h                        | 6 +++---
 gdb/extension.h                             | 6 +++---
 gdb/f-array-walker.h                        | 6 +++---
 gdb/f-exp.h                                 | 6 +++---
 gdb/f-lang.h                                | 6 +++---
 gdb/fbsd-nat.h                              | 6 +++---
 gdb/fbsd-tdep.h                             | 6 +++---
 gdb/filename-seen-cache.h                   | 6 +++---
 gdb/filesystem.h                            | 6 +++---
 gdb/frame-base.h                            | 6 +++---
 gdb/frame-id.h                              | 4 ++--
 gdb/frame-unwind.h                          | 6 +++---
 gdb/frame.h                                 | 6 +++---
 gdb/frv-tdep.h                              | 6 +++---
 gdb/ft32-tdep.h                             | 6 +++---
 gdb/gcore-elf.h                             | 6 +++---
 gdb/gcore.h                                 | 6 +++---
 gdb/gdb-demangle.h                          | 6 +++---
 gdb/gdb-stabs.h                             | 6 +++---
 gdb/gdb_bfd.h                               | 6 +++---
 gdb/gdb_curses.h                            | 6 +++---
 gdb/gdb_expat.h                             | 6 +++---
 gdb/gdb_proc_service.h                      | 6 +++---
 gdb/gdb_vfork.h                             | 6 +++---
 gdb/gdb_wchar.h                             | 6 +++---
 gdb/gdbarch.h                               | 6 +++---
 gdb/gdbcmd.h                                | 6 +++---
 gdb/gdbcore.h                               | 6 +++---
 gdb/gdbthread.h                             | 6 +++---
 gdb/gdbtypes.h                              | 6 +++---
 gdb/glibc-tdep.h                            | 6 +++---
 gdb/gmp-utils.h                             | 6 +++---
 gdb/gnu-nat-mig.h                           | 6 +++---
 gdb/gnu-nat.h                               | 6 +++---
 gdb/go-lang.h                               | 6 +++---
 gdb/gregset.h                               | 6 +++---
 gdb/guile/guile-internal.h                  | 6 +++---
 gdb/guile/guile.h                           | 6 +++---
 gdb/hppa-bsd-tdep.h                         | 6 +++---
 gdb/hppa-linux-offsets.h                    | 6 +++---
 gdb/hppa-tdep.h                             | 6 +++---
 gdb/i386-bsd-nat.h                          | 6 +++---
 gdb/i386-darwin-tdep.h                      | 6 +++---
 gdb/i386-fbsd-tdep.h                        | 6 +++---
 gdb/i386-linux-nat.h                        | 6 +++---
 gdb/i386-linux-tdep.h                       | 6 +++---
 gdb/i386-tdep.h                             | 6 +++---
 gdb/i387-tdep.h                             | 6 +++---
 gdb/ia64-libunwind-tdep.h                   | 6 +++---
 gdb/ia64-tdep.h                             | 6 +++---
 gdb/inf-child.h                             | 6 +++---
 gdb/inf-loop.h                              | 6 +++---
 gdb/inf-ptrace.h                            | 6 +++---
 gdb/infcall.h                               | 6 +++---
 gdb/inferior-iter.h                         | 6 +++---
 gdb/inferior.h                              | 6 +++---
 gdb/infrun.h                                | 6 +++---
 gdb/inline-frame.h                          | 6 +++---
 gdb/interps.h                               | 6 +++---
 gdb/jit.h                                   | 6 +++---
 gdb/language.h                              | 6 +++---
 gdb/linespec.h                              | 6 +++---
 gdb/linux-fork.h                            | 6 +++---
 gdb/linux-nat-trad.h                        | 6 +++---
 gdb/linux-nat.h                             | 6 +++---
 gdb/linux-record.h                          | 6 +++---
 gdb/linux-tdep.h                            | 6 +++---
 gdb/location.h                              | 6 +++---
 gdb/loongarch-tdep.h                        | 6 +++---
 gdb/m2-exp.h                                | 6 +++---
 gdb/m2-lang.h                               | 6 +++---
 gdb/m32r-tdep.h                             | 6 +++---
 gdb/m68k-tdep.h                             | 6 +++---
 gdb/macroexp.h                              | 6 +++---
 gdb/macroscope.h                            | 6 +++---
 gdb/macrotab.h                              | 6 +++---
 gdb/main.h                                  | 6 +++---
 gdb/maint.h                                 | 6 +++---
 gdb/mdebugread.h                            | 6 +++---
 gdb/memattr.h                               | 6 +++---
 gdb/memory-map.h                            | 6 +++---
 gdb/memrange.h                              | 6 +++---
 gdb/memtag.h                                | 6 +++---
 gdb/mi/mi-cmd-break.h                       | 6 +++---
 gdb/mi/mi-cmds.h                            | 6 +++---
 gdb/mi/mi-common.h                          | 6 +++---
 gdb/mi/mi-console.h                         | 6 +++---
 gdb/mi/mi-getopt.h                          | 6 +++---
 gdb/mi/mi-interp.h                          | 6 +++---
 gdb/mi/mi-main.h                            | 6 +++---
 gdb/mi/mi-out.h                             | 6 +++---
 gdb/mi/mi-parse.h                           | 6 +++---
 gdb/microblaze-tdep.h                       | 6 +++---
 gdb/minsyms.h                               | 6 +++---
 gdb/mips-fbsd-tdep.h                        | 6 +++---
 gdb/mips-linux-tdep.h                       | 6 +++---
 gdb/mips-netbsd-tdep.h                      | 6 +++---
 gdb/mips-tdep.h                             | 6 +++---
 gdb/mn10300-tdep.h                          | 6 +++---
 gdb/moxie-tdep.h                            | 6 +++---
 gdb/namespace.h                             | 6 +++---
 gdb/nat/aarch64-hw-point.h                  | 6 +++---
 gdb/nat/aarch64-linux-hw-point.h            | 6 +++---
 gdb/nat/aarch64-linux.h                     | 6 +++---
 gdb/nat/aarch64-mte-linux-ptrace.h          | 6 +++---
 gdb/nat/aarch64-scalable-linux-ptrace.h     | 6 +++---
 gdb/nat/aarch64-scalable-linux-sigcontext.h | 6 +++---
 gdb/nat/amd64-linux-siginfo.h               | 6 +++---
 gdb/nat/fork-inferior.h                     | 6 +++---
 gdb/nat/gdb_ptrace.h                        | 6 +++---
 gdb/nat/gdb_thread_db.h                     | 6 +++---
 gdb/nat/glibc_thread_db.h                   | 6 +++---
 gdb/nat/linux-btrace.h                      | 6 +++---
 gdb/nat/linux-namespaces.h                  | 6 +++---
 gdb/nat/linux-nat.h                         | 6 +++---
 gdb/nat/linux-osdata.h                      | 6 +++---
 gdb/nat/linux-personality.h                 | 6 +++---
 gdb/nat/linux-procfs.h                      | 6 +++---
 gdb/nat/linux-ptrace.h                      | 6 +++---
 gdb/nat/linux-waitpid.h                     | 6 +++---
 gdb/nat/mips-linux-watch.h                  | 6 +++---
 gdb/nat/netbsd-nat.h                        | 6 +++---
 gdb/nat/ppc-linux.h                         | 6 +++---
 gdb/nat/riscv-linux-tdesc.h                 | 6 +++---
 gdb/nat/windows-nat.h                       | 6 +++---
 gdb/nat/x86-cpuid.h                         | 6 +++---
 gdb/nat/x86-dregs.h                         | 6 +++---
 gdb/nat/x86-gcc-cpuid.h                     | 6 +++---
 gdb/nat/x86-linux-dregs.h                   | 6 +++---
 gdb/nat/x86-linux.h                         | 6 +++---
 gdb/nat/x86-xstate.h                        | 6 +++---
 gdb/nds32-tdep.h                            | 6 +++---
 gdb/netbsd-nat.h                            | 6 +++---
 gdb/netbsd-tdep.h                           | 6 +++---
 gdb/nios2-tdep.h                            | 6 +++---
 gdb/nto-tdep.h                              | 6 +++---
 gdb/objc-lang.h                             | 6 +++---
 gdb/objfile-flags.h                         | 6 +++---
 gdb/objfiles.h                              | 6 +++---
 gdb/obsd-nat.h                              | 6 +++---
 gdb/obsd-tdep.h                             | 6 +++---
 gdb/observable.h                            | 6 +++---
 gdb/or1k-linux-tdep.h                       | 6 +++---
 gdb/or1k-tdep.h                             | 6 +++---
 gdb/osabi.h                                 | 6 +++---
 gdb/osdata.h                                | 6 +++---
 gdb/p-lang.h                                | 6 +++---
 gdb/parser-defs.h                           | 6 +++---
 gdb/ppc-fbsd-tdep.h                         | 6 +++---
 gdb/ppc-linux-tdep.h                        | 6 +++---
 gdb/ppc-netbsd-tdep.h                       | 6 +++---
 gdb/ppc-obsd-tdep.h                         | 6 +++---
 gdb/ppc-ravenscar-thread.h                  | 6 +++---
 gdb/ppc-tdep.h                              | 6 +++---
 gdb/ppc64-tdep.h                            | 6 +++---
 gdb/probe.h                                 | 6 +++---
 gdb/proc-utils.h                            | 6 +++---
 gdb/process-stratum-target.h                | 6 +++---
 gdb/procfs.h                                | 6 +++---
 gdb/producer.h                              | 6 +++---
 gdb/progspace-and-thread.h                  | 6 +++---
 gdb/progspace.h                             | 6 +++---
 gdb/prologue-value.h                        | 6 +++---
 gdb/psymtab.h                               | 6 +++---
 gdb/python/py-event.h                       | 6 +++---
 gdb/python/py-events.h                      | 6 +++---
 gdb/python/py-instruction.h                 | 6 +++---
 gdb/python/py-record-btrace.h               | 6 +++---
 gdb/python/py-record-full.h                 | 6 +++---
 gdb/python/py-record.h                      | 6 +++---
 gdb/python/py-ref.h                         | 6 +++---
 gdb/python/py-stopevent.h                   | 6 +++---
 gdb/python/python-internal.h                | 6 +++---
 gdb/python/python.h                         | 6 +++---
 gdb/ravenscar-thread.h                      | 6 +++---
 gdb/record-btrace.h                         | 6 +++---
 gdb/record-full.h                           | 6 +++---
 gdb/record.h                                | 6 +++---
 gdb/regcache.h                              | 6 +++---
 gdb/regformats/regdef.h                     | 6 +++---
 gdb/reggroups.h                             | 6 +++---
 gdb/registry.h                              | 6 +++---
 gdb/regset.h                                | 6 +++---
 gdb/remote-fileio.h                         | 6 +++---
 gdb/remote-notif.h                          | 6 +++---
 gdb/remote.h                                | 6 +++---
 gdb/riscv-fbsd-tdep.h                       | 6 +++---
 gdb/riscv-ravenscar-thread.h                | 6 +++---
 gdb/riscv-tdep.h                            | 6 +++---
 gdb/rs6000-aix-tdep.h                       | 6 +++---
 gdb/rust-exp.h                              | 6 +++---
 gdb/rust-lang.h                             | 6 +++---
 gdb/s390-linux-tdep.h                       | 6 +++---
 gdb/s390-tdep.h                             | 6 +++---
 gdb/scoped-mock-context.h                   | 6 +++---
 gdb/selftest-arch.h                         | 6 +++---
 gdb/sentinel-frame.h                        | 6 +++---
 gdb/ser-base.h                              | 6 +++---
 gdb/ser-event.h                             | 6 +++---
 gdb/ser-tcp.h                               | 6 +++---
 gdb/ser-unix.h                              | 6 +++---
 gdb/serial.h                                | 6 +++---
 gdb/sh-tdep.h                               | 6 +++---
 gdb/sim-regno.h                             | 6 +++---
 gdb/skip.h                                  | 6 +++---
 gdb/sol2-tdep.h                             | 6 +++---
 gdb/solib-aix.h                             | 6 +++---
 gdb/solib-darwin.h                          | 6 +++---
 gdb/solib-dsbt.h                            | 6 +++---
 gdb/solib-svr4.h                            | 6 +++---
 gdb/solib-target.h                          | 6 +++---
 gdb/solib.h                                 | 6 +++---
 gdb/solist.h                                | 6 +++---
 gdb/source-cache.h                          | 6 +++---
 gdb/source.h                                | 6 +++---
 gdb/sparc-nat.h                             | 6 +++---
 gdb/sparc-ravenscar-thread.h                | 6 +++---
 gdb/sparc-tdep.h                            | 6 +++---
 gdb/sparc64-tdep.h                          | 6 +++---
 gdb/stabsread.h                             | 6 +++---
 gdb/stack.h                                 | 6 +++---
 gdb/stap-probe.h                            | 6 +++---
 gdb/symfile-add-flags.h                     | 6 +++---
 gdb/symfile.h                               | 6 +++---
 gdb/symtab.h                                | 6 +++---
 gdb/target-connection.h                     | 6 +++---
 gdb/target-dcache.h                         | 6 +++---
 gdb/target-debug.h                          | 6 +++---
 gdb/target-descriptions.h                   | 6 +++---
 gdb/target-float.h                          | 6 +++---
 gdb/target.h                                | 6 +++---
 gdb/target/resume.h                         | 6 +++---
 gdb/target/target.h                         | 6 +++---
 gdb/target/wait.h                           | 6 +++---
 gdb/target/waitstatus.h                     | 6 +++---
 gdb/terminal.h                              | 6 +++---
 gdb/test-target.h                           | 6 +++---
 gdb/thread-fsm.h                            | 6 +++---
 gdb/thread-iter.h                           | 6 +++---
 gdb/tic6x-tdep.h                            | 6 +++---
 gdb/tid-parse.h                             | 6 +++---
 gdb/tilegx-tdep.h                           | 6 +++---
 gdb/top.h                                   | 6 +++---
 gdb/tracectf.h                              | 6 +++---
 gdb/tracefile.h                             | 6 +++---
 gdb/tracepoint.h                            | 6 +++---
 gdb/trad-frame.h                            | 6 +++---
 gdb/tramp-frame.h                           | 6 +++---
 gdb/tui/tui-command.h                       | 6 +++---
 gdb/tui/tui-data.h                          | 6 +++---
 gdb/tui/tui-disasm.h                        | 6 +++---
 gdb/tui/tui-file.h                          | 6 +++---
 gdb/tui/tui-hooks.h                         | 6 +++---
 gdb/tui/tui-io.h                            | 6 +++---
 gdb/tui/tui-layout.h                        | 6 +++---
 gdb/tui/tui-location.h                      | 6 +++---
 gdb/tui/tui-regs.h                          | 6 +++---
 gdb/tui/tui-source.h                        | 6 +++---
 gdb/tui/tui-status.h                        | 6 +++---
 gdb/tui/tui-win.h                           | 6 +++---
 gdb/tui/tui-wingeneral.h                    | 6 +++---
 gdb/tui/tui-winsource.h                     | 6 +++---
 gdb/tui/tui.h                               | 6 +++---
 gdb/type-stack.h                            | 6 +++---
 gdb/typeprint.h                             | 6 +++---
 gdb/ui-file.h                               | 6 +++---
 gdb/ui-out.h                                | 6 +++---
 gdb/ui-style.h                              | 6 +++---
 gdb/ui.h                                    | 6 +++---
 gdb/user-regs.h                             | 6 +++---
 gdb/utils.h                                 | 6 +++---
 gdb/valprint.h                              | 6 +++---
 gdb/value.h                                 | 6 +++---
 gdb/varobj-iter.h                           | 6 +++---
 gdb/varobj.h                                | 6 +++---
 gdb/vax-tdep.h                              | 6 +++---
 gdb/windows-nat.h                           | 6 +++---
 gdb/windows-tdep.h                          | 6 +++---
 gdb/x86-bsd-nat.h                           | 6 +++---
 gdb/x86-fbsd-nat.h                          | 6 +++---
 gdb/x86-linux-nat.h                         | 6 +++---
 gdb/x86-nat.h                               | 6 +++---
 gdb/x86-tdep.h                              | 6 +++---
 gdb/xcoffread.h                             | 6 +++---
 gdb/xml-builtin.h                           | 6 +++---
 gdb/xml-support.h                           | 6 +++---
 gdb/xml-syscall.h                           | 6 +++---
 gdb/xml-tdesc.h                             | 6 +++---
 gdb/xtensa-tdep.h                           | 6 +++---
 gdb/yy-remap.h                              | 6 +++---
 gdb/z80-tdep.h                              | 6 +++---
 gdbserver/linux-aarch32-tdesc.h             | 2 +-
 gdbserver/linux-arm-tdesc.h                 | 2 +-
 gdbsupport/agent.h                          | 6 +++---
 gdbsupport/array-view.h                     | 6 +++---
 gdbsupport/break-common.h                   | 6 +++---
 gdbsupport/btrace-common.h                  | 6 +++---
 gdbsupport/byte-vector.h                    | 6 +++---
 gdbsupport/cleanups.h                       | 6 +++---
 gdbsupport/common-debug.h                   | 6 +++---
 gdbsupport/common-defs.h                    | 6 +++---
 gdbsupport/common-exceptions.h              | 6 +++---
 gdbsupport/common-gdbthread.h               | 6 +++---
 gdbsupport/common-inferior.h                | 6 +++---
 gdbsupport/common-regcache.h                | 6 +++---
 gdbsupport/common-types.h                   | 6 +++---
 gdbsupport/common-utils.h                   | 6 +++---
 gdbsupport/def-vector.h                     | 6 +++---
 gdbsupport/default-init-alloc.h             | 6 +++---
 gdbsupport/enum-flags.h                     | 6 +++---
 gdbsupport/environ.h                        | 6 +++---
 gdbsupport/errors.h                         | 6 +++---
 gdbsupport/event-loop.h                     | 6 +++---
 gdbsupport/event-pipe.h                     | 6 +++---
 gdbsupport/fileio.h                         | 6 +++---
 gdbsupport/filestuff.h                      | 6 +++---
 gdbsupport/filtered-iterator.h              | 6 +++---
 gdbsupport/format.h                         | 6 +++---
 gdbsupport/forward-scope-exit.h             | 6 +++---
 gdbsupport/function-view.h                  | 6 +++---
 gdbsupport/gdb-checked-static-cast.h        | 6 +++---
 gdbsupport/gdb-dlfcn.h                      | 6 +++---
 gdbsupport/gdb-safe-ctype.h                 | 6 +++---
 gdbsupport/gdb_assert.h                     | 6 +++---
 gdbsupport/gdb_file.h                       | 6 +++---
 gdbsupport/gdb_locale.h                     | 6 +++---
 gdbsupport/gdb_obstack.h                    | 6 +++---
 gdbsupport/gdb_proc_service.h               | 6 +++---
 gdbsupport/gdb_ref_ptr.h                    | 6 +++---
 gdbsupport/gdb_regex.h                      | 6 +++---
 gdbsupport/gdb_select.h                     | 6 +++---
 gdbsupport/gdb_setjmp.h                     | 6 +++---
 gdbsupport/gdb_signals.h                    | 6 +++---
 gdbsupport/gdb_splay_tree.h                 | 6 +++---
 gdbsupport/gdb_sys_time.h                   | 6 +++---
 gdbsupport/gdb_tilde_expand.h               | 6 +++---
 gdbsupport/gdb_unique_ptr.h                 | 6 +++---
 gdbsupport/gdb_unlinker.h                   | 6 +++---
 gdbsupport/gdb_vecs.h                       | 6 +++---
 gdbsupport/gdb_wait.h                       | 6 +++---
 gdbsupport/hash_enum.h                      | 6 +++---
 gdbsupport/host-defs.h                      | 6 +++---
 gdbsupport/job-control.h                    | 6 +++---
 gdbsupport/netstuff.h                       | 6 +++---
 gdbsupport/next-iterator.h                  | 6 +++---
 gdbsupport/observable.h                     | 6 +++---
 gdbsupport/offset-type.h                    | 6 +++---
 gdbsupport/packed.h                         | 6 +++---
 gdbsupport/pathstuff.h                      | 6 +++---
 gdbsupport/poison.h                         | 6 +++---
 gdbsupport/preprocessor.h                   | 6 +++---
 gdbsupport/print-utils.h                    | 6 +++---
 gdbsupport/ptid.h                           | 6 +++---
 gdbsupport/refcounted-object.h              | 6 +++---
 gdbsupport/rsp-low.h                        | 6 +++---
 gdbsupport/run-time-clock.h                 | 6 +++---
 gdbsupport/safe-iterator.h                  | 6 +++---
 gdbsupport/scope-exit.h                     | 6 +++---
 gdbsupport/scoped_fd.h                      | 6 +++---
 gdbsupport/scoped_ignore_signal.h           | 6 +++---
 gdbsupport/scoped_ignore_sigttou.h          | 6 +++---
 gdbsupport/scoped_mmap.h                    | 6 +++---
 gdbsupport/scoped_restore.h                 | 6 +++---
 gdbsupport/search.h                         | 6 +++---
 gdbsupport/selftest.h                       | 6 +++---
 gdbsupport/signals-state-save-restore.h     | 6 +++---
 gdbsupport/symbol.h                         | 6 +++---
 gdbsupport/tdesc.h                          | 6 +++---
 gdbsupport/traits.h                         | 6 +++---
 gdbsupport/underlying.h                     | 6 +++---
 gdbsupport/valid-expr.h                     | 6 +++---
 gdbsupport/version.h                        | 6 +++---
 gdbsupport/x86-xstate.h                     | 6 +++---
 gdbsupport/xml-utils.h                      | 6 +++---
 504 files changed, 1507 insertions(+), 1507 deletions(-)

diff --git a/gdb/aarch32-linux-nat.h b/gdb/aarch32-linux-nat.h
index 611c9fcfba9..79ad5adcef8 100644
--- a/gdb/aarch32-linux-nat.h
+++ b/gdb/aarch32-linux-nat.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH32_LINUX_NAT_H
-#define AARCH32_LINUX_NAT_H
+#ifndef GDB_AARCH32_LINUX_NAT_H
+#define GDB_AARCH32_LINUX_NAT_H
 
 void aarch32_gp_regcache_supply (struct regcache *regcache, uint32_t *regs,
 				 int arm_apcs_32);
@@ -31,4 +31,4 @@ void aarch32_vfp_regcache_collect (const struct regcache *regcache,
 				   gdb_byte *regs,
 				   const int vfp_register_count);
 
-#endif /* AARCH32_LINUX_NAT_H */
+#endif /* GDB_AARCH32_LINUX_NAT_H */
diff --git a/gdb/aarch32-tdep.h b/gdb/aarch32-tdep.h
index 009ee61890e..16ceb30a25f 100644
--- a/gdb/aarch32-tdep.h
+++ b/gdb/aarch32-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH32_TDEP_H
-#define AARCH32_TDEP_H
+#ifndef GDB_AARCH32_TDEP_H
+#define GDB_AARCH32_TDEP_H
 
 struct target_desc;
 
@@ -24,4 +24,4 @@ struct target_desc;
 
 const target_desc *aarch32_read_description (bool tls);
 
-#endif /* aarch32-tdep.h.  */
+#endif /* GDB_AARCH32_TDEP_H */
diff --git a/gdb/aarch64-fbsd-tdep.h b/gdb/aarch64-fbsd-tdep.h
index 56b15a94ee4..6d53b28386f 100644
--- a/gdb/aarch64-fbsd-tdep.h
+++ b/gdb/aarch64-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_FBSD_TDEP_H
-#define AARCH64_FBSD_TDEP_H
+#ifndef GDB_AARCH64_FBSD_TDEP_H
+#define GDB_AARCH64_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -39,4 +39,4 @@ extern const struct regset aarch64_fbsd_gregset;
 extern const struct regset aarch64_fbsd_fpregset;
 extern const struct regset aarch64_fbsd_tls_regset;
 
-#endif /* AARCH64_FBSD_TDEP_H */
+#endif /* GDB_AARCH64_FBSD_TDEP_H */
diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h
index 1961250e14f..4cca8e901a7 100644
--- a/gdb/aarch64-linux-tdep.h
+++ b/gdb/aarch64-linux-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_LINUX_TDEP_H
-#define AARCH64_LINUX_TDEP_H
+#ifndef GDB_AARCH64_LINUX_TDEP_H
+#define GDB_AARCH64_LINUX_TDEP_H
 
 #include "regset.h"
 
@@ -45,4 +45,4 @@ extern const struct regset aarch64_linux_fpregset;
 /* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h.  */
 #define AARCH64_HWCAP_PACA (1 << 30)
 
-#endif /* AARCH64_LINUX_TDEP_H */
+#endif /* GDB_AARCH64_LINUX_TDEP_H */
diff --git a/gdb/aarch64-nat.h b/gdb/aarch64-nat.h
index 947d2805602..33621c2643b 100644
--- a/gdb/aarch64-nat.h
+++ b/gdb/aarch64-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_NAT_H
-#define AARCH64_NAT_H
+#ifndef GDB_AARCH64_NAT_H
+#define GDB_AARCH64_NAT_H
 
 #include "breakpoint.h"
 #include "nat/aarch64-hw-point.h"
@@ -106,4 +106,4 @@ struct aarch64_nat_target : public BaseTarget
   { return start <= addr && start + length - 1 >= addr; }
 };
 
-#endif /* AARCH64_NAT_H */
+#endif /* GDB_AARCH64_NAT_H */
diff --git a/gdb/aarch64-ravenscar-thread.h b/gdb/aarch64-ravenscar-thread.h
index 2d2665627c5..9cf0113e635 100644
--- a/gdb/aarch64-ravenscar-thread.h
+++ b/gdb/aarch64-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_RAVENSCAR_THREAD_H
-#define AARCH64_RAVENSCAR_THREAD_H
+#ifndef GDB_AARCH64_RAVENSCAR_THREAD_H
+#define GDB_AARCH64_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_aarch64_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_AARCH64_RAVENSCAR_THREAD_H */
diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h
index 0e6024bfcbc..e1e9f43fd11 100644
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -19,8 +19,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef AARCH64_TDEP_H
-#define AARCH64_TDEP_H
+#ifndef GDB_AARCH64_TDEP_H
+#define GDB_AARCH64_TDEP_H
 
 #include "arch/aarch64.h"
 #include "displaced-stepping.h"
@@ -203,4 +203,4 @@ void aarch64_displaced_step_fixup (struct gdbarch *gdbarch,
 
 bool aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch);
 
-#endif /* aarch64-tdep.h */
+#endif /* GDB_AARCH64_TDEP_H */
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 94e4ea0f47e..0a59b343f14 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ADA_EXP_H
-#define ADA_EXP_H
+#ifndef GDB_ADA_EXP_H
+#define GDB_ADA_EXP_H
 
 #include "expop.h"
 
@@ -981,4 +981,4 @@ class ada_concat_operation : public concat_operation
 
 } /* namespace expr */
 
-#endif /* ADA_EXP_H */
+#endif /* GDB_ADA_EXP_H */
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 5083d004ac9..69c91b2e719 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (ADA_LANG_H)
-#define ADA_LANG_H 1
+#ifndef GDB_ADA_LANG_H
+#define GDB_ADA_LANG_H
 
 class frame_info_ptr;
 struct inferior;
@@ -435,4 +435,4 @@ extern block_symbol ada_resolve_variable (struct symbol *sym,
 extern struct type *ada_index_type (struct type *type, int n,
 				    const char *name);
 
-#endif
+#endif /* GDB_ADA_LANG_H */
diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index 5378b753760..a2ccc7b0cfd 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ADDRMAP_H
-#define ADDRMAP_H
+#ifndef GDB_ADDRMAP_H
+#define GDB_ADDRMAP_H
 
 #include "splay-tree.h"
 #include "gdbsupport/function-view.h"
@@ -222,4 +222,4 @@ struct addrmap_mutable final : public addrmap
 void addrmap_dump (struct addrmap *map, struct ui_file *outfile,
 		   void *payload);
 
-#endif /* ADDRMAP_H */
+#endif /* GDB_ADDRMAP_H */
diff --git a/gdb/alpha-bsd-tdep.h b/gdb/alpha-bsd-tdep.h
index 25ac043ba86..4783854eb47 100644
--- a/gdb/alpha-bsd-tdep.h
+++ b/gdb/alpha-bsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ALPHA_BSD_TDEP_H
-#define ALPHA_BSD_TDEP_H
+#ifndef GDB_ALPHA_BSD_TDEP_H
+#define GDB_ALPHA_BSD_TDEP_H
 
 #include "gdbarch.h"
 
@@ -39,4 +39,4 @@ void alphanbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					     void *cb_data,
 					     const struct regcache *regcache);
 
-#endif /* alpha-bsd-tdep.h */
+#endif /* GDB_ALPHA_BSD_TDEP_H */
diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h
index 0423abb2558..37c1eddf691 100644
--- a/gdb/alpha-tdep.h
+++ b/gdb/alpha-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ALPHA_TDEP_H
-#define ALPHA_TDEP_H
+#ifndef GDB_ALPHA_TDEP_H
+#define GDB_ALPHA_TDEP_H
 
 #include "gdbarch.h"
 
@@ -121,4 +121,4 @@ extern void alpha_supply_fp_regs (struct regcache *, int,
 extern void alpha_fill_fp_regs (const struct regcache *,
 				int, void *, void *);
 
-#endif /* ALPHA_TDEP_H */
+#endif /* GDB_ALPHA_TDEP_H */
diff --git a/gdb/amd-dbgapi-target.h b/gdb/amd-dbgapi-target.h
index f377fd0c57a..0a9cafaa7ee 100644
--- a/gdb/amd-dbgapi-target.h
+++ b/gdb/amd-dbgapi-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD_DBGAPI_TARGET_H
-#define AMD_DBGAPI_TARGET_H 1
+#ifndef GDB_AMD_DBGAPI_TARGET_H
+#define GDB_AMD_DBGAPI_TARGET_H
 
 #include "gdbsupport/observable.h"
 
@@ -113,4 +113,4 @@ get_status_string (amd_dbgapi_status_t status)
   return ret;
 }
 
-#endif /* AMD_DBGAPI_TARGET_H */
+#endif /* GDB_AMD_DBGAPI_TARGET_H */
diff --git a/gdb/amd64-bsd-nat.h b/gdb/amd64-bsd-nat.h
index b11356e0375..7ea26827625 100644
--- a/gdb/amd64-bsd-nat.h
+++ b/gdb/amd64-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_BSD_NAT_H
-#define AMD64_BSD_NAT_H
+#ifndef GDB_AMD64_BSD_NAT_H
+#define GDB_AMD64_BSD_NAT_H
 
 #include "x86-bsd-nat.h"
 
@@ -41,4 +41,4 @@ class amd64_bsd_nat_target : public x86bsd_nat_target<BaseTarget>
   { amd64bsd_store_inferior_registers (regcache, regnum); }
 };
 
-#endif /* i386-bsd-nat.h */
+#endif /* GDB_AMD64_BSD_NAT_H */
diff --git a/gdb/amd64-darwin-tdep.h b/gdb/amd64-darwin-tdep.h
index 19d92b61b90..c09cfe3229b 100644
--- a/gdb/amd64-darwin-tdep.h
+++ b/gdb/amd64-darwin-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_DARWIN_TDEP_H
-#define AMD64_DARWIN_TDEP_H
+#ifndef GDB_AMD64_DARWIN_TDEP_H
+#define GDB_AMD64_DARWIN_TDEP_H
 
 /* Mapping between the general-purpose registers in Darwin x86-64 thread
    state and GDB's register cache layout.
@@ -26,4 +26,4 @@
 extern int amd64_darwin_thread_state_reg_offset[];
 extern const int amd64_darwin_thread_state_num_regs;
 
-#endif /* AMD64_DARWIN_TDEP_H */
+#endif /* GDB_AMD64_DARWIN_TDEP_H */
diff --git a/gdb/amd64-fbsd-tdep.h b/gdb/amd64-fbsd-tdep.h
index 93b0ca901ce..7e8acc6959e 100644
--- a/gdb/amd64-fbsd-tdep.h
+++ b/gdb/amd64-fbsd-tdep.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_FBSD_TDEP_H
-#define AMD64_FBSD_TDEP_H
+#ifndef GDB_AMD64_FBSD_TDEP_H
+#define GDB_AMD64_FBSD_TDEP_H
 
 #include "regset.h"
 
 extern const struct regset amd64_fbsd_gregset;
 
-#endif /* AMD64_FBSD_TDEP_H */
+#endif /* GDB_AMD64_FBSD_TDEP_H */
diff --git a/gdb/amd64-linux-tdep.h b/gdb/amd64-linux-tdep.h
index 2003dcda78f..6ce0032040c 100644
--- a/gdb/amd64-linux-tdep.h
+++ b/gdb/amd64-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_LINUX_TDEP_H
-#define AMD64_LINUX_TDEP_H
+#ifndef GDB_AMD64_LINUX_TDEP_H
+#define GDB_AMD64_LINUX_TDEP_H
 
 /* Like for i386 GNU/Linux, there is an extra "register"
    used to control syscall restarting.  */
@@ -604,4 +604,4 @@ enum amd64_x32_syscall {
   amd64_x32_sys_getsockopt = (amd64_x32_syscall_bit + 542),
 };
 
-#endif /* amd64-linux-tdep.h */
+#endif /* GDB_AMD64_LINUX_TDEP_H */
diff --git a/gdb/amd64-nat.h b/gdb/amd64-nat.h
index b18ff8b1728..56ad36c9f1e 100644
--- a/gdb/amd64-nat.h
+++ b/gdb/amd64-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_NAT_H
-#define AMD64_NAT_H 1
+#ifndef GDB_AMD64_NAT_H
+#define GDB_AMD64_NAT_H
 
 struct regcache;
 
@@ -49,4 +49,4 @@ extern void amd64_supply_native_gregset (struct regcache *regcache,
 extern void amd64_collect_native_gregset (const struct regcache *regcache,
 					  void *gregs, int regnum);
 
-#endif /* amd64-nat.h */
+#endif /* GDB_AMD64_NAT_H */
diff --git a/gdb/amd64-ravenscar-thread.h b/gdb/amd64-ravenscar-thread.h
index 1a723600e7a..41e38327753 100644
--- a/gdb/amd64-ravenscar-thread.h
+++ b/gdb/amd64-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_RAVENSCAR_THREAD_H
-#define AMD64_RAVENSCAR_THREAD_H
+#ifndef GDB_AMD64_RAVENSCAR_THREAD_H
+#define GDB_AMD64_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_amd64_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif /* AMD64_RAVENSCAR_THREAD_H */
+#endif /* GDB_AMD64_RAVENSCAR_THREAD_H */
diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
index 696c65b4f1b..c964e26e6a3 100644
--- a/gdb/amd64-tdep.h
+++ b/gdb/amd64-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_TDEP_H
-#define AMD64_TDEP_H
+#ifndef GDB_AMD64_TDEP_H
+#define GDB_AMD64_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -144,4 +144,4 @@ extern int amd64nbsd_r_reg_offset[];
 /* Variables exported from amd64-obsd-tdep.c.  */
 extern int amd64obsd_r_reg_offset[];
 
-#endif /* amd64-tdep.h */
+#endif /* GDB_AMD64_TDEP_H */
diff --git a/gdb/amdgpu-tdep.h b/gdb/amdgpu-tdep.h
index 2656d18e727..16c7b83a679 100644
--- a/gdb/amdgpu-tdep.h
+++ b/gdb/amdgpu-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMDGPU_TDEP_H
-#define AMDGPU_TDEP_H
+#ifndef GDB_AMDGPU_TDEP_H
+#define GDB_AMDGPU_TDEP_H
 
 #include "gdbarch.h"
 
@@ -90,4 +90,4 @@ bool is_amdgpu_arch (struct gdbarch *gdbarch);
 
 amdgpu_gdbarch_tdep *get_amdgpu_gdbarch_tdep (gdbarch *arch);
 
-#endif /* AMDGPU_TDEP_H */
+#endif /* GDB_AMDGPU_TDEP_H */
diff --git a/gdb/annotate.h b/gdb/annotate.h
index b8ce63ff233..d730b2e8297 100644
--- a/gdb/annotate.h
+++ b/gdb/annotate.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ANNOTATE_H
-#define ANNOTATE_H
+#ifndef GDB_ANNOTATE_H
+#define GDB_ANNOTATE_H
 
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -132,4 +132,4 @@ extern void annotate_array_section_end (void);
 extern void (*deprecated_annotate_signalled_hook) (void);
 extern void (*deprecated_annotate_signal_hook) (void);
 
-#endif /* ANNOTATE_H */
+#endif /* GDB_ANNOTATE_H */
diff --git a/gdb/arc-linux-tdep.h b/gdb/arc-linux-tdep.h
index 20ed525fe7c..9fe4116984d 100644
--- a/gdb/arc-linux-tdep.h
+++ b/gdb/arc-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARC_LINUX_TDEP_H
-#define ARC_LINUX_TDEP_H
+#ifndef GDB_ARC_LINUX_TDEP_H
+#define GDB_ARC_LINUX_TDEP_H
 
 #include "gdbarch.h"
 #include "regset.h"
@@ -49,4 +49,4 @@ void arc_linux_collect_v2_regset (const struct regset *regset,
 				  const struct regcache *regcache,
 				  int regnum, void *v2_regs, size_t size);
 
-#endif /* ARC_LINUX_TDEP_H */
+#endif /* GDB_ARC_LINUX_TDEP_H */
diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
index c59490dec00..86a483d00c7 100644
--- a/gdb/arc-tdep.h
+++ b/gdb/arc-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARC_TDEP_H
-#define ARC_TDEP_H
+#ifndef GDB_ARC_TDEP_H
+#define GDB_ARC_TDEP_H
 
 /* Need disassemble_info.  */
 #include "dis-asm.h"
@@ -205,4 +205,4 @@ CORE_ADDR arc_insn_get_linear_next_pc (const struct arc_instruction &insn);
 arc_arch_features arc_arch_features_create (const bfd *abfd,
 					    const unsigned long mach);
 
-#endif /* ARC_TDEP_H */
+#endif /* GDB_ARC_TDEP_H */
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 467be40c688..685a0ed0cd9 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_UTILS_H
-#define ARCH_UTILS_H
+#ifndef GDB_ARCH_UTILS_H
+#define GDB_ARCH_UTILS_H
 
 #include "gdbarch.h"
 
@@ -325,4 +325,4 @@ extern enum return_value_convention default_gdbarch_return_value
       struct regcache *regcache, struct value **read_value,
       const gdb_byte *writebuf);
 
-#endif /* ARCH_UTILS_H */
+#endif /* GDB_ARCH_UTILS_H */
diff --git a/gdb/arch/aarch32.h b/gdb/arch/aarch32.h
index 1811b8a7a92..f3e70affb0b 100644
--- a/gdb/arch/aarch32.h
+++ b/gdb/arch/aarch32.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH32_H
-#define ARCH_AARCH32_H
+#ifndef GDB_ARCH_AARCH32_H
+#define GDB_ARCH_AARCH32_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -24,4 +24,4 @@
 
 target_desc *aarch32_create_target_description (bool tls);
 
-#endif /* aarch32.h.  */
+#endif /* GDB_ARCH_AARCH32_H */
diff --git a/gdb/arch/aarch64-insn.h b/gdb/arch/aarch64-insn.h
index e4ee5c74fbf..bd3a85f9686 100644
--- a/gdb/arch/aarch64-insn.h
+++ b/gdb/arch/aarch64-insn.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_INSN_H
-#define ARCH_AARCH64_INSN_H
+#ifndef GDB_ARCH_AARCH64_INSN_H
+#define GDB_ARCH_AARCH64_INSN_H
 
 extern bool aarch64_debug;
 
@@ -356,4 +356,4 @@ int aarch64_emit_load_store (uint32_t *buf, uint32_t size,
 			     struct aarch64_register rn,
 			     struct aarch64_memory_operand operand);
 
-#endif /* ARCH_AARCH64_INSN_H */
+#endif /* GDB_ARCH_AARCH64_INSN_H */
diff --git a/gdb/arch/aarch64-mte-linux.h b/gdb/arch/aarch64-mte-linux.h
index 460b10e05c9..d917dd1b1e3 100644
--- a/gdb/arch/aarch64-mte-linux.h
+++ b/gdb/arch/aarch64-mte-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_MTE_LINUX_H
-#define ARCH_AARCH64_MTE_LINUX_H
+#ifndef GDB_ARCH_AARCH64_MTE_LINUX_H
+#define GDB_ARCH_AARCH64_MTE_LINUX_H
 
 
 /* Feature check for Memory Tagging Extension.  */
@@ -80,4 +80,4 @@ extern void aarch64_mte_pack_tags (gdb::byte_vector &tags);
    first unpacked element.  Otherwise leave it in the unpacked vector.  */
 extern void aarch64_mte_unpack_tags (gdb::byte_vector &tags, bool skip_first);
 
-#endif /* ARCH_AARCH64_MTE_LINUX_H */
+#endif /* GDB_ARCH_AARCH64_MTE_LINUX_H */
diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h
index 4d2ace8f153..886f4a2dee8 100644
--- a/gdb/arch/aarch64-scalable-linux.h
+++ b/gdb/arch/aarch64-scalable-linux.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_SCALABLE_LINUX_H
-#define ARCH_AARCH64_SCALABLE_LINUX_H
+#ifndef GDB_ARCH_AARCH64_SCALABLE_LINUX_H
+#define GDB_ARCH_AARCH64_SCALABLE_LINUX_H
 
 #include "gdbsupport/common-regcache.h"
 
@@ -55,4 +55,4 @@
    is empty (zero).  Return FALSE otherwise.  */
 extern bool sve_state_is_empty (const struct reg_buffer_common *reg_buf);
 
-#endif /* ARCH_AARCH64_SCALABLE_LINUX_H */
+#endif /* GDB_ARCH_AARCH64_SCALABLE_LINUX_H */
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index b4c0111aeb4..f45a0e2f13e 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_H
-#define ARCH_AARCH64_H
+#ifndef GDB_ARCH_AARCH64_H
+#define GDB_ARCH_AARCH64_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -230,4 +230,4 @@ enum aarch64_regnum
 /* Size of the SME2 ZT0 register in bytes.  */
 #define AARCH64_SME2_ZT0_SIZE 64
 
-#endif /* ARCH_AARCH64_H */
+#endif /* GDB_ARCH_AARCH64_H */
diff --git a/gdb/arch/amd64.h b/gdb/arch/amd64.h
index 042d986a694..1c7a2bb26e9 100644
--- a/gdb/arch/amd64.h
+++ b/gdb/arch/amd64.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AMD64_H
-#define ARCH_AMD64_H
+#ifndef GDB_ARCH_AMD64_H
+#define GDB_ARCH_AMD64_H
 
 #include "gdbsupport/tdesc.h"
 #include <stdint.h>
@@ -24,4 +24,4 @@
 target_desc *amd64_create_target_description (uint64_t xcr0, bool is_x32,
 					      bool is_linux, bool segments);
 
-#endif /* ARCH_AMD64_H */
+#endif /* GDB_ARCH_AMD64_H */
diff --git a/gdb/arch/arc.h b/gdb/arch/arc.h
index 1a5a9b6b492..887431ea12a 100644
--- a/gdb/arch/arc.h
+++ b/gdb/arch/arc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARC_H
-#define ARCH_ARC_H
+#ifndef GDB_ARCH_ARC_H
+#define GDB_ARCH_ARC_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -84,4 +84,4 @@ const target_desc *arc_lookup_target_description
 #endif /* GDBSERVER */
 
 
-#endif /* ARCH_ARC_H */
+#endif /* GDB_ARCH_ARC_H */
diff --git a/gdb/arch/arm-get-next-pcs.h b/gdb/arch/arm-get-next-pcs.h
index 77bf0b566a8..7680373c638 100644
--- a/gdb/arch/arm-get-next-pcs.h
+++ b/gdb/arch/arm-get-next-pcs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_GET_NEXT_PCS_H
-#define ARCH_ARM_GET_NEXT_PCS_H
+#ifndef GDB_ARCH_ARM_GET_NEXT_PCS_H
+#define GDB_ARCH_ARM_GET_NEXT_PCS_H
 
 #include <vector>
 
@@ -65,4 +65,4 @@ void arm_get_next_pcs_ctor (struct arm_get_next_pcs *self,
 /* Find the next possible PCs after the current instruction executes.  */
 std::vector<CORE_ADDR> arm_get_next_pcs (struct arm_get_next_pcs *self);
 
-#endif /* ARCH_ARM_GET_NEXT_PCS_H */
+#endif /* GDB_ARCH_ARM_GET_NEXT_PCS_H */
diff --git a/gdb/arch/arm-linux.h b/gdb/arch/arm-linux.h
index 68862521bbc..39c73c34011 100644
--- a/gdb/arch/arm-linux.h
+++ b/gdb/arch/arm-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_LINUX_H
-#define ARCH_ARM_LINUX_H
+#ifndef GDB_ARCH_ARM_LINUX_H
+#define GDB_ARCH_ARM_LINUX_H
 
 /* The index to access CSPR in user_regs defined in GLIBC.  */
 #define ARM_CPSR_GREGNUM 16
@@ -79,4 +79,4 @@ struct arm_get_next_pcs;
 CORE_ADDR arm_linux_get_next_pcs_fixup (struct arm_get_next_pcs *self,
 					CORE_ADDR pc);
 
-#endif /* ARCH_ARM_LINUX_H */
+#endif /* GDB_ARCH_ARM_LINUX_H */
diff --git a/gdb/arch/arm.h b/gdb/arch/arm.h
index 34cf7ca79cf..7738d9c6611 100644
--- a/gdb/arch/arm.h
+++ b/gdb/arch/arm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_H
-#define ARCH_ARM_H
+#ifndef GDB_ARCH_ARM_H
+#define GDB_ARCH_ARM_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -227,4 +227,4 @@ target_desc *arm_create_target_description (arm_fp_type fp_type, bool tls);
 
 target_desc *arm_create_mprofile_target_description (arm_m_profile_type m_type);
 
-#endif /* ARCH_ARM_H */
+#endif /* GDB_ARCH_ARM_H */
diff --git a/gdb/arch/csky.h b/gdb/arch/csky.h
index 290bf97dd12..67b2f176114 100644
--- a/gdb/arch/csky.h
+++ b/gdb/arch/csky.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_CSKY_H
-#define ARCH_CSKY_H
+#ifndef GDB_ARCH_CSKY_H
+#define GDB_ARCH_CSKY_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -26,4 +26,4 @@
 
 target_desc_up csky_create_target_description (void);
 
-#endif /* ARCH_CSKY_H */
+#endif /* GDB_ARCH_CSKY_H */
diff --git a/gdb/arch/i386.h b/gdb/arch/i386.h
index d0519f1b551..1b5cc6e1095 100644
--- a/gdb/arch/i386.h
+++ b/gdb/arch/i386.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_I386_H
-#define ARCH_I386_H
+#ifndef GDB_ARCH_I386_H
+#define GDB_ARCH_I386_H
 
 #include "gdbsupport/tdesc.h"
 #include <stdint.h>
@@ -24,4 +24,4 @@
 target_desc *i386_create_target_description (uint64_t xcr0, bool is_linux,
 					     bool segments);
 
-#endif /* ARCH_I386_H */
+#endif /* GDB_ARCH_I386_H */
diff --git a/gdb/arch/loongarch.h b/gdb/arch/loongarch.h
index 7056d506bf4..07f37d8d7e8 100644
--- a/gdb/arch/loongarch.h
+++ b/gdb/arch/loongarch.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_LOONGARCH_H
-#define ARCH_LOONGARCH_H
+#ifndef GDB_ARCH_LOONGARCH_H
+#define GDB_ARCH_LOONGARCH_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -128,4 +128,4 @@ const target_desc *loongarch_lookup_target_description
 
 #endif /* GDBSERVER */
 
-#endif /* ARCH_LOONGARCH_H  */
+#endif /* GDB_ARCH_LOONGARCH_H */
diff --git a/gdb/arch/ppc-linux-common.h b/gdb/arch/ppc-linux-common.h
index 05704c8f898..1f72b295de8 100644
--- a/gdb/arch/ppc-linux-common.h
+++ b/gdb/arch/ppc-linux-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_PPC_LINUX_COMMON_H
-#define ARCH_PPC_LINUX_COMMON_H
+#ifndef GDB_ARCH_PPC_LINUX_COMMON_H
+#define GDB_ARCH_PPC_LINUX_COMMON_H
 
 struct target_desc;
 
@@ -75,4 +75,4 @@ const struct ppc_linux_features ppc_linux_no_features = {
 const struct target_desc * ppc_linux_match_description
 (struct ppc_linux_features features);
 
-#endif /* ARCH_PPC_LINUX_COMMON_H */
+#endif /* GDB_ARCH_PPC_LINUX_COMMON_H */
diff --git a/gdb/arch/ppc-linux-tdesc.h b/gdb/arch/ppc-linux-tdesc.h
index 0a022071c08..bde6ba225bd 100644
--- a/gdb/arch/ppc-linux-tdesc.h
+++ b/gdb/arch/ppc-linux-tdesc.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_PPC_LINUX_TDESC_H
-#define ARCH_PPC_LINUX_TDESC_H
+#ifndef GDB_ARCH_PPC_LINUX_TDESC_H
+#define GDB_ARCH_PPC_LINUX_TDESC_H
 
 struct target_desc;
 
@@ -43,4 +43,4 @@ extern const struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l;
 extern const struct target_desc *tdesc_powerpc_isa207_vsx64l;
 extern const struct target_desc *tdesc_powerpc_isa207_htm_vsx64l;
 
-#endif /* ARCH_PPC_LINUX_TDESC_H */
+#endif /* GDB_ARCH_PPC_LINUX_TDESC_H */
diff --git a/gdb/arch/riscv.h b/gdb/arch/riscv.h
index 925fffee18a..bf65b0bc5a8 100644
--- a/gdb/arch/riscv.h
+++ b/gdb/arch/riscv.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_RISCV_H
-#define ARCH_RISCV_H
+#ifndef GDB_ARCH_RISCV_H
+#define GDB_ARCH_RISCV_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -119,4 +119,4 @@ const target_desc *riscv_lookup_target_description
 #endif /* GDBSERVER */
 
 
-#endif /* ARCH_RISCV_H */
+#endif /* GDB_ARCH_RISCV_H */
diff --git a/gdb/arch/tic6x.h b/gdb/arch/tic6x.h
index da67da7c5fb..efb3282c506 100644
--- a/gdb/arch/tic6x.h
+++ b/gdb/arch/tic6x.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_TIC6X_H
-#define ARCH_TIC6X_H
+#ifndef GDB_ARCH_TIC6X_H
+#define GDB_ARCH_TIC6X_H
 
 enum c6x_feature
 {
@@ -28,4 +28,4 @@ enum c6x_feature
 
 target_desc *tic6x_create_target_description (enum c6x_feature feature);
 
-#endif /* ARCH_TIC6X_H */
+#endif /* GDB_ARCH_TIC6X_H */
diff --git a/gdb/arch/xtensa.h b/gdb/arch/xtensa.h
index 5961641cad8..70167b304ce 100644
--- a/gdb/arch/xtensa.h
+++ b/gdb/arch/xtensa.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_XTENSA_H
-#define ARCH_XTENSA_H
+#ifndef GDB_ARCH_XTENSA_H
+#define GDB_ARCH_XTENSA_H
 
 /* Xtensa ELF core file register set representation ('.reg' section).
    Copied from target-side ELF header <xtensa/elf.h>.  */
@@ -45,4 +45,4 @@ typedef struct
 
 #define C0_NREGS   16	/* Number of A-registers to track in call0 ABI.  */
 
-#endif /* ARCH_XTENSA_H */
+#endif /* GDB_ARCH_XTENSA_H */
diff --git a/gdb/arm-fbsd-tdep.h b/gdb/arm-fbsd-tdep.h
index 26a9dbcdd21..151f26c83b7 100644
--- a/gdb/arm-fbsd-tdep.h
+++ b/gdb/arm-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_FBSD_TDEP_H
-#define ARM_FBSD_TDEP_H
+#ifndef GDB_ARM_FBSD_TDEP_H
+#define GDB_ARM_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -56,4 +56,4 @@ extern const struct target_desc *
 extern const struct target_desc *
   arm_fbsd_read_description_auxv (bool tls);
 
-#endif /* ARM_FBSD_TDEP_H */
+#endif /* GDB_ARM_FBSD_TDEP_H */
diff --git a/gdb/arm-linux-tdep.h b/gdb/arm-linux-tdep.h
index a6eeb333351..7aa69ce3f4c 100644
--- a/gdb/arm-linux-tdep.h
+++ b/gdb/arm-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_LINUX_TDEP_H
-#define ARM_LINUX_TDEP_H
+#ifndef GDB_ARM_LINUX_TDEP_H
+#define GDB_ARM_LINUX_TDEP_H
 
 struct regset;
 struct regcache;
@@ -67,4 +67,4 @@ void arm_linux_collect_nwfpe (const struct regset *regset,
 #define HWCAP_VFPv3     8192
 #define HWCAP_VFPv3D16  16384
 
-#endif /* ARM_LINUX_TDEP_H */
+#endif /* GDB_ARM_LINUX_TDEP_H */
diff --git a/gdb/arm-netbsd-tdep.h b/gdb/arm-netbsd-tdep.h
index 75b1fb9bd27..6e554d4ca21 100644
--- a/gdb/arm-netbsd-tdep.h
+++ b/gdb/arm-netbsd-tdep.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_NBSD_TDEP_H
-#define ARM_NBSD_TDEP_H
+#ifndef GDB_ARM_NETBSD_TDEP_H
+#define GDB_ARM_NETBSD_TDEP_H
 
 void arm_nbsd_supply_gregset
   (const struct regset *regset, struct regcache *regcache,
    int regnum, const void *gregs, size_t len);
 
-#endif
+#endif /* GDB_ARM_NETBSD_TDEP_H */
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 11839b0ff4d..f8049f4673c 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_TDEP_H
-#define ARM_TDEP_H
+#ifndef GDB_ARM_TDEP_H
+#define GDB_ARM_TDEP_H
 
 /* Forward declarations.  */
 struct regset;
@@ -326,4 +326,4 @@ const target_desc *arm_read_description (arm_fp_type fp_type, bool tls);
    type.  */
 const target_desc *arm_read_mprofile_description (arm_m_profile_type m_type);
 
-#endif /* arm-tdep.h */
+#endif /* GDB_ARM_TDEP_H */
diff --git a/gdb/async-event.h b/gdb/async-event.h
index 1027f9d6fb3..16045f42448 100644
--- a/gdb/async-event.h
+++ b/gdb/async-event.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ASYNC_EVENT_H
-#define ASYNC_EVENT_H
+#ifndef GDB_ASYNC_EVENT_H
+#define GDB_ASYNC_EVENT_H
 
 #include "gdbsupport/event-loop.h"
 
@@ -87,4 +87,4 @@ extern void clear_async_event_handler (struct async_event_handler *handler);
 
 extern void initialize_async_signal_handlers (void);
 
-#endif /* ASYNC_EVENT_H */
+#endif /* GDB_ASYNC_EVENT_H */
diff --git a/gdb/auto-load.h b/gdb/auto-load.h
index c1003aef0e3..48e6ccfc82f 100644
--- a/gdb/auto-load.h
+++ b/gdb/auto-load.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AUTO_LOAD_H
-#define AUTO_LOAD_H 1
+#ifndef GDB_AUTO_LOAD_H
+#define GDB_AUTO_LOAD_H
 
 struct objfile;
 struct program_space;
@@ -79,4 +79,4 @@ extern bool file_is_auto_load_safe (const char *filename);
 extern bool auto_load_gdb_scripts_enabled
   (const struct extension_language_defn *extlang);
 
-#endif /* AUTO_LOAD_H */
+#endif /* GDB_AUTO_LOAD_H */
diff --git a/gdb/auxv.h b/gdb/auxv.h
index aed430dd851..3faddff7771 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AUXV_H
-#define AUXV_H
+#ifndef GDB_AUXV_H
+#define GDB_AUXV_H
 
 #include "target.h"
 
@@ -88,4 +88,4 @@ extern void default_print_auxv_entry (struct gdbarch *gdbarch,
 extern target_xfer_partial_ftype memory_xfer_auxv;
 
 
-#endif
+#endif /* GDB_AUXV_H */
diff --git a/gdb/ax-gdb.h b/gdb/ax-gdb.h
index 9e2dfea1c51..53f48ff9e33 100644
--- a/gdb/ax-gdb.h
+++ b/gdb/ax-gdb.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AX_GDB_H
-#define AX_GDB_H
+#ifndef GDB_AX_GDB_H
+#define GDB_AX_GDB_H
 
 #include "ax.h"
 
@@ -123,4 +123,4 @@ extern agent_expr_up gen_printf (CORE_ADDR, struct gdbarch *,
 				 CORE_ADDR, LONGEST, const char *, int,
 				 int, struct expression **);
 
-#endif /* AX_GDB_H */
+#endif /* GDB_AX_GDB_H */
diff --git a/gdb/ax.h b/gdb/ax.h
index 46c2393f9e0..45fd560927b 100644
--- a/gdb/ax.h
+++ b/gdb/ax.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AX_H
-#define AX_H
+#ifndef GDB_AX_H
+#define GDB_AX_H
 
 /* It's sometimes useful to be able to debug programs that you can't
    really stop for more than a fraction of a second.  To this end, the
@@ -224,4 +224,4 @@ extern void ax_print (struct ui_file *f, struct agent_expr * EXPR);
 
 extern void ax_reqs (struct agent_expr *ax);
 
-#endif /* AX_H */
+#endif /* GDB_AX_H */
diff --git a/gdb/bcache.h b/gdb/bcache.h
index 17a09880d99..abe9e58c116 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BCACHE_H
-#define BCACHE_H 1
+#ifndef GDB_BCACHE_H
+#define GDB_BCACHE_H
 
 /* A bcache is a data structure for factoring out duplication in
    read-only structures.  You give the bcache some string of bytes S.
@@ -207,4 +207,4 @@ struct bcache
 
 } /* namespace gdb */
 
-#endif /* BCACHE_H */
+#endif /* GDB_BCACHE_H */
diff --git a/gdb/bfd-target.h b/gdb/bfd-target.h
index d20c9263c4b..ab3233e8f6f 100644
--- a/gdb/bfd-target.h
+++ b/gdb/bfd-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BFD_TARGET_H
-#define BFD_TARGET_H
+#ifndef GDB_BFD_TARGET_H
+#define GDB_BFD_TARGET_H
 
 #include "gdb_bfd.h"
 
@@ -27,4 +27,4 @@ struct target_ops;
 /* Given an existing BFD, re-open it as a "struct target_ops".  */
 target_ops_up target_bfd_reopen (const gdb_bfd_ref_ptr &bfd);
 
-#endif
+#endif /* GDB_BFD_TARGET_H */
diff --git a/gdb/bfin-tdep.h b/gdb/bfin-tdep.h
index dbdafae9d45..d28af50406f 100644
--- a/gdb/bfin-tdep.h
+++ b/gdb/bfin-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BFIN_TDEP_H
-#define BFIN_TDEP_H
+#ifndef GDB_BFIN_TDEP_H
+#define GDB_BFIN_TDEP_H
 
 #include "gdbarch.h"
 
@@ -105,4 +105,4 @@ struct bfin_gdbarch_tdep : gdbarch_tdep_base
 /* Return the Blackfin ABI associated with GDBARCH.  */
 extern enum bfin_abi bfin_abi (struct gdbarch *gdbarch);
 
-#endif /* BFIN_TDEP_H */
+#endif /* GDB_BFIN_TDEP_H */
diff --git a/gdb/block.h b/gdb/block.h
index ae676c4ba67..0cc4d7d53f7 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BLOCK_H
-#define BLOCK_H
+#ifndef GDB_BLOCK_H
+#define GDB_BLOCK_H
 
 #include "dictionary.h"
 #include "gdbsupport/array-view.h"
@@ -592,4 +592,4 @@ extern struct symbol *block_find_symbol (const struct block *block,
 struct blockranges *make_blockranges (struct objfile *objfile,
 				      const std::vector<blockrange> &rangevec);
 
-#endif /* BLOCK_H */
+#endif /* GDB_BLOCK_H */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 6da04d5ec00..4db18274e55 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (BREAKPOINT_H)
-#define BREAKPOINT_H 1
+#ifndef GDB_BREAKPOINT_H
+#define GDB_BREAKPOINT_H
 
 #include "frame.h"
 #include "value.h"
@@ -2068,4 +2068,4 @@ extern void enable_disable_bp_location (bp_location *loc, bool enable);
 
 extern void notify_breakpoint_modified (breakpoint *b);
 
-#endif /* !defined (BREAKPOINT_H) */
+#endif /* GDB_BREAKPOINT_H */
diff --git a/gdb/bsd-kvm.h b/gdb/bsd-kvm.h
index 1606eb3acea..6ddd154da4a 100644
--- a/gdb/bsd-kvm.h
+++ b/gdb/bsd-kvm.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BSD_KVM_H
-#define BSD_KVM_H
+#ifndef GDB_BSD_KVM_H
+#define GDB_BSD_KVM_H
 
 struct pcb;
 struct regcache;
@@ -30,4 +30,4 @@ struct regcache;
 extern void
   bsd_kvm_add_target (int (*supply_pcb)(struct regcache *, struct pcb *));
 
-#endif /* bsd-kvm.h */
+#endif /* GDB_BSD_KVM_H */
diff --git a/gdb/bsd-uthread.h b/gdb/bsd-uthread.h
index eabd82dbdaf..e236eaae4f6 100644
--- a/gdb/bsd-uthread.h
+++ b/gdb/bsd-uthread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BSD_UTHREAD_H
-#define BSD_UTHREAD_H 1
+#ifndef GDB_BSD_UTHREAD_H
+#define GDB_BSD_UTHREAD_H
 
 /* Set the function that supplies registers for an inactive thread for
    architecture GDBARCH to SUPPLY_UTHREAD.  */
@@ -35,4 +35,4 @@ extern void bsd_uthread_set_collect_uthread (struct gdbarch *gdbarch,
 			     void (*collect_uthread) (const struct regcache *,
 						      int, CORE_ADDR));
 
-#endif /* bsd-uthread.h */
+#endif /* GDB_BSD_UTHREAD_H */
diff --git a/gdb/bt-utils.h b/gdb/bt-utils.h
index ec2d14a5484..819dd8caf86 100644
--- a/gdb/bt-utils.h
+++ b/gdb/bt-utils.h
@@ -18,8 +18,8 @@
 /* Support for printing a backtrace when GDB hits an error.  This is not
    for printing backtraces of the inferior, but backtraces of GDB itself.  */
 
-#ifndef BT_UTILS_H
-#define BT_UTILS_H
+#ifndef GDB_BT_UTILS_H
+#define GDB_BT_UTILS_H
 
 #ifdef HAVE_LIBBACKTRACE
 # include "backtrace.h"
@@ -71,4 +71,4 @@ extern void gdb_internal_backtrace ();
 extern void gdb_internal_backtrace_set_cmd (const char *args, int from_tty,
 					    cmd_list_element *c);
 
-#endif /* BT_UTILS_H */
+#endif /* GDB_BT_UTILS_H */
diff --git a/gdb/btrace.h b/gdb/btrace.h
index f05ec2bca04..dc9541960e0 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BTRACE_H
-#define BTRACE_H
+#ifndef GDB_BTRACE_H
+#define GDB_BTRACE_H
 
 /* Branch tracing (btrace) is a per-thread control-flow execution trace of the
    inferior.  For presentation purposes, the branch trace is represented as a
@@ -498,4 +498,4 @@ extern int btrace_is_replaying (struct thread_info *tp);
 /* Return non-zero if the branch trace for TP is empty; zero otherwise.  */
 extern int btrace_is_empty (struct thread_info *tp);
 
-#endif /* BTRACE_H */
+#endif /* GDB_BTRACE_H */
diff --git a/gdb/build-id.h b/gdb/build-id.h
index 15bd8a964dc..5bf338299b1 100644
--- a/gdb/build-id.h
+++ b/gdb/build-id.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BUILD_ID_H
-#define BUILD_ID_H
+#ifndef GDB_BUILD_ID_H
+#define GDB_BUILD_ID_H
 
 #include "gdb_bfd.h"
 #include "gdbsupport/rsp-low.h"
@@ -70,4 +70,4 @@ build_id_to_string (const bfd_build_id *build_id)
   return bin2hex (build_id->data, build_id->size);
 }
 
-#endif /* BUILD_ID_H */
+#endif /* GDB_BUILD_ID_H */
diff --git a/gdb/buildsym-legacy.h b/gdb/buildsym-legacy.h
index 1fb545831b8..1f032c42751 100644
--- a/gdb/buildsym-legacy.h
+++ b/gdb/buildsym-legacy.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BUILDSYM_LEGACY_H
-#define BUILDSYM_LEGACY_H
+#ifndef GDB_BUILDSYM_LEGACY_H
+#define GDB_BUILDSYM_LEGACY_H
 
 #include "buildsym.h"
 
@@ -144,4 +144,4 @@ extern struct pending **get_global_symbols ();
 
 extern struct buildsym_compunit *get_buildsym_compunit ();
 
-#endif /* BUILDSYM_LEGACY_H */
+#endif /* GDB_BUILDSYM_LEGACY_H */
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index c1eed247d25..974645c1c47 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (BUILDSYM_H)
-#define BUILDSYM_H 1
+#ifndef GDB_BUILDSYM_H
+#define GDB_BUILDSYM_H
 
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
@@ -456,4 +456,4 @@ extern void add_symbol_to_list (struct symbol *symbol,
 extern struct symbol *find_symbol_in_list (struct pending *list,
 					   char *name, int length);
 
-#endif /* defined (BUILDSYM_H) */
+#endif /* GDB_BUILDSYM_H */
diff --git a/gdb/c-exp.h b/gdb/c-exp.h
index a76f1bc8213..a6c084d32be 100644
--- a/gdb/c-exp.h
+++ b/gdb/c-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef C_EXP_H
-#define C_EXP_H
+#ifndef GDB_C_EXP_H
+#define GDB_C_EXP_H
 
 #include "expop.h"
 #include "objc-lang.h"
@@ -217,4 +217,4 @@ class opencl_ternop_cond_operation
 
 }/* namespace expr */
 
-#endif /* C_EXP_H */
+#endif /* GDB_C_EXP_H */
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 8dc47ac8be5..0e733d810d8 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#if !defined (C_LANG_H)
-#define C_LANG_H 1
+#ifndef GDB_C_LANG_H
+#define GDB_C_LANG_H
 
 struct ui_file;
 struct language_arch_info;
@@ -174,4 +174,4 @@ extern std::string cplus_compute_program (compile_instance *inst,
 
 extern gdb::unique_xmalloc_ptr<char> c_canonicalize_name (const char *name);
 
-#endif /* !defined (C_LANG_H) */
+#endif /* GDB_C_LANG_H */
diff --git a/gdb/c-support.h b/gdb/c-support.h
index 3718181ba81..30858d1e1af 100644
--- a/gdb/c-support.h
+++ b/gdb/c-support.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef C_SUPPORT_H
-#define C_SUPPORT_H
+#ifndef GDB_C_SUPPORT_H
+#define GDB_C_SUPPORT_H
 
 #include "safe-ctype.h"
 
@@ -43,4 +43,4 @@ c_ident_is_alnum (unsigned char ch)
   return ISALNUM (ch) || ch >= 0x80;
 }
 
-#endif /* C_SUPPORT_H */
+#endif /* GDB_C_SUPPORT_H */
diff --git a/gdb/cgen-remap.h b/gdb/cgen-remap.h
index 35f09c1269b..30b84575263 100644
--- a/gdb/cgen-remap.h
+++ b/gdb/cgen-remap.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CGEN_REMAP_H
-#define CGEN_REMAP_H
+#ifndef GDB_CGEN_REMAP_H
+#define GDB_CGEN_REMAP_H
 
 /* Remap cgen interface names, so we can have multiple cgen generated include
    files in gdb without violating c++ ODR.  */
@@ -50,4 +50,4 @@
 #define CGEN_OPERAND		GDB_CGEN_REMAP (CGEN_OPERAND)
 #define CGEN_MAYBE_MULTI_IFLD	GDB_CGEN_REMAP (CGEN_MAYBE_MULTI_IFLD)
 
-#endif /* CGEN_REMAP_H */
+#endif /* GDB_CGEN_REMAP_H */
diff --git a/gdb/charset-list.h b/gdb/charset-list.h
index c4d0867d580..9da3da2590a 100644
--- a/gdb/charset-list.h
+++ b/gdb/charset-list.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CHARSET_LIST_H
-#define CHARSET_LIST_H
+#ifndef GDB_CHARSET_LIST_H
+#define GDB_CHARSET_LIST_H
 
 /* Note that the first entry must always be "auto".
    The remaining entries were created by running this script:
@@ -1192,4 +1192,4 @@
 "WS2", \
 "YU",
 
-#endif /* CHARSET_LIST_H */
+#endif /* GDB_CHARSET_LIST_H */
diff --git a/gdb/charset.h b/gdb/charset.h
index 4263dc147e9..c4e0de553d3 100644
--- a/gdb/charset.h
+++ b/gdb/charset.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CHARSET_H
-#define CHARSET_H
+#ifndef GDB_CHARSET_H
+#define GDB_CHARSET_H
 
 #include "gdbsupport/def-vector.h"
 
@@ -165,4 +165,4 @@ char host_letter_to_control_character (char c);
 #define HOST_UTF32 "UTF-32LE"
 #endif
 
-#endif /* CHARSET_H */
+#endif /* GDB_CHARSET_H */
diff --git a/gdb/cli-out.h b/gdb/cli-out.h
index f17cb0c9856..5799df559f4 100644
--- a/gdb/cli-out.h
+++ b/gdb/cli-out.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_OUT_H
-#define CLI_OUT_H
+#ifndef GDB_CLI_OUT_H
+#define GDB_CLI_OUT_H
 
 #include "ui-out.h"
 #include <chrono>
@@ -112,4 +112,4 @@ class cli_ui_out : public ui_out
 
 extern void cli_display_match_list (char **matches, int len, int max);
 
-#endif
+#endif /* GDB_CLI_OUT_H */
diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h
index 8f26ca3e17a..6719ad7cae3 100644
--- a/gdb/cli/cli-cmds.h
+++ b/gdb/cli/cli-cmds.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_CMDS_H
-#define CLI_CLI_CMDS_H
+#ifndef GDB_CLI_CLI_CMDS_H
+#define GDB_CLI_CLI_CMDS_H
 
 #include "gdbsupport/filestuff.h"
 #include <optional>
@@ -202,4 +202,4 @@ extern void with_command_completer_1 (const char *set_cmd_prefix,
 				      completion_tracker &tracker,
 				      const char *text);
 
-#endif /* CLI_CLI_CMDS_H */
+#endif /* GDB_CLI_CLI_CMDS_H */
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 7365c3f0157..2219d62fbf3 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_DECODE_H
-#define CLI_CLI_DECODE_H
+#ifndef GDB_CLI_CLI_DECODE_H
+#define GDB_CLI_CLI_DECODE_H
 
 /* This file defines the private interfaces for any code implementing
    command internals.  */
@@ -313,4 +313,4 @@ extern int cli_user_command_p (struct cmd_list_element *);
 
 extern int find_command_name_length (const char *);
 
-#endif /* CLI_CLI_DECODE_H */
+#endif /* GDB_CLI_CLI_DECODE_H */
diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h
index 137eb466f6b..fc3dee7b68b 100644
--- a/gdb/cli/cli-interp.h
+++ b/gdb/cli/cli-interp.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_INTERP_H
-#define CLI_CLI_INTERP_H
+#ifndef GDB_CLI_CLI_INTERP_H
+#define GDB_CLI_CLI_INTERP_H
 
 #include "interps.h"
 
@@ -69,4 +69,4 @@ class cli_interp_base : public interp
 extern int should_print_stop_to_console (struct interp *interp,
 					 struct thread_info *tp);
 
-#endif /* CLI_CLI_INTERP_H */
+#endif /* GDB_CLI_CLI_INTERP_H */
diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h
index bbe281d9721..35e5bdcd684 100644
--- a/gdb/cli/cli-option.h
+++ b/gdb/cli/cli-option.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_OPTION_H
-#define CLI_OPTION_H 1
+#ifndef GDB_CLI_CLI_OPTION_H
+#define GDB_CLI_CLI_OPTION_H
 
 #include <optional>
 #include "gdbsupport/array-view.h"
@@ -379,4 +379,4 @@ extern void add_setshow_cmds_for_options (command_class cmd_class, void *data,
 } /* namespace option */
 } /* namespace gdb */
 
-#endif /* CLI_OPTION_H */
+#endif /* GDB_CLI_CLI_OPTION_H */
diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h
index d36743e5a31..1f0cfd3c1dd 100644
--- a/gdb/cli/cli-script.h
+++ b/gdb/cli/cli-script.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_SCRIPT_H
-#define CLI_CLI_SCRIPT_H
+#ifndef GDB_CLI_CLI_SCRIPT_H
+#define GDB_CLI_CLI_SCRIPT_H
 
 #include "gdbsupport/function-view.h"
 
@@ -181,4 +181,4 @@ extern void print_command_trace (const char *cmd, ...)
 
 extern void reset_command_nest_depth (void);
 
-#endif /* CLI_CLI_SCRIPT_H */
+#endif /* GDB_CLI_CLI_SCRIPT_H */
diff --git a/gdb/cli/cli-setshow.h b/gdb/cli/cli-setshow.h
index 4b8875d5794..9eac86fc674 100644
--- a/gdb/cli/cli-setshow.h
+++ b/gdb/cli/cli-setshow.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_SETSHOW_H
-#define CLI_CLI_SETSHOW_H
+#ifndef GDB_CLI_CLI_SETSHOW_H
+#define GDB_CLI_CLI_SETSHOW_H
 
 #include <string>
 
@@ -60,4 +60,4 @@ extern std::string get_setshow_command_value_string (const setting &var);
 
 extern void cmd_show_list (struct cmd_list_element *list, int from_tty);
 
-#endif /* CLI_CLI_SETSHOW_H */
+#endif /* GDB_CLI_CLI_SETSHOW_H */
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index 31d40ed65ca..1a9c8e65b60 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_STYLE_H
-#define CLI_CLI_STYLE_H
+#ifndef GDB_CLI_CLI_STYLE_H
+#define GDB_CLI_CLI_STYLE_H
 
 #include "ui-file.h"
 #include "command.h"
@@ -150,4 +150,4 @@ extern bool disassembler_styling;
 /* True if styling is enabled.  */
 extern bool cli_styling;
 
-#endif /* CLI_CLI_STYLE_H */
+#endif /* GDB_CLI_CLI_STYLE_H */
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index 54b45fdc796..e11430ecb70 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_UTILS_H
-#define CLI_CLI_UTILS_H
+#ifndef GDB_CLI_CLI_UTILS_H
+#define GDB_CLI_CLI_UTILS_H
 
 #include "completer.h"
 
@@ -225,4 +225,4 @@ struct qcs_flags
    message.  */
 extern void validate_flags_qcs (const char *which_command, qcs_flags *flags);
 
-#endif /* CLI_CLI_UTILS_H */
+#endif /* GDB_CLI_CLI_UTILS_H */
diff --git a/gdb/coff-pe-read.h b/gdb/coff-pe-read.h
index d596240f97d..c1510460f9b 100644
--- a/gdb/coff-pe-read.h
+++ b/gdb/coff-pe-read.h
@@ -19,8 +19,8 @@
 
    Contributed by Raoul M. Gough (RaoulGough@yahoo.co.uk).  */
 
-#if !defined (COFF_PE_READ_H)
-#define COFF_PE_READ_H
+#ifndef GDB_COFF_PE_READ_H
+#define GDB_COFF_PE_READ_H
 
 class minimal_symbol_reader;
 struct objfile;
@@ -35,4 +35,4 @@ extern void read_pe_exported_syms (minimal_symbol_reader &reader,
    Returns default value 0x1000 if information is not found.  */
 extern CORE_ADDR pe_text_section_offset (struct bfd *abfd);
 
-#endif /* !defined (COFF_PE_READ_H) */
+#endif /* GDB_COFF_PE_READ_H */
diff --git a/gdb/command.h b/gdb/command.h
index 615f4e524aa..4f83d3515c3 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (COMMAND_H)
-#define COMMAND_H 1
+#ifndef GDB_COMMAND_H
+#define GDB_COMMAND_H
 
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbsupport/scoped_restore.h"
@@ -934,4 +934,4 @@ extern void not_just_help_class_command (const char *, int);
 extern void cmd_func (struct cmd_list_element *cmd,
 		      const char *args, int from_tty);
 
-#endif /* !defined (COMMAND_H) */
+#endif /* GDB_COMMAND_H */
diff --git a/gdb/compile/compile-c.h b/gdb/compile/compile-c.h
index 4670d671a9f..b77b7aab087 100644
--- a/gdb/compile/compile-c.h
+++ b/gdb/compile/compile-c.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_C_H
-#define COMPILE_COMPILE_C_H
+#ifndef GDB_COMPILE_COMPILE_C_H
+#define GDB_COMPILE_COMPILE_C_H
 
 #include "compile/compile.h"
 #include "gdbsupport/enum-flags.h"
@@ -93,4 +93,4 @@ extern std::string c_get_range_decl_name (const struct dynamic_prop *prop);
 extern gdb::unique_xmalloc_ptr<char>
   c_symbol_substitution_name (struct symbol *sym);
 
-#endif /* COMPILE_COMPILE_C_H */
+#endif /* GDB_COMPILE_COMPILE_C_H */
diff --git a/gdb/compile/compile-cplus.h b/gdb/compile/compile-cplus.h
index a714b6dab3c..d3b2d3e9843 100644
--- a/gdb/compile/compile-cplus.h
+++ b/gdb/compile/compile-cplus.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_CPLUS_H
-#define COMPILE_COMPILE_CPLUS_H
+#ifndef GDB_COMPILE_COMPILE_CPLUS_H
+#define GDB_COMPILE_COMPILE_CPLUS_H
 
 #include "compile/compile.h"
 #include "gdbsupport/enum-flags.h"
@@ -204,4 +204,4 @@ class compile_cplus_instance : public compile_instance
 enum gcc_cp_symbol_kind get_method_access_flag (const struct type *type,
 						int fni, int num);
 
-#endif /* COMPILE_COMPILE_CPLUS_H */
+#endif /* GDB_COMPILE_COMPILE_CPLUS_H */
diff --git a/gdb/compile/compile-internal.h b/gdb/compile/compile-internal.h
index 666406b2395..f4cc9ee4984 100644
--- a/gdb/compile/compile-internal.h
+++ b/gdb/compile/compile-internal.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_INTERNAL_H
-#define COMPILE_COMPILE_INTERNAL_H
+#ifndef GDB_COMPILE_COMPILE_INTERNAL_H
+#define GDB_COMPILE_COMPILE_INTERNAL_H
 
 #include "gcc-c-interface.h"
 #include "gdbsupport/gdb-hashtab.h"
@@ -80,4 +80,4 @@ class compile_file_names
   std::string m_object_file;
 };
 
-#endif /* COMPILE_COMPILE_INTERNAL_H */
+#endif /* GDB_COMPILE_COMPILE_INTERNAL_H */
diff --git a/gdb/compile/compile-object-load.h b/gdb/compile/compile-object-load.h
index eb6eb0dd871..bb414f90df4 100644
--- a/gdb/compile/compile-object-load.h
+++ b/gdb/compile/compile-object-load.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_OBJECT_LOAD_H
-#define COMPILE_COMPILE_OBJECT_LOAD_H
+#ifndef GDB_COMPILE_COMPILE_OBJECT_LOAD_H
+#define GDB_COMPILE_COMPILE_OBJECT_LOAD_H
 
 #include "compile-internal.h"
 #include <list>
@@ -94,4 +94,4 @@ extern compile_module_up compile_object_load
   (const compile_file_names &fnames,
    enum compile_i_scope_types scope, void *scope_data);
 
-#endif /* COMPILE_COMPILE_OBJECT_LOAD_H */
+#endif /* GDB_COMPILE_COMPILE_OBJECT_LOAD_H */
diff --git a/gdb/compile/compile-object-run.h b/gdb/compile/compile-object-run.h
index 5d9f23c6a39..64b2bd90a99 100644
--- a/gdb/compile/compile-object-run.h
+++ b/gdb/compile/compile-object-run.h
@@ -14,11 +14,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_OBJECT_RUN_H
-#define COMPILE_COMPILE_OBJECT_RUN_H
+#ifndef GDB_COMPILE_COMPILE_OBJECT_RUN_H
+#define GDB_COMPILE_COMPILE_OBJECT_RUN_H
 
 #include "compile-object-load.h"
 
 extern void compile_object_run (compile_module_up &&module);
 
-#endif /* COMPILE_COMPILE_OBJECT_RUN_H */
+#endif /* GDB_COMPILE_COMPILE_OBJECT_RUN_H */
diff --git a/gdb/compile/compile.h b/gdb/compile/compile.h
index d584df6661c..14b97c4b91c 100644
--- a/gdb/compile/compile.h
+++ b/gdb/compile/compile.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_H
-#define COMPILE_COMPILE_H
+#ifndef GDB_COMPILE_COMPILE_H
+#define GDB_COMPILE_COMPILE_H
 
 #include "gcc-c-interface.h"
 
@@ -231,4 +231,4 @@ extern void compile_print_value (struct value *val, void *data_voidp);
 /* Command element for the 'compile' command.  */
 extern cmd_list_element *compile_cmd_element;
 
-#endif /* COMPILE_COMPILE_H */
+#endif /* GDB_COMPILE_COMPILE_H */
diff --git a/gdb/compile/gcc-c-plugin.h b/gdb/compile/gcc-c-plugin.h
index 4008807526b..d12472f01c1 100644
--- a/gdb/compile/gcc-c-plugin.h
+++ b/gdb/compile/gcc-c-plugin.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_GCC_C_PLUGIN_H
-#define COMPILE_GCC_C_PLUGIN_H
+#ifndef GDB_COMPILE_GCC_C_PLUGIN_H
+#define GDB_COMPILE_GCC_C_PLUGIN_H
 
 #include "compile-internal.h"
 
@@ -68,4 +68,4 @@ class gcc_c_plugin
   struct gcc_c_context *m_context;
 };
 
-#endif /* COMPILE_GCC_C_PLUGIN_H */
+#endif /* GDB_COMPILE_GCC_C_PLUGIN_H */
diff --git a/gdb/compile/gcc-cp-plugin.h b/gdb/compile/gcc-cp-plugin.h
index cf8ccd90725..8f369934127 100644
--- a/gdb/compile/gcc-cp-plugin.h
+++ b/gdb/compile/gcc-cp-plugin.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_GCC_CP_PLUGIN_H
-#define COMPILE_GCC_CP_PLUGIN_H
+#ifndef GDB_COMPILE_GCC_CP_PLUGIN_H
+#define GDB_COMPILE_GCC_CP_PLUGIN_H
 
 /* A class representing the GCC C++ plug-in.  */
 
@@ -87,4 +87,4 @@ class gcc_cp_plugin
   struct gcc_cp_context *m_context;
 };
 
-#endif /* COMPILE_GCC_CP_PLUGIN_H */
+#endif /* GDB_COMPILE_GCC_CP_PLUGIN_H */
diff --git a/gdb/complaints.h b/gdb/complaints.h
index 995c35e0ab0..ab91d05b8a0 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#if !defined (COMPLAINTS_H)
-#define COMPLAINTS_H
+#ifndef GDB_COMPLAINTS_H
+#define GDB_COMPLAINTS_H
 
 #include <unordered_set>
 
@@ -109,4 +109,4 @@ class complaint_interceptor final : public warning_hook_handler_type
 
 extern void re_emit_complaints (const complaint_collection &);
 
-#endif /* !defined (COMPLAINTS_H) */
+#endif /* GDB_COMPLAINTS_H */
diff --git a/gdb/completer.h b/gdb/completer.h
index 98a12f3907c..9ca97c2b435 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (COMPLETER_H)
-#define COMPLETER_H 1
+#ifndef GDB_COMPLETER_H
+#define GDB_COMPLETER_H
 
 #include "gdbsupport/gdb-hashtab.h"
 #include "gdbsupport/gdb_vecs.h"
@@ -661,4 +661,4 @@ extern bool skip_over_slash_fmt (completion_tracker &tracker,
 
 extern int max_completions;
 
-#endif /* defined (COMPLETER_H) */
+#endif /* GDB_COMPLETER_H */
diff --git a/gdb/config/nm-linux.h b/gdb/config/nm-linux.h
index 4ac42cdae1a..d599d3fdef5 100644
--- a/gdb/config/nm-linux.h
+++ b/gdb/config/nm-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CONFIG_NM_LINUX_H
-#define CONFIG_NM_LINUX_H
+#ifndef GDB_CONFIG_NM_LINUX_H
+#define GDB_CONFIG_NM_LINUX_H
 
 /* Use elf_gregset_t and elf_fpregset_t, rather than
    gregset_t and fpregset_t.  */
@@ -26,4 +26,4 @@
 #define GDB_GREGSET_T  elf_gregset_t
 #define GDB_FPREGSET_T elf_fpregset_t
 
-#endif /* CONFIG_NM_LINUX_H */
+#endif /* GDB_CONFIG_NM_LINUX_H */
diff --git a/gdb/config/nm-nto.h b/gdb/config/nm-nto.h
index 5a002df5548..b06cd1f5e03 100644
--- a/gdb/config/nm-nto.h
+++ b/gdb/config/nm-nto.h
@@ -19,11 +19,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CONFIG_NM_NTO_H
-#define CONFIG_NM_NTO_H
+#ifndef GDB_CONFIG_NM_NTO_H
+#define GDB_CONFIG_NM_NTO_H
 
 /* Setup the valid realtime signal range.  */
 #define REALTIME_LO 41
 #define REALTIME_HI 56
 
-#endif /* CONFIG_NM_NTO_H */
+#endif /* GDB_CONFIG_NM_NTO_H */
diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h
index fdbe4843129..6c8d9043463 100644
--- a/gdb/cp-abi.h
+++ b/gdb/cp-abi.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CP_ABI_H
-#define CP_ABI_H
+#ifndef GDB_CP_ABI_H
+#define GDB_CP_ABI_H
 
 struct fn_field;
 struct type;
@@ -255,4 +255,4 @@ struct cp_abi_ops
 extern int register_cp_abi (struct cp_abi_ops *abi);
 extern void set_cp_abi_as_auto_default (const char *short_name);
 
-#endif /* CP_ABI_H */
+#endif /* GDB_CP_ABI_H */
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 4015126154b..e2d480b2f16 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CP_SUPPORT_H
-#define CP_SUPPORT_H
+#ifndef GDB_CP_SUPPORT_H
+#define GDB_CP_SUPPORT_H
 
 #include "symtab.h"
 #include "gdbsupport/gdb_vecs.h"
@@ -212,4 +212,4 @@ extern char *gdb_cplus_demangle_print (int options,
 
 extern const char *find_toplevel_char (const char *s, char c);
 
-#endif /* CP_SUPPORT_H */
+#endif /* GDB_CP_SUPPORT_H */
diff --git a/gdb/cris-tdep.h b/gdb/cris-tdep.h
index f4f4744adaf..8be95473e21 100644
--- a/gdb/cris-tdep.h
+++ b/gdb/cris-tdep.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CRIS_TDEP_H
-#define CRIS_TDEP_H
+#ifndef GDB_CRIS_TDEP_H
+#define GDB_CRIS_TDEP_H
 
 #include "gdbarch.h"
 
@@ -33,4 +33,4 @@ struct cris_gdbarch_tdep : gdbarch_tdep_base
   int cris_dwarf2_cfi = 0;
 };
 
-#endif /* CRIS_TDEP_H */
+#endif /* GDB_CRIS_TDEP_H */
diff --git a/gdb/csky-tdep.h b/gdb/csky-tdep.h
index e5516e83550..29917192298 100644
--- a/gdb/csky-tdep.h
+++ b/gdb/csky-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CSKY_TDEP_H
-#define CSKY_TDEP_H
+#ifndef GDB_CSKY_TDEP_H
+#define GDB_CSKY_TDEP_H
 
 #include "gdbarch.h"
 
@@ -390,4 +390,4 @@ enum csky_regnum
 #define CSKY_LRW_T1_PC_8    0x2ea8d
 #define CSKY_JMP_T1_VS_NOP  0x6c037834
 
-#endif
+#endif /* GDB_CSKY_TDEP_H */
diff --git a/gdb/ctfread.h b/gdb/ctfread.h
index ff348a2487b..711a1dd2902 100644
--- a/gdb/ctfread.h
+++ b/gdb/ctfread.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CTFREAD_H
-#define CTFREAD_H
+#ifndef GDB_CTFREAD_H
+#define GDB_CTFREAD_H
 
 extern void elfctf_build_psymtabs (struct objfile *objfile);
 
-#endif /* CTFREAD_H */
+#endif /* GDB_CTFREAD_H */
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index ecf194d8155..8a944472b32 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (D_LANG_H)
-#define D_LANG_H 1
+#ifndef GDB_D_LANG_H
+#define GDB_D_LANG_H
 
 #include "symtab.h"
 
@@ -84,4 +84,4 @@ extern void d_value_print_inner (struct value *val,
 				 struct ui_file *stream, int recurse,
 				 const struct value_print_options *options);
 
-#endif /* !defined (D_LANG_H) */
+#endif /* GDB_D_LANG_H */
diff --git a/gdb/darwin-nat.h b/gdb/darwin-nat.h
index 71aee57f61a..4ead0ea7003 100644
--- a/gdb/darwin-nat.h
+++ b/gdb/darwin-nat.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DARWIN_NAT_H
-#define DARWIN_NAT_H
+#ifndef GDB_DARWIN_NAT_H
+#define GDB_DARWIN_NAT_H
 
 #include "inf-child.h"
 #include <mach/mach.h>
@@ -210,4 +210,4 @@ void darwin_set_sstep (thread_t thread, int enable);
 
 void darwin_check_osabi (darwin_inferior *inf, thread_t thread);
 
-#endif /* DARWIN_NAT_H */
+#endif /* GDB_DARWIN_NAT_H */
diff --git a/gdb/dcache.h b/gdb/dcache.h
index 101e65dc41f..21f49e522c5 100644
--- a/gdb/dcache.h
+++ b/gdb/dcache.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DCACHE_H
-#define DCACHE_H
+#ifndef GDB_DCACHE_H
+#define GDB_DCACHE_H
 
 #include "target.h"
 
@@ -52,4 +52,4 @@ void dcache_update (DCACHE *dcache, enum target_xfer_status status,
 		    CORE_ADDR memaddr, const gdb_byte *myaddr,
 		    ULONGEST len);
 
-#endif /* DCACHE_H */
+#endif /* GDB_DCACHE_H */
diff --git a/gdb/debuginfod-support.h b/gdb/debuginfod-support.h
index 2b816fd4b82..2b396dc13c1 100644
--- a/gdb/debuginfod-support.h
+++ b/gdb/debuginfod-support.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DEBUGINFOD_SUPPORT_H
-#define DEBUGINFOD_SUPPORT_H
+#ifndef GDB_DEBUGINFOD_SUPPORT_H
+#define GDB_DEBUGINFOD_SUPPORT_H
 
 #include "gdbsupport/scoped_fd.h"
 
@@ -105,4 +105,4 @@ extern scoped_fd debuginfod_section_query (const unsigned char *build_id,
 					   const char *section_name,
 					   gdb::unique_xmalloc_ptr<char>
 					     *destname);
-#endif /* DEBUGINFOD_SUPPORT_H */
+#endif /* GDB_DEBUGINFOD_SUPPORT_H */
diff --git a/gdb/defs.h b/gdb/defs.h
index cf471bf5d66..212599b2bcc 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DEFS_H
-#define DEFS_H
+#ifndef GDB_DEFS_H
+#define GDB_DEFS_H
 
 #ifdef GDBSERVER
 #  error gdbserver should not include gdb/defs.h
@@ -619,4 +619,4 @@ DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
 
 #include "utils.h"
 
-#endif /* #ifndef DEFS_H */
+#endif /* GDB_DEFS_H */
diff --git a/gdb/dicos-tdep.h b/gdb/dicos-tdep.h
index 1e3eb41a41f..5305debd707 100644
--- a/gdb/dicos-tdep.h
+++ b/gdb/dicos-tdep.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DICOS_TDEP_H
-#define DICOS_TDEP_H
+#ifndef GDB_DICOS_TDEP_H
+#define GDB_DICOS_TDEP_H
 
 extern void dicos_init_abi (struct gdbarch *gdbarch);
 extern int dicos_load_module_p (bfd *abfd, int header_size);
 
-#endif /* dicos-tdep.h */
+#endif /* GDB_DICOS_TDEP_H */
diff --git a/gdb/dictionary.h b/gdb/dictionary.h
index 6f602f4a18b..a06aa1738f1 100644
--- a/gdb/dictionary.h
+++ b/gdb/dictionary.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DICTIONARY_H
-#define DICTIONARY_H
+#ifndef GDB_DICTIONARY_H
+#define GDB_DICTIONARY_H
 
 #include "symfile.h"
 
@@ -208,4 +208,4 @@ struct mdict_iterator_wrapper
   struct mdict_iterator m_iter;
 };
 
-#endif /* DICTIONARY_H */
+#endif /* GDB_DICTIONARY_H */
diff --git a/gdb/disasm-flags.h b/gdb/disasm-flags.h
index b2f0ec95b07..9d4011cebf2 100644
--- a/gdb/disasm-flags.h
+++ b/gdb/disasm-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISASM_FLAGS_H
-#define DISASM_FLAGS_H
+#ifndef GDB_DISASM_FLAGS_H
+#define GDB_DISASM_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -37,4 +37,4 @@ enum gdb_disassembly_flag : unsigned
   };
 DEF_ENUM_FLAGS_TYPE (enum gdb_disassembly_flag, gdb_disassembly_flags);
 
-#endif /* DISASM_FLAGS_H */
+#endif /* GDB_DISASM_FLAGS_H */
diff --git a/gdb/disasm.h b/gdb/disasm.h
index 9282632b270..60d7e0fc834 100644
--- a/gdb/disasm.h
+++ b/gdb/disasm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISASM_H
-#define DISASM_H
+#ifndef GDB_DISASM_H
+#define GDB_DISASM_H
 
 #include "dis-asm.h"
 #include "disasm-flags.h"
@@ -391,4 +391,4 @@ extern const char *get_disassembler_options (struct gdbarch *gdbarch);
 
 extern void set_disassembler_options (const char *options);
 
-#endif
+#endif /* GDB_DISASM_H */
diff --git a/gdb/displaced-stepping.h b/gdb/displaced-stepping.h
index ba0d56c2a1f..d7a537a58c9 100644
--- a/gdb/displaced-stepping.h
+++ b/gdb/displaced-stepping.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISPLACED_STEPPING_H
-#define DISPLACED_STEPPING_H
+#ifndef GDB_DISPLACED_STEPPING_H
+#define GDB_DISPLACED_STEPPING_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/byte-vector.h"
@@ -207,4 +207,4 @@ struct displaced_step_buffers
   std::vector<displaced_step_buffer> m_buffers;
 };
 
-#endif /* DISPLACED_STEPPING_H */
+#endif /* GDB_DISPLACED_STEPPING_H */
diff --git a/gdb/dummy-frame.h b/gdb/dummy-frame.h
index 7d963ad9beb..78998e84413 100644
--- a/gdb/dummy-frame.h
+++ b/gdb/dummy-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DUMMY_FRAME_H)
-#define DUMMY_FRAME_H 1
+#ifndef GDB_DUMMY_FRAME_H
+#define GDB_DUMMY_FRAME_H
 
 #include "frame.h"
 
@@ -80,4 +80,4 @@ extern int find_dummy_frame_dtor (dummy_frame_dtor_ftype *dtor,
 extern struct frame_id default_dummy_id (struct gdbarch *gdbarch,
 					 const frame_info_ptr &this_frame);
 
-#endif /* !defined (DUMMY_FRAME_H)  */
+#endif /* GDB_DUMMY_FRAME_H */
diff --git a/gdb/dwarf2/call-site.h b/gdb/dwarf2/call-site.h
index 0a0c7e83b81..0c587470311 100644
--- a/gdb/dwarf2/call-site.h
+++ b/gdb/dwarf2/call-site.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CALL_SITE_H
-#define CALL_SITE_H
+#ifndef GDB_DWARF2_CALL_SITE_H
+#define GDB_DWARF2_CALL_SITE_H
 
 #include "dwarf2/types.h"
 #include "../frame.h"
@@ -241,4 +241,4 @@ struct call_site
   struct call_site_parameter parameter[];
 };
 
-#endif /* CALL_SITE_H */
+#endif /* GDB_DWARF2_CALL_SITE_H */
diff --git a/gdb/dwarf2/comp-unit-head.h b/gdb/dwarf2/comp-unit-head.h
index fad484c3b93..d161783187c 100644
--- a/gdb/dwarf2/comp-unit-head.h
+++ b/gdb/dwarf2/comp-unit-head.h
@@ -24,8 +24,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DWARF2_COMP_UNIT_H
-#define GDB_DWARF2_COMP_UNIT_H
+#ifndef GDB_DWARF2_COMP_UNIT_HEAD_H
+#define GDB_DWARF2_COMP_UNIT_HEAD_H
 
 #include "dwarf2.h"
 #include "dwarf2/leb.h"
@@ -136,4 +136,4 @@ extern const gdb_byte *read_and_check_comp_unit_head
    const gdb_byte *info_ptr,
    rcuh_kind section_kind);
 
-#endif /* GDB_DWARF2_COMP_UNIT_H */
+#endif /* GDB_DWARF2_COMP_UNIT_HEAD_H */
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index b02cc531640..bbb9cd078ba 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DWARF2EXPR_H)
-#define DWARF2EXPR_H
+#ifndef GDB_DWARF2_EXPR_H
+#define GDB_DWARF2_EXPR_H
 
 #include "leb128.h"
 #include "dwarf2/call-site.h"
@@ -320,4 +320,4 @@ extern const gdb_byte *safe_read_sleb128 (const gdb_byte *buf,
 extern const gdb_byte *safe_skip_leb128 (const gdb_byte *buf,
 					 const gdb_byte *buf_end);
 
-#endif /* DWARF2EXPR_H */
+#endif /* GDB_DWARF2_EXPR_H */
diff --git a/gdb/dwarf2/frame-tailcall.h b/gdb/dwarf2/frame-tailcall.h
index 3f49487ac2a..558957eb999 100644
--- a/gdb/dwarf2/frame-tailcall.h
+++ b/gdb/dwarf2/frame-tailcall.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_FRAME_TAILCALL_H
-#define DWARF2_FRAME_TAILCALL_H 1
+#ifndef GDB_DWARF2_FRAME_TAILCALL_H
+#define GDB_DWARF2_FRAME_TAILCALL_H
 
 class frame_info_ptr;
 struct frame_unwind;
@@ -36,4 +36,4 @@ extern struct value *
 
 extern const struct frame_unwind dwarf2_tailcall_frame_unwind;
 
-#endif /* !DWARF2_FRAME_TAILCALL_H */
+#endif /* GDB_DWARF2_FRAME_TAILCALL_H */
diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h
index 2167310fbdf..f53f4bdd864 100644
--- a/gdb/dwarf2/frame.h
+++ b/gdb/dwarf2/frame.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_FRAME_H
-#define DWARF2_FRAME_H 1
+#ifndef GDB_DWARF2_FRAME_H
+#define GDB_DWARF2_FRAME_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -294,4 +294,4 @@ extern void *dwarf2_frame_get_fn_data (const frame_info_ptr &this_frame,
 				       void **this_cache,
 				       fn_prev_register cookie);
 
-#endif /* dwarf2-frame.h */
+#endif /* GDB_DWARF2_FRAME_H */
diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h
index 95f217ed961..922c1568f8e 100644
--- a/gdb/dwarf2/index-cache.h
+++ b/gdb/dwarf2/index-cache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_CACHE_H
-#define DWARF_INDEX_CACHE_H
+#ifndef GDB_DWARF2_INDEX_CACHE_H
+#define GDB_DWARF2_INDEX_CACHE_H
 
 #include "dwarf2/index-common.h"
 #include "gdbsupport/array-view.h"
@@ -137,4 +137,4 @@ class index_cache
 /* The global instance of the index cache.  */
 extern index_cache global_index_cache;
 
-#endif /* DWARF_INDEX_CACHE_H */
+#endif /* GDB_DWARF2_INDEX_CACHE_H */
diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h
index dca41517b3d..4c029f4318e 100644
--- a/gdb/dwarf2/index-common.h
+++ b/gdb/dwarf2/index-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_COMMON_H
-#define DWARF_INDEX_COMMON_H
+#ifndef GDB_DWARF2_INDEX_COMMON_H
+#define GDB_DWARF2_INDEX_COMMON_H
 
 /* The suffix for an index file.  */
 #define INDEX4_SUFFIX ".gdb-index"
@@ -56,4 +56,4 @@ uint32_t dwarf5_djb_hash (const char *str_);
 
 uint32_t dwarf5_djb_hash (std::string_view str_);
 
-#endif /* DWARF_INDEX_COMMON_H */
+#endif /* GDB_DWARF2_INDEX_COMMON_H */
diff --git a/gdb/dwarf2/index-write.h b/gdb/dwarf2/index-write.h
index b7cf564efc5..1982e8510fc 100644
--- a/gdb/dwarf2/index-write.h
+++ b/gdb/dwarf2/index-write.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_WRITE_H
-#define DWARF_INDEX_WRITE_H
+#ifndef GDB_DWARF2_INDEX_WRITE_H
+#define GDB_DWARF2_INDEX_WRITE_H
 
 #include "dwarf2/read.h"
 #include "dwarf2/public.h"
@@ -36,4 +36,4 @@ extern void write_dwarf_index
   (dwarf2_per_bfd *per_bfd, const char *dir, const char *basename,
    const char *dwz_basename, dw_index_kind index_kind);
 
-#endif /* DWARF_INDEX_WRITE_H */
+#endif /* GDB_DWARF2_INDEX_WRITE_H */
diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index c068dff70a3..b9bc55a926e 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_LINE_HEADER_H
-#define DWARF2_LINE_HEADER_H
+#ifndef GDB_DWARF2_LINE_HEADER_H
+#define GDB_DWARF2_LINE_HEADER_H
 
 /* dir_index is 1-based in DWARF 4 and before, and is 0-based in DWARF 5 and
    later.  */
@@ -217,4 +217,4 @@ extern line_header_up dwarf_decode_line_header
    struct dwarf2_section_info *section, const struct comp_unit_head *cu_header,
    const char *comp_dir);
 
-#endif /* DWARF2_LINE_HEADER_H */
+#endif /* GDB_DWARF2_LINE_HEADER_H */
diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h
index 4fb743618e7..78635682d94 100644
--- a/gdb/dwarf2/loc.h
+++ b/gdb/dwarf2/loc.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DWARF2LOC_H)
-#define DWARF2LOC_H
+#ifndef GDB_DWARF2_LOC_H
+#define GDB_DWARF2_LOC_H
 
 #include "dwarf2/expr.h"
 
@@ -308,4 +308,4 @@ extern struct value *value_of_dwarf_reg_entry (struct type *type,
 					       const frame_info_ptr &frame,
 					       enum call_site_parameter_kind kind,
 					       union call_site_parameter_u kind_u);
-#endif /* DWARF2LOC_H */
+#endif /* GDB_DWARF2_LOC_H */
diff --git a/gdb/dwarf2/public.h b/gdb/dwarf2/public.h
index bc419ff208f..8247641b25b 100644
--- a/gdb/dwarf2/public.h
+++ b/gdb/dwarf2/public.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_PUBLIC_H
-#define DWARF2_PUBLIC_H
+#ifndef GDB_DWARF2_PUBLIC_H
+#define GDB_DWARF2_PUBLIC_H
 
 /* A DWARF names index variant.  */
 enum class dw_index_kind
@@ -44,4 +44,4 @@ extern bool dwarf2_initialize_objfile
 
 extern void dwarf2_build_frame_info (struct objfile *);
 
-#endif /* DWARF2_PUBLIC_H */
+#endif /* GDB_DWARF2_PUBLIC_H */
diff --git a/gdb/dwarf2/read-debug-names.h b/gdb/dwarf2/read-debug-names.h
index e616cf887a7..729fe898ea8 100644
--- a/gdb/dwarf2/read-debug-names.h
+++ b/gdb/dwarf2/read-debug-names.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_READ_DEBUG_NAMES_H
-#define DWARF2_READ_DEBUG_NAMES_H
+#ifndef GDB_DWARF2_READ_DEBUG_NAMES_H
+#define GDB_DWARF2_READ_DEBUG_NAMES_H
 
 struct dwarf2_per_objfile;
 
@@ -29,4 +29,4 @@ extern const gdb_byte dwarf5_augmentation[8];
 
 bool dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile);
 
-#endif /* DWARF2_READ_DEBUG_NAMES_H */
+#endif /* GDB_DWARF2_READ_DEBUG_NAMES_H */
diff --git a/gdb/dwarf2/read-gdb-index.h b/gdb/dwarf2/read-gdb-index.h
index e411114b147..906e3bd0bed 100644
--- a/gdb/dwarf2/read-gdb-index.h
+++ b/gdb/dwarf2/read-gdb-index.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_READ_GDB_INDEX_H
-#define DWARF2_READ_GDB_INDEX_H
+#ifndef GDB_DWARF2_READ_GDB_INDEX_H
+#define GDB_DWARF2_READ_GDB_INDEX_H
 
 #include "gdbsupport/function-view.h"
 
@@ -44,4 +44,4 @@ int dwarf2_read_gdb_index
    get_gdb_index_contents_ftype get_gdb_index_contents,
    get_gdb_index_contents_dwz_ftype get_gdb_index_contents_dwz);
 
-#endif /* DWARF2_READ_GDB_INDEX_H */
+#endif /* GDB_DWARF2_READ_GDB_INDEX_H */
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 73def88c4c0..76bf6a422f4 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2READ_H
-#define DWARF2READ_H
+#ifndef GDB_DWARF2_READ_H
+#define GDB_DWARF2_READ_H
 
 #include <queue>
 #include <unordered_map>
@@ -932,4 +932,4 @@ extern void create_all_units (dwarf2_per_objfile *per_objfile);
 
 extern htab_up create_quick_file_names_table (unsigned int nr_initial_entries);
 
-#endif /* DWARF2READ_H */
+#endif /* GDB_DWARF2_READ_H */
diff --git a/gdb/dwarf2/types.h b/gdb/dwarf2/types.h
index f0b9febba15..8cb689d652b 100644
--- a/gdb/dwarf2/types.h
+++ b/gdb/dwarf2/types.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_TYPES_H
-#define DWARF2_TYPES_H
+#ifndef GDB_DWARF2_TYPES_H
+#define GDB_DWARF2_TYPES_H
 
 #include "gdbsupport/offset-type.h"
 #include "gdbsupport/underlying.h"
@@ -37,4 +37,4 @@ sect_offset_str (sect_offset offset)
   return hex_string (to_underlying (offset));
 }
 
-#endif /* DWARF2_TYPES_H */
+#endif /* GDB_DWARF2_TYPES_H */
diff --git a/gdb/elf-none-tdep.h b/gdb/elf-none-tdep.h
index ecbf2d776c6..1881e4b8cb6 100644
--- a/gdb/elf-none-tdep.h
+++ b/gdb/elf-none-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NONE_TDEP_H
-#define NONE_TDEP_H
+#ifndef GDB_ELF_NONE_TDEP_H
+#define GDB_ELF_NONE_TDEP_H
 
 struct gdbarch;
 
@@ -27,4 +27,4 @@ struct gdbarch;
 
 void elf_none_init_abi (struct gdbarch *gdbarch);
 
-#endif /* NONE_TDEP_H */
+#endif /* GDB_ELF_NONE_TDEP_H */
diff --git a/gdb/event-top.h b/gdb/event-top.h
index f431f2812b2..7f544b0f27c 100644
--- a/gdb/event-top.h
+++ b/gdb/event-top.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EVENT_TOP_H
-#define EVENT_TOP_H
+#ifndef GDB_EVENT_TOP_H
+#define GDB_EVENT_TOP_H
 
 #include <signal.h>
 
@@ -90,4 +90,4 @@ class scoped_segv_handler_restore
   segv_handler_t m_old_handler;
 };
 
-#endif
+#endif /* GDB_EVENT_TOP_H */
diff --git a/gdb/exceptions.h b/gdb/exceptions.h
index 64f4d75c39c..bf7141dbb9f 100644
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXCEPTIONS_H
-#define EXCEPTIONS_H
+#ifndef GDB_EXCEPTIONS_H
+#define GDB_EXCEPTIONS_H
 
 #include "ui-out.h"
 
@@ -31,4 +31,4 @@ extern void exception_fprintf (struct ui_file *file,
 			       const char *prefix,
 			       ...) ATTRIBUTE_PRINTF (3, 4);
 
-#endif
+#endif /* GDB_EXCEPTIONS_H */
diff --git a/gdb/exec.h b/gdb/exec.h
index f667f23600d..950a21c2f3a 100644
--- a/gdb/exec.h
+++ b/gdb/exec.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXEC_H
-#define EXEC_H
+#ifndef GDB_EXEC_H
+#define GDB_EXEC_H
 
 #include "target.h"
 #include "progspace.h"
@@ -105,4 +105,4 @@ extern void print_section_info (const std::vector<target_section> *table,
 extern void try_open_exec_file (const char *exec_file_host,
 				struct inferior *inf,
 				symfile_add_flags add_flags);
-#endif
+#endif /* GDB_EXEC_H */
diff --git a/gdb/expop.h b/gdb/expop.h
index b81e228c07e..64158bc4706 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXPOP_H
-#define EXPOP_H
+#ifndef GDB_EXPOP_H
+#define GDB_EXPOP_H
 
 #include "c-lang.h"
 #include "cp-abi.h"
@@ -2215,4 +2215,4 @@ class funcall_operation
 
 } /* namespace expr */
 
-#endif /* EXPOP_H */
+#endif /* GDB_EXPOP_H */
diff --git a/gdb/expression.h b/gdb/expression.h
index 5bfc74c973f..7c79518da8b 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (EXPRESSION_H)
-#define EXPRESSION_H 1
+#ifndef GDB_EXPRESSION_H
+#define GDB_EXPRESSION_H
 
 #include "gdbtypes.h"
 #include "symtab.h"
@@ -387,4 +387,4 @@ enum range_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum range_flag, range_flags);
 
-#endif /* !defined (EXPRESSION_H) */
+#endif /* GDB_EXPRESSION_H */
diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index cb00cb6ff7b..f6c5f3fe75f 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXTENSION_PRIV_H
-#define EXTENSION_PRIV_H
+#ifndef GDB_EXTENSION_PRIV_H
+#define GDB_EXTENSION_PRIV_H
 
 #include "extension.h"
 #include <signal.h>
@@ -320,4 +320,4 @@ extern struct active_ext_lang_state *set_active_ext_lang
 
 extern void restore_active_ext_lang (struct active_ext_lang_state *previous);
 
-#endif /* EXTENSION_PRIV_H */
+#endif /* GDB_EXTENSION_PRIV_H */
diff --git a/gdb/extension.h b/gdb/extension.h
index 5260bcbde00..93c3cdfcc69 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXTENSION_H
-#define EXTENSION_H
+#ifndef GDB_EXTENSION_H
+#define GDB_EXTENSION_H
 
 #include "mi/mi-cmds.h"
 #include "gdbsupport/array-view.h"
@@ -428,4 +428,4 @@ class scoped_disable_cooperative_sigint_handling
   bool m_prev_cooperative_sigint_handling_disabled;
 };
 
-#endif /* EXTENSION_H */
+#endif /* GDB_EXTENSION_H */
diff --git a/gdb/f-array-walker.h b/gdb/f-array-walker.h
index bcbaa3da5b3..d1f2b06fa9b 100644
--- a/gdb/f-array-walker.h
+++ b/gdb/f-array-walker.h
@@ -18,8 +18,8 @@
 /* Support classes to wrap up the process of iterating over a
    multi-dimensional Fortran array.  */
 
-#ifndef F_ARRAY_WALKER_H
-#define F_ARRAY_WALKER_H
+#ifndef GDB_F_ARRAY_WALKER_H
+#define GDB_F_ARRAY_WALKER_H
 
 #include "gdbtypes.h"
 #include "f-lang.h"
@@ -298,4 +298,4 @@ class fortran_array_walker
   int m_nss;
 };
 
-#endif /* F_ARRAY_WALKER_H */
+#endif /* GDB_F_ARRAY_WALKER_H */
diff --git a/gdb/f-exp.h b/gdb/f-exp.h
index aa0094c8ff1..47d469abe7c 100644
--- a/gdb/f-exp.h
+++ b/gdb/f-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FORTRAN_EXP_H
-#define FORTRAN_EXP_H
+#ifndef GDB_F_EXP_H
+#define GDB_F_EXP_H
 
 #include "expop.h"
 
@@ -417,4 +417,4 @@ class fortran_structop_operation
 
 } /* namespace expr */
 
-#endif /* FORTRAN_EXP_H */
+#endif /* GDB_F_EXP_H */
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index c2034258513..59cdd5f2334 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef F_LANG_H
-#define F_LANG_H
+#ifndef GDB_F_LANG_H
+#define GDB_F_LANG_H
 
 #include "language.h"
 #include "valprint.h"
@@ -378,4 +378,4 @@ extern struct type *fortran_preserve_arg_pointer (struct value *arg,
 extern CORE_ADDR fortran_adjust_dynamic_array_base_address_hack
 	(struct type *type, CORE_ADDR address);
 
-#endif /* F_LANG_H */
+#endif /* GDB_F_LANG_H */
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index 35c06b2c985..2123175944e 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FBSD_NAT_H
-#define FBSD_NAT_H
+#ifndef GDB_FBSD_NAT_H
+#define GDB_FBSD_NAT_H
 
 #include <optional>
 #include "inf-ptrace.h"
@@ -285,4 +285,4 @@ class fbsd_nat_target : public inf_ptrace_target
    Return true if successful.  */
 bool fbsd_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
 
-#endif /* fbsd-nat.h */
+#endif /* GDB_FBSD_NAT_H */
diff --git a/gdb/fbsd-tdep.h b/gdb/fbsd-tdep.h
index 54ff45c8d93..79381b3fefd 100644
--- a/gdb/fbsd-tdep.h
+++ b/gdb/fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FBSD_TDEP_H
-#define FBSD_TDEP_H
+#ifndef GDB_FBSD_TDEP_H
+#define GDB_FBSD_TDEP_H
 
 extern void fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
 
@@ -76,4 +76,4 @@ extern CORE_ADDR fbsd_get_thread_local_address (struct gdbarch *gdbarch,
 extern CORE_ADDR fbsd_skip_solib_resolver (struct gdbarch *gdbarch,
 					   CORE_ADDR pc);
 
-#endif /* fbsd-tdep.h */
+#endif /* GDB_FBSD_TDEP_H */
diff --git a/gdb/filename-seen-cache.h b/gdb/filename-seen-cache.h
index 5dc800d2b16..9107f449183 100644
--- a/gdb/filename-seen-cache.h
+++ b/gdb/filename-seen-cache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FILENAME_SEEN_CACHE_H
-#define FILENAME_SEEN_CACHE_H
+#ifndef GDB_FILENAME_SEEN_CACHE_H
+#define GDB_FILENAME_SEEN_CACHE_H
 
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/gdb-hashtab.h"
@@ -62,4 +62,4 @@ class filename_seen_cache
   htab_up m_tab;
 };
 
-#endif /* FILENAME_SEEN_CACHE_H */
+#endif /* GDB_FILENAME_SEEN_CACHE_H */
diff --git a/gdb/filesystem.h b/gdb/filesystem.h
index 29c31803fc4..73b9a8bb84e 100644
--- a/gdb/filesystem.h
+++ b/gdb/filesystem.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FILESYSTEM_H
-#define FILESYSTEM_H
+#ifndef GDB_FILESYSTEM_H
+#define GDB_FILESYSTEM_H
 
 extern const char file_system_kind_auto[];
 extern const char file_system_kind_unix[];
@@ -55,4 +55,4 @@ extern const char *target_lbasename (const char *kind, const char *name);
    result from this function.  */
 extern const char *effective_target_file_system_kind (void);
 
-#endif
+#endif /* GDB_FILESYSTEM_H */
diff --git a/gdb/frame-base.h b/gdb/frame-base.h
index ae22431d5ef..8436929839e 100644
--- a/gdb/frame-base.h
+++ b/gdb/frame-base.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_BASE_H)
-#define FRAME_BASE_H 1
+#ifndef GDB_FRAME_BASE_H
+#define GDB_FRAME_BASE_H
 
 class frame_info_ptr;
 struct frame_id;
@@ -88,4 +88,4 @@ extern void frame_base_set_default (struct gdbarch *gdbarch,
 
 extern const struct frame_base *frame_base_find_by_frame (const frame_info_ptr &this_frame);
 
-#endif
+#endif /* GDB_FRAME_BASE_H */
diff --git a/gdb/frame-id.h b/gdb/frame-id.h
index 0d03b476aef..30850e24017 100644
--- a/gdb/frame-id.h
+++ b/gdb/frame-id.h
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef GDB_FRAME_ID_H
-#define GDB_FRAME_ID_H 1
+#define GDB_FRAME_ID_H
 
 /* Status of a given frame's stack.  */
 
@@ -140,4 +140,4 @@ is_sentinel_frame_id (frame_id id)
   return id.stack_status == FID_STACK_SENTINEL;
 }
 
-#endif /* ifdef GDB_FRAME_ID_H  */
+#endif /* GDB_FRAME_ID_H */
diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h
index 53fcd6869e9..1799d3625bd 100644
--- a/gdb/frame-unwind.h
+++ b/gdb/frame-unwind.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_UNWIND_H)
-#define FRAME_UNWIND_H 1
+#ifndef GDB_FRAME_UNWIND_H
+#define GDB_FRAME_UNWIND_H
 
 struct frame_data;
 class frame_info_ptr;
@@ -235,4 +235,4 @@ value *frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum,
 value *frame_unwind_got_address (const frame_info_ptr &frame, int regnum,
 				 CORE_ADDR addr);
 
-#endif
+#endif /* GDB_FRAME_UNWIND_H */
diff --git a/gdb/frame.h b/gdb/frame.h
index e784c17b480..9b41dd958fa 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_H)
-#define FRAME_H 1
+#ifndef GDB_FRAME_H
+#define GDB_FRAME_H
 
 /* The following is the intended naming schema for frame functions.
    It isn't 100% consistent, but it is approaching that.  Frame naming
@@ -1077,4 +1077,4 @@ extern void set_frame_previous_pc_masked (const frame_info_ptr &frame);
 extern bool get_frame_pc_masked (const frame_info_ptr &frame);
 
 
-#endif /* !defined (FRAME_H)  */
+#endif /* GDB_FRAME_H */
diff --git a/gdb/frv-tdep.h b/gdb/frv-tdep.h
index 95347ed224e..0d78ec4ac6a 100644
--- a/gdb/frv-tdep.h
+++ b/gdb/frv-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FRV_TDEP_H
-#define FRV_TDEP_H
+#ifndef GDB_FRV_TDEP_H
+#define GDB_FRV_TDEP_H
 
 /* Enumerate the possible ABIs for FR-V.  */
 enum frv_abi
@@ -121,4 +121,4 @@ CORE_ADDR frv_fetch_objfile_link_map (struct objfile *objfile);
 struct solib_ops;
 extern const solib_ops frv_so_ops;
 
-#endif /* FRV_TDEP_H */
+#endif /* GDB_FRV_TDEP_H */
diff --git a/gdb/ft32-tdep.h b/gdb/ft32-tdep.h
index 308d2333bc2..ee4a2473f8d 100644
--- a/gdb/ft32-tdep.h
+++ b/gdb/ft32-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FT32_TDEP_H
-#define FT32_TDEP_H
+#ifndef GDB_FT32_TDEP_H
+#define GDB_FT32_TDEP_H
 
 #include "gdbarch.h"
 
@@ -28,4 +28,4 @@ struct ft32_gdbarch_tdep : gdbarch_tdep_base
   struct type *pc_type = nullptr;
 };
 
-#endif /* FT32_TDEP_H */
+#endif /* GDB_FT32_TDEP_H */
diff --git a/gdb/gcore-elf.h b/gdb/gcore-elf.h
index e7239b88b09..8217f0b1c85 100644
--- a/gdb/gcore-elf.h
+++ b/gdb/gcore-elf.h
@@ -17,8 +17,8 @@
 
 /* This file contains generic functions for writing ELF based core files.  */
 
-#if !defined (GCORE_ELF_H)
-#define GCORE_ELF_H 1
+#ifndef GDB_GCORE_ELF_H
+#define GDB_GCORE_ELF_H
 
 #include "gdb_bfd.h"
 #include "gdbsupport/gdb_signals.h"
@@ -45,4 +45,4 @@ extern void gcore_elf_make_tdesc_note
   (struct gdbarch *gdbarch, bfd *obfd,
    gdb::unique_xmalloc_ptr<char> *note_data, int *note_size);
 
-#endif /* GCORE_ELF_H */
+#endif /* GDB_GCORE_ELF_H */
diff --git a/gdb/gcore.h b/gdb/gcore.h
index 0bedc0a7ba9..21e7a8d29ee 100644
--- a/gdb/gcore.h
+++ b/gdb/gcore.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GCORE_H)
-#define GCORE_H 1
+#ifndef GDB_GCORE_H
+#define GDB_GCORE_H
 
 #include "gdb_bfd.h"
 
@@ -37,4 +37,4 @@ extern int objfile_find_memory_regions (struct target_ops *self,
 
 extern thread_info *gcore_find_signalled_thread ();
 
-#endif /* GCORE_H */
+#endif /* GDB_GCORE_H */
diff --git a/gdb/gdb-demangle.h b/gdb/gdb-demangle.h
index e434f890969..86a8bd618eb 100644
--- a/gdb/gdb-demangle.h
+++ b/gdb/gdb-demangle.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DEMANGLE_H
-#define GDB_DEMANGLE_H
+#ifndef GDB_GDB_DEMANGLE_H
+#define GDB_GDB_DEMANGLE_H
 
 /* True means that encoded C++/ObjC names should be printed out in their
    C++/ObjC form rather than raw.  */
@@ -31,4 +31,4 @@ extern bool asm_demangle;
 /* Check if a character is one of the commonly used C++ marker characters.  */
 extern bool is_cplus_marker (int);
 
-#endif /* GDB_DEMANGLE_H */
+#endif /* GDB_GDB_DEMANGLE_H */
diff --git a/gdb/gdb-stabs.h b/gdb/gdb-stabs.h
index 3786ad6881d..373a7269470 100644
--- a/gdb/gdb-stabs.h
+++ b/gdb/gdb-stabs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_STABS_H
-#define GDB_STABS_H
+#ifndef GDB_GDB_STABS_H
+#define GDB_GDB_STABS_H
 
 /* This file exists to hold the common definitions required of most of
    the symbol-readers that end up using stabs.  The common use of
@@ -75,4 +75,4 @@ extern const registry<objfile>::key<dbx_symfile_info> dbx_objfile_data_key;
 #define DBX_BSS_SECTION(o)	(DBX_SYMFILE_INFO(o)->bss_section)
 #define DBX_STAB_SECTION(o)	(DBX_SYMFILE_INFO(o)->stab_section)
 
-#endif /* GDB_STABS_H */
+#endif /* GDB_GDB_STABS_H */
diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h
index 331570d769c..c09e4e7f811 100644
--- a/gdb/gdb_bfd.h
+++ b/gdb/gdb_bfd.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_BFD_H
-#define GDB_BFD_H
+#ifndef GDB_GDB_BFD_H
+#define GDB_GDB_BFD_H
 
 #include "registry.h"
 #include "gdbsupport/byte-vector.h"
@@ -263,4 +263,4 @@ extern std::string gdb_bfd_errmsg (bfd_error_type error_tag, char **matching);
 
 extern void gdb_bfd_init ();
 
-#endif /* GDB_BFD_H */
+#endif /* GDB_GDB_BFD_H */
diff --git a/gdb/gdb_curses.h b/gdb/gdb_curses.h
index c7ee862cd67..c0ab883f17b 100644
--- a/gdb/gdb_curses.h
+++ b/gdb/gdb_curses.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_CURSES_H
-#define GDB_CURSES_H 1
+#ifndef GDB_GDB_CURSES_H
+#define GDB_GDB_CURSES_H
 
 #ifdef __MINGW32__
 /* Windows API headers, included e.g. by serial.h, define MOUSE_MOVED,
@@ -71,4 +71,4 @@ extern "C" int tgetnum (const char *);
 #undef reg
 #endif
 
-#endif /* gdb_curses.h */
+#endif /* GDB_GDB_CURSES_H */
diff --git a/gdb/gdb_expat.h b/gdb/gdb_expat.h
index 566f065fd13..36cee8031eb 100644
--- a/gdb/gdb_expat.h
+++ b/gdb/gdb_expat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(GDB_EXPAT_H)
-#define GDB_EXPAT_H
+#ifndef GDB_GDB_EXPAT_H
+#define GDB_GDB_EXPAT_H
 
 #include <expat.h>
 
@@ -35,4 +35,4 @@
 #define XMLCALL
 #endif
 
-#endif /* !defined(GDB_EXPAT_H) */
+#endif /* GDB_GDB_EXPAT_H */
diff --git a/gdb/gdb_proc_service.h b/gdb/gdb_proc_service.h
index 1088e19a4c5..c5e060b4eee 100644
--- a/gdb/gdb_proc_service.h
+++ b/gdb/gdb_proc_service.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_PROC_SERVICE_H
-#define GDB_PROC_SERVICE_H
+#ifndef GDB_GDB_PROC_SERVICE_H
+#define GDB_GDB_PROC_SERVICE_H
 
 #include "gdbsupport/gdb_proc_service.h"
 
@@ -30,4 +30,4 @@ struct ps_prochandle
   thread_info *thread;
 };
 
-#endif /* gdb_proc_service.h */
+#endif /* GDB_GDB_PROC_SERVICE_H */
diff --git a/gdb/gdb_vfork.h b/gdb/gdb_vfork.h
index 521fed9b007..69f4955ee97 100644
--- a/gdb/gdb_vfork.h
+++ b/gdb/gdb_vfork.h
@@ -16,11 +16,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_VFORK_H
-#define GDB_VFORK_H
+#ifndef GDB_GDB_VFORK_H
+#define GDB_GDB_VFORK_H
 
 #if HAVE_VFORK_H
 #include <vfork.h>
 #endif
 
-#endif /* GDB_VFORK_H */
+#endif /* GDB_GDB_VFORK_H */
diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h
index 8df00e4679f..937b409d039 100644
--- a/gdb/gdb_wchar.h
+++ b/gdb/gdb_wchar.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_WCHAR_H
-#define GDB_WCHAR_H
+#ifndef GDB_GDB_WCHAR_H
+#define GDB_GDB_WCHAR_H
 
 /* We handle three different modes here.
    
@@ -121,4 +121,4 @@ typedef int gdb_wint_t;
 
 #endif
 
-#endif /* GDB_WCHAR_H */
+#endif /* GDB_GDB_WCHAR_H */
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 77d3406779f..bfe08fe65a8 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef GDBARCH_H
-#define GDBARCH_H
+#ifndef GDB_GDBARCH_H
+#define GDB_GDBARCH_H
 
 #include <vector>
 #include "frame.h"
@@ -370,4 +370,4 @@ gdbarch_num_cooked_regs (gdbarch *arch)
   return gdbarch_num_regs (arch) + gdbarch_num_pseudo_regs (arch);
 }
 
-#endif
+#endif /* GDB_GDBARCH_H */
diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h
index 8a1f6f20052..cba32528dfa 100644
--- a/gdb/gdbcmd.h
+++ b/gdb/gdbcmd.h
@@ -21,8 +21,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDBCMD_H)
-#define GDBCMD_H 1
+#ifndef GDB_GDBCMD_H
+#define GDB_GDBCMD_H
 
 #include "command.h"
 #include "ui-out.h"
@@ -69,4 +69,4 @@ extern void print_command_lines (struct ui_out *,
 extern struct cmd_list_element *style_set_list;
 extern struct cmd_list_element *style_show_list;
 
-#endif /* !defined (GDBCMD_H) */
+#endif /* GDB_GDBCMD_H */
diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h
index d6aeb356e37..4eab2cd70a5 100644
--- a/gdb/gdbcore.h
+++ b/gdb/gdbcore.h
@@ -19,8 +19,8 @@
 
 /* Interface routines for core, executable, etc.  */
 
-#if !defined (GDBCORE_H)
-#define GDBCORE_H 1
+#ifndef GDB_GDBCORE_H
+#define GDB_GDBCORE_H
 
 struct type;
 struct regcache;
@@ -196,4 +196,4 @@ class thread_section_name
   std::string m_storage;
 };
 
-#endif /* !defined (GDBCORE_H) */
+#endif /* GDB_GDBCORE_H */
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 73f6895fe46..490d05db340 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDBTHREAD_H
-#define GDBTHREAD_H
+#ifndef GDB_GDBTHREAD_H
+#define GDB_GDBTHREAD_H
 
 struct symtab;
 
@@ -1071,4 +1071,4 @@ extern void thread_try_catch_cmd (thread_info *thr,
 
 extern const char *thread_state_string (enum thread_state state);
 
-#endif /* GDBTHREAD_H */
+#endif /* GDB_GDBTHREAD_H */
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 55018f2c344..5182b54cc96 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDBTYPES_H)
-#define GDBTYPES_H 1
+#ifndef GDB_GDBTYPES_H
+#define GDB_GDBTYPES_H
 
 /* * \page gdbtypes GDB Types
 
@@ -2830,4 +2830,4 @@ extern unsigned int overload_debug;
 
 extern bool is_nocall_function (const struct type *type);
 
-#endif /* GDBTYPES_H */
+#endif /* GDB_GDBTYPES_H */
diff --git a/gdb/glibc-tdep.h b/gdb/glibc-tdep.h
index 264e1e707f2..17006d0fafc 100644
--- a/gdb/glibc-tdep.h
+++ b/gdb/glibc-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GLIBC_TDEP_H
-#define GLIBC_TDEP_H
+#ifndef GDB_GLIBC_TDEP_H
+#define GDB_GLIBC_TDEP_H
 
 struct gdbarch;
 
 extern CORE_ADDR glibc_skip_solib_resolver (struct gdbarch *gdbarch,
 					    CORE_ADDR);
 
-#endif /* glibc-tdep.h */
+#endif /* GDB_GLIBC_TDEP_H */
diff --git a/gdb/gmp-utils.h b/gdb/gmp-utils.h
index 51e06abc050..84ac0e7333b 100644
--- a/gdb/gmp-utils.h
+++ b/gdb/gmp-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GMP_UTILS_H
-#define GMP_UTILS_H
+#ifndef GDB_GMP_UTILS_H
+#define GDB_GMP_UTILS_H
 
 /* Include <stdio.h> and <stdarg.h> ahead of <gmp.h>, so as to get
    access to GMP's various formatting functions.  */
@@ -663,4 +663,4 @@ gdb_mpz::as_integer_truncate () const
   return result;
 }
 
-#endif
+#endif /* GDB_GMP_UTILS_H */
diff --git a/gdb/gnu-nat-mig.h b/gdb/gnu-nat-mig.h
index 4b9e78c99e2..01c1ed46f20 100644
--- a/gdb/gnu-nat-mig.h
+++ b/gdb/gnu-nat-mig.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GNU_NAT_MIG_H
-#define GNU_NAT_MIG_H
+#ifndef GDB_GNU_NAT_MIG_H
+#define GDB_GNU_NAT_MIG_H
 
 #include <mach/boolean.h>
 #include <mach/message.h>
@@ -28,4 +28,4 @@ boolean_t notify_server (mach_msg_header_t *InHeadP,
 boolean_t process_reply_server (mach_msg_header_t *InHeadP,
 				mach_msg_header_t *OutHeadP);
 
-#endif /* GNU_NAT_MIG_H */
+#endif /* GDB_GNU_NAT_MIG_H */
diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index f1694b8a3a7..700a01a7d17 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GNU_NAT_H
-#define GNU_NAT_H
+#ifndef GDB_GNU_NAT_H
+#define GDB_GNU_NAT_H
 
 /* Work around conflict between Mach's 'thread_info' function, and GDB's
    'thread_info' class.  Make the former available as 'mach_thread_info'.  */
@@ -188,4 +188,4 @@ struct gnu_nat_target : public inf_child_target
 /* The final/concrete instance.  */
 extern gnu_nat_target *gnu_target;
 
-#endif /* GNU_NAT_H */
+#endif /* GDB_GNU_NAT_H */
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
index 1aca9ddd118..030febc4215 100644
--- a/gdb/go-lang.h
+++ b/gdb/go-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GO_LANG_H)
-#define GO_LANG_H 1
+#ifndef GDB_GO_LANG_H
+#define GDB_GO_LANG_H
 
 struct type_print_options;
 
@@ -144,4 +144,4 @@ class go_language : public language_defn
   { return true; }
 };
 
-#endif /* !defined (GO_LANG_H) */
+#endif /* GDB_GO_LANG_H */
diff --git a/gdb/gregset.h b/gdb/gregset.h
index 8c14809a47d..9345625d98a 100644
--- a/gdb/gregset.h
+++ b/gdb/gregset.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GREGSET_H
-#define GREGSET_H
+#ifndef GDB_GREGSET_H
+#define GDB_GREGSET_H
 
 #ifdef HAVE_SYS_PROCFS_H
 #include <sys/procfs.h>
@@ -60,4 +60,4 @@ extern void fill_gregset (const struct regcache *regcache,
 extern void fill_fpregset (const struct regcache *regcache,
 			   gdb_fpregset_t *fpregs, int regno);
 
-#endif
+#endif /* GDB_GREGSET_H */
diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h
index be16fee0dd2..c2856478eed 100644
--- a/gdb/guile/guile-internal.h
+++ b/gdb/guile/guile-internal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GUILE_GUILE_INTERNAL_H
-#define GUILE_GUILE_INTERNAL_H
+#ifndef GDB_GUILE_GUILE_INTERNAL_H
+#define GDB_GUILE_GUILE_INTERNAL_H
 
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
@@ -722,4 +722,4 @@ gdbscm_wrap (Function &&func, Args &&... args)
   return result;
 }
 
-#endif /* GUILE_GUILE_INTERNAL_H */
+#endif /* GDB_GUILE_GUILE_INTERNAL_H */
diff --git a/gdb/guile/guile.h b/gdb/guile/guile.h
index 2ab1f7552c7..6ce4864aabd 100644
--- a/gdb/guile/guile.h
+++ b/gdb/guile/guile.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GUILE_GUILE_H
-#define GUILE_GUILE_H
+#ifndef GDB_GUILE_GUILE_H
+#define GDB_GUILE_GUILE_H
 
 #include "extension.h"
 
@@ -28,4 +28,4 @@ extern const struct extension_language_defn extension_language_guile;
 /* Command element for the 'guile' command.  */
 extern cmd_list_element *guile_cmd_element;
 
-#endif /* GUILE_GUILE_H */
+#endif /* GDB_GUILE_GUILE_H */
diff --git a/gdb/hppa-bsd-tdep.h b/gdb/hppa-bsd-tdep.h
index 42aefe6e142..54599ab9ab4 100644
--- a/gdb/hppa-bsd-tdep.h
+++ b/gdb/hppa-bsd-tdep.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_BSD_TDEP_H
-#define HPPA_BSD_TDEP_H
+#ifndef GDB_HPPA_BSD_TDEP_H
+#define GDB_HPPA_BSD_TDEP_H
 
 extern void hppabsd_init_abi (struct gdbarch_info, struct gdbarch *);
 
-#endif /* hppa-bsd-tdep.h */
+#endif /* GDB_HPPA_BSD_TDEP_H */
diff --git a/gdb/hppa-linux-offsets.h b/gdb/hppa-linux-offsets.h
index b1543b05705..958afd115a8 100644
--- a/gdb/hppa-linux-offsets.h
+++ b/gdb/hppa-linux-offsets.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_LINUX_OFFSETS_H
-#define HPPA_LINUX_OFFSETS_H
+#ifndef GDB_HPPA_LINUX_OFFSETS_H
+#define GDB_HPPA_LINUX_OFFSETS_H
 
 #define PT_PSW offsetof(struct pt_regs, gr[ 0])
 #define PT_GR1 offsetof(struct pt_regs, gr[ 1])
@@ -105,4 +105,4 @@
 #define PT_ISR offsetof(struct pt_regs, isr)
 #define PT_IOR offsetof(struct pt_regs, ior)
 
-#endif /* HPPA_LINUX_OFFSETS_H */
+#endif /* GDB_HPPA_LINUX_OFFSETS_H */
diff --git a/gdb/hppa-tdep.h b/gdb/hppa-tdep.h
index 0f706536cc9..e1143a56bcd 100644
--- a/gdb/hppa-tdep.h
+++ b/gdb/hppa-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_TDEP_H
-#define HPPA_TDEP_H
+#ifndef GDB_HPPA_TDEP_H
+#define GDB_HPPA_TDEP_H
 
 #include "gdbarch.h"
 
@@ -214,4 +214,4 @@ extern int hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
 					  CORE_ADDR pc);
 extern CORE_ADDR hppa_skip_trampoline_code (const frame_info_ptr &, CORE_ADDR pc);
 
-#endif  /* hppa-tdep.h */
+#endif /* GDB_HPPA_TDEP_H */
diff --git a/gdb/i386-bsd-nat.h b/gdb/i386-bsd-nat.h
index a05eb90d4f8..54061ab46d1 100644
--- a/gdb/i386-bsd-nat.h
+++ b/gdb/i386-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_BSD_NAT_H
-#define I386_BSD_NAT_H
+#ifndef GDB_I386_BSD_NAT_H
+#define GDB_I386_BSD_NAT_H
 
 #include "x86-bsd-nat.h"
 
@@ -41,4 +41,4 @@ class i386_bsd_nat_target : public x86bsd_nat_target<BaseTarget>
   { i386bsd_store_inferior_registers (regcache, regnum); }
 };
 
-#endif /* i386-bsd-nat.h */
+#endif /* GDB_I386_BSD_NAT_H */
diff --git a/gdb/i386-darwin-tdep.h b/gdb/i386-darwin-tdep.h
index 0b867fab94c..7ccdeeced13 100644
--- a/gdb/i386-darwin-tdep.h
+++ b/gdb/i386-darwin-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_DARWIN_TDEP_H
-#define I386_DARWIN_TDEP_H
+#ifndef GDB_I386_DARWIN_TDEP_H
+#define GDB_I386_DARWIN_TDEP_H
 
 #include "frame.h"
 
@@ -29,4 +29,4 @@ extern const int i386_darwin_thread_state_num_regs;
 
 int darwin_dwarf_signal_frame_p (struct gdbarch *, const frame_info_ptr &);
 
-#endif /* I386_DARWIN_TDEP_H */
+#endif /* GDB_I386_DARWIN_TDEP_H */
diff --git a/gdb/i386-fbsd-tdep.h b/gdb/i386-fbsd-tdep.h
index 0a008421915..3b953e58435 100644
--- a/gdb/i386-fbsd-tdep.h
+++ b/gdb/i386-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_FBSD_TDEP_H
-#define I386_FBSD_TDEP_H
+#ifndef GDB_I386_FBSD_TDEP_H
+#define GDB_I386_FBSD_TDEP_H
 
 #include "gdbsupport/x86-xstate.h"
 #include "regset.h"
@@ -42,4 +42,4 @@ bool i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
 
 extern const struct regset i386_fbsd_gregset;
 
-#endif /* i386-fbsd-tdep.h */
+#endif /* GDB_I386_FBSD_TDEP_H */
diff --git a/gdb/i386-linux-nat.h b/gdb/i386-linux-nat.h
index c3d32aff1be..e4a86c70382 100644
--- a/gdb/i386-linux-nat.h
+++ b/gdb/i386-linux-nat.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_LINUX_NAT_H
-#define I386_LINUX_NAT_H 1
+#ifndef GDB_I386_LINUX_NAT_H
+#define GDB_I386_LINUX_NAT_H
 
 /* Does the current host support the GETFPXREGS request? */
 extern int have_ptrace_getfpxregs;
 
-#endif
+#endif /* GDB_I386_LINUX_NAT_H */
diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h
index 5891747572b..025b0f5fc51 100644
--- a/gdb/i386-linux-tdep.h
+++ b/gdb/i386-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_LINUX_TDEP_H
-#define I386_LINUX_TDEP_H
+#ifndef GDB_I386_LINUX_TDEP_H
+#define GDB_I386_LINUX_TDEP_H
 
 #include "gdbsupport/x86-xstate.h"
 
@@ -83,4 +83,4 @@ extern int i386_linux_gregset_reg_offset[];
 /* Return x86 siginfo type.  */
 extern struct type *x86_linux_get_siginfo_type (struct gdbarch *gdbarch);
 
-#endif /* i386-linux-tdep.h */
+#endif /* GDB_I386_LINUX_TDEP_H */
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index a85e0a984a0..e394e159c04 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_TDEP_H
-#define I386_TDEP_H
+#ifndef GDB_I386_TDEP_H
+#define GDB_I386_TDEP_H
 
 #include "gdbarch.h"
 #include "infrun.h"
@@ -488,4 +488,4 @@ extern int i386_stap_is_single_operand (struct gdbarch *gdbarch,
 extern expr::operation_up i386_stap_parse_special_token
      (struct gdbarch *gdbarch, struct stap_parse_info *p);
 
-#endif /* i386-tdep.h */
+#endif /* GDB_I386_TDEP_H */
diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h
index 30d769478a6..77e089ab723 100644
--- a/gdb/i387-tdep.h
+++ b/gdb/i387-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I387_TDEP_H
-#define I387_TDEP_H
+#ifndef GDB_I387_TDEP_H
+#define GDB_I387_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -185,4 +185,4 @@ extern void i387_return_value (struct gdbarch *gdbarch,
    all memory range can be accessed.  */
 extern void i387_reset_bnd_regs (struct gdbarch *gdbarch,
 				 struct regcache *regcache);
-#endif /* i387-tdep.h */
+#endif /* GDB_I387_TDEP_H */
diff --git a/gdb/ia64-libunwind-tdep.h b/gdb/ia64-libunwind-tdep.h
index 4f064bfc333..9d358642d9f 100644
--- a/gdb/ia64-libunwind-tdep.h
+++ b/gdb/ia64-libunwind-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef IA64_LIBUNWIND_TDEP_H
-#define IA64_LIBUNWIND_TDEP_H 1
+#ifndef GDB_IA64_LIBUNWIND_TDEP_H
+#define GDB_IA64_LIBUNWIND_TDEP_H
 
 class frame_info_ptr;
 struct frame_id;
@@ -76,4 +76,4 @@ int libunwind_get_reg_special (struct gdbarch *gdbarch,
 			       readable_regcache *regcache,
 			       int regnum, void *buf);
 
-#endif /* IA64_LIBUNWIND_TDEP_H */
+#endif /* GDB_IA64_LIBUNWIND_TDEP_H */
diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h
index 64be38b4d76..e5eb7eac071 100644
--- a/gdb/ia64-tdep.h
+++ b/gdb/ia64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef IA64_TDEP_H
-#define IA64_TDEP_H
+#ifndef GDB_IA64_TDEP_H
+#define GDB_IA64_TDEP_H
 
 #include "gdbarch.h"
 
@@ -265,4 +265,4 @@ extern unw_accessors_t ia64_unw_rse_accessors;
 extern struct libunwind_descr ia64_libunwind_descr;
 #endif
 
-#endif /* ia64-tdep.h */
+#endif /* GDB_IA64_TDEP_H */
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index 91955a64f4c..2a251b365f2 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_CHILD_H
-#define INF_CHILD_H
+#ifndef GDB_INF_CHILD_H
+#define GDB_INF_CHILD_H
 
 #include "target.h"
 #include "process-stratum-target.h"
@@ -115,4 +115,4 @@ extern void add_inf_child_target (inf_child_target *target);
    targets use add_inf_child_target instead.  */
 extern void inf_child_open_target (const char *arg, int from_tty);
 
-#endif
+#endif /* GDB_INF_CHILD_H */
diff --git a/gdb/inf-loop.h b/gdb/inf-loop.h
index ceabd14bd9e..2bf29fa7498 100644
--- a/gdb/inf-loop.h
+++ b/gdb/inf-loop.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_LOOP_H
-#define INF_LOOP_H
+#ifndef GDB_INF_LOOP_H
+#define GDB_INF_LOOP_H
 
 #include "target.h"
 
 extern void inferior_event_handler (enum inferior_event_type event_type);
 
-#endif /* #ifndef INF_LOOP_H */
+#endif /* GDB_INF_LOOP_H */
diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h
index 868bee92da8..901f7e9162d 100644
--- a/gdb/inf-ptrace.h
+++ b/gdb/inf-ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_PTRACE_H
-#define INF_PTRACE_H
+#ifndef GDB_INF_PTRACE_H
+#define GDB_INF_PTRACE_H
 
 #include "gdbsupport/event-pipe.h"
 #include "inf-child.h"
@@ -113,4 +113,4 @@ struct inf_ptrace_target : public inf_child_target
 extern pid_t get_ptrace_pid (ptid_t);
 #endif
 
-#endif
+#endif /* GDB_INF_PTRACE_H */
diff --git a/gdb/infcall.h b/gdb/infcall.h
index dcc701b5f31..eccf13307c7 100644
--- a/gdb/infcall.h
+++ b/gdb/infcall.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFCALL_H
-#define INFCALL_H
+#ifndef GDB_INFCALL_H
+#define GDB_INFCALL_H
 
 #include "dummy-frame.h"
 #include "gdbsupport/array-view.h"
@@ -71,4 +71,4 @@ extern struct value *
 
 extern void error_call_unknown_return_type (const char *func_name);
 
-#endif
+#endif /* GDB_INFCALL_H */
diff --git a/gdb/inferior-iter.h b/gdb/inferior-iter.h
index 821c7bec94e..05ddfca54c9 100644
--- a/gdb/inferior-iter.h
+++ b/gdb/inferior-iter.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFERIOR_ITER_H
-#define INFERIOR_ITER_H
+#ifndef GDB_INFERIOR_ITER_H
+#define GDB_INFERIOR_ITER_H
 
 #include "gdbsupport/filtered-iterator.h"
 #include "gdbsupport/safe-iterator.h"
@@ -132,4 +132,4 @@ using all_inferiors_safe_iterator
 
 using all_inferiors_safe_range = iterator_range<all_inferiors_safe_iterator>;
 
-#endif /* !defined (INFERIOR_ITER_H) */
+#endif /* GDB_INFERIOR_ITER_H */
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 7be28423aeb..4163396b775 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (INFERIOR_H)
-#define INFERIOR_H 1
+#ifndef GDB_INFERIOR_H
+#define GDB_INFERIOR_H
 
 #include <exception>
 #include <list>
@@ -869,4 +869,4 @@ valid_global_inferior_id (int id)
   return false;
 }
 
-#endif /* !defined (INFERIOR_H) */
+#endif /* GDB_INFERIOR_H */
diff --git a/gdb/infrun.h b/gdb/infrun.h
index 5f83ca2b4c3..4574874706e 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFRUN_H
-#define INFRUN_H 1
+#ifndef GDB_INFRUN_H
+#define GDB_INFRUN_H
 
 #include "gdbthread.h"
 #include "symtab.h"
@@ -418,4 +418,4 @@ struct scoped_enable_commit_resumed
 };
 
 
-#endif /* INFRUN_H */
+#endif /* GDB_INFRUN_H */
diff --git a/gdb/inline-frame.h b/gdb/inline-frame.h
index bbe617c7c5b..a11376f1d43 100644
--- a/gdb/inline-frame.h
+++ b/gdb/inline-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (INLINE_FRAME_H)
-#define INLINE_FRAME_H 1
+#ifndef GDB_INLINE_FRAME_H
+#define GDB_INLINE_FRAME_H
 
 class frame_info_ptr;
 struct frame_unwind;
@@ -70,4 +70,4 @@ struct symbol *inline_skipped_symbol (thread_info *thread);
 
 int frame_inlined_callees (const frame_info_ptr &this_frame);
 
-#endif /* !defined (INLINE_FRAME_H) */
+#endif /* GDB_INLINE_FRAME_H */
diff --git a/gdb/interps.h b/gdb/interps.h
index bd435d734af..726b660684e 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INTERPS_H
-#define INTERPS_H
+#ifndef GDB_INTERPS_H
+#define GDB_INTERPS_H
 
 #include "gdbsupport/intrusive_list.h"
 
@@ -372,4 +372,4 @@ extern void interps_notify_memory_changed (inferior *inf, CORE_ADDR addr,
 #define INTERP_TUI		"tui"
 #define INTERP_INSIGHT		"insight"
 
-#endif
+#endif /* GDB_INTERPS_H */
diff --git a/gdb/jit.h b/gdb/jit.h
index ade0fb28ce2..59ad900c4e0 100644
--- a/gdb/jit.h
+++ b/gdb/jit.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef JIT_H
-#define JIT_H
+#ifndef GDB_JIT_H
+#define GDB_JIT_H
 
 struct inferior;
 struct objfile;
@@ -122,4 +122,4 @@ extern void jit_breakpoint_re_set (void);
 
 extern void jit_event_handler (gdbarch *gdbarch, objfile *jiter);
 
-#endif /* JIT_H */
+#endif /* GDB_JIT_H */
diff --git a/gdb/language.h b/gdb/language.h
index e67150d7596..157c46877d2 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (LANGUAGE_H)
-#define LANGUAGE_H 1
+#ifndef GDB_LANGUAGE_H
+#define GDB_LANGUAGE_H
 
 #include "symtab.h"
 #include "gdbsupport/function-view.h"
@@ -911,4 +911,4 @@ class scoped_switch_to_sym_language_if_auto
   enum language m_lang;
 };
 
-#endif /* defined (LANGUAGE_H) */
+#endif /* GDB_LANGUAGE_H */
diff --git a/gdb/linespec.h b/gdb/linespec.h
index 18f491d74d0..86eb36bbae9 100644
--- a/gdb/linespec.h
+++ b/gdb/linespec.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (LINESPEC_H)
-#define LINESPEC_H 1
+#ifndef GDB_LINESPEC_H
+#define GDB_LINESPEC_H
 
 struct symtab;
 
@@ -201,4 +201,4 @@ extern void linespec_complete_label (completion_tracker &tracker,
    advancing EXP_PTR past any parsed text.  */
 
 extern CORE_ADDR linespec_expression_to_pc (const char **exp_ptr);
-#endif /* defined (LINESPEC_H) */
+#endif /* GDB_LINESPEC_H */
diff --git a/gdb/linux-fork.h b/gdb/linux-fork.h
index c553aaf0740..2a306881695 100644
--- a/gdb/linux-fork.h
+++ b/gdb/linux-fork.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_FORK_H
-#define LINUX_FORK_H
+#ifndef GDB_LINUX_FORK_H
+#define GDB_LINUX_FORK_H
 
 struct fork_info;
 struct lwp_info;
@@ -30,4 +30,4 @@ extern void linux_fork_detach (int, lwp_info *);
 extern int forks_exist_p (void);
 extern int linux_fork_checkpointing_p (int);
 
-#endif /* LINUX_FORK_H */
+#endif /* GDB_LINUX_FORK_H */
diff --git a/gdb/linux-nat-trad.h b/gdb/linux-nat-trad.h
index ae40ce773b4..c1c031ea27d 100644
--- a/gdb/linux-nat-trad.h
+++ b/gdb/linux-nat-trad.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_NAT_TRAD_H
-#define LINUX_NAT_TRAD_H
+#ifndef GDB_LINUX_NAT_TRAD_H
+#define GDB_LINUX_NAT_TRAD_H
 
 #include "linux-nat.h"
 
@@ -43,4 +43,4 @@ class linux_nat_trad_target : public linux_nat_target
   void store_register (const struct regcache *regcache, int regnum);
 };
 
-#endif /* LINUX_NAT_TRAD_H */
+#endif /* GDB_LINUX_NAT_TRAD_H */
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 4dcbe9e170a..01e071e0f89 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_NAT_H
-#define LINUX_NAT_H
+#ifndef GDB_LINUX_NAT_H
+#define GDB_LINUX_NAT_H
 
 #include "nat/linux-nat.h"
 #include "inf-ptrace.h"
@@ -339,4 +339,4 @@ void linux_nat_switch_fork (ptid_t new_ptid);
    uninitialized in such case).  */
 bool linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
 
-#endif /* LINUX_NAT_H */
+#endif /* GDB_LINUX_NAT_H */
diff --git a/gdb/linux-record.h b/gdb/linux-record.h
index 962cedc3d34..26d113b6a65 100644
--- a/gdb/linux-record.h
+++ b/gdb/linux-record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_RECORD_H
-#define LINUX_RECORD_H
+#ifndef GDB_LINUX_RECORD_H
+#define GDB_LINUX_RECORD_H
 
 struct linux_record_tdep
 {
@@ -549,4 +549,4 @@ extern int record_linux_system_call (enum gdb_syscall num,
 				     struct regcache *regcache,
 				     struct linux_record_tdep *tdep);
 
-#endif /* LINUX_RECORD_H */
+#endif /* GDB_LINUX_RECORD_H */
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index 66b03cabaa6..bf4220bf75b 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_TDEP_H
-#define LINUX_TDEP_H
+#ifndef GDB_LINUX_TDEP_H
+#define GDB_LINUX_TDEP_H
 
 #include "bfd.h"
 #include "displaced-stepping.h"
@@ -117,4 +117,4 @@ extern CORE_ADDR linux_get_hwcap2 ();
 extern struct link_map_offsets *linux_ilp32_fetch_link_map_offsets ();
 extern struct link_map_offsets *linux_lp64_fetch_link_map_offsets ();
 
-#endif /* linux-tdep.h */
+#endif /* GDB_LINUX_TDEP_H */
diff --git a/gdb/location.h b/gdb/location.h
index e8cdd0d4ec6..7772d10426f 100644
--- a/gdb/location.h
+++ b/gdb/location.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LOCATION_H
-#define LOCATION_H
+#ifndef GDB_LOCATION_H
+#define GDB_LOCATION_H
 
 #include "symtab.h"
 
@@ -365,4 +365,4 @@ extern location_spec_up
 				    const struct language_defn *language,
 				    explicit_completion_info *completion_info);
 
-#endif /* LOCATION_H */
+#endif /* GDB_LOCATION_H */
diff --git a/gdb/loongarch-tdep.h b/gdb/loongarch-tdep.h
index 5c8108182ad..4908923db20 100644
--- a/gdb/loongarch-tdep.h
+++ b/gdb/loongarch-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LOONGARCH_TDEP_H
-#define LOONGARCH_TDEP_H
+#ifndef GDB_LOONGARCH_TDEP_H
+#define GDB_LOONGARCH_TDEP_H
 
 #include "gdbarch.h"
 #include "arch/loongarch.h"
@@ -44,4 +44,4 @@ struct loongarch_gdbarch_tdep : gdbarch_tdep_base
   CORE_ADDR (*syscall_next_pc) (const frame_info_ptr &frame) = nullptr;
 };
 
-#endif /* LOONGARCH_TDEP_H  */
+#endif /* GDB_LOONGARCH_TDEP_H */
diff --git a/gdb/m2-exp.h b/gdb/m2-exp.h
index 9d2634f813b..ce773cbf864 100644
--- a/gdb/m2-exp.h
+++ b/gdb/m2-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M2_EXP_H
-#define M2_EXP_H
+#ifndef GDB_M2_EXP_H
+#define GDB_M2_EXP_H
 
 #include "expop.h"
 
@@ -81,4 +81,4 @@ class m2_binop_subscript_operation
 
 } /* namespace expr */
 
-#endif /* M2_EXP_H */
+#endif /* GDB_M2_EXP_H */
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index 3d3c6980bb2..1551d7e00d6 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M2_LANG_H
-#define M2_LANG_H
+#ifndef GDB_M2_LANG_H
+#define GDB_M2_LANG_H
 
 struct type_print_options;
 struct parser_state;
@@ -149,4 +149,4 @@ class m2_language : public language_defn
   { return true; }
 };
 
-#endif /* M2_LANG_H */
+#endif /* GDB_M2_LANG_H */
diff --git a/gdb/m32r-tdep.h b/gdb/m32r-tdep.h
index 83799a3c698..1cc0de38c15 100644
--- a/gdb/m32r-tdep.h
+++ b/gdb/m32r-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M32R_TDEP_H
-#define M32R_TDEP_H
+#ifndef GDB_M32R_TDEP_H
+#define GDB_M32R_TDEP_H
 
 #include "gdbarch.h"
 
@@ -49,4 +49,4 @@ enum m32r_regnum
 
 #define M32R_NUM_REGS 25
 
-#endif /* m32r-tdep.h */
+#endif /* GDB_M32R_TDEP_H */
diff --git a/gdb/m68k-tdep.h b/gdb/m68k-tdep.h
index dcb3728896e..ad569932144 100644
--- a/gdb/m68k-tdep.h
+++ b/gdb/m68k-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M68K_TDEP_H
-#define M68K_TDEP_H
+#ifndef GDB_M68K_TDEP_H
+#define GDB_M68K_TDEP_H
 
 #include "gdbarch.h"
 
@@ -111,4 +111,4 @@ extern void m68k_svr4_init_abi (struct gdbarch_info, struct gdbarch *);
 
 extern int m68kbsd_fpreg_offset (struct gdbarch *gdbarch, int regnum);
 
-#endif /* m68k-tdep.h */
+#endif /* GDB_M68K_TDEP_H */
diff --git a/gdb/macroexp.h b/gdb/macroexp.h
index 2706f15787f..6fd5dc27916 100644
--- a/gdb/macroexp.h
+++ b/gdb/macroexp.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef MACROEXP_H
-#define MACROEXP_H
+#ifndef GDB_MACROEXP_H
+#define GDB_MACROEXP_H
 
 struct macro_scope;
 
@@ -81,4 +81,4 @@ int macro_is_digit (int c);
 /* Stringify STR according to C rules and return a null-terminated string.  */
 gdb::unique_xmalloc_ptr<char> macro_stringify (const char *str);
 
-#endif /* MACROEXP_H */
+#endif /* GDB_MACROEXP_H */
diff --git a/gdb/macroscope.h b/gdb/macroscope.h
index 6a1f5f0a3fe..ce9ae33838f 100644
--- a/gdb/macroscope.h
+++ b/gdb/macroscope.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MACROSCOPE_H
-#define MACROSCOPE_H
+#ifndef GDB_MACROSCOPE_H
+#define GDB_MACROSCOPE_H
 
 #include "macrotab.h"
 #include "symtab.h"
@@ -61,4 +61,4 @@ gdb::unique_xmalloc_ptr<struct macro_scope> default_macro_scope (void);
 macro_definition *standard_macro_lookup (const char *name,
 					 const macro_scope &ms);
 
-#endif /* MACROSCOPE_H */
+#endif /* GDB_MACROSCOPE_H */
diff --git a/gdb/macrotab.h b/gdb/macrotab.h
index 789beed0476..ea6557aa391 100644
--- a/gdb/macrotab.h
+++ b/gdb/macrotab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MACROTAB_H
-#define MACROTAB_H
+#ifndef GDB_MACROTAB_H
+#define GDB_MACROTAB_H
 
 #include "gdbsupport/function-view.h"
 
@@ -361,4 +361,4 @@ void macro_for_each_in_scope (struct macro_source_file *file, int line,
    of macro filenames printing was "absolute".  */
 extern std::string macro_source_fullname (struct macro_source_file *file);
 
-#endif /* MACROTAB_H */
+#endif /* GDB_MACROTAB_H */
diff --git a/gdb/main.h b/gdb/main.h
index fa267786d89..35dfe9d4729 100644
--- a/gdb/main.h
+++ b/gdb/main.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MAIN_H
-#define MAIN_H
+#ifndef GDB_MAIN_H
+#define GDB_MAIN_H
 
 struct captured_main_args
 {
@@ -46,4 +46,4 @@ extern char *windows_get_absolute_argv0 (const char *argv0);
 
 extern void set_gdb_data_directory (const char *new_data_dir);
 
-#endif
+#endif /* GDB_MAIN_H */
diff --git a/gdb/maint.h b/gdb/maint.h
index c1860d8cd59..5529d8a9d3a 100644
--- a/gdb/maint.h
+++ b/gdb/maint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MAINT_H
-#define MAINT_H
+#ifndef GDB_MAINT_H
+#define GDB_MAINT_H
 
 #include "gdbsupport/run-time-clock.h"
 #include <chrono>
@@ -70,4 +70,4 @@ class scoped_command_stats
 extern obj_section *maint_obj_section_from_bfd_section (bfd *abfd,
 							asection *asection,
 							objfile *ofile);
-#endif /* MAINT_H */
+#endif /* GDB_MAINT_H */
diff --git a/gdb/mdebugread.h b/gdb/mdebugread.h
index af0584bd3e6..4f434226ff9 100644
--- a/gdb/mdebugread.h
+++ b/gdb/mdebugread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MDEBUGREAD_H
-#define MDEBUGREAD_H
+#ifndef GDB_MDEBUGREAD_H
+#define GDB_MDEBUGREAD_H
 
 #include "coff/sym.h"
 #include "coff/symconst.h"
@@ -46,4 +46,4 @@ extern void elfmdebug_build_psymtabs (struct objfile *,
 				      const struct ecoff_debug_swap *,
 				      asection *);
 
-#endif /* MDEBUGREAD_H */
+#endif /* GDB_MDEBUGREAD_H */
diff --git a/gdb/memattr.h b/gdb/memattr.h
index dcc52298846..a6c9e6dcd8c 100644
--- a/gdb/memattr.h
+++ b/gdb/memattr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMATTR_H
-#define MEMATTR_H
+#ifndef GDB_MEMATTR_H
+#define GDB_MEMATTR_H
 
 enum mem_access_mode
 {
@@ -129,4 +129,4 @@ extern struct mem_region *lookup_mem_region (CORE_ADDR);
 
 void invalidate_target_mem_regions (void);
 
-#endif	/* MEMATTR_H */
+#endif /* GDB_MEMATTR_H */
diff --git a/gdb/memory-map.h b/gdb/memory-map.h
index 525646b6e37..59fcd4a9f73 100644
--- a/gdb/memory-map.h
+++ b/gdb/memory-map.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef MEMORY_MAP_H
-#define MEMORY_MAP_H
+#ifndef GDB_MEMORY_MAP_H
+#define GDB_MEMORY_MAP_H
 
 #include "memattr.h"
 
@@ -28,4 +28,4 @@
    return an empty vector.  Does not throw.  */
 std::vector<mem_region> parse_memory_map (const char *memory_map);
 
-#endif
+#endif /* GDB_MEMORY_MAP_H */
diff --git a/gdb/memrange.h b/gdb/memrange.h
index 74df82588f4..ec033ddb21e 100644
--- a/gdb/memrange.h
+++ b/gdb/memrange.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMRANGE_H
-#define MEMRANGE_H
+#ifndef GDB_MEMRANGE_H
+#define GDB_MEMRANGE_H
 
 /* Defines a [START, START + LENGTH) memory range.  */
 
@@ -64,4 +64,4 @@ extern int address_in_mem_range (CORE_ADDR addr,
 
 extern void normalize_mem_ranges (std::vector<mem_range> *memory);
 
-#endif
+#endif /* GDB_MEMRANGE_H */
diff --git a/gdb/memtag.h b/gdb/memtag.h
index b176371699c..600b4b9db74 100644
--- a/gdb/memtag.h
+++ b/gdb/memtag.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMTAG_H
-#define MEMTAG_H
+#ifndef GDB_MEMTAG_H
+#define GDB_MEMTAG_H
 
 #include "bfd.h"
 
@@ -47,4 +47,4 @@ bool get_next_core_memtag_section (bfd *abfd, asection *section,
 				   CORE_ADDR address,
 				   memtag_section_info &info);
 
-#endif /* MEMTAG_H */
+#endif /* GDB_MEMTAG_H */
diff --git a/gdb/mi/mi-cmd-break.h b/gdb/mi/mi-cmd-break.h
index 76aedfffcd9..160c578865d 100644
--- a/gdb/mi/mi-cmd-break.h
+++ b/gdb/mi/mi-cmd-break.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CMD_BREAK_H
-#define MI_MI_CMD_BREAK_H
+#ifndef GDB_MI_MI_CMD_BREAK_H
+#define GDB_MI_MI_CMD_BREAK_H
 
 #include "gdbsupport/scoped_restore.h"
 
@@ -27,4 +27,4 @@
    catchpoint.  */
 scoped_restore_tmpl<int> setup_breakpoint_reporting (void);
 
-#endif /* MI_MI_CMD_BREAK_H */
+#endif /* GDB_MI_MI_CMD_BREAK_H */
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index 26faded3032..9e31ba397b0 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CMDS_H
-#define MI_MI_CMDS_H
+#ifndef GDB_MI_MI_CMDS_H
+#define GDB_MI_MI_CMDS_H
 
 #include "gdbsupport/function-view.h"
 #include <optional>
@@ -237,4 +237,4 @@ extern void remove_mi_cmd_entries (remove_mi_cmd_entries_ftype callback);
 
 extern bool mi_simple_type_p (struct type *type);
 
-#endif /* MI_MI_CMDS_H */
+#endif /* GDB_MI_MI_CMDS_H */
diff --git a/gdb/mi/mi-common.h b/gdb/mi/mi-common.h
index 38ad35c3e36..4c3951ca8c0 100644
--- a/gdb/mi/mi-common.h
+++ b/gdb/mi/mi-common.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_COMMON_H
-#define MI_MI_COMMON_H
+#ifndef GDB_MI_MI_COMMON_H
+#define GDB_MI_MI_COMMON_H
 
 /* Represents the reason why GDB is sending an asynchronous command to
    the front end.  NOTE: When modifying this, don't forget to update
@@ -49,4 +49,4 @@ enum async_reply_reason
 
 const char *async_reason_lookup (enum async_reply_reason reason);
 
-#endif /* MI_MI_COMMON_H */
+#endif /* GDB_MI_MI_COMMON_H */
diff --git a/gdb/mi/mi-console.h b/gdb/mi/mi-console.h
index 89ba199fbce..89e0f4d3db6 100644
--- a/gdb/mi/mi-console.h
+++ b/gdb/mi/mi-console.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CONSOLE_H
-#define MI_MI_CONSOLE_H
+#ifndef GDB_MI_MI_CONSOLE_H
+#define GDB_MI_MI_CONSOLE_H
 
 /* An output stream for MI.  Wraps a given output stream with a prefix
    and handles quoting.  This stream is locally buffered.  */
@@ -55,4 +55,4 @@ class mi_console_file : public ui_file
   char m_quote;
 };
 
-#endif /* MI_MI_CONSOLE_H */
+#endif /* GDB_MI_MI_CONSOLE_H */
diff --git a/gdb/mi/mi-getopt.h b/gdb/mi/mi-getopt.h
index f3dd326fced..5bc35aa565a 100644
--- a/gdb/mi/mi-getopt.h
+++ b/gdb/mi/mi-getopt.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_GETOPT_H
-#define MI_MI_GETOPT_H
+#ifndef GDB_MI_MI_GETOPT_H
+#define GDB_MI_MI_GETOPT_H
 
 /* The option list.  Terminated by NAME==NULL.  ARG_P that the option
    requires an argument.  INDEX is returned to identify the option.  */
@@ -78,4 +78,4 @@ extern int mi_getopt_allow_unknown (const char *prefix, int argc,
 extern int mi_valid_noargs (const char *prefix, int argc,
 			    const char *const *argv);
 
-#endif /* MI_MI_GETOPT_H */
+#endif /* GDB_MI_MI_GETOPT_H */
diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h
index cd48fcf0aa1..8f5eee6f558 100644
--- a/gdb/mi/mi-interp.h
+++ b/gdb/mi/mi-interp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_INTERP_H
-#define MI_MI_INTERP_H
+#ifndef GDB_MI_MI_INTERP_H
+#define GDB_MI_MI_INTERP_H
 
 #include "interps.h"
 
@@ -119,4 +119,4 @@ as_mi_interp (struct interp *interp)
   return dynamic_cast<mi_interp *> (interp);
 }
 
-#endif /* MI_MI_INTERP_H */
+#endif /* GDB_MI_MI_INTERP_H */
diff --git a/gdb/mi/mi-main.h b/gdb/mi/mi-main.h
index 59c9ffa31bb..af670295c1f 100644
--- a/gdb/mi/mi-main.h
+++ b/gdb/mi/mi-main.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_MAIN_H
-#define MI_MI_MAIN_H
+#ifndef GDB_MI_MI_MAIN_H
+#define GDB_MI_MI_MAIN_H
 
 struct ui_file;
 
@@ -79,4 +79,4 @@ extern void mi_cmd_fix_breakpoint_script_output (const char *command,
 
 extern int mi_parse_thread_group_id (const char *id);
 
-#endif /* MI_MI_MAIN_H */
+#endif /* GDB_MI_MI_MAIN_H */
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index a7afb156ed4..16e6db2456e 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_OUT_H
-#define MI_MI_OUT_H
+#ifndef GDB_MI_MI_OUT_H
+#define GDB_MI_MI_OUT_H
 
 #include <vector>
 
@@ -151,4 +151,4 @@ std::unique_ptr<mi_ui_out> mi_out_new (const char *mi_version);
 void mi_out_put (ui_out *uiout, struct ui_file *stream);
 void mi_out_rewind (ui_out *uiout);
 
-#endif /* MI_MI_OUT_H */
+#endif /* GDB_MI_MI_OUT_H */
diff --git a/gdb/mi/mi-parse.h b/gdb/mi/mi-parse.h
index 8b685755a5c..22d10185925 100644
--- a/gdb/mi/mi-parse.h
+++ b/gdb/mi/mi-parse.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_PARSE_H
-#define MI_MI_PARSE_H
+#ifndef GDB_MI_MI_PARSE_H
+#define GDB_MI_MI_PARSE_H
 
 #include "gdbsupport/run-time-clock.h"
 #include <chrono>
@@ -101,4 +101,4 @@ struct mi_parse
 
 enum print_values mi_parse_print_values (const char *name);
 
-#endif /* MI_MI_PARSE_H */
+#endif /* GDB_MI_MI_PARSE_H */
diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
index 0b4a5a3f472..7b5924e9317 100644
--- a/gdb/microblaze-tdep.h
+++ b/gdb/microblaze-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MICROBLAZE_TDEP_H
-#define MICROBLAZE_TDEP_H 1
+#ifndef GDB_MICROBLAZE_TDEP_H
+#define GDB_MICROBLAZE_TDEP_H
 
 #include "gdbarch.h"
 
@@ -120,4 +120,4 @@ struct microblaze_frame_cache
    Only used for native debugging.  */
 #define MICROBLAZE_BREAKPOINT {0xb9, 0xcc, 0x00, 0x60}
 
-#endif /* microblaze-tdep.h */
+#endif /* GDB_MICROBLAZE_TDEP_H */
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index d44f281939b..4d704f0d35b 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MINSYMS_H
-#define MINSYMS_H
+#ifndef GDB_MINSYMS_H
+#define GDB_MINSYMS_H
 
 struct type;
 
@@ -327,4 +327,4 @@ CORE_ADDR minimal_symbol_upper_bound (struct bound_minimal_symbol minsym);
 type *find_minsym_type_and_address (minimal_symbol *msymbol, objfile *objf,
 				    CORE_ADDR *address_p);
 
-#endif /* MINSYMS_H */
+#endif /* GDB_MINSYMS_H */
diff --git a/gdb/mips-fbsd-tdep.h b/gdb/mips-fbsd-tdep.h
index ec834d0474a..201b1e5a793 100644
--- a/gdb/mips-fbsd-tdep.h
+++ b/gdb/mips-fbsd-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_FBSD_TDEP_H
-#define MIPS_FBSD_TDEP_H
+#ifndef GDB_MIPS_FBSD_TDEP_H
+#define GDB_MIPS_FBSD_TDEP_H
 
 void mips_fbsd_supply_fpregs (struct regcache *, int, const void *, size_t);
 void mips_fbsd_supply_gregs (struct regcache *, int, const void *, size_t);
 void mips_fbsd_collect_fpregs (const struct regcache *, int, void *, size_t);
 void mips_fbsd_collect_gregs (const struct regcache *, int, void *, size_t);
 
-#endif /* MIPS_FBSD_TDEP_H */
+#endif /* GDB_MIPS_FBSD_TDEP_H */
diff --git a/gdb/mips-linux-tdep.h b/gdb/mips-linux-tdep.h
index 2c4c35954c4..8670c0b7e15 100644
--- a/gdb/mips-linux-tdep.h
+++ b/gdb/mips-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_LINUX_TDEP_H
-#define MIPS_LINUX_TDEP_H
+#ifndef GDB_MIPS_LINUX_TDEP_H
+#define GDB_MIPS_LINUX_TDEP_H
 
 /* Copied from <asm/elf.h>.  */
 #define ELF_NGREG       45
@@ -113,4 +113,4 @@ extern const struct target_desc *tdesc_mips64_linux;
 extern const struct target_desc *tdesc_mips_dsp_linux;
 extern const struct target_desc *tdesc_mips64_dsp_linux;
 
-#endif /* MIPS_LINUX_TDEP_H */
+#endif /* GDB_MIPS_LINUX_TDEP_H */
diff --git a/gdb/mips-netbsd-tdep.h b/gdb/mips-netbsd-tdep.h
index 034261fbf44..e9544f0f1bf 100644
--- a/gdb/mips-netbsd-tdep.h
+++ b/gdb/mips-netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_NBSD_TDEP_H
-#define MIPS_NBSD_TDEP_H
+#ifndef GDB_MIPS_NETBSD_TDEP_H
+#define GDB_MIPS_NETBSD_TDEP_H
 
 void mipsnbsd_supply_reg (struct regcache *, const char *, int);
 void mipsnbsd_fill_reg (const struct regcache *, char *, int);
@@ -26,4 +26,4 @@ void mipsnbsd_fill_reg (const struct regcache *, char *, int);
 void mipsnbsd_supply_fpreg (struct regcache *, const char *, int);
 void mipsnbsd_fill_fpreg (const struct regcache *, char *, int);
 
-#endif /* MIPS_NBSD_TDEP_H */
+#endif /* GDB_MIPS_NETBSD_TDEP_H */
diff --git a/gdb/mips-tdep.h b/gdb/mips-tdep.h
index eec1fb56f4e..df589cf71b8 100644
--- a/gdb/mips-tdep.h
+++ b/gdb/mips-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_TDEP_H
-#define MIPS_TDEP_H
+#ifndef GDB_MIPS_TDEP_H
+#define GDB_MIPS_TDEP_H
 
 #include "objfiles.h"
 #include "gdbarch.h"
@@ -201,4 +201,4 @@ in_mips_stubs_section (CORE_ADDR pc)
   return pc_in_section (pc, ".MIPS.stubs");
 }
 
-#endif /* MIPS_TDEP_H */
+#endif /* GDB_MIPS_TDEP_H */
diff --git a/gdb/mn10300-tdep.h b/gdb/mn10300-tdep.h
index 683a6ec2e14..bec5f04253a 100644
--- a/gdb/mn10300-tdep.h
+++ b/gdb/mn10300-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MN10300_TDEP_H
-#define MN10300_TDEP_H
+#ifndef GDB_MN10300_TDEP_H
+#define GDB_MN10300_TDEP_H
 
 #include "gdbarch.h"
 
@@ -88,4 +88,4 @@ get_am33_mode (gdbarch *arch)
   return tdep->am33_mode;
 }
 
-#endif /* MN10300_TDEP_H */
+#endif /* GDB_MN10300_TDEP_H */
diff --git a/gdb/moxie-tdep.h b/gdb/moxie-tdep.h
index 64bfc825fc1..329d9972b49 100644
--- a/gdb/moxie-tdep.h
+++ b/gdb/moxie-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MOXIE_TDEP_H
-#define MOXIE_TDEP_H
+#ifndef GDB_MOXIE_TDEP_H
+#define GDB_MOXIE_TDEP_H
 
 #include "gdbarch.h"
 
@@ -42,4 +42,4 @@ enum moxie_regnum
 
 #define MOXIE_NUM_REGS 18
 
-#endif /* moxie-tdep.h */
+#endif /* GDB_MOXIE_TDEP_H */
diff --git a/gdb/namespace.h b/gdb/namespace.h
index 232dcc03bd8..a9b020f6395 100644
--- a/gdb/namespace.h
+++ b/gdb/namespace.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAMESPACE_H
-#define NAMESPACE_H
+#ifndef GDB_NAMESPACE_H
+#define GDB_NAMESPACE_H
 
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbsupport/gdb_obstack.h"
@@ -127,4 +127,4 @@ extern void add_using_directive (struct using_direct **using_directives,
 				 const unsigned int decl_line,
 				 struct obstack *obstack);
 
-#endif /* NAMESPACE_H */
+#endif /* GDB_NAMESPACE_H */
diff --git a/gdb/nat/aarch64-hw-point.h b/gdb/nat/aarch64-hw-point.h
index bdcca932e57..f4db38b494d 100644
--- a/gdb/nat/aarch64-hw-point.h
+++ b/gdb/nat/aarch64-hw-point.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_HW_POINT_H
-#define NAT_AARCH64_HW_POINT_H
+#ifndef GDB_NAT_AARCH64_HW_POINT_H
+#define GDB_NAT_AARCH64_HW_POINT_H
 
 /* Macro definitions, data structures, and code for the hardware
    breakpoint and hardware watchpoint support follow.  We use the
@@ -128,4 +128,4 @@ void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state,
 
 int aarch64_region_ok_for_watchpoint (CORE_ADDR addr, int len);
 
-#endif /* NAT_AARCH64_HW_POINT_H */
+#endif /* GDB_NAT_AARCH64_HW_POINT_H */
diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h
index cf749c34ae7..618f79f1587 100644
--- a/gdb/nat/aarch64-linux-hw-point.h
+++ b/gdb/nat/aarch64-linux-hw-point.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_LINUX_HW_POINT_H
-#define NAT_AARCH64_LINUX_HW_POINT_H
+#ifndef GDB_NAT_AARCH64_LINUX_HW_POINT_H
+#define GDB_NAT_AARCH64_LINUX_HW_POINT_H
 
 #include "gdbsupport/break-common.h"
 
@@ -109,4 +109,4 @@ void aarch64_linux_get_debug_reg_capacity (int tid);
 
 struct aarch64_debug_reg_state *aarch64_get_debug_reg_state (pid_t pid);
 
-#endif /* NAT_AARCH64_LINUX_HW_POINT_H */
+#endif /* GDB_NAT_AARCH64_LINUX_HW_POINT_H */
diff --git a/gdb/nat/aarch64-linux.h b/gdb/nat/aarch64-linux.h
index f4df7481162..969bb52b812 100644
--- a/gdb/nat/aarch64-linux.h
+++ b/gdb/nat/aarch64-linux.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_LINUX_H
-#define NAT_AARCH64_LINUX_H
+#ifndef GDB_NAT_AARCH64_LINUX_H
+#define GDB_NAT_AARCH64_LINUX_H
 
 #include <signal.h>
 
@@ -133,4 +133,4 @@ ps_err_e aarch64_ps_get_thread_area (struct ps_prochandle *ph,
    used for aarch64 state.  */
 int aarch64_tls_register_count (int tid);
 
-#endif /* NAT_AARCH64_LINUX_H */
+#endif /* GDB_NAT_AARCH64_LINUX_H */
diff --git a/gdb/nat/aarch64-mte-linux-ptrace.h b/gdb/nat/aarch64-mte-linux-ptrace.h
index 28dd8158c90..e02a0818963 100644
--- a/gdb/nat/aarch64-mte-linux-ptrace.h
+++ b/gdb/nat/aarch64-mte-linux-ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_MTE_LINUX_PTRACE_H
-#define NAT_AARCH64_MTE_LINUX_PTRACE_H
+#ifndef GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
+#define GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
 
 /* MTE allocation tag access */
 
@@ -47,4 +47,4 @@ extern bool aarch64_mte_fetch_memtags (int tid, CORE_ADDR address, size_t len,
 extern bool aarch64_mte_store_memtags (int tid, CORE_ADDR address, size_t len,
 				       const gdb::byte_vector &tags);
 
-#endif /* NAT_AARCH64_MTE_LINUX_PTRACE_H */
+#endif /* GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H */
diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h
index 2be45588785..2c6d899e931 100644
--- a/gdb/nat/aarch64-scalable-linux-ptrace.h
+++ b/gdb/nat/aarch64-scalable-linux-ptrace.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
-#define NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
+#ifndef GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
+#define GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
 
 #include <signal.h>
 #include <sys/utsname.h>
@@ -176,4 +176,4 @@ aarch64_zt_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf,
 extern void
 aarch64_zt_regs_copy_from_reg_buf (int tid, struct reg_buffer_common *reg_buf,
 				   int zt_regnum);
-#endif /* NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */
+#endif /* GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */
diff --git a/gdb/nat/aarch64-scalable-linux-sigcontext.h b/gdb/nat/aarch64-scalable-linux-sigcontext.h
index 8db524250a8..bfda9be617a 100644
--- a/gdb/nat/aarch64-scalable-linux-sigcontext.h
+++ b/gdb/nat/aarch64-scalable-linux-sigcontext.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
-#define NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
+#ifndef GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
+#define GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
 
 #ifndef SVE_SIG_ZREGS_SIZE
 
@@ -325,4 +325,4 @@ struct user_za_header {
 	(ZA_PT_ZA_OFFSET + ZA_PT_ZA_SIZE(vq))
 #endif /* ZA_PT_SIZE */
 
-#endif /* NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H */
+#endif /* GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H */
diff --git a/gdb/nat/amd64-linux-siginfo.h b/gdb/nat/amd64-linux-siginfo.h
index b8fd8c0e2ae..1e102ae99b3 100644
--- a/gdb/nat/amd64-linux-siginfo.h
+++ b/gdb/nat/amd64-linux-siginfo.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AMD64_LINUX_SIGINFO_H
-#define NAT_AMD64_LINUX_SIGINFO_H
+#ifndef GDB_NAT_AMD64_LINUX_SIGINFO_H
+#define GDB_NAT_AMD64_LINUX_SIGINFO_H
 
 #include <signal.h>
 
@@ -55,4 +55,4 @@ int amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf,
 				      int direction,
 				      enum amd64_siginfo_fixup_mode mode);
 
-#endif /* NAT_AMD64_LINUX_SIGINFO_H */
+#endif /* GDB_NAT_AMD64_LINUX_SIGINFO_H */
diff --git a/gdb/nat/fork-inferior.h b/gdb/nat/fork-inferior.h
index a609f68bcb4..509aa053764 100644
--- a/gdb/nat/fork-inferior.h
+++ b/gdb/nat/fork-inferior.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_FORK_INFERIOR_H
-#define NAT_FORK_INFERIOR_H
+#ifndef GDB_NAT_FORK_INFERIOR_H
+#define GDB_NAT_FORK_INFERIOR_H
 
 #include <string>
 #include "gdbsupport/function-view.h"
@@ -87,4 +87,4 @@ extern void trace_start_error (const char *fmt, ...)
 extern void trace_start_error_with_name (const char *string)
   ATTRIBUTE_NORETURN;
 
-#endif /* NAT_FORK_INFERIOR_H */
+#endif /* GDB_NAT_FORK_INFERIOR_H */
diff --git a/gdb/nat/gdb_ptrace.h b/gdb/nat/gdb_ptrace.h
index 81727cbdbd6..17858848a62 100644
--- a/gdb/nat/gdb_ptrace.h
+++ b/gdb/nat/gdb_ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GDB_PTRACE_H
-#define NAT_GDB_PTRACE_H
+#ifndef GDB_NAT_GDB_PTRACE_H
+#define GDB_NAT_GDB_PTRACE_H
 
 /* The <sys/ptrace.h> header was introduced with 4.4BSD, and provided
    the PT_* symbolic constants for the ptrace(2) request numbers.  The
@@ -142,4 +142,4 @@
 	 ptrace ((PTRACE_TYPE_ARG1) request, pid, addr, data)
 #endif
 
-#endif /* NAT_GDB_PTRACE_H */
+#endif /* GDB_NAT_GDB_PTRACE_H */
diff --git a/gdb/nat/gdb_thread_db.h b/gdb/nat/gdb_thread_db.h
index 0e683787c40..446b92129dd 100644
--- a/gdb/nat/gdb_thread_db.h
+++ b/gdb/nat/gdb_thread_db.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GDB_THREAD_DB_H
-#define NAT_GDB_THREAD_DB_H
+#ifndef GDB_NAT_GDB_THREAD_DB_H
+#define GDB_NAT_GDB_THREAD_DB_H
 
 #ifdef HAVE_THREAD_DB_H
 #include <thread_db.h>
@@ -73,4 +73,4 @@ typedef td_err_e (td_thr_tlsbase_ftype) (const td_thrhandle_t *th,
 typedef const char ** (td_symbol_list_ftype) (void);
 typedef td_err_e (td_ta_delete_ftype) (td_thragent_t *);
 
-#endif /* NAT_GDB_THREAD_DB_H */
+#endif /* GDB_NAT_GDB_THREAD_DB_H */
diff --git a/gdb/nat/glibc_thread_db.h b/gdb/nat/glibc_thread_db.h
index 598805deef2..87eb62b3efe 100644
--- a/gdb/nat/glibc_thread_db.h
+++ b/gdb/nat/glibc_thread_db.h
@@ -16,8 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GLIBC_THREAD_DB_H
-#define NAT_GLIBC_THREAD_DB_H
+#ifndef GDB_NAT_GLIBC_THREAD_DB_H
+#define GDB_NAT_GLIBC_THREAD_DB_H
 
 /* This is the debugger interface for the NPTL library.  It is
    modelled closely after the interface with same names in Solaris
@@ -455,4 +455,4 @@ extern td_err_e td_thr_dbsuspend (const td_thrhandle_t *__th);
 /* Resume execution of thread TH.  */
 extern td_err_e td_thr_dbresume (const td_thrhandle_t *__th);
 
-#endif /* NAT_GLIBC_THREAD_DB_H */
+#endif /* GDB_NAT_GLIBC_THREAD_DB_H */
diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
index 0771f4b5a65..6fd81073673 100644
--- a/gdb/nat/linux-btrace.h
+++ b/gdb/nat/linux-btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_BTRACE_H
-#define NAT_LINUX_BTRACE_H
+#ifndef GDB_NAT_LINUX_BTRACE_H
+#define GDB_NAT_LINUX_BTRACE_H
 
 #include "gdbsupport/btrace-common.h"
 #include "gdbsupport/gdb-checked-static-cast.h"
@@ -86,4 +86,4 @@ extern enum btrace_error linux_read_btrace (struct btrace_data *btrace,
 extern const struct btrace_config *
   linux_btrace_conf (const struct btrace_target_info *);
 
-#endif /* NAT_LINUX_BTRACE_H */
+#endif /* GDB_NAT_LINUX_BTRACE_H */
diff --git a/gdb/nat/linux-namespaces.h b/gdb/nat/linux-namespaces.h
index 298ff056653..4327292950b 100644
--- a/gdb/nat/linux-namespaces.h
+++ b/gdb/nat/linux-namespaces.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_NAMESPACES_H
-#define NAT_LINUX_NAMESPACES_H
+#ifndef GDB_NAT_LINUX_NAMESPACES_H
+#define GDB_NAT_LINUX_NAMESPACES_H
 
 /* Set to true to enable debugging of Linux namespaces code.  */
 
@@ -73,4 +73,4 @@ extern int linux_mntns_unlink (pid_t pid, const char *filename);
 extern ssize_t linux_mntns_readlink (pid_t pid, const char *filename,
 				     char *buf, size_t bufsiz);
 
-#endif /* NAT_LINUX_NAMESPACES_H */
+#endif /* GDB_NAT_LINUX_NAMESPACES_H */
diff --git a/gdb/nat/linux-nat.h b/gdb/nat/linux-nat.h
index d4a36cbb601..e847eb033bd 100644
--- a/gdb/nat/linux-nat.h
+++ b/gdb/nat/linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_NAT_H
-#define NAT_LINUX_NAT_H
+#ifndef GDB_NAT_LINUX_NAT_H
+#define GDB_NAT_LINUX_NAT_H
 
 #include "gdbsupport/function-view.h"
 #include "target/waitstatus.h"
@@ -91,4 +91,4 @@ extern void linux_stop_lwp (struct lwp_info *lwp);
 
 extern int lwp_is_stepping (struct lwp_info *lwp);
 
-#endif /* NAT_LINUX_NAT_H */
+#endif /* GDB_NAT_LINUX_NAT_H */
diff --git a/gdb/nat/linux-osdata.h b/gdb/nat/linux-osdata.h
index 833915cdb2f..a700ea1eb80 100644
--- a/gdb/nat/linux-osdata.h
+++ b/gdb/nat/linux-osdata.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_OSDATA_H
-#define NAT_LINUX_OSDATA_H
+#ifndef GDB_NAT_LINUX_OSDATA_H
+#define GDB_NAT_LINUX_OSDATA_H
 
 extern int linux_common_core_of_thread (ptid_t ptid);
 extern LONGEST linux_common_xfer_osdata (const char *annex, gdb_byte *readbuf,
 					 ULONGEST offset, ULONGEST len);
 
-#endif /* NAT_LINUX_OSDATA_H */
+#endif /* GDB_NAT_LINUX_OSDATA_H */
diff --git a/gdb/nat/linux-personality.h b/gdb/nat/linux-personality.h
index 0238fe0c7e5..ab6727076ad 100644
--- a/gdb/nat/linux-personality.h
+++ b/gdb/nat/linux-personality.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PERSONALITY_H
-#define NAT_LINUX_PERSONALITY_H
+#ifndef GDB_NAT_LINUX_PERSONALITY_H
+#define GDB_NAT_LINUX_PERSONALITY_H
 
 class maybe_disable_address_space_randomization
 {
@@ -43,4 +43,4 @@ class maybe_disable_address_space_randomization
   int m_personality_orig;
 };
 
-#endif /* ! NAT_LINUX_PERSONALITY_H */
+#endif /* GDB_NAT_LINUX_PERSONALITY_H */
diff --git a/gdb/nat/linux-procfs.h b/gdb/nat/linux-procfs.h
index 880afbcdd61..6b352d97f3d 100644
--- a/gdb/nat/linux-procfs.h
+++ b/gdb/nat/linux-procfs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PROCFS_H
-#define NAT_LINUX_PROCFS_H
+#ifndef GDB_NAT_LINUX_PROCFS_H
+#define GDB_NAT_LINUX_PROCFS_H
 
 #include <unistd.h>
 
@@ -85,4 +85,4 @@ extern const char *linux_proc_pid_to_exec_file (int pid);
 
 extern void linux_proc_init_warnings ();
 
-#endif /* NAT_LINUX_PROCFS_H */
+#endif /* GDB_NAT_LINUX_PROCFS_H */
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index a3b4ca8d176..c7d40234044 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PTRACE_H
-#define NAT_LINUX_PTRACE_H
+#ifndef GDB_NAT_LINUX_PTRACE_H
+#define GDB_NAT_LINUX_PTRACE_H
 
 #include "nat/gdb_ptrace.h"
 #include "gdbsupport/gdb_wait.h"
@@ -186,4 +186,4 @@ extern int linux_ptrace_get_extended_event (int wstat);
 extern int linux_is_extended_waitstatus (int wstat);
 extern int linux_wstatus_maybe_breakpoint (int wstat);
 
-#endif /* NAT_LINUX_PTRACE_H */
+#endif /* GDB_NAT_LINUX_PTRACE_H */
diff --git a/gdb/nat/linux-waitpid.h b/gdb/nat/linux-waitpid.h
index e069f8a84a8..b75782d4520 100644
--- a/gdb/nat/linux-waitpid.h
+++ b/gdb/nat/linux-waitpid.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_WAITPID_H
-#define NAT_LINUX_WAITPID_H
+#ifndef GDB_NAT_LINUX_WAITPID_H
+#define GDB_NAT_LINUX_WAITPID_H
 
 /* Wrapper function for waitpid which handles EINTR.  */
 extern int my_waitpid (int pid, int *status, int flags);
@@ -27,4 +27,4 @@ extern int my_waitpid (int pid, int *status, int flags);
    messages only.  */
 extern std::string status_to_str (int status);
 
-#endif /* NAT_LINUX_WAITPID_H */
+#endif /* GDB_NAT_LINUX_WAITPID_H */
diff --git a/gdb/nat/mips-linux-watch.h b/gdb/nat/mips-linux-watch.h
index a37eabd2058..b18b009f3b7 100644
--- a/gdb/nat/mips-linux-watch.h
+++ b/gdb/nat/mips-linux-watch.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_MIPS_LINUX_WATCH_H
-#define NAT_MIPS_LINUX_WATCH_H
+#ifndef GDB_NAT_MIPS_LINUX_WATCH_H
+#define GDB_NAT_MIPS_LINUX_WATCH_H
 
 #include <asm/ptrace.h>
 #include "gdbsupport/break-common.h"
@@ -116,4 +116,4 @@ int mips_linux_read_watch_registers (long lwpid,
 				     struct pt_watch_regs *watch_readback,
 				     int *watch_readback_valid, int force);
 
-#endif /* NAT_MIPS_LINUX_WATCH_H */
+#endif /* GDB_NAT_MIPS_LINUX_WATCH_H */
diff --git a/gdb/nat/netbsd-nat.h b/gdb/nat/netbsd-nat.h
index cc529cfd0c6..1ffd705e3be 100644
--- a/gdb/nat/netbsd-nat.h
+++ b/gdb/nat/netbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_NETBSD_NAT_H
-#define NAT_NETBSD_NAT_H
+#ifndef GDB_NAT_NETBSD_NAT_H
+#define GDB_NAT_NETBSD_NAT_H
 
 #include "gdbsupport/function-view.h"
 
@@ -91,4 +91,4 @@ extern int read_memory (pid_t pid, unsigned char *readbuf, CORE_ADDR offset,
 			size_t len, size_t *xfered_len);
 }
 
-#endif
+#endif /* GDB_NAT_NETBSD_NAT_H */
diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h
index b51e2278f4b..3efc1b9a9bf 100644
--- a/gdb/nat/ppc-linux.h
+++ b/gdb/nat/ppc-linux.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_PPC_LINUX_H
-#define NAT_PPC_LINUX_H
+#ifndef GDB_NAT_PPC_LINUX_H
+#define GDB_NAT_PPC_LINUX_H
 
 #include <asm/ptrace.h>
 #include <asm/cputable.h>
@@ -162,4 +162,4 @@
 /* Return the wordsize of the target, either 4 or 8 bytes.  */
 int ppc_linux_target_wordsize (int tid);
 
-#endif /* NAT_PPC_LINUX_H */
+#endif /* GDB_NAT_PPC_LINUX_H */
diff --git a/gdb/nat/riscv-linux-tdesc.h b/gdb/nat/riscv-linux-tdesc.h
index fa9d5bcb7f5..875135ed979 100644
--- a/gdb/nat/riscv-linux-tdesc.h
+++ b/gdb/nat/riscv-linux-tdesc.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_RISCV_LINUX_TDESC_H
-#define NAT_RISCV_LINUX_TDESC_H
+#ifndef GDB_NAT_RISCV_LINUX_TDESC_H
+#define GDB_NAT_RISCV_LINUX_TDESC_H
 
 #include "arch/riscv.h"
 
@@ -25,4 +25,4 @@
    corresponding features object.  */
 struct riscv_gdbarch_features riscv_linux_read_features (int tid);
 
-#endif /* NAT_RISCV_LINUX_TDESC_H */
+#endif /* GDB_NAT_RISCV_LINUX_TDESC_H */
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index f2b5d777016..e03b41a53d4 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_WINDOWS_NAT_H
-#define NAT_WINDOWS_NAT_H
+#ifndef GDB_NAT_WINDOWS_NAT_H
+#define GDB_NAT_WINDOWS_NAT_H
 
 #include <windows.h>
 #include <psapi.h>
@@ -440,4 +440,4 @@ extern bool initialize_loadable ();
 
 }
 
-#endif
+#endif /* GDB_NAT_WINDOWS_NAT_H */
diff --git a/gdb/nat/x86-cpuid.h b/gdb/nat/x86-cpuid.h
index 5e9ce604f4e..02a204c1348 100644
--- a/gdb/nat/x86-cpuid.h
+++ b/gdb/nat/x86-cpuid.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_CPUID_H
-#define NAT_X86_CPUID_H
+#ifndef GDB_NAT_X86_CPUID_H
+#define GDB_NAT_X86_CPUID_H
 
 /* Always include the header for the cpu bit defines.  */
 #include "x86-gcc-cpuid.h"
@@ -82,4 +82,4 @@ x86_cpuid_count (unsigned int __level, unsigned int __sublevel,
 #undef nullptr
 #endif
 
-#endif /* NAT_X86_CPUID_H */
+#endif /* GDB_NAT_X86_CPUID_H */
diff --git a/gdb/nat/x86-dregs.h b/gdb/nat/x86-dregs.h
index 795cb112f88..3dcbf8e3028 100644
--- a/gdb/nat/x86-dregs.h
+++ b/gdb/nat/x86-dregs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_DREGS_H
-#define NAT_X86_DREGS_H
+#ifndef GDB_NAT_X86_DREGS_H
+#define GDB_NAT_X86_DREGS_H
 
 /* Support for hardware watchpoints and breakpoints using the x86
    debug registers.
@@ -133,4 +133,4 @@ extern int x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state);
    triggered.  Otherwise return false.  */
 extern int x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state);
 
-#endif /* NAT_X86_DREGS_H */
+#endif /* GDB_NAT_X86_DREGS_H */
diff --git a/gdb/nat/x86-gcc-cpuid.h b/gdb/nat/x86-gcc-cpuid.h
index dfd12587d81..b0f2d239af3 100644
--- a/gdb/nat/x86-gcc-cpuid.h
+++ b/gdb/nat/x86-gcc-cpuid.h
@@ -3,8 +3,8 @@
  * include this directly, but pull in x86-cpuid.h and use that func.
  */
 
-#ifndef NAT_X86_GCC_CPUID_H
-#define NAT_X86_GCC_CPUID_H
+#ifndef GDB_NAT_X86_GCC_CPUID_H
+#define GDB_NAT_X86_GCC_CPUID_H
 
 /*
  * Copyright (C) 2007-2024 Free Software Foundation, Inc.
@@ -273,4 +273,4 @@ __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
   return 1;
 }
 
-#endif /* NAT_X86_GCC_CPUID_H */
+#endif /* GDB_NAT_X86_GCC_CPUID_H */
diff --git a/gdb/nat/x86-linux-dregs.h b/gdb/nat/x86-linux-dregs.h
index 2b30c4a7a62..6f6a6e3d24e 100644
--- a/gdb/nat/x86-linux-dregs.h
+++ b/gdb/nat/x86-linux-dregs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_LINUX_DREGS_H
-#define NAT_X86_LINUX_DREGS_H
+#ifndef GDB_NAT_X86_LINUX_DREGS_H
+#define GDB_NAT_X86_LINUX_DREGS_H
 
 /* Return the address stored in the current inferior's debug register
    REGNUM.  */
@@ -50,4 +50,4 @@ extern unsigned long x86_linux_dr_get_status (void);
 
 extern void x86_linux_update_debug_registers (struct lwp_info *lwp);
 
-#endif /* NAT_X86_LINUX_DREGS_H */
+#endif /* GDB_NAT_X86_LINUX_DREGS_H */
diff --git a/gdb/nat/x86-linux.h b/gdb/nat/x86-linux.h
index 822882173f9..9b5db895455 100644
--- a/gdb/nat/x86-linux.h
+++ b/gdb/nat/x86-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_LINUX_H
-#define NAT_X86_LINUX_H
+#ifndef GDB_NAT_X86_LINUX_H
+#define GDB_NAT_X86_LINUX_H
 
 #include "nat/linux-nat.h"
 
@@ -47,4 +47,4 @@ extern void x86_linux_delete_thread (struct arch_lwp_info *arch_lwp);
 
 extern void x86_linux_prepare_to_resume (struct lwp_info *lwp);
 
-#endif /* NAT_X86_LINUX_H */
+#endif /* GDB_NAT_X86_LINUX_H */
diff --git a/gdb/nat/x86-xstate.h b/gdb/nat/x86-xstate.h
index 199d39a5217..14b58cd0312 100644
--- a/gdb/nat/x86-xstate.h
+++ b/gdb/nat/x86-xstate.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_XSTATE_H
-#define NAT_X86_XSTATE_H
+#ifndef GDB_NAT_X86_XSTATE_H
+#define GDB_NAT_X86_XSTATE_H
 
 #include "gdbsupport/x86-xstate.h"
 
@@ -32,4 +32,4 @@ int x86_xsave_length ();
 
 x86_xsave_layout x86_fetch_xsave_layout (uint64_t xcr0, int len);
 
-#endif /* NAT_X86_XSTATE_H */
+#endif /* GDB_NAT_X86_XSTATE_H */
diff --git a/gdb/nds32-tdep.h b/gdb/nds32-tdep.h
index a4d62848c51..18c360d7bdb 100644
--- a/gdb/nds32-tdep.h
+++ b/gdb/nds32-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NDS32_TDEP_H
-#define NDS32_TDEP_H
+#ifndef GDB_NDS32_TDEP_H
+#define GDB_NDS32_TDEP_H
 
 #include "gdbarch.h"
 
@@ -53,4 +53,4 @@ struct nds32_gdbarch_tdep : gdbarch_tdep_base
   /* ELF ABI info.  */
   int elf_abi = 0;
 };
-#endif /* NDS32_TDEP_H */
+#endif /* GDB_NDS32_TDEP_H */
diff --git a/gdb/netbsd-nat.h b/gdb/netbsd-nat.h
index 4895b088d13..87e076f69e7 100644
--- a/gdb/netbsd-nat.h
+++ b/gdb/netbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NBSD_NAT_H
-#define NBSD_NAT_H
+#ifndef GDB_NETBSD_NAT_H
+#define GDB_NETBSD_NAT_H
 
 #include "inf-ptrace.h"
 
@@ -61,4 +61,4 @@ struct nbsd_nat_target : public inf_ptrace_target
   void post_startup_inferior (ptid_t ptid) override;
 };
 
-#endif /* netbsd-nat.h */
+#endif /* GDB_NETBSD_NAT_H */
diff --git a/gdb/netbsd-tdep.h b/gdb/netbsd-tdep.h
index 3a9d527ca81..2e2993ea5dc 100644
--- a/gdb/netbsd-tdep.h
+++ b/gdb/netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NBSD_TDEP_H
-#define NBSD_TDEP_H
+#ifndef GDB_NETBSD_TDEP_H
+#define GDB_NETBSD_TDEP_H
 
 int nbsd_pc_in_sigtramp (CORE_ADDR, const char *);
 
@@ -44,4 +44,4 @@ extern void nbsd_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
 					   int kve_flags, int kve_protection,
 					   const char *kve_path);
 
-#endif /* NBSD_TDEP_H */
+#endif /* GDB_NETBSD_TDEP_H */
diff --git a/gdb/nios2-tdep.h b/gdb/nios2-tdep.h
index 57e0de7076d..0b3d01ab232 100644
--- a/gdb/nios2-tdep.h
+++ b/gdb/nios2-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NIOS2_TDEP_H
-#define NIOS2_TDEP_H
+#ifndef GDB_NIOS2_TDEP_H
+#define GDB_NIOS2_TDEP_H
 
 #include "gdbarch.h"
 
@@ -87,4 +87,4 @@ struct nios2_gdbarch_tdep : gdbarch_tdep_base
 extern const struct target_desc *tdesc_nios2_linux;
 extern const struct target_desc *tdesc_nios2;
 
-#endif /* NIOS2_TDEP_H */
+#endif /* GDB_NIOS2_TDEP_H */
diff --git a/gdb/nto-tdep.h b/gdb/nto-tdep.h
index 249a4f631fe..2edbcff8c91 100644
--- a/gdb/nto-tdep.h
+++ b/gdb/nto-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NTO_TDEP_H
-#define NTO_TDEP_H
+#ifndef GDB_NTO_TDEP_H
+#define GDB_NTO_TDEP_H
 
 #include "solist.h"
 #include "osabi.h"
@@ -191,4 +191,4 @@ LONGEST nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack,
 
 struct nto_inferior_data *nto_inferior_data (struct inferior *inf);
 
-#endif /* NTO_TDEP_H */
+#endif /* GDB_NTO_TDEP_H */
diff --git a/gdb/objc-lang.h b/gdb/objc-lang.h
index 879d7475d9d..6a8dc39c53a 100644
--- a/gdb/objc-lang.h
+++ b/gdb/objc-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(OBJC_LANG_H)
-#define OBJC_LANG_H
+#ifndef GDB_OBJC_LANG_H
+#define GDB_OBJC_LANG_H
 
 struct stoken;
 
@@ -48,4 +48,4 @@ struct symbol *lookup_struct_typedef (const char *name,
 				      const struct block *block,
 				      int noerr);
 
-#endif
+#endif /* GDB_OBJC_LANG_H */
diff --git a/gdb/objfile-flags.h b/gdb/objfile-flags.h
index 43d888e2a5a..e0a84bcdc2e 100644
--- a/gdb/objfile-flags.h
+++ b/gdb/objfile-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (OBJFILE_FLAGS_H)
-#define OBJFILE_FLAGS_H
+#ifndef GDB_OBJFILE_FLAGS_H
+#define GDB_OBJFILE_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -60,4 +60,4 @@ enum objfile_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum objfile_flag, objfile_flags);
 
-#endif /* !defined (OBJFILE_FLAGS_H) */
+#endif /* GDB_OBJFILE_FLAGS_H */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 8b8b7182e87..4d8e5c45680 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (OBJFILES_H)
-#define OBJFILES_H
+#ifndef GDB_OBJFILES_H
+#define GDB_OBJFILES_H
 
 #include "hashtab.h"
 #include "gdbsupport/gdb_obstack.h"
@@ -1031,4 +1031,4 @@ extern void objfile_register_static_link
 extern const struct dynamic_prop *objfile_lookup_static_link
   (struct objfile *objfile, const struct block *block);
 
-#endif /* !defined (OBJFILES_H) */
+#endif /* GDB_OBJFILES_H */
diff --git a/gdb/obsd-nat.h b/gdb/obsd-nat.h
index 0811a82d85c..35ee212e09f 100644
--- a/gdb/obsd-nat.h
+++ b/gdb/obsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSD_NAT_H
-#define OBSD_NAT_H
+#ifndef GDB_OBSD_NAT_H
+#define GDB_OBSD_NAT_H
 
 #include "inf-ptrace.h"
 
@@ -41,4 +41,4 @@ class obsd_nat_target : public inf_ptrace_target
   void post_startup_inferior (ptid_t) override;
 };
 
-#endif /* obsd-nat.h */
+#endif /* GDB_OBSD_NAT_H */
diff --git a/gdb/obsd-tdep.h b/gdb/obsd-tdep.h
index 85cea7be7cf..c018513cb1b 100644
--- a/gdb/obsd-tdep.h
+++ b/gdb/obsd-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSD_TDEP_H
-#define OBSD_TDEP_H 1
+#ifndef GDB_OBSD_TDEP_H
+#define GDB_OBSD_TDEP_H
 
 struct gdbarch;
 
 CORE_ADDR obsd_skip_solib_resolver (struct gdbarch *, CORE_ADDR);
 void obsd_init_abi (struct gdbarch_info, struct gdbarch *);
 
-#endif /* obsd-tdep.h */
+#endif /* GDB_OBSD_TDEP_H */
diff --git a/gdb/observable.h b/gdb/observable.h
index 2aa3ef3fd4e..2ce2711abd6 100644
--- a/gdb/observable.h
+++ b/gdb/observable.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSERVABLE_H
-#define OBSERVABLE_H
+#ifndef GDB_OBSERVABLE_H
+#define GDB_OBSERVABLE_H
 
 #include "gdbsupport/observable.h"
 #include "target/waitstatus.h"
@@ -257,4 +257,4 @@ extern observable <program_space */* pspace */> free_program_space;
 
 } /* namespace gdb */
 
-#endif /* OBSERVABLE_H */
+#endif /* GDB_OBSERVABLE_H */
diff --git a/gdb/or1k-linux-tdep.h b/gdb/or1k-linux-tdep.h
index 4e84e72c269..b510f32d16e 100644
--- a/gdb/or1k-linux-tdep.h
+++ b/gdb/or1k-linux-tdep.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OR1K_LINUX_TDEP_H
-#define OR1K_LINUX_TDEP_H
+#ifndef GDB_OR1K_LINUX_TDEP_H
+#define GDB_OR1K_LINUX_TDEP_H
 
 /* Target descriptions.  */
 extern struct target_desc *tdesc_or1k_linux;
 
-#endif /* OR1K_LINUX_TDEP_H */
+#endif /* GDB_OR1K_LINUX_TDEP_H */
diff --git a/gdb/or1k-tdep.h b/gdb/or1k-tdep.h
index 6107cc4612c..f3072572e57 100644
--- a/gdb/or1k-tdep.h
+++ b/gdb/or1k-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License along
    With this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OR1K_TDEP_H
-#define OR1K_TDEP_H
+#ifndef GDB_OR1K_TDEP_H
+#define GDB_OR1K_TDEP_H
 
 #ifndef TARGET_OR1K
 #define TARGET_OR1K
@@ -60,4 +60,4 @@ extern std::vector<CORE_ADDR> or1k_software_single_step
   (struct regcache *regcache);
 
 
-#endif /* OR1K_TDEP_H */
+#endif /* GDB_OR1K_TDEP_H */
diff --git a/gdb/osabi.h b/gdb/osabi.h
index c1a85d1b9a3..bbcd0d0c23a 100644
--- a/gdb/osabi.h
+++ b/gdb/osabi.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OSABI_H
-#define OSABI_H
+#ifndef GDB_OSABI_H
+#define GDB_OSABI_H
 
 /* * List of known OS ABIs.  If you change this, make sure to update the
    table in osabi.c.  */
@@ -92,4 +92,4 @@ const char *osabi_triplet_regexp (enum gdb_osabi osabi);
 void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *,
 					       enum gdb_osabi *);
 
-#endif /* OSABI_H */
+#endif /* GDB_OSABI_H */
diff --git a/gdb/osdata.h b/gdb/osdata.h
index 09259b6c9ae..9de443ac4de 100644
--- a/gdb/osdata.h
+++ b/gdb/osdata.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OSDATA_H
-#define OSDATA_H
+#ifndef GDB_OSDATA_H
+#define GDB_OSDATA_H
 
 #include <vector>
 
@@ -57,4 +57,4 @@ const std::string *get_osdata_column (const osdata_item &item,
    available types of OS data.  */
 void info_osdata (const char *type);
 
-#endif /* OSDATA_H */
+#endif /* GDB_OSDATA_H */
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index fe12e7cab33..abb981aeaed 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef P_LANG_H
-#define P_LANG_H
+#ifndef GDB_P_LANG_H
+#define GDB_P_LANG_H
 
 /* This file is derived from c-lang.h */
 
@@ -252,4 +252,4 @@ class pascal_language : public language_defn
 				   struct type *type) const;
 };
 
-#endif /* P_LANG_H */
+#endif /* GDB_P_LANG_H */
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 9774a465ee2..eaa3c411141 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (PARSER_DEFS_H)
-#define PARSER_DEFS_H 1
+#ifndef GDB_PARSER_DEFS_H
+#define GDB_PARSER_DEFS_H
 
 #include "expression.h"
 #include "symtab.h"
@@ -389,4 +389,4 @@ extern bool fits_in_type (int n_sign, const gdb_mpz &n, int type_bits,
 
 extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3);
 
-#endif /* PARSER_DEFS_H */
+#endif /* GDB_PARSER_DEFS_H */
diff --git a/gdb/ppc-fbsd-tdep.h b/gdb/ppc-fbsd-tdep.h
index b9c0e6bb351..93ba9045f2f 100644
--- a/gdb/ppc-fbsd-tdep.h
+++ b/gdb/ppc-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_FBSD_TDEP_H
-#define PPC_FBSD_TDEP_H
+#ifndef GDB_PPC_FBSD_TDEP_H
+#define GDB_PPC_FBSD_TDEP_H
 
 struct regset;
 
@@ -26,4 +26,4 @@ struct regset;
 const struct regset *ppc_fbsd_gregset (int);
 const struct regset *ppc_fbsd_fpregset (void);
 
-#endif /* PPC_FBSD_TDEP_H  */
+#endif /* GDB_PPC_FBSD_TDEP_H */
diff --git a/gdb/ppc-linux-tdep.h b/gdb/ppc-linux-tdep.h
index 8a0a59f2b70..a1db503c9f5 100644
--- a/gdb/ppc-linux-tdep.h
+++ b/gdb/ppc-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_LINUX_TDEP_H
-#define PPC_LINUX_TDEP_H
+#ifndef GDB_PPC_LINUX_TDEP_H
+#define GDB_PPC_LINUX_TDEP_H
 
 #include "ppc-tdep.h"
 
@@ -65,4 +65,4 @@ extern const struct regset ppc32_linux_cpprregset;
 extern const struct regset ppc32_linux_cdscrregset;
 extern const struct regset ppc32_linux_ctarregset;
 
-#endif /* PPC_LINUX_TDEP_H */
+#endif /* GDB_PPC_LINUX_TDEP_H */
diff --git a/gdb/ppc-netbsd-tdep.h b/gdb/ppc-netbsd-tdep.h
index 6a92020f5ab..47a8b25782a 100644
--- a/gdb/ppc-netbsd-tdep.h
+++ b/gdb/ppc-netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_NBSD_TDEP_H
-#define PPC_NBSD_TDEP_H
+#ifndef GDB_PPC_NETBSD_TDEP_H
+#define GDB_PPC_NETBSD_TDEP_H
 
 struct regset;
 
@@ -29,4 +29,4 @@ extern struct ppc_reg_offsets ppcnbsd_reg_offsets;
 extern const struct regset ppcnbsd_gregset;
 extern const struct regset ppcnbsd_fpregset;
 
-#endif /* PPC_NBSD_TDEP_H */
+#endif /* GDB_PPC_NETBSD_TDEP_H */
diff --git a/gdb/ppc-obsd-tdep.h b/gdb/ppc-obsd-tdep.h
index 70396abdf84..7f5e7b99850 100644
--- a/gdb/ppc-obsd-tdep.h
+++ b/gdb/ppc-obsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_OBSD_TDEP_H
-#define PPC_OBSD_TDEP_H
+#ifndef GDB_PPC_OBSD_TDEP_H
+#define GDB_PPC_OBSD_TDEP_H
 
 struct regset;
 struct regcache;
@@ -49,4 +49,4 @@ extern void ppcobsd_collect_gregset (const struct regset *regset,
 				     const struct regcache *regcache,
 				     int regnum, void *gregs, size_t len);
 
-#endif /* ppc-obsd-tdep.h */
+#endif /* GDB_PPC_OBSD_TDEP_H */
diff --git a/gdb/ppc-ravenscar-thread.h b/gdb/ppc-ravenscar-thread.h
index 2b0916a916f..c03fbd2ec52 100644
--- a/gdb/ppc-ravenscar-thread.h
+++ b/gdb/ppc-ravenscar-thread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_RAVENSCAR_THREAD_H
-#define PPC_RAVENSCAR_THREAD_H
+#ifndef GDB_PPC_RAVENSCAR_THREAD_H
+#define GDB_PPC_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
@@ -26,4 +26,4 @@ extern void register_ppc_ravenscar_ops (struct gdbarch *gdbarch);
 
 extern void register_e500_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_PPC_RAVENSCAR_THREAD_H */
diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
index db31c7f199a..3176c155fe3 100644
--- a/gdb/ppc-tdep.h
+++ b/gdb/ppc-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_TDEP_H
-#define PPC_TDEP_H
+#ifndef GDB_PPC_TDEP_H
+#define GDB_PPC_TDEP_H
 
 #include "gdbarch.h"
 
@@ -458,4 +458,4 @@ extern const struct target_desc *tdesc_powerpc_vsx32;
 extern const struct target_desc *tdesc_powerpc_altivec64;
 extern const struct target_desc *tdesc_powerpc_altivec32;
 
-#endif /* ppc-tdep.h */
+#endif /* GDB_PPC_TDEP_H */
diff --git a/gdb/ppc64-tdep.h b/gdb/ppc64-tdep.h
index ff0e3fdd033..7bea549dda0 100644
--- a/gdb/ppc64-tdep.h
+++ b/gdb/ppc64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC64_TDEP_H
-#define PPC64_TDEP_H
+#ifndef GDB_PPC64_TDEP_H
+#define GDB_PPC64_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -33,4 +33,4 @@ extern CORE_ADDR ppc64_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
 
 extern void ppc64_elf_make_msymbol_special (asymbol *,
 					    struct minimal_symbol *);
-#endif /* PPC64_TDEP_H  */
+#endif /* GDB_PPC64_TDEP_H */
diff --git a/gdb/probe.h b/gdb/probe.h
index 41e728ad049..00b3f9086b4 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (PROBE_H)
-#define PROBE_H 1
+#ifndef GDB_PROBE_H
+#define GDB_PROBE_H
 
 #include "symtab.h"
 
@@ -309,4 +309,4 @@ extern struct value *probe_safe_evaluate_at_pc (const frame_info_ptr &frame,
 
 bool ignore_probe_p (const char *provider, const char *name,
 		     const char *objfile_name, const char *TYPE);
-#endif /* !defined (PROBE_H) */
+#endif /* GDB_PROBE_H */
diff --git a/gdb/proc-utils.h b/gdb/proc-utils.h
index 8ef7d7ccd34..5f8fe39f78f 100644
--- a/gdb/proc-utils.h
+++ b/gdb/proc-utils.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROC_UTILS_H
-#define PROC_UTILS_H
+#ifndef GDB_PROC_UTILS_H
+#define GDB_PROC_UTILS_H
 
 /* From proc-why.c */
 
@@ -117,4 +117,4 @@ extern  void  procfs_note      (const char *, const char *, int);
    word used to write to the /proc/PID/ctl file.  */
 typedef long procfs_ctl_t;
 
-#endif /* PROC_UTILS_H */
+#endif /* GDB_PROC_UTILS_H */
diff --git a/gdb/process-stratum-target.h b/gdb/process-stratum-target.h
index 9aa9d874ecb..8a0e139cd0c 100644
--- a/gdb/process-stratum-target.h
+++ b/gdb/process-stratum-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROCESS_STRATUM_TARGET_H
-#define PROCESS_STRATUM_TARGET_H
+#ifndef GDB_PROCESS_STRATUM_TARGET_H
+#define GDB_PROCESS_STRATUM_TARGET_H
 
 #include "target.h"
 #include <set>
@@ -173,4 +173,4 @@ extern std::set<process_stratum_target *> all_non_exited_process_targets ();
 
 extern void switch_to_target_no_thread (process_stratum_target *target);
 
-#endif /* !defined (PROCESS_STRATUM_TARGET_H) */
+#endif /* GDB_PROCESS_STRATUM_TARGET_H */
diff --git a/gdb/procfs.h b/gdb/procfs.h
index e0c1dd654ca..0dafb9a88b4 100644
--- a/gdb/procfs.h
+++ b/gdb/procfs.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROCFS_H
-#define PROCFS_H
+#ifndef GDB_PROCFS_H
+#define GDB_PROCFS_H
 
 /* Return a ptid for which we guarantee we will be able to find a
    'live' procinfo.  */
 
 extern ptid_t procfs_first_available (void);
 
-#endif /* PROCFS_H */
+#endif /* GDB_PROCFS_H */
diff --git a/gdb/producer.h b/gdb/producer.h
index 84721bd2665..5cdb7ee3435 100644
--- a/gdb/producer.h
+++ b/gdb/producer.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PRODUCER_H
-#define PRODUCER_H
+#ifndef GDB_PRODUCER_H
+#define GDB_PRODUCER_H
 
 /* Check for GCC >= 4.x according to the symtab->producer string.  Return minor
    version (x) of 4.x in such case.  If it is not GCC or it is GCC older than
@@ -50,4 +50,4 @@ extern bool producer_is_llvm (const char *producer);
    Sets MAJOR and MINOR accordingly, if not NULL.  */
 extern bool producer_is_clang (const char *producer, int *major, int *minor);
 
-#endif
+#endif /* GDB_PRODUCER_H */
diff --git a/gdb/progspace-and-thread.h b/gdb/progspace-and-thread.h
index fa512710a25..52c493bf687 100644
--- a/gdb/progspace-and-thread.h
+++ b/gdb/progspace-and-thread.h
@@ -16,8 +16,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef PROGSPACE_AND_THREAD_H
-#define PROGSPACE_AND_THREAD_H
+#ifndef GDB_PROGSPACE_AND_THREAD_H
+#define GDB_PROGSPACE_AND_THREAD_H
 
 #include "progspace.h"
 #include "gdbthread.h"
@@ -37,4 +37,4 @@ class scoped_restore_current_pspace_and_thread
    current thread, if there's one and it isn't executing.  */
 void switch_to_program_space_and_thread (program_space *pspace);
 
-#endif
+#endif /* GDB_PROGSPACE_AND_THREAD_H */
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 7f5e23df126..74220e5ba4c 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef PROGSPACE_H
-#define PROGSPACE_H
+#ifndef GDB_PROGSPACE_H
+#define GDB_PROGSPACE_H
 
 #include "target.h"
 #include "gdb_bfd.h"
@@ -472,4 +472,4 @@ extern address_space_ref_ptr maybe_new_address_space ();
    mappings.  */
 extern void update_address_spaces (void);
 
-#endif
+#endif /* GDB_PROGSPACE_H */
diff --git a/gdb/prologue-value.h b/gdb/prologue-value.h
index ea784f90dd2..39235d591fc 100644
--- a/gdb/prologue-value.h
+++ b/gdb/prologue-value.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROLOGUE_VALUE_H
-#define PROLOGUE_VALUE_H
+#ifndef GDB_PROLOGUE_VALUE_H
+#define GDB_PROLOGUE_VALUE_H
 
 /* What sort of value is this?  This determines the interpretation
    of subsequent fields.  */
@@ -327,4 +327,4 @@ class pv_area
   struct area_entry *m_entry;
 };
 
-#endif /* PROLOGUE_VALUE_H */
+#endif /* GDB_PROLOGUE_VALUE_H */
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 557a7cf4c08..7833815ef50 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PSYMTAB_H
-#define PSYMTAB_H
+#ifndef GDB_PSYMTAB_H
+#define GDB_PSYMTAB_H
 
 #include "objfiles.h"
 #include <string_view>
@@ -687,4 +687,4 @@ struct psymbol_functions : public quick_symbol_functions
   std::shared_ptr<psymtab_storage> m_partial_symtabs;
 };
 
-#endif /* PSYMTAB_H */
+#endif /* GDB_PSYMTAB_H */
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 388c513e5e9..2819707b2dd 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_EVENT_H
-#define PYTHON_PY_EVENT_H
+#ifndef GDB_PYTHON_PY_EVENT_H
+#define GDB_PYTHON_PY_EVENT_H
 
 #include "py-events.h"
 #include "command.h"
@@ -87,4 +87,4 @@ extern int evpy_add_attribute (PyObject *event,
 int gdbpy_initialize_event_generic (PyTypeObject *type, const char *name)
   CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
 
-#endif /* PYTHON_PY_EVENT_H */
+#endif /* GDB_PYTHON_PY_EVENT_H */
diff --git a/gdb/python/py-events.h b/gdb/python/py-events.h
index e628e0fd63e..b44c4371f24 100644
--- a/gdb/python/py-events.h
+++ b/gdb/python/py-events.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_EVENTS_H
-#define PYTHON_PY_EVENTS_H
+#ifndef GDB_PYTHON_PY_EVENTS_H
+#define GDB_PYTHON_PY_EVENTS_H
 
 #include "command.h"
 #include "python-internal.h"
@@ -54,4 +54,4 @@ extern events_object gdb_py_events;
 extern eventregistry_object *create_eventregistry_object (void);
 extern bool evregpy_no_listeners_p (eventregistry_object *registry);
 
-#endif /* PYTHON_PY_EVENTS_H */
+#endif /* GDB_PYTHON_PY_EVENTS_H */
diff --git a/gdb/python/py-instruction.h b/gdb/python/py-instruction.h
index 85604de5188..efbdda84bae 100644
--- a/gdb/python/py-instruction.h
+++ b/gdb/python/py-instruction.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_INSTRUCTION_H
-#define PYTHON_PY_INSTRUCTION_H
+#ifndef GDB_PYTHON_PY_INSTRUCTION_H
+#define GDB_PYTHON_PY_INSTRUCTION_H
 
 #include "python-internal.h"
 
@@ -32,4 +32,4 @@
 
 extern PyTypeObject *py_insn_get_insn_type ();
 
-#endif /* PYTHON_PY_INSTRUCTION_H */
+#endif /* GDB_PYTHON_PY_INSTRUCTION_H */
diff --git a/gdb/python/py-record-btrace.h b/gdb/python/py-record-btrace.h
index 8678e77322b..0410dd66be8 100644
--- a/gdb/python/py-record-btrace.h
+++ b/gdb/python/py-record-btrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_BTRACE_H
-#define PYTHON_PY_RECORD_BTRACE_H
+#ifndef GDB_PYTHON_PY_RECORD_BTRACE_H
+#define GDB_PYTHON_PY_RECORD_BTRACE_H
 
 #include "python-internal.h"
 
@@ -88,4 +88,4 @@ extern PyObject *recpy_bt_func_prev (PyObject *self, void *closure);
 /* Implementation of RecordFunctionSegment.next [RecordFunctionSegment].  */
 extern PyObject *recpy_bt_func_next (PyObject *self, void *closure);
 
-#endif /* PYTHON_PY_RECORD_BTRACE_H */
+#endif /* GDB_PYTHON_PY_RECORD_BTRACE_H */
diff --git a/gdb/python/py-record-full.h b/gdb/python/py-record-full.h
index 7125e4eba05..df957761602 100644
--- a/gdb/python/py-record-full.h
+++ b/gdb/python/py-record-full.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_FULL_H
-#define PYTHON_PY_RECORD_FULL_H
+#ifndef GDB_PYTHON_PY_RECORD_FULL_H
+#define GDB_PYTHON_PY_RECORD_FULL_H
 
 #include "python-internal.h"
 
@@ -28,4 +28,4 @@ extern PyObject *recpy_full_method (PyObject *self, void *value);
 /* Implementation of record.format [str].  */
 extern PyObject *recpy_full_format (PyObject *self, void *value);
 
-#endif /* PYTHON_PY_RECORD_FULL_H */
+#endif /* GDB_PYTHON_PY_RECORD_FULL_H */
diff --git a/gdb/python/py-record.h b/gdb/python/py-record.h
index 7e1161005b4..0687e78784a 100644
--- a/gdb/python/py-record.h
+++ b/gdb/python/py-record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_H
-#define PYTHON_PY_RECORD_H
+#ifndef GDB_PYTHON_PY_RECORD_H
+#define GDB_PYTHON_PY_RECORD_H
 
 #include "inferior.h"
 #include "python-internal.h"
@@ -71,4 +71,4 @@ extern PyObject *recpy_func_new (thread_info *thread, enum record_method method,
 extern PyObject *recpy_gap_new (int reason_code, const char *reason_string,
 				Py_ssize_t number);
 
-#endif /* PYTHON_PY_RECORD_H */
+#endif /* GDB_PYTHON_PY_RECORD_H */
diff --git a/gdb/python/py-ref.h b/gdb/python/py-ref.h
index 35029e8d673..938068e7803 100644
--- a/gdb/python/py-ref.h
+++ b/gdb/python/py-ref.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_REF_H
-#define PYTHON_PY_REF_H
+#ifndef GDB_PYTHON_PY_REF_H
+#define GDB_PYTHON_PY_REF_H
 
 #include "gdbsupport/gdb_ref_ptr.h"
 
@@ -42,4 +42,4 @@ struct gdbpy_ref_policy
 template<typename T = PyObject> using gdbpy_ref
   = gdb::ref_ptr<T, gdbpy_ref_policy<T>>;
 
-#endif /* PYTHON_PY_REF_H */
+#endif /* GDB_PYTHON_PY_REF_H */
diff --git a/gdb/python/py-stopevent.h b/gdb/python/py-stopevent.h
index 6cae0a729db..450d8c23b4a 100644
--- a/gdb/python/py-stopevent.h
+++ b/gdb/python/py-stopevent.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_STOPEVENT_H
-#define PYTHON_PY_STOPEVENT_H
+#ifndef GDB_PYTHON_PY_STOPEVENT_H
+#define GDB_PYTHON_PY_STOPEVENT_H
 
 #include "py-event.h"
 
@@ -35,4 +35,4 @@ extern gdbpy_ref<> create_breakpoint_event_object (const gdbpy_ref<> &dict,
 extern gdbpy_ref<> create_signal_event_object (const gdbpy_ref<> &dict,
 					       enum gdb_signal stop_signal);
 
-#endif /* PYTHON_PY_STOPEVENT_H */
+#endif /* GDB_PYTHON_PY_STOPEVENT_H */
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 5132ec15ba6..d9863935f0c 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PYTHON_INTERNAL_H
-#define PYTHON_PYTHON_INTERNAL_H
+#ifndef GDB_PYTHON_PYTHON_INTERNAL_H
+#define GDB_PYTHON_PYTHON_INTERNAL_H
 
 #include "extension.h"
 #include "extension-priv.h"
@@ -1035,4 +1035,4 @@ extern std::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch,
 					    CORE_ADDR address,
 					    disassemble_info *info);
 
-#endif /* PYTHON_PYTHON_INTERNAL_H */
+#endif /* GDB_PYTHON_PYTHON_INTERNAL_H */
diff --git a/gdb/python/python.h b/gdb/python/python.h
index e6279482ce0..e8032853e8e 100644
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PYTHON_H
-#define PYTHON_PYTHON_H
+#ifndef GDB_PYTHON_PYTHON_H
+#define GDB_PYTHON_PYTHON_H
 
 #include "extension.h"
 
@@ -34,4 +34,4 @@ extern cmd_list_element *python_cmd_element;
    at other times.  */
 extern struct objfile *gdbpy_current_objfile;
 
-#endif /* PYTHON_PYTHON_H */
+#endif /* GDB_PYTHON_PYTHON_H */
diff --git a/gdb/ravenscar-thread.h b/gdb/ravenscar-thread.h
index 32c31269225..046b3575e7f 100644
--- a/gdb/ravenscar-thread.h
+++ b/gdb/ravenscar-thread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RAVENSCAR_THREAD_H
-#define RAVENSCAR_THREAD_H
+#ifndef GDB_RAVENSCAR_THREAD_H
+#define GDB_RAVENSCAR_THREAD_H
 
 /* Architecture-specific hooks.  */
 
@@ -130,4 +130,4 @@ struct ravenscar_arch_ops
   CORE_ADDR get_stack_base (struct regcache *) const;
 };
 
-#endif /* !defined (RAVENSCAR_THREAD_H) */
+#endif /* GDB_RAVENSCAR_THREAD_H */
diff --git a/gdb/record-btrace.h b/gdb/record-btrace.h
index b6e6c4df030..5ab3208f659 100644
--- a/gdb/record-btrace.h
+++ b/gdb/record-btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_BTRACE_H
-#define RECORD_BTRACE_H
+#ifndef GDB_RECORD_BTRACE_H
+#define GDB_RECORD_BTRACE_H
 
 /* Push the record_btrace target.  */
 extern void record_btrace_push_target (void);
@@ -29,4 +29,4 @@ extern void record_btrace_push_target (void);
    NULL if the cpu was configured as auto.  */
 extern const struct btrace_cpu *record_btrace_get_cpu (void);
 
-#endif /* RECORD_BTRACE_H */
+#endif /* GDB_RECORD_BTRACE_H */
diff --git a/gdb/record-full.h b/gdb/record-full.h
index ef45b1c0d59..dc14d476715 100644
--- a/gdb/record-full.h
+++ b/gdb/record-full.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_FULL_H
-#define RECORD_FULL_H
+#ifndef GDB_RECORD_FULL_H
+#define GDB_RECORD_FULL_H
 
 extern bool record_full_memory_query;
 
@@ -31,4 +31,4 @@ extern int record_full_is_used (void);
 
 extern scoped_restore_tmpl<int> record_full_gdb_operation_disable_set ();
 
-#endif /* RECORD_FULL_H */
+#endif /* GDB_RECORD_FULL_H */
diff --git a/gdb/record.h b/gdb/record.h
index f44b3952943..471e2711b12 100644
--- a/gdb/record.h
+++ b/gdb/record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_H
-#define RECORD_H
+#ifndef GDB_RECORD_H
+#define GDB_RECORD_H
 
 #include "target/waitstatus.h"
 #include "gdbsupport/enum-flags.h"
@@ -114,4 +114,4 @@ extern void record_start (const char *method, const char *format,
 /* Stop recording.  Throw on failure.  */
 extern void record_stop (int from_tty);
 
-#endif /* RECORD_H */
+#endif /* GDB_RECORD_H */
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 9ba6c79ab0d..1e06dc60096 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGCACHE_H
-#define REGCACHE_H
+#ifndef GDB_REGCACHE_H
+#define GDB_REGCACHE_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/common-regcache.h"
@@ -548,4 +548,4 @@ class register_dump
   gdbarch *m_gdbarch;
 };
 
-#endif /* REGCACHE_H */
+#endif /* GDB_REGCACHE_H */
diff --git a/gdb/regformats/regdef.h b/gdb/regformats/regdef.h
index 0ba7a08bb0c..8715229fcdb 100644
--- a/gdb/regformats/regdef.h
+++ b/gdb/regformats/regdef.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGFORMATS_REGDEF_H
-#define REGFORMATS_REGDEF_H
+#ifndef GDB_REGFORMATS_REGDEF_H
+#define GDB_REGFORMATS_REGDEF_H
 
 namespace gdb {
 
@@ -64,4 +64,4 @@ struct reg
 
 } /* namespace gdb */
 
-#endif /* REGFORMATS_REGDEF_H */
+#endif /* GDB_REGFORMATS_REGDEF_H */
diff --git a/gdb/reggroups.h b/gdb/reggroups.h
index 1be1f0ad613..24f81e4675b 100644
--- a/gdb/reggroups.h
+++ b/gdb/reggroups.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGGROUPS_H
-#define REGGROUPS_H
+#ifndef GDB_REGGROUPS_H
+#define GDB_REGGROUPS_H
 
 struct gdbarch;
 
@@ -98,4 +98,4 @@ extern const reggroup *reggroup_find (struct gdbarch *gdbarch,
 extern int default_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 					const struct reggroup *reggroup);
 
-#endif
+#endif /* GDB_REGGROUPS_H */
diff --git a/gdb/registry.h b/gdb/registry.h
index b6b941f56fd..32216545cb0 100644
--- a/gdb/registry.h
+++ b/gdb/registry.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGISTRY_H
-#define REGISTRY_H
+#ifndef GDB_REGISTRY_H
+#define GDB_REGISTRY_H
 
 #include <type_traits>
 
@@ -225,4 +225,4 @@ class registry
   }
 };
 
-#endif /* REGISTRY_H */
+#endif /* GDB_REGISTRY_H */
diff --git a/gdb/regset.h b/gdb/regset.h
index 5fab2e16d9c..44eaf1406bc 100644
--- a/gdb/regset.h
+++ b/gdb/regset.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGSET_H
-#define REGSET_H 1
+#ifndef GDB_REGSET_H
+#define GDB_REGSET_H
 
 struct gdbarch;
 struct regcache;
@@ -52,4 +52,4 @@ struct regset
 #define REGSET_VARIABLE_SIZE 1	/* Accept a larger regset section size
 				   in a core file without warning.  */
 
-#endif /* regset.h */
+#endif /* GDB_REGSET_H */
diff --git a/gdb/remote-fileio.h b/gdb/remote-fileio.h
index 479dc46888e..d406895bc7e 100644
--- a/gdb/remote-fileio.h
+++ b/gdb/remote-fileio.h
@@ -19,8 +19,8 @@
 
 /* See the GDB User Guide for details of the GDB remote protocol.  */
 
-#ifndef REMOTE_FILEIO_H
-#define REMOTE_FILEIO_H
+#ifndef GDB_REMOTE_FILEIO_H
+#define GDB_REMOTE_FILEIO_H
 
 #include "gdbsupport/fileio.h"
 
@@ -44,4 +44,4 @@ extern void initialize_remote_fileio (
 extern void remote_fileio_to_host_stat (struct fio_stat *fst,
 					struct stat *st);
 
-#endif
+#endif /* GDB_REMOTE_FILEIO_H */
diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h
index 4c5b50a0d12..cca26b09f95 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REMOTE_NOTIF_H
-#define REMOTE_NOTIF_H
+#ifndef GDB_REMOTE_NOTIF_H
+#define GDB_REMOTE_NOTIF_H
 
 #include <list>
 #include <memory>
@@ -131,4 +131,4 @@ extern const notif_client notif_client_stop;
 
 extern bool notif_debug;
 
-#endif /* REMOTE_NOTIF_H */
+#endif /* GDB_REMOTE_NOTIF_H */
diff --git a/gdb/remote.h b/gdb/remote.h
index cb0a66da66e..173f3a2a0f2 100644
--- a/gdb/remote.h
+++ b/gdb/remote.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REMOTE_H
-#define REMOTE_H
+#ifndef GDB_REMOTE_H
+#define GDB_REMOTE_H
 
 #include "remote-notif.h"
 
@@ -121,4 +121,4 @@ extern void send_remote_packet (gdb::array_view<const char> &buf,
 
 extern bool is_remote_target (process_stratum_target *target);
 
-#endif
+#endif /* GDB_REMOTE_H */
diff --git a/gdb/riscv-fbsd-tdep.h b/gdb/riscv-fbsd-tdep.h
index c797b231a8e..22ae08d3678 100644
--- a/gdb/riscv-fbsd-tdep.h
+++ b/gdb/riscv-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_FBSD_TDEP_H
-#define RISCV_FBSD_TDEP_H
+#ifndef GDB_RISCV_FBSD_TDEP_H
+#define GDB_RISCV_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -35,4 +35,4 @@
 extern const struct regset riscv_fbsd_gregset;
 extern const struct regset riscv_fbsd_fpregset;
 
-#endif /* RISCV_FBSD_TDEP_H */
+#endif /* GDB_RISCV_FBSD_TDEP_H */
diff --git a/gdb/riscv-ravenscar-thread.h b/gdb/riscv-ravenscar-thread.h
index a586a85583a..87730438017 100644
--- a/gdb/riscv-ravenscar-thread.h
+++ b/gdb/riscv-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_RAVENSCAR_THREAD_H
-#define RISCV_RAVENSCAR_THREAD_H
+#ifndef GDB_RISCV_RAVENSCAR_THREAD_H
+#define GDB_RISCV_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_riscv_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_RISCV_RAVENSCAR_THREAD_H */
diff --git a/gdb/riscv-tdep.h b/gdb/riscv-tdep.h
index 4bdc2e7a3d5..15c2c4cafcb 100644
--- a/gdb/riscv-tdep.h
+++ b/gdb/riscv-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_TDEP_H
-#define RISCV_TDEP_H
+#ifndef GDB_RISCV_TDEP_H
+#define GDB_RISCV_TDEP_H
 
 #include "arch/riscv.h"
 #include "gdbarch.h"
@@ -180,4 +180,4 @@ extern void riscv_supply_regset (const struct regset *regset,
 /* The names of the RISC-V target description features.  */
 extern const char *riscv_feature_name_csr;
 
-#endif /* RISCV_TDEP_H */
+#endif /* GDB_RISCV_TDEP_H */
diff --git a/gdb/rs6000-aix-tdep.h b/gdb/rs6000-aix-tdep.h
index 52cffc31084..5e4f7865ac6 100644
--- a/gdb/rs6000-aix-tdep.h
+++ b/gdb/rs6000-aix-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RS6000_AIX_TDEP_H
-#define RS6000_AIX_TDEP_H
+#ifndef GDB_RS6000_AIX_TDEP_H
+#define GDB_RS6000_AIX_TDEP_H
 
 extern ULONGEST rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch,
 					   const gdb_byte *ldi_buf,
@@ -25,4 +25,4 @@ extern ULONGEST rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch,
 					   ULONGEST len,
 					   int close_ldinfo_fd);
 
-#endif /* RS6000_AIX_TDEP_H */
+#endif /* GDB_RS6000_AIX_TDEP_H */
diff --git a/gdb/rust-exp.h b/gdb/rust-exp.h
index f5c5904cfb4..e0496e1a050 100644
--- a/gdb/rust-exp.h
+++ b/gdb/rust-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RUST_EXP_H
-#define RUST_EXP_H
+#ifndef GDB_RUST_EXP_H
+#define GDB_RUST_EXP_H
 
 #include "expop.h"
 
@@ -226,4 +226,4 @@ class rust_parenthesized_operation
 
 } /* namespace expr */
 
-#endif /* RUST_EXP_H */
+#endif /* GDB_RUST_EXP_H */
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index 9ae5961e9ac..f9c82454817 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RUST_LANG_H
-#define RUST_LANG_H
+#ifndef GDB_RUST_LANG_H
+#define GDB_RUST_LANG_H
 
 #include "demangle.h"
 #include "language.h"
@@ -228,4 +228,4 @@ class rust_language : public language_defn
 		   const struct value_print_options *options) const;
 };
 
-#endif /* RUST_LANG_H */
+#endif /* GDB_RUST_LANG_H */
diff --git a/gdb/s390-linux-tdep.h b/gdb/s390-linux-tdep.h
index 2f9741dca96..b2efb5b1d2f 100644
--- a/gdb/s390-linux-tdep.h
+++ b/gdb/s390-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef S390_LINUX_TDEP_H
-#define S390_LINUX_TDEP_H
+#ifndef GDB_S390_LINUX_TDEP_H
+#define GDB_S390_LINUX_TDEP_H
 
 #define S390_IS_GREGSET_REGNUM(i)					\
   (((i) >= S390_PSWM_REGNUM && (i) <= S390_A15_REGNUM)			\
@@ -64,4 +64,4 @@ extern const struct target_desc *tdesc_s390x_vx_linux64;
 extern const struct target_desc *tdesc_s390x_tevx_linux64;
 extern const struct target_desc *tdesc_s390x_gs_linux64;
 
-#endif /* S390_LINUX_TDEP_H */
+#endif /* GDB_S390_LINUX_TDEP_H */
diff --git a/gdb/s390-tdep.h b/gdb/s390-tdep.h
index 10f775f468f..bfcb8f17c56 100644
--- a/gdb/s390-tdep.h
+++ b/gdb/s390-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef S390_TDEP_H
-#define S390_TDEP_H
+#ifndef GDB_S390_TDEP_H
+#define GDB_S390_TDEP_H
 
 #include "prologue-value.h"
 #include "gdbarch.h"
@@ -322,4 +322,4 @@ extern struct value *s390_trad_frame_prev_register
 extern const struct target_desc *tdesc_s390_linux32;
 extern const struct target_desc *tdesc_s390x_linux64;
 
-#endif /* S390_TDEP_H */
+#endif /* GDB_S390_TDEP_H */
diff --git a/gdb/scoped-mock-context.h b/gdb/scoped-mock-context.h
index 2446e9ad41b..6fd83da4679 100644
--- a/gdb/scoped-mock-context.h
+++ b/gdb/scoped-mock-context.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_MOCK_CONTEXT_H
-#define SCOPED_MOCK_CONTEXT_H
+#ifndef GDB_SCOPED_MOCK_CONTEXT_H
+#define GDB_SCOPED_MOCK_CONTEXT_H
 
 #include "inferior.h"
 #include "gdbthread.h"
@@ -78,4 +78,4 @@ struct scoped_mock_context
 } // namespace selftests
 #endif /* GDB_SELF_TEST */
 
-#endif /* !defined (SCOPED_MOCK_CONTEXT_H) */
+#endif /* GDB_SCOPED_MOCK_CONTEXT_H */
diff --git a/gdb/selftest-arch.h b/gdb/selftest-arch.h
index 84494076bd7..db11723395e 100644
--- a/gdb/selftest-arch.h
+++ b/gdb/selftest-arch.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SELFTEST_ARCH_H
-#define SELFTEST_ARCH_H
+#ifndef GDB_SELFTEST_ARCH_H
+#define GDB_SELFTEST_ARCH_H
 
 typedef void self_test_foreach_arch_function (struct gdbarch *);
 
@@ -31,4 +31,4 @@ extern void
 			      self_test_foreach_arch_function *function);
 }
 
-#endif /* SELFTEST_ARCH_H */
+#endif /* GDB_SELFTEST_ARCH_H */
diff --git a/gdb/sentinel-frame.h b/gdb/sentinel-frame.h
index 1a37ff1f49a..36bee59f0f0 100644
--- a/gdb/sentinel-frame.h
+++ b/gdb/sentinel-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SENTINEL_FRAME_H)
-#define SENTINEL_FRAME_H 1
+#ifndef GDB_SENTINEL_FRAME_H
+#define GDB_SENTINEL_FRAME_H
 
 struct frame_unwind;
 struct regcache;
@@ -36,4 +36,4 @@ extern void *sentinel_frame_cache (struct regcache *regcache);
 
 extern const struct frame_unwind sentinel_frame_unwind;
 
-#endif /* !defined (SENTINEL_FRAME_H)  */
+#endif /* GDB_SENTINEL_FRAME_H */
diff --git a/gdb/ser-base.h b/gdb/ser-base.h
index 37fe0a2e5f5..ecb7c99ea62 100644
--- a/gdb/ser-base.h
+++ b/gdb/ser-base.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_BASE_H
-#define SER_BASE_H
+#ifndef GDB_SER_BASE_H
+#define GDB_SER_BASE_H
 
 #include "serial.h"
 
@@ -50,4 +50,4 @@ extern void ser_base_write (struct serial *scb, const void *buf, size_t count);
 extern void ser_base_async (struct serial *scb, int async_p);
 extern int ser_base_readchar (struct serial *scb, int timeout);
 
-#endif
+#endif /* GDB_SER_BASE_H */
diff --git a/gdb/ser-event.h b/gdb/ser-event.h
index 2c0a59df5df..08fc62b29ab 100644
--- a/gdb/ser-event.h
+++ b/gdb/ser-event.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_EVENT_H
-#define SER_EVENT_H
+#ifndef GDB_SER_EVENT_H
+#define GDB_SER_EVENT_H
 
 /* This is used to be able to signal the event loop (or any other
    select/poll) of events, in a race-free manner.
@@ -48,4 +48,4 @@ extern void serial_event_set (struct serial_event *event);
    call is made.  */
 extern void serial_event_clear (struct serial_event *event);
 
-#endif
+#endif /* GDB_SER_EVENT_H */
diff --git a/gdb/ser-tcp.h b/gdb/ser-tcp.h
index 6ff3662cefd..a1ebcf3c2a8 100644
--- a/gdb/ser-tcp.h
+++ b/gdb/ser-tcp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_TCP_H
-#define SER_TCP_H
+#ifndef GDB_SER_TCP_H
+#define GDB_SER_TCP_H
 
 struct serial;
 
@@ -28,4 +28,4 @@ extern int net_read_prim (struct serial *scb, size_t count);
 extern int net_write_prim (struct serial *scb, const void *buf, size_t count);
 extern void ser_tcp_send_break (struct serial *scb);
 
-#endif
+#endif /* GDB_SER_TCP_H */
diff --git a/gdb/ser-unix.h b/gdb/ser-unix.h
index 253c95b24c0..487921f8d53 100644
--- a/gdb/ser-unix.h
+++ b/gdb/ser-unix.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_UNIX_H
-#define SER_UNIX_H
+#ifndef GDB_SER_UNIX_H
+#define GDB_SER_UNIX_H
 
 extern int ser_unix_read_prim (struct serial *scb, size_t count);
 extern int ser_unix_write_prim (struct serial *scb, const void *buf, 
 				size_t count);
 
-#endif
+#endif /* GDB_SER_UNIX_H */
diff --git a/gdb/serial.h b/gdb/serial.h
index 69507e69295..017b8904c35 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SERIAL_H
-#define SERIAL_H
+#ifndef GDB_SERIAL_H
+#define GDB_SERIAL_H
 
 #ifdef USE_WIN32API
 #include <winsock2.h>
@@ -326,4 +326,4 @@ extern void serial_done_wait_handle (struct serial *);
 
 #endif /* USE_WIN32API */
 
-#endif /* SERIAL_H */
+#endif /* GDB_SERIAL_H */
diff --git a/gdb/sh-tdep.h b/gdb/sh-tdep.h
index 1b1f019920a..dd524406b25 100644
--- a/gdb/sh-tdep.h
+++ b/gdb/sh-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SH_TDEP_H
-#define SH_TDEP_H
+#ifndef GDB_SH_TDEP_H
+#define GDB_SH_TDEP_H
 
 #include "gdbarch.h"
 
@@ -115,4 +115,4 @@ void sh_corefile_supply_regset (const struct regset *regset,
 void sh_corefile_collect_regset (const struct regset *regset,
 				 const struct regcache *regcache,
 				 int regnum, void *regs, size_t len);
-#endif /* SH_TDEP_H */
+#endif /* GDB_SH_TDEP_H */
diff --git a/gdb/sim-regno.h b/gdb/sim-regno.h
index 7f8f9422a02..76ecfeae3d9 100644
--- a/gdb/sim-regno.h
+++ b/gdb/sim-regno.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SIM_REGNO_H
-#define SIM_REGNO_H
+#ifndef GDB_SIM_REGNO_H
+#define GDB_SIM_REGNO_H
 
 /* The gdbarch_register_sim_regno (REGNUM) method, when there is a
    corresponding simulator register, returns that register number as a
@@ -40,4 +40,4 @@ enum sim_regno {
 
 extern int one2one_register_sim_regno (struct gdbarch *gdbarch, int regnum);
 
-#endif
+#endif /* GDB_SIM_REGNO_H */
diff --git a/gdb/skip.h b/gdb/skip.h
index c3e6cbf98ba..5625a7962fc 100644
--- a/gdb/skip.h
+++ b/gdb/skip.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SKIP_H)
-#define SKIP_H
+#ifndef GDB_SKIP_H
+#define GDB_SKIP_H
 
 struct symtab_and_line;
 
@@ -25,4 +25,4 @@ struct symtab_and_line;
 bool function_name_is_marked_for_skip (const char *function_name,
 				       const symtab_and_line &function_sal);
 
-#endif /* !defined (SKIP_H) */
+#endif /* GDB_SKIP_H */
diff --git a/gdb/sol2-tdep.h b/gdb/sol2-tdep.h
index a189666f05e..8e505d30e0e 100644
--- a/gdb/sol2-tdep.h
+++ b/gdb/sol2-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOL2_TDEP_H
-#define SOL2_TDEP_H 1
+#ifndef GDB_SOL2_TDEP_H
+#define GDB_SOL2_TDEP_H
 
 struct gdbarch;
 
@@ -26,4 +26,4 @@ int sol2_sigtramp_p (const frame_info_ptr &this_frame);
 
 void sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
 
-#endif /* sol2-tdep.h */
+#endif /* GDB_SOL2_TDEP_H */
diff --git a/gdb/solib-aix.h b/gdb/solib-aix.h
index 6487460b04c..79cad4dcdee 100644
--- a/gdb/solib-aix.h
+++ b/gdb/solib-aix.h
@@ -15,12 +15,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_AIX_H
-#define SOLIB_AIX_H
+#ifndef GDB_SOLIB_AIX_H
+#define GDB_SOLIB_AIX_H
 
 struct solib_ops;
 extern const solib_ops solib_aix_so_ops;
 
 extern CORE_ADDR solib_aix_get_toc_value (CORE_ADDR pc);
 
-#endif
+#endif /* GDB_SOLIB_AIX_H */
diff --git a/gdb/solib-darwin.h b/gdb/solib-darwin.h
index d6be9eb5b42..d62d6805137 100644
--- a/gdb/solib-darwin.h
+++ b/gdb/solib-darwin.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_DARWIN_H
-#define SOLIB_DARWIN_H
+#ifndef GDB_SOLIB_DARWIN_H
+#define GDB_SOLIB_DARWIN_H
 
 struct solib_ops;
 
 extern const solib_ops darwin_so_ops;
 
-#endif /* solib-darwin.h */
+#endif /* GDB_SOLIB_DARWIN_H */
diff --git a/gdb/solib-dsbt.h b/gdb/solib-dsbt.h
index e1f7d143848..2777939f7f9 100644
--- a/gdb/solib-dsbt.h
+++ b/gdb/solib-dsbt.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_DSBT_H
-#define SOLIB_DSBT_H
+#ifndef GDB_SOLIB_DSBT_H
+#define GDB_SOLIB_DSBT_H
 
 struct solib_ops;
 
 extern const solib_ops dsbt_so_ops;
 
-#endif /* solib-dsbt.h */
+#endif /* GDB_SOLIB_DSBT_H */
diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h
index 579fe6d9843..37cdaff4882 100644
--- a/gdb/solib-svr4.h
+++ b/gdb/solib-svr4.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_SVR4_H
-#define SOLIB_SVR4_H
+#ifndef GDB_SOLIB_SVR4_H
+#define GDB_SOLIB_SVR4_H
 
 #include "solist.h"
 
@@ -112,4 +112,4 @@ extern struct link_map_offsets *svr4_lp64_fetch_link_map_offsets (void);
    SVR4 run time loader.  */
 int svr4_in_dynsym_resolve_code (CORE_ADDR pc);
 
-#endif /* solib-svr4.h */
+#endif /* GDB_SOLIB_SVR4_H */
diff --git a/gdb/solib-target.h b/gdb/solib-target.h
index 70f53c54553..f03e221588e 100644
--- a/gdb/solib-target.h
+++ b/gdb/solib-target.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_TARGET_H
-#define SOLIB_TARGET_H
+#ifndef GDB_SOLIB_TARGET_H
+#define GDB_SOLIB_TARGET_H
 
 struct solib_ops;
 extern const solib_ops solib_target_so_ops;
 
-#endif /* solib-target.h */
+#endif /* GDB_SOLIB_TARGET_H */
diff --git a/gdb/solib.h b/gdb/solib.h
index f7a93c0718f..1d3089634fe 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_H
-#define SOLIB_H
+#ifndef GDB_SOLIB_H
+#define GDB_SOLIB_H
 
 /* Forward decl's for prototypes */
 struct solib;
@@ -143,4 +143,4 @@ extern void set_cbfd_soname_build_id (gdb_bfd_ref_ptr abfd,
 				      const char *soname,
 				      const bfd_build_id *build_id);
 
-#endif /* SOLIB_H */
+#endif /* GDB_SOLIB_H */
diff --git a/gdb/solist.h b/gdb/solist.h
index f0d22080de1..006cdddeed9 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIST_H
-#define SOLIST_H
+#ifndef GDB_SOLIST_H
+#define GDB_SOLIST_H
 
 #define SO_NAME_MAX_PATH_SIZE 512	/* FIXME: Should be dynamic */
 /* For domain_enum domain.  */
@@ -186,4 +186,4 @@ extern gdb_bfd_ref_ptr solib_bfd_fopen (const char *pathname, int fd);
 /* Find solib binary file and open it.  */
 extern gdb_bfd_ref_ptr solib_bfd_open (const char *in_pathname);
 
-#endif
+#endif /* GDB_SOLIST_H */
diff --git a/gdb/source-cache.h b/gdb/source-cache.h
index d4cb7d00ae8..35eeb1cb204 100644
--- a/gdb/source-cache.h
+++ b/gdb/source-cache.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOURCE_CACHE_H
-#define SOURCE_CACHE_H
+#ifndef GDB_SOURCE_CACHE_H
+#define GDB_SOURCE_CACHE_H
 
 #include <unordered_map>
 #include <unordered_set>
@@ -104,4 +104,4 @@ class source_cache
 /* The global source cache.  */
 extern source_cache g_source_cache;
 
-#endif /* SOURCE_CACHE_H */
+#endif /* GDB_SOURCE_CACHE_H */
diff --git a/gdb/source.h b/gdb/source.h
index 144ee48f722..09eb1e38655 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOURCE_H
-#define SOURCE_H
+#ifndef GDB_SOURCE_H
+#define GDB_SOURCE_H
 
 #include "gdbsupport/scoped_fd.h"
 
@@ -216,4 +216,4 @@ extern void forget_cached_source_info (void);
    need to would make things slower than necessary.  */
 extern void select_source_symtab ();
 
-#endif
+#endif /* GDB_SOURCE_H */
diff --git a/gdb/sparc-nat.h b/gdb/sparc-nat.h
index 29d994c2a41..712c9d0ac12 100644
--- a/gdb/sparc-nat.h
+++ b/gdb/sparc-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_NAT_H
-#define SPARC_NAT_H 1
+#ifndef GDB_SPARC_NAT_H
+#define GDB_SPARC_NAT_H
 
 #include "target.h"
 
@@ -82,4 +82,4 @@ struct sparc_target : public BaseTarget
   }
 };
 
-#endif /* sparc-nat.h */
+#endif /* GDB_SPARC_NAT_H */
diff --git a/gdb/sparc-ravenscar-thread.h b/gdb/sparc-ravenscar-thread.h
index d45f6ba8ba5..5f2749f5cd5 100644
--- a/gdb/sparc-ravenscar-thread.h
+++ b/gdb/sparc-ravenscar-thread.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_RAVENSCAR_THREAD_H
-#define SPARC_RAVENSCAR_THREAD_H
+#ifndef GDB_SPARC_RAVENSCAR_THREAD_H
+#define GDB_SPARC_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_sparc_ravenscar_ops (struct gdbarch *gdbarch);
-#endif
+#endif /* GDB_SPARC_RAVENSCAR_THREAD_H */
diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h
index 2d8c50768be..4fd7e6b0f74 100644
--- a/gdb/sparc-tdep.h
+++ b/gdb/sparc-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_TDEP_H
-#define SPARC_TDEP_H 1
+#ifndef GDB_SPARC_TDEP_H
+#define GDB_SPARC_TDEP_H
 
 #include "gdbarch.h"
 
@@ -264,4 +264,4 @@ extern void sparc32nbsd_init_abi (struct gdbarch_info info,
 extern struct trad_frame_saved_reg *
   sparc32nbsd_sigcontext_saved_regs (const frame_info_ptr &next_frame);
 
-#endif /* sparc-tdep.h */
+#endif /* GDB_SPARC_TDEP_H */
diff --git a/gdb/sparc64-tdep.h b/gdb/sparc64-tdep.h
index 6fcd91ee8d3..a19af4a1b5d 100644
--- a/gdb/sparc64-tdep.h
+++ b/gdb/sparc64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC64_TDEP_H
-#define SPARC64_TDEP_H 1
+#ifndef GDB_SPARC64_TDEP_H
+#define GDB_SPARC64_TDEP_H
 
 class frame_info_ptr;
 struct gdbarch;
@@ -137,4 +137,4 @@ extern const struct sparc_fpregmap sparc64_bsd_fpregmap;
 
 extern void sparc64_forget_process (pid_t pid);
 
-#endif /* sparc64-tdep.h */
+#endif /* GDB_SPARC64_TDEP_H */
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index 0a868409470..00c7bd9edfa 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef STABSREAD_H
-#define STABSREAD_H
+#ifndef GDB_STABSREAD_H
+#define GDB_STABSREAD_H
 
 struct objfile;
 struct legacy_psymtab;
@@ -215,4 +215,4 @@ extern void init_header_files (void);
 
 extern void scan_file_globals (struct objfile *objfile);
 
-#endif /* STABSREAD_H */
+#endif /* GDB_STABSREAD_H */
diff --git a/gdb/stack.h b/gdb/stack.h
index e7242c71036..e87ba322dee 100644
--- a/gdb/stack.h
+++ b/gdb/stack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef STACK_H
-#define STACK_H
+#ifndef GDB_STACK_H
+#define GDB_STACK_H
 
 gdb::unique_xmalloc_ptr<char> find_frame_funname (const frame_info_ptr &frame,
 						  enum language *funlang,
@@ -84,4 +84,4 @@ void frame_apply_all_cmd_completer (struct cmd_list_element *ignore,
 				    completion_tracker &tracker,
 				    const char *text, const char */*word*/);
 
-#endif /* #ifndef STACK_H */
+#endif /* GDB_STACK_H */
diff --git a/gdb/stap-probe.h b/gdb/stap-probe.h
index 1401b876ba7..e757d80ef38 100644
--- a/gdb/stap-probe.h
+++ b/gdb/stap-probe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (STAP_PROBE_H)
-#define STAP_PROBE_H 1
+#ifndef GDB_STAP_PROBE_H
+#define GDB_STAP_PROBE_H
 
 #include "parser-defs.h"
 
@@ -66,4 +66,4 @@ struct stap_parse_info
   int inside_paren_p;
 };
 
-#endif /* !defined (STAP_PROBE_H) */
+#endif /* GDB_STAP_PROBE_H */
diff --git a/gdb/symfile-add-flags.h b/gdb/symfile-add-flags.h
index 19dd5e36907..3db532cc86b 100644
--- a/gdb/symfile-add-flags.h
+++ b/gdb/symfile-add-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMFILE_ADD_FLAGS_H)
-#define SYMFILE_ADD_FLAGS_H
+#ifndef GDB_SYMFILE_ADD_FLAGS_H
+#define GDB_SYMFILE_ADD_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -54,4 +54,4 @@ enum symfile_add_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum symfile_add_flag, symfile_add_flags);
 
-#endif /* !defined(SYMFILE_ADD_FLAGS_H) */
+#endif /* GDB_SYMFILE_ADD_FLAGS_H */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 6f8b441b39f..3ed2179ba41 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMFILE_H)
-#define SYMFILE_H
+#ifndef GDB_SYMFILE_H
+#define GDB_SYMFILE_H
 
 /* This file requires that you first include "bfd.h".  */
 #include "symtab.h"
@@ -379,4 +379,4 @@ extern int readnow_symbol_files;
 
 extern int readnever_symbol_files;
 
-#endif /* !defined(SYMFILE_H) */
+#endif /* GDB_SYMFILE_H */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index bf9a3cfb79f..bfc91574415 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMTAB_H)
-#define SYMTAB_H 1
+#ifndef GDB_SYMTAB_H
+#define GDB_SYMTAB_H
 
 #include <array>
 #include <vector>
@@ -2974,4 +2974,4 @@ extern void info_sources_worker (struct ui_out *uiout,
 
 std::optional<CORE_ADDR> find_epilogue_using_linetable (CORE_ADDR func_addr);
 
-#endif /* !defined(SYMTAB_H) */
+#endif /* GDB_SYMTAB_H */
diff --git a/gdb/target-connection.h b/gdb/target-connection.h
index c742932644f..4faae112dc7 100644
--- a/gdb/target-connection.h
+++ b/gdb/target-connection.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_CONNECTION_H
-#define TARGET_CONNECTION_H
+#ifndef GDB_TARGET_CONNECTION_H
+#define GDB_TARGET_CONNECTION_H
 
 #include <string>
 
@@ -37,4 +37,4 @@ void connection_list_remove (process_stratum_target *t);
    it.  */
 std::string make_target_connection_string (process_stratum_target *t);
 
-#endif /* TARGET_CONNECTION_H */
+#endif /* GDB_TARGET_CONNECTION_H */
diff --git a/gdb/target-dcache.h b/gdb/target-dcache.h
index 4acc82f83ce..a199a2382f2 100644
--- a/gdb/target-dcache.h
+++ b/gdb/target-dcache.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DCACHE_H
-#define TARGET_DCACHE_H
+#ifndef GDB_TARGET_DCACHE_H
+#define GDB_TARGET_DCACHE_H
 
 #include "dcache.h"
 #include "progspace.h"
@@ -33,4 +33,4 @@ extern int stack_cache_enabled_p (void);
 
 extern int code_cache_enabled_p (void);
 
-#endif /* TARGET_DCACHE_H */
+#endif /* GDB_TARGET_DCACHE_H */
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index 20ba1f73ac5..cf8d690511f 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DEBUG_H
-#define TARGET_DEBUG_H
+#ifndef GDB_TARGET_DEBUG_H
+#define GDB_TARGET_DEBUG_H
 
 /* Printers for the debug target.  Each prints an object of a given
    type to a string that needn't be freed.  Most printers are macros,
@@ -264,4 +264,4 @@ target_debug_print_x86_xsave_layout (const x86_xsave_layout &layout)
 #undef POFFS
   gdb_puts (" }", gdb_stdlog);
 }
-#endif /* TARGET_DEBUG_H */
+#endif /* GDB_TARGET_DEBUG_H */
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 54c1f234f06..833a367bc9a 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DESCRIPTIONS_H
-#define TARGET_DESCRIPTIONS_H 1
+#ifndef GDB_TARGET_DESCRIPTIONS_H
+#define GDB_TARGET_DESCRIPTIONS_H
 #include "gdbsupport/tdesc.h"
 #include "gdbarch.h"
 
@@ -238,4 +238,4 @@ void record_xml_tdesc (const char *xml_file,
 }
 #endif
 
-#endif /* TARGET_DESCRIPTIONS_H */
+#endif /* GDB_TARGET_DESCRIPTIONS_H */
diff --git a/gdb/target-float.h b/gdb/target-float.h
index a649f5ceb86..0b9cd7a8409 100644
--- a/gdb/target-float.h
+++ b/gdb/target-float.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_FLOAT_H
-#define TARGET_FLOAT_H
+#ifndef GDB_TARGET_FLOAT_H
+#define GDB_TARGET_FLOAT_H
 
 #include "expression.h"
 
@@ -58,4 +58,4 @@ extern void target_float_binop (enum exp_opcode opcode,
 extern int target_float_compare (const gdb_byte *x, const struct type *type_x,
 				 const gdb_byte *y, const struct type *type_y);
 
-#endif /* TARGET_FLOAT_H */
+#endif /* GDB_TARGET_FLOAT_H */
diff --git a/gdb/target.h b/gdb/target.h
index 486a0a687b0..941022a5c4a 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TARGET_H)
-#define TARGET_H
+#ifndef GDB_TARGET_H
+#define GDB_TARGET_H
 
 struct objfile;
 struct ui_file;
@@ -2586,4 +2586,4 @@ extern void target_prepare_to_generate_core (void);
 /* See to_done_generating_core.  */
 extern void target_done_generating_core (void);
 
-#endif /* !defined (TARGET_H) */
+#endif /* GDB_TARGET_H */
diff --git a/gdb/target/resume.h b/gdb/target/resume.h
index 2f13aa9ada1..024e39b5bce 100644
--- a/gdb/target/resume.h
+++ b/gdb/target/resume.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_RESUME_H
-#define TARGET_RESUME_H
+#ifndef GDB_TARGET_RESUME_H
+#define GDB_TARGET_RESUME_H
 
 /* Ways to "resume" a thread.  */
 
@@ -34,4 +34,4 @@ enum resume_kind
   resume_stop
 };
 
-#endif /* TARGET_RESUME_H */
+#endif /* GDB_TARGET_RESUME_H */
diff --git a/gdb/target/target.h b/gdb/target/target.h
index 408db3558b0..87a3464e323 100644
--- a/gdb/target/target.h
+++ b/gdb/target/target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_TARGET_H
-#define TARGET_TARGET_H
+#ifndef GDB_TARGET_TARGET_H
+#define GDB_TARGET_TARGET_H
 
 #include "target/waitstatus.h"
 #include "target/wait.h"
@@ -262,4 +262,4 @@ class target_terminal
   static target_terminal_state m_terminal_state;
 };
 
-#endif /* TARGET_TARGET_H */
+#endif /* GDB_TARGET_TARGET_H */
diff --git a/gdb/target/wait.h b/gdb/target/wait.h
index 304f61497aa..026a42f9a30 100644
--- a/gdb/target/wait.h
+++ b/gdb/target/wait.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_WAIT_H
-#define TARGET_WAIT_H
+#ifndef GDB_TARGET_WAIT_H
+#define GDB_TARGET_WAIT_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -34,4 +34,4 @@ enum target_wait_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum target_wait_flag, target_wait_flags);
 
-#endif /* TARGET_WAIT_H */
+#endif /* GDB_TARGET_WAIT_H */
diff --git a/gdb/target/waitstatus.h b/gdb/target/waitstatus.h
index dce1a7f3175..08907f5a610 100644
--- a/gdb/target/waitstatus.h
+++ b/gdb/target/waitstatus.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_WAITSTATUS_H
-#define TARGET_WAITSTATUS_H
+#ifndef GDB_TARGET_WAITSTATUS_H
+#define GDB_TARGET_WAITSTATUS_H
 
 #include "diagnostics.h"
 #include "gdbsupport/gdb_signals.h"
@@ -470,4 +470,4 @@ enum target_stop_reason
   TARGET_STOPPED_BY_SINGLE_STEP
 };
 
-#endif /* TARGET_WAITSTATUS_H */
+#endif /* GDB_TARGET_WAITSTATUS_H */
diff --git a/gdb/terminal.h b/gdb/terminal.h
index 236ab67745b..154b4be952b 100644
--- a/gdb/terminal.h
+++ b/gdb/terminal.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TERMINAL_H)
-#define TERMINAL_H 1
+#ifndef GDB_TERMINAL_H
+#define GDB_TERMINAL_H
 
 struct inferior;
 
@@ -43,4 +43,4 @@ extern void gdb_save_tty_state (void);
    have had a chance to alter it.  */
 extern void set_initial_gdb_ttystate (void);
 
-#endif /* !defined (TERMINAL_H) */
+#endif /* GDB_TERMINAL_H */
diff --git a/gdb/test-target.h b/gdb/test-target.h
index 54924e06994..b88c154da8f 100644
--- a/gdb/test-target.h
+++ b/gdb/test-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TEST_TARGET_H
-#define TEST_TARGET_H
+#ifndef GDB_TEST_TARGET_H
+#define GDB_TEST_TARGET_H
 
 #include "process-stratum-target.h"
 
@@ -62,4 +62,4 @@ class test_target_ops : public process_stratum_target
 } // namespace selftests
 #endif /* GDB_SELF_TEST */
 
-#endif /* !defined (TEST_TARGET_H) */
+#endif /* GDB_TEST_TARGET_H */
diff --git a/gdb/thread-fsm.h b/gdb/thread-fsm.h
index ed117719c0d..36efee75abc 100644
--- a/gdb/thread-fsm.h
+++ b/gdb/thread-fsm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef THREAD_FSM_H
-#define THREAD_FSM_H
+#ifndef GDB_THREAD_FSM_H
+#define GDB_THREAD_FSM_H
 
 #include "mi/mi-common.h"
 
@@ -129,4 +129,4 @@ struct thread_fsm
   }
 };
 
-#endif /* THREAD_FSM_H */
+#endif /* GDB_THREAD_FSM_H */
diff --git a/gdb/thread-iter.h b/gdb/thread-iter.h
index a2fd9891a57..89537213ac0 100644
--- a/gdb/thread-iter.h
+++ b/gdb/thread-iter.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef THREAD_ITER_H
-#define THREAD_ITER_H
+#ifndef GDB_THREAD_ITER_H
+#define GDB_THREAD_ITER_H
 
 #include "gdbsupport/filtered-iterator.h"
 #include "gdbsupport/iterator-range.h"
@@ -249,4 +249,4 @@ class all_non_exited_threads_range
   ptid_t m_filter_ptid;
 };
 
-#endif /* THREAD_ITER_H */
+#endif /* GDB_THREAD_ITER_H */
diff --git a/gdb/tic6x-tdep.h b/gdb/tic6x-tdep.h
index 886e1b8b309..03a8a3ebb55 100644
--- a/gdb/tic6x-tdep.h
+++ b/gdb/tic6x-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TIC6X_TDEP_H
-#define TIC6X_TDEP_H
+#ifndef GDB_TIC6X_TDEP_H
+#define GDB_TIC6X_TDEP_H
 
 #include "gdbarch.h"
 
@@ -57,4 +57,4 @@ struct tic6x_gdbarch_tdep : gdbarch_tdep_base
   int has_gp = 0; /* Has general purpose registers A16 - A31 and B16 - B31.  */
 };
 
-#endif /* TIC6X_TDEP_H */
+#endif /* GDB_TIC6X_TDEP_H */
diff --git a/gdb/tid-parse.h b/gdb/tid-parse.h
index b7bd920f48a..ad45f216350 100644
--- a/gdb/tid-parse.h
+++ b/gdb/tid-parse.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TID_PARSE_H
-#define TID_PARSE_H
+#ifndef GDB_TID_PARSE_H
+#define GDB_TID_PARSE_H
 
 #include "cli/cli-utils.h"
 
@@ -186,4 +186,4 @@ class tid_range_parser
 extern int tid_is_in_list (const char *list, int default_inferior,
 			   int inf_num, int thr_num);
 
-#endif /* TID_PARSE_H */
+#endif /* GDB_TID_PARSE_H */
diff --git a/gdb/tilegx-tdep.h b/gdb/tilegx-tdep.h
index 893035a6273..5430281bed5 100644
--- a/gdb/tilegx-tdep.h
+++ b/gdb/tilegx-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TILEGX_TDEP_H
-#define TILEGX_TDEP_H
+#ifndef GDB_TILEGX_TDEP_H
+#define GDB_TILEGX_TDEP_H
 
 /* TILE-Gx has 56 general purpose registers (R0 - R52, TP, SP, LR),
    plus 8 special general purpose registers (network and ZERO),
@@ -107,4 +107,4 @@ enum tilegx_regnum
 
 enum { tilegx_reg_size = 8 };
 
-#endif /* tilegx-tdep.h */
+#endif /* GDB_TILEGX_TDEP_H */
diff --git a/gdb/top.h b/gdb/top.h
index 68c637a03d8..c142f1d9363 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TOP_H
-#define TOP_H
+#ifndef GDB_TOP_H
+#define GDB_TOP_H
 
 #include "gdbsupport/event-loop.h"
 #include "gdbsupport/next-iterator.h"
@@ -109,4 +109,4 @@ extern bool check_quiet_mode ();
 
 extern void unbuffer_stream (FILE *stream);
 
-#endif
+#endif /* GDB_TOP_H */
diff --git a/gdb/tracectf.h b/gdb/tracectf.h
index 08a681cb8cf..9f821c5314c 100644
--- a/gdb/tracectf.h
+++ b/gdb/tracectf.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CTF_H
-#define CTF_H
+#ifndef GDB_TRACECTF_H
+#define GDB_TRACECTF_H
 
 extern struct trace_file_writer *ctf_trace_file_writer_new (void);
 
-#endif
+#endif /* GDB_TRACECTF_H */
diff --git a/gdb/tracefile.h b/gdb/tracefile.h
index 90967eff855..028f70dabd3 100644
--- a/gdb/tracefile.h
+++ b/gdb/tracefile.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRACEFILE_H
-#define TRACEFILE_H 1
+#ifndef GDB_TRACEFILE_H
+#define GDB_TRACEFILE_H
 
 #include "tracepoint.h"
 #include "target.h"
@@ -151,4 +151,4 @@ class tracefile_target : public process_stratum_target
 
 extern void tracefile_fetch_registers (struct regcache *regcache, int regno);
 
-#endif /* TRACEFILE_H */
+#endif /* GDB_TRACEFILE_H */
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index 5e6ea67c8d2..1b9e03efc7a 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TRACEPOINT_H)
-#define TRACEPOINT_H 1
+#ifndef GDB_TRACEPOINT_H
+#define GDB_TRACEPOINT_H
 
 #include "breakpoint.h"
 #include "memrange.h"
@@ -432,4 +432,4 @@ extern struct bp_location *get_traceframe_location (int *stepping_frame_p);
 /* Command element for the 'while-stepping' command.  */
 extern cmd_list_element *while_stepping_cmd_element;
 
-#endif	/* TRACEPOINT_H */
+#endif /* GDB_TRACEPOINT_H */
diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h
index ca8792baa17..40a3f74d44a 100644
--- a/gdb/trad-frame.h
+++ b/gdb/trad-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRAD_FRAME_H
-#define TRAD_FRAME_H
+#ifndef GDB_TRAD_FRAME_H
+#define GDB_TRAD_FRAME_H
 
 #include "frame.h"
 
@@ -203,4 +203,4 @@ struct value *trad_frame_get_prev_register (const frame_info_ptr &this_frame,
 					    trad_frame_saved_reg this_saved_regs[],
 					    int regnum);
 
-#endif
+#endif /* GDB_TRAD_FRAME_H */
diff --git a/gdb/tramp-frame.h b/gdb/tramp-frame.h
index d9e54f5981a..a7288c1889c 100644
--- a/gdb/tramp-frame.h
+++ b/gdb/tramp-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRAMP_FRAME_H
-#define TRAMP_FRAME_H
+#ifndef GDB_TRAMP_FRAME_H
+#define GDB_TRAMP_FRAME_H
 
 #include "frame.h"
 #include "frame-unwind.h"	/* For frame_prev_arch_ftype.  */
@@ -85,4 +85,4 @@ struct tramp_frame
 void tramp_frame_prepend_unwinder (struct gdbarch *gdbarch,
 				   const struct tramp_frame *tramp);
 
-#endif
+#endif /* GDB_TRAMP_FRAME_H */
diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h
index 2dc579bce30..0f6553845a2 100644
--- a/gdb/tui/tui-command.h
+++ b/gdb/tui/tui-command.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_COMMAND_H
-#define TUI_TUI_COMMAND_H
+#ifndef GDB_TUI_TUI_COMMAND_H
+#define GDB_TUI_TUI_COMMAND_H
 
 #include "tui/tui-data.h"
 
@@ -58,4 +58,4 @@ struct tui_cmd_window
 /* Refresh the command window.  */
 extern void tui_refresh_cmd_win (void);
 
-#endif /* TUI_TUI_COMMAND_H */
+#endif /* GDB_TUI_TUI_COMMAND_H */
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index ce9c1a8a95a..4ff9fa64aa7 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_DATA_H
-#define TUI_TUI_DATA_H
+#ifndef GDB_TUI_TUI_DATA_H
+#define GDB_TUI_TUI_DATA_H
 
 #include "tui/tui.h"
 #include "gdb_curses.h"
@@ -325,4 +325,4 @@ extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
 
 extern unsigned int tui_tab_width;
 
-#endif /* TUI_TUI_DATA_H */
+#endif /* GDB_TUI_TUI_DATA_H */
diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
index 0aef091069b..a5a240fddf1 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_DISASM_H
-#define TUI_TUI_DISASM_H
+#ifndef GDB_TUI_TUI_DISASM_H
+#define GDB_TUI_TUI_DISASM_H
 
 #include "tui/tui.h"
 #include "tui/tui-data.h"
@@ -66,4 +66,4 @@ struct tui_disasm_window : public tui_source_window_base
 
 extern void tui_get_begin_asm_address (struct gdbarch **, CORE_ADDR *);
 
-#endif /* TUI_TUI_DISASM_H */
+#endif /* GDB_TUI_TUI_DISASM_H */
diff --git a/gdb/tui/tui-file.h b/gdb/tui/tui-file.h
index b723f3974ea..6178a90a6c6 100644
--- a/gdb/tui/tui-file.h
+++ b/gdb/tui/tui-file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_FILE_H
-#define TUI_TUI_FILE_H
+#ifndef GDB_TUI_TUI_FILE_H
+#define GDB_TUI_TUI_FILE_H
 
 #include "ui-file.h"
 
@@ -41,4 +41,4 @@ class tui_file : public stdio_file
   bool m_buffered;
 };
 
-#endif /* TUI_TUI_FILE_H */
+#endif /* GDB_TUI_TUI_FILE_H */
diff --git a/gdb/tui/tui-hooks.h b/gdb/tui/tui-hooks.h
index 97683826544..21ba169713c 100644
--- a/gdb/tui/tui-hooks.h
+++ b/gdb/tui/tui-hooks.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_HOOKS_H
-#define TUI_TUI_HOOKS_H
+#ifndef GDB_TUI_TUI_HOOKS_H
+#define GDB_TUI_TUI_HOOKS_H
 
 extern void tui_install_hooks (void);
 extern void tui_remove_hooks (void);
 
-#endif /* TUI_TUI_HOOKS_H */
+#endif /* GDB_TUI_TUI_HOOKS_H */
diff --git a/gdb/tui/tui-io.h b/gdb/tui/tui-io.h
index 9e7eecdf5f4..66b3b90dfe3 100644
--- a/gdb/tui/tui-io.h
+++ b/gdb/tui/tui-io.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_IO_H
-#define TUI_TUI_IO_H
+#ifndef GDB_TUI_TUI_IO_H
+#define GDB_TUI_TUI_IO_H
 
 #include "gdb_curses.h"
 
@@ -60,4 +60,4 @@ extern cli_ui_out *tui_old_uiout;
    next line.  */
 extern void tui_inject_newline_into_command_window ();
 
-#endif /* TUI_TUI_IO_H */
+#endif /* GDB_TUI_TUI_IO_H */
diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h
index f621f9cea55..d1dc9bfd904 100644
--- a/gdb/tui/tui-layout.h
+++ b/gdb/tui/tui-layout.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_LAYOUT_H
-#define TUI_TUI_LAYOUT_H
+#ifndef GDB_TUI_TUI_LAYOUT_H
+#define GDB_TUI_TUI_LAYOUT_H
 
 #include "ui-file.h"
 
@@ -418,4 +418,4 @@ using known_window_names_range
 
 extern known_window_names_range all_known_window_names ();
 
-#endif /* TUI_TUI_LAYOUT_H */
+#endif /* GDB_TUI_TUI_LAYOUT_H */
diff --git a/gdb/tui/tui-location.h b/gdb/tui/tui-location.h
index db558a4e147..8e83b26996b 100644
--- a/gdb/tui/tui-location.h
+++ b/gdb/tui/tui-location.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_LOCATION_H
-#define TUI_TUI_LOCATION_H
+#ifndef GDB_TUI_TUI_LOCATION_H
+#define GDB_TUI_TUI_LOCATION_H
 
 #include "tui/tui.h"
 #include "tui/tui.h"
@@ -90,4 +90,4 @@ struct tui_location_tracker
 
 extern tui_location_tracker tui_location;
 
-#endif /* TUI_TUI_LOCATION_H */
+#endif /* GDB_TUI_TUI_LOCATION_H */
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 07b951316b6..eea5ca6d061 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_REGS_H
-#define TUI_TUI_REGS_H
+#ifndef GDB_TUI_TUI_REGS_H
+#define GDB_TUI_TUI_REGS_H
 
 #include "tui/tui-data.h"
 #include "reggroups.h"
@@ -145,4 +145,4 @@ struct tui_data_window : public tui_win_info
   gdbarch *m_gdbarch = nullptr;
 };
 
-#endif /* TUI_TUI_REGS_H */
+#endif /* GDB_TUI_TUI_REGS_H */
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 6d4ad4e39c2..4312b928740 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_SOURCE_H
-#define TUI_TUI_SOURCE_H
+#ifndef GDB_TUI_TUI_SOURCE_H
+#define GDB_TUI_TUI_SOURCE_H
 
 #include "tui/tui-data.h"
 #include "tui-winsource.h"
@@ -84,4 +84,4 @@ struct tui_source_window : public tui_source_window_base
   gdb::unique_xmalloc_ptr<char> m_fullname;
 };
 
-#endif /* TUI_TUI_SOURCE_H */
+#endif /* GDB_TUI_TUI_SOURCE_H */
diff --git a/gdb/tui/tui-status.h b/gdb/tui/tui-status.h
index 0af44664104..b4c8a2bd407 100644
--- a/gdb/tui/tui-status.h
+++ b/gdb/tui/tui-status.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_STATUS_H
-#define TUI_TUI_STATUS_H
+#ifndef GDB_TUI_TUI_STATUS_H
+#define GDB_TUI_TUI_STATUS_H
 
 #include "tui/tui-data.h"
 
@@ -53,4 +53,4 @@ struct tui_status_window
 extern void tui_show_status_content (void);
 extern void tui_show_frame_info (const frame_info_ptr &);
 
-#endif /* TUI_TUI_STATUS_H */
+#endif /* GDB_TUI_TUI_STATUS_H */
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 9b03d01c430..15219930149 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WIN_H
-#define TUI_TUI_WIN_H
+#ifndef GDB_TUI_TUI_WIN_H
+#define GDB_TUI_TUI_WIN_H
 
 #include "tui/tui-data.h"
 
@@ -61,4 +61,4 @@ extern bool style_tui_current_position;
 /* Whether to replace the spaces in the left margin with '_' and '0'.  */
 extern bool tui_left_margin_verbose;
 
-#endif /* TUI_TUI_WIN_H */
+#endif /* GDB_TUI_TUI_WIN_H */
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 6bee433689e..c36f32de7e4 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WINGENERAL_H
-#define TUI_TUI_WINGENERAL_H
+#ifndef GDB_TUI_TUI_WINGENERAL_H
+#define GDB_TUI_TUI_WINGENERAL_H
 
 #include "gdb_curses.h"
 
@@ -53,4 +53,4 @@ class tui_suppress_output
    suppressed via tui_suppress_output, do not call wrefresh.  */
 extern void tui_wrefresh (WINDOW *win);
 
-#endif /* TUI_TUI_WINGENERAL_H */
+#endif /* GDB_TUI_TUI_WINGENERAL_H */
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 646597306f2..7effb5694e3 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WINSOURCE_H
-#define TUI_TUI_WINSOURCE_H
+#ifndef GDB_TUI_TUI_WINSOURCE_H
+#define GDB_TUI_TUI_WINSOURCE_H
 
 #include "tui/tui-data.h"
 #include "symtab.h"
@@ -365,4 +365,4 @@ extern std::string tui_copy_source_line (const char **ptr,
 /* Constant definitions. */
 #define SCROLL_THRESHOLD 2	/* Threshold for lazy scroll.  */
 
-#endif /* TUI_TUI_WINSOURCE_H */
+#endif /* GDB_TUI_TUI_WINSOURCE_H */
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index 00295107eac..1bcaa2f4099 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_H
-#define TUI_TUI_H
+#ifndef GDB_TUI_TUI_H
+#define GDB_TUI_TUI_H
 
 /* Flag to control tui debugging.  */
 
@@ -98,4 +98,4 @@ extern void tui_set_key_mode (enum tui_key_mode mode);
 
 extern bool tui_active;
 
-#endif /* TUI_TUI_H */
+#endif /* GDB_TUI_TUI_H */
diff --git a/gdb/type-stack.h b/gdb/type-stack.h
index faef3c85f67..87c0fe20c5a 100644
--- a/gdb/type-stack.h
+++ b/gdb/type-stack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TYPE_STACK_H
-#define TYPE_STACK_H
+#ifndef GDB_TYPE_STACK_H
+#define GDB_TYPE_STACK_H
 
 #include "gdbtypes.h"
 #include <vector>
@@ -203,4 +203,4 @@ struct type_stack
   std::vector<union type_stack_elt> m_elements;
 };
 
-#endif /* TYPE_STACK_H */
+#endif /* GDB_TYPE_STACK_H */
diff --git a/gdb/typeprint.h b/gdb/typeprint.h
index e14d70efa2d..91b64f3e728 100644
--- a/gdb/typeprint.h
+++ b/gdb/typeprint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TYPEPRINT_H
-#define TYPEPRINT_H
+#ifndef GDB_TYPEPRINT_H
+#define GDB_TYPEPRINT_H
 
 #include "gdbsupport/gdb_obstack.h"
 
@@ -181,4 +181,4 @@ extern void val_print_not_allocated (struct ui_file *stream);
 
 extern void val_print_not_associated (struct ui_file *stream);
 
-#endif
+#endif /* GDB_TYPEPRINT_H */
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index 96864409375..627e51ae84c 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_FILE_H
-#define UI_FILE_H
+#ifndef GDB_UI_FILE_H
+#define GDB_UI_FILE_H
 
 #include <string>
 #include "ui-style.h"
@@ -467,4 +467,4 @@ class timestamped_file : public wrapped_file
   bool m_needs_timestamp = true;
 };
 
-#endif
+#endif /* GDB_UI_FILE_H */
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 5b6ddd55063..67f6b18576f 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_OUT_H
-#define UI_OUT_H 1
+#ifndef GDB_UI_OUT_H
+#define GDB_UI_OUT_H
 
 #include <vector>
 
@@ -654,4 +654,4 @@ struct buffered_streams
   std::optional<buffering_file> m_buffered_uiout;
 };
 
-#endif /* UI_OUT_H */
+#endif /* GDB_UI_OUT_H */
diff --git a/gdb/ui-style.h b/gdb/ui-style.h
index 1b7b5fafb9d..53ac2897c78 100644
--- a/gdb/ui-style.h
+++ b/gdb/ui-style.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_STYLE_H
-#define UI_STYLE_H
+#ifndef GDB_UI_STYLE_H
+#define GDB_UI_STYLE_H
 
 /* Styles that can be applied to a ui_file.  */
 struct ui_file_style
@@ -250,4 +250,4 @@ struct ui_file_style
 
 extern bool skip_ansi_escape (const char *buf, int *n_read);
 
-#endif /* UI_STYLE_H */
+#endif /* GDB_UI_STYLE_H */
diff --git a/gdb/ui.h b/gdb/ui.h
index 95cf273473a..ec3a6c5fbae 100644
--- a/gdb/ui.h
+++ b/gdb/ui.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_H
-#define UI_H
+#ifndef GDB_UI_H
+#define GDB_UI_H
 
 #include "gdbsupport/event-loop.h"
 #include "gdbsupport/intrusive_list.h"
@@ -229,4 +229,4 @@ ui_range all_uis ()
   return ui_range (ui_list);
 }
 
-#endif /* UI_H */
+#endif /* GDB_UI_H */
diff --git a/gdb/user-regs.h b/gdb/user-regs.h
index baa3581a0ba..67a28dd429e 100644
--- a/gdb/user-regs.h
+++ b/gdb/user-regs.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef USER_REGS_H
-#define USER_REGS_H
+#ifndef GDB_USER_REGS_H
+#define GDB_USER_REGS_H
 
 /* Implement both builtin, and architecture specific, per-frame user
    visible registers.
@@ -69,4 +69,4 @@ extern void user_reg_add_builtin (const char *name,
 extern void user_reg_add (struct gdbarch *gdbarch, const char *name, 
 			  user_reg_read_ftype *read, const void *baton);
 
-#endif
+#endif /* GDB_USER_REGS_H */
diff --git a/gdb/utils.h b/gdb/utils.h
index 96350890a97..2dc36f42ed1 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UTILS_H
-#define UTILS_H
+#ifndef GDB_UTILS_H
+#define GDB_UTILS_H
 
 #include "exceptions.h"
 #include "gdbsupport/array-view.h"
@@ -475,4 +475,4 @@ struct deferred_warnings final : public warning_hook_handler_type
   std::vector<string_file> m_warnings;
 };
 
-#endif /* UTILS_H */
+#endif /* GDB_UTILS_H */
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 4f194b77008..834e9d97ffd 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VALPRINT_H
-#define VALPRINT_H
+#ifndef GDB_VALPRINT_H
+#define GDB_VALPRINT_H
 
 #include "cli/cli-option.h"
 
@@ -337,4 +337,4 @@ extern void common_val_print_checked
    const struct value_print_options *options,
    const struct language_defn *language);
 
-#endif
+#endif /* GDB_VALPRINT_H */
diff --git a/gdb/value.h b/gdb/value.h
index 9d7e88d9433..8fc9550f11f 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (VALUE_H)
-#define VALUE_H 1
+#ifndef GDB_VALUE_H
+#define GDB_VALUE_H
 
 #include "frame.h"
 #include "extension.h"
@@ -1704,4 +1704,4 @@ void pseudo_to_concat_raw (const frame_info_ptr &next_frame,
 			   int raw_reg_1_num, int raw_reg_2_num,
 			   int raw_reg_3_num);
 
-#endif /* !defined (VALUE_H) */
+#endif /* GDB_VALUE_H */
diff --git a/gdb/varobj-iter.h b/gdb/varobj-iter.h
index 4254f8b549e..46e25e797c8 100644
--- a/gdb/varobj-iter.h
+++ b/gdb/varobj-iter.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAROBJ_ITER_H
-#define VAROBJ_ITER_H
+#ifndef GDB_VAROBJ_ITER_H
+#define GDB_VAROBJ_ITER_H
 
 /* A node or item of varobj, composed of the name and the value.  */
 
@@ -39,4 +39,4 @@ struct varobj_iter
   virtual std::unique_ptr<varobj_item> next () = 0;
 };
 
-#endif /* VAROBJ_ITER_H */
+#endif /* GDB_VAROBJ_ITER_H */
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 426c3b7d628..9d19f53fb3e 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAROBJ_H
-#define VAROBJ_H 1
+#ifndef GDB_VAROBJ_H
+#define GDB_VAROBJ_H
 
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -355,4 +355,4 @@ extern void varobj_restrict_range (const std::vector<varobj *> &children,
 
 extern bool varobj_default_is_path_expr_parent (const struct varobj *var);
 
-#endif /* VAROBJ_H */
+#endif /* GDB_VAROBJ_H */
diff --git a/gdb/vax-tdep.h b/gdb/vax-tdep.h
index 72b072d692d..fbc35d97c4e 100644
--- a/gdb/vax-tdep.h
+++ b/gdb/vax-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAX_TDEP_H
-#define VAX_TDEP_H
+#ifndef GDB_VAX_TDEP_H
+#define GDB_VAX_TDEP_H
 
 /* Register numbers of various important registers.  */
 
@@ -36,4 +36,4 @@ enum vax_regnum
 /* Number of machine registers.  */
 #define VAX_NUM_REGS 17
 
-#endif /* vax-tdep.h */
+#endif /* GDB_VAX_TDEP_H */
diff --git a/gdb/windows-nat.h b/gdb/windows-nat.h
index 3fbb1ea35df..b36e7f45512 100644
--- a/gdb/windows-nat.h
+++ b/gdb/windows-nat.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef WINDOWS_NAT_H
-#define WINDOWS_NAT_H
+#ifndef GDB_WINDOWS_NAT_H
+#define GDB_WINDOWS_NAT_H
 
 /* A pointer to a function that should return non-zero iff REGNUM
    corresponds to one of the segment registers.  */
@@ -36,4 +36,4 @@ int amd64_windows_segment_register_p (int regnum);
 extern const int amd64_mappings[];
 #endif
 
-#endif
+#endif /* GDB_WINDOWS_NAT_H */
diff --git a/gdb/windows-tdep.h b/gdb/windows-tdep.h
index f122f7aaa61..abb25331938 100644
--- a/gdb/windows-tdep.h
+++ b/gdb/windows-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef WINDOWS_TDEP_H
-#define WINDOWS_TDEP_H
+#ifndef GDB_WINDOWS_TDEP_H
+#define GDB_WINDOWS_TDEP_H
 
 #include "frame-unwind.h"
 
@@ -75,4 +75,4 @@ struct cygwin_sigwrapper_frame_unwind : public frame_unwind
   gdb::array_view<const gdb::array_view<const gdb_byte>> patterns_list;
 };
 
-#endif
+#endif /* GDB_WINDOWS_TDEP_H */
diff --git a/gdb/x86-bsd-nat.h b/gdb/x86-bsd-nat.h
index 7b1ba7a1f44..b1745448ece 100644
--- a/gdb/x86-bsd-nat.h
+++ b/gdb/x86-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_BSD_NAT_H
-#define X86_BSD_NAT_H
+#ifndef GDB_X86_BSD_NAT_H
+#define GDB_X86_BSD_NAT_H
 
 #include "x86-nat.h"
 
@@ -43,4 +43,4 @@ class x86bsd_nat_target : public BaseTarget
 };
 #endif /* HAVE_PT_GETDBREGS */
 
-#endif /* x86-bsd-nat.h */
+#endif /* GDB_X86_BSD_NAT_H */
diff --git a/gdb/x86-fbsd-nat.h b/gdb/x86-fbsd-nat.h
index a202e77c788..66f2b2f61b2 100644
--- a/gdb/x86-fbsd-nat.h
+++ b/gdb/x86-fbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_FBSD_NAT_H
-#define X86_FBSD_NAT_H
+#ifndef GDB_X86_FBSD_NAT_H
+#define GDB_X86_FBSD_NAT_H
 
 #include <sys/ptrace.h>
 
@@ -53,4 +53,4 @@ class x86_fbsd_nat_target : public x86bsd_nat_target<fbsd_nat_target>
 #endif
 };
 
-#endif /* x86-bsd-nat.h */
+#endif /* GDB_X86_FBSD_NAT_H */
diff --git a/gdb/x86-linux-nat.h b/gdb/x86-linux-nat.h
index 4efe5461847..3c2241bb0b6 100644
--- a/gdb/x86-linux-nat.h
+++ b/gdb/x86-linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_LINUX_NAT_H
-#define X86_LINUX_NAT_H 1
+#ifndef GDB_X86_LINUX_NAT_H
+#define GDB_X86_LINUX_NAT_H
 
 #include "gdb_proc_service.h"
 #include "linux-nat.h"
@@ -92,4 +92,4 @@ struct x86_linux_nat_target : public x86_nat_target<linux_nat_target>
 extern ps_err_e x86_linux_get_thread_area (pid_t pid, void *addr,
 					   unsigned int *base_addr);
 
-#endif
+#endif /* GDB_X86_LINUX_NAT_H */
diff --git a/gdb/x86-nat.h b/gdb/x86-nat.h
index f07cefa027d..1b8fdd38325 100644
--- a/gdb/x86-nat.h
+++ b/gdb/x86-nat.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_NAT_H
-#define X86_NAT_H 1
+#ifndef GDB_X86_NAT_H
+#define GDB_X86_NAT_H
 
 #include "breakpoint.h"
 #include "nat/x86-dregs.h"
@@ -114,4 +114,4 @@ struct x86_nat_target : public BaseTarget
   { return x86_stopped_by_hw_breakpoint (); }
 };
 
-#endif /* X86_NAT_H */
+#endif /* GDB_X86_NAT_H */
diff --git a/gdb/x86-tdep.h b/gdb/x86-tdep.h
index 7ab47814d41..2b5853adb8a 100644
--- a/gdb/x86-tdep.h
+++ b/gdb/x86-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_TDEP_H
-#define X86_TDEP_H
+#ifndef GDB_X86_TDEP_H
+#define GDB_X86_TDEP_H
 
 /* Checks whether PC lies in an indirect branch thunk using registers
    REGISTER_NAMES[LO] (inclusive) to REGISTER_NAMES[HI] (exclusive).  */
@@ -27,4 +27,4 @@ extern bool x86_in_indirect_branch_thunk (CORE_ADDR pc,
 					  const char * const *register_names,
 					  int lo, int hi);
 
-#endif /* x86-tdep.h */
+#endif /* GDB_X86_TDEP_H */
diff --git a/gdb/xcoffread.h b/gdb/xcoffread.h
index 8bc729e3dff..7528dec4a6c 100644
--- a/gdb/xcoffread.h
+++ b/gdb/xcoffread.h
@@ -16,11 +16,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XCOFFREAD_H
-#define XCOFFREAD_H
+#ifndef GDB_XCOFFREAD_H
+#define GDB_XCOFFREAD_H
 
 extern CORE_ADDR xcoff_get_toc_offset (struct objfile *);
 
 extern int xcoff_get_n_import_files (bfd *abfd);
 
-#endif /* XCOFFREAD_H */
+#endif /* GDB_XCOFFREAD_H */
diff --git a/gdb/xml-builtin.h b/gdb/xml-builtin.h
index 417771ea4e9..463e0fb16e0 100644
--- a/gdb/xml-builtin.h
+++ b/gdb/xml-builtin.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_BUILTIN_H
-#define XML_BUILTIN_H
+#ifndef GDB_XML_BUILTIN_H
+#define GDB_XML_BUILTIN_H
 
 /* The text of compiled-in XML documents, from xml-builtin.c
    (generated).  */
 
 extern const char *const xml_builtin[][2];
 
-#endif /* XML_BUILTIN_H */
+#endif /* GDB_XML_BUILTIN_H */
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index b9bac7a10c2..f2860a20d6b 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef XML_SUPPORT_H
-#define XML_SUPPORT_H
+#ifndef GDB_XML_SUPPORT_H
+#define GDB_XML_SUPPORT_H
 
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/xml-utils.h"
@@ -233,4 +233,4 @@ ULONGEST gdb_xml_parse_ulongest (struct gdb_xml_parser *parser,
 extern std::optional<gdb::char_vector> xml_fetch_content_from_file
     (const char *filename, const char *dirname);
 
-#endif
+#endif /* GDB_XML_SUPPORT_H */
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index 60cfb71ada2..579805d9394 100644
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_SYSCALL_H
-#define XML_SYSCALL_H 1
+#ifndef GDB_XML_SYSCALL_H
+#define GDB_XML_SYSCALL_H
 
 /* Function used to set the name of the file which contains
    information about the system calls present in the current
@@ -66,4 +66,4 @@ bool get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
 
 const char **get_syscall_group_names (struct gdbarch *gdbarch);
 
-#endif /* XML_SYSCALL_H */
+#endif /* GDB_XML_SYSCALL_H */
diff --git a/gdb/xml-tdesc.h b/gdb/xml-tdesc.h
index cd6e79cc24f..ec71c682f86 100644
--- a/gdb/xml-tdesc.h
+++ b/gdb/xml-tdesc.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_TDESC_H
-#define XML_TDESC_H
+#ifndef GDB_XML_TDESC_H
+#define GDB_XML_TDESC_H
 
 #include <optional>
 #include <string>
@@ -49,4 +49,4 @@ std::optional<std::string> target_fetch_description_xml (target_ops *ops);
 
 const struct target_desc *string_read_description_xml (const char *xml);
 
-#endif /* XML_TDESC_H */
+#endif /* GDB_XML_TDESC_H */
diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h
index b76ed137380..832b4fbf33a 100644
--- a/gdb/xtensa-tdep.h
+++ b/gdb/xtensa-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XTENSA_TDEP_H
-#define XTENSA_TDEP_H
+#ifndef GDB_XTENSA_TDEP_H
+#define GDB_XTENSA_TDEP_H
 
 #include "arch/xtensa.h"
 #include "gdbarch.h"
@@ -249,4 +249,4 @@ struct xtensa_gdbarch_tdep : gdbarch_tdep_base
    data structure to their corresponding register in the AR register 
    file (see xtensa-tdep.c).  */
 
-#endif /* XTENSA_TDEP_H */
+#endif /* GDB_XTENSA_TDEP_H */
diff --git a/gdb/yy-remap.h b/gdb/yy-remap.h
index d52a59d11b9..9a6c399b855 100644
--- a/gdb/yy-remap.h
+++ b/gdb/yy-remap.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef YY_REMAP_H
-#define YY_REMAP_H
+#ifndef GDB_YY_REMAP_H
+#define GDB_YY_REMAP_H
 
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
    etc), as well as gratuitiously global symbol names, so we can have
@@ -97,4 +97,4 @@
 # define YYFPRINTF parser_fprintf
 #endif
 
-#endif /* YY_REMAP_H */
+#endif /* GDB_YY_REMAP_H */
diff --git a/gdb/z80-tdep.h b/gdb/z80-tdep.h
index 4b36024d1f0..19a7d046f7a 100644
--- a/gdb/z80-tdep.h
+++ b/gdb/z80-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef Z80_TDEP_H
-#define Z80_TDEP_H
+#ifndef GDB_Z80_TDEP_H
+#define GDB_Z80_TDEP_H
 
 /* Register pair constants
    Order optimized for gdb-stub implementation
@@ -49,4 +49,4 @@ enum z80_regnum
 #define EZ80_NUM_REGS	(Z80_NUM_REGS + 1)
 #define EZ80_REG_BYTES	(EZ80_NUM_REGS*3)
 
-#endif /* z80-tdep.h */
+#endif /* GDB_Z80_TDEP_H */
diff --git a/gdbserver/linux-aarch32-tdesc.h b/gdbserver/linux-aarch32-tdesc.h
index ff1c45fa1c1..173eac24389 100644
--- a/gdbserver/linux-aarch32-tdesc.h
+++ b/gdbserver/linux-aarch32-tdesc.h
@@ -26,4 +26,4 @@ const target_desc * aarch32_linux_read_description ();
 
 bool is_aarch32_linux_description (const target_desc *tdesc);
 
-#endif /* linux-aarch32-tdesc.h.  */
+#endif /* GDBSERVER_LINUX_AARCH32_TDESC_H */
diff --git a/gdbserver/linux-arm-tdesc.h b/gdbserver/linux-arm-tdesc.h
index 76a30c3c73a..bf12c8f5b68 100644
--- a/gdbserver/linux-arm-tdesc.h
+++ b/gdbserver/linux-arm-tdesc.h
@@ -28,4 +28,4 @@ const target_desc * arm_linux_read_description (arm_fp_type fp_type);
 
 arm_fp_type arm_linux_get_tdesc_fp_type (const target_desc *tdesc);
 
-#endif /* linux-arm-tdesc.h.  */
+#endif /* GDBSERVER_LINUX_ARM_TDESC_H */
diff --git a/gdbsupport/agent.h b/gdbsupport/agent.h
index e5a1fed84b9..305ed70fff2 100644
--- a/gdbsupport/agent.h
+++ b/gdbsupport/agent.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_AGENT_H
-#define COMMON_AGENT_H
+#ifndef GDBSUPPORT_AGENT_H
+#define GDBSUPPORT_AGENT_H
 
 #include "gdbsupport/preprocessor.h"
 
@@ -65,4 +65,4 @@ bool agent_capability_check (enum agent_capa);
 
 void agent_capability_invalidate (void);
 
-#endif /* COMMON_AGENT_H */
+#endif /* GDBSUPPORT_AGENT_H */
diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h
index 93842a40ec1..a61e09e882c 100644
--- a/gdbsupport/array-view.h
+++ b/gdbsupport/array-view.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ARRAY_VIEW_H
-#define COMMON_ARRAY_VIEW_H
+#ifndef GDBSUPPORT_ARRAY_VIEW_H
+#define GDBSUPPORT_ARRAY_VIEW_H
 
 #include "traits.h"
 #include <algorithm>
@@ -294,4 +294,4 @@ make_array_view (U *array, size_t size) noexcept
 
 } /* namespace gdb */
 
-#endif
+#endif /* GDBSUPPORT_ARRAY_VIEW_H */
diff --git a/gdbsupport/break-common.h b/gdbsupport/break-common.h
index 95ab3e290ba..1202231be0c 100644
--- a/gdbsupport/break-common.h
+++ b/gdbsupport/break-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BREAK_COMMON_H
-#define COMMON_BREAK_COMMON_H
+#ifndef GDBSUPPORT_BREAK_COMMON_H
+#define GDBSUPPORT_BREAK_COMMON_H
 
 enum target_hw_bp_type
   {
@@ -28,4 +28,4 @@ enum target_hw_bp_type
     hw_execute = 3		/* Execute HW breakpoint */
   };
 
-#endif /* COMMON_BREAK_COMMON_H */
+#endif /* GDBSUPPORT_BREAK_COMMON_H */
diff --git a/gdbsupport/btrace-common.h b/gdbsupport/btrace-common.h
index bf57bc1615e..1888b242f70 100644
--- a/gdbsupport/btrace-common.h
+++ b/gdbsupport/btrace-common.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BTRACE_COMMON_H
-#define COMMON_BTRACE_COMMON_H
+#ifndef GDBSUPPORT_BTRACE_COMMON_H
+#define GDBSUPPORT_BTRACE_COMMON_H
 
 /* Branch tracing (btrace) is a per-thread control-flow execution trace of the
    inferior.  For presentation purposes, the branch trace is represented as a
@@ -276,4 +276,4 @@ extern const char *btrace_format_short_string (enum btrace_format format);
 extern int btrace_data_append (struct btrace_data *dst,
 			       const struct btrace_data *src);
 
-#endif /* COMMON_BTRACE_COMMON_H */
+#endif /* GDBSUPPORT_BTRACE_COMMON_H */
diff --git a/gdbsupport/byte-vector.h b/gdbsupport/byte-vector.h
index 54f4cc2edf2..0586d40016e 100644
--- a/gdbsupport/byte-vector.h
+++ b/gdbsupport/byte-vector.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BYTE_VECTOR_H
-#define COMMON_BYTE_VECTOR_H
+#ifndef GDBSUPPORT_BYTE_VECTOR_H
+#define GDBSUPPORT_BYTE_VECTOR_H
 
 #include "gdbsupport/def-vector.h"
 
@@ -60,4 +60,4 @@ using char_vector = gdb::def_vector<char>;
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEF_VECTOR_H */
+#endif /* GDBSUPPORT_BYTE_VECTOR_H */
diff --git a/gdbsupport/cleanups.h b/gdbsupport/cleanups.h
index 985cf81ff7d..12b7774763c 100644
--- a/gdbsupport/cleanups.h
+++ b/gdbsupport/cleanups.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_CLEANUPS_H
-#define COMMON_CLEANUPS_H
+#ifndef GDBSUPPORT_CLEANUPS_H
+#define GDBSUPPORT_CLEANUPS_H
 
 #include <functional>
 
@@ -27,4 +27,4 @@ extern void add_final_cleanup (std::function<void ()> &&func);
 /* Run all the registered functions.  */
 extern void do_final_cleanups ();
 
-#endif /* COMMON_CLEANUPS_H */
+#endif /* GDBSUPPORT_CLEANUPS_H */
diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h
index b41d6a401cc..6c793dc33d4 100644
--- a/gdbsupport/common-debug.h
+++ b/gdbsupport/common-debug.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_DEBUG_H
-#define COMMON_COMMON_DEBUG_H
+#ifndef GDBSUPPORT_COMMON_DEBUG_H
+#define GDBSUPPORT_COMMON_DEBUG_H
 
 #include <optional>
 #include "gdbsupport/preprocessor.h"
@@ -271,4 +271,4 @@ make_scoped_debug_start_end (PT &&pred, const char *module, const char *func,
 				   __func__, "enter", "exit",	\
 				   nullptr)
 
-#endif /* COMMON_COMMON_DEBUG_H */
+#endif /* GDBSUPPORT_COMMON_DEBUG_H */
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index 6120719480b..07315956514 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_DEFS_H
-#define COMMON_COMMON_DEFS_H
+#ifndef GDBSUPPORT_COMMON_DEFS_H
+#define GDBSUPPORT_COMMON_DEFS_H
 
 #include <gdbsupport/config.h>
 
@@ -217,4 +217,4 @@
 #define HAVE_USEFUL_SBRK 1
 #endif
 
-#endif /* COMMON_COMMON_DEFS_H */
+#endif /* GDBSUPPORT_COMMON_DEFS_H */
diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h
index ffc02d2107f..124c41d1acd 100644
--- a/gdbsupport/common-exceptions.h
+++ b/gdbsupport/common-exceptions.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_EXCEPTIONS_H
-#define COMMON_COMMON_EXCEPTIONS_H
+#ifndef GDBSUPPORT_COMMON_EXCEPTIONS_H
+#define GDBSUPPORT_COMMON_EXCEPTIONS_H
 
 #include <setjmp.h>
 #include <new>
@@ -359,4 +359,4 @@ extern void throw_quit (const char *fmt, ...)
 extern void throw_forced_quit (const char *fmt, ...)
      ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
 
-#endif /* COMMON_COMMON_EXCEPTIONS_H */
+#endif /* GDBSUPPORT_COMMON_EXCEPTIONS_H */
diff --git a/gdbsupport/common-gdbthread.h b/gdbsupport/common-gdbthread.h
index d149f8eed41..289cc8f1b30 100644
--- a/gdbsupport/common-gdbthread.h
+++ b/gdbsupport/common-gdbthread.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_GDBTHREAD_H
-#define COMMON_COMMON_GDBTHREAD_H
+#ifndef GDBSUPPORT_COMMON_GDBTHREAD_H
+#define GDBSUPPORT_COMMON_GDBTHREAD_H
 
 struct process_stratum_target;
 
@@ -25,4 +25,4 @@ struct process_stratum_target;
 extern void switch_to_thread (process_stratum_target *proc_target,
 			      ptid_t ptid);
 
-#endif /* COMMON_COMMON_GDBTHREAD_H */
+#endif /* GDBSUPPORT_COMMON_GDBTHREAD_H */
diff --git a/gdbsupport/common-inferior.h b/gdbsupport/common-inferior.h
index bc6afd65f2b..299c159678b 100644
--- a/gdbsupport/common-inferior.h
+++ b/gdbsupport/common-inferior.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_INFERIOR_H
-#define COMMON_COMMON_INFERIOR_H
+#ifndef GDBSUPPORT_COMMON_INFERIOR_H
+#define GDBSUPPORT_COMMON_INFERIOR_H
 
 #include "gdbsupport/array-view.h"
 
@@ -62,4 +62,4 @@ extern bool startup_with_shell;
 extern std::string
 construct_inferior_arguments (gdb::array_view<char * const>);
 
-#endif /* COMMON_COMMON_INFERIOR_H */
+#endif /* GDBSUPPORT_COMMON_INFERIOR_H */
diff --git a/gdbsupport/common-regcache.h b/gdbsupport/common-regcache.h
index f8704c16939..caf4662e7e5 100644
--- a/gdbsupport/common-regcache.h
+++ b/gdbsupport/common-regcache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_REGCACHE_H
-#define COMMON_COMMON_REGCACHE_H
+#ifndef GDBSUPPORT_COMMON_REGCACHE_H
+#define GDBSUPPORT_COMMON_REGCACHE_H
 
 struct reg_buffer_common;
 
@@ -120,4 +120,4 @@ struct reg_buffer_common
   virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0;
 };
 
-#endif /* COMMON_COMMON_REGCACHE_H */
+#endif /* GDBSUPPORT_COMMON_REGCACHE_H */
diff --git a/gdbsupport/common-types.h b/gdbsupport/common-types.h
index 19d3f49ca0f..10d5f38ae4a 100644
--- a/gdbsupport/common-types.h
+++ b/gdbsupport/common-types.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_TYPES_H
-#define COMMON_COMMON_TYPES_H
+#ifndef GDBSUPPORT_COMMON_TYPES_H
+#define GDBSUPPORT_COMMON_TYPES_H
 
 #include <inttypes.h>
 
@@ -53,4 +53,4 @@ typedef uint64_t ULONGEST;
 
 enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 };
 
-#endif /* COMMON_COMMON_TYPES_H */
+#endif /* GDBSUPPORT_COMMON_TYPES_H */
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 23cd40c0207..42c129b643c 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_UTILS_H
-#define COMMON_COMMON_UTILS_H
+#ifndef GDBSUPPORT_COMMON_UTILS_H
+#define GDBSUPPORT_COMMON_UTILS_H
 
 #include <string>
 #include <vector>
@@ -242,4 +242,4 @@ struct string_view_hash
 
 } /* namespace gdb */
 
-#endif /* COMMON_COMMON_UTILS_H */
+#endif /* GDBSUPPORT_COMMON_UTILS_H */
diff --git a/gdbsupport/def-vector.h b/gdbsupport/def-vector.h
index b9aa663c688..3db6a2fedc9 100644
--- a/gdbsupport/def-vector.h
+++ b/gdbsupport/def-vector.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_DEF_VECTOR_H
-#define COMMON_DEF_VECTOR_H
+#ifndef GDBSUPPORT_DEF_VECTOR_H
+#define GDBSUPPORT_DEF_VECTOR_H
 
 #include <vector>
 #include "gdbsupport/default-init-alloc.h"
@@ -33,4 +33,4 @@ template<typename T> using def_vector
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEF_VECTOR_H */
+#endif /* GDBSUPPORT_DEF_VECTOR_H */
diff --git a/gdbsupport/default-init-alloc.h b/gdbsupport/default-init-alloc.h
index 5ed9715b64c..e84110f128a 100644
--- a/gdbsupport/default-init-alloc.h
+++ b/gdbsupport/default-init-alloc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_DEFAULT_INIT_ALLOC_H
-#define COMMON_DEFAULT_INIT_ALLOC_H
+#ifndef GDBSUPPORT_DEFAULT_INIT_ALLOC_H
+#define GDBSUPPORT_DEFAULT_INIT_ALLOC_H
 
 #if __cplusplus >= 202002L
 #include <memory_resource>
@@ -75,4 +75,4 @@ class default_init_allocator : public A
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEFAULT_INIT_ALLOC_H */
+#endif /* GDBSUPPORT_DEFAULT_INIT_ALLOC_H */
diff --git a/gdbsupport/enum-flags.h b/gdbsupport/enum-flags.h
index 50780043477..b2858b83efe 100644
--- a/gdbsupport/enum-flags.h
+++ b/gdbsupport/enum-flags.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ENUM_FLAGS_H
-#define COMMON_ENUM_FLAGS_H
+#ifndef GDBSUPPORT_ENUM_FLAGS_H
+#define GDBSUPPORT_ENUM_FLAGS_H
 
 #include "traits.h"
 
@@ -493,4 +493,4 @@ enum_flags<E>::to_string (const string_mapping (&mapping)[N]) const
 
 #endif /* __cplusplus */
 
-#endif /* COMMON_ENUM_FLAGS_H */
+#endif /* GDBSUPPORT_ENUM_FLAGS_H */
diff --git a/gdbsupport/environ.h b/gdbsupport/environ.h
index e46050b0350..6ac9f75d94e 100644
--- a/gdbsupport/environ.h
+++ b/gdbsupport/environ.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ENVIRON_H
-#define COMMON_ENVIRON_H
+#ifndef GDBSUPPORT_ENVIRON_H
+#define GDBSUPPORT_ENVIRON_H
 
 #include <vector>
 #include <set>
@@ -100,4 +100,4 @@ class gdb_environ
   std::set<std::string> m_user_unset_env;
 };
 
-#endif /* COMMON_ENVIRON_H */
+#endif /* GDBSUPPORT_ENVIRON_H */
diff --git a/gdbsupport/errors.h b/gdbsupport/errors.h
index d8daed0f5f2..4570221f879 100644
--- a/gdbsupport/errors.h
+++ b/gdbsupport/errors.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ERRORS_H
-#define COMMON_ERRORS_H
+#ifndef GDBSUPPORT_ERRORS_H
+#define GDBSUPPORT_ERRORS_H
 
 /* A problem was detected, but the requested operation can still
    proceed.  A warning message is constructed using a printf- or
@@ -129,4 +129,4 @@ extern void throw_winerror_with_name (const char *string, ULONGEST err)
 
 #endif /* USE_WIN32API */
 
-#endif /* COMMON_ERRORS_H */
+#endif /* GDBSUPPORT_ERRORS_H */
diff --git a/gdbsupport/event-loop.h b/gdbsupport/event-loop.h
index 9155658e8f9..80f471066c8 100644
--- a/gdbsupport/event-loop.h
+++ b/gdbsupport/event-loop.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EVENT_LOOP_H
-#define EVENT_LOOP_H
+#ifndef GDBSUPPORT_EVENT_LOOP_H
+#define GDBSUPPORT_EVENT_LOOP_H
 
 /* An event loop listens for events from multiple event sources.  When
    an event arrives, it is queued and processed by calling the
@@ -145,4 +145,4 @@ extern debug_event_loop_kind debug_event_loop;
     } \
   while (0)
 
-#endif /* EVENT_LOOP_H */
+#endif /* GDBSUPPORT_EVENT_LOOP_H */
diff --git a/gdbsupport/event-pipe.h b/gdbsupport/event-pipe.h
index fb5dd3a8833..7262403e267 100644
--- a/gdbsupport/event-pipe.h
+++ b/gdbsupport/event-pipe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_EVENT_PIPE_H
-#define COMMON_EVENT_PIPE_H
+#ifndef GDBSUPPORT_EVENT_PIPE_H
+#define GDBSUPPORT_EVENT_PIPE_H
 
 /* An event pipe used as a waitable file in the event loop in place of
    some other event associated with a signal.  The handler for the
@@ -57,4 +57,4 @@ class event_pipe
   int m_fds[2] = { -1, -1 };
 };
 
-#endif /* COMMON_EVENT_PIPE_H */
+#endif /* GDBSUPPORT_EVENT_PIPE_H */
diff --git a/gdbsupport/fileio.h b/gdbsupport/fileio.h
index 2e7469d771b..7e4c361d14f 100644
--- a/gdbsupport/fileio.h
+++ b/gdbsupport/fileio.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILEIO_H
-#define COMMON_FILEIO_H
+#ifndef GDBSUPPORT_FILEIO_H
+#define GDBSUPPORT_FILEIO_H
 
 #include <sys/stat.h>
 
@@ -186,4 +186,4 @@ host_to_fileio_time (time_t num, fio_time_t fnum)
 
 extern void host_to_fileio_stat (struct stat *st, struct fio_stat *fst);
 
-#endif /* COMMON_FILEIO_H */
+#endif /* GDBSUPPORT_FILEIO_H */
diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h
index e2ee141d46f..549987bc29c 100644
--- a/gdbsupport/filestuff.h
+++ b/gdbsupport/filestuff.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILESTUFF_H
-#define COMMON_FILESTUFF_H
+#ifndef GDBSUPPORT_FILESTUFF_H
+#define GDBSUPPORT_FILESTUFF_H
 
 #include <dirent.h>
 #include <fcntl.h>
@@ -137,4 +137,4 @@ extern std::optional<std::string> read_text_file_to_string (const char *path);
 
 extern std::string read_remainder_of_file (FILE *file);
 
-#endif /* COMMON_FILESTUFF_H */
+#endif /* GDBSUPPORT_FILESTUFF_H */
diff --git a/gdbsupport/filtered-iterator.h b/gdbsupport/filtered-iterator.h
index 12e5e6cd577..f801f9614da 100644
--- a/gdbsupport/filtered-iterator.h
+++ b/gdbsupport/filtered-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILTERED_ITERATOR_H
-#define COMMON_FILTERED_ITERATOR_H
+#ifndef GDBSUPPORT_FILTERED_ITERATOR_H
+#define GDBSUPPORT_FILTERED_ITERATOR_H
 
 #include <type_traits>
 
@@ -89,4 +89,4 @@ class filtered_iterator
   BaseIterator m_end {};
 };
 
-#endif /* COMMON_FILTERED_ITERATOR_H */
+#endif /* GDBSUPPORT_FILTERED_ITERATOR_H */
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 68504b4475c..b1f0c46d4c2 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FORMAT_H
-#define COMMON_FORMAT_H
+#ifndef GDBSUPPORT_FORMAT_H
+#define GDBSUPPORT_FORMAT_H
 
 #include <string_view>
 
@@ -101,4 +101,4 @@ class format_pieces
   gdb::unique_xmalloc_ptr<char> m_storage;
 };
 
-#endif /* COMMON_FORMAT_H */
+#endif /* GDBSUPPORT_FORMAT_H */
diff --git a/gdbsupport/forward-scope-exit.h b/gdbsupport/forward-scope-exit.h
index 6dd22722595..d4a3fc00cf8 100644
--- a/gdbsupport/forward-scope-exit.h
+++ b/gdbsupport/forward-scope-exit.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FORWARD_SCOPE_EXIT_H
-#define COMMON_FORWARD_SCOPE_EXIT_H
+#ifndef GDBSUPPORT_FORWARD_SCOPE_EXIT_H
+#define GDBSUPPORT_FORWARD_SCOPE_EXIT_H
 
 #include "gdbsupport/scope-exit.h"
 #include <functional>
@@ -120,4 +120,4 @@ class forward_scope_exit<Function, function, Res (Args...)>
 #define FORWARD_SCOPE_EXIT(FUNC) \
   detail::forward_scope_exit<decltype (FUNC), FUNC, decltype (FUNC)>
 
-#endif /* COMMON_FORWARD_SCOPE_EXIT_H */
+#endif /* GDBSUPPORT_FORWARD_SCOPE_EXIT_H */
diff --git a/gdbsupport/function-view.h b/gdbsupport/function-view.h
index 9d852c2a378..f8262068174 100644
--- a/gdbsupport/function-view.h
+++ b/gdbsupport/function-view.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FUNCTION_VIEW_H
-#define COMMON_FUNCTION_VIEW_H
+#ifndef GDBSUPPORT_FUNCTION_VIEW_H
+#define GDBSUPPORT_FUNCTION_VIEW_H
 
 /* function_view is a polymorphic type-erasing wrapper class that
    encapsulates a non-owning reference to arbitrary callable objects.
@@ -448,4 +448,4 @@ auto make_function_view (Callable &&callable)
 
 } /* namespace gdb */
 
-#endif
+#endif /* GDBSUPPORT_FUNCTION_VIEW_H */
diff --git a/gdbsupport/gdb-checked-static-cast.h b/gdbsupport/gdb-checked-static-cast.h
index 97843fab225..e8909b9206f 100644
--- a/gdbsupport/gdb-checked-static-cast.h
+++ b/gdbsupport/gdb-checked-static-cast.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_CHECKED_STATIC_CAST_H
-#define COMMON_GDB_CHECKED_STATIC_CAST_H
+#ifndef GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H
+#define GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H
 
 #include "gdbsupport/traits.h"
 
@@ -80,4 +80,4 @@ checked_static_cast (V &v)
 
 }
 
-#endif /* COMMON_GDB_CHECKED_STATIC_CAST_H */
+#endif /* GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H */
diff --git a/gdbsupport/gdb-dlfcn.h b/gdbsupport/gdb-dlfcn.h
index 24481d94e5c..654db794638 100644
--- a/gdbsupport/gdb-dlfcn.h
+++ b/gdbsupport/gdb-dlfcn.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DLFCN_H
-#define GDB_DLFCN_H
+#ifndef GDBSUPPORT_GDB_DLFCN_H
+#define GDBSUPPORT_GDB_DLFCN_H
 
 /* A deleter that closes an open dynamic library.  */
 
@@ -48,4 +48,4 @@ void *gdb_dlsym (const gdb_dlhandle_up &handle, const char *symbol);
 
 int is_dl_available(void);
 
-#endif /* GDB_DLFCN_H */
+#endif /* GDBSUPPORT_GDB_DLFCN_H */
diff --git a/gdbsupport/gdb-safe-ctype.h b/gdbsupport/gdb-safe-ctype.h
index a91e54a3e65..f8968ef7e7c 100644
--- a/gdbsupport/gdb-safe-ctype.h
+++ b/gdbsupport/gdb-safe-ctype.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_SAFE_CTYPE_H
-#define GDB_SAFE_CTYPE_H
+#ifndef GDBSUPPORT_GDB_SAFE_CTYPE_H
+#define GDBSUPPORT_GDB_SAFE_CTYPE_H
 
 /* After safe-ctype.h is included, we can no longer use the host's
    ctype routines.  Trying to do so results in compile errors.  Code
@@ -46,4 +46,4 @@ gdb_isprint (int ch)
 #include <locale>
 #include "safe-ctype.h"
 
-#endif
+#endif /* GDBSUPPORT_GDB_SAFE_CTYPE_H */
diff --git a/gdbsupport/gdb_assert.h b/gdbsupport/gdb_assert.h
index 2b5e6557424..dd0e1e2286e 100644
--- a/gdbsupport/gdb_assert.h
+++ b/gdbsupport/gdb_assert.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_ASSERT_H
-#define COMMON_GDB_ASSERT_H
+#ifndef GDBSUPPORT_GDB_ASSERT_H
+#define GDBSUPPORT_GDB_ASSERT_H
 
 #include "errors.h"
 
@@ -43,4 +43,4 @@
   internal_error_loc (__FILE__, __LINE__, _("%s: " message), __func__, \
 		      ##__VA_ARGS__)
 
-#endif /* COMMON_GDB_ASSERT_H */
+#endif /* GDBSUPPORT_GDB_ASSERT_H */
diff --git a/gdbsupport/gdb_file.h b/gdbsupport/gdb_file.h
index 645ecb9f75c..41bbbbc51b1 100644
--- a/gdbsupport/gdb_file.h
+++ b/gdbsupport/gdb_file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDBSUPPORT_GDB_FILE
-#define GDBSUPPORT_GDB_FILE
+#ifndef GDBSUPPORT_GDB_FILE_H
+#define GDBSUPPORT_GDB_FILE_H
 
 #include <memory>
 #include <stdio.h>
@@ -34,4 +34,4 @@ struct gdb_file_deleter
 
 typedef std::unique_ptr<FILE, gdb_file_deleter> gdb_file_up;
 
-#endif
+#endif /* GDBSUPPORT_GDB_FILE_H */
diff --git a/gdbsupport/gdb_locale.h b/gdbsupport/gdb_locale.h
index 58524857879..dcdb064a917 100644
--- a/gdbsupport/gdb_locale.h
+++ b/gdbsupport/gdb_locale.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_LOCALE_H
-#define COMMON_GDB_LOCALE_H
+#ifndef GDBSUPPORT_GDB_LOCALE_H
+#define GDBSUPPORT_GDB_LOCALE_H
 
 #ifdef HAVE_LOCALE_H
 # include <locale.h>
@@ -40,4 +40,4 @@
 #include <langinfo.h>
 #endif
 
-#endif /* COMMON_GDB_LOCALE_H */
+#endif /* GDBSUPPORT_GDB_LOCALE_H */
diff --git a/gdbsupport/gdb_obstack.h b/gdbsupport/gdb_obstack.h
index 7b3bb05bc00..d40182441f8 100644
--- a/gdbsupport/gdb_obstack.h
+++ b/gdbsupport/gdb_obstack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDB_OBSTACK_H)
-#define GDB_OBSTACK_H 1
+#ifndef GDBSUPPORT_GDB_OBSTACK_H
+#define GDBSUPPORT_GDB_OBSTACK_H
 
 #include "obstack.h"
 
@@ -157,4 +157,4 @@ struct allocate_on_obstack
   void operator delete[] (void *memory) {}
 };
 
-#endif
+#endif /* GDBSUPPORT_GDB_OBSTACK_H */
diff --git a/gdbsupport/gdb_proc_service.h b/gdbsupport/gdb_proc_service.h
index 52f77a8a5c5..0009702b978 100644
--- a/gdbsupport/gdb_proc_service.h
+++ b/gdbsupport/gdb_proc_service.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_PROC_SERVICE_H
-#define COMMON_GDB_PROC_SERVICE_H
+#ifndef GDBSUPPORT_GDB_PROC_SERVICE_H
+#define GDBSUPPORT_GDB_PROC_SERVICE_H
 
 #include <sys/types.h>
 
@@ -199,4 +199,4 @@ PS_EXPORT (ps_lsetxregs);
 PS_EXPORT (ps_plog);
 #endif
 
-#endif /* COMMON_GDB_PROC_SERVICE_H */
+#endif /* GDBSUPPORT_GDB_PROC_SERVICE_H */
diff --git a/gdbsupport/gdb_ref_ptr.h b/gdbsupport/gdb_ref_ptr.h
index 8a90cb10b05..df2b3d80815 100644
--- a/gdbsupport/gdb_ref_ptr.h
+++ b/gdbsupport/gdb_ref_ptr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_REF_PTR_H
-#define COMMON_GDB_REF_PTR_H
+#ifndef GDBSUPPORT_GDB_REF_PTR_H
+#define GDBSUPPORT_GDB_REF_PTR_H
 
 #include <cstddef>
 
@@ -225,4 +225,4 @@ inline bool operator!= (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
 
 }
 
-#endif /* COMMON_GDB_REF_PTR_H */
+#endif /* GDBSUPPORT_GDB_REF_PTR_H */
diff --git a/gdbsupport/gdb_regex.h b/gdbsupport/gdb_regex.h
index aeb1bb922a9..76264e5a0c9 100644
--- a/gdbsupport/gdb_regex.h
+++ b/gdbsupport/gdb_regex.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_REGEX_H
-#define GDB_REGEX_H 1
+#ifndef GDBSUPPORT_GDB_REGEX_H
+#define GDBSUPPORT_GDB_REGEX_H
 
 # include "xregex.h"
 
@@ -54,4 +54,4 @@ class compiled_regex
   regex_t m_pattern;
 };
 
-#endif /* not GDB_REGEX_H */
+#endif /* GDBSUPPORT_GDB_REGEX_H */
diff --git a/gdbsupport/gdb_select.h b/gdbsupport/gdb_select.h
index 9f7350a904a..b229a25478c 100644
--- a/gdbsupport/gdb_select.h
+++ b/gdbsupport/gdb_select.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(GDB_SELECT_H)
-#define GDB_SELECT_H
+#ifndef GDBSUPPORT_GDB_SELECT_H
+#define GDBSUPPORT_GDB_SELECT_H
 
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
@@ -48,4 +48,4 @@ extern int interruptible_select (int n,
 				 fd_set *exceptfds,
 				 struct timeval *timeout);
 
-#endif /* !defined(GDB_SELECT_H) */
+#endif /* GDBSUPPORT_GDB_SELECT_H */
diff --git a/gdbsupport/gdb_setjmp.h b/gdbsupport/gdb_setjmp.h
index e994226cbea..2482990671d 100644
--- a/gdbsupport/gdb_setjmp.h
+++ b/gdbsupport/gdb_setjmp.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SETJMP_H
-#define COMMON_GDB_SETJMP_H
+#ifndef GDBSUPPORT_GDB_SETJMP_H
+#define GDBSUPPORT_GDB_SETJMP_H
 
 #include <setjmp.h>
 
@@ -33,4 +33,4 @@
 #define SIGLONGJMP(buf,val)	longjmp((buf), (val))
 #endif
 
-#endif /* COMMON_GDB_SETJMP_H */
+#endif /* GDBSUPPORT_GDB_SETJMP_H */
diff --git a/gdbsupport/gdb_signals.h b/gdbsupport/gdb_signals.h
index 7a71f0d8f99..2f9237aea46 100644
--- a/gdbsupport/gdb_signals.h
+++ b/gdbsupport/gdb_signals.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SIGNALS_H
-#define COMMON_GDB_SIGNALS_H
+#ifndef GDBSUPPORT_GDB_SIGNALS_H
+#define GDBSUPPORT_GDB_SIGNALS_H
 
 #include "gdb/signals.h"
 
@@ -55,4 +55,4 @@ extern const char *gdb_signal_to_name (enum gdb_signal);
 /* Given a name (SIGHUP, etc.), return its signal.  */
 enum gdb_signal gdb_signal_from_name (const char *);
 
-#endif /* COMMON_GDB_SIGNALS_H */
+#endif /* GDBSUPPORT_GDB_SIGNALS_H */
diff --git a/gdbsupport/gdb_splay_tree.h b/gdbsupport/gdb_splay_tree.h
index 873ad8e27f3..05be2f1dc4e 100644
--- a/gdbsupport/gdb_splay_tree.h
+++ b/gdbsupport/gdb_splay_tree.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SPLAY_TREE_H
-#define COMMON_GDB_SPLAY_TREE_H
+#ifndef GDBSUPPORT_GDB_SPLAY_TREE_H
+#define GDBSUPPORT_GDB_SPLAY_TREE_H
 
 #include "splay-tree.h"
 
@@ -39,4 +39,4 @@ struct splay_tree_deleter
 typedef std::unique_ptr<splay_tree_s, gdb::splay_tree_deleter>
     gdb_splay_tree_up;
 
-#endif /* COMMON_GDB_SPLAY_TREE_H */
+#endif /* GDBSUPPORT_GDB_SPLAY_TREE_H */
diff --git a/gdbsupport/gdb_sys_time.h b/gdbsupport/gdb_sys_time.h
index 63c93445121..ca93fc8d293 100644
--- a/gdbsupport/gdb_sys_time.h
+++ b/gdbsupport/gdb_sys_time.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SYS_TIME_H
-#define COMMON_GDB_SYS_TIME_H
+#ifndef GDBSUPPORT_GDB_SYS_TIME_H
+#define GDBSUPPORT_GDB_SYS_TIME_H
 
 #include <sys/time.h>
 
@@ -35,4 +35,4 @@
 # undef gettimeofday
 #endif
 
-#endif /* COMMON_GDB_SYS_TIME_H */
+#endif /* GDBSUPPORT_GDB_SYS_TIME_H */
diff --git a/gdbsupport/gdb_tilde_expand.h b/gdbsupport/gdb_tilde_expand.h
index fbd410dd133..12ae9cc73a7 100644
--- a/gdbsupport/gdb_tilde_expand.h
+++ b/gdbsupport/gdb_tilde_expand.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_TILDE_EXPAND_H
-#define COMMON_GDB_TILDE_EXPAND_H
+#ifndef GDBSUPPORT_GDB_TILDE_EXPAND_H
+#define GDBSUPPORT_GDB_TILDE_EXPAND_H
 
 /* Perform tilde expansion on DIR, and return the full path.  */
 extern std::string gdb_tilde_expand (const char *dir);
 
-#endif /* COMMON_GDB_TILDE_EXPAND_H */
+#endif /* GDBSUPPORT_GDB_TILDE_EXPAND_H */
diff --git a/gdbsupport/gdb_unique_ptr.h b/gdbsupport/gdb_unique_ptr.h
index 19b1581dab5..a40e1b133da 100644
--- a/gdbsupport/gdb_unique_ptr.h
+++ b/gdbsupport/gdb_unique_ptr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_UNIQUE_PTR_H
-#define COMMON_GDB_UNIQUE_PTR_H
+#ifndef GDBSUPPORT_GDB_UNIQUE_PTR_H
+#define GDBSUPPORT_GDB_UNIQUE_PTR_H
 
 #include <memory>
 #include <string>
@@ -93,4 +93,4 @@ operator+ (const std::string &lhs, const gdb::unique_xmalloc_ptr<char> &rhs)
   return lhs + rhs.get ();
 }
 
-#endif /* COMMON_GDB_UNIQUE_PTR_H */
+#endif /* GDBSUPPORT_GDB_UNIQUE_PTR_H */
diff --git a/gdbsupport/gdb_unlinker.h b/gdbsupport/gdb_unlinker.h
index 2da65fe45e8..2b9044290fe 100644
--- a/gdbsupport/gdb_unlinker.h
+++ b/gdbsupport/gdb_unlinker.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_UNLINKER_H
-#define COMMON_GDB_UNLINKER_H
+#ifndef GDBSUPPORT_GDB_UNLINKER_H
+#define GDBSUPPORT_GDB_UNLINKER_H
 
 namespace gdb
 {
@@ -57,4 +57,4 @@ class unlinker
 
 }
 
-#endif /* COMMON_GDB_UNLINKER_H */
+#endif /* GDBSUPPORT_GDB_UNLINKER_H */
diff --git a/gdbsupport/gdb_vecs.h b/gdbsupport/gdb_vecs.h
index 47083cead38..22c165c8a55 100644
--- a/gdbsupport/gdb_vecs.h
+++ b/gdbsupport/gdb_vecs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_VECS_H
-#define COMMON_GDB_VECS_H
+#ifndef GDBSUPPORT_GDB_VECS_H
+#define GDBSUPPORT_GDB_VECS_H
 
 /* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
 
@@ -85,4 +85,4 @@ ordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
   return removed;
 }
 
-#endif /* COMMON_GDB_VECS_H */
+#endif /* GDBSUPPORT_GDB_VECS_H */
diff --git a/gdbsupport/gdb_wait.h b/gdbsupport/gdb_wait.h
index c6348dbcb1c..590dcea6a12 100644
--- a/gdbsupport/gdb_wait.h
+++ b/gdbsupport/gdb_wait.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_WAIT_H
-#define COMMON_GDB_WAIT_H
+#ifndef GDBSUPPORT_GDB_WAIT_H
+#define GDBSUPPORT_GDB_WAIT_H
 
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
@@ -128,4 +128,4 @@ extern int windows_status_to_termsig (unsigned long);
 #define __WCLONE	0x80000000 /* Wait for cloned process.  */
 #endif
 
-#endif /* COMMON_GDB_WAIT_H */
+#endif /* GDBSUPPORT_GDB_WAIT_H */
diff --git a/gdbsupport/hash_enum.h b/gdbsupport/hash_enum.h
index 5ef0e15c9ff..5771686dc1d 100644
--- a/gdbsupport/hash_enum.h
+++ b/gdbsupport/hash_enum.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_HASH_ENUM_H
-#define COMMON_HASH_ENUM_H
+#ifndef GDBSUPPORT_HASH_ENUM_H
+#define GDBSUPPORT_HASH_ENUM_H
 
 /* A hasher for enums, which was missing in C++11:
     http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148
@@ -42,4 +42,4 @@ struct hash_enum
 
 } /* namespace gdb */
 
-#endif /* COMMON_HASH_ENUM_H */
+#endif /* GDBSUPPORT_HASH_ENUM_H */
diff --git a/gdbsupport/host-defs.h b/gdbsupport/host-defs.h
index 6e7a08524f9..5298089ba15 100644
--- a/gdbsupport/host-defs.h
+++ b/gdbsupport/host-defs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_HOST_DEFS_H
-#define COMMON_HOST_DEFS_H
+#ifndef GDBSUPPORT_HOST_DEFS_H
+#define GDBSUPPORT_HOST_DEFS_H
 
 #include <limits.h>
 
@@ -58,4 +58,4 @@
 #define SLASH_STRING "/"
 #endif
 
-#endif /* COMMON_HOST_DEFS_H */
+#endif /* GDBSUPPORT_HOST_DEFS_H */
diff --git a/gdbsupport/job-control.h b/gdbsupport/job-control.h
index 977276d95ce..2b99d69d2bb 100644
--- a/gdbsupport/job-control.h
+++ b/gdbsupport/job-control.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_JOB_CONTROL_H
-#define COMMON_JOB_CONTROL_H
+#ifndef GDBSUPPORT_JOB_CONTROL_H
+#define GDBSUPPORT_JOB_CONTROL_H
 
 /* Do we have job control?  Can be assumed to always be the same
    within a given run of GDB.  Use in gdb/inflow.c and
@@ -35,4 +35,4 @@ extern int gdb_setpgid ();
    JOB_CONTROL.  */
 extern void have_job_control ();
 
-#endif /* COMMON_JOB_CONTROL_H */
+#endif /* GDBSUPPORT_JOB_CONTROL_H */
diff --git a/gdbsupport/netstuff.h b/gdbsupport/netstuff.h
index f0df5fe7671..ae8f9bbd9da 100644
--- a/gdbsupport/netstuff.h
+++ b/gdbsupport/netstuff.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_NETSTUFF_H
-#define COMMON_NETSTUFF_H
+#ifndef GDBSUPPORT_NETSTUFF_H
+#define GDBSUPPORT_NETSTUFF_H
 
 #include <string>
 
@@ -73,4 +73,4 @@ extern parsed_connection_spec
 extern parsed_connection_spec parse_connection_spec (const char *spec,
 						     struct addrinfo *hint);
 
-#endif /* COMMON_NETSTUFF_H */
+#endif /* GDBSUPPORT_NETSTUFF_H */
diff --git a/gdbsupport/next-iterator.h b/gdbsupport/next-iterator.h
index 772083482ee..6bacb58752a 100644
--- a/gdbsupport/next-iterator.h
+++ b/gdbsupport/next-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_NEXT_ITERATOR_H
-#define COMMON_NEXT_ITERATOR_H
+#ifndef GDBSUPPORT_NEXT_ITERATOR_H
+#define GDBSUPPORT_NEXT_ITERATOR_H
 
 #include "gdbsupport/iterator-range.h"
 
@@ -77,4 +77,4 @@ struct next_iterator
 template <typename T>
 using next_range = iterator_range<next_iterator<T>>;
 
-#endif /* COMMON_NEXT_ITERATOR_H */
+#endif /* GDBSUPPORT_NEXT_ITERATOR_H */
diff --git a/gdbsupport/observable.h b/gdbsupport/observable.h
index 41e0ba385c9..b386bbcee29 100644
--- a/gdbsupport/observable.h
+++ b/gdbsupport/observable.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_OBSERVABLE_H
-#define COMMON_OBSERVABLE_H
+#ifndef GDBSUPPORT_OBSERVABLE_H
+#define GDBSUPPORT_OBSERVABLE_H
 
 #include <algorithm>
 #include <functional>
@@ -248,4 +248,4 @@ class observable
 
 } /* namespace gdb */
 
-#endif /* COMMON_OBSERVABLE_H */
+#endif /* GDBSUPPORT_OBSERVABLE_H */
diff --git a/gdbsupport/offset-type.h b/gdbsupport/offset-type.h
index 256703cab4d..181e224253e 100644
--- a/gdbsupport/offset-type.h
+++ b/gdbsupport/offset-type.h
@@ -45,8 +45,8 @@
 
    However, unlike pointers, you can't deference offset types.  */
 
-#ifndef COMMON_OFFSET_TYPE_H
-#define COMMON_OFFSET_TYPE_H
+#ifndef GDBSUPPORT_OFFSET_TYPE_H
+#define GDBSUPPORT_OFFSET_TYPE_H
 
 /* Declare TYPE as being an offset type.  This declares the type and
    enables the operators defined below.  */
@@ -130,4 +130,4 @@ operator- (E lhs, E rhs)
   return static_cast<underlying> (lhs) - static_cast<underlying> (rhs);
 }
 
-#endif /* COMMON_OFFSET_TYPE_H */
+#endif /* GDBSUPPORT_OFFSET_TYPE_H */
diff --git a/gdbsupport/packed.h b/gdbsupport/packed.h
index 5c817d4c9cc..37f02d26373 100644
--- a/gdbsupport/packed.h
+++ b/gdbsupport/packed.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PACKED_H
-#define PACKED_H
+#ifndef GDBSUPPORT_PACKED_H
+#define GDBSUPPORT_PACKED_H
 
 #include "traits.h"
 #include <atomic>
@@ -163,4 +163,4 @@ PACKED_ATOMIC_OP (<=)
 
 #undef PACKED_ATOMIC_OP
 
-#endif
+#endif /* GDBSUPPORT_PACKED_H */
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
index 170a2c5e724..fc516505017 100644
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PATHSTUFF_H
-#define COMMON_PATHSTUFF_H
+#ifndef GDBSUPPORT_PATHSTUFF_H
+#define GDBSUPPORT_PATHSTUFF_H
 
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/array-view.h"
@@ -162,4 +162,4 @@ extern gdb::char_vector make_temp_filename (const std::string &f);
 /* String containing the current directory (what getwd would return).  */
 extern char *current_directory;
 
-#endif /* COMMON_PATHSTUFF_H */
+#endif /* GDBSUPPORT_PATHSTUFF_H */
diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h
index 7b4f8e8a178..66f0fcf53b8 100644
--- a/gdbsupport/poison.h
+++ b/gdbsupport/poison.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_POISON_H
-#define COMMON_POISON_H
+#ifndef GDBSUPPORT_POISON_H
+#define GDBSUPPORT_POISON_H
 
 #include "traits.h"
 #include "obstack.h"
@@ -237,4 +237,4 @@ non-POD data type.");
 #undef XOBNEWVEC
 #define XOBNEWVEC(O, T, N) xobnewvec<T> (O, N)
 
-#endif /* COMMON_POISON_H */
+#endif /* GDBSUPPORT_POISON_H */
diff --git a/gdbsupport/preprocessor.h b/gdbsupport/preprocessor.h
index 96b3b94bf35..23177d5d82e 100644
--- a/gdbsupport/preprocessor.h
+++ b/gdbsupport/preprocessor.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PREPROCESSOR_H
-#define COMMON_PREPROCESSOR_H
+#ifndef GDBSUPPORT_PREPROCESSOR_H
+#define GDBSUPPORT_PREPROCESSOR_H
 
 /* Generally useful preprocessor bits.  */
 
@@ -32,4 +32,4 @@
    includes commas to another macro.  */
 #define ESC_PARENS(...) __VA_ARGS__
 
-#endif /* COMMON_PREPROCESSOR_H */
+#endif /* GDBSUPPORT_PREPROCESSOR_H */
diff --git a/gdbsupport/print-utils.h b/gdbsupport/print-utils.h
index 5c5869ec1ae..dcc68045791 100644
--- a/gdbsupport/print-utils.h
+++ b/gdbsupport/print-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PRINT_UTILS_H
-#define COMMON_PRINT_UTILS_H
+#ifndef GDBSUPPORT_PRINT_UTILS_H
+#define GDBSUPPORT_PRINT_UTILS_H
 
 /* How many characters (including the terminating null byte) fit in a
    cell.  */
@@ -82,4 +82,4 @@ extern const char *host_address_to_string_1 (const void *addr);
 
 extern char *get_print_cell (void);
 
-#endif /* COMMON_PRINT_UTILS_H */
+#endif /* GDBSUPPORT_PRINT_UTILS_H */
diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h
index fef9749ee80..f502efe7484 100644
--- a/gdbsupport/ptid.h
+++ b/gdbsupport/ptid.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PTID_H
-#define COMMON_PTID_H
+#ifndef GDBSUPPORT_PTID_H
+#define GDBSUPPORT_PTID_H
 
 /* The ptid struct is a collection of the various "ids" necessary for
    identifying the inferior process/thread being debugged.  This
@@ -182,4 +182,4 @@ extern const ptid_t null_ptid;
 
 extern const ptid_t minus_one_ptid;
 
-#endif /* COMMON_PTID_H */
+#endif /* GDBSUPPORT_PTID_H */
diff --git a/gdbsupport/refcounted-object.h b/gdbsupport/refcounted-object.h
index 9cdf0f10729..42bf71a0309 100644
--- a/gdbsupport/refcounted-object.h
+++ b/gdbsupport/refcounted-object.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_REFCOUNTED_OBJECT_H
-#define COMMON_REFCOUNTED_OBJECT_H
+#ifndef GDBSUPPORT_REFCOUNTED_OBJECT_H
+#define GDBSUPPORT_REFCOUNTED_OBJECT_H
 
 /* Base class of intrusively reference-countable objects.
    Incrementing and decrementing the reference count is an external
@@ -84,4 +84,4 @@ struct refcounted_object_delete_ref_policy
   }
 };
 
-#endif /* COMMON_REFCOUNTED_OBJECT_H */
+#endif /* GDBSUPPORT_REFCOUNTED_OBJECT_H */
diff --git a/gdbsupport/rsp-low.h b/gdbsupport/rsp-low.h
index 801df0ebc0c..e91c79e822f 100644
--- a/gdbsupport/rsp-low.h
+++ b/gdbsupport/rsp-low.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_RSP_LOW_H
-#define COMMON_RSP_LOW_H
+#ifndef GDBSUPPORT_RSP_LOW_H
+#define GDBSUPPORT_RSP_LOW_H
 
 /* Convert number NIB to a hex digit.  */
 
@@ -81,4 +81,4 @@ extern int remote_escape_output (const gdb_byte *buffer, int len_units,
 extern int remote_unescape_input (const gdb_byte *buffer, int len,
 				  gdb_byte *out_buf, int out_maxlen);
 
-#endif /* COMMON_RSP_LOW_H */
+#endif /* GDBSUPPORT_RSP_LOW_H */
diff --git a/gdbsupport/run-time-clock.h b/gdbsupport/run-time-clock.h
index 8176151add9..f4328543945 100644
--- a/gdbsupport/run-time-clock.h
+++ b/gdbsupport/run-time-clock.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_RUN_TIME_CLOCK_H
-#define COMMON_RUN_TIME_CLOCK_H
+#ifndef GDBSUPPORT_RUN_TIME_CLOCK_H
+#define GDBSUPPORT_RUN_TIME_CLOCK_H
 
 #include <chrono>
 
@@ -72,4 +72,4 @@ struct run_time_clock
 		   system_cpu_time_clock::time_point &system) noexcept;
 };
 
-#endif /* COMMON_RUN_TIME_CLOCK_H */
+#endif /* GDBSUPPORT_RUN_TIME_CLOCK_H */
diff --git a/gdbsupport/safe-iterator.h b/gdbsupport/safe-iterator.h
index f69f3896758..f31f92f6c24 100644
--- a/gdbsupport/safe-iterator.h
+++ b/gdbsupport/safe-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SAFE_ITERATOR_H
-#define COMMON_SAFE_ITERATOR_H
+#ifndef GDBSUPPORT_SAFE_ITERATOR_H
+#define GDBSUPPORT_SAFE_ITERATOR_H
 
 #include <type_traits>
 
@@ -136,4 +136,4 @@ class basic_safe_range
   Range m_range;
 };
 
-#endif /* COMMON_SAFE_ITERATOR_H */
+#endif /* GDBSUPPORT_SAFE_ITERATOR_H */
diff --git a/gdbsupport/scope-exit.h b/gdbsupport/scope-exit.h
index 86b2969f817..c3d27d7c77a 100644
--- a/gdbsupport/scope-exit.h
+++ b/gdbsupport/scope-exit.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPE_EXIT_H
-#define COMMON_SCOPE_EXIT_H
+#ifndef GDBSUPPORT_SCOPE_EXIT_H
+#define GDBSUPPORT_SCOPE_EXIT_H
 
 #include <functional>
 #include <type_traits>
@@ -165,4 +165,4 @@ operator+ (scope_exit_lhs, EF &&rhs)
 #define SCOPE_EXIT \
   auto CONCAT(scope_exit_, __LINE__) = ::detail::scope_exit_lhs () + [&] ()
 
-#endif /* COMMON_SCOPE_EXIT_H */
+#endif /* GDBSUPPORT_SCOPE_EXIT_H */
diff --git a/gdbsupport/scoped_fd.h b/gdbsupport/scoped_fd.h
index aa214b2c1c1..240685a927b 100644
--- a/gdbsupport/scoped_fd.h
+++ b/gdbsupport/scoped_fd.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_FD_H
-#define COMMON_SCOPED_FD_H
+#ifndef GDBSUPPORT_SCOPED_FD_H
+#define GDBSUPPORT_SCOPED_FD_H
 
 #include <unistd.h>
 #include "gdb_file.h"
@@ -84,4 +84,4 @@ class scoped_fd
   int m_fd;
 };
 
-#endif /* COMMON_SCOPED_FD_H */
+#endif /* GDBSUPPORT_SCOPED_FD_H */
diff --git a/gdbsupport/scoped_ignore_signal.h b/gdbsupport/scoped_ignore_signal.h
index 74fc69057a8..2fecd58466d 100644
--- a/gdbsupport/scoped_ignore_signal.h
+++ b/gdbsupport/scoped_ignore_signal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_IGNORE_SIGNAL_H
-#define SCOPED_IGNORE_SIGNAL_H
+#ifndef GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H
+#define GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H
 
 #include <signal.h>
 
@@ -118,4 +118,4 @@ using scoped_ignore_sigpipe = scoped_ignore_signal<SIGPIPE, true>;
 using scoped_ignore_sigpipe = scoped_ignore_signal_nop;
 #endif
 
-#endif /* SCOPED_IGNORE_SIGNAL_H */
+#endif /* GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H */
diff --git a/gdbsupport/scoped_ignore_sigttou.h b/gdbsupport/scoped_ignore_sigttou.h
index de2e40a6492..bb4e86d5b21 100644
--- a/gdbsupport/scoped_ignore_sigttou.h
+++ b/gdbsupport/scoped_ignore_sigttou.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_IGNORE_SIGTTOU_H
-#define SCOPED_IGNORE_SIGTTOU_H
+#ifndef GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H
+#define GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H
 
 #include "gdbsupport/scoped_ignore_signal.h"
 #include "gdbsupport/job-control.h"
@@ -84,4 +84,4 @@ using scoped_ignore_sigttou = scoped_ignore_signal_nop;
 
 #endif
 
-#endif /* SCOPED_IGNORE_SIGTTOU_H */
+#endif /* GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H */
diff --git a/gdbsupport/scoped_mmap.h b/gdbsupport/scoped_mmap.h
index 8383b8933b5..ea2f4fd3af5 100644
--- a/gdbsupport/scoped_mmap.h
+++ b/gdbsupport/scoped_mmap.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_MMAP_H
-#define COMMON_SCOPED_MMAP_H
+#ifndef GDBSUPPORT_SCOPED_MMAP_H
+#define GDBSUPPORT_SCOPED_MMAP_H
 
 #ifdef HAVE_SYS_MMAN_H
 
@@ -88,4 +88,4 @@ scoped_mmap mmap_file (const char *filename);
 
 #endif /* HAVE_SYS_MMAN_H */
 
-#endif /* COMMON_SCOPED_MMAP_H */
+#endif /* GDBSUPPORT_SCOPED_MMAP_H */
diff --git a/gdbsupport/scoped_restore.h b/gdbsupport/scoped_restore.h
index 96fe5256f80..5833b928fe3 100644
--- a/gdbsupport/scoped_restore.h
+++ b/gdbsupport/scoped_restore.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_RESTORE_H
-#define COMMON_SCOPED_RESTORE_H
+#ifndef GDBSUPPORT_SCOPED_RESTORE_H
+#define GDBSUPPORT_SCOPED_RESTORE_H
 
 /* Base class for scoped_restore_tmpl.  */
 class scoped_restore_base
@@ -115,4 +115,4 @@ scoped_restore_tmpl<T> make_scoped_restore (T *var, T2 value)
   return scoped_restore_tmpl<T> (var, value);
 }
 
-#endif /* COMMON_SCOPED_RESTORE_H */
+#endif /* GDBSUPPORT_SCOPED_RESTORE_H */
diff --git a/gdbsupport/search.h b/gdbsupport/search.h
index 42a9fd23083..f8c003bf6df 100644
--- a/gdbsupport/search.h
+++ b/gdbsupport/search.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SEARCH_H
-#define COMMON_SEARCH_H
+#ifndef GDBSUPPORT_SEARCH_H
+#define GDBSUPPORT_SEARCH_H
 
 #include "gdbsupport/function-view.h"
 
@@ -39,4 +39,4 @@ extern int simple_search_memory
    ULONGEST pattern_len,
    CORE_ADDR *found_addrp);
 
-#endif /* COMMON_SEARCH_H */
+#endif /* GDBSUPPORT_SEARCH_H */
diff --git a/gdbsupport/selftest.h b/gdbsupport/selftest.h
index 41d1210a5a5..cbbdd01093d 100644
--- a/gdbsupport/selftest.h
+++ b/gdbsupport/selftest.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SELFTEST_H
-#define COMMON_SELFTEST_H
+#ifndef GDBSUPPORT_SELFTEST_H
+#define GDBSUPPORT_SELFTEST_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/function-view.h"
@@ -93,4 +93,4 @@ extern void reset ();
       error (_("self-test failed at %s:%d"), __FILE__, __LINE__);	\
   } while (0)
 
-#endif /* COMMON_SELFTEST_H */
+#endif /* GDBSUPPORT_SELFTEST_H */
diff --git a/gdbsupport/signals-state-save-restore.h b/gdbsupport/signals-state-save-restore.h
index 132aaa8c522..e01ac36fe99 100644
--- a/gdbsupport/signals-state-save-restore.h
+++ b/gdbsupport/signals-state-save-restore.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SIGNALS_STATE_SAVE_RESTORE_H
-#define COMMON_SIGNALS_STATE_SAVE_RESTORE_H
+#ifndef GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H
+#define GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H
 
 /* Save/restore the signal actions of all signals, and the signal
    mask.
@@ -37,4 +37,4 @@ extern void save_original_signals_state (bool quiet);
 
 extern void restore_original_signals_state (void);
 
-#endif /* COMMON_SIGNALS_STATE_SAVE_RESTORE_H */
+#endif /* GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H */
diff --git a/gdbsupport/symbol.h b/gdbsupport/symbol.h
index 3e1dc9d29d3..de439c07179 100644
--- a/gdbsupport/symbol.h
+++ b/gdbsupport/symbol.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SYMBOL_H
-#define COMMON_SYMBOL_H
+#ifndef GDBSUPPORT_SYMBOL_H
+#define GDBSUPPORT_SYMBOL_H
 
 struct objfile;
 
@@ -34,4 +34,4 @@ struct objfile;
 extern int find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
 					struct objfile *objfile);
 
-#endif /* COMMON_SYMBOL_H */
+#endif /* GDBSUPPORT_SYMBOL_H */
diff --git a/gdbsupport/tdesc.h b/gdbsupport/tdesc.h
index fa9431b5b65..dc2d45278d1 100644
--- a/gdbsupport/tdesc.h
+++ b/gdbsupport/tdesc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_TDESC_H
-#define COMMON_TDESC_H
+#ifndef GDBSUPPORT_TDESC_H
+#define GDBSUPPORT_TDESC_H
 
 struct tdesc_feature;
 struct tdesc_type;
@@ -462,4 +462,4 @@ class print_xml_feature : public tdesc_element_visitor
   int m_depth;
 };
 
-#endif /* COMMON_TDESC_H */
+#endif /* GDBSUPPORT_TDESC_H */
diff --git a/gdbsupport/traits.h b/gdbsupport/traits.h
index 92fe59f34af..600f89ede65 100644
--- a/gdbsupport/traits.h
+++ b/gdbsupport/traits.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_TRAITS_H
-#define COMMON_TRAITS_H
+#ifndef GDBSUPPORT_TRAITS_H
+#define GDBSUPPORT_TRAITS_H
 
 #include <type_traits>
 
@@ -143,4 +143,4 @@ template<typename Condition>
 using Requires = typename std::enable_if<Condition::value, void>::type;
 }
 
-#endif /* COMMON_TRAITS_H */
+#endif /* GDBSUPPORT_TRAITS_H */
diff --git a/gdbsupport/underlying.h b/gdbsupport/underlying.h
index d9c5696a4cd..a3e7e3fca85 100644
--- a/gdbsupport/underlying.h
+++ b/gdbsupport/underlying.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_UNDERLYING_H
-#define COMMON_UNDERLYING_H
+#ifndef GDBSUPPORT_UNDERLYING_H
+#define GDBSUPPORT_UNDERLYING_H
 
 #include <type_traits>
 
@@ -29,4 +29,4 @@ to_underlying (E val) noexcept
   return static_cast<typename std::underlying_type<E>::type> (val);
 }
 
-#endif
+#endif /* GDBSUPPORT_UNDERLYING_H */
diff --git a/gdbsupport/valid-expr.h b/gdbsupport/valid-expr.h
index 6d2b481c6e1..ef51958dc09 100644
--- a/gdbsupport/valid-expr.h
+++ b/gdbsupport/valid-expr.h
@@ -23,8 +23,8 @@
    right type.  This is mainly used to verify that some utility's API
    is really as safe as intended.  */
 
-#ifndef COMMON_VALID_EXPR_H
-#define COMMON_VALID_EXPR_H
+#ifndef GDBSUPPORT_VALID_EXPR_H
+#define GDBSUPPORT_VALID_EXPR_H
 
 #include "gdbsupport/preprocessor.h"
 #include "gdbsupport/traits.h"
@@ -108,4 +108,4 @@
 			ESC_PARENS (T1, T2, T3, T4, T5, T6),		\
 			VALID, EXPR_TYPE, EXPR)
 
-#endif /* COMMON_VALID_EXPR_H */
+#endif /* GDBSUPPORT_VALID_EXPR_H */
diff --git a/gdbsupport/version.h b/gdbsupport/version.h
index 7c60a963919..052d613d47e 100644
--- a/gdbsupport/version.h
+++ b/gdbsupport/version.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_VERSION_H
-#define COMMON_VERSION_H
+#ifndef GDBSUPPORT_VERSION_H
+#define GDBSUPPORT_VERSION_H
 
 /* Version number of GDB, as a string.  */
 extern const char version[];
@@ -28,4 +28,4 @@ extern const char host_name[];
 /* Canonical target name as a string.  */
 extern const char target_name[];
 
-#endif /* COMMON_VERSION_H */
+#endif /* GDBSUPPORT_VERSION_H */
diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h
index 89c1143fbe1..ed8aeccece2 100644
--- a/gdbsupport/x86-xstate.h
+++ b/gdbsupport/x86-xstate.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_X86_XSTATE_H
-#define COMMON_X86_XSTATE_H
+#ifndef GDBSUPPORT_X86_XSTATE_H
+#define GDBSUPPORT_X86_XSTATE_H
 
 /* The extended state feature IDs in the state component bitmap.  */
 #define X86_XSTATE_X87_ID	0
@@ -120,4 +120,4 @@ constexpr bool operator!= (const x86_xsave_layout &lhs,
 
 #define I387_MXCSR_INIT_VAL 0x1f80
 
-#endif /* COMMON_X86_XSTATE_H */
+#endif /* GDBSUPPORT_X86_XSTATE_H */
diff --git a/gdbsupport/xml-utils.h b/gdbsupport/xml-utils.h
index c1f21b9b8ec..d68f4c98018 100644
--- a/gdbsupport/xml-utils.h
+++ b/gdbsupport/xml-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_XML_UTILS_H
-#define COMMON_XML_UTILS_H
+#ifndef GDBSUPPORT_XML_UTILS_H
+#define GDBSUPPORT_XML_UTILS_H
 
 /* Return a string with special characters from TEXT replaced by entity
    references.  */
@@ -40,4 +40,4 @@ extern void xml_escape_text_append (std::string &result, const char *text);
 void string_xml_appendf (std::string &buffer, const char *format, ...)
   ATTRIBUTE_PRINTF (2, 3);
 
-#endif /* COMMON_XML_UTILS_H */
+#endif /* GDBSUPPORT_XML_UTILS_H */
-- 
2.43.0


^ permalink raw reply	[relevance 1%]

* [PATCH v3 4/4] Run check-include-guards.py
  @ 2024-04-19 14:55  1% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-19 14:55 UTC (permalink / raw)
  To: gdb-patches

This patch is the result of running check-include-guards.py on the
current tree.  Running it a second time causes no changes.
---
 gdb/aarch32-linux-nat.h                     | 6 +++---
 gdb/aarch32-tdep.h                          | 6 +++---
 gdb/aarch64-fbsd-tdep.h                     | 6 +++---
 gdb/aarch64-linux-tdep.h                    | 6 +++---
 gdb/aarch64-nat.h                           | 6 +++---
 gdb/aarch64-ravenscar-thread.h              | 6 +++---
 gdb/aarch64-tdep.h                          | 6 +++---
 gdb/ada-exp.h                               | 6 +++---
 gdb/ada-lang.h                              | 6 +++---
 gdb/addrmap.h                               | 6 +++---
 gdb/alpha-bsd-tdep.h                        | 6 +++---
 gdb/alpha-tdep.h                            | 6 +++---
 gdb/amd-dbgapi-target.h                     | 6 +++---
 gdb/amd64-bsd-nat.h                         | 6 +++---
 gdb/amd64-darwin-tdep.h                     | 6 +++---
 gdb/amd64-fbsd-tdep.h                       | 6 +++---
 gdb/amd64-linux-tdep.h                      | 6 +++---
 gdb/amd64-nat.h                             | 6 +++---
 gdb/amd64-ravenscar-thread.h                | 6 +++---
 gdb/amd64-tdep.h                            | 6 +++---
 gdb/amdgpu-tdep.h                           | 6 +++---
 gdb/annotate.h                              | 6 +++---
 gdb/arc-linux-tdep.h                        | 6 +++---
 gdb/arc-tdep.h                              | 6 +++---
 gdb/arch-utils.h                            | 6 +++---
 gdb/arch/aarch32.h                          | 6 +++---
 gdb/arch/aarch64-insn.h                     | 6 +++---
 gdb/arch/aarch64-mte-linux.h                | 6 +++---
 gdb/arch/aarch64-scalable-linux.h           | 6 +++---
 gdb/arch/aarch64.h                          | 6 +++---
 gdb/arch/amd64.h                            | 6 +++---
 gdb/arch/arc.h                              | 6 +++---
 gdb/arch/arm-get-next-pcs.h                 | 6 +++---
 gdb/arch/arm-linux.h                        | 6 +++---
 gdb/arch/arm.h                              | 6 +++---
 gdb/arch/csky.h                             | 6 +++---
 gdb/arch/i386.h                             | 6 +++---
 gdb/arch/loongarch.h                        | 6 +++---
 gdb/arch/ppc-linux-common.h                 | 6 +++---
 gdb/arch/ppc-linux-tdesc.h                  | 6 +++---
 gdb/arch/riscv.h                            | 6 +++---
 gdb/arch/tic6x.h                            | 6 +++---
 gdb/arch/xtensa.h                           | 6 +++---
 gdb/arm-fbsd-tdep.h                         | 6 +++---
 gdb/arm-linux-tdep.h                        | 6 +++---
 gdb/arm-netbsd-tdep.h                       | 6 +++---
 gdb/arm-tdep.h                              | 6 +++---
 gdb/async-event.h                           | 6 +++---
 gdb/auto-load.h                             | 6 +++---
 gdb/auxv.h                                  | 6 +++---
 gdb/ax-gdb.h                                | 6 +++---
 gdb/ax.h                                    | 6 +++---
 gdb/bcache.h                                | 6 +++---
 gdb/bfd-target.h                            | 6 +++---
 gdb/bfin-tdep.h                             | 6 +++---
 gdb/block.h                                 | 6 +++---
 gdb/breakpoint.h                            | 6 +++---
 gdb/bsd-kvm.h                               | 6 +++---
 gdb/bsd-uthread.h                           | 6 +++---
 gdb/bt-utils.h                              | 6 +++---
 gdb/btrace.h                                | 6 +++---
 gdb/build-id.h                              | 6 +++---
 gdb/buildsym-legacy.h                       | 6 +++---
 gdb/buildsym.h                              | 6 +++---
 gdb/c-exp.h                                 | 6 +++---
 gdb/c-lang.h                                | 6 +++---
 gdb/c-support.h                             | 6 +++---
 gdb/cgen-remap.h                            | 6 +++---
 gdb/charset-list.h                          | 6 +++---
 gdb/charset.h                               | 6 +++---
 gdb/cli-out.h                               | 6 +++---
 gdb/cli/cli-cmds.h                          | 6 +++---
 gdb/cli/cli-decode.h                        | 6 +++---
 gdb/cli/cli-interp.h                        | 6 +++---
 gdb/cli/cli-option.h                        | 6 +++---
 gdb/cli/cli-script.h                        | 6 +++---
 gdb/cli/cli-setshow.h                       | 6 +++---
 gdb/cli/cli-style.h                         | 6 +++---
 gdb/cli/cli-utils.h                         | 6 +++---
 gdb/coff-pe-read.h                          | 6 +++---
 gdb/command.h                               | 6 +++---
 gdb/compile/compile-c.h                     | 6 +++---
 gdb/compile/compile-cplus.h                 | 6 +++---
 gdb/compile/compile-internal.h              | 6 +++---
 gdb/compile/compile-object-load.h           | 6 +++---
 gdb/compile/compile-object-run.h            | 6 +++---
 gdb/compile/compile.h                       | 6 +++---
 gdb/compile/gcc-c-plugin.h                  | 6 +++---
 gdb/compile/gcc-cp-plugin.h                 | 6 +++---
 gdb/complaints.h                            | 6 +++---
 gdb/completer.h                             | 6 +++---
 gdb/config/nm-linux.h                       | 6 +++---
 gdb/config/nm-nto.h                         | 6 +++---
 gdb/cp-abi.h                                | 6 +++---
 gdb/cp-support.h                            | 6 +++---
 gdb/cris-tdep.h                             | 6 +++---
 gdb/csky-tdep.h                             | 6 +++---
 gdb/ctfread.h                               | 6 +++---
 gdb/d-lang.h                                | 6 +++---
 gdb/darwin-nat.h                            | 6 +++---
 gdb/dcache.h                                | 6 +++---
 gdb/debuginfod-support.h                    | 6 +++---
 gdb/defs.h                                  | 6 +++---
 gdb/dicos-tdep.h                            | 6 +++---
 gdb/dictionary.h                            | 6 +++---
 gdb/disasm-flags.h                          | 6 +++---
 gdb/disasm.h                                | 6 +++---
 gdb/displaced-stepping.h                    | 6 +++---
 gdb/dummy-frame.h                           | 6 +++---
 gdb/dwarf2/call-site.h                      | 6 +++---
 gdb/dwarf2/comp-unit-head.h                 | 6 +++---
 gdb/dwarf2/expr.h                           | 6 +++---
 gdb/dwarf2/frame-tailcall.h                 | 6 +++---
 gdb/dwarf2/frame.h                          | 6 +++---
 gdb/dwarf2/index-cache.h                    | 6 +++---
 gdb/dwarf2/index-common.h                   | 6 +++---
 gdb/dwarf2/index-write.h                    | 6 +++---
 gdb/dwarf2/line-header.h                    | 6 +++---
 gdb/dwarf2/loc.h                            | 6 +++---
 gdb/dwarf2/public.h                         | 6 +++---
 gdb/dwarf2/read-debug-names.h               | 6 +++---
 gdb/dwarf2/read-gdb-index.h                 | 6 +++---
 gdb/dwarf2/read.h                           | 6 +++---
 gdb/dwarf2/types.h                          | 6 +++---
 gdb/elf-none-tdep.h                         | 6 +++---
 gdb/event-top.h                             | 6 +++---
 gdb/exceptions.h                            | 6 +++---
 gdb/exec.h                                  | 6 +++---
 gdb/expop.h                                 | 6 +++---
 gdb/expression.h                            | 6 +++---
 gdb/extension-priv.h                        | 6 +++---
 gdb/extension.h                             | 6 +++---
 gdb/f-array-walker.h                        | 6 +++---
 gdb/f-exp.h                                 | 6 +++---
 gdb/f-lang.h                                | 6 +++---
 gdb/fbsd-nat.h                              | 6 +++---
 gdb/fbsd-tdep.h                             | 6 +++---
 gdb/filename-seen-cache.h                   | 6 +++---
 gdb/filesystem.h                            | 6 +++---
 gdb/frame-base.h                            | 6 +++---
 gdb/frame-id.h                              | 4 ++--
 gdb/frame-unwind.h                          | 6 +++---
 gdb/frame.h                                 | 6 +++---
 gdb/frv-tdep.h                              | 6 +++---
 gdb/ft32-tdep.h                             | 6 +++---
 gdb/gcore-elf.h                             | 6 +++---
 gdb/gcore.h                                 | 6 +++---
 gdb/gdb-demangle.h                          | 6 +++---
 gdb/gdb-stabs.h                             | 6 +++---
 gdb/gdb_bfd.h                               | 6 +++---
 gdb/gdb_curses.h                            | 6 +++---
 gdb/gdb_expat.h                             | 6 +++---
 gdb/gdb_proc_service.h                      | 6 +++---
 gdb/gdb_vfork.h                             | 6 +++---
 gdb/gdb_wchar.h                             | 6 +++---
 gdb/gdbarch.h                               | 6 +++---
 gdb/gdbcmd.h                                | 6 +++---
 gdb/gdbcore.h                               | 6 +++---
 gdb/gdbthread.h                             | 6 +++---
 gdb/gdbtypes.h                              | 6 +++---
 gdb/glibc-tdep.h                            | 6 +++---
 gdb/gmp-utils.h                             | 6 +++---
 gdb/gnu-nat-mig.h                           | 6 +++---
 gdb/gnu-nat.h                               | 6 +++---
 gdb/go-lang.h                               | 6 +++---
 gdb/gregset.h                               | 6 +++---
 gdb/guile/guile-internal.h                  | 6 +++---
 gdb/guile/guile.h                           | 6 +++---
 gdb/hppa-bsd-tdep.h                         | 6 +++---
 gdb/hppa-linux-offsets.h                    | 6 +++---
 gdb/hppa-tdep.h                             | 6 +++---
 gdb/i386-bsd-nat.h                          | 6 +++---
 gdb/i386-darwin-tdep.h                      | 6 +++---
 gdb/i386-fbsd-tdep.h                        | 6 +++---
 gdb/i386-linux-nat.h                        | 6 +++---
 gdb/i386-linux-tdep.h                       | 6 +++---
 gdb/i386-tdep.h                             | 6 +++---
 gdb/i387-tdep.h                             | 6 +++---
 gdb/ia64-libunwind-tdep.h                   | 6 +++---
 gdb/ia64-tdep.h                             | 6 +++---
 gdb/inf-child.h                             | 6 +++---
 gdb/inf-loop.h                              | 6 +++---
 gdb/inf-ptrace.h                            | 6 +++---
 gdb/infcall.h                               | 6 +++---
 gdb/inferior-iter.h                         | 6 +++---
 gdb/inferior.h                              | 6 +++---
 gdb/infrun.h                                | 6 +++---
 gdb/inline-frame.h                          | 6 +++---
 gdb/interps.h                               | 6 +++---
 gdb/jit.h                                   | 6 +++---
 gdb/language.h                              | 6 +++---
 gdb/linespec.h                              | 6 +++---
 gdb/linux-fork.h                            | 6 +++---
 gdb/linux-nat-trad.h                        | 6 +++---
 gdb/linux-nat.h                             | 6 +++---
 gdb/linux-record.h                          | 6 +++---
 gdb/linux-tdep.h                            | 6 +++---
 gdb/location.h                              | 6 +++---
 gdb/loongarch-tdep.h                        | 6 +++---
 gdb/m2-exp.h                                | 6 +++---
 gdb/m2-lang.h                               | 6 +++---
 gdb/m32r-tdep.h                             | 6 +++---
 gdb/m68k-tdep.h                             | 6 +++---
 gdb/macroexp.h                              | 6 +++---
 gdb/macroscope.h                            | 6 +++---
 gdb/macrotab.h                              | 6 +++---
 gdb/main.h                                  | 6 +++---
 gdb/maint.h                                 | 6 +++---
 gdb/mdebugread.h                            | 6 +++---
 gdb/memattr.h                               | 6 +++---
 gdb/memory-map.h                            | 6 +++---
 gdb/memrange.h                              | 6 +++---
 gdb/memtag.h                                | 6 +++---
 gdb/mi/mi-cmd-break.h                       | 6 +++---
 gdb/mi/mi-cmds.h                            | 6 +++---
 gdb/mi/mi-common.h                          | 6 +++---
 gdb/mi/mi-console.h                         | 6 +++---
 gdb/mi/mi-getopt.h                          | 6 +++---
 gdb/mi/mi-interp.h                          | 6 +++---
 gdb/mi/mi-main.h                            | 6 +++---
 gdb/mi/mi-out.h                             | 6 +++---
 gdb/mi/mi-parse.h                           | 6 +++---
 gdb/microblaze-tdep.h                       | 6 +++---
 gdb/minsyms.h                               | 6 +++---
 gdb/mips-fbsd-tdep.h                        | 6 +++---
 gdb/mips-linux-tdep.h                       | 6 +++---
 gdb/mips-netbsd-tdep.h                      | 6 +++---
 gdb/mips-tdep.h                             | 6 +++---
 gdb/mn10300-tdep.h                          | 6 +++---
 gdb/moxie-tdep.h                            | 6 +++---
 gdb/namespace.h                             | 6 +++---
 gdb/nat/aarch64-hw-point.h                  | 6 +++---
 gdb/nat/aarch64-linux-hw-point.h            | 6 +++---
 gdb/nat/aarch64-linux.h                     | 6 +++---
 gdb/nat/aarch64-mte-linux-ptrace.h          | 6 +++---
 gdb/nat/aarch64-scalable-linux-ptrace.h     | 6 +++---
 gdb/nat/aarch64-scalable-linux-sigcontext.h | 6 +++---
 gdb/nat/amd64-linux-siginfo.h               | 6 +++---
 gdb/nat/fork-inferior.h                     | 6 +++---
 gdb/nat/gdb_ptrace.h                        | 6 +++---
 gdb/nat/gdb_thread_db.h                     | 6 +++---
 gdb/nat/glibc_thread_db.h                   | 6 +++---
 gdb/nat/linux-btrace.h                      | 6 +++---
 gdb/nat/linux-namespaces.h                  | 6 +++---
 gdb/nat/linux-nat.h                         | 6 +++---
 gdb/nat/linux-osdata.h                      | 6 +++---
 gdb/nat/linux-personality.h                 | 6 +++---
 gdb/nat/linux-procfs.h                      | 6 +++---
 gdb/nat/linux-ptrace.h                      | 6 +++---
 gdb/nat/linux-waitpid.h                     | 6 +++---
 gdb/nat/mips-linux-watch.h                  | 6 +++---
 gdb/nat/netbsd-nat.h                        | 6 +++---
 gdb/nat/ppc-linux.h                         | 6 +++---
 gdb/nat/riscv-linux-tdesc.h                 | 6 +++---
 gdb/nat/windows-nat.h                       | 6 +++---
 gdb/nat/x86-cpuid.h                         | 6 +++---
 gdb/nat/x86-dregs.h                         | 6 +++---
 gdb/nat/x86-gcc-cpuid.h                     | 6 +++---
 gdb/nat/x86-linux-dregs.h                   | 6 +++---
 gdb/nat/x86-linux.h                         | 6 +++---
 gdb/nat/x86-xstate.h                        | 6 +++---
 gdb/nds32-tdep.h                            | 6 +++---
 gdb/netbsd-nat.h                            | 6 +++---
 gdb/netbsd-tdep.h                           | 6 +++---
 gdb/nios2-tdep.h                            | 6 +++---
 gdb/nto-tdep.h                              | 6 +++---
 gdb/objc-lang.h                             | 6 +++---
 gdb/objfile-flags.h                         | 6 +++---
 gdb/objfiles.h                              | 6 +++---
 gdb/obsd-nat.h                              | 6 +++---
 gdb/obsd-tdep.h                             | 6 +++---
 gdb/observable.h                            | 6 +++---
 gdb/or1k-linux-tdep.h                       | 6 +++---
 gdb/or1k-tdep.h                             | 6 +++---
 gdb/osabi.h                                 | 6 +++---
 gdb/osdata.h                                | 6 +++---
 gdb/p-lang.h                                | 6 +++---
 gdb/parser-defs.h                           | 6 +++---
 gdb/ppc-fbsd-tdep.h                         | 6 +++---
 gdb/ppc-linux-tdep.h                        | 6 +++---
 gdb/ppc-netbsd-tdep.h                       | 6 +++---
 gdb/ppc-obsd-tdep.h                         | 6 +++---
 gdb/ppc-ravenscar-thread.h                  | 6 +++---
 gdb/ppc-tdep.h                              | 6 +++---
 gdb/ppc64-tdep.h                            | 6 +++---
 gdb/probe.h                                 | 6 +++---
 gdb/proc-utils.h                            | 6 +++---
 gdb/process-stratum-target.h                | 6 +++---
 gdb/procfs.h                                | 6 +++---
 gdb/producer.h                              | 6 +++---
 gdb/progspace-and-thread.h                  | 6 +++---
 gdb/progspace.h                             | 6 +++---
 gdb/prologue-value.h                        | 6 +++---
 gdb/psymtab.h                               | 6 +++---
 gdb/python/py-event.h                       | 6 +++---
 gdb/python/py-events.h                      | 6 +++---
 gdb/python/py-instruction.h                 | 6 +++---
 gdb/python/py-record-btrace.h               | 6 +++---
 gdb/python/py-record-full.h                 | 6 +++---
 gdb/python/py-record.h                      | 6 +++---
 gdb/python/py-ref.h                         | 6 +++---
 gdb/python/py-stopevent.h                   | 6 +++---
 gdb/python/python-internal.h                | 6 +++---
 gdb/python/python.h                         | 6 +++---
 gdb/ravenscar-thread.h                      | 6 +++---
 gdb/record-btrace.h                         | 6 +++---
 gdb/record-full.h                           | 6 +++---
 gdb/record.h                                | 6 +++---
 gdb/regcache.h                              | 6 +++---
 gdb/regformats/regdef.h                     | 6 +++---
 gdb/reggroups.h                             | 6 +++---
 gdb/registry.h                              | 6 +++---
 gdb/regset.h                                | 6 +++---
 gdb/remote-fileio.h                         | 6 +++---
 gdb/remote-notif.h                          | 6 +++---
 gdb/remote.h                                | 6 +++---
 gdb/riscv-fbsd-tdep.h                       | 6 +++---
 gdb/riscv-ravenscar-thread.h                | 6 +++---
 gdb/riscv-tdep.h                            | 6 +++---
 gdb/rs6000-aix-tdep.h                       | 6 +++---
 gdb/rust-exp.h                              | 6 +++---
 gdb/rust-lang.h                             | 6 +++---
 gdb/s390-linux-tdep.h                       | 6 +++---
 gdb/s390-tdep.h                             | 6 +++---
 gdb/scoped-mock-context.h                   | 6 +++---
 gdb/selftest-arch.h                         | 6 +++---
 gdb/sentinel-frame.h                        | 6 +++---
 gdb/ser-base.h                              | 6 +++---
 gdb/ser-event.h                             | 6 +++---
 gdb/ser-tcp.h                               | 6 +++---
 gdb/ser-unix.h                              | 6 +++---
 gdb/serial.h                                | 6 +++---
 gdb/sh-tdep.h                               | 6 +++---
 gdb/sim-regno.h                             | 6 +++---
 gdb/skip.h                                  | 6 +++---
 gdb/sol2-tdep.h                             | 6 +++---
 gdb/solib-aix.h                             | 6 +++---
 gdb/solib-darwin.h                          | 6 +++---
 gdb/solib-dsbt.h                            | 6 +++---
 gdb/solib-svr4.h                            | 6 +++---
 gdb/solib-target.h                          | 6 +++---
 gdb/solib.h                                 | 6 +++---
 gdb/solist.h                                | 6 +++---
 gdb/source-cache.h                          | 6 +++---
 gdb/source.h                                | 6 +++---
 gdb/sparc-nat.h                             | 6 +++---
 gdb/sparc-ravenscar-thread.h                | 6 +++---
 gdb/sparc-tdep.h                            | 6 +++---
 gdb/sparc64-tdep.h                          | 6 +++---
 gdb/stabsread.h                             | 6 +++---
 gdb/stack.h                                 | 6 +++---
 gdb/stap-probe.h                            | 6 +++---
 gdb/symfile-add-flags.h                     | 6 +++---
 gdb/symfile.h                               | 6 +++---
 gdb/symtab.h                                | 6 +++---
 gdb/target-connection.h                     | 6 +++---
 gdb/target-dcache.h                         | 6 +++---
 gdb/target-debug.h                          | 6 +++---
 gdb/target-descriptions.h                   | 6 +++---
 gdb/target-float.h                          | 6 +++---
 gdb/target.h                                | 6 +++---
 gdb/target/resume.h                         | 6 +++---
 gdb/target/target.h                         | 6 +++---
 gdb/target/wait.h                           | 6 +++---
 gdb/target/waitstatus.h                     | 6 +++---
 gdb/terminal.h                              | 6 +++---
 gdb/test-target.h                           | 6 +++---
 gdb/thread-fsm.h                            | 6 +++---
 gdb/thread-iter.h                           | 6 +++---
 gdb/tic6x-tdep.h                            | 6 +++---
 gdb/tid-parse.h                             | 6 +++---
 gdb/tilegx-tdep.h                           | 6 +++---
 gdb/top.h                                   | 6 +++---
 gdb/tracectf.h                              | 6 +++---
 gdb/tracefile.h                             | 6 +++---
 gdb/tracepoint.h                            | 6 +++---
 gdb/trad-frame.h                            | 6 +++---
 gdb/tramp-frame.h                           | 6 +++---
 gdb/tui/tui-command.h                       | 6 +++---
 gdb/tui/tui-data.h                          | 6 +++---
 gdb/tui/tui-disasm.h                        | 6 +++---
 gdb/tui/tui-file.h                          | 6 +++---
 gdb/tui/tui-hooks.h                         | 6 +++---
 gdb/tui/tui-io.h                            | 6 +++---
 gdb/tui/tui-layout.h                        | 6 +++---
 gdb/tui/tui-location.h                      | 6 +++---
 gdb/tui/tui-regs.h                          | 6 +++---
 gdb/tui/tui-source.h                        | 6 +++---
 gdb/tui/tui-status.h                        | 6 +++---
 gdb/tui/tui-win.h                           | 6 +++---
 gdb/tui/tui-wingeneral.h                    | 6 +++---
 gdb/tui/tui-winsource.h                     | 6 +++---
 gdb/tui/tui.h                               | 6 +++---
 gdb/type-stack.h                            | 6 +++---
 gdb/typeprint.h                             | 6 +++---
 gdb/ui-file.h                               | 6 +++---
 gdb/ui-out.h                                | 6 +++---
 gdb/ui-style.h                              | 6 +++---
 gdb/ui.h                                    | 6 +++---
 gdb/user-regs.h                             | 6 +++---
 gdb/utils.h                                 | 6 +++---
 gdb/valprint.h                              | 6 +++---
 gdb/value.h                                 | 6 +++---
 gdb/varobj-iter.h                           | 6 +++---
 gdb/varobj.h                                | 6 +++---
 gdb/vax-tdep.h                              | 6 +++---
 gdb/windows-nat.h                           | 6 +++---
 gdb/windows-tdep.h                          | 6 +++---
 gdb/x86-bsd-nat.h                           | 6 +++---
 gdb/x86-fbsd-nat.h                          | 6 +++---
 gdb/x86-linux-nat.h                         | 6 +++---
 gdb/x86-nat.h                               | 6 +++---
 gdb/x86-tdep.h                              | 6 +++---
 gdb/xcoffread.h                             | 6 +++---
 gdb/xml-builtin.h                           | 6 +++---
 gdb/xml-support.h                           | 6 +++---
 gdb/xml-syscall.h                           | 6 +++---
 gdb/xml-tdesc.h                             | 6 +++---
 gdb/xtensa-tdep.h                           | 6 +++---
 gdb/yy-remap.h                              | 6 +++---
 gdb/z80-tdep.h                              | 6 +++---
 gdbserver/linux-aarch32-tdesc.h             | 2 +-
 gdbserver/linux-arm-tdesc.h                 | 2 +-
 gdbsupport/agent.h                          | 6 +++---
 gdbsupport/array-view.h                     | 6 +++---
 gdbsupport/break-common.h                   | 6 +++---
 gdbsupport/btrace-common.h                  | 6 +++---
 gdbsupport/byte-vector.h                    | 6 +++---
 gdbsupport/cleanups.h                       | 6 +++---
 gdbsupport/common-debug.h                   | 6 +++---
 gdbsupport/common-defs.h                    | 6 +++---
 gdbsupport/common-exceptions.h              | 6 +++---
 gdbsupport/common-gdbthread.h               | 6 +++---
 gdbsupport/common-inferior.h                | 6 +++---
 gdbsupport/common-regcache.h                | 6 +++---
 gdbsupport/common-types.h                   | 6 +++---
 gdbsupport/common-utils.h                   | 6 +++---
 gdbsupport/def-vector.h                     | 6 +++---
 gdbsupport/default-init-alloc.h             | 6 +++---
 gdbsupport/enum-flags.h                     | 6 +++---
 gdbsupport/environ.h                        | 6 +++---
 gdbsupport/errors.h                         | 6 +++---
 gdbsupport/event-loop.h                     | 6 +++---
 gdbsupport/event-pipe.h                     | 6 +++---
 gdbsupport/fileio.h                         | 6 +++---
 gdbsupport/filestuff.h                      | 6 +++---
 gdbsupport/filtered-iterator.h              | 6 +++---
 gdbsupport/format.h                         | 6 +++---
 gdbsupport/forward-scope-exit.h             | 6 +++---
 gdbsupport/function-view.h                  | 6 +++---
 gdbsupport/gdb-checked-static-cast.h        | 6 +++---
 gdbsupport/gdb-dlfcn.h                      | 6 +++---
 gdbsupport/gdb-safe-ctype.h                 | 6 +++---
 gdbsupport/gdb_assert.h                     | 6 +++---
 gdbsupport/gdb_file.h                       | 6 +++---
 gdbsupport/gdb_locale.h                     | 6 +++---
 gdbsupport/gdb_obstack.h                    | 6 +++---
 gdbsupport/gdb_proc_service.h               | 6 +++---
 gdbsupport/gdb_ref_ptr.h                    | 6 +++---
 gdbsupport/gdb_regex.h                      | 6 +++---
 gdbsupport/gdb_select.h                     | 6 +++---
 gdbsupport/gdb_setjmp.h                     | 6 +++---
 gdbsupport/gdb_signals.h                    | 6 +++---
 gdbsupport/gdb_splay_tree.h                 | 6 +++---
 gdbsupport/gdb_sys_time.h                   | 6 +++---
 gdbsupport/gdb_tilde_expand.h               | 6 +++---
 gdbsupport/gdb_unique_ptr.h                 | 6 +++---
 gdbsupport/gdb_unlinker.h                   | 6 +++---
 gdbsupport/gdb_vecs.h                       | 6 +++---
 gdbsupport/gdb_wait.h                       | 6 +++---
 gdbsupport/hash_enum.h                      | 6 +++---
 gdbsupport/host-defs.h                      | 6 +++---
 gdbsupport/job-control.h                    | 6 +++---
 gdbsupport/netstuff.h                       | 6 +++---
 gdbsupport/next-iterator.h                  | 6 +++---
 gdbsupport/observable.h                     | 6 +++---
 gdbsupport/offset-type.h                    | 6 +++---
 gdbsupport/packed.h                         | 6 +++---
 gdbsupport/pathstuff.h                      | 6 +++---
 gdbsupport/poison.h                         | 6 +++---
 gdbsupport/preprocessor.h                   | 6 +++---
 gdbsupport/print-utils.h                    | 6 +++---
 gdbsupport/ptid.h                           | 6 +++---
 gdbsupport/refcounted-object.h              | 6 +++---
 gdbsupport/rsp-low.h                        | 6 +++---
 gdbsupport/run-time-clock.h                 | 6 +++---
 gdbsupport/safe-iterator.h                  | 6 +++---
 gdbsupport/scope-exit.h                     | 6 +++---
 gdbsupport/scoped_fd.h                      | 6 +++---
 gdbsupport/scoped_ignore_signal.h           | 6 +++---
 gdbsupport/scoped_ignore_sigttou.h          | 6 +++---
 gdbsupport/scoped_mmap.h                    | 6 +++---
 gdbsupport/scoped_restore.h                 | 6 +++---
 gdbsupport/search.h                         | 6 +++---
 gdbsupport/selftest.h                       | 6 +++---
 gdbsupport/signals-state-save-restore.h     | 6 +++---
 gdbsupport/symbol.h                         | 6 +++---
 gdbsupport/tdesc.h                          | 6 +++---
 gdbsupport/traits.h                         | 6 +++---
 gdbsupport/underlying.h                     | 6 +++---
 gdbsupport/valid-expr.h                     | 6 +++---
 gdbsupport/version.h                        | 6 +++---
 gdbsupport/x86-xstate.h                     | 6 +++---
 gdbsupport/xml-utils.h                      | 6 +++---
 504 files changed, 1507 insertions(+), 1507 deletions(-)

diff --git a/gdb/aarch32-linux-nat.h b/gdb/aarch32-linux-nat.h
index 611c9fcfba9..79ad5adcef8 100644
--- a/gdb/aarch32-linux-nat.h
+++ b/gdb/aarch32-linux-nat.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH32_LINUX_NAT_H
-#define AARCH32_LINUX_NAT_H
+#ifndef GDB_AARCH32_LINUX_NAT_H
+#define GDB_AARCH32_LINUX_NAT_H
 
 void aarch32_gp_regcache_supply (struct regcache *regcache, uint32_t *regs,
 				 int arm_apcs_32);
@@ -31,4 +31,4 @@ void aarch32_vfp_regcache_collect (const struct regcache *regcache,
 				   gdb_byte *regs,
 				   const int vfp_register_count);
 
-#endif /* AARCH32_LINUX_NAT_H */
+#endif /* GDB_AARCH32_LINUX_NAT_H */
diff --git a/gdb/aarch32-tdep.h b/gdb/aarch32-tdep.h
index 009ee61890e..16ceb30a25f 100644
--- a/gdb/aarch32-tdep.h
+++ b/gdb/aarch32-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH32_TDEP_H
-#define AARCH32_TDEP_H
+#ifndef GDB_AARCH32_TDEP_H
+#define GDB_AARCH32_TDEP_H
 
 struct target_desc;
 
@@ -24,4 +24,4 @@ struct target_desc;
 
 const target_desc *aarch32_read_description (bool tls);
 
-#endif /* aarch32-tdep.h.  */
+#endif /* GDB_AARCH32_TDEP_H */
diff --git a/gdb/aarch64-fbsd-tdep.h b/gdb/aarch64-fbsd-tdep.h
index 56b15a94ee4..6d53b28386f 100644
--- a/gdb/aarch64-fbsd-tdep.h
+++ b/gdb/aarch64-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_FBSD_TDEP_H
-#define AARCH64_FBSD_TDEP_H
+#ifndef GDB_AARCH64_FBSD_TDEP_H
+#define GDB_AARCH64_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -39,4 +39,4 @@ extern const struct regset aarch64_fbsd_gregset;
 extern const struct regset aarch64_fbsd_fpregset;
 extern const struct regset aarch64_fbsd_tls_regset;
 
-#endif /* AARCH64_FBSD_TDEP_H */
+#endif /* GDB_AARCH64_FBSD_TDEP_H */
diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h
index 1961250e14f..4cca8e901a7 100644
--- a/gdb/aarch64-linux-tdep.h
+++ b/gdb/aarch64-linux-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_LINUX_TDEP_H
-#define AARCH64_LINUX_TDEP_H
+#ifndef GDB_AARCH64_LINUX_TDEP_H
+#define GDB_AARCH64_LINUX_TDEP_H
 
 #include "regset.h"
 
@@ -45,4 +45,4 @@ extern const struct regset aarch64_linux_fpregset;
 /* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h.  */
 #define AARCH64_HWCAP_PACA (1 << 30)
 
-#endif /* AARCH64_LINUX_TDEP_H */
+#endif /* GDB_AARCH64_LINUX_TDEP_H */
diff --git a/gdb/aarch64-nat.h b/gdb/aarch64-nat.h
index 947d2805602..33621c2643b 100644
--- a/gdb/aarch64-nat.h
+++ b/gdb/aarch64-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_NAT_H
-#define AARCH64_NAT_H
+#ifndef GDB_AARCH64_NAT_H
+#define GDB_AARCH64_NAT_H
 
 #include "breakpoint.h"
 #include "nat/aarch64-hw-point.h"
@@ -106,4 +106,4 @@ struct aarch64_nat_target : public BaseTarget
   { return start <= addr && start + length - 1 >= addr; }
 };
 
-#endif /* AARCH64_NAT_H */
+#endif /* GDB_AARCH64_NAT_H */
diff --git a/gdb/aarch64-ravenscar-thread.h b/gdb/aarch64-ravenscar-thread.h
index 2d2665627c5..9cf0113e635 100644
--- a/gdb/aarch64-ravenscar-thread.h
+++ b/gdb/aarch64-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_RAVENSCAR_THREAD_H
-#define AARCH64_RAVENSCAR_THREAD_H
+#ifndef GDB_AARCH64_RAVENSCAR_THREAD_H
+#define GDB_AARCH64_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_aarch64_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_AARCH64_RAVENSCAR_THREAD_H */
diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h
index 0e6024bfcbc..e1e9f43fd11 100644
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -19,8 +19,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef AARCH64_TDEP_H
-#define AARCH64_TDEP_H
+#ifndef GDB_AARCH64_TDEP_H
+#define GDB_AARCH64_TDEP_H
 
 #include "arch/aarch64.h"
 #include "displaced-stepping.h"
@@ -203,4 +203,4 @@ void aarch64_displaced_step_fixup (struct gdbarch *gdbarch,
 
 bool aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch);
 
-#endif /* aarch64-tdep.h */
+#endif /* GDB_AARCH64_TDEP_H */
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 94e4ea0f47e..0a59b343f14 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ADA_EXP_H
-#define ADA_EXP_H
+#ifndef GDB_ADA_EXP_H
+#define GDB_ADA_EXP_H
 
 #include "expop.h"
 
@@ -981,4 +981,4 @@ class ada_concat_operation : public concat_operation
 
 } /* namespace expr */
 
-#endif /* ADA_EXP_H */
+#endif /* GDB_ADA_EXP_H */
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 5083d004ac9..69c91b2e719 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (ADA_LANG_H)
-#define ADA_LANG_H 1
+#ifndef GDB_ADA_LANG_H
+#define GDB_ADA_LANG_H
 
 class frame_info_ptr;
 struct inferior;
@@ -435,4 +435,4 @@ extern block_symbol ada_resolve_variable (struct symbol *sym,
 extern struct type *ada_index_type (struct type *type, int n,
 				    const char *name);
 
-#endif
+#endif /* GDB_ADA_LANG_H */
diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index 5378b753760..a2ccc7b0cfd 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ADDRMAP_H
-#define ADDRMAP_H
+#ifndef GDB_ADDRMAP_H
+#define GDB_ADDRMAP_H
 
 #include "splay-tree.h"
 #include "gdbsupport/function-view.h"
@@ -222,4 +222,4 @@ struct addrmap_mutable final : public addrmap
 void addrmap_dump (struct addrmap *map, struct ui_file *outfile,
 		   void *payload);
 
-#endif /* ADDRMAP_H */
+#endif /* GDB_ADDRMAP_H */
diff --git a/gdb/alpha-bsd-tdep.h b/gdb/alpha-bsd-tdep.h
index 25ac043ba86..4783854eb47 100644
--- a/gdb/alpha-bsd-tdep.h
+++ b/gdb/alpha-bsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ALPHA_BSD_TDEP_H
-#define ALPHA_BSD_TDEP_H
+#ifndef GDB_ALPHA_BSD_TDEP_H
+#define GDB_ALPHA_BSD_TDEP_H
 
 #include "gdbarch.h"
 
@@ -39,4 +39,4 @@ void alphanbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					     void *cb_data,
 					     const struct regcache *regcache);
 
-#endif /* alpha-bsd-tdep.h */
+#endif /* GDB_ALPHA_BSD_TDEP_H */
diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h
index 0423abb2558..37c1eddf691 100644
--- a/gdb/alpha-tdep.h
+++ b/gdb/alpha-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ALPHA_TDEP_H
-#define ALPHA_TDEP_H
+#ifndef GDB_ALPHA_TDEP_H
+#define GDB_ALPHA_TDEP_H
 
 #include "gdbarch.h"
 
@@ -121,4 +121,4 @@ extern void alpha_supply_fp_regs (struct regcache *, int,
 extern void alpha_fill_fp_regs (const struct regcache *,
 				int, void *, void *);
 
-#endif /* ALPHA_TDEP_H */
+#endif /* GDB_ALPHA_TDEP_H */
diff --git a/gdb/amd-dbgapi-target.h b/gdb/amd-dbgapi-target.h
index f377fd0c57a..0a9cafaa7ee 100644
--- a/gdb/amd-dbgapi-target.h
+++ b/gdb/amd-dbgapi-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD_DBGAPI_TARGET_H
-#define AMD_DBGAPI_TARGET_H 1
+#ifndef GDB_AMD_DBGAPI_TARGET_H
+#define GDB_AMD_DBGAPI_TARGET_H
 
 #include "gdbsupport/observable.h"
 
@@ -113,4 +113,4 @@ get_status_string (amd_dbgapi_status_t status)
   return ret;
 }
 
-#endif /* AMD_DBGAPI_TARGET_H */
+#endif /* GDB_AMD_DBGAPI_TARGET_H */
diff --git a/gdb/amd64-bsd-nat.h b/gdb/amd64-bsd-nat.h
index b11356e0375..7ea26827625 100644
--- a/gdb/amd64-bsd-nat.h
+++ b/gdb/amd64-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_BSD_NAT_H
-#define AMD64_BSD_NAT_H
+#ifndef GDB_AMD64_BSD_NAT_H
+#define GDB_AMD64_BSD_NAT_H
 
 #include "x86-bsd-nat.h"
 
@@ -41,4 +41,4 @@ class amd64_bsd_nat_target : public x86bsd_nat_target<BaseTarget>
   { amd64bsd_store_inferior_registers (regcache, regnum); }
 };
 
-#endif /* i386-bsd-nat.h */
+#endif /* GDB_AMD64_BSD_NAT_H */
diff --git a/gdb/amd64-darwin-tdep.h b/gdb/amd64-darwin-tdep.h
index 19d92b61b90..c09cfe3229b 100644
--- a/gdb/amd64-darwin-tdep.h
+++ b/gdb/amd64-darwin-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_DARWIN_TDEP_H
-#define AMD64_DARWIN_TDEP_H
+#ifndef GDB_AMD64_DARWIN_TDEP_H
+#define GDB_AMD64_DARWIN_TDEP_H
 
 /* Mapping between the general-purpose registers in Darwin x86-64 thread
    state and GDB's register cache layout.
@@ -26,4 +26,4 @@
 extern int amd64_darwin_thread_state_reg_offset[];
 extern const int amd64_darwin_thread_state_num_regs;
 
-#endif /* AMD64_DARWIN_TDEP_H */
+#endif /* GDB_AMD64_DARWIN_TDEP_H */
diff --git a/gdb/amd64-fbsd-tdep.h b/gdb/amd64-fbsd-tdep.h
index 93b0ca901ce..7e8acc6959e 100644
--- a/gdb/amd64-fbsd-tdep.h
+++ b/gdb/amd64-fbsd-tdep.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_FBSD_TDEP_H
-#define AMD64_FBSD_TDEP_H
+#ifndef GDB_AMD64_FBSD_TDEP_H
+#define GDB_AMD64_FBSD_TDEP_H
 
 #include "regset.h"
 
 extern const struct regset amd64_fbsd_gregset;
 
-#endif /* AMD64_FBSD_TDEP_H */
+#endif /* GDB_AMD64_FBSD_TDEP_H */
diff --git a/gdb/amd64-linux-tdep.h b/gdb/amd64-linux-tdep.h
index 2003dcda78f..6ce0032040c 100644
--- a/gdb/amd64-linux-tdep.h
+++ b/gdb/amd64-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_LINUX_TDEP_H
-#define AMD64_LINUX_TDEP_H
+#ifndef GDB_AMD64_LINUX_TDEP_H
+#define GDB_AMD64_LINUX_TDEP_H
 
 /* Like for i386 GNU/Linux, there is an extra "register"
    used to control syscall restarting.  */
@@ -604,4 +604,4 @@ enum amd64_x32_syscall {
   amd64_x32_sys_getsockopt = (amd64_x32_syscall_bit + 542),
 };
 
-#endif /* amd64-linux-tdep.h */
+#endif /* GDB_AMD64_LINUX_TDEP_H */
diff --git a/gdb/amd64-nat.h b/gdb/amd64-nat.h
index b18ff8b1728..56ad36c9f1e 100644
--- a/gdb/amd64-nat.h
+++ b/gdb/amd64-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_NAT_H
-#define AMD64_NAT_H 1
+#ifndef GDB_AMD64_NAT_H
+#define GDB_AMD64_NAT_H
 
 struct regcache;
 
@@ -49,4 +49,4 @@ extern void amd64_supply_native_gregset (struct regcache *regcache,
 extern void amd64_collect_native_gregset (const struct regcache *regcache,
 					  void *gregs, int regnum);
 
-#endif /* amd64-nat.h */
+#endif /* GDB_AMD64_NAT_H */
diff --git a/gdb/amd64-ravenscar-thread.h b/gdb/amd64-ravenscar-thread.h
index 1a723600e7a..41e38327753 100644
--- a/gdb/amd64-ravenscar-thread.h
+++ b/gdb/amd64-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_RAVENSCAR_THREAD_H
-#define AMD64_RAVENSCAR_THREAD_H
+#ifndef GDB_AMD64_RAVENSCAR_THREAD_H
+#define GDB_AMD64_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_amd64_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif /* AMD64_RAVENSCAR_THREAD_H */
+#endif /* GDB_AMD64_RAVENSCAR_THREAD_H */
diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
index 696c65b4f1b..c964e26e6a3 100644
--- a/gdb/amd64-tdep.h
+++ b/gdb/amd64-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_TDEP_H
-#define AMD64_TDEP_H
+#ifndef GDB_AMD64_TDEP_H
+#define GDB_AMD64_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -144,4 +144,4 @@ extern int amd64nbsd_r_reg_offset[];
 /* Variables exported from amd64-obsd-tdep.c.  */
 extern int amd64obsd_r_reg_offset[];
 
-#endif /* amd64-tdep.h */
+#endif /* GDB_AMD64_TDEP_H */
diff --git a/gdb/amdgpu-tdep.h b/gdb/amdgpu-tdep.h
index 2656d18e727..16c7b83a679 100644
--- a/gdb/amdgpu-tdep.h
+++ b/gdb/amdgpu-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMDGPU_TDEP_H
-#define AMDGPU_TDEP_H
+#ifndef GDB_AMDGPU_TDEP_H
+#define GDB_AMDGPU_TDEP_H
 
 #include "gdbarch.h"
 
@@ -90,4 +90,4 @@ bool is_amdgpu_arch (struct gdbarch *gdbarch);
 
 amdgpu_gdbarch_tdep *get_amdgpu_gdbarch_tdep (gdbarch *arch);
 
-#endif /* AMDGPU_TDEP_H */
+#endif /* GDB_AMDGPU_TDEP_H */
diff --git a/gdb/annotate.h b/gdb/annotate.h
index b8ce63ff233..d730b2e8297 100644
--- a/gdb/annotate.h
+++ b/gdb/annotate.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ANNOTATE_H
-#define ANNOTATE_H
+#ifndef GDB_ANNOTATE_H
+#define GDB_ANNOTATE_H
 
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -132,4 +132,4 @@ extern void annotate_array_section_end (void);
 extern void (*deprecated_annotate_signalled_hook) (void);
 extern void (*deprecated_annotate_signal_hook) (void);
 
-#endif /* ANNOTATE_H */
+#endif /* GDB_ANNOTATE_H */
diff --git a/gdb/arc-linux-tdep.h b/gdb/arc-linux-tdep.h
index 20ed525fe7c..9fe4116984d 100644
--- a/gdb/arc-linux-tdep.h
+++ b/gdb/arc-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARC_LINUX_TDEP_H
-#define ARC_LINUX_TDEP_H
+#ifndef GDB_ARC_LINUX_TDEP_H
+#define GDB_ARC_LINUX_TDEP_H
 
 #include "gdbarch.h"
 #include "regset.h"
@@ -49,4 +49,4 @@ void arc_linux_collect_v2_regset (const struct regset *regset,
 				  const struct regcache *regcache,
 				  int regnum, void *v2_regs, size_t size);
 
-#endif /* ARC_LINUX_TDEP_H */
+#endif /* GDB_ARC_LINUX_TDEP_H */
diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
index c59490dec00..86a483d00c7 100644
--- a/gdb/arc-tdep.h
+++ b/gdb/arc-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARC_TDEP_H
-#define ARC_TDEP_H
+#ifndef GDB_ARC_TDEP_H
+#define GDB_ARC_TDEP_H
 
 /* Need disassemble_info.  */
 #include "dis-asm.h"
@@ -205,4 +205,4 @@ CORE_ADDR arc_insn_get_linear_next_pc (const struct arc_instruction &insn);
 arc_arch_features arc_arch_features_create (const bfd *abfd,
 					    const unsigned long mach);
 
-#endif /* ARC_TDEP_H */
+#endif /* GDB_ARC_TDEP_H */
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 467be40c688..685a0ed0cd9 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_UTILS_H
-#define ARCH_UTILS_H
+#ifndef GDB_ARCH_UTILS_H
+#define GDB_ARCH_UTILS_H
 
 #include "gdbarch.h"
 
@@ -325,4 +325,4 @@ extern enum return_value_convention default_gdbarch_return_value
       struct regcache *regcache, struct value **read_value,
       const gdb_byte *writebuf);
 
-#endif /* ARCH_UTILS_H */
+#endif /* GDB_ARCH_UTILS_H */
diff --git a/gdb/arch/aarch32.h b/gdb/arch/aarch32.h
index 1811b8a7a92..f3e70affb0b 100644
--- a/gdb/arch/aarch32.h
+++ b/gdb/arch/aarch32.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH32_H
-#define ARCH_AARCH32_H
+#ifndef GDB_ARCH_AARCH32_H
+#define GDB_ARCH_AARCH32_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -24,4 +24,4 @@
 
 target_desc *aarch32_create_target_description (bool tls);
 
-#endif /* aarch32.h.  */
+#endif /* GDB_ARCH_AARCH32_H */
diff --git a/gdb/arch/aarch64-insn.h b/gdb/arch/aarch64-insn.h
index e4ee5c74fbf..bd3a85f9686 100644
--- a/gdb/arch/aarch64-insn.h
+++ b/gdb/arch/aarch64-insn.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_INSN_H
-#define ARCH_AARCH64_INSN_H
+#ifndef GDB_ARCH_AARCH64_INSN_H
+#define GDB_ARCH_AARCH64_INSN_H
 
 extern bool aarch64_debug;
 
@@ -356,4 +356,4 @@ int aarch64_emit_load_store (uint32_t *buf, uint32_t size,
 			     struct aarch64_register rn,
 			     struct aarch64_memory_operand operand);
 
-#endif /* ARCH_AARCH64_INSN_H */
+#endif /* GDB_ARCH_AARCH64_INSN_H */
diff --git a/gdb/arch/aarch64-mte-linux.h b/gdb/arch/aarch64-mte-linux.h
index 460b10e05c9..d917dd1b1e3 100644
--- a/gdb/arch/aarch64-mte-linux.h
+++ b/gdb/arch/aarch64-mte-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_MTE_LINUX_H
-#define ARCH_AARCH64_MTE_LINUX_H
+#ifndef GDB_ARCH_AARCH64_MTE_LINUX_H
+#define GDB_ARCH_AARCH64_MTE_LINUX_H
 
 
 /* Feature check for Memory Tagging Extension.  */
@@ -80,4 +80,4 @@ extern void aarch64_mte_pack_tags (gdb::byte_vector &tags);
    first unpacked element.  Otherwise leave it in the unpacked vector.  */
 extern void aarch64_mte_unpack_tags (gdb::byte_vector &tags, bool skip_first);
 
-#endif /* ARCH_AARCH64_MTE_LINUX_H */
+#endif /* GDB_ARCH_AARCH64_MTE_LINUX_H */
diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h
index 4d2ace8f153..886f4a2dee8 100644
--- a/gdb/arch/aarch64-scalable-linux.h
+++ b/gdb/arch/aarch64-scalable-linux.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_SCALABLE_LINUX_H
-#define ARCH_AARCH64_SCALABLE_LINUX_H
+#ifndef GDB_ARCH_AARCH64_SCALABLE_LINUX_H
+#define GDB_ARCH_AARCH64_SCALABLE_LINUX_H
 
 #include "gdbsupport/common-regcache.h"
 
@@ -55,4 +55,4 @@
    is empty (zero).  Return FALSE otherwise.  */
 extern bool sve_state_is_empty (const struct reg_buffer_common *reg_buf);
 
-#endif /* ARCH_AARCH64_SCALABLE_LINUX_H */
+#endif /* GDB_ARCH_AARCH64_SCALABLE_LINUX_H */
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index b4c0111aeb4..f45a0e2f13e 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_H
-#define ARCH_AARCH64_H
+#ifndef GDB_ARCH_AARCH64_H
+#define GDB_ARCH_AARCH64_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -230,4 +230,4 @@ enum aarch64_regnum
 /* Size of the SME2 ZT0 register in bytes.  */
 #define AARCH64_SME2_ZT0_SIZE 64
 
-#endif /* ARCH_AARCH64_H */
+#endif /* GDB_ARCH_AARCH64_H */
diff --git a/gdb/arch/amd64.h b/gdb/arch/amd64.h
index 042d986a694..1c7a2bb26e9 100644
--- a/gdb/arch/amd64.h
+++ b/gdb/arch/amd64.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AMD64_H
-#define ARCH_AMD64_H
+#ifndef GDB_ARCH_AMD64_H
+#define GDB_ARCH_AMD64_H
 
 #include "gdbsupport/tdesc.h"
 #include <stdint.h>
@@ -24,4 +24,4 @@
 target_desc *amd64_create_target_description (uint64_t xcr0, bool is_x32,
 					      bool is_linux, bool segments);
 
-#endif /* ARCH_AMD64_H */
+#endif /* GDB_ARCH_AMD64_H */
diff --git a/gdb/arch/arc.h b/gdb/arch/arc.h
index 1a5a9b6b492..887431ea12a 100644
--- a/gdb/arch/arc.h
+++ b/gdb/arch/arc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARC_H
-#define ARCH_ARC_H
+#ifndef GDB_ARCH_ARC_H
+#define GDB_ARCH_ARC_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -84,4 +84,4 @@ const target_desc *arc_lookup_target_description
 #endif /* GDBSERVER */
 
 
-#endif /* ARCH_ARC_H */
+#endif /* GDB_ARCH_ARC_H */
diff --git a/gdb/arch/arm-get-next-pcs.h b/gdb/arch/arm-get-next-pcs.h
index 77bf0b566a8..7680373c638 100644
--- a/gdb/arch/arm-get-next-pcs.h
+++ b/gdb/arch/arm-get-next-pcs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_GET_NEXT_PCS_H
-#define ARCH_ARM_GET_NEXT_PCS_H
+#ifndef GDB_ARCH_ARM_GET_NEXT_PCS_H
+#define GDB_ARCH_ARM_GET_NEXT_PCS_H
 
 #include <vector>
 
@@ -65,4 +65,4 @@ void arm_get_next_pcs_ctor (struct arm_get_next_pcs *self,
 /* Find the next possible PCs after the current instruction executes.  */
 std::vector<CORE_ADDR> arm_get_next_pcs (struct arm_get_next_pcs *self);
 
-#endif /* ARCH_ARM_GET_NEXT_PCS_H */
+#endif /* GDB_ARCH_ARM_GET_NEXT_PCS_H */
diff --git a/gdb/arch/arm-linux.h b/gdb/arch/arm-linux.h
index 68862521bbc..39c73c34011 100644
--- a/gdb/arch/arm-linux.h
+++ b/gdb/arch/arm-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_LINUX_H
-#define ARCH_ARM_LINUX_H
+#ifndef GDB_ARCH_ARM_LINUX_H
+#define GDB_ARCH_ARM_LINUX_H
 
 /* The index to access CSPR in user_regs defined in GLIBC.  */
 #define ARM_CPSR_GREGNUM 16
@@ -79,4 +79,4 @@ struct arm_get_next_pcs;
 CORE_ADDR arm_linux_get_next_pcs_fixup (struct arm_get_next_pcs *self,
 					CORE_ADDR pc);
 
-#endif /* ARCH_ARM_LINUX_H */
+#endif /* GDB_ARCH_ARM_LINUX_H */
diff --git a/gdb/arch/arm.h b/gdb/arch/arm.h
index 34cf7ca79cf..7738d9c6611 100644
--- a/gdb/arch/arm.h
+++ b/gdb/arch/arm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_H
-#define ARCH_ARM_H
+#ifndef GDB_ARCH_ARM_H
+#define GDB_ARCH_ARM_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -227,4 +227,4 @@ target_desc *arm_create_target_description (arm_fp_type fp_type, bool tls);
 
 target_desc *arm_create_mprofile_target_description (arm_m_profile_type m_type);
 
-#endif /* ARCH_ARM_H */
+#endif /* GDB_ARCH_ARM_H */
diff --git a/gdb/arch/csky.h b/gdb/arch/csky.h
index 290bf97dd12..67b2f176114 100644
--- a/gdb/arch/csky.h
+++ b/gdb/arch/csky.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_CSKY_H
-#define ARCH_CSKY_H
+#ifndef GDB_ARCH_CSKY_H
+#define GDB_ARCH_CSKY_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -26,4 +26,4 @@
 
 target_desc_up csky_create_target_description (void);
 
-#endif /* ARCH_CSKY_H */
+#endif /* GDB_ARCH_CSKY_H */
diff --git a/gdb/arch/i386.h b/gdb/arch/i386.h
index d0519f1b551..1b5cc6e1095 100644
--- a/gdb/arch/i386.h
+++ b/gdb/arch/i386.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_I386_H
-#define ARCH_I386_H
+#ifndef GDB_ARCH_I386_H
+#define GDB_ARCH_I386_H
 
 #include "gdbsupport/tdesc.h"
 #include <stdint.h>
@@ -24,4 +24,4 @@
 target_desc *i386_create_target_description (uint64_t xcr0, bool is_linux,
 					     bool segments);
 
-#endif /* ARCH_I386_H */
+#endif /* GDB_ARCH_I386_H */
diff --git a/gdb/arch/loongarch.h b/gdb/arch/loongarch.h
index 7056d506bf4..07f37d8d7e8 100644
--- a/gdb/arch/loongarch.h
+++ b/gdb/arch/loongarch.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_LOONGARCH_H
-#define ARCH_LOONGARCH_H
+#ifndef GDB_ARCH_LOONGARCH_H
+#define GDB_ARCH_LOONGARCH_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -128,4 +128,4 @@ const target_desc *loongarch_lookup_target_description
 
 #endif /* GDBSERVER */
 
-#endif /* ARCH_LOONGARCH_H  */
+#endif /* GDB_ARCH_LOONGARCH_H */
diff --git a/gdb/arch/ppc-linux-common.h b/gdb/arch/ppc-linux-common.h
index 05704c8f898..1f72b295de8 100644
--- a/gdb/arch/ppc-linux-common.h
+++ b/gdb/arch/ppc-linux-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_PPC_LINUX_COMMON_H
-#define ARCH_PPC_LINUX_COMMON_H
+#ifndef GDB_ARCH_PPC_LINUX_COMMON_H
+#define GDB_ARCH_PPC_LINUX_COMMON_H
 
 struct target_desc;
 
@@ -75,4 +75,4 @@ const struct ppc_linux_features ppc_linux_no_features = {
 const struct target_desc * ppc_linux_match_description
 (struct ppc_linux_features features);
 
-#endif /* ARCH_PPC_LINUX_COMMON_H */
+#endif /* GDB_ARCH_PPC_LINUX_COMMON_H */
diff --git a/gdb/arch/ppc-linux-tdesc.h b/gdb/arch/ppc-linux-tdesc.h
index 0a022071c08..bde6ba225bd 100644
--- a/gdb/arch/ppc-linux-tdesc.h
+++ b/gdb/arch/ppc-linux-tdesc.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_PPC_LINUX_TDESC_H
-#define ARCH_PPC_LINUX_TDESC_H
+#ifndef GDB_ARCH_PPC_LINUX_TDESC_H
+#define GDB_ARCH_PPC_LINUX_TDESC_H
 
 struct target_desc;
 
@@ -43,4 +43,4 @@ extern const struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l;
 extern const struct target_desc *tdesc_powerpc_isa207_vsx64l;
 extern const struct target_desc *tdesc_powerpc_isa207_htm_vsx64l;
 
-#endif /* ARCH_PPC_LINUX_TDESC_H */
+#endif /* GDB_ARCH_PPC_LINUX_TDESC_H */
diff --git a/gdb/arch/riscv.h b/gdb/arch/riscv.h
index 925fffee18a..bf65b0bc5a8 100644
--- a/gdb/arch/riscv.h
+++ b/gdb/arch/riscv.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_RISCV_H
-#define ARCH_RISCV_H
+#ifndef GDB_ARCH_RISCV_H
+#define GDB_ARCH_RISCV_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -119,4 +119,4 @@ const target_desc *riscv_lookup_target_description
 #endif /* GDBSERVER */
 
 
-#endif /* ARCH_RISCV_H */
+#endif /* GDB_ARCH_RISCV_H */
diff --git a/gdb/arch/tic6x.h b/gdb/arch/tic6x.h
index da67da7c5fb..efb3282c506 100644
--- a/gdb/arch/tic6x.h
+++ b/gdb/arch/tic6x.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_TIC6X_H
-#define ARCH_TIC6X_H
+#ifndef GDB_ARCH_TIC6X_H
+#define GDB_ARCH_TIC6X_H
 
 enum c6x_feature
 {
@@ -28,4 +28,4 @@ enum c6x_feature
 
 target_desc *tic6x_create_target_description (enum c6x_feature feature);
 
-#endif /* ARCH_TIC6X_H */
+#endif /* GDB_ARCH_TIC6X_H */
diff --git a/gdb/arch/xtensa.h b/gdb/arch/xtensa.h
index 5961641cad8..70167b304ce 100644
--- a/gdb/arch/xtensa.h
+++ b/gdb/arch/xtensa.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_XTENSA_H
-#define ARCH_XTENSA_H
+#ifndef GDB_ARCH_XTENSA_H
+#define GDB_ARCH_XTENSA_H
 
 /* Xtensa ELF core file register set representation ('.reg' section).
    Copied from target-side ELF header <xtensa/elf.h>.  */
@@ -45,4 +45,4 @@ typedef struct
 
 #define C0_NREGS   16	/* Number of A-registers to track in call0 ABI.  */
 
-#endif /* ARCH_XTENSA_H */
+#endif /* GDB_ARCH_XTENSA_H */
diff --git a/gdb/arm-fbsd-tdep.h b/gdb/arm-fbsd-tdep.h
index 26a9dbcdd21..151f26c83b7 100644
--- a/gdb/arm-fbsd-tdep.h
+++ b/gdb/arm-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_FBSD_TDEP_H
-#define ARM_FBSD_TDEP_H
+#ifndef GDB_ARM_FBSD_TDEP_H
+#define GDB_ARM_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -56,4 +56,4 @@ extern const struct target_desc *
 extern const struct target_desc *
   arm_fbsd_read_description_auxv (bool tls);
 
-#endif /* ARM_FBSD_TDEP_H */
+#endif /* GDB_ARM_FBSD_TDEP_H */
diff --git a/gdb/arm-linux-tdep.h b/gdb/arm-linux-tdep.h
index a6eeb333351..7aa69ce3f4c 100644
--- a/gdb/arm-linux-tdep.h
+++ b/gdb/arm-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_LINUX_TDEP_H
-#define ARM_LINUX_TDEP_H
+#ifndef GDB_ARM_LINUX_TDEP_H
+#define GDB_ARM_LINUX_TDEP_H
 
 struct regset;
 struct regcache;
@@ -67,4 +67,4 @@ void arm_linux_collect_nwfpe (const struct regset *regset,
 #define HWCAP_VFPv3     8192
 #define HWCAP_VFPv3D16  16384
 
-#endif /* ARM_LINUX_TDEP_H */
+#endif /* GDB_ARM_LINUX_TDEP_H */
diff --git a/gdb/arm-netbsd-tdep.h b/gdb/arm-netbsd-tdep.h
index 75b1fb9bd27..6e554d4ca21 100644
--- a/gdb/arm-netbsd-tdep.h
+++ b/gdb/arm-netbsd-tdep.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_NBSD_TDEP_H
-#define ARM_NBSD_TDEP_H
+#ifndef GDB_ARM_NETBSD_TDEP_H
+#define GDB_ARM_NETBSD_TDEP_H
 
 void arm_nbsd_supply_gregset
   (const struct regset *regset, struct regcache *regcache,
    int regnum, const void *gregs, size_t len);
 
-#endif
+#endif /* GDB_ARM_NETBSD_TDEP_H */
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 11839b0ff4d..f8049f4673c 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_TDEP_H
-#define ARM_TDEP_H
+#ifndef GDB_ARM_TDEP_H
+#define GDB_ARM_TDEP_H
 
 /* Forward declarations.  */
 struct regset;
@@ -326,4 +326,4 @@ const target_desc *arm_read_description (arm_fp_type fp_type, bool tls);
    type.  */
 const target_desc *arm_read_mprofile_description (arm_m_profile_type m_type);
 
-#endif /* arm-tdep.h */
+#endif /* GDB_ARM_TDEP_H */
diff --git a/gdb/async-event.h b/gdb/async-event.h
index 1027f9d6fb3..16045f42448 100644
--- a/gdb/async-event.h
+++ b/gdb/async-event.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ASYNC_EVENT_H
-#define ASYNC_EVENT_H
+#ifndef GDB_ASYNC_EVENT_H
+#define GDB_ASYNC_EVENT_H
 
 #include "gdbsupport/event-loop.h"
 
@@ -87,4 +87,4 @@ extern void clear_async_event_handler (struct async_event_handler *handler);
 
 extern void initialize_async_signal_handlers (void);
 
-#endif /* ASYNC_EVENT_H */
+#endif /* GDB_ASYNC_EVENT_H */
diff --git a/gdb/auto-load.h b/gdb/auto-load.h
index c1003aef0e3..48e6ccfc82f 100644
--- a/gdb/auto-load.h
+++ b/gdb/auto-load.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AUTO_LOAD_H
-#define AUTO_LOAD_H 1
+#ifndef GDB_AUTO_LOAD_H
+#define GDB_AUTO_LOAD_H
 
 struct objfile;
 struct program_space;
@@ -79,4 +79,4 @@ extern bool file_is_auto_load_safe (const char *filename);
 extern bool auto_load_gdb_scripts_enabled
   (const struct extension_language_defn *extlang);
 
-#endif /* AUTO_LOAD_H */
+#endif /* GDB_AUTO_LOAD_H */
diff --git a/gdb/auxv.h b/gdb/auxv.h
index aed430dd851..3faddff7771 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AUXV_H
-#define AUXV_H
+#ifndef GDB_AUXV_H
+#define GDB_AUXV_H
 
 #include "target.h"
 
@@ -88,4 +88,4 @@ extern void default_print_auxv_entry (struct gdbarch *gdbarch,
 extern target_xfer_partial_ftype memory_xfer_auxv;
 
 
-#endif
+#endif /* GDB_AUXV_H */
diff --git a/gdb/ax-gdb.h b/gdb/ax-gdb.h
index 9e2dfea1c51..53f48ff9e33 100644
--- a/gdb/ax-gdb.h
+++ b/gdb/ax-gdb.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AX_GDB_H
-#define AX_GDB_H
+#ifndef GDB_AX_GDB_H
+#define GDB_AX_GDB_H
 
 #include "ax.h"
 
@@ -123,4 +123,4 @@ extern agent_expr_up gen_printf (CORE_ADDR, struct gdbarch *,
 				 CORE_ADDR, LONGEST, const char *, int,
 				 int, struct expression **);
 
-#endif /* AX_GDB_H */
+#endif /* GDB_AX_GDB_H */
diff --git a/gdb/ax.h b/gdb/ax.h
index 46c2393f9e0..45fd560927b 100644
--- a/gdb/ax.h
+++ b/gdb/ax.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AX_H
-#define AX_H
+#ifndef GDB_AX_H
+#define GDB_AX_H
 
 /* It's sometimes useful to be able to debug programs that you can't
    really stop for more than a fraction of a second.  To this end, the
@@ -224,4 +224,4 @@ extern void ax_print (struct ui_file *f, struct agent_expr * EXPR);
 
 extern void ax_reqs (struct agent_expr *ax);
 
-#endif /* AX_H */
+#endif /* GDB_AX_H */
diff --git a/gdb/bcache.h b/gdb/bcache.h
index 17a09880d99..abe9e58c116 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BCACHE_H
-#define BCACHE_H 1
+#ifndef GDB_BCACHE_H
+#define GDB_BCACHE_H
 
 /* A bcache is a data structure for factoring out duplication in
    read-only structures.  You give the bcache some string of bytes S.
@@ -207,4 +207,4 @@ struct bcache
 
 } /* namespace gdb */
 
-#endif /* BCACHE_H */
+#endif /* GDB_BCACHE_H */
diff --git a/gdb/bfd-target.h b/gdb/bfd-target.h
index d20c9263c4b..ab3233e8f6f 100644
--- a/gdb/bfd-target.h
+++ b/gdb/bfd-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BFD_TARGET_H
-#define BFD_TARGET_H
+#ifndef GDB_BFD_TARGET_H
+#define GDB_BFD_TARGET_H
 
 #include "gdb_bfd.h"
 
@@ -27,4 +27,4 @@ struct target_ops;
 /* Given an existing BFD, re-open it as a "struct target_ops".  */
 target_ops_up target_bfd_reopen (const gdb_bfd_ref_ptr &bfd);
 
-#endif
+#endif /* GDB_BFD_TARGET_H */
diff --git a/gdb/bfin-tdep.h b/gdb/bfin-tdep.h
index dbdafae9d45..d28af50406f 100644
--- a/gdb/bfin-tdep.h
+++ b/gdb/bfin-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BFIN_TDEP_H
-#define BFIN_TDEP_H
+#ifndef GDB_BFIN_TDEP_H
+#define GDB_BFIN_TDEP_H
 
 #include "gdbarch.h"
 
@@ -105,4 +105,4 @@ struct bfin_gdbarch_tdep : gdbarch_tdep_base
 /* Return the Blackfin ABI associated with GDBARCH.  */
 extern enum bfin_abi bfin_abi (struct gdbarch *gdbarch);
 
-#endif /* BFIN_TDEP_H */
+#endif /* GDB_BFIN_TDEP_H */
diff --git a/gdb/block.h b/gdb/block.h
index ae676c4ba67..0cc4d7d53f7 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BLOCK_H
-#define BLOCK_H
+#ifndef GDB_BLOCK_H
+#define GDB_BLOCK_H
 
 #include "dictionary.h"
 #include "gdbsupport/array-view.h"
@@ -592,4 +592,4 @@ extern struct symbol *block_find_symbol (const struct block *block,
 struct blockranges *make_blockranges (struct objfile *objfile,
 				      const std::vector<blockrange> &rangevec);
 
-#endif /* BLOCK_H */
+#endif /* GDB_BLOCK_H */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 6da04d5ec00..4db18274e55 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (BREAKPOINT_H)
-#define BREAKPOINT_H 1
+#ifndef GDB_BREAKPOINT_H
+#define GDB_BREAKPOINT_H
 
 #include "frame.h"
 #include "value.h"
@@ -2068,4 +2068,4 @@ extern void enable_disable_bp_location (bp_location *loc, bool enable);
 
 extern void notify_breakpoint_modified (breakpoint *b);
 
-#endif /* !defined (BREAKPOINT_H) */
+#endif /* GDB_BREAKPOINT_H */
diff --git a/gdb/bsd-kvm.h b/gdb/bsd-kvm.h
index 1606eb3acea..6ddd154da4a 100644
--- a/gdb/bsd-kvm.h
+++ b/gdb/bsd-kvm.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BSD_KVM_H
-#define BSD_KVM_H
+#ifndef GDB_BSD_KVM_H
+#define GDB_BSD_KVM_H
 
 struct pcb;
 struct regcache;
@@ -30,4 +30,4 @@ struct regcache;
 extern void
   bsd_kvm_add_target (int (*supply_pcb)(struct regcache *, struct pcb *));
 
-#endif /* bsd-kvm.h */
+#endif /* GDB_BSD_KVM_H */
diff --git a/gdb/bsd-uthread.h b/gdb/bsd-uthread.h
index eabd82dbdaf..e236eaae4f6 100644
--- a/gdb/bsd-uthread.h
+++ b/gdb/bsd-uthread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BSD_UTHREAD_H
-#define BSD_UTHREAD_H 1
+#ifndef GDB_BSD_UTHREAD_H
+#define GDB_BSD_UTHREAD_H
 
 /* Set the function that supplies registers for an inactive thread for
    architecture GDBARCH to SUPPLY_UTHREAD.  */
@@ -35,4 +35,4 @@ extern void bsd_uthread_set_collect_uthread (struct gdbarch *gdbarch,
 			     void (*collect_uthread) (const struct regcache *,
 						      int, CORE_ADDR));
 
-#endif /* bsd-uthread.h */
+#endif /* GDB_BSD_UTHREAD_H */
diff --git a/gdb/bt-utils.h b/gdb/bt-utils.h
index ec2d14a5484..819dd8caf86 100644
--- a/gdb/bt-utils.h
+++ b/gdb/bt-utils.h
@@ -18,8 +18,8 @@
 /* Support for printing a backtrace when GDB hits an error.  This is not
    for printing backtraces of the inferior, but backtraces of GDB itself.  */
 
-#ifndef BT_UTILS_H
-#define BT_UTILS_H
+#ifndef GDB_BT_UTILS_H
+#define GDB_BT_UTILS_H
 
 #ifdef HAVE_LIBBACKTRACE
 # include "backtrace.h"
@@ -71,4 +71,4 @@ extern void gdb_internal_backtrace ();
 extern void gdb_internal_backtrace_set_cmd (const char *args, int from_tty,
 					    cmd_list_element *c);
 
-#endif /* BT_UTILS_H */
+#endif /* GDB_BT_UTILS_H */
diff --git a/gdb/btrace.h b/gdb/btrace.h
index f05ec2bca04..dc9541960e0 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BTRACE_H
-#define BTRACE_H
+#ifndef GDB_BTRACE_H
+#define GDB_BTRACE_H
 
 /* Branch tracing (btrace) is a per-thread control-flow execution trace of the
    inferior.  For presentation purposes, the branch trace is represented as a
@@ -498,4 +498,4 @@ extern int btrace_is_replaying (struct thread_info *tp);
 /* Return non-zero if the branch trace for TP is empty; zero otherwise.  */
 extern int btrace_is_empty (struct thread_info *tp);
 
-#endif /* BTRACE_H */
+#endif /* GDB_BTRACE_H */
diff --git a/gdb/build-id.h b/gdb/build-id.h
index 15bd8a964dc..5bf338299b1 100644
--- a/gdb/build-id.h
+++ b/gdb/build-id.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BUILD_ID_H
-#define BUILD_ID_H
+#ifndef GDB_BUILD_ID_H
+#define GDB_BUILD_ID_H
 
 #include "gdb_bfd.h"
 #include "gdbsupport/rsp-low.h"
@@ -70,4 +70,4 @@ build_id_to_string (const bfd_build_id *build_id)
   return bin2hex (build_id->data, build_id->size);
 }
 
-#endif /* BUILD_ID_H */
+#endif /* GDB_BUILD_ID_H */
diff --git a/gdb/buildsym-legacy.h b/gdb/buildsym-legacy.h
index 1fb545831b8..1f032c42751 100644
--- a/gdb/buildsym-legacy.h
+++ b/gdb/buildsym-legacy.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BUILDSYM_LEGACY_H
-#define BUILDSYM_LEGACY_H
+#ifndef GDB_BUILDSYM_LEGACY_H
+#define GDB_BUILDSYM_LEGACY_H
 
 #include "buildsym.h"
 
@@ -144,4 +144,4 @@ extern struct pending **get_global_symbols ();
 
 extern struct buildsym_compunit *get_buildsym_compunit ();
 
-#endif /* BUILDSYM_LEGACY_H */
+#endif /* GDB_BUILDSYM_LEGACY_H */
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index c1eed247d25..974645c1c47 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (BUILDSYM_H)
-#define BUILDSYM_H 1
+#ifndef GDB_BUILDSYM_H
+#define GDB_BUILDSYM_H
 
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
@@ -456,4 +456,4 @@ extern void add_symbol_to_list (struct symbol *symbol,
 extern struct symbol *find_symbol_in_list (struct pending *list,
 					   char *name, int length);
 
-#endif /* defined (BUILDSYM_H) */
+#endif /* GDB_BUILDSYM_H */
diff --git a/gdb/c-exp.h b/gdb/c-exp.h
index a76f1bc8213..a6c084d32be 100644
--- a/gdb/c-exp.h
+++ b/gdb/c-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef C_EXP_H
-#define C_EXP_H
+#ifndef GDB_C_EXP_H
+#define GDB_C_EXP_H
 
 #include "expop.h"
 #include "objc-lang.h"
@@ -217,4 +217,4 @@ class opencl_ternop_cond_operation
 
 }/* namespace expr */
 
-#endif /* C_EXP_H */
+#endif /* GDB_C_EXP_H */
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 8dc47ac8be5..0e733d810d8 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#if !defined (C_LANG_H)
-#define C_LANG_H 1
+#ifndef GDB_C_LANG_H
+#define GDB_C_LANG_H
 
 struct ui_file;
 struct language_arch_info;
@@ -174,4 +174,4 @@ extern std::string cplus_compute_program (compile_instance *inst,
 
 extern gdb::unique_xmalloc_ptr<char> c_canonicalize_name (const char *name);
 
-#endif /* !defined (C_LANG_H) */
+#endif /* GDB_C_LANG_H */
diff --git a/gdb/c-support.h b/gdb/c-support.h
index 3718181ba81..30858d1e1af 100644
--- a/gdb/c-support.h
+++ b/gdb/c-support.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef C_SUPPORT_H
-#define C_SUPPORT_H
+#ifndef GDB_C_SUPPORT_H
+#define GDB_C_SUPPORT_H
 
 #include "safe-ctype.h"
 
@@ -43,4 +43,4 @@ c_ident_is_alnum (unsigned char ch)
   return ISALNUM (ch) || ch >= 0x80;
 }
 
-#endif /* C_SUPPORT_H */
+#endif /* GDB_C_SUPPORT_H */
diff --git a/gdb/cgen-remap.h b/gdb/cgen-remap.h
index 35f09c1269b..30b84575263 100644
--- a/gdb/cgen-remap.h
+++ b/gdb/cgen-remap.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CGEN_REMAP_H
-#define CGEN_REMAP_H
+#ifndef GDB_CGEN_REMAP_H
+#define GDB_CGEN_REMAP_H
 
 /* Remap cgen interface names, so we can have multiple cgen generated include
    files in gdb without violating c++ ODR.  */
@@ -50,4 +50,4 @@
 #define CGEN_OPERAND		GDB_CGEN_REMAP (CGEN_OPERAND)
 #define CGEN_MAYBE_MULTI_IFLD	GDB_CGEN_REMAP (CGEN_MAYBE_MULTI_IFLD)
 
-#endif /* CGEN_REMAP_H */
+#endif /* GDB_CGEN_REMAP_H */
diff --git a/gdb/charset-list.h b/gdb/charset-list.h
index c4d0867d580..9da3da2590a 100644
--- a/gdb/charset-list.h
+++ b/gdb/charset-list.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CHARSET_LIST_H
-#define CHARSET_LIST_H
+#ifndef GDB_CHARSET_LIST_H
+#define GDB_CHARSET_LIST_H
 
 /* Note that the first entry must always be "auto".
    The remaining entries were created by running this script:
@@ -1192,4 +1192,4 @@
 "WS2", \
 "YU",
 
-#endif /* CHARSET_LIST_H */
+#endif /* GDB_CHARSET_LIST_H */
diff --git a/gdb/charset.h b/gdb/charset.h
index 4263dc147e9..c4e0de553d3 100644
--- a/gdb/charset.h
+++ b/gdb/charset.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CHARSET_H
-#define CHARSET_H
+#ifndef GDB_CHARSET_H
+#define GDB_CHARSET_H
 
 #include "gdbsupport/def-vector.h"
 
@@ -165,4 +165,4 @@ char host_letter_to_control_character (char c);
 #define HOST_UTF32 "UTF-32LE"
 #endif
 
-#endif /* CHARSET_H */
+#endif /* GDB_CHARSET_H */
diff --git a/gdb/cli-out.h b/gdb/cli-out.h
index f17cb0c9856..5799df559f4 100644
--- a/gdb/cli-out.h
+++ b/gdb/cli-out.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_OUT_H
-#define CLI_OUT_H
+#ifndef GDB_CLI_OUT_H
+#define GDB_CLI_OUT_H
 
 #include "ui-out.h"
 #include <chrono>
@@ -112,4 +112,4 @@ class cli_ui_out : public ui_out
 
 extern void cli_display_match_list (char **matches, int len, int max);
 
-#endif
+#endif /* GDB_CLI_OUT_H */
diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h
index 8f26ca3e17a..6719ad7cae3 100644
--- a/gdb/cli/cli-cmds.h
+++ b/gdb/cli/cli-cmds.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_CMDS_H
-#define CLI_CLI_CMDS_H
+#ifndef GDB_CLI_CLI_CMDS_H
+#define GDB_CLI_CLI_CMDS_H
 
 #include "gdbsupport/filestuff.h"
 #include <optional>
@@ -202,4 +202,4 @@ extern void with_command_completer_1 (const char *set_cmd_prefix,
 				      completion_tracker &tracker,
 				      const char *text);
 
-#endif /* CLI_CLI_CMDS_H */
+#endif /* GDB_CLI_CLI_CMDS_H */
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 7365c3f0157..2219d62fbf3 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_DECODE_H
-#define CLI_CLI_DECODE_H
+#ifndef GDB_CLI_CLI_DECODE_H
+#define GDB_CLI_CLI_DECODE_H
 
 /* This file defines the private interfaces for any code implementing
    command internals.  */
@@ -313,4 +313,4 @@ extern int cli_user_command_p (struct cmd_list_element *);
 
 extern int find_command_name_length (const char *);
 
-#endif /* CLI_CLI_DECODE_H */
+#endif /* GDB_CLI_CLI_DECODE_H */
diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h
index 137eb466f6b..fc3dee7b68b 100644
--- a/gdb/cli/cli-interp.h
+++ b/gdb/cli/cli-interp.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_INTERP_H
-#define CLI_CLI_INTERP_H
+#ifndef GDB_CLI_CLI_INTERP_H
+#define GDB_CLI_CLI_INTERP_H
 
 #include "interps.h"
 
@@ -69,4 +69,4 @@ class cli_interp_base : public interp
 extern int should_print_stop_to_console (struct interp *interp,
 					 struct thread_info *tp);
 
-#endif /* CLI_CLI_INTERP_H */
+#endif /* GDB_CLI_CLI_INTERP_H */
diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h
index bbe281d9721..35e5bdcd684 100644
--- a/gdb/cli/cli-option.h
+++ b/gdb/cli/cli-option.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_OPTION_H
-#define CLI_OPTION_H 1
+#ifndef GDB_CLI_CLI_OPTION_H
+#define GDB_CLI_CLI_OPTION_H
 
 #include <optional>
 #include "gdbsupport/array-view.h"
@@ -379,4 +379,4 @@ extern void add_setshow_cmds_for_options (command_class cmd_class, void *data,
 } /* namespace option */
 } /* namespace gdb */
 
-#endif /* CLI_OPTION_H */
+#endif /* GDB_CLI_CLI_OPTION_H */
diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h
index d36743e5a31..1f0cfd3c1dd 100644
--- a/gdb/cli/cli-script.h
+++ b/gdb/cli/cli-script.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_SCRIPT_H
-#define CLI_CLI_SCRIPT_H
+#ifndef GDB_CLI_CLI_SCRIPT_H
+#define GDB_CLI_CLI_SCRIPT_H
 
 #include "gdbsupport/function-view.h"
 
@@ -181,4 +181,4 @@ extern void print_command_trace (const char *cmd, ...)
 
 extern void reset_command_nest_depth (void);
 
-#endif /* CLI_CLI_SCRIPT_H */
+#endif /* GDB_CLI_CLI_SCRIPT_H */
diff --git a/gdb/cli/cli-setshow.h b/gdb/cli/cli-setshow.h
index 4b8875d5794..9eac86fc674 100644
--- a/gdb/cli/cli-setshow.h
+++ b/gdb/cli/cli-setshow.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_SETSHOW_H
-#define CLI_CLI_SETSHOW_H
+#ifndef GDB_CLI_CLI_SETSHOW_H
+#define GDB_CLI_CLI_SETSHOW_H
 
 #include <string>
 
@@ -60,4 +60,4 @@ extern std::string get_setshow_command_value_string (const setting &var);
 
 extern void cmd_show_list (struct cmd_list_element *list, int from_tty);
 
-#endif /* CLI_CLI_SETSHOW_H */
+#endif /* GDB_CLI_CLI_SETSHOW_H */
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index 31d40ed65ca..1a9c8e65b60 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_STYLE_H
-#define CLI_CLI_STYLE_H
+#ifndef GDB_CLI_CLI_STYLE_H
+#define GDB_CLI_CLI_STYLE_H
 
 #include "ui-file.h"
 #include "command.h"
@@ -150,4 +150,4 @@ extern bool disassembler_styling;
 /* True if styling is enabled.  */
 extern bool cli_styling;
 
-#endif /* CLI_CLI_STYLE_H */
+#endif /* GDB_CLI_CLI_STYLE_H */
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index 54b45fdc796..e11430ecb70 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_UTILS_H
-#define CLI_CLI_UTILS_H
+#ifndef GDB_CLI_CLI_UTILS_H
+#define GDB_CLI_CLI_UTILS_H
 
 #include "completer.h"
 
@@ -225,4 +225,4 @@ struct qcs_flags
    message.  */
 extern void validate_flags_qcs (const char *which_command, qcs_flags *flags);
 
-#endif /* CLI_CLI_UTILS_H */
+#endif /* GDB_CLI_CLI_UTILS_H */
diff --git a/gdb/coff-pe-read.h b/gdb/coff-pe-read.h
index d596240f97d..c1510460f9b 100644
--- a/gdb/coff-pe-read.h
+++ b/gdb/coff-pe-read.h
@@ -19,8 +19,8 @@
 
    Contributed by Raoul M. Gough (RaoulGough@yahoo.co.uk).  */
 
-#if !defined (COFF_PE_READ_H)
-#define COFF_PE_READ_H
+#ifndef GDB_COFF_PE_READ_H
+#define GDB_COFF_PE_READ_H
 
 class minimal_symbol_reader;
 struct objfile;
@@ -35,4 +35,4 @@ extern void read_pe_exported_syms (minimal_symbol_reader &reader,
    Returns default value 0x1000 if information is not found.  */
 extern CORE_ADDR pe_text_section_offset (struct bfd *abfd);
 
-#endif /* !defined (COFF_PE_READ_H) */
+#endif /* GDB_COFF_PE_READ_H */
diff --git a/gdb/command.h b/gdb/command.h
index 615f4e524aa..4f83d3515c3 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (COMMAND_H)
-#define COMMAND_H 1
+#ifndef GDB_COMMAND_H
+#define GDB_COMMAND_H
 
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbsupport/scoped_restore.h"
@@ -934,4 +934,4 @@ extern void not_just_help_class_command (const char *, int);
 extern void cmd_func (struct cmd_list_element *cmd,
 		      const char *args, int from_tty);
 
-#endif /* !defined (COMMAND_H) */
+#endif /* GDB_COMMAND_H */
diff --git a/gdb/compile/compile-c.h b/gdb/compile/compile-c.h
index 4670d671a9f..b77b7aab087 100644
--- a/gdb/compile/compile-c.h
+++ b/gdb/compile/compile-c.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_C_H
-#define COMPILE_COMPILE_C_H
+#ifndef GDB_COMPILE_COMPILE_C_H
+#define GDB_COMPILE_COMPILE_C_H
 
 #include "compile/compile.h"
 #include "gdbsupport/enum-flags.h"
@@ -93,4 +93,4 @@ extern std::string c_get_range_decl_name (const struct dynamic_prop *prop);
 extern gdb::unique_xmalloc_ptr<char>
   c_symbol_substitution_name (struct symbol *sym);
 
-#endif /* COMPILE_COMPILE_C_H */
+#endif /* GDB_COMPILE_COMPILE_C_H */
diff --git a/gdb/compile/compile-cplus.h b/gdb/compile/compile-cplus.h
index a714b6dab3c..d3b2d3e9843 100644
--- a/gdb/compile/compile-cplus.h
+++ b/gdb/compile/compile-cplus.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_CPLUS_H
-#define COMPILE_COMPILE_CPLUS_H
+#ifndef GDB_COMPILE_COMPILE_CPLUS_H
+#define GDB_COMPILE_COMPILE_CPLUS_H
 
 #include "compile/compile.h"
 #include "gdbsupport/enum-flags.h"
@@ -204,4 +204,4 @@ class compile_cplus_instance : public compile_instance
 enum gcc_cp_symbol_kind get_method_access_flag (const struct type *type,
 						int fni, int num);
 
-#endif /* COMPILE_COMPILE_CPLUS_H */
+#endif /* GDB_COMPILE_COMPILE_CPLUS_H */
diff --git a/gdb/compile/compile-internal.h b/gdb/compile/compile-internal.h
index 666406b2395..f4cc9ee4984 100644
--- a/gdb/compile/compile-internal.h
+++ b/gdb/compile/compile-internal.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_INTERNAL_H
-#define COMPILE_COMPILE_INTERNAL_H
+#ifndef GDB_COMPILE_COMPILE_INTERNAL_H
+#define GDB_COMPILE_COMPILE_INTERNAL_H
 
 #include "gcc-c-interface.h"
 #include "gdbsupport/gdb-hashtab.h"
@@ -80,4 +80,4 @@ class compile_file_names
   std::string m_object_file;
 };
 
-#endif /* COMPILE_COMPILE_INTERNAL_H */
+#endif /* GDB_COMPILE_COMPILE_INTERNAL_H */
diff --git a/gdb/compile/compile-object-load.h b/gdb/compile/compile-object-load.h
index eb6eb0dd871..bb414f90df4 100644
--- a/gdb/compile/compile-object-load.h
+++ b/gdb/compile/compile-object-load.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_OBJECT_LOAD_H
-#define COMPILE_COMPILE_OBJECT_LOAD_H
+#ifndef GDB_COMPILE_COMPILE_OBJECT_LOAD_H
+#define GDB_COMPILE_COMPILE_OBJECT_LOAD_H
 
 #include "compile-internal.h"
 #include <list>
@@ -94,4 +94,4 @@ extern compile_module_up compile_object_load
   (const compile_file_names &fnames,
    enum compile_i_scope_types scope, void *scope_data);
 
-#endif /* COMPILE_COMPILE_OBJECT_LOAD_H */
+#endif /* GDB_COMPILE_COMPILE_OBJECT_LOAD_H */
diff --git a/gdb/compile/compile-object-run.h b/gdb/compile/compile-object-run.h
index 5d9f23c6a39..64b2bd90a99 100644
--- a/gdb/compile/compile-object-run.h
+++ b/gdb/compile/compile-object-run.h
@@ -14,11 +14,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_OBJECT_RUN_H
-#define COMPILE_COMPILE_OBJECT_RUN_H
+#ifndef GDB_COMPILE_COMPILE_OBJECT_RUN_H
+#define GDB_COMPILE_COMPILE_OBJECT_RUN_H
 
 #include "compile-object-load.h"
 
 extern void compile_object_run (compile_module_up &&module);
 
-#endif /* COMPILE_COMPILE_OBJECT_RUN_H */
+#endif /* GDB_COMPILE_COMPILE_OBJECT_RUN_H */
diff --git a/gdb/compile/compile.h b/gdb/compile/compile.h
index d584df6661c..14b97c4b91c 100644
--- a/gdb/compile/compile.h
+++ b/gdb/compile/compile.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_H
-#define COMPILE_COMPILE_H
+#ifndef GDB_COMPILE_COMPILE_H
+#define GDB_COMPILE_COMPILE_H
 
 #include "gcc-c-interface.h"
 
@@ -231,4 +231,4 @@ extern void compile_print_value (struct value *val, void *data_voidp);
 /* Command element for the 'compile' command.  */
 extern cmd_list_element *compile_cmd_element;
 
-#endif /* COMPILE_COMPILE_H */
+#endif /* GDB_COMPILE_COMPILE_H */
diff --git a/gdb/compile/gcc-c-plugin.h b/gdb/compile/gcc-c-plugin.h
index 4008807526b..d12472f01c1 100644
--- a/gdb/compile/gcc-c-plugin.h
+++ b/gdb/compile/gcc-c-plugin.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_GCC_C_PLUGIN_H
-#define COMPILE_GCC_C_PLUGIN_H
+#ifndef GDB_COMPILE_GCC_C_PLUGIN_H
+#define GDB_COMPILE_GCC_C_PLUGIN_H
 
 #include "compile-internal.h"
 
@@ -68,4 +68,4 @@ class gcc_c_plugin
   struct gcc_c_context *m_context;
 };
 
-#endif /* COMPILE_GCC_C_PLUGIN_H */
+#endif /* GDB_COMPILE_GCC_C_PLUGIN_H */
diff --git a/gdb/compile/gcc-cp-plugin.h b/gdb/compile/gcc-cp-plugin.h
index cf8ccd90725..8f369934127 100644
--- a/gdb/compile/gcc-cp-plugin.h
+++ b/gdb/compile/gcc-cp-plugin.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_GCC_CP_PLUGIN_H
-#define COMPILE_GCC_CP_PLUGIN_H
+#ifndef GDB_COMPILE_GCC_CP_PLUGIN_H
+#define GDB_COMPILE_GCC_CP_PLUGIN_H
 
 /* A class representing the GCC C++ plug-in.  */
 
@@ -87,4 +87,4 @@ class gcc_cp_plugin
   struct gcc_cp_context *m_context;
 };
 
-#endif /* COMPILE_GCC_CP_PLUGIN_H */
+#endif /* GDB_COMPILE_GCC_CP_PLUGIN_H */
diff --git a/gdb/complaints.h b/gdb/complaints.h
index 995c35e0ab0..ab91d05b8a0 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#if !defined (COMPLAINTS_H)
-#define COMPLAINTS_H
+#ifndef GDB_COMPLAINTS_H
+#define GDB_COMPLAINTS_H
 
 #include <unordered_set>
 
@@ -109,4 +109,4 @@ class complaint_interceptor final : public warning_hook_handler_type
 
 extern void re_emit_complaints (const complaint_collection &);
 
-#endif /* !defined (COMPLAINTS_H) */
+#endif /* GDB_COMPLAINTS_H */
diff --git a/gdb/completer.h b/gdb/completer.h
index 98a12f3907c..9ca97c2b435 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (COMPLETER_H)
-#define COMPLETER_H 1
+#ifndef GDB_COMPLETER_H
+#define GDB_COMPLETER_H
 
 #include "gdbsupport/gdb-hashtab.h"
 #include "gdbsupport/gdb_vecs.h"
@@ -661,4 +661,4 @@ extern bool skip_over_slash_fmt (completion_tracker &tracker,
 
 extern int max_completions;
 
-#endif /* defined (COMPLETER_H) */
+#endif /* GDB_COMPLETER_H */
diff --git a/gdb/config/nm-linux.h b/gdb/config/nm-linux.h
index 4ac42cdae1a..d599d3fdef5 100644
--- a/gdb/config/nm-linux.h
+++ b/gdb/config/nm-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CONFIG_NM_LINUX_H
-#define CONFIG_NM_LINUX_H
+#ifndef GDB_CONFIG_NM_LINUX_H
+#define GDB_CONFIG_NM_LINUX_H
 
 /* Use elf_gregset_t and elf_fpregset_t, rather than
    gregset_t and fpregset_t.  */
@@ -26,4 +26,4 @@
 #define GDB_GREGSET_T  elf_gregset_t
 #define GDB_FPREGSET_T elf_fpregset_t
 
-#endif /* CONFIG_NM_LINUX_H */
+#endif /* GDB_CONFIG_NM_LINUX_H */
diff --git a/gdb/config/nm-nto.h b/gdb/config/nm-nto.h
index 5a002df5548..b06cd1f5e03 100644
--- a/gdb/config/nm-nto.h
+++ b/gdb/config/nm-nto.h
@@ -19,11 +19,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CONFIG_NM_NTO_H
-#define CONFIG_NM_NTO_H
+#ifndef GDB_CONFIG_NM_NTO_H
+#define GDB_CONFIG_NM_NTO_H
 
 /* Setup the valid realtime signal range.  */
 #define REALTIME_LO 41
 #define REALTIME_HI 56
 
-#endif /* CONFIG_NM_NTO_H */
+#endif /* GDB_CONFIG_NM_NTO_H */
diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h
index fdbe4843129..6c8d9043463 100644
--- a/gdb/cp-abi.h
+++ b/gdb/cp-abi.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CP_ABI_H
-#define CP_ABI_H
+#ifndef GDB_CP_ABI_H
+#define GDB_CP_ABI_H
 
 struct fn_field;
 struct type;
@@ -255,4 +255,4 @@ struct cp_abi_ops
 extern int register_cp_abi (struct cp_abi_ops *abi);
 extern void set_cp_abi_as_auto_default (const char *short_name);
 
-#endif /* CP_ABI_H */
+#endif /* GDB_CP_ABI_H */
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 4015126154b..e2d480b2f16 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CP_SUPPORT_H
-#define CP_SUPPORT_H
+#ifndef GDB_CP_SUPPORT_H
+#define GDB_CP_SUPPORT_H
 
 #include "symtab.h"
 #include "gdbsupport/gdb_vecs.h"
@@ -212,4 +212,4 @@ extern char *gdb_cplus_demangle_print (int options,
 
 extern const char *find_toplevel_char (const char *s, char c);
 
-#endif /* CP_SUPPORT_H */
+#endif /* GDB_CP_SUPPORT_H */
diff --git a/gdb/cris-tdep.h b/gdb/cris-tdep.h
index f4f4744adaf..8be95473e21 100644
--- a/gdb/cris-tdep.h
+++ b/gdb/cris-tdep.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CRIS_TDEP_H
-#define CRIS_TDEP_H
+#ifndef GDB_CRIS_TDEP_H
+#define GDB_CRIS_TDEP_H
 
 #include "gdbarch.h"
 
@@ -33,4 +33,4 @@ struct cris_gdbarch_tdep : gdbarch_tdep_base
   int cris_dwarf2_cfi = 0;
 };
 
-#endif /* CRIS_TDEP_H */
+#endif /* GDB_CRIS_TDEP_H */
diff --git a/gdb/csky-tdep.h b/gdb/csky-tdep.h
index e5516e83550..29917192298 100644
--- a/gdb/csky-tdep.h
+++ b/gdb/csky-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CSKY_TDEP_H
-#define CSKY_TDEP_H
+#ifndef GDB_CSKY_TDEP_H
+#define GDB_CSKY_TDEP_H
 
 #include "gdbarch.h"
 
@@ -390,4 +390,4 @@ enum csky_regnum
 #define CSKY_LRW_T1_PC_8    0x2ea8d
 #define CSKY_JMP_T1_VS_NOP  0x6c037834
 
-#endif
+#endif /* GDB_CSKY_TDEP_H */
diff --git a/gdb/ctfread.h b/gdb/ctfread.h
index ff348a2487b..711a1dd2902 100644
--- a/gdb/ctfread.h
+++ b/gdb/ctfread.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CTFREAD_H
-#define CTFREAD_H
+#ifndef GDB_CTFREAD_H
+#define GDB_CTFREAD_H
 
 extern void elfctf_build_psymtabs (struct objfile *objfile);
 
-#endif /* CTFREAD_H */
+#endif /* GDB_CTFREAD_H */
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index ecf194d8155..8a944472b32 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (D_LANG_H)
-#define D_LANG_H 1
+#ifndef GDB_D_LANG_H
+#define GDB_D_LANG_H
 
 #include "symtab.h"
 
@@ -84,4 +84,4 @@ extern void d_value_print_inner (struct value *val,
 				 struct ui_file *stream, int recurse,
 				 const struct value_print_options *options);
 
-#endif /* !defined (D_LANG_H) */
+#endif /* GDB_D_LANG_H */
diff --git a/gdb/darwin-nat.h b/gdb/darwin-nat.h
index 71aee57f61a..4ead0ea7003 100644
--- a/gdb/darwin-nat.h
+++ b/gdb/darwin-nat.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DARWIN_NAT_H
-#define DARWIN_NAT_H
+#ifndef GDB_DARWIN_NAT_H
+#define GDB_DARWIN_NAT_H
 
 #include "inf-child.h"
 #include <mach/mach.h>
@@ -210,4 +210,4 @@ void darwin_set_sstep (thread_t thread, int enable);
 
 void darwin_check_osabi (darwin_inferior *inf, thread_t thread);
 
-#endif /* DARWIN_NAT_H */
+#endif /* GDB_DARWIN_NAT_H */
diff --git a/gdb/dcache.h b/gdb/dcache.h
index 101e65dc41f..21f49e522c5 100644
--- a/gdb/dcache.h
+++ b/gdb/dcache.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DCACHE_H
-#define DCACHE_H
+#ifndef GDB_DCACHE_H
+#define GDB_DCACHE_H
 
 #include "target.h"
 
@@ -52,4 +52,4 @@ void dcache_update (DCACHE *dcache, enum target_xfer_status status,
 		    CORE_ADDR memaddr, const gdb_byte *myaddr,
 		    ULONGEST len);
 
-#endif /* DCACHE_H */
+#endif /* GDB_DCACHE_H */
diff --git a/gdb/debuginfod-support.h b/gdb/debuginfod-support.h
index 2b816fd4b82..2b396dc13c1 100644
--- a/gdb/debuginfod-support.h
+++ b/gdb/debuginfod-support.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DEBUGINFOD_SUPPORT_H
-#define DEBUGINFOD_SUPPORT_H
+#ifndef GDB_DEBUGINFOD_SUPPORT_H
+#define GDB_DEBUGINFOD_SUPPORT_H
 
 #include "gdbsupport/scoped_fd.h"
 
@@ -105,4 +105,4 @@ extern scoped_fd debuginfod_section_query (const unsigned char *build_id,
 					   const char *section_name,
 					   gdb::unique_xmalloc_ptr<char>
 					     *destname);
-#endif /* DEBUGINFOD_SUPPORT_H */
+#endif /* GDB_DEBUGINFOD_SUPPORT_H */
diff --git a/gdb/defs.h b/gdb/defs.h
index cf471bf5d66..212599b2bcc 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DEFS_H
-#define DEFS_H
+#ifndef GDB_DEFS_H
+#define GDB_DEFS_H
 
 #ifdef GDBSERVER
 #  error gdbserver should not include gdb/defs.h
@@ -619,4 +619,4 @@ DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
 
 #include "utils.h"
 
-#endif /* #ifndef DEFS_H */
+#endif /* GDB_DEFS_H */
diff --git a/gdb/dicos-tdep.h b/gdb/dicos-tdep.h
index 1e3eb41a41f..5305debd707 100644
--- a/gdb/dicos-tdep.h
+++ b/gdb/dicos-tdep.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DICOS_TDEP_H
-#define DICOS_TDEP_H
+#ifndef GDB_DICOS_TDEP_H
+#define GDB_DICOS_TDEP_H
 
 extern void dicos_init_abi (struct gdbarch *gdbarch);
 extern int dicos_load_module_p (bfd *abfd, int header_size);
 
-#endif /* dicos-tdep.h */
+#endif /* GDB_DICOS_TDEP_H */
diff --git a/gdb/dictionary.h b/gdb/dictionary.h
index 6f602f4a18b..a06aa1738f1 100644
--- a/gdb/dictionary.h
+++ b/gdb/dictionary.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DICTIONARY_H
-#define DICTIONARY_H
+#ifndef GDB_DICTIONARY_H
+#define GDB_DICTIONARY_H
 
 #include "symfile.h"
 
@@ -208,4 +208,4 @@ struct mdict_iterator_wrapper
   struct mdict_iterator m_iter;
 };
 
-#endif /* DICTIONARY_H */
+#endif /* GDB_DICTIONARY_H */
diff --git a/gdb/disasm-flags.h b/gdb/disasm-flags.h
index b2f0ec95b07..9d4011cebf2 100644
--- a/gdb/disasm-flags.h
+++ b/gdb/disasm-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISASM_FLAGS_H
-#define DISASM_FLAGS_H
+#ifndef GDB_DISASM_FLAGS_H
+#define GDB_DISASM_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -37,4 +37,4 @@ enum gdb_disassembly_flag : unsigned
   };
 DEF_ENUM_FLAGS_TYPE (enum gdb_disassembly_flag, gdb_disassembly_flags);
 
-#endif /* DISASM_FLAGS_H */
+#endif /* GDB_DISASM_FLAGS_H */
diff --git a/gdb/disasm.h b/gdb/disasm.h
index 9282632b270..60d7e0fc834 100644
--- a/gdb/disasm.h
+++ b/gdb/disasm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISASM_H
-#define DISASM_H
+#ifndef GDB_DISASM_H
+#define GDB_DISASM_H
 
 #include "dis-asm.h"
 #include "disasm-flags.h"
@@ -391,4 +391,4 @@ extern const char *get_disassembler_options (struct gdbarch *gdbarch);
 
 extern void set_disassembler_options (const char *options);
 
-#endif
+#endif /* GDB_DISASM_H */
diff --git a/gdb/displaced-stepping.h b/gdb/displaced-stepping.h
index ba0d56c2a1f..d7a537a58c9 100644
--- a/gdb/displaced-stepping.h
+++ b/gdb/displaced-stepping.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISPLACED_STEPPING_H
-#define DISPLACED_STEPPING_H
+#ifndef GDB_DISPLACED_STEPPING_H
+#define GDB_DISPLACED_STEPPING_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/byte-vector.h"
@@ -207,4 +207,4 @@ struct displaced_step_buffers
   std::vector<displaced_step_buffer> m_buffers;
 };
 
-#endif /* DISPLACED_STEPPING_H */
+#endif /* GDB_DISPLACED_STEPPING_H */
diff --git a/gdb/dummy-frame.h b/gdb/dummy-frame.h
index 7d963ad9beb..78998e84413 100644
--- a/gdb/dummy-frame.h
+++ b/gdb/dummy-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DUMMY_FRAME_H)
-#define DUMMY_FRAME_H 1
+#ifndef GDB_DUMMY_FRAME_H
+#define GDB_DUMMY_FRAME_H
 
 #include "frame.h"
 
@@ -80,4 +80,4 @@ extern int find_dummy_frame_dtor (dummy_frame_dtor_ftype *dtor,
 extern struct frame_id default_dummy_id (struct gdbarch *gdbarch,
 					 const frame_info_ptr &this_frame);
 
-#endif /* !defined (DUMMY_FRAME_H)  */
+#endif /* GDB_DUMMY_FRAME_H */
diff --git a/gdb/dwarf2/call-site.h b/gdb/dwarf2/call-site.h
index 0a0c7e83b81..0c587470311 100644
--- a/gdb/dwarf2/call-site.h
+++ b/gdb/dwarf2/call-site.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CALL_SITE_H
-#define CALL_SITE_H
+#ifndef GDB_DWARF2_CALL_SITE_H
+#define GDB_DWARF2_CALL_SITE_H
 
 #include "dwarf2/types.h"
 #include "../frame.h"
@@ -241,4 +241,4 @@ struct call_site
   struct call_site_parameter parameter[];
 };
 
-#endif /* CALL_SITE_H */
+#endif /* GDB_DWARF2_CALL_SITE_H */
diff --git a/gdb/dwarf2/comp-unit-head.h b/gdb/dwarf2/comp-unit-head.h
index fad484c3b93..d161783187c 100644
--- a/gdb/dwarf2/comp-unit-head.h
+++ b/gdb/dwarf2/comp-unit-head.h
@@ -24,8 +24,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DWARF2_COMP_UNIT_H
-#define GDB_DWARF2_COMP_UNIT_H
+#ifndef GDB_DWARF2_COMP_UNIT_HEAD_H
+#define GDB_DWARF2_COMP_UNIT_HEAD_H
 
 #include "dwarf2.h"
 #include "dwarf2/leb.h"
@@ -136,4 +136,4 @@ extern const gdb_byte *read_and_check_comp_unit_head
    const gdb_byte *info_ptr,
    rcuh_kind section_kind);
 
-#endif /* GDB_DWARF2_COMP_UNIT_H */
+#endif /* GDB_DWARF2_COMP_UNIT_HEAD_H */
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index b02cc531640..bbb9cd078ba 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DWARF2EXPR_H)
-#define DWARF2EXPR_H
+#ifndef GDB_DWARF2_EXPR_H
+#define GDB_DWARF2_EXPR_H
 
 #include "leb128.h"
 #include "dwarf2/call-site.h"
@@ -320,4 +320,4 @@ extern const gdb_byte *safe_read_sleb128 (const gdb_byte *buf,
 extern const gdb_byte *safe_skip_leb128 (const gdb_byte *buf,
 					 const gdb_byte *buf_end);
 
-#endif /* DWARF2EXPR_H */
+#endif /* GDB_DWARF2_EXPR_H */
diff --git a/gdb/dwarf2/frame-tailcall.h b/gdb/dwarf2/frame-tailcall.h
index 3f49487ac2a..558957eb999 100644
--- a/gdb/dwarf2/frame-tailcall.h
+++ b/gdb/dwarf2/frame-tailcall.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_FRAME_TAILCALL_H
-#define DWARF2_FRAME_TAILCALL_H 1
+#ifndef GDB_DWARF2_FRAME_TAILCALL_H
+#define GDB_DWARF2_FRAME_TAILCALL_H
 
 class frame_info_ptr;
 struct frame_unwind;
@@ -36,4 +36,4 @@ extern struct value *
 
 extern const struct frame_unwind dwarf2_tailcall_frame_unwind;
 
-#endif /* !DWARF2_FRAME_TAILCALL_H */
+#endif /* GDB_DWARF2_FRAME_TAILCALL_H */
diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h
index 2167310fbdf..f53f4bdd864 100644
--- a/gdb/dwarf2/frame.h
+++ b/gdb/dwarf2/frame.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_FRAME_H
-#define DWARF2_FRAME_H 1
+#ifndef GDB_DWARF2_FRAME_H
+#define GDB_DWARF2_FRAME_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -294,4 +294,4 @@ extern void *dwarf2_frame_get_fn_data (const frame_info_ptr &this_frame,
 				       void **this_cache,
 				       fn_prev_register cookie);
 
-#endif /* dwarf2-frame.h */
+#endif /* GDB_DWARF2_FRAME_H */
diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h
index 95f217ed961..922c1568f8e 100644
--- a/gdb/dwarf2/index-cache.h
+++ b/gdb/dwarf2/index-cache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_CACHE_H
-#define DWARF_INDEX_CACHE_H
+#ifndef GDB_DWARF2_INDEX_CACHE_H
+#define GDB_DWARF2_INDEX_CACHE_H
 
 #include "dwarf2/index-common.h"
 #include "gdbsupport/array-view.h"
@@ -137,4 +137,4 @@ class index_cache
 /* The global instance of the index cache.  */
 extern index_cache global_index_cache;
 
-#endif /* DWARF_INDEX_CACHE_H */
+#endif /* GDB_DWARF2_INDEX_CACHE_H */
diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h
index dca41517b3d..4c029f4318e 100644
--- a/gdb/dwarf2/index-common.h
+++ b/gdb/dwarf2/index-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_COMMON_H
-#define DWARF_INDEX_COMMON_H
+#ifndef GDB_DWARF2_INDEX_COMMON_H
+#define GDB_DWARF2_INDEX_COMMON_H
 
 /* The suffix for an index file.  */
 #define INDEX4_SUFFIX ".gdb-index"
@@ -56,4 +56,4 @@ uint32_t dwarf5_djb_hash (const char *str_);
 
 uint32_t dwarf5_djb_hash (std::string_view str_);
 
-#endif /* DWARF_INDEX_COMMON_H */
+#endif /* GDB_DWARF2_INDEX_COMMON_H */
diff --git a/gdb/dwarf2/index-write.h b/gdb/dwarf2/index-write.h
index b7cf564efc5..1982e8510fc 100644
--- a/gdb/dwarf2/index-write.h
+++ b/gdb/dwarf2/index-write.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_WRITE_H
-#define DWARF_INDEX_WRITE_H
+#ifndef GDB_DWARF2_INDEX_WRITE_H
+#define GDB_DWARF2_INDEX_WRITE_H
 
 #include "dwarf2/read.h"
 #include "dwarf2/public.h"
@@ -36,4 +36,4 @@ extern void write_dwarf_index
   (dwarf2_per_bfd *per_bfd, const char *dir, const char *basename,
    const char *dwz_basename, dw_index_kind index_kind);
 
-#endif /* DWARF_INDEX_WRITE_H */
+#endif /* GDB_DWARF2_INDEX_WRITE_H */
diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index c068dff70a3..b9bc55a926e 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_LINE_HEADER_H
-#define DWARF2_LINE_HEADER_H
+#ifndef GDB_DWARF2_LINE_HEADER_H
+#define GDB_DWARF2_LINE_HEADER_H
 
 /* dir_index is 1-based in DWARF 4 and before, and is 0-based in DWARF 5 and
    later.  */
@@ -217,4 +217,4 @@ extern line_header_up dwarf_decode_line_header
    struct dwarf2_section_info *section, const struct comp_unit_head *cu_header,
    const char *comp_dir);
 
-#endif /* DWARF2_LINE_HEADER_H */
+#endif /* GDB_DWARF2_LINE_HEADER_H */
diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h
index 4fb743618e7..78635682d94 100644
--- a/gdb/dwarf2/loc.h
+++ b/gdb/dwarf2/loc.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DWARF2LOC_H)
-#define DWARF2LOC_H
+#ifndef GDB_DWARF2_LOC_H
+#define GDB_DWARF2_LOC_H
 
 #include "dwarf2/expr.h"
 
@@ -308,4 +308,4 @@ extern struct value *value_of_dwarf_reg_entry (struct type *type,
 					       const frame_info_ptr &frame,
 					       enum call_site_parameter_kind kind,
 					       union call_site_parameter_u kind_u);
-#endif /* DWARF2LOC_H */
+#endif /* GDB_DWARF2_LOC_H */
diff --git a/gdb/dwarf2/public.h b/gdb/dwarf2/public.h
index bc419ff208f..8247641b25b 100644
--- a/gdb/dwarf2/public.h
+++ b/gdb/dwarf2/public.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_PUBLIC_H
-#define DWARF2_PUBLIC_H
+#ifndef GDB_DWARF2_PUBLIC_H
+#define GDB_DWARF2_PUBLIC_H
 
 /* A DWARF names index variant.  */
 enum class dw_index_kind
@@ -44,4 +44,4 @@ extern bool dwarf2_initialize_objfile
 
 extern void dwarf2_build_frame_info (struct objfile *);
 
-#endif /* DWARF2_PUBLIC_H */
+#endif /* GDB_DWARF2_PUBLIC_H */
diff --git a/gdb/dwarf2/read-debug-names.h b/gdb/dwarf2/read-debug-names.h
index e616cf887a7..729fe898ea8 100644
--- a/gdb/dwarf2/read-debug-names.h
+++ b/gdb/dwarf2/read-debug-names.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_READ_DEBUG_NAMES_H
-#define DWARF2_READ_DEBUG_NAMES_H
+#ifndef GDB_DWARF2_READ_DEBUG_NAMES_H
+#define GDB_DWARF2_READ_DEBUG_NAMES_H
 
 struct dwarf2_per_objfile;
 
@@ -29,4 +29,4 @@ extern const gdb_byte dwarf5_augmentation[8];
 
 bool dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile);
 
-#endif /* DWARF2_READ_DEBUG_NAMES_H */
+#endif /* GDB_DWARF2_READ_DEBUG_NAMES_H */
diff --git a/gdb/dwarf2/read-gdb-index.h b/gdb/dwarf2/read-gdb-index.h
index e411114b147..906e3bd0bed 100644
--- a/gdb/dwarf2/read-gdb-index.h
+++ b/gdb/dwarf2/read-gdb-index.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_READ_GDB_INDEX_H
-#define DWARF2_READ_GDB_INDEX_H
+#ifndef GDB_DWARF2_READ_GDB_INDEX_H
+#define GDB_DWARF2_READ_GDB_INDEX_H
 
 #include "gdbsupport/function-view.h"
 
@@ -44,4 +44,4 @@ int dwarf2_read_gdb_index
    get_gdb_index_contents_ftype get_gdb_index_contents,
    get_gdb_index_contents_dwz_ftype get_gdb_index_contents_dwz);
 
-#endif /* DWARF2_READ_GDB_INDEX_H */
+#endif /* GDB_DWARF2_READ_GDB_INDEX_H */
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 73def88c4c0..76bf6a422f4 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2READ_H
-#define DWARF2READ_H
+#ifndef GDB_DWARF2_READ_H
+#define GDB_DWARF2_READ_H
 
 #include <queue>
 #include <unordered_map>
@@ -932,4 +932,4 @@ extern void create_all_units (dwarf2_per_objfile *per_objfile);
 
 extern htab_up create_quick_file_names_table (unsigned int nr_initial_entries);
 
-#endif /* DWARF2READ_H */
+#endif /* GDB_DWARF2_READ_H */
diff --git a/gdb/dwarf2/types.h b/gdb/dwarf2/types.h
index f0b9febba15..8cb689d652b 100644
--- a/gdb/dwarf2/types.h
+++ b/gdb/dwarf2/types.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_TYPES_H
-#define DWARF2_TYPES_H
+#ifndef GDB_DWARF2_TYPES_H
+#define GDB_DWARF2_TYPES_H
 
 #include "gdbsupport/offset-type.h"
 #include "gdbsupport/underlying.h"
@@ -37,4 +37,4 @@ sect_offset_str (sect_offset offset)
   return hex_string (to_underlying (offset));
 }
 
-#endif /* DWARF2_TYPES_H */
+#endif /* GDB_DWARF2_TYPES_H */
diff --git a/gdb/elf-none-tdep.h b/gdb/elf-none-tdep.h
index ecbf2d776c6..1881e4b8cb6 100644
--- a/gdb/elf-none-tdep.h
+++ b/gdb/elf-none-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NONE_TDEP_H
-#define NONE_TDEP_H
+#ifndef GDB_ELF_NONE_TDEP_H
+#define GDB_ELF_NONE_TDEP_H
 
 struct gdbarch;
 
@@ -27,4 +27,4 @@ struct gdbarch;
 
 void elf_none_init_abi (struct gdbarch *gdbarch);
 
-#endif /* NONE_TDEP_H */
+#endif /* GDB_ELF_NONE_TDEP_H */
diff --git a/gdb/event-top.h b/gdb/event-top.h
index f431f2812b2..7f544b0f27c 100644
--- a/gdb/event-top.h
+++ b/gdb/event-top.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EVENT_TOP_H
-#define EVENT_TOP_H
+#ifndef GDB_EVENT_TOP_H
+#define GDB_EVENT_TOP_H
 
 #include <signal.h>
 
@@ -90,4 +90,4 @@ class scoped_segv_handler_restore
   segv_handler_t m_old_handler;
 };
 
-#endif
+#endif /* GDB_EVENT_TOP_H */
diff --git a/gdb/exceptions.h b/gdb/exceptions.h
index 64f4d75c39c..bf7141dbb9f 100644
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXCEPTIONS_H
-#define EXCEPTIONS_H
+#ifndef GDB_EXCEPTIONS_H
+#define GDB_EXCEPTIONS_H
 
 #include "ui-out.h"
 
@@ -31,4 +31,4 @@ extern void exception_fprintf (struct ui_file *file,
 			       const char *prefix,
 			       ...) ATTRIBUTE_PRINTF (3, 4);
 
-#endif
+#endif /* GDB_EXCEPTIONS_H */
diff --git a/gdb/exec.h b/gdb/exec.h
index f667f23600d..950a21c2f3a 100644
--- a/gdb/exec.h
+++ b/gdb/exec.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXEC_H
-#define EXEC_H
+#ifndef GDB_EXEC_H
+#define GDB_EXEC_H
 
 #include "target.h"
 #include "progspace.h"
@@ -105,4 +105,4 @@ extern void print_section_info (const std::vector<target_section> *table,
 extern void try_open_exec_file (const char *exec_file_host,
 				struct inferior *inf,
 				symfile_add_flags add_flags);
-#endif
+#endif /* GDB_EXEC_H */
diff --git a/gdb/expop.h b/gdb/expop.h
index b81e228c07e..64158bc4706 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXPOP_H
-#define EXPOP_H
+#ifndef GDB_EXPOP_H
+#define GDB_EXPOP_H
 
 #include "c-lang.h"
 #include "cp-abi.h"
@@ -2215,4 +2215,4 @@ class funcall_operation
 
 } /* namespace expr */
 
-#endif /* EXPOP_H */
+#endif /* GDB_EXPOP_H */
diff --git a/gdb/expression.h b/gdb/expression.h
index 5bfc74c973f..7c79518da8b 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (EXPRESSION_H)
-#define EXPRESSION_H 1
+#ifndef GDB_EXPRESSION_H
+#define GDB_EXPRESSION_H
 
 #include "gdbtypes.h"
 #include "symtab.h"
@@ -387,4 +387,4 @@ enum range_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum range_flag, range_flags);
 
-#endif /* !defined (EXPRESSION_H) */
+#endif /* GDB_EXPRESSION_H */
diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index cb00cb6ff7b..f6c5f3fe75f 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXTENSION_PRIV_H
-#define EXTENSION_PRIV_H
+#ifndef GDB_EXTENSION_PRIV_H
+#define GDB_EXTENSION_PRIV_H
 
 #include "extension.h"
 #include <signal.h>
@@ -320,4 +320,4 @@ extern struct active_ext_lang_state *set_active_ext_lang
 
 extern void restore_active_ext_lang (struct active_ext_lang_state *previous);
 
-#endif /* EXTENSION_PRIV_H */
+#endif /* GDB_EXTENSION_PRIV_H */
diff --git a/gdb/extension.h b/gdb/extension.h
index 5260bcbde00..93c3cdfcc69 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXTENSION_H
-#define EXTENSION_H
+#ifndef GDB_EXTENSION_H
+#define GDB_EXTENSION_H
 
 #include "mi/mi-cmds.h"
 #include "gdbsupport/array-view.h"
@@ -428,4 +428,4 @@ class scoped_disable_cooperative_sigint_handling
   bool m_prev_cooperative_sigint_handling_disabled;
 };
 
-#endif /* EXTENSION_H */
+#endif /* GDB_EXTENSION_H */
diff --git a/gdb/f-array-walker.h b/gdb/f-array-walker.h
index bcbaa3da5b3..d1f2b06fa9b 100644
--- a/gdb/f-array-walker.h
+++ b/gdb/f-array-walker.h
@@ -18,8 +18,8 @@
 /* Support classes to wrap up the process of iterating over a
    multi-dimensional Fortran array.  */
 
-#ifndef F_ARRAY_WALKER_H
-#define F_ARRAY_WALKER_H
+#ifndef GDB_F_ARRAY_WALKER_H
+#define GDB_F_ARRAY_WALKER_H
 
 #include "gdbtypes.h"
 #include "f-lang.h"
@@ -298,4 +298,4 @@ class fortran_array_walker
   int m_nss;
 };
 
-#endif /* F_ARRAY_WALKER_H */
+#endif /* GDB_F_ARRAY_WALKER_H */
diff --git a/gdb/f-exp.h b/gdb/f-exp.h
index aa0094c8ff1..47d469abe7c 100644
--- a/gdb/f-exp.h
+++ b/gdb/f-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FORTRAN_EXP_H
-#define FORTRAN_EXP_H
+#ifndef GDB_F_EXP_H
+#define GDB_F_EXP_H
 
 #include "expop.h"
 
@@ -417,4 +417,4 @@ class fortran_structop_operation
 
 } /* namespace expr */
 
-#endif /* FORTRAN_EXP_H */
+#endif /* GDB_F_EXP_H */
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index c2034258513..59cdd5f2334 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef F_LANG_H
-#define F_LANG_H
+#ifndef GDB_F_LANG_H
+#define GDB_F_LANG_H
 
 #include "language.h"
 #include "valprint.h"
@@ -378,4 +378,4 @@ extern struct type *fortran_preserve_arg_pointer (struct value *arg,
 extern CORE_ADDR fortran_adjust_dynamic_array_base_address_hack
 	(struct type *type, CORE_ADDR address);
 
-#endif /* F_LANG_H */
+#endif /* GDB_F_LANG_H */
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index 35c06b2c985..2123175944e 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FBSD_NAT_H
-#define FBSD_NAT_H
+#ifndef GDB_FBSD_NAT_H
+#define GDB_FBSD_NAT_H
 
 #include <optional>
 #include "inf-ptrace.h"
@@ -285,4 +285,4 @@ class fbsd_nat_target : public inf_ptrace_target
    Return true if successful.  */
 bool fbsd_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
 
-#endif /* fbsd-nat.h */
+#endif /* GDB_FBSD_NAT_H */
diff --git a/gdb/fbsd-tdep.h b/gdb/fbsd-tdep.h
index 54ff45c8d93..79381b3fefd 100644
--- a/gdb/fbsd-tdep.h
+++ b/gdb/fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FBSD_TDEP_H
-#define FBSD_TDEP_H
+#ifndef GDB_FBSD_TDEP_H
+#define GDB_FBSD_TDEP_H
 
 extern void fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
 
@@ -76,4 +76,4 @@ extern CORE_ADDR fbsd_get_thread_local_address (struct gdbarch *gdbarch,
 extern CORE_ADDR fbsd_skip_solib_resolver (struct gdbarch *gdbarch,
 					   CORE_ADDR pc);
 
-#endif /* fbsd-tdep.h */
+#endif /* GDB_FBSD_TDEP_H */
diff --git a/gdb/filename-seen-cache.h b/gdb/filename-seen-cache.h
index 5dc800d2b16..9107f449183 100644
--- a/gdb/filename-seen-cache.h
+++ b/gdb/filename-seen-cache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FILENAME_SEEN_CACHE_H
-#define FILENAME_SEEN_CACHE_H
+#ifndef GDB_FILENAME_SEEN_CACHE_H
+#define GDB_FILENAME_SEEN_CACHE_H
 
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/gdb-hashtab.h"
@@ -62,4 +62,4 @@ class filename_seen_cache
   htab_up m_tab;
 };
 
-#endif /* FILENAME_SEEN_CACHE_H */
+#endif /* GDB_FILENAME_SEEN_CACHE_H */
diff --git a/gdb/filesystem.h b/gdb/filesystem.h
index 29c31803fc4..73b9a8bb84e 100644
--- a/gdb/filesystem.h
+++ b/gdb/filesystem.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FILESYSTEM_H
-#define FILESYSTEM_H
+#ifndef GDB_FILESYSTEM_H
+#define GDB_FILESYSTEM_H
 
 extern const char file_system_kind_auto[];
 extern const char file_system_kind_unix[];
@@ -55,4 +55,4 @@ extern const char *target_lbasename (const char *kind, const char *name);
    result from this function.  */
 extern const char *effective_target_file_system_kind (void);
 
-#endif
+#endif /* GDB_FILESYSTEM_H */
diff --git a/gdb/frame-base.h b/gdb/frame-base.h
index ae22431d5ef..8436929839e 100644
--- a/gdb/frame-base.h
+++ b/gdb/frame-base.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_BASE_H)
-#define FRAME_BASE_H 1
+#ifndef GDB_FRAME_BASE_H
+#define GDB_FRAME_BASE_H
 
 class frame_info_ptr;
 struct frame_id;
@@ -88,4 +88,4 @@ extern void frame_base_set_default (struct gdbarch *gdbarch,
 
 extern const struct frame_base *frame_base_find_by_frame (const frame_info_ptr &this_frame);
 
-#endif
+#endif /* GDB_FRAME_BASE_H */
diff --git a/gdb/frame-id.h b/gdb/frame-id.h
index 0d03b476aef..30850e24017 100644
--- a/gdb/frame-id.h
+++ b/gdb/frame-id.h
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef GDB_FRAME_ID_H
-#define GDB_FRAME_ID_H 1
+#define GDB_FRAME_ID_H
 
 /* Status of a given frame's stack.  */
 
@@ -140,4 +140,4 @@ is_sentinel_frame_id (frame_id id)
   return id.stack_status == FID_STACK_SENTINEL;
 }
 
-#endif /* ifdef GDB_FRAME_ID_H  */
+#endif /* GDB_FRAME_ID_H */
diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h
index 53fcd6869e9..1799d3625bd 100644
--- a/gdb/frame-unwind.h
+++ b/gdb/frame-unwind.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_UNWIND_H)
-#define FRAME_UNWIND_H 1
+#ifndef GDB_FRAME_UNWIND_H
+#define GDB_FRAME_UNWIND_H
 
 struct frame_data;
 class frame_info_ptr;
@@ -235,4 +235,4 @@ value *frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum,
 value *frame_unwind_got_address (const frame_info_ptr &frame, int regnum,
 				 CORE_ADDR addr);
 
-#endif
+#endif /* GDB_FRAME_UNWIND_H */
diff --git a/gdb/frame.h b/gdb/frame.h
index e784c17b480..9b41dd958fa 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_H)
-#define FRAME_H 1
+#ifndef GDB_FRAME_H
+#define GDB_FRAME_H
 
 /* The following is the intended naming schema for frame functions.
    It isn't 100% consistent, but it is approaching that.  Frame naming
@@ -1077,4 +1077,4 @@ extern void set_frame_previous_pc_masked (const frame_info_ptr &frame);
 extern bool get_frame_pc_masked (const frame_info_ptr &frame);
 
 
-#endif /* !defined (FRAME_H)  */
+#endif /* GDB_FRAME_H */
diff --git a/gdb/frv-tdep.h b/gdb/frv-tdep.h
index 95347ed224e..0d78ec4ac6a 100644
--- a/gdb/frv-tdep.h
+++ b/gdb/frv-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FRV_TDEP_H
-#define FRV_TDEP_H
+#ifndef GDB_FRV_TDEP_H
+#define GDB_FRV_TDEP_H
 
 /* Enumerate the possible ABIs for FR-V.  */
 enum frv_abi
@@ -121,4 +121,4 @@ CORE_ADDR frv_fetch_objfile_link_map (struct objfile *objfile);
 struct solib_ops;
 extern const solib_ops frv_so_ops;
 
-#endif /* FRV_TDEP_H */
+#endif /* GDB_FRV_TDEP_H */
diff --git a/gdb/ft32-tdep.h b/gdb/ft32-tdep.h
index 308d2333bc2..ee4a2473f8d 100644
--- a/gdb/ft32-tdep.h
+++ b/gdb/ft32-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FT32_TDEP_H
-#define FT32_TDEP_H
+#ifndef GDB_FT32_TDEP_H
+#define GDB_FT32_TDEP_H
 
 #include "gdbarch.h"
 
@@ -28,4 +28,4 @@ struct ft32_gdbarch_tdep : gdbarch_tdep_base
   struct type *pc_type = nullptr;
 };
 
-#endif /* FT32_TDEP_H */
+#endif /* GDB_FT32_TDEP_H */
diff --git a/gdb/gcore-elf.h b/gdb/gcore-elf.h
index e7239b88b09..8217f0b1c85 100644
--- a/gdb/gcore-elf.h
+++ b/gdb/gcore-elf.h
@@ -17,8 +17,8 @@
 
 /* This file contains generic functions for writing ELF based core files.  */
 
-#if !defined (GCORE_ELF_H)
-#define GCORE_ELF_H 1
+#ifndef GDB_GCORE_ELF_H
+#define GDB_GCORE_ELF_H
 
 #include "gdb_bfd.h"
 #include "gdbsupport/gdb_signals.h"
@@ -45,4 +45,4 @@ extern void gcore_elf_make_tdesc_note
   (struct gdbarch *gdbarch, bfd *obfd,
    gdb::unique_xmalloc_ptr<char> *note_data, int *note_size);
 
-#endif /* GCORE_ELF_H */
+#endif /* GDB_GCORE_ELF_H */
diff --git a/gdb/gcore.h b/gdb/gcore.h
index 0bedc0a7ba9..21e7a8d29ee 100644
--- a/gdb/gcore.h
+++ b/gdb/gcore.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GCORE_H)
-#define GCORE_H 1
+#ifndef GDB_GCORE_H
+#define GDB_GCORE_H
 
 #include "gdb_bfd.h"
 
@@ -37,4 +37,4 @@ extern int objfile_find_memory_regions (struct target_ops *self,
 
 extern thread_info *gcore_find_signalled_thread ();
 
-#endif /* GCORE_H */
+#endif /* GDB_GCORE_H */
diff --git a/gdb/gdb-demangle.h b/gdb/gdb-demangle.h
index e434f890969..86a8bd618eb 100644
--- a/gdb/gdb-demangle.h
+++ b/gdb/gdb-demangle.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DEMANGLE_H
-#define GDB_DEMANGLE_H
+#ifndef GDB_GDB_DEMANGLE_H
+#define GDB_GDB_DEMANGLE_H
 
 /* True means that encoded C++/ObjC names should be printed out in their
    C++/ObjC form rather than raw.  */
@@ -31,4 +31,4 @@ extern bool asm_demangle;
 /* Check if a character is one of the commonly used C++ marker characters.  */
 extern bool is_cplus_marker (int);
 
-#endif /* GDB_DEMANGLE_H */
+#endif /* GDB_GDB_DEMANGLE_H */
diff --git a/gdb/gdb-stabs.h b/gdb/gdb-stabs.h
index 3786ad6881d..373a7269470 100644
--- a/gdb/gdb-stabs.h
+++ b/gdb/gdb-stabs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_STABS_H
-#define GDB_STABS_H
+#ifndef GDB_GDB_STABS_H
+#define GDB_GDB_STABS_H
 
 /* This file exists to hold the common definitions required of most of
    the symbol-readers that end up using stabs.  The common use of
@@ -75,4 +75,4 @@ extern const registry<objfile>::key<dbx_symfile_info> dbx_objfile_data_key;
 #define DBX_BSS_SECTION(o)	(DBX_SYMFILE_INFO(o)->bss_section)
 #define DBX_STAB_SECTION(o)	(DBX_SYMFILE_INFO(o)->stab_section)
 
-#endif /* GDB_STABS_H */
+#endif /* GDB_GDB_STABS_H */
diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h
index 331570d769c..c09e4e7f811 100644
--- a/gdb/gdb_bfd.h
+++ b/gdb/gdb_bfd.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_BFD_H
-#define GDB_BFD_H
+#ifndef GDB_GDB_BFD_H
+#define GDB_GDB_BFD_H
 
 #include "registry.h"
 #include "gdbsupport/byte-vector.h"
@@ -263,4 +263,4 @@ extern std::string gdb_bfd_errmsg (bfd_error_type error_tag, char **matching);
 
 extern void gdb_bfd_init ();
 
-#endif /* GDB_BFD_H */
+#endif /* GDB_GDB_BFD_H */
diff --git a/gdb/gdb_curses.h b/gdb/gdb_curses.h
index c7ee862cd67..c0ab883f17b 100644
--- a/gdb/gdb_curses.h
+++ b/gdb/gdb_curses.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_CURSES_H
-#define GDB_CURSES_H 1
+#ifndef GDB_GDB_CURSES_H
+#define GDB_GDB_CURSES_H
 
 #ifdef __MINGW32__
 /* Windows API headers, included e.g. by serial.h, define MOUSE_MOVED,
@@ -71,4 +71,4 @@ extern "C" int tgetnum (const char *);
 #undef reg
 #endif
 
-#endif /* gdb_curses.h */
+#endif /* GDB_GDB_CURSES_H */
diff --git a/gdb/gdb_expat.h b/gdb/gdb_expat.h
index 566f065fd13..36cee8031eb 100644
--- a/gdb/gdb_expat.h
+++ b/gdb/gdb_expat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(GDB_EXPAT_H)
-#define GDB_EXPAT_H
+#ifndef GDB_GDB_EXPAT_H
+#define GDB_GDB_EXPAT_H
 
 #include <expat.h>
 
@@ -35,4 +35,4 @@
 #define XMLCALL
 #endif
 
-#endif /* !defined(GDB_EXPAT_H) */
+#endif /* GDB_GDB_EXPAT_H */
diff --git a/gdb/gdb_proc_service.h b/gdb/gdb_proc_service.h
index 1088e19a4c5..c5e060b4eee 100644
--- a/gdb/gdb_proc_service.h
+++ b/gdb/gdb_proc_service.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_PROC_SERVICE_H
-#define GDB_PROC_SERVICE_H
+#ifndef GDB_GDB_PROC_SERVICE_H
+#define GDB_GDB_PROC_SERVICE_H
 
 #include "gdbsupport/gdb_proc_service.h"
 
@@ -30,4 +30,4 @@ struct ps_prochandle
   thread_info *thread;
 };
 
-#endif /* gdb_proc_service.h */
+#endif /* GDB_GDB_PROC_SERVICE_H */
diff --git a/gdb/gdb_vfork.h b/gdb/gdb_vfork.h
index 521fed9b007..69f4955ee97 100644
--- a/gdb/gdb_vfork.h
+++ b/gdb/gdb_vfork.h
@@ -16,11 +16,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_VFORK_H
-#define GDB_VFORK_H
+#ifndef GDB_GDB_VFORK_H
+#define GDB_GDB_VFORK_H
 
 #if HAVE_VFORK_H
 #include <vfork.h>
 #endif
 
-#endif /* GDB_VFORK_H */
+#endif /* GDB_GDB_VFORK_H */
diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h
index 8df00e4679f..937b409d039 100644
--- a/gdb/gdb_wchar.h
+++ b/gdb/gdb_wchar.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_WCHAR_H
-#define GDB_WCHAR_H
+#ifndef GDB_GDB_WCHAR_H
+#define GDB_GDB_WCHAR_H
 
 /* We handle three different modes here.
    
@@ -121,4 +121,4 @@ typedef int gdb_wint_t;
 
 #endif
 
-#endif /* GDB_WCHAR_H */
+#endif /* GDB_GDB_WCHAR_H */
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 77d3406779f..bfe08fe65a8 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef GDBARCH_H
-#define GDBARCH_H
+#ifndef GDB_GDBARCH_H
+#define GDB_GDBARCH_H
 
 #include <vector>
 #include "frame.h"
@@ -370,4 +370,4 @@ gdbarch_num_cooked_regs (gdbarch *arch)
   return gdbarch_num_regs (arch) + gdbarch_num_pseudo_regs (arch);
 }
 
-#endif
+#endif /* GDB_GDBARCH_H */
diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h
index 8a1f6f20052..cba32528dfa 100644
--- a/gdb/gdbcmd.h
+++ b/gdb/gdbcmd.h
@@ -21,8 +21,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDBCMD_H)
-#define GDBCMD_H 1
+#ifndef GDB_GDBCMD_H
+#define GDB_GDBCMD_H
 
 #include "command.h"
 #include "ui-out.h"
@@ -69,4 +69,4 @@ extern void print_command_lines (struct ui_out *,
 extern struct cmd_list_element *style_set_list;
 extern struct cmd_list_element *style_show_list;
 
-#endif /* !defined (GDBCMD_H) */
+#endif /* GDB_GDBCMD_H */
diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h
index d6aeb356e37..4eab2cd70a5 100644
--- a/gdb/gdbcore.h
+++ b/gdb/gdbcore.h
@@ -19,8 +19,8 @@
 
 /* Interface routines for core, executable, etc.  */
 
-#if !defined (GDBCORE_H)
-#define GDBCORE_H 1
+#ifndef GDB_GDBCORE_H
+#define GDB_GDBCORE_H
 
 struct type;
 struct regcache;
@@ -196,4 +196,4 @@ class thread_section_name
   std::string m_storage;
 };
 
-#endif /* !defined (GDBCORE_H) */
+#endif /* GDB_GDBCORE_H */
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 73f6895fe46..490d05db340 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDBTHREAD_H
-#define GDBTHREAD_H
+#ifndef GDB_GDBTHREAD_H
+#define GDB_GDBTHREAD_H
 
 struct symtab;
 
@@ -1071,4 +1071,4 @@ extern void thread_try_catch_cmd (thread_info *thr,
 
 extern const char *thread_state_string (enum thread_state state);
 
-#endif /* GDBTHREAD_H */
+#endif /* GDB_GDBTHREAD_H */
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 55018f2c344..5182b54cc96 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDBTYPES_H)
-#define GDBTYPES_H 1
+#ifndef GDB_GDBTYPES_H
+#define GDB_GDBTYPES_H
 
 /* * \page gdbtypes GDB Types
 
@@ -2830,4 +2830,4 @@ extern unsigned int overload_debug;
 
 extern bool is_nocall_function (const struct type *type);
 
-#endif /* GDBTYPES_H */
+#endif /* GDB_GDBTYPES_H */
diff --git a/gdb/glibc-tdep.h b/gdb/glibc-tdep.h
index 264e1e707f2..17006d0fafc 100644
--- a/gdb/glibc-tdep.h
+++ b/gdb/glibc-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GLIBC_TDEP_H
-#define GLIBC_TDEP_H
+#ifndef GDB_GLIBC_TDEP_H
+#define GDB_GLIBC_TDEP_H
 
 struct gdbarch;
 
 extern CORE_ADDR glibc_skip_solib_resolver (struct gdbarch *gdbarch,
 					    CORE_ADDR);
 
-#endif /* glibc-tdep.h */
+#endif /* GDB_GLIBC_TDEP_H */
diff --git a/gdb/gmp-utils.h b/gdb/gmp-utils.h
index 51e06abc050..84ac0e7333b 100644
--- a/gdb/gmp-utils.h
+++ b/gdb/gmp-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GMP_UTILS_H
-#define GMP_UTILS_H
+#ifndef GDB_GMP_UTILS_H
+#define GDB_GMP_UTILS_H
 
 /* Include <stdio.h> and <stdarg.h> ahead of <gmp.h>, so as to get
    access to GMP's various formatting functions.  */
@@ -663,4 +663,4 @@ gdb_mpz::as_integer_truncate () const
   return result;
 }
 
-#endif
+#endif /* GDB_GMP_UTILS_H */
diff --git a/gdb/gnu-nat-mig.h b/gdb/gnu-nat-mig.h
index 4b9e78c99e2..01c1ed46f20 100644
--- a/gdb/gnu-nat-mig.h
+++ b/gdb/gnu-nat-mig.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GNU_NAT_MIG_H
-#define GNU_NAT_MIG_H
+#ifndef GDB_GNU_NAT_MIG_H
+#define GDB_GNU_NAT_MIG_H
 
 #include <mach/boolean.h>
 #include <mach/message.h>
@@ -28,4 +28,4 @@ boolean_t notify_server (mach_msg_header_t *InHeadP,
 boolean_t process_reply_server (mach_msg_header_t *InHeadP,
 				mach_msg_header_t *OutHeadP);
 
-#endif /* GNU_NAT_MIG_H */
+#endif /* GDB_GNU_NAT_MIG_H */
diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index f1694b8a3a7..700a01a7d17 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GNU_NAT_H
-#define GNU_NAT_H
+#ifndef GDB_GNU_NAT_H
+#define GDB_GNU_NAT_H
 
 /* Work around conflict between Mach's 'thread_info' function, and GDB's
    'thread_info' class.  Make the former available as 'mach_thread_info'.  */
@@ -188,4 +188,4 @@ struct gnu_nat_target : public inf_child_target
 /* The final/concrete instance.  */
 extern gnu_nat_target *gnu_target;
 
-#endif /* GNU_NAT_H */
+#endif /* GDB_GNU_NAT_H */
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
index 1aca9ddd118..030febc4215 100644
--- a/gdb/go-lang.h
+++ b/gdb/go-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GO_LANG_H)
-#define GO_LANG_H 1
+#ifndef GDB_GO_LANG_H
+#define GDB_GO_LANG_H
 
 struct type_print_options;
 
@@ -144,4 +144,4 @@ class go_language : public language_defn
   { return true; }
 };
 
-#endif /* !defined (GO_LANG_H) */
+#endif /* GDB_GO_LANG_H */
diff --git a/gdb/gregset.h b/gdb/gregset.h
index 8c14809a47d..9345625d98a 100644
--- a/gdb/gregset.h
+++ b/gdb/gregset.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GREGSET_H
-#define GREGSET_H
+#ifndef GDB_GREGSET_H
+#define GDB_GREGSET_H
 
 #ifdef HAVE_SYS_PROCFS_H
 #include <sys/procfs.h>
@@ -60,4 +60,4 @@ extern void fill_gregset (const struct regcache *regcache,
 extern void fill_fpregset (const struct regcache *regcache,
 			   gdb_fpregset_t *fpregs, int regno);
 
-#endif
+#endif /* GDB_GREGSET_H */
diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h
index be16fee0dd2..c2856478eed 100644
--- a/gdb/guile/guile-internal.h
+++ b/gdb/guile/guile-internal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GUILE_GUILE_INTERNAL_H
-#define GUILE_GUILE_INTERNAL_H
+#ifndef GDB_GUILE_GUILE_INTERNAL_H
+#define GDB_GUILE_GUILE_INTERNAL_H
 
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
@@ -722,4 +722,4 @@ gdbscm_wrap (Function &&func, Args &&... args)
   return result;
 }
 
-#endif /* GUILE_GUILE_INTERNAL_H */
+#endif /* GDB_GUILE_GUILE_INTERNAL_H */
diff --git a/gdb/guile/guile.h b/gdb/guile/guile.h
index 2ab1f7552c7..6ce4864aabd 100644
--- a/gdb/guile/guile.h
+++ b/gdb/guile/guile.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GUILE_GUILE_H
-#define GUILE_GUILE_H
+#ifndef GDB_GUILE_GUILE_H
+#define GDB_GUILE_GUILE_H
 
 #include "extension.h"
 
@@ -28,4 +28,4 @@ extern const struct extension_language_defn extension_language_guile;
 /* Command element for the 'guile' command.  */
 extern cmd_list_element *guile_cmd_element;
 
-#endif /* GUILE_GUILE_H */
+#endif /* GDB_GUILE_GUILE_H */
diff --git a/gdb/hppa-bsd-tdep.h b/gdb/hppa-bsd-tdep.h
index 42aefe6e142..54599ab9ab4 100644
--- a/gdb/hppa-bsd-tdep.h
+++ b/gdb/hppa-bsd-tdep.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_BSD_TDEP_H
-#define HPPA_BSD_TDEP_H
+#ifndef GDB_HPPA_BSD_TDEP_H
+#define GDB_HPPA_BSD_TDEP_H
 
 extern void hppabsd_init_abi (struct gdbarch_info, struct gdbarch *);
 
-#endif /* hppa-bsd-tdep.h */
+#endif /* GDB_HPPA_BSD_TDEP_H */
diff --git a/gdb/hppa-linux-offsets.h b/gdb/hppa-linux-offsets.h
index b1543b05705..958afd115a8 100644
--- a/gdb/hppa-linux-offsets.h
+++ b/gdb/hppa-linux-offsets.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_LINUX_OFFSETS_H
-#define HPPA_LINUX_OFFSETS_H
+#ifndef GDB_HPPA_LINUX_OFFSETS_H
+#define GDB_HPPA_LINUX_OFFSETS_H
 
 #define PT_PSW offsetof(struct pt_regs, gr[ 0])
 #define PT_GR1 offsetof(struct pt_regs, gr[ 1])
@@ -105,4 +105,4 @@
 #define PT_ISR offsetof(struct pt_regs, isr)
 #define PT_IOR offsetof(struct pt_regs, ior)
 
-#endif /* HPPA_LINUX_OFFSETS_H */
+#endif /* GDB_HPPA_LINUX_OFFSETS_H */
diff --git a/gdb/hppa-tdep.h b/gdb/hppa-tdep.h
index 0f706536cc9..e1143a56bcd 100644
--- a/gdb/hppa-tdep.h
+++ b/gdb/hppa-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_TDEP_H
-#define HPPA_TDEP_H
+#ifndef GDB_HPPA_TDEP_H
+#define GDB_HPPA_TDEP_H
 
 #include "gdbarch.h"
 
@@ -214,4 +214,4 @@ extern int hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
 					  CORE_ADDR pc);
 extern CORE_ADDR hppa_skip_trampoline_code (const frame_info_ptr &, CORE_ADDR pc);
 
-#endif  /* hppa-tdep.h */
+#endif /* GDB_HPPA_TDEP_H */
diff --git a/gdb/i386-bsd-nat.h b/gdb/i386-bsd-nat.h
index a05eb90d4f8..54061ab46d1 100644
--- a/gdb/i386-bsd-nat.h
+++ b/gdb/i386-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_BSD_NAT_H
-#define I386_BSD_NAT_H
+#ifndef GDB_I386_BSD_NAT_H
+#define GDB_I386_BSD_NAT_H
 
 #include "x86-bsd-nat.h"
 
@@ -41,4 +41,4 @@ class i386_bsd_nat_target : public x86bsd_nat_target<BaseTarget>
   { i386bsd_store_inferior_registers (regcache, regnum); }
 };
 
-#endif /* i386-bsd-nat.h */
+#endif /* GDB_I386_BSD_NAT_H */
diff --git a/gdb/i386-darwin-tdep.h b/gdb/i386-darwin-tdep.h
index 0b867fab94c..7ccdeeced13 100644
--- a/gdb/i386-darwin-tdep.h
+++ b/gdb/i386-darwin-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_DARWIN_TDEP_H
-#define I386_DARWIN_TDEP_H
+#ifndef GDB_I386_DARWIN_TDEP_H
+#define GDB_I386_DARWIN_TDEP_H
 
 #include "frame.h"
 
@@ -29,4 +29,4 @@ extern const int i386_darwin_thread_state_num_regs;
 
 int darwin_dwarf_signal_frame_p (struct gdbarch *, const frame_info_ptr &);
 
-#endif /* I386_DARWIN_TDEP_H */
+#endif /* GDB_I386_DARWIN_TDEP_H */
diff --git a/gdb/i386-fbsd-tdep.h b/gdb/i386-fbsd-tdep.h
index 0a008421915..3b953e58435 100644
--- a/gdb/i386-fbsd-tdep.h
+++ b/gdb/i386-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_FBSD_TDEP_H
-#define I386_FBSD_TDEP_H
+#ifndef GDB_I386_FBSD_TDEP_H
+#define GDB_I386_FBSD_TDEP_H
 
 #include "gdbsupport/x86-xstate.h"
 #include "regset.h"
@@ -42,4 +42,4 @@ bool i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
 
 extern const struct regset i386_fbsd_gregset;
 
-#endif /* i386-fbsd-tdep.h */
+#endif /* GDB_I386_FBSD_TDEP_H */
diff --git a/gdb/i386-linux-nat.h b/gdb/i386-linux-nat.h
index c3d32aff1be..e4a86c70382 100644
--- a/gdb/i386-linux-nat.h
+++ b/gdb/i386-linux-nat.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_LINUX_NAT_H
-#define I386_LINUX_NAT_H 1
+#ifndef GDB_I386_LINUX_NAT_H
+#define GDB_I386_LINUX_NAT_H
 
 /* Does the current host support the GETFPXREGS request? */
 extern int have_ptrace_getfpxregs;
 
-#endif
+#endif /* GDB_I386_LINUX_NAT_H */
diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h
index 5891747572b..025b0f5fc51 100644
--- a/gdb/i386-linux-tdep.h
+++ b/gdb/i386-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_LINUX_TDEP_H
-#define I386_LINUX_TDEP_H
+#ifndef GDB_I386_LINUX_TDEP_H
+#define GDB_I386_LINUX_TDEP_H
 
 #include "gdbsupport/x86-xstate.h"
 
@@ -83,4 +83,4 @@ extern int i386_linux_gregset_reg_offset[];
 /* Return x86 siginfo type.  */
 extern struct type *x86_linux_get_siginfo_type (struct gdbarch *gdbarch);
 
-#endif /* i386-linux-tdep.h */
+#endif /* GDB_I386_LINUX_TDEP_H */
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index a85e0a984a0..e394e159c04 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_TDEP_H
-#define I386_TDEP_H
+#ifndef GDB_I386_TDEP_H
+#define GDB_I386_TDEP_H
 
 #include "gdbarch.h"
 #include "infrun.h"
@@ -488,4 +488,4 @@ extern int i386_stap_is_single_operand (struct gdbarch *gdbarch,
 extern expr::operation_up i386_stap_parse_special_token
      (struct gdbarch *gdbarch, struct stap_parse_info *p);
 
-#endif /* i386-tdep.h */
+#endif /* GDB_I386_TDEP_H */
diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h
index 30d769478a6..77e089ab723 100644
--- a/gdb/i387-tdep.h
+++ b/gdb/i387-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I387_TDEP_H
-#define I387_TDEP_H
+#ifndef GDB_I387_TDEP_H
+#define GDB_I387_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -185,4 +185,4 @@ extern void i387_return_value (struct gdbarch *gdbarch,
    all memory range can be accessed.  */
 extern void i387_reset_bnd_regs (struct gdbarch *gdbarch,
 				 struct regcache *regcache);
-#endif /* i387-tdep.h */
+#endif /* GDB_I387_TDEP_H */
diff --git a/gdb/ia64-libunwind-tdep.h b/gdb/ia64-libunwind-tdep.h
index 4f064bfc333..9d358642d9f 100644
--- a/gdb/ia64-libunwind-tdep.h
+++ b/gdb/ia64-libunwind-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef IA64_LIBUNWIND_TDEP_H
-#define IA64_LIBUNWIND_TDEP_H 1
+#ifndef GDB_IA64_LIBUNWIND_TDEP_H
+#define GDB_IA64_LIBUNWIND_TDEP_H
 
 class frame_info_ptr;
 struct frame_id;
@@ -76,4 +76,4 @@ int libunwind_get_reg_special (struct gdbarch *gdbarch,
 			       readable_regcache *regcache,
 			       int regnum, void *buf);
 
-#endif /* IA64_LIBUNWIND_TDEP_H */
+#endif /* GDB_IA64_LIBUNWIND_TDEP_H */
diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h
index 64be38b4d76..e5eb7eac071 100644
--- a/gdb/ia64-tdep.h
+++ b/gdb/ia64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef IA64_TDEP_H
-#define IA64_TDEP_H
+#ifndef GDB_IA64_TDEP_H
+#define GDB_IA64_TDEP_H
 
 #include "gdbarch.h"
 
@@ -265,4 +265,4 @@ extern unw_accessors_t ia64_unw_rse_accessors;
 extern struct libunwind_descr ia64_libunwind_descr;
 #endif
 
-#endif /* ia64-tdep.h */
+#endif /* GDB_IA64_TDEP_H */
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index 91955a64f4c..2a251b365f2 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_CHILD_H
-#define INF_CHILD_H
+#ifndef GDB_INF_CHILD_H
+#define GDB_INF_CHILD_H
 
 #include "target.h"
 #include "process-stratum-target.h"
@@ -115,4 +115,4 @@ extern void add_inf_child_target (inf_child_target *target);
    targets use add_inf_child_target instead.  */
 extern void inf_child_open_target (const char *arg, int from_tty);
 
-#endif
+#endif /* GDB_INF_CHILD_H */
diff --git a/gdb/inf-loop.h b/gdb/inf-loop.h
index ceabd14bd9e..2bf29fa7498 100644
--- a/gdb/inf-loop.h
+++ b/gdb/inf-loop.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_LOOP_H
-#define INF_LOOP_H
+#ifndef GDB_INF_LOOP_H
+#define GDB_INF_LOOP_H
 
 #include "target.h"
 
 extern void inferior_event_handler (enum inferior_event_type event_type);
 
-#endif /* #ifndef INF_LOOP_H */
+#endif /* GDB_INF_LOOP_H */
diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h
index 868bee92da8..901f7e9162d 100644
--- a/gdb/inf-ptrace.h
+++ b/gdb/inf-ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_PTRACE_H
-#define INF_PTRACE_H
+#ifndef GDB_INF_PTRACE_H
+#define GDB_INF_PTRACE_H
 
 #include "gdbsupport/event-pipe.h"
 #include "inf-child.h"
@@ -113,4 +113,4 @@ struct inf_ptrace_target : public inf_child_target
 extern pid_t get_ptrace_pid (ptid_t);
 #endif
 
-#endif
+#endif /* GDB_INF_PTRACE_H */
diff --git a/gdb/infcall.h b/gdb/infcall.h
index dcc701b5f31..eccf13307c7 100644
--- a/gdb/infcall.h
+++ b/gdb/infcall.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFCALL_H
-#define INFCALL_H
+#ifndef GDB_INFCALL_H
+#define GDB_INFCALL_H
 
 #include "dummy-frame.h"
 #include "gdbsupport/array-view.h"
@@ -71,4 +71,4 @@ extern struct value *
 
 extern void error_call_unknown_return_type (const char *func_name);
 
-#endif
+#endif /* GDB_INFCALL_H */
diff --git a/gdb/inferior-iter.h b/gdb/inferior-iter.h
index 821c7bec94e..05ddfca54c9 100644
--- a/gdb/inferior-iter.h
+++ b/gdb/inferior-iter.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFERIOR_ITER_H
-#define INFERIOR_ITER_H
+#ifndef GDB_INFERIOR_ITER_H
+#define GDB_INFERIOR_ITER_H
 
 #include "gdbsupport/filtered-iterator.h"
 #include "gdbsupport/safe-iterator.h"
@@ -132,4 +132,4 @@ using all_inferiors_safe_iterator
 
 using all_inferiors_safe_range = iterator_range<all_inferiors_safe_iterator>;
 
-#endif /* !defined (INFERIOR_ITER_H) */
+#endif /* GDB_INFERIOR_ITER_H */
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 7be28423aeb..4163396b775 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (INFERIOR_H)
-#define INFERIOR_H 1
+#ifndef GDB_INFERIOR_H
+#define GDB_INFERIOR_H
 
 #include <exception>
 #include <list>
@@ -869,4 +869,4 @@ valid_global_inferior_id (int id)
   return false;
 }
 
-#endif /* !defined (INFERIOR_H) */
+#endif /* GDB_INFERIOR_H */
diff --git a/gdb/infrun.h b/gdb/infrun.h
index 5f83ca2b4c3..4574874706e 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFRUN_H
-#define INFRUN_H 1
+#ifndef GDB_INFRUN_H
+#define GDB_INFRUN_H
 
 #include "gdbthread.h"
 #include "symtab.h"
@@ -418,4 +418,4 @@ struct scoped_enable_commit_resumed
 };
 
 
-#endif /* INFRUN_H */
+#endif /* GDB_INFRUN_H */
diff --git a/gdb/inline-frame.h b/gdb/inline-frame.h
index bbe617c7c5b..a11376f1d43 100644
--- a/gdb/inline-frame.h
+++ b/gdb/inline-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (INLINE_FRAME_H)
-#define INLINE_FRAME_H 1
+#ifndef GDB_INLINE_FRAME_H
+#define GDB_INLINE_FRAME_H
 
 class frame_info_ptr;
 struct frame_unwind;
@@ -70,4 +70,4 @@ struct symbol *inline_skipped_symbol (thread_info *thread);
 
 int frame_inlined_callees (const frame_info_ptr &this_frame);
 
-#endif /* !defined (INLINE_FRAME_H) */
+#endif /* GDB_INLINE_FRAME_H */
diff --git a/gdb/interps.h b/gdb/interps.h
index bd435d734af..726b660684e 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INTERPS_H
-#define INTERPS_H
+#ifndef GDB_INTERPS_H
+#define GDB_INTERPS_H
 
 #include "gdbsupport/intrusive_list.h"
 
@@ -372,4 +372,4 @@ extern void interps_notify_memory_changed (inferior *inf, CORE_ADDR addr,
 #define INTERP_TUI		"tui"
 #define INTERP_INSIGHT		"insight"
 
-#endif
+#endif /* GDB_INTERPS_H */
diff --git a/gdb/jit.h b/gdb/jit.h
index ade0fb28ce2..59ad900c4e0 100644
--- a/gdb/jit.h
+++ b/gdb/jit.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef JIT_H
-#define JIT_H
+#ifndef GDB_JIT_H
+#define GDB_JIT_H
 
 struct inferior;
 struct objfile;
@@ -122,4 +122,4 @@ extern void jit_breakpoint_re_set (void);
 
 extern void jit_event_handler (gdbarch *gdbarch, objfile *jiter);
 
-#endif /* JIT_H */
+#endif /* GDB_JIT_H */
diff --git a/gdb/language.h b/gdb/language.h
index e67150d7596..157c46877d2 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (LANGUAGE_H)
-#define LANGUAGE_H 1
+#ifndef GDB_LANGUAGE_H
+#define GDB_LANGUAGE_H
 
 #include "symtab.h"
 #include "gdbsupport/function-view.h"
@@ -911,4 +911,4 @@ class scoped_switch_to_sym_language_if_auto
   enum language m_lang;
 };
 
-#endif /* defined (LANGUAGE_H) */
+#endif /* GDB_LANGUAGE_H */
diff --git a/gdb/linespec.h b/gdb/linespec.h
index 18f491d74d0..86eb36bbae9 100644
--- a/gdb/linespec.h
+++ b/gdb/linespec.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (LINESPEC_H)
-#define LINESPEC_H 1
+#ifndef GDB_LINESPEC_H
+#define GDB_LINESPEC_H
 
 struct symtab;
 
@@ -201,4 +201,4 @@ extern void linespec_complete_label (completion_tracker &tracker,
    advancing EXP_PTR past any parsed text.  */
 
 extern CORE_ADDR linespec_expression_to_pc (const char **exp_ptr);
-#endif /* defined (LINESPEC_H) */
+#endif /* GDB_LINESPEC_H */
diff --git a/gdb/linux-fork.h b/gdb/linux-fork.h
index c553aaf0740..2a306881695 100644
--- a/gdb/linux-fork.h
+++ b/gdb/linux-fork.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_FORK_H
-#define LINUX_FORK_H
+#ifndef GDB_LINUX_FORK_H
+#define GDB_LINUX_FORK_H
 
 struct fork_info;
 struct lwp_info;
@@ -30,4 +30,4 @@ extern void linux_fork_detach (int, lwp_info *);
 extern int forks_exist_p (void);
 extern int linux_fork_checkpointing_p (int);
 
-#endif /* LINUX_FORK_H */
+#endif /* GDB_LINUX_FORK_H */
diff --git a/gdb/linux-nat-trad.h b/gdb/linux-nat-trad.h
index ae40ce773b4..c1c031ea27d 100644
--- a/gdb/linux-nat-trad.h
+++ b/gdb/linux-nat-trad.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_NAT_TRAD_H
-#define LINUX_NAT_TRAD_H
+#ifndef GDB_LINUX_NAT_TRAD_H
+#define GDB_LINUX_NAT_TRAD_H
 
 #include "linux-nat.h"
 
@@ -43,4 +43,4 @@ class linux_nat_trad_target : public linux_nat_target
   void store_register (const struct regcache *regcache, int regnum);
 };
 
-#endif /* LINUX_NAT_TRAD_H */
+#endif /* GDB_LINUX_NAT_TRAD_H */
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 4dcbe9e170a..01e071e0f89 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_NAT_H
-#define LINUX_NAT_H
+#ifndef GDB_LINUX_NAT_H
+#define GDB_LINUX_NAT_H
 
 #include "nat/linux-nat.h"
 #include "inf-ptrace.h"
@@ -339,4 +339,4 @@ void linux_nat_switch_fork (ptid_t new_ptid);
    uninitialized in such case).  */
 bool linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
 
-#endif /* LINUX_NAT_H */
+#endif /* GDB_LINUX_NAT_H */
diff --git a/gdb/linux-record.h b/gdb/linux-record.h
index 962cedc3d34..26d113b6a65 100644
--- a/gdb/linux-record.h
+++ b/gdb/linux-record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_RECORD_H
-#define LINUX_RECORD_H
+#ifndef GDB_LINUX_RECORD_H
+#define GDB_LINUX_RECORD_H
 
 struct linux_record_tdep
 {
@@ -549,4 +549,4 @@ extern int record_linux_system_call (enum gdb_syscall num,
 				     struct regcache *regcache,
 				     struct linux_record_tdep *tdep);
 
-#endif /* LINUX_RECORD_H */
+#endif /* GDB_LINUX_RECORD_H */
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index 66b03cabaa6..bf4220bf75b 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_TDEP_H
-#define LINUX_TDEP_H
+#ifndef GDB_LINUX_TDEP_H
+#define GDB_LINUX_TDEP_H
 
 #include "bfd.h"
 #include "displaced-stepping.h"
@@ -117,4 +117,4 @@ extern CORE_ADDR linux_get_hwcap2 ();
 extern struct link_map_offsets *linux_ilp32_fetch_link_map_offsets ();
 extern struct link_map_offsets *linux_lp64_fetch_link_map_offsets ();
 
-#endif /* linux-tdep.h */
+#endif /* GDB_LINUX_TDEP_H */
diff --git a/gdb/location.h b/gdb/location.h
index e8cdd0d4ec6..7772d10426f 100644
--- a/gdb/location.h
+++ b/gdb/location.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LOCATION_H
-#define LOCATION_H
+#ifndef GDB_LOCATION_H
+#define GDB_LOCATION_H
 
 #include "symtab.h"
 
@@ -365,4 +365,4 @@ extern location_spec_up
 				    const struct language_defn *language,
 				    explicit_completion_info *completion_info);
 
-#endif /* LOCATION_H */
+#endif /* GDB_LOCATION_H */
diff --git a/gdb/loongarch-tdep.h b/gdb/loongarch-tdep.h
index 5c8108182ad..4908923db20 100644
--- a/gdb/loongarch-tdep.h
+++ b/gdb/loongarch-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LOONGARCH_TDEP_H
-#define LOONGARCH_TDEP_H
+#ifndef GDB_LOONGARCH_TDEP_H
+#define GDB_LOONGARCH_TDEP_H
 
 #include "gdbarch.h"
 #include "arch/loongarch.h"
@@ -44,4 +44,4 @@ struct loongarch_gdbarch_tdep : gdbarch_tdep_base
   CORE_ADDR (*syscall_next_pc) (const frame_info_ptr &frame) = nullptr;
 };
 
-#endif /* LOONGARCH_TDEP_H  */
+#endif /* GDB_LOONGARCH_TDEP_H */
diff --git a/gdb/m2-exp.h b/gdb/m2-exp.h
index 9d2634f813b..ce773cbf864 100644
--- a/gdb/m2-exp.h
+++ b/gdb/m2-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M2_EXP_H
-#define M2_EXP_H
+#ifndef GDB_M2_EXP_H
+#define GDB_M2_EXP_H
 
 #include "expop.h"
 
@@ -81,4 +81,4 @@ class m2_binop_subscript_operation
 
 } /* namespace expr */
 
-#endif /* M2_EXP_H */
+#endif /* GDB_M2_EXP_H */
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index 3d3c6980bb2..1551d7e00d6 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M2_LANG_H
-#define M2_LANG_H
+#ifndef GDB_M2_LANG_H
+#define GDB_M2_LANG_H
 
 struct type_print_options;
 struct parser_state;
@@ -149,4 +149,4 @@ class m2_language : public language_defn
   { return true; }
 };
 
-#endif /* M2_LANG_H */
+#endif /* GDB_M2_LANG_H */
diff --git a/gdb/m32r-tdep.h b/gdb/m32r-tdep.h
index 83799a3c698..1cc0de38c15 100644
--- a/gdb/m32r-tdep.h
+++ b/gdb/m32r-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M32R_TDEP_H
-#define M32R_TDEP_H
+#ifndef GDB_M32R_TDEP_H
+#define GDB_M32R_TDEP_H
 
 #include "gdbarch.h"
 
@@ -49,4 +49,4 @@ enum m32r_regnum
 
 #define M32R_NUM_REGS 25
 
-#endif /* m32r-tdep.h */
+#endif /* GDB_M32R_TDEP_H */
diff --git a/gdb/m68k-tdep.h b/gdb/m68k-tdep.h
index dcb3728896e..ad569932144 100644
--- a/gdb/m68k-tdep.h
+++ b/gdb/m68k-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M68K_TDEP_H
-#define M68K_TDEP_H
+#ifndef GDB_M68K_TDEP_H
+#define GDB_M68K_TDEP_H
 
 #include "gdbarch.h"
 
@@ -111,4 +111,4 @@ extern void m68k_svr4_init_abi (struct gdbarch_info, struct gdbarch *);
 
 extern int m68kbsd_fpreg_offset (struct gdbarch *gdbarch, int regnum);
 
-#endif /* m68k-tdep.h */
+#endif /* GDB_M68K_TDEP_H */
diff --git a/gdb/macroexp.h b/gdb/macroexp.h
index 2706f15787f..6fd5dc27916 100644
--- a/gdb/macroexp.h
+++ b/gdb/macroexp.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef MACROEXP_H
-#define MACROEXP_H
+#ifndef GDB_MACROEXP_H
+#define GDB_MACROEXP_H
 
 struct macro_scope;
 
@@ -81,4 +81,4 @@ int macro_is_digit (int c);
 /* Stringify STR according to C rules and return a null-terminated string.  */
 gdb::unique_xmalloc_ptr<char> macro_stringify (const char *str);
 
-#endif /* MACROEXP_H */
+#endif /* GDB_MACROEXP_H */
diff --git a/gdb/macroscope.h b/gdb/macroscope.h
index 6a1f5f0a3fe..ce9ae33838f 100644
--- a/gdb/macroscope.h
+++ b/gdb/macroscope.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MACROSCOPE_H
-#define MACROSCOPE_H
+#ifndef GDB_MACROSCOPE_H
+#define GDB_MACROSCOPE_H
 
 #include "macrotab.h"
 #include "symtab.h"
@@ -61,4 +61,4 @@ gdb::unique_xmalloc_ptr<struct macro_scope> default_macro_scope (void);
 macro_definition *standard_macro_lookup (const char *name,
 					 const macro_scope &ms);
 
-#endif /* MACROSCOPE_H */
+#endif /* GDB_MACROSCOPE_H */
diff --git a/gdb/macrotab.h b/gdb/macrotab.h
index 789beed0476..ea6557aa391 100644
--- a/gdb/macrotab.h
+++ b/gdb/macrotab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MACROTAB_H
-#define MACROTAB_H
+#ifndef GDB_MACROTAB_H
+#define GDB_MACROTAB_H
 
 #include "gdbsupport/function-view.h"
 
@@ -361,4 +361,4 @@ void macro_for_each_in_scope (struct macro_source_file *file, int line,
    of macro filenames printing was "absolute".  */
 extern std::string macro_source_fullname (struct macro_source_file *file);
 
-#endif /* MACROTAB_H */
+#endif /* GDB_MACROTAB_H */
diff --git a/gdb/main.h b/gdb/main.h
index fa267786d89..35dfe9d4729 100644
--- a/gdb/main.h
+++ b/gdb/main.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MAIN_H
-#define MAIN_H
+#ifndef GDB_MAIN_H
+#define GDB_MAIN_H
 
 struct captured_main_args
 {
@@ -46,4 +46,4 @@ extern char *windows_get_absolute_argv0 (const char *argv0);
 
 extern void set_gdb_data_directory (const char *new_data_dir);
 
-#endif
+#endif /* GDB_MAIN_H */
diff --git a/gdb/maint.h b/gdb/maint.h
index c1860d8cd59..5529d8a9d3a 100644
--- a/gdb/maint.h
+++ b/gdb/maint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MAINT_H
-#define MAINT_H
+#ifndef GDB_MAINT_H
+#define GDB_MAINT_H
 
 #include "gdbsupport/run-time-clock.h"
 #include <chrono>
@@ -70,4 +70,4 @@ class scoped_command_stats
 extern obj_section *maint_obj_section_from_bfd_section (bfd *abfd,
 							asection *asection,
 							objfile *ofile);
-#endif /* MAINT_H */
+#endif /* GDB_MAINT_H */
diff --git a/gdb/mdebugread.h b/gdb/mdebugread.h
index af0584bd3e6..4f434226ff9 100644
--- a/gdb/mdebugread.h
+++ b/gdb/mdebugread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MDEBUGREAD_H
-#define MDEBUGREAD_H
+#ifndef GDB_MDEBUGREAD_H
+#define GDB_MDEBUGREAD_H
 
 #include "coff/sym.h"
 #include "coff/symconst.h"
@@ -46,4 +46,4 @@ extern void elfmdebug_build_psymtabs (struct objfile *,
 				      const struct ecoff_debug_swap *,
 				      asection *);
 
-#endif /* MDEBUGREAD_H */
+#endif /* GDB_MDEBUGREAD_H */
diff --git a/gdb/memattr.h b/gdb/memattr.h
index dcc52298846..a6c9e6dcd8c 100644
--- a/gdb/memattr.h
+++ b/gdb/memattr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMATTR_H
-#define MEMATTR_H
+#ifndef GDB_MEMATTR_H
+#define GDB_MEMATTR_H
 
 enum mem_access_mode
 {
@@ -129,4 +129,4 @@ extern struct mem_region *lookup_mem_region (CORE_ADDR);
 
 void invalidate_target_mem_regions (void);
 
-#endif	/* MEMATTR_H */
+#endif /* GDB_MEMATTR_H */
diff --git a/gdb/memory-map.h b/gdb/memory-map.h
index 525646b6e37..59fcd4a9f73 100644
--- a/gdb/memory-map.h
+++ b/gdb/memory-map.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef MEMORY_MAP_H
-#define MEMORY_MAP_H
+#ifndef GDB_MEMORY_MAP_H
+#define GDB_MEMORY_MAP_H
 
 #include "memattr.h"
 
@@ -28,4 +28,4 @@
    return an empty vector.  Does not throw.  */
 std::vector<mem_region> parse_memory_map (const char *memory_map);
 
-#endif
+#endif /* GDB_MEMORY_MAP_H */
diff --git a/gdb/memrange.h b/gdb/memrange.h
index 74df82588f4..ec033ddb21e 100644
--- a/gdb/memrange.h
+++ b/gdb/memrange.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMRANGE_H
-#define MEMRANGE_H
+#ifndef GDB_MEMRANGE_H
+#define GDB_MEMRANGE_H
 
 /* Defines a [START, START + LENGTH) memory range.  */
 
@@ -64,4 +64,4 @@ extern int address_in_mem_range (CORE_ADDR addr,
 
 extern void normalize_mem_ranges (std::vector<mem_range> *memory);
 
-#endif
+#endif /* GDB_MEMRANGE_H */
diff --git a/gdb/memtag.h b/gdb/memtag.h
index b176371699c..600b4b9db74 100644
--- a/gdb/memtag.h
+++ b/gdb/memtag.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMTAG_H
-#define MEMTAG_H
+#ifndef GDB_MEMTAG_H
+#define GDB_MEMTAG_H
 
 #include "bfd.h"
 
@@ -47,4 +47,4 @@ bool get_next_core_memtag_section (bfd *abfd, asection *section,
 				   CORE_ADDR address,
 				   memtag_section_info &info);
 
-#endif /* MEMTAG_H */
+#endif /* GDB_MEMTAG_H */
diff --git a/gdb/mi/mi-cmd-break.h b/gdb/mi/mi-cmd-break.h
index 76aedfffcd9..160c578865d 100644
--- a/gdb/mi/mi-cmd-break.h
+++ b/gdb/mi/mi-cmd-break.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CMD_BREAK_H
-#define MI_MI_CMD_BREAK_H
+#ifndef GDB_MI_MI_CMD_BREAK_H
+#define GDB_MI_MI_CMD_BREAK_H
 
 #include "gdbsupport/scoped_restore.h"
 
@@ -27,4 +27,4 @@
    catchpoint.  */
 scoped_restore_tmpl<int> setup_breakpoint_reporting (void);
 
-#endif /* MI_MI_CMD_BREAK_H */
+#endif /* GDB_MI_MI_CMD_BREAK_H */
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index 26faded3032..9e31ba397b0 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CMDS_H
-#define MI_MI_CMDS_H
+#ifndef GDB_MI_MI_CMDS_H
+#define GDB_MI_MI_CMDS_H
 
 #include "gdbsupport/function-view.h"
 #include <optional>
@@ -237,4 +237,4 @@ extern void remove_mi_cmd_entries (remove_mi_cmd_entries_ftype callback);
 
 extern bool mi_simple_type_p (struct type *type);
 
-#endif /* MI_MI_CMDS_H */
+#endif /* GDB_MI_MI_CMDS_H */
diff --git a/gdb/mi/mi-common.h b/gdb/mi/mi-common.h
index 38ad35c3e36..4c3951ca8c0 100644
--- a/gdb/mi/mi-common.h
+++ b/gdb/mi/mi-common.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_COMMON_H
-#define MI_MI_COMMON_H
+#ifndef GDB_MI_MI_COMMON_H
+#define GDB_MI_MI_COMMON_H
 
 /* Represents the reason why GDB is sending an asynchronous command to
    the front end.  NOTE: When modifying this, don't forget to update
@@ -49,4 +49,4 @@ enum async_reply_reason
 
 const char *async_reason_lookup (enum async_reply_reason reason);
 
-#endif /* MI_MI_COMMON_H */
+#endif /* GDB_MI_MI_COMMON_H */
diff --git a/gdb/mi/mi-console.h b/gdb/mi/mi-console.h
index 89ba199fbce..89e0f4d3db6 100644
--- a/gdb/mi/mi-console.h
+++ b/gdb/mi/mi-console.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CONSOLE_H
-#define MI_MI_CONSOLE_H
+#ifndef GDB_MI_MI_CONSOLE_H
+#define GDB_MI_MI_CONSOLE_H
 
 /* An output stream for MI.  Wraps a given output stream with a prefix
    and handles quoting.  This stream is locally buffered.  */
@@ -55,4 +55,4 @@ class mi_console_file : public ui_file
   char m_quote;
 };
 
-#endif /* MI_MI_CONSOLE_H */
+#endif /* GDB_MI_MI_CONSOLE_H */
diff --git a/gdb/mi/mi-getopt.h b/gdb/mi/mi-getopt.h
index f3dd326fced..5bc35aa565a 100644
--- a/gdb/mi/mi-getopt.h
+++ b/gdb/mi/mi-getopt.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_GETOPT_H
-#define MI_MI_GETOPT_H
+#ifndef GDB_MI_MI_GETOPT_H
+#define GDB_MI_MI_GETOPT_H
 
 /* The option list.  Terminated by NAME==NULL.  ARG_P that the option
    requires an argument.  INDEX is returned to identify the option.  */
@@ -78,4 +78,4 @@ extern int mi_getopt_allow_unknown (const char *prefix, int argc,
 extern int mi_valid_noargs (const char *prefix, int argc,
 			    const char *const *argv);
 
-#endif /* MI_MI_GETOPT_H */
+#endif /* GDB_MI_MI_GETOPT_H */
diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h
index cd48fcf0aa1..8f5eee6f558 100644
--- a/gdb/mi/mi-interp.h
+++ b/gdb/mi/mi-interp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_INTERP_H
-#define MI_MI_INTERP_H
+#ifndef GDB_MI_MI_INTERP_H
+#define GDB_MI_MI_INTERP_H
 
 #include "interps.h"
 
@@ -119,4 +119,4 @@ as_mi_interp (struct interp *interp)
   return dynamic_cast<mi_interp *> (interp);
 }
 
-#endif /* MI_MI_INTERP_H */
+#endif /* GDB_MI_MI_INTERP_H */
diff --git a/gdb/mi/mi-main.h b/gdb/mi/mi-main.h
index 59c9ffa31bb..af670295c1f 100644
--- a/gdb/mi/mi-main.h
+++ b/gdb/mi/mi-main.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_MAIN_H
-#define MI_MI_MAIN_H
+#ifndef GDB_MI_MI_MAIN_H
+#define GDB_MI_MI_MAIN_H
 
 struct ui_file;
 
@@ -79,4 +79,4 @@ extern void mi_cmd_fix_breakpoint_script_output (const char *command,
 
 extern int mi_parse_thread_group_id (const char *id);
 
-#endif /* MI_MI_MAIN_H */
+#endif /* GDB_MI_MI_MAIN_H */
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index a7afb156ed4..16e6db2456e 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_OUT_H
-#define MI_MI_OUT_H
+#ifndef GDB_MI_MI_OUT_H
+#define GDB_MI_MI_OUT_H
 
 #include <vector>
 
@@ -151,4 +151,4 @@ std::unique_ptr<mi_ui_out> mi_out_new (const char *mi_version);
 void mi_out_put (ui_out *uiout, struct ui_file *stream);
 void mi_out_rewind (ui_out *uiout);
 
-#endif /* MI_MI_OUT_H */
+#endif /* GDB_MI_MI_OUT_H */
diff --git a/gdb/mi/mi-parse.h b/gdb/mi/mi-parse.h
index 8b685755a5c..22d10185925 100644
--- a/gdb/mi/mi-parse.h
+++ b/gdb/mi/mi-parse.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_PARSE_H
-#define MI_MI_PARSE_H
+#ifndef GDB_MI_MI_PARSE_H
+#define GDB_MI_MI_PARSE_H
 
 #include "gdbsupport/run-time-clock.h"
 #include <chrono>
@@ -101,4 +101,4 @@ struct mi_parse
 
 enum print_values mi_parse_print_values (const char *name);
 
-#endif /* MI_MI_PARSE_H */
+#endif /* GDB_MI_MI_PARSE_H */
diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
index 0b4a5a3f472..7b5924e9317 100644
--- a/gdb/microblaze-tdep.h
+++ b/gdb/microblaze-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MICROBLAZE_TDEP_H
-#define MICROBLAZE_TDEP_H 1
+#ifndef GDB_MICROBLAZE_TDEP_H
+#define GDB_MICROBLAZE_TDEP_H
 
 #include "gdbarch.h"
 
@@ -120,4 +120,4 @@ struct microblaze_frame_cache
    Only used for native debugging.  */
 #define MICROBLAZE_BREAKPOINT {0xb9, 0xcc, 0x00, 0x60}
 
-#endif /* microblaze-tdep.h */
+#endif /* GDB_MICROBLAZE_TDEP_H */
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index d44f281939b..4d704f0d35b 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MINSYMS_H
-#define MINSYMS_H
+#ifndef GDB_MINSYMS_H
+#define GDB_MINSYMS_H
 
 struct type;
 
@@ -327,4 +327,4 @@ CORE_ADDR minimal_symbol_upper_bound (struct bound_minimal_symbol minsym);
 type *find_minsym_type_and_address (minimal_symbol *msymbol, objfile *objf,
 				    CORE_ADDR *address_p);
 
-#endif /* MINSYMS_H */
+#endif /* GDB_MINSYMS_H */
diff --git a/gdb/mips-fbsd-tdep.h b/gdb/mips-fbsd-tdep.h
index ec834d0474a..201b1e5a793 100644
--- a/gdb/mips-fbsd-tdep.h
+++ b/gdb/mips-fbsd-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_FBSD_TDEP_H
-#define MIPS_FBSD_TDEP_H
+#ifndef GDB_MIPS_FBSD_TDEP_H
+#define GDB_MIPS_FBSD_TDEP_H
 
 void mips_fbsd_supply_fpregs (struct regcache *, int, const void *, size_t);
 void mips_fbsd_supply_gregs (struct regcache *, int, const void *, size_t);
 void mips_fbsd_collect_fpregs (const struct regcache *, int, void *, size_t);
 void mips_fbsd_collect_gregs (const struct regcache *, int, void *, size_t);
 
-#endif /* MIPS_FBSD_TDEP_H */
+#endif /* GDB_MIPS_FBSD_TDEP_H */
diff --git a/gdb/mips-linux-tdep.h b/gdb/mips-linux-tdep.h
index 2c4c35954c4..8670c0b7e15 100644
--- a/gdb/mips-linux-tdep.h
+++ b/gdb/mips-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_LINUX_TDEP_H
-#define MIPS_LINUX_TDEP_H
+#ifndef GDB_MIPS_LINUX_TDEP_H
+#define GDB_MIPS_LINUX_TDEP_H
 
 /* Copied from <asm/elf.h>.  */
 #define ELF_NGREG       45
@@ -113,4 +113,4 @@ extern const struct target_desc *tdesc_mips64_linux;
 extern const struct target_desc *tdesc_mips_dsp_linux;
 extern const struct target_desc *tdesc_mips64_dsp_linux;
 
-#endif /* MIPS_LINUX_TDEP_H */
+#endif /* GDB_MIPS_LINUX_TDEP_H */
diff --git a/gdb/mips-netbsd-tdep.h b/gdb/mips-netbsd-tdep.h
index 034261fbf44..e9544f0f1bf 100644
--- a/gdb/mips-netbsd-tdep.h
+++ b/gdb/mips-netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_NBSD_TDEP_H
-#define MIPS_NBSD_TDEP_H
+#ifndef GDB_MIPS_NETBSD_TDEP_H
+#define GDB_MIPS_NETBSD_TDEP_H
 
 void mipsnbsd_supply_reg (struct regcache *, const char *, int);
 void mipsnbsd_fill_reg (const struct regcache *, char *, int);
@@ -26,4 +26,4 @@ void mipsnbsd_fill_reg (const struct regcache *, char *, int);
 void mipsnbsd_supply_fpreg (struct regcache *, const char *, int);
 void mipsnbsd_fill_fpreg (const struct regcache *, char *, int);
 
-#endif /* MIPS_NBSD_TDEP_H */
+#endif /* GDB_MIPS_NETBSD_TDEP_H */
diff --git a/gdb/mips-tdep.h b/gdb/mips-tdep.h
index eec1fb56f4e..df589cf71b8 100644
--- a/gdb/mips-tdep.h
+++ b/gdb/mips-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_TDEP_H
-#define MIPS_TDEP_H
+#ifndef GDB_MIPS_TDEP_H
+#define GDB_MIPS_TDEP_H
 
 #include "objfiles.h"
 #include "gdbarch.h"
@@ -201,4 +201,4 @@ in_mips_stubs_section (CORE_ADDR pc)
   return pc_in_section (pc, ".MIPS.stubs");
 }
 
-#endif /* MIPS_TDEP_H */
+#endif /* GDB_MIPS_TDEP_H */
diff --git a/gdb/mn10300-tdep.h b/gdb/mn10300-tdep.h
index 683a6ec2e14..bec5f04253a 100644
--- a/gdb/mn10300-tdep.h
+++ b/gdb/mn10300-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MN10300_TDEP_H
-#define MN10300_TDEP_H
+#ifndef GDB_MN10300_TDEP_H
+#define GDB_MN10300_TDEP_H
 
 #include "gdbarch.h"
 
@@ -88,4 +88,4 @@ get_am33_mode (gdbarch *arch)
   return tdep->am33_mode;
 }
 
-#endif /* MN10300_TDEP_H */
+#endif /* GDB_MN10300_TDEP_H */
diff --git a/gdb/moxie-tdep.h b/gdb/moxie-tdep.h
index 64bfc825fc1..329d9972b49 100644
--- a/gdb/moxie-tdep.h
+++ b/gdb/moxie-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MOXIE_TDEP_H
-#define MOXIE_TDEP_H
+#ifndef GDB_MOXIE_TDEP_H
+#define GDB_MOXIE_TDEP_H
 
 #include "gdbarch.h"
 
@@ -42,4 +42,4 @@ enum moxie_regnum
 
 #define MOXIE_NUM_REGS 18
 
-#endif /* moxie-tdep.h */
+#endif /* GDB_MOXIE_TDEP_H */
diff --git a/gdb/namespace.h b/gdb/namespace.h
index 232dcc03bd8..a9b020f6395 100644
--- a/gdb/namespace.h
+++ b/gdb/namespace.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAMESPACE_H
-#define NAMESPACE_H
+#ifndef GDB_NAMESPACE_H
+#define GDB_NAMESPACE_H
 
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbsupport/gdb_obstack.h"
@@ -127,4 +127,4 @@ extern void add_using_directive (struct using_direct **using_directives,
 				 const unsigned int decl_line,
 				 struct obstack *obstack);
 
-#endif /* NAMESPACE_H */
+#endif /* GDB_NAMESPACE_H */
diff --git a/gdb/nat/aarch64-hw-point.h b/gdb/nat/aarch64-hw-point.h
index bdcca932e57..f4db38b494d 100644
--- a/gdb/nat/aarch64-hw-point.h
+++ b/gdb/nat/aarch64-hw-point.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_HW_POINT_H
-#define NAT_AARCH64_HW_POINT_H
+#ifndef GDB_NAT_AARCH64_HW_POINT_H
+#define GDB_NAT_AARCH64_HW_POINT_H
 
 /* Macro definitions, data structures, and code for the hardware
    breakpoint and hardware watchpoint support follow.  We use the
@@ -128,4 +128,4 @@ void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state,
 
 int aarch64_region_ok_for_watchpoint (CORE_ADDR addr, int len);
 
-#endif /* NAT_AARCH64_HW_POINT_H */
+#endif /* GDB_NAT_AARCH64_HW_POINT_H */
diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h
index cf749c34ae7..618f79f1587 100644
--- a/gdb/nat/aarch64-linux-hw-point.h
+++ b/gdb/nat/aarch64-linux-hw-point.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_LINUX_HW_POINT_H
-#define NAT_AARCH64_LINUX_HW_POINT_H
+#ifndef GDB_NAT_AARCH64_LINUX_HW_POINT_H
+#define GDB_NAT_AARCH64_LINUX_HW_POINT_H
 
 #include "gdbsupport/break-common.h"
 
@@ -109,4 +109,4 @@ void aarch64_linux_get_debug_reg_capacity (int tid);
 
 struct aarch64_debug_reg_state *aarch64_get_debug_reg_state (pid_t pid);
 
-#endif /* NAT_AARCH64_LINUX_HW_POINT_H */
+#endif /* GDB_NAT_AARCH64_LINUX_HW_POINT_H */
diff --git a/gdb/nat/aarch64-linux.h b/gdb/nat/aarch64-linux.h
index f4df7481162..969bb52b812 100644
--- a/gdb/nat/aarch64-linux.h
+++ b/gdb/nat/aarch64-linux.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_LINUX_H
-#define NAT_AARCH64_LINUX_H
+#ifndef GDB_NAT_AARCH64_LINUX_H
+#define GDB_NAT_AARCH64_LINUX_H
 
 #include <signal.h>
 
@@ -133,4 +133,4 @@ ps_err_e aarch64_ps_get_thread_area (struct ps_prochandle *ph,
    used for aarch64 state.  */
 int aarch64_tls_register_count (int tid);
 
-#endif /* NAT_AARCH64_LINUX_H */
+#endif /* GDB_NAT_AARCH64_LINUX_H */
diff --git a/gdb/nat/aarch64-mte-linux-ptrace.h b/gdb/nat/aarch64-mte-linux-ptrace.h
index 28dd8158c90..e02a0818963 100644
--- a/gdb/nat/aarch64-mte-linux-ptrace.h
+++ b/gdb/nat/aarch64-mte-linux-ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_MTE_LINUX_PTRACE_H
-#define NAT_AARCH64_MTE_LINUX_PTRACE_H
+#ifndef GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
+#define GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
 
 /* MTE allocation tag access */
 
@@ -47,4 +47,4 @@ extern bool aarch64_mte_fetch_memtags (int tid, CORE_ADDR address, size_t len,
 extern bool aarch64_mte_store_memtags (int tid, CORE_ADDR address, size_t len,
 				       const gdb::byte_vector &tags);
 
-#endif /* NAT_AARCH64_MTE_LINUX_PTRACE_H */
+#endif /* GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H */
diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h
index 2be45588785..2c6d899e931 100644
--- a/gdb/nat/aarch64-scalable-linux-ptrace.h
+++ b/gdb/nat/aarch64-scalable-linux-ptrace.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
-#define NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
+#ifndef GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
+#define GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
 
 #include <signal.h>
 #include <sys/utsname.h>
@@ -176,4 +176,4 @@ aarch64_zt_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf,
 extern void
 aarch64_zt_regs_copy_from_reg_buf (int tid, struct reg_buffer_common *reg_buf,
 				   int zt_regnum);
-#endif /* NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */
+#endif /* GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */
diff --git a/gdb/nat/aarch64-scalable-linux-sigcontext.h b/gdb/nat/aarch64-scalable-linux-sigcontext.h
index 8db524250a8..bfda9be617a 100644
--- a/gdb/nat/aarch64-scalable-linux-sigcontext.h
+++ b/gdb/nat/aarch64-scalable-linux-sigcontext.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
-#define NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
+#ifndef GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
+#define GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
 
 #ifndef SVE_SIG_ZREGS_SIZE
 
@@ -325,4 +325,4 @@ struct user_za_header {
 	(ZA_PT_ZA_OFFSET + ZA_PT_ZA_SIZE(vq))
 #endif /* ZA_PT_SIZE */
 
-#endif /* NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H */
+#endif /* GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H */
diff --git a/gdb/nat/amd64-linux-siginfo.h b/gdb/nat/amd64-linux-siginfo.h
index b8fd8c0e2ae..1e102ae99b3 100644
--- a/gdb/nat/amd64-linux-siginfo.h
+++ b/gdb/nat/amd64-linux-siginfo.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AMD64_LINUX_SIGINFO_H
-#define NAT_AMD64_LINUX_SIGINFO_H
+#ifndef GDB_NAT_AMD64_LINUX_SIGINFO_H
+#define GDB_NAT_AMD64_LINUX_SIGINFO_H
 
 #include <signal.h>
 
@@ -55,4 +55,4 @@ int amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf,
 				      int direction,
 				      enum amd64_siginfo_fixup_mode mode);
 
-#endif /* NAT_AMD64_LINUX_SIGINFO_H */
+#endif /* GDB_NAT_AMD64_LINUX_SIGINFO_H */
diff --git a/gdb/nat/fork-inferior.h b/gdb/nat/fork-inferior.h
index a609f68bcb4..509aa053764 100644
--- a/gdb/nat/fork-inferior.h
+++ b/gdb/nat/fork-inferior.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_FORK_INFERIOR_H
-#define NAT_FORK_INFERIOR_H
+#ifndef GDB_NAT_FORK_INFERIOR_H
+#define GDB_NAT_FORK_INFERIOR_H
 
 #include <string>
 #include "gdbsupport/function-view.h"
@@ -87,4 +87,4 @@ extern void trace_start_error (const char *fmt, ...)
 extern void trace_start_error_with_name (const char *string)
   ATTRIBUTE_NORETURN;
 
-#endif /* NAT_FORK_INFERIOR_H */
+#endif /* GDB_NAT_FORK_INFERIOR_H */
diff --git a/gdb/nat/gdb_ptrace.h b/gdb/nat/gdb_ptrace.h
index 81727cbdbd6..17858848a62 100644
--- a/gdb/nat/gdb_ptrace.h
+++ b/gdb/nat/gdb_ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GDB_PTRACE_H
-#define NAT_GDB_PTRACE_H
+#ifndef GDB_NAT_GDB_PTRACE_H
+#define GDB_NAT_GDB_PTRACE_H
 
 /* The <sys/ptrace.h> header was introduced with 4.4BSD, and provided
    the PT_* symbolic constants for the ptrace(2) request numbers.  The
@@ -142,4 +142,4 @@
 	 ptrace ((PTRACE_TYPE_ARG1) request, pid, addr, data)
 #endif
 
-#endif /* NAT_GDB_PTRACE_H */
+#endif /* GDB_NAT_GDB_PTRACE_H */
diff --git a/gdb/nat/gdb_thread_db.h b/gdb/nat/gdb_thread_db.h
index 0e683787c40..446b92129dd 100644
--- a/gdb/nat/gdb_thread_db.h
+++ b/gdb/nat/gdb_thread_db.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GDB_THREAD_DB_H
-#define NAT_GDB_THREAD_DB_H
+#ifndef GDB_NAT_GDB_THREAD_DB_H
+#define GDB_NAT_GDB_THREAD_DB_H
 
 #ifdef HAVE_THREAD_DB_H
 #include <thread_db.h>
@@ -73,4 +73,4 @@ typedef td_err_e (td_thr_tlsbase_ftype) (const td_thrhandle_t *th,
 typedef const char ** (td_symbol_list_ftype) (void);
 typedef td_err_e (td_ta_delete_ftype) (td_thragent_t *);
 
-#endif /* NAT_GDB_THREAD_DB_H */
+#endif /* GDB_NAT_GDB_THREAD_DB_H */
diff --git a/gdb/nat/glibc_thread_db.h b/gdb/nat/glibc_thread_db.h
index 598805deef2..87eb62b3efe 100644
--- a/gdb/nat/glibc_thread_db.h
+++ b/gdb/nat/glibc_thread_db.h
@@ -16,8 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GLIBC_THREAD_DB_H
-#define NAT_GLIBC_THREAD_DB_H
+#ifndef GDB_NAT_GLIBC_THREAD_DB_H
+#define GDB_NAT_GLIBC_THREAD_DB_H
 
 /* This is the debugger interface for the NPTL library.  It is
    modelled closely after the interface with same names in Solaris
@@ -455,4 +455,4 @@ extern td_err_e td_thr_dbsuspend (const td_thrhandle_t *__th);
 /* Resume execution of thread TH.  */
 extern td_err_e td_thr_dbresume (const td_thrhandle_t *__th);
 
-#endif /* NAT_GLIBC_THREAD_DB_H */
+#endif /* GDB_NAT_GLIBC_THREAD_DB_H */
diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
index 0771f4b5a65..6fd81073673 100644
--- a/gdb/nat/linux-btrace.h
+++ b/gdb/nat/linux-btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_BTRACE_H
-#define NAT_LINUX_BTRACE_H
+#ifndef GDB_NAT_LINUX_BTRACE_H
+#define GDB_NAT_LINUX_BTRACE_H
 
 #include "gdbsupport/btrace-common.h"
 #include "gdbsupport/gdb-checked-static-cast.h"
@@ -86,4 +86,4 @@ extern enum btrace_error linux_read_btrace (struct btrace_data *btrace,
 extern const struct btrace_config *
   linux_btrace_conf (const struct btrace_target_info *);
 
-#endif /* NAT_LINUX_BTRACE_H */
+#endif /* GDB_NAT_LINUX_BTRACE_H */
diff --git a/gdb/nat/linux-namespaces.h b/gdb/nat/linux-namespaces.h
index 298ff056653..4327292950b 100644
--- a/gdb/nat/linux-namespaces.h
+++ b/gdb/nat/linux-namespaces.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_NAMESPACES_H
-#define NAT_LINUX_NAMESPACES_H
+#ifndef GDB_NAT_LINUX_NAMESPACES_H
+#define GDB_NAT_LINUX_NAMESPACES_H
 
 /* Set to true to enable debugging of Linux namespaces code.  */
 
@@ -73,4 +73,4 @@ extern int linux_mntns_unlink (pid_t pid, const char *filename);
 extern ssize_t linux_mntns_readlink (pid_t pid, const char *filename,
 				     char *buf, size_t bufsiz);
 
-#endif /* NAT_LINUX_NAMESPACES_H */
+#endif /* GDB_NAT_LINUX_NAMESPACES_H */
diff --git a/gdb/nat/linux-nat.h b/gdb/nat/linux-nat.h
index d4a36cbb601..e847eb033bd 100644
--- a/gdb/nat/linux-nat.h
+++ b/gdb/nat/linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_NAT_H
-#define NAT_LINUX_NAT_H
+#ifndef GDB_NAT_LINUX_NAT_H
+#define GDB_NAT_LINUX_NAT_H
 
 #include "gdbsupport/function-view.h"
 #include "target/waitstatus.h"
@@ -91,4 +91,4 @@ extern void linux_stop_lwp (struct lwp_info *lwp);
 
 extern int lwp_is_stepping (struct lwp_info *lwp);
 
-#endif /* NAT_LINUX_NAT_H */
+#endif /* GDB_NAT_LINUX_NAT_H */
diff --git a/gdb/nat/linux-osdata.h b/gdb/nat/linux-osdata.h
index 833915cdb2f..a700ea1eb80 100644
--- a/gdb/nat/linux-osdata.h
+++ b/gdb/nat/linux-osdata.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_OSDATA_H
-#define NAT_LINUX_OSDATA_H
+#ifndef GDB_NAT_LINUX_OSDATA_H
+#define GDB_NAT_LINUX_OSDATA_H
 
 extern int linux_common_core_of_thread (ptid_t ptid);
 extern LONGEST linux_common_xfer_osdata (const char *annex, gdb_byte *readbuf,
 					 ULONGEST offset, ULONGEST len);
 
-#endif /* NAT_LINUX_OSDATA_H */
+#endif /* GDB_NAT_LINUX_OSDATA_H */
diff --git a/gdb/nat/linux-personality.h b/gdb/nat/linux-personality.h
index 0238fe0c7e5..ab6727076ad 100644
--- a/gdb/nat/linux-personality.h
+++ b/gdb/nat/linux-personality.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PERSONALITY_H
-#define NAT_LINUX_PERSONALITY_H
+#ifndef GDB_NAT_LINUX_PERSONALITY_H
+#define GDB_NAT_LINUX_PERSONALITY_H
 
 class maybe_disable_address_space_randomization
 {
@@ -43,4 +43,4 @@ class maybe_disable_address_space_randomization
   int m_personality_orig;
 };
 
-#endif /* ! NAT_LINUX_PERSONALITY_H */
+#endif /* GDB_NAT_LINUX_PERSONALITY_H */
diff --git a/gdb/nat/linux-procfs.h b/gdb/nat/linux-procfs.h
index 880afbcdd61..6b352d97f3d 100644
--- a/gdb/nat/linux-procfs.h
+++ b/gdb/nat/linux-procfs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PROCFS_H
-#define NAT_LINUX_PROCFS_H
+#ifndef GDB_NAT_LINUX_PROCFS_H
+#define GDB_NAT_LINUX_PROCFS_H
 
 #include <unistd.h>
 
@@ -85,4 +85,4 @@ extern const char *linux_proc_pid_to_exec_file (int pid);
 
 extern void linux_proc_init_warnings ();
 
-#endif /* NAT_LINUX_PROCFS_H */
+#endif /* GDB_NAT_LINUX_PROCFS_H */
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index a3b4ca8d176..c7d40234044 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PTRACE_H
-#define NAT_LINUX_PTRACE_H
+#ifndef GDB_NAT_LINUX_PTRACE_H
+#define GDB_NAT_LINUX_PTRACE_H
 
 #include "nat/gdb_ptrace.h"
 #include "gdbsupport/gdb_wait.h"
@@ -186,4 +186,4 @@ extern int linux_ptrace_get_extended_event (int wstat);
 extern int linux_is_extended_waitstatus (int wstat);
 extern int linux_wstatus_maybe_breakpoint (int wstat);
 
-#endif /* NAT_LINUX_PTRACE_H */
+#endif /* GDB_NAT_LINUX_PTRACE_H */
diff --git a/gdb/nat/linux-waitpid.h b/gdb/nat/linux-waitpid.h
index e069f8a84a8..b75782d4520 100644
--- a/gdb/nat/linux-waitpid.h
+++ b/gdb/nat/linux-waitpid.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_WAITPID_H
-#define NAT_LINUX_WAITPID_H
+#ifndef GDB_NAT_LINUX_WAITPID_H
+#define GDB_NAT_LINUX_WAITPID_H
 
 /* Wrapper function for waitpid which handles EINTR.  */
 extern int my_waitpid (int pid, int *status, int flags);
@@ -27,4 +27,4 @@ extern int my_waitpid (int pid, int *status, int flags);
    messages only.  */
 extern std::string status_to_str (int status);
 
-#endif /* NAT_LINUX_WAITPID_H */
+#endif /* GDB_NAT_LINUX_WAITPID_H */
diff --git a/gdb/nat/mips-linux-watch.h b/gdb/nat/mips-linux-watch.h
index a37eabd2058..b18b009f3b7 100644
--- a/gdb/nat/mips-linux-watch.h
+++ b/gdb/nat/mips-linux-watch.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_MIPS_LINUX_WATCH_H
-#define NAT_MIPS_LINUX_WATCH_H
+#ifndef GDB_NAT_MIPS_LINUX_WATCH_H
+#define GDB_NAT_MIPS_LINUX_WATCH_H
 
 #include <asm/ptrace.h>
 #include "gdbsupport/break-common.h"
@@ -116,4 +116,4 @@ int mips_linux_read_watch_registers (long lwpid,
 				     struct pt_watch_regs *watch_readback,
 				     int *watch_readback_valid, int force);
 
-#endif /* NAT_MIPS_LINUX_WATCH_H */
+#endif /* GDB_NAT_MIPS_LINUX_WATCH_H */
diff --git a/gdb/nat/netbsd-nat.h b/gdb/nat/netbsd-nat.h
index cc529cfd0c6..1ffd705e3be 100644
--- a/gdb/nat/netbsd-nat.h
+++ b/gdb/nat/netbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_NETBSD_NAT_H
-#define NAT_NETBSD_NAT_H
+#ifndef GDB_NAT_NETBSD_NAT_H
+#define GDB_NAT_NETBSD_NAT_H
 
 #include "gdbsupport/function-view.h"
 
@@ -91,4 +91,4 @@ extern int read_memory (pid_t pid, unsigned char *readbuf, CORE_ADDR offset,
 			size_t len, size_t *xfered_len);
 }
 
-#endif
+#endif /* GDB_NAT_NETBSD_NAT_H */
diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h
index b51e2278f4b..3efc1b9a9bf 100644
--- a/gdb/nat/ppc-linux.h
+++ b/gdb/nat/ppc-linux.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_PPC_LINUX_H
-#define NAT_PPC_LINUX_H
+#ifndef GDB_NAT_PPC_LINUX_H
+#define GDB_NAT_PPC_LINUX_H
 
 #include <asm/ptrace.h>
 #include <asm/cputable.h>
@@ -162,4 +162,4 @@
 /* Return the wordsize of the target, either 4 or 8 bytes.  */
 int ppc_linux_target_wordsize (int tid);
 
-#endif /* NAT_PPC_LINUX_H */
+#endif /* GDB_NAT_PPC_LINUX_H */
diff --git a/gdb/nat/riscv-linux-tdesc.h b/gdb/nat/riscv-linux-tdesc.h
index fa9d5bcb7f5..875135ed979 100644
--- a/gdb/nat/riscv-linux-tdesc.h
+++ b/gdb/nat/riscv-linux-tdesc.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_RISCV_LINUX_TDESC_H
-#define NAT_RISCV_LINUX_TDESC_H
+#ifndef GDB_NAT_RISCV_LINUX_TDESC_H
+#define GDB_NAT_RISCV_LINUX_TDESC_H
 
 #include "arch/riscv.h"
 
@@ -25,4 +25,4 @@
    corresponding features object.  */
 struct riscv_gdbarch_features riscv_linux_read_features (int tid);
 
-#endif /* NAT_RISCV_LINUX_TDESC_H */
+#endif /* GDB_NAT_RISCV_LINUX_TDESC_H */
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index f2b5d777016..e03b41a53d4 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_WINDOWS_NAT_H
-#define NAT_WINDOWS_NAT_H
+#ifndef GDB_NAT_WINDOWS_NAT_H
+#define GDB_NAT_WINDOWS_NAT_H
 
 #include <windows.h>
 #include <psapi.h>
@@ -440,4 +440,4 @@ extern bool initialize_loadable ();
 
 }
 
-#endif
+#endif /* GDB_NAT_WINDOWS_NAT_H */
diff --git a/gdb/nat/x86-cpuid.h b/gdb/nat/x86-cpuid.h
index 5e9ce604f4e..02a204c1348 100644
--- a/gdb/nat/x86-cpuid.h
+++ b/gdb/nat/x86-cpuid.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_CPUID_H
-#define NAT_X86_CPUID_H
+#ifndef GDB_NAT_X86_CPUID_H
+#define GDB_NAT_X86_CPUID_H
 
 /* Always include the header for the cpu bit defines.  */
 #include "x86-gcc-cpuid.h"
@@ -82,4 +82,4 @@ x86_cpuid_count (unsigned int __level, unsigned int __sublevel,
 #undef nullptr
 #endif
 
-#endif /* NAT_X86_CPUID_H */
+#endif /* GDB_NAT_X86_CPUID_H */
diff --git a/gdb/nat/x86-dregs.h b/gdb/nat/x86-dregs.h
index 795cb112f88..3dcbf8e3028 100644
--- a/gdb/nat/x86-dregs.h
+++ b/gdb/nat/x86-dregs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_DREGS_H
-#define NAT_X86_DREGS_H
+#ifndef GDB_NAT_X86_DREGS_H
+#define GDB_NAT_X86_DREGS_H
 
 /* Support for hardware watchpoints and breakpoints using the x86
    debug registers.
@@ -133,4 +133,4 @@ extern int x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state);
    triggered.  Otherwise return false.  */
 extern int x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state);
 
-#endif /* NAT_X86_DREGS_H */
+#endif /* GDB_NAT_X86_DREGS_H */
diff --git a/gdb/nat/x86-gcc-cpuid.h b/gdb/nat/x86-gcc-cpuid.h
index dfd12587d81..b0f2d239af3 100644
--- a/gdb/nat/x86-gcc-cpuid.h
+++ b/gdb/nat/x86-gcc-cpuid.h
@@ -3,8 +3,8 @@
  * include this directly, but pull in x86-cpuid.h and use that func.
  */
 
-#ifndef NAT_X86_GCC_CPUID_H
-#define NAT_X86_GCC_CPUID_H
+#ifndef GDB_NAT_X86_GCC_CPUID_H
+#define GDB_NAT_X86_GCC_CPUID_H
 
 /*
  * Copyright (C) 2007-2024 Free Software Foundation, Inc.
@@ -273,4 +273,4 @@ __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
   return 1;
 }
 
-#endif /* NAT_X86_GCC_CPUID_H */
+#endif /* GDB_NAT_X86_GCC_CPUID_H */
diff --git a/gdb/nat/x86-linux-dregs.h b/gdb/nat/x86-linux-dregs.h
index 2b30c4a7a62..6f6a6e3d24e 100644
--- a/gdb/nat/x86-linux-dregs.h
+++ b/gdb/nat/x86-linux-dregs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_LINUX_DREGS_H
-#define NAT_X86_LINUX_DREGS_H
+#ifndef GDB_NAT_X86_LINUX_DREGS_H
+#define GDB_NAT_X86_LINUX_DREGS_H
 
 /* Return the address stored in the current inferior's debug register
    REGNUM.  */
@@ -50,4 +50,4 @@ extern unsigned long x86_linux_dr_get_status (void);
 
 extern void x86_linux_update_debug_registers (struct lwp_info *lwp);
 
-#endif /* NAT_X86_LINUX_DREGS_H */
+#endif /* GDB_NAT_X86_LINUX_DREGS_H */
diff --git a/gdb/nat/x86-linux.h b/gdb/nat/x86-linux.h
index 822882173f9..9b5db895455 100644
--- a/gdb/nat/x86-linux.h
+++ b/gdb/nat/x86-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_LINUX_H
-#define NAT_X86_LINUX_H
+#ifndef GDB_NAT_X86_LINUX_H
+#define GDB_NAT_X86_LINUX_H
 
 #include "nat/linux-nat.h"
 
@@ -47,4 +47,4 @@ extern void x86_linux_delete_thread (struct arch_lwp_info *arch_lwp);
 
 extern void x86_linux_prepare_to_resume (struct lwp_info *lwp);
 
-#endif /* NAT_X86_LINUX_H */
+#endif /* GDB_NAT_X86_LINUX_H */
diff --git a/gdb/nat/x86-xstate.h b/gdb/nat/x86-xstate.h
index 199d39a5217..14b58cd0312 100644
--- a/gdb/nat/x86-xstate.h
+++ b/gdb/nat/x86-xstate.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_XSTATE_H
-#define NAT_X86_XSTATE_H
+#ifndef GDB_NAT_X86_XSTATE_H
+#define GDB_NAT_X86_XSTATE_H
 
 #include "gdbsupport/x86-xstate.h"
 
@@ -32,4 +32,4 @@ int x86_xsave_length ();
 
 x86_xsave_layout x86_fetch_xsave_layout (uint64_t xcr0, int len);
 
-#endif /* NAT_X86_XSTATE_H */
+#endif /* GDB_NAT_X86_XSTATE_H */
diff --git a/gdb/nds32-tdep.h b/gdb/nds32-tdep.h
index a4d62848c51..18c360d7bdb 100644
--- a/gdb/nds32-tdep.h
+++ b/gdb/nds32-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NDS32_TDEP_H
-#define NDS32_TDEP_H
+#ifndef GDB_NDS32_TDEP_H
+#define GDB_NDS32_TDEP_H
 
 #include "gdbarch.h"
 
@@ -53,4 +53,4 @@ struct nds32_gdbarch_tdep : gdbarch_tdep_base
   /* ELF ABI info.  */
   int elf_abi = 0;
 };
-#endif /* NDS32_TDEP_H */
+#endif /* GDB_NDS32_TDEP_H */
diff --git a/gdb/netbsd-nat.h b/gdb/netbsd-nat.h
index 4895b088d13..87e076f69e7 100644
--- a/gdb/netbsd-nat.h
+++ b/gdb/netbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NBSD_NAT_H
-#define NBSD_NAT_H
+#ifndef GDB_NETBSD_NAT_H
+#define GDB_NETBSD_NAT_H
 
 #include "inf-ptrace.h"
 
@@ -61,4 +61,4 @@ struct nbsd_nat_target : public inf_ptrace_target
   void post_startup_inferior (ptid_t ptid) override;
 };
 
-#endif /* netbsd-nat.h */
+#endif /* GDB_NETBSD_NAT_H */
diff --git a/gdb/netbsd-tdep.h b/gdb/netbsd-tdep.h
index 3a9d527ca81..2e2993ea5dc 100644
--- a/gdb/netbsd-tdep.h
+++ b/gdb/netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NBSD_TDEP_H
-#define NBSD_TDEP_H
+#ifndef GDB_NETBSD_TDEP_H
+#define GDB_NETBSD_TDEP_H
 
 int nbsd_pc_in_sigtramp (CORE_ADDR, const char *);
 
@@ -44,4 +44,4 @@ extern void nbsd_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
 					   int kve_flags, int kve_protection,
 					   const char *kve_path);
 
-#endif /* NBSD_TDEP_H */
+#endif /* GDB_NETBSD_TDEP_H */
diff --git a/gdb/nios2-tdep.h b/gdb/nios2-tdep.h
index 57e0de7076d..0b3d01ab232 100644
--- a/gdb/nios2-tdep.h
+++ b/gdb/nios2-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NIOS2_TDEP_H
-#define NIOS2_TDEP_H
+#ifndef GDB_NIOS2_TDEP_H
+#define GDB_NIOS2_TDEP_H
 
 #include "gdbarch.h"
 
@@ -87,4 +87,4 @@ struct nios2_gdbarch_tdep : gdbarch_tdep_base
 extern const struct target_desc *tdesc_nios2_linux;
 extern const struct target_desc *tdesc_nios2;
 
-#endif /* NIOS2_TDEP_H */
+#endif /* GDB_NIOS2_TDEP_H */
diff --git a/gdb/nto-tdep.h b/gdb/nto-tdep.h
index 249a4f631fe..2edbcff8c91 100644
--- a/gdb/nto-tdep.h
+++ b/gdb/nto-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NTO_TDEP_H
-#define NTO_TDEP_H
+#ifndef GDB_NTO_TDEP_H
+#define GDB_NTO_TDEP_H
 
 #include "solist.h"
 #include "osabi.h"
@@ -191,4 +191,4 @@ LONGEST nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack,
 
 struct nto_inferior_data *nto_inferior_data (struct inferior *inf);
 
-#endif /* NTO_TDEP_H */
+#endif /* GDB_NTO_TDEP_H */
diff --git a/gdb/objc-lang.h b/gdb/objc-lang.h
index 879d7475d9d..6a8dc39c53a 100644
--- a/gdb/objc-lang.h
+++ b/gdb/objc-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(OBJC_LANG_H)
-#define OBJC_LANG_H
+#ifndef GDB_OBJC_LANG_H
+#define GDB_OBJC_LANG_H
 
 struct stoken;
 
@@ -48,4 +48,4 @@ struct symbol *lookup_struct_typedef (const char *name,
 				      const struct block *block,
 				      int noerr);
 
-#endif
+#endif /* GDB_OBJC_LANG_H */
diff --git a/gdb/objfile-flags.h b/gdb/objfile-flags.h
index 43d888e2a5a..e0a84bcdc2e 100644
--- a/gdb/objfile-flags.h
+++ b/gdb/objfile-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (OBJFILE_FLAGS_H)
-#define OBJFILE_FLAGS_H
+#ifndef GDB_OBJFILE_FLAGS_H
+#define GDB_OBJFILE_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -60,4 +60,4 @@ enum objfile_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum objfile_flag, objfile_flags);
 
-#endif /* !defined (OBJFILE_FLAGS_H) */
+#endif /* GDB_OBJFILE_FLAGS_H */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 8b8b7182e87..4d8e5c45680 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (OBJFILES_H)
-#define OBJFILES_H
+#ifndef GDB_OBJFILES_H
+#define GDB_OBJFILES_H
 
 #include "hashtab.h"
 #include "gdbsupport/gdb_obstack.h"
@@ -1031,4 +1031,4 @@ extern void objfile_register_static_link
 extern const struct dynamic_prop *objfile_lookup_static_link
   (struct objfile *objfile, const struct block *block);
 
-#endif /* !defined (OBJFILES_H) */
+#endif /* GDB_OBJFILES_H */
diff --git a/gdb/obsd-nat.h b/gdb/obsd-nat.h
index 0811a82d85c..35ee212e09f 100644
--- a/gdb/obsd-nat.h
+++ b/gdb/obsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSD_NAT_H
-#define OBSD_NAT_H
+#ifndef GDB_OBSD_NAT_H
+#define GDB_OBSD_NAT_H
 
 #include "inf-ptrace.h"
 
@@ -41,4 +41,4 @@ class obsd_nat_target : public inf_ptrace_target
   void post_startup_inferior (ptid_t) override;
 };
 
-#endif /* obsd-nat.h */
+#endif /* GDB_OBSD_NAT_H */
diff --git a/gdb/obsd-tdep.h b/gdb/obsd-tdep.h
index 85cea7be7cf..c018513cb1b 100644
--- a/gdb/obsd-tdep.h
+++ b/gdb/obsd-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSD_TDEP_H
-#define OBSD_TDEP_H 1
+#ifndef GDB_OBSD_TDEP_H
+#define GDB_OBSD_TDEP_H
 
 struct gdbarch;
 
 CORE_ADDR obsd_skip_solib_resolver (struct gdbarch *, CORE_ADDR);
 void obsd_init_abi (struct gdbarch_info, struct gdbarch *);
 
-#endif /* obsd-tdep.h */
+#endif /* GDB_OBSD_TDEP_H */
diff --git a/gdb/observable.h b/gdb/observable.h
index 2aa3ef3fd4e..2ce2711abd6 100644
--- a/gdb/observable.h
+++ b/gdb/observable.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSERVABLE_H
-#define OBSERVABLE_H
+#ifndef GDB_OBSERVABLE_H
+#define GDB_OBSERVABLE_H
 
 #include "gdbsupport/observable.h"
 #include "target/waitstatus.h"
@@ -257,4 +257,4 @@ extern observable <program_space */* pspace */> free_program_space;
 
 } /* namespace gdb */
 
-#endif /* OBSERVABLE_H */
+#endif /* GDB_OBSERVABLE_H */
diff --git a/gdb/or1k-linux-tdep.h b/gdb/or1k-linux-tdep.h
index 4e84e72c269..b510f32d16e 100644
--- a/gdb/or1k-linux-tdep.h
+++ b/gdb/or1k-linux-tdep.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OR1K_LINUX_TDEP_H
-#define OR1K_LINUX_TDEP_H
+#ifndef GDB_OR1K_LINUX_TDEP_H
+#define GDB_OR1K_LINUX_TDEP_H
 
 /* Target descriptions.  */
 extern struct target_desc *tdesc_or1k_linux;
 
-#endif /* OR1K_LINUX_TDEP_H */
+#endif /* GDB_OR1K_LINUX_TDEP_H */
diff --git a/gdb/or1k-tdep.h b/gdb/or1k-tdep.h
index 6107cc4612c..f3072572e57 100644
--- a/gdb/or1k-tdep.h
+++ b/gdb/or1k-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License along
    With this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OR1K_TDEP_H
-#define OR1K_TDEP_H
+#ifndef GDB_OR1K_TDEP_H
+#define GDB_OR1K_TDEP_H
 
 #ifndef TARGET_OR1K
 #define TARGET_OR1K
@@ -60,4 +60,4 @@ extern std::vector<CORE_ADDR> or1k_software_single_step
   (struct regcache *regcache);
 
 
-#endif /* OR1K_TDEP_H */
+#endif /* GDB_OR1K_TDEP_H */
diff --git a/gdb/osabi.h b/gdb/osabi.h
index c1a85d1b9a3..bbcd0d0c23a 100644
--- a/gdb/osabi.h
+++ b/gdb/osabi.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OSABI_H
-#define OSABI_H
+#ifndef GDB_OSABI_H
+#define GDB_OSABI_H
 
 /* * List of known OS ABIs.  If you change this, make sure to update the
    table in osabi.c.  */
@@ -92,4 +92,4 @@ const char *osabi_triplet_regexp (enum gdb_osabi osabi);
 void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *,
 					       enum gdb_osabi *);
 
-#endif /* OSABI_H */
+#endif /* GDB_OSABI_H */
diff --git a/gdb/osdata.h b/gdb/osdata.h
index 09259b6c9ae..9de443ac4de 100644
--- a/gdb/osdata.h
+++ b/gdb/osdata.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OSDATA_H
-#define OSDATA_H
+#ifndef GDB_OSDATA_H
+#define GDB_OSDATA_H
 
 #include <vector>
 
@@ -57,4 +57,4 @@ const std::string *get_osdata_column (const osdata_item &item,
    available types of OS data.  */
 void info_osdata (const char *type);
 
-#endif /* OSDATA_H */
+#endif /* GDB_OSDATA_H */
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index fe12e7cab33..abb981aeaed 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef P_LANG_H
-#define P_LANG_H
+#ifndef GDB_P_LANG_H
+#define GDB_P_LANG_H
 
 /* This file is derived from c-lang.h */
 
@@ -252,4 +252,4 @@ class pascal_language : public language_defn
 				   struct type *type) const;
 };
 
-#endif /* P_LANG_H */
+#endif /* GDB_P_LANG_H */
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 9774a465ee2..eaa3c411141 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (PARSER_DEFS_H)
-#define PARSER_DEFS_H 1
+#ifndef GDB_PARSER_DEFS_H
+#define GDB_PARSER_DEFS_H
 
 #include "expression.h"
 #include "symtab.h"
@@ -389,4 +389,4 @@ extern bool fits_in_type (int n_sign, const gdb_mpz &n, int type_bits,
 
 extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3);
 
-#endif /* PARSER_DEFS_H */
+#endif /* GDB_PARSER_DEFS_H */
diff --git a/gdb/ppc-fbsd-tdep.h b/gdb/ppc-fbsd-tdep.h
index b9c0e6bb351..93ba9045f2f 100644
--- a/gdb/ppc-fbsd-tdep.h
+++ b/gdb/ppc-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_FBSD_TDEP_H
-#define PPC_FBSD_TDEP_H
+#ifndef GDB_PPC_FBSD_TDEP_H
+#define GDB_PPC_FBSD_TDEP_H
 
 struct regset;
 
@@ -26,4 +26,4 @@ struct regset;
 const struct regset *ppc_fbsd_gregset (int);
 const struct regset *ppc_fbsd_fpregset (void);
 
-#endif /* PPC_FBSD_TDEP_H  */
+#endif /* GDB_PPC_FBSD_TDEP_H */
diff --git a/gdb/ppc-linux-tdep.h b/gdb/ppc-linux-tdep.h
index 8a0a59f2b70..a1db503c9f5 100644
--- a/gdb/ppc-linux-tdep.h
+++ b/gdb/ppc-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_LINUX_TDEP_H
-#define PPC_LINUX_TDEP_H
+#ifndef GDB_PPC_LINUX_TDEP_H
+#define GDB_PPC_LINUX_TDEP_H
 
 #include "ppc-tdep.h"
 
@@ -65,4 +65,4 @@ extern const struct regset ppc32_linux_cpprregset;
 extern const struct regset ppc32_linux_cdscrregset;
 extern const struct regset ppc32_linux_ctarregset;
 
-#endif /* PPC_LINUX_TDEP_H */
+#endif /* GDB_PPC_LINUX_TDEP_H */
diff --git a/gdb/ppc-netbsd-tdep.h b/gdb/ppc-netbsd-tdep.h
index 6a92020f5ab..47a8b25782a 100644
--- a/gdb/ppc-netbsd-tdep.h
+++ b/gdb/ppc-netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_NBSD_TDEP_H
-#define PPC_NBSD_TDEP_H
+#ifndef GDB_PPC_NETBSD_TDEP_H
+#define GDB_PPC_NETBSD_TDEP_H
 
 struct regset;
 
@@ -29,4 +29,4 @@ extern struct ppc_reg_offsets ppcnbsd_reg_offsets;
 extern const struct regset ppcnbsd_gregset;
 extern const struct regset ppcnbsd_fpregset;
 
-#endif /* PPC_NBSD_TDEP_H */
+#endif /* GDB_PPC_NETBSD_TDEP_H */
diff --git a/gdb/ppc-obsd-tdep.h b/gdb/ppc-obsd-tdep.h
index 70396abdf84..7f5e7b99850 100644
--- a/gdb/ppc-obsd-tdep.h
+++ b/gdb/ppc-obsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_OBSD_TDEP_H
-#define PPC_OBSD_TDEP_H
+#ifndef GDB_PPC_OBSD_TDEP_H
+#define GDB_PPC_OBSD_TDEP_H
 
 struct regset;
 struct regcache;
@@ -49,4 +49,4 @@ extern void ppcobsd_collect_gregset (const struct regset *regset,
 				     const struct regcache *regcache,
 				     int regnum, void *gregs, size_t len);
 
-#endif /* ppc-obsd-tdep.h */
+#endif /* GDB_PPC_OBSD_TDEP_H */
diff --git a/gdb/ppc-ravenscar-thread.h b/gdb/ppc-ravenscar-thread.h
index 2b0916a916f..c03fbd2ec52 100644
--- a/gdb/ppc-ravenscar-thread.h
+++ b/gdb/ppc-ravenscar-thread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_RAVENSCAR_THREAD_H
-#define PPC_RAVENSCAR_THREAD_H
+#ifndef GDB_PPC_RAVENSCAR_THREAD_H
+#define GDB_PPC_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
@@ -26,4 +26,4 @@ extern void register_ppc_ravenscar_ops (struct gdbarch *gdbarch);
 
 extern void register_e500_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_PPC_RAVENSCAR_THREAD_H */
diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
index db31c7f199a..3176c155fe3 100644
--- a/gdb/ppc-tdep.h
+++ b/gdb/ppc-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_TDEP_H
-#define PPC_TDEP_H
+#ifndef GDB_PPC_TDEP_H
+#define GDB_PPC_TDEP_H
 
 #include "gdbarch.h"
 
@@ -458,4 +458,4 @@ extern const struct target_desc *tdesc_powerpc_vsx32;
 extern const struct target_desc *tdesc_powerpc_altivec64;
 extern const struct target_desc *tdesc_powerpc_altivec32;
 
-#endif /* ppc-tdep.h */
+#endif /* GDB_PPC_TDEP_H */
diff --git a/gdb/ppc64-tdep.h b/gdb/ppc64-tdep.h
index ff0e3fdd033..7bea549dda0 100644
--- a/gdb/ppc64-tdep.h
+++ b/gdb/ppc64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC64_TDEP_H
-#define PPC64_TDEP_H
+#ifndef GDB_PPC64_TDEP_H
+#define GDB_PPC64_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -33,4 +33,4 @@ extern CORE_ADDR ppc64_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
 
 extern void ppc64_elf_make_msymbol_special (asymbol *,
 					    struct minimal_symbol *);
-#endif /* PPC64_TDEP_H  */
+#endif /* GDB_PPC64_TDEP_H */
diff --git a/gdb/probe.h b/gdb/probe.h
index 41e728ad049..00b3f9086b4 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (PROBE_H)
-#define PROBE_H 1
+#ifndef GDB_PROBE_H
+#define GDB_PROBE_H
 
 #include "symtab.h"
 
@@ -309,4 +309,4 @@ extern struct value *probe_safe_evaluate_at_pc (const frame_info_ptr &frame,
 
 bool ignore_probe_p (const char *provider, const char *name,
 		     const char *objfile_name, const char *TYPE);
-#endif /* !defined (PROBE_H) */
+#endif /* GDB_PROBE_H */
diff --git a/gdb/proc-utils.h b/gdb/proc-utils.h
index 8ef7d7ccd34..5f8fe39f78f 100644
--- a/gdb/proc-utils.h
+++ b/gdb/proc-utils.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROC_UTILS_H
-#define PROC_UTILS_H
+#ifndef GDB_PROC_UTILS_H
+#define GDB_PROC_UTILS_H
 
 /* From proc-why.c */
 
@@ -117,4 +117,4 @@ extern  void  procfs_note      (const char *, const char *, int);
    word used to write to the /proc/PID/ctl file.  */
 typedef long procfs_ctl_t;
 
-#endif /* PROC_UTILS_H */
+#endif /* GDB_PROC_UTILS_H */
diff --git a/gdb/process-stratum-target.h b/gdb/process-stratum-target.h
index 9aa9d874ecb..8a0e139cd0c 100644
--- a/gdb/process-stratum-target.h
+++ b/gdb/process-stratum-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROCESS_STRATUM_TARGET_H
-#define PROCESS_STRATUM_TARGET_H
+#ifndef GDB_PROCESS_STRATUM_TARGET_H
+#define GDB_PROCESS_STRATUM_TARGET_H
 
 #include "target.h"
 #include <set>
@@ -173,4 +173,4 @@ extern std::set<process_stratum_target *> all_non_exited_process_targets ();
 
 extern void switch_to_target_no_thread (process_stratum_target *target);
 
-#endif /* !defined (PROCESS_STRATUM_TARGET_H) */
+#endif /* GDB_PROCESS_STRATUM_TARGET_H */
diff --git a/gdb/procfs.h b/gdb/procfs.h
index e0c1dd654ca..0dafb9a88b4 100644
--- a/gdb/procfs.h
+++ b/gdb/procfs.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROCFS_H
-#define PROCFS_H
+#ifndef GDB_PROCFS_H
+#define GDB_PROCFS_H
 
 /* Return a ptid for which we guarantee we will be able to find a
    'live' procinfo.  */
 
 extern ptid_t procfs_first_available (void);
 
-#endif /* PROCFS_H */
+#endif /* GDB_PROCFS_H */
diff --git a/gdb/producer.h b/gdb/producer.h
index 84721bd2665..5cdb7ee3435 100644
--- a/gdb/producer.h
+++ b/gdb/producer.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PRODUCER_H
-#define PRODUCER_H
+#ifndef GDB_PRODUCER_H
+#define GDB_PRODUCER_H
 
 /* Check for GCC >= 4.x according to the symtab->producer string.  Return minor
    version (x) of 4.x in such case.  If it is not GCC or it is GCC older than
@@ -50,4 +50,4 @@ extern bool producer_is_llvm (const char *producer);
    Sets MAJOR and MINOR accordingly, if not NULL.  */
 extern bool producer_is_clang (const char *producer, int *major, int *minor);
 
-#endif
+#endif /* GDB_PRODUCER_H */
diff --git a/gdb/progspace-and-thread.h b/gdb/progspace-and-thread.h
index fa512710a25..52c493bf687 100644
--- a/gdb/progspace-and-thread.h
+++ b/gdb/progspace-and-thread.h
@@ -16,8 +16,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef PROGSPACE_AND_THREAD_H
-#define PROGSPACE_AND_THREAD_H
+#ifndef GDB_PROGSPACE_AND_THREAD_H
+#define GDB_PROGSPACE_AND_THREAD_H
 
 #include "progspace.h"
 #include "gdbthread.h"
@@ -37,4 +37,4 @@ class scoped_restore_current_pspace_and_thread
    current thread, if there's one and it isn't executing.  */
 void switch_to_program_space_and_thread (program_space *pspace);
 
-#endif
+#endif /* GDB_PROGSPACE_AND_THREAD_H */
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 7f5e23df126..74220e5ba4c 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef PROGSPACE_H
-#define PROGSPACE_H
+#ifndef GDB_PROGSPACE_H
+#define GDB_PROGSPACE_H
 
 #include "target.h"
 #include "gdb_bfd.h"
@@ -472,4 +472,4 @@ extern address_space_ref_ptr maybe_new_address_space ();
    mappings.  */
 extern void update_address_spaces (void);
 
-#endif
+#endif /* GDB_PROGSPACE_H */
diff --git a/gdb/prologue-value.h b/gdb/prologue-value.h
index ea784f90dd2..39235d591fc 100644
--- a/gdb/prologue-value.h
+++ b/gdb/prologue-value.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROLOGUE_VALUE_H
-#define PROLOGUE_VALUE_H
+#ifndef GDB_PROLOGUE_VALUE_H
+#define GDB_PROLOGUE_VALUE_H
 
 /* What sort of value is this?  This determines the interpretation
    of subsequent fields.  */
@@ -327,4 +327,4 @@ class pv_area
   struct area_entry *m_entry;
 };
 
-#endif /* PROLOGUE_VALUE_H */
+#endif /* GDB_PROLOGUE_VALUE_H */
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 557a7cf4c08..7833815ef50 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PSYMTAB_H
-#define PSYMTAB_H
+#ifndef GDB_PSYMTAB_H
+#define GDB_PSYMTAB_H
 
 #include "objfiles.h"
 #include <string_view>
@@ -687,4 +687,4 @@ struct psymbol_functions : public quick_symbol_functions
   std::shared_ptr<psymtab_storage> m_partial_symtabs;
 };
 
-#endif /* PSYMTAB_H */
+#endif /* GDB_PSYMTAB_H */
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 388c513e5e9..2819707b2dd 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_EVENT_H
-#define PYTHON_PY_EVENT_H
+#ifndef GDB_PYTHON_PY_EVENT_H
+#define GDB_PYTHON_PY_EVENT_H
 
 #include "py-events.h"
 #include "command.h"
@@ -87,4 +87,4 @@ extern int evpy_add_attribute (PyObject *event,
 int gdbpy_initialize_event_generic (PyTypeObject *type, const char *name)
   CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
 
-#endif /* PYTHON_PY_EVENT_H */
+#endif /* GDB_PYTHON_PY_EVENT_H */
diff --git a/gdb/python/py-events.h b/gdb/python/py-events.h
index e628e0fd63e..b44c4371f24 100644
--- a/gdb/python/py-events.h
+++ b/gdb/python/py-events.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_EVENTS_H
-#define PYTHON_PY_EVENTS_H
+#ifndef GDB_PYTHON_PY_EVENTS_H
+#define GDB_PYTHON_PY_EVENTS_H
 
 #include "command.h"
 #include "python-internal.h"
@@ -54,4 +54,4 @@ extern events_object gdb_py_events;
 extern eventregistry_object *create_eventregistry_object (void);
 extern bool evregpy_no_listeners_p (eventregistry_object *registry);
 
-#endif /* PYTHON_PY_EVENTS_H */
+#endif /* GDB_PYTHON_PY_EVENTS_H */
diff --git a/gdb/python/py-instruction.h b/gdb/python/py-instruction.h
index 85604de5188..efbdda84bae 100644
--- a/gdb/python/py-instruction.h
+++ b/gdb/python/py-instruction.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_INSTRUCTION_H
-#define PYTHON_PY_INSTRUCTION_H
+#ifndef GDB_PYTHON_PY_INSTRUCTION_H
+#define GDB_PYTHON_PY_INSTRUCTION_H
 
 #include "python-internal.h"
 
@@ -32,4 +32,4 @@
 
 extern PyTypeObject *py_insn_get_insn_type ();
 
-#endif /* PYTHON_PY_INSTRUCTION_H */
+#endif /* GDB_PYTHON_PY_INSTRUCTION_H */
diff --git a/gdb/python/py-record-btrace.h b/gdb/python/py-record-btrace.h
index 8678e77322b..0410dd66be8 100644
--- a/gdb/python/py-record-btrace.h
+++ b/gdb/python/py-record-btrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_BTRACE_H
-#define PYTHON_PY_RECORD_BTRACE_H
+#ifndef GDB_PYTHON_PY_RECORD_BTRACE_H
+#define GDB_PYTHON_PY_RECORD_BTRACE_H
 
 #include "python-internal.h"
 
@@ -88,4 +88,4 @@ extern PyObject *recpy_bt_func_prev (PyObject *self, void *closure);
 /* Implementation of RecordFunctionSegment.next [RecordFunctionSegment].  */
 extern PyObject *recpy_bt_func_next (PyObject *self, void *closure);
 
-#endif /* PYTHON_PY_RECORD_BTRACE_H */
+#endif /* GDB_PYTHON_PY_RECORD_BTRACE_H */
diff --git a/gdb/python/py-record-full.h b/gdb/python/py-record-full.h
index 7125e4eba05..df957761602 100644
--- a/gdb/python/py-record-full.h
+++ b/gdb/python/py-record-full.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_FULL_H
-#define PYTHON_PY_RECORD_FULL_H
+#ifndef GDB_PYTHON_PY_RECORD_FULL_H
+#define GDB_PYTHON_PY_RECORD_FULL_H
 
 #include "python-internal.h"
 
@@ -28,4 +28,4 @@ extern PyObject *recpy_full_method (PyObject *self, void *value);
 /* Implementation of record.format [str].  */
 extern PyObject *recpy_full_format (PyObject *self, void *value);
 
-#endif /* PYTHON_PY_RECORD_FULL_H */
+#endif /* GDB_PYTHON_PY_RECORD_FULL_H */
diff --git a/gdb/python/py-record.h b/gdb/python/py-record.h
index 7e1161005b4..0687e78784a 100644
--- a/gdb/python/py-record.h
+++ b/gdb/python/py-record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_H
-#define PYTHON_PY_RECORD_H
+#ifndef GDB_PYTHON_PY_RECORD_H
+#define GDB_PYTHON_PY_RECORD_H
 
 #include "inferior.h"
 #include "python-internal.h"
@@ -71,4 +71,4 @@ extern PyObject *recpy_func_new (thread_info *thread, enum record_method method,
 extern PyObject *recpy_gap_new (int reason_code, const char *reason_string,
 				Py_ssize_t number);
 
-#endif /* PYTHON_PY_RECORD_H */
+#endif /* GDB_PYTHON_PY_RECORD_H */
diff --git a/gdb/python/py-ref.h b/gdb/python/py-ref.h
index 35029e8d673..938068e7803 100644
--- a/gdb/python/py-ref.h
+++ b/gdb/python/py-ref.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_REF_H
-#define PYTHON_PY_REF_H
+#ifndef GDB_PYTHON_PY_REF_H
+#define GDB_PYTHON_PY_REF_H
 
 #include "gdbsupport/gdb_ref_ptr.h"
 
@@ -42,4 +42,4 @@ struct gdbpy_ref_policy
 template<typename T = PyObject> using gdbpy_ref
   = gdb::ref_ptr<T, gdbpy_ref_policy<T>>;
 
-#endif /* PYTHON_PY_REF_H */
+#endif /* GDB_PYTHON_PY_REF_H */
diff --git a/gdb/python/py-stopevent.h b/gdb/python/py-stopevent.h
index 6cae0a729db..450d8c23b4a 100644
--- a/gdb/python/py-stopevent.h
+++ b/gdb/python/py-stopevent.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_STOPEVENT_H
-#define PYTHON_PY_STOPEVENT_H
+#ifndef GDB_PYTHON_PY_STOPEVENT_H
+#define GDB_PYTHON_PY_STOPEVENT_H
 
 #include "py-event.h"
 
@@ -35,4 +35,4 @@ extern gdbpy_ref<> create_breakpoint_event_object (const gdbpy_ref<> &dict,
 extern gdbpy_ref<> create_signal_event_object (const gdbpy_ref<> &dict,
 					       enum gdb_signal stop_signal);
 
-#endif /* PYTHON_PY_STOPEVENT_H */
+#endif /* GDB_PYTHON_PY_STOPEVENT_H */
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 5132ec15ba6..d9863935f0c 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PYTHON_INTERNAL_H
-#define PYTHON_PYTHON_INTERNAL_H
+#ifndef GDB_PYTHON_PYTHON_INTERNAL_H
+#define GDB_PYTHON_PYTHON_INTERNAL_H
 
 #include "extension.h"
 #include "extension-priv.h"
@@ -1035,4 +1035,4 @@ extern std::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch,
 					    CORE_ADDR address,
 					    disassemble_info *info);
 
-#endif /* PYTHON_PYTHON_INTERNAL_H */
+#endif /* GDB_PYTHON_PYTHON_INTERNAL_H */
diff --git a/gdb/python/python.h b/gdb/python/python.h
index e6279482ce0..e8032853e8e 100644
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PYTHON_H
-#define PYTHON_PYTHON_H
+#ifndef GDB_PYTHON_PYTHON_H
+#define GDB_PYTHON_PYTHON_H
 
 #include "extension.h"
 
@@ -34,4 +34,4 @@ extern cmd_list_element *python_cmd_element;
    at other times.  */
 extern struct objfile *gdbpy_current_objfile;
 
-#endif /* PYTHON_PYTHON_H */
+#endif /* GDB_PYTHON_PYTHON_H */
diff --git a/gdb/ravenscar-thread.h b/gdb/ravenscar-thread.h
index 32c31269225..046b3575e7f 100644
--- a/gdb/ravenscar-thread.h
+++ b/gdb/ravenscar-thread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RAVENSCAR_THREAD_H
-#define RAVENSCAR_THREAD_H
+#ifndef GDB_RAVENSCAR_THREAD_H
+#define GDB_RAVENSCAR_THREAD_H
 
 /* Architecture-specific hooks.  */
 
@@ -130,4 +130,4 @@ struct ravenscar_arch_ops
   CORE_ADDR get_stack_base (struct regcache *) const;
 };
 
-#endif /* !defined (RAVENSCAR_THREAD_H) */
+#endif /* GDB_RAVENSCAR_THREAD_H */
diff --git a/gdb/record-btrace.h b/gdb/record-btrace.h
index b6e6c4df030..5ab3208f659 100644
--- a/gdb/record-btrace.h
+++ b/gdb/record-btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_BTRACE_H
-#define RECORD_BTRACE_H
+#ifndef GDB_RECORD_BTRACE_H
+#define GDB_RECORD_BTRACE_H
 
 /* Push the record_btrace target.  */
 extern void record_btrace_push_target (void);
@@ -29,4 +29,4 @@ extern void record_btrace_push_target (void);
    NULL if the cpu was configured as auto.  */
 extern const struct btrace_cpu *record_btrace_get_cpu (void);
 
-#endif /* RECORD_BTRACE_H */
+#endif /* GDB_RECORD_BTRACE_H */
diff --git a/gdb/record-full.h b/gdb/record-full.h
index ef45b1c0d59..dc14d476715 100644
--- a/gdb/record-full.h
+++ b/gdb/record-full.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_FULL_H
-#define RECORD_FULL_H
+#ifndef GDB_RECORD_FULL_H
+#define GDB_RECORD_FULL_H
 
 extern bool record_full_memory_query;
 
@@ -31,4 +31,4 @@ extern int record_full_is_used (void);
 
 extern scoped_restore_tmpl<int> record_full_gdb_operation_disable_set ();
 
-#endif /* RECORD_FULL_H */
+#endif /* GDB_RECORD_FULL_H */
diff --git a/gdb/record.h b/gdb/record.h
index f44b3952943..471e2711b12 100644
--- a/gdb/record.h
+++ b/gdb/record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_H
-#define RECORD_H
+#ifndef GDB_RECORD_H
+#define GDB_RECORD_H
 
 #include "target/waitstatus.h"
 #include "gdbsupport/enum-flags.h"
@@ -114,4 +114,4 @@ extern void record_start (const char *method, const char *format,
 /* Stop recording.  Throw on failure.  */
 extern void record_stop (int from_tty);
 
-#endif /* RECORD_H */
+#endif /* GDB_RECORD_H */
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 9ba6c79ab0d..1e06dc60096 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGCACHE_H
-#define REGCACHE_H
+#ifndef GDB_REGCACHE_H
+#define GDB_REGCACHE_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/common-regcache.h"
@@ -548,4 +548,4 @@ class register_dump
   gdbarch *m_gdbarch;
 };
 
-#endif /* REGCACHE_H */
+#endif /* GDB_REGCACHE_H */
diff --git a/gdb/regformats/regdef.h b/gdb/regformats/regdef.h
index 0ba7a08bb0c..8715229fcdb 100644
--- a/gdb/regformats/regdef.h
+++ b/gdb/regformats/regdef.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGFORMATS_REGDEF_H
-#define REGFORMATS_REGDEF_H
+#ifndef GDB_REGFORMATS_REGDEF_H
+#define GDB_REGFORMATS_REGDEF_H
 
 namespace gdb {
 
@@ -64,4 +64,4 @@ struct reg
 
 } /* namespace gdb */
 
-#endif /* REGFORMATS_REGDEF_H */
+#endif /* GDB_REGFORMATS_REGDEF_H */
diff --git a/gdb/reggroups.h b/gdb/reggroups.h
index 1be1f0ad613..24f81e4675b 100644
--- a/gdb/reggroups.h
+++ b/gdb/reggroups.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGGROUPS_H
-#define REGGROUPS_H
+#ifndef GDB_REGGROUPS_H
+#define GDB_REGGROUPS_H
 
 struct gdbarch;
 
@@ -98,4 +98,4 @@ extern const reggroup *reggroup_find (struct gdbarch *gdbarch,
 extern int default_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 					const struct reggroup *reggroup);
 
-#endif
+#endif /* GDB_REGGROUPS_H */
diff --git a/gdb/registry.h b/gdb/registry.h
index b6b941f56fd..32216545cb0 100644
--- a/gdb/registry.h
+++ b/gdb/registry.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGISTRY_H
-#define REGISTRY_H
+#ifndef GDB_REGISTRY_H
+#define GDB_REGISTRY_H
 
 #include <type_traits>
 
@@ -225,4 +225,4 @@ class registry
   }
 };
 
-#endif /* REGISTRY_H */
+#endif /* GDB_REGISTRY_H */
diff --git a/gdb/regset.h b/gdb/regset.h
index 5fab2e16d9c..44eaf1406bc 100644
--- a/gdb/regset.h
+++ b/gdb/regset.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGSET_H
-#define REGSET_H 1
+#ifndef GDB_REGSET_H
+#define GDB_REGSET_H
 
 struct gdbarch;
 struct regcache;
@@ -52,4 +52,4 @@ struct regset
 #define REGSET_VARIABLE_SIZE 1	/* Accept a larger regset section size
 				   in a core file without warning.  */
 
-#endif /* regset.h */
+#endif /* GDB_REGSET_H */
diff --git a/gdb/remote-fileio.h b/gdb/remote-fileio.h
index 479dc46888e..d406895bc7e 100644
--- a/gdb/remote-fileio.h
+++ b/gdb/remote-fileio.h
@@ -19,8 +19,8 @@
 
 /* See the GDB User Guide for details of the GDB remote protocol.  */
 
-#ifndef REMOTE_FILEIO_H
-#define REMOTE_FILEIO_H
+#ifndef GDB_REMOTE_FILEIO_H
+#define GDB_REMOTE_FILEIO_H
 
 #include "gdbsupport/fileio.h"
 
@@ -44,4 +44,4 @@ extern void initialize_remote_fileio (
 extern void remote_fileio_to_host_stat (struct fio_stat *fst,
 					struct stat *st);
 
-#endif
+#endif /* GDB_REMOTE_FILEIO_H */
diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h
index 4c5b50a0d12..cca26b09f95 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REMOTE_NOTIF_H
-#define REMOTE_NOTIF_H
+#ifndef GDB_REMOTE_NOTIF_H
+#define GDB_REMOTE_NOTIF_H
 
 #include <list>
 #include <memory>
@@ -131,4 +131,4 @@ extern const notif_client notif_client_stop;
 
 extern bool notif_debug;
 
-#endif /* REMOTE_NOTIF_H */
+#endif /* GDB_REMOTE_NOTIF_H */
diff --git a/gdb/remote.h b/gdb/remote.h
index cb0a66da66e..173f3a2a0f2 100644
--- a/gdb/remote.h
+++ b/gdb/remote.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REMOTE_H
-#define REMOTE_H
+#ifndef GDB_REMOTE_H
+#define GDB_REMOTE_H
 
 #include "remote-notif.h"
 
@@ -121,4 +121,4 @@ extern void send_remote_packet (gdb::array_view<const char> &buf,
 
 extern bool is_remote_target (process_stratum_target *target);
 
-#endif
+#endif /* GDB_REMOTE_H */
diff --git a/gdb/riscv-fbsd-tdep.h b/gdb/riscv-fbsd-tdep.h
index c797b231a8e..22ae08d3678 100644
--- a/gdb/riscv-fbsd-tdep.h
+++ b/gdb/riscv-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_FBSD_TDEP_H
-#define RISCV_FBSD_TDEP_H
+#ifndef GDB_RISCV_FBSD_TDEP_H
+#define GDB_RISCV_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -35,4 +35,4 @@
 extern const struct regset riscv_fbsd_gregset;
 extern const struct regset riscv_fbsd_fpregset;
 
-#endif /* RISCV_FBSD_TDEP_H */
+#endif /* GDB_RISCV_FBSD_TDEP_H */
diff --git a/gdb/riscv-ravenscar-thread.h b/gdb/riscv-ravenscar-thread.h
index a586a85583a..87730438017 100644
--- a/gdb/riscv-ravenscar-thread.h
+++ b/gdb/riscv-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_RAVENSCAR_THREAD_H
-#define RISCV_RAVENSCAR_THREAD_H
+#ifndef GDB_RISCV_RAVENSCAR_THREAD_H
+#define GDB_RISCV_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_riscv_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_RISCV_RAVENSCAR_THREAD_H */
diff --git a/gdb/riscv-tdep.h b/gdb/riscv-tdep.h
index 4bdc2e7a3d5..15c2c4cafcb 100644
--- a/gdb/riscv-tdep.h
+++ b/gdb/riscv-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_TDEP_H
-#define RISCV_TDEP_H
+#ifndef GDB_RISCV_TDEP_H
+#define GDB_RISCV_TDEP_H
 
 #include "arch/riscv.h"
 #include "gdbarch.h"
@@ -180,4 +180,4 @@ extern void riscv_supply_regset (const struct regset *regset,
 /* The names of the RISC-V target description features.  */
 extern const char *riscv_feature_name_csr;
 
-#endif /* RISCV_TDEP_H */
+#endif /* GDB_RISCV_TDEP_H */
diff --git a/gdb/rs6000-aix-tdep.h b/gdb/rs6000-aix-tdep.h
index 52cffc31084..5e4f7865ac6 100644
--- a/gdb/rs6000-aix-tdep.h
+++ b/gdb/rs6000-aix-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RS6000_AIX_TDEP_H
-#define RS6000_AIX_TDEP_H
+#ifndef GDB_RS6000_AIX_TDEP_H
+#define GDB_RS6000_AIX_TDEP_H
 
 extern ULONGEST rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch,
 					   const gdb_byte *ldi_buf,
@@ -25,4 +25,4 @@ extern ULONGEST rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch,
 					   ULONGEST len,
 					   int close_ldinfo_fd);
 
-#endif /* RS6000_AIX_TDEP_H */
+#endif /* GDB_RS6000_AIX_TDEP_H */
diff --git a/gdb/rust-exp.h b/gdb/rust-exp.h
index f5c5904cfb4..e0496e1a050 100644
--- a/gdb/rust-exp.h
+++ b/gdb/rust-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RUST_EXP_H
-#define RUST_EXP_H
+#ifndef GDB_RUST_EXP_H
+#define GDB_RUST_EXP_H
 
 #include "expop.h"
 
@@ -226,4 +226,4 @@ class rust_parenthesized_operation
 
 } /* namespace expr */
 
-#endif /* RUST_EXP_H */
+#endif /* GDB_RUST_EXP_H */
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index 9ae5961e9ac..f9c82454817 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RUST_LANG_H
-#define RUST_LANG_H
+#ifndef GDB_RUST_LANG_H
+#define GDB_RUST_LANG_H
 
 #include "demangle.h"
 #include "language.h"
@@ -228,4 +228,4 @@ class rust_language : public language_defn
 		   const struct value_print_options *options) const;
 };
 
-#endif /* RUST_LANG_H */
+#endif /* GDB_RUST_LANG_H */
diff --git a/gdb/s390-linux-tdep.h b/gdb/s390-linux-tdep.h
index 2f9741dca96..b2efb5b1d2f 100644
--- a/gdb/s390-linux-tdep.h
+++ b/gdb/s390-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef S390_LINUX_TDEP_H
-#define S390_LINUX_TDEP_H
+#ifndef GDB_S390_LINUX_TDEP_H
+#define GDB_S390_LINUX_TDEP_H
 
 #define S390_IS_GREGSET_REGNUM(i)					\
   (((i) >= S390_PSWM_REGNUM && (i) <= S390_A15_REGNUM)			\
@@ -64,4 +64,4 @@ extern const struct target_desc *tdesc_s390x_vx_linux64;
 extern const struct target_desc *tdesc_s390x_tevx_linux64;
 extern const struct target_desc *tdesc_s390x_gs_linux64;
 
-#endif /* S390_LINUX_TDEP_H */
+#endif /* GDB_S390_LINUX_TDEP_H */
diff --git a/gdb/s390-tdep.h b/gdb/s390-tdep.h
index 10f775f468f..bfcb8f17c56 100644
--- a/gdb/s390-tdep.h
+++ b/gdb/s390-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef S390_TDEP_H
-#define S390_TDEP_H
+#ifndef GDB_S390_TDEP_H
+#define GDB_S390_TDEP_H
 
 #include "prologue-value.h"
 #include "gdbarch.h"
@@ -322,4 +322,4 @@ extern struct value *s390_trad_frame_prev_register
 extern const struct target_desc *tdesc_s390_linux32;
 extern const struct target_desc *tdesc_s390x_linux64;
 
-#endif /* S390_TDEP_H */
+#endif /* GDB_S390_TDEP_H */
diff --git a/gdb/scoped-mock-context.h b/gdb/scoped-mock-context.h
index 2446e9ad41b..6fd83da4679 100644
--- a/gdb/scoped-mock-context.h
+++ b/gdb/scoped-mock-context.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_MOCK_CONTEXT_H
-#define SCOPED_MOCK_CONTEXT_H
+#ifndef GDB_SCOPED_MOCK_CONTEXT_H
+#define GDB_SCOPED_MOCK_CONTEXT_H
 
 #include "inferior.h"
 #include "gdbthread.h"
@@ -78,4 +78,4 @@ struct scoped_mock_context
 } // namespace selftests
 #endif /* GDB_SELF_TEST */
 
-#endif /* !defined (SCOPED_MOCK_CONTEXT_H) */
+#endif /* GDB_SCOPED_MOCK_CONTEXT_H */
diff --git a/gdb/selftest-arch.h b/gdb/selftest-arch.h
index 84494076bd7..db11723395e 100644
--- a/gdb/selftest-arch.h
+++ b/gdb/selftest-arch.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SELFTEST_ARCH_H
-#define SELFTEST_ARCH_H
+#ifndef GDB_SELFTEST_ARCH_H
+#define GDB_SELFTEST_ARCH_H
 
 typedef void self_test_foreach_arch_function (struct gdbarch *);
 
@@ -31,4 +31,4 @@ extern void
 			      self_test_foreach_arch_function *function);
 }
 
-#endif /* SELFTEST_ARCH_H */
+#endif /* GDB_SELFTEST_ARCH_H */
diff --git a/gdb/sentinel-frame.h b/gdb/sentinel-frame.h
index 1a37ff1f49a..36bee59f0f0 100644
--- a/gdb/sentinel-frame.h
+++ b/gdb/sentinel-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SENTINEL_FRAME_H)
-#define SENTINEL_FRAME_H 1
+#ifndef GDB_SENTINEL_FRAME_H
+#define GDB_SENTINEL_FRAME_H
 
 struct frame_unwind;
 struct regcache;
@@ -36,4 +36,4 @@ extern void *sentinel_frame_cache (struct regcache *regcache);
 
 extern const struct frame_unwind sentinel_frame_unwind;
 
-#endif /* !defined (SENTINEL_FRAME_H)  */
+#endif /* GDB_SENTINEL_FRAME_H */
diff --git a/gdb/ser-base.h b/gdb/ser-base.h
index 37fe0a2e5f5..ecb7c99ea62 100644
--- a/gdb/ser-base.h
+++ b/gdb/ser-base.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_BASE_H
-#define SER_BASE_H
+#ifndef GDB_SER_BASE_H
+#define GDB_SER_BASE_H
 
 #include "serial.h"
 
@@ -50,4 +50,4 @@ extern void ser_base_write (struct serial *scb, const void *buf, size_t count);
 extern void ser_base_async (struct serial *scb, int async_p);
 extern int ser_base_readchar (struct serial *scb, int timeout);
 
-#endif
+#endif /* GDB_SER_BASE_H */
diff --git a/gdb/ser-event.h b/gdb/ser-event.h
index 2c0a59df5df..08fc62b29ab 100644
--- a/gdb/ser-event.h
+++ b/gdb/ser-event.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_EVENT_H
-#define SER_EVENT_H
+#ifndef GDB_SER_EVENT_H
+#define GDB_SER_EVENT_H
 
 /* This is used to be able to signal the event loop (or any other
    select/poll) of events, in a race-free manner.
@@ -48,4 +48,4 @@ extern void serial_event_set (struct serial_event *event);
    call is made.  */
 extern void serial_event_clear (struct serial_event *event);
 
-#endif
+#endif /* GDB_SER_EVENT_H */
diff --git a/gdb/ser-tcp.h b/gdb/ser-tcp.h
index 6ff3662cefd..a1ebcf3c2a8 100644
--- a/gdb/ser-tcp.h
+++ b/gdb/ser-tcp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_TCP_H
-#define SER_TCP_H
+#ifndef GDB_SER_TCP_H
+#define GDB_SER_TCP_H
 
 struct serial;
 
@@ -28,4 +28,4 @@ extern int net_read_prim (struct serial *scb, size_t count);
 extern int net_write_prim (struct serial *scb, const void *buf, size_t count);
 extern void ser_tcp_send_break (struct serial *scb);
 
-#endif
+#endif /* GDB_SER_TCP_H */
diff --git a/gdb/ser-unix.h b/gdb/ser-unix.h
index 253c95b24c0..487921f8d53 100644
--- a/gdb/ser-unix.h
+++ b/gdb/ser-unix.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_UNIX_H
-#define SER_UNIX_H
+#ifndef GDB_SER_UNIX_H
+#define GDB_SER_UNIX_H
 
 extern int ser_unix_read_prim (struct serial *scb, size_t count);
 extern int ser_unix_write_prim (struct serial *scb, const void *buf, 
 				size_t count);
 
-#endif
+#endif /* GDB_SER_UNIX_H */
diff --git a/gdb/serial.h b/gdb/serial.h
index 69507e69295..017b8904c35 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SERIAL_H
-#define SERIAL_H
+#ifndef GDB_SERIAL_H
+#define GDB_SERIAL_H
 
 #ifdef USE_WIN32API
 #include <winsock2.h>
@@ -326,4 +326,4 @@ extern void serial_done_wait_handle (struct serial *);
 
 #endif /* USE_WIN32API */
 
-#endif /* SERIAL_H */
+#endif /* GDB_SERIAL_H */
diff --git a/gdb/sh-tdep.h b/gdb/sh-tdep.h
index 1b1f019920a..dd524406b25 100644
--- a/gdb/sh-tdep.h
+++ b/gdb/sh-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SH_TDEP_H
-#define SH_TDEP_H
+#ifndef GDB_SH_TDEP_H
+#define GDB_SH_TDEP_H
 
 #include "gdbarch.h"
 
@@ -115,4 +115,4 @@ void sh_corefile_supply_regset (const struct regset *regset,
 void sh_corefile_collect_regset (const struct regset *regset,
 				 const struct regcache *regcache,
 				 int regnum, void *regs, size_t len);
-#endif /* SH_TDEP_H */
+#endif /* GDB_SH_TDEP_H */
diff --git a/gdb/sim-regno.h b/gdb/sim-regno.h
index 7f8f9422a02..76ecfeae3d9 100644
--- a/gdb/sim-regno.h
+++ b/gdb/sim-regno.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SIM_REGNO_H
-#define SIM_REGNO_H
+#ifndef GDB_SIM_REGNO_H
+#define GDB_SIM_REGNO_H
 
 /* The gdbarch_register_sim_regno (REGNUM) method, when there is a
    corresponding simulator register, returns that register number as a
@@ -40,4 +40,4 @@ enum sim_regno {
 
 extern int one2one_register_sim_regno (struct gdbarch *gdbarch, int regnum);
 
-#endif
+#endif /* GDB_SIM_REGNO_H */
diff --git a/gdb/skip.h b/gdb/skip.h
index c3e6cbf98ba..5625a7962fc 100644
--- a/gdb/skip.h
+++ b/gdb/skip.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SKIP_H)
-#define SKIP_H
+#ifndef GDB_SKIP_H
+#define GDB_SKIP_H
 
 struct symtab_and_line;
 
@@ -25,4 +25,4 @@ struct symtab_and_line;
 bool function_name_is_marked_for_skip (const char *function_name,
 				       const symtab_and_line &function_sal);
 
-#endif /* !defined (SKIP_H) */
+#endif /* GDB_SKIP_H */
diff --git a/gdb/sol2-tdep.h b/gdb/sol2-tdep.h
index a189666f05e..8e505d30e0e 100644
--- a/gdb/sol2-tdep.h
+++ b/gdb/sol2-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOL2_TDEP_H
-#define SOL2_TDEP_H 1
+#ifndef GDB_SOL2_TDEP_H
+#define GDB_SOL2_TDEP_H
 
 struct gdbarch;
 
@@ -26,4 +26,4 @@ int sol2_sigtramp_p (const frame_info_ptr &this_frame);
 
 void sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
 
-#endif /* sol2-tdep.h */
+#endif /* GDB_SOL2_TDEP_H */
diff --git a/gdb/solib-aix.h b/gdb/solib-aix.h
index 6487460b04c..79cad4dcdee 100644
--- a/gdb/solib-aix.h
+++ b/gdb/solib-aix.h
@@ -15,12 +15,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_AIX_H
-#define SOLIB_AIX_H
+#ifndef GDB_SOLIB_AIX_H
+#define GDB_SOLIB_AIX_H
 
 struct solib_ops;
 extern const solib_ops solib_aix_so_ops;
 
 extern CORE_ADDR solib_aix_get_toc_value (CORE_ADDR pc);
 
-#endif
+#endif /* GDB_SOLIB_AIX_H */
diff --git a/gdb/solib-darwin.h b/gdb/solib-darwin.h
index d6be9eb5b42..d62d6805137 100644
--- a/gdb/solib-darwin.h
+++ b/gdb/solib-darwin.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_DARWIN_H
-#define SOLIB_DARWIN_H
+#ifndef GDB_SOLIB_DARWIN_H
+#define GDB_SOLIB_DARWIN_H
 
 struct solib_ops;
 
 extern const solib_ops darwin_so_ops;
 
-#endif /* solib-darwin.h */
+#endif /* GDB_SOLIB_DARWIN_H */
diff --git a/gdb/solib-dsbt.h b/gdb/solib-dsbt.h
index e1f7d143848..2777939f7f9 100644
--- a/gdb/solib-dsbt.h
+++ b/gdb/solib-dsbt.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_DSBT_H
-#define SOLIB_DSBT_H
+#ifndef GDB_SOLIB_DSBT_H
+#define GDB_SOLIB_DSBT_H
 
 struct solib_ops;
 
 extern const solib_ops dsbt_so_ops;
 
-#endif /* solib-dsbt.h */
+#endif /* GDB_SOLIB_DSBT_H */
diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h
index 579fe6d9843..37cdaff4882 100644
--- a/gdb/solib-svr4.h
+++ b/gdb/solib-svr4.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_SVR4_H
-#define SOLIB_SVR4_H
+#ifndef GDB_SOLIB_SVR4_H
+#define GDB_SOLIB_SVR4_H
 
 #include "solist.h"
 
@@ -112,4 +112,4 @@ extern struct link_map_offsets *svr4_lp64_fetch_link_map_offsets (void);
    SVR4 run time loader.  */
 int svr4_in_dynsym_resolve_code (CORE_ADDR pc);
 
-#endif /* solib-svr4.h */
+#endif /* GDB_SOLIB_SVR4_H */
diff --git a/gdb/solib-target.h b/gdb/solib-target.h
index 70f53c54553..f03e221588e 100644
--- a/gdb/solib-target.h
+++ b/gdb/solib-target.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_TARGET_H
-#define SOLIB_TARGET_H
+#ifndef GDB_SOLIB_TARGET_H
+#define GDB_SOLIB_TARGET_H
 
 struct solib_ops;
 extern const solib_ops solib_target_so_ops;
 
-#endif /* solib-target.h */
+#endif /* GDB_SOLIB_TARGET_H */
diff --git a/gdb/solib.h b/gdb/solib.h
index f7a93c0718f..1d3089634fe 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_H
-#define SOLIB_H
+#ifndef GDB_SOLIB_H
+#define GDB_SOLIB_H
 
 /* Forward decl's for prototypes */
 struct solib;
@@ -143,4 +143,4 @@ extern void set_cbfd_soname_build_id (gdb_bfd_ref_ptr abfd,
 				      const char *soname,
 				      const bfd_build_id *build_id);
 
-#endif /* SOLIB_H */
+#endif /* GDB_SOLIB_H */
diff --git a/gdb/solist.h b/gdb/solist.h
index f0d22080de1..006cdddeed9 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIST_H
-#define SOLIST_H
+#ifndef GDB_SOLIST_H
+#define GDB_SOLIST_H
 
 #define SO_NAME_MAX_PATH_SIZE 512	/* FIXME: Should be dynamic */
 /* For domain_enum domain.  */
@@ -186,4 +186,4 @@ extern gdb_bfd_ref_ptr solib_bfd_fopen (const char *pathname, int fd);
 /* Find solib binary file and open it.  */
 extern gdb_bfd_ref_ptr solib_bfd_open (const char *in_pathname);
 
-#endif
+#endif /* GDB_SOLIST_H */
diff --git a/gdb/source-cache.h b/gdb/source-cache.h
index d4cb7d00ae8..35eeb1cb204 100644
--- a/gdb/source-cache.h
+++ b/gdb/source-cache.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOURCE_CACHE_H
-#define SOURCE_CACHE_H
+#ifndef GDB_SOURCE_CACHE_H
+#define GDB_SOURCE_CACHE_H
 
 #include <unordered_map>
 #include <unordered_set>
@@ -104,4 +104,4 @@ class source_cache
 /* The global source cache.  */
 extern source_cache g_source_cache;
 
-#endif /* SOURCE_CACHE_H */
+#endif /* GDB_SOURCE_CACHE_H */
diff --git a/gdb/source.h b/gdb/source.h
index 144ee48f722..09eb1e38655 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOURCE_H
-#define SOURCE_H
+#ifndef GDB_SOURCE_H
+#define GDB_SOURCE_H
 
 #include "gdbsupport/scoped_fd.h"
 
@@ -216,4 +216,4 @@ extern void forget_cached_source_info (void);
    need to would make things slower than necessary.  */
 extern void select_source_symtab ();
 
-#endif
+#endif /* GDB_SOURCE_H */
diff --git a/gdb/sparc-nat.h b/gdb/sparc-nat.h
index 29d994c2a41..712c9d0ac12 100644
--- a/gdb/sparc-nat.h
+++ b/gdb/sparc-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_NAT_H
-#define SPARC_NAT_H 1
+#ifndef GDB_SPARC_NAT_H
+#define GDB_SPARC_NAT_H
 
 #include "target.h"
 
@@ -82,4 +82,4 @@ struct sparc_target : public BaseTarget
   }
 };
 
-#endif /* sparc-nat.h */
+#endif /* GDB_SPARC_NAT_H */
diff --git a/gdb/sparc-ravenscar-thread.h b/gdb/sparc-ravenscar-thread.h
index d45f6ba8ba5..5f2749f5cd5 100644
--- a/gdb/sparc-ravenscar-thread.h
+++ b/gdb/sparc-ravenscar-thread.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_RAVENSCAR_THREAD_H
-#define SPARC_RAVENSCAR_THREAD_H
+#ifndef GDB_SPARC_RAVENSCAR_THREAD_H
+#define GDB_SPARC_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_sparc_ravenscar_ops (struct gdbarch *gdbarch);
-#endif
+#endif /* GDB_SPARC_RAVENSCAR_THREAD_H */
diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h
index 2d8c50768be..4fd7e6b0f74 100644
--- a/gdb/sparc-tdep.h
+++ b/gdb/sparc-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_TDEP_H
-#define SPARC_TDEP_H 1
+#ifndef GDB_SPARC_TDEP_H
+#define GDB_SPARC_TDEP_H
 
 #include "gdbarch.h"
 
@@ -264,4 +264,4 @@ extern void sparc32nbsd_init_abi (struct gdbarch_info info,
 extern struct trad_frame_saved_reg *
   sparc32nbsd_sigcontext_saved_regs (const frame_info_ptr &next_frame);
 
-#endif /* sparc-tdep.h */
+#endif /* GDB_SPARC_TDEP_H */
diff --git a/gdb/sparc64-tdep.h b/gdb/sparc64-tdep.h
index 6fcd91ee8d3..a19af4a1b5d 100644
--- a/gdb/sparc64-tdep.h
+++ b/gdb/sparc64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC64_TDEP_H
-#define SPARC64_TDEP_H 1
+#ifndef GDB_SPARC64_TDEP_H
+#define GDB_SPARC64_TDEP_H
 
 class frame_info_ptr;
 struct gdbarch;
@@ -137,4 +137,4 @@ extern const struct sparc_fpregmap sparc64_bsd_fpregmap;
 
 extern void sparc64_forget_process (pid_t pid);
 
-#endif /* sparc64-tdep.h */
+#endif /* GDB_SPARC64_TDEP_H */
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index 0a868409470..00c7bd9edfa 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef STABSREAD_H
-#define STABSREAD_H
+#ifndef GDB_STABSREAD_H
+#define GDB_STABSREAD_H
 
 struct objfile;
 struct legacy_psymtab;
@@ -215,4 +215,4 @@ extern void init_header_files (void);
 
 extern void scan_file_globals (struct objfile *objfile);
 
-#endif /* STABSREAD_H */
+#endif /* GDB_STABSREAD_H */
diff --git a/gdb/stack.h b/gdb/stack.h
index e7242c71036..e87ba322dee 100644
--- a/gdb/stack.h
+++ b/gdb/stack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef STACK_H
-#define STACK_H
+#ifndef GDB_STACK_H
+#define GDB_STACK_H
 
 gdb::unique_xmalloc_ptr<char> find_frame_funname (const frame_info_ptr &frame,
 						  enum language *funlang,
@@ -84,4 +84,4 @@ void frame_apply_all_cmd_completer (struct cmd_list_element *ignore,
 				    completion_tracker &tracker,
 				    const char *text, const char */*word*/);
 
-#endif /* #ifndef STACK_H */
+#endif /* GDB_STACK_H */
diff --git a/gdb/stap-probe.h b/gdb/stap-probe.h
index 1401b876ba7..e757d80ef38 100644
--- a/gdb/stap-probe.h
+++ b/gdb/stap-probe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (STAP_PROBE_H)
-#define STAP_PROBE_H 1
+#ifndef GDB_STAP_PROBE_H
+#define GDB_STAP_PROBE_H
 
 #include "parser-defs.h"
 
@@ -66,4 +66,4 @@ struct stap_parse_info
   int inside_paren_p;
 };
 
-#endif /* !defined (STAP_PROBE_H) */
+#endif /* GDB_STAP_PROBE_H */
diff --git a/gdb/symfile-add-flags.h b/gdb/symfile-add-flags.h
index 19dd5e36907..3db532cc86b 100644
--- a/gdb/symfile-add-flags.h
+++ b/gdb/symfile-add-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMFILE_ADD_FLAGS_H)
-#define SYMFILE_ADD_FLAGS_H
+#ifndef GDB_SYMFILE_ADD_FLAGS_H
+#define GDB_SYMFILE_ADD_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -54,4 +54,4 @@ enum symfile_add_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum symfile_add_flag, symfile_add_flags);
 
-#endif /* !defined(SYMFILE_ADD_FLAGS_H) */
+#endif /* GDB_SYMFILE_ADD_FLAGS_H */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 6f8b441b39f..3ed2179ba41 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMFILE_H)
-#define SYMFILE_H
+#ifndef GDB_SYMFILE_H
+#define GDB_SYMFILE_H
 
 /* This file requires that you first include "bfd.h".  */
 #include "symtab.h"
@@ -379,4 +379,4 @@ extern int readnow_symbol_files;
 
 extern int readnever_symbol_files;
 
-#endif /* !defined(SYMFILE_H) */
+#endif /* GDB_SYMFILE_H */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index bf9a3cfb79f..bfc91574415 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMTAB_H)
-#define SYMTAB_H 1
+#ifndef GDB_SYMTAB_H
+#define GDB_SYMTAB_H
 
 #include <array>
 #include <vector>
@@ -2974,4 +2974,4 @@ extern void info_sources_worker (struct ui_out *uiout,
 
 std::optional<CORE_ADDR> find_epilogue_using_linetable (CORE_ADDR func_addr);
 
-#endif /* !defined(SYMTAB_H) */
+#endif /* GDB_SYMTAB_H */
diff --git a/gdb/target-connection.h b/gdb/target-connection.h
index c742932644f..4faae112dc7 100644
--- a/gdb/target-connection.h
+++ b/gdb/target-connection.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_CONNECTION_H
-#define TARGET_CONNECTION_H
+#ifndef GDB_TARGET_CONNECTION_H
+#define GDB_TARGET_CONNECTION_H
 
 #include <string>
 
@@ -37,4 +37,4 @@ void connection_list_remove (process_stratum_target *t);
    it.  */
 std::string make_target_connection_string (process_stratum_target *t);
 
-#endif /* TARGET_CONNECTION_H */
+#endif /* GDB_TARGET_CONNECTION_H */
diff --git a/gdb/target-dcache.h b/gdb/target-dcache.h
index 4acc82f83ce..a199a2382f2 100644
--- a/gdb/target-dcache.h
+++ b/gdb/target-dcache.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DCACHE_H
-#define TARGET_DCACHE_H
+#ifndef GDB_TARGET_DCACHE_H
+#define GDB_TARGET_DCACHE_H
 
 #include "dcache.h"
 #include "progspace.h"
@@ -33,4 +33,4 @@ extern int stack_cache_enabled_p (void);
 
 extern int code_cache_enabled_p (void);
 
-#endif /* TARGET_DCACHE_H */
+#endif /* GDB_TARGET_DCACHE_H */
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index 20ba1f73ac5..cf8d690511f 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DEBUG_H
-#define TARGET_DEBUG_H
+#ifndef GDB_TARGET_DEBUG_H
+#define GDB_TARGET_DEBUG_H
 
 /* Printers for the debug target.  Each prints an object of a given
    type to a string that needn't be freed.  Most printers are macros,
@@ -264,4 +264,4 @@ target_debug_print_x86_xsave_layout (const x86_xsave_layout &layout)
 #undef POFFS
   gdb_puts (" }", gdb_stdlog);
 }
-#endif /* TARGET_DEBUG_H */
+#endif /* GDB_TARGET_DEBUG_H */
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 54c1f234f06..833a367bc9a 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DESCRIPTIONS_H
-#define TARGET_DESCRIPTIONS_H 1
+#ifndef GDB_TARGET_DESCRIPTIONS_H
+#define GDB_TARGET_DESCRIPTIONS_H
 #include "gdbsupport/tdesc.h"
 #include "gdbarch.h"
 
@@ -238,4 +238,4 @@ void record_xml_tdesc (const char *xml_file,
 }
 #endif
 
-#endif /* TARGET_DESCRIPTIONS_H */
+#endif /* GDB_TARGET_DESCRIPTIONS_H */
diff --git a/gdb/target-float.h b/gdb/target-float.h
index a649f5ceb86..0b9cd7a8409 100644
--- a/gdb/target-float.h
+++ b/gdb/target-float.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_FLOAT_H
-#define TARGET_FLOAT_H
+#ifndef GDB_TARGET_FLOAT_H
+#define GDB_TARGET_FLOAT_H
 
 #include "expression.h"
 
@@ -58,4 +58,4 @@ extern void target_float_binop (enum exp_opcode opcode,
 extern int target_float_compare (const gdb_byte *x, const struct type *type_x,
 				 const gdb_byte *y, const struct type *type_y);
 
-#endif /* TARGET_FLOAT_H */
+#endif /* GDB_TARGET_FLOAT_H */
diff --git a/gdb/target.h b/gdb/target.h
index 486a0a687b0..941022a5c4a 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TARGET_H)
-#define TARGET_H
+#ifndef GDB_TARGET_H
+#define GDB_TARGET_H
 
 struct objfile;
 struct ui_file;
@@ -2586,4 +2586,4 @@ extern void target_prepare_to_generate_core (void);
 /* See to_done_generating_core.  */
 extern void target_done_generating_core (void);
 
-#endif /* !defined (TARGET_H) */
+#endif /* GDB_TARGET_H */
diff --git a/gdb/target/resume.h b/gdb/target/resume.h
index 2f13aa9ada1..024e39b5bce 100644
--- a/gdb/target/resume.h
+++ b/gdb/target/resume.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_RESUME_H
-#define TARGET_RESUME_H
+#ifndef GDB_TARGET_RESUME_H
+#define GDB_TARGET_RESUME_H
 
 /* Ways to "resume" a thread.  */
 
@@ -34,4 +34,4 @@ enum resume_kind
   resume_stop
 };
 
-#endif /* TARGET_RESUME_H */
+#endif /* GDB_TARGET_RESUME_H */
diff --git a/gdb/target/target.h b/gdb/target/target.h
index 408db3558b0..87a3464e323 100644
--- a/gdb/target/target.h
+++ b/gdb/target/target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_TARGET_H
-#define TARGET_TARGET_H
+#ifndef GDB_TARGET_TARGET_H
+#define GDB_TARGET_TARGET_H
 
 #include "target/waitstatus.h"
 #include "target/wait.h"
@@ -262,4 +262,4 @@ class target_terminal
   static target_terminal_state m_terminal_state;
 };
 
-#endif /* TARGET_TARGET_H */
+#endif /* GDB_TARGET_TARGET_H */
diff --git a/gdb/target/wait.h b/gdb/target/wait.h
index 304f61497aa..026a42f9a30 100644
--- a/gdb/target/wait.h
+++ b/gdb/target/wait.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_WAIT_H
-#define TARGET_WAIT_H
+#ifndef GDB_TARGET_WAIT_H
+#define GDB_TARGET_WAIT_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -34,4 +34,4 @@ enum target_wait_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum target_wait_flag, target_wait_flags);
 
-#endif /* TARGET_WAIT_H */
+#endif /* GDB_TARGET_WAIT_H */
diff --git a/gdb/target/waitstatus.h b/gdb/target/waitstatus.h
index dce1a7f3175..08907f5a610 100644
--- a/gdb/target/waitstatus.h
+++ b/gdb/target/waitstatus.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_WAITSTATUS_H
-#define TARGET_WAITSTATUS_H
+#ifndef GDB_TARGET_WAITSTATUS_H
+#define GDB_TARGET_WAITSTATUS_H
 
 #include "diagnostics.h"
 #include "gdbsupport/gdb_signals.h"
@@ -470,4 +470,4 @@ enum target_stop_reason
   TARGET_STOPPED_BY_SINGLE_STEP
 };
 
-#endif /* TARGET_WAITSTATUS_H */
+#endif /* GDB_TARGET_WAITSTATUS_H */
diff --git a/gdb/terminal.h b/gdb/terminal.h
index 236ab67745b..154b4be952b 100644
--- a/gdb/terminal.h
+++ b/gdb/terminal.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TERMINAL_H)
-#define TERMINAL_H 1
+#ifndef GDB_TERMINAL_H
+#define GDB_TERMINAL_H
 
 struct inferior;
 
@@ -43,4 +43,4 @@ extern void gdb_save_tty_state (void);
    have had a chance to alter it.  */
 extern void set_initial_gdb_ttystate (void);
 
-#endif /* !defined (TERMINAL_H) */
+#endif /* GDB_TERMINAL_H */
diff --git a/gdb/test-target.h b/gdb/test-target.h
index 54924e06994..b88c154da8f 100644
--- a/gdb/test-target.h
+++ b/gdb/test-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TEST_TARGET_H
-#define TEST_TARGET_H
+#ifndef GDB_TEST_TARGET_H
+#define GDB_TEST_TARGET_H
 
 #include "process-stratum-target.h"
 
@@ -62,4 +62,4 @@ class test_target_ops : public process_stratum_target
 } // namespace selftests
 #endif /* GDB_SELF_TEST */
 
-#endif /* !defined (TEST_TARGET_H) */
+#endif /* GDB_TEST_TARGET_H */
diff --git a/gdb/thread-fsm.h b/gdb/thread-fsm.h
index ed117719c0d..36efee75abc 100644
--- a/gdb/thread-fsm.h
+++ b/gdb/thread-fsm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef THREAD_FSM_H
-#define THREAD_FSM_H
+#ifndef GDB_THREAD_FSM_H
+#define GDB_THREAD_FSM_H
 
 #include "mi/mi-common.h"
 
@@ -129,4 +129,4 @@ struct thread_fsm
   }
 };
 
-#endif /* THREAD_FSM_H */
+#endif /* GDB_THREAD_FSM_H */
diff --git a/gdb/thread-iter.h b/gdb/thread-iter.h
index a2fd9891a57..89537213ac0 100644
--- a/gdb/thread-iter.h
+++ b/gdb/thread-iter.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef THREAD_ITER_H
-#define THREAD_ITER_H
+#ifndef GDB_THREAD_ITER_H
+#define GDB_THREAD_ITER_H
 
 #include "gdbsupport/filtered-iterator.h"
 #include "gdbsupport/iterator-range.h"
@@ -249,4 +249,4 @@ class all_non_exited_threads_range
   ptid_t m_filter_ptid;
 };
 
-#endif /* THREAD_ITER_H */
+#endif /* GDB_THREAD_ITER_H */
diff --git a/gdb/tic6x-tdep.h b/gdb/tic6x-tdep.h
index 886e1b8b309..03a8a3ebb55 100644
--- a/gdb/tic6x-tdep.h
+++ b/gdb/tic6x-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TIC6X_TDEP_H
-#define TIC6X_TDEP_H
+#ifndef GDB_TIC6X_TDEP_H
+#define GDB_TIC6X_TDEP_H
 
 #include "gdbarch.h"
 
@@ -57,4 +57,4 @@ struct tic6x_gdbarch_tdep : gdbarch_tdep_base
   int has_gp = 0; /* Has general purpose registers A16 - A31 and B16 - B31.  */
 };
 
-#endif /* TIC6X_TDEP_H */
+#endif /* GDB_TIC6X_TDEP_H */
diff --git a/gdb/tid-parse.h b/gdb/tid-parse.h
index b7bd920f48a..ad45f216350 100644
--- a/gdb/tid-parse.h
+++ b/gdb/tid-parse.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TID_PARSE_H
-#define TID_PARSE_H
+#ifndef GDB_TID_PARSE_H
+#define GDB_TID_PARSE_H
 
 #include "cli/cli-utils.h"
 
@@ -186,4 +186,4 @@ class tid_range_parser
 extern int tid_is_in_list (const char *list, int default_inferior,
 			   int inf_num, int thr_num);
 
-#endif /* TID_PARSE_H */
+#endif /* GDB_TID_PARSE_H */
diff --git a/gdb/tilegx-tdep.h b/gdb/tilegx-tdep.h
index 893035a6273..5430281bed5 100644
--- a/gdb/tilegx-tdep.h
+++ b/gdb/tilegx-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TILEGX_TDEP_H
-#define TILEGX_TDEP_H
+#ifndef GDB_TILEGX_TDEP_H
+#define GDB_TILEGX_TDEP_H
 
 /* TILE-Gx has 56 general purpose registers (R0 - R52, TP, SP, LR),
    plus 8 special general purpose registers (network and ZERO),
@@ -107,4 +107,4 @@ enum tilegx_regnum
 
 enum { tilegx_reg_size = 8 };
 
-#endif /* tilegx-tdep.h */
+#endif /* GDB_TILEGX_TDEP_H */
diff --git a/gdb/top.h b/gdb/top.h
index 68c637a03d8..c142f1d9363 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TOP_H
-#define TOP_H
+#ifndef GDB_TOP_H
+#define GDB_TOP_H
 
 #include "gdbsupport/event-loop.h"
 #include "gdbsupport/next-iterator.h"
@@ -109,4 +109,4 @@ extern bool check_quiet_mode ();
 
 extern void unbuffer_stream (FILE *stream);
 
-#endif
+#endif /* GDB_TOP_H */
diff --git a/gdb/tracectf.h b/gdb/tracectf.h
index 08a681cb8cf..9f821c5314c 100644
--- a/gdb/tracectf.h
+++ b/gdb/tracectf.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CTF_H
-#define CTF_H
+#ifndef GDB_TRACECTF_H
+#define GDB_TRACECTF_H
 
 extern struct trace_file_writer *ctf_trace_file_writer_new (void);
 
-#endif
+#endif /* GDB_TRACECTF_H */
diff --git a/gdb/tracefile.h b/gdb/tracefile.h
index 90967eff855..028f70dabd3 100644
--- a/gdb/tracefile.h
+++ b/gdb/tracefile.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRACEFILE_H
-#define TRACEFILE_H 1
+#ifndef GDB_TRACEFILE_H
+#define GDB_TRACEFILE_H
 
 #include "tracepoint.h"
 #include "target.h"
@@ -151,4 +151,4 @@ class tracefile_target : public process_stratum_target
 
 extern void tracefile_fetch_registers (struct regcache *regcache, int regno);
 
-#endif /* TRACEFILE_H */
+#endif /* GDB_TRACEFILE_H */
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index 5e6ea67c8d2..1b9e03efc7a 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TRACEPOINT_H)
-#define TRACEPOINT_H 1
+#ifndef GDB_TRACEPOINT_H
+#define GDB_TRACEPOINT_H
 
 #include "breakpoint.h"
 #include "memrange.h"
@@ -432,4 +432,4 @@ extern struct bp_location *get_traceframe_location (int *stepping_frame_p);
 /* Command element for the 'while-stepping' command.  */
 extern cmd_list_element *while_stepping_cmd_element;
 
-#endif	/* TRACEPOINT_H */
+#endif /* GDB_TRACEPOINT_H */
diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h
index ca8792baa17..40a3f74d44a 100644
--- a/gdb/trad-frame.h
+++ b/gdb/trad-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRAD_FRAME_H
-#define TRAD_FRAME_H
+#ifndef GDB_TRAD_FRAME_H
+#define GDB_TRAD_FRAME_H
 
 #include "frame.h"
 
@@ -203,4 +203,4 @@ struct value *trad_frame_get_prev_register (const frame_info_ptr &this_frame,
 					    trad_frame_saved_reg this_saved_regs[],
 					    int regnum);
 
-#endif
+#endif /* GDB_TRAD_FRAME_H */
diff --git a/gdb/tramp-frame.h b/gdb/tramp-frame.h
index d9e54f5981a..a7288c1889c 100644
--- a/gdb/tramp-frame.h
+++ b/gdb/tramp-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRAMP_FRAME_H
-#define TRAMP_FRAME_H
+#ifndef GDB_TRAMP_FRAME_H
+#define GDB_TRAMP_FRAME_H
 
 #include "frame.h"
 #include "frame-unwind.h"	/* For frame_prev_arch_ftype.  */
@@ -85,4 +85,4 @@ struct tramp_frame
 void tramp_frame_prepend_unwinder (struct gdbarch *gdbarch,
 				   const struct tramp_frame *tramp);
 
-#endif
+#endif /* GDB_TRAMP_FRAME_H */
diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h
index 2dc579bce30..0f6553845a2 100644
--- a/gdb/tui/tui-command.h
+++ b/gdb/tui/tui-command.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_COMMAND_H
-#define TUI_TUI_COMMAND_H
+#ifndef GDB_TUI_TUI_COMMAND_H
+#define GDB_TUI_TUI_COMMAND_H
 
 #include "tui/tui-data.h"
 
@@ -58,4 +58,4 @@ struct tui_cmd_window
 /* Refresh the command window.  */
 extern void tui_refresh_cmd_win (void);
 
-#endif /* TUI_TUI_COMMAND_H */
+#endif /* GDB_TUI_TUI_COMMAND_H */
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index ce9c1a8a95a..4ff9fa64aa7 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_DATA_H
-#define TUI_TUI_DATA_H
+#ifndef GDB_TUI_TUI_DATA_H
+#define GDB_TUI_TUI_DATA_H
 
 #include "tui/tui.h"
 #include "gdb_curses.h"
@@ -325,4 +325,4 @@ extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
 
 extern unsigned int tui_tab_width;
 
-#endif /* TUI_TUI_DATA_H */
+#endif /* GDB_TUI_TUI_DATA_H */
diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
index 0aef091069b..a5a240fddf1 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_DISASM_H
-#define TUI_TUI_DISASM_H
+#ifndef GDB_TUI_TUI_DISASM_H
+#define GDB_TUI_TUI_DISASM_H
 
 #include "tui/tui.h"
 #include "tui/tui-data.h"
@@ -66,4 +66,4 @@ struct tui_disasm_window : public tui_source_window_base
 
 extern void tui_get_begin_asm_address (struct gdbarch **, CORE_ADDR *);
 
-#endif /* TUI_TUI_DISASM_H */
+#endif /* GDB_TUI_TUI_DISASM_H */
diff --git a/gdb/tui/tui-file.h b/gdb/tui/tui-file.h
index b723f3974ea..6178a90a6c6 100644
--- a/gdb/tui/tui-file.h
+++ b/gdb/tui/tui-file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_FILE_H
-#define TUI_TUI_FILE_H
+#ifndef GDB_TUI_TUI_FILE_H
+#define GDB_TUI_TUI_FILE_H
 
 #include "ui-file.h"
 
@@ -41,4 +41,4 @@ class tui_file : public stdio_file
   bool m_buffered;
 };
 
-#endif /* TUI_TUI_FILE_H */
+#endif /* GDB_TUI_TUI_FILE_H */
diff --git a/gdb/tui/tui-hooks.h b/gdb/tui/tui-hooks.h
index 97683826544..21ba169713c 100644
--- a/gdb/tui/tui-hooks.h
+++ b/gdb/tui/tui-hooks.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_HOOKS_H
-#define TUI_TUI_HOOKS_H
+#ifndef GDB_TUI_TUI_HOOKS_H
+#define GDB_TUI_TUI_HOOKS_H
 
 extern void tui_install_hooks (void);
 extern void tui_remove_hooks (void);
 
-#endif /* TUI_TUI_HOOKS_H */
+#endif /* GDB_TUI_TUI_HOOKS_H */
diff --git a/gdb/tui/tui-io.h b/gdb/tui/tui-io.h
index 9e7eecdf5f4..66b3b90dfe3 100644
--- a/gdb/tui/tui-io.h
+++ b/gdb/tui/tui-io.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_IO_H
-#define TUI_TUI_IO_H
+#ifndef GDB_TUI_TUI_IO_H
+#define GDB_TUI_TUI_IO_H
 
 #include "gdb_curses.h"
 
@@ -60,4 +60,4 @@ extern cli_ui_out *tui_old_uiout;
    next line.  */
 extern void tui_inject_newline_into_command_window ();
 
-#endif /* TUI_TUI_IO_H */
+#endif /* GDB_TUI_TUI_IO_H */
diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h
index f621f9cea55..d1dc9bfd904 100644
--- a/gdb/tui/tui-layout.h
+++ b/gdb/tui/tui-layout.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_LAYOUT_H
-#define TUI_TUI_LAYOUT_H
+#ifndef GDB_TUI_TUI_LAYOUT_H
+#define GDB_TUI_TUI_LAYOUT_H
 
 #include "ui-file.h"
 
@@ -418,4 +418,4 @@ using known_window_names_range
 
 extern known_window_names_range all_known_window_names ();
 
-#endif /* TUI_TUI_LAYOUT_H */
+#endif /* GDB_TUI_TUI_LAYOUT_H */
diff --git a/gdb/tui/tui-location.h b/gdb/tui/tui-location.h
index db558a4e147..8e83b26996b 100644
--- a/gdb/tui/tui-location.h
+++ b/gdb/tui/tui-location.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_LOCATION_H
-#define TUI_TUI_LOCATION_H
+#ifndef GDB_TUI_TUI_LOCATION_H
+#define GDB_TUI_TUI_LOCATION_H
 
 #include "tui/tui.h"
 #include "tui/tui.h"
@@ -90,4 +90,4 @@ struct tui_location_tracker
 
 extern tui_location_tracker tui_location;
 
-#endif /* TUI_TUI_LOCATION_H */
+#endif /* GDB_TUI_TUI_LOCATION_H */
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 07b951316b6..eea5ca6d061 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_REGS_H
-#define TUI_TUI_REGS_H
+#ifndef GDB_TUI_TUI_REGS_H
+#define GDB_TUI_TUI_REGS_H
 
 #include "tui/tui-data.h"
 #include "reggroups.h"
@@ -145,4 +145,4 @@ struct tui_data_window : public tui_win_info
   gdbarch *m_gdbarch = nullptr;
 };
 
-#endif /* TUI_TUI_REGS_H */
+#endif /* GDB_TUI_TUI_REGS_H */
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 6d4ad4e39c2..4312b928740 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_SOURCE_H
-#define TUI_TUI_SOURCE_H
+#ifndef GDB_TUI_TUI_SOURCE_H
+#define GDB_TUI_TUI_SOURCE_H
 
 #include "tui/tui-data.h"
 #include "tui-winsource.h"
@@ -84,4 +84,4 @@ struct tui_source_window : public tui_source_window_base
   gdb::unique_xmalloc_ptr<char> m_fullname;
 };
 
-#endif /* TUI_TUI_SOURCE_H */
+#endif /* GDB_TUI_TUI_SOURCE_H */
diff --git a/gdb/tui/tui-status.h b/gdb/tui/tui-status.h
index 0af44664104..b4c8a2bd407 100644
--- a/gdb/tui/tui-status.h
+++ b/gdb/tui/tui-status.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_STATUS_H
-#define TUI_TUI_STATUS_H
+#ifndef GDB_TUI_TUI_STATUS_H
+#define GDB_TUI_TUI_STATUS_H
 
 #include "tui/tui-data.h"
 
@@ -53,4 +53,4 @@ struct tui_status_window
 extern void tui_show_status_content (void);
 extern void tui_show_frame_info (const frame_info_ptr &);
 
-#endif /* TUI_TUI_STATUS_H */
+#endif /* GDB_TUI_TUI_STATUS_H */
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 9b03d01c430..15219930149 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WIN_H
-#define TUI_TUI_WIN_H
+#ifndef GDB_TUI_TUI_WIN_H
+#define GDB_TUI_TUI_WIN_H
 
 #include "tui/tui-data.h"
 
@@ -61,4 +61,4 @@ extern bool style_tui_current_position;
 /* Whether to replace the spaces in the left margin with '_' and '0'.  */
 extern bool tui_left_margin_verbose;
 
-#endif /* TUI_TUI_WIN_H */
+#endif /* GDB_TUI_TUI_WIN_H */
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 6bee433689e..c36f32de7e4 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WINGENERAL_H
-#define TUI_TUI_WINGENERAL_H
+#ifndef GDB_TUI_TUI_WINGENERAL_H
+#define GDB_TUI_TUI_WINGENERAL_H
 
 #include "gdb_curses.h"
 
@@ -53,4 +53,4 @@ class tui_suppress_output
    suppressed via tui_suppress_output, do not call wrefresh.  */
 extern void tui_wrefresh (WINDOW *win);
 
-#endif /* TUI_TUI_WINGENERAL_H */
+#endif /* GDB_TUI_TUI_WINGENERAL_H */
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 646597306f2..7effb5694e3 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WINSOURCE_H
-#define TUI_TUI_WINSOURCE_H
+#ifndef GDB_TUI_TUI_WINSOURCE_H
+#define GDB_TUI_TUI_WINSOURCE_H
 
 #include "tui/tui-data.h"
 #include "symtab.h"
@@ -365,4 +365,4 @@ extern std::string tui_copy_source_line (const char **ptr,
 /* Constant definitions. */
 #define SCROLL_THRESHOLD 2	/* Threshold for lazy scroll.  */
 
-#endif /* TUI_TUI_WINSOURCE_H */
+#endif /* GDB_TUI_TUI_WINSOURCE_H */
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index 00295107eac..1bcaa2f4099 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_H
-#define TUI_TUI_H
+#ifndef GDB_TUI_TUI_H
+#define GDB_TUI_TUI_H
 
 /* Flag to control tui debugging.  */
 
@@ -98,4 +98,4 @@ extern void tui_set_key_mode (enum tui_key_mode mode);
 
 extern bool tui_active;
 
-#endif /* TUI_TUI_H */
+#endif /* GDB_TUI_TUI_H */
diff --git a/gdb/type-stack.h b/gdb/type-stack.h
index faef3c85f67..87c0fe20c5a 100644
--- a/gdb/type-stack.h
+++ b/gdb/type-stack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TYPE_STACK_H
-#define TYPE_STACK_H
+#ifndef GDB_TYPE_STACK_H
+#define GDB_TYPE_STACK_H
 
 #include "gdbtypes.h"
 #include <vector>
@@ -203,4 +203,4 @@ struct type_stack
   std::vector<union type_stack_elt> m_elements;
 };
 
-#endif /* TYPE_STACK_H */
+#endif /* GDB_TYPE_STACK_H */
diff --git a/gdb/typeprint.h b/gdb/typeprint.h
index e14d70efa2d..91b64f3e728 100644
--- a/gdb/typeprint.h
+++ b/gdb/typeprint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TYPEPRINT_H
-#define TYPEPRINT_H
+#ifndef GDB_TYPEPRINT_H
+#define GDB_TYPEPRINT_H
 
 #include "gdbsupport/gdb_obstack.h"
 
@@ -181,4 +181,4 @@ extern void val_print_not_allocated (struct ui_file *stream);
 
 extern void val_print_not_associated (struct ui_file *stream);
 
-#endif
+#endif /* GDB_TYPEPRINT_H */
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index 96864409375..627e51ae84c 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_FILE_H
-#define UI_FILE_H
+#ifndef GDB_UI_FILE_H
+#define GDB_UI_FILE_H
 
 #include <string>
 #include "ui-style.h"
@@ -467,4 +467,4 @@ class timestamped_file : public wrapped_file
   bool m_needs_timestamp = true;
 };
 
-#endif
+#endif /* GDB_UI_FILE_H */
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 5b6ddd55063..67f6b18576f 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_OUT_H
-#define UI_OUT_H 1
+#ifndef GDB_UI_OUT_H
+#define GDB_UI_OUT_H
 
 #include <vector>
 
@@ -654,4 +654,4 @@ struct buffered_streams
   std::optional<buffering_file> m_buffered_uiout;
 };
 
-#endif /* UI_OUT_H */
+#endif /* GDB_UI_OUT_H */
diff --git a/gdb/ui-style.h b/gdb/ui-style.h
index 1b7b5fafb9d..53ac2897c78 100644
--- a/gdb/ui-style.h
+++ b/gdb/ui-style.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_STYLE_H
-#define UI_STYLE_H
+#ifndef GDB_UI_STYLE_H
+#define GDB_UI_STYLE_H
 
 /* Styles that can be applied to a ui_file.  */
 struct ui_file_style
@@ -250,4 +250,4 @@ struct ui_file_style
 
 extern bool skip_ansi_escape (const char *buf, int *n_read);
 
-#endif /* UI_STYLE_H */
+#endif /* GDB_UI_STYLE_H */
diff --git a/gdb/ui.h b/gdb/ui.h
index 95cf273473a..ec3a6c5fbae 100644
--- a/gdb/ui.h
+++ b/gdb/ui.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_H
-#define UI_H
+#ifndef GDB_UI_H
+#define GDB_UI_H
 
 #include "gdbsupport/event-loop.h"
 #include "gdbsupport/intrusive_list.h"
@@ -229,4 +229,4 @@ ui_range all_uis ()
   return ui_range (ui_list);
 }
 
-#endif /* UI_H */
+#endif /* GDB_UI_H */
diff --git a/gdb/user-regs.h b/gdb/user-regs.h
index baa3581a0ba..67a28dd429e 100644
--- a/gdb/user-regs.h
+++ b/gdb/user-regs.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef USER_REGS_H
-#define USER_REGS_H
+#ifndef GDB_USER_REGS_H
+#define GDB_USER_REGS_H
 
 /* Implement both builtin, and architecture specific, per-frame user
    visible registers.
@@ -69,4 +69,4 @@ extern void user_reg_add_builtin (const char *name,
 extern void user_reg_add (struct gdbarch *gdbarch, const char *name, 
 			  user_reg_read_ftype *read, const void *baton);
 
-#endif
+#endif /* GDB_USER_REGS_H */
diff --git a/gdb/utils.h b/gdb/utils.h
index 96350890a97..2dc36f42ed1 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UTILS_H
-#define UTILS_H
+#ifndef GDB_UTILS_H
+#define GDB_UTILS_H
 
 #include "exceptions.h"
 #include "gdbsupport/array-view.h"
@@ -475,4 +475,4 @@ struct deferred_warnings final : public warning_hook_handler_type
   std::vector<string_file> m_warnings;
 };
 
-#endif /* UTILS_H */
+#endif /* GDB_UTILS_H */
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 4f194b77008..834e9d97ffd 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VALPRINT_H
-#define VALPRINT_H
+#ifndef GDB_VALPRINT_H
+#define GDB_VALPRINT_H
 
 #include "cli/cli-option.h"
 
@@ -337,4 +337,4 @@ extern void common_val_print_checked
    const struct value_print_options *options,
    const struct language_defn *language);
 
-#endif
+#endif /* GDB_VALPRINT_H */
diff --git a/gdb/value.h b/gdb/value.h
index 9d7e88d9433..8fc9550f11f 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (VALUE_H)
-#define VALUE_H 1
+#ifndef GDB_VALUE_H
+#define GDB_VALUE_H
 
 #include "frame.h"
 #include "extension.h"
@@ -1704,4 +1704,4 @@ void pseudo_to_concat_raw (const frame_info_ptr &next_frame,
 			   int raw_reg_1_num, int raw_reg_2_num,
 			   int raw_reg_3_num);
 
-#endif /* !defined (VALUE_H) */
+#endif /* GDB_VALUE_H */
diff --git a/gdb/varobj-iter.h b/gdb/varobj-iter.h
index 4254f8b549e..46e25e797c8 100644
--- a/gdb/varobj-iter.h
+++ b/gdb/varobj-iter.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAROBJ_ITER_H
-#define VAROBJ_ITER_H
+#ifndef GDB_VAROBJ_ITER_H
+#define GDB_VAROBJ_ITER_H
 
 /* A node or item of varobj, composed of the name and the value.  */
 
@@ -39,4 +39,4 @@ struct varobj_iter
   virtual std::unique_ptr<varobj_item> next () = 0;
 };
 
-#endif /* VAROBJ_ITER_H */
+#endif /* GDB_VAROBJ_ITER_H */
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 426c3b7d628..9d19f53fb3e 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAROBJ_H
-#define VAROBJ_H 1
+#ifndef GDB_VAROBJ_H
+#define GDB_VAROBJ_H
 
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -355,4 +355,4 @@ extern void varobj_restrict_range (const std::vector<varobj *> &children,
 
 extern bool varobj_default_is_path_expr_parent (const struct varobj *var);
 
-#endif /* VAROBJ_H */
+#endif /* GDB_VAROBJ_H */
diff --git a/gdb/vax-tdep.h b/gdb/vax-tdep.h
index 72b072d692d..fbc35d97c4e 100644
--- a/gdb/vax-tdep.h
+++ b/gdb/vax-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAX_TDEP_H
-#define VAX_TDEP_H
+#ifndef GDB_VAX_TDEP_H
+#define GDB_VAX_TDEP_H
 
 /* Register numbers of various important registers.  */
 
@@ -36,4 +36,4 @@ enum vax_regnum
 /* Number of machine registers.  */
 #define VAX_NUM_REGS 17
 
-#endif /* vax-tdep.h */
+#endif /* GDB_VAX_TDEP_H */
diff --git a/gdb/windows-nat.h b/gdb/windows-nat.h
index 3fbb1ea35df..b36e7f45512 100644
--- a/gdb/windows-nat.h
+++ b/gdb/windows-nat.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef WINDOWS_NAT_H
-#define WINDOWS_NAT_H
+#ifndef GDB_WINDOWS_NAT_H
+#define GDB_WINDOWS_NAT_H
 
 /* A pointer to a function that should return non-zero iff REGNUM
    corresponds to one of the segment registers.  */
@@ -36,4 +36,4 @@ int amd64_windows_segment_register_p (int regnum);
 extern const int amd64_mappings[];
 #endif
 
-#endif
+#endif /* GDB_WINDOWS_NAT_H */
diff --git a/gdb/windows-tdep.h b/gdb/windows-tdep.h
index f122f7aaa61..abb25331938 100644
--- a/gdb/windows-tdep.h
+++ b/gdb/windows-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef WINDOWS_TDEP_H
-#define WINDOWS_TDEP_H
+#ifndef GDB_WINDOWS_TDEP_H
+#define GDB_WINDOWS_TDEP_H
 
 #include "frame-unwind.h"
 
@@ -75,4 +75,4 @@ struct cygwin_sigwrapper_frame_unwind : public frame_unwind
   gdb::array_view<const gdb::array_view<const gdb_byte>> patterns_list;
 };
 
-#endif
+#endif /* GDB_WINDOWS_TDEP_H */
diff --git a/gdb/x86-bsd-nat.h b/gdb/x86-bsd-nat.h
index 7b1ba7a1f44..b1745448ece 100644
--- a/gdb/x86-bsd-nat.h
+++ b/gdb/x86-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_BSD_NAT_H
-#define X86_BSD_NAT_H
+#ifndef GDB_X86_BSD_NAT_H
+#define GDB_X86_BSD_NAT_H
 
 #include "x86-nat.h"
 
@@ -43,4 +43,4 @@ class x86bsd_nat_target : public BaseTarget
 };
 #endif /* HAVE_PT_GETDBREGS */
 
-#endif /* x86-bsd-nat.h */
+#endif /* GDB_X86_BSD_NAT_H */
diff --git a/gdb/x86-fbsd-nat.h b/gdb/x86-fbsd-nat.h
index a202e77c788..66f2b2f61b2 100644
--- a/gdb/x86-fbsd-nat.h
+++ b/gdb/x86-fbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_FBSD_NAT_H
-#define X86_FBSD_NAT_H
+#ifndef GDB_X86_FBSD_NAT_H
+#define GDB_X86_FBSD_NAT_H
 
 #include <sys/ptrace.h>
 
@@ -53,4 +53,4 @@ class x86_fbsd_nat_target : public x86bsd_nat_target<fbsd_nat_target>
 #endif
 };
 
-#endif /* x86-bsd-nat.h */
+#endif /* GDB_X86_FBSD_NAT_H */
diff --git a/gdb/x86-linux-nat.h b/gdb/x86-linux-nat.h
index 4efe5461847..3c2241bb0b6 100644
--- a/gdb/x86-linux-nat.h
+++ b/gdb/x86-linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_LINUX_NAT_H
-#define X86_LINUX_NAT_H 1
+#ifndef GDB_X86_LINUX_NAT_H
+#define GDB_X86_LINUX_NAT_H
 
 #include "gdb_proc_service.h"
 #include "linux-nat.h"
@@ -92,4 +92,4 @@ struct x86_linux_nat_target : public x86_nat_target<linux_nat_target>
 extern ps_err_e x86_linux_get_thread_area (pid_t pid, void *addr,
 					   unsigned int *base_addr);
 
-#endif
+#endif /* GDB_X86_LINUX_NAT_H */
diff --git a/gdb/x86-nat.h b/gdb/x86-nat.h
index f07cefa027d..1b8fdd38325 100644
--- a/gdb/x86-nat.h
+++ b/gdb/x86-nat.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_NAT_H
-#define X86_NAT_H 1
+#ifndef GDB_X86_NAT_H
+#define GDB_X86_NAT_H
 
 #include "breakpoint.h"
 #include "nat/x86-dregs.h"
@@ -114,4 +114,4 @@ struct x86_nat_target : public BaseTarget
   { return x86_stopped_by_hw_breakpoint (); }
 };
 
-#endif /* X86_NAT_H */
+#endif /* GDB_X86_NAT_H */
diff --git a/gdb/x86-tdep.h b/gdb/x86-tdep.h
index 7ab47814d41..2b5853adb8a 100644
--- a/gdb/x86-tdep.h
+++ b/gdb/x86-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_TDEP_H
-#define X86_TDEP_H
+#ifndef GDB_X86_TDEP_H
+#define GDB_X86_TDEP_H
 
 /* Checks whether PC lies in an indirect branch thunk using registers
    REGISTER_NAMES[LO] (inclusive) to REGISTER_NAMES[HI] (exclusive).  */
@@ -27,4 +27,4 @@ extern bool x86_in_indirect_branch_thunk (CORE_ADDR pc,
 					  const char * const *register_names,
 					  int lo, int hi);
 
-#endif /* x86-tdep.h */
+#endif /* GDB_X86_TDEP_H */
diff --git a/gdb/xcoffread.h b/gdb/xcoffread.h
index 8bc729e3dff..7528dec4a6c 100644
--- a/gdb/xcoffread.h
+++ b/gdb/xcoffread.h
@@ -16,11 +16,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XCOFFREAD_H
-#define XCOFFREAD_H
+#ifndef GDB_XCOFFREAD_H
+#define GDB_XCOFFREAD_H
 
 extern CORE_ADDR xcoff_get_toc_offset (struct objfile *);
 
 extern int xcoff_get_n_import_files (bfd *abfd);
 
-#endif /* XCOFFREAD_H */
+#endif /* GDB_XCOFFREAD_H */
diff --git a/gdb/xml-builtin.h b/gdb/xml-builtin.h
index 417771ea4e9..463e0fb16e0 100644
--- a/gdb/xml-builtin.h
+++ b/gdb/xml-builtin.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_BUILTIN_H
-#define XML_BUILTIN_H
+#ifndef GDB_XML_BUILTIN_H
+#define GDB_XML_BUILTIN_H
 
 /* The text of compiled-in XML documents, from xml-builtin.c
    (generated).  */
 
 extern const char *const xml_builtin[][2];
 
-#endif /* XML_BUILTIN_H */
+#endif /* GDB_XML_BUILTIN_H */
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index b9bac7a10c2..f2860a20d6b 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef XML_SUPPORT_H
-#define XML_SUPPORT_H
+#ifndef GDB_XML_SUPPORT_H
+#define GDB_XML_SUPPORT_H
 
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/xml-utils.h"
@@ -233,4 +233,4 @@ ULONGEST gdb_xml_parse_ulongest (struct gdb_xml_parser *parser,
 extern std::optional<gdb::char_vector> xml_fetch_content_from_file
     (const char *filename, const char *dirname);
 
-#endif
+#endif /* GDB_XML_SUPPORT_H */
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index 60cfb71ada2..579805d9394 100644
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_SYSCALL_H
-#define XML_SYSCALL_H 1
+#ifndef GDB_XML_SYSCALL_H
+#define GDB_XML_SYSCALL_H
 
 /* Function used to set the name of the file which contains
    information about the system calls present in the current
@@ -66,4 +66,4 @@ bool get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
 
 const char **get_syscall_group_names (struct gdbarch *gdbarch);
 
-#endif /* XML_SYSCALL_H */
+#endif /* GDB_XML_SYSCALL_H */
diff --git a/gdb/xml-tdesc.h b/gdb/xml-tdesc.h
index cd6e79cc24f..ec71c682f86 100644
--- a/gdb/xml-tdesc.h
+++ b/gdb/xml-tdesc.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_TDESC_H
-#define XML_TDESC_H
+#ifndef GDB_XML_TDESC_H
+#define GDB_XML_TDESC_H
 
 #include <optional>
 #include <string>
@@ -49,4 +49,4 @@ std::optional<std::string> target_fetch_description_xml (target_ops *ops);
 
 const struct target_desc *string_read_description_xml (const char *xml);
 
-#endif /* XML_TDESC_H */
+#endif /* GDB_XML_TDESC_H */
diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h
index b76ed137380..832b4fbf33a 100644
--- a/gdb/xtensa-tdep.h
+++ b/gdb/xtensa-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XTENSA_TDEP_H
-#define XTENSA_TDEP_H
+#ifndef GDB_XTENSA_TDEP_H
+#define GDB_XTENSA_TDEP_H
 
 #include "arch/xtensa.h"
 #include "gdbarch.h"
@@ -249,4 +249,4 @@ struct xtensa_gdbarch_tdep : gdbarch_tdep_base
    data structure to their corresponding register in the AR register 
    file (see xtensa-tdep.c).  */
 
-#endif /* XTENSA_TDEP_H */
+#endif /* GDB_XTENSA_TDEP_H */
diff --git a/gdb/yy-remap.h b/gdb/yy-remap.h
index d52a59d11b9..9a6c399b855 100644
--- a/gdb/yy-remap.h
+++ b/gdb/yy-remap.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef YY_REMAP_H
-#define YY_REMAP_H
+#ifndef GDB_YY_REMAP_H
+#define GDB_YY_REMAP_H
 
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
    etc), as well as gratuitiously global symbol names, so we can have
@@ -97,4 +97,4 @@
 # define YYFPRINTF parser_fprintf
 #endif
 
-#endif /* YY_REMAP_H */
+#endif /* GDB_YY_REMAP_H */
diff --git a/gdb/z80-tdep.h b/gdb/z80-tdep.h
index 4b36024d1f0..19a7d046f7a 100644
--- a/gdb/z80-tdep.h
+++ b/gdb/z80-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef Z80_TDEP_H
-#define Z80_TDEP_H
+#ifndef GDB_Z80_TDEP_H
+#define GDB_Z80_TDEP_H
 
 /* Register pair constants
    Order optimized for gdb-stub implementation
@@ -49,4 +49,4 @@ enum z80_regnum
 #define EZ80_NUM_REGS	(Z80_NUM_REGS + 1)
 #define EZ80_REG_BYTES	(EZ80_NUM_REGS*3)
 
-#endif /* z80-tdep.h */
+#endif /* GDB_Z80_TDEP_H */
diff --git a/gdbserver/linux-aarch32-tdesc.h b/gdbserver/linux-aarch32-tdesc.h
index ff1c45fa1c1..173eac24389 100644
--- a/gdbserver/linux-aarch32-tdesc.h
+++ b/gdbserver/linux-aarch32-tdesc.h
@@ -26,4 +26,4 @@ const target_desc * aarch32_linux_read_description ();
 
 bool is_aarch32_linux_description (const target_desc *tdesc);
 
-#endif /* linux-aarch32-tdesc.h.  */
+#endif /* GDBSERVER_LINUX_AARCH32_TDESC_H */
diff --git a/gdbserver/linux-arm-tdesc.h b/gdbserver/linux-arm-tdesc.h
index 76a30c3c73a..bf12c8f5b68 100644
--- a/gdbserver/linux-arm-tdesc.h
+++ b/gdbserver/linux-arm-tdesc.h
@@ -28,4 +28,4 @@ const target_desc * arm_linux_read_description (arm_fp_type fp_type);
 
 arm_fp_type arm_linux_get_tdesc_fp_type (const target_desc *tdesc);
 
-#endif /* linux-arm-tdesc.h.  */
+#endif /* GDBSERVER_LINUX_ARM_TDESC_H */
diff --git a/gdbsupport/agent.h b/gdbsupport/agent.h
index e5a1fed84b9..305ed70fff2 100644
--- a/gdbsupport/agent.h
+++ b/gdbsupport/agent.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_AGENT_H
-#define COMMON_AGENT_H
+#ifndef GDBSUPPORT_AGENT_H
+#define GDBSUPPORT_AGENT_H
 
 #include "gdbsupport/preprocessor.h"
 
@@ -65,4 +65,4 @@ bool agent_capability_check (enum agent_capa);
 
 void agent_capability_invalidate (void);
 
-#endif /* COMMON_AGENT_H */
+#endif /* GDBSUPPORT_AGENT_H */
diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h
index 93842a40ec1..a61e09e882c 100644
--- a/gdbsupport/array-view.h
+++ b/gdbsupport/array-view.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ARRAY_VIEW_H
-#define COMMON_ARRAY_VIEW_H
+#ifndef GDBSUPPORT_ARRAY_VIEW_H
+#define GDBSUPPORT_ARRAY_VIEW_H
 
 #include "traits.h"
 #include <algorithm>
@@ -294,4 +294,4 @@ make_array_view (U *array, size_t size) noexcept
 
 } /* namespace gdb */
 
-#endif
+#endif /* GDBSUPPORT_ARRAY_VIEW_H */
diff --git a/gdbsupport/break-common.h b/gdbsupport/break-common.h
index 95ab3e290ba..1202231be0c 100644
--- a/gdbsupport/break-common.h
+++ b/gdbsupport/break-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BREAK_COMMON_H
-#define COMMON_BREAK_COMMON_H
+#ifndef GDBSUPPORT_BREAK_COMMON_H
+#define GDBSUPPORT_BREAK_COMMON_H
 
 enum target_hw_bp_type
   {
@@ -28,4 +28,4 @@ enum target_hw_bp_type
     hw_execute = 3		/* Execute HW breakpoint */
   };
 
-#endif /* COMMON_BREAK_COMMON_H */
+#endif /* GDBSUPPORT_BREAK_COMMON_H */
diff --git a/gdbsupport/btrace-common.h b/gdbsupport/btrace-common.h
index bf57bc1615e..1888b242f70 100644
--- a/gdbsupport/btrace-common.h
+++ b/gdbsupport/btrace-common.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BTRACE_COMMON_H
-#define COMMON_BTRACE_COMMON_H
+#ifndef GDBSUPPORT_BTRACE_COMMON_H
+#define GDBSUPPORT_BTRACE_COMMON_H
 
 /* Branch tracing (btrace) is a per-thread control-flow execution trace of the
    inferior.  For presentation purposes, the branch trace is represented as a
@@ -276,4 +276,4 @@ extern const char *btrace_format_short_string (enum btrace_format format);
 extern int btrace_data_append (struct btrace_data *dst,
 			       const struct btrace_data *src);
 
-#endif /* COMMON_BTRACE_COMMON_H */
+#endif /* GDBSUPPORT_BTRACE_COMMON_H */
diff --git a/gdbsupport/byte-vector.h b/gdbsupport/byte-vector.h
index 54f4cc2edf2..0586d40016e 100644
--- a/gdbsupport/byte-vector.h
+++ b/gdbsupport/byte-vector.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BYTE_VECTOR_H
-#define COMMON_BYTE_VECTOR_H
+#ifndef GDBSUPPORT_BYTE_VECTOR_H
+#define GDBSUPPORT_BYTE_VECTOR_H
 
 #include "gdbsupport/def-vector.h"
 
@@ -60,4 +60,4 @@ using char_vector = gdb::def_vector<char>;
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEF_VECTOR_H */
+#endif /* GDBSUPPORT_BYTE_VECTOR_H */
diff --git a/gdbsupport/cleanups.h b/gdbsupport/cleanups.h
index 985cf81ff7d..12b7774763c 100644
--- a/gdbsupport/cleanups.h
+++ b/gdbsupport/cleanups.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_CLEANUPS_H
-#define COMMON_CLEANUPS_H
+#ifndef GDBSUPPORT_CLEANUPS_H
+#define GDBSUPPORT_CLEANUPS_H
 
 #include <functional>
 
@@ -27,4 +27,4 @@ extern void add_final_cleanup (std::function<void ()> &&func);
 /* Run all the registered functions.  */
 extern void do_final_cleanups ();
 
-#endif /* COMMON_CLEANUPS_H */
+#endif /* GDBSUPPORT_CLEANUPS_H */
diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h
index b41d6a401cc..6c793dc33d4 100644
--- a/gdbsupport/common-debug.h
+++ b/gdbsupport/common-debug.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_DEBUG_H
-#define COMMON_COMMON_DEBUG_H
+#ifndef GDBSUPPORT_COMMON_DEBUG_H
+#define GDBSUPPORT_COMMON_DEBUG_H
 
 #include <optional>
 #include "gdbsupport/preprocessor.h"
@@ -271,4 +271,4 @@ make_scoped_debug_start_end (PT &&pred, const char *module, const char *func,
 				   __func__, "enter", "exit",	\
 				   nullptr)
 
-#endif /* COMMON_COMMON_DEBUG_H */
+#endif /* GDBSUPPORT_COMMON_DEBUG_H */
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index 6120719480b..07315956514 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_DEFS_H
-#define COMMON_COMMON_DEFS_H
+#ifndef GDBSUPPORT_COMMON_DEFS_H
+#define GDBSUPPORT_COMMON_DEFS_H
 
 #include <gdbsupport/config.h>
 
@@ -217,4 +217,4 @@
 #define HAVE_USEFUL_SBRK 1
 #endif
 
-#endif /* COMMON_COMMON_DEFS_H */
+#endif /* GDBSUPPORT_COMMON_DEFS_H */
diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h
index ffc02d2107f..124c41d1acd 100644
--- a/gdbsupport/common-exceptions.h
+++ b/gdbsupport/common-exceptions.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_EXCEPTIONS_H
-#define COMMON_COMMON_EXCEPTIONS_H
+#ifndef GDBSUPPORT_COMMON_EXCEPTIONS_H
+#define GDBSUPPORT_COMMON_EXCEPTIONS_H
 
 #include <setjmp.h>
 #include <new>
@@ -359,4 +359,4 @@ extern void throw_quit (const char *fmt, ...)
 extern void throw_forced_quit (const char *fmt, ...)
      ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
 
-#endif /* COMMON_COMMON_EXCEPTIONS_H */
+#endif /* GDBSUPPORT_COMMON_EXCEPTIONS_H */
diff --git a/gdbsupport/common-gdbthread.h b/gdbsupport/common-gdbthread.h
index d149f8eed41..289cc8f1b30 100644
--- a/gdbsupport/common-gdbthread.h
+++ b/gdbsupport/common-gdbthread.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_GDBTHREAD_H
-#define COMMON_COMMON_GDBTHREAD_H
+#ifndef GDBSUPPORT_COMMON_GDBTHREAD_H
+#define GDBSUPPORT_COMMON_GDBTHREAD_H
 
 struct process_stratum_target;
 
@@ -25,4 +25,4 @@ struct process_stratum_target;
 extern void switch_to_thread (process_stratum_target *proc_target,
 			      ptid_t ptid);
 
-#endif /* COMMON_COMMON_GDBTHREAD_H */
+#endif /* GDBSUPPORT_COMMON_GDBTHREAD_H */
diff --git a/gdbsupport/common-inferior.h b/gdbsupport/common-inferior.h
index bc6afd65f2b..299c159678b 100644
--- a/gdbsupport/common-inferior.h
+++ b/gdbsupport/common-inferior.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_INFERIOR_H
-#define COMMON_COMMON_INFERIOR_H
+#ifndef GDBSUPPORT_COMMON_INFERIOR_H
+#define GDBSUPPORT_COMMON_INFERIOR_H
 
 #include "gdbsupport/array-view.h"
 
@@ -62,4 +62,4 @@ extern bool startup_with_shell;
 extern std::string
 construct_inferior_arguments (gdb::array_view<char * const>);
 
-#endif /* COMMON_COMMON_INFERIOR_H */
+#endif /* GDBSUPPORT_COMMON_INFERIOR_H */
diff --git a/gdbsupport/common-regcache.h b/gdbsupport/common-regcache.h
index f8704c16939..caf4662e7e5 100644
--- a/gdbsupport/common-regcache.h
+++ b/gdbsupport/common-regcache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_REGCACHE_H
-#define COMMON_COMMON_REGCACHE_H
+#ifndef GDBSUPPORT_COMMON_REGCACHE_H
+#define GDBSUPPORT_COMMON_REGCACHE_H
 
 struct reg_buffer_common;
 
@@ -120,4 +120,4 @@ struct reg_buffer_common
   virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0;
 };
 
-#endif /* COMMON_COMMON_REGCACHE_H */
+#endif /* GDBSUPPORT_COMMON_REGCACHE_H */
diff --git a/gdbsupport/common-types.h b/gdbsupport/common-types.h
index 19d3f49ca0f..10d5f38ae4a 100644
--- a/gdbsupport/common-types.h
+++ b/gdbsupport/common-types.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_TYPES_H
-#define COMMON_COMMON_TYPES_H
+#ifndef GDBSUPPORT_COMMON_TYPES_H
+#define GDBSUPPORT_COMMON_TYPES_H
 
 #include <inttypes.h>
 
@@ -53,4 +53,4 @@ typedef uint64_t ULONGEST;
 
 enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 };
 
-#endif /* COMMON_COMMON_TYPES_H */
+#endif /* GDBSUPPORT_COMMON_TYPES_H */
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 23cd40c0207..42c129b643c 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_UTILS_H
-#define COMMON_COMMON_UTILS_H
+#ifndef GDBSUPPORT_COMMON_UTILS_H
+#define GDBSUPPORT_COMMON_UTILS_H
 
 #include <string>
 #include <vector>
@@ -242,4 +242,4 @@ struct string_view_hash
 
 } /* namespace gdb */
 
-#endif /* COMMON_COMMON_UTILS_H */
+#endif /* GDBSUPPORT_COMMON_UTILS_H */
diff --git a/gdbsupport/def-vector.h b/gdbsupport/def-vector.h
index b9aa663c688..3db6a2fedc9 100644
--- a/gdbsupport/def-vector.h
+++ b/gdbsupport/def-vector.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_DEF_VECTOR_H
-#define COMMON_DEF_VECTOR_H
+#ifndef GDBSUPPORT_DEF_VECTOR_H
+#define GDBSUPPORT_DEF_VECTOR_H
 
 #include <vector>
 #include "gdbsupport/default-init-alloc.h"
@@ -33,4 +33,4 @@ template<typename T> using def_vector
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEF_VECTOR_H */
+#endif /* GDBSUPPORT_DEF_VECTOR_H */
diff --git a/gdbsupport/default-init-alloc.h b/gdbsupport/default-init-alloc.h
index 5ed9715b64c..e84110f128a 100644
--- a/gdbsupport/default-init-alloc.h
+++ b/gdbsupport/default-init-alloc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_DEFAULT_INIT_ALLOC_H
-#define COMMON_DEFAULT_INIT_ALLOC_H
+#ifndef GDBSUPPORT_DEFAULT_INIT_ALLOC_H
+#define GDBSUPPORT_DEFAULT_INIT_ALLOC_H
 
 #if __cplusplus >= 202002L
 #include <memory_resource>
@@ -75,4 +75,4 @@ class default_init_allocator : public A
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEFAULT_INIT_ALLOC_H */
+#endif /* GDBSUPPORT_DEFAULT_INIT_ALLOC_H */
diff --git a/gdbsupport/enum-flags.h b/gdbsupport/enum-flags.h
index 50780043477..b2858b83efe 100644
--- a/gdbsupport/enum-flags.h
+++ b/gdbsupport/enum-flags.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ENUM_FLAGS_H
-#define COMMON_ENUM_FLAGS_H
+#ifndef GDBSUPPORT_ENUM_FLAGS_H
+#define GDBSUPPORT_ENUM_FLAGS_H
 
 #include "traits.h"
 
@@ -493,4 +493,4 @@ enum_flags<E>::to_string (const string_mapping (&mapping)[N]) const
 
 #endif /* __cplusplus */
 
-#endif /* COMMON_ENUM_FLAGS_H */
+#endif /* GDBSUPPORT_ENUM_FLAGS_H */
diff --git a/gdbsupport/environ.h b/gdbsupport/environ.h
index e46050b0350..6ac9f75d94e 100644
--- a/gdbsupport/environ.h
+++ b/gdbsupport/environ.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ENVIRON_H
-#define COMMON_ENVIRON_H
+#ifndef GDBSUPPORT_ENVIRON_H
+#define GDBSUPPORT_ENVIRON_H
 
 #include <vector>
 #include <set>
@@ -100,4 +100,4 @@ class gdb_environ
   std::set<std::string> m_user_unset_env;
 };
 
-#endif /* COMMON_ENVIRON_H */
+#endif /* GDBSUPPORT_ENVIRON_H */
diff --git a/gdbsupport/errors.h b/gdbsupport/errors.h
index d8daed0f5f2..4570221f879 100644
--- a/gdbsupport/errors.h
+++ b/gdbsupport/errors.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ERRORS_H
-#define COMMON_ERRORS_H
+#ifndef GDBSUPPORT_ERRORS_H
+#define GDBSUPPORT_ERRORS_H
 
 /* A problem was detected, but the requested operation can still
    proceed.  A warning message is constructed using a printf- or
@@ -129,4 +129,4 @@ extern void throw_winerror_with_name (const char *string, ULONGEST err)
 
 #endif /* USE_WIN32API */
 
-#endif /* COMMON_ERRORS_H */
+#endif /* GDBSUPPORT_ERRORS_H */
diff --git a/gdbsupport/event-loop.h b/gdbsupport/event-loop.h
index 9155658e8f9..80f471066c8 100644
--- a/gdbsupport/event-loop.h
+++ b/gdbsupport/event-loop.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EVENT_LOOP_H
-#define EVENT_LOOP_H
+#ifndef GDBSUPPORT_EVENT_LOOP_H
+#define GDBSUPPORT_EVENT_LOOP_H
 
 /* An event loop listens for events from multiple event sources.  When
    an event arrives, it is queued and processed by calling the
@@ -145,4 +145,4 @@ extern debug_event_loop_kind debug_event_loop;
     } \
   while (0)
 
-#endif /* EVENT_LOOP_H */
+#endif /* GDBSUPPORT_EVENT_LOOP_H */
diff --git a/gdbsupport/event-pipe.h b/gdbsupport/event-pipe.h
index fb5dd3a8833..7262403e267 100644
--- a/gdbsupport/event-pipe.h
+++ b/gdbsupport/event-pipe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_EVENT_PIPE_H
-#define COMMON_EVENT_PIPE_H
+#ifndef GDBSUPPORT_EVENT_PIPE_H
+#define GDBSUPPORT_EVENT_PIPE_H
 
 /* An event pipe used as a waitable file in the event loop in place of
    some other event associated with a signal.  The handler for the
@@ -57,4 +57,4 @@ class event_pipe
   int m_fds[2] = { -1, -1 };
 };
 
-#endif /* COMMON_EVENT_PIPE_H */
+#endif /* GDBSUPPORT_EVENT_PIPE_H */
diff --git a/gdbsupport/fileio.h b/gdbsupport/fileio.h
index 2e7469d771b..7e4c361d14f 100644
--- a/gdbsupport/fileio.h
+++ b/gdbsupport/fileio.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILEIO_H
-#define COMMON_FILEIO_H
+#ifndef GDBSUPPORT_FILEIO_H
+#define GDBSUPPORT_FILEIO_H
 
 #include <sys/stat.h>
 
@@ -186,4 +186,4 @@ host_to_fileio_time (time_t num, fio_time_t fnum)
 
 extern void host_to_fileio_stat (struct stat *st, struct fio_stat *fst);
 
-#endif /* COMMON_FILEIO_H */
+#endif /* GDBSUPPORT_FILEIO_H */
diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h
index e2ee141d46f..549987bc29c 100644
--- a/gdbsupport/filestuff.h
+++ b/gdbsupport/filestuff.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILESTUFF_H
-#define COMMON_FILESTUFF_H
+#ifndef GDBSUPPORT_FILESTUFF_H
+#define GDBSUPPORT_FILESTUFF_H
 
 #include <dirent.h>
 #include <fcntl.h>
@@ -137,4 +137,4 @@ extern std::optional<std::string> read_text_file_to_string (const char *path);
 
 extern std::string read_remainder_of_file (FILE *file);
 
-#endif /* COMMON_FILESTUFF_H */
+#endif /* GDBSUPPORT_FILESTUFF_H */
diff --git a/gdbsupport/filtered-iterator.h b/gdbsupport/filtered-iterator.h
index 12e5e6cd577..f801f9614da 100644
--- a/gdbsupport/filtered-iterator.h
+++ b/gdbsupport/filtered-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILTERED_ITERATOR_H
-#define COMMON_FILTERED_ITERATOR_H
+#ifndef GDBSUPPORT_FILTERED_ITERATOR_H
+#define GDBSUPPORT_FILTERED_ITERATOR_H
 
 #include <type_traits>
 
@@ -89,4 +89,4 @@ class filtered_iterator
   BaseIterator m_end {};
 };
 
-#endif /* COMMON_FILTERED_ITERATOR_H */
+#endif /* GDBSUPPORT_FILTERED_ITERATOR_H */
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 68504b4475c..b1f0c46d4c2 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FORMAT_H
-#define COMMON_FORMAT_H
+#ifndef GDBSUPPORT_FORMAT_H
+#define GDBSUPPORT_FORMAT_H
 
 #include <string_view>
 
@@ -101,4 +101,4 @@ class format_pieces
   gdb::unique_xmalloc_ptr<char> m_storage;
 };
 
-#endif /* COMMON_FORMAT_H */
+#endif /* GDBSUPPORT_FORMAT_H */
diff --git a/gdbsupport/forward-scope-exit.h b/gdbsupport/forward-scope-exit.h
index 6dd22722595..d4a3fc00cf8 100644
--- a/gdbsupport/forward-scope-exit.h
+++ b/gdbsupport/forward-scope-exit.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FORWARD_SCOPE_EXIT_H
-#define COMMON_FORWARD_SCOPE_EXIT_H
+#ifndef GDBSUPPORT_FORWARD_SCOPE_EXIT_H
+#define GDBSUPPORT_FORWARD_SCOPE_EXIT_H
 
 #include "gdbsupport/scope-exit.h"
 #include <functional>
@@ -120,4 +120,4 @@ class forward_scope_exit<Function, function, Res (Args...)>
 #define FORWARD_SCOPE_EXIT(FUNC) \
   detail::forward_scope_exit<decltype (FUNC), FUNC, decltype (FUNC)>
 
-#endif /* COMMON_FORWARD_SCOPE_EXIT_H */
+#endif /* GDBSUPPORT_FORWARD_SCOPE_EXIT_H */
diff --git a/gdbsupport/function-view.h b/gdbsupport/function-view.h
index 9d852c2a378..f8262068174 100644
--- a/gdbsupport/function-view.h
+++ b/gdbsupport/function-view.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FUNCTION_VIEW_H
-#define COMMON_FUNCTION_VIEW_H
+#ifndef GDBSUPPORT_FUNCTION_VIEW_H
+#define GDBSUPPORT_FUNCTION_VIEW_H
 
 /* function_view is a polymorphic type-erasing wrapper class that
    encapsulates a non-owning reference to arbitrary callable objects.
@@ -448,4 +448,4 @@ auto make_function_view (Callable &&callable)
 
 } /* namespace gdb */
 
-#endif
+#endif /* GDBSUPPORT_FUNCTION_VIEW_H */
diff --git a/gdbsupport/gdb-checked-static-cast.h b/gdbsupport/gdb-checked-static-cast.h
index 97843fab225..e8909b9206f 100644
--- a/gdbsupport/gdb-checked-static-cast.h
+++ b/gdbsupport/gdb-checked-static-cast.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_CHECKED_STATIC_CAST_H
-#define COMMON_GDB_CHECKED_STATIC_CAST_H
+#ifndef GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H
+#define GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H
 
 #include "gdbsupport/traits.h"
 
@@ -80,4 +80,4 @@ checked_static_cast (V &v)
 
 }
 
-#endif /* COMMON_GDB_CHECKED_STATIC_CAST_H */
+#endif /* GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H */
diff --git a/gdbsupport/gdb-dlfcn.h b/gdbsupport/gdb-dlfcn.h
index 24481d94e5c..654db794638 100644
--- a/gdbsupport/gdb-dlfcn.h
+++ b/gdbsupport/gdb-dlfcn.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DLFCN_H
-#define GDB_DLFCN_H
+#ifndef GDBSUPPORT_GDB_DLFCN_H
+#define GDBSUPPORT_GDB_DLFCN_H
 
 /* A deleter that closes an open dynamic library.  */
 
@@ -48,4 +48,4 @@ void *gdb_dlsym (const gdb_dlhandle_up &handle, const char *symbol);
 
 int is_dl_available(void);
 
-#endif /* GDB_DLFCN_H */
+#endif /* GDBSUPPORT_GDB_DLFCN_H */
diff --git a/gdbsupport/gdb-safe-ctype.h b/gdbsupport/gdb-safe-ctype.h
index a91e54a3e65..f8968ef7e7c 100644
--- a/gdbsupport/gdb-safe-ctype.h
+++ b/gdbsupport/gdb-safe-ctype.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_SAFE_CTYPE_H
-#define GDB_SAFE_CTYPE_H
+#ifndef GDBSUPPORT_GDB_SAFE_CTYPE_H
+#define GDBSUPPORT_GDB_SAFE_CTYPE_H
 
 /* After safe-ctype.h is included, we can no longer use the host's
    ctype routines.  Trying to do so results in compile errors.  Code
@@ -46,4 +46,4 @@ gdb_isprint (int ch)
 #include <locale>
 #include "safe-ctype.h"
 
-#endif
+#endif /* GDBSUPPORT_GDB_SAFE_CTYPE_H */
diff --git a/gdbsupport/gdb_assert.h b/gdbsupport/gdb_assert.h
index 2b5e6557424..dd0e1e2286e 100644
--- a/gdbsupport/gdb_assert.h
+++ b/gdbsupport/gdb_assert.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_ASSERT_H
-#define COMMON_GDB_ASSERT_H
+#ifndef GDBSUPPORT_GDB_ASSERT_H
+#define GDBSUPPORT_GDB_ASSERT_H
 
 #include "errors.h"
 
@@ -43,4 +43,4 @@
   internal_error_loc (__FILE__, __LINE__, _("%s: " message), __func__, \
 		      ##__VA_ARGS__)
 
-#endif /* COMMON_GDB_ASSERT_H */
+#endif /* GDBSUPPORT_GDB_ASSERT_H */
diff --git a/gdbsupport/gdb_file.h b/gdbsupport/gdb_file.h
index 645ecb9f75c..41bbbbc51b1 100644
--- a/gdbsupport/gdb_file.h
+++ b/gdbsupport/gdb_file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDBSUPPORT_GDB_FILE
-#define GDBSUPPORT_GDB_FILE
+#ifndef GDBSUPPORT_GDB_FILE_H
+#define GDBSUPPORT_GDB_FILE_H
 
 #include <memory>
 #include <stdio.h>
@@ -34,4 +34,4 @@ struct gdb_file_deleter
 
 typedef std::unique_ptr<FILE, gdb_file_deleter> gdb_file_up;
 
-#endif
+#endif /* GDBSUPPORT_GDB_FILE_H */
diff --git a/gdbsupport/gdb_locale.h b/gdbsupport/gdb_locale.h
index 58524857879..dcdb064a917 100644
--- a/gdbsupport/gdb_locale.h
+++ b/gdbsupport/gdb_locale.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_LOCALE_H
-#define COMMON_GDB_LOCALE_H
+#ifndef GDBSUPPORT_GDB_LOCALE_H
+#define GDBSUPPORT_GDB_LOCALE_H
 
 #ifdef HAVE_LOCALE_H
 # include <locale.h>
@@ -40,4 +40,4 @@
 #include <langinfo.h>
 #endif
 
-#endif /* COMMON_GDB_LOCALE_H */
+#endif /* GDBSUPPORT_GDB_LOCALE_H */
diff --git a/gdbsupport/gdb_obstack.h b/gdbsupport/gdb_obstack.h
index 7b3bb05bc00..d40182441f8 100644
--- a/gdbsupport/gdb_obstack.h
+++ b/gdbsupport/gdb_obstack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDB_OBSTACK_H)
-#define GDB_OBSTACK_H 1
+#ifndef GDBSUPPORT_GDB_OBSTACK_H
+#define GDBSUPPORT_GDB_OBSTACK_H
 
 #include "obstack.h"
 
@@ -157,4 +157,4 @@ struct allocate_on_obstack
   void operator delete[] (void *memory) {}
 };
 
-#endif
+#endif /* GDBSUPPORT_GDB_OBSTACK_H */
diff --git a/gdbsupport/gdb_proc_service.h b/gdbsupport/gdb_proc_service.h
index 52f77a8a5c5..0009702b978 100644
--- a/gdbsupport/gdb_proc_service.h
+++ b/gdbsupport/gdb_proc_service.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_PROC_SERVICE_H
-#define COMMON_GDB_PROC_SERVICE_H
+#ifndef GDBSUPPORT_GDB_PROC_SERVICE_H
+#define GDBSUPPORT_GDB_PROC_SERVICE_H
 
 #include <sys/types.h>
 
@@ -199,4 +199,4 @@ PS_EXPORT (ps_lsetxregs);
 PS_EXPORT (ps_plog);
 #endif
 
-#endif /* COMMON_GDB_PROC_SERVICE_H */
+#endif /* GDBSUPPORT_GDB_PROC_SERVICE_H */
diff --git a/gdbsupport/gdb_ref_ptr.h b/gdbsupport/gdb_ref_ptr.h
index 8a90cb10b05..df2b3d80815 100644
--- a/gdbsupport/gdb_ref_ptr.h
+++ b/gdbsupport/gdb_ref_ptr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_REF_PTR_H
-#define COMMON_GDB_REF_PTR_H
+#ifndef GDBSUPPORT_GDB_REF_PTR_H
+#define GDBSUPPORT_GDB_REF_PTR_H
 
 #include <cstddef>
 
@@ -225,4 +225,4 @@ inline bool operator!= (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
 
 }
 
-#endif /* COMMON_GDB_REF_PTR_H */
+#endif /* GDBSUPPORT_GDB_REF_PTR_H */
diff --git a/gdbsupport/gdb_regex.h b/gdbsupport/gdb_regex.h
index aeb1bb922a9..76264e5a0c9 100644
--- a/gdbsupport/gdb_regex.h
+++ b/gdbsupport/gdb_regex.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_REGEX_H
-#define GDB_REGEX_H 1
+#ifndef GDBSUPPORT_GDB_REGEX_H
+#define GDBSUPPORT_GDB_REGEX_H
 
 # include "xregex.h"
 
@@ -54,4 +54,4 @@ class compiled_regex
   regex_t m_pattern;
 };
 
-#endif /* not GDB_REGEX_H */
+#endif /* GDBSUPPORT_GDB_REGEX_H */
diff --git a/gdbsupport/gdb_select.h b/gdbsupport/gdb_select.h
index 9f7350a904a..b229a25478c 100644
--- a/gdbsupport/gdb_select.h
+++ b/gdbsupport/gdb_select.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(GDB_SELECT_H)
-#define GDB_SELECT_H
+#ifndef GDBSUPPORT_GDB_SELECT_H
+#define GDBSUPPORT_GDB_SELECT_H
 
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
@@ -48,4 +48,4 @@ extern int interruptible_select (int n,
 				 fd_set *exceptfds,
 				 struct timeval *timeout);
 
-#endif /* !defined(GDB_SELECT_H) */
+#endif /* GDBSUPPORT_GDB_SELECT_H */
diff --git a/gdbsupport/gdb_setjmp.h b/gdbsupport/gdb_setjmp.h
index e994226cbea..2482990671d 100644
--- a/gdbsupport/gdb_setjmp.h
+++ b/gdbsupport/gdb_setjmp.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SETJMP_H
-#define COMMON_GDB_SETJMP_H
+#ifndef GDBSUPPORT_GDB_SETJMP_H
+#define GDBSUPPORT_GDB_SETJMP_H
 
 #include <setjmp.h>
 
@@ -33,4 +33,4 @@
 #define SIGLONGJMP(buf,val)	longjmp((buf), (val))
 #endif
 
-#endif /* COMMON_GDB_SETJMP_H */
+#endif /* GDBSUPPORT_GDB_SETJMP_H */
diff --git a/gdbsupport/gdb_signals.h b/gdbsupport/gdb_signals.h
index 7a71f0d8f99..2f9237aea46 100644
--- a/gdbsupport/gdb_signals.h
+++ b/gdbsupport/gdb_signals.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SIGNALS_H
-#define COMMON_GDB_SIGNALS_H
+#ifndef GDBSUPPORT_GDB_SIGNALS_H
+#define GDBSUPPORT_GDB_SIGNALS_H
 
 #include "gdb/signals.h"
 
@@ -55,4 +55,4 @@ extern const char *gdb_signal_to_name (enum gdb_signal);
 /* Given a name (SIGHUP, etc.), return its signal.  */
 enum gdb_signal gdb_signal_from_name (const char *);
 
-#endif /* COMMON_GDB_SIGNALS_H */
+#endif /* GDBSUPPORT_GDB_SIGNALS_H */
diff --git a/gdbsupport/gdb_splay_tree.h b/gdbsupport/gdb_splay_tree.h
index 873ad8e27f3..05be2f1dc4e 100644
--- a/gdbsupport/gdb_splay_tree.h
+++ b/gdbsupport/gdb_splay_tree.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SPLAY_TREE_H
-#define COMMON_GDB_SPLAY_TREE_H
+#ifndef GDBSUPPORT_GDB_SPLAY_TREE_H
+#define GDBSUPPORT_GDB_SPLAY_TREE_H
 
 #include "splay-tree.h"
 
@@ -39,4 +39,4 @@ struct splay_tree_deleter
 typedef std::unique_ptr<splay_tree_s, gdb::splay_tree_deleter>
     gdb_splay_tree_up;
 
-#endif /* COMMON_GDB_SPLAY_TREE_H */
+#endif /* GDBSUPPORT_GDB_SPLAY_TREE_H */
diff --git a/gdbsupport/gdb_sys_time.h b/gdbsupport/gdb_sys_time.h
index 63c93445121..ca93fc8d293 100644
--- a/gdbsupport/gdb_sys_time.h
+++ b/gdbsupport/gdb_sys_time.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SYS_TIME_H
-#define COMMON_GDB_SYS_TIME_H
+#ifndef GDBSUPPORT_GDB_SYS_TIME_H
+#define GDBSUPPORT_GDB_SYS_TIME_H
 
 #include <sys/time.h>
 
@@ -35,4 +35,4 @@
 # undef gettimeofday
 #endif
 
-#endif /* COMMON_GDB_SYS_TIME_H */
+#endif /* GDBSUPPORT_GDB_SYS_TIME_H */
diff --git a/gdbsupport/gdb_tilde_expand.h b/gdbsupport/gdb_tilde_expand.h
index fbd410dd133..12ae9cc73a7 100644
--- a/gdbsupport/gdb_tilde_expand.h
+++ b/gdbsupport/gdb_tilde_expand.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_TILDE_EXPAND_H
-#define COMMON_GDB_TILDE_EXPAND_H
+#ifndef GDBSUPPORT_GDB_TILDE_EXPAND_H
+#define GDBSUPPORT_GDB_TILDE_EXPAND_H
 
 /* Perform tilde expansion on DIR, and return the full path.  */
 extern std::string gdb_tilde_expand (const char *dir);
 
-#endif /* COMMON_GDB_TILDE_EXPAND_H */
+#endif /* GDBSUPPORT_GDB_TILDE_EXPAND_H */
diff --git a/gdbsupport/gdb_unique_ptr.h b/gdbsupport/gdb_unique_ptr.h
index 19b1581dab5..a40e1b133da 100644
--- a/gdbsupport/gdb_unique_ptr.h
+++ b/gdbsupport/gdb_unique_ptr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_UNIQUE_PTR_H
-#define COMMON_GDB_UNIQUE_PTR_H
+#ifndef GDBSUPPORT_GDB_UNIQUE_PTR_H
+#define GDBSUPPORT_GDB_UNIQUE_PTR_H
 
 #include <memory>
 #include <string>
@@ -93,4 +93,4 @@ operator+ (const std::string &lhs, const gdb::unique_xmalloc_ptr<char> &rhs)
   return lhs + rhs.get ();
 }
 
-#endif /* COMMON_GDB_UNIQUE_PTR_H */
+#endif /* GDBSUPPORT_GDB_UNIQUE_PTR_H */
diff --git a/gdbsupport/gdb_unlinker.h b/gdbsupport/gdb_unlinker.h
index 2da65fe45e8..2b9044290fe 100644
--- a/gdbsupport/gdb_unlinker.h
+++ b/gdbsupport/gdb_unlinker.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_UNLINKER_H
-#define COMMON_GDB_UNLINKER_H
+#ifndef GDBSUPPORT_GDB_UNLINKER_H
+#define GDBSUPPORT_GDB_UNLINKER_H
 
 namespace gdb
 {
@@ -57,4 +57,4 @@ class unlinker
 
 }
 
-#endif /* COMMON_GDB_UNLINKER_H */
+#endif /* GDBSUPPORT_GDB_UNLINKER_H */
diff --git a/gdbsupport/gdb_vecs.h b/gdbsupport/gdb_vecs.h
index 47083cead38..22c165c8a55 100644
--- a/gdbsupport/gdb_vecs.h
+++ b/gdbsupport/gdb_vecs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_VECS_H
-#define COMMON_GDB_VECS_H
+#ifndef GDBSUPPORT_GDB_VECS_H
+#define GDBSUPPORT_GDB_VECS_H
 
 /* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
 
@@ -85,4 +85,4 @@ ordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
   return removed;
 }
 
-#endif /* COMMON_GDB_VECS_H */
+#endif /* GDBSUPPORT_GDB_VECS_H */
diff --git a/gdbsupport/gdb_wait.h b/gdbsupport/gdb_wait.h
index c6348dbcb1c..590dcea6a12 100644
--- a/gdbsupport/gdb_wait.h
+++ b/gdbsupport/gdb_wait.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_WAIT_H
-#define COMMON_GDB_WAIT_H
+#ifndef GDBSUPPORT_GDB_WAIT_H
+#define GDBSUPPORT_GDB_WAIT_H
 
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
@@ -128,4 +128,4 @@ extern int windows_status_to_termsig (unsigned long);
 #define __WCLONE	0x80000000 /* Wait for cloned process.  */
 #endif
 
-#endif /* COMMON_GDB_WAIT_H */
+#endif /* GDBSUPPORT_GDB_WAIT_H */
diff --git a/gdbsupport/hash_enum.h b/gdbsupport/hash_enum.h
index 5ef0e15c9ff..5771686dc1d 100644
--- a/gdbsupport/hash_enum.h
+++ b/gdbsupport/hash_enum.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_HASH_ENUM_H
-#define COMMON_HASH_ENUM_H
+#ifndef GDBSUPPORT_HASH_ENUM_H
+#define GDBSUPPORT_HASH_ENUM_H
 
 /* A hasher for enums, which was missing in C++11:
     http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148
@@ -42,4 +42,4 @@ struct hash_enum
 
 } /* namespace gdb */
 
-#endif /* COMMON_HASH_ENUM_H */
+#endif /* GDBSUPPORT_HASH_ENUM_H */
diff --git a/gdbsupport/host-defs.h b/gdbsupport/host-defs.h
index 6e7a08524f9..5298089ba15 100644
--- a/gdbsupport/host-defs.h
+++ b/gdbsupport/host-defs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_HOST_DEFS_H
-#define COMMON_HOST_DEFS_H
+#ifndef GDBSUPPORT_HOST_DEFS_H
+#define GDBSUPPORT_HOST_DEFS_H
 
 #include <limits.h>
 
@@ -58,4 +58,4 @@
 #define SLASH_STRING "/"
 #endif
 
-#endif /* COMMON_HOST_DEFS_H */
+#endif /* GDBSUPPORT_HOST_DEFS_H */
diff --git a/gdbsupport/job-control.h b/gdbsupport/job-control.h
index 977276d95ce..2b99d69d2bb 100644
--- a/gdbsupport/job-control.h
+++ b/gdbsupport/job-control.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_JOB_CONTROL_H
-#define COMMON_JOB_CONTROL_H
+#ifndef GDBSUPPORT_JOB_CONTROL_H
+#define GDBSUPPORT_JOB_CONTROL_H
 
 /* Do we have job control?  Can be assumed to always be the same
    within a given run of GDB.  Use in gdb/inflow.c and
@@ -35,4 +35,4 @@ extern int gdb_setpgid ();
    JOB_CONTROL.  */
 extern void have_job_control ();
 
-#endif /* COMMON_JOB_CONTROL_H */
+#endif /* GDBSUPPORT_JOB_CONTROL_H */
diff --git a/gdbsupport/netstuff.h b/gdbsupport/netstuff.h
index f0df5fe7671..ae8f9bbd9da 100644
--- a/gdbsupport/netstuff.h
+++ b/gdbsupport/netstuff.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_NETSTUFF_H
-#define COMMON_NETSTUFF_H
+#ifndef GDBSUPPORT_NETSTUFF_H
+#define GDBSUPPORT_NETSTUFF_H
 
 #include <string>
 
@@ -73,4 +73,4 @@ extern parsed_connection_spec
 extern parsed_connection_spec parse_connection_spec (const char *spec,
 						     struct addrinfo *hint);
 
-#endif /* COMMON_NETSTUFF_H */
+#endif /* GDBSUPPORT_NETSTUFF_H */
diff --git a/gdbsupport/next-iterator.h b/gdbsupport/next-iterator.h
index 772083482ee..6bacb58752a 100644
--- a/gdbsupport/next-iterator.h
+++ b/gdbsupport/next-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_NEXT_ITERATOR_H
-#define COMMON_NEXT_ITERATOR_H
+#ifndef GDBSUPPORT_NEXT_ITERATOR_H
+#define GDBSUPPORT_NEXT_ITERATOR_H
 
 #include "gdbsupport/iterator-range.h"
 
@@ -77,4 +77,4 @@ struct next_iterator
 template <typename T>
 using next_range = iterator_range<next_iterator<T>>;
 
-#endif /* COMMON_NEXT_ITERATOR_H */
+#endif /* GDBSUPPORT_NEXT_ITERATOR_H */
diff --git a/gdbsupport/observable.h b/gdbsupport/observable.h
index 41e0ba385c9..b386bbcee29 100644
--- a/gdbsupport/observable.h
+++ b/gdbsupport/observable.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_OBSERVABLE_H
-#define COMMON_OBSERVABLE_H
+#ifndef GDBSUPPORT_OBSERVABLE_H
+#define GDBSUPPORT_OBSERVABLE_H
 
 #include <algorithm>
 #include <functional>
@@ -248,4 +248,4 @@ class observable
 
 } /* namespace gdb */
 
-#endif /* COMMON_OBSERVABLE_H */
+#endif /* GDBSUPPORT_OBSERVABLE_H */
diff --git a/gdbsupport/offset-type.h b/gdbsupport/offset-type.h
index 256703cab4d..181e224253e 100644
--- a/gdbsupport/offset-type.h
+++ b/gdbsupport/offset-type.h
@@ -45,8 +45,8 @@
 
    However, unlike pointers, you can't deference offset types.  */
 
-#ifndef COMMON_OFFSET_TYPE_H
-#define COMMON_OFFSET_TYPE_H
+#ifndef GDBSUPPORT_OFFSET_TYPE_H
+#define GDBSUPPORT_OFFSET_TYPE_H
 
 /* Declare TYPE as being an offset type.  This declares the type and
    enables the operators defined below.  */
@@ -130,4 +130,4 @@ operator- (E lhs, E rhs)
   return static_cast<underlying> (lhs) - static_cast<underlying> (rhs);
 }
 
-#endif /* COMMON_OFFSET_TYPE_H */
+#endif /* GDBSUPPORT_OFFSET_TYPE_H */
diff --git a/gdbsupport/packed.h b/gdbsupport/packed.h
index 5c817d4c9cc..37f02d26373 100644
--- a/gdbsupport/packed.h
+++ b/gdbsupport/packed.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PACKED_H
-#define PACKED_H
+#ifndef GDBSUPPORT_PACKED_H
+#define GDBSUPPORT_PACKED_H
 
 #include "traits.h"
 #include <atomic>
@@ -163,4 +163,4 @@ PACKED_ATOMIC_OP (<=)
 
 #undef PACKED_ATOMIC_OP
 
-#endif
+#endif /* GDBSUPPORT_PACKED_H */
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
index 170a2c5e724..fc516505017 100644
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PATHSTUFF_H
-#define COMMON_PATHSTUFF_H
+#ifndef GDBSUPPORT_PATHSTUFF_H
+#define GDBSUPPORT_PATHSTUFF_H
 
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/array-view.h"
@@ -162,4 +162,4 @@ extern gdb::char_vector make_temp_filename (const std::string &f);
 /* String containing the current directory (what getwd would return).  */
 extern char *current_directory;
 
-#endif /* COMMON_PATHSTUFF_H */
+#endif /* GDBSUPPORT_PATHSTUFF_H */
diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h
index 7b4f8e8a178..66f0fcf53b8 100644
--- a/gdbsupport/poison.h
+++ b/gdbsupport/poison.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_POISON_H
-#define COMMON_POISON_H
+#ifndef GDBSUPPORT_POISON_H
+#define GDBSUPPORT_POISON_H
 
 #include "traits.h"
 #include "obstack.h"
@@ -237,4 +237,4 @@ non-POD data type.");
 #undef XOBNEWVEC
 #define XOBNEWVEC(O, T, N) xobnewvec<T> (O, N)
 
-#endif /* COMMON_POISON_H */
+#endif /* GDBSUPPORT_POISON_H */
diff --git a/gdbsupport/preprocessor.h b/gdbsupport/preprocessor.h
index 96b3b94bf35..23177d5d82e 100644
--- a/gdbsupport/preprocessor.h
+++ b/gdbsupport/preprocessor.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PREPROCESSOR_H
-#define COMMON_PREPROCESSOR_H
+#ifndef GDBSUPPORT_PREPROCESSOR_H
+#define GDBSUPPORT_PREPROCESSOR_H
 
 /* Generally useful preprocessor bits.  */
 
@@ -32,4 +32,4 @@
    includes commas to another macro.  */
 #define ESC_PARENS(...) __VA_ARGS__
 
-#endif /* COMMON_PREPROCESSOR_H */
+#endif /* GDBSUPPORT_PREPROCESSOR_H */
diff --git a/gdbsupport/print-utils.h b/gdbsupport/print-utils.h
index 5c5869ec1ae..dcc68045791 100644
--- a/gdbsupport/print-utils.h
+++ b/gdbsupport/print-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PRINT_UTILS_H
-#define COMMON_PRINT_UTILS_H
+#ifndef GDBSUPPORT_PRINT_UTILS_H
+#define GDBSUPPORT_PRINT_UTILS_H
 
 /* How many characters (including the terminating null byte) fit in a
    cell.  */
@@ -82,4 +82,4 @@ extern const char *host_address_to_string_1 (const void *addr);
 
 extern char *get_print_cell (void);
 
-#endif /* COMMON_PRINT_UTILS_H */
+#endif /* GDBSUPPORT_PRINT_UTILS_H */
diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h
index fef9749ee80..f502efe7484 100644
--- a/gdbsupport/ptid.h
+++ b/gdbsupport/ptid.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PTID_H
-#define COMMON_PTID_H
+#ifndef GDBSUPPORT_PTID_H
+#define GDBSUPPORT_PTID_H
 
 /* The ptid struct is a collection of the various "ids" necessary for
    identifying the inferior process/thread being debugged.  This
@@ -182,4 +182,4 @@ extern const ptid_t null_ptid;
 
 extern const ptid_t minus_one_ptid;
 
-#endif /* COMMON_PTID_H */
+#endif /* GDBSUPPORT_PTID_H */
diff --git a/gdbsupport/refcounted-object.h b/gdbsupport/refcounted-object.h
index 9cdf0f10729..42bf71a0309 100644
--- a/gdbsupport/refcounted-object.h
+++ b/gdbsupport/refcounted-object.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_REFCOUNTED_OBJECT_H
-#define COMMON_REFCOUNTED_OBJECT_H
+#ifndef GDBSUPPORT_REFCOUNTED_OBJECT_H
+#define GDBSUPPORT_REFCOUNTED_OBJECT_H
 
 /* Base class of intrusively reference-countable objects.
    Incrementing and decrementing the reference count is an external
@@ -84,4 +84,4 @@ struct refcounted_object_delete_ref_policy
   }
 };
 
-#endif /* COMMON_REFCOUNTED_OBJECT_H */
+#endif /* GDBSUPPORT_REFCOUNTED_OBJECT_H */
diff --git a/gdbsupport/rsp-low.h b/gdbsupport/rsp-low.h
index 801df0ebc0c..e91c79e822f 100644
--- a/gdbsupport/rsp-low.h
+++ b/gdbsupport/rsp-low.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_RSP_LOW_H
-#define COMMON_RSP_LOW_H
+#ifndef GDBSUPPORT_RSP_LOW_H
+#define GDBSUPPORT_RSP_LOW_H
 
 /* Convert number NIB to a hex digit.  */
 
@@ -81,4 +81,4 @@ extern int remote_escape_output (const gdb_byte *buffer, int len_units,
 extern int remote_unescape_input (const gdb_byte *buffer, int len,
 				  gdb_byte *out_buf, int out_maxlen);
 
-#endif /* COMMON_RSP_LOW_H */
+#endif /* GDBSUPPORT_RSP_LOW_H */
diff --git a/gdbsupport/run-time-clock.h b/gdbsupport/run-time-clock.h
index 8176151add9..f4328543945 100644
--- a/gdbsupport/run-time-clock.h
+++ b/gdbsupport/run-time-clock.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_RUN_TIME_CLOCK_H
-#define COMMON_RUN_TIME_CLOCK_H
+#ifndef GDBSUPPORT_RUN_TIME_CLOCK_H
+#define GDBSUPPORT_RUN_TIME_CLOCK_H
 
 #include <chrono>
 
@@ -72,4 +72,4 @@ struct run_time_clock
 		   system_cpu_time_clock::time_point &system) noexcept;
 };
 
-#endif /* COMMON_RUN_TIME_CLOCK_H */
+#endif /* GDBSUPPORT_RUN_TIME_CLOCK_H */
diff --git a/gdbsupport/safe-iterator.h b/gdbsupport/safe-iterator.h
index f69f3896758..f31f92f6c24 100644
--- a/gdbsupport/safe-iterator.h
+++ b/gdbsupport/safe-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SAFE_ITERATOR_H
-#define COMMON_SAFE_ITERATOR_H
+#ifndef GDBSUPPORT_SAFE_ITERATOR_H
+#define GDBSUPPORT_SAFE_ITERATOR_H
 
 #include <type_traits>
 
@@ -136,4 +136,4 @@ class basic_safe_range
   Range m_range;
 };
 
-#endif /* COMMON_SAFE_ITERATOR_H */
+#endif /* GDBSUPPORT_SAFE_ITERATOR_H */
diff --git a/gdbsupport/scope-exit.h b/gdbsupport/scope-exit.h
index 86b2969f817..c3d27d7c77a 100644
--- a/gdbsupport/scope-exit.h
+++ b/gdbsupport/scope-exit.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPE_EXIT_H
-#define COMMON_SCOPE_EXIT_H
+#ifndef GDBSUPPORT_SCOPE_EXIT_H
+#define GDBSUPPORT_SCOPE_EXIT_H
 
 #include <functional>
 #include <type_traits>
@@ -165,4 +165,4 @@ operator+ (scope_exit_lhs, EF &&rhs)
 #define SCOPE_EXIT \
   auto CONCAT(scope_exit_, __LINE__) = ::detail::scope_exit_lhs () + [&] ()
 
-#endif /* COMMON_SCOPE_EXIT_H */
+#endif /* GDBSUPPORT_SCOPE_EXIT_H */
diff --git a/gdbsupport/scoped_fd.h b/gdbsupport/scoped_fd.h
index aa214b2c1c1..240685a927b 100644
--- a/gdbsupport/scoped_fd.h
+++ b/gdbsupport/scoped_fd.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_FD_H
-#define COMMON_SCOPED_FD_H
+#ifndef GDBSUPPORT_SCOPED_FD_H
+#define GDBSUPPORT_SCOPED_FD_H
 
 #include <unistd.h>
 #include "gdb_file.h"
@@ -84,4 +84,4 @@ class scoped_fd
   int m_fd;
 };
 
-#endif /* COMMON_SCOPED_FD_H */
+#endif /* GDBSUPPORT_SCOPED_FD_H */
diff --git a/gdbsupport/scoped_ignore_signal.h b/gdbsupport/scoped_ignore_signal.h
index 74fc69057a8..2fecd58466d 100644
--- a/gdbsupport/scoped_ignore_signal.h
+++ b/gdbsupport/scoped_ignore_signal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_IGNORE_SIGNAL_H
-#define SCOPED_IGNORE_SIGNAL_H
+#ifndef GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H
+#define GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H
 
 #include <signal.h>
 
@@ -118,4 +118,4 @@ using scoped_ignore_sigpipe = scoped_ignore_signal<SIGPIPE, true>;
 using scoped_ignore_sigpipe = scoped_ignore_signal_nop;
 #endif
 
-#endif /* SCOPED_IGNORE_SIGNAL_H */
+#endif /* GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H */
diff --git a/gdbsupport/scoped_ignore_sigttou.h b/gdbsupport/scoped_ignore_sigttou.h
index de2e40a6492..bb4e86d5b21 100644
--- a/gdbsupport/scoped_ignore_sigttou.h
+++ b/gdbsupport/scoped_ignore_sigttou.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_IGNORE_SIGTTOU_H
-#define SCOPED_IGNORE_SIGTTOU_H
+#ifndef GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H
+#define GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H
 
 #include "gdbsupport/scoped_ignore_signal.h"
 #include "gdbsupport/job-control.h"
@@ -84,4 +84,4 @@ using scoped_ignore_sigttou = scoped_ignore_signal_nop;
 
 #endif
 
-#endif /* SCOPED_IGNORE_SIGTTOU_H */
+#endif /* GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H */
diff --git a/gdbsupport/scoped_mmap.h b/gdbsupport/scoped_mmap.h
index 8383b8933b5..ea2f4fd3af5 100644
--- a/gdbsupport/scoped_mmap.h
+++ b/gdbsupport/scoped_mmap.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_MMAP_H
-#define COMMON_SCOPED_MMAP_H
+#ifndef GDBSUPPORT_SCOPED_MMAP_H
+#define GDBSUPPORT_SCOPED_MMAP_H
 
 #ifdef HAVE_SYS_MMAN_H
 
@@ -88,4 +88,4 @@ scoped_mmap mmap_file (const char *filename);
 
 #endif /* HAVE_SYS_MMAN_H */
 
-#endif /* COMMON_SCOPED_MMAP_H */
+#endif /* GDBSUPPORT_SCOPED_MMAP_H */
diff --git a/gdbsupport/scoped_restore.h b/gdbsupport/scoped_restore.h
index 96fe5256f80..5833b928fe3 100644
--- a/gdbsupport/scoped_restore.h
+++ b/gdbsupport/scoped_restore.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_RESTORE_H
-#define COMMON_SCOPED_RESTORE_H
+#ifndef GDBSUPPORT_SCOPED_RESTORE_H
+#define GDBSUPPORT_SCOPED_RESTORE_H
 
 /* Base class for scoped_restore_tmpl.  */
 class scoped_restore_base
@@ -115,4 +115,4 @@ scoped_restore_tmpl<T> make_scoped_restore (T *var, T2 value)
   return scoped_restore_tmpl<T> (var, value);
 }
 
-#endif /* COMMON_SCOPED_RESTORE_H */
+#endif /* GDBSUPPORT_SCOPED_RESTORE_H */
diff --git a/gdbsupport/search.h b/gdbsupport/search.h
index 42a9fd23083..f8c003bf6df 100644
--- a/gdbsupport/search.h
+++ b/gdbsupport/search.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SEARCH_H
-#define COMMON_SEARCH_H
+#ifndef GDBSUPPORT_SEARCH_H
+#define GDBSUPPORT_SEARCH_H
 
 #include "gdbsupport/function-view.h"
 
@@ -39,4 +39,4 @@ extern int simple_search_memory
    ULONGEST pattern_len,
    CORE_ADDR *found_addrp);
 
-#endif /* COMMON_SEARCH_H */
+#endif /* GDBSUPPORT_SEARCH_H */
diff --git a/gdbsupport/selftest.h b/gdbsupport/selftest.h
index 41d1210a5a5..cbbdd01093d 100644
--- a/gdbsupport/selftest.h
+++ b/gdbsupport/selftest.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SELFTEST_H
-#define COMMON_SELFTEST_H
+#ifndef GDBSUPPORT_SELFTEST_H
+#define GDBSUPPORT_SELFTEST_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/function-view.h"
@@ -93,4 +93,4 @@ extern void reset ();
       error (_("self-test failed at %s:%d"), __FILE__, __LINE__);	\
   } while (0)
 
-#endif /* COMMON_SELFTEST_H */
+#endif /* GDBSUPPORT_SELFTEST_H */
diff --git a/gdbsupport/signals-state-save-restore.h b/gdbsupport/signals-state-save-restore.h
index 132aaa8c522..e01ac36fe99 100644
--- a/gdbsupport/signals-state-save-restore.h
+++ b/gdbsupport/signals-state-save-restore.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SIGNALS_STATE_SAVE_RESTORE_H
-#define COMMON_SIGNALS_STATE_SAVE_RESTORE_H
+#ifndef GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H
+#define GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H
 
 /* Save/restore the signal actions of all signals, and the signal
    mask.
@@ -37,4 +37,4 @@ extern void save_original_signals_state (bool quiet);
 
 extern void restore_original_signals_state (void);
 
-#endif /* COMMON_SIGNALS_STATE_SAVE_RESTORE_H */
+#endif /* GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H */
diff --git a/gdbsupport/symbol.h b/gdbsupport/symbol.h
index 3e1dc9d29d3..de439c07179 100644
--- a/gdbsupport/symbol.h
+++ b/gdbsupport/symbol.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SYMBOL_H
-#define COMMON_SYMBOL_H
+#ifndef GDBSUPPORT_SYMBOL_H
+#define GDBSUPPORT_SYMBOL_H
 
 struct objfile;
 
@@ -34,4 +34,4 @@ struct objfile;
 extern int find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
 					struct objfile *objfile);
 
-#endif /* COMMON_SYMBOL_H */
+#endif /* GDBSUPPORT_SYMBOL_H */
diff --git a/gdbsupport/tdesc.h b/gdbsupport/tdesc.h
index fa9431b5b65..dc2d45278d1 100644
--- a/gdbsupport/tdesc.h
+++ b/gdbsupport/tdesc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_TDESC_H
-#define COMMON_TDESC_H
+#ifndef GDBSUPPORT_TDESC_H
+#define GDBSUPPORT_TDESC_H
 
 struct tdesc_feature;
 struct tdesc_type;
@@ -462,4 +462,4 @@ class print_xml_feature : public tdesc_element_visitor
   int m_depth;
 };
 
-#endif /* COMMON_TDESC_H */
+#endif /* GDBSUPPORT_TDESC_H */
diff --git a/gdbsupport/traits.h b/gdbsupport/traits.h
index 92fe59f34af..600f89ede65 100644
--- a/gdbsupport/traits.h
+++ b/gdbsupport/traits.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_TRAITS_H
-#define COMMON_TRAITS_H
+#ifndef GDBSUPPORT_TRAITS_H
+#define GDBSUPPORT_TRAITS_H
 
 #include <type_traits>
 
@@ -143,4 +143,4 @@ template<typename Condition>
 using Requires = typename std::enable_if<Condition::value, void>::type;
 }
 
-#endif /* COMMON_TRAITS_H */
+#endif /* GDBSUPPORT_TRAITS_H */
diff --git a/gdbsupport/underlying.h b/gdbsupport/underlying.h
index d9c5696a4cd..a3e7e3fca85 100644
--- a/gdbsupport/underlying.h
+++ b/gdbsupport/underlying.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_UNDERLYING_H
-#define COMMON_UNDERLYING_H
+#ifndef GDBSUPPORT_UNDERLYING_H
+#define GDBSUPPORT_UNDERLYING_H
 
 #include <type_traits>
 
@@ -29,4 +29,4 @@ to_underlying (E val) noexcept
   return static_cast<typename std::underlying_type<E>::type> (val);
 }
 
-#endif
+#endif /* GDBSUPPORT_UNDERLYING_H */
diff --git a/gdbsupport/valid-expr.h b/gdbsupport/valid-expr.h
index 6d2b481c6e1..ef51958dc09 100644
--- a/gdbsupport/valid-expr.h
+++ b/gdbsupport/valid-expr.h
@@ -23,8 +23,8 @@
    right type.  This is mainly used to verify that some utility's API
    is really as safe as intended.  */
 
-#ifndef COMMON_VALID_EXPR_H
-#define COMMON_VALID_EXPR_H
+#ifndef GDBSUPPORT_VALID_EXPR_H
+#define GDBSUPPORT_VALID_EXPR_H
 
 #include "gdbsupport/preprocessor.h"
 #include "gdbsupport/traits.h"
@@ -108,4 +108,4 @@
 			ESC_PARENS (T1, T2, T3, T4, T5, T6),		\
 			VALID, EXPR_TYPE, EXPR)
 
-#endif /* COMMON_VALID_EXPR_H */
+#endif /* GDBSUPPORT_VALID_EXPR_H */
diff --git a/gdbsupport/version.h b/gdbsupport/version.h
index 7c60a963919..052d613d47e 100644
--- a/gdbsupport/version.h
+++ b/gdbsupport/version.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_VERSION_H
-#define COMMON_VERSION_H
+#ifndef GDBSUPPORT_VERSION_H
+#define GDBSUPPORT_VERSION_H
 
 /* Version number of GDB, as a string.  */
 extern const char version[];
@@ -28,4 +28,4 @@ extern const char host_name[];
 /* Canonical target name as a string.  */
 extern const char target_name[];
 
-#endif /* COMMON_VERSION_H */
+#endif /* GDBSUPPORT_VERSION_H */
diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h
index 89c1143fbe1..ed8aeccece2 100644
--- a/gdbsupport/x86-xstate.h
+++ b/gdbsupport/x86-xstate.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_X86_XSTATE_H
-#define COMMON_X86_XSTATE_H
+#ifndef GDBSUPPORT_X86_XSTATE_H
+#define GDBSUPPORT_X86_XSTATE_H
 
 /* The extended state feature IDs in the state component bitmap.  */
 #define X86_XSTATE_X87_ID	0
@@ -120,4 +120,4 @@ constexpr bool operator!= (const x86_xsave_layout &lhs,
 
 #define I387_MXCSR_INIT_VAL 0x1f80
 
-#endif /* COMMON_X86_XSTATE_H */
+#endif /* GDBSUPPORT_X86_XSTATE_H */
diff --git a/gdbsupport/xml-utils.h b/gdbsupport/xml-utils.h
index c1f21b9b8ec..d68f4c98018 100644
--- a/gdbsupport/xml-utils.h
+++ b/gdbsupport/xml-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_XML_UTILS_H
-#define COMMON_XML_UTILS_H
+#ifndef GDBSUPPORT_XML_UTILS_H
+#define GDBSUPPORT_XML_UTILS_H
 
 /* Return a string with special characters from TEXT replaced by entity
    references.  */
@@ -40,4 +40,4 @@ extern void xml_escape_text_append (std::string &result, const char *text);
 void string_xml_appendf (std::string &buffer, const char *format, ...)
   ATTRIBUTE_PRINTF (2, 3);
 
-#endif /* COMMON_XML_UTILS_H */
+#endif /* GDBSUPPORT_XML_UTILS_H */

-- 
2.43.0


^ permalink raw reply	[relevance 1%]

* Re: [PATCH v6 6/8] gdb: Add qIsAddressTagged packet
  @ 2024-04-19  7:52  0%   ` Luis Machado
  0 siblings, 0 replies; 200+ results
From: Luis Machado @ 2024-04-19  7:52 UTC (permalink / raw)
  To: Gustavo Romero, gdb-patches; +Cc: thiago.bauermann, eliz, tom

On 4/18/24 21:10, Gustavo Romero wrote:
> This commit adds a new packet, qIsAddressTagged, allowing GDB remote
> targets to use it to query the stub if a given address is tagged.
> 
> Currently, the memory tagging address check is done via a read query,
> where the contents of /proc/<PID>/smaps is read and the flags are
> inspected for memory tagging-related flags that indicate the address is
> in a memory tagged region.
> 
> This is not ideal, for example, for QEMU stub and other cases, such as
> on bare-metal, where there is no notion of an OS file like 'smaps.'
> Hence, the introduction of qIsAddressTagged packet allows checking
> if an address is tagged in an agnostic way.
> 
> The is_address_tagged target hook in remote.c attempts to use the
> qIsAddressTagged packet first for checking if an address is tagged and
> if the stub does not support such a packet (reply is empty) it falls
> back to using the current mechanism that reads the contents of
> /proc/<PID>/smaps via vFile requests.
> 
> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
> ---
>  gdb/remote.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 75 insertions(+)
> 
> diff --git a/gdb/remote.c b/gdb/remote.c
> index cd271c4b493..3d034bb1ef8 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -337,6 +337,9 @@ enum {
>       packets and the tag violation stop replies.  */
>    PACKET_memory_tagging_feature,
>  
> +  /* Support for the qIsAddressTagged packet.  */
> +  PACKET_qIsAddressTagged,
> +
>    PACKET_MAX
>  };
>  
> @@ -15535,6 +15538,50 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address,
>    strcpy (packet.data (), request.c_str ());
>  }
>  
> +static void
> +create_is_address_tagged_request (gdbarch *gdbarch, gdb::char_vector &packet,
> +				  CORE_ADDR address)
> +{
> +  int addr_size;
> +  std::string request;
> +
> +  addr_size = gdbarch_addr_bit (gdbarch) / 8;
> +  request = string_printf ("qIsAddressTagged:%s", phex_nz (address, addr_size));
> +
> +  if (packet.size () < request.length () + 1)
> +    error (_("Contents too big for packet qIsAddressTagged."));
> +
> +  strcpy (packet.data (), request.c_str ());
> +}
> +
> +static bool
> +check_is_address_tagged_reply (remote_target *remote, gdb::char_vector &packet,
> +			       bool &tagged)
> +{
> +  gdb_assert (remote != nullptr);
> +  /* Check reply and disable qIsAddressTagged usage if it's not supported.  */
> +  packet_result result = remote->m_features.packet_ok (packet,
> +						       PACKET_qIsAddressTagged);
> +
> +  /* Return false on error (Exx), empty reply (packet not supported), or reply
> +     size doesn't match 2 hex digits.  */
> +  if ((result.status () != PACKET_OK) || (strlen (packet.data ()) != 2))
> +    return false;
> +
> +  gdb_byte reply;
> +  /* Convert only 2 hex digits, i.e. 1 byte in hex format.  */
> +  hex2bin (packet.data (), &reply, 1);
> +
> +  if (reply == 0x00 || reply == 0x01)
> +    {
> +      tagged = !!reply;
> +      return true;
> +    }
> +
> +  /* Invalid reply.  */
> +  return false;
> +}
> +
>  /* Implement the "fetch_memtags" target_ops method.  */
>  
>  bool
> @@ -15581,6 +15628,31 @@ remote_target::store_memtags (CORE_ADDR address, size_t len,
>  bool
>  remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address)
>  {
> +  /* Firstly, attempt to check the address using the qIsAddressTagged
> +     packet.  */
> +  if (m_features.packet_support (PACKET_qIsAddressTagged) != PACKET_DISABLE)
> +    {
> +      remote_target *remote = get_current_remote_target ();
> +      struct remote_state *rs = get_remote_state ();
> +      bool is_addr_tagged;
> +
> +      create_is_address_tagged_request (gdbarch, rs->buf, address);
> +
> +      putpkt (rs->buf);
> +      getpkt (&rs->buf);
> +
> +      /* If qIsAddressTagged is not supported PACKET_qIsAddressTagged will be
> +	 set to PACKET_DISABLE so no further attempt is made to check addresses
> +	 using this packet and the fallback mechanism below will be used
> +	 instead.  Also, if the check fails due to an error (Exx reply) the
> +	 fallback is used too.  Otherwise, the qIsAddressTagged query succeeded
> +	 and is_addr_tagged is valid.  */
> +      if (check_is_address_tagged_reply (remote, rs->buf, is_addr_tagged))
> +	return is_addr_tagged;
> +    }
> +
> +  /* Fallback to arch-specific method of checking whether an address is tagged
> +     in case check via qIsAddressTagged fails.  */
>    return gdbarch_tagged_address_p (gdbarch, address);
>  }
>  
> @@ -16070,6 +16142,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
>    add_packet_config_cmd (PACKET_memory_tagging_feature,
>  			 "memory-tagging-feature", "memory-tagging-feature", 0);
>  
> +  add_packet_config_cmd (PACKET_qIsAddressTagged,
> +			 "qIsAddressTagged", "memory-tagging-address-check", 0);
> +
>    /* Assert that we've registered "set remote foo-packet" commands
>       for all packet configs.  */
>    {

Thanks, this is OK.

Approved-By: Luis Machado <luis.machado@arm.com>
Tested-By: Luis Machado <luis.machado@arm.com>

^ permalink raw reply	[relevance 0%]

* Re: Deprecation/removal of nios2 target support
  @ 2024-04-18 15:57  0%   ` Joel Sherrill
  0 siblings, 0 replies; 200+ results
From: Joel Sherrill @ 2024-04-18 15:57 UTC (permalink / raw)
  To: Joseph Myers
  Cc: Sandra Loosemore, gcc, binutils, gdb-patches, libc-alpha,
	Chung-Lin Tang, andrew, Yao Qi, Dinh Nguyen, qemu-devel, newlib,
	Arnd Bergmann

[-- Attachment #1: Type: text/plain, Size: 791 bytes --]

On Thu, Apr 18, 2024 at 10:46 AM Joseph Myers <josmyers@redhat.com> wrote:

> On Wed, 17 Apr 2024, Sandra Loosemore wrote:
>
> > Therefore I'd like to mark Nios II as obsolete in GCC 14 now, and remove
> > support from all toolchain components after the release is made.  I'm
> not sure
> > there is an established process for obsoleting/removing support in other
> > components; besides binutils, GDB, and GLIBC, there's QEMU,
> newlib/libgloss,
> > and the Linux kernel.  But, we need to get the ball rolling somewhere.
>
> CC:ing Arnd Bergmann regarding the obsolescence in the Linux kernel.
>

Just an FYI that the RTEMS Project plans to drop NIOS II support based
on what happens with the tooling.

--joel

>
> --
> Joseph S. Myers
> josmyers@redhat.com
>
>

^ permalink raw reply	[relevance 0%]

* [PATCH v2 4/4] Run check-include-guards.py
  @ 2024-04-18 15:41  1% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-18 15:41 UTC (permalink / raw)
  To: gdb-patches

This patch is the result of running check-include-guards.py on the
current tree.  Running it a second time causes no changes.
---
 gdb/aarch32-linux-nat.h                     | 6 +++---
 gdb/aarch32-tdep.h                          | 6 +++---
 gdb/aarch64-fbsd-tdep.h                     | 6 +++---
 gdb/aarch64-linux-tdep.h                    | 6 +++---
 gdb/aarch64-nat.h                           | 6 +++---
 gdb/aarch64-ravenscar-thread.h              | 6 +++---
 gdb/aarch64-tdep.h                          | 6 +++---
 gdb/ada-exp.h                               | 6 +++---
 gdb/ada-lang.h                              | 6 +++---
 gdb/addrmap.h                               | 6 +++---
 gdb/alpha-bsd-tdep.h                        | 6 +++---
 gdb/alpha-tdep.h                            | 6 +++---
 gdb/amd-dbgapi-target.h                     | 6 +++---
 gdb/amd64-bsd-nat.h                         | 6 +++---
 gdb/amd64-darwin-tdep.h                     | 6 +++---
 gdb/amd64-fbsd-tdep.h                       | 6 +++---
 gdb/amd64-linux-tdep.h                      | 6 +++---
 gdb/amd64-nat.h                             | 6 +++---
 gdb/amd64-ravenscar-thread.h                | 6 +++---
 gdb/amd64-tdep.h                            | 6 +++---
 gdb/amdgpu-tdep.h                           | 6 +++---
 gdb/annotate.h                              | 6 +++---
 gdb/arc-linux-tdep.h                        | 6 +++---
 gdb/arc-tdep.h                              | 6 +++---
 gdb/arch-utils.h                            | 6 +++---
 gdb/arch/aarch32.h                          | 6 +++---
 gdb/arch/aarch64-insn.h                     | 6 +++---
 gdb/arch/aarch64-mte-linux.h                | 6 +++---
 gdb/arch/aarch64-scalable-linux.h           | 6 +++---
 gdb/arch/aarch64.h                          | 6 +++---
 gdb/arch/amd64.h                            | 6 +++---
 gdb/arch/arc.h                              | 6 +++---
 gdb/arch/arm-get-next-pcs.h                 | 6 +++---
 gdb/arch/arm-linux.h                        | 6 +++---
 gdb/arch/arm.h                              | 6 +++---
 gdb/arch/csky.h                             | 6 +++---
 gdb/arch/i386.h                             | 6 +++---
 gdb/arch/loongarch.h                        | 6 +++---
 gdb/arch/ppc-linux-common.h                 | 6 +++---
 gdb/arch/ppc-linux-tdesc.h                  | 6 +++---
 gdb/arch/riscv.h                            | 6 +++---
 gdb/arch/tic6x.h                            | 6 +++---
 gdb/arch/xtensa.h                           | 6 +++---
 gdb/arm-fbsd-tdep.h                         | 6 +++---
 gdb/arm-linux-tdep.h                        | 6 +++---
 gdb/arm-netbsd-tdep.h                       | 6 +++---
 gdb/arm-tdep.h                              | 6 +++---
 gdb/async-event.h                           | 6 +++---
 gdb/auto-load.h                             | 6 +++---
 gdb/auxv.h                                  | 6 +++---
 gdb/ax-gdb.h                                | 6 +++---
 gdb/ax.h                                    | 6 +++---
 gdb/bcache.h                                | 6 +++---
 gdb/bfd-target.h                            | 6 +++---
 gdb/bfin-tdep.h                             | 6 +++---
 gdb/block.h                                 | 6 +++---
 gdb/breakpoint.h                            | 6 +++---
 gdb/bsd-kvm.h                               | 6 +++---
 gdb/bsd-uthread.h                           | 6 +++---
 gdb/bt-utils.h                              | 6 +++---
 gdb/btrace.h                                | 6 +++---
 gdb/build-id.h                              | 6 +++---
 gdb/buildsym-legacy.h                       | 6 +++---
 gdb/buildsym.h                              | 6 +++---
 gdb/c-exp.h                                 | 6 +++---
 gdb/c-lang.h                                | 6 +++---
 gdb/c-support.h                             | 6 +++---
 gdb/cgen-remap.h                            | 6 +++---
 gdb/charset-list.h                          | 6 +++---
 gdb/charset.h                               | 6 +++---
 gdb/cli-out.h                               | 6 +++---
 gdb/cli/cli-cmds.h                          | 6 +++---
 gdb/cli/cli-decode.h                        | 6 +++---
 gdb/cli/cli-interp.h                        | 6 +++---
 gdb/cli/cli-option.h                        | 6 +++---
 gdb/cli/cli-script.h                        | 6 +++---
 gdb/cli/cli-setshow.h                       | 6 +++---
 gdb/cli/cli-style.h                         | 6 +++---
 gdb/cli/cli-utils.h                         | 6 +++---
 gdb/coff-pe-read.h                          | 6 +++---
 gdb/command.h                               | 6 +++---
 gdb/compile/compile-c.h                     | 6 +++---
 gdb/compile/compile-cplus.h                 | 6 +++---
 gdb/compile/compile-internal.h              | 6 +++---
 gdb/compile/compile-object-load.h           | 6 +++---
 gdb/compile/compile-object-run.h            | 6 +++---
 gdb/compile/compile.h                       | 6 +++---
 gdb/compile/gcc-c-plugin.h                  | 6 +++---
 gdb/compile/gcc-cp-plugin.h                 | 6 +++---
 gdb/complaints.h                            | 6 +++---
 gdb/completer.h                             | 6 +++---
 gdb/config/nm-linux.h                       | 6 +++---
 gdb/config/nm-nto.h                         | 6 +++---
 gdb/cp-abi.h                                | 6 +++---
 gdb/cp-support.h                            | 6 +++---
 gdb/cris-tdep.h                             | 6 +++---
 gdb/csky-tdep.h                             | 6 +++---
 gdb/ctfread.h                               | 6 +++---
 gdb/d-lang.h                                | 6 +++---
 gdb/darwin-nat.h                            | 6 +++---
 gdb/dcache.h                                | 6 +++---
 gdb/debuginfod-support.h                    | 6 +++---
 gdb/defs.h                                  | 6 +++---
 gdb/dicos-tdep.h                            | 6 +++---
 gdb/dictionary.h                            | 6 +++---
 gdb/disasm-flags.h                          | 6 +++---
 gdb/disasm.h                                | 6 +++---
 gdb/displaced-stepping.h                    | 6 +++---
 gdb/dummy-frame.h                           | 6 +++---
 gdb/dwarf2/call-site.h                      | 6 +++---
 gdb/dwarf2/comp-unit-head.h                 | 6 +++---
 gdb/dwarf2/expr.h                           | 6 +++---
 gdb/dwarf2/frame-tailcall.h                 | 6 +++---
 gdb/dwarf2/frame.h                          | 6 +++---
 gdb/dwarf2/index-cache.h                    | 6 +++---
 gdb/dwarf2/index-common.h                   | 6 +++---
 gdb/dwarf2/index-write.h                    | 6 +++---
 gdb/dwarf2/line-header.h                    | 6 +++---
 gdb/dwarf2/loc.h                            | 6 +++---
 gdb/dwarf2/public.h                         | 6 +++---
 gdb/dwarf2/read-debug-names.h               | 6 +++---
 gdb/dwarf2/read-gdb-index.h                 | 6 +++---
 gdb/dwarf2/read.h                           | 6 +++---
 gdb/dwarf2/types.h                          | 6 +++---
 gdb/elf-none-tdep.h                         | 6 +++---
 gdb/event-top.h                             | 6 +++---
 gdb/exceptions.h                            | 6 +++---
 gdb/exec.h                                  | 6 +++---
 gdb/expop.h                                 | 6 +++---
 gdb/expression.h                            | 6 +++---
 gdb/extension-priv.h                        | 6 +++---
 gdb/extension.h                             | 6 +++---
 gdb/f-array-walker.h                        | 6 +++---
 gdb/f-exp.h                                 | 6 +++---
 gdb/f-lang.h                                | 6 +++---
 gdb/fbsd-nat.h                              | 6 +++---
 gdb/fbsd-tdep.h                             | 6 +++---
 gdb/filename-seen-cache.h                   | 6 +++---
 gdb/filesystem.h                            | 6 +++---
 gdb/frame-base.h                            | 6 +++---
 gdb/frame-id.h                              | 4 ++--
 gdb/frame-unwind.h                          | 6 +++---
 gdb/frame.h                                 | 6 +++---
 gdb/frv-tdep.h                              | 6 +++---
 gdb/ft32-tdep.h                             | 6 +++---
 gdb/gcore-elf.h                             | 6 +++---
 gdb/gcore.h                                 | 6 +++---
 gdb/gdb-demangle.h                          | 6 +++---
 gdb/gdb-stabs.h                             | 6 +++---
 gdb/gdb_bfd.h                               | 6 +++---
 gdb/gdb_curses.h                            | 6 +++---
 gdb/gdb_expat.h                             | 6 +++---
 gdb/gdb_proc_service.h                      | 6 +++---
 gdb/gdb_vfork.h                             | 6 +++---
 gdb/gdb_wchar.h                             | 6 +++---
 gdb/gdbarch.h                               | 6 +++---
 gdb/gdbcmd.h                                | 6 +++---
 gdb/gdbcore.h                               | 6 +++---
 gdb/gdbthread.h                             | 6 +++---
 gdb/gdbtypes.h                              | 6 +++---
 gdb/glibc-tdep.h                            | 6 +++---
 gdb/gmp-utils.h                             | 6 +++---
 gdb/gnu-nat-mig.h                           | 6 +++---
 gdb/gnu-nat.h                               | 6 +++---
 gdb/go-lang.h                               | 6 +++---
 gdb/gregset.h                               | 6 +++---
 gdb/guile/guile-internal.h                  | 6 +++---
 gdb/guile/guile.h                           | 6 +++---
 gdb/hppa-bsd-tdep.h                         | 6 +++---
 gdb/hppa-linux-offsets.h                    | 6 +++---
 gdb/hppa-tdep.h                             | 6 +++---
 gdb/i386-bsd-nat.h                          | 6 +++---
 gdb/i386-darwin-tdep.h                      | 6 +++---
 gdb/i386-fbsd-tdep.h                        | 6 +++---
 gdb/i386-linux-nat.h                        | 6 +++---
 gdb/i386-linux-tdep.h                       | 6 +++---
 gdb/i386-tdep.h                             | 6 +++---
 gdb/i387-tdep.h                             | 6 +++---
 gdb/ia64-libunwind-tdep.h                   | 6 +++---
 gdb/ia64-tdep.h                             | 6 +++---
 gdb/inf-child.h                             | 6 +++---
 gdb/inf-loop.h                              | 6 +++---
 gdb/inf-ptrace.h                            | 6 +++---
 gdb/infcall.h                               | 6 +++---
 gdb/inferior-iter.h                         | 6 +++---
 gdb/inferior.h                              | 6 +++---
 gdb/infrun.h                                | 6 +++---
 gdb/inline-frame.h                          | 6 +++---
 gdb/interps.h                               | 6 +++---
 gdb/jit.h                                   | 6 +++---
 gdb/language.h                              | 6 +++---
 gdb/linespec.h                              | 6 +++---
 gdb/linux-fork.h                            | 6 +++---
 gdb/linux-nat-trad.h                        | 6 +++---
 gdb/linux-nat.h                             | 6 +++---
 gdb/linux-record.h                          | 6 +++---
 gdb/linux-tdep.h                            | 6 +++---
 gdb/location.h                              | 6 +++---
 gdb/loongarch-tdep.h                        | 6 +++---
 gdb/m2-exp.h                                | 6 +++---
 gdb/m2-lang.h                               | 6 +++---
 gdb/m32r-tdep.h                             | 6 +++---
 gdb/m68k-tdep.h                             | 6 +++---
 gdb/macroexp.h                              | 6 +++---
 gdb/macroscope.h                            | 6 +++---
 gdb/macrotab.h                              | 6 +++---
 gdb/main.h                                  | 6 +++---
 gdb/maint.h                                 | 6 +++---
 gdb/mdebugread.h                            | 6 +++---
 gdb/memattr.h                               | 6 +++---
 gdb/memory-map.h                            | 6 +++---
 gdb/memrange.h                              | 6 +++---
 gdb/memtag.h                                | 6 +++---
 gdb/mi/mi-cmd-break.h                       | 6 +++---
 gdb/mi/mi-cmds.h                            | 6 +++---
 gdb/mi/mi-common.h                          | 6 +++---
 gdb/mi/mi-console.h                         | 6 +++---
 gdb/mi/mi-getopt.h                          | 6 +++---
 gdb/mi/mi-interp.h                          | 6 +++---
 gdb/mi/mi-main.h                            | 6 +++---
 gdb/mi/mi-out.h                             | 6 +++---
 gdb/mi/mi-parse.h                           | 6 +++---
 gdb/microblaze-tdep.h                       | 6 +++---
 gdb/minsyms.h                               | 6 +++---
 gdb/mips-fbsd-tdep.h                        | 6 +++---
 gdb/mips-linux-tdep.h                       | 6 +++---
 gdb/mips-netbsd-tdep.h                      | 6 +++---
 gdb/mips-tdep.h                             | 6 +++---
 gdb/mn10300-tdep.h                          | 6 +++---
 gdb/moxie-tdep.h                            | 6 +++---
 gdb/namespace.h                             | 6 +++---
 gdb/nat/aarch64-hw-point.h                  | 6 +++---
 gdb/nat/aarch64-linux-hw-point.h            | 6 +++---
 gdb/nat/aarch64-linux.h                     | 6 +++---
 gdb/nat/aarch64-mte-linux-ptrace.h          | 6 +++---
 gdb/nat/aarch64-scalable-linux-ptrace.h     | 6 +++---
 gdb/nat/aarch64-scalable-linux-sigcontext.h | 6 +++---
 gdb/nat/amd64-linux-siginfo.h               | 6 +++---
 gdb/nat/fork-inferior.h                     | 6 +++---
 gdb/nat/gdb_ptrace.h                        | 6 +++---
 gdb/nat/gdb_thread_db.h                     | 6 +++---
 gdb/nat/glibc_thread_db.h                   | 6 +++---
 gdb/nat/linux-btrace.h                      | 6 +++---
 gdb/nat/linux-namespaces.h                  | 6 +++---
 gdb/nat/linux-nat.h                         | 6 +++---
 gdb/nat/linux-osdata.h                      | 6 +++---
 gdb/nat/linux-personality.h                 | 6 +++---
 gdb/nat/linux-procfs.h                      | 6 +++---
 gdb/nat/linux-ptrace.h                      | 6 +++---
 gdb/nat/linux-waitpid.h                     | 6 +++---
 gdb/nat/mips-linux-watch.h                  | 6 +++---
 gdb/nat/netbsd-nat.h                        | 6 +++---
 gdb/nat/ppc-linux.h                         | 6 +++---
 gdb/nat/riscv-linux-tdesc.h                 | 6 +++---
 gdb/nat/windows-nat.h                       | 6 +++---
 gdb/nat/x86-cpuid.h                         | 6 +++---
 gdb/nat/x86-dregs.h                         | 6 +++---
 gdb/nat/x86-gcc-cpuid.h                     | 6 +++---
 gdb/nat/x86-linux-dregs.h                   | 6 +++---
 gdb/nat/x86-linux.h                         | 6 +++---
 gdb/nat/x86-xstate.h                        | 6 +++---
 gdb/nds32-tdep.h                            | 6 +++---
 gdb/netbsd-nat.h                            | 6 +++---
 gdb/netbsd-tdep.h                           | 6 +++---
 gdb/nios2-tdep.h                            | 6 +++---
 gdb/nto-tdep.h                              | 6 +++---
 gdb/objc-lang.h                             | 6 +++---
 gdb/objfile-flags.h                         | 6 +++---
 gdb/objfiles.h                              | 6 +++---
 gdb/obsd-nat.h                              | 6 +++---
 gdb/obsd-tdep.h                             | 6 +++---
 gdb/observable.h                            | 6 +++---
 gdb/or1k-linux-tdep.h                       | 6 +++---
 gdb/or1k-tdep.h                             | 6 +++---
 gdb/osabi.h                                 | 6 +++---
 gdb/osdata.h                                | 6 +++---
 gdb/p-lang.h                                | 6 +++---
 gdb/parser-defs.h                           | 6 +++---
 gdb/ppc-fbsd-tdep.h                         | 6 +++---
 gdb/ppc-linux-tdep.h                        | 6 +++---
 gdb/ppc-netbsd-tdep.h                       | 6 +++---
 gdb/ppc-obsd-tdep.h                         | 6 +++---
 gdb/ppc-ravenscar-thread.h                  | 6 +++---
 gdb/ppc-tdep.h                              | 6 +++---
 gdb/ppc64-tdep.h                            | 6 +++---
 gdb/probe.h                                 | 6 +++---
 gdb/proc-utils.h                            | 6 +++---
 gdb/process-stratum-target.h                | 6 +++---
 gdb/procfs.h                                | 6 +++---
 gdb/producer.h                              | 6 +++---
 gdb/progspace-and-thread.h                  | 6 +++---
 gdb/progspace.h                             | 6 +++---
 gdb/prologue-value.h                        | 6 +++---
 gdb/psymtab.h                               | 6 +++---
 gdb/python/py-event.h                       | 6 +++---
 gdb/python/py-events.h                      | 6 +++---
 gdb/python/py-instruction.h                 | 6 +++---
 gdb/python/py-record-btrace.h               | 6 +++---
 gdb/python/py-record-full.h                 | 6 +++---
 gdb/python/py-record.h                      | 6 +++---
 gdb/python/py-ref.h                         | 6 +++---
 gdb/python/py-stopevent.h                   | 6 +++---
 gdb/python/python-internal.h                | 6 +++---
 gdb/python/python.h                         | 6 +++---
 gdb/ravenscar-thread.h                      | 6 +++---
 gdb/record-btrace.h                         | 6 +++---
 gdb/record-full.h                           | 6 +++---
 gdb/record.h                                | 6 +++---
 gdb/regcache.h                              | 6 +++---
 gdb/regformats/regdef.h                     | 6 +++---
 gdb/reggroups.h                             | 6 +++---
 gdb/registry.h                              | 6 +++---
 gdb/regset.h                                | 6 +++---
 gdb/remote-fileio.h                         | 6 +++---
 gdb/remote-notif.h                          | 6 +++---
 gdb/remote.h                                | 6 +++---
 gdb/riscv-fbsd-tdep.h                       | 6 +++---
 gdb/riscv-ravenscar-thread.h                | 6 +++---
 gdb/riscv-tdep.h                            | 6 +++---
 gdb/rs6000-aix-tdep.h                       | 6 +++---
 gdb/rust-exp.h                              | 6 +++---
 gdb/rust-lang.h                             | 6 +++---
 gdb/s390-linux-tdep.h                       | 6 +++---
 gdb/s390-tdep.h                             | 6 +++---
 gdb/scoped-mock-context.h                   | 6 +++---
 gdb/selftest-arch.h                         | 6 +++---
 gdb/sentinel-frame.h                        | 6 +++---
 gdb/ser-base.h                              | 6 +++---
 gdb/ser-event.h                             | 6 +++---
 gdb/ser-tcp.h                               | 6 +++---
 gdb/ser-unix.h                              | 6 +++---
 gdb/serial.h                                | 6 +++---
 gdb/sh-tdep.h                               | 6 +++---
 gdb/sim-regno.h                             | 6 +++---
 gdb/skip.h                                  | 6 +++---
 gdb/sol2-tdep.h                             | 6 +++---
 gdb/solib-aix.h                             | 6 +++---
 gdb/solib-darwin.h                          | 6 +++---
 gdb/solib-dsbt.h                            | 6 +++---
 gdb/solib-svr4.h                            | 6 +++---
 gdb/solib-target.h                          | 6 +++---
 gdb/solib.h                                 | 6 +++---
 gdb/solist.h                                | 6 +++---
 gdb/source-cache.h                          | 6 +++---
 gdb/source.h                                | 6 +++---
 gdb/sparc-nat.h                             | 6 +++---
 gdb/sparc-ravenscar-thread.h                | 6 +++---
 gdb/sparc-tdep.h                            | 6 +++---
 gdb/sparc64-tdep.h                          | 6 +++---
 gdb/stabsread.h                             | 6 +++---
 gdb/stack.h                                 | 6 +++---
 gdb/stap-probe.h                            | 6 +++---
 gdb/symfile-add-flags.h                     | 6 +++---
 gdb/symfile.h                               | 6 +++---
 gdb/symtab.h                                | 6 +++---
 gdb/target-connection.h                     | 6 +++---
 gdb/target-dcache.h                         | 6 +++---
 gdb/target-debug.h                          | 6 +++---
 gdb/target-descriptions.h                   | 6 +++---
 gdb/target-float.h                          | 6 +++---
 gdb/target.h                                | 6 +++---
 gdb/target/resume.h                         | 6 +++---
 gdb/target/target.h                         | 6 +++---
 gdb/target/wait.h                           | 6 +++---
 gdb/target/waitstatus.h                     | 6 +++---
 gdb/terminal.h                              | 6 +++---
 gdb/test-target.h                           | 6 +++---
 gdb/thread-fsm.h                            | 6 +++---
 gdb/thread-iter.h                           | 6 +++---
 gdb/tic6x-tdep.h                            | 6 +++---
 gdb/tid-parse.h                             | 6 +++---
 gdb/tilegx-tdep.h                           | 6 +++---
 gdb/top.h                                   | 6 +++---
 gdb/tracectf.h                              | 6 +++---
 gdb/tracefile.h                             | 6 +++---
 gdb/tracepoint.h                            | 6 +++---
 gdb/trad-frame.h                            | 6 +++---
 gdb/tramp-frame.h                           | 6 +++---
 gdb/tui/tui-command.h                       | 6 +++---
 gdb/tui/tui-data.h                          | 6 +++---
 gdb/tui/tui-disasm.h                        | 6 +++---
 gdb/tui/tui-file.h                          | 6 +++---
 gdb/tui/tui-hooks.h                         | 6 +++---
 gdb/tui/tui-io.h                            | 6 +++---
 gdb/tui/tui-layout.h                        | 6 +++---
 gdb/tui/tui-location.h                      | 6 +++---
 gdb/tui/tui-regs.h                          | 6 +++---
 gdb/tui/tui-source.h                        | 6 +++---
 gdb/tui/tui-status.h                        | 6 +++---
 gdb/tui/tui-win.h                           | 6 +++---
 gdb/tui/tui-wingeneral.h                    | 6 +++---
 gdb/tui/tui-winsource.h                     | 6 +++---
 gdb/tui/tui.h                               | 6 +++---
 gdb/type-stack.h                            | 6 +++---
 gdb/typeprint.h                             | 6 +++---
 gdb/ui-file.h                               | 6 +++---
 gdb/ui-out.h                                | 6 +++---
 gdb/ui-style.h                              | 6 +++---
 gdb/ui.h                                    | 6 +++---
 gdb/user-regs.h                             | 6 +++---
 gdb/utils.h                                 | 6 +++---
 gdb/valprint.h                              | 6 +++---
 gdb/value.h                                 | 6 +++---
 gdb/varobj-iter.h                           | 6 +++---
 gdb/varobj.h                                | 6 +++---
 gdb/vax-tdep.h                              | 6 +++---
 gdb/windows-nat.h                           | 6 +++---
 gdb/windows-tdep.h                          | 6 +++---
 gdb/x86-bsd-nat.h                           | 6 +++---
 gdb/x86-fbsd-nat.h                          | 6 +++---
 gdb/x86-linux-nat.h                         | 6 +++---
 gdb/x86-nat.h                               | 6 +++---
 gdb/x86-tdep.h                              | 6 +++---
 gdb/xcoffread.h                             | 6 +++---
 gdb/xml-builtin.h                           | 6 +++---
 gdb/xml-support.h                           | 6 +++---
 gdb/xml-syscall.h                           | 6 +++---
 gdb/xml-tdesc.h                             | 6 +++---
 gdb/xtensa-tdep.h                           | 6 +++---
 gdb/yy-remap.h                              | 6 +++---
 gdb/z80-tdep.h                              | 6 +++---
 gdbserver/linux-aarch32-tdesc.h             | 2 +-
 gdbserver/linux-arm-tdesc.h                 | 2 +-
 gdbsupport/agent.h                          | 6 +++---
 gdbsupport/array-view.h                     | 6 +++---
 gdbsupport/break-common.h                   | 6 +++---
 gdbsupport/btrace-common.h                  | 6 +++---
 gdbsupport/byte-vector.h                    | 6 +++---
 gdbsupport/cleanups.h                       | 6 +++---
 gdbsupport/common-debug.h                   | 6 +++---
 gdbsupport/common-defs.h                    | 6 +++---
 gdbsupport/common-exceptions.h              | 6 +++---
 gdbsupport/common-gdbthread.h               | 6 +++---
 gdbsupport/common-inferior.h                | 6 +++---
 gdbsupport/common-regcache.h                | 6 +++---
 gdbsupport/common-types.h                   | 6 +++---
 gdbsupport/common-utils.h                   | 6 +++---
 gdbsupport/def-vector.h                     | 6 +++---
 gdbsupport/default-init-alloc.h             | 6 +++---
 gdbsupport/enum-flags.h                     | 6 +++---
 gdbsupport/environ.h                        | 6 +++---
 gdbsupport/errors.h                         | 6 +++---
 gdbsupport/event-loop.h                     | 6 +++---
 gdbsupport/event-pipe.h                     | 6 +++---
 gdbsupport/fileio.h                         | 6 +++---
 gdbsupport/filestuff.h                      | 6 +++---
 gdbsupport/filtered-iterator.h              | 6 +++---
 gdbsupport/format.h                         | 6 +++---
 gdbsupport/forward-scope-exit.h             | 6 +++---
 gdbsupport/function-view.h                  | 6 +++---
 gdbsupport/gdb-checked-static-cast.h        | 6 +++---
 gdbsupport/gdb-dlfcn.h                      | 6 +++---
 gdbsupport/gdb-safe-ctype.h                 | 6 +++---
 gdbsupport/gdb_assert.h                     | 6 +++---
 gdbsupport/gdb_file.h                       | 6 +++---
 gdbsupport/gdb_locale.h                     | 6 +++---
 gdbsupport/gdb_obstack.h                    | 6 +++---
 gdbsupport/gdb_proc_service.h               | 6 +++---
 gdbsupport/gdb_ref_ptr.h                    | 6 +++---
 gdbsupport/gdb_regex.h                      | 6 +++---
 gdbsupport/gdb_select.h                     | 6 +++---
 gdbsupport/gdb_setjmp.h                     | 6 +++---
 gdbsupport/gdb_signals.h                    | 6 +++---
 gdbsupport/gdb_splay_tree.h                 | 6 +++---
 gdbsupport/gdb_sys_time.h                   | 6 +++---
 gdbsupport/gdb_tilde_expand.h               | 6 +++---
 gdbsupport/gdb_unique_ptr.h                 | 6 +++---
 gdbsupport/gdb_unlinker.h                   | 6 +++---
 gdbsupport/gdb_vecs.h                       | 6 +++---
 gdbsupport/gdb_wait.h                       | 6 +++---
 gdbsupport/hash_enum.h                      | 6 +++---
 gdbsupport/host-defs.h                      | 6 +++---
 gdbsupport/job-control.h                    | 6 +++---
 gdbsupport/netstuff.h                       | 6 +++---
 gdbsupport/next-iterator.h                  | 6 +++---
 gdbsupport/observable.h                     | 6 +++---
 gdbsupport/offset-type.h                    | 6 +++---
 gdbsupport/packed.h                         | 6 +++---
 gdbsupport/pathstuff.h                      | 6 +++---
 gdbsupport/poison.h                         | 6 +++---
 gdbsupport/preprocessor.h                   | 6 +++---
 gdbsupport/print-utils.h                    | 6 +++---
 gdbsupport/ptid.h                           | 6 +++---
 gdbsupport/refcounted-object.h              | 6 +++---
 gdbsupport/rsp-low.h                        | 6 +++---
 gdbsupport/run-time-clock.h                 | 6 +++---
 gdbsupport/safe-iterator.h                  | 6 +++---
 gdbsupport/scope-exit.h                     | 6 +++---
 gdbsupport/scoped_fd.h                      | 6 +++---
 gdbsupport/scoped_ignore_signal.h           | 6 +++---
 gdbsupport/scoped_ignore_sigttou.h          | 6 +++---
 gdbsupport/scoped_mmap.h                    | 6 +++---
 gdbsupport/scoped_restore.h                 | 6 +++---
 gdbsupport/search.h                         | 6 +++---
 gdbsupport/selftest.h                       | 6 +++---
 gdbsupport/signals-state-save-restore.h     | 6 +++---
 gdbsupport/symbol.h                         | 6 +++---
 gdbsupport/tdesc.h                          | 6 +++---
 gdbsupport/traits.h                         | 6 +++---
 gdbsupport/underlying.h                     | 6 +++---
 gdbsupport/valid-expr.h                     | 6 +++---
 gdbsupport/version.h                        | 6 +++---
 gdbsupport/x86-xstate.h                     | 6 +++---
 gdbsupport/xml-utils.h                      | 6 +++---
 504 files changed, 1507 insertions(+), 1507 deletions(-)

diff --git a/gdb/aarch32-linux-nat.h b/gdb/aarch32-linux-nat.h
index 611c9fcfba9..79ad5adcef8 100644
--- a/gdb/aarch32-linux-nat.h
+++ b/gdb/aarch32-linux-nat.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH32_LINUX_NAT_H
-#define AARCH32_LINUX_NAT_H
+#ifndef GDB_AARCH32_LINUX_NAT_H
+#define GDB_AARCH32_LINUX_NAT_H
 
 void aarch32_gp_regcache_supply (struct regcache *regcache, uint32_t *regs,
 				 int arm_apcs_32);
@@ -31,4 +31,4 @@ void aarch32_vfp_regcache_collect (const struct regcache *regcache,
 				   gdb_byte *regs,
 				   const int vfp_register_count);
 
-#endif /* AARCH32_LINUX_NAT_H */
+#endif /* GDB_AARCH32_LINUX_NAT_H */
diff --git a/gdb/aarch32-tdep.h b/gdb/aarch32-tdep.h
index 009ee61890e..16ceb30a25f 100644
--- a/gdb/aarch32-tdep.h
+++ b/gdb/aarch32-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH32_TDEP_H
-#define AARCH32_TDEP_H
+#ifndef GDB_AARCH32_TDEP_H
+#define GDB_AARCH32_TDEP_H
 
 struct target_desc;
 
@@ -24,4 +24,4 @@ struct target_desc;
 
 const target_desc *aarch32_read_description (bool tls);
 
-#endif /* aarch32-tdep.h.  */
+#endif /* GDB_AARCH32_TDEP_H */
diff --git a/gdb/aarch64-fbsd-tdep.h b/gdb/aarch64-fbsd-tdep.h
index 56b15a94ee4..6d53b28386f 100644
--- a/gdb/aarch64-fbsd-tdep.h
+++ b/gdb/aarch64-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_FBSD_TDEP_H
-#define AARCH64_FBSD_TDEP_H
+#ifndef GDB_AARCH64_FBSD_TDEP_H
+#define GDB_AARCH64_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -39,4 +39,4 @@ extern const struct regset aarch64_fbsd_gregset;
 extern const struct regset aarch64_fbsd_fpregset;
 extern const struct regset aarch64_fbsd_tls_regset;
 
-#endif /* AARCH64_FBSD_TDEP_H */
+#endif /* GDB_AARCH64_FBSD_TDEP_H */
diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h
index 1961250e14f..4cca8e901a7 100644
--- a/gdb/aarch64-linux-tdep.h
+++ b/gdb/aarch64-linux-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_LINUX_TDEP_H
-#define AARCH64_LINUX_TDEP_H
+#ifndef GDB_AARCH64_LINUX_TDEP_H
+#define GDB_AARCH64_LINUX_TDEP_H
 
 #include "regset.h"
 
@@ -45,4 +45,4 @@ extern const struct regset aarch64_linux_fpregset;
 /* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h.  */
 #define AARCH64_HWCAP_PACA (1 << 30)
 
-#endif /* AARCH64_LINUX_TDEP_H */
+#endif /* GDB_AARCH64_LINUX_TDEP_H */
diff --git a/gdb/aarch64-nat.h b/gdb/aarch64-nat.h
index 947d2805602..33621c2643b 100644
--- a/gdb/aarch64-nat.h
+++ b/gdb/aarch64-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_NAT_H
-#define AARCH64_NAT_H
+#ifndef GDB_AARCH64_NAT_H
+#define GDB_AARCH64_NAT_H
 
 #include "breakpoint.h"
 #include "nat/aarch64-hw-point.h"
@@ -106,4 +106,4 @@ struct aarch64_nat_target : public BaseTarget
   { return start <= addr && start + length - 1 >= addr; }
 };
 
-#endif /* AARCH64_NAT_H */
+#endif /* GDB_AARCH64_NAT_H */
diff --git a/gdb/aarch64-ravenscar-thread.h b/gdb/aarch64-ravenscar-thread.h
index 2d2665627c5..9cf0113e635 100644
--- a/gdb/aarch64-ravenscar-thread.h
+++ b/gdb/aarch64-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_RAVENSCAR_THREAD_H
-#define AARCH64_RAVENSCAR_THREAD_H
+#ifndef GDB_AARCH64_RAVENSCAR_THREAD_H
+#define GDB_AARCH64_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_aarch64_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_AARCH64_RAVENSCAR_THREAD_H */
diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h
index 0e6024bfcbc..e1e9f43fd11 100644
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -19,8 +19,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef AARCH64_TDEP_H
-#define AARCH64_TDEP_H
+#ifndef GDB_AARCH64_TDEP_H
+#define GDB_AARCH64_TDEP_H
 
 #include "arch/aarch64.h"
 #include "displaced-stepping.h"
@@ -203,4 +203,4 @@ void aarch64_displaced_step_fixup (struct gdbarch *gdbarch,
 
 bool aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch);
 
-#endif /* aarch64-tdep.h */
+#endif /* GDB_AARCH64_TDEP_H */
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 94e4ea0f47e..0a59b343f14 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ADA_EXP_H
-#define ADA_EXP_H
+#ifndef GDB_ADA_EXP_H
+#define GDB_ADA_EXP_H
 
 #include "expop.h"
 
@@ -981,4 +981,4 @@ class ada_concat_operation : public concat_operation
 
 } /* namespace expr */
 
-#endif /* ADA_EXP_H */
+#endif /* GDB_ADA_EXP_H */
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 5083d004ac9..69c91b2e719 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (ADA_LANG_H)
-#define ADA_LANG_H 1
+#ifndef GDB_ADA_LANG_H
+#define GDB_ADA_LANG_H
 
 class frame_info_ptr;
 struct inferior;
@@ -435,4 +435,4 @@ extern block_symbol ada_resolve_variable (struct symbol *sym,
 extern struct type *ada_index_type (struct type *type, int n,
 				    const char *name);
 
-#endif
+#endif /* GDB_ADA_LANG_H */
diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index 5378b753760..a2ccc7b0cfd 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ADDRMAP_H
-#define ADDRMAP_H
+#ifndef GDB_ADDRMAP_H
+#define GDB_ADDRMAP_H
 
 #include "splay-tree.h"
 #include "gdbsupport/function-view.h"
@@ -222,4 +222,4 @@ struct addrmap_mutable final : public addrmap
 void addrmap_dump (struct addrmap *map, struct ui_file *outfile,
 		   void *payload);
 
-#endif /* ADDRMAP_H */
+#endif /* GDB_ADDRMAP_H */
diff --git a/gdb/alpha-bsd-tdep.h b/gdb/alpha-bsd-tdep.h
index 25ac043ba86..4783854eb47 100644
--- a/gdb/alpha-bsd-tdep.h
+++ b/gdb/alpha-bsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ALPHA_BSD_TDEP_H
-#define ALPHA_BSD_TDEP_H
+#ifndef GDB_ALPHA_BSD_TDEP_H
+#define GDB_ALPHA_BSD_TDEP_H
 
 #include "gdbarch.h"
 
@@ -39,4 +39,4 @@ void alphanbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					     void *cb_data,
 					     const struct regcache *regcache);
 
-#endif /* alpha-bsd-tdep.h */
+#endif /* GDB_ALPHA_BSD_TDEP_H */
diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h
index 0423abb2558..37c1eddf691 100644
--- a/gdb/alpha-tdep.h
+++ b/gdb/alpha-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ALPHA_TDEP_H
-#define ALPHA_TDEP_H
+#ifndef GDB_ALPHA_TDEP_H
+#define GDB_ALPHA_TDEP_H
 
 #include "gdbarch.h"
 
@@ -121,4 +121,4 @@ extern void alpha_supply_fp_regs (struct regcache *, int,
 extern void alpha_fill_fp_regs (const struct regcache *,
 				int, void *, void *);
 
-#endif /* ALPHA_TDEP_H */
+#endif /* GDB_ALPHA_TDEP_H */
diff --git a/gdb/amd-dbgapi-target.h b/gdb/amd-dbgapi-target.h
index f377fd0c57a..0a9cafaa7ee 100644
--- a/gdb/amd-dbgapi-target.h
+++ b/gdb/amd-dbgapi-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD_DBGAPI_TARGET_H
-#define AMD_DBGAPI_TARGET_H 1
+#ifndef GDB_AMD_DBGAPI_TARGET_H
+#define GDB_AMD_DBGAPI_TARGET_H
 
 #include "gdbsupport/observable.h"
 
@@ -113,4 +113,4 @@ get_status_string (amd_dbgapi_status_t status)
   return ret;
 }
 
-#endif /* AMD_DBGAPI_TARGET_H */
+#endif /* GDB_AMD_DBGAPI_TARGET_H */
diff --git a/gdb/amd64-bsd-nat.h b/gdb/amd64-bsd-nat.h
index b11356e0375..7ea26827625 100644
--- a/gdb/amd64-bsd-nat.h
+++ b/gdb/amd64-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_BSD_NAT_H
-#define AMD64_BSD_NAT_H
+#ifndef GDB_AMD64_BSD_NAT_H
+#define GDB_AMD64_BSD_NAT_H
 
 #include "x86-bsd-nat.h"
 
@@ -41,4 +41,4 @@ class amd64_bsd_nat_target : public x86bsd_nat_target<BaseTarget>
   { amd64bsd_store_inferior_registers (regcache, regnum); }
 };
 
-#endif /* i386-bsd-nat.h */
+#endif /* GDB_AMD64_BSD_NAT_H */
diff --git a/gdb/amd64-darwin-tdep.h b/gdb/amd64-darwin-tdep.h
index 19d92b61b90..c09cfe3229b 100644
--- a/gdb/amd64-darwin-tdep.h
+++ b/gdb/amd64-darwin-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_DARWIN_TDEP_H
-#define AMD64_DARWIN_TDEP_H
+#ifndef GDB_AMD64_DARWIN_TDEP_H
+#define GDB_AMD64_DARWIN_TDEP_H
 
 /* Mapping between the general-purpose registers in Darwin x86-64 thread
    state and GDB's register cache layout.
@@ -26,4 +26,4 @@
 extern int amd64_darwin_thread_state_reg_offset[];
 extern const int amd64_darwin_thread_state_num_regs;
 
-#endif /* AMD64_DARWIN_TDEP_H */
+#endif /* GDB_AMD64_DARWIN_TDEP_H */
diff --git a/gdb/amd64-fbsd-tdep.h b/gdb/amd64-fbsd-tdep.h
index 93b0ca901ce..7e8acc6959e 100644
--- a/gdb/amd64-fbsd-tdep.h
+++ b/gdb/amd64-fbsd-tdep.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_FBSD_TDEP_H
-#define AMD64_FBSD_TDEP_H
+#ifndef GDB_AMD64_FBSD_TDEP_H
+#define GDB_AMD64_FBSD_TDEP_H
 
 #include "regset.h"
 
 extern const struct regset amd64_fbsd_gregset;
 
-#endif /* AMD64_FBSD_TDEP_H */
+#endif /* GDB_AMD64_FBSD_TDEP_H */
diff --git a/gdb/amd64-linux-tdep.h b/gdb/amd64-linux-tdep.h
index 2003dcda78f..6ce0032040c 100644
--- a/gdb/amd64-linux-tdep.h
+++ b/gdb/amd64-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_LINUX_TDEP_H
-#define AMD64_LINUX_TDEP_H
+#ifndef GDB_AMD64_LINUX_TDEP_H
+#define GDB_AMD64_LINUX_TDEP_H
 
 /* Like for i386 GNU/Linux, there is an extra "register"
    used to control syscall restarting.  */
@@ -604,4 +604,4 @@ enum amd64_x32_syscall {
   amd64_x32_sys_getsockopt = (amd64_x32_syscall_bit + 542),
 };
 
-#endif /* amd64-linux-tdep.h */
+#endif /* GDB_AMD64_LINUX_TDEP_H */
diff --git a/gdb/amd64-nat.h b/gdb/amd64-nat.h
index b18ff8b1728..56ad36c9f1e 100644
--- a/gdb/amd64-nat.h
+++ b/gdb/amd64-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_NAT_H
-#define AMD64_NAT_H 1
+#ifndef GDB_AMD64_NAT_H
+#define GDB_AMD64_NAT_H
 
 struct regcache;
 
@@ -49,4 +49,4 @@ extern void amd64_supply_native_gregset (struct regcache *regcache,
 extern void amd64_collect_native_gregset (const struct regcache *regcache,
 					  void *gregs, int regnum);
 
-#endif /* amd64-nat.h */
+#endif /* GDB_AMD64_NAT_H */
diff --git a/gdb/amd64-ravenscar-thread.h b/gdb/amd64-ravenscar-thread.h
index 1a723600e7a..41e38327753 100644
--- a/gdb/amd64-ravenscar-thread.h
+++ b/gdb/amd64-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_RAVENSCAR_THREAD_H
-#define AMD64_RAVENSCAR_THREAD_H
+#ifndef GDB_AMD64_RAVENSCAR_THREAD_H
+#define GDB_AMD64_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_amd64_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif /* AMD64_RAVENSCAR_THREAD_H */
+#endif /* GDB_AMD64_RAVENSCAR_THREAD_H */
diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
index 696c65b4f1b..c964e26e6a3 100644
--- a/gdb/amd64-tdep.h
+++ b/gdb/amd64-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_TDEP_H
-#define AMD64_TDEP_H
+#ifndef GDB_AMD64_TDEP_H
+#define GDB_AMD64_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -144,4 +144,4 @@ extern int amd64nbsd_r_reg_offset[];
 /* Variables exported from amd64-obsd-tdep.c.  */
 extern int amd64obsd_r_reg_offset[];
 
-#endif /* amd64-tdep.h */
+#endif /* GDB_AMD64_TDEP_H */
diff --git a/gdb/amdgpu-tdep.h b/gdb/amdgpu-tdep.h
index 2656d18e727..16c7b83a679 100644
--- a/gdb/amdgpu-tdep.h
+++ b/gdb/amdgpu-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMDGPU_TDEP_H
-#define AMDGPU_TDEP_H
+#ifndef GDB_AMDGPU_TDEP_H
+#define GDB_AMDGPU_TDEP_H
 
 #include "gdbarch.h"
 
@@ -90,4 +90,4 @@ bool is_amdgpu_arch (struct gdbarch *gdbarch);
 
 amdgpu_gdbarch_tdep *get_amdgpu_gdbarch_tdep (gdbarch *arch);
 
-#endif /* AMDGPU_TDEP_H */
+#endif /* GDB_AMDGPU_TDEP_H */
diff --git a/gdb/annotate.h b/gdb/annotate.h
index b8ce63ff233..d730b2e8297 100644
--- a/gdb/annotate.h
+++ b/gdb/annotate.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ANNOTATE_H
-#define ANNOTATE_H
+#ifndef GDB_ANNOTATE_H
+#define GDB_ANNOTATE_H
 
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -132,4 +132,4 @@ extern void annotate_array_section_end (void);
 extern void (*deprecated_annotate_signalled_hook) (void);
 extern void (*deprecated_annotate_signal_hook) (void);
 
-#endif /* ANNOTATE_H */
+#endif /* GDB_ANNOTATE_H */
diff --git a/gdb/arc-linux-tdep.h b/gdb/arc-linux-tdep.h
index 20ed525fe7c..9fe4116984d 100644
--- a/gdb/arc-linux-tdep.h
+++ b/gdb/arc-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARC_LINUX_TDEP_H
-#define ARC_LINUX_TDEP_H
+#ifndef GDB_ARC_LINUX_TDEP_H
+#define GDB_ARC_LINUX_TDEP_H
 
 #include "gdbarch.h"
 #include "regset.h"
@@ -49,4 +49,4 @@ void arc_linux_collect_v2_regset (const struct regset *regset,
 				  const struct regcache *regcache,
 				  int regnum, void *v2_regs, size_t size);
 
-#endif /* ARC_LINUX_TDEP_H */
+#endif /* GDB_ARC_LINUX_TDEP_H */
diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
index c59490dec00..86a483d00c7 100644
--- a/gdb/arc-tdep.h
+++ b/gdb/arc-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARC_TDEP_H
-#define ARC_TDEP_H
+#ifndef GDB_ARC_TDEP_H
+#define GDB_ARC_TDEP_H
 
 /* Need disassemble_info.  */
 #include "dis-asm.h"
@@ -205,4 +205,4 @@ CORE_ADDR arc_insn_get_linear_next_pc (const struct arc_instruction &insn);
 arc_arch_features arc_arch_features_create (const bfd *abfd,
 					    const unsigned long mach);
 
-#endif /* ARC_TDEP_H */
+#endif /* GDB_ARC_TDEP_H */
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 2dcd8f6dc53..d70d0b670c0 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_UTILS_H
-#define ARCH_UTILS_H
+#ifndef GDB_ARCH_UTILS_H
+#define GDB_ARCH_UTILS_H
 
 #include "gdbarch.h"
 
@@ -325,4 +325,4 @@ extern enum return_value_convention default_gdbarch_return_value
       struct regcache *regcache, struct value **read_value,
       const gdb_byte *writebuf);
 
-#endif /* ARCH_UTILS_H */
+#endif /* GDB_ARCH_UTILS_H */
diff --git a/gdb/arch/aarch32.h b/gdb/arch/aarch32.h
index 1811b8a7a92..f3e70affb0b 100644
--- a/gdb/arch/aarch32.h
+++ b/gdb/arch/aarch32.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH32_H
-#define ARCH_AARCH32_H
+#ifndef GDB_ARCH_AARCH32_H
+#define GDB_ARCH_AARCH32_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -24,4 +24,4 @@
 
 target_desc *aarch32_create_target_description (bool tls);
 
-#endif /* aarch32.h.  */
+#endif /* GDB_ARCH_AARCH32_H */
diff --git a/gdb/arch/aarch64-insn.h b/gdb/arch/aarch64-insn.h
index e4ee5c74fbf..bd3a85f9686 100644
--- a/gdb/arch/aarch64-insn.h
+++ b/gdb/arch/aarch64-insn.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_INSN_H
-#define ARCH_AARCH64_INSN_H
+#ifndef GDB_ARCH_AARCH64_INSN_H
+#define GDB_ARCH_AARCH64_INSN_H
 
 extern bool aarch64_debug;
 
@@ -356,4 +356,4 @@ int aarch64_emit_load_store (uint32_t *buf, uint32_t size,
 			     struct aarch64_register rn,
 			     struct aarch64_memory_operand operand);
 
-#endif /* ARCH_AARCH64_INSN_H */
+#endif /* GDB_ARCH_AARCH64_INSN_H */
diff --git a/gdb/arch/aarch64-mte-linux.h b/gdb/arch/aarch64-mte-linux.h
index 460b10e05c9..d917dd1b1e3 100644
--- a/gdb/arch/aarch64-mte-linux.h
+++ b/gdb/arch/aarch64-mte-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_MTE_LINUX_H
-#define ARCH_AARCH64_MTE_LINUX_H
+#ifndef GDB_ARCH_AARCH64_MTE_LINUX_H
+#define GDB_ARCH_AARCH64_MTE_LINUX_H
 
 
 /* Feature check for Memory Tagging Extension.  */
@@ -80,4 +80,4 @@ extern void aarch64_mte_pack_tags (gdb::byte_vector &tags);
    first unpacked element.  Otherwise leave it in the unpacked vector.  */
 extern void aarch64_mte_unpack_tags (gdb::byte_vector &tags, bool skip_first);
 
-#endif /* ARCH_AARCH64_MTE_LINUX_H */
+#endif /* GDB_ARCH_AARCH64_MTE_LINUX_H */
diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h
index 4d2ace8f153..886f4a2dee8 100644
--- a/gdb/arch/aarch64-scalable-linux.h
+++ b/gdb/arch/aarch64-scalable-linux.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_SCALABLE_LINUX_H
-#define ARCH_AARCH64_SCALABLE_LINUX_H
+#ifndef GDB_ARCH_AARCH64_SCALABLE_LINUX_H
+#define GDB_ARCH_AARCH64_SCALABLE_LINUX_H
 
 #include "gdbsupport/common-regcache.h"
 
@@ -55,4 +55,4 @@
    is empty (zero).  Return FALSE otherwise.  */
 extern bool sve_state_is_empty (const struct reg_buffer_common *reg_buf);
 
-#endif /* ARCH_AARCH64_SCALABLE_LINUX_H */
+#endif /* GDB_ARCH_AARCH64_SCALABLE_LINUX_H */
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index b4c0111aeb4..f45a0e2f13e 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_H
-#define ARCH_AARCH64_H
+#ifndef GDB_ARCH_AARCH64_H
+#define GDB_ARCH_AARCH64_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -230,4 +230,4 @@ enum aarch64_regnum
 /* Size of the SME2 ZT0 register in bytes.  */
 #define AARCH64_SME2_ZT0_SIZE 64
 
-#endif /* ARCH_AARCH64_H */
+#endif /* GDB_ARCH_AARCH64_H */
diff --git a/gdb/arch/amd64.h b/gdb/arch/amd64.h
index 042d986a694..1c7a2bb26e9 100644
--- a/gdb/arch/amd64.h
+++ b/gdb/arch/amd64.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AMD64_H
-#define ARCH_AMD64_H
+#ifndef GDB_ARCH_AMD64_H
+#define GDB_ARCH_AMD64_H
 
 #include "gdbsupport/tdesc.h"
 #include <stdint.h>
@@ -24,4 +24,4 @@
 target_desc *amd64_create_target_description (uint64_t xcr0, bool is_x32,
 					      bool is_linux, bool segments);
 
-#endif /* ARCH_AMD64_H */
+#endif /* GDB_ARCH_AMD64_H */
diff --git a/gdb/arch/arc.h b/gdb/arch/arc.h
index 1a5a9b6b492..887431ea12a 100644
--- a/gdb/arch/arc.h
+++ b/gdb/arch/arc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARC_H
-#define ARCH_ARC_H
+#ifndef GDB_ARCH_ARC_H
+#define GDB_ARCH_ARC_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -84,4 +84,4 @@ const target_desc *arc_lookup_target_description
 #endif /* GDBSERVER */
 
 
-#endif /* ARCH_ARC_H */
+#endif /* GDB_ARCH_ARC_H */
diff --git a/gdb/arch/arm-get-next-pcs.h b/gdb/arch/arm-get-next-pcs.h
index 77bf0b566a8..7680373c638 100644
--- a/gdb/arch/arm-get-next-pcs.h
+++ b/gdb/arch/arm-get-next-pcs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_GET_NEXT_PCS_H
-#define ARCH_ARM_GET_NEXT_PCS_H
+#ifndef GDB_ARCH_ARM_GET_NEXT_PCS_H
+#define GDB_ARCH_ARM_GET_NEXT_PCS_H
 
 #include <vector>
 
@@ -65,4 +65,4 @@ void arm_get_next_pcs_ctor (struct arm_get_next_pcs *self,
 /* Find the next possible PCs after the current instruction executes.  */
 std::vector<CORE_ADDR> arm_get_next_pcs (struct arm_get_next_pcs *self);
 
-#endif /* ARCH_ARM_GET_NEXT_PCS_H */
+#endif /* GDB_ARCH_ARM_GET_NEXT_PCS_H */
diff --git a/gdb/arch/arm-linux.h b/gdb/arch/arm-linux.h
index 68862521bbc..39c73c34011 100644
--- a/gdb/arch/arm-linux.h
+++ b/gdb/arch/arm-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_LINUX_H
-#define ARCH_ARM_LINUX_H
+#ifndef GDB_ARCH_ARM_LINUX_H
+#define GDB_ARCH_ARM_LINUX_H
 
 /* The index to access CSPR in user_regs defined in GLIBC.  */
 #define ARM_CPSR_GREGNUM 16
@@ -79,4 +79,4 @@ struct arm_get_next_pcs;
 CORE_ADDR arm_linux_get_next_pcs_fixup (struct arm_get_next_pcs *self,
 					CORE_ADDR pc);
 
-#endif /* ARCH_ARM_LINUX_H */
+#endif /* GDB_ARCH_ARM_LINUX_H */
diff --git a/gdb/arch/arm.h b/gdb/arch/arm.h
index 34cf7ca79cf..7738d9c6611 100644
--- a/gdb/arch/arm.h
+++ b/gdb/arch/arm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_H
-#define ARCH_ARM_H
+#ifndef GDB_ARCH_ARM_H
+#define GDB_ARCH_ARM_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -227,4 +227,4 @@ target_desc *arm_create_target_description (arm_fp_type fp_type, bool tls);
 
 target_desc *arm_create_mprofile_target_description (arm_m_profile_type m_type);
 
-#endif /* ARCH_ARM_H */
+#endif /* GDB_ARCH_ARM_H */
diff --git a/gdb/arch/csky.h b/gdb/arch/csky.h
index 290bf97dd12..67b2f176114 100644
--- a/gdb/arch/csky.h
+++ b/gdb/arch/csky.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_CSKY_H
-#define ARCH_CSKY_H
+#ifndef GDB_ARCH_CSKY_H
+#define GDB_ARCH_CSKY_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -26,4 +26,4 @@
 
 target_desc_up csky_create_target_description (void);
 
-#endif /* ARCH_CSKY_H */
+#endif /* GDB_ARCH_CSKY_H */
diff --git a/gdb/arch/i386.h b/gdb/arch/i386.h
index d0519f1b551..1b5cc6e1095 100644
--- a/gdb/arch/i386.h
+++ b/gdb/arch/i386.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_I386_H
-#define ARCH_I386_H
+#ifndef GDB_ARCH_I386_H
+#define GDB_ARCH_I386_H
 
 #include "gdbsupport/tdesc.h"
 #include <stdint.h>
@@ -24,4 +24,4 @@
 target_desc *i386_create_target_description (uint64_t xcr0, bool is_linux,
 					     bool segments);
 
-#endif /* ARCH_I386_H */
+#endif /* GDB_ARCH_I386_H */
diff --git a/gdb/arch/loongarch.h b/gdb/arch/loongarch.h
index 7056d506bf4..07f37d8d7e8 100644
--- a/gdb/arch/loongarch.h
+++ b/gdb/arch/loongarch.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_LOONGARCH_H
-#define ARCH_LOONGARCH_H
+#ifndef GDB_ARCH_LOONGARCH_H
+#define GDB_ARCH_LOONGARCH_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -128,4 +128,4 @@ const target_desc *loongarch_lookup_target_description
 
 #endif /* GDBSERVER */
 
-#endif /* ARCH_LOONGARCH_H  */
+#endif /* GDB_ARCH_LOONGARCH_H */
diff --git a/gdb/arch/ppc-linux-common.h b/gdb/arch/ppc-linux-common.h
index 05704c8f898..1f72b295de8 100644
--- a/gdb/arch/ppc-linux-common.h
+++ b/gdb/arch/ppc-linux-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_PPC_LINUX_COMMON_H
-#define ARCH_PPC_LINUX_COMMON_H
+#ifndef GDB_ARCH_PPC_LINUX_COMMON_H
+#define GDB_ARCH_PPC_LINUX_COMMON_H
 
 struct target_desc;
 
@@ -75,4 +75,4 @@ const struct ppc_linux_features ppc_linux_no_features = {
 const struct target_desc * ppc_linux_match_description
 (struct ppc_linux_features features);
 
-#endif /* ARCH_PPC_LINUX_COMMON_H */
+#endif /* GDB_ARCH_PPC_LINUX_COMMON_H */
diff --git a/gdb/arch/ppc-linux-tdesc.h b/gdb/arch/ppc-linux-tdesc.h
index 0a022071c08..bde6ba225bd 100644
--- a/gdb/arch/ppc-linux-tdesc.h
+++ b/gdb/arch/ppc-linux-tdesc.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_PPC_LINUX_TDESC_H
-#define ARCH_PPC_LINUX_TDESC_H
+#ifndef GDB_ARCH_PPC_LINUX_TDESC_H
+#define GDB_ARCH_PPC_LINUX_TDESC_H
 
 struct target_desc;
 
@@ -43,4 +43,4 @@ extern const struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l;
 extern const struct target_desc *tdesc_powerpc_isa207_vsx64l;
 extern const struct target_desc *tdesc_powerpc_isa207_htm_vsx64l;
 
-#endif /* ARCH_PPC_LINUX_TDESC_H */
+#endif /* GDB_ARCH_PPC_LINUX_TDESC_H */
diff --git a/gdb/arch/riscv.h b/gdb/arch/riscv.h
index 925fffee18a..bf65b0bc5a8 100644
--- a/gdb/arch/riscv.h
+++ b/gdb/arch/riscv.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_RISCV_H
-#define ARCH_RISCV_H
+#ifndef GDB_ARCH_RISCV_H
+#define GDB_ARCH_RISCV_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -119,4 +119,4 @@ const target_desc *riscv_lookup_target_description
 #endif /* GDBSERVER */
 
 
-#endif /* ARCH_RISCV_H */
+#endif /* GDB_ARCH_RISCV_H */
diff --git a/gdb/arch/tic6x.h b/gdb/arch/tic6x.h
index da67da7c5fb..efb3282c506 100644
--- a/gdb/arch/tic6x.h
+++ b/gdb/arch/tic6x.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_TIC6X_H
-#define ARCH_TIC6X_H
+#ifndef GDB_ARCH_TIC6X_H
+#define GDB_ARCH_TIC6X_H
 
 enum c6x_feature
 {
@@ -28,4 +28,4 @@ enum c6x_feature
 
 target_desc *tic6x_create_target_description (enum c6x_feature feature);
 
-#endif /* ARCH_TIC6X_H */
+#endif /* GDB_ARCH_TIC6X_H */
diff --git a/gdb/arch/xtensa.h b/gdb/arch/xtensa.h
index 5961641cad8..70167b304ce 100644
--- a/gdb/arch/xtensa.h
+++ b/gdb/arch/xtensa.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_XTENSA_H
-#define ARCH_XTENSA_H
+#ifndef GDB_ARCH_XTENSA_H
+#define GDB_ARCH_XTENSA_H
 
 /* Xtensa ELF core file register set representation ('.reg' section).
    Copied from target-side ELF header <xtensa/elf.h>.  */
@@ -45,4 +45,4 @@ typedef struct
 
 #define C0_NREGS   16	/* Number of A-registers to track in call0 ABI.  */
 
-#endif /* ARCH_XTENSA_H */
+#endif /* GDB_ARCH_XTENSA_H */
diff --git a/gdb/arm-fbsd-tdep.h b/gdb/arm-fbsd-tdep.h
index 26a9dbcdd21..151f26c83b7 100644
--- a/gdb/arm-fbsd-tdep.h
+++ b/gdb/arm-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_FBSD_TDEP_H
-#define ARM_FBSD_TDEP_H
+#ifndef GDB_ARM_FBSD_TDEP_H
+#define GDB_ARM_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -56,4 +56,4 @@ extern const struct target_desc *
 extern const struct target_desc *
   arm_fbsd_read_description_auxv (bool tls);
 
-#endif /* ARM_FBSD_TDEP_H */
+#endif /* GDB_ARM_FBSD_TDEP_H */
diff --git a/gdb/arm-linux-tdep.h b/gdb/arm-linux-tdep.h
index a6eeb333351..7aa69ce3f4c 100644
--- a/gdb/arm-linux-tdep.h
+++ b/gdb/arm-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_LINUX_TDEP_H
-#define ARM_LINUX_TDEP_H
+#ifndef GDB_ARM_LINUX_TDEP_H
+#define GDB_ARM_LINUX_TDEP_H
 
 struct regset;
 struct regcache;
@@ -67,4 +67,4 @@ void arm_linux_collect_nwfpe (const struct regset *regset,
 #define HWCAP_VFPv3     8192
 #define HWCAP_VFPv3D16  16384
 
-#endif /* ARM_LINUX_TDEP_H */
+#endif /* GDB_ARM_LINUX_TDEP_H */
diff --git a/gdb/arm-netbsd-tdep.h b/gdb/arm-netbsd-tdep.h
index 75b1fb9bd27..6e554d4ca21 100644
--- a/gdb/arm-netbsd-tdep.h
+++ b/gdb/arm-netbsd-tdep.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_NBSD_TDEP_H
-#define ARM_NBSD_TDEP_H
+#ifndef GDB_ARM_NETBSD_TDEP_H
+#define GDB_ARM_NETBSD_TDEP_H
 
 void arm_nbsd_supply_gregset
   (const struct regset *regset, struct regcache *regcache,
    int regnum, const void *gregs, size_t len);
 
-#endif
+#endif /* GDB_ARM_NETBSD_TDEP_H */
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 11839b0ff4d..f8049f4673c 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_TDEP_H
-#define ARM_TDEP_H
+#ifndef GDB_ARM_TDEP_H
+#define GDB_ARM_TDEP_H
 
 /* Forward declarations.  */
 struct regset;
@@ -326,4 +326,4 @@ const target_desc *arm_read_description (arm_fp_type fp_type, bool tls);
    type.  */
 const target_desc *arm_read_mprofile_description (arm_m_profile_type m_type);
 
-#endif /* arm-tdep.h */
+#endif /* GDB_ARM_TDEP_H */
diff --git a/gdb/async-event.h b/gdb/async-event.h
index 1027f9d6fb3..16045f42448 100644
--- a/gdb/async-event.h
+++ b/gdb/async-event.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ASYNC_EVENT_H
-#define ASYNC_EVENT_H
+#ifndef GDB_ASYNC_EVENT_H
+#define GDB_ASYNC_EVENT_H
 
 #include "gdbsupport/event-loop.h"
 
@@ -87,4 +87,4 @@ extern void clear_async_event_handler (struct async_event_handler *handler);
 
 extern void initialize_async_signal_handlers (void);
 
-#endif /* ASYNC_EVENT_H */
+#endif /* GDB_ASYNC_EVENT_H */
diff --git a/gdb/auto-load.h b/gdb/auto-load.h
index c1003aef0e3..48e6ccfc82f 100644
--- a/gdb/auto-load.h
+++ b/gdb/auto-load.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AUTO_LOAD_H
-#define AUTO_LOAD_H 1
+#ifndef GDB_AUTO_LOAD_H
+#define GDB_AUTO_LOAD_H
 
 struct objfile;
 struct program_space;
@@ -79,4 +79,4 @@ extern bool file_is_auto_load_safe (const char *filename);
 extern bool auto_load_gdb_scripts_enabled
   (const struct extension_language_defn *extlang);
 
-#endif /* AUTO_LOAD_H */
+#endif /* GDB_AUTO_LOAD_H */
diff --git a/gdb/auxv.h b/gdb/auxv.h
index aed430dd851..3faddff7771 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AUXV_H
-#define AUXV_H
+#ifndef GDB_AUXV_H
+#define GDB_AUXV_H
 
 #include "target.h"
 
@@ -88,4 +88,4 @@ extern void default_print_auxv_entry (struct gdbarch *gdbarch,
 extern target_xfer_partial_ftype memory_xfer_auxv;
 
 
-#endif
+#endif /* GDB_AUXV_H */
diff --git a/gdb/ax-gdb.h b/gdb/ax-gdb.h
index 9e2dfea1c51..53f48ff9e33 100644
--- a/gdb/ax-gdb.h
+++ b/gdb/ax-gdb.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AX_GDB_H
-#define AX_GDB_H
+#ifndef GDB_AX_GDB_H
+#define GDB_AX_GDB_H
 
 #include "ax.h"
 
@@ -123,4 +123,4 @@ extern agent_expr_up gen_printf (CORE_ADDR, struct gdbarch *,
 				 CORE_ADDR, LONGEST, const char *, int,
 				 int, struct expression **);
 
-#endif /* AX_GDB_H */
+#endif /* GDB_AX_GDB_H */
diff --git a/gdb/ax.h b/gdb/ax.h
index 46c2393f9e0..45fd560927b 100644
--- a/gdb/ax.h
+++ b/gdb/ax.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AX_H
-#define AX_H
+#ifndef GDB_AX_H
+#define GDB_AX_H
 
 /* It's sometimes useful to be able to debug programs that you can't
    really stop for more than a fraction of a second.  To this end, the
@@ -224,4 +224,4 @@ extern void ax_print (struct ui_file *f, struct agent_expr * EXPR);
 
 extern void ax_reqs (struct agent_expr *ax);
 
-#endif /* AX_H */
+#endif /* GDB_AX_H */
diff --git a/gdb/bcache.h b/gdb/bcache.h
index 17a09880d99..abe9e58c116 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BCACHE_H
-#define BCACHE_H 1
+#ifndef GDB_BCACHE_H
+#define GDB_BCACHE_H
 
 /* A bcache is a data structure for factoring out duplication in
    read-only structures.  You give the bcache some string of bytes S.
@@ -207,4 +207,4 @@ struct bcache
 
 } /* namespace gdb */
 
-#endif /* BCACHE_H */
+#endif /* GDB_BCACHE_H */
diff --git a/gdb/bfd-target.h b/gdb/bfd-target.h
index d20c9263c4b..ab3233e8f6f 100644
--- a/gdb/bfd-target.h
+++ b/gdb/bfd-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BFD_TARGET_H
-#define BFD_TARGET_H
+#ifndef GDB_BFD_TARGET_H
+#define GDB_BFD_TARGET_H
 
 #include "gdb_bfd.h"
 
@@ -27,4 +27,4 @@ struct target_ops;
 /* Given an existing BFD, re-open it as a "struct target_ops".  */
 target_ops_up target_bfd_reopen (const gdb_bfd_ref_ptr &bfd);
 
-#endif
+#endif /* GDB_BFD_TARGET_H */
diff --git a/gdb/bfin-tdep.h b/gdb/bfin-tdep.h
index dbdafae9d45..d28af50406f 100644
--- a/gdb/bfin-tdep.h
+++ b/gdb/bfin-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BFIN_TDEP_H
-#define BFIN_TDEP_H
+#ifndef GDB_BFIN_TDEP_H
+#define GDB_BFIN_TDEP_H
 
 #include "gdbarch.h"
 
@@ -105,4 +105,4 @@ struct bfin_gdbarch_tdep : gdbarch_tdep_base
 /* Return the Blackfin ABI associated with GDBARCH.  */
 extern enum bfin_abi bfin_abi (struct gdbarch *gdbarch);
 
-#endif /* BFIN_TDEP_H */
+#endif /* GDB_BFIN_TDEP_H */
diff --git a/gdb/block.h b/gdb/block.h
index ae676c4ba67..0cc4d7d53f7 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BLOCK_H
-#define BLOCK_H
+#ifndef GDB_BLOCK_H
+#define GDB_BLOCK_H
 
 #include "dictionary.h"
 #include "gdbsupport/array-view.h"
@@ -592,4 +592,4 @@ extern struct symbol *block_find_symbol (const struct block *block,
 struct blockranges *make_blockranges (struct objfile *objfile,
 				      const std::vector<blockrange> &rangevec);
 
-#endif /* BLOCK_H */
+#endif /* GDB_BLOCK_H */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 6da04d5ec00..4db18274e55 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (BREAKPOINT_H)
-#define BREAKPOINT_H 1
+#ifndef GDB_BREAKPOINT_H
+#define GDB_BREAKPOINT_H
 
 #include "frame.h"
 #include "value.h"
@@ -2068,4 +2068,4 @@ extern void enable_disable_bp_location (bp_location *loc, bool enable);
 
 extern void notify_breakpoint_modified (breakpoint *b);
 
-#endif /* !defined (BREAKPOINT_H) */
+#endif /* GDB_BREAKPOINT_H */
diff --git a/gdb/bsd-kvm.h b/gdb/bsd-kvm.h
index 1606eb3acea..6ddd154da4a 100644
--- a/gdb/bsd-kvm.h
+++ b/gdb/bsd-kvm.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BSD_KVM_H
-#define BSD_KVM_H
+#ifndef GDB_BSD_KVM_H
+#define GDB_BSD_KVM_H
 
 struct pcb;
 struct regcache;
@@ -30,4 +30,4 @@ struct regcache;
 extern void
   bsd_kvm_add_target (int (*supply_pcb)(struct regcache *, struct pcb *));
 
-#endif /* bsd-kvm.h */
+#endif /* GDB_BSD_KVM_H */
diff --git a/gdb/bsd-uthread.h b/gdb/bsd-uthread.h
index eabd82dbdaf..e236eaae4f6 100644
--- a/gdb/bsd-uthread.h
+++ b/gdb/bsd-uthread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BSD_UTHREAD_H
-#define BSD_UTHREAD_H 1
+#ifndef GDB_BSD_UTHREAD_H
+#define GDB_BSD_UTHREAD_H
 
 /* Set the function that supplies registers for an inactive thread for
    architecture GDBARCH to SUPPLY_UTHREAD.  */
@@ -35,4 +35,4 @@ extern void bsd_uthread_set_collect_uthread (struct gdbarch *gdbarch,
 			     void (*collect_uthread) (const struct regcache *,
 						      int, CORE_ADDR));
 
-#endif /* bsd-uthread.h */
+#endif /* GDB_BSD_UTHREAD_H */
diff --git a/gdb/bt-utils.h b/gdb/bt-utils.h
index ec2d14a5484..819dd8caf86 100644
--- a/gdb/bt-utils.h
+++ b/gdb/bt-utils.h
@@ -18,8 +18,8 @@
 /* Support for printing a backtrace when GDB hits an error.  This is not
    for printing backtraces of the inferior, but backtraces of GDB itself.  */
 
-#ifndef BT_UTILS_H
-#define BT_UTILS_H
+#ifndef GDB_BT_UTILS_H
+#define GDB_BT_UTILS_H
 
 #ifdef HAVE_LIBBACKTRACE
 # include "backtrace.h"
@@ -71,4 +71,4 @@ extern void gdb_internal_backtrace ();
 extern void gdb_internal_backtrace_set_cmd (const char *args, int from_tty,
 					    cmd_list_element *c);
 
-#endif /* BT_UTILS_H */
+#endif /* GDB_BT_UTILS_H */
diff --git a/gdb/btrace.h b/gdb/btrace.h
index f05ec2bca04..dc9541960e0 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BTRACE_H
-#define BTRACE_H
+#ifndef GDB_BTRACE_H
+#define GDB_BTRACE_H
 
 /* Branch tracing (btrace) is a per-thread control-flow execution trace of the
    inferior.  For presentation purposes, the branch trace is represented as a
@@ -498,4 +498,4 @@ extern int btrace_is_replaying (struct thread_info *tp);
 /* Return non-zero if the branch trace for TP is empty; zero otherwise.  */
 extern int btrace_is_empty (struct thread_info *tp);
 
-#endif /* BTRACE_H */
+#endif /* GDB_BTRACE_H */
diff --git a/gdb/build-id.h b/gdb/build-id.h
index 15bd8a964dc..5bf338299b1 100644
--- a/gdb/build-id.h
+++ b/gdb/build-id.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BUILD_ID_H
-#define BUILD_ID_H
+#ifndef GDB_BUILD_ID_H
+#define GDB_BUILD_ID_H
 
 #include "gdb_bfd.h"
 #include "gdbsupport/rsp-low.h"
@@ -70,4 +70,4 @@ build_id_to_string (const bfd_build_id *build_id)
   return bin2hex (build_id->data, build_id->size);
 }
 
-#endif /* BUILD_ID_H */
+#endif /* GDB_BUILD_ID_H */
diff --git a/gdb/buildsym-legacy.h b/gdb/buildsym-legacy.h
index 1fb545831b8..1f032c42751 100644
--- a/gdb/buildsym-legacy.h
+++ b/gdb/buildsym-legacy.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BUILDSYM_LEGACY_H
-#define BUILDSYM_LEGACY_H
+#ifndef GDB_BUILDSYM_LEGACY_H
+#define GDB_BUILDSYM_LEGACY_H
 
 #include "buildsym.h"
 
@@ -144,4 +144,4 @@ extern struct pending **get_global_symbols ();
 
 extern struct buildsym_compunit *get_buildsym_compunit ();
 
-#endif /* BUILDSYM_LEGACY_H */
+#endif /* GDB_BUILDSYM_LEGACY_H */
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index c1eed247d25..974645c1c47 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (BUILDSYM_H)
-#define BUILDSYM_H 1
+#ifndef GDB_BUILDSYM_H
+#define GDB_BUILDSYM_H
 
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
@@ -456,4 +456,4 @@ extern void add_symbol_to_list (struct symbol *symbol,
 extern struct symbol *find_symbol_in_list (struct pending *list,
 					   char *name, int length);
 
-#endif /* defined (BUILDSYM_H) */
+#endif /* GDB_BUILDSYM_H */
diff --git a/gdb/c-exp.h b/gdb/c-exp.h
index a76f1bc8213..a6c084d32be 100644
--- a/gdb/c-exp.h
+++ b/gdb/c-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef C_EXP_H
-#define C_EXP_H
+#ifndef GDB_C_EXP_H
+#define GDB_C_EXP_H
 
 #include "expop.h"
 #include "objc-lang.h"
@@ -217,4 +217,4 @@ class opencl_ternop_cond_operation
 
 }/* namespace expr */
 
-#endif /* C_EXP_H */
+#endif /* GDB_C_EXP_H */
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 8dc47ac8be5..0e733d810d8 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#if !defined (C_LANG_H)
-#define C_LANG_H 1
+#ifndef GDB_C_LANG_H
+#define GDB_C_LANG_H
 
 struct ui_file;
 struct language_arch_info;
@@ -174,4 +174,4 @@ extern std::string cplus_compute_program (compile_instance *inst,
 
 extern gdb::unique_xmalloc_ptr<char> c_canonicalize_name (const char *name);
 
-#endif /* !defined (C_LANG_H) */
+#endif /* GDB_C_LANG_H */
diff --git a/gdb/c-support.h b/gdb/c-support.h
index 3718181ba81..30858d1e1af 100644
--- a/gdb/c-support.h
+++ b/gdb/c-support.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef C_SUPPORT_H
-#define C_SUPPORT_H
+#ifndef GDB_C_SUPPORT_H
+#define GDB_C_SUPPORT_H
 
 #include "safe-ctype.h"
 
@@ -43,4 +43,4 @@ c_ident_is_alnum (unsigned char ch)
   return ISALNUM (ch) || ch >= 0x80;
 }
 
-#endif /* C_SUPPORT_H */
+#endif /* GDB_C_SUPPORT_H */
diff --git a/gdb/cgen-remap.h b/gdb/cgen-remap.h
index 35f09c1269b..30b84575263 100644
--- a/gdb/cgen-remap.h
+++ b/gdb/cgen-remap.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CGEN_REMAP_H
-#define CGEN_REMAP_H
+#ifndef GDB_CGEN_REMAP_H
+#define GDB_CGEN_REMAP_H
 
 /* Remap cgen interface names, so we can have multiple cgen generated include
    files in gdb without violating c++ ODR.  */
@@ -50,4 +50,4 @@
 #define CGEN_OPERAND		GDB_CGEN_REMAP (CGEN_OPERAND)
 #define CGEN_MAYBE_MULTI_IFLD	GDB_CGEN_REMAP (CGEN_MAYBE_MULTI_IFLD)
 
-#endif /* CGEN_REMAP_H */
+#endif /* GDB_CGEN_REMAP_H */
diff --git a/gdb/charset-list.h b/gdb/charset-list.h
index c4d0867d580..9da3da2590a 100644
--- a/gdb/charset-list.h
+++ b/gdb/charset-list.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CHARSET_LIST_H
-#define CHARSET_LIST_H
+#ifndef GDB_CHARSET_LIST_H
+#define GDB_CHARSET_LIST_H
 
 /* Note that the first entry must always be "auto".
    The remaining entries were created by running this script:
@@ -1192,4 +1192,4 @@
 "WS2", \
 "YU",
 
-#endif /* CHARSET_LIST_H */
+#endif /* GDB_CHARSET_LIST_H */
diff --git a/gdb/charset.h b/gdb/charset.h
index 4263dc147e9..c4e0de553d3 100644
--- a/gdb/charset.h
+++ b/gdb/charset.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CHARSET_H
-#define CHARSET_H
+#ifndef GDB_CHARSET_H
+#define GDB_CHARSET_H
 
 #include "gdbsupport/def-vector.h"
 
@@ -165,4 +165,4 @@ char host_letter_to_control_character (char c);
 #define HOST_UTF32 "UTF-32LE"
 #endif
 
-#endif /* CHARSET_H */
+#endif /* GDB_CHARSET_H */
diff --git a/gdb/cli-out.h b/gdb/cli-out.h
index f17cb0c9856..5799df559f4 100644
--- a/gdb/cli-out.h
+++ b/gdb/cli-out.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_OUT_H
-#define CLI_OUT_H
+#ifndef GDB_CLI_OUT_H
+#define GDB_CLI_OUT_H
 
 #include "ui-out.h"
 #include <chrono>
@@ -112,4 +112,4 @@ class cli_ui_out : public ui_out
 
 extern void cli_display_match_list (char **matches, int len, int max);
 
-#endif
+#endif /* GDB_CLI_OUT_H */
diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h
index 8f26ca3e17a..6719ad7cae3 100644
--- a/gdb/cli/cli-cmds.h
+++ b/gdb/cli/cli-cmds.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_CMDS_H
-#define CLI_CLI_CMDS_H
+#ifndef GDB_CLI_CLI_CMDS_H
+#define GDB_CLI_CLI_CMDS_H
 
 #include "gdbsupport/filestuff.h"
 #include <optional>
@@ -202,4 +202,4 @@ extern void with_command_completer_1 (const char *set_cmd_prefix,
 				      completion_tracker &tracker,
 				      const char *text);
 
-#endif /* CLI_CLI_CMDS_H */
+#endif /* GDB_CLI_CLI_CMDS_H */
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 7365c3f0157..2219d62fbf3 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_DECODE_H
-#define CLI_CLI_DECODE_H
+#ifndef GDB_CLI_CLI_DECODE_H
+#define GDB_CLI_CLI_DECODE_H
 
 /* This file defines the private interfaces for any code implementing
    command internals.  */
@@ -313,4 +313,4 @@ extern int cli_user_command_p (struct cmd_list_element *);
 
 extern int find_command_name_length (const char *);
 
-#endif /* CLI_CLI_DECODE_H */
+#endif /* GDB_CLI_CLI_DECODE_H */
diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h
index 137eb466f6b..fc3dee7b68b 100644
--- a/gdb/cli/cli-interp.h
+++ b/gdb/cli/cli-interp.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_INTERP_H
-#define CLI_CLI_INTERP_H
+#ifndef GDB_CLI_CLI_INTERP_H
+#define GDB_CLI_CLI_INTERP_H
 
 #include "interps.h"
 
@@ -69,4 +69,4 @@ class cli_interp_base : public interp
 extern int should_print_stop_to_console (struct interp *interp,
 					 struct thread_info *tp);
 
-#endif /* CLI_CLI_INTERP_H */
+#endif /* GDB_CLI_CLI_INTERP_H */
diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h
index bbe281d9721..35e5bdcd684 100644
--- a/gdb/cli/cli-option.h
+++ b/gdb/cli/cli-option.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_OPTION_H
-#define CLI_OPTION_H 1
+#ifndef GDB_CLI_CLI_OPTION_H
+#define GDB_CLI_CLI_OPTION_H
 
 #include <optional>
 #include "gdbsupport/array-view.h"
@@ -379,4 +379,4 @@ extern void add_setshow_cmds_for_options (command_class cmd_class, void *data,
 } /* namespace option */
 } /* namespace gdb */
 
-#endif /* CLI_OPTION_H */
+#endif /* GDB_CLI_CLI_OPTION_H */
diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h
index d36743e5a31..1f0cfd3c1dd 100644
--- a/gdb/cli/cli-script.h
+++ b/gdb/cli/cli-script.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_SCRIPT_H
-#define CLI_CLI_SCRIPT_H
+#ifndef GDB_CLI_CLI_SCRIPT_H
+#define GDB_CLI_CLI_SCRIPT_H
 
 #include "gdbsupport/function-view.h"
 
@@ -181,4 +181,4 @@ extern void print_command_trace (const char *cmd, ...)
 
 extern void reset_command_nest_depth (void);
 
-#endif /* CLI_CLI_SCRIPT_H */
+#endif /* GDB_CLI_CLI_SCRIPT_H */
diff --git a/gdb/cli/cli-setshow.h b/gdb/cli/cli-setshow.h
index 4b8875d5794..9eac86fc674 100644
--- a/gdb/cli/cli-setshow.h
+++ b/gdb/cli/cli-setshow.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_SETSHOW_H
-#define CLI_CLI_SETSHOW_H
+#ifndef GDB_CLI_CLI_SETSHOW_H
+#define GDB_CLI_CLI_SETSHOW_H
 
 #include <string>
 
@@ -60,4 +60,4 @@ extern std::string get_setshow_command_value_string (const setting &var);
 
 extern void cmd_show_list (struct cmd_list_element *list, int from_tty);
 
-#endif /* CLI_CLI_SETSHOW_H */
+#endif /* GDB_CLI_CLI_SETSHOW_H */
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index 31d40ed65ca..1a9c8e65b60 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_STYLE_H
-#define CLI_CLI_STYLE_H
+#ifndef GDB_CLI_CLI_STYLE_H
+#define GDB_CLI_CLI_STYLE_H
 
 #include "ui-file.h"
 #include "command.h"
@@ -150,4 +150,4 @@ extern bool disassembler_styling;
 /* True if styling is enabled.  */
 extern bool cli_styling;
 
-#endif /* CLI_CLI_STYLE_H */
+#endif /* GDB_CLI_CLI_STYLE_H */
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index 54b45fdc796..e11430ecb70 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_UTILS_H
-#define CLI_CLI_UTILS_H
+#ifndef GDB_CLI_CLI_UTILS_H
+#define GDB_CLI_CLI_UTILS_H
 
 #include "completer.h"
 
@@ -225,4 +225,4 @@ struct qcs_flags
    message.  */
 extern void validate_flags_qcs (const char *which_command, qcs_flags *flags);
 
-#endif /* CLI_CLI_UTILS_H */
+#endif /* GDB_CLI_CLI_UTILS_H */
diff --git a/gdb/coff-pe-read.h b/gdb/coff-pe-read.h
index d596240f97d..c1510460f9b 100644
--- a/gdb/coff-pe-read.h
+++ b/gdb/coff-pe-read.h
@@ -19,8 +19,8 @@
 
    Contributed by Raoul M. Gough (RaoulGough@yahoo.co.uk).  */
 
-#if !defined (COFF_PE_READ_H)
-#define COFF_PE_READ_H
+#ifndef GDB_COFF_PE_READ_H
+#define GDB_COFF_PE_READ_H
 
 class minimal_symbol_reader;
 struct objfile;
@@ -35,4 +35,4 @@ extern void read_pe_exported_syms (minimal_symbol_reader &reader,
    Returns default value 0x1000 if information is not found.  */
 extern CORE_ADDR pe_text_section_offset (struct bfd *abfd);
 
-#endif /* !defined (COFF_PE_READ_H) */
+#endif /* GDB_COFF_PE_READ_H */
diff --git a/gdb/command.h b/gdb/command.h
index 615f4e524aa..4f83d3515c3 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (COMMAND_H)
-#define COMMAND_H 1
+#ifndef GDB_COMMAND_H
+#define GDB_COMMAND_H
 
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbsupport/scoped_restore.h"
@@ -934,4 +934,4 @@ extern void not_just_help_class_command (const char *, int);
 extern void cmd_func (struct cmd_list_element *cmd,
 		      const char *args, int from_tty);
 
-#endif /* !defined (COMMAND_H) */
+#endif /* GDB_COMMAND_H */
diff --git a/gdb/compile/compile-c.h b/gdb/compile/compile-c.h
index 4670d671a9f..b77b7aab087 100644
--- a/gdb/compile/compile-c.h
+++ b/gdb/compile/compile-c.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_C_H
-#define COMPILE_COMPILE_C_H
+#ifndef GDB_COMPILE_COMPILE_C_H
+#define GDB_COMPILE_COMPILE_C_H
 
 #include "compile/compile.h"
 #include "gdbsupport/enum-flags.h"
@@ -93,4 +93,4 @@ extern std::string c_get_range_decl_name (const struct dynamic_prop *prop);
 extern gdb::unique_xmalloc_ptr<char>
   c_symbol_substitution_name (struct symbol *sym);
 
-#endif /* COMPILE_COMPILE_C_H */
+#endif /* GDB_COMPILE_COMPILE_C_H */
diff --git a/gdb/compile/compile-cplus.h b/gdb/compile/compile-cplus.h
index a714b6dab3c..d3b2d3e9843 100644
--- a/gdb/compile/compile-cplus.h
+++ b/gdb/compile/compile-cplus.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_CPLUS_H
-#define COMPILE_COMPILE_CPLUS_H
+#ifndef GDB_COMPILE_COMPILE_CPLUS_H
+#define GDB_COMPILE_COMPILE_CPLUS_H
 
 #include "compile/compile.h"
 #include "gdbsupport/enum-flags.h"
@@ -204,4 +204,4 @@ class compile_cplus_instance : public compile_instance
 enum gcc_cp_symbol_kind get_method_access_flag (const struct type *type,
 						int fni, int num);
 
-#endif /* COMPILE_COMPILE_CPLUS_H */
+#endif /* GDB_COMPILE_COMPILE_CPLUS_H */
diff --git a/gdb/compile/compile-internal.h b/gdb/compile/compile-internal.h
index 666406b2395..f4cc9ee4984 100644
--- a/gdb/compile/compile-internal.h
+++ b/gdb/compile/compile-internal.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_INTERNAL_H
-#define COMPILE_COMPILE_INTERNAL_H
+#ifndef GDB_COMPILE_COMPILE_INTERNAL_H
+#define GDB_COMPILE_COMPILE_INTERNAL_H
 
 #include "gcc-c-interface.h"
 #include "gdbsupport/gdb-hashtab.h"
@@ -80,4 +80,4 @@ class compile_file_names
   std::string m_object_file;
 };
 
-#endif /* COMPILE_COMPILE_INTERNAL_H */
+#endif /* GDB_COMPILE_COMPILE_INTERNAL_H */
diff --git a/gdb/compile/compile-object-load.h b/gdb/compile/compile-object-load.h
index eb6eb0dd871..bb414f90df4 100644
--- a/gdb/compile/compile-object-load.h
+++ b/gdb/compile/compile-object-load.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_OBJECT_LOAD_H
-#define COMPILE_COMPILE_OBJECT_LOAD_H
+#ifndef GDB_COMPILE_COMPILE_OBJECT_LOAD_H
+#define GDB_COMPILE_COMPILE_OBJECT_LOAD_H
 
 #include "compile-internal.h"
 #include <list>
@@ -94,4 +94,4 @@ extern compile_module_up compile_object_load
   (const compile_file_names &fnames,
    enum compile_i_scope_types scope, void *scope_data);
 
-#endif /* COMPILE_COMPILE_OBJECT_LOAD_H */
+#endif /* GDB_COMPILE_COMPILE_OBJECT_LOAD_H */
diff --git a/gdb/compile/compile-object-run.h b/gdb/compile/compile-object-run.h
index 5d9f23c6a39..64b2bd90a99 100644
--- a/gdb/compile/compile-object-run.h
+++ b/gdb/compile/compile-object-run.h
@@ -14,11 +14,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_OBJECT_RUN_H
-#define COMPILE_COMPILE_OBJECT_RUN_H
+#ifndef GDB_COMPILE_COMPILE_OBJECT_RUN_H
+#define GDB_COMPILE_COMPILE_OBJECT_RUN_H
 
 #include "compile-object-load.h"
 
 extern void compile_object_run (compile_module_up &&module);
 
-#endif /* COMPILE_COMPILE_OBJECT_RUN_H */
+#endif /* GDB_COMPILE_COMPILE_OBJECT_RUN_H */
diff --git a/gdb/compile/compile.h b/gdb/compile/compile.h
index d584df6661c..14b97c4b91c 100644
--- a/gdb/compile/compile.h
+++ b/gdb/compile/compile.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_H
-#define COMPILE_COMPILE_H
+#ifndef GDB_COMPILE_COMPILE_H
+#define GDB_COMPILE_COMPILE_H
 
 #include "gcc-c-interface.h"
 
@@ -231,4 +231,4 @@ extern void compile_print_value (struct value *val, void *data_voidp);
 /* Command element for the 'compile' command.  */
 extern cmd_list_element *compile_cmd_element;
 
-#endif /* COMPILE_COMPILE_H */
+#endif /* GDB_COMPILE_COMPILE_H */
diff --git a/gdb/compile/gcc-c-plugin.h b/gdb/compile/gcc-c-plugin.h
index 4008807526b..d12472f01c1 100644
--- a/gdb/compile/gcc-c-plugin.h
+++ b/gdb/compile/gcc-c-plugin.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_GCC_C_PLUGIN_H
-#define COMPILE_GCC_C_PLUGIN_H
+#ifndef GDB_COMPILE_GCC_C_PLUGIN_H
+#define GDB_COMPILE_GCC_C_PLUGIN_H
 
 #include "compile-internal.h"
 
@@ -68,4 +68,4 @@ class gcc_c_plugin
   struct gcc_c_context *m_context;
 };
 
-#endif /* COMPILE_GCC_C_PLUGIN_H */
+#endif /* GDB_COMPILE_GCC_C_PLUGIN_H */
diff --git a/gdb/compile/gcc-cp-plugin.h b/gdb/compile/gcc-cp-plugin.h
index cf8ccd90725..8f369934127 100644
--- a/gdb/compile/gcc-cp-plugin.h
+++ b/gdb/compile/gcc-cp-plugin.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_GCC_CP_PLUGIN_H
-#define COMPILE_GCC_CP_PLUGIN_H
+#ifndef GDB_COMPILE_GCC_CP_PLUGIN_H
+#define GDB_COMPILE_GCC_CP_PLUGIN_H
 
 /* A class representing the GCC C++ plug-in.  */
 
@@ -87,4 +87,4 @@ class gcc_cp_plugin
   struct gcc_cp_context *m_context;
 };
 
-#endif /* COMPILE_GCC_CP_PLUGIN_H */
+#endif /* GDB_COMPILE_GCC_CP_PLUGIN_H */
diff --git a/gdb/complaints.h b/gdb/complaints.h
index 995c35e0ab0..ab91d05b8a0 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#if !defined (COMPLAINTS_H)
-#define COMPLAINTS_H
+#ifndef GDB_COMPLAINTS_H
+#define GDB_COMPLAINTS_H
 
 #include <unordered_set>
 
@@ -109,4 +109,4 @@ class complaint_interceptor final : public warning_hook_handler_type
 
 extern void re_emit_complaints (const complaint_collection &);
 
-#endif /* !defined (COMPLAINTS_H) */
+#endif /* GDB_COMPLAINTS_H */
diff --git a/gdb/completer.h b/gdb/completer.h
index 98a12f3907c..9ca97c2b435 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (COMPLETER_H)
-#define COMPLETER_H 1
+#ifndef GDB_COMPLETER_H
+#define GDB_COMPLETER_H
 
 #include "gdbsupport/gdb-hashtab.h"
 #include "gdbsupport/gdb_vecs.h"
@@ -661,4 +661,4 @@ extern bool skip_over_slash_fmt (completion_tracker &tracker,
 
 extern int max_completions;
 
-#endif /* defined (COMPLETER_H) */
+#endif /* GDB_COMPLETER_H */
diff --git a/gdb/config/nm-linux.h b/gdb/config/nm-linux.h
index 4ac42cdae1a..d599d3fdef5 100644
--- a/gdb/config/nm-linux.h
+++ b/gdb/config/nm-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CONFIG_NM_LINUX_H
-#define CONFIG_NM_LINUX_H
+#ifndef GDB_CONFIG_NM_LINUX_H
+#define GDB_CONFIG_NM_LINUX_H
 
 /* Use elf_gregset_t and elf_fpregset_t, rather than
    gregset_t and fpregset_t.  */
@@ -26,4 +26,4 @@
 #define GDB_GREGSET_T  elf_gregset_t
 #define GDB_FPREGSET_T elf_fpregset_t
 
-#endif /* CONFIG_NM_LINUX_H */
+#endif /* GDB_CONFIG_NM_LINUX_H */
diff --git a/gdb/config/nm-nto.h b/gdb/config/nm-nto.h
index 5a002df5548..b06cd1f5e03 100644
--- a/gdb/config/nm-nto.h
+++ b/gdb/config/nm-nto.h
@@ -19,11 +19,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CONFIG_NM_NTO_H
-#define CONFIG_NM_NTO_H
+#ifndef GDB_CONFIG_NM_NTO_H
+#define GDB_CONFIG_NM_NTO_H
 
 /* Setup the valid realtime signal range.  */
 #define REALTIME_LO 41
 #define REALTIME_HI 56
 
-#endif /* CONFIG_NM_NTO_H */
+#endif /* GDB_CONFIG_NM_NTO_H */
diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h
index fdbe4843129..6c8d9043463 100644
--- a/gdb/cp-abi.h
+++ b/gdb/cp-abi.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CP_ABI_H
-#define CP_ABI_H
+#ifndef GDB_CP_ABI_H
+#define GDB_CP_ABI_H
 
 struct fn_field;
 struct type;
@@ -255,4 +255,4 @@ struct cp_abi_ops
 extern int register_cp_abi (struct cp_abi_ops *abi);
 extern void set_cp_abi_as_auto_default (const char *short_name);
 
-#endif /* CP_ABI_H */
+#endif /* GDB_CP_ABI_H */
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 4015126154b..e2d480b2f16 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CP_SUPPORT_H
-#define CP_SUPPORT_H
+#ifndef GDB_CP_SUPPORT_H
+#define GDB_CP_SUPPORT_H
 
 #include "symtab.h"
 #include "gdbsupport/gdb_vecs.h"
@@ -212,4 +212,4 @@ extern char *gdb_cplus_demangle_print (int options,
 
 extern const char *find_toplevel_char (const char *s, char c);
 
-#endif /* CP_SUPPORT_H */
+#endif /* GDB_CP_SUPPORT_H */
diff --git a/gdb/cris-tdep.h b/gdb/cris-tdep.h
index f4f4744adaf..8be95473e21 100644
--- a/gdb/cris-tdep.h
+++ b/gdb/cris-tdep.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CRIS_TDEP_H
-#define CRIS_TDEP_H
+#ifndef GDB_CRIS_TDEP_H
+#define GDB_CRIS_TDEP_H
 
 #include "gdbarch.h"
 
@@ -33,4 +33,4 @@ struct cris_gdbarch_tdep : gdbarch_tdep_base
   int cris_dwarf2_cfi = 0;
 };
 
-#endif /* CRIS_TDEP_H */
+#endif /* GDB_CRIS_TDEP_H */
diff --git a/gdb/csky-tdep.h b/gdb/csky-tdep.h
index e5516e83550..29917192298 100644
--- a/gdb/csky-tdep.h
+++ b/gdb/csky-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CSKY_TDEP_H
-#define CSKY_TDEP_H
+#ifndef GDB_CSKY_TDEP_H
+#define GDB_CSKY_TDEP_H
 
 #include "gdbarch.h"
 
@@ -390,4 +390,4 @@ enum csky_regnum
 #define CSKY_LRW_T1_PC_8    0x2ea8d
 #define CSKY_JMP_T1_VS_NOP  0x6c037834
 
-#endif
+#endif /* GDB_CSKY_TDEP_H */
diff --git a/gdb/ctfread.h b/gdb/ctfread.h
index ff348a2487b..711a1dd2902 100644
--- a/gdb/ctfread.h
+++ b/gdb/ctfread.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CTFREAD_H
-#define CTFREAD_H
+#ifndef GDB_CTFREAD_H
+#define GDB_CTFREAD_H
 
 extern void elfctf_build_psymtabs (struct objfile *objfile);
 
-#endif /* CTFREAD_H */
+#endif /* GDB_CTFREAD_H */
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index ecf194d8155..8a944472b32 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (D_LANG_H)
-#define D_LANG_H 1
+#ifndef GDB_D_LANG_H
+#define GDB_D_LANG_H
 
 #include "symtab.h"
 
@@ -84,4 +84,4 @@ extern void d_value_print_inner (struct value *val,
 				 struct ui_file *stream, int recurse,
 				 const struct value_print_options *options);
 
-#endif /* !defined (D_LANG_H) */
+#endif /* GDB_D_LANG_H */
diff --git a/gdb/darwin-nat.h b/gdb/darwin-nat.h
index 71aee57f61a..4ead0ea7003 100644
--- a/gdb/darwin-nat.h
+++ b/gdb/darwin-nat.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DARWIN_NAT_H
-#define DARWIN_NAT_H
+#ifndef GDB_DARWIN_NAT_H
+#define GDB_DARWIN_NAT_H
 
 #include "inf-child.h"
 #include <mach/mach.h>
@@ -210,4 +210,4 @@ void darwin_set_sstep (thread_t thread, int enable);
 
 void darwin_check_osabi (darwin_inferior *inf, thread_t thread);
 
-#endif /* DARWIN_NAT_H */
+#endif /* GDB_DARWIN_NAT_H */
diff --git a/gdb/dcache.h b/gdb/dcache.h
index 101e65dc41f..21f49e522c5 100644
--- a/gdb/dcache.h
+++ b/gdb/dcache.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DCACHE_H
-#define DCACHE_H
+#ifndef GDB_DCACHE_H
+#define GDB_DCACHE_H
 
 #include "target.h"
 
@@ -52,4 +52,4 @@ void dcache_update (DCACHE *dcache, enum target_xfer_status status,
 		    CORE_ADDR memaddr, const gdb_byte *myaddr,
 		    ULONGEST len);
 
-#endif /* DCACHE_H */
+#endif /* GDB_DCACHE_H */
diff --git a/gdb/debuginfod-support.h b/gdb/debuginfod-support.h
index 2b816fd4b82..2b396dc13c1 100644
--- a/gdb/debuginfod-support.h
+++ b/gdb/debuginfod-support.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DEBUGINFOD_SUPPORT_H
-#define DEBUGINFOD_SUPPORT_H
+#ifndef GDB_DEBUGINFOD_SUPPORT_H
+#define GDB_DEBUGINFOD_SUPPORT_H
 
 #include "gdbsupport/scoped_fd.h"
 
@@ -105,4 +105,4 @@ extern scoped_fd debuginfod_section_query (const unsigned char *build_id,
 					   const char *section_name,
 					   gdb::unique_xmalloc_ptr<char>
 					     *destname);
-#endif /* DEBUGINFOD_SUPPORT_H */
+#endif /* GDB_DEBUGINFOD_SUPPORT_H */
diff --git a/gdb/defs.h b/gdb/defs.h
index cf471bf5d66..212599b2bcc 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DEFS_H
-#define DEFS_H
+#ifndef GDB_DEFS_H
+#define GDB_DEFS_H
 
 #ifdef GDBSERVER
 #  error gdbserver should not include gdb/defs.h
@@ -619,4 +619,4 @@ DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
 
 #include "utils.h"
 
-#endif /* #ifndef DEFS_H */
+#endif /* GDB_DEFS_H */
diff --git a/gdb/dicos-tdep.h b/gdb/dicos-tdep.h
index 1e3eb41a41f..5305debd707 100644
--- a/gdb/dicos-tdep.h
+++ b/gdb/dicos-tdep.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DICOS_TDEP_H
-#define DICOS_TDEP_H
+#ifndef GDB_DICOS_TDEP_H
+#define GDB_DICOS_TDEP_H
 
 extern void dicos_init_abi (struct gdbarch *gdbarch);
 extern int dicos_load_module_p (bfd *abfd, int header_size);
 
-#endif /* dicos-tdep.h */
+#endif /* GDB_DICOS_TDEP_H */
diff --git a/gdb/dictionary.h b/gdb/dictionary.h
index 6f602f4a18b..a06aa1738f1 100644
--- a/gdb/dictionary.h
+++ b/gdb/dictionary.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DICTIONARY_H
-#define DICTIONARY_H
+#ifndef GDB_DICTIONARY_H
+#define GDB_DICTIONARY_H
 
 #include "symfile.h"
 
@@ -208,4 +208,4 @@ struct mdict_iterator_wrapper
   struct mdict_iterator m_iter;
 };
 
-#endif /* DICTIONARY_H */
+#endif /* GDB_DICTIONARY_H */
diff --git a/gdb/disasm-flags.h b/gdb/disasm-flags.h
index b2f0ec95b07..9d4011cebf2 100644
--- a/gdb/disasm-flags.h
+++ b/gdb/disasm-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISASM_FLAGS_H
-#define DISASM_FLAGS_H
+#ifndef GDB_DISASM_FLAGS_H
+#define GDB_DISASM_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -37,4 +37,4 @@ enum gdb_disassembly_flag : unsigned
   };
 DEF_ENUM_FLAGS_TYPE (enum gdb_disassembly_flag, gdb_disassembly_flags);
 
-#endif /* DISASM_FLAGS_H */
+#endif /* GDB_DISASM_FLAGS_H */
diff --git a/gdb/disasm.h b/gdb/disasm.h
index 9282632b270..60d7e0fc834 100644
--- a/gdb/disasm.h
+++ b/gdb/disasm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISASM_H
-#define DISASM_H
+#ifndef GDB_DISASM_H
+#define GDB_DISASM_H
 
 #include "dis-asm.h"
 #include "disasm-flags.h"
@@ -391,4 +391,4 @@ extern const char *get_disassembler_options (struct gdbarch *gdbarch);
 
 extern void set_disassembler_options (const char *options);
 
-#endif
+#endif /* GDB_DISASM_H */
diff --git a/gdb/displaced-stepping.h b/gdb/displaced-stepping.h
index ba0d56c2a1f..d7a537a58c9 100644
--- a/gdb/displaced-stepping.h
+++ b/gdb/displaced-stepping.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISPLACED_STEPPING_H
-#define DISPLACED_STEPPING_H
+#ifndef GDB_DISPLACED_STEPPING_H
+#define GDB_DISPLACED_STEPPING_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/byte-vector.h"
@@ -207,4 +207,4 @@ struct displaced_step_buffers
   std::vector<displaced_step_buffer> m_buffers;
 };
 
-#endif /* DISPLACED_STEPPING_H */
+#endif /* GDB_DISPLACED_STEPPING_H */
diff --git a/gdb/dummy-frame.h b/gdb/dummy-frame.h
index 7d963ad9beb..78998e84413 100644
--- a/gdb/dummy-frame.h
+++ b/gdb/dummy-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DUMMY_FRAME_H)
-#define DUMMY_FRAME_H 1
+#ifndef GDB_DUMMY_FRAME_H
+#define GDB_DUMMY_FRAME_H
 
 #include "frame.h"
 
@@ -80,4 +80,4 @@ extern int find_dummy_frame_dtor (dummy_frame_dtor_ftype *dtor,
 extern struct frame_id default_dummy_id (struct gdbarch *gdbarch,
 					 const frame_info_ptr &this_frame);
 
-#endif /* !defined (DUMMY_FRAME_H)  */
+#endif /* GDB_DUMMY_FRAME_H */
diff --git a/gdb/dwarf2/call-site.h b/gdb/dwarf2/call-site.h
index 0a0c7e83b81..0c587470311 100644
--- a/gdb/dwarf2/call-site.h
+++ b/gdb/dwarf2/call-site.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CALL_SITE_H
-#define CALL_SITE_H
+#ifndef GDB_DWARF2_CALL_SITE_H
+#define GDB_DWARF2_CALL_SITE_H
 
 #include "dwarf2/types.h"
 #include "../frame.h"
@@ -241,4 +241,4 @@ struct call_site
   struct call_site_parameter parameter[];
 };
 
-#endif /* CALL_SITE_H */
+#endif /* GDB_DWARF2_CALL_SITE_H */
diff --git a/gdb/dwarf2/comp-unit-head.h b/gdb/dwarf2/comp-unit-head.h
index fad484c3b93..d161783187c 100644
--- a/gdb/dwarf2/comp-unit-head.h
+++ b/gdb/dwarf2/comp-unit-head.h
@@ -24,8 +24,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DWARF2_COMP_UNIT_H
-#define GDB_DWARF2_COMP_UNIT_H
+#ifndef GDB_DWARF2_COMP_UNIT_HEAD_H
+#define GDB_DWARF2_COMP_UNIT_HEAD_H
 
 #include "dwarf2.h"
 #include "dwarf2/leb.h"
@@ -136,4 +136,4 @@ extern const gdb_byte *read_and_check_comp_unit_head
    const gdb_byte *info_ptr,
    rcuh_kind section_kind);
 
-#endif /* GDB_DWARF2_COMP_UNIT_H */
+#endif /* GDB_DWARF2_COMP_UNIT_HEAD_H */
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index b02cc531640..bbb9cd078ba 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DWARF2EXPR_H)
-#define DWARF2EXPR_H
+#ifndef GDB_DWARF2_EXPR_H
+#define GDB_DWARF2_EXPR_H
 
 #include "leb128.h"
 #include "dwarf2/call-site.h"
@@ -320,4 +320,4 @@ extern const gdb_byte *safe_read_sleb128 (const gdb_byte *buf,
 extern const gdb_byte *safe_skip_leb128 (const gdb_byte *buf,
 					 const gdb_byte *buf_end);
 
-#endif /* DWARF2EXPR_H */
+#endif /* GDB_DWARF2_EXPR_H */
diff --git a/gdb/dwarf2/frame-tailcall.h b/gdb/dwarf2/frame-tailcall.h
index 3f49487ac2a..558957eb999 100644
--- a/gdb/dwarf2/frame-tailcall.h
+++ b/gdb/dwarf2/frame-tailcall.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_FRAME_TAILCALL_H
-#define DWARF2_FRAME_TAILCALL_H 1
+#ifndef GDB_DWARF2_FRAME_TAILCALL_H
+#define GDB_DWARF2_FRAME_TAILCALL_H
 
 class frame_info_ptr;
 struct frame_unwind;
@@ -36,4 +36,4 @@ extern struct value *
 
 extern const struct frame_unwind dwarf2_tailcall_frame_unwind;
 
-#endif /* !DWARF2_FRAME_TAILCALL_H */
+#endif /* GDB_DWARF2_FRAME_TAILCALL_H */
diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h
index 2167310fbdf..f53f4bdd864 100644
--- a/gdb/dwarf2/frame.h
+++ b/gdb/dwarf2/frame.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_FRAME_H
-#define DWARF2_FRAME_H 1
+#ifndef GDB_DWARF2_FRAME_H
+#define GDB_DWARF2_FRAME_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -294,4 +294,4 @@ extern void *dwarf2_frame_get_fn_data (const frame_info_ptr &this_frame,
 				       void **this_cache,
 				       fn_prev_register cookie);
 
-#endif /* dwarf2-frame.h */
+#endif /* GDB_DWARF2_FRAME_H */
diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h
index 95f217ed961..922c1568f8e 100644
--- a/gdb/dwarf2/index-cache.h
+++ b/gdb/dwarf2/index-cache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_CACHE_H
-#define DWARF_INDEX_CACHE_H
+#ifndef GDB_DWARF2_INDEX_CACHE_H
+#define GDB_DWARF2_INDEX_CACHE_H
 
 #include "dwarf2/index-common.h"
 #include "gdbsupport/array-view.h"
@@ -137,4 +137,4 @@ class index_cache
 /* The global instance of the index cache.  */
 extern index_cache global_index_cache;
 
-#endif /* DWARF_INDEX_CACHE_H */
+#endif /* GDB_DWARF2_INDEX_CACHE_H */
diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h
index dca41517b3d..4c029f4318e 100644
--- a/gdb/dwarf2/index-common.h
+++ b/gdb/dwarf2/index-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_COMMON_H
-#define DWARF_INDEX_COMMON_H
+#ifndef GDB_DWARF2_INDEX_COMMON_H
+#define GDB_DWARF2_INDEX_COMMON_H
 
 /* The suffix for an index file.  */
 #define INDEX4_SUFFIX ".gdb-index"
@@ -56,4 +56,4 @@ uint32_t dwarf5_djb_hash (const char *str_);
 
 uint32_t dwarf5_djb_hash (std::string_view str_);
 
-#endif /* DWARF_INDEX_COMMON_H */
+#endif /* GDB_DWARF2_INDEX_COMMON_H */
diff --git a/gdb/dwarf2/index-write.h b/gdb/dwarf2/index-write.h
index b7cf564efc5..1982e8510fc 100644
--- a/gdb/dwarf2/index-write.h
+++ b/gdb/dwarf2/index-write.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_WRITE_H
-#define DWARF_INDEX_WRITE_H
+#ifndef GDB_DWARF2_INDEX_WRITE_H
+#define GDB_DWARF2_INDEX_WRITE_H
 
 #include "dwarf2/read.h"
 #include "dwarf2/public.h"
@@ -36,4 +36,4 @@ extern void write_dwarf_index
   (dwarf2_per_bfd *per_bfd, const char *dir, const char *basename,
    const char *dwz_basename, dw_index_kind index_kind);
 
-#endif /* DWARF_INDEX_WRITE_H */
+#endif /* GDB_DWARF2_INDEX_WRITE_H */
diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index c068dff70a3..b9bc55a926e 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_LINE_HEADER_H
-#define DWARF2_LINE_HEADER_H
+#ifndef GDB_DWARF2_LINE_HEADER_H
+#define GDB_DWARF2_LINE_HEADER_H
 
 /* dir_index is 1-based in DWARF 4 and before, and is 0-based in DWARF 5 and
    later.  */
@@ -217,4 +217,4 @@ extern line_header_up dwarf_decode_line_header
    struct dwarf2_section_info *section, const struct comp_unit_head *cu_header,
    const char *comp_dir);
 
-#endif /* DWARF2_LINE_HEADER_H */
+#endif /* GDB_DWARF2_LINE_HEADER_H */
diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h
index 4fb743618e7..78635682d94 100644
--- a/gdb/dwarf2/loc.h
+++ b/gdb/dwarf2/loc.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DWARF2LOC_H)
-#define DWARF2LOC_H
+#ifndef GDB_DWARF2_LOC_H
+#define GDB_DWARF2_LOC_H
 
 #include "dwarf2/expr.h"
 
@@ -308,4 +308,4 @@ extern struct value *value_of_dwarf_reg_entry (struct type *type,
 					       const frame_info_ptr &frame,
 					       enum call_site_parameter_kind kind,
 					       union call_site_parameter_u kind_u);
-#endif /* DWARF2LOC_H */
+#endif /* GDB_DWARF2_LOC_H */
diff --git a/gdb/dwarf2/public.h b/gdb/dwarf2/public.h
index bc419ff208f..8247641b25b 100644
--- a/gdb/dwarf2/public.h
+++ b/gdb/dwarf2/public.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_PUBLIC_H
-#define DWARF2_PUBLIC_H
+#ifndef GDB_DWARF2_PUBLIC_H
+#define GDB_DWARF2_PUBLIC_H
 
 /* A DWARF names index variant.  */
 enum class dw_index_kind
@@ -44,4 +44,4 @@ extern bool dwarf2_initialize_objfile
 
 extern void dwarf2_build_frame_info (struct objfile *);
 
-#endif /* DWARF2_PUBLIC_H */
+#endif /* GDB_DWARF2_PUBLIC_H */
diff --git a/gdb/dwarf2/read-debug-names.h b/gdb/dwarf2/read-debug-names.h
index e616cf887a7..729fe898ea8 100644
--- a/gdb/dwarf2/read-debug-names.h
+++ b/gdb/dwarf2/read-debug-names.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_READ_DEBUG_NAMES_H
-#define DWARF2_READ_DEBUG_NAMES_H
+#ifndef GDB_DWARF2_READ_DEBUG_NAMES_H
+#define GDB_DWARF2_READ_DEBUG_NAMES_H
 
 struct dwarf2_per_objfile;
 
@@ -29,4 +29,4 @@ extern const gdb_byte dwarf5_augmentation[8];
 
 bool dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile);
 
-#endif /* DWARF2_READ_DEBUG_NAMES_H */
+#endif /* GDB_DWARF2_READ_DEBUG_NAMES_H */
diff --git a/gdb/dwarf2/read-gdb-index.h b/gdb/dwarf2/read-gdb-index.h
index e411114b147..906e3bd0bed 100644
--- a/gdb/dwarf2/read-gdb-index.h
+++ b/gdb/dwarf2/read-gdb-index.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_READ_GDB_INDEX_H
-#define DWARF2_READ_GDB_INDEX_H
+#ifndef GDB_DWARF2_READ_GDB_INDEX_H
+#define GDB_DWARF2_READ_GDB_INDEX_H
 
 #include "gdbsupport/function-view.h"
 
@@ -44,4 +44,4 @@ int dwarf2_read_gdb_index
    get_gdb_index_contents_ftype get_gdb_index_contents,
    get_gdb_index_contents_dwz_ftype get_gdb_index_contents_dwz);
 
-#endif /* DWARF2_READ_GDB_INDEX_H */
+#endif /* GDB_DWARF2_READ_GDB_INDEX_H */
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 73def88c4c0..76bf6a422f4 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2READ_H
-#define DWARF2READ_H
+#ifndef GDB_DWARF2_READ_H
+#define GDB_DWARF2_READ_H
 
 #include <queue>
 #include <unordered_map>
@@ -932,4 +932,4 @@ extern void create_all_units (dwarf2_per_objfile *per_objfile);
 
 extern htab_up create_quick_file_names_table (unsigned int nr_initial_entries);
 
-#endif /* DWARF2READ_H */
+#endif /* GDB_DWARF2_READ_H */
diff --git a/gdb/dwarf2/types.h b/gdb/dwarf2/types.h
index 9db5c635704..f4588a12df8 100644
--- a/gdb/dwarf2/types.h
+++ b/gdb/dwarf2/types.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_TYPES_H
-#define DWARF2_TYPES_H
+#ifndef GDB_DWARF2_TYPES_H
+#define GDB_DWARF2_TYPES_H
 
 #include "gdbsupport/offset-type.h"
 #include "gdbsupport/underlying.h"
@@ -37,4 +37,4 @@ sect_offset_str (sect_offset offset)
   return hex_string (to_underlying (offset));
 }
 
-#endif /* DWARF2_TYPES_H */
+#endif /* GDB_DWARF2_TYPES_H */
diff --git a/gdb/elf-none-tdep.h b/gdb/elf-none-tdep.h
index ecbf2d776c6..1881e4b8cb6 100644
--- a/gdb/elf-none-tdep.h
+++ b/gdb/elf-none-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NONE_TDEP_H
-#define NONE_TDEP_H
+#ifndef GDB_ELF_NONE_TDEP_H
+#define GDB_ELF_NONE_TDEP_H
 
 struct gdbarch;
 
@@ -27,4 +27,4 @@ struct gdbarch;
 
 void elf_none_init_abi (struct gdbarch *gdbarch);
 
-#endif /* NONE_TDEP_H */
+#endif /* GDB_ELF_NONE_TDEP_H */
diff --git a/gdb/event-top.h b/gdb/event-top.h
index f431f2812b2..7f544b0f27c 100644
--- a/gdb/event-top.h
+++ b/gdb/event-top.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EVENT_TOP_H
-#define EVENT_TOP_H
+#ifndef GDB_EVENT_TOP_H
+#define GDB_EVENT_TOP_H
 
 #include <signal.h>
 
@@ -90,4 +90,4 @@ class scoped_segv_handler_restore
   segv_handler_t m_old_handler;
 };
 
-#endif
+#endif /* GDB_EVENT_TOP_H */
diff --git a/gdb/exceptions.h b/gdb/exceptions.h
index 64f4d75c39c..bf7141dbb9f 100644
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXCEPTIONS_H
-#define EXCEPTIONS_H
+#ifndef GDB_EXCEPTIONS_H
+#define GDB_EXCEPTIONS_H
 
 #include "ui-out.h"
 
@@ -31,4 +31,4 @@ extern void exception_fprintf (struct ui_file *file,
 			       const char *prefix,
 			       ...) ATTRIBUTE_PRINTF (3, 4);
 
-#endif
+#endif /* GDB_EXCEPTIONS_H */
diff --git a/gdb/exec.h b/gdb/exec.h
index f667f23600d..950a21c2f3a 100644
--- a/gdb/exec.h
+++ b/gdb/exec.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXEC_H
-#define EXEC_H
+#ifndef GDB_EXEC_H
+#define GDB_EXEC_H
 
 #include "target.h"
 #include "progspace.h"
@@ -105,4 +105,4 @@ extern void print_section_info (const std::vector<target_section> *table,
 extern void try_open_exec_file (const char *exec_file_host,
 				struct inferior *inf,
 				symfile_add_flags add_flags);
-#endif
+#endif /* GDB_EXEC_H */
diff --git a/gdb/expop.h b/gdb/expop.h
index b81e228c07e..64158bc4706 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXPOP_H
-#define EXPOP_H
+#ifndef GDB_EXPOP_H
+#define GDB_EXPOP_H
 
 #include "c-lang.h"
 #include "cp-abi.h"
@@ -2215,4 +2215,4 @@ class funcall_operation
 
 } /* namespace expr */
 
-#endif /* EXPOP_H */
+#endif /* GDB_EXPOP_H */
diff --git a/gdb/expression.h b/gdb/expression.h
index 5bfc74c973f..7c79518da8b 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (EXPRESSION_H)
-#define EXPRESSION_H 1
+#ifndef GDB_EXPRESSION_H
+#define GDB_EXPRESSION_H
 
 #include "gdbtypes.h"
 #include "symtab.h"
@@ -387,4 +387,4 @@ enum range_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum range_flag, range_flags);
 
-#endif /* !defined (EXPRESSION_H) */
+#endif /* GDB_EXPRESSION_H */
diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index cb00cb6ff7b..f6c5f3fe75f 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXTENSION_PRIV_H
-#define EXTENSION_PRIV_H
+#ifndef GDB_EXTENSION_PRIV_H
+#define GDB_EXTENSION_PRIV_H
 
 #include "extension.h"
 #include <signal.h>
@@ -320,4 +320,4 @@ extern struct active_ext_lang_state *set_active_ext_lang
 
 extern void restore_active_ext_lang (struct active_ext_lang_state *previous);
 
-#endif /* EXTENSION_PRIV_H */
+#endif /* GDB_EXTENSION_PRIV_H */
diff --git a/gdb/extension.h b/gdb/extension.h
index 5260bcbde00..93c3cdfcc69 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXTENSION_H
-#define EXTENSION_H
+#ifndef GDB_EXTENSION_H
+#define GDB_EXTENSION_H
 
 #include "mi/mi-cmds.h"
 #include "gdbsupport/array-view.h"
@@ -428,4 +428,4 @@ class scoped_disable_cooperative_sigint_handling
   bool m_prev_cooperative_sigint_handling_disabled;
 };
 
-#endif /* EXTENSION_H */
+#endif /* GDB_EXTENSION_H */
diff --git a/gdb/f-array-walker.h b/gdb/f-array-walker.h
index bcbaa3da5b3..d1f2b06fa9b 100644
--- a/gdb/f-array-walker.h
+++ b/gdb/f-array-walker.h
@@ -18,8 +18,8 @@
 /* Support classes to wrap up the process of iterating over a
    multi-dimensional Fortran array.  */
 
-#ifndef F_ARRAY_WALKER_H
-#define F_ARRAY_WALKER_H
+#ifndef GDB_F_ARRAY_WALKER_H
+#define GDB_F_ARRAY_WALKER_H
 
 #include "gdbtypes.h"
 #include "f-lang.h"
@@ -298,4 +298,4 @@ class fortran_array_walker
   int m_nss;
 };
 
-#endif /* F_ARRAY_WALKER_H */
+#endif /* GDB_F_ARRAY_WALKER_H */
diff --git a/gdb/f-exp.h b/gdb/f-exp.h
index aa0094c8ff1..47d469abe7c 100644
--- a/gdb/f-exp.h
+++ b/gdb/f-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FORTRAN_EXP_H
-#define FORTRAN_EXP_H
+#ifndef GDB_F_EXP_H
+#define GDB_F_EXP_H
 
 #include "expop.h"
 
@@ -417,4 +417,4 @@ class fortran_structop_operation
 
 } /* namespace expr */
 
-#endif /* FORTRAN_EXP_H */
+#endif /* GDB_F_EXP_H */
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index c2034258513..59cdd5f2334 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef F_LANG_H
-#define F_LANG_H
+#ifndef GDB_F_LANG_H
+#define GDB_F_LANG_H
 
 #include "language.h"
 #include "valprint.h"
@@ -378,4 +378,4 @@ extern struct type *fortran_preserve_arg_pointer (struct value *arg,
 extern CORE_ADDR fortran_adjust_dynamic_array_base_address_hack
 	(struct type *type, CORE_ADDR address);
 
-#endif /* F_LANG_H */
+#endif /* GDB_F_LANG_H */
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index 35c06b2c985..2123175944e 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FBSD_NAT_H
-#define FBSD_NAT_H
+#ifndef GDB_FBSD_NAT_H
+#define GDB_FBSD_NAT_H
 
 #include <optional>
 #include "inf-ptrace.h"
@@ -285,4 +285,4 @@ class fbsd_nat_target : public inf_ptrace_target
    Return true if successful.  */
 bool fbsd_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
 
-#endif /* fbsd-nat.h */
+#endif /* GDB_FBSD_NAT_H */
diff --git a/gdb/fbsd-tdep.h b/gdb/fbsd-tdep.h
index 54ff45c8d93..79381b3fefd 100644
--- a/gdb/fbsd-tdep.h
+++ b/gdb/fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FBSD_TDEP_H
-#define FBSD_TDEP_H
+#ifndef GDB_FBSD_TDEP_H
+#define GDB_FBSD_TDEP_H
 
 extern void fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
 
@@ -76,4 +76,4 @@ extern CORE_ADDR fbsd_get_thread_local_address (struct gdbarch *gdbarch,
 extern CORE_ADDR fbsd_skip_solib_resolver (struct gdbarch *gdbarch,
 					   CORE_ADDR pc);
 
-#endif /* fbsd-tdep.h */
+#endif /* GDB_FBSD_TDEP_H */
diff --git a/gdb/filename-seen-cache.h b/gdb/filename-seen-cache.h
index 5dc800d2b16..9107f449183 100644
--- a/gdb/filename-seen-cache.h
+++ b/gdb/filename-seen-cache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FILENAME_SEEN_CACHE_H
-#define FILENAME_SEEN_CACHE_H
+#ifndef GDB_FILENAME_SEEN_CACHE_H
+#define GDB_FILENAME_SEEN_CACHE_H
 
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/gdb-hashtab.h"
@@ -62,4 +62,4 @@ class filename_seen_cache
   htab_up m_tab;
 };
 
-#endif /* FILENAME_SEEN_CACHE_H */
+#endif /* GDB_FILENAME_SEEN_CACHE_H */
diff --git a/gdb/filesystem.h b/gdb/filesystem.h
index 29c31803fc4..73b9a8bb84e 100644
--- a/gdb/filesystem.h
+++ b/gdb/filesystem.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FILESYSTEM_H
-#define FILESYSTEM_H
+#ifndef GDB_FILESYSTEM_H
+#define GDB_FILESYSTEM_H
 
 extern const char file_system_kind_auto[];
 extern const char file_system_kind_unix[];
@@ -55,4 +55,4 @@ extern const char *target_lbasename (const char *kind, const char *name);
    result from this function.  */
 extern const char *effective_target_file_system_kind (void);
 
-#endif
+#endif /* GDB_FILESYSTEM_H */
diff --git a/gdb/frame-base.h b/gdb/frame-base.h
index ae22431d5ef..8436929839e 100644
--- a/gdb/frame-base.h
+++ b/gdb/frame-base.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_BASE_H)
-#define FRAME_BASE_H 1
+#ifndef GDB_FRAME_BASE_H
+#define GDB_FRAME_BASE_H
 
 class frame_info_ptr;
 struct frame_id;
@@ -88,4 +88,4 @@ extern void frame_base_set_default (struct gdbarch *gdbarch,
 
 extern const struct frame_base *frame_base_find_by_frame (const frame_info_ptr &this_frame);
 
-#endif
+#endif /* GDB_FRAME_BASE_H */
diff --git a/gdb/frame-id.h b/gdb/frame-id.h
index 0d03b476aef..30850e24017 100644
--- a/gdb/frame-id.h
+++ b/gdb/frame-id.h
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef GDB_FRAME_ID_H
-#define GDB_FRAME_ID_H 1
+#define GDB_FRAME_ID_H
 
 /* Status of a given frame's stack.  */
 
@@ -140,4 +140,4 @@ is_sentinel_frame_id (frame_id id)
   return id.stack_status == FID_STACK_SENTINEL;
 }
 
-#endif /* ifdef GDB_FRAME_ID_H  */
+#endif /* GDB_FRAME_ID_H */
diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h
index 53fcd6869e9..1799d3625bd 100644
--- a/gdb/frame-unwind.h
+++ b/gdb/frame-unwind.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_UNWIND_H)
-#define FRAME_UNWIND_H 1
+#ifndef GDB_FRAME_UNWIND_H
+#define GDB_FRAME_UNWIND_H
 
 struct frame_data;
 class frame_info_ptr;
@@ -235,4 +235,4 @@ value *frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum,
 value *frame_unwind_got_address (const frame_info_ptr &frame, int regnum,
 				 CORE_ADDR addr);
 
-#endif
+#endif /* GDB_FRAME_UNWIND_H */
diff --git a/gdb/frame.h b/gdb/frame.h
index e784c17b480..9b41dd958fa 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_H)
-#define FRAME_H 1
+#ifndef GDB_FRAME_H
+#define GDB_FRAME_H
 
 /* The following is the intended naming schema for frame functions.
    It isn't 100% consistent, but it is approaching that.  Frame naming
@@ -1077,4 +1077,4 @@ extern void set_frame_previous_pc_masked (const frame_info_ptr &frame);
 extern bool get_frame_pc_masked (const frame_info_ptr &frame);
 
 
-#endif /* !defined (FRAME_H)  */
+#endif /* GDB_FRAME_H */
diff --git a/gdb/frv-tdep.h b/gdb/frv-tdep.h
index 95347ed224e..0d78ec4ac6a 100644
--- a/gdb/frv-tdep.h
+++ b/gdb/frv-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FRV_TDEP_H
-#define FRV_TDEP_H
+#ifndef GDB_FRV_TDEP_H
+#define GDB_FRV_TDEP_H
 
 /* Enumerate the possible ABIs for FR-V.  */
 enum frv_abi
@@ -121,4 +121,4 @@ CORE_ADDR frv_fetch_objfile_link_map (struct objfile *objfile);
 struct solib_ops;
 extern const solib_ops frv_so_ops;
 
-#endif /* FRV_TDEP_H */
+#endif /* GDB_FRV_TDEP_H */
diff --git a/gdb/ft32-tdep.h b/gdb/ft32-tdep.h
index 308d2333bc2..ee4a2473f8d 100644
--- a/gdb/ft32-tdep.h
+++ b/gdb/ft32-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FT32_TDEP_H
-#define FT32_TDEP_H
+#ifndef GDB_FT32_TDEP_H
+#define GDB_FT32_TDEP_H
 
 #include "gdbarch.h"
 
@@ -28,4 +28,4 @@ struct ft32_gdbarch_tdep : gdbarch_tdep_base
   struct type *pc_type = nullptr;
 };
 
-#endif /* FT32_TDEP_H */
+#endif /* GDB_FT32_TDEP_H */
diff --git a/gdb/gcore-elf.h b/gdb/gcore-elf.h
index e7239b88b09..8217f0b1c85 100644
--- a/gdb/gcore-elf.h
+++ b/gdb/gcore-elf.h
@@ -17,8 +17,8 @@
 
 /* This file contains generic functions for writing ELF based core files.  */
 
-#if !defined (GCORE_ELF_H)
-#define GCORE_ELF_H 1
+#ifndef GDB_GCORE_ELF_H
+#define GDB_GCORE_ELF_H
 
 #include "gdb_bfd.h"
 #include "gdbsupport/gdb_signals.h"
@@ -45,4 +45,4 @@ extern void gcore_elf_make_tdesc_note
   (struct gdbarch *gdbarch, bfd *obfd,
    gdb::unique_xmalloc_ptr<char> *note_data, int *note_size);
 
-#endif /* GCORE_ELF_H */
+#endif /* GDB_GCORE_ELF_H */
diff --git a/gdb/gcore.h b/gdb/gcore.h
index 0bedc0a7ba9..21e7a8d29ee 100644
--- a/gdb/gcore.h
+++ b/gdb/gcore.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GCORE_H)
-#define GCORE_H 1
+#ifndef GDB_GCORE_H
+#define GDB_GCORE_H
 
 #include "gdb_bfd.h"
 
@@ -37,4 +37,4 @@ extern int objfile_find_memory_regions (struct target_ops *self,
 
 extern thread_info *gcore_find_signalled_thread ();
 
-#endif /* GCORE_H */
+#endif /* GDB_GCORE_H */
diff --git a/gdb/gdb-demangle.h b/gdb/gdb-demangle.h
index e434f890969..86a8bd618eb 100644
--- a/gdb/gdb-demangle.h
+++ b/gdb/gdb-demangle.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DEMANGLE_H
-#define GDB_DEMANGLE_H
+#ifndef GDB_GDB_DEMANGLE_H
+#define GDB_GDB_DEMANGLE_H
 
 /* True means that encoded C++/ObjC names should be printed out in their
    C++/ObjC form rather than raw.  */
@@ -31,4 +31,4 @@ extern bool asm_demangle;
 /* Check if a character is one of the commonly used C++ marker characters.  */
 extern bool is_cplus_marker (int);
 
-#endif /* GDB_DEMANGLE_H */
+#endif /* GDB_GDB_DEMANGLE_H */
diff --git a/gdb/gdb-stabs.h b/gdb/gdb-stabs.h
index 3786ad6881d..373a7269470 100644
--- a/gdb/gdb-stabs.h
+++ b/gdb/gdb-stabs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_STABS_H
-#define GDB_STABS_H
+#ifndef GDB_GDB_STABS_H
+#define GDB_GDB_STABS_H
 
 /* This file exists to hold the common definitions required of most of
    the symbol-readers that end up using stabs.  The common use of
@@ -75,4 +75,4 @@ extern const registry<objfile>::key<dbx_symfile_info> dbx_objfile_data_key;
 #define DBX_BSS_SECTION(o)	(DBX_SYMFILE_INFO(o)->bss_section)
 #define DBX_STAB_SECTION(o)	(DBX_SYMFILE_INFO(o)->stab_section)
 
-#endif /* GDB_STABS_H */
+#endif /* GDB_GDB_STABS_H */
diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h
index 331570d769c..c09e4e7f811 100644
--- a/gdb/gdb_bfd.h
+++ b/gdb/gdb_bfd.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_BFD_H
-#define GDB_BFD_H
+#ifndef GDB_GDB_BFD_H
+#define GDB_GDB_BFD_H
 
 #include "registry.h"
 #include "gdbsupport/byte-vector.h"
@@ -263,4 +263,4 @@ extern std::string gdb_bfd_errmsg (bfd_error_type error_tag, char **matching);
 
 extern void gdb_bfd_init ();
 
-#endif /* GDB_BFD_H */
+#endif /* GDB_GDB_BFD_H */
diff --git a/gdb/gdb_curses.h b/gdb/gdb_curses.h
index c7ee862cd67..c0ab883f17b 100644
--- a/gdb/gdb_curses.h
+++ b/gdb/gdb_curses.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_CURSES_H
-#define GDB_CURSES_H 1
+#ifndef GDB_GDB_CURSES_H
+#define GDB_GDB_CURSES_H
 
 #ifdef __MINGW32__
 /* Windows API headers, included e.g. by serial.h, define MOUSE_MOVED,
@@ -71,4 +71,4 @@ extern "C" int tgetnum (const char *);
 #undef reg
 #endif
 
-#endif /* gdb_curses.h */
+#endif /* GDB_GDB_CURSES_H */
diff --git a/gdb/gdb_expat.h b/gdb/gdb_expat.h
index 566f065fd13..36cee8031eb 100644
--- a/gdb/gdb_expat.h
+++ b/gdb/gdb_expat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(GDB_EXPAT_H)
-#define GDB_EXPAT_H
+#ifndef GDB_GDB_EXPAT_H
+#define GDB_GDB_EXPAT_H
 
 #include <expat.h>
 
@@ -35,4 +35,4 @@
 #define XMLCALL
 #endif
 
-#endif /* !defined(GDB_EXPAT_H) */
+#endif /* GDB_GDB_EXPAT_H */
diff --git a/gdb/gdb_proc_service.h b/gdb/gdb_proc_service.h
index 1088e19a4c5..c5e060b4eee 100644
--- a/gdb/gdb_proc_service.h
+++ b/gdb/gdb_proc_service.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_PROC_SERVICE_H
-#define GDB_PROC_SERVICE_H
+#ifndef GDB_GDB_PROC_SERVICE_H
+#define GDB_GDB_PROC_SERVICE_H
 
 #include "gdbsupport/gdb_proc_service.h"
 
@@ -30,4 +30,4 @@ struct ps_prochandle
   thread_info *thread;
 };
 
-#endif /* gdb_proc_service.h */
+#endif /* GDB_GDB_PROC_SERVICE_H */
diff --git a/gdb/gdb_vfork.h b/gdb/gdb_vfork.h
index 521fed9b007..69f4955ee97 100644
--- a/gdb/gdb_vfork.h
+++ b/gdb/gdb_vfork.h
@@ -16,11 +16,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_VFORK_H
-#define GDB_VFORK_H
+#ifndef GDB_GDB_VFORK_H
+#define GDB_GDB_VFORK_H
 
 #if HAVE_VFORK_H
 #include <vfork.h>
 #endif
 
-#endif /* GDB_VFORK_H */
+#endif /* GDB_GDB_VFORK_H */
diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h
index 8df00e4679f..937b409d039 100644
--- a/gdb/gdb_wchar.h
+++ b/gdb/gdb_wchar.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_WCHAR_H
-#define GDB_WCHAR_H
+#ifndef GDB_GDB_WCHAR_H
+#define GDB_GDB_WCHAR_H
 
 /* We handle three different modes here.
    
@@ -121,4 +121,4 @@ typedef int gdb_wint_t;
 
 #endif
 
-#endif /* GDB_WCHAR_H */
+#endif /* GDB_GDB_WCHAR_H */
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 77d3406779f..bfe08fe65a8 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef GDBARCH_H
-#define GDBARCH_H
+#ifndef GDB_GDBARCH_H
+#define GDB_GDBARCH_H
 
 #include <vector>
 #include "frame.h"
@@ -370,4 +370,4 @@ gdbarch_num_cooked_regs (gdbarch *arch)
   return gdbarch_num_regs (arch) + gdbarch_num_pseudo_regs (arch);
 }
 
-#endif
+#endif /* GDB_GDBARCH_H */
diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h
index 8a1f6f20052..cba32528dfa 100644
--- a/gdb/gdbcmd.h
+++ b/gdb/gdbcmd.h
@@ -21,8 +21,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDBCMD_H)
-#define GDBCMD_H 1
+#ifndef GDB_GDBCMD_H
+#define GDB_GDBCMD_H
 
 #include "command.h"
 #include "ui-out.h"
@@ -69,4 +69,4 @@ extern void print_command_lines (struct ui_out *,
 extern struct cmd_list_element *style_set_list;
 extern struct cmd_list_element *style_show_list;
 
-#endif /* !defined (GDBCMD_H) */
+#endif /* GDB_GDBCMD_H */
diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h
index d6aeb356e37..4eab2cd70a5 100644
--- a/gdb/gdbcore.h
+++ b/gdb/gdbcore.h
@@ -19,8 +19,8 @@
 
 /* Interface routines for core, executable, etc.  */
 
-#if !defined (GDBCORE_H)
-#define GDBCORE_H 1
+#ifndef GDB_GDBCORE_H
+#define GDB_GDBCORE_H
 
 struct type;
 struct regcache;
@@ -196,4 +196,4 @@ class thread_section_name
   std::string m_storage;
 };
 
-#endif /* !defined (GDBCORE_H) */
+#endif /* GDB_GDBCORE_H */
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 73f6895fe46..490d05db340 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDBTHREAD_H
-#define GDBTHREAD_H
+#ifndef GDB_GDBTHREAD_H
+#define GDB_GDBTHREAD_H
 
 struct symtab;
 
@@ -1071,4 +1071,4 @@ extern void thread_try_catch_cmd (thread_info *thr,
 
 extern const char *thread_state_string (enum thread_state state);
 
-#endif /* GDBTHREAD_H */
+#endif /* GDB_GDBTHREAD_H */
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 55018f2c344..5182b54cc96 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDBTYPES_H)
-#define GDBTYPES_H 1
+#ifndef GDB_GDBTYPES_H
+#define GDB_GDBTYPES_H
 
 /* * \page gdbtypes GDB Types
 
@@ -2830,4 +2830,4 @@ extern unsigned int overload_debug;
 
 extern bool is_nocall_function (const struct type *type);
 
-#endif /* GDBTYPES_H */
+#endif /* GDB_GDBTYPES_H */
diff --git a/gdb/glibc-tdep.h b/gdb/glibc-tdep.h
index 264e1e707f2..17006d0fafc 100644
--- a/gdb/glibc-tdep.h
+++ b/gdb/glibc-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GLIBC_TDEP_H
-#define GLIBC_TDEP_H
+#ifndef GDB_GLIBC_TDEP_H
+#define GDB_GLIBC_TDEP_H
 
 struct gdbarch;
 
 extern CORE_ADDR glibc_skip_solib_resolver (struct gdbarch *gdbarch,
 					    CORE_ADDR);
 
-#endif /* glibc-tdep.h */
+#endif /* GDB_GLIBC_TDEP_H */
diff --git a/gdb/gmp-utils.h b/gdb/gmp-utils.h
index 51e06abc050..84ac0e7333b 100644
--- a/gdb/gmp-utils.h
+++ b/gdb/gmp-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GMP_UTILS_H
-#define GMP_UTILS_H
+#ifndef GDB_GMP_UTILS_H
+#define GDB_GMP_UTILS_H
 
 /* Include <stdio.h> and <stdarg.h> ahead of <gmp.h>, so as to get
    access to GMP's various formatting functions.  */
@@ -663,4 +663,4 @@ gdb_mpz::as_integer_truncate () const
   return result;
 }
 
-#endif
+#endif /* GDB_GMP_UTILS_H */
diff --git a/gdb/gnu-nat-mig.h b/gdb/gnu-nat-mig.h
index 4b9e78c99e2..01c1ed46f20 100644
--- a/gdb/gnu-nat-mig.h
+++ b/gdb/gnu-nat-mig.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GNU_NAT_MIG_H
-#define GNU_NAT_MIG_H
+#ifndef GDB_GNU_NAT_MIG_H
+#define GDB_GNU_NAT_MIG_H
 
 #include <mach/boolean.h>
 #include <mach/message.h>
@@ -28,4 +28,4 @@ boolean_t notify_server (mach_msg_header_t *InHeadP,
 boolean_t process_reply_server (mach_msg_header_t *InHeadP,
 				mach_msg_header_t *OutHeadP);
 
-#endif /* GNU_NAT_MIG_H */
+#endif /* GDB_GNU_NAT_MIG_H */
diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index f1694b8a3a7..700a01a7d17 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GNU_NAT_H
-#define GNU_NAT_H
+#ifndef GDB_GNU_NAT_H
+#define GDB_GNU_NAT_H
 
 /* Work around conflict between Mach's 'thread_info' function, and GDB's
    'thread_info' class.  Make the former available as 'mach_thread_info'.  */
@@ -188,4 +188,4 @@ struct gnu_nat_target : public inf_child_target
 /* The final/concrete instance.  */
 extern gnu_nat_target *gnu_target;
 
-#endif /* GNU_NAT_H */
+#endif /* GDB_GNU_NAT_H */
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
index 1aca9ddd118..030febc4215 100644
--- a/gdb/go-lang.h
+++ b/gdb/go-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GO_LANG_H)
-#define GO_LANG_H 1
+#ifndef GDB_GO_LANG_H
+#define GDB_GO_LANG_H
 
 struct type_print_options;
 
@@ -144,4 +144,4 @@ class go_language : public language_defn
   { return true; }
 };
 
-#endif /* !defined (GO_LANG_H) */
+#endif /* GDB_GO_LANG_H */
diff --git a/gdb/gregset.h b/gdb/gregset.h
index 8c14809a47d..9345625d98a 100644
--- a/gdb/gregset.h
+++ b/gdb/gregset.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GREGSET_H
-#define GREGSET_H
+#ifndef GDB_GREGSET_H
+#define GDB_GREGSET_H
 
 #ifdef HAVE_SYS_PROCFS_H
 #include <sys/procfs.h>
@@ -60,4 +60,4 @@ extern void fill_gregset (const struct regcache *regcache,
 extern void fill_fpregset (const struct regcache *regcache,
 			   gdb_fpregset_t *fpregs, int regno);
 
-#endif
+#endif /* GDB_GREGSET_H */
diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h
index be16fee0dd2..c2856478eed 100644
--- a/gdb/guile/guile-internal.h
+++ b/gdb/guile/guile-internal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GUILE_GUILE_INTERNAL_H
-#define GUILE_GUILE_INTERNAL_H
+#ifndef GDB_GUILE_GUILE_INTERNAL_H
+#define GDB_GUILE_GUILE_INTERNAL_H
 
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
@@ -722,4 +722,4 @@ gdbscm_wrap (Function &&func, Args &&... args)
   return result;
 }
 
-#endif /* GUILE_GUILE_INTERNAL_H */
+#endif /* GDB_GUILE_GUILE_INTERNAL_H */
diff --git a/gdb/guile/guile.h b/gdb/guile/guile.h
index 2ab1f7552c7..6ce4864aabd 100644
--- a/gdb/guile/guile.h
+++ b/gdb/guile/guile.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GUILE_GUILE_H
-#define GUILE_GUILE_H
+#ifndef GDB_GUILE_GUILE_H
+#define GDB_GUILE_GUILE_H
 
 #include "extension.h"
 
@@ -28,4 +28,4 @@ extern const struct extension_language_defn extension_language_guile;
 /* Command element for the 'guile' command.  */
 extern cmd_list_element *guile_cmd_element;
 
-#endif /* GUILE_GUILE_H */
+#endif /* GDB_GUILE_GUILE_H */
diff --git a/gdb/hppa-bsd-tdep.h b/gdb/hppa-bsd-tdep.h
index 42aefe6e142..54599ab9ab4 100644
--- a/gdb/hppa-bsd-tdep.h
+++ b/gdb/hppa-bsd-tdep.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_BSD_TDEP_H
-#define HPPA_BSD_TDEP_H
+#ifndef GDB_HPPA_BSD_TDEP_H
+#define GDB_HPPA_BSD_TDEP_H
 
 extern void hppabsd_init_abi (struct gdbarch_info, struct gdbarch *);
 
-#endif /* hppa-bsd-tdep.h */
+#endif /* GDB_HPPA_BSD_TDEP_H */
diff --git a/gdb/hppa-linux-offsets.h b/gdb/hppa-linux-offsets.h
index b1543b05705..958afd115a8 100644
--- a/gdb/hppa-linux-offsets.h
+++ b/gdb/hppa-linux-offsets.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_LINUX_OFFSETS_H
-#define HPPA_LINUX_OFFSETS_H
+#ifndef GDB_HPPA_LINUX_OFFSETS_H
+#define GDB_HPPA_LINUX_OFFSETS_H
 
 #define PT_PSW offsetof(struct pt_regs, gr[ 0])
 #define PT_GR1 offsetof(struct pt_regs, gr[ 1])
@@ -105,4 +105,4 @@
 #define PT_ISR offsetof(struct pt_regs, isr)
 #define PT_IOR offsetof(struct pt_regs, ior)
 
-#endif /* HPPA_LINUX_OFFSETS_H */
+#endif /* GDB_HPPA_LINUX_OFFSETS_H */
diff --git a/gdb/hppa-tdep.h b/gdb/hppa-tdep.h
index 0f706536cc9..e1143a56bcd 100644
--- a/gdb/hppa-tdep.h
+++ b/gdb/hppa-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_TDEP_H
-#define HPPA_TDEP_H
+#ifndef GDB_HPPA_TDEP_H
+#define GDB_HPPA_TDEP_H
 
 #include "gdbarch.h"
 
@@ -214,4 +214,4 @@ extern int hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
 					  CORE_ADDR pc);
 extern CORE_ADDR hppa_skip_trampoline_code (const frame_info_ptr &, CORE_ADDR pc);
 
-#endif  /* hppa-tdep.h */
+#endif /* GDB_HPPA_TDEP_H */
diff --git a/gdb/i386-bsd-nat.h b/gdb/i386-bsd-nat.h
index a05eb90d4f8..54061ab46d1 100644
--- a/gdb/i386-bsd-nat.h
+++ b/gdb/i386-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_BSD_NAT_H
-#define I386_BSD_NAT_H
+#ifndef GDB_I386_BSD_NAT_H
+#define GDB_I386_BSD_NAT_H
 
 #include "x86-bsd-nat.h"
 
@@ -41,4 +41,4 @@ class i386_bsd_nat_target : public x86bsd_nat_target<BaseTarget>
   { i386bsd_store_inferior_registers (regcache, regnum); }
 };
 
-#endif /* i386-bsd-nat.h */
+#endif /* GDB_I386_BSD_NAT_H */
diff --git a/gdb/i386-darwin-tdep.h b/gdb/i386-darwin-tdep.h
index 0b867fab94c..7ccdeeced13 100644
--- a/gdb/i386-darwin-tdep.h
+++ b/gdb/i386-darwin-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_DARWIN_TDEP_H
-#define I386_DARWIN_TDEP_H
+#ifndef GDB_I386_DARWIN_TDEP_H
+#define GDB_I386_DARWIN_TDEP_H
 
 #include "frame.h"
 
@@ -29,4 +29,4 @@ extern const int i386_darwin_thread_state_num_regs;
 
 int darwin_dwarf_signal_frame_p (struct gdbarch *, const frame_info_ptr &);
 
-#endif /* I386_DARWIN_TDEP_H */
+#endif /* GDB_I386_DARWIN_TDEP_H */
diff --git a/gdb/i386-fbsd-tdep.h b/gdb/i386-fbsd-tdep.h
index 0a008421915..3b953e58435 100644
--- a/gdb/i386-fbsd-tdep.h
+++ b/gdb/i386-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_FBSD_TDEP_H
-#define I386_FBSD_TDEP_H
+#ifndef GDB_I386_FBSD_TDEP_H
+#define GDB_I386_FBSD_TDEP_H
 
 #include "gdbsupport/x86-xstate.h"
 #include "regset.h"
@@ -42,4 +42,4 @@ bool i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
 
 extern const struct regset i386_fbsd_gregset;
 
-#endif /* i386-fbsd-tdep.h */
+#endif /* GDB_I386_FBSD_TDEP_H */
diff --git a/gdb/i386-linux-nat.h b/gdb/i386-linux-nat.h
index c3d32aff1be..e4a86c70382 100644
--- a/gdb/i386-linux-nat.h
+++ b/gdb/i386-linux-nat.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_LINUX_NAT_H
-#define I386_LINUX_NAT_H 1
+#ifndef GDB_I386_LINUX_NAT_H
+#define GDB_I386_LINUX_NAT_H
 
 /* Does the current host support the GETFPXREGS request? */
 extern int have_ptrace_getfpxregs;
 
-#endif
+#endif /* GDB_I386_LINUX_NAT_H */
diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h
index 5891747572b..025b0f5fc51 100644
--- a/gdb/i386-linux-tdep.h
+++ b/gdb/i386-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_LINUX_TDEP_H
-#define I386_LINUX_TDEP_H
+#ifndef GDB_I386_LINUX_TDEP_H
+#define GDB_I386_LINUX_TDEP_H
 
 #include "gdbsupport/x86-xstate.h"
 
@@ -83,4 +83,4 @@ extern int i386_linux_gregset_reg_offset[];
 /* Return x86 siginfo type.  */
 extern struct type *x86_linux_get_siginfo_type (struct gdbarch *gdbarch);
 
-#endif /* i386-linux-tdep.h */
+#endif /* GDB_I386_LINUX_TDEP_H */
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index a85e0a984a0..e394e159c04 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_TDEP_H
-#define I386_TDEP_H
+#ifndef GDB_I386_TDEP_H
+#define GDB_I386_TDEP_H
 
 #include "gdbarch.h"
 #include "infrun.h"
@@ -488,4 +488,4 @@ extern int i386_stap_is_single_operand (struct gdbarch *gdbarch,
 extern expr::operation_up i386_stap_parse_special_token
      (struct gdbarch *gdbarch, struct stap_parse_info *p);
 
-#endif /* i386-tdep.h */
+#endif /* GDB_I386_TDEP_H */
diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h
index 30d769478a6..77e089ab723 100644
--- a/gdb/i387-tdep.h
+++ b/gdb/i387-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I387_TDEP_H
-#define I387_TDEP_H
+#ifndef GDB_I387_TDEP_H
+#define GDB_I387_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -185,4 +185,4 @@ extern void i387_return_value (struct gdbarch *gdbarch,
    all memory range can be accessed.  */
 extern void i387_reset_bnd_regs (struct gdbarch *gdbarch,
 				 struct regcache *regcache);
-#endif /* i387-tdep.h */
+#endif /* GDB_I387_TDEP_H */
diff --git a/gdb/ia64-libunwind-tdep.h b/gdb/ia64-libunwind-tdep.h
index 4f064bfc333..9d358642d9f 100644
--- a/gdb/ia64-libunwind-tdep.h
+++ b/gdb/ia64-libunwind-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef IA64_LIBUNWIND_TDEP_H
-#define IA64_LIBUNWIND_TDEP_H 1
+#ifndef GDB_IA64_LIBUNWIND_TDEP_H
+#define GDB_IA64_LIBUNWIND_TDEP_H
 
 class frame_info_ptr;
 struct frame_id;
@@ -76,4 +76,4 @@ int libunwind_get_reg_special (struct gdbarch *gdbarch,
 			       readable_regcache *regcache,
 			       int regnum, void *buf);
 
-#endif /* IA64_LIBUNWIND_TDEP_H */
+#endif /* GDB_IA64_LIBUNWIND_TDEP_H */
diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h
index 64be38b4d76..e5eb7eac071 100644
--- a/gdb/ia64-tdep.h
+++ b/gdb/ia64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef IA64_TDEP_H
-#define IA64_TDEP_H
+#ifndef GDB_IA64_TDEP_H
+#define GDB_IA64_TDEP_H
 
 #include "gdbarch.h"
 
@@ -265,4 +265,4 @@ extern unw_accessors_t ia64_unw_rse_accessors;
 extern struct libunwind_descr ia64_libunwind_descr;
 #endif
 
-#endif /* ia64-tdep.h */
+#endif /* GDB_IA64_TDEP_H */
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index 91955a64f4c..2a251b365f2 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_CHILD_H
-#define INF_CHILD_H
+#ifndef GDB_INF_CHILD_H
+#define GDB_INF_CHILD_H
 
 #include "target.h"
 #include "process-stratum-target.h"
@@ -115,4 +115,4 @@ extern void add_inf_child_target (inf_child_target *target);
    targets use add_inf_child_target instead.  */
 extern void inf_child_open_target (const char *arg, int from_tty);
 
-#endif
+#endif /* GDB_INF_CHILD_H */
diff --git a/gdb/inf-loop.h b/gdb/inf-loop.h
index ceabd14bd9e..2bf29fa7498 100644
--- a/gdb/inf-loop.h
+++ b/gdb/inf-loop.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_LOOP_H
-#define INF_LOOP_H
+#ifndef GDB_INF_LOOP_H
+#define GDB_INF_LOOP_H
 
 #include "target.h"
 
 extern void inferior_event_handler (enum inferior_event_type event_type);
 
-#endif /* #ifndef INF_LOOP_H */
+#endif /* GDB_INF_LOOP_H */
diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h
index 868bee92da8..901f7e9162d 100644
--- a/gdb/inf-ptrace.h
+++ b/gdb/inf-ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_PTRACE_H
-#define INF_PTRACE_H
+#ifndef GDB_INF_PTRACE_H
+#define GDB_INF_PTRACE_H
 
 #include "gdbsupport/event-pipe.h"
 #include "inf-child.h"
@@ -113,4 +113,4 @@ struct inf_ptrace_target : public inf_child_target
 extern pid_t get_ptrace_pid (ptid_t);
 #endif
 
-#endif
+#endif /* GDB_INF_PTRACE_H */
diff --git a/gdb/infcall.h b/gdb/infcall.h
index dcc701b5f31..eccf13307c7 100644
--- a/gdb/infcall.h
+++ b/gdb/infcall.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFCALL_H
-#define INFCALL_H
+#ifndef GDB_INFCALL_H
+#define GDB_INFCALL_H
 
 #include "dummy-frame.h"
 #include "gdbsupport/array-view.h"
@@ -71,4 +71,4 @@ extern struct value *
 
 extern void error_call_unknown_return_type (const char *func_name);
 
-#endif
+#endif /* GDB_INFCALL_H */
diff --git a/gdb/inferior-iter.h b/gdb/inferior-iter.h
index 821c7bec94e..05ddfca54c9 100644
--- a/gdb/inferior-iter.h
+++ b/gdb/inferior-iter.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFERIOR_ITER_H
-#define INFERIOR_ITER_H
+#ifndef GDB_INFERIOR_ITER_H
+#define GDB_INFERIOR_ITER_H
 
 #include "gdbsupport/filtered-iterator.h"
 #include "gdbsupport/safe-iterator.h"
@@ -132,4 +132,4 @@ using all_inferiors_safe_iterator
 
 using all_inferiors_safe_range = iterator_range<all_inferiors_safe_iterator>;
 
-#endif /* !defined (INFERIOR_ITER_H) */
+#endif /* GDB_INFERIOR_ITER_H */
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 7be28423aeb..4163396b775 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (INFERIOR_H)
-#define INFERIOR_H 1
+#ifndef GDB_INFERIOR_H
+#define GDB_INFERIOR_H
 
 #include <exception>
 #include <list>
@@ -869,4 +869,4 @@ valid_global_inferior_id (int id)
   return false;
 }
 
-#endif /* !defined (INFERIOR_H) */
+#endif /* GDB_INFERIOR_H */
diff --git a/gdb/infrun.h b/gdb/infrun.h
index 5f83ca2b4c3..4574874706e 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFRUN_H
-#define INFRUN_H 1
+#ifndef GDB_INFRUN_H
+#define GDB_INFRUN_H
 
 #include "gdbthread.h"
 #include "symtab.h"
@@ -418,4 +418,4 @@ struct scoped_enable_commit_resumed
 };
 
 
-#endif /* INFRUN_H */
+#endif /* GDB_INFRUN_H */
diff --git a/gdb/inline-frame.h b/gdb/inline-frame.h
index bbe617c7c5b..a11376f1d43 100644
--- a/gdb/inline-frame.h
+++ b/gdb/inline-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (INLINE_FRAME_H)
-#define INLINE_FRAME_H 1
+#ifndef GDB_INLINE_FRAME_H
+#define GDB_INLINE_FRAME_H
 
 class frame_info_ptr;
 struct frame_unwind;
@@ -70,4 +70,4 @@ struct symbol *inline_skipped_symbol (thread_info *thread);
 
 int frame_inlined_callees (const frame_info_ptr &this_frame);
 
-#endif /* !defined (INLINE_FRAME_H) */
+#endif /* GDB_INLINE_FRAME_H */
diff --git a/gdb/interps.h b/gdb/interps.h
index bd435d734af..726b660684e 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INTERPS_H
-#define INTERPS_H
+#ifndef GDB_INTERPS_H
+#define GDB_INTERPS_H
 
 #include "gdbsupport/intrusive_list.h"
 
@@ -372,4 +372,4 @@ extern void interps_notify_memory_changed (inferior *inf, CORE_ADDR addr,
 #define INTERP_TUI		"tui"
 #define INTERP_INSIGHT		"insight"
 
-#endif
+#endif /* GDB_INTERPS_H */
diff --git a/gdb/jit.h b/gdb/jit.h
index ade0fb28ce2..59ad900c4e0 100644
--- a/gdb/jit.h
+++ b/gdb/jit.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef JIT_H
-#define JIT_H
+#ifndef GDB_JIT_H
+#define GDB_JIT_H
 
 struct inferior;
 struct objfile;
@@ -122,4 +122,4 @@ extern void jit_breakpoint_re_set (void);
 
 extern void jit_event_handler (gdbarch *gdbarch, objfile *jiter);
 
-#endif /* JIT_H */
+#endif /* GDB_JIT_H */
diff --git a/gdb/language.h b/gdb/language.h
index e67150d7596..157c46877d2 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (LANGUAGE_H)
-#define LANGUAGE_H 1
+#ifndef GDB_LANGUAGE_H
+#define GDB_LANGUAGE_H
 
 #include "symtab.h"
 #include "gdbsupport/function-view.h"
@@ -911,4 +911,4 @@ class scoped_switch_to_sym_language_if_auto
   enum language m_lang;
 };
 
-#endif /* defined (LANGUAGE_H) */
+#endif /* GDB_LANGUAGE_H */
diff --git a/gdb/linespec.h b/gdb/linespec.h
index 18f491d74d0..86eb36bbae9 100644
--- a/gdb/linespec.h
+++ b/gdb/linespec.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (LINESPEC_H)
-#define LINESPEC_H 1
+#ifndef GDB_LINESPEC_H
+#define GDB_LINESPEC_H
 
 struct symtab;
 
@@ -201,4 +201,4 @@ extern void linespec_complete_label (completion_tracker &tracker,
    advancing EXP_PTR past any parsed text.  */
 
 extern CORE_ADDR linespec_expression_to_pc (const char **exp_ptr);
-#endif /* defined (LINESPEC_H) */
+#endif /* GDB_LINESPEC_H */
diff --git a/gdb/linux-fork.h b/gdb/linux-fork.h
index c553aaf0740..2a306881695 100644
--- a/gdb/linux-fork.h
+++ b/gdb/linux-fork.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_FORK_H
-#define LINUX_FORK_H
+#ifndef GDB_LINUX_FORK_H
+#define GDB_LINUX_FORK_H
 
 struct fork_info;
 struct lwp_info;
@@ -30,4 +30,4 @@ extern void linux_fork_detach (int, lwp_info *);
 extern int forks_exist_p (void);
 extern int linux_fork_checkpointing_p (int);
 
-#endif /* LINUX_FORK_H */
+#endif /* GDB_LINUX_FORK_H */
diff --git a/gdb/linux-nat-trad.h b/gdb/linux-nat-trad.h
index ae40ce773b4..c1c031ea27d 100644
--- a/gdb/linux-nat-trad.h
+++ b/gdb/linux-nat-trad.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_NAT_TRAD_H
-#define LINUX_NAT_TRAD_H
+#ifndef GDB_LINUX_NAT_TRAD_H
+#define GDB_LINUX_NAT_TRAD_H
 
 #include "linux-nat.h"
 
@@ -43,4 +43,4 @@ class linux_nat_trad_target : public linux_nat_target
   void store_register (const struct regcache *regcache, int regnum);
 };
 
-#endif /* LINUX_NAT_TRAD_H */
+#endif /* GDB_LINUX_NAT_TRAD_H */
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 4dcbe9e170a..01e071e0f89 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_NAT_H
-#define LINUX_NAT_H
+#ifndef GDB_LINUX_NAT_H
+#define GDB_LINUX_NAT_H
 
 #include "nat/linux-nat.h"
 #include "inf-ptrace.h"
@@ -339,4 +339,4 @@ void linux_nat_switch_fork (ptid_t new_ptid);
    uninitialized in such case).  */
 bool linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
 
-#endif /* LINUX_NAT_H */
+#endif /* GDB_LINUX_NAT_H */
diff --git a/gdb/linux-record.h b/gdb/linux-record.h
index 962cedc3d34..26d113b6a65 100644
--- a/gdb/linux-record.h
+++ b/gdb/linux-record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_RECORD_H
-#define LINUX_RECORD_H
+#ifndef GDB_LINUX_RECORD_H
+#define GDB_LINUX_RECORD_H
 
 struct linux_record_tdep
 {
@@ -549,4 +549,4 @@ extern int record_linux_system_call (enum gdb_syscall num,
 				     struct regcache *regcache,
 				     struct linux_record_tdep *tdep);
 
-#endif /* LINUX_RECORD_H */
+#endif /* GDB_LINUX_RECORD_H */
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index 66b03cabaa6..bf4220bf75b 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_TDEP_H
-#define LINUX_TDEP_H
+#ifndef GDB_LINUX_TDEP_H
+#define GDB_LINUX_TDEP_H
 
 #include "bfd.h"
 #include "displaced-stepping.h"
@@ -117,4 +117,4 @@ extern CORE_ADDR linux_get_hwcap2 ();
 extern struct link_map_offsets *linux_ilp32_fetch_link_map_offsets ();
 extern struct link_map_offsets *linux_lp64_fetch_link_map_offsets ();
 
-#endif /* linux-tdep.h */
+#endif /* GDB_LINUX_TDEP_H */
diff --git a/gdb/location.h b/gdb/location.h
index e8cdd0d4ec6..7772d10426f 100644
--- a/gdb/location.h
+++ b/gdb/location.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LOCATION_H
-#define LOCATION_H
+#ifndef GDB_LOCATION_H
+#define GDB_LOCATION_H
 
 #include "symtab.h"
 
@@ -365,4 +365,4 @@ extern location_spec_up
 				    const struct language_defn *language,
 				    explicit_completion_info *completion_info);
 
-#endif /* LOCATION_H */
+#endif /* GDB_LOCATION_H */
diff --git a/gdb/loongarch-tdep.h b/gdb/loongarch-tdep.h
index 5c8108182ad..4908923db20 100644
--- a/gdb/loongarch-tdep.h
+++ b/gdb/loongarch-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LOONGARCH_TDEP_H
-#define LOONGARCH_TDEP_H
+#ifndef GDB_LOONGARCH_TDEP_H
+#define GDB_LOONGARCH_TDEP_H
 
 #include "gdbarch.h"
 #include "arch/loongarch.h"
@@ -44,4 +44,4 @@ struct loongarch_gdbarch_tdep : gdbarch_tdep_base
   CORE_ADDR (*syscall_next_pc) (const frame_info_ptr &frame) = nullptr;
 };
 
-#endif /* LOONGARCH_TDEP_H  */
+#endif /* GDB_LOONGARCH_TDEP_H */
diff --git a/gdb/m2-exp.h b/gdb/m2-exp.h
index 9d2634f813b..ce773cbf864 100644
--- a/gdb/m2-exp.h
+++ b/gdb/m2-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M2_EXP_H
-#define M2_EXP_H
+#ifndef GDB_M2_EXP_H
+#define GDB_M2_EXP_H
 
 #include "expop.h"
 
@@ -81,4 +81,4 @@ class m2_binop_subscript_operation
 
 } /* namespace expr */
 
-#endif /* M2_EXP_H */
+#endif /* GDB_M2_EXP_H */
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index 3d3c6980bb2..1551d7e00d6 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M2_LANG_H
-#define M2_LANG_H
+#ifndef GDB_M2_LANG_H
+#define GDB_M2_LANG_H
 
 struct type_print_options;
 struct parser_state;
@@ -149,4 +149,4 @@ class m2_language : public language_defn
   { return true; }
 };
 
-#endif /* M2_LANG_H */
+#endif /* GDB_M2_LANG_H */
diff --git a/gdb/m32r-tdep.h b/gdb/m32r-tdep.h
index 83799a3c698..1cc0de38c15 100644
--- a/gdb/m32r-tdep.h
+++ b/gdb/m32r-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M32R_TDEP_H
-#define M32R_TDEP_H
+#ifndef GDB_M32R_TDEP_H
+#define GDB_M32R_TDEP_H
 
 #include "gdbarch.h"
 
@@ -49,4 +49,4 @@ enum m32r_regnum
 
 #define M32R_NUM_REGS 25
 
-#endif /* m32r-tdep.h */
+#endif /* GDB_M32R_TDEP_H */
diff --git a/gdb/m68k-tdep.h b/gdb/m68k-tdep.h
index dcb3728896e..ad569932144 100644
--- a/gdb/m68k-tdep.h
+++ b/gdb/m68k-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M68K_TDEP_H
-#define M68K_TDEP_H
+#ifndef GDB_M68K_TDEP_H
+#define GDB_M68K_TDEP_H
 
 #include "gdbarch.h"
 
@@ -111,4 +111,4 @@ extern void m68k_svr4_init_abi (struct gdbarch_info, struct gdbarch *);
 
 extern int m68kbsd_fpreg_offset (struct gdbarch *gdbarch, int regnum);
 
-#endif /* m68k-tdep.h */
+#endif /* GDB_M68K_TDEP_H */
diff --git a/gdb/macroexp.h b/gdb/macroexp.h
index 2706f15787f..6fd5dc27916 100644
--- a/gdb/macroexp.h
+++ b/gdb/macroexp.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef MACROEXP_H
-#define MACROEXP_H
+#ifndef GDB_MACROEXP_H
+#define GDB_MACROEXP_H
 
 struct macro_scope;
 
@@ -81,4 +81,4 @@ int macro_is_digit (int c);
 /* Stringify STR according to C rules and return a null-terminated string.  */
 gdb::unique_xmalloc_ptr<char> macro_stringify (const char *str);
 
-#endif /* MACROEXP_H */
+#endif /* GDB_MACROEXP_H */
diff --git a/gdb/macroscope.h b/gdb/macroscope.h
index 6a1f5f0a3fe..ce9ae33838f 100644
--- a/gdb/macroscope.h
+++ b/gdb/macroscope.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MACROSCOPE_H
-#define MACROSCOPE_H
+#ifndef GDB_MACROSCOPE_H
+#define GDB_MACROSCOPE_H
 
 #include "macrotab.h"
 #include "symtab.h"
@@ -61,4 +61,4 @@ gdb::unique_xmalloc_ptr<struct macro_scope> default_macro_scope (void);
 macro_definition *standard_macro_lookup (const char *name,
 					 const macro_scope &ms);
 
-#endif /* MACROSCOPE_H */
+#endif /* GDB_MACROSCOPE_H */
diff --git a/gdb/macrotab.h b/gdb/macrotab.h
index 789beed0476..ea6557aa391 100644
--- a/gdb/macrotab.h
+++ b/gdb/macrotab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MACROTAB_H
-#define MACROTAB_H
+#ifndef GDB_MACROTAB_H
+#define GDB_MACROTAB_H
 
 #include "gdbsupport/function-view.h"
 
@@ -361,4 +361,4 @@ void macro_for_each_in_scope (struct macro_source_file *file, int line,
    of macro filenames printing was "absolute".  */
 extern std::string macro_source_fullname (struct macro_source_file *file);
 
-#endif /* MACROTAB_H */
+#endif /* GDB_MACROTAB_H */
diff --git a/gdb/main.h b/gdb/main.h
index fa267786d89..35dfe9d4729 100644
--- a/gdb/main.h
+++ b/gdb/main.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MAIN_H
-#define MAIN_H
+#ifndef GDB_MAIN_H
+#define GDB_MAIN_H
 
 struct captured_main_args
 {
@@ -46,4 +46,4 @@ extern char *windows_get_absolute_argv0 (const char *argv0);
 
 extern void set_gdb_data_directory (const char *new_data_dir);
 
-#endif
+#endif /* GDB_MAIN_H */
diff --git a/gdb/maint.h b/gdb/maint.h
index c1860d8cd59..5529d8a9d3a 100644
--- a/gdb/maint.h
+++ b/gdb/maint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MAINT_H
-#define MAINT_H
+#ifndef GDB_MAINT_H
+#define GDB_MAINT_H
 
 #include "gdbsupport/run-time-clock.h"
 #include <chrono>
@@ -70,4 +70,4 @@ class scoped_command_stats
 extern obj_section *maint_obj_section_from_bfd_section (bfd *abfd,
 							asection *asection,
 							objfile *ofile);
-#endif /* MAINT_H */
+#endif /* GDB_MAINT_H */
diff --git a/gdb/mdebugread.h b/gdb/mdebugread.h
index af0584bd3e6..4f434226ff9 100644
--- a/gdb/mdebugread.h
+++ b/gdb/mdebugread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MDEBUGREAD_H
-#define MDEBUGREAD_H
+#ifndef GDB_MDEBUGREAD_H
+#define GDB_MDEBUGREAD_H
 
 #include "coff/sym.h"
 #include "coff/symconst.h"
@@ -46,4 +46,4 @@ extern void elfmdebug_build_psymtabs (struct objfile *,
 				      const struct ecoff_debug_swap *,
 				      asection *);
 
-#endif /* MDEBUGREAD_H */
+#endif /* GDB_MDEBUGREAD_H */
diff --git a/gdb/memattr.h b/gdb/memattr.h
index dcc52298846..a6c9e6dcd8c 100644
--- a/gdb/memattr.h
+++ b/gdb/memattr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMATTR_H
-#define MEMATTR_H
+#ifndef GDB_MEMATTR_H
+#define GDB_MEMATTR_H
 
 enum mem_access_mode
 {
@@ -129,4 +129,4 @@ extern struct mem_region *lookup_mem_region (CORE_ADDR);
 
 void invalidate_target_mem_regions (void);
 
-#endif	/* MEMATTR_H */
+#endif /* GDB_MEMATTR_H */
diff --git a/gdb/memory-map.h b/gdb/memory-map.h
index 525646b6e37..59fcd4a9f73 100644
--- a/gdb/memory-map.h
+++ b/gdb/memory-map.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef MEMORY_MAP_H
-#define MEMORY_MAP_H
+#ifndef GDB_MEMORY_MAP_H
+#define GDB_MEMORY_MAP_H
 
 #include "memattr.h"
 
@@ -28,4 +28,4 @@
    return an empty vector.  Does not throw.  */
 std::vector<mem_region> parse_memory_map (const char *memory_map);
 
-#endif
+#endif /* GDB_MEMORY_MAP_H */
diff --git a/gdb/memrange.h b/gdb/memrange.h
index 74df82588f4..ec033ddb21e 100644
--- a/gdb/memrange.h
+++ b/gdb/memrange.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMRANGE_H
-#define MEMRANGE_H
+#ifndef GDB_MEMRANGE_H
+#define GDB_MEMRANGE_H
 
 /* Defines a [START, START + LENGTH) memory range.  */
 
@@ -64,4 +64,4 @@ extern int address_in_mem_range (CORE_ADDR addr,
 
 extern void normalize_mem_ranges (std::vector<mem_range> *memory);
 
-#endif
+#endif /* GDB_MEMRANGE_H */
diff --git a/gdb/memtag.h b/gdb/memtag.h
index b176371699c..600b4b9db74 100644
--- a/gdb/memtag.h
+++ b/gdb/memtag.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMTAG_H
-#define MEMTAG_H
+#ifndef GDB_MEMTAG_H
+#define GDB_MEMTAG_H
 
 #include "bfd.h"
 
@@ -47,4 +47,4 @@ bool get_next_core_memtag_section (bfd *abfd, asection *section,
 				   CORE_ADDR address,
 				   memtag_section_info &info);
 
-#endif /* MEMTAG_H */
+#endif /* GDB_MEMTAG_H */
diff --git a/gdb/mi/mi-cmd-break.h b/gdb/mi/mi-cmd-break.h
index 76aedfffcd9..160c578865d 100644
--- a/gdb/mi/mi-cmd-break.h
+++ b/gdb/mi/mi-cmd-break.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CMD_BREAK_H
-#define MI_MI_CMD_BREAK_H
+#ifndef GDB_MI_MI_CMD_BREAK_H
+#define GDB_MI_MI_CMD_BREAK_H
 
 #include "gdbsupport/scoped_restore.h"
 
@@ -27,4 +27,4 @@
    catchpoint.  */
 scoped_restore_tmpl<int> setup_breakpoint_reporting (void);
 
-#endif /* MI_MI_CMD_BREAK_H */
+#endif /* GDB_MI_MI_CMD_BREAK_H */
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index 26faded3032..9e31ba397b0 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CMDS_H
-#define MI_MI_CMDS_H
+#ifndef GDB_MI_MI_CMDS_H
+#define GDB_MI_MI_CMDS_H
 
 #include "gdbsupport/function-view.h"
 #include <optional>
@@ -237,4 +237,4 @@ extern void remove_mi_cmd_entries (remove_mi_cmd_entries_ftype callback);
 
 extern bool mi_simple_type_p (struct type *type);
 
-#endif /* MI_MI_CMDS_H */
+#endif /* GDB_MI_MI_CMDS_H */
diff --git a/gdb/mi/mi-common.h b/gdb/mi/mi-common.h
index 38ad35c3e36..4c3951ca8c0 100644
--- a/gdb/mi/mi-common.h
+++ b/gdb/mi/mi-common.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_COMMON_H
-#define MI_MI_COMMON_H
+#ifndef GDB_MI_MI_COMMON_H
+#define GDB_MI_MI_COMMON_H
 
 /* Represents the reason why GDB is sending an asynchronous command to
    the front end.  NOTE: When modifying this, don't forget to update
@@ -49,4 +49,4 @@ enum async_reply_reason
 
 const char *async_reason_lookup (enum async_reply_reason reason);
 
-#endif /* MI_MI_COMMON_H */
+#endif /* GDB_MI_MI_COMMON_H */
diff --git a/gdb/mi/mi-console.h b/gdb/mi/mi-console.h
index 89ba199fbce..89e0f4d3db6 100644
--- a/gdb/mi/mi-console.h
+++ b/gdb/mi/mi-console.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CONSOLE_H
-#define MI_MI_CONSOLE_H
+#ifndef GDB_MI_MI_CONSOLE_H
+#define GDB_MI_MI_CONSOLE_H
 
 /* An output stream for MI.  Wraps a given output stream with a prefix
    and handles quoting.  This stream is locally buffered.  */
@@ -55,4 +55,4 @@ class mi_console_file : public ui_file
   char m_quote;
 };
 
-#endif /* MI_MI_CONSOLE_H */
+#endif /* GDB_MI_MI_CONSOLE_H */
diff --git a/gdb/mi/mi-getopt.h b/gdb/mi/mi-getopt.h
index f3dd326fced..5bc35aa565a 100644
--- a/gdb/mi/mi-getopt.h
+++ b/gdb/mi/mi-getopt.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_GETOPT_H
-#define MI_MI_GETOPT_H
+#ifndef GDB_MI_MI_GETOPT_H
+#define GDB_MI_MI_GETOPT_H
 
 /* The option list.  Terminated by NAME==NULL.  ARG_P that the option
    requires an argument.  INDEX is returned to identify the option.  */
@@ -78,4 +78,4 @@ extern int mi_getopt_allow_unknown (const char *prefix, int argc,
 extern int mi_valid_noargs (const char *prefix, int argc,
 			    const char *const *argv);
 
-#endif /* MI_MI_GETOPT_H */
+#endif /* GDB_MI_MI_GETOPT_H */
diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h
index cd48fcf0aa1..8f5eee6f558 100644
--- a/gdb/mi/mi-interp.h
+++ b/gdb/mi/mi-interp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_INTERP_H
-#define MI_MI_INTERP_H
+#ifndef GDB_MI_MI_INTERP_H
+#define GDB_MI_MI_INTERP_H
 
 #include "interps.h"
 
@@ -119,4 +119,4 @@ as_mi_interp (struct interp *interp)
   return dynamic_cast<mi_interp *> (interp);
 }
 
-#endif /* MI_MI_INTERP_H */
+#endif /* GDB_MI_MI_INTERP_H */
diff --git a/gdb/mi/mi-main.h b/gdb/mi/mi-main.h
index 59c9ffa31bb..af670295c1f 100644
--- a/gdb/mi/mi-main.h
+++ b/gdb/mi/mi-main.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_MAIN_H
-#define MI_MI_MAIN_H
+#ifndef GDB_MI_MI_MAIN_H
+#define GDB_MI_MI_MAIN_H
 
 struct ui_file;
 
@@ -79,4 +79,4 @@ extern void mi_cmd_fix_breakpoint_script_output (const char *command,
 
 extern int mi_parse_thread_group_id (const char *id);
 
-#endif /* MI_MI_MAIN_H */
+#endif /* GDB_MI_MI_MAIN_H */
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index a7afb156ed4..16e6db2456e 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_OUT_H
-#define MI_MI_OUT_H
+#ifndef GDB_MI_MI_OUT_H
+#define GDB_MI_MI_OUT_H
 
 #include <vector>
 
@@ -151,4 +151,4 @@ std::unique_ptr<mi_ui_out> mi_out_new (const char *mi_version);
 void mi_out_put (ui_out *uiout, struct ui_file *stream);
 void mi_out_rewind (ui_out *uiout);
 
-#endif /* MI_MI_OUT_H */
+#endif /* GDB_MI_MI_OUT_H */
diff --git a/gdb/mi/mi-parse.h b/gdb/mi/mi-parse.h
index 8b685755a5c..22d10185925 100644
--- a/gdb/mi/mi-parse.h
+++ b/gdb/mi/mi-parse.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_PARSE_H
-#define MI_MI_PARSE_H
+#ifndef GDB_MI_MI_PARSE_H
+#define GDB_MI_MI_PARSE_H
 
 #include "gdbsupport/run-time-clock.h"
 #include <chrono>
@@ -101,4 +101,4 @@ struct mi_parse
 
 enum print_values mi_parse_print_values (const char *name);
 
-#endif /* MI_MI_PARSE_H */
+#endif /* GDB_MI_MI_PARSE_H */
diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
index 0b4a5a3f472..7b5924e9317 100644
--- a/gdb/microblaze-tdep.h
+++ b/gdb/microblaze-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MICROBLAZE_TDEP_H
-#define MICROBLAZE_TDEP_H 1
+#ifndef GDB_MICROBLAZE_TDEP_H
+#define GDB_MICROBLAZE_TDEP_H
 
 #include "gdbarch.h"
 
@@ -120,4 +120,4 @@ struct microblaze_frame_cache
    Only used for native debugging.  */
 #define MICROBLAZE_BREAKPOINT {0xb9, 0xcc, 0x00, 0x60}
 
-#endif /* microblaze-tdep.h */
+#endif /* GDB_MICROBLAZE_TDEP_H */
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index d44f281939b..4d704f0d35b 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MINSYMS_H
-#define MINSYMS_H
+#ifndef GDB_MINSYMS_H
+#define GDB_MINSYMS_H
 
 struct type;
 
@@ -327,4 +327,4 @@ CORE_ADDR minimal_symbol_upper_bound (struct bound_minimal_symbol minsym);
 type *find_minsym_type_and_address (minimal_symbol *msymbol, objfile *objf,
 				    CORE_ADDR *address_p);
 
-#endif /* MINSYMS_H */
+#endif /* GDB_MINSYMS_H */
diff --git a/gdb/mips-fbsd-tdep.h b/gdb/mips-fbsd-tdep.h
index ec834d0474a..201b1e5a793 100644
--- a/gdb/mips-fbsd-tdep.h
+++ b/gdb/mips-fbsd-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_FBSD_TDEP_H
-#define MIPS_FBSD_TDEP_H
+#ifndef GDB_MIPS_FBSD_TDEP_H
+#define GDB_MIPS_FBSD_TDEP_H
 
 void mips_fbsd_supply_fpregs (struct regcache *, int, const void *, size_t);
 void mips_fbsd_supply_gregs (struct regcache *, int, const void *, size_t);
 void mips_fbsd_collect_fpregs (const struct regcache *, int, void *, size_t);
 void mips_fbsd_collect_gregs (const struct regcache *, int, void *, size_t);
 
-#endif /* MIPS_FBSD_TDEP_H */
+#endif /* GDB_MIPS_FBSD_TDEP_H */
diff --git a/gdb/mips-linux-tdep.h b/gdb/mips-linux-tdep.h
index 2c4c35954c4..8670c0b7e15 100644
--- a/gdb/mips-linux-tdep.h
+++ b/gdb/mips-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_LINUX_TDEP_H
-#define MIPS_LINUX_TDEP_H
+#ifndef GDB_MIPS_LINUX_TDEP_H
+#define GDB_MIPS_LINUX_TDEP_H
 
 /* Copied from <asm/elf.h>.  */
 #define ELF_NGREG       45
@@ -113,4 +113,4 @@ extern const struct target_desc *tdesc_mips64_linux;
 extern const struct target_desc *tdesc_mips_dsp_linux;
 extern const struct target_desc *tdesc_mips64_dsp_linux;
 
-#endif /* MIPS_LINUX_TDEP_H */
+#endif /* GDB_MIPS_LINUX_TDEP_H */
diff --git a/gdb/mips-netbsd-tdep.h b/gdb/mips-netbsd-tdep.h
index 034261fbf44..e9544f0f1bf 100644
--- a/gdb/mips-netbsd-tdep.h
+++ b/gdb/mips-netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_NBSD_TDEP_H
-#define MIPS_NBSD_TDEP_H
+#ifndef GDB_MIPS_NETBSD_TDEP_H
+#define GDB_MIPS_NETBSD_TDEP_H
 
 void mipsnbsd_supply_reg (struct regcache *, const char *, int);
 void mipsnbsd_fill_reg (const struct regcache *, char *, int);
@@ -26,4 +26,4 @@ void mipsnbsd_fill_reg (const struct regcache *, char *, int);
 void mipsnbsd_supply_fpreg (struct regcache *, const char *, int);
 void mipsnbsd_fill_fpreg (const struct regcache *, char *, int);
 
-#endif /* MIPS_NBSD_TDEP_H */
+#endif /* GDB_MIPS_NETBSD_TDEP_H */
diff --git a/gdb/mips-tdep.h b/gdb/mips-tdep.h
index eec1fb56f4e..df589cf71b8 100644
--- a/gdb/mips-tdep.h
+++ b/gdb/mips-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_TDEP_H
-#define MIPS_TDEP_H
+#ifndef GDB_MIPS_TDEP_H
+#define GDB_MIPS_TDEP_H
 
 #include "objfiles.h"
 #include "gdbarch.h"
@@ -201,4 +201,4 @@ in_mips_stubs_section (CORE_ADDR pc)
   return pc_in_section (pc, ".MIPS.stubs");
 }
 
-#endif /* MIPS_TDEP_H */
+#endif /* GDB_MIPS_TDEP_H */
diff --git a/gdb/mn10300-tdep.h b/gdb/mn10300-tdep.h
index 683a6ec2e14..bec5f04253a 100644
--- a/gdb/mn10300-tdep.h
+++ b/gdb/mn10300-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MN10300_TDEP_H
-#define MN10300_TDEP_H
+#ifndef GDB_MN10300_TDEP_H
+#define GDB_MN10300_TDEP_H
 
 #include "gdbarch.h"
 
@@ -88,4 +88,4 @@ get_am33_mode (gdbarch *arch)
   return tdep->am33_mode;
 }
 
-#endif /* MN10300_TDEP_H */
+#endif /* GDB_MN10300_TDEP_H */
diff --git a/gdb/moxie-tdep.h b/gdb/moxie-tdep.h
index 64bfc825fc1..329d9972b49 100644
--- a/gdb/moxie-tdep.h
+++ b/gdb/moxie-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MOXIE_TDEP_H
-#define MOXIE_TDEP_H
+#ifndef GDB_MOXIE_TDEP_H
+#define GDB_MOXIE_TDEP_H
 
 #include "gdbarch.h"
 
@@ -42,4 +42,4 @@ enum moxie_regnum
 
 #define MOXIE_NUM_REGS 18
 
-#endif /* moxie-tdep.h */
+#endif /* GDB_MOXIE_TDEP_H */
diff --git a/gdb/namespace.h b/gdb/namespace.h
index 232dcc03bd8..a9b020f6395 100644
--- a/gdb/namespace.h
+++ b/gdb/namespace.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAMESPACE_H
-#define NAMESPACE_H
+#ifndef GDB_NAMESPACE_H
+#define GDB_NAMESPACE_H
 
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbsupport/gdb_obstack.h"
@@ -127,4 +127,4 @@ extern void add_using_directive (struct using_direct **using_directives,
 				 const unsigned int decl_line,
 				 struct obstack *obstack);
 
-#endif /* NAMESPACE_H */
+#endif /* GDB_NAMESPACE_H */
diff --git a/gdb/nat/aarch64-hw-point.h b/gdb/nat/aarch64-hw-point.h
index bdcca932e57..f4db38b494d 100644
--- a/gdb/nat/aarch64-hw-point.h
+++ b/gdb/nat/aarch64-hw-point.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_HW_POINT_H
-#define NAT_AARCH64_HW_POINT_H
+#ifndef GDB_NAT_AARCH64_HW_POINT_H
+#define GDB_NAT_AARCH64_HW_POINT_H
 
 /* Macro definitions, data structures, and code for the hardware
    breakpoint and hardware watchpoint support follow.  We use the
@@ -128,4 +128,4 @@ void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state,
 
 int aarch64_region_ok_for_watchpoint (CORE_ADDR addr, int len);
 
-#endif /* NAT_AARCH64_HW_POINT_H */
+#endif /* GDB_NAT_AARCH64_HW_POINT_H */
diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h
index cf749c34ae7..618f79f1587 100644
--- a/gdb/nat/aarch64-linux-hw-point.h
+++ b/gdb/nat/aarch64-linux-hw-point.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_LINUX_HW_POINT_H
-#define NAT_AARCH64_LINUX_HW_POINT_H
+#ifndef GDB_NAT_AARCH64_LINUX_HW_POINT_H
+#define GDB_NAT_AARCH64_LINUX_HW_POINT_H
 
 #include "gdbsupport/break-common.h"
 
@@ -109,4 +109,4 @@ void aarch64_linux_get_debug_reg_capacity (int tid);
 
 struct aarch64_debug_reg_state *aarch64_get_debug_reg_state (pid_t pid);
 
-#endif /* NAT_AARCH64_LINUX_HW_POINT_H */
+#endif /* GDB_NAT_AARCH64_LINUX_HW_POINT_H */
diff --git a/gdb/nat/aarch64-linux.h b/gdb/nat/aarch64-linux.h
index f4df7481162..969bb52b812 100644
--- a/gdb/nat/aarch64-linux.h
+++ b/gdb/nat/aarch64-linux.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_LINUX_H
-#define NAT_AARCH64_LINUX_H
+#ifndef GDB_NAT_AARCH64_LINUX_H
+#define GDB_NAT_AARCH64_LINUX_H
 
 #include <signal.h>
 
@@ -133,4 +133,4 @@ ps_err_e aarch64_ps_get_thread_area (struct ps_prochandle *ph,
    used for aarch64 state.  */
 int aarch64_tls_register_count (int tid);
 
-#endif /* NAT_AARCH64_LINUX_H */
+#endif /* GDB_NAT_AARCH64_LINUX_H */
diff --git a/gdb/nat/aarch64-mte-linux-ptrace.h b/gdb/nat/aarch64-mte-linux-ptrace.h
index 28dd8158c90..e02a0818963 100644
--- a/gdb/nat/aarch64-mte-linux-ptrace.h
+++ b/gdb/nat/aarch64-mte-linux-ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_MTE_LINUX_PTRACE_H
-#define NAT_AARCH64_MTE_LINUX_PTRACE_H
+#ifndef GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
+#define GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
 
 /* MTE allocation tag access */
 
@@ -47,4 +47,4 @@ extern bool aarch64_mte_fetch_memtags (int tid, CORE_ADDR address, size_t len,
 extern bool aarch64_mte_store_memtags (int tid, CORE_ADDR address, size_t len,
 				       const gdb::byte_vector &tags);
 
-#endif /* NAT_AARCH64_MTE_LINUX_PTRACE_H */
+#endif /* GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H */
diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h
index 2be45588785..2c6d899e931 100644
--- a/gdb/nat/aarch64-scalable-linux-ptrace.h
+++ b/gdb/nat/aarch64-scalable-linux-ptrace.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
-#define NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
+#ifndef GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
+#define GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
 
 #include <signal.h>
 #include <sys/utsname.h>
@@ -176,4 +176,4 @@ aarch64_zt_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf,
 extern void
 aarch64_zt_regs_copy_from_reg_buf (int tid, struct reg_buffer_common *reg_buf,
 				   int zt_regnum);
-#endif /* NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */
+#endif /* GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */
diff --git a/gdb/nat/aarch64-scalable-linux-sigcontext.h b/gdb/nat/aarch64-scalable-linux-sigcontext.h
index 8db524250a8..bfda9be617a 100644
--- a/gdb/nat/aarch64-scalable-linux-sigcontext.h
+++ b/gdb/nat/aarch64-scalable-linux-sigcontext.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
-#define NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
+#ifndef GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
+#define GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
 
 #ifndef SVE_SIG_ZREGS_SIZE
 
@@ -325,4 +325,4 @@ struct user_za_header {
 	(ZA_PT_ZA_OFFSET + ZA_PT_ZA_SIZE(vq))
 #endif /* ZA_PT_SIZE */
 
-#endif /* NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H */
+#endif /* GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H */
diff --git a/gdb/nat/amd64-linux-siginfo.h b/gdb/nat/amd64-linux-siginfo.h
index b8fd8c0e2ae..1e102ae99b3 100644
--- a/gdb/nat/amd64-linux-siginfo.h
+++ b/gdb/nat/amd64-linux-siginfo.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AMD64_LINUX_SIGINFO_H
-#define NAT_AMD64_LINUX_SIGINFO_H
+#ifndef GDB_NAT_AMD64_LINUX_SIGINFO_H
+#define GDB_NAT_AMD64_LINUX_SIGINFO_H
 
 #include <signal.h>
 
@@ -55,4 +55,4 @@ int amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf,
 				      int direction,
 				      enum amd64_siginfo_fixup_mode mode);
 
-#endif /* NAT_AMD64_LINUX_SIGINFO_H */
+#endif /* GDB_NAT_AMD64_LINUX_SIGINFO_H */
diff --git a/gdb/nat/fork-inferior.h b/gdb/nat/fork-inferior.h
index a609f68bcb4..509aa053764 100644
--- a/gdb/nat/fork-inferior.h
+++ b/gdb/nat/fork-inferior.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_FORK_INFERIOR_H
-#define NAT_FORK_INFERIOR_H
+#ifndef GDB_NAT_FORK_INFERIOR_H
+#define GDB_NAT_FORK_INFERIOR_H
 
 #include <string>
 #include "gdbsupport/function-view.h"
@@ -87,4 +87,4 @@ extern void trace_start_error (const char *fmt, ...)
 extern void trace_start_error_with_name (const char *string)
   ATTRIBUTE_NORETURN;
 
-#endif /* NAT_FORK_INFERIOR_H */
+#endif /* GDB_NAT_FORK_INFERIOR_H */
diff --git a/gdb/nat/gdb_ptrace.h b/gdb/nat/gdb_ptrace.h
index 81727cbdbd6..17858848a62 100644
--- a/gdb/nat/gdb_ptrace.h
+++ b/gdb/nat/gdb_ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GDB_PTRACE_H
-#define NAT_GDB_PTRACE_H
+#ifndef GDB_NAT_GDB_PTRACE_H
+#define GDB_NAT_GDB_PTRACE_H
 
 /* The <sys/ptrace.h> header was introduced with 4.4BSD, and provided
    the PT_* symbolic constants for the ptrace(2) request numbers.  The
@@ -142,4 +142,4 @@
 	 ptrace ((PTRACE_TYPE_ARG1) request, pid, addr, data)
 #endif
 
-#endif /* NAT_GDB_PTRACE_H */
+#endif /* GDB_NAT_GDB_PTRACE_H */
diff --git a/gdb/nat/gdb_thread_db.h b/gdb/nat/gdb_thread_db.h
index 0e683787c40..446b92129dd 100644
--- a/gdb/nat/gdb_thread_db.h
+++ b/gdb/nat/gdb_thread_db.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GDB_THREAD_DB_H
-#define NAT_GDB_THREAD_DB_H
+#ifndef GDB_NAT_GDB_THREAD_DB_H
+#define GDB_NAT_GDB_THREAD_DB_H
 
 #ifdef HAVE_THREAD_DB_H
 #include <thread_db.h>
@@ -73,4 +73,4 @@ typedef td_err_e (td_thr_tlsbase_ftype) (const td_thrhandle_t *th,
 typedef const char ** (td_symbol_list_ftype) (void);
 typedef td_err_e (td_ta_delete_ftype) (td_thragent_t *);
 
-#endif /* NAT_GDB_THREAD_DB_H */
+#endif /* GDB_NAT_GDB_THREAD_DB_H */
diff --git a/gdb/nat/glibc_thread_db.h b/gdb/nat/glibc_thread_db.h
index 598805deef2..87eb62b3efe 100644
--- a/gdb/nat/glibc_thread_db.h
+++ b/gdb/nat/glibc_thread_db.h
@@ -16,8 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GLIBC_THREAD_DB_H
-#define NAT_GLIBC_THREAD_DB_H
+#ifndef GDB_NAT_GLIBC_THREAD_DB_H
+#define GDB_NAT_GLIBC_THREAD_DB_H
 
 /* This is the debugger interface for the NPTL library.  It is
    modelled closely after the interface with same names in Solaris
@@ -455,4 +455,4 @@ extern td_err_e td_thr_dbsuspend (const td_thrhandle_t *__th);
 /* Resume execution of thread TH.  */
 extern td_err_e td_thr_dbresume (const td_thrhandle_t *__th);
 
-#endif /* NAT_GLIBC_THREAD_DB_H */
+#endif /* GDB_NAT_GLIBC_THREAD_DB_H */
diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
index 0771f4b5a65..6fd81073673 100644
--- a/gdb/nat/linux-btrace.h
+++ b/gdb/nat/linux-btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_BTRACE_H
-#define NAT_LINUX_BTRACE_H
+#ifndef GDB_NAT_LINUX_BTRACE_H
+#define GDB_NAT_LINUX_BTRACE_H
 
 #include "gdbsupport/btrace-common.h"
 #include "gdbsupport/gdb-checked-static-cast.h"
@@ -86,4 +86,4 @@ extern enum btrace_error linux_read_btrace (struct btrace_data *btrace,
 extern const struct btrace_config *
   linux_btrace_conf (const struct btrace_target_info *);
 
-#endif /* NAT_LINUX_BTRACE_H */
+#endif /* GDB_NAT_LINUX_BTRACE_H */
diff --git a/gdb/nat/linux-namespaces.h b/gdb/nat/linux-namespaces.h
index 298ff056653..4327292950b 100644
--- a/gdb/nat/linux-namespaces.h
+++ b/gdb/nat/linux-namespaces.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_NAMESPACES_H
-#define NAT_LINUX_NAMESPACES_H
+#ifndef GDB_NAT_LINUX_NAMESPACES_H
+#define GDB_NAT_LINUX_NAMESPACES_H
 
 /* Set to true to enable debugging of Linux namespaces code.  */
 
@@ -73,4 +73,4 @@ extern int linux_mntns_unlink (pid_t pid, const char *filename);
 extern ssize_t linux_mntns_readlink (pid_t pid, const char *filename,
 				     char *buf, size_t bufsiz);
 
-#endif /* NAT_LINUX_NAMESPACES_H */
+#endif /* GDB_NAT_LINUX_NAMESPACES_H */
diff --git a/gdb/nat/linux-nat.h b/gdb/nat/linux-nat.h
index d4a36cbb601..e847eb033bd 100644
--- a/gdb/nat/linux-nat.h
+++ b/gdb/nat/linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_NAT_H
-#define NAT_LINUX_NAT_H
+#ifndef GDB_NAT_LINUX_NAT_H
+#define GDB_NAT_LINUX_NAT_H
 
 #include "gdbsupport/function-view.h"
 #include "target/waitstatus.h"
@@ -91,4 +91,4 @@ extern void linux_stop_lwp (struct lwp_info *lwp);
 
 extern int lwp_is_stepping (struct lwp_info *lwp);
 
-#endif /* NAT_LINUX_NAT_H */
+#endif /* GDB_NAT_LINUX_NAT_H */
diff --git a/gdb/nat/linux-osdata.h b/gdb/nat/linux-osdata.h
index 833915cdb2f..a700ea1eb80 100644
--- a/gdb/nat/linux-osdata.h
+++ b/gdb/nat/linux-osdata.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_OSDATA_H
-#define NAT_LINUX_OSDATA_H
+#ifndef GDB_NAT_LINUX_OSDATA_H
+#define GDB_NAT_LINUX_OSDATA_H
 
 extern int linux_common_core_of_thread (ptid_t ptid);
 extern LONGEST linux_common_xfer_osdata (const char *annex, gdb_byte *readbuf,
 					 ULONGEST offset, ULONGEST len);
 
-#endif /* NAT_LINUX_OSDATA_H */
+#endif /* GDB_NAT_LINUX_OSDATA_H */
diff --git a/gdb/nat/linux-personality.h b/gdb/nat/linux-personality.h
index 0238fe0c7e5..ab6727076ad 100644
--- a/gdb/nat/linux-personality.h
+++ b/gdb/nat/linux-personality.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PERSONALITY_H
-#define NAT_LINUX_PERSONALITY_H
+#ifndef GDB_NAT_LINUX_PERSONALITY_H
+#define GDB_NAT_LINUX_PERSONALITY_H
 
 class maybe_disable_address_space_randomization
 {
@@ -43,4 +43,4 @@ class maybe_disable_address_space_randomization
   int m_personality_orig;
 };
 
-#endif /* ! NAT_LINUX_PERSONALITY_H */
+#endif /* GDB_NAT_LINUX_PERSONALITY_H */
diff --git a/gdb/nat/linux-procfs.h b/gdb/nat/linux-procfs.h
index 880afbcdd61..6b352d97f3d 100644
--- a/gdb/nat/linux-procfs.h
+++ b/gdb/nat/linux-procfs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PROCFS_H
-#define NAT_LINUX_PROCFS_H
+#ifndef GDB_NAT_LINUX_PROCFS_H
+#define GDB_NAT_LINUX_PROCFS_H
 
 #include <unistd.h>
 
@@ -85,4 +85,4 @@ extern const char *linux_proc_pid_to_exec_file (int pid);
 
 extern void linux_proc_init_warnings ();
 
-#endif /* NAT_LINUX_PROCFS_H */
+#endif /* GDB_NAT_LINUX_PROCFS_H */
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index a268432ad92..fee2a4f4c5d 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PTRACE_H
-#define NAT_LINUX_PTRACE_H
+#ifndef GDB_NAT_LINUX_PTRACE_H
+#define GDB_NAT_LINUX_PTRACE_H
 
 #include "nat/gdb_ptrace.h"
 #include "gdbsupport/gdb_wait.h"
@@ -189,4 +189,4 @@ extern int linux_ptrace_get_extended_event (int wstat);
 extern int linux_is_extended_waitstatus (int wstat);
 extern int linux_wstatus_maybe_breakpoint (int wstat);
 
-#endif /* NAT_LINUX_PTRACE_H */
+#endif /* GDB_NAT_LINUX_PTRACE_H */
diff --git a/gdb/nat/linux-waitpid.h b/gdb/nat/linux-waitpid.h
index e069f8a84a8..b75782d4520 100644
--- a/gdb/nat/linux-waitpid.h
+++ b/gdb/nat/linux-waitpid.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_WAITPID_H
-#define NAT_LINUX_WAITPID_H
+#ifndef GDB_NAT_LINUX_WAITPID_H
+#define GDB_NAT_LINUX_WAITPID_H
 
 /* Wrapper function for waitpid which handles EINTR.  */
 extern int my_waitpid (int pid, int *status, int flags);
@@ -27,4 +27,4 @@ extern int my_waitpid (int pid, int *status, int flags);
    messages only.  */
 extern std::string status_to_str (int status);
 
-#endif /* NAT_LINUX_WAITPID_H */
+#endif /* GDB_NAT_LINUX_WAITPID_H */
diff --git a/gdb/nat/mips-linux-watch.h b/gdb/nat/mips-linux-watch.h
index a37eabd2058..b18b009f3b7 100644
--- a/gdb/nat/mips-linux-watch.h
+++ b/gdb/nat/mips-linux-watch.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_MIPS_LINUX_WATCH_H
-#define NAT_MIPS_LINUX_WATCH_H
+#ifndef GDB_NAT_MIPS_LINUX_WATCH_H
+#define GDB_NAT_MIPS_LINUX_WATCH_H
 
 #include <asm/ptrace.h>
 #include "gdbsupport/break-common.h"
@@ -116,4 +116,4 @@ int mips_linux_read_watch_registers (long lwpid,
 				     struct pt_watch_regs *watch_readback,
 				     int *watch_readback_valid, int force);
 
-#endif /* NAT_MIPS_LINUX_WATCH_H */
+#endif /* GDB_NAT_MIPS_LINUX_WATCH_H */
diff --git a/gdb/nat/netbsd-nat.h b/gdb/nat/netbsd-nat.h
index cc529cfd0c6..1ffd705e3be 100644
--- a/gdb/nat/netbsd-nat.h
+++ b/gdb/nat/netbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_NETBSD_NAT_H
-#define NAT_NETBSD_NAT_H
+#ifndef GDB_NAT_NETBSD_NAT_H
+#define GDB_NAT_NETBSD_NAT_H
 
 #include "gdbsupport/function-view.h"
 
@@ -91,4 +91,4 @@ extern int read_memory (pid_t pid, unsigned char *readbuf, CORE_ADDR offset,
 			size_t len, size_t *xfered_len);
 }
 
-#endif
+#endif /* GDB_NAT_NETBSD_NAT_H */
diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h
index b51e2278f4b..3efc1b9a9bf 100644
--- a/gdb/nat/ppc-linux.h
+++ b/gdb/nat/ppc-linux.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_PPC_LINUX_H
-#define NAT_PPC_LINUX_H
+#ifndef GDB_NAT_PPC_LINUX_H
+#define GDB_NAT_PPC_LINUX_H
 
 #include <asm/ptrace.h>
 #include <asm/cputable.h>
@@ -162,4 +162,4 @@
 /* Return the wordsize of the target, either 4 or 8 bytes.  */
 int ppc_linux_target_wordsize (int tid);
 
-#endif /* NAT_PPC_LINUX_H */
+#endif /* GDB_NAT_PPC_LINUX_H */
diff --git a/gdb/nat/riscv-linux-tdesc.h b/gdb/nat/riscv-linux-tdesc.h
index fa9d5bcb7f5..875135ed979 100644
--- a/gdb/nat/riscv-linux-tdesc.h
+++ b/gdb/nat/riscv-linux-tdesc.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_RISCV_LINUX_TDESC_H
-#define NAT_RISCV_LINUX_TDESC_H
+#ifndef GDB_NAT_RISCV_LINUX_TDESC_H
+#define GDB_NAT_RISCV_LINUX_TDESC_H
 
 #include "arch/riscv.h"
 
@@ -25,4 +25,4 @@
    corresponding features object.  */
 struct riscv_gdbarch_features riscv_linux_read_features (int tid);
 
-#endif /* NAT_RISCV_LINUX_TDESC_H */
+#endif /* GDB_NAT_RISCV_LINUX_TDESC_H */
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index f2b5d777016..e03b41a53d4 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_WINDOWS_NAT_H
-#define NAT_WINDOWS_NAT_H
+#ifndef GDB_NAT_WINDOWS_NAT_H
+#define GDB_NAT_WINDOWS_NAT_H
 
 #include <windows.h>
 #include <psapi.h>
@@ -440,4 +440,4 @@ extern bool initialize_loadable ();
 
 }
 
-#endif
+#endif /* GDB_NAT_WINDOWS_NAT_H */
diff --git a/gdb/nat/x86-cpuid.h b/gdb/nat/x86-cpuid.h
index 5e9ce604f4e..02a204c1348 100644
--- a/gdb/nat/x86-cpuid.h
+++ b/gdb/nat/x86-cpuid.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_CPUID_H
-#define NAT_X86_CPUID_H
+#ifndef GDB_NAT_X86_CPUID_H
+#define GDB_NAT_X86_CPUID_H
 
 /* Always include the header for the cpu bit defines.  */
 #include "x86-gcc-cpuid.h"
@@ -82,4 +82,4 @@ x86_cpuid_count (unsigned int __level, unsigned int __sublevel,
 #undef nullptr
 #endif
 
-#endif /* NAT_X86_CPUID_H */
+#endif /* GDB_NAT_X86_CPUID_H */
diff --git a/gdb/nat/x86-dregs.h b/gdb/nat/x86-dregs.h
index 795cb112f88..3dcbf8e3028 100644
--- a/gdb/nat/x86-dregs.h
+++ b/gdb/nat/x86-dregs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_DREGS_H
-#define NAT_X86_DREGS_H
+#ifndef GDB_NAT_X86_DREGS_H
+#define GDB_NAT_X86_DREGS_H
 
 /* Support for hardware watchpoints and breakpoints using the x86
    debug registers.
@@ -133,4 +133,4 @@ extern int x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state);
    triggered.  Otherwise return false.  */
 extern int x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state);
 
-#endif /* NAT_X86_DREGS_H */
+#endif /* GDB_NAT_X86_DREGS_H */
diff --git a/gdb/nat/x86-gcc-cpuid.h b/gdb/nat/x86-gcc-cpuid.h
index dfd12587d81..b0f2d239af3 100644
--- a/gdb/nat/x86-gcc-cpuid.h
+++ b/gdb/nat/x86-gcc-cpuid.h
@@ -3,8 +3,8 @@
  * include this directly, but pull in x86-cpuid.h and use that func.
  */
 
-#ifndef NAT_X86_GCC_CPUID_H
-#define NAT_X86_GCC_CPUID_H
+#ifndef GDB_NAT_X86_GCC_CPUID_H
+#define GDB_NAT_X86_GCC_CPUID_H
 
 /*
  * Copyright (C) 2007-2024 Free Software Foundation, Inc.
@@ -273,4 +273,4 @@ __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
   return 1;
 }
 
-#endif /* NAT_X86_GCC_CPUID_H */
+#endif /* GDB_NAT_X86_GCC_CPUID_H */
diff --git a/gdb/nat/x86-linux-dregs.h b/gdb/nat/x86-linux-dregs.h
index 2b30c4a7a62..6f6a6e3d24e 100644
--- a/gdb/nat/x86-linux-dregs.h
+++ b/gdb/nat/x86-linux-dregs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_LINUX_DREGS_H
-#define NAT_X86_LINUX_DREGS_H
+#ifndef GDB_NAT_X86_LINUX_DREGS_H
+#define GDB_NAT_X86_LINUX_DREGS_H
 
 /* Return the address stored in the current inferior's debug register
    REGNUM.  */
@@ -50,4 +50,4 @@ extern unsigned long x86_linux_dr_get_status (void);
 
 extern void x86_linux_update_debug_registers (struct lwp_info *lwp);
 
-#endif /* NAT_X86_LINUX_DREGS_H */
+#endif /* GDB_NAT_X86_LINUX_DREGS_H */
diff --git a/gdb/nat/x86-linux.h b/gdb/nat/x86-linux.h
index 822882173f9..9b5db895455 100644
--- a/gdb/nat/x86-linux.h
+++ b/gdb/nat/x86-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_LINUX_H
-#define NAT_X86_LINUX_H
+#ifndef GDB_NAT_X86_LINUX_H
+#define GDB_NAT_X86_LINUX_H
 
 #include "nat/linux-nat.h"
 
@@ -47,4 +47,4 @@ extern void x86_linux_delete_thread (struct arch_lwp_info *arch_lwp);
 
 extern void x86_linux_prepare_to_resume (struct lwp_info *lwp);
 
-#endif /* NAT_X86_LINUX_H */
+#endif /* GDB_NAT_X86_LINUX_H */
diff --git a/gdb/nat/x86-xstate.h b/gdb/nat/x86-xstate.h
index 199d39a5217..14b58cd0312 100644
--- a/gdb/nat/x86-xstate.h
+++ b/gdb/nat/x86-xstate.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_XSTATE_H
-#define NAT_X86_XSTATE_H
+#ifndef GDB_NAT_X86_XSTATE_H
+#define GDB_NAT_X86_XSTATE_H
 
 #include "gdbsupport/x86-xstate.h"
 
@@ -32,4 +32,4 @@ int x86_xsave_length ();
 
 x86_xsave_layout x86_fetch_xsave_layout (uint64_t xcr0, int len);
 
-#endif /* NAT_X86_XSTATE_H */
+#endif /* GDB_NAT_X86_XSTATE_H */
diff --git a/gdb/nds32-tdep.h b/gdb/nds32-tdep.h
index a4d62848c51..18c360d7bdb 100644
--- a/gdb/nds32-tdep.h
+++ b/gdb/nds32-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NDS32_TDEP_H
-#define NDS32_TDEP_H
+#ifndef GDB_NDS32_TDEP_H
+#define GDB_NDS32_TDEP_H
 
 #include "gdbarch.h"
 
@@ -53,4 +53,4 @@ struct nds32_gdbarch_tdep : gdbarch_tdep_base
   /* ELF ABI info.  */
   int elf_abi = 0;
 };
-#endif /* NDS32_TDEP_H */
+#endif /* GDB_NDS32_TDEP_H */
diff --git a/gdb/netbsd-nat.h b/gdb/netbsd-nat.h
index 4895b088d13..87e076f69e7 100644
--- a/gdb/netbsd-nat.h
+++ b/gdb/netbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NBSD_NAT_H
-#define NBSD_NAT_H
+#ifndef GDB_NETBSD_NAT_H
+#define GDB_NETBSD_NAT_H
 
 #include "inf-ptrace.h"
 
@@ -61,4 +61,4 @@ struct nbsd_nat_target : public inf_ptrace_target
   void post_startup_inferior (ptid_t ptid) override;
 };
 
-#endif /* netbsd-nat.h */
+#endif /* GDB_NETBSD_NAT_H */
diff --git a/gdb/netbsd-tdep.h b/gdb/netbsd-tdep.h
index 3a9d527ca81..2e2993ea5dc 100644
--- a/gdb/netbsd-tdep.h
+++ b/gdb/netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NBSD_TDEP_H
-#define NBSD_TDEP_H
+#ifndef GDB_NETBSD_TDEP_H
+#define GDB_NETBSD_TDEP_H
 
 int nbsd_pc_in_sigtramp (CORE_ADDR, const char *);
 
@@ -44,4 +44,4 @@ extern void nbsd_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
 					   int kve_flags, int kve_protection,
 					   const char *kve_path);
 
-#endif /* NBSD_TDEP_H */
+#endif /* GDB_NETBSD_TDEP_H */
diff --git a/gdb/nios2-tdep.h b/gdb/nios2-tdep.h
index 57e0de7076d..0b3d01ab232 100644
--- a/gdb/nios2-tdep.h
+++ b/gdb/nios2-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NIOS2_TDEP_H
-#define NIOS2_TDEP_H
+#ifndef GDB_NIOS2_TDEP_H
+#define GDB_NIOS2_TDEP_H
 
 #include "gdbarch.h"
 
@@ -87,4 +87,4 @@ struct nios2_gdbarch_tdep : gdbarch_tdep_base
 extern const struct target_desc *tdesc_nios2_linux;
 extern const struct target_desc *tdesc_nios2;
 
-#endif /* NIOS2_TDEP_H */
+#endif /* GDB_NIOS2_TDEP_H */
diff --git a/gdb/nto-tdep.h b/gdb/nto-tdep.h
index 249a4f631fe..2edbcff8c91 100644
--- a/gdb/nto-tdep.h
+++ b/gdb/nto-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NTO_TDEP_H
-#define NTO_TDEP_H
+#ifndef GDB_NTO_TDEP_H
+#define GDB_NTO_TDEP_H
 
 #include "solist.h"
 #include "osabi.h"
@@ -191,4 +191,4 @@ LONGEST nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack,
 
 struct nto_inferior_data *nto_inferior_data (struct inferior *inf);
 
-#endif /* NTO_TDEP_H */
+#endif /* GDB_NTO_TDEP_H */
diff --git a/gdb/objc-lang.h b/gdb/objc-lang.h
index 879d7475d9d..6a8dc39c53a 100644
--- a/gdb/objc-lang.h
+++ b/gdb/objc-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(OBJC_LANG_H)
-#define OBJC_LANG_H
+#ifndef GDB_OBJC_LANG_H
+#define GDB_OBJC_LANG_H
 
 struct stoken;
 
@@ -48,4 +48,4 @@ struct symbol *lookup_struct_typedef (const char *name,
 				      const struct block *block,
 				      int noerr);
 
-#endif
+#endif /* GDB_OBJC_LANG_H */
diff --git a/gdb/objfile-flags.h b/gdb/objfile-flags.h
index 43d888e2a5a..e0a84bcdc2e 100644
--- a/gdb/objfile-flags.h
+++ b/gdb/objfile-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (OBJFILE_FLAGS_H)
-#define OBJFILE_FLAGS_H
+#ifndef GDB_OBJFILE_FLAGS_H
+#define GDB_OBJFILE_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -60,4 +60,4 @@ enum objfile_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum objfile_flag, objfile_flags);
 
-#endif /* !defined (OBJFILE_FLAGS_H) */
+#endif /* GDB_OBJFILE_FLAGS_H */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 8b8b7182e87..4d8e5c45680 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (OBJFILES_H)
-#define OBJFILES_H
+#ifndef GDB_OBJFILES_H
+#define GDB_OBJFILES_H
 
 #include "hashtab.h"
 #include "gdbsupport/gdb_obstack.h"
@@ -1031,4 +1031,4 @@ extern void objfile_register_static_link
 extern const struct dynamic_prop *objfile_lookup_static_link
   (struct objfile *objfile, const struct block *block);
 
-#endif /* !defined (OBJFILES_H) */
+#endif /* GDB_OBJFILES_H */
diff --git a/gdb/obsd-nat.h b/gdb/obsd-nat.h
index 0811a82d85c..35ee212e09f 100644
--- a/gdb/obsd-nat.h
+++ b/gdb/obsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSD_NAT_H
-#define OBSD_NAT_H
+#ifndef GDB_OBSD_NAT_H
+#define GDB_OBSD_NAT_H
 
 #include "inf-ptrace.h"
 
@@ -41,4 +41,4 @@ class obsd_nat_target : public inf_ptrace_target
   void post_startup_inferior (ptid_t) override;
 };
 
-#endif /* obsd-nat.h */
+#endif /* GDB_OBSD_NAT_H */
diff --git a/gdb/obsd-tdep.h b/gdb/obsd-tdep.h
index 85cea7be7cf..c018513cb1b 100644
--- a/gdb/obsd-tdep.h
+++ b/gdb/obsd-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSD_TDEP_H
-#define OBSD_TDEP_H 1
+#ifndef GDB_OBSD_TDEP_H
+#define GDB_OBSD_TDEP_H
 
 struct gdbarch;
 
 CORE_ADDR obsd_skip_solib_resolver (struct gdbarch *, CORE_ADDR);
 void obsd_init_abi (struct gdbarch_info, struct gdbarch *);
 
-#endif /* obsd-tdep.h */
+#endif /* GDB_OBSD_TDEP_H */
diff --git a/gdb/observable.h b/gdb/observable.h
index 2aa3ef3fd4e..2ce2711abd6 100644
--- a/gdb/observable.h
+++ b/gdb/observable.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSERVABLE_H
-#define OBSERVABLE_H
+#ifndef GDB_OBSERVABLE_H
+#define GDB_OBSERVABLE_H
 
 #include "gdbsupport/observable.h"
 #include "target/waitstatus.h"
@@ -257,4 +257,4 @@ extern observable <program_space */* pspace */> free_program_space;
 
 } /* namespace gdb */
 
-#endif /* OBSERVABLE_H */
+#endif /* GDB_OBSERVABLE_H */
diff --git a/gdb/or1k-linux-tdep.h b/gdb/or1k-linux-tdep.h
index 4e84e72c269..b510f32d16e 100644
--- a/gdb/or1k-linux-tdep.h
+++ b/gdb/or1k-linux-tdep.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OR1K_LINUX_TDEP_H
-#define OR1K_LINUX_TDEP_H
+#ifndef GDB_OR1K_LINUX_TDEP_H
+#define GDB_OR1K_LINUX_TDEP_H
 
 /* Target descriptions.  */
 extern struct target_desc *tdesc_or1k_linux;
 
-#endif /* OR1K_LINUX_TDEP_H */
+#endif /* GDB_OR1K_LINUX_TDEP_H */
diff --git a/gdb/or1k-tdep.h b/gdb/or1k-tdep.h
index 6107cc4612c..f3072572e57 100644
--- a/gdb/or1k-tdep.h
+++ b/gdb/or1k-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License along
    With this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OR1K_TDEP_H
-#define OR1K_TDEP_H
+#ifndef GDB_OR1K_TDEP_H
+#define GDB_OR1K_TDEP_H
 
 #ifndef TARGET_OR1K
 #define TARGET_OR1K
@@ -60,4 +60,4 @@ extern std::vector<CORE_ADDR> or1k_software_single_step
   (struct regcache *regcache);
 
 
-#endif /* OR1K_TDEP_H */
+#endif /* GDB_OR1K_TDEP_H */
diff --git a/gdb/osabi.h b/gdb/osabi.h
index c1a85d1b9a3..bbcd0d0c23a 100644
--- a/gdb/osabi.h
+++ b/gdb/osabi.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OSABI_H
-#define OSABI_H
+#ifndef GDB_OSABI_H
+#define GDB_OSABI_H
 
 /* * List of known OS ABIs.  If you change this, make sure to update the
    table in osabi.c.  */
@@ -92,4 +92,4 @@ const char *osabi_triplet_regexp (enum gdb_osabi osabi);
 void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *,
 					       enum gdb_osabi *);
 
-#endif /* OSABI_H */
+#endif /* GDB_OSABI_H */
diff --git a/gdb/osdata.h b/gdb/osdata.h
index 09259b6c9ae..9de443ac4de 100644
--- a/gdb/osdata.h
+++ b/gdb/osdata.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OSDATA_H
-#define OSDATA_H
+#ifndef GDB_OSDATA_H
+#define GDB_OSDATA_H
 
 #include <vector>
 
@@ -57,4 +57,4 @@ const std::string *get_osdata_column (const osdata_item &item,
    available types of OS data.  */
 void info_osdata (const char *type);
 
-#endif /* OSDATA_H */
+#endif /* GDB_OSDATA_H */
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index fe12e7cab33..abb981aeaed 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef P_LANG_H
-#define P_LANG_H
+#ifndef GDB_P_LANG_H
+#define GDB_P_LANG_H
 
 /* This file is derived from c-lang.h */
 
@@ -252,4 +252,4 @@ class pascal_language : public language_defn
 				   struct type *type) const;
 };
 
-#endif /* P_LANG_H */
+#endif /* GDB_P_LANG_H */
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 9774a465ee2..eaa3c411141 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (PARSER_DEFS_H)
-#define PARSER_DEFS_H 1
+#ifndef GDB_PARSER_DEFS_H
+#define GDB_PARSER_DEFS_H
 
 #include "expression.h"
 #include "symtab.h"
@@ -389,4 +389,4 @@ extern bool fits_in_type (int n_sign, const gdb_mpz &n, int type_bits,
 
 extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3);
 
-#endif /* PARSER_DEFS_H */
+#endif /* GDB_PARSER_DEFS_H */
diff --git a/gdb/ppc-fbsd-tdep.h b/gdb/ppc-fbsd-tdep.h
index b9c0e6bb351..93ba9045f2f 100644
--- a/gdb/ppc-fbsd-tdep.h
+++ b/gdb/ppc-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_FBSD_TDEP_H
-#define PPC_FBSD_TDEP_H
+#ifndef GDB_PPC_FBSD_TDEP_H
+#define GDB_PPC_FBSD_TDEP_H
 
 struct regset;
 
@@ -26,4 +26,4 @@ struct regset;
 const struct regset *ppc_fbsd_gregset (int);
 const struct regset *ppc_fbsd_fpregset (void);
 
-#endif /* PPC_FBSD_TDEP_H  */
+#endif /* GDB_PPC_FBSD_TDEP_H */
diff --git a/gdb/ppc-linux-tdep.h b/gdb/ppc-linux-tdep.h
index 8a0a59f2b70..a1db503c9f5 100644
--- a/gdb/ppc-linux-tdep.h
+++ b/gdb/ppc-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_LINUX_TDEP_H
-#define PPC_LINUX_TDEP_H
+#ifndef GDB_PPC_LINUX_TDEP_H
+#define GDB_PPC_LINUX_TDEP_H
 
 #include "ppc-tdep.h"
 
@@ -65,4 +65,4 @@ extern const struct regset ppc32_linux_cpprregset;
 extern const struct regset ppc32_linux_cdscrregset;
 extern const struct regset ppc32_linux_ctarregset;
 
-#endif /* PPC_LINUX_TDEP_H */
+#endif /* GDB_PPC_LINUX_TDEP_H */
diff --git a/gdb/ppc-netbsd-tdep.h b/gdb/ppc-netbsd-tdep.h
index 6a92020f5ab..47a8b25782a 100644
--- a/gdb/ppc-netbsd-tdep.h
+++ b/gdb/ppc-netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_NBSD_TDEP_H
-#define PPC_NBSD_TDEP_H
+#ifndef GDB_PPC_NETBSD_TDEP_H
+#define GDB_PPC_NETBSD_TDEP_H
 
 struct regset;
 
@@ -29,4 +29,4 @@ extern struct ppc_reg_offsets ppcnbsd_reg_offsets;
 extern const struct regset ppcnbsd_gregset;
 extern const struct regset ppcnbsd_fpregset;
 
-#endif /* PPC_NBSD_TDEP_H */
+#endif /* GDB_PPC_NETBSD_TDEP_H */
diff --git a/gdb/ppc-obsd-tdep.h b/gdb/ppc-obsd-tdep.h
index 70396abdf84..7f5e7b99850 100644
--- a/gdb/ppc-obsd-tdep.h
+++ b/gdb/ppc-obsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_OBSD_TDEP_H
-#define PPC_OBSD_TDEP_H
+#ifndef GDB_PPC_OBSD_TDEP_H
+#define GDB_PPC_OBSD_TDEP_H
 
 struct regset;
 struct regcache;
@@ -49,4 +49,4 @@ extern void ppcobsd_collect_gregset (const struct regset *regset,
 				     const struct regcache *regcache,
 				     int regnum, void *gregs, size_t len);
 
-#endif /* ppc-obsd-tdep.h */
+#endif /* GDB_PPC_OBSD_TDEP_H */
diff --git a/gdb/ppc-ravenscar-thread.h b/gdb/ppc-ravenscar-thread.h
index 2b0916a916f..c03fbd2ec52 100644
--- a/gdb/ppc-ravenscar-thread.h
+++ b/gdb/ppc-ravenscar-thread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_RAVENSCAR_THREAD_H
-#define PPC_RAVENSCAR_THREAD_H
+#ifndef GDB_PPC_RAVENSCAR_THREAD_H
+#define GDB_PPC_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
@@ -26,4 +26,4 @@ extern void register_ppc_ravenscar_ops (struct gdbarch *gdbarch);
 
 extern void register_e500_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_PPC_RAVENSCAR_THREAD_H */
diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
index db31c7f199a..3176c155fe3 100644
--- a/gdb/ppc-tdep.h
+++ b/gdb/ppc-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_TDEP_H
-#define PPC_TDEP_H
+#ifndef GDB_PPC_TDEP_H
+#define GDB_PPC_TDEP_H
 
 #include "gdbarch.h"
 
@@ -458,4 +458,4 @@ extern const struct target_desc *tdesc_powerpc_vsx32;
 extern const struct target_desc *tdesc_powerpc_altivec64;
 extern const struct target_desc *tdesc_powerpc_altivec32;
 
-#endif /* ppc-tdep.h */
+#endif /* GDB_PPC_TDEP_H */
diff --git a/gdb/ppc64-tdep.h b/gdb/ppc64-tdep.h
index ff0e3fdd033..7bea549dda0 100644
--- a/gdb/ppc64-tdep.h
+++ b/gdb/ppc64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC64_TDEP_H
-#define PPC64_TDEP_H
+#ifndef GDB_PPC64_TDEP_H
+#define GDB_PPC64_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -33,4 +33,4 @@ extern CORE_ADDR ppc64_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
 
 extern void ppc64_elf_make_msymbol_special (asymbol *,
 					    struct minimal_symbol *);
-#endif /* PPC64_TDEP_H  */
+#endif /* GDB_PPC64_TDEP_H */
diff --git a/gdb/probe.h b/gdb/probe.h
index 41e728ad049..00b3f9086b4 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (PROBE_H)
-#define PROBE_H 1
+#ifndef GDB_PROBE_H
+#define GDB_PROBE_H
 
 #include "symtab.h"
 
@@ -309,4 +309,4 @@ extern struct value *probe_safe_evaluate_at_pc (const frame_info_ptr &frame,
 
 bool ignore_probe_p (const char *provider, const char *name,
 		     const char *objfile_name, const char *TYPE);
-#endif /* !defined (PROBE_H) */
+#endif /* GDB_PROBE_H */
diff --git a/gdb/proc-utils.h b/gdb/proc-utils.h
index 8ef7d7ccd34..5f8fe39f78f 100644
--- a/gdb/proc-utils.h
+++ b/gdb/proc-utils.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROC_UTILS_H
-#define PROC_UTILS_H
+#ifndef GDB_PROC_UTILS_H
+#define GDB_PROC_UTILS_H
 
 /* From proc-why.c */
 
@@ -117,4 +117,4 @@ extern  void  procfs_note      (const char *, const char *, int);
    word used to write to the /proc/PID/ctl file.  */
 typedef long procfs_ctl_t;
 
-#endif /* PROC_UTILS_H */
+#endif /* GDB_PROC_UTILS_H */
diff --git a/gdb/process-stratum-target.h b/gdb/process-stratum-target.h
index 9aa9d874ecb..8a0e139cd0c 100644
--- a/gdb/process-stratum-target.h
+++ b/gdb/process-stratum-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROCESS_STRATUM_TARGET_H
-#define PROCESS_STRATUM_TARGET_H
+#ifndef GDB_PROCESS_STRATUM_TARGET_H
+#define GDB_PROCESS_STRATUM_TARGET_H
 
 #include "target.h"
 #include <set>
@@ -173,4 +173,4 @@ extern std::set<process_stratum_target *> all_non_exited_process_targets ();
 
 extern void switch_to_target_no_thread (process_stratum_target *target);
 
-#endif /* !defined (PROCESS_STRATUM_TARGET_H) */
+#endif /* GDB_PROCESS_STRATUM_TARGET_H */
diff --git a/gdb/procfs.h b/gdb/procfs.h
index e0c1dd654ca..0dafb9a88b4 100644
--- a/gdb/procfs.h
+++ b/gdb/procfs.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROCFS_H
-#define PROCFS_H
+#ifndef GDB_PROCFS_H
+#define GDB_PROCFS_H
 
 /* Return a ptid for which we guarantee we will be able to find a
    'live' procinfo.  */
 
 extern ptid_t procfs_first_available (void);
 
-#endif /* PROCFS_H */
+#endif /* GDB_PROCFS_H */
diff --git a/gdb/producer.h b/gdb/producer.h
index 84721bd2665..5cdb7ee3435 100644
--- a/gdb/producer.h
+++ b/gdb/producer.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PRODUCER_H
-#define PRODUCER_H
+#ifndef GDB_PRODUCER_H
+#define GDB_PRODUCER_H
 
 /* Check for GCC >= 4.x according to the symtab->producer string.  Return minor
    version (x) of 4.x in such case.  If it is not GCC or it is GCC older than
@@ -50,4 +50,4 @@ extern bool producer_is_llvm (const char *producer);
    Sets MAJOR and MINOR accordingly, if not NULL.  */
 extern bool producer_is_clang (const char *producer, int *major, int *minor);
 
-#endif
+#endif /* GDB_PRODUCER_H */
diff --git a/gdb/progspace-and-thread.h b/gdb/progspace-and-thread.h
index fa512710a25..52c493bf687 100644
--- a/gdb/progspace-and-thread.h
+++ b/gdb/progspace-and-thread.h
@@ -16,8 +16,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef PROGSPACE_AND_THREAD_H
-#define PROGSPACE_AND_THREAD_H
+#ifndef GDB_PROGSPACE_AND_THREAD_H
+#define GDB_PROGSPACE_AND_THREAD_H
 
 #include "progspace.h"
 #include "gdbthread.h"
@@ -37,4 +37,4 @@ class scoped_restore_current_pspace_and_thread
    current thread, if there's one and it isn't executing.  */
 void switch_to_program_space_and_thread (program_space *pspace);
 
-#endif
+#endif /* GDB_PROGSPACE_AND_THREAD_H */
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 7f5e23df126..74220e5ba4c 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef PROGSPACE_H
-#define PROGSPACE_H
+#ifndef GDB_PROGSPACE_H
+#define GDB_PROGSPACE_H
 
 #include "target.h"
 #include "gdb_bfd.h"
@@ -472,4 +472,4 @@ extern address_space_ref_ptr maybe_new_address_space ();
    mappings.  */
 extern void update_address_spaces (void);
 
-#endif
+#endif /* GDB_PROGSPACE_H */
diff --git a/gdb/prologue-value.h b/gdb/prologue-value.h
index ea784f90dd2..39235d591fc 100644
--- a/gdb/prologue-value.h
+++ b/gdb/prologue-value.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROLOGUE_VALUE_H
-#define PROLOGUE_VALUE_H
+#ifndef GDB_PROLOGUE_VALUE_H
+#define GDB_PROLOGUE_VALUE_H
 
 /* What sort of value is this?  This determines the interpretation
    of subsequent fields.  */
@@ -327,4 +327,4 @@ class pv_area
   struct area_entry *m_entry;
 };
 
-#endif /* PROLOGUE_VALUE_H */
+#endif /* GDB_PROLOGUE_VALUE_H */
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 557a7cf4c08..7833815ef50 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PSYMTAB_H
-#define PSYMTAB_H
+#ifndef GDB_PSYMTAB_H
+#define GDB_PSYMTAB_H
 
 #include "objfiles.h"
 #include <string_view>
@@ -687,4 +687,4 @@ struct psymbol_functions : public quick_symbol_functions
   std::shared_ptr<psymtab_storage> m_partial_symtabs;
 };
 
-#endif /* PSYMTAB_H */
+#endif /* GDB_PSYMTAB_H */
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 388c513e5e9..2819707b2dd 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_EVENT_H
-#define PYTHON_PY_EVENT_H
+#ifndef GDB_PYTHON_PY_EVENT_H
+#define GDB_PYTHON_PY_EVENT_H
 
 #include "py-events.h"
 #include "command.h"
@@ -87,4 +87,4 @@ extern int evpy_add_attribute (PyObject *event,
 int gdbpy_initialize_event_generic (PyTypeObject *type, const char *name)
   CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
 
-#endif /* PYTHON_PY_EVENT_H */
+#endif /* GDB_PYTHON_PY_EVENT_H */
diff --git a/gdb/python/py-events.h b/gdb/python/py-events.h
index e628e0fd63e..b44c4371f24 100644
--- a/gdb/python/py-events.h
+++ b/gdb/python/py-events.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_EVENTS_H
-#define PYTHON_PY_EVENTS_H
+#ifndef GDB_PYTHON_PY_EVENTS_H
+#define GDB_PYTHON_PY_EVENTS_H
 
 #include "command.h"
 #include "python-internal.h"
@@ -54,4 +54,4 @@ extern events_object gdb_py_events;
 extern eventregistry_object *create_eventregistry_object (void);
 extern bool evregpy_no_listeners_p (eventregistry_object *registry);
 
-#endif /* PYTHON_PY_EVENTS_H */
+#endif /* GDB_PYTHON_PY_EVENTS_H */
diff --git a/gdb/python/py-instruction.h b/gdb/python/py-instruction.h
index 85604de5188..efbdda84bae 100644
--- a/gdb/python/py-instruction.h
+++ b/gdb/python/py-instruction.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_INSTRUCTION_H
-#define PYTHON_PY_INSTRUCTION_H
+#ifndef GDB_PYTHON_PY_INSTRUCTION_H
+#define GDB_PYTHON_PY_INSTRUCTION_H
 
 #include "python-internal.h"
 
@@ -32,4 +32,4 @@
 
 extern PyTypeObject *py_insn_get_insn_type ();
 
-#endif /* PYTHON_PY_INSTRUCTION_H */
+#endif /* GDB_PYTHON_PY_INSTRUCTION_H */
diff --git a/gdb/python/py-record-btrace.h b/gdb/python/py-record-btrace.h
index 8678e77322b..0410dd66be8 100644
--- a/gdb/python/py-record-btrace.h
+++ b/gdb/python/py-record-btrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_BTRACE_H
-#define PYTHON_PY_RECORD_BTRACE_H
+#ifndef GDB_PYTHON_PY_RECORD_BTRACE_H
+#define GDB_PYTHON_PY_RECORD_BTRACE_H
 
 #include "python-internal.h"
 
@@ -88,4 +88,4 @@ extern PyObject *recpy_bt_func_prev (PyObject *self, void *closure);
 /* Implementation of RecordFunctionSegment.next [RecordFunctionSegment].  */
 extern PyObject *recpy_bt_func_next (PyObject *self, void *closure);
 
-#endif /* PYTHON_PY_RECORD_BTRACE_H */
+#endif /* GDB_PYTHON_PY_RECORD_BTRACE_H */
diff --git a/gdb/python/py-record-full.h b/gdb/python/py-record-full.h
index 7125e4eba05..df957761602 100644
--- a/gdb/python/py-record-full.h
+++ b/gdb/python/py-record-full.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_FULL_H
-#define PYTHON_PY_RECORD_FULL_H
+#ifndef GDB_PYTHON_PY_RECORD_FULL_H
+#define GDB_PYTHON_PY_RECORD_FULL_H
 
 #include "python-internal.h"
 
@@ -28,4 +28,4 @@ extern PyObject *recpy_full_method (PyObject *self, void *value);
 /* Implementation of record.format [str].  */
 extern PyObject *recpy_full_format (PyObject *self, void *value);
 
-#endif /* PYTHON_PY_RECORD_FULL_H */
+#endif /* GDB_PYTHON_PY_RECORD_FULL_H */
diff --git a/gdb/python/py-record.h b/gdb/python/py-record.h
index 7e1161005b4..0687e78784a 100644
--- a/gdb/python/py-record.h
+++ b/gdb/python/py-record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_H
-#define PYTHON_PY_RECORD_H
+#ifndef GDB_PYTHON_PY_RECORD_H
+#define GDB_PYTHON_PY_RECORD_H
 
 #include "inferior.h"
 #include "python-internal.h"
@@ -71,4 +71,4 @@ extern PyObject *recpy_func_new (thread_info *thread, enum record_method method,
 extern PyObject *recpy_gap_new (int reason_code, const char *reason_string,
 				Py_ssize_t number);
 
-#endif /* PYTHON_PY_RECORD_H */
+#endif /* GDB_PYTHON_PY_RECORD_H */
diff --git a/gdb/python/py-ref.h b/gdb/python/py-ref.h
index 35029e8d673..938068e7803 100644
--- a/gdb/python/py-ref.h
+++ b/gdb/python/py-ref.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_REF_H
-#define PYTHON_PY_REF_H
+#ifndef GDB_PYTHON_PY_REF_H
+#define GDB_PYTHON_PY_REF_H
 
 #include "gdbsupport/gdb_ref_ptr.h"
 
@@ -42,4 +42,4 @@ struct gdbpy_ref_policy
 template<typename T = PyObject> using gdbpy_ref
   = gdb::ref_ptr<T, gdbpy_ref_policy<T>>;
 
-#endif /* PYTHON_PY_REF_H */
+#endif /* GDB_PYTHON_PY_REF_H */
diff --git a/gdb/python/py-stopevent.h b/gdb/python/py-stopevent.h
index 6cae0a729db..450d8c23b4a 100644
--- a/gdb/python/py-stopevent.h
+++ b/gdb/python/py-stopevent.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_STOPEVENT_H
-#define PYTHON_PY_STOPEVENT_H
+#ifndef GDB_PYTHON_PY_STOPEVENT_H
+#define GDB_PYTHON_PY_STOPEVENT_H
 
 #include "py-event.h"
 
@@ -35,4 +35,4 @@ extern gdbpy_ref<> create_breakpoint_event_object (const gdbpy_ref<> &dict,
 extern gdbpy_ref<> create_signal_event_object (const gdbpy_ref<> &dict,
 					       enum gdb_signal stop_signal);
 
-#endif /* PYTHON_PY_STOPEVENT_H */
+#endif /* GDB_PYTHON_PY_STOPEVENT_H */
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 5132ec15ba6..d9863935f0c 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PYTHON_INTERNAL_H
-#define PYTHON_PYTHON_INTERNAL_H
+#ifndef GDB_PYTHON_PYTHON_INTERNAL_H
+#define GDB_PYTHON_PYTHON_INTERNAL_H
 
 #include "extension.h"
 #include "extension-priv.h"
@@ -1035,4 +1035,4 @@ extern std::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch,
 					    CORE_ADDR address,
 					    disassemble_info *info);
 
-#endif /* PYTHON_PYTHON_INTERNAL_H */
+#endif /* GDB_PYTHON_PYTHON_INTERNAL_H */
diff --git a/gdb/python/python.h b/gdb/python/python.h
index e6279482ce0..e8032853e8e 100644
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PYTHON_H
-#define PYTHON_PYTHON_H
+#ifndef GDB_PYTHON_PYTHON_H
+#define GDB_PYTHON_PYTHON_H
 
 #include "extension.h"
 
@@ -34,4 +34,4 @@ extern cmd_list_element *python_cmd_element;
    at other times.  */
 extern struct objfile *gdbpy_current_objfile;
 
-#endif /* PYTHON_PYTHON_H */
+#endif /* GDB_PYTHON_PYTHON_H */
diff --git a/gdb/ravenscar-thread.h b/gdb/ravenscar-thread.h
index 32c31269225..046b3575e7f 100644
--- a/gdb/ravenscar-thread.h
+++ b/gdb/ravenscar-thread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RAVENSCAR_THREAD_H
-#define RAVENSCAR_THREAD_H
+#ifndef GDB_RAVENSCAR_THREAD_H
+#define GDB_RAVENSCAR_THREAD_H
 
 /* Architecture-specific hooks.  */
 
@@ -130,4 +130,4 @@ struct ravenscar_arch_ops
   CORE_ADDR get_stack_base (struct regcache *) const;
 };
 
-#endif /* !defined (RAVENSCAR_THREAD_H) */
+#endif /* GDB_RAVENSCAR_THREAD_H */
diff --git a/gdb/record-btrace.h b/gdb/record-btrace.h
index b6e6c4df030..5ab3208f659 100644
--- a/gdb/record-btrace.h
+++ b/gdb/record-btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_BTRACE_H
-#define RECORD_BTRACE_H
+#ifndef GDB_RECORD_BTRACE_H
+#define GDB_RECORD_BTRACE_H
 
 /* Push the record_btrace target.  */
 extern void record_btrace_push_target (void);
@@ -29,4 +29,4 @@ extern void record_btrace_push_target (void);
    NULL if the cpu was configured as auto.  */
 extern const struct btrace_cpu *record_btrace_get_cpu (void);
 
-#endif /* RECORD_BTRACE_H */
+#endif /* GDB_RECORD_BTRACE_H */
diff --git a/gdb/record-full.h b/gdb/record-full.h
index ef45b1c0d59..dc14d476715 100644
--- a/gdb/record-full.h
+++ b/gdb/record-full.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_FULL_H
-#define RECORD_FULL_H
+#ifndef GDB_RECORD_FULL_H
+#define GDB_RECORD_FULL_H
 
 extern bool record_full_memory_query;
 
@@ -31,4 +31,4 @@ extern int record_full_is_used (void);
 
 extern scoped_restore_tmpl<int> record_full_gdb_operation_disable_set ();
 
-#endif /* RECORD_FULL_H */
+#endif /* GDB_RECORD_FULL_H */
diff --git a/gdb/record.h b/gdb/record.h
index f44b3952943..471e2711b12 100644
--- a/gdb/record.h
+++ b/gdb/record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_H
-#define RECORD_H
+#ifndef GDB_RECORD_H
+#define GDB_RECORD_H
 
 #include "target/waitstatus.h"
 #include "gdbsupport/enum-flags.h"
@@ -114,4 +114,4 @@ extern void record_start (const char *method, const char *format,
 /* Stop recording.  Throw on failure.  */
 extern void record_stop (int from_tty);
 
-#endif /* RECORD_H */
+#endif /* GDB_RECORD_H */
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 9ba6c79ab0d..1e06dc60096 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGCACHE_H
-#define REGCACHE_H
+#ifndef GDB_REGCACHE_H
+#define GDB_REGCACHE_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/common-regcache.h"
@@ -548,4 +548,4 @@ class register_dump
   gdbarch *m_gdbarch;
 };
 
-#endif /* REGCACHE_H */
+#endif /* GDB_REGCACHE_H */
diff --git a/gdb/regformats/regdef.h b/gdb/regformats/regdef.h
index 0ba7a08bb0c..8715229fcdb 100644
--- a/gdb/regformats/regdef.h
+++ b/gdb/regformats/regdef.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGFORMATS_REGDEF_H
-#define REGFORMATS_REGDEF_H
+#ifndef GDB_REGFORMATS_REGDEF_H
+#define GDB_REGFORMATS_REGDEF_H
 
 namespace gdb {
 
@@ -64,4 +64,4 @@ struct reg
 
 } /* namespace gdb */
 
-#endif /* REGFORMATS_REGDEF_H */
+#endif /* GDB_REGFORMATS_REGDEF_H */
diff --git a/gdb/reggroups.h b/gdb/reggroups.h
index 1be1f0ad613..24f81e4675b 100644
--- a/gdb/reggroups.h
+++ b/gdb/reggroups.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGGROUPS_H
-#define REGGROUPS_H
+#ifndef GDB_REGGROUPS_H
+#define GDB_REGGROUPS_H
 
 struct gdbarch;
 
@@ -98,4 +98,4 @@ extern const reggroup *reggroup_find (struct gdbarch *gdbarch,
 extern int default_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 					const struct reggroup *reggroup);
 
-#endif
+#endif /* GDB_REGGROUPS_H */
diff --git a/gdb/registry.h b/gdb/registry.h
index b6b941f56fd..32216545cb0 100644
--- a/gdb/registry.h
+++ b/gdb/registry.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGISTRY_H
-#define REGISTRY_H
+#ifndef GDB_REGISTRY_H
+#define GDB_REGISTRY_H
 
 #include <type_traits>
 
@@ -225,4 +225,4 @@ class registry
   }
 };
 
-#endif /* REGISTRY_H */
+#endif /* GDB_REGISTRY_H */
diff --git a/gdb/regset.h b/gdb/regset.h
index 5fab2e16d9c..44eaf1406bc 100644
--- a/gdb/regset.h
+++ b/gdb/regset.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGSET_H
-#define REGSET_H 1
+#ifndef GDB_REGSET_H
+#define GDB_REGSET_H
 
 struct gdbarch;
 struct regcache;
@@ -52,4 +52,4 @@ struct regset
 #define REGSET_VARIABLE_SIZE 1	/* Accept a larger regset section size
 				   in a core file without warning.  */
 
-#endif /* regset.h */
+#endif /* GDB_REGSET_H */
diff --git a/gdb/remote-fileio.h b/gdb/remote-fileio.h
index 479dc46888e..d406895bc7e 100644
--- a/gdb/remote-fileio.h
+++ b/gdb/remote-fileio.h
@@ -19,8 +19,8 @@
 
 /* See the GDB User Guide for details of the GDB remote protocol.  */
 
-#ifndef REMOTE_FILEIO_H
-#define REMOTE_FILEIO_H
+#ifndef GDB_REMOTE_FILEIO_H
+#define GDB_REMOTE_FILEIO_H
 
 #include "gdbsupport/fileio.h"
 
@@ -44,4 +44,4 @@ extern void initialize_remote_fileio (
 extern void remote_fileio_to_host_stat (struct fio_stat *fst,
 					struct stat *st);
 
-#endif
+#endif /* GDB_REMOTE_FILEIO_H */
diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h
index 4c5b50a0d12..cca26b09f95 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REMOTE_NOTIF_H
-#define REMOTE_NOTIF_H
+#ifndef GDB_REMOTE_NOTIF_H
+#define GDB_REMOTE_NOTIF_H
 
 #include <list>
 #include <memory>
@@ -131,4 +131,4 @@ extern const notif_client notif_client_stop;
 
 extern bool notif_debug;
 
-#endif /* REMOTE_NOTIF_H */
+#endif /* GDB_REMOTE_NOTIF_H */
diff --git a/gdb/remote.h b/gdb/remote.h
index cb0a66da66e..173f3a2a0f2 100644
--- a/gdb/remote.h
+++ b/gdb/remote.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REMOTE_H
-#define REMOTE_H
+#ifndef GDB_REMOTE_H
+#define GDB_REMOTE_H
 
 #include "remote-notif.h"
 
@@ -121,4 +121,4 @@ extern void send_remote_packet (gdb::array_view<const char> &buf,
 
 extern bool is_remote_target (process_stratum_target *target);
 
-#endif
+#endif /* GDB_REMOTE_H */
diff --git a/gdb/riscv-fbsd-tdep.h b/gdb/riscv-fbsd-tdep.h
index c797b231a8e..22ae08d3678 100644
--- a/gdb/riscv-fbsd-tdep.h
+++ b/gdb/riscv-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_FBSD_TDEP_H
-#define RISCV_FBSD_TDEP_H
+#ifndef GDB_RISCV_FBSD_TDEP_H
+#define GDB_RISCV_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -35,4 +35,4 @@
 extern const struct regset riscv_fbsd_gregset;
 extern const struct regset riscv_fbsd_fpregset;
 
-#endif /* RISCV_FBSD_TDEP_H */
+#endif /* GDB_RISCV_FBSD_TDEP_H */
diff --git a/gdb/riscv-ravenscar-thread.h b/gdb/riscv-ravenscar-thread.h
index a586a85583a..87730438017 100644
--- a/gdb/riscv-ravenscar-thread.h
+++ b/gdb/riscv-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_RAVENSCAR_THREAD_H
-#define RISCV_RAVENSCAR_THREAD_H
+#ifndef GDB_RISCV_RAVENSCAR_THREAD_H
+#define GDB_RISCV_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_riscv_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_RISCV_RAVENSCAR_THREAD_H */
diff --git a/gdb/riscv-tdep.h b/gdb/riscv-tdep.h
index 4bdc2e7a3d5..15c2c4cafcb 100644
--- a/gdb/riscv-tdep.h
+++ b/gdb/riscv-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_TDEP_H
-#define RISCV_TDEP_H
+#ifndef GDB_RISCV_TDEP_H
+#define GDB_RISCV_TDEP_H
 
 #include "arch/riscv.h"
 #include "gdbarch.h"
@@ -180,4 +180,4 @@ extern void riscv_supply_regset (const struct regset *regset,
 /* The names of the RISC-V target description features.  */
 extern const char *riscv_feature_name_csr;
 
-#endif /* RISCV_TDEP_H */
+#endif /* GDB_RISCV_TDEP_H */
diff --git a/gdb/rs6000-aix-tdep.h b/gdb/rs6000-aix-tdep.h
index 52cffc31084..5e4f7865ac6 100644
--- a/gdb/rs6000-aix-tdep.h
+++ b/gdb/rs6000-aix-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RS6000_AIX_TDEP_H
-#define RS6000_AIX_TDEP_H
+#ifndef GDB_RS6000_AIX_TDEP_H
+#define GDB_RS6000_AIX_TDEP_H
 
 extern ULONGEST rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch,
 					   const gdb_byte *ldi_buf,
@@ -25,4 +25,4 @@ extern ULONGEST rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch,
 					   ULONGEST len,
 					   int close_ldinfo_fd);
 
-#endif /* RS6000_AIX_TDEP_H */
+#endif /* GDB_RS6000_AIX_TDEP_H */
diff --git a/gdb/rust-exp.h b/gdb/rust-exp.h
index f5c5904cfb4..e0496e1a050 100644
--- a/gdb/rust-exp.h
+++ b/gdb/rust-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RUST_EXP_H
-#define RUST_EXP_H
+#ifndef GDB_RUST_EXP_H
+#define GDB_RUST_EXP_H
 
 #include "expop.h"
 
@@ -226,4 +226,4 @@ class rust_parenthesized_operation
 
 } /* namespace expr */
 
-#endif /* RUST_EXP_H */
+#endif /* GDB_RUST_EXP_H */
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index 9ae5961e9ac..f9c82454817 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RUST_LANG_H
-#define RUST_LANG_H
+#ifndef GDB_RUST_LANG_H
+#define GDB_RUST_LANG_H
 
 #include "demangle.h"
 #include "language.h"
@@ -228,4 +228,4 @@ class rust_language : public language_defn
 		   const struct value_print_options *options) const;
 };
 
-#endif /* RUST_LANG_H */
+#endif /* GDB_RUST_LANG_H */
diff --git a/gdb/s390-linux-tdep.h b/gdb/s390-linux-tdep.h
index 2f9741dca96..b2efb5b1d2f 100644
--- a/gdb/s390-linux-tdep.h
+++ b/gdb/s390-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef S390_LINUX_TDEP_H
-#define S390_LINUX_TDEP_H
+#ifndef GDB_S390_LINUX_TDEP_H
+#define GDB_S390_LINUX_TDEP_H
 
 #define S390_IS_GREGSET_REGNUM(i)					\
   (((i) >= S390_PSWM_REGNUM && (i) <= S390_A15_REGNUM)			\
@@ -64,4 +64,4 @@ extern const struct target_desc *tdesc_s390x_vx_linux64;
 extern const struct target_desc *tdesc_s390x_tevx_linux64;
 extern const struct target_desc *tdesc_s390x_gs_linux64;
 
-#endif /* S390_LINUX_TDEP_H */
+#endif /* GDB_S390_LINUX_TDEP_H */
diff --git a/gdb/s390-tdep.h b/gdb/s390-tdep.h
index 10f775f468f..bfcb8f17c56 100644
--- a/gdb/s390-tdep.h
+++ b/gdb/s390-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef S390_TDEP_H
-#define S390_TDEP_H
+#ifndef GDB_S390_TDEP_H
+#define GDB_S390_TDEP_H
 
 #include "prologue-value.h"
 #include "gdbarch.h"
@@ -322,4 +322,4 @@ extern struct value *s390_trad_frame_prev_register
 extern const struct target_desc *tdesc_s390_linux32;
 extern const struct target_desc *tdesc_s390x_linux64;
 
-#endif /* S390_TDEP_H */
+#endif /* GDB_S390_TDEP_H */
diff --git a/gdb/scoped-mock-context.h b/gdb/scoped-mock-context.h
index 2446e9ad41b..6fd83da4679 100644
--- a/gdb/scoped-mock-context.h
+++ b/gdb/scoped-mock-context.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_MOCK_CONTEXT_H
-#define SCOPED_MOCK_CONTEXT_H
+#ifndef GDB_SCOPED_MOCK_CONTEXT_H
+#define GDB_SCOPED_MOCK_CONTEXT_H
 
 #include "inferior.h"
 #include "gdbthread.h"
@@ -78,4 +78,4 @@ struct scoped_mock_context
 } // namespace selftests
 #endif /* GDB_SELF_TEST */
 
-#endif /* !defined (SCOPED_MOCK_CONTEXT_H) */
+#endif /* GDB_SCOPED_MOCK_CONTEXT_H */
diff --git a/gdb/selftest-arch.h b/gdb/selftest-arch.h
index 84494076bd7..db11723395e 100644
--- a/gdb/selftest-arch.h
+++ b/gdb/selftest-arch.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SELFTEST_ARCH_H
-#define SELFTEST_ARCH_H
+#ifndef GDB_SELFTEST_ARCH_H
+#define GDB_SELFTEST_ARCH_H
 
 typedef void self_test_foreach_arch_function (struct gdbarch *);
 
@@ -31,4 +31,4 @@ extern void
 			      self_test_foreach_arch_function *function);
 }
 
-#endif /* SELFTEST_ARCH_H */
+#endif /* GDB_SELFTEST_ARCH_H */
diff --git a/gdb/sentinel-frame.h b/gdb/sentinel-frame.h
index 1a37ff1f49a..36bee59f0f0 100644
--- a/gdb/sentinel-frame.h
+++ b/gdb/sentinel-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SENTINEL_FRAME_H)
-#define SENTINEL_FRAME_H 1
+#ifndef GDB_SENTINEL_FRAME_H
+#define GDB_SENTINEL_FRAME_H
 
 struct frame_unwind;
 struct regcache;
@@ -36,4 +36,4 @@ extern void *sentinel_frame_cache (struct regcache *regcache);
 
 extern const struct frame_unwind sentinel_frame_unwind;
 
-#endif /* !defined (SENTINEL_FRAME_H)  */
+#endif /* GDB_SENTINEL_FRAME_H */
diff --git a/gdb/ser-base.h b/gdb/ser-base.h
index 37fe0a2e5f5..ecb7c99ea62 100644
--- a/gdb/ser-base.h
+++ b/gdb/ser-base.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_BASE_H
-#define SER_BASE_H
+#ifndef GDB_SER_BASE_H
+#define GDB_SER_BASE_H
 
 #include "serial.h"
 
@@ -50,4 +50,4 @@ extern void ser_base_write (struct serial *scb, const void *buf, size_t count);
 extern void ser_base_async (struct serial *scb, int async_p);
 extern int ser_base_readchar (struct serial *scb, int timeout);
 
-#endif
+#endif /* GDB_SER_BASE_H */
diff --git a/gdb/ser-event.h b/gdb/ser-event.h
index 2c0a59df5df..08fc62b29ab 100644
--- a/gdb/ser-event.h
+++ b/gdb/ser-event.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_EVENT_H
-#define SER_EVENT_H
+#ifndef GDB_SER_EVENT_H
+#define GDB_SER_EVENT_H
 
 /* This is used to be able to signal the event loop (or any other
    select/poll) of events, in a race-free manner.
@@ -48,4 +48,4 @@ extern void serial_event_set (struct serial_event *event);
    call is made.  */
 extern void serial_event_clear (struct serial_event *event);
 
-#endif
+#endif /* GDB_SER_EVENT_H */
diff --git a/gdb/ser-tcp.h b/gdb/ser-tcp.h
index 6ff3662cefd..a1ebcf3c2a8 100644
--- a/gdb/ser-tcp.h
+++ b/gdb/ser-tcp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_TCP_H
-#define SER_TCP_H
+#ifndef GDB_SER_TCP_H
+#define GDB_SER_TCP_H
 
 struct serial;
 
@@ -28,4 +28,4 @@ extern int net_read_prim (struct serial *scb, size_t count);
 extern int net_write_prim (struct serial *scb, const void *buf, size_t count);
 extern void ser_tcp_send_break (struct serial *scb);
 
-#endif
+#endif /* GDB_SER_TCP_H */
diff --git a/gdb/ser-unix.h b/gdb/ser-unix.h
index 253c95b24c0..487921f8d53 100644
--- a/gdb/ser-unix.h
+++ b/gdb/ser-unix.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_UNIX_H
-#define SER_UNIX_H
+#ifndef GDB_SER_UNIX_H
+#define GDB_SER_UNIX_H
 
 extern int ser_unix_read_prim (struct serial *scb, size_t count);
 extern int ser_unix_write_prim (struct serial *scb, const void *buf, 
 				size_t count);
 
-#endif
+#endif /* GDB_SER_UNIX_H */
diff --git a/gdb/serial.h b/gdb/serial.h
index 69507e69295..017b8904c35 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SERIAL_H
-#define SERIAL_H
+#ifndef GDB_SERIAL_H
+#define GDB_SERIAL_H
 
 #ifdef USE_WIN32API
 #include <winsock2.h>
@@ -326,4 +326,4 @@ extern void serial_done_wait_handle (struct serial *);
 
 #endif /* USE_WIN32API */
 
-#endif /* SERIAL_H */
+#endif /* GDB_SERIAL_H */
diff --git a/gdb/sh-tdep.h b/gdb/sh-tdep.h
index 1b1f019920a..dd524406b25 100644
--- a/gdb/sh-tdep.h
+++ b/gdb/sh-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SH_TDEP_H
-#define SH_TDEP_H
+#ifndef GDB_SH_TDEP_H
+#define GDB_SH_TDEP_H
 
 #include "gdbarch.h"
 
@@ -115,4 +115,4 @@ void sh_corefile_supply_regset (const struct regset *regset,
 void sh_corefile_collect_regset (const struct regset *regset,
 				 const struct regcache *regcache,
 				 int regnum, void *regs, size_t len);
-#endif /* SH_TDEP_H */
+#endif /* GDB_SH_TDEP_H */
diff --git a/gdb/sim-regno.h b/gdb/sim-regno.h
index 7f8f9422a02..76ecfeae3d9 100644
--- a/gdb/sim-regno.h
+++ b/gdb/sim-regno.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SIM_REGNO_H
-#define SIM_REGNO_H
+#ifndef GDB_SIM_REGNO_H
+#define GDB_SIM_REGNO_H
 
 /* The gdbarch_register_sim_regno (REGNUM) method, when there is a
    corresponding simulator register, returns that register number as a
@@ -40,4 +40,4 @@ enum sim_regno {
 
 extern int one2one_register_sim_regno (struct gdbarch *gdbarch, int regnum);
 
-#endif
+#endif /* GDB_SIM_REGNO_H */
diff --git a/gdb/skip.h b/gdb/skip.h
index c3e6cbf98ba..5625a7962fc 100644
--- a/gdb/skip.h
+++ b/gdb/skip.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SKIP_H)
-#define SKIP_H
+#ifndef GDB_SKIP_H
+#define GDB_SKIP_H
 
 struct symtab_and_line;
 
@@ -25,4 +25,4 @@ struct symtab_and_line;
 bool function_name_is_marked_for_skip (const char *function_name,
 				       const symtab_and_line &function_sal);
 
-#endif /* !defined (SKIP_H) */
+#endif /* GDB_SKIP_H */
diff --git a/gdb/sol2-tdep.h b/gdb/sol2-tdep.h
index a189666f05e..8e505d30e0e 100644
--- a/gdb/sol2-tdep.h
+++ b/gdb/sol2-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOL2_TDEP_H
-#define SOL2_TDEP_H 1
+#ifndef GDB_SOL2_TDEP_H
+#define GDB_SOL2_TDEP_H
 
 struct gdbarch;
 
@@ -26,4 +26,4 @@ int sol2_sigtramp_p (const frame_info_ptr &this_frame);
 
 void sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
 
-#endif /* sol2-tdep.h */
+#endif /* GDB_SOL2_TDEP_H */
diff --git a/gdb/solib-aix.h b/gdb/solib-aix.h
index 6487460b04c..79cad4dcdee 100644
--- a/gdb/solib-aix.h
+++ b/gdb/solib-aix.h
@@ -15,12 +15,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_AIX_H
-#define SOLIB_AIX_H
+#ifndef GDB_SOLIB_AIX_H
+#define GDB_SOLIB_AIX_H
 
 struct solib_ops;
 extern const solib_ops solib_aix_so_ops;
 
 extern CORE_ADDR solib_aix_get_toc_value (CORE_ADDR pc);
 
-#endif
+#endif /* GDB_SOLIB_AIX_H */
diff --git a/gdb/solib-darwin.h b/gdb/solib-darwin.h
index d6be9eb5b42..d62d6805137 100644
--- a/gdb/solib-darwin.h
+++ b/gdb/solib-darwin.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_DARWIN_H
-#define SOLIB_DARWIN_H
+#ifndef GDB_SOLIB_DARWIN_H
+#define GDB_SOLIB_DARWIN_H
 
 struct solib_ops;
 
 extern const solib_ops darwin_so_ops;
 
-#endif /* solib-darwin.h */
+#endif /* GDB_SOLIB_DARWIN_H */
diff --git a/gdb/solib-dsbt.h b/gdb/solib-dsbt.h
index e1f7d143848..2777939f7f9 100644
--- a/gdb/solib-dsbt.h
+++ b/gdb/solib-dsbt.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_DSBT_H
-#define SOLIB_DSBT_H
+#ifndef GDB_SOLIB_DSBT_H
+#define GDB_SOLIB_DSBT_H
 
 struct solib_ops;
 
 extern const solib_ops dsbt_so_ops;
 
-#endif /* solib-dsbt.h */
+#endif /* GDB_SOLIB_DSBT_H */
diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h
index 579fe6d9843..37cdaff4882 100644
--- a/gdb/solib-svr4.h
+++ b/gdb/solib-svr4.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_SVR4_H
-#define SOLIB_SVR4_H
+#ifndef GDB_SOLIB_SVR4_H
+#define GDB_SOLIB_SVR4_H
 
 #include "solist.h"
 
@@ -112,4 +112,4 @@ extern struct link_map_offsets *svr4_lp64_fetch_link_map_offsets (void);
    SVR4 run time loader.  */
 int svr4_in_dynsym_resolve_code (CORE_ADDR pc);
 
-#endif /* solib-svr4.h */
+#endif /* GDB_SOLIB_SVR4_H */
diff --git a/gdb/solib-target.h b/gdb/solib-target.h
index 70f53c54553..f03e221588e 100644
--- a/gdb/solib-target.h
+++ b/gdb/solib-target.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_TARGET_H
-#define SOLIB_TARGET_H
+#ifndef GDB_SOLIB_TARGET_H
+#define GDB_SOLIB_TARGET_H
 
 struct solib_ops;
 extern const solib_ops solib_target_so_ops;
 
-#endif /* solib-target.h */
+#endif /* GDB_SOLIB_TARGET_H */
diff --git a/gdb/solib.h b/gdb/solib.h
index f7a93c0718f..1d3089634fe 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_H
-#define SOLIB_H
+#ifndef GDB_SOLIB_H
+#define GDB_SOLIB_H
 
 /* Forward decl's for prototypes */
 struct solib;
@@ -143,4 +143,4 @@ extern void set_cbfd_soname_build_id (gdb_bfd_ref_ptr abfd,
 				      const char *soname,
 				      const bfd_build_id *build_id);
 
-#endif /* SOLIB_H */
+#endif /* GDB_SOLIB_H */
diff --git a/gdb/solist.h b/gdb/solist.h
index f0d22080de1..006cdddeed9 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIST_H
-#define SOLIST_H
+#ifndef GDB_SOLIST_H
+#define GDB_SOLIST_H
 
 #define SO_NAME_MAX_PATH_SIZE 512	/* FIXME: Should be dynamic */
 /* For domain_enum domain.  */
@@ -186,4 +186,4 @@ extern gdb_bfd_ref_ptr solib_bfd_fopen (const char *pathname, int fd);
 /* Find solib binary file and open it.  */
 extern gdb_bfd_ref_ptr solib_bfd_open (const char *in_pathname);
 
-#endif
+#endif /* GDB_SOLIST_H */
diff --git a/gdb/source-cache.h b/gdb/source-cache.h
index d4cb7d00ae8..35eeb1cb204 100644
--- a/gdb/source-cache.h
+++ b/gdb/source-cache.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOURCE_CACHE_H
-#define SOURCE_CACHE_H
+#ifndef GDB_SOURCE_CACHE_H
+#define GDB_SOURCE_CACHE_H
 
 #include <unordered_map>
 #include <unordered_set>
@@ -104,4 +104,4 @@ class source_cache
 /* The global source cache.  */
 extern source_cache g_source_cache;
 
-#endif /* SOURCE_CACHE_H */
+#endif /* GDB_SOURCE_CACHE_H */
diff --git a/gdb/source.h b/gdb/source.h
index 144ee48f722..09eb1e38655 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOURCE_H
-#define SOURCE_H
+#ifndef GDB_SOURCE_H
+#define GDB_SOURCE_H
 
 #include "gdbsupport/scoped_fd.h"
 
@@ -216,4 +216,4 @@ extern void forget_cached_source_info (void);
    need to would make things slower than necessary.  */
 extern void select_source_symtab ();
 
-#endif
+#endif /* GDB_SOURCE_H */
diff --git a/gdb/sparc-nat.h b/gdb/sparc-nat.h
index 29d994c2a41..712c9d0ac12 100644
--- a/gdb/sparc-nat.h
+++ b/gdb/sparc-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_NAT_H
-#define SPARC_NAT_H 1
+#ifndef GDB_SPARC_NAT_H
+#define GDB_SPARC_NAT_H
 
 #include "target.h"
 
@@ -82,4 +82,4 @@ struct sparc_target : public BaseTarget
   }
 };
 
-#endif /* sparc-nat.h */
+#endif /* GDB_SPARC_NAT_H */
diff --git a/gdb/sparc-ravenscar-thread.h b/gdb/sparc-ravenscar-thread.h
index d45f6ba8ba5..5f2749f5cd5 100644
--- a/gdb/sparc-ravenscar-thread.h
+++ b/gdb/sparc-ravenscar-thread.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_RAVENSCAR_THREAD_H
-#define SPARC_RAVENSCAR_THREAD_H
+#ifndef GDB_SPARC_RAVENSCAR_THREAD_H
+#define GDB_SPARC_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_sparc_ravenscar_ops (struct gdbarch *gdbarch);
-#endif
+#endif /* GDB_SPARC_RAVENSCAR_THREAD_H */
diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h
index 2d8c50768be..4fd7e6b0f74 100644
--- a/gdb/sparc-tdep.h
+++ b/gdb/sparc-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_TDEP_H
-#define SPARC_TDEP_H 1
+#ifndef GDB_SPARC_TDEP_H
+#define GDB_SPARC_TDEP_H
 
 #include "gdbarch.h"
 
@@ -264,4 +264,4 @@ extern void sparc32nbsd_init_abi (struct gdbarch_info info,
 extern struct trad_frame_saved_reg *
   sparc32nbsd_sigcontext_saved_regs (const frame_info_ptr &next_frame);
 
-#endif /* sparc-tdep.h */
+#endif /* GDB_SPARC_TDEP_H */
diff --git a/gdb/sparc64-tdep.h b/gdb/sparc64-tdep.h
index 6fcd91ee8d3..a19af4a1b5d 100644
--- a/gdb/sparc64-tdep.h
+++ b/gdb/sparc64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC64_TDEP_H
-#define SPARC64_TDEP_H 1
+#ifndef GDB_SPARC64_TDEP_H
+#define GDB_SPARC64_TDEP_H
 
 class frame_info_ptr;
 struct gdbarch;
@@ -137,4 +137,4 @@ extern const struct sparc_fpregmap sparc64_bsd_fpregmap;
 
 extern void sparc64_forget_process (pid_t pid);
 
-#endif /* sparc64-tdep.h */
+#endif /* GDB_SPARC64_TDEP_H */
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index 0a868409470..00c7bd9edfa 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef STABSREAD_H
-#define STABSREAD_H
+#ifndef GDB_STABSREAD_H
+#define GDB_STABSREAD_H
 
 struct objfile;
 struct legacy_psymtab;
@@ -215,4 +215,4 @@ extern void init_header_files (void);
 
 extern void scan_file_globals (struct objfile *objfile);
 
-#endif /* STABSREAD_H */
+#endif /* GDB_STABSREAD_H */
diff --git a/gdb/stack.h b/gdb/stack.h
index e7242c71036..e87ba322dee 100644
--- a/gdb/stack.h
+++ b/gdb/stack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef STACK_H
-#define STACK_H
+#ifndef GDB_STACK_H
+#define GDB_STACK_H
 
 gdb::unique_xmalloc_ptr<char> find_frame_funname (const frame_info_ptr &frame,
 						  enum language *funlang,
@@ -84,4 +84,4 @@ void frame_apply_all_cmd_completer (struct cmd_list_element *ignore,
 				    completion_tracker &tracker,
 				    const char *text, const char */*word*/);
 
-#endif /* #ifndef STACK_H */
+#endif /* GDB_STACK_H */
diff --git a/gdb/stap-probe.h b/gdb/stap-probe.h
index 1401b876ba7..e757d80ef38 100644
--- a/gdb/stap-probe.h
+++ b/gdb/stap-probe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (STAP_PROBE_H)
-#define STAP_PROBE_H 1
+#ifndef GDB_STAP_PROBE_H
+#define GDB_STAP_PROBE_H
 
 #include "parser-defs.h"
 
@@ -66,4 +66,4 @@ struct stap_parse_info
   int inside_paren_p;
 };
 
-#endif /* !defined (STAP_PROBE_H) */
+#endif /* GDB_STAP_PROBE_H */
diff --git a/gdb/symfile-add-flags.h b/gdb/symfile-add-flags.h
index 19dd5e36907..3db532cc86b 100644
--- a/gdb/symfile-add-flags.h
+++ b/gdb/symfile-add-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMFILE_ADD_FLAGS_H)
-#define SYMFILE_ADD_FLAGS_H
+#ifndef GDB_SYMFILE_ADD_FLAGS_H
+#define GDB_SYMFILE_ADD_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -54,4 +54,4 @@ enum symfile_add_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum symfile_add_flag, symfile_add_flags);
 
-#endif /* !defined(SYMFILE_ADD_FLAGS_H) */
+#endif /* GDB_SYMFILE_ADD_FLAGS_H */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 6f8b441b39f..3ed2179ba41 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMFILE_H)
-#define SYMFILE_H
+#ifndef GDB_SYMFILE_H
+#define GDB_SYMFILE_H
 
 /* This file requires that you first include "bfd.h".  */
 #include "symtab.h"
@@ -379,4 +379,4 @@ extern int readnow_symbol_files;
 
 extern int readnever_symbol_files;
 
-#endif /* !defined(SYMFILE_H) */
+#endif /* GDB_SYMFILE_H */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index bf9a3cfb79f..bfc91574415 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMTAB_H)
-#define SYMTAB_H 1
+#ifndef GDB_SYMTAB_H
+#define GDB_SYMTAB_H
 
 #include <array>
 #include <vector>
@@ -2974,4 +2974,4 @@ extern void info_sources_worker (struct ui_out *uiout,
 
 std::optional<CORE_ADDR> find_epilogue_using_linetable (CORE_ADDR func_addr);
 
-#endif /* !defined(SYMTAB_H) */
+#endif /* GDB_SYMTAB_H */
diff --git a/gdb/target-connection.h b/gdb/target-connection.h
index c742932644f..4faae112dc7 100644
--- a/gdb/target-connection.h
+++ b/gdb/target-connection.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_CONNECTION_H
-#define TARGET_CONNECTION_H
+#ifndef GDB_TARGET_CONNECTION_H
+#define GDB_TARGET_CONNECTION_H
 
 #include <string>
 
@@ -37,4 +37,4 @@ void connection_list_remove (process_stratum_target *t);
    it.  */
 std::string make_target_connection_string (process_stratum_target *t);
 
-#endif /* TARGET_CONNECTION_H */
+#endif /* GDB_TARGET_CONNECTION_H */
diff --git a/gdb/target-dcache.h b/gdb/target-dcache.h
index 4acc82f83ce..a199a2382f2 100644
--- a/gdb/target-dcache.h
+++ b/gdb/target-dcache.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DCACHE_H
-#define TARGET_DCACHE_H
+#ifndef GDB_TARGET_DCACHE_H
+#define GDB_TARGET_DCACHE_H
 
 #include "dcache.h"
 #include "progspace.h"
@@ -33,4 +33,4 @@ extern int stack_cache_enabled_p (void);
 
 extern int code_cache_enabled_p (void);
 
-#endif /* TARGET_DCACHE_H */
+#endif /* GDB_TARGET_DCACHE_H */
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index 20ba1f73ac5..cf8d690511f 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DEBUG_H
-#define TARGET_DEBUG_H
+#ifndef GDB_TARGET_DEBUG_H
+#define GDB_TARGET_DEBUG_H
 
 /* Printers for the debug target.  Each prints an object of a given
    type to a string that needn't be freed.  Most printers are macros,
@@ -264,4 +264,4 @@ target_debug_print_x86_xsave_layout (const x86_xsave_layout &layout)
 #undef POFFS
   gdb_puts (" }", gdb_stdlog);
 }
-#endif /* TARGET_DEBUG_H */
+#endif /* GDB_TARGET_DEBUG_H */
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 54c1f234f06..833a367bc9a 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DESCRIPTIONS_H
-#define TARGET_DESCRIPTIONS_H 1
+#ifndef GDB_TARGET_DESCRIPTIONS_H
+#define GDB_TARGET_DESCRIPTIONS_H
 #include "gdbsupport/tdesc.h"
 #include "gdbarch.h"
 
@@ -238,4 +238,4 @@ void record_xml_tdesc (const char *xml_file,
 }
 #endif
 
-#endif /* TARGET_DESCRIPTIONS_H */
+#endif /* GDB_TARGET_DESCRIPTIONS_H */
diff --git a/gdb/target-float.h b/gdb/target-float.h
index a649f5ceb86..0b9cd7a8409 100644
--- a/gdb/target-float.h
+++ b/gdb/target-float.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_FLOAT_H
-#define TARGET_FLOAT_H
+#ifndef GDB_TARGET_FLOAT_H
+#define GDB_TARGET_FLOAT_H
 
 #include "expression.h"
 
@@ -58,4 +58,4 @@ extern void target_float_binop (enum exp_opcode opcode,
 extern int target_float_compare (const gdb_byte *x, const struct type *type_x,
 				 const gdb_byte *y, const struct type *type_y);
 
-#endif /* TARGET_FLOAT_H */
+#endif /* GDB_TARGET_FLOAT_H */
diff --git a/gdb/target.h b/gdb/target.h
index c9eaff16346..c9f7d4c22d9 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TARGET_H)
-#define TARGET_H
+#ifndef GDB_TARGET_H
+#define GDB_TARGET_H
 
 struct objfile;
 struct ui_file;
@@ -2580,4 +2580,4 @@ extern void target_prepare_to_generate_core (void);
 /* See to_done_generating_core.  */
 extern void target_done_generating_core (void);
 
-#endif /* !defined (TARGET_H) */
+#endif /* GDB_TARGET_H */
diff --git a/gdb/target/resume.h b/gdb/target/resume.h
index 2f13aa9ada1..024e39b5bce 100644
--- a/gdb/target/resume.h
+++ b/gdb/target/resume.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_RESUME_H
-#define TARGET_RESUME_H
+#ifndef GDB_TARGET_RESUME_H
+#define GDB_TARGET_RESUME_H
 
 /* Ways to "resume" a thread.  */
 
@@ -34,4 +34,4 @@ enum resume_kind
   resume_stop
 };
 
-#endif /* TARGET_RESUME_H */
+#endif /* GDB_TARGET_RESUME_H */
diff --git a/gdb/target/target.h b/gdb/target/target.h
index 408db3558b0..87a3464e323 100644
--- a/gdb/target/target.h
+++ b/gdb/target/target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_TARGET_H
-#define TARGET_TARGET_H
+#ifndef GDB_TARGET_TARGET_H
+#define GDB_TARGET_TARGET_H
 
 #include "target/waitstatus.h"
 #include "target/wait.h"
@@ -262,4 +262,4 @@ class target_terminal
   static target_terminal_state m_terminal_state;
 };
 
-#endif /* TARGET_TARGET_H */
+#endif /* GDB_TARGET_TARGET_H */
diff --git a/gdb/target/wait.h b/gdb/target/wait.h
index 304f61497aa..026a42f9a30 100644
--- a/gdb/target/wait.h
+++ b/gdb/target/wait.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_WAIT_H
-#define TARGET_WAIT_H
+#ifndef GDB_TARGET_WAIT_H
+#define GDB_TARGET_WAIT_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -34,4 +34,4 @@ enum target_wait_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum target_wait_flag, target_wait_flags);
 
-#endif /* TARGET_WAIT_H */
+#endif /* GDB_TARGET_WAIT_H */
diff --git a/gdb/target/waitstatus.h b/gdb/target/waitstatus.h
index dce1a7f3175..08907f5a610 100644
--- a/gdb/target/waitstatus.h
+++ b/gdb/target/waitstatus.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_WAITSTATUS_H
-#define TARGET_WAITSTATUS_H
+#ifndef GDB_TARGET_WAITSTATUS_H
+#define GDB_TARGET_WAITSTATUS_H
 
 #include "diagnostics.h"
 #include "gdbsupport/gdb_signals.h"
@@ -470,4 +470,4 @@ enum target_stop_reason
   TARGET_STOPPED_BY_SINGLE_STEP
 };
 
-#endif /* TARGET_WAITSTATUS_H */
+#endif /* GDB_TARGET_WAITSTATUS_H */
diff --git a/gdb/terminal.h b/gdb/terminal.h
index 236ab67745b..154b4be952b 100644
--- a/gdb/terminal.h
+++ b/gdb/terminal.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TERMINAL_H)
-#define TERMINAL_H 1
+#ifndef GDB_TERMINAL_H
+#define GDB_TERMINAL_H
 
 struct inferior;
 
@@ -43,4 +43,4 @@ extern void gdb_save_tty_state (void);
    have had a chance to alter it.  */
 extern void set_initial_gdb_ttystate (void);
 
-#endif /* !defined (TERMINAL_H) */
+#endif /* GDB_TERMINAL_H */
diff --git a/gdb/test-target.h b/gdb/test-target.h
index 54924e06994..b88c154da8f 100644
--- a/gdb/test-target.h
+++ b/gdb/test-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TEST_TARGET_H
-#define TEST_TARGET_H
+#ifndef GDB_TEST_TARGET_H
+#define GDB_TEST_TARGET_H
 
 #include "process-stratum-target.h"
 
@@ -62,4 +62,4 @@ class test_target_ops : public process_stratum_target
 } // namespace selftests
 #endif /* GDB_SELF_TEST */
 
-#endif /* !defined (TEST_TARGET_H) */
+#endif /* GDB_TEST_TARGET_H */
diff --git a/gdb/thread-fsm.h b/gdb/thread-fsm.h
index ed117719c0d..36efee75abc 100644
--- a/gdb/thread-fsm.h
+++ b/gdb/thread-fsm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef THREAD_FSM_H
-#define THREAD_FSM_H
+#ifndef GDB_THREAD_FSM_H
+#define GDB_THREAD_FSM_H
 
 #include "mi/mi-common.h"
 
@@ -129,4 +129,4 @@ struct thread_fsm
   }
 };
 
-#endif /* THREAD_FSM_H */
+#endif /* GDB_THREAD_FSM_H */
diff --git a/gdb/thread-iter.h b/gdb/thread-iter.h
index a2fd9891a57..89537213ac0 100644
--- a/gdb/thread-iter.h
+++ b/gdb/thread-iter.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef THREAD_ITER_H
-#define THREAD_ITER_H
+#ifndef GDB_THREAD_ITER_H
+#define GDB_THREAD_ITER_H
 
 #include "gdbsupport/filtered-iterator.h"
 #include "gdbsupport/iterator-range.h"
@@ -249,4 +249,4 @@ class all_non_exited_threads_range
   ptid_t m_filter_ptid;
 };
 
-#endif /* THREAD_ITER_H */
+#endif /* GDB_THREAD_ITER_H */
diff --git a/gdb/tic6x-tdep.h b/gdb/tic6x-tdep.h
index 886e1b8b309..03a8a3ebb55 100644
--- a/gdb/tic6x-tdep.h
+++ b/gdb/tic6x-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TIC6X_TDEP_H
-#define TIC6X_TDEP_H
+#ifndef GDB_TIC6X_TDEP_H
+#define GDB_TIC6X_TDEP_H
 
 #include "gdbarch.h"
 
@@ -57,4 +57,4 @@ struct tic6x_gdbarch_tdep : gdbarch_tdep_base
   int has_gp = 0; /* Has general purpose registers A16 - A31 and B16 - B31.  */
 };
 
-#endif /* TIC6X_TDEP_H */
+#endif /* GDB_TIC6X_TDEP_H */
diff --git a/gdb/tid-parse.h b/gdb/tid-parse.h
index b7bd920f48a..ad45f216350 100644
--- a/gdb/tid-parse.h
+++ b/gdb/tid-parse.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TID_PARSE_H
-#define TID_PARSE_H
+#ifndef GDB_TID_PARSE_H
+#define GDB_TID_PARSE_H
 
 #include "cli/cli-utils.h"
 
@@ -186,4 +186,4 @@ class tid_range_parser
 extern int tid_is_in_list (const char *list, int default_inferior,
 			   int inf_num, int thr_num);
 
-#endif /* TID_PARSE_H */
+#endif /* GDB_TID_PARSE_H */
diff --git a/gdb/tilegx-tdep.h b/gdb/tilegx-tdep.h
index 893035a6273..5430281bed5 100644
--- a/gdb/tilegx-tdep.h
+++ b/gdb/tilegx-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TILEGX_TDEP_H
-#define TILEGX_TDEP_H
+#ifndef GDB_TILEGX_TDEP_H
+#define GDB_TILEGX_TDEP_H
 
 /* TILE-Gx has 56 general purpose registers (R0 - R52, TP, SP, LR),
    plus 8 special general purpose registers (network and ZERO),
@@ -107,4 +107,4 @@ enum tilegx_regnum
 
 enum { tilegx_reg_size = 8 };
 
-#endif /* tilegx-tdep.h */
+#endif /* GDB_TILEGX_TDEP_H */
diff --git a/gdb/top.h b/gdb/top.h
index 68c637a03d8..c142f1d9363 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TOP_H
-#define TOP_H
+#ifndef GDB_TOP_H
+#define GDB_TOP_H
 
 #include "gdbsupport/event-loop.h"
 #include "gdbsupport/next-iterator.h"
@@ -109,4 +109,4 @@ extern bool check_quiet_mode ();
 
 extern void unbuffer_stream (FILE *stream);
 
-#endif
+#endif /* GDB_TOP_H */
diff --git a/gdb/tracectf.h b/gdb/tracectf.h
index 08a681cb8cf..9f821c5314c 100644
--- a/gdb/tracectf.h
+++ b/gdb/tracectf.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CTF_H
-#define CTF_H
+#ifndef GDB_TRACECTF_H
+#define GDB_TRACECTF_H
 
 extern struct trace_file_writer *ctf_trace_file_writer_new (void);
 
-#endif
+#endif /* GDB_TRACECTF_H */
diff --git a/gdb/tracefile.h b/gdb/tracefile.h
index 90967eff855..028f70dabd3 100644
--- a/gdb/tracefile.h
+++ b/gdb/tracefile.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRACEFILE_H
-#define TRACEFILE_H 1
+#ifndef GDB_TRACEFILE_H
+#define GDB_TRACEFILE_H
 
 #include "tracepoint.h"
 #include "target.h"
@@ -151,4 +151,4 @@ class tracefile_target : public process_stratum_target
 
 extern void tracefile_fetch_registers (struct regcache *regcache, int regno);
 
-#endif /* TRACEFILE_H */
+#endif /* GDB_TRACEFILE_H */
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index 5e6ea67c8d2..1b9e03efc7a 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TRACEPOINT_H)
-#define TRACEPOINT_H 1
+#ifndef GDB_TRACEPOINT_H
+#define GDB_TRACEPOINT_H
 
 #include "breakpoint.h"
 #include "memrange.h"
@@ -432,4 +432,4 @@ extern struct bp_location *get_traceframe_location (int *stepping_frame_p);
 /* Command element for the 'while-stepping' command.  */
 extern cmd_list_element *while_stepping_cmd_element;
 
-#endif	/* TRACEPOINT_H */
+#endif /* GDB_TRACEPOINT_H */
diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h
index ca8792baa17..40a3f74d44a 100644
--- a/gdb/trad-frame.h
+++ b/gdb/trad-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRAD_FRAME_H
-#define TRAD_FRAME_H
+#ifndef GDB_TRAD_FRAME_H
+#define GDB_TRAD_FRAME_H
 
 #include "frame.h"
 
@@ -203,4 +203,4 @@ struct value *trad_frame_get_prev_register (const frame_info_ptr &this_frame,
 					    trad_frame_saved_reg this_saved_regs[],
 					    int regnum);
 
-#endif
+#endif /* GDB_TRAD_FRAME_H */
diff --git a/gdb/tramp-frame.h b/gdb/tramp-frame.h
index d9e54f5981a..a7288c1889c 100644
--- a/gdb/tramp-frame.h
+++ b/gdb/tramp-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRAMP_FRAME_H
-#define TRAMP_FRAME_H
+#ifndef GDB_TRAMP_FRAME_H
+#define GDB_TRAMP_FRAME_H
 
 #include "frame.h"
 #include "frame-unwind.h"	/* For frame_prev_arch_ftype.  */
@@ -85,4 +85,4 @@ struct tramp_frame
 void tramp_frame_prepend_unwinder (struct gdbarch *gdbarch,
 				   const struct tramp_frame *tramp);
 
-#endif
+#endif /* GDB_TRAMP_FRAME_H */
diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h
index 2dc579bce30..0f6553845a2 100644
--- a/gdb/tui/tui-command.h
+++ b/gdb/tui/tui-command.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_COMMAND_H
-#define TUI_TUI_COMMAND_H
+#ifndef GDB_TUI_TUI_COMMAND_H
+#define GDB_TUI_TUI_COMMAND_H
 
 #include "tui/tui-data.h"
 
@@ -58,4 +58,4 @@ struct tui_cmd_window
 /* Refresh the command window.  */
 extern void tui_refresh_cmd_win (void);
 
-#endif /* TUI_TUI_COMMAND_H */
+#endif /* GDB_TUI_TUI_COMMAND_H */
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index ce9c1a8a95a..4ff9fa64aa7 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_DATA_H
-#define TUI_TUI_DATA_H
+#ifndef GDB_TUI_TUI_DATA_H
+#define GDB_TUI_TUI_DATA_H
 
 #include "tui/tui.h"
 #include "gdb_curses.h"
@@ -325,4 +325,4 @@ extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
 
 extern unsigned int tui_tab_width;
 
-#endif /* TUI_TUI_DATA_H */
+#endif /* GDB_TUI_TUI_DATA_H */
diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
index 0aef091069b..a5a240fddf1 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_DISASM_H
-#define TUI_TUI_DISASM_H
+#ifndef GDB_TUI_TUI_DISASM_H
+#define GDB_TUI_TUI_DISASM_H
 
 #include "tui/tui.h"
 #include "tui/tui-data.h"
@@ -66,4 +66,4 @@ struct tui_disasm_window : public tui_source_window_base
 
 extern void tui_get_begin_asm_address (struct gdbarch **, CORE_ADDR *);
 
-#endif /* TUI_TUI_DISASM_H */
+#endif /* GDB_TUI_TUI_DISASM_H */
diff --git a/gdb/tui/tui-file.h b/gdb/tui/tui-file.h
index b723f3974ea..6178a90a6c6 100644
--- a/gdb/tui/tui-file.h
+++ b/gdb/tui/tui-file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_FILE_H
-#define TUI_TUI_FILE_H
+#ifndef GDB_TUI_TUI_FILE_H
+#define GDB_TUI_TUI_FILE_H
 
 #include "ui-file.h"
 
@@ -41,4 +41,4 @@ class tui_file : public stdio_file
   bool m_buffered;
 };
 
-#endif /* TUI_TUI_FILE_H */
+#endif /* GDB_TUI_TUI_FILE_H */
diff --git a/gdb/tui/tui-hooks.h b/gdb/tui/tui-hooks.h
index 97683826544..21ba169713c 100644
--- a/gdb/tui/tui-hooks.h
+++ b/gdb/tui/tui-hooks.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_HOOKS_H
-#define TUI_TUI_HOOKS_H
+#ifndef GDB_TUI_TUI_HOOKS_H
+#define GDB_TUI_TUI_HOOKS_H
 
 extern void tui_install_hooks (void);
 extern void tui_remove_hooks (void);
 
-#endif /* TUI_TUI_HOOKS_H */
+#endif /* GDB_TUI_TUI_HOOKS_H */
diff --git a/gdb/tui/tui-io.h b/gdb/tui/tui-io.h
index 9e7eecdf5f4..66b3b90dfe3 100644
--- a/gdb/tui/tui-io.h
+++ b/gdb/tui/tui-io.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_IO_H
-#define TUI_TUI_IO_H
+#ifndef GDB_TUI_TUI_IO_H
+#define GDB_TUI_TUI_IO_H
 
 #include "gdb_curses.h"
 
@@ -60,4 +60,4 @@ extern cli_ui_out *tui_old_uiout;
    next line.  */
 extern void tui_inject_newline_into_command_window ();
 
-#endif /* TUI_TUI_IO_H */
+#endif /* GDB_TUI_TUI_IO_H */
diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h
index f621f9cea55..d1dc9bfd904 100644
--- a/gdb/tui/tui-layout.h
+++ b/gdb/tui/tui-layout.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_LAYOUT_H
-#define TUI_TUI_LAYOUT_H
+#ifndef GDB_TUI_TUI_LAYOUT_H
+#define GDB_TUI_TUI_LAYOUT_H
 
 #include "ui-file.h"
 
@@ -418,4 +418,4 @@ using known_window_names_range
 
 extern known_window_names_range all_known_window_names ();
 
-#endif /* TUI_TUI_LAYOUT_H */
+#endif /* GDB_TUI_TUI_LAYOUT_H */
diff --git a/gdb/tui/tui-location.h b/gdb/tui/tui-location.h
index db558a4e147..8e83b26996b 100644
--- a/gdb/tui/tui-location.h
+++ b/gdb/tui/tui-location.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_LOCATION_H
-#define TUI_TUI_LOCATION_H
+#ifndef GDB_TUI_TUI_LOCATION_H
+#define GDB_TUI_TUI_LOCATION_H
 
 #include "tui/tui.h"
 #include "tui/tui.h"
@@ -90,4 +90,4 @@ struct tui_location_tracker
 
 extern tui_location_tracker tui_location;
 
-#endif /* TUI_TUI_LOCATION_H */
+#endif /* GDB_TUI_TUI_LOCATION_H */
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 07b951316b6..eea5ca6d061 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_REGS_H
-#define TUI_TUI_REGS_H
+#ifndef GDB_TUI_TUI_REGS_H
+#define GDB_TUI_TUI_REGS_H
 
 #include "tui/tui-data.h"
 #include "reggroups.h"
@@ -145,4 +145,4 @@ struct tui_data_window : public tui_win_info
   gdbarch *m_gdbarch = nullptr;
 };
 
-#endif /* TUI_TUI_REGS_H */
+#endif /* GDB_TUI_TUI_REGS_H */
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 6d4ad4e39c2..4312b928740 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_SOURCE_H
-#define TUI_TUI_SOURCE_H
+#ifndef GDB_TUI_TUI_SOURCE_H
+#define GDB_TUI_TUI_SOURCE_H
 
 #include "tui/tui-data.h"
 #include "tui-winsource.h"
@@ -84,4 +84,4 @@ struct tui_source_window : public tui_source_window_base
   gdb::unique_xmalloc_ptr<char> m_fullname;
 };
 
-#endif /* TUI_TUI_SOURCE_H */
+#endif /* GDB_TUI_TUI_SOURCE_H */
diff --git a/gdb/tui/tui-status.h b/gdb/tui/tui-status.h
index 0af44664104..b4c8a2bd407 100644
--- a/gdb/tui/tui-status.h
+++ b/gdb/tui/tui-status.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_STATUS_H
-#define TUI_TUI_STATUS_H
+#ifndef GDB_TUI_TUI_STATUS_H
+#define GDB_TUI_TUI_STATUS_H
 
 #include "tui/tui-data.h"
 
@@ -53,4 +53,4 @@ struct tui_status_window
 extern void tui_show_status_content (void);
 extern void tui_show_frame_info (const frame_info_ptr &);
 
-#endif /* TUI_TUI_STATUS_H */
+#endif /* GDB_TUI_TUI_STATUS_H */
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 9b03d01c430..15219930149 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WIN_H
-#define TUI_TUI_WIN_H
+#ifndef GDB_TUI_TUI_WIN_H
+#define GDB_TUI_TUI_WIN_H
 
 #include "tui/tui-data.h"
 
@@ -61,4 +61,4 @@ extern bool style_tui_current_position;
 /* Whether to replace the spaces in the left margin with '_' and '0'.  */
 extern bool tui_left_margin_verbose;
 
-#endif /* TUI_TUI_WIN_H */
+#endif /* GDB_TUI_TUI_WIN_H */
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 6bee433689e..c36f32de7e4 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WINGENERAL_H
-#define TUI_TUI_WINGENERAL_H
+#ifndef GDB_TUI_TUI_WINGENERAL_H
+#define GDB_TUI_TUI_WINGENERAL_H
 
 #include "gdb_curses.h"
 
@@ -53,4 +53,4 @@ class tui_suppress_output
    suppressed via tui_suppress_output, do not call wrefresh.  */
 extern void tui_wrefresh (WINDOW *win);
 
-#endif /* TUI_TUI_WINGENERAL_H */
+#endif /* GDB_TUI_TUI_WINGENERAL_H */
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 646597306f2..7effb5694e3 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WINSOURCE_H
-#define TUI_TUI_WINSOURCE_H
+#ifndef GDB_TUI_TUI_WINSOURCE_H
+#define GDB_TUI_TUI_WINSOURCE_H
 
 #include "tui/tui-data.h"
 #include "symtab.h"
@@ -365,4 +365,4 @@ extern std::string tui_copy_source_line (const char **ptr,
 /* Constant definitions. */
 #define SCROLL_THRESHOLD 2	/* Threshold for lazy scroll.  */
 
-#endif /* TUI_TUI_WINSOURCE_H */
+#endif /* GDB_TUI_TUI_WINSOURCE_H */
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index 00295107eac..1bcaa2f4099 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_H
-#define TUI_TUI_H
+#ifndef GDB_TUI_TUI_H
+#define GDB_TUI_TUI_H
 
 /* Flag to control tui debugging.  */
 
@@ -98,4 +98,4 @@ extern void tui_set_key_mode (enum tui_key_mode mode);
 
 extern bool tui_active;
 
-#endif /* TUI_TUI_H */
+#endif /* GDB_TUI_TUI_H */
diff --git a/gdb/type-stack.h b/gdb/type-stack.h
index faef3c85f67..87c0fe20c5a 100644
--- a/gdb/type-stack.h
+++ b/gdb/type-stack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TYPE_STACK_H
-#define TYPE_STACK_H
+#ifndef GDB_TYPE_STACK_H
+#define GDB_TYPE_STACK_H
 
 #include "gdbtypes.h"
 #include <vector>
@@ -203,4 +203,4 @@ struct type_stack
   std::vector<union type_stack_elt> m_elements;
 };
 
-#endif /* TYPE_STACK_H */
+#endif /* GDB_TYPE_STACK_H */
diff --git a/gdb/typeprint.h b/gdb/typeprint.h
index e14d70efa2d..91b64f3e728 100644
--- a/gdb/typeprint.h
+++ b/gdb/typeprint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TYPEPRINT_H
-#define TYPEPRINT_H
+#ifndef GDB_TYPEPRINT_H
+#define GDB_TYPEPRINT_H
 
 #include "gdbsupport/gdb_obstack.h"
 
@@ -181,4 +181,4 @@ extern void val_print_not_allocated (struct ui_file *stream);
 
 extern void val_print_not_associated (struct ui_file *stream);
 
-#endif
+#endif /* GDB_TYPEPRINT_H */
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index 96864409375..627e51ae84c 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_FILE_H
-#define UI_FILE_H
+#ifndef GDB_UI_FILE_H
+#define GDB_UI_FILE_H
 
 #include <string>
 #include "ui-style.h"
@@ -467,4 +467,4 @@ class timestamped_file : public wrapped_file
   bool m_needs_timestamp = true;
 };
 
-#endif
+#endif /* GDB_UI_FILE_H */
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 5b6ddd55063..67f6b18576f 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_OUT_H
-#define UI_OUT_H 1
+#ifndef GDB_UI_OUT_H
+#define GDB_UI_OUT_H
 
 #include <vector>
 
@@ -654,4 +654,4 @@ struct buffered_streams
   std::optional<buffering_file> m_buffered_uiout;
 };
 
-#endif /* UI_OUT_H */
+#endif /* GDB_UI_OUT_H */
diff --git a/gdb/ui-style.h b/gdb/ui-style.h
index 1b7b5fafb9d..53ac2897c78 100644
--- a/gdb/ui-style.h
+++ b/gdb/ui-style.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_STYLE_H
-#define UI_STYLE_H
+#ifndef GDB_UI_STYLE_H
+#define GDB_UI_STYLE_H
 
 /* Styles that can be applied to a ui_file.  */
 struct ui_file_style
@@ -250,4 +250,4 @@ struct ui_file_style
 
 extern bool skip_ansi_escape (const char *buf, int *n_read);
 
-#endif /* UI_STYLE_H */
+#endif /* GDB_UI_STYLE_H */
diff --git a/gdb/ui.h b/gdb/ui.h
index 95cf273473a..ec3a6c5fbae 100644
--- a/gdb/ui.h
+++ b/gdb/ui.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_H
-#define UI_H
+#ifndef GDB_UI_H
+#define GDB_UI_H
 
 #include "gdbsupport/event-loop.h"
 #include "gdbsupport/intrusive_list.h"
@@ -229,4 +229,4 @@ ui_range all_uis ()
   return ui_range (ui_list);
 }
 
-#endif /* UI_H */
+#endif /* GDB_UI_H */
diff --git a/gdb/user-regs.h b/gdb/user-regs.h
index baa3581a0ba..67a28dd429e 100644
--- a/gdb/user-regs.h
+++ b/gdb/user-regs.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef USER_REGS_H
-#define USER_REGS_H
+#ifndef GDB_USER_REGS_H
+#define GDB_USER_REGS_H
 
 /* Implement both builtin, and architecture specific, per-frame user
    visible registers.
@@ -69,4 +69,4 @@ extern void user_reg_add_builtin (const char *name,
 extern void user_reg_add (struct gdbarch *gdbarch, const char *name, 
 			  user_reg_read_ftype *read, const void *baton);
 
-#endif
+#endif /* GDB_USER_REGS_H */
diff --git a/gdb/utils.h b/gdb/utils.h
index 96350890a97..2dc36f42ed1 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UTILS_H
-#define UTILS_H
+#ifndef GDB_UTILS_H
+#define GDB_UTILS_H
 
 #include "exceptions.h"
 #include "gdbsupport/array-view.h"
@@ -475,4 +475,4 @@ struct deferred_warnings final : public warning_hook_handler_type
   std::vector<string_file> m_warnings;
 };
 
-#endif /* UTILS_H */
+#endif /* GDB_UTILS_H */
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 4f194b77008..834e9d97ffd 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VALPRINT_H
-#define VALPRINT_H
+#ifndef GDB_VALPRINT_H
+#define GDB_VALPRINT_H
 
 #include "cli/cli-option.h"
 
@@ -337,4 +337,4 @@ extern void common_val_print_checked
    const struct value_print_options *options,
    const struct language_defn *language);
 
-#endif
+#endif /* GDB_VALPRINT_H */
diff --git a/gdb/value.h b/gdb/value.h
index 9d7e88d9433..8fc9550f11f 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (VALUE_H)
-#define VALUE_H 1
+#ifndef GDB_VALUE_H
+#define GDB_VALUE_H
 
 #include "frame.h"
 #include "extension.h"
@@ -1704,4 +1704,4 @@ void pseudo_to_concat_raw (const frame_info_ptr &next_frame,
 			   int raw_reg_1_num, int raw_reg_2_num,
 			   int raw_reg_3_num);
 
-#endif /* !defined (VALUE_H) */
+#endif /* GDB_VALUE_H */
diff --git a/gdb/varobj-iter.h b/gdb/varobj-iter.h
index 4254f8b549e..46e25e797c8 100644
--- a/gdb/varobj-iter.h
+++ b/gdb/varobj-iter.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAROBJ_ITER_H
-#define VAROBJ_ITER_H
+#ifndef GDB_VAROBJ_ITER_H
+#define GDB_VAROBJ_ITER_H
 
 /* A node or item of varobj, composed of the name and the value.  */
 
@@ -39,4 +39,4 @@ struct varobj_iter
   virtual std::unique_ptr<varobj_item> next () = 0;
 };
 
-#endif /* VAROBJ_ITER_H */
+#endif /* GDB_VAROBJ_ITER_H */
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 426c3b7d628..9d19f53fb3e 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAROBJ_H
-#define VAROBJ_H 1
+#ifndef GDB_VAROBJ_H
+#define GDB_VAROBJ_H
 
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -355,4 +355,4 @@ extern void varobj_restrict_range (const std::vector<varobj *> &children,
 
 extern bool varobj_default_is_path_expr_parent (const struct varobj *var);
 
-#endif /* VAROBJ_H */
+#endif /* GDB_VAROBJ_H */
diff --git a/gdb/vax-tdep.h b/gdb/vax-tdep.h
index 72b072d692d..fbc35d97c4e 100644
--- a/gdb/vax-tdep.h
+++ b/gdb/vax-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAX_TDEP_H
-#define VAX_TDEP_H
+#ifndef GDB_VAX_TDEP_H
+#define GDB_VAX_TDEP_H
 
 /* Register numbers of various important registers.  */
 
@@ -36,4 +36,4 @@ enum vax_regnum
 /* Number of machine registers.  */
 #define VAX_NUM_REGS 17
 
-#endif /* vax-tdep.h */
+#endif /* GDB_VAX_TDEP_H */
diff --git a/gdb/windows-nat.h b/gdb/windows-nat.h
index 3fbb1ea35df..b36e7f45512 100644
--- a/gdb/windows-nat.h
+++ b/gdb/windows-nat.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef WINDOWS_NAT_H
-#define WINDOWS_NAT_H
+#ifndef GDB_WINDOWS_NAT_H
+#define GDB_WINDOWS_NAT_H
 
 /* A pointer to a function that should return non-zero iff REGNUM
    corresponds to one of the segment registers.  */
@@ -36,4 +36,4 @@ int amd64_windows_segment_register_p (int regnum);
 extern const int amd64_mappings[];
 #endif
 
-#endif
+#endif /* GDB_WINDOWS_NAT_H */
diff --git a/gdb/windows-tdep.h b/gdb/windows-tdep.h
index f122f7aaa61..abb25331938 100644
--- a/gdb/windows-tdep.h
+++ b/gdb/windows-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef WINDOWS_TDEP_H
-#define WINDOWS_TDEP_H
+#ifndef GDB_WINDOWS_TDEP_H
+#define GDB_WINDOWS_TDEP_H
 
 #include "frame-unwind.h"
 
@@ -75,4 +75,4 @@ struct cygwin_sigwrapper_frame_unwind : public frame_unwind
   gdb::array_view<const gdb::array_view<const gdb_byte>> patterns_list;
 };
 
-#endif
+#endif /* GDB_WINDOWS_TDEP_H */
diff --git a/gdb/x86-bsd-nat.h b/gdb/x86-bsd-nat.h
index 7b1ba7a1f44..b1745448ece 100644
--- a/gdb/x86-bsd-nat.h
+++ b/gdb/x86-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_BSD_NAT_H
-#define X86_BSD_NAT_H
+#ifndef GDB_X86_BSD_NAT_H
+#define GDB_X86_BSD_NAT_H
 
 #include "x86-nat.h"
 
@@ -43,4 +43,4 @@ class x86bsd_nat_target : public BaseTarget
 };
 #endif /* HAVE_PT_GETDBREGS */
 
-#endif /* x86-bsd-nat.h */
+#endif /* GDB_X86_BSD_NAT_H */
diff --git a/gdb/x86-fbsd-nat.h b/gdb/x86-fbsd-nat.h
index a202e77c788..66f2b2f61b2 100644
--- a/gdb/x86-fbsd-nat.h
+++ b/gdb/x86-fbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_FBSD_NAT_H
-#define X86_FBSD_NAT_H
+#ifndef GDB_X86_FBSD_NAT_H
+#define GDB_X86_FBSD_NAT_H
 
 #include <sys/ptrace.h>
 
@@ -53,4 +53,4 @@ class x86_fbsd_nat_target : public x86bsd_nat_target<fbsd_nat_target>
 #endif
 };
 
-#endif /* x86-bsd-nat.h */
+#endif /* GDB_X86_FBSD_NAT_H */
diff --git a/gdb/x86-linux-nat.h b/gdb/x86-linux-nat.h
index 4efe5461847..3c2241bb0b6 100644
--- a/gdb/x86-linux-nat.h
+++ b/gdb/x86-linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_LINUX_NAT_H
-#define X86_LINUX_NAT_H 1
+#ifndef GDB_X86_LINUX_NAT_H
+#define GDB_X86_LINUX_NAT_H
 
 #include "gdb_proc_service.h"
 #include "linux-nat.h"
@@ -92,4 +92,4 @@ struct x86_linux_nat_target : public x86_nat_target<linux_nat_target>
 extern ps_err_e x86_linux_get_thread_area (pid_t pid, void *addr,
 					   unsigned int *base_addr);
 
-#endif
+#endif /* GDB_X86_LINUX_NAT_H */
diff --git a/gdb/x86-nat.h b/gdb/x86-nat.h
index f07cefa027d..1b8fdd38325 100644
--- a/gdb/x86-nat.h
+++ b/gdb/x86-nat.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_NAT_H
-#define X86_NAT_H 1
+#ifndef GDB_X86_NAT_H
+#define GDB_X86_NAT_H
 
 #include "breakpoint.h"
 #include "nat/x86-dregs.h"
@@ -114,4 +114,4 @@ struct x86_nat_target : public BaseTarget
   { return x86_stopped_by_hw_breakpoint (); }
 };
 
-#endif /* X86_NAT_H */
+#endif /* GDB_X86_NAT_H */
diff --git a/gdb/x86-tdep.h b/gdb/x86-tdep.h
index 7ab47814d41..2b5853adb8a 100644
--- a/gdb/x86-tdep.h
+++ b/gdb/x86-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_TDEP_H
-#define X86_TDEP_H
+#ifndef GDB_X86_TDEP_H
+#define GDB_X86_TDEP_H
 
 /* Checks whether PC lies in an indirect branch thunk using registers
    REGISTER_NAMES[LO] (inclusive) to REGISTER_NAMES[HI] (exclusive).  */
@@ -27,4 +27,4 @@ extern bool x86_in_indirect_branch_thunk (CORE_ADDR pc,
 					  const char * const *register_names,
 					  int lo, int hi);
 
-#endif /* x86-tdep.h */
+#endif /* GDB_X86_TDEP_H */
diff --git a/gdb/xcoffread.h b/gdb/xcoffread.h
index 8bc729e3dff..7528dec4a6c 100644
--- a/gdb/xcoffread.h
+++ b/gdb/xcoffread.h
@@ -16,11 +16,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XCOFFREAD_H
-#define XCOFFREAD_H
+#ifndef GDB_XCOFFREAD_H
+#define GDB_XCOFFREAD_H
 
 extern CORE_ADDR xcoff_get_toc_offset (struct objfile *);
 
 extern int xcoff_get_n_import_files (bfd *abfd);
 
-#endif /* XCOFFREAD_H */
+#endif /* GDB_XCOFFREAD_H */
diff --git a/gdb/xml-builtin.h b/gdb/xml-builtin.h
index 417771ea4e9..463e0fb16e0 100644
--- a/gdb/xml-builtin.h
+++ b/gdb/xml-builtin.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_BUILTIN_H
-#define XML_BUILTIN_H
+#ifndef GDB_XML_BUILTIN_H
+#define GDB_XML_BUILTIN_H
 
 /* The text of compiled-in XML documents, from xml-builtin.c
    (generated).  */
 
 extern const char *const xml_builtin[][2];
 
-#endif /* XML_BUILTIN_H */
+#endif /* GDB_XML_BUILTIN_H */
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index b9bac7a10c2..f2860a20d6b 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef XML_SUPPORT_H
-#define XML_SUPPORT_H
+#ifndef GDB_XML_SUPPORT_H
+#define GDB_XML_SUPPORT_H
 
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/xml-utils.h"
@@ -233,4 +233,4 @@ ULONGEST gdb_xml_parse_ulongest (struct gdb_xml_parser *parser,
 extern std::optional<gdb::char_vector> xml_fetch_content_from_file
     (const char *filename, const char *dirname);
 
-#endif
+#endif /* GDB_XML_SUPPORT_H */
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index 60cfb71ada2..579805d9394 100644
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_SYSCALL_H
-#define XML_SYSCALL_H 1
+#ifndef GDB_XML_SYSCALL_H
+#define GDB_XML_SYSCALL_H
 
 /* Function used to set the name of the file which contains
    information about the system calls present in the current
@@ -66,4 +66,4 @@ bool get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
 
 const char **get_syscall_group_names (struct gdbarch *gdbarch);
 
-#endif /* XML_SYSCALL_H */
+#endif /* GDB_XML_SYSCALL_H */
diff --git a/gdb/xml-tdesc.h b/gdb/xml-tdesc.h
index cd6e79cc24f..ec71c682f86 100644
--- a/gdb/xml-tdesc.h
+++ b/gdb/xml-tdesc.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_TDESC_H
-#define XML_TDESC_H
+#ifndef GDB_XML_TDESC_H
+#define GDB_XML_TDESC_H
 
 #include <optional>
 #include <string>
@@ -49,4 +49,4 @@ std::optional<std::string> target_fetch_description_xml (target_ops *ops);
 
 const struct target_desc *string_read_description_xml (const char *xml);
 
-#endif /* XML_TDESC_H */
+#endif /* GDB_XML_TDESC_H */
diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h
index b76ed137380..832b4fbf33a 100644
--- a/gdb/xtensa-tdep.h
+++ b/gdb/xtensa-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XTENSA_TDEP_H
-#define XTENSA_TDEP_H
+#ifndef GDB_XTENSA_TDEP_H
+#define GDB_XTENSA_TDEP_H
 
 #include "arch/xtensa.h"
 #include "gdbarch.h"
@@ -249,4 +249,4 @@ struct xtensa_gdbarch_tdep : gdbarch_tdep_base
    data structure to their corresponding register in the AR register 
    file (see xtensa-tdep.c).  */
 
-#endif /* XTENSA_TDEP_H */
+#endif /* GDB_XTENSA_TDEP_H */
diff --git a/gdb/yy-remap.h b/gdb/yy-remap.h
index d52a59d11b9..9a6c399b855 100644
--- a/gdb/yy-remap.h
+++ b/gdb/yy-remap.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef YY_REMAP_H
-#define YY_REMAP_H
+#ifndef GDB_YY_REMAP_H
+#define GDB_YY_REMAP_H
 
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
    etc), as well as gratuitiously global symbol names, so we can have
@@ -97,4 +97,4 @@
 # define YYFPRINTF parser_fprintf
 #endif
 
-#endif /* YY_REMAP_H */
+#endif /* GDB_YY_REMAP_H */
diff --git a/gdb/z80-tdep.h b/gdb/z80-tdep.h
index 4b36024d1f0..19a7d046f7a 100644
--- a/gdb/z80-tdep.h
+++ b/gdb/z80-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef Z80_TDEP_H
-#define Z80_TDEP_H
+#ifndef GDB_Z80_TDEP_H
+#define GDB_Z80_TDEP_H
 
 /* Register pair constants
    Order optimized for gdb-stub implementation
@@ -49,4 +49,4 @@ enum z80_regnum
 #define EZ80_NUM_REGS	(Z80_NUM_REGS + 1)
 #define EZ80_REG_BYTES	(EZ80_NUM_REGS*3)
 
-#endif /* z80-tdep.h */
+#endif /* GDB_Z80_TDEP_H */
diff --git a/gdbserver/linux-aarch32-tdesc.h b/gdbserver/linux-aarch32-tdesc.h
index ff1c45fa1c1..173eac24389 100644
--- a/gdbserver/linux-aarch32-tdesc.h
+++ b/gdbserver/linux-aarch32-tdesc.h
@@ -26,4 +26,4 @@ const target_desc * aarch32_linux_read_description ();
 
 bool is_aarch32_linux_description (const target_desc *tdesc);
 
-#endif /* linux-aarch32-tdesc.h.  */
+#endif /* GDBSERVER_LINUX_AARCH32_TDESC_H */
diff --git a/gdbserver/linux-arm-tdesc.h b/gdbserver/linux-arm-tdesc.h
index 76a30c3c73a..bf12c8f5b68 100644
--- a/gdbserver/linux-arm-tdesc.h
+++ b/gdbserver/linux-arm-tdesc.h
@@ -28,4 +28,4 @@ const target_desc * arm_linux_read_description (arm_fp_type fp_type);
 
 arm_fp_type arm_linux_get_tdesc_fp_type (const target_desc *tdesc);
 
-#endif /* linux-arm-tdesc.h.  */
+#endif /* GDBSERVER_LINUX_ARM_TDESC_H */
diff --git a/gdbsupport/agent.h b/gdbsupport/agent.h
index e5a1fed84b9..305ed70fff2 100644
--- a/gdbsupport/agent.h
+++ b/gdbsupport/agent.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_AGENT_H
-#define COMMON_AGENT_H
+#ifndef GDBSUPPORT_AGENT_H
+#define GDBSUPPORT_AGENT_H
 
 #include "gdbsupport/preprocessor.h"
 
@@ -65,4 +65,4 @@ bool agent_capability_check (enum agent_capa);
 
 void agent_capability_invalidate (void);
 
-#endif /* COMMON_AGENT_H */
+#endif /* GDBSUPPORT_AGENT_H */
diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h
index 93842a40ec1..a61e09e882c 100644
--- a/gdbsupport/array-view.h
+++ b/gdbsupport/array-view.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ARRAY_VIEW_H
-#define COMMON_ARRAY_VIEW_H
+#ifndef GDBSUPPORT_ARRAY_VIEW_H
+#define GDBSUPPORT_ARRAY_VIEW_H
 
 #include "traits.h"
 #include <algorithm>
@@ -294,4 +294,4 @@ make_array_view (U *array, size_t size) noexcept
 
 } /* namespace gdb */
 
-#endif
+#endif /* GDBSUPPORT_ARRAY_VIEW_H */
diff --git a/gdbsupport/break-common.h b/gdbsupport/break-common.h
index 95ab3e290ba..1202231be0c 100644
--- a/gdbsupport/break-common.h
+++ b/gdbsupport/break-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BREAK_COMMON_H
-#define COMMON_BREAK_COMMON_H
+#ifndef GDBSUPPORT_BREAK_COMMON_H
+#define GDBSUPPORT_BREAK_COMMON_H
 
 enum target_hw_bp_type
   {
@@ -28,4 +28,4 @@ enum target_hw_bp_type
     hw_execute = 3		/* Execute HW breakpoint */
   };
 
-#endif /* COMMON_BREAK_COMMON_H */
+#endif /* GDBSUPPORT_BREAK_COMMON_H */
diff --git a/gdbsupport/btrace-common.h b/gdbsupport/btrace-common.h
index bf57bc1615e..1888b242f70 100644
--- a/gdbsupport/btrace-common.h
+++ b/gdbsupport/btrace-common.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BTRACE_COMMON_H
-#define COMMON_BTRACE_COMMON_H
+#ifndef GDBSUPPORT_BTRACE_COMMON_H
+#define GDBSUPPORT_BTRACE_COMMON_H
 
 /* Branch tracing (btrace) is a per-thread control-flow execution trace of the
    inferior.  For presentation purposes, the branch trace is represented as a
@@ -276,4 +276,4 @@ extern const char *btrace_format_short_string (enum btrace_format format);
 extern int btrace_data_append (struct btrace_data *dst,
 			       const struct btrace_data *src);
 
-#endif /* COMMON_BTRACE_COMMON_H */
+#endif /* GDBSUPPORT_BTRACE_COMMON_H */
diff --git a/gdbsupport/byte-vector.h b/gdbsupport/byte-vector.h
index 54f4cc2edf2..0586d40016e 100644
--- a/gdbsupport/byte-vector.h
+++ b/gdbsupport/byte-vector.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BYTE_VECTOR_H
-#define COMMON_BYTE_VECTOR_H
+#ifndef GDBSUPPORT_BYTE_VECTOR_H
+#define GDBSUPPORT_BYTE_VECTOR_H
 
 #include "gdbsupport/def-vector.h"
 
@@ -60,4 +60,4 @@ using char_vector = gdb::def_vector<char>;
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEF_VECTOR_H */
+#endif /* GDBSUPPORT_BYTE_VECTOR_H */
diff --git a/gdbsupport/cleanups.h b/gdbsupport/cleanups.h
index 985cf81ff7d..12b7774763c 100644
--- a/gdbsupport/cleanups.h
+++ b/gdbsupport/cleanups.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_CLEANUPS_H
-#define COMMON_CLEANUPS_H
+#ifndef GDBSUPPORT_CLEANUPS_H
+#define GDBSUPPORT_CLEANUPS_H
 
 #include <functional>
 
@@ -27,4 +27,4 @@ extern void add_final_cleanup (std::function<void ()> &&func);
 /* Run all the registered functions.  */
 extern void do_final_cleanups ();
 
-#endif /* COMMON_CLEANUPS_H */
+#endif /* GDBSUPPORT_CLEANUPS_H */
diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h
index b41d6a401cc..6c793dc33d4 100644
--- a/gdbsupport/common-debug.h
+++ b/gdbsupport/common-debug.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_DEBUG_H
-#define COMMON_COMMON_DEBUG_H
+#ifndef GDBSUPPORT_COMMON_DEBUG_H
+#define GDBSUPPORT_COMMON_DEBUG_H
 
 #include <optional>
 #include "gdbsupport/preprocessor.h"
@@ -271,4 +271,4 @@ make_scoped_debug_start_end (PT &&pred, const char *module, const char *func,
 				   __func__, "enter", "exit",	\
 				   nullptr)
 
-#endif /* COMMON_COMMON_DEBUG_H */
+#endif /* GDBSUPPORT_COMMON_DEBUG_H */
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index 6120719480b..07315956514 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_DEFS_H
-#define COMMON_COMMON_DEFS_H
+#ifndef GDBSUPPORT_COMMON_DEFS_H
+#define GDBSUPPORT_COMMON_DEFS_H
 
 #include <gdbsupport/config.h>
 
@@ -217,4 +217,4 @@
 #define HAVE_USEFUL_SBRK 1
 #endif
 
-#endif /* COMMON_COMMON_DEFS_H */
+#endif /* GDBSUPPORT_COMMON_DEFS_H */
diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h
index ffc02d2107f..124c41d1acd 100644
--- a/gdbsupport/common-exceptions.h
+++ b/gdbsupport/common-exceptions.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_EXCEPTIONS_H
-#define COMMON_COMMON_EXCEPTIONS_H
+#ifndef GDBSUPPORT_COMMON_EXCEPTIONS_H
+#define GDBSUPPORT_COMMON_EXCEPTIONS_H
 
 #include <setjmp.h>
 #include <new>
@@ -359,4 +359,4 @@ extern void throw_quit (const char *fmt, ...)
 extern void throw_forced_quit (const char *fmt, ...)
      ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
 
-#endif /* COMMON_COMMON_EXCEPTIONS_H */
+#endif /* GDBSUPPORT_COMMON_EXCEPTIONS_H */
diff --git a/gdbsupport/common-gdbthread.h b/gdbsupport/common-gdbthread.h
index d149f8eed41..289cc8f1b30 100644
--- a/gdbsupport/common-gdbthread.h
+++ b/gdbsupport/common-gdbthread.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_GDBTHREAD_H
-#define COMMON_COMMON_GDBTHREAD_H
+#ifndef GDBSUPPORT_COMMON_GDBTHREAD_H
+#define GDBSUPPORT_COMMON_GDBTHREAD_H
 
 struct process_stratum_target;
 
@@ -25,4 +25,4 @@ struct process_stratum_target;
 extern void switch_to_thread (process_stratum_target *proc_target,
 			      ptid_t ptid);
 
-#endif /* COMMON_COMMON_GDBTHREAD_H */
+#endif /* GDBSUPPORT_COMMON_GDBTHREAD_H */
diff --git a/gdbsupport/common-inferior.h b/gdbsupport/common-inferior.h
index bc6afd65f2b..299c159678b 100644
--- a/gdbsupport/common-inferior.h
+++ b/gdbsupport/common-inferior.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_INFERIOR_H
-#define COMMON_COMMON_INFERIOR_H
+#ifndef GDBSUPPORT_COMMON_INFERIOR_H
+#define GDBSUPPORT_COMMON_INFERIOR_H
 
 #include "gdbsupport/array-view.h"
 
@@ -62,4 +62,4 @@ extern bool startup_with_shell;
 extern std::string
 construct_inferior_arguments (gdb::array_view<char * const>);
 
-#endif /* COMMON_COMMON_INFERIOR_H */
+#endif /* GDBSUPPORT_COMMON_INFERIOR_H */
diff --git a/gdbsupport/common-regcache.h b/gdbsupport/common-regcache.h
index f8704c16939..caf4662e7e5 100644
--- a/gdbsupport/common-regcache.h
+++ b/gdbsupport/common-regcache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_REGCACHE_H
-#define COMMON_COMMON_REGCACHE_H
+#ifndef GDBSUPPORT_COMMON_REGCACHE_H
+#define GDBSUPPORT_COMMON_REGCACHE_H
 
 struct reg_buffer_common;
 
@@ -120,4 +120,4 @@ struct reg_buffer_common
   virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0;
 };
 
-#endif /* COMMON_COMMON_REGCACHE_H */
+#endif /* GDBSUPPORT_COMMON_REGCACHE_H */
diff --git a/gdbsupport/common-types.h b/gdbsupport/common-types.h
index 19d3f49ca0f..10d5f38ae4a 100644
--- a/gdbsupport/common-types.h
+++ b/gdbsupport/common-types.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_TYPES_H
-#define COMMON_COMMON_TYPES_H
+#ifndef GDBSUPPORT_COMMON_TYPES_H
+#define GDBSUPPORT_COMMON_TYPES_H
 
 #include <inttypes.h>
 
@@ -53,4 +53,4 @@ typedef uint64_t ULONGEST;
 
 enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 };
 
-#endif /* COMMON_COMMON_TYPES_H */
+#endif /* GDBSUPPORT_COMMON_TYPES_H */
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 23cd40c0207..42c129b643c 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_UTILS_H
-#define COMMON_COMMON_UTILS_H
+#ifndef GDBSUPPORT_COMMON_UTILS_H
+#define GDBSUPPORT_COMMON_UTILS_H
 
 #include <string>
 #include <vector>
@@ -242,4 +242,4 @@ struct string_view_hash
 
 } /* namespace gdb */
 
-#endif /* COMMON_COMMON_UTILS_H */
+#endif /* GDBSUPPORT_COMMON_UTILS_H */
diff --git a/gdbsupport/def-vector.h b/gdbsupport/def-vector.h
index b9aa663c688..3db6a2fedc9 100644
--- a/gdbsupport/def-vector.h
+++ b/gdbsupport/def-vector.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_DEF_VECTOR_H
-#define COMMON_DEF_VECTOR_H
+#ifndef GDBSUPPORT_DEF_VECTOR_H
+#define GDBSUPPORT_DEF_VECTOR_H
 
 #include <vector>
 #include "gdbsupport/default-init-alloc.h"
@@ -33,4 +33,4 @@ template<typename T> using def_vector
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEF_VECTOR_H */
+#endif /* GDBSUPPORT_DEF_VECTOR_H */
diff --git a/gdbsupport/default-init-alloc.h b/gdbsupport/default-init-alloc.h
index 5ed9715b64c..e84110f128a 100644
--- a/gdbsupport/default-init-alloc.h
+++ b/gdbsupport/default-init-alloc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_DEFAULT_INIT_ALLOC_H
-#define COMMON_DEFAULT_INIT_ALLOC_H
+#ifndef GDBSUPPORT_DEFAULT_INIT_ALLOC_H
+#define GDBSUPPORT_DEFAULT_INIT_ALLOC_H
 
 #if __cplusplus >= 202002L
 #include <memory_resource>
@@ -75,4 +75,4 @@ class default_init_allocator : public A
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEFAULT_INIT_ALLOC_H */
+#endif /* GDBSUPPORT_DEFAULT_INIT_ALLOC_H */
diff --git a/gdbsupport/enum-flags.h b/gdbsupport/enum-flags.h
index 50780043477..b2858b83efe 100644
--- a/gdbsupport/enum-flags.h
+++ b/gdbsupport/enum-flags.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ENUM_FLAGS_H
-#define COMMON_ENUM_FLAGS_H
+#ifndef GDBSUPPORT_ENUM_FLAGS_H
+#define GDBSUPPORT_ENUM_FLAGS_H
 
 #include "traits.h"
 
@@ -493,4 +493,4 @@ enum_flags<E>::to_string (const string_mapping (&mapping)[N]) const
 
 #endif /* __cplusplus */
 
-#endif /* COMMON_ENUM_FLAGS_H */
+#endif /* GDBSUPPORT_ENUM_FLAGS_H */
diff --git a/gdbsupport/environ.h b/gdbsupport/environ.h
index e46050b0350..6ac9f75d94e 100644
--- a/gdbsupport/environ.h
+++ b/gdbsupport/environ.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ENVIRON_H
-#define COMMON_ENVIRON_H
+#ifndef GDBSUPPORT_ENVIRON_H
+#define GDBSUPPORT_ENVIRON_H
 
 #include <vector>
 #include <set>
@@ -100,4 +100,4 @@ class gdb_environ
   std::set<std::string> m_user_unset_env;
 };
 
-#endif /* COMMON_ENVIRON_H */
+#endif /* GDBSUPPORT_ENVIRON_H */
diff --git a/gdbsupport/errors.h b/gdbsupport/errors.h
index d8daed0f5f2..4570221f879 100644
--- a/gdbsupport/errors.h
+++ b/gdbsupport/errors.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ERRORS_H
-#define COMMON_ERRORS_H
+#ifndef GDBSUPPORT_ERRORS_H
+#define GDBSUPPORT_ERRORS_H
 
 /* A problem was detected, but the requested operation can still
    proceed.  A warning message is constructed using a printf- or
@@ -129,4 +129,4 @@ extern void throw_winerror_with_name (const char *string, ULONGEST err)
 
 #endif /* USE_WIN32API */
 
-#endif /* COMMON_ERRORS_H */
+#endif /* GDBSUPPORT_ERRORS_H */
diff --git a/gdbsupport/event-loop.h b/gdbsupport/event-loop.h
index 9155658e8f9..80f471066c8 100644
--- a/gdbsupport/event-loop.h
+++ b/gdbsupport/event-loop.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EVENT_LOOP_H
-#define EVENT_LOOP_H
+#ifndef GDBSUPPORT_EVENT_LOOP_H
+#define GDBSUPPORT_EVENT_LOOP_H
 
 /* An event loop listens for events from multiple event sources.  When
    an event arrives, it is queued and processed by calling the
@@ -145,4 +145,4 @@ extern debug_event_loop_kind debug_event_loop;
     } \
   while (0)
 
-#endif /* EVENT_LOOP_H */
+#endif /* GDBSUPPORT_EVENT_LOOP_H */
diff --git a/gdbsupport/event-pipe.h b/gdbsupport/event-pipe.h
index fb5dd3a8833..7262403e267 100644
--- a/gdbsupport/event-pipe.h
+++ b/gdbsupport/event-pipe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_EVENT_PIPE_H
-#define COMMON_EVENT_PIPE_H
+#ifndef GDBSUPPORT_EVENT_PIPE_H
+#define GDBSUPPORT_EVENT_PIPE_H
 
 /* An event pipe used as a waitable file in the event loop in place of
    some other event associated with a signal.  The handler for the
@@ -57,4 +57,4 @@ class event_pipe
   int m_fds[2] = { -1, -1 };
 };
 
-#endif /* COMMON_EVENT_PIPE_H */
+#endif /* GDBSUPPORT_EVENT_PIPE_H */
diff --git a/gdbsupport/fileio.h b/gdbsupport/fileio.h
index 2e7469d771b..7e4c361d14f 100644
--- a/gdbsupport/fileio.h
+++ b/gdbsupport/fileio.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILEIO_H
-#define COMMON_FILEIO_H
+#ifndef GDBSUPPORT_FILEIO_H
+#define GDBSUPPORT_FILEIO_H
 
 #include <sys/stat.h>
 
@@ -186,4 +186,4 @@ host_to_fileio_time (time_t num, fio_time_t fnum)
 
 extern void host_to_fileio_stat (struct stat *st, struct fio_stat *fst);
 
-#endif /* COMMON_FILEIO_H */
+#endif /* GDBSUPPORT_FILEIO_H */
diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h
index e2ee141d46f..549987bc29c 100644
--- a/gdbsupport/filestuff.h
+++ b/gdbsupport/filestuff.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILESTUFF_H
-#define COMMON_FILESTUFF_H
+#ifndef GDBSUPPORT_FILESTUFF_H
+#define GDBSUPPORT_FILESTUFF_H
 
 #include <dirent.h>
 #include <fcntl.h>
@@ -137,4 +137,4 @@ extern std::optional<std::string> read_text_file_to_string (const char *path);
 
 extern std::string read_remainder_of_file (FILE *file);
 
-#endif /* COMMON_FILESTUFF_H */
+#endif /* GDBSUPPORT_FILESTUFF_H */
diff --git a/gdbsupport/filtered-iterator.h b/gdbsupport/filtered-iterator.h
index 12e5e6cd577..f801f9614da 100644
--- a/gdbsupport/filtered-iterator.h
+++ b/gdbsupport/filtered-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILTERED_ITERATOR_H
-#define COMMON_FILTERED_ITERATOR_H
+#ifndef GDBSUPPORT_FILTERED_ITERATOR_H
+#define GDBSUPPORT_FILTERED_ITERATOR_H
 
 #include <type_traits>
 
@@ -89,4 +89,4 @@ class filtered_iterator
   BaseIterator m_end {};
 };
 
-#endif /* COMMON_FILTERED_ITERATOR_H */
+#endif /* GDBSUPPORT_FILTERED_ITERATOR_H */
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 68504b4475c..b1f0c46d4c2 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FORMAT_H
-#define COMMON_FORMAT_H
+#ifndef GDBSUPPORT_FORMAT_H
+#define GDBSUPPORT_FORMAT_H
 
 #include <string_view>
 
@@ -101,4 +101,4 @@ class format_pieces
   gdb::unique_xmalloc_ptr<char> m_storage;
 };
 
-#endif /* COMMON_FORMAT_H */
+#endif /* GDBSUPPORT_FORMAT_H */
diff --git a/gdbsupport/forward-scope-exit.h b/gdbsupport/forward-scope-exit.h
index 6dd22722595..d4a3fc00cf8 100644
--- a/gdbsupport/forward-scope-exit.h
+++ b/gdbsupport/forward-scope-exit.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FORWARD_SCOPE_EXIT_H
-#define COMMON_FORWARD_SCOPE_EXIT_H
+#ifndef GDBSUPPORT_FORWARD_SCOPE_EXIT_H
+#define GDBSUPPORT_FORWARD_SCOPE_EXIT_H
 
 #include "gdbsupport/scope-exit.h"
 #include <functional>
@@ -120,4 +120,4 @@ class forward_scope_exit<Function, function, Res (Args...)>
 #define FORWARD_SCOPE_EXIT(FUNC) \
   detail::forward_scope_exit<decltype (FUNC), FUNC, decltype (FUNC)>
 
-#endif /* COMMON_FORWARD_SCOPE_EXIT_H */
+#endif /* GDBSUPPORT_FORWARD_SCOPE_EXIT_H */
diff --git a/gdbsupport/function-view.h b/gdbsupport/function-view.h
index 9d852c2a378..f8262068174 100644
--- a/gdbsupport/function-view.h
+++ b/gdbsupport/function-view.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FUNCTION_VIEW_H
-#define COMMON_FUNCTION_VIEW_H
+#ifndef GDBSUPPORT_FUNCTION_VIEW_H
+#define GDBSUPPORT_FUNCTION_VIEW_H
 
 /* function_view is a polymorphic type-erasing wrapper class that
    encapsulates a non-owning reference to arbitrary callable objects.
@@ -448,4 +448,4 @@ auto make_function_view (Callable &&callable)
 
 } /* namespace gdb */
 
-#endif
+#endif /* GDBSUPPORT_FUNCTION_VIEW_H */
diff --git a/gdbsupport/gdb-checked-static-cast.h b/gdbsupport/gdb-checked-static-cast.h
index 97843fab225..e8909b9206f 100644
--- a/gdbsupport/gdb-checked-static-cast.h
+++ b/gdbsupport/gdb-checked-static-cast.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_CHECKED_STATIC_CAST_H
-#define COMMON_GDB_CHECKED_STATIC_CAST_H
+#ifndef GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H
+#define GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H
 
 #include "gdbsupport/traits.h"
 
@@ -80,4 +80,4 @@ checked_static_cast (V &v)
 
 }
 
-#endif /* COMMON_GDB_CHECKED_STATIC_CAST_H */
+#endif /* GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H */
diff --git a/gdbsupport/gdb-dlfcn.h b/gdbsupport/gdb-dlfcn.h
index 24481d94e5c..654db794638 100644
--- a/gdbsupport/gdb-dlfcn.h
+++ b/gdbsupport/gdb-dlfcn.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DLFCN_H
-#define GDB_DLFCN_H
+#ifndef GDBSUPPORT_GDB_DLFCN_H
+#define GDBSUPPORT_GDB_DLFCN_H
 
 /* A deleter that closes an open dynamic library.  */
 
@@ -48,4 +48,4 @@ void *gdb_dlsym (const gdb_dlhandle_up &handle, const char *symbol);
 
 int is_dl_available(void);
 
-#endif /* GDB_DLFCN_H */
+#endif /* GDBSUPPORT_GDB_DLFCN_H */
diff --git a/gdbsupport/gdb-safe-ctype.h b/gdbsupport/gdb-safe-ctype.h
index a91e54a3e65..f8968ef7e7c 100644
--- a/gdbsupport/gdb-safe-ctype.h
+++ b/gdbsupport/gdb-safe-ctype.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_SAFE_CTYPE_H
-#define GDB_SAFE_CTYPE_H
+#ifndef GDBSUPPORT_GDB_SAFE_CTYPE_H
+#define GDBSUPPORT_GDB_SAFE_CTYPE_H
 
 /* After safe-ctype.h is included, we can no longer use the host's
    ctype routines.  Trying to do so results in compile errors.  Code
@@ -46,4 +46,4 @@ gdb_isprint (int ch)
 #include <locale>
 #include "safe-ctype.h"
 
-#endif
+#endif /* GDBSUPPORT_GDB_SAFE_CTYPE_H */
diff --git a/gdbsupport/gdb_assert.h b/gdbsupport/gdb_assert.h
index 2b5e6557424..dd0e1e2286e 100644
--- a/gdbsupport/gdb_assert.h
+++ b/gdbsupport/gdb_assert.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_ASSERT_H
-#define COMMON_GDB_ASSERT_H
+#ifndef GDBSUPPORT_GDB_ASSERT_H
+#define GDBSUPPORT_GDB_ASSERT_H
 
 #include "errors.h"
 
@@ -43,4 +43,4 @@
   internal_error_loc (__FILE__, __LINE__, _("%s: " message), __func__, \
 		      ##__VA_ARGS__)
 
-#endif /* COMMON_GDB_ASSERT_H */
+#endif /* GDBSUPPORT_GDB_ASSERT_H */
diff --git a/gdbsupport/gdb_file.h b/gdbsupport/gdb_file.h
index 645ecb9f75c..41bbbbc51b1 100644
--- a/gdbsupport/gdb_file.h
+++ b/gdbsupport/gdb_file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDBSUPPORT_GDB_FILE
-#define GDBSUPPORT_GDB_FILE
+#ifndef GDBSUPPORT_GDB_FILE_H
+#define GDBSUPPORT_GDB_FILE_H
 
 #include <memory>
 #include <stdio.h>
@@ -34,4 +34,4 @@ struct gdb_file_deleter
 
 typedef std::unique_ptr<FILE, gdb_file_deleter> gdb_file_up;
 
-#endif
+#endif /* GDBSUPPORT_GDB_FILE_H */
diff --git a/gdbsupport/gdb_locale.h b/gdbsupport/gdb_locale.h
index 58524857879..dcdb064a917 100644
--- a/gdbsupport/gdb_locale.h
+++ b/gdbsupport/gdb_locale.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_LOCALE_H
-#define COMMON_GDB_LOCALE_H
+#ifndef GDBSUPPORT_GDB_LOCALE_H
+#define GDBSUPPORT_GDB_LOCALE_H
 
 #ifdef HAVE_LOCALE_H
 # include <locale.h>
@@ -40,4 +40,4 @@
 #include <langinfo.h>
 #endif
 
-#endif /* COMMON_GDB_LOCALE_H */
+#endif /* GDBSUPPORT_GDB_LOCALE_H */
diff --git a/gdbsupport/gdb_obstack.h b/gdbsupport/gdb_obstack.h
index 7b3bb05bc00..d40182441f8 100644
--- a/gdbsupport/gdb_obstack.h
+++ b/gdbsupport/gdb_obstack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDB_OBSTACK_H)
-#define GDB_OBSTACK_H 1
+#ifndef GDBSUPPORT_GDB_OBSTACK_H
+#define GDBSUPPORT_GDB_OBSTACK_H
 
 #include "obstack.h"
 
@@ -157,4 +157,4 @@ struct allocate_on_obstack
   void operator delete[] (void *memory) {}
 };
 
-#endif
+#endif /* GDBSUPPORT_GDB_OBSTACK_H */
diff --git a/gdbsupport/gdb_proc_service.h b/gdbsupport/gdb_proc_service.h
index 52f77a8a5c5..0009702b978 100644
--- a/gdbsupport/gdb_proc_service.h
+++ b/gdbsupport/gdb_proc_service.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_PROC_SERVICE_H
-#define COMMON_GDB_PROC_SERVICE_H
+#ifndef GDBSUPPORT_GDB_PROC_SERVICE_H
+#define GDBSUPPORT_GDB_PROC_SERVICE_H
 
 #include <sys/types.h>
 
@@ -199,4 +199,4 @@ PS_EXPORT (ps_lsetxregs);
 PS_EXPORT (ps_plog);
 #endif
 
-#endif /* COMMON_GDB_PROC_SERVICE_H */
+#endif /* GDBSUPPORT_GDB_PROC_SERVICE_H */
diff --git a/gdbsupport/gdb_ref_ptr.h b/gdbsupport/gdb_ref_ptr.h
index 8a90cb10b05..df2b3d80815 100644
--- a/gdbsupport/gdb_ref_ptr.h
+++ b/gdbsupport/gdb_ref_ptr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_REF_PTR_H
-#define COMMON_GDB_REF_PTR_H
+#ifndef GDBSUPPORT_GDB_REF_PTR_H
+#define GDBSUPPORT_GDB_REF_PTR_H
 
 #include <cstddef>
 
@@ -225,4 +225,4 @@ inline bool operator!= (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
 
 }
 
-#endif /* COMMON_GDB_REF_PTR_H */
+#endif /* GDBSUPPORT_GDB_REF_PTR_H */
diff --git a/gdbsupport/gdb_regex.h b/gdbsupport/gdb_regex.h
index aeb1bb922a9..76264e5a0c9 100644
--- a/gdbsupport/gdb_regex.h
+++ b/gdbsupport/gdb_regex.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_REGEX_H
-#define GDB_REGEX_H 1
+#ifndef GDBSUPPORT_GDB_REGEX_H
+#define GDBSUPPORT_GDB_REGEX_H
 
 # include "xregex.h"
 
@@ -54,4 +54,4 @@ class compiled_regex
   regex_t m_pattern;
 };
 
-#endif /* not GDB_REGEX_H */
+#endif /* GDBSUPPORT_GDB_REGEX_H */
diff --git a/gdbsupport/gdb_select.h b/gdbsupport/gdb_select.h
index 9f7350a904a..b229a25478c 100644
--- a/gdbsupport/gdb_select.h
+++ b/gdbsupport/gdb_select.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(GDB_SELECT_H)
-#define GDB_SELECT_H
+#ifndef GDBSUPPORT_GDB_SELECT_H
+#define GDBSUPPORT_GDB_SELECT_H
 
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
@@ -48,4 +48,4 @@ extern int interruptible_select (int n,
 				 fd_set *exceptfds,
 				 struct timeval *timeout);
 
-#endif /* !defined(GDB_SELECT_H) */
+#endif /* GDBSUPPORT_GDB_SELECT_H */
diff --git a/gdbsupport/gdb_setjmp.h b/gdbsupport/gdb_setjmp.h
index e994226cbea..2482990671d 100644
--- a/gdbsupport/gdb_setjmp.h
+++ b/gdbsupport/gdb_setjmp.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SETJMP_H
-#define COMMON_GDB_SETJMP_H
+#ifndef GDBSUPPORT_GDB_SETJMP_H
+#define GDBSUPPORT_GDB_SETJMP_H
 
 #include <setjmp.h>
 
@@ -33,4 +33,4 @@
 #define SIGLONGJMP(buf,val)	longjmp((buf), (val))
 #endif
 
-#endif /* COMMON_GDB_SETJMP_H */
+#endif /* GDBSUPPORT_GDB_SETJMP_H */
diff --git a/gdbsupport/gdb_signals.h b/gdbsupport/gdb_signals.h
index 7a71f0d8f99..2f9237aea46 100644
--- a/gdbsupport/gdb_signals.h
+++ b/gdbsupport/gdb_signals.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SIGNALS_H
-#define COMMON_GDB_SIGNALS_H
+#ifndef GDBSUPPORT_GDB_SIGNALS_H
+#define GDBSUPPORT_GDB_SIGNALS_H
 
 #include "gdb/signals.h"
 
@@ -55,4 +55,4 @@ extern const char *gdb_signal_to_name (enum gdb_signal);
 /* Given a name (SIGHUP, etc.), return its signal.  */
 enum gdb_signal gdb_signal_from_name (const char *);
 
-#endif /* COMMON_GDB_SIGNALS_H */
+#endif /* GDBSUPPORT_GDB_SIGNALS_H */
diff --git a/gdbsupport/gdb_splay_tree.h b/gdbsupport/gdb_splay_tree.h
index 873ad8e27f3..05be2f1dc4e 100644
--- a/gdbsupport/gdb_splay_tree.h
+++ b/gdbsupport/gdb_splay_tree.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SPLAY_TREE_H
-#define COMMON_GDB_SPLAY_TREE_H
+#ifndef GDBSUPPORT_GDB_SPLAY_TREE_H
+#define GDBSUPPORT_GDB_SPLAY_TREE_H
 
 #include "splay-tree.h"
 
@@ -39,4 +39,4 @@ struct splay_tree_deleter
 typedef std::unique_ptr<splay_tree_s, gdb::splay_tree_deleter>
     gdb_splay_tree_up;
 
-#endif /* COMMON_GDB_SPLAY_TREE_H */
+#endif /* GDBSUPPORT_GDB_SPLAY_TREE_H */
diff --git a/gdbsupport/gdb_sys_time.h b/gdbsupport/gdb_sys_time.h
index 63c93445121..ca93fc8d293 100644
--- a/gdbsupport/gdb_sys_time.h
+++ b/gdbsupport/gdb_sys_time.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SYS_TIME_H
-#define COMMON_GDB_SYS_TIME_H
+#ifndef GDBSUPPORT_GDB_SYS_TIME_H
+#define GDBSUPPORT_GDB_SYS_TIME_H
 
 #include <sys/time.h>
 
@@ -35,4 +35,4 @@
 # undef gettimeofday
 #endif
 
-#endif /* COMMON_GDB_SYS_TIME_H */
+#endif /* GDBSUPPORT_GDB_SYS_TIME_H */
diff --git a/gdbsupport/gdb_tilde_expand.h b/gdbsupport/gdb_tilde_expand.h
index fbd410dd133..12ae9cc73a7 100644
--- a/gdbsupport/gdb_tilde_expand.h
+++ b/gdbsupport/gdb_tilde_expand.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_TILDE_EXPAND_H
-#define COMMON_GDB_TILDE_EXPAND_H
+#ifndef GDBSUPPORT_GDB_TILDE_EXPAND_H
+#define GDBSUPPORT_GDB_TILDE_EXPAND_H
 
 /* Perform tilde expansion on DIR, and return the full path.  */
 extern std::string gdb_tilde_expand (const char *dir);
 
-#endif /* COMMON_GDB_TILDE_EXPAND_H */
+#endif /* GDBSUPPORT_GDB_TILDE_EXPAND_H */
diff --git a/gdbsupport/gdb_unique_ptr.h b/gdbsupport/gdb_unique_ptr.h
index 19b1581dab5..a40e1b133da 100644
--- a/gdbsupport/gdb_unique_ptr.h
+++ b/gdbsupport/gdb_unique_ptr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_UNIQUE_PTR_H
-#define COMMON_GDB_UNIQUE_PTR_H
+#ifndef GDBSUPPORT_GDB_UNIQUE_PTR_H
+#define GDBSUPPORT_GDB_UNIQUE_PTR_H
 
 #include <memory>
 #include <string>
@@ -93,4 +93,4 @@ operator+ (const std::string &lhs, const gdb::unique_xmalloc_ptr<char> &rhs)
   return lhs + rhs.get ();
 }
 
-#endif /* COMMON_GDB_UNIQUE_PTR_H */
+#endif /* GDBSUPPORT_GDB_UNIQUE_PTR_H */
diff --git a/gdbsupport/gdb_unlinker.h b/gdbsupport/gdb_unlinker.h
index 2da65fe45e8..2b9044290fe 100644
--- a/gdbsupport/gdb_unlinker.h
+++ b/gdbsupport/gdb_unlinker.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_UNLINKER_H
-#define COMMON_GDB_UNLINKER_H
+#ifndef GDBSUPPORT_GDB_UNLINKER_H
+#define GDBSUPPORT_GDB_UNLINKER_H
 
 namespace gdb
 {
@@ -57,4 +57,4 @@ class unlinker
 
 }
 
-#endif /* COMMON_GDB_UNLINKER_H */
+#endif /* GDBSUPPORT_GDB_UNLINKER_H */
diff --git a/gdbsupport/gdb_vecs.h b/gdbsupport/gdb_vecs.h
index 47083cead38..22c165c8a55 100644
--- a/gdbsupport/gdb_vecs.h
+++ b/gdbsupport/gdb_vecs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_VECS_H
-#define COMMON_GDB_VECS_H
+#ifndef GDBSUPPORT_GDB_VECS_H
+#define GDBSUPPORT_GDB_VECS_H
 
 /* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
 
@@ -85,4 +85,4 @@ ordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
   return removed;
 }
 
-#endif /* COMMON_GDB_VECS_H */
+#endif /* GDBSUPPORT_GDB_VECS_H */
diff --git a/gdbsupport/gdb_wait.h b/gdbsupport/gdb_wait.h
index c6348dbcb1c..590dcea6a12 100644
--- a/gdbsupport/gdb_wait.h
+++ b/gdbsupport/gdb_wait.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_WAIT_H
-#define COMMON_GDB_WAIT_H
+#ifndef GDBSUPPORT_GDB_WAIT_H
+#define GDBSUPPORT_GDB_WAIT_H
 
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
@@ -128,4 +128,4 @@ extern int windows_status_to_termsig (unsigned long);
 #define __WCLONE	0x80000000 /* Wait for cloned process.  */
 #endif
 
-#endif /* COMMON_GDB_WAIT_H */
+#endif /* GDBSUPPORT_GDB_WAIT_H */
diff --git a/gdbsupport/hash_enum.h b/gdbsupport/hash_enum.h
index 5ef0e15c9ff..5771686dc1d 100644
--- a/gdbsupport/hash_enum.h
+++ b/gdbsupport/hash_enum.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_HASH_ENUM_H
-#define COMMON_HASH_ENUM_H
+#ifndef GDBSUPPORT_HASH_ENUM_H
+#define GDBSUPPORT_HASH_ENUM_H
 
 /* A hasher for enums, which was missing in C++11:
     http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148
@@ -42,4 +42,4 @@ struct hash_enum
 
 } /* namespace gdb */
 
-#endif /* COMMON_HASH_ENUM_H */
+#endif /* GDBSUPPORT_HASH_ENUM_H */
diff --git a/gdbsupport/host-defs.h b/gdbsupport/host-defs.h
index 6e7a08524f9..5298089ba15 100644
--- a/gdbsupport/host-defs.h
+++ b/gdbsupport/host-defs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_HOST_DEFS_H
-#define COMMON_HOST_DEFS_H
+#ifndef GDBSUPPORT_HOST_DEFS_H
+#define GDBSUPPORT_HOST_DEFS_H
 
 #include <limits.h>
 
@@ -58,4 +58,4 @@
 #define SLASH_STRING "/"
 #endif
 
-#endif /* COMMON_HOST_DEFS_H */
+#endif /* GDBSUPPORT_HOST_DEFS_H */
diff --git a/gdbsupport/job-control.h b/gdbsupport/job-control.h
index 977276d95ce..2b99d69d2bb 100644
--- a/gdbsupport/job-control.h
+++ b/gdbsupport/job-control.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_JOB_CONTROL_H
-#define COMMON_JOB_CONTROL_H
+#ifndef GDBSUPPORT_JOB_CONTROL_H
+#define GDBSUPPORT_JOB_CONTROL_H
 
 /* Do we have job control?  Can be assumed to always be the same
    within a given run of GDB.  Use in gdb/inflow.c and
@@ -35,4 +35,4 @@ extern int gdb_setpgid ();
    JOB_CONTROL.  */
 extern void have_job_control ();
 
-#endif /* COMMON_JOB_CONTROL_H */
+#endif /* GDBSUPPORT_JOB_CONTROL_H */
diff --git a/gdbsupport/netstuff.h b/gdbsupport/netstuff.h
index f0df5fe7671..ae8f9bbd9da 100644
--- a/gdbsupport/netstuff.h
+++ b/gdbsupport/netstuff.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_NETSTUFF_H
-#define COMMON_NETSTUFF_H
+#ifndef GDBSUPPORT_NETSTUFF_H
+#define GDBSUPPORT_NETSTUFF_H
 
 #include <string>
 
@@ -73,4 +73,4 @@ extern parsed_connection_spec
 extern parsed_connection_spec parse_connection_spec (const char *spec,
 						     struct addrinfo *hint);
 
-#endif /* COMMON_NETSTUFF_H */
+#endif /* GDBSUPPORT_NETSTUFF_H */
diff --git a/gdbsupport/next-iterator.h b/gdbsupport/next-iterator.h
index 772083482ee..6bacb58752a 100644
--- a/gdbsupport/next-iterator.h
+++ b/gdbsupport/next-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_NEXT_ITERATOR_H
-#define COMMON_NEXT_ITERATOR_H
+#ifndef GDBSUPPORT_NEXT_ITERATOR_H
+#define GDBSUPPORT_NEXT_ITERATOR_H
 
 #include "gdbsupport/iterator-range.h"
 
@@ -77,4 +77,4 @@ struct next_iterator
 template <typename T>
 using next_range = iterator_range<next_iterator<T>>;
 
-#endif /* COMMON_NEXT_ITERATOR_H */
+#endif /* GDBSUPPORT_NEXT_ITERATOR_H */
diff --git a/gdbsupport/observable.h b/gdbsupport/observable.h
index 41e0ba385c9..b386bbcee29 100644
--- a/gdbsupport/observable.h
+++ b/gdbsupport/observable.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_OBSERVABLE_H
-#define COMMON_OBSERVABLE_H
+#ifndef GDBSUPPORT_OBSERVABLE_H
+#define GDBSUPPORT_OBSERVABLE_H
 
 #include <algorithm>
 #include <functional>
@@ -248,4 +248,4 @@ class observable
 
 } /* namespace gdb */
 
-#endif /* COMMON_OBSERVABLE_H */
+#endif /* GDBSUPPORT_OBSERVABLE_H */
diff --git a/gdbsupport/offset-type.h b/gdbsupport/offset-type.h
index 256703cab4d..181e224253e 100644
--- a/gdbsupport/offset-type.h
+++ b/gdbsupport/offset-type.h
@@ -45,8 +45,8 @@
 
    However, unlike pointers, you can't deference offset types.  */
 
-#ifndef COMMON_OFFSET_TYPE_H
-#define COMMON_OFFSET_TYPE_H
+#ifndef GDBSUPPORT_OFFSET_TYPE_H
+#define GDBSUPPORT_OFFSET_TYPE_H
 
 /* Declare TYPE as being an offset type.  This declares the type and
    enables the operators defined below.  */
@@ -130,4 +130,4 @@ operator- (E lhs, E rhs)
   return static_cast<underlying> (lhs) - static_cast<underlying> (rhs);
 }
 
-#endif /* COMMON_OFFSET_TYPE_H */
+#endif /* GDBSUPPORT_OFFSET_TYPE_H */
diff --git a/gdbsupport/packed.h b/gdbsupport/packed.h
index 5c817d4c9cc..37f02d26373 100644
--- a/gdbsupport/packed.h
+++ b/gdbsupport/packed.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PACKED_H
-#define PACKED_H
+#ifndef GDBSUPPORT_PACKED_H
+#define GDBSUPPORT_PACKED_H
 
 #include "traits.h"
 #include <atomic>
@@ -163,4 +163,4 @@ PACKED_ATOMIC_OP (<=)
 
 #undef PACKED_ATOMIC_OP
 
-#endif
+#endif /* GDBSUPPORT_PACKED_H */
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
index 170a2c5e724..fc516505017 100644
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PATHSTUFF_H
-#define COMMON_PATHSTUFF_H
+#ifndef GDBSUPPORT_PATHSTUFF_H
+#define GDBSUPPORT_PATHSTUFF_H
 
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/array-view.h"
@@ -162,4 +162,4 @@ extern gdb::char_vector make_temp_filename (const std::string &f);
 /* String containing the current directory (what getwd would return).  */
 extern char *current_directory;
 
-#endif /* COMMON_PATHSTUFF_H */
+#endif /* GDBSUPPORT_PATHSTUFF_H */
diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h
index 7b4f8e8a178..66f0fcf53b8 100644
--- a/gdbsupport/poison.h
+++ b/gdbsupport/poison.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_POISON_H
-#define COMMON_POISON_H
+#ifndef GDBSUPPORT_POISON_H
+#define GDBSUPPORT_POISON_H
 
 #include "traits.h"
 #include "obstack.h"
@@ -237,4 +237,4 @@ non-POD data type.");
 #undef XOBNEWVEC
 #define XOBNEWVEC(O, T, N) xobnewvec<T> (O, N)
 
-#endif /* COMMON_POISON_H */
+#endif /* GDBSUPPORT_POISON_H */
diff --git a/gdbsupport/preprocessor.h b/gdbsupport/preprocessor.h
index 96b3b94bf35..23177d5d82e 100644
--- a/gdbsupport/preprocessor.h
+++ b/gdbsupport/preprocessor.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PREPROCESSOR_H
-#define COMMON_PREPROCESSOR_H
+#ifndef GDBSUPPORT_PREPROCESSOR_H
+#define GDBSUPPORT_PREPROCESSOR_H
 
 /* Generally useful preprocessor bits.  */
 
@@ -32,4 +32,4 @@
    includes commas to another macro.  */
 #define ESC_PARENS(...) __VA_ARGS__
 
-#endif /* COMMON_PREPROCESSOR_H */
+#endif /* GDBSUPPORT_PREPROCESSOR_H */
diff --git a/gdbsupport/print-utils.h b/gdbsupport/print-utils.h
index 510cc63bc89..9b915acb8e3 100644
--- a/gdbsupport/print-utils.h
+++ b/gdbsupport/print-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PRINT_UTILS_H
-#define COMMON_PRINT_UTILS_H
+#ifndef GDBSUPPORT_PRINT_UTILS_H
+#define GDBSUPPORT_PRINT_UTILS_H
 
 /* How many characters (including the terminating null byte) fit in a
    cell.  */
@@ -82,4 +82,4 @@ extern const char *host_address_to_string_1 (const void *addr);
 
 extern char *get_print_cell (void);
 
-#endif /* COMMON_PRINT_UTILS_H */
+#endif /* GDBSUPPORT_PRINT_UTILS_H */
diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h
index fef9749ee80..f502efe7484 100644
--- a/gdbsupport/ptid.h
+++ b/gdbsupport/ptid.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PTID_H
-#define COMMON_PTID_H
+#ifndef GDBSUPPORT_PTID_H
+#define GDBSUPPORT_PTID_H
 
 /* The ptid struct is a collection of the various "ids" necessary for
    identifying the inferior process/thread being debugged.  This
@@ -182,4 +182,4 @@ extern const ptid_t null_ptid;
 
 extern const ptid_t minus_one_ptid;
 
-#endif /* COMMON_PTID_H */
+#endif /* GDBSUPPORT_PTID_H */
diff --git a/gdbsupport/refcounted-object.h b/gdbsupport/refcounted-object.h
index 9cdf0f10729..42bf71a0309 100644
--- a/gdbsupport/refcounted-object.h
+++ b/gdbsupport/refcounted-object.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_REFCOUNTED_OBJECT_H
-#define COMMON_REFCOUNTED_OBJECT_H
+#ifndef GDBSUPPORT_REFCOUNTED_OBJECT_H
+#define GDBSUPPORT_REFCOUNTED_OBJECT_H
 
 /* Base class of intrusively reference-countable objects.
    Incrementing and decrementing the reference count is an external
@@ -84,4 +84,4 @@ struct refcounted_object_delete_ref_policy
   }
 };
 
-#endif /* COMMON_REFCOUNTED_OBJECT_H */
+#endif /* GDBSUPPORT_REFCOUNTED_OBJECT_H */
diff --git a/gdbsupport/rsp-low.h b/gdbsupport/rsp-low.h
index 801df0ebc0c..e91c79e822f 100644
--- a/gdbsupport/rsp-low.h
+++ b/gdbsupport/rsp-low.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_RSP_LOW_H
-#define COMMON_RSP_LOW_H
+#ifndef GDBSUPPORT_RSP_LOW_H
+#define GDBSUPPORT_RSP_LOW_H
 
 /* Convert number NIB to a hex digit.  */
 
@@ -81,4 +81,4 @@ extern int remote_escape_output (const gdb_byte *buffer, int len_units,
 extern int remote_unescape_input (const gdb_byte *buffer, int len,
 				  gdb_byte *out_buf, int out_maxlen);
 
-#endif /* COMMON_RSP_LOW_H */
+#endif /* GDBSUPPORT_RSP_LOW_H */
diff --git a/gdbsupport/run-time-clock.h b/gdbsupport/run-time-clock.h
index 8176151add9..f4328543945 100644
--- a/gdbsupport/run-time-clock.h
+++ b/gdbsupport/run-time-clock.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_RUN_TIME_CLOCK_H
-#define COMMON_RUN_TIME_CLOCK_H
+#ifndef GDBSUPPORT_RUN_TIME_CLOCK_H
+#define GDBSUPPORT_RUN_TIME_CLOCK_H
 
 #include <chrono>
 
@@ -72,4 +72,4 @@ struct run_time_clock
 		   system_cpu_time_clock::time_point &system) noexcept;
 };
 
-#endif /* COMMON_RUN_TIME_CLOCK_H */
+#endif /* GDBSUPPORT_RUN_TIME_CLOCK_H */
diff --git a/gdbsupport/safe-iterator.h b/gdbsupport/safe-iterator.h
index f69f3896758..f31f92f6c24 100644
--- a/gdbsupport/safe-iterator.h
+++ b/gdbsupport/safe-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SAFE_ITERATOR_H
-#define COMMON_SAFE_ITERATOR_H
+#ifndef GDBSUPPORT_SAFE_ITERATOR_H
+#define GDBSUPPORT_SAFE_ITERATOR_H
 
 #include <type_traits>
 
@@ -136,4 +136,4 @@ class basic_safe_range
   Range m_range;
 };
 
-#endif /* COMMON_SAFE_ITERATOR_H */
+#endif /* GDBSUPPORT_SAFE_ITERATOR_H */
diff --git a/gdbsupport/scope-exit.h b/gdbsupport/scope-exit.h
index 86b2969f817..c3d27d7c77a 100644
--- a/gdbsupport/scope-exit.h
+++ b/gdbsupport/scope-exit.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPE_EXIT_H
-#define COMMON_SCOPE_EXIT_H
+#ifndef GDBSUPPORT_SCOPE_EXIT_H
+#define GDBSUPPORT_SCOPE_EXIT_H
 
 #include <functional>
 #include <type_traits>
@@ -165,4 +165,4 @@ operator+ (scope_exit_lhs, EF &&rhs)
 #define SCOPE_EXIT \
   auto CONCAT(scope_exit_, __LINE__) = ::detail::scope_exit_lhs () + [&] ()
 
-#endif /* COMMON_SCOPE_EXIT_H */
+#endif /* GDBSUPPORT_SCOPE_EXIT_H */
diff --git a/gdbsupport/scoped_fd.h b/gdbsupport/scoped_fd.h
index aa214b2c1c1..240685a927b 100644
--- a/gdbsupport/scoped_fd.h
+++ b/gdbsupport/scoped_fd.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_FD_H
-#define COMMON_SCOPED_FD_H
+#ifndef GDBSUPPORT_SCOPED_FD_H
+#define GDBSUPPORT_SCOPED_FD_H
 
 #include <unistd.h>
 #include "gdb_file.h"
@@ -84,4 +84,4 @@ class scoped_fd
   int m_fd;
 };
 
-#endif /* COMMON_SCOPED_FD_H */
+#endif /* GDBSUPPORT_SCOPED_FD_H */
diff --git a/gdbsupport/scoped_ignore_signal.h b/gdbsupport/scoped_ignore_signal.h
index 74fc69057a8..2fecd58466d 100644
--- a/gdbsupport/scoped_ignore_signal.h
+++ b/gdbsupport/scoped_ignore_signal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_IGNORE_SIGNAL_H
-#define SCOPED_IGNORE_SIGNAL_H
+#ifndef GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H
+#define GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H
 
 #include <signal.h>
 
@@ -118,4 +118,4 @@ using scoped_ignore_sigpipe = scoped_ignore_signal<SIGPIPE, true>;
 using scoped_ignore_sigpipe = scoped_ignore_signal_nop;
 #endif
 
-#endif /* SCOPED_IGNORE_SIGNAL_H */
+#endif /* GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H */
diff --git a/gdbsupport/scoped_ignore_sigttou.h b/gdbsupport/scoped_ignore_sigttou.h
index de2e40a6492..bb4e86d5b21 100644
--- a/gdbsupport/scoped_ignore_sigttou.h
+++ b/gdbsupport/scoped_ignore_sigttou.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_IGNORE_SIGTTOU_H
-#define SCOPED_IGNORE_SIGTTOU_H
+#ifndef GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H
+#define GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H
 
 #include "gdbsupport/scoped_ignore_signal.h"
 #include "gdbsupport/job-control.h"
@@ -84,4 +84,4 @@ using scoped_ignore_sigttou = scoped_ignore_signal_nop;
 
 #endif
 
-#endif /* SCOPED_IGNORE_SIGTTOU_H */
+#endif /* GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H */
diff --git a/gdbsupport/scoped_mmap.h b/gdbsupport/scoped_mmap.h
index 8383b8933b5..ea2f4fd3af5 100644
--- a/gdbsupport/scoped_mmap.h
+++ b/gdbsupport/scoped_mmap.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_MMAP_H
-#define COMMON_SCOPED_MMAP_H
+#ifndef GDBSUPPORT_SCOPED_MMAP_H
+#define GDBSUPPORT_SCOPED_MMAP_H
 
 #ifdef HAVE_SYS_MMAN_H
 
@@ -88,4 +88,4 @@ scoped_mmap mmap_file (const char *filename);
 
 #endif /* HAVE_SYS_MMAN_H */
 
-#endif /* COMMON_SCOPED_MMAP_H */
+#endif /* GDBSUPPORT_SCOPED_MMAP_H */
diff --git a/gdbsupport/scoped_restore.h b/gdbsupport/scoped_restore.h
index 96fe5256f80..5833b928fe3 100644
--- a/gdbsupport/scoped_restore.h
+++ b/gdbsupport/scoped_restore.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_RESTORE_H
-#define COMMON_SCOPED_RESTORE_H
+#ifndef GDBSUPPORT_SCOPED_RESTORE_H
+#define GDBSUPPORT_SCOPED_RESTORE_H
 
 /* Base class for scoped_restore_tmpl.  */
 class scoped_restore_base
@@ -115,4 +115,4 @@ scoped_restore_tmpl<T> make_scoped_restore (T *var, T2 value)
   return scoped_restore_tmpl<T> (var, value);
 }
 
-#endif /* COMMON_SCOPED_RESTORE_H */
+#endif /* GDBSUPPORT_SCOPED_RESTORE_H */
diff --git a/gdbsupport/search.h b/gdbsupport/search.h
index 42a9fd23083..f8c003bf6df 100644
--- a/gdbsupport/search.h
+++ b/gdbsupport/search.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SEARCH_H
-#define COMMON_SEARCH_H
+#ifndef GDBSUPPORT_SEARCH_H
+#define GDBSUPPORT_SEARCH_H
 
 #include "gdbsupport/function-view.h"
 
@@ -39,4 +39,4 @@ extern int simple_search_memory
    ULONGEST pattern_len,
    CORE_ADDR *found_addrp);
 
-#endif /* COMMON_SEARCH_H */
+#endif /* GDBSUPPORT_SEARCH_H */
diff --git a/gdbsupport/selftest.h b/gdbsupport/selftest.h
index 41d1210a5a5..cbbdd01093d 100644
--- a/gdbsupport/selftest.h
+++ b/gdbsupport/selftest.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SELFTEST_H
-#define COMMON_SELFTEST_H
+#ifndef GDBSUPPORT_SELFTEST_H
+#define GDBSUPPORT_SELFTEST_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/function-view.h"
@@ -93,4 +93,4 @@ extern void reset ();
       error (_("self-test failed at %s:%d"), __FILE__, __LINE__);	\
   } while (0)
 
-#endif /* COMMON_SELFTEST_H */
+#endif /* GDBSUPPORT_SELFTEST_H */
diff --git a/gdbsupport/signals-state-save-restore.h b/gdbsupport/signals-state-save-restore.h
index 132aaa8c522..e01ac36fe99 100644
--- a/gdbsupport/signals-state-save-restore.h
+++ b/gdbsupport/signals-state-save-restore.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SIGNALS_STATE_SAVE_RESTORE_H
-#define COMMON_SIGNALS_STATE_SAVE_RESTORE_H
+#ifndef GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H
+#define GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H
 
 /* Save/restore the signal actions of all signals, and the signal
    mask.
@@ -37,4 +37,4 @@ extern void save_original_signals_state (bool quiet);
 
 extern void restore_original_signals_state (void);
 
-#endif /* COMMON_SIGNALS_STATE_SAVE_RESTORE_H */
+#endif /* GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H */
diff --git a/gdbsupport/symbol.h b/gdbsupport/symbol.h
index 3e1dc9d29d3..de439c07179 100644
--- a/gdbsupport/symbol.h
+++ b/gdbsupport/symbol.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SYMBOL_H
-#define COMMON_SYMBOL_H
+#ifndef GDBSUPPORT_SYMBOL_H
+#define GDBSUPPORT_SYMBOL_H
 
 struct objfile;
 
@@ -34,4 +34,4 @@ struct objfile;
 extern int find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
 					struct objfile *objfile);
 
-#endif /* COMMON_SYMBOL_H */
+#endif /* GDBSUPPORT_SYMBOL_H */
diff --git a/gdbsupport/tdesc.h b/gdbsupport/tdesc.h
index fa9431b5b65..dc2d45278d1 100644
--- a/gdbsupport/tdesc.h
+++ b/gdbsupport/tdesc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_TDESC_H
-#define COMMON_TDESC_H
+#ifndef GDBSUPPORT_TDESC_H
+#define GDBSUPPORT_TDESC_H
 
 struct tdesc_feature;
 struct tdesc_type;
@@ -462,4 +462,4 @@ class print_xml_feature : public tdesc_element_visitor
   int m_depth;
 };
 
-#endif /* COMMON_TDESC_H */
+#endif /* GDBSUPPORT_TDESC_H */
diff --git a/gdbsupport/traits.h b/gdbsupport/traits.h
index 92fe59f34af..600f89ede65 100644
--- a/gdbsupport/traits.h
+++ b/gdbsupport/traits.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_TRAITS_H
-#define COMMON_TRAITS_H
+#ifndef GDBSUPPORT_TRAITS_H
+#define GDBSUPPORT_TRAITS_H
 
 #include <type_traits>
 
@@ -143,4 +143,4 @@ template<typename Condition>
 using Requires = typename std::enable_if<Condition::value, void>::type;
 }
 
-#endif /* COMMON_TRAITS_H */
+#endif /* GDBSUPPORT_TRAITS_H */
diff --git a/gdbsupport/underlying.h b/gdbsupport/underlying.h
index d9c5696a4cd..a3e7e3fca85 100644
--- a/gdbsupport/underlying.h
+++ b/gdbsupport/underlying.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_UNDERLYING_H
-#define COMMON_UNDERLYING_H
+#ifndef GDBSUPPORT_UNDERLYING_H
+#define GDBSUPPORT_UNDERLYING_H
 
 #include <type_traits>
 
@@ -29,4 +29,4 @@ to_underlying (E val) noexcept
   return static_cast<typename std::underlying_type<E>::type> (val);
 }
 
-#endif
+#endif /* GDBSUPPORT_UNDERLYING_H */
diff --git a/gdbsupport/valid-expr.h b/gdbsupport/valid-expr.h
index 6d2b481c6e1..ef51958dc09 100644
--- a/gdbsupport/valid-expr.h
+++ b/gdbsupport/valid-expr.h
@@ -23,8 +23,8 @@
    right type.  This is mainly used to verify that some utility's API
    is really as safe as intended.  */
 
-#ifndef COMMON_VALID_EXPR_H
-#define COMMON_VALID_EXPR_H
+#ifndef GDBSUPPORT_VALID_EXPR_H
+#define GDBSUPPORT_VALID_EXPR_H
 
 #include "gdbsupport/preprocessor.h"
 #include "gdbsupport/traits.h"
@@ -108,4 +108,4 @@
 			ESC_PARENS (T1, T2, T3, T4, T5, T6),		\
 			VALID, EXPR_TYPE, EXPR)
 
-#endif /* COMMON_VALID_EXPR_H */
+#endif /* GDBSUPPORT_VALID_EXPR_H */
diff --git a/gdbsupport/version.h b/gdbsupport/version.h
index 7c60a963919..052d613d47e 100644
--- a/gdbsupport/version.h
+++ b/gdbsupport/version.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_VERSION_H
-#define COMMON_VERSION_H
+#ifndef GDBSUPPORT_VERSION_H
+#define GDBSUPPORT_VERSION_H
 
 /* Version number of GDB, as a string.  */
 extern const char version[];
@@ -28,4 +28,4 @@ extern const char host_name[];
 /* Canonical target name as a string.  */
 extern const char target_name[];
 
-#endif /* COMMON_VERSION_H */
+#endif /* GDBSUPPORT_VERSION_H */
diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h
index 89c1143fbe1..ed8aeccece2 100644
--- a/gdbsupport/x86-xstate.h
+++ b/gdbsupport/x86-xstate.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_X86_XSTATE_H
-#define COMMON_X86_XSTATE_H
+#ifndef GDBSUPPORT_X86_XSTATE_H
+#define GDBSUPPORT_X86_XSTATE_H
 
 /* The extended state feature IDs in the state component bitmap.  */
 #define X86_XSTATE_X87_ID	0
@@ -120,4 +120,4 @@ constexpr bool operator!= (const x86_xsave_layout &lhs,
 
 #define I387_MXCSR_INIT_VAL 0x1f80
 
-#endif /* COMMON_X86_XSTATE_H */
+#endif /* GDBSUPPORT_X86_XSTATE_H */
diff --git a/gdbsupport/xml-utils.h b/gdbsupport/xml-utils.h
index c1f21b9b8ec..d68f4c98018 100644
--- a/gdbsupport/xml-utils.h
+++ b/gdbsupport/xml-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_XML_UTILS_H
-#define COMMON_XML_UTILS_H
+#ifndef GDBSUPPORT_XML_UTILS_H
+#define GDBSUPPORT_XML_UTILS_H
 
 /* Return a string with special characters from TEXT replaced by entity
    references.  */
@@ -40,4 +40,4 @@ extern void xml_escape_text_append (std::string &result, const char *text);
 void string_xml_appendf (std::string &buffer, const char *format, ...)
   ATTRIBUTE_PRINTF (2, 3);
 
-#endif /* COMMON_XML_UTILS_H */
+#endif /* GDBSUPPORT_XML_UTILS_H */

-- 
2.43.0


^ permalink raw reply	[relevance 1%]

* [PATCH] Fix AIX thread exit events not being reported and UI to show kernel thread ID.
@ 2024-04-18 13:26  8% Aditya Kamath1
  0 siblings, 0 replies; 200+ results
From: Aditya Kamath1 @ 2024-04-18 13:26 UTC (permalink / raw)
  To: Ulrich Weigand, Aditya Kamath1 via Gdb-patches; +Cc: Sangamesh Mallayya


[-- Attachment #1.1: Type: text/plain, Size: 6434 bytes --]

Respected community members,

Hi,

Thank you for the comments in the [RFC] thread<https://sourceware.org/pipermail/gdb-patches/2024-April/208104.html>.

Please find attached the patch. (See: 0001-Fix-AIX-thread-exit-events-not-being-reported-and-UI.patch)


In AIX, we were not reporting a thread exit event due to which we had a bad UI.

Hello World
Hello World
Hello World
[New Thread 258]
[New Thread 515]
[New Thread 772]
Thread 1 received signal SIGINT, Interrupt.
0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
(gdb) info threads
  Id   Target Id                                          Frame
* 1    Thread 1 (tid 26607979) (tid 26607979, running)    0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
  2    Thread 258 (tid 30998799) (tid 30998799, finished) aix-thread: ptrace (52, 30998799) returned -1 (errno = 3 The process does not exist.)

More on this can be read here<https://sourceware.org/pipermail/gdb-patches/2024-April/208104.html>. [https://sourceware.org/pipermail/gdb-patches/2024-April/208104.html]

So, consider program 1 pasted below this email.

This program creates 6 threads in total.

In AIX once a thread reaches terminated state the information can be obtained using pthdb_pthread_state()

In this patch if the state is terminated then we do not want pbuf to keep the thread in its list so that we can delete the same from GDB’s list i.e. gbuf in sync_threadlists ().

But we faced one problem.


>Linux raises a ptrace() stop when a new thread is created.  When using >libthread_db

>I believe you should be placing a breakpoint in your thread library so that you ?>can

>capture new threads in userspace before they start executing (e.g. in the >internal

>routine in your thread library that eventually calls the thread's start routine).

As John mentioned in the RFC thread we need to set a breakpoint in the thread library or similar to capture the new threads before it begins execution.

This is currently not happening in AIX. Though in the pd_activate () we are successful in pthdb_session_init () before the threads begin execution, in sync_threadlists (), pthdb_pthread () and pthdb_pthread_ptid () return invalid thread ID’s for thread except for the main thread.

This results in break of the for loop and we not capturing the remaining 6 new threads, since pbuf now has only one vector that is the main thread.

So the next time when we come to sync_threadlists () we do have all the threads in pbuf.
But by then these 6 threads completed their execution and are in PST_TERM state i.e. terminated state.

In this stage we did not inform users that the threads are born. At this stage we also have to show the threads exited or terminated.

In order to fix this race I used a variable threads_reported to keep track of how many threads have reported i.e we displayed new thread information. So I want to make use of this to show new threads even though the six threads are in terminated state at this stage.

The condition
if (state == PST_TERM && data->threads_reported > 0)
checks if we are at PST_TERM and if we reported the new threads. If we did not we add the new threads in the pbuf list to allow GDB to display new threads.

For each new thread we increase the threads_reported variable and decrement it for every delete.

By this way we make sure that the next time post the new thread event [Adding the threads to GDB list] display, when we are in sync_threadlists (), the condition
if (state == PST_TERM && data->threads_reported > 0)
holds true and we do not have those terminated threads in the pbuf. This will make sure the terminated threads are removed.

Sample output of GDB of program 1 is pasted below.

Reading symbols from //gdb_tests/continue-pending-status_exit_test...
(gdb) r
Starting program: /gdb_tests/continue-pending-status_exit_test
More threads
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
[New Thread 258 (tid 32178533)]
[New Thread 515 (tid 30343651)]
[New Thread 772 (tid 33554909)]
[New Thread 1029 (tid 24969489)]
[New Thread 1286 (tid 18153945)]
[New Thread 1543 (tid 30736739)]
[Thread 258 (tid 32178533) exited]
[Thread 515 (tid 30343651) exited]
[Thread 772 (tid 33554909) exited]
[Thread 1029 (tid 24969489) exited]
[Thread 1286 (tid 18153945) exited]
[Thread 1543 (tid 30736739) exited]

Thread 1 received signal SIGINT, Interrupt.
0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) inof threads
Undefined command: "inof".  Try "help".
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 31326579) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) q
A debugging session is active.

        Inferior 1 [process 9437570] will be killed.

Quit anyway? (y or n) y


All these workarounds are because we have problems in catching the new thread event before the threads start executing. If we have that in place, perhaps we can optimise this patch further.

Kindly let me know your feedback for this patch.

Also, some minor changes in the UI are made in this patch so that thread debugging information is the same like Linux.

Have a nice day ahead.

Thanks and regards,
Aditya.

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>

pthread_barrier_t barrier;

#define NUM_THREADS 3

void *
thread_function (void *arg)
{
  /* This ensures that the breakpoint is only hit after both threads
     are created, so the test can always switch to the non-event
     thread when the breakpoint triggers.  */
//  pthread_barrier_wait (&barrier);

  printf ("Hello World \n"); /* break here */
}

int
main (void)
{
  int i;

  alarm (300);

  pthread_barrier_init (&barrier, NULL, NUM_THREADS);

  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_t thread;
      int res;

      res = pthread_create (&thread, NULL,
                            thread_function, NULL);
      assert (res == 0);
    }

  printf ("More threads \n");
  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_t thread;
      int res;

      res = pthread_create (&thread, NULL,
                thread_function, NULL);
      assert (res == 0);
    }
  while (1)
    sleep (1);

  return 0;
}



[-- Attachment #2: 0001-Fix-AIX-thread-exit-events-not-being-reported-and-UI.patch --]
[-- Type: application/octet-stream, Size: 9238 bytes --]

From f5d0db4320ddab7cc52d56bb8edf626a0fc50ad4 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Thu, 18 Apr 2024 07:46:13 -0500
Subject: [PATCH] Fix AIX thread exit events not being reported and UI to show
 kernel thread ID.

In AIX when a thread exits we were not showing that a thread exit event happened
and GDB continued to keep the terminated threads.

If we have terminated threads then the UI on info threads command will look like
(gdb) info threads
  Id   Target Id                                          Frame
* 1    Thread 1 (tid 26607979, running)    0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
  2    Thread 258 (tid 30998799, finished) aix-thread: ptrace (52, 30998799) returned -1 (errno = 3 The process does not exist.)

If we see the frame is not getting displayed correctly.

The reason for the same is that in AIX we were not managing thread states. In particular we do not know
when a thread terminates.

The reason being in sync_threadlists () the pbuf and gbuf lists remain the same though certain threads exit.

This patch is a fix to the same.

Also certain UI is changed.

On a new thread born and exit the UI in AIX will be similar to Linux with both user and kernel thread information.

[New Thread 258 (tid 32178533)]
[New Thread 515 (tid 30343651)]
[New Thread 772 (tid 33554909)]
[New Thread 1029 (tid 24969489)]
[New Thread 1286 (tid 18153945)]
[New Thread 1543 (tid 30736739)]
[Thread 258 (tid 32178533) exited]
[Thread 515 (tid 30343651) exited]
[Thread 772 (tid 33554909) exited]
[Thread 1029 (tid 24969489) exited]
[Thread 1286 (tid 18153945) exited]
[Thread 1543 (tid 30736739) exited]

and info threads will look like
(gdb) info threads
  Id   Target Id                           Frame
* 1    Thread 1 (tid 31326579) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
---
 gdb/aix-thread.c | 91 ++++++++++++++++++++++++++++++------------------
 1 file changed, 57 insertions(+), 34 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index c70bd82bc24..5ccccf02879 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -55,6 +55,7 @@
 #include <sys/reg.h>
 #include <sched.h>
 #include <sys/pthdebug.h>
+#include <vector>
 
 #if !HAVE_DECL_GETTHRDS
 extern int getthrds (pid_t, struct thrdsinfo64 *, int, tid_t *, int);
@@ -190,6 +191,9 @@ struct aix_thread_variables
   /* Whether the current architecture is 64-bit.
    Only valid when pd_able is true.  */
   int arch64;
+
+  /* Describes the number of thread born events have been reported.  */
+  int threads_reported = 0;
 };
 
 /* Key to our per-inferior data.  */
@@ -740,11 +744,9 @@ state2str (pthdb_state_t state)
 /* qsort() comparison function for sorting pd_thread structs by pthid.  */
 
 static int
-pcmp (const void *p1v, const void *p2v)
+pcmp (struct pd_thread p1v, struct pd_thread p2v)
 {
-  struct pd_thread *p1 = (struct pd_thread *) p1v;
-  struct pd_thread *p2 = (struct pd_thread *) p2v;
-  return p1->pthid < p2->pthid ? -1 : p1->pthid > p2->pthid;
+  return p1v.pthid < p2v.pthid;
 }
 
 /* ptid comparison function */
@@ -823,7 +825,6 @@ sync_threadlists (pid_t pid)
 {
   int cmd, status;
   int pcount, psize, pi, gcount, gi;
-  struct pd_thread *pbuf;
   struct thread_info **gbuf, **g, *thread;
   pthdb_pthread_t pdtid;
   pthread_t pthid;
@@ -831,12 +832,13 @@ sync_threadlists (pid_t pid)
   process_stratum_target *proc_target = current_inferior ()->process_target ();
   struct aix_thread_variables *data;
   data = get_thread_data_helper_for_pid (pid);
+  std::vector<pd_thread> pbuf;
+  struct pd_thread aix_pd_thread;
 
   /* Accumulate an array of libpthdebug threads sorted by pthread id.  */
 
   pcount = 0;
   psize = 1;
-  pbuf = XNEWVEC (struct pd_thread, psize);
 
   for (cmd = PTHDB_LIST_FIRST;; cmd = PTHDB_LIST_NEXT)
     {
@@ -848,27 +850,36 @@ sync_threadlists (pid_t pid)
       if (status != PTHDB_SUCCESS || pthid == PTHDB_INVALID_PTID)
 	continue;
 
-      if (pcount == psize)
-	{
-	  psize *= 2;
-	  pbuf = (struct pd_thread *) xrealloc (pbuf, 
-						psize * sizeof *pbuf);
-	}
-      pbuf[pcount].pdtid = pdtid;
-      pbuf[pcount].pthid = pthid;
+      aix_pd_thread.pdtid = pdtid;
+      aix_pd_thread.pthid = pthid;
+      pbuf.push_back (aix_pd_thread);
       pcount++;
     }
 
-  for (pi = 0; pi < pcount; pi++)
+  for (auto it = pbuf.begin (); it != pbuf.end ();)
     {
-      status = pthdb_pthread_tid (data->pd_session, pbuf[pi].pdtid, &tid);
+      status = pthdb_pthread_tid (data->pd_session, (*it).pdtid, &tid);
       if (status != PTHDB_SUCCESS)
 	tid = PTHDB_INVALID_TID;
-      pbuf[pi].tid = tid;
-    }
 
-  qsort (pbuf, pcount, sizeof *pbuf, pcmp);
+      (*it).tid = tid;
+      pthdb_state_t state;
+
+      status = pthdb_pthread_state (data->pd_session, (*it).pdtid, &state);
 
+      /* If the thread is terminated and has not reported its existence
+	 or new thread event, then wait for it to report.  We want users
+	 to know threads were added and then delete. So first add them to
+	 pbuf and the next time sync_threadlists is called delete them since
+	 data->threads_reported is guarenteed to be greater than 0.  */
+
+      if (state == PST_TERM && data->threads_reported > 0)
+	pbuf.erase (it);
+      else
+	++it;
+    }
+
+  std::sort (pbuf.begin (), pbuf.end (), pcmp);
   /* Accumulate an array of GDB threads sorted by pid.  */
 
   /* gcount is GDB thread count and pcount is pthreadlib thread count.  */
@@ -881,6 +892,7 @@ sync_threadlists (pid_t pid)
     *g++ = tp;
   qsort (gbuf, gcount, sizeof *gbuf, gcmp);
 
+  pcount = pbuf.size ();
   /* Apply differences between the two arrays to GDB's thread list.  */
 
   for (pi = gi = 0; pi < pcount || gi < gcount;)
@@ -889,6 +901,12 @@ sync_threadlists (pid_t pid)
 	{
 	  delete_thread (gbuf[gi]);
 	  gi++;
+	  data->threads_reported--;
+
+	  /* Since main thread is reported.  */
+
+	  if (data->threads_reported == 0)
+	    data->threads_reported = 1;
 	}
       else if (gi == gcount)
 	{
@@ -901,6 +919,7 @@ sync_threadlists (pid_t pid)
 					 private_thread_info_up (priv));
 
 	  pi++;
+	  data->threads_reported++;
 	}
       else
 	{
@@ -913,7 +932,6 @@ sync_threadlists (pid_t pid)
 	  tid = pbuf[pi].tid;
 
 	  cmp_result = ptid_cmp (pptid, gptid);
-
 	  if (cmp_result == 0)
 	    {
 	      aix_thread_info *priv = get_aix_thread_info (gbuf[gi]);
@@ -943,6 +961,10 @@ sync_threadlists (pid_t pid)
 		{
 		  delete_thread (gbuf[gi]);
 		  gi++;
+		  data->threads_reported--;
+
+		  if (data->threads_reported == 0)
+		    data->threads_reported = 1;
 		}
 	    }
 	  else
@@ -954,11 +976,11 @@ sync_threadlists (pid_t pid)
 	      priv->pdtid = pdtid;
 	      priv->tid = tid;
 	      pi++;
+	      data->threads_reported++;
 	    }
 	}
     }
 
-  xfree (pbuf);
   xfree (gbuf);
 }
 
@@ -2084,10 +2106,17 @@ aix_thread_target::thread_alive (ptid_t ptid)
 std::string
 aix_thread_target::pid_to_str (ptid_t ptid)
 {
-  if (ptid.tid () == 0)
-    return beneath ()->pid_to_str (ptid);
+  thread_info *thread_info = current_inferior ()->find_thread (ptid);
+
+  if (thread_info != NULL && thread_info->priv != NULL)
+    {
+      aix_thread_info *priv = get_aix_thread_info (thread_info);
+
+      return string_printf (_("Thread %s (tid %s)"), pulongest (ptid.tid ()),
+		pulongest (priv->tid));
+    }
 
-  return string_printf (_("Thread %s"), pulongest (ptid.tid ()));
+  return beneath ()->pid_to_str (ptid);
 }
 
 /* Return a printable representation of extra information about
@@ -2098,7 +2127,6 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
 {
   int status;
   pthdb_pthread_t pdtid;
-  pthdb_tid_t tid;
   pthdb_state_t state;
   pthdb_suspendstate_t suspendstate;
   pthdb_detachstate_t detachstate;
@@ -2115,33 +2143,28 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
   aix_thread_info *priv = get_aix_thread_info (thread);
 
   pdtid = priv->pdtid;
-  tid = priv->tid;
-
-  if (tid != PTHDB_INVALID_TID)
-    /* i18n: Like "thread-identifier %d, [state] running, suspended" */
-    buf.printf (_("tid %d"), (int)tid);
 
   status = pthdb_pthread_state (data->pd_session, pdtid, &state);
   if (status != PTHDB_SUCCESS)
     state = PST_NOTSUP;
-  buf.printf (", %s", state2str (state));
+  buf.printf ("[%s]", state2str (state));
 
   status = pthdb_pthread_suspendstate (data->pd_session, pdtid,
 				       &suspendstate);
   if (status == PTHDB_SUCCESS && suspendstate == PSS_SUSPENDED)
     /* i18n: Like "Thread-Id %d, [state] running, suspended" */
-    buf.printf (_(", suspended"));
+    buf.printf (_("[suspended]"));
 
   status = pthdb_pthread_detachstate (data->pd_session, pdtid,
 				      &detachstate);
   if (status == PTHDB_SUCCESS && detachstate == PDS_DETACHED)
     /* i18n: Like "Thread-Id %d, [state] running, detached" */
-    buf.printf (_(", detached"));
+    buf.printf (_("[detached]"));
 
   pthdb_pthread_cancelpend (data->pd_session, pdtid, &cancelpend);
   if (status == PTHDB_SUCCESS && cancelpend)
     /* i18n: Like "Thread-Id %d, [state] running, cancel pending" */
-    buf.printf (_(", cancel pending"));
+    buf.printf (_("[cancel pending]"));
 
   buf.write ("", 1);
 
-- 
2.41.0


^ permalink raw reply	[relevance 8%]

* Re: [PATCH v5 6/8] gdb: Add qIsAddressTagged packet
  @ 2024-04-18 10:37  0%   ` Luis Machado
  0 siblings, 0 replies; 200+ results
From: Luis Machado @ 2024-04-18 10:37 UTC (permalink / raw)
  To: Gustavo Romero, gdb-patches; +Cc: thiago.bauermann, eliz, tom

Hi, this is mostly OK for me, but ...

On 4/17/24 22:04, Gustavo Romero wrote:
> This commit adds a new packet, qIsAddressTagged, allowing GDB remote
> targets to use it to query the stub if a given address is tagged.
> 
> Currently, the memory tagging address check is done via a read query,
> where the contents of /proc/<PID>/smaps is read and the flags are
> inspected for memory tagging-related flags that indicate the address is
> in a memory tagged region.
> 
> This is not ideal, for example, for QEMU stub and other cases, such as
> on bare-metal, where there is no notion of an OS file like 'smaps.'
> Hence, the introduction of qIsAddressTagged packet allows checking
> if an address is tagged in an agnostic way.
> 
> The is_address_tagged target hook in remote.c attempts to use the
> qIsAddressTagged packet first for checking if an address is tagged and
> if the stub does not support such a packet (reply is empty) it falls
> back to using the current mechanism that reads the contents of
> /proc/<PID>/smaps via vFile requests.
> 
> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
> ---
>  gdb/remote.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
> 
> diff --git a/gdb/remote.c b/gdb/remote.c
> index cd271c4b493..2bb962955b5 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -337,6 +337,9 @@ enum {
>       packets and the tag violation stop replies.  */
>    PACKET_memory_tagging_feature,
>  
> +  /* Support for the qIsAddressTagged packet.  */
> +  PACKET_qIsAddressTagged,
> +
>    PACKET_MAX
>  };
>  
> @@ -15535,6 +15538,49 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address,
>    strcpy (packet.data (), request.c_str ());
>  }
>  
> +static void
> +create_is_address_tagged_request (gdbarch *gdbarch, gdb::char_vector &packet,
> +				  CORE_ADDR address)
> +{
> +  int addr_size;
> +  std::string request;
> +
> +  addr_size = gdbarch_addr_bit (gdbarch) / 8;
> +  request = string_printf ("qIsAddressTagged:%s", phex_nz (address, addr_size));
> +
> +  if (packet.size () < request.length () + 1)
> +    error (_("Contents too big for packet qIsAddressTagged."));
> +
> +  strcpy (packet.data (), request.c_str ());
> +}
> +
> +static bool
> +check_is_address_tagged_reply (remote_target *remote, gdb::char_vector &packet,
> +			       bool &tagged)
> +{
> +  gdb_assert (remote != nullptr);
> +  /* Check reply and disable qIsAddressTagged usage if it's not supported.  */
> +  packet_result result = remote->m_features.packet_ok (packet,
> +						       PACKET_qIsAddressTagged);
> +
> +  /* Return false on error (Exx) or empty reply (packet not supported).  */
> +  if (result.status () != PACKET_OK)
> +    return false;
> +
> +  gdb_byte reply;
> +  /* Convert only 2 hex digits, i.e. 1 byte in hex format.  */
> +  hex2bin (packet.data (), &reply, 1);
> +
> +  if (reply == 0x00 || reply == 0x01)
> +    {
> +      tagged = !!reply;
> +      return true;
> +    }
> +
> +  /* Invalid reply.  */
> +  return false;
> +}


... check_is_address_tagged_reply still doesn't check for the length of the reply. Do we
want to consider garbage replies starting with 00 or 01 as valid? If so, we need to document
that in the manual more clearly. Otherwise we should limit the validity of the replies to
known good values like 00, 01, empty and errors.

> +
>  /* Implement the "fetch_memtags" target_ops method.  */
>  
>  bool
> @@ -15581,6 +15627,31 @@ remote_target::store_memtags (CORE_ADDR address, size_t len,
>  bool
>  remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address)
>  {
> +  /* Firstly, attempt to check the address using the qIsAddressTagged
> +     packet.  */
> +  if (m_features.packet_support (PACKET_qIsAddressTagged) != PACKET_DISABLE)
> +    {
> +      remote_target *remote = get_current_remote_target ();
> +      struct remote_state *rs = get_remote_state ();
> +      bool is_addr_tagged;
> +
> +      create_is_address_tagged_request (gdbarch, rs->buf, address);
> +
> +      putpkt (rs->buf);
> +      getpkt (&rs->buf);
> +
> +      /* If qIsAddressTagged is not supported PACKET_qIsAddressTagged will be
> +	 set to PACKET_DISABLE so no further attempt is made to check addresses
> +	 using this packet and the fallback mechanism below will be used
> +	 instead.  Also, if the check fails due to an error (Exx reply) the
> +	 fallback is used too.  Otherwise, the qIsAddressTagged query succeeded
> +	 and is_addr_tagged is valid.  */
> +      if (check_is_address_tagged_reply (remote, rs->buf, is_addr_tagged))
> +	return is_addr_tagged;
> +    }
> +
> +  /* Fallback to arch-specific method of checking whether an address is tagged
> +     in case check via qIsAddressTagged fails.  */
>    return gdbarch_tagged_address_p (gdbarch, address);
>  }
>  
> @@ -16070,6 +16141,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
>    add_packet_config_cmd (PACKET_memory_tagging_feature,
>  			 "memory-tagging-feature", "memory-tagging-feature", 0);
>  
> +  add_packet_config_cmd (PACKET_qIsAddressTagged,
> +			 "qIsAddressTagged", "memory-tagging-address-check", 0);
> +
>    /* Assert that we've registered "set remote foo-packet" commands
>       for all packet configs.  */
>    {

Otherwise this looks OK to me.

^ permalink raw reply	[relevance 0%]

* [PATCH 1/3] gdb: print target in print_target_wait_results
  @ 2024-04-18  7:36  9% ` Tankut Baris Aktemur
  0 siblings, 0 replies; 200+ results
From: Tankut Baris Aktemur @ 2024-04-18  7:36 UTC (permalink / raw)
  To: gdb-patches

Extend `print_target_wait_results` to print the target from which the
wait result came.
---
 gdb/infrun.c | 27 ++++++++++++++++++++++-----
 gdb/infrun.h |  3 ++-
 gdb/remote.c |  2 +-
 3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index a5030b16376..3dbd42f81cb 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3979,7 +3979,8 @@ delete_just_stopped_threads_single_step_breakpoints (void)
 
 void
 print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid,
-			   const struct target_waitstatus &ws)
+			   const struct target_waitstatus &ws,
+			   process_stratum_target *proc_target)
 {
   infrun_debug_printf ("target_wait (%s [%s], status) =",
 		       waiton_ptid.to_string ().c_str (),
@@ -3988,6 +3989,20 @@ print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid,
 		       result_ptid.to_string ().c_str (),
 		       target_pid_to_str (result_ptid).c_str ());
   infrun_debug_printf ("  %s", ws.to_string ().c_str ());
+
+  if (proc_target != nullptr)
+    infrun_debug_printf ("  from target %d (%s)",
+			 proc_target->connection_number,
+			 proc_target->shortname ());
+}
+
+/* Wrapper for print_target_wait_results above for convenience.  */
+
+static void
+print_target_wait_results (ptid_t waiton_ptid,
+			   const execution_control_state &ecs)
+{
+  print_target_wait_results (waiton_ptid, ecs.ptid, ecs.ws, ecs.target);
 }
 
 /* Select a thread at random, out of those which are resumed and have
@@ -4339,7 +4354,8 @@ prepare_for_detach (void)
 	  event.ptid = do_target_wait_1 (inf, pid_ptid, &event.ws, 0);
 
 	  if (debug_infrun)
-	    print_target_wait_results (pid_ptid, event.ptid, event.ws);
+	    print_target_wait_results (pid_ptid, event.ptid, event.ws,
+				       event.target);
 
 	  handle_one (event);
 	}
@@ -4395,7 +4411,7 @@ wait_for_inferior (inferior *inf)
       ecs.target = inf->process_target ();
 
       if (debug_infrun)
-	print_target_wait_results (minus_one_ptid, ecs.ptid, ecs.ws);
+	print_target_wait_results (minus_one_ptid, ecs);
 
       /* Now figure out what to do with the result of the result.  */
       handle_inferior_event (&ecs);
@@ -4676,7 +4692,7 @@ fetch_inferior_event ()
       switch_to_target_no_thread (ecs.target);
 
     if (debug_infrun)
-      print_target_wait_results (minus_one_ptid, ecs.ptid, ecs.ws);
+      print_target_wait_results (minus_one_ptid, ecs);
 
     /* If an error happens while handling the event, propagate GDB's
        knowledge of the executing state to the frontend/user running
@@ -5239,7 +5255,8 @@ poll_one_curr_target (struct target_waitstatus *ws)
   event_ptid = target_wait (minus_one_ptid, ws, TARGET_WNOHANG);
 
   if (debug_infrun)
-    print_target_wait_results (minus_one_ptid, event_ptid, *ws);
+    print_target_wait_results (minus_one_ptid, event_ptid, *ws,
+			       current_inferior ()->process_target ());
 
   return event_ptid;
 }
diff --git a/gdb/infrun.h b/gdb/infrun.h
index 5f83ca2b4c3..0dc26ae2c33 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -256,7 +256,8 @@ extern void print_stop_event (struct ui_out *uiout, bool displays = true);
 /* Pretty print the results of target_wait, for debugging purposes.  */
 
 extern void print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid,
-				       const struct target_waitstatus &ws);
+				       const struct target_waitstatus &ws,
+				       process_stratum_target *proc_target);
 
 extern int signal_stop_state (int);
 
diff --git a/gdb/remote.c b/gdb/remote.c
index 5c9fdebcdbe..fdf45abf2ee 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4860,7 +4860,7 @@ remote_target::process_initial_stop_replies (int from_tty)
 
       event_ptid = target_wait (waiton_ptid, &ws, TARGET_WNOHANG);
       if (remote_debug)
-	print_target_wait_results (waiton_ptid, event_ptid, ws);
+	print_target_wait_results (waiton_ptid, event_ptid, ws, this);
 
       switch (ws.kind ())
 	{
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 9%]

* [PATCH 4/4] Run check-include-guards.py
  @ 2024-04-17 22:05  1% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-17 22:05 UTC (permalink / raw)
  To: gdb-patches

This patch is the result of running check-include-guards.py on the
current tree.  Running it a second time causes no changes.
---
 gdb/aarch32-linux-nat.h                     | 6 +++---
 gdb/aarch32-tdep.h                          | 6 +++---
 gdb/aarch64-fbsd-tdep.h                     | 6 +++---
 gdb/aarch64-linux-tdep.h                    | 6 +++---
 gdb/aarch64-nat.h                           | 6 +++---
 gdb/aarch64-ravenscar-thread.h              | 6 +++---
 gdb/aarch64-tdep.h                          | 6 +++---
 gdb/ada-exp.h                               | 6 +++---
 gdb/ada-lang.h                              | 6 +++---
 gdb/addrmap.h                               | 6 +++---
 gdb/alpha-bsd-tdep.h                        | 6 +++---
 gdb/alpha-tdep.h                            | 6 +++---
 gdb/amd-dbgapi-target.h                     | 6 +++---
 gdb/amd64-bsd-nat.h                         | 6 +++---
 gdb/amd64-darwin-tdep.h                     | 6 +++---
 gdb/amd64-fbsd-tdep.h                       | 6 +++---
 gdb/amd64-linux-tdep.h                      | 6 +++---
 gdb/amd64-nat.h                             | 6 +++---
 gdb/amd64-ravenscar-thread.h                | 6 +++---
 gdb/amd64-tdep.h                            | 6 +++---
 gdb/amdgpu-tdep.h                           | 6 +++---
 gdb/annotate.h                              | 6 +++---
 gdb/arc-linux-tdep.h                        | 6 +++---
 gdb/arc-tdep.h                              | 6 +++---
 gdb/arch-utils.h                            | 6 +++---
 gdb/arch/aarch32.h                          | 6 +++---
 gdb/arch/aarch64-insn.h                     | 6 +++---
 gdb/arch/aarch64-mte-linux.h                | 6 +++---
 gdb/arch/aarch64-scalable-linux.h           | 6 +++---
 gdb/arch/aarch64.h                          | 6 +++---
 gdb/arch/amd64.h                            | 6 +++---
 gdb/arch/arc.h                              | 6 +++---
 gdb/arch/arm-get-next-pcs.h                 | 6 +++---
 gdb/arch/arm-linux.h                        | 6 +++---
 gdb/arch/arm.h                              | 6 +++---
 gdb/arch/csky.h                             | 6 +++---
 gdb/arch/i386.h                             | 6 +++---
 gdb/arch/loongarch.h                        | 6 +++---
 gdb/arch/ppc-linux-common.h                 | 6 +++---
 gdb/arch/ppc-linux-tdesc.h                  | 6 +++---
 gdb/arch/riscv.h                            | 6 +++---
 gdb/arch/tic6x.h                            | 6 +++---
 gdb/arch/xtensa.h                           | 6 +++---
 gdb/arm-fbsd-tdep.h                         | 6 +++---
 gdb/arm-linux-tdep.h                        | 6 +++---
 gdb/arm-netbsd-tdep.h                       | 6 +++---
 gdb/arm-tdep.h                              | 6 +++---
 gdb/async-event.h                           | 6 +++---
 gdb/auto-load.h                             | 6 +++---
 gdb/auxv.h                                  | 6 +++---
 gdb/ax-gdb.h                                | 6 +++---
 gdb/ax.h                                    | 6 +++---
 gdb/bcache.h                                | 6 +++---
 gdb/bfd-target.h                            | 6 +++---
 gdb/bfin-tdep.h                             | 6 +++---
 gdb/block.h                                 | 6 +++---
 gdb/breakpoint.h                            | 6 +++---
 gdb/bsd-kvm.h                               | 6 +++---
 gdb/bsd-uthread.h                           | 6 +++---
 gdb/bt-utils.h                              | 6 +++---
 gdb/btrace.h                                | 6 +++---
 gdb/build-id.h                              | 6 +++---
 gdb/buildsym-legacy.h                       | 6 +++---
 gdb/buildsym.h                              | 6 +++---
 gdb/c-exp.h                                 | 6 +++---
 gdb/c-lang.h                                | 6 +++---
 gdb/c-support.h                             | 6 +++---
 gdb/cgen-remap.h                            | 6 +++---
 gdb/charset-list.h                          | 6 +++---
 gdb/charset.h                               | 6 +++---
 gdb/cli-out.h                               | 6 +++---
 gdb/cli/cli-cmds.h                          | 6 +++---
 gdb/cli/cli-decode.h                        | 6 +++---
 gdb/cli/cli-interp.h                        | 6 +++---
 gdb/cli/cli-option.h                        | 6 +++---
 gdb/cli/cli-script.h                        | 6 +++---
 gdb/cli/cli-setshow.h                       | 6 +++---
 gdb/cli/cli-style.h                         | 6 +++---
 gdb/cli/cli-utils.h                         | 6 +++---
 gdb/coff-pe-read.h                          | 6 +++---
 gdb/command.h                               | 6 +++---
 gdb/compile/compile-c.h                     | 6 +++---
 gdb/compile/compile-cplus.h                 | 6 +++---
 gdb/compile/compile-internal.h              | 6 +++---
 gdb/compile/compile-object-load.h           | 6 +++---
 gdb/compile/compile-object-run.h            | 6 +++---
 gdb/compile/compile.h                       | 6 +++---
 gdb/compile/gcc-c-plugin.h                  | 6 +++---
 gdb/compile/gcc-cp-plugin.h                 | 6 +++---
 gdb/complaints.h                            | 6 +++---
 gdb/completer.h                             | 6 +++---
 gdb/config/nm-linux.h                       | 6 +++---
 gdb/config/nm-nto.h                         | 6 +++---
 gdb/cp-abi.h                                | 6 +++---
 gdb/cp-support.h                            | 6 +++---
 gdb/cris-tdep.h                             | 6 +++---
 gdb/csky-tdep.h                             | 6 +++---
 gdb/ctfread.h                               | 6 +++---
 gdb/d-lang.h                                | 6 +++---
 gdb/darwin-nat.h                            | 6 +++---
 gdb/dcache.h                                | 6 +++---
 gdb/debuginfod-support.h                    | 6 +++---
 gdb/defs.h                                  | 6 +++---
 gdb/dicos-tdep.h                            | 6 +++---
 gdb/dictionary.h                            | 6 +++---
 gdb/disasm-flags.h                          | 6 +++---
 gdb/disasm.h                                | 6 +++---
 gdb/displaced-stepping.h                    | 6 +++---
 gdb/dummy-frame.h                           | 6 +++---
 gdb/dwarf2/call-site.h                      | 6 +++---
 gdb/dwarf2/comp-unit-head.h                 | 6 +++---
 gdb/dwarf2/expr.h                           | 6 +++---
 gdb/dwarf2/frame-tailcall.h                 | 6 +++---
 gdb/dwarf2/frame.h                          | 6 +++---
 gdb/dwarf2/index-cache.h                    | 6 +++---
 gdb/dwarf2/index-common.h                   | 6 +++---
 gdb/dwarf2/index-write.h                    | 6 +++---
 gdb/dwarf2/line-header.h                    | 6 +++---
 gdb/dwarf2/loc.h                            | 6 +++---
 gdb/dwarf2/public.h                         | 6 +++---
 gdb/dwarf2/read-debug-names.h               | 6 +++---
 gdb/dwarf2/read-gdb-index.h                 | 6 +++---
 gdb/dwarf2/read.h                           | 6 +++---
 gdb/dwarf2/types.h                          | 6 +++---
 gdb/elf-none-tdep.h                         | 6 +++---
 gdb/event-top.h                             | 6 +++---
 gdb/exceptions.h                            | 6 +++---
 gdb/exec.h                                  | 6 +++---
 gdb/expop.h                                 | 6 +++---
 gdb/expression.h                            | 6 +++---
 gdb/extension-priv.h                        | 6 +++---
 gdb/extension.h                             | 6 +++---
 gdb/f-array-walker.h                        | 6 +++---
 gdb/f-exp.h                                 | 6 +++---
 gdb/f-lang.h                                | 6 +++---
 gdb/fbsd-nat.h                              | 6 +++---
 gdb/fbsd-tdep.h                             | 6 +++---
 gdb/filename-seen-cache.h                   | 6 +++---
 gdb/filesystem.h                            | 6 +++---
 gdb/frame-base.h                            | 6 +++---
 gdb/frame-id.h                              | 4 ++--
 gdb/frame-unwind.h                          | 6 +++---
 gdb/frame.h                                 | 6 +++---
 gdb/frv-tdep.h                              | 6 +++---
 gdb/ft32-tdep.h                             | 6 +++---
 gdb/gcore-elf.h                             | 6 +++---
 gdb/gcore.h                                 | 6 +++---
 gdb/gdb-demangle.h                          | 6 +++---
 gdb/gdb-stabs.h                             | 6 +++---
 gdb/gdb_bfd.h                               | 6 +++---
 gdb/gdb_curses.h                            | 6 +++---
 gdb/gdb_expat.h                             | 6 +++---
 gdb/gdb_proc_service.h                      | 6 +++---
 gdb/gdb_vfork.h                             | 6 +++---
 gdb/gdb_wchar.h                             | 6 +++---
 gdb/gdbarch.h                               | 6 +++---
 gdb/gdbcmd.h                                | 6 +++---
 gdb/gdbcore.h                               | 6 +++---
 gdb/gdbthread.h                             | 6 +++---
 gdb/gdbtypes.h                              | 6 +++---
 gdb/glibc-tdep.h                            | 6 +++---
 gdb/gmp-utils.h                             | 6 +++---
 gdb/gnu-nat-mig.h                           | 6 +++---
 gdb/gnu-nat.h                               | 6 +++---
 gdb/go-lang.h                               | 6 +++---
 gdb/gregset.h                               | 6 +++---
 gdb/guile/guile-internal.h                  | 6 +++---
 gdb/guile/guile.h                           | 6 +++---
 gdb/hppa-bsd-tdep.h                         | 6 +++---
 gdb/hppa-linux-offsets.h                    | 6 +++---
 gdb/hppa-tdep.h                             | 6 +++---
 gdb/i386-bsd-nat.h                          | 6 +++---
 gdb/i386-darwin-tdep.h                      | 6 +++---
 gdb/i386-fbsd-tdep.h                        | 6 +++---
 gdb/i386-linux-nat.h                        | 6 +++---
 gdb/i386-linux-tdep.h                       | 6 +++---
 gdb/i386-tdep.h                             | 6 +++---
 gdb/i387-tdep.h                             | 6 +++---
 gdb/ia64-libunwind-tdep.h                   | 6 +++---
 gdb/ia64-tdep.h                             | 6 +++---
 gdb/inf-child.h                             | 6 +++---
 gdb/inf-loop.h                              | 6 +++---
 gdb/inf-ptrace.h                            | 6 +++---
 gdb/infcall.h                               | 6 +++---
 gdb/inferior-iter.h                         | 6 +++---
 gdb/inferior.h                              | 6 +++---
 gdb/infrun.h                                | 6 +++---
 gdb/inline-frame.h                          | 6 +++---
 gdb/interps.h                               | 6 +++---
 gdb/jit.h                                   | 6 +++---
 gdb/language.h                              | 6 +++---
 gdb/linespec.h                              | 6 +++---
 gdb/linux-fork.h                            | 6 +++---
 gdb/linux-nat-trad.h                        | 6 +++---
 gdb/linux-nat.h                             | 6 +++---
 gdb/linux-record.h                          | 6 +++---
 gdb/linux-tdep.h                            | 6 +++---
 gdb/location.h                              | 6 +++---
 gdb/loongarch-tdep.h                        | 6 +++---
 gdb/m2-exp.h                                | 6 +++---
 gdb/m2-lang.h                               | 6 +++---
 gdb/m32r-tdep.h                             | 6 +++---
 gdb/m68k-tdep.h                             | 6 +++---
 gdb/macroexp.h                              | 6 +++---
 gdb/macroscope.h                            | 6 +++---
 gdb/macrotab.h                              | 6 +++---
 gdb/main.h                                  | 6 +++---
 gdb/maint.h                                 | 6 +++---
 gdb/mdebugread.h                            | 6 +++---
 gdb/memattr.h                               | 6 +++---
 gdb/memory-map.h                            | 6 +++---
 gdb/memrange.h                              | 6 +++---
 gdb/memtag.h                                | 6 +++---
 gdb/mi/mi-cmd-break.h                       | 6 +++---
 gdb/mi/mi-cmds.h                            | 6 +++---
 gdb/mi/mi-common.h                          | 6 +++---
 gdb/mi/mi-console.h                         | 6 +++---
 gdb/mi/mi-getopt.h                          | 6 +++---
 gdb/mi/mi-interp.h                          | 6 +++---
 gdb/mi/mi-main.h                            | 6 +++---
 gdb/mi/mi-out.h                             | 6 +++---
 gdb/mi/mi-parse.h                           | 6 +++---
 gdb/microblaze-tdep.h                       | 6 +++---
 gdb/minsyms.h                               | 6 +++---
 gdb/mips-fbsd-tdep.h                        | 6 +++---
 gdb/mips-linux-tdep.h                       | 6 +++---
 gdb/mips-netbsd-tdep.h                      | 6 +++---
 gdb/mips-tdep.h                             | 6 +++---
 gdb/mn10300-tdep.h                          | 6 +++---
 gdb/moxie-tdep.h                            | 6 +++---
 gdb/namespace.h                             | 6 +++---
 gdb/nat/aarch64-hw-point.h                  | 6 +++---
 gdb/nat/aarch64-linux-hw-point.h            | 6 +++---
 gdb/nat/aarch64-linux.h                     | 6 +++---
 gdb/nat/aarch64-mte-linux-ptrace.h          | 6 +++---
 gdb/nat/aarch64-scalable-linux-ptrace.h     | 6 +++---
 gdb/nat/aarch64-scalable-linux-sigcontext.h | 6 +++---
 gdb/nat/amd64-linux-siginfo.h               | 6 +++---
 gdb/nat/fork-inferior.h                     | 6 +++---
 gdb/nat/gdb_ptrace.h                        | 6 +++---
 gdb/nat/gdb_thread_db.h                     | 6 +++---
 gdb/nat/glibc_thread_db.h                   | 6 +++---
 gdb/nat/linux-btrace.h                      | 6 +++---
 gdb/nat/linux-namespaces.h                  | 6 +++---
 gdb/nat/linux-nat.h                         | 6 +++---
 gdb/nat/linux-osdata.h                      | 6 +++---
 gdb/nat/linux-personality.h                 | 6 +++---
 gdb/nat/linux-procfs.h                      | 6 +++---
 gdb/nat/linux-ptrace.h                      | 6 +++---
 gdb/nat/linux-waitpid.h                     | 6 +++---
 gdb/nat/mips-linux-watch.h                  | 6 +++---
 gdb/nat/netbsd-nat.h                        | 6 +++---
 gdb/nat/ppc-linux.h                         | 6 +++---
 gdb/nat/riscv-linux-tdesc.h                 | 6 +++---
 gdb/nat/windows-nat.h                       | 6 +++---
 gdb/nat/x86-cpuid.h                         | 6 +++---
 gdb/nat/x86-dregs.h                         | 6 +++---
 gdb/nat/x86-gcc-cpuid.h                     | 6 +++---
 gdb/nat/x86-linux-dregs.h                   | 6 +++---
 gdb/nat/x86-linux.h                         | 6 +++---
 gdb/nat/x86-xstate.h                        | 6 +++---
 gdb/nds32-tdep.h                            | 6 +++---
 gdb/netbsd-nat.h                            | 6 +++---
 gdb/netbsd-tdep.h                           | 6 +++---
 gdb/nios2-tdep.h                            | 6 +++---
 gdb/nto-tdep.h                              | 6 +++---
 gdb/objc-lang.h                             | 6 +++---
 gdb/objfile-flags.h                         | 6 +++---
 gdb/objfiles.h                              | 6 +++---
 gdb/obsd-nat.h                              | 6 +++---
 gdb/obsd-tdep.h                             | 6 +++---
 gdb/observable.h                            | 6 +++---
 gdb/or1k-linux-tdep.h                       | 6 +++---
 gdb/or1k-tdep.h                             | 6 +++---
 gdb/osabi.h                                 | 6 +++---
 gdb/osdata.h                                | 6 +++---
 gdb/p-lang.h                                | 6 +++---
 gdb/parser-defs.h                           | 6 +++---
 gdb/ppc-fbsd-tdep.h                         | 6 +++---
 gdb/ppc-linux-tdep.h                        | 6 +++---
 gdb/ppc-netbsd-tdep.h                       | 6 +++---
 gdb/ppc-obsd-tdep.h                         | 6 +++---
 gdb/ppc-ravenscar-thread.h                  | 6 +++---
 gdb/ppc-tdep.h                              | 6 +++---
 gdb/ppc64-tdep.h                            | 6 +++---
 gdb/probe.h                                 | 6 +++---
 gdb/proc-utils.h                            | 6 +++---
 gdb/process-stratum-target.h                | 6 +++---
 gdb/procfs.h                                | 6 +++---
 gdb/producer.h                              | 6 +++---
 gdb/progspace-and-thread.h                  | 6 +++---
 gdb/progspace.h                             | 6 +++---
 gdb/prologue-value.h                        | 6 +++---
 gdb/psymtab.h                               | 6 +++---
 gdb/python/py-event.h                       | 6 +++---
 gdb/python/py-events.h                      | 6 +++---
 gdb/python/py-instruction.h                 | 6 +++---
 gdb/python/py-record-btrace.h               | 6 +++---
 gdb/python/py-record-full.h                 | 6 +++---
 gdb/python/py-record.h                      | 6 +++---
 gdb/python/py-ref.h                         | 6 +++---
 gdb/python/py-stopevent.h                   | 6 +++---
 gdb/python/python-internal.h                | 6 +++---
 gdb/python/python.h                         | 6 +++---
 gdb/ravenscar-thread.h                      | 6 +++---
 gdb/record-btrace.h                         | 6 +++---
 gdb/record-full.h                           | 6 +++---
 gdb/record.h                                | 6 +++---
 gdb/regcache.h                              | 6 +++---
 gdb/regformats/regdef.h                     | 6 +++---
 gdb/reggroups.h                             | 6 +++---
 gdb/registry.h                              | 6 +++---
 gdb/regset.h                                | 6 +++---
 gdb/remote-fileio.h                         | 6 +++---
 gdb/remote-notif.h                          | 6 +++---
 gdb/remote.h                                | 6 +++---
 gdb/riscv-fbsd-tdep.h                       | 6 +++---
 gdb/riscv-ravenscar-thread.h                | 6 +++---
 gdb/riscv-tdep.h                            | 6 +++---
 gdb/rs6000-aix-tdep.h                       | 6 +++---
 gdb/rust-exp.h                              | 6 +++---
 gdb/rust-lang.h                             | 6 +++---
 gdb/s390-linux-tdep.h                       | 6 +++---
 gdb/s390-tdep.h                             | 6 +++---
 gdb/scoped-mock-context.h                   | 6 +++---
 gdb/selftest-arch.h                         | 6 +++---
 gdb/sentinel-frame.h                        | 6 +++---
 gdb/ser-base.h                              | 6 +++---
 gdb/ser-event.h                             | 6 +++---
 gdb/ser-tcp.h                               | 6 +++---
 gdb/ser-unix.h                              | 6 +++---
 gdb/serial.h                                | 6 +++---
 gdb/sh-tdep.h                               | 6 +++---
 gdb/sim-regno.h                             | 6 +++---
 gdb/skip.h                                  | 6 +++---
 gdb/sol2-tdep.h                             | 6 +++---
 gdb/solib-aix.h                             | 6 +++---
 gdb/solib-darwin.h                          | 6 +++---
 gdb/solib-dsbt.h                            | 6 +++---
 gdb/solib-svr4.h                            | 6 +++---
 gdb/solib-target.h                          | 6 +++---
 gdb/solib.h                                 | 6 +++---
 gdb/solist.h                                | 6 +++---
 gdb/source-cache.h                          | 6 +++---
 gdb/source.h                                | 6 +++---
 gdb/sparc-nat.h                             | 6 +++---
 gdb/sparc-ravenscar-thread.h                | 6 +++---
 gdb/sparc-tdep.h                            | 6 +++---
 gdb/sparc64-tdep.h                          | 6 +++---
 gdb/stabsread.h                             | 6 +++---
 gdb/stack.h                                 | 6 +++---
 gdb/stap-probe.h                            | 6 +++---
 gdb/symfile-add-flags.h                     | 6 +++---
 gdb/symfile.h                               | 6 +++---
 gdb/symtab.h                                | 6 +++---
 gdb/target-connection.h                     | 6 +++---
 gdb/target-dcache.h                         | 6 +++---
 gdb/target-debug.h                          | 6 +++---
 gdb/target-descriptions.h                   | 6 +++---
 gdb/target-float.h                          | 6 +++---
 gdb/target.h                                | 6 +++---
 gdb/target/resume.h                         | 6 +++---
 gdb/target/target.h                         | 6 +++---
 gdb/target/wait.h                           | 6 +++---
 gdb/target/waitstatus.h                     | 6 +++---
 gdb/terminal.h                              | 6 +++---
 gdb/test-target.h                           | 6 +++---
 gdb/thread-fsm.h                            | 6 +++---
 gdb/thread-iter.h                           | 6 +++---
 gdb/tic6x-tdep.h                            | 6 +++---
 gdb/tid-parse.h                             | 6 +++---
 gdb/tilegx-tdep.h                           | 6 +++---
 gdb/top.h                                   | 6 +++---
 gdb/tracectf.h                              | 6 +++---
 gdb/tracefile.h                             | 6 +++---
 gdb/tracepoint.h                            | 6 +++---
 gdb/trad-frame.h                            | 6 +++---
 gdb/tramp-frame.h                           | 6 +++---
 gdb/tui/tui-command.h                       | 6 +++---
 gdb/tui/tui-data.h                          | 6 +++---
 gdb/tui/tui-disasm.h                        | 6 +++---
 gdb/tui/tui-file.h                          | 6 +++---
 gdb/tui/tui-hooks.h                         | 6 +++---
 gdb/tui/tui-io.h                            | 6 +++---
 gdb/tui/tui-layout.h                        | 6 +++---
 gdb/tui/tui-location.h                      | 6 +++---
 gdb/tui/tui-regs.h                          | 6 +++---
 gdb/tui/tui-source.h                        | 6 +++---
 gdb/tui/tui-status.h                        | 6 +++---
 gdb/tui/tui-win.h                           | 6 +++---
 gdb/tui/tui-wingeneral.h                    | 6 +++---
 gdb/tui/tui-winsource.h                     | 6 +++---
 gdb/tui/tui.h                               | 6 +++---
 gdb/type-stack.h                            | 6 +++---
 gdb/typeprint.h                             | 6 +++---
 gdb/ui-file.h                               | 6 +++---
 gdb/ui-out.h                                | 6 +++---
 gdb/ui-style.h                              | 6 +++---
 gdb/ui.h                                    | 6 +++---
 gdb/user-regs.h                             | 6 +++---
 gdb/utils.h                                 | 6 +++---
 gdb/valprint.h                              | 6 +++---
 gdb/value.h                                 | 6 +++---
 gdb/varobj-iter.h                           | 6 +++---
 gdb/varobj.h                                | 6 +++---
 gdb/vax-tdep.h                              | 6 +++---
 gdb/windows-nat.h                           | 6 +++---
 gdb/windows-tdep.h                          | 6 +++---
 gdb/x86-bsd-nat.h                           | 6 +++---
 gdb/x86-fbsd-nat.h                          | 6 +++---
 gdb/x86-linux-nat.h                         | 6 +++---
 gdb/x86-nat.h                               | 6 +++---
 gdb/x86-tdep.h                              | 6 +++---
 gdb/xcoffread.h                             | 6 +++---
 gdb/xml-builtin.h                           | 6 +++---
 gdb/xml-support.h                           | 6 +++---
 gdb/xml-syscall.h                           | 6 +++---
 gdb/xml-tdesc.h                             | 6 +++---
 gdb/xtensa-tdep.h                           | 6 +++---
 gdb/yy-remap.h                              | 6 +++---
 gdb/z80-tdep.h                              | 6 +++---
 gdbserver/linux-aarch32-tdesc.h             | 2 +-
 gdbserver/linux-arm-tdesc.h                 | 2 +-
 gdbsupport/agent.h                          | 6 +++---
 gdbsupport/array-view.h                     | 6 +++---
 gdbsupport/break-common.h                   | 6 +++---
 gdbsupport/btrace-common.h                  | 6 +++---
 gdbsupport/byte-vector.h                    | 6 +++---
 gdbsupport/cleanups.h                       | 6 +++---
 gdbsupport/common-debug.h                   | 6 +++---
 gdbsupport/common-defs.h                    | 6 +++---
 gdbsupport/common-exceptions.h              | 6 +++---
 gdbsupport/common-gdbthread.h               | 6 +++---
 gdbsupport/common-inferior.h                | 6 +++---
 gdbsupport/common-regcache.h                | 6 +++---
 gdbsupport/common-types.h                   | 6 +++---
 gdbsupport/common-utils.h                   | 6 +++---
 gdbsupport/def-vector.h                     | 6 +++---
 gdbsupport/default-init-alloc.h             | 6 +++---
 gdbsupport/enum-flags.h                     | 6 +++---
 gdbsupport/environ.h                        | 6 +++---
 gdbsupport/errors.h                         | 6 +++---
 gdbsupport/event-loop.h                     | 6 +++---
 gdbsupport/event-pipe.h                     | 6 +++---
 gdbsupport/fileio.h                         | 6 +++---
 gdbsupport/filestuff.h                      | 6 +++---
 gdbsupport/filtered-iterator.h              | 6 +++---
 gdbsupport/format.h                         | 6 +++---
 gdbsupport/forward-scope-exit.h             | 6 +++---
 gdbsupport/function-view.h                  | 6 +++---
 gdbsupport/gdb-checked-static-cast.h        | 6 +++---
 gdbsupport/gdb-dlfcn.h                      | 6 +++---
 gdbsupport/gdb-safe-ctype.h                 | 6 +++---
 gdbsupport/gdb_assert.h                     | 6 +++---
 gdbsupport/gdb_file.h                       | 6 +++---
 gdbsupport/gdb_locale.h                     | 6 +++---
 gdbsupport/gdb_obstack.h                    | 6 +++---
 gdbsupport/gdb_proc_service.h               | 6 +++---
 gdbsupport/gdb_ref_ptr.h                    | 6 +++---
 gdbsupport/gdb_regex.h                      | 6 +++---
 gdbsupport/gdb_select.h                     | 6 +++---
 gdbsupport/gdb_setjmp.h                     | 6 +++---
 gdbsupport/gdb_signals.h                    | 6 +++---
 gdbsupport/gdb_splay_tree.h                 | 6 +++---
 gdbsupport/gdb_sys_time.h                   | 6 +++---
 gdbsupport/gdb_tilde_expand.h               | 6 +++---
 gdbsupport/gdb_unique_ptr.h                 | 6 +++---
 gdbsupport/gdb_unlinker.h                   | 6 +++---
 gdbsupport/gdb_vecs.h                       | 6 +++---
 gdbsupport/gdb_wait.h                       | 6 +++---
 gdbsupport/hash_enum.h                      | 6 +++---
 gdbsupport/host-defs.h                      | 6 +++---
 gdbsupport/job-control.h                    | 6 +++---
 gdbsupport/netstuff.h                       | 6 +++---
 gdbsupport/next-iterator.h                  | 6 +++---
 gdbsupport/observable.h                     | 6 +++---
 gdbsupport/offset-type.h                    | 6 +++---
 gdbsupport/packed.h                         | 6 +++---
 gdbsupport/pathstuff.h                      | 6 +++---
 gdbsupport/poison.h                         | 6 +++---
 gdbsupport/preprocessor.h                   | 6 +++---
 gdbsupport/print-utils.h                    | 6 +++---
 gdbsupport/ptid.h                           | 6 +++---
 gdbsupport/refcounted-object.h              | 6 +++---
 gdbsupport/rsp-low.h                        | 6 +++---
 gdbsupport/run-time-clock.h                 | 6 +++---
 gdbsupport/safe-iterator.h                  | 6 +++---
 gdbsupport/scope-exit.h                     | 6 +++---
 gdbsupport/scoped_fd.h                      | 6 +++---
 gdbsupport/scoped_ignore_signal.h           | 6 +++---
 gdbsupport/scoped_ignore_sigttou.h          | 6 +++---
 gdbsupport/scoped_mmap.h                    | 6 +++---
 gdbsupport/scoped_restore.h                 | 6 +++---
 gdbsupport/search.h                         | 6 +++---
 gdbsupport/selftest.h                       | 6 +++---
 gdbsupport/signals-state-save-restore.h     | 6 +++---
 gdbsupport/symbol.h                         | 6 +++---
 gdbsupport/tdesc.h                          | 6 +++---
 gdbsupport/traits.h                         | 6 +++---
 gdbsupport/underlying.h                     | 6 +++---
 gdbsupport/valid-expr.h                     | 6 +++---
 gdbsupport/version.h                        | 6 +++---
 gdbsupport/x86-xstate.h                     | 6 +++---
 gdbsupport/xml-utils.h                      | 6 +++---
 504 files changed, 1507 insertions(+), 1507 deletions(-)

diff --git a/gdb/aarch32-linux-nat.h b/gdb/aarch32-linux-nat.h
index 611c9fcfba9..79ad5adcef8 100644
--- a/gdb/aarch32-linux-nat.h
+++ b/gdb/aarch32-linux-nat.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH32_LINUX_NAT_H
-#define AARCH32_LINUX_NAT_H
+#ifndef GDB_AARCH32_LINUX_NAT_H
+#define GDB_AARCH32_LINUX_NAT_H
 
 void aarch32_gp_regcache_supply (struct regcache *regcache, uint32_t *regs,
 				 int arm_apcs_32);
@@ -31,4 +31,4 @@ void aarch32_vfp_regcache_collect (const struct regcache *regcache,
 				   gdb_byte *regs,
 				   const int vfp_register_count);
 
-#endif /* AARCH32_LINUX_NAT_H */
+#endif /* GDB_AARCH32_LINUX_NAT_H */
diff --git a/gdb/aarch32-tdep.h b/gdb/aarch32-tdep.h
index 009ee61890e..16ceb30a25f 100644
--- a/gdb/aarch32-tdep.h
+++ b/gdb/aarch32-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH32_TDEP_H
-#define AARCH32_TDEP_H
+#ifndef GDB_AARCH32_TDEP_H
+#define GDB_AARCH32_TDEP_H
 
 struct target_desc;
 
@@ -24,4 +24,4 @@ struct target_desc;
 
 const target_desc *aarch32_read_description (bool tls);
 
-#endif /* aarch32-tdep.h.  */
+#endif /* GDB_AARCH32_TDEP_H */
diff --git a/gdb/aarch64-fbsd-tdep.h b/gdb/aarch64-fbsd-tdep.h
index 56b15a94ee4..6d53b28386f 100644
--- a/gdb/aarch64-fbsd-tdep.h
+++ b/gdb/aarch64-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_FBSD_TDEP_H
-#define AARCH64_FBSD_TDEP_H
+#ifndef GDB_AARCH64_FBSD_TDEP_H
+#define GDB_AARCH64_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -39,4 +39,4 @@ extern const struct regset aarch64_fbsd_gregset;
 extern const struct regset aarch64_fbsd_fpregset;
 extern const struct regset aarch64_fbsd_tls_regset;
 
-#endif /* AARCH64_FBSD_TDEP_H */
+#endif /* GDB_AARCH64_FBSD_TDEP_H */
diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h
index 1961250e14f..4cca8e901a7 100644
--- a/gdb/aarch64-linux-tdep.h
+++ b/gdb/aarch64-linux-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_LINUX_TDEP_H
-#define AARCH64_LINUX_TDEP_H
+#ifndef GDB_AARCH64_LINUX_TDEP_H
+#define GDB_AARCH64_LINUX_TDEP_H
 
 #include "regset.h"
 
@@ -45,4 +45,4 @@ extern const struct regset aarch64_linux_fpregset;
 /* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h.  */
 #define AARCH64_HWCAP_PACA (1 << 30)
 
-#endif /* AARCH64_LINUX_TDEP_H */
+#endif /* GDB_AARCH64_LINUX_TDEP_H */
diff --git a/gdb/aarch64-nat.h b/gdb/aarch64-nat.h
index 947d2805602..33621c2643b 100644
--- a/gdb/aarch64-nat.h
+++ b/gdb/aarch64-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_NAT_H
-#define AARCH64_NAT_H
+#ifndef GDB_AARCH64_NAT_H
+#define GDB_AARCH64_NAT_H
 
 #include "breakpoint.h"
 #include "nat/aarch64-hw-point.h"
@@ -106,4 +106,4 @@ struct aarch64_nat_target : public BaseTarget
   { return start <= addr && start + length - 1 >= addr; }
 };
 
-#endif /* AARCH64_NAT_H */
+#endif /* GDB_AARCH64_NAT_H */
diff --git a/gdb/aarch64-ravenscar-thread.h b/gdb/aarch64-ravenscar-thread.h
index 2d2665627c5..9cf0113e635 100644
--- a/gdb/aarch64-ravenscar-thread.h
+++ b/gdb/aarch64-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AARCH64_RAVENSCAR_THREAD_H
-#define AARCH64_RAVENSCAR_THREAD_H
+#ifndef GDB_AARCH64_RAVENSCAR_THREAD_H
+#define GDB_AARCH64_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_aarch64_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_AARCH64_RAVENSCAR_THREAD_H */
diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h
index 0e6024bfcbc..e1e9f43fd11 100644
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -19,8 +19,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef AARCH64_TDEP_H
-#define AARCH64_TDEP_H
+#ifndef GDB_AARCH64_TDEP_H
+#define GDB_AARCH64_TDEP_H
 
 #include "arch/aarch64.h"
 #include "displaced-stepping.h"
@@ -203,4 +203,4 @@ void aarch64_displaced_step_fixup (struct gdbarch *gdbarch,
 
 bool aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch);
 
-#endif /* aarch64-tdep.h */
+#endif /* GDB_AARCH64_TDEP_H */
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 94e4ea0f47e..0a59b343f14 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ADA_EXP_H
-#define ADA_EXP_H
+#ifndef GDB_ADA_EXP_H
+#define GDB_ADA_EXP_H
 
 #include "expop.h"
 
@@ -981,4 +981,4 @@ class ada_concat_operation : public concat_operation
 
 } /* namespace expr */
 
-#endif /* ADA_EXP_H */
+#endif /* GDB_ADA_EXP_H */
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 5083d004ac9..69c91b2e719 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (ADA_LANG_H)
-#define ADA_LANG_H 1
+#ifndef GDB_ADA_LANG_H
+#define GDB_ADA_LANG_H
 
 class frame_info_ptr;
 struct inferior;
@@ -435,4 +435,4 @@ extern block_symbol ada_resolve_variable (struct symbol *sym,
 extern struct type *ada_index_type (struct type *type, int n,
 				    const char *name);
 
-#endif
+#endif /* GDB_ADA_LANG_H */
diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index 5378b753760..a2ccc7b0cfd 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ADDRMAP_H
-#define ADDRMAP_H
+#ifndef GDB_ADDRMAP_H
+#define GDB_ADDRMAP_H
 
 #include "splay-tree.h"
 #include "gdbsupport/function-view.h"
@@ -222,4 +222,4 @@ struct addrmap_mutable final : public addrmap
 void addrmap_dump (struct addrmap *map, struct ui_file *outfile,
 		   void *payload);
 
-#endif /* ADDRMAP_H */
+#endif /* GDB_ADDRMAP_H */
diff --git a/gdb/alpha-bsd-tdep.h b/gdb/alpha-bsd-tdep.h
index 25ac043ba86..4783854eb47 100644
--- a/gdb/alpha-bsd-tdep.h
+++ b/gdb/alpha-bsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ALPHA_BSD_TDEP_H
-#define ALPHA_BSD_TDEP_H
+#ifndef GDB_ALPHA_BSD_TDEP_H
+#define GDB_ALPHA_BSD_TDEP_H
 
 #include "gdbarch.h"
 
@@ -39,4 +39,4 @@ void alphanbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					     void *cb_data,
 					     const struct regcache *regcache);
 
-#endif /* alpha-bsd-tdep.h */
+#endif /* GDB_ALPHA_BSD_TDEP_H */
diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h
index 0423abb2558..37c1eddf691 100644
--- a/gdb/alpha-tdep.h
+++ b/gdb/alpha-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ALPHA_TDEP_H
-#define ALPHA_TDEP_H
+#ifndef GDB_ALPHA_TDEP_H
+#define GDB_ALPHA_TDEP_H
 
 #include "gdbarch.h"
 
@@ -121,4 +121,4 @@ extern void alpha_supply_fp_regs (struct regcache *, int,
 extern void alpha_fill_fp_regs (const struct regcache *,
 				int, void *, void *);
 
-#endif /* ALPHA_TDEP_H */
+#endif /* GDB_ALPHA_TDEP_H */
diff --git a/gdb/amd-dbgapi-target.h b/gdb/amd-dbgapi-target.h
index f377fd0c57a..0a9cafaa7ee 100644
--- a/gdb/amd-dbgapi-target.h
+++ b/gdb/amd-dbgapi-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD_DBGAPI_TARGET_H
-#define AMD_DBGAPI_TARGET_H 1
+#ifndef GDB_AMD_DBGAPI_TARGET_H
+#define GDB_AMD_DBGAPI_TARGET_H
 
 #include "gdbsupport/observable.h"
 
@@ -113,4 +113,4 @@ get_status_string (amd_dbgapi_status_t status)
   return ret;
 }
 
-#endif /* AMD_DBGAPI_TARGET_H */
+#endif /* GDB_AMD_DBGAPI_TARGET_H */
diff --git a/gdb/amd64-bsd-nat.h b/gdb/amd64-bsd-nat.h
index b11356e0375..7ea26827625 100644
--- a/gdb/amd64-bsd-nat.h
+++ b/gdb/amd64-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_BSD_NAT_H
-#define AMD64_BSD_NAT_H
+#ifndef GDB_AMD64_BSD_NAT_H
+#define GDB_AMD64_BSD_NAT_H
 
 #include "x86-bsd-nat.h"
 
@@ -41,4 +41,4 @@ class amd64_bsd_nat_target : public x86bsd_nat_target<BaseTarget>
   { amd64bsd_store_inferior_registers (regcache, regnum); }
 };
 
-#endif /* i386-bsd-nat.h */
+#endif /* GDB_AMD64_BSD_NAT_H */
diff --git a/gdb/amd64-darwin-tdep.h b/gdb/amd64-darwin-tdep.h
index 19d92b61b90..c09cfe3229b 100644
--- a/gdb/amd64-darwin-tdep.h
+++ b/gdb/amd64-darwin-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_DARWIN_TDEP_H
-#define AMD64_DARWIN_TDEP_H
+#ifndef GDB_AMD64_DARWIN_TDEP_H
+#define GDB_AMD64_DARWIN_TDEP_H
 
 /* Mapping between the general-purpose registers in Darwin x86-64 thread
    state and GDB's register cache layout.
@@ -26,4 +26,4 @@
 extern int amd64_darwin_thread_state_reg_offset[];
 extern const int amd64_darwin_thread_state_num_regs;
 
-#endif /* AMD64_DARWIN_TDEP_H */
+#endif /* GDB_AMD64_DARWIN_TDEP_H */
diff --git a/gdb/amd64-fbsd-tdep.h b/gdb/amd64-fbsd-tdep.h
index 93b0ca901ce..7e8acc6959e 100644
--- a/gdb/amd64-fbsd-tdep.h
+++ b/gdb/amd64-fbsd-tdep.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_FBSD_TDEP_H
-#define AMD64_FBSD_TDEP_H
+#ifndef GDB_AMD64_FBSD_TDEP_H
+#define GDB_AMD64_FBSD_TDEP_H
 
 #include "regset.h"
 
 extern const struct regset amd64_fbsd_gregset;
 
-#endif /* AMD64_FBSD_TDEP_H */
+#endif /* GDB_AMD64_FBSD_TDEP_H */
diff --git a/gdb/amd64-linux-tdep.h b/gdb/amd64-linux-tdep.h
index 2003dcda78f..6ce0032040c 100644
--- a/gdb/amd64-linux-tdep.h
+++ b/gdb/amd64-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_LINUX_TDEP_H
-#define AMD64_LINUX_TDEP_H
+#ifndef GDB_AMD64_LINUX_TDEP_H
+#define GDB_AMD64_LINUX_TDEP_H
 
 /* Like for i386 GNU/Linux, there is an extra "register"
    used to control syscall restarting.  */
@@ -604,4 +604,4 @@ enum amd64_x32_syscall {
   amd64_x32_sys_getsockopt = (amd64_x32_syscall_bit + 542),
 };
 
-#endif /* amd64-linux-tdep.h */
+#endif /* GDB_AMD64_LINUX_TDEP_H */
diff --git a/gdb/amd64-nat.h b/gdb/amd64-nat.h
index b18ff8b1728..56ad36c9f1e 100644
--- a/gdb/amd64-nat.h
+++ b/gdb/amd64-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_NAT_H
-#define AMD64_NAT_H 1
+#ifndef GDB_AMD64_NAT_H
+#define GDB_AMD64_NAT_H
 
 struct regcache;
 
@@ -49,4 +49,4 @@ extern void amd64_supply_native_gregset (struct regcache *regcache,
 extern void amd64_collect_native_gregset (const struct regcache *regcache,
 					  void *gregs, int regnum);
 
-#endif /* amd64-nat.h */
+#endif /* GDB_AMD64_NAT_H */
diff --git a/gdb/amd64-ravenscar-thread.h b/gdb/amd64-ravenscar-thread.h
index 1a723600e7a..41e38327753 100644
--- a/gdb/amd64-ravenscar-thread.h
+++ b/gdb/amd64-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_RAVENSCAR_THREAD_H
-#define AMD64_RAVENSCAR_THREAD_H
+#ifndef GDB_AMD64_RAVENSCAR_THREAD_H
+#define GDB_AMD64_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_amd64_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif /* AMD64_RAVENSCAR_THREAD_H */
+#endif /* GDB_AMD64_RAVENSCAR_THREAD_H */
diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
index 696c65b4f1b..c964e26e6a3 100644
--- a/gdb/amd64-tdep.h
+++ b/gdb/amd64-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMD64_TDEP_H
-#define AMD64_TDEP_H
+#ifndef GDB_AMD64_TDEP_H
+#define GDB_AMD64_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -144,4 +144,4 @@ extern int amd64nbsd_r_reg_offset[];
 /* Variables exported from amd64-obsd-tdep.c.  */
 extern int amd64obsd_r_reg_offset[];
 
-#endif /* amd64-tdep.h */
+#endif /* GDB_AMD64_TDEP_H */
diff --git a/gdb/amdgpu-tdep.h b/gdb/amdgpu-tdep.h
index 2656d18e727..16c7b83a679 100644
--- a/gdb/amdgpu-tdep.h
+++ b/gdb/amdgpu-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AMDGPU_TDEP_H
-#define AMDGPU_TDEP_H
+#ifndef GDB_AMDGPU_TDEP_H
+#define GDB_AMDGPU_TDEP_H
 
 #include "gdbarch.h"
 
@@ -90,4 +90,4 @@ bool is_amdgpu_arch (struct gdbarch *gdbarch);
 
 amdgpu_gdbarch_tdep *get_amdgpu_gdbarch_tdep (gdbarch *arch);
 
-#endif /* AMDGPU_TDEP_H */
+#endif /* GDB_AMDGPU_TDEP_H */
diff --git a/gdb/annotate.h b/gdb/annotate.h
index b8ce63ff233..d730b2e8297 100644
--- a/gdb/annotate.h
+++ b/gdb/annotate.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ANNOTATE_H
-#define ANNOTATE_H
+#ifndef GDB_ANNOTATE_H
+#define GDB_ANNOTATE_H
 
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -132,4 +132,4 @@ extern void annotate_array_section_end (void);
 extern void (*deprecated_annotate_signalled_hook) (void);
 extern void (*deprecated_annotate_signal_hook) (void);
 
-#endif /* ANNOTATE_H */
+#endif /* GDB_ANNOTATE_H */
diff --git a/gdb/arc-linux-tdep.h b/gdb/arc-linux-tdep.h
index 20ed525fe7c..9fe4116984d 100644
--- a/gdb/arc-linux-tdep.h
+++ b/gdb/arc-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARC_LINUX_TDEP_H
-#define ARC_LINUX_TDEP_H
+#ifndef GDB_ARC_LINUX_TDEP_H
+#define GDB_ARC_LINUX_TDEP_H
 
 #include "gdbarch.h"
 #include "regset.h"
@@ -49,4 +49,4 @@ void arc_linux_collect_v2_regset (const struct regset *regset,
 				  const struct regcache *regcache,
 				  int regnum, void *v2_regs, size_t size);
 
-#endif /* ARC_LINUX_TDEP_H */
+#endif /* GDB_ARC_LINUX_TDEP_H */
diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
index c59490dec00..86a483d00c7 100644
--- a/gdb/arc-tdep.h
+++ b/gdb/arc-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARC_TDEP_H
-#define ARC_TDEP_H
+#ifndef GDB_ARC_TDEP_H
+#define GDB_ARC_TDEP_H
 
 /* Need disassemble_info.  */
 #include "dis-asm.h"
@@ -205,4 +205,4 @@ CORE_ADDR arc_insn_get_linear_next_pc (const struct arc_instruction &insn);
 arc_arch_features arc_arch_features_create (const bfd *abfd,
 					    const unsigned long mach);
 
-#endif /* ARC_TDEP_H */
+#endif /* GDB_ARC_TDEP_H */
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 2dcd8f6dc53..d70d0b670c0 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_UTILS_H
-#define ARCH_UTILS_H
+#ifndef GDB_ARCH_UTILS_H
+#define GDB_ARCH_UTILS_H
 
 #include "gdbarch.h"
 
@@ -325,4 +325,4 @@ extern enum return_value_convention default_gdbarch_return_value
       struct regcache *regcache, struct value **read_value,
       const gdb_byte *writebuf);
 
-#endif /* ARCH_UTILS_H */
+#endif /* GDB_ARCH_UTILS_H */
diff --git a/gdb/arch/aarch32.h b/gdb/arch/aarch32.h
index 1811b8a7a92..f3e70affb0b 100644
--- a/gdb/arch/aarch32.h
+++ b/gdb/arch/aarch32.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH32_H
-#define ARCH_AARCH32_H
+#ifndef GDB_ARCH_AARCH32_H
+#define GDB_ARCH_AARCH32_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -24,4 +24,4 @@
 
 target_desc *aarch32_create_target_description (bool tls);
 
-#endif /* aarch32.h.  */
+#endif /* GDB_ARCH_AARCH32_H */
diff --git a/gdb/arch/aarch64-insn.h b/gdb/arch/aarch64-insn.h
index e4ee5c74fbf..bd3a85f9686 100644
--- a/gdb/arch/aarch64-insn.h
+++ b/gdb/arch/aarch64-insn.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_INSN_H
-#define ARCH_AARCH64_INSN_H
+#ifndef GDB_ARCH_AARCH64_INSN_H
+#define GDB_ARCH_AARCH64_INSN_H
 
 extern bool aarch64_debug;
 
@@ -356,4 +356,4 @@ int aarch64_emit_load_store (uint32_t *buf, uint32_t size,
 			     struct aarch64_register rn,
 			     struct aarch64_memory_operand operand);
 
-#endif /* ARCH_AARCH64_INSN_H */
+#endif /* GDB_ARCH_AARCH64_INSN_H */
diff --git a/gdb/arch/aarch64-mte-linux.h b/gdb/arch/aarch64-mte-linux.h
index 460b10e05c9..d917dd1b1e3 100644
--- a/gdb/arch/aarch64-mte-linux.h
+++ b/gdb/arch/aarch64-mte-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_MTE_LINUX_H
-#define ARCH_AARCH64_MTE_LINUX_H
+#ifndef GDB_ARCH_AARCH64_MTE_LINUX_H
+#define GDB_ARCH_AARCH64_MTE_LINUX_H
 
 
 /* Feature check for Memory Tagging Extension.  */
@@ -80,4 +80,4 @@ extern void aarch64_mte_pack_tags (gdb::byte_vector &tags);
    first unpacked element.  Otherwise leave it in the unpacked vector.  */
 extern void aarch64_mte_unpack_tags (gdb::byte_vector &tags, bool skip_first);
 
-#endif /* ARCH_AARCH64_MTE_LINUX_H */
+#endif /* GDB_ARCH_AARCH64_MTE_LINUX_H */
diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h
index 4d2ace8f153..886f4a2dee8 100644
--- a/gdb/arch/aarch64-scalable-linux.h
+++ b/gdb/arch/aarch64-scalable-linux.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_SCALABLE_LINUX_H
-#define ARCH_AARCH64_SCALABLE_LINUX_H
+#ifndef GDB_ARCH_AARCH64_SCALABLE_LINUX_H
+#define GDB_ARCH_AARCH64_SCALABLE_LINUX_H
 
 #include "gdbsupport/common-regcache.h"
 
@@ -55,4 +55,4 @@
    is empty (zero).  Return FALSE otherwise.  */
 extern bool sve_state_is_empty (const struct reg_buffer_common *reg_buf);
 
-#endif /* ARCH_AARCH64_SCALABLE_LINUX_H */
+#endif /* GDB_ARCH_AARCH64_SCALABLE_LINUX_H */
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index b4c0111aeb4..f45a0e2f13e 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AARCH64_H
-#define ARCH_AARCH64_H
+#ifndef GDB_ARCH_AARCH64_H
+#define GDB_ARCH_AARCH64_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -230,4 +230,4 @@ enum aarch64_regnum
 /* Size of the SME2 ZT0 register in bytes.  */
 #define AARCH64_SME2_ZT0_SIZE 64
 
-#endif /* ARCH_AARCH64_H */
+#endif /* GDB_ARCH_AARCH64_H */
diff --git a/gdb/arch/amd64.h b/gdb/arch/amd64.h
index 042d986a694..1c7a2bb26e9 100644
--- a/gdb/arch/amd64.h
+++ b/gdb/arch/amd64.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_AMD64_H
-#define ARCH_AMD64_H
+#ifndef GDB_ARCH_AMD64_H
+#define GDB_ARCH_AMD64_H
 
 #include "gdbsupport/tdesc.h"
 #include <stdint.h>
@@ -24,4 +24,4 @@
 target_desc *amd64_create_target_description (uint64_t xcr0, bool is_x32,
 					      bool is_linux, bool segments);
 
-#endif /* ARCH_AMD64_H */
+#endif /* GDB_ARCH_AMD64_H */
diff --git a/gdb/arch/arc.h b/gdb/arch/arc.h
index 1a5a9b6b492..887431ea12a 100644
--- a/gdb/arch/arc.h
+++ b/gdb/arch/arc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARC_H
-#define ARCH_ARC_H
+#ifndef GDB_ARCH_ARC_H
+#define GDB_ARCH_ARC_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -84,4 +84,4 @@ const target_desc *arc_lookup_target_description
 #endif /* GDBSERVER */
 
 
-#endif /* ARCH_ARC_H */
+#endif /* GDB_ARCH_ARC_H */
diff --git a/gdb/arch/arm-get-next-pcs.h b/gdb/arch/arm-get-next-pcs.h
index 77bf0b566a8..7680373c638 100644
--- a/gdb/arch/arm-get-next-pcs.h
+++ b/gdb/arch/arm-get-next-pcs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_GET_NEXT_PCS_H
-#define ARCH_ARM_GET_NEXT_PCS_H
+#ifndef GDB_ARCH_ARM_GET_NEXT_PCS_H
+#define GDB_ARCH_ARM_GET_NEXT_PCS_H
 
 #include <vector>
 
@@ -65,4 +65,4 @@ void arm_get_next_pcs_ctor (struct arm_get_next_pcs *self,
 /* Find the next possible PCs after the current instruction executes.  */
 std::vector<CORE_ADDR> arm_get_next_pcs (struct arm_get_next_pcs *self);
 
-#endif /* ARCH_ARM_GET_NEXT_PCS_H */
+#endif /* GDB_ARCH_ARM_GET_NEXT_PCS_H */
diff --git a/gdb/arch/arm-linux.h b/gdb/arch/arm-linux.h
index 68862521bbc..39c73c34011 100644
--- a/gdb/arch/arm-linux.h
+++ b/gdb/arch/arm-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_LINUX_H
-#define ARCH_ARM_LINUX_H
+#ifndef GDB_ARCH_ARM_LINUX_H
+#define GDB_ARCH_ARM_LINUX_H
 
 /* The index to access CSPR in user_regs defined in GLIBC.  */
 #define ARM_CPSR_GREGNUM 16
@@ -79,4 +79,4 @@ struct arm_get_next_pcs;
 CORE_ADDR arm_linux_get_next_pcs_fixup (struct arm_get_next_pcs *self,
 					CORE_ADDR pc);
 
-#endif /* ARCH_ARM_LINUX_H */
+#endif /* GDB_ARCH_ARM_LINUX_H */
diff --git a/gdb/arch/arm.h b/gdb/arch/arm.h
index 34cf7ca79cf..7738d9c6611 100644
--- a/gdb/arch/arm.h
+++ b/gdb/arch/arm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_ARM_H
-#define ARCH_ARM_H
+#ifndef GDB_ARCH_ARM_H
+#define GDB_ARCH_ARM_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -227,4 +227,4 @@ target_desc *arm_create_target_description (arm_fp_type fp_type, bool tls);
 
 target_desc *arm_create_mprofile_target_description (arm_m_profile_type m_type);
 
-#endif /* ARCH_ARM_H */
+#endif /* GDB_ARCH_ARM_H */
diff --git a/gdb/arch/csky.h b/gdb/arch/csky.h
index 290bf97dd12..67b2f176114 100644
--- a/gdb/arch/csky.h
+++ b/gdb/arch/csky.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_CSKY_H
-#define ARCH_CSKY_H
+#ifndef GDB_ARCH_CSKY_H
+#define GDB_ARCH_CSKY_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -26,4 +26,4 @@
 
 target_desc_up csky_create_target_description (void);
 
-#endif /* ARCH_CSKY_H */
+#endif /* GDB_ARCH_CSKY_H */
diff --git a/gdb/arch/i386.h b/gdb/arch/i386.h
index d0519f1b551..1b5cc6e1095 100644
--- a/gdb/arch/i386.h
+++ b/gdb/arch/i386.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_I386_H
-#define ARCH_I386_H
+#ifndef GDB_ARCH_I386_H
+#define GDB_ARCH_I386_H
 
 #include "gdbsupport/tdesc.h"
 #include <stdint.h>
@@ -24,4 +24,4 @@
 target_desc *i386_create_target_description (uint64_t xcr0, bool is_linux,
 					     bool segments);
 
-#endif /* ARCH_I386_H */
+#endif /* GDB_ARCH_I386_H */
diff --git a/gdb/arch/loongarch.h b/gdb/arch/loongarch.h
index 7056d506bf4..07f37d8d7e8 100644
--- a/gdb/arch/loongarch.h
+++ b/gdb/arch/loongarch.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_LOONGARCH_H
-#define ARCH_LOONGARCH_H
+#ifndef GDB_ARCH_LOONGARCH_H
+#define GDB_ARCH_LOONGARCH_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -128,4 +128,4 @@ const target_desc *loongarch_lookup_target_description
 
 #endif /* GDBSERVER */
 
-#endif /* ARCH_LOONGARCH_H  */
+#endif /* GDB_ARCH_LOONGARCH_H */
diff --git a/gdb/arch/ppc-linux-common.h b/gdb/arch/ppc-linux-common.h
index 05704c8f898..1f72b295de8 100644
--- a/gdb/arch/ppc-linux-common.h
+++ b/gdb/arch/ppc-linux-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_PPC_LINUX_COMMON_H
-#define ARCH_PPC_LINUX_COMMON_H
+#ifndef GDB_ARCH_PPC_LINUX_COMMON_H
+#define GDB_ARCH_PPC_LINUX_COMMON_H
 
 struct target_desc;
 
@@ -75,4 +75,4 @@ const struct ppc_linux_features ppc_linux_no_features = {
 const struct target_desc * ppc_linux_match_description
 (struct ppc_linux_features features);
 
-#endif /* ARCH_PPC_LINUX_COMMON_H */
+#endif /* GDB_ARCH_PPC_LINUX_COMMON_H */
diff --git a/gdb/arch/ppc-linux-tdesc.h b/gdb/arch/ppc-linux-tdesc.h
index 0a022071c08..bde6ba225bd 100644
--- a/gdb/arch/ppc-linux-tdesc.h
+++ b/gdb/arch/ppc-linux-tdesc.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_PPC_LINUX_TDESC_H
-#define ARCH_PPC_LINUX_TDESC_H
+#ifndef GDB_ARCH_PPC_LINUX_TDESC_H
+#define GDB_ARCH_PPC_LINUX_TDESC_H
 
 struct target_desc;
 
@@ -43,4 +43,4 @@ extern const struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l;
 extern const struct target_desc *tdesc_powerpc_isa207_vsx64l;
 extern const struct target_desc *tdesc_powerpc_isa207_htm_vsx64l;
 
-#endif /* ARCH_PPC_LINUX_TDESC_H */
+#endif /* GDB_ARCH_PPC_LINUX_TDESC_H */
diff --git a/gdb/arch/riscv.h b/gdb/arch/riscv.h
index 925fffee18a..bf65b0bc5a8 100644
--- a/gdb/arch/riscv.h
+++ b/gdb/arch/riscv.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_RISCV_H
-#define ARCH_RISCV_H
+#ifndef GDB_ARCH_RISCV_H
+#define GDB_ARCH_RISCV_H
 
 #include "gdbsupport/tdesc.h"
 
@@ -119,4 +119,4 @@ const target_desc *riscv_lookup_target_description
 #endif /* GDBSERVER */
 
 
-#endif /* ARCH_RISCV_H */
+#endif /* GDB_ARCH_RISCV_H */
diff --git a/gdb/arch/tic6x.h b/gdb/arch/tic6x.h
index da67da7c5fb..efb3282c506 100644
--- a/gdb/arch/tic6x.h
+++ b/gdb/arch/tic6x.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_TIC6X_H
-#define ARCH_TIC6X_H
+#ifndef GDB_ARCH_TIC6X_H
+#define GDB_ARCH_TIC6X_H
 
 enum c6x_feature
 {
@@ -28,4 +28,4 @@ enum c6x_feature
 
 target_desc *tic6x_create_target_description (enum c6x_feature feature);
 
-#endif /* ARCH_TIC6X_H */
+#endif /* GDB_ARCH_TIC6X_H */
diff --git a/gdb/arch/xtensa.h b/gdb/arch/xtensa.h
index 5961641cad8..70167b304ce 100644
--- a/gdb/arch/xtensa.h
+++ b/gdb/arch/xtensa.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARCH_XTENSA_H
-#define ARCH_XTENSA_H
+#ifndef GDB_ARCH_XTENSA_H
+#define GDB_ARCH_XTENSA_H
 
 /* Xtensa ELF core file register set representation ('.reg' section).
    Copied from target-side ELF header <xtensa/elf.h>.  */
@@ -45,4 +45,4 @@ typedef struct
 
 #define C0_NREGS   16	/* Number of A-registers to track in call0 ABI.  */
 
-#endif /* ARCH_XTENSA_H */
+#endif /* GDB_ARCH_XTENSA_H */
diff --git a/gdb/arm-fbsd-tdep.h b/gdb/arm-fbsd-tdep.h
index 26a9dbcdd21..151f26c83b7 100644
--- a/gdb/arm-fbsd-tdep.h
+++ b/gdb/arm-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_FBSD_TDEP_H
-#define ARM_FBSD_TDEP_H
+#ifndef GDB_ARM_FBSD_TDEP_H
+#define GDB_ARM_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -56,4 +56,4 @@ extern const struct target_desc *
 extern const struct target_desc *
   arm_fbsd_read_description_auxv (bool tls);
 
-#endif /* ARM_FBSD_TDEP_H */
+#endif /* GDB_ARM_FBSD_TDEP_H */
diff --git a/gdb/arm-linux-tdep.h b/gdb/arm-linux-tdep.h
index a6eeb333351..7aa69ce3f4c 100644
--- a/gdb/arm-linux-tdep.h
+++ b/gdb/arm-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_LINUX_TDEP_H
-#define ARM_LINUX_TDEP_H
+#ifndef GDB_ARM_LINUX_TDEP_H
+#define GDB_ARM_LINUX_TDEP_H
 
 struct regset;
 struct regcache;
@@ -67,4 +67,4 @@ void arm_linux_collect_nwfpe (const struct regset *regset,
 #define HWCAP_VFPv3     8192
 #define HWCAP_VFPv3D16  16384
 
-#endif /* ARM_LINUX_TDEP_H */
+#endif /* GDB_ARM_LINUX_TDEP_H */
diff --git a/gdb/arm-netbsd-tdep.h b/gdb/arm-netbsd-tdep.h
index 75b1fb9bd27..6e554d4ca21 100644
--- a/gdb/arm-netbsd-tdep.h
+++ b/gdb/arm-netbsd-tdep.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_NBSD_TDEP_H
-#define ARM_NBSD_TDEP_H
+#ifndef GDB_ARM_NETBSD_TDEP_H
+#define GDB_ARM_NETBSD_TDEP_H
 
 void arm_nbsd_supply_gregset
   (const struct regset *regset, struct regcache *regcache,
    int regnum, const void *gregs, size_t len);
 
-#endif
+#endif /* GDB_ARM_NETBSD_TDEP_H */
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 11839b0ff4d..f8049f4673c 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ARM_TDEP_H
-#define ARM_TDEP_H
+#ifndef GDB_ARM_TDEP_H
+#define GDB_ARM_TDEP_H
 
 /* Forward declarations.  */
 struct regset;
@@ -326,4 +326,4 @@ const target_desc *arm_read_description (arm_fp_type fp_type, bool tls);
    type.  */
 const target_desc *arm_read_mprofile_description (arm_m_profile_type m_type);
 
-#endif /* arm-tdep.h */
+#endif /* GDB_ARM_TDEP_H */
diff --git a/gdb/async-event.h b/gdb/async-event.h
index 1027f9d6fb3..16045f42448 100644
--- a/gdb/async-event.h
+++ b/gdb/async-event.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef ASYNC_EVENT_H
-#define ASYNC_EVENT_H
+#ifndef GDB_ASYNC_EVENT_H
+#define GDB_ASYNC_EVENT_H
 
 #include "gdbsupport/event-loop.h"
 
@@ -87,4 +87,4 @@ extern void clear_async_event_handler (struct async_event_handler *handler);
 
 extern void initialize_async_signal_handlers (void);
 
-#endif /* ASYNC_EVENT_H */
+#endif /* GDB_ASYNC_EVENT_H */
diff --git a/gdb/auto-load.h b/gdb/auto-load.h
index c1003aef0e3..48e6ccfc82f 100644
--- a/gdb/auto-load.h
+++ b/gdb/auto-load.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AUTO_LOAD_H
-#define AUTO_LOAD_H 1
+#ifndef GDB_AUTO_LOAD_H
+#define GDB_AUTO_LOAD_H
 
 struct objfile;
 struct program_space;
@@ -79,4 +79,4 @@ extern bool file_is_auto_load_safe (const char *filename);
 extern bool auto_load_gdb_scripts_enabled
   (const struct extension_language_defn *extlang);
 
-#endif /* AUTO_LOAD_H */
+#endif /* GDB_AUTO_LOAD_H */
diff --git a/gdb/auxv.h b/gdb/auxv.h
index aed430dd851..3faddff7771 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AUXV_H
-#define AUXV_H
+#ifndef GDB_AUXV_H
+#define GDB_AUXV_H
 
 #include "target.h"
 
@@ -88,4 +88,4 @@ extern void default_print_auxv_entry (struct gdbarch *gdbarch,
 extern target_xfer_partial_ftype memory_xfer_auxv;
 
 
-#endif
+#endif /* GDB_AUXV_H */
diff --git a/gdb/ax-gdb.h b/gdb/ax-gdb.h
index 9e2dfea1c51..53f48ff9e33 100644
--- a/gdb/ax-gdb.h
+++ b/gdb/ax-gdb.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AX_GDB_H
-#define AX_GDB_H
+#ifndef GDB_AX_GDB_H
+#define GDB_AX_GDB_H
 
 #include "ax.h"
 
@@ -123,4 +123,4 @@ extern agent_expr_up gen_printf (CORE_ADDR, struct gdbarch *,
 				 CORE_ADDR, LONGEST, const char *, int,
 				 int, struct expression **);
 
-#endif /* AX_GDB_H */
+#endif /* GDB_AX_GDB_H */
diff --git a/gdb/ax.h b/gdb/ax.h
index 46c2393f9e0..45fd560927b 100644
--- a/gdb/ax.h
+++ b/gdb/ax.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef AX_H
-#define AX_H
+#ifndef GDB_AX_H
+#define GDB_AX_H
 
 /* It's sometimes useful to be able to debug programs that you can't
    really stop for more than a fraction of a second.  To this end, the
@@ -224,4 +224,4 @@ extern void ax_print (struct ui_file *f, struct agent_expr * EXPR);
 
 extern void ax_reqs (struct agent_expr *ax);
 
-#endif /* AX_H */
+#endif /* GDB_AX_H */
diff --git a/gdb/bcache.h b/gdb/bcache.h
index 17a09880d99..abe9e58c116 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BCACHE_H
-#define BCACHE_H 1
+#ifndef GDB_BCACHE_H
+#define GDB_BCACHE_H
 
 /* A bcache is a data structure for factoring out duplication in
    read-only structures.  You give the bcache some string of bytes S.
@@ -207,4 +207,4 @@ struct bcache
 
 } /* namespace gdb */
 
-#endif /* BCACHE_H */
+#endif /* GDB_BCACHE_H */
diff --git a/gdb/bfd-target.h b/gdb/bfd-target.h
index d20c9263c4b..ab3233e8f6f 100644
--- a/gdb/bfd-target.h
+++ b/gdb/bfd-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BFD_TARGET_H
-#define BFD_TARGET_H
+#ifndef GDB_BFD_TARGET_H
+#define GDB_BFD_TARGET_H
 
 #include "gdb_bfd.h"
 
@@ -27,4 +27,4 @@ struct target_ops;
 /* Given an existing BFD, re-open it as a "struct target_ops".  */
 target_ops_up target_bfd_reopen (const gdb_bfd_ref_ptr &bfd);
 
-#endif
+#endif /* GDB_BFD_TARGET_H */
diff --git a/gdb/bfin-tdep.h b/gdb/bfin-tdep.h
index dbdafae9d45..d28af50406f 100644
--- a/gdb/bfin-tdep.h
+++ b/gdb/bfin-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BFIN_TDEP_H
-#define BFIN_TDEP_H
+#ifndef GDB_BFIN_TDEP_H
+#define GDB_BFIN_TDEP_H
 
 #include "gdbarch.h"
 
@@ -105,4 +105,4 @@ struct bfin_gdbarch_tdep : gdbarch_tdep_base
 /* Return the Blackfin ABI associated with GDBARCH.  */
 extern enum bfin_abi bfin_abi (struct gdbarch *gdbarch);
 
-#endif /* BFIN_TDEP_H */
+#endif /* GDB_BFIN_TDEP_H */
diff --git a/gdb/block.h b/gdb/block.h
index ae676c4ba67..0cc4d7d53f7 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BLOCK_H
-#define BLOCK_H
+#ifndef GDB_BLOCK_H
+#define GDB_BLOCK_H
 
 #include "dictionary.h"
 #include "gdbsupport/array-view.h"
@@ -592,4 +592,4 @@ extern struct symbol *block_find_symbol (const struct block *block,
 struct blockranges *make_blockranges (struct objfile *objfile,
 				      const std::vector<blockrange> &rangevec);
 
-#endif /* BLOCK_H */
+#endif /* GDB_BLOCK_H */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 6da04d5ec00..4db18274e55 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (BREAKPOINT_H)
-#define BREAKPOINT_H 1
+#ifndef GDB_BREAKPOINT_H
+#define GDB_BREAKPOINT_H
 
 #include "frame.h"
 #include "value.h"
@@ -2068,4 +2068,4 @@ extern void enable_disable_bp_location (bp_location *loc, bool enable);
 
 extern void notify_breakpoint_modified (breakpoint *b);
 
-#endif /* !defined (BREAKPOINT_H) */
+#endif /* GDB_BREAKPOINT_H */
diff --git a/gdb/bsd-kvm.h b/gdb/bsd-kvm.h
index 1606eb3acea..6ddd154da4a 100644
--- a/gdb/bsd-kvm.h
+++ b/gdb/bsd-kvm.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BSD_KVM_H
-#define BSD_KVM_H
+#ifndef GDB_BSD_KVM_H
+#define GDB_BSD_KVM_H
 
 struct pcb;
 struct regcache;
@@ -30,4 +30,4 @@ struct regcache;
 extern void
   bsd_kvm_add_target (int (*supply_pcb)(struct regcache *, struct pcb *));
 
-#endif /* bsd-kvm.h */
+#endif /* GDB_BSD_KVM_H */
diff --git a/gdb/bsd-uthread.h b/gdb/bsd-uthread.h
index eabd82dbdaf..e236eaae4f6 100644
--- a/gdb/bsd-uthread.h
+++ b/gdb/bsd-uthread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BSD_UTHREAD_H
-#define BSD_UTHREAD_H 1
+#ifndef GDB_BSD_UTHREAD_H
+#define GDB_BSD_UTHREAD_H
 
 /* Set the function that supplies registers for an inactive thread for
    architecture GDBARCH to SUPPLY_UTHREAD.  */
@@ -35,4 +35,4 @@ extern void bsd_uthread_set_collect_uthread (struct gdbarch *gdbarch,
 			     void (*collect_uthread) (const struct regcache *,
 						      int, CORE_ADDR));
 
-#endif /* bsd-uthread.h */
+#endif /* GDB_BSD_UTHREAD_H */
diff --git a/gdb/bt-utils.h b/gdb/bt-utils.h
index ec2d14a5484..819dd8caf86 100644
--- a/gdb/bt-utils.h
+++ b/gdb/bt-utils.h
@@ -18,8 +18,8 @@
 /* Support for printing a backtrace when GDB hits an error.  This is not
    for printing backtraces of the inferior, but backtraces of GDB itself.  */
 
-#ifndef BT_UTILS_H
-#define BT_UTILS_H
+#ifndef GDB_BT_UTILS_H
+#define GDB_BT_UTILS_H
 
 #ifdef HAVE_LIBBACKTRACE
 # include "backtrace.h"
@@ -71,4 +71,4 @@ extern void gdb_internal_backtrace ();
 extern void gdb_internal_backtrace_set_cmd (const char *args, int from_tty,
 					    cmd_list_element *c);
 
-#endif /* BT_UTILS_H */
+#endif /* GDB_BT_UTILS_H */
diff --git a/gdb/btrace.h b/gdb/btrace.h
index f05ec2bca04..dc9541960e0 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BTRACE_H
-#define BTRACE_H
+#ifndef GDB_BTRACE_H
+#define GDB_BTRACE_H
 
 /* Branch tracing (btrace) is a per-thread control-flow execution trace of the
    inferior.  For presentation purposes, the branch trace is represented as a
@@ -498,4 +498,4 @@ extern int btrace_is_replaying (struct thread_info *tp);
 /* Return non-zero if the branch trace for TP is empty; zero otherwise.  */
 extern int btrace_is_empty (struct thread_info *tp);
 
-#endif /* BTRACE_H */
+#endif /* GDB_BTRACE_H */
diff --git a/gdb/build-id.h b/gdb/build-id.h
index 15bd8a964dc..5bf338299b1 100644
--- a/gdb/build-id.h
+++ b/gdb/build-id.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BUILD_ID_H
-#define BUILD_ID_H
+#ifndef GDB_BUILD_ID_H
+#define GDB_BUILD_ID_H
 
 #include "gdb_bfd.h"
 #include "gdbsupport/rsp-low.h"
@@ -70,4 +70,4 @@ build_id_to_string (const bfd_build_id *build_id)
   return bin2hex (build_id->data, build_id->size);
 }
 
-#endif /* BUILD_ID_H */
+#endif /* GDB_BUILD_ID_H */
diff --git a/gdb/buildsym-legacy.h b/gdb/buildsym-legacy.h
index 1fb545831b8..1f032c42751 100644
--- a/gdb/buildsym-legacy.h
+++ b/gdb/buildsym-legacy.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef BUILDSYM_LEGACY_H
-#define BUILDSYM_LEGACY_H
+#ifndef GDB_BUILDSYM_LEGACY_H
+#define GDB_BUILDSYM_LEGACY_H
 
 #include "buildsym.h"
 
@@ -144,4 +144,4 @@ extern struct pending **get_global_symbols ();
 
 extern struct buildsym_compunit *get_buildsym_compunit ();
 
-#endif /* BUILDSYM_LEGACY_H */
+#endif /* GDB_BUILDSYM_LEGACY_H */
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index c1eed247d25..974645c1c47 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (BUILDSYM_H)
-#define BUILDSYM_H 1
+#ifndef GDB_BUILDSYM_H
+#define GDB_BUILDSYM_H
 
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
@@ -456,4 +456,4 @@ extern void add_symbol_to_list (struct symbol *symbol,
 extern struct symbol *find_symbol_in_list (struct pending *list,
 					   char *name, int length);
 
-#endif /* defined (BUILDSYM_H) */
+#endif /* GDB_BUILDSYM_H */
diff --git a/gdb/c-exp.h b/gdb/c-exp.h
index a76f1bc8213..a6c084d32be 100644
--- a/gdb/c-exp.h
+++ b/gdb/c-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef C_EXP_H
-#define C_EXP_H
+#ifndef GDB_C_EXP_H
+#define GDB_C_EXP_H
 
 #include "expop.h"
 #include "objc-lang.h"
@@ -217,4 +217,4 @@ class opencl_ternop_cond_operation
 
 }/* namespace expr */
 
-#endif /* C_EXP_H */
+#endif /* GDB_C_EXP_H */
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 8dc47ac8be5..0e733d810d8 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#if !defined (C_LANG_H)
-#define C_LANG_H 1
+#ifndef GDB_C_LANG_H
+#define GDB_C_LANG_H
 
 struct ui_file;
 struct language_arch_info;
@@ -174,4 +174,4 @@ extern std::string cplus_compute_program (compile_instance *inst,
 
 extern gdb::unique_xmalloc_ptr<char> c_canonicalize_name (const char *name);
 
-#endif /* !defined (C_LANG_H) */
+#endif /* GDB_C_LANG_H */
diff --git a/gdb/c-support.h b/gdb/c-support.h
index 3718181ba81..30858d1e1af 100644
--- a/gdb/c-support.h
+++ b/gdb/c-support.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef C_SUPPORT_H
-#define C_SUPPORT_H
+#ifndef GDB_C_SUPPORT_H
+#define GDB_C_SUPPORT_H
 
 #include "safe-ctype.h"
 
@@ -43,4 +43,4 @@ c_ident_is_alnum (unsigned char ch)
   return ISALNUM (ch) || ch >= 0x80;
 }
 
-#endif /* C_SUPPORT_H */
+#endif /* GDB_C_SUPPORT_H */
diff --git a/gdb/cgen-remap.h b/gdb/cgen-remap.h
index 35f09c1269b..30b84575263 100644
--- a/gdb/cgen-remap.h
+++ b/gdb/cgen-remap.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CGEN_REMAP_H
-#define CGEN_REMAP_H
+#ifndef GDB_CGEN_REMAP_H
+#define GDB_CGEN_REMAP_H
 
 /* Remap cgen interface names, so we can have multiple cgen generated include
    files in gdb without violating c++ ODR.  */
@@ -50,4 +50,4 @@
 #define CGEN_OPERAND		GDB_CGEN_REMAP (CGEN_OPERAND)
 #define CGEN_MAYBE_MULTI_IFLD	GDB_CGEN_REMAP (CGEN_MAYBE_MULTI_IFLD)
 
-#endif /* CGEN_REMAP_H */
+#endif /* GDB_CGEN_REMAP_H */
diff --git a/gdb/charset-list.h b/gdb/charset-list.h
index c4d0867d580..9da3da2590a 100644
--- a/gdb/charset-list.h
+++ b/gdb/charset-list.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CHARSET_LIST_H
-#define CHARSET_LIST_H
+#ifndef GDB_CHARSET_LIST_H
+#define GDB_CHARSET_LIST_H
 
 /* Note that the first entry must always be "auto".
    The remaining entries were created by running this script:
@@ -1192,4 +1192,4 @@
 "WS2", \
 "YU",
 
-#endif /* CHARSET_LIST_H */
+#endif /* GDB_CHARSET_LIST_H */
diff --git a/gdb/charset.h b/gdb/charset.h
index 4263dc147e9..c4e0de553d3 100644
--- a/gdb/charset.h
+++ b/gdb/charset.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CHARSET_H
-#define CHARSET_H
+#ifndef GDB_CHARSET_H
+#define GDB_CHARSET_H
 
 #include "gdbsupport/def-vector.h"
 
@@ -165,4 +165,4 @@ char host_letter_to_control_character (char c);
 #define HOST_UTF32 "UTF-32LE"
 #endif
 
-#endif /* CHARSET_H */
+#endif /* GDB_CHARSET_H */
diff --git a/gdb/cli-out.h b/gdb/cli-out.h
index f17cb0c9856..5799df559f4 100644
--- a/gdb/cli-out.h
+++ b/gdb/cli-out.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_OUT_H
-#define CLI_OUT_H
+#ifndef GDB_CLI_OUT_H
+#define GDB_CLI_OUT_H
 
 #include "ui-out.h"
 #include <chrono>
@@ -112,4 +112,4 @@ class cli_ui_out : public ui_out
 
 extern void cli_display_match_list (char **matches, int len, int max);
 
-#endif
+#endif /* GDB_CLI_OUT_H */
diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h
index 8f26ca3e17a..6719ad7cae3 100644
--- a/gdb/cli/cli-cmds.h
+++ b/gdb/cli/cli-cmds.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_CMDS_H
-#define CLI_CLI_CMDS_H
+#ifndef GDB_CLI_CLI_CMDS_H
+#define GDB_CLI_CLI_CMDS_H
 
 #include "gdbsupport/filestuff.h"
 #include <optional>
@@ -202,4 +202,4 @@ extern void with_command_completer_1 (const char *set_cmd_prefix,
 				      completion_tracker &tracker,
 				      const char *text);
 
-#endif /* CLI_CLI_CMDS_H */
+#endif /* GDB_CLI_CLI_CMDS_H */
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 7365c3f0157..2219d62fbf3 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_DECODE_H
-#define CLI_CLI_DECODE_H
+#ifndef GDB_CLI_CLI_DECODE_H
+#define GDB_CLI_CLI_DECODE_H
 
 /* This file defines the private interfaces for any code implementing
    command internals.  */
@@ -313,4 +313,4 @@ extern int cli_user_command_p (struct cmd_list_element *);
 
 extern int find_command_name_length (const char *);
 
-#endif /* CLI_CLI_DECODE_H */
+#endif /* GDB_CLI_CLI_DECODE_H */
diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h
index 137eb466f6b..fc3dee7b68b 100644
--- a/gdb/cli/cli-interp.h
+++ b/gdb/cli/cli-interp.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_INTERP_H
-#define CLI_CLI_INTERP_H
+#ifndef GDB_CLI_CLI_INTERP_H
+#define GDB_CLI_CLI_INTERP_H
 
 #include "interps.h"
 
@@ -69,4 +69,4 @@ class cli_interp_base : public interp
 extern int should_print_stop_to_console (struct interp *interp,
 					 struct thread_info *tp);
 
-#endif /* CLI_CLI_INTERP_H */
+#endif /* GDB_CLI_CLI_INTERP_H */
diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h
index bbe281d9721..35e5bdcd684 100644
--- a/gdb/cli/cli-option.h
+++ b/gdb/cli/cli-option.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_OPTION_H
-#define CLI_OPTION_H 1
+#ifndef GDB_CLI_CLI_OPTION_H
+#define GDB_CLI_CLI_OPTION_H
 
 #include <optional>
 #include "gdbsupport/array-view.h"
@@ -379,4 +379,4 @@ extern void add_setshow_cmds_for_options (command_class cmd_class, void *data,
 } /* namespace option */
 } /* namespace gdb */
 
-#endif /* CLI_OPTION_H */
+#endif /* GDB_CLI_CLI_OPTION_H */
diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h
index d36743e5a31..1f0cfd3c1dd 100644
--- a/gdb/cli/cli-script.h
+++ b/gdb/cli/cli-script.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_SCRIPT_H
-#define CLI_CLI_SCRIPT_H
+#ifndef GDB_CLI_CLI_SCRIPT_H
+#define GDB_CLI_CLI_SCRIPT_H
 
 #include "gdbsupport/function-view.h"
 
@@ -181,4 +181,4 @@ extern void print_command_trace (const char *cmd, ...)
 
 extern void reset_command_nest_depth (void);
 
-#endif /* CLI_CLI_SCRIPT_H */
+#endif /* GDB_CLI_CLI_SCRIPT_H */
diff --git a/gdb/cli/cli-setshow.h b/gdb/cli/cli-setshow.h
index 4b8875d5794..9eac86fc674 100644
--- a/gdb/cli/cli-setshow.h
+++ b/gdb/cli/cli-setshow.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_SETSHOW_H
-#define CLI_CLI_SETSHOW_H
+#ifndef GDB_CLI_CLI_SETSHOW_H
+#define GDB_CLI_CLI_SETSHOW_H
 
 #include <string>
 
@@ -60,4 +60,4 @@ extern std::string get_setshow_command_value_string (const setting &var);
 
 extern void cmd_show_list (struct cmd_list_element *list, int from_tty);
 
-#endif /* CLI_CLI_SETSHOW_H */
+#endif /* GDB_CLI_CLI_SETSHOW_H */
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index 31d40ed65ca..1a9c8e65b60 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_STYLE_H
-#define CLI_CLI_STYLE_H
+#ifndef GDB_CLI_CLI_STYLE_H
+#define GDB_CLI_CLI_STYLE_H
 
 #include "ui-file.h"
 #include "command.h"
@@ -150,4 +150,4 @@ extern bool disassembler_styling;
 /* True if styling is enabled.  */
 extern bool cli_styling;
 
-#endif /* CLI_CLI_STYLE_H */
+#endif /* GDB_CLI_CLI_STYLE_H */
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index 54b45fdc796..e11430ecb70 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_CLI_UTILS_H
-#define CLI_CLI_UTILS_H
+#ifndef GDB_CLI_CLI_UTILS_H
+#define GDB_CLI_CLI_UTILS_H
 
 #include "completer.h"
 
@@ -225,4 +225,4 @@ struct qcs_flags
    message.  */
 extern void validate_flags_qcs (const char *which_command, qcs_flags *flags);
 
-#endif /* CLI_CLI_UTILS_H */
+#endif /* GDB_CLI_CLI_UTILS_H */
diff --git a/gdb/coff-pe-read.h b/gdb/coff-pe-read.h
index d596240f97d..c1510460f9b 100644
--- a/gdb/coff-pe-read.h
+++ b/gdb/coff-pe-read.h
@@ -19,8 +19,8 @@
 
    Contributed by Raoul M. Gough (RaoulGough@yahoo.co.uk).  */
 
-#if !defined (COFF_PE_READ_H)
-#define COFF_PE_READ_H
+#ifndef GDB_COFF_PE_READ_H
+#define GDB_COFF_PE_READ_H
 
 class minimal_symbol_reader;
 struct objfile;
@@ -35,4 +35,4 @@ extern void read_pe_exported_syms (minimal_symbol_reader &reader,
    Returns default value 0x1000 if information is not found.  */
 extern CORE_ADDR pe_text_section_offset (struct bfd *abfd);
 
-#endif /* !defined (COFF_PE_READ_H) */
+#endif /* GDB_COFF_PE_READ_H */
diff --git a/gdb/command.h b/gdb/command.h
index 615f4e524aa..4f83d3515c3 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (COMMAND_H)
-#define COMMAND_H 1
+#ifndef GDB_COMMAND_H
+#define GDB_COMMAND_H
 
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbsupport/scoped_restore.h"
@@ -934,4 +934,4 @@ extern void not_just_help_class_command (const char *, int);
 extern void cmd_func (struct cmd_list_element *cmd,
 		      const char *args, int from_tty);
 
-#endif /* !defined (COMMAND_H) */
+#endif /* GDB_COMMAND_H */
diff --git a/gdb/compile/compile-c.h b/gdb/compile/compile-c.h
index 4670d671a9f..b77b7aab087 100644
--- a/gdb/compile/compile-c.h
+++ b/gdb/compile/compile-c.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_C_H
-#define COMPILE_COMPILE_C_H
+#ifndef GDB_COMPILE_COMPILE_C_H
+#define GDB_COMPILE_COMPILE_C_H
 
 #include "compile/compile.h"
 #include "gdbsupport/enum-flags.h"
@@ -93,4 +93,4 @@ extern std::string c_get_range_decl_name (const struct dynamic_prop *prop);
 extern gdb::unique_xmalloc_ptr<char>
   c_symbol_substitution_name (struct symbol *sym);
 
-#endif /* COMPILE_COMPILE_C_H */
+#endif /* GDB_COMPILE_COMPILE_C_H */
diff --git a/gdb/compile/compile-cplus.h b/gdb/compile/compile-cplus.h
index a714b6dab3c..d3b2d3e9843 100644
--- a/gdb/compile/compile-cplus.h
+++ b/gdb/compile/compile-cplus.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_CPLUS_H
-#define COMPILE_COMPILE_CPLUS_H
+#ifndef GDB_COMPILE_COMPILE_CPLUS_H
+#define GDB_COMPILE_COMPILE_CPLUS_H
 
 #include "compile/compile.h"
 #include "gdbsupport/enum-flags.h"
@@ -204,4 +204,4 @@ class compile_cplus_instance : public compile_instance
 enum gcc_cp_symbol_kind get_method_access_flag (const struct type *type,
 						int fni, int num);
 
-#endif /* COMPILE_COMPILE_CPLUS_H */
+#endif /* GDB_COMPILE_COMPILE_CPLUS_H */
diff --git a/gdb/compile/compile-internal.h b/gdb/compile/compile-internal.h
index 666406b2395..f4cc9ee4984 100644
--- a/gdb/compile/compile-internal.h
+++ b/gdb/compile/compile-internal.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_INTERNAL_H
-#define COMPILE_COMPILE_INTERNAL_H
+#ifndef GDB_COMPILE_COMPILE_INTERNAL_H
+#define GDB_COMPILE_COMPILE_INTERNAL_H
 
 #include "gcc-c-interface.h"
 #include "gdbsupport/gdb-hashtab.h"
@@ -80,4 +80,4 @@ class compile_file_names
   std::string m_object_file;
 };
 
-#endif /* COMPILE_COMPILE_INTERNAL_H */
+#endif /* GDB_COMPILE_COMPILE_INTERNAL_H */
diff --git a/gdb/compile/compile-object-load.h b/gdb/compile/compile-object-load.h
index eb6eb0dd871..bb414f90df4 100644
--- a/gdb/compile/compile-object-load.h
+++ b/gdb/compile/compile-object-load.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_OBJECT_LOAD_H
-#define COMPILE_COMPILE_OBJECT_LOAD_H
+#ifndef GDB_COMPILE_COMPILE_OBJECT_LOAD_H
+#define GDB_COMPILE_COMPILE_OBJECT_LOAD_H
 
 #include "compile-internal.h"
 #include <list>
@@ -94,4 +94,4 @@ extern compile_module_up compile_object_load
   (const compile_file_names &fnames,
    enum compile_i_scope_types scope, void *scope_data);
 
-#endif /* COMPILE_COMPILE_OBJECT_LOAD_H */
+#endif /* GDB_COMPILE_COMPILE_OBJECT_LOAD_H */
diff --git a/gdb/compile/compile-object-run.h b/gdb/compile/compile-object-run.h
index 5d9f23c6a39..64b2bd90a99 100644
--- a/gdb/compile/compile-object-run.h
+++ b/gdb/compile/compile-object-run.h
@@ -14,11 +14,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_OBJECT_RUN_H
-#define COMPILE_COMPILE_OBJECT_RUN_H
+#ifndef GDB_COMPILE_COMPILE_OBJECT_RUN_H
+#define GDB_COMPILE_COMPILE_OBJECT_RUN_H
 
 #include "compile-object-load.h"
 
 extern void compile_object_run (compile_module_up &&module);
 
-#endif /* COMPILE_COMPILE_OBJECT_RUN_H */
+#endif /* GDB_COMPILE_COMPILE_OBJECT_RUN_H */
diff --git a/gdb/compile/compile.h b/gdb/compile/compile.h
index d584df6661c..14b97c4b91c 100644
--- a/gdb/compile/compile.h
+++ b/gdb/compile/compile.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_COMPILE_H
-#define COMPILE_COMPILE_H
+#ifndef GDB_COMPILE_COMPILE_H
+#define GDB_COMPILE_COMPILE_H
 
 #include "gcc-c-interface.h"
 
@@ -231,4 +231,4 @@ extern void compile_print_value (struct value *val, void *data_voidp);
 /* Command element for the 'compile' command.  */
 extern cmd_list_element *compile_cmd_element;
 
-#endif /* COMPILE_COMPILE_H */
+#endif /* GDB_COMPILE_COMPILE_H */
diff --git a/gdb/compile/gcc-c-plugin.h b/gdb/compile/gcc-c-plugin.h
index 4008807526b..d12472f01c1 100644
--- a/gdb/compile/gcc-c-plugin.h
+++ b/gdb/compile/gcc-c-plugin.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_GCC_C_PLUGIN_H
-#define COMPILE_GCC_C_PLUGIN_H
+#ifndef GDB_COMPILE_GCC_C_PLUGIN_H
+#define GDB_COMPILE_GCC_C_PLUGIN_H
 
 #include "compile-internal.h"
 
@@ -68,4 +68,4 @@ class gcc_c_plugin
   struct gcc_c_context *m_context;
 };
 
-#endif /* COMPILE_GCC_C_PLUGIN_H */
+#endif /* GDB_COMPILE_GCC_C_PLUGIN_H */
diff --git a/gdb/compile/gcc-cp-plugin.h b/gdb/compile/gcc-cp-plugin.h
index cf8ccd90725..8f369934127 100644
--- a/gdb/compile/gcc-cp-plugin.h
+++ b/gdb/compile/gcc-cp-plugin.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMPILE_GCC_CP_PLUGIN_H
-#define COMPILE_GCC_CP_PLUGIN_H
+#ifndef GDB_COMPILE_GCC_CP_PLUGIN_H
+#define GDB_COMPILE_GCC_CP_PLUGIN_H
 
 /* A class representing the GCC C++ plug-in.  */
 
@@ -87,4 +87,4 @@ class gcc_cp_plugin
   struct gcc_cp_context *m_context;
 };
 
-#endif /* COMPILE_GCC_CP_PLUGIN_H */
+#endif /* GDB_COMPILE_GCC_CP_PLUGIN_H */
diff --git a/gdb/complaints.h b/gdb/complaints.h
index 995c35e0ab0..ab91d05b8a0 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#if !defined (COMPLAINTS_H)
-#define COMPLAINTS_H
+#ifndef GDB_COMPLAINTS_H
+#define GDB_COMPLAINTS_H
 
 #include <unordered_set>
 
@@ -109,4 +109,4 @@ class complaint_interceptor final : public warning_hook_handler_type
 
 extern void re_emit_complaints (const complaint_collection &);
 
-#endif /* !defined (COMPLAINTS_H) */
+#endif /* GDB_COMPLAINTS_H */
diff --git a/gdb/completer.h b/gdb/completer.h
index 98a12f3907c..9ca97c2b435 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (COMPLETER_H)
-#define COMPLETER_H 1
+#ifndef GDB_COMPLETER_H
+#define GDB_COMPLETER_H
 
 #include "gdbsupport/gdb-hashtab.h"
 #include "gdbsupport/gdb_vecs.h"
@@ -661,4 +661,4 @@ extern bool skip_over_slash_fmt (completion_tracker &tracker,
 
 extern int max_completions;
 
-#endif /* defined (COMPLETER_H) */
+#endif /* GDB_COMPLETER_H */
diff --git a/gdb/config/nm-linux.h b/gdb/config/nm-linux.h
index 4ac42cdae1a..d599d3fdef5 100644
--- a/gdb/config/nm-linux.h
+++ b/gdb/config/nm-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CONFIG_NM_LINUX_H
-#define CONFIG_NM_LINUX_H
+#ifndef GDB_CONFIG_NM_LINUX_H
+#define GDB_CONFIG_NM_LINUX_H
 
 /* Use elf_gregset_t and elf_fpregset_t, rather than
    gregset_t and fpregset_t.  */
@@ -26,4 +26,4 @@
 #define GDB_GREGSET_T  elf_gregset_t
 #define GDB_FPREGSET_T elf_fpregset_t
 
-#endif /* CONFIG_NM_LINUX_H */
+#endif /* GDB_CONFIG_NM_LINUX_H */
diff --git a/gdb/config/nm-nto.h b/gdb/config/nm-nto.h
index 5a002df5548..b06cd1f5e03 100644
--- a/gdb/config/nm-nto.h
+++ b/gdb/config/nm-nto.h
@@ -19,11 +19,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CONFIG_NM_NTO_H
-#define CONFIG_NM_NTO_H
+#ifndef GDB_CONFIG_NM_NTO_H
+#define GDB_CONFIG_NM_NTO_H
 
 /* Setup the valid realtime signal range.  */
 #define REALTIME_LO 41
 #define REALTIME_HI 56
 
-#endif /* CONFIG_NM_NTO_H */
+#endif /* GDB_CONFIG_NM_NTO_H */
diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h
index fdbe4843129..6c8d9043463 100644
--- a/gdb/cp-abi.h
+++ b/gdb/cp-abi.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CP_ABI_H
-#define CP_ABI_H
+#ifndef GDB_CP_ABI_H
+#define GDB_CP_ABI_H
 
 struct fn_field;
 struct type;
@@ -255,4 +255,4 @@ struct cp_abi_ops
 extern int register_cp_abi (struct cp_abi_ops *abi);
 extern void set_cp_abi_as_auto_default (const char *short_name);
 
-#endif /* CP_ABI_H */
+#endif /* GDB_CP_ABI_H */
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 4015126154b..e2d480b2f16 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CP_SUPPORT_H
-#define CP_SUPPORT_H
+#ifndef GDB_CP_SUPPORT_H
+#define GDB_CP_SUPPORT_H
 
 #include "symtab.h"
 #include "gdbsupport/gdb_vecs.h"
@@ -212,4 +212,4 @@ extern char *gdb_cplus_demangle_print (int options,
 
 extern const char *find_toplevel_char (const char *s, char c);
 
-#endif /* CP_SUPPORT_H */
+#endif /* GDB_CP_SUPPORT_H */
diff --git a/gdb/cris-tdep.h b/gdb/cris-tdep.h
index f4f4744adaf..8be95473e21 100644
--- a/gdb/cris-tdep.h
+++ b/gdb/cris-tdep.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CRIS_TDEP_H
-#define CRIS_TDEP_H
+#ifndef GDB_CRIS_TDEP_H
+#define GDB_CRIS_TDEP_H
 
 #include "gdbarch.h"
 
@@ -33,4 +33,4 @@ struct cris_gdbarch_tdep : gdbarch_tdep_base
   int cris_dwarf2_cfi = 0;
 };
 
-#endif /* CRIS_TDEP_H */
+#endif /* GDB_CRIS_TDEP_H */
diff --git a/gdb/csky-tdep.h b/gdb/csky-tdep.h
index e5516e83550..29917192298 100644
--- a/gdb/csky-tdep.h
+++ b/gdb/csky-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CSKY_TDEP_H
-#define CSKY_TDEP_H
+#ifndef GDB_CSKY_TDEP_H
+#define GDB_CSKY_TDEP_H
 
 #include "gdbarch.h"
 
@@ -390,4 +390,4 @@ enum csky_regnum
 #define CSKY_LRW_T1_PC_8    0x2ea8d
 #define CSKY_JMP_T1_VS_NOP  0x6c037834
 
-#endif
+#endif /* GDB_CSKY_TDEP_H */
diff --git a/gdb/ctfread.h b/gdb/ctfread.h
index ff348a2487b..711a1dd2902 100644
--- a/gdb/ctfread.h
+++ b/gdb/ctfread.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CTFREAD_H
-#define CTFREAD_H
+#ifndef GDB_CTFREAD_H
+#define GDB_CTFREAD_H
 
 extern void elfctf_build_psymtabs (struct objfile *objfile);
 
-#endif /* CTFREAD_H */
+#endif /* GDB_CTFREAD_H */
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index ecf194d8155..8a944472b32 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (D_LANG_H)
-#define D_LANG_H 1
+#ifndef GDB_D_LANG_H
+#define GDB_D_LANG_H
 
 #include "symtab.h"
 
@@ -84,4 +84,4 @@ extern void d_value_print_inner (struct value *val,
 				 struct ui_file *stream, int recurse,
 				 const struct value_print_options *options);
 
-#endif /* !defined (D_LANG_H) */
+#endif /* GDB_D_LANG_H */
diff --git a/gdb/darwin-nat.h b/gdb/darwin-nat.h
index 71aee57f61a..4ead0ea7003 100644
--- a/gdb/darwin-nat.h
+++ b/gdb/darwin-nat.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DARWIN_NAT_H
-#define DARWIN_NAT_H
+#ifndef GDB_DARWIN_NAT_H
+#define GDB_DARWIN_NAT_H
 
 #include "inf-child.h"
 #include <mach/mach.h>
@@ -210,4 +210,4 @@ void darwin_set_sstep (thread_t thread, int enable);
 
 void darwin_check_osabi (darwin_inferior *inf, thread_t thread);
 
-#endif /* DARWIN_NAT_H */
+#endif /* GDB_DARWIN_NAT_H */
diff --git a/gdb/dcache.h b/gdb/dcache.h
index 101e65dc41f..21f49e522c5 100644
--- a/gdb/dcache.h
+++ b/gdb/dcache.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DCACHE_H
-#define DCACHE_H
+#ifndef GDB_DCACHE_H
+#define GDB_DCACHE_H
 
 #include "target.h"
 
@@ -52,4 +52,4 @@ void dcache_update (DCACHE *dcache, enum target_xfer_status status,
 		    CORE_ADDR memaddr, const gdb_byte *myaddr,
 		    ULONGEST len);
 
-#endif /* DCACHE_H */
+#endif /* GDB_DCACHE_H */
diff --git a/gdb/debuginfod-support.h b/gdb/debuginfod-support.h
index 2b816fd4b82..2b396dc13c1 100644
--- a/gdb/debuginfod-support.h
+++ b/gdb/debuginfod-support.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DEBUGINFOD_SUPPORT_H
-#define DEBUGINFOD_SUPPORT_H
+#ifndef GDB_DEBUGINFOD_SUPPORT_H
+#define GDB_DEBUGINFOD_SUPPORT_H
 
 #include "gdbsupport/scoped_fd.h"
 
@@ -105,4 +105,4 @@ extern scoped_fd debuginfod_section_query (const unsigned char *build_id,
 					   const char *section_name,
 					   gdb::unique_xmalloc_ptr<char>
 					     *destname);
-#endif /* DEBUGINFOD_SUPPORT_H */
+#endif /* GDB_DEBUGINFOD_SUPPORT_H */
diff --git a/gdb/defs.h b/gdb/defs.h
index cf471bf5d66..212599b2bcc 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DEFS_H
-#define DEFS_H
+#ifndef GDB_DEFS_H
+#define GDB_DEFS_H
 
 #ifdef GDBSERVER
 #  error gdbserver should not include gdb/defs.h
@@ -619,4 +619,4 @@ DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
 
 #include "utils.h"
 
-#endif /* #ifndef DEFS_H */
+#endif /* GDB_DEFS_H */
diff --git a/gdb/dicos-tdep.h b/gdb/dicos-tdep.h
index 1e3eb41a41f..5305debd707 100644
--- a/gdb/dicos-tdep.h
+++ b/gdb/dicos-tdep.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DICOS_TDEP_H
-#define DICOS_TDEP_H
+#ifndef GDB_DICOS_TDEP_H
+#define GDB_DICOS_TDEP_H
 
 extern void dicos_init_abi (struct gdbarch *gdbarch);
 extern int dicos_load_module_p (bfd *abfd, int header_size);
 
-#endif /* dicos-tdep.h */
+#endif /* GDB_DICOS_TDEP_H */
diff --git a/gdb/dictionary.h b/gdb/dictionary.h
index 6f602f4a18b..a06aa1738f1 100644
--- a/gdb/dictionary.h
+++ b/gdb/dictionary.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DICTIONARY_H
-#define DICTIONARY_H
+#ifndef GDB_DICTIONARY_H
+#define GDB_DICTIONARY_H
 
 #include "symfile.h"
 
@@ -208,4 +208,4 @@ struct mdict_iterator_wrapper
   struct mdict_iterator m_iter;
 };
 
-#endif /* DICTIONARY_H */
+#endif /* GDB_DICTIONARY_H */
diff --git a/gdb/disasm-flags.h b/gdb/disasm-flags.h
index b2f0ec95b07..9d4011cebf2 100644
--- a/gdb/disasm-flags.h
+++ b/gdb/disasm-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISASM_FLAGS_H
-#define DISASM_FLAGS_H
+#ifndef GDB_DISASM_FLAGS_H
+#define GDB_DISASM_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -37,4 +37,4 @@ enum gdb_disassembly_flag : unsigned
   };
 DEF_ENUM_FLAGS_TYPE (enum gdb_disassembly_flag, gdb_disassembly_flags);
 
-#endif /* DISASM_FLAGS_H */
+#endif /* GDB_DISASM_FLAGS_H */
diff --git a/gdb/disasm.h b/gdb/disasm.h
index 9282632b270..60d7e0fc834 100644
--- a/gdb/disasm.h
+++ b/gdb/disasm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISASM_H
-#define DISASM_H
+#ifndef GDB_DISASM_H
+#define GDB_DISASM_H
 
 #include "dis-asm.h"
 #include "disasm-flags.h"
@@ -391,4 +391,4 @@ extern const char *get_disassembler_options (struct gdbarch *gdbarch);
 
 extern void set_disassembler_options (const char *options);
 
-#endif
+#endif /* GDB_DISASM_H */
diff --git a/gdb/displaced-stepping.h b/gdb/displaced-stepping.h
index ba0d56c2a1f..d7a537a58c9 100644
--- a/gdb/displaced-stepping.h
+++ b/gdb/displaced-stepping.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DISPLACED_STEPPING_H
-#define DISPLACED_STEPPING_H
+#ifndef GDB_DISPLACED_STEPPING_H
+#define GDB_DISPLACED_STEPPING_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/byte-vector.h"
@@ -207,4 +207,4 @@ struct displaced_step_buffers
   std::vector<displaced_step_buffer> m_buffers;
 };
 
-#endif /* DISPLACED_STEPPING_H */
+#endif /* GDB_DISPLACED_STEPPING_H */
diff --git a/gdb/dummy-frame.h b/gdb/dummy-frame.h
index 7d963ad9beb..78998e84413 100644
--- a/gdb/dummy-frame.h
+++ b/gdb/dummy-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DUMMY_FRAME_H)
-#define DUMMY_FRAME_H 1
+#ifndef GDB_DUMMY_FRAME_H
+#define GDB_DUMMY_FRAME_H
 
 #include "frame.h"
 
@@ -80,4 +80,4 @@ extern int find_dummy_frame_dtor (dummy_frame_dtor_ftype *dtor,
 extern struct frame_id default_dummy_id (struct gdbarch *gdbarch,
 					 const frame_info_ptr &this_frame);
 
-#endif /* !defined (DUMMY_FRAME_H)  */
+#endif /* GDB_DUMMY_FRAME_H */
diff --git a/gdb/dwarf2/call-site.h b/gdb/dwarf2/call-site.h
index 0a0c7e83b81..0c587470311 100644
--- a/gdb/dwarf2/call-site.h
+++ b/gdb/dwarf2/call-site.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CALL_SITE_H
-#define CALL_SITE_H
+#ifndef GDB_DWARF2_CALL_SITE_H
+#define GDB_DWARF2_CALL_SITE_H
 
 #include "dwarf2/types.h"
 #include "../frame.h"
@@ -241,4 +241,4 @@ struct call_site
   struct call_site_parameter parameter[];
 };
 
-#endif /* CALL_SITE_H */
+#endif /* GDB_DWARF2_CALL_SITE_H */
diff --git a/gdb/dwarf2/comp-unit-head.h b/gdb/dwarf2/comp-unit-head.h
index fad484c3b93..d161783187c 100644
--- a/gdb/dwarf2/comp-unit-head.h
+++ b/gdb/dwarf2/comp-unit-head.h
@@ -24,8 +24,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DWARF2_COMP_UNIT_H
-#define GDB_DWARF2_COMP_UNIT_H
+#ifndef GDB_DWARF2_COMP_UNIT_HEAD_H
+#define GDB_DWARF2_COMP_UNIT_HEAD_H
 
 #include "dwarf2.h"
 #include "dwarf2/leb.h"
@@ -136,4 +136,4 @@ extern const gdb_byte *read_and_check_comp_unit_head
    const gdb_byte *info_ptr,
    rcuh_kind section_kind);
 
-#endif /* GDB_DWARF2_COMP_UNIT_H */
+#endif /* GDB_DWARF2_COMP_UNIT_HEAD_H */
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index b02cc531640..bbb9cd078ba 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DWARF2EXPR_H)
-#define DWARF2EXPR_H
+#ifndef GDB_DWARF2_EXPR_H
+#define GDB_DWARF2_EXPR_H
 
 #include "leb128.h"
 #include "dwarf2/call-site.h"
@@ -320,4 +320,4 @@ extern const gdb_byte *safe_read_sleb128 (const gdb_byte *buf,
 extern const gdb_byte *safe_skip_leb128 (const gdb_byte *buf,
 					 const gdb_byte *buf_end);
 
-#endif /* DWARF2EXPR_H */
+#endif /* GDB_DWARF2_EXPR_H */
diff --git a/gdb/dwarf2/frame-tailcall.h b/gdb/dwarf2/frame-tailcall.h
index 3f49487ac2a..558957eb999 100644
--- a/gdb/dwarf2/frame-tailcall.h
+++ b/gdb/dwarf2/frame-tailcall.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_FRAME_TAILCALL_H
-#define DWARF2_FRAME_TAILCALL_H 1
+#ifndef GDB_DWARF2_FRAME_TAILCALL_H
+#define GDB_DWARF2_FRAME_TAILCALL_H
 
 class frame_info_ptr;
 struct frame_unwind;
@@ -36,4 +36,4 @@ extern struct value *
 
 extern const struct frame_unwind dwarf2_tailcall_frame_unwind;
 
-#endif /* !DWARF2_FRAME_TAILCALL_H */
+#endif /* GDB_DWARF2_FRAME_TAILCALL_H */
diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h
index 2167310fbdf..f53f4bdd864 100644
--- a/gdb/dwarf2/frame.h
+++ b/gdb/dwarf2/frame.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_FRAME_H
-#define DWARF2_FRAME_H 1
+#ifndef GDB_DWARF2_FRAME_H
+#define GDB_DWARF2_FRAME_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -294,4 +294,4 @@ extern void *dwarf2_frame_get_fn_data (const frame_info_ptr &this_frame,
 				       void **this_cache,
 				       fn_prev_register cookie);
 
-#endif /* dwarf2-frame.h */
+#endif /* GDB_DWARF2_FRAME_H */
diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h
index 95f217ed961..922c1568f8e 100644
--- a/gdb/dwarf2/index-cache.h
+++ b/gdb/dwarf2/index-cache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_CACHE_H
-#define DWARF_INDEX_CACHE_H
+#ifndef GDB_DWARF2_INDEX_CACHE_H
+#define GDB_DWARF2_INDEX_CACHE_H
 
 #include "dwarf2/index-common.h"
 #include "gdbsupport/array-view.h"
@@ -137,4 +137,4 @@ class index_cache
 /* The global instance of the index cache.  */
 extern index_cache global_index_cache;
 
-#endif /* DWARF_INDEX_CACHE_H */
+#endif /* GDB_DWARF2_INDEX_CACHE_H */
diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h
index dca41517b3d..4c029f4318e 100644
--- a/gdb/dwarf2/index-common.h
+++ b/gdb/dwarf2/index-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_COMMON_H
-#define DWARF_INDEX_COMMON_H
+#ifndef GDB_DWARF2_INDEX_COMMON_H
+#define GDB_DWARF2_INDEX_COMMON_H
 
 /* The suffix for an index file.  */
 #define INDEX4_SUFFIX ".gdb-index"
@@ -56,4 +56,4 @@ uint32_t dwarf5_djb_hash (const char *str_);
 
 uint32_t dwarf5_djb_hash (std::string_view str_);
 
-#endif /* DWARF_INDEX_COMMON_H */
+#endif /* GDB_DWARF2_INDEX_COMMON_H */
diff --git a/gdb/dwarf2/index-write.h b/gdb/dwarf2/index-write.h
index b7cf564efc5..1982e8510fc 100644
--- a/gdb/dwarf2/index-write.h
+++ b/gdb/dwarf2/index-write.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF_INDEX_WRITE_H
-#define DWARF_INDEX_WRITE_H
+#ifndef GDB_DWARF2_INDEX_WRITE_H
+#define GDB_DWARF2_INDEX_WRITE_H
 
 #include "dwarf2/read.h"
 #include "dwarf2/public.h"
@@ -36,4 +36,4 @@ extern void write_dwarf_index
   (dwarf2_per_bfd *per_bfd, const char *dir, const char *basename,
    const char *dwz_basename, dw_index_kind index_kind);
 
-#endif /* DWARF_INDEX_WRITE_H */
+#endif /* GDB_DWARF2_INDEX_WRITE_H */
diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index c068dff70a3..b9bc55a926e 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_LINE_HEADER_H
-#define DWARF2_LINE_HEADER_H
+#ifndef GDB_DWARF2_LINE_HEADER_H
+#define GDB_DWARF2_LINE_HEADER_H
 
 /* dir_index is 1-based in DWARF 4 and before, and is 0-based in DWARF 5 and
    later.  */
@@ -217,4 +217,4 @@ extern line_header_up dwarf_decode_line_header
    struct dwarf2_section_info *section, const struct comp_unit_head *cu_header,
    const char *comp_dir);
 
-#endif /* DWARF2_LINE_HEADER_H */
+#endif /* GDB_DWARF2_LINE_HEADER_H */
diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h
index 4fb743618e7..78635682d94 100644
--- a/gdb/dwarf2/loc.h
+++ b/gdb/dwarf2/loc.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (DWARF2LOC_H)
-#define DWARF2LOC_H
+#ifndef GDB_DWARF2_LOC_H
+#define GDB_DWARF2_LOC_H
 
 #include "dwarf2/expr.h"
 
@@ -308,4 +308,4 @@ extern struct value *value_of_dwarf_reg_entry (struct type *type,
 					       const frame_info_ptr &frame,
 					       enum call_site_parameter_kind kind,
 					       union call_site_parameter_u kind_u);
-#endif /* DWARF2LOC_H */
+#endif /* GDB_DWARF2_LOC_H */
diff --git a/gdb/dwarf2/public.h b/gdb/dwarf2/public.h
index bc419ff208f..8247641b25b 100644
--- a/gdb/dwarf2/public.h
+++ b/gdb/dwarf2/public.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_PUBLIC_H
-#define DWARF2_PUBLIC_H
+#ifndef GDB_DWARF2_PUBLIC_H
+#define GDB_DWARF2_PUBLIC_H
 
 /* A DWARF names index variant.  */
 enum class dw_index_kind
@@ -44,4 +44,4 @@ extern bool dwarf2_initialize_objfile
 
 extern void dwarf2_build_frame_info (struct objfile *);
 
-#endif /* DWARF2_PUBLIC_H */
+#endif /* GDB_DWARF2_PUBLIC_H */
diff --git a/gdb/dwarf2/read-debug-names.h b/gdb/dwarf2/read-debug-names.h
index e616cf887a7..729fe898ea8 100644
--- a/gdb/dwarf2/read-debug-names.h
+++ b/gdb/dwarf2/read-debug-names.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_READ_DEBUG_NAMES_H
-#define DWARF2_READ_DEBUG_NAMES_H
+#ifndef GDB_DWARF2_READ_DEBUG_NAMES_H
+#define GDB_DWARF2_READ_DEBUG_NAMES_H
 
 struct dwarf2_per_objfile;
 
@@ -29,4 +29,4 @@ extern const gdb_byte dwarf5_augmentation[8];
 
 bool dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile);
 
-#endif /* DWARF2_READ_DEBUG_NAMES_H */
+#endif /* GDB_DWARF2_READ_DEBUG_NAMES_H */
diff --git a/gdb/dwarf2/read-gdb-index.h b/gdb/dwarf2/read-gdb-index.h
index e411114b147..906e3bd0bed 100644
--- a/gdb/dwarf2/read-gdb-index.h
+++ b/gdb/dwarf2/read-gdb-index.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_READ_GDB_INDEX_H
-#define DWARF2_READ_GDB_INDEX_H
+#ifndef GDB_DWARF2_READ_GDB_INDEX_H
+#define GDB_DWARF2_READ_GDB_INDEX_H
 
 #include "gdbsupport/function-view.h"
 
@@ -44,4 +44,4 @@ int dwarf2_read_gdb_index
    get_gdb_index_contents_ftype get_gdb_index_contents,
    get_gdb_index_contents_dwz_ftype get_gdb_index_contents_dwz);
 
-#endif /* DWARF2_READ_GDB_INDEX_H */
+#endif /* GDB_DWARF2_READ_GDB_INDEX_H */
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 73def88c4c0..76bf6a422f4 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2READ_H
-#define DWARF2READ_H
+#ifndef GDB_DWARF2_READ_H
+#define GDB_DWARF2_READ_H
 
 #include <queue>
 #include <unordered_map>
@@ -932,4 +932,4 @@ extern void create_all_units (dwarf2_per_objfile *per_objfile);
 
 extern htab_up create_quick_file_names_table (unsigned int nr_initial_entries);
 
-#endif /* DWARF2READ_H */
+#endif /* GDB_DWARF2_READ_H */
diff --git a/gdb/dwarf2/types.h b/gdb/dwarf2/types.h
index 9db5c635704..f4588a12df8 100644
--- a/gdb/dwarf2/types.h
+++ b/gdb/dwarf2/types.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef DWARF2_TYPES_H
-#define DWARF2_TYPES_H
+#ifndef GDB_DWARF2_TYPES_H
+#define GDB_DWARF2_TYPES_H
 
 #include "gdbsupport/offset-type.h"
 #include "gdbsupport/underlying.h"
@@ -37,4 +37,4 @@ sect_offset_str (sect_offset offset)
   return hex_string (to_underlying (offset));
 }
 
-#endif /* DWARF2_TYPES_H */
+#endif /* GDB_DWARF2_TYPES_H */
diff --git a/gdb/elf-none-tdep.h b/gdb/elf-none-tdep.h
index ecbf2d776c6..1881e4b8cb6 100644
--- a/gdb/elf-none-tdep.h
+++ b/gdb/elf-none-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NONE_TDEP_H
-#define NONE_TDEP_H
+#ifndef GDB_ELF_NONE_TDEP_H
+#define GDB_ELF_NONE_TDEP_H
 
 struct gdbarch;
 
@@ -27,4 +27,4 @@ struct gdbarch;
 
 void elf_none_init_abi (struct gdbarch *gdbarch);
 
-#endif /* NONE_TDEP_H */
+#endif /* GDB_ELF_NONE_TDEP_H */
diff --git a/gdb/event-top.h b/gdb/event-top.h
index f431f2812b2..7f544b0f27c 100644
--- a/gdb/event-top.h
+++ b/gdb/event-top.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EVENT_TOP_H
-#define EVENT_TOP_H
+#ifndef GDB_EVENT_TOP_H
+#define GDB_EVENT_TOP_H
 
 #include <signal.h>
 
@@ -90,4 +90,4 @@ class scoped_segv_handler_restore
   segv_handler_t m_old_handler;
 };
 
-#endif
+#endif /* GDB_EVENT_TOP_H */
diff --git a/gdb/exceptions.h b/gdb/exceptions.h
index 64f4d75c39c..bf7141dbb9f 100644
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXCEPTIONS_H
-#define EXCEPTIONS_H
+#ifndef GDB_EXCEPTIONS_H
+#define GDB_EXCEPTIONS_H
 
 #include "ui-out.h"
 
@@ -31,4 +31,4 @@ extern void exception_fprintf (struct ui_file *file,
 			       const char *prefix,
 			       ...) ATTRIBUTE_PRINTF (3, 4);
 
-#endif
+#endif /* GDB_EXCEPTIONS_H */
diff --git a/gdb/exec.h b/gdb/exec.h
index f667f23600d..950a21c2f3a 100644
--- a/gdb/exec.h
+++ b/gdb/exec.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXEC_H
-#define EXEC_H
+#ifndef GDB_EXEC_H
+#define GDB_EXEC_H
 
 #include "target.h"
 #include "progspace.h"
@@ -105,4 +105,4 @@ extern void print_section_info (const std::vector<target_section> *table,
 extern void try_open_exec_file (const char *exec_file_host,
 				struct inferior *inf,
 				symfile_add_flags add_flags);
-#endif
+#endif /* GDB_EXEC_H */
diff --git a/gdb/expop.h b/gdb/expop.h
index b81e228c07e..64158bc4706 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXPOP_H
-#define EXPOP_H
+#ifndef GDB_EXPOP_H
+#define GDB_EXPOP_H
 
 #include "c-lang.h"
 #include "cp-abi.h"
@@ -2215,4 +2215,4 @@ class funcall_operation
 
 } /* namespace expr */
 
-#endif /* EXPOP_H */
+#endif /* GDB_EXPOP_H */
diff --git a/gdb/expression.h b/gdb/expression.h
index 5bfc74c973f..7c79518da8b 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (EXPRESSION_H)
-#define EXPRESSION_H 1
+#ifndef GDB_EXPRESSION_H
+#define GDB_EXPRESSION_H
 
 #include "gdbtypes.h"
 #include "symtab.h"
@@ -387,4 +387,4 @@ enum range_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum range_flag, range_flags);
 
-#endif /* !defined (EXPRESSION_H) */
+#endif /* GDB_EXPRESSION_H */
diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index cb00cb6ff7b..f6c5f3fe75f 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXTENSION_PRIV_H
-#define EXTENSION_PRIV_H
+#ifndef GDB_EXTENSION_PRIV_H
+#define GDB_EXTENSION_PRIV_H
 
 #include "extension.h"
 #include <signal.h>
@@ -320,4 +320,4 @@ extern struct active_ext_lang_state *set_active_ext_lang
 
 extern void restore_active_ext_lang (struct active_ext_lang_state *previous);
 
-#endif /* EXTENSION_PRIV_H */
+#endif /* GDB_EXTENSION_PRIV_H */
diff --git a/gdb/extension.h b/gdb/extension.h
index 5260bcbde00..93c3cdfcc69 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EXTENSION_H
-#define EXTENSION_H
+#ifndef GDB_EXTENSION_H
+#define GDB_EXTENSION_H
 
 #include "mi/mi-cmds.h"
 #include "gdbsupport/array-view.h"
@@ -428,4 +428,4 @@ class scoped_disable_cooperative_sigint_handling
   bool m_prev_cooperative_sigint_handling_disabled;
 };
 
-#endif /* EXTENSION_H */
+#endif /* GDB_EXTENSION_H */
diff --git a/gdb/f-array-walker.h b/gdb/f-array-walker.h
index bcbaa3da5b3..d1f2b06fa9b 100644
--- a/gdb/f-array-walker.h
+++ b/gdb/f-array-walker.h
@@ -18,8 +18,8 @@
 /* Support classes to wrap up the process of iterating over a
    multi-dimensional Fortran array.  */
 
-#ifndef F_ARRAY_WALKER_H
-#define F_ARRAY_WALKER_H
+#ifndef GDB_F_ARRAY_WALKER_H
+#define GDB_F_ARRAY_WALKER_H
 
 #include "gdbtypes.h"
 #include "f-lang.h"
@@ -298,4 +298,4 @@ class fortran_array_walker
   int m_nss;
 };
 
-#endif /* F_ARRAY_WALKER_H */
+#endif /* GDB_F_ARRAY_WALKER_H */
diff --git a/gdb/f-exp.h b/gdb/f-exp.h
index aa0094c8ff1..47d469abe7c 100644
--- a/gdb/f-exp.h
+++ b/gdb/f-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FORTRAN_EXP_H
-#define FORTRAN_EXP_H
+#ifndef GDB_F_EXP_H
+#define GDB_F_EXP_H
 
 #include "expop.h"
 
@@ -417,4 +417,4 @@ class fortran_structop_operation
 
 } /* namespace expr */
 
-#endif /* FORTRAN_EXP_H */
+#endif /* GDB_F_EXP_H */
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index c2034258513..59cdd5f2334 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef F_LANG_H
-#define F_LANG_H
+#ifndef GDB_F_LANG_H
+#define GDB_F_LANG_H
 
 #include "language.h"
 #include "valprint.h"
@@ -378,4 +378,4 @@ extern struct type *fortran_preserve_arg_pointer (struct value *arg,
 extern CORE_ADDR fortran_adjust_dynamic_array_base_address_hack
 	(struct type *type, CORE_ADDR address);
 
-#endif /* F_LANG_H */
+#endif /* GDB_F_LANG_H */
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index 35c06b2c985..2123175944e 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FBSD_NAT_H
-#define FBSD_NAT_H
+#ifndef GDB_FBSD_NAT_H
+#define GDB_FBSD_NAT_H
 
 #include <optional>
 #include "inf-ptrace.h"
@@ -285,4 +285,4 @@ class fbsd_nat_target : public inf_ptrace_target
    Return true if successful.  */
 bool fbsd_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
 
-#endif /* fbsd-nat.h */
+#endif /* GDB_FBSD_NAT_H */
diff --git a/gdb/fbsd-tdep.h b/gdb/fbsd-tdep.h
index 54ff45c8d93..79381b3fefd 100644
--- a/gdb/fbsd-tdep.h
+++ b/gdb/fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FBSD_TDEP_H
-#define FBSD_TDEP_H
+#ifndef GDB_FBSD_TDEP_H
+#define GDB_FBSD_TDEP_H
 
 extern void fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
 
@@ -76,4 +76,4 @@ extern CORE_ADDR fbsd_get_thread_local_address (struct gdbarch *gdbarch,
 extern CORE_ADDR fbsd_skip_solib_resolver (struct gdbarch *gdbarch,
 					   CORE_ADDR pc);
 
-#endif /* fbsd-tdep.h */
+#endif /* GDB_FBSD_TDEP_H */
diff --git a/gdb/filename-seen-cache.h b/gdb/filename-seen-cache.h
index 5dc800d2b16..9107f449183 100644
--- a/gdb/filename-seen-cache.h
+++ b/gdb/filename-seen-cache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FILENAME_SEEN_CACHE_H
-#define FILENAME_SEEN_CACHE_H
+#ifndef GDB_FILENAME_SEEN_CACHE_H
+#define GDB_FILENAME_SEEN_CACHE_H
 
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/gdb-hashtab.h"
@@ -62,4 +62,4 @@ class filename_seen_cache
   htab_up m_tab;
 };
 
-#endif /* FILENAME_SEEN_CACHE_H */
+#endif /* GDB_FILENAME_SEEN_CACHE_H */
diff --git a/gdb/filesystem.h b/gdb/filesystem.h
index 29c31803fc4..73b9a8bb84e 100644
--- a/gdb/filesystem.h
+++ b/gdb/filesystem.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FILESYSTEM_H
-#define FILESYSTEM_H
+#ifndef GDB_FILESYSTEM_H
+#define GDB_FILESYSTEM_H
 
 extern const char file_system_kind_auto[];
 extern const char file_system_kind_unix[];
@@ -55,4 +55,4 @@ extern const char *target_lbasename (const char *kind, const char *name);
    result from this function.  */
 extern const char *effective_target_file_system_kind (void);
 
-#endif
+#endif /* GDB_FILESYSTEM_H */
diff --git a/gdb/frame-base.h b/gdb/frame-base.h
index ae22431d5ef..8436929839e 100644
--- a/gdb/frame-base.h
+++ b/gdb/frame-base.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_BASE_H)
-#define FRAME_BASE_H 1
+#ifndef GDB_FRAME_BASE_H
+#define GDB_FRAME_BASE_H
 
 class frame_info_ptr;
 struct frame_id;
@@ -88,4 +88,4 @@ extern void frame_base_set_default (struct gdbarch *gdbarch,
 
 extern const struct frame_base *frame_base_find_by_frame (const frame_info_ptr &this_frame);
 
-#endif
+#endif /* GDB_FRAME_BASE_H */
diff --git a/gdb/frame-id.h b/gdb/frame-id.h
index 0d03b476aef..30850e24017 100644
--- a/gdb/frame-id.h
+++ b/gdb/frame-id.h
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef GDB_FRAME_ID_H
-#define GDB_FRAME_ID_H 1
+#define GDB_FRAME_ID_H
 
 /* Status of a given frame's stack.  */
 
@@ -140,4 +140,4 @@ is_sentinel_frame_id (frame_id id)
   return id.stack_status == FID_STACK_SENTINEL;
 }
 
-#endif /* ifdef GDB_FRAME_ID_H  */
+#endif /* GDB_FRAME_ID_H */
diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h
index 53fcd6869e9..1799d3625bd 100644
--- a/gdb/frame-unwind.h
+++ b/gdb/frame-unwind.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_UNWIND_H)
-#define FRAME_UNWIND_H 1
+#ifndef GDB_FRAME_UNWIND_H
+#define GDB_FRAME_UNWIND_H
 
 struct frame_data;
 class frame_info_ptr;
@@ -235,4 +235,4 @@ value *frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum,
 value *frame_unwind_got_address (const frame_info_ptr &frame, int regnum,
 				 CORE_ADDR addr);
 
-#endif
+#endif /* GDB_FRAME_UNWIND_H */
diff --git a/gdb/frame.h b/gdb/frame.h
index e784c17b480..9b41dd958fa 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (FRAME_H)
-#define FRAME_H 1
+#ifndef GDB_FRAME_H
+#define GDB_FRAME_H
 
 /* The following is the intended naming schema for frame functions.
    It isn't 100% consistent, but it is approaching that.  Frame naming
@@ -1077,4 +1077,4 @@ extern void set_frame_previous_pc_masked (const frame_info_ptr &frame);
 extern bool get_frame_pc_masked (const frame_info_ptr &frame);
 
 
-#endif /* !defined (FRAME_H)  */
+#endif /* GDB_FRAME_H */
diff --git a/gdb/frv-tdep.h b/gdb/frv-tdep.h
index 95347ed224e..0d78ec4ac6a 100644
--- a/gdb/frv-tdep.h
+++ b/gdb/frv-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FRV_TDEP_H
-#define FRV_TDEP_H
+#ifndef GDB_FRV_TDEP_H
+#define GDB_FRV_TDEP_H
 
 /* Enumerate the possible ABIs for FR-V.  */
 enum frv_abi
@@ -121,4 +121,4 @@ CORE_ADDR frv_fetch_objfile_link_map (struct objfile *objfile);
 struct solib_ops;
 extern const solib_ops frv_so_ops;
 
-#endif /* FRV_TDEP_H */
+#endif /* GDB_FRV_TDEP_H */
diff --git a/gdb/ft32-tdep.h b/gdb/ft32-tdep.h
index 308d2333bc2..ee4a2473f8d 100644
--- a/gdb/ft32-tdep.h
+++ b/gdb/ft32-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef FT32_TDEP_H
-#define FT32_TDEP_H
+#ifndef GDB_FT32_TDEP_H
+#define GDB_FT32_TDEP_H
 
 #include "gdbarch.h"
 
@@ -28,4 +28,4 @@ struct ft32_gdbarch_tdep : gdbarch_tdep_base
   struct type *pc_type = nullptr;
 };
 
-#endif /* FT32_TDEP_H */
+#endif /* GDB_FT32_TDEP_H */
diff --git a/gdb/gcore-elf.h b/gdb/gcore-elf.h
index e7239b88b09..8217f0b1c85 100644
--- a/gdb/gcore-elf.h
+++ b/gdb/gcore-elf.h
@@ -17,8 +17,8 @@
 
 /* This file contains generic functions for writing ELF based core files.  */
 
-#if !defined (GCORE_ELF_H)
-#define GCORE_ELF_H 1
+#ifndef GDB_GCORE_ELF_H
+#define GDB_GCORE_ELF_H
 
 #include "gdb_bfd.h"
 #include "gdbsupport/gdb_signals.h"
@@ -45,4 +45,4 @@ extern void gcore_elf_make_tdesc_note
   (struct gdbarch *gdbarch, bfd *obfd,
    gdb::unique_xmalloc_ptr<char> *note_data, int *note_size);
 
-#endif /* GCORE_ELF_H */
+#endif /* GDB_GCORE_ELF_H */
diff --git a/gdb/gcore.h b/gdb/gcore.h
index 0bedc0a7ba9..21e7a8d29ee 100644
--- a/gdb/gcore.h
+++ b/gdb/gcore.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GCORE_H)
-#define GCORE_H 1
+#ifndef GDB_GCORE_H
+#define GDB_GCORE_H
 
 #include "gdb_bfd.h"
 
@@ -37,4 +37,4 @@ extern int objfile_find_memory_regions (struct target_ops *self,
 
 extern thread_info *gcore_find_signalled_thread ();
 
-#endif /* GCORE_H */
+#endif /* GDB_GCORE_H */
diff --git a/gdb/gdb-demangle.h b/gdb/gdb-demangle.h
index e434f890969..86a8bd618eb 100644
--- a/gdb/gdb-demangle.h
+++ b/gdb/gdb-demangle.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DEMANGLE_H
-#define GDB_DEMANGLE_H
+#ifndef GDB_GDB_DEMANGLE_H
+#define GDB_GDB_DEMANGLE_H
 
 /* True means that encoded C++/ObjC names should be printed out in their
    C++/ObjC form rather than raw.  */
@@ -31,4 +31,4 @@ extern bool asm_demangle;
 /* Check if a character is one of the commonly used C++ marker characters.  */
 extern bool is_cplus_marker (int);
 
-#endif /* GDB_DEMANGLE_H */
+#endif /* GDB_GDB_DEMANGLE_H */
diff --git a/gdb/gdb-stabs.h b/gdb/gdb-stabs.h
index 3786ad6881d..373a7269470 100644
--- a/gdb/gdb-stabs.h
+++ b/gdb/gdb-stabs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_STABS_H
-#define GDB_STABS_H
+#ifndef GDB_GDB_STABS_H
+#define GDB_GDB_STABS_H
 
 /* This file exists to hold the common definitions required of most of
    the symbol-readers that end up using stabs.  The common use of
@@ -75,4 +75,4 @@ extern const registry<objfile>::key<dbx_symfile_info> dbx_objfile_data_key;
 #define DBX_BSS_SECTION(o)	(DBX_SYMFILE_INFO(o)->bss_section)
 #define DBX_STAB_SECTION(o)	(DBX_SYMFILE_INFO(o)->stab_section)
 
-#endif /* GDB_STABS_H */
+#endif /* GDB_GDB_STABS_H */
diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h
index 331570d769c..c09e4e7f811 100644
--- a/gdb/gdb_bfd.h
+++ b/gdb/gdb_bfd.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_BFD_H
-#define GDB_BFD_H
+#ifndef GDB_GDB_BFD_H
+#define GDB_GDB_BFD_H
 
 #include "registry.h"
 #include "gdbsupport/byte-vector.h"
@@ -263,4 +263,4 @@ extern std::string gdb_bfd_errmsg (bfd_error_type error_tag, char **matching);
 
 extern void gdb_bfd_init ();
 
-#endif /* GDB_BFD_H */
+#endif /* GDB_GDB_BFD_H */
diff --git a/gdb/gdb_curses.h b/gdb/gdb_curses.h
index c7ee862cd67..c0ab883f17b 100644
--- a/gdb/gdb_curses.h
+++ b/gdb/gdb_curses.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_CURSES_H
-#define GDB_CURSES_H 1
+#ifndef GDB_GDB_CURSES_H
+#define GDB_GDB_CURSES_H
 
 #ifdef __MINGW32__
 /* Windows API headers, included e.g. by serial.h, define MOUSE_MOVED,
@@ -71,4 +71,4 @@ extern "C" int tgetnum (const char *);
 #undef reg
 #endif
 
-#endif /* gdb_curses.h */
+#endif /* GDB_GDB_CURSES_H */
diff --git a/gdb/gdb_expat.h b/gdb/gdb_expat.h
index 566f065fd13..36cee8031eb 100644
--- a/gdb/gdb_expat.h
+++ b/gdb/gdb_expat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(GDB_EXPAT_H)
-#define GDB_EXPAT_H
+#ifndef GDB_GDB_EXPAT_H
+#define GDB_GDB_EXPAT_H
 
 #include <expat.h>
 
@@ -35,4 +35,4 @@
 #define XMLCALL
 #endif
 
-#endif /* !defined(GDB_EXPAT_H) */
+#endif /* GDB_GDB_EXPAT_H */
diff --git a/gdb/gdb_proc_service.h b/gdb/gdb_proc_service.h
index 1088e19a4c5..c5e060b4eee 100644
--- a/gdb/gdb_proc_service.h
+++ b/gdb/gdb_proc_service.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_PROC_SERVICE_H
-#define GDB_PROC_SERVICE_H
+#ifndef GDB_GDB_PROC_SERVICE_H
+#define GDB_GDB_PROC_SERVICE_H
 
 #include "gdbsupport/gdb_proc_service.h"
 
@@ -30,4 +30,4 @@ struct ps_prochandle
   thread_info *thread;
 };
 
-#endif /* gdb_proc_service.h */
+#endif /* GDB_GDB_PROC_SERVICE_H */
diff --git a/gdb/gdb_vfork.h b/gdb/gdb_vfork.h
index 521fed9b007..69f4955ee97 100644
--- a/gdb/gdb_vfork.h
+++ b/gdb/gdb_vfork.h
@@ -16,11 +16,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_VFORK_H
-#define GDB_VFORK_H
+#ifndef GDB_GDB_VFORK_H
+#define GDB_GDB_VFORK_H
 
 #if HAVE_VFORK_H
 #include <vfork.h>
 #endif
 
-#endif /* GDB_VFORK_H */
+#endif /* GDB_GDB_VFORK_H */
diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h
index 8df00e4679f..937b409d039 100644
--- a/gdb/gdb_wchar.h
+++ b/gdb/gdb_wchar.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_WCHAR_H
-#define GDB_WCHAR_H
+#ifndef GDB_GDB_WCHAR_H
+#define GDB_GDB_WCHAR_H
 
 /* We handle three different modes here.
    
@@ -121,4 +121,4 @@ typedef int gdb_wint_t;
 
 #endif
 
-#endif /* GDB_WCHAR_H */
+#endif /* GDB_GDB_WCHAR_H */
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 77d3406779f..bfe08fe65a8 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef GDBARCH_H
-#define GDBARCH_H
+#ifndef GDB_GDBARCH_H
+#define GDB_GDBARCH_H
 
 #include <vector>
 #include "frame.h"
@@ -370,4 +370,4 @@ gdbarch_num_cooked_regs (gdbarch *arch)
   return gdbarch_num_regs (arch) + gdbarch_num_pseudo_regs (arch);
 }
 
-#endif
+#endif /* GDB_GDBARCH_H */
diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h
index 8a1f6f20052..cba32528dfa 100644
--- a/gdb/gdbcmd.h
+++ b/gdb/gdbcmd.h
@@ -21,8 +21,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDBCMD_H)
-#define GDBCMD_H 1
+#ifndef GDB_GDBCMD_H
+#define GDB_GDBCMD_H
 
 #include "command.h"
 #include "ui-out.h"
@@ -69,4 +69,4 @@ extern void print_command_lines (struct ui_out *,
 extern struct cmd_list_element *style_set_list;
 extern struct cmd_list_element *style_show_list;
 
-#endif /* !defined (GDBCMD_H) */
+#endif /* GDB_GDBCMD_H */
diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h
index d6aeb356e37..4eab2cd70a5 100644
--- a/gdb/gdbcore.h
+++ b/gdb/gdbcore.h
@@ -19,8 +19,8 @@
 
 /* Interface routines for core, executable, etc.  */
 
-#if !defined (GDBCORE_H)
-#define GDBCORE_H 1
+#ifndef GDB_GDBCORE_H
+#define GDB_GDBCORE_H
 
 struct type;
 struct regcache;
@@ -196,4 +196,4 @@ class thread_section_name
   std::string m_storage;
 };
 
-#endif /* !defined (GDBCORE_H) */
+#endif /* GDB_GDBCORE_H */
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 73f6895fe46..490d05db340 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDBTHREAD_H
-#define GDBTHREAD_H
+#ifndef GDB_GDBTHREAD_H
+#define GDB_GDBTHREAD_H
 
 struct symtab;
 
@@ -1071,4 +1071,4 @@ extern void thread_try_catch_cmd (thread_info *thr,
 
 extern const char *thread_state_string (enum thread_state state);
 
-#endif /* GDBTHREAD_H */
+#endif /* GDB_GDBTHREAD_H */
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 55018f2c344..5182b54cc96 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDBTYPES_H)
-#define GDBTYPES_H 1
+#ifndef GDB_GDBTYPES_H
+#define GDB_GDBTYPES_H
 
 /* * \page gdbtypes GDB Types
 
@@ -2830,4 +2830,4 @@ extern unsigned int overload_debug;
 
 extern bool is_nocall_function (const struct type *type);
 
-#endif /* GDBTYPES_H */
+#endif /* GDB_GDBTYPES_H */
diff --git a/gdb/glibc-tdep.h b/gdb/glibc-tdep.h
index 264e1e707f2..17006d0fafc 100644
--- a/gdb/glibc-tdep.h
+++ b/gdb/glibc-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GLIBC_TDEP_H
-#define GLIBC_TDEP_H
+#ifndef GDB_GLIBC_TDEP_H
+#define GDB_GLIBC_TDEP_H
 
 struct gdbarch;
 
 extern CORE_ADDR glibc_skip_solib_resolver (struct gdbarch *gdbarch,
 					    CORE_ADDR);
 
-#endif /* glibc-tdep.h */
+#endif /* GDB_GLIBC_TDEP_H */
diff --git a/gdb/gmp-utils.h b/gdb/gmp-utils.h
index 51e06abc050..84ac0e7333b 100644
--- a/gdb/gmp-utils.h
+++ b/gdb/gmp-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GMP_UTILS_H
-#define GMP_UTILS_H
+#ifndef GDB_GMP_UTILS_H
+#define GDB_GMP_UTILS_H
 
 /* Include <stdio.h> and <stdarg.h> ahead of <gmp.h>, so as to get
    access to GMP's various formatting functions.  */
@@ -663,4 +663,4 @@ gdb_mpz::as_integer_truncate () const
   return result;
 }
 
-#endif
+#endif /* GDB_GMP_UTILS_H */
diff --git a/gdb/gnu-nat-mig.h b/gdb/gnu-nat-mig.h
index 4b9e78c99e2..01c1ed46f20 100644
--- a/gdb/gnu-nat-mig.h
+++ b/gdb/gnu-nat-mig.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GNU_NAT_MIG_H
-#define GNU_NAT_MIG_H
+#ifndef GDB_GNU_NAT_MIG_H
+#define GDB_GNU_NAT_MIG_H
 
 #include <mach/boolean.h>
 #include <mach/message.h>
@@ -28,4 +28,4 @@ boolean_t notify_server (mach_msg_header_t *InHeadP,
 boolean_t process_reply_server (mach_msg_header_t *InHeadP,
 				mach_msg_header_t *OutHeadP);
 
-#endif /* GNU_NAT_MIG_H */
+#endif /* GDB_GNU_NAT_MIG_H */
diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index f1694b8a3a7..700a01a7d17 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GNU_NAT_H
-#define GNU_NAT_H
+#ifndef GDB_GNU_NAT_H
+#define GDB_GNU_NAT_H
 
 /* Work around conflict between Mach's 'thread_info' function, and GDB's
    'thread_info' class.  Make the former available as 'mach_thread_info'.  */
@@ -188,4 +188,4 @@ struct gnu_nat_target : public inf_child_target
 /* The final/concrete instance.  */
 extern gnu_nat_target *gnu_target;
 
-#endif /* GNU_NAT_H */
+#endif /* GDB_GNU_NAT_H */
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
index 1aca9ddd118..030febc4215 100644
--- a/gdb/go-lang.h
+++ b/gdb/go-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GO_LANG_H)
-#define GO_LANG_H 1
+#ifndef GDB_GO_LANG_H
+#define GDB_GO_LANG_H
 
 struct type_print_options;
 
@@ -144,4 +144,4 @@ class go_language : public language_defn
   { return true; }
 };
 
-#endif /* !defined (GO_LANG_H) */
+#endif /* GDB_GO_LANG_H */
diff --git a/gdb/gregset.h b/gdb/gregset.h
index 8c14809a47d..9345625d98a 100644
--- a/gdb/gregset.h
+++ b/gdb/gregset.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GREGSET_H
-#define GREGSET_H
+#ifndef GDB_GREGSET_H
+#define GDB_GREGSET_H
 
 #ifdef HAVE_SYS_PROCFS_H
 #include <sys/procfs.h>
@@ -60,4 +60,4 @@ extern void fill_gregset (const struct regcache *regcache,
 extern void fill_fpregset (const struct regcache *regcache,
 			   gdb_fpregset_t *fpregs, int regno);
 
-#endif
+#endif /* GDB_GREGSET_H */
diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h
index be16fee0dd2..c2856478eed 100644
--- a/gdb/guile/guile-internal.h
+++ b/gdb/guile/guile-internal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GUILE_GUILE_INTERNAL_H
-#define GUILE_GUILE_INTERNAL_H
+#ifndef GDB_GUILE_GUILE_INTERNAL_H
+#define GDB_GUILE_GUILE_INTERNAL_H
 
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
@@ -722,4 +722,4 @@ gdbscm_wrap (Function &&func, Args &&... args)
   return result;
 }
 
-#endif /* GUILE_GUILE_INTERNAL_H */
+#endif /* GDB_GUILE_GUILE_INTERNAL_H */
diff --git a/gdb/guile/guile.h b/gdb/guile/guile.h
index 2ab1f7552c7..6ce4864aabd 100644
--- a/gdb/guile/guile.h
+++ b/gdb/guile/guile.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GUILE_GUILE_H
-#define GUILE_GUILE_H
+#ifndef GDB_GUILE_GUILE_H
+#define GDB_GUILE_GUILE_H
 
 #include "extension.h"
 
@@ -28,4 +28,4 @@ extern const struct extension_language_defn extension_language_guile;
 /* Command element for the 'guile' command.  */
 extern cmd_list_element *guile_cmd_element;
 
-#endif /* GUILE_GUILE_H */
+#endif /* GDB_GUILE_GUILE_H */
diff --git a/gdb/hppa-bsd-tdep.h b/gdb/hppa-bsd-tdep.h
index 42aefe6e142..54599ab9ab4 100644
--- a/gdb/hppa-bsd-tdep.h
+++ b/gdb/hppa-bsd-tdep.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_BSD_TDEP_H
-#define HPPA_BSD_TDEP_H
+#ifndef GDB_HPPA_BSD_TDEP_H
+#define GDB_HPPA_BSD_TDEP_H
 
 extern void hppabsd_init_abi (struct gdbarch_info, struct gdbarch *);
 
-#endif /* hppa-bsd-tdep.h */
+#endif /* GDB_HPPA_BSD_TDEP_H */
diff --git a/gdb/hppa-linux-offsets.h b/gdb/hppa-linux-offsets.h
index b1543b05705..958afd115a8 100644
--- a/gdb/hppa-linux-offsets.h
+++ b/gdb/hppa-linux-offsets.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_LINUX_OFFSETS_H
-#define HPPA_LINUX_OFFSETS_H
+#ifndef GDB_HPPA_LINUX_OFFSETS_H
+#define GDB_HPPA_LINUX_OFFSETS_H
 
 #define PT_PSW offsetof(struct pt_regs, gr[ 0])
 #define PT_GR1 offsetof(struct pt_regs, gr[ 1])
@@ -105,4 +105,4 @@
 #define PT_ISR offsetof(struct pt_regs, isr)
 #define PT_IOR offsetof(struct pt_regs, ior)
 
-#endif /* HPPA_LINUX_OFFSETS_H */
+#endif /* GDB_HPPA_LINUX_OFFSETS_H */
diff --git a/gdb/hppa-tdep.h b/gdb/hppa-tdep.h
index 0f706536cc9..e1143a56bcd 100644
--- a/gdb/hppa-tdep.h
+++ b/gdb/hppa-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef HPPA_TDEP_H
-#define HPPA_TDEP_H
+#ifndef GDB_HPPA_TDEP_H
+#define GDB_HPPA_TDEP_H
 
 #include "gdbarch.h"
 
@@ -214,4 +214,4 @@ extern int hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
 					  CORE_ADDR pc);
 extern CORE_ADDR hppa_skip_trampoline_code (const frame_info_ptr &, CORE_ADDR pc);
 
-#endif  /* hppa-tdep.h */
+#endif /* GDB_HPPA_TDEP_H */
diff --git a/gdb/i386-bsd-nat.h b/gdb/i386-bsd-nat.h
index a05eb90d4f8..54061ab46d1 100644
--- a/gdb/i386-bsd-nat.h
+++ b/gdb/i386-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_BSD_NAT_H
-#define I386_BSD_NAT_H
+#ifndef GDB_I386_BSD_NAT_H
+#define GDB_I386_BSD_NAT_H
 
 #include "x86-bsd-nat.h"
 
@@ -41,4 +41,4 @@ class i386_bsd_nat_target : public x86bsd_nat_target<BaseTarget>
   { i386bsd_store_inferior_registers (regcache, regnum); }
 };
 
-#endif /* i386-bsd-nat.h */
+#endif /* GDB_I386_BSD_NAT_H */
diff --git a/gdb/i386-darwin-tdep.h b/gdb/i386-darwin-tdep.h
index 0b867fab94c..7ccdeeced13 100644
--- a/gdb/i386-darwin-tdep.h
+++ b/gdb/i386-darwin-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_DARWIN_TDEP_H
-#define I386_DARWIN_TDEP_H
+#ifndef GDB_I386_DARWIN_TDEP_H
+#define GDB_I386_DARWIN_TDEP_H
 
 #include "frame.h"
 
@@ -29,4 +29,4 @@ extern const int i386_darwin_thread_state_num_regs;
 
 int darwin_dwarf_signal_frame_p (struct gdbarch *, const frame_info_ptr &);
 
-#endif /* I386_DARWIN_TDEP_H */
+#endif /* GDB_I386_DARWIN_TDEP_H */
diff --git a/gdb/i386-fbsd-tdep.h b/gdb/i386-fbsd-tdep.h
index 0a008421915..3b953e58435 100644
--- a/gdb/i386-fbsd-tdep.h
+++ b/gdb/i386-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_FBSD_TDEP_H
-#define I386_FBSD_TDEP_H
+#ifndef GDB_I386_FBSD_TDEP_H
+#define GDB_I386_FBSD_TDEP_H
 
 #include "gdbsupport/x86-xstate.h"
 #include "regset.h"
@@ -42,4 +42,4 @@ bool i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
 
 extern const struct regset i386_fbsd_gregset;
 
-#endif /* i386-fbsd-tdep.h */
+#endif /* GDB_I386_FBSD_TDEP_H */
diff --git a/gdb/i386-linux-nat.h b/gdb/i386-linux-nat.h
index c3d32aff1be..e4a86c70382 100644
--- a/gdb/i386-linux-nat.h
+++ b/gdb/i386-linux-nat.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_LINUX_NAT_H
-#define I386_LINUX_NAT_H 1
+#ifndef GDB_I386_LINUX_NAT_H
+#define GDB_I386_LINUX_NAT_H
 
 /* Does the current host support the GETFPXREGS request? */
 extern int have_ptrace_getfpxregs;
 
-#endif
+#endif /* GDB_I386_LINUX_NAT_H */
diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h
index 5891747572b..025b0f5fc51 100644
--- a/gdb/i386-linux-tdep.h
+++ b/gdb/i386-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_LINUX_TDEP_H
-#define I386_LINUX_TDEP_H
+#ifndef GDB_I386_LINUX_TDEP_H
+#define GDB_I386_LINUX_TDEP_H
 
 #include "gdbsupport/x86-xstate.h"
 
@@ -83,4 +83,4 @@ extern int i386_linux_gregset_reg_offset[];
 /* Return x86 siginfo type.  */
 extern struct type *x86_linux_get_siginfo_type (struct gdbarch *gdbarch);
 
-#endif /* i386-linux-tdep.h */
+#endif /* GDB_I386_LINUX_TDEP_H */
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index a85e0a984a0..e394e159c04 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I386_TDEP_H
-#define I386_TDEP_H
+#ifndef GDB_I386_TDEP_H
+#define GDB_I386_TDEP_H
 
 #include "gdbarch.h"
 #include "infrun.h"
@@ -488,4 +488,4 @@ extern int i386_stap_is_single_operand (struct gdbarch *gdbarch,
 extern expr::operation_up i386_stap_parse_special_token
      (struct gdbarch *gdbarch, struct stap_parse_info *p);
 
-#endif /* i386-tdep.h */
+#endif /* GDB_I386_TDEP_H */
diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h
index 30d769478a6..77e089ab723 100644
--- a/gdb/i387-tdep.h
+++ b/gdb/i387-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef I387_TDEP_H
-#define I387_TDEP_H
+#ifndef GDB_I387_TDEP_H
+#define GDB_I387_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -185,4 +185,4 @@ extern void i387_return_value (struct gdbarch *gdbarch,
    all memory range can be accessed.  */
 extern void i387_reset_bnd_regs (struct gdbarch *gdbarch,
 				 struct regcache *regcache);
-#endif /* i387-tdep.h */
+#endif /* GDB_I387_TDEP_H */
diff --git a/gdb/ia64-libunwind-tdep.h b/gdb/ia64-libunwind-tdep.h
index 4f064bfc333..9d358642d9f 100644
--- a/gdb/ia64-libunwind-tdep.h
+++ b/gdb/ia64-libunwind-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef IA64_LIBUNWIND_TDEP_H
-#define IA64_LIBUNWIND_TDEP_H 1
+#ifndef GDB_IA64_LIBUNWIND_TDEP_H
+#define GDB_IA64_LIBUNWIND_TDEP_H
 
 class frame_info_ptr;
 struct frame_id;
@@ -76,4 +76,4 @@ int libunwind_get_reg_special (struct gdbarch *gdbarch,
 			       readable_regcache *regcache,
 			       int regnum, void *buf);
 
-#endif /* IA64_LIBUNWIND_TDEP_H */
+#endif /* GDB_IA64_LIBUNWIND_TDEP_H */
diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h
index 64be38b4d76..e5eb7eac071 100644
--- a/gdb/ia64-tdep.h
+++ b/gdb/ia64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef IA64_TDEP_H
-#define IA64_TDEP_H
+#ifndef GDB_IA64_TDEP_H
+#define GDB_IA64_TDEP_H
 
 #include "gdbarch.h"
 
@@ -265,4 +265,4 @@ extern unw_accessors_t ia64_unw_rse_accessors;
 extern struct libunwind_descr ia64_libunwind_descr;
 #endif
 
-#endif /* ia64-tdep.h */
+#endif /* GDB_IA64_TDEP_H */
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index 91955a64f4c..2a251b365f2 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_CHILD_H
-#define INF_CHILD_H
+#ifndef GDB_INF_CHILD_H
+#define GDB_INF_CHILD_H
 
 #include "target.h"
 #include "process-stratum-target.h"
@@ -115,4 +115,4 @@ extern void add_inf_child_target (inf_child_target *target);
    targets use add_inf_child_target instead.  */
 extern void inf_child_open_target (const char *arg, int from_tty);
 
-#endif
+#endif /* GDB_INF_CHILD_H */
diff --git a/gdb/inf-loop.h b/gdb/inf-loop.h
index ceabd14bd9e..2bf29fa7498 100644
--- a/gdb/inf-loop.h
+++ b/gdb/inf-loop.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_LOOP_H
-#define INF_LOOP_H
+#ifndef GDB_INF_LOOP_H
+#define GDB_INF_LOOP_H
 
 #include "target.h"
 
 extern void inferior_event_handler (enum inferior_event_type event_type);
 
-#endif /* #ifndef INF_LOOP_H */
+#endif /* GDB_INF_LOOP_H */
diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h
index 868bee92da8..901f7e9162d 100644
--- a/gdb/inf-ptrace.h
+++ b/gdb/inf-ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INF_PTRACE_H
-#define INF_PTRACE_H
+#ifndef GDB_INF_PTRACE_H
+#define GDB_INF_PTRACE_H
 
 #include "gdbsupport/event-pipe.h"
 #include "inf-child.h"
@@ -113,4 +113,4 @@ struct inf_ptrace_target : public inf_child_target
 extern pid_t get_ptrace_pid (ptid_t);
 #endif
 
-#endif
+#endif /* GDB_INF_PTRACE_H */
diff --git a/gdb/infcall.h b/gdb/infcall.h
index dcc701b5f31..eccf13307c7 100644
--- a/gdb/infcall.h
+++ b/gdb/infcall.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFCALL_H
-#define INFCALL_H
+#ifndef GDB_INFCALL_H
+#define GDB_INFCALL_H
 
 #include "dummy-frame.h"
 #include "gdbsupport/array-view.h"
@@ -71,4 +71,4 @@ extern struct value *
 
 extern void error_call_unknown_return_type (const char *func_name);
 
-#endif
+#endif /* GDB_INFCALL_H */
diff --git a/gdb/inferior-iter.h b/gdb/inferior-iter.h
index 821c7bec94e..05ddfca54c9 100644
--- a/gdb/inferior-iter.h
+++ b/gdb/inferior-iter.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFERIOR_ITER_H
-#define INFERIOR_ITER_H
+#ifndef GDB_INFERIOR_ITER_H
+#define GDB_INFERIOR_ITER_H
 
 #include "gdbsupport/filtered-iterator.h"
 #include "gdbsupport/safe-iterator.h"
@@ -132,4 +132,4 @@ using all_inferiors_safe_iterator
 
 using all_inferiors_safe_range = iterator_range<all_inferiors_safe_iterator>;
 
-#endif /* !defined (INFERIOR_ITER_H) */
+#endif /* GDB_INFERIOR_ITER_H */
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 7be28423aeb..4163396b775 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (INFERIOR_H)
-#define INFERIOR_H 1
+#ifndef GDB_INFERIOR_H
+#define GDB_INFERIOR_H
 
 #include <exception>
 #include <list>
@@ -869,4 +869,4 @@ valid_global_inferior_id (int id)
   return false;
 }
 
-#endif /* !defined (INFERIOR_H) */
+#endif /* GDB_INFERIOR_H */
diff --git a/gdb/infrun.h b/gdb/infrun.h
index 5f83ca2b4c3..4574874706e 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INFRUN_H
-#define INFRUN_H 1
+#ifndef GDB_INFRUN_H
+#define GDB_INFRUN_H
 
 #include "gdbthread.h"
 #include "symtab.h"
@@ -418,4 +418,4 @@ struct scoped_enable_commit_resumed
 };
 
 
-#endif /* INFRUN_H */
+#endif /* GDB_INFRUN_H */
diff --git a/gdb/inline-frame.h b/gdb/inline-frame.h
index bbe617c7c5b..a11376f1d43 100644
--- a/gdb/inline-frame.h
+++ b/gdb/inline-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (INLINE_FRAME_H)
-#define INLINE_FRAME_H 1
+#ifndef GDB_INLINE_FRAME_H
+#define GDB_INLINE_FRAME_H
 
 class frame_info_ptr;
 struct frame_unwind;
@@ -70,4 +70,4 @@ struct symbol *inline_skipped_symbol (thread_info *thread);
 
 int frame_inlined_callees (const frame_info_ptr &this_frame);
 
-#endif /* !defined (INLINE_FRAME_H) */
+#endif /* GDB_INLINE_FRAME_H */
diff --git a/gdb/interps.h b/gdb/interps.h
index bd435d734af..726b660684e 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef INTERPS_H
-#define INTERPS_H
+#ifndef GDB_INTERPS_H
+#define GDB_INTERPS_H
 
 #include "gdbsupport/intrusive_list.h"
 
@@ -372,4 +372,4 @@ extern void interps_notify_memory_changed (inferior *inf, CORE_ADDR addr,
 #define INTERP_TUI		"tui"
 #define INTERP_INSIGHT		"insight"
 
-#endif
+#endif /* GDB_INTERPS_H */
diff --git a/gdb/jit.h b/gdb/jit.h
index ade0fb28ce2..59ad900c4e0 100644
--- a/gdb/jit.h
+++ b/gdb/jit.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef JIT_H
-#define JIT_H
+#ifndef GDB_JIT_H
+#define GDB_JIT_H
 
 struct inferior;
 struct objfile;
@@ -122,4 +122,4 @@ extern void jit_breakpoint_re_set (void);
 
 extern void jit_event_handler (gdbarch *gdbarch, objfile *jiter);
 
-#endif /* JIT_H */
+#endif /* GDB_JIT_H */
diff --git a/gdb/language.h b/gdb/language.h
index e67150d7596..157c46877d2 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (LANGUAGE_H)
-#define LANGUAGE_H 1
+#ifndef GDB_LANGUAGE_H
+#define GDB_LANGUAGE_H
 
 #include "symtab.h"
 #include "gdbsupport/function-view.h"
@@ -911,4 +911,4 @@ class scoped_switch_to_sym_language_if_auto
   enum language m_lang;
 };
 
-#endif /* defined (LANGUAGE_H) */
+#endif /* GDB_LANGUAGE_H */
diff --git a/gdb/linespec.h b/gdb/linespec.h
index 18f491d74d0..86eb36bbae9 100644
--- a/gdb/linespec.h
+++ b/gdb/linespec.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (LINESPEC_H)
-#define LINESPEC_H 1
+#ifndef GDB_LINESPEC_H
+#define GDB_LINESPEC_H
 
 struct symtab;
 
@@ -201,4 +201,4 @@ extern void linespec_complete_label (completion_tracker &tracker,
    advancing EXP_PTR past any parsed text.  */
 
 extern CORE_ADDR linespec_expression_to_pc (const char **exp_ptr);
-#endif /* defined (LINESPEC_H) */
+#endif /* GDB_LINESPEC_H */
diff --git a/gdb/linux-fork.h b/gdb/linux-fork.h
index c553aaf0740..2a306881695 100644
--- a/gdb/linux-fork.h
+++ b/gdb/linux-fork.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_FORK_H
-#define LINUX_FORK_H
+#ifndef GDB_LINUX_FORK_H
+#define GDB_LINUX_FORK_H
 
 struct fork_info;
 struct lwp_info;
@@ -30,4 +30,4 @@ extern void linux_fork_detach (int, lwp_info *);
 extern int forks_exist_p (void);
 extern int linux_fork_checkpointing_p (int);
 
-#endif /* LINUX_FORK_H */
+#endif /* GDB_LINUX_FORK_H */
diff --git a/gdb/linux-nat-trad.h b/gdb/linux-nat-trad.h
index ae40ce773b4..c1c031ea27d 100644
--- a/gdb/linux-nat-trad.h
+++ b/gdb/linux-nat-trad.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_NAT_TRAD_H
-#define LINUX_NAT_TRAD_H
+#ifndef GDB_LINUX_NAT_TRAD_H
+#define GDB_LINUX_NAT_TRAD_H
 
 #include "linux-nat.h"
 
@@ -43,4 +43,4 @@ class linux_nat_trad_target : public linux_nat_target
   void store_register (const struct regcache *regcache, int regnum);
 };
 
-#endif /* LINUX_NAT_TRAD_H */
+#endif /* GDB_LINUX_NAT_TRAD_H */
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 4dcbe9e170a..01e071e0f89 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_NAT_H
-#define LINUX_NAT_H
+#ifndef GDB_LINUX_NAT_H
+#define GDB_LINUX_NAT_H
 
 #include "nat/linux-nat.h"
 #include "inf-ptrace.h"
@@ -339,4 +339,4 @@ void linux_nat_switch_fork (ptid_t new_ptid);
    uninitialized in such case).  */
 bool linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
 
-#endif /* LINUX_NAT_H */
+#endif /* GDB_LINUX_NAT_H */
diff --git a/gdb/linux-record.h b/gdb/linux-record.h
index 962cedc3d34..26d113b6a65 100644
--- a/gdb/linux-record.h
+++ b/gdb/linux-record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_RECORD_H
-#define LINUX_RECORD_H
+#ifndef GDB_LINUX_RECORD_H
+#define GDB_LINUX_RECORD_H
 
 struct linux_record_tdep
 {
@@ -549,4 +549,4 @@ extern int record_linux_system_call (enum gdb_syscall num,
 				     struct regcache *regcache,
 				     struct linux_record_tdep *tdep);
 
-#endif /* LINUX_RECORD_H */
+#endif /* GDB_LINUX_RECORD_H */
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index 66b03cabaa6..bf4220bf75b 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LINUX_TDEP_H
-#define LINUX_TDEP_H
+#ifndef GDB_LINUX_TDEP_H
+#define GDB_LINUX_TDEP_H
 
 #include "bfd.h"
 #include "displaced-stepping.h"
@@ -117,4 +117,4 @@ extern CORE_ADDR linux_get_hwcap2 ();
 extern struct link_map_offsets *linux_ilp32_fetch_link_map_offsets ();
 extern struct link_map_offsets *linux_lp64_fetch_link_map_offsets ();
 
-#endif /* linux-tdep.h */
+#endif /* GDB_LINUX_TDEP_H */
diff --git a/gdb/location.h b/gdb/location.h
index e8cdd0d4ec6..7772d10426f 100644
--- a/gdb/location.h
+++ b/gdb/location.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LOCATION_H
-#define LOCATION_H
+#ifndef GDB_LOCATION_H
+#define GDB_LOCATION_H
 
 #include "symtab.h"
 
@@ -365,4 +365,4 @@ extern location_spec_up
 				    const struct language_defn *language,
 				    explicit_completion_info *completion_info);
 
-#endif /* LOCATION_H */
+#endif /* GDB_LOCATION_H */
diff --git a/gdb/loongarch-tdep.h b/gdb/loongarch-tdep.h
index 5c8108182ad..4908923db20 100644
--- a/gdb/loongarch-tdep.h
+++ b/gdb/loongarch-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef LOONGARCH_TDEP_H
-#define LOONGARCH_TDEP_H
+#ifndef GDB_LOONGARCH_TDEP_H
+#define GDB_LOONGARCH_TDEP_H
 
 #include "gdbarch.h"
 #include "arch/loongarch.h"
@@ -44,4 +44,4 @@ struct loongarch_gdbarch_tdep : gdbarch_tdep_base
   CORE_ADDR (*syscall_next_pc) (const frame_info_ptr &frame) = nullptr;
 };
 
-#endif /* LOONGARCH_TDEP_H  */
+#endif /* GDB_LOONGARCH_TDEP_H */
diff --git a/gdb/m2-exp.h b/gdb/m2-exp.h
index 9d2634f813b..ce773cbf864 100644
--- a/gdb/m2-exp.h
+++ b/gdb/m2-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M2_EXP_H
-#define M2_EXP_H
+#ifndef GDB_M2_EXP_H
+#define GDB_M2_EXP_H
 
 #include "expop.h"
 
@@ -81,4 +81,4 @@ class m2_binop_subscript_operation
 
 } /* namespace expr */
 
-#endif /* M2_EXP_H */
+#endif /* GDB_M2_EXP_H */
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index 3d3c6980bb2..1551d7e00d6 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M2_LANG_H
-#define M2_LANG_H
+#ifndef GDB_M2_LANG_H
+#define GDB_M2_LANG_H
 
 struct type_print_options;
 struct parser_state;
@@ -149,4 +149,4 @@ class m2_language : public language_defn
   { return true; }
 };
 
-#endif /* M2_LANG_H */
+#endif /* GDB_M2_LANG_H */
diff --git a/gdb/m32r-tdep.h b/gdb/m32r-tdep.h
index 83799a3c698..1cc0de38c15 100644
--- a/gdb/m32r-tdep.h
+++ b/gdb/m32r-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M32R_TDEP_H
-#define M32R_TDEP_H
+#ifndef GDB_M32R_TDEP_H
+#define GDB_M32R_TDEP_H
 
 #include "gdbarch.h"
 
@@ -49,4 +49,4 @@ enum m32r_regnum
 
 #define M32R_NUM_REGS 25
 
-#endif /* m32r-tdep.h */
+#endif /* GDB_M32R_TDEP_H */
diff --git a/gdb/m68k-tdep.h b/gdb/m68k-tdep.h
index dcb3728896e..ad569932144 100644
--- a/gdb/m68k-tdep.h
+++ b/gdb/m68k-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef M68K_TDEP_H
-#define M68K_TDEP_H
+#ifndef GDB_M68K_TDEP_H
+#define GDB_M68K_TDEP_H
 
 #include "gdbarch.h"
 
@@ -111,4 +111,4 @@ extern void m68k_svr4_init_abi (struct gdbarch_info, struct gdbarch *);
 
 extern int m68kbsd_fpreg_offset (struct gdbarch *gdbarch, int regnum);
 
-#endif /* m68k-tdep.h */
+#endif /* GDB_M68K_TDEP_H */
diff --git a/gdb/macroexp.h b/gdb/macroexp.h
index 2706f15787f..6fd5dc27916 100644
--- a/gdb/macroexp.h
+++ b/gdb/macroexp.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef MACROEXP_H
-#define MACROEXP_H
+#ifndef GDB_MACROEXP_H
+#define GDB_MACROEXP_H
 
 struct macro_scope;
 
@@ -81,4 +81,4 @@ int macro_is_digit (int c);
 /* Stringify STR according to C rules and return a null-terminated string.  */
 gdb::unique_xmalloc_ptr<char> macro_stringify (const char *str);
 
-#endif /* MACROEXP_H */
+#endif /* GDB_MACROEXP_H */
diff --git a/gdb/macroscope.h b/gdb/macroscope.h
index 6a1f5f0a3fe..ce9ae33838f 100644
--- a/gdb/macroscope.h
+++ b/gdb/macroscope.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MACROSCOPE_H
-#define MACROSCOPE_H
+#ifndef GDB_MACROSCOPE_H
+#define GDB_MACROSCOPE_H
 
 #include "macrotab.h"
 #include "symtab.h"
@@ -61,4 +61,4 @@ gdb::unique_xmalloc_ptr<struct macro_scope> default_macro_scope (void);
 macro_definition *standard_macro_lookup (const char *name,
 					 const macro_scope &ms);
 
-#endif /* MACROSCOPE_H */
+#endif /* GDB_MACROSCOPE_H */
diff --git a/gdb/macrotab.h b/gdb/macrotab.h
index 789beed0476..ea6557aa391 100644
--- a/gdb/macrotab.h
+++ b/gdb/macrotab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MACROTAB_H
-#define MACROTAB_H
+#ifndef GDB_MACROTAB_H
+#define GDB_MACROTAB_H
 
 #include "gdbsupport/function-view.h"
 
@@ -361,4 +361,4 @@ void macro_for_each_in_scope (struct macro_source_file *file, int line,
    of macro filenames printing was "absolute".  */
 extern std::string macro_source_fullname (struct macro_source_file *file);
 
-#endif /* MACROTAB_H */
+#endif /* GDB_MACROTAB_H */
diff --git a/gdb/main.h b/gdb/main.h
index fa267786d89..35dfe9d4729 100644
--- a/gdb/main.h
+++ b/gdb/main.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MAIN_H
-#define MAIN_H
+#ifndef GDB_MAIN_H
+#define GDB_MAIN_H
 
 struct captured_main_args
 {
@@ -46,4 +46,4 @@ extern char *windows_get_absolute_argv0 (const char *argv0);
 
 extern void set_gdb_data_directory (const char *new_data_dir);
 
-#endif
+#endif /* GDB_MAIN_H */
diff --git a/gdb/maint.h b/gdb/maint.h
index c1860d8cd59..5529d8a9d3a 100644
--- a/gdb/maint.h
+++ b/gdb/maint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MAINT_H
-#define MAINT_H
+#ifndef GDB_MAINT_H
+#define GDB_MAINT_H
 
 #include "gdbsupport/run-time-clock.h"
 #include <chrono>
@@ -70,4 +70,4 @@ class scoped_command_stats
 extern obj_section *maint_obj_section_from_bfd_section (bfd *abfd,
 							asection *asection,
 							objfile *ofile);
-#endif /* MAINT_H */
+#endif /* GDB_MAINT_H */
diff --git a/gdb/mdebugread.h b/gdb/mdebugread.h
index af0584bd3e6..4f434226ff9 100644
--- a/gdb/mdebugread.h
+++ b/gdb/mdebugread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MDEBUGREAD_H
-#define MDEBUGREAD_H
+#ifndef GDB_MDEBUGREAD_H
+#define GDB_MDEBUGREAD_H
 
 #include "coff/sym.h"
 #include "coff/symconst.h"
@@ -46,4 +46,4 @@ extern void elfmdebug_build_psymtabs (struct objfile *,
 				      const struct ecoff_debug_swap *,
 				      asection *);
 
-#endif /* MDEBUGREAD_H */
+#endif /* GDB_MDEBUGREAD_H */
diff --git a/gdb/memattr.h b/gdb/memattr.h
index dcc52298846..a6c9e6dcd8c 100644
--- a/gdb/memattr.h
+++ b/gdb/memattr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMATTR_H
-#define MEMATTR_H
+#ifndef GDB_MEMATTR_H
+#define GDB_MEMATTR_H
 
 enum mem_access_mode
 {
@@ -129,4 +129,4 @@ extern struct mem_region *lookup_mem_region (CORE_ADDR);
 
 void invalidate_target_mem_regions (void);
 
-#endif	/* MEMATTR_H */
+#endif /* GDB_MEMATTR_H */
diff --git a/gdb/memory-map.h b/gdb/memory-map.h
index 525646b6e37..59fcd4a9f73 100644
--- a/gdb/memory-map.h
+++ b/gdb/memory-map.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef MEMORY_MAP_H
-#define MEMORY_MAP_H
+#ifndef GDB_MEMORY_MAP_H
+#define GDB_MEMORY_MAP_H
 
 #include "memattr.h"
 
@@ -28,4 +28,4 @@
    return an empty vector.  Does not throw.  */
 std::vector<mem_region> parse_memory_map (const char *memory_map);
 
-#endif
+#endif /* GDB_MEMORY_MAP_H */
diff --git a/gdb/memrange.h b/gdb/memrange.h
index 74df82588f4..ec033ddb21e 100644
--- a/gdb/memrange.h
+++ b/gdb/memrange.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMRANGE_H
-#define MEMRANGE_H
+#ifndef GDB_MEMRANGE_H
+#define GDB_MEMRANGE_H
 
 /* Defines a [START, START + LENGTH) memory range.  */
 
@@ -64,4 +64,4 @@ extern int address_in_mem_range (CORE_ADDR addr,
 
 extern void normalize_mem_ranges (std::vector<mem_range> *memory);
 
-#endif
+#endif /* GDB_MEMRANGE_H */
diff --git a/gdb/memtag.h b/gdb/memtag.h
index b176371699c..600b4b9db74 100644
--- a/gdb/memtag.h
+++ b/gdb/memtag.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MEMTAG_H
-#define MEMTAG_H
+#ifndef GDB_MEMTAG_H
+#define GDB_MEMTAG_H
 
 #include "bfd.h"
 
@@ -47,4 +47,4 @@ bool get_next_core_memtag_section (bfd *abfd, asection *section,
 				   CORE_ADDR address,
 				   memtag_section_info &info);
 
-#endif /* MEMTAG_H */
+#endif /* GDB_MEMTAG_H */
diff --git a/gdb/mi/mi-cmd-break.h b/gdb/mi/mi-cmd-break.h
index 76aedfffcd9..160c578865d 100644
--- a/gdb/mi/mi-cmd-break.h
+++ b/gdb/mi/mi-cmd-break.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CMD_BREAK_H
-#define MI_MI_CMD_BREAK_H
+#ifndef GDB_MI_MI_CMD_BREAK_H
+#define GDB_MI_MI_CMD_BREAK_H
 
 #include "gdbsupport/scoped_restore.h"
 
@@ -27,4 +27,4 @@
    catchpoint.  */
 scoped_restore_tmpl<int> setup_breakpoint_reporting (void);
 
-#endif /* MI_MI_CMD_BREAK_H */
+#endif /* GDB_MI_MI_CMD_BREAK_H */
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index 26faded3032..9e31ba397b0 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CMDS_H
-#define MI_MI_CMDS_H
+#ifndef GDB_MI_MI_CMDS_H
+#define GDB_MI_MI_CMDS_H
 
 #include "gdbsupport/function-view.h"
 #include <optional>
@@ -237,4 +237,4 @@ extern void remove_mi_cmd_entries (remove_mi_cmd_entries_ftype callback);
 
 extern bool mi_simple_type_p (struct type *type);
 
-#endif /* MI_MI_CMDS_H */
+#endif /* GDB_MI_MI_CMDS_H */
diff --git a/gdb/mi/mi-common.h b/gdb/mi/mi-common.h
index 38ad35c3e36..4c3951ca8c0 100644
--- a/gdb/mi/mi-common.h
+++ b/gdb/mi/mi-common.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_COMMON_H
-#define MI_MI_COMMON_H
+#ifndef GDB_MI_MI_COMMON_H
+#define GDB_MI_MI_COMMON_H
 
 /* Represents the reason why GDB is sending an asynchronous command to
    the front end.  NOTE: When modifying this, don't forget to update
@@ -49,4 +49,4 @@ enum async_reply_reason
 
 const char *async_reason_lookup (enum async_reply_reason reason);
 
-#endif /* MI_MI_COMMON_H */
+#endif /* GDB_MI_MI_COMMON_H */
diff --git a/gdb/mi/mi-console.h b/gdb/mi/mi-console.h
index 89ba199fbce..89e0f4d3db6 100644
--- a/gdb/mi/mi-console.h
+++ b/gdb/mi/mi-console.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_CONSOLE_H
-#define MI_MI_CONSOLE_H
+#ifndef GDB_MI_MI_CONSOLE_H
+#define GDB_MI_MI_CONSOLE_H
 
 /* An output stream for MI.  Wraps a given output stream with a prefix
    and handles quoting.  This stream is locally buffered.  */
@@ -55,4 +55,4 @@ class mi_console_file : public ui_file
   char m_quote;
 };
 
-#endif /* MI_MI_CONSOLE_H */
+#endif /* GDB_MI_MI_CONSOLE_H */
diff --git a/gdb/mi/mi-getopt.h b/gdb/mi/mi-getopt.h
index f3dd326fced..5bc35aa565a 100644
--- a/gdb/mi/mi-getopt.h
+++ b/gdb/mi/mi-getopt.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_GETOPT_H
-#define MI_MI_GETOPT_H
+#ifndef GDB_MI_MI_GETOPT_H
+#define GDB_MI_MI_GETOPT_H
 
 /* The option list.  Terminated by NAME==NULL.  ARG_P that the option
    requires an argument.  INDEX is returned to identify the option.  */
@@ -78,4 +78,4 @@ extern int mi_getopt_allow_unknown (const char *prefix, int argc,
 extern int mi_valid_noargs (const char *prefix, int argc,
 			    const char *const *argv);
 
-#endif /* MI_MI_GETOPT_H */
+#endif /* GDB_MI_MI_GETOPT_H */
diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h
index cd48fcf0aa1..8f5eee6f558 100644
--- a/gdb/mi/mi-interp.h
+++ b/gdb/mi/mi-interp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_INTERP_H
-#define MI_MI_INTERP_H
+#ifndef GDB_MI_MI_INTERP_H
+#define GDB_MI_MI_INTERP_H
 
 #include "interps.h"
 
@@ -119,4 +119,4 @@ as_mi_interp (struct interp *interp)
   return dynamic_cast<mi_interp *> (interp);
 }
 
-#endif /* MI_MI_INTERP_H */
+#endif /* GDB_MI_MI_INTERP_H */
diff --git a/gdb/mi/mi-main.h b/gdb/mi/mi-main.h
index 59c9ffa31bb..af670295c1f 100644
--- a/gdb/mi/mi-main.h
+++ b/gdb/mi/mi-main.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_MAIN_H
-#define MI_MI_MAIN_H
+#ifndef GDB_MI_MI_MAIN_H
+#define GDB_MI_MI_MAIN_H
 
 struct ui_file;
 
@@ -79,4 +79,4 @@ extern void mi_cmd_fix_breakpoint_script_output (const char *command,
 
 extern int mi_parse_thread_group_id (const char *id);
 
-#endif /* MI_MI_MAIN_H */
+#endif /* GDB_MI_MI_MAIN_H */
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index a7afb156ed4..16e6db2456e 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_OUT_H
-#define MI_MI_OUT_H
+#ifndef GDB_MI_MI_OUT_H
+#define GDB_MI_MI_OUT_H
 
 #include <vector>
 
@@ -151,4 +151,4 @@ std::unique_ptr<mi_ui_out> mi_out_new (const char *mi_version);
 void mi_out_put (ui_out *uiout, struct ui_file *stream);
 void mi_out_rewind (ui_out *uiout);
 
-#endif /* MI_MI_OUT_H */
+#endif /* GDB_MI_MI_OUT_H */
diff --git a/gdb/mi/mi-parse.h b/gdb/mi/mi-parse.h
index 8b685755a5c..22d10185925 100644
--- a/gdb/mi/mi-parse.h
+++ b/gdb/mi/mi-parse.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MI_MI_PARSE_H
-#define MI_MI_PARSE_H
+#ifndef GDB_MI_MI_PARSE_H
+#define GDB_MI_MI_PARSE_H
 
 #include "gdbsupport/run-time-clock.h"
 #include <chrono>
@@ -101,4 +101,4 @@ struct mi_parse
 
 enum print_values mi_parse_print_values (const char *name);
 
-#endif /* MI_MI_PARSE_H */
+#endif /* GDB_MI_MI_PARSE_H */
diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
index 0b4a5a3f472..7b5924e9317 100644
--- a/gdb/microblaze-tdep.h
+++ b/gdb/microblaze-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MICROBLAZE_TDEP_H
-#define MICROBLAZE_TDEP_H 1
+#ifndef GDB_MICROBLAZE_TDEP_H
+#define GDB_MICROBLAZE_TDEP_H
 
 #include "gdbarch.h"
 
@@ -120,4 +120,4 @@ struct microblaze_frame_cache
    Only used for native debugging.  */
 #define MICROBLAZE_BREAKPOINT {0xb9, 0xcc, 0x00, 0x60}
 
-#endif /* microblaze-tdep.h */
+#endif /* GDB_MICROBLAZE_TDEP_H */
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index d44f281939b..4d704f0d35b 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MINSYMS_H
-#define MINSYMS_H
+#ifndef GDB_MINSYMS_H
+#define GDB_MINSYMS_H
 
 struct type;
 
@@ -327,4 +327,4 @@ CORE_ADDR minimal_symbol_upper_bound (struct bound_minimal_symbol minsym);
 type *find_minsym_type_and_address (minimal_symbol *msymbol, objfile *objf,
 				    CORE_ADDR *address_p);
 
-#endif /* MINSYMS_H */
+#endif /* GDB_MINSYMS_H */
diff --git a/gdb/mips-fbsd-tdep.h b/gdb/mips-fbsd-tdep.h
index ec834d0474a..201b1e5a793 100644
--- a/gdb/mips-fbsd-tdep.h
+++ b/gdb/mips-fbsd-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_FBSD_TDEP_H
-#define MIPS_FBSD_TDEP_H
+#ifndef GDB_MIPS_FBSD_TDEP_H
+#define GDB_MIPS_FBSD_TDEP_H
 
 void mips_fbsd_supply_fpregs (struct regcache *, int, const void *, size_t);
 void mips_fbsd_supply_gregs (struct regcache *, int, const void *, size_t);
 void mips_fbsd_collect_fpregs (const struct regcache *, int, void *, size_t);
 void mips_fbsd_collect_gregs (const struct regcache *, int, void *, size_t);
 
-#endif /* MIPS_FBSD_TDEP_H */
+#endif /* GDB_MIPS_FBSD_TDEP_H */
diff --git a/gdb/mips-linux-tdep.h b/gdb/mips-linux-tdep.h
index 2c4c35954c4..8670c0b7e15 100644
--- a/gdb/mips-linux-tdep.h
+++ b/gdb/mips-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_LINUX_TDEP_H
-#define MIPS_LINUX_TDEP_H
+#ifndef GDB_MIPS_LINUX_TDEP_H
+#define GDB_MIPS_LINUX_TDEP_H
 
 /* Copied from <asm/elf.h>.  */
 #define ELF_NGREG       45
@@ -113,4 +113,4 @@ extern const struct target_desc *tdesc_mips64_linux;
 extern const struct target_desc *tdesc_mips_dsp_linux;
 extern const struct target_desc *tdesc_mips64_dsp_linux;
 
-#endif /* MIPS_LINUX_TDEP_H */
+#endif /* GDB_MIPS_LINUX_TDEP_H */
diff --git a/gdb/mips-netbsd-tdep.h b/gdb/mips-netbsd-tdep.h
index 034261fbf44..e9544f0f1bf 100644
--- a/gdb/mips-netbsd-tdep.h
+++ b/gdb/mips-netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_NBSD_TDEP_H
-#define MIPS_NBSD_TDEP_H
+#ifndef GDB_MIPS_NETBSD_TDEP_H
+#define GDB_MIPS_NETBSD_TDEP_H
 
 void mipsnbsd_supply_reg (struct regcache *, const char *, int);
 void mipsnbsd_fill_reg (const struct regcache *, char *, int);
@@ -26,4 +26,4 @@ void mipsnbsd_fill_reg (const struct regcache *, char *, int);
 void mipsnbsd_supply_fpreg (struct regcache *, const char *, int);
 void mipsnbsd_fill_fpreg (const struct regcache *, char *, int);
 
-#endif /* MIPS_NBSD_TDEP_H */
+#endif /* GDB_MIPS_NETBSD_TDEP_H */
diff --git a/gdb/mips-tdep.h b/gdb/mips-tdep.h
index eec1fb56f4e..df589cf71b8 100644
--- a/gdb/mips-tdep.h
+++ b/gdb/mips-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_TDEP_H
-#define MIPS_TDEP_H
+#ifndef GDB_MIPS_TDEP_H
+#define GDB_MIPS_TDEP_H
 
 #include "objfiles.h"
 #include "gdbarch.h"
@@ -201,4 +201,4 @@ in_mips_stubs_section (CORE_ADDR pc)
   return pc_in_section (pc, ".MIPS.stubs");
 }
 
-#endif /* MIPS_TDEP_H */
+#endif /* GDB_MIPS_TDEP_H */
diff --git a/gdb/mn10300-tdep.h b/gdb/mn10300-tdep.h
index 683a6ec2e14..bec5f04253a 100644
--- a/gdb/mn10300-tdep.h
+++ b/gdb/mn10300-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MN10300_TDEP_H
-#define MN10300_TDEP_H
+#ifndef GDB_MN10300_TDEP_H
+#define GDB_MN10300_TDEP_H
 
 #include "gdbarch.h"
 
@@ -88,4 +88,4 @@ get_am33_mode (gdbarch *arch)
   return tdep->am33_mode;
 }
 
-#endif /* MN10300_TDEP_H */
+#endif /* GDB_MN10300_TDEP_H */
diff --git a/gdb/moxie-tdep.h b/gdb/moxie-tdep.h
index 64bfc825fc1..329d9972b49 100644
--- a/gdb/moxie-tdep.h
+++ b/gdb/moxie-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MOXIE_TDEP_H
-#define MOXIE_TDEP_H
+#ifndef GDB_MOXIE_TDEP_H
+#define GDB_MOXIE_TDEP_H
 
 #include "gdbarch.h"
 
@@ -42,4 +42,4 @@ enum moxie_regnum
 
 #define MOXIE_NUM_REGS 18
 
-#endif /* moxie-tdep.h */
+#endif /* GDB_MOXIE_TDEP_H */
diff --git a/gdb/namespace.h b/gdb/namespace.h
index 232dcc03bd8..a9b020f6395 100644
--- a/gdb/namespace.h
+++ b/gdb/namespace.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAMESPACE_H
-#define NAMESPACE_H
+#ifndef GDB_NAMESPACE_H
+#define GDB_NAMESPACE_H
 
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbsupport/gdb_obstack.h"
@@ -127,4 +127,4 @@ extern void add_using_directive (struct using_direct **using_directives,
 				 const unsigned int decl_line,
 				 struct obstack *obstack);
 
-#endif /* NAMESPACE_H */
+#endif /* GDB_NAMESPACE_H */
diff --git a/gdb/nat/aarch64-hw-point.h b/gdb/nat/aarch64-hw-point.h
index bdcca932e57..f4db38b494d 100644
--- a/gdb/nat/aarch64-hw-point.h
+++ b/gdb/nat/aarch64-hw-point.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_HW_POINT_H
-#define NAT_AARCH64_HW_POINT_H
+#ifndef GDB_NAT_AARCH64_HW_POINT_H
+#define GDB_NAT_AARCH64_HW_POINT_H
 
 /* Macro definitions, data structures, and code for the hardware
    breakpoint and hardware watchpoint support follow.  We use the
@@ -128,4 +128,4 @@ void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state,
 
 int aarch64_region_ok_for_watchpoint (CORE_ADDR addr, int len);
 
-#endif /* NAT_AARCH64_HW_POINT_H */
+#endif /* GDB_NAT_AARCH64_HW_POINT_H */
diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h
index cf749c34ae7..618f79f1587 100644
--- a/gdb/nat/aarch64-linux-hw-point.h
+++ b/gdb/nat/aarch64-linux-hw-point.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_LINUX_HW_POINT_H
-#define NAT_AARCH64_LINUX_HW_POINT_H
+#ifndef GDB_NAT_AARCH64_LINUX_HW_POINT_H
+#define GDB_NAT_AARCH64_LINUX_HW_POINT_H
 
 #include "gdbsupport/break-common.h"
 
@@ -109,4 +109,4 @@ void aarch64_linux_get_debug_reg_capacity (int tid);
 
 struct aarch64_debug_reg_state *aarch64_get_debug_reg_state (pid_t pid);
 
-#endif /* NAT_AARCH64_LINUX_HW_POINT_H */
+#endif /* GDB_NAT_AARCH64_LINUX_HW_POINT_H */
diff --git a/gdb/nat/aarch64-linux.h b/gdb/nat/aarch64-linux.h
index f4df7481162..969bb52b812 100644
--- a/gdb/nat/aarch64-linux.h
+++ b/gdb/nat/aarch64-linux.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_LINUX_H
-#define NAT_AARCH64_LINUX_H
+#ifndef GDB_NAT_AARCH64_LINUX_H
+#define GDB_NAT_AARCH64_LINUX_H
 
 #include <signal.h>
 
@@ -133,4 +133,4 @@ ps_err_e aarch64_ps_get_thread_area (struct ps_prochandle *ph,
    used for aarch64 state.  */
 int aarch64_tls_register_count (int tid);
 
-#endif /* NAT_AARCH64_LINUX_H */
+#endif /* GDB_NAT_AARCH64_LINUX_H */
diff --git a/gdb/nat/aarch64-mte-linux-ptrace.h b/gdb/nat/aarch64-mte-linux-ptrace.h
index 28dd8158c90..e02a0818963 100644
--- a/gdb/nat/aarch64-mte-linux-ptrace.h
+++ b/gdb/nat/aarch64-mte-linux-ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_MTE_LINUX_PTRACE_H
-#define NAT_AARCH64_MTE_LINUX_PTRACE_H
+#ifndef GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
+#define GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
 
 /* MTE allocation tag access */
 
@@ -47,4 +47,4 @@ extern bool aarch64_mte_fetch_memtags (int tid, CORE_ADDR address, size_t len,
 extern bool aarch64_mte_store_memtags (int tid, CORE_ADDR address, size_t len,
 				       const gdb::byte_vector &tags);
 
-#endif /* NAT_AARCH64_MTE_LINUX_PTRACE_H */
+#endif /* GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H */
diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h
index 2be45588785..2c6d899e931 100644
--- a/gdb/nat/aarch64-scalable-linux-ptrace.h
+++ b/gdb/nat/aarch64-scalable-linux-ptrace.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
-#define NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
+#ifndef GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
+#define GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
 
 #include <signal.h>
 #include <sys/utsname.h>
@@ -176,4 +176,4 @@ aarch64_zt_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf,
 extern void
 aarch64_zt_regs_copy_from_reg_buf (int tid, struct reg_buffer_common *reg_buf,
 				   int zt_regnum);
-#endif /* NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */
+#endif /* GDB_NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */
diff --git a/gdb/nat/aarch64-scalable-linux-sigcontext.h b/gdb/nat/aarch64-scalable-linux-sigcontext.h
index 8db524250a8..bfda9be617a 100644
--- a/gdb/nat/aarch64-scalable-linux-sigcontext.h
+++ b/gdb/nat/aarch64-scalable-linux-sigcontext.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
-#define NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
+#ifndef GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
+#define GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H
 
 #ifndef SVE_SIG_ZREGS_SIZE
 
@@ -325,4 +325,4 @@ struct user_za_header {
 	(ZA_PT_ZA_OFFSET + ZA_PT_ZA_SIZE(vq))
 #endif /* ZA_PT_SIZE */
 
-#endif /* NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H */
+#endif /* GDB_NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H */
diff --git a/gdb/nat/amd64-linux-siginfo.h b/gdb/nat/amd64-linux-siginfo.h
index b8fd8c0e2ae..1e102ae99b3 100644
--- a/gdb/nat/amd64-linux-siginfo.h
+++ b/gdb/nat/amd64-linux-siginfo.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_AMD64_LINUX_SIGINFO_H
-#define NAT_AMD64_LINUX_SIGINFO_H
+#ifndef GDB_NAT_AMD64_LINUX_SIGINFO_H
+#define GDB_NAT_AMD64_LINUX_SIGINFO_H
 
 #include <signal.h>
 
@@ -55,4 +55,4 @@ int amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf,
 				      int direction,
 				      enum amd64_siginfo_fixup_mode mode);
 
-#endif /* NAT_AMD64_LINUX_SIGINFO_H */
+#endif /* GDB_NAT_AMD64_LINUX_SIGINFO_H */
diff --git a/gdb/nat/fork-inferior.h b/gdb/nat/fork-inferior.h
index a609f68bcb4..509aa053764 100644
--- a/gdb/nat/fork-inferior.h
+++ b/gdb/nat/fork-inferior.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_FORK_INFERIOR_H
-#define NAT_FORK_INFERIOR_H
+#ifndef GDB_NAT_FORK_INFERIOR_H
+#define GDB_NAT_FORK_INFERIOR_H
 
 #include <string>
 #include "gdbsupport/function-view.h"
@@ -87,4 +87,4 @@ extern void trace_start_error (const char *fmt, ...)
 extern void trace_start_error_with_name (const char *string)
   ATTRIBUTE_NORETURN;
 
-#endif /* NAT_FORK_INFERIOR_H */
+#endif /* GDB_NAT_FORK_INFERIOR_H */
diff --git a/gdb/nat/gdb_ptrace.h b/gdb/nat/gdb_ptrace.h
index 81727cbdbd6..17858848a62 100644
--- a/gdb/nat/gdb_ptrace.h
+++ b/gdb/nat/gdb_ptrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GDB_PTRACE_H
-#define NAT_GDB_PTRACE_H
+#ifndef GDB_NAT_GDB_PTRACE_H
+#define GDB_NAT_GDB_PTRACE_H
 
 /* The <sys/ptrace.h> header was introduced with 4.4BSD, and provided
    the PT_* symbolic constants for the ptrace(2) request numbers.  The
@@ -142,4 +142,4 @@
 	 ptrace ((PTRACE_TYPE_ARG1) request, pid, addr, data)
 #endif
 
-#endif /* NAT_GDB_PTRACE_H */
+#endif /* GDB_NAT_GDB_PTRACE_H */
diff --git a/gdb/nat/gdb_thread_db.h b/gdb/nat/gdb_thread_db.h
index 0e683787c40..446b92129dd 100644
--- a/gdb/nat/gdb_thread_db.h
+++ b/gdb/nat/gdb_thread_db.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GDB_THREAD_DB_H
-#define NAT_GDB_THREAD_DB_H
+#ifndef GDB_NAT_GDB_THREAD_DB_H
+#define GDB_NAT_GDB_THREAD_DB_H
 
 #ifdef HAVE_THREAD_DB_H
 #include <thread_db.h>
@@ -73,4 +73,4 @@ typedef td_err_e (td_thr_tlsbase_ftype) (const td_thrhandle_t *th,
 typedef const char ** (td_symbol_list_ftype) (void);
 typedef td_err_e (td_ta_delete_ftype) (td_thragent_t *);
 
-#endif /* NAT_GDB_THREAD_DB_H */
+#endif /* GDB_NAT_GDB_THREAD_DB_H */
diff --git a/gdb/nat/glibc_thread_db.h b/gdb/nat/glibc_thread_db.h
index 598805deef2..87eb62b3efe 100644
--- a/gdb/nat/glibc_thread_db.h
+++ b/gdb/nat/glibc_thread_db.h
@@ -16,8 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_GLIBC_THREAD_DB_H
-#define NAT_GLIBC_THREAD_DB_H
+#ifndef GDB_NAT_GLIBC_THREAD_DB_H
+#define GDB_NAT_GLIBC_THREAD_DB_H
 
 /* This is the debugger interface for the NPTL library.  It is
    modelled closely after the interface with same names in Solaris
@@ -455,4 +455,4 @@ extern td_err_e td_thr_dbsuspend (const td_thrhandle_t *__th);
 /* Resume execution of thread TH.  */
 extern td_err_e td_thr_dbresume (const td_thrhandle_t *__th);
 
-#endif /* NAT_GLIBC_THREAD_DB_H */
+#endif /* GDB_NAT_GLIBC_THREAD_DB_H */
diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
index 0771f4b5a65..6fd81073673 100644
--- a/gdb/nat/linux-btrace.h
+++ b/gdb/nat/linux-btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_BTRACE_H
-#define NAT_LINUX_BTRACE_H
+#ifndef GDB_NAT_LINUX_BTRACE_H
+#define GDB_NAT_LINUX_BTRACE_H
 
 #include "gdbsupport/btrace-common.h"
 #include "gdbsupport/gdb-checked-static-cast.h"
@@ -86,4 +86,4 @@ extern enum btrace_error linux_read_btrace (struct btrace_data *btrace,
 extern const struct btrace_config *
   linux_btrace_conf (const struct btrace_target_info *);
 
-#endif /* NAT_LINUX_BTRACE_H */
+#endif /* GDB_NAT_LINUX_BTRACE_H */
diff --git a/gdb/nat/linux-namespaces.h b/gdb/nat/linux-namespaces.h
index 298ff056653..4327292950b 100644
--- a/gdb/nat/linux-namespaces.h
+++ b/gdb/nat/linux-namespaces.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_NAMESPACES_H
-#define NAT_LINUX_NAMESPACES_H
+#ifndef GDB_NAT_LINUX_NAMESPACES_H
+#define GDB_NAT_LINUX_NAMESPACES_H
 
 /* Set to true to enable debugging of Linux namespaces code.  */
 
@@ -73,4 +73,4 @@ extern int linux_mntns_unlink (pid_t pid, const char *filename);
 extern ssize_t linux_mntns_readlink (pid_t pid, const char *filename,
 				     char *buf, size_t bufsiz);
 
-#endif /* NAT_LINUX_NAMESPACES_H */
+#endif /* GDB_NAT_LINUX_NAMESPACES_H */
diff --git a/gdb/nat/linux-nat.h b/gdb/nat/linux-nat.h
index d4a36cbb601..e847eb033bd 100644
--- a/gdb/nat/linux-nat.h
+++ b/gdb/nat/linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_NAT_H
-#define NAT_LINUX_NAT_H
+#ifndef GDB_NAT_LINUX_NAT_H
+#define GDB_NAT_LINUX_NAT_H
 
 #include "gdbsupport/function-view.h"
 #include "target/waitstatus.h"
@@ -91,4 +91,4 @@ extern void linux_stop_lwp (struct lwp_info *lwp);
 
 extern int lwp_is_stepping (struct lwp_info *lwp);
 
-#endif /* NAT_LINUX_NAT_H */
+#endif /* GDB_NAT_LINUX_NAT_H */
diff --git a/gdb/nat/linux-osdata.h b/gdb/nat/linux-osdata.h
index 833915cdb2f..a700ea1eb80 100644
--- a/gdb/nat/linux-osdata.h
+++ b/gdb/nat/linux-osdata.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_OSDATA_H
-#define NAT_LINUX_OSDATA_H
+#ifndef GDB_NAT_LINUX_OSDATA_H
+#define GDB_NAT_LINUX_OSDATA_H
 
 extern int linux_common_core_of_thread (ptid_t ptid);
 extern LONGEST linux_common_xfer_osdata (const char *annex, gdb_byte *readbuf,
 					 ULONGEST offset, ULONGEST len);
 
-#endif /* NAT_LINUX_OSDATA_H */
+#endif /* GDB_NAT_LINUX_OSDATA_H */
diff --git a/gdb/nat/linux-personality.h b/gdb/nat/linux-personality.h
index 0238fe0c7e5..ab6727076ad 100644
--- a/gdb/nat/linux-personality.h
+++ b/gdb/nat/linux-personality.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PERSONALITY_H
-#define NAT_LINUX_PERSONALITY_H
+#ifndef GDB_NAT_LINUX_PERSONALITY_H
+#define GDB_NAT_LINUX_PERSONALITY_H
 
 class maybe_disable_address_space_randomization
 {
@@ -43,4 +43,4 @@ class maybe_disable_address_space_randomization
   int m_personality_orig;
 };
 
-#endif /* ! NAT_LINUX_PERSONALITY_H */
+#endif /* GDB_NAT_LINUX_PERSONALITY_H */
diff --git a/gdb/nat/linux-procfs.h b/gdb/nat/linux-procfs.h
index 880afbcdd61..6b352d97f3d 100644
--- a/gdb/nat/linux-procfs.h
+++ b/gdb/nat/linux-procfs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PROCFS_H
-#define NAT_LINUX_PROCFS_H
+#ifndef GDB_NAT_LINUX_PROCFS_H
+#define GDB_NAT_LINUX_PROCFS_H
 
 #include <unistd.h>
 
@@ -85,4 +85,4 @@ extern const char *linux_proc_pid_to_exec_file (int pid);
 
 extern void linux_proc_init_warnings ();
 
-#endif /* NAT_LINUX_PROCFS_H */
+#endif /* GDB_NAT_LINUX_PROCFS_H */
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index a268432ad92..fee2a4f4c5d 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_PTRACE_H
-#define NAT_LINUX_PTRACE_H
+#ifndef GDB_NAT_LINUX_PTRACE_H
+#define GDB_NAT_LINUX_PTRACE_H
 
 #include "nat/gdb_ptrace.h"
 #include "gdbsupport/gdb_wait.h"
@@ -189,4 +189,4 @@ extern int linux_ptrace_get_extended_event (int wstat);
 extern int linux_is_extended_waitstatus (int wstat);
 extern int linux_wstatus_maybe_breakpoint (int wstat);
 
-#endif /* NAT_LINUX_PTRACE_H */
+#endif /* GDB_NAT_LINUX_PTRACE_H */
diff --git a/gdb/nat/linux-waitpid.h b/gdb/nat/linux-waitpid.h
index e069f8a84a8..b75782d4520 100644
--- a/gdb/nat/linux-waitpid.h
+++ b/gdb/nat/linux-waitpid.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_WAITPID_H
-#define NAT_LINUX_WAITPID_H
+#ifndef GDB_NAT_LINUX_WAITPID_H
+#define GDB_NAT_LINUX_WAITPID_H
 
 /* Wrapper function for waitpid which handles EINTR.  */
 extern int my_waitpid (int pid, int *status, int flags);
@@ -27,4 +27,4 @@ extern int my_waitpid (int pid, int *status, int flags);
    messages only.  */
 extern std::string status_to_str (int status);
 
-#endif /* NAT_LINUX_WAITPID_H */
+#endif /* GDB_NAT_LINUX_WAITPID_H */
diff --git a/gdb/nat/mips-linux-watch.h b/gdb/nat/mips-linux-watch.h
index a37eabd2058..b18b009f3b7 100644
--- a/gdb/nat/mips-linux-watch.h
+++ b/gdb/nat/mips-linux-watch.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_MIPS_LINUX_WATCH_H
-#define NAT_MIPS_LINUX_WATCH_H
+#ifndef GDB_NAT_MIPS_LINUX_WATCH_H
+#define GDB_NAT_MIPS_LINUX_WATCH_H
 
 #include <asm/ptrace.h>
 #include "gdbsupport/break-common.h"
@@ -116,4 +116,4 @@ int mips_linux_read_watch_registers (long lwpid,
 				     struct pt_watch_regs *watch_readback,
 				     int *watch_readback_valid, int force);
 
-#endif /* NAT_MIPS_LINUX_WATCH_H */
+#endif /* GDB_NAT_MIPS_LINUX_WATCH_H */
diff --git a/gdb/nat/netbsd-nat.h b/gdb/nat/netbsd-nat.h
index cc529cfd0c6..1ffd705e3be 100644
--- a/gdb/nat/netbsd-nat.h
+++ b/gdb/nat/netbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_NETBSD_NAT_H
-#define NAT_NETBSD_NAT_H
+#ifndef GDB_NAT_NETBSD_NAT_H
+#define GDB_NAT_NETBSD_NAT_H
 
 #include "gdbsupport/function-view.h"
 
@@ -91,4 +91,4 @@ extern int read_memory (pid_t pid, unsigned char *readbuf, CORE_ADDR offset,
 			size_t len, size_t *xfered_len);
 }
 
-#endif
+#endif /* GDB_NAT_NETBSD_NAT_H */
diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h
index b51e2278f4b..3efc1b9a9bf 100644
--- a/gdb/nat/ppc-linux.h
+++ b/gdb/nat/ppc-linux.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_PPC_LINUX_H
-#define NAT_PPC_LINUX_H
+#ifndef GDB_NAT_PPC_LINUX_H
+#define GDB_NAT_PPC_LINUX_H
 
 #include <asm/ptrace.h>
 #include <asm/cputable.h>
@@ -162,4 +162,4 @@
 /* Return the wordsize of the target, either 4 or 8 bytes.  */
 int ppc_linux_target_wordsize (int tid);
 
-#endif /* NAT_PPC_LINUX_H */
+#endif /* GDB_NAT_PPC_LINUX_H */
diff --git a/gdb/nat/riscv-linux-tdesc.h b/gdb/nat/riscv-linux-tdesc.h
index fa9d5bcb7f5..875135ed979 100644
--- a/gdb/nat/riscv-linux-tdesc.h
+++ b/gdb/nat/riscv-linux-tdesc.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_RISCV_LINUX_TDESC_H
-#define NAT_RISCV_LINUX_TDESC_H
+#ifndef GDB_NAT_RISCV_LINUX_TDESC_H
+#define GDB_NAT_RISCV_LINUX_TDESC_H
 
 #include "arch/riscv.h"
 
@@ -25,4 +25,4 @@
    corresponding features object.  */
 struct riscv_gdbarch_features riscv_linux_read_features (int tid);
 
-#endif /* NAT_RISCV_LINUX_TDESC_H */
+#endif /* GDB_NAT_RISCV_LINUX_TDESC_H */
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index f2b5d777016..e03b41a53d4 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_WINDOWS_NAT_H
-#define NAT_WINDOWS_NAT_H
+#ifndef GDB_NAT_WINDOWS_NAT_H
+#define GDB_NAT_WINDOWS_NAT_H
 
 #include <windows.h>
 #include <psapi.h>
@@ -440,4 +440,4 @@ extern bool initialize_loadable ();
 
 }
 
-#endif
+#endif /* GDB_NAT_WINDOWS_NAT_H */
diff --git a/gdb/nat/x86-cpuid.h b/gdb/nat/x86-cpuid.h
index 5e9ce604f4e..02a204c1348 100644
--- a/gdb/nat/x86-cpuid.h
+++ b/gdb/nat/x86-cpuid.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_CPUID_H
-#define NAT_X86_CPUID_H
+#ifndef GDB_NAT_X86_CPUID_H
+#define GDB_NAT_X86_CPUID_H
 
 /* Always include the header for the cpu bit defines.  */
 #include "x86-gcc-cpuid.h"
@@ -82,4 +82,4 @@ x86_cpuid_count (unsigned int __level, unsigned int __sublevel,
 #undef nullptr
 #endif
 
-#endif /* NAT_X86_CPUID_H */
+#endif /* GDB_NAT_X86_CPUID_H */
diff --git a/gdb/nat/x86-dregs.h b/gdb/nat/x86-dregs.h
index 795cb112f88..3dcbf8e3028 100644
--- a/gdb/nat/x86-dregs.h
+++ b/gdb/nat/x86-dregs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_DREGS_H
-#define NAT_X86_DREGS_H
+#ifndef GDB_NAT_X86_DREGS_H
+#define GDB_NAT_X86_DREGS_H
 
 /* Support for hardware watchpoints and breakpoints using the x86
    debug registers.
@@ -133,4 +133,4 @@ extern int x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state);
    triggered.  Otherwise return false.  */
 extern int x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state);
 
-#endif /* NAT_X86_DREGS_H */
+#endif /* GDB_NAT_X86_DREGS_H */
diff --git a/gdb/nat/x86-gcc-cpuid.h b/gdb/nat/x86-gcc-cpuid.h
index dfd12587d81..b0f2d239af3 100644
--- a/gdb/nat/x86-gcc-cpuid.h
+++ b/gdb/nat/x86-gcc-cpuid.h
@@ -3,8 +3,8 @@
  * include this directly, but pull in x86-cpuid.h and use that func.
  */
 
-#ifndef NAT_X86_GCC_CPUID_H
-#define NAT_X86_GCC_CPUID_H
+#ifndef GDB_NAT_X86_GCC_CPUID_H
+#define GDB_NAT_X86_GCC_CPUID_H
 
 /*
  * Copyright (C) 2007-2024 Free Software Foundation, Inc.
@@ -273,4 +273,4 @@ __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
   return 1;
 }
 
-#endif /* NAT_X86_GCC_CPUID_H */
+#endif /* GDB_NAT_X86_GCC_CPUID_H */
diff --git a/gdb/nat/x86-linux-dregs.h b/gdb/nat/x86-linux-dregs.h
index 2b30c4a7a62..6f6a6e3d24e 100644
--- a/gdb/nat/x86-linux-dregs.h
+++ b/gdb/nat/x86-linux-dregs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_LINUX_DREGS_H
-#define NAT_X86_LINUX_DREGS_H
+#ifndef GDB_NAT_X86_LINUX_DREGS_H
+#define GDB_NAT_X86_LINUX_DREGS_H
 
 /* Return the address stored in the current inferior's debug register
    REGNUM.  */
@@ -50,4 +50,4 @@ extern unsigned long x86_linux_dr_get_status (void);
 
 extern void x86_linux_update_debug_registers (struct lwp_info *lwp);
 
-#endif /* NAT_X86_LINUX_DREGS_H */
+#endif /* GDB_NAT_X86_LINUX_DREGS_H */
diff --git a/gdb/nat/x86-linux.h b/gdb/nat/x86-linux.h
index 822882173f9..9b5db895455 100644
--- a/gdb/nat/x86-linux.h
+++ b/gdb/nat/x86-linux.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_LINUX_H
-#define NAT_X86_LINUX_H
+#ifndef GDB_NAT_X86_LINUX_H
+#define GDB_NAT_X86_LINUX_H
 
 #include "nat/linux-nat.h"
 
@@ -47,4 +47,4 @@ extern void x86_linux_delete_thread (struct arch_lwp_info *arch_lwp);
 
 extern void x86_linux_prepare_to_resume (struct lwp_info *lwp);
 
-#endif /* NAT_X86_LINUX_H */
+#endif /* GDB_NAT_X86_LINUX_H */
diff --git a/gdb/nat/x86-xstate.h b/gdb/nat/x86-xstate.h
index 199d39a5217..14b58cd0312 100644
--- a/gdb/nat/x86-xstate.h
+++ b/gdb/nat/x86-xstate.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_X86_XSTATE_H
-#define NAT_X86_XSTATE_H
+#ifndef GDB_NAT_X86_XSTATE_H
+#define GDB_NAT_X86_XSTATE_H
 
 #include "gdbsupport/x86-xstate.h"
 
@@ -32,4 +32,4 @@ int x86_xsave_length ();
 
 x86_xsave_layout x86_fetch_xsave_layout (uint64_t xcr0, int len);
 
-#endif /* NAT_X86_XSTATE_H */
+#endif /* GDB_NAT_X86_XSTATE_H */
diff --git a/gdb/nds32-tdep.h b/gdb/nds32-tdep.h
index a4d62848c51..18c360d7bdb 100644
--- a/gdb/nds32-tdep.h
+++ b/gdb/nds32-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NDS32_TDEP_H
-#define NDS32_TDEP_H
+#ifndef GDB_NDS32_TDEP_H
+#define GDB_NDS32_TDEP_H
 
 #include "gdbarch.h"
 
@@ -53,4 +53,4 @@ struct nds32_gdbarch_tdep : gdbarch_tdep_base
   /* ELF ABI info.  */
   int elf_abi = 0;
 };
-#endif /* NDS32_TDEP_H */
+#endif /* GDB_NDS32_TDEP_H */
diff --git a/gdb/netbsd-nat.h b/gdb/netbsd-nat.h
index 4895b088d13..87e076f69e7 100644
--- a/gdb/netbsd-nat.h
+++ b/gdb/netbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NBSD_NAT_H
-#define NBSD_NAT_H
+#ifndef GDB_NETBSD_NAT_H
+#define GDB_NETBSD_NAT_H
 
 #include "inf-ptrace.h"
 
@@ -61,4 +61,4 @@ struct nbsd_nat_target : public inf_ptrace_target
   void post_startup_inferior (ptid_t ptid) override;
 };
 
-#endif /* netbsd-nat.h */
+#endif /* GDB_NETBSD_NAT_H */
diff --git a/gdb/netbsd-tdep.h b/gdb/netbsd-tdep.h
index 3a9d527ca81..2e2993ea5dc 100644
--- a/gdb/netbsd-tdep.h
+++ b/gdb/netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NBSD_TDEP_H
-#define NBSD_TDEP_H
+#ifndef GDB_NETBSD_TDEP_H
+#define GDB_NETBSD_TDEP_H
 
 int nbsd_pc_in_sigtramp (CORE_ADDR, const char *);
 
@@ -44,4 +44,4 @@ extern void nbsd_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
 					   int kve_flags, int kve_protection,
 					   const char *kve_path);
 
-#endif /* NBSD_TDEP_H */
+#endif /* GDB_NETBSD_TDEP_H */
diff --git a/gdb/nios2-tdep.h b/gdb/nios2-tdep.h
index 57e0de7076d..0b3d01ab232 100644
--- a/gdb/nios2-tdep.h
+++ b/gdb/nios2-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NIOS2_TDEP_H
-#define NIOS2_TDEP_H
+#ifndef GDB_NIOS2_TDEP_H
+#define GDB_NIOS2_TDEP_H
 
 #include "gdbarch.h"
 
@@ -87,4 +87,4 @@ struct nios2_gdbarch_tdep : gdbarch_tdep_base
 extern const struct target_desc *tdesc_nios2_linux;
 extern const struct target_desc *tdesc_nios2;
 
-#endif /* NIOS2_TDEP_H */
+#endif /* GDB_NIOS2_TDEP_H */
diff --git a/gdb/nto-tdep.h b/gdb/nto-tdep.h
index 249a4f631fe..2edbcff8c91 100644
--- a/gdb/nto-tdep.h
+++ b/gdb/nto-tdep.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NTO_TDEP_H
-#define NTO_TDEP_H
+#ifndef GDB_NTO_TDEP_H
+#define GDB_NTO_TDEP_H
 
 #include "solist.h"
 #include "osabi.h"
@@ -191,4 +191,4 @@ LONGEST nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack,
 
 struct nto_inferior_data *nto_inferior_data (struct inferior *inf);
 
-#endif /* NTO_TDEP_H */
+#endif /* GDB_NTO_TDEP_H */
diff --git a/gdb/objc-lang.h b/gdb/objc-lang.h
index 879d7475d9d..6a8dc39c53a 100644
--- a/gdb/objc-lang.h
+++ b/gdb/objc-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(OBJC_LANG_H)
-#define OBJC_LANG_H
+#ifndef GDB_OBJC_LANG_H
+#define GDB_OBJC_LANG_H
 
 struct stoken;
 
@@ -48,4 +48,4 @@ struct symbol *lookup_struct_typedef (const char *name,
 				      const struct block *block,
 				      int noerr);
 
-#endif
+#endif /* GDB_OBJC_LANG_H */
diff --git a/gdb/objfile-flags.h b/gdb/objfile-flags.h
index 43d888e2a5a..e0a84bcdc2e 100644
--- a/gdb/objfile-flags.h
+++ b/gdb/objfile-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (OBJFILE_FLAGS_H)
-#define OBJFILE_FLAGS_H
+#ifndef GDB_OBJFILE_FLAGS_H
+#define GDB_OBJFILE_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -60,4 +60,4 @@ enum objfile_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum objfile_flag, objfile_flags);
 
-#endif /* !defined (OBJFILE_FLAGS_H) */
+#endif /* GDB_OBJFILE_FLAGS_H */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 8b8b7182e87..4d8e5c45680 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (OBJFILES_H)
-#define OBJFILES_H
+#ifndef GDB_OBJFILES_H
+#define GDB_OBJFILES_H
 
 #include "hashtab.h"
 #include "gdbsupport/gdb_obstack.h"
@@ -1031,4 +1031,4 @@ extern void objfile_register_static_link
 extern const struct dynamic_prop *objfile_lookup_static_link
   (struct objfile *objfile, const struct block *block);
 
-#endif /* !defined (OBJFILES_H) */
+#endif /* GDB_OBJFILES_H */
diff --git a/gdb/obsd-nat.h b/gdb/obsd-nat.h
index 0811a82d85c..35ee212e09f 100644
--- a/gdb/obsd-nat.h
+++ b/gdb/obsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSD_NAT_H
-#define OBSD_NAT_H
+#ifndef GDB_OBSD_NAT_H
+#define GDB_OBSD_NAT_H
 
 #include "inf-ptrace.h"
 
@@ -41,4 +41,4 @@ class obsd_nat_target : public inf_ptrace_target
   void post_startup_inferior (ptid_t) override;
 };
 
-#endif /* obsd-nat.h */
+#endif /* GDB_OBSD_NAT_H */
diff --git a/gdb/obsd-tdep.h b/gdb/obsd-tdep.h
index 85cea7be7cf..c018513cb1b 100644
--- a/gdb/obsd-tdep.h
+++ b/gdb/obsd-tdep.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSD_TDEP_H
-#define OBSD_TDEP_H 1
+#ifndef GDB_OBSD_TDEP_H
+#define GDB_OBSD_TDEP_H
 
 struct gdbarch;
 
 CORE_ADDR obsd_skip_solib_resolver (struct gdbarch *, CORE_ADDR);
 void obsd_init_abi (struct gdbarch_info, struct gdbarch *);
 
-#endif /* obsd-tdep.h */
+#endif /* GDB_OBSD_TDEP_H */
diff --git a/gdb/observable.h b/gdb/observable.h
index 2aa3ef3fd4e..2ce2711abd6 100644
--- a/gdb/observable.h
+++ b/gdb/observable.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OBSERVABLE_H
-#define OBSERVABLE_H
+#ifndef GDB_OBSERVABLE_H
+#define GDB_OBSERVABLE_H
 
 #include "gdbsupport/observable.h"
 #include "target/waitstatus.h"
@@ -257,4 +257,4 @@ extern observable <program_space */* pspace */> free_program_space;
 
 } /* namespace gdb */
 
-#endif /* OBSERVABLE_H */
+#endif /* GDB_OBSERVABLE_H */
diff --git a/gdb/or1k-linux-tdep.h b/gdb/or1k-linux-tdep.h
index 4e84e72c269..b510f32d16e 100644
--- a/gdb/or1k-linux-tdep.h
+++ b/gdb/or1k-linux-tdep.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OR1K_LINUX_TDEP_H
-#define OR1K_LINUX_TDEP_H
+#ifndef GDB_OR1K_LINUX_TDEP_H
+#define GDB_OR1K_LINUX_TDEP_H
 
 /* Target descriptions.  */
 extern struct target_desc *tdesc_or1k_linux;
 
-#endif /* OR1K_LINUX_TDEP_H */
+#endif /* GDB_OR1K_LINUX_TDEP_H */
diff --git a/gdb/or1k-tdep.h b/gdb/or1k-tdep.h
index 6107cc4612c..f3072572e57 100644
--- a/gdb/or1k-tdep.h
+++ b/gdb/or1k-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License along
    With this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OR1K_TDEP_H
-#define OR1K_TDEP_H
+#ifndef GDB_OR1K_TDEP_H
+#define GDB_OR1K_TDEP_H
 
 #ifndef TARGET_OR1K
 #define TARGET_OR1K
@@ -60,4 +60,4 @@ extern std::vector<CORE_ADDR> or1k_software_single_step
   (struct regcache *regcache);
 
 
-#endif /* OR1K_TDEP_H */
+#endif /* GDB_OR1K_TDEP_H */
diff --git a/gdb/osabi.h b/gdb/osabi.h
index c1a85d1b9a3..bbcd0d0c23a 100644
--- a/gdb/osabi.h
+++ b/gdb/osabi.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OSABI_H
-#define OSABI_H
+#ifndef GDB_OSABI_H
+#define GDB_OSABI_H
 
 /* * List of known OS ABIs.  If you change this, make sure to update the
    table in osabi.c.  */
@@ -92,4 +92,4 @@ const char *osabi_triplet_regexp (enum gdb_osabi osabi);
 void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *,
 					       enum gdb_osabi *);
 
-#endif /* OSABI_H */
+#endif /* GDB_OSABI_H */
diff --git a/gdb/osdata.h b/gdb/osdata.h
index 09259b6c9ae..9de443ac4de 100644
--- a/gdb/osdata.h
+++ b/gdb/osdata.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef OSDATA_H
-#define OSDATA_H
+#ifndef GDB_OSDATA_H
+#define GDB_OSDATA_H
 
 #include <vector>
 
@@ -57,4 +57,4 @@ const std::string *get_osdata_column (const osdata_item &item,
    available types of OS data.  */
 void info_osdata (const char *type);
 
-#endif /* OSDATA_H */
+#endif /* GDB_OSDATA_H */
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index fe12e7cab33..abb981aeaed 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef P_LANG_H
-#define P_LANG_H
+#ifndef GDB_P_LANG_H
+#define GDB_P_LANG_H
 
 /* This file is derived from c-lang.h */
 
@@ -252,4 +252,4 @@ class pascal_language : public language_defn
 				   struct type *type) const;
 };
 
-#endif /* P_LANG_H */
+#endif /* GDB_P_LANG_H */
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 9774a465ee2..eaa3c411141 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (PARSER_DEFS_H)
-#define PARSER_DEFS_H 1
+#ifndef GDB_PARSER_DEFS_H
+#define GDB_PARSER_DEFS_H
 
 #include "expression.h"
 #include "symtab.h"
@@ -389,4 +389,4 @@ extern bool fits_in_type (int n_sign, const gdb_mpz &n, int type_bits,
 
 extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3);
 
-#endif /* PARSER_DEFS_H */
+#endif /* GDB_PARSER_DEFS_H */
diff --git a/gdb/ppc-fbsd-tdep.h b/gdb/ppc-fbsd-tdep.h
index b9c0e6bb351..93ba9045f2f 100644
--- a/gdb/ppc-fbsd-tdep.h
+++ b/gdb/ppc-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_FBSD_TDEP_H
-#define PPC_FBSD_TDEP_H
+#ifndef GDB_PPC_FBSD_TDEP_H
+#define GDB_PPC_FBSD_TDEP_H
 
 struct regset;
 
@@ -26,4 +26,4 @@ struct regset;
 const struct regset *ppc_fbsd_gregset (int);
 const struct regset *ppc_fbsd_fpregset (void);
 
-#endif /* PPC_FBSD_TDEP_H  */
+#endif /* GDB_PPC_FBSD_TDEP_H */
diff --git a/gdb/ppc-linux-tdep.h b/gdb/ppc-linux-tdep.h
index 8a0a59f2b70..a1db503c9f5 100644
--- a/gdb/ppc-linux-tdep.h
+++ b/gdb/ppc-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_LINUX_TDEP_H
-#define PPC_LINUX_TDEP_H
+#ifndef GDB_PPC_LINUX_TDEP_H
+#define GDB_PPC_LINUX_TDEP_H
 
 #include "ppc-tdep.h"
 
@@ -65,4 +65,4 @@ extern const struct regset ppc32_linux_cpprregset;
 extern const struct regset ppc32_linux_cdscrregset;
 extern const struct regset ppc32_linux_ctarregset;
 
-#endif /* PPC_LINUX_TDEP_H */
+#endif /* GDB_PPC_LINUX_TDEP_H */
diff --git a/gdb/ppc-netbsd-tdep.h b/gdb/ppc-netbsd-tdep.h
index 6a92020f5ab..47a8b25782a 100644
--- a/gdb/ppc-netbsd-tdep.h
+++ b/gdb/ppc-netbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_NBSD_TDEP_H
-#define PPC_NBSD_TDEP_H
+#ifndef GDB_PPC_NETBSD_TDEP_H
+#define GDB_PPC_NETBSD_TDEP_H
 
 struct regset;
 
@@ -29,4 +29,4 @@ extern struct ppc_reg_offsets ppcnbsd_reg_offsets;
 extern const struct regset ppcnbsd_gregset;
 extern const struct regset ppcnbsd_fpregset;
 
-#endif /* PPC_NBSD_TDEP_H */
+#endif /* GDB_PPC_NETBSD_TDEP_H */
diff --git a/gdb/ppc-obsd-tdep.h b/gdb/ppc-obsd-tdep.h
index 70396abdf84..7f5e7b99850 100644
--- a/gdb/ppc-obsd-tdep.h
+++ b/gdb/ppc-obsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_OBSD_TDEP_H
-#define PPC_OBSD_TDEP_H
+#ifndef GDB_PPC_OBSD_TDEP_H
+#define GDB_PPC_OBSD_TDEP_H
 
 struct regset;
 struct regcache;
@@ -49,4 +49,4 @@ extern void ppcobsd_collect_gregset (const struct regset *regset,
 				     const struct regcache *regcache,
 				     int regnum, void *gregs, size_t len);
 
-#endif /* ppc-obsd-tdep.h */
+#endif /* GDB_PPC_OBSD_TDEP_H */
diff --git a/gdb/ppc-ravenscar-thread.h b/gdb/ppc-ravenscar-thread.h
index 2b0916a916f..c03fbd2ec52 100644
--- a/gdb/ppc-ravenscar-thread.h
+++ b/gdb/ppc-ravenscar-thread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_RAVENSCAR_THREAD_H
-#define PPC_RAVENSCAR_THREAD_H
+#ifndef GDB_PPC_RAVENSCAR_THREAD_H
+#define GDB_PPC_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
@@ -26,4 +26,4 @@ extern void register_ppc_ravenscar_ops (struct gdbarch *gdbarch);
 
 extern void register_e500_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_PPC_RAVENSCAR_THREAD_H */
diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
index db31c7f199a..3176c155fe3 100644
--- a/gdb/ppc-tdep.h
+++ b/gdb/ppc-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_TDEP_H
-#define PPC_TDEP_H
+#ifndef GDB_PPC_TDEP_H
+#define GDB_PPC_TDEP_H
 
 #include "gdbarch.h"
 
@@ -458,4 +458,4 @@ extern const struct target_desc *tdesc_powerpc_vsx32;
 extern const struct target_desc *tdesc_powerpc_altivec64;
 extern const struct target_desc *tdesc_powerpc_altivec32;
 
-#endif /* ppc-tdep.h */
+#endif /* GDB_PPC_TDEP_H */
diff --git a/gdb/ppc64-tdep.h b/gdb/ppc64-tdep.h
index ff0e3fdd033..7bea549dda0 100644
--- a/gdb/ppc64-tdep.h
+++ b/gdb/ppc64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC64_TDEP_H
-#define PPC64_TDEP_H
+#ifndef GDB_PPC64_TDEP_H
+#define GDB_PPC64_TDEP_H
 
 struct gdbarch;
 class frame_info_ptr;
@@ -33,4 +33,4 @@ extern CORE_ADDR ppc64_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
 
 extern void ppc64_elf_make_msymbol_special (asymbol *,
 					    struct minimal_symbol *);
-#endif /* PPC64_TDEP_H  */
+#endif /* GDB_PPC64_TDEP_H */
diff --git a/gdb/probe.h b/gdb/probe.h
index 41e728ad049..00b3f9086b4 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (PROBE_H)
-#define PROBE_H 1
+#ifndef GDB_PROBE_H
+#define GDB_PROBE_H
 
 #include "symtab.h"
 
@@ -309,4 +309,4 @@ extern struct value *probe_safe_evaluate_at_pc (const frame_info_ptr &frame,
 
 bool ignore_probe_p (const char *provider, const char *name,
 		     const char *objfile_name, const char *TYPE);
-#endif /* !defined (PROBE_H) */
+#endif /* GDB_PROBE_H */
diff --git a/gdb/proc-utils.h b/gdb/proc-utils.h
index 8ef7d7ccd34..5f8fe39f78f 100644
--- a/gdb/proc-utils.h
+++ b/gdb/proc-utils.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROC_UTILS_H
-#define PROC_UTILS_H
+#ifndef GDB_PROC_UTILS_H
+#define GDB_PROC_UTILS_H
 
 /* From proc-why.c */
 
@@ -117,4 +117,4 @@ extern  void  procfs_note      (const char *, const char *, int);
    word used to write to the /proc/PID/ctl file.  */
 typedef long procfs_ctl_t;
 
-#endif /* PROC_UTILS_H */
+#endif /* GDB_PROC_UTILS_H */
diff --git a/gdb/process-stratum-target.h b/gdb/process-stratum-target.h
index 9aa9d874ecb..8a0e139cd0c 100644
--- a/gdb/process-stratum-target.h
+++ b/gdb/process-stratum-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROCESS_STRATUM_TARGET_H
-#define PROCESS_STRATUM_TARGET_H
+#ifndef GDB_PROCESS_STRATUM_TARGET_H
+#define GDB_PROCESS_STRATUM_TARGET_H
 
 #include "target.h"
 #include <set>
@@ -173,4 +173,4 @@ extern std::set<process_stratum_target *> all_non_exited_process_targets ();
 
 extern void switch_to_target_no_thread (process_stratum_target *target);
 
-#endif /* !defined (PROCESS_STRATUM_TARGET_H) */
+#endif /* GDB_PROCESS_STRATUM_TARGET_H */
diff --git a/gdb/procfs.h b/gdb/procfs.h
index e0c1dd654ca..0dafb9a88b4 100644
--- a/gdb/procfs.h
+++ b/gdb/procfs.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROCFS_H
-#define PROCFS_H
+#ifndef GDB_PROCFS_H
+#define GDB_PROCFS_H
 
 /* Return a ptid for which we guarantee we will be able to find a
    'live' procinfo.  */
 
 extern ptid_t procfs_first_available (void);
 
-#endif /* PROCFS_H */
+#endif /* GDB_PROCFS_H */
diff --git a/gdb/producer.h b/gdb/producer.h
index 84721bd2665..5cdb7ee3435 100644
--- a/gdb/producer.h
+++ b/gdb/producer.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PRODUCER_H
-#define PRODUCER_H
+#ifndef GDB_PRODUCER_H
+#define GDB_PRODUCER_H
 
 /* Check for GCC >= 4.x according to the symtab->producer string.  Return minor
    version (x) of 4.x in such case.  If it is not GCC or it is GCC older than
@@ -50,4 +50,4 @@ extern bool producer_is_llvm (const char *producer);
    Sets MAJOR and MINOR accordingly, if not NULL.  */
 extern bool producer_is_clang (const char *producer, int *major, int *minor);
 
-#endif
+#endif /* GDB_PRODUCER_H */
diff --git a/gdb/progspace-and-thread.h b/gdb/progspace-and-thread.h
index fa512710a25..52c493bf687 100644
--- a/gdb/progspace-and-thread.h
+++ b/gdb/progspace-and-thread.h
@@ -16,8 +16,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef PROGSPACE_AND_THREAD_H
-#define PROGSPACE_AND_THREAD_H
+#ifndef GDB_PROGSPACE_AND_THREAD_H
+#define GDB_PROGSPACE_AND_THREAD_H
 
 #include "progspace.h"
 #include "gdbthread.h"
@@ -37,4 +37,4 @@ class scoped_restore_current_pspace_and_thread
    current thread, if there's one and it isn't executing.  */
 void switch_to_program_space_and_thread (program_space *pspace);
 
-#endif
+#endif /* GDB_PROGSPACE_AND_THREAD_H */
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 7f5e23df126..74220e5ba4c 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef PROGSPACE_H
-#define PROGSPACE_H
+#ifndef GDB_PROGSPACE_H
+#define GDB_PROGSPACE_H
 
 #include "target.h"
 #include "gdb_bfd.h"
@@ -472,4 +472,4 @@ extern address_space_ref_ptr maybe_new_address_space ();
    mappings.  */
 extern void update_address_spaces (void);
 
-#endif
+#endif /* GDB_PROGSPACE_H */
diff --git a/gdb/prologue-value.h b/gdb/prologue-value.h
index ea784f90dd2..39235d591fc 100644
--- a/gdb/prologue-value.h
+++ b/gdb/prologue-value.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PROLOGUE_VALUE_H
-#define PROLOGUE_VALUE_H
+#ifndef GDB_PROLOGUE_VALUE_H
+#define GDB_PROLOGUE_VALUE_H
 
 /* What sort of value is this?  This determines the interpretation
    of subsequent fields.  */
@@ -327,4 +327,4 @@ class pv_area
   struct area_entry *m_entry;
 };
 
-#endif /* PROLOGUE_VALUE_H */
+#endif /* GDB_PROLOGUE_VALUE_H */
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 557a7cf4c08..7833815ef50 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PSYMTAB_H
-#define PSYMTAB_H
+#ifndef GDB_PSYMTAB_H
+#define GDB_PSYMTAB_H
 
 #include "objfiles.h"
 #include <string_view>
@@ -687,4 +687,4 @@ struct psymbol_functions : public quick_symbol_functions
   std::shared_ptr<psymtab_storage> m_partial_symtabs;
 };
 
-#endif /* PSYMTAB_H */
+#endif /* GDB_PSYMTAB_H */
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 388c513e5e9..2819707b2dd 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_EVENT_H
-#define PYTHON_PY_EVENT_H
+#ifndef GDB_PYTHON_PY_EVENT_H
+#define GDB_PYTHON_PY_EVENT_H
 
 #include "py-events.h"
 #include "command.h"
@@ -87,4 +87,4 @@ extern int evpy_add_attribute (PyObject *event,
 int gdbpy_initialize_event_generic (PyTypeObject *type, const char *name)
   CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
 
-#endif /* PYTHON_PY_EVENT_H */
+#endif /* GDB_PYTHON_PY_EVENT_H */
diff --git a/gdb/python/py-events.h b/gdb/python/py-events.h
index e628e0fd63e..b44c4371f24 100644
--- a/gdb/python/py-events.h
+++ b/gdb/python/py-events.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_EVENTS_H
-#define PYTHON_PY_EVENTS_H
+#ifndef GDB_PYTHON_PY_EVENTS_H
+#define GDB_PYTHON_PY_EVENTS_H
 
 #include "command.h"
 #include "python-internal.h"
@@ -54,4 +54,4 @@ extern events_object gdb_py_events;
 extern eventregistry_object *create_eventregistry_object (void);
 extern bool evregpy_no_listeners_p (eventregistry_object *registry);
 
-#endif /* PYTHON_PY_EVENTS_H */
+#endif /* GDB_PYTHON_PY_EVENTS_H */
diff --git a/gdb/python/py-instruction.h b/gdb/python/py-instruction.h
index 85604de5188..efbdda84bae 100644
--- a/gdb/python/py-instruction.h
+++ b/gdb/python/py-instruction.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_INSTRUCTION_H
-#define PYTHON_PY_INSTRUCTION_H
+#ifndef GDB_PYTHON_PY_INSTRUCTION_H
+#define GDB_PYTHON_PY_INSTRUCTION_H
 
 #include "python-internal.h"
 
@@ -32,4 +32,4 @@
 
 extern PyTypeObject *py_insn_get_insn_type ();
 
-#endif /* PYTHON_PY_INSTRUCTION_H */
+#endif /* GDB_PYTHON_PY_INSTRUCTION_H */
diff --git a/gdb/python/py-record-btrace.h b/gdb/python/py-record-btrace.h
index 8678e77322b..0410dd66be8 100644
--- a/gdb/python/py-record-btrace.h
+++ b/gdb/python/py-record-btrace.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_BTRACE_H
-#define PYTHON_PY_RECORD_BTRACE_H
+#ifndef GDB_PYTHON_PY_RECORD_BTRACE_H
+#define GDB_PYTHON_PY_RECORD_BTRACE_H
 
 #include "python-internal.h"
 
@@ -88,4 +88,4 @@ extern PyObject *recpy_bt_func_prev (PyObject *self, void *closure);
 /* Implementation of RecordFunctionSegment.next [RecordFunctionSegment].  */
 extern PyObject *recpy_bt_func_next (PyObject *self, void *closure);
 
-#endif /* PYTHON_PY_RECORD_BTRACE_H */
+#endif /* GDB_PYTHON_PY_RECORD_BTRACE_H */
diff --git a/gdb/python/py-record-full.h b/gdb/python/py-record-full.h
index 7125e4eba05..df957761602 100644
--- a/gdb/python/py-record-full.h
+++ b/gdb/python/py-record-full.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_FULL_H
-#define PYTHON_PY_RECORD_FULL_H
+#ifndef GDB_PYTHON_PY_RECORD_FULL_H
+#define GDB_PYTHON_PY_RECORD_FULL_H
 
 #include "python-internal.h"
 
@@ -28,4 +28,4 @@ extern PyObject *recpy_full_method (PyObject *self, void *value);
 /* Implementation of record.format [str].  */
 extern PyObject *recpy_full_format (PyObject *self, void *value);
 
-#endif /* PYTHON_PY_RECORD_FULL_H */
+#endif /* GDB_PYTHON_PY_RECORD_FULL_H */
diff --git a/gdb/python/py-record.h b/gdb/python/py-record.h
index 7e1161005b4..0687e78784a 100644
--- a/gdb/python/py-record.h
+++ b/gdb/python/py-record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_RECORD_H
-#define PYTHON_PY_RECORD_H
+#ifndef GDB_PYTHON_PY_RECORD_H
+#define GDB_PYTHON_PY_RECORD_H
 
 #include "inferior.h"
 #include "python-internal.h"
@@ -71,4 +71,4 @@ extern PyObject *recpy_func_new (thread_info *thread, enum record_method method,
 extern PyObject *recpy_gap_new (int reason_code, const char *reason_string,
 				Py_ssize_t number);
 
-#endif /* PYTHON_PY_RECORD_H */
+#endif /* GDB_PYTHON_PY_RECORD_H */
diff --git a/gdb/python/py-ref.h b/gdb/python/py-ref.h
index 35029e8d673..938068e7803 100644
--- a/gdb/python/py-ref.h
+++ b/gdb/python/py-ref.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_REF_H
-#define PYTHON_PY_REF_H
+#ifndef GDB_PYTHON_PY_REF_H
+#define GDB_PYTHON_PY_REF_H
 
 #include "gdbsupport/gdb_ref_ptr.h"
 
@@ -42,4 +42,4 @@ struct gdbpy_ref_policy
 template<typename T = PyObject> using gdbpy_ref
   = gdb::ref_ptr<T, gdbpy_ref_policy<T>>;
 
-#endif /* PYTHON_PY_REF_H */
+#endif /* GDB_PYTHON_PY_REF_H */
diff --git a/gdb/python/py-stopevent.h b/gdb/python/py-stopevent.h
index 6cae0a729db..450d8c23b4a 100644
--- a/gdb/python/py-stopevent.h
+++ b/gdb/python/py-stopevent.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PY_STOPEVENT_H
-#define PYTHON_PY_STOPEVENT_H
+#ifndef GDB_PYTHON_PY_STOPEVENT_H
+#define GDB_PYTHON_PY_STOPEVENT_H
 
 #include "py-event.h"
 
@@ -35,4 +35,4 @@ extern gdbpy_ref<> create_breakpoint_event_object (const gdbpy_ref<> &dict,
 extern gdbpy_ref<> create_signal_event_object (const gdbpy_ref<> &dict,
 					       enum gdb_signal stop_signal);
 
-#endif /* PYTHON_PY_STOPEVENT_H */
+#endif /* GDB_PYTHON_PY_STOPEVENT_H */
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 5132ec15ba6..d9863935f0c 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PYTHON_INTERNAL_H
-#define PYTHON_PYTHON_INTERNAL_H
+#ifndef GDB_PYTHON_PYTHON_INTERNAL_H
+#define GDB_PYTHON_PYTHON_INTERNAL_H
 
 #include "extension.h"
 #include "extension-priv.h"
@@ -1035,4 +1035,4 @@ extern std::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch,
 					    CORE_ADDR address,
 					    disassemble_info *info);
 
-#endif /* PYTHON_PYTHON_INTERNAL_H */
+#endif /* GDB_PYTHON_PYTHON_INTERNAL_H */
diff --git a/gdb/python/python.h b/gdb/python/python.h
index e6279482ce0..e8032853e8e 100644
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PYTHON_PYTHON_H
-#define PYTHON_PYTHON_H
+#ifndef GDB_PYTHON_PYTHON_H
+#define GDB_PYTHON_PYTHON_H
 
 #include "extension.h"
 
@@ -34,4 +34,4 @@ extern cmd_list_element *python_cmd_element;
    at other times.  */
 extern struct objfile *gdbpy_current_objfile;
 
-#endif /* PYTHON_PYTHON_H */
+#endif /* GDB_PYTHON_PYTHON_H */
diff --git a/gdb/ravenscar-thread.h b/gdb/ravenscar-thread.h
index 32c31269225..046b3575e7f 100644
--- a/gdb/ravenscar-thread.h
+++ b/gdb/ravenscar-thread.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RAVENSCAR_THREAD_H
-#define RAVENSCAR_THREAD_H
+#ifndef GDB_RAVENSCAR_THREAD_H
+#define GDB_RAVENSCAR_THREAD_H
 
 /* Architecture-specific hooks.  */
 
@@ -130,4 +130,4 @@ struct ravenscar_arch_ops
   CORE_ADDR get_stack_base (struct regcache *) const;
 };
 
-#endif /* !defined (RAVENSCAR_THREAD_H) */
+#endif /* GDB_RAVENSCAR_THREAD_H */
diff --git a/gdb/record-btrace.h b/gdb/record-btrace.h
index b6e6c4df030..5ab3208f659 100644
--- a/gdb/record-btrace.h
+++ b/gdb/record-btrace.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_BTRACE_H
-#define RECORD_BTRACE_H
+#ifndef GDB_RECORD_BTRACE_H
+#define GDB_RECORD_BTRACE_H
 
 /* Push the record_btrace target.  */
 extern void record_btrace_push_target (void);
@@ -29,4 +29,4 @@ extern void record_btrace_push_target (void);
    NULL if the cpu was configured as auto.  */
 extern const struct btrace_cpu *record_btrace_get_cpu (void);
 
-#endif /* RECORD_BTRACE_H */
+#endif /* GDB_RECORD_BTRACE_H */
diff --git a/gdb/record-full.h b/gdb/record-full.h
index ef45b1c0d59..dc14d476715 100644
--- a/gdb/record-full.h
+++ b/gdb/record-full.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_FULL_H
-#define RECORD_FULL_H
+#ifndef GDB_RECORD_FULL_H
+#define GDB_RECORD_FULL_H
 
 extern bool record_full_memory_query;
 
@@ -31,4 +31,4 @@ extern int record_full_is_used (void);
 
 extern scoped_restore_tmpl<int> record_full_gdb_operation_disable_set ();
 
-#endif /* RECORD_FULL_H */
+#endif /* GDB_RECORD_FULL_H */
diff --git a/gdb/record.h b/gdb/record.h
index f44b3952943..471e2711b12 100644
--- a/gdb/record.h
+++ b/gdb/record.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RECORD_H
-#define RECORD_H
+#ifndef GDB_RECORD_H
+#define GDB_RECORD_H
 
 #include "target/waitstatus.h"
 #include "gdbsupport/enum-flags.h"
@@ -114,4 +114,4 @@ extern void record_start (const char *method, const char *format,
 /* Stop recording.  Throw on failure.  */
 extern void record_stop (int from_tty);
 
-#endif /* RECORD_H */
+#endif /* GDB_RECORD_H */
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 9ba6c79ab0d..1e06dc60096 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGCACHE_H
-#define REGCACHE_H
+#ifndef GDB_REGCACHE_H
+#define GDB_REGCACHE_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/common-regcache.h"
@@ -548,4 +548,4 @@ class register_dump
   gdbarch *m_gdbarch;
 };
 
-#endif /* REGCACHE_H */
+#endif /* GDB_REGCACHE_H */
diff --git a/gdb/regformats/regdef.h b/gdb/regformats/regdef.h
index 0ba7a08bb0c..8715229fcdb 100644
--- a/gdb/regformats/regdef.h
+++ b/gdb/regformats/regdef.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGFORMATS_REGDEF_H
-#define REGFORMATS_REGDEF_H
+#ifndef GDB_REGFORMATS_REGDEF_H
+#define GDB_REGFORMATS_REGDEF_H
 
 namespace gdb {
 
@@ -64,4 +64,4 @@ struct reg
 
 } /* namespace gdb */
 
-#endif /* REGFORMATS_REGDEF_H */
+#endif /* GDB_REGFORMATS_REGDEF_H */
diff --git a/gdb/reggroups.h b/gdb/reggroups.h
index 1be1f0ad613..24f81e4675b 100644
--- a/gdb/reggroups.h
+++ b/gdb/reggroups.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGGROUPS_H
-#define REGGROUPS_H
+#ifndef GDB_REGGROUPS_H
+#define GDB_REGGROUPS_H
 
 struct gdbarch;
 
@@ -98,4 +98,4 @@ extern const reggroup *reggroup_find (struct gdbarch *gdbarch,
 extern int default_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 					const struct reggroup *reggroup);
 
-#endif
+#endif /* GDB_REGGROUPS_H */
diff --git a/gdb/registry.h b/gdb/registry.h
index b6b941f56fd..32216545cb0 100644
--- a/gdb/registry.h
+++ b/gdb/registry.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGISTRY_H
-#define REGISTRY_H
+#ifndef GDB_REGISTRY_H
+#define GDB_REGISTRY_H
 
 #include <type_traits>
 
@@ -225,4 +225,4 @@ class registry
   }
 };
 
-#endif /* REGISTRY_H */
+#endif /* GDB_REGISTRY_H */
diff --git a/gdb/regset.h b/gdb/regset.h
index 5fab2e16d9c..44eaf1406bc 100644
--- a/gdb/regset.h
+++ b/gdb/regset.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REGSET_H
-#define REGSET_H 1
+#ifndef GDB_REGSET_H
+#define GDB_REGSET_H
 
 struct gdbarch;
 struct regcache;
@@ -52,4 +52,4 @@ struct regset
 #define REGSET_VARIABLE_SIZE 1	/* Accept a larger regset section size
 				   in a core file without warning.  */
 
-#endif /* regset.h */
+#endif /* GDB_REGSET_H */
diff --git a/gdb/remote-fileio.h b/gdb/remote-fileio.h
index 479dc46888e..d406895bc7e 100644
--- a/gdb/remote-fileio.h
+++ b/gdb/remote-fileio.h
@@ -19,8 +19,8 @@
 
 /* See the GDB User Guide for details of the GDB remote protocol.  */
 
-#ifndef REMOTE_FILEIO_H
-#define REMOTE_FILEIO_H
+#ifndef GDB_REMOTE_FILEIO_H
+#define GDB_REMOTE_FILEIO_H
 
 #include "gdbsupport/fileio.h"
 
@@ -44,4 +44,4 @@ extern void initialize_remote_fileio (
 extern void remote_fileio_to_host_stat (struct fio_stat *fst,
 					struct stat *st);
 
-#endif
+#endif /* GDB_REMOTE_FILEIO_H */
diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h
index 4c5b50a0d12..cca26b09f95 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REMOTE_NOTIF_H
-#define REMOTE_NOTIF_H
+#ifndef GDB_REMOTE_NOTIF_H
+#define GDB_REMOTE_NOTIF_H
 
 #include <list>
 #include <memory>
@@ -131,4 +131,4 @@ extern const notif_client notif_client_stop;
 
 extern bool notif_debug;
 
-#endif /* REMOTE_NOTIF_H */
+#endif /* GDB_REMOTE_NOTIF_H */
diff --git a/gdb/remote.h b/gdb/remote.h
index cb0a66da66e..173f3a2a0f2 100644
--- a/gdb/remote.h
+++ b/gdb/remote.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef REMOTE_H
-#define REMOTE_H
+#ifndef GDB_REMOTE_H
+#define GDB_REMOTE_H
 
 #include "remote-notif.h"
 
@@ -121,4 +121,4 @@ extern void send_remote_packet (gdb::array_view<const char> &buf,
 
 extern bool is_remote_target (process_stratum_target *target);
 
-#endif
+#endif /* GDB_REMOTE_H */
diff --git a/gdb/riscv-fbsd-tdep.h b/gdb/riscv-fbsd-tdep.h
index c797b231a8e..22ae08d3678 100644
--- a/gdb/riscv-fbsd-tdep.h
+++ b/gdb/riscv-fbsd-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_FBSD_TDEP_H
-#define RISCV_FBSD_TDEP_H
+#ifndef GDB_RISCV_FBSD_TDEP_H
+#define GDB_RISCV_FBSD_TDEP_H
 
 #include "regset.h"
 
@@ -35,4 +35,4 @@
 extern const struct regset riscv_fbsd_gregset;
 extern const struct regset riscv_fbsd_fpregset;
 
-#endif /* RISCV_FBSD_TDEP_H */
+#endif /* GDB_RISCV_FBSD_TDEP_H */
diff --git a/gdb/riscv-ravenscar-thread.h b/gdb/riscv-ravenscar-thread.h
index a586a85583a..87730438017 100644
--- a/gdb/riscv-ravenscar-thread.h
+++ b/gdb/riscv-ravenscar-thread.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_RAVENSCAR_THREAD_H
-#define RISCV_RAVENSCAR_THREAD_H
+#ifndef GDB_RISCV_RAVENSCAR_THREAD_H
+#define GDB_RISCV_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_riscv_ravenscar_ops (struct gdbarch *gdbarch);
 
-#endif
+#endif /* GDB_RISCV_RAVENSCAR_THREAD_H */
diff --git a/gdb/riscv-tdep.h b/gdb/riscv-tdep.h
index 4bdc2e7a3d5..15c2c4cafcb 100644
--- a/gdb/riscv-tdep.h
+++ b/gdb/riscv-tdep.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RISCV_TDEP_H
-#define RISCV_TDEP_H
+#ifndef GDB_RISCV_TDEP_H
+#define GDB_RISCV_TDEP_H
 
 #include "arch/riscv.h"
 #include "gdbarch.h"
@@ -180,4 +180,4 @@ extern void riscv_supply_regset (const struct regset *regset,
 /* The names of the RISC-V target description features.  */
 extern const char *riscv_feature_name_csr;
 
-#endif /* RISCV_TDEP_H */
+#endif /* GDB_RISCV_TDEP_H */
diff --git a/gdb/rs6000-aix-tdep.h b/gdb/rs6000-aix-tdep.h
index 52cffc31084..5e4f7865ac6 100644
--- a/gdb/rs6000-aix-tdep.h
+++ b/gdb/rs6000-aix-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RS6000_AIX_TDEP_H
-#define RS6000_AIX_TDEP_H
+#ifndef GDB_RS6000_AIX_TDEP_H
+#define GDB_RS6000_AIX_TDEP_H
 
 extern ULONGEST rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch,
 					   const gdb_byte *ldi_buf,
@@ -25,4 +25,4 @@ extern ULONGEST rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch,
 					   ULONGEST len,
 					   int close_ldinfo_fd);
 
-#endif /* RS6000_AIX_TDEP_H */
+#endif /* GDB_RS6000_AIX_TDEP_H */
diff --git a/gdb/rust-exp.h b/gdb/rust-exp.h
index f5c5904cfb4..e0496e1a050 100644
--- a/gdb/rust-exp.h
+++ b/gdb/rust-exp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RUST_EXP_H
-#define RUST_EXP_H
+#ifndef GDB_RUST_EXP_H
+#define GDB_RUST_EXP_H
 
 #include "expop.h"
 
@@ -226,4 +226,4 @@ class rust_parenthesized_operation
 
 } /* namespace expr */
 
-#endif /* RUST_EXP_H */
+#endif /* GDB_RUST_EXP_H */
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index 9ae5961e9ac..f9c82454817 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef RUST_LANG_H
-#define RUST_LANG_H
+#ifndef GDB_RUST_LANG_H
+#define GDB_RUST_LANG_H
 
 #include "demangle.h"
 #include "language.h"
@@ -228,4 +228,4 @@ class rust_language : public language_defn
 		   const struct value_print_options *options) const;
 };
 
-#endif /* RUST_LANG_H */
+#endif /* GDB_RUST_LANG_H */
diff --git a/gdb/s390-linux-tdep.h b/gdb/s390-linux-tdep.h
index 2f9741dca96..b2efb5b1d2f 100644
--- a/gdb/s390-linux-tdep.h
+++ b/gdb/s390-linux-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef S390_LINUX_TDEP_H
-#define S390_LINUX_TDEP_H
+#ifndef GDB_S390_LINUX_TDEP_H
+#define GDB_S390_LINUX_TDEP_H
 
 #define S390_IS_GREGSET_REGNUM(i)					\
   (((i) >= S390_PSWM_REGNUM && (i) <= S390_A15_REGNUM)			\
@@ -64,4 +64,4 @@ extern const struct target_desc *tdesc_s390x_vx_linux64;
 extern const struct target_desc *tdesc_s390x_tevx_linux64;
 extern const struct target_desc *tdesc_s390x_gs_linux64;
 
-#endif /* S390_LINUX_TDEP_H */
+#endif /* GDB_S390_LINUX_TDEP_H */
diff --git a/gdb/s390-tdep.h b/gdb/s390-tdep.h
index 10f775f468f..bfcb8f17c56 100644
--- a/gdb/s390-tdep.h
+++ b/gdb/s390-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef S390_TDEP_H
-#define S390_TDEP_H
+#ifndef GDB_S390_TDEP_H
+#define GDB_S390_TDEP_H
 
 #include "prologue-value.h"
 #include "gdbarch.h"
@@ -322,4 +322,4 @@ extern struct value *s390_trad_frame_prev_register
 extern const struct target_desc *tdesc_s390_linux32;
 extern const struct target_desc *tdesc_s390x_linux64;
 
-#endif /* S390_TDEP_H */
+#endif /* GDB_S390_TDEP_H */
diff --git a/gdb/scoped-mock-context.h b/gdb/scoped-mock-context.h
index 2446e9ad41b..6fd83da4679 100644
--- a/gdb/scoped-mock-context.h
+++ b/gdb/scoped-mock-context.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_MOCK_CONTEXT_H
-#define SCOPED_MOCK_CONTEXT_H
+#ifndef GDB_SCOPED_MOCK_CONTEXT_H
+#define GDB_SCOPED_MOCK_CONTEXT_H
 
 #include "inferior.h"
 #include "gdbthread.h"
@@ -78,4 +78,4 @@ struct scoped_mock_context
 } // namespace selftests
 #endif /* GDB_SELF_TEST */
 
-#endif /* !defined (SCOPED_MOCK_CONTEXT_H) */
+#endif /* GDB_SCOPED_MOCK_CONTEXT_H */
diff --git a/gdb/selftest-arch.h b/gdb/selftest-arch.h
index 84494076bd7..db11723395e 100644
--- a/gdb/selftest-arch.h
+++ b/gdb/selftest-arch.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SELFTEST_ARCH_H
-#define SELFTEST_ARCH_H
+#ifndef GDB_SELFTEST_ARCH_H
+#define GDB_SELFTEST_ARCH_H
 
 typedef void self_test_foreach_arch_function (struct gdbarch *);
 
@@ -31,4 +31,4 @@ extern void
 			      self_test_foreach_arch_function *function);
 }
 
-#endif /* SELFTEST_ARCH_H */
+#endif /* GDB_SELFTEST_ARCH_H */
diff --git a/gdb/sentinel-frame.h b/gdb/sentinel-frame.h
index 1a37ff1f49a..36bee59f0f0 100644
--- a/gdb/sentinel-frame.h
+++ b/gdb/sentinel-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SENTINEL_FRAME_H)
-#define SENTINEL_FRAME_H 1
+#ifndef GDB_SENTINEL_FRAME_H
+#define GDB_SENTINEL_FRAME_H
 
 struct frame_unwind;
 struct regcache;
@@ -36,4 +36,4 @@ extern void *sentinel_frame_cache (struct regcache *regcache);
 
 extern const struct frame_unwind sentinel_frame_unwind;
 
-#endif /* !defined (SENTINEL_FRAME_H)  */
+#endif /* GDB_SENTINEL_FRAME_H */
diff --git a/gdb/ser-base.h b/gdb/ser-base.h
index 37fe0a2e5f5..ecb7c99ea62 100644
--- a/gdb/ser-base.h
+++ b/gdb/ser-base.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_BASE_H
-#define SER_BASE_H
+#ifndef GDB_SER_BASE_H
+#define GDB_SER_BASE_H
 
 #include "serial.h"
 
@@ -50,4 +50,4 @@ extern void ser_base_write (struct serial *scb, const void *buf, size_t count);
 extern void ser_base_async (struct serial *scb, int async_p);
 extern int ser_base_readchar (struct serial *scb, int timeout);
 
-#endif
+#endif /* GDB_SER_BASE_H */
diff --git a/gdb/ser-event.h b/gdb/ser-event.h
index 2c0a59df5df..08fc62b29ab 100644
--- a/gdb/ser-event.h
+++ b/gdb/ser-event.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_EVENT_H
-#define SER_EVENT_H
+#ifndef GDB_SER_EVENT_H
+#define GDB_SER_EVENT_H
 
 /* This is used to be able to signal the event loop (or any other
    select/poll) of events, in a race-free manner.
@@ -48,4 +48,4 @@ extern void serial_event_set (struct serial_event *event);
    call is made.  */
 extern void serial_event_clear (struct serial_event *event);
 
-#endif
+#endif /* GDB_SER_EVENT_H */
diff --git a/gdb/ser-tcp.h b/gdb/ser-tcp.h
index 6ff3662cefd..a1ebcf3c2a8 100644
--- a/gdb/ser-tcp.h
+++ b/gdb/ser-tcp.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_TCP_H
-#define SER_TCP_H
+#ifndef GDB_SER_TCP_H
+#define GDB_SER_TCP_H
 
 struct serial;
 
@@ -28,4 +28,4 @@ extern int net_read_prim (struct serial *scb, size_t count);
 extern int net_write_prim (struct serial *scb, const void *buf, size_t count);
 extern void ser_tcp_send_break (struct serial *scb);
 
-#endif
+#endif /* GDB_SER_TCP_H */
diff --git a/gdb/ser-unix.h b/gdb/ser-unix.h
index 253c95b24c0..487921f8d53 100644
--- a/gdb/ser-unix.h
+++ b/gdb/ser-unix.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SER_UNIX_H
-#define SER_UNIX_H
+#ifndef GDB_SER_UNIX_H
+#define GDB_SER_UNIX_H
 
 extern int ser_unix_read_prim (struct serial *scb, size_t count);
 extern int ser_unix_write_prim (struct serial *scb, const void *buf, 
 				size_t count);
 
-#endif
+#endif /* GDB_SER_UNIX_H */
diff --git a/gdb/serial.h b/gdb/serial.h
index 69507e69295..017b8904c35 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SERIAL_H
-#define SERIAL_H
+#ifndef GDB_SERIAL_H
+#define GDB_SERIAL_H
 
 #ifdef USE_WIN32API
 #include <winsock2.h>
@@ -326,4 +326,4 @@ extern void serial_done_wait_handle (struct serial *);
 
 #endif /* USE_WIN32API */
 
-#endif /* SERIAL_H */
+#endif /* GDB_SERIAL_H */
diff --git a/gdb/sh-tdep.h b/gdb/sh-tdep.h
index 1b1f019920a..dd524406b25 100644
--- a/gdb/sh-tdep.h
+++ b/gdb/sh-tdep.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SH_TDEP_H
-#define SH_TDEP_H
+#ifndef GDB_SH_TDEP_H
+#define GDB_SH_TDEP_H
 
 #include "gdbarch.h"
 
@@ -115,4 +115,4 @@ void sh_corefile_supply_regset (const struct regset *regset,
 void sh_corefile_collect_regset (const struct regset *regset,
 				 const struct regcache *regcache,
 				 int regnum, void *regs, size_t len);
-#endif /* SH_TDEP_H */
+#endif /* GDB_SH_TDEP_H */
diff --git a/gdb/sim-regno.h b/gdb/sim-regno.h
index 7f8f9422a02..76ecfeae3d9 100644
--- a/gdb/sim-regno.h
+++ b/gdb/sim-regno.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SIM_REGNO_H
-#define SIM_REGNO_H
+#ifndef GDB_SIM_REGNO_H
+#define GDB_SIM_REGNO_H
 
 /* The gdbarch_register_sim_regno (REGNUM) method, when there is a
    corresponding simulator register, returns that register number as a
@@ -40,4 +40,4 @@ enum sim_regno {
 
 extern int one2one_register_sim_regno (struct gdbarch *gdbarch, int regnum);
 
-#endif
+#endif /* GDB_SIM_REGNO_H */
diff --git a/gdb/skip.h b/gdb/skip.h
index c3e6cbf98ba..5625a7962fc 100644
--- a/gdb/skip.h
+++ b/gdb/skip.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SKIP_H)
-#define SKIP_H
+#ifndef GDB_SKIP_H
+#define GDB_SKIP_H
 
 struct symtab_and_line;
 
@@ -25,4 +25,4 @@ struct symtab_and_line;
 bool function_name_is_marked_for_skip (const char *function_name,
 				       const symtab_and_line &function_sal);
 
-#endif /* !defined (SKIP_H) */
+#endif /* GDB_SKIP_H */
diff --git a/gdb/sol2-tdep.h b/gdb/sol2-tdep.h
index a189666f05e..8e505d30e0e 100644
--- a/gdb/sol2-tdep.h
+++ b/gdb/sol2-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOL2_TDEP_H
-#define SOL2_TDEP_H 1
+#ifndef GDB_SOL2_TDEP_H
+#define GDB_SOL2_TDEP_H
 
 struct gdbarch;
 
@@ -26,4 +26,4 @@ int sol2_sigtramp_p (const frame_info_ptr &this_frame);
 
 void sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
 
-#endif /* sol2-tdep.h */
+#endif /* GDB_SOL2_TDEP_H */
diff --git a/gdb/solib-aix.h b/gdb/solib-aix.h
index 6487460b04c..79cad4dcdee 100644
--- a/gdb/solib-aix.h
+++ b/gdb/solib-aix.h
@@ -15,12 +15,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_AIX_H
-#define SOLIB_AIX_H
+#ifndef GDB_SOLIB_AIX_H
+#define GDB_SOLIB_AIX_H
 
 struct solib_ops;
 extern const solib_ops solib_aix_so_ops;
 
 extern CORE_ADDR solib_aix_get_toc_value (CORE_ADDR pc);
 
-#endif
+#endif /* GDB_SOLIB_AIX_H */
diff --git a/gdb/solib-darwin.h b/gdb/solib-darwin.h
index d6be9eb5b42..d62d6805137 100644
--- a/gdb/solib-darwin.h
+++ b/gdb/solib-darwin.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_DARWIN_H
-#define SOLIB_DARWIN_H
+#ifndef GDB_SOLIB_DARWIN_H
+#define GDB_SOLIB_DARWIN_H
 
 struct solib_ops;
 
 extern const solib_ops darwin_so_ops;
 
-#endif /* solib-darwin.h */
+#endif /* GDB_SOLIB_DARWIN_H */
diff --git a/gdb/solib-dsbt.h b/gdb/solib-dsbt.h
index e1f7d143848..2777939f7f9 100644
--- a/gdb/solib-dsbt.h
+++ b/gdb/solib-dsbt.h
@@ -17,11 +17,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_DSBT_H
-#define SOLIB_DSBT_H
+#ifndef GDB_SOLIB_DSBT_H
+#define GDB_SOLIB_DSBT_H
 
 struct solib_ops;
 
 extern const solib_ops dsbt_so_ops;
 
-#endif /* solib-dsbt.h */
+#endif /* GDB_SOLIB_DSBT_H */
diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h
index 579fe6d9843..37cdaff4882 100644
--- a/gdb/solib-svr4.h
+++ b/gdb/solib-svr4.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_SVR4_H
-#define SOLIB_SVR4_H
+#ifndef GDB_SOLIB_SVR4_H
+#define GDB_SOLIB_SVR4_H
 
 #include "solist.h"
 
@@ -112,4 +112,4 @@ extern struct link_map_offsets *svr4_lp64_fetch_link_map_offsets (void);
    SVR4 run time loader.  */
 int svr4_in_dynsym_resolve_code (CORE_ADDR pc);
 
-#endif /* solib-svr4.h */
+#endif /* GDB_SOLIB_SVR4_H */
diff --git a/gdb/solib-target.h b/gdb/solib-target.h
index 70f53c54553..f03e221588e 100644
--- a/gdb/solib-target.h
+++ b/gdb/solib-target.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_TARGET_H
-#define SOLIB_TARGET_H
+#ifndef GDB_SOLIB_TARGET_H
+#define GDB_SOLIB_TARGET_H
 
 struct solib_ops;
 extern const solib_ops solib_target_so_ops;
 
-#endif /* solib-target.h */
+#endif /* GDB_SOLIB_TARGET_H */
diff --git a/gdb/solib.h b/gdb/solib.h
index f7a93c0718f..1d3089634fe 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIB_H
-#define SOLIB_H
+#ifndef GDB_SOLIB_H
+#define GDB_SOLIB_H
 
 /* Forward decl's for prototypes */
 struct solib;
@@ -143,4 +143,4 @@ extern void set_cbfd_soname_build_id (gdb_bfd_ref_ptr abfd,
 				      const char *soname,
 				      const bfd_build_id *build_id);
 
-#endif /* SOLIB_H */
+#endif /* GDB_SOLIB_H */
diff --git a/gdb/solist.h b/gdb/solist.h
index f0d22080de1..006cdddeed9 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOLIST_H
-#define SOLIST_H
+#ifndef GDB_SOLIST_H
+#define GDB_SOLIST_H
 
 #define SO_NAME_MAX_PATH_SIZE 512	/* FIXME: Should be dynamic */
 /* For domain_enum domain.  */
@@ -186,4 +186,4 @@ extern gdb_bfd_ref_ptr solib_bfd_fopen (const char *pathname, int fd);
 /* Find solib binary file and open it.  */
 extern gdb_bfd_ref_ptr solib_bfd_open (const char *in_pathname);
 
-#endif
+#endif /* GDB_SOLIST_H */
diff --git a/gdb/source-cache.h b/gdb/source-cache.h
index d4cb7d00ae8..35eeb1cb204 100644
--- a/gdb/source-cache.h
+++ b/gdb/source-cache.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOURCE_CACHE_H
-#define SOURCE_CACHE_H
+#ifndef GDB_SOURCE_CACHE_H
+#define GDB_SOURCE_CACHE_H
 
 #include <unordered_map>
 #include <unordered_set>
@@ -104,4 +104,4 @@ class source_cache
 /* The global source cache.  */
 extern source_cache g_source_cache;
 
-#endif /* SOURCE_CACHE_H */
+#endif /* GDB_SOURCE_CACHE_H */
diff --git a/gdb/source.h b/gdb/source.h
index 144ee48f722..09eb1e38655 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SOURCE_H
-#define SOURCE_H
+#ifndef GDB_SOURCE_H
+#define GDB_SOURCE_H
 
 #include "gdbsupport/scoped_fd.h"
 
@@ -216,4 +216,4 @@ extern void forget_cached_source_info (void);
    need to would make things slower than necessary.  */
 extern void select_source_symtab ();
 
-#endif
+#endif /* GDB_SOURCE_H */
diff --git a/gdb/sparc-nat.h b/gdb/sparc-nat.h
index 29d994c2a41..712c9d0ac12 100644
--- a/gdb/sparc-nat.h
+++ b/gdb/sparc-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_NAT_H
-#define SPARC_NAT_H 1
+#ifndef GDB_SPARC_NAT_H
+#define GDB_SPARC_NAT_H
 
 #include "target.h"
 
@@ -82,4 +82,4 @@ struct sparc_target : public BaseTarget
   }
 };
 
-#endif /* sparc-nat.h */
+#endif /* GDB_SPARC_NAT_H */
diff --git a/gdb/sparc-ravenscar-thread.h b/gdb/sparc-ravenscar-thread.h
index d45f6ba8ba5..5f2749f5cd5 100644
--- a/gdb/sparc-ravenscar-thread.h
+++ b/gdb/sparc-ravenscar-thread.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_RAVENSCAR_THREAD_H
-#define SPARC_RAVENSCAR_THREAD_H
+#ifndef GDB_SPARC_RAVENSCAR_THREAD_H
+#define GDB_SPARC_RAVENSCAR_THREAD_H
 
 struct gdbarch;
 
 extern void register_sparc_ravenscar_ops (struct gdbarch *gdbarch);
-#endif
+#endif /* GDB_SPARC_RAVENSCAR_THREAD_H */
diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h
index 2d8c50768be..4fd7e6b0f74 100644
--- a/gdb/sparc-tdep.h
+++ b/gdb/sparc-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC_TDEP_H
-#define SPARC_TDEP_H 1
+#ifndef GDB_SPARC_TDEP_H
+#define GDB_SPARC_TDEP_H
 
 #include "gdbarch.h"
 
@@ -264,4 +264,4 @@ extern void sparc32nbsd_init_abi (struct gdbarch_info info,
 extern struct trad_frame_saved_reg *
   sparc32nbsd_sigcontext_saved_regs (const frame_info_ptr &next_frame);
 
-#endif /* sparc-tdep.h */
+#endif /* GDB_SPARC_TDEP_H */
diff --git a/gdb/sparc64-tdep.h b/gdb/sparc64-tdep.h
index 6fcd91ee8d3..a19af4a1b5d 100644
--- a/gdb/sparc64-tdep.h
+++ b/gdb/sparc64-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SPARC64_TDEP_H
-#define SPARC64_TDEP_H 1
+#ifndef GDB_SPARC64_TDEP_H
+#define GDB_SPARC64_TDEP_H
 
 class frame_info_ptr;
 struct gdbarch;
@@ -137,4 +137,4 @@ extern const struct sparc_fpregmap sparc64_bsd_fpregmap;
 
 extern void sparc64_forget_process (pid_t pid);
 
-#endif /* sparc64-tdep.h */
+#endif /* GDB_SPARC64_TDEP_H */
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index 0a868409470..00c7bd9edfa 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef STABSREAD_H
-#define STABSREAD_H
+#ifndef GDB_STABSREAD_H
+#define GDB_STABSREAD_H
 
 struct objfile;
 struct legacy_psymtab;
@@ -215,4 +215,4 @@ extern void init_header_files (void);
 
 extern void scan_file_globals (struct objfile *objfile);
 
-#endif /* STABSREAD_H */
+#endif /* GDB_STABSREAD_H */
diff --git a/gdb/stack.h b/gdb/stack.h
index e7242c71036..e87ba322dee 100644
--- a/gdb/stack.h
+++ b/gdb/stack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef STACK_H
-#define STACK_H
+#ifndef GDB_STACK_H
+#define GDB_STACK_H
 
 gdb::unique_xmalloc_ptr<char> find_frame_funname (const frame_info_ptr &frame,
 						  enum language *funlang,
@@ -84,4 +84,4 @@ void frame_apply_all_cmd_completer (struct cmd_list_element *ignore,
 				    completion_tracker &tracker,
 				    const char *text, const char */*word*/);
 
-#endif /* #ifndef STACK_H */
+#endif /* GDB_STACK_H */
diff --git a/gdb/stap-probe.h b/gdb/stap-probe.h
index 1401b876ba7..e757d80ef38 100644
--- a/gdb/stap-probe.h
+++ b/gdb/stap-probe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (STAP_PROBE_H)
-#define STAP_PROBE_H 1
+#ifndef GDB_STAP_PROBE_H
+#define GDB_STAP_PROBE_H
 
 #include "parser-defs.h"
 
@@ -66,4 +66,4 @@ struct stap_parse_info
   int inside_paren_p;
 };
 
-#endif /* !defined (STAP_PROBE_H) */
+#endif /* GDB_STAP_PROBE_H */
diff --git a/gdb/symfile-add-flags.h b/gdb/symfile-add-flags.h
index 19dd5e36907..3db532cc86b 100644
--- a/gdb/symfile-add-flags.h
+++ b/gdb/symfile-add-flags.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMFILE_ADD_FLAGS_H)
-#define SYMFILE_ADD_FLAGS_H
+#ifndef GDB_SYMFILE_ADD_FLAGS_H
+#define GDB_SYMFILE_ADD_FLAGS_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -54,4 +54,4 @@ enum symfile_add_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum symfile_add_flag, symfile_add_flags);
 
-#endif /* !defined(SYMFILE_ADD_FLAGS_H) */
+#endif /* GDB_SYMFILE_ADD_FLAGS_H */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 6f8b441b39f..3ed2179ba41 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMFILE_H)
-#define SYMFILE_H
+#ifndef GDB_SYMFILE_H
+#define GDB_SYMFILE_H
 
 /* This file requires that you first include "bfd.h".  */
 #include "symtab.h"
@@ -379,4 +379,4 @@ extern int readnow_symbol_files;
 
 extern int readnever_symbol_files;
 
-#endif /* !defined(SYMFILE_H) */
+#endif /* GDB_SYMFILE_H */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index bf9a3cfb79f..bfc91574415 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (SYMTAB_H)
-#define SYMTAB_H 1
+#ifndef GDB_SYMTAB_H
+#define GDB_SYMTAB_H
 
 #include <array>
 #include <vector>
@@ -2974,4 +2974,4 @@ extern void info_sources_worker (struct ui_out *uiout,
 
 std::optional<CORE_ADDR> find_epilogue_using_linetable (CORE_ADDR func_addr);
 
-#endif /* !defined(SYMTAB_H) */
+#endif /* GDB_SYMTAB_H */
diff --git a/gdb/target-connection.h b/gdb/target-connection.h
index c742932644f..4faae112dc7 100644
--- a/gdb/target-connection.h
+++ b/gdb/target-connection.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_CONNECTION_H
-#define TARGET_CONNECTION_H
+#ifndef GDB_TARGET_CONNECTION_H
+#define GDB_TARGET_CONNECTION_H
 
 #include <string>
 
@@ -37,4 +37,4 @@ void connection_list_remove (process_stratum_target *t);
    it.  */
 std::string make_target_connection_string (process_stratum_target *t);
 
-#endif /* TARGET_CONNECTION_H */
+#endif /* GDB_TARGET_CONNECTION_H */
diff --git a/gdb/target-dcache.h b/gdb/target-dcache.h
index 4acc82f83ce..a199a2382f2 100644
--- a/gdb/target-dcache.h
+++ b/gdb/target-dcache.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DCACHE_H
-#define TARGET_DCACHE_H
+#ifndef GDB_TARGET_DCACHE_H
+#define GDB_TARGET_DCACHE_H
 
 #include "dcache.h"
 #include "progspace.h"
@@ -33,4 +33,4 @@ extern int stack_cache_enabled_p (void);
 
 extern int code_cache_enabled_p (void);
 
-#endif /* TARGET_DCACHE_H */
+#endif /* GDB_TARGET_DCACHE_H */
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index 20ba1f73ac5..cf8d690511f 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DEBUG_H
-#define TARGET_DEBUG_H
+#ifndef GDB_TARGET_DEBUG_H
+#define GDB_TARGET_DEBUG_H
 
 /* Printers for the debug target.  Each prints an object of a given
    type to a string that needn't be freed.  Most printers are macros,
@@ -264,4 +264,4 @@ target_debug_print_x86_xsave_layout (const x86_xsave_layout &layout)
 #undef POFFS
   gdb_puts (" }", gdb_stdlog);
 }
-#endif /* TARGET_DEBUG_H */
+#endif /* GDB_TARGET_DEBUG_H */
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 54c1f234f06..833a367bc9a 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_DESCRIPTIONS_H
-#define TARGET_DESCRIPTIONS_H 1
+#ifndef GDB_TARGET_DESCRIPTIONS_H
+#define GDB_TARGET_DESCRIPTIONS_H
 #include "gdbsupport/tdesc.h"
 #include "gdbarch.h"
 
@@ -238,4 +238,4 @@ void record_xml_tdesc (const char *xml_file,
 }
 #endif
 
-#endif /* TARGET_DESCRIPTIONS_H */
+#endif /* GDB_TARGET_DESCRIPTIONS_H */
diff --git a/gdb/target-float.h b/gdb/target-float.h
index a649f5ceb86..0b9cd7a8409 100644
--- a/gdb/target-float.h
+++ b/gdb/target-float.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_FLOAT_H
-#define TARGET_FLOAT_H
+#ifndef GDB_TARGET_FLOAT_H
+#define GDB_TARGET_FLOAT_H
 
 #include "expression.h"
 
@@ -58,4 +58,4 @@ extern void target_float_binop (enum exp_opcode opcode,
 extern int target_float_compare (const gdb_byte *x, const struct type *type_x,
 				 const gdb_byte *y, const struct type *type_y);
 
-#endif /* TARGET_FLOAT_H */
+#endif /* GDB_TARGET_FLOAT_H */
diff --git a/gdb/target.h b/gdb/target.h
index c9eaff16346..c9f7d4c22d9 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TARGET_H)
-#define TARGET_H
+#ifndef GDB_TARGET_H
+#define GDB_TARGET_H
 
 struct objfile;
 struct ui_file;
@@ -2580,4 +2580,4 @@ extern void target_prepare_to_generate_core (void);
 /* See to_done_generating_core.  */
 extern void target_done_generating_core (void);
 
-#endif /* !defined (TARGET_H) */
+#endif /* GDB_TARGET_H */
diff --git a/gdb/target/resume.h b/gdb/target/resume.h
index 2f13aa9ada1..024e39b5bce 100644
--- a/gdb/target/resume.h
+++ b/gdb/target/resume.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_RESUME_H
-#define TARGET_RESUME_H
+#ifndef GDB_TARGET_RESUME_H
+#define GDB_TARGET_RESUME_H
 
 /* Ways to "resume" a thread.  */
 
@@ -34,4 +34,4 @@ enum resume_kind
   resume_stop
 };
 
-#endif /* TARGET_RESUME_H */
+#endif /* GDB_TARGET_RESUME_H */
diff --git a/gdb/target/target.h b/gdb/target/target.h
index 408db3558b0..87a3464e323 100644
--- a/gdb/target/target.h
+++ b/gdb/target/target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_TARGET_H
-#define TARGET_TARGET_H
+#ifndef GDB_TARGET_TARGET_H
+#define GDB_TARGET_TARGET_H
 
 #include "target/waitstatus.h"
 #include "target/wait.h"
@@ -262,4 +262,4 @@ class target_terminal
   static target_terminal_state m_terminal_state;
 };
 
-#endif /* TARGET_TARGET_H */
+#endif /* GDB_TARGET_TARGET_H */
diff --git a/gdb/target/wait.h b/gdb/target/wait.h
index 304f61497aa..026a42f9a30 100644
--- a/gdb/target/wait.h
+++ b/gdb/target/wait.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_WAIT_H
-#define TARGET_WAIT_H
+#ifndef GDB_TARGET_WAIT_H
+#define GDB_TARGET_WAIT_H
 
 #include "gdbsupport/enum-flags.h"
 
@@ -34,4 +34,4 @@ enum target_wait_flag : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum target_wait_flag, target_wait_flags);
 
-#endif /* TARGET_WAIT_H */
+#endif /* GDB_TARGET_WAIT_H */
diff --git a/gdb/target/waitstatus.h b/gdb/target/waitstatus.h
index dce1a7f3175..08907f5a610 100644
--- a/gdb/target/waitstatus.h
+++ b/gdb/target/waitstatus.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TARGET_WAITSTATUS_H
-#define TARGET_WAITSTATUS_H
+#ifndef GDB_TARGET_WAITSTATUS_H
+#define GDB_TARGET_WAITSTATUS_H
 
 #include "diagnostics.h"
 #include "gdbsupport/gdb_signals.h"
@@ -470,4 +470,4 @@ enum target_stop_reason
   TARGET_STOPPED_BY_SINGLE_STEP
 };
 
-#endif /* TARGET_WAITSTATUS_H */
+#endif /* GDB_TARGET_WAITSTATUS_H */
diff --git a/gdb/terminal.h b/gdb/terminal.h
index 236ab67745b..154b4be952b 100644
--- a/gdb/terminal.h
+++ b/gdb/terminal.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TERMINAL_H)
-#define TERMINAL_H 1
+#ifndef GDB_TERMINAL_H
+#define GDB_TERMINAL_H
 
 struct inferior;
 
@@ -43,4 +43,4 @@ extern void gdb_save_tty_state (void);
    have had a chance to alter it.  */
 extern void set_initial_gdb_ttystate (void);
 
-#endif /* !defined (TERMINAL_H) */
+#endif /* GDB_TERMINAL_H */
diff --git a/gdb/test-target.h b/gdb/test-target.h
index 54924e06994..b88c154da8f 100644
--- a/gdb/test-target.h
+++ b/gdb/test-target.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TEST_TARGET_H
-#define TEST_TARGET_H
+#ifndef GDB_TEST_TARGET_H
+#define GDB_TEST_TARGET_H
 
 #include "process-stratum-target.h"
 
@@ -62,4 +62,4 @@ class test_target_ops : public process_stratum_target
 } // namespace selftests
 #endif /* GDB_SELF_TEST */
 
-#endif /* !defined (TEST_TARGET_H) */
+#endif /* GDB_TEST_TARGET_H */
diff --git a/gdb/thread-fsm.h b/gdb/thread-fsm.h
index ed117719c0d..36efee75abc 100644
--- a/gdb/thread-fsm.h
+++ b/gdb/thread-fsm.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef THREAD_FSM_H
-#define THREAD_FSM_H
+#ifndef GDB_THREAD_FSM_H
+#define GDB_THREAD_FSM_H
 
 #include "mi/mi-common.h"
 
@@ -129,4 +129,4 @@ struct thread_fsm
   }
 };
 
-#endif /* THREAD_FSM_H */
+#endif /* GDB_THREAD_FSM_H */
diff --git a/gdb/thread-iter.h b/gdb/thread-iter.h
index a2fd9891a57..89537213ac0 100644
--- a/gdb/thread-iter.h
+++ b/gdb/thread-iter.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef THREAD_ITER_H
-#define THREAD_ITER_H
+#ifndef GDB_THREAD_ITER_H
+#define GDB_THREAD_ITER_H
 
 #include "gdbsupport/filtered-iterator.h"
 #include "gdbsupport/iterator-range.h"
@@ -249,4 +249,4 @@ class all_non_exited_threads_range
   ptid_t m_filter_ptid;
 };
 
-#endif /* THREAD_ITER_H */
+#endif /* GDB_THREAD_ITER_H */
diff --git a/gdb/tic6x-tdep.h b/gdb/tic6x-tdep.h
index 886e1b8b309..03a8a3ebb55 100644
--- a/gdb/tic6x-tdep.h
+++ b/gdb/tic6x-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TIC6X_TDEP_H
-#define TIC6X_TDEP_H
+#ifndef GDB_TIC6X_TDEP_H
+#define GDB_TIC6X_TDEP_H
 
 #include "gdbarch.h"
 
@@ -57,4 +57,4 @@ struct tic6x_gdbarch_tdep : gdbarch_tdep_base
   int has_gp = 0; /* Has general purpose registers A16 - A31 and B16 - B31.  */
 };
 
-#endif /* TIC6X_TDEP_H */
+#endif /* GDB_TIC6X_TDEP_H */
diff --git a/gdb/tid-parse.h b/gdb/tid-parse.h
index b7bd920f48a..ad45f216350 100644
--- a/gdb/tid-parse.h
+++ b/gdb/tid-parse.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TID_PARSE_H
-#define TID_PARSE_H
+#ifndef GDB_TID_PARSE_H
+#define GDB_TID_PARSE_H
 
 #include "cli/cli-utils.h"
 
@@ -186,4 +186,4 @@ class tid_range_parser
 extern int tid_is_in_list (const char *list, int default_inferior,
 			   int inf_num, int thr_num);
 
-#endif /* TID_PARSE_H */
+#endif /* GDB_TID_PARSE_H */
diff --git a/gdb/tilegx-tdep.h b/gdb/tilegx-tdep.h
index 893035a6273..5430281bed5 100644
--- a/gdb/tilegx-tdep.h
+++ b/gdb/tilegx-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TILEGX_TDEP_H
-#define TILEGX_TDEP_H
+#ifndef GDB_TILEGX_TDEP_H
+#define GDB_TILEGX_TDEP_H
 
 /* TILE-Gx has 56 general purpose registers (R0 - R52, TP, SP, LR),
    plus 8 special general purpose registers (network and ZERO),
@@ -107,4 +107,4 @@ enum tilegx_regnum
 
 enum { tilegx_reg_size = 8 };
 
-#endif /* tilegx-tdep.h */
+#endif /* GDB_TILEGX_TDEP_H */
diff --git a/gdb/top.h b/gdb/top.h
index 68c637a03d8..c142f1d9363 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TOP_H
-#define TOP_H
+#ifndef GDB_TOP_H
+#define GDB_TOP_H
 
 #include "gdbsupport/event-loop.h"
 #include "gdbsupport/next-iterator.h"
@@ -109,4 +109,4 @@ extern bool check_quiet_mode ();
 
 extern void unbuffer_stream (FILE *stream);
 
-#endif
+#endif /* GDB_TOP_H */
diff --git a/gdb/tracectf.h b/gdb/tracectf.h
index 08a681cb8cf..9f821c5314c 100644
--- a/gdb/tracectf.h
+++ b/gdb/tracectf.h
@@ -17,9 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CTF_H
-#define CTF_H
+#ifndef GDB_TRACECTF_H
+#define GDB_TRACECTF_H
 
 extern struct trace_file_writer *ctf_trace_file_writer_new (void);
 
-#endif
+#endif /* GDB_TRACECTF_H */
diff --git a/gdb/tracefile.h b/gdb/tracefile.h
index 90967eff855..028f70dabd3 100644
--- a/gdb/tracefile.h
+++ b/gdb/tracefile.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRACEFILE_H
-#define TRACEFILE_H 1
+#ifndef GDB_TRACEFILE_H
+#define GDB_TRACEFILE_H
 
 #include "tracepoint.h"
 #include "target.h"
@@ -151,4 +151,4 @@ class tracefile_target : public process_stratum_target
 
 extern void tracefile_fetch_registers (struct regcache *regcache, int regno);
 
-#endif /* TRACEFILE_H */
+#endif /* GDB_TRACEFILE_H */
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index 5e6ea67c8d2..1b9e03efc7a 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (TRACEPOINT_H)
-#define TRACEPOINT_H 1
+#ifndef GDB_TRACEPOINT_H
+#define GDB_TRACEPOINT_H
 
 #include "breakpoint.h"
 #include "memrange.h"
@@ -432,4 +432,4 @@ extern struct bp_location *get_traceframe_location (int *stepping_frame_p);
 /* Command element for the 'while-stepping' command.  */
 extern cmd_list_element *while_stepping_cmd_element;
 
-#endif	/* TRACEPOINT_H */
+#endif /* GDB_TRACEPOINT_H */
diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h
index ca8792baa17..40a3f74d44a 100644
--- a/gdb/trad-frame.h
+++ b/gdb/trad-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRAD_FRAME_H
-#define TRAD_FRAME_H
+#ifndef GDB_TRAD_FRAME_H
+#define GDB_TRAD_FRAME_H
 
 #include "frame.h"
 
@@ -203,4 +203,4 @@ struct value *trad_frame_get_prev_register (const frame_info_ptr &this_frame,
 					    trad_frame_saved_reg this_saved_regs[],
 					    int regnum);
 
-#endif
+#endif /* GDB_TRAD_FRAME_H */
diff --git a/gdb/tramp-frame.h b/gdb/tramp-frame.h
index d9e54f5981a..a7288c1889c 100644
--- a/gdb/tramp-frame.h
+++ b/gdb/tramp-frame.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TRAMP_FRAME_H
-#define TRAMP_FRAME_H
+#ifndef GDB_TRAMP_FRAME_H
+#define GDB_TRAMP_FRAME_H
 
 #include "frame.h"
 #include "frame-unwind.h"	/* For frame_prev_arch_ftype.  */
@@ -85,4 +85,4 @@ struct tramp_frame
 void tramp_frame_prepend_unwinder (struct gdbarch *gdbarch,
 				   const struct tramp_frame *tramp);
 
-#endif
+#endif /* GDB_TRAMP_FRAME_H */
diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h
index 2dc579bce30..0f6553845a2 100644
--- a/gdb/tui/tui-command.h
+++ b/gdb/tui/tui-command.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_COMMAND_H
-#define TUI_TUI_COMMAND_H
+#ifndef GDB_TUI_TUI_COMMAND_H
+#define GDB_TUI_TUI_COMMAND_H
 
 #include "tui/tui-data.h"
 
@@ -58,4 +58,4 @@ struct tui_cmd_window
 /* Refresh the command window.  */
 extern void tui_refresh_cmd_win (void);
 
-#endif /* TUI_TUI_COMMAND_H */
+#endif /* GDB_TUI_TUI_COMMAND_H */
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index ce9c1a8a95a..4ff9fa64aa7 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_DATA_H
-#define TUI_TUI_DATA_H
+#ifndef GDB_TUI_TUI_DATA_H
+#define GDB_TUI_TUI_DATA_H
 
 #include "tui/tui.h"
 #include "gdb_curses.h"
@@ -325,4 +325,4 @@ extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
 
 extern unsigned int tui_tab_width;
 
-#endif /* TUI_TUI_DATA_H */
+#endif /* GDB_TUI_TUI_DATA_H */
diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
index 0aef091069b..a5a240fddf1 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_DISASM_H
-#define TUI_TUI_DISASM_H
+#ifndef GDB_TUI_TUI_DISASM_H
+#define GDB_TUI_TUI_DISASM_H
 
 #include "tui/tui.h"
 #include "tui/tui-data.h"
@@ -66,4 +66,4 @@ struct tui_disasm_window : public tui_source_window_base
 
 extern void tui_get_begin_asm_address (struct gdbarch **, CORE_ADDR *);
 
-#endif /* TUI_TUI_DISASM_H */
+#endif /* GDB_TUI_TUI_DISASM_H */
diff --git a/gdb/tui/tui-file.h b/gdb/tui/tui-file.h
index b723f3974ea..6178a90a6c6 100644
--- a/gdb/tui/tui-file.h
+++ b/gdb/tui/tui-file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_FILE_H
-#define TUI_TUI_FILE_H
+#ifndef GDB_TUI_TUI_FILE_H
+#define GDB_TUI_TUI_FILE_H
 
 #include "ui-file.h"
 
@@ -41,4 +41,4 @@ class tui_file : public stdio_file
   bool m_buffered;
 };
 
-#endif /* TUI_TUI_FILE_H */
+#endif /* GDB_TUI_TUI_FILE_H */
diff --git a/gdb/tui/tui-hooks.h b/gdb/tui/tui-hooks.h
index 97683826544..21ba169713c 100644
--- a/gdb/tui/tui-hooks.h
+++ b/gdb/tui/tui-hooks.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_HOOKS_H
-#define TUI_TUI_HOOKS_H
+#ifndef GDB_TUI_TUI_HOOKS_H
+#define GDB_TUI_TUI_HOOKS_H
 
 extern void tui_install_hooks (void);
 extern void tui_remove_hooks (void);
 
-#endif /* TUI_TUI_HOOKS_H */
+#endif /* GDB_TUI_TUI_HOOKS_H */
diff --git a/gdb/tui/tui-io.h b/gdb/tui/tui-io.h
index 9e7eecdf5f4..66b3b90dfe3 100644
--- a/gdb/tui/tui-io.h
+++ b/gdb/tui/tui-io.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_IO_H
-#define TUI_TUI_IO_H
+#ifndef GDB_TUI_TUI_IO_H
+#define GDB_TUI_TUI_IO_H
 
 #include "gdb_curses.h"
 
@@ -60,4 +60,4 @@ extern cli_ui_out *tui_old_uiout;
    next line.  */
 extern void tui_inject_newline_into_command_window ();
 
-#endif /* TUI_TUI_IO_H */
+#endif /* GDB_TUI_TUI_IO_H */
diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h
index f621f9cea55..d1dc9bfd904 100644
--- a/gdb/tui/tui-layout.h
+++ b/gdb/tui/tui-layout.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_LAYOUT_H
-#define TUI_TUI_LAYOUT_H
+#ifndef GDB_TUI_TUI_LAYOUT_H
+#define GDB_TUI_TUI_LAYOUT_H
 
 #include "ui-file.h"
 
@@ -418,4 +418,4 @@ using known_window_names_range
 
 extern known_window_names_range all_known_window_names ();
 
-#endif /* TUI_TUI_LAYOUT_H */
+#endif /* GDB_TUI_TUI_LAYOUT_H */
diff --git a/gdb/tui/tui-location.h b/gdb/tui/tui-location.h
index db558a4e147..8e83b26996b 100644
--- a/gdb/tui/tui-location.h
+++ b/gdb/tui/tui-location.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_LOCATION_H
-#define TUI_TUI_LOCATION_H
+#ifndef GDB_TUI_TUI_LOCATION_H
+#define GDB_TUI_TUI_LOCATION_H
 
 #include "tui/tui.h"
 #include "tui/tui.h"
@@ -90,4 +90,4 @@ struct tui_location_tracker
 
 extern tui_location_tracker tui_location;
 
-#endif /* TUI_TUI_LOCATION_H */
+#endif /* GDB_TUI_TUI_LOCATION_H */
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 07b951316b6..eea5ca6d061 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_REGS_H
-#define TUI_TUI_REGS_H
+#ifndef GDB_TUI_TUI_REGS_H
+#define GDB_TUI_TUI_REGS_H
 
 #include "tui/tui-data.h"
 #include "reggroups.h"
@@ -145,4 +145,4 @@ struct tui_data_window : public tui_win_info
   gdbarch *m_gdbarch = nullptr;
 };
 
-#endif /* TUI_TUI_REGS_H */
+#endif /* GDB_TUI_TUI_REGS_H */
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 6d4ad4e39c2..4312b928740 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_SOURCE_H
-#define TUI_TUI_SOURCE_H
+#ifndef GDB_TUI_TUI_SOURCE_H
+#define GDB_TUI_TUI_SOURCE_H
 
 #include "tui/tui-data.h"
 #include "tui-winsource.h"
@@ -84,4 +84,4 @@ struct tui_source_window : public tui_source_window_base
   gdb::unique_xmalloc_ptr<char> m_fullname;
 };
 
-#endif /* TUI_TUI_SOURCE_H */
+#endif /* GDB_TUI_TUI_SOURCE_H */
diff --git a/gdb/tui/tui-status.h b/gdb/tui/tui-status.h
index 0af44664104..b4c8a2bd407 100644
--- a/gdb/tui/tui-status.h
+++ b/gdb/tui/tui-status.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_STATUS_H
-#define TUI_TUI_STATUS_H
+#ifndef GDB_TUI_TUI_STATUS_H
+#define GDB_TUI_TUI_STATUS_H
 
 #include "tui/tui-data.h"
 
@@ -53,4 +53,4 @@ struct tui_status_window
 extern void tui_show_status_content (void);
 extern void tui_show_frame_info (const frame_info_ptr &);
 
-#endif /* TUI_TUI_STATUS_H */
+#endif /* GDB_TUI_TUI_STATUS_H */
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 9b03d01c430..15219930149 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WIN_H
-#define TUI_TUI_WIN_H
+#ifndef GDB_TUI_TUI_WIN_H
+#define GDB_TUI_TUI_WIN_H
 
 #include "tui/tui-data.h"
 
@@ -61,4 +61,4 @@ extern bool style_tui_current_position;
 /* Whether to replace the spaces in the left margin with '_' and '0'.  */
 extern bool tui_left_margin_verbose;
 
-#endif /* TUI_TUI_WIN_H */
+#endif /* GDB_TUI_TUI_WIN_H */
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 6bee433689e..c36f32de7e4 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WINGENERAL_H
-#define TUI_TUI_WINGENERAL_H
+#ifndef GDB_TUI_TUI_WINGENERAL_H
+#define GDB_TUI_TUI_WINGENERAL_H
 
 #include "gdb_curses.h"
 
@@ -53,4 +53,4 @@ class tui_suppress_output
    suppressed via tui_suppress_output, do not call wrefresh.  */
 extern void tui_wrefresh (WINDOW *win);
 
-#endif /* TUI_TUI_WINGENERAL_H */
+#endif /* GDB_TUI_TUI_WINGENERAL_H */
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 646597306f2..7effb5694e3 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_WINSOURCE_H
-#define TUI_TUI_WINSOURCE_H
+#ifndef GDB_TUI_TUI_WINSOURCE_H
+#define GDB_TUI_TUI_WINSOURCE_H
 
 #include "tui/tui-data.h"
 #include "symtab.h"
@@ -365,4 +365,4 @@ extern std::string tui_copy_source_line (const char **ptr,
 /* Constant definitions. */
 #define SCROLL_THRESHOLD 2	/* Threshold for lazy scroll.  */
 
-#endif /* TUI_TUI_WINSOURCE_H */
+#endif /* GDB_TUI_TUI_WINSOURCE_H */
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index 00295107eac..1bcaa2f4099 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TUI_TUI_H
-#define TUI_TUI_H
+#ifndef GDB_TUI_TUI_H
+#define GDB_TUI_TUI_H
 
 /* Flag to control tui debugging.  */
 
@@ -98,4 +98,4 @@ extern void tui_set_key_mode (enum tui_key_mode mode);
 
 extern bool tui_active;
 
-#endif /* TUI_TUI_H */
+#endif /* GDB_TUI_TUI_H */
diff --git a/gdb/type-stack.h b/gdb/type-stack.h
index faef3c85f67..87c0fe20c5a 100644
--- a/gdb/type-stack.h
+++ b/gdb/type-stack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TYPE_STACK_H
-#define TYPE_STACK_H
+#ifndef GDB_TYPE_STACK_H
+#define GDB_TYPE_STACK_H
 
 #include "gdbtypes.h"
 #include <vector>
@@ -203,4 +203,4 @@ struct type_stack
   std::vector<union type_stack_elt> m_elements;
 };
 
-#endif /* TYPE_STACK_H */
+#endif /* GDB_TYPE_STACK_H */
diff --git a/gdb/typeprint.h b/gdb/typeprint.h
index e14d70efa2d..91b64f3e728 100644
--- a/gdb/typeprint.h
+++ b/gdb/typeprint.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef TYPEPRINT_H
-#define TYPEPRINT_H
+#ifndef GDB_TYPEPRINT_H
+#define GDB_TYPEPRINT_H
 
 #include "gdbsupport/gdb_obstack.h"
 
@@ -181,4 +181,4 @@ extern void val_print_not_allocated (struct ui_file *stream);
 
 extern void val_print_not_associated (struct ui_file *stream);
 
-#endif
+#endif /* GDB_TYPEPRINT_H */
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index 96864409375..627e51ae84c 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_FILE_H
-#define UI_FILE_H
+#ifndef GDB_UI_FILE_H
+#define GDB_UI_FILE_H
 
 #include <string>
 #include "ui-style.h"
@@ -467,4 +467,4 @@ class timestamped_file : public wrapped_file
   bool m_needs_timestamp = true;
 };
 
-#endif
+#endif /* GDB_UI_FILE_H */
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 5b6ddd55063..67f6b18576f 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_OUT_H
-#define UI_OUT_H 1
+#ifndef GDB_UI_OUT_H
+#define GDB_UI_OUT_H
 
 #include <vector>
 
@@ -654,4 +654,4 @@ struct buffered_streams
   std::optional<buffering_file> m_buffered_uiout;
 };
 
-#endif /* UI_OUT_H */
+#endif /* GDB_UI_OUT_H */
diff --git a/gdb/ui-style.h b/gdb/ui-style.h
index 1b7b5fafb9d..53ac2897c78 100644
--- a/gdb/ui-style.h
+++ b/gdb/ui-style.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_STYLE_H
-#define UI_STYLE_H
+#ifndef GDB_UI_STYLE_H
+#define GDB_UI_STYLE_H
 
 /* Styles that can be applied to a ui_file.  */
 struct ui_file_style
@@ -250,4 +250,4 @@ struct ui_file_style
 
 extern bool skip_ansi_escape (const char *buf, int *n_read);
 
-#endif /* UI_STYLE_H */
+#endif /* GDB_UI_STYLE_H */
diff --git a/gdb/ui.h b/gdb/ui.h
index 95cf273473a..ec3a6c5fbae 100644
--- a/gdb/ui.h
+++ b/gdb/ui.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UI_H
-#define UI_H
+#ifndef GDB_UI_H
+#define GDB_UI_H
 
 #include "gdbsupport/event-loop.h"
 #include "gdbsupport/intrusive_list.h"
@@ -229,4 +229,4 @@ ui_range all_uis ()
   return ui_range (ui_list);
 }
 
-#endif /* UI_H */
+#endif /* GDB_UI_H */
diff --git a/gdb/user-regs.h b/gdb/user-regs.h
index baa3581a0ba..67a28dd429e 100644
--- a/gdb/user-regs.h
+++ b/gdb/user-regs.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef USER_REGS_H
-#define USER_REGS_H
+#ifndef GDB_USER_REGS_H
+#define GDB_USER_REGS_H
 
 /* Implement both builtin, and architecture specific, per-frame user
    visible registers.
@@ -69,4 +69,4 @@ extern void user_reg_add_builtin (const char *name,
 extern void user_reg_add (struct gdbarch *gdbarch, const char *name, 
 			  user_reg_read_ftype *read, const void *baton);
 
-#endif
+#endif /* GDB_USER_REGS_H */
diff --git a/gdb/utils.h b/gdb/utils.h
index 96350890a97..2dc36f42ed1 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef UTILS_H
-#define UTILS_H
+#ifndef GDB_UTILS_H
+#define GDB_UTILS_H
 
 #include "exceptions.h"
 #include "gdbsupport/array-view.h"
@@ -475,4 +475,4 @@ struct deferred_warnings final : public warning_hook_handler_type
   std::vector<string_file> m_warnings;
 };
 
-#endif /* UTILS_H */
+#endif /* GDB_UTILS_H */
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 4f194b77008..834e9d97ffd 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VALPRINT_H
-#define VALPRINT_H
+#ifndef GDB_VALPRINT_H
+#define GDB_VALPRINT_H
 
 #include "cli/cli-option.h"
 
@@ -337,4 +337,4 @@ extern void common_val_print_checked
    const struct value_print_options *options,
    const struct language_defn *language);
 
-#endif
+#endif /* GDB_VALPRINT_H */
diff --git a/gdb/value.h b/gdb/value.h
index 9d7e88d9433..8fc9550f11f 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (VALUE_H)
-#define VALUE_H 1
+#ifndef GDB_VALUE_H
+#define GDB_VALUE_H
 
 #include "frame.h"
 #include "extension.h"
@@ -1704,4 +1704,4 @@ void pseudo_to_concat_raw (const frame_info_ptr &next_frame,
 			   int raw_reg_1_num, int raw_reg_2_num,
 			   int raw_reg_3_num);
 
-#endif /* !defined (VALUE_H) */
+#endif /* GDB_VALUE_H */
diff --git a/gdb/varobj-iter.h b/gdb/varobj-iter.h
index 4254f8b549e..46e25e797c8 100644
--- a/gdb/varobj-iter.h
+++ b/gdb/varobj-iter.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAROBJ_ITER_H
-#define VAROBJ_ITER_H
+#ifndef GDB_VAROBJ_ITER_H
+#define GDB_VAROBJ_ITER_H
 
 /* A node or item of varobj, composed of the name and the value.  */
 
@@ -39,4 +39,4 @@ struct varobj_iter
   virtual std::unique_ptr<varobj_item> next () = 0;
 };
 
-#endif /* VAROBJ_ITER_H */
+#endif /* GDB_VAROBJ_ITER_H */
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 426c3b7d628..9d19f53fb3e 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAROBJ_H
-#define VAROBJ_H 1
+#ifndef GDB_VAROBJ_H
+#define GDB_VAROBJ_H
 
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -355,4 +355,4 @@ extern void varobj_restrict_range (const std::vector<varobj *> &children,
 
 extern bool varobj_default_is_path_expr_parent (const struct varobj *var);
 
-#endif /* VAROBJ_H */
+#endif /* GDB_VAROBJ_H */
diff --git a/gdb/vax-tdep.h b/gdb/vax-tdep.h
index 72b072d692d..fbc35d97c4e 100644
--- a/gdb/vax-tdep.h
+++ b/gdb/vax-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef VAX_TDEP_H
-#define VAX_TDEP_H
+#ifndef GDB_VAX_TDEP_H
+#define GDB_VAX_TDEP_H
 
 /* Register numbers of various important registers.  */
 
@@ -36,4 +36,4 @@ enum vax_regnum
 /* Number of machine registers.  */
 #define VAX_NUM_REGS 17
 
-#endif /* vax-tdep.h */
+#endif /* GDB_VAX_TDEP_H */
diff --git a/gdb/windows-nat.h b/gdb/windows-nat.h
index 3fbb1ea35df..b36e7f45512 100644
--- a/gdb/windows-nat.h
+++ b/gdb/windows-nat.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef WINDOWS_NAT_H
-#define WINDOWS_NAT_H
+#ifndef GDB_WINDOWS_NAT_H
+#define GDB_WINDOWS_NAT_H
 
 /* A pointer to a function that should return non-zero iff REGNUM
    corresponds to one of the segment registers.  */
@@ -36,4 +36,4 @@ int amd64_windows_segment_register_p (int regnum);
 extern const int amd64_mappings[];
 #endif
 
-#endif
+#endif /* GDB_WINDOWS_NAT_H */
diff --git a/gdb/windows-tdep.h b/gdb/windows-tdep.h
index f122f7aaa61..abb25331938 100644
--- a/gdb/windows-tdep.h
+++ b/gdb/windows-tdep.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef WINDOWS_TDEP_H
-#define WINDOWS_TDEP_H
+#ifndef GDB_WINDOWS_TDEP_H
+#define GDB_WINDOWS_TDEP_H
 
 #include "frame-unwind.h"
 
@@ -75,4 +75,4 @@ struct cygwin_sigwrapper_frame_unwind : public frame_unwind
   gdb::array_view<const gdb::array_view<const gdb_byte>> patterns_list;
 };
 
-#endif
+#endif /* GDB_WINDOWS_TDEP_H */
diff --git a/gdb/x86-bsd-nat.h b/gdb/x86-bsd-nat.h
index 7b1ba7a1f44..b1745448ece 100644
--- a/gdb/x86-bsd-nat.h
+++ b/gdb/x86-bsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_BSD_NAT_H
-#define X86_BSD_NAT_H
+#ifndef GDB_X86_BSD_NAT_H
+#define GDB_X86_BSD_NAT_H
 
 #include "x86-nat.h"
 
@@ -43,4 +43,4 @@ class x86bsd_nat_target : public BaseTarget
 };
 #endif /* HAVE_PT_GETDBREGS */
 
-#endif /* x86-bsd-nat.h */
+#endif /* GDB_X86_BSD_NAT_H */
diff --git a/gdb/x86-fbsd-nat.h b/gdb/x86-fbsd-nat.h
index a202e77c788..66f2b2f61b2 100644
--- a/gdb/x86-fbsd-nat.h
+++ b/gdb/x86-fbsd-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_FBSD_NAT_H
-#define X86_FBSD_NAT_H
+#ifndef GDB_X86_FBSD_NAT_H
+#define GDB_X86_FBSD_NAT_H
 
 #include <sys/ptrace.h>
 
@@ -53,4 +53,4 @@ class x86_fbsd_nat_target : public x86bsd_nat_target<fbsd_nat_target>
 #endif
 };
 
-#endif /* x86-bsd-nat.h */
+#endif /* GDB_X86_FBSD_NAT_H */
diff --git a/gdb/x86-linux-nat.h b/gdb/x86-linux-nat.h
index 4efe5461847..3c2241bb0b6 100644
--- a/gdb/x86-linux-nat.h
+++ b/gdb/x86-linux-nat.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_LINUX_NAT_H
-#define X86_LINUX_NAT_H 1
+#ifndef GDB_X86_LINUX_NAT_H
+#define GDB_X86_LINUX_NAT_H
 
 #include "gdb_proc_service.h"
 #include "linux-nat.h"
@@ -92,4 +92,4 @@ struct x86_linux_nat_target : public x86_nat_target<linux_nat_target>
 extern ps_err_e x86_linux_get_thread_area (pid_t pid, void *addr,
 					   unsigned int *base_addr);
 
-#endif
+#endif /* GDB_X86_LINUX_NAT_H */
diff --git a/gdb/x86-nat.h b/gdb/x86-nat.h
index f07cefa027d..1b8fdd38325 100644
--- a/gdb/x86-nat.h
+++ b/gdb/x86-nat.h
@@ -20,8 +20,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_NAT_H
-#define X86_NAT_H 1
+#ifndef GDB_X86_NAT_H
+#define GDB_X86_NAT_H
 
 #include "breakpoint.h"
 #include "nat/x86-dregs.h"
@@ -114,4 +114,4 @@ struct x86_nat_target : public BaseTarget
   { return x86_stopped_by_hw_breakpoint (); }
 };
 
-#endif /* X86_NAT_H */
+#endif /* GDB_X86_NAT_H */
diff --git a/gdb/x86-tdep.h b/gdb/x86-tdep.h
index 7ab47814d41..2b5853adb8a 100644
--- a/gdb/x86-tdep.h
+++ b/gdb/x86-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef X86_TDEP_H
-#define X86_TDEP_H
+#ifndef GDB_X86_TDEP_H
+#define GDB_X86_TDEP_H
 
 /* Checks whether PC lies in an indirect branch thunk using registers
    REGISTER_NAMES[LO] (inclusive) to REGISTER_NAMES[HI] (exclusive).  */
@@ -27,4 +27,4 @@ extern bool x86_in_indirect_branch_thunk (CORE_ADDR pc,
 					  const char * const *register_names,
 					  int lo, int hi);
 
-#endif /* x86-tdep.h */
+#endif /* GDB_X86_TDEP_H */
diff --git a/gdb/xcoffread.h b/gdb/xcoffread.h
index 8bc729e3dff..7528dec4a6c 100644
--- a/gdb/xcoffread.h
+++ b/gdb/xcoffread.h
@@ -16,11 +16,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XCOFFREAD_H
-#define XCOFFREAD_H
+#ifndef GDB_XCOFFREAD_H
+#define GDB_XCOFFREAD_H
 
 extern CORE_ADDR xcoff_get_toc_offset (struct objfile *);
 
 extern int xcoff_get_n_import_files (bfd *abfd);
 
-#endif /* XCOFFREAD_H */
+#endif /* GDB_XCOFFREAD_H */
diff --git a/gdb/xml-builtin.h b/gdb/xml-builtin.h
index 417771ea4e9..463e0fb16e0 100644
--- a/gdb/xml-builtin.h
+++ b/gdb/xml-builtin.h
@@ -17,12 +17,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_BUILTIN_H
-#define XML_BUILTIN_H
+#ifndef GDB_XML_BUILTIN_H
+#define GDB_XML_BUILTIN_H
 
 /* The text of compiled-in XML documents, from xml-builtin.c
    (generated).  */
 
 extern const char *const xml_builtin[][2];
 
-#endif /* XML_BUILTIN_H */
+#endif /* GDB_XML_BUILTIN_H */
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index b9bac7a10c2..f2860a20d6b 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -18,8 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef XML_SUPPORT_H
-#define XML_SUPPORT_H
+#ifndef GDB_XML_SUPPORT_H
+#define GDB_XML_SUPPORT_H
 
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/xml-utils.h"
@@ -233,4 +233,4 @@ ULONGEST gdb_xml_parse_ulongest (struct gdb_xml_parser *parser,
 extern std::optional<gdb::char_vector> xml_fetch_content_from_file
     (const char *filename, const char *dirname);
 
-#endif
+#endif /* GDB_XML_SUPPORT_H */
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index 60cfb71ada2..579805d9394 100644
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_SYSCALL_H
-#define XML_SYSCALL_H 1
+#ifndef GDB_XML_SYSCALL_H
+#define GDB_XML_SYSCALL_H
 
 /* Function used to set the name of the file which contains
    information about the system calls present in the current
@@ -66,4 +66,4 @@ bool get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
 
 const char **get_syscall_group_names (struct gdbarch *gdbarch);
 
-#endif /* XML_SYSCALL_H */
+#endif /* GDB_XML_SYSCALL_H */
diff --git a/gdb/xml-tdesc.h b/gdb/xml-tdesc.h
index cd6e79cc24f..ec71c682f86 100644
--- a/gdb/xml-tdesc.h
+++ b/gdb/xml-tdesc.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XML_TDESC_H
-#define XML_TDESC_H
+#ifndef GDB_XML_TDESC_H
+#define GDB_XML_TDESC_H
 
 #include <optional>
 #include <string>
@@ -49,4 +49,4 @@ std::optional<std::string> target_fetch_description_xml (target_ops *ops);
 
 const struct target_desc *string_read_description_xml (const char *xml);
 
-#endif /* XML_TDESC_H */
+#endif /* GDB_XML_TDESC_H */
diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h
index b76ed137380..832b4fbf33a 100644
--- a/gdb/xtensa-tdep.h
+++ b/gdb/xtensa-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef XTENSA_TDEP_H
-#define XTENSA_TDEP_H
+#ifndef GDB_XTENSA_TDEP_H
+#define GDB_XTENSA_TDEP_H
 
 #include "arch/xtensa.h"
 #include "gdbarch.h"
@@ -249,4 +249,4 @@ struct xtensa_gdbarch_tdep : gdbarch_tdep_base
    data structure to their corresponding register in the AR register 
    file (see xtensa-tdep.c).  */
 
-#endif /* XTENSA_TDEP_H */
+#endif /* GDB_XTENSA_TDEP_H */
diff --git a/gdb/yy-remap.h b/gdb/yy-remap.h
index d52a59d11b9..9a6c399b855 100644
--- a/gdb/yy-remap.h
+++ b/gdb/yy-remap.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef YY_REMAP_H
-#define YY_REMAP_H
+#ifndef GDB_YY_REMAP_H
+#define GDB_YY_REMAP_H
 
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
    etc), as well as gratuitiously global symbol names, so we can have
@@ -97,4 +97,4 @@
 # define YYFPRINTF parser_fprintf
 #endif
 
-#endif /* YY_REMAP_H */
+#endif /* GDB_YY_REMAP_H */
diff --git a/gdb/z80-tdep.h b/gdb/z80-tdep.h
index 4b36024d1f0..19a7d046f7a 100644
--- a/gdb/z80-tdep.h
+++ b/gdb/z80-tdep.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef Z80_TDEP_H
-#define Z80_TDEP_H
+#ifndef GDB_Z80_TDEP_H
+#define GDB_Z80_TDEP_H
 
 /* Register pair constants
    Order optimized for gdb-stub implementation
@@ -49,4 +49,4 @@ enum z80_regnum
 #define EZ80_NUM_REGS	(Z80_NUM_REGS + 1)
 #define EZ80_REG_BYTES	(EZ80_NUM_REGS*3)
 
-#endif /* z80-tdep.h */
+#endif /* GDB_Z80_TDEP_H */
diff --git a/gdbserver/linux-aarch32-tdesc.h b/gdbserver/linux-aarch32-tdesc.h
index ff1c45fa1c1..173eac24389 100644
--- a/gdbserver/linux-aarch32-tdesc.h
+++ b/gdbserver/linux-aarch32-tdesc.h
@@ -26,4 +26,4 @@ const target_desc * aarch32_linux_read_description ();
 
 bool is_aarch32_linux_description (const target_desc *tdesc);
 
-#endif /* linux-aarch32-tdesc.h.  */
+#endif /* GDBSERVER_LINUX_AARCH32_TDESC_H */
diff --git a/gdbserver/linux-arm-tdesc.h b/gdbserver/linux-arm-tdesc.h
index 76a30c3c73a..bf12c8f5b68 100644
--- a/gdbserver/linux-arm-tdesc.h
+++ b/gdbserver/linux-arm-tdesc.h
@@ -28,4 +28,4 @@ const target_desc * arm_linux_read_description (arm_fp_type fp_type);
 
 arm_fp_type arm_linux_get_tdesc_fp_type (const target_desc *tdesc);
 
-#endif /* linux-arm-tdesc.h.  */
+#endif /* GDBSERVER_LINUX_ARM_TDESC_H */
diff --git a/gdbsupport/agent.h b/gdbsupport/agent.h
index e5a1fed84b9..305ed70fff2 100644
--- a/gdbsupport/agent.h
+++ b/gdbsupport/agent.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_AGENT_H
-#define COMMON_AGENT_H
+#ifndef GDBSUPPORT_AGENT_H
+#define GDBSUPPORT_AGENT_H
 
 #include "gdbsupport/preprocessor.h"
 
@@ -65,4 +65,4 @@ bool agent_capability_check (enum agent_capa);
 
 void agent_capability_invalidate (void);
 
-#endif /* COMMON_AGENT_H */
+#endif /* GDBSUPPORT_AGENT_H */
diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h
index 93842a40ec1..a61e09e882c 100644
--- a/gdbsupport/array-view.h
+++ b/gdbsupport/array-view.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ARRAY_VIEW_H
-#define COMMON_ARRAY_VIEW_H
+#ifndef GDBSUPPORT_ARRAY_VIEW_H
+#define GDBSUPPORT_ARRAY_VIEW_H
 
 #include "traits.h"
 #include <algorithm>
@@ -294,4 +294,4 @@ make_array_view (U *array, size_t size) noexcept
 
 } /* namespace gdb */
 
-#endif
+#endif /* GDBSUPPORT_ARRAY_VIEW_H */
diff --git a/gdbsupport/break-common.h b/gdbsupport/break-common.h
index 95ab3e290ba..1202231be0c 100644
--- a/gdbsupport/break-common.h
+++ b/gdbsupport/break-common.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BREAK_COMMON_H
-#define COMMON_BREAK_COMMON_H
+#ifndef GDBSUPPORT_BREAK_COMMON_H
+#define GDBSUPPORT_BREAK_COMMON_H
 
 enum target_hw_bp_type
   {
@@ -28,4 +28,4 @@ enum target_hw_bp_type
     hw_execute = 3		/* Execute HW breakpoint */
   };
 
-#endif /* COMMON_BREAK_COMMON_H */
+#endif /* GDBSUPPORT_BREAK_COMMON_H */
diff --git a/gdbsupport/btrace-common.h b/gdbsupport/btrace-common.h
index bf57bc1615e..1888b242f70 100644
--- a/gdbsupport/btrace-common.h
+++ b/gdbsupport/btrace-common.h
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BTRACE_COMMON_H
-#define COMMON_BTRACE_COMMON_H
+#ifndef GDBSUPPORT_BTRACE_COMMON_H
+#define GDBSUPPORT_BTRACE_COMMON_H
 
 /* Branch tracing (btrace) is a per-thread control-flow execution trace of the
    inferior.  For presentation purposes, the branch trace is represented as a
@@ -276,4 +276,4 @@ extern const char *btrace_format_short_string (enum btrace_format format);
 extern int btrace_data_append (struct btrace_data *dst,
 			       const struct btrace_data *src);
 
-#endif /* COMMON_BTRACE_COMMON_H */
+#endif /* GDBSUPPORT_BTRACE_COMMON_H */
diff --git a/gdbsupport/byte-vector.h b/gdbsupport/byte-vector.h
index 54f4cc2edf2..0586d40016e 100644
--- a/gdbsupport/byte-vector.h
+++ b/gdbsupport/byte-vector.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_BYTE_VECTOR_H
-#define COMMON_BYTE_VECTOR_H
+#ifndef GDBSUPPORT_BYTE_VECTOR_H
+#define GDBSUPPORT_BYTE_VECTOR_H
 
 #include "gdbsupport/def-vector.h"
 
@@ -60,4 +60,4 @@ using char_vector = gdb::def_vector<char>;
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEF_VECTOR_H */
+#endif /* GDBSUPPORT_BYTE_VECTOR_H */
diff --git a/gdbsupport/cleanups.h b/gdbsupport/cleanups.h
index 985cf81ff7d..12b7774763c 100644
--- a/gdbsupport/cleanups.h
+++ b/gdbsupport/cleanups.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_CLEANUPS_H
-#define COMMON_CLEANUPS_H
+#ifndef GDBSUPPORT_CLEANUPS_H
+#define GDBSUPPORT_CLEANUPS_H
 
 #include <functional>
 
@@ -27,4 +27,4 @@ extern void add_final_cleanup (std::function<void ()> &&func);
 /* Run all the registered functions.  */
 extern void do_final_cleanups ();
 
-#endif /* COMMON_CLEANUPS_H */
+#endif /* GDBSUPPORT_CLEANUPS_H */
diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h
index b41d6a401cc..6c793dc33d4 100644
--- a/gdbsupport/common-debug.h
+++ b/gdbsupport/common-debug.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_DEBUG_H
-#define COMMON_COMMON_DEBUG_H
+#ifndef GDBSUPPORT_COMMON_DEBUG_H
+#define GDBSUPPORT_COMMON_DEBUG_H
 
 #include <optional>
 #include "gdbsupport/preprocessor.h"
@@ -271,4 +271,4 @@ make_scoped_debug_start_end (PT &&pred, const char *module, const char *func,
 				   __func__, "enter", "exit",	\
 				   nullptr)
 
-#endif /* COMMON_COMMON_DEBUG_H */
+#endif /* GDBSUPPORT_COMMON_DEBUG_H */
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index 6120719480b..07315956514 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_DEFS_H
-#define COMMON_COMMON_DEFS_H
+#ifndef GDBSUPPORT_COMMON_DEFS_H
+#define GDBSUPPORT_COMMON_DEFS_H
 
 #include <gdbsupport/config.h>
 
@@ -217,4 +217,4 @@
 #define HAVE_USEFUL_SBRK 1
 #endif
 
-#endif /* COMMON_COMMON_DEFS_H */
+#endif /* GDBSUPPORT_COMMON_DEFS_H */
diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h
index ffc02d2107f..124c41d1acd 100644
--- a/gdbsupport/common-exceptions.h
+++ b/gdbsupport/common-exceptions.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_EXCEPTIONS_H
-#define COMMON_COMMON_EXCEPTIONS_H
+#ifndef GDBSUPPORT_COMMON_EXCEPTIONS_H
+#define GDBSUPPORT_COMMON_EXCEPTIONS_H
 
 #include <setjmp.h>
 #include <new>
@@ -359,4 +359,4 @@ extern void throw_quit (const char *fmt, ...)
 extern void throw_forced_quit (const char *fmt, ...)
      ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
 
-#endif /* COMMON_COMMON_EXCEPTIONS_H */
+#endif /* GDBSUPPORT_COMMON_EXCEPTIONS_H */
diff --git a/gdbsupport/common-gdbthread.h b/gdbsupport/common-gdbthread.h
index d149f8eed41..289cc8f1b30 100644
--- a/gdbsupport/common-gdbthread.h
+++ b/gdbsupport/common-gdbthread.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_GDBTHREAD_H
-#define COMMON_COMMON_GDBTHREAD_H
+#ifndef GDBSUPPORT_COMMON_GDBTHREAD_H
+#define GDBSUPPORT_COMMON_GDBTHREAD_H
 
 struct process_stratum_target;
 
@@ -25,4 +25,4 @@ struct process_stratum_target;
 extern void switch_to_thread (process_stratum_target *proc_target,
 			      ptid_t ptid);
 
-#endif /* COMMON_COMMON_GDBTHREAD_H */
+#endif /* GDBSUPPORT_COMMON_GDBTHREAD_H */
diff --git a/gdbsupport/common-inferior.h b/gdbsupport/common-inferior.h
index bc6afd65f2b..299c159678b 100644
--- a/gdbsupport/common-inferior.h
+++ b/gdbsupport/common-inferior.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_INFERIOR_H
-#define COMMON_COMMON_INFERIOR_H
+#ifndef GDBSUPPORT_COMMON_INFERIOR_H
+#define GDBSUPPORT_COMMON_INFERIOR_H
 
 #include "gdbsupport/array-view.h"
 
@@ -62,4 +62,4 @@ extern bool startup_with_shell;
 extern std::string
 construct_inferior_arguments (gdb::array_view<char * const>);
 
-#endif /* COMMON_COMMON_INFERIOR_H */
+#endif /* GDBSUPPORT_COMMON_INFERIOR_H */
diff --git a/gdbsupport/common-regcache.h b/gdbsupport/common-regcache.h
index f8704c16939..caf4662e7e5 100644
--- a/gdbsupport/common-regcache.h
+++ b/gdbsupport/common-regcache.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_REGCACHE_H
-#define COMMON_COMMON_REGCACHE_H
+#ifndef GDBSUPPORT_COMMON_REGCACHE_H
+#define GDBSUPPORT_COMMON_REGCACHE_H
 
 struct reg_buffer_common;
 
@@ -120,4 +120,4 @@ struct reg_buffer_common
   virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0;
 };
 
-#endif /* COMMON_COMMON_REGCACHE_H */
+#endif /* GDBSUPPORT_COMMON_REGCACHE_H */
diff --git a/gdbsupport/common-types.h b/gdbsupport/common-types.h
index 19d3f49ca0f..10d5f38ae4a 100644
--- a/gdbsupport/common-types.h
+++ b/gdbsupport/common-types.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_TYPES_H
-#define COMMON_COMMON_TYPES_H
+#ifndef GDBSUPPORT_COMMON_TYPES_H
+#define GDBSUPPORT_COMMON_TYPES_H
 
 #include <inttypes.h>
 
@@ -53,4 +53,4 @@ typedef uint64_t ULONGEST;
 
 enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 };
 
-#endif /* COMMON_COMMON_TYPES_H */
+#endif /* GDBSUPPORT_COMMON_TYPES_H */
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 23cd40c0207..42c129b643c 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_COMMON_UTILS_H
-#define COMMON_COMMON_UTILS_H
+#ifndef GDBSUPPORT_COMMON_UTILS_H
+#define GDBSUPPORT_COMMON_UTILS_H
 
 #include <string>
 #include <vector>
@@ -242,4 +242,4 @@ struct string_view_hash
 
 } /* namespace gdb */
 
-#endif /* COMMON_COMMON_UTILS_H */
+#endif /* GDBSUPPORT_COMMON_UTILS_H */
diff --git a/gdbsupport/def-vector.h b/gdbsupport/def-vector.h
index b9aa663c688..3db6a2fedc9 100644
--- a/gdbsupport/def-vector.h
+++ b/gdbsupport/def-vector.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_DEF_VECTOR_H
-#define COMMON_DEF_VECTOR_H
+#ifndef GDBSUPPORT_DEF_VECTOR_H
+#define GDBSUPPORT_DEF_VECTOR_H
 
 #include <vector>
 #include "gdbsupport/default-init-alloc.h"
@@ -33,4 +33,4 @@ template<typename T> using def_vector
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEF_VECTOR_H */
+#endif /* GDBSUPPORT_DEF_VECTOR_H */
diff --git a/gdbsupport/default-init-alloc.h b/gdbsupport/default-init-alloc.h
index 5ed9715b64c..e84110f128a 100644
--- a/gdbsupport/default-init-alloc.h
+++ b/gdbsupport/default-init-alloc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_DEFAULT_INIT_ALLOC_H
-#define COMMON_DEFAULT_INIT_ALLOC_H
+#ifndef GDBSUPPORT_DEFAULT_INIT_ALLOC_H
+#define GDBSUPPORT_DEFAULT_INIT_ALLOC_H
 
 #if __cplusplus >= 202002L
 #include <memory_resource>
@@ -75,4 +75,4 @@ class default_init_allocator : public A
 
 } /* namespace gdb */
 
-#endif /* COMMON_DEFAULT_INIT_ALLOC_H */
+#endif /* GDBSUPPORT_DEFAULT_INIT_ALLOC_H */
diff --git a/gdbsupport/enum-flags.h b/gdbsupport/enum-flags.h
index 50780043477..b2858b83efe 100644
--- a/gdbsupport/enum-flags.h
+++ b/gdbsupport/enum-flags.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ENUM_FLAGS_H
-#define COMMON_ENUM_FLAGS_H
+#ifndef GDBSUPPORT_ENUM_FLAGS_H
+#define GDBSUPPORT_ENUM_FLAGS_H
 
 #include "traits.h"
 
@@ -493,4 +493,4 @@ enum_flags<E>::to_string (const string_mapping (&mapping)[N]) const
 
 #endif /* __cplusplus */
 
-#endif /* COMMON_ENUM_FLAGS_H */
+#endif /* GDBSUPPORT_ENUM_FLAGS_H */
diff --git a/gdbsupport/environ.h b/gdbsupport/environ.h
index e46050b0350..6ac9f75d94e 100644
--- a/gdbsupport/environ.h
+++ b/gdbsupport/environ.h
@@ -14,8 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ENVIRON_H
-#define COMMON_ENVIRON_H
+#ifndef GDBSUPPORT_ENVIRON_H
+#define GDBSUPPORT_ENVIRON_H
 
 #include <vector>
 #include <set>
@@ -100,4 +100,4 @@ class gdb_environ
   std::set<std::string> m_user_unset_env;
 };
 
-#endif /* COMMON_ENVIRON_H */
+#endif /* GDBSUPPORT_ENVIRON_H */
diff --git a/gdbsupport/errors.h b/gdbsupport/errors.h
index d8daed0f5f2..4570221f879 100644
--- a/gdbsupport/errors.h
+++ b/gdbsupport/errors.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_ERRORS_H
-#define COMMON_ERRORS_H
+#ifndef GDBSUPPORT_ERRORS_H
+#define GDBSUPPORT_ERRORS_H
 
 /* A problem was detected, but the requested operation can still
    proceed.  A warning message is constructed using a printf- or
@@ -129,4 +129,4 @@ extern void throw_winerror_with_name (const char *string, ULONGEST err)
 
 #endif /* USE_WIN32API */
 
-#endif /* COMMON_ERRORS_H */
+#endif /* GDBSUPPORT_ERRORS_H */
diff --git a/gdbsupport/event-loop.h b/gdbsupport/event-loop.h
index 9155658e8f9..80f471066c8 100644
--- a/gdbsupport/event-loop.h
+++ b/gdbsupport/event-loop.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef EVENT_LOOP_H
-#define EVENT_LOOP_H
+#ifndef GDBSUPPORT_EVENT_LOOP_H
+#define GDBSUPPORT_EVENT_LOOP_H
 
 /* An event loop listens for events from multiple event sources.  When
    an event arrives, it is queued and processed by calling the
@@ -145,4 +145,4 @@ extern debug_event_loop_kind debug_event_loop;
     } \
   while (0)
 
-#endif /* EVENT_LOOP_H */
+#endif /* GDBSUPPORT_EVENT_LOOP_H */
diff --git a/gdbsupport/event-pipe.h b/gdbsupport/event-pipe.h
index fb5dd3a8833..7262403e267 100644
--- a/gdbsupport/event-pipe.h
+++ b/gdbsupport/event-pipe.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_EVENT_PIPE_H
-#define COMMON_EVENT_PIPE_H
+#ifndef GDBSUPPORT_EVENT_PIPE_H
+#define GDBSUPPORT_EVENT_PIPE_H
 
 /* An event pipe used as a waitable file in the event loop in place of
    some other event associated with a signal.  The handler for the
@@ -57,4 +57,4 @@ class event_pipe
   int m_fds[2] = { -1, -1 };
 };
 
-#endif /* COMMON_EVENT_PIPE_H */
+#endif /* GDBSUPPORT_EVENT_PIPE_H */
diff --git a/gdbsupport/fileio.h b/gdbsupport/fileio.h
index 2e7469d771b..7e4c361d14f 100644
--- a/gdbsupport/fileio.h
+++ b/gdbsupport/fileio.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILEIO_H
-#define COMMON_FILEIO_H
+#ifndef GDBSUPPORT_FILEIO_H
+#define GDBSUPPORT_FILEIO_H
 
 #include <sys/stat.h>
 
@@ -186,4 +186,4 @@ host_to_fileio_time (time_t num, fio_time_t fnum)
 
 extern void host_to_fileio_stat (struct stat *st, struct fio_stat *fst);
 
-#endif /* COMMON_FILEIO_H */
+#endif /* GDBSUPPORT_FILEIO_H */
diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h
index e2ee141d46f..549987bc29c 100644
--- a/gdbsupport/filestuff.h
+++ b/gdbsupport/filestuff.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILESTUFF_H
-#define COMMON_FILESTUFF_H
+#ifndef GDBSUPPORT_FILESTUFF_H
+#define GDBSUPPORT_FILESTUFF_H
 
 #include <dirent.h>
 #include <fcntl.h>
@@ -137,4 +137,4 @@ extern std::optional<std::string> read_text_file_to_string (const char *path);
 
 extern std::string read_remainder_of_file (FILE *file);
 
-#endif /* COMMON_FILESTUFF_H */
+#endif /* GDBSUPPORT_FILESTUFF_H */
diff --git a/gdbsupport/filtered-iterator.h b/gdbsupport/filtered-iterator.h
index 12e5e6cd577..f801f9614da 100644
--- a/gdbsupport/filtered-iterator.h
+++ b/gdbsupport/filtered-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FILTERED_ITERATOR_H
-#define COMMON_FILTERED_ITERATOR_H
+#ifndef GDBSUPPORT_FILTERED_ITERATOR_H
+#define GDBSUPPORT_FILTERED_ITERATOR_H
 
 #include <type_traits>
 
@@ -89,4 +89,4 @@ class filtered_iterator
   BaseIterator m_end {};
 };
 
-#endif /* COMMON_FILTERED_ITERATOR_H */
+#endif /* GDBSUPPORT_FILTERED_ITERATOR_H */
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 68504b4475c..b1f0c46d4c2 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FORMAT_H
-#define COMMON_FORMAT_H
+#ifndef GDBSUPPORT_FORMAT_H
+#define GDBSUPPORT_FORMAT_H
 
 #include <string_view>
 
@@ -101,4 +101,4 @@ class format_pieces
   gdb::unique_xmalloc_ptr<char> m_storage;
 };
 
-#endif /* COMMON_FORMAT_H */
+#endif /* GDBSUPPORT_FORMAT_H */
diff --git a/gdbsupport/forward-scope-exit.h b/gdbsupport/forward-scope-exit.h
index 6dd22722595..d4a3fc00cf8 100644
--- a/gdbsupport/forward-scope-exit.h
+++ b/gdbsupport/forward-scope-exit.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FORWARD_SCOPE_EXIT_H
-#define COMMON_FORWARD_SCOPE_EXIT_H
+#ifndef GDBSUPPORT_FORWARD_SCOPE_EXIT_H
+#define GDBSUPPORT_FORWARD_SCOPE_EXIT_H
 
 #include "gdbsupport/scope-exit.h"
 #include <functional>
@@ -120,4 +120,4 @@ class forward_scope_exit<Function, function, Res (Args...)>
 #define FORWARD_SCOPE_EXIT(FUNC) \
   detail::forward_scope_exit<decltype (FUNC), FUNC, decltype (FUNC)>
 
-#endif /* COMMON_FORWARD_SCOPE_EXIT_H */
+#endif /* GDBSUPPORT_FORWARD_SCOPE_EXIT_H */
diff --git a/gdbsupport/function-view.h b/gdbsupport/function-view.h
index 9d852c2a378..f8262068174 100644
--- a/gdbsupport/function-view.h
+++ b/gdbsupport/function-view.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_FUNCTION_VIEW_H
-#define COMMON_FUNCTION_VIEW_H
+#ifndef GDBSUPPORT_FUNCTION_VIEW_H
+#define GDBSUPPORT_FUNCTION_VIEW_H
 
 /* function_view is a polymorphic type-erasing wrapper class that
    encapsulates a non-owning reference to arbitrary callable objects.
@@ -448,4 +448,4 @@ auto make_function_view (Callable &&callable)
 
 } /* namespace gdb */
 
-#endif
+#endif /* GDBSUPPORT_FUNCTION_VIEW_H */
diff --git a/gdbsupport/gdb-checked-static-cast.h b/gdbsupport/gdb-checked-static-cast.h
index 97843fab225..e8909b9206f 100644
--- a/gdbsupport/gdb-checked-static-cast.h
+++ b/gdbsupport/gdb-checked-static-cast.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_CHECKED_STATIC_CAST_H
-#define COMMON_GDB_CHECKED_STATIC_CAST_H
+#ifndef GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H
+#define GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H
 
 #include "gdbsupport/traits.h"
 
@@ -80,4 +80,4 @@ checked_static_cast (V &v)
 
 }
 
-#endif /* COMMON_GDB_CHECKED_STATIC_CAST_H */
+#endif /* GDBSUPPORT_GDB_CHECKED_STATIC_CAST_H */
diff --git a/gdbsupport/gdb-dlfcn.h b/gdbsupport/gdb-dlfcn.h
index 24481d94e5c..654db794638 100644
--- a/gdbsupport/gdb-dlfcn.h
+++ b/gdbsupport/gdb-dlfcn.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_DLFCN_H
-#define GDB_DLFCN_H
+#ifndef GDBSUPPORT_GDB_DLFCN_H
+#define GDBSUPPORT_GDB_DLFCN_H
 
 /* A deleter that closes an open dynamic library.  */
 
@@ -48,4 +48,4 @@ void *gdb_dlsym (const gdb_dlhandle_up &handle, const char *symbol);
 
 int is_dl_available(void);
 
-#endif /* GDB_DLFCN_H */
+#endif /* GDBSUPPORT_GDB_DLFCN_H */
diff --git a/gdbsupport/gdb-safe-ctype.h b/gdbsupport/gdb-safe-ctype.h
index a91e54a3e65..f8968ef7e7c 100644
--- a/gdbsupport/gdb-safe-ctype.h
+++ b/gdbsupport/gdb-safe-ctype.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_SAFE_CTYPE_H
-#define GDB_SAFE_CTYPE_H
+#ifndef GDBSUPPORT_GDB_SAFE_CTYPE_H
+#define GDBSUPPORT_GDB_SAFE_CTYPE_H
 
 /* After safe-ctype.h is included, we can no longer use the host's
    ctype routines.  Trying to do so results in compile errors.  Code
@@ -46,4 +46,4 @@ gdb_isprint (int ch)
 #include <locale>
 #include "safe-ctype.h"
 
-#endif
+#endif /* GDBSUPPORT_GDB_SAFE_CTYPE_H */
diff --git a/gdbsupport/gdb_assert.h b/gdbsupport/gdb_assert.h
index 2b5e6557424..dd0e1e2286e 100644
--- a/gdbsupport/gdb_assert.h
+++ b/gdbsupport/gdb_assert.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_ASSERT_H
-#define COMMON_GDB_ASSERT_H
+#ifndef GDBSUPPORT_GDB_ASSERT_H
+#define GDBSUPPORT_GDB_ASSERT_H
 
 #include "errors.h"
 
@@ -43,4 +43,4 @@
   internal_error_loc (__FILE__, __LINE__, _("%s: " message), __func__, \
 		      ##__VA_ARGS__)
 
-#endif /* COMMON_GDB_ASSERT_H */
+#endif /* GDBSUPPORT_GDB_ASSERT_H */
diff --git a/gdbsupport/gdb_file.h b/gdbsupport/gdb_file.h
index 645ecb9f75c..41bbbbc51b1 100644
--- a/gdbsupport/gdb_file.h
+++ b/gdbsupport/gdb_file.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDBSUPPORT_GDB_FILE
-#define GDBSUPPORT_GDB_FILE
+#ifndef GDBSUPPORT_GDB_FILE_H
+#define GDBSUPPORT_GDB_FILE_H
 
 #include <memory>
 #include <stdio.h>
@@ -34,4 +34,4 @@ struct gdb_file_deleter
 
 typedef std::unique_ptr<FILE, gdb_file_deleter> gdb_file_up;
 
-#endif
+#endif /* GDBSUPPORT_GDB_FILE_H */
diff --git a/gdbsupport/gdb_locale.h b/gdbsupport/gdb_locale.h
index 58524857879..dcdb064a917 100644
--- a/gdbsupport/gdb_locale.h
+++ b/gdbsupport/gdb_locale.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_LOCALE_H
-#define COMMON_GDB_LOCALE_H
+#ifndef GDBSUPPORT_GDB_LOCALE_H
+#define GDBSUPPORT_GDB_LOCALE_H
 
 #ifdef HAVE_LOCALE_H
 # include <locale.h>
@@ -40,4 +40,4 @@
 #include <langinfo.h>
 #endif
 
-#endif /* COMMON_GDB_LOCALE_H */
+#endif /* GDBSUPPORT_GDB_LOCALE_H */
diff --git a/gdbsupport/gdb_obstack.h b/gdbsupport/gdb_obstack.h
index 7b3bb05bc00..d40182441f8 100644
--- a/gdbsupport/gdb_obstack.h
+++ b/gdbsupport/gdb_obstack.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (GDB_OBSTACK_H)
-#define GDB_OBSTACK_H 1
+#ifndef GDBSUPPORT_GDB_OBSTACK_H
+#define GDBSUPPORT_GDB_OBSTACK_H
 
 #include "obstack.h"
 
@@ -157,4 +157,4 @@ struct allocate_on_obstack
   void operator delete[] (void *memory) {}
 };
 
-#endif
+#endif /* GDBSUPPORT_GDB_OBSTACK_H */
diff --git a/gdbsupport/gdb_proc_service.h b/gdbsupport/gdb_proc_service.h
index 52f77a8a5c5..0009702b978 100644
--- a/gdbsupport/gdb_proc_service.h
+++ b/gdbsupport/gdb_proc_service.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_PROC_SERVICE_H
-#define COMMON_GDB_PROC_SERVICE_H
+#ifndef GDBSUPPORT_GDB_PROC_SERVICE_H
+#define GDBSUPPORT_GDB_PROC_SERVICE_H
 
 #include <sys/types.h>
 
@@ -199,4 +199,4 @@ PS_EXPORT (ps_lsetxregs);
 PS_EXPORT (ps_plog);
 #endif
 
-#endif /* COMMON_GDB_PROC_SERVICE_H */
+#endif /* GDBSUPPORT_GDB_PROC_SERVICE_H */
diff --git a/gdbsupport/gdb_ref_ptr.h b/gdbsupport/gdb_ref_ptr.h
index 8a90cb10b05..df2b3d80815 100644
--- a/gdbsupport/gdb_ref_ptr.h
+++ b/gdbsupport/gdb_ref_ptr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_REF_PTR_H
-#define COMMON_GDB_REF_PTR_H
+#ifndef GDBSUPPORT_GDB_REF_PTR_H
+#define GDBSUPPORT_GDB_REF_PTR_H
 
 #include <cstddef>
 
@@ -225,4 +225,4 @@ inline bool operator!= (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
 
 }
 
-#endif /* COMMON_GDB_REF_PTR_H */
+#endif /* GDBSUPPORT_GDB_REF_PTR_H */
diff --git a/gdbsupport/gdb_regex.h b/gdbsupport/gdb_regex.h
index aeb1bb922a9..76264e5a0c9 100644
--- a/gdbsupport/gdb_regex.h
+++ b/gdbsupport/gdb_regex.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef GDB_REGEX_H
-#define GDB_REGEX_H 1
+#ifndef GDBSUPPORT_GDB_REGEX_H
+#define GDBSUPPORT_GDB_REGEX_H
 
 # include "xregex.h"
 
@@ -54,4 +54,4 @@ class compiled_regex
   regex_t m_pattern;
 };
 
-#endif /* not GDB_REGEX_H */
+#endif /* GDBSUPPORT_GDB_REGEX_H */
diff --git a/gdbsupport/gdb_select.h b/gdbsupport/gdb_select.h
index 9f7350a904a..b229a25478c 100644
--- a/gdbsupport/gdb_select.h
+++ b/gdbsupport/gdb_select.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined(GDB_SELECT_H)
-#define GDB_SELECT_H
+#ifndef GDBSUPPORT_GDB_SELECT_H
+#define GDBSUPPORT_GDB_SELECT_H
 
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
@@ -48,4 +48,4 @@ extern int interruptible_select (int n,
 				 fd_set *exceptfds,
 				 struct timeval *timeout);
 
-#endif /* !defined(GDB_SELECT_H) */
+#endif /* GDBSUPPORT_GDB_SELECT_H */
diff --git a/gdbsupport/gdb_setjmp.h b/gdbsupport/gdb_setjmp.h
index e994226cbea..2482990671d 100644
--- a/gdbsupport/gdb_setjmp.h
+++ b/gdbsupport/gdb_setjmp.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SETJMP_H
-#define COMMON_GDB_SETJMP_H
+#ifndef GDBSUPPORT_GDB_SETJMP_H
+#define GDBSUPPORT_GDB_SETJMP_H
 
 #include <setjmp.h>
 
@@ -33,4 +33,4 @@
 #define SIGLONGJMP(buf,val)	longjmp((buf), (val))
 #endif
 
-#endif /* COMMON_GDB_SETJMP_H */
+#endif /* GDBSUPPORT_GDB_SETJMP_H */
diff --git a/gdbsupport/gdb_signals.h b/gdbsupport/gdb_signals.h
index 7a71f0d8f99..2f9237aea46 100644
--- a/gdbsupport/gdb_signals.h
+++ b/gdbsupport/gdb_signals.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SIGNALS_H
-#define COMMON_GDB_SIGNALS_H
+#ifndef GDBSUPPORT_GDB_SIGNALS_H
+#define GDBSUPPORT_GDB_SIGNALS_H
 
 #include "gdb/signals.h"
 
@@ -55,4 +55,4 @@ extern const char *gdb_signal_to_name (enum gdb_signal);
 /* Given a name (SIGHUP, etc.), return its signal.  */
 enum gdb_signal gdb_signal_from_name (const char *);
 
-#endif /* COMMON_GDB_SIGNALS_H */
+#endif /* GDBSUPPORT_GDB_SIGNALS_H */
diff --git a/gdbsupport/gdb_splay_tree.h b/gdbsupport/gdb_splay_tree.h
index 873ad8e27f3..05be2f1dc4e 100644
--- a/gdbsupport/gdb_splay_tree.h
+++ b/gdbsupport/gdb_splay_tree.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SPLAY_TREE_H
-#define COMMON_GDB_SPLAY_TREE_H
+#ifndef GDBSUPPORT_GDB_SPLAY_TREE_H
+#define GDBSUPPORT_GDB_SPLAY_TREE_H
 
 #include "splay-tree.h"
 
@@ -39,4 +39,4 @@ struct splay_tree_deleter
 typedef std::unique_ptr<splay_tree_s, gdb::splay_tree_deleter>
     gdb_splay_tree_up;
 
-#endif /* COMMON_GDB_SPLAY_TREE_H */
+#endif /* GDBSUPPORT_GDB_SPLAY_TREE_H */
diff --git a/gdbsupport/gdb_sys_time.h b/gdbsupport/gdb_sys_time.h
index 63c93445121..ca93fc8d293 100644
--- a/gdbsupport/gdb_sys_time.h
+++ b/gdbsupport/gdb_sys_time.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_SYS_TIME_H
-#define COMMON_GDB_SYS_TIME_H
+#ifndef GDBSUPPORT_GDB_SYS_TIME_H
+#define GDBSUPPORT_GDB_SYS_TIME_H
 
 #include <sys/time.h>
 
@@ -35,4 +35,4 @@
 # undef gettimeofday
 #endif
 
-#endif /* COMMON_GDB_SYS_TIME_H */
+#endif /* GDBSUPPORT_GDB_SYS_TIME_H */
diff --git a/gdbsupport/gdb_tilde_expand.h b/gdbsupport/gdb_tilde_expand.h
index fbd410dd133..12ae9cc73a7 100644
--- a/gdbsupport/gdb_tilde_expand.h
+++ b/gdbsupport/gdb_tilde_expand.h
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_TILDE_EXPAND_H
-#define COMMON_GDB_TILDE_EXPAND_H
+#ifndef GDBSUPPORT_GDB_TILDE_EXPAND_H
+#define GDBSUPPORT_GDB_TILDE_EXPAND_H
 
 /* Perform tilde expansion on DIR, and return the full path.  */
 extern std::string gdb_tilde_expand (const char *dir);
 
-#endif /* COMMON_GDB_TILDE_EXPAND_H */
+#endif /* GDBSUPPORT_GDB_TILDE_EXPAND_H */
diff --git a/gdbsupport/gdb_unique_ptr.h b/gdbsupport/gdb_unique_ptr.h
index 19b1581dab5..a40e1b133da 100644
--- a/gdbsupport/gdb_unique_ptr.h
+++ b/gdbsupport/gdb_unique_ptr.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_UNIQUE_PTR_H
-#define COMMON_GDB_UNIQUE_PTR_H
+#ifndef GDBSUPPORT_GDB_UNIQUE_PTR_H
+#define GDBSUPPORT_GDB_UNIQUE_PTR_H
 
 #include <memory>
 #include <string>
@@ -93,4 +93,4 @@ operator+ (const std::string &lhs, const gdb::unique_xmalloc_ptr<char> &rhs)
   return lhs + rhs.get ();
 }
 
-#endif /* COMMON_GDB_UNIQUE_PTR_H */
+#endif /* GDBSUPPORT_GDB_UNIQUE_PTR_H */
diff --git a/gdbsupport/gdb_unlinker.h b/gdbsupport/gdb_unlinker.h
index 2da65fe45e8..2b9044290fe 100644
--- a/gdbsupport/gdb_unlinker.h
+++ b/gdbsupport/gdb_unlinker.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_UNLINKER_H
-#define COMMON_GDB_UNLINKER_H
+#ifndef GDBSUPPORT_GDB_UNLINKER_H
+#define GDBSUPPORT_GDB_UNLINKER_H
 
 namespace gdb
 {
@@ -57,4 +57,4 @@ class unlinker
 
 }
 
-#endif /* COMMON_GDB_UNLINKER_H */
+#endif /* GDBSUPPORT_GDB_UNLINKER_H */
diff --git a/gdbsupport/gdb_vecs.h b/gdbsupport/gdb_vecs.h
index 47083cead38..22c165c8a55 100644
--- a/gdbsupport/gdb_vecs.h
+++ b/gdbsupport/gdb_vecs.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_VECS_H
-#define COMMON_GDB_VECS_H
+#ifndef GDBSUPPORT_GDB_VECS_H
+#define GDBSUPPORT_GDB_VECS_H
 
 /* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
 
@@ -85,4 +85,4 @@ ordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
   return removed;
 }
 
-#endif /* COMMON_GDB_VECS_H */
+#endif /* GDBSUPPORT_GDB_VECS_H */
diff --git a/gdbsupport/gdb_wait.h b/gdbsupport/gdb_wait.h
index c6348dbcb1c..590dcea6a12 100644
--- a/gdbsupport/gdb_wait.h
+++ b/gdbsupport/gdb_wait.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_GDB_WAIT_H
-#define COMMON_GDB_WAIT_H
+#ifndef GDBSUPPORT_GDB_WAIT_H
+#define GDBSUPPORT_GDB_WAIT_H
 
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
@@ -128,4 +128,4 @@ extern int windows_status_to_termsig (unsigned long);
 #define __WCLONE	0x80000000 /* Wait for cloned process.  */
 #endif
 
-#endif /* COMMON_GDB_WAIT_H */
+#endif /* GDBSUPPORT_GDB_WAIT_H */
diff --git a/gdbsupport/hash_enum.h b/gdbsupport/hash_enum.h
index 5ef0e15c9ff..5771686dc1d 100644
--- a/gdbsupport/hash_enum.h
+++ b/gdbsupport/hash_enum.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_HASH_ENUM_H
-#define COMMON_HASH_ENUM_H
+#ifndef GDBSUPPORT_HASH_ENUM_H
+#define GDBSUPPORT_HASH_ENUM_H
 
 /* A hasher for enums, which was missing in C++11:
     http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148
@@ -42,4 +42,4 @@ struct hash_enum
 
 } /* namespace gdb */
 
-#endif /* COMMON_HASH_ENUM_H */
+#endif /* GDBSUPPORT_HASH_ENUM_H */
diff --git a/gdbsupport/host-defs.h b/gdbsupport/host-defs.h
index 6e7a08524f9..5298089ba15 100644
--- a/gdbsupport/host-defs.h
+++ b/gdbsupport/host-defs.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_HOST_DEFS_H
-#define COMMON_HOST_DEFS_H
+#ifndef GDBSUPPORT_HOST_DEFS_H
+#define GDBSUPPORT_HOST_DEFS_H
 
 #include <limits.h>
 
@@ -58,4 +58,4 @@
 #define SLASH_STRING "/"
 #endif
 
-#endif /* COMMON_HOST_DEFS_H */
+#endif /* GDBSUPPORT_HOST_DEFS_H */
diff --git a/gdbsupport/job-control.h b/gdbsupport/job-control.h
index 977276d95ce..2b99d69d2bb 100644
--- a/gdbsupport/job-control.h
+++ b/gdbsupport/job-control.h
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_JOB_CONTROL_H
-#define COMMON_JOB_CONTROL_H
+#ifndef GDBSUPPORT_JOB_CONTROL_H
+#define GDBSUPPORT_JOB_CONTROL_H
 
 /* Do we have job control?  Can be assumed to always be the same
    within a given run of GDB.  Use in gdb/inflow.c and
@@ -35,4 +35,4 @@ extern int gdb_setpgid ();
    JOB_CONTROL.  */
 extern void have_job_control ();
 
-#endif /* COMMON_JOB_CONTROL_H */
+#endif /* GDBSUPPORT_JOB_CONTROL_H */
diff --git a/gdbsupport/netstuff.h b/gdbsupport/netstuff.h
index f0df5fe7671..ae8f9bbd9da 100644
--- a/gdbsupport/netstuff.h
+++ b/gdbsupport/netstuff.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_NETSTUFF_H
-#define COMMON_NETSTUFF_H
+#ifndef GDBSUPPORT_NETSTUFF_H
+#define GDBSUPPORT_NETSTUFF_H
 
 #include <string>
 
@@ -73,4 +73,4 @@ extern parsed_connection_spec
 extern parsed_connection_spec parse_connection_spec (const char *spec,
 						     struct addrinfo *hint);
 
-#endif /* COMMON_NETSTUFF_H */
+#endif /* GDBSUPPORT_NETSTUFF_H */
diff --git a/gdbsupport/next-iterator.h b/gdbsupport/next-iterator.h
index 772083482ee..6bacb58752a 100644
--- a/gdbsupport/next-iterator.h
+++ b/gdbsupport/next-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_NEXT_ITERATOR_H
-#define COMMON_NEXT_ITERATOR_H
+#ifndef GDBSUPPORT_NEXT_ITERATOR_H
+#define GDBSUPPORT_NEXT_ITERATOR_H
 
 #include "gdbsupport/iterator-range.h"
 
@@ -77,4 +77,4 @@ struct next_iterator
 template <typename T>
 using next_range = iterator_range<next_iterator<T>>;
 
-#endif /* COMMON_NEXT_ITERATOR_H */
+#endif /* GDBSUPPORT_NEXT_ITERATOR_H */
diff --git a/gdbsupport/observable.h b/gdbsupport/observable.h
index 41e0ba385c9..b386bbcee29 100644
--- a/gdbsupport/observable.h
+++ b/gdbsupport/observable.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_OBSERVABLE_H
-#define COMMON_OBSERVABLE_H
+#ifndef GDBSUPPORT_OBSERVABLE_H
+#define GDBSUPPORT_OBSERVABLE_H
 
 #include <algorithm>
 #include <functional>
@@ -248,4 +248,4 @@ class observable
 
 } /* namespace gdb */
 
-#endif /* COMMON_OBSERVABLE_H */
+#endif /* GDBSUPPORT_OBSERVABLE_H */
diff --git a/gdbsupport/offset-type.h b/gdbsupport/offset-type.h
index 256703cab4d..181e224253e 100644
--- a/gdbsupport/offset-type.h
+++ b/gdbsupport/offset-type.h
@@ -45,8 +45,8 @@
 
    However, unlike pointers, you can't deference offset types.  */
 
-#ifndef COMMON_OFFSET_TYPE_H
-#define COMMON_OFFSET_TYPE_H
+#ifndef GDBSUPPORT_OFFSET_TYPE_H
+#define GDBSUPPORT_OFFSET_TYPE_H
 
 /* Declare TYPE as being an offset type.  This declares the type and
    enables the operators defined below.  */
@@ -130,4 +130,4 @@ operator- (E lhs, E rhs)
   return static_cast<underlying> (lhs) - static_cast<underlying> (rhs);
 }
 
-#endif /* COMMON_OFFSET_TYPE_H */
+#endif /* GDBSUPPORT_OFFSET_TYPE_H */
diff --git a/gdbsupport/packed.h b/gdbsupport/packed.h
index 5c817d4c9cc..37f02d26373 100644
--- a/gdbsupport/packed.h
+++ b/gdbsupport/packed.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PACKED_H
-#define PACKED_H
+#ifndef GDBSUPPORT_PACKED_H
+#define GDBSUPPORT_PACKED_H
 
 #include "traits.h"
 #include <atomic>
@@ -163,4 +163,4 @@ PACKED_ATOMIC_OP (<=)
 
 #undef PACKED_ATOMIC_OP
 
-#endif
+#endif /* GDBSUPPORT_PACKED_H */
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
index 170a2c5e724..fc516505017 100644
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PATHSTUFF_H
-#define COMMON_PATHSTUFF_H
+#ifndef GDBSUPPORT_PATHSTUFF_H
+#define GDBSUPPORT_PATHSTUFF_H
 
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/array-view.h"
@@ -162,4 +162,4 @@ extern gdb::char_vector make_temp_filename (const std::string &f);
 /* String containing the current directory (what getwd would return).  */
 extern char *current_directory;
 
-#endif /* COMMON_PATHSTUFF_H */
+#endif /* GDBSUPPORT_PATHSTUFF_H */
diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h
index 7b4f8e8a178..66f0fcf53b8 100644
--- a/gdbsupport/poison.h
+++ b/gdbsupport/poison.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_POISON_H
-#define COMMON_POISON_H
+#ifndef GDBSUPPORT_POISON_H
+#define GDBSUPPORT_POISON_H
 
 #include "traits.h"
 #include "obstack.h"
@@ -237,4 +237,4 @@ non-POD data type.");
 #undef XOBNEWVEC
 #define XOBNEWVEC(O, T, N) xobnewvec<T> (O, N)
 
-#endif /* COMMON_POISON_H */
+#endif /* GDBSUPPORT_POISON_H */
diff --git a/gdbsupport/preprocessor.h b/gdbsupport/preprocessor.h
index 96b3b94bf35..23177d5d82e 100644
--- a/gdbsupport/preprocessor.h
+++ b/gdbsupport/preprocessor.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PREPROCESSOR_H
-#define COMMON_PREPROCESSOR_H
+#ifndef GDBSUPPORT_PREPROCESSOR_H
+#define GDBSUPPORT_PREPROCESSOR_H
 
 /* Generally useful preprocessor bits.  */
 
@@ -32,4 +32,4 @@
    includes commas to another macro.  */
 #define ESC_PARENS(...) __VA_ARGS__
 
-#endif /* COMMON_PREPROCESSOR_H */
+#endif /* GDBSUPPORT_PREPROCESSOR_H */
diff --git a/gdbsupport/print-utils.h b/gdbsupport/print-utils.h
index 510cc63bc89..9b915acb8e3 100644
--- a/gdbsupport/print-utils.h
+++ b/gdbsupport/print-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PRINT_UTILS_H
-#define COMMON_PRINT_UTILS_H
+#ifndef GDBSUPPORT_PRINT_UTILS_H
+#define GDBSUPPORT_PRINT_UTILS_H
 
 /* How many characters (including the terminating null byte) fit in a
    cell.  */
@@ -82,4 +82,4 @@ extern const char *host_address_to_string_1 (const void *addr);
 
 extern char *get_print_cell (void);
 
-#endif /* COMMON_PRINT_UTILS_H */
+#endif /* GDBSUPPORT_PRINT_UTILS_H */
diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h
index fef9749ee80..f502efe7484 100644
--- a/gdbsupport/ptid.h
+++ b/gdbsupport/ptid.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_PTID_H
-#define COMMON_PTID_H
+#ifndef GDBSUPPORT_PTID_H
+#define GDBSUPPORT_PTID_H
 
 /* The ptid struct is a collection of the various "ids" necessary for
    identifying the inferior process/thread being debugged.  This
@@ -182,4 +182,4 @@ extern const ptid_t null_ptid;
 
 extern const ptid_t minus_one_ptid;
 
-#endif /* COMMON_PTID_H */
+#endif /* GDBSUPPORT_PTID_H */
diff --git a/gdbsupport/refcounted-object.h b/gdbsupport/refcounted-object.h
index 9cdf0f10729..42bf71a0309 100644
--- a/gdbsupport/refcounted-object.h
+++ b/gdbsupport/refcounted-object.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_REFCOUNTED_OBJECT_H
-#define COMMON_REFCOUNTED_OBJECT_H
+#ifndef GDBSUPPORT_REFCOUNTED_OBJECT_H
+#define GDBSUPPORT_REFCOUNTED_OBJECT_H
 
 /* Base class of intrusively reference-countable objects.
    Incrementing and decrementing the reference count is an external
@@ -84,4 +84,4 @@ struct refcounted_object_delete_ref_policy
   }
 };
 
-#endif /* COMMON_REFCOUNTED_OBJECT_H */
+#endif /* GDBSUPPORT_REFCOUNTED_OBJECT_H */
diff --git a/gdbsupport/rsp-low.h b/gdbsupport/rsp-low.h
index 801df0ebc0c..e91c79e822f 100644
--- a/gdbsupport/rsp-low.h
+++ b/gdbsupport/rsp-low.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_RSP_LOW_H
-#define COMMON_RSP_LOW_H
+#ifndef GDBSUPPORT_RSP_LOW_H
+#define GDBSUPPORT_RSP_LOW_H
 
 /* Convert number NIB to a hex digit.  */
 
@@ -81,4 +81,4 @@ extern int remote_escape_output (const gdb_byte *buffer, int len_units,
 extern int remote_unescape_input (const gdb_byte *buffer, int len,
 				  gdb_byte *out_buf, int out_maxlen);
 
-#endif /* COMMON_RSP_LOW_H */
+#endif /* GDBSUPPORT_RSP_LOW_H */
diff --git a/gdbsupport/run-time-clock.h b/gdbsupport/run-time-clock.h
index 8176151add9..f4328543945 100644
--- a/gdbsupport/run-time-clock.h
+++ b/gdbsupport/run-time-clock.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_RUN_TIME_CLOCK_H
-#define COMMON_RUN_TIME_CLOCK_H
+#ifndef GDBSUPPORT_RUN_TIME_CLOCK_H
+#define GDBSUPPORT_RUN_TIME_CLOCK_H
 
 #include <chrono>
 
@@ -72,4 +72,4 @@ struct run_time_clock
 		   system_cpu_time_clock::time_point &system) noexcept;
 };
 
-#endif /* COMMON_RUN_TIME_CLOCK_H */
+#endif /* GDBSUPPORT_RUN_TIME_CLOCK_H */
diff --git a/gdbsupport/safe-iterator.h b/gdbsupport/safe-iterator.h
index f69f3896758..f31f92f6c24 100644
--- a/gdbsupport/safe-iterator.h
+++ b/gdbsupport/safe-iterator.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SAFE_ITERATOR_H
-#define COMMON_SAFE_ITERATOR_H
+#ifndef GDBSUPPORT_SAFE_ITERATOR_H
+#define GDBSUPPORT_SAFE_ITERATOR_H
 
 #include <type_traits>
 
@@ -136,4 +136,4 @@ class basic_safe_range
   Range m_range;
 };
 
-#endif /* COMMON_SAFE_ITERATOR_H */
+#endif /* GDBSUPPORT_SAFE_ITERATOR_H */
diff --git a/gdbsupport/scope-exit.h b/gdbsupport/scope-exit.h
index 86b2969f817..c3d27d7c77a 100644
--- a/gdbsupport/scope-exit.h
+++ b/gdbsupport/scope-exit.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPE_EXIT_H
-#define COMMON_SCOPE_EXIT_H
+#ifndef GDBSUPPORT_SCOPE_EXIT_H
+#define GDBSUPPORT_SCOPE_EXIT_H
 
 #include <functional>
 #include <type_traits>
@@ -165,4 +165,4 @@ operator+ (scope_exit_lhs, EF &&rhs)
 #define SCOPE_EXIT \
   auto CONCAT(scope_exit_, __LINE__) = ::detail::scope_exit_lhs () + [&] ()
 
-#endif /* COMMON_SCOPE_EXIT_H */
+#endif /* GDBSUPPORT_SCOPE_EXIT_H */
diff --git a/gdbsupport/scoped_fd.h b/gdbsupport/scoped_fd.h
index aa214b2c1c1..240685a927b 100644
--- a/gdbsupport/scoped_fd.h
+++ b/gdbsupport/scoped_fd.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_FD_H
-#define COMMON_SCOPED_FD_H
+#ifndef GDBSUPPORT_SCOPED_FD_H
+#define GDBSUPPORT_SCOPED_FD_H
 
 #include <unistd.h>
 #include "gdb_file.h"
@@ -84,4 +84,4 @@ class scoped_fd
   int m_fd;
 };
 
-#endif /* COMMON_SCOPED_FD_H */
+#endif /* GDBSUPPORT_SCOPED_FD_H */
diff --git a/gdbsupport/scoped_ignore_signal.h b/gdbsupport/scoped_ignore_signal.h
index 74fc69057a8..2fecd58466d 100644
--- a/gdbsupport/scoped_ignore_signal.h
+++ b/gdbsupport/scoped_ignore_signal.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_IGNORE_SIGNAL_H
-#define SCOPED_IGNORE_SIGNAL_H
+#ifndef GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H
+#define GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H
 
 #include <signal.h>
 
@@ -118,4 +118,4 @@ using scoped_ignore_sigpipe = scoped_ignore_signal<SIGPIPE, true>;
 using scoped_ignore_sigpipe = scoped_ignore_signal_nop;
 #endif
 
-#endif /* SCOPED_IGNORE_SIGNAL_H */
+#endif /* GDBSUPPORT_SCOPED_IGNORE_SIGNAL_H */
diff --git a/gdbsupport/scoped_ignore_sigttou.h b/gdbsupport/scoped_ignore_sigttou.h
index de2e40a6492..bb4e86d5b21 100644
--- a/gdbsupport/scoped_ignore_sigttou.h
+++ b/gdbsupport/scoped_ignore_sigttou.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef SCOPED_IGNORE_SIGTTOU_H
-#define SCOPED_IGNORE_SIGTTOU_H
+#ifndef GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H
+#define GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H
 
 #include "gdbsupport/scoped_ignore_signal.h"
 #include "gdbsupport/job-control.h"
@@ -84,4 +84,4 @@ using scoped_ignore_sigttou = scoped_ignore_signal_nop;
 
 #endif
 
-#endif /* SCOPED_IGNORE_SIGTTOU_H */
+#endif /* GDBSUPPORT_SCOPED_IGNORE_SIGTTOU_H */
diff --git a/gdbsupport/scoped_mmap.h b/gdbsupport/scoped_mmap.h
index 8383b8933b5..ea2f4fd3af5 100644
--- a/gdbsupport/scoped_mmap.h
+++ b/gdbsupport/scoped_mmap.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_MMAP_H
-#define COMMON_SCOPED_MMAP_H
+#ifndef GDBSUPPORT_SCOPED_MMAP_H
+#define GDBSUPPORT_SCOPED_MMAP_H
 
 #ifdef HAVE_SYS_MMAN_H
 
@@ -88,4 +88,4 @@ scoped_mmap mmap_file (const char *filename);
 
 #endif /* HAVE_SYS_MMAN_H */
 
-#endif /* COMMON_SCOPED_MMAP_H */
+#endif /* GDBSUPPORT_SCOPED_MMAP_H */
diff --git a/gdbsupport/scoped_restore.h b/gdbsupport/scoped_restore.h
index 96fe5256f80..5833b928fe3 100644
--- a/gdbsupport/scoped_restore.h
+++ b/gdbsupport/scoped_restore.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SCOPED_RESTORE_H
-#define COMMON_SCOPED_RESTORE_H
+#ifndef GDBSUPPORT_SCOPED_RESTORE_H
+#define GDBSUPPORT_SCOPED_RESTORE_H
 
 /* Base class for scoped_restore_tmpl.  */
 class scoped_restore_base
@@ -115,4 +115,4 @@ scoped_restore_tmpl<T> make_scoped_restore (T *var, T2 value)
   return scoped_restore_tmpl<T> (var, value);
 }
 
-#endif /* COMMON_SCOPED_RESTORE_H */
+#endif /* GDBSUPPORT_SCOPED_RESTORE_H */
diff --git a/gdbsupport/search.h b/gdbsupport/search.h
index 42a9fd23083..f8c003bf6df 100644
--- a/gdbsupport/search.h
+++ b/gdbsupport/search.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SEARCH_H
-#define COMMON_SEARCH_H
+#ifndef GDBSUPPORT_SEARCH_H
+#define GDBSUPPORT_SEARCH_H
 
 #include "gdbsupport/function-view.h"
 
@@ -39,4 +39,4 @@ extern int simple_search_memory
    ULONGEST pattern_len,
    CORE_ADDR *found_addrp);
 
-#endif /* COMMON_SEARCH_H */
+#endif /* GDBSUPPORT_SEARCH_H */
diff --git a/gdbsupport/selftest.h b/gdbsupport/selftest.h
index 41d1210a5a5..cbbdd01093d 100644
--- a/gdbsupport/selftest.h
+++ b/gdbsupport/selftest.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SELFTEST_H
-#define COMMON_SELFTEST_H
+#ifndef GDBSUPPORT_SELFTEST_H
+#define GDBSUPPORT_SELFTEST_H
 
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/function-view.h"
@@ -93,4 +93,4 @@ extern void reset ();
       error (_("self-test failed at %s:%d"), __FILE__, __LINE__);	\
   } while (0)
 
-#endif /* COMMON_SELFTEST_H */
+#endif /* GDBSUPPORT_SELFTEST_H */
diff --git a/gdbsupport/signals-state-save-restore.h b/gdbsupport/signals-state-save-restore.h
index 132aaa8c522..e01ac36fe99 100644
--- a/gdbsupport/signals-state-save-restore.h
+++ b/gdbsupport/signals-state-save-restore.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SIGNALS_STATE_SAVE_RESTORE_H
-#define COMMON_SIGNALS_STATE_SAVE_RESTORE_H
+#ifndef GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H
+#define GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H
 
 /* Save/restore the signal actions of all signals, and the signal
    mask.
@@ -37,4 +37,4 @@ extern void save_original_signals_state (bool quiet);
 
 extern void restore_original_signals_state (void);
 
-#endif /* COMMON_SIGNALS_STATE_SAVE_RESTORE_H */
+#endif /* GDBSUPPORT_SIGNALS_STATE_SAVE_RESTORE_H */
diff --git a/gdbsupport/symbol.h b/gdbsupport/symbol.h
index 3e1dc9d29d3..de439c07179 100644
--- a/gdbsupport/symbol.h
+++ b/gdbsupport/symbol.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_SYMBOL_H
-#define COMMON_SYMBOL_H
+#ifndef GDBSUPPORT_SYMBOL_H
+#define GDBSUPPORT_SYMBOL_H
 
 struct objfile;
 
@@ -34,4 +34,4 @@ struct objfile;
 extern int find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
 					struct objfile *objfile);
 
-#endif /* COMMON_SYMBOL_H */
+#endif /* GDBSUPPORT_SYMBOL_H */
diff --git a/gdbsupport/tdesc.h b/gdbsupport/tdesc.h
index fa9431b5b65..dc2d45278d1 100644
--- a/gdbsupport/tdesc.h
+++ b/gdbsupport/tdesc.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_TDESC_H
-#define COMMON_TDESC_H
+#ifndef GDBSUPPORT_TDESC_H
+#define GDBSUPPORT_TDESC_H
 
 struct tdesc_feature;
 struct tdesc_type;
@@ -462,4 +462,4 @@ class print_xml_feature : public tdesc_element_visitor
   int m_depth;
 };
 
-#endif /* COMMON_TDESC_H */
+#endif /* GDBSUPPORT_TDESC_H */
diff --git a/gdbsupport/traits.h b/gdbsupport/traits.h
index 92fe59f34af..600f89ede65 100644
--- a/gdbsupport/traits.h
+++ b/gdbsupport/traits.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_TRAITS_H
-#define COMMON_TRAITS_H
+#ifndef GDBSUPPORT_TRAITS_H
+#define GDBSUPPORT_TRAITS_H
 
 #include <type_traits>
 
@@ -143,4 +143,4 @@ template<typename Condition>
 using Requires = typename std::enable_if<Condition::value, void>::type;
 }
 
-#endif /* COMMON_TRAITS_H */
+#endif /* GDBSUPPORT_TRAITS_H */
diff --git a/gdbsupport/underlying.h b/gdbsupport/underlying.h
index d9c5696a4cd..a3e7e3fca85 100644
--- a/gdbsupport/underlying.h
+++ b/gdbsupport/underlying.h
@@ -15,8 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_UNDERLYING_H
-#define COMMON_UNDERLYING_H
+#ifndef GDBSUPPORT_UNDERLYING_H
+#define GDBSUPPORT_UNDERLYING_H
 
 #include <type_traits>
 
@@ -29,4 +29,4 @@ to_underlying (E val) noexcept
   return static_cast<typename std::underlying_type<E>::type> (val);
 }
 
-#endif
+#endif /* GDBSUPPORT_UNDERLYING_H */
diff --git a/gdbsupport/valid-expr.h b/gdbsupport/valid-expr.h
index 6d2b481c6e1..ef51958dc09 100644
--- a/gdbsupport/valid-expr.h
+++ b/gdbsupport/valid-expr.h
@@ -23,8 +23,8 @@
    right type.  This is mainly used to verify that some utility's API
    is really as safe as intended.  */
 
-#ifndef COMMON_VALID_EXPR_H
-#define COMMON_VALID_EXPR_H
+#ifndef GDBSUPPORT_VALID_EXPR_H
+#define GDBSUPPORT_VALID_EXPR_H
 
 #include "gdbsupport/preprocessor.h"
 #include "gdbsupport/traits.h"
@@ -108,4 +108,4 @@
 			ESC_PARENS (T1, T2, T3, T4, T5, T6),		\
 			VALID, EXPR_TYPE, EXPR)
 
-#endif /* COMMON_VALID_EXPR_H */
+#endif /* GDBSUPPORT_VALID_EXPR_H */
diff --git a/gdbsupport/version.h b/gdbsupport/version.h
index 7c60a963919..052d613d47e 100644
--- a/gdbsupport/version.h
+++ b/gdbsupport/version.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_VERSION_H
-#define COMMON_VERSION_H
+#ifndef GDBSUPPORT_VERSION_H
+#define GDBSUPPORT_VERSION_H
 
 /* Version number of GDB, as a string.  */
 extern const char version[];
@@ -28,4 +28,4 @@ extern const char host_name[];
 /* Canonical target name as a string.  */
 extern const char target_name[];
 
-#endif /* COMMON_VERSION_H */
+#endif /* GDBSUPPORT_VERSION_H */
diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h
index 89c1143fbe1..ed8aeccece2 100644
--- a/gdbsupport/x86-xstate.h
+++ b/gdbsupport/x86-xstate.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_X86_XSTATE_H
-#define COMMON_X86_XSTATE_H
+#ifndef GDBSUPPORT_X86_XSTATE_H
+#define GDBSUPPORT_X86_XSTATE_H
 
 /* The extended state feature IDs in the state component bitmap.  */
 #define X86_XSTATE_X87_ID	0
@@ -120,4 +120,4 @@ constexpr bool operator!= (const x86_xsave_layout &lhs,
 
 #define I387_MXCSR_INIT_VAL 0x1f80
 
-#endif /* COMMON_X86_XSTATE_H */
+#endif /* GDBSUPPORT_X86_XSTATE_H */
diff --git a/gdbsupport/xml-utils.h b/gdbsupport/xml-utils.h
index c1f21b9b8ec..d68f4c98018 100644
--- a/gdbsupport/xml-utils.h
+++ b/gdbsupport/xml-utils.h
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_XML_UTILS_H
-#define COMMON_XML_UTILS_H
+#ifndef GDBSUPPORT_XML_UTILS_H
+#define GDBSUPPORT_XML_UTILS_H
 
 /* Return a string with special characters from TEXT replaced by entity
    references.  */
@@ -40,4 +40,4 @@ extern void xml_escape_text_append (std::string &result, const char *text);
 void string_xml_appendf (std::string &buffer, const char *format, ...)
   ATTRIBUTE_PRINTF (2, 3);
 
-#endif /* COMMON_XML_UTILS_H */
+#endif /* GDBSUPPORT_XML_UTILS_H */

-- 
2.43.0


^ permalink raw reply	[relevance 1%]

* Re: [PATCH] gdb/doc: use silent-rules.mk in the Makefile
  @ 2024-04-17 21:00 12%                 ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-04-17 21:00 UTC (permalink / raw)
  To: Simon Marchi, Eli Zaretskii; +Cc: gdb-patches

Simon Marchi <simark@simark.ca> writes:

> On 2024-04-16 04:47, Andrew Burgess wrote:
>> Andrew Burgess <aburgess@redhat.com> writes:
>> 
>>> Simon Marchi <simark@simark.ca> writes:
>>>
>>>> On 4/15/24 9:55 AM, Andrew Burgess wrote:
>>>>> Eli Zaretskii <eliz@gnu.org> writes:
>>>>>> So my preference would be for having the above emit something like the
>>>>>> below instead
>>>>>>
>>>>>>   TEXI2POD gdb.pod
>>>>>>   POD2MAN1 gdb.1
>>>>>
>>>>> That one's harder.  The target information comes from make's $@
>>>>> variable, so it's easy enough to do:
>>>>>
>>>>>   TEXI2POD gdb.1
>>>>>   POD2MAN  gdb.1
>>>>>
>>>>> which isn't exactly what you asked for.
>>>>
>>>> Could you split the rule in two?  One rule generating gdb.pod and one
>>>> rule generating gdb.1.
>>>>
>>>> I personally think the original output from Andrew's patch is fine.  In
>>>> the silent mode, all I need to know is that make is currently working on
>>>> getting gdb.1 generated.  The intermediary gdb.pod file is an
>>>> implementation detail of the rule.  If I want to see it, then I'll use
>>>> `make V=1`.
>>>
>>> I agree.
>>>
>>>> But if it makes everyone happy, I don't mind if we split the rule in
>>>> two.  Smaller and simpler rules are easier to understand.
>>>
>>> I didn't really want to split the rule as the .pod really is an
>>> intermediate step:
>>>
>>> 	$(SILENCE) touch $@
>>> 	-$(ECHO_TEXI2POD) $(TEXI2POD) $(MANCONF) -Dgdb < $(srcdir)/gdb.texinfo > gdb.pod
>>> 	-$(ECHO_TEXI2MAN) ($(POD2MAN1) gdb.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
>>> 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
>>> 	$(SILENCE) rm -f gdb.pod
>>>
>>> We create the .pod and then consume it, before finally deleting it.
>>>
>>> If the rule was split then we'd end up creating the .pod in one rule
>>> before deleting it in another, which didn't seem great.  But if you're
>>> happy with that change then I can split the rule.
>
> We could maybe just not remove the intermediary pod files (but remove
> them in the clean target, of course)?  They probably don't take that
> much space in the build.
>
> I think your version with the split rules is fine, it fits well the
> make model.
>
>> 
>> Below is a reworked patch which splits the man page and .pod creation.
>> 
>> Let me know what you think.
>> 
>> Thanks,
>> Andrew
>> 
>> ---
>> 
>> commit 1b0c9eb959212f175092da0e200811ba47f2000f
>> Author: Andrew Burgess <aburgess@redhat.com>
>> Date:   Fri Apr 12 17:47:20 2024 +0100
>> 
>>     gdb/doc: use silent-rules.mk in the Makefile
>>     
>>     Make use of silent-rules.mk when building the GDB docs.
>>     
>>     During review it was requested that there be more specific rules than
>>     just reusing the general 'GEN' rule everywhere in the doc/ directory,
>>     so I've added:
>>     
>>       ECHO_DVIPS =    @echo "  DVIPS    $@";
>>       ECHO_TEX =      @echo "  TEX      $@";
>>       ECHO_PDFTEX =   @echo "  PDFTEX   $@";
>>       ECHO_TEXI2DVI = @echo "  TEXI2DVI $@";
>>       ECHO_MAKEHTML = @echo "  MAKEHTML $@";
>>       ECHO_TEXI2POD = @echo "  TEXI2POD $@";
>>       ECHO_TEXI2MAN = @echo "  TEXI2MAN $@";
>>       ECHO_MAKEINFO = @echo "  MAKEINFO $@";
>>     
>>     Then I've made use of these new silent rules and added lots of uses of
>>     SILENT to reduce additional clutter.
>>     
>>     As the man page generation is done in two phases, first the creation
>>     of a .pod file, then the creation of the final man page file, I've
>>     restructured the man page rules.  Previously we had one rule for each
>>     of the 5 man pages.  I now have one general rule that will generate
>>     all of the 5 .pod files, then I have two rules that convert the .pod
>>     files into the final man pages.
>>     
>>     I needed two rules for the man page generation as some man pages match
>>     %.1 and some match %.5.  I could combine these by using the GNU Make
>>     .SECONDARYEXPANSION extension, but I'm not sure if we are OK to depend
>>     on GNU only Make features, and having the two separate rules seems
>>     clear enough.
>
> We do require GNU make already:
>
>   https://sourceware.org/gdb/current/onlinedocs/gdb.html/Requirements.html#Requirements
>
> But I have to admit that a using things like .SECONDARYEXPANSION is
> above my make skill level :).

Good to know.  I looked again at .SECONDARYEXPANSION and in the end I
figured it was probably less clear than what I've got now, so I'm not
going to use it I think.

>
>>     
>>     I've also added a new SILENT_QUIET_FLAG to silent-rules.mk, this is
>>     like SILENT_FLAG, but is set to '-q' when in silent mode, this can be
>>     used with the 'dvips' and 'texi2dvi' commands, both of which use '-q'
>>     to mean: only report errors.
>
> Maybe name this one SILENT_Q_FLAG?  SILENT_QUIET_FLAG would be for
> "--quiet" or "-quiet".

Done.

>
>>     As with the rest of the GDB makefiles, I've only converted the
>>     "generation" rules to use silent-rules.mk, the install / uninstall
>>     rules are left unchanged.
>>     
>>     There are still a few "generation" targets that produce output, there
>>     seems to be no flag to silence the 'tex' and 'pdftex' commands which
>>     some recipes use, I've not worried about these for now, e.g. the
>>     refcard.dvi and refcard.pdf targets still produce some output.
>
> Not a big deal IMO.  If we really want to, we could pipe stdout to
> /dev/null I suppose.

I thought about this, and figured this was likely a bad idea.  A well
written application should send general chat to stdout and
warnings/errors to stderr, but I don't think we should assume that's the
case.  Sending stdout to /dev/null runs the risk that the build could
fail with no useful message being printed.

>
>>     Luckily, when doing a 'make all' in the gdb/ directory, we only build
>>     the info docs by default, and those rules are now nice and silent, so
>>     a complete GDB build is now looking nice and quiet by default.
>> 
>> diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
>> index 8007f6373d4..ed8f7be5227 100644
>> --- a/gdb/doc/Makefile.in
>> +++ b/gdb/doc/Makefile.in
>> @@ -33,6 +33,8 @@ man5dir = $(mandir)/man5
>>  
>>  transform = @program_transform_name@
>>  
>> +include $(srcdir)/../silent-rules.mk
>> +
>>  SHELL = @SHELL@
>>  
>>  LN_S = @LN_S@
>> @@ -238,7 +240,7 @@ Doxyfile-gdbserver:	$(srcdir)/Doxyfile-gdbserver.in
>>  
>>  all-doc: info dvi ps pdf
>>  diststuff: info man
>> -	rm -f gdb-cfg.texi
>> +	$(SILENCE) rm -f gdb-cfg.texi

I've dropped this 'rm' in the latest update.  Looking at the rule to
generate gdb-cfg.texi, I'm not sure why we'd want to delete this file
here.  It's already deleted as part of the 'clean' rule.

>
> This makes this rule completely silent, that's maybe too much?  In the
> clean target, we don't silence the `rm`s, so I don't think we should
> here either.
>
>> -gdb-add-index.1: $(GDB_DOC_FILES)
>> -	touch $@
>> -	-$(TEXI2POD) $(MANCONF) -Dgdb-add-index < $(srcdir)/gdb.texinfo > gdb-add-index.pod
>> -	-($(POD2MAN1) gdb-add-index.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
>> +$(MAN1S) : %.1 : %.pod $(GDB_DOC_FILES)
>> +	$(SILENCE) touch $@
>> +	$(ECHO_TEXI2MAN) ($(POD2MAN1) $*.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
>>  		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
>> -	rm -f gdb-add-index.pod
>> +	$(SILENCE) rm -f $*.pod
>
> So as I said above, I would just not remove the pod file.

Done.

>
> A question about the pre-existing code: do you know why the `touch @` is
> needed?  It just seems dangerous to me.

I agree this seems weird.  I've dropped this in this new update.

So in the version below:

  + .pod file removal is now done as part of the 'mostlyclean' target,

  + the 'diststuff' target doesn't remove a temporary file any more,
  that is done in the 'mostlyclean' target,

  + No longer start by touching the target file when building the man
  pages.

Thoughts?

Thanks,
Andrew


---

commit 13baf7f097593b9d877036f55fb3d9c2d443ea38
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Fri Apr 12 17:47:20 2024 +0100

    gdb/doc: use silent-rules.mk in the Makefile
    
    Make use of silent-rules.mk when building the GDB docs.
    
    During review it was requested that there be more specific rules than
    just reusing the general 'GEN' rule everywhere in the doc/ directory,
    so I've added:
    
      ECHO_DVIPS =    @echo "  DVIPS    $@";
      ECHO_TEX =      @echo "  TEX      $@";
      ECHO_PDFTEX =   @echo "  PDFTEX   $@";
      ECHO_TEXI2DVI = @echo "  TEXI2DVI $@";
      ECHO_MAKEHTML = @echo "  MAKEHTML $@";
      ECHO_TEXI2POD = @echo "  TEXI2POD $@";
      ECHO_TEXI2MAN = @echo "  TEXI2MAN $@";
      ECHO_MAKEINFO = @echo "  MAKEINFO $@";
    
    Then I've made use of these new silent rules and added lots of uses of
    SILENT to reduce additional clutter.
    
    As the man page generation is done in two phases, first the creation
    of a .pod file, then the creation of the final man page file, I've
    restructured the man page rules.  Previously we had one rule for each
    of the 5 man pages.  I now have one general rule that will generate
    all of the 5 .pod files, then I have two rules that convert the .pod
    files into the final man pages.
    
    I needed two rules for the man page generation as some man pages match
    %.1 and some match %.5.  I could combine these by using the GNU Make
    .SECONDARYEXPANSION extension, but I think having two rules like this
    is probably clearer, and the duplication is minimal.
    
    Cleaning up the temporary .pod files is now moved into the
    'mostlyclean' target rather than being done as soon as the man page is
    created.
    
    I've added a new SILENT_Q_FLAG to silent-rules.mk, this is like
    SILENT_FLAG, but is set to '-q' when in silent mode, this can be used
    with the 'dvips' and 'texi2dvi' commands, both of which use '-q' to
    mean: only report errors.
    
    As with the rest of the GDB makefiles, I've only converted the
    "generation" rules to use silent-rules.mk, the install / uninstall
    rules are left unchanged.
    
    When looking at the 'diststuff' target, which generates the info and
    man pages, I noticed the recipe for this rule just deleted a temporary
    file.  As that temporary file is already cleaned up as part of the
    'clean' rule I've removed the deletion from the 'diststuff' target.
    
    There are still a few "generation" targets that produce output, there
    seems to be no flag to silence the 'tex' and 'pdftex' commands which
    some recipes use, I've not worried about these for now, e.g. the
    refcard.dvi and refcard.pdf targets still produce some output.
    
    Luckily, when doing a 'make all' in the gdb/ directory, we only build
    the info docs by default, and those rules are now nice and silent, so
    a complete GDB build is now looking nice and quiet by default.
    
    While working on this patch I noticed that 'make -j all-doc' doesn't
    work (reliably), this is a preexisting bug in the way that dvi/pdf
    targets are generated.  For example gdb.dvi and gdb.pdf both use the
    texi2dvi tool, which relies on temporary files to hold state.  If both
    these rules run in parallel then one (or both) of the recipes will
    fail.
    
    Luckily, the default docs target (all), which is what gets run when we
    do 'make all' in the gdb/ directory, doesn't build the dvi and pdf
    targets, so we're OK in that case.
    
    I've not tried to fix this problem in this commit as it already
    existed, and I don't want to do too much in one commit.  I mention it
    only because I ran into this issue while testing this commit.

diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
index 8007f6373d4..28d829fdfee 100644
--- a/gdb/doc/Makefile.in
+++ b/gdb/doc/Makefile.in
@@ -33,6 +33,8 @@ man5dir = $(mandir)/man5
 
 transform = @program_transform_name@
 
+include $(srcdir)/../silent-rules.mk
+
 SHELL = @SHELL@
 
 LN_S = @LN_S@
@@ -186,6 +188,11 @@ MAN1S = gdb.1 gdbserver.1 gcore.1 gdb-add-index.1
 MAN5S = gdbinit.5
 MANS = $(MAN1S) $(MAN5S)
 
+# The pod files that are generated as a side effect of creating the
+# man pages.
+POD_FILE_TMPS = $(patsubst %.1,%.pod,$MAN1S) \
+		$(patsubst %.5,%.pod,$MAN1S)
+
 HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
 HAVE_NATIVE_GCORE_HOST = @HAVE_NATIVE_GCORE_HOST@
 
@@ -238,7 +245,6 @@ Doxyfile-gdbserver:	$(srcdir)/Doxyfile-gdbserver.in
 
 all-doc: info dvi ps pdf
 diststuff: info man
-	rm -f gdb-cfg.texi
 
 install-info: $(INFO_DEPS)
 	$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(infodir)
@@ -406,55 +412,56 @@ de-stage3: force
 
 # GDB QUICK REFERENCE (dvi output)
 refcard.dvi : refcard.tex $(REFEDITS)
-	echo > tmp.sed
-	for f in x $(REFEDITS) ; do \
+	$(SILENCE) echo > tmp.sed
+	$(SILENCE) for f in x $(REFEDITS) ; do \
 		test x$$f = xx && continue ; \
 		cat $(srcdir)/$$f >>tmp.sed ; \
 	done
-	sed -f tmp.sed $(srcdir)/refcard.tex >sedref.tex
-	$(SET_TEXINPUTS) $(TEX) sedref.tex
-	mv sedref.dvi refcard.dvi
-	rm -f sedref.log sedref.tex tmp.sed
+	$(SILENCE) sed -f tmp.sed $(srcdir)/refcard.tex >sedref.tex
+	$(ECHO_TEX) $(SET_TEXINPUTS) $(TEX) sedref.tex
+	$(SILENCE) mv sedref.dvi refcard.dvi
+	$(SILENCE) rm -f sedref.log sedref.tex tmp.sed
 
 refcard.ps : refcard.dvi
-	$(DVIPS) -t landscape -o $@ $?
+	$(ECHO_DVIPS) $(DVIPS) $(SILENT_Q_FLAG) -t landscape -o $@ $?
 
 refcard.pdf : refcard.tex $(REFEDITS)
-	echo > tmp.sed
-	for f in x $(REFEDITS) ; do \
+	$(SILENCE) echo > tmp.sed
+	$(SILENCE) for f in x $(REFEDITS) ; do \
 		test x$$f = xx && continue ; \
 		cat $(srcdir)/$$f >>tmp.sed ; \
 	done
-	sed -f tmp.sed $(srcdir)/refcard.tex >sedref.tex
-	$(SET_TEXINPUTS) $(PDFTEX) sedref.tex
-	mv sedref.pdf refcard.pdf
-	rm -f sedref.log sedref.tex tmp.sed
+	$(SILENCE) sed -f tmp.sed $(srcdir)/refcard.tex >sedref.tex
+	$(ECHO_PDFTEX) $(SET_TEXINPUTS) $(PDFTEX) sedref.tex
+	$(SILENCE) mv sedref.pdf refcard.pdf
+	$(SILENCE) rm -f sedref.log sedref.tex tmp.sed
 
 # File to record current GDB version number.
 GDBvn.texi : version.subst
-	echo "@set GDBVN `sed q version.subst`" > ./GDBvn.new
-	if [ -n "$(PKGVERSION)" ]; then \
+	$(ECHO_GEN)
+	$(SILENCE) echo "@set GDBVN `sed q version.subst`" > ./GDBvn.new
+	$(SILENCE) if [ -n "$(PKGVERSION)" ]; then \
 	  echo "@set VERSION_PACKAGE $(PKGVERSION)" >> ./GDBvn.new; \
 	fi
-	echo "@set BUGURL $(BUGURL_TEXI)" >> ./GDBvn.new
-	if [ "$(BUGURL_TEXI)" = "@uref{http://www.gnu.org/software/gdb/bugs/}" ]; then \
+	$(SILENCE) echo "@set BUGURL $(BUGURL_TEXI)" >> ./GDBvn.new
+	$(SILENCE) if [ "$(BUGURL_TEXI)" = "@uref{http://www.gnu.org/software/gdb/bugs/}" ]; then \
 	  echo "@set BUGURL_DEFAULT" >> ./GDBvn.new; \
 	fi
-	if test -z "$(READLINE_TEXI_INCFLAG)"; then \
+	$(SILENCE) if test -z "$(READLINE_TEXI_INCFLAG)"; then \
 	  echo "@set SYSTEM_READLINE" >> ./GDBvn.new; \
 	fi
-	if [ -n "$(SYSTEM_GDBINIT)" ]; then \
+	$(SILENCE) if [ -n "$(SYSTEM_GDBINIT)" ]; then \
 	  escaped_system_gdbinit=`echo $(SYSTEM_GDBINIT) | sed 's/@/@@/g'`; \
 	  echo "@set SYSTEM_GDBINIT $$escaped_system_gdbinit" >> ./GDBvn.new; \
 	fi
-	if [ -n "$(SYSTEM_GDBINIT_DIR)" ]; then \
+	$(SILENCE) if [ -n "$(SYSTEM_GDBINIT_DIR)" ]; then \
 	  escaped_system_gdbinit_dir=`echo $(SYSTEM_GDBINIT_DIR) | sed 's/@/@@/g'`; \
 	  echo "@set SYSTEM_GDBINIT_DIR $$escaped_system_gdbinit_dir" >> ./GDBvn.new; \
 	fi
-	mv GDBvn.new GDBvn.texi
+	$(SILENCE) mv GDBvn.new GDBvn.texi
 
 version.subst: $(gdbdir)/version.in $(gdbdir)/../bfd/version.h
-	date=`sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$$/\1/p' $(gdbdir)/../bfd/version.h`; \
+	$(ECHO_GEN) date=`sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$$/\1/p' $(gdbdir)/../bfd/version.h`; \
 	sed -e "s/DATE/$$date/" < $(gdbdir)/version.in > version.subst
 
 # Updated atomically
@@ -465,7 +472,7 @@ version.subst: $(gdbdir)/version.in $(gdbdir)/../bfd/version.h
 # not one for their binary config---which may not be specifically
 # defined anyways).
 gdb-cfg.texi: ${srcdir}/${DOC_CONFIG}-cfg.texi
-	(test "$(LN_S)" = "ln -s" && \
+	$(ECHO_GEN) (test "$(LN_S)" = "ln -s" && \
 	  ln -s ${srcdir}/${DOC_CONFIG}-cfg.texi gdb-cfg.texi) || \
 	ln ${srcdir}/${DOC_CONFIG}-cfg.texi gdb-cfg.texi || \
 	cp ${srcdir}/${DOC_CONFIG}-cfg.texi gdb-cfg.texi
@@ -487,29 +494,30 @@ GDB_TEX_TMPS = gdb.aux gdb.cp* gdb.fn* gdb.ky* gdb.log gdb.pg* gdb.toc \
 
 # GDB MANUAL: TeX dvi file
 gdb.dvi: ${GDB_DOC_FILES}
-	if [ ! -f ./GDBvn.texi ]; then \
+	$(SILENCE) if [ ! -f ./GDBvn.texi ]; then \
 		(test "$(LN_S)" = "ln -s" && ln -s $(srcdir)/GDBvn.texi .) || \
 		ln $(srcdir)/GDBvn.texi . || \
 		cp $(srcdir)/GDBvn.texi . ; else true; fi
-	rm -f $(GDB_TEX_TMPS)
-	$(TEXI2DVI) $(READLINE_TEXI_INCFLAG) -I ${GDBMI_DIR} -I $(srcdir) \
-		$(srcdir)/gdb.texinfo
+	$(SILENCE) rm -f $(GDB_TEX_TMPS)
+	$(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) $(READLINE_TEXI_INCFLAG) \
+		-I ${GDBMI_DIR} -I $(srcdir) $(srcdir)/gdb.texinfo
 
 gdb.ps: gdb.dvi
-	$(DVIPS) -o $@ $?
+	$(ECHO_DVIPS) $(DVIPS) $(SILENT_Q_FLAG) -o $@ $?
 
 gdb.pdf: ${GDB_DOC_FILES}
-	if [ ! -f ./GDBvn.texi ]; then \
+	$(SILENCE) if [ ! -f ./GDBvn.texi ]; then \
 		(test "$(LN_S)" = "ln -s" && ln -s $(srcdir)/GDBvn.texi .) || \
 		ln $(srcdir)/GDBvn.texi . || \
 		cp $(srcdir)/GDBvn.texi . ; else true; fi
-	rm -f $(GDB_TEX_TMPS)
-	$(TEXI2DVI) --pdf $(READLINE_TEXI_INCFLAG) -I ${GDBMI_DIR} -I $(srcdir) \
+	$(SILENCE) rm -f $(GDB_TEX_TMPS)
+	$(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) --pdf \
+		$(READLINE_TEXI_INCFLAG) -I ${GDBMI_DIR} -I $(srcdir) \
 		$(srcdir)/gdb.texinfo
 
 # GDB MANUAL: info file
 gdb.info: ${GDB_DOC_FILES}
-	$(MAKEINFO_CMD) $(READLINE_TEXI_INCFLAG) -I ${GDBMI_DIR} -I $(srcdir) \
+	$(ECHO_MAKEINFO) $(MAKEINFO_CMD) $(READLINE_TEXI_INCFLAG) -I ${GDBMI_DIR} -I $(srcdir) \
 		-o gdb.info $(srcdir)/gdb.texinfo
 
 # GDB MANUAL: roff translations
@@ -527,16 +535,16 @@ gdb.info: ${GDB_DOC_FILES}
 # it out for gdb manual's include files---but only if not configured
 # in main sourcedir.
 links2roff: $(GDB_DOC_SOURCE_INCLUDES)
-	if [ ! -f gdb.texinfo ]; then \
+	$(ECHO_GEN) if [ ! -f gdb.texinfo ]; then \
 		(test "$(LN_S)" = "ln -s" && ln -s $(GDB_DOC_SOURCE_INCLUDES) .) || \
 		ln $(GDB_DOC_SOURCE_INCLUDES)    . || \
 		cp $(GDB_DOC_SOURCE_INCLUDES)    . ; \
 	fi
-	touch links2roff
+	$(SILENCE) touch links2roff
 
 # gdb manual suitable for [gtn]roff -me
 gdb.me: $(GDB_DOC_FILES) links2roff
-	sed -e '/\\input texinfo/d' \
+	$(ECHO_GEN) sed -e '/\\input texinfo/d' \
 		-e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
 		-e '/^@ifinfo/,/^@end ifinfo/d' \
 		-e '/^@c /d' \
@@ -551,7 +559,7 @@ gdb.me: $(GDB_DOC_FILES) links2roff
 
 # gdb manual suitable for [gtn]roff -ms
 gdb.ms: $(GDB_DOC_FILES) links2roff
-	sed -e '/\\input texinfo/d' \
+	$(ECHO_GEN) sed -e '/\\input texinfo/d' \
 		-e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
 		-e '/^@ifinfo/,/^@end ifinfo/d' \
 		-e '/^@c /d' \
@@ -568,7 +576,7 @@ gdb.ms: $(GDB_DOC_FILES) links2roff
 # '@noindent's removed due to texi2roff-2 mm bug; if yours is newer, 
 #   try leaving them in
 gdb.mm: $(GDB_DOC_FILES) links2roff
-	sed -e '/\\input texinfo/d' \
+	$(ECHO_GEN) sed -e '/\\input texinfo/d' \
 		-e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
 		-e '/^@ifinfo/,/^@end ifinfo/d' \
 		-e '/^@c /d' \
@@ -585,18 +593,18 @@ gdb.mm: $(GDB_DOC_FILES) links2roff
 # GDB MANUAL: HTML file
 
 gdb/index.html: ${GDB_DOC_FILES}
-	$(MAKEHTML) $(MAKEHTMLFLAGS) \
+	$(ECHO_GEN) $(MAKEHTML) $(MAKEHTMLFLAGS) \
 		-o gdb \
 		$(READLINE_TEXI_INCFLAG) -I ${GDBMI_DIR} -I $(srcdir) \
 		$(srcdir)/gdb.texinfo
 
 stabs.info: $(STABS_DOC_FILES)
-	$(MAKEINFO_CMD) -I $(srcdir) -o stabs.info $(srcdir)/stabs.texinfo
+	$(ECHO_MAKEINFO) $(MAKEINFO_CMD) -I $(srcdir) -o stabs.info $(srcdir)/stabs.texinfo
 
 # STABS DOCUMENTATION: HTML file
 
 stabs/index.html: $(STABS_DOC_FILES)
-	$(MAKEHTML) $(MAKEHTMLFLAGS) \
+	$(ECHO_GEN) $(MAKEHTML) $(MAKEHTMLFLAGS) \
 		-o stabs \
 		-I $(srcdir) \
 		$(srcdir)/stabs.texinfo
@@ -609,15 +617,17 @@ STABS_TEX_TMPS = stabs.aux stabs.cp* stabs.fn* stabs.ky* \
 
 # STABS DOCUMENTATION: TeX dvi file
 stabs.dvi : $(STABS_DOC_FILES)
-	rm -f $(STABS_TEX_TMPS)
-	$(TEXI2DVI) -I $(srcdir) $(srcdir)/stabs.texinfo
+	$(SILENCE) rm -f $(STABS_TEX_TMPS)
+	$(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) -I $(srcdir) \
+		$(srcdir)/stabs.texinfo
 
 stabs.ps: stabs.dvi
-	$(DVIPS) -o $@ $?
+	$(ECHO_DVIPS) $(DVIPS) $(SILENT_Q_FLAG) -o $@ $?
 
 stabs.pdf: $(STABS_DOC_FILES)
-	rm -f $(STABS_TEX_TMPS)
-	$(TEXI2DVI) --pdf -I $(srcdir) $(srcdir)/stabs.texinfo
+	$(SILENCE) rm -f $(STABS_TEX_TMPS)
+	$(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) --pdf -I $(srcdir) \
+		$(srcdir)/stabs.texinfo
 
 # Clean these up before each run.  Avoids a catch 22 with not being
 # able to re-generate these files (to fix a corruption) because these
@@ -627,65 +637,45 @@ ANNOTATE_TEX_TMPS = annotate.aux annotate.cp* annotate.fn* annotate.ky* \
 
 # ANNOTATE DOCUMENTATION: TeX dvi file
 annotate.dvi : $(ANNOTATE_DOC_FILES)
-	rm -f $(ANNOTATE_TEX_TMPS)
-	$(TEXI2DVI) -I $(srcdir) $(srcdir)/annotate.texinfo
+	$(SILENCE) rm -f $(ANNOTATE_TEX_TMPS)
+	$(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) -I $(srcdir) \
+		$(srcdir)/annotate.texinfo
 
 annotate.ps: annotate.dvi
-	$(DVIPS) -o $@ $?
+	$(ECHO_DVIPS) $(DVIPS) $(SILENT_Q_FLAG) -o $@ $?
 
 annotate.pdf: $(ANNOTATE_DOC_FILES)
-	rm -f $(ANNOTATE_TEX_TMPS)
-	$(TEXI2DVI) --pdf -I $(srcdir) $(srcdir)/annotate.texinfo
+	$(SILENCE) rm -f $(ANNOTATE_TEX_TMPS)
+	$(ECHO_TEXI2DVI) $(TEXI2DVI) $(SILENT_Q_FLAG) --pdf -I $(srcdir) \
+		$(srcdir)/annotate.texinfo
 
 annotate.info: $(ANNOTATE_DOC_FILES)
-	$(MAKEINFO_CMD) -I $(srcdir) -o annotate.info $(srcdir)/annotate.texinfo
+	$(ECHO_MAKEINFO) $(MAKEINFO_CMD) -I $(srcdir) -o annotate.info $(srcdir)/annotate.texinfo
 
 annotate/index.html: $(ANNOTATE_DOC_FILES)
-	$(MAKEHTML) $(MAKEHTMLFLAGS) \
+	$(ECHO_MAKEHTML) $(MAKEHTML) $(MAKEHTMLFLAGS) \
 		-o annotate \
 		-I $(srcdir) \
 		$(srcdir)/annotate.texinfo
 
 # Man pages
-gdb.1: $(GDB_DOC_FILES)
-	touch $@
-	-$(TEXI2POD) $(MANCONF) -Dgdb < $(srcdir)/gdb.texinfo > gdb.pod
-	-($(POD2MAN1) gdb.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
-		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
-	rm -f gdb.pod
-
-gdbserver.1: $(GDB_DOC_FILES)
-	touch $@
-	-$(TEXI2POD) $(MANCONF) -Dgdbserver < $(srcdir)/gdb.texinfo > gdbserver.pod
-	-($(POD2MAN1) gdbserver.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
-		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
-	rm -f gdbserver.pod
-
-gcore.1: $(GDB_DOC_FILES)
-	touch $@
-	-$(TEXI2POD) $(MANCONF) -Dgcore < $(srcdir)/gdb.texinfo > gcore.pod
-	-($(POD2MAN1) gcore.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
-		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
-	rm -f gcore.pod
+%.pod : gdb.texinfo $(GDB_DOC_FILES)
+	$(ECHO_TEXI2POD) $(TEXI2POD) $(MANCONF) -D$* < $(srcdir)/gdb.texinfo > $@
 
-gdb-add-index.1: $(GDB_DOC_FILES)
-	touch $@
-	-$(TEXI2POD) $(MANCONF) -Dgdb-add-index < $(srcdir)/gdb.texinfo > gdb-add-index.pod
-	-($(POD2MAN1) gdb-add-index.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
+$(MAN1S) : %.1 : %.pod $(GDB_DOC_FILES)
+	$(ECHO_TEXI2MAN) ($(POD2MAN1) $*.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
-	rm -f gdb-add-index.pod
+	$(SILENCE) rm -f $*.pod
 
-gdbinit.5: $(GDB_DOC_FILES)
-	touch $@
-	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod
-	-($(POD2MAN5) gdbinit.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
+$(MAN5S) : %.5 : %.pod $(GDB_DOC_FILES)
+	$(ECHO_TEXI2MAN) ($(POD2MAN1) $*.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
-	rm -f gdbinit.pod
+	$(SILENCE) rm -f $*.pod
 
 force:
 
 Makefile: Makefile.in $(host_makefile_frag) ../config.status
-	cd .. && $(SHELL) ./config.status doc/Makefile
+	$(ECHO_GEN) cd .. && $(SHELL) ./config.status $(SILENT_FLAG) doc/Makefile
 
 
 # The "least clean" level of cleaning.  Get rid of files which are
@@ -696,7 +686,8 @@ mostlyclean:
 	rm -f $(GDB_TEX_TMPS)
 	rm -f $(STABS_TEX_TMPS)
 	rm -f $(ANNOTATE_TEX_TMPS)
-	rm -f sedref.dvi sedref.tex tmp.sed
+	rm -f sedref.dvi sedref.tex tmp.sed sedref.log
+	rm -f $(POD_FILE_TMPS)
 
 clean: mostlyclean
 	rm -f gdb-cfg.texi
diff --git a/gdb/silent-rules.mk b/gdb/silent-rules.mk
index 43dc2bf3aca..d0983a514ff 100644
--- a/gdb/silent-rules.mk
+++ b/gdb/silent-rules.mk
@@ -17,9 +17,23 @@ ECHO_YACC =   @echo "  YACC   $@";
 ECHO_LEX  =   @echo "  LEX    $@";
 ECHO_AR =     @echo "  AR     $@";
 ECHO_RANLIB = @echo "  RANLIB $@";
+ECHO_DVIPS =  @echo "  DVIPS    $@";
+ECHO_TEX =    @echo "  TEX      $@";
+ECHO_PDFTEX = @echo "  PDFTEX   $@";
+ECHO_TEXI2DVI = \
+              @echo "  TEXI2DVI $@";
+ECHO_MAKEHTML = \
+              @echo "  MAKEHTML $@";
+ECHO_TEXI2POD = \
+              @echo "  TEXI2POD $@";
+ECHO_TEXI2MAN = \
+              @echo "  TEXI2MAN $@";
+ECHO_MAKEINFO = \
+              @echo "  MAKEINFO $@";
 SILENCE = @
 # Silence libtool.
 SILENT_FLAG = --silent
+SILENT_Q_FLAG = -q
 # Used in shell snippets instead of 'echo'.
 SILENT_ECHO = true
 else


^ permalink raw reply	[relevance 12%]

* Re: [PATCH v4 6/8] gdb: Add qIsAddressTagged packet
  @ 2024-04-17 20:57  0%     ` Gustavo Romero
  0 siblings, 0 replies; 200+ results
From: Gustavo Romero @ 2024-04-17 20:57 UTC (permalink / raw)
  To: Luis Machado, gdb-patches; +Cc: thiago.bauermann, eliz, tom

Hi Luis,

On 4/16/24 3:04 PM, Luis Machado wrote:
> Close, by I still have a few comments below.
> 
> On 4/16/24 15:07, Gustavo Romero wrote:
>> This commit adds a new packet, qIsAddressTagged, allowing GDB remote
>> targets to use it to query the stub if a given address is tagged.
>>
>> Currently, the memory tagging address check is done via a read query,
>> where the contents of /proc/<PID>/smaps is read and the flags are
>> inspected for memory tagging-related flags that indicate the address is
>> in a memory tagged region.
>>
>> This is not ideal, for example, for QEMU stub and other cases, such as
>> on bare-metal, where there is no notion of an OS file like 'smaps.'
>> Hence, the introduction of qIsAddressTagged packet allows checking
>> if an address is tagged in an agnostic way.
>>
>> The is_address_tagged target hook in remote.c attempts to use the
>> qIsAddressTagged packet first for checking if an address is tagged and
>> if the stub does not support such a packet (reply is empty) it falls
>> back to using the current mechanism that reads the contents of
>> /proc/<PID>/smaps via vFile requests.
>>
>> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
>> ---
>>   gdb/remote.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 49 insertions(+)
>>
>> diff --git a/gdb/remote.c b/gdb/remote.c
>> index 9717db55e27..63799ac5e3f 100644
>> --- a/gdb/remote.c
>> +++ b/gdb/remote.c
>> @@ -15534,6 +15534,40 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address,
>>     strcpy (packet.data (), request.c_str ());
>>   }
>>   
>> +static void
>> +create_is_address_tagged_request (gdbarch *gdbarch, gdb::char_vector &packet,
>> +				  CORE_ADDR address)
>> +{
>> +  int addr_size;
>> +  std::string request;
>> +
>> +  addr_size = gdbarch_addr_bit (gdbarch) / 8;
>> +  request = string_printf ("qIsAddressTagged:%s", phex_nz (address, addr_size));
>> +
>> +  if (packet.size () < request.length () + 1)
>> +    error (_("Contents too big for packet qIsAddressTagged."));
>> +
>> +  strcpy (packet.data (), request.c_str ());
>> +}
>> +
>> +static bool
>> +check_is_address_tagged_reply (gdb::char_vector &packet, bool *tagged)
> 
> Instead of passing TAGGED as pointer, make it a reference. It is safer.

Thanks, fixed in v5.


>> +{
>> +  if (packet_check_result (packet).status () != PACKET_OK)
> 
> This function signature is incorrect and leads to a build error. This function has two
> arguments.

argh, not sure how that happened, fixed in v5.


> Also, this check will return false if the packet yields an error and if the packet is not
> supported. We need to be able to distinguish between unsupported and error here, right?

Error replies (Exx) and empty replies are treat the same: they fail the
check. As a consequence, the fallback mechanism will be used.


>> +    return false;
>> +
>> +  gdb_byte reply;
>> +  /* Convert only 2 hex digits, i.e. 1 byte in hex format.  */
>> +  hex2bin (packet.data (), &reply, 1);
>> +
>> +  if (reply == 0x00 || reply == 0x01) {
>> +    *tagged = !!reply;
> 
> Passing tagged as reference just use tagged instead of *tagged here.
> 
>> +    return true;
>> +  }
>> +
>> +  return false;
>> +}
>> +
>>   /* Implement the "fetch_memtags" target_ops method.  */
>>   
>>   bool
>> @@ -15580,6 +15614,21 @@ remote_target::store_memtags (CORE_ADDR address, size_t len,
>>   bool
>>   remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address)
>>   {
>> +  struct remote_state *rs = get_remote_state ();
>> +  bool is_addr_tagged;
>> +
> 
> Before sending the packet, we need to check if the packet is supported. Generally gdb
> will send it the first time around, but if the packet isn't supported gdb shouldn't
> keep sending these packets if the stub is gonna reply empty again.

hmm, I missed GDB's "auto" mechanism for this. Thanks, fixed in v5.


> See remote_target::remote_query_attached for an example of how we deal with this.
> 
> First you need to have a new enum PACKET_qIsAddressTagged, so we can register if
> the packet is supported or not at runtime.
> 
> Then at the start of the function:
> 
> if (m_features.packet_support (PACKET_qIsAddressTagged) != PACKET_DISABLE)
>    {
>      /* Use the qIsTaggedAddress packet.  */
>    }
> else
>    {
>      /* Use the fallback smaps method.  */
>    }
> 
> That way gdb only sends the qIsTaggedAddress packet once. If it works, then gdb
> keeps using it. Otherwise it always uses the fallback.

This if/else struct can't be used afaics. It is problematic on the first time
it is executed, because if the packet is not supported by the stub (the check
is performed inside the if statement, not before it) the fallback code must be
called, but since the fallback code is inside the else {} statement, and if {}
is already taken, it won't be executed. So, it must be instead:

if (m_features.packet_support (PACKET_qIsAddressTagged) != PACKET_DISABLE)
   {
     /* Use the qIsTaggedAddress packet.  */
   }

/* Use the fallback smaps method.  */

Please see v5.


Cheers,
Gustavo

^ permalink raw reply	[relevance 0%]

* Re: [PATCH] Disallow trailing whitespace in docstrings
  @ 2024-04-17 19:02  0% ` Philippe Waroquiers
  0 siblings, 0 replies; 200+ results
From: Philippe Waroquiers @ 2024-04-17 19:02 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Looks ok to me, thanks
Philippe

On Wed, 2024-04-17 at 08:06 -0600, Tom Tromey wrote:
> This patch changes the docstring self-test to verify that there is no
> trailing whitespace at the end of lines.  A few existing docstrings
> had to be updated.
> ---
>  gdb/breakpoint.c                      |  4 ++--
>  gdb/cris-tdep.c                       |  2 +-
>  gdb/infcmd.c                          |  6 +++---
>  gdb/macrocmd.c                        |  2 +-
>  gdb/reverse.c                         |  8 ++++----
>  gdb/skip.c                            |  2 +-
>  gdb/typeprint.c                       |  2 +-
>  gdb/unittests/command-def-selftests.c | 19 +++++++++++++++++--
>  8 files changed, 30 insertions(+), 15 deletions(-)
> 
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 6d8adc62664..880cc57037c 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -14597,7 +14597,7 @@ command" [PROBE_MODIFIER] [LOCATION] [thread THREADNUM]\n\
>  \t[-force-condition] [if CONDITION]\n\
>  PROBE_MODIFIER shall be present if the command is to be placed in a\n\
>  probe point.  Accepted values are `-probe' (for a generic, automatically\n\
> -guessed probe type), `-probe-stap' (for a SystemTap probe) or \n\
> +guessed probe type), `-probe-stap' (for a SystemTap probe) or\n\
>  `-probe-dtrace' (for a DTrace probe).\n\
>  LOCATION may be a linespec, address, or explicit location as described\n\
>  below.\n\
> @@ -15028,7 +15028,7 @@ Do \"help tracepoints\" for info on other tracepoint commands."));
>  Set a static tracepoint at location or marker.\n\
>  \n\
>  strace [LOCATION] [if CONDITION]\n\
> -LOCATION may be a linespec, explicit, or address location (described below) \n\
> +LOCATION may be a linespec, explicit, or address location (described below)\n\
>  or -m MARKER_ID.\n\n\
>  If a marker id is specified, probe the marker with that name.  With\n\
>  no LOCATION, uses current execution address of the selected stack frame.\n\
> diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
> index dd013d531ab..1fc30c0b193 100644
> --- a/gdb/cris-tdep.c
> +++ b/gdb/cris-tdep.c
> @@ -3828,7 +3828,7 @@ _initialize_cris_tdep ()
>  			     _("Show the current CRIS version."),
>  			     _("\
>  Set to 10 for CRISv10 or 32 for CRISv32 if autodetection fails.\n\
> -Defaults to 10. "),
> +Defaults to 10."),
>  			     set_cris_version,
>  			     NULL, /* FIXME: i18n: Current CRIS version
>  				      is %s.  */
> diff --git a/gdb/infcmd.c b/gdb/infcmd.c
> index 10a964a90d7..a53c6c91828 100644
> --- a/gdb/infcmd.c
> +++ b/gdb/infcmd.c
> @@ -3077,7 +3077,7 @@ shell that will start the program (specified by the \"$SHELL\" environment\n\
>  variable).  Input and output redirection with \">\", \"<\", or \">>\"\n\
>  are also allowed.\n\
>  \n\
> -With no arguments, uses arguments last specified (with \"run\" or \n\
> +With no arguments, uses arguments last specified (with \"run\" or\n\
>  \"set args\").  To cancel previous arguments and run with no arguments,\n\
>  use \"set args\" without arguments.\n\
>  \n\
> @@ -3303,7 +3303,7 @@ which means to set the ignore count of that breakpoint to N - 1 (so that\n\
>  the breakpoint won't break until the Nth time it is reached).\n\
>  \n\
>  If non-stop mode is enabled, continue only the current thread,\n\
> -otherwise all the threads in the program are continued.  To \n\
> +otherwise all the threads in the program are continued.  To\n\
>  continue all stopped threads in non-stop mode, use the -a option.\n\
>  Specifying -a and an ignore count simultaneously is an error."));
>    add_com_alias ("c", continue_cmd, class_run, 1);
> @@ -3329,7 +3329,7 @@ RUN_ARGS_HELP));
>    add_com ("interrupt", class_run, interrupt_command,
>  	   _("Interrupt the execution of the debugged program.\n\
>  If non-stop mode is enabled, interrupt only the current thread,\n\
> -otherwise all the threads in the program are stopped.  To \n\
> +otherwise all the threads in the program are stopped.  To\n\
>  interrupt all running threads in non-stop mode, use the -a option."));
>  
>    cmd_list_element *info_registers_cmd
> diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
> index ddabfede0f5..a84ea57a7ba 100644
> --- a/gdb/macrocmd.c
> +++ b/gdb/macrocmd.c
> @@ -480,7 +480,7 @@ expression work together to yield a pre-processed expression."),
>    add_info ("macro", info_macro_command,
>  	    _("Show the definition of MACRO, and it's source location.\n\
>  Usage: info macro [-a|-all] [--] MACRO\n\
> -Options: \n\
> +Options:\n\
>    -a, --all    Output all definitions of MACRO in the current compilation\
>   unit.\n\
>    --           Specify the end of arguments and the beginning of the MACRO."));
> diff --git a/gdb/reverse.c b/gdb/reverse.c
> index 11c76b4b335..ca11f83119b 100644
> --- a/gdb/reverse.c
> +++ b/gdb/reverse.c
> @@ -320,12 +320,12 @@ Execute backward until just before selected stack frame is called."));
>  
>    add_com ("bookmark", class_bookmark, save_bookmark_command, _("\
>  Set a bookmark in the program's execution history.\n\
> -A bookmark represents a point in the execution history \n\
> +A bookmark represents a point in the execution history\n\
>  that can be returned to at a later point in the debug session."));
>    add_info ("bookmarks", info_bookmarks_command, _("\
>  Status of user-settable bookmarks.\n\
> -Bookmarks are user-settable markers representing a point in the \n\
> -execution history that can be returned to later in the same debug \n\
> +Bookmarks are user-settable markers representing a point in the\n\
> +execution history that can be returned to later in the same debug\n\
>  session."));
>    add_cmd ("bookmark", class_bookmark, delete_bookmark_command, _("\
>  Delete a bookmark from the bookmark list.\n\
> @@ -334,7 +334,7 @@ Argument is a bookmark number or numbers,\n\
>  	   &deletelist);
>    add_com ("goto-bookmark", class_bookmark, goto_bookmark_command, _("\
>  Go to an earlier-bookmarked point in the program's execution history.\n\
> -Argument is the bookmark number of a bookmark saved earlier by using \n\
> +Argument is the bookmark number of a bookmark saved earlier by using\n\
>  the 'bookmark' command, or the special arguments:\n\
>    start (beginning of recording)\n\
>    end   (end of recording)"));
> diff --git a/gdb/skip.c b/gdb/skip.c
> index f2818eccb34..e3448700247 100644
> --- a/gdb/skip.c
> +++ b/gdb/skip.c
> @@ -722,7 +722,7 @@ If you don't specify any numbers or ranges, we'll delete all skip entries."),
>    add_info ("skip", info_skip_command, _("\
>  Display the status of skips.\n\
>  Usage: info skip [NUMBER | RANGES]...\n\
> -You can specify numbers (e.g. \"info skip 1 3\"), \n\
> +You can specify numbers (e.g. \"info skip 1 3\"),\n\
>  ranges (e.g. \"info skip 4-8\"), or both (e.g. \"info skip 1 3 4-8\").\n\n\
>  If you don't specify any numbers or ranges, we'll show all skips."));
>    set_cmd_completer (c, complete_skip_number);
> diff --git a/gdb/typeprint.c b/gdb/typeprint.c
> index 4d0e764274a..7977bd2c4ae 100644
> --- a/gdb/typeprint.c
> +++ b/gdb/typeprint.c
> @@ -843,7 +843,7 @@ Available FLAGS are:\n\
>    /x    use hexadecimal notation when displaying sizes and offsets\n\
>  	of struct members\n\
>    /d    use decimal notation when displaying sizes and offsets\n\
> -	of struct members "));
> +	of struct members"));
>    set_cmd_completer (c, expression_completer);
>  
>    c = add_com ("whatis", class_vars, whatis_command,
> diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c
> index 6936af740fc..6a9b194e680 100644
> --- a/gdb/unittests/command-def-selftests.c
> +++ b/gdb/unittests/command-def-selftests.c
> @@ -73,10 +73,25 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix)
>  	   "first line is not terminated with a '.' character");
>  
>        /* Checks the doc is not terminated with a new line.  */
> -      if (c->doc[strlen (c->doc) - 1] == '\n')
> +      if (isspace (c->doc[strlen (c->doc) - 1]))
>  	broken_doc_invariant
>  	  (prefix, c->name,
> -	   "has a superfluous trailing end of line");
> +	   "has superfluous trailing whitespace");
> +
> +      for (const char *nl = strchr (c->doc, '\n');
> +	   nl != nullptr;
> +	   nl = strchr (nl + 1, '\n'))
> +	{
> +	  if (nl == c->doc)
> +	    broken_doc_invariant (prefix, c->name, "has a leading newline");
> +	  else
> +	    {
> +	      /* \n\n is ok, so we check that explicitly here.  */
> +	      if (isspace (nl[-1]) && nl[-1] != '\n')
> +		broken_doc_invariant (prefix, c->name,
> +				      "has whitespace before a newline");
> +	    }
> +	}
>  
>        /* Check if this command has subcommands and is not an
>  	 abbreviation.  We skip checking subcommands of abbreviations


^ permalink raw reply	[relevance 0%]

* Re: [PATCH] gdb+gdbserver/Linux: Remove USE_SIGTRAP_SIGINFO fallback
  @ 2024-04-17 16:40  0% ` Pedro Alves
  0 siblings, 0 replies; 200+ results
From: Pedro Alves @ 2024-04-17 16:40 UTC (permalink / raw)
  To: gdb-patches

On 2022-06-27 22:10, Pedro Alves wrote:
> It's been over 7 years (since commit faf09f0119da) since Linux GDB and
> GDBserver started relying on SIGTRAP si_code to tell whether a
> breakpoint triggered, which is important for non-stop mode.  When that
> then-new code was added, I had left the then-old code as fallback, in
> case some architectured still needed it.  Given AFAIK there haven't
> been complaints since, this commit finally removes the fallback code,
> along with USE_SIGTRAP_SIGINFO.
> 
> Change-Id: I140a5333a9fe70e90dbd186aca1f081549b2e63d

W00t.  I was looking at linux-nat.c today, and noticed the USE_SIGTRAP_SIGINFO
code was still around, which made me go like "but hadn't I removed this before??".
Well, turns out I forgot to merge this.

I'm going to merge it, after I download the patch from the list and
update that "7 years".  :-)

Pedro Alves

> ---
>  gdb/linux-nat.c        | 53 ++----------------------------------------
>  gdb/nat/linux-ptrace.h | 11 ++++-----
>  gdbserver/linux-low.cc | 39 ++-----------------------------
>  3 files changed, 8 insertions(+), 95 deletions(-)
> 
> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
> index b9164e621db..008791c12dc 100644
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c
> @@ -2439,17 +2439,6 @@ status_callback (struct lwp_info *lp)
>  	  discard = 1;
>  	}
>  
> -#if !USE_SIGTRAP_SIGINFO
> -      else if (!breakpoint_inserted_here_p (regcache->aspace (), pc))
> -	{
> -	  linux_nat_debug_printf ("previous breakpoint of %s, at %s gone",
> -				  lp->ptid.to_string ().c_str (),
> -				  paddress (target_gdbarch (), lp->stop_pc));
> -
> -	  discard = 1;
> -	}
> -#endif
> -
>        if (discard)
>  	{
>  	  linux_nat_debug_printf ("pending event of %s cancelled.",
> @@ -2529,9 +2518,7 @@ save_stop_reason (struct lwp_info *lp)
>    struct gdbarch *gdbarch;
>    CORE_ADDR pc;
>    CORE_ADDR sw_bp_pc;
> -#if USE_SIGTRAP_SIGINFO
>    siginfo_t siginfo;
> -#endif
>  
>    gdb_assert (lp->stop_reason == TARGET_STOPPED_BY_NO_REASON);
>    gdb_assert (lp->status != 0);
> @@ -2545,7 +2532,6 @@ save_stop_reason (struct lwp_info *lp)
>    pc = regcache_read_pc (regcache);
>    sw_bp_pc = pc - gdbarch_decr_pc_after_break (gdbarch);
>  
> -#if USE_SIGTRAP_SIGINFO
>    if (linux_nat_get_siginfo (lp->ptid, &siginfo))
>      {
>        if (siginfo.si_signo == SIGTRAP)
> @@ -2588,22 +2574,6 @@ save_stop_reason (struct lwp_info *lp)
>  	    }
>  	}
>      }
> -#else
> -  if ((!lp->step || lp->stop_pc == sw_bp_pc)
> -      && software_breakpoint_inserted_here_p (regcache->aspace (),
> -					      sw_bp_pc))
> -    {
> -      /* The LWP was either continued, or stepped a software
> -	 breakpoint instruction.  */
> -      lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
> -    }
> -
> -  if (hardware_breakpoint_inserted_here_p (regcache->aspace (), pc))
> -    lp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
> -
> -  if (lp->stop_reason == TARGET_STOPPED_BY_NO_REASON)
> -    check_stopped_by_watchpoint (lp);
> -#endif
>  
>    if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT)
>      {
> @@ -2649,7 +2619,7 @@ linux_nat_target::stopped_by_sw_breakpoint ()
>  bool
>  linux_nat_target::supports_stopped_by_sw_breakpoint ()
>  {
> -  return USE_SIGTRAP_SIGINFO;
> +  return true;
>  }
>  
>  /* Returns true if the LWP had stopped for a hardware
> @@ -2670,7 +2640,7 @@ linux_nat_target::stopped_by_hw_breakpoint ()
>  bool
>  linux_nat_target::supports_stopped_by_hw_breakpoint ()
>  {
> -  return USE_SIGTRAP_SIGINFO;
> +  return true;
>  }
>  
>  /* Select one LWP out of those that have events pending.  */
> @@ -3252,25 +3222,6 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
>  
>    gdb_assert (lp != NULL);
>  
> -  /* Now that we've selected our final event LWP, un-adjust its PC if
> -     it was a software breakpoint, and we can't reliably support the
> -     "stopped by software breakpoint" stop reason.  */
> -  if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
> -      && !USE_SIGTRAP_SIGINFO)
> -    {
> -      struct regcache *regcache = get_thread_regcache (linux_target, lp->ptid);
> -      struct gdbarch *gdbarch = regcache->arch ();
> -      int decr_pc = gdbarch_decr_pc_after_break (gdbarch);
> -
> -      if (decr_pc != 0)
> -	{
> -	  CORE_ADDR pc;
> -
> -	  pc = regcache_read_pc (regcache);
> -	  regcache_write_pc (regcache, pc + decr_pc);
> -	}
> -    }
> -
>    /* We'll need this to determine whether to report a SIGSTOP as
>       GDB_SIGNAL_0.  Need to take a copy because resume_clear_callback
>       clears it.  */
> diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
> index 4694046e1e8..3edc2363aa2 100644
> --- a/gdb/nat/linux-ptrace.h
> +++ b/gdb/nat/linux-ptrace.h
> @@ -97,9 +97,9 @@ struct buffer;
>  #define __WALL          0x40000000 /* Wait for any child.  */
>  #endif
>  
> -/* True if whether a breakpoint/watchpoint triggered can be determined
> -   from the si_code of SIGTRAP's siginfo_t (TRAP_BRKPT/TRAP_HWBKPT).
> -   That is, if the kernel can tell us whether the thread executed a
> +/* Whether a breakpoint/watchpoint triggered can be determined from
> +   the si_code of SIGTRAP's siginfo_t (TRAP_BRKPT/TRAP_HWBKPT).  That
> +   is, since the kernel can tell us whether the thread executed a
>     software breakpoint, we trust it.  The kernel will be determining
>     that from the hardware (e.g., from which exception was raised in
>     the CPU).  Relying on whether a breakpoint is planted in memory at
> @@ -112,10 +112,7 @@ struct buffer;
>     architectures.  The moribund location mechanism helps with that
>     somewhat but it is an heuristic, and can well fail.  Getting that
>     information out of the kernel and ultimately out of the CPU is the
> -   way to go.  That said, some architecture may get the si_code wrong,
> -   and as such we're leaving fallback code in place.  We'll remove
> -   this after a while if no problem is reported.  */
> -#define USE_SIGTRAP_SIGINFO 1
> +   way to go.  */
>  
>  /* The x86 kernel gets some of the si_code values backwards, like
>     this:
> diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
> index 8b8614f6ed4..9305928bbbf 100644
> --- a/gdbserver/linux-low.cc
> +++ b/gdbserver/linux-low.cc
> @@ -790,9 +790,7 @@ linux_process_target::save_stop_reason (lwp_info *lwp)
>  {
>    CORE_ADDR pc;
>    CORE_ADDR sw_breakpoint_pc;
> -#if USE_SIGTRAP_SIGINFO
>    siginfo_t siginfo;
> -#endif
>  
>    if (!low_supports_breakpoints ())
>      return false;
> @@ -804,7 +802,6 @@ linux_process_target::save_stop_reason (lwp_info *lwp)
>    scoped_restore_current_thread restore_thread;
>    switch_to_thread (get_lwp_thread (lwp));
>  
> -#if USE_SIGTRAP_SIGINFO
>    if (ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
>  	      (PTRACE_TYPE_ARG3) 0, &siginfo) == 0)
>      {
> @@ -846,21 +843,6 @@ linux_process_target::save_stop_reason (lwp_info *lwp)
>  	    }
>  	}
>      }
> -#else
> -  /* We may have just stepped a breakpoint instruction.  E.g., in
> -     non-stop mode, GDB first tells the thread A to step a range, and
> -     then the user inserts a breakpoint inside the range.  In that
> -     case we need to report the breakpoint PC.  */
> -  if ((!lwp->stepping || lwp->stop_pc == sw_breakpoint_pc)
> -      && low_breakpoint_at (sw_breakpoint_pc))
> -    lwp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
> -
> -  if (hardware_breakpoint_inserted_here (pc))
> -    lwp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
> -
> -  if (lwp->stop_reason == TARGET_STOPPED_BY_NO_REASON)
> -    check_stopped_by_watchpoint (lwp);
> -#endif
>  
>    if (lwp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT)
>      {
> @@ -1648,23 +1630,6 @@ linux_process_target::thread_still_has_status_pending (thread_info *thread)
>  	  discard = 1;
>  	}
>  
> -#if !USE_SIGTRAP_SIGINFO
> -      else if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
> -	       && !low_breakpoint_at (pc))
> -	{
> -	  threads_debug_printf ("previous SW breakpoint of %ld gone",
> -				lwpid_of (thread));
> -	  discard = 1;
> -	}
> -      else if (lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT
> -	       && !hardware_breakpoint_inserted_here (pc))
> -	{
> -	  threads_debug_printf ("previous HW breakpoint of %ld gone",
> -				lwpid_of (thread));
> -	  discard = 1;
> -	}
> -#endif
> -
>        if (discard)
>  	{
>  	  threads_debug_printf ("discarding pending breakpoint status");
> @@ -5555,7 +5520,7 @@ linux_process_target::stopped_by_sw_breakpoint ()
>  bool
>  linux_process_target::supports_stopped_by_sw_breakpoint ()
>  {
> -  return USE_SIGTRAP_SIGINFO;
> +  return true;
>  }
>  
>  /* Implement the stopped_by_hw_breakpoint target_ops
> @@ -5575,7 +5540,7 @@ linux_process_target::stopped_by_hw_breakpoint ()
>  bool
>  linux_process_target::supports_stopped_by_hw_breakpoint ()
>  {
> -  return USE_SIGTRAP_SIGINFO;
> +  return true;
>  }
>  
>  /* Implement the supports_hardware_single_step target_ops method.  */
> 
> base-commit: f18acc9c4e5d18f4783f3a7d59e3ec95d7af0199

^ permalink raw reply	[relevance 0%]

* Re: [RFC PATCH 3/3] gdb/nat/linux: Fix attaching to process when it has zombie threads
  @ 2024-04-17 15:32  0%       ` Pedro Alves
  0 siblings, 0 replies; 200+ results
From: Pedro Alves @ 2024-04-17 15:32 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: gdb-patches

On 2024-04-16 05:48, Thiago Jung Bauermann wrote:
> 
> Hello Pedro,
> 
> [ I just now noticed that I replied to you in private last time. Sorry
>   about that, I thought I had cc'd the list. ]

I hadn't noticed.  :-)

> 
> Pedro Alves <pedro@palves.net> writes:
> 
>> On 2024-03-21 23:11, Thiago Jung Bauermann wrote:
>>> When GDB attaches to a multi-threaded process, it calls
>>> linux_proc_attach_tgid_threads () to go through all threads found in
>>> /proc/PID/task/ and call attach_proc_task_lwp_callback () on each of
>>> them.  If it does that twice without the callback reporting that a new
>>> thread was found, then it considers that all inferior threads have been
>>> found and returns.
>>>
>>> The problem is that the callback considers any thread that it hasn't
>>> attached to yet as new.  This causes problems if the process has one or
>>> more zombie threads, because GDB can't attach to it and the loop will
>>> always "find" a new thread (the zombie one), and get stuck in an
>>> infinite loop.
>>>
>>> This is easy to trigger (at least on aarch64-linux and powerpc64le-linux)
>>> with the gdb.threads/attach-many-short-lived-threads.exp testcase, because
>>> its test program constantly creates and finishes joinable threads so the
>>> chance of having zombie threads is high.
>>
>> Hmm.  How about simply not restarting the loop if attach_lwp tries to attach to
>> a zombie lwp (and silently fails)?
>>
>> I.e., in gdb, make attach_proc_task_lwp_callback return false/0 here:
>>
>>       if (ptrace (PTRACE_ATTACH, lwpid, 0, 0) < 0)
>> 	{
>> 	  int err = errno;
>>
>> 	  /* Be quiet if we simply raced with the thread exiting.
>> 	     EPERM is returned if the thread's task still exists, and
>> 	     is marked as exited or zombie, as well as other
>> 	     conditions, so in that case, confirm the status in
>> 	     /proc/PID/status.  */
>> 	  if (err == ESRCH
>> 	      || (err == EPERM && linux_proc_pid_is_gone (lwpid)))
>> 	    {
>> 	      linux_nat_debug_printf
>> 		("Cannot attach to lwp %d: thread is gone (%d: %s)",
>> 		 lwpid, err, safe_strerror (err));
>>
>>               return 0;        <<<< NEW RETURN
>> 	    }
>>
>> Similar thing for gdbserver, of course.
> 
> Thank you for the suggestion. I tried doing that, and in fact I attached
> a patch with that change in comment #17 of PR 31312 when I was
> investigating a fix¹. I called it a workaround because I also had to
> increase the number of iterations in linux_proc_attach_tgid_threads from
> 2 to 100, otherwise GDB gives up on waiting for new inferior threads too
> early and the inferior dies with a SIGTRAP because some new unnoticed
> thread tripped into the breakpoint.
> 
> Because of the need to increase the number of iterations, I didn't
> consider it a good solution and went with the approach in this patch
> series instead. Now I finally understand why I had to increase the
> number of iterations (though I still don't see a way around it other
> than what this patch series does):
> 
> With the approach in this patch series, even if a new thread becomes
> zombie by the time GDB tries to attach to it, it still causes
> new_threads_found to be set the first time GDB notices it, and the loop
> in linux_proc_attach_tgid_threads starts over.
> 
> With the approach above, a new thread that becomes zombie before GDB has
> a chance to attach to it never causes the loop to start over, and so it
> exits earlier.
> 
> I think it's a matter of opinion whether one approach or the other can
> be considered the better one.
> 
> Even with this patch series, it's not guaranteed that two iterations
> without finding new threads is enough to ensure that GDB has found all
> threads in the inferior. I left the test running in a loop overnight
> with the patch series applied and it failed after about 2500 runs.

Thanks for all the investigations.  I hadn't seen the bugzilla before,
I didn't notice there was one identified in the patch.

Let me just start by saying "bleh"...

This is all of course bad ptrace/kernel design...  The only way to plug this race
completely is with kernel help, I believe.

The only way that I know of today that we can make the kernel pause all threads for
us, is with a group-stop.  I.e., pass a SIGSTOP to the inferior, and the kernel stops
_all_ threads with SIGSTOP.

I prototyped it today, and while far from perfect (would need to handle a corner
scenarios like attaching and getting back something != SIGSTOP, and I still see
some spurious SIGSTOPs), it kind of works ...

... except for what I think is a deal breaker that I don't know how to work around:

If you attach to a process that is running on a shell, you will see that the group-stop
makes it go to the background.  GDB resumes the process, but it won't go back to the
foreground without an explicit "fg" in the shell...  Like:

 $ ./test_program
 [1]+  Stopped                 ./test_program
 $

I'm pasting the incomplete patch below for the archives, but I'm not going to
pursue this further.  

Another idea I had was to look for the thread_db thread creation event breakpoint
address, and instead of putting a breakpoint there, put a "jmp $pc" instruction there.
That would halt creation of new pthreads.  But it wouldn't halt raw clones...

Maybe someone has some better idea.  Really the kernel should have a nice interface
for this.  

Thankfully this is a contrived test, no real program should be spawning threads
like this.  One would hope.

I will take a new look at your series.

From 9dad08eff6fc534964e457de7f99127354dfae44 Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>
Date: Wed, 17 Apr 2024 12:47:25 +0100
Subject: [PATCH] Force group-stop when attaching

Change-Id: I95bc82d2347af87c74a11ee9ddfc65b851f3e6c7
---
 gdb/linux-nat.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 2602e1f240d..c95b4370d1b 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1033,6 +1033,14 @@ linux_nat_post_attach_wait (ptid_t ptid, int *signalled)
 			      status_to_str (status).c_str ());
     }
 
+  /* Force the inferior into group-stop, so all threads are frozen by
+     the kernel, so we can attach to all of them, race-free.  */
+  ptrace (PTRACE_CONT, pid, 0, SIGSTOP);
+
+  /* */
+  pid_t pid2 = my_waitpid (pid, &status, __WALL);
+  gdb_assert (pid == pid2);
+
   return status;
 }
 
@@ -1231,6 +1239,31 @@ linux_nat_target::attach (const char *args, int from_tty)
       throw;
     }
 
+  /* Consume the group-stop SIGSTOP for every thread, and move them
+     into ptrace-stopped.  */
+  for (lwp_info *lwp : all_lwps_safe ())
+    {
+      if (lwp->ptid.pid () == lwp->ptid.lwp ())
+	continue;
+
+      int lwp_status;
+      int lwpid = lwp->ptid.lwp ();
+      pid_t ret = my_waitpid (lwpid, &lwp_status, __WALL);
+      gdb_assert (ret == lwpid);
+
+      gdb_assert (WIFSTOPPED (lwp_status));
+      gdb_assert (WSTOPSIG (lwp_status) == SIGSTOP);
+
+      /* If PTRACE_GETSIGINFO fails with EINVAL, then it is definitely
+	 a group-stop.  */
+      siginfo_t siginfo;
+      gdb_assert (!linux_nat_get_siginfo (lwp->ptid, &siginfo));
+      gdb_assert (errno == EINVAL);
+
+      kill_lwp (lwpid, SIGSTOP);
+      ptrace (PTRACE_CONT, lwpid, 0, 0);
+    }
+
   /* Add all the LWPs to gdb's thread list.  */
   iterate_over_lwps (ptid_t (ptid.pid ()),
 		     [] (struct lwp_info *lwp) -> int

base-commit: 2d4c39a885d4d12325d0a9be9e014e75a295fb25
-- 
2.43.2


^ permalink raw reply	[relevance 0%]

* Re: [PATCH] Use section name in DWARF error message
  @ 2024-04-17 14:48  0% ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-04-17 14:48 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: mark



On 2024-04-17 09:44, Tom Tromey wrote:
> A bug points out that a certain error message in read_str_index uses a
> hard-coded section name.  This patch changes it to use
> dwarf2_section_info::get_name instead, like the other errors in the
> function.
> 
> No test because it didn't seem worthwhile.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31639
> ---
>  gdb/dwarf2/read.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 061db8c2a2a..af69e1d9d9e 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -17469,8 +17469,9 @@ read_str_index (struct dwarf2_cu *cu,
>      str_offset = bfd_get_64 (abfd, info_ptr);
>    if (str_offset >= str_section->size)
>      error (_("Offset from %s pointing outside of"
> -	     " .debug_str.dwo section in CU at offset %s [in module %s]"),
> -	   form_name, sect_offset_str (cu->header.sect_off), objf_name);
> +	     " %s section in CU at offset %s [in module %s]"),
> +	   form_name, str_section->get_name (),
> +	   sect_offset_str (cu->header.sect_off), objf_name);
>    return (const char *) (str_section->buffer + str_offset);
>  }
>  

LGTM, thanks.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon

^ permalink raw reply	[relevance 0%]

* [PATCH v2] gdb: Change "list ." command's error when no debuginfo is available
@ 2024-04-16 20:00  5% Guinevere Larsen
  0 siblings, 0 replies; 200+ results
From: Guinevere Larsen @ 2024-04-16 20:00 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simark@simark.ca>

Currently, when a user tries to list the current location, there are 2
different error messages that can happen, either:

    (gdb) list .
    No symbol table is loaded.  Use the "file" command.
or
    (gdb) list .
    No debug information available to print source lines.

The difference here is if gdb can find any symtabs at all or not, which
is not something too important for end-users - and isn't informative at
all. This commit changes it so that the error always says that there
isn't debug information available, with these two variants:

    (gdb) list .
    No debug information available to print source lines at current PC (0x55555555511d).
or
    (gdb) list .
    No debug information available to print source lines at default location.

The difference now is if the inferior has started already, which is
controlled by the user and may be useful.

Unfortunately, it isn't as easy to differentiate if the symtab found for
other list parameters is correct, so other invocations, such as "list +"
still retain their original error message.

Co-Authored-By: Simon Marchi <simark@simark.ca>
---

Changes for v2:
  Added NEWS entry, should have done that from the start oops.
  Added test. This test aims to roughly recreate a situation where the
    current function is in a spot with no debuginfo, and being called
    from somewhere that has debuginfo.

---
 gdb/NEWS                                      |  6 ++
 gdb/cli/cli-cmds.c                            | 47 +++++++++----
 .../gdb.base/list-dot-nodebug-extra.c         | 24 +++++++
 gdb/testsuite/gdb.base/list-dot-nodebug.c     | 34 ++++++++++
 gdb/testsuite/gdb.base/list-dot-nodebug.exp   | 67 +++++++++++++++++++
 5 files changed, 164 insertions(+), 14 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/list-dot-nodebug-extra.c
 create mode 100644 gdb/testsuite/gdb.base/list-dot-nodebug.c
 create mode 100644 gdb/testsuite/gdb.base/list-dot-nodebug.exp

diff --git a/gdb/NEWS b/gdb/NEWS
index feb3a37393a..99909414796 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -36,6 +36,12 @@ set unwindonsignal on|off
 show unwindonsignal
   These commands are now aliases for the new set/show unwind-on-signal.
 
+list .
+  When using the command "list ." in a location that has no debug information
+  or no file loaded, GDB now says that there is no debug information to print
+  lines.  This makes it more obvious that there is no information, as opposed
+  to implying there is no inferior loaded.
+
 * New commands
 
 info missing-debug-handler
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 3afe2178199..a537a370cc2 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1235,37 +1235,39 @@ list_command (const char *arg, int from_tty)
   /* Pull in the current default source line if necessary.  */
   if (arg == NULL || ((arg[0] == '+' || arg[0] == '-' || arg[0] == '.') && arg[1] == '\0'))
     {
-      set_default_source_symtab_and_line ();
-      symtab_and_line cursal = get_current_source_symtab_and_line ();
-
       /* If this is the first "list" since we've set the current
 	 source line, center the listing around that line.  */
       if (get_first_line_listed () == 0 && (arg == nullptr || arg[0] != '.'))
 	{
-	  list_around_line (arg, cursal);
+	  set_default_source_symtab_and_line ();
+	  list_around_line (arg, get_current_source_symtab_and_line ());
 	}
 
       /* "l" and "l +" lists the next few lines, unless we're listing past
 	 the end of the file.  */
       else if (arg == nullptr || arg[0] == '+')
 	{
+	  set_default_source_symtab_and_line ();
+	  const symtab_and_line cursal = get_current_source_symtab_and_line ();
 	  if (last_symtab_line (cursal.symtab) >= cursal.line)
 	    print_source_lines (cursal.symtab,
 				source_lines_range (cursal.line), 0);
 	  else
-	    {
-	      error (_("End of the file was already reached, use \"list .\" to"
-		       " list the current location again"));
-	    }
+	    error (_("End of the file was already reached, use \"list .\" to"
+		     " list the current location again"));
 	}
 
       /* "l -" lists previous ten lines, the ones before the ten just
 	 listed.  */
       else if (arg[0] == '-')
 	{
+	  set_default_source_symtab_and_line ();
+	  const symtab_and_line cursal = get_current_source_symtab_and_line ();
+
 	  if (get_first_line_listed () == 1)
 	    error (_("Already at the start of %s."),
 		   symtab_to_filename_for_display (cursal.symtab));
+
 	  source_lines_range range (get_first_line_listed (),
 				    source_lines_range::BACKWARD);
 	  print_source_lines (cursal.symtab, range, 0);
@@ -1274,25 +1276,42 @@ list_command (const char *arg, int from_tty)
       /* "list ." lists the default location again.  */
       else if (arg[0] == '.')
 	{
+	  std::optional<const symtab_and_line> cursal;
 	  if (target_has_stack ())
 	    {
 	      /* Find the current line by getting the PC of the currently
 		 selected frame, and finding the line associated to it.  */
 	      frame_info_ptr frame = get_selected_frame (nullptr);
 	      CORE_ADDR curr_pc = get_frame_pc (frame);
-	      cursal = find_pc_line (curr_pc, 0);
+	      cursal.emplace (find_pc_line (curr_pc, 0));
+
+	      if (cursal->symtab == nullptr)
+		error
+		  (_("No debug information available to print source lines at "
+		     "current PC (%s)."), paddress (get_frame_arch (frame),
+						    curr_pc));
 	    }
 	  else
 	    {
 	      /* The inferior is not running, so reset the current source
 		 location to the default (usually the main function).  */
 	      clear_current_source_symtab_and_line ();
-	      set_default_source_symtab_and_line ();
-	      cursal = get_current_source_symtab_and_line ();
+	      try
+		{
+		  set_default_source_symtab_and_line ();
+		}
+	      catch (const gdb_exception &e)
+		{
+		  error (_("No debug information available to print source "
+			   "lines at default location"));
+		}
+	      cursal.emplace (get_current_source_symtab_and_line ());
+
+	      gdb_assert (cursal->symtab != nullptr);
 	    }
-	  if (cursal.symtab == nullptr)
-	    error (_("No debug information available to print source lines."));
-	  list_around_line (arg, cursal);
+
+	  list_around_line (arg, *cursal);
+
 	  /* Set the repeat args so just pressing "enter" after using "list ."
 	     will print the following lines instead of the same lines again. */
 	  if (from_tty)
diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug-extra.c b/gdb/testsuite/gdb.base/list-dot-nodebug-extra.c
new file mode 100644
index 00000000000..c3d2416e70d
--- /dev/null
+++ b/gdb/testsuite/gdb.base/list-dot-nodebug-extra.c
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+extern void bar(int *);
+
+void
+foo (int *x)
+{
+  bar (x);
+}
diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug.c b/gdb/testsuite/gdb.base/list-dot-nodebug.c
new file mode 100644
index 00000000000..5e1a09fa645
--- /dev/null
+++ b/gdb/testsuite/gdb.base/list-dot-nodebug.c
@@ -0,0 +1,34 @@
+/* main */
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+extern void foo (int *x);
+
+int x;
+
+void
+bar (int *p)
+{
+  *p++;
+}
+
+int
+main ()
+{
+  foo (&x);
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug.exp b/gdb/testsuite/gdb.base/list-dot-nodebug.exp
new file mode 100644
index 00000000000..7c4144da8ab
--- /dev/null
+++ b/gdb/testsuite/gdb.base/list-dot-nodebug.exp
@@ -0,0 +1,67 @@
+# Copyright 2005-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This test is here to confirm that the command "list ." will print the
+# same message if GDB detects no debug information at all, or detects some
+# but nothing for the current objfile.
+
+require !use_gdb_stub
+
+set linkflags [list additional_flags="-static"]
+
+if { ![gdb_can_simple_compile static-libc \
+	   {
+	       void main (void) { return 0; }
+	   } \
+	   executable $linkflags] } {
+    untested "Can't statically link"
+    return -1
+}
+
+standard_testfile .c -extra.c
+set objmainfile [standard_output_file ${testfile}-main.o]
+set objextrafile [standard_output_file ${testfile}-extra.o]
+
+if {[gdb_compile "$srcdir/$subdir/$srcfile" $objmainfile object {nodebug}] != "" } {
+    untested "couldn't compile main file into object"
+    return -1
+}
+
+foreach_with_prefix debug {"none" "some"} {
+
+    set flags "nodebug"
+    if {$debug == "some"} {
+	set flags "debug"
+    }
+
+    if {[prepare_for_testing_full "failed to prepare" \
+	    [list ${testfile}-${debug} $linkflags \
+		$srcfile [list nodebug] \
+		$srcfile2 [list $debug]]]} {
+	return -1
+    }
+
+    gdb_test "list ." \
+	"No debug information available to print source lines.*" \
+	"print before start"
+
+    if { ![runto bar] } {
+	return -1
+    }
+
+    gdb_test "list ." \
+	"No debug information available to print source lines at current PC.*" \
+	"print after start"
+}
-- 
2.44.0


^ permalink raw reply	[relevance 5%]

* Re: [PATCH v3 1/1] gdb: Fix assertion in 'value_primitive_field'
  @ 2024-04-16 17:52  0%   ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-16 17:52 UTC (permalink / raw)
  To: Stephan Rohr; +Cc: gdb-patches, aburgess, tom

>>>>> Stephan Rohr <stephan.rohr@intel.com> writes:

> From: "Rohr, Stephan" <stephan.rohr@intel.com>
> GDB asserts that the data location of a value's field with a dynamic
> data location is resolved when fetching the field's value in
> 'value_primitive_field'.  This assertion was hit because of bogus DWARF
> generated by the Intel Fortran compiler.  While that compiler should fix
> the DWARF, we prefer GDB to error out here instead, e.g. to allow the
> user to continue debugging other parts of the program.

I have been trying to understand this patch for a while but I really
don't.  Could you explain it in more detail, preferably in the commit
message?

> +	    DW_TAG_variable {
> +		{DW_AT_name var_a_invalid_location}
> +		{DW_AT_type :$struct_label}
> +		{DW_AT_location {
> +		    DW_OP_addr [gdb_target_symbol var_a]
> +		    DW_OP_deref
> +		    DW_OP_stack_value
> +		} SPECIAL_expr}
> +	    }

For example, I don't understand what is invalid about this.
It's weird for sure, but why is gdb's failure to evaluate it anything
other than a bug somewhere else in gdb?

In the "valid" case I see the field type being resolved.  Why doesn't
this happen in the invalid case?

> +	error (_("cannot read %s, expected an already resolved data "
> +		 "location."), arg_type->field (fieldno).name ());

This error shouldn't have a trailing ".", it makes the output look
weird:

$1 = {data = <error reading variable: cannot read data, expected an already resolved data location.>

Tom

^ permalink raw reply	[relevance 0%]

* [PATCH 3/5] Remove call to dwarf2_per_objfile::adjust from read_call_site_scope
  @ 2024-04-16 17:05  5% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-16 17:05 UTC (permalink / raw)
  To: gdb-patches

read_call_site_scope does not need to call 'adjust', because in
general the call site is not a symbol address, but rather just the
address of some particular call.
---
 gdb/dwarf2/read.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 9670f232f05..4168cec5c1a 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -10242,7 +10242,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 		 sect_offset_str (die->sect_off), objfile_name (objfile));
       return;
     }
-  unrelocated_addr pc = per_objfile->adjust (attr->as_address ());
+  unrelocated_addr pc = attr->as_address ();
 
   if (cu->call_site_htab == NULL)
     cu->call_site_htab = htab_create_alloc_ex (16, call_site::hash,
@@ -10417,10 +10417,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 			 "low pc, for referencing DIE %s [in module %s]"),
 		       sect_offset_str (die->sect_off), objfile_name (objfile));
 	  else
-	    {
-	      lowpc = per_objfile->adjust (lowpc);
-	      call_site->target.set_loc_physaddr (lowpc);
-	    }
+	    call_site->target.set_loc_physaddr (lowpc);
 	}
     }
   else

-- 
2.43.0


^ permalink raw reply	[relevance 5%]

* Re: [PATCH] gdb/make-target-delegates.py: don't handle "void" in parse_argtypes
  @ 2024-04-16 16:14  0%   ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-04-16 16:14 UTC (permalink / raw)
  To: John Baldwin, Simon Marchi, gdb-patches

On 4/16/24 12:06 PM, John Baldwin wrote:
> On 4/16/24 8:52 AM, Simon Marchi wrote:
>> From: Simon Marchi <simon.marchi@efficios.com>
>>
>> I suppose this was needed when we had `void` in declarations of methods
>> with no parameters.  If so, we no longer need it.
>>
>> Change-Id: I0a2b398408aa129634e2d73097a038f7f80db4b4
>> ---
>>   gdb/make-target-delegates.py | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/gdb/make-target-delegates.py b/gdb/make-target-delegates.py
>> index 4d18d2802ced..1893fc63ca84 100755
>> --- a/gdb/make-target-delegates.py
>> +++ b/gdb/make-target-delegates.py
>> @@ -149,8 +149,9 @@ def parse_argtypes(typestr: str):
>>       typestr = re.sub(r"^\((.*)\)$", r"\1", typestr)
>>       result: list[str] = []
>>       for item in re.split(r",\s*", typestr):
>> -        if item == "void" or item == "":
>> +        if item == "":
>>               continue
>> +
>>           m = ARGTYPES.match(item)
>>           if m:
>>               if m.group("E"):
>>
>> base-commit: 3f6a060c7543332d0cb4377fc318e2db01ea1d3c
> 
> Seems ok to me.  I assume it doesn't result in any differences in the generated
> code today?

Exactly.  I'll add a mention in the commit message.

> Approved-By: John Baldwin <jhb@FreeBSD.org>

Thanks, will push.

Simon

^ permalink raw reply	[relevance 0%]

* Re: [PATCH 3/3] gdb/record: minor clean, remove some unneeded arguments
  @ 2024-04-16 14:12  7%   ` Keith Seitz
  0 siblings, 0 replies; 200+ results
From: Keith Seitz @ 2024-04-16 14:12 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 4/15/24 07:19, Andrew Burgess wrote:
> I spotted that the two functions:
> 
>    record_full_open_1
>    record_full_core_open_1
> 
> both took two arguments, neither of which are used.

Nice catch. I've looked over this series, and I just have one really
trivial -- if not silly -- comment.

> diff --git a/gdb/record-full.c b/gdb/record-full.c
> index 4c3667f48ba..4ef85b0cdb6 100644
> --- a/gdb/record-full.c
> +++ b/gdb/record-full.c
> @@ -957,11 +957,14 @@ static void record_full_init_record_breakpoints (void);
>   /* Open the process record target.  */
>   
>   static void
> -record_full_open (const char *name, int from_tty)
> +record_full_open (const char *args, int from_tty)
>   {
>     if (record_debug)
>       gdb_printf (gdb_stdlog, "Process record: record_full_open\n");
>   
> +  if (args != nullptr)
> +    error (_("trailing junk: '%s'"), args);
> +
>     record_preopen ();
>   
>     /* Reset */

While I am no fan of this type of error, I understand the motive
in terms of consistency. Grep'ping for this string in gdb gives
numerous wordings of this type of error:

ada-lang.c:    error (_("Junk at end of expression"));
ada-lang.c:    error (_("Junk at end of arguments."));
break-catch-exec.c:    error (_("Junk at end of arguments."));
break-catch-fork.c:    error (_("Junk at end of arguments."));
break-catch-throw.c:    error (_("Junk at end of arguments."));
breakpoint.c:	    error (_("Junk at end of expression"));
breakpoint.c:		    error (_("Junk at end of expression"));
breakpoint.c:	    error (_("Junk after thread keyword."));
breakpoint.c:	    error (_("Junk after inferior keyword."));
breakpoint.c:	    error (_("Junk after task keyword."));
breakpoint.c:	error (_("Junk at end of arguments."));
breakpoint.c:		error (_("Junk after thread keyword."));
breakpoint.c:		error (_("Junk after task keyword."));
breakpoint.c:    error (_("Junk at end of command."));
breakpoint.c:    error (_("Junk at end of arguments."));
breakpoint.c:	error (_("Junk at end of arguments."));
btrace.c:    error (_("Junk after argument: %s."), arg);
linespec.c:    error (_("Junk at end of line specification: %s"), string);
linespec.c:    error (_("Junk at end of line specification: %s"), string);
parse.c:    error (_("Junk after end of expression."));
psymtab.c:	error (_("Junk at end of command"));
record-btrace.c:    error (_("Trailing junk: '%s'."), args);
record-btrace.c:    error (_("Trailing junk: '%s'."), args);
record-btrace.c:	error (_("Trailing junk: '%s'."), args + l2);
record-btrace.c:	error (_("Trailing junk: '%s'."), args + l1);
record-btrace.c:    error (_("Trailing junk: '%s'."), args);
record.c:    error (_("Junk after argument: %s."), arg);
record.c:    error (_("Junk after argument: %s."), arg);
record.c:    error (_("Junk after argument: %s."), arg);
symfile.c:	error (_("Junk after %s"), argv[1]);
symfile.c:	error (_("Junk after %s"), argv[0]);
symmisc.c:	error (_("Junk at end of command"));
symmisc.c:	error (_("Junk at end of command"));

So i guess as far as the record feature goes, the error message should
at least be "Trailing junk: %s". [Yeah, that is one heck of a silly nit,
isn't it?]

Otherwise, LGTM.

Keith


^ permalink raw reply	[relevance 7%]

* Re: [PATCH v5] gdb: Support embedded source in DWARF
  @ 2024-04-15 16:13  0%         ` Will Hawkins
  0 siblings, 0 replies; 200+ results
From: Will Hawkins @ 2024-04-15 16:13 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

On Sun, Apr 14, 2024 at 3:15 AM Will Hawkins <hawkinsw@obs.cr> wrote:
>
> On Sun, Apr 14, 2024 at 3:01 AM Tom de Vries <tdevries@suse.de> wrote:
> >
> > On 4/14/24 04:50, Will Hawkins wrote:
> > > On Fri, Apr 12, 2024 at 4:12 PM Tom de Vries <tdevries@suse.de> wrote:
> > >>
> > >> On 4/12/24 20:55, Will Hawkins wrote:
> > >>> +         DW_LNE_set_address main_end
> > >>> +         line [gdb_get_line_number "main end"]
> > >>> +         DW_LNS_copy
> > >>> +
> > >>> +         DW_LNE_end_sequence
> > >>> +     }
> > >> I've just submitted a patch series designed to catch this (
> > >> https://sourceware.org/pipermail/gdb-patches/2024-April/207922.html ).
> > >>
> > >> The copy produces a line table entry with empty address range (because
> > >> the end_sequence is at the same address),.
> > >>
> > >> This is probably not what you intended.
> > >
> > > What I get for doing copy/paste! A v6 is on its way! Thank you for the
> > > eagle eyes!
> > >
> >
> > It's just that I spent some time fixing all test-cases with this
> > problem, so I happened to spot it.  Anyway, thanks for following up.
> >
> > > On a semi-related note, it appears that "many" of the dwarf2 tests do
> > > not properly specify
> > >
> > > add_dummy_cus 0
> > >
> > > in their invocation of Dwarf::assemble resulting in two CUs being
> > > generated in the .S file. This does not appear to cause problems for
> > > the tests, but if you run the generated binaries through a "dwarf
> > > validator", e.g., llvm-dwarfdump, they will report errors. I have
> > > requested an account on the gdb bugzilla to report a bug and will file
> > > a related patch as a fix, if that is okay with you?
> >
> > The dummy cu's are there by default, intentionally, as explained here (
> > https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=5ef670d81fd222ae5edfa1428ad48710f5e10d35
> > ).  In brief, it tries to make sure that when writing a dwarf assembly
> > test-case on one platform it will work on another.
> >
> > If this causes problems with llvm-dwarfdump, we can look into fixing
> > that.  So, yes, please file a PR.
> >
> > But I'd look into a way of fixing this that doesn't require
> > "add_dummy_cus 0".
>
> Interesting. So, as I understand it, forcing CUs for the file being
> compiled (hello.c in the example you cited) to be somewhere other than
> the beginning of the .debug_info sections allowed you to catch
> additional bugs. In order to draw out similar bugs on platforms where
> the "main" CU goes first by default, you added the dummy CU feature.
> Am I understanding that correctly? If so, that's really neat.

FYI for Tom, the problem is with llvm-dwarfdump and I am currently in
the process of opening a PR with a fix.

Sincerely,
Will


>
> I will file a bug and then work on PR that makes the dummy cu feature
> "compatible" with llvm-dwarfdump. It could obviously also be an issue
> with the llvm-dwarfdump tool, too. I have contributed to LLDB, too,
> and would be more than happy to work with them if the problems is
> really in their tool.
>
> Thank you for the follow up!
> Will
>
>
> >
> > Thanks,
> > - Tom
> >

^ permalink raw reply	[relevance 0%]

* Re: [PATCH] gdb/linux-nat: Fix mem access ptrace fallback (PR threads/31579)
  @ 2024-04-15 16:05  0%     ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-15 16:05 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Andrew Burgess, gdb-patches

>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:

>> s/NULL/nullptr/ ?

Pedro> Personally, I prefer writing NULL in comments than nullptr, because saying (I mean,
Pedro> imagine reading the comment aloud) "null ptr" is kind of awkward, in my mind.
Pedro> It see it more as NULL meaning "the null pointer value", i.e., the word "null"
Pedro> uppercased, than literally the NULL macro.  I've seen other patches from others
Pedro> using NULL in comments so I thought it was other's preference as well.

Yeah, I prefer this in comments as well.  I'm not really sure why but
maybe because the all-caps makes it more distinct.

Tom

^ permalink raw reply	[relevance 0%]

* [PATCH 2/2] sim: riscv: Simplify the signed div by -1 code
@ 2024-04-15 14:46  7% Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-15 14:46 UTC (permalink / raw)
  To: gdb-patches

This uses the idea from the previous patch to
simplify the code for non-overflowing signed
divisions by -1.  This is no bug-fix but it
simplifies the code and avoids some unnecessary
branches.
---
 sim/riscv/sim-main.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
index 515ff835223..e4b15b533ba 100644
--- a/sim/riscv/sim-main.c
+++ b/sim/riscv/sim-main.c
@@ -700,18 +700,16 @@ execute_m (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
   const char *rd_name = riscv_gpr_names_abi[rd];
   const char *rs1_name = riscv_gpr_names_abi[rs1];
   const char *rs2_name = riscv_gpr_names_abi[rs2];
-  unsigned_word tmp, dividend_max;
+  unsigned_word tmp;
   sim_cia pc = riscv_cpu->pc + 4;
 
-  dividend_max = -((unsigned_word) 1 << (WITH_TARGET_WORD_BITSIZE - 1));
-
   switch (op->match)
     {
     case MATCH_DIV:
       TRACE_INSN (cpu, "div %s, %s, %s;  // %s = %s / %s",
 		  rd_name, rs1_name, rs2_name, rd_name, rs1_name, rs2_name);
-      if (riscv_cpu->regs[rs1] == dividend_max && riscv_cpu->regs[rs2] == -1)
-	tmp = dividend_max;
+      if (riscv_cpu->regs[rs2] == -1)
+	tmp = -riscv_cpu->regs[rs1];
       else if (riscv_cpu->regs[rs2])
 	tmp = (signed_word) riscv_cpu->regs[rs1] /
 	  (signed_word) riscv_cpu->regs[rs2];
@@ -793,7 +791,7 @@ execute_m (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
     case MATCH_REM:
       TRACE_INSN (cpu, "rem %s, %s, %s;  // %s = %s %% %s",
 		  rd_name, rs1_name, rs2_name, rd_name, rs1_name, rs2_name);
-      if (riscv_cpu->regs[rs1] == dividend_max && riscv_cpu->regs[rs2] == -1)
+      if (riscv_cpu->regs[rs2] == -1)
 	tmp = 0;
       else if (riscv_cpu->regs[rs2])
 	tmp = (signed_word) riscv_cpu->regs[rs1]
-- 
2.39.2


^ permalink raw reply	[relevance 7%]

* [PATCH 1/2] sim: riscv: fix a divw division by -1 bug
@ 2024-04-15 14:46  4% Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-15 14:46 UTC (permalink / raw)
  To: gdb-patches

There is a bug in divw for riscv64 target
with dividing by -1, the result was always 0,
when it should in fact be sign-extended -dividend.
It did not affect the rv32 target, because
these instructions are rv64 only.
Since 1 << 31 is an integer overflow this avoids
an undefined behaviour bug at the same time.

This caused test failures in the gcc testsuite like:

FAIL: gcc.c-torture/execute/arith-rand-ll.c   -O0  execution test
FAIL: gcc.c-torture/execute/arith-rand-ll.c   -O1  execution test
FAIL: gcc.c-torture/execute/arith-rand-ll.c   -O2  execution test
FAIL: gcc.c-torture/execute/arith-rand-ll.c   -O3  execution test
FAIL: gcc.c-torture/execute/arith-rand.c   -O0  execution test
FAIL: gcc.c-torture/execute/arith-rand.c   -O1  execution test
FAIL: gcc.c-torture/execute/arith-rand.c   -O2  execution test
FAIL: gcc.c-torture/execute/arith-rand.c   -O3  execution test
...
---
 sim/riscv/sim-main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
index c8adb65139b..515ff835223 100644
--- a/sim/riscv/sim-main.c
+++ b/sim/riscv/sim-main.c
@@ -724,7 +724,7 @@ execute_m (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
 		  rd_name, rs1_name, rs2_name, rd_name, rs1_name, rs2_name);
       RISCV_ASSERT_RV64 (cpu, "insn: %s", op->name);
       if (EXTEND32 (riscv_cpu->regs[rs2]) == -1)
-	tmp = 1 << 31;
+	tmp = EXTEND32 (-(uint32_t) riscv_cpu->regs[rs1]);
       else if (EXTEND32 (riscv_cpu->regs[rs2]))
 	tmp = EXTEND32 (riscv_cpu->regs[rs1]) / EXTEND32 (riscv_cpu->regs[rs2]);
       else
-- 
2.39.2


^ permalink raw reply	[relevance 4%]

* Re: [PATCH] sim: riscv: Fix confusion with c.jal vs. c.addiw
  @ 2024-04-15  9:05  0%   ` Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-15  9:05 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 4/15/24 10:56, Andrew Burgess wrote:
> Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
> 
>> There was apparently a confusion which cpu model uses
>> compressed JAL and which ADDIW.  Fixed that in execute_c,
>> case MATCH_C_JAL | MATCH_C_ADDIW.
>>
>> Fixes 3224e32fb84f ("sim: riscv: Add support for compressed integer
>> instructions")
> 
> Thanks for splitting this off.  This looks good.
> 
> Approved-By: Andrew Burgess <aburgess@redhat.com>
> 

Okay, no problem.  Pushed.

Thanks
Bernd.

> Thanks,
> Andrew
> 
> 
>> ---
>>  sim/riscv/sim-main.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
>> index adff99921c6..9fd2cc70657 100644
>> --- a/sim/riscv/sim-main.c
>> +++ b/sim/riscv/sim-main.c
>> @@ -1016,9 +1016,9 @@ execute_c (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>        TRACE_BRANCH (cpu, "to %#" PRIxTW, pc);
>>        break;
>>      case MATCH_C_JAL | MATCH_C_ADDIW:
>> -      /* JAL and ADDIW have the same mask but are only available on RV64 or
>> -	 RV32 respectively.  */
>> -      if (RISCV_XLEN (cpu) == 64)
>> +      /* JAL and ADDIW have the same mask but are only available on RV32 or
>> +	 RV64 respectively.  */
>> +      if (RISCV_XLEN (cpu) == 32)
>>  	{
>>  	  imm = EXTRACT_CJTYPE_IMM (iw);
>>  	  TRACE_INSN (cpu, "c.jal %" PRIxTW,
>> @@ -1027,7 +1027,7 @@ execute_c (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>  	  pc = riscv_cpu->pc + imm;
>>  	  TRACE_BRANCH (cpu, "to %#" PRIxTW, pc);
>>  	}
>> -      else if (RISCV_XLEN (cpu) == 32)
>> +      else if (RISCV_XLEN (cpu) == 64)
>>  	{
>>  	  imm = EXTRACT_CITYPE_IMM (iw);
>>  	  TRACE_INSN (cpu, "c.addiw %s, %s, %#" PRIxTW ";  // %s += %#" PRIxTW,
>> -- 
>> 2.39.2
> 

^ permalink raw reply	[relevance 0%]

* [PATCH v2 1/2] Make linux checkpoints work with multiple inferiors
  @ 2024-04-14  3:24 10% ` Kevin Buettner
  0 siblings, 0 replies; 200+ results
From: Kevin Buettner @ 2024-04-14  3:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves, Kevin Buettner

The current linux checkpoint code, most of which may be found in
linux-fork.c, is quite broken when attempting to use more than
one inferior.  Running GDB will show internal errors when starting
two inferiors, placing a checkpoint in one, then switching to
the other and doing one of the following commands, "restart",
"detach", "kill", or continue (to program exit).  Test cases
for two of those scenarios may be found in this bug:

    https://sourceware.org/bugzilla/show_bug.cgi?id=31065

I've tested for each of the scenarios and many more in the new
test case, gdb.multi/checkpoint-multi.exp.

I started off with the goal of fixing just those problems, and was
mostly successful with a much smaller patch, but doing "info
checkpoints" with more than one inferior didn't work correctly due to
some of the inferiors being in the wrong program space.  That led me
to making the linux-fork code fully inferior-aware.

Prior to this commit, the list of forks was being maintained in a
global named named 'fork_list'.  I turned this into a per-inferior
data structure.  There was also global named 'highest_fork_num' which
is also now part of the per-inferior struct.  A registry key named
'checkpoint_inferior_data_key' along with function
'get_checkpoint_inferior_data' is used to access the per-inferior
data.  This new function, get_checkpoint_inferior_data, is only
called by the new functions 'fork_list' and 'highest_fork_num', each
of which is passed a pointer to the inferior.  Most occurrences
referring to the (previously) global 'fork_list' have been replaced
by 'fork_list (inf)'.  In some functions, where the 'fork_list' is
referenced multiple times, a local named 'fork_list' is declared and
initialized instead, like this:

    auto &fork_list = ::fork_list (inf);

The constructor for 'struct fork_info' has gained an additional
parameter.  In addition to passing the pid of the new fork, we now
also pass the fork identifier, fork_num, to the constructor.  This
integer is shown to the user in the "info checkpoints" command and
is provided by the user, perhaps in conjunction with the inferior
number, in commands which manipulate checkpoints, e.g. 'restart' and
'delete checkpoint'.

When checkpoints are used in only one inferior, this commit will
present information to the user and will accept checkpoint identifiers
to commands in much the same way as the code did before this commit.
Per Pedro Alves's recommendations, the "info checkpoints" command
has been changed somewhat.  "info checkpoints" used to display
"(main process)" for the first process in the checkpoint list.
This is no longer done because it does not provide useful information.
It also used to display "<running>", presumably when in non-stop
mode.  I've changed this to print a state flag 'R'.  Additionally,
a state flag 'A' is used to indicate the active checkpoint for
each inferior.  For the active inferior a '*' is also printed
preceding the checkpoint identifier.  Here's what things look(ed)
like before and after for just one inferior:

Before:

(gdb) info checkpoints
* 0 Thread 0x7ffff7cd3740 (LWP 84201) (main process) at 0x40114a, file hello.c, line 28
  1 process 84205 at 0x401199, file hello.c, line 51
  2 process 84206 at 0x4011a3, file hello.c, line 53

After:

(gdb) info checkpoints
*  0 A  process 84159 at 0x40114a, file hello.c, line 28
   1    process 84162 at 0x401199, file hello.c, line 51
   2    process 84163 at 0x4011a3, file hello.c, line 53

(The Thread versus process distinction is handled by another
patch - the "After" example assumes that patch is applied too.)

When there are multiple inferiors, the "info checkpoints" output looks
like this:

(gdb) info checkpoints
   1.0    process 84159 at 0x40114a, file hello.c, line 28
*  1.1 A  process 84162 at 0x401199, file hello.c, line 51
   1.2    process 84163 at 0x4011a3, file hello.c, line 53
   2.0 A  process 84223 at 0x40116f, file hangout.c, line 35
   2.1    process 84224 at 0x40115c, file hangout.c, line 31
   2.2    process 84225 at 0x401166, file hangout.c, line 33
   3.0 A  process 84226 at 0x401218, file goodbye.c, line 46
   3.1    process 84229 at 0x40124e, file goodbye.c, line 61

A new function named 'parse_checkpoint_id' has been added.  As its
name suggests, it's responsible for parsing a string representing a
checkpoint identifier.  These identifiers may be either a decimal
number representing the checkpoint number in the current inferior or
two decimal numbers separated by '.', in which case the first is the
inferior number and the second is the checkpoint number in that
inferior.  It is called by delete_checkpoint_command,
detach_checkpoint_command, info_checkpoints_command, and
restart_command.  Calls to 'parse_checkpoint_id' replace calls to
'parse_and_eval_long', plus error checking and error reporting code
near the calls to 'parse_and_eval_long'.  As such, error checking and
reporting has been consolidated into a single function and the
messages output are more uniform, though this has necessitated changes
to the existing test case gdb.base/checkpoint.exp.

The functions 'find_fork_ptid' and 'find_fork_pid' used to return a
pointer to a fork_info struct.  They now return a pair consisting of
the pointer to a fork_info struct in addition to a pointer to the
inferior containing that checkpoint.

'find_fork_id' returns a a pointer to a fork_info struct just as
it did before, but it's now gained a new parameter, 'inf', which
is the inferior in which to look.

info_checkpoints_command used to simply iterate over the list of
forks (checkpoints), printing each one out.  It now needs to iterate
over all inferiors and, for those which have checkpoints, it needs
to iterate over the list of checkpoints in that inferior.  As noted
earlier, the format of the output has been changed so that checkpoint
identifers incorporating an inferior number may be printed.

linux_fork_context, called by restart_command, now contains code to
switch inferiors when the fork being restarted is in a different
inferior from the current one.  The scoped_switch_fork_info class now
also contains code for switching inferiors in both the constructor and
destructor.

gdb/linux-nat.c has a few changes.  All but one of them are related
to passing the inferior to one of the linux-fork functions.  But
one of the tests in linux_nat_target::detach has also changed in
a non-obvious way.  In attempting to determine whether to call
linux_fork_detach(), that code used to do:

  if (pid == inferior_ptid.pid () && forks_exist_p ())

It's been simplified to:

  if (forks_exist_p (inf))

I had added the 'pid == inferior_ptid.pid ()' condition in late 2023
while working on a detach bug.  It was kind of a hack to prevent
calling linux_fork_detach() when in a different inferior.  That's no
longer needed since the call to forks_exist_p does this directly -
i.e. it is now inferior-aware.

Finally, the header file 'linux-fork.h' has been updated to reflect
the fact that add_fork, linux_fork_killall, linux_fork_mourn_inferior,
linux_fork_detach, and forks_exist_p all now require that a pointer to
an inferior be passed to these functions.  Additionally (as mentioned
earlier), find_fork_pid now returns std::pair<fork_info *, inferior *>
instead 'of fork_info *'.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31065
---
 gdb/linux-fork.c                             | 517 +++++++++-----
 gdb/linux-fork.h                             |  15 +-
 gdb/linux-nat.c                              |  20 +-
 gdb/testsuite/gdb.base/checkpoint.exp        |  26 +-
 gdb/testsuite/gdb.multi/checkpoint-multi.exp | 687 +++++++++++++++++++
 5 files changed, 1079 insertions(+), 186 deletions(-)
 create mode 100644 gdb/testsuite/gdb.multi/checkpoint-multi.exp

diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index bb8119a36d0..d21ab8e567e 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -28,6 +28,7 @@
 #include "linux-nat.h"
 #include "gdbthread.h"
 #include "source.h"
+#include "progspace-and-thread.h"
 
 #include "nat/gdb_ptrace.h"
 #include "gdbsupport/gdb_wait.h"
@@ -38,10 +39,11 @@
 #include <list>
 
 /* Fork list data structure:  */
+
 struct fork_info
 {
-  explicit fork_info (pid_t pid)
-    : ptid (pid, pid)
+  explicit fork_info (pid_t pid, int fork_num)
+    : ptid (pid, pid), num (fork_num)
   {
   }
 
@@ -69,7 +71,7 @@ struct fork_info
   ptid_t parent_ptid = null_ptid;
 
   /* Convenient handle (GDB fork id).  */
-  int num = 0;
+  int num;
 
   /* Convenient for info fork, saves having to actually switch
      contexts.  */
@@ -83,115 +85,253 @@ struct fork_info
   int maxfd = 0;
 };
 
-static std::list<fork_info> fork_list;
-static int highest_fork_num;
+/* Per-inferior checkpoint data.  */
+
+struct checkpoint_inferior_data
+{
+  /* List of forks (checkpoints) in particular inferior.  Once a
+     checkpoint has been created, fork_list will contain at least two
+     items, the first in the list will be the original (or, if not
+     original, then the oldest) fork.  */
+  std::list<fork_info> fork_list;
+
+  /* Most recently assigned fork number; when 0, no checkpoints have
+     been created yet.  */
+  int highest_fork_num = 0;
+};
+
+/* Per-inferior data key.  */
+
+static const registry<inferior>::key<checkpoint_inferior_data>
+  checkpoint_inferior_data_key;
+
+/* Fetch per-inferior checkpoint data.  It always returns a valid pointer
+   to a checkpoint_inferior_info struct.  */
+
+static struct checkpoint_inferior_data *
+get_checkpoint_inferior_data (struct inferior *inf)
+{
+  struct checkpoint_inferior_data *data;
+
+  data = checkpoint_inferior_data_key.get (inf);
+  if (data == nullptr)
+    data = checkpoint_inferior_data_key.emplace (inf);
+
+  return data;
+}
+
+/* Return a reference to the per-inferior fork list.  */
+
+static std::list<fork_info> &
+fork_list (inferior *inf)
+{
+  return get_checkpoint_inferior_data (inf)->fork_list;
+}
+
+/* Return a reference to 'highest_fork_num' for the given inferior INF.  */
+
+static int &
+highest_fork_num (inferior *inf)
+{
+  return get_checkpoint_inferior_data (inf)->highest_fork_num;
+}
+
+/* Predicate which returns true when more than one inferior contains
+   a checkpoint, false otherwise.  */
+
+static bool
+forks_exist_in_multiple_inferiors_p ()
+{
+  int count = 0;
+  for (inferior *inf : all_inferiors ())
+    {
+      if (forks_exist_p (inf))
+	count++;
+      if (count > 1)
+	return true;
+    }
+  return false;
+}
 
 /* Fork list methods:  */
 
-int
-forks_exist_p (void)
+/* Predicate which returns true if checkpoint(s) exist in the inferior
+   INF, false otherwise.  */
+
+bool
+forks_exist_p (inferior *inf)
 {
-  return !fork_list.empty ();
+  return !fork_list (inf).empty ();
 }
 
-/* Return the last fork in the list.  */
+/* Return the last fork in the list for inferior INF.  */
 
 static struct fork_info *
-find_last_fork (void)
+find_last_fork (inferior *inf)
 {
+  auto &fork_list = ::fork_list (inf);
+
   if (fork_list.empty ())
     return NULL;
 
   return &fork_list.back ();
 }
 
-/* Return true iff there's one fork in the list.  */
+/* Return true iff there's one fork in the list for inferior INF.  */
 
 static bool
-one_fork_p ()
+one_fork_p (inferior *inf)
 {
-  return fork_list.size () == 1;
+  return fork_list (inf).size () == 1;
 }
 
 /* Add a new fork to the internal fork list.  */
 
 void
-add_fork (pid_t pid)
+add_fork (pid_t pid, inferior *inf)
 {
-  fork_list.emplace_back (pid);
-
-  if (one_fork_p ())
-    highest_fork_num = 0;
-
-  fork_info *fp = &fork_list.back ();
-  fp->num = ++highest_fork_num;
+  fork_list (inf).emplace_back (pid, ++highest_fork_num (inf));
 }
 
+/* Delete a fork for PTID in inferior INF.  When the last fork is
+   deleted, HIGHEST_FORK_NUM for the given inferior is reset to 0.
+   The fork list may also be made to be empty when only one fork
+   remains.  */
+
 static void
-delete_fork (ptid_t ptid)
+delete_fork (ptid_t ptid, inferior *inf)
 {
   linux_target->low_forget_process (ptid.pid ());
 
+  auto &fork_list = ::fork_list (inf);
   for (auto it = fork_list.begin (); it != fork_list.end (); ++it)
     if (it->ptid == ptid)
       {
 	fork_list.erase (it);
 
+	if (fork_list.empty ())
+	  {
+	    /* Reset highest_fork_num.  */
+	    highest_fork_num (inf) = 0;
+	  }
+
 	/* Special case: if there is now only one process in the list,
 	   and if it is (hopefully!) the current inferior_ptid, then
 	   remove it, leaving the list empty -- we're now down to the
 	   default case of debugging a single process.  */
-	if (one_fork_p () && fork_list.front ().ptid == inferior_ptid)
+	if (one_fork_p (inf) && fork_list.front ().ptid == inferior_ptid)
 	  {
 	    /* Last fork -- delete from list and handle as solo
 	       process (should be a safe recursion).  */
-	    delete_fork (inferior_ptid);
+	    delete_fork (inferior_ptid, inf);
 	  }
 	return;
       }
 }
 
-/* Find a fork_info by matching PTID.  */
-static struct fork_info *
+/* Find a fork_info and inferior by matching PTID.  */
+
+static std::pair<fork_info *, inferior *>
 find_fork_ptid (ptid_t ptid)
 {
-  for (fork_info &fi : fork_list)
-    if (fi.ptid == ptid)
-      return &fi;
+  for (inferior *inf : all_inferiors ())
+    {
+      for (fork_info &fi : fork_list (inf))
+	if (fi.ptid == ptid)
+	  return { &fi, inf };
+    }
 
-  return NULL;
+  return { nullptr, nullptr };
 }
 
-/* Find a fork_info by matching ID.  */
-static struct fork_info *
-find_fork_id (int num)
+/* Find a fork_info by matching NUM in inferior INF.  */
+
+static fork_info *
+find_fork_id (inferior *inf, int num)
 {
-  for (fork_info &fi : fork_list)
+  for (fork_info &fi : fork_list (inf))
     if (fi.num == num)
       return &fi;
 
-  return NULL;
+  return nullptr;
 }
 
-/* Find a fork_info by matching pid.  */
-extern struct fork_info *
+/* Find a fork_info and inferior by matching pid.  */
+
+extern std::pair<fork_info *, inferior *>
 find_fork_pid (pid_t pid)
 {
-  for (fork_info &fi : fork_list)
-    if (pid == fi.ptid.pid ())
-      return &fi;
+  for (inferior *inf : all_inferiors ())
+    {
+      for (fork_info &fi : fork_list (inf))
+	if (pid == fi.ptid.pid ())
+	  return { &fi, inf };
+    }
 
-  return NULL;
+  return { nullptr, nullptr };
 }
 
-static ptid_t
-fork_id_to_ptid (int num)
+/* Parse a command argument representing a checkpoint id.  This
+   can take one of two forms:
+
+   Num
+
+   -or-
+
+   Inf.Num
+
+   where Num is a non-negative decimal integer and Inf, if present, is
+   a positive decimal integer.
+   
+   Return a pair with a pointer to the fork_info struct and pointer
+   to the inferior.  This function will throw an error if there's
+   a problem with the parsing or if either the inferior or checkpoint
+   id does not exist. */
+
+static std::pair<fork_info *, inferior *>
+parse_checkpoint_id (const char *ckptstr)
 {
-  struct fork_info *fork = find_fork_id (num);
-  if (fork)
-    return fork->ptid;
+  const char *number = ckptstr;
+  const char *p1;
+  struct inferior *inf;
+
+  const char *dot = strchr (number, '.');
+
+  if (dot != nullptr)
+    {
+      /* Parse number to the left of the dot.  */
+      int inf_num;
+
+      p1 = number;
+      inf_num = get_number_trailer (&p1, '.');
+      if (inf_num <= 0)
+	error (_("Inferior number must be a positive integer"));
+
+      inf = find_inferior_id (inf_num);
+      if (inf == NULL)
+	error (_("No inferior number '%d'"), inf_num);
+
+      p1 = dot + 1;
+    }
   else
-    return ptid_t (-1);
+    {
+      inf = current_inferior ();
+      p1 = number;
+    }
+
+  int fork_num = get_number_trailer (&p1, 0);
+  if (fork_num < 0)
+    error (_("Checkpoint number must be a non-negative integer"));
+
+  if (!forks_exist_p (inf))
+    error (_("Inferior %d has no checkpoints"), inf->num);
+
+  auto fork_ptr = find_fork_id (inf, fork_num);
+  if (fork_ptr == nullptr)
+    error (_("Invalid checkpoint number %d for inferior %d"),
+           fork_num, inf->num);
+
+  return { fork_ptr, inf };
 }
 
 /* Fork list <-> gdb interface.  */
@@ -296,7 +436,7 @@ fork_save_infrun_state (struct fork_info *fp)
 /* Kill 'em all, let God sort 'em out...  */
 
 void
-linux_fork_killall (void)
+linux_fork_killall (inferior *inf)
 {
   /* Walk list and kill every pid.  No need to treat the
      current inferior_ptid as special (we do not return a
@@ -304,6 +444,7 @@ linux_fork_killall (void)
      or a parent, so may get a SIGCHLD from a previously
      killed child.  Wait them all out.  */
 
+  auto &fork_list = ::fork_list (inf);
   for (fork_info &fi : fork_list)
     {
       pid_t pid = fi.ptid.pid ();
@@ -322,6 +463,7 @@ linux_fork_killall (void)
 
   /* Clear list, prepare to start fresh.  */
   fork_list.clear ();
+  highest_fork_num (inf) = 0;
 }
 
 /* The current inferior_ptid has exited, but there are other viable
@@ -329,7 +471,7 @@ linux_fork_killall (void)
    first available.  */
 
 void
-linux_fork_mourn_inferior (void)
+linux_fork_mourn_inferior (inferior *inf)
 {
   struct fork_info *last;
   int status;
@@ -341,23 +483,23 @@ linux_fork_mourn_inferior (void)
   waitpid (inferior_ptid.pid (), &status, 0);
 
   /* OK, presumably inferior_ptid is the one who has exited.
-     We need to delete that one from the fork_list, and switch
+     We need to delete that one from the fork list, and switch
      to the next available fork.  */
-  delete_fork (inferior_ptid);
+  delete_fork (inferior_ptid, inf);
 
   /* There should still be a fork - if there's only one left,
      delete_fork won't remove it, because we haven't updated
      inferior_ptid yet.  */
-  gdb_assert (!fork_list.empty ());
+  gdb_assert (!fork_list (inf).empty ());
 
-  last = find_last_fork ();
+  last = find_last_fork (inf);
   fork_load_infrun_state (last);
   gdb_printf (_("[Switching to %s]\n"),
 	      target_pid_to_str (inferior_ptid).c_str ());
 
   /* If there's only one fork, switch back to non-fork mode.  */
-  if (one_fork_p ())
-    delete_fork (inferior_ptid);
+  if (one_fork_p (inf))
+    delete_fork (inferior_ptid, inf);
 }
 
 /* The current inferior_ptid is being detached, but there are other
@@ -365,13 +507,13 @@ linux_fork_mourn_inferior (void)
    the first available.  */
 
 void
-linux_fork_detach (int from_tty, lwp_info *lp)
+linux_fork_detach (int from_tty, lwp_info *lp, inferior *inf)
 {
   gdb_assert (lp != nullptr);
   gdb_assert (lp->ptid == inferior_ptid);
 
   /* OK, inferior_ptid is the one we are detaching from.  We need to
-     delete it from the fork_list, and switch to the next available
+     delete it from the fork list, and switch to the next available
      fork.  But before doing the detach, do make sure that the lwp
      hasn't exited or been terminated first.  */
 
@@ -384,11 +526,12 @@ linux_fork_detach (int from_tty, lwp_info *lp)
 	       target_pid_to_str (inferior_ptid).c_str ());
     }
 
-  delete_fork (inferior_ptid);
+  delete_fork (inferior_ptid, inf);
 
   /* There should still be a fork - if there's only one left,
      delete_fork won't remove it, because we haven't updated
      inferior_ptid yet.  */
+  auto &fork_list = ::fork_list (inf);
   gdb_assert (!fork_list.empty ());
 
   fork_load_infrun_state (&fork_list.front ());
@@ -398,8 +541,8 @@ linux_fork_detach (int from_tty, lwp_info *lp)
 		target_pid_to_str (inferior_ptid).c_str ());
 
   /* If there's only one fork, switch back to non-fork mode.  */
-  if (one_fork_p ())
-    delete_fork (inferior_ptid);
+  if (one_fork_p (inf))
+    delete_fork (inferior_ptid, inf);
 }
 
 /* Temporarily switch to the infrun state stored on the fork_info
@@ -412,19 +555,26 @@ class scoped_switch_fork_info
   /* Switch to the infrun state held on the fork_info identified by
      PPTID.  If PPTID is the current inferior then no switch is done.  */
   explicit scoped_switch_fork_info (ptid_t pptid)
-    : m_oldfp (nullptr)
+    : m_oldfp (nullptr), m_oldinf (nullptr)
   {
     if (pptid != inferior_ptid)
       {
-	struct fork_info *newfp = nullptr;
-
 	/* Switch to pptid.  */
-	m_oldfp = find_fork_ptid (inferior_ptid);
+	auto [oldfp, oldinf] = find_fork_ptid (inferior_ptid);
+	m_oldfp = oldfp;
 	gdb_assert (m_oldfp != nullptr);
-	newfp = find_fork_ptid (pptid);
+	auto [newfp, newinf]  = find_fork_ptid (pptid);
 	gdb_assert (newfp != nullptr);
 	fork_save_infrun_state (m_oldfp);
 	remove_breakpoints ();
+
+	if (oldinf != newinf)
+	  {
+	    thread_info *tp = any_thread_of_inferior (newinf);
+	    switch_to_thread (tp);
+	    m_oldinf = oldinf;
+	  }
+
 	fork_load_infrun_state (newfp);
 	insert_breakpoints ();
       }
@@ -434,12 +584,17 @@ class scoped_switch_fork_info
      didn't need to switch states, then nothing is done here either.  */
   ~scoped_switch_fork_info ()
   {
-    if (m_oldfp != nullptr)
+    if (m_oldinf != nullptr || m_oldfp != nullptr)
       {
 	/* Switch back to inferior_ptid.  */
 	try
 	  {
 	    remove_breakpoints ();
+	    if (m_oldinf != nullptr)
+	      {
+		thread_info *tp = any_thread_of_inferior (m_oldinf);
+		switch_to_thread (tp);
+	      }
 	    fork_load_infrun_state (m_oldfp);
 	    insert_breakpoints ();
 	  }
@@ -471,6 +626,7 @@ class scoped_switch_fork_info
      we were already in the desired state, and nothing needs to be
      restored.  */
   struct fork_info *m_oldfp;
+  inferior *m_oldinf;
 };
 
 static int
@@ -513,30 +669,35 @@ static void
 delete_checkpoint_command (const char *args, int from_tty)
 {
   ptid_t ptid, pptid;
-  struct fork_info *fi;
 
   if (!args || !*args)
     error (_("Requires argument (checkpoint id to delete)"));
 
-  ptid = fork_id_to_ptid (parse_and_eval_long (args));
-  if (ptid == minus_one_ptid)
-    error (_("No such checkpoint id, %s"), args);
+  auto [fi, inf] = parse_checkpoint_id (args);
+  ptid = fi->ptid;
+  gdb_assert (fi != nullptr);
+  pptid = fi->parent_ptid;
 
-  if (ptid == inferior_ptid)
-    error (_("\
+  thread_info *inf_thr = any_thread_of_inferior (inf);
+  gdb_assert (inf_thr != nullptr);
+  if (ptid == inf_thr->ptid)
+    {
+      if (inf == current_inferior ())
+	error (_("\
 Please switch to another checkpoint before deleting the current one"));
+      else
+	error (_("\
+Please switch to another checkpoint before deleting the current one\n\
+in inferior %d"), inf->num);
+    }
 
   if (ptrace (PTRACE_KILL, ptid.pid (), 0, 0))
     error (_("Unable to kill pid %s"), target_pid_to_str (ptid).c_str ());
 
-  fi = find_fork_ptid (ptid);
-  gdb_assert (fi);
-  pptid = fi->parent_ptid;
-
   if (from_tty)
     gdb_printf (_("Killed %s\n"), target_pid_to_str (ptid).c_str ());
 
-  delete_fork (ptid);
+  delete_fork (ptid, inf);
 
   if (pptid == null_ptid)
     {
@@ -554,7 +715,7 @@ Please switch to another checkpoint before deleting the current one"));
      If fi->parent_ptid is a part of lwp and it is stopped, waitpid the
      ptid.  */
   thread_info *parent = linux_target->find_thread (pptid);
-  if ((parent == NULL && find_fork_ptid (pptid))
+  if ((parent == NULL && find_fork_ptid (pptid).first != nullptr)
       || (parent != NULL && parent->state == THREAD_STOPPED))
     {
       if (inferior_call_waitpid (pptid, ptid.pid ()))
@@ -571,9 +732,8 @@ detach_checkpoint_command (const char *args, int from_tty)
   if (!args || !*args)
     error (_("Requires argument (checkpoint id to detach)"));
 
-  ptid = fork_id_to_ptid (parse_and_eval_long (args));
-  if (ptid == minus_one_ptid)
-    error (_("No such checkpoint id, %s"), args);
+  auto [fi, inf] = parse_checkpoint_id (args);
+  ptid = fi->ptid;
 
   if (ptid == inferior_ptid)
     error (_("\
@@ -585,7 +745,7 @@ Please switch to another checkpoint before detaching the current one"));
   if (from_tty)
     gdb_printf (_("Detached %s\n"), target_pid_to_str (ptid).c_str ());
 
-  delete_fork (ptid);
+  delete_fork (ptid, current_inferior ());
 }
 
 /* Print information about currently known checkpoints.  */
@@ -594,72 +754,96 @@ static void
 info_checkpoints_command (const char *arg, int from_tty)
 {
   struct gdbarch *gdbarch = get_current_arch ();
-  int requested = -1;
+  struct inferior *cur_inf = current_inferior ();
+  inferior *req_inf = nullptr;
+  fork_info *req_fi = nullptr;
   bool printed = false;
 
   if (arg && *arg)
-    requested = (int) parse_and_eval_long (arg);
+    std::tie (req_fi, req_inf) = parse_checkpoint_id (arg);
 
-  for (const fork_info &fi : fork_list)
-    {
-      if (requested > 0 && fi.num != requested)
-	continue;
-      printed = true;
-
-      bool is_current = fi.ptid == inferior_ptid;
-      if (is_current)
-	gdb_printf ("* ");
-      else
-	gdb_printf ("  ");
+  /* Figure out whether to print the inferior number in the
+     checkpoint list.  */
+  bool print_inf = (!forks_exist_p (current_inferior ())
+                    || forks_exist_in_multiple_inferiors_p ());
 
-      gdb_printf ("%d %s", fi.num, target_pid_to_str (fi.ptid).c_str ());
-      if (fi.num == 0)
-	gdb_printf (_(" (main process)"));
+  for (inferior *inf : all_inferiors ())
+    {
+      if (req_inf != nullptr && req_inf != inf)
+        continue;
 
-      if (is_current && inferior_thread ()->state == THREAD_RUNNING)
-	{
-	  gdb_printf (_(" <running>\n"));
-	  continue;
-	}
+      scoped_restore_current_pspace_and_thread restore_pspace_thread;
+      switch_to_program_space_and_thread (inf->pspace);
 
-      gdb_printf (_(" at "));
-      ULONGEST pc
-	= (is_current
-	   ? regcache_read_pc (get_thread_regcache (inferior_thread ()))
-	   : fi.pc);
-      gdb_puts (paddress (gdbarch, pc));
-
-      symtab_and_line sal = find_pc_line (pc, 0);
-      if (sal.symtab)
-	gdb_printf (_(", file %s"),
-		    symtab_to_filename_for_display (sal.symtab));
-      if (sal.line)
-	gdb_printf (_(", line %d"), sal.line);
-      if (!sal.symtab && !sal.line)
+      for (const fork_info &fi : fork_list (inf))
 	{
-	  struct bound_minimal_symbol msym;
-
-	  msym = lookup_minimal_symbol_by_pc (pc);
-	  if (msym.minsym)
-	    gdb_printf (", <%s>", msym.minsym->linkage_name ());
+	  if (req_fi != nullptr && req_fi != &fi)
+	    continue;
+	  printed = true;
+
+	  thread_info *t = any_thread_of_inferior (inf);
+	  bool is_current = fi.ptid == t->ptid;
+	  if (is_current && cur_inf == inf)
+	    gdb_printf ("*");
+	  else
+	    gdb_printf (" ");
+
+	  if (print_inf)
+	    gdb_printf ("%3d.%-2d", inf->num, fi.num);
+	  else
+	    gdb_printf ("%3d ", fi.num);
+
+	  /* Print out state associated with current checkpoint.  */
+	  if (is_current)
+	    {
+	      gdb_printf ("A");
+	      if (t->state == THREAD_RUNNING)
+		gdb_printf ("R");
+	      else
+	        gdb_printf (" ");
+	      gdb_printf (" ");
+	    }
+	  else
+	    gdb_printf ("   ");
+
+	  gdb_printf ("%s", target_pid_to_str (fi.ptid).c_str ());
+
+	  gdb_printf (_(" at "));
+	  ULONGEST pc
+	    = (is_current
+	       ? regcache_read_pc (get_thread_regcache (t))
+	       : fi.pc);
+	  gdb_puts (paddress (gdbarch, pc));
+
+	  symtab_and_line sal = find_pc_line (pc, 0);
+	  if (sal.symtab)
+	    gdb_printf (_(", file %s"),
+			symtab_to_filename_for_display (sal.symtab));
+	  if (sal.line)
+	    gdb_printf (_(", line %d"), sal.line);
+	  if (!sal.symtab && !sal.line)
+	    {
+	      struct bound_minimal_symbol msym;
+
+	      msym = lookup_minimal_symbol_by_pc (pc);
+	      if (msym.minsym)
+		gdb_printf (", <%s>", msym.minsym->linkage_name ());
+	    }
+
+	  gdb_putc ('\n');
 	}
-
-      gdb_putc ('\n');
     }
 
   if (!printed)
     {
-      if (requested > 0)
-	gdb_printf (_("No checkpoint number %d.\n"), requested);
-      else
-	gdb_printf (_("No checkpoints.\n"));
+      gdb_printf (_("No checkpoints.\n"));
     }
 }
 
 /* The PID of the process we're checkpointing.  */
 static int checkpointing_pid = 0;
 
-int
+bool
 linux_fork_checkpointing_p (int pid)
 {
   return (checkpointing_pid == pid);
@@ -689,7 +873,6 @@ checkpoint_command (const char *args, int from_tty)
   struct target_waitstatus last_target_waitstatus;
   ptid_t last_target_ptid;
   struct value *fork_fn = NULL, *ret;
-  struct fork_info *fp;
   pid_t retpid;
 
   if (!target_has_execution ()) 
@@ -727,14 +910,22 @@ checkpoint_command (const char *args, int from_tty)
   retpid = value_as_long (ret);
   get_last_target_status (nullptr, &last_target_ptid, &last_target_waitstatus);
 
-  fp = find_fork_pid (retpid);
+  auto [fp, inf] = find_fork_pid (retpid);
+
+  if (!fp)
+    error (_("Failed to find new fork"));
 
   if (from_tty)
     {
       int parent_pid;
 
-      gdb_printf (_("checkpoint %d: fork returned pid %ld.\n"),
-		  fp != NULL ? fp->num : -1, (long) retpid);
+      gdb_printf (_("Checkpoint "));
+      if (forks_exist_in_multiple_inferiors_p ())
+	gdb_printf ("%d.%d: ", inf->num, fp->num);
+      else
+	gdb_printf ("%d: ", fp->num);
+      gdb_printf (_("fork returned pid %ld.\n"), (long) retpid);
+
       if (info_verbose)
 	{
 	  parent_pid = last_target_ptid.lwp ();
@@ -745,15 +936,12 @@ checkpoint_command (const char *args, int from_tty)
 	}
     }
 
-  if (!fp)
-    error (_("Failed to find new fork"));
-
-  if (one_fork_p ())
+  if (one_fork_p (inf))
     {
       /* Special case -- if this is the first fork in the list (the
-	 list was hitherto empty), then add inferior_ptid first, as a
-	 special zeroeth fork id.  */
-      fork_list.emplace_front (inferior_ptid.pid ());
+	 list was hitherto empty), then add inferior_ptid as a special
+	 zeroeth fork id.  */
+      fork_list (inf).emplace_front (inferior_ptid.pid (), 0);
     }
 
   fork_save_infrun_state (fp);
@@ -761,40 +949,53 @@ checkpoint_command (const char *args, int from_tty)
 }
 
 static void
-linux_fork_context (struct fork_info *newfp, int from_tty)
+linux_fork_context (struct fork_info *newfp, int from_tty, inferior *newinf)
 {
-  /* Now we attempt to switch processes.  */
-  struct fork_info *oldfp;
+  bool inferior_changed = false;
 
+  /* Now we attempt to switch processes.  */
   gdb_assert (newfp != NULL);
 
-  oldfp = find_fork_ptid (inferior_ptid);
-  gdb_assert (oldfp != NULL);
+  if (newinf != current_inferior ())
+    {
+      thread_info *tp = any_thread_of_inferior (newinf);
+      switch_to_thread (tp);
+      inferior_changed = true;
+    }
 
-  fork_save_infrun_state (oldfp);
-  remove_breakpoints ();
-  fork_load_infrun_state (newfp);
-  insert_breakpoints ();
+  auto [oldfp, oldinf] = find_fork_ptid (inferior_ptid);
+  gdb_assert (oldfp != NULL);
 
-  gdb_printf (_("Switching to %s\n"),
-	      target_pid_to_str (inferior_ptid).c_str ());
+  if (oldfp == newfp)
+    {
+      if (!inferior_changed)
+	error (_("Already using checkpoint %d"), oldfp->num);
+    }
+  else
+    {
+      fork_save_infrun_state (oldfp);
+      remove_breakpoints ();
+      fork_load_infrun_state (newfp);
+      insert_breakpoints ();
+      if (!inferior_changed)
+	gdb_printf (_("Switching to %s\n"),
+		    target_pid_to_str (inferior_ptid).c_str ());
+    }
 
-  print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+  notify_user_selected_context_changed
+    (inferior_changed ? (USER_SELECTED_INFERIOR | USER_SELECTED_FRAME)
+		      : USER_SELECTED_FRAME);
 }
 
 /* Switch inferior process (checkpoint) context, by checkpoint id.  */
 static void
 restart_command (const char *args, int from_tty)
 {
-  struct fork_info *fp;
-
   if (!args || !*args)
     error (_("Requires argument (checkpoint id to restart)"));
 
-  if ((fp = find_fork_id (parse_and_eval_long (args))) == NULL)
-    error (_("Not found: checkpoint id %s"), args);
-
-  linux_fork_context (fp, from_tty);
+  auto [fp, inf] = parse_checkpoint_id (args);
+  linux_fork_context (fp, from_tty, inf);
 }
 
 void _initialize_linux_fork ();
diff --git a/gdb/linux-fork.h b/gdb/linux-fork.h
index c553aaf0740..0233a6c8cfc 100644
--- a/gdb/linux-fork.h
+++ b/gdb/linux-fork.h
@@ -22,12 +22,13 @@
 
 struct fork_info;
 struct lwp_info;
-extern void add_fork (pid_t);
-extern struct fork_info *find_fork_pid (pid_t);
-extern void linux_fork_killall (void);
-extern void linux_fork_mourn_inferior (void);
-extern void linux_fork_detach (int, lwp_info *);
-extern int forks_exist_p (void);
-extern int linux_fork_checkpointing_p (int);
+class inferior;
+extern void add_fork (pid_t, inferior *inf);
+extern std::pair<fork_info *, inferior *> find_fork_pid (pid_t);
+extern void linux_fork_killall (inferior *inf);
+extern void linux_fork_mourn_inferior (inferior *inf);
+extern void linux_fork_detach (int, lwp_info *, inferior *inf);
+extern bool forks_exist_p (inferior *inf);
+extern bool linux_fork_checkpointing_p (int);
 
 #endif /* LINUX_FORK_H */
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 2602e1f240d..e774691cb20 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1552,13 +1552,13 @@ linux_nat_target::detach (inferior *inf, int from_tty)
   gdb_assert (num_lwps (pid) == 1
 	      || (target_is_non_stop_p () && num_lwps (pid) == 0));
 
-  if (pid == inferior_ptid.pid () && forks_exist_p ())
+  if (forks_exist_p (inf))
     {
       /* Multi-fork case.  The current inferior_ptid is being detached
 	 from, but there are other viable forks to debug.  Detach from
 	 the current fork, and context-switch to the first
 	 available.  */
-      linux_fork_detach (from_tty, find_lwp_pid (ptid_t (pid)));
+      linux_fork_detach (from_tty, find_lwp_pid (ptid_t (pid)), inf);
     }
   else
     {
@@ -2076,8 +2076,12 @@ linux_handle_extended_wait (struct lwp_info *lp, int status)
 	  detach_breakpoints (ptid_t (new_pid, new_pid));
 
 	  /* Retain child fork in ptrace (stopped) state.  */
-	  if (!find_fork_pid (new_pid))
-	    add_fork (new_pid);
+	  if (find_fork_pid (new_pid).first == nullptr)
+	    {
+	      struct inferior *inf = find_inferior_ptid (linux_target,
+	                                                 lp->ptid);
+	      add_fork (new_pid, inf);
+	    }
 
 	  /* Report as spurious, so that infrun doesn't want to follow
 	     this fork.  We're actually doing an infcall in
@@ -3757,8 +3761,8 @@ linux_nat_target::kill ()
      parent will be sleeping if this is a vfork.  */
   iterate_over_lwps (pid_ptid, kill_unfollowed_child_callback);
 
-  if (forks_exist_p ())
-    linux_fork_killall ();
+  if (forks_exist_p (current_inferior ()))
+    linux_fork_killall (current_inferior ());
   else
     {
       /* Stop all threads before killing them, since ptrace requires
@@ -3789,14 +3793,14 @@ linux_nat_target::mourn_inferior ()
 
   close_proc_mem_file (pid);
 
-  if (! forks_exist_p ())
+  if (! forks_exist_p (current_inferior ()))
     /* Normal case, no other forks available.  */
     inf_ptrace_target::mourn_inferior ();
   else
     /* Multi-fork case.  The current inferior_ptid has exited, but
        there are other viable forks to debug.  Delete the exiting
        one and context-switch to the first available.  */
-    linux_fork_mourn_inferior ();
+    linux_fork_mourn_inferior (current_inferior ());
 
   /* Let the arch-specific native code know this process is gone.  */
   linux_target->low_forget_process (pid);
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index f87f528e167..0662fe1c654 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -274,17 +274,17 @@ gdb_test "kill" "" "kill all one" \
 # and confirm that all are gone
 #
 
-gdb_test "restart 0" "Not found.*" "no more checkpoint 0"
-gdb_test "restart 1" "Not found.*" "no more checkpoint 1"
-gdb_test "restart 2" "Not found.*" "no more checkpoint 2"
-gdb_test "restart 3" "Not found.*" "no more checkpoint 3"
-gdb_test "restart 4" "Not found.*" "no more checkpoint 4"
-gdb_test "restart 5" "Not found.*" "no more checkpoint 5"
-gdb_test "restart 6" "Not found.*" "no more checkpoint 6"
-gdb_test "restart 7" "Not found.*" "no more checkpoint 7"
-gdb_test "restart 8" "Not found.*" "no more checkpoint 8"
-gdb_test "restart 9" "Not found.*" "no more checkpoint 9"
-gdb_test "restart 10" "Not found.*" "no more checkpoint 10"
+gdb_test "restart 0" "has no checkpoints" "no more checkpoint 0"
+gdb_test "restart 1" "has no checkpoints" "no more checkpoint 1"
+gdb_test "restart 2" "has no checkpoints" "no more checkpoint 2"
+gdb_test "restart 3" "has no checkpoints" "no more checkpoint 3"
+gdb_test "restart 4" "has no checkpoints" "no more checkpoint 4"
+gdb_test "restart 5" "has no checkpoints" "no more checkpoint 5"
+gdb_test "restart 6" "has no checkpoints" "no more checkpoint 6"
+gdb_test "restart 7" "has no checkpoints" "no more checkpoint 7"
+gdb_test "restart 8" "has no checkpoints" "no more checkpoint 8"
+gdb_test "restart 9" "has no checkpoints" "no more checkpoint 9"
+gdb_test "restart 10" "has no checkpoints" "no more checkpoint 10"
 
 #
 # Now let's try setting a large number of checkpoints (>600)
@@ -309,7 +309,7 @@ gdb_test "continue" "breakpoint 2.*" "break2 with many checkpoints"
 set count 0
 set msg "info checkpoints with at least 600 checkpoints"
 gdb_test_multiple "info checkpoints" $msg {
-    -re "  $decimal process \[^\r\]*\r\n" {
+    -re " $decimal A? *process \[^\r\]*\r\n" {
 	incr count
 	exp_continue
     }
@@ -345,7 +345,7 @@ with_test_prefix "delete checkpoint 0" {
     clean_restart $binfile
     runto_main
 
-    gdb_test "checkpoint" "checkpoint 1: fork returned pid $decimal\\."
+    gdb_test "checkpoint" "Checkpoint 1: fork returned pid $decimal\\."
     gdb_test "restart 1" "Switching to .*"
     gdb_test "delete checkpoint 0" "Killed process $decimal"
     gdb_test "info checkpoints" [string_to_regexp "No checkpoints."]
diff --git a/gdb/testsuite/gdb.multi/checkpoint-multi.exp b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
new file mode 100644
index 00000000000..a880d31d326
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
@@ -0,0 +1,687 @@
+# Copyright 2009-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file tests various scenarios involving multiple inferiors
+# and the checkpoint command.
+
+# Checkpoint support works only on Linux.
+require {istarget "*-*-linux*"}
+
+# Checkpoint support is implemented for the (Linux) native target,
+# which is indicated when [target_info gdb_protocol] returns the empty
+# string.
+if { [target_info gdb_protocol] != "" } {
+    return
+}
+
+set testfile "checkpoint-multi"
+
+set exec1 "hello"
+set srcfile1 ${exec1}.c
+set binfile1 [standard_output_file ${exec1}]
+
+set exec2 "goodbye"
+set srcfile2 ${exec2}.c
+set binfile2 [standard_output_file ${exec2}]
+
+set exec3 "hangout"
+set srcfile3 ${exec3}.c
+set binfile3 [standard_output_file ${exec3}]
+
+if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" {debug}] == -1 } {
+    return -1
+}
+
+if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" {debug}] == -1 } {
+    return -1
+}
+
+if { [build_executable ${testfile}.exp ${exec3} "${srcfile3}" {debug}] == -1 } {
+    return -1
+}
+
+# Start two inferiors, place a checkpoint on inferior 2, but switch
+# back to inferior 1.
+proc start_2_inferiors_checkpoint_on_inf_2 {} {
+    clean_restart $::exec1
+
+    # Start inferior 1.
+    if {[gdb_start_cmd] < 0} {
+	fail "start first inferior"
+    } else {
+	gdb_test "" "main.*" "start first inferior"
+    }
+
+    # Add a new inferior and exec into it.
+    gdb_test "add-inferior -exec $::binfile2" \
+	"Added inferior 2.*" \
+	"add inferior 2 with -exec $::exec2"
+
+    # Check that we have multiple inferiors.
+    gdb_test "info inferiors" \
+	"Executable.*$::exec1.*$::exec2.*"
+
+    # Switch to inferior 2.
+    gdb_test "inferior 2" \
+	"Switching to inferior 2.*$::exec2.*"
+
+    # Start inferior 2:
+    if {[gdb_start_cmd] < 0} {
+	fail "start second inferior"
+    } else {
+	gdb_test "" "main.*" "start second inferior"
+    }
+
+    # Set a checkpoint in inferior 2
+    gdb_test "checkpoint" "Checkpoint 1: fork returned pid $::decimal.*"
+
+    # Step one line in inferior 2.
+    gdb_test "step" "glob = 46;"
+
+    # Switch back to inferior 1.
+    gdb_test "inferior 1" "Switching to inferior 1.*$::exec1.*"
+}
+
+# Start two inferiors, place a checkpoint on inferior 2, but switch
+# back to inferior 1.  This is like the one above, except that it
+# swaps the executables loaded into inferior 1 and inferior 2.	This
+# is important for being able to test "continue to exit".  (Because... 
+# hello.c has an infinite loop, but goodbye.c doesn't.	In order to
+# test "continue to exit", we need to continue in an executable which
+# will actually exit.)
+
+proc start_2_inferiors_checkpoint_on_inf_2_alt {} {
+    clean_restart $::exec2
+
+    # Start inferior 1.
+    if {[gdb_start_cmd] < 0} {
+	fail "start first inferior"
+    } else {
+	gdb_test "" "main.*" "start first inferior"
+    }
+
+    # Add a new inferior and exec exec1 into it.
+    gdb_test "add-inferior -exec $::binfile1" \
+	"Added inferior 2.*" \
+	"add inferior 2 with -exec $::exec1"
+
+    # Check that we have two inferiors.
+    gdb_test "info inferiors" \
+	"Executable.*$::exec2.*$::exec1.*"
+
+    # Switch to inferior 2.
+    gdb_test "inferior 2" \
+	"Switching to inferior 2.*$::exec1.*"
+
+    # Start inferior 2:
+    if {[gdb_start_cmd] < 0} {
+	fail "start second inferior"
+    } else {
+	gdb_test "" "main.*" "start second inferior"
+    }
+
+    # Set a checkpoint in inferior 2
+    gdb_test "checkpoint" "Checkpoint 1: fork returned pid $::decimal.*"
+
+    # next one line in inferior 2.
+    gdb_test "next" "bar\\(\\).*"
+
+    # Switch back to inferior 1.
+    gdb_test "inferior 1" "Switching to inferior 1.*$::exec2.*"
+}
+
+with_test_prefix "check detach on non-checkpointed inferior" {
+    start_2_inferiors_checkpoint_on_inf_2
+    gdb_test "detach" "Detaching from program.*$::exec1.*Inferior 1.*detached.*"
+}
+
+with_test_prefix "check kill on non-checkpointed inferior" {
+    start_2_inferiors_checkpoint_on_inf_2
+    gdb_test "kill" "" "kill non-checkpointed inferior" \
+	     "Kill the program being debugged.*y or n. $" "y"
+}
+
+with_test_prefix "check restart 0 on non-checkpointed inferior" {
+    start_2_inferiors_checkpoint_on_inf_2
+    gdb_test "restart 0" "Inferior 1 has no checkpoints"
+    gdb_test "restart 2.0" "Switching to inferior 2.*?goodbye.*?#0 +mailand .*?glob = 46;.*"
+}
+
+with_test_prefix "check restart 1 on non-checkpointed inferior" {
+    start_2_inferiors_checkpoint_on_inf_2
+    gdb_test "restart 1" "Inferior 1 has no checkpoints"
+    gdb_test "restart 2.1" "Switching to inferior 2.*?goodbye.*?#0 +main .*?mailand\\(\\);.*"
+}
+
+with_test_prefix "check continue to exit on non-checkpointed inferior" {
+    start_2_inferiors_checkpoint_on_inf_2_alt
+    gdb_test "continue" "Inferior 1.*? exited normally.*"
+}
+
+set proc_re "(?:process $::decimal|Thread $::hex \\(LWP $::decimal\\))"
+set main_proc "\\(main process\\)"
+set hello_c "hello\\.c"
+set goodbye_c "goodbye\\.c"
+set hangout_c "hangout\\.c"
+
+with_test_prefix "two inferiors with checkpoints" {
+    start_2_inferiors_checkpoint_on_inf_2
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   2.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2.1    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 1"
+    gdb_test "checkpoint" "Checkpoint 1\\.1: fork returned pid $::decimal.*" \
+	     "checkpoint in inferior 1"
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\*  1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 2"
+    gdb_test "restart 0" "Already using checkpoint 0"
+    gdb_test "restart 2.0" \
+	     "\\\[Switching to inferior 2.*?mailand.*?glob = 46;.*"
+    gdb_test "next" "\}"
+
+    gdb_test "restart 1" "^Switching to $proc_re.*?#0  main \\(\\) at.*?$goodbye_c.*mailand\\(\\);"
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 3"
+
+    # Doing "info_checkpoints" twice in a row might seem pointless,
+    # but during work on making the checkpoint code inferior aware,
+    # there was a point at which doing it twice in a row did not
+    # produce the same output.
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 4"
+
+    # Switch back to checkpoint 0; again, there should be no
+    # "Switching to inferior" message.
+    gdb_test "restart 0" "^Switching to $proc_re.*?#0  mailand \\(\\) at.*?$goodbye_c.*\}" \
+	     "restart 0 #2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "\\*  2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 5"
+
+    # Try switching to invalid checkpoints:
+    gdb_test "restart 3" "Invalid checkpoint number 3 for inferior 2"
+    gdb_test "restart 2" "Invalid checkpoint number 2 for inferior 2"
+    gdb_test "restart -1" "Checkpoint number must be a non-negative integer"
+    gdb_test "restart 2.3" "Invalid checkpoint number 3 for inferior 2"
+    gdb_test "restart 3.0" "No inferior number '3'"
+    gdb_test "restart 1.2" "Invalid checkpoint number 2 for inferior 1"
+    gdb_test "restart 1.3" "Invalid checkpoint number 3 for inferior 1"
+    gdb_test "restart 1.-1" "Checkpoint number must be a non-negative integer"
+    gdb_test "restart -1.0" "Inferior number must be a positive integer"
+
+    # Switch to checkpoint 3; this time, we should see a "Switching to
+    # inferior" message.
+    gdb_test "restart 1.1" \
+	     "\\\[Switching to inferior 1.*?main.*?$hello_c.*?alarm \\(240\\);"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "\\*  1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 6"
+
+    gdb_test "restart 2.1" \
+	     "Switching to inferior 2.*?#0  main \\(\\) at.*?$goodbye_c.*mailand\\(\\);"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 7"
+
+    gdb_test "checkpoint" "Checkpoint 2\\.2: fork returned pid $::decimal.*" \
+	     "second checkpoint in inferior 2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 8"
+
+    gdb_test "checkpoint" "Checkpoint 2.3: fork returned pid $::decimal.*" \
+	     "third checkpoint in inferior 2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.3    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 9"
+
+    gdb_test "continue" \
+	     "Inferior 2 \\(process $decimal\\) exited normally.*?Switching to $proc_re.*?" \
+	     "continue to exit in checkpoint 2.1"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  2\\.3 A  $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 10"
+
+    gdb_test "continue" \
+	     "Inferior 2 \\(process $decimal\\) exited normally.*?Switching to process $decimal.*?" \
+	     "continue to exit in checkpoint 2.3"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  2\\.2 A  $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 11"
+
+    gdb_test "continue" \
+	     "Inferior 2 \\(process $decimal\\) exited normally.*?Switching to process $decimal.*?" \
+	     "continue to exit in checkpoint 2.2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?"] \
+	"info checkpoints 12"
+
+    gdb_test "checkpoint" "Checkpoint 2.1: fork returned pid $::decimal.*" \
+	     "fourth checkpoint in inferior 2"
+
+    gdb_test "checkpoint" "Checkpoint 2.2: fork returned pid $::decimal.*" \
+	     "fifth checkpoint in inferior 2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "\\*  2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 13"
+
+    gdb_test "delete checkpoint 2.0" \
+	     "Please switch to another checkpoint before deleting the current one"
+
+    gdb_test "restart 2.1" \
+	     "^Switching to process.*?#0  mailand \\(\\) at.*?$goodbye_c.*\}" \
+	     "restart 2.1 #2"
+
+    gdb_test "delete checkpoint 2.0" \
+	     "Killed process $::decimal" \
+	     "delete checkpoint 2.0 #2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "\\*  2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 14"
+
+    gdb_test "delete checkpoint 2.2" \
+	     "Killed process $::decimal"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?"] \
+	"info checkpoints 15"
+
+    gdb_test "checkpoint" "Checkpoint 2.1: fork returned pid $::decimal.*" \
+	     "sixth checkpoint in inferior 2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "\\*  2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 16"
+
+    gdb_test "inferior 1" "Switching to inferior 1.*?alarm \\(240\\);" \
+	     "inferior 1 #2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "\\*  1\\.1 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 17"
+
+    gdb_test "kill" "\\\[Inferior 1 \\(process $::decimal\\) killed\\\]" \
+	     "kill inferior 1" \
+	     "Kill the program being debugged.*y or n. $" "y"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 18"
+
+    gdb_test "checkpoint" "The program is not being run\\." \
+	     "checkpoint in non-running inferior"
+
+    gdb_test "start" "Starting program.*?hello.*?alarm \\(240\\);"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 19"
+
+    gdb_test "checkpoint" "Checkpoint 1.1: fork returned pid $::decimal.*" \
+	     "second checkpoint in inferior 1"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\*  1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 20"
+}
+
+with_test_prefix "three inferiors with checkpoints" {
+    start_2_inferiors_checkpoint_on_inf_2
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?"] \
+	"info checkpoints 1"
+
+    # Add a third inferior and exec into it.
+    gdb_test "add-inferior -exec $::binfile3" \
+	     "Added inferior 3.*" \
+	     "add inferior 3 with -exec $::exec3"
+
+    # Check that we have three inferiors.
+    gdb_test "info inferiors" \
+	     "Executable.*?\\* 1 .*?$::exec1.*? 2 .*?$::exec2.*? 3 .*?$::exec3.*?" \
+	     "check for three inferiors"
+
+    # Switch to inferior 3.
+    gdb_test "inferior 3" \
+	"Switching to inferior 3.*$::exec3.*"
+
+    # Start inferior 2:
+    if {[gdb_start_cmd] < 0} {
+	fail "start third inferior"
+    } else {
+	gdb_test "" "main.*" "start third inferior"
+    }
+
+    gdb_test "checkpoint" "Checkpoint 3\\.1: fork returned pid $::decimal.*" \
+	     "first checkpoint in inferior 3"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.1    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 2"
+
+    gdb_test "inferior 1" "Switching to inferior 1.*?alarm \\(240\\);" \
+	     "inferior 1 #2"
+
+    gdb_test "checkpoint" "Checkpoint 1\\.1: fork returned pid $::decimal.*" \
+	     "first checkpoint in inferior 1"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\*  1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.1    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 3"
+
+    gdb_test "restart 2.1" \
+	     "Switching to inferior 2.*?#0  main \\(\\) at.*?$goodbye_c.*mailand\\(\\);" \
+	     "restart 1"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.1    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 4"
+
+    gdb_test "next" "foo\\(glob\\);"
+
+    gdb_test "checkpoint" "Checkpoint 2\\.2: fork returned pid $::decimal.*" \
+	     "second checkpoint in inferior 2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.1    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 5"
+
+    gdb_test "inferior 3" "Switching to inferior 3.*?alarm \\(30\\);" \
+	     "inferior 3 #2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.1    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 6"
+
+    gdb_test "kill" "\\\[Inferior 3 \\(process $::decimal\\) killed\\\]" \
+	     "kill inferior 3" \
+	     "Kill the program being debugged.*y or n. $" "y"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.0    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2    $proc_re at $::hex, file.*?$goodbye_c.*?" ]\
+	"info checkpoints 7"
+
+    gdb_test "delete checkpoint 0" \
+	     "Inferior 3 has no checkpoints"
+    gdb_test "delete checkpoint 2.0" \
+	     "Killed process $::decimal"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.1 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2    $proc_re at $::hex, file.*?$goodbye_c.*?" ]\
+	"info checkpoints 8"
+
+    gdb_test "restart 2.2" \
+	     "Switching to inferior 2.*?#0  main \\(\\) at.*?$goodbye_c.*foo\\(glob\\);"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  2\\.2 A  $proc_re at $::hex, file.*?$goodbye_c.*?" ]\
+	"info checkpoints 9"
+
+    gdb_test "inferior 3" "\\\[Switching to inferior 3 \\\[<null>\\\] \\(.*?$::exec3\\)\\\]" \
+	     "inferior 3 #3"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2 A  $proc_re at $::hex, file.*?$goodbye_c.*?" ]\
+	"info checkpoints 10"
+
+    gdb_test "start" "Starting program.*?hangout.*?alarm \\(30\\);"
+
+    gdb_test "checkpoint" "Checkpoint 3\\.1: fork returned pid $::decimal.*" \
+	     "second checkpoint in inferior 3"
+
+    gdb_test "checkpoint" "Checkpoint 3\\.2: fork returned pid $::decimal.*" \
+	     "third checkpoint in inferior 3"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.1    $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.2    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 11"
+
+    gdb_test "delete checkpoint 1" \
+	     "Killed process $::decimal"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.2    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 12"
+
+    # Switch to inferior 1, add another checkpoint - so that there are
+    # three of them in inferior 1 - then switch back to inferior 3 and
+    # delete active checkpoint in inferior 1.  Then, switch to
+    # inferior 1 and attempt to add another checkpoint.  During
+    # development, a "Cannot access memory at address ..." message was
+    # seen.  This was a bug - there were several problems, but one
+    # of them was that the checkpoint in question was an "active"
+    # checkpoint.  The fix was to disallow this case.
+    gdb_test "inferior 1" "Switching to inferior 1.*?alarm \\(240\\);" \
+	     "inferior 1 #3"
+
+    gdb_test "checkpoint" "Checkpoint 1\\.2: fork returned pid $::decimal.*" \
+	     "second checkpoint in inferior 1"
+
+    gdb_test "inferior 3" "Switching to inferior 3.*?alarm \\(30\\);" \
+	     "inferior 3 #4"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.1    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.2    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.2    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 13"
+
+    # Check that deleting active checkpoints in other (non-current)
+    # inferiors is disallowed.
+    gdb_test "delete checkpoint 1.0" \
+	     "Please switch to another checkpoint before deleting the current one\[ \r\n\]+in inferior 1"
+
+    # But deleting non-active checkpoints, even in other inferiors 
+    # should work.
+    gdb_test "delete checkpoint 1.1" \
+	     "Killed process $::decimal"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "   1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.2    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "\\*  3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.2    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 14"
+
+    gdb_test "inferior 1" "Switching to inferior 1.*?alarm \\(240\\);" \
+	     "inferior 1 #4"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\*  1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.2    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.2    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 15"
+
+    gdb_test "checkpoint" "Checkpoint 1\\.3: fork returned pid $::decimal.*" \
+	     "third checkpoint in inferior 1"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\*  1\\.0 A  $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.2    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   1\\.3    $proc_re at $::hex, file.*?$hello_c.*?" \
+	    "   2\\.1    $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   2\\.2 A  $proc_re at $::hex, file.*?$goodbye_c.*?" \
+	    "   3\\.0 A  $proc_re at $::hex, file.*?$hangout_c.*?" \
+	    "   3\\.2    $proc_re at $::hex, file.*?$hangout_c.*?"] \
+	"info checkpoints 16"
+
+    gdb_test "x/i \$pc" "=> $::hex <main.*"
+
+    gdb_test "remove-inferior 3" \
+	     "warning: Can not remove active inferior 3\."
+}
-- 
2.44.0


^ permalink raw reply	[relevance 10%]

* Re: [PATCH v2] sim: riscv: Fix some compatibility issues with gcc
  @ 2024-04-12 17:18  0%   ` Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-12 17:18 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 4/12/24 16:48, Andrew Burgess wrote:
> Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
> 
>> This makes the riscv simulator able to execute a simple
>> "hello world" program when gcc is configured
>> with:
>>
>> .../gcc-trunk/configure --target=riscv-unknown-elf
>>
>> The first problem is that gcc generates rv32
>> code by default in this configuration, while
>> riscv64-unknown-elf generates rv64 code by default.
>>
>> So change the riscv/acinclude.m4 to use the same
>> logic here.
> 
> I'm sorry, but this change is not OK.  At least, I'll need more
> convincing before this could be merged.
> 
> Previously, the riscv sim would support ( in theory ) both RV32 and
> RV64, and would pick the correct word size based on the ELF
> architecture.
> 
> What you're finding is that the riscv sim is (apparently) pretty buggy.
> 
> With just the sim-main.c fix and the model_list.def change I can see the
> simulator trying to run the RV32 code.  But, the problem I see is
> confusion about whether registers should be sign extended or not.
> 
> One example of where this goes wrong is this.  Consider the instruction:
> 
>   c.li a1,-1
> 
> this will result in the value 0xffffffffffffffff being written into the
> register, even for RV32 code.
> 
> But as this is 32-bit code, I also see the code build the constant
> 0xffffffff by shifting and or-ing things together.  The code then
> compares the register containing 0xffffffffffffffff with the register
> containing 0xffffffff together, and expects them to be the same.
> 
> Obviously they are not the same, so the code takes an incorrect branch,
> and everything goes wrong...
> 
> If we force the build to be RV32 only then the register size will be
> 32-bits and the above problem is "solved".  But it's not really, we're
> just masking the issue.
> 
> So I think we need to solve the register size issue first.
> 

This patch series fixes only the case when no --architecture riscv:rv32
is given to riscv64-unknown-elf-run, also the argc argv parameters of main
use hard-coded values of type address_word which is uint64_t for riscv64
and uint32_t for other spec.  I could probably add an error if this non-working
architecture is requested.

Given the number of issues I ran into in the few days I started working
on this architecture I cant imagine that I can solve every issue, for
instance the missing f and d floating point instructions, would be far
more important than making --architecture riscv:rv32 work, since it can be
achieved by using the --target buildspec when building the simulator.

>>
>> And the second issue is that gcc does by default
>> generate instructions in INSN_CLASS_C, so move
>> the M(GC) to top of list, in riscv/model_list.def.
> 
> I haven't looked at this part of the change yet.  But just going by my
> gut, this doesn't feel right.  I would have expected there to be some
> logic "somewhere" that checks down the model list and looks for a mode
> with the required extensions.
> 
> Just moving the one we want/need to the top feels like we're just
> changing the default.  Is the "pick the correct model" code broken?
> Completely missing?
> 

It changes only the default when no --model RV32IMAC or sonmething
similar is given on the command line,  previously RV32G was the first
element in the list, and now RV32GC is the default, which allows
to use the C instruction set, which is really used all the time.

The default should at least allow all implemented instructions.


>>
>> Then there was apparently a confusion which cpu
>> model uses JAL and which ADDIW.  Fixed that in
>> execute_c, case MATCH_C_JAL | MATCH_C_ADDIW.
> 
> You might consider breaking this change out, as this third part could go
> in on its own I think.
> 

OK. Sure.
I can also update the comment.


Thanks
Bernd.

> Thanks,
> Andrew
> 
> 
>>
>> With these changes a simple c-prgram can be executed,
>> however there is still work to do, since when the
>> program does floating point operations, gcc starts to
>> generate hardware floating point instructions, with no
>> obvious opt-out option.
>>
>> Note the gcc test suite can be used to test the
>> simulator in this way:
>>
>> make check-gcc RUNTESTFLAGS="--target_board=multi-sim SIM=riscv-unknown-elf-run"
>>
>> Now many tests are passed, except those which use
>> floating point instructions.
>>
>> To work around the not supported float instructions the
>> following gcc configuration can be used, which makes
>> most of the gcc test cases successfully executed:
>>
>> .../gcc-trunk/configure --prefix=... --target=riscv-unknown-elf
>>  --disable-multilib --with-arch=rv32imac --with-abi=ilp32
>>
>> Note: binutils are installed at prefix path and newlib/libgloss in-tree.
>>
>> Fixes 3224e32fb84f ("sim: riscv: Add support for compressed integer instructions")
>> ---
>>  sim/configure            | 6 +++---
>>  sim/riscv/acinclude.m4   | 4 ++--
>>  sim/riscv/model_list.def | 2 +-
>>  sim/riscv/sim-main.c     | 4 ++--
>>  4 files changed, 8 insertions(+), 8 deletions(-)
>>
>> v2: updated the commit message, with some hints
>> how to compile a compatible gcc toolchain.
>>
>> diff --git a/sim/configure b/sim/configure
>> index 1ebef377973..fdc0a86d524 100755
>> --- a/sim/configure
>> +++ b/sim/configure
>> @@ -17479,10 +17479,10 @@ $as_echo "$sim_ppc_xor_endian" >&6; }
>>  
>>  { $as_echo "$as_me:${as_lineno-$LINENO}: checking riscv bitsize" >&5
>>  $as_echo_n "checking riscv bitsize... " >&6; }
>> -SIM_RISCV_BITSIZE=64
>> +SIM_RISCV_BITSIZE=32
>>  case $target in #(
>> -  riscv32*) :
>> -    SIM_RISCV_BITSIZE=32 ;; #(
>> +  riscv64*) :
>> +    SIM_RISCV_BITSIZE=64 ;; #(
>>    *) :
>>       ;;
>>  esac
>> diff --git a/sim/riscv/acinclude.m4 b/sim/riscv/acinclude.m4
>> index 0c6290c9c08..e9953c1017d 100644
>> --- a/sim/riscv/acinclude.m4
>> +++ b/sim/riscv/acinclude.m4
>> @@ -15,8 +15,8 @@ dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
>>  dnl
>>  dnl NB: This file is included in sim/configure, so keep settings namespaced.
>>  AC_MSG_CHECKING([riscv bitsize])
>> -SIM_RISCV_BITSIZE=64
>> +SIM_RISCV_BITSIZE=32
>>  AS_CASE([$target],
>> -	[riscv32*], [SIM_RISCV_BITSIZE=32])
>> +	[riscv64*], [SIM_RISCV_BITSIZE=64])
>>  AC_MSG_RESULT([$SIM_RISCV_BITSIZE])
>>  AC_SUBST(SIM_RISCV_BITSIZE)
>> diff --git a/sim/riscv/model_list.def b/sim/riscv/model_list.def
>> index b83557e5539..df9ec897126 100644
>> --- a/sim/riscv/model_list.def
>> +++ b/sim/riscv/model_list.def
>> @@ -1,9 +1,9 @@
>> +M(GC)
>>  M(G)
>>  M(I)
>>  M(IM)
>>  M(IMA)
>>  M(IA)
>> -M(GC)
>>  M(IC)
>>  M(IMC)
>>  M(IMAC)
>> diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
>> index adff99921c6..9c0d070aa60 100644
>> --- a/sim/riscv/sim-main.c
>> +++ b/sim/riscv/sim-main.c
>> @@ -1018,7 +1018,7 @@ execute_c (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>      case MATCH_C_JAL | MATCH_C_ADDIW:
>>        /* JAL and ADDIW have the same mask but are only available on RV64 or
>>  	 RV32 respectively.  */
>> -      if (RISCV_XLEN (cpu) == 64)
>> +      if (RISCV_XLEN (cpu) == 32)
>>  	{
>>  	  imm = EXTRACT_CJTYPE_IMM (iw);
>>  	  TRACE_INSN (cpu, "c.jal %" PRIxTW,
>> @@ -1027,7 +1027,7 @@ execute_c (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
>>  	  pc = riscv_cpu->pc + imm;
>>  	  TRACE_BRANCH (cpu, "to %#" PRIxTW, pc);
>>  	}
>> -      else if (RISCV_XLEN (cpu) == 32)
>> +      else if (RISCV_XLEN (cpu) == 64)
>>  	{
>>  	  imm = EXTRACT_CITYPE_IMM (iw);
>>  	  TRACE_INSN (cpu, "c.addiw %s, %s, %#" PRIxTW ";  // %s += %#" PRIxTW,
>> -- 
>> 2.39.2
> 

^ permalink raw reply	[relevance 0%]

* Re: [PATCH] [gdb/python] Throw MemoryError in inferior.read_memory if malloc fails
  @ 2024-04-12  7:09  9%   ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-04-12  7:09 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 4874 bytes --]

On 4/11/24 18:07, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
> 
> Tom> PR python/31631 reports a gdb internal error when doing:
> Tom> ...
> Tom> (gdb) python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff)
> Tom> utils.c:709: internal-error: virtual memory exhausted.
> Tom> A problem internal to GDB has been detected,
> Tom> further debugging may prove unreliable.
> Tom> ...
> 
> Tom> Fix this by throwing a python MemoryError, such that we have instead:
> Tom> ...
> Tom> (gdb) python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff)
> Tom> Python Exception <class 'MemoryError'>:
> Tom> Error occurred in Python.
> Tom> (gdb)
> Tom> ...
> 
> I tend to think you will regret opening this door, because I imagine
> there are a large number of ways to crash gdb by passing nonsensical
> values to Python APIs.
> 

Hm, ok then let's hope I don't regret it.

> Tom>  @request("readMemory")
> Tom>  @capability("supportsReadMemoryRequest")
> Tom>  def read_memory(*, memoryReference: str, offset: int = 0, count: int, **extra):
> Tom>      addr = int(memoryReference, 0) + offset
> Tom> -    buf = gdb.selected_inferior().read_memory(addr, count)
> Tom> +    oom = False
> Tom> +    try:
> Tom> +        buf = gdb.selected_inferior().read_memory(addr, count)
> Tom> +    except MemoryError:
> Tom> +        oom = True
> Tom> +    if oom:
> Tom> +        raise DAPException("Out of memory")
> 
> This should probably chain the memory error in the except block and
> re-throw.  See https://peps.python.org/pep-3134/
> 

Ack, that's what I had initially, but I ran into an error that I can no 
longer reproduce ... so, I'm not sure what happened there.  Anyway, fixed.

> However I don't really understand why this is needed.  Isn't the
> exception already propagated back to the server thread?
> 

Without it I run into:
...
FAIL: gdb.dap/memory.exp: exceptions in log file
...
because in the dap log we have:
...
READ: <<<{"seq": 7, "type": "request", "command": "readMemory", 
"arguments": {"memoryReference": "0x402010", "count": 
18446744073709551615}}>>>
Traceback (most recent call last):
   File 
"/data/vries/gdb/leap-15-5/build/gdb/data-directory/python/gdb/dap/server.py", 
line 157, in _handle_command
     body = _commands[params["command"]](**args)
   File 
"/data/vries/gdb/leap-15-5/build/gdb/data-directory/python/gdb/dap/server.py", 
line 300, in check
     return func(*args, **kwargs)
   File 
"/data/vries/gdb/leap-15-5/build/gdb/data-directory/python/gdb/dap/server.py", 
line 360, in sync_call
     return send_gdb_with_response(lambda: func(**args))
   File 
"/data/vries/gdb/leap-15-5/build/gdb/data-directory/python/gdb/dap/server.py", 
line 514, in send_gdb_with_response
     raise val
   File 
"/data/vries/gdb/leap-15-5/build/gdb/data-directory/python/gdb/dap/server.py", 
line 470, in __call__
     val = self.fn()
   File 
"/data/vries/gdb/leap-15-5/build/gdb/data-directory/python/gdb/dap/server.py", 
line 360, in <lambda>
     return send_gdb_with_response(lambda: func(**args))
   File 
"/data/vries/gdb/leap-15-5/build/gdb/data-directory/python/gdb/dap/startup.py", 
line 113, in ensure_gdb_thread
     return func(*args, **kwargs)
   File 
"/data/vries/gdb/leap-15-5/build/gdb/data-directory/python/gdb/dap/memory.py", 
line 28, in read_memory
     buf = gdb.selected_inferior().read_memory(addr, count)
MemoryError
WROTE: <<<{"request_seq": 7, "type": "response", "command": 
"readMemory", "success": false, "message": ""}>>>
...

So that needs fixing here:
...
diff --git a/gdb/python/lib/gdb/dap/server.py 
b/gdb/python/lib/gdb/dap/server.py
index 7eb87177710..8408232eceb 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -173,6 +173,9 @@ class Server:
              log_stack(LogLevel.FULL)
              result["success"] = False
              result["message"] = str(e)
+        except MemoryError as e:
+            result["success"] = False
+            result["message"] = str(e)
          except BaseException as e:
...

But I couldn't come up with a good rationale as to why I should handle 
MemoryError differently from BaseException, so I decided to catch it 
locally and turn it into a DAPException.

> Tom> +      /* We used to use xmalloc, which does this trick to avoid malloc
> Tom> +	 returning a nullptr for a valid reason.  Keep doing the same.  */
> Tom> +      if (length == 0)
> Tom> +	length = 1;
> 
> This is most likely a workaround for vendor implementations of malloc
> that return NULL for malloc(0).  See
> https://www.gnu.org/software/gnulib/manual/html_node/malloc.html
> 
> However, here this is not necessary, because a 0-length memory read is
> meaningless, and so this case can simply be reported as an error.

I went for backward compatibility here, but ok, fixed.  Updated version 
attached.

Thanks,
- Tom

[-- Attachment #2: 0001-gdb-python-Throw-MemoryError-in-inferior.read_memory.patch --]
[-- Type: text/x-patch, Size: 4490 bytes --]

From 96f62bf65fe8a43175820f99c890daf184533d5e Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Thu, 11 Apr 2024 10:42:39 +0200
Subject: [PATCH] [gdb/python] Throw MemoryError in inferior.read_memory if
 malloc fails

PR python/31631 reports a gdb internal error when doing:
...
(gdb) python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff)
utils.c:709: internal-error: virtual memory exhausted.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...

Fix this by throwing a python MemoryError, such that we have instead:
...
(gdb) python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff)
Python Exception <class 'MemoryError'>:
Error occurred in Python.
(gdb)
...

Likewise for DAP.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31631
---
 gdb/python/lib/gdb/dap/memory.py         |  6 +++++-
 gdb/python/py-inferior.c                 | 14 ++++++++++++--
 gdb/testsuite/gdb.dap/memory.exp         |  5 +++++
 gdb/testsuite/gdb.python/py-inferior.exp |  6 ++++++
 4 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/memory.py b/gdb/python/lib/gdb/dap/memory.py
index dd62b0e7ba6..48aac8f4d7c 100644
--- a/gdb/python/lib/gdb/dap/memory.py
+++ b/gdb/python/lib/gdb/dap/memory.py
@@ -18,13 +18,17 @@ import base64
 import gdb
 
 from .server import capability, request
+from .startup import DAPException
 
 
 @request("readMemory")
 @capability("supportsReadMemoryRequest")
 def read_memory(*, memoryReference: str, offset: int = 0, count: int, **extra):
     addr = int(memoryReference, 0) + offset
-    buf = gdb.selected_inferior().read_memory(addr, count)
+    try:
+        buf = gdb.selected_inferior().read_memory(addr, count)
+    except MemoryError:
+        raise DAPException("Out of memory")
     return {
         "address": hex(addr),
         "data": base64.b64encode(buf).decode("ASCII"),
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 795ac655ddd..a1042ee72ac 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -555,6 +555,18 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw)
       || get_addr_from_python (length_obj, &length) < 0)
     return NULL;
 
+  if (length == 0)
+    {
+      PyErr_SetString (PyExc_ValueError,
+		       _("Argument 'count' should be greater than zero"));
+      return NULL;
+    }
+
+  void *p = malloc (length);
+  if (p == nullptr)
+    return PyErr_NoMemory ();
+  buffer.reset ((gdb_byte *) p);
+
   try
     {
       /* Use this scoped-restore because we want to be able to read
@@ -562,8 +574,6 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw)
       scoped_restore_current_inferior_for_memory restore_inferior
 	(inf->inferior);
 
-      buffer.reset ((gdb_byte *) xmalloc (length));
-
       read_memory (addr, buffer.get (), length);
     }
   catch (const gdb_exception &except)
diff --git a/gdb/testsuite/gdb.dap/memory.exp b/gdb/testsuite/gdb.dap/memory.exp
index 2e911f4dc77..4e2e361289a 100644
--- a/gdb/testsuite/gdb.dap/memory.exp
+++ b/gdb/testsuite/gdb.dap/memory.exp
@@ -55,6 +55,11 @@ set obj [dap_check_request_and_response "evaluate global pointer" \
 	     evaluate {o expression [s thirty_two_p]}]
 set addr [dict get [lindex $obj 0] body memoryReference]
 
+set obj [dap_request_and_response \
+	     readMemory [format {o memoryReference [s %s] count [i 18446744073709551615]} $addr]]
+set response [lindex $obj 0]
+gdb_assert { [dict get $response success] == "false" } "read memory, count to big"
+
 set obj [dap_check_request_and_response "read memory" \
 	     readMemory [format {o memoryReference [s %s] count [i 4]} $addr]]
 
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index c14f2d2796c..4c19e259159 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -34,6 +34,12 @@ switch [get_endianness] {
     big { set python_pack_char ">" }
 }
 
+gdb_test \
+    "python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff)" \
+    [multi_line \
+	 [string_to_regexp "Python Exception <class 'MemoryError'>: "] \
+	 [string_to_regexp "Error occurred in Python."]]
+
 # Test memory read operations without execution.
 
 gdb_py_test_silent_cmd "python addr = gdb.lookup_global_symbol ('int8_global').value().address" \

base-commit: 8bad8d5133f3f91c287e63f8046f040fc4d881e8
-- 
2.35.3


^ permalink raw reply	[relevance 9%]

* [PUSHED] gdb: fix format in remote.c
@ 2024-04-11 11:05  8% Tankut Baris Aktemur
  0 siblings, 0 replies; 200+ results
From: Tankut Baris Aktemur @ 2024-04-11 11:05 UTC (permalink / raw)
  To: gdb-patches

Fix space-before-parenthesis format at three spots in remote.c.
---
 gdb/remote.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index a09ba4d715d..5c9fdebcdbe 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2739,14 +2739,14 @@ remote_target::remote_query_attached (int pid)
   getpkt (&rs->buf);
 
   packet_result result = m_features.packet_ok (rs->buf, PACKET_qAttached);
-  switch (result.status())
+  switch (result.status ())
     {
     case PACKET_OK:
       if (strcmp (rs->buf.data (), "1") == 0)
 	return 1;
       break;
     case PACKET_ERROR:
-      warning (_("Remote failure reply: %s"), result.err_msg());
+      warning (_("Remote failure reply: %s"), result.err_msg ());
       break;
     case PACKET_UNKNOWN:
       break;
@@ -3107,7 +3107,7 @@ remote_target::set_syscall_catchpoint (int pid, bool needed, int any_count,
   putpkt (catch_packet);
   getpkt (&rs->buf);
   packet_result result = m_features.packet_ok (rs->buf, PACKET_QCatchSyscalls);
-  if (result.status() == PACKET_OK)
+  if (result.status () == PACKET_OK)
     return 0;
   else
     return -1;
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 8%]

* [PATCH v2 4/6] gdb, btrace: set wait status to ignore if nothing is moving
  @ 2024-04-11  5:26  5% ` Markus Metzger
  0 siblings, 0 replies; 200+ results
From: Markus Metzger @ 2024-04-11  5:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro

When record_btrace::wait() is called and no threads are moving, we set the
wait status to no_resumed.  Change that to ignore.

This helps with enabling per-inferior run-control for the record btrace
target as it avoids breaking out of do_target_wait() too early with
no_resumed when there would have been an event on another thread.
---
 gdb/record-btrace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 66f283b8680..53ed481eb4d 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -2279,14 +2279,14 @@ btrace_step_spurious (void)
   return status;
 }
 
-/* Return a target_waitstatus indicating that the thread was not resumed.  */
+/* Return a target_waitstatus indicating that nothing is moving.  */
 
 static struct target_waitstatus
-btrace_step_no_resumed (void)
+btrace_step_no_moving_threads (void)
 {
   struct target_waitstatus status;
 
-  status.set_no_resumed ();
+  status.set_ignore ();
 
   return status;
 }
@@ -2555,7 +2555,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
 
   if (moving.empty ())
     {
-      *status = btrace_step_no_resumed ();
+      *status = btrace_step_no_moving_threads ();
 
       DEBUG ("wait ended by %s: %s", null_ptid.to_string ().c_str (),
 	     status->to_string ().c_str ());
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 5%]

* Re: [PATCH v2] gdb, gdbserver: Add missing install-dvi Makefile target
  @ 2024-04-10 13:00  0%         ` Luis Machado
  0 siblings, 0 replies; 200+ results
From: Luis Machado @ 2024-04-10 13:00 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: gdb-patches, binutils

On 4/10/24 11:02, Christophe Lyon wrote:
> On Wed, 10 Apr 2024 at 10:10, Christophe Lyon
> <christophe.lyon@linaro.org> wrote:
>>
>> On Wed, 10 Apr 2024 at 01:00, Luis Machado <luis.machado@arm.com> wrote:
>>>
>>> On 4/7/24 20:10, Christophe Lyon wrote:
>>>> For some reason install-dvi is missing although other targets of the
>>>> same family are present. This looks like an oversight.
>>>>
>>>> This enables calling 'make install-dvi' from the top-level build
>>>> directory.
>>>>
>>>> Fix what looks like another oversight: include 'pdf' in 'all-doc' in
>>>> gdb/doc/Makefile.in.
>>>> ---
>>>>  gdb/Makefile.in                |  2 +-
>>>>  gdb/data-directory/Makefile.in |  2 +-
>>>>  gdb/doc/Makefile.in            | 19 +++++++++++++++++--
>>>>  gdb/testsuite/Makefile.in      |  1 +
>>>>  gdbserver/Makefile.in          |  1 +
>>>>  5 files changed, 21 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/gdb/Makefile.in b/gdb/Makefile.in
>>>> index 40732cb2227..d001359539a 100644
>>>> --- a/gdb/Makefile.in
>>>> +++ b/gdb/Makefile.in
>>>> @@ -2035,7 +2035,7 @@ check-headers:
>>>>       done
>>>>  .PHONY: check-headers
>>>>
>>>> -info install-info clean-info dvi pdf install-pdf html install-html: force
>>>> +info install-info clean-info dvi install-dvi pdf install-pdf html install-html: force
>>>>       @$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
>>>>
>>>>  # Traditionally "install" depends on "all".  But it may be useful
>>>> diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in
>>>> index 2a40be4ade0..2db8706eba6 100644
>>>> --- a/gdb/data-directory/Makefile.in
>>>> +++ b/gdb/data-directory/Makefile.in
>>>> @@ -422,7 +422,7 @@ maintainer-clean realclean distclean: clean
>>>>  .PHONY: install-info install-pdf install-html clean-info
>>>>  check installcheck:
>>>>  info dvi pdf html:
>>>> -install-info install-pdf install-html:
>>>> +install-info install-dvi install-pdf install-html:
>>>>  clean-info:
>>>>
>>>>  # GNU Make has an annoying habit of putting *all* the Makefile variables
>>>> diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
>>>> index 04f9dbd27f0..8007f6373d4 100644
>>>> --- a/gdb/doc/Makefile.in
>>>> +++ b/gdb/doc/Makefile.in
>>>> @@ -24,6 +24,7 @@ prefix = @prefix@
>>>>  infodir = @infodir@
>>>>  datarootdir = @datarootdir@
>>>>  docdir = @docdir@
>>>> +dvidir = @dvidir@
>>>>  pdfdir = @pdfdir@
>>>>  htmldir = @htmldir@
>>>>  mandir = @mandir@
>>>> @@ -87,6 +88,8 @@ SET_TEXINPUTS = \
>>>>  # Files which should be generated via 'info' and installed by 'install-info'
>>>>  INFO_DEPS = gdb.info stabs.info annotate.info
>>>>
>>>> +# Files which should be generated via 'dvi' and installed by 'install-dvi'
>>>> +DVIFILES = gdb.dvi stabs.dvi refcard.dvi annotate.dvi
>>>>  # Files which should be generated via 'pdf' and installed by 'install-pdf'
>>>>  PDFFILES = gdb.pdf stabs.pdf refcard.pdf annotate.pdf
>>>>  # Files which should be generated via 'html' and installed by 'install-html'
>>>> @@ -191,7 +194,7 @@ HAVE_NATIVE_GCORE_HOST = @HAVE_NATIVE_GCORE_HOST@
>>>>  all: info
>>>>
>>>>  info: $(INFO_DEPS)
>>>> -dvi: gdb.dvi stabs.dvi refcard.dvi annotate.dvi
>>>> +dvi: $(DVIFILES)
>>>>  ps: gdb.ps stabs.ps refcard.ps annotate.ps
>>>>  html: $(HTMLFILES)
>>>>  pdf: $(PDFFILES)
>>>> @@ -233,7 +236,7 @@ Doxyfile-gdb-xref:        $(srcdir)/Doxyfile-gdb-xref.in
>>>>  Doxyfile-gdbserver:  $(srcdir)/Doxyfile-gdbserver.in
>>>>       $(doxyedit) $(srcdir)/Doxyfile-gdbserver.in >Doxyfile-gdbserver
>>>>
>>>> -all-doc: info dvi ps # pdf
>>>> +all-doc: info dvi ps pdf
>>>>  diststuff: info man
>>>>       rm -f gdb-cfg.texi
>>>>
>>>> @@ -293,6 +296,18 @@ install-html: $(HTMLFILES)
>>>>         fi; \
>>>>       done
>>>>
>>>> +dvi__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
>>>> +
>>>> +install-dvi: $(DVIFILES)
>>>> +     @$(NORMAL_INSTALL)
>>>> +     test -z "$(dvidir)" || $(mkinstalldirs) "$(DESTDIR)$(dvidir)"
>>>> +     @list='$(DVIFILES)'; for p in $$list; do \
>>>> +       if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
>>>> +       f=$(dvi__strip_dir) \
>>>> +       echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(dvidir)/$$f'"; \
>>>> +       $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(dvidir)/$$f"; \
>>>> +     done
>>>> +
>>>>  pdf__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
>>>>
>>>>  install-pdf: $(PDFFILES)
>>>> diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in
>>>> index f6603daf7fd..f799f16c2bb 100644
>>>> --- a/gdb/testsuite/Makefile.in
>>>> +++ b/gdb/testsuite/Makefile.in
>>>> @@ -105,6 +105,7 @@ INFODIRS=doc
>>>>  info:
>>>>  install-info:
>>>>  dvi:
>>>> +install-dvi:
>>>>  pdf:
>>>>  install-pdf:
>>>>  html:
>>>> diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
>>>> index d12f8746611..4eed8926f48 100644
>>>> --- a/gdbserver/Makefile.in
>>>> +++ b/gdbserver/Makefile.in
>>>> @@ -342,6 +342,7 @@ installcheck:
>>>>  check:
>>>>  info dvi pdf:
>>>>  install-info:
>>>> +install-dvi:
>>>>  install-pdf:
>>>>  html:
>>>>  install-html:
>>>
>>> I gave this a try and install-dvi almost fully works from the top level, though it still fails for gprofng.
>>>
>>> Maybe something for the binutils folks? Otherwise this part looks OK to me.
>>
>> Thanks for checking. Yes IIUC gprofng is part of binutils, and I
>> didn't notice because we don't build it ;-)
>>
> This patch should fix it:
> https://sourceware.org/pipermail/binutils/2024-April/133528.html

Indeed. I suppose the libdecnumber install-dvi failure will have to be addressed by the master copy.

In any case, this looks good. Thanks for fixing it.

Approved-By: Luis Machado <luis.machado@arm.com>
Tested-By: Luis Machado <luis.machado@arm.com>


^ permalink raw reply	[relevance 0%]

* RE: Fix max-depth test case for AIX.
  @ 2024-04-10  6:01  5%     ` Aditya Kamath1
  0 siblings, 0 replies; 200+ results
From: Aditya Kamath1 @ 2024-04-10  6:01 UTC (permalink / raw)
  To: Tom Tromey, Andrew Burgess
  Cc: Ulrich Weigand, Aditya Kamath1 via Gdb-patches, Sangamesh Mallayya


[-- Attachment #1.1: Type: text/plain, Size: 2283 bytes --]

Respected Tom, Andrew and community members,

Hi,

Thank you for your feedback.

Please find attached a patch. (See: 0001-Fix-max-depth-test-case-for-AIX.patch)

Andrew> Given what the test is doing I don't think there's any need for the
Andrew> #ifdef, I'd suggest just adding a comment explaining why we need to
Andrew> ensure the variables are referenced, and reference them.

>Agreed.  Look for 'Do_Nothing' in the Ada tests to see how this is
>handled for Ada programs.  I feel like we've done something similar in
>some cases for C as well.

Thank you Tom. I referred the gdb.ada/varsize_limit/pck.adb file for the Do_nothing function.

package body Pck is
   procedure Do_Nothing (A : System.Address) is
   begin
      null;
   end Do_Nothing;
   function Ident (S : String) return String is
   begin
      return S;
   end Ident;
end Pck;

Here Do_nothing is doing nothing. Did something similar. Let me know if any changes needed.

Output in AIX after this patch is applied.

/current_gdb/binutils-gdb/gdb/gdb version  15.0.50.20240325-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /current_gdb/binutils-gdb/gdb/data-directory

                === gdb Summary ===

# of expected passes            92
/current_gdb/binutils-gdb/gdb/gdb version  15.0.50.20240325-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /current_gdb/binutils-gdb/gdb/data-directory

Have a nice day ahead.

Thanks and regards,
Aditya.


From: Tom Tromey <tom@tromey.com>
Date: Wednesday, 3 April 2024 at 8:28 PM
To: Andrew Burgess <aburgess@redhat.com>
Cc: Aditya Kamath1 <Aditya.Kamath1@ibm.com>, Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, Aditya Kamath1 via Gdb-patches <gdb-patches@sourceware.org>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: [EXTERNAL] Re: Fix max-depth test case for AIX.
Andrew> Given what the test is doing I don't think there's any need for the
Andrew> #ifdef, I'd suggest just adding a comment explaining why we need to
Andrew> ensure the variables are referenced, and reference them.

Agreed.  Look for 'Do_Nothing' in the Ada tests to see how this is
handled for Ada programs.  I feel like we've done something similar in
some cases for C as well.

Tom

[-- Attachment #2: 0001-Fix-max-depth-test-case-for-AIX.patch --]
[-- Type: application/octet-stream, Size: 1223 bytes --]

From 3117e666bad264e460596903acbcd008dc3f9287 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Wed, 10 Apr 2024 00:52:05 -0500
Subject: [PATCH] Fix max-depth test case for AIX.

In AIX, if in the main program the global variables are unused then the linker optimises
these variables and the dwarf will not have proper address to the same. Hence we cannot access these
variables.

This patch is a fix to the same so that all the test case of max-depth can passs in AIX as well.
---
 gdb/testsuite/gdb.base/max-depth.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/testsuite/gdb.base/max-depth.c b/gdb/testsuite/gdb.base/max-depth.c
index fee5de5af34..7e46b134c10 100644
--- a/gdb/testsuite/gdb.base/max-depth.c
+++ b/gdb/testsuite/gdb.base/max-depth.c
@@ -225,8 +225,17 @@ struct V7 : virtual V4, virtual V5, virtual V6 { int v7 = 1; } v7;
 
 #endif /* __cplusplus */
 
+void Do_nothing (struct s1 sone)
+{
+  /*  This Function does nothing.  */
+}
+
 int
 main ()
 {
+  /*  In targets like AIX, linker optimises out unused global
+      variables.  The do_nothing () function stops the linker
+      from doing so.  */
+  Do_nothing (s1);
   return 0;
 }
-- 
2.41.0


^ permalink raw reply	[relevance 5%]

* [PATCH] Avoid complaint warning on mingw
@ 2024-04-09 15:46  7% Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-09 15:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The mingw build currently issues a warning:

./../../src/gdb/utils.h:378:56: warning: ignoring attributes on template argument 'void(const char*, va_list)' {aka 'void(const char*, char*)'} [-Wignored-attributes]

This patch fixes the problem as suggested by Simon:

    https://sourceware.org/pipermail/gdb-patches/2024-April/207908.html

...that is, by changing the warning interceptor to a class with a
single 'warn' method.
---
 gdb/complaints.c          |  8 ++++----
 gdb/complaints.h          |  6 +++---
 gdb/dwarf2/cooked-index.c |  2 +-
 gdb/utils.c               |  2 +-
 gdb/utils.h               | 28 ++++++++++++++++------------
 5 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/gdb/complaints.c b/gdb/complaints.c
index e375c734884..d3c72df6d41 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -58,7 +58,7 @@ complaint_internal (const char *fmt, ...)
 
   warning_hook_handler handler = get_warning_hook_handler ();
   if (handler != nullptr)
-    handler (fmt, args);
+    handler->warn (fmt, args);
   else
     {
       gdb_puts (_("During symbol reading: "), gdb_stderr);
@@ -85,7 +85,7 @@ thread_local complaint_interceptor *complaint_interceptor::g_complaint_intercept
 
 complaint_interceptor::complaint_interceptor ()
   : m_saved_complaint_interceptor (&g_complaint_interceptor, this),
-    m_saved_warning_hook (issue_complaint)
+    m_saved_warning_hook (this)
 {
 }
 
@@ -96,7 +96,7 @@ wrap_warning_hook (warning_hook_handler hook, ...)
 {
   va_list args;
   va_start (args, hook);
-  hook ("%s", args);
+  hook->warn ("%s", args);
   va_end (args);
 }
 
@@ -121,7 +121,7 @@ re_emit_complaints (const complaint_collection &complaints)
 /* See complaints.h.  */
 
 void
-complaint_interceptor::issue_complaint (const char *fmt, va_list args)
+complaint_interceptor::warn (const char *fmt, va_list args)
 {
 #if CXX_STD_THREAD
   std::lock_guard<std::mutex> guard (complaint_mutex);
diff --git a/gdb/complaints.h b/gdb/complaints.h
index 8ac4c5034ee..995c35e0ab0 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -70,7 +70,7 @@ typedef std::unordered_set<std::string> complaint_collection;
    the main thread).  Messages can be re-emitted on the main thread
    using re_emit_complaints, see below.  */
 
-class complaint_interceptor
+class complaint_interceptor final : public warning_hook_handler_type
 {
 public:
 
@@ -94,8 +94,8 @@ class complaint_interceptor
 
   /* A helper function that is used by the 'complaint' implementation
      to issue a complaint.  */
-  static void issue_complaint (const char *, va_list)
-    ATTRIBUTE_PRINTF (1, 0);
+  void warn (const char *, va_list) override
+    ATTRIBUTE_PRINTF (2, 0);
 
   /* This object.  Used by the static callback function.  */
   static thread_local complaint_interceptor *g_complaint_interceptor;
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 66822b575ca..cb0d1f3cd47 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -589,7 +589,7 @@ cooked_index_worker::write_to_cache (const cooked_index *idx,
 	 See PR symtab/30837.  This arranges to capture all such
 	 warnings.  This is safe because we know the deferred_warnings
 	 object isn't in use by any other thread at this point.  */
-      scoped_restore_warning_hook defer (*warn);
+      scoped_restore_warning_hook defer (warn);
       m_cache_store.store ();
     }
 }
diff --git a/gdb/utils.c b/gdb/utils.c
index ded03c74099..6a77f6be713 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -164,7 +164,7 @@ void
 vwarning (const char *string, va_list args)
 {
   if (warning_hook != nullptr)
-    warning_hook (string, args);
+    warning_hook->warn (string, args);
   else
     {
       std::optional<target_terminal::scoped_restore_terminal_state> term_state;
diff --git a/gdb/utils.h b/gdb/utils.h
index 875a2583179..65882363e3c 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -374,8 +374,19 @@ assign_return_if_changed (T &lval, const T &val)
   return true;
 }
 
-/* A function that can be used to intercept warnings.  */
-typedef gdb::function_view<void (const char *, va_list)> warning_hook_handler;
+/* A class that can be used to intercept warnings.  A class is used
+   here, rather than a gdb::function_view because it proved difficult
+   to use a function view in conjunction with ATTRIBUTE_PRINTF in a
+   way that would satisfy all compilers on all systems.  And, even
+   though gdb only ever uses deferred_warnings here, a virtual
+   function is used to help Insight.  */
+struct warning_hook_handler_type
+{
+  virtual void warn (const char *format, va_list args) ATTRIBUTE_PRINTF (2, 0)
+    = 0;
+};
+
+typedef warning_hook_handler_type *warning_hook_handler;
 
 /* Set the thread-local warning hook, and restore the old value when
    finished.  */
@@ -418,7 +429,7 @@ extern warning_hook_handler get_warning_hook_handler ();
    instance of this class with the 'warn' function, and all warnings can be
    emitted with a single call to 'emit'.  */
 
-struct deferred_warnings
+struct deferred_warnings final : public warning_hook_handler_type
 {
   deferred_warnings ()
     : m_can_style (gdb_stderr->can_emit_style_escape ())
@@ -444,18 +455,11 @@ struct deferred_warnings
      hook; see scoped_restore_warning_hook.  Note that no locking is
      done, so users have to be careful to only install this into a
      single thread at a time.  */
-  void operator() (const char *format, va_list args)
+  void warn (const char *format, va_list args) override
+    ATTRIBUTE_PRINTF (2, 0)
   {
     string_file msg (m_can_style);
-    /* Clang warns if we add ATTRIBUTE_PRINTF to this method (because
-       the function-view wrapper doesn't also have the attribute), but
-       then warns again if we remove it, because this vprintf call
-       does not use a literal format string.  So, suppress the
-       warnings here.  */
-    DIAGNOSTIC_PUSH
-    DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
     msg.vprintf (format, args);
-    DIAGNOSTIC_POP
     m_warnings.emplace_back (std::move (msg));
   }
 
-- 
2.43.0


^ permalink raw reply	[relevance 7%]

* [PATCH v3 2/3] gdbserver: allow suppressing the next putpkt remote-debug log
  @ 2024-04-09  7:48 11% ` Tankut Baris Aktemur
  0 siblings, 0 replies; 200+ results
From: Tankut Baris Aktemur @ 2024-04-09  7:48 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom, aburgess

When started with the --remote-debug flag, gdbserver enables the debug
logs for the received and sent remote packets.  If the packet contents
are too long or contain verbatim binary data, printing the contents
may create noise in the logs or even distortion in the terminal output.

Introduce a function, `suppress_next_putpkt_log`, that allows omitting
the contents of a sent package in the logs.  This can be useful when a
certain packet handler knows that it is sending binary data.

My first attempt was to implement this mechanism by passing an extra
parameter to putpt_binary_1 that could be controlled by the caller,
putpkt_binary or putpkt.  However, all qxfer handlers, regardless of
whether they send binary or ascii data, cause the data to be sent via
putpkt_binary. Hence, the solution was going to be either too
suppressive or too intrusive.  I opted for the approach where a package
handler would suppress the log explicitly.
---
 gdbserver/debug.cc        | 10 ++++++++++
 gdbserver/debug.h         | 10 ++++++++++
 gdbserver/remote-utils.cc | 13 ++++++++-----
 3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/gdbserver/debug.cc b/gdbserver/debug.cc
index ae9ca5cd768..3d05a76b26a 100644
--- a/gdbserver/debug.cc
+++ b/gdbserver/debug.cc
@@ -20,6 +20,8 @@
 
 #if !defined (IN_PROCESS_AGENT)
 bool remote_debug = false;
+
+bool suppressed_remote_debug = false;
 #endif
 
 /* Output file for debugging.  Default to standard error.  */
@@ -117,3 +119,11 @@ debug_write (const void *buf, size_t nbyte)
   int fd = fileno (debug_file);
   return write (fd, buf, nbyte);
 }
+
+/* See debug.h.  */
+
+void
+suppress_next_putpkt_log ()
+{
+  suppressed_remote_debug = true;
+}
diff --git a/gdbserver/debug.h b/gdbserver/debug.h
index f78ef2580c3..eb6f69549ae 100644
--- a/gdbserver/debug.h
+++ b/gdbserver/debug.h
@@ -22,6 +22,11 @@
 #if !defined (IN_PROCESS_AGENT)
 extern bool remote_debug;
 
+/* If true, do not print the packet content sent with the next putpkt.
+   This flag is reset to false after each putpkt logging.  Useful to
+   omit printing binary packet contents.  */
+extern bool suppressed_remote_debug;
+
 /* Print a "remote" debug statement.  */
 
 #define remote_debug_printf(fmt, ...) \
@@ -59,4 +64,9 @@ void debug_flush (void);
 /* Async signal safe debug output function that calls write directly.  */
 ssize_t debug_write (const void *buf, size_t nbyte);
 
+/* Suppress the next putpkt debug log by omitting the packet contents.
+   Useful to reduce the logs when sending binary packets.  */
+
+void suppress_next_putpkt_log ();
+
 #endif /* GDBSERVER_DEBUG_H */
diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index 5a8eb9ae52a..a5b5d25dd5e 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -25,6 +25,7 @@
 #include "debug.h"
 #include "dll.h"
 #include "gdbsupport/rsp-low.h"
+#include "gdbsupport/scope-exit.h"
 #include "gdbsupport/netstuff.h"
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/gdb-sigmask.h"
@@ -634,6 +635,8 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif)
   char *p;
   int cc;
 
+  SCOPE_EXIT { suppressed_remote_debug = false; };
+
   buf2 = (char *) xmalloc (strlen ("$") + cnt + strlen ("#nn") + 1);
 
   /* Copy the packet into buffer BUF2, encapsulating it
@@ -668,15 +671,15 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif)
       if (cs.noack_mode || is_notif)
 	{
 	  /* Don't expect an ack then.  */
-	  if (is_notif)
-	    remote_debug_printf ("putpkt (\"%s\"); [notif]", buf2);
-	  else
-	    remote_debug_printf ("putpkt (\"%s\"); [noack mode]", buf2);
+	  remote_debug_printf ("putpkt (\"%s\"); [%s]",
+			       (suppressed_remote_debug ? "..." : buf2),
+			       (is_notif ? "notif" : "noack mode"));
 
 	  break;
 	}
 
-      remote_debug_printf ("putpkt (\"%s\"); [looking for ack]", buf2);
+      remote_debug_printf ("putpkt (\"%s\"); [looking for ack]",
+			   (suppressed_remote_debug ? "..." : buf2));
 
       cc = readchar ();
 
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 11%]

* [PATCH v4] gdb: Support embedded source in DWARF
@ 2024-04-09  4:57 27% Will Hawkins
  0 siblings, 0 replies; 200+ results
From: Will Hawkins @ 2024-04-09  4:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Will Hawkins

While DW_LNCT_source is not yet finalized in the DWARF standard
(https://dwarfstd.org/issues/180201.1.html), LLVM does emit it.

This patch adds support for it in gdb.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
---

Notes:
    v3 -> v4
      - Initialize the source pointer in the symtab to NULL.
      - Fix a bug that caused an error generating formatted output.
    v2 -> v3
      - Address feedback from v2.
      - Fixed up a bug where non-CU embedded files were incorrectly
        marked as embedded.
      - Revamped source access through the cache to avoid copies.
    
    v1 -> v2
      - Address feedback from original PR
      - Add support for maintenance commands to see embedded source status
      - Prevent access to the filesystem for symtabs with embedded source
      - Add additional unit tests

 gdb/dwarf2/file-and-dir.h                    | 23 ++++-
 gdb/dwarf2/line-header.c                     | 22 +++--
 gdb/dwarf2/line-header.h                     |  9 +-
 gdb/dwarf2/read.c                            | 83 +++++++++++++++---
 gdb/extension.c                              |  7 +-
 gdb/extension.h                              |  9 +-
 gdb/source-cache.c                           | 87 ++++++++++++-------
 gdb/source-cache.h                           | 12 +--
 gdb/source.c                                 | 74 +++++++++++-----
 gdb/source.h                                 |  4 +
 gdb/symfile.c                                |  1 +
 gdb/symmisc.c                                | 17 ++--
 gdb/symtab.h                                 |  5 ++
 gdb/testsuite/gdb.dwarf2/dw2-lnct-source.c   | 24 ++++++
 gdb/testsuite/gdb.dwarf2/dw2-lnct-source.exp | 88 ++++++++++++++++++++
 gdb/testsuite/lib/dwarf.exp                  | 19 +++--
 include/dwarf2.h                             |  5 ++
 17 files changed, 391 insertions(+), 98 deletions(-)
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-lnct-source.c
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-lnct-source.exp

diff --git a/gdb/dwarf2/file-and-dir.h b/gdb/dwarf2/file-and-dir.h
index a5b1d8a3a21..84a7367e973 100644
--- a/gdb/dwarf2/file-and-dir.h
+++ b/gdb/dwarf2/file-and-dir.h
@@ -95,7 +95,14 @@ struct file_and_directory
   const char *get_fullname ()
   {
     if (m_fullname == nullptr)
-      m_fullname = find_source_or_rewrite (get_name (), get_comp_dir ());
+      {
+	if (m_is_embedded)
+	  m_fullname = make_unique_xstrdup (embedded_fullname (
+							       get_name (),
+							       get_comp_dir ()));
+	else
+	  m_fullname = find_source_or_rewrite (get_name (), get_comp_dir ());
+      }
     return m_fullname.get ();
   }
 
@@ -105,6 +112,17 @@ struct file_and_directory
     m_fullname.reset ();
   }
 
+  /* Set whether the file's source is embedded in the dwarf.  */
+  void set_embedded (bool is_embedded)
+  {
+    m_is_embedded = is_embedded;
+  }
+
+  /* Return true if the file's source is embedded in the dwarf.  */
+  bool is_embedded () const
+  {
+    return m_is_embedded;
+  }
 private:
 
   /* The filename.  */
@@ -124,6 +142,9 @@ struct file_and_directory
 
   /* The full name.  */
   gdb::unique_xmalloc_ptr<char> m_fullname;
+
+  /* Whether the file's source is embedded in the dwarf.  */
+  bool m_is_embedded = false;
 };
 
 #endif /* GDB_DWARF2_FILE_AND_DIR_H */
diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
index a3ca49b64f5..3bc707e999e 100644
--- a/gdb/dwarf2/line-header.c
+++ b/gdb/dwarf2/line-header.c
@@ -45,6 +45,7 @@ line_header::add_include_dir (const char *include_dir)
 void
 line_header::add_file_name (const char *name,
 			    dir_index d_index,
+			    const char *source,
 			    unsigned int mod_time,
 			    unsigned int length)
 {
@@ -54,7 +55,7 @@ line_header::add_file_name (const char *name,
   if (dwarf_line_debug >= 2)
     gdb_printf (gdb_stdlog, "Adding file %d: %s\n", index, name);
 
-  m_file_names.emplace_back (name, index, d_index, mod_time, length);
+  m_file_names.emplace_back (name, index, d_index, source, mod_time, length);
 }
 
 std::string
@@ -125,6 +126,7 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
 			void (*callback) (struct line_header *lh,
 					  const char *name,
 					  dir_index d_index,
+					  const char *source,
 					  unsigned int mod_time,
 					  unsigned int length))
 {
@@ -239,13 +241,17 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
 	      break;
 	    case DW_LNCT_MD5:
 	      break;
+	    case DW_LNCT_LLVM_SOURCE:
+	      if (string.has_value () && (*string)[0] != '\0')
+		fe.source = *string;
+	      break;
 	    default:
 	      complaint (_("Unknown format content type %s"),
 			 pulongest (content_type));
 	    }
 	}
 
-      callback (lh, fe.name, fe.d_index, fe.mod_time, fe.length);
+      callback (lh, fe.name, fe.d_index, fe.source, fe.mod_time, fe.length);
     }
 
   *bufp = buf;
@@ -368,8 +374,8 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
       read_formatted_entries (per_objfile, abfd, &line_ptr, lh.get (),
 			      offset_size,
 			      [] (struct line_header *header, const char *name,
-				  dir_index d_index, unsigned int mod_time,
-				  unsigned int length)
+				  dir_index d_index, const char *source,
+				  unsigned int mod_time, unsigned int length)
 	{
 	  header->add_include_dir (name);
 	});
@@ -378,10 +384,10 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
       read_formatted_entries (per_objfile, abfd, &line_ptr, lh.get (),
 			      offset_size,
 			      [] (struct line_header *header, const char *name,
-				  dir_index d_index, unsigned int mod_time,
-				  unsigned int length)
+				  dir_index d_index, const char *source,
+				  unsigned int mod_time, unsigned int length)
 	{
-	  header->add_file_name (name, d_index, mod_time, length);
+	  header->add_file_name (name, d_index, source, mod_time, length);
 	});
     }
   else
@@ -408,7 +414,7 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
 	  length = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 	  line_ptr += bytes_read;
 
-	  lh->add_file_name (cur_file, d_index, mod_time, length);
+	  lh->add_file_name (cur_file, d_index, nullptr, mod_time, length);
 	}
       line_ptr += bytes_read;
     }
diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index c068dff70a3..abc95f3ee87 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -35,9 +35,10 @@ struct file_entry
   file_entry () = default;
 
   file_entry (const char *name_, file_name_index index_, dir_index d_index_,
-	      unsigned int mod_time_, unsigned int length_)
+	      const char *source_, unsigned int mod_time_, unsigned int length_)
     : name (name_),
       index (index_),
+      source (source_),
       d_index (d_index_),
       mod_time (mod_time_),
       length (length_)
@@ -54,6 +55,10 @@ struct file_entry
   /* The index of this file in the file table.  */
   file_name_index index {};
 
+  /* The file's contents (if not null).  Note this is an observing pointer.
+     The memory is owned by debug_line_buffer.  */
+  const char *source {};
+
   /* The directory index (1-based).  */
   dir_index d_index {};
 
@@ -88,7 +93,7 @@ struct line_header
   void add_include_dir (const char *include_dir);
 
   /* Add an entry to the file name table.  */
-  void add_file_name (const char *name, dir_index d_index,
+  void add_file_name (const char *name, dir_index d_index, const char *source,
 		      unsigned int mod_time, unsigned int length);
 
   /* Return the include dir at INDEX (0-based in DWARF 5 and 1-based before).
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 7442094874c..e35ff019acf 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1635,6 +1635,10 @@ struct quick_file_names
   /* The file names from the line table after being run through
      gdb_realpath.  These are computed lazily.  */
   const char **real_names;
+
+  /* Whether or not the file names refer to sources embedded
+     in the dwarf.  */
+  const bool *embeddeds;
 };
 
 /* With OBJF_READNOW, the DWARF reader expands all CUs immediately.
@@ -1908,27 +1912,39 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
   if (slot != nullptr)
     *slot = qfn;
 
+
+  bool cu_file_embedded = false;
+  std::vector<bool> embeddedv;
+
   std::vector<const char *> include_names;
   if (lh != nullptr)
     {
       for (const auto &entry : lh->file_names ())
 	{
 	  std::string name_holder;
-	  const char *include_name =
-	    compute_include_file_name (lh.get (), entry, fnd, name_holder);
+	  const char *include_name
+	    = compute_include_file_name (lh.get (), entry, fnd, name_holder);
 	  if (include_name != nullptr)
 	    {
 	      include_name = per_objfile->objfile->intern (include_name);
 	      include_names.push_back (include_name);
+	      embeddedv.push_back (entry.source != nullptr);
 	    }
+	  else if (entry.source != nullptr)
+	    {
+	      /* We have an embedded source for the CU.  */
+	      gdb_assert (offset == 1);
+	      cu_file_embedded = true;
+	    }
+
 	}
     }
 
   qfn->num_file_names = offset + include_names.size ();
   qfn->comp_dir = fnd.intern_comp_dir (per_objfile->objfile);
-  qfn->file_names =
-    XOBNEWVEC (&per_objfile->per_bfd->obstack, const char *,
-	       qfn->num_file_names);
+  qfn->file_names
+    = XOBNEWVEC (&per_objfile->per_bfd->obstack, const char *,
+		 qfn->num_file_names);
   if (offset != 0)
     qfn->file_names[0] = per_objfile->objfile->intern (fnd.get_name ());
 
@@ -1936,7 +1952,16 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
     memcpy (&qfn->file_names[offset], include_names.data (),
 	    include_names.size () * sizeof (const char *));
 
-  qfn->real_names = NULL;
+  bool *embeddeds
+    = XOBNEWVEC (&per_objfile->per_bfd->obstack, bool,
+		 qfn->num_file_names);
+  if (cu_file_embedded)
+    embeddeds[0] = true;
+  for (size_t i = 0; i < embeddedv.size (); i++)
+    embeddeds[offset + i] = embeddedv[i];
+  qfn->embeddeds = embeddeds;
+
+  qfn->real_names = nullptr;
 
   lh_cu->file_names = qfn;
 }
@@ -1980,7 +2005,11 @@ dw2_get_real_path (dwarf2_per_objfile *per_objfile,
 	dirname = qfn->comp_dir;
 
       gdb::unique_xmalloc_ptr<char> fullname;
-      fullname = find_source_or_rewrite (qfn->file_names[index], dirname);
+
+      if (qfn->embeddeds[index])
+	fullname.reset (embedded_fullname (dirname, qfn->file_names[index]));
+      else
+	fullname = find_source_or_rewrite (qfn->file_names[index], dirname);
 
       qfn->real_names[index] = fullname.release ();
     }
@@ -7311,6 +7340,35 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu)
   file_and_directory res (dwarf2_string_attr (die, DW_AT_name, cu),
 			  dwarf2_string_attr (die, DW_AT_comp_dir, cu));
 
+  /* Because the line header may tell us information about the CU
+     filename (e.g., whether it is embedded) which will affect other
+     calculations, we have to read that information here.  */
+  line_header *lh = cu->line_header;
+  struct attribute *attr = dwarf2_attr (die, DW_AT_stmt_list, cu);
+  if (lh == nullptr && attr != nullptr && attr->form_is_unsigned ())
+    {
+      sect_offset line_offset = (sect_offset) attr->as_unsigned ();
+      line_header_up lhu = dwarf_decode_line_header (line_offset, cu,
+				     res.get_comp_dir ());
+      if (lhu != nullptr)
+	  lh = lhu.release();
+    }
+
+  if (lh != nullptr)
+    {
+      for (const auto &entry : lh->file_names ())
+	{
+	  if (entry.source == nullptr)
+	    continue;
+
+	  std::string name_holder;
+	  const char *include_name =
+	    compute_include_file_name (lh, entry, res, name_holder);
+	  if (include_name == nullptr)
+	    res.set_embedded (true);
+	}
+    }
+
   if (res.get_comp_dir () == nullptr
       && producer_is_gcc_lt_4_3 (cu)
       && res.get_name () != nullptr
@@ -18448,7 +18506,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 		    length =
 		      read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 		    line_ptr += bytes_read;
-		    lh->add_file_name (cur_file, dindex, mod_time, length);
+		    lh->add_file_name (cur_file, dindex, nullptr, mod_time, length);
 		  }
 		  break;
 		case DW_LNE_set_discriminator:
@@ -18603,9 +18661,12 @@ dwarf_decode_lines (struct line_header *lh, struct dwarf2_cu *cu,
       subfile *sf = builder->get_current_subfile ();
 
       if (sf->symtab == nullptr)
-	sf->symtab = allocate_symtab (cust, sf->name.c_str (),
-				      sf->name_for_id.c_str ());
-
+	{
+	  sf->symtab = allocate_symtab (cust, sf->name.c_str (),
+					sf->name_for_id.c_str ());
+	  if (fe.source)
+	    sf->symtab->source = fe.source;
+	}
       fe.symtab = sf->symtab;
     }
 }
diff --git a/gdb/extension.c b/gdb/extension.c
index 9db8b53a087..f17991a3751 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -991,16 +991,19 @@ xmethod_worker::get_result_type (value *object, gdb::array_view<value *> args)
 /* See extension.h.  */
 
 std::optional<std::string>
-ext_lang_colorize (const std::string &filename, const std::string &contents)
+ext_lang_colorize (const std::string &filename, const std::string_view contents)
 {
   std::optional<std::string> result;
 
+  /* We avoided copies as long as possible. The external colorization API
+     requires a std::string.  */
+  std::string contents_storage = std::string (contents);
   for (const struct extension_language_defn *extlang : extension_languages)
     {
       if (extlang->ops == nullptr
 	  || extlang->ops->colorize == nullptr)
 	continue;
-      result = extlang->ops->colorize (filename, contents);
+      result = extlang->ops->colorize (filename, contents_storage);
       if (result.has_value ())
 	return result;
     }
diff --git a/gdb/extension.h b/gdb/extension.h
index 5260bcbde00..e5a5333b7c3 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -319,12 +319,13 @@ extern void get_matching_xmethod_workers
    std::vector<xmethod_worker_up> *workers);
 
 /* Try to colorize some source code.  FILENAME is the name of the file
-   holding the code.  CONTENTS is the source code itself.  This will
-   either a colorized (using ANSI terminal escapes) version of the
-   source code, or an empty value if colorizing could not be done.  */
+   holding the code.  CONTENTS is a view of the source code itself.
+   This will either generate a colorized (using ANSI terminal escapes)
+   version of the source code, or an empty value if colorizing could not
+   be done.  */
 
 extern std::optional<std::string> ext_lang_colorize
-  (const std::string &filename, const std::string &contents);
+  (const std::string &filename, const std::string_view contents);
 
 /* Try to colorize a single line of disassembler output, CONTENT for
    GDBARCH.  This will return either a colorized (using ANSI terminal
diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index 8b5bd84d19a..f5168921f99 100644
--- a/gdb/source-cache.c
+++ b/gdb/source-cache.c
@@ -93,32 +93,45 @@ set_use_gnu_source_highlight_enabled (const char *ignore_args,
 
 /* See source-cache.h.  */
 
-std::string
+std::string_view
 source_cache::get_plain_source_lines (struct symtab *s,
-				      const std::string &fullname)
+				      const std::string &fullname,
+				      std::string &source_storage)
 {
-  scoped_fd desc (open_source_file (s));
-  if (desc.get () < 0)
-    perror_with_name (symtab_to_filename_for_display (s), -desc.get ());
+  std::string_view lines;
+  if (!s->source)
+    {
+
+      scoped_fd desc (open_source_file (s));
+      if (desc.get () < 0)
+	perror_with_name (symtab_to_filename_for_display (s), -desc.get ());
 
-  struct stat st;
-  if (fstat (desc.get (), &st) < 0)
-    perror_with_name (symtab_to_filename_for_display (s));
+      struct stat st;
+      if (fstat (desc.get (), &st) < 0)
+	perror_with_name (symtab_to_filename_for_display (s));
 
-  std::string lines;
-  lines.resize (st.st_size);
-  if (myread (desc.get (), &lines[0], lines.size ()) < 0)
-    perror_with_name (symtab_to_filename_for_display (s));
+      source_storage.resize (st.st_size);
+      if (myread (desc.get (),
+		  &source_storage[0],
+		  source_storage.size ()) < 0)
+	perror_with_name (symtab_to_filename_for_display (s));
 
-  time_t mtime = 0;
-  if (s->compunit ()->objfile () != NULL
-      && s->compunit ()->objfile ()->obfd != NULL)
-    mtime = s->compunit ()->objfile ()->mtime;
-  else if (current_program_space->exec_bfd ())
-    mtime = current_program_space->ebfd_mtime;
+      time_t mtime = 0;
+      if (s->compunit ()->objfile () != nullptr
+	  && s->compunit ()->objfile ()->obfd != nullptr)
+	mtime = s->compunit ()->objfile ()->mtime;
+      else if (current_program_space->exec_bfd ())
+	mtime = current_program_space->ebfd_mtime;
 
-  if (mtime && mtime < st.st_mtime)
-    warning (_("Source file is more recent than executable."));
+      if (mtime && mtime < st.st_mtime)
+	warning (_("Source file is more recent than executable."));
+
+      lines = source_storage;
+    }
+  else
+    {
+      lines = s->source;
+    }
 
   std::vector<off_t> offsets;
   offsets.push_back (0);
@@ -200,9 +213,10 @@ get_language_name (enum language lang)
    succeeded.  */
 
 static bool
-try_source_highlight (std::string &contents ATTRIBUTE_UNUSED,
+try_source_highlight (std::string_view &contents ATTRIBUTE_UNUSED,
 		      enum language lang ATTRIBUTE_UNUSED,
-		      const std::string &fullname ATTRIBUTE_UNUSED)
+		      const std::string &fullname ATTRIBUTE_UNUSED,
+		      std::string &contents_storage)
 {
 #ifdef HAVE_SOURCE_HIGHLIGHT
   if (!use_gnu_source_highlight)
@@ -240,10 +254,14 @@ try_source_highlight (std::string &contents ATTRIBUTE_UNUSED,
 	  lang_name = detected_lang.c_str ();
 	}
 
-      std::istringstream input (contents);
+      /* We waited as long as possible but now we need a string.  */
+      contents_storage = contents;
+      std::istringstream input (contents_storage);
       std::ostringstream output;
       highlighter->highlight (input, output, lang_name, fullname);
-      contents = std::move (output).str ();
+      /* Use the given storage for the contents and set the
+	 view appropriately.  */
+      contents = contents_storage = std::move (output).str ();
       styled = true;
     }
   catch (...)
@@ -275,13 +293,16 @@ static void gnu_source_highlight_test ()
        "}\n");
   const std::string fullname = "test.c";
   std::string styled_prog;
+  std::string_view styled_prog_view;
 
   bool res = false;
   bool saw_exception = false;
   styled_prog = prog;
+  styled_prog_view = styled_prog;
   try
     {
-      res = try_source_highlight (styled_prog, language_c, fullname);
+      res = try_source_highlight (styled_prog_view, language_c, fullname,
+				  styled_prog);
     }
   catch (...)
     {
@@ -324,10 +345,12 @@ source_cache::ensure (struct symtab *s)
 	}
     }
 
-  std::string contents;
+  std::string_view source_contents;
+  std::string source_contents_storage;
   try
     {
-      contents = get_plain_source_lines (s, fullname);
+      source_contents = get_plain_source_lines (s, fullname,
+						source_contents_storage);
     }
   catch (const gdb_exception_error &e)
     {
@@ -339,15 +362,17 @@ source_cache::ensure (struct symtab *s)
       && m_no_styling_files.count (fullname) == 0)
     {
       bool already_styled
-	= try_source_highlight (contents, s->language (), fullname);
+	= try_source_highlight (source_contents, s->language (), fullname,
+				source_contents_storage);
 
       if (!already_styled)
 	{
 	  std::optional<std::string> ext_contents;
-	  ext_contents = ext_lang_colorize (fullname, contents);
+	  ext_contents = ext_lang_colorize (fullname, source_contents);
 	  if (ext_contents.has_value ())
 	    {
-	      contents = std::move (*ext_contents);
+	      source_contents = source_contents_storage
+		= std::move (*ext_contents);
 	      already_styled = true;
 	    }
 	}
@@ -369,7 +394,7 @@ source_cache::ensure (struct symtab *s)
 	}
     }
 
-  source_text result = { std::move (fullname), std::move (contents) };
+  source_text result = { std::move (fullname), std::string (source_contents) };
   m_source_map.push_back (std::move (result));
 
   if (m_source_map.size () > MAX_ENTRIES)
diff --git a/gdb/source-cache.h b/gdb/source-cache.h
index d4cb7d00ae8..84996a6a5a1 100644
--- a/gdb/source-cache.h
+++ b/gdb/source-cache.h
@@ -80,11 +80,13 @@ class source_cache
     std::string contents;
   };
 
-  /* A helper function for get_source_lines reads a source file.
-     Returns the contents of the file; or throws an exception on
-     error.  This also updates m_offset_cache.  */
-  std::string get_plain_source_lines (struct symtab *s,
-				      const std::string &fullname);
+  /* A helper function for get_source_lines that reads a source file.
+     Returns a view of the contents of the file using SOURCE_STORAGE
+     as necessary (i.e., if the source is stored on disk);  or throws
+     an exception on error.  This also updates m_offset_cache.  */
+  std::string_view get_plain_source_lines (struct symtab *s,
+					   const std::string &fullname,
+					   std::string &source_storage);
 
   /* A helper function that the data for the given symtab is entered
      into both caches.  Returns false on error.  */
diff --git a/gdb/source.c b/gdb/source.c
index bbeb4154258..8bfaffe43a8 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -684,9 +684,11 @@ info_source_command (const char *ignore, int from_tty)
 
   cust = s->compunit ();
   gdb_printf (_("Current source file is %s\n"), s->filename);
-  if (s->compunit ()->dirname () != NULL)
+  if (s->compunit ()->dirname () != nullptr)
     gdb_printf (_("Compilation directory is %s\n"), s->compunit ()->dirname ());
-  if (s->fullname)
+  if (s->source != nullptr)
+    gdb_printf (_("With embedded source.\n"));
+  else if (s->fullname)
     gdb_printf (_("Located in %s\n"), s->fullname);
   const std::vector<off_t> *offsets;
   if (g_source_cache.get_line_charpos (s, &offsets))
@@ -960,6 +962,19 @@ source_full_path_of (const char *filename,
   return 1;
 }
 
+/* See source.h.  */
+
+char *
+embedded_fullname (const char *dirname, const char *filename)
+{
+  if (dirname != nullptr)
+    {
+      return concat (dirname, SLASH_STRING, filename, (char *) nullptr);
+    }
+
+  return xstrdup (filename);
+}
+
 /* Return non-zero if RULE matches PATH, that is if the rule can be
    applied to PATH.  */
 
@@ -1237,27 +1252,35 @@ symtab_to_fullname (struct symtab *s)
   /* Use cached copy if we have it.
      We rely on forget_cached_source_info being called appropriately
      to handle cases like the file being moved.  */
-  if (s->fullname == NULL)
+  if (s->fullname == nullptr)
     {
-      scoped_fd fd = open_source_file (s);
-
-      if (fd.get () < 0)
+      if (s->source)
+	  s->fullname = embedded_fullname (s->compunit ()->dirname (),
+					   s->filename);
+      else
 	{
-	  gdb::unique_xmalloc_ptr<char> fullname;
+	  scoped_fd fd = open_source_file (s);
 
-	  /* rewrite_source_path would be applied by find_and_open_source, we
-	     should report the pathname where GDB tried to find the file.  */
+	  if (fd.get () < 0)
+	    {
+	      gdb::unique_xmalloc_ptr<char> fullname;
 
-	  if (s->compunit ()->dirname () == nullptr
-	      || IS_ABSOLUTE_PATH (s->filename))
-	    fullname.reset (xstrdup (s->filename));
-	  else
-	    fullname.reset (concat (s->compunit ()->dirname (), SLASH_STRING,
-				    s->filename, (char *) NULL));
+	      /* rewrite_source_path would be applied by find_and_open_source,
+		 we should report the pathname where GDB tried to find the
+		 file.  */
 
-	  s->fullname = rewrite_source_path (fullname.get ()).release ();
-	  if (s->fullname == NULL)
-	    s->fullname = fullname.release ();
+	      if (s->compunit ()->dirname () == nullptr
+		  || IS_ABSOLUTE_PATH (s->filename))
+		fullname.reset (xstrdup (s->filename));
+	      else
+		fullname.reset (concat (s->compunit ()->dirname (),
+					SLASH_STRING, s->filename,
+					(char *) nullptr));
+
+	      s->fullname = rewrite_source_path (fullname.get ()).release ();
+	      if (s->fullname == nullptr)
+		s->fullname = fullname.release ();
+	    }
 	}
     } 
 
@@ -1317,12 +1340,17 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
       else
 	{
 	  last_source_visited = s;
-	  scoped_fd desc = open_source_file (s);
-	  last_source_error = desc.get () < 0;
-	  if (last_source_error)
+	  /* Do not attempt to open a source file for a symtab
+	     with an embedded source.  */
+	  if (!s->source)
 	    {
-	      noprint = true;
-	      errcode = -desc.get ();
+	      scoped_fd desc = open_source_file (s);
+	      last_source_error = desc.get () < 0;
+	      if (last_source_error)
+		{
+		  noprint = true;
+		  errcode = -desc.get ();
+		}
 	    }
 	}
     }
diff --git a/gdb/source.h b/gdb/source.h
index 144ee48f722..f27caf1a9b5 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -216,4 +216,8 @@ extern void forget_cached_source_info (void);
    need to would make things slower than necessary.  */
 extern void select_source_symtab ();
 
+/* Compute the fullname for a source file whose source is embedded
+   in the dwarf file.  */
+extern char *embedded_fullname (const char *dirname,
+				const char *filename);
 #endif
diff --git a/gdb/symfile.c b/gdb/symfile.c
index db6d76e78bf..48b297b540b 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2835,6 +2835,7 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename,
   symtab->filename = objfile->intern (filename);
   symtab->filename_for_id = objfile->intern (filename_for_id);
   symtab->fullname = NULL;
+  symtab->source = NULL;
   symtab->set_language (deduce_language_from_filename (filename));
 
   /* This can be very verbose with lots of headers.
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 49b9674f77a..91d9ca906a5 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -810,9 +810,11 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
 		    gdb_printf ("((struct symtab *) %s)\n",
 				host_address_to_string (symtab));
 		    gdb_printf ("\t  fullname %s\n",
-				symtab->fullname != NULL
+				symtab->fullname != nullptr
 				? symtab->fullname
 				: "(null)");
+		    if (symtab->source != nullptr)
+		      gdb_printf ("\t  source embedded in DWARF\n");
 		    gdb_printf ("\t  "
 				"linetable ((struct linetable *) %s)\n",
 				host_address_to_string
@@ -955,15 +957,20 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
   gdb_printf (_("compunit_symtab: %s ((struct compunit_symtab *) %s)\n"),
 	      symtab->compunit ()->name,
 	      host_address_to_string (symtab->compunit ()));
+  styled_string_s styled_symtab_fullname;
+  if (symtab->source)
+    styled_symtab_fullname = *styled_string (metadata_style.style (),
+					    _("Source embedded in DWARF"));
+  else
+    styled_symtab_fullname = *styled_string (file_name_style.style (),
+					    symtab_to_fullname (symtab));
   gdb_printf (_("symtab: %ps ((struct symtab *) %s)\n"),
-	      styled_string (file_name_style.style (),
-			     symtab_to_fullname (symtab)),
+	      &styled_symtab_fullname,
 	      host_address_to_string (symtab));
   linetable = symtab->linetable ();
   gdb_printf (_("linetable: ((struct linetable *) %s):\n"),
 	      host_address_to_string (linetable));
-
-  if (linetable == NULL)
+  if (linetable == nullptr)
     gdb_printf (_("No line table.\n"));
   else if (linetable->nitems <= 0)
     gdb_printf (_("Line table has no lines.\n"));
diff --git a/gdb/symtab.h b/gdb/symtab.h
index bf9a3cfb79f..90c2f202390 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1755,6 +1755,11 @@ struct symtab
 
   const char *filename;
 
+  /* When the contents of the source file were/are embedded with the
+     debugging info, this pointer will refer to that source. Can be nullptr
+     if the source for this source file is on disk.  */
+  const char *source;
+
   /* Filename for this source file, used as an identifier to link with
      related objects such as associated macro_source_file objects.  It must
      therefore match the name of any macro_source_file object created for this
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.c b/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.c
new file mode 100644
index 00000000000..86cdb9655b7
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.c
@@ -0,0 +1,24 @@
+/* Copyright 2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+
+int
+main (void)
+{							/* main prologue */
+  asm ("main_label: .global main_label");
+  int m = 42;						/* main assign m */
+  asm ("main_end: .global main_end");			/* main end */
+  return m;
+}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.exp b/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.exp
new file mode 100644
index 00000000000..73a06bd7b9c
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.exp
@@ -0,0 +1,88 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that GDB can honor LNCT_llvm_SOURCE.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+require dwarf2_support
+
+standard_testfile .c .S
+
+set asm_file [standard_output_file $srcfile2]
+
+set fp [open "${srcdir}/${subdir}/${srcfile}" r]
+set srcfile_data [read $fp]
+close $fp
+
+Dwarf::assemble $asm_file {
+    global srcdir subdir srcfile srcfile2 srcfile_data
+    declare_labels lines_label
+
+    get_func_info main
+
+    cu {} {
+	compile_unit {
+	    {language @DW_LANG_C}
+	    {name missing-file.c}
+	    {stmt_list ${lines_label} DW_FORM_sec_offset}
+	} {
+	    subprogram {
+		{external 1 flag}
+		{name main}
+		{low_pc $main_start addr}
+		{high_pc "$main_start + $main_len" addr}
+	    }
+	}
+    }
+
+    lines {version 5} lines_label {
+	set diridx [include_dir "${srcdir}/${subdir}"]
+	file_name "missing-file.c" $diridx "${srcfile_data}"
+
+	program {
+	    DW_LNS_set_file $diridx
+	    DW_LNE_set_address $main_start
+	    line [gdb_get_line_number "main prologue"]
+	    DW_LNS_copy
+
+	    DW_LNE_set_address main_label
+	    line [gdb_get_line_number "main assign m"]
+	    DW_LNS_copy
+
+	    DW_LNE_set_address main_end
+	    line [gdb_get_line_number "main end"]
+	    DW_LNS_copy
+
+	    DW_LNE_end_sequence
+	}
+    }
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+	  [list $srcfile $asm_file] {nodebug}] } {
+    return -1
+}
+
+if ![runto_main] {
+    return -1
+}
+
+set assign_m_line [gdb_get_line_number "main assign m"]
+gdb_test "frame" ".*main \\\(\\\) at \[^\r\n\]*:$assign_m_line\r\n.*"
+gdb_test "maintenance info symtabs missing-file.c" ".*source embedded in DWARF.*"
+gdb_test "maintenance info line-table missing-file.c" ".*symtab: Source embedded in DWARF.*"
+gdb_test "info source" ".*With embedded source.*"
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index d085f835f07..b1f09eab3d3 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -2423,9 +2423,9 @@ namespace eval Dwarf {
 	# Add a file name entry to the line table header's file names table.
 	#
 	# Return the index by which this entry can be referred to.
-	proc file_name {filename diridx} {
+	proc file_name {filename diridx { source "" } } {
 	    variable _line_file_names
-	    lappend _line_file_names $filename $diridx
+	    lappend _line_file_names $filename $diridx $source
 
 	    if { $Dwarf::_line_unit_version >= 5 } {
 		return [expr [llength $_line_file_names] - 1]
@@ -2481,7 +2481,7 @@ namespace eval Dwarf {
 		    }
 		}
 
-		_op .byte 2 "file_name_entry_format_count"
+		_op .byte 3 "file_name_entry_format_count"
 		_op .uleb128 1 \
 		    "file_name_entry_format (content type code: DW_LNCT_path)"
 		switch $_line_string_form {
@@ -2494,15 +2494,21 @@ namespace eval Dwarf {
 			    "directory_entry_format (form: DW_FORM_line_strp)"
 		    }
 		}
+
 		_op .uleb128 2 \
 		    "file_name_entry_format (content type code: DW_LNCT_directory_index)"
 		_op .uleb128 0x0f \
 		    "file_name_entry_format (form: DW_FORM_udata)"
 
-		set nr_files [expr [llength $_line_file_names] / 2]
+		_op .uleb128 0x2001 \
+		    "file_name_entry_format (content type code: DW_LNCT_LLVM_SOURCE)"
+		_op .uleb128 0x08 \
+		    "file_name_entry_format (form: DW_FORM_string)"
+
+		set nr_files [expr [llength $_line_file_names] / 3]
 		_op .byte $nr_files "file_names_count"
 
-		foreach { filename diridx } $_line_file_names {
+		foreach { filename diridx source } $_line_file_names {
 		    switch $_line_string_form {
 			string {
 			    _op .ascii [_quote $filename]
@@ -2517,6 +2523,7 @@ namespace eval Dwarf {
 			}
 		    }
 		    _op .uleb128 $diridx
+		    _op .ascii [_quote [string map { "\"" "\\\"" "\n" "\\n" } $source]]
 		}
 	    } else {
 		foreach dirname $_line_include_dirs {
@@ -2525,7 +2532,7 @@ namespace eval Dwarf {
 
 		_op .byte 0 "Terminator (include_directories)"
 
-		foreach { filename diridx } $_line_file_names {
+		foreach { filename diridx source } $_line_file_names {
 		    _op .ascii [_quote $filename]
 		    _op .sleb128 $diridx
 		    _op .sleb128 0 "mtime"
diff --git a/include/dwarf2.h b/include/dwarf2.h
index b3d3731ee83..3823c041bab 100644
--- a/include/dwarf2.h
+++ b/include/dwarf2.h
@@ -289,6 +289,11 @@ enum dwarf_line_number_content_type
     DW_LNCT_size = 0x4,
     DW_LNCT_MD5 = 0x5,
     DW_LNCT_lo_user = 0x2000,
+    /* LLVM has implemented DW_LNCT_source (see
+       https://dwarfstd.org/issues/180201.1.html) as DW_LNCT_LLVM_SOURCE as
+       a vendor extension until the DWARF standard is updated (see
+       https://github.com/llvm/llvm-project/blob/08bb121835be432ac52372f92845950628ce9a4a/llvm/include/llvm/BinaryFormat/Dwarf.def#L1080 .  */
+    DW_LNCT_LLVM_SOURCE = 0x2001,
     DW_LNCT_hi_user = 0x3fff
   };
 
-- 
2.44.0


^ permalink raw reply	[relevance 27%]

* Re: [PATCH v2 4/5] gdb: introduce ability to disable frame unwinders
  @ 2024-04-09  2:47  0%   ` Eli Zaretskii
  0 siblings, 0 replies; 200+ results
From: Eli Zaretskii @ 2024-04-09  2:47 UTC (permalink / raw)
  To: Guinevere Larsen; +Cc: gdb-patches

> From: Guinevere Larsen <blarsen@redhat.com>
> Cc: Guinevere Larsen <blarsen@redhat.com>
> Date: Mon,  8 Apr 2024 17:19:14 -0300
> 
> Sometimes, in the GDB testsuite, we want to test the ability of specific
> unwinders to handle some piece of code. Usually this is done by trying
> to outsmart GDB, or by coercing the compiler to remove information that
> GDB would rely on.  Both approaches have problems as GDB gets smarter
> with time, and that compilers might differ in version and behavior, or
> simply introduce new useful information. This was requested back in 2003
> in PR backtrace/8434.
> 
> To improve our ability to thoroughly test GDB, this patch introduces a
> new maintenance command that allows a user to disable some unwinders,
> based on either the name of the unwinder or on its class. With this
> change, it will now be possible for GDB to not find any frame unwinders
> for a given frame, which would previously cause GDB to assert. GDB will
> now check if any frame unwinder has been disabled, and if some has, it
> will just error out instead of asserting.
> 
> Unwinders can be disabled or re-enabled in 3 different ways:
> * Disabling/enabling all at once (using '-all').
> * By specifying an unwinder class to be disabled (option '-class').
> * By specifying the name of an unwinder (option '-name').
> 
> If you give no options to the command, GDB assumes the input is an
> unwinder class. '-class' would make no difference if used, is just here
> for completeness.
> 
> This command is meant to be used once the inferior is already at the
> desired location for the test. An example session would be:
> 
> (gdb) start
> Temporary breakpoint 1, main () at omp.c:17
> 17          func();
> (gdb) maint frame-unwinder disable ARCH
> (gdb) bt
> \#0  main () at omp.c:17
> (gdb) maint frame-unwinder enable ARCH
> (gdb) cont
> Continuing.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=8434
> ---
>  gdb/NEWS                                      |   7 +
>  gdb/doc/gdb.texinfo                           |  24 +++
>  gdb/frame-unwind.c                            | 154 +++++++++++++++++-
>  gdb/frame-unwind.h                            |  13 ++
>  gdb/testsuite/gdb.base/frame-unwind-disable.c |  21 +++
>  .../gdb.base/frame-unwind-disable.exp         | 114 +++++++++++++
>  6 files changed, 329 insertions(+), 4 deletions(-)
>  create mode 100644 gdb/testsuite/gdb.base/frame-unwind-disable.c
>  create mode 100644 gdb/testsuite/gdb.base/frame-unwind-disable.exp

Thanks.

> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -54,6 +54,13 @@ disable missing-debug-handler LOCUS HANDLER
>  maintenance info linux-lwps
>    List all LWPs under control of the linux-nat target.
>  
> +maintenance frame-unwinder disable [-all | -name NAME | [-class] CLASS]
> +maintenance frame-unwinder enable [-all | -name NAME | [-class] CLASS]
> +  Enable or disable frame unwinders.  This is only meant to be used when
> +  testing unwinders themselves, and you want to ensure that a fallback
> +  algorithm won't obscure a regression.  GDB is not expected to behave
> +  well if you try to execute the inferior with unwinders disabled.

This part is OK.

> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -42022,6 +42022,30 @@ architecture, then enabling this flag does not cause them to be used.
>  @item maint info frame-unwinders
>  List the frame unwinders currently in effect, starting with the highest priority.
>  
> +@kindex maint frame-unwinder disable
> +@kindex maint frame-unwinder enable
> +@item maint frame-unwinder disable [@code{-all} | @code{-name} @var{NAME} | [@code{-class}] @var{CLASS}]
> +@item maint frame-unwinder enable [@code{-all} | @code{-name} @var{NAME} | [@code{-class}] @var{CLASS}]

The symbols in @var should be in lower-case (they will be up-cased in
the Info output, but in HTML and printed output they will be in
italics instead).

> +Disable or enable frame unwinders.  This is meant only as a testing tool, and
> +@value{GDBN} is not guaranteed to work properly if it is unable to find
> +valid frame unwinders.
> +
> +The meaning of each of the invocations are as follows:
> +
> +@table @samp
> +@item @code{-all}
> +Disable or enable all unwinders.
> +@item @code{-name} @var{NAME}
> +@var{NAME} is the exact name of the unwinder to be disabled or enabled.
> +@item [@code{-class}] @var{CLASS}
> +@var{CLASS} is the class of frame unwinders to be disabled or enabled.
> +The class may include the prefix @code{FRAME_UNWINDER_}, but it is not
> +required.
> +@end table
> +
> +@var{NAME} and @var{CLASS} are always case insensitive.  If no option
> +starting wth @code{-} is given, @value{GDBN} assumes @code{-class}.

I think this command should be moved to after "maint info
frame-unwinders", and it should say that the list of available
unwinders is shown by that command.  Also, I suppose what you call
"class" is what "maint info frame-unwinders" displays as "Type"?  Or
is it something else?  If the latter, the manual should tell how to
know which classes are available.
> +  add_cmd ("disable", class_maintenance, maintenance_disable_frame_unwinders,
> +	   _("\
> +Disable one or more frame unwinder(s).\n\
> +Usage: maint frame-unwinder disable [-all | -name NAME | [-class] CLASS]\n\
> +\n\
> +These are the meanings of the options:\n\
> +\t-all    - All available unwinders will be disabled\n\
> +\t-name   - NAME is the exact name of the frame unwinder is to be disabled\n\
                                                            ^^
That "is" should be removed.

> +  add_cmd ("enable", class_maintenance, maintenance_enable_frame_unwinders,
> +	   _("\
> +Enable one or more frame unwinder(s).\n\
> +Usage: maint frame-unwinder enable [-all | -name NAME | [-class] CLASS]\n\
> +\n\
> +These are the meanings of the options:\n\
> +\t-all    - All available unwinders will be enabled\n\
> +\t-name   - NAME is the exact name of the frame unwinder is to be enabled\n\

Likewise here.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>

^ permalink raw reply	[relevance 0%]

* [PATCH gdb/testsuite v2 7/7] Add gdb.dwarf2/backward-spec-inter-cu.exp
  @ 2024-04-08 21:11  3% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-04-08 21:11 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom de Vries

From: Tom de Vries <tdevries@suse.de>

Add another regression test for PR symtab/30846.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30846
---
 .../gdb.dwarf2/backward-spec-inter-cu.exp          | 103 +++++++++++++++++++++
 1 file changed, 103 insertions(+)

diff --git a/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp b/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp
new file mode 100644
index 00000000000..59b3db50dbb
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp
@@ -0,0 +1,103 @@
+# Copyright 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the DWARF reader works with a a DW_AT_specification that
+# refers to an earlier DIE.  Inter-cu variant of forward-spec.exp.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+require dwarf2_support
+
+standard_testfile main.c -debug.S
+
+# Set up the DWARF for the test.
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+    global srcfile
+
+    declare_labels spec
+
+    cu {} {
+	DW_TAG_compile_unit {
+	    {DW_AT_language @DW_LANG_C_plus_plus}
+	} {
+	    declare_labels myint
+
+	    myint: DW_TAG_base_type {
+		{DW_AT_byte_size 4 DW_FORM_sdata}
+		{DW_AT_encoding  @DW_ATE_signed}
+		{DW_AT_name      myint}
+	    }
+
+	    DW_TAG_namespace {
+		{DW_AT_name ns}
+	    } {
+		spec: DW_TAG_variable {
+		    {DW_AT_name v}
+		    {DW_AT_type :$myint}
+		    {DW_AT_declaration 1 DW_FORM_flag_present}
+		}
+	    }
+	}
+    }
+
+    cu {} {
+	DW_TAG_compile_unit {
+	    {DW_AT_language @DW_LANG_C_plus_plus}
+	} {
+	    # The new indexer has special code to compute the full
+	    # name of an object that uses a specification that appears
+	    # later in the DWARF.
+	    DW_TAG_variable {
+		{DW_AT_specification %$spec}
+		{DW_AT_location {
+		    DW_OP_const1u 23
+		    DW_OP_stack_value
+		} SPECIAL_expr}
+	    }
+	}
+    }
+}
+
+if {[build_executable "failed to build executable" ${testfile} \
+	 [list $srcfile $asm_file] {nodebug}]} {
+    return -1
+}
+
+set eol "\r\n"
+set ws "\[ \t\]"
+
+set worker_threads_list {}
+
+# Exercises the intra-shard case.
+lappend worker_threads_list 0
+
+# Might exercise the inter-shard case.
+lappend worker_threads_list default
+
+foreach_with_prefix worker_threads $worker_threads_list {
+
+    clean_restart
+
+    if { $worker_threads != "default" } {
+	gdb_test_no_output "maint set worker-threads $worker_threads"
+    }
+
+    gdb_load $binfile
+
+    gdb_test "maint print objfiles" "$eol$ws+qualified:$ws+ns::v$eol.*" \
+	"v has parent ns"
+}

-- 
2.43.0


^ permalink raw reply	[relevance 3%]

* Re: [PATCH v3 5/7] gdb: Introduce is_address_tagged target hook
  @ 2024-04-08 20:47  4%     ` Gustavo Romero
  0 siblings, 0 replies; 200+ results
From: Gustavo Romero @ 2024-04-08 20:47 UTC (permalink / raw)
  To: Luis Machado, gdb-patches; +Cc: thiago.bauermann

Hi Luis,

On 4/4/24 12:45 PM, Luis Machado wrote:
> On 4/4/24 07:48, Gustavo Romero wrote:
>> This commit introduces a new target hook, target_is_address_tagged,
>> which is used instead of the gdbarch_tagged_address_p gdbarch hook in
>> the upper layer (printcmd.c).
>>
>> This change allows the memory tagging address checking to be specialized
>> easily per target in the future. Since target_is_address_tagged
>> continues to use the gdbarch_tagged_address_p hook there is no change
>> in behavior for the targets using the new target hook (the remote.c,
>> aarch64-linux-nat.c, and corelow.c targets).
> 
> The above block...
> 
>>
>> This change enables easy specialization of memory tagging address
>> check per target in the future. As target_is_address_tagged continues
>> to utilize the gdbarch_tagged_address_p hook, there is no change in
>> behavior for all the targets that use the new target hook (i.e., the
>> remote.c, aarch64-linux-nat.c, and corelow.c targets).
> 
> ... seems to be somewhat duplicated above in the commit message.
> 
> Also, as general rule, we usually make updates clear at the top of the
> commit message. for instace:
> 
> Updates in v3:
> 
> - Something something.
> - Fixed breakage.
> 
> And then those update blocks don't get pushed when the series is
> approved (sometimes some do push it).
> 
>>
>> Just the gdbarch_tagged_address_p signature is changed for convenience,
>> since target_is_address_tagged takes the address to be checked as a
>> CORE_ADDR type.
>>
>> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
>> ---
>>   gdb/aarch64-linux-nat.c   |  8 ++++++++
>>   gdb/aarch64-linux-tdep.c  | 10 ++++------
>>   gdb/arch-utils.c          |  2 +-
>>   gdb/arch-utils.h          |  2 +-
>>   gdb/corelow.c             |  8 ++++++++
>>   gdb/gdbarch-gen.h         |  4 ++--
>>   gdb/gdbarch.c             |  2 +-
>>   gdb/gdbarch_components.py |  2 +-
>>   gdb/printcmd.c            | 31 +++++++++++++++++--------------
>>   gdb/remote.c              | 10 ++++++++++
>>   gdb/target-delegates.c    | 30 ++++++++++++++++++++++++++++++
>>   gdb/target.c              |  6 ++++++
>>   gdb/target.h              |  6 ++++++
>>   13 files changed, 95 insertions(+), 26 deletions(-)
>>
>> diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
>> index 3face34ce79..19c099832a5 100644
>> --- a/gdb/aarch64-linux-nat.c
>> +++ b/gdb/aarch64-linux-nat.c
>> @@ -110,6 +110,8 @@ class aarch64_linux_nat_target final
>>     /* Write allocation tags to memory via PTRACE.  */
>>     bool store_memtags (CORE_ADDR address, size_t len,
>>   		      const gdb::byte_vector &tags, int type) override;
>> +  /* Check if an address is tagged.  */
>> +  bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override;
>>   };
>>   
>>   static aarch64_linux_nat_target the_aarch64_linux_nat_target;
>> @@ -1071,6 +1073,12 @@ aarch64_linux_nat_target::store_memtags (CORE_ADDR address, size_t len,
>>     return false;
>>   }
>>   
>> +bool
>> +aarch64_linux_nat_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address)
>> +{
>> +  return gdbarch_tagged_address_p (gdbarch, address);
> 
> I'd add a comment here on why we take a detour going to the linux-tdep layer
> to read the smaps file, because we don't have a better way to get that information.
> 
> In the future, if this check is ever made available through PTRACE, one can come
> here and drop the smaps path.
> 
>> +}
>> +
>>   void _initialize_aarch64_linux_nat ();
>>   void
>>   _initialize_aarch64_linux_nat ()
>> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
>> index fc60e602748..2a47c3f0845 100644
>> --- a/gdb/aarch64-linux-tdep.c
>> +++ b/gdb/aarch64-linux-tdep.c
>> @@ -2451,17 +2451,15 @@ aarch64_mte_get_atag (CORE_ADDR address)
>>   /* Implement the tagged_address_p gdbarch method.  */
>>   
>>   static bool
>> -aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, struct value *address)
>> +aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address)
>>   {
>> -  gdb_assert (address != nullptr);
>> -
>> -  CORE_ADDR addr = value_as_address (address);
>> +  gdb_assert (address);
> 
> No need to assert for a non-zero address. We used to assert that we had a valid pointer,
> but since we're no longer dealing with a pointer, we don't have to worry about it.
> 
> Plus, 0x0 is a valid address (at least for bare-metal. We could run into an assertion if
> the user explicitly tries to check for tags in a 0x0 address. See below:
> 
> (gdb) memory-tag check 0x0
> ../../../repos/binutils-gdb/gdb/aarch64-linux-tdep.c:2456: internal-error: aarch64_linux_tagged_address_p: Assertion `address' failed.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> ----- Backtrace -----
> 0xaaaac69ccf97 _Z22gdb_internal_backtracev
> 0xaaaac6e443e7 _ZL17internal_vproblemP16internal_problemPKciS2_St9__va_list
> 0xaaaac6e4464f _Z15internal_verrorPKciS0_St9__va_list
> 0xaaaac734a8b3 _Z18internal_error_locPKciS0_z
> 0xaaaac68dc407 _ZL30aarch64_linux_tagged_address_pP7gdbarchm
> 0xaaaac6c849ab _ZL24memory_tag_check_commandPKci
> 0xaaaac69fb8ab _Z8cmd_funcP16cmd_list_elementPKci
> 0xaaaac6de5ed3 _Z15execute_commandPKci
> 0xaaaac6adc203 _Z15command_handlerPKc
> 0xaaaac6add45f _Z20command_line_handlerOSt10unique_ptrIcN3gdb13xfree_deleterIcEEE
> 0xaaaac6adccd7 _ZL23gdb_rl_callback_handlerPc
> 0xaaaac6ea7eeb rl_callback_read_char
> 0xaaaac6adbc7b _ZL42gdb_rl_callback_read_char_wrapper_noexceptv
> 0xaaaac6adcb3b _ZL33gdb_rl_callback_read_char_wrapperPv
> 0xaaaac6e1ef5f _ZL19stdin_event_handleriPv
> 0xaaaac734b29f _ZL18gdb_wait_for_eventi.part.0
> 0xaaaac734bc7f _Z16gdb_do_one_eventi
> 0xaaaac6bdd977 _ZL21captured_command_loopv
> 0xaaaac6bdf6bb _Z8gdb_mainP18captured_main_args
> 0xaaaac68cee47 main
> 
>>   
>>     /* Remove the top byte for the memory range check.  */
>> -  addr = gdbarch_remove_non_address_bits (gdbarch, addr);
>> +  address = gdbarch_remove_non_address_bits (gdbarch, address);
>>   
>>     /* Check if the page that contains ADDRESS is mapped with PROT_MTE.  */
>> -  if (!linux_address_in_memtag_page (addr))
>> +  if (!linux_address_in_memtag_page (address))
>>       return false;
>>   
>>     /* We have a valid tag in the top byte of the 64-bit address.  */
>> diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
>> index 456bfe971ff..cb149c36bc9 100644
>> --- a/gdb/arch-utils.c
>> +++ b/gdb/arch-utils.c
>> @@ -102,7 +102,7 @@ default_memtag_to_string (struct gdbarch *gdbarch, struct value *tag)
>>   /* See arch-utils.h */
>>   
>>   bool
>> -default_tagged_address_p (struct gdbarch *gdbarch, struct value *address)
>> +default_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address)
>>   {
>>     /* By default, assume the address is untagged.  */
>>     return false;
>> diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
>> index 2dcd8f6dc53..467be40c688 100644
>> --- a/gdb/arch-utils.h
>> +++ b/gdb/arch-utils.h
>> @@ -141,7 +141,7 @@ extern std::string default_memtag_to_string (struct gdbarch *gdbarch,
>>   					     struct value *tag);
>>   
>>   /* Default implementation of gdbarch_tagged_address_p.  */
>> -bool default_tagged_address_p (struct gdbarch *gdbarch, struct value *address);
>> +bool default_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address);
>>   
>>   /* Default implementation of gdbarch_memtag_matches_p.  */
>>   extern bool default_memtag_matches_p (struct gdbarch *gdbarch,
>> diff --git a/gdb/corelow.c b/gdb/corelow.c
>> index f4e8273d962..b13d0124471 100644
>> --- a/gdb/corelow.c
>> +++ b/gdb/corelow.c
>> @@ -109,6 +109,8 @@ class core_target final : public process_stratum_target
>>     bool fetch_memtags (CORE_ADDR address, size_t len,
>>   		      gdb::byte_vector &tags, int type) override;
>>   
>> +  bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override;
>> +
> 
> Maybe add a comment to this function stating what we're looking for:
> 
> /* If the architecture supports it, check if ADDRESS is within a memory range
>     mapped with tags.  For example,  MTE tags for AArch64.  */
> 
> Or some other variation of the above.
> 
> The reason being that the corelow target is a bit special because it is generic, hence
> why we see an override for a x86 target hook in there as well.
> 
>>     x86_xsave_layout fetch_x86_xsave_layout () override;
>>   
>>     /* A few helpers.  */
>> @@ -1410,6 +1412,12 @@ core_target::fetch_memtags (CORE_ADDR address, size_t len,
>>     return false;
>>   }
>>   
>> +bool
>> +core_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address)
>> +{
>> +  return gdbarch_tagged_address_p (gdbarch, address);
>> +}
>> +
>>   /* Implementation of the "fetch_x86_xsave_layout" target_ops method.  */
>>   
>>   x86_xsave_layout
>> diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
>> index ebcff80bb9e..63fab26987f 100644
>> --- a/gdb/gdbarch-gen.h
>> +++ b/gdb/gdbarch-gen.h
>> @@ -707,8 +707,8 @@ extern void set_gdbarch_memtag_to_string (struct gdbarch *gdbarch, gdbarch_memta
>>   /* Return true if ADDRESS contains a tag and false otherwise.  ADDRESS
>>      must be either a pointer or a reference type. */
>>   
>> -typedef bool (gdbarch_tagged_address_p_ftype) (struct gdbarch *gdbarch, struct value *address);
>> -extern bool gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address);
>> +typedef bool (gdbarch_tagged_address_p_ftype) (struct gdbarch *gdbarch, CORE_ADDR address);
>> +extern bool gdbarch_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address);
>>   extern void set_gdbarch_tagged_address_p (struct gdbarch *gdbarch, gdbarch_tagged_address_p_ftype *tagged_address_p);
>>   
>>   /* Return true if the tag from ADDRESS matches the memory tag for that
>> diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
>> index 9319571deba..2d92f604c49 100644
>> --- a/gdb/gdbarch.c
>> +++ b/gdb/gdbarch.c
>> @@ -3232,7 +3232,7 @@ set_gdbarch_memtag_to_string (struct gdbarch *gdbarch,
>>   }
>>   
>>   bool
>> -gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address)
>> +gdbarch_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address)
>>   {
>>     gdb_assert (gdbarch != NULL);
>>     gdb_assert (gdbarch->tagged_address_p != NULL);
>> diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py
>> index 7d913ade621..24e979431b6 100644
>> --- a/gdb/gdbarch_components.py
>> +++ b/gdb/gdbarch_components.py
>> @@ -1267,7 +1267,7 @@ must be either a pointer or a reference type.
>>   """,
>>       type="bool",
>>       name="tagged_address_p",
>> -    params=[("struct value *", "address")],
>> +    params=[("CORE_ADDR", "address")],
>>       predefault="default_tagged_address_p",
>>       invalid=False,
>>   )
>> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
>> index 62fbcb98cfb..24eac7c8421 100644
>> --- a/gdb/printcmd.c
>> +++ b/gdb/printcmd.c
>> @@ -1132,7 +1132,7 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
>>   	    = value_from_ulongest (builtin_type (gdbarch)->builtin_data_ptr,
>>   				   tag_laddr);
>>   
>> -	  if (gdbarch_tagged_address_p (gdbarch, v_addr))
>> +	  if (target_is_address_tagged (gdbarch, value_as_address (v_addr)))
>>   	    {
>>   	      /* Fetch the allocation tag.  */
>>   	      struct value *tag
>> @@ -1268,7 +1268,7 @@ print_value (value *val, const value_print_options &opts)
>>   /* Returns true if memory tags should be validated.  False otherwise.  */
>>   
>>   static bool
>> -should_validate_memtags (struct value *value)
>> +should_validate_memtags (gdbarch *gdbarch, struct value *value)
>>   {
>>     gdb_assert (value != nullptr && value->type () != nullptr);
>>   
>> @@ -1289,7 +1289,7 @@ should_validate_memtags (struct value *value)
>>       return false;
>>   
>>     /* We do.  Check whether it includes any tags.  */
>> -  return gdbarch_tagged_address_p (current_inferior ()->arch  (), value);
>> +  return target_is_address_tagged (gdbarch, value_as_address (value));
>>   }
>>   
>>   /* Helper for parsing arguments for print_command_1.  */
>> @@ -1346,7 +1346,7 @@ print_command_1 (const char *args, int voidprint)
>>   	    {
>>   	      gdbarch *arch = current_inferior ()->arch ();
>>   
>> -	      if (should_validate_memtags (val)
>> +	      if (should_validate_memtags (arch, val)
>>   		  && !gdbarch_memtag_matches_p (arch, val))
>>   		{
>>   		  /* Fetch the logical tag.  */
>> @@ -2946,9 +2946,10 @@ memory_tag_print_tag_command (const char *args, enum memtag_type tag_type)
>>        flag, it is no use trying to access/manipulate its allocation tag.
>>   
>>        It is OK to manipulate the logical tag though.  */
>> +  CORE_ADDR addr = value_as_address (val);
>>     if (tag_type == memtag_type::allocation
>> -      && !gdbarch_tagged_address_p (arch, val))
>> -    show_addr_not_tagged (value_as_address (val));
>> +      && !target_is_address_tagged (arch, addr))
>> +    show_addr_not_tagged (addr);
>>   
>>     value *tag_value = gdbarch_get_memtag (arch, val, tag_type);
>>     std::string tag = gdbarch_memtag_to_string (arch, tag_value);
>> @@ -3104,8 +3105,9 @@ parse_set_allocation_tag_input (const char *args, struct value **val,
>>   
>>     /* If the address is not in a region memory mapped with a memory tagging
>>        flag, it is no use trying to access/manipulate its allocation tag.  */
>> -  if (!gdbarch_tagged_address_p (current_inferior ()->arch (), *val))
>> -    show_addr_not_tagged (value_as_address (*val));
>> +  CORE_ADDR addr = value_as_address (*val);
>> +  if (!target_is_address_tagged (current_inferior ()->arch (), addr))
>> +    show_addr_not_tagged (addr);
>>   }
>>   
>>   /* Implement the "memory-tag set-allocation-tag" command.
>> @@ -3129,8 +3131,9 @@ memory_tag_set_allocation_tag_command (const char *args, int from_tty)
>>   
>>     /* If the address is not in a region memory mapped with a memory tagging
>>        flag, it is no use trying to manipulate its allocation tag.  */
>> -  if (!gdbarch_tagged_address_p (current_inferior ()->arch (), val))
>> -    show_addr_not_tagged (value_as_address(val));
>> +  CORE_ADDR addr = value_as_address (val);
>> +  if (!target_is_address_tagged (current_inferior ()-> arch(), addr))
>> +    show_addr_not_tagged (addr);
>>   
>>     if (!gdbarch_set_memtags (current_inferior ()->arch (), val, length, tags,
>>   			    memtag_type::allocation))
>> @@ -3157,12 +3160,12 @@ memory_tag_check_command (const char *args, int from_tty)
>>     struct value *val = process_print_command_args (args, &print_opts, true);
>>     gdbarch *arch = current_inferior ()->arch ();
>>   
>> +  CORE_ADDR addr = value_as_address (val);
>> +
>>     /* If the address is not in a region memory mapped with a memory tagging
>>        flag, it is no use trying to access/manipulate its allocation tag.  */
>> -  if (!gdbarch_tagged_address_p (arch, val))
>> -    show_addr_not_tagged (value_as_address (val));
>> -
>> -  CORE_ADDR addr = value_as_address (val);
>> +  if (!target_is_address_tagged (current_inferior ()->arch (), addr))
>> +    show_addr_not_tagged (addr);
> 
> I noticed the above checks happen at least 3 times in the code. Maybe a future
> cleanup possibility to split the check into a separate function.
> 
>>   
>>     /* Check if the tag is valid.  */
>>     if (!gdbarch_memtag_matches_p (arch, val))
>> diff --git a/gdb/remote.c b/gdb/remote.c
>> index e278711df7b..9717db55e27 100644
>> --- a/gdb/remote.c
>> +++ b/gdb/remote.c
>> @@ -1084,6 +1084,8 @@ class remote_target : public process_stratum_target
>>     bool store_memtags (CORE_ADDR address, size_t len,
>>   		      const gdb::byte_vector &tags, int type) override;
>>   
>> +  bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override;
>> +
>>   public: /* Remote specific methods.  */
>>   
>>     void remote_download_command_source (int num, ULONGEST addr,
>> @@ -15573,6 +15575,14 @@ remote_target::store_memtags (CORE_ADDR address, size_t len,
>>     return packet_check_result (rs->buf).status () == PACKET_OK;
>>   }
>>   
>> +/* Implement the "is_address_tagged" target_ops method.  */
>> +
>> +bool
>> +remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address)
>> +{
>> +  return gdbarch_tagged_address_p (gdbarch, address);
>> +}
>> +
>>   /* Return true if remote target T is non-stop.  */
>>   
>>   bool
>> diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
>> index 59ea70458ad..e322bbbe481 100644
>> --- a/gdb/target-delegates.c
>> +++ b/gdb/target-delegates.c
>> @@ -197,6 +197,7 @@ struct dummy_target : public target_ops
>>     bool supports_memory_tagging () override;
>>     bool fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2, int arg3) override;
>>     bool store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector &arg2, int arg3) override;
>> +  bool is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) override;
>>     x86_xsave_layout fetch_x86_xsave_layout () override;
>>   };
>>   
>> @@ -373,6 +374,7 @@ struct debug_target : public target_ops
>>     bool supports_memory_tagging () override;
>>     bool fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2, int arg3) override;
>>     bool store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector &arg2, int arg3) override;
>> +  bool is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) override;
>>     x86_xsave_layout fetch_x86_xsave_layout () override;
>>   };
>>   
>> @@ -4562,6 +4564,34 @@ debug_target::store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector
>>     return result;
>>   }
>>   
>> +bool
>> +target_ops::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1)
>> +{
>> +  return this->beneath ()->is_address_tagged (arg0, arg1);
>> +}
>> +
>> +bool
>> +dummy_target::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1)
>> +{
>> +  tcomplain ();
>> +}
>> +
>> +bool
>> +debug_target::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1)
>> +{
>> +  gdb_printf (gdb_stdlog, "-> %s->is_address_tagged (...)\n", this->beneath ()->shortname ());
>> +  bool result
>> +    = this->beneath ()->is_address_tagged (arg0, arg1);
>> +  gdb_printf (gdb_stdlog, "<- %s->is_address_tagged (", this->beneath ()->shortname ());
>> +  target_debug_print_gdbarch_p (arg0);
>> +  gdb_puts (", ", gdb_stdlog);
>> +  target_debug_print_CORE_ADDR (arg1);
>> +  gdb_puts (") = ", gdb_stdlog);
>> +  target_debug_print_bool (result);
>> +  gdb_puts ("\n", gdb_stdlog);
>> +  return result;
>> +}
>> +
>>   x86_xsave_layout
>>   target_ops::fetch_x86_xsave_layout ()
>>   {
>> diff --git a/gdb/target.c b/gdb/target.c
>> index 107a84b3ca1..5c3c1a57dbd 100644
>> --- a/gdb/target.c
>> +++ b/gdb/target.c
>> @@ -796,6 +796,12 @@ target_store_memtags (CORE_ADDR address, size_t len,
>>     return current_inferior ()->top_target ()->store_memtags (address, len, tags, type);
>>   }
>>   
>> +bool
>> +target_is_address_tagged (gdbarch *gdbarch, CORE_ADDR address)
>> +{
>> +  return current_inferior ()->top_target ()->is_address_tagged (gdbarch, address);
>> +}
>> +
>>   x86_xsave_layout
>>   target_fetch_x86_xsave_layout ()
>>   {
>> diff --git a/gdb/target.h b/gdb/target.h
>> index c9eaff16346..486a0a687b0 100644
>> --- a/gdb/target.h
>> +++ b/gdb/target.h
>> @@ -1334,6 +1334,10 @@ struct target_ops
>>   				const gdb::byte_vector &tags, int type)
>>         TARGET_DEFAULT_NORETURN (tcomplain ());
>>   
>> +    /* Returns true if ADDRESS is tagged, otherwise returns false.  */
>> +    virtual bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address)
>> +      TARGET_DEFAULT_NORETURN (tcomplain ());
>> +
> 
> Should the default for is_address_tagged by to return false, meaning the address is never
> tagged?

No, I think tcomplain() is correct. This is the virtual (default) declaration, so
it will be called if the target layer does not implement/override this method in the
base class, and tcomplain() will correctly complain:

"You can't do that when your target is `%s`"

But this should be a rare condition, when GDB understands that the target supports
memory tagging and so will call target_is_address_tagged at some point but the
target layer does not implement the target hook.


Cheers,
Gustavo

^ permalink raw reply	[relevance 4%]

* [PATCHv2 6/6] gdb/build: apply silent-rules.mk to the data-directory Makefile.in
  @ 2024-04-06 17:03  5%   ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-04-06 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

This commit makes use of gdb/silent-rules.mk in the data-directory
Makefile.in.  I've only updated the rules that actually generate
things, I've not touched the install or uninstall rules, this matches
gdb/Makefile.in.

I've not managed to completely silence all of the recipe output, the
mkinstalldirs command outputs some diagnostic text which looks like
this:

    GEN    stamp-python
  mkdir -p -- ./python/gdb
  mkdir -p -- ./python/gdb/command
  mkdir -p -- ./python/gdb/dap
  mkdir -p -- ./python/gdb/function
  mkdir -p -- ./python/gdb/printer

I have a patch for mkinstalldirs that fixes this (by adding a new
--silent command line flag), but that patch needs to be submitted to
automake, then an updated mkinstalldirs sync'd to the gcc repository,
and then copied into the binutils-gdb repository... so I'm leaving
that for a future project.

Then the guild compiler also emits some diagnostic output, which looks
like this:

    GEN    stamp-guile
  mkdir -p -- ./guile/.
  mkdir -p -- ./guile/gdb
  wrote `./gdb.go'
  wrote `gdb/experimental.go'
  wrote `gdb/iterator.go'
  wrote `gdb/printing.go'
  wrote `gdb/support.go'
  wrote `gdb/types.go'

The 'wrote' lines are from the guild compiler.  The only way to
silence these would be to redirect stdout to /dev/null I think.  I did
prototype this, but wasn't 100% convinced about that part of the
patch, so I've decided to leave that for another day.

I did need to add a new SILENT_ECHO variable to silent-rules.mk, this
is set to a suitable 'echo' command to use within recipes.  When we
are in silent mode then I use the 'true' command, while in verbose
mode we actually use 'echo'.

So, other than the issues outlined above, the output when building the
data-directory is now greatly reduced, and more inline with the output
when building in the gdb/ directory.

There should be no change in what is actually built after this commit.
---
 gdb/data-directory/Makefile.in | 40 +++++++++++++++++++---------------
 gdb/silent-rules.mk            |  4 ++++
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in
index edfa52c2217..720b983ef6c 100644
--- a/gdb/data-directory/Makefile.in
+++ b/gdb/data-directory/Makefile.in
@@ -36,6 +36,8 @@ exec_prefix = @exec_prefix@
 datarootdir = @datarootdir@
 datadir = @datadir@
 
+include $(srcdir)/../silent-rules.mk
+
 SHELL = @SHELL@
 
 LN_S = @LN_S@
@@ -202,7 +204,7 @@ FLAGS_TO_PASS = \
 all: stamp-syscalls stamp-python stamp-guile stamp-system-gdbinit
 
 %.xml: @MAINTAINER_MODE_TRUE@ %.xml.in apply-defaults.xsl linux-defaults.xml.in
-	$(XSLTPROC) -o $(SYSCALLS_SRCDIR)/$@ $(SYSCALLS_SRCDIR)/apply-defaults.xsl\
+	$(ECHO_GEN) $(XSLTPROC) -o $(SYSCALLS_SRCDIR)/$@ $(SYSCALLS_SRCDIR)/apply-defaults.xsl \
 		$(SYSCALLS_SRCDIR)/$@.in
 
 .PHONY: syscall-xml
@@ -219,16 +221,17 @@ clean-syscall-xml:
 # For portability's sake, we need to handle systems that don't have
 # symbolic links.
 stamp-syscalls: Makefile $(SYSCALLS_FILES)
-	rm -rf ./$(SYSCALLS_DIR)
-	mkdir ./$(SYSCALLS_DIR)
-	files='$(SYSCALLS_FILES)' ; \
+	$(ECHO_GEN)
+	$(SILENCE) rm -rf ./$(SYSCALLS_DIR)
+	$(SILENCE) mkdir ./$(SYSCALLS_DIR)
+	$(SILENCE) files='$(SYSCALLS_FILES)' ; \
 	for file in $$files ; do \
 	  f=$(SYSCALLS_SRCDIR)/$$file ; \
 	  if test -f $$f ; then \
 	    $(INSTALL_DATA) $$f ./$(SYSCALLS_DIR) ; \
 	  fi ; \
 	done
-	touch $@
+	$(SILENCE) touch $@
 
 .PHONY: clean-syscalls
 clean-syscalls:
@@ -262,8 +265,9 @@ uninstall-syscalls:
 	done
 
 stamp-python: Makefile $(PYTHON_FILES)
-	rm -rf ./$(PYTHON_DIR)
-	files='$(PYTHON_FILES)' ; \
+	$(ECHO_GEN)
+	$(SILENCE) rm -rf ./$(PYTHON_DIR)
+	$(SILENCE) files='$(PYTHON_FILES)' ; \
 	if test "x$$files" != x ; then \
 	  for file in $$files ; do \
 	    dir=`echo "$$file" | sed 's,/[^/]*$$,,'` ; \
@@ -271,7 +275,7 @@ stamp-python: Makefile $(PYTHON_FILES)
 	    $(INSTALL_DATA) $(PYTHON_SRCDIR)/$$file ./$(PYTHON_DIR)/$$dir ; \
 	  done ; \
 	fi
-	touch $@
+	$(SILENCE) touch $@
 
 .PHONY: clean-python
 clean-python:
@@ -305,8 +309,9 @@ uninstall-python:
 	fi
 
 stamp-guile: Makefile $(GUILE_SOURCE_FILES)
-	rm -rf ./$(GUILE_DIR)
-	if test "x$(GUILE_FILES)" != x ; then \
+	$(ECHO_GEN)
+	$(SILENCE) rm -rf ./$(GUILE_DIR)
+	$(SILENCE) if test "x$(GUILE_FILES)" != x ; then \
 	  files='$(GUILE_SOURCE_FILES)' ; \
 	  for file in $$files ; do \
 	    dir=`echo "$$file" | sed 's,/[^/]*$$,,'` ; \
@@ -317,11 +322,11 @@ stamp-guile: Makefile $(GUILE_SOURCE_FILES)
 	  cd ./$(GUILE_DIR) ; \
 	  for go in $$files ; do \
 	    source="`echo $$go | sed 's/\.go$$/.scm/'`" ; \
-	    echo $(GUILD) compile $(GUILD_COMPILE_FLAGS) -o "$$go" "$$source" ; \
+	    $(SILENT_ECHO) $(GUILD) compile $(GUILD_COMPILE_FLAGS) -o "$$go" "$$source" ; \
 	    $(GUILD) compile $(GUILD_COMPILE_FLAGS) -o "$$go" "$$source" || exit 1 ; \
 	  done ; \
 	fi
-	touch $@
+	$(SILENCE) touch $@
 
 .PHONY: clean-guile
 clean-guile:
@@ -355,16 +360,17 @@ uninstall-guile:
 	fi
 
 stamp-system-gdbinit: Makefile $(SYSTEM_GDBINIT_FILES)
-	rm -rf ./$(SYSTEM_GDBINIT_DIR)
-	mkdir ./$(SYSTEM_GDBINIT_DIR)
-	files='$(SYSTEM_GDBINIT_FILES)' ; \
+	$(ECHO_GEN)
+	$(SILENCE) rm -rf ./$(SYSTEM_GDBINIT_DIR)
+	$(SILENCE) mkdir ./$(SYSTEM_GDBINIT_DIR)
+	$(SILENCE) files='$(SYSTEM_GDBINIT_FILES)' ; \
 	for file in $$files ; do \
 	  f=$(SYSTEM_GDBINIT_SRCDIR)/$$file ; \
 	  if test -f $$f ; then \
 	    $(INSTALL_DATA) $$f ./$(SYSTEM_GDBINIT_DIR) ; \
 	  fi ; \
 	done
-	touch $@
+	$(SILENCE) touch $@
 
 .PHONY: clean-system-gdbinit
 clean-system-gdbinit:
@@ -438,7 +444,7 @@ clean-info:
 MAKEOVERRIDES=
 
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
-	cd .. && $(SHELL) ./config.status data-directory/Makefile
+	$(ECHO_GEN) cd .. && $(SHELL) ./config.status $(SILENT_FLAG) data-directory/Makefile
 
 # Disable implicit make rules.
 include $(srcdir)/../disable-implicit-rules.mk
diff --git a/gdb/silent-rules.mk b/gdb/silent-rules.mk
index 36791f6683f..43dc2bf3aca 100644
--- a/gdb/silent-rules.mk
+++ b/gdb/silent-rules.mk
@@ -20,4 +20,8 @@ ECHO_RANLIB = @echo "  RANLIB $@";
 SILENCE = @
 # Silence libtool.
 SILENT_FLAG = --silent
+# Used in shell snippets instead of 'echo'.
+SILENT_ECHO = true
+else
+SILENT_ECHO = echo
 endif
-- 
2.25.4


^ permalink raw reply	[relevance 5%]

* Re: [PATCH] Fix an out of bounds array access in, find_epilogue_using_linetable
  @ 2024-04-05 18:13  5%       ` Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-05 18:13 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches; +Cc: Guinevere Larsen

On 4/5/24 17:11, Tom de Vries wrote:
> 
> Looking at the "pointer exactly at the upper bound of the line table" problem a bit more, I think it can happen that it->epilogue_begin is evaluated for an end_sequence entry.  My guess is that this is harmless, but it's better to avoid it.
> 
> Atm it's hard to reason about what happens because we try to handle several initial scenarios in the loop.  It's best to untangle this:
> - handle exceptional situations before the loop, and
> - reserve the loop to handle the steady state: iterating over
>   proper line-table entries of the current function.
> 
>>> I think things can be solved simpler by:
>>> - using a trivial for loop that expresses the boundary of the line
>>>    table, and
>>> - moving the while condition into the loop, while
>>> - handling the exceptional case explictly, outside the loop:
>>> ...
>>>        if (it == &linetable->item[linetable->nitems])
>>>          it--;
>>>
>>
>> no, that is also wrong if linetable->nitems == 0, `it` is
>> &linetable->item[-1], and the comparing that value to
>> &linetable->item[0] yields an undefined boolean value.
> 
> I see, I forgot about that, thanks for pointing that out.  It's good to make explicit in the implementation that and where we're avoid this.
> 
> Btw, if "linetable->nitems == 0" indeed can happen, it's best handled using an early-out.
> 
>> And as I said above looking at the line table entry
>> that belongs to the next function is asking for trouble.
>>
>> Even decrementing `it` below the first element of an array
>> is undefined behavior, avoiding that is the main reason
>> why I wrote the if condition in this way.
>>
>> I would agree to add a comment here which explains how the
>> loop works.
>>
>> OK?
>>
> 
> I've written a version that avoids the undefined behaviour decrement, clearly advertises this, handles cornercases explicitly and adds and reorganizes comments, as well as adds some asserts.  I've submitted it as a v3, which also adds an additional test-case.
> 

Ah okay,
I forgot about the end_sequence, that should be at the upper bound of the function range,
but it should not be possible, that it has an epilogue-begin bit set in this line table
item, see dwarf_finish_line, there is only a IS_STMT flag, no LEF_EPILOGUE_BEGIN:

dwarf_finish_line (struct gdbarch *gdbarch, struct subfile *subfile,
                   unrelocated_addr address, struct dwarf2_cu *cu,
                   bool end_sequence) 
{           
  if (subfile == NULL)
    return;

  if (dwarf_line_debug)
    {
      gdb_printf (gdb_stdlog,
                  "Finishing current line, file %s, address %s\n",
                  lbasename (subfile->name.c_str ()),
                  paddress (gdbarch, (CORE_ADDR) address));
    }

  dwarf_record_line_1 (gdbarch, subfile, end_sequence ? 0 : -1, address,
                       LEF_IS_STMT, cu);
}

So it should not be necessary to check end-sequence for epilogue-begin bit.
 
But even if an epilogue-begin line table entry would be at the same address,
that can only happen due to an invalid debug info: That would by my reasoning
be impossible, because that would imply a zero byte epilogue and that
cannot be correct because the epilogue consists of at least a return instruction.
Therefore I'd suggest to skip that line table entry, because even if it has the
epilogue-begin bit set, it can only be invalid and it is better ignored.


Thanks,
Bernd.



> Thanks,
> - Tom
> 

^ permalink raw reply	[relevance 5%]

* Re: [PATCH v3] gdb: Support embedded source in DWARF
  @ 2024-04-05 16:18  0% ` Will Hawkins
  0 siblings, 0 replies; 200+ results
From: Will Hawkins @ 2024-04-05 16:18 UTC (permalink / raw)
  To: gdb-patches

While there are still some areas that I need to address from Tom's
feedback, I took a stab at updating the source code access through the
cache and wanted to get your initial thoughts. See comments below.

On Fri, Apr 5, 2024 at 12:13 PM Will Hawkins <hawkinsw@obs.cr> wrote:
>
> While DW_LNCT_source is not yet finalized in the DWARF standard
> (https://dwarfstd.org/issues/180201.1.html), LLVM does emit it.
>
> This patch adds support for it in gdb.
>
> Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
> ---
>
> Notes:
>         v2 -> v3
>           - Address feedback from v2.
>           - Fixed up a bug where non-CU embedded files were incorrectly
>             marked as embedded.
>           - Revamped source access through the cache to avoid copies.
>
>         v1 -> v2
>           - Address feedback from original PR
>           - Add support for maintenance commands to see embedded source status
>           - Prevent access to the filesystem for symtabs with embedded source
>           - Add additional unit tests
>
>  gdb/dwarf2/file-and-dir.h                    | 23 ++++-
>  gdb/dwarf2/line-header.c                     | 22 +++--
>  gdb/dwarf2/line-header.h                     |  9 +-
>  gdb/dwarf2/read.c                            | 83 +++++++++++++++---
>  gdb/extension.c                              |  7 +-
>  gdb/extension.h                              |  9 +-
>  gdb/source-cache.c                           | 87 ++++++++++++-------
>  gdb/source-cache.h                           | 12 +--
>  gdb/source.c                                 | 74 +++++++++++-----
>  gdb/source.h                                 |  4 +
>  gdb/symmisc.c                                | 17 ++--
>  gdb/symtab.h                                 |  5 ++
>  gdb/testsuite/gdb.dwarf2/dw2-lnct-source.c   | 24 ++++++
>  gdb/testsuite/gdb.dwarf2/dw2-lnct-source.exp | 88 ++++++++++++++++++++
>  gdb/testsuite/lib/dwarf.exp                  | 19 +++--
>  include/dwarf2.h                             |  5 ++
>  16 files changed, 390 insertions(+), 98 deletions(-)
>  create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-lnct-source.c
>  create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-lnct-source.exp
>
> diff --git a/gdb/dwarf2/file-and-dir.h b/gdb/dwarf2/file-and-dir.h
> index a5b1d8a3a21..84a7367e973 100644
> --- a/gdb/dwarf2/file-and-dir.h
> +++ b/gdb/dwarf2/file-and-dir.h
> @@ -95,7 +95,14 @@ struct file_and_directory
>    const char *get_fullname ()
>    {
>      if (m_fullname == nullptr)
> -      m_fullname = find_source_or_rewrite (get_name (), get_comp_dir ());
> +      {
> +       if (m_is_embedded)
> +         m_fullname = make_unique_xstrdup (embedded_fullname (
> +                                                              get_name (),
> +                                                              get_comp_dir ()));
> +       else
> +         m_fullname = find_source_or_rewrite (get_name (), get_comp_dir ());
> +      }
>      return m_fullname.get ();
>    }
>
> @@ -105,6 +112,17 @@ struct file_and_directory
>      m_fullname.reset ();
>    }
>
> +  /* Set whether the file's source is embedded in the dwarf.  */
> +  void set_embedded (bool is_embedded)
> +  {
> +    m_is_embedded = is_embedded;
> +  }
> +
> +  /* Return true if the file's source is embedded in the dwarf.  */
> +  bool is_embedded () const
> +  {
> +    return m_is_embedded;
> +  }
>  private:
>
>    /* The filename.  */
> @@ -124,6 +142,9 @@ struct file_and_directory
>
>    /* The full name.  */
>    gdb::unique_xmalloc_ptr<char> m_fullname;
> +
> +  /* Whether the file's source is embedded in the dwarf.  */
> +  bool m_is_embedded = false;
>  };
>
>  #endif /* GDB_DWARF2_FILE_AND_DIR_H */
> diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
> index a3ca49b64f5..3bc707e999e 100644
> --- a/gdb/dwarf2/line-header.c
> +++ b/gdb/dwarf2/line-header.c
> @@ -45,6 +45,7 @@ line_header::add_include_dir (const char *include_dir)
>  void
>  line_header::add_file_name (const char *name,
>                             dir_index d_index,
> +                           const char *source,
>                             unsigned int mod_time,
>                             unsigned int length)
>  {
> @@ -54,7 +55,7 @@ line_header::add_file_name (const char *name,
>    if (dwarf_line_debug >= 2)
>      gdb_printf (gdb_stdlog, "Adding file %d: %s\n", index, name);
>
> -  m_file_names.emplace_back (name, index, d_index, mod_time, length);
> +  m_file_names.emplace_back (name, index, d_index, source, mod_time, length);
>  }
>
>  std::string
> @@ -125,6 +126,7 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
>                         void (*callback) (struct line_header *lh,
>                                           const char *name,
>                                           dir_index d_index,
> +                                         const char *source,
>                                           unsigned int mod_time,
>                                           unsigned int length))
>  {
> @@ -239,13 +241,17 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
>               break;
>             case DW_LNCT_MD5:
>               break;
> +           case DW_LNCT_LLVM_SOURCE:
> +             if (string.has_value () && (*string)[0] != '\0')
> +               fe.source = *string;
> +             break;
>             default:
>               complaint (_("Unknown format content type %s"),
>                          pulongest (content_type));
>             }
>         }
>
> -      callback (lh, fe.name, fe.d_index, fe.mod_time, fe.length);
> +      callback (lh, fe.name, fe.d_index, fe.source, fe.mod_time, fe.length);
>      }
>
>    *bufp = buf;
> @@ -368,8 +374,8 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>        read_formatted_entries (per_objfile, abfd, &line_ptr, lh.get (),
>                               offset_size,
>                               [] (struct line_header *header, const char *name,
> -                                 dir_index d_index, unsigned int mod_time,
> -                                 unsigned int length)
> +                                 dir_index d_index, const char *source,
> +                                 unsigned int mod_time, unsigned int length)
>         {
>           header->add_include_dir (name);
>         });
> @@ -378,10 +384,10 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>        read_formatted_entries (per_objfile, abfd, &line_ptr, lh.get (),
>                               offset_size,
>                               [] (struct line_header *header, const char *name,
> -                                 dir_index d_index, unsigned int mod_time,
> -                                 unsigned int length)
> +                                 dir_index d_index, const char *source,
> +                                 unsigned int mod_time, unsigned int length)
>         {
> -         header->add_file_name (name, d_index, mod_time, length);
> +         header->add_file_name (name, d_index, source, mod_time, length);
>         });
>      }
>    else
> @@ -408,7 +414,7 @@ dwarf_decode_line_header  (sect_offset sect_off, bool is_dwz,
>           length = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
>           line_ptr += bytes_read;
>
> -         lh->add_file_name (cur_file, d_index, mod_time, length);
> +         lh->add_file_name (cur_file, d_index, nullptr, mod_time, length);
>         }
>        line_ptr += bytes_read;
>      }
> diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
> index c068dff70a3..abc95f3ee87 100644
> --- a/gdb/dwarf2/line-header.h
> +++ b/gdb/dwarf2/line-header.h
> @@ -35,9 +35,10 @@ struct file_entry
>    file_entry () = default;
>
>    file_entry (const char *name_, file_name_index index_, dir_index d_index_,
> -             unsigned int mod_time_, unsigned int length_)
> +             const char *source_, unsigned int mod_time_, unsigned int length_)
>      : name (name_),
>        index (index_),
> +      source (source_),
>        d_index (d_index_),
>        mod_time (mod_time_),
>        length (length_)
> @@ -54,6 +55,10 @@ struct file_entry
>    /* The index of this file in the file table.  */
>    file_name_index index {};
>
> +  /* The file's contents (if not null).  Note this is an observing pointer.
> +     The memory is owned by debug_line_buffer.  */
> +  const char *source {};
> +
>    /* The directory index (1-based).  */
>    dir_index d_index {};
>
> @@ -88,7 +93,7 @@ struct line_header
>    void add_include_dir (const char *include_dir);
>
>    /* Add an entry to the file name table.  */
> -  void add_file_name (const char *name, dir_index d_index,
> +  void add_file_name (const char *name, dir_index d_index, const char *source,
>                       unsigned int mod_time, unsigned int length);
>
>    /* Return the include dir at INDEX (0-based in DWARF 5 and 1-based before).
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 7442094874c..e35ff019acf 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -1635,6 +1635,10 @@ struct quick_file_names
>    /* The file names from the line table after being run through
>       gdb_realpath.  These are computed lazily.  */
>    const char **real_names;
> +
> +  /* Whether or not the file names refer to sources embedded
> +     in the dwarf.  */
> +  const bool *embeddeds;
>  };
>
>  /* With OBJF_READNOW, the DWARF reader expands all CUs immediately.
> @@ -1908,27 +1912,39 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
>    if (slot != nullptr)
>      *slot = qfn;
>
> +
> +  bool cu_file_embedded = false;
> +  std::vector<bool> embeddedv;
> +
>    std::vector<const char *> include_names;
>    if (lh != nullptr)
>      {
>        for (const auto &entry : lh->file_names ())
>         {
>           std::string name_holder;
> -         const char *include_name =
> -           compute_include_file_name (lh.get (), entry, fnd, name_holder);
> +         const char *include_name
> +           = compute_include_file_name (lh.get (), entry, fnd, name_holder);
>           if (include_name != nullptr)
>             {
>               include_name = per_objfile->objfile->intern (include_name);
>               include_names.push_back (include_name);
> +             embeddedv.push_back (entry.source != nullptr);
>             }
> +         else if (entry.source != nullptr)
> +           {
> +             /* We have an embedded source for the CU.  */
> +             gdb_assert (offset == 1);
> +             cu_file_embedded = true;
> +           }
> +
>         }
>      }
>
>    qfn->num_file_names = offset + include_names.size ();
>    qfn->comp_dir = fnd.intern_comp_dir (per_objfile->objfile);
> -  qfn->file_names =
> -    XOBNEWVEC (&per_objfile->per_bfd->obstack, const char *,
> -              qfn->num_file_names);
> +  qfn->file_names
> +    = XOBNEWVEC (&per_objfile->per_bfd->obstack, const char *,
> +                qfn->num_file_names);
>    if (offset != 0)
>      qfn->file_names[0] = per_objfile->objfile->intern (fnd.get_name ());
>
> @@ -1936,7 +1952,16 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
>      memcpy (&qfn->file_names[offset], include_names.data (),
>             include_names.size () * sizeof (const char *));
>
> -  qfn->real_names = NULL;
> +  bool *embeddeds
> +    = XOBNEWVEC (&per_objfile->per_bfd->obstack, bool,
> +                qfn->num_file_names);
> +  if (cu_file_embedded)
> +    embeddeds[0] = true;
> +  for (size_t i = 0; i < embeddedv.size (); i++)
> +    embeddeds[offset + i] = embeddedv[i];
> +  qfn->embeddeds = embeddeds;
> +
> +  qfn->real_names = nullptr;
>
>    lh_cu->file_names = qfn;
>  }
> @@ -1980,7 +2005,11 @@ dw2_get_real_path (dwarf2_per_objfile *per_objfile,
>         dirname = qfn->comp_dir;
>
>        gdb::unique_xmalloc_ptr<char> fullname;
> -      fullname = find_source_or_rewrite (qfn->file_names[index], dirname);
> +
> +      if (qfn->embeddeds[index])
> +       fullname.reset (embedded_fullname (dirname, qfn->file_names[index]));
> +      else
> +       fullname = find_source_or_rewrite (qfn->file_names[index], dirname);
>
>        qfn->real_names[index] = fullname.release ();
>      }
> @@ -7311,6 +7340,35 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu)
>    file_and_directory res (dwarf2_string_attr (die, DW_AT_name, cu),
>                           dwarf2_string_attr (die, DW_AT_comp_dir, cu));
>
> +  /* Because the line header may tell us information about the CU
> +     filename (e.g., whether it is embedded) which will affect other
> +     calculations, we have to read that information here.  */
> +  line_header *lh = cu->line_header;
> +  struct attribute *attr = dwarf2_attr (die, DW_AT_stmt_list, cu);
> +  if (lh == nullptr && attr != nullptr && attr->form_is_unsigned ())
> +    {
> +      sect_offset line_offset = (sect_offset) attr->as_unsigned ();
> +      line_header_up lhu = dwarf_decode_line_header (line_offset, cu,
> +                                    res.get_comp_dir ());
> +      if (lhu != nullptr)
> +         lh = lhu.release();
> +    }
> +
> +  if (lh != nullptr)
> +    {
> +      for (const auto &entry : lh->file_names ())
> +       {
> +         if (entry.source == nullptr)
> +           continue;
> +
> +         std::string name_holder;
> +         const char *include_name =
> +           compute_include_file_name (lh, entry, res, name_holder);
> +         if (include_name == nullptr)
> +           res.set_embedded (true);
> +       }
> +    }
> +
>    if (res.get_comp_dir () == nullptr
>        && producer_is_gcc_lt_4_3 (cu)
>        && res.get_name () != nullptr
> @@ -18448,7 +18506,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
>                     length =
>                       read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
>                     line_ptr += bytes_read;
> -                   lh->add_file_name (cur_file, dindex, mod_time, length);
> +                   lh->add_file_name (cur_file, dindex, nullptr, mod_time, length);
>                   }
>                   break;
>                 case DW_LNE_set_discriminator:
> @@ -18603,9 +18661,12 @@ dwarf_decode_lines (struct line_header *lh, struct dwarf2_cu *cu,
>        subfile *sf = builder->get_current_subfile ();
>
>        if (sf->symtab == nullptr)
> -       sf->symtab = allocate_symtab (cust, sf->name.c_str (),
> -                                     sf->name_for_id.c_str ());
> -
> +       {
> +         sf->symtab = allocate_symtab (cust, sf->name.c_str (),
> +                                       sf->name_for_id.c_str ());
> +         if (fe.source)
> +           sf->symtab->source = fe.source;
> +       }
>        fe.symtab = sf->symtab;
>      }
>  }
> diff --git a/gdb/extension.c b/gdb/extension.c
> index 9db8b53a087..f17991a3751 100644
> --- a/gdb/extension.c
> +++ b/gdb/extension.c
> @@ -991,16 +991,19 @@ xmethod_worker::get_result_type (value *object, gdb::array_view<value *> args)
>  /* See extension.h.  */
>
>  std::optional<std::string>
> -ext_lang_colorize (const std::string &filename, const std::string &contents)
> +ext_lang_colorize (const std::string &filename, const std::string_view contents)
>  {
>    std::optional<std::string> result;
>
> +  /* We avoided copies as long as possible. The external colorization API
> +     requires a std::string.  */
> +  std::string contents_storage = std::string (contents);
>    for (const struct extension_language_defn *extlang : extension_languages)
>      {
>        if (extlang->ops == nullptr
>           || extlang->ops->colorize == nullptr)
>         continue;
> -      result = extlang->ops->colorize (filename, contents);
> +      result = extlang->ops->colorize (filename, contents_storage);
>        if (result.has_value ())
>         return result;
>      }
> diff --git a/gdb/extension.h b/gdb/extension.h
> index 5260bcbde00..e5a5333b7c3 100644
> --- a/gdb/extension.h
> +++ b/gdb/extension.h
> @@ -319,12 +319,13 @@ extern void get_matching_xmethod_workers
>     std::vector<xmethod_worker_up> *workers);
>
>  /* Try to colorize some source code.  FILENAME is the name of the file
> -   holding the code.  CONTENTS is the source code itself.  This will
> -   either a colorized (using ANSI terminal escapes) version of the
> -   source code, or an empty value if colorizing could not be done.  */
> +   holding the code.  CONTENTS is a view of the source code itself.
> +   This will either generate a colorized (using ANSI terminal escapes)
> +   version of the source code, or an empty value if colorizing could not
> +   be done.  */
>
>  extern std::optional<std::string> ext_lang_colorize
> -  (const std::string &filename, const std::string &contents);
> +  (const std::string &filename, const std::string_view contents);
>
>  /* Try to colorize a single line of disassembler output, CONTENT for
>     GDBARCH.  This will return either a colorized (using ANSI terminal
> diff --git a/gdb/source-cache.c b/gdb/source-cache.c
> index 8b5bd84d19a..f5168921f99 100644
> --- a/gdb/source-cache.c
> +++ b/gdb/source-cache.c
> @@ -93,32 +93,45 @@ set_use_gnu_source_highlight_enabled (const char *ignore_args,
>
>  /* See source-cache.h.  */
>
> -std::string
> +std::string_view
>  source_cache::get_plain_source_lines (struct symtab *s,
> -                                     const std::string &fullname)
> +                                     const std::string &fullname,
> +                                     std::string &source_storage)
>  {
> -  scoped_fd desc (open_source_file (s));
> -  if (desc.get () < 0)
> -    perror_with_name (symtab_to_filename_for_display (s), -desc.get ());
> +  std::string_view lines;
> +  if (!s->source)
> +    {
> +
> +      scoped_fd desc (open_source_file (s));
> +      if (desc.get () < 0)
> +       perror_with_name (symtab_to_filename_for_display (s), -desc.get ());
>
> -  struct stat st;
> -  if (fstat (desc.get (), &st) < 0)
> -    perror_with_name (symtab_to_filename_for_display (s));
> +      struct stat st;
> +      if (fstat (desc.get (), &st) < 0)
> +       perror_with_name (symtab_to_filename_for_display (s));
>
> -  std::string lines;
> -  lines.resize (st.st_size);
> -  if (myread (desc.get (), &lines[0], lines.size ()) < 0)
> -    perror_with_name (symtab_to_filename_for_display (s));
> +      source_storage.resize (st.st_size);
> +      if (myread (desc.get (),
> +                 &source_storage[0],
> +                 source_storage.size ()) < 0)
> +       perror_with_name (symtab_to_filename_for_display (s));
>
> -  time_t mtime = 0;
> -  if (s->compunit ()->objfile () != NULL
> -      && s->compunit ()->objfile ()->obfd != NULL)
> -    mtime = s->compunit ()->objfile ()->mtime;
> -  else if (current_program_space->exec_bfd ())
> -    mtime = current_program_space->ebfd_mtime;
> +      time_t mtime = 0;
> +      if (s->compunit ()->objfile () != nullptr
> +         && s->compunit ()->objfile ()->obfd != nullptr)
> +       mtime = s->compunit ()->objfile ()->mtime;
> +      else if (current_program_space->exec_bfd ())
> +       mtime = current_program_space->ebfd_mtime;
>
> -  if (mtime && mtime < st.st_mtime)
> -    warning (_("Source file is more recent than executable."));
> +      if (mtime && mtime < st.st_mtime)
> +       warning (_("Source file is more recent than executable."));
> +
> +      lines = source_storage;
> +    }
> +  else
> +    {
> +      lines = s->source;
> +    }
>

Tom mentioned lifting this check to the caller (source_cache::ensure)
but I thought it made more sense to leave it here because of the code
that calculates the offsets. If that is not reason enough to leave it
here, I am glad to take another whack at refactoring!


>    std::vector<off_t> offsets;
>    offsets.push_back (0);
> @@ -200,9 +213,10 @@ get_language_name (enum language lang)
>     succeeded.  */
>
>  static bool
> -try_source_highlight (std::string &contents ATTRIBUTE_UNUSED,
> +try_source_highlight (std::string_view &contents ATTRIBUTE_UNUSED,
>                       enum language lang ATTRIBUTE_UNUSED,
> -                     const std::string &fullname ATTRIBUTE_UNUSED)
> +                     const std::string &fullname ATTRIBUTE_UNUSED,
> +                     std::string &contents_storage)
>  {


My general approach was to use the '_storage' paradigm that I have
seen throughout the codebase. Where I can use a std::string_view, I
did. Where I ultimately needed some storage, I use those parameters.

As above, please let me know if this pattern looks okay! If it does, I
will continue to finalize based on the feedback that I received in the
previous review.

Thank you again for the welcome to the project!
Will


>  #ifdef HAVE_SOURCE_HIGHLIGHT
>    if (!use_gnu_source_highlight)
> @@ -240,10 +254,14 @@ try_source_highlight (std::string &contents ATTRIBUTE_UNUSED,
>           lang_name = detected_lang.c_str ();
>         }
>
> -      std::istringstream input (contents);
> +      /* We waited as long as possible but now we need a string.  */
> +      contents_storage = contents;
> +      std::istringstream input (contents_storage);
>        std::ostringstream output;
>        highlighter->highlight (input, output, lang_name, fullname);
> -      contents = std::move (output).str ();
> +      /* Use the given storage for the contents and set the
> +        view appropriately.  */
> +      contents = contents_storage = std::move (output).str ();
>        styled = true;
>      }
>    catch (...)
> @@ -275,13 +293,16 @@ static void gnu_source_highlight_test ()
>         "}\n");
>    const std::string fullname = "test.c";
>    std::string styled_prog;
> +  std::string_view styled_prog_view;
>
>    bool res = false;
>    bool saw_exception = false;
>    styled_prog = prog;
> +  styled_prog_view = styled_prog;
>    try
>      {
> -      res = try_source_highlight (styled_prog, language_c, fullname);
> +      res = try_source_highlight (styled_prog_view, language_c, fullname,
> +                                 styled_prog);
>      }
>    catch (...)
>      {
> @@ -324,10 +345,12 @@ source_cache::ensure (struct symtab *s)
>         }
>      }
>
> -  std::string contents;
> +  std::string_view source_contents;
> +  std::string source_contents_storage;
>    try
>      {
> -      contents = get_plain_source_lines (s, fullname);
> +      source_contents = get_plain_source_lines (s, fullname,
> +                                               source_contents_storage);
>      }
>    catch (const gdb_exception_error &e)
>      {
> @@ -339,15 +362,17 @@ source_cache::ensure (struct symtab *s)
>        && m_no_styling_files.count (fullname) == 0)
>      {
>        bool already_styled
> -       = try_source_highlight (contents, s->language (), fullname);
> +       = try_source_highlight (source_contents, s->language (), fullname,
> +                               source_contents_storage);
>
>        if (!already_styled)
>         {
>           std::optional<std::string> ext_contents;
> -         ext_contents = ext_lang_colorize (fullname, contents);
> +         ext_contents = ext_lang_colorize (fullname, source_contents);
>           if (ext_contents.has_value ())
>             {
> -             contents = std::move (*ext_contents);
> +             source_contents = source_contents_storage
> +               = std::move (*ext_contents);
>               already_styled = true;
>             }
>         }
> @@ -369,7 +394,7 @@ source_cache::ensure (struct symtab *s)
>         }
>      }
>
> -  source_text result = { std::move (fullname), std::move (contents) };
> +  source_text result = { std::move (fullname), std::string (source_contents) };
>    m_source_map.push_back (std::move (result));
>
>    if (m_source_map.size () > MAX_ENTRIES)
> diff --git a/gdb/source-cache.h b/gdb/source-cache.h
> index d4cb7d00ae8..84996a6a5a1 100644
> --- a/gdb/source-cache.h
> +++ b/gdb/source-cache.h
> @@ -80,11 +80,13 @@ class source_cache
>      std::string contents;
>    };
>
> -  /* A helper function for get_source_lines reads a source file.
> -     Returns the contents of the file; or throws an exception on
> -     error.  This also updates m_offset_cache.  */
> -  std::string get_plain_source_lines (struct symtab *s,
> -                                     const std::string &fullname);
> +  /* A helper function for get_source_lines that reads a source file.
> +     Returns a view of the contents of the file using SOURCE_STORAGE
> +     as necessary (i.e., if the source is stored on disk);  or throws
> +     an exception on error.  This also updates m_offset_cache.  */
> +  std::string_view get_plain_source_lines (struct symtab *s,
> +                                          const std::string &fullname,
> +                                          std::string &source_storage);
>
>    /* A helper function that the data for the given symtab is entered
>       into both caches.  Returns false on error.  */
> diff --git a/gdb/source.c b/gdb/source.c
> index bbeb4154258..8bfaffe43a8 100644
> --- a/gdb/source.c
> +++ b/gdb/source.c
> @@ -684,9 +684,11 @@ info_source_command (const char *ignore, int from_tty)
>
>    cust = s->compunit ();
>    gdb_printf (_("Current source file is %s\n"), s->filename);
> -  if (s->compunit ()->dirname () != NULL)
> +  if (s->compunit ()->dirname () != nullptr)
>      gdb_printf (_("Compilation directory is %s\n"), s->compunit ()->dirname ());
> -  if (s->fullname)
> +  if (s->source != nullptr)
> +    gdb_printf (_("With embedded source.\n"));
> +  else if (s->fullname)
>      gdb_printf (_("Located in %s\n"), s->fullname);
>    const std::vector<off_t> *offsets;
>    if (g_source_cache.get_line_charpos (s, &offsets))
> @@ -960,6 +962,19 @@ source_full_path_of (const char *filename,
>    return 1;
>  }
>
> +/* See source.h.  */
> +
> +char *
> +embedded_fullname (const char *dirname, const char *filename)
> +{
> +  if (dirname != nullptr)
> +    {
> +      return concat (dirname, SLASH_STRING, filename, (char *) nullptr);
> +    }
> +
> +  return xstrdup (filename);
> +}
> +
>  /* Return non-zero if RULE matches PATH, that is if the rule can be
>     applied to PATH.  */
>
> @@ -1237,27 +1252,35 @@ symtab_to_fullname (struct symtab *s)
>    /* Use cached copy if we have it.
>       We rely on forget_cached_source_info being called appropriately
>       to handle cases like the file being moved.  */
> -  if (s->fullname == NULL)
> +  if (s->fullname == nullptr)
>      {
> -      scoped_fd fd = open_source_file (s);
> -
> -      if (fd.get () < 0)
> +      if (s->source)
> +         s->fullname = embedded_fullname (s->compunit ()->dirname (),
> +                                          s->filename);
> +      else
>         {
> -         gdb::unique_xmalloc_ptr<char> fullname;
> +         scoped_fd fd = open_source_file (s);
>
> -         /* rewrite_source_path would be applied by find_and_open_source, we
> -            should report the pathname where GDB tried to find the file.  */
> +         if (fd.get () < 0)
> +           {
> +             gdb::unique_xmalloc_ptr<char> fullname;
>
> -         if (s->compunit ()->dirname () == nullptr
> -             || IS_ABSOLUTE_PATH (s->filename))
> -           fullname.reset (xstrdup (s->filename));
> -         else
> -           fullname.reset (concat (s->compunit ()->dirname (), SLASH_STRING,
> -                                   s->filename, (char *) NULL));
> +             /* rewrite_source_path would be applied by find_and_open_source,
> +                we should report the pathname where GDB tried to find the
> +                file.  */
>
> -         s->fullname = rewrite_source_path (fullname.get ()).release ();
> -         if (s->fullname == NULL)
> -           s->fullname = fullname.release ();
> +             if (s->compunit ()->dirname () == nullptr
> +                 || IS_ABSOLUTE_PATH (s->filename))
> +               fullname.reset (xstrdup (s->filename));
> +             else
> +               fullname.reset (concat (s->compunit ()->dirname (),
> +                                       SLASH_STRING, s->filename,
> +                                       (char *) nullptr));
> +
> +             s->fullname = rewrite_source_path (fullname.get ()).release ();
> +             if (s->fullname == nullptr)
> +               s->fullname = fullname.release ();
> +           }
>         }
>      }
>
> @@ -1317,12 +1340,17 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
>        else
>         {
>           last_source_visited = s;
> -         scoped_fd desc = open_source_file (s);
> -         last_source_error = desc.get () < 0;
> -         if (last_source_error)
> +         /* Do not attempt to open a source file for a symtab
> +            with an embedded source.  */
> +         if (!s->source)
>             {
> -             noprint = true;
> -             errcode = -desc.get ();
> +             scoped_fd desc = open_source_file (s);
> +             last_source_error = desc.get () < 0;
> +             if (last_source_error)
> +               {
> +                 noprint = true;
> +                 errcode = -desc.get ();
> +               }
>             }
>         }
>      }
> diff --git a/gdb/source.h b/gdb/source.h
> index 144ee48f722..f27caf1a9b5 100644
> --- a/gdb/source.h
> +++ b/gdb/source.h
> @@ -216,4 +216,8 @@ extern void forget_cached_source_info (void);
>     need to would make things slower than necessary.  */
>  extern void select_source_symtab ();
>
> +/* Compute the fullname for a source file whose source is embedded
> +   in the dwarf file.  */
> +extern char *embedded_fullname (const char *dirname,
> +                               const char *filename);
>  #endif
> diff --git a/gdb/symmisc.c b/gdb/symmisc.c
> index 49b9674f77a..f5092de2659 100644
> --- a/gdb/symmisc.c
> +++ b/gdb/symmisc.c
> @@ -810,9 +810,11 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
>                     gdb_printf ("((struct symtab *) %s)\n",
>                                 host_address_to_string (symtab));
>                     gdb_printf ("\t  fullname %s\n",
> -                               symtab->fullname != NULL
> +                               symtab->fullname != nullptr
>                                 ? symtab->fullname
>                                 : "(null)");
> +                   if (symtab->source != nullptr)
> +                     gdb_printf ("\t  source embedded in DWARF\n");
>                     gdb_printf ("\t  "
>                                 "linetable ((struct linetable *) %s)\n",
>                                 host_address_to_string
> @@ -955,15 +957,20 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
>    gdb_printf (_("compunit_symtab: %s ((struct compunit_symtab *) %s)\n"),
>               symtab->compunit ()->name,
>               host_address_to_string (symtab->compunit ()));
> +  styled_string_s *styled_symtab_fullname = nullptr;
> +  if (symtab->source)
> +    styled_symtab_fullname = styled_string (metadata_style.style (),
> +                                           _("Source embedded in DWARF"));
> +  else
> +    styled_symtab_fullname = styled_string (file_name_style.style (),
> +                                           symtab_to_fullname (symtab));
>    gdb_printf (_("symtab: %ps ((struct symtab *) %s)\n"),
> -             styled_string (file_name_style.style (),
> -                            symtab_to_fullname (symtab)),
> +             styled_symtab_fullname,
>               host_address_to_string (symtab));
>    linetable = symtab->linetable ();
>    gdb_printf (_("linetable: ((struct linetable *) %s):\n"),
>               host_address_to_string (linetable));
> -
> -  if (linetable == NULL)
> +  if (linetable == nullptr)
>      gdb_printf (_("No line table.\n"));
>    else if (linetable->nitems <= 0)
>      gdb_printf (_("Line table has no lines.\n"));
> diff --git a/gdb/symtab.h b/gdb/symtab.h
> index bf9a3cfb79f..90c2f202390 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -1755,6 +1755,11 @@ struct symtab
>
>    const char *filename;
>
> +  /* When the contents of the source file were/are embedded with the
> +     debugging info, this pointer will refer to that source. Can be nullptr
> +     if the source for this source file is on disk.  */
> +  const char *source;
> +
>    /* Filename for this source file, used as an identifier to link with
>       related objects such as associated macro_source_file objects.  It must
>       therefore match the name of any macro_source_file object created for this
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.c b/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.c
> new file mode 100644
> index 00000000000..86cdb9655b7
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.c
> @@ -0,0 +1,24 @@
> +/* Copyright 2024 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +
> +int
> +main (void)
> +{                                                      /* main prologue */
> +  asm ("main_label: .global main_label");
> +  int m = 42;                                          /* main assign m */
> +  asm ("main_end: .global main_end");                  /* main end */
> +  return m;
> +}
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.exp b/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.exp
> new file mode 100644
> index 00000000000..73a06bd7b9c
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-lnct-source.exp
> @@ -0,0 +1,88 @@
> +# Copyright 2024 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Check that GDB can honor LNCT_llvm_SOURCE.
> +
> +load_lib dwarf.exp
> +
> +# This test can only be run on targets which support DWARF-2 and use gas.
> +require dwarf2_support
> +
> +standard_testfile .c .S
> +
> +set asm_file [standard_output_file $srcfile2]
> +
> +set fp [open "${srcdir}/${subdir}/${srcfile}" r]
> +set srcfile_data [read $fp]
> +close $fp
> +
> +Dwarf::assemble $asm_file {
> +    global srcdir subdir srcfile srcfile2 srcfile_data
> +    declare_labels lines_label
> +
> +    get_func_info main
> +
> +    cu {} {
> +       compile_unit {
> +           {language @DW_LANG_C}
> +           {name missing-file.c}
> +           {stmt_list ${lines_label} DW_FORM_sec_offset}
> +       } {
> +           subprogram {
> +               {external 1 flag}
> +               {name main}
> +               {low_pc $main_start addr}
> +               {high_pc "$main_start + $main_len" addr}
> +           }
> +       }
> +    }
> +
> +    lines {version 5} lines_label {
> +       set diridx [include_dir "${srcdir}/${subdir}"]
> +       file_name "missing-file.c" $diridx "${srcfile_data}"
> +
> +       program {
> +           DW_LNS_set_file $diridx
> +           DW_LNE_set_address $main_start
> +           line [gdb_get_line_number "main prologue"]
> +           DW_LNS_copy
> +
> +           DW_LNE_set_address main_label
> +           line [gdb_get_line_number "main assign m"]
> +           DW_LNS_copy
> +
> +           DW_LNE_set_address main_end
> +           line [gdb_get_line_number "main end"]
> +           DW_LNS_copy
> +
> +           DW_LNE_end_sequence
> +       }
> +    }
> +}
> +
> +if { [prepare_for_testing "failed to prepare" ${testfile} \
> +         [list $srcfile $asm_file] {nodebug}] } {
> +    return -1
> +}
> +
> +if ![runto_main] {
> +    return -1
> +}
> +
> +set assign_m_line [gdb_get_line_number "main assign m"]
> +gdb_test "frame" ".*main \\\(\\\) at \[^\r\n\]*:$assign_m_line\r\n.*"
> +gdb_test "maintenance info symtabs missing-file.c" ".*source embedded in DWARF.*"
> +gdb_test "maintenance info line-table missing-file.c" ".*symtab: Source embedded in DWARF.*"
> +gdb_test "info source" ".*With embedded source.*"
> diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
> index d085f835f07..b1f09eab3d3 100644
> --- a/gdb/testsuite/lib/dwarf.exp
> +++ b/gdb/testsuite/lib/dwarf.exp
> @@ -2423,9 +2423,9 @@ namespace eval Dwarf {
>         # Add a file name entry to the line table header's file names table.
>         #
>         # Return the index by which this entry can be referred to.
> -       proc file_name {filename diridx} {
> +       proc file_name {filename diridx { source "" } } {
>             variable _line_file_names
> -           lappend _line_file_names $filename $diridx
> +           lappend _line_file_names $filename $diridx $source
>
>             if { $Dwarf::_line_unit_version >= 5 } {
>                 return [expr [llength $_line_file_names] - 1]
> @@ -2481,7 +2481,7 @@ namespace eval Dwarf {
>                     }
>                 }
>
> -               _op .byte 2 "file_name_entry_format_count"
> +               _op .byte 3 "file_name_entry_format_count"
>                 _op .uleb128 1 \
>                     "file_name_entry_format (content type code: DW_LNCT_path)"
>                 switch $_line_string_form {
> @@ -2494,15 +2494,21 @@ namespace eval Dwarf {
>                             "directory_entry_format (form: DW_FORM_line_strp)"
>                     }
>                 }
> +
>                 _op .uleb128 2 \
>                     "file_name_entry_format (content type code: DW_LNCT_directory_index)"
>                 _op .uleb128 0x0f \
>                     "file_name_entry_format (form: DW_FORM_udata)"
>
> -               set nr_files [expr [llength $_line_file_names] / 2]
> +               _op .uleb128 0x2001 \
> +                   "file_name_entry_format (content type code: DW_LNCT_LLVM_SOURCE)"
> +               _op .uleb128 0x08 \
> +                   "file_name_entry_format (form: DW_FORM_string)"
> +
> +               set nr_files [expr [llength $_line_file_names] / 3]
>                 _op .byte $nr_files "file_names_count"
>
> -               foreach { filename diridx } $_line_file_names {
> +               foreach { filename diridx source } $_line_file_names {
>                     switch $_line_string_form {
>                         string {
>                             _op .ascii [_quote $filename]
> @@ -2517,6 +2523,7 @@ namespace eval Dwarf {
>                         }
>                     }
>                     _op .uleb128 $diridx
> +                   _op .ascii [_quote [string map { "\"" "\\\"" "\n" "\\n" } $source]]
>                 }
>             } else {
>                 foreach dirname $_line_include_dirs {
> @@ -2525,7 +2532,7 @@ namespace eval Dwarf {
>
>                 _op .byte 0 "Terminator (include_directories)"
>
> -               foreach { filename diridx } $_line_file_names {
> +               foreach { filename diridx source } $_line_file_names {
>                     _op .ascii [_quote $filename]
>                     _op .sleb128 $diridx
>                     _op .sleb128 0 "mtime"
> diff --git a/include/dwarf2.h b/include/dwarf2.h
> index b3d3731ee83..3823c041bab 100644
> --- a/include/dwarf2.h
> +++ b/include/dwarf2.h
> @@ -289,6 +289,11 @@ enum dwarf_line_number_content_type
>      DW_LNCT_size = 0x4,
>      DW_LNCT_MD5 = 0x5,
>      DW_LNCT_lo_user = 0x2000,
> +    /* LLVM has implemented DW_LNCT_source (see
> +       https://dwarfstd.org/issues/180201.1.html) as DW_LNCT_LLVM_SOURCE as
> +       a vendor extension until the DWARF standard is updated (see
> +       https://github.com/llvm/llvm-project/blob/08bb121835be432ac52372f92845950628ce9a4a/llvm/include/llvm/BinaryFormat/Dwarf.def#L1080 .  */
> +    DW_LNCT_LLVM_SOURCE = 0x2001,
>      DW_LNCT_hi_user = 0x3fff
>    };
>
> --
> 2.44.0
>

^ permalink raw reply	[relevance 0%]

* Re: [PATCH^4] gdb: mips: Add MIPSR6 support
  @ 2024-04-05 15:12  0% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-04-05 15:12 UTC (permalink / raw)
  To: Milos Kalicanin, gdb-patches
  Cc: Maciej W . Rozycki, Chao-ying Fu, Simon Marchi,
	Djordje Todorovic, Dragan Mladjenovic

Milos Kalicanin <Milos.Kalicanin@Syrmia.com> writes:

> Introduce new instruction encodings from Release 6 of the MIPS
> architecture [1]. Support breakpoints and single stepping with
> compact branches, forbidden slots, new branch instruction and
> new atomic load-store instruction encodings.

OK, so I've not done any MIPS work in ~20 years, so I'm not going to
review the actual details of the MIPS architecture that you've
implemented here.  I see you've CC'd the MIPS maintainer, they can
comment if they care.  All the changes are contained in the mips tdep
file, so if you break it, then it's not going to hurt anyone else.

I do have some style comments which I think should be addressed, all
notes are inline below.

>
> Changes from v3: Apply code formatting as Simon Marchi suggested.
>
> [1] "MIPS64 Architecture for Programmers Volume II-A: The MIPS64
>     Instruction Set Reference Manual", Document Number: MD00087,
>     Revision 6.06, December 15, 2016, Section 3 "The MIPS64
>     Instruction Set", pp. 42-530
> https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00087-2B-MIPS64BIS-AFP-6.06.pdf
>
> 2024-02-14  Andrew Bennett  <andrew.bennett@imgtec.com>
>             Matthew Fortune  <matthew.fortune@mips.com>
>             Faraz Shahbazker  <fshahbazker@wavecomp.com>
>
> gdb/ChangeLog:
>         * mips-tdep.c (is_mipsr6_isa): New.
>         (b0s21_imm): New define.
>         (mips32_relative_offset21, mips32_relative_offset26): New.
>         (is_add32bit_overflow, is_add64bit_overflow): New.
>         (mips32_next_pc): Handle r6 compact and fpu coprocessor branches.
>         Move handling of BLEZ, BGTZ opcode into ...
>         (mips32_blez_pc): New.
>         (mips32_instruction_is_compact_branch): New.
>         (mips32_insn_at_pc_has_forbidden_slot):  New.
>         (mips32_scan_prologue): Ignore pre-r6 addi encoding on r6.
>         Stop at compact branch also.
>         (LLSC_R6_OPCODE,LL_R6_FUNCT,LLE_FUNCT,
>         LLD_R6_FUNCT,SC_R6_FUNCT,SCE_FUNCT,
>         SCD_R6_FUNCT: New defines.
>         (is_ll_insn, is_sc_insn): New.
>         (mips_deal_with_atomic_sequence): Use is_ll_insn/is_sc_insn.
>         Handle compact branches.
>         (mips_about_to_return): Handle jrc and macro jr.
>         (mips32_stack_frame_destroyed_p): Likewise.
>         (mips32_instruction_has_delay_slot): Don't handle JALX on r6.
>         Handle compact branches and coprocessor branches.
>         (mips_adjust_breakpoint_address): Skip forbidden slot for
>         compact branches.
> ---
>  gdb/mips-tdep.c                       | 538 +++++++++++++--
>  gdb/testsuite/gdb.arch/mips-64-r6.c   | 913 ++++++++++++++++++++++++++
>  gdb/testsuite/gdb.arch/mips-64-r6.exp |  88 +++
>  3 files changed, 1492 insertions(+), 47 deletions(-)
>  create mode 100644 gdb/testsuite/gdb.arch/mips-64-r6.c
>  create mode 100644 gdb/testsuite/gdb.arch/mips-64-r6.exp
>
> diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
> index bf0b66c4b00..609932100cf 100644
> --- a/gdb/mips-tdep.c
> +++ b/gdb/mips-tdep.c
> @@ -60,7 +60,7 @@
>  
>  static struct type *mips_register_type (struct gdbarch *gdbarch, int regnum);
>  
> -static int mips32_instruction_has_delay_slot (struct gdbarch *gdbarch,
> +static bool mips32_instruction_has_delay_slot (struct gdbarch *gdbarch,
>  					      ULONGEST inst);
>  static int micromips_instruction_has_delay_slot (ULONGEST insn, int mustbe32);
>  static int mips16_instruction_has_delay_slot (unsigned short inst,
> @@ -76,6 +76,9 @@ static int mips16_insn_at_pc_has_delay_slot (struct gdbarch *gdbarch,
>  static void mips_print_float_info (struct gdbarch *, struct ui_file *,
>  				   frame_info_ptr, const char *);
>  
> +static void mips_read_fp_register_single (struct frame_info_ptr, int,
> +					  gdb_byte *);
> +
>  /* A useful bit in the CP0 status register (MIPS_PS_REGNUM).  */
>  /* This bit is set if we are emulating 32-bit FPRs on a 64-bit chip.  */
>  #define ST0_FR (1 << 26)
> @@ -124,6 +127,10 @@ enum mips_breakpoint_kind
>    MIPS_BP_KIND_MICROMIPS32 = 5,
>  };
>  
> +/* Enum describing type of compact branch or jump. */

Two spaces at the end of the sentence before the '*/'.

> +enum compact_branch_type
> +{ COMP_BRANCH_NONE = 0, COMP_BRANCH_UNCOND = 1, COMP_BRANCH_COND = 2 };
> +
>  /* For backwards compatibility we default to MIPS16.  This flag is
>     overridden as soon as unambiguous ELF file flags tell us the
>     compressed ISA encoding used.  */
> @@ -1500,6 +1507,16 @@ mips_fetch_instruction (struct gdbarch *gdbarch,
>    return extract_unsigned_integer (buf, instlen, byte_order);
>  }
>  
> +/* Return true if the gdbarch is based on MIPS Release 6.  */
> +static bool
> +is_mipsr6_isa (struct gdbarch *gdbarch)
> +{
> +  const struct bfd_arch_info *info = gdbarch_bfd_arch_info (gdbarch);
> +
> +  return (info->mach == bfd_mach_mipsisa32r6
> +	  || info->mach == bfd_mach_mipsisa64r6);
> +}

I notice that we already have the functions is_mips16_isa and
is_micromips_isa, which return a result based on the value of
mips_gdbarch_tdep::mips_isa.

I suspect I can guess the answer, but I think it would be good to place
this function next to the other *_isa () functions, and I think the
comment on the function should explain why this function is different to
the other functions.

> +
>  /* These are the fields of 32 bit mips instructions.  */
>  #define mips32_op(x) (x >> 26)
>  #define itype_op(x) (x >> 26)
> @@ -1542,6 +1559,7 @@ mips_fetch_instruction (struct gdbarch *gdbarch,
>  #define b0s11_op(x) ((x) & 0x7ff)
>  #define b0s12_imm(x) ((x) & 0xfff)
>  #define b0s16_imm(x) ((x) & 0xffff)
> +#define b0s21_imm(x) ((x) & 0x1fffff)
>  #define b0s26_imm(x) ((x) & 0x3ffffff)
>  #define b6s10_ext(x) (((x) >> 6) & 0x3ff)
>  #define b11s5_reg(x) (((x) >> 11) & 0x1f)

> @@ -1636,6 +1666,71 @@ is_octeon_bbit_op (int op, struct gdbarch *gdbarch)
>    return 0;
>  }
>  
> +static bool
> +is_add32bit_overflow (int32_t a, int32_t b)
> +{
> +  int32_t r = (uint32_t) a + (uint32_t) b;
> +  return (a < 0 && b < 0 && r >= 0) || (a >= 0 && b >= 0 && r < 0);
> +}
> +
> +static bool
> +is_add64bit_overflow (int64_t a, int64_t b)
> +{
> +  if (a != (int32_t) a)
> +    return true;
> +  if (b != (int32_t) b)
> +    return true;
> +  return is_add32bit_overflow ((int32_t) a, (int32_t) b);
> +}

Every function should have a header comment explaining the purpose.

> +
> +/* Calculate address of next instruction after BLEZ.  */

And ideally the comment should explain what the function arguments
actually mean.  Some it's OK to skip, e.g. gdbarch and regcache.  But at
a minimum this function should explain INST, PC, and INVERT.

> +
> +static CORE_ADDR
> +mips32_blez_pc (struct gdbarch *gdbarch, struct regcache *regcache,
> +		ULONGEST inst, CORE_ADDR pc, int invert)
> +{
> +  int rs = itype_rs (inst);
> +  int rt = itype_rt (inst);
> +  LONGEST val_rs = regcache_raw_get_signed (regcache, rs);
> +  LONGEST val_rt = regcache_raw_get_signed (regcache, rt);
> +  ULONGEST uval_rs = regcache_raw_get_unsigned (regcache, rs);
> +  ULONGEST uval_rt = regcache_raw_get_unsigned (regcache, rt);
> +  bool taken = false;
> +  int delay_slot_size = 4;
> +
> +  /* BLEZ, BLEZL, BGTZ, BGTZL */

This comment doesn't really help me.  Are you detecting these
instructions?  Handling these functions after already detecting them?

> +  if (rt == 0)
> +    taken = (val_rs <= 0);
> +  else if (is_mipsr6_isa (gdbarch))
> +    {
> +      /* BLEZALC, BGTZALC */
> +      if (rs == 0 && rt != 0)
> +	taken = (val_rt <= 0);
> +      /* BGEZALC, BLTZALC */
> +      else if (rs == rt && rt != 0)
> +	taken = (val_rt >= 0);
> +      /* BGEUC, BLTUC */
> +      else if (rs != rt && rs != 0 && rt != 0)
> +	taken = (uval_rs >= uval_rt);
> +
> +      /* Step through the forbidden slot to avoid repeated exceptions we do
> +	 not currently have access to the BD bit when hitting a breakpoint
> +	 and therefore cannot tell if the breakpoint hit on the branch or the
> +	 forbidden slot.  */
> +      /* delay_slot_size = 0; */

Clearly my lack of MIPS knowledge doesn't help here.  I assume the
commented out code is related to the comment in some way, but it's not
clear to me how exactly.

I'd prefer the comment to say something like: "If we had access to XXX
then we'd know YYY and so we'd set delay_slot_size to 0.  We don't have
access to XXX because ZZZ, so we leave delay_slot_size as is.  This
might case ... problems / This is fine because of reason ...".

> +    }
> +
> +  if (invert)
> +    taken = !taken;
> +
> +  /* Calculate branch target.  */
> +  if (taken)
> +    pc += mips32_relative_offset (inst);
> +  else
> +    pc += delay_slot_size;
> +
> +  return pc;
> +}
>  
>  /* Determine where to set a single step breakpoint while considering
>     branch prediction.  */

> @@ -2451,6 +2690,72 @@ micromips_instruction_is_compact_branch (unsigned short insn)
>      }
>  }
>  
> +
> +
> +/* Return non-zero if the MIPS instruction INSN is a compact branch
> +   or jump. */
> +static enum compact_branch_type

Double space at end of sentence.  Also you're a little inconsistent
about whether you leave a empty line after the comment and before the
function.  I believe the GDB style is to leave a blank line.

> +mips32_instruction_is_compact_branch (struct gdbarch *gdbarch, ULONGEST insn)
> +{
> +  switch (itype_op (insn))
> +    {
> +    /* BC */
> +    case 50:
> +    /* BALC */
> +    case 58:
> +      if (is_mipsr6_isa (gdbarch))
> +	return COMP_BRANCH_UNCOND;
> +      break;
> +    /* BOVC, BEQZALC, BEQC */
> +    case 8:
> +    /* BNVC, BNEZALC, BNEC */
> +    case 24:
> +      if (is_mipsr6_isa (gdbarch))
> +	return COMP_BRANCH_COND;
> +      break;
> +    /* BEQZC, JIC */
> +    case 54:
> +    /* BNEZC, JIALC */
> +    case 62:
> +      if (is_mipsr6_isa (gdbarch))
> +	/* JIC, JIALC are unconditional */
> +	return (itype_rs (insn) == 0) ? COMP_BRANCH_UNCOND : COMP_BRANCH_COND;
> +      break;
> +    /* BLEZC, BGEZC, BGEC */
> +    case 22:
> +    /* BGTZC, BLTZC, BLTC */
> +    case 23:
> +    /* BLEZALC, BGEZALC, BGEUC */
> +    case 6:
> +    /* BGTZALC, BLTZALC, BLTUC */
> +    case 7:
> +      if (is_mipsr6_isa (gdbarch)
> +	  && itype_rt (insn) != 0)
> +	return COMP_BRANCH_COND;
> +      break;
> +    /* BPOSGE32C */
> +    case 1:
> +      if (is_mipsr6_isa (gdbarch)
> +	  && itype_rt (insn) == 0x1d && itype_rs (insn) == 0)
> +	return COMP_BRANCH_COND;
> +    }
> +  return COMP_BRANCH_NONE;
> +}
> +
> +/* Return true if a standard MIPS instruction at ADDR has a branch
> +   forbidden slot (i.e. it is a conditional compact branch instruction).  */
> +
> +static bool
> +mips32_insn_at_pc_has_forbidden_slot (struct gdbarch *gdbarch, CORE_ADDR addr)
> +{
> +  int status;
> +  ULONGEST insn = mips_fetch_instruction (gdbarch, ISA_MIPS, addr, &status);
> +  if (status)
> +    return false;
> +
> +  return mips32_instruction_is_compact_branch (gdbarch, insn) == COMP_BRANCH_COND;
> +}
> +
>  struct mips_frame_cache
>  {
>    CORE_ADDR base;

> @@ -3938,6 +4246,59 @@ mips_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
>  #define LLD_OPCODE 0x34
>  #define SC_OPCODE 0x38
>  #define SCD_OPCODE 0x3c
> +#define LLSC_R6_OPCODE 0x1f
> +#define LL_R6_FUNCT 0x36
> +#define LLE_FUNCT 0x2e
> +#define LLD_R6_FUNCT 0x37
> +#define SC_R6_FUNCT 0x26
> +#define SCE_FUNCT 0x1e
> +#define SCD_R6_FUNCT 0x27
> +
> +static bool
> +is_ll_insn (struct gdbarch *gdbarch, ULONGEST insn)

Missing header comment.

> +{
> +  if (itype_op (insn) == LL_OPCODE
> +      || itype_op (insn) == LLD_OPCODE)
> +    return true;
> +
> +  if (rtype_op (insn) == LLSC_R6_OPCODE
> +      && rtype_funct (insn) == LLE_FUNCT
> +      && (insn & 0x40) == 0)
> +    return true;
> +
> +  /* Handle LL and LLP varieties.  */
> +  if (is_mipsr6_isa (gdbarch)
> +      && rtype_op (insn) == LLSC_R6_OPCODE
> +      && (rtype_funct (insn) == LL_R6_FUNCT
> +	  || rtype_funct (insn) == LLD_R6_FUNCT
> +	  || rtype_funct (insn) == LLE_FUNCT))
> +    return true;
> +
> +  return false;
> +}
> +
> +static bool
> +is_sc_insn (struct gdbarch *gdbarch, ULONGEST insn)

Missing header comment.

> +{
> +  if (itype_op (insn) == SC_OPCODE
> +      || itype_op (insn) == SCD_OPCODE)
> +    return true;
> +
> +  if (rtype_op (insn) == LLSC_R6_OPCODE
> +      && rtype_funct (insn) == SCE_FUNCT
> +      && (insn & 0x40) == 0)
> +    return true;
> +
> +  /* Handle SC and SCP varieties.  */
> +  if (is_mipsr6_isa (gdbarch)
> +      && rtype_op (insn) == LLSC_R6_OPCODE
> +      && (rtype_funct (insn) == SC_R6_FUNCT
> +	  || rtype_funct (insn) == SCD_R6_FUNCT
> +	  || rtype_funct (insn) == SCE_FUNCT))
> +    return true;
> +
> +  return false;
> +}
>  
>  static std::vector<CORE_ADDR>
>  mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)

> @@ -3983,28 +4345,72 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
>  	  return {}; /* fallback to the standard single-step code.  */
>  	case 4: /* BEQ */
>  	case 5: /* BNE */
> -	case 6: /* BLEZ */
> -	case 7: /* BGTZ */
>  	case 20: /* BEQL */
>  	case 21: /* BNEL */
> -	case 22: /* BLEZL */
> -	case 23: /* BGTTL */
> +	case 22: /* BLEZL (BLEZC, BGEZC, BGEC) */
> +	case 23: /* BGTZL (BGTZC, BLTZC, BLTC) */
> +	  is_branch = 1;
> +	  break;
> +	case 6: /* BLEZ (BLEZALC, BGEZALC, BGEUC) */
> +	case 7: /* BGTZ (BGTZALC, BLTZALC, BLTUC) */
> +	  if (is_mipsr6)
> +	    {
> +	      /* BLEZALC, BGTZALC */
> +	      if (itype_rs (insn) == 0 && itype_rt (insn) != 0)
> +		return {}; /* fallback to the standard single-step code.  */
> +	      /* BGEZALC, BLTZALC */
> +	      else if (itype_rs (insn) == itype_rt (insn)
> +		       && itype_rt (insn) != 0)
> +		return {}; /* fallback to the standard single-step code.  */
> +	    }
>  	  is_branch = 1;
>  	  break;
> +	case 8: /* BOVC, BEQZALC, BEQC */
> +	case 24: /* BNVC, BNEZALC, BNEC */
> +	  if (is_mipsr6)
> +	    is_branch = 1;
> +	  break;
> +	case 50: /* BC */
> +	case 58: /* BALC */
> +	  if (is_mipsr6)
> +	    return {}; /* fallback to the standard single-step code.  */
> +	  break;
> +	case 54: /* BEQZC, JIC */
> +	case 62: /* BNEZC, JIALC */
> +	  if (is_mipsr6)
> +	    {
> +	      if (itype_rs (insn) == 0) /* JIC, JIALC */
> +		return {}; /* fallback to the standard single-step code.  */
> +	      else
> +		is_branch = 2; /* Marker for branches with a 21-bit offset.  */
> +	    }
> +	  break;
>  	case 17: /* COP1 */
> -	  is_branch = ((itype_rs (insn) == 9 || itype_rs (insn) == 10)
> -		       && (itype_rt (insn) & 0x2) == 0);
> -	  if (is_branch) /* BC1ANY2F, BC1ANY2T, BC1ANY4F, BC1ANY4T */
> +	  is_branch = ((!is_mipsr6
> +			/* BC1ANY2F, BC1ANY2T, BC1ANY4F, BC1ANY4T */
> +			&& (itype_rs (insn) == 9 || itype_rs (insn) == 10)
> +			&& (itype_rt (insn) & 0x2) == 0)
> +		       /* BZ.df:  010001 110xx */
> +		       || (itype_rs (insn) & 0x18) == 0x18);
> +	  if (is_branch)
>  	    break;
>  	  [[fallthrough]];
>  	case 18: /* COP2 */
>  	case 19: /* COP3 */
> -	  is_branch = (itype_rs (insn) == 8); /* BCzF, BCzFL, BCzT, BCzTL */
> +	  /* BCzF, BCzFL, BCzT, BCzTL, BC*EQZ, BC*NEZ */
> +	  is_branch = ((itype_rs (insn) == 8)
> +		       || (is_mipsr6
> +			   && (itype_rs (insn) == 9
> +			       || itype_rs (insn) == 13)));
>  	  break;
>  	}
>        if (is_branch)

Could you update this condition to:

  if (is_branch != 0)

GDB is (slowly) moving away from using int as a bool replacement.  And
we try to avoid implicit conversion to bool in conditions (e.g. explicit
nullptr comparisons).  Especially now that you've introduced '2' as
another value of 'is_branch' I think the condition should be explicit
about what you're checking for.

>  	{
> -	  branch_bp = loc + mips32_relative_offset (insn) + 4;
> +	  /* Is this a special PC21_S2 branch? */
> +	  if (is_branch == 2)
> +	    branch_bp = loc + mips32_relative_offset21 (insn) + 4;
> +	  else
> +	    branch_bp = loc + mips32_relative_offset (insn) + 4;
>  	  if (last_breakpoint >= 1)
>  	    return {}; /* More than one branch found, fallback to the
>  			  standard single-step code.  */
> @@ -4012,12 +4418,12 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
>  	  last_breakpoint++;
>  	}
>  
> -      if (itype_op (insn) == SC_OPCODE || itype_op (insn) == SCD_OPCODE)
> +      if (is_sc_insn (gdbarch, insn))
>  	break;
>      }
>  
>    /* Assume that the atomic sequence ends with a sc/scd instruction.  */
> -  if (itype_op (insn) != SC_OPCODE && itype_op (insn) != SCD_OPCODE)
> +  if (!is_sc_insn (gdbarch, insn))
>      return {};
>  
>    loc += MIPS_INSN32_SIZE;
> @@ -4231,7 +4637,7 @@ mips_software_single_step (struct regcache *regcache)
>  /* Test whether the PC points to the return instruction at the
>     end of a function.  */
>  
> -static int
> +static bool
>  mips_about_to_return (struct gdbarch *gdbarch, CORE_ADDR pc)
>  {
>    ULONGEST insn;
> @@ -4242,8 +4648,14 @@ mips_about_to_return (struct gdbarch *gdbarch, CORE_ADDR pc)
>    gdb_assert (mips_pc_is_mips (pc));
>  
>    insn = mips_fetch_instruction (gdbarch, ISA_MIPS, pc, NULL);
> -  hint = 0x7c0;
> -  return (insn & ~hint) == 0x3e00008;			/* jr(.hb) $ra */
> +  /* Mask the hint and the jalr/jr bit.  */
> +  hint = 0x7c1;
> +
> +  if (is_mipsr6_isa (gdbarch) && insn == 0xd81f0000) /* jrc $31 */
> +    return true;
> +
> +  /* jr(.hb) $ra and "jalr(.hb) $ra" */
> +  return ((insn & ~hint) == 0x3e00008);
>  }
>  
>  
> @@ -6760,7 +7172,9 @@ mips32_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
>  
>  	  if (high_word != 0x27bd	/* addiu $sp,$sp,offset */
>  	      && high_word != 0x67bd	/* daddiu $sp,$sp,offset */
> -	      && inst != 0x03e00008	/* jr $ra */
> +	      && (inst & ~0x1) != 0x03e00008 /* jr $31 or jalr $0, $31 */
> +	      && (!is_mipsr6_isa (gdbarch)
> +		  || inst != 0xd81f0000) /* jrc $31 */
>  	      && inst != 0x00000000)	/* nop */
>  	    return 0;
>  	}
> @@ -7129,32 +7543,41 @@ mips_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
>      };
>  }
>  
> -/* Return non-zero if the standard MIPS instruction INST has a branch
> +/* Return true if the standard MIPS instruction INST has a branch
>     delay slot (i.e. it is a jump or branch instruction).  This function
>     is based on mips32_next_pc.  */
>  
> -static int
> +static bool
>  mips32_instruction_has_delay_slot (struct gdbarch *gdbarch, ULONGEST inst)
>  {
>    int op;
>    int rs;
>    int rt;
> +  int is_mipsr6 = is_mipsr6_isa (gdbarch);
>  
>    op = itype_op (inst);
>    if ((inst & 0xe0000000) != 0)
>      {
>        rs = itype_rs (inst);
>        rt = itype_rt (inst);
> -      return (is_octeon_bbit_op (op, gdbarch) 
> -	      || op >> 2 == 5	/* BEQL, BNEL, BLEZL, BGTZL: bits 0101xx  */
> -	      || op == 29	/* JALX: bits 011101  */
> +      return (is_octeon_bbit_op (op, gdbarch)
> +	      || (op >> 1 == 10) /* BEQL, BNEL: bits 01010x  */
> +	      || (op >> 1 == 11 && rt == 0) /* BLEZL, BGTZL: bits 01011x  */
> +	      || (!is_mipsr6 && op == 29)	/* JALX: bits 011101  */
>  	      || (op == 17
>  		  && (rs == 8
>  				/* BC1F, BC1FL, BC1T, BC1TL: 010001 01000  */
> -		      || (rs == 9 && (rt & 0x2) == 0)
> +		      || (!is_mipsr6 && rs == 9 && (rt & 0x2) == 0)
>  				/* BC1ANY2F, BC1ANY2T: bits 010001 01001  */
> -		      || (rs == 10 && (rt & 0x2) == 0))));
> +		      || (!is_mipsr6 && rs == 10 && (rt & 0x2) == 0)))
>  				/* BC1ANY4F, BC1ANY4T: bits 010001 01010  */
> +	      || (is_mipsr6
> +		  && ((op == 17
> +		       && (rs == 9  /* BC1EQZ: 010001 01001  */
> +			   || rs == 13))  /* BC1NEZ: 010001 01101  */
> +		      || (op == 18
> +			  && (rs == 9  /* BC2EQZ: 010010 01001  */
> +			      || rs == 13)))));  /* BC2NEZ: 010010 01101  */
>      }
>    else
>      switch (op & 0x07)		/* extract bits 28,27,26  */
> @@ -7173,8 +7596,12 @@ mips32_instruction_has_delay_slot (struct gdbarch *gdbarch, ULONGEST inst)
>  		|| ((rt & 0x1e) == 0x1c && rs == 0));
>  				/* BPOSGE32, BPOSGE64: bits 1110x  */
>  	break;			/* end REGIMM  */
> -      default:			/* J, JAL, BEQ, BNE, BLEZ, BGTZ  */
> -	return 1;
> +	case 6:			/* BLEZ  */
> +	case 7:			/* BGTZ  */
> +	 return (itype_rt (inst) == 0);
> +	 break;
> +      default:			/* J, JAL, BEQ, BNE  */
> +	return true;
>  	break;
>        }
>  }
> @@ -7385,7 +7812,18 @@ mips_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
>  
>       So, we'll use the second solution.  To do this we need to know if
>       the instruction we're trying to set the breakpoint on is in the
> -     branch delay slot.  */
> +     branch delay slot.
> +
> +     A similar problem occurs for breakpoints on forbidden slots where
> +     the trap will be reported for the branch with the BD bit set.
> +     In this case it would be ideal to recover using solution 1 from
> +     above as there is no problem with the branch being skipped
> +     (since the forbidden slot only exists on not-taken branches).
> +     However, the BD bit is not available in all scenarios currently
> +     so instead we move the breakpoint on to the next instruction.
> +     This means that it is not possible to stop on an instruction
> +     that can be in a forbidden slot even if that instruction is
> +     jumped to directly.  */
>  
>    boundary = mips_segment_boundary (bpaddr);
>  
> @@ -7407,6 +7845,12 @@ mips_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
>        prev_addr = bpaddr - 4;
>        if (mips32_insn_at_pc_has_delay_slot (gdbarch, prev_addr))
>  	bpaddr = prev_addr;
> +      /* If the previous instruction has a forbidden slot, we have to
> +	 move the breakpoint to the following instruction to prevent
> +	 breakpoints in forbidden slots being reported as unknown
> +	 traps.  */
> +      else if (mips32_insn_at_pc_has_forbidden_slot (gdbarch, prev_addr))
> +	bpaddr += 4;
>      }
>    else
>      {
> diff --git a/gdb/testsuite/gdb.arch/mips-64-r6.c b/gdb/testsuite/gdb.arch/mips-64-r6.c
> new file mode 100644
> index 00000000000..cd540d1e70c
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/mips-64-r6.c
> @@ -0,0 +1,913 @@
> +/*
> +   Copyright 2006-2024 Free Software Foundation, Inc.

So, for a long time I thought that the date range here was supposed to
be the years that the code was offered to upstream GDB.

But I think I saw something recently that these dates should actually be
the range for when this code was "released" whatever that means, even if
that release wasn't for upstream GDB.

But what I did notice was that this .c file has a different date range
than the corresponding .exp file, which seems weird (but not impossible
I guess).

I think my point here is: can you check these date ranges.  If you've
released these files previously then I guess retain the original release
year, but if this is the first time the file is being released, then you
likely just need 2023 - 2024 here ... maybe?

> +
> +   This file is part of GDB.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +*/
> +
> +#define xstr(s) str(s)
> +#define str(s) #s
> +
> +/* ============ macros from sim/testutils/mips/utils-r6.inc ============= */
> +
> +/* 58 is local label to exit with errcode != 0 */
> +#define fp_assert(a, b) "beq " xstr (a) ", " xstr (b) ", 1f \n\t" \
> +  "nop \n\t" \
> +  "b 58f \n\t" \
> +  "nop \n\t" \
> +  "1: \n\t"
> +
> +/* Clobbers: $4,$6,$7 */
> +#define r6ck_1r(inst, a, ret) \
> +  "li $4, " xstr (a) "    \n\t" \
> +  "li $6, " xstr (ret) "  \n\t" \
> +  xstr (inst) " $7, $4    \n\t" \
> +  fp_assert ($6, $7)
> +
> +/* Clobbers: $4,$6,$7 */
> +#define r6ck_1dr(inst, a, ret) \
> +  "ld $4, " xstr (a) "   \n\t" \
> +  "ld $6, " xstr (ret) " \n\t" \
> +  xstr (inst) " $7, $4   \n\t" \
> +  fp_assert ($6, $7)
> +
> +/* Clobbers: $4,$5,$6,$7 */
> +#define r6ck_2r(inst, a, b, ret) \
> +  "li $4, " xstr (a) "   \n\t" \
> +  "li $5, " xstr (b) "   \n\t" \
> +  "li $6, " xstr (ret) " \n\t" \
> +  xstr (inst) " $7, $4, $5   \n\t" \
> +  fp_assert ($6, $7)
> +
> +/* Clobbers: $4,$5,$6,$7 */
> +#define r6ck_2dr(inst, a, b, ret) \
> +  "ld $4, " xstr (a) "    \n\t" \
> +  "ld $5, " xstr (b) "    \n\t" \
> +  "ld $6, " xstr (ret) "  \n\t" \
> +  xstr (inst) " $7, $4, $5  \n\t" \
> +  fp_assert ($6, $7)
> +
> +/* Clobbers: $4,$5,$6,$7 */
> +#define r6ck_2dr1i(inst, a, b, imm, ret) \
> +  "ld $4, " xstr (a) "      \n\t" \
> +  "ld $5, " xstr (b) "      \n\t" \
> +  "ld $6, " xstr (ret) "    \n\t" \
> +  xstr (inst) " $7, $4, $5, " xstr (imm) "  \n\t" \
> +  fp_assert ($6, $7)
> +
> +/* Clobbers: $4,$6,$7 */
> +#define r6ck_1r1i(inst, a, imm, ret) \
> +  "li $4, " xstr (a) "      \n\t" \
> +  "li $6, " xstr (ret) "    \n\t" \
> +  xstr (inst) " $7, $4, " xstr (imm) "  \n\t" \
> +  fp_assert ($6, $7)
> +
> +/* Clobbers: $4,$6,$7 */
> +#define r6ck_1dr1i(inst, a, imm, ret) \
> +  "ld $4, " xstr (a) "     \n\t" \
> +  "ld $6, " xstr (ret) "   \n\t" \
> +  xstr (inst) " $7, $4, " xstr (imm) "  \n\t" \
> +  fp_assert ($6, $7)
> +
> +/* Clobbers: $4,$6 */
> +#define r6ck_0dr1i(inst, a, imm, ret) \
> +  "ld $4, " xstr (a) "     \n\t" \
> +  "ld $6, " xstr (ret) "   \n\t" \
> +  xstr (inst) " $4, $4, " xstr (imm) "   \n\t" \
> +  fp_assert ($6, $4)
> +
> +/* Clobbers: $4,$5,$6,$7 */
> +#define r6ck_2r1i(inst, a, b, imm, ret) \
> +  "li $4, " xstr (a) "     \n\t" \
> +  "li $5, " xstr (b) "     \n\t" \
> +  "li $6, " xstr (ret) "   \n\t" \
> +  xstr (inst) " $7, $4, $5, " xstr (imm) "   \n\t" \
> +  fp_assert ($6, $7)
> +
> +/* Clobbers: $4,$5,$6,$7,$8,$f2,$f4,$f6 */
> +#define r6ck_3s(inst, a, b, c, ret) \
> +  "li $4, " xstr (a) "     \n\t" \
> +  "li $5, " xstr (b) "     \n\t" \
> +  "li $6, " xstr (c) "     \n\t" \
> +  "li $7, " xstr (ret) "   \n\t" \
> +  "mtc1 $4, $f2           \n\t" \
> +  "mtc1 $5, $f4           \n\t" \
> +  "mtc1 $6, $f6           \n\t" \
> +  xstr (inst) " $f2, $f4, $f6       \n\t" \
> +  "mfc1 $8, $f2           \n\t" \
> +  fp_assert ($7, $8)
> +
> +/* Clobbers: $4,$5,$6,$7,$f2,$f4 */
> +#define r6ck_2s(inst, a, b, ret) \
> +  "li $4, " xstr (a) "       \n\t" \
> +  "li $5, " xstr (b) "       \n\t" \
> +  "li $6, " xstr (ret) "     \n\t" \
> +  "mtc1 $4, $f2             \n\t" \
> +  "mtc1 $5, $f4             \n\t" \
> +  xstr (inst) " $f2, $f4     \n\t" \
> +  "mfc1 $7, $f2             \n\t" \
> +  fp_assert ($6, $7)
> +
> +/* Clobbers: $4,$5,$6,$7,$8,$9,$10,$f2,$f4 */
> +#define r6ck_2d(inst, a, b, ret) \
> +  ".data                  \n\t" \
> +  "1: .dword " xstr (a) "    \n\t" \
> +  "2: .dword " xstr (b) "    \n\t" \
> +  "3: .dword " xstr (ret) "  \n\t" \
> +  ".text                   \n\t" \
> +  "dla $4, 1b              \n\t" \
> +  "dla $5, 2b              \n\t" \
> +  "dla $6, 3b              \n\t" \
> +  "ldc1 $f2, 0($4)        \n\t" \
> +  "ldc1 $f4, 0($5)        \n\t" \
> +  "lw $7, 0($6)           \n\t" \
> +  "lw $8, 4($6)           \n\t" \
> +  xstr (inst) " $f2, $f4   \n\t" \
> +  "mfhc1 $9, $f2          \n\t" \
> +  "mfc1 $10, $f2          \n\t" \
> +  fp_assert ($7, $9) \
> +  fp_assert ($8, $10)
> +
> +/* Clobbers: $2,$4,$5,$6,$7,$8,$9,$10,$f2,$f4,$f6 */
> +#define r6ck_3d(inst, a, b, c, ret) \
> +  ".data                                \n\t" \
> +  "1: .dword " xstr (a) "                  \n\t" \
> +  "2: .dword " xstr (b) "                  \n\t" \
> +  "3: .dword " xstr (c) "                  \n\t" \
> +  "4: .dword " xstr (ret) "                \n\t" \
> +  ".text                                \n\t" \
> +  "dla $4, 1b                            \n\t" \
> +  "dla $5, 2b                            \n\t" \
> +  "dla $6, 3b                            \n\t" \
> +  "dla $2, 4b                            \n\t" \
> +  "ldc1 $f2, 0($4)                      \n\t" \
> +  "ldc1 $f4, 0($5)                      \n\t" \
> +  "ldc1 $f6, 0($6)                      \n\t" \
> +  "lw $7, 0($2)                         \n\t" \
> +  "lw $8, 4($2)                         \n\t" \
> +  xstr (inst) " $f2, $f4, $f6            \n\t" \
> +  "mfhc1 $9, $f2                        \n\t" \
> +  "mfc1 $10, $f2                        \n\t" \
> +  fp_assert ($7, $9) \
> +  fp_assert ($8, $10)
> +
> +
> +/* ============ macros from sim/testutils/mips/testutils.inc ============= */
> +
> +/* Put value 'val' into register 'reg'
> + * Clobbers: None                              */
> +#define load32(reg, val) \
> +  "li  " xstr (reg) ", " xstr (val) "     \n\t"
> +
> +/* Check whether two registers contain the same value
> + *  Clobbers: None                                     */
> +#define checkreg(reg, expreg) \
> +  ".set push         \n\t" \
> +  ".set noat         \n\t" \
> +  ".set noreorder    \n\t" \
> +  "beq "  xstr (expreg) ", " xstr (reg) ", 901f    \n\t" \
> +  "nop               \n\t" \
> +  "b 58f              \n\t" \
> +  "nop                \n\t" \
> +  "901:                   \n\t" \
> +  ".set pop           \n\t"
> +
> +/* Check if register 'reg' contains value 'val'.
> + * Clobbers: $1                                  */
> +#define check32(reg, val) \
> +  ".set push         \n\t" \
> +  ".set noat         \n\t" \
> +  load32 ($1, val) \
> +  checkreg (reg, $1) \
> +  ".set pop          \n\t"
> +
> +/* Checkpair based on endianess
> + * Clobbers: $1                 */
> +#define checkpair_xendian(lo, hi, base, ec, w) \
> +  ".set noat               \n\t" \
> +  "lw   $1, " xstr (ec) "   \n\t" \
> +  "andi $1, $1, 0x1        \n\t" \
> +  "beqz  $1, 2f            \n\t" \
> +  ".set at                 \n\t" \
> +  "1:                          \n\t" \
> +  checkpair_be_##w (lo, hi, base) \
> +  "b 3f                    \n\t" \
> +  "nop                     \n\t" \
> +  "2:                          \n\t" \
> +  checkpair_le_##w (lo, hi, base) \
> +  "3:                          \n\t"
> +
> +
> +/* Check hi-lo register pair against data stored at base+o1 and base+o2
> + * Clobbers: $1 - $5                              */
> +#define  checkpair(lo, hi, base, w, o1, o2) \
> +  "move  $2, " xstr (lo) "   \n\t" \
> +  "move  $3, " xstr (hi) "   \n\t" \
> +  ".set noat                \n\t" \
> +  "dla   $1, " xstr (base) "  \n\t" \
> +  "l" xstr (w) " $4, " xstr (o1) "($1)  \n\t" \
> +  "l" xstr (w)  " $5, " xstr (o2) "($1)  \n\t" \
> +  ".set at                  \n\t" \
> +  checkreg ($2, $4) \
> +  checkreg ($3, $5)
> +
> +#define checkpair_le_d(lo, hi, base) \
> +  checkpair (lo, hi, base, w, 0, 4)
> +
> +#define checkpair_be_d(lo, hi, base) \
> +  checkpair (lo, hi, base, w, 4, 0)
> +
> +
> +#define checkpair_le_q(lo, hi, base) \
> +  checkpair (lo, hi, base, d, 0, 8)
> +
> +#define checkpair_be_q(lo, hi, base) \
> +  checkpair (lo, hi, base, d, 8, 0)
> +
> +#define checkpair_qword(lo, hi, base, oe) \
> +  checkpair_xendian (lo, hi, base, oe, q)
> +
> +#define checkpair_dword(lo, hi, base, oe) \
> +  checkpair_xendian (lo, hi, base, oe, d)
> +
> +void
> +abort (void);
> +
> +int
> +test_r6_branch(void)
> +{
> +/* Using volatile to prevent certain optimizations which could cause
> + * instruction deletion.
> + * 'err' identifies instruction which (eventually) caused error.
> + * (err == 0) ==> all instructions executed successfully */
> +
> +  volatile int err = -1;
> +  volatile int a14 = 0xffffffff;
> +  volatile int a13 = 0x123;
> +  volatile int a12 = 0x45;
> +  volatile int a7 = 0x45;
> +  volatile int a8 = 0xfffffffe;
> +  volatile int a9 = 2147483647;
> +  volatile int a11 = 0;
> +  volatile int a10 = 0;
> +
> +  asm (
> +  ".set push             \n\t" /* create new scope for asm configuration */
> +  ".set noreorder        \n\t" /* don't allow reordering of instructions */
> +  "li %[err], 1                  \n\t"
> +  "bovc %[a12], %[a13], Lfail    \n\t" /* BOVC */
> +  "nop                           \n\t"
> +  "bovc %[a9], %[a13], L2        \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L2:                           \n\t"
> +  "li %[err], 2                  \n\t"
> +  "bnvc %[a9], %[a13], Lfail     \n\t" /* BNVC */
> +  "nop                           \n\t"
> +  "bnvc %[a12], %[a13], L3       \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L3:                           \n\t"
> +  "li %[err], 3                  \n\t"
> +  "beqc %[a12], %[a13], Lfail    \n\t" /* BEQC */
> +  "nop                           \n\t"
> +  "beqc %[a12], %[a7], L4        \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L4:                           \n\t"
> +  "li %[err], 4                  \n\t"
> +  "bnec %[a12], %[a7], Lfail     \n\t" /* BNEC */
> +  "nop                           \n\t"
> +  "bnec %[a12], %[a13], L5       \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L5:                           \n\t"
> +  "li %[err], 5                  \n\t"
> +  "bltc %[a13], %[a12], Lfail    \n\t" /* BLTC */
> +  "nop                           \n\t"
> +  "bltc %[a12], %[a13], L6       \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L6:                           \n\t"
> +  "L7:                           \n\t"
> +  "li %[err], 7                  \n\t"
> +  "bgec %[a12], %[a13], Lfail    \n\t" /* BGEC */
> +  "nop                           \n\t"
> +  "bgec %[a13], %[a12], L8       \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L8:                           \n\t"
> +  "L9:                           \n\t"
> +  "li %[err], 9                  \n\t"
> +  "bltuc %[a14], %[a13], Lfail   \n\t" /* BLTUC */
> +  "nop                           \n\t"
> +  "bltuc %[a8], %[a14], L10      \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L10:                          \n\t"
> +  "L11:                          \n\t"
> +  "li %[err], 11                 \n\t"
> +  "bgeuc %[a13], %[a14], Lfail   \n\t" /* BGEUC */
> +  "nop                           \n\t"
> +  "bgeuc %[a14], %[a8], L12      \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L12:                          \n\t"
> +  "L13:                          \n\t"
> +  "li %[err], 13                 \n\t"
> +  "bltzc %[a13], Lfail           \n\t" /* BLTZC */
> +  "nop                           \n\t"
> +  "bltzc %[a11], Lfail           \n\t"
> +  "nop                           \n\t"
> +  "bltzc %[a14], L14             \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L14:                          \n\t"
> +  "li %[err], 14                 \n\t"
> +  "blezc %[a13], Lfail           \n\t" /* BLEZC */
> +  "nop                           \n\t"
> +  "blezc %[a11], L145            \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L145:                         \n\t"
> +  "blezc %[a14], L15             \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L15:                          \n\t"
> +  "li %[err], 15                 \n\t"
> +  "bgezc %[a8], Lfail            \n\t" /* BGEZC */
> +  "nop                           \n\t"
> +  "bgezc %[a11], L155            \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L155:                         \n\t"
> +  "bgezc %[a13], L16             \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L16:                          \n\t"
> +  "li %[err], 16                 \n\t"
> +  "bgtzc %[a8], Lfail            \n\t" /* BGTZC */
> +  "nop                           \n\t"
> +  "bgtzc %[a11], Lfail           \n\t"
> +  "nop                           \n\t"
> +  "bgtzc %[a13], L17             \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "li %[a10], 0                  \n\t"
> +  "L17:                          \n\t"
> +  "li %[err], 17                 \n\t"
> +  "blezalc %[a12], Lfail         \n\t" /* BLEZALC */
> +  "nop                           \n\t"
> +  "blezalc %[a11], Lret          \n\t"
> +  "li %[a10], 1                  \n\t"
> +  "beqzc %[a10], L175            \n\t" /* BEQZC */
> +  "nop                           \n\t"
> +  "li %[err], 8531               \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L175:                         \n\t"
> +  "li %[err], 23531              \n\t"
> +  "blezalc %[a14], Lret          \n\t"
> +  "li %[a10], 1                  \n\t"
> +  "beqzc %[a10], L18             \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L18:                          \n\t"
> +  "li %[err], 18                 \n\t"
> +  "bgezalc %[a14], Lfail         \n\t" /* BGEZALC */
> +  "nop                           \n\t"
> +  "bgezalc %[a11], Lret          \n\t"
> +  "li %[a10], 1                  \n\t"
> +  "beqzc %[a10], L185            \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L185:                         \n\t"
> +  "bgezalc %[a12], Lret          \n\t"
> +  "li %[a10], 1                  \n\t"
> +  "beqzc %[a10], L19             \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L19:                          \n\t"
> +  "li %[err], 19                 \n\t"
> +  "bgtzalc %[a14], Lfail         \n\t" /* BGTZALC */
> +  "nop                           \n\t"
> +  "bgtzalc %[a11], Lfail         \n\t"
> +  "nop                           \n\t"
> +  "bgtzalc %[a12], Lret          \n\t"
> +  "li %[a10], 1                  \n\t"
> +  "beqzc %[a10], L20             \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L20:                          \n\t"
> +  "li %[err], 20                 \n\t"
> +  "bltzalc %[a12], Lfail         \n\t" /* BLTZALC */
> +  "nop                           \n\t"
> +  "bltzalc %[a11], Lfail         \n\t"
> +  "nop                           \n\t"
> +  "bltzalc %[a14], Lret          \n\t"
> +  "li %[a10], 1                  \n\t"
> +  "beqzc %[a10], L21             \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L21:                          \n\t"
> +  "li %[err], 21                 \n\t"
> +  "bc L22                        \n\t" /* BC */
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L22:                          \n\t"
> +  "li %[err], 22                 \n\t"
> +  "balc Lret                     \n\t" /* BALC */
> +  "li %[a10], 1                  \n\t"
> +  "beqzc %[a10], L23             \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L23:                          \n\t"
> +  "li %[err], 23                 \n\t"
> +  "jal GetPC                     \n\t" /* JAL */
> +  "nop                           \n\t"
> +  "jic $6, 4                     \n\t" /* JIC */
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L24:                          \n\t"
> +  "li %[err], 24                 \n\t"
> +  "li %[a10], 1                  \n\t"
> +  "jal GetPC                     \n\t"
> +  "nop                           \n\t"
> +  "jialc $6, 20                  \n\t" /* JIALC */
> +  "nop                           \n\t"
> +  "beqzc %[a10], L25             \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "LJIALCRET:                    \n\t"
> +  "li %[a10], 0                  \n\t"
> +  "jr $31                        \n\t" /* JR */
> +  "nop                           \n\t"
> +  "L25:                          \n\t"
> +  "li %[err], 25                 \n\t"
> +  "jal GetPC                     \n\t"
> +  "nop                           \n\t"
> +  "move %[a11], $6               \n\t"
> +  "nal                           \n\t"
> +  "nop                           \n\t"
> +  "addiu %[a11], 12              \n\t" /* ADDIU */
> +  "beqc %[a11], $31, L26         \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "L26:                          \n\t"
> +  "li %[err], 26                 \n\t"
> +  "balc Lret                     \n\t"
> +  "li %[a10], 1                  \n\t"
> +  "beqzc %[a10], Lend            \n\t"
> +  "nop                           \n\t"
> +  "b Lfail                       \n\t"
> +  "nop                           \n\t"
> +  "Lret:                         \n\t"
> +  "li %[a10], 0                  \n\t"
> +  "daddiu $31, 4                 \n\t" /* DADDIU */
> +  "jrc $31                       \n\t" /* JRC */
> +  "nop                           \n\t"
> +  "GetPC:                        \n\t"
> +  "move $6, $31                  \n\t"
> +  "jr $31                        \n\t"
> +  "Lend:                         \n\t"
> +  "li %[err], 0                  \n\t"
> +  "Lfail:                        \n\t"
> +  ".set pop                      \n\t" /* Restore previous config */
> +  : [err] "+r"(err), [a14] "+r"(a14), [a13] "+r"(a13), [a12] "+r"(a12),
> +    [a7] "+r"(a7), [a8] "+r"(a8), [a9] "+r"(a9), [a10] "+r"(a10), [a11] "+r"(a11)
> +  : /* inputs */
> +  : "$31", "$6" /* clobbers */
> +  );
> +
> +  return err;
> +}
> +
> +int
> +test_r6_forbidden(void)

Test should follow GNU coding standard where possible, so space after
the function name before the parameter list.  This applies in a bunch of
places in this file.

> +{
> +  volatile int err = -1;
> +  volatile int a4 = 0;
> +  volatile int a2 = 0;
> +  volatile int a1 = 0;
> +
> +  asm (
> +  ".set push                         \n\t"
> +  ".set noreorder                    \n\t"
> +/* Test if FS is ignored when branch is taken */
> +  "li %[err], 1                      \n\t"
> +  "li %[a4], 0                       \n\t"
> +  "beqzalc %[a4], L41                \n\t"
> +  "li %[err], -85                    \n\t"
> +  "L42:                              \n\t"
> +  "b Lfail2                          \n\t"
> +  "nop                               \n\t"
> +  "L41:                              \n\t"
> +  "blez %[err], Lfail2               \n\t"
> +/* Test if FS is used when branch is not taken */
> +  "li %[err], 2                      \n\t"
> +  "li %[a4], 1                       \n\t"
> +  "blezc %[a4], L43                  \n\t"
> +  "addiu %[a4], %[a4], 1             \n\t"
> +  "li %[a2], 2                       \n\t"
> +  "beq %[a4], %[a2], L44             \n\t"
> +  "nop                               \n\t"
> +  "L43:                              \n\t"
> +  "nop                               \n\t"
> +  "b Lfail2                          \n\t"
> +  "nop                               \n\t"
> +  "L44:                              \n\t"
> +/* Test if FS causes an error when it contains a branch */
> +  "li %[err], 3                      \n\t"
> +  "li %[a4], 3                       \n\t"
> +  "beqzalc %[a4], Lfail2             \n\t"
> +/* Note: bc L45 here causes SegFault: Illegal instruction which is OK. */

Double space at end of sentence.

> diff --git a/gdb/testsuite/gdb.arch/mips-64-r6.exp b/gdb/testsuite/gdb.arch/mips-64-r6.exp
> new file mode 100644
> index 00000000000..cddf9c19574
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/mips-64-r6.exp
> @@ -0,0 +1,88 @@
> +# Copyright (C) 2012-2023 Free Software Foundation, Inc.

Date range needs updating to 2024.  Also this is the range that doesn't
match the corresponding .c file ... which might be fine if that's
actually true.

> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, see <http://www.gnu.org/licenses/>.
> +
> +# Test mips release 6 patch.
> +
> +require {istarget "*mips*"}
> +
> +standard_testfile .c

No need for the '.c' here -- it's the default value.

> +
> +set tests { test_r6_branch test_r6_forbidden test_r6_64 test_r6
> +test_r6_fpu test_r6_llsc_dp test_r6_llsc_wp }
> +
> +proc single_step {} {

All procs should have a comment, but especially in this case with the
set of return values being used.

> +  global gdb_prompt
> +
> +  send_gdb "si\n"
> +  gdb_expect {

I wonder if we could switch to gdb_test_multiple here, which catches a
bunch of additional error outputs?

> +    -re "$gdb_prompt \$" {
> +      return 1
> +    }
> +    -re ".*Breakpoint.*test_.*" {
> +      return 2
> +    }
> +    -re ".*exited normally.*" {
> +      return 3
> +    }

In some embedded situations inferior's never really exit, but instead
just enter a spin loop.  As such, unless the test specifically requires
a test for the inferior exiting, I always think it's better to place a
breakpoint before the test exits and then stop the test once we hit that
breakpoint.

Maybe this concern doesn't apply for this MIPS variant?  But it
shouldn't be a difficult change.

> +    -re ".*The program is not being run.*" {
> +      return 4
> +    }
> +  }
> +  return 0
> +}
> +
> +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable { debug }] != "" } {
> +  fail "compilation"
> +  return
> +}
> +
> +clean_restart $binfile

The gdb_compile and clean_restart should be replaced with a single
prepare_for_testing call.


> +if { ![runto_main] } {
> +  return
> +}
> +
> +# put breakpoint on each test-function
> +foreach func $tests {
> +  gdb_test "break $func" "Breakpoint.*at.*" "set breakpoint on $func"

You can probably use gdb_breakpoint here.

But, do you even need these breakpoints?  Maybe I'm missing something,
but you just seem to runto_main, and then step through everything until
the inferior exits.

That said, you might be interested to read
gdb.base/step-through-epilogue.exp, which does a similar "step until we
reach some stopping point" type testing.  In that case the whole
stepping logic is done in a single gdb_test_multiple.  You could do
something similar:

  1. Setup all the breakpoints as you currently do,

  2. Continue until you hit one of these breakpoints,

  3. Step until you return to main,

  4. If we have more tests to run then goto #2, otherwise we're done.

> +}
> +
> +set rt [single_step]
> +if { $rt == 0 } {
> +  fail "single_step returned $rt"
> +  return
> +}
> +
> +set start [timestamp]
> +global timeout

Don't read timeout directly.  Use the result of get_largest_timeout.

> +while { $rt != 0 && [timestamp] - $start < 3*$timeout } {
> +
> +  if { $rt == 3 } {
> +    pass "all tests are fine"
> +    return
> +  } elseif { $rt == 4 } {
> +    fail "Program exited abnormally"
> +    return
> +  }
> +#  elseif { $rt == 1 || $rt == 2 } { # 1->got gdb_prompt ; 2->hit breakpoint
> +#    verbose -log "\[DEBUG_\] 'single_step' returned rt=$rt ; timeout = $timeout"
> +#  }

Remove comment out code please.

> +
> +  set rt [single_step]
> +}
> +
> +if {$rt == 0 } {
> +  fail "stepi"
> +}

It would be good practice to use the same string for all the pass/fail
calls within the while loop, and in this final trailing check, these
really are the same one test, which either passes or fails.

Thanks,
Andrew


^ permalink raw reply	[relevance 0%]

* [PATCH v3 2/2] [gdb/testsuite] Add gdb.dwarf2/dw2-epilogue-begin-2.exp
  @ 2024-04-05 15:10  4% ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-04-05 15:10 UTC (permalink / raw)
  To: gdb-patches

Test-case gdb.dwarf2/dw2-epilogue-begin.exp has an end_sequence at 0x4004ff:
...
File name                Line number    Starting address    View    Stmt

dw2-epilogue-begin.c              20            0x4004b7               x
dw2-epilogue-begin.c              27            0x4004be               x
dw2-epilogue-begin.c              34            0x4004d0               x
dw2-epilogue-begin.c              37            0x4004de               x
dw2-epilogue-begin.c              38            0x4004ec               x
dw2-epilogue-begin.c              43            0x4004ef               x
dw2-epilogue-begin.c              47            0x4004fa               x
dw2-epilogue-begin.c              50            0x4004ff               x
dw2-epilogue-begin.c               -            0x4004ff
...
which is before the actual exclusive end of the main function at 0x40050d:
...
00000000004004ff <main_epilogue>:
  4004ff:       c6 05 1b 1b 00 00 0a    movb   $0xa,0x1b1b(%rip)
  400506:       b8 00 00 00 00          mov    $0x0,%eax
  40050b:       5d                      pop    %rbp
  40050c:       c3                      ret
...

This triggers the corner case in find_epilogue_using_linetable that
the call to std::lower_bound returns the "not found" case.

However, if we handle the corner case explicitly by returning something
incorrect:
...
+      if (it == linetable->item + linetable->nitems)
+	return {};
...
the test-case still passes.

Fix this by:
- rearranging the test-case to move the watch function to after the main
  function, and
- reworking the test-case into two variants:
  - end_sequence at the watch function end (the correct version), and
  - end_sequence before the watch function end (triggered the corner-case).

Tested on x86_64-linux.
---
 .../gdb.dwarf2/dw2-epilogue-begin-2.exp       |  20 ++
 gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c |  28 +--
 .../gdb.dwarf2/dw2-epilogue-begin.exp         | 156 +-------------
 .../gdb.dwarf2/dw2-epilogue-begin.exp.tcl     | 191 ++++++++++++++++++
 4 files changed, 229 insertions(+), 166 deletions(-)
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin-2.exp
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl

diff --git a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin-2.exp
new file mode 100644
index 00000000000..64cd85644e0
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin-2.exp
@@ -0,0 +1,20 @@
+# Copyright 2022-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile dw2-epilogue-begin.c dw2-epilogue-begin.S
+
+set early_end_sequence 1
+
+source $srcdir/$subdir/dw2-epilogue-begin.exp.tcl
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c
index 4ff445cf37d..2fcc4807904 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c
+++ b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c
@@ -22,6 +22,20 @@ trivial (void)
 
 char global;
 
+extern void watch (void);
+
+int
+main (void)
+{							/* main prologue */
+  asm ("main_label: .global main_label");
+  global = 0;
+  asm ("main_fun_call: .global main_fun_call");
+  watch ();						/* main function call */
+  asm ("main_epilogue: .global main_epilogue");
+  global = 10;
+  return 0;						/* main end */
+}
+
 void
 watch (void)
 {							/* watch start */
@@ -36,16 +50,6 @@ watch (void)
   asm ("mov $0x2, %rax");
   local = 2;						/* watch reassign */
   asm ("watch_end: .global watch_end");			/* watch end */
-}
-
-int
-main (void)
-{							/* main prologue */
-  asm ("main_label: .global main_label");
-  global = 0;
-  asm ("main_fun_call: .global main_fun_call");
-  watch ();						/* main function call */
-  asm ("main_epilogue: .global main_epilogue");
-  global = 10;
-  return 0;						/* main end */
+  local = 3;
+  asm ("watch_early_end_sequence: .global watch_early_end_sequence");
 }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
index f646e23da62..9552dd764dd 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
@@ -13,161 +13,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Check that GDB can honor the epilogue_begin flag the compiler can place
-# in the line-table data.
-# We test 2 things: 1. that a software watchpoint triggered in an epilogue
-# is correctly ignored
-# 2. that GDB can mark the same line as both prologue and epilogue
-
-load_lib dwarf.exp
-
-# This test can only be run on targets which support DWARF-2 and use gas.
-require dwarf2_support
-# restricted to x86 to make it simpler to follow a variable
-require is_x86_64_m64_target
-
 standard_testfile .c .S
 
-set trivial_line [gdb_get_line_number "trivial function"]
-set main_prologue [gdb_get_line_number "main prologue"]
-set main_epilogue [gdb_get_line_number "main end"]
-set watch_start_line [gdb_get_line_number "watch start"]
-
-set asm_file [standard_output_file $srcfile2]
-
-# The producer will be set to clang because at the time of writing
-# we only care about epilogues if the producer is clang.  When the
-# producer is GCC, variables use CFA locations, so watchpoints can
-# continue working even on epilogues.
-Dwarf::assemble $asm_file {
-    global srcdir subdir srcfile srcfile2
-    global trivial_line main_prologue main_epilogue watch_start_line
-    declare_labels lines_label
-
-    get_func_info main
-    get_func_info trivial
-    get_func_info watch
-
-    cu {} {
-	compile_unit {
-	    {language @DW_LANG_C}
-	    {name dw2-prologue-end.c}
-	    {stmt_list ${lines_label} DW_FORM_sec_offset}
-	    {producer "clang version 17.0.1"}
-	} {
-	    declare_labels char_label
-
-	    char_label: base_type {
-		{name char}
-		{encoding @DW_ATE_signed}
-		{byte_size 1 DW_FORM_sdata}
-	    }
-
-	    subprogram {
-		{external 1 flag}
-		{name trivial}
-		{low_pc $trivial_start addr}
-		{high_pc "$trivial_start + $trivial_len" addr}
-	    }
-	    subprogram {
-		{external 1 flag}
-		{name watch}
-		{low_pc $watch_start addr}
-		{high_pc "$watch_start + $watch_len" addr}
-	    } {
-		DW_TAG_variable {
-		    {name local}
-		    {type :$char_label}
-		    {DW_AT_location {DW_OP_reg0} SPECIAL_expr}
-		}
-	    }
-	    subprogram {
-		{external 1 flag}
-		{name main}
-		{low_pc $main_start addr}
-		{high_pc "$main_start + $main_len" addr}
-	    }
-	}
-    }
-
-    lines {version 5} lines_label {
-	set diridx [include_dir "${srcdir}/${subdir}"]
-	file_name "$srcfile" $diridx
-
-	program {
-	    DW_LNS_set_file $diridx
-	    DW_LNE_set_address $trivial_start
-	    line $trivial_line
-	    DW_LNS_set_prologue_end
-	    DW_LNS_set_epilogue_begin
-	    DW_LNS_copy
-
-	    DW_LNE_set_address watch
-	    line $watch_start_line
-	    DW_LNS_copy
-
-	    DW_LNE_set_address watch_start
-	    line [gdb_get_line_number "watch assign"]
-	    DW_LNS_set_prologue_end
-	    DW_LNS_copy
-
-	    DW_LNE_set_address watch_reassign
-	    line [gdb_get_line_number "watch reassign"]
-	    DW_LNS_set_epilogue_begin
-	    DW_LNS_copy
-
-	    DW_LNE_set_address watch_end
-	    line [gdb_get_line_number "watch end"]
-	    DW_LNS_copy
-
-	    DW_LNE_set_address $main_start
-	    line $main_prologue
-	    DW_LNS_set_prologue_end
-	    DW_LNS_copy
-
-	    DW_LNE_set_address main_fun_call
-	    line [gdb_get_line_number "main function call"]
-	    DW_LNS_copy
-
-	    DW_LNE_set_address main_epilogue
-	    line $main_epilogue
-	    DW_LNS_set_epilogue_begin
-	    DW_LNS_copy
-
-	    DW_LNE_end_sequence
-	}
-    }
-}
-
-if { [prepare_for_testing "failed to prepare" ${testfile} \
-	  [list $srcfile $asm_file] {nodebug}] } {
-    return -1
-}
-
-if ![runto_main] {
-    return -1
-}
-
-# Moving to the scope with a local variable.
-gdb_breakpoint $watch_start_line
-gdb_continue_to_breakpoint "continuing to function" ".*"
-gdb_test "next" "local = 2.*" "stepping to epilogue"
-
-# Forcing software watchpoints because hardware ones don't care if we
-# are in the epilogue or not.
-gdb_test_no_output "set can-use-hw-watchpoints 0"
+set early_end_sequence 0
 
-# Test that the software watchpoint will not trigger in this case
-gdb_test "watch local" "\[W|w\]atchpoint .: local" "set watchpoint"
-gdb_test "continue" ".*\[W|w\]atchpoint . deleted.*" \
-    "confirm watchpoint doesn't trigger"
+source $srcdir/$subdir/dw2-epilogue-begin.exp.tcl
 
-# First we test that the trivial function has a line with both a prologue
-# and an epilogue. Do this by finding a line that has 3 Y columns
-set sep "\[ \t\]"
-set hex_number "0x\[0-9a-f\]+"
-gdb_test_multiple "maint info line-table" "test epilogue in linetable" -lbl {
-    -re "\[0-9\]$sep+$trivial_line$sep+$hex_number$sep+$hex_number$sep+Y$sep+Y$sep+Y" {
-	pass $gdb_test_name
-    }
-}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl
new file mode 100644
index 00000000000..18282e884e4
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl
@@ -0,0 +1,191 @@
+# Copyright 2022-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that GDB can honor the epilogue_begin flag the compiler can place
+# in the line-table data.
+# We test 2 things: 1. that a software watchpoint triggered in an epilogue
+# is correctly ignored
+# 2. that GDB can mark the same line as both prologue and epilogue
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+require dwarf2_support
+# restricted to x86 to make it simpler to follow a variable
+require is_x86_64_m64_target
+
+set trivial_line [gdb_get_line_number "trivial function"]
+set main_prologue [gdb_get_line_number "main prologue"]
+set main_epilogue [gdb_get_line_number "main end"]
+set watch_start_line [gdb_get_line_number "watch start"]
+
+set asm_file [standard_output_file $srcfile2]
+
+# The producer will be set to clang because at the time of writing
+# we only care about epilogues if the producer is clang.  When the
+# producer is GCC, variables use CFA locations, so watchpoints can
+# continue working even on epilogues.
+Dwarf::assemble $asm_file {
+    global srcdir subdir srcfile srcfile2
+    global trivial_line main_prologue main_epilogue watch_start_line
+    declare_labels lines_label
+
+    get_func_info main
+    get_func_info trivial
+    get_func_info watch
+
+    if { $::early_end_sequence == 1 } {
+	set watch_end_sequence watch_early_end_sequence
+    } else {
+	set watch_end_sequence $watch_end
+    }
+
+    cu {} {
+	compile_unit {
+	    {language @DW_LANG_C}
+	    {name dw2-prologue-end.c}
+	    {stmt_list ${lines_label} DW_FORM_sec_offset}
+	    {producer "clang version 17.0.1"}
+	} {
+	    declare_labels char_label
+
+	    char_label: base_type {
+		{name char}
+		{encoding @DW_ATE_signed}
+		{byte_size 1 DW_FORM_sdata}
+	    }
+
+	    subprogram {
+		{external 1 flag}
+		{name trivial}
+		{low_pc $trivial_start addr}
+		{high_pc "$trivial_start + $trivial_len" addr}
+	    }
+	    subprogram {
+		{external 1 flag}
+		{name watch}
+		{low_pc $watch_start addr}
+		{high_pc "$watch_start + $watch_len" addr}
+	    } {
+		DW_TAG_variable {
+		    {name local}
+		    {type :$char_label}
+		    {DW_AT_location {DW_OP_reg0} SPECIAL_expr}
+		}
+	    }
+	    subprogram {
+		{external 1 flag}
+		{name main}
+		{low_pc $main_start addr}
+		{high_pc "$main_start + $main_len" addr}
+	    }
+	}
+    }
+
+    lines {version 5} lines_label {
+	set diridx [include_dir "${srcdir}/${subdir}"]
+	file_name "$srcfile" $diridx
+
+	program {
+	    DW_LNS_set_file $diridx
+
+	    DW_LNE_set_address $trivial_start
+	    line $trivial_line
+	    DW_LNS_set_prologue_end
+	    DW_LNS_set_epilogue_begin
+	    DW_LNS_copy
+
+	    DW_LNE_set_address $trivial_end
+	    DW_LNE_end_sequence
+
+
+	    DW_LNS_set_file $diridx
+
+	    DW_LNE_set_address $main_start
+	    line $main_prologue
+	    DW_LNS_set_prologue_end
+	    DW_LNS_copy
+
+	    DW_LNE_set_address main_fun_call
+	    line [gdb_get_line_number "main function call"]
+	    DW_LNS_copy
+
+	    DW_LNE_set_address main_epilogue
+	    line $main_epilogue
+	    DW_LNS_set_epilogue_begin
+	    DW_LNS_copy
+
+	    DW_LNE_set_address $main_end
+	    DW_LNE_end_sequence
+
+
+	    DW_LNS_set_file $diridx
+
+	    DW_LNE_set_address $watch_start
+	    line $watch_start_line
+	    DW_LNS_copy
+
+	    DW_LNE_set_address watch_start
+	    line [gdb_get_line_number "watch assign"]
+	    DW_LNS_set_prologue_end
+	    DW_LNS_copy
+
+	    DW_LNE_set_address watch_reassign
+	    line [gdb_get_line_number "watch reassign"]
+	    DW_LNS_set_epilogue_begin
+	    DW_LNS_copy
+
+	    DW_LNE_set_address watch_end
+	    line [gdb_get_line_number "watch end"]
+	    DW_LNS_copy
+
+	    DW_LNE_set_address $watch_end_sequence
+	    DW_LNE_end_sequence
+	}
+    }
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+	  [list $srcfile $asm_file] {nodebug}] } {
+    return -1
+}
+
+if ![runto_main] {
+    return -1
+}
+
+# Moving to the scope with a local variable.
+gdb_breakpoint $watch_start_line
+gdb_continue_to_breakpoint "continuing to function" ".*"
+gdb_test "next" "local = 2.*" "stepping to epilogue"
+
+# Forcing software watchpoints because hardware ones don't care if we
+# are in the epilogue or not.
+gdb_test_no_output "set can-use-hw-watchpoints 0"
+
+# Test that the software watchpoint will not trigger in this case
+gdb_test "watch local" "\[W|w\]atchpoint .: local" "set watchpoint"
+gdb_test "continue" ".*\[W|w\]atchpoint . deleted.*" \
+    "confirm watchpoint doesn't trigger"
+
+# First we test that the trivial function has a line with both a prologue
+# and an epilogue. Do this by finding a line that has 3 Y columns
+set sep "\[ \t\]"
+set hex_number "0x\[0-9a-f\]+"
+gdb_test_multiple "maint info line-table" "test epilogue in linetable" -lbl {
+    -re "\[0-9\]$sep+$trivial_line$sep+$hex_number$sep+$hex_number$sep+Y$sep+Y$sep+Y" {
+	pass $gdb_test_name
+    }
+}
-- 
2.35.3


^ permalink raw reply	[relevance 4%]

* [PATCH] sim: riscv: Fix some compatiblity issues with gcc
@ 2024-04-05  7:51  5% Bernd Edlinger
  0 siblings, 0 replies; 200+ results
From: Bernd Edlinger @ 2024-04-05  7:51 UTC (permalink / raw)
  To: gdb-patches, Jaydeep Patil

This makes the riscv simulator able to execute a simple
"hello world" program when gcc is configured
with:

../configure --target=riscv-none-elf

The first problem is that gcc generates rv32
code by default in this configuration, while
riscv64-none-elf generates rv64 code by default.

So change the riscv/acinclude.m4 to use the same
logic here.

And the second issue is that gcc does by default
generate instructions in INSN_CLASS_C, so move
the M(GC) to top of list, in riscv/model_list.def.

Then there was apparently a confusion which cpu
model uses JAL and which ADDIW.  Fixed that in
execute_c, case MATCH_C_JAL | MATCH_C_ADDIW.

With these changes a simple c-prgram can be executed,
however there is still work to do, since when the
program does floating point operations, gcc starts to
generate hardware floating point instructions, with no
obvious opt-out option.

Note the gcc test suite can be used to test the
simulator in this way:

make check-gcc RUNTESTFLAGS="--target_board=multi-sim SIM=riscv-none-elf-run"

Now many tests are passed, except those which use
floating point instructions.

Fixes 3224e32fb84f ("sim: riscv: Add support for compressed integer instructions")
---
 sim/configure            | 6 +++---
 sim/riscv/acinclude.m4   | 4 ++--
 sim/riscv/model_list.def | 2 +-
 sim/riscv/sim-main.c     | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/sim/configure b/sim/configure
index 1ebef377973..fdc0a86d524 100755
--- a/sim/configure
+++ b/sim/configure
@@ -17479,10 +17479,10 @@ $as_echo "$sim_ppc_xor_endian" >&6; }
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking riscv bitsize" >&5
 $as_echo_n "checking riscv bitsize... " >&6; }
-SIM_RISCV_BITSIZE=64
+SIM_RISCV_BITSIZE=32
 case $target in #(
-  riscv32*) :
-    SIM_RISCV_BITSIZE=32 ;; #(
+  riscv64*) :
+    SIM_RISCV_BITSIZE=64 ;; #(
   *) :
      ;;
 esac
diff --git a/sim/riscv/acinclude.m4 b/sim/riscv/acinclude.m4
index 0c6290c9c08..e9953c1017d 100644
--- a/sim/riscv/acinclude.m4
+++ b/sim/riscv/acinclude.m4
@@ -15,8 +15,8 @@ dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 dnl
 dnl NB: This file is included in sim/configure, so keep settings namespaced.
 AC_MSG_CHECKING([riscv bitsize])
-SIM_RISCV_BITSIZE=64
+SIM_RISCV_BITSIZE=32
 AS_CASE([$target],
-	[riscv32*], [SIM_RISCV_BITSIZE=32])
+	[riscv64*], [SIM_RISCV_BITSIZE=64])
 AC_MSG_RESULT([$SIM_RISCV_BITSIZE])
 AC_SUBST(SIM_RISCV_BITSIZE)
diff --git a/sim/riscv/model_list.def b/sim/riscv/model_list.def
index b83557e5539..df9ec897126 100644
--- a/sim/riscv/model_list.def
+++ b/sim/riscv/model_list.def
@@ -1,9 +1,9 @@
+M(GC)
 M(G)
 M(I)
 M(IM)
 M(IMA)
 M(IA)
-M(GC)
 M(IC)
 M(IMC)
 M(IMAC)
diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
index adff99921c6..9c0d070aa60 100644
--- a/sim/riscv/sim-main.c
+++ b/sim/riscv/sim-main.c
@@ -1018,7 +1018,7 @@ execute_c (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
     case MATCH_C_JAL | MATCH_C_ADDIW:
       /* JAL and ADDIW have the same mask but are only available on RV64 or
 	 RV32 respectively.  */
-      if (RISCV_XLEN (cpu) == 64)
+      if (RISCV_XLEN (cpu) == 32)
 	{
 	  imm = EXTRACT_CJTYPE_IMM (iw);
 	  TRACE_INSN (cpu, "c.jal %" PRIxTW,
@@ -1027,7 +1027,7 @@ execute_c (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
 	  pc = riscv_cpu->pc + imm;
 	  TRACE_BRANCH (cpu, "to %#" PRIxTW, pc);
 	}
-      else if (RISCV_XLEN (cpu) == 32)
+      else if (RISCV_XLEN (cpu) == 64)
 	{
 	  imm = EXTRACT_CITYPE_IMM (iw);
 	  TRACE_INSN (cpu, "c.addiw %s, %s, %#" PRIxTW ";  // %s += %#" PRIxTW,
-- 
2.25.1


^ permalink raw reply	[relevance 5%]

* Re: [PATCH v3 1/2] remote.c: Use packet_check_result
  @ 2024-04-04  8:52  0% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-04-04  8:52 UTC (permalink / raw)
  To: Alexandra Hájková, gdb-patches; +Cc: ahajkova

Alexandra Hájková <ahajkova@khirnov.net> writes:

> From: Alexandra Hájková <ahajkova@redhat.com>
>
> when processing the GDBserver reply to qRcmd packet.
> Print error message or the error code.
> Currently, when qRcmd request returns an error,
> GDB just prints:
>
> Protocol error with Rcmd
>
> After this change, GDB will also print the error code:
>
> Protocol error with Rcmd: 01.
>
> Add an accept_msg argument to packet_check result. qRcmd
> request (such as many other packets) does not recognise
> "E.msg" form as an error right now. We want to recognise
> "E.msg" as an error response only for the packets where
> it's documented.
>
> Also use packet_check result in remote_read_bytes_1.

Thanks for doing this.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


> ---
>  gdb/remote.c | 81 +++++++++++++++++++++++++++++-----------------------
>  1 file changed, 46 insertions(+), 35 deletions(-)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index e278711df7b..63f1112095d 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -2450,11 +2450,15 @@ add_packet_config_cmd (const unsigned int which_packet, const char *name,
>      }
>  }
>  
> -/* Check GDBserver's reply packet.  Return packet_result
> -   structure which contains the packet_status enum
> -   and an error message for the PACKET_ERROR case.  */
> +/* Check GDBserver's reply packet.  Return packet_result structure
> +   which contains the packet_status enum and an error message for the
> +   PACKET_ERROR case.
> +
> +   An error packet can always take the form Exx (where xx is a hex
> +   code).  When ACCEPT_MSG is true error messages can also take the
> +   form E.msg (where msg is any arbitrary string).  */
>  static packet_result
> -packet_check_result (const char *buf)
> +packet_check_result (const char *buf, bool accept_msg)
>  {
>    if (buf[0] != '\0')
>      {
> @@ -2466,14 +2470,20 @@ packet_check_result (const char *buf)
>  	/* "Enn"  - definitely an error.  */
>  	return { PACKET_ERROR, buf + 1 };
>  
> -      /* Always treat "E." as an error.  This will be used for
> -	 more verbose error messages, such as E.memtypes.  */
> -      if (buf[0] == 'E' && buf[1] == '.')
> +      /* Not every request accepts an error in a E.msg form.
> +	 Some packets accepts only Enn, in this case E. is not
> +	 defined and E. is treated as PACKET_OK.  */
> +      if (accept_msg)
>  	{
> -	  if (buf[2] != '\0')
> -	    return { PACKET_ERROR, buf + 2 };
> -	  else
> -	    return { PACKET_ERROR, "no error provided" };
> +	  /* Always treat "E." as an error.  This will be used for
> +	     more verbose error messages, such as E.memtypes.  */
> +	  if (buf[0] == 'E' && buf[1] == '.')
> +	    {
> +	      if (buf[2] != '\0')
> +		return { PACKET_ERROR, buf + 2 };
> +	      else
> +		return { PACKET_ERROR, "no error provided" };
> +	    }
>  	}
>  
>        /* The packet may or may not be OK.  Just assume it is.  */
> @@ -2487,9 +2497,9 @@ packet_check_result (const char *buf)
>  }
>  
>  static packet_result
> -packet_check_result (const gdb::char_vector &buf)
> +packet_check_result (const gdb::char_vector &buf, bool accept_msg)
>  {
> -  return packet_check_result (buf.data ());
> +  return packet_check_result (buf.data (), accept_msg);
>  }
>  
>  packet_status
> @@ -2502,7 +2512,7 @@ remote_features::packet_ok (const char *buf, const int which_packet)
>        && config->support == PACKET_DISABLE)
>      internal_error (_("packet_ok: attempt to use a disabled packet"));
>  
> -  packet_result result = packet_check_result (buf);
> +  packet_result result = packet_check_result (buf, true);
>    switch (result.status ())
>      {
>      case PACKET_OK:
> @@ -8830,7 +8840,7 @@ remote_target::send_g_packet ()
>    xsnprintf (rs->buf.data (), get_remote_packet_size (), "g");
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
> -  packet_result result = packet_check_result (rs->buf);
> +  packet_result result = packet_check_result (rs->buf, true);
>    if (result.status () == PACKET_ERROR)
>      error (_("Could not read registers; remote failure reply '%s'"),
>  	   result.err_msg ());
> @@ -9139,7 +9149,7 @@ remote_target::store_registers_using_G (const struct regcache *regcache)
>    bin2hex (regs, p, rsa->sizeof_g_packet);
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
> -  packet_result pkt_status = packet_check_result (rs->buf);
> +  packet_result pkt_status = packet_check_result (rs->buf, true);
>    if (pkt_status.status () == PACKET_ERROR)
>      error (_("Could not write registers; remote failure reply '%s'"),
>  	   pkt_status.err_msg ());
> @@ -9591,9 +9601,8 @@ remote_target::remote_read_bytes_1 (CORE_ADDR memaddr, gdb_byte *myaddr,
>    *p = '\0';
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
> -  if (rs->buf[0] == 'E'
> -      && isxdigit (rs->buf[1]) && isxdigit (rs->buf[2])
> -      && rs->buf[3] == '\0')
> +  packet_result result = packet_check_result (rs->buf, false);
> +  if (result.status () == PACKET_ERROR)
>      return TARGET_XFER_E_IO;
>    /* Reply describes memory byte by byte, each byte encoded as two hex
>       characters.  */
> @@ -9747,7 +9756,7 @@ remote_target::remote_send_printf (const char *format, ...)
>    rs->buf[0] = '\0';
>    getpkt (&rs->buf);
>  
> -  return packet_check_result (rs->buf).status ();
> +  return packet_check_result (rs->buf, true).status ();
>  }
>  
>  /* Flash writing can take quite some time.  We'll set
> @@ -11930,20 +11939,19 @@ remote_target::rcmd (const char *command, struct ui_file *outbuf)
>  	  continue;
>  	}
>        buf = rs->buf.data ();
> -      if (buf[0] == '\0')
> -	error (_("Target does not support this command."));
>        if (buf[0] == 'O' && buf[1] != 'K')
>  	{
>  	  remote_console_output (buf + 1); /* 'O' message from stub.  */
>  	  continue;
>  	}
> +      packet_result result = packet_check_result (buf, false);
>        if (strcmp (buf, "OK") == 0)
>  	break;
> -      if (strlen (buf) == 3 && buf[0] == 'E'
> -	  && isxdigit (buf[1]) && isxdigit (buf[2]))
> -	{
> -	  error (_("Protocol error with Rcmd"));
> -	}
> +      else if (result.status () == PACKET_UNKNOWN)
> +	error (_("Target does not support this command."));
> +      else
> +	error (_("Protocol error with Rcmd: %s."), result.err_msg ());
> +
>        for (p = buf; p[0] != '\0' && p[1] != '\0'; p += 2)
>  	{
>  	  char c = (fromhex (p[0]) << 4) + fromhex (p[1]);
> @@ -15570,7 +15578,7 @@ remote_target::store_memtags (CORE_ADDR address, size_t len,
>    getpkt (&rs->buf);
>  
>    /* Verify if the request was successful.  */
> -  return packet_check_result (rs->buf).status () == PACKET_OK;
> +  return packet_check_result (rs->buf, true).status () == PACKET_OK;
>  }
>  
>  /* Return true if remote target T is non-stop.  */
> @@ -15671,26 +15679,29 @@ static void
>  test_packet_check_result ()
>  {
>    std::string buf = "E.msg";
> -  packet_result result = packet_check_result (buf.data ());
> +  packet_result result = packet_check_result (buf.data (), true);
>  
>    SELF_CHECK (result.status () == PACKET_ERROR);
>    SELF_CHECK (strcmp(result.err_msg (), "msg") == 0);
>  
> -  result = packet_check_result ("E01");
> +  result = packet_check_result ("E01", true);
>    SELF_CHECK (result.status () == PACKET_ERROR);
>    SELF_CHECK (strcmp(result.err_msg (), "01") == 0);
>  
> -  SELF_CHECK (packet_check_result ("E1").status () == PACKET_OK);
> +  SELF_CHECK (packet_check_result ("E1", true).status () == PACKET_OK);
>  
> -  SELF_CHECK (packet_check_result ("E000").status () == PACKET_OK);
> +  SELF_CHECK (packet_check_result ("E000", true).status () == PACKET_OK);
>  
> -  result = packet_check_result ("E.");
> +  result = packet_check_result ("E.", true);
>    SELF_CHECK (result.status () == PACKET_ERROR);
>    SELF_CHECK (strcmp(result.err_msg (), "no error provided") == 0);
>  
> -  SELF_CHECK (packet_check_result ("some response").status () == PACKET_OK);
> +  SELF_CHECK (packet_check_result ("some response", true).status () == PACKET_OK);
> +
> +  SELF_CHECK (packet_check_result ("", true).status () == PACKET_UNKNOWN);
>  
> -  SELF_CHECK (packet_check_result ("").status () == PACKET_UNKNOWN);
> +  result = packet_check_result ("E.msg", false);
> +  SELF_CHECK (result.status () == PACKET_OK);
>  }
>  } // namespace selftests
>  #endif /* GDB_SELF_TEST */
> -- 
> 2.44.0


^ permalink raw reply	[relevance 0%]

* Re: [PATCH v2 4/4] gdb: Add new remote packet to check if address is tagged
  @ 2024-04-04  5:32  0%     ` Gustavo Romero
  0 siblings, 0 replies; 200+ results
From: Gustavo Romero @ 2024-04-04  5:32 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: gdb-patches, luis.machado

Hi Thiago,

Thanks a lot for the nice review. I think it helped a lot the
series organization.

On 3/29/24 8:35 PM, Thiago Jung Bauermann wrote:
> 
> Hello Gustavo,
> 
> I started reviewing the patch series backwards...
> I'll provide comments on this patch first.
> 
> Overall, it looks great. I just have some localised comments in a few
> places below.
> 
> Also, for ease of review I suggest splitting this patch in two:
> 
> - one that introduces the new check_memtag_addr target hook and converts
>    the existing code to use it,
> - and another that adds a check_memtag_addr target hook implementation
>    to the remote target.

Done in v3.

  
> Gustavo Romero <gustavo.romero@linaro.org> writes:
> 
>> This commit adds a new packet qMemTagAddrCheck allowing GDB remote
>> targets to use it to query gdbservers if a given address is tagged.
>>
>> It also adds a new GDB remote feature, 'memory-tagging-check-add+',
>> which must be advertised by the GDB servers to inform GDB they can reply
>> to address checks via the new qMemTagAddrCheck remote packet.
> 
> You will need to document the remote protocol changes in gdb.texinfo, in
> the "Remote Serial Protocol" appendix.

Done in v3.

  
>> Currently, this address check is done via a read query, where the
>> contents of /proc/<PID>/smaps is read and the flags in there are
>> inspected for MTE-related flags that indicate the address is in a tagged
>> memory region.
>>
>> This is not ideal, for example, on QEMU gdbstub and in other cases,
>> like in baremetal debugging, where there is no notion of any OS file
>> like smaps. Hence, qMemTagAddrCheck packet allows check addresses in
>> an OS-agnostic way.
>>
>> For supporting the new packet, a new target hook is introduced,
>> check_memtag_addr, which is used instead of the gdbarch_tagged_address_p
>> gdbarch hook in the upper layers (printcmd.c).
>>
>> The new target hook is then specialized per target, for remote.c,
>> aarch64-linux-nat.c, and corelow.c targets (the current targets that
>> are MTE-aware).
>>
>> The target hook in remote.c uses the qMemTagAddrCheck packet to check
>> an address if the server advertised the 'memory-tagging-check-add+'
>> feature, otherwise it falls back to using the current mechanism, i.e. it
>> reads the /proc/<PID>/smaps contents.
>>
>> In the aarch64-linux-nat.c and corelow.c the target hook uses the
>> gdbarch_tagged_address_p gdbarch hook, so there is no change regarding
>> how an address is checked in these targets. Just the
>> gdbarch_tagged_address_p signature is changed for convenience, since
>> target_check_memtag_addr takes the address to be checked as a CORE_ADDR
>> type.
> 
> I agree that a CORE_ADDR argument is more convenient.
> 
>> @@ -1071,6 +1073,12 @@ aarch64_linux_nat_target::store_memtags (CORE_ADDR address, size_t len,
>>     return false;
>>   }
>>
>> +bool
>> +aarch64_linux_nat_target::check_memtag_addr (CORE_ADDR address)
>> +{
>> +  return gdbarch_tagged_address_p (current_inferior ()->arch (), address);
> 
> I think it's better to pass the gdbarch as an argument to the
> check_memtag_addr hook rather than getting it from current_inferior
> here, even if in practice your patch is equivalent to the existing
> code.
> 
> The reason is that we are trying to move calls to current_* functions
> (which is global state in disguise) up the stack, so that most of GDB
> needs to reference only local state.
> 
> Then if callers have a gdbarch available in their context they can pass
> it to the hook, or else they can use current_inferior ()->arch ().
> 
>> @@ -1410,6 +1412,12 @@ core_target::fetch_memtags (CORE_ADDR address, size_t len,
>>     return false;
>>   }
>>
>> +bool
>> +core_target::check_memtag_addr (CORE_ADDR address)
>> +{
>> +  return gdbarch_tagged_address_p (current_inferior ()->arch (), address);
> 
> Same comment here, of course.
> 
>> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
>> index ae4d640ccf2..c81c75afc5d 100644
>> --- a/gdb/printcmd.c
>> +++ b/gdb/printcmd.c
>> @@ -1132,7 +1132,7 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
>>   	    = value_from_ulongest (builtin_type (gdbarch)->builtin_data_ptr,
>>   				   tag_laddr);
>>
>> -	  if (gdbarch_tagged_address_p (current_inferior ()->arch  (), v_addr))
>> +	  if (target_check_memtag_addr (value_as_address(v_addr)))
> 
> Missing space between "value_as_address" and the opening parens.
> 
> Also, not a problem introduced by you, but I don't understand why the code
> uses the gdbarch from current_inferior if it was passed a gdbarch in the
> arguments.
> 
> So I'd add a separate patch before this one to fix this code to use the
> gdbarch that was passed as a parameter. Then this patch can also pass it
> as a parameter to target_check_memtag_addr as I mentioned in an earlier
> comment.

Done in v3 in commit "gdb: Use passed gdbarch instead of calling current_inferior".


>>   	    {
>>   	      /* Fetch the allocation tag.  */
>>   	      struct value *tag
>> @@ -1289,7 +1289,7 @@ should_validate_memtags (struct value *value)
>>       return false;
>>
>>     /* We do.  Check whether it includes any tags.  */
>> -  return gdbarch_tagged_address_p (current_inferior ()->arch  (), value);
>> +  return target_check_memtag_addr (value_as_address(value));
> 
> Here there's no gdbarch available in context, but since there's only one
> caller to this function, it's easy to add the gdbarch parameter to it
> and make the caller pass it down. The caller does get it from
> current_inferior, so perhaps I'm being too pedantic here but IMHO it's
> worth it.
> 
> Also, a space is missing before the opening parens.
> 
>>   }
>>
>>   /* Helper for parsing arguments for print_command_1.  */
>> @@ -2946,9 +2946,10 @@ memory_tag_print_tag_command (const char *args, enum memtag_type tag_type)
>>        flag, it is no use trying to access/manipulate its allocation tag.
>>
>>        It is OK to manipulate the logical tag though.  */
>> +  CORE_ADDR addr = value_as_address(val);
> 
> Missing space before the opening parens.
> 
>>     if (tag_type == memtag_type::allocation
>> -      && !gdbarch_tagged_address_p (arch, val))
>> -    show_addr_not_tagged (value_as_address (val));
>> +      && !target_check_memtag_addr(addr))
> 
> Missing space before the opening parens.
> 
>> +    show_addr_not_tagged (addr);
>>
>>     value *tag_value = gdbarch_get_memtag (arch, val, tag_type);
>>     std::string tag = gdbarch_memtag_to_string (arch, tag_value);
>> @@ -3104,8 +3105,9 @@ parse_set_allocation_tag_input (const char *args, struct value **val,
>>
>>     /* If the address is not in a region memory mapped with a memory tagging
>>        flag, it is no use trying to access/manipulate its allocation tag.  */
>> -  if (!gdbarch_tagged_address_p (current_inferior ()->arch (), *val))
>> -    show_addr_not_tagged (value_as_address (*val));
>> +  CORE_ADDR addr = value_as_address (*val);
>> +  if (!target_check_memtag_addr (addr))
>> +    show_addr_not_tagged (addr);
> 
> This is another instance where I'd suggest making the caller pass
> gdbarch as an argument so that it can be used here, since this function
> only has one caller.

OK, done in v3.


> 
>>   }
>>
>>   /* Implement the "memory-tag set-allocation-tag" command.
>> @@ -3129,8 +3131,9 @@ memory_tag_set_allocation_tag_command (const char *args, int from_tty)
>>
>>     /* If the address is not in a region memory mapped with a memory tagging
>>        flag, it is no use trying to manipulate its allocation tag.  */
>> -  if (!gdbarch_tagged_address_p (current_inferior ()->arch (), val)) {
>> -    show_addr_not_tagged (value_as_address(val));
>> +  CORE_ADDR addr = value_as_address (val);
>> +  if (!target_check_memtag_addr (addr)) {
>> +    show_addr_not_tagged (addr);
>>     }
> 
> This is a preexisting issue in the code, but since you're touching it:
> the GNU style is to not use curly braces when there's only one statement
> in the if block.
> 
>> @@ -15532,6 +15547,19 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address,
>>     strcpy (packet.data (), request.c_str ());
>>   }
>>
>> +static void
>> +create_check_memtag_addr_request (gdb::char_vector &packet, CORE_ADDR address)
>> +{
>> +  int addr_size = gdbarch_addr_bit (current_inferior ()->arch()) / 8;
>> +
>> +  std::string request = string_printf ("qMemTagAddrCheck:%s", phex_nz (address, addr_size));
>> +
>> +  if (packet.size () < request.length ())
> 
> There's an off-by-one error here: packet is expected to be
> null-terminated, but request.length doesn't count a terminating null
> byte so a "+ 1" needs to be added here.

Good catch, thanks. Fixed in v3.

  
>> +    error (_("Contents too big for packet qMemTagAddrCheck."));
>> +
>> +  strcpy (packet.data (), request.c_str ());
>> +}
>> +
>>   /* Implement the "fetch_memtags" target_ops method.  */
>>
>>   bool
>> @@ -15573,6 +15601,36 @@ remote_target::store_memtags (CORE_ADDR address, size_t len,
>>     return packet_check_result (rs->buf).status () == PACKET_OK;
>>   }
>>
>> +bool
>> +remote_target::check_memtag_addr (CORE_ADDR address)
>> +{
>> +  struct remote_state *rs = get_remote_state ();
>> +
>> +  if (!m_features.remote_memory_tagging_check_addr_p ())
>> +    /* Fallback to reading /proc/<PID>/smaps for checking if an address is
>> +       tagged or not.  */
> 
> Currently this comment is accurate, but if some other architecture adds
> a gdbarch method that doesn't use /proc/<PID>/smaps then it won't be
> anymore.
> 
> I suggest saying something like "Fallback to arch-specific method of
> checking whether an address is tagged".

Done in v3.


>> +    return gdbarch_tagged_address_p (current_inferior ()->arch (), address);
>> +
>> +  create_check_memtag_addr_request (rs->buf, address);
>> +
>> +  putpkt (rs->buf);
>> +  getpkt (&rs->buf);
>> +
>> +  /* Check if reply is OK.  */
>> +  if ((packet_check_result (rs->buf).status () != PACKET_OK) || rs->buf.empty())
> 
> Missing space between "empty" and opening parens.
> 
> But I don't understand why check whether buf is empty. Looking at
> remote_target::getpkt, it doesn't look like buf is ever emptied.

I removed rs->buf.empty() in v3.


>> +    return false;
>> +
>> +  gdb_byte tagged_addr;
>> +  /* Convert only 2 hex digits, i.e. 1 byte in hex format.  */
>> +  hex2bin(rs->buf.data(), &tagged_addr , 1);
> 
> Missing space between "hex2bin", "data" and the opening parens.
> 
>> +  if (tagged_addr)
>> +    /* 01 means address is tagged.  */
>> +    return true;
>> +  else
>> +    /* 00 means address is not tagged.  */
>> +    return false;
> 
> The above can be simplified to "return tagged_addr != 0".

Done in v3.


Cheers,
Gustavo

^ permalink raw reply	[relevance 0%]

* [PATCH v2] Add wildcard matching to substitute-path rules
@ 2024-04-04  0:17  3% Max Yvon Zimmermann
  0 siblings, 0 replies; 200+ results
From: Max Yvon Zimmermann @ 2024-04-04  0:17 UTC (permalink / raw)
  To: gdb-patches

Changes since v1:

The function strip_trailing_directory_separator_and_escape() is now fixed.

I have added a new function validate_substitute_path_pattern() that will validate any pattern during the registration of a new rule. If an invalid pattern is detected, an error message gets printed. I hope this will make the feature more usable. If this check would not be performed an invalid rule would still be visible with 'show substitute-path', but it would never match anything.

Use literal ',' and '\' in the documentation.

Change the example file names in the documentation.

More tests in the testsuite.

---
 gdb/NEWS                              |   5 +
 gdb/doc/gdb.texinfo                   |  29 ++++
 gdb/source.c                          | 106 +++++++++++----
 gdb/testsuite/gdb.base/subst-glob.exp | 182 ++++++++++++++++++++++++++
 gdb/utils.c                           | 100 ++++++++++++++
 gdb/utils.h                           |   2 +
 6 files changed, 401 insertions(+), 23 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/subst-glob.exp

diff --git a/gdb/NEWS b/gdb/NEWS
index feb3a37393a..5a041175507 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -90,6 +90,11 @@ show unwind-on-signal
   These new commands replaces the existing set/show unwindonsignal.  The
   old command is maintained as an alias.
 
+set substitute-path
+  This command now supports glob pattern matching for substitution
+  rules.  Wildcards '?' and '*' are supported.  Use '\' to escape
+  '?', '*' and '\' characters.
+
 * New features in the GDB remote stub, GDBserver
 
   ** The --remote-debug and --event-loop-debug command line options
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 727f9275bfb..3bf7d99a153 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -9954,6 +9954,35 @@ For instance, if we had entered the following commands:
 use the second rule to rewrite @file{/usr/src/lib/foo.c} into
 @file{/mnt/src/lib/foo.c}.
 
+Rules can contain wildcards to match multiple paths.  The supported
+wildcards are @file{?} (to match any single character) and @file{*}
+(to match any string).  Wildcards will never match the path separator of
+the system.
+
+For instance, if we had entered the following command:
+
+@smallexample
+(@value{GDBP}) set substitute-path /build/*/include /mnt/include
+@end smallexample
+
+@noindent
+@value{GDBN} would then rewrite @file{/build/release/include/inc.h} into
+@file{/mnt/include/inc.h}.  Another file @file{/build/debug/include/inc.h}
+would also be rewritten as @file{/mnt/include/inc.h} using the same rule.
+
+Use @samp{\} to escape the characters @samp{?}, @samp{*} and @samp{\}.  Note
+that you need to escape any @samp{\} characters twice in the @value{GDBN}
+command line.
+
+So if we want to match a literal @samp{*} character in a rule, we would enter:
+
+@smallexample
+(@value{GDBP}) set substitute-path /foo\\*/bar /mnt/cross
+@end smallexample
+
+@noindent
+Now only the directory @file{/foo*/bar/} would match against the rule.
+
 
 @item unset substitute-path [path]
 @kindex unset substitute-path
diff --git a/gdb/source.c b/gdb/source.c
index 432301e2a71..9a2f47194af 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -16,6 +16,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "expression.h"
@@ -26,6 +27,7 @@
 #include "frame.h"
 #include "value.h"
 #include "gdbsupport/filestuff.h"
+#include "utils.h"
 
 #include <sys/types.h>
 #include <fcntl.h>
@@ -959,44 +961,69 @@ source_full_path_of (const char *filename,
   return 1;
 }
 
-/* Return non-zero if RULE matches PATH, that is if the rule can be
-   applied to PATH.  */
+/* Validate a substitute-path PATTERN.
+   Return 1 if PATTERN is valid.
+   Return 0 if PATTERN is invalid.  */
 
 static int
-substitute_path_rule_matches (const struct substitute_path_rule *rule,
-			      const char *path)
+validate_substitute_path_pattern (const char *pattern)
 {
-  const int from_len = rule->from.length ();
-  const int path_len = strlen (path);
+  /* Iterate backwards to find any unterminated escapes.  */
 
-  if (path_len < from_len)
-    return 0;
+  int backslash_count = 0;
+  for (int i = strlen (pattern) - 1; i >= 0; --i)
+    {
+      if (pattern[i] != '\\')
+        break;
+
+      ++backslash_count;
+    }
 
+  return (backslash_count % 2) == 0;
+}
+
+/* Return the position in PATH up until RULE matches PATH, that is if the rule
+   can be applied to PATH.
+   Return -1 if there is no match.  */
+
+static int
+substitute_path_rule_matches (const struct substitute_path_rule *rule,
+			      const char *path)
+{
   /* The substitution rules are anchored at the start of the path,
      so the path should start with rule->from.  */
 
-  if (filename_ncmp (path, rule->from.c_str (), from_len) != 0)
-    return 0;
+  const int result = gdb_fileprefix_fnmatch (rule->from.c_str (), path);
 
-  /* Make sure that the region in the path that matches the substitution
-     rule is immediately followed by a directory separator (or the end of
-     string character).  */
+  if (result != -1)
+    {
+      /* Make sure that the region in the path that matches the substitution
+        rule is immediately followed by a directory separator (or the end of
+        string character).  */
 
-  if (path[from_len] != '\0' && !IS_DIR_SEPARATOR (path[from_len]))
-    return 0;
+      if (path[result] != '\0' && !IS_DIR_SEPARATOR (path[result]))
+        return -1;
+    }
 
-  return 1;
+  return result;
 }
 
 /* Find the substitute-path rule that applies to PATH and return it.
+   Also set SUB_POS to the position in PATH up until the rule matches PATH.
    Return NULL if no rule applies.  */
 
 static struct substitute_path_rule *
-get_substitute_path_rule (const char *path)
+get_substitute_path_rule (const char *path, int &sub_pos)
 {
   for (substitute_path_rule &rule : substitute_path_rules)
-    if (substitute_path_rule_matches (&rule, path))
-      return &rule;
+    {
+      const int result = substitute_path_rule_matches (&rule, path);
+      if (result != -1)
+        {
+          sub_pos = result;
+          return &rule;
+        }
+    }
 
   return nullptr;
 }
@@ -1010,7 +1037,9 @@ get_substitute_path_rule (const char *path)
 gdb::unique_xmalloc_ptr<char>
 rewrite_source_path (const char *path)
 {
-  const struct substitute_path_rule *rule = get_substitute_path_rule (path);
+  int sub_pos;
+  const struct substitute_path_rule *rule
+    = get_substitute_path_rule (path, sub_pos);
 
   if (rule == nullptr)
     return nullptr;
@@ -1018,7 +1047,7 @@ rewrite_source_path (const char *path)
   /* Compute the rewritten path and return it.  */
 
   return (gdb::unique_xmalloc_ptr<char>
-	  (concat (rule->to.c_str (), path + rule->from.length (), nullptr)));
+	  (concat (rule->to.c_str (), path + sub_pos, nullptr)));
 }
 
 /* See source.h.  */
@@ -1718,6 +1747,34 @@ strip_trailing_directory_separator (char *path)
     path[last] = '\0';
 }
 
+/* If the last character of PATH is a directory separator, then strip it.
+   Also remove any related escape character (on DOS-based systems).  */
+
+static void
+strip_trailing_directory_separator_and_escape (char *path)
+{
+  const int last = strlen (path) - 1;
+
+  if (last < 0)
+    return;  /* No stripping is needed if PATH is the empty string.  */
+
+  if (!IS_DIR_SEPARATOR (path[last]))
+    return;
+
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  if (path[last] == '\\')
+    {
+      if (last < 1 || path[last - 1] != '\\')
+        return;
+
+      /* Remove any related escape character.  */
+      path[last - 1] = '\0';
+    }
+#endif
+
+  path[last] = '\0';
+}
+
 /* Add a new substitute-path rule at the end of the current list of rules.
    The new rule will replace FROM into TO.  */
 
@@ -1754,7 +1811,7 @@ show_substitute_path_command (const char *args, int from_tty)
 
   for (substitute_path_rule &rule : substitute_path_rules)
     {
-      if (from == NULL || substitute_path_rule_matches (&rule, from) != 0)
+      if (from == NULL || substitute_path_rule_matches (&rule, from) != -1)
 	gdb_printf ("  `%s' -> `%s'.\n", rule.from.c_str (),
 		    rule.to.c_str ());
     }
@@ -1830,9 +1887,12 @@ set_substitute_path_command (const char *args, int from_tty)
 
   /* Strip any trailing directory separator character in either FROM
      or TO.  The substitution rule already implicitly contains them.  */
-  strip_trailing_directory_separator (argv[0]);
+  strip_trailing_directory_separator_and_escape (argv[0]);
   strip_trailing_directory_separator (argv[1]);
 
+  if (!validate_substitute_path_pattern (argv[0]))
+    error (_("First argument is not a valid glob expression"));
+
   /* If a rule with the same "from" was previously defined, then
      delete it.  This new rule replaces it.  */
 
diff --git a/gdb/testsuite/gdb.base/subst-glob.exp b/gdb/testsuite/gdb.base/subst-glob.exp
new file mode 100644
index 00000000000..b364760671a
--- /dev/null
+++ b/gdb/testsuite/gdb.base/subst-glob.exp
@@ -0,0 +1,182 @@
+# Copyright 2006-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+clean_restart
+
+# Do a bunch of testing of the substitute-path glob pattern matching.
+
+gdb_test_no_output "set confirm off" \
+        "deactivate GDB's confirmation interface"
+
+proc test_pattern { pattern path mode } {
+    # Escape backslashes so the GDB console can unescape them again.
+    set terminal_pattern [ \
+        string map { \
+            "\\" "\\\\" \
+        } $pattern \
+    ]
+
+    # Escape the pattern for regex matching.
+    set match_pattern [ \
+        string map { \
+            "*"  "\\\\*" \
+            "?"  "\\\\?" \
+            "\\" "\\\\\\\\" \
+        } $pattern \
+    ]
+
+    # Handle stripping of path separators.
+    if {[ishost "*-mingw*"]} {
+        regsub {(\\\\\\\\\\\\|/)$} $match_pattern {} match_pattern
+        set match_pattern [subst $match_pattern]
+    } else {
+        regsub {/$} $match_pattern {} match_pattern
+        set match_pattern [subst $match_pattern]
+    }
+
+    # Escape backslashes so the GDB console can unescape them again.
+    set terminal_path [ \
+        string map { \
+            "\\" "\\\\" \
+        } $path \
+    ]
+    
+    # Escape the path for regex matching.
+    set match_path [ \
+        string map { \
+            "*"  "\\*" \
+            "?"  "\\?" \
+            "\\" "\\\\" \
+        } $path \
+    ]
+    
+    if {$mode == "fail"} {
+        gdb_test "set substitute-path \"$terminal_pattern\" \"to\"" \
+            "First argument is not a valid glob expression" \
+            "set substitute-path $terminal_pattern (expect failure)"
+    } else {
+        gdb_test_no_output "unset substitute-path" \
+            "unset substitute-path before testing '$terminal_pattern' matches '$terminal_path'"
+
+        gdb_test_no_output "set substitute-path \"$terminal_pattern\" \"to\"" \
+            "set substitute-path $terminal_pattern before testing '$terminal_pattern' matches '$terminal_path'"
+    }
+    
+    if {$mode == "pos"} {
+        gdb_test "show substitute-path \"$terminal_path\"" \
+            "Source path substitution rule matching `$match_path':\r\n +`$match_pattern' -> `to'." \
+            "testing '$terminal_pattern' matches '$terminal_path'"
+    } elseif {$mode == "neg"} {
+        gdb_test "show substitute-path \"$terminal_path\"" \
+            "Source path substitution rule matching `$match_path':" \
+            "testing '$terminal_pattern' does not match '$terminal_path'"
+    }
+}
+
+proc test_pattern_pos { pattern path } {
+    test_pattern $pattern $path "pos"
+}
+
+proc test_pattern_neg { pattern path } {
+    test_pattern $pattern $path "neg"
+}
+
+proc test_pattern_fail { pattern } {
+    test_pattern $pattern "" "fail"
+}
+
+# Sanity checks.
+test_pattern_pos "path" "path"
+test_pattern_pos "path" "path/to"
+test_pattern_pos "/" "/test"
+test_pattern_pos "/testing" "/testing/test"
+test_pattern_pos "/testing/" "/testing/test"
+test_pattern_neg "path" "test"
+test_pattern_neg "///" "test"
+test_pattern_neg "/path//to" "/path/to"
+
+# '?' wildcard.
+test_pattern_pos "?atchone" "matchone"
+test_pattern_pos "pat?/to" "path/to"
+test_pattern_pos "path??" "pathto"
+test_pattern_pos "test?ng" "testing"
+test_pattern_pos "?" "?/test"
+test_pattern_neg "test?" "test/"
+test_pattern_neg "test?" "testing/"
+test_pattern_neg "?" ""
+
+# '*' wildcard.
+test_pattern_pos "*" "matchall"
+test_pattern_pos "path_*" "path_pattern"
+test_pattern_pos "test*/test" "testing/test"
+test_pattern_pos "test*" "testing/test"
+test_pattern_pos "test*" "test/test"
+test_pattern_pos "*" "testing/test"
+test_pattern_pos "*/*" "testing/test"
+test_pattern_pos "*/" "test/"
+test_pattern_pos "/*" "/test"
+test_pattern_pos "test*" "test/"
+test_pattern_pos "test*" "test"
+test_pattern_pos "test*test" "testtest"
+test_pattern_pos "test*test" "testingtest"
+test_pattern_pos "test*test" "testingtest/test"
+test_pattern_pos "*" "*test"
+test_pattern_pos "**" "t"
+test_pattern_pos "*" ""
+test_pattern_pos "*t*st" "foobartest"
+test_pattern_pos "*t*st" "foobartest/ing"
+test_pattern_pos "*t*st" "tetest"
+test_pattern_pos "*t*st" "tetest/ing"
+test_pattern_pos "*t*st" "testtest"
+test_pattern_pos "*t*st" "testtest/ing"
+test_pattern_neg "*test" "foobar"
+test_pattern_neg "*/test" "foo/bar"
+
+# Escapes.
+test_pattern_pos "\\\\" "\\"
+test_pattern_pos "\\\\*" "\\test"
+test_pattern_pos "*\\\\" "test\\"
+test_pattern_pos "\\\\/" "\\/"
+test_pattern_pos "\\*" "*"
+test_pattern_pos "\\?" "?"
+test_pattern_pos "\\*" "*/test"
+test_pattern_pos "\\?" "?/test"
+test_pattern_pos "\\//" "/"
+test_pattern_neg "\\//" "test"
+test_pattern_neg "\\*" "*test"
+test_pattern_neg "\\?" "?test"
+test_pattern_neg "\\*" "t"
+test_pattern_neg "\\?" "t"
+test_pattern_fail "\\"
+test_pattern_fail "\\/"
+test_pattern_fail "\\\\\\"
+test_pattern_fail "test\\"
+test_pattern_fail "test\\\\\\"
+
+if {[ishost "*-mingw*"]} {
+    # DOS tests.
+    test_pattern_pos "test" "TEST"
+    test_pattern_pos "/" "\\test"
+    test_pattern_pos "\\\\" "/test"
+    test_pattern_pos "*\\\\" "test/"
+}
+
+if {[ishost "*-linux*"]} {
+    # Unix tests.
+    test_pattern_neg "test" "TEST"
+    test_pattern_neg "/" "\\test"
+    test_pattern_fail "\\\\" "/test"
+    test_pattern_fail "*\\\\" "test/"
+}
diff --git a/gdb/utils.c b/gdb/utils.c
index ded03c74099..00597543051 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3532,6 +3532,106 @@ gdb_filename_fnmatch (const char *pattern, const char *string, int flags)
   return fnmatch (pattern, string, flags);
 }
 
+/* Return the position in STRING up until a PATTERN expression is matched.
+   Return -1 if there is no match.
+   
+   Only the wildcards ? and * are supported. */
+
+int
+gdb_fileprefix_fnmatch (const char *pattern, const char *string)
+{
+  int string_pos = 0;
+  char pattern_c;
+  char string_c;
+
+  while (*pattern != '\0' && *string != '\0')
+    {
+      switch (*pattern)
+        {
+        /* Unescape and match the next character.  */
+        case '\\':
+          ++pattern;
+          if (*pattern == '\0')
+            return -1;
+          [[fallthrough]];
+
+        default:
+          pattern_c = *pattern;
+          string_c = *string;
+
+#ifdef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
+          pattern_c = TOLOWER (pattern_c);
+          string_c = TOLOWER (string_c);
+#endif
+
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+          /* On DOS-based file systems, the '/' and the '\' are equivalent.  */
+          if (pattern_c == '/')
+            pattern_c = '\\';
+          if (string_c == '/')
+            string_c = '\\';
+#endif
+
+          /* Compare the current character of the pattern with the path.  */
+          if (pattern_c != string_c)
+            return -1;
+          break;
+
+        /* Match any character.  */
+        case '?':
+          /* Directory separators are not matched by '?'.  */
+          if (IS_DIR_SEPARATOR (*string))
+            return -1;
+          break;
+
+        /* Match any string.  */
+        case '*':
+          int best_result = -1;
+
+          /* Try to match any folling substring.  */
+          while (true)
+            {
+              /* Most of these attempts will fail at the first character. */
+              int result = gdb_fileprefix_fnmatch (pattern+1, string);
+
+              if (result != -1)
+                {
+                  /* If there is a substring match, compare its result to the best
+                    candidate so far.  */
+                  result += string_pos;
+                  if (result > best_result)
+                    best_result = result;
+                }
+
+              /* Exit on a null byte or a directory separator.  */
+              if (*string == '\0' || IS_DIR_SEPARATOR (*string))
+                return best_result;
+
+              ++string;
+              ++string_pos;
+            }
+        }
+    
+        ++pattern;
+        ++string;
+        ++string_pos;
+      }
+
+  /* If the macthing is complete but there is still some of the pattern left,
+     we must ensure that the remaining pattern matches the empty string.  */
+  if (*pattern != '\0')
+    {
+      /* Only '*' can match the empty string.  */
+      while (*pattern == '*')
+        ++pattern;
+
+      if (*pattern != '\0')
+        return -1;
+    }
+
+  return string_pos;
+}
+
 /* Return the number of path elements in PATH.
    / = 1
    /foo = 2
diff --git a/gdb/utils.h b/gdb/utils.h
index 875a2583179..eaf3fe8a8c3 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -137,6 +137,8 @@ struct set_batch_flag_and_restore_page_info
 extern int gdb_filename_fnmatch (const char *pattern, const char *string,
 				 int flags);
 
+extern int gdb_fileprefix_fnmatch (const char *pattern, const char *string);
+
 extern void substitute_path_component (char **stringp, const char *from,
 				       const char *to);
 
-- 
2.34.1

^ permalink raw reply	[relevance 3%]

* Re: [PATCH v2] gdb: Support embedded source in DWARF
  @ 2024-04-03 21:20  0%   ` Will Hawkins
  0 siblings, 0 replies; 200+ results
From: Will Hawkins @ 2024-04-03 21:20 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Wed, Apr 3, 2024 at 4:34 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Will" == Will Hawkins <hawkinsw@obs.cr> writes:
>
> Will> While DW_LNCT_source is not yet finalized in the DWARF standard
> Will> (https://dwarfstd.org/issues/180201.1.html), LLVM does emit it.
>
> Will> This patch adds support for it in gdb.
>
> Will> Tested on x86_64-redhat-linux.
>
> Will> Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
>
> Thanks for the patch.
> It looks basically reasonable to me but I found a few oddities and then
> also some of the normal stylistic nits.
>

Thank you for the feedback! As I said for the other patch that I
submitted, I was nervous and hoping to hear some positive feedback.
And, I got it ... so mission accomplished for the day.

> Will> +      m_is_embedded (false)
>
> It's better to use inline initialization, like:
>
> Will> +  /* Whether the file's source is embedded in the dwarf.  */
> Will> +  bool m_is_embedded;
>
>    bool m_is_embedded = false;

Makes perfect sense. I obviously had a hard time deciphering the
prevailing style!

>
> Will> +     case DW_LNCT_LLVM_SOURCE:
> Will> +       if (string.has_value () && strlen (*string))
> Will> +         fe.source = *string;
> Will> +       break;
>
> If the source can be large then it seems bad to spend time computing the
> strlen, when just checking if the first byte is '\0' gives the same
> answer in constant time.

100% agree. Thank you!


>
> Will> +  /* Whether or not the file names refer to sources embedded
> Will> +     in the dwarf.  */
> Will> +  bool *embeddeds;
>
> Probably should be 'const bool *' since IIUC this is set up once and
> then never written to again.

Of course!

>
> Will> +       if (entry.source != NULL)
> Will> +         embeddeds.push_back (false);
> Will> +       else
> Will> +         embeddeds.push_back(true);
>
> embeddeds.push_back (entry.source == nullptr);

I have *no* idea why I didn't write that the first time.

>
> Will> +  qfn->embeddeds =
> Will> +    XOBNEWVEC (&per_objfile->per_bfd->obstack, bool,
>
> gdb puts '=' on the continuation line.

Sorry for not respecting the style here. I tried really hard to make
sure that I was doing the right thing!

>
> Will> + fullname.reset (embedded_fullname (dirname, qfn->file_names[index]));
>
> embedded_fullname should return a unique_xmalloc_ptr so that this spot
> can be an assignment.  Maybe one spot needs a '.release ()' then.
>
> It's better to return these self-managing objects, since it makes leaks
> less likely.

I agree. I went back and forth on what type embedded_fullname should
return. Thank you for the feedback.

>
> Will> +  /* Because the line header may tell us information about the CU
> Will> +     filename (e.g., whether it is embedded) which will affect other
> Will> +     calculations, we have to read that information here.  */
> Will> +  line_header_up lh;
> Will> +  lh.reset (cu->line_header);
>
> This will wind up deleting cu->line_header, which I assume is not
> intended.  For one thing, dwarf2_cu::line_header seems to have a kind of
> complicated ownership situation.
>
> In gdb the "_up" suffix on a type means "unique pointer"; i.e., 'lh'
> will delete the memory when its destructor is run.

Agree. I have no idea how I didn't realize that. I do really like the
`_up` convention. Makes it very easy to read!

>
> Will> +   const char *include_name =
> Will> +     compute_include_file_name (lh.get (), entry, res, name_holder);
>
> '=' on 2nd line.
>
> Will> +   if (!include_name )
>
> gdb tends to spell this out, like: include_name == nullptr

See above for the apology and I will correct!

>
> Will> + {
> Will> +   sf->symtab = allocate_symtab (cust, sf->name.c_str (),
> Will> +                                 sf->name_for_id.c_str ());
> Will> +   if (fe.source)
> Will> +     sf->symtab->source = cu->per_objfile->objfile->intern (fe.source);
>
> You don't want to intern the source here.  That makes a copy.  If the
> source is in one of the debug sections, those are mapped during DWARF
> reading and not unmapped until the per-BFD object is destroyed.  Objects
> like this can safely be referred to by other symbol table data
> structure; there are a lot of cases of this in gdb.

I am terribly sorry -- you must think that I completely ignored your
previous feedback where you said the same thing. I didn't mean to
imply that. I simply screwed up my git history. I promise that I did
read and process your previous response!

>
> Will>  source_cache::get_plain_source_lines (struct symtab *s,
> Will>                                 const std::string &fullname)
> Will>  {
> Will> -  scoped_fd desc (open_source_file (s));
> Will> -  if (desc.get () < 0)
> Will> -    perror_with_name (symtab_to_filename_for_display (s), -desc.get ());
> Will> +  std::string lines;
>
> [...]
>
> Will> +  else
> Will> +    {
> Will> +      lines = s->source;
> Will> +    }
>
> gdb doesn't use braces when there's just a single statemnt.
>
> However, I suspect you will want a different factoring here.  This line
> makes a copy of the entire source text -- but a copy isn't needed here.
>
> Currently, get_plain_source_lines is written this way because it is
> reading from the filesystem, so the data has to go somewhere.
>
> Instead, what if the caller (source_cache::ensure) did the checking
> here?  Then it could make a string_view for the text -- either the
> saved source or the string returned by get_plain_source_lines.
>
> Then try_source_highlight and ext_lang_colorize could be changed to
> accept a string view instead.  (I'm not 100% sure this works, maybe just
> passing a 'const char *' is better, it depends on if this code assumes
> \0-termination.)
>
> source_cache::source_text will also need some kind of update, but that
> doesn't seem so bad either.
>
> This approach should avoid copying as much as possible.  It's maybe not
> possible to completely avoid it (I didn't look to see what the Pygments
> call does); but at least we can avoid it where it's not needed.

Thank you! I will process this and attempt to make a good v3.

>
> Will> +  if (s->source != NULL)
>
> We're slowly switching to nullptr.  There's a few cases of this.

Ack.

>
> Will> diff --git a/gdb/symtab.h b/gdb/symtab.h
> Will> index bf9a3cfb79f..1f871ee0a74 100644
> Will> --- a/gdb/symtab.h
> Will> +++ b/gdb/symtab.h
> Will> @@ -1755,6 +1755,8 @@ struct symtab
>
> Will>    const char *filename;
>
> Will> +  const char *source;
>
> This should have a comment.  Older code may sometimes be missing one,
> but we try to add one for anything new.

I thought I got all the places that needed a comment. Sorry!


>
> Will> +# Copyright 2022-2024 Free Software Foundation, Inc.
>
> Probably should just say 2024.
>
> Will> +set assign_m_line [gdb_get_line_number "main assign m"]
> Will> +gdb_test "frame" ".*main \\\(\\\) at \[^\r\n\]*:$assign_m_line\r\n.*"
> Will> +gdb_test "maintenance info symtabs missing-file.c" ".*source embedded in DWARF.*"
> Will> +gdb_test "maintenance info line-table missing-file.c" ".*symtab: Source embedded in DWARF.*"
> Will> +gdb_test "info source" ".*With embedded source.*"
>
> Probably some of these lines need to be broken up.
>
> Also I wonder if the output here is voluminous.  That can cause problems
> unless you use gdb_test_multiple.

Interesting! I will look into that!

>
> Will> diff --git a/include/dwarf2.h b/include/dwarf2.h
> Will> index b3d3731ee83..bf8bdcd608f 100644
> Will> --- a/include/dwarf2.h
> Will> +++ b/include/dwarf2.h
> Will> @@ -289,6 +289,7 @@ enum dwarf_line_number_content_type
> Will>      DW_LNCT_size = 0x4,
> Will>      DW_LNCT_MD5 = 0x5,
> Will>      DW_LNCT_lo_user = 0x2000,
> Will> +    DW_LNCT_LLVM_SOURCE = 0x2001,
>
> I think this needs some kind of comment as well.  Maybe a link to
> whatever spec or docs there are.  Look in dwarf2.{h,def} for "http" to
> see some examples.

Absolutely will add a link to the same doc linked in the commit message.

Thank you, again, for the comments. I really appreciate you being so welcoming!

Sincerely,
Will

>
> Tom

^ permalink raw reply	[relevance 0%]

* [PATCH v2] gdbserver, remote: introduce "id_str" in the "qXfer:threads:read" XML
  @ 2024-04-03 14:57  5% ` Tankut Baris Aktemur
  0 siblings, 0 replies; 200+ results
From: Tankut Baris Aktemur @ 2024-04-03 14:57 UTC (permalink / raw)
  To: gdb-patches

GDB prints the target id of a thread in various places such as the
output of the "info threads" command in the "Target Id" column or when
switching to a thread.  A target can define what to print for a given
ptid by overriding the `pid_to_str` method.

The remote target is a gateway behind which one of many various
targets could be running.  The remote target converts a given ptid to
a string in a uniform way, without consulting the low target at the
server-side.

In this patch we introduce a new attribute in the XML that is sent in
response to the "qXfer:threads:read" RSP packet, so that a low target
at the server side, if it wishes, can specify what to print as the
target id of a thread.

Note that the existing "name" attribute or the "extra" text provided
in the XML are not sufficient for the server-side low target to
achieve the goal.  Those attributes, when present, are simply appended
to the target id by GDB.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---
 gdb/NEWS            |  9 +++++++++
 gdb/doc/gdb.texinfo |  7 +++++--
 gdb/remote.c        | 26 +++++++++++++++++++++++++-
 gdbserver/server.cc |  4 ++++
 gdbserver/target.cc |  6 ++++++
 gdbserver/target.h  | 13 +++++++++++++
 6 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index feb3a37393a..2a0b08887a1 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -192,6 +192,15 @@ QThreadOptions in qSupported
   QThreadOptions packet, and the qSupported response can contain the
   set of thread options the remote stub supports.
 
+* Changed remote packets
+
+qXfer:threads:read
+
+  The XML that is sent as a response can now include an "id_str"
+  attribute for a thread element.  The attribute indicates what GDB
+  should print as the target ID of the thread, for example in the
+  "info threads" command or when switching to the thread.
+
 *** Changes in GDB 14
 
 * GDB now supports the AArch64 Scalable Matrix Extension 2 (SME2), which
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 82a617e9ad3..c72a070b223 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -48081,7 +48081,7 @@ the following structure:
 @smallexample
 <?xml version="1.0"?>
 <threads>
-    <thread id="id" core="0" name="name" handle="1a2b3c">
+    <thread id="id" core="0" name="name" id_str="Thread 12.34" handle="1a2b3c">
     ... description ...
     </thread>
 </threads>
@@ -48093,7 +48093,10 @@ identifies the thread (@pxref{thread-id syntax}).  The
 the thread was last executing on.  The @samp{name} attribute, if
 present, specifies the human-readable name of the thread.  The content
 of the of @samp{thread} element is interpreted as human-readable
-auxiliary information.  The @samp{handle} attribute, if present,
+auxiliary information.  The @samp{id_str} attribute, if present,
+specifies what @value{GDBN} should print as the target ID of the
+thread (e.g.@: in the @samp{info threads} command or when switching
+to the thread).  The @samp{handle} attribute, if present,
 is a hex encoded representation of the thread handle.
 
 
diff --git a/gdb/remote.c b/gdb/remote.c
index e278711df7b..e09a0c56eb3 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1537,6 +1537,12 @@ struct remote_thread_info : public private_thread_info
   std::string name;
   int core = -1;
 
+  /* The string representation for the thread's id.
+
+     The target specifies this if they want to display the thread id
+     in a specific way.  If empty, the default approach is used.  */
+  std::string id_str;
+
   /* Thread handle, perhaps a pthread_t or thread_t value, stored as a
      sequence of bytes.  */
   gdb::byte_vector thread_handle;
@@ -3951,6 +3957,9 @@ struct thread_item
   /* The thread's name.  */
   std::string name;
 
+  /* The thread's id, translated to a string for displaying.  */
+  std::string id_str;
+
   /* The core the thread was running on.  -1 if not known.  */
   int core = -1;
 
@@ -4077,6 +4086,10 @@ start_thread (struct gdb_xml_parser *parser,
   if (attr != NULL)
     item.name = (const char *) attr->value.get ();
 
+  attr = xml_find_attribute (attributes, "id_str");
+  if (attr != nullptr)
+    item.id_str = (const char *) attr->value.get ();
+
   attr = xml_find_attribute (attributes, "handle");
   if (attr != NULL)
     item.thread_handle = hex2bin ((const char *) attr->value.get ());
@@ -4098,6 +4111,7 @@ const struct gdb_xml_attribute thread_attributes[] = {
   { "id", GDB_XML_AF_NONE, NULL, NULL },
   { "core", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
   { "name", GDB_XML_AF_OPTIONAL, NULL, NULL },
+  { "id_str", GDB_XML_AF_OPTIONAL, NULL, NULL },
   { "handle", GDB_XML_AF_OPTIONAL, NULL, NULL },
   { NULL, GDB_XML_AF_NONE, NULL, NULL }
 };
@@ -4282,6 +4296,7 @@ remote_target::update_thread_list ()
 	      info->core = item.core;
 	      info->extra = std::move (item.extra);
 	      info->name = std::move (item.name);
+	      info->id_str = std::move (item.id_str);
 	      info->thread_handle = std::move (item.thread_handle);
 	    }
 	}
@@ -12228,7 +12243,16 @@ remote_target::pid_to_str (ptid_t ptid)
     {
       if (magic_null_ptid == ptid)
 	return "Thread <main>";
-      else if (m_features.remote_multi_process_p ())
+
+      thread_info *thread = this->find_thread (ptid);
+      if ((thread != nullptr) && (thread->priv != nullptr))
+	{
+	  remote_thread_info *priv = get_remote_thread_info (thread);
+	  if (!priv->id_str.empty ())
+	    return priv->id_str.c_str ();
+	}
+
+      if (m_features.remote_multi_process_p ())
 	if (ptid.lwp () == 0)
 	  return normal_pid_to_str (ptid);
 	else
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index c7d5cc1c1b0..018fbc04076 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1994,6 +1994,7 @@ handle_qxfer_threads_worker (thread_info *thread, std::string *buffer)
   int core = target_core_of_thread (ptid);
   char core_s[21];
   const char *name = target_thread_name (ptid);
+  std::string id_str = target_thread_id_str (thread);
   int handle_len;
   gdb_byte *handle;
   bool handle_status = target_thread_handle (ptid, &handle, &handle_len);
@@ -2018,6 +2019,9 @@ handle_qxfer_threads_worker (thread_info *thread, std::string *buffer)
   if (name != NULL)
     string_xml_appendf (*buffer, " name=\"%s\"", name);
 
+  if (!id_str.empty ())
+    string_xml_appendf (*buffer, " id_str=\"%s\"", id_str.c_str ());
+
   if (handle_status)
     {
       char *handle_s = (char *) alloca (handle_len * 2 + 1);
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 6db32da2e95..a26e1599975 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -807,6 +807,12 @@ process_stratum_target::thread_name (ptid_t thread)
   return nullptr;
 }
 
+std::string
+process_stratum_target::thread_id_str (thread_info *thread)
+{
+  return "";
+}
+
 bool
 process_stratum_target::thread_handle (ptid_t ptid, gdb_byte **handle,
 				       int *handle_len)
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 3643b9110da..a46b3fa47ff 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -475,6 +475,13 @@ class process_stratum_target
      caller.  */
   virtual const char *thread_name (ptid_t thread);
 
+  /* Return the string translation for THREAD's id.  This gives the
+     target a chance to completely re-interpret the thread id and
+     present a target-specific description for displaying to the user.
+     Return empty if the target is fine with how an id is displayed
+     by default.  */
+  virtual std::string thread_id_str (thread_info *thread);
+
   /* Thread ID to (numeric) thread handle: Return true on success and
      false for failure.  Return pointer to thread handle via HANDLE
      and the handle's length via HANDLE_LEN.  */
@@ -735,4 +742,10 @@ bool set_desired_process ();
 
 std::string target_pid_to_str (ptid_t);
 
+static inline std::string
+target_thread_id_str (thread_info *thread)
+{
+  return the_target->thread_id_str (thread);
+}
+
 #endif /* GDBSERVER_TARGET_H */
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 5%]

* [PATCH] Revert "gdb/compile: Use std::filesystem::remove_all in cleanup"
@ 2024-04-03 14:44 10% Lancelot SIX
  0 siblings, 0 replies; 200+ results
From: Lancelot SIX @ 2024-04-03 14:44 UTC (permalink / raw)
  To: gdb-patches, tdevries; +Cc: Lancelot SIX

This reverts commit 7bba0ad08576309763e3f41193eaa93025e10b8b.

Tom de Vries reported that 7bba0ad0857 (gdb/compile: Use
std::filesystem::remove_all in cleanup) broke builds with gcc-7.5.0
which mostly supports c++17, but not std::filesystem[1].  As this change
is not critical, revert it to maintain compatibility.

[1] https://inbox.sourceware.org/gdb-patches/a06e6483-aa2e-4b8a-854f-e369a1e961ea@suse.de/

Change-Id: I58150bd27600c95052bdf1bbbd6b44718a5a0bbf
---
 gdb/compile/compile.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index bff69a5092d..2d97a1b2005 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -39,9 +39,7 @@
 #include "osabi.h"
 #include "gdbsupport/gdb_wait.h"
 #include "valprint.h"
-#include <filesystem>
 #include <optional>
-#include <system_error>
 #include "gdbsupport/gdb_unlinker.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/scoped_ignore_signal.h"
@@ -451,11 +449,15 @@ get_compile_file_tempdir (void)
   tempdir_name = xstrdup (tempdir_name);
   add_final_cleanup ([] ()
     {
-      std::error_code error;
-      if (std::filesystem::remove_all (tempdir_name, error)
-	  == static_cast<std::uintmax_t> (-1))
-	warning (_("Could not remove temporary directory %s (%s)"),
-		 tempdir_name, error.message ().c_str ());
+      char *zap;
+      int wstat;
+
+      gdb_assert (startswith (tempdir_name, TMP_PREFIX));
+      zap = concat ("rm -rf ", tempdir_name, (char *) NULL);
+      wstat = system (zap);
+      if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0)
+	warning (_("Could not remove temporary directory %s"), tempdir_name);
+      XDELETEVEC (zap);
     });
   return tempdir_name;
 }

base-commit: 7bba0ad08576309763e3f41193eaa93025e10b8b
-- 
2.34.1


^ permalink raw reply	[relevance 10%]

* [PATCH] Add wildcard matching to substitute-path rules
@ 2024-04-01 21:26  3% Max Yvon Zimmermann
  0 siblings, 0 replies; 200+ results
From: Max Yvon Zimmermann @ 2024-04-01 21:26 UTC (permalink / raw)
  To: gdb-patches

Hi everyone!

I have developed a patch that allows for glob pattern matching within substitute-path rules.

Why is this useful?
Some build systems and/or package managers may copy the sources of a program before build. The path of this copy may not always be the same. In the case of conan (https://conan.io/) the path will consist of some constant part and some directory named with some hash value (i.e., /path/to/<unique hash>/builddir/). This hash will differ with each build, and therefore any source redirection within GDB must be reconfigured. This is, of course, really annoying when debugging a library. You might write a custom startup script for GDB to set the correct path automatically. But I thought it would be much more elegant if GDB would just support glob patterns (so that the rule /path/to/*/builddir/ would match any relevant build directory).

How does the patch work?
I wrote a custom glob matching function gdb_fileprefix_fnmatch() that is called from substitute_path_rule_matches() (maybe this function should be renamed because its meaning is slightly different now). It is located in utils.c. If you think this function should be defined at another location, let me know.
I considered just using fnmatch(), but I found that this is not viable for the problem at hand. fnmatch() matches a complete string, but I need to find the longest leading substring (and its length) that matches a given pattern. So calling fnmatch() multiple times would have quadratic complexity.
I also didn't want to add any additional dependencies.
Instead, I was inspired by git's implementation (https://github.com/git/git/blob/master/wildmatch.c) as well as fnmatch() from libiberty. It is recursive, but given that usually only a few (often just one) wildcards are used, this should not be an issue.

What must be considered?
This patch will break some (rather obscure) substitute-path rules. Any rule containing the characters '\', '?' and '*' must be rewritten to escape the aforementioned characters. This could get messy because backslashes must already be escaped in the GDB command line. Maybe another command (substitute-path-glob) should be introduced instead. Personally, I am ok with breaking stuff because it's only a small change to perform for the user, but that's not really my decision to make.
I have not implemented character sets yet. I don't really see use cases for them in this setting. But if you want me to add them for completeness, I would be willing to do so.
I also actively decided against implementing the '**' wildcard (match any string, also match directory separators), as this could lead to ambiguous matches.

Testing
I have created the 'gdb.base/subst-glob.exp' testsuite to test out the new feature. I also tested against 'gdb.base/subst.exp'. The tests were performed on GNU/Linux and Windows (MinGW). I did not find any regressions in the testsuite (on Linux).

Copyright
I have not yet signed any papers regarding FSF copyright assignment.

Please let me know what you think of this patch!
Thank you in advance,
Max

---
 gdb/NEWS                              |   5 +
 gdb/doc/gdb.texinfo                   |  29 +++++
 gdb/source.c                          |  77 ++++++++----
 gdb/testsuite/gdb.base/subst-glob.exp | 166 ++++++++++++++++++++++++++
 gdb/utils.c                           | 100 ++++++++++++++++
 gdb/utils.h                           |   2 +
 6 files changed, 356 insertions(+), 23 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/subst-glob.exp

diff --git a/gdb/NEWS b/gdb/NEWS
index feb3a37393a..5a041175507 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -90,6 +90,11 @@ show unwind-on-signal
   These new commands replaces the existing set/show unwindonsignal.  The
   old command is maintained as an alias.
 
+set substitute-path
+  This command now supports glob pattern matching for substitution
+  rules.  Wildcards '?' and '*' are supported.  Use '\' to escape
+  '?', '*' and '\' characters.
+
 * New features in the GDB remote stub, GDBserver
 
   ** The --remote-debug and --event-loop-debug command line options
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 727f9275bfb..bfd96afb5b4 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -9954,6 +9954,35 @@ For instance, if we had entered the following commands:
 use the second rule to rewrite @file{/usr/src/lib/foo.c} into
 @file{/mnt/src/lib/foo.c}.
 
+Rules can contain wildcards to match multiple paths.  The supported
+wildcards are @samp{?} (to match any single character) and @samp{*}
+(to match any string).  Wildcards will never match the path separator of
+the system.
+
+For instance, if we had entered the following command:
+
+@smallexample
+(@value{GDBP}) set substitute-path /usr/*/include /mnt/include
+@end smallexample
+
+@noindent
+@value{GDBN} would then rewrite @file{/usr/src/include/defs.h} into
+@file{/mnt/include/defs.h}.  Another file @file{/usr/local/include/inc.h}
+would be rewritten as @file{/mnt/include/inc.h} using the same rule.
+
+Use @samp{@backslashchar{}} to escape the characters @samp{?}@comma{}
+@samp{*} and @samp{@backslashchar{}}.  Note that you need to escape any
+@samp{@backslashchar{}} characters twice in the @value{GDBN} command line.
+
+So if we want to match a literal @samp{*} character in a rule, we would enter:
+
+@smallexample
+(@value{GDBP}) set substitute-path /foo\\*/bar /mnt/cross
+@end smallexample
+
+@noindent
+Now only the directory @file{/foo*/bar/} would match against the rule.
+
 
 @item unset substitute-path [path]
 @kindex unset substitute-path
diff --git a/gdb/source.c b/gdb/source.c
index 432301e2a71..2406e75a8b9 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -26,6 +26,7 @@
 #include "frame.h"
 #include "value.h"
 #include "gdbsupport/filestuff.h"
+#include "utils.h"
 
 #include <sys/types.h>
 #include <fcntl.h>
@@ -959,44 +960,48 @@ source_full_path_of (const char *filename,
   return 1;
 }
 
-/* Return non-zero if RULE matches PATH, that is if the rule can be
-   applied to PATH.  */
+/* Return the position in PATH up until RULE matches PATH, that is if the rule
+   can be applied to PATH.
+   Return -1 if there is no match.  */
 
 static int
 substitute_path_rule_matches (const struct substitute_path_rule *rule,
 			      const char *path)
 {
-  const int from_len = rule->from.length ();
-  const int path_len = strlen (path);
-
-  if (path_len < from_len)
-    return 0;
-
   /* The substitution rules are anchored at the start of the path,
      so the path should start with rule->from.  */
 
-  if (filename_ncmp (path, rule->from.c_str (), from_len) != 0)
-    return 0;
+  const int result = gdb_fileprefix_fnmatch (rule->from.c_str (), path);
 
-  /* Make sure that the region in the path that matches the substitution
-     rule is immediately followed by a directory separator (or the end of
-     string character).  */
+  if (result != -1)
+    {
+      /* Make sure that the region in the path that matches the substitution
+        rule is immediately followed by a directory separator (or the end of
+        string character).  */
 
-  if (path[from_len] != '\0' && !IS_DIR_SEPARATOR (path[from_len]))
-    return 0;
+      if (path[result] != '\0' && !IS_DIR_SEPARATOR (path[result]))
+        return -1;
+    }
 
-  return 1;
+  return result;
 }
 
 /* Find the substitute-path rule that applies to PATH and return it.
+   Also set SUB_POS to the position in PATH up until the rule matches PATH.
    Return NULL if no rule applies.  */
 
 static struct substitute_path_rule *
-get_substitute_path_rule (const char *path)
+get_substitute_path_rule (const char *path, int &sub_pos)
 {
   for (substitute_path_rule &rule : substitute_path_rules)
-    if (substitute_path_rule_matches (&rule, path))
-      return &rule;
+    {
+      const int result = substitute_path_rule_matches (&rule, path);
+      if (result != -1)
+        {
+          sub_pos = result;
+          return &rule;
+        }
+    }
 
   return nullptr;
 }
@@ -1010,7 +1015,8 @@ get_substitute_path_rule (const char *path)
 gdb::unique_xmalloc_ptr<char>
 rewrite_source_path (const char *path)
 {
-  const struct substitute_path_rule *rule = get_substitute_path_rule (path);
+  int sub_pos;
+  const struct substitute_path_rule *rule = get_substitute_path_rule (path, sub_pos);
 
   if (rule == nullptr)
     return nullptr;
@@ -1018,7 +1024,7 @@ rewrite_source_path (const char *path)
   /* Compute the rewritten path and return it.  */
 
   return (gdb::unique_xmalloc_ptr<char>
-	  (concat (rule->to.c_str (), path + rule->from.length (), nullptr)));
+	  (concat (rule->to.c_str (), path + sub_pos, nullptr)));
 }
 
 /* See source.h.  */
@@ -1718,6 +1724,31 @@ strip_trailing_directory_separator (char *path)
     path[last] = '\0';
 }
 
+/* If the last character of PATH is a directory separator, then strip it.
+   Also remove any related escape character.  */
+
+static void
+strip_trailing_directory_separator_and_escape (char *path)
+{
+  int last = strlen (path) - 1;
+
+  if (last < 0)
+    return;  /* No stripping is needed if PATH is the empty string.  */
+
+  if (IS_DIR_SEPARATOR (path[last]))
+    {
+      path[last] = '\0';
+
+      if (path[last] != '\\')
+        return;
+
+      --last;
+      /* Remove any related escape character.  */
+      if (last >= 0 && path[last] == '\\')
+        path[last] = '\0';
+    }
+}
+
 /* Add a new substitute-path rule at the end of the current list of rules.
    The new rule will replace FROM into TO.  */
 
@@ -1754,7 +1785,7 @@ show_substitute_path_command (const char *args, int from_tty)
 
   for (substitute_path_rule &rule : substitute_path_rules)
     {
-      if (from == NULL || substitute_path_rule_matches (&rule, from) != 0)
+      if (from == NULL || substitute_path_rule_matches (&rule, from) != -1)
 	gdb_printf ("  `%s' -> `%s'.\n", rule.from.c_str (),
 		    rule.to.c_str ());
     }
@@ -1830,7 +1861,7 @@ set_substitute_path_command (const char *args, int from_tty)
 
   /* Strip any trailing directory separator character in either FROM
      or TO.  The substitution rule already implicitly contains them.  */
-  strip_trailing_directory_separator (argv[0]);
+  strip_trailing_directory_separator_and_escape (argv[0]);
   strip_trailing_directory_separator (argv[1]);
 
   /* If a rule with the same "from" was previously defined, then
diff --git a/gdb/testsuite/gdb.base/subst-glob.exp b/gdb/testsuite/gdb.base/subst-glob.exp
new file mode 100644
index 00000000000..74dec472b7a
--- /dev/null
+++ b/gdb/testsuite/gdb.base/subst-glob.exp
@@ -0,0 +1,166 @@
+# Copyright 2006-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+clean_restart
+
+# Do a bunch of testing of the substitute-path glob pattern matching.
+
+gdb_test_no_output "set confirm off" \
+        "deactivate GDB's confirmation interface"
+
+proc test_pattern { pattern path mode } {
+    # Escape backslashes so the GDB console can unescape them again.
+    set terminal_pattern [ \
+        string map { \
+            "\\" "\\\\" \
+        } $pattern \
+    ]
+
+    # Escape the pattern for regex matching.
+    set match_pattern [ \
+        string map { \
+            "*"  "\\\\*" \
+            "?"  "\\\\?" \
+            "\\" "\\\\\\\\" \
+        } $pattern \
+    ]
+
+    # Handle stripping of path separators.
+    if {[ishost "*-mingw*"]} {
+        regsub {\\\\\\\\\\\\|/$} $match_pattern {} match_pattern
+        set match_pattern [subst $match_pattern]
+    } else {
+        regsub {/$} $match_pattern {} match_pattern
+        set match_pattern [subst $match_pattern]
+    }
+
+    # Escape backslashes so the GDB console can unescape them again.
+    set terminal_path [ \
+        string map { \
+            "\\" "\\\\" \
+        } $path \
+    ]
+    
+    # Escape the path for regex matching.
+    set match_path [ \
+        string map { \
+            "*"  "\\*" \
+            "?"  "\\?" \
+            "\\" "\\\\" \
+        } $path \
+    ]
+    
+    gdb_test_no_output "unset substitute-path" \
+        "unset substitute-path before testing '$terminal_pattern' matches '$terminal_path'"
+
+    gdb_test_no_output "set substitute-path \"$terminal_pattern\" \"to\"" \
+        "set substitute-path $terminal_pattern before testing '$terminal_pattern' matches '$terminal_path'"
+    
+    if {$mode == 1} {
+        gdb_test "show substitute-path \"$terminal_path\"" \
+            "Source path substitution rule matching `$match_path':\r\n +`$match_pattern' -> `to'." \
+            "testing '$terminal_pattern' matches '$terminal_path'"
+    } else {
+        gdb_test "show substitute-path \"$terminal_path\"" \
+            "Source path substitution rule matching `$match_path':" \
+            "testing '$terminal_pattern' does not match '$terminal_path'"
+    }
+}
+
+proc test_pattern_pos { pattern path } {
+    test_pattern $pattern $path 1
+}
+
+proc test_pattern_neg { pattern path } {
+    test_pattern $pattern $path 0
+}
+
+# Sanity checks.
+test_pattern_pos "path" "path"
+test_pattern_pos "path" "path/to"
+test_pattern_pos "/" "/test"
+test_pattern_pos "/testing" "/testing/test"
+test_pattern_pos "/testing/" "/testing/test"
+test_pattern_neg "path" "test"
+
+# '?' wildcard.
+test_pattern_pos "?atchone" "matchone"
+test_pattern_pos "pat?/to" "path/to"
+test_pattern_pos "path??" "pathto"
+test_pattern_pos "test?ng" "testing"
+test_pattern_pos "?" "?/test"
+test_pattern_neg "test?" "test/"
+test_pattern_neg "test?" "testing/"
+test_pattern_neg "?" ""
+
+# '*' wildcard.
+test_pattern_pos "*" "matchall"
+test_pattern_pos "path_*" "path_pattern"
+test_pattern_pos "test*/test" "testing/test"
+test_pattern_pos "test*" "testing/test"
+test_pattern_pos "test*" "test/test"
+test_pattern_pos "*" "testing/test"
+test_pattern_pos "*/*" "testing/test"
+test_pattern_pos "*/" "test/"
+test_pattern_pos "/*" "/test"
+test_pattern_pos "test*" "test/"
+test_pattern_pos "test*" "test"
+test_pattern_pos "test*test" "testtest"
+test_pattern_pos "test*test" "testingtest"
+test_pattern_pos "test*test" "testingtest/test"
+test_pattern_pos "*" "*test"
+test_pattern_pos "**" "t"
+test_pattern_pos "*" ""
+test_pattern_pos "*t*st" "foobartest"
+test_pattern_pos "*t*st" "foobartest/ing"
+test_pattern_pos "*t*st" "tetest"
+test_pattern_pos "*t*st" "tetest/ing"
+test_pattern_pos "*t*st" "testtest"
+test_pattern_pos "*t*st" "testtest/ing"
+test_pattern_neg "*test" "foobar"
+test_pattern_neg "*/test" "foo/bar"
+
+# Escapes.
+test_pattern_pos "\\\\" "\\"
+test_pattern_pos "\\\\*" "\\test"
+test_pattern_pos "*\\\\" "test\\"
+test_pattern_pos "\\\\/" "\\/"
+test_pattern_pos "\\*" "*"
+test_pattern_pos "\\?" "?"
+test_pattern_pos "\\*" "*/test"
+test_pattern_pos "\\?" "?/test"
+test_pattern_neg "\\*" "*test"
+test_pattern_neg "\\?" "?test"
+test_pattern_neg "\\*" "t"
+test_pattern_neg "\\?" "t"
+test_pattern_neg "\\" "test"
+test_pattern_neg "\\/" ""
+test_pattern_neg "\\/" "/test"
+
+if {[ishost "*-mingw*"]} {
+    # DOS tests.
+    test_pattern_pos "test" "TEST"
+    test_pattern_pos "/" "\\test"
+    test_pattern_pos "\\\\" "/test"
+    test_pattern_pos "*\\\\" "test/"
+}
+
+if {[ishost "*-linux*"]} {
+    # Unix tests.
+    test_pattern_neg "test" "TEST"
+    test_pattern_neg "/" "\\test"
+    test_pattern_neg "\\\\" "/test"
+    test_pattern_neg "*\\\\" "test/"
+}
diff --git a/gdb/utils.c b/gdb/utils.c
index ded03c74099..00597543051 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3532,6 +3532,106 @@ gdb_filename_fnmatch (const char *pattern, const char *string, int flags)
   return fnmatch (pattern, string, flags);
 }
 
+/* Return the position in STRING up until a PATTERN expression is matched.
+   Return -1 if there is no match.
+   
+   Only the wildcards ? and * are supported. */
+
+int
+gdb_fileprefix_fnmatch (const char *pattern, const char *string)
+{
+  int string_pos = 0;
+  char pattern_c;
+  char string_c;
+
+  while (*pattern != '\0' && *string != '\0')
+    {
+      switch (*pattern)
+        {
+        /* Unescape and match the next character.  */
+        case '\\':
+          ++pattern;
+          if (*pattern == '\0')
+            return -1;
+          [[fallthrough]];
+
+        default:
+          pattern_c = *pattern;
+          string_c = *string;
+
+#ifdef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
+          pattern_c = TOLOWER (pattern_c);
+          string_c = TOLOWER (string_c);
+#endif
+
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+          /* On DOS-based file systems, the '/' and the '\' are equivalent.  */
+          if (pattern_c == '/')
+            pattern_c = '\\';
+          if (string_c == '/')
+            string_c = '\\';
+#endif
+
+          /* Compare the current character of the pattern with the path.  */
+          if (pattern_c != string_c)
+            return -1;
+          break;
+
+        /* Match any character.  */
+        case '?':
+          /* Directory separators are not matched by '?'.  */
+          if (IS_DIR_SEPARATOR (*string))
+            return -1;
+          break;
+
+        /* Match any string.  */
+        case '*':
+          int best_result = -1;
+
+          /* Try to match any folling substring.  */
+          while (true)
+            {
+              /* Most of these attempts will fail at the first character. */
+              int result = gdb_fileprefix_fnmatch (pattern+1, string);
+
+              if (result != -1)
+                {
+                  /* If there is a substring match, compare its result to the best
+                    candidate so far.  */
+                  result += string_pos;
+                  if (result > best_result)
+                    best_result = result;
+                }
+
+              /* Exit on a null byte or a directory separator.  */
+              if (*string == '\0' || IS_DIR_SEPARATOR (*string))
+                return best_result;
+
+              ++string;
+              ++string_pos;
+            }
+        }
+    
+        ++pattern;
+        ++string;
+        ++string_pos;
+      }
+
+  /* If the macthing is complete but there is still some of the pattern left,
+     we must ensure that the remaining pattern matches the empty string.  */
+  if (*pattern != '\0')
+    {
+      /* Only '*' can match the empty string.  */
+      while (*pattern == '*')
+        ++pattern;
+
+      if (*pattern != '\0')
+        return -1;
+    }
+
+  return string_pos;
+}
+
 /* Return the number of path elements in PATH.
    / = 1
    /foo = 2
diff --git a/gdb/utils.h b/gdb/utils.h
index 875a2583179..eaf3fe8a8c3 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -137,6 +137,8 @@ struct set_batch_flag_and_restore_page_info
 extern int gdb_filename_fnmatch (const char *pattern, const char *string,
 				 int flags);
 
+extern int gdb_fileprefix_fnmatch (const char *pattern, const char *string);
+
 extern void substitute_path_component (char **stringp, const char *from,
 				       const char *to);
 
-- 
2.34.1

^ permalink raw reply	[relevance 3%]

* [PATCHv10 9/9] gdb: only insert thread-specific breakpoints in the relevant inferior
  @ 2024-03-31 10:31 11%   ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-03-31 10:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess, Eli Zaretskii

This commit updates GDB so that thread or inferior specific
breakpoints are only inserted into the program space in which the
specific thread or inferior is running.

In terms of implementation, getting this basically working is easy
enough, now that a breakpoint's thread or inferior field is setup
prior to GDB looking for locations, we can easily use this information
to find a suitable program_space and pass this to as a filter when
creating the sals.

Or we could if breakpoint_ops::create_sals_from_location_spec allowed
us to pass in a filter program_space.

So, this commit extends breakpoint_ops::create_sals_from_location_spec
to take a program_space argument, and uses this to filter the set of
returned sals.  This accounts for about half the change in this patch.

The second set of changes starts from breakpoint_set_thread and
breakpoint_set_inferior, this is called when the thread or inferior
for a breakpoint changes, e.g. from the Python API.

Previously this call would never result in the locations of a
breakpoint changing, after all, locations were inserted in every
program space, and we just use the thread or inferior variable to
decide when we should stop.  Now though, changing a breakpoint's
thread or inferior can mean we need to figure out a new set of
breakpoint locations.

To support this I've added a new breakpoint_re_set_one function, which
is like breakpoint_re_set, but takes a single breakpoint, and just
updates the locations for that one breakpoint.  We only need to call
this function if the program_space in which a breakpoint's thread (or
inferior) is running actually changes.  If the program_space does
change then we call the new breakpoint_re_set_one function passing in
the program_space which should be used to filter the new locations (or
nullptr to indicate we should set locations in all program spaces).
This filter program_space needs to propagate down to all the re_set
methods, this accounts for the remaining half of the changes in this
patch.

There were a couple of existing tests that created thread or inferior
specific breakpoints and then checked the 'info breakpoints' output,
these needed updating.  These were:

  gdb.mi/user-selected-context-sync.exp
  gdb.multi/bp-thread-specific.exp
  gdb.multi/multi-target-continue.exp
  gdb.multi/multi-target-ping-pong-next.exp
  gdb.multi/tids.exp
  gdb.mi/new-ui-bp-deleted.exp
  gdb.multi/inferior-specific-bp.exp
  gdb.multi/pending-bp-del-inferior.exp

I've also added some additional tests to:

  gdb.multi/pending-bp.exp

I've updated the documentation and added a NEWS entry.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---
 gdb/NEWS                                      |   7 +
 gdb/ada-lang.c                                |   6 +-
 gdb/break-catch-throw.c                       |   6 +-
 gdb/breakpoint.c                              | 280 ++++++++++++++----
 gdb/breakpoint.h                              |  29 +-
 gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp    |   8 +-
 .../gdb.mi/user-selected-context-sync.exp     |  14 +-
 .../gdb.multi/bp-thread-specific.exp          |   7 +-
 .../gdb.multi/inferior-specific-bp.exp        |  12 +-
 .../gdb.multi/multi-target-continue.exp       |   2 +-
 .../gdb.multi/multi-target-ping-pong-next.exp |   4 +-
 .../gdb.multi/pending-bp-del-inferior.exp     |   6 +-
 gdb/testsuite/gdb.multi/pending-bp.exp        | 206 +++++++++++++
 gdb/testsuite/gdb.multi/tids.exp              |   6 +-
 14 files changed, 486 insertions(+), 107 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index fa2d1427ded..8ccc9e1199d 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -20,6 +20,13 @@
   'thread' or 'task' keywords are parsed at the time the breakpoint is
   created, rather than at the time the breakpoint becomes non-pending.
 
+* Thread-specific breakpoints are only inserted into the program space
+  in which the thread of interest is running.  In most cases program
+  spaces are unique for each inferior, so this means that
+  thread-specific breakpoints will usually only be inserted for the
+  inferior containing the thread of interest.  The breakpoint will
+  be hit no less than before.
+
 * Changed commands
 
 disassemble
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index c9f12d72b70..8492ad06306 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12051,11 +12051,11 @@ struct ada_catchpoint : public code_breakpoint
     enable_state = enabled ? bp_enabled : bp_disabled;
     language = language_ada;
 
-    re_set ();
+    re_set (pspace);
   }
 
   struct bp_location *allocate_location () override;
-  void re_set () override;
+  void re_set (program_space *pspace) override;
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (const bp_location **) const override;
@@ -12100,7 +12100,7 @@ static struct symtab_and_line ada_exception_sal
    catchpoint kinds.  */
 
 void
-ada_catchpoint::re_set ()
+ada_catchpoint::re_set (program_space *pspace)
 {
   std::vector<symtab_and_line> sals;
   try
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index ce614ac8fe3..c24f38d6272 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -81,10 +81,10 @@ struct exception_catchpoint : public code_breakpoint
 				     _("invalid type-matching regexp")))
   {
     pspace = current_program_space;
-    re_set ();
+    re_set (pspace);
   }
 
-  void re_set () override;
+  void re_set (program_space *pspace) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (const bp_location **) const override;
   void print_mention () const override;
@@ -197,7 +197,7 @@ exception_catchpoint::check_status (struct bpstat *bs)
 /* Implement the 're_set' method.  */
 
 void
-exception_catchpoint::re_set ()
+exception_catchpoint::re_set (program_space *pspace)
 {
   std::vector<symtab_and_line> sals;
   struct program_space *filter_pspace = current_program_space;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 5e9a030536e..3bc92ceb865 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -90,9 +90,12 @@
 static void map_breakpoint_numbers (const char *,
 				    gdb::function_view<void (breakpoint *)>);
 
-static void
-  create_sals_from_location_spec_default (location_spec *locspec,
-					  linespec_result *canonical);
+static void parse_breakpoint_sals (location_spec *locspec,
+				   linespec_result *canonical,
+				   program_space *search_pspace);
+
+static void breakpoint_re_set_one (breakpoint *b,
+				   program_space *filter_pspace);
 
 static void create_breakpoints_sal (struct gdbarch *,
 				    struct linespec_result *,
@@ -282,11 +285,12 @@ static bool strace_marker_p (struct breakpoint *b);
 
 static void bkpt_probe_create_sals_from_location_spec
      (location_spec *locspec,
-      struct linespec_result *canonical);
+      struct linespec_result *canonical,
+      struct program_space *search_pspace);
 
 const struct breakpoint_ops code_breakpoint_ops =
 {
-  create_sals_from_location_spec_default,
+  parse_breakpoint_sals,
   create_breakpoints_sal,
 };
 
@@ -351,7 +355,7 @@ struct internal_breakpoint : public code_breakpoint
     disposition = disp_donttouch;
   }
 
-  void re_set () override;
+  void re_set (program_space *pspace) override;
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   void print_mention () const override;
@@ -388,7 +392,7 @@ struct momentary_breakpoint : public code_breakpoint
     gdb_assert (inferior == -1);
   }
 
-  void re_set () override;
+  void re_set (program_space *pspace) override;
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   void print_mention () const override;
@@ -399,7 +403,7 @@ struct dprintf_breakpoint : public ordinary_breakpoint
 {
   using ordinary_breakpoint::ordinary_breakpoint;
 
-  void re_set () override;
+  void re_set (program_space *pspace) override;
   int breakpoint_hit (const struct bp_location *bl,
 		      const address_space *aspace,
 		      CORE_ADDR bp_addr,
@@ -1548,7 +1552,36 @@ breakpoint_set_thread (struct breakpoint *b, int thread)
   int old_thread = b->thread;
   b->thread = thread;
   if (old_thread != thread)
-    notify_breakpoint_modified (b);
+    {
+      /* If THREAD is in a different program_space than OLD_THREAD, or the
+	 breakpoint has switched to or from being thread-specific, then we
+	 need to re-set the locations of this breakpoint.  First, figure
+	 out the program_space for the old and new threads, use a value of
+	 nullptr to indicate the breakpoint is in all program spaces.  */
+      program_space *old_pspace = nullptr;
+      if (old_thread != -1)
+	{
+	  struct thread_info *thr = find_thread_global_id (old_thread);
+	  gdb_assert (thr != nullptr);
+	  old_pspace = thr->inf->pspace;
+	}
+
+      program_space *new_pspace = nullptr;
+      if (thread != -1)
+	{
+	  struct thread_info *thr = find_thread_global_id (thread);
+	  gdb_assert (thr != nullptr);
+	  new_pspace = thr->inf->pspace;
+	}
+
+      /* If the program space has changed for this breakpoint, then
+	 re-evaluate it's locations.  */
+      if (old_pspace != new_pspace)
+	breakpoint_re_set_one (b, new_pspace);
+
+      /* Let others know the breakpoint has changed.  */
+      notify_breakpoint_modified (b);
+    }
 }
 
 /* See breakpoint.h.  */
@@ -1567,7 +1600,34 @@ breakpoint_set_inferior (struct breakpoint *b, int inferior)
   int old_inferior = b->inferior;
   b->inferior = inferior;
   if (old_inferior != inferior)
-    notify_breakpoint_modified (b);
+    {
+      /* If INFERIOR is in a different program_space than OLD_INFERIOR, or
+	 the breakpoint has switch to or from inferior-specific, then we
+	 need to re-set the locations of this breakpoint.  First, figure
+	 out the program_space for the old and new inferiors, use a value
+	 of nullptr to indicate the breakpoint is in all program
+	 spaces.  */
+      program_space *old_pspace = nullptr;
+      if (old_inferior != -1)
+	{
+	  struct inferior *inf = find_inferior_id (old_inferior);
+	  gdb_assert (inf != nullptr);
+	  old_pspace = inf->pspace;
+	}
+
+      program_space *new_pspace = nullptr;
+      if (inferior != -1)
+	{
+	  struct inferior *inf = find_inferior_id (inferior);
+	  gdb_assert (inf != nullptr);
+	  new_pspace = inf->pspace;
+	}
+
+      if (old_pspace != new_pspace)
+	breakpoint_re_set_one (b, new_pspace);
+
+      notify_breakpoint_modified (b);
+    }
 }
 
 /* See breakpoint.h.  */
@@ -8800,7 +8860,8 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
 
 static void
 parse_breakpoint_sals (location_spec *locspec,
-		       struct linespec_result *canonical)
+		       struct linespec_result *canonical,
+		       struct program_space *search_pspace)
 {
   struct symtab_and_line cursal;
 
@@ -8865,7 +8926,7 @@ parse_breakpoint_sals (location_spec *locspec,
 	      && strchr ("+-", spec[0]) != NULL
 	      && spec[1] != '['))
 	{
-	  decode_line_full (locspec, DECODE_LINE_FUNFIRSTLINE, NULL,
+	  decode_line_full (locspec, DECODE_LINE_FUNFIRSTLINE, search_pspace,
 			    get_last_displayed_symtab (),
 			    get_last_displayed_line (),
 			    canonical, NULL, NULL);
@@ -8873,7 +8934,7 @@ parse_breakpoint_sals (location_spec *locspec,
 	}
     }
 
-  decode_line_full (locspec, DECODE_LINE_FUNFIRSTLINE, NULL,
+  decode_line_full (locspec, DECODE_LINE_FUNFIRSTLINE, search_pspace,
 		    cursal.symtab, cursal.line, canonical, NULL, NULL);
 }
 
@@ -8972,6 +9033,39 @@ breakpoint_ops_for_location_spec_type (enum location_spec_type locspec_type,
     }
 }
 
+/* Return the program space to use as a filter when searching for locations
+   of a breakpoint specific to THREAD or INFERIOR.  If THREAD and INFERIOR
+   are both -1, meaning all threads/inferiors, then this function returns
+   nullptr, indicating no program space filtering should be performed.
+   Otherwise, this function returns the program space for the inferior that
+   contains THREAD (when THREAD is not -1), or the program space for
+   INFERIOR (when INFERIOR is not -1).  */
+
+static struct program_space *
+find_program_space_for_breakpoint (int thread, int inferior)
+{
+  if (thread != -1)
+    {
+      gdb_assert (inferior == -1);
+
+      struct thread_info *thr = find_thread_global_id (thread);
+      gdb_assert (thr != nullptr);
+      gdb_assert (thr->inf != nullptr);
+      return thr->inf->pspace;
+    }
+  else if (inferior != -1)
+    {
+      gdb_assert (thread == -1);
+
+      struct inferior *inf = find_inferior_id (inferior);
+      gdb_assert (inf != nullptr);
+
+      return inf->pspace;
+    }
+
+  return nullptr;
+}
+
 /* See breakpoint.h.  */
 
 const struct breakpoint_ops *
@@ -9073,7 +9167,10 @@ create_breakpoint (struct gdbarch *gdbarch,
 
   try
     {
-      ops->create_sals_from_location_spec (locspec, &canonical);
+      struct program_space *search_pspace
+	= find_program_space_for_breakpoint (thread, inferior);
+      ops->create_sals_from_location_spec (locspec, &canonical,
+					   search_pspace);
     }
   catch (const gdb_exception_error &e)
     {
@@ -9546,7 +9643,7 @@ break_range_command (const char *arg, int from_tty)
   arg_start = arg;
   location_spec_up start_locspec
     = string_to_location_spec (&arg, current_language);
-  parse_breakpoint_sals (start_locspec.get (), &canonical_start);
+  parse_breakpoint_sals (start_locspec.get (), &canonical_start, nullptr);
 
   if (arg[0] != ',')
     error (_("Too few arguments."));
@@ -9647,7 +9744,7 @@ watchpoint_exp_is_const (const struct expression *exp)
 /* Implement the "re_set" method for watchpoints.  */
 
 void
-watchpoint::re_set ()
+watchpoint::re_set (struct program_space *pspace)
 {
   /* Watchpoint can be either on expression using entirely global
      variables, or it can be on local variables.
@@ -11758,7 +11855,7 @@ breakpoint::print_recreate (struct ui_file *fp) const
 /* Default breakpoint_ops methods.  */
 
 void
-code_breakpoint::re_set ()
+code_breakpoint::re_set (struct program_space *pspace)
 {
   /* FIXME: is this still reachable?  */
   if (breakpoint_location_spec_empty_p (this))
@@ -11768,7 +11865,7 @@ code_breakpoint::re_set ()
       return;
     }
 
-  re_set_default ();
+  re_set_default (pspace);
 }
 
 int
@@ -11974,7 +12071,7 @@ code_breakpoint::decode_location_spec (location_spec *locspec,
 /* Virtual table for internal breakpoints.  */
 
 void
-internal_breakpoint::re_set ()
+internal_breakpoint::re_set (struct program_space *pspace)
 {
   switch (type)
     {
@@ -12067,7 +12164,7 @@ internal_breakpoint::print_mention () const
 /* Virtual table for momentary breakpoints  */
 
 void
-momentary_breakpoint::re_set ()
+momentary_breakpoint::re_set (struct program_space *pspace)
 {
   /* Keep temporary breakpoints, which can be encountered when we step
      over a dlopen call and solib_add is resetting the breakpoints.
@@ -12108,12 +12205,13 @@ longjmp_breakpoint::~longjmp_breakpoint ()
 
 static void
 bkpt_probe_create_sals_from_location_spec (location_spec *locspec,
-					   struct linespec_result *canonical)
+					   struct linespec_result *canonical,
+					   struct program_space *search_pspace)
 
 {
   struct linespec_sals lsal;
 
-  lsal.sals = parse_probes (locspec, NULL, canonical);
+  lsal.sals = parse_probes (locspec, search_pspace, canonical);
   lsal.canonical = xstrdup (canonical->locspec->to_string ());
   canonical->lsals.push_back (std::move (lsal));
 }
@@ -12203,9 +12301,9 @@ tracepoint::print_recreate (struct ui_file *fp) const
 }
 
 void
-dprintf_breakpoint::re_set ()
+dprintf_breakpoint::re_set (struct program_space *pspace)
 {
-  re_set_default ();
+  re_set_default (pspace);
 
   /* 1 - connect to target 1, that can run breakpoint commands.
      2 - create a dprintf, which resolves fine.
@@ -12259,8 +12357,10 @@ dprintf_breakpoint::after_condition_true (struct bpstat *bs)
    markers (`-m').  */
 
 static void
-strace_marker_create_sals_from_location_spec (location_spec *locspec,
-					      struct linespec_result *canonical)
+strace_marker_create_sals_from_location_spec
+	(location_spec *locspec,
+	 struct linespec_result *canonical,
+	 struct program_space *search_pspace)
 {
   struct linespec_sals lsal;
   const char *arg_start, *arg;
@@ -12777,12 +12877,32 @@ update_breakpoint_locations (code_breakpoint *b,
      all locations are in the same shared library, that was unloaded.
      We'd like to retain the location, so that when the library is
      loaded again, we don't loose the enabled/disabled status of the
-     individual locations.  */
+     individual locations.
+
+     Thread specific breakpoints will also trigger this case if the thread
+     is changed to a different program space, and all of the old locations
+     go out of scope.  In this case we do (currently) discard the old
+     locations -- we assume the change in thread is permanent and the old
+     locations will never come back into scope.  */
   if (all_locations_are_pending (b, filter_pspace) && sals.empty ())
-    return;
+    {
+      if (b->thread != -1)
+	b->clear_locations ();
+      return;
+    }
 
   bp_location_list existing_locations = b->steal_locations (filter_pspace);
 
+  /* If this is a thread-specific breakpoint then any locations left on the
+     breakpoint are for a program space in which the thread of interest
+     does not operate.  This can happen when the user changes the thread of
+     a thread-specific breakpoint.
+
+     We assume that the change in thread is permanent, and that the old
+     locations will never be used again, so discard them now.  */
+  if (b->thread != -1)
+    b->clear_locations ();
+
   for (const auto &sal : sals)
     {
       struct bp_location *new_loc;
@@ -12948,40 +13068,45 @@ code_breakpoint::location_spec_to_sals (location_spec *locspec,
    locations.  */
 
 void
-code_breakpoint::re_set_default ()
+code_breakpoint::re_set_default (struct program_space *filter_pspace)
 {
-  struct program_space *filter_pspace = current_program_space;
   std::vector<symtab_and_line> expanded, expanded_end;
 
-  int found;
-  std::vector<symtab_and_line> sals = location_spec_to_sals (locspec.get (),
-							     filter_pspace,
-							     &found);
-  if (found)
-    expanded = std::move (sals);
-
-  if (locspec_range_end != nullptr)
-    {
-      std::vector<symtab_and_line> sals_end
-	= location_spec_to_sals (locspec_range_end.get (),
-				 filter_pspace, &found);
+  /* If this breakpoint is thread-specific then find the program space in
+     which the specific thread exists.  Otherwise, for breakpoints that are
+     not thread-specific THREAD_PSPACE will be nullptr.  */
+  program_space *bp_pspace
+    = find_program_space_for_breakpoint (this->thread, this->inferior);
+
+  /* If this is not a thread or inferior specific breakpoint, or it is a
+     thread or inferior specific breakpoint but we are looking for new
+     locations in the program space that the specific thread or inferior is
+     running, then look for new locations for this breakpoint.  */
+  if (bp_pspace == nullptr || filter_pspace == bp_pspace)
+    {
+      int found;
+      std::vector<symtab_and_line> sals
+	= location_spec_to_sals (locspec.get (), filter_pspace, &found);
       if (found)
-	expanded_end = std::move (sals_end);
+	expanded = std::move (sals);
+
+      if (locspec_range_end != nullptr)
+	{
+	  std::vector<symtab_and_line> sals_end
+	    = location_spec_to_sals (locspec_range_end.get (),
+				     filter_pspace, &found);
+	  if (found)
+	    expanded_end = std::move (sals_end);
+	}
     }
 
+  /* Update the locations for this breakpoint.  For thread-specific
+     breakpoints this will remove any old locations that are for the wrong
+     program space -- this can happen if the user changes the thread of a
+     thread-specific breakpoint.  */
   update_breakpoint_locations (this, filter_pspace, expanded, expanded_end);
 }
 
-/* Default method for creating SALs from an address string.  It basically
-   calls parse_breakpoint_sals.  Return 1 for success, zero for failure.  */
-
-static void
-create_sals_from_location_spec_default (location_spec *locspec,
-					struct linespec_result *canonical)
-{
-  parse_breakpoint_sals (locspec, canonical);
-}
-
 /* Re-set breakpoint locations for the current program space.
    Locations bound to other program spaces are left untouched.  */
 
@@ -13016,7 +13141,7 @@ breakpoint_re_set (void)
 	  {
 	    input_radix = b.input_radix;
 	    set_language (b.language);
-	    b.re_set ();
+	    b.re_set (current_program_space);
 	  }
 	catch (const gdb_exception &ex)
 	  {
@@ -13037,6 +13162,53 @@ breakpoint_re_set (void)
   /* Now we can insert.  */
   update_global_location_list (UGLL_MAY_INSERT);
 }
+
+/* Re-set locations for breakpoint B in FILTER_PSPACE.  If FILTER_PSPACE is
+   nullptr then re-set locations for B in all program spaces.  Locations
+   bound to program spaces other than FILTER_PSPACE are left untouched.  */
+
+static void
+breakpoint_re_set_one (breakpoint *b, program_space *filter_pspace)
+{
+  {
+    scoped_restore_current_language save_language;
+    scoped_restore save_input_radix = make_scoped_restore (&input_radix);
+    scoped_restore_current_pspace_and_thread restore_pspace_thread;
+
+    /* To ::re_set each breakpoint we set the current_language to the
+       language of the breakpoint before re-evaluating the breakpoint's
+       location.  This change can unfortunately get undone by accident if
+       the language_mode is set to auto, and we either switch frames, or
+       more likely in this context, we select the current frame.
+
+       We prevent this by temporarily turning the language_mode to
+       language_mode_manual.  We restore it once all breakpoints
+       have been reset.  */
+    scoped_restore save_language_mode = make_scoped_restore (&language_mode);
+    language_mode = language_mode_manual;
+
+    /* Note: we must not try to insert locations until after all
+       breakpoints have been re-set.  Otherwise, e.g., when re-setting
+       breakpoint 1, we'd insert the locations of breakpoint 2, which
+       hadn't been re-set yet, and thus may have stale locations.  */
+
+    try
+      {
+	input_radix = b->input_radix;
+	set_language (b->language);
+	b->re_set (filter_pspace);
+      }
+    catch (const gdb_exception &ex)
+      {
+	exception_fprintf (gdb_stderr, ex,
+			   "Error in re-setting breakpoint %d: ",
+			   b->number);
+      }
+  }
+
+  /* Now we can insert.  */
+  update_global_location_list (UGLL_MAY_INSERT);
+}
 \f
 /* Reset the thread number of this breakpoint:
 
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 42b49144e79..dea55deb314 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -570,15 +570,15 @@ enum print_stop_action
 
 struct breakpoint_ops
 {
-  /* Create SALs from location spec, storing the result in
-     linespec_result.
-
-     For an explanation about the arguments, see the function
-     `create_sals_from_location_spec_default'.
+  /* Create SALs from LOCSPEC, storing the result in linespec_result
+     CANONICAL.  If SEARCH_PSPACE is not nullptr then only results in the
+     corresponding program space are returned.  If SEARCH_PSPACE is nullptr
+     then results for all program spaces are returned.
 
      This function is called inside `create_breakpoint'.  */
   void (*create_sals_from_location_spec) (location_spec *locspec,
-					  struct linespec_result *canonical);
+					  linespec_result *canonical,
+					  program_space *search_pspace);
 
   /* This method will be responsible for creating a breakpoint given its SALs.
      Usually, it just calls `create_breakpoints_sal' (for ordinary
@@ -710,8 +710,15 @@ struct breakpoint : public intrusive_list_node<breakpoint>
 
   /* Reevaluate a breakpoint.  This is necessary after symbols change
      (e.g., an executable or DSO was loaded, or the inferior just
-     started).  */
-  virtual void re_set ()
+     started).
+
+     If not nullptr, then FILTER_PSPACE is the program space in which
+     symbols may have changed, we only need to add new locations in
+     FILTER_PSPACE.
+
+     If FILTER_PSPACE is nullptr then all program spaces may have changed,
+     new locations need to be searched for in every program space.  */
+  virtual void re_set (program_space *filter_pspace)
   {
     /* Nothing to re-set.  */
   }
@@ -955,7 +962,7 @@ struct code_breakpoint : public breakpoint
   /* Add a location for SAL to this breakpoint.  */
   bp_location *add_location (const symtab_and_line &sal);
 
-  void re_set () override;
+  void re_set (program_space *pspace) override;
   int insert_location (struct bp_location *) override;
   int remove_location (struct bp_location *,
 		       enum remove_bp_reason reason) override;
@@ -977,7 +984,7 @@ struct code_breakpoint : public breakpoint
      struct program_space *search_pspace);
 
   /* Helper method that does the basic work of re_set.  */
-  void re_set_default ();
+  void re_set_default (program_space *pspace);
 
   /* Find the SaL locations corresponding to the given LOCATION.
      On return, FOUND will be 1 if any SaL was found, zero otherwise.  */
@@ -999,7 +1006,7 @@ struct watchpoint : public breakpoint
 {
   using breakpoint::breakpoint;
 
-  void re_set () override;
+  void re_set (program_space *pspace) override;
   int insert_location (struct bp_location *) override;
   int remove_location (struct bp_location *,
 		       enum remove_bp_reason reason) override;
diff --git a/gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp b/gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp
index f736994d234..938e6deec05 100644
--- a/gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp
+++ b/gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp
@@ -76,8 +76,12 @@ foreach_mi_ui_mode mode {
     set loc2 [make_bp_loc "$::decimal\\.2"]
 
     # Create the inferior-specific breakpoint.
-    mi_create_breakpoint_multi "-g i2 foo" "create breakpoint in inferior 2" \
-	-inferior "2" -locations "\\\[$loc1,$loc2\\\]"
+    mi_create_breakpoint "-g i2 foo" "create breakpoint in inferior 2" \
+	-number "$decimal" \
+	-type "breakpoint" \
+	-enabled "y" \
+	-func "foo" \
+	-inferior "2"
     set bpnum [mi_get_valueof "/d" "\$bpnum" "INVALID"]
 
     if {$mode eq "separate"} {
diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
index 93b91b42f92..e168a5eee45 100644
--- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
+++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
@@ -364,15 +364,9 @@ proc test_continue_to_start { mode inf } {
 
 		# Consume MI output.
 		with_spawn_id $mi_spawn_id {
-		    if { $inf == 1} {
-			mi_expect_stop "breakpoint-hit" "child_sub_function" \
-			    "" "$srcfile" "$decimal" {"" "disp=\"del\""} \
-			    "thread $inf.2 stops MI"
-		    } else {
-			mi_expect_stop "breakpoint-hit" "child_sub_function" \
-			    "" "$srcfile" "$decimal" {"" "disp=\"del\"" "locno=\"[0-9]+\""} \
-			    "thread $inf.2 stops MI"
-		    }
+		    mi_expect_stop "breakpoint-hit" "child_sub_function" \
+			"" "$srcfile" "$decimal" {"" "disp=\"del\""} \
+			"thread $inf.2 stops MI"
 		}
 	    }
 	}
@@ -439,7 +433,7 @@ proc_with_prefix test_setup { mode } {
 
 	with_spawn_id $mi_spawn_id {
 	    mi_expect_stop "breakpoint-hit" "main" "" "$srcfile" "$decimal" \
-		{"" "disp=\"del\"" "locno=\"[0-9]+\""} "main stop"
+		{"" "disp=\"del\""} "main stop"
 	}
 
 	# Consume CLI output.
diff --git a/gdb/testsuite/gdb.multi/bp-thread-specific.exp b/gdb/testsuite/gdb.multi/bp-thread-specific.exp
index 7635e84b913..c1d87521ee9 100644
--- a/gdb/testsuite/gdb.multi/bp-thread-specific.exp
+++ b/gdb/testsuite/gdb.multi/bp-thread-specific.exp
@@ -50,7 +50,7 @@ gdb_test "info threads" \
 # locations ('foo' in both inferiors) even though only one of those
 # locations will ever trigger ('foo' in inferior 2).
 gdb_test "break foo thread 2.1" \
-    "Breakpoint $decimal at $hex: foo\\. \\(2 locations\\)"
+    "Breakpoint $decimal at $hex: file \[^\r\n\]+$srcfile, line $decimal\\."
 
 set bpnum [get_integer_valueof "\$bpnum" "INVALID"]
 
@@ -58,10 +58,7 @@ set bpnum [get_integer_valueof "\$bpnum" "INVALID"]
 # earlier breakpoint.  Check that the thread-id used when describing
 # the earlier breakpoints is correct.
 gdb_test "break foo thread 1.1" \
-    [multi_line \
-	 "Note: breakpoint $bpnum \\(thread 2.1\\) also set at pc $hex\\." \
-	 "Note: breakpoint $bpnum \\(thread 2.1\\) also set at pc $hex\\." \
-	 "Breakpoint $decimal at $hex: foo\\. \\(2 locations\\)"]
+    "Breakpoint $decimal at $hex: file \[^\r\n\]+$srcfile, line $decimal\\."
 
 # Save the breakpoints into a file.
 if {[is_remote host]} {
diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
index 46efe6f54bc..52f84183589 100644
--- a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
+++ b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
@@ -105,16 +105,8 @@ proc check_info_breakpoints { testname bp_number expected_loc_count } {
 # Create an inferior-specific breakpoint.  Use gdb_test instead of
 # gdb_breakpoint here as we want to check the breakpoint was placed in
 # multiple locations.
-#
-# Currently GDB still places inferior specific breakpoints into every
-# inferior, just like it does with thread specific breakpoints.
-# Hopefully this will change in the future, at which point, this test
-# will need updating.
-#
-# Two of these locations are in inferior 1, while the third is in
-# inferior 2.
 gdb_test "break foo inferior 1" \
-    "Breakpoint $decimal at $hex: foo\\. \\(3 locations\\)"
+    "Breakpoint $decimal at $hex: foo\\. \\(2 locations\\)"
 set bp_number [get_integer_valueof "\$bpnum" "INVALID" \
 		  "get b/p number for inferior specific breakpoint"]
 
@@ -123,7 +115,7 @@ set location_count 0
 set saw_inf_cond false
 
 check_info_breakpoints "first check for inferior specific breakpoint" \
-    $bp_number 3
+    $bp_number 2
 
 # Create a multi-inferior breakpoint to stop at.
 gdb_breakpoint "stop_breakpt" message
diff --git a/gdb/testsuite/gdb.multi/multi-target-continue.exp b/gdb/testsuite/gdb.multi/multi-target-continue.exp
index d2201061713..d4b2fc28133 100644
--- a/gdb/testsuite/gdb.multi/multi-target-continue.exp
+++ b/gdb/testsuite/gdb.multi/multi-target-continue.exp
@@ -30,7 +30,7 @@ proc test_continue {non-stop} {
 
     proc set_break {inf} {
 	gdb_test "break function${inf} thread ${inf}.1" \
-	"Breakpoint .* function${inf}\\..*"
+	    "Breakpoint ${::decimal} at ${::hex}: file .*, line ${::decimal}\\."
     }
 
     # Select inferior INF, and then run to a breakpoint on inferior
diff --git a/gdb/testsuite/gdb.multi/multi-target-ping-pong-next.exp b/gdb/testsuite/gdb.multi/multi-target-ping-pong-next.exp
index 0aff708c0f3..36f9d24a917 100644
--- a/gdb/testsuite/gdb.multi/multi-target-ping-pong-next.exp
+++ b/gdb/testsuite/gdb.multi/multi-target-ping-pong-next.exp
@@ -52,12 +52,12 @@ proc test_ping_pong_next {} {
     gdb_test "thread 1.1" "Switching to thread 1.1 .*"
 
     gdb_test "break $srcfile:$line1 thread 1.1" \
-	"Breakpoint .*$srcfile:$line1\\..*"
+	"Breakpoint .*$srcfile, line $line1\\."
 
     gdb_test "continue" "hit Breakpoint .*"
 
     gdb_test "break $srcfile:$line2 thread 2.1" \
-	"Breakpoint .*$srcfile:$line2\\..*"
+	"Breakpoint .*$srcfile, line $line2\\."
 
     # Now block inferior 1 and issue "next".  We should stop at the
     # breakpoint for inferior 2, given schedlock off.
diff --git a/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp b/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
index 5fcd1ef2e39..12c0a84bb02 100644
--- a/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
+++ b/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
@@ -129,10 +129,8 @@ proc do_bp_test { bp_type bp_pending } {
     } else {
 	set bp_pattern_before \
 	    [multi_line \
-		 "$bp_number\\s+breakpoint\\s+keep\\s+y\\s+<MULTIPLE>\\s*" \
-		 "\\s+stop only in [string_to_regexp $bp_restriction]" \
-		 "$bp_number\\.1\\s+y\\s+$::hex in $bp_func at \[^\r\n\]+ inf 1" \
-		 "$bp_number\\.2\\s+y\\s+$::hex in $bp_func at \[^\r\n\]+ inf 2"]
+		 "$bp_number\\s+breakpoint\\s+keep\\s+y\\s+$::hex in $bp_func at \[^\r\n\]+ inf 1" \
+		 "\\s+stop only in [string_to_regexp $bp_restriction]"]
 
 	set bp_pattern_after \
 	    [multi_line \
diff --git a/gdb/testsuite/gdb.multi/pending-bp.exp b/gdb/testsuite/gdb.multi/pending-bp.exp
index 478d8d7c037..aeb8c2c886e 100644
--- a/gdb/testsuite/gdb.multi/pending-bp.exp
+++ b/gdb/testsuite/gdb.multi/pending-bp.exp
@@ -72,6 +72,48 @@ proc do_test_setup { inf_1_stop inf_2_stop } {
     return true
 }
 
+# Create a breakpoint on the function 'foo' in THREAD.  It is expected
+# that the breakpoint created will be pending, this is checked by
+# running the 'info breakpoints' command.
+#
+# Returns the number for the newly created breakpoint.
+proc do_create_pending_foo_breakpoint { {thread "1.1"} } {
+    gdb_test "break foo thread $thread" \
+	[multi_line \
+	     "Function \"foo\" not defined\\." \
+	     "Breakpoint $::decimal \\(foo\\) pending\."] \
+	"set pending thread-specific breakpoint"
+    set bpnum [get_integer_valueof "\$bpnum" "*INVALID*" \
+		   "get number for thread-specific breakpoint on foo"]
+    gdb_test "info breakpoints $bpnum" \
+	[multi_line \
+	     "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+<PENDING>\\s+foo" \
+	     "\\s+stop only in thread [string_to_regexp $thread]"] \
+	"check thread-specific breakpoint is initially pending"
+
+    return $bpnum
+}
+
+# Create a breakpoint on the function 'foo' in THREAD.  It is expected
+# that the breakpoint created will not be pending, this is checked by
+# running the 'info breakpoints' command.
+#
+# Returns the number for the newly created breakpoint.
+proc do_create_foo_breakpoint { {thread "1.1"} } {
+    gdb_test "break foo thread $thread" \
+	"Breakpoint $::decimal at $::hex" \
+	"set thread-specific breakpoint"
+    set bpnum [get_integer_valueof "\$bpnum" "*INVALID*" \
+		   "get number for thread-specific breakpoint on foo"]
+    gdb_test "info breakpoints $bpnum" \
+	[multi_line \
+	     "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$::hex\\s+<foo\[^>\]*> inf $::decimal" \
+	     "\\s+stop only in thread [string_to_regexp $thread]"] \
+	"check thread-specific breakpoint is initially pending"
+
+    return $bpnum
+}
+
 # Check that when a breakpoint is in the pending state, but that breakpoint
 # does have some locations (those locations themselves are pending), GDB
 # doesn't display the inferior list in the 'info breakpoints' output.
@@ -122,5 +164,169 @@ proc_with_prefix test_no_inf_display {} {
 	"check info breakpoints while breakpoint is pending"
 }
 
+# Setup two inferiors.  In #1 the symbol 'foo' has not yet been
+# loaded, while in #2 the symbol 'foo' has been loaded.
+#
+# Create a thread-specific breakpoint on 'foo' tied to a thread in
+# inferior #1, the breakpoint should be pending -- 'foo' is not yet
+# loaded in #1.
+#
+# Now move inferior #1 forward until 'foo' is loaded, check the
+# breakpoint is no longer pending.
+#
+# Move inferior #1 forward more until 'foo' is unloaded, check that
+# the breakpoint returns to the pending state.
+proc_with_prefix test_pending_toggle { } {
+
+    do_test_setup "Break before open" "Break before close"
+
+    set bpnum [do_create_pending_foo_breakpoint]
+
+    # Now return to inferior 1 and continue until the shared library is
+    # loaded, the breakpoint should become non-pending.
+    gdb_test "inferior 1" "Switching to inferior 1 .*" \
+	"switch back to inferior 1"
+    gdb_continue_to_breakpoint "stop in foo in inferior 1" "foo \\(\\) .*"
+
+    gdb_test "info breakpoint $bpnum" \
+	[multi_line \
+	     "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$::hex <foo\[^>\]*> inf 1" \
+	     "\\s+stop only in thread 1\\.1" \
+	     "\\s+breakpoint already hit 1 time"] \
+	"check thread-specific breakpoint is no longer pending"
+
+    gdb_breakpoint [gdb_get_line_number "Break after close"] temporary
+    gdb_continue_to_breakpoint "close library"
+    gdb_test "info breakpoints $bpnum" \
+	[multi_line \
+	     "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+<PENDING>\\s+foo" \
+	     "\\s+stop only in thread 1\\.1" \
+	     "\\s+breakpoint already hit 1 time"] \
+	"check thread-specific breakpoint is pending again"
+}
+
+# Create a Python variable VAR and set it to the gdb.Breakpoint object
+# corresponding to the breakpoint numbered BPNUM.  If THREAD is not
+# the empty string then THREAD should be an integer, check that
+# gdb.Breakpoint.thread is set to the value of THREAD.  Otherwise, if
+# THREAD is the empty string, check that gdb.Breakpoint.thread is set
+# to None.
+proc py_find_breakpoint { var bpnum {thread ""} } {
+    gdb_test_no_output \
+	"python ${var}=\[b for b in gdb.breakpoints() if b.number == $bpnum\]\[0\]" \
+	"find Python gdb.Breakpoint object"
+    if { $thread ne "" } {
+	gdb_test_no_output "python assert(${var}.thread == ${thread})" \
+	    "check thread attribute is currently correct"
+    } else {
+	gdb_test_no_output "python assert(${var}.thread is None)" \
+	    "check thread attribute is currently correct"
+    }
+}
+
+# Setup two inferiors.  In #1 the symbol 'foo' has not yet been
+# loaded, while in #2 the symbol 'foo' has been loaded.
+#
+# Create a thread-specific breakpoint on 'foo' tied to a thread in
+# inferior #1, the breakpoint should be pending -- 'foo' is not yet
+# loaded in #1.
+#
+# Use Python to change the thread of the thread-specific breakpoint to
+# a thread in inferior #2, at this point the thread should gain a
+# location and become non-pending.
+#
+# Set the thread back to a thread in inferior #1, the breakpoint
+# should return to the pending state.
+proc_with_prefix py_test_toggle_thread {} {
+    do_test_setup "Break before open" "Break after open"
+
+    set bpnum [do_create_pending_foo_breakpoint]
+
+    py_find_breakpoint "bp" $bpnum 1
+
+    gdb_test_no_output "python bp.thread = 2" \
+	"change thread on thread-specific breakpoint"
+    gdb_test "info breakpoint $bpnum" \
+	[multi_line \
+	     "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$::hex <foo\[^>\]*> inf 2" \
+	     "\\s+stop only in thread 2\\.1"] \
+	"check thread-specific breakpoint now has a location"
+
+    gdb_test_no_output "set call_count = 2" "set call_count in inferior 2"
+    gdb_continue_to_breakpoint "stop at foo in inferior 2" "foo \\(\\) .*"
+
+    gdb_test_no_output "python bp.thread = 1" \
+	"restore thread on thread-specific breakpoint"
+    gdb_test "info breakpoints $bpnum" \
+	[multi_line \
+	     "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+<PENDING>\\s+foo" \
+	     "\\s+stop only in thread 1\\.1" \
+	     "\\s+breakpoint already hit 1 time"] \
+	"check thread-specific breakpoint has returned to pending"
+
+    gdb_breakpoint [gdb_get_line_number "Break after close"] temporary
+    gdb_continue_to_breakpoint "stop after close in inferior 2" \
+	".* Break after close\\. .*"
+
+    gdb_test "inferior 1" "Switching to inferior 1 .*" \
+	"switch to inferior 1"
+    gdb_continue_to_breakpoint "stop at foo in inferior 1" "foo \\(\\) .*"
+}
+
+# Setup two inferiors.  Both inferiors have the symbol 'foo'
+# available.
+#
+# Create a thread-specific breakpoint on 'foo' tied to a thread in
+# inferior #1, the breakpoint should not be pending, but will only
+# have a single location, the location in inferior #1.
+#
+# Use Python to change the thread of the thread-specific breakpoint to
+# None.  At this point the breakpoint should gain a second location, a
+# location in inferior #2.
+proc_with_prefix py_test_clear_thread {} {
+    do_test_setup "Break after open" "Break after open"
+
+    set bpnum [do_create_foo_breakpoint]
+
+    py_find_breakpoint "bp" $bpnum 1
+
+    gdb_test_no_output "python bp.thread = None" \
+	"clear thread on thread-specific breakpoint"
+    gdb_test "info breakpoints $bpnum" \
+	[multi_line \
+	     "${bpnum}\\s+breakpoint\\s+keep y\\s+<MULTIPLE>\\s*" \
+	     "${bpnum}\\.1\\s+y\\s+${::hex}\\s+<foo\[^>\]*> inf $::decimal" \
+	     "${bpnum}\\.2\\s+y\\s+${::hex}\\s+<foo\[^>\]*> inf $::decimal"] \
+	"check for a location in both inferiors"
+
+    gdb_continue_to_breakpoint "stop at foo in inferior 2" "foo \\(\\) .*"
+    gdb_test_no_output "set call_count = 2" "set call_count in inferior 2"
+
+    gdb_test "inferior 1" "Switching to inferior 1 .*" \
+	"switch to inferior 1"
+    gdb_continue_to_breakpoint "stop at foo in inferior 1" "foo \\(\\) .*"
+    gdb_test_no_output "set call_count = 2" "set call_count in inferior 1"
+
+    gdb_test_no_output "python bp.thread = 2"
+    gdb_test "info breakpoints $bpnum" \
+	[multi_line \
+	     "${bpnum}\\s+breakpoint\\s+keep y\\s+${::hex}\\s+<foo\[^>\]*> inf 2" \
+	     "\\s+stop only in thread 2\\.1" \
+	     "\\s+breakpoint already hit 2 times"] \
+	"check for a location only in inferior 2"
+
+    gdb_breakpoint [gdb_get_line_number "Break after close"] temporary
+    gdb_continue_to_breakpoint "stop after close in inferior 1" \
+	".* Break after close\\. .*"
+
+    gdb_test "inferior 2" "Switching to inferior 2 .*" \
+	"switch back to inferior 2"
+    gdb_continue_to_breakpoint "stop at foo again in inferior 2" \
+	"foo \\(\\) .*"
+}
+
 # Run all the tests.
 test_no_inf_display
+test_pending_toggle
+py_test_toggle_thread
+py_test_clear_thread
diff --git a/gdb/testsuite/gdb.multi/tids.exp b/gdb/testsuite/gdb.multi/tids.exp
index 573b02fdd42..4f788844ee4 100644
--- a/gdb/testsuite/gdb.multi/tids.exp
+++ b/gdb/testsuite/gdb.multi/tids.exp
@@ -433,11 +433,13 @@ if { [allow_python_tests] } {
 
 	gdb_py_test_silent_cmd "python bp = gdb.breakpoints()\[0\]" \
 	    "get python breakpoint" 0
-	gdb_test "python bp.thread = 6" "thread = 6" \
+	gdb_test_no_output "python bp.thread = 6" \
 	    "make breakpoint thread-specific with python"
 	# Check that the inferior-qualified ID is correct.
 	gdb_test "info breakpoint" \
-	    "stop only in thread 1.3\r\n.*" \
+	    [multi_line \
+		 "$decimal\\s+\[^\r\n\]+ in thread_function1 at \[^\r\n\]+" \
+		 "\\s+stop only in thread 1\\.3"] \
 	    "thread specific breakpoint right thread"
     }
 }
-- 
2.25.4


^ permalink raw reply	[relevance 11%]

* [PATCH] Normalize "on|off" text in manual
@ 2024-03-30 18:54  4% Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-03-30 18:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

While looking in the info manual, I noticed this:

    ‘set style enabled ‘on|off’’

The styling looked weird here and in the source I saw it was written as:

    @item set style enabled @samp{on|off}

I looked through the rest of the manual and found this same sort of
thing was written in a variety of styles.

For this patch, I picked one way to write this and applied it to all
the instances.
---
 gdb/doc/gdb.texinfo | 102 ++++++++++++++++++++++----------------------
 gdb/doc/guile.texi  |   2 +-
 gdb/doc/python.texi |   6 +--
 3 files changed, 55 insertions(+), 55 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 727f9275bfb..4cf5d98c701 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1718,18 +1718,18 @@ There are several commands to control @value{GDBN}'s logging.
 
 @table @code
 @kindex set logging enabled
-@item set logging enabled [on|off]
+@item set logging enabled @r{[}on@r{|}off@r{]}
 Enable or disable logging.
 @cindex logging file name
 @item set logging file @var{file}
 Change the name of the current logfile.  The default logfile is @file{gdb.txt}.
-@item set logging overwrite [on|off]
+@item set logging overwrite @r{[}on@r{|}off@r{]}
 By default, @value{GDBN} will append to the logfile.  Set @code{overwrite} if
 you want @code{set logging enabled on} to overwrite the logfile instead.
-@item set logging redirect [on|off]
+@item set logging redirect @r{[}on@r{|}off@r{]}
 By default, @value{GDBN} output will go to both the terminal and the logfile.
 Set @code{redirect} if you want output to go only to the log file.
-@item set logging debugredirect [on|off]
+@item set logging debugredirect @r{[}on@r{|}off@r{]}
 By default, @value{GDBN} debug output will go to both the terminal and the logfile.
 Set @code{debugredirect} if you want debug output to go only to the log file.
 @kindex show logging
@@ -6457,7 +6457,7 @@ Contrast this with the @code{return} command (@pxref{Returning,
 
 @kindex set print finish
 @kindex show print finish
-@item set print finish @r{[}on|off@r{]}
+@item set print finish @r{[}on@r{|}off@r{]}
 @itemx show print finish
 By default the @code{finish} command will show the value that is
 returned by the function.  This can be disabled using @code{set print
@@ -6779,7 +6779,7 @@ Disable the specified skip(s).  If @var{range} is not specified, disable all
 skips.
 
 @kindex set debug skip
-@item set debug skip @r{[}on|off@r{]}
+@item set debug skip @r{[}on@r{|}off@r{]}
 Set whether to print the debug output about skipping files and functions.
 
 @kindex show debug skip
@@ -8412,11 +8412,11 @@ allow overriding relevant global print settings as set by @code{set
 backtrace} and @code{set print} subcommands:
 
 @table @code
-@item -past-main [@code{on}|@code{off}]
+@item -past-main @r{[}on@r{|}off@r{]}
 Set whether backtraces should continue past @code{main}.  Related setting:
 @ref{set backtrace past-main}.
 
-@item -past-entry [@code{on}|@code{off}]
+@item -past-entry @r{[}on@r{|}off@r{]}
 Set whether backtraces should continue past the entry point of a program.
 Related setting: @ref{set backtrace past-entry}.
 
@@ -8428,7 +8428,7 @@ Related setting: @ref{set print entry-values}.
 Set printing of non-scalar frame arguments.
 Related setting: @ref{set print frame-arguments}.
 
-@item -raw-frame-arguments [@code{on}|@code{off}]
+@item -raw-frame-arguments @r{[}on@r{|}off@r{]}
 Set whether to print frame arguments in raw form.
 Related setting: @ref{set print raw-frame-arguments}.
 
@@ -8911,11 +8911,11 @@ The @code{frame apply} command also supports a number of options that
 allow overriding relevant @code{set backtrace} settings:
 
 @table @code
-@item -past-main [@code{on}|@code{off}]
+@item -past-main @r{[}on@r{|}off@r{]}
 Whether backtraces should continue past @code{main}.
 Related setting: @ref{set backtrace past-main}.
 
-@item -past-entry [@code{on}|@code{off}]
+@item -past-entry @r{[}on@r{|}off@r{]}
 Whether backtraces should continue past the entry point of a program.
 Related setting: @ref{set backtrace past-entry}.
 @end table
@@ -10405,15 +10405,15 @@ overriding relevant global print settings as set by @code{set print}
 subcommands:
 
 @table @code
-@item -address [@code{on}|@code{off}]
+@item -address @r{[}on@r{|}off@r{]}
 Set printing of addresses.
 Related setting: @ref{set print address}.
 
-@item -array [@code{on}|@code{off}]
+@item -array @r{[}on@r{|}off@r{]}
 Pretty formatting of arrays.
 Related setting: @ref{set print array}.
 
-@item -array-indexes [@code{on}|@code{off}]
+@item -array-indexes @r{[}on@r{|}off@r{]}
 Set printing of array indexes.
 Related setting: @ref{set print array-indexes}.
 
@@ -10434,27 +10434,27 @@ CLI command.
 Set the threshold after which nested structures are replaced with
 ellipsis.  Related setting: @ref{set print max-depth}.
 
-@item -nibbles [@code{on}|@code{off}]
+@item -nibbles @r{[}on@r{|}off@r{]}
 Set whether to print binary values in groups of four bits, known
 as ``nibbles''.  @xref{set print nibbles}.
 
-@item -memory-tag-violations [@code{on}|@code{off}]
+@item -memory-tag-violations @r{[}on@r{|}off@r{]}
 Set printing of additional information about memory tag violations.
 @xref{set print memory-tag-violations}.
 
-@item -null-stop [@code{on}|@code{off}]
+@item -null-stop @r{[}on@r{|}off@r{]}
 Set printing of char arrays to stop at first null char.  Related
 setting: @ref{set print null-stop}.
 
-@item -object [@code{on}|@code{off}]
+@item -object @r{[}on@r{|}off@r{]}
 Set printing C@t{++} virtual function tables.  Related setting:
 @ref{set print object}.
 
-@item -pretty [@code{on}|@code{off}]
+@item -pretty @r{[}on@r{|}off@r{]}
 Set pretty formatting of structures.  Related setting: @ref{set print
 pretty}.
 
-@item -raw-values [@code{on}|@code{off}]
+@item -raw-values @r{[}on@r{|}off@r{]}
 Set whether to print values in raw form, bypassing any
 pretty-printers for that value.  Related setting: @ref{set print
 raw-values}.
@@ -10464,19 +10464,19 @@ Set threshold for repeated print elements.  @code{unlimited} causes
 all elements to be individually printed.  Related setting: @ref{set
 print repeats}.
 
-@item -static-members [@code{on}|@code{off}]
+@item -static-members @r{[}on@r{|}off@r{]}
 Set printing C@t{++} static members.  Related setting: @ref{set print
 static-members}.
 
-@item -symbol [@code{on}|@code{off}]
+@item -symbol @r{[}on@r{|}off@r{]}
 Set printing of symbol names when printing pointers.  Related setting:
 @ref{set print symbol}.
 
-@item -union [@code{on}|@code{off}]
+@item -union @r{[}on@r{|}off@r{]}
 Set printing of unions interior to structures.  Related setting:
 @ref{set print union}.
 
-@item -vtbl [@code{on}|@code{off}]
+@item -vtbl @r{[}on@r{|}off@r{]}
 Set printing of C++ virtual function tables.  Related setting:
 @ref{set print vtbl}.
 @end table
@@ -13750,7 +13750,7 @@ better error checking.  The following commands control this behaviour.
 
 @table @code
 @kindex set mem inaccessible-by-default
-@item set mem inaccessible-by-default [on|off]
+@item set mem inaccessible-by-default @r{[}on@r{|}off@r{]}
 If @code{on} is specified, make  @value{GDBN} treat memory not
 explicitly described by the memory ranges as non-existent and refuse accesses
 to such memory.  The checks are only performed if there's at least one
@@ -17922,7 +17922,7 @@ printed.
 @cindex arrays slices (Fortran)
 @kindex set fortran repack-array-slices
 @kindex show fortran repack-array-slices
-@item set fortran repack-array-slices [on|off]
+@item set fortran repack-array-slices @r{[}on@r{|}off@r{]}
 @item show fortran repack-array-slices
 When taking a slice from an array, a Fortran compiler can choose to
 either produce an array descriptor that describes the slice in place,
@@ -19542,7 +19542,7 @@ well @value{GDBN} works without them.
 @table @code
 
 @kindex maint ada set ignore-descriptive-types
-@item maintenance ada set ignore-descriptive-types [on|off]
+@item maintenance ada set ignore-descriptive-types @r{[}on@r{|}off@r{]}
 Control whether the debugger should ignore descriptive types.
 The default is not to ignore descriptives types (@code{off}).
 
@@ -20480,11 +20480,11 @@ first instruction following a function prologue.  The @samp{EPILOGUE-BEGIN}
 column indicates that a given address marks the point where a block's frame is
 destroyed, making local variables hard or impossible to find.
 
-@kindex set always-read-ctf [on|off]
+@kindex set always-read-ctf @r{[}on@r{|}off@r{]}
 @kindex show always-read-ctf
 @cindex always-read-ctf
 @cindex CTF info, when to read
-@item set always-read-ctf [on|off]
+@item set always-read-ctf @r{[}on@r{|}off@r{]}
 @itemx show always-read-ctf
 
 When off, CTF debug info is only read if DWARF debug info is not
@@ -20528,7 +20528,7 @@ symbol-cache}..
 
 @kindex maint set ignore-prologue-end-flag
 @cindex prologue-end
-@item maint set ignore-prologue-end-flag [on|off]
+@item maint set ignore-prologue-end-flag @r{[}on@r{|}off@r{]}
 Enable or disable the use of the @samp{PROLOGUE-END} flag from the line-table.
 When @samp{off} (the default), @value{GDBN} uses the @samp{PROLOGUE-END} flag
 to place breakpoints past the end of a function prologue.  When @samp{on},
@@ -27740,7 +27740,7 @@ batch mode (@pxref{Mode Options}).  Various style settings are available;
 and styles can also be disabled entirely.
 
 @table @code
-@item set style enabled @samp{on|off}
+@item set style enabled @r{[}on@r{|}off@r{]}
 Enable or disable all styling.  The default is host-dependent, with
 most hosts defaulting to @samp{on}.
 
@@ -27750,7 +27750,7 @@ value, then @value{GDBN} will change this to @samp{off} at startup.
 @item show style enabled
 Show the current state of styling.
 
-@item set style sources @samp{on|off}
+@item set style sources @r{[}on@r{|}off@r{]}
 Enable or disable source code styling.  This affects whether source
 code, such as the output of the @code{list} command, is styled.  The
 default is @samp{on}.  Note that source styling only works if styling
@@ -27766,7 +27766,7 @@ then it will be used.
 @item show style sources
 Show the current state of source code styling.
 
-@item set style tui-current-position @samp{on|off}
+@item set style tui-current-position @r{[}on@r{|}off@r{]}
 Enable or disable styling of the source and assembly code highlighted
 by the TUI's current position indicator.  The default is @samp{off}.
 @xref{TUI, ,@value{GDBN} Text User Interface}.
@@ -27776,7 +27776,7 @@ Show whether the source and assembly code highlighted by the TUI's
 current position indicator is styled.
 
 @anchor{style_disassembler_enabled}
-@item set style disassembler enabled @samp{on|off}
+@item set style disassembler enabled @r{[}on@r{|}off@r{]}
 Enable or disable disassembler styling.  This affects whether
 disassembler output, such as the output of the @code{disassemble}
 command, is styled.  Disassembler styling only works if styling in
@@ -28272,7 +28272,7 @@ configured @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
 @table @code
 @anchor{set auto-load local-gdbinit}
 @kindex set auto-load local-gdbinit
-@item set auto-load local-gdbinit [on|off]
+@item set auto-load local-gdbinit @r{[}on@r{|}off@r{]}
 Enable or disable the auto-loading of canned sequences of commands
 (@pxref{Sequences}) found in init file in the current directory.
 
@@ -28311,7 +28311,7 @@ Note that loading of this debugging library also requires accordingly configured
 @table @code
 @anchor{set auto-load libthread-db}
 @kindex set auto-load libthread-db
-@item set auto-load libthread-db [on|off]
+@item set auto-load libthread-db @r{[}on@r{|}off@r{]}
 Enable or disable the auto-loading of inferior specific thread debugging library.
 
 @anchor{show auto-load libthread-db}
@@ -28479,7 +28479,7 @@ warning: File "/tmp/true-gdb.gdb" auto-loading has been declined
 @table @code
 @anchor{set debug auto-load}
 @kindex set debug auto-load
-@item set debug auto-load [on|off]
+@item set debug auto-load @r{[}on@r{|}off@r{]}
 Set whether to print the filenames attempted to be auto-loaded.
 
 @anchor{show debug auto-load}
@@ -29731,7 +29731,7 @@ and the list of auto-loaded scripts can be printed.
 @table @code
 @anchor{set auto-load gdb-scripts}
 @kindex set auto-load gdb-scripts
-@item set auto-load gdb-scripts [on|off]
+@item set auto-load gdb-scripts @r{[}on@r{|}off@r{]}
 Enable or disable the auto-loading of canned sequences of commands scripts.
 
 @anchor{show auto-load gdb-scripts}
@@ -31016,7 +31016,7 @@ When off, mouse clicks are handled by the terminal, enabling terminal-native
 text selection.
 
 @kindex set debug tui
-@item set debug tui @r{[}on|off@r{]}
+@item set debug tui @r{[}on@r{|}off@r{]}
 Turn on or off display of @value{GDBN} internal debug messages relating
 to the TUI.
 
@@ -41547,7 +41547,7 @@ names matching @var{regexp}.
 @kindex maint set catch-demangler-crashes
 @kindex maint show catch-demangler-crashes
 @cindex demangler crashes
-@item maint set catch-demangler-crashes [on|off]
+@item maint set catch-demangler-crashes @r{[}on@r{|}off@r{]}
 @itemx maint show catch-demangler-crashes
 Control whether @value{GDBN} should attempt to catch crashes in the
 symbol name demangler.  The default is to attempt to catch crashes.
@@ -41616,7 +41616,7 @@ Create a core file? (y or n) @kbd{n}
 @kindex maint show debuginfod download-sections
 @cindex debuginfod, maintenance commands
 @item maint set debuginfod download-sections
-@itemx maint set debuginfod download-sections @r{[}on|off@r{]}
+@itemx maint set debuginfod download-sections @r{[}on@r{|}off@r{]}
 @itemx maint show debuginfod download-sections
 Controls whether @value{GDBN} will attempt to download individual
 ELF/DWARF sections from @code{debuginfod}.  If disabled, only
@@ -41662,9 +41662,9 @@ disabled.
 @kindex maint show internal-error
 @kindex maint set internal-warning
 @kindex maint show internal-warning
-@item maint set internal-error backtrace @r{[}on|off@r{]}
+@item maint set internal-error backtrace @r{[}on@r{|}off@r{]}
 @itemx maint show internal-error backtrace
-@itemx maint set internal-warning backtrace @r{[}on|off@r{]}
+@itemx maint set internal-warning backtrace @r{[}on@r{|}off@r{]}
 @itemx maint show internal-warning backtrace
 When @value{GDBN} reports an internal problem (error or warning) it is
 possible to have a backtrace of @value{GDBN} printed to the standard
@@ -42082,7 +42082,7 @@ asynchronous mode (@pxref{Background Execution}).  Normally the
 default is asynchronous, if it is available; but this can be changed
 to more easily debug problems occurring only in synchronous mode.
 
-@kindex maint set target-non-stop @var{mode} [on|off|auto]
+@kindex maint set target-non-stop @var{mode} @r{[}on@r{|}off@r{|}auto@r{]}
 @kindex maint show target-non-stop
 @item maint set target-non-stop
 @itemx maint show target-non-stop
@@ -42140,7 +42140,7 @@ the left margin.
 This is useful in debugging performance problems.
 
 @table @code
-@item maint set per-command space [on|off]
+@item maint set per-command space @r{[}on@r{|}off@r{]}
 @itemx maint show per-command space
 Enable or disable the printing of the memory used by GDB for each command.
 If enabled, @value{GDBN} will display how much memory each command
@@ -42148,7 +42148,7 @@ took, following the command's own output.
 This can also be requested by invoking @value{GDBN} with the
 @option{--statistics} command-line switch (@pxref{Mode Options}).
 
-@item maint set per-command time [on|off]
+@item maint set per-command time @r{[}on@r{|}off@r{]}
 @itemx maint show per-command time
 Enable or disable the printing of the execution time of @value{GDBN}
 for each command.
@@ -42164,7 +42164,7 @@ spent by the program been debugged.
 This can also be requested by invoking @value{GDBN} with the
 @option{--statistics} command-line switch (@pxref{Mode Options}).
 
-@item maint set per-command symtab [on|off]
+@item maint set per-command symtab @r{[}on@r{|}off@r{]}
 @itemx maint show per-command symtab
 Enable or disable the printing of basic symbol table statistics
 for each command.
@@ -42182,7 +42182,7 @@ number of blocks in the blockvector
 
 @kindex maint set check-libthread-db
 @kindex maint show check-libthread-db
-@item maint set check-libthread-db [on|off]
+@item maint set check-libthread-db @r{[}on@r{|}off@r{]}
 @itemx maint show check-libthread-db
 Control whether @value{GDBN} should run integrity checks on inferior
 specific thread debugging libraries as they are loaded.  The default
@@ -42193,7 +42193,7 @@ about the tests, see @ref{maint check libthread-db}.
 
 @kindex maint set gnu-source-highlight enabled
 @kindex maint show gnu-source-highlight enabled
-@item maint set gnu-source-highlight enabled @r{[}on|off@r{]}
+@item maint set gnu-source-highlight enabled @r{[}on@r{|}off@r{]}
 @itemx maint show gnu-source-highlight enabled
 Control whether @value{GDBN} should use the GNU Source Highlight
 library for applying styling to source code (@pxref{Output Styling}).
@@ -42213,7 +42213,7 @@ library.
 @anchor{maint_libopcodes_styling}
 @kindex maint set libopcodes-styling enabled
 @kindex maint show libopcodes-styling enabled
-@item maint set libopcodes-styling enabled @r{[}on|off@r{]}
+@item maint set libopcodes-styling enabled @r{[}on@r{|}off@r{]}
 @itemx maint show libopcodes-styling enabled
 Control whether @value{GDBN} should use its builtin disassembler
 (@file{libopcodes}) to style disassembler output (@pxref{Output
@@ -42296,7 +42296,7 @@ the settings infrastructure.
 
 @kindex maint set backtrace-on-fatal-signal
 @kindex maint show backtrace-on-fatal-signal
-@item maint set backtrace-on-fatal-signal [on|off]
+@item maint set backtrace-on-fatal-signal @r{[}on@r{|}off@r{]}
 @itemx maint show backtrace-on-fatal-signal
 When this setting is @code{on}, if @value{GDBN} itself terminates with
 a fatal signal (e.g.@: SIGSEGV), then a limited backtrace will be
diff --git a/gdb/doc/guile.texi b/gdb/doc/guile.texi
index a66e8bfe16b..3089df71a09 100644
--- a/gdb/doc/guile.texi
+++ b/gdb/doc/guile.texi
@@ -3839,7 +3839,7 @@ and the list of auto-loaded scripts can be printed.
 @table @code
 @anchor{set auto-load guile-scripts}
 @kindex set auto-load guile-scripts
-@item set auto-load guile-scripts [on|off]
+@item set auto-load guile-scripts @r{[}on@r{|}off@r{]}
 Enable or disable the auto-loading of Guile scripts.
 
 @anchor{show auto-load guile-scripts}
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 4ca3ae4eca4..77524abd53b 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -162,14 +162,14 @@ The following commands are intended to help debug @value{GDBN} itself:
 @table @code
 @kindex set debug py-breakpoint
 @kindex show debug py-breakpoint
-@item set debug py-breakpoint on@r{|}off
+@item set debug py-breakpoint @r{[}on@r{|}off@r{]}
 @itemx show debug py-breakpoint
 When @samp{on}, @value{GDBN} prints debug messages related to the
 Python breakpoint API.  This is @samp{off} by default.
 
 @kindex set debug py-unwind
 @kindex show debug py-unwind
-@item set debug py-unwind on@r{|}off
+@item set debug py-unwind @r{[}on@r{|}off@r{]}
 @itemx show debug py-unwind
 When @samp{on}, @value{GDBN} prints debug messages related to the
 Python unwinder API.  This is @samp{off} by default.
@@ -8155,7 +8155,7 @@ and the list of auto-loaded scripts can be printed.
 @table @code
 @anchor{set auto-load python-scripts}
 @kindex set auto-load python-scripts
-@item set auto-load python-scripts [on|off]
+@item set auto-load python-scripts @r{[}on@r{|}off@r{]}
 Enable or disable the auto-loading of Python scripts.
 
 @anchor{show auto-load python-scripts}
-- 
2.43.0


^ permalink raw reply	[relevance 4%]

* [PATCH] gdb: ensure has dwarf info before reading DWZ file
@ 2024-03-30 11:01 11% Lancelot SIX
  0 siblings, 0 replies; 200+ results
From: Lancelot SIX @ 2024-03-30 11:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot SIX

I recent change (e9b738dfbdc "Avoid race when reading dwz file") moved
the call to dwarf2_read_dwz_file from dwarf2_initialize_objfile to
dwarf2_has_info.

Before that patch, dwarf2_initialize_objfile was only called when
dwarf2_has_info returned true, and since that patch it is always called.

When reading a file that has no debug info (.debug_info/.debug_abbrev
sections), but has a .gnu_debugaltlink section, GDB’s behavior is
different.  I can observe this when loading
/lib/x86_64-linux-gnu/libtinfo.so on Ubuntu 22.04 (or while debugging
any program dynamically loading this library).

Before e9b738dfbdc, we had:

    $ ./gdb/gdb -data-directory ./gdb/data-directory -q  /lib/x86_64-linux-gnu/libtinfo.so
    Reading symbols from /lib/x86_64-linux-gnu/libtinfo.so...
    (No debugging symbols found in /lib/x86_64-linux-gnu/libtinfo.so)
    (gdb)

while after we have:

    $ ./gdb/gdb -data-directory ./gdb/data-directory -q  /lib/x86_64-linux-gnu/libtinfo.so
    Reading symbols from /lib/x86_64-linux-gnu/libtinfo.so...

    warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
    (No debugging symbols found in /lib/x86_64-linux-gnu/libtinfo.so)
    (gdb)

This patch restores the previous behavior of only trying to load the
DWZ file for objfiles when the main part of the debuginfo is present
(i.e. when dwarf2_has_info returns true).  We still make sure that
dwarf2_read_dwz_file is called at most once per objfile.

A consequence of this change is that the per_bfd->dwz_file optional
object can now remain empty (instead of containing a nullptr), so also
this patch also adjusts dwarf2_get_dwz_file to account for this
possibility.  This effectively reverts the changes to
dwarf2_get_dwz_file done by e9b738dfbdc.

Regression tested on x86_64-linux-gnu Ubuntu 22.04.
---
 gdb/dwarf2/dwz.c  | 13 +++++++++----
 gdb/dwarf2/read.c | 36 +++++++++++++++++++-----------------
 2 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/gdb/dwarf2/dwz.c b/gdb/dwarf2/dwz.c
index 1eb4816fb47..c7cdba24076 100644
--- a/gdb/dwarf2/dwz.c
+++ b/gdb/dwarf2/dwz.c
@@ -282,9 +282,14 @@ dwarf2_read_dwz_file (dwarf2_per_objfile *per_objfile)
 struct dwz_file *
 dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd, bool require)
 {
-  gdb_assert (per_bfd->dwz_file.has_value ());
-  dwz_file *result = per_bfd->dwz_file->get ();
-  if (require && result == nullptr)
-    error (_("could not read '.gnu_debugaltlink' section"));
+  gdb_assert (!require || per_bfd->dwz_file.has_value ());
+
+  dwz_file *result = nullptr;
+  if (per_bfd->dwz_file.has_value ())
+    {
+      result = per_bfd->dwz_file->get ();
+      if (require && result == nullptr)
+	error (_("could not read '.gnu_debugaltlink' section"));
+    }
   return result;
 }
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 31313bc88b3..9e37011ddf0 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1362,11 +1362,11 @@ dwarf2_has_info (struct objfile *objfile,
     return false;
 
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+  bool just_created = false;
 
   if (per_objfile == NULL)
     {
       dwarf2_per_bfd *per_bfd;
-      bool just_created = false;
 
       /* We can share a "dwarf2_per_bfd" with other objfiles if the
 	 BFD doesn't require relocations.
@@ -1398,27 +1398,29 @@ dwarf2_has_info (struct objfile *objfile,
 	}
 
       per_objfile = dwarf2_objfile_data_key.emplace (objfile, objfile, per_bfd);
+    }
+
+  const bool has_info = (!per_objfile->per_bfd->info.is_virtual
+			 && per_objfile->per_bfd->info.s.section != nullptr
+			 && !per_objfile->per_bfd->abbrev.is_virtual
+			 && per_objfile->per_bfd->abbrev.s.section != nullptr);
 
-      if (just_created)
+  if (just_created && has_info)
+    {
+      /* Try to fetch any potential dwz file early, while still on
+	 the main thread.  Also, be sure to do it just once per
+	 BFD, to avoid races.  */
+      try
 	{
-	  /* Try to fetch any potential dwz file early, while still on
-	     the main thread.  Also, be sure to do it just once per
-	     BFD, to avoid races.  */
-	  try
-	    {
-	      dwarf2_read_dwz_file (per_objfile);
-	    }
-	  catch (const gdb_exception_error &err)
-	    {
-	      warning (_("%s"), err.what ());
-	    }
+	  dwarf2_read_dwz_file (per_objfile);
+	}
+      catch (const gdb_exception_error &err)
+	{
+	  warning (_("%s"), err.what ());
 	}
     }
 
-  return (!per_objfile->per_bfd->info.is_virtual
-	  && per_objfile->per_bfd->info.s.section != NULL
-	  && !per_objfile->per_bfd->abbrev.is_virtual
-	  && per_objfile->per_bfd->abbrev.s.section != NULL);
+  return has_info;
 }
 
 /* See declaration.  */

base-commit: 13ed3225004896142dcb0fbe24411b66f17dfc8e
-- 
2.34.1


^ permalink raw reply	[relevance 11%]

* [PATCH 2/3] gdb: boolify thread_info's 'stop_requested' field
  @ 2024-03-28 17:35  4% ` Tankut Baris Aktemur
  0 siblings, 0 replies; 200+ results
From: Tankut Baris Aktemur @ 2024-03-28 17:35 UTC (permalink / raw)
  To: gdb-patches

Boolify the field.  The 'set_stop_requested' function was already
taking a bool parameter, whose value is assigned to the field.
---
 gdb/gdbthread.h | 2 +-
 gdb/infcmd.c    | 2 +-
 gdb/infrun.c    | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 11c553a99ca..02ff50afcd9 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -530,7 +530,7 @@ class thread_info : public intrusive_list_node<thread_info>,
   struct target_waitstatus pending_follow;
 
   /* True if this thread has been explicitly requested to stop.  */
-  int stop_requested = 0;
+  bool stop_requested = false;
 
   /* The initiating frame of a nexting operation, used for deciding
      which exceptions to intercept.  If it is null_frame_id no
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index ac41ebf11b4..68ecdb9feba 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2879,7 +2879,7 @@ stop_current_target_threads_ns (ptid_t ptid)
      all-stop mode, we will only get one stop event --- it's undefined
      which thread will report the event.  */
   set_stop_requested (current_inferior ()->process_target (),
-		      ptid, 1);
+		      ptid, true);
 }
 
 /* See inferior.h.  */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index bbb98f6dcdb..c0ebc95a061 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1284,7 +1284,7 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
   /* The user may have had the main thread held stopped in the
      previous image (e.g., schedlock on, or non-stop).  Release
      it now.  */
-  th->stop_requested = 0;
+  th->stop_requested = false;
 
   update_breakpoints_after_exec ();
 
@@ -3079,7 +3079,7 @@ clear_proceed_status_thread (struct thread_info *tp)
   tp->control.step_stack_frame_id = null_frame_id;
   tp->control.step_over_calls = STEP_OVER_UNDEBUGGABLE;
   tp->control.step_start_function = nullptr;
-  tp->stop_requested = 0;
+  tp->stop_requested = false;
 
   tp->control.stop_step = 0;
 
@@ -5455,7 +5455,7 @@ handle_one (const wait_one_event &event)
       if (t == nullptr)
 	t = add_thread (event.target, event.ptid);
 
-      t->stop_requested = 0;
+      t->stop_requested = false;
       t->set_executing (false);
       t->set_resumed (false);
       t->control.may_range_step = 0;
@@ -5695,7 +5695,7 @@ stop_all_threads (const char *reason, inferior *inf)
 		      infrun_debug_printf ("  %s executing, need stop",
 					   t->ptid.to_string ().c_str ());
 		      target_stop (t->ptid);
-		      t->stop_requested = 1;
+		      t->stop_requested = true;
 		    }
 		  else
 		    {
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 4%]

* [PATCH] [gdb/tui] Fix centering and highlighting of current line
@ 2024-03-28 14:33  4% Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-03-28 14:33 UTC (permalink / raw)
  To: gdb-patches

After starting TUI like this with a hello world a.out:
...
$ gdb -q a.out -ex start -ex "tui enable"
...
we get:
...
┌─hello.c──────────────────────────────┐
│        5 {                           │
│        6   printf ("hello\n");       │
│        7                             │
│        8   return 0;                 │
│        9 }                           │
│                                      │
└──────────────────────────────────────┘
...

This is a regression since commit ee1e9bbb513 ("[gdb/tui] Fix displaying main
after resizing"), before which we had instead:
...
┌─hello.c──────────────────────────────┐
│        4 main (void)                 │
│        5 {                           │
│  >     6 ^[[7m  printf ("hello\n");^[[0m       │
│        7                             │
│        8   return 0;                 │
│        9 }                           │
└──────────────────────────────────────┘
...

In other words, the problems are:
- the active line (source line 6) is no longer highlighted, and
- the active line is not veritically centered (screen line 2 out 6 instead of
  screen line 3 out of 6).

Fix these problems respectively by:
- in tui_enable, instead of "tui_show_frame_info (0)" using
  'tui_show_frame_info (deprecated_safe_get_selected_frame ())", and
- in tui_source_window_base::rerender, adding centering functionality.

Tested on aarch64-linux.

Co-Authored-By: Tom Tromey <tromey@adacore.com>

PR tui/31522
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31522
---
 gdb/testsuite/gdb.tui/main-2.exp | 47 ++++++++++++++++++++++++++++++++
 gdb/tui/tui-winsource.c          | 10 +++++++
 gdb/tui/tui.c                    |  2 +-
 3 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.tui/main-2.exp

diff --git a/gdb/testsuite/gdb.tui/main-2.exp b/gdb/testsuite/gdb.tui/main-2.exp
new file mode 100644
index 00000000000..1dcb3cfc6d4
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/main-2.exp
@@ -0,0 +1,47 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that enabling tui while having a current frame results in
+# centering and highlighting the associated line.
+
+require allow_tui_tests
+
+tuiterm_env
+
+standard_testfile tui-layout.c
+
+if { [build_executable "failed to prepare" $testfile $srcfile ] == -1} {
+    return -1
+}
+
+Term::clean_restart 24 80 $binfile
+
+if {![runto_main]} {
+    perror "test suppressed"
+    return
+}
+
+if {![Term::enter_tui]} {
+    unsupported "TUI not supported"
+    return
+}
+
+set line "  return 0;"
+set nr [gdb_get_line_number $line]
+
+set screen_line [Term::get_line_with_attrs 6]
+verbose -log "screen line 6: '$screen_line'"
+gdb_assert { [regexp "$nr <reverse:1>$line<reverse:0>" $screen_line] } \
+    "highlighted line in middle of source window"
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 4dbbe922256..61c8e00589d 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -467,6 +467,16 @@ tui_source_window_base::rerender ()
       struct symtab *s = find_pc_line_symtab (get_frame_pc (frame));
       if (this != TUI_SRC_WIN)
 	find_line_pc (s, cursal.line, &cursal.pc);
+
+      /* This centering code is copied from tui_source_window::maybe_update.
+	 It would be nice to do centering more often, and do it in just one
+	 location.  But since this is a regression fix, handle this
+	 conservatively for now.  */
+      int start_line = (cursal.line - ((height - box_size ()) / 2)) + 1;
+      if (start_line <= 0)
+	start_line = 1;
+      cursal.line = start_line;
+
       update_source_window (gdbarch, cursal);
     }
   else
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 19f09609a2f..eaee85f82b4 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -466,7 +466,7 @@ tui_enable (void)
       tui_set_term_width_to (COLS);
       def_prog_mode ();
 
-      tui_show_frame_info (0);
+      tui_show_frame_info (deprecated_safe_get_selected_frame ());
       tui_set_initial_layout ();
       tui_set_win_focus_to (TUI_SRC_WIN);
       keypad (TUI_CMD_WIN->handle.get (), TRUE);

base-commit: 4ef6173d2dfeafd33deedf7ce0d384cfbcf1170d
-- 
2.35.3


^ permalink raw reply	[relevance 4%]

* [PATCH v6 04/10] gdb: Skip trampoline frames for the backtrace command.
  @ 2024-03-28 12:05  2% ` Abdul Basit Ijaz
  0 siblings, 0 replies; 200+ results
From: Abdul Basit Ijaz @ 2024-03-28 12:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: abdul.b.ijaz, JiniSusan.George, tom, eliz

From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>

This change filters trampoline functions when the option
'skip-trampoline-functions' is set to 'on' for the backtrace command.
Before the change, GDB prints the frames indicated by the compiler with
DIE "DW_AT_trampoline" in the backtrace, but for better user experience,
all such frames can be hidden from the user.

The test 'gdb.fortran/mixed-lang-stack' test used to fail for the IFX
compiler because of extra trampoline frames in the backtrace.  After the
commit, those trampoline frames are filtered and test is updated accordingly.

Extra trampoline frames:

bt -frame-arguments all
'''
\#8  0x0000000000405535 in mixed_func_1b_.t86p.t87p.t88p.t89p.t90p.t91p.t3v ()
\#10 0x0000000000405439 in mixed_func_1a_.void () at mixed-lang-stack.f90:33
'''
(gdb) FAIL: gdb.fortran/mixed-lang-stack.exp: lang=auto: bt -frame-arguments all

In this example the IFX compiler emits "DW_AT_trampoline" tag for the 'first'
and 'second' trampoline functions like following:

function second (x, y) result(z)
  integer, intent(in) :: x, y
  integer :: z
  z = x * y ! breakpt-backtrace
end function second

function first (num1, num2) result(total)
  integer, intent(in) :: num1, num2
  integer  :: total
  total = second (num1 + 4, num2 * 3) ! first-breakpt
  total = total + 30
end function first

Related Dwarf:

0x0000013f:   DW_TAG_subprogram
                DW_AT_low_pc    (0x0000000000404350)
                DW_AT_high_pc   (0x000000000040435f)
                DW_AT_frame_base        (DW_OP_reg6 RBP)
                DW_AT_linkage_name      ("second_.t74p.t75p")
                DW_AT_name      ("second_.t74p.t75p")
                DW_AT_trampoline        ("second_")

0x0000015a:   DW_TAG_subprogram
                DW_AT_low_pc    (0x00000000004044a0)
                DW_AT_high_pc   (0x00000000004044af)
                DW_AT_frame_base        (DW_OP_reg6 RBP)
                DW_AT_linkage_name      ("first_.t104p.t105p")
                DW_AT_name      ("first_.t104p.t105p")
                DW_AT_trampoline        ("first_")

Before this change, the backtrace command output looks like:

'''
(gdb) backtrace 3
\#0  second (x=20, y=9) at test.f90:4
\#1  0x0000000000405209 in second_.t74p.t75p () at test.f90:12
\#2  0x00000000004051e3 in first (num1=16, num2=3) at test.f90:10
(gdb) backtrace -3
\#2  0x00000000004051e3 in first (num1=16, num2=3) at test.f90:10
\#3  0x0000000000405309 in first_.t95p.t96p () at test.f90:21
\#4  0x0000000000405234 in func_trampoline () at test.f90:17
'''

After the change:
'''
(gdb) backtrace 3
\#0  second (x=20, y=9) at test.f90:4
\#2  0x00000000004051e3 in first (num1=16, num2=3) at test.f90:10
\#4  0x0000000000405234 in func_trampoline () at test.f90:17

(gdb) backtrace -3
\#2  0x00000000004051e3 in first (num1=16, num2=3) at test.f90:10
\#4  0x0000000000405234 in func_trampoline () at test.f90:17
'''

The test gdb.fortran/func-trampoline.exp is added for testing the change.

2024-03-28 Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
---
 gdb/NEWS                                      |  5 +-
 gdb/doc/gdb.texinfo                           |  6 ++
 gdb/infrun.c                                  |  8 +-
 gdb/infrun.h                                  |  6 ++
 gdb/stack.c                                   |  8 ++
 gdb/symtab.c                                  | 12 +++
 gdb/symtab.h                                  |  5 ++
 gdb/testsuite/gdb.fortran/func-trampoline.exp | 77 +++++++++++++++++++
 gdb/testsuite/gdb.fortran/func-trampoline.f90 | 39 ++++++++++
 .../gdb.fortran/mixed-lang-stack.exp          | 10 ++-
 10 files changed, 167 insertions(+), 9 deletions(-)
 create mode 100644 gdb/testsuite/gdb.fortran/func-trampoline.exp
 create mode 100644 gdb/testsuite/gdb.fortran/func-trampoline.f90

diff --git a/gdb/NEWS b/gdb/NEWS
index da0d936ff70..025f2e1a17e 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -897,8 +897,9 @@ show skip-trampoline-functions
   This setting is 'on' by default.  When 'on' it controls whether GDB will
   recognize function calls that have been marked as trampolines in the debug
   info.  It improves stepping behavior in that it steps over the trampoline
-  code and hides it from the user.  Currently, only DWARF trampolines are
-  supported.
+  code and hides it from the user.  It improves the printing of the stack by
+  hiding trampoline functions from the backtrace.  Currently, only DWARF
+  trampolines are supported.
 
   If this is turned off, GDB gdb will handle trampoline functions the same
   as any other function.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 19fecd00480..6117f6e889f 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6472,6 +6472,12 @@ execution until leaving the trampoline region.  The @code{stepi} command
 is not affected by the setting which is enabled by default.  Currently, only
 DWARF trampolines marked via DW_AT_trampoline are supported by this.
 
+When issuing a @code{backtrace}, if @code{skip-trampoline-functions} is set,
+@value{GDBN} will skip trampoline frames while printing the stack.
+
+Currently, only DWARF trampolines marked via DW_AT_trampoline are supported by
+this.
+
 @item set skip-trampoline-functions off
 Causes @value{GDBN} to completely ignore any trampoline information a compiler
 might have emitted in its debug info.  Trampolines will be treated like any
diff --git a/gdb/infrun.c b/gdb/infrun.c
index a669798f5b8..1c5711b8c41 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -191,7 +191,7 @@ static bool detach_fork = true;
    DW_AT_trampoline by the compiler.  If false, GDB will ignore the
    attribute.  */
 
-static bool skip_trampoline_functions = true;
+bool skip_trampoline_functions = true;
 
 bool debug_infrun = false;
 static void
@@ -10809,9 +10809,9 @@ Options are 'forward' or 'reverse'."),
 			  &skip_trampoline_functions, _("\
 Set whether gdb attempts to hide trampolines marked in the debug info."), _("\
 Show whether gdb attempts to hide trampolines marked in the debug info."), _("\
-If on, while stepping gdb will skip through functions and inlined functions\n\
-marked as trampolines by the compiler.  If off, gdb will ignore such function\n\
-trampolines."),
+If on, gdb will skip through functions and inlined functions marked as\n\
+trampolines by the compiler.  If off, gdb will handle trampoline functions\n\
+the same way as any other function."),
 			  nullptr, show_skip_trampoline_functions, &setlist,
 			  &showlist);
 
diff --git a/gdb/infrun.h b/gdb/infrun.h
index ea1ec134c7c..fbe88ad4595 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -107,6 +107,12 @@ extern bool non_stop;
    starting an inferior.  */
 extern bool disable_randomization;
 
+/* If set (default) GDB will step through functions/inlined subroutines marked
+   DW_AT_trampoline by the compiler.  If false, GDB will ignore the
+   attribute.  */
+
+extern bool skip_trampoline_functions;
+
 /* Returns a unique identifier for the current stop.  This can be used
    to tell whether a command has proceeded the inferior past the
    current location.  */
diff --git a/gdb/stack.c b/gdb/stack.c
index 9c679222708..6a25054673f 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2065,6 +2065,14 @@ backtrace_command_1 (const frame_print_options &fp_opts,
 	{
 	  QUIT;
 
+	  if (skip_trampoline_functions && in_trampoline_frame (fi))
+	    {
+	      /* Trampoline frames are not printed so they are not counted in
+		 the backtrace limit.  */
+	      count++;
+	      continue;
+	    }
+
 	  /* Don't use print_stack_frame; if an error() occurs it probably
 	     means further attempts to backtrace would fail (on the other
 	     hand, perhaps the code does or could be fixed to make sure
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 831a58a9aff..8f509663d9f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4220,6 +4220,18 @@ in_trampoline_function (CORE_ADDR pc)
 
 /* See symtab.h.  */
 
+bool
+in_trampoline_frame (frame_info_ptr fi)
+{
+  CORE_ADDR pc;
+  if (get_frame_pc_if_available (fi, &pc))
+    return in_trampoline_function (pc);
+
+  return false;
+}
+
+/* See symtab.h.  */
+
 CORE_ADDR
 find_function_trampoline_target (CORE_ADDR pc)
 {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index c60485dc6d3..234171ed404 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2359,6 +2359,11 @@ extern CORE_ADDR find_solib_trampoline_target (const frame_info_ptr &, CORE_ADDR
 
 extern bool in_trampoline_function (CORE_ADDR pc);
 
+/* Return whether or not the pc of the current frame is within a block that
+   belongs to a function that is marked as a trampoline by the compiler.  */
+
+extern bool in_trampoline_frame (frame_info_ptr);
+
 /* Find the target of a trampoline function marked via the DW_AT_trampoline
    attribute and return its address.  Returns 0 if the pc is not contained
    in a trampoline function (inlined or not).  If DW_AT_trampoline
diff --git a/gdb/testsuite/gdb.fortran/func-trampoline.exp b/gdb/testsuite/gdb.fortran/func-trampoline.exp
new file mode 100644
index 00000000000..bfa0002cf0e
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/func-trampoline.exp
@@ -0,0 +1,77 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/> .
+
+# Test "backtrace" and "backtrace -n" commands for functions with trampoline
+# calls.
+
+require allow_fortran_tests
+
+if {![test_compiler_info {ifx-*} f90]} {
+    untested "This test is only applicable for IFX, which emits the\
+	trampoline DIE in Dwarf."
+    return -1
+}
+
+standard_testfile ".f90"
+load_lib fortran.exp
+
+# Initialize the test by running the program to the innermost
+# function name "second".
+
+proc init_test {} {
+    global binfile srcfile inner_loc
+
+    clean_restart ${binfile}
+    if {![fortran_runto_main]} {
+	return -1
+    }
+
+    # Set breakpoint inside the innermost function 'second'.
+    gdb_breakpoint "$srcfile:$inner_loc"
+    gdb_continue_to_breakpoint "innermost-body" ".*$srcfile:$inner_loc.*"
+}
+
+if {[build_executable "failed to prepare" ${testfile} ${srcfile} \
+    {debug f90}]} {
+    return -1
+}
+
+set inner_loc [gdb_get_line_number "second-breakpt"]
+set middle_loc [gdb_get_line_number "first-breakpt"]
+set outer_loc [gdb_get_line_number "main-outer-loc"]
+set fill "\[^\r\n\]*"
+
+set inner_desc  "second \\(x=20, y=9\\) at ${fill}$srcfile:$inner_loc"
+set middle_desc "first \\(num1=16, num2=3\\) at ${fill}$srcfile:$middle_loc"
+set outer_desc  ".* at .*$srcfile:$outer_loc"
+
+with_test_prefix "backtrace" {
+    init_test
+
+    # Limit the backtrace to 3 frames and ensure both frames for first
+    # and second function are shown only and trampoline frames are filtered.
+    gdb_test "backtrace 3" [multi_line \
+	"#$decimal.* $inner_desc" \
+	"#$decimal.* $middle_desc" \
+	"#$decimal.* $outer_desc.*"]
+}
+
+with_test_prefix "backtrace outerframes" {
+    init_test
+
+    gdb_test "backtrace -3" [multi_line \
+	"#$decimal.* $middle_desc" \
+	"#$decimal.* $outer_desc.*"]
+}
diff --git a/gdb/testsuite/gdb.fortran/func-trampoline.f90 b/gdb/testsuite/gdb.fortran/func-trampoline.f90
new file mode 100644
index 00000000000..10eb3f5188f
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/func-trampoline.f90
@@ -0,0 +1,39 @@
+! Copyright 2024 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program.  If not, see <http://www.gnu.org/licenses/> .
+
+! Source code for func-trampoline.exp.
+
+integer(kind=4) function second(x, y)
+  integer(kind=4), intent(in) :: x
+  integer(kind=4), intent(in) :: y
+
+  second = x * y ! second-breakpt
+end function
+
+integer(kind=4) function first(num1, num2)
+  integer(kind=4), intent(in) :: num1
+  integer(kind=4), intent(in) :: num2
+
+  first = second (num1 + 4, num2 * 3) ! first-breakpt
+end function
+
+program func_trampoline
+  integer(kind=4) :: total
+
+  total = first(16, 3) ! main-outer-loc
+
+  write(*,*)  "Result is ", total, "\n"
+  ! Expected: 180
+end program func_trampoline
diff --git a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
index eef84da0e44..4591880ca7b 100644
--- a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
+++ b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
@@ -41,7 +41,7 @@ set have_index [exec_has_index_section $binfile]
 # value to pass to GDB's 'set language ...' command.
 proc run_tests { lang } {
     with_test_prefix "lang=${lang}" {
-	global binfile hex have_index
+	global binfile hex have_index decimal
 
 	clean_restart ${binfile}
 
@@ -63,6 +63,10 @@ proc run_tests { lang } {
 	set e_arg "\['\"\]abcdef\['\"\]"
 	set 1b_args "\[^\r\n\]+$e_arg\[^\r\n\]+"
 	set 1g_args "obj=\[^\r\n\]+"
+	# Generic decimal number is checked in regex for Frame #8 and #9 to
+	# handle filtered trampoline frames.  Since Frame#8 and Frame#10 are
+	# set to trampoline in DWARF by Intel® Fortran Compiler (ifx), they
+	# are not shown by the backtrace command.
 	set bt_stack \
 	    [multi_line \
 		 "#0\\s+breakpt \\(\\) at \[^\r\n\]+" \
@@ -73,8 +77,8 @@ proc run_tests { lang } {
 		 "#5\\s+$hex in mixed_func_1d \\(\[^\r\n\]+\\) at \[^\r\n\]+" \
 		 "#6\\s+$hex in mixed_func_1c \\(\[^\r\n\]+\\) at \[^\r\n\]+" \
 		 "#7\\s+$hex in mixed_func_1b \\($1b_args\\) at \[^\r\n\]+" \
-		 "#8\\s+$hex in mixed_func_1a \\(\\) at \[^\r\n\]+" \
-		 "#9\\s+$hex in mixed_stack_main \\(\\) at \[^\r\n\]+" ]
+		 "#$decimal\\s+$hex in mixed_func_1a \\(\\) at \[^\r\n\]+" \
+		 "#$decimal\\s+$hex in mixed_stack_main \\(\\) at \[^\r\n\]+" ]
 	set main_args "argc=1, argv=${hex}( \[^\r\n\]+)?"
 	set bt_stack_kfail \
 	    [multi_line \
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[relevance 2%]

* Re: [PATCH 1/3] gdb: Make tagged pointer support configurable.
  @ 2024-03-28 11:58  0%   ` Luis Machado
  0 siblings, 0 replies; 200+ results
From: Luis Machado @ 2024-03-28 11:58 UTC (permalink / raw)
  To: Schimpe, Christina, gdb-patches

Hi,


On 3/27/24 07:47, Schimpe, Christina wrote:
> From: Christina Schimpe <christina.schimpe@intel.com>
> 
> The gdbarch function gdbarch_remove_non_address_bits adjusts addresses to
> enable debugging of programs with tagged pointers on Linux, for instance for
> ARM's feature top byte ignore (TBI).
> Once the function is implemented for an architecture, it adjusts addresses for
> memory access, breakpoints and watchpoints.
> 
> Linear address masking (LAM) is Intel's (R) implementation of tagged
> pointer support.  It requires certain adaptions to GDB's tagged pointer
> support due to the following:
> - LAM supports address tagging for data accesses only.  Thus, specifying
>   breakpoints on tagged addresses is not a valid use case.
> - In contrast to the implementation for ARM's TBI, the kernel supports tagged
>   pointers for memory access.
> 
> This patch makes GDB's tagged pointer support configurable such that it is
> possible to enable the address adjustment for a specific feature only (e.g
> memory access, breakpoints or watchpoints).


Thanks for the series. More of a general question, we're splitting the more general
handling of bit removal from addresses into 3 different categories in gdb. Isn't gdbserver
also affected by this change? At least for aarch64 we have non-address-bits removal.

Do we need to do anything in gdbserver so it can properly handle removal of non-address-bits
on its own, without the help of gdb?

Also, another more general comment is related to the naming of the hooks. I suppose it is down
to personal preference, but spelling out the entire word is likely to make the meaning of a
function/hook clearer. For instance:

gdbarch_remove_non_address_bits -> gdbarch_remove_non_addr_bits_memory

Maybe we should...

gdbarch_remove_non_address_bits -> gdbarch_remove_non_address_bits_memory

The same applies to the other hooks and function names.

wpt -> watchpoint

or

wpt -> hw_watchpoint

bpt -> breakpoint

or

bpt -> hw_breakpoint

> ---
>  gdb/aarch64-linux-nat.c   |  3 +-
>  gdb/aarch64-linux-tdep.c  | 14 +++++----
>  gdb/aarch64-tdep.c        | 12 +++++--
>  gdb/breakpoint.c          |  4 +--
>  gdb/gdbarch-gen.h         | 50 ++++++++++++++++++++++-------
>  gdb/gdbarch.c             | 66 ++++++++++++++++++++++++++++++++-------
>  gdb/gdbarch_components.py | 54 +++++++++++++++++++++++++++-----
>  gdb/target.c              |  4 +--
>  8 files changed, 163 insertions(+), 44 deletions(-)
> 
> diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
> index 3face34ce79..bd02a7b2d08 100644
> --- a/gdb/aarch64-linux-nat.c
> +++ b/gdb/aarch64-linux-nat.c
> @@ -959,7 +959,8 @@ aarch64_linux_nat_target::stopped_data_address (CORE_ADDR *addr_p)
>       kernel can potentially be tagged addresses.  */
>    struct gdbarch *gdbarch = thread_architecture (inferior_ptid);
>    const CORE_ADDR addr_trap
> -    = gdbarch_remove_non_address_bits (gdbarch, (CORE_ADDR) siginfo.si_addr);
> +    = gdbarch_remove_non_addr_bits_memory (gdbarch,
> +					   (CORE_ADDR) siginfo.si_addr);
>  
>    /* Check if the address matches any watched address.  */
>    state = aarch64_get_debug_reg_state (inferior_ptid.pid ());
> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
> index 0b9784f38e4..d2d42efe305 100644
> --- a/gdb/aarch64-linux-tdep.c
> +++ b/gdb/aarch64-linux-tdep.c
> @@ -2458,7 +2458,7 @@ aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, struct value *address)
>    CORE_ADDR addr = value_as_address (address);
>  
>    /* Remove the top byte for the memory range check.  */
> -  addr = gdbarch_remove_non_address_bits (gdbarch, addr);
> +  addr = gdbarch_remove_non_addr_bits_memory (gdbarch, addr);
>  
>    /* Check if the page that contains ADDRESS is mapped with PROT_MTE.  */
>    if (!linux_address_in_memtag_page (addr))
> @@ -2484,7 +2484,8 @@ aarch64_linux_memtag_matches_p (struct gdbarch *gdbarch,
>  
>    /* Fetch the allocation tag for ADDRESS.  */
>    std::optional<CORE_ADDR> atag
> -    = aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch, addr));
> +    = aarch64_mte_get_atag (gdbarch_remove_non_addr_bits_memory (gdbarch,
> +								 addr));
>  
>    if (!atag.has_value ())
>      return true;
> @@ -2523,7 +2524,7 @@ aarch64_linux_set_memtags (struct gdbarch *gdbarch, struct value *address,
>    else
>      {
>        /* Remove the top byte.  */
> -      addr = gdbarch_remove_non_address_bits (gdbarch, addr);
> +      addr = gdbarch_remove_non_addr_bits_memory (gdbarch, addr);
>  
>        /* Make sure we are dealing with a tagged address to begin with.  */
>        if (!aarch64_linux_tagged_address_p (gdbarch, address))
> @@ -2580,7 +2581,7 @@ aarch64_linux_get_memtag (struct gdbarch *gdbarch, struct value *address,
>  	return nullptr;
>  
>        /* Remove the top byte.  */
> -      addr = gdbarch_remove_non_address_bits (gdbarch, addr);
> +      addr = gdbarch_remove_non_addr_bits_memory (gdbarch, addr);
>        std::optional<CORE_ADDR> atag = aarch64_mte_get_atag (addr);
>  
>        if (!atag.has_value ())
> @@ -2654,8 +2655,9 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
>        uiout->text ("\n");
>  
>        std::optional<CORE_ADDR> atag
> -	= aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch,
> -								 fault_addr));
> +	= aarch64_mte_get_atag (
> +	    gdbarch_remove_non_addr_bits_memory (gdbarch, fault_addr));
> +
>        gdb_byte ltag = aarch64_mte_get_ltag (fault_addr);
>  
>        if (!atag.has_value ())
> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
> index 545ec872fd8..86d620bd181 100644
> --- a/gdb/aarch64-tdep.c
> +++ b/gdb/aarch64-tdep.c
> @@ -4582,9 +4582,15 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
>      tdep->ra_sign_state_regnum = ra_sign_state_offset + num_regs;
>  
>    /* Architecture hook to remove bits of a pointer that are not part of the
> -     address, like memory tags (MTE) and pointer authentication signatures.  */
> -  set_gdbarch_remove_non_address_bits (gdbarch,
> -				       aarch64_remove_non_address_bits);
> +     address, like memory tags (MTE) and pointer authentication signatures.
> +     Configure address adjustment for watch-, breakpoints and memory
> +     transfer.  */
> +  set_gdbarch_remove_non_addr_bits_wpt (gdbarch,
> +					aarch64_remove_non_address_bits);
> +  set_gdbarch_remove_non_addr_bits_bpt (gdbarch,
> +					aarch64_remove_non_address_bits);
> +  set_gdbarch_remove_non_addr_bits_memory (gdbarch,
> +					   aarch64_remove_non_address_bits);
>  
>    /* SME pseudo-registers.  */
>    if (tdep->has_sme ())
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 053d17df03e..24b322b9bb4 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -2234,7 +2234,7 @@ update_watchpoint (struct watchpoint *b, bool reparse)
>  		  loc->gdbarch = v->type ()->arch ();
>  		  loc->pspace = frame_pspace;
>  		  loc->address
> -		    = gdbarch_remove_non_address_bits (loc->gdbarch, addr);
> +		    = gdbarch_remove_non_addr_bits_wpt (loc->gdbarch, addr);
>  		  b->add_location (*loc);
>  
>  		  if (bitsize != 0)
> @@ -7473,7 +7473,7 @@ adjust_breakpoint_address (struct gdbarch *gdbarch,
>  	}
>  
>        adjusted_bpaddr
> -	= gdbarch_remove_non_address_bits (gdbarch, adjusted_bpaddr);
> +	= gdbarch_remove_non_addr_bits_bpt (gdbarch, adjusted_bpaddr);
>  
>        /* An adjusted breakpoint address can significantly alter
>  	 a user's expectations.  Print a warning if an adjustment
> diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
> index ebcff80bb9e..ec296c86668 100644
> --- a/gdb/gdbarch-gen.h
> +++ b/gdb/gdbarch-gen.h
> @@ -684,19 +684,47 @@ extern CORE_ADDR gdbarch_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR ad
>  extern void set_gdbarch_addr_bits_remove (struct gdbarch *gdbarch, gdbarch_addr_bits_remove_ftype *addr_bits_remove);
>  
>  /* On some architectures, not all bits of a pointer are significant.
> -   On AArch64, for example, the top bits of a pointer may carry a "tag", which
> -   can be ignored by the kernel and the hardware.  The "tag" can be regarded as
> -   additional data associated with the pointer, but it is not part of the address.
> +   On AArch64 and amd64, for example, the top bits of a pointer may carry a
> +   "tag", which can be ignored by the kernel and the hardware.  The "tag" can be
> +   regarded as additional data associated with the pointer, but it is not part
> +   of the address.
>  
>     Given a pointer for the architecture, this hook removes all the
> -   non-significant bits and sign-extends things as needed.  It gets used to remove
> -   non-address bits from data pointers (for example, removing the AArch64 MTE tag
> -   bits from a pointer) and from code pointers (removing the AArch64 PAC signature
> -   from a pointer containing the return address). */
> -
> -typedef CORE_ADDR (gdbarch_remove_non_address_bits_ftype) (struct gdbarch *gdbarch, CORE_ADDR pointer);
> -extern CORE_ADDR gdbarch_remove_non_address_bits (struct gdbarch *gdbarch, CORE_ADDR pointer);
> -extern void set_gdbarch_remove_non_address_bits (struct gdbarch *gdbarch, gdbarch_remove_non_address_bits_ftype *remove_non_address_bits);
> +   non-significant bits and sign-extends things as needed.  It gets used to
> +   remove non-address bits from pointers used for watchpoints. */
> +

Do we need to make a distinction between software watchpoint / hardware watchpoints?

> +typedef CORE_ADDR (gdbarch_remove_non_addr_bits_wpt_ftype) (struct gdbarch *gdbarch, CORE_ADDR pointer);
> +extern CORE_ADDR gdbarch_remove_non_addr_bits_wpt (struct gdbarch *gdbarch, CORE_ADDR pointer);
> +extern void set_gdbarch_remove_non_addr_bits_wpt (struct gdbarch *gdbarch, gdbarch_remove_non_addr_bits_wpt_ftype *remove_non_addr_bits_wpt);
> +
> +/* On some architectures, not all bits of a pointer are significant.
> +   On AArch64 and amd64, for example, the top bits of a pointer may carry a
> +   "tag", which can be ignored by the kernel and the hardware.  The "tag" can be
> +   regarded as additional data associated with the pointer, but it is not part
> +   of the address.
> +
> +   Given a pointer for the architecture, this hook removes all the
> +   non-significant bits and sign-extends things as needed.  It gets used to
> +   remove non-address bits from pointers used for breakpoints. */
> +

Similarly, do we need to make a distinction between software breakpoints and hardware breakpoints?

> +typedef CORE_ADDR (gdbarch_remove_non_addr_bits_bpt_ftype) (struct gdbarch *gdbarch, CORE_ADDR pointer);
> +extern CORE_ADDR gdbarch_remove_non_addr_bits_bpt (struct gdbarch *gdbarch, CORE_ADDR pointer);
> +extern void set_gdbarch_remove_non_addr_bits_bpt (struct gdbarch *gdbarch, gdbarch_remove_non_addr_bits_bpt_ftype *remove_non_addr_bits_bpt);
> +
> +/* On some architectures, not all bits of a pointer are significant.
> +   On AArch64 and amd64, for example, the top bits of a pointer may carry a
> +   "tag", which can be ignored by the kernel and the hardware.  The "tag" can be
> +   regarded as additional data associated with the pointer, but it is not part
> +   of the address.
> +
> +   Given a pointer for the architecture, this hook removes all the
> +   non-significant bits and sign-extends things as needed.  It gets used to
> +   remove non-address bits from any pointer used to access memory (called in
> +   memory_xfer_partial). */
> +
> +typedef CORE_ADDR (gdbarch_remove_non_addr_bits_memory_ftype) (struct gdbarch *gdbarch, CORE_ADDR pointer);
> +extern CORE_ADDR gdbarch_remove_non_addr_bits_memory (struct gdbarch *gdbarch, CORE_ADDR pointer);
> +extern void set_gdbarch_remove_non_addr_bits_memory (struct gdbarch *gdbarch, gdbarch_remove_non_addr_bits_memory_ftype *remove_non_addr_bits_memory);
>  
>  /* Return a string representation of the memory tag TAG. */
>  
> diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
> index 9319571deba..f59e090d294 100644
> --- a/gdb/gdbarch.c
> +++ b/gdb/gdbarch.c
> @@ -143,7 +143,9 @@ struct gdbarch
>    int frame_red_zone_size = 0;
>    gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity;
>    gdbarch_addr_bits_remove_ftype *addr_bits_remove = core_addr_identity;
> -  gdbarch_remove_non_address_bits_ftype *remove_non_address_bits = default_remove_non_address_bits;
> +  gdbarch_remove_non_addr_bits_wpt_ftype *remove_non_addr_bits_wpt = default_remove_non_address_bits;
> +  gdbarch_remove_non_addr_bits_bpt_ftype *remove_non_addr_bits_bpt = default_remove_non_address_bits;
> +  gdbarch_remove_non_addr_bits_memory_ftype *remove_non_addr_bits_memory = default_remove_non_address_bits;
>    gdbarch_memtag_to_string_ftype *memtag_to_string = default_memtag_to_string;
>    gdbarch_tagged_address_p_ftype *tagged_address_p = default_tagged_address_p;
>    gdbarch_memtag_matches_p_ftype *memtag_matches_p = default_memtag_matches_p;
> @@ -407,7 +409,9 @@ verify_gdbarch (struct gdbarch *gdbarch)
>    /* Skip verify of frame_red_zone_size, invalid_p == 0 */
>    /* Skip verify of convert_from_func_ptr_addr, invalid_p == 0 */
>    /* Skip verify of addr_bits_remove, invalid_p == 0 */
> -  /* Skip verify of remove_non_address_bits, invalid_p == 0 */
> +  /* Skip verify of remove_non_addr_bits_wpt, invalid_p == 0 */
> +  /* Skip verify of remove_non_addr_bits_bpt, invalid_p == 0 */
> +  /* Skip verify of remove_non_addr_bits_memory, invalid_p == 0 */
>    /* Skip verify of memtag_to_string, invalid_p == 0 */
>    /* Skip verify of tagged_address_p, invalid_p == 0 */
>    /* Skip verify of memtag_matches_p, invalid_p == 0 */
> @@ -910,8 +914,14 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
>  	      "gdbarch_dump: addr_bits_remove = <%s>\n",
>  	      host_address_to_string (gdbarch->addr_bits_remove));
>    gdb_printf (file,
> -	      "gdbarch_dump: remove_non_address_bits = <%s>\n",
> -	      host_address_to_string (gdbarch->remove_non_address_bits));
> +	      "gdbarch_dump: remove_non_addr_bits_wpt = <%s>\n",
> +	      host_address_to_string (gdbarch->remove_non_addr_bits_wpt));
> +  gdb_printf (file,
> +	      "gdbarch_dump: remove_non_addr_bits_bpt = <%s>\n",
> +	      host_address_to_string (gdbarch->remove_non_addr_bits_bpt));
> +  gdb_printf (file,
> +	      "gdbarch_dump: remove_non_addr_bits_memory = <%s>\n",
> +	      host_address_to_string (gdbarch->remove_non_addr_bits_memory));
>    gdb_printf (file,
>  	      "gdbarch_dump: memtag_to_string = <%s>\n",
>  	      host_address_to_string (gdbarch->memtag_to_string));
> @@ -3198,20 +3208,54 @@ set_gdbarch_addr_bits_remove (struct gdbarch *gdbarch,
>  }
>  
>  CORE_ADDR
> -gdbarch_remove_non_address_bits (struct gdbarch *gdbarch, CORE_ADDR pointer)
> +gdbarch_remove_non_addr_bits_wpt (struct gdbarch *gdbarch, CORE_ADDR pointer)
> +{
> +  gdb_assert (gdbarch != NULL);
> +  gdb_assert (gdbarch->remove_non_addr_bits_wpt != NULL);
> +  if (gdbarch_debug >= 2)
> +    gdb_printf (gdb_stdlog, "gdbarch_remove_non_addr_bits_wpt called\n");
> +  return gdbarch->remove_non_addr_bits_wpt (gdbarch, pointer);
> +}
> +
> +void
> +set_gdbarch_remove_non_addr_bits_wpt (struct gdbarch *gdbarch,
> +				      gdbarch_remove_non_addr_bits_wpt_ftype remove_non_addr_bits_wpt)
> +{
> +  gdbarch->remove_non_addr_bits_wpt = remove_non_addr_bits_wpt;
> +}
> +
> +CORE_ADDR
> +gdbarch_remove_non_addr_bits_bpt (struct gdbarch *gdbarch, CORE_ADDR pointer)
> +{
> +  gdb_assert (gdbarch != NULL);
> +  gdb_assert (gdbarch->remove_non_addr_bits_bpt != NULL);
> +  if (gdbarch_debug >= 2)
> +    gdb_printf (gdb_stdlog, "gdbarch_remove_non_addr_bits_bpt called\n");
> +  return gdbarch->remove_non_addr_bits_bpt (gdbarch, pointer);
> +}
> +
> +void
> +set_gdbarch_remove_non_addr_bits_bpt (struct gdbarch *gdbarch,
> +				      gdbarch_remove_non_addr_bits_bpt_ftype remove_non_addr_bits_bpt)
> +{
> +  gdbarch->remove_non_addr_bits_bpt = remove_non_addr_bits_bpt;
> +}
> +
> +CORE_ADDR
> +gdbarch_remove_non_addr_bits_memory (struct gdbarch *gdbarch, CORE_ADDR pointer)
>  {
>    gdb_assert (gdbarch != NULL);
> -  gdb_assert (gdbarch->remove_non_address_bits != NULL);
> +  gdb_assert (gdbarch->remove_non_addr_bits_memory != NULL);
>    if (gdbarch_debug >= 2)
> -    gdb_printf (gdb_stdlog, "gdbarch_remove_non_address_bits called\n");
> -  return gdbarch->remove_non_address_bits (gdbarch, pointer);
> +    gdb_printf (gdb_stdlog, "gdbarch_remove_non_addr_bits_memory called\n");
> +  return gdbarch->remove_non_addr_bits_memory (gdbarch, pointer);
>  }
>  
>  void
> -set_gdbarch_remove_non_address_bits (struct gdbarch *gdbarch,
> -				     gdbarch_remove_non_address_bits_ftype remove_non_address_bits)
> +set_gdbarch_remove_non_addr_bits_memory (struct gdbarch *gdbarch,
> +					 gdbarch_remove_non_addr_bits_memory_ftype remove_non_addr_bits_memory)
>  {
> -  gdbarch->remove_non_address_bits = remove_non_address_bits;
> +  gdbarch->remove_non_addr_bits_memory = remove_non_addr_bits_memory;
>  }
>  
>  std::string
> diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py
> index 7d913ade621..555bc4707c5 100644
> --- a/gdb/gdbarch_components.py
> +++ b/gdb/gdbarch_components.py
> @@ -1232,18 +1232,56 @@ possible it should be in TARGET_READ_PC instead).
>  Method(
>      comment="""
>  On some architectures, not all bits of a pointer are significant.
> -On AArch64, for example, the top bits of a pointer may carry a "tag", which
> -can be ignored by the kernel and the hardware.  The "tag" can be regarded as
> -additional data associated with the pointer, but it is not part of the address.
> +On AArch64 and amd64, for example, the top bits of a pointer may carry a
> +"tag", which can be ignored by the kernel and the hardware.  The "tag" can be
> +regarded as additional data associated with the pointer, but it is not part
> +of the address.
>  
>  Given a pointer for the architecture, this hook removes all the
> -non-significant bits and sign-extends things as needed.  It gets used to remove
> -non-address bits from data pointers (for example, removing the AArch64 MTE tag
> -bits from a pointer) and from code pointers (removing the AArch64 PAC signature
> -from a pointer containing the return address).
> +non-significant bits and sign-extends things as needed.  It gets used to
> +remove non-address bits from pointers used for watchpoints.
>  """,
>      type="CORE_ADDR",
> -    name="remove_non_address_bits",
> +    name="remove_non_addr_bits_wpt",
> +    params=[("CORE_ADDR", "pointer")],
> +    predefault="default_remove_non_address_bits",
> +    invalid=False,
> +)
> +
> +Method(
> +    comment="""
> +On some architectures, not all bits of a pointer are significant.
> +On AArch64 and amd64, for example, the top bits of a pointer may carry a
> +"tag", which can be ignored by the kernel and the hardware.  The "tag" can be
> +regarded as additional data associated with the pointer, but it is not part
> +of the address.
> +
> +Given a pointer for the architecture, this hook removes all the
> +non-significant bits and sign-extends things as needed.  It gets used to
> +remove non-address bits from pointers used for breakpoints.
> +""",
> +    type="CORE_ADDR",
> +    name="remove_non_addr_bits_bpt",
> +    params=[("CORE_ADDR", "pointer")],
> +    predefault="default_remove_non_address_bits",
> +    invalid=False,
> +)
> +
> +Method(
> +    comment="""
> +On some architectures, not all bits of a pointer are significant.
> +On AArch64 and amd64, for example, the top bits of a pointer may carry a
> +"tag", which can be ignored by the kernel and the hardware.  The "tag" can be
> +regarded as additional data associated with the pointer, but it is not part
> +of the address.
> +
> +Given a pointer for the architecture, this hook removes all the
> +non-significant bits and sign-extends things as needed.  It gets used to
> +remove non-address bits from any pointer used to access memory (called in
> +memory_xfer_partial).
> +""",
> +    type="CORE_ADDR",
> +    name="remove_non_addr_bits_memory",
>      params=[("CORE_ADDR", "pointer")],
>      predefault="default_remove_non_address_bits",
>      invalid=False,
> diff --git a/gdb/target.c b/gdb/target.c
> index 107a84b3ca1..586eee2ee73 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -1597,8 +1597,8 @@ memory_xfer_partial (struct target_ops *ops, enum target_object object,
>    if (len == 0)
>      return TARGET_XFER_EOF;
>  
> -  memaddr = gdbarch_remove_non_address_bits (current_inferior ()->arch (),
> -					     memaddr);
> +  memaddr = gdbarch_remove_non_addr_bits_memory (current_inferior ()->arch (),
> +				  		 memaddr);
>  
>    /* Fill in READBUF with breakpoint shadows, or WRITEBUF with
>       breakpoint insns, thus hiding out from higher layers whether


^ permalink raw reply	[relevance 0%]

* [PATCH 4/4] gdb: Add new remote packet to check if address is tagged
  @ 2024-03-28  7:00  3% ` Gustavo Romero
  0 siblings, 0 replies; 200+ results
From: Gustavo Romero @ 2024-03-28  7:00 UTC (permalink / raw)
  To: gdb-patches; +Cc: luis.machado, thiago.bauermann, gustavo.romero

This commit adds a new packet qMemTagAddrCheck allowing GDB remote
targets to use it to query gdbservers if a given address is tagged.

It also adds a new GDB remote feature, 'memory-tagging-check-add+',
which must be advertised by the GDB servers to inform GDB they can reply
to address checks via the new qMemTagAddrCheck remote packet.

Currently, this address check is done via a read query, where the
contents of /proc/<PID>/smaps is read and the flags in there are
inspected for MTE-related flags that indicate the address is in a tagged
memory region.

This is not ideal, for example, on QEMU gdbstub and in other cases,
like in baremetal debugging, where there is no notion of any OS file
like smaps. Hence, qMemTagAddrCheck packet allows check addresses in
an OS-agnostic way.

For supporting the new packet, a new target hook is introduced,
check_memtag_addr, which is used instead of the gdbarch_tagged_address_p
gdbarch hook in the upper layers (printcmd.c).

The new target hook is then specialized per target, for remote.c,
aarch64-linux-nat.c, and corelow.c targets (the current targets that
are MTE-aware).

The target hook in remote.c uses the qMemTagAddrCheck packet to check
an address if the server advertised the 'memory-tagging-check-add+'
feature, otherwise it falls back to using the current mechanism, i.e. it
reads the /proc/<PID>/smaps contents.

In the aarch64-linux-nat.c and corelow.c the target hook uses the
gdbarch_tagged_address_p gdbarch hook, so there is no change regarding
how an address is checked in these targets. Just the
gdbarch_tagged_address_p signature is changed for convenience, since
target_check_memtag_addr takes the address to be checked as a CORE_ADDR
type.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
---
 gdb/aarch64-linux-nat.c   |  8 +++++
 gdb/aarch64-linux-tdep.c  | 10 +++----
 gdb/arch-utils.c          |  2 +-
 gdb/arch-utils.h          |  2 +-
 gdb/corelow.c             |  8 +++++
 gdb/gdbarch-gen.h         |  4 +--
 gdb/gdbarch.c             |  2 +-
 gdb/gdbarch_components.py |  2 +-
 gdb/printcmd.c            | 27 +++++++++--------
 gdb/remote.c              | 62 +++++++++++++++++++++++++++++++++++++++
 gdb/target-delegates.c    | 28 ++++++++++++++++++
 gdb/target.c              |  6 ++++
 gdb/target.h              |  6 ++++
 13 files changed, 143 insertions(+), 24 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 3face34ce79..1c64df6af41 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -110,6 +110,8 @@ class aarch64_linux_nat_target final
   /* Write allocation tags to memory via PTRACE.  */
   bool store_memtags (CORE_ADDR address, size_t len,
 		      const gdb::byte_vector &tags, int type) override;
+  /* Check if an address is tagged.  */
+  bool check_memtag_addr (CORE_ADDR address) override;
 };
 
 static aarch64_linux_nat_target the_aarch64_linux_nat_target;
@@ -1071,6 +1073,12 @@ aarch64_linux_nat_target::store_memtags (CORE_ADDR address, size_t len,
   return false;
 }
 
+bool
+aarch64_linux_nat_target::check_memtag_addr (CORE_ADDR address)
+{
+  return gdbarch_tagged_address_p (current_inferior ()->arch (), address);
+}
+
 void _initialize_aarch64_linux_nat ();
 void
 _initialize_aarch64_linux_nat ()
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index fc60e602748..2a47c3f0845 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -2451,17 +2451,15 @@ aarch64_mte_get_atag (CORE_ADDR address)
 /* Implement the tagged_address_p gdbarch method.  */
 
 static bool
-aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, struct value *address)
+aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address)
 {
-  gdb_assert (address != nullptr);
-
-  CORE_ADDR addr = value_as_address (address);
+  gdb_assert (address);
 
   /* Remove the top byte for the memory range check.  */
-  addr = gdbarch_remove_non_address_bits (gdbarch, addr);
+  address = gdbarch_remove_non_address_bits (gdbarch, address);
 
   /* Check if the page that contains ADDRESS is mapped with PROT_MTE.  */
-  if (!linux_address_in_memtag_page (addr))
+  if (!linux_address_in_memtag_page (address))
     return false;
 
   /* We have a valid tag in the top byte of the 64-bit address.  */
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 456bfe971ff..cb149c36bc9 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -102,7 +102,7 @@ default_memtag_to_string (struct gdbarch *gdbarch, struct value *tag)
 /* See arch-utils.h */
 
 bool
-default_tagged_address_p (struct gdbarch *gdbarch, struct value *address)
+default_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address)
 {
   /* By default, assume the address is untagged.  */
   return false;
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 2dcd8f6dc53..467be40c688 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -141,7 +141,7 @@ extern std::string default_memtag_to_string (struct gdbarch *gdbarch,
 					     struct value *tag);
 
 /* Default implementation of gdbarch_tagged_address_p.  */
-bool default_tagged_address_p (struct gdbarch *gdbarch, struct value *address);
+bool default_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address);
 
 /* Default implementation of gdbarch_memtag_matches_p.  */
 extern bool default_memtag_matches_p (struct gdbarch *gdbarch,
diff --git a/gdb/corelow.c b/gdb/corelow.c
index f4e8273d962..676738825fb 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -109,6 +109,8 @@ class core_target final : public process_stratum_target
   bool fetch_memtags (CORE_ADDR address, size_t len,
 		      gdb::byte_vector &tags, int type) override;
 
+  bool check_memtag_addr (CORE_ADDR address) override;
+
   x86_xsave_layout fetch_x86_xsave_layout () override;
 
   /* A few helpers.  */
@@ -1410,6 +1412,12 @@ core_target::fetch_memtags (CORE_ADDR address, size_t len,
   return false;
 }
 
+bool
+core_target::check_memtag_addr (CORE_ADDR address)
+{
+  return gdbarch_tagged_address_p (current_inferior ()->arch (), address);
+}
+
 /* Implementation of the "fetch_x86_xsave_layout" target_ops method.  */
 
 x86_xsave_layout
diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
index ebcff80bb9e..63fab26987f 100644
--- a/gdb/gdbarch-gen.h
+++ b/gdb/gdbarch-gen.h
@@ -707,8 +707,8 @@ extern void set_gdbarch_memtag_to_string (struct gdbarch *gdbarch, gdbarch_memta
 /* Return true if ADDRESS contains a tag and false otherwise.  ADDRESS
    must be either a pointer or a reference type. */
 
-typedef bool (gdbarch_tagged_address_p_ftype) (struct gdbarch *gdbarch, struct value *address);
-extern bool gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address);
+typedef bool (gdbarch_tagged_address_p_ftype) (struct gdbarch *gdbarch, CORE_ADDR address);
+extern bool gdbarch_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address);
 extern void set_gdbarch_tagged_address_p (struct gdbarch *gdbarch, gdbarch_tagged_address_p_ftype *tagged_address_p);
 
 /* Return true if the tag from ADDRESS matches the memory tag for that
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 9319571deba..2d92f604c49 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -3232,7 +3232,7 @@ set_gdbarch_memtag_to_string (struct gdbarch *gdbarch,
 }
 
 bool
-gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address)
+gdbarch_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->tagged_address_p != NULL);
diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py
index 7d913ade621..24e979431b6 100644
--- a/gdb/gdbarch_components.py
+++ b/gdb/gdbarch_components.py
@@ -1267,7 +1267,7 @@ must be either a pointer or a reference type.
 """,
     type="bool",
     name="tagged_address_p",
-    params=[("struct value *", "address")],
+    params=[("CORE_ADDR", "address")],
     predefault="default_tagged_address_p",
     invalid=False,
 )
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index ae4d640ccf2..c81c75afc5d 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1132,7 +1132,7 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
 	    = value_from_ulongest (builtin_type (gdbarch)->builtin_data_ptr,
 				   tag_laddr);
 
-	  if (gdbarch_tagged_address_p (current_inferior ()->arch  (), v_addr))
+	  if (target_check_memtag_addr (value_as_address(v_addr)))
 	    {
 	      /* Fetch the allocation tag.  */
 	      struct value *tag
@@ -1289,7 +1289,7 @@ should_validate_memtags (struct value *value)
     return false;
 
   /* We do.  Check whether it includes any tags.  */
-  return gdbarch_tagged_address_p (current_inferior ()->arch  (), value);
+  return target_check_memtag_addr (value_as_address(value));
 }
 
 /* Helper for parsing arguments for print_command_1.  */
@@ -2946,9 +2946,10 @@ memory_tag_print_tag_command (const char *args, enum memtag_type tag_type)
      flag, it is no use trying to access/manipulate its allocation tag.
 
      It is OK to manipulate the logical tag though.  */
+  CORE_ADDR addr = value_as_address(val);
   if (tag_type == memtag_type::allocation
-      && !gdbarch_tagged_address_p (arch, val))
-    show_addr_not_tagged (value_as_address (val));
+      && !target_check_memtag_addr(addr))
+    show_addr_not_tagged (addr);
 
   value *tag_value = gdbarch_get_memtag (arch, val, tag_type);
   std::string tag = gdbarch_memtag_to_string (arch, tag_value);
@@ -3104,8 +3105,9 @@ parse_set_allocation_tag_input (const char *args, struct value **val,
 
   /* If the address is not in a region memory mapped with a memory tagging
      flag, it is no use trying to access/manipulate its allocation tag.  */
-  if (!gdbarch_tagged_address_p (current_inferior ()->arch (), *val))
-    show_addr_not_tagged (value_as_address (*val));
+  CORE_ADDR addr = value_as_address (*val);
+  if (!target_check_memtag_addr (addr))
+    show_addr_not_tagged (addr);
 }
 
 /* Implement the "memory-tag set-allocation-tag" command.
@@ -3129,8 +3131,9 @@ memory_tag_set_allocation_tag_command (const char *args, int from_tty)
 
   /* If the address is not in a region memory mapped with a memory tagging
      flag, it is no use trying to manipulate its allocation tag.  */
-  if (!gdbarch_tagged_address_p (current_inferior ()->arch (), val)) {
-    show_addr_not_tagged (value_as_address(val));
+  CORE_ADDR addr = value_as_address (val);
+  if (!target_check_memtag_addr (addr)) {
+    show_addr_not_tagged (addr);
   }
 
   if (!gdbarch_set_memtags (current_inferior ()->arch (), val, length, tags,
@@ -3158,12 +3161,12 @@ memory_tag_check_command (const char *args, int from_tty)
   struct value *val = process_print_command_args (args, &print_opts, true);
   gdbarch *arch = current_inferior ()->arch ();
 
+  CORE_ADDR addr = value_as_address (val);
+
   /* If the address is not in a region memory mapped with a memory tagging
      flag, it is no use trying to access/manipulate its allocation tag.  */
-  if (!gdbarch_tagged_address_p (arch, val))
-    show_addr_not_tagged (value_as_address (val));
-
-  CORE_ADDR addr = value_as_address (val);
+  if (!target_check_memtag_addr (addr))
+    show_addr_not_tagged (addr);
 
   /* Check if the tag is valid.  */
   if (!gdbarch_memtag_matches_p (arch, val))
diff --git a/gdb/remote.c b/gdb/remote.c
index e278711df7b..264adb686f8 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -337,6 +337,9 @@ enum {
      packets and the tag violation stop replies.  */
   PACKET_memory_tagging_feature,
 
+  /* Support checking if an address is tagged via qMemTagAddrCheck packet.  */
+  PACKET_memory_tagging_check_addr_feature,
+
   PACKET_MAX
 };
 
@@ -758,6 +761,10 @@ struct remote_features
   bool remote_memory_tagging_p () const
   { return packet_support (PACKET_memory_tagging_feature) == PACKET_ENABLE; }
 
+  bool remote_memory_tagging_check_addr_p () const
+  { return packet_support (PACKET_memory_tagging_check_addr_feature) ==
+			   PACKET_ENABLE; }
+
   /* Reset all packets back to "unknown support".  Called when opening a
      new connection to a remote target.  */
   void reset_all_packet_configs_support ();
@@ -1084,6 +1091,8 @@ class remote_target : public process_stratum_target
   bool store_memtags (CORE_ADDR address, size_t len,
 		      const gdb::byte_vector &tags, int type) override;
 
+  bool check_memtag_addr (CORE_ADDR address) override;
+
 public: /* Remote specific methods.  */
 
   void remote_download_command_source (int num, ULONGEST addr,
@@ -5762,6 +5771,8 @@ static const struct protocol_feature remote_protocol_features[] = {
   { "no-resumed", PACKET_DISABLE, remote_supported_packet, PACKET_no_resumed },
   { "memory-tagging", PACKET_DISABLE, remote_supported_packet,
     PACKET_memory_tagging_feature },
+  { "memory-tagging-check-addr", PACKET_DISABLE, remote_supported_packet,
+    PACKET_memory_tagging_check_addr_feature },
 };
 
 static char *remote_support_xml;
@@ -5873,6 +5884,10 @@ remote_target::remote_query_supported ()
 	  != AUTO_BOOLEAN_FALSE)
 	remote_query_supported_append (&q, "memory-tagging+");
 
+      if (m_features.packet_set_cmd_state (PACKET_memory_tagging_check_addr_feature)
+	  != AUTO_BOOLEAN_FALSE)
+	remote_query_supported_append (&q, "memory-tagging-check-addr+");
+
       /* Keep this one last to work around a gdbserver <= 7.10 bug in
 	 the qSupported:xmlRegisters=i386 handling.  */
       if (remote_support_xml != NULL
@@ -15532,6 +15547,19 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address,
   strcpy (packet.data (), request.c_str ());
 }
 
+static void
+create_check_memtag_addr_request (gdb::char_vector &packet, CORE_ADDR address)
+{
+  int addr_size = gdbarch_addr_bit (current_inferior ()->arch()) / 8;
+
+  std::string request = string_printf ("qMemTagAddrCheck:%s", phex_nz (address, addr_size));
+
+  if (packet.size () < request.length ())
+    error (_("Contents too big for packet qMemTagAddrCheck."));
+
+  strcpy (packet.data (), request.c_str ());
+}
+
 /* Implement the "fetch_memtags" target_ops method.  */
 
 bool
@@ -15573,6 +15601,36 @@ remote_target::store_memtags (CORE_ADDR address, size_t len,
   return packet_check_result (rs->buf).status () == PACKET_OK;
 }
 
+bool
+remote_target::check_memtag_addr (CORE_ADDR address)
+{
+  struct remote_state *rs = get_remote_state ();
+
+  if (!m_features.remote_memory_tagging_check_addr_p ())
+    /* Fallback to reading /proc/<PID>/smaps for checking if an address is
+       tagged or not.  */
+    return gdbarch_tagged_address_p (current_inferior ()->arch (), address);
+
+  create_check_memtag_addr_request (rs->buf, address);
+
+  putpkt (rs->buf);
+  getpkt (&rs->buf);
+
+  /* Check if reply is OK.  */
+  if ((packet_check_result (rs->buf.data ()) != PACKET_OK) || rs->buf.empty())
+    return false;
+
+  gdb_byte tagged_addr;
+  /* Convert only 2 hex digits, i.e. 1 byte in hex format.  */
+  hex2bin(rs->buf.data(), &tagged_addr , 1);
+  if (tagged_addr)
+    /* 01 means address is tagged.  */
+    return true;
+  else
+    /* 00 means address is not tagged.  */
+    return false;
+}
+
 /* Return true if remote target T is non-stop.  */
 
 bool
@@ -16056,6 +16114,10 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
   add_packet_config_cmd (PACKET_memory_tagging_feature,
 			 "memory-tagging-feature", "memory-tagging-feature", 0);
 
+  add_packet_config_cmd (PACKET_memory_tagging_check_addr_feature,
+			 "memory-tagging-check-addr-feature",
+			 "memory-tagging-check-addr-feature", 0);
+
   /* Assert that we've registered "set remote foo-packet" commands
      for all packet configs.  */
   {
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 59ea70458ad..fbd9e3f65b4 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -197,6 +197,7 @@ struct dummy_target : public target_ops
   bool supports_memory_tagging () override;
   bool fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2, int arg3) override;
   bool store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector &arg2, int arg3) override;
+  bool check_memtag_addr (CORE_ADDR arg0) override;
   x86_xsave_layout fetch_x86_xsave_layout () override;
 };
 
@@ -373,6 +374,7 @@ struct debug_target : public target_ops
   bool supports_memory_tagging () override;
   bool fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2, int arg3) override;
   bool store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector &arg2, int arg3) override;
+  bool check_memtag_addr (CORE_ADDR arg0) override;
   x86_xsave_layout fetch_x86_xsave_layout () override;
 };
 
@@ -4562,6 +4564,32 @@ debug_target::store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector
   return result;
 }
 
+bool
+target_ops::check_memtag_addr (CORE_ADDR arg0)
+{
+  return this->beneath ()->check_memtag_addr (arg0);
+}
+
+bool
+dummy_target::check_memtag_addr (CORE_ADDR arg0)
+{
+  tcomplain ();
+}
+
+bool
+debug_target::check_memtag_addr (CORE_ADDR arg0)
+{
+  gdb_printf (gdb_stdlog, "-> %s->check_memtag_addr (...)\n", this->beneath ()->shortname ());
+  bool result
+    = this->beneath ()->check_memtag_addr (arg0);
+  gdb_printf (gdb_stdlog, "<- %s->check_memtag_addr (", this->beneath ()->shortname ());
+  target_debug_print_CORE_ADDR (arg0);
+  gdb_puts (") = ", gdb_stdlog);
+  target_debug_print_bool (result);
+  gdb_puts ("\n", gdb_stdlog);
+  return result;
+}
+
 x86_xsave_layout
 target_ops::fetch_x86_xsave_layout ()
 {
diff --git a/gdb/target.c b/gdb/target.c
index 107a84b3ca1..938a0f76595 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -796,6 +796,12 @@ target_store_memtags (CORE_ADDR address, size_t len,
   return current_inferior ()->top_target ()->store_memtags (address, len, tags, type);
 }
 
+bool
+target_check_memtag_addr (CORE_ADDR address)
+{
+  return current_inferior ()->top_target ()->check_memtag_addr (address);
+}
+
 x86_xsave_layout
 target_fetch_x86_xsave_layout ()
 {
diff --git a/gdb/target.h b/gdb/target.h
index c9eaff16346..bb64d32994e 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1334,6 +1334,10 @@ struct target_ops
 				const gdb::byte_vector &tags, int type)
       TARGET_DEFAULT_NORETURN (tcomplain ());
 
+    /* Returns true if ADDRESS is tagged, otherwise returns false.  */
+    virtual bool check_memtag_addr (CORE_ADDR address)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
+
     /* Return the x86 XSAVE extended state area layout.  */
     virtual x86_xsave_layout fetch_x86_xsave_layout ()
       TARGET_DEFAULT_RETURN (x86_xsave_layout ());
@@ -2317,6 +2321,8 @@ extern bool target_fetch_memtags (CORE_ADDR address, size_t len,
 extern bool target_store_memtags (CORE_ADDR address, size_t len,
 				  const gdb::byte_vector &tags, int type);
 
+extern bool target_check_memtag_addr (CORE_ADDR address);
+
 extern x86_xsave_layout target_fetch_x86_xsave_layout ();
 
 /* Command logging facility.  */
-- 
2.34.1


^ permalink raw reply	[relevance 3%]

* Re: [PATCH 3/4 v5] gdb/debuginfod: Support on-demand debuginfo downloading
  @ 2024-03-27 23:56  0%     ` Aaron Merey
  0 siblings, 0 replies; 200+ results
From: Aaron Merey @ 2024-03-27 23:56 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches, Thiago Jung Bauermann

Hi Andrew,

On Wed, Mar 27, 2024 at 6:58 AM Andrew Burgess <aburgess@redhat.com> wrote:
> > +gdb::array_view<const gdb_byte>
> > +index_cache::lookup_gdb_index_debuginfod (const char *index_path,
> > +                                       std::unique_ptr<index_cache_resource> *resource)
> > +{
> > +  try
> > +    {
> > +      /* Try to map that file.  */
> > +      index_cache_resource_mmap *mmap_resource
> > +     = new index_cache_resource_mmap (index_path);
> > +
> > +      /* Hand the resource to the caller.  */
> > +      resource->reset (mmap_resource);
> > +
> > +      return gdb::array_view<const gdb_byte>
> > +       ((const gdb_byte *) mmap_resource->mapping.get (),
> > +        mmap_resource->mapping.size ());
> > +    }
> > +  catch (const gdb_exception_error &except)
> > +    {
> > +      warning (_("Unable to read %s: %s"), index_path, except.what ());
> > +    }
> > +
> > +  return {};
> > +}
>
> I wonder if the core of this function should be merged with
> lookup_gdb_index?  The core functionality should be identical, but
> there's already a little divergence.
>
> I'd be tempted to just rename lookup_gdb_index_debuginfod to
> lookup_gdb_index and have it be an overload, one that finds the index in
> a named file, and the other that takes a build-id, creates a filename,
> and then calls your new version.

Ok I'll change this.

> > diff --git a/gdb/dwarf2/public.h b/gdb/dwarf2/public.h
> > index efb754b5fe8..4d3776465c3 100644
> > --- a/gdb/dwarf2/public.h
> > +++ b/gdb/dwarf2/public.h
> > @@ -44,4 +44,11 @@ extern bool dwarf2_initialize_objfile
> >
> >  extern void dwarf2_build_frame_info (struct objfile *);
> >
> > +/* Query debuginfod for the .gdb_index associated with OBJFILE.  If
> > +   successful, create an objfile to hold the .gdb_index information
> > +   and act as a placeholder until the full debuginfo needs to be
> > +   downloaded.  */
> > +
> > +extern bool dwarf2_has_separate_index (struct objfile *);
>
> Unless I'm missing something then this comment is not correct.  This
> function doesn't create an objfile to held the .gdb_index does it?

My mistake, that comment should instead say something like "associate
the .gdb_index information with OBJFILE until the full debuginfo is
downloaded".  In earlier revisions of the patch, this function did
create a new objfile but the comment wasn't updated when the function
changed.

> > +void
> > +dwarf2_gdb_index::expand_all_symtabs (struct objfile *objfile)
> > +{
> > +  try
> > +    {
> > +      dwarf2_base_index_functions::expand_all_symtabs (objfile);
> > +    }
> > +  catch (const gdb_exception &e)
> > +    {
> > +      if ((objfile->flags & OBJF_DOWNLOAD_DEFERRED) == 0)
> > +     exception_print (gdb_stderr, e);
> > +      else
> > +     read_full_dwarf_from_debuginfod (objfile, this);
>
> This is the part that I don't really understand about this patch, why is
> the download and read of the full dwarf done in the exception path?
>
> How do we know that the exception that was thrown indicates we should go
> fetch the dwarf and not that some other error has occurred?
>
> I couldn't find any obvious path from which
> read_full_dwarf_from_debuginfod might throw an exception, but if it does
> then I guess we're not going to get the behaviour we expect.
>
> I guess my expectation, going into this patch, was that you would have
> generalised the index checking code in some way so that when we check
> the index and find a match, instead of reading the full DWARF, we'd
> download the info, and then read the full DWARF.
>
> I'm not saying that what you have is wrong, or that it needs to change,
> just that I found this approach surprising, and I don't really
> understand the design -- but I'm open to being convinced.

Performing the download and read in the exception path helps decouple
dwarf2_base_index_functions and dwarf2_gdb_index functions from
the lazy debuginfo logic.  This design also facilitates an early return
from these functions so that the next objfile in the progspace objfile
list can be searched for a match.  If the deferred download was
successful, this next objfile holds the actual DWARF that gdb is looking for.

It is possible that some unrelated error during the initial index search
triggers an unnecessary debuginfo download.  FWIW I have not come across
such a case.  If this turned out to be an issue later on, we could for
instance introduce a special exception type indicating whether or not
gdb should attempt to download the deferred debuginfo.

In any case, the chance of an unnecessary download with this patch is
vastly lower than the current approach of immediately downloading all
debuginfo.

Aaron


^ permalink raw reply	[relevance 0%]

* [PATCH v3 4/4] gdb, gdbserver, gdbsupport: remove includes of early headers
  @ 2024-03-26 19:06  1% ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-03-26 19:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Now that defs.h, server.h and common-defs.h are included via the
`-include` option, it is no longer necessary for source files to include
it.  Remove all the inclusions of these files I could find.  Update the
generation scripts where relevant.

Change-Id: Ia026cff269c1b7ae7386dd3619bc9bb6a5332837
---
 gdb/aarch32-linux-nat.c                              | 1 -
 gdb/aarch32-tdep.c                                   | 2 --
 gdb/aarch64-fbsd-nat.c                               | 1 -
 gdb/aarch64-fbsd-tdep.c                              | 1 -
 gdb/aarch64-linux-nat.c                              | 1 -
 gdb/aarch64-linux-tdep.c                             | 1 -
 gdb/aarch64-nat.c                                    | 1 -
 gdb/aarch64-newlib-tdep.c                            | 1 -
 gdb/aarch64-ravenscar-thread.c                       | 1 -
 gdb/aarch64-tdep.c                                   | 1 -
 gdb/ada-exp.y                                        | 1 -
 gdb/ada-lang.c                                       | 1 -
 gdb/ada-tasks.c                                      | 1 -
 gdb/ada-typeprint.c                                  | 1 -
 gdb/ada-valprint.c                                   | 1 -
 gdb/ada-varobj.c                                     | 1 -
 gdb/addrmap.c                                        | 1 -
 gdb/agent.c                                          | 1 -
 gdb/aix-thread.c                                     | 1 -
 gdb/alloc.c                                          | 7 +------
 gdb/alpha-bsd-nat.c                                  | 1 -
 gdb/alpha-bsd-tdep.c                                 | 1 -
 gdb/alpha-linux-nat.c                                | 1 -
 gdb/alpha-linux-tdep.c                               | 1 -
 gdb/alpha-mdebug-tdep.c                              | 1 -
 gdb/alpha-netbsd-tdep.c                              | 1 -
 gdb/alpha-obsd-tdep.c                                | 1 -
 gdb/alpha-tdep.c                                     | 1 -
 gdb/amd-dbgapi-target.c                              | 1 -
 gdb/amd64-bsd-nat.c                                  | 1 -
 gdb/amd64-darwin-tdep.c                              | 1 -
 gdb/amd64-dicos-tdep.c                               | 1 -
 gdb/amd64-fbsd-nat.c                                 | 1 -
 gdb/amd64-fbsd-tdep.c                                | 1 -
 gdb/amd64-linux-nat.c                                | 1 -
 gdb/amd64-linux-tdep.c                               | 1 -
 gdb/amd64-nat.c                                      | 1 -
 gdb/amd64-netbsd-nat.c                               | 1 -
 gdb/amd64-netbsd-tdep.c                              | 1 -
 gdb/amd64-obsd-nat.c                                 | 1 -
 gdb/amd64-obsd-tdep.c                                | 1 -
 gdb/amd64-ravenscar-thread.c                         | 1 -
 gdb/amd64-sol2-tdep.c                                | 1 -
 gdb/amd64-tdep.c                                     | 1 -
 gdb/amd64-windows-nat.c                              | 1 -
 gdb/amd64-windows-tdep.c                             | 1 -
 gdb/amdgpu-tdep.c                                    | 1 -
 gdb/annotate.c                                       | 1 -
 gdb/arc-linux-nat.c                                  | 1 -
 gdb/arc-linux-tdep.c                                 | 1 -
 gdb/arc-newlib-tdep.c                                | 1 -
 gdb/arc-tdep.c                                       | 1 -
 gdb/arch-utils.c                                     | 1 -
 gdb/arch/aarch32.c                                   | 1 -
 gdb/arch/aarch64-insn.c                              | 1 -
 gdb/arch/aarch64-mte-linux.h                         | 1 -
 gdb/arch/aarch64-scalable-linux.h                    | 1 -
 gdb/arch/aarch64.c                                   | 1 -
 gdb/arch/amd64.c                                     | 1 -
 gdb/arch/arc.c                                       | 1 -
 gdb/arch/arm-get-next-pcs.c                          | 1 -
 gdb/arch/arm-linux.c                                 | 1 -
 gdb/arch/arm.c                                       | 1 -
 gdb/arch/csky.c                                      | 1 -
 gdb/arch/i386.c                                      | 1 -
 gdb/arch/loongarch.c                                 | 1 -
 gdb/arch/ppc-linux-common.c                          | 1 -
 gdb/arch/riscv.c                                     | 1 -
 gdb/arch/tic6x.c                                     | 1 -
 gdb/arm-bsd-tdep.c                                   | 1 -
 gdb/arm-fbsd-nat.c                                   | 1 -
 gdb/arm-fbsd-tdep.c                                  | 1 -
 gdb/arm-linux-nat.c                                  | 1 -
 gdb/arm-linux-tdep.c                                 | 1 -
 gdb/arm-netbsd-nat.c                                 | 1 -
 gdb/arm-netbsd-tdep.c                                | 1 -
 gdb/arm-none-tdep.c                                  | 1 -
 gdb/arm-obsd-tdep.c                                  | 1 -
 gdb/arm-pikeos-tdep.c                                | 1 -
 gdb/arm-tdep.c                                       | 1 -
 gdb/arm-wince-tdep.c                                 | 1 -
 gdb/async-event.c                                    | 1 -
 gdb/auto-load.c                                      | 1 -
 gdb/auxv.c                                           | 1 -
 gdb/avr-tdep.c                                       | 1 -
 gdb/ax-gdb.c                                         | 1 -
 gdb/ax-general.c                                     | 1 -
 gdb/bcache.c                                         | 1 -
 gdb/bfd-target.c                                     | 1 -
 gdb/bfin-linux-tdep.c                                | 1 -
 gdb/bfin-tdep.c                                      | 1 -
 gdb/block.c                                          | 1 -
 gdb/blockframe.c                                     | 1 -
 gdb/bpf-tdep.c                                       | 1 -
 gdb/break-catch-exec.c                               | 1 -
 gdb/break-catch-fork.c                               | 1 -
 gdb/break-catch-load.c                               | 1 -
 gdb/break-catch-sig.c                                | 1 -
 gdb/break-catch-syscall.c                            | 1 -
 gdb/break-catch-throw.c                              | 1 -
 gdb/breakpoint.c                                     | 1 -
 gdb/bsd-kvm.c                                        | 1 -
 gdb/bsd-uthread.c                                    | 1 -
 gdb/bt-utils.c                                       | 1 -
 gdb/btrace.c                                         | 1 -
 gdb/build-id.c                                       | 1 -
 gdb/buildsym-legacy.c                                | 1 -
 gdb/buildsym.c                                       | 1 -
 gdb/c-exp.y                                          | 1 -
 gdb/c-lang.c                                         | 1 -
 gdb/c-typeprint.c                                    | 1 -
 gdb/c-valprint.c                                     | 1 -
 gdb/c-varobj.c                                       | 1 -
 gdb/charset.c                                        | 1 -
 gdb/cli-out.c                                        | 1 -
 gdb/cli/cli-cmds.c                                   | 1 -
 gdb/cli/cli-decode.c                                 | 1 -
 gdb/cli/cli-dump.c                                   | 1 -
 gdb/cli/cli-interp.c                                 | 1 -
 gdb/cli/cli-logging.c                                | 1 -
 gdb/cli/cli-option.c                                 | 1 -
 gdb/cli/cli-script.c                                 | 1 -
 gdb/cli/cli-setshow.c                                | 1 -
 gdb/cli/cli-style.c                                  | 1 -
 gdb/cli/cli-utils.c                                  | 1 -
 gdb/coff-pe-read.c                                   | 1 -
 gdb/coffread.c                                       | 1 -
 gdb/compile/compile-c-support.c                      | 1 -
 gdb/compile/compile-c-symbols.c                      | 1 -
 gdb/compile/compile-c-types.c                        | 1 -
 gdb/compile/compile-cplus-symbols.c                  | 1 -
 gdb/compile/compile-cplus-types.c                    | 1 -
 gdb/compile/compile-loc2c.c                          | 1 -
 gdb/compile/compile-object-load.c                    | 1 -
 gdb/compile/compile-object-run.c                     | 1 -
 gdb/compile/compile.c                                | 1 -
 gdb/complaints.c                                     | 1 -
 gdb/completer.c                                      | 1 -
 gdb/copying.awk                                      | 1 -
 gdb/copying.c                                        | 1 -
 gdb/corefile.c                                       | 1 -
 gdb/corelow.c                                        | 1 -
 gdb/cp-abi.c                                         | 1 -
 gdb/cp-name-parser.y                                 | 1 -
 gdb/cp-namespace.c                                   | 1 -
 gdb/cp-support.c                                     | 1 -
 gdb/cp-valprint.c                                    | 1 -
 gdb/cris-linux-tdep.c                                | 1 -
 gdb/cris-tdep.c                                      | 1 -
 gdb/csky-linux-tdep.c                                | 1 -
 gdb/csky-tdep.c                                      | 1 -
 gdb/ctfread.c                                        | 1 -
 gdb/d-exp.y                                          | 1 -
 gdb/d-lang.c                                         | 1 -
 gdb/d-namespace.c                                    | 1 -
 gdb/d-valprint.c                                     | 1 -
 gdb/darwin-nat-info.c                                | 1 -
 gdb/darwin-nat.c                                     | 1 -
 gdb/dbxread.c                                        | 1 -
 gdb/dcache.c                                         | 1 -
 gdb/debug.c                                          | 1 -
 gdb/debuginfod-support.c                             | 1 -
 gdb/dicos-tdep.c                                     | 1 -
 gdb/dictionary.c                                     | 1 -
 gdb/disasm-selftests.c                               | 1 -
 gdb/disasm.c                                         | 1 -
 gdb/displaced-stepping.c                             | 1 -
 gdb/dtrace-probe.c                                   | 1 -
 gdb/dummy-frame.c                                    | 1 -
 gdb/dwarf2/abbrev-cache.c                            | 1 -
 gdb/dwarf2/abbrev.c                                  | 1 -
 gdb/dwarf2/ada-imported.c                            | 1 -
 gdb/dwarf2/aranges.c                                 | 1 -
 gdb/dwarf2/attribute.c                               | 1 -
 gdb/dwarf2/comp-unit-head.c                          | 1 -
 gdb/dwarf2/cooked-index.c                            | 1 -
 gdb/dwarf2/cu.c                                      | 1 -
 gdb/dwarf2/die.c                                     | 1 -
 gdb/dwarf2/dwz.c                                     | 1 -
 gdb/dwarf2/expr.c                                    | 1 -
 gdb/dwarf2/frame-tailcall.c                          | 1 -
 gdb/dwarf2/frame.c                                   | 1 -
 gdb/dwarf2/index-cache.c                             | 1 -
 gdb/dwarf2/index-common.c                            | 1 -
 gdb/dwarf2/index-write.c                             | 1 -
 gdb/dwarf2/leb.c                                     | 1 -
 gdb/dwarf2/line-header.c                             | 1 -
 gdb/dwarf2/loc.c                                     | 1 -
 gdb/dwarf2/macro.c                                   | 1 -
 gdb/dwarf2/read-debug-names.c                        | 1 -
 gdb/dwarf2/read-gdb-index.c                          | 1 -
 gdb/dwarf2/read.c                                    | 1 -
 gdb/dwarf2/section.c                                 | 1 -
 gdb/dwarf2/stringify.c                               | 1 -
 gdb/elf-none-tdep.c                                  | 1 -
 gdb/elfread.c                                        | 1 -
 gdb/eval.c                                           | 1 -
 gdb/event-top.c                                      | 1 -
 gdb/exceptions.c                                     | 1 -
 gdb/exec.c                                           | 1 -
 gdb/expprint.c                                       | 1 -
 gdb/extension.c                                      | 1 -
 gdb/f-array-walker.h                                 | 1 -
 gdb/f-exp.y                                          | 1 -
 gdb/f-lang.c                                         | 1 -
 gdb/f-typeprint.c                                    | 1 -
 gdb/f-valprint.c                                     | 1 -
 gdb/fbsd-nat.c                                       | 1 -
 gdb/fbsd-tdep.c                                      | 1 -
 gdb/features/microblaze-with-stack-protect.c         | 1 -
 gdb/features/microblaze.c                            | 1 -
 gdb/features/mips-dsp-linux.c                        | 1 -
 gdb/features/mips-linux.c                            | 1 -
 gdb/features/mips64-dsp-linux.c                      | 1 -
 gdb/features/mips64-linux.c                          | 1 -
 gdb/features/nds32.c                                 | 1 -
 gdb/features/nios2.c                                 | 1 -
 gdb/features/or1k-linux.c                            | 1 -
 gdb/features/or1k.c                                  | 1 -
 gdb/features/rs6000/powerpc-32.c                     | 1 -
 gdb/features/rs6000/powerpc-32l.c                    | 1 -
 gdb/features/rs6000/powerpc-403.c                    | 1 -
 gdb/features/rs6000/powerpc-403gc.c                  | 1 -
 gdb/features/rs6000/powerpc-405.c                    | 1 -
 gdb/features/rs6000/powerpc-505.c                    | 1 -
 gdb/features/rs6000/powerpc-601.c                    | 1 -
 gdb/features/rs6000/powerpc-602.c                    | 1 -
 gdb/features/rs6000/powerpc-603.c                    | 1 -
 gdb/features/rs6000/powerpc-604.c                    | 1 -
 gdb/features/rs6000/powerpc-64.c                     | 1 -
 gdb/features/rs6000/powerpc-64l.c                    | 1 -
 gdb/features/rs6000/powerpc-7400.c                   | 1 -
 gdb/features/rs6000/powerpc-750.c                    | 1 -
 gdb/features/rs6000/powerpc-860.c                    | 1 -
 gdb/features/rs6000/powerpc-altivec32.c              | 1 -
 gdb/features/rs6000/powerpc-altivec32l.c             | 1 -
 gdb/features/rs6000/powerpc-altivec64.c              | 1 -
 gdb/features/rs6000/powerpc-altivec64l.c             | 1 -
 gdb/features/rs6000/powerpc-e500.c                   | 1 -
 gdb/features/rs6000/powerpc-e500l.c                  | 1 -
 gdb/features/rs6000/powerpc-isa205-32l.c             | 1 -
 gdb/features/rs6000/powerpc-isa205-64l.c             | 1 -
 gdb/features/rs6000/powerpc-isa205-altivec32l.c      | 1 -
 gdb/features/rs6000/powerpc-isa205-altivec64l.c      | 1 -
 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c | 1 -
 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c | 1 -
 gdb/features/rs6000/powerpc-isa205-vsx32l.c          | 1 -
 gdb/features/rs6000/powerpc-isa205-vsx64l.c          | 1 -
 gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c      | 1 -
 gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c      | 1 -
 gdb/features/rs6000/powerpc-isa207-vsx32l.c          | 1 -
 gdb/features/rs6000/powerpc-isa207-vsx64l.c          | 1 -
 gdb/features/rs6000/powerpc-vsx32.c                  | 1 -
 gdb/features/rs6000/powerpc-vsx32l.c                 | 1 -
 gdb/features/rs6000/powerpc-vsx64.c                  | 1 -
 gdb/features/rs6000/powerpc-vsx64l.c                 | 1 -
 gdb/features/rs6000/rs6000.c                         | 1 -
 gdb/features/rx.c                                    | 1 -
 gdb/features/s390-gs-linux64.c                       | 1 -
 gdb/features/s390-linux32.c                          | 1 -
 gdb/features/s390-linux32v1.c                        | 1 -
 gdb/features/s390-linux32v2.c                        | 1 -
 gdb/features/s390-linux64.c                          | 1 -
 gdb/features/s390-linux64v1.c                        | 1 -
 gdb/features/s390-linux64v2.c                        | 1 -
 gdb/features/s390-te-linux64.c                       | 1 -
 gdb/features/s390-tevx-linux64.c                     | 1 -
 gdb/features/s390-vx-linux64.c                       | 1 -
 gdb/features/s390x-gs-linux64.c                      | 1 -
 gdb/features/s390x-linux64.c                         | 1 -
 gdb/features/s390x-linux64v1.c                       | 1 -
 gdb/features/s390x-linux64v2.c                       | 1 -
 gdb/features/s390x-te-linux64.c                      | 1 -
 gdb/features/s390x-tevx-linux64.c                    | 1 -
 gdb/features/s390x-vx-linux64.c                      | 1 -
 gdb/features/sparc/sparc32-solaris.c                 | 1 -
 gdb/features/sparc/sparc64-solaris.c                 | 1 -
 gdb/features/z80.c                                   | 1 -
 gdb/filename-seen-cache.c                            | 1 -
 gdb/filename-seen-cache.h                            | 1 -
 gdb/filesystem.c                                     | 1 -
 gdb/findcmd.c                                        | 1 -
 gdb/findvar.c                                        | 1 -
 gdb/fork-child.c                                     | 1 -
 gdb/frame-base.c                                     | 1 -
 gdb/frame-unwind.c                                   | 1 -
 gdb/frame.c                                          | 1 -
 gdb/frv-linux-tdep.c                                 | 1 -
 gdb/frv-tdep.c                                       | 1 -
 gdb/ft32-tdep.c                                      | 1 -
 gdb/gcore-elf.c                                      | 1 -
 gdb/gcore.c                                          | 1 -
 gdb/gdb-demangle.c                                   | 1 -
 gdb/gdb.c                                            | 1 -
 gdb/gdb_bfd.c                                        | 1 -
 gdb/gdbarch-selftests.c                              | 1 -
 gdb/gdbtypes.c                                       | 1 -
 gdb/glibc-tdep.c                                     | 1 -
 gdb/gmp-utils.c                                      | 1 -
 gdb/gnu-nat.c                                        | 1 -
 gdb/gnu-nat.h                                        | 2 --
 gdb/gnu-v2-abi.c                                     | 1 -
 gdb/gnu-v3-abi.c                                     | 1 -
 gdb/go-exp.y                                         | 1 -
 gdb/go-lang.c                                        | 1 -
 gdb/go-typeprint.c                                   | 1 -
 gdb/go-valprint.c                                    | 1 -
 gdb/go32-nat.c                                       | 1 -
 gdb/guile/guile.c                                    | 1 -
 gdb/guile/scm-arch.c                                 | 1 -
 gdb/guile/scm-auto-load.c                            | 1 -
 gdb/guile/scm-block.c                                | 1 -
 gdb/guile/scm-breakpoint.c                           | 1 -
 gdb/guile/scm-cmd.c                                  | 1 -
 gdb/guile/scm-disasm.c                               | 1 -
 gdb/guile/scm-exception.c                            | 1 -
 gdb/guile/scm-frame.c                                | 1 -
 gdb/guile/scm-gsmob.c                                | 1 -
 gdb/guile/scm-iterator.c                             | 1 -
 gdb/guile/scm-lazy-string.c                          | 1 -
 gdb/guile/scm-math.c                                 | 1 -
 gdb/guile/scm-objfile.c                              | 1 -
 gdb/guile/scm-param.c                                | 1 -
 gdb/guile/scm-ports.c                                | 1 -
 gdb/guile/scm-pretty-print.c                         | 1 -
 gdb/guile/scm-progspace.c                            | 1 -
 gdb/guile/scm-safe-call.c                            | 1 -
 gdb/guile/scm-string.c                               | 1 -
 gdb/guile/scm-symbol.c                               | 1 -
 gdb/guile/scm-symtab.c                               | 1 -
 gdb/guile/scm-type.c                                 | 1 -
 gdb/guile/scm-utils.c                                | 1 -
 gdb/guile/scm-value.c                                | 1 -
 gdb/h8300-tdep.c                                     | 1 -
 gdb/hppa-bsd-tdep.c                                  | 1 -
 gdb/hppa-linux-nat.c                                 | 1 -
 gdb/hppa-linux-tdep.c                                | 1 -
 gdb/hppa-netbsd-nat.c                                | 1 -
 gdb/hppa-netbsd-tdep.c                               | 1 -
 gdb/hppa-obsd-nat.c                                  | 1 -
 gdb/hppa-obsd-tdep.c                                 | 1 -
 gdb/hppa-tdep.c                                      | 1 -
 gdb/i386-bsd-nat.c                                   | 1 -
 gdb/i386-bsd-tdep.c                                  | 1 -
 gdb/i386-darwin-nat.c                                | 1 -
 gdb/i386-darwin-tdep.c                               | 1 -
 gdb/i386-dicos-tdep.c                                | 1 -
 gdb/i386-fbsd-nat.c                                  | 1 -
 gdb/i386-fbsd-tdep.c                                 | 1 -
 gdb/i386-gnu-nat.c                                   | 1 -
 gdb/i386-gnu-tdep.c                                  | 1 -
 gdb/i386-go32-tdep.c                                 | 1 -
 gdb/i386-linux-nat.c                                 | 1 -
 gdb/i386-linux-tdep.c                                | 1 -
 gdb/i386-netbsd-nat.c                                | 1 -
 gdb/i386-netbsd-tdep.c                               | 1 -
 gdb/i386-nto-tdep.c                                  | 1 -
 gdb/i386-obsd-nat.c                                  | 1 -
 gdb/i386-obsd-tdep.c                                 | 1 -
 gdb/i386-sol2-nat.c                                  | 1 -
 gdb/i386-sol2-tdep.c                                 | 1 -
 gdb/i386-tdep.c                                      | 1 -
 gdb/i386-windows-nat.c                               | 1 -
 gdb/i386-windows-tdep.c                              | 1 -
 gdb/i387-tdep.c                                      | 1 -
 gdb/ia64-libunwind-tdep.c                            | 1 -
 gdb/ia64-linux-nat.c                                 | 1 -
 gdb/ia64-linux-tdep.c                                | 1 -
 gdb/ia64-tdep.c                                      | 1 -
 gdb/ia64-vms-tdep.c                                  | 1 -
 gdb/inf-child.c                                      | 1 -
 gdb/inf-loop.c                                       | 1 -
 gdb/inf-ptrace.c                                     | 1 -
 gdb/infcall.c                                        | 1 -
 gdb/infcmd.c                                         | 1 -
 gdb/inferior.c                                       | 1 -
 gdb/inflow.c                                         | 1 -
 gdb/infrun.c                                         | 1 -
 gdb/inline-frame.c                                   | 1 -
 gdb/interps.c                                        | 1 -
 gdb/iq2000-tdep.c                                    | 1 -
 gdb/jit.c                                            | 1 -
 gdb/language.c                                       | 1 -
 gdb/linespec.c                                       | 1 -
 gdb/linux-fork.c                                     | 1 -
 gdb/linux-nat-trad.c                                 | 1 -
 gdb/linux-nat.c                                      | 1 -
 gdb/linux-record.c                                   | 1 -
 gdb/linux-tdep.c                                     | 1 -
 gdb/linux-thread-db.c                                | 1 -
 gdb/lm32-tdep.c                                      | 1 -
 gdb/location.c                                       | 1 -
 gdb/loongarch-linux-nat.c                            | 1 -
 gdb/loongarch-linux-tdep.c                           | 1 -
 gdb/loongarch-tdep.c                                 | 1 -
 gdb/m2-exp.y                                         | 1 -
 gdb/m2-lang.c                                        | 1 -
 gdb/m2-typeprint.c                                   | 1 -
 gdb/m2-valprint.c                                    | 1 -
 gdb/m32c-tdep.c                                      | 1 -
 gdb/m32r-linux-nat.c                                 | 1 -
 gdb/m32r-linux-tdep.c                                | 1 -
 gdb/m32r-tdep.c                                      | 1 -
 gdb/m68hc11-tdep.c                                   | 1 -
 gdb/m68k-bsd-nat.c                                   | 1 -
 gdb/m68k-bsd-tdep.c                                  | 1 -
 gdb/m68k-linux-nat.c                                 | 1 -
 gdb/m68k-linux-tdep.c                                | 1 -
 gdb/m68k-tdep.c                                      | 1 -
 gdb/machoread.c                                      | 1 -
 gdb/macrocmd.c                                       | 1 -
 gdb/macroexp.c                                       | 1 -
 gdb/macroscope.c                                     | 1 -
 gdb/macrotab.c                                       | 1 -
 gdb/main.c                                           | 1 -
 gdb/maint-test-options.c                             | 1 -
 gdb/maint-test-settings.c                            | 1 -
 gdb/maint.c                                          | 1 -
 gdb/make-init-c                                      | 1 -
 gdb/mdebugread.c                                     | 1 -
 gdb/mem-break.c                                      | 1 -
 gdb/memattr.c                                        | 1 -
 gdb/memory-map.c                                     | 1 -
 gdb/memrange.c                                       | 1 -
 gdb/memtag.c                                         | 1 -
 gdb/mep-tdep.c                                       | 1 -
 gdb/mi/mi-cmd-break.c                                | 1 -
 gdb/mi/mi-cmd-catch.c                                | 1 -
 gdb/mi/mi-cmd-disas.c                                | 1 -
 gdb/mi/mi-cmd-env.c                                  | 1 -
 gdb/mi/mi-cmd-file.c                                 | 1 -
 gdb/mi/mi-cmd-info.c                                 | 1 -
 gdb/mi/mi-cmd-stack.c                                | 1 -
 gdb/mi/mi-cmd-target.c                               | 1 -
 gdb/mi/mi-cmd-var.c                                  | 1 -
 gdb/mi/mi-cmds.c                                     | 1 -
 gdb/mi/mi-common.c                                   | 1 -
 gdb/mi/mi-console.c                                  | 1 -
 gdb/mi/mi-getopt.c                                   | 1 -
 gdb/mi/mi-interp.c                                   | 1 -
 gdb/mi/mi-main.c                                     | 1 -
 gdb/mi/mi-out.c                                      | 1 -
 gdb/mi/mi-parse.c                                    | 1 -
 gdb/mi/mi-symbol-cmds.c                              | 1 -
 gdb/microblaze-linux-tdep.c                          | 1 -
 gdb/microblaze-tdep.c                                | 1 -
 gdb/mingw-hdep.c                                     | 1 -
 gdb/minidebug.c                                      | 1 -
 gdb/minsyms.c                                        | 1 -
 gdb/mips-fbsd-nat.c                                  | 1 -
 gdb/mips-fbsd-tdep.c                                 | 1 -
 gdb/mips-linux-nat.c                                 | 1 -
 gdb/mips-linux-tdep.c                                | 1 -
 gdb/mips-netbsd-nat.c                                | 1 -
 gdb/mips-netbsd-tdep.c                               | 1 -
 gdb/mips-sde-tdep.c                                  | 1 -
 gdb/mips-tdep.c                                      | 1 -
 gdb/mips64-obsd-nat.c                                | 1 -
 gdb/mips64-obsd-tdep.c                               | 1 -
 gdb/mipsread.c                                       | 1 -
 gdb/mn10300-linux-tdep.c                             | 1 -
 gdb/mn10300-tdep.c                                   | 1 -
 gdb/moxie-tdep.c                                     | 1 -
 gdb/msp430-tdep.c                                    | 1 -
 gdb/namespace.c                                      | 1 -
 gdb/nat/aarch64-hw-point.c                           | 1 -
 gdb/nat/aarch64-linux-hw-point.c                     | 1 -
 gdb/nat/aarch64-linux.c                              | 1 -
 gdb/nat/aarch64-mte-linux-ptrace.c                   | 1 -
 gdb/nat/aarch64-scalable-linux-ptrace.c              | 1 -
 gdb/nat/amd64-linux-siginfo.c                        | 1 -
 gdb/nat/fork-inferior.c                              | 1 -
 gdb/nat/linux-btrace.c                               | 1 -
 gdb/nat/linux-namespaces.c                           | 1 -
 gdb/nat/linux-osdata.c                               | 1 -
 gdb/nat/linux-personality.c                          | 1 -
 gdb/nat/linux-procfs.c                               | 1 -
 gdb/nat/linux-ptrace.c                               | 1 -
 gdb/nat/linux-waitpid.c                              | 1 -
 gdb/nat/mips-linux-watch.c                           | 1 -
 gdb/nat/netbsd-nat.c                                 | 1 -
 gdb/nat/ppc-linux.c                                  | 1 -
 gdb/nat/riscv-linux-tdesc.c                          | 1 -
 gdb/nat/windows-nat.c                                | 1 -
 gdb/nat/x86-dregs.c                                  | 1 -
 gdb/nat/x86-linux-dregs.c                            | 1 -
 gdb/nat/x86-linux.c                                  | 1 -
 gdb/nat/x86-xstate.c                                 | 1 -
 gdb/nds32-tdep.c                                     | 1 -
 gdb/netbsd-nat.c                                     | 1 -
 gdb/netbsd-tdep.c                                    | 1 -
 gdb/nios2-linux-tdep.c                               | 1 -
 gdb/nios2-tdep.c                                     | 1 -
 gdb/nto-procfs.c                                     | 1 -
 gdb/nto-tdep.c                                       | 1 -
 gdb/objc-lang.c                                      | 1 -
 gdb/objfiles.c                                       | 1 -
 gdb/obsd-nat.c                                       | 1 -
 gdb/obsd-tdep.c                                      | 1 -
 gdb/observable.c                                     | 1 -
 gdb/opencl-lang.c                                    | 1 -
 gdb/or1k-linux-nat.c                                 | 1 -
 gdb/or1k-linux-tdep.c                                | 1 -
 gdb/or1k-tdep.c                                      | 1 -
 gdb/osabi.c                                          | 1 -
 gdb/osdata.c                                         | 1 -
 gdb/p-exp.y                                          | 1 -
 gdb/p-lang.c                                         | 1 -
 gdb/p-typeprint.c                                    | 1 -
 gdb/p-valprint.c                                     | 1 -
 gdb/parse.c                                          | 1 -
 gdb/posix-hdep.c                                     | 1 -
 gdb/ppc-fbsd-nat.c                                   | 1 -
 gdb/ppc-fbsd-tdep.c                                  | 1 -
 gdb/ppc-linux-nat.c                                  | 1 -
 gdb/ppc-linux-tdep.c                                 | 1 -
 gdb/ppc-netbsd-nat.c                                 | 1 -
 gdb/ppc-netbsd-tdep.c                                | 1 -
 gdb/ppc-obsd-nat.c                                   | 1 -
 gdb/ppc-obsd-tdep.c                                  | 1 -
 gdb/ppc-ravenscar-thread.c                           | 1 -
 gdb/ppc-sysv-tdep.c                                  | 1 -
 gdb/ppc64-tdep.c                                     | 1 -
 gdb/printcmd.c                                       | 1 -
 gdb/probe.c                                          | 1 -
 gdb/proc-api.c                                       | 1 -
 gdb/proc-events.c                                    | 1 -
 gdb/proc-flags.c                                     | 1 -
 gdb/proc-service.c                                   | 1 -
 gdb/proc-why.c                                       | 1 -
 gdb/process-stratum-target.c                         | 1 -
 gdb/procfs.c                                         | 1 -
 gdb/producer.c                                       | 1 -
 gdb/progspace-and-thread.c                           | 1 -
 gdb/progspace.c                                      | 1 -
 gdb/prologue-value.c                                 | 1 -
 gdb/psymtab.c                                        | 1 -
 gdb/python/py-arch.c                                 | 1 -
 gdb/python/py-auto-load.c                            | 1 -
 gdb/python/py-block.c                                | 1 -
 gdb/python/py-bpevent.c                              | 1 -
 gdb/python/py-breakpoint.c                           | 1 -
 gdb/python/py-cmd.c                                  | 1 -
 gdb/python/py-connection.c                           | 1 -
 gdb/python/py-continueevent.c                        | 1 -
 gdb/python/py-dap.c                                  | 1 -
 gdb/python/py-disasm.c                               | 1 -
 gdb/python/py-event.c                                | 1 -
 gdb/python/py-evtregistry.c                          | 1 -
 gdb/python/py-evts.c                                 | 1 -
 gdb/python/py-exitedevent.c                          | 1 -
 gdb/python/py-finishbreakpoint.c                     | 1 -
 gdb/python/py-frame.c                                | 1 -
 gdb/python/py-framefilter.c                          | 1 -
 gdb/python/py-function.c                             | 1 -
 gdb/python/py-gdb-readline.c                         | 1 -
 gdb/python/py-inferior.c                             | 1 -
 gdb/python/py-infevents.c                            | 1 -
 gdb/python/py-infthread.c                            | 1 -
 gdb/python/py-instruction.c                          | 1 -
 gdb/python/py-lazy-string.c                          | 1 -
 gdb/python/py-linetable.c                            | 1 -
 gdb/python/py-membuf.c                               | 1 -
 gdb/python/py-mi.c                                   | 1 -
 gdb/python/py-micmd.c                                | 1 -
 gdb/python/py-newobjfileevent.c                      | 1 -
 gdb/python/py-objfile.c                              | 1 -
 gdb/python/py-param.c                                | 1 -
 gdb/python/py-prettyprint.c                          | 1 -
 gdb/python/py-progspace.c                            | 1 -
 gdb/python/py-record-btrace.c                        | 1 -
 gdb/python/py-record-full.c                          | 1 -
 gdb/python/py-record.c                               | 1 -
 gdb/python/py-registers.c                            | 1 -
 gdb/python/py-signalevent.c                          | 1 -
 gdb/python/py-stopevent.c                            | 1 -
 gdb/python/py-symbol.c                               | 1 -
 gdb/python/py-symtab.c                               | 1 -
 gdb/python/py-threadevent.c                          | 1 -
 gdb/python/py-tui.c                                  | 1 -
 gdb/python/py-type.c                                 | 1 -
 gdb/python/py-unwind.c                               | 1 -
 gdb/python/py-utils.c                                | 1 -
 gdb/python/py-value.c                                | 1 -
 gdb/python/py-varobj.c                               | 1 -
 gdb/python/py-xmethods.c                             | 1 -
 gdb/python/python.c                                  | 1 -
 gdb/ravenscar-thread.c                               | 1 -
 gdb/record-btrace.c                                  | 1 -
 gdb/record-full.c                                    | 1 -
 gdb/record.c                                         | 1 -
 gdb/regcache-dump.c                                  | 1 -
 gdb/regcache.c                                       | 1 -
 gdb/regformats/regdat.sh                             | 1 -
 gdb/reggroups.c                                      | 1 -
 gdb/remote-fileio.c                                  | 1 -
 gdb/remote-notif.c                                   | 1 -
 gdb/remote-sim.c                                     | 1 -
 gdb/remote.c                                         | 1 -
 gdb/reverse.c                                        | 1 -
 gdb/riscv-fbsd-nat.c                                 | 1 -
 gdb/riscv-fbsd-tdep.c                                | 1 -
 gdb/riscv-linux-nat.c                                | 1 -
 gdb/riscv-linux-tdep.c                               | 1 -
 gdb/riscv-none-tdep.c                                | 1 -
 gdb/riscv-ravenscar-thread.c                         | 1 -
 gdb/riscv-tdep.c                                     | 2 --
 gdb/rl78-tdep.c                                      | 1 -
 gdb/rs6000-aix-nat.c                                 | 1 -
 gdb/rs6000-aix-tdep.c                                | 1 -
 gdb/rs6000-lynx178-tdep.c                            | 1 -
 gdb/rs6000-tdep.c                                    | 1 -
 gdb/run-on-main-thread.c                             | 1 -
 gdb/rust-lang.c                                      | 1 -
 gdb/rust-parse.c                                     | 1 -
 gdb/rx-tdep.c                                        | 1 -
 gdb/s12z-tdep.c                                      | 1 -
 gdb/s390-linux-nat.c                                 | 1 -
 gdb/s390-linux-tdep.c                                | 1 -
 gdb/s390-tdep.c                                      | 1 -
 gdb/selftest-arch.c                                  | 1 -
 gdb/sentinel-frame.c                                 | 1 -
 gdb/ser-base.c                                       | 1 -
 gdb/ser-event.c                                      | 1 -
 gdb/ser-go32.c                                       | 1 -
 gdb/ser-mingw.c                                      | 1 -
 gdb/ser-pipe.c                                       | 1 -
 gdb/ser-tcp.c                                        | 1 -
 gdb/ser-uds.c                                        | 1 -
 gdb/ser-unix.c                                       | 1 -
 gdb/serial.c                                         | 1 -
 gdb/sh-linux-tdep.c                                  | 1 -
 gdb/sh-netbsd-nat.c                                  | 1 -
 gdb/sh-netbsd-tdep.c                                 | 1 -
 gdb/sh-tdep.c                                        | 1 -
 gdb/skip.c                                           | 1 -
 gdb/sol-thread.c                                     | 1 -
 gdb/sol2-tdep.c                                      | 1 -
 gdb/solib-aix.c                                      | 1 -
 gdb/solib-darwin.c                                   | 1 -
 gdb/solib-dsbt.c                                     | 1 -
 gdb/solib-frv.c                                      | 1 -
 gdb/solib-rocm.c                                     | 1 -
 gdb/solib-svr4.c                                     | 1 -
 gdb/solib-target.c                                   | 1 -
 gdb/solib.c                                          | 1 -
 gdb/source-cache.c                                   | 1 -
 gdb/source.c                                         | 1 -
 gdb/sparc-linux-nat.c                                | 1 -
 gdb/sparc-linux-tdep.c                               | 1 -
 gdb/sparc-nat.c                                      | 1 -
 gdb/sparc-netbsd-nat.c                               | 1 -
 gdb/sparc-netbsd-tdep.c                              | 1 -
 gdb/sparc-obsd-tdep.c                                | 1 -
 gdb/sparc-ravenscar-thread.c                         | 1 -
 gdb/sparc-sol2-nat.c                                 | 1 -
 gdb/sparc-sol2-tdep.c                                | 1 -
 gdb/sparc-tdep.c                                     | 1 -
 gdb/sparc64-fbsd-nat.c                               | 1 -
 gdb/sparc64-fbsd-tdep.c                              | 1 -
 gdb/sparc64-linux-nat.c                              | 1 -
 gdb/sparc64-linux-tdep.c                             | 1 -
 gdb/sparc64-nat.c                                    | 1 -
 gdb/sparc64-netbsd-nat.c                             | 1 -
 gdb/sparc64-netbsd-tdep.c                            | 1 -
 gdb/sparc64-obsd-nat.c                               | 1 -
 gdb/sparc64-obsd-tdep.c                              | 1 -
 gdb/sparc64-sol2-tdep.c                              | 1 -
 gdb/sparc64-tdep.c                                   | 1 -
 gdb/split-name.c                                     | 1 -
 gdb/stabsread.c                                      | 1 -
 gdb/stack.c                                          | 1 -
 gdb/stap-probe.c                                     | 1 -
 gdb/std-regs.c                                       | 1 -
 gdb/stub-termcap.c                                   | 1 -
 gdb/symfile-debug.c                                  | 1 -
 gdb/symfile-mem.c                                    | 1 -
 gdb/symfile.c                                        | 1 -
 gdb/symmisc.c                                        | 1 -
 gdb/symtab.c                                         | 1 -
 gdb/target-connection.c                              | 1 -
 gdb/target-dcache.c                                  | 1 -
 gdb/target-descriptions.c                            | 2 --
 gdb/target-float.c                                   | 1 -
 gdb/target-memory.c                                  | 1 -
 gdb/target.c                                         | 1 -
 gdb/target/target.c                                  | 1 -
 gdb/target/waitstatus.c                              | 1 -
 gdb/test-target.c                                    | 1 -
 gdb/thread-iter.c                                    | 1 -
 gdb/thread.c                                         | 1 -
 gdb/tic6x-linux-tdep.c                               | 1 -
 gdb/tic6x-tdep.c                                     | 1 -
 gdb/tid-parse.c                                      | 1 -
 gdb/tilegx-linux-nat.c                               | 1 -
 gdb/tilegx-linux-tdep.c                              | 1 -
 gdb/tilegx-tdep.c                                    | 1 -
 gdb/top.c                                            | 1 -
 gdb/tracectf.c                                       | 1 -
 gdb/tracefile-tfile.c                                | 1 -
 gdb/tracefile.c                                      | 1 -
 gdb/tracepoint.c                                     | 1 -
 gdb/trad-frame.c                                     | 1 -
 gdb/tramp-frame.c                                    | 1 -
 gdb/tui/tui-command.c                                | 1 -
 gdb/tui/tui-data.c                                   | 1 -
 gdb/tui/tui-disasm.c                                 | 1 -
 gdb/tui/tui-file.c                                   | 1 -
 gdb/tui/tui-hooks.c                                  | 1 -
 gdb/tui/tui-interp.c                                 | 1 -
 gdb/tui/tui-io.c                                     | 1 -
 gdb/tui/tui-layout.c                                 | 1 -
 gdb/tui/tui-location.c                               | 1 -
 gdb/tui/tui-regs.c                                   | 1 -
 gdb/tui/tui-source.c                                 | 1 -
 gdb/tui/tui-status.c                                 | 1 -
 gdb/tui/tui-win.c                                    | 1 -
 gdb/tui/tui-wingeneral.c                             | 1 -
 gdb/tui/tui-winsource.c                              | 1 -
 gdb/tui/tui.c                                        | 1 -
 gdb/type-stack.c                                     | 1 -
 gdb/typeprint.c                                      | 1 -
 gdb/ui-file.c                                        | 1 -
 gdb/ui-out.c                                         | 1 -
 gdb/ui-style.c                                       | 1 -
 gdb/ui.c                                             | 1 -
 gdb/unittests/array-view-selftests.c                 | 1 -
 gdb/unittests/child-path-selftests.c                 | 1 -
 gdb/unittests/cli-utils-selftests.c                  | 1 -
 gdb/unittests/command-def-selftests.c                | 1 -
 gdb/unittests/common-utils-selftests.c               | 1 -
 gdb/unittests/copy_bitwise-selftests.c               | 1 -
 gdb/unittests/enum-flags-selftests.c                 | 1 -
 gdb/unittests/environ-selftests.c                    | 1 -
 gdb/unittests/filtered_iterator-selftests.c          | 1 -
 gdb/unittests/format_pieces-selftests.c              | 1 -
 gdb/unittests/frame_info_ptr-selftests.c             | 1 -
 gdb/unittests/function-view-selftests.c              | 1 -
 gdb/unittests/gdb_tilde_expand-selftests.c           | 1 -
 gdb/unittests/gmp-utils-selftests.c                  | 1 -
 gdb/unittests/intrusive_list-selftests.c             | 1 -
 gdb/unittests/lookup_name_info-selftests.c           | 1 -
 gdb/unittests/main-thread-selftests.c                | 1 -
 gdb/unittests/memory-map-selftests.c                 | 1 -
 gdb/unittests/memrange-selftests.c                   | 1 -
 gdb/unittests/mkdir-recursive-selftests.c            | 1 -
 gdb/unittests/observable-selftests.c                 | 1 -
 gdb/unittests/offset-type-selftests.c                | 1 -
 gdb/unittests/packed-selftests.c                     | 1 -
 gdb/unittests/parallel-for-selftests.c               | 1 -
 gdb/unittests/parse-connection-spec-selftests.c      | 1 -
 gdb/unittests/path-join-selftests.c                  | 1 -
 gdb/unittests/ptid-selftests.c                       | 1 -
 gdb/unittests/rsp-low-selftests.c                    | 1 -
 gdb/unittests/scoped_fd-selftests.c                  | 1 -
 gdb/unittests/scoped_ignore_signal-selftests.c       | 1 -
 gdb/unittests/scoped_mmap-selftests.c                | 1 -
 gdb/unittests/scoped_restore-selftests.c             | 1 -
 gdb/unittests/search-memory-selftests.c              | 1 -
 gdb/unittests/style-selftests.c                      | 1 -
 gdb/unittests/tracepoint-selftests.c                 | 1 -
 gdb/unittests/tui-selftests.c                        | 1 -
 gdb/unittests/ui-file-selftests.c                    | 1 -
 gdb/unittests/unique_xmalloc_ptr_char.c              | 1 -
 gdb/unittests/unpack-selftests.c                     | 1 -
 gdb/unittests/utils-selftests.c                      | 1 -
 gdb/unittests/vec-utils-selftests.c                  | 1 -
 gdb/unittests/xml-utils-selftests.c                  | 1 -
 gdb/user-regs.c                                      | 1 -
 gdb/utils.c                                          | 1 -
 gdb/v850-tdep.c                                      | 1 -
 gdb/valarith.c                                       | 1 -
 gdb/valops.c                                         | 1 -
 gdb/valprint.c                                       | 1 -
 gdb/value.c                                          | 1 -
 gdb/varobj.c                                         | 1 -
 gdb/vax-bsd-nat.c                                    | 1 -
 gdb/vax-netbsd-tdep.c                                | 1 -
 gdb/vax-tdep.c                                       | 1 -
 gdb/windows-nat.c                                    | 1 -
 gdb/windows-tdep.c                                   | 1 -
 gdb/x86-bsd-nat.c                                    | 1 -
 gdb/x86-fbsd-nat.c                                   | 1 -
 gdb/x86-linux-nat.c                                  | 1 -
 gdb/x86-nat.c                                        | 1 -
 gdb/x86-tdep.c                                       | 1 -
 gdb/xcoffread.c                                      | 1 -
 gdb/xml-support.c                                    | 1 -
 gdb/xml-syscall.c                                    | 1 -
 gdb/xml-tdesc.c                                      | 1 -
 gdb/xstormy16-tdep.c                                 | 1 -
 gdb/xtensa-config.c                                  | 1 -
 gdb/xtensa-linux-nat.c                               | 1 -
 gdb/xtensa-linux-tdep.c                              | 1 -
 gdb/xtensa-tdep.c                                    | 1 -
 gdb/z80-tdep.c                                       | 1 -
 gdbserver/ax.cc                                      | 1 -
 gdbserver/debug.cc                                   | 1 -
 gdbserver/dll.cc                                     | 1 -
 gdbserver/fork-child.cc                              | 1 -
 gdbserver/gdbreplay.cc                               | 2 --
 gdbserver/hostio.cc                                  | 1 -
 gdbserver/i387-fp.cc                                 | 1 -
 gdbserver/inferiors.cc                               | 1 -
 gdbserver/linux-aarch32-low.cc                       | 1 -
 gdbserver/linux-aarch32-tdesc.cc                     | 1 -
 gdbserver/linux-aarch64-ipa.cc                       | 1 -
 gdbserver/linux-aarch64-low.cc                       | 1 -
 gdbserver/linux-aarch64-tdesc.cc                     | 1 -
 gdbserver/linux-amd64-ipa.cc                         | 1 -
 gdbserver/linux-arc-low.cc                           | 1 -
 gdbserver/linux-arm-low.cc                           | 1 -
 gdbserver/linux-arm-tdesc.cc                         | 1 -
 gdbserver/linux-csky-low.cc                          | 1 -
 gdbserver/linux-i386-ipa.cc                          | 1 -
 gdbserver/linux-ia64-low.cc                          | 1 -
 gdbserver/linux-loongarch-low.cc                     | 1 -
 gdbserver/linux-low.cc                               | 1 -
 gdbserver/linux-m68k-low.cc                          | 1 -
 gdbserver/linux-mips-low.cc                          | 1 -
 gdbserver/linux-nios2-low.cc                         | 1 -
 gdbserver/linux-or1k-low.cc                          | 1 -
 gdbserver/linux-ppc-ipa.cc                           | 1 -
 gdbserver/linux-ppc-low.cc                           | 1 -
 gdbserver/linux-riscv-low.cc                         | 1 -
 gdbserver/linux-s390-ipa.cc                          | 1 -
 gdbserver/linux-s390-low.cc                          | 1 -
 gdbserver/linux-sh-low.cc                            | 1 -
 gdbserver/linux-sparc-low.cc                         | 1 -
 gdbserver/linux-tic6x-low.cc                         | 1 -
 gdbserver/linux-x86-low.cc                           | 1 -
 gdbserver/linux-x86-tdesc.cc                         | 1 -
 gdbserver/linux-xtensa-low.cc                        | 1 -
 gdbserver/mem-break.cc                               | 1 -
 gdbserver/netbsd-aarch64-low.cc                      | 1 -
 gdbserver/netbsd-amd64-low.cc                        | 1 -
 gdbserver/netbsd-i386-low.cc                         | 1 -
 gdbserver/netbsd-low.cc                              | 1 -
 gdbserver/notif.cc                                   | 1 -
 gdbserver/proc-service.cc                            | 1 -
 gdbserver/regcache.cc                                | 1 -
 gdbserver/remote-utils.cc                            | 1 -
 gdbserver/server.cc                                  | 1 -
 gdbserver/symbol.cc                                  | 1 -
 gdbserver/target.cc                                  | 1 -
 gdbserver/tdesc.cc                                   | 1 -
 gdbserver/thread-db.cc                               | 1 -
 gdbserver/tracepoint.cc                              | 1 -
 gdbserver/utils.cc                                   | 1 -
 gdbserver/win32-i386-low.cc                          | 1 -
 gdbserver/win32-low.cc                               | 1 -
 gdbserver/x86-low.cc                                 | 1 -
 gdbsupport/agent.cc                                  | 1 -
 gdbsupport/btrace-common.cc                          | 1 -
 gdbsupport/cleanups.cc                               | 1 -
 gdbsupport/common-debug.cc                           | 1 -
 gdbsupport/common-exceptions.cc                      | 1 -
 gdbsupport/common-inferior.cc                        | 1 -
 gdbsupport/common-regcache.cc                        | 1 -
 gdbsupport/common-utils.cc                           | 1 -
 gdbsupport/environ.cc                                | 1 -
 gdbsupport/errors.cc                                 | 1 -
 gdbsupport/event-loop.cc                             | 1 -
 gdbsupport/event-pipe.cc                             | 1 -
 gdbsupport/fileio.cc                                 | 1 -
 gdbsupport/filestuff.cc                              | 1 -
 gdbsupport/format.cc                                 | 1 -
 gdbsupport/gdb-dlfcn.cc                              | 1 -
 gdbsupport/gdb-hashtab.cc                            | 1 -
 gdbsupport/gdb_obstack.cc                            | 1 -
 gdbsupport/gdb_regex.cc                              | 1 -
 gdbsupport/gdb_tilde_expand.cc                       | 1 -
 gdbsupport/gdb_vecs.cc                               | 1 -
 gdbsupport/gdb_wait.cc                               | 1 -
 gdbsupport/job-control.cc                            | 1 -
 gdbsupport/netstuff.cc                               | 1 -
 gdbsupport/new-op.cc                                 | 1 -
 gdbsupport/pathstuff.cc                              | 1 -
 gdbsupport/print-utils.cc                            | 1 -
 gdbsupport/ptid.cc                                   | 1 -
 gdbsupport/rsp-low.cc                                | 1 -
 gdbsupport/run-time-clock.cc                         | 1 -
 gdbsupport/safe-strerror.cc                          | 1 -
 gdbsupport/scoped_mmap.cc                            | 1 -
 gdbsupport/search.cc                                 | 1 -
 gdbsupport/selftest.cc                               | 1 -
 gdbsupport/signals-state-save-restore.cc             | 1 -
 gdbsupport/signals.cc                                | 1 -
 gdbsupport/task-group.cc                             | 1 -
 gdbsupport/tdesc.cc                                  | 1 -
 gdbsupport/thread-pool.cc                            | 1 -
 gdbsupport/xml-utils.cc                              | 1 -
 892 files changed, 1 insertion(+), 902 deletions(-)

diff --git a/gdb/aarch32-linux-nat.c b/gdb/aarch32-linux-nat.c
index 8c1b3ab49cc6..edff97b0ea9e 100644
--- a/gdb/aarch32-linux-nat.c
+++ b/gdb/aarch32-linux-nat.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "regcache.h"
 #include "arm-tdep.h"
diff --git a/gdb/aarch32-tdep.c b/gdb/aarch32-tdep.c
index 0b7783c3e15d..5a54a71ba4fd 100644
--- a/gdb/aarch32-tdep.c
+++ b/gdb/aarch32-tdep.c
@@ -15,8 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
-
 #include "aarch32-tdep.h"
 
 #include "gdbsupport/common-regcache.h"
diff --git a/gdb/aarch64-fbsd-nat.c b/gdb/aarch64-fbsd-nat.c
index 89ed12bb8e57..7ca8463ece85 100644
--- a/gdb/aarch64-fbsd-nat.c
+++ b/gdb/aarch64-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/aarch64-fbsd-tdep.c b/gdb/aarch64-fbsd-tdep.c
index 44ca6c90c818..e2ff57e83900 100644
--- a/gdb/aarch64-fbsd-tdep.c
+++ b/gdb/aarch64-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbarch.h"
 #include "fbsd-tdep.h"
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index cf7d5f8c6b14..3face34ce791 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 4ebc173a0a00..0b9784f38e4c 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbarch.h"
 #include "glibc-tdep.h"
diff --git a/gdb/aarch64-nat.c b/gdb/aarch64-nat.c
index 802bab6d6824..894fb73095b9 100644
--- a/gdb/aarch64-nat.c
+++ b/gdb/aarch64-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "inferior.h"
 #include "cli/cli-cmds.h"
diff --git a/gdb/aarch64-newlib-tdep.c b/gdb/aarch64-newlib-tdep.c
index c6370066aa35..4ac42a4ae268 100644
--- a/gdb/aarch64-newlib-tdep.c
+++ b/gdb/aarch64-newlib-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbarch.h"
 #include "aarch64-tdep.h"
diff --git a/gdb/aarch64-ravenscar-thread.c b/gdb/aarch64-ravenscar-thread.c
index 155641d5b7c5..5a877cde89da 100644
--- a/gdb/aarch64-ravenscar-thread.c
+++ b/gdb/aarch64-ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "aarch64-tdep.h"
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index d1d5486f90dd..545ec872fd86 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "frame.h"
 #include "language.h"
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 2b205714d7a3..b116f31104e8 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -35,7 +35,6 @@
 
 %{
 
-#include "defs.h"
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 493ef3b6c7d4..c9f12d72b70d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include <ctype.h>
 #include "gdbsupport/gdb_regex.h"
 #include "frame.h"
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 8ae94dcdbab2..864c5cfdf1c6 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "observable.h"
 #include "gdbcmd.h"
 #include "target.h"
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index df047d82fd64..deead1055dbf 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index ac85440b1396..6acfb9a48b69 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c
index 0a4c73f9c728..21412dbf2200 100644
--- a/gdb/ada-varobj.c
+++ b/gdb/ada-varobj.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ada-lang.h"
 #include "varobj.h"
 #include "language.h"
diff --git a/gdb/addrmap.c b/gdb/addrmap.c
index 162ab84763bb..0c60c0c2cebd 100644
--- a/gdb/addrmap.c
+++ b/gdb/addrmap.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "addrmap.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/agent.c b/gdb/agent.c
index a01b02cd4d38..00e75458a79e 100644
--- a/gdb/agent.c
+++ b/gdb/agent.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "command.h"
 #include "gdbcmd.h"
 #include "target.h"
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index c70bd82bc24e..0fe87b2b0809 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -39,7 +39,6 @@
 
      */
 
-#include "defs.h"
 #include "gdbthread.h"
 #include "target.h"
 #include "inferior.h"
diff --git a/gdb/alloc.c b/gdb/alloc.c
index 7c45c45ece38..d07c81f49553 100644
--- a/gdb/alloc.c
+++ b/gdb/alloc.c
@@ -27,14 +27,9 @@
    file can't live there.
 
    So, it lives in gdb and is built separately by gdb and gdbserver.
-   Please be aware of this when modifying it.
+   Please be aware of this when modifying it.  */
 
-   This also explains why this file includes common-defs.h and not
-   defs.h or server.h -- we'd prefer to avoid depending on the
-   GDBSERVER define when possible, and for this file it seemed
-   simple to do so.  */
 
-#include "gdbsupport/common-defs.h"
 #include "libiberty.h"
 #include "gdbsupport/errors.h"
 
diff --git a/gdb/alpha-bsd-nat.c b/gdb/alpha-bsd-nat.c
index 790958e33309..11e1639173a3 100644
--- a/gdb/alpha-bsd-nat.c
+++ b/gdb/alpha-bsd-nat.c
@@ -19,7 +19,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 
diff --git a/gdb/alpha-bsd-tdep.c b/gdb/alpha-bsd-tdep.c
index 03becf22d9f1..21e39cc937ca 100644
--- a/gdb/alpha-bsd-tdep.c
+++ b/gdb/alpha-bsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 
 #include "alpha-tdep.h"
diff --git a/gdb/alpha-linux-nat.c b/gdb/alpha-linux-nat.c
index 618b0c8140b7..83d6bc468584 100644
--- a/gdb/alpha-linux-nat.c
+++ b/gdb/alpha-linux-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "regcache.h"
 #include "linux-nat-trad.h"
diff --git a/gdb/alpha-linux-tdep.c b/gdb/alpha-linux-tdep.c
index 5f5e46d514e4..9a40e0cda111 100644
--- a/gdb/alpha-linux-tdep.c
+++ b/gdb/alpha-linux-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "osabi.h"
 #include "solib-svr4.h"
diff --git a/gdb/alpha-mdebug-tdep.c b/gdb/alpha-mdebug-tdep.c
index 7e9312d2aa73..abded2ac1921 100644
--- a/gdb/alpha-mdebug-tdep.c
+++ b/gdb/alpha-mdebug-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/alpha-netbsd-tdep.c b/gdb/alpha-netbsd-tdep.c
index 569fe42a2a94..f3cd62b0b58e 100644
--- a/gdb/alpha-netbsd-tdep.c
+++ b/gdb/alpha-netbsd-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "osabi.h"
diff --git a/gdb/alpha-obsd-tdep.c b/gdb/alpha-obsd-tdep.c
index 610866835c85..8602e21c64aa 100644
--- a/gdb/alpha-obsd-tdep.c
+++ b/gdb/alpha-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "osabi.h"
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index e5e0860fe241..c93bd69657f6 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index 3fdc3cd838af..fcde6d27ffb3 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "amd-dbgapi-target.h"
 #include "amdgpu-tdep.h"
diff --git a/gdb/amd64-bsd-nat.c b/gdb/amd64-bsd-nat.c
index ea9c0f47c6bf..e0ba28fa9fb8 100644
--- a/gdb/amd64-bsd-nat.c
+++ b/gdb/amd64-bsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/amd64-darwin-tdep.c b/gdb/amd64-darwin-tdep.c
index 001f5379def2..b0bead084fea 100644
--- a/gdb/amd64-darwin-tdep.c
+++ b/gdb/amd64-darwin-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/amd64-dicos-tdep.c b/gdb/amd64-dicos-tdep.c
index cc91b92f6dc0..7624289dc25d 100644
--- a/gdb/amd64-dicos-tdep.c
+++ b/gdb/amd64-dicos-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "amd64-tdep.h"
 #include "gdbsupport/x86-xstate.h"
diff --git a/gdb/amd64-fbsd-nat.c b/gdb/amd64-fbsd-nat.c
index 6a742034cbcd..6ce7c45b8b3c 100644
--- a/gdb/amd64-fbsd-nat.c
+++ b/gdb/amd64-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c
index a837bd197ffe..de295099052f 100644
--- a/gdb/amd64-fbsd-tdep.c
+++ b/gdb/amd64-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regset.h"
 #include "target.h"
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 0ee878f54018..aa9295d57230 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "elf/common.h"
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 1deb13b4e9ad..9d560ac4fbf4 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "gdbcore.h"
diff --git a/gdb/amd64-nat.c b/gdb/amd64-nat.c
index cb76658ab580..5c5c368c93d6 100644
--- a/gdb/amd64-nat.c
+++ b/gdb/amd64-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "regcache.h"
 
diff --git a/gdb/amd64-netbsd-nat.c b/gdb/amd64-netbsd-nat.c
index abd92abd77f7..8bd3e122e7b0 100644
--- a/gdb/amd64-netbsd-nat.c
+++ b/gdb/amd64-netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 
 #include "netbsd-nat.h"
diff --git a/gdb/amd64-netbsd-tdep.c b/gdb/amd64-netbsd-tdep.c
index 40500ee5f76c..264042059b73 100644
--- a/gdb/amd64-netbsd-tdep.c
+++ b/gdb/amd64-netbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "gdbcore.h"
diff --git a/gdb/amd64-obsd-nat.c b/gdb/amd64-obsd-nat.c
index 16c2c2d67a5e..717f6bd78677 100644
--- a/gdb/amd64-obsd-nat.c
+++ b/gdb/amd64-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c
index 6b37e8954ee4..f6f63bbf8ed0 100644
--- a/gdb/amd64-obsd-tdep.c
+++ b/gdb/amd64-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/amd64-ravenscar-thread.c b/gdb/amd64-ravenscar-thread.c
index a97ed3c43cf1..a0de0d731351 100644
--- a/gdb/amd64-ravenscar-thread.c
+++ b/gdb/amd64-ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/amd64-sol2-tdep.c b/gdb/amd64-sol2-tdep.c
index 6cc84017f740..070d7ed324bd 100644
--- a/gdb/amd64-sol2-tdep.c
+++ b/gdb/amd64-sol2-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 60d6b7aa1988..0bb7a24cbd08 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "opcode/i386.h"
 #include "dis-asm.h"
diff --git a/gdb/amd64-windows-nat.c b/gdb/amd64-windows-nat.c
index b4625b2f0ded..a282762d027b 100644
--- a/gdb/amd64-windows-nat.c
+++ b/gdb/amd64-windows-nat.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "windows-nat.h"
 #include "x86-nat.h"
 #include "amd64-tdep.h"
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index af17886c0806..a559d967b3c9 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "amd64-tdep.h"
 #include "gdbsupport/x86-xstate.h"
diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
index ac137d9acc44..49996aeefc33 100644
--- a/gdb/amdgpu-tdep.c
+++ b/gdb/amdgpu-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "amd-dbgapi-target.h"
 #include "amdgpu-tdep.h"
diff --git a/gdb/annotate.c b/gdb/annotate.c
index 468b9698f023..19195ac70970 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "annotate.h"
 #include "value.h"
 #include "target.h"
diff --git a/gdb/arc-linux-nat.c b/gdb/arc-linux-nat.c
index 9f8125f8a235..66f00008089d 100644
--- a/gdb/arc-linux-nat.c
+++ b/gdb/arc-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
index ca630ab6df0c..54406ac5b907 100644
--- a/gdb/arc-linux-tdep.c
+++ b/gdb/arc-linux-tdep.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* GDB header files.  */
-#include "defs.h"
 #include "linux-tdep.h"
 #include "objfiles.h"
 #include "opcode/arc.h"
diff --git a/gdb/arc-newlib-tdep.c b/gdb/arc-newlib-tdep.c
index 2efea56a7c4a..dbc096142b5f 100644
--- a/gdb/arc-newlib-tdep.c
+++ b/gdb/arc-newlib-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbarch.h"
 #include "arc-tdep.h"
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 63a1fd918d1f..5684f324233c 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -19,7 +19,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* GDB header files.  */
-#include "defs.h"
 #include "arch-utils.h"
 #include "elf-bfd.h"
 #include "disasm.h"
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index d404d1fc38a3..456bfe971ffa 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "arch-utils.h"
 #include "gdbcmd.h"
diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c
index 9f3e25088f41..ead368f5fb59 100644
--- a/gdb/arch/aarch32.c
+++ b/gdb/arch/aarch32.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "aarch32.h"
 
 #include "../features/arm/arm-core.c"
diff --git a/gdb/arch/aarch64-insn.c b/gdb/arch/aarch64-insn.c
index 65a2841eef5a..3caef45df70b 100644
--- a/gdb/arch/aarch64-insn.c
+++ b/gdb/arch/aarch64-insn.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "aarch64-insn.h"
 
 /* Toggle this file's internal debugging dump.  */
diff --git a/gdb/arch/aarch64-mte-linux.h b/gdb/arch/aarch64-mte-linux.h
index e0f4a9845b52..460b10e05c97 100644
--- a/gdb/arch/aarch64-mte-linux.h
+++ b/gdb/arch/aarch64-mte-linux.h
@@ -20,7 +20,6 @@
 #ifndef ARCH_AARCH64_MTE_LINUX_H
 #define ARCH_AARCH64_MTE_LINUX_H
 
-#include "gdbsupport/common-defs.h"
 
 /* Feature check for Memory Tagging Extension.  */
 #ifndef HWCAP2_MTE
diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h
index 43577c43797f..4d2ace8f153b 100644
--- a/gdb/arch/aarch64-scalable-linux.h
+++ b/gdb/arch/aarch64-scalable-linux.h
@@ -21,7 +21,6 @@
 #ifndef ARCH_AARCH64_SCALABLE_LINUX_H
 #define ARCH_AARCH64_SCALABLE_LINUX_H
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/common-regcache.h"
 
 /* Feature check for Scalable Matrix Extension.  */
diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c
index dfa4f592ef73..5526aa1b580b 100644
--- a/gdb/arch/aarch64.c
+++ b/gdb/arch/aarch64.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "aarch64.h"
 #include <stdlib.h>
 
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
index b8ff42700797..cb9683c6931f 100644
--- a/gdb/arch/amd64.c
+++ b/gdb/arch/amd64.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "amd64.h"
 #include "gdbsupport/x86-xstate.h"
 #include <stdlib.h>
diff --git a/gdb/arch/arc.c b/gdb/arch/arc.c
index aeb476df1a00..e807b60539f6 100644
--- a/gdb/arch/arc.c
+++ b/gdb/arch/arc.c
@@ -16,7 +16,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "gdbsupport/common-defs.h"
 #include "arc.h"
 #include <stdlib.h>
 #include <unordered_map>
diff --git a/gdb/arch/arm-get-next-pcs.c b/gdb/arch/arm-get-next-pcs.c
index 3657ac799c31..03115cf21387 100644
--- a/gdb/arch/arm-get-next-pcs.c
+++ b/gdb/arch/arm-get-next-pcs.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbsupport/common-regcache.h"
 #include "arm.h"
diff --git a/gdb/arch/arm-linux.c b/gdb/arch/arm-linux.c
index 80c3cdd2e338..246bade658fe 100644
--- a/gdb/arch/arm-linux.c
+++ b/gdb/arch/arm-linux.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/common-regcache.h"
 #include "arch/arm.h"
 #include "arm-linux.h"
diff --git a/gdb/arch/arm.c b/gdb/arch/arm.c
index 111803027d77..f1c292b44c9b 100644
--- a/gdb/arch/arm.c
+++ b/gdb/arch/arm.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/common-regcache.h"
 #include "arm.h"
 
diff --git a/gdb/arch/csky.c b/gdb/arch/csky.c
index 3ecba618764c..32df2ade7183 100644
--- a/gdb/arch/csky.c
+++ b/gdb/arch/csky.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "csky.h"
 #include <stdlib.h>
 
diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c
index 0e46b6afd5f7..f3165c5b7f0c 100644
--- a/gdb/arch/i386.c
+++ b/gdb/arch/i386.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "i386.h"
 #include "gdbsupport/tdesc.h"
 #include "gdbsupport/x86-xstate.h"
diff --git a/gdb/arch/loongarch.c b/gdb/arch/loongarch.c
index 22f2d3936cab..04b6dfc82794 100644
--- a/gdb/arch/loongarch.c
+++ b/gdb/arch/loongarch.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "loongarch.h"
 #include <stdlib.h>
 #include <unordered_map>
diff --git a/gdb/arch/ppc-linux-common.c b/gdb/arch/ppc-linux-common.c
index e67327872b6f..0a6915cdc097 100644
--- a/gdb/arch/ppc-linux-common.c
+++ b/gdb/arch/ppc-linux-common.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "arch/ppc-linux-common.h"
 #include "arch/ppc-linux-tdesc.h"
 
diff --git a/gdb/arch/riscv.c b/gdb/arch/riscv.c
index cafcda50e54b..9a84844a6456 100644
--- a/gdb/arch/riscv.c
+++ b/gdb/arch/riscv.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "riscv.h"
 #include <stdlib.h>
 #include <unordered_map>
diff --git a/gdb/arch/tic6x.c b/gdb/arch/tic6x.c
index dea409a39469..680a79420708 100644
--- a/gdb/arch/tic6x.c
+++ b/gdb/arch/tic6x.c
@@ -17,7 +17,6 @@
 
 #include "gdbsupport/tdesc.h"
 #include "tic6x.h"
-#include "gdbsupport/common-defs.h"
 
 #include "../features/tic6x-core.c"
 #include "../features/tic6x-gp.c"
diff --git a/gdb/arm-bsd-tdep.c b/gdb/arm-bsd-tdep.c
index 1a9ebcf202cc..1ccabcb24f06 100644
--- a/gdb/arm-bsd-tdep.c
+++ b/gdb/arm-bsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/arm-fbsd-nat.c b/gdb/arm-fbsd-nat.c
index 80c901842ee5..cbe9867f49d2 100644
--- a/gdb/arm-fbsd-nat.c
+++ b/gdb/arm-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "target.h"
 
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index 7b82de2166b5..dfb75329cd8c 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "elf/common.h"
 #include "target-descriptions.h"
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 75f498cd5b3f..50c24ecfcd2e 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index a8b27a7463a6..8511abcd11d6 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "value.h"
 #include "gdbtypes.h"
diff --git a/gdb/arm-netbsd-nat.c b/gdb/arm-netbsd-nat.c
index 4b9f92946412..37f6530a0fe8 100644
--- a/gdb/arm-netbsd-nat.c
+++ b/gdb/arm-netbsd-nat.c
@@ -19,7 +19,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/arm-netbsd-tdep.c b/gdb/arm-netbsd-tdep.c
index 829e1d3d4b8b..f77fec7894ab 100644
--- a/gdb/arm-netbsd-tdep.c
+++ b/gdb/arm-netbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 
 #include "arch/arm.h"
diff --git a/gdb/arm-none-tdep.c b/gdb/arm-none-tdep.c
index 72eff2c0b170..453e75234d4b 100644
--- a/gdb/arm-none-tdep.c
+++ b/gdb/arm-none-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arm-tdep.h"
 #include "arch-utils.h"
 #include "regcache.h"
diff --git a/gdb/arm-obsd-tdep.c b/gdb/arm-obsd-tdep.c
index 0bdecec3b6fb..56102b038158 100644
--- a/gdb/arm-obsd-tdep.c
+++ b/gdb/arm-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "trad-frame.h"
 #include "tramp-frame.h"
diff --git a/gdb/arm-pikeos-tdep.c b/gdb/arm-pikeos-tdep.c
index 5354af6ac7bf..4760755a32a9 100644
--- a/gdb/arm-pikeos-tdep.c
+++ b/gdb/arm-pikeos-tdep.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "arm-tdep.h"
 #include "osabi.h"
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 3a5fbe71b8b5..b4062a8f9225 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include <ctype.h>
 
diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c
index b722851e7e1a..eab496c2c0bd 100644
--- a/gdb/arm-wince-tdep.c
+++ b/gdb/arm-wince-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "gdbcore.h"
 #include "target.h"
diff --git a/gdb/async-event.c b/gdb/async-event.c
index 7097c482fff2..32b58652e585 100644
--- a/gdb/async-event.c
+++ b/gdb/async-event.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "async-event.h"
 
 #include "ser-event.h"
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index a097a3bd2f4b..db6d6ae0f73d 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "auto-load.h"
 #include "progspace.h"
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 323ea831d54e..1dc0587c0075 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "gdbtypes.h"
 #include "command.h"
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 2d38f41cd7fa..be95034abd5c 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -22,7 +22,6 @@
 /* Portions of this file were taken from the original gdb-4.18 patch developed
    by Denis Chertykov, denisc@overta.ru */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index f6d2bc5772b3..ae0992a298a3 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "symfile.h"
 #include "gdbtypes.h"
diff --git a/gdb/ax-general.c b/gdb/ax-general.c
index 19c684c04e01..3d007456a52e 100644
--- a/gdb/ax-general.c
+++ b/gdb/ax-general.c
@@ -21,7 +21,6 @@
    dependencies, since we want to be able to use them in contexts
    outside of GDB (test suites, the stub, etc.)  */
 
-#include "defs.h"
 #include "ax.h"
 #include "gdbarch.h"
 
diff --git a/gdb/bcache.c b/gdb/bcache.c
index 674ba796833e..a9aab28ab841 100644
--- a/gdb/bcache.c
+++ b/gdb/bcache.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bcache.h"
 
diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c
index 296e767d0266..96e045e4e52f 100644
--- a/gdb/bfd-target.c
+++ b/gdb/bfd-target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "bfd-target.h"
 #include "exec.h"
diff --git a/gdb/bfin-linux-tdep.c b/gdb/bfin-linux-tdep.c
index 31aa14765ae8..f67e06478eb1 100644
--- a/gdb/bfin-linux-tdep.c
+++ b/gdb/bfin-linux-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "regcache.h"
 #include "tramp-frame.h"
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index 357866ef9532..dbc339d93366 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "arch-utils.h"
diff --git a/gdb/block.c b/gdb/block.c
index 6d0d33fa85ed..511689c9738f 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "block.h"
 #include "symtab.h"
 #include "symfile.h"
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 451818332de3..b7c751300cbf 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "bfd.h"
 #include "objfiles.h"
diff --git a/gdb/bpf-tdep.c b/gdb/bpf-tdep.c
index 1b3f3e72c5b7..098a08aa7e7c 100644
--- a/gdb/bpf-tdep.c
+++ b/gdb/bpf-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "frame.h"
diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index 35b126ce9048..bd412fccdb73 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "annotate.h"
 #include "arch-utils.h"
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index 9417babdbd15..afbd84741f21 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "annotate.h"
 #include "arch-utils.h"
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 9582a7ccaad4..ce30b6fd4275 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "annotate.h"
 #include "arch-utils.h"
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index b1cee147ef1f..f077fa29a0c1 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
 #include "breakpoint.h"
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index e5ddd835c92b..a0e6e6788fe8 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "breakpoint.h"
 #include "gdbcmd.h"
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index d053bd5fbe02..ce614ac8fe37 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
 #include "breakpoint.h"
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 39c13107ba26..053d17df03eb 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
 #include "hashtab.h"
diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c
index 76021df1ed5f..a1020b05b193 100644
--- a/gdb/bsd-kvm.c
+++ b/gdb/bsd-kvm.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #define _KMEMUSER
-#include "defs.h"
 #include "cli/cli-cmds.h"
 #include "command.h"
 #include "filenames.h"
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 10e2ca5939e7..576a9ec1cfbb 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
 #include "inferior.h"
diff --git a/gdb/bt-utils.c b/gdb/bt-utils.c
index 6f68e269c511..cbca4a9b7b8e 100644
--- a/gdb/bt-utils.c
+++ b/gdb/bt-utils.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bt-utils.h"
 #include "command.h"
 #include "gdbcmd.h"
diff --git a/gdb/btrace.c b/gdb/btrace.c
index b5a047b245b0..04ae3fd0b5eb 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "btrace.h"
 #include "gdbthread.h"
 #include "inferior.h"
diff --git a/gdb/build-id.c b/gdb/build-id.c
index a40c56087ed1..d1ebd8d37d77 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "gdb_bfd.h"
 #include "build-id.h"
diff --git a/gdb/buildsym-legacy.c b/gdb/buildsym-legacy.c
index 84bc96e843bc..a2d786b48774 100644
--- a/gdb/buildsym-legacy.c
+++ b/gdb/buildsym-legacy.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "buildsym-legacy.h"
 #include "symtab.h"
 
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 506110989bf5..1c762ad81bfd 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "buildsym-legacy.h"
 #include "bfd.h"
 #include "gdbsupport/gdb_obstack.h"
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index fb85914805cf..459a4cf1e8f2 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -35,7 +35,6 @@
 
 %{
 
-#include "defs.h"
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index cc33aad088ed..922bf8c0de34 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index da269dae13b1..3e299356308c 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
 #include "symtab.h"
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 8911a1696049..28a6a6afea2f 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 4a7476449097..4751f0a957a6 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "varobj.h"
 #include "gdbthread.h"
diff --git a/gdb/charset.c b/gdb/charset.c
index 2b759495f17b..4c1debef6143 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "gdbcmd.h"
 #include "gdbsupport/gdb_obstack.h"
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 2a1e72125f9c..1c303f096626 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ui-out.h"
 #include "cli-out.h"
 #include "completer.h"
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index df11f956245c..3afe2178199e 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "readline/tilde.h"
 #include "completer.h"
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index bbabd40db071..d9a2ab40575a 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include <ctype.h>
 #include "gdbsupport/gdb_regex.h"
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 765117bcbb50..9b44c6edcf21 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-cmds.h"
 #include "value.h"
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index a0bf32fd5857..7cefc3902d8c 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli-interp.h"
 #include "interps.h"
 #include "event-top.h"
diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c
index 7c337c808e75..2b3572885855 100644
--- a/gdb/cli/cli-logging.c
+++ b/gdb/cli/cli-logging.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "ui-out.h"
 #include "interps.h"
diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c
index 3ef210e53d3e..05539285c80d 100644
--- a/gdb/cli/cli-option.c
+++ b/gdb/cli/cli-option.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-option.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-utils.h"
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index f06724af325a..2f731807c94f 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include <ctype.h>
 
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index b1ad11cc61b4..bcc793b31480 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "readline/tilde.h"
 #include "value.h"
 #include <ctype.h>
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 2fccc72b1029..5928998e9cae 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-setshow.h"
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index c3206c4f3fa3..45b30842e005 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-utils.h"
 #include "value.h"
 
diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c
index 271076e6d8d9..43700d96ec36 100644
--- a/gdb/coff-pe-read.c
+++ b/gdb/coff-pe-read.c
@@ -21,7 +21,6 @@
 
    Contributed by Raoul M. Gough (RaoulGough@yahoo.co.uk).  */
 
-#include "defs.h"
 
 #include "coff-pe-read.h"
 
diff --git a/gdb/coffread.c b/gdb/coffread.c
index abb1c1880d68..327c014a5a4c 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "demangle.h"
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c
index 72e7bfe1484a..a152e5ace614 100644
--- a/gdb/compile/compile-c-support.c
+++ b/gdb/compile/compile-c-support.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "compile-internal.h"
 #include "compile-c.h"
 #include "compile-cplus.h"
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 804a0a01377e..20e8550b3f7e 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "compile-internal.h"
 #include "compile-c.h"
 #include "symtab.h"
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index 1243be369f83..6407f1243bea 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "compile-internal.h"
 #include "compile-c.h"
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index c4355b83c7fd..c95c86f37756 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "compile-internal.h"
 #include "compile-cplus.h"
 #include "gdbsupport/gdb_assert.h"
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index c8a255153591..212db680482b 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "gdbsupport/preprocessor.h"
 #include "gdbtypes.h"
 #include "compile-internal.h"
diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c
index da3a84e00807..fbcc3d6340b2 100644
--- a/gdb/compile/compile-loc2c.c
+++ b/gdb/compile/compile-loc2c.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2.h"
 #include "objfiles.h"
 #include "dwarf2/expr.h"
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 33971a51a711..d1b5d5947a67 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "compile-object-load.h"
 #include "compile-internal.h"
 #include "command.h"
diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c
index a3ac376f38f7..5a810d5a16d4 100644
--- a/gdb/compile/compile-object-run.c
+++ b/gdb/compile/compile-object-run.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "compile-object-run.h"
 #include "value.h"
 #include "infcall.h"
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 27cff2553eed..2d97a1b2005f 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ui.h"
 #include "ui-out.h"
 #include "command.h"
diff --git a/gdb/complaints.c b/gdb/complaints.c
index 496736fe95f9..e375c7348848 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "complaints.h"
 #include "command.h"
 #include "gdbcmd.h"
diff --git a/gdb/completer.c b/gdb/completer.c
index 8e34e30f46be..171d1ca8c0ed 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/copying.awk b/gdb/copying.awk
index bbeb2664f4c6..0babd8342693 100644
--- a/gdb/copying.awk
+++ b/gdb/copying.awk
@@ -6,7 +6,6 @@ BEGIN	{
 	  print "   It is created automatically by copying.awk.";
 	  print "   Modify copying.awk instead.  <== */";
 	  print ""
-	  print "#include \"defs.h\""
 	  print "#include \"command.h\""
 	  print "#include \"gdbcmd.h\""
 	  print ""
diff --git a/gdb/copying.c b/gdb/copying.c
index a66a55b73ea3..bc45fe0dc3a5 100644
--- a/gdb/copying.c
+++ b/gdb/copying.c
@@ -2,7 +2,6 @@
    It is created automatically by copying.awk.
    Modify copying.awk instead.  <== */
 
-#include "defs.h"
 #include "command.h"
 #include "gdbcmd.h"
 
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 169d4229e9c1..16cd60f7106d 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <signal.h>
 #include <fcntl.h>
 #include "inferior.h"
diff --git a/gdb/corelow.c b/gdb/corelow.c
index f291b2aba191..f4e8273d9622 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <signal.h>
 #include <fcntl.h>
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index 882c1a03fe29..a813b4ad15cc 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "value.h"
 #include "cp-abi.h"
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 701ec25e3344..87f13445bbaf 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -37,7 +37,6 @@
 
 %{
 
-#include "defs.h"
 
 #include <unistd.h>
 #include "gdbsupport/gdb-safe-ctype.h"
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index fb9fcf8ed6e8..ec72d72b5a78 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cp-support.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 6b7c2f5a0628..e6e811ddf503 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cp-support.h"
 #include "language.h"
 #include "demangle.h"
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index d7fce64408d7..f2a2ca5288da 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/cris-linux-tdep.c b/gdb/cris-linux-tdep.c
index d46f3e846489..7ec5505fba8e 100644
--- a/gdb/cris-linux-tdep.c
+++ b/gdb/cris-linux-tdep.c
@@ -21,7 +21,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "linux-tdep.h"
 #include "solib-svr4.h"
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 02c35da723d4..dd013d531abb 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/csky-linux-tdep.c b/gdb/csky-linux-tdep.c
index d485f1763178..a703b389d2ea 100644
--- a/gdb/csky-linux-tdep.c
+++ b/gdb/csky-linux-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "glibc-tdep.h"
 #include "linux-tdep.h"
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index c1ce8a5b02ce..5f0fd3d7170d 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_assert.h"
 #include "frame.h"
 #include "inferior.h"
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index cbb8c3f2b8a6..d8606d3c0611 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -75,7 +75,6 @@
    already in the symbol table, and the CTF string table does not contain any
    duplicated strings.  */
 
-#include "defs.h"
 #include "buildsym.h"
 #include "complaints.h"
 #include "block.h"
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index 620d900709c4..b2adad24d1a9 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -38,7 +38,6 @@
 
 %{
 
-#include "defs.h"
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 6af57062ef96..d4f9956bc9ee 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "language.h"
 #include "varobj.h"
diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c
index 3f8f7d8c24e1..0bcd75dac10c 100644
--- a/gdb/d-namespace.c
+++ b/gdb/d-namespace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "block.h"
 #include "language.h"
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index 2cdbf5ae09b5..543bb193f615 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
 #include "d-lang.h"
diff --git a/gdb/darwin-nat-info.c b/gdb/darwin-nat-info.c
index 48868c8115ec..3d3e47c998a3 100644
--- a/gdb/darwin-nat-info.c
+++ b/gdb/darwin-nat-info.c
@@ -27,7 +27,6 @@
    the future.  It'd be good to remove this at some point when compiling on
    Tiger is no longer important.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 0eb49d8734ae..0c5b54b40a3b 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 1734e8062fb1..9faaf0e7381b 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -30,7 +30,6 @@
    fledged symbol table by going back and reading the symbols
    for real.  dbx_psymtab_to_symtab() is the function that does this */
 
-#include "defs.h"
 
 #include "gdbsupport/gdb_obstack.h"
 #include <sys/stat.h>
diff --git a/gdb/dcache.c b/gdb/dcache.c
index 57b39c0e51ea..ae08f3518c11 100644
--- a/gdb/dcache.c
+++ b/gdb/dcache.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dcache.h"
 #include "gdbcmd.h"
 #include "gdbcore.h"
diff --git a/gdb/debug.c b/gdb/debug.c
index 56725b68b316..f7d245126854 100644
--- a/gdb/debug.c
+++ b/gdb/debug.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbsupport/common-debug.h"
 
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 9bb3748c8c3b..841b6f2078c7 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "diagnostics.h"
 #include <errno.h>
 #include "gdbsupport/scoped_fd.h"
diff --git a/gdb/dicos-tdep.c b/gdb/dicos-tdep.c
index 950a7d617bf5..3627426eee75 100644
--- a/gdb/dicos-tdep.c
+++ b/gdb/dicos-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "solib.h"
 #include "solib-target.h"
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index 8e7eb420cc6f..6925ad4d46ce 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c
index f288707669dd..14b7fb30badf 100644
--- a/gdb/disasm-selftests.c
+++ b/gdb/disasm-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "disasm.h"
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
diff --git a/gdb/disasm.c b/gdb/disasm.c
index cafbc078c60d..da6f3afba7a1 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "target.h"
 #include "value.h"
diff --git a/gdb/displaced-stepping.c b/gdb/displaced-stepping.c
index e727c6d5662e..7869ebae7714 100644
--- a/gdb/displaced-stepping.c
+++ b/gdb/displaced-stepping.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "displaced-stepping.h"
 
 #include "cli/cli-cmds.h"
diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index 5757de1cf77d..ad1a3f870b63 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "probe.h"
 #include "elf-bfd.h"
 #include "gdbtypes.h"
diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
index 5969ef2cdadd..7d72fe032ee1 100644
--- a/gdb/dummy-frame.c
+++ b/gdb/dummy-frame.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "dummy-frame.h"
 #include "regcache.h"
 #include "frame.h"
diff --git a/gdb/dwarf2/abbrev-cache.c b/gdb/dwarf2/abbrev-cache.c
index 01ff203aeee4..b87206c2c4ee 100644
--- a/gdb/dwarf2/abbrev-cache.c
+++ b/gdb/dwarf2/abbrev-cache.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/read.h"
 #include "dwarf2/abbrev-cache.h"
 
diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c
index d68a86ef178f..359a0094872a 100644
--- a/gdb/dwarf2/abbrev.c
+++ b/gdb/dwarf2/abbrev.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/read.h"
 #include "dwarf2/abbrev.h"
 #include "dwarf2/leb.h"
diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c
index 065e2b90a0f4..9ec0d51e9205 100644
--- a/gdb/dwarf2/ada-imported.c
+++ b/gdb/dwarf2/ada-imported.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "value.h"
 #include "dwarf2/loc.h"
diff --git a/gdb/dwarf2/aranges.c b/gdb/dwarf2/aranges.c
index 4287a5a884b0..d577db627260 100644
--- a/gdb/dwarf2/aranges.c
+++ b/gdb/dwarf2/aranges.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/aranges.h"
 #include "dwarf2/read.h"
 
diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c
index 6b8f1c95ce7a..f777c1454e65 100644
--- a/gdb/dwarf2/attribute.c
+++ b/gdb/dwarf2/attribute.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/attribute.h"
 #include "dwarf2/stringify.h"
 #include "complaints.h"
diff --git a/gdb/dwarf2/comp-unit-head.c b/gdb/dwarf2/comp-unit-head.c
index 5a8279514855..a26a6c0cd58f 100644
--- a/gdb/dwarf2/comp-unit-head.c
+++ b/gdb/dwarf2/comp-unit-head.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/comp-unit-head.h"
 #include "dwarf2/leb.h"
 #include "dwarf2/read.h"
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index f78b00df446e..66822b575ca1 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/cooked-index.h"
 #include "dwarf2/read.h"
 #include "dwarf2/stringify.h"
diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c
index 62c0a8a3ede4..a64cb1d8380f 100644
--- a/gdb/dwarf2/cu.c
+++ b/gdb/dwarf2/cu.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/cu.h"
 #include "dwarf2/read.h"
 #include "objfiles.h"
diff --git a/gdb/dwarf2/die.c b/gdb/dwarf2/die.c
index 4bdf02be429f..bfa54e517abb 100644
--- a/gdb/dwarf2/die.c
+++ b/gdb/dwarf2/die.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/die.h"
 #include "dwarf2/stringify.h"
 
diff --git a/gdb/dwarf2/dwz.c b/gdb/dwarf2/dwz.c
index f53a5b64c4a3..1eb4816fb479 100644
--- a/gdb/dwarf2/dwz.c
+++ b/gdb/dwarf2/dwz.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/dwz.h"
 
 #include "build-id.h"
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index d0256e7009d9..d92facbf0dcf 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "block.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/dwarf2/frame-tailcall.c b/gdb/dwarf2/frame-tailcall.c
index 2f6400d62c38..bcbe41f7933c 100644
--- a/gdb/dwarf2/frame-tailcall.c
+++ b/gdb/dwarf2/frame-tailcall.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "dwarf2/frame-tailcall.h"
 #include "dwarf2/loc.h"
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 530513c2684e..9ebf3ac4ac47 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/expr.h"
 #include "dwarf2.h"
 #include "dwarf2/leb.h"
diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
index d9047ef46bb2..1720e925ee60 100644
--- a/gdb/dwarf2/index-cache.c
+++ b/gdb/dwarf2/index-cache.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/index-cache.h"
 
 #include "build-id.h"
diff --git a/gdb/dwarf2/index-common.c b/gdb/dwarf2/index-common.c
index 515093a63d32..08b2f3746193 100644
--- a/gdb/dwarf2/index-common.c
+++ b/gdb/dwarf2/index-common.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/index-common.h"
 
 /* See dwarf-index-common.h.  */
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index a114001f4eec..3f812285995d 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "dwarf2/index-write.h"
 
diff --git a/gdb/dwarf2/leb.c b/gdb/dwarf2/leb.c
index 7e10dc16e59f..1b7202e6240e 100644
--- a/gdb/dwarf2/leb.c
+++ b/gdb/dwarf2/leb.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/leb.h"
 
 ULONGEST
diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
index a3ca49b64f56..eddb2ef7ae80 100644
--- a/gdb/dwarf2/line-header.c
+++ b/gdb/dwarf2/line-header.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/comp-unit-head.h"
 #include "dwarf2/leb.h"
 #include "dwarf2/line-header.h"
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 203ad536162a..205d2ba56cbb 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ui-out.h"
 #include "value.h"
 #include "frame.h"
diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c
index 6b43aa49aa46..a511d0a3b449 100644
--- a/gdb/dwarf2/macro.c
+++ b/gdb/dwarf2/macro.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/read.h"
 #include "dwarf2/leb.h"
 #include "dwarf2/expr.h"
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index 0d60b01f408c..a3547cde7aa6 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "read-debug-names.h"
 #include "dwarf2/aranges.h"
 #include "dwarf2/cooked-index.h"
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index bf4f828b007b..8c0895b96393 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "read-gdb-index.h"
 
 #include "cli/cli-cmds.h"
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a747922a4ed4..31313bc88b32 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -27,7 +27,6 @@
 /* FIXME: Various die-reading functions need to be more careful with
    reading off the end of the section.  */
 
-#include "defs.h"
 #include "dwarf2/read.h"
 #include "dwarf2/abbrev.h"
 #include "dwarf2/aranges.h"
diff --git a/gdb/dwarf2/section.c b/gdb/dwarf2/section.c
index e813fc0fd8ee..6aab0b9aee9f 100644
--- a/gdb/dwarf2/section.c
+++ b/gdb/dwarf2/section.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/section.h"
 #include "gdb_bfd.h"
 #include "objfiles.h"
diff --git a/gdb/dwarf2/stringify.c b/gdb/dwarf2/stringify.c
index 3700e0c1e784..1a4e280fc765 100644
--- a/gdb/dwarf2/stringify.c
+++ b/gdb/dwarf2/stringify.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2.h"
 #include "dwarf2/stringify.h"
 
diff --git a/gdb/elf-none-tdep.c b/gdb/elf-none-tdep.c
index ddf26a9b666e..00d46992b248 100644
--- a/gdb/elf-none-tdep.c
+++ b/gdb/elf-none-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "elf-none-tdep.h"
 #include "regset.h"
 #include "elf-bfd.h"
diff --git a/gdb/elfread.c b/gdb/elfread.c
index e8a0c4d7a2cf..9bfe12712db7 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "elf-bfd.h"
 #include "elf/common.h"
diff --git a/gdb/eval.c b/gdb/eval.c
index 2759b46a5dff..6b752e706355 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/event-top.c b/gdb/event-top.c
index ef4ceedccfaa..9a02ac6df273 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "ui.h"
 #include "inferior.h"
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index 3a4216382a58..368999829fce 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "exceptions.h"
 #include "breakpoint.h"
 #include "target.h"
diff --git a/gdb/exec.c b/gdb/exec.c
index f17040a7a1b1..98ad81fb99ae 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/expprint.c b/gdb/expprint.c
index d34604fb13fb..2d8bccd60c65 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/extension.c b/gdb/extension.c
index 9db8b53a0873..f4bdcc1f6110 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -20,7 +20,6 @@
 /* Note: With few exceptions, external functions and variables in this file
    have "ext_lang" in the name, and no other symbol in gdb does.  */
 
-#include "defs.h"
 #include <signal.h>
 #include "target.h"
 #include "auto-load.h"
diff --git a/gdb/f-array-walker.h b/gdb/f-array-walker.h
index 8769e570ca34..bcbaa3da5b3c 100644
--- a/gdb/f-array-walker.h
+++ b/gdb/f-array-walker.h
@@ -21,7 +21,6 @@
 #ifndef F_ARRAY_WALKER_H
 #define F_ARRAY_WALKER_H
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "f-lang.h"
 
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index faa53ba9dd0e..11cd7948682e 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -42,7 +42,6 @@
    
 %{
 
-#include "defs.h"
 #include "expression.h"
 #include "value.h"
 #include "parser-defs.h"
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 96d4ed821c65..5eeb22806bb6 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 617e87cdeb71..6e9722dbeb85 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
 #include "symtab.h"
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 19bcd746208a..cd87dd222fda 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "annotate.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 7ac5983ae5ae..2d1bb5a33682 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/block-signals.h"
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index e3ebcb82ed64..593f5b4fd4a1 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "auxv.h"
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/features/microblaze-with-stack-protect.c b/gdb/features/microblaze-with-stack-protect.c
index 574dc02db67d..e5c0956610a3 100644
--- a/gdb/features/microblaze-with-stack-protect.c
+++ b/gdb/features/microblaze-with-stack-protect.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: microblaze-with-stack-protect.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/microblaze.c b/gdb/features/microblaze.c
index 8f1fb0a142fb..32ae3b02ad76 100644
--- a/gdb/features/microblaze.c
+++ b/gdb/features/microblaze.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: microblaze.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/mips-dsp-linux.c b/gdb/features/mips-dsp-linux.c
index d9d928c80128..d8e40283cafb 100644
--- a/gdb/features/mips-dsp-linux.c
+++ b/gdb/features/mips-dsp-linux.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: mips-dsp-linux.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/mips-linux.c b/gdb/features/mips-linux.c
index 8557bc8357df..f93eef5e41dc 100644
--- a/gdb/features/mips-linux.c
+++ b/gdb/features/mips-linux.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: mips-linux.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/mips64-dsp-linux.c b/gdb/features/mips64-dsp-linux.c
index 80bbbcbd152f..7ea0bb704f4a 100644
--- a/gdb/features/mips64-dsp-linux.c
+++ b/gdb/features/mips64-dsp-linux.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: mips64-dsp-linux.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/mips64-linux.c b/gdb/features/mips64-linux.c
index 21e8c37b9333..f4dcf8bc109b 100644
--- a/gdb/features/mips64-linux.c
+++ b/gdb/features/mips64-linux.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: mips64-linux.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/nds32.c b/gdb/features/nds32.c
index 7a08d2c85bb0..e5c5d50dce10 100644
--- a/gdb/features/nds32.c
+++ b/gdb/features/nds32.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: nds32.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/nios2.c b/gdb/features/nios2.c
index 648f7ed57abe..f53b0ddb4a03 100644
--- a/gdb/features/nios2.c
+++ b/gdb/features/nios2.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: nios2.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/or1k-linux.c b/gdb/features/or1k-linux.c
index 3eb65489383f..24731458de2c 100644
--- a/gdb/features/or1k-linux.c
+++ b/gdb/features/or1k-linux.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: or1k-linux.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/or1k.c b/gdb/features/or1k.c
index 67040965bd54..ee5e2f5b2067 100644
--- a/gdb/features/or1k.c
+++ b/gdb/features/or1k.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: or1k.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-32.c b/gdb/features/rs6000/powerpc-32.c
index a4f4bed180fa..562761e69a55 100644
--- a/gdb/features/rs6000/powerpc-32.c
+++ b/gdb/features/rs6000/powerpc-32.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-32.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-32l.c b/gdb/features/rs6000/powerpc-32l.c
index f5893bff01bf..caf81b760171 100644
--- a/gdb/features/rs6000/powerpc-32l.c
+++ b/gdb/features/rs6000/powerpc-32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-403.c b/gdb/features/rs6000/powerpc-403.c
index 2783287b981e..7cff21ceed7b 100644
--- a/gdb/features/rs6000/powerpc-403.c
+++ b/gdb/features/rs6000/powerpc-403.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-403.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-403gc.c b/gdb/features/rs6000/powerpc-403gc.c
index c69a1342773b..e86b51c43467 100644
--- a/gdb/features/rs6000/powerpc-403gc.c
+++ b/gdb/features/rs6000/powerpc-403gc.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-403gc.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-405.c b/gdb/features/rs6000/powerpc-405.c
index 1146d6601bd6..2716e37d8a8c 100644
--- a/gdb/features/rs6000/powerpc-405.c
+++ b/gdb/features/rs6000/powerpc-405.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-405.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-505.c b/gdb/features/rs6000/powerpc-505.c
index a36157f6c74d..51352e78bac4 100644
--- a/gdb/features/rs6000/powerpc-505.c
+++ b/gdb/features/rs6000/powerpc-505.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-505.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-601.c b/gdb/features/rs6000/powerpc-601.c
index ceaf789f3d73..2b700bbe128f 100644
--- a/gdb/features/rs6000/powerpc-601.c
+++ b/gdb/features/rs6000/powerpc-601.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-601.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-602.c b/gdb/features/rs6000/powerpc-602.c
index eb85e69d6a0d..13591b953020 100644
--- a/gdb/features/rs6000/powerpc-602.c
+++ b/gdb/features/rs6000/powerpc-602.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-602.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-603.c b/gdb/features/rs6000/powerpc-603.c
index 223919ca2d73..88b2b2c98c62 100644
--- a/gdb/features/rs6000/powerpc-603.c
+++ b/gdb/features/rs6000/powerpc-603.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-603.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-604.c b/gdb/features/rs6000/powerpc-604.c
index 16e6c12dae93..d266ba6ee897 100644
--- a/gdb/features/rs6000/powerpc-604.c
+++ b/gdb/features/rs6000/powerpc-604.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-604.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-64.c b/gdb/features/rs6000/powerpc-64.c
index 43dee105954f..c2f741091850 100644
--- a/gdb/features/rs6000/powerpc-64.c
+++ b/gdb/features/rs6000/powerpc-64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-64l.c b/gdb/features/rs6000/powerpc-64l.c
index 83a6a1590482..dbe06acdb200 100644
--- a/gdb/features/rs6000/powerpc-64l.c
+++ b/gdb/features/rs6000/powerpc-64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-7400.c b/gdb/features/rs6000/powerpc-7400.c
index d5fbf4bd3d79..f1f52eb51e63 100644
--- a/gdb/features/rs6000/powerpc-7400.c
+++ b/gdb/features/rs6000/powerpc-7400.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-7400.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-750.c b/gdb/features/rs6000/powerpc-750.c
index 3c9e7e1d23a1..14f490565906 100644
--- a/gdb/features/rs6000/powerpc-750.c
+++ b/gdb/features/rs6000/powerpc-750.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-750.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-860.c b/gdb/features/rs6000/powerpc-860.c
index 3e9a25f8e974..b02fcc4e357e 100644
--- a/gdb/features/rs6000/powerpc-860.c
+++ b/gdb/features/rs6000/powerpc-860.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-860.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-altivec32.c b/gdb/features/rs6000/powerpc-altivec32.c
index 41cca727be8e..05f7348df9ac 100644
--- a/gdb/features/rs6000/powerpc-altivec32.c
+++ b/gdb/features/rs6000/powerpc-altivec32.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-altivec32.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-altivec32l.c b/gdb/features/rs6000/powerpc-altivec32l.c
index 9cd935551db7..0bcae972502e 100644
--- a/gdb/features/rs6000/powerpc-altivec32l.c
+++ b/gdb/features/rs6000/powerpc-altivec32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-altivec32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-altivec64.c b/gdb/features/rs6000/powerpc-altivec64.c
index 8422708ec7fa..bdc500043918 100644
--- a/gdb/features/rs6000/powerpc-altivec64.c
+++ b/gdb/features/rs6000/powerpc-altivec64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-altivec64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-altivec64l.c b/gdb/features/rs6000/powerpc-altivec64l.c
index 977af8c941f6..2392f3496576 100644
--- a/gdb/features/rs6000/powerpc-altivec64l.c
+++ b/gdb/features/rs6000/powerpc-altivec64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-altivec64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-e500.c b/gdb/features/rs6000/powerpc-e500.c
index 84f721d948f3..0442569c3181 100644
--- a/gdb/features/rs6000/powerpc-e500.c
+++ b/gdb/features/rs6000/powerpc-e500.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-e500.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-e500l.c b/gdb/features/rs6000/powerpc-e500l.c
index a1e133d1c730..4e426c3005ae 100644
--- a/gdb/features/rs6000/powerpc-e500l.c
+++ b/gdb/features/rs6000/powerpc-e500l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-e500l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-32l.c b/gdb/features/rs6000/powerpc-isa205-32l.c
index 57fb20a4b12c..3834c9800191 100644
--- a/gdb/features/rs6000/powerpc-isa205-32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-64l.c b/gdb/features/rs6000/powerpc-isa205-64l.c
index b9ce8e604fba..9a3621877c07 100644
--- a/gdb/features/rs6000/powerpc-isa205-64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-altivec32l.c b/gdb/features/rs6000/powerpc-isa205-altivec32l.c
index 54b914c3714b..e42e1b922972 100644
--- a/gdb/features/rs6000/powerpc-isa205-altivec32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-altivec32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-altivec32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-altivec64l.c b/gdb/features/rs6000/powerpc-isa205-altivec64l.c
index 42e6f03e93c2..dc43206a9d37 100644
--- a/gdb/features/rs6000/powerpc-isa205-altivec64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-altivec64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-altivec64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
index a2c6172c6d27..acc1c5b9a3e7 100644
--- a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-ppr-dscr-vsx32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
index 3e7915a0619c..6bfe08d4cb56 100644
--- a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-ppr-dscr-vsx64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-vsx32l.c b/gdb/features/rs6000/powerpc-isa205-vsx32l.c
index 4cefcc36de57..b3f40b9d009c 100644
--- a/gdb/features/rs6000/powerpc-isa205-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-vsx32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-vsx32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-vsx64l.c b/gdb/features/rs6000/powerpc-isa205-vsx64l.c
index 2fb151d12c51..5f548176701b 100644
--- a/gdb/features/rs6000/powerpc-isa205-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-vsx64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-vsx64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
index b945039ca28d..b9dfd3092159 100644
--- a/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa207-htm-vsx32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
index 3aa579fd5f91..14a911b30aaf 100644
--- a/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa207-htm-vsx64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa207-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-vsx32l.c
index e5ce7f956cfb..bcfa7c175b85 100644
--- a/gdb/features/rs6000/powerpc-isa207-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa207-vsx32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa207-vsx32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa207-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-vsx64l.c
index adf6d3eec7f2..43bd6e584559 100644
--- a/gdb/features/rs6000/powerpc-isa207-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa207-vsx64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa207-vsx64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-vsx32.c b/gdb/features/rs6000/powerpc-vsx32.c
index 6fccdb374fb3..6d60eca340fe 100644
--- a/gdb/features/rs6000/powerpc-vsx32.c
+++ b/gdb/features/rs6000/powerpc-vsx32.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-vsx32.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-vsx32l.c b/gdb/features/rs6000/powerpc-vsx32l.c
index 1efe880d379c..cf2331349788 100644
--- a/gdb/features/rs6000/powerpc-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-vsx32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-vsx32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-vsx64.c b/gdb/features/rs6000/powerpc-vsx64.c
index df6d0f4bef91..a5baaa2dfdc2 100644
--- a/gdb/features/rs6000/powerpc-vsx64.c
+++ b/gdb/features/rs6000/powerpc-vsx64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-vsx64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-vsx64l.c b/gdb/features/rs6000/powerpc-vsx64l.c
index 89aa13de6627..03d2b694b7d0 100644
--- a/gdb/features/rs6000/powerpc-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-vsx64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-vsx64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/rs6000.c b/gdb/features/rs6000/rs6000.c
index 4aa5a8764a02..210dd96e4f61 100644
--- a/gdb/features/rs6000/rs6000.c
+++ b/gdb/features/rs6000/rs6000.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: rs6000.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rx.c b/gdb/features/rx.c
index 825a4ac4538f..f9a5584f9b80 100644
--- a/gdb/features/rx.c
+++ b/gdb/features/rx.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: rx.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-gs-linux64.c b/gdb/features/s390-gs-linux64.c
index d48f8312f20b..49ea08b2c398 100644
--- a/gdb/features/s390-gs-linux64.c
+++ b/gdb/features/s390-gs-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-gs-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux32.c b/gdb/features/s390-linux32.c
index 03ec11a26b33..43ceb9c008e2 100644
--- a/gdb/features/s390-linux32.c
+++ b/gdb/features/s390-linux32.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux32.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux32v1.c b/gdb/features/s390-linux32v1.c
index 65de6f254f77..291784fdac75 100644
--- a/gdb/features/s390-linux32v1.c
+++ b/gdb/features/s390-linux32v1.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux32v1.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux32v2.c b/gdb/features/s390-linux32v2.c
index 0e3e04dfd435..6fa26daa537c 100644
--- a/gdb/features/s390-linux32v2.c
+++ b/gdb/features/s390-linux32v2.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux32v2.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux64.c b/gdb/features/s390-linux64.c
index f0ec91992f92..74c338c1fa60 100644
--- a/gdb/features/s390-linux64.c
+++ b/gdb/features/s390-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux64v1.c b/gdb/features/s390-linux64v1.c
index 9a360c7e2676..0aebbdb6b7ae 100644
--- a/gdb/features/s390-linux64v1.c
+++ b/gdb/features/s390-linux64v1.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux64v1.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux64v2.c b/gdb/features/s390-linux64v2.c
index 18bc6ed4f9c1..3b3b4916ac37 100644
--- a/gdb/features/s390-linux64v2.c
+++ b/gdb/features/s390-linux64v2.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux64v2.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-te-linux64.c b/gdb/features/s390-te-linux64.c
index a8909b36bbf4..d49e74413137 100644
--- a/gdb/features/s390-te-linux64.c
+++ b/gdb/features/s390-te-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-te-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-tevx-linux64.c b/gdb/features/s390-tevx-linux64.c
index 8f8aec61a49f..ffe1ddf4ee13 100644
--- a/gdb/features/s390-tevx-linux64.c
+++ b/gdb/features/s390-tevx-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-tevx-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-vx-linux64.c b/gdb/features/s390-vx-linux64.c
index 0bcc14d7d089..30262a63fce6 100644
--- a/gdb/features/s390-vx-linux64.c
+++ b/gdb/features/s390-vx-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-vx-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-gs-linux64.c b/gdb/features/s390x-gs-linux64.c
index 074c38d668c9..501b3b24061e 100644
--- a/gdb/features/s390x-gs-linux64.c
+++ b/gdb/features/s390x-gs-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-gs-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-linux64.c b/gdb/features/s390x-linux64.c
index af5ba23dc383..8655d5a6116d 100644
--- a/gdb/features/s390x-linux64.c
+++ b/gdb/features/s390x-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-linux64v1.c b/gdb/features/s390x-linux64v1.c
index a33bdc1672f8..11bfd85c9955 100644
--- a/gdb/features/s390x-linux64v1.c
+++ b/gdb/features/s390x-linux64v1.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-linux64v1.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-linux64v2.c b/gdb/features/s390x-linux64v2.c
index 8b906a47e44c..400b1af44854 100644
--- a/gdb/features/s390x-linux64v2.c
+++ b/gdb/features/s390x-linux64v2.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-linux64v2.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-te-linux64.c b/gdb/features/s390x-te-linux64.c
index de8bf6104701..74883e30fe83 100644
--- a/gdb/features/s390x-te-linux64.c
+++ b/gdb/features/s390x-te-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-te-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-tevx-linux64.c b/gdb/features/s390x-tevx-linux64.c
index 8bd5cc6c4390..1d45d6044c10 100644
--- a/gdb/features/s390x-tevx-linux64.c
+++ b/gdb/features/s390x-tevx-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-tevx-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-vx-linux64.c b/gdb/features/s390x-vx-linux64.c
index f450c45144d6..4de6585a2276 100644
--- a/gdb/features/s390x-vx-linux64.c
+++ b/gdb/features/s390x-vx-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-vx-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/sparc/sparc32-solaris.c b/gdb/features/sparc/sparc32-solaris.c
index 3353d4f44f7a..dce96851f96a 100644
--- a/gdb/features/sparc/sparc32-solaris.c
+++ b/gdb/features/sparc/sparc32-solaris.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: sparc32-solaris.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/sparc/sparc64-solaris.c b/gdb/features/sparc/sparc64-solaris.c
index 1150c884b444..d030df63c6cc 100644
--- a/gdb/features/sparc/sparc64-solaris.c
+++ b/gdb/features/sparc/sparc64-solaris.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: sparc64-solaris.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/z80.c b/gdb/features/z80.c
index f8e2a1988d0e..627649cc6901 100644
--- a/gdb/features/z80.c
+++ b/gdb/features/z80.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: z80.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/filename-seen-cache.c b/gdb/filename-seen-cache.c
index d103f22b0b5b..a08927fb9fd4 100644
--- a/gdb/filename-seen-cache.c
+++ b/gdb/filename-seen-cache.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "filename-seen-cache.h"
 #include "filenames.h"
 
diff --git a/gdb/filename-seen-cache.h b/gdb/filename-seen-cache.h
index e351c074f222..5dc800d2b163 100644
--- a/gdb/filename-seen-cache.h
+++ b/gdb/filename-seen-cache.h
@@ -20,7 +20,6 @@
 #ifndef FILENAME_SEEN_CACHE_H
 #define FILENAME_SEEN_CACHE_H
 
-#include "defs.h"
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/gdb-hashtab.h"
 
diff --git a/gdb/filesystem.c b/gdb/filesystem.c
index 62b2829a76c5..4e05b0413a89 100644
--- a/gdb/filesystem.c
+++ b/gdb/filesystem.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "filesystem.h"
 #include "gdbarch.h"
 #include "gdbcmd.h"
diff --git a/gdb/findcmd.c b/gdb/findcmd.c
index 2bc3fe107386..2915c7067334 100644
--- a/gdb/findcmd.c
+++ b/gdb/findcmd.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
 #include "gdbcmd.h"
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 516a2ca044cc..71bfebe40a7a 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "frame.h"
diff --git a/gdb/fork-child.c b/gdb/fork-child.c
index 7bd81f41a531..e0891296f8c9 100644
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcmd.h"
 #include "terminal.h"
diff --git a/gdb/frame-base.c b/gdb/frame-base.c
index fda19b57bacb..7faa999532bb 100644
--- a/gdb/frame-base.c
+++ b/gdb/frame-base.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame-base.h"
 #include "frame.h"
 #include "gdbsupport/gdb_obstack.h"
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index e9983a9fd74f..a80421a9c5a8 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "dummy-frame.h"
diff --git a/gdb/frame.c b/gdb/frame.c
index f1f97040ff0c..f042bbb2ec25 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "target.h"
 #include "value.h"
diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c
index 5160c3b0c1d6..0b13a81c0642 100644
--- a/gdb/frv-linux-tdep.c
+++ b/gdb/frv-linux-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "target.h"
 #include "frame.h"
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index bcb2c621945b..5c026ebd53a3 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "arch-utils.h"
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 60cd2c974a12..c5a48bebe5f2 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/gcore-elf.c b/gdb/gcore-elf.c
index 5b0a014deb0d..c88fa08a5891 100644
--- a/gdb/gcore-elf.c
+++ b/gdb/gcore-elf.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gcore-elf.h"
 #include "elf-bfd.h"
 #include "target.h"
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 3d3973bfaba1..007966212a79 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "elf-bfd.h"
 #include "infcall.h"
 #include "inferior.h"
diff --git a/gdb/gdb-demangle.c b/gdb/gdb-demangle.c
index 20390aabb52e..7779beb591da 100644
--- a/gdb/gdb-demangle.c
+++ b/gdb/gdb-demangle.c
@@ -23,7 +23,6 @@
 /*  This file contains support code for C++ demangling that is common
    to a styles of demangling, and GDB specific.  */
 
-#include "defs.h"
 #include "cli/cli-utils.h"
 #include "command.h"
 #include "gdbcmd.h"
diff --git a/gdb/gdb.c b/gdb/gdb.c
index ad37e37e4669..5326df426931 100644
--- a/gdb/gdb.c
+++ b/gdb/gdb.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "main.h"
 #include "interps.h"
 #include "run-on-main-thread.h"
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 3b1df4897a32..ffff76e54b72 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdb_bfd.h"
 #include "ui-out.h"
 #include "gdbcmd.h"
diff --git a/gdb/gdbarch-selftests.c b/gdb/gdbarch-selftests.c
index 2013a0ebed3e..0dc0c5006544 100644
--- a/gdb/gdbarch-selftests.c
+++ b/gdb/gdbarch-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "target.h"
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 960a7f49e451..1e1a7e9ce615 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "symtab.h"
 #include "symfile.h"
diff --git a/gdb/glibc-tdep.c b/gdb/glibc-tdep.c
index ea1bfef60b5f..48e080ae9bf3 100644
--- a/gdb/glibc-tdep.c
+++ b/gdb/glibc-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "symtab.h"
 #include "symfile.h"
diff --git a/gdb/gmp-utils.c b/gdb/gmp-utils.c
index 4341ade16df1..aabdd5f3de5c 100644
--- a/gdb/gmp-utils.c
+++ b/gdb/gmp-utils.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gmp-utils.h"
 
 /* See gmp-utils.h.  */
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 0add13e3b89f..92b2858bd9d6 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -49,7 +49,6 @@ extern "C"
 #include <portinfo.h>
 }
 
-#include "defs.h"
 
 #include <ctype.h>
 #include <setjmp.h>
diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index 725691c3d07b..f1694b8a3a78 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -19,8 +19,6 @@
 #ifndef GNU_NAT_H
 #define GNU_NAT_H
 
-#include "defs.h"
-
 /* Work around conflict between Mach's 'thread_info' function, and GDB's
    'thread_info' class.  Make the former available as 'mach_thread_info'.  */
 #define thread_info mach_thread_info
diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
index 34c8f1916610..7b511eabdec8 100644
--- a/gdb/gnu-v2-abi.c
+++ b/gdb/gnu-v2-abi.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 133bf28f6487..90f5b29dd8e9 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "value.h"
 #include "cp-abi.h"
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 2e56e4bff610..20ab8ff76cf8 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -51,7 +51,6 @@
 
 %{
 
-#include "defs.h"
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 99bc5b74a934..8b4250b222a8 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -31,7 +31,6 @@
    - 6g mangling isn't supported yet
 */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "block.h"
 #include "symtab.h"
diff --git a/gdb/go-typeprint.c b/gdb/go-typeprint.c
index 0d2653d909c0..7778c71a3d24 100644
--- a/gdb/go-typeprint.c
+++ b/gdb/go-typeprint.c
@@ -23,7 +23,6 @@
      want a Python API for type printing
 */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "c-lang.h"
 #include "go-lang.h"
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index b16707138e65..43f279a44263 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -23,7 +23,6 @@
    Strings are handled specially here, at least for now, in case the Python
    support is unavailable.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
 #include "go-lang.h"
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 44022a260aa9..1d8c16fa71c3 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -81,7 +81,6 @@
    GDB does not use those as of this writing, and will never need
    to.  */
 
-#include "defs.h"
 
 #include <fcntl.h>
 
diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c
index f0db709e4fec..f540659d6479 100644
--- a/gdb/guile/guile.c
+++ b/gdb/guile/guile.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "breakpoint.h"
 #include "cli/cli-cmds.h"
 #include "cli/cli-script.h"
diff --git a/gdb/guile/scm-arch.c b/gdb/guile/scm-arch.c
index eaa2e5e22b6a..02adad0ec113 100644
--- a/gdb/guile/scm-arch.c
+++ b/gdb/guile/scm-arch.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "gdbarch.h"
 #include "arch-utils.h"
diff --git a/gdb/guile/scm-auto-load.c b/gdb/guile/scm-auto-load.c
index 1ffa96070dd5..90c4eedb9254 100644
--- a/gdb/guile/scm-auto-load.c
+++ b/gdb/guile/scm-auto-load.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c
index 44097a633dd6..4ca43117914e 100644
--- a/gdb/guile/scm-block.c
+++ b/gdb/guile/scm-block.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "block.h"
 #include "dictionary.h"
 #include "objfiles.h"
diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c
index 88b660329e43..a32862b0349f 100644
--- a/gdb/guile/scm-breakpoint.c
+++ b/gdb/guile/scm-breakpoint.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "value.h"
 #include "breakpoint.h"
 #include "gdbcmd.h"
diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c
index d70d4897413a..d75d2b63c8ca 100644
--- a/gdb/guile/scm-cmd.c
+++ b/gdb/guile/scm-cmd.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "charset.h"
 #include "gdbcmd.h"
diff --git a/gdb/guile/scm-disasm.c b/gdb/guile/scm-disasm.c
index 5266faa601be..0c7c4ec6246b 100644
--- a/gdb/guile/scm-disasm.c
+++ b/gdb/guile/scm-disasm.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "disasm.h"
 #include "dis-asm.h"
diff --git a/gdb/guile/scm-exception.c b/gdb/guile/scm-exception.c
index de17c089df3c..61007de935ec 100644
--- a/gdb/guile/scm-exception.c
+++ b/gdb/guile/scm-exception.c
@@ -28,7 +28,6 @@
    The non-static functions in this file have prefix gdbscm_ and
    not exscm_ on purpose.  */
 
-#include "defs.h"
 #include <signal.h>
 #include "guile-internal.h"
 
diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c
index b133e8de11d6..c94fcfe66982 100644
--- a/gdb/guile/scm-frame.c
+++ b/gdb/guile/scm-frame.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "block.h"
 #include "frame.h"
 #include "inferior.h"
diff --git a/gdb/guile/scm-gsmob.c b/gdb/guile/scm-gsmob.c
index 40871e9167de..b3efad20aba6 100644
--- a/gdb/guile/scm-gsmob.c
+++ b/gdb/guile/scm-gsmob.c
@@ -41,7 +41,6 @@
    seeing if it's already in the table.  Eqable gsmobs can also be used where
    lifetime-tracking is required.  */
 
-#include "defs.h"
 #include "hashtab.h"
 #include "objfiles.h"
 #include "guile-internal.h"
diff --git a/gdb/guile/scm-iterator.c b/gdb/guile/scm-iterator.c
index 035aa8bb8ff1..f4d5344dfc15 100644
--- a/gdb/guile/scm-iterator.c
+++ b/gdb/guile/scm-iterator.c
@@ -50,7 +50,6 @@
    There is SRFI 41, Streams.  We might support that too eventually (not with
    this interface of course).  */
 
-#include "defs.h"
 #include "guile-internal.h"
 
 /* A smob for iterating over something.
diff --git a/gdb/guile/scm-lazy-string.c b/gdb/guile/scm-lazy-string.c
index 30f5a0daeada..94032ae5332b 100644
--- a/gdb/guile/scm-lazy-string.c
+++ b/gdb/guile/scm-lazy-string.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "value.h"
 #include "valprint.h"
diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c
index b09a0ff7ffda..7a4a703e103f 100644
--- a/gdb/guile/scm-math.c
+++ b/gdb/guile/scm-math.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "charset.h"
 #include "cp-abi.h"
diff --git a/gdb/guile/scm-objfile.c b/gdb/guile/scm-objfile.c
index 5db4bd2922e0..bccf6ba156d7 100644
--- a/gdb/guile/scm-objfile.c
+++ b/gdb/guile/scm-objfile.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "language.h"
 #include "guile-internal.h"
diff --git a/gdb/guile/scm-param.c b/gdb/guile/scm-param.c
index b26e66e71d81..018bd1499c99 100644
--- a/gdb/guile/scm-param.c
+++ b/gdb/guile/scm-param.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "charset.h"
 #include "gdbcmd.h"
diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c
index 3b58fff17e72..ab78b5c43439 100644
--- a/gdb/guile/scm-ports.c
+++ b/gdb/guile/scm-ports.c
@@ -21,7 +21,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_select.h"
 #include "ui.h"
 #include "target.h"
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index 068fadb853ae..99fa243f9d72 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "top.h"
 #include "charset.h"
 #include "symtab.h"
diff --git a/gdb/guile/scm-progspace.c b/gdb/guile/scm-progspace.c
index 216985efd685..fcdcca24f068 100644
--- a/gdb/guile/scm-progspace.c
+++ b/gdb/guile/scm-progspace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "progspace.h"
 #include "objfiles.h"
diff --git a/gdb/guile/scm-safe-call.c b/gdb/guile/scm-safe-call.c
index 1c5b9fac4130..bc0a1e641c0c 100644
--- a/gdb/guile/scm-safe-call.c
+++ b/gdb/guile/scm-safe-call.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "filenames.h"
 #include "guile-internal.h"
 #include "gdbsupport/pathstuff.h"
diff --git a/gdb/guile/scm-string.c b/gdb/guile/scm-string.c
index 134445d011c2..a249bccda1eb 100644
--- a/gdb/guile/scm-string.c
+++ b/gdb/guile/scm-string.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "guile-internal.h"
 #include "gdbsupport/buildargv.h"
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 860ed5222748..368a598dc4b2 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "block.h"
 #include "frame.h"
 #include "symtab.h"
diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c
index 9a34a5d7b92e..2fd4b03b4c6d 100644
--- a/gdb/guile/scm-symtab.c
+++ b/gdb/guile/scm-symtab.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "source.h"
 #include "objfiles.h"
diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c
index 67b8179e076f..19324a69810c 100644
--- a/gdb/guile/scm-type.c
+++ b/gdb/guile/scm-type.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "top.h"
 #include "arch-utils.h"
 #include "value.h"
diff --git a/gdb/guile/scm-utils.c b/gdb/guile/scm-utils.c
index 1cacafdd1375..45f42ba0ccf0 100644
--- a/gdb/guile/scm-utils.c
+++ b/gdb/guile/scm-utils.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "guile-internal.h"
 
 /* Define VARIABLES in the gdb module.  */
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c
index f8b3eea52e28..a7b21707eba1 100644
--- a/gdb/guile/scm-value.c
+++ b/gdb/guile/scm-value.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "top.h"
 #include "arch-utils.h"
 #include "charset.h"
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index 36cbd9d4aa60..32907e29abff 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -22,7 +22,6 @@
    sac@cygnus.com
  */
 
-#include "defs.h"
 #include "value.h"
 #include "arch-utils.h"
 #include "regcache.h"
diff --git a/gdb/hppa-bsd-tdep.c b/gdb/hppa-bsd-tdep.c
index b1df3d17aa4d..dacda88c5866 100644
--- a/gdb/hppa-bsd-tdep.c
+++ b/gdb/hppa-bsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "target.h"
 #include "value.h"
diff --git a/gdb/hppa-linux-nat.c b/gdb/hppa-linux-nat.c
index 46bcb7c186ec..96faeb39d8f4 100644
--- a/gdb/hppa-linux-nat.c
+++ b/gdb/hppa-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "inferior.h"
diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c
index db0c36801316..659c265bfb86 100644
--- a/gdb/hppa-linux-tdep.c
+++ b/gdb/hppa-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "osabi.h"
 #include "target.h"
diff --git a/gdb/hppa-netbsd-nat.c b/gdb/hppa-netbsd-nat.c
index 6966aa4b8750..e7df997f6e4b 100644
--- a/gdb/hppa-netbsd-nat.c
+++ b/gdb/hppa-netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 
diff --git a/gdb/hppa-netbsd-tdep.c b/gdb/hppa-netbsd-tdep.c
index ccf32c790906..c71e191c8a58 100644
--- a/gdb/hppa-netbsd-tdep.c
+++ b/gdb/hppa-netbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/hppa-obsd-nat.c b/gdb/hppa-obsd-nat.c
index 3e9938c5e545..f6f79cd33857 100644
--- a/gdb/hppa-obsd-nat.c
+++ b/gdb/hppa-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/hppa-obsd-tdep.c b/gdb/hppa-obsd-tdep.c
index f009775425c8..c4f8d1fcfe1e 100644
--- a/gdb/hppa-obsd-tdep.c
+++ b/gdb/hppa-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 30128bafac48..8becfd5f9f9d 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/i386-bsd-nat.c b/gdb/i386-bsd-nat.c
index 612eae9e6f14..e1db6c74f9c4 100644
--- a/gdb/i386-bsd-nat.c
+++ b/gdb/i386-bsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 
diff --git a/gdb/i386-bsd-tdep.c b/gdb/i386-bsd-tdep.c
index 8470f2b6d2f9..db00e18bccfe 100644
--- a/gdb/i386-bsd-tdep.c
+++ b/gdb/i386-bsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "gdbcore.h"
diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
index 4fa86e49696c..acfa46a8b7d0 100644
--- a/gdb/i386-darwin-nat.c
+++ b/gdb/i386-darwin-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
index fc0a3dd3909e..5a5c8bffc210 100644
--- a/gdb/i386-darwin-tdep.c
+++ b/gdb/i386-darwin-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/i386-dicos-tdep.c b/gdb/i386-dicos-tdep.c
index e893a04617f8..9859c855150d 100644
--- a/gdb/i386-dicos-tdep.c
+++ b/gdb/i386-dicos-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "dicos-tdep.h"
 #include "gdbarch.h"
diff --git a/gdb/i386-fbsd-nat.c b/gdb/i386-fbsd-nat.c
index 6b567071fb39..f4538fbe407b 100644
--- a/gdb/i386-fbsd-nat.c
+++ b/gdb/i386-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c
index 2b9ef77e5e6d..d6d477ab7322 100644
--- a/gdb/i386-fbsd-tdep.c
+++ b/gdb/i386-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "osabi.h"
 #include "regcache.h"
diff --git a/gdb/i386-gnu-nat.c b/gdb/i386-gnu-nat.c
index 0b0759179aa7..52d4a4b7cec2 100644
--- a/gdb/i386-gnu-nat.c
+++ b/gdb/i386-gnu-nat.c
@@ -29,7 +29,6 @@ extern "C"
 #include <mach/exception.h>
 }
 
-#include "defs.h"
 #include "x86-nat.h"
 #include "inferior.h"
 #include "floatformat.h"
diff --git a/gdb/i386-gnu-tdep.c b/gdb/i386-gnu-tdep.c
index aa1898693b61..fb308215a7a9 100644
--- a/gdb/i386-gnu-tdep.c
+++ b/gdb/i386-gnu-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "osabi.h"
 #include "solib-svr4.h"
diff --git a/gdb/i386-go32-tdep.c b/gdb/i386-go32-tdep.c
index fd1a22fb50a9..738b2583a1dc 100644
--- a/gdb/i386-go32-tdep.c
+++ b/gdb/i386-go32-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "i386-tdep.h"
 #include "gdbsupport/x86-xstate.h"
 #include "target-descriptions.h"
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 25c57fc902cc..7278dd91ff0b 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index a2f937690c2e..44730f204db5 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "frame.h"
 #include "value.h"
diff --git a/gdb/i386-netbsd-nat.c b/gdb/i386-netbsd-nat.c
index e4f912f733b1..7eaaaf398c3b 100644
--- a/gdb/i386-netbsd-nat.c
+++ b/gdb/i386-netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/i386-netbsd-tdep.c b/gdb/i386-netbsd-tdep.c
index 9596435e9d10..a43765696270 100644
--- a/gdb/i386-netbsd-tdep.c
+++ b/gdb/i386-netbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "gdbcore.h"
diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c
index f4bb70cc5a08..674d45feba99 100644
--- a/gdb/i386-nto-tdep.c
+++ b/gdb/i386-nto-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "osabi.h"
 #include "regcache.h"
diff --git a/gdb/i386-obsd-nat.c b/gdb/i386-obsd-nat.c
index 69dd67ed6558..2b3d3912430f 100644
--- a/gdb/i386-obsd-nat.c
+++ b/gdb/i386-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/i386-obsd-tdep.c b/gdb/i386-obsd-tdep.c
index e1480ec6cc41..6e31567328eb 100644
--- a/gdb/i386-obsd-tdep.c
+++ b/gdb/i386-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "frame-unwind.h"
diff --git a/gdb/i386-sol2-nat.c b/gdb/i386-sol2-nat.c
index 7b3bc3a02ace..20ca9d68cbc8 100644
--- a/gdb/i386-sol2-nat.c
+++ b/gdb/i386-sol2-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 
 #include <sys/reg.h>
diff --git a/gdb/i386-sol2-tdep.c b/gdb/i386-sol2-tdep.c
index bc8df378219d..b85ac1751ac4 100644
--- a/gdb/i386-sol2-tdep.c
+++ b/gdb/i386-sol2-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "osabi.h"
 
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 0d4e30b9a4e4..1b1efad6fa3e 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "opcode/i386.h"
 #include "arch-utils.h"
 #include "command.h"
diff --git a/gdb/i386-windows-nat.c b/gdb/i386-windows-nat.c
index d262b5fce67e..ec6077ffce18 100644
--- a/gdb/i386-windows-nat.c
+++ b/gdb/i386-windows-nat.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "windows-nat.h"
 #include "x86-nat.h"
 #include "i386-tdep.h"
diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c
index e8ed043be8a0..b3a96d70bdf1 100644
--- a/gdb/i386-windows-tdep.c
+++ b/gdb/i386-windows-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "i386-tdep.h"
 #include "windows-tdep.h"
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 3d979e279a1e..00c9523ff258 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/ia64-libunwind-tdep.c b/gdb/ia64-libunwind-tdep.c
index 24a5162cdc65..72e4fae418d9 100644
--- a/gdb/ia64-libunwind-tdep.c
+++ b/gdb/ia64-libunwind-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "inferior.h"
 #include "frame.h"
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
index 2ea7203e7b0f..7a8e742daea3 100644
--- a/gdb/ia64-linux-nat.c
+++ b/gdb/ia64-linux-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "target.h"
 #include "gdbarch.h"
diff --git a/gdb/ia64-linux-tdep.c b/gdb/ia64-linux-tdep.c
index 68d4102ee9a2..676fdb8edac7 100644
--- a/gdb/ia64-linux-tdep.c
+++ b/gdb/ia64-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ia64-tdep.h"
 #include "arch-utils.h"
 #include "gdbcore.h"
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 88f67ccf0962..f49a8d6b5586 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "arch-utils.h"
diff --git a/gdb/ia64-vms-tdep.c b/gdb/ia64-vms-tdep.c
index f5bf2b53e5e2..20308c707205 100644
--- a/gdb/ia64-vms-tdep.c
+++ b/gdb/ia64-vms-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame-unwind.h"
 #include "ia64-tdep.h"
 #include "osabi.h"
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index d44179ca042e..1318d6b041e1 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -22,7 +22,6 @@
    new prototype target and then overriding target methods as
    necessary.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "memattr.h"
 #include "symtab.h"
diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c
index e23608f2800f..41e766095f05 100644
--- a/gdb/inf-loop.c
+++ b/gdb/inf-loop.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "infrun.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 31638fcbb2d8..ce303eb87eaf 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "command.h"
 #include "inferior.h"
 #include "terminal.h"
diff --git a/gdb/infcall.c b/gdb/infcall.c
index c9267e7a1293..86f50044d6db 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "infcall.h"
 #include "breakpoint.h"
 #include "tracepoint.h"
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index ac41ebf11b4f..600c90c055a5 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 5ff5eb989552..4e1d789d1ba6 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "exec.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 3dd70b97fe53..ac71e262a1f2 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "command.h"
diff --git a/gdb/infrun.c b/gdb/infrun.c
index b06972bb9687..a5030b16376d 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "displaced-stepping.h"
 #include "infrun.h"
 #include <ctype.h>
diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c
index 9f3deef8f030..f65f39be40d6 100644
--- a/gdb/inline-frame.c
+++ b/gdb/inline-frame.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "breakpoint.h"
 #include "inline-frame.h"
 #include "addrmap.h"
diff --git a/gdb/interps.c b/gdb/interps.c
index 8e9570ecb1eb..36d96eea5149 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -29,7 +29,6 @@
    the readline command interface, and it is probably simpler to just let
    them take over the input in their resume proc.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "ui-out.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
index 4177de059c0d..b9d95bbc2675 100644
--- a/gdb/iq2000-tdep.c
+++ b/gdb/iq2000-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/jit.c b/gdb/jit.c
index a7fd5c40f9d4..3843b84b0e63 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "jit.h"
 #include "jit-reader.h"
diff --git a/gdb/language.c b/gdb/language.c
index c5bbc3199637..e43e0fe7a172 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -28,7 +28,6 @@
    return data out of a "language-specific" struct pointer that is set
    whenever the working language changes.  That would be a lot faster.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/linespec.c b/gdb/linespec.c
index b5bbd8c433c9..ca154d2dcba1 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "frame.h"
 #include "command.h"
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 0d92d61f0d24..bb8119a36d05 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/linux-nat-trad.c b/gdb/linux-nat-trad.c
index 3639b2e2578b..d90d76fd9a03 100644
--- a/gdb/linux-nat-trad.c
+++ b/gdb/linux-nat-trad.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "linux-nat-trad.h"
 
 #include "nat/gdb_ptrace.h"
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 3ba072bc8d70..2602e1f240d0 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "infrun.h"
 #include "target.h"
diff --git a/gdb/linux-record.c b/gdb/linux-record.c
index 1b7330de08c4..6430c0e00884 100644
--- a/gdb/linux-record.c
+++ b/gdb/linux-record.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "gdbtypes.h"
 #include "regcache.h"
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 701e3df7a279..b967580a6431 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "linux-tdep.h"
 #include "auxv.h"
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 34a39899eeb4..65bf4a79fdf1 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <dlfcn.h>
 #include "gdb_proc_service.h"
 #include "nat/gdb_thread_db.h"
diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index b4605e48c6a3..478f1edf3e64 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/location.c b/gdb/location.c
index c3bea1fc673d..851d6e474448 100644
--- a/gdb/location.c
+++ b/gdb/location.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_assert.h"
 #include "gdbsupport/gdb-checked-static-cast.h"
 #include "location.h"
diff --git a/gdb/loongarch-linux-nat.c b/gdb/loongarch-linux-nat.c
index 9bceb8a5953d..15fca6ad781c 100644
--- a/gdb/loongarch-linux-nat.c
+++ b/gdb/loongarch-linux-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "elf/common.h"
 #include "gregset.h"
 #include "inferior.h"
diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c
index cc8121bb2b8d..a57dc31cde8a 100644
--- a/gdb/loongarch-linux-tdep.c
+++ b/gdb/loongarch-linux-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "glibc-tdep.h"
 #include "inferior.h"
 #include "linux-tdep.h"
diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c
index 0b38e751d165..149fbd55db90 100644
--- a/gdb/loongarch-tdep.c
+++ b/gdb/loongarch-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dwarf2/frame.h"
 #include "elf-bfd.h"
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index ce5a399477d4..ebbc49c62a5e 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -37,7 +37,6 @@
    
 %{
 
-#include "defs.h"
 #include "expression.h"
 #include "language.h"
 #include "value.h"
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 30c2a931236b..86fef96dec18 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index d8172c0c3684..32cc930cfb8d 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index c98f9269ae62..62bfec9cf1c4 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 0895f7bd0c4b..33ec44349d76 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "sim/sim-m32c.h"
 #include "gdbtypes.h"
 #include "regcache.h"
diff --git a/gdb/m32r-linux-nat.c b/gdb/m32r-linux-nat.c
index f482fe62e235..08a4db1d39a6 100644
--- a/gdb/m32r-linux-nat.c
+++ b/gdb/m32r-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/m32r-linux-tdep.c b/gdb/m32r-linux-tdep.c
index b74d2f3f161b..a28e11358402 100644
--- a/gdb/m32r-linux-tdep.c
+++ b/gdb/m32r-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "frame.h"
 #include "value.h"
diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index 0bd6b499e6f0..215df88b21c8 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index d80b190f2c0f..70b3f129d5aa 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -20,7 +20,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/m68k-bsd-nat.c b/gdb/m68k-bsd-nat.c
index 29fd98f0921e..1fb0c20d05cd 100644
--- a/gdb/m68k-bsd-nat.c
+++ b/gdb/m68k-bsd-nat.c
@@ -19,7 +19,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/m68k-bsd-tdep.c b/gdb/m68k-bsd-tdep.c
index 3903a83f4e04..faec4713143a 100644
--- a/gdb/m68k-bsd-tdep.c
+++ b/gdb/m68k-bsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "osabi.h"
diff --git a/gdb/m68k-linux-nat.c b/gdb/m68k-linux-nat.c
index 8b1f868a6b9f..7f3373986769 100644
--- a/gdb/m68k-linux-nat.c
+++ b/gdb/m68k-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "language.h"
diff --git a/gdb/m68k-linux-tdep.c b/gdb/m68k-linux-tdep.c
index eca4ede099f7..4874db720db9 100644
--- a/gdb/m68k-linux-tdep.c
+++ b/gdb/m68k-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "frame.h"
 #include "target.h"
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index abfc605aabb6..f73f58de90aa 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/frame.h"
 #include "frame.h"
 #include "frame-base.h"
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 8022fac9378c..b65694e697d5 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "bfd.h"
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index d3879cdf94c8..ddabfede0f55 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "macrotab.h"
 #include "macroexp.h"
 #include "macroscope.h"
diff --git a/gdb/macroexp.c b/gdb/macroexp.c
index b8a9b29db245..bcae7ec8daf6 100644
--- a/gdb/macroexp.c
+++ b/gdb/macroexp.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "macrotab.h"
 #include "macroexp.h"
diff --git a/gdb/macroscope.c b/gdb/macroscope.c
index b193b0a5c02e..4c1304f119ad 100644
--- a/gdb/macroscope.c
+++ b/gdb/macroscope.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "macroscope.h"
 #include "symtab.h"
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
index 5329d2a5a939..f2012dae1ad6 100644
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/pathstuff.h"
 #include "splay-tree.h"
diff --git a/gdb/main.c b/gdb/main.c
index 17826fae95e3..bf3c776dba9c 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "ui.h"
 #include "target.h"
diff --git a/gdb/maint-test-options.c b/gdb/maint-test-options.c
index 11b0e1d1f0f0..f671771f3b37 100644
--- a/gdb/maint-test-options.c
+++ b/gdb/maint-test-options.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "cli/cli-option.h"
 
diff --git a/gdb/maint-test-settings.c b/gdb/maint-test-settings.c
index 22c7d2dd7ab7..61456911589d 100644
--- a/gdb/maint-test-settings.c
+++ b/gdb/maint-test-settings.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "gdbcmd.h"
 
 /* Command list for "maint set test-settings".  */
diff --git a/gdb/maint.c b/gdb/maint.c
index f410cf11e697..6a5a55afebf8 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -20,7 +20,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
 #include <cmath>
diff --git a/gdb/make-init-c b/gdb/make-init-c
index 7190e691c3e7..3458333c84cb 100755
--- a/gdb/make-init-c
+++ b/gdb/make-init-c
@@ -41,7 +41,6 @@ set -e
 
 echo "/* Do not modify this file.  */"
 echo "/* It is created automatically by the Makefile.  */"
-echo "#include \"defs.h\"      /* For initialize_file_ftype.  */"
 echo "#include <algorithm>"
 echo ""
 sed -n -e 's/^\(_initialize_[a-zA-Z0-9_]*\) ()$/\1/p' "$@" | while read -r name; do
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 4748b0cd7aa8..ab4d509e02a2 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -39,7 +39,6 @@
    This module can read all four of the known byte-order combinations,
    on any type of host.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
diff --git a/gdb/mem-break.c b/gdb/mem-break.c
index 552bb28b288d..712ad000daf1 100644
--- a/gdb/mem-break.c
+++ b/gdb/mem-break.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "breakpoint.h"
 #include "inferior.h"
diff --git a/gdb/memattr.c b/gdb/memattr.c
index 6d406be36337..062611e8ee6f 100644
--- a/gdb/memattr.c
+++ b/gdb/memattr.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "command.h"
 #include "gdbcmd.h"
 #include "memattr.h"
diff --git a/gdb/memory-map.c b/gdb/memory-map.c
index 7b7a0ebf9503..26c49dbb079c 100644
--- a/gdb/memory-map.c
+++ b/gdb/memory-map.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "memory-map.h"
 
 #if !defined(HAVE_LIBEXPAT)
diff --git a/gdb/memrange.c b/gdb/memrange.c
index 161e9ac8f955..11687b808b86 100644
--- a/gdb/memrange.c
+++ b/gdb/memrange.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "memrange.h"
 #include <algorithm>
 
diff --git a/gdb/memtag.c b/gdb/memtag.c
index 86b2f66de28f..54bdc0ad323c 100644
--- a/gdb/memtag.c
+++ b/gdb/memtag.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "memtag.h"
 #include "bfd.h"
 
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index f455d3eb51d6..fdb589134da0 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index 4e64283f8e94..343a167e3d87 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "mi-cmds.h"
 #include "ui-out.h"
diff --git a/gdb/mi/mi-cmd-catch.c b/gdb/mi/mi-cmd-catch.c
index 422bbe793f2c..6cba316efda4 100644
--- a/gdb/mi/mi-cmd-catch.c
+++ b/gdb/mi/mi-cmd-catch.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "breakpoint.h"
 #include "ada-lang.h"
diff --git a/gdb/mi/mi-cmd-disas.c b/gdb/mi/mi-cmd-disas.c
index 3121f0c1dd9f..99b2ae418172 100644
--- a/gdb/mi/mi-cmd-disas.c
+++ b/gdb/mi/mi-cmd-disas.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "target.h"
 #include "value.h"
diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c
index e4fa89bb82cd..ae8c5e8bf00c 100644
--- a/gdb/mi/mi-cmd-env.c
+++ b/gdb/mi/mi-cmd-env.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "value.h"
 #include "mi-out.h"
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index 95128a9ad6dc..3e2702e04ed1 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-cmds.h"
 #include "mi-getopt.h"
 #include "mi-interp.h"
diff --git a/gdb/mi/mi-cmd-info.c b/gdb/mi/mi-cmd-info.c
index 1af20f8cb3a9..628891bcc119 100644
--- a/gdb/mi/mi-cmd-info.c
+++ b/gdb/mi/mi-cmd-info.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osdata.h"
 #include "mi-cmds.h"
 #include "ada-lang.h"
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 09c31b6a9a4c..b78c169e70bc 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "frame.h"
 #include "value.h"
diff --git a/gdb/mi/mi-cmd-target.c b/gdb/mi/mi-cmd-target.c
index e9edad739960..fbc6d6c07c8f 100644
--- a/gdb/mi/mi-cmd-target.c
+++ b/gdb/mi/mi-cmd-target.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-cmds.h"
 #include "mi-getopt.h"
 #include "remote.h"
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index cb5bafe9b7b7..f31120472a70 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-cmds.h"
 #include "mi-main.h"
 #include "ui-out.h"
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 53df07c41d07..c7afb10097be 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "mi-cmds.h"
 #include "mi-main.h"
diff --git a/gdb/mi/mi-common.c b/gdb/mi/mi-common.c
index dc0ea563921b..699ead285200 100644
--- a/gdb/mi/mi-common.c
+++ b/gdb/mi/mi-common.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-common.h"
 
 static const char * const async_reason_string_lookup[] =
diff --git a/gdb/mi/mi-console.c b/gdb/mi/mi-console.c
index 74d332005759..1f8d731e39fa 100644
--- a/gdb/mi/mi-console.c
+++ b/gdb/mi/mi-console.c
@@ -24,7 +24,6 @@
    for instance, error output is normally identified by a leading
    "&".  */
 
-#include "defs.h"
 #include "mi-console.h"
 
 /* Create a console that wraps the given output stream RAW with the
diff --git a/gdb/mi/mi-getopt.c b/gdb/mi/mi-getopt.c
index cf98c56e7e05..143c5b92dcdb 100644
--- a/gdb/mi/mi-getopt.c
+++ b/gdb/mi/mi-getopt.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-getopt.h"
 /* See comments about mi_getopt and mi_getopt_silent in mi-getopt.h.
    When there is an unknown option, if ERROR_ON_UNKNOWN is true,
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 38ae22769015..07e036f5ff90 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "mi-interp.h"
 
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index f4ab17915ecb..ab788a202310 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "target.h"
 #include "inferior.h"
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index 41bb95a92737..ff93d2cd4485 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-out.h"
 
 #include <vector>
diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c
index 6975821c7ec9..8804c98d7b4b 100644
--- a/gdb/mi/mi-parse.c
+++ b/gdb/mi/mi-parse.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-cmds.h"
 #include "mi-parse.h"
 #include "charset.h"
diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index 37cf2fbcfa2b..15c032b9ae29 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-cmds.h"
 #include "symtab.h"
 #include "objfiles.h"
diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
index 6236ab0a0447..999a3bc27126 100644
--- a/gdb/microblaze-linux-tdep.c
+++ b/gdb/microblaze-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 07261bd4d22f..1886c973bdc5 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "frame.h"
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index 0ef19b680fb2..53815b2f683e 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "main.h"
 #include "serial.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/minidebug.c b/gdb/minidebug.c
index b7558b71f980..b3a1f121280a 100644
--- a/gdb/minidebug.c
+++ b/gdb/minidebug.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdb_bfd.h"
 #include "symfile.h"
 #include "objfiles.h"
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 6aa2010fb014..38176c4bdcb4 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -36,7 +36,6 @@
    to figure out what full symbol table entries need to be read in.  */
 
 
-#include "defs.h"
 #include <ctype.h>
 #include "symtab.h"
 #include "bfd.h"
diff --git a/gdb/mips-fbsd-nat.c b/gdb/mips-fbsd-nat.c
index 6dd7b00bf5ed..b4d410405e3d 100644
--- a/gdb/mips-fbsd-nat.c
+++ b/gdb/mips-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/mips-fbsd-tdep.c b/gdb/mips-fbsd-tdep.c
index 8464a92bf4af..188ef4099da8 100644
--- a/gdb/mips-fbsd-tdep.c
+++ b/gdb/mips-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regset.h"
 #include "trad-frame.h"
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 435aff82bbc5..97ec72e5d731 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "command.h"
 #include "gdbcmd.h"
 #include "inferior.h"
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index 0b5e7867788d..79508f0fce75 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "target.h"
 #include "solib-svr4.h"
diff --git a/gdb/mips-netbsd-nat.c b/gdb/mips-netbsd-nat.c
index ddf6a8d15db9..3576c099fa69 100644
--- a/gdb/mips-netbsd-nat.c
+++ b/gdb/mips-netbsd-nat.c
@@ -19,7 +19,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/mips-netbsd-tdep.c b/gdb/mips-netbsd-tdep.c
index 8d3604a8b905..63068a18fe8e 100644
--- a/gdb/mips-netbsd-tdep.c
+++ b/gdb/mips-netbsd-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/mips-sde-tdep.c b/gdb/mips-sde-tdep.c
index 7b367898f043..90988cdfdac0 100644
--- a/gdb/mips-sde-tdep.c
+++ b/gdb/mips-sde-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "elf-bfd.h"
 #include "symtab.h"
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 67bed1d2ba05..c34971c60c1b 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/mips64-obsd-nat.c b/gdb/mips64-obsd-nat.c
index 2b3449c2dc12..ced3ffb2ee28 100644
--- a/gdb/mips64-obsd-nat.c
+++ b/gdb/mips64-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/mips64-obsd-tdep.c b/gdb/mips64-obsd-tdep.c
index cacb8bbee50a..543938bc08eb 100644
--- a/gdb/mips64-obsd-tdep.c
+++ b/gdb/mips64-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "osabi.h"
 #include "regcache.h"
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 40b1413e2155..53def129be70 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -23,7 +23,6 @@
 /* Read symbols from an ECOFF file.  Most of the work is done in
    mdebugread.c.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "symtab.h"
 #include "objfiles.h"
diff --git a/gdb/mn10300-linux-tdep.c b/gdb/mn10300-linux-tdep.c
index 4554cb182314..8eb59d2cee46 100644
--- a/gdb/mn10300-linux-tdep.c
+++ b/gdb/mn10300-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "mn10300-tdep.h"
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index f8c5a0906ef5..cd70f8adb68d 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "gdbtypes.h"
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 812c92d1e0af..a6b783e5c84c 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c
index e07e3cc4be2b..9d90a6e2784d 100644
--- a/gdb/msp430-tdep.c
+++ b/gdb/msp430-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "prologue-value.h"
 #include "target.h"
diff --git a/gdb/namespace.c b/gdb/namespace.c
index 33057fe08bef..231c7bd4cb66 100644
--- a/gdb/namespace.c
+++ b/gdb/namespace.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "namespace.h"
 #include "frame.h"
 #include "symtab.h"
diff --git a/gdb/nat/aarch64-hw-point.c b/gdb/nat/aarch64-hw-point.c
index 08fd230b71f3..b62c4627d963 100644
--- a/gdb/nat/aarch64-hw-point.c
+++ b/gdb/nat/aarch64-hw-point.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/break-common.h"
 #include "gdbsupport/common-regcache.h"
 #include "aarch64-hw-point.h"
diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c
index 8a06a0c30ef9..43e04fef137d 100644
--- a/gdb/nat/aarch64-linux-hw-point.c
+++ b/gdb/nat/aarch64-linux-hw-point.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/break-common.h"
 #include "gdbsupport/common-regcache.h"
 #include "nat/linux-nat.h"
diff --git a/gdb/nat/aarch64-linux.c b/gdb/nat/aarch64-linux.c
index 5ebbc9b81f8a..5a95f22a6fce 100644
--- a/gdb/nat/aarch64-linux.c
+++ b/gdb/nat/aarch64-linux.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/break-common.h"
 #include "nat/linux-nat.h"
 #include "nat/aarch64-linux-hw-point.h"
diff --git a/gdb/nat/aarch64-mte-linux-ptrace.c b/gdb/nat/aarch64-mte-linux-ptrace.c
index dfd2856a642e..ace3e1880610 100644
--- a/gdb/nat/aarch64-mte-linux-ptrace.c
+++ b/gdb/nat/aarch64-mte-linux-ptrace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/byte-vector.h"
 
 #include "linux-ptrace.h"
diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.c b/gdb/nat/aarch64-scalable-linux-ptrace.c
index a840d513c0c0..81bb8eab4a8f 100644
--- a/gdb/nat/aarch64-scalable-linux-ptrace.c
+++ b/gdb/nat/aarch64-scalable-linux-ptrace.c
@@ -19,7 +19,6 @@
 
 #include <sys/utsname.h>
 #include <sys/uio.h>
-#include "gdbsupport/common-defs.h"
 #include "elf/external.h"
 #include "elf/common.h"
 #include "aarch64-scalable-linux-ptrace.h"
diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
index 8ced1935342b..f5e99941b5c1 100644
--- a/gdb/nat/amd64-linux-siginfo.c
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include <signal.h>
 #include "amd64-linux-siginfo.h"
 
diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c
index dfc2f6c5a88e..a5900fe4ee8f 100644
--- a/gdb/nat/fork-inferior.c
+++ b/gdb/nat/fork-inferior.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "fork-inferior.h"
 #include "target/waitstatus.h"
 #include "gdbsupport/filestuff.h"
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index f8352b62b8b6..5715168d2f08 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "linux-btrace.h"
 #include "gdbsupport/common-regcache.h"
 #include "gdbsupport/gdb_wait.h"
diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c
index 292e7e7ffc83..36a245c6a4cb 100644
--- a/gdb/nat/linux-namespaces.c
+++ b/gdb/nat/linux-namespaces.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/linux-namespaces.h"
 #include "gdbsupport/filestuff.h"
 #include <fcntl.h>
diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
index c9192940f236..6ffabe90aa7d 100644
--- a/gdb/nat/linux-osdata.c
+++ b/gdb/nat/linux-osdata.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "linux-osdata.h"
 
 #include <sys/types.h>
diff --git a/gdb/nat/linux-personality.c b/gdb/nat/linux-personality.c
index 49789321aeb8..a406c73dfe81 100644
--- a/gdb/nat/linux-personality.c
+++ b/gdb/nat/linux-personality.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/linux-personality.h"
 
 #include <sys/personality.h>
diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c
index b17e3120792e..e2086952ce6b 100644
--- a/gdb/nat/linux-procfs.c
+++ b/gdb/nat/linux-procfs.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "linux-procfs.h"
 #include "gdbsupport/filestuff.h"
 #include <dirent.h>
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 4fe8ffa40538..9ea0e22913f6 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "linux-ptrace.h"
 #include "linux-procfs.h"
 #include "linux-waitpid.h"
diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c
index 7b5b095b560a..0ac2f9fb2b9e 100644
--- a/gdb/nat/linux-waitpid.c
+++ b/gdb/nat/linux-waitpid.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 
 #include "linux-nat.h"
 #include "linux-waitpid.h"
diff --git a/gdb/nat/mips-linux-watch.c b/gdb/nat/mips-linux-watch.c
index 091d235f760c..7d105e8e6eac 100644
--- a/gdb/nat/mips-linux-watch.c
+++ b/gdb/nat/mips-linux-watch.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/gdb_ptrace.h"
 #include "mips-linux-watch.h"
 
diff --git a/gdb/nat/netbsd-nat.c b/gdb/nat/netbsd-nat.c
index 5b208c15fe47..713ed6a16fa5 100644
--- a/gdb/nat/netbsd-nat.c
+++ b/gdb/nat/netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/netbsd-nat.h"
 #include "gdbsupport/common-debug.h"
 
diff --git a/gdb/nat/ppc-linux.c b/gdb/nat/ppc-linux.c
index cc6dffe7d60f..d64ed33fcf21 100644
--- a/gdb/nat/ppc-linux.c
+++ b/gdb/nat/ppc-linux.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "ppc-linux.h"
 #include "nat/gdb_ptrace.h"
 #include <elf.h>
diff --git a/gdb/nat/riscv-linux-tdesc.c b/gdb/nat/riscv-linux-tdesc.c
index 32f52772f625..0cd38435b228 100644
--- a/gdb/nat/riscv-linux-tdesc.c
+++ b/gdb/nat/riscv-linux-tdesc.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 
 #include "gdb_proc_service.h"
 #include "arch/riscv.h"
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index 86b70c8d566b..f9f6848861d3 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/windows-nat.h"
 #include "gdbsupport/common-debug.h"
 #include "target/target.h"
diff --git a/gdb/nat/x86-dregs.c b/gdb/nat/x86-dregs.c
index d22e839730aa..7ea9f49eb680 100644
--- a/gdb/nat/x86-dregs.c
+++ b/gdb/nat/x86-dregs.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "x86-dregs.h"
 #include "gdbsupport/break-common.h"
 
diff --git a/gdb/nat/x86-linux-dregs.c b/gdb/nat/x86-linux-dregs.c
index a1bc49909d97..a6c0ea63552d 100644
--- a/gdb/nat/x86-linux-dregs.c
+++ b/gdb/nat/x86-linux-dregs.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/gdb_ptrace.h"
 #include <sys/user.h>
 #include "target/waitstatus.h"
diff --git a/gdb/nat/x86-linux.c b/gdb/nat/x86-linux.c
index e61f4d749ba1..7a21c8f2c268 100644
--- a/gdb/nat/x86-linux.c
+++ b/gdb/nat/x86-linux.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "x86-linux.h"
 #include "x86-linux-dregs.h"
 
diff --git a/gdb/nat/x86-xstate.c b/gdb/nat/x86-xstate.c
index 9b64ceb309e6..970dda1d8946 100644
--- a/gdb/nat/x86-xstate.c
+++ b/gdb/nat/x86-xstate.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/x86-xstate.h"
 #include "nat/x86-cpuid.h"
 #include "nat/x86-xstate.h"
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index e453cd0f6d9a..bbbc80b37cd2 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/netbsd-nat.c b/gdb/netbsd-nat.c
index 574c1ad489ca..90456de165e2 100644
--- a/gdb/netbsd-nat.c
+++ b/gdb/netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "netbsd-nat.h"
 #include "nat/netbsd-nat.h"
diff --git a/gdb/netbsd-tdep.c b/gdb/netbsd-tdep.c
index e21217d75090..953b329674a4 100644
--- a/gdb/netbsd-tdep.c
+++ b/gdb/netbsd-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "auxv.h"
 #include "solib-svr4.h"
 #include "netbsd-tdep.h"
diff --git a/gdb/nios2-linux-tdep.c b/gdb/nios2-linux-tdep.c
index 9d2d4fff04a2..bd5f6cfe3f61 100644
--- a/gdb/nios2-linux-tdep.c
+++ b/gdb/nios2-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "osabi.h"
 #include "solib-svr4.h"
diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
index 0a8eeb88bb5a..da2616b436eb 100644
--- a/gdb/nios2-tdep.c
+++ b/gdb/nios2-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index a076a237f269..95a75b46d4fc 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include <fcntl.h>
 #include <spawn.h>
diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index a16459283f50..937902b4f0a5 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <sys/stat.h>
 #include "nto-tdep.h"
 #include "top.h"
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 2424e1e8530d..e492c82845b3 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index d880b9304d27..ba88ed1bc41b 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -22,7 +22,6 @@
 /* This file contains support routines for creating, manipulating, and
    destroying objfile structures.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "symtab.h"
 #include "symfile.h"
diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c
index d9134c0b18da..69a21ad71fce 100644
--- a/gdb/obsd-nat.c
+++ b/gdb/obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbthread.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/obsd-tdep.c b/gdb/obsd-tdep.c
index da53a82b2a82..5142984bc84f 100644
--- a/gdb/obsd-tdep.c
+++ b/gdb/obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "auxv.h"
 #include "frame.h"
 #include "symtab.h"
diff --git a/gdb/observable.c b/gdb/observable.c
index 6ee456243a53..0527cc68e2c0 100644
--- a/gdb/observable.c
+++ b/gdb/observable.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "observable.h"
 #include "command.h"
 #include "gdbcmd.h"
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 2b58deed5730..2132778b4bee 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "symtab.h"
 #include "expression.h"
diff --git a/gdb/or1k-linux-nat.c b/gdb/or1k-linux-nat.c
index 9a84bc93af32..21392245f484 100644
--- a/gdb/or1k-linux-nat.c
+++ b/gdb/or1k-linux-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "gregset.h"
 #include "linux-nat.h"
diff --git a/gdb/or1k-linux-tdep.c b/gdb/or1k-linux-tdep.c
index 75ab8459e754..00045a338204 100644
--- a/gdb/or1k-linux-tdep.c
+++ b/gdb/or1k-linux-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "or1k-tdep.h"
 #include "osabi.h"
 #include "glibc-tdep.h"
diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
index ffcb50f4bcd1..d4ac0ac1b9d1 100644
--- a/gdb/or1k-tdep.c
+++ b/gdb/or1k-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/osabi.c b/gdb/osabi.c
index 9917d360b6a2..016c203f47fe 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "osabi.h"
 #include "arch-utils.h"
diff --git a/gdb/osdata.c b/gdb/osdata.c
index a1cc468a346b..6dea1003cd2c 100644
--- a/gdb/osdata.c
+++ b/gdb/osdata.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "xml-support.h"
 #include "osdata.h"
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index bfb1cad60a77..2140b6092251 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -43,7 +43,6 @@
    Probably also lots of other problems, less well defined PM.  */
 %{
 
-#include "defs.h"
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 73ba436437b1..adc6402084d7 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -19,7 +19,6 @@
 
 /* This file is derived from c-lang.c */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index eb2d0283d63d..5c48c1400c4d 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -18,7 +18,6 @@
 
 /* This file is derived from p-typeprint.c */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
 #include "symtab.h"
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 2372cdf83ebf..7f6d7dc6e6bb 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -19,7 +19,6 @@
 
 /* This file is derived from c-valprint.c */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/parse.c b/gdb/parse.c
index 4b0eeaf53305..fecaa81c318a 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -29,7 +29,6 @@
    during the process of parsing; the lower levels of the tree always
    come first in the result.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "arch-utils.h"
 #include "symtab.h"
diff --git a/gdb/posix-hdep.c b/gdb/posix-hdep.c
index ae5add9790f1..a0d5c585ebc7 100644
--- a/gdb/posix-hdep.c
+++ b/gdb/posix-hdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/event-loop.h"
 #include "gdbsupport/gdb_select.h"
 #include "inferior.h"
diff --git a/gdb/ppc-fbsd-nat.c b/gdb/ppc-fbsd-nat.c
index 1925660f4573..b3b20ffdbbc1 100644
--- a/gdb/ppc-fbsd-nat.c
+++ b/gdb/ppc-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/ppc-fbsd-tdep.c b/gdb/ppc-fbsd-tdep.c
index 719ddc71d130..8f86607d5d19 100644
--- a/gdb/ppc-fbsd-tdep.c
+++ b/gdb/ppc-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "gdbcore.h"
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 028422bb1e8d..2ed6e6e50685 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbthread.h"
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 2824cb628c3d..2da2d32eb262 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/ppc-netbsd-nat.c b/gdb/ppc-netbsd-nat.c
index 06a7a3710f71..a384944376e2 100644
--- a/gdb/ppc-netbsd-nat.c
+++ b/gdb/ppc-netbsd-nat.c
@@ -21,7 +21,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 
 #include <sys/types.h>
 #include <sys/ptrace.h>
diff --git a/gdb/ppc-netbsd-tdep.c b/gdb/ppc-netbsd-tdep.c
index 58f5678d5d9c..d8e4c424ba46 100644
--- a/gdb/ppc-netbsd-tdep.c
+++ b/gdb/ppc-netbsd-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "osabi.h"
 #include "regcache.h"
diff --git a/gdb/ppc-obsd-nat.c b/gdb/ppc-obsd-nat.c
index 06a67c3e25ff..66e7b9357fa7 100644
--- a/gdb/ppc-obsd-nat.c
+++ b/gdb/ppc-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/ppc-obsd-tdep.c b/gdb/ppc-obsd-tdep.c
index b845e67bcaab..b50a24c6af79 100644
--- a/gdb/ppc-obsd-tdep.c
+++ b/gdb/ppc-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "frame-unwind.h"
diff --git a/gdb/ppc-ravenscar-thread.c b/gdb/ppc-ravenscar-thread.c
index 8e610573bd97..fd44a9a3ec6a 100644
--- a/gdb/ppc-ravenscar-thread.c
+++ b/gdb/ppc-ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "ppc-tdep.h"
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index ebbf1cf4295f..9d0e8a95a773 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c
index 5797d55f00b7..8f91d06a085d 100644
--- a/gdb/ppc64-tdep.c
+++ b/gdb/ppc64-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "infrun.h"
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 63e530e612e2..cb0d32aa4bcf 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/probe.c b/gdb/probe.c
index 4d68e129636e..b13baf00e714 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "probe.h"
 #include "command.h"
 #include "cli/cli-cmds.h"
diff --git a/gdb/proc-api.c b/gdb/proc-api.c
index 07395c5ab0b4..0d3f389afdb5 100644
--- a/gdb/proc-api.c
+++ b/gdb/proc-api.c
@@ -24,7 +24,6 @@
  * Pretty-print trace of api calls to the /proc api
  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "completer.h"
 
diff --git a/gdb/proc-events.c b/gdb/proc-events.c
index 76d66deb593b..55b73636cb56 100644
--- a/gdb/proc-events.c
+++ b/gdb/proc-events.c
@@ -28,7 +28,6 @@
    FIXME: At present, the syscall translation table must be
    initialized, which is not true of the other translation tables.  */
 
-#include "defs.h"
 
 #include <sys/types.h>
 #include <sys/procfs.h>
diff --git a/gdb/proc-flags.c b/gdb/proc-flags.c
index 24b0cce91be7..33075e933ecc 100644
--- a/gdb/proc-flags.c
+++ b/gdb/proc-flags.c
@@ -25,7 +25,6 @@
  *
  */
 
-#include "defs.h"
 
 #include <sys/types.h>
 #include <sys/procfs.h>
diff --git a/gdb/proc-service.c b/gdb/proc-service.c
index f2ba0975096a..1889a001a1dd 100644
--- a/gdb/proc-service.c
+++ b/gdb/proc-service.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/proc-why.c b/gdb/proc-why.c
index 5bfc3627c7e6..ec8987ddb736 100644
--- a/gdb/proc-why.c
+++ b/gdb/proc-why.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include <sys/types.h>
 #include <sys/procfs.h>
diff --git a/gdb/process-stratum-target.c b/gdb/process-stratum-target.c
index 8737938e3b49..ce8ff28958e0 100644
--- a/gdb/process-stratum-target.c
+++ b/gdb/process-stratum-target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "process-stratum-target.h"
 #include "inferior.h"
 #include <algorithm>
diff --git a/gdb/procfs.c b/gdb/procfs.c
index ba2b166727ee..77fdacfd61e1 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "infrun.h"
 #include "target.h"
diff --git a/gdb/producer.c b/gdb/producer.c
index cd615a450c2f..2ca701f5c7ca 100644
--- a/gdb/producer.c
+++ b/gdb/producer.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "producer.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/gdb_regex.h"
diff --git a/gdb/progspace-and-thread.c b/gdb/progspace-and-thread.c
index 092deb774712..e78e56d84946 100644
--- a/gdb/progspace-and-thread.c
+++ b/gdb/progspace-and-thread.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "progspace-and-thread.h"
 #include "inferior.h"
 
diff --git a/gdb/progspace.c b/gdb/progspace.c
index cda0f415a3fd..131cd2f11865 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
 #include "arch-utils.h"
diff --git a/gdb/prologue-value.c b/gdb/prologue-value.c
index 7183a9079a3f..2c0ce52421b5 100644
--- a/gdb/prologue-value.c
+++ b/gdb/prologue-value.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "prologue-value.h"
 #include "regcache.h"
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index a831e5eec40b..a4f5b04627c2 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "objfiles.h"
 #include "psymtab.h"
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index 663113d4fd5b..c6f566221d82 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "arch-utils.h"
 #include "disasm.h"
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index 42795259399c..8a3327b37226 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index 9417ebc252e9..3e30faf08560 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "block.h"
 #include "dictionary.h"
 #include "symtab.h"
diff --git a/gdb/python/py-bpevent.c b/gdb/python/py-bpevent.c
index dc962f117882..5982a26f5629 100644
--- a/gdb/python/py-bpevent.c
+++ b/gdb/python/py-bpevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-stopevent.h"
 
 /* Create and initialize a BreakpointEvent object.  This acquires new
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 95782444c4a7..cd9ef3093c16 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "python-internal.h"
 #include "python.h"
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 91e8f100e1c4..f18a8e8eaa9a 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "value.h"
 #include "python-internal.h"
diff --git a/gdb/python/py-connection.c b/gdb/python/py-connection.c
index 84f80cf6a74b..dcca76b7867b 100644
--- a/gdb/python/py-connection.c
+++ b/gdb/python/py-connection.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "process-stratum-target.h"
 #include "inferior.h"
diff --git a/gdb/python/py-continueevent.c b/gdb/python/py-continueevent.c
index e366b4d1bc3c..c859b1e91cae 100644
--- a/gdb/python/py-continueevent.c
+++ b/gdb/python/py-continueevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 #include "gdbthread.h"
 
diff --git a/gdb/python/py-dap.c b/gdb/python/py-dap.c
index 9a00130fe907..861514d90021 100644
--- a/gdb/python/py-dap.c
+++ b/gdb/python/py-dap.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "interps.h"
 #include "cli-out.h"
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index b48d5620b158..2d8ce44a0655 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "language.h"
 #include "dis-asm.h"
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index 7ac16c850f16..47a2997a09a3 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 
 void
diff --git a/gdb/python/py-evtregistry.c b/gdb/python/py-evtregistry.c
index d968815003a2..1f486e28c92e 100644
--- a/gdb/python/py-evtregistry.c
+++ b/gdb/python/py-evtregistry.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "command.h"
 #include "py-events.h"
 
diff --git a/gdb/python/py-evts.c b/gdb/python/py-evts.c
index 1fbba517a39a..4e966e197e3f 100644
--- a/gdb/python/py-evts.c
+++ b/gdb/python/py-evts.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-events.h"
 
 static struct PyModuleDef EventModuleDef =
diff --git a/gdb/python/py-exitedevent.c b/gdb/python/py-exitedevent.c
index bef16c913a1e..4837468ff997 100644
--- a/gdb/python/py-exitedevent.c
+++ b/gdb/python/py-exitedevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 
 static gdbpy_ref<>
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 617e879a040c..c74a2473a815 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -19,7 +19,6 @@
 
 
 
-#include "defs.h"
 #include "top.h"
 #include "python-internal.h"
 #include "breakpoint.h"
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 7467f845b78f..bbb42afb2ede 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "charset.h"
 #include "block.h"
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 768e3a6e0c81..0cd15977d2ff 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "symtab.h"
 #include "language.h"
diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c
index 81c4106c477d..077396cb93ec 100644
--- a/gdb/python/py-function.c
+++ b/gdb/python/py-function.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "value.h"
 #include "python-internal.h"
 #include "charset.h"
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
index bbf49bb73264..92287eea7c91 100644
--- a/gdb/python/py-gdb-readline.c
+++ b/gdb/python/py-gdb-readline.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "top.h"
 #include "cli/cli-utils.h"
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index c25519c8dd9c..795ac655ddd5 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "auto-load.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
diff --git a/gdb/python/py-infevents.c b/gdb/python/py-infevents.c
index 8a150852e089..f53d589f85b5 100644
--- a/gdb/python/py-infevents.c
+++ b/gdb/python/py-infevents.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 
 /* Construct either a gdb.InferiorCallPreEvent or a
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 995397e7f0d2..a17f25ed4985 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbthread.h"
 #include "inferior.h"
 #include "python-internal.h"
diff --git a/gdb/python/py-instruction.c b/gdb/python/py-instruction.c
index e3c99ef7a7b3..bc3945af2cf0 100644
--- a/gdb/python/py-instruction.c
+++ b/gdb/python/py-instruction.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-instruction.h"
 
 /* Python type object for the abstract gdb.Instruction class.  This class
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index 5d07f376f97c..0b7f5c9d680a 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "charset.h"
 #include "value.h"
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index 31194786eb7b..e3e71f9e4367 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 
 struct linetable_entry_object {
diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c
index 538d7f41fe3e..af48d01b9edd 100644
--- a/gdb/python/py-membuf.c
+++ b/gdb/python/py-membuf.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 
 struct membuf_object {
diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c
index 49e524a2df81..bc95e86a4566 100644
--- a/gdb/python/py-mi.c
+++ b/gdb/python/py-mi.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "py-uiout.h"
 #include "utils.h"
diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c
index aab6c5c2317a..54427d4633b1 100644
--- a/gdb/python/py-micmd.c
+++ b/gdb/python/py-micmd.c
@@ -19,7 +19,6 @@
 
 /* GDB/MI commands implemented in Python.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "arch-utils.h"
 #include "charset.h"
diff --git a/gdb/python/py-newobjfileevent.c b/gdb/python/py-newobjfileevent.c
index b7a09680613a..deaee706246c 100644
--- a/gdb/python/py-newobjfileevent.c
+++ b/gdb/python/py-newobjfileevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 
 static gdbpy_ref<>
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index ffdb7be4a9a1..60a14833b957 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "charset.h"
 #include "objfiles.h"
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 9f3c63116ec9..ba837566343e 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "value.h"
 #include "python-internal.h"
 #include "charset.h"
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index fb141fb42dc5..368b3a3c793f 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "symtab.h"
 #include "language.h"
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index 5d883a7d8127..a5b22ce9d5c8 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "charset.h"
 #include "progspace.h"
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index 347100ba404e..8c34add0d771 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "gdbcmd.h"
 #include "gdbthread.h"
diff --git a/gdb/python/py-record-full.c b/gdb/python/py-record-full.c
index 73b24053c9da..b6623a600c58 100644
--- a/gdb/python/py-record-full.c
+++ b/gdb/python/py-record-full.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-record-full.h"
 
 /* Implementation of
diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c
index 81b4c63d5974..d4891268e036 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-instruction.h"
 #include "py-record.h"
 #include "py-record-btrace.h"
diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c
index d7a40c9ba581..f03274c308a1 100644
--- a/gdb/python/py-registers.c
+++ b/gdb/python/py-registers.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "arch-utils.h"
 #include "reggroups.h"
diff --git a/gdb/python/py-signalevent.c b/gdb/python/py-signalevent.c
index 73f56035e354..bf511064fe6c 100644
--- a/gdb/python/py-signalevent.c
+++ b/gdb/python/py-signalevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-stopevent.h"
 
 gdbpy_ref<>
diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c
index fcaebe26f13c..be26bc17f859 100644
--- a/gdb/python/py-stopevent.c
+++ b/gdb/python/py-stopevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-stopevent.h"
 #include "py-uiout.h"
 #include "thread-fsm.h"
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 88da56527e83..754420f3b564 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "block.h"
 #include "frame.h"
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index b28f6ca8b48c..7290b8564789 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "symtab.h"
 #include "source.h"
diff --git a/gdb/python/py-threadevent.c b/gdb/python/py-threadevent.c
index 5c99b60b46f6..557f2b780170 100644
--- a/gdb/python/py-threadevent.c
+++ b/gdb/python/py-threadevent.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 #include "infrun.h"
 #include "gdbthread.h"
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index 089f4f877686..5dcec4bd2b11 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "python-internal.h"
 #include "gdbsupport/intrusive_list.h"
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 8793db8eed1e..863e6f6175fc 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "python-internal.h"
 #include "charset.h"
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index 56f925bc57f0..58bcf40e1c9f 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame-unwind.h"
 #include "gdbsupport/gdb_obstack.h"
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 3fcf48f79988..47f65f4fd441 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "charset.h"
 #include "value.h"
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index ff7943d80c39..dd17420b0b50 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "charset.h"
 #include "value.h"
diff --git a/gdb/python/py-varobj.c b/gdb/python/py-varobj.c
index efe6b4312b64..cbfea266f605 100644
--- a/gdb/python/py-varobj.c
+++ b/gdb/python/py-varobj.c
@@ -13,7 +13,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "varobj.h"
 #include "varobj-iter.h"
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index c7041eb2ad3c..2fae04303b22 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "extension-priv.h"
 #include "objfiles.h"
diff --git a/gdb/python/python.c b/gdb/python/python.c
index e2ac315f9f59..d6e5883476e1 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "command.h"
 #include "ui-out.h"
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 75d110f20c5c..ecc9235c9174 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
 #include "ada-lang.h"
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 6350400c318a..0ef1dfbe652f 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "record.h"
 #include "record-btrace.h"
 #include "gdbthread.h"
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 24058824d749..4c3667f48bad 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "regcache.h"
 #include "gdbthread.h"
diff --git a/gdb/record.c b/gdb/record.c
index 25901d2deefd..1843969c2c9b 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "completer.h"
 #include "record.h"
diff --git a/gdb/regcache-dump.c b/gdb/regcache-dump.c
index 709dd0586336..33205a4241d8 100644
--- a/gdb/regcache-dump.c
+++ b/gdb/regcache-dump.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "regcache.h"
 #include "gdbsupport/def-vector.h"
diff --git a/gdb/regcache.c b/gdb/regcache.c
index af298893acf9..b7abbe99f3cc 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbthread.h"
 #include "target.h"
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index 344fcf5b9a17..38464c65b067 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -107,7 +107,6 @@ EOF
 
 exec > new-$2
 copyright $1
-echo '#include "server.h"'
 echo '#include "regdef.h"'
 echo '#include "tdesc.h"'
 echo
diff --git a/gdb/reggroups.c b/gdb/reggroups.c
index ee76c04623e7..8fb21bd7622d 100644
--- a/gdb/reggroups.c
+++ b/gdb/reggroups.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "reggroups.h"
 #include "gdbtypes.h"
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index 154cd0be8e5f..eaa0d8f619a6 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -19,7 +19,6 @@
 
 /* See the GDB User Guide for details of the GDB remote protocol.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "remote.h"
 #include "gdbsupport/gdb_wait.h"
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index 2088b50fd957..9acf3f8dc78e 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -31,7 +31,6 @@
    remote_async_get_pending_events_handler, while in all-stop mode,
    they are processed in remote_resume.  */
 
-#include "defs.h"
 #include "remote.h"
 #include "remote-notif.h"
 #include "observable.h"
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index e761d3a05799..5fccefe93a16 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdb_bfd.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/remote.c b/gdb/remote.c
index 14c8b020b1e9..e278711df7b5 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -19,7 +19,6 @@
 
 /* See the GDB User Guide for details of the GDB remote protocol.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include <fcntl.h>
 #include "inferior.h"
diff --git a/gdb/reverse.c b/gdb/reverse.c
index 9a011631a320..11c76b4b3355 100644
--- a/gdb/reverse.c
+++ b/gdb/reverse.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "top.h"
 #include "cli/cli-cmds.h"
diff --git a/gdb/riscv-fbsd-nat.c b/gdb/riscv-fbsd-nat.c
index 8da2e02fafec..bc9d613d207f 100644
--- a/gdb/riscv-fbsd-nat.c
+++ b/gdb/riscv-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "target.h"
 
diff --git a/gdb/riscv-fbsd-tdep.c b/gdb/riscv-fbsd-tdep.c
index 205f7a950df5..68f726743d9c 100644
--- a/gdb/riscv-fbsd-tdep.c
+++ b/gdb/riscv-fbsd-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "fbsd-tdep.h"
 #include "osabi.h"
 #include "riscv-tdep.h"
diff --git a/gdb/riscv-linux-nat.c b/gdb/riscv-linux-nat.c
index 5bccc1f53490..a5507e88ea17 100644
--- a/gdb/riscv-linux-nat.c
+++ b/gdb/riscv-linux-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "gregset.h"
 #include "linux-nat.h"
diff --git a/gdb/riscv-linux-tdep.c b/gdb/riscv-linux-tdep.c
index 0267dc65e58e..ff478cf4c287 100644
--- a/gdb/riscv-linux-tdep.c
+++ b/gdb/riscv-linux-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "riscv-tdep.h"
 #include "osabi.h"
 #include "glibc-tdep.h"
diff --git a/gdb/riscv-none-tdep.c b/gdb/riscv-none-tdep.c
index 7dcab01de6d1..e98c699a68c5 100644
--- a/gdb/riscv-none-tdep.c
+++ b/gdb/riscv-none-tdep.c
@@ -17,7 +17,6 @@
 
 /* This file contain code that is specific for bare-metal RISC-V targets.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "regcache.h"
 #include "riscv-tdep.h"
diff --git a/gdb/riscv-ravenscar-thread.c b/gdb/riscv-ravenscar-thread.c
index 794b0c44c998..291b1db8d9e4 100644
--- a/gdb/riscv-ravenscar-thread.c
+++ b/gdb/riscv-ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 604a19fe2a62..f86a37988cbd 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
@@ -49,7 +48,6 @@
 #include "dwarf2/frame.h"
 #include "user-regs.h"
 #include "valprint.h"
-#include "gdbsupport/common-defs.h"
 #include "opcode/riscv-opc.h"
 #include "cli/cli-decode.h"
 #include "observable.h"
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index 1e439f363564..acd0731dd9f4 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "prologue-value.h"
 #include "target.h"
diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c
index 066d34d446c5..908671a713a4 100644
--- a/gdb/rs6000-aix-nat.c
+++ b/gdb/rs6000-aix-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "target.h"
 #include "gdbcore.h"
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index db76af6984b9..5111f4f55c0a 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c
index c92c71dcb881..550e06882031 100644
--- a/gdb/rs6000-lynx178-tdep.c
+++ b/gdb/rs6000-lynx178-tdep.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "gdbcore.h"
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 3157213cb1fa..b7ba0042bb73 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c
index 7b9807e0eaf0..e30dabaff032 100644
--- a/gdb/run-on-main-thread.c
+++ b/gdb/run-on-main-thread.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "run-on-main-thread.h"
 #include "ser-event.h"
 #if CXX_STD_THREAD
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index ab537cc97528..64e40577a696 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include <ctype.h>
 
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index 66263b91bdc9..9300e17bdf83 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "block.h"
 #include "charset.h"
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index 53ad5d5c92b2..844e36023e04 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "prologue-value.h"
 #include "target.h"
diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c
index 60cbc26afffd..29d4ef3b71ce 100644
--- a/gdb/s12z-tdep.c
+++ b/gdb/s12z-tdep.c
@@ -18,7 +18,6 @@
 
 /* Much of this file is shamelessly copied from or1k-tdep.c and others.  */
 
-#include "defs.h"
 
 #include "arch-utils.h"
 #include "dwarf2/frame.h"
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index 1e074814d87b..fa4aaf9aa9ae 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 945b3c7cee72..bc1db550d2e7 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "auxv.h"
 #include "elf/common.h"
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 174338e18852..519e3eb0a423 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "arch-utils.h"
 #include "ax-gdb.h"
diff --git a/gdb/selftest-arch.c b/gdb/selftest-arch.c
index 99677edfa66f..a337f76083ab 100644
--- a/gdb/selftest-arch.c
+++ b/gdb/selftest-arch.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <functional>
 
 #if GDB_SELF_TEST
diff --git a/gdb/sentinel-frame.c b/gdb/sentinel-frame.c
index ca7c28952f36..4eaeae0d254f 100644
--- a/gdb/sentinel-frame.c
+++ b/gdb/sentinel-frame.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "regcache.h"
 #include "sentinel-frame.h"
 #include "inferior.h"
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index f63082685466..ccf38d2202b6 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/ser-event.c b/gdb/ser-event.c
index 374322ead23c..fe1c460aa1fe 100644
--- a/gdb/ser-event.c
+++ b/gdb/ser-event.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ser-event.h"
 #include "serial.h"
 #include "gdbsupport/filestuff.h"
diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c
index 57c44806c0e8..ae71f73cce92 100644
--- a/gdb/ser-go32.c
+++ b/gdb/ser-go32.c
@@ -21,7 +21,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "serial.h"
 /*
diff --git a/gdb/ser-mingw.c b/gdb/ser-mingw.c
index 5c2e06c29262..2603bb8dcfb4 100644
--- a/gdb/ser-mingw.c
+++ b/gdb/ser-mingw.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 #include "ser-tcp.h"
diff --git a/gdb/ser-pipe.c b/gdb/ser-pipe.c
index 842b656eb5af..49312036da02 100644
--- a/gdb/ser-pipe.c
+++ b/gdb/ser-pipe.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 #include "ser-unix.h"
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index 3f5541d0a2f2..6efc2457bdb7 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 #include "ser-tcp.h"
diff --git a/gdb/ser-uds.c b/gdb/ser-uds.c
index 39a5f6f053a0..8da4c7a22fa5 100644
--- a/gdb/ser-uds.c
+++ b/gdb/ser-uds.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index bc8b087b6eb6..db1464f8f6e8 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 #include "ser-unix.h"
diff --git a/gdb/serial.c b/gdb/serial.c
index 734a580ed020..aeab7ebcfb08 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "serial.h"
 #include "gdbcmd.h"
diff --git a/gdb/sh-linux-tdep.c b/gdb/sh-linux-tdep.c
index c78d363400ad..affbf550a505 100644
--- a/gdb/sh-linux-tdep.c
+++ b/gdb/sh-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 
 #include "solib-svr4.h"
diff --git a/gdb/sh-netbsd-nat.c b/gdb/sh-netbsd-nat.c
index cf321984eeb6..c3c31e9bb3a0 100644
--- a/gdb/sh-netbsd-nat.c
+++ b/gdb/sh-netbsd-nat.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 
 #include <sys/types.h>
diff --git a/gdb/sh-netbsd-tdep.c b/gdb/sh-netbsd-tdep.c
index e04df2709f4b..fec6a2e03d22 100644
--- a/gdb/sh-netbsd-tdep.c
+++ b/gdb/sh-netbsd-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regset.h"
 #include "value.h"
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 16e513eb4053..1c67ea42b040 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -20,7 +20,6 @@
 /* Contributed by Steve Chamberlain
    sac@cygnus.com.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/skip.c b/gdb/skip.c
index 79db4c54e06e..f2818eccb34c 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "skip.h"
 #include "value.h"
 #include "valprint.h"
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index d58e2af0d22e..7c17601d5608 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -48,7 +48,6 @@
    symbols, etc...  The ps_* routines actually do most of their work
    by calling functions in procfs.c.  */
 
-#include "defs.h"
 #include <thread.h>
 #include <proc_service.h>
 #include <thread_db.h>
diff --git a/gdb/sol2-tdep.c b/gdb/sol2-tdep.c
index 4ee2d0ac3460..468b132165e6 100644
--- a/gdb/sol2-tdep.c
+++ b/gdb/sol2-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "symtab.h"
 #include "inferior.h"
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 8c8f219bdc59..a50bb165c193 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "solib-aix.h"
 #include "solib.h"
 #include "solist.h"
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 5ef0646d5385..6943b2df5865 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "bfd.h"
 #include "objfiles.h"
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index f1c10d0f302d..0208ed13effc 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -17,7 +17,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "solib.h"
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index f90a0a218d6c..aef609378a42 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -17,7 +17,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "solib.h"
 #include "solist.h"
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index 02ab36bb95e6..b714e4ef6cce 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "amd-dbgapi-target.h"
 #include "amdgpu-tdep.h"
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 2377ed3341dc..49dd1e9aa330 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "elf/external.h"
 #include "elf/common.h"
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index bb4c6a6c174f..6563da05a471 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "solist.h"
 #include "symtab.h"
diff --git a/gdb/solib.c b/gdb/solib.c
index 9497f5d30992..2f69c3372b0b 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include <fcntl.h>
 #include "symtab.h"
diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index 8b5bd84d19a8..6af984fb88bf 100644
--- a/gdb/source-cache.c
+++ b/gdb/source-cache.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "source-cache.h"
 #include "gdbsupport/scoped_fd.h"
 #include "source.h"
diff --git a/gdb/source.c b/gdb/source.c
index bbeb41542583..432301e2a717 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "expression.h"
diff --git a/gdb/sparc-linux-nat.c b/gdb/sparc-linux-nat.c
index f8142435162b..0b3a69256109 100644
--- a/gdb/sparc-linux-nat.c
+++ b/gdb/sparc-linux-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 
 #include <sys/procfs.h>
diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c
index 1590cbdc4f05..fac4c7d773db 100644
--- a/gdb/sparc-linux-tdep.c
+++ b/gdb/sparc-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/frame.h"
 #include "frame.h"
 #include "frame-unwind.h"
diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c
index d3149ab39ef7..b8d0bed622f0 100644
--- a/gdb/sparc-nat.c
+++ b/gdb/sparc-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/sparc-netbsd-nat.c b/gdb/sparc-netbsd-nat.c
index 1f65c01d3dfb..82592ccc3cfa 100644
--- a/gdb/sparc-netbsd-nat.c
+++ b/gdb/sparc-netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "target.h"
 
diff --git a/gdb/sparc-netbsd-tdep.c b/gdb/sparc-netbsd-tdep.c
index d2b1a4bfd140..fc22e66826fd 100644
--- a/gdb/sparc-netbsd-tdep.c
+++ b/gdb/sparc-netbsd-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc-obsd-tdep.c b/gdb/sparc-obsd-tdep.c
index 8cdbc8aae6e7..d6166710709c 100644
--- a/gdb/sparc-obsd-tdep.c
+++ b/gdb/sparc-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc-ravenscar-thread.c b/gdb/sparc-ravenscar-thread.c
index 0f6dec072c3e..82f68e14cb28 100644
--- a/gdb/sparc-ravenscar-thread.c
+++ b/gdb/sparc-ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "sparc-tdep.h"
diff --git a/gdb/sparc-sol2-nat.c b/gdb/sparc-sol2-nat.c
index cee9a68459e5..8f9607f338d9 100644
--- a/gdb/sparc-sol2-nat.c
+++ b/gdb/sparc-sol2-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 
 #include <sys/procfs.h>
diff --git a/gdb/sparc-sol2-tdep.c b/gdb/sparc-sol2-tdep.c
index 525784401038..aea3766d9b53 100644
--- a/gdb/sparc-sol2-tdep.c
+++ b/gdb/sparc-sol2-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 5eec3615f536..fbc27ffcb5e6 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "dwarf2.h"
diff --git a/gdb/sparc64-fbsd-nat.c b/gdb/sparc64-fbsd-nat.c
index 7c025405e974..c10d55f0cd0e 100644
--- a/gdb/sparc64-fbsd-nat.c
+++ b/gdb/sparc64-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "target.h"
 
diff --git a/gdb/sparc64-fbsd-tdep.c b/gdb/sparc64-fbsd-tdep.c
index c992c8c8f6fb..a30c7c448e5b 100644
--- a/gdb/sparc64-fbsd-tdep.c
+++ b/gdb/sparc64-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc64-linux-nat.c b/gdb/sparc64-linux-nat.c
index 24dfa2c01455..bd9aafd58b00 100644
--- a/gdb/sparc64-linux-nat.c
+++ b/gdb/sparc64-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 
 #include <sys/procfs.h>
diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c
index 33da5321d81a..e91bba3aadba 100644
--- a/gdb/sparc64-linux-tdep.c
+++ b/gdb/sparc64-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "dwarf2/frame.h"
diff --git a/gdb/sparc64-nat.c b/gdb/sparc64-nat.c
index a7cc4403c250..aa07bf5d3628 100644
--- a/gdb/sparc64-nat.c
+++ b/gdb/sparc64-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 
 #include "sparc64-tdep.h"
diff --git a/gdb/sparc64-netbsd-nat.c b/gdb/sparc64-netbsd-nat.c
index 32dc87e5495a..111a45dd8a76 100644
--- a/gdb/sparc64-netbsd-nat.c
+++ b/gdb/sparc64-netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/sparc64-netbsd-tdep.c b/gdb/sparc64-netbsd-tdep.c
index fe97689ae157..b101f4970d90 100644
--- a/gdb/sparc64-netbsd-tdep.c
+++ b/gdb/sparc64-netbsd-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc64-obsd-nat.c b/gdb/sparc64-obsd-nat.c
index c007edb71229..71589d109e3d 100644
--- a/gdb/sparc64-obsd-nat.c
+++ b/gdb/sparc64-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/sparc64-obsd-tdep.c b/gdb/sparc64-obsd-tdep.c
index 3837074a9fb7..6caeb107b9f0 100644
--- a/gdb/sparc64-obsd-tdep.c
+++ b/gdb/sparc64-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc64-sol2-tdep.c b/gdb/sparc64-sol2-tdep.c
index 7cef98bb681c..b7ca4ca1f5ba 100644
--- a/gdb/sparc64-sol2-tdep.c
+++ b/gdb/sparc64-sol2-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbarch.h"
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 8a90dd00d16f..a55107fa32d9 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dwarf2/frame.h"
 #include "frame.h"
diff --git a/gdb/split-name.c b/gdb/split-name.c
index eacec135530b..f29608095ab3 100644
--- a/gdb/split-name.c
+++ b/gdb/split-name.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "split-name.h"
 #include "cp-support.h"
 
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 025cb2120d19..85fe4000f329 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -24,7 +24,6 @@
    format).  Avoid placing any object file format specific code in
    this file.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
diff --git a/gdb/stack.c b/gdb/stack.c
index 23e3891a0600..9c679222708e 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index b54e4d2d10a7..0b66554efae1 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "stap-probe.h"
 #include "probe.h"
 #include "ui-out.h"
diff --git a/gdb/std-regs.c b/gdb/std-regs.c
index 755e0c987e6e..3539d8a629a6 100644
--- a/gdb/std-regs.c
+++ b/gdb/std-regs.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "user-regs.h"
 #include "frame.h"
 #include "gdbtypes.h"
diff --git a/gdb/stub-termcap.c b/gdb/stub-termcap.c
index 28b046d7f7f1..ff0ef9929604 100644
--- a/gdb/stub-termcap.c
+++ b/gdb/stub-termcap.c
@@ -20,7 +20,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 
 extern "C" {
 
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 3955298b1fef..bc70447600ee 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -25,7 +25,6 @@
    and then if the function returns a result printing a message after it
    returns.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
 #include "observable.h"
diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c
index 12a5f7d936b2..87fcc076986e 100644
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -41,7 +41,6 @@
    entry point.  */
 
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbcore.h"
 #include "objfiles.h"
diff --git a/gdb/symfile.c b/gdb/symfile.c
index db6d76e78bf5..2a7d41dc9746 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "bfdlink.h"
 #include "symtab.h"
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 49b9674f77ad..f80fc5ab196d 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "bfd.h"
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 33b664f94789..86603dfebc31 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/call-site.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/target-connection.c b/gdb/target-connection.c
index 388fd873d642..d9a529ae9bb3 100644
--- a/gdb/target-connection.c
+++ b/gdb/target-connection.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target-connection.h"
 
 #include <map>
diff --git a/gdb/target-dcache.c b/gdb/target-dcache.c
index 72886d753ec0..7c6bcd8d18c9 100644
--- a/gdb/target-dcache.c
+++ b/gdb/target-dcache.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target-dcache.h"
 #include "gdbcmd.h"
 #include "progspace.h"
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 591ae3dac7b5..8aca5cf719ba 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "gdbcmd.h"
 #include "gdbtypes.h"
@@ -1299,7 +1298,6 @@ class print_c_tdesc : public tdesc_element_visitor
     gdb_printf ("  Original: %s */\n\n",
 		lbasename (m_filename_after_features.c_str ()));
 
-    gdb_printf ("#include \"defs.h\"\n");
     gdb_printf ("#include \"osabi.h\"\n");
     gdb_printf ("#include \"target-descriptions.h\"\n");
     gdb_printf ("\n");
diff --git a/gdb/target-float.c b/gdb/target-float.c
index 415988923561..9b1b6b781d98 100644
--- a/gdb/target-float.c
+++ b/gdb/target-float.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "floatformat.h"
 #include "target-float.h"
diff --git a/gdb/target-memory.c b/gdb/target-memory.c
index 6bb67e44aa0d..f752769e415a 100644
--- a/gdb/target-memory.c
+++ b/gdb/target-memory.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "memory-map.h"
 #include "inferior.h"
diff --git a/gdb/target.c b/gdb/target.c
index bbc1badc9e19..107a84b3ca1d 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "target-dcache.h"
 #include "gdbcmd.h"
diff --git a/gdb/target/target.c b/gdb/target/target.c
index f00506a625ef..c84a6ff52daa 100644
--- a/gdb/target/target.c
+++ b/gdb/target/target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "target/target.h"
 
 /* Read LEN bytes of target memory at address MEMADDR, placing the
diff --git a/gdb/target/waitstatus.c b/gdb/target/waitstatus.c
index 411a2ecc4f82..30c0621326fd 100644
--- a/gdb/target/waitstatus.c
+++ b/gdb/target/waitstatus.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "waitstatus.h"
 
 /* See waitstatus.h.  */
diff --git a/gdb/test-target.c b/gdb/test-target.c
index 3d6629506701..4da7a08f24e6 100644
--- a/gdb/test-target.c
+++ b/gdb/test-target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "test-target.h"
 
 #if GDB_SELF_TEST
diff --git a/gdb/thread-iter.c b/gdb/thread-iter.c
index 31fcf1fc2551..601d23c9ec34 100644
--- a/gdb/thread-iter.c
+++ b/gdb/thread-iter.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbthread.h"
 #include "inferior.h"
 
diff --git a/gdb/thread.c b/gdb/thread.c
index 22523569fdbd..60a1bef8cf0a 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "symtab.h"
 #include "frame.h"
diff --git a/gdb/tic6x-linux-tdep.c b/gdb/tic6x-linux-tdep.c
index a9de60cf662a..c214178b66d4 100644
--- a/gdb/tic6x-linux-tdep.c
+++ b/gdb/tic6x-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "solib.h"
 #include "osabi.h"
 #include "linux-tdep.h"
diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
index aa115095df79..3a63b0cc25db 100644
--- a/gdb/tic6x-tdep.c
+++ b/gdb/tic6x-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/tid-parse.c b/gdb/tid-parse.c
index aa1480d7cf0c..623f55e14b36 100644
--- a/gdb/tid-parse.c
+++ b/gdb/tid-parse.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tid-parse.h"
 #include "inferior.h"
 #include "gdbthread.h"
diff --git a/gdb/tilegx-linux-nat.c b/gdb/tilegx-linux-nat.c
index ad707d34daf4..bbfeaefeccd2 100644
--- a/gdb/tilegx-linux-nat.c
+++ b/gdb/tilegx-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/tilegx-linux-tdep.c b/gdb/tilegx-linux-tdep.c
index e0ff0fc2a86c..cec2be2bfec0 100644
--- a/gdb/tilegx-linux-tdep.c
+++ b/gdb/tilegx-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "linux-tdep.h"
 #include "glibc-tdep.h"
diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
index c25933be5585..d5ea93cf5038 100644
--- a/gdb/tilegx-tdep.c
+++ b/gdb/tilegx-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/top.c b/gdb/top.c
index 0aeeb9878321..6e9df41c4f3c 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "cli/cli-cmds.h"
 #include "cli/cli-script.h"
diff --git a/gdb/tracectf.c b/gdb/tracectf.c
index 2ffae6bd326a..282a8250ac10 100644
--- a/gdb/tracectf.c
+++ b/gdb/tracectf.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tracectf.h"
 #include "tracepoint.h"
 #include "regcache.h"
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index f5696bf0129e..79af963b049b 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tracefile.h"
 #include "readline/tilde.h"
 #include "gdbsupport/filestuff.h"
diff --git a/gdb/tracefile.c b/gdb/tracefile.c
index e347b3a30c0d..9db68bbac510 100644
--- a/gdb/tracefile.c
+++ b/gdb/tracefile.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tracefile.h"
 #include "tracectf.h"
 #include "exec.h"
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 418d9ea2203a..1586a043af69 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "frame.h"
diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c
index c35e08ab2805..fc9261314784 100644
--- a/gdb/trad-frame.c
+++ b/gdb/trad-frame.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "trad-frame.h"
 #include "regcache.h"
diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c
index 0e730e66b583..4b397cbf046d 100644
--- a/gdb/tramp-frame.c
+++ b/gdb/tramp-frame.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tramp-frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index 2587dfe59b4a..59e595525b00 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tui/tui.h"
 #include "tui/tui-data.h"
 #include "tui/tui-win.h"
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 03395d2df09d..462771ca1637 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "tui/tui.h"
 #include "tui/tui-data.h"
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 5dc27c32daac..07ca37603b8c 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "breakpoint.h"
diff --git a/gdb/tui/tui-file.c b/gdb/tui/tui-file.c
index 1cf840488c12..a0d72a0fbd2e 100644
--- a/gdb/tui/tui-file.c
+++ b/gdb/tui/tui-file.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tui/tui-file.h"
 #include "tui/tui-io.h"
 #include "tui/tui-command.h"
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 289a25996889..cf48e709ed8a 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "inferior.h"
 #include "command.h"
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index b16da314455e..a75708ba6624 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-interp.h"
 #include "interps.h"
 #include "ui.h"
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index ba07e3d573bb..34e85de08532 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "gdbsupport/event-loop.h"
 #include "event-top.h"
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index a96ca855d1d7..143254bcf990 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "command.h"
 #include "symtab.h"
diff --git a/gdb/tui/tui-location.c b/gdb/tui/tui-location.c
index 831ab14345eb..7e8f769d8047 100644
--- a/gdb/tui/tui-location.c
+++ b/gdb/tui/tui-location.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tui/tui.h"
 #include "tui/tui-status.h"
 #include "tui/tui-data.h"
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 05211eb7b221..88e1c5a34105 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "tui/tui.h"
 #include "tui/tui-data.h"
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index fa956b29a195..5c17aba3a1a2 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <math.h>
 #include <ctype.h>
 #include "symtab.h"
diff --git a/gdb/tui/tui-status.c b/gdb/tui/tui-status.c
index aac391d3babc..c7750af6ea0b 100644
--- a/gdb/tui/tui-status.c
+++ b/gdb/tui/tui-status.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "breakpoint.h"
 #include "frame.h"
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a2982eba0c62..ced7e254f505 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -24,7 +24,6 @@
 
    Author: Susan B. Macchia  */
 
-#include "defs.h"
 #include "command.h"
 #include "symtab.h"
 #include "breakpoint.h"
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 4263b9c049ba..c14ac5a8faf2 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tui/tui.h"
 #include "tui/tui-data.h"
 #include "tui/tui-io.h"
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 6b8716cd27cf..4dbbe922256e 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "symtab.h"
 #include "frame.h"
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index dea6ffbf954d..19f09609a2f6 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "tui/tui.h"
 #include "tui/tui-hooks.h"
diff --git a/gdb/type-stack.c b/gdb/type-stack.c
index 614f7e8764e6..09348dfd3713 100644
--- a/gdb/type-stack.c
+++ b/gdb/type-stack.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "type-stack.h"
 
 #include "gdbtypes.h"
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 3b100dcb1482..4d0e764274a1 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
 #include "symtab.h"
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index e60921072a47..dd15ea427bcf 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -19,7 +19,6 @@
 
 /* Implement the ``struct ui_file'' object.  */
 
-#include "defs.h"
 #include "ui-file.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/gdb_select.h"
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index a5f1ba518abe..b3a2fb7f4e51 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "expression.h"
 #include "language.h"
 #include "ui-out.h"
diff --git a/gdb/ui-style.c b/gdb/ui-style.c
index 3d9e1b5a97de..952102e30c32 100644
--- a/gdb/ui-style.c
+++ b/gdb/ui-style.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ui-style.h"
 #include "gdbsupport/gdb_regex.h"
 
diff --git a/gdb/ui.c b/gdb/ui.c
index 2a9bf519c6cd..80ee67dbae5a 100644
--- a/gdb/ui.c
+++ b/gdb/ui.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ui.h"
 
 #include "cli/cli-cmds.h"
diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-view-selftests.c
index 299318ace434..eb3ae304790f 100644
--- a/gdb/unittests/array-view-selftests.c
+++ b/gdb/unittests/array-view-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/array-view.h"
 #include <array>
diff --git a/gdb/unittests/child-path-selftests.c b/gdb/unittests/child-path-selftests.c
index 9f77dd739955..4c4014d14776 100644
--- a/gdb/unittests/child-path-selftests.c
+++ b/gdb/unittests/child-path-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/cli-utils-selftests.c b/gdb/unittests/cli-utils-selftests.c
index 69d84bf50153..6ade3af4ffa4 100644
--- a/gdb/unittests/cli-utils-selftests.c
+++ b/gdb/unittests/cli-utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-utils.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c
index 74a218019766..6936af740fc4 100644
--- a/gdb/unittests/command-def-selftests.c
+++ b/gdb/unittests/command-def-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/unittests/common-utils-selftests.c b/gdb/unittests/common-utils-selftests.c
index b1f8fb843964..e66e38045ad5 100644
--- a/gdb/unittests/common-utils-selftests.c
+++ b/gdb/unittests/common-utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/selftest.h"
 
 namespace selftests {
diff --git a/gdb/unittests/copy_bitwise-selftests.c b/gdb/unittests/copy_bitwise-selftests.c
index 776d99ac9f12..c9f61b09cf42 100644
--- a/gdb/unittests/copy_bitwise-selftests.c
+++ b/gdb/unittests/copy_bitwise-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "utils.h"
 
diff --git a/gdb/unittests/enum-flags-selftests.c b/gdb/unittests/enum-flags-selftests.c
index 54e168173de6..b55d8c314062 100644
--- a/gdb/unittests/enum-flags-selftests.c
+++ b/gdb/unittests/enum-flags-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/valid-expr.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/unittests/environ-selftests.c b/gdb/unittests/environ-selftests.c
index c016e74ccf1e..9bd736028b3b 100644
--- a/gdb/unittests/environ-selftests.c
+++ b/gdb/unittests/environ-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/environ.h"
 #include "diagnostics.h"
diff --git a/gdb/unittests/filtered_iterator-selftests.c b/gdb/unittests/filtered_iterator-selftests.c
index 147f09dd4499..dc76fe031aa4 100644
--- a/gdb/unittests/filtered_iterator-selftests.c
+++ b/gdb/unittests/filtered_iterator-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/filtered-iterator.h"
 
diff --git a/gdb/unittests/format_pieces-selftests.c b/gdb/unittests/format_pieces-selftests.c
index b4918c67af42..a01f248c316f 100644
--- a/gdb/unittests/format_pieces-selftests.c
+++ b/gdb/unittests/format_pieces-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/format.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/frame_info_ptr-selftests.c b/gdb/unittests/frame_info_ptr-selftests.c
index f09d1c8ba015..ec83024cc3d1 100644
--- a/gdb/unittests/frame_info_ptr-selftests.c
+++ b/gdb/unittests/frame_info_ptr-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "frame.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/unittests/function-view-selftests.c b/gdb/unittests/function-view-selftests.c
index b01c02c1d9bd..dc1a6304eb68 100644
--- a/gdb/unittests/function-view-selftests.c
+++ b/gdb/unittests/function-view-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/function-view.h"
 
diff --git a/gdb/unittests/gdb_tilde_expand-selftests.c b/gdb/unittests/gdb_tilde_expand-selftests.c
index 5edf4b688b19..165885f361b9 100644
--- a/gdb/unittests/gdb_tilde_expand-selftests.c
+++ b/gdb/unittests/gdb_tilde_expand-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/selftest.h"
 #include <cstdlib>
 
diff --git a/gdb/unittests/gmp-utils-selftests.c b/gdb/unittests/gmp-utils-selftests.c
index 513ebc824979..3c6b71062a7b 100644
--- a/gdb/unittests/gmp-utils-selftests.c
+++ b/gdb/unittests/gmp-utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gmp-utils.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/intrusive_list-selftests.c b/gdb/unittests/intrusive_list-selftests.c
index 61e1343b2419..28d0134ffe6b 100644
--- a/gdb/unittests/intrusive_list-selftests.c
+++ b/gdb/unittests/intrusive_list-selftests.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbsupport/intrusive_list.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/unittests/lookup_name_info-selftests.c b/gdb/unittests/lookup_name_info-selftests.c
index 2fd8be9a3dbd..fe87bedac765 100644
--- a/gdb/unittests/lookup_name_info-selftests.c
+++ b/gdb/unittests/lookup_name_info-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "symtab.h"
 
diff --git a/gdb/unittests/main-thread-selftests.c b/gdb/unittests/main-thread-selftests.c
index 9fd1b99e34b0..1ba350575f10 100644
--- a/gdb/unittests/main-thread-selftests.c
+++ b/gdb/unittests/main-thread-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/block-signals.h"
 #include "gdbsupport/scope-exit.h"
diff --git a/gdb/unittests/memory-map-selftests.c b/gdb/unittests/memory-map-selftests.c
index cc059bbc1996..55d66fd61a0d 100644
--- a/gdb/unittests/memory-map-selftests.c
+++ b/gdb/unittests/memory-map-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "memory-map.h"
 
diff --git a/gdb/unittests/memrange-selftests.c b/gdb/unittests/memrange-selftests.c
index d6a10511a751..df02b6ad2658 100644
--- a/gdb/unittests/memrange-selftests.c
+++ b/gdb/unittests/memrange-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "memrange.h"
 
diff --git a/gdb/unittests/mkdir-recursive-selftests.c b/gdb/unittests/mkdir-recursive-selftests.c
index 1aaf685855b2..a96874d22282 100644
--- a/gdb/unittests/mkdir-recursive-selftests.c
+++ b/gdb/unittests/mkdir-recursive-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/unittests/observable-selftests.c b/gdb/unittests/observable-selftests.c
index bc2e001d86a0..2640f6817ee5 100644
--- a/gdb/unittests/observable-selftests.c
+++ b/gdb/unittests/observable-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/observable.h"
 
diff --git a/gdb/unittests/offset-type-selftests.c b/gdb/unittests/offset-type-selftests.c
index e5a24ab1a19b..95cc4f8ebd59 100644
--- a/gdb/unittests/offset-type-selftests.c
+++ b/gdb/unittests/offset-type-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/offset-type.h"
 #include "gdbsupport/underlying.h"
diff --git a/gdb/unittests/packed-selftests.c b/gdb/unittests/packed-selftests.c
index 852a7d364ce9..060c87c4e159 100644
--- a/gdb/unittests/packed-selftests.c
+++ b/gdb/unittests/packed-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/packed.h"
 
diff --git a/gdb/unittests/parallel-for-selftests.c b/gdb/unittests/parallel-for-selftests.c
index a9abbf0328c1..0261948361ae 100644
--- a/gdb/unittests/parallel-for-selftests.c
+++ b/gdb/unittests/parallel-for-selftests.c
@@ -24,7 +24,6 @@
    FOR_EACH.  The FOR_EACH-defined part reads like a regular function.  */
 #ifndef FOR_EACH
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/parallel-for.h"
 
diff --git a/gdb/unittests/parse-connection-spec-selftests.c b/gdb/unittests/parse-connection-spec-selftests.c
index 83c006ba9285..55a7c13c3a8c 100644
--- a/gdb/unittests/parse-connection-spec-selftests.c
+++ b/gdb/unittests/parse-connection-spec-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/netstuff.h"
 #include "diagnostics.h"
diff --git a/gdb/unittests/path-join-selftests.c b/gdb/unittests/path-join-selftests.c
index 15df04884d9b..08fad63341d8 100644
--- a/gdb/unittests/path-join-selftests.c
+++ b/gdb/unittests/path-join-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/ptid-selftests.c b/gdb/unittests/ptid-selftests.c
index a44ffa3f7c99..6fc04c12eb1c 100644
--- a/gdb/unittests/ptid-selftests.c
+++ b/gdb/unittests/ptid-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/ptid.h"
 #include <type_traits>
 
diff --git a/gdb/unittests/rsp-low-selftests.c b/gdb/unittests/rsp-low-selftests.c
index 90141abb65e7..7a1787150965 100644
--- a/gdb/unittests/rsp-low-selftests.c
+++ b/gdb/unittests/rsp-low-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/rsp-low.h"
 
diff --git a/gdb/unittests/scoped_fd-selftests.c b/gdb/unittests/scoped_fd-selftests.c
index e85f9f7d920f..1413c5018e87 100644
--- a/gdb/unittests/scoped_fd-selftests.c
+++ b/gdb/unittests/scoped_fd-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/scoped_fd.h"
diff --git a/gdb/unittests/scoped_ignore_signal-selftests.c b/gdb/unittests/scoped_ignore_signal-selftests.c
index dc1d9341b7a1..361928c53c0b 100644
--- a/gdb/unittests/scoped_ignore_signal-selftests.c
+++ b/gdb/unittests/scoped_ignore_signal-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/scoped_ignore_signal.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/scope-exit.h"
diff --git a/gdb/unittests/scoped_mmap-selftests.c b/gdb/unittests/scoped_mmap-selftests.c
index dbf836fa2d7c..7b3a6f5202b4 100644
--- a/gdb/unittests/scoped_mmap-selftests.c
+++ b/gdb/unittests/scoped_mmap-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/scoped_mmap.h"
diff --git a/gdb/unittests/scoped_restore-selftests.c b/gdb/unittests/scoped_restore-selftests.c
index 074cc4ccda1e..1fd511813923 100644
--- a/gdb/unittests/scoped_restore-selftests.c
+++ b/gdb/unittests/scoped_restore-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/scoped_restore.h"
 
diff --git a/gdb/unittests/search-memory-selftests.c b/gdb/unittests/search-memory-selftests.c
index 109ce8b528d5..11246337db33 100644
--- a/gdb/unittests/search-memory-selftests.c
+++ b/gdb/unittests/search-memory-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/search.h"
 
diff --git a/gdb/unittests/style-selftests.c b/gdb/unittests/style-selftests.c
index 8a6cf2b38682..4dc3c842c470 100644
--- a/gdb/unittests/style-selftests.c
+++ b/gdb/unittests/style-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "ui-style.h"
 
diff --git a/gdb/unittests/tracepoint-selftests.c b/gdb/unittests/tracepoint-selftests.c
index 7267b70eef97..027002845483 100644
--- a/gdb/unittests/tracepoint-selftests.c
+++ b/gdb/unittests/tracepoint-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "tracepoint.h"
 
diff --git a/gdb/unittests/tui-selftests.c b/gdb/unittests/tui-selftests.c
index e936b20f3705..684720797017 100644
--- a/gdb/unittests/tui-selftests.c
+++ b/gdb/unittests/tui-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 
 #ifdef TUI
diff --git a/gdb/unittests/ui-file-selftests.c b/gdb/unittests/ui-file-selftests.c
index eff1be7f2b2f..7c55b80cdfed 100644
--- a/gdb/unittests/ui-file-selftests.c
+++ b/gdb/unittests/ui-file-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "ui-file.h"
 
diff --git a/gdb/unittests/unique_xmalloc_ptr_char.c b/gdb/unittests/unique_xmalloc_ptr_char.c
index e36d871dd170..b7fd5b6c4a1a 100644
--- a/gdb/unittests/unique_xmalloc_ptr_char.c
+++ b/gdb/unittests/unique_xmalloc_ptr_char.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "gdbsupport/gdb_unique_ptr.h"
diff --git a/gdb/unittests/unpack-selftests.c b/gdb/unittests/unpack-selftests.c
index 2fc789231db1..35f4eeeee2fb 100644
--- a/gdb/unittests/unpack-selftests.c
+++ b/gdb/unittests/unpack-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "value.h"
diff --git a/gdb/unittests/utils-selftests.c b/gdb/unittests/utils-selftests.c
index 2f6d10400e1e..6748dc2546c7 100644
--- a/gdb/unittests/utils-selftests.c
+++ b/gdb/unittests/utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "utils.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/vec-utils-selftests.c b/gdb/unittests/vec-utils-selftests.c
index e7ff1289205d..da3bcf08d3cd 100644
--- a/gdb/unittests/vec-utils-selftests.c
+++ b/gdb/unittests/vec-utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/selftest.h"
 
 #include "gdbsupport/gdb_vecs.h"
diff --git a/gdb/unittests/xml-utils-selftests.c b/gdb/unittests/xml-utils-selftests.c
index 31f74742b0a5..627d5d8428ee 100644
--- a/gdb/unittests/xml-utils-selftests.c
+++ b/gdb/unittests/xml-utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/xml-utils.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/user-regs.c b/gdb/user-regs.c
index d1b510a79278..ac04f63dbb80 100644
--- a/gdb/user-regs.c
+++ b/gdb/user-regs.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "user-regs.h"
 #include "gdbtypes.h"
 #include "frame.h"
diff --git a/gdb/utils.c b/gdb/utils.c
index 68aebf373819..ded03c740997 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "gdbsupport/gdb_wait.h"
 #include "event-top.h"
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 4c1fd383a84f..6bda14f0fa15 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "trad-frame.h"
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 31b1c4762f77..6b152cadcac9 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/valops.c b/gdb/valops.c
index 52cce2872813..a17b937a9631 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 7b3ffc884f13..40ffdbe6146f 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/value.c b/gdb/value.c
index 7ddfeb7c7286..1bd180a62ccc 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/varobj.c b/gdb/varobj.c
index af64534169f8..8ce3cbdd440f 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "expression.h"
 #include "frame.h"
diff --git a/gdb/vax-bsd-nat.c b/gdb/vax-bsd-nat.c
index 0f982ca62190..2a4db3a81218 100644
--- a/gdb/vax-bsd-nat.c
+++ b/gdb/vax-bsd-nat.c
@@ -19,7 +19,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/vax-netbsd-tdep.c b/gdb/vax-netbsd-tdep.c
index 66c56227f418..fa528ae658a3 100644
--- a/gdb/vax-netbsd-tdep.c
+++ b/gdb/vax-netbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "osabi.h"
 
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
index 125f3423be57..dd00898c298c 100644
--- a/gdb/vax-tdep.c
+++ b/gdb/vax-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "frame.h"
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index b123a66ef0f9..6fc412310236 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -21,7 +21,6 @@
 
 /* Originally by Steve Chamberlain, sac@cygnus.com */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 361ccdd0dcbf..f9585adf8fa3 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "windows-tdep.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "xml-support.h"
diff --git a/gdb/x86-bsd-nat.c b/gdb/x86-bsd-nat.c
index e2bc7a8ad0b1..2bdd385e7f24 100644
--- a/gdb/x86-bsd-nat.c
+++ b/gdb/x86-bsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbthread.h"
 
diff --git a/gdb/x86-fbsd-nat.c b/gdb/x86-fbsd-nat.c
index eea4dd37cac5..bfd15bf6748d 100644
--- a/gdb/x86-fbsd-nat.c
+++ b/gdb/x86-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "x86-fbsd-nat.h"
 #ifdef PT_GETXSTATE_INFO
 #include "nat/x86-xstate.h"
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index b93ffca38db2..a3d8ffb60f16 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "elf/common.h"
 #include "gdb_proc_service.h"
diff --git a/gdb/x86-nat.c b/gdb/x86-nat.c
index bd4a05da2375..5826716a1f8d 100644
--- a/gdb/x86-nat.c
+++ b/gdb/x86-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "x86-nat.h"
 #include "gdbcmd.h"
 #include "inferior.h"
diff --git a/gdb/x86-tdep.c b/gdb/x86-tdep.c
index 4cacf3ba511d..5d7aa9535b7c 100644
--- a/gdb/x86-tdep.c
+++ b/gdb/x86-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "x86-tdep.h"
 #include "symtab.h"
 
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index e324f4ef8caf..c4914bdcbaf0 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 
 #include <sys/types.h>
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 65de9b292f0b..583e101c25f4 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "xml-builtin.h"
 #include "xml-support.h"
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index fc999f0eee30..2373d0fd77b5 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "xml-support.h"
 #include "xml-syscall.h"
diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c
index 0a84f2b77ed5..436c493d4f91 100644
--- a/gdb/xml-tdesc.c
+++ b/gdb/xml-tdesc.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "target-descriptions.h"
 #include "xml-support.h"
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index 12b16c2d3d36..166e6af85275 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/xtensa-config.c b/gdb/xtensa-config.c
index c312fe2749ef..77eb922c1f9f 100644
--- a/gdb/xtensa-config.c
+++ b/gdb/xtensa-config.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #define XTENSA_CONFIG_VERSION 0x60
 
diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c
index e32656833a16..f8509b02e07d 100644
--- a/gdb/xtensa-linux-nat.c
+++ b/gdb/xtensa-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/xtensa-linux-tdep.c b/gdb/xtensa-linux-tdep.c
index cc8c30b10683..7c215e300b37 100644
--- a/gdb/xtensa-linux-tdep.c
+++ b/gdb/xtensa-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "xtensa-tdep.h"
 #include "osabi.h"
 #include "linux-tdep.h"
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index d116b34fd819..2c3d468d8be9 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "solib-svr4.h"
 #include "symtab.h"
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index f2d000f53030..ee8e36b18670 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "frame.h"
diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc
index 2307e8dbeea6..ff42795582ff 100644
--- a/gdbserver/ax.cc
+++ b/gdbserver/ax.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "ax.h"
 #include "gdbsupport/format.h"
 #include "tracepoint.h"
diff --git a/gdbserver/debug.cc b/gdbserver/debug.cc
index 9bdff962dda0..ae9ca5cd7687 100644
--- a/gdbserver/debug.cc
+++ b/gdbserver/debug.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <chrono>
 
 #if !defined (IN_PROCESS_AGENT)
diff --git a/gdbserver/dll.cc b/gdbserver/dll.cc
index 0fb6476f40e1..ff637a03fed1 100644
--- a/gdbserver/dll.cc
+++ b/gdbserver/dll.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "dll.h"
 
 #include <algorithm>
diff --git a/gdbserver/fork-child.cc b/gdbserver/fork-child.cc
index 43ff57c31673..7e4c69b31bd5 100644
--- a/gdbserver/fork-child.cc
+++ b/gdbserver/fork-child.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "gdbsupport/job-control.h"
 #include "gdbsupport/scoped_restore.h"
 #include "nat/fork-inferior.h"
diff --git a/gdbserver/gdbreplay.cc b/gdbserver/gdbreplay.cc
index 6263423db357..0219e865ec73 100644
--- a/gdbserver/gdbreplay.cc
+++ b/gdbserver/gdbreplay.cc
@@ -17,8 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
-
 #undef PACKAGE
 #undef PACKAGE_NAME
 #undef PACKAGE_VERSION
diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc
index 255d86dab654..c5ae35ab7ddb 100644
--- a/gdbserver/hostio.cc
+++ b/gdbserver/hostio.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "gdbsupport/fileio.h"
 #include "hostio.h"
 
diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
index 60d565b84823..62cafd872041 100644
--- a/gdbserver/i387-fp.cc
+++ b/gdbserver/i387-fp.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "i387-fp.h"
 #include "gdbsupport/x86-xstate.h"
 #include "nat/x86-xstate.h"
diff --git a/gdbserver/inferiors.cc b/gdbserver/inferiors.cc
index c02d47aa91b8..d088340474fa 100644
--- a/gdbserver/inferiors.cc
+++ b/gdbserver/inferiors.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "gdbsupport/common-inferior.h"
 #include "gdbthread.h"
 #include "dll.h"
diff --git a/gdbserver/linux-aarch32-low.cc b/gdbserver/linux-aarch32-low.cc
index 940c10fd1cf5..ca66e7f8fbc5 100644
--- a/gdbserver/linux-aarch32-low.cc
+++ b/gdbserver/linux-aarch32-low.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "arch/arm.h"
 #include "arch/arm-linux.h"
 #include "linux-low.h"
diff --git a/gdbserver/linux-aarch32-tdesc.cc b/gdbserver/linux-aarch32-tdesc.cc
index 54c6f62e9965..b8987752b9f8 100644
--- a/gdbserver/linux-aarch32-tdesc.cc
+++ b/gdbserver/linux-aarch32-tdesc.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #include "linux-aarch32-tdesc.h"
 
diff --git a/gdbserver/linux-aarch64-ipa.cc b/gdbserver/linux-aarch64-ipa.cc
index f33374ebd6c8..99b7700ac4b9 100644
--- a/gdbserver/linux-aarch64-ipa.cc
+++ b/gdbserver/linux-aarch64-ipa.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include <elf.h>
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index 28d75d035dcb..5df67fccd08c 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "nat/aarch64-linux.h"
 #include "nat/aarch64-linux-hw-point.h"
diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbserver/linux-aarch64-tdesc.cc
index 7a41769905c4..0ed9a42cbff6 100644
--- a/gdbserver/linux-aarch64-tdesc.cc
+++ b/gdbserver/linux-aarch64-tdesc.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #include "linux-aarch64-tdesc.h"
 
diff --git a/gdbserver/linux-amd64-ipa.cc b/gdbserver/linux-amd64-ipa.cc
index 54e4c9812bb3..13c8a5bb360e 100644
--- a/gdbserver/linux-amd64-ipa.cc
+++ b/gdbserver/linux-amd64-ipa.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include "linux-x86-tdesc.h"
diff --git a/gdbserver/linux-arc-low.cc b/gdbserver/linux-arc-low.cc
index 166a4431f09f..dda224f0a74c 100644
--- a/gdbserver/linux-arc-low.cc
+++ b/gdbserver/linux-arc-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "regdef.h"
 #include "linux-low.h"
 #include "tdesc.h"
diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc
index 396ec88081b9..17b64c09affd 100644
--- a/gdbserver/linux-arm-low.cc
+++ b/gdbserver/linux-arm-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "arch/arm.h"
 #include "arch/arm-linux.h"
diff --git a/gdbserver/linux-arm-tdesc.cc b/gdbserver/linux-arm-tdesc.cc
index 24941fe667e3..559f9b0f3dc3 100644
--- a/gdbserver/linux-arm-tdesc.cc
+++ b/gdbserver/linux-arm-tdesc.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #include "linux-arm-tdesc.h"
 
diff --git a/gdbserver/linux-csky-low.cc b/gdbserver/linux-csky-low.cc
index 5497f7dc7a36..2eb5a2df17b9 100644
--- a/gdbserver/linux-csky-low.cc
+++ b/gdbserver/linux-csky-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "tdesc.h"
 #include "linux-low.h"
 #include <sys/ptrace.h>
diff --git a/gdbserver/linux-i386-ipa.cc b/gdbserver/linux-i386-ipa.cc
index 2e4646f8c032..8f14e0937d40 100644
--- a/gdbserver/linux-i386-ipa.cc
+++ b/gdbserver/linux-i386-ipa.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include "linux-x86-tdesc.h"
diff --git a/gdbserver/linux-ia64-low.cc b/gdbserver/linux-ia64-low.cc
index 7bceaadbc809..b7c3c642eb3e 100644
--- a/gdbserver/linux-ia64-low.cc
+++ b/gdbserver/linux-ia64-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 #ifdef HAVE_SYS_REG_H
diff --git a/gdbserver/linux-loongarch-low.cc b/gdbserver/linux-loongarch-low.cc
index f1e1deb878ba..584ea64a7d95 100644
--- a/gdbserver/linux-loongarch-low.cc
+++ b/gdbserver/linux-loongarch-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "tdesc.h"
 #include "elf/common.h"
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 9d5a62428034..d8842f0972db 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "nat/linux-osdata.h"
 #include "gdbsupport/agent.h"
diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc
index 1cccb25bc53d..8020e49ac6e7 100644
--- a/gdbserver/linux-m68k-low.cc
+++ b/gdbserver/linux-m68k-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 /* Linux target op definitions for the m68k architecture.  */
diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc
index 35f92fc24d45..6cf4a6d2d9b7 100644
--- a/gdbserver/linux-mips-low.cc
+++ b/gdbserver/linux-mips-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 #include "nat/gdb_ptrace.h"
diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc
index 31868ff0a4a9..c37bb5a5da9e 100644
--- a/gdbserver/linux-nios2-low.cc
+++ b/gdbserver/linux-nios2-low.cc
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "elf/common.h"
 #include "nat/gdb_ptrace.h"
diff --git a/gdbserver/linux-or1k-low.cc b/gdbserver/linux-or1k-low.cc
index bea92516e9c7..1e0fa39358ce 100644
--- a/gdbserver/linux-or1k-low.cc
+++ b/gdbserver/linux-or1k-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "elf/common.h"
 #include "nat/gdb_ptrace.h"
diff --git a/gdbserver/linux-ppc-ipa.cc b/gdbserver/linux-ppc-ipa.cc
index 299ef377843a..cbbfcfa19be0 100644
--- a/gdbserver/linux-ppc-ipa.cc
+++ b/gdbserver/linux-ppc-ipa.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include "arch/ppc-linux-tdesc.h"
diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc
index 5c45a3f6ecb0..bd3ac143660d 100644
--- a/gdbserver/linux-ppc-low.cc
+++ b/gdbserver/linux-ppc-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 #include "elf/common.h"
diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc
index 680e9f7a094b..c4554c507a8c 100644
--- a/gdbserver/linux-riscv-low.cc
+++ b/gdbserver/linux-riscv-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #include "linux-low.h"
 #include "tdesc.h"
diff --git a/gdbserver/linux-s390-ipa.cc b/gdbserver/linux-s390-ipa.cc
index 56d106674457..55ce4a41d157 100644
--- a/gdbserver/linux-s390-ipa.cc
+++ b/gdbserver/linux-s390-ipa.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include "linux-s390-tdesc.h"
diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc
index 79937f00d6f1..ee2c192609ac 100644
--- a/gdbserver/linux-s390-low.cc
+++ b/gdbserver/linux-s390-low.cc
@@ -19,7 +19,6 @@
 
 /* This file is used for both 31-bit and 64-bit S/390 systems.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "elf/common.h"
 #include "ax.h"
diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc
index 910b6a0e2e9e..64e6de3480bc 100644
--- a/gdbserver/linux-sh-low.cc
+++ b/gdbserver/linux-sh-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 /* Linux target op definitions for the SH architecture.  */
diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc
index 8e3960a5fa7e..4192bd3984ef 100644
--- a/gdbserver/linux-sparc-low.cc
+++ b/gdbserver/linux-sparc-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 #include "nat/gdb_ptrace.h"
diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc
index 7c961901dd10..707be2e7b0f9 100644
--- a/gdbserver/linux-tic6x-low.cc
+++ b/gdbserver/linux-tic6x-low.cc
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "arch/tic6x.h"
 #include "tdesc.h"
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 933d1fb012a1..2532603451af 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <signal.h>
 #include <limits.h>
 #include <inttypes.h>
diff --git a/gdbserver/linux-x86-tdesc.cc b/gdbserver/linux-x86-tdesc.cc
index 626207fc477a..cd3b5d80e37e 100644
--- a/gdbserver/linux-x86-tdesc.cc
+++ b/gdbserver/linux-x86-tdesc.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "tdesc.h"
 #include "linux-x86-tdesc.h"
 #include "arch/i386.h"
diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc
index 9ebb2e635906..b20b62e1c0d3 100644
--- a/gdbserver/linux-xtensa-low.cc
+++ b/gdbserver/linux-xtensa-low.cc
@@ -17,7 +17,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "server.h"
 #include "linux-low.h"
 
 /* Linux target op definitions for the Xtensa architecture.  */
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index c23bb46c666a..eebf999c223d 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "regcache.h"
 #include "ax.h"
 
diff --git a/gdbserver/netbsd-aarch64-low.cc b/gdbserver/netbsd-aarch64-low.cc
index cfb1bb7914b0..f20a1a717733 100644
--- a/gdbserver/netbsd-aarch64-low.cc
+++ b/gdbserver/netbsd-aarch64-low.cc
@@ -19,7 +19,6 @@
 #include <sys/ptrace.h>
 #include <limits.h>
 
-#include "server.h"
 #include "netbsd-low.h"
 #include "arch/aarch64.h"
 #include "arch/aarch64-insn.h"
diff --git a/gdbserver/netbsd-amd64-low.cc b/gdbserver/netbsd-amd64-low.cc
index 5555e0ba3070..2c8c7113f7dd 100644
--- a/gdbserver/netbsd-amd64-low.cc
+++ b/gdbserver/netbsd-amd64-low.cc
@@ -19,7 +19,6 @@
 #include <sys/ptrace.h>
 #include <limits.h>
 
-#include "server.h"
 #include "netbsd-low.h"
 #include "gdbsupport/x86-xstate.h"
 #include "arch/amd64.h"
diff --git a/gdbserver/netbsd-i386-low.cc b/gdbserver/netbsd-i386-low.cc
index a694609d50df..247a39797c41 100644
--- a/gdbserver/netbsd-i386-low.cc
+++ b/gdbserver/netbsd-i386-low.cc
@@ -19,7 +19,6 @@
 #include <sys/ptrace.h>
 #include <limits.h>
 
-#include "server.h"
 #include "netbsd-low.h"
 #include "gdbsupport/x86-xstate.h"
 #include "arch/i386.h"
diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc
index bcb1bd97170f..4b58826e0914 100644
--- a/gdbserver/netbsd-low.cc
+++ b/gdbserver/netbsd-low.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "target.h"
 #include "netbsd-low.h"
 #include "nat/netbsd-nat.h"
diff --git a/gdbserver/notif.cc b/gdbserver/notif.cc
index 25e40a3c6b61..dac3c3b1bab0 100644
--- a/gdbserver/notif.cc
+++ b/gdbserver/notif.cc
@@ -47,7 +47,6 @@
 
    # 3 is done by function 'handle_notif_ack'.  */
 
-#include "server.h"
 #include "notif.h"
 
 static struct notif_server *notifs[] =
diff --git a/gdbserver/proc-service.cc b/gdbserver/proc-service.cc
index 40a0c7c43bfc..0a332b52d56b 100644
--- a/gdbserver/proc-service.cc
+++ b/gdbserver/proc-service.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 /* This file is currently tied to GNU/Linux.  It should scale well to
    another libthread_db implementation, with the appropriate gdbserver
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 55d14239e816..1bb71d103288 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "regdef.h"
 #include "gdbthread.h"
 #include "tdesc.h"
diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index 959557534013..5a8eb9ae52ae 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #if HAVE_TERMIOS_H
 #include <termios.h>
 #endif
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 74c7763d777a..c7d5cc1c1b0a 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "gdbthread.h"
 #include "gdbsupport/agent.h"
 #include "notif.h"
diff --git a/gdbserver/symbol.cc b/gdbserver/symbol.cc
index 90945dcd35dc..435acc71978f 100644
--- a/gdbserver/symbol.cc
+++ b/gdbserver/symbol.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "gdbsupport/symbol.h"
 
 /* See gdbsupport/symbol.h.  */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 23b699d33bb9..6db32da2e959 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "tracepoint.h"
 #include "gdbsupport/byte-vector.h"
 #include "hostio.h"
diff --git a/gdbserver/tdesc.cc b/gdbserver/tdesc.cc
index aff6f53029a3..3265793da962 100644
--- a/gdbserver/tdesc.cc
+++ b/gdbserver/tdesc.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "tdesc.h"
 #include "regdef.h"
 
diff --git a/gdbserver/thread-db.cc b/gdbserver/thread-db.cc
index d08c0f752632..8cef84206b8b 100644
--- a/gdbserver/thread-db.cc
+++ b/gdbserver/thread-db.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #include "linux-low.h"
 
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 461fa8fa1c55..b7d0ef2c2932 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "tracepoint.h"
 #include "gdbthread.h"
 #include "gdbsupport/rsp-low.h"
diff --git a/gdbserver/utils.cc b/gdbserver/utils.cc
index 11902f7c3fd5..3d3144e33da3 100644
--- a/gdbserver/utils.cc
+++ b/gdbserver/utils.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #ifdef IN_PROCESS_AGENT
 #  define PREFIX "ipa: "
diff --git a/gdbserver/win32-i386-low.cc b/gdbserver/win32-i386-low.cc
index 44490300b693..0a761ca58ef3 100644
--- a/gdbserver/win32-i386-low.cc
+++ b/gdbserver/win32-i386-low.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "win32-low.h"
 #include "x86-low.h"
 #include "gdbsupport/x86-xstate.h"
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 58e8b089f2e4..f672e542d1bc 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "regcache.h"
 #include "gdbsupport/fileio.h"
 #include "mem-break.h"
diff --git a/gdbserver/x86-low.cc b/gdbserver/x86-low.cc
index 11d9028992c3..c59b31b78f79 100644
--- a/gdbserver/x86-low.cc
+++ b/gdbserver/x86-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "x86-low.h"
 
 /* Clear the reference counts and forget everything we knew about the
diff --git a/gdbsupport/agent.cc b/gdbsupport/agent.cc
index 862582c78887..c70b59a4c839 100644
--- a/gdbsupport/agent.cc
+++ b/gdbsupport/agent.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "target/target.h"
 #include "gdbsupport/symbol.h"
 #include <unistd.h>
diff --git a/gdbsupport/btrace-common.cc b/gdbsupport/btrace-common.cc
index 2d54e8ba82d7..2358a9fab338 100644
--- a/gdbsupport/btrace-common.cc
+++ b/gdbsupport/btrace-common.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "btrace-common.h"
 
 
diff --git a/gdbsupport/cleanups.cc b/gdbsupport/cleanups.cc
index cc14523b2d1a..6362ea24e7c2 100644
--- a/gdbsupport/cleanups.cc
+++ b/gdbsupport/cleanups.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "cleanups.h"
 #include <vector>
 
diff --git a/gdbsupport/common-debug.cc b/gdbsupport/common-debug.cc
index 9a5309f1e721..c4d95287271d 100644
--- a/gdbsupport/common-debug.cc
+++ b/gdbsupport/common-debug.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "common-debug.h"
 
 /* See gdbsupport/common-debug.h.  */
diff --git a/gdbsupport/common-exceptions.cc b/gdbsupport/common-exceptions.cc
index 0caed27434e5..5aa16129b02b 100644
--- a/gdbsupport/common-exceptions.cc
+++ b/gdbsupport/common-exceptions.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "common-exceptions.h"
 #include <forward_list>
 
diff --git a/gdbsupport/common-inferior.cc b/gdbsupport/common-inferior.cc
index e9824dfcd36d..4211e049ba7d 100644
--- a/gdbsupport/common-inferior.cc
+++ b/gdbsupport/common-inferior.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/common-inferior.h"
 
 /* See common-inferior.h.  */
diff --git a/gdbsupport/common-regcache.cc b/gdbsupport/common-regcache.cc
index 9baca3197d10..525bb5ce7056 100644
--- a/gdbsupport/common-regcache.cc
+++ b/gdbsupport/common-regcache.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "common-regcache.h"
 
 /* Return the register's value or throw if it's not available.  */
diff --git a/gdbsupport/common-utils.cc b/gdbsupport/common-utils.cc
index 99b9cb8609bb..91c14a0f139f 100644
--- a/gdbsupport/common-utils.cc
+++ b/gdbsupport/common-utils.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "common-utils.h"
 #include "host-defs.h"
 #include "gdbsupport/gdb-safe-ctype.h"
diff --git a/gdbsupport/environ.cc b/gdbsupport/environ.cc
index f7984c565cb5..1b6ca61ee804 100644
--- a/gdbsupport/environ.cc
+++ b/gdbsupport/environ.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "environ.h"
 #include <algorithm>
 #include <utility>
diff --git a/gdbsupport/errors.cc b/gdbsupport/errors.cc
index cccdc5cafb24..c11229aa0d7b 100644
--- a/gdbsupport/errors.cc
+++ b/gdbsupport/errors.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "errors.h"
 #if defined (USE_WIN32API) || defined(__CYGWIN__)
 #include <windows.h>
diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc
index 0ab6974b8769..b18a9fdaac0a 100644
--- a/gdbsupport/event-loop.cc
+++ b/gdbsupport/event-loop.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/event-loop.h"
 
 #include <chrono>
diff --git a/gdbsupport/event-pipe.cc b/gdbsupport/event-pipe.cc
index 7e8e8d63683f..af6c943284fc 100644
--- a/gdbsupport/event-pipe.cc
+++ b/gdbsupport/event-pipe.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/event-pipe.h"
 #include "gdbsupport/filestuff.h"
 
diff --git a/gdbsupport/fileio.cc b/gdbsupport/fileio.cc
index 26fa6fd616eb..b115e33b581e 100644
--- a/gdbsupport/fileio.cc
+++ b/gdbsupport/fileio.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "fileio.h"
 #include <sys/stat.h>
 #include <fcntl.h>
diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc
index 9d3b417359b1..5c427e11b02a 100644
--- a/gdbsupport/filestuff.cc
+++ b/gdbsupport/filestuff.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "filestuff.h"
 #include "gdb_vecs.h"
 #include <fcntl.h>
diff --git a/gdbsupport/format.cc b/gdbsupport/format.cc
index 4e228a95ea87..12173eeba300 100644
--- a/gdbsupport/format.cc
+++ b/gdbsupport/format.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "format.h"
 
 format_pieces::format_pieces (const char **arg, bool gdb_extensions,
diff --git a/gdbsupport/gdb-dlfcn.cc b/gdbsupport/gdb-dlfcn.cc
index d8dbabd336de..1a8289ace742 100644
--- a/gdbsupport/gdb-dlfcn.cc
+++ b/gdbsupport/gdb-dlfcn.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdb-dlfcn.h"
 
 #ifdef HAVE_DLFCN_H
diff --git a/gdbsupport/gdb-hashtab.cc b/gdbsupport/gdb-hashtab.cc
index 7ef41cc332db..42f80faa403e 100644
--- a/gdbsupport/gdb-hashtab.cc
+++ b/gdbsupport/gdb-hashtab.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdb-hashtab.h"
 
 /* Allocation function for the libiberty hash table which uses an
diff --git a/gdbsupport/gdb_obstack.cc b/gdbsupport/gdb_obstack.cc
index 8bbd64fb6fae..f24b4fc998b5 100644
--- a/gdbsupport/gdb_obstack.cc
+++ b/gdbsupport/gdb_obstack.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdb_obstack.h"
 
 /* Concatenate NULL terminated variable argument list of `const char *'
diff --git a/gdbsupport/gdb_regex.cc b/gdbsupport/gdb_regex.cc
index 4c50c4fadef7..5570a1435c72 100644
--- a/gdbsupport/gdb_regex.cc
+++ b/gdbsupport/gdb_regex.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdb_regex.h"
 #include "gdbsupport/def-vector.h"
 
diff --git a/gdbsupport/gdb_tilde_expand.cc b/gdbsupport/gdb_tilde_expand.cc
index 8aa4fa02ec2c..4a0a5734ad86 100644
--- a/gdbsupport/gdb_tilde_expand.cc
+++ b/gdbsupport/gdb_tilde_expand.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include <algorithm>
 #include "filenames.h"
 #include "gdb_tilde_expand.h"
diff --git a/gdbsupport/gdb_vecs.cc b/gdbsupport/gdb_vecs.cc
index 8b7f4fb91463..71c730876d6e 100644
--- a/gdbsupport/gdb_vecs.cc
+++ b/gdbsupport/gdb_vecs.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdb_vecs.h"
 #include "host-defs.h"
 
diff --git a/gdbsupport/gdb_wait.cc b/gdbsupport/gdb_wait.cc
index 5c1c42495875..476861db2288 100644
--- a/gdbsupport/gdb_wait.cc
+++ b/gdbsupport/gdb_wait.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 
 #include "gdb_wait.h"
 
diff --git a/gdbsupport/job-control.cc b/gdbsupport/job-control.cc
index 7637cc5988f9..eff196dfdc85 100644
--- a/gdbsupport/job-control.cc
+++ b/gdbsupport/job-control.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "job-control.h"
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
diff --git a/gdbsupport/netstuff.cc b/gdbsupport/netstuff.cc
index af00f9cb8606..73f1d3b4dcb8 100644
--- a/gdbsupport/netstuff.cc
+++ b/gdbsupport/netstuff.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "netstuff.h"
 #include <algorithm>
 
diff --git a/gdbsupport/new-op.cc b/gdbsupport/new-op.cc
index 3d3fa999bf11..23ab0bb90aa9 100644
--- a/gdbsupport/new-op.cc
+++ b/gdbsupport/new-op.cc
@@ -23,7 +23,6 @@
 #endif
 
 #if !__has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__)
-#include "common-defs.h"
 #include "host-defs.h"
 #include <new>
 
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
index f40df1150e01..9c3816ccc630 100644
--- a/gdbsupport/pathstuff.cc
+++ b/gdbsupport/pathstuff.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "pathstuff.h"
 #include "host-defs.h"
 #include "filenames.h"
diff --git a/gdbsupport/print-utils.cc b/gdbsupport/print-utils.cc
index 1fdaf4d745a0..565a4791675f 100644
--- a/gdbsupport/print-utils.cc
+++ b/gdbsupport/print-utils.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "print-utils.h"
 /* Temporary storage using circular buffer.  */
 
diff --git a/gdbsupport/ptid.cc b/gdbsupport/ptid.cc
index 08866ef90e61..56daf92d4a9b 100644
--- a/gdbsupport/ptid.cc
+++ b/gdbsupport/ptid.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "ptid.h"
 #include "print-utils.h"
 
diff --git a/gdbsupport/rsp-low.cc b/gdbsupport/rsp-low.cc
index 37dce9d5c747..20f249f642d5 100644
--- a/gdbsupport/rsp-low.cc
+++ b/gdbsupport/rsp-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "rsp-low.h"
 
 /* See rsp-low.h.  */
diff --git a/gdbsupport/run-time-clock.cc b/gdbsupport/run-time-clock.cc
index 4e0f9802de2b..f754b03f0466 100644
--- a/gdbsupport/run-time-clock.cc
+++ b/gdbsupport/run-time-clock.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "run-time-clock.h"
 #if defined HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
diff --git a/gdbsupport/safe-strerror.cc b/gdbsupport/safe-strerror.cc
index 68899dfbdaad..54b3b857d4dc 100644
--- a/gdbsupport/safe-strerror.cc
+++ b/gdbsupport/safe-strerror.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include <string.h>
 
 /* There are two different versions of strerror_r; one is GNU-specific, the
diff --git a/gdbsupport/scoped_mmap.cc b/gdbsupport/scoped_mmap.cc
index 4f70ac65ec7c..c5c527b4fd4f 100644
--- a/gdbsupport/scoped_mmap.cc
+++ b/gdbsupport/scoped_mmap.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "scoped_mmap.h"
 #include "scoped_fd.h"
 #include "gdbsupport/filestuff.h"
diff --git a/gdbsupport/search.cc b/gdbsupport/search.cc
index 896aed5e6956..6c52643a4f3f 100644
--- a/gdbsupport/search.cc
+++ b/gdbsupport/search.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 
 #include "gdbsupport/search.h"
 #include "gdbsupport/byte-vector.h"
diff --git a/gdbsupport/selftest.cc b/gdbsupport/selftest.cc
index 1e6d07f287af..d3bed68038a9 100644
--- a/gdbsupport/selftest.cc
+++ b/gdbsupport/selftest.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "common-exceptions.h"
 #include "common-debug.h"
 #include "selftest.h"
diff --git a/gdbsupport/signals-state-save-restore.cc b/gdbsupport/signals-state-save-restore.cc
index 307e238307fb..60724f95c87e 100644
--- a/gdbsupport/signals-state-save-restore.cc
+++ b/gdbsupport/signals-state-save-restore.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "signals-state-save-restore.h"
 #include "gdbsupport/gdb-sigmask.h"
 
diff --git a/gdbsupport/signals.cc b/gdbsupport/signals.cc
index 782b4904f917..4989b3fc28bd 100644
--- a/gdbsupport/signals.cc
+++ b/gdbsupport/signals.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 
 #ifdef HAVE_SIGNAL_H
 #include <signal.h>
diff --git a/gdbsupport/task-group.cc b/gdbsupport/task-group.cc
index 6844d8594e3e..e29ed25e0d35 100644
--- a/gdbsupport/task-group.cc
+++ b/gdbsupport/task-group.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "task-group.h"
 #include "thread-pool.h"
 
diff --git a/gdbsupport/tdesc.cc b/gdbsupport/tdesc.cc
index 1ee3e1f7c2ec..080d39c485dc 100644
--- a/gdbsupport/tdesc.cc
+++ b/gdbsupport/tdesc.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdbsupport/tdesc.h"
 
 tdesc_reg::tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc
index 1b46b68e12ee..04a203444204 100644
--- a/gdbsupport/thread-pool.cc
+++ b/gdbsupport/thread-pool.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdbsupport/thread-pool.h"
 
 #if CXX_STD_THREAD
diff --git a/gdbsupport/xml-utils.cc b/gdbsupport/xml-utils.cc
index 0490f21d763c..b89204cdf510 100644
--- a/gdbsupport/xml-utils.cc
+++ b/gdbsupport/xml-utils.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "xml-utils.h"
 
 /* See xml-utils.h.  */
-- 
2.44.0


^ permalink raw reply	[relevance 1%]

* Re: [PATCH v2 2/2] remote.c: Make packet_ok return struct packet_result
  @ 2024-03-26  9:48  0%   ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-03-26  9:48 UTC (permalink / raw)
  To: Alexandra Hájková, gdb-patches; +Cc: ahajkova

Alexandra Hájková <ahajkova@khirnov.net> writes:

> From: Alexandra Hájková <ahajkova@redhat.com>
>
> This allows to print the error message stored in a packet_result
> to be easily used in the calling function.

This looks good.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


> ---
>  gdb/remote.c | 199 +++++++++++++++++++++++++--------------------------
>  1 file changed, 96 insertions(+), 103 deletions(-)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index 8462b7e4e60..95e193ba543 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -765,8 +765,8 @@ struct remote_features
>  
>  /* Check result value in BUF for packet WHICH_PACKET and update the packet's
>     support configuration accordingly.  */
> -  packet_status packet_ok (const char *buf, const int which_packet);
> -  packet_status packet_ok (const gdb::char_vector &buf, const int which_packet);
> +  packet_result packet_ok (const char *buf, const int which_packet);
> +  packet_result packet_ok (const gdb::char_vector &buf, const int which_packet);
>  
>    /* Configuration of a remote target's memory read packet.  */
>    memory_packet_config m_memory_read_packet_config;
> @@ -2503,7 +2503,7 @@ packet_check_result (const gdb::char_vector &buf, bool accept_msg)
>    return packet_check_result (buf.data (), accept_msg);
>  }
>  
> -packet_status
> +packet_result
>  remote_features::packet_ok (const char *buf, const int which_packet)
>  {
>    packet_config *config = &m_protocol_packets[which_packet];
> @@ -2549,10 +2549,10 @@ remote_features::packet_ok (const char *buf, const int which_packet)
>        break;
>      }
>  
> -  return result.status ();
> +  return result;
>  }
>  
> -packet_status
> +packet_result
>  remote_features::packet_ok (const gdb::char_vector &buf, const int which_packet)
>  {
>    return packet_ok (buf.data (), which_packet);
> @@ -2739,14 +2739,15 @@ remote_target::remote_query_attached (int pid)
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_qAttached))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_qAttached);
> +  switch (result.status())
>      {
>      case PACKET_OK:
>        if (strcmp (rs->buf.data (), "1") == 0)
>  	return 1;
>        break;
>      case PACKET_ERROR:
> -      warning (_("Remote failure reply: %s"), rs->buf.data ());
> +      warning (_("Remote failure reply: %s"), result.err_msg());
>        break;
>      case PACKET_UNKNOWN:
>        break;
> @@ -3051,7 +3052,6 @@ remote_target::set_syscall_catchpoint (int pid, bool needed, int any_count,
>  				       gdb::array_view<const int> syscall_counts)
>  {
>    const char *catch_packet;
> -  enum packet_status result;
>    int n_sysno = 0;
>  
>    if (m_features.packet_support (PACKET_QCatchSyscalls) == PACKET_DISABLE)
> @@ -3107,8 +3107,8 @@ remote_target::set_syscall_catchpoint (int pid, bool needed, int any_count,
>  
>    putpkt (catch_packet);
>    getpkt (&rs->buf);
> -  result = m_features.packet_ok (rs->buf, PACKET_QCatchSyscalls);
> -  if (result == PACKET_OK)
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_QCatchSyscalls);
> +  if (result.status() == PACKET_OK)
>      return 0;
>    else
>      return -1;
> @@ -5113,7 +5113,8 @@ remote_target::start_remote_1 (int from_tty, int extended_p)
>      {
>        putpkt ("QStartNoAckMode");
>        getpkt (&rs->buf);
> -      if (m_features.packet_ok (rs->buf, PACKET_QStartNoAckMode) == PACKET_OK)
> +      if ((m_features.packet_ok (rs->buf, PACKET_QStartNoAckMode)).status ()
> +	  == PACKET_OK)
>  	rs->noack_mode = 1;
>      }
>  
> @@ -5898,9 +5899,10 @@ remote_target::remote_query_supported ()
>  
>        /* If an error occurred, warn, but do not return - just reset the
>  	 buffer to empty and go on to disable features.  */
> -      if (m_features.packet_ok (rs->buf, PACKET_qSupported) == PACKET_ERROR)
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_qSupported);
> +      if (result.status () == PACKET_ERROR)
>  	{
> -	  warning (_("Remote failure reply: %s"), rs->buf.data ());
> +	  warning (_("Remote failure reply: %s"), result.err_msg ());
>  	  rs->buf[0] = 0;
>  	}
>      }
> @@ -6552,7 +6554,8 @@ extended_remote_target::attach (const char *args, int from_tty)
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_vAttach))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_vAttach);
> +  switch (result.status ())
>      {
>      case PACKET_OK:
>        if (!target_is_non_stop_p ())
> @@ -6568,9 +6571,9 @@ extended_remote_target::attach (const char *args, int from_tty)
>        break;
>      case PACKET_UNKNOWN:
>        error (_("This target does not support attaching to a process"));
> -    default:
> -      error (_("Attaching to %s failed"),
> -	     target_pid_to_str (ptid_t (pid)).c_str ());
> +    case PACKET_ERROR:
> +      error (_("Attaching to %s failed: %s"),
> +	     target_pid_to_str (ptid_t (pid)).c_str (), result.err_msg ());
>      }
>  
>    switch_to_inferior_no_thread (remote_add_inferior (false, pid, 1, 0));
> @@ -7493,14 +7496,15 @@ remote_target::remote_interrupt_ns ()
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_vCtrlC))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_vCtrlC);
> +  switch (result.status ())
>      {
>      case PACKET_OK:
>        break;
>      case PACKET_UNKNOWN:
>        error (_("No support for interrupting the remote target."));
>      case PACKET_ERROR:
> -      error (_("Interrupting target failed: %s"), rs->buf.data ());
> +      error (_("Interrupting target failed: %s"), result.err_msg ());
>      }
>  }
>  
> @@ -8796,7 +8800,8 @@ remote_target::fetch_register_using_p (struct regcache *regcache,
>  
>    buf = rs->buf.data ();
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_p))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_p);
> +  switch (result.status ())
>      {
>      case PACKET_OK:
>        break;
> @@ -8805,7 +8810,7 @@ remote_target::fetch_register_using_p (struct regcache *regcache,
>      case PACKET_ERROR:
>        error (_("Could not fetch register \"%s\"; remote failure reply '%s'"),
>  	     gdbarch_register_name (regcache->arch (), reg->regnum),
> -	     buf);
> +	     result.err_msg ());
>      }
>  
>    /* If this register is unfetchable, tell the regcache.  */
> @@ -9102,13 +9107,14 @@ remote_target::store_register_using_P (const struct regcache *regcache,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_P))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_P);
> +  switch (result.status ())
>      {
>      case PACKET_OK:
>        return 1;
>      case PACKET_ERROR:
>        error (_("Could not write register \"%s\"; remote failure reply '%s'"),
> -	     gdbarch_register_name (gdbarch, reg->regnum), rs->buf.data ());
> +	     gdbarch_register_name (gdbarch, reg->regnum), result.err_msg ());
>      case PACKET_UNKNOWN:
>        return 0;
>      default:
> @@ -10539,7 +10545,7 @@ remote_target::remote_vkill (int pid)
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_vKill))
> +  switch ((m_features.packet_ok (rs->buf, PACKET_vKill)).status ())
>      {
>      case PACKET_OK:
>        return 0;
> @@ -10695,7 +10701,7 @@ remote_target::extended_remote_run (const std::string &args)
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_vRun))
> +  switch ((m_features.packet_ok (rs->buf, PACKET_vRun)).status ())
>      {
>      case PACKET_OK:
>        /* We have a wait response.  All is well.  */
> @@ -10802,11 +10808,14 @@ remote_target::extended_remote_set_inferior_cwd ()
>  
>        putpkt (rs->buf);
>        getpkt (&rs->buf);
> -      if (m_features.packet_ok (rs->buf, PACKET_QSetWorkingDir) != PACKET_OK)
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_QSetWorkingDir);
> +      if (result.status () == PACKET_ERROR)
>  	error (_("\
>  Remote replied unexpectedly while setting the inferior's working\n\
>  directory: %s"),
> -	       rs->buf.data ());
> +	       result.err_msg ());
> +      if (result.status () == PACKET_UNKNOWN)
> +	error (_("Remote target failed to process setting the inferior's working directory"));
>  
>      }
>  }
> @@ -10975,7 +10984,7 @@ remote_target::insert_breakpoint (struct gdbarch *gdbarch,
>        putpkt (rs->buf);
>        getpkt (&rs->buf);
>  
> -      switch (m_features.packet_ok (rs->buf, PACKET_Z0))
> +      switch ((m_features.packet_ok (rs->buf, PACKET_Z0)).status ())
>  	{
>  	case PACKET_ERROR:
>  	  return -1;
> @@ -11076,8 +11085,8 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
> -					  + to_underlying (packet))))
> +  switch ((m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
> +					  + to_underlying (packet)))).status ())
>      {
>      case PACKET_ERROR:
>        return -1;
> @@ -11125,8 +11134,8 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
> -					  + to_underlying (packet))))
> +  switch ((m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
> +					  + to_underlying (packet)))).status ())
>      {
>      case PACKET_ERROR:
>      case PACKET_UNKNOWN:
> @@ -11257,7 +11266,6 @@ remote_target::insert_hw_breakpoint (struct gdbarch *gdbarch,
>    CORE_ADDR addr = bp_tgt->reqstd_address;
>    struct remote_state *rs;
>    char *p, *endbuf;
> -  char *message;
>  
>    if (m_features.packet_support (PACKET_Z1) == PACKET_DISABLE)
>      return -1;
> @@ -11288,16 +11296,11 @@ remote_target::insert_hw_breakpoint (struct gdbarch *gdbarch,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_Z1))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_Z1);
> +  switch (result.status ())
>      {
>      case PACKET_ERROR:
> -      if (rs->buf[1] == '.')
> -	{
> -	  message = strchr (&rs->buf[2], '.');
> -	  if (message)
> -	    error (_("Remote failure reply: %s"), message + 1);
> -	}
> -      return -1;
> +      error (_("Remote failure reply: %s"), result.err_msg ());
>      case PACKET_UNKNOWN:
>        return -1;
>      case PACKET_OK:
> @@ -11335,7 +11338,7 @@ remote_target::remove_hw_breakpoint (struct gdbarch *gdbarch,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_Z1))
> +  switch ((m_features.packet_ok (rs->buf, PACKET_Z1)).status ())
>      {
>      case PACKET_ERROR:
>      case PACKET_UNKNOWN:
> @@ -11376,7 +11379,7 @@ remote_target::verify_memory (const gdb_byte *data, CORE_ADDR lma, ULONGEST size
>  
>        getpkt (&rs->buf);
>  
> -      status = m_features.packet_ok (rs->buf, PACKET_qCRC);
> +      status = (m_features.packet_ok (rs->buf, PACKET_qCRC)).status ();
>        if (status == PACKET_ERROR)
>  	return -1;
>        else if (status == PACKET_OK)
> @@ -11498,7 +11501,7 @@ remote_target::remote_write_qxfer (const char *object_name,
>  
>    if (putpkt_binary (rs->buf.data (), i + buf_len) < 0
>        || getpkt (&rs->buf) < 0
> -      || m_features.packet_ok (rs->buf, which_packet) != PACKET_OK)
> +      || (m_features.packet_ok (rs->buf, which_packet)).status () != PACKET_OK)
>      return TARGET_XFER_E_IO;
>  
>    unpack_varlen_hex (rs->buf.data (), &n);
> @@ -11563,7 +11566,7 @@ remote_target::remote_read_qxfer (const char *object_name,
>    rs->buf[0] = '\0';
>    packet_len = getpkt (&rs->buf);
>    if (packet_len < 0
> -      || m_features.packet_ok (rs->buf, which_packet) != PACKET_OK)
> +      || (m_features.packet_ok (rs->buf, which_packet)).status () != PACKET_OK)
>      return TARGET_XFER_E_IO;
>  
>    if (rs->buf[0] != 'l' && rs->buf[0] != 'm')
> @@ -11868,7 +11871,8 @@ remote_target::search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
>  
>    if (putpkt_binary (rs->buf.data (), i + escaped_pattern_len) < 0
>        || getpkt (&rs->buf) < 0
> -      || m_features.packet_ok (rs->buf, PACKET_qSearch_memory) != PACKET_OK)
> +      || (m_features.packet_ok (rs->buf, PACKET_qSearch_memory)).status ()
> +      != PACKET_OK)
>      {
>        /* The request may not have worked because the command is not
>  	 supported.  If so, fall back to the simple way.  */
> @@ -12261,7 +12265,6 @@ remote_target::get_thread_local_address (ptid_t ptid, CORE_ADDR lm,
>        struct remote_state *rs = get_remote_state ();
>        char *p = rs->buf.data ();
>        char *endp = p + get_remote_packet_size ();
> -      enum packet_status result;
>  
>        strcpy (p, "qGetTLSAddr:");
>        p += strlen (p);
> @@ -12274,15 +12277,15 @@ remote_target::get_thread_local_address (ptid_t ptid, CORE_ADDR lm,
>  
>        putpkt (rs->buf);
>        getpkt (&rs->buf);
> -      result = m_features.packet_ok (rs->buf, PACKET_qGetTLSAddr);
> -      if (result == PACKET_OK)
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_qGetTLSAddr);
> +      if (result.status () == PACKET_OK)
>  	{
>  	  ULONGEST addr;
>  
>  	  unpack_varlen_hex (rs->buf.data (), &addr);
>  	  return addr;
>  	}
> -      else if (result == PACKET_UNKNOWN)
> +      else if (result.status () == PACKET_UNKNOWN)
>  	throw_error (TLS_GENERIC_ERROR,
>  		     _("Remote target doesn't support qGetTLSAddr packet"));
>        else
> @@ -12307,7 +12310,6 @@ remote_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr)
>        struct remote_state *rs = get_remote_state ();
>        char *p = rs->buf.data ();
>        char *endp = p + get_remote_packet_size ();
> -      enum packet_status result;
>  
>        strcpy (p, "qGetTIBAddr:");
>        p += strlen (p);
> @@ -12316,8 +12318,8 @@ remote_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr)
>  
>        putpkt (rs->buf);
>        getpkt (&rs->buf);
> -      result = m_features.packet_ok (rs->buf, PACKET_qGetTIBAddr);
> -      if (result == PACKET_OK)
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_qGetTIBAddr);
> +      if (result.status () == PACKET_OK)
>  	{
>  	  ULONGEST val;
>  	  unpack_varlen_hex (rs->buf.data (), &val);
> @@ -12325,10 +12327,11 @@ remote_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr)
>  	    *addr = (CORE_ADDR) val;
>  	  return true;
>  	}
> -      else if (result == PACKET_UNKNOWN)
> +      else if (result.status () == PACKET_UNKNOWN)
>  	error (_("Remote target doesn't support qGetTIBAddr packet"));
>        else
> -	error (_("Remote target failed to process qGetTIBAddr request"));
> +	error (_("Remote target failed to process qGetTIBAddr request, %s"),
> +		 result.err_msg ());
>      }
>    else
>      error (_("qGetTIBAddr not supported or disabled on this target"));
> @@ -12584,7 +12587,7 @@ remote_target::remote_hostio_send_command (int command_bytes, int which_packet,
>        return -1;
>      }
>  
> -  switch (m_features.packet_ok (rs->buf, which_packet))
> +  switch ((m_features.packet_ok (rs->buf, which_packet)).status ())
>      {
>      case PACKET_ERROR:
>        *remote_errno = FILEIO_EINVAL;
> @@ -13872,7 +13875,6 @@ remote_target::get_trace_status (struct trace_status *ts)
>  {
>    /* Initialize it just to avoid a GCC false warning.  */
>    char *p = NULL;
> -  enum packet_status result;
>    struct remote_state *rs = get_remote_state ();
>  
>    if (m_features.packet_support (PACKET_qTStatus) == PACKET_DISABLE)
> @@ -13898,11 +13900,16 @@ remote_target::get_trace_status (struct trace_status *ts)
>        throw;
>      }
>  
> -  result = m_features.packet_ok (p, PACKET_qTStatus);
> +  packet_result result = m_features.packet_ok (p, PACKET_qTStatus);
>  
> -  /* If the remote target doesn't do tracing, flag it.  */
> -  if (result == PACKET_UNKNOWN)
> -    return -1;
> +  switch (result.status ())
> +    {
> +    case PACKET_ERROR:
> +      error (_("Remote failure reply: %s"), result.err_msg ());
> +    /* If the remote target doesn't do tracing, flag it.  */
> +    case PACKET_UNKNOWN:
> +      return -1;
> +    }
>  
>    /* We're working with a live target.  */
>    ts->filename = NULL;
> @@ -14252,7 +14259,6 @@ remote_target::set_trace_buffer_size (LONGEST val)
>        struct remote_state *rs = get_remote_state ();
>        char *buf = rs->buf.data ();
>        char *endbuf = buf + get_remote_packet_size ();
> -      enum packet_status result;
>  
>        gdb_assert (val >= 0 || val == -1);
>        buf += xsnprintf (buf, endbuf - buf, "QTBuffer:size:");
> @@ -14267,10 +14273,15 @@ remote_target::set_trace_buffer_size (LONGEST val)
>  
>        putpkt (rs->buf);
>        remote_get_noisy_reply ();
> -      result = m_features.packet_ok (rs->buf, PACKET_QTBuffer_size);
> -
> -      if (result != PACKET_OK)
> -	warning (_("Bogus reply from target: %s"), rs->buf.data ());
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_QTBuffer_size);
> +      switch (result.status ())
> +	{
> +	case PACKET_ERROR:
> +	  warning (_("Bogus reply from target: %s"), result.err_msg ());
> +	  break;
> +	case PACKET_UNKNOWN:
> +	  warning (_("Remote target failed to process the request "));
> +	}
>      }
>  }
>  
> @@ -14696,14 +14707,9 @@ remote_target::btrace_sync_conf (const btrace_config *conf)
>        putpkt (buf);
>        getpkt (&rs->buf);
>  
> -      if (m_features.packet_ok (buf, PACKET_Qbtrace_conf_bts_size)
> -	  == PACKET_ERROR)
> -	{
> -	  if (buf[0] == 'E' && buf[1] == '.')
> -	    error (_("Failed to configure the BTS buffer size: %s"), buf + 2);
> -	  else
> -	    error (_("Failed to configure the BTS buffer size."));
> -	}
> +      packet_result result = m_features.packet_ok (buf, PACKET_Qbtrace_conf_bts_size);
> +      if (result.status () == PACKET_ERROR)
> +	error (_("Failed to configure the BTS buffer size: %s"), result.err_msg ());
>  
>        rs->btrace_config.bts.size = conf->bts.size;
>      }
> @@ -14719,14 +14725,9 @@ remote_target::btrace_sync_conf (const btrace_config *conf)
>        putpkt (buf);
>        getpkt (&rs->buf);
>  
> -      if (m_features.packet_ok (buf, PACKET_Qbtrace_conf_pt_size)
> -	  == PACKET_ERROR)
> -	{
> -	  if (buf[0] == 'E' && buf[1] == '.')
> -	    error (_("Failed to configure the trace buffer size: %s"), buf + 2);
> -	  else
> -	    error (_("Failed to configure the trace buffer size."));
> -	}
> +      packet_result result = m_features.packet_ok (buf, PACKET_Qbtrace_conf_pt_size);
> +      if (result.status () == PACKET_ERROR)
> +	error (_("Failed to configure the trace buffer size: %s"), result.err_msg ());
>  
>        rs->btrace_config.pt.size = conf->pt.size;
>      }
> @@ -14841,15 +14842,10 @@ remote_target::enable_btrace (thread_info *tp,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  if (m_features.packet_ok (rs->buf, which_packet) == PACKET_ERROR)
> -    {
> -      if (rs->buf[0] == 'E' && rs->buf[1] == '.')
> -	error (_("Could not enable branch tracing for %s: %s"),
> -	       target_pid_to_str (ptid).c_str (), &rs->buf[2]);
> -      else
> -	error (_("Could not enable branch tracing for %s."),
> -	       target_pid_to_str (ptid).c_str ());
> -    }
> +  packet_result result = m_features.packet_ok (rs->buf, which_packet);
> +  if (result.status () == PACKET_ERROR)
> +    error (_("Could not enable branch tracing for %s: %s"),
> +	   target_pid_to_str (ptid).c_str (), result.err_msg ());
>  
>    btrace_target_info *tinfo = new btrace_target_info { ptid };
>  
> @@ -14887,15 +14883,10 @@ remote_target::disable_btrace (struct btrace_target_info *tinfo)
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  if (m_features.packet_ok (rs->buf, PACKET_Qbtrace_off) == PACKET_ERROR)
> -    {
> -      if (rs->buf[0] == 'E' && rs->buf[1] == '.')
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_Qbtrace_off);
> +  if (result.status () == PACKET_ERROR)
>  	error (_("Could not disable branch tracing for %s: %s"),
> -	       target_pid_to_str (tinfo->ptid).c_str (), &rs->buf[2]);
> -      else
> -	error (_("Could not disable branch tracing for %s."),
> -	       target_pid_to_str (tinfo->ptid).c_str ());
> -    }
> +	       target_pid_to_str (tinfo->ptid).c_str (), result.err_msg ());
>  
>    delete tinfo;
>  }
> @@ -15160,7 +15151,8 @@ remote_target::thread_events (int enable)
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_QThreadEvents))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_QThreadEvents);
> +  switch (result.status ())
>      {
>      case PACKET_OK:
>        if (strcmp (rs->buf.data (), "OK") != 0)
> @@ -15168,7 +15160,7 @@ remote_target::thread_events (int enable)
>        rs->last_thread_events = enable;
>        break;
>      case PACKET_ERROR:
> -      warning (_("Remote failure reply: %s"), rs->buf.data ());
> +      warning (_("Remote failure reply: %s"), result.err_msg ());
>        break;
>      case PACKET_UNKNOWN:
>        break;
> @@ -15215,14 +15207,15 @@ remote_target::commit_requested_thread_options ()
>        putpkt (rs->buf);
>        getpkt (&rs->buf, 0);
>  
> -      switch (m_features.packet_ok (rs->buf, PACKET_QThreadOptions))
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_QThreadOptions);
> +      switch (result.status ())
>  	{
>  	case PACKET_OK:
>  	  if (strcmp (rs->buf.data (), "OK") != 0)
>  	    error (_("Remote refused setting thread options: %s"), rs->buf.data ());
>  	  break;
>  	case PACKET_ERROR:
> -	  error (_("Remote failure reply: %s"), rs->buf.data ());
> +	  error (_("Remote failure reply: %s"), result.err_msg ());
>  	case PACKET_UNKNOWN:
>  	  gdb_assert_not_reached ("PACKET_UNKNOWN");
>  	  break;
> -- 
> 2.44.0


^ permalink raw reply	[relevance 0%]

* [PATCH] [gdb/testsuite] Fix gdb.ada/tagged-lookup.exp with gcc <= 12
@ 2024-03-25 14:05  5% Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-03-25 14:05 UTC (permalink / raw)
  To: gdb-patches

With gcc 13, test-case gdb.ada/tagged-lookup.exp passes for me, but with gcc
12, I get:
...
(gdb) set debug symtab-create 1^M
(gdb) print *the_local_var^M
  ...
$1 = (n => 2)^M
(gdb) FAIL: gdb.ada/tagged-lookup.exp: only one CU expanded
...

The problem is that this fails:
...
    -re -wrap ".* = \\\(n => $decimal\\\)" {
	if {$found_pck + $found_pck2 == 1} {
	    pass $gdb_test_name
	} else {
	    fail $gdb_test_name
	}
...
because $found_pck == 0 and $found_pck2 == 0.

Indeed, with gcc 13 we have:
...
$ grep "start_subfile: name = .*/tagged-lookup/" gdb.log | sed 's%.*/%%'
b~foo.adb
b~foo.adb
b~foo.adb
b~foo.ads
pck2.adb
pck2.adb
pck2.ads
pck2.adb
pck2.ads
...
and with gcc 12:
...
$ grep "start_subfile: name = .*/tagged-lookup/" gdb.log | sed 's%.*/%%'
b~foo.adb
b~foo.adb
b~foo.adb
b~foo.ads
...

Fix this by checking for "$found_pck + $found_pck2 <= 1" instead.

Tested on x86_64-linux.

PR testsuite/31514
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31514
---
 gdb/testsuite/gdb.ada/tagged-lookup.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.ada/tagged-lookup.exp b/gdb/testsuite/gdb.ada/tagged-lookup.exp
index 4bc088ba8d5..3803319c505 100644
--- a/gdb/testsuite/gdb.ada/tagged-lookup.exp
+++ b/gdb/testsuite/gdb.ada/tagged-lookup.exp
@@ -52,7 +52,7 @@ gdb_test_multiple "print *the_local_var" "only one CU expanded" -lbl {
 	exp_continue
     }
     -re -wrap ".* = \\\(n => $decimal\\\)" {
-	if {$found_pck + $found_pck2 == 1} {
+	if {$found_pck + $found_pck2 <= 1} {
 	    pass $gdb_test_name
 	} else {
 	    fail $gdb_test_name

base-commit: 61ced226a4fc2e6df7836cd9c0f7e1ad47af2440
-- 
2.35.3


^ permalink raw reply	[relevance 5%]

* [PATCH] Make source.c:search_command_helper use source cache
@ 2024-03-24  1:18  3% Will Hawkins
  0 siblings, 0 replies; 200+ results
From: Will Hawkins @ 2024-03-24  1:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: Will Hawkins

The current implementation of search_command_helper accesses the line
offsets of the current program spaces's source code through
the source cache but then accesses its contents through the disk. This
PR updates the implementation so that the access of the contents is also
through the source cache.

Tested on x86_64-redhat-linux.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
---

Notes:
    Rationale:
    
    Supporting access through the source cache during searching will make it
    easier to implement the embedded source functionality of DW_LNCT_source.

 gdb/source.c | 87 +++++++++++++++++++++++++++-------------------------
 1 file changed, 46 insertions(+), 41 deletions(-)

diff --git a/gdb/source.c b/gdb/source.c
index bbeb4154258..81432c7b527 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1617,46 +1617,53 @@ search_command_helper (const char *regex, int from_tty, bool forward)
   if (!source_open)
     error (_("source code access disabled"));
 
-  scoped_fd desc (open_source_file (loc->symtab ()));
-  if (desc.get () < 0)
-    perror_with_name (symtab_to_filename_for_display (loc->symtab ()),
-		      -desc.get ());
-
-  int line = (forward
-	      ? last_line_listed + 1
-	      : last_line_listed - 1);
-
   const std::vector<off_t> *offsets;
-  if (line < 1
-      || !g_source_cache.get_line_charpos (loc->symtab (), &offsets)
-      || line > offsets->size ())
+  if (!g_source_cache.get_line_charpos (loc->symtab (), &offsets))
     error (_("Expression not found"));
 
-  if (lseek (desc.get (), (*offsets)[line - 1], 0) < 0)
-    perror_with_name (symtab_to_filename_for_display (loc->symtab ()));
+  std::string lines;
+  if (!g_source_cache.get_source_lines (loc->symtab (), 1, offsets->size (),
+					&lines))
+    perror_with_name (symtab_to_filename_for_display (loc->symtab ()), -ENOENT);
+
+  int line_no = (forward
+		 ? last_line_listed + 1
+		 : last_line_listed - 1);
 
-  gdb_file_up stream = desc.to_file (FDOPEN_MODE);
-  clearerr (stream.get ());
+  if (line_no < 1
+      || line_no > offsets->size ())
+    error (_("Expression not found"));
+
+  size_t current_line_start = (*offsets)[line_no - 1];
 
-  gdb::def_vector<char> buf;
-  buf.reserve (256);
+  std::string buf;
 
   while (1)
     {
-      buf.resize (0);
-
-      int c = fgetc (stream.get ());
-      if (c == EOF)
+      /* Invariant: current_line_start is either the index
+	 of the start of the current line in LINES *or* the
+	 length of the source code (LINES, when there is nothing
+	 else to do).  */
+      if (current_line_start == lines.length ())
 	break;
-      do
-	{
-	  buf.push_back (c);
-	}
-      while (c != '\n' && (c = fgetc (stream.get ())) >= 0);
+
+      size_t current_line_end = ((line_no + 1) > offsets->size ()
+				 ? lines.size () - 1
+				 : (*offsets)[line_no] - 1);
+
+      size_t sz = current_line_end - current_line_start;
+      buf = lines.substr (current_line_start, sz);
+#if 0
+      gdb_printf (_("sz: %lu\n"), sz);
+      gdb_printf (_("line: %d\n"), line);
+      gdb_printf (_("current_line_start: %lu\n"), current_line_start);
+      gdb_printf (_("current_line_end: %lu\n"), current_line_end);
+      gdb_printf (_("lines.size (): %lu\n"), lines.size ());
+      gdb_printf (_("buf: -%s-\n"), buf.data ());
+#endif
 
       /* Remove the \r, if any, at the end of the line, otherwise
 	 regular expressions that end with $ or \n won't work.  */
-      size_t sz = buf.size ();
       if (sz >= 2 && buf[sz - 2] == '\r')
 	{
 	  buf[sz - 2] = '\n';
@@ -1664,29 +1671,27 @@ search_command_helper (const char *regex, int from_tty, bool forward)
 	}
 
       /* We now have a source line in buf, null terminate and match.  */
-      buf.push_back ('\0');
+      buf += '\0';
       if (re_exec (buf.data ()) > 0)
 	{
 	  /* Match!  */
-	  print_source_lines (loc->symtab (), line, line + 1, 0);
-	  set_internalvar_integer (lookup_internalvar ("_"), line);
-	  loc->set (loc->symtab (), std::max (line - lines_to_list / 2, 1));
+	  print_source_lines (loc->symtab (), line_no, line_no + 1, 0);
+	  set_internalvar_integer (lookup_internalvar ("_"), line_no);
+	  loc->set (loc->symtab (), std::max (line_no - lines_to_list / 2, 1));
 	  return;
 	}
 
       if (forward)
-	line++;
+	{
+	  line_no++;
+	  current_line_start = current_line_end + 1;
+	}
       else
 	{
-	  line--;
-	  if (line < 1)
+	  line_no--;
+	  if (line_no < 1)
 	    break;
-	  if (fseek (stream.get (), (*offsets)[line - 1], 0) < 0)
-	    {
-	      const char *filename
-		= symtab_to_filename_for_display (loc->symtab ());
-	      perror_with_name (filename);
-	    }
+	  current_line_start = (*offsets)[line_no - 1];
 	}
     }
 
-- 
2.44.0


^ permalink raw reply	[relevance 3%]

* [PATCH 1/2] Make linux checkpoints work with multiple inferiors
  @ 2024-03-23 20:27 10% ` Kevin Buettner
  0 siblings, 0 replies; 200+ results
From: Kevin Buettner @ 2024-03-23 20:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner

The current linux checkpoint code, most of which may be found in
linux-fork.c, is quite broken when attempting to use more than
one inferior.  Running GDB will show internal errors when starting
two inferiors, placing a checkpoint in one, then switching to
the other and doing one of the following commands, "restart",
"detach", "kill", or continue (to program exit).  Test cases
for two of those scenarios may be found in the bug:

    https://sourceware.org/bugzilla/show_bug.cgi?id=31065

I've tested for each of the scenarios and many more in the new
test case: gdb.multi/checkpoint-multi.exp.

I started off with the goal of fixing just those problems, and was
mostly successful with a much smaller patch, but doing "info
checkpoints" with more than one inferior didn't work correctly due to
some of the inferiors being in the wrong program space.  So I decided
to do the right thing and make the linux-fork code inferior aware.

Prior to this commit, the list of forks was being maintained in a
global named named 'fork_list'.  I turned this into a per-inferior
data structure.  There is now a registry key named
'checkpoint_inferior_data_key' along with a new function named
'get_checkpoint_inferior_data', but it is only called by a new
function named 'get_fork_list'.  In all functions where the global
'fork_list' was previously accessed directly, a local named
'fork_list' is used instead.  In each of those functions, it is
declared and initialized like this:

    auto &fork_list = get_fork_list (inf);

In some cases, except for the addition of an additional
'inferior *inf' parameter, the rest of the function stays the same.

The constructor for 'struct fork_info' has gained an additional
parameter.  In addition to passing the pid of the new fork, we now
also pass the fork identifier, fork_num, to the constructor.  This
integer is shown to the user in the "info checkpoints" command and
is provided by the user in commands which manipulate checkpoints,
i.e. 'restart' and 'delete checkpoint'.

Adding the 'fork_num' parameter to the constructor simplified some of
the initialization when making a new checkpoint.  In particular, code
in add_fork() which initialized the static global highest_fork_num to
0 when there was only one fork has been removed.  Instead,
highest_fork_num now starts at -1.  When creating a checkpoint for an
inferior for which no checkpoints currently exist,
checkpoint_command() will now allocate what used to always be the
zeroeth fork number early on.  (This was done to preserve the existing
behavior of having lower numbered entries appear in the checkpoint
list first.  A fork number '0' will even still appear when the first
checkpoint is created.) Later on in checkpoint_command, the
start-of-list entry is added using the checkpoint number allocated
earlier in the function.

The old code was set up so that fork numbers would be reused if all
checkpoints were deleted and then new checkpoints were created.  That
no longer happens - checkpoint numbers are no longer reused.  There is
more than one precedent for not reusing identifiers in GDB, e.g.
breakpoint numbers aren't reused when one is deleted; the same is true
for inferior numbers.  Does this require a documentation change?  I
think not since the manual makes no mention of this behavior.

The functions find_fork_ptid, find_fork_id, and find_fork_pid
used to return a pointer to a fork_info struct.  Each of these
now return a pair consisting of the pointer to a fork_info struct
in addition to a pointer to the inferior containing that checkpoint.
Each of these functions now has at least one call where it is
necessary to have access to both the fork_info struct as well as
the inferior to which it applies.

info_checkpoints_command used to simply iterate over the list of
forks (checkpoints), printing each one out.  It now needs to iterate
over all inferiors and, for those which have checkpoints, it needs
to iterate over the list of checkpoints in that inferior.  This
command prints out a '*' preceding the currently active checkpoint.
That's still the case, but it'll now also print out a '+' preceding
the current checkpoint in non-current inferiors.  E.g...

    (gdb) info checkpoints
    + 4 process 8996 (main process) at 0x401199, file hello.c, line 51
      5 process 9004 at 0x401199, file hello.c, line 51
      1 process 9001 (main process) at 0x401258, file goodbye.c, line 62
    + 6 process 9005 at 0x401258, file goodbye.c, line 62
    * 7 process 9006 (main process) at 0x40115c, file hangout.c, line 31
      9 process 9008 at 0x40115c, file hangout.c, line 31

This shows checkpoints in three inferiors.  Fork #7 is the active one
in the current inferior, while #4, and #6 are the active forks in the
other two inferiors.  I haven't updated the documentation since it
didn't mention this behavior in the first place.

linux_fork_context, called by restart_command, now contains code to
switch inferiors when the fork being restarted is in a different
inferior from the current one.  The scoped_switch_fork_info class now
also contains code for switching inferiors in both the constructor and
destructor.

gdb/linux-nat.c has a few changes.  All but one of them are related
to passing the inferior to one of the linux-fork functions.  But
one of the tests in linux_nat_target::detach has also changed in
a non-obvious way.  In attempting to determine whether to call
linux_fork_detach(), that code used to do:

  if (pid == inferior_ptid.pid () && forks_exist_p ())

It's been simplified to:

  if (forks_exist_p (inf))

I had added the 'pid == inferior_ptid.pid ()' condition in late 2023
while working on a detach bug.  It was kind of a hack to prevent
calling linux_fork_detach() when in a different inferior.  That's no
longer needed since the call to forks_exist_p does this directly -
i.e. it is now inferior-aware.

Finally, the header file 'linux-fork.h' has been updated to reflect
the fact that add_fork, linux_fork_killall, linux_fork_mourn_inferior,
linux_fork_detach, and forks_exist_p all now require that a pointer to
an inferior be passed to these functions.  Additionally (as mentioned
earlier), find_fork_pid now returns std::pair<fork_info *, inferior *>
instead 'of fork_info *'.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31065
---
 gdb/linux-fork.c                             | 361 ++++++----
 gdb/linux-fork.h                             |  13 +-
 gdb/linux-nat.c                              |  20 +-
 gdb/testsuite/gdb.multi/checkpoint-multi.exp | 668 +++++++++++++++++++
 4 files changed, 922 insertions(+), 140 deletions(-)
 create mode 100644 gdb/testsuite/gdb.multi/checkpoint-multi.exp

diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 0d92d61f0d2..8e066341b63 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -29,6 +29,7 @@
 #include "linux-nat.h"
 #include "gdbthread.h"
 #include "source.h"
+#include "progspace-and-thread.h"
 
 #include "nat/gdb_ptrace.h"
 #include "gdbsupport/gdb_wait.h"
@@ -38,11 +39,14 @@
 
 #include <list>
 
+/* Most recently assigned fork number.  Fork numbers are never reused.  */
+static int highest_fork_num = -1;
+
 /* Fork list data structure:  */
 struct fork_info
 {
-  explicit fork_info (pid_t pid)
-    : ptid (pid, pid)
+  explicit fork_info (pid_t pid, int fork_num)
+    : ptid (pid, pid), num (fork_num)
   {
   }
 
@@ -70,7 +74,7 @@ struct fork_info
   ptid_t parent_ptid = null_ptid;
 
   /* Convenient handle (GDB fork id).  */
-  int num = 0;
+  int num;
 
   /* Convenient for info fork, saves having to actually switch
      contexts.  */
@@ -84,22 +88,56 @@ struct fork_info
   int maxfd = 0;
 };
 
-static std::list<fork_info> fork_list;
-static int highest_fork_num;
+struct checkpoint_inferior_data
+{
+  std::list<fork_info> fork_list;
+};
+
+/* Per-inferior data key.  */
+
+static const registry<inferior>::key<checkpoint_inferior_data>
+  checkpoint_inferior_data_key;
+
+/* Fetch per-inferior checkpoint data.  It always returns a valid pointer
+   to a checkpoint_inferior_info struct.  */
+
+static struct checkpoint_inferior_data *
+get_checkpoint_inferior_data (struct inferior *inf)
+{
+  struct checkpoint_inferior_data *data;
+
+  data = checkpoint_inferior_data_key.get (inf);
+  if (data == nullptr)
+    data = checkpoint_inferior_data_key.emplace (inf);
+
+  return data;
+}
+
+/* Return a reference to the per-inferior fork list.  */
+
+static std::list<fork_info> &
+get_fork_list (inferior *inf)
+{
+  return get_checkpoint_inferior_data (inf)->fork_list;
+}
 
 /* Fork list methods:  */
 
 int
-forks_exist_p (void)
+forks_exist_p (inferior *inf)
 {
+  auto &fork_list = get_fork_list (inf);
+
   return !fork_list.empty ();
 }
 
 /* Return the last fork in the list.  */
 
 static struct fork_info *
-find_last_fork (void)
+find_last_fork (inferior *inf)
 {
+  auto &fork_list = get_fork_list (inf);
+
   if (fork_list.empty ())
     return NULL;
 
@@ -109,30 +147,29 @@ find_last_fork (void)
 /* Return true iff there's one fork in the list.  */
 
 static bool
-one_fork_p ()
+one_fork_p (inferior *inf)
 {
+  auto &fork_list = get_fork_list (inf);
+
   return fork_list.size () == 1;
 }
 
 /* Add a new fork to the internal fork list.  */
 
 void
-add_fork (pid_t pid)
+add_fork (pid_t pid, inferior *inf)
 {
-  fork_list.emplace_back (pid);
-
-  if (one_fork_p ())
-    highest_fork_num = 0;
+  auto &fork_list = get_fork_list (inf);
 
-  fork_info *fp = &fork_list.back ();
-  fp->num = ++highest_fork_num;
+  fork_list.emplace_back (pid, ++highest_fork_num);
 }
 
 static void
-delete_fork (ptid_t ptid)
+delete_fork (ptid_t ptid, inferior *inf)
 {
   linux_target->low_forget_process (ptid.pid ());
 
+  auto &fork_list = get_fork_list (inf);
   for (auto it = fork_list.begin (); it != fork_list.end (); ++it)
     if (it->ptid == ptid)
       {
@@ -142,55 +179,68 @@ delete_fork (ptid_t ptid)
 	   and if it is (hopefully!) the current inferior_ptid, then
 	   remove it, leaving the list empty -- we're now down to the
 	   default case of debugging a single process.  */
-	if (one_fork_p () && fork_list.front ().ptid == inferior_ptid)
+	if (one_fork_p (inf) && fork_list.front ().ptid == inferior_ptid)
 	  {
 	    /* Last fork -- delete from list and handle as solo
 	       process (should be a safe recursion).  */
-	    delete_fork (inferior_ptid);
+	    delete_fork (inferior_ptid, inf);
 	  }
 	return;
       }
 }
 
 /* Find a fork_info by matching PTID.  */
-static struct fork_info *
+static std::pair<fork_info *, inferior *>
 find_fork_ptid (ptid_t ptid)
 {
-  for (fork_info &fi : fork_list)
-    if (fi.ptid == ptid)
-      return &fi;
+  for (inferior *inf : all_inferiors ())
+    {
+      auto &fork_list = get_fork_list (inf);
+      for (fork_info &fi : fork_list)
+	if (fi.ptid == ptid)
+	  return { &fi, inf };
+    }
 
-  return NULL;
+  return { nullptr, nullptr };
 }
 
 /* Find a fork_info by matching ID.  */
-static struct fork_info *
+static std::pair<fork_info *, inferior *>
 find_fork_id (int num)
 {
-  for (fork_info &fi : fork_list)
-    if (fi.num == num)
-      return &fi;
+  for (inferior *inf : all_inferiors ())
+    {
+      auto &fork_list = get_fork_list (inf);
+      for (fork_info &fi : fork_list)
+	if (fi.num == num)
+	  return { &fi, inf };
+    }
 
-  return NULL;
+  return { nullptr, nullptr };
 }
 
 /* Find a fork_info by matching pid.  */
-extern struct fork_info *
+extern std::pair<fork_info *, inferior *>
 find_fork_pid (pid_t pid)
 {
-  for (fork_info &fi : fork_list)
-    if (pid == fi.ptid.pid ())
-      return &fi;
+  for (inferior *inf : all_inferiors ())
+    {
+      auto &fork_list = get_fork_list (inf);
+      for (fork_info &fi : fork_list)
+	if (pid == fi.ptid.pid ())
+	  return { &fi, inf };
+    }
 
-  return NULL;
+  return { nullptr, nullptr };
 }
 
+/* Find a fork's ptid given it's number NUM.  */
 static ptid_t
 fork_id_to_ptid (int num)
 {
-  struct fork_info *fork = find_fork_id (num);
-  if (fork)
-    return fork->ptid;
+  struct fork_info *fi = find_fork_id (num).first;
+  if (fi != nullptr)
+    return fi->ptid;
   else
     return ptid_t (-1);
 }
@@ -297,7 +347,7 @@ fork_save_infrun_state (struct fork_info *fp)
 /* Kill 'em all, let God sort 'em out...  */
 
 void
-linux_fork_killall (void)
+linux_fork_killall (inferior *inf)
 {
   /* Walk list and kill every pid.  No need to treat the
      current inferior_ptid as special (we do not return a
@@ -305,6 +355,7 @@ linux_fork_killall (void)
      or a parent, so may get a SIGCHLD from a previously
      killed child.  Wait them all out.  */
 
+  auto &fork_list = get_fork_list (inf);
   for (fork_info &fi : fork_list)
     {
       pid_t pid = fi.ptid.pid ();
@@ -330,7 +381,7 @@ linux_fork_killall (void)
    first available.  */
 
 void
-linux_fork_mourn_inferior (void)
+linux_fork_mourn_inferior (inferior *inf)
 {
   struct fork_info *last;
   int status;
@@ -344,21 +395,21 @@ linux_fork_mourn_inferior (void)
   /* OK, presumably inferior_ptid is the one who has exited.
      We need to delete that one from the fork_list, and switch
      to the next available fork.  */
-  delete_fork (inferior_ptid);
+  delete_fork (inferior_ptid, inf);
 
   /* There should still be a fork - if there's only one left,
      delete_fork won't remove it, because we haven't updated
      inferior_ptid yet.  */
-  gdb_assert (!fork_list.empty ());
+  gdb_assert (!get_fork_list (inf).empty ());
 
-  last = find_last_fork ();
+  last = find_last_fork (inf);
   fork_load_infrun_state (last);
   gdb_printf (_("[Switching to %s]\n"),
 	      target_pid_to_str (inferior_ptid).c_str ());
 
   /* If there's only one fork, switch back to non-fork mode.  */
-  if (one_fork_p ())
-    delete_fork (inferior_ptid);
+  if (one_fork_p (inf))
+    delete_fork (inferior_ptid, inf);
 }
 
 /* The current inferior_ptid is being detached, but there are other
@@ -366,7 +417,7 @@ linux_fork_mourn_inferior (void)
    the first available.  */
 
 void
-linux_fork_detach (int from_tty, lwp_info *lp)
+linux_fork_detach (int from_tty, lwp_info *lp, inferior *inf)
 {
   gdb_assert (lp != nullptr);
   gdb_assert (lp->ptid == inferior_ptid);
@@ -385,11 +436,12 @@ linux_fork_detach (int from_tty, lwp_info *lp)
 	       target_pid_to_str (inferior_ptid).c_str ());
     }
 
-  delete_fork (inferior_ptid);
+  delete_fork (inferior_ptid, inf);
 
   /* There should still be a fork - if there's only one left,
      delete_fork won't remove it, because we haven't updated
      inferior_ptid yet.  */
+  auto &fork_list = get_fork_list (inf);
   gdb_assert (!fork_list.empty ());
 
   fork_load_infrun_state (&fork_list.front ());
@@ -399,8 +451,8 @@ linux_fork_detach (int from_tty, lwp_info *lp)
 		target_pid_to_str (inferior_ptid).c_str ());
 
   /* If there's only one fork, switch back to non-fork mode.  */
-  if (one_fork_p ())
-    delete_fork (inferior_ptid);
+  if (one_fork_p (inf))
+    delete_fork (inferior_ptid, inf);
 }
 
 /* Temporarily switch to the infrun state stored on the fork_info
@@ -413,19 +465,26 @@ class scoped_switch_fork_info
   /* Switch to the infrun state held on the fork_info identified by
      PPTID.  If PPTID is the current inferior then no switch is done.  */
   explicit scoped_switch_fork_info (ptid_t pptid)
-    : m_oldfp (nullptr)
+    : m_oldfp (nullptr), m_oldinf (nullptr)
   {
     if (pptid != inferior_ptid)
       {
-	struct fork_info *newfp = nullptr;
-
 	/* Switch to pptid.  */
-	m_oldfp = find_fork_ptid (inferior_ptid);
+	auto [oldfp, oldinf] = find_fork_ptid (inferior_ptid);
+	m_oldfp = oldfp;
 	gdb_assert (m_oldfp != nullptr);
-	newfp = find_fork_ptid (pptid);
+	auto [newfp, newinf]  = find_fork_ptid (pptid);
 	gdb_assert (newfp != nullptr);
 	fork_save_infrun_state (m_oldfp);
 	remove_breakpoints ();
+
+	if (oldinf != newinf)
+	  {
+	    thread_info *tp = any_thread_of_inferior (newinf);
+	    switch_to_thread (tp);
+	    m_oldinf = oldinf;
+	  }
+
 	fork_load_infrun_state (newfp);
 	insert_breakpoints ();
       }
@@ -435,12 +494,17 @@ class scoped_switch_fork_info
      didn't need to switch states, then nothing is done here either.  */
   ~scoped_switch_fork_info ()
   {
-    if (m_oldfp != nullptr)
+    if (m_oldinf != nullptr || m_oldfp != nullptr)
       {
 	/* Switch back to inferior_ptid.  */
 	try
 	  {
 	    remove_breakpoints ();
+	    if (m_oldinf != nullptr)
+	      {
+		thread_info *tp = any_thread_of_inferior (m_oldinf);
+		switch_to_thread (tp);
+	      }
 	    fork_load_infrun_state (m_oldfp);
 	    insert_breakpoints ();
 	  }
@@ -472,6 +536,7 @@ class scoped_switch_fork_info
      we were already in the desired state, and nothing needs to be
      restored.  */
   struct fork_info *m_oldfp;
+  inferior *m_oldinf;
 };
 
 static int
@@ -514,7 +579,6 @@ static void
 delete_checkpoint_command (const char *args, int from_tty)
 {
   ptid_t ptid, pptid;
-  struct fork_info *fi;
 
   if (!args || !*args)
     error (_("Requires argument (checkpoint id to delete)"));
@@ -523,21 +587,30 @@ delete_checkpoint_command (const char *args, int from_tty)
   if (ptid == minus_one_ptid)
     error (_("No such checkpoint id, %s"), args);
 
-  if (ptid == inferior_ptid)
-    error (_("\
+  auto [fi, inf] = find_fork_ptid (ptid);
+  gdb_assert (fi != nullptr);
+  pptid = fi->parent_ptid;
+
+  thread_info *inf_thr = any_thread_of_inferior (inf);
+  gdb_assert (inf_thr != nullptr);
+  if (ptid == inf_thr->ptid)
+    {
+      if (inf == current_inferior ())
+	error (_("\
 Please switch to another checkpoint before deleting the current one"));
+      else
+	error (_("\
+Please switch to another checkpoint before deleting the current one\n\
+in inferior %d"), inf->num);
+    }
 
   if (ptrace (PTRACE_KILL, ptid.pid (), 0, 0))
     error (_("Unable to kill pid %s"), target_pid_to_str (ptid).c_str ());
 
-  fi = find_fork_ptid (ptid);
-  gdb_assert (fi);
-  pptid = fi->parent_ptid;
-
   if (from_tty)
     gdb_printf (_("Killed %s\n"), target_pid_to_str (ptid).c_str ());
 
-  delete_fork (ptid);
+  delete_fork (ptid, inf);
 
   if (pptid == null_ptid)
     {
@@ -555,7 +628,7 @@ Please switch to another checkpoint before deleting the current one"));
      If fi->parent_ptid is a part of lwp and it is stopped, waitpid the
      ptid.  */
   thread_info *parent = linux_target->find_thread (pptid);
-  if ((parent == NULL && find_fork_ptid (pptid))
+  if ((parent == NULL && find_fork_ptid (pptid).first != nullptr)
       || (parent != NULL && parent->state == THREAD_STOPPED))
     {
       if (inferior_call_waitpid (pptid, ptid.pid ()))
@@ -586,7 +659,7 @@ Please switch to another checkpoint before detaching the current one"));
   if (from_tty)
     gdb_printf (_("Detached %s\n"), target_pid_to_str (ptid).c_str ());
 
-  delete_fork (ptid);
+  delete_fork (ptid, current_inferior ());
 }
 
 /* Print information about currently known checkpoints.  */
@@ -595,57 +668,72 @@ static void
 info_checkpoints_command (const char *arg, int from_tty)
 {
   struct gdbarch *gdbarch = get_current_arch ();
+  struct inferior *cur_inf = current_inferior ();
   int requested = -1;
   bool printed = false;
 
   if (arg && *arg)
     requested = (int) parse_and_eval_long (arg);
 
-  for (const fork_info &fi : fork_list)
-    {
-      if (requested > 0 && fi.num != requested)
-	continue;
-      printed = true;
-
-      bool is_current = fi.ptid == inferior_ptid;
-      if (is_current)
-	gdb_printf ("* ");
-      else
-	gdb_printf ("  ");
-
-      gdb_printf ("%d %s", fi.num, target_pid_to_str (fi.ptid).c_str ());
-      if (fi.num == 0)
-	gdb_printf (_(" (main process)"));
 
-      if (is_current && inferior_thread ()->state == THREAD_RUNNING)
-	{
-	  gdb_printf (_(" <running>\n"));
-	  continue;
-	}
+  for (inferior *inf : all_inferiors ())
+    {
+      scoped_restore_current_pspace_and_thread restore_pspace_thread;
+      switch_to_program_space_and_thread (inf->pspace);
 
-      gdb_printf (_(" at "));
-      ULONGEST pc
-	= (is_current
-	   ? regcache_read_pc (get_thread_regcache (inferior_thread ()))
-	   : fi.pc);
-      gdb_puts (paddress (gdbarch, pc));
-
-      symtab_and_line sal = find_pc_line (pc, 0);
-      if (sal.symtab)
-	gdb_printf (_(", file %s"),
-		    symtab_to_filename_for_display (sal.symtab));
-      if (sal.line)
-	gdb_printf (_(", line %d"), sal.line);
-      if (!sal.symtab && !sal.line)
+      auto &fork_list = get_fork_list (inf);
+      for (const fork_info &fi : fork_list)
 	{
-	  struct bound_minimal_symbol msym;
-
-	  msym = lookup_minimal_symbol_by_pc (pc);
-	  if (msym.minsym)
-	    gdb_printf (", <%s>", msym.minsym->linkage_name ());
+	  if (requested > 0 && fi.num != requested)
+	    continue;
+	  printed = true;
+
+	  thread_info *t = any_thread_of_inferior (inf);
+	  bool is_current = fi.ptid == t->ptid;
+	  if (is_current)
+	    {
+	      if (cur_inf == inf)
+		gdb_printf ("* ");
+	      else
+		gdb_printf ("+ ");
+	    }
+	  else
+	    gdb_printf ("  ");
+
+	  gdb_printf ("%d %s", fi.num, target_pid_to_str (fi.ptid).c_str ());
+	  if (&fi == &fork_list.front ())
+	    gdb_printf (_(" (main process)"));
+
+	  if (is_current && t->state == THREAD_RUNNING)
+	    {
+	      gdb_printf (_(" <running>\n"));
+	      continue;
+	    }
+
+	  gdb_printf (_(" at "));
+	  ULONGEST pc
+	    = (is_current
+	       ? regcache_read_pc (get_thread_regcache (t))
+	       : fi.pc);
+	  gdb_puts (paddress (gdbarch, pc));
+
+	  symtab_and_line sal = find_pc_line (pc, 0);
+	  if (sal.symtab)
+	    gdb_printf (_(", file %s"),
+			symtab_to_filename_for_display (sal.symtab));
+	  if (sal.line)
+	    gdb_printf (_(", line %d"), sal.line);
+	  if (!sal.symtab && !sal.line)
+	    {
+	      struct bound_minimal_symbol msym;
+
+	      msym = lookup_minimal_symbol_by_pc (pc);
+	      if (msym.minsym)
+		gdb_printf (", <%s>", msym.minsym->linkage_name ());
+	    }
+
+	  gdb_putc ('\n');
 	}
-
-      gdb_putc ('\n');
     }
 
   if (!printed)
@@ -690,7 +778,6 @@ checkpoint_command (const char *args, int from_tty)
   struct target_waitstatus last_target_waitstatus;
   ptid_t last_target_ptid;
   struct value *fork_fn = NULL, *ret;
-  struct fork_info *fp;
   pid_t retpid;
 
   if (!target_has_execution ()) 
@@ -711,6 +798,10 @@ checkpoint_command (const char *args, int from_tty)
   if (!fork_fn)
     error (_("checkpoint: can't find fork function in inferior."));
 
+  int first_num = 0;
+  if (!forks_exist_p (current_inferior ()))
+    first_num = ++highest_fork_num;
+
   gdbarch = fork_objf->arch ();
   ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
 
@@ -728,7 +819,7 @@ checkpoint_command (const char *args, int from_tty)
   retpid = value_as_long (ret);
   get_last_target_status (nullptr, &last_target_ptid, &last_target_waitstatus);
 
-  fp = find_fork_pid (retpid);
+  auto [fp, inf] = find_fork_pid (retpid);
 
   if (from_tty)
     {
@@ -749,12 +840,14 @@ checkpoint_command (const char *args, int from_tty)
   if (!fp)
     error (_("Failed to find new fork"));
 
-  if (one_fork_p ())
+  if (one_fork_p (inf))
     {
       /* Special case -- if this is the first fork in the list (the
-	 list was hitherto empty), then add inferior_ptid first, as a
-	 special zeroeth fork id.  */
-      fork_list.emplace_front (inferior_ptid.pid ());
+	 list was hitherto empty), then add inferior_ptid first, using
+	 the fork number allocated earlier - see above assignment to
+	 FIRST_NUM.  */
+      auto &fork_list = get_fork_list (inf);
+      fork_list.emplace_front (inferior_ptid.pid (), first_num);
     }
 
   fork_save_infrun_state (fp);
@@ -762,40 +855,56 @@ checkpoint_command (const char *args, int from_tty)
 }
 
 static void
-linux_fork_context (struct fork_info *newfp, int from_tty)
+linux_fork_context (struct fork_info *newfp, int from_tty, inferior *newinf)
 {
-  /* Now we attempt to switch processes.  */
-  struct fork_info *oldfp;
+  bool inferior_changed = false;
 
+  /* Now we attempt to switch processes.  */
   gdb_assert (newfp != NULL);
 
-  oldfp = find_fork_ptid (inferior_ptid);
-  gdb_assert (oldfp != NULL);
+  if (newinf != current_inferior ())
+    {
+      thread_info *tp = any_thread_of_inferior (newinf);
+      switch_to_thread (tp);
+      inferior_changed = true;
+    }
 
-  fork_save_infrun_state (oldfp);
-  remove_breakpoints ();
-  fork_load_infrun_state (newfp);
-  insert_breakpoints ();
+  auto [oldfp, oldinf] = find_fork_ptid (inferior_ptid);
+  gdb_assert (oldfp != NULL);
 
-  gdb_printf (_("Switching to %s\n"),
-	      target_pid_to_str (inferior_ptid).c_str ());
+  if (oldfp == newfp)
+    {
+      if (!inferior_changed)
+	error (_("Already using checkpoint %d\n"), oldfp->num);
+    }
+  else
+    {
+      fork_save_infrun_state (oldfp);
+      remove_breakpoints ();
+      fork_load_infrun_state (newfp);
+      insert_breakpoints ();
+      if (!inferior_changed)
+	gdb_printf (_("Switching to %s\n"),
+		    target_pid_to_str (inferior_ptid).c_str ());
+    }
 
-  print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+  notify_user_selected_context_changed
+    (inferior_changed ? (USER_SELECTED_INFERIOR | USER_SELECTED_FRAME)
+		      : USER_SELECTED_FRAME);
 }
 
 /* Switch inferior process (checkpoint) context, by checkpoint id.  */
 static void
 restart_command (const char *args, int from_tty)
 {
-  struct fork_info *fp;
-
   if (!args || !*args)
     error (_("Requires argument (checkpoint id to restart)"));
 
-  if ((fp = find_fork_id (parse_and_eval_long (args))) == NULL)
+  auto [fp, inf] = find_fork_id (parse_and_eval_long (args));
+  if (fp == nullptr)
     error (_("Not found: checkpoint id %s"), args);
 
-  linux_fork_context (fp, from_tty);
+  linux_fork_context (fp, from_tty, inf);
 }
 
 void _initialize_linux_fork ();
diff --git a/gdb/linux-fork.h b/gdb/linux-fork.h
index c553aaf0740..e8ed37a4118 100644
--- a/gdb/linux-fork.h
+++ b/gdb/linux-fork.h
@@ -22,12 +22,13 @@
 
 struct fork_info;
 struct lwp_info;
-extern void add_fork (pid_t);
-extern struct fork_info *find_fork_pid (pid_t);
-extern void linux_fork_killall (void);
-extern void linux_fork_mourn_inferior (void);
-extern void linux_fork_detach (int, lwp_info *);
-extern int forks_exist_p (void);
+class inferior;
+extern void add_fork (pid_t, inferior *inf);
+extern std::pair<fork_info *, inferior *> find_fork_pid (pid_t);
+extern void linux_fork_killall (inferior *inf);
+extern void linux_fork_mourn_inferior (inferior *inf);
+extern void linux_fork_detach (int, lwp_info *, inferior *inf);
+extern int forks_exist_p (inferior *inf);
 extern int linux_fork_checkpointing_p (int);
 
 #endif /* LINUX_FORK_H */
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 3ba072bc8d7..5181aa2421d 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1553,13 +1553,13 @@ linux_nat_target::detach (inferior *inf, int from_tty)
   gdb_assert (num_lwps (pid) == 1
 	      || (target_is_non_stop_p () && num_lwps (pid) == 0));
 
-  if (pid == inferior_ptid.pid () && forks_exist_p ())
+  if (forks_exist_p (inf))
     {
       /* Multi-fork case.  The current inferior_ptid is being detached
 	 from, but there are other viable forks to debug.  Detach from
 	 the current fork, and context-switch to the first
 	 available.  */
-      linux_fork_detach (from_tty, find_lwp_pid (ptid_t (pid)));
+      linux_fork_detach (from_tty, find_lwp_pid (ptid_t (pid)), inf);
     }
   else
     {
@@ -2077,8 +2077,12 @@ linux_handle_extended_wait (struct lwp_info *lp, int status)
 	  detach_breakpoints (ptid_t (new_pid, new_pid));
 
 	  /* Retain child fork in ptrace (stopped) state.  */
-	  if (!find_fork_pid (new_pid))
-	    add_fork (new_pid);
+	  if (find_fork_pid (new_pid).first == nullptr)
+	    {
+	      struct inferior *inf = find_inferior_ptid (linux_target,
+	                                                 lp->ptid);
+	      add_fork (new_pid, inf);
+	    }
 
 	  /* Report as spurious, so that infrun doesn't want to follow
 	     this fork.  We're actually doing an infcall in
@@ -3758,8 +3762,8 @@ linux_nat_target::kill ()
      parent will be sleeping if this is a vfork.  */
   iterate_over_lwps (pid_ptid, kill_unfollowed_child_callback);
 
-  if (forks_exist_p ())
-    linux_fork_killall ();
+  if (forks_exist_p (current_inferior ()))
+    linux_fork_killall (current_inferior ());
   else
     {
       /* Stop all threads before killing them, since ptrace requires
@@ -3790,14 +3794,14 @@ linux_nat_target::mourn_inferior ()
 
   close_proc_mem_file (pid);
 
-  if (! forks_exist_p ())
+  if (! forks_exist_p (current_inferior ()))
     /* Normal case, no other forks available.  */
     inf_ptrace_target::mourn_inferior ();
   else
     /* Multi-fork case.  The current inferior_ptid has exited, but
        there are other viable forks to debug.  Delete the exiting
        one and context-switch to the first available.  */
-    linux_fork_mourn_inferior ();
+    linux_fork_mourn_inferior (current_inferior ());
 
   /* Let the arch-specific native code know this process is gone.  */
   linux_target->low_forget_process (pid);
diff --git a/gdb/testsuite/gdb.multi/checkpoint-multi.exp b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
new file mode 100644
index 00000000000..98f6e0ae933
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
@@ -0,0 +1,668 @@
+# Copyright 2009-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file tests various scenarios involving multiple inferiors
+# and the checkpoint command.
+
+# Checkpoint support works only on Linux.
+require {istarget "*-*-linux*"}
+
+# Checkpoint support is implemented for the (Linux) native target,
+# which is indicated when [target_info gdb_protocol] returns the empty
+# string.
+if { [target_info gdb_protocol] != "" } {
+    return
+}
+
+set testfile "checkpoint-multi"
+
+set exec1 "hello"
+set srcfile1 ${exec1}.c
+set binfile1 [standard_output_file ${exec1}]
+
+set exec2 "goodbye"
+set srcfile2 ${exec2}.c
+set binfile2 [standard_output_file ${exec2}]
+
+set exec3 "hangout"
+set srcfile3 ${exec3}.c
+set binfile3 [standard_output_file ${exec3}]
+
+if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" {debug}] == -1 } {
+    return -1
+}
+
+if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" {debug}] == -1 } {
+    return -1
+}
+
+if { [build_executable ${testfile}.exp ${exec3} "${srcfile3}" {debug}] == -1 } {
+    return -1
+}
+
+# Start two inferiors, place a catchpoint on inferior 2, but switch
+# back to inferior 1.
+proc start_2_inferiors_catchpoint_on_inf_2 {} {
+    clean_restart $::exec1
+
+    # Start inferior 1.
+    if {[gdb_start_cmd] < 0} {
+	fail "start first inferior"
+    } else {
+	gdb_test "" "main.*" "start first inferior"
+    }
+
+    # Add a new inferior and exec into it.
+    gdb_test "add-inferior -exec $::binfile2" \
+	"Added inferior 2.*" \
+	"add inferior 2 with -exec $::exec2"
+
+    # Check that we have multiple inferiors.
+    gdb_test "info inferiors" \
+	"Executable.*$::exec1.*$::exec2.*"
+
+    # Switch to inferior 2.
+    gdb_test "inferior 2" \
+	"Switching to inferior 2.*$::exec2.*"
+
+    # Start inferior 2:
+    if {[gdb_start_cmd] < 0} {
+	fail "start second inferior"
+    } else {
+	gdb_test "" "main.*" "start second inferior"
+    }
+
+    # Set a checkpoint in inferior 2
+    gdb_test "checkpoint" "checkpoint 1: fork returned pid $::decimal.*"
+
+    # Step one line in inferior 2.
+    gdb_test "step" "glob = 46;"
+
+    # Switch back to inferior 1.
+    gdb_test "inferior 1" "Switching to inferior 1.*$::exec1.*"
+}
+
+# Start two inferiors, place a catchpoint on inferior 2, but switch
+# back to inferior 1.  This is like the one above, except that it
+# swaps the executables loaded into inferior 1 and inferior 2.	This
+# is important for being able to test "continue to exit".  (Because... 
+# hello.c has an infinite loop, but goodbye.c doesn't.	In order to
+# test "continue to exit", we need to continue in an executable which
+# will actually exit.)
+
+proc start_2_inferiors_catchpoint_on_inf_2_alt {} {
+    clean_restart $::exec2
+
+    # Start inferior 1.
+    if {[gdb_start_cmd] < 0} {
+	fail "start first inferior"
+    } else {
+	gdb_test "" "main.*" "start first inferior"
+    }
+
+    # Add a new inferior and exec exec1 into it.
+    gdb_test "add-inferior -exec $::binfile1" \
+	"Added inferior 2.*" \
+	"add inferior 2 with -exec $::exec1"
+
+    # Check that we have two inferiors.
+    gdb_test "info inferiors" \
+	"Executable.*$::exec2.*$::exec1.*"
+
+    # Switch to inferior 2.
+    gdb_test "inferior 2" \
+	"Switching to inferior 2.*$::exec1.*"
+
+    # Start inferior 2:
+    if {[gdb_start_cmd] < 0} {
+	fail "start second inferior"
+    } else {
+	gdb_test "" "main.*" "start second inferior"
+    }
+
+    # Set a checkpoint in inferior 2
+    gdb_test "checkpoint" "checkpoint 1: fork returned pid $::decimal.*"
+
+    # next one line in inferior 2.
+    gdb_test "next" "bar\\(\\).*"
+
+    # Switch back to inferior 1.
+    gdb_test "inferior 1" "Switching to inferior 1.*$::exec2.*"
+}
+
+with_test_prefix "check detach on non-checkpointed inferior" {
+    start_2_inferiors_catchpoint_on_inf_2
+    gdb_test "detach" "Detaching from program.*$::exec1.*Inferior 1.*detached.*"
+}
+
+with_test_prefix "check kill on non-checkpointed inferior" {
+    start_2_inferiors_catchpoint_on_inf_2
+    gdb_test "kill" "" "kill non-checkpointed inferior" \
+	     "Kill the program being debugged.*y or n. $" "y"
+}
+
+with_test_prefix "check restart 0 on non-checkpointed inferior" {
+    start_2_inferiors_catchpoint_on_inf_2
+    gdb_test "restart 0" "Switching to inferior 2.*?goodbye.*?#0 +mailand .*?glob = 46;.*"
+}
+
+with_test_prefix "check restart 1 on non-checkpointed inferior" {
+    start_2_inferiors_catchpoint_on_inf_2
+    gdb_test "restart 1" "Switching to inferior 2.*?goodbye.*?#0 +main .*?mailand\\(\\);.*"
+}
+
+with_test_prefix "check continue to exit on non-checkpointed inferior" {
+    start_2_inferiors_catchpoint_on_inf_2_alt
+    gdb_test "continue" "Inferior 1.*? exited normally.*"
+}
+
+set thr_or_proc "(?:process $::decimal|Thread $::hex \\(LWP $::decimal\\))"
+set main_proc "\\(main process\\)"
+set hello_c "hello\\.c"
+set goodbye_c "goodbye\\.c"
+set hangout_c "hangout\\.c"
+
+with_test_prefix "two inferiors with checkpoints" {
+    start_2_inferiors_catchpoint_on_inf_2
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?"] \
+	    "info checkpoints 1"
+    gdb_test "checkpoint" "checkpoint 3: fork returned pid $::decimal.*" \
+	     "checkpoint in inferior 1"
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\* 2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?"] \
+	    "info checkpoints 2"
+    gdb_test "restart 0" \
+	     "\\\[Switching to inferior 2.*?mailand.*?glob = 46;.*"
+    gdb_test "next" "\}"
+
+    gdb_test "restart 1" "^Switching to $thr_or_proc.*?#0  main \\(\\) at.*?$goodbye_c.*mailand\\(\\);"
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?"] \
+	    "info checkpoints 3"
+
+    # Doing "info_checkpoints" twice in a row might seem pointless,
+    # but during work on making the checkpoint code inferior aware,
+    # there was a point at which doing it twice in a row did not
+    # produce the same output.
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?"] \
+	    "info checkpoints 4"
+
+    # Switch back to checkpoint 0; again, there should be no
+    # "Switching to inferior" message.
+    gdb_test "restart 0" "^Switching to $thr_or_proc.*?#0  mailand \\(\\) at.*?$goodbye_c.*\}" \
+	     "restart 0 #2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\* 0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?"] \
+	    "info checkpoints 5"
+
+    # Switch to checkpoint 3; this time, we should see a "Switching to
+    # inferior" message.
+    gdb_test "restart 3" \
+	     "\\\[Switching to inferior 1.*?main.*?$hello_c.*?alarm \\(240\\);"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\* 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?"] \
+	    "info checkpoints 6"
+
+    gdb_test "restart 1" \
+	     "Switching to inferior 2.*?#0  main \\(\\) at.*?$goodbye_c.*mailand\\(\\);" \
+	     "restart 1 #2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?"] \
+	    "info checkpoints 7"
+
+    gdb_test "checkpoint" "checkpoint 4: fork returned pid $::decimal.*" \
+	     "second checkpoint in inferior 2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  4 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 8"
+
+    gdb_test "checkpoint" "checkpoint 5: fork returned pid $::decimal.*" \
+	     "third checkpoint in inferior 2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  4 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 9"
+
+    gdb_test "continue" \
+	     "Inferior 2 \\(process $decimal\\) exited normally.*?Switching to $thr_or_proc.*?" \
+	     "continue to exit in checkpoint 1"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  4 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 5 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 10"
+
+    gdb_test "continue" \
+	     "Inferior 2 \\(process $decimal\\) exited normally.*?Switching to process $decimal.*?" \
+	     "continue to exit in checkpoint 5"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 4 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 11"
+
+    gdb_test "continue" \
+	     "Inferior 2 \\(process $decimal\\) exited normally.*?Switching to process $decimal.*?" \
+	     "continue to exit in checkpoint 4"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" ] \
+	    "info checkpoints 12"
+
+    gdb_test "checkpoint" "checkpoint 7: fork returned pid $::decimal.*" \
+	     "fourth checkpoint in inferior 2"
+
+    gdb_test "checkpoint" "checkpoint 8: fork returned pid $::decimal.*" \
+	     "fifth checkpoint in inferior 2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\* 6 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  7 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  8 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 13"
+
+    gdb_test "delete checkpoint 6" \
+	     "Please switch to another checkpoint before deleting the current one" \
+	     "delete checkpoint 6 #2"
+
+    gdb_test "restart 7" \
+	     "^Switching to process.*?#0  mailand \\(\\) at.*?$goodbye_c.*\}"
+
+    gdb_test "delete checkpoint 6" \
+	     "Killed process $::decimal"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\* 7 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  8 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 14"
+
+    gdb_test "delete checkpoint 8" \
+	     "Killed process $::decimal"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" ] \
+	    "info checkpoints 15"
+
+    gdb_test "checkpoint" "checkpoint 10: fork returned pid $::decimal.*" \
+	     "sixth checkpoint in inferior 2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\* 9 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  10 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 16"
+
+    gdb_test "inferior 1" "Switching to inferior 1.*?alarm \\(240\\);" \
+	     "inferior 1 #2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "  2 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\* 3 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 9 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  10 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 17"
+
+    gdb_test "kill" "\\\[Inferior 1 \\(process $::decimal\\) killed\\\]" \
+	     "kill inferior 1" \
+	     "Kill the program being debugged.*y or n. $" "y"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 9 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  10 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 18"
+
+    gdb_test "checkpoint" "The program is not being run\\." \
+	     "checkpoint in non-running inferior"
+
+    gdb_test "start" "Starting program.*?hello.*?alarm \\(240\\);"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 9 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  10 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 19"
+
+    gdb_test "checkpoint" "checkpoint 12: fork returned pid $::decimal.*" \
+	     "second checkpoint in inferior 1"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\* 11 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  12 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 9 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  10 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 20"
+}
+
+with_test_prefix "three inferiors with checkpoints" {
+    start_2_inferiors_catchpoint_on_inf_2
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?"] \
+	    "info checkpoints 1"
+
+    # Add a third inferior and exec into it.
+    gdb_test "add-inferior -exec $::binfile3" \
+	     "Added inferior 3.*" \
+	     "add inferior 3 with -exec $::exec3"
+
+    # Check that we have three inferiors.
+    gdb_test "info inferiors" \
+	     "Executable.*?\\* 1 .*?$::exec1.*? 2 .*?$::exec2.*? 3 .*?$::exec3.*?" \
+	     "check for three inferiors"
+
+    # Switch to inferior 3.
+    gdb_test "inferior 3" \
+	"Switching to inferior 3.*$::exec3.*"
+
+    # Start inferior 2:
+    if {[gdb_start_cmd] < 0} {
+	fail "start third inferior"
+    } else {
+	gdb_test "" "main.*" "start third inferior"
+    }
+
+    gdb_test "checkpoint" "checkpoint 3: fork returned pid $::decimal.*" \
+	     "first checkpoint in inferior 3"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 2 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  3 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 2"
+
+    gdb_test "inferior 1" "Switching to inferior 1.*?alarm \\(240\\);" \
+	     "inferior 1 #2"
+
+    gdb_test "checkpoint" "checkpoint 5: fork returned pid $::decimal.*" \
+	     "first checkpoint in inferior 1"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\* 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 2 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  3 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 3"
+
+    gdb_test "restart 1" \
+	     "Switching to inferior 2.*?#0  main \\(\\) at.*?$goodbye_c.*mailand\\(\\);" \
+	     "restart 1"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 2 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  3 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 4"
+
+    gdb_test "next" "foo\\(glob\\);"
+
+    gdb_test "checkpoint" "checkpoint 6: fork returned pid $::decimal.*" \
+	     "second checkpoint in inferior 2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 2 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  3 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 5"
+
+    gdb_test "inferior 3" "Switching to inferior 3.*?alarm \\(30\\);" \
+	     "inferior 3 #2"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 2 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  3 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 6"
+
+    gdb_test "kill" "\\\[Inferior 3 \\(process $::decimal\\) killed\\\]" \
+	     "kill inferior 3" \
+	     "Kill the program being debugged.*y or n. $" "y"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  0 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 1 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 7"
+
+    gdb_test "delete checkpoint 0" \
+	     "Killed process $::decimal"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "\\+ 1 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "  6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 8"
+
+    gdb_test "restart 6" \
+	     "Switching to inferior 2.*?#0  main \\(\\) at.*?$goodbye_c.*foo\\(glob\\);"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  1 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 9"
+
+    gdb_test "inferior 3" "\\\[Switching to inferior 3 \\\[<null>\\\] \\(.*?$::exec3\\)\\\]" \
+	     "inferior 3 #3"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  1 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" ] \
+	    "info checkpoints 10"
+
+    gdb_test "start" "Starting program.*?hangout.*?alarm \\(30\\);"
+
+    gdb_test "checkpoint" "checkpoint 8: fork returned pid $::decimal.*" \
+	     "second checkpoint in inferior 3"
+
+    gdb_test "checkpoint" "checkpoint 9: fork returned pid $::decimal.*" \
+	     "third checkpoint in inferior 3"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  1 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 7 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  8 $thr_or_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  9 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 11"
+
+    gdb_test "delete checkpoint 8" \
+	     "Killed process $::decimal"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  1 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 7 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  9 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 12"
+
+    # Switch to inferior 1, add another checkpoint - so that there are
+    # three of them in inferior 1 - then switch back to inferior 1 and
+    # delete active checkpoint in inferior 1.  Then, switch to
+    # inferior 1 and attempt to add another checkpoint.  During
+    # development, a "Cannot access memory at address ..." message was
+    # seen.  This was a bug - there were several problems, but one
+    # of them was that the checkpoint in question was an "active"
+    # checkpoint.  The fix was to disallow this case.
+    gdb_test "inferior 1" "Switching to inferior 1.*?alarm \\(240\\);" \
+	     "inferior 1 #3"
+
+    gdb_test "checkpoint" "checkpoint 10: fork returned pid $::decimal.*" \
+	     "second checkpoint in inferior 1"
+
+    gdb_test "inferior 3" "Switching to inferior 3.*?alarm \\(30\\);" \
+	     "inferior 3 #4"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  5 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  10 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  1 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 7 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  9 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 13"
+
+    # Check that deleting active checkpoints in other (non-current)
+    # inferiors is disallowed.
+    gdb_test "delete checkpoint 4" \
+	     "Please switch to another checkpoint before deleting the current one\[ \r\n\]+in inferior 1"
+
+    # But deleting non-active checkpoints, even in other inferiors 
+    # should work.
+    gdb_test "delete checkpoint 5" \
+	     "Killed process $::decimal"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\+ 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  10 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  1 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\* 7 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  9 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 14"
+
+    gdb_test "inferior 1" "Switching to inferior 1.*?alarm \\(240\\);" \
+	     "inferior 1 #4"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\* 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  10 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  1 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 7 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  9 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 15"
+
+    gdb_test "checkpoint" "checkpoint 11: fork returned pid $::decimal.*" \
+	     "third checkpoint in inferior 1"
+
+    gdb_test "info checkpoints" \
+	[multi_line \
+	    "\\* 4 $thr_or_proc $main_proc at $::hex, file.*?$hello_c.*?" \
+	    "  10 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  11 $thr_or_proc at $::hex, file.*?$hello_c.*?" \
+	    "  1 $thr_or_proc $main_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 6 $thr_or_proc at $::hex, file.*?$goodbye_c.*?" \
+	    "\\+ 7 $thr_or_proc $main_proc at $::hex, file.*?$hangout_c.*?" \
+	    "  9 $thr_or_proc at $::hex, file.*?$hangout_c.*?" ] \
+	    "info checkpoints 16"
+
+    gdb_test "x/i \$pc" "=> $::hex <main.*"
+}
-- 
2.44.0


^ permalink raw reply	[relevance 10%]

* [PATCH v2 4/4] gdb, gdbserver, gdbsupport: remove includes of early headers
  @ 2024-03-23  2:14  1% ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-03-23  2:14 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves, Simon Marchi

Now that defs.h, server.h and common-defs.h are included via the
`-include` option, it is no longer necessary for source files to include
it.  Remove all the inclusions of these files I could find.  Update the
generation scripts where relevant.

Change-Id: Ia026cff269c1b7ae7386dd3619bc9bb6a5332837
---
 gdb/aarch32-linux-nat.c                              | 1 -
 gdb/aarch32-tdep.c                                   | 2 --
 gdb/aarch64-fbsd-nat.c                               | 1 -
 gdb/aarch64-fbsd-tdep.c                              | 1 -
 gdb/aarch64-linux-nat.c                              | 1 -
 gdb/aarch64-linux-tdep.c                             | 1 -
 gdb/aarch64-nat.c                                    | 1 -
 gdb/aarch64-newlib-tdep.c                            | 1 -
 gdb/aarch64-ravenscar-thread.c                       | 1 -
 gdb/aarch64-tdep.c                                   | 1 -
 gdb/ada-exp.y                                        | 1 -
 gdb/ada-lang.c                                       | 1 -
 gdb/ada-tasks.c                                      | 1 -
 gdb/ada-typeprint.c                                  | 1 -
 gdb/ada-valprint.c                                   | 1 -
 gdb/ada-varobj.c                                     | 1 -
 gdb/addrmap.c                                        | 1 -
 gdb/agent.c                                          | 1 -
 gdb/aix-thread.c                                     | 1 -
 gdb/alloc.c                                          | 7 +------
 gdb/alpha-bsd-nat.c                                  | 1 -
 gdb/alpha-bsd-tdep.c                                 | 1 -
 gdb/alpha-linux-nat.c                                | 1 -
 gdb/alpha-linux-tdep.c                               | 1 -
 gdb/alpha-mdebug-tdep.c                              | 1 -
 gdb/alpha-netbsd-tdep.c                              | 1 -
 gdb/alpha-obsd-tdep.c                                | 1 -
 gdb/alpha-tdep.c                                     | 1 -
 gdb/amd-dbgapi-target.c                              | 1 -
 gdb/amd64-bsd-nat.c                                  | 1 -
 gdb/amd64-darwin-tdep.c                              | 1 -
 gdb/amd64-dicos-tdep.c                               | 1 -
 gdb/amd64-fbsd-nat.c                                 | 1 -
 gdb/amd64-fbsd-tdep.c                                | 1 -
 gdb/amd64-linux-nat.c                                | 1 -
 gdb/amd64-linux-tdep.c                               | 1 -
 gdb/amd64-nat.c                                      | 1 -
 gdb/amd64-netbsd-nat.c                               | 1 -
 gdb/amd64-netbsd-tdep.c                              | 1 -
 gdb/amd64-obsd-nat.c                                 | 1 -
 gdb/amd64-obsd-tdep.c                                | 1 -
 gdb/amd64-ravenscar-thread.c                         | 1 -
 gdb/amd64-sol2-tdep.c                                | 1 -
 gdb/amd64-tdep.c                                     | 1 -
 gdb/amd64-windows-nat.c                              | 1 -
 gdb/amd64-windows-tdep.c                             | 1 -
 gdb/amdgpu-tdep.c                                    | 1 -
 gdb/annotate.c                                       | 1 -
 gdb/arc-linux-nat.c                                  | 1 -
 gdb/arc-linux-tdep.c                                 | 1 -
 gdb/arc-newlib-tdep.c                                | 1 -
 gdb/arc-tdep.c                                       | 1 -
 gdb/arch-utils.c                                     | 1 -
 gdb/arch/aarch32.c                                   | 1 -
 gdb/arch/aarch64-insn.c                              | 1 -
 gdb/arch/aarch64-mte-linux.h                         | 1 -
 gdb/arch/aarch64-scalable-linux.h                    | 1 -
 gdb/arch/aarch64.c                                   | 1 -
 gdb/arch/amd64.c                                     | 1 -
 gdb/arch/arc.c                                       | 1 -
 gdb/arch/arm-get-next-pcs.c                          | 1 -
 gdb/arch/arm-linux.c                                 | 1 -
 gdb/arch/arm.c                                       | 1 -
 gdb/arch/csky.c                                      | 1 -
 gdb/arch/i386.c                                      | 1 -
 gdb/arch/loongarch.c                                 | 1 -
 gdb/arch/ppc-linux-common.c                          | 1 -
 gdb/arch/riscv.c                                     | 1 -
 gdb/arch/tic6x.c                                     | 1 -
 gdb/arm-bsd-tdep.c                                   | 1 -
 gdb/arm-fbsd-nat.c                                   | 1 -
 gdb/arm-fbsd-tdep.c                                  | 1 -
 gdb/arm-linux-nat.c                                  | 1 -
 gdb/arm-linux-tdep.c                                 | 1 -
 gdb/arm-netbsd-nat.c                                 | 1 -
 gdb/arm-netbsd-tdep.c                                | 1 -
 gdb/arm-none-tdep.c                                  | 1 -
 gdb/arm-obsd-tdep.c                                  | 1 -
 gdb/arm-pikeos-tdep.c                                | 1 -
 gdb/arm-tdep.c                                       | 1 -
 gdb/arm-wince-tdep.c                                 | 1 -
 gdb/async-event.c                                    | 1 -
 gdb/auto-load.c                                      | 1 -
 gdb/auxv.c                                           | 1 -
 gdb/avr-tdep.c                                       | 1 -
 gdb/ax-gdb.c                                         | 1 -
 gdb/ax-general.c                                     | 1 -
 gdb/bcache.c                                         | 1 -
 gdb/bfd-target.c                                     | 1 -
 gdb/bfin-linux-tdep.c                                | 1 -
 gdb/bfin-tdep.c                                      | 1 -
 gdb/block.c                                          | 1 -
 gdb/blockframe.c                                     | 1 -
 gdb/bpf-tdep.c                                       | 1 -
 gdb/break-catch-exec.c                               | 1 -
 gdb/break-catch-fork.c                               | 1 -
 gdb/break-catch-load.c                               | 1 -
 gdb/break-catch-sig.c                                | 1 -
 gdb/break-catch-syscall.c                            | 1 -
 gdb/break-catch-throw.c                              | 1 -
 gdb/breakpoint.c                                     | 1 -
 gdb/bsd-kvm.c                                        | 1 -
 gdb/bsd-uthread.c                                    | 1 -
 gdb/bt-utils.c                                       | 1 -
 gdb/btrace.c                                         | 1 -
 gdb/build-id.c                                       | 1 -
 gdb/buildsym-legacy.c                                | 1 -
 gdb/buildsym.c                                       | 1 -
 gdb/c-exp.y                                          | 1 -
 gdb/c-lang.c                                         | 1 -
 gdb/c-typeprint.c                                    | 1 -
 gdb/c-valprint.c                                     | 1 -
 gdb/c-varobj.c                                       | 1 -
 gdb/charset.c                                        | 1 -
 gdb/cli-out.c                                        | 1 -
 gdb/cli/cli-cmds.c                                   | 1 -
 gdb/cli/cli-decode.c                                 | 1 -
 gdb/cli/cli-dump.c                                   | 1 -
 gdb/cli/cli-interp.c                                 | 1 -
 gdb/cli/cli-logging.c                                | 1 -
 gdb/cli/cli-option.c                                 | 1 -
 gdb/cli/cli-script.c                                 | 1 -
 gdb/cli/cli-setshow.c                                | 1 -
 gdb/cli/cli-style.c                                  | 1 -
 gdb/cli/cli-utils.c                                  | 1 -
 gdb/coff-pe-read.c                                   | 1 -
 gdb/coffread.c                                       | 1 -
 gdb/compile/compile-c-support.c                      | 1 -
 gdb/compile/compile-c-symbols.c                      | 1 -
 gdb/compile/compile-c-types.c                        | 1 -
 gdb/compile/compile-cplus-symbols.c                  | 1 -
 gdb/compile/compile-cplus-types.c                    | 1 -
 gdb/compile/compile-loc2c.c                          | 1 -
 gdb/compile/compile-object-load.c                    | 1 -
 gdb/compile/compile-object-run.c                     | 1 -
 gdb/compile/compile.c                                | 1 -
 gdb/complaints.c                                     | 1 -
 gdb/completer.c                                      | 1 -
 gdb/copying.awk                                      | 1 -
 gdb/copying.c                                        | 1 -
 gdb/corefile.c                                       | 1 -
 gdb/corelow.c                                        | 1 -
 gdb/cp-abi.c                                         | 1 -
 gdb/cp-name-parser.y                                 | 1 -
 gdb/cp-namespace.c                                   | 1 -
 gdb/cp-support.c                                     | 1 -
 gdb/cp-valprint.c                                    | 1 -
 gdb/cris-linux-tdep.c                                | 1 -
 gdb/cris-tdep.c                                      | 1 -
 gdb/csky-linux-tdep.c                                | 1 -
 gdb/csky-tdep.c                                      | 1 -
 gdb/ctfread.c                                        | 1 -
 gdb/d-exp.y                                          | 1 -
 gdb/d-lang.c                                         | 1 -
 gdb/d-namespace.c                                    | 1 -
 gdb/d-valprint.c                                     | 1 -
 gdb/darwin-nat-info.c                                | 1 -
 gdb/darwin-nat.c                                     | 1 -
 gdb/dbxread.c                                        | 1 -
 gdb/dcache.c                                         | 1 -
 gdb/debug.c                                          | 1 -
 gdb/debuginfod-support.c                             | 1 -
 gdb/dicos-tdep.c                                     | 1 -
 gdb/dictionary.c                                     | 1 -
 gdb/disasm-selftests.c                               | 1 -
 gdb/disasm.c                                         | 1 -
 gdb/displaced-stepping.c                             | 1 -
 gdb/dtrace-probe.c                                   | 1 -
 gdb/dummy-frame.c                                    | 1 -
 gdb/dwarf2/abbrev-cache.c                            | 1 -
 gdb/dwarf2/abbrev.c                                  | 1 -
 gdb/dwarf2/ada-imported.c                            | 1 -
 gdb/dwarf2/aranges.c                                 | 1 -
 gdb/dwarf2/attribute.c                               | 1 -
 gdb/dwarf2/comp-unit-head.c                          | 1 -
 gdb/dwarf2/cooked-index.c                            | 1 -
 gdb/dwarf2/cu.c                                      | 1 -
 gdb/dwarf2/die.c                                     | 1 -
 gdb/dwarf2/dwz.c                                     | 1 -
 gdb/dwarf2/expr.c                                    | 1 -
 gdb/dwarf2/frame-tailcall.c                          | 1 -
 gdb/dwarf2/frame.c                                   | 1 -
 gdb/dwarf2/index-cache.c                             | 1 -
 gdb/dwarf2/index-common.c                            | 1 -
 gdb/dwarf2/index-write.c                             | 1 -
 gdb/dwarf2/leb.c                                     | 1 -
 gdb/dwarf2/line-header.c                             | 1 -
 gdb/dwarf2/loc.c                                     | 1 -
 gdb/dwarf2/macro.c                                   | 1 -
 gdb/dwarf2/read-debug-names.c                        | 1 -
 gdb/dwarf2/read-gdb-index.c                          | 1 -
 gdb/dwarf2/read.c                                    | 1 -
 gdb/dwarf2/section.c                                 | 1 -
 gdb/dwarf2/stringify.c                               | 1 -
 gdb/elf-none-tdep.c                                  | 1 -
 gdb/elfread.c                                        | 1 -
 gdb/eval.c                                           | 1 -
 gdb/event-top.c                                      | 1 -
 gdb/exceptions.c                                     | 1 -
 gdb/exec.c                                           | 1 -
 gdb/expprint.c                                       | 1 -
 gdb/extension.c                                      | 1 -
 gdb/f-array-walker.h                                 | 1 -
 gdb/f-exp.y                                          | 1 -
 gdb/f-lang.c                                         | 1 -
 gdb/f-typeprint.c                                    | 1 -
 gdb/f-valprint.c                                     | 1 -
 gdb/fbsd-nat.c                                       | 1 -
 gdb/fbsd-tdep.c                                      | 1 -
 gdb/features/microblaze-with-stack-protect.c         | 1 -
 gdb/features/microblaze.c                            | 1 -
 gdb/features/mips-dsp-linux.c                        | 1 -
 gdb/features/mips-linux.c                            | 1 -
 gdb/features/mips64-dsp-linux.c                      | 1 -
 gdb/features/mips64-linux.c                          | 1 -
 gdb/features/nds32.c                                 | 1 -
 gdb/features/nios2.c                                 | 1 -
 gdb/features/or1k-linux.c                            | 1 -
 gdb/features/or1k.c                                  | 1 -
 gdb/features/rs6000/powerpc-32.c                     | 1 -
 gdb/features/rs6000/powerpc-32l.c                    | 1 -
 gdb/features/rs6000/powerpc-403.c                    | 1 -
 gdb/features/rs6000/powerpc-403gc.c                  | 1 -
 gdb/features/rs6000/powerpc-405.c                    | 1 -
 gdb/features/rs6000/powerpc-505.c                    | 1 -
 gdb/features/rs6000/powerpc-601.c                    | 1 -
 gdb/features/rs6000/powerpc-602.c                    | 1 -
 gdb/features/rs6000/powerpc-603.c                    | 1 -
 gdb/features/rs6000/powerpc-604.c                    | 1 -
 gdb/features/rs6000/powerpc-64.c                     | 1 -
 gdb/features/rs6000/powerpc-64l.c                    | 1 -
 gdb/features/rs6000/powerpc-7400.c                   | 1 -
 gdb/features/rs6000/powerpc-750.c                    | 1 -
 gdb/features/rs6000/powerpc-860.c                    | 1 -
 gdb/features/rs6000/powerpc-altivec32.c              | 1 -
 gdb/features/rs6000/powerpc-altivec32l.c             | 1 -
 gdb/features/rs6000/powerpc-altivec64.c              | 1 -
 gdb/features/rs6000/powerpc-altivec64l.c             | 1 -
 gdb/features/rs6000/powerpc-e500.c                   | 1 -
 gdb/features/rs6000/powerpc-e500l.c                  | 1 -
 gdb/features/rs6000/powerpc-isa205-32l.c             | 1 -
 gdb/features/rs6000/powerpc-isa205-64l.c             | 1 -
 gdb/features/rs6000/powerpc-isa205-altivec32l.c      | 1 -
 gdb/features/rs6000/powerpc-isa205-altivec64l.c      | 1 -
 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c | 1 -
 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c | 1 -
 gdb/features/rs6000/powerpc-isa205-vsx32l.c          | 1 -
 gdb/features/rs6000/powerpc-isa205-vsx64l.c          | 1 -
 gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c      | 1 -
 gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c      | 1 -
 gdb/features/rs6000/powerpc-isa207-vsx32l.c          | 1 -
 gdb/features/rs6000/powerpc-isa207-vsx64l.c          | 1 -
 gdb/features/rs6000/powerpc-vsx32.c                  | 1 -
 gdb/features/rs6000/powerpc-vsx32l.c                 | 1 -
 gdb/features/rs6000/powerpc-vsx64.c                  | 1 -
 gdb/features/rs6000/powerpc-vsx64l.c                 | 1 -
 gdb/features/rs6000/rs6000.c                         | 1 -
 gdb/features/rx.c                                    | 1 -
 gdb/features/s390-gs-linux64.c                       | 1 -
 gdb/features/s390-linux32.c                          | 1 -
 gdb/features/s390-linux32v1.c                        | 1 -
 gdb/features/s390-linux32v2.c                        | 1 -
 gdb/features/s390-linux64.c                          | 1 -
 gdb/features/s390-linux64v1.c                        | 1 -
 gdb/features/s390-linux64v2.c                        | 1 -
 gdb/features/s390-te-linux64.c                       | 1 -
 gdb/features/s390-tevx-linux64.c                     | 1 -
 gdb/features/s390-vx-linux64.c                       | 1 -
 gdb/features/s390x-gs-linux64.c                      | 1 -
 gdb/features/s390x-linux64.c                         | 1 -
 gdb/features/s390x-linux64v1.c                       | 1 -
 gdb/features/s390x-linux64v2.c                       | 1 -
 gdb/features/s390x-te-linux64.c                      | 1 -
 gdb/features/s390x-tevx-linux64.c                    | 1 -
 gdb/features/s390x-vx-linux64.c                      | 1 -
 gdb/features/sparc/sparc32-solaris.c                 | 1 -
 gdb/features/sparc/sparc64-solaris.c                 | 1 -
 gdb/features/z80.c                                   | 1 -
 gdb/filename-seen-cache.c                            | 1 -
 gdb/filename-seen-cache.h                            | 1 -
 gdb/filesystem.c                                     | 1 -
 gdb/findcmd.c                                        | 1 -
 gdb/findvar.c                                        | 1 -
 gdb/fork-child.c                                     | 1 -
 gdb/frame-base.c                                     | 1 -
 gdb/frame-unwind.c                                   | 1 -
 gdb/frame.c                                          | 1 -
 gdb/frv-linux-tdep.c                                 | 1 -
 gdb/frv-tdep.c                                       | 1 -
 gdb/ft32-tdep.c                                      | 1 -
 gdb/gcore-elf.c                                      | 1 -
 gdb/gcore.c                                          | 1 -
 gdb/gdb-demangle.c                                   | 1 -
 gdb/gdb.c                                            | 1 -
 gdb/gdb_bfd.c                                        | 1 -
 gdb/gdbarch-selftests.c                              | 1 -
 gdb/gdbtypes.c                                       | 1 -
 gdb/glibc-tdep.c                                     | 1 -
 gdb/gmp-utils.c                                      | 1 -
 gdb/gnu-nat.c                                        | 1 -
 gdb/gnu-nat.h                                        | 2 --
 gdb/gnu-v2-abi.c                                     | 1 -
 gdb/gnu-v3-abi.c                                     | 1 -
 gdb/go-exp.y                                         | 1 -
 gdb/go-lang.c                                        | 1 -
 gdb/go-typeprint.c                                   | 1 -
 gdb/go-valprint.c                                    | 1 -
 gdb/go32-nat.c                                       | 1 -
 gdb/guile/guile.c                                    | 1 -
 gdb/guile/scm-arch.c                                 | 1 -
 gdb/guile/scm-auto-load.c                            | 1 -
 gdb/guile/scm-block.c                                | 1 -
 gdb/guile/scm-breakpoint.c                           | 1 -
 gdb/guile/scm-cmd.c                                  | 1 -
 gdb/guile/scm-disasm.c                               | 1 -
 gdb/guile/scm-exception.c                            | 1 -
 gdb/guile/scm-frame.c                                | 1 -
 gdb/guile/scm-gsmob.c                                | 1 -
 gdb/guile/scm-iterator.c                             | 1 -
 gdb/guile/scm-lazy-string.c                          | 1 -
 gdb/guile/scm-math.c                                 | 1 -
 gdb/guile/scm-objfile.c                              | 1 -
 gdb/guile/scm-param.c                                | 1 -
 gdb/guile/scm-ports.c                                | 1 -
 gdb/guile/scm-pretty-print.c                         | 1 -
 gdb/guile/scm-progspace.c                            | 1 -
 gdb/guile/scm-safe-call.c                            | 1 -
 gdb/guile/scm-string.c                               | 1 -
 gdb/guile/scm-symbol.c                               | 1 -
 gdb/guile/scm-symtab.c                               | 1 -
 gdb/guile/scm-type.c                                 | 1 -
 gdb/guile/scm-utils.c                                | 1 -
 gdb/guile/scm-value.c                                | 1 -
 gdb/h8300-tdep.c                                     | 1 -
 gdb/hppa-bsd-tdep.c                                  | 1 -
 gdb/hppa-linux-nat.c                                 | 1 -
 gdb/hppa-linux-tdep.c                                | 1 -
 gdb/hppa-netbsd-nat.c                                | 1 -
 gdb/hppa-netbsd-tdep.c                               | 1 -
 gdb/hppa-obsd-nat.c                                  | 1 -
 gdb/hppa-obsd-tdep.c                                 | 1 -
 gdb/hppa-tdep.c                                      | 1 -
 gdb/i386-bsd-nat.c                                   | 1 -
 gdb/i386-bsd-tdep.c                                  | 1 -
 gdb/i386-darwin-nat.c                                | 1 -
 gdb/i386-darwin-tdep.c                               | 1 -
 gdb/i386-dicos-tdep.c                                | 1 -
 gdb/i386-fbsd-nat.c                                  | 1 -
 gdb/i386-fbsd-tdep.c                                 | 1 -
 gdb/i386-gnu-nat.c                                   | 1 -
 gdb/i386-gnu-tdep.c                                  | 1 -
 gdb/i386-go32-tdep.c                                 | 1 -
 gdb/i386-linux-nat.c                                 | 1 -
 gdb/i386-linux-tdep.c                                | 1 -
 gdb/i386-netbsd-nat.c                                | 1 -
 gdb/i386-netbsd-tdep.c                               | 1 -
 gdb/i386-nto-tdep.c                                  | 1 -
 gdb/i386-obsd-nat.c                                  | 1 -
 gdb/i386-obsd-tdep.c                                 | 1 -
 gdb/i386-sol2-nat.c                                  | 1 -
 gdb/i386-sol2-tdep.c                                 | 1 -
 gdb/i386-tdep.c                                      | 1 -
 gdb/i386-windows-nat.c                               | 1 -
 gdb/i386-windows-tdep.c                              | 1 -
 gdb/i387-tdep.c                                      | 1 -
 gdb/ia64-libunwind-tdep.c                            | 1 -
 gdb/ia64-linux-nat.c                                 | 1 -
 gdb/ia64-linux-tdep.c                                | 1 -
 gdb/ia64-tdep.c                                      | 1 -
 gdb/ia64-vms-tdep.c                                  | 1 -
 gdb/inf-child.c                                      | 1 -
 gdb/inf-loop.c                                       | 1 -
 gdb/inf-ptrace.c                                     | 1 -
 gdb/infcall.c                                        | 1 -
 gdb/infcmd.c                                         | 1 -
 gdb/inferior.c                                       | 1 -
 gdb/inflow.c                                         | 1 -
 gdb/infrun.c                                         | 1 -
 gdb/inline-frame.c                                   | 1 -
 gdb/interps.c                                        | 1 -
 gdb/iq2000-tdep.c                                    | 1 -
 gdb/jit.c                                            | 1 -
 gdb/language.c                                       | 1 -
 gdb/linespec.c                                       | 1 -
 gdb/linux-fork.c                                     | 1 -
 gdb/linux-nat-trad.c                                 | 1 -
 gdb/linux-nat.c                                      | 1 -
 gdb/linux-record.c                                   | 1 -
 gdb/linux-tdep.c                                     | 1 -
 gdb/linux-thread-db.c                                | 1 -
 gdb/lm32-tdep.c                                      | 1 -
 gdb/location.c                                       | 1 -
 gdb/loongarch-linux-nat.c                            | 1 -
 gdb/loongarch-linux-tdep.c                           | 1 -
 gdb/loongarch-tdep.c                                 | 1 -
 gdb/m2-exp.y                                         | 1 -
 gdb/m2-lang.c                                        | 1 -
 gdb/m2-typeprint.c                                   | 1 -
 gdb/m2-valprint.c                                    | 1 -
 gdb/m32c-tdep.c                                      | 1 -
 gdb/m32r-linux-nat.c                                 | 1 -
 gdb/m32r-linux-tdep.c                                | 1 -
 gdb/m32r-tdep.c                                      | 1 -
 gdb/m68hc11-tdep.c                                   | 1 -
 gdb/m68k-bsd-nat.c                                   | 1 -
 gdb/m68k-bsd-tdep.c                                  | 1 -
 gdb/m68k-linux-nat.c                                 | 1 -
 gdb/m68k-linux-tdep.c                                | 1 -
 gdb/m68k-tdep.c                                      | 1 -
 gdb/machoread.c                                      | 1 -
 gdb/macrocmd.c                                       | 1 -
 gdb/macroexp.c                                       | 1 -
 gdb/macroscope.c                                     | 1 -
 gdb/macrotab.c                                       | 1 -
 gdb/main.c                                           | 1 -
 gdb/maint-test-options.c                             | 1 -
 gdb/maint-test-settings.c                            | 1 -
 gdb/maint.c                                          | 1 -
 gdb/make-init-c                                      | 1 -
 gdb/mdebugread.c                                     | 1 -
 gdb/mem-break.c                                      | 1 -
 gdb/memattr.c                                        | 1 -
 gdb/memory-map.c                                     | 1 -
 gdb/memrange.c                                       | 1 -
 gdb/memtag.c                                         | 1 -
 gdb/mep-tdep.c                                       | 1 -
 gdb/mi/mi-cmd-break.c                                | 1 -
 gdb/mi/mi-cmd-catch.c                                | 1 -
 gdb/mi/mi-cmd-disas.c                                | 1 -
 gdb/mi/mi-cmd-env.c                                  | 1 -
 gdb/mi/mi-cmd-file.c                                 | 1 -
 gdb/mi/mi-cmd-info.c                                 | 1 -
 gdb/mi/mi-cmd-stack.c                                | 1 -
 gdb/mi/mi-cmd-target.c                               | 1 -
 gdb/mi/mi-cmd-var.c                                  | 1 -
 gdb/mi/mi-cmds.c                                     | 1 -
 gdb/mi/mi-common.c                                   | 1 -
 gdb/mi/mi-console.c                                  | 1 -
 gdb/mi/mi-getopt.c                                   | 1 -
 gdb/mi/mi-interp.c                                   | 1 -
 gdb/mi/mi-main.c                                     | 1 -
 gdb/mi/mi-out.c                                      | 1 -
 gdb/mi/mi-parse.c                                    | 1 -
 gdb/mi/mi-symbol-cmds.c                              | 1 -
 gdb/microblaze-linux-tdep.c                          | 1 -
 gdb/microblaze-tdep.c                                | 1 -
 gdb/mingw-hdep.c                                     | 1 -
 gdb/minidebug.c                                      | 1 -
 gdb/minsyms.c                                        | 1 -
 gdb/mips-fbsd-nat.c                                  | 1 -
 gdb/mips-fbsd-tdep.c                                 | 1 -
 gdb/mips-linux-nat.c                                 | 1 -
 gdb/mips-linux-tdep.c                                | 1 -
 gdb/mips-netbsd-nat.c                                | 1 -
 gdb/mips-netbsd-tdep.c                               | 1 -
 gdb/mips-sde-tdep.c                                  | 1 -
 gdb/mips-tdep.c                                      | 1 -
 gdb/mips64-obsd-nat.c                                | 1 -
 gdb/mips64-obsd-tdep.c                               | 1 -
 gdb/mipsread.c                                       | 1 -
 gdb/mn10300-linux-tdep.c                             | 1 -
 gdb/mn10300-tdep.c                                   | 1 -
 gdb/moxie-tdep.c                                     | 1 -
 gdb/msp430-tdep.c                                    | 1 -
 gdb/namespace.c                                      | 1 -
 gdb/nat/aarch64-hw-point.c                           | 1 -
 gdb/nat/aarch64-linux-hw-point.c                     | 1 -
 gdb/nat/aarch64-linux.c                              | 1 -
 gdb/nat/aarch64-mte-linux-ptrace.c                   | 1 -
 gdb/nat/aarch64-scalable-linux-ptrace.c              | 1 -
 gdb/nat/amd64-linux-siginfo.c                        | 1 -
 gdb/nat/fork-inferior.c                              | 1 -
 gdb/nat/linux-btrace.c                               | 1 -
 gdb/nat/linux-namespaces.c                           | 1 -
 gdb/nat/linux-osdata.c                               | 1 -
 gdb/nat/linux-personality.c                          | 1 -
 gdb/nat/linux-procfs.c                               | 1 -
 gdb/nat/linux-ptrace.c                               | 1 -
 gdb/nat/linux-waitpid.c                              | 1 -
 gdb/nat/mips-linux-watch.c                           | 1 -
 gdb/nat/netbsd-nat.c                                 | 1 -
 gdb/nat/ppc-linux.c                                  | 1 -
 gdb/nat/riscv-linux-tdesc.c                          | 1 -
 gdb/nat/windows-nat.c                                | 1 -
 gdb/nat/x86-dregs.c                                  | 1 -
 gdb/nat/x86-linux-dregs.c                            | 1 -
 gdb/nat/x86-linux.c                                  | 1 -
 gdb/nat/x86-xstate.c                                 | 1 -
 gdb/nds32-tdep.c                                     | 1 -
 gdb/netbsd-nat.c                                     | 1 -
 gdb/netbsd-tdep.c                                    | 1 -
 gdb/nios2-linux-tdep.c                               | 1 -
 gdb/nios2-tdep.c                                     | 1 -
 gdb/nto-procfs.c                                     | 1 -
 gdb/nto-tdep.c                                       | 1 -
 gdb/objc-lang.c                                      | 1 -
 gdb/objfiles.c                                       | 1 -
 gdb/obsd-nat.c                                       | 1 -
 gdb/obsd-tdep.c                                      | 1 -
 gdb/observable.c                                     | 1 -
 gdb/opencl-lang.c                                    | 1 -
 gdb/or1k-linux-nat.c                                 | 1 -
 gdb/or1k-linux-tdep.c                                | 1 -
 gdb/or1k-tdep.c                                      | 1 -
 gdb/osabi.c                                          | 1 -
 gdb/osdata.c                                         | 1 -
 gdb/p-exp.y                                          | 1 -
 gdb/p-lang.c                                         | 1 -
 gdb/p-typeprint.c                                    | 1 -
 gdb/p-valprint.c                                     | 1 -
 gdb/parse.c                                          | 1 -
 gdb/posix-hdep.c                                     | 1 -
 gdb/ppc-fbsd-nat.c                                   | 1 -
 gdb/ppc-fbsd-tdep.c                                  | 1 -
 gdb/ppc-linux-nat.c                                  | 1 -
 gdb/ppc-linux-tdep.c                                 | 1 -
 gdb/ppc-netbsd-nat.c                                 | 1 -
 gdb/ppc-netbsd-tdep.c                                | 1 -
 gdb/ppc-obsd-nat.c                                   | 1 -
 gdb/ppc-obsd-tdep.c                                  | 1 -
 gdb/ppc-ravenscar-thread.c                           | 1 -
 gdb/ppc-sysv-tdep.c                                  | 1 -
 gdb/ppc64-tdep.c                                     | 1 -
 gdb/printcmd.c                                       | 1 -
 gdb/probe.c                                          | 1 -
 gdb/proc-api.c                                       | 1 -
 gdb/proc-events.c                                    | 1 -
 gdb/proc-flags.c                                     | 1 -
 gdb/proc-service.c                                   | 1 -
 gdb/proc-why.c                                       | 1 -
 gdb/process-stratum-target.c                         | 1 -
 gdb/procfs.c                                         | 1 -
 gdb/producer.c                                       | 1 -
 gdb/progspace-and-thread.c                           | 1 -
 gdb/progspace.c                                      | 1 -
 gdb/prologue-value.c                                 | 1 -
 gdb/psymtab.c                                        | 1 -
 gdb/python/py-arch.c                                 | 1 -
 gdb/python/py-auto-load.c                            | 1 -
 gdb/python/py-block.c                                | 1 -
 gdb/python/py-bpevent.c                              | 1 -
 gdb/python/py-breakpoint.c                           | 1 -
 gdb/python/py-cmd.c                                  | 1 -
 gdb/python/py-connection.c                           | 1 -
 gdb/python/py-continueevent.c                        | 1 -
 gdb/python/py-dap.c                                  | 1 -
 gdb/python/py-disasm.c                               | 1 -
 gdb/python/py-event.c                                | 1 -
 gdb/python/py-evtregistry.c                          | 1 -
 gdb/python/py-evts.c                                 | 1 -
 gdb/python/py-exitedevent.c                          | 1 -
 gdb/python/py-finishbreakpoint.c                     | 1 -
 gdb/python/py-frame.c                                | 1 -
 gdb/python/py-framefilter.c                          | 1 -
 gdb/python/py-function.c                             | 1 -
 gdb/python/py-gdb-readline.c                         | 1 -
 gdb/python/py-inferior.c                             | 1 -
 gdb/python/py-infevents.c                            | 1 -
 gdb/python/py-infthread.c                            | 1 -
 gdb/python/py-instruction.c                          | 1 -
 gdb/python/py-lazy-string.c                          | 1 -
 gdb/python/py-linetable.c                            | 1 -
 gdb/python/py-membuf.c                               | 1 -
 gdb/python/py-mi.c                                   | 1 -
 gdb/python/py-micmd.c                                | 1 -
 gdb/python/py-newobjfileevent.c                      | 1 -
 gdb/python/py-objfile.c                              | 1 -
 gdb/python/py-param.c                                | 1 -
 gdb/python/py-prettyprint.c                          | 1 -
 gdb/python/py-progspace.c                            | 1 -
 gdb/python/py-record-btrace.c                        | 1 -
 gdb/python/py-record-full.c                          | 1 -
 gdb/python/py-record.c                               | 1 -
 gdb/python/py-registers.c                            | 1 -
 gdb/python/py-signalevent.c                          | 1 -
 gdb/python/py-stopevent.c                            | 1 -
 gdb/python/py-symbol.c                               | 1 -
 gdb/python/py-symtab.c                               | 1 -
 gdb/python/py-threadevent.c                          | 1 -
 gdb/python/py-tui.c                                  | 1 -
 gdb/python/py-type.c                                 | 1 -
 gdb/python/py-unwind.c                               | 1 -
 gdb/python/py-utils.c                                | 1 -
 gdb/python/py-value.c                                | 1 -
 gdb/python/py-varobj.c                               | 1 -
 gdb/python/py-xmethods.c                             | 1 -
 gdb/python/python.c                                  | 1 -
 gdb/ravenscar-thread.c                               | 1 -
 gdb/record-btrace.c                                  | 1 -
 gdb/record-full.c                                    | 1 -
 gdb/record.c                                         | 1 -
 gdb/regcache-dump.c                                  | 1 -
 gdb/regcache.c                                       | 1 -
 gdb/reggroups.c                                      | 1 -
 gdb/remote-fileio.c                                  | 1 -
 gdb/remote-notif.c                                   | 1 -
 gdb/remote-sim.c                                     | 1 -
 gdb/remote.c                                         | 1 -
 gdb/reverse.c                                        | 1 -
 gdb/riscv-fbsd-nat.c                                 | 1 -
 gdb/riscv-fbsd-tdep.c                                | 1 -
 gdb/riscv-linux-nat.c                                | 1 -
 gdb/riscv-linux-tdep.c                               | 1 -
 gdb/riscv-none-tdep.c                                | 1 -
 gdb/riscv-ravenscar-thread.c                         | 1 -
 gdb/riscv-tdep.c                                     | 2 --
 gdb/rl78-tdep.c                                      | 1 -
 gdb/rs6000-aix-nat.c                                 | 1 -
 gdb/rs6000-aix-tdep.c                                | 1 -
 gdb/rs6000-lynx178-tdep.c                            | 1 -
 gdb/rs6000-tdep.c                                    | 1 -
 gdb/run-on-main-thread.c                             | 1 -
 gdb/rust-lang.c                                      | 1 -
 gdb/rust-parse.c                                     | 1 -
 gdb/rx-tdep.c                                        | 1 -
 gdb/s12z-tdep.c                                      | 1 -
 gdb/s390-linux-nat.c                                 | 1 -
 gdb/s390-linux-tdep.c                                | 1 -
 gdb/s390-tdep.c                                      | 1 -
 gdb/selftest-arch.c                                  | 1 -
 gdb/sentinel-frame.c                                 | 1 -
 gdb/ser-base.c                                       | 1 -
 gdb/ser-event.c                                      | 1 -
 gdb/ser-go32.c                                       | 1 -
 gdb/ser-mingw.c                                      | 1 -
 gdb/ser-pipe.c                                       | 1 -
 gdb/ser-tcp.c                                        | 1 -
 gdb/ser-uds.c                                        | 1 -
 gdb/ser-unix.c                                       | 1 -
 gdb/serial.c                                         | 1 -
 gdb/sh-linux-tdep.c                                  | 1 -
 gdb/sh-netbsd-nat.c                                  | 1 -
 gdb/sh-netbsd-tdep.c                                 | 1 -
 gdb/sh-tdep.c                                        | 1 -
 gdb/skip.c                                           | 1 -
 gdb/sol-thread.c                                     | 1 -
 gdb/sol2-tdep.c                                      | 1 -
 gdb/solib-aix.c                                      | 1 -
 gdb/solib-darwin.c                                   | 1 -
 gdb/solib-dsbt.c                                     | 1 -
 gdb/solib-frv.c                                      | 1 -
 gdb/solib-rocm.c                                     | 1 -
 gdb/solib-svr4.c                                     | 1 -
 gdb/solib-target.c                                   | 1 -
 gdb/solib.c                                          | 1 -
 gdb/source-cache.c                                   | 1 -
 gdb/source.c                                         | 1 -
 gdb/sparc-linux-nat.c                                | 1 -
 gdb/sparc-linux-tdep.c                               | 1 -
 gdb/sparc-nat.c                                      | 1 -
 gdb/sparc-netbsd-nat.c                               | 1 -
 gdb/sparc-netbsd-tdep.c                              | 1 -
 gdb/sparc-obsd-tdep.c                                | 1 -
 gdb/sparc-ravenscar-thread.c                         | 1 -
 gdb/sparc-sol2-nat.c                                 | 1 -
 gdb/sparc-sol2-tdep.c                                | 1 -
 gdb/sparc-tdep.c                                     | 1 -
 gdb/sparc64-fbsd-nat.c                               | 1 -
 gdb/sparc64-fbsd-tdep.c                              | 1 -
 gdb/sparc64-linux-nat.c                              | 1 -
 gdb/sparc64-linux-tdep.c                             | 1 -
 gdb/sparc64-nat.c                                    | 1 -
 gdb/sparc64-netbsd-nat.c                             | 1 -
 gdb/sparc64-netbsd-tdep.c                            | 1 -
 gdb/sparc64-obsd-nat.c                               | 1 -
 gdb/sparc64-obsd-tdep.c                              | 1 -
 gdb/sparc64-sol2-tdep.c                              | 1 -
 gdb/sparc64-tdep.c                                   | 1 -
 gdb/split-name.c                                     | 1 -
 gdb/stabsread.c                                      | 1 -
 gdb/stack.c                                          | 1 -
 gdb/stap-probe.c                                     | 1 -
 gdb/std-regs.c                                       | 1 -
 gdb/stub-termcap.c                                   | 1 -
 gdb/symfile-debug.c                                  | 1 -
 gdb/symfile-mem.c                                    | 1 -
 gdb/symfile.c                                        | 1 -
 gdb/symmisc.c                                        | 1 -
 gdb/symtab.c                                         | 1 -
 gdb/target-connection.c                              | 1 -
 gdb/target-dcache.c                                  | 1 -
 gdb/target-descriptions.c                            | 2 --
 gdb/target-float.c                                   | 1 -
 gdb/target-memory.c                                  | 1 -
 gdb/target.c                                         | 1 -
 gdb/target/target.c                                  | 1 -
 gdb/target/waitstatus.c                              | 1 -
 gdb/test-target.c                                    | 1 -
 gdb/thread-iter.c                                    | 1 -
 gdb/thread.c                                         | 1 -
 gdb/tic6x-linux-tdep.c                               | 1 -
 gdb/tic6x-tdep.c                                     | 1 -
 gdb/tid-parse.c                                      | 1 -
 gdb/tilegx-linux-nat.c                               | 1 -
 gdb/tilegx-linux-tdep.c                              | 1 -
 gdb/tilegx-tdep.c                                    | 1 -
 gdb/top.c                                            | 1 -
 gdb/tracectf.c                                       | 1 -
 gdb/tracefile-tfile.c                                | 1 -
 gdb/tracefile.c                                      | 1 -
 gdb/tracepoint.c                                     | 1 -
 gdb/trad-frame.c                                     | 1 -
 gdb/tramp-frame.c                                    | 1 -
 gdb/tui/tui-command.c                                | 1 -
 gdb/tui/tui-data.c                                   | 1 -
 gdb/tui/tui-disasm.c                                 | 1 -
 gdb/tui/tui-file.c                                   | 1 -
 gdb/tui/tui-hooks.c                                  | 1 -
 gdb/tui/tui-interp.c                                 | 1 -
 gdb/tui/tui-io.c                                     | 1 -
 gdb/tui/tui-layout.c                                 | 1 -
 gdb/tui/tui-location.c                               | 1 -
 gdb/tui/tui-regs.c                                   | 1 -
 gdb/tui/tui-source.c                                 | 1 -
 gdb/tui/tui-status.c                                 | 1 -
 gdb/tui/tui-win.c                                    | 1 -
 gdb/tui/tui-wingeneral.c                             | 1 -
 gdb/tui/tui-winsource.c                              | 1 -
 gdb/tui/tui.c                                        | 1 -
 gdb/type-stack.c                                     | 1 -
 gdb/typeprint.c                                      | 1 -
 gdb/ui-file.c                                        | 1 -
 gdb/ui-out.c                                         | 1 -
 gdb/ui-style.c                                       | 1 -
 gdb/ui.c                                             | 1 -
 gdb/unittests/array-view-selftests.c                 | 1 -
 gdb/unittests/child-path-selftests.c                 | 1 -
 gdb/unittests/cli-utils-selftests.c                  | 1 -
 gdb/unittests/command-def-selftests.c                | 1 -
 gdb/unittests/common-utils-selftests.c               | 1 -
 gdb/unittests/copy_bitwise-selftests.c               | 1 -
 gdb/unittests/enum-flags-selftests.c                 | 1 -
 gdb/unittests/environ-selftests.c                    | 1 -
 gdb/unittests/filtered_iterator-selftests.c          | 1 -
 gdb/unittests/format_pieces-selftests.c              | 1 -
 gdb/unittests/frame_info_ptr-selftests.c             | 1 -
 gdb/unittests/function-view-selftests.c              | 1 -
 gdb/unittests/gdb_tilde_expand-selftests.c           | 1 -
 gdb/unittests/gmp-utils-selftests.c                  | 1 -
 gdb/unittests/intrusive_list-selftests.c             | 1 -
 gdb/unittests/lookup_name_info-selftests.c           | 1 -
 gdb/unittests/main-thread-selftests.c                | 1 -
 gdb/unittests/memory-map-selftests.c                 | 1 -
 gdb/unittests/memrange-selftests.c                   | 1 -
 gdb/unittests/mkdir-recursive-selftests.c            | 1 -
 gdb/unittests/observable-selftests.c                 | 1 -
 gdb/unittests/offset-type-selftests.c                | 1 -
 gdb/unittests/packed-selftests.c                     | 1 -
 gdb/unittests/parallel-for-selftests.c               | 1 -
 gdb/unittests/parse-connection-spec-selftests.c      | 1 -
 gdb/unittests/path-join-selftests.c                  | 1 -
 gdb/unittests/ptid-selftests.c                       | 1 -
 gdb/unittests/rsp-low-selftests.c                    | 1 -
 gdb/unittests/scoped_fd-selftests.c                  | 1 -
 gdb/unittests/scoped_ignore_signal-selftests.c       | 1 -
 gdb/unittests/scoped_mmap-selftests.c                | 1 -
 gdb/unittests/scoped_restore-selftests.c             | 1 -
 gdb/unittests/search-memory-selftests.c              | 1 -
 gdb/unittests/style-selftests.c                      | 1 -
 gdb/unittests/tracepoint-selftests.c                 | 1 -
 gdb/unittests/tui-selftests.c                        | 1 -
 gdb/unittests/ui-file-selftests.c                    | 1 -
 gdb/unittests/unique_xmalloc_ptr_char.c              | 1 -
 gdb/unittests/unpack-selftests.c                     | 1 -
 gdb/unittests/utils-selftests.c                      | 1 -
 gdb/unittests/vec-utils-selftests.c                  | 1 -
 gdb/unittests/xml-utils-selftests.c                  | 1 -
 gdb/user-regs.c                                      | 1 -
 gdb/utils.c                                          | 1 -
 gdb/v850-tdep.c                                      | 1 -
 gdb/valarith.c                                       | 1 -
 gdb/valops.c                                         | 1 -
 gdb/valprint.c                                       | 1 -
 gdb/value.c                                          | 1 -
 gdb/varobj.c                                         | 1 -
 gdb/vax-bsd-nat.c                                    | 1 -
 gdb/vax-netbsd-tdep.c                                | 1 -
 gdb/vax-tdep.c                                       | 1 -
 gdb/windows-nat.c                                    | 1 -
 gdb/windows-tdep.c                                   | 1 -
 gdb/x86-bsd-nat.c                                    | 1 -
 gdb/x86-fbsd-nat.c                                   | 1 -
 gdb/x86-linux-nat.c                                  | 1 -
 gdb/x86-nat.c                                        | 1 -
 gdb/x86-tdep.c                                       | 1 -
 gdb/xcoffread.c                                      | 1 -
 gdb/xml-support.c                                    | 1 -
 gdb/xml-syscall.c                                    | 1 -
 gdb/xml-tdesc.c                                      | 1 -
 gdb/xstormy16-tdep.c                                 | 1 -
 gdb/xtensa-config.c                                  | 1 -
 gdb/xtensa-linux-nat.c                               | 1 -
 gdb/xtensa-linux-tdep.c                              | 1 -
 gdb/xtensa-tdep.c                                    | 1 -
 gdb/z80-tdep.c                                       | 1 -
 gdbserver/ax.cc                                      | 1 -
 gdbserver/debug.cc                                   | 1 -
 gdbserver/dll.cc                                     | 1 -
 gdbserver/fork-child.cc                              | 1 -
 gdbserver/hostio.cc                                  | 1 -
 gdbserver/i387-fp.cc                                 | 1 -
 gdbserver/inferiors.cc                               | 1 -
 gdbserver/linux-aarch32-low.cc                       | 1 -
 gdbserver/linux-aarch32-tdesc.cc                     | 1 -
 gdbserver/linux-aarch64-ipa.cc                       | 1 -
 gdbserver/linux-aarch64-low.cc                       | 1 -
 gdbserver/linux-aarch64-tdesc.cc                     | 1 -
 gdbserver/linux-amd64-ipa.cc                         | 1 -
 gdbserver/linux-arc-low.cc                           | 1 -
 gdbserver/linux-arm-low.cc                           | 1 -
 gdbserver/linux-arm-tdesc.cc                         | 1 -
 gdbserver/linux-csky-low.cc                          | 1 -
 gdbserver/linux-i386-ipa.cc                          | 1 -
 gdbserver/linux-ia64-low.cc                          | 1 -
 gdbserver/linux-loongarch-low.cc                     | 1 -
 gdbserver/linux-low.cc                               | 1 -
 gdbserver/linux-m68k-low.cc                          | 1 -
 gdbserver/linux-mips-low.cc                          | 1 -
 gdbserver/linux-nios2-low.cc                         | 1 -
 gdbserver/linux-or1k-low.cc                          | 1 -
 gdbserver/linux-ppc-ipa.cc                           | 1 -
 gdbserver/linux-ppc-low.cc                           | 1 -
 gdbserver/linux-riscv-low.cc                         | 1 -
 gdbserver/linux-s390-ipa.cc                          | 1 -
 gdbserver/linux-s390-low.cc                          | 1 -
 gdbserver/linux-sh-low.cc                            | 1 -
 gdbserver/linux-sparc-low.cc                         | 1 -
 gdbserver/linux-tic6x-low.cc                         | 1 -
 gdbserver/linux-x86-low.cc                           | 1 -
 gdbserver/linux-x86-tdesc.cc                         | 1 -
 gdbserver/linux-xtensa-low.cc                        | 1 -
 gdbserver/mem-break.cc                               | 1 -
 gdbserver/netbsd-aarch64-low.cc                      | 1 -
 gdbserver/netbsd-amd64-low.cc                        | 1 -
 gdbserver/netbsd-i386-low.cc                         | 1 -
 gdbserver/netbsd-low.cc                              | 1 -
 gdbserver/notif.cc                                   | 1 -
 gdbserver/proc-service.cc                            | 1 -
 gdbserver/regcache.cc                                | 1 -
 gdbserver/remote-utils.cc                            | 1 -
 gdbserver/server.cc                                  | 1 -
 gdbserver/symbol.cc                                  | 1 -
 gdbserver/target.cc                                  | 1 -
 gdbserver/tdesc.cc                                   | 1 -
 gdbserver/thread-db.cc                               | 1 -
 gdbserver/tracepoint.cc                              | 1 -
 gdbserver/utils.cc                                   | 1 -
 gdbserver/win32-i386-low.cc                          | 1 -
 gdbserver/win32-low.cc                               | 1 -
 gdbserver/x86-low.cc                                 | 1 -
 gdbsupport/agent.cc                                  | 1 -
 gdbsupport/btrace-common.cc                          | 1 -
 gdbsupport/cleanups.cc                               | 1 -
 gdbsupport/common-debug.cc                           | 1 -
 gdbsupport/common-exceptions.cc                      | 1 -
 gdbsupport/common-inferior.cc                        | 1 -
 gdbsupport/common-regcache.cc                        | 1 -
 gdbsupport/common-utils.cc                           | 1 -
 gdbsupport/environ.cc                                | 1 -
 gdbsupport/errors.cc                                 | 1 -
 gdbsupport/event-loop.cc                             | 1 -
 gdbsupport/event-pipe.cc                             | 1 -
 gdbsupport/fileio.cc                                 | 1 -
 gdbsupport/filestuff.cc                              | 1 -
 gdbsupport/format.cc                                 | 1 -
 gdbsupport/gdb-dlfcn.cc                              | 1 -
 gdbsupport/gdb-hashtab.cc                            | 1 -
 gdbsupport/gdb_obstack.cc                            | 1 -
 gdbsupport/gdb_regex.cc                              | 1 -
 gdbsupport/gdb_tilde_expand.cc                       | 1 -
 gdbsupport/gdb_vecs.cc                               | 1 -
 gdbsupport/gdb_wait.cc                               | 1 -
 gdbsupport/job-control.cc                            | 1 -
 gdbsupport/netstuff.cc                               | 1 -
 gdbsupport/new-op.cc                                 | 1 -
 gdbsupport/pathstuff.cc                              | 1 -
 gdbsupport/print-utils.cc                            | 1 -
 gdbsupport/ptid.cc                                   | 1 -
 gdbsupport/rsp-low.cc                                | 1 -
 gdbsupport/run-time-clock.cc                         | 1 -
 gdbsupport/safe-strerror.cc                          | 1 -
 gdbsupport/scoped_mmap.cc                            | 1 -
 gdbsupport/search.cc                                 | 1 -
 gdbsupport/selftest.cc                               | 1 -
 gdbsupport/signals-state-save-restore.cc             | 1 -
 gdbsupport/signals.cc                                | 1 -
 gdbsupport/task-group.cc                             | 1 -
 gdbsupport/tdesc.cc                                  | 1 -
 gdbsupport/thread-pool.cc                            | 1 -
 gdbsupport/xml-utils.cc                              | 1 -
 890 files changed, 1 insertion(+), 899 deletions(-)

diff --git a/gdb/aarch32-linux-nat.c b/gdb/aarch32-linux-nat.c
index 8c1b3ab49cc6..edff97b0ea9e 100644
--- a/gdb/aarch32-linux-nat.c
+++ b/gdb/aarch32-linux-nat.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "regcache.h"
 #include "arm-tdep.h"
diff --git a/gdb/aarch32-tdep.c b/gdb/aarch32-tdep.c
index 0b7783c3e15d..5a54a71ba4fd 100644
--- a/gdb/aarch32-tdep.c
+++ b/gdb/aarch32-tdep.c
@@ -15,8 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
-
 #include "aarch32-tdep.h"
 
 #include "gdbsupport/common-regcache.h"
diff --git a/gdb/aarch64-fbsd-nat.c b/gdb/aarch64-fbsd-nat.c
index 89ed12bb8e57..7ca8463ece85 100644
--- a/gdb/aarch64-fbsd-nat.c
+++ b/gdb/aarch64-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/aarch64-fbsd-tdep.c b/gdb/aarch64-fbsd-tdep.c
index 44ca6c90c818..e2ff57e83900 100644
--- a/gdb/aarch64-fbsd-tdep.c
+++ b/gdb/aarch64-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbarch.h"
 #include "fbsd-tdep.h"
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index cf7d5f8c6b14..3face34ce791 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 4ebc173a0a00..0b9784f38e4c 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbarch.h"
 #include "glibc-tdep.h"
diff --git a/gdb/aarch64-nat.c b/gdb/aarch64-nat.c
index 802bab6d6824..894fb73095b9 100644
--- a/gdb/aarch64-nat.c
+++ b/gdb/aarch64-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "inferior.h"
 #include "cli/cli-cmds.h"
diff --git a/gdb/aarch64-newlib-tdep.c b/gdb/aarch64-newlib-tdep.c
index c6370066aa35..4ac42a4ae268 100644
--- a/gdb/aarch64-newlib-tdep.c
+++ b/gdb/aarch64-newlib-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbarch.h"
 #include "aarch64-tdep.h"
diff --git a/gdb/aarch64-ravenscar-thread.c b/gdb/aarch64-ravenscar-thread.c
index 155641d5b7c5..5a877cde89da 100644
--- a/gdb/aarch64-ravenscar-thread.c
+++ b/gdb/aarch64-ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "aarch64-tdep.h"
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index d1d5486f90dd..545ec872fd86 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "frame.h"
 #include "language.h"
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 2b205714d7a3..b116f31104e8 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -35,7 +35,6 @@
 
 %{
 
-#include "defs.h"
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 493ef3b6c7d4..c9f12d72b70d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include <ctype.h>
 #include "gdbsupport/gdb_regex.h"
 #include "frame.h"
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 8ae94dcdbab2..864c5cfdf1c6 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "observable.h"
 #include "gdbcmd.h"
 #include "target.h"
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index df047d82fd64..deead1055dbf 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index ac85440b1396..6acfb9a48b69 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c
index 0a4c73f9c728..21412dbf2200 100644
--- a/gdb/ada-varobj.c
+++ b/gdb/ada-varobj.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ada-lang.h"
 #include "varobj.h"
 #include "language.h"
diff --git a/gdb/addrmap.c b/gdb/addrmap.c
index 162ab84763bb..0c60c0c2cebd 100644
--- a/gdb/addrmap.c
+++ b/gdb/addrmap.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "addrmap.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/agent.c b/gdb/agent.c
index a01b02cd4d38..00e75458a79e 100644
--- a/gdb/agent.c
+++ b/gdb/agent.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "command.h"
 #include "gdbcmd.h"
 #include "target.h"
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index c70bd82bc24e..0fe87b2b0809 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -39,7 +39,6 @@
 
      */
 
-#include "defs.h"
 #include "gdbthread.h"
 #include "target.h"
 #include "inferior.h"
diff --git a/gdb/alloc.c b/gdb/alloc.c
index 7c45c45ece38..d07c81f49553 100644
--- a/gdb/alloc.c
+++ b/gdb/alloc.c
@@ -27,14 +27,9 @@
    file can't live there.
 
    So, it lives in gdb and is built separately by gdb and gdbserver.
-   Please be aware of this when modifying it.
+   Please be aware of this when modifying it.  */
 
-   This also explains why this file includes common-defs.h and not
-   defs.h or server.h -- we'd prefer to avoid depending on the
-   GDBSERVER define when possible, and for this file it seemed
-   simple to do so.  */
 
-#include "gdbsupport/common-defs.h"
 #include "libiberty.h"
 #include "gdbsupport/errors.h"
 
diff --git a/gdb/alpha-bsd-nat.c b/gdb/alpha-bsd-nat.c
index 790958e33309..11e1639173a3 100644
--- a/gdb/alpha-bsd-nat.c
+++ b/gdb/alpha-bsd-nat.c
@@ -19,7 +19,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 
diff --git a/gdb/alpha-bsd-tdep.c b/gdb/alpha-bsd-tdep.c
index 03becf22d9f1..21e39cc937ca 100644
--- a/gdb/alpha-bsd-tdep.c
+++ b/gdb/alpha-bsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 
 #include "alpha-tdep.h"
diff --git a/gdb/alpha-linux-nat.c b/gdb/alpha-linux-nat.c
index 618b0c8140b7..83d6bc468584 100644
--- a/gdb/alpha-linux-nat.c
+++ b/gdb/alpha-linux-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "regcache.h"
 #include "linux-nat-trad.h"
diff --git a/gdb/alpha-linux-tdep.c b/gdb/alpha-linux-tdep.c
index 5f5e46d514e4..9a40e0cda111 100644
--- a/gdb/alpha-linux-tdep.c
+++ b/gdb/alpha-linux-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "osabi.h"
 #include "solib-svr4.h"
diff --git a/gdb/alpha-mdebug-tdep.c b/gdb/alpha-mdebug-tdep.c
index 7e9312d2aa73..abded2ac1921 100644
--- a/gdb/alpha-mdebug-tdep.c
+++ b/gdb/alpha-mdebug-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/alpha-netbsd-tdep.c b/gdb/alpha-netbsd-tdep.c
index 569fe42a2a94..f3cd62b0b58e 100644
--- a/gdb/alpha-netbsd-tdep.c
+++ b/gdb/alpha-netbsd-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "osabi.h"
diff --git a/gdb/alpha-obsd-tdep.c b/gdb/alpha-obsd-tdep.c
index 610866835c85..8602e21c64aa 100644
--- a/gdb/alpha-obsd-tdep.c
+++ b/gdb/alpha-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "osabi.h"
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index e5e0860fe241..c93bd69657f6 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index 3fdc3cd838af..fcde6d27ffb3 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "amd-dbgapi-target.h"
 #include "amdgpu-tdep.h"
diff --git a/gdb/amd64-bsd-nat.c b/gdb/amd64-bsd-nat.c
index ea9c0f47c6bf..e0ba28fa9fb8 100644
--- a/gdb/amd64-bsd-nat.c
+++ b/gdb/amd64-bsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/amd64-darwin-tdep.c b/gdb/amd64-darwin-tdep.c
index 001f5379def2..b0bead084fea 100644
--- a/gdb/amd64-darwin-tdep.c
+++ b/gdb/amd64-darwin-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/amd64-dicos-tdep.c b/gdb/amd64-dicos-tdep.c
index cc91b92f6dc0..7624289dc25d 100644
--- a/gdb/amd64-dicos-tdep.c
+++ b/gdb/amd64-dicos-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "amd64-tdep.h"
 #include "gdbsupport/x86-xstate.h"
diff --git a/gdb/amd64-fbsd-nat.c b/gdb/amd64-fbsd-nat.c
index 6a742034cbcd..6ce7c45b8b3c 100644
--- a/gdb/amd64-fbsd-nat.c
+++ b/gdb/amd64-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c
index a837bd197ffe..de295099052f 100644
--- a/gdb/amd64-fbsd-tdep.c
+++ b/gdb/amd64-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regset.h"
 #include "target.h"
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 0ee878f54018..aa9295d57230 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "elf/common.h"
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 1deb13b4e9ad..9d560ac4fbf4 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "gdbcore.h"
diff --git a/gdb/amd64-nat.c b/gdb/amd64-nat.c
index cb76658ab580..5c5c368c93d6 100644
--- a/gdb/amd64-nat.c
+++ b/gdb/amd64-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "regcache.h"
 
diff --git a/gdb/amd64-netbsd-nat.c b/gdb/amd64-netbsd-nat.c
index abd92abd77f7..8bd3e122e7b0 100644
--- a/gdb/amd64-netbsd-nat.c
+++ b/gdb/amd64-netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 
 #include "netbsd-nat.h"
diff --git a/gdb/amd64-netbsd-tdep.c b/gdb/amd64-netbsd-tdep.c
index 40500ee5f76c..264042059b73 100644
--- a/gdb/amd64-netbsd-tdep.c
+++ b/gdb/amd64-netbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "gdbcore.h"
diff --git a/gdb/amd64-obsd-nat.c b/gdb/amd64-obsd-nat.c
index 16c2c2d67a5e..717f6bd78677 100644
--- a/gdb/amd64-obsd-nat.c
+++ b/gdb/amd64-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c
index 6b37e8954ee4..f6f63bbf8ed0 100644
--- a/gdb/amd64-obsd-tdep.c
+++ b/gdb/amd64-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/amd64-ravenscar-thread.c b/gdb/amd64-ravenscar-thread.c
index a97ed3c43cf1..a0de0d731351 100644
--- a/gdb/amd64-ravenscar-thread.c
+++ b/gdb/amd64-ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/amd64-sol2-tdep.c b/gdb/amd64-sol2-tdep.c
index 6cc84017f740..070d7ed324bd 100644
--- a/gdb/amd64-sol2-tdep.c
+++ b/gdb/amd64-sol2-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 60d6b7aa1988..0bb7a24cbd08 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "opcode/i386.h"
 #include "dis-asm.h"
diff --git a/gdb/amd64-windows-nat.c b/gdb/amd64-windows-nat.c
index b4625b2f0ded..a282762d027b 100644
--- a/gdb/amd64-windows-nat.c
+++ b/gdb/amd64-windows-nat.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "windows-nat.h"
 #include "x86-nat.h"
 #include "amd64-tdep.h"
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index af17886c0806..a559d967b3c9 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "amd64-tdep.h"
 #include "gdbsupport/x86-xstate.h"
diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
index ac137d9acc44..49996aeefc33 100644
--- a/gdb/amdgpu-tdep.c
+++ b/gdb/amdgpu-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "amd-dbgapi-target.h"
 #include "amdgpu-tdep.h"
diff --git a/gdb/annotate.c b/gdb/annotate.c
index 468b9698f023..19195ac70970 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "annotate.h"
 #include "value.h"
 #include "target.h"
diff --git a/gdb/arc-linux-nat.c b/gdb/arc-linux-nat.c
index 9f8125f8a235..66f00008089d 100644
--- a/gdb/arc-linux-nat.c
+++ b/gdb/arc-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
index ca630ab6df0c..54406ac5b907 100644
--- a/gdb/arc-linux-tdep.c
+++ b/gdb/arc-linux-tdep.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* GDB header files.  */
-#include "defs.h"
 #include "linux-tdep.h"
 #include "objfiles.h"
 #include "opcode/arc.h"
diff --git a/gdb/arc-newlib-tdep.c b/gdb/arc-newlib-tdep.c
index 2efea56a7c4a..dbc096142b5f 100644
--- a/gdb/arc-newlib-tdep.c
+++ b/gdb/arc-newlib-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbarch.h"
 #include "arc-tdep.h"
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 63a1fd918d1f..5684f324233c 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -19,7 +19,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* GDB header files.  */
-#include "defs.h"
 #include "arch-utils.h"
 #include "elf-bfd.h"
 #include "disasm.h"
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index d404d1fc38a3..456bfe971ffa 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "arch-utils.h"
 #include "gdbcmd.h"
diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c
index 9f3e25088f41..ead368f5fb59 100644
--- a/gdb/arch/aarch32.c
+++ b/gdb/arch/aarch32.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "aarch32.h"
 
 #include "../features/arm/arm-core.c"
diff --git a/gdb/arch/aarch64-insn.c b/gdb/arch/aarch64-insn.c
index 65a2841eef5a..3caef45df70b 100644
--- a/gdb/arch/aarch64-insn.c
+++ b/gdb/arch/aarch64-insn.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "aarch64-insn.h"
 
 /* Toggle this file's internal debugging dump.  */
diff --git a/gdb/arch/aarch64-mte-linux.h b/gdb/arch/aarch64-mte-linux.h
index e0f4a9845b52..460b10e05c97 100644
--- a/gdb/arch/aarch64-mte-linux.h
+++ b/gdb/arch/aarch64-mte-linux.h
@@ -20,7 +20,6 @@
 #ifndef ARCH_AARCH64_MTE_LINUX_H
 #define ARCH_AARCH64_MTE_LINUX_H
 
-#include "gdbsupport/common-defs.h"
 
 /* Feature check for Memory Tagging Extension.  */
 #ifndef HWCAP2_MTE
diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h
index 43577c43797f..4d2ace8f153b 100644
--- a/gdb/arch/aarch64-scalable-linux.h
+++ b/gdb/arch/aarch64-scalable-linux.h
@@ -21,7 +21,6 @@
 #ifndef ARCH_AARCH64_SCALABLE_LINUX_H
 #define ARCH_AARCH64_SCALABLE_LINUX_H
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/common-regcache.h"
 
 /* Feature check for Scalable Matrix Extension.  */
diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c
index dfa4f592ef73..5526aa1b580b 100644
--- a/gdb/arch/aarch64.c
+++ b/gdb/arch/aarch64.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "aarch64.h"
 #include <stdlib.h>
 
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
index b8ff42700797..cb9683c6931f 100644
--- a/gdb/arch/amd64.c
+++ b/gdb/arch/amd64.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "amd64.h"
 #include "gdbsupport/x86-xstate.h"
 #include <stdlib.h>
diff --git a/gdb/arch/arc.c b/gdb/arch/arc.c
index aeb476df1a00..e807b60539f6 100644
--- a/gdb/arch/arc.c
+++ b/gdb/arch/arc.c
@@ -16,7 +16,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "gdbsupport/common-defs.h"
 #include "arc.h"
 #include <stdlib.h>
 #include <unordered_map>
diff --git a/gdb/arch/arm-get-next-pcs.c b/gdb/arch/arm-get-next-pcs.c
index 3657ac799c31..03115cf21387 100644
--- a/gdb/arch/arm-get-next-pcs.c
+++ b/gdb/arch/arm-get-next-pcs.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbsupport/common-regcache.h"
 #include "arm.h"
diff --git a/gdb/arch/arm-linux.c b/gdb/arch/arm-linux.c
index 80c3cdd2e338..246bade658fe 100644
--- a/gdb/arch/arm-linux.c
+++ b/gdb/arch/arm-linux.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/common-regcache.h"
 #include "arch/arm.h"
 #include "arm-linux.h"
diff --git a/gdb/arch/arm.c b/gdb/arch/arm.c
index 111803027d77..f1c292b44c9b 100644
--- a/gdb/arch/arm.c
+++ b/gdb/arch/arm.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/common-regcache.h"
 #include "arm.h"
 
diff --git a/gdb/arch/csky.c b/gdb/arch/csky.c
index 3ecba618764c..32df2ade7183 100644
--- a/gdb/arch/csky.c
+++ b/gdb/arch/csky.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "csky.h"
 #include <stdlib.h>
 
diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c
index 0e46b6afd5f7..f3165c5b7f0c 100644
--- a/gdb/arch/i386.c
+++ b/gdb/arch/i386.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "i386.h"
 #include "gdbsupport/tdesc.h"
 #include "gdbsupport/x86-xstate.h"
diff --git a/gdb/arch/loongarch.c b/gdb/arch/loongarch.c
index 22f2d3936cab..04b6dfc82794 100644
--- a/gdb/arch/loongarch.c
+++ b/gdb/arch/loongarch.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "loongarch.h"
 #include <stdlib.h>
 #include <unordered_map>
diff --git a/gdb/arch/ppc-linux-common.c b/gdb/arch/ppc-linux-common.c
index e67327872b6f..0a6915cdc097 100644
--- a/gdb/arch/ppc-linux-common.c
+++ b/gdb/arch/ppc-linux-common.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "arch/ppc-linux-common.h"
 #include "arch/ppc-linux-tdesc.h"
 
diff --git a/gdb/arch/riscv.c b/gdb/arch/riscv.c
index cafcda50e54b..9a84844a6456 100644
--- a/gdb/arch/riscv.c
+++ b/gdb/arch/riscv.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "riscv.h"
 #include <stdlib.h>
 #include <unordered_map>
diff --git a/gdb/arch/tic6x.c b/gdb/arch/tic6x.c
index dea409a39469..680a79420708 100644
--- a/gdb/arch/tic6x.c
+++ b/gdb/arch/tic6x.c
@@ -17,7 +17,6 @@
 
 #include "gdbsupport/tdesc.h"
 #include "tic6x.h"
-#include "gdbsupport/common-defs.h"
 
 #include "../features/tic6x-core.c"
 #include "../features/tic6x-gp.c"
diff --git a/gdb/arm-bsd-tdep.c b/gdb/arm-bsd-tdep.c
index 1a9ebcf202cc..1ccabcb24f06 100644
--- a/gdb/arm-bsd-tdep.c
+++ b/gdb/arm-bsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/arm-fbsd-nat.c b/gdb/arm-fbsd-nat.c
index 80c901842ee5..cbe9867f49d2 100644
--- a/gdb/arm-fbsd-nat.c
+++ b/gdb/arm-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "target.h"
 
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index 7b82de2166b5..dfb75329cd8c 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "elf/common.h"
 #include "target-descriptions.h"
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 75f498cd5b3f..50c24ecfcd2e 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index a8b27a7463a6..8511abcd11d6 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "value.h"
 #include "gdbtypes.h"
diff --git a/gdb/arm-netbsd-nat.c b/gdb/arm-netbsd-nat.c
index 4b9f92946412..37f6530a0fe8 100644
--- a/gdb/arm-netbsd-nat.c
+++ b/gdb/arm-netbsd-nat.c
@@ -19,7 +19,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/arm-netbsd-tdep.c b/gdb/arm-netbsd-tdep.c
index 829e1d3d4b8b..f77fec7894ab 100644
--- a/gdb/arm-netbsd-tdep.c
+++ b/gdb/arm-netbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 
 #include "arch/arm.h"
diff --git a/gdb/arm-none-tdep.c b/gdb/arm-none-tdep.c
index 72eff2c0b170..453e75234d4b 100644
--- a/gdb/arm-none-tdep.c
+++ b/gdb/arm-none-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arm-tdep.h"
 #include "arch-utils.h"
 #include "regcache.h"
diff --git a/gdb/arm-obsd-tdep.c b/gdb/arm-obsd-tdep.c
index 0bdecec3b6fb..56102b038158 100644
--- a/gdb/arm-obsd-tdep.c
+++ b/gdb/arm-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "trad-frame.h"
 #include "tramp-frame.h"
diff --git a/gdb/arm-pikeos-tdep.c b/gdb/arm-pikeos-tdep.c
index 5354af6ac7bf..4760755a32a9 100644
--- a/gdb/arm-pikeos-tdep.c
+++ b/gdb/arm-pikeos-tdep.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "arm-tdep.h"
 #include "osabi.h"
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 3a5fbe71b8b5..b4062a8f9225 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include <ctype.h>
 
diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c
index b722851e7e1a..eab496c2c0bd 100644
--- a/gdb/arm-wince-tdep.c
+++ b/gdb/arm-wince-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "gdbcore.h"
 #include "target.h"
diff --git a/gdb/async-event.c b/gdb/async-event.c
index 7097c482fff2..32b58652e585 100644
--- a/gdb/async-event.c
+++ b/gdb/async-event.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "async-event.h"
 
 #include "ser-event.h"
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index a097a3bd2f4b..db6d6ae0f73d 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "auto-load.h"
 #include "progspace.h"
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 323ea831d54e..1dc0587c0075 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "gdbtypes.h"
 #include "command.h"
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 2d38f41cd7fa..be95034abd5c 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -22,7 +22,6 @@
 /* Portions of this file were taken from the original gdb-4.18 patch developed
    by Denis Chertykov, denisc@overta.ru */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index f6d2bc5772b3..ae0992a298a3 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "symfile.h"
 #include "gdbtypes.h"
diff --git a/gdb/ax-general.c b/gdb/ax-general.c
index 19c684c04e01..3d007456a52e 100644
--- a/gdb/ax-general.c
+++ b/gdb/ax-general.c
@@ -21,7 +21,6 @@
    dependencies, since we want to be able to use them in contexts
    outside of GDB (test suites, the stub, etc.)  */
 
-#include "defs.h"
 #include "ax.h"
 #include "gdbarch.h"
 
diff --git a/gdb/bcache.c b/gdb/bcache.c
index 674ba796833e..a9aab28ab841 100644
--- a/gdb/bcache.c
+++ b/gdb/bcache.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bcache.h"
 
diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c
index 296e767d0266..96e045e4e52f 100644
--- a/gdb/bfd-target.c
+++ b/gdb/bfd-target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "bfd-target.h"
 #include "exec.h"
diff --git a/gdb/bfin-linux-tdep.c b/gdb/bfin-linux-tdep.c
index 31aa14765ae8..f67e06478eb1 100644
--- a/gdb/bfin-linux-tdep.c
+++ b/gdb/bfin-linux-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "regcache.h"
 #include "tramp-frame.h"
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index 357866ef9532..dbc339d93366 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "arch-utils.h"
diff --git a/gdb/block.c b/gdb/block.c
index 6d0d33fa85ed..511689c9738f 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "block.h"
 #include "symtab.h"
 #include "symfile.h"
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 451818332de3..b7c751300cbf 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "bfd.h"
 #include "objfiles.h"
diff --git a/gdb/bpf-tdep.c b/gdb/bpf-tdep.c
index 1b3f3e72c5b7..098a08aa7e7c 100644
--- a/gdb/bpf-tdep.c
+++ b/gdb/bpf-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "frame.h"
diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index 35b126ce9048..bd412fccdb73 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "annotate.h"
 #include "arch-utils.h"
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index 9417babdbd15..afbd84741f21 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "annotate.h"
 #include "arch-utils.h"
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 9582a7ccaad4..ce30b6fd4275 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "annotate.h"
 #include "arch-utils.h"
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index b1cee147ef1f..f077fa29a0c1 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
 #include "breakpoint.h"
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index e5ddd835c92b..a0e6e6788fe8 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "breakpoint.h"
 #include "gdbcmd.h"
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index d053bd5fbe02..ce614ac8fe37 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
 #include "breakpoint.h"
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 102bd7fad419..b59d4582ec92 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
 #include "hashtab.h"
diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c
index 76021df1ed5f..a1020b05b193 100644
--- a/gdb/bsd-kvm.c
+++ b/gdb/bsd-kvm.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #define _KMEMUSER
-#include "defs.h"
 #include "cli/cli-cmds.h"
 #include "command.h"
 #include "filenames.h"
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 10e2ca5939e7..576a9ec1cfbb 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
 #include "inferior.h"
diff --git a/gdb/bt-utils.c b/gdb/bt-utils.c
index 6f68e269c511..cbca4a9b7b8e 100644
--- a/gdb/bt-utils.c
+++ b/gdb/bt-utils.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bt-utils.h"
 #include "command.h"
 #include "gdbcmd.h"
diff --git a/gdb/btrace.c b/gdb/btrace.c
index b5a047b245b0..04ae3fd0b5eb 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "btrace.h"
 #include "gdbthread.h"
 #include "inferior.h"
diff --git a/gdb/build-id.c b/gdb/build-id.c
index a40c56087ed1..d1ebd8d37d77 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "gdb_bfd.h"
 #include "build-id.h"
diff --git a/gdb/buildsym-legacy.c b/gdb/buildsym-legacy.c
index 84bc96e843bc..a2d786b48774 100644
--- a/gdb/buildsym-legacy.c
+++ b/gdb/buildsym-legacy.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "buildsym-legacy.h"
 #include "symtab.h"
 
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 506110989bf5..1c762ad81bfd 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "buildsym-legacy.h"
 #include "bfd.h"
 #include "gdbsupport/gdb_obstack.h"
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index fb85914805cf..459a4cf1e8f2 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -35,7 +35,6 @@
 
 %{
 
-#include "defs.h"
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index cc33aad088ed..922bf8c0de34 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index da269dae13b1..3e299356308c 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
 #include "symtab.h"
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 8911a1696049..28a6a6afea2f 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 4a7476449097..4751f0a957a6 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "varobj.h"
 #include "gdbthread.h"
diff --git a/gdb/charset.c b/gdb/charset.c
index 2b759495f17b..4c1debef6143 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "gdbcmd.h"
 #include "gdbsupport/gdb_obstack.h"
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 2a1e72125f9c..1c303f096626 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ui-out.h"
 #include "cli-out.h"
 #include "completer.h"
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index df11f956245c..3afe2178199e 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "readline/tilde.h"
 #include "completer.h"
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index bbabd40db071..d9a2ab40575a 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include <ctype.h>
 #include "gdbsupport/gdb_regex.h"
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 765117bcbb50..9b44c6edcf21 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-cmds.h"
 #include "value.h"
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index a0bf32fd5857..7cefc3902d8c 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli-interp.h"
 #include "interps.h"
 #include "event-top.h"
diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c
index 7c337c808e75..2b3572885855 100644
--- a/gdb/cli/cli-logging.c
+++ b/gdb/cli/cli-logging.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "ui-out.h"
 #include "interps.h"
diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c
index 3ef210e53d3e..05539285c80d 100644
--- a/gdb/cli/cli-option.c
+++ b/gdb/cli/cli-option.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-option.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-utils.h"
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index f06724af325a..2f731807c94f 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include <ctype.h>
 
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index b1ad11cc61b4..bcc793b31480 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "readline/tilde.h"
 #include "value.h"
 #include <ctype.h>
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 2fccc72b1029..5928998e9cae 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-setshow.h"
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index c3206c4f3fa3..45b30842e005 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-utils.h"
 #include "value.h"
 
diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c
index 271076e6d8d9..43700d96ec36 100644
--- a/gdb/coff-pe-read.c
+++ b/gdb/coff-pe-read.c
@@ -21,7 +21,6 @@
 
    Contributed by Raoul M. Gough (RaoulGough@yahoo.co.uk).  */
 
-#include "defs.h"
 
 #include "coff-pe-read.h"
 
diff --git a/gdb/coffread.c b/gdb/coffread.c
index abb1c1880d68..327c014a5a4c 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "demangle.h"
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c
index 72e7bfe1484a..a152e5ace614 100644
--- a/gdb/compile/compile-c-support.c
+++ b/gdb/compile/compile-c-support.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "compile-internal.h"
 #include "compile-c.h"
 #include "compile-cplus.h"
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 804a0a01377e..20e8550b3f7e 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "compile-internal.h"
 #include "compile-c.h"
 #include "symtab.h"
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index 1243be369f83..6407f1243bea 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "compile-internal.h"
 #include "compile-c.h"
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index c4355b83c7fd..c95c86f37756 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "compile-internal.h"
 #include "compile-cplus.h"
 #include "gdbsupport/gdb_assert.h"
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index c8a255153591..212db680482b 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "gdbsupport/preprocessor.h"
 #include "gdbtypes.h"
 #include "compile-internal.h"
diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c
index da3a84e00807..fbcc3d6340b2 100644
--- a/gdb/compile/compile-loc2c.c
+++ b/gdb/compile/compile-loc2c.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2.h"
 #include "objfiles.h"
 #include "dwarf2/expr.h"
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 33971a51a711..d1b5d5947a67 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "compile-object-load.h"
 #include "compile-internal.h"
 #include "command.h"
diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c
index a3ac376f38f7..5a810d5a16d4 100644
--- a/gdb/compile/compile-object-run.c
+++ b/gdb/compile/compile-object-run.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "compile-object-run.h"
 #include "value.h"
 #include "infcall.h"
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 27cff2553eed..2d97a1b2005f 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ui.h"
 #include "ui-out.h"
 #include "command.h"
diff --git a/gdb/complaints.c b/gdb/complaints.c
index 496736fe95f9..e375c7348848 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "complaints.h"
 #include "command.h"
 #include "gdbcmd.h"
diff --git a/gdb/completer.c b/gdb/completer.c
index 168fab74d149..fedf65d1cc01 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/copying.awk b/gdb/copying.awk
index bbeb2664f4c6..0babd8342693 100644
--- a/gdb/copying.awk
+++ b/gdb/copying.awk
@@ -6,7 +6,6 @@ BEGIN	{
 	  print "   It is created automatically by copying.awk.";
 	  print "   Modify copying.awk instead.  <== */";
 	  print ""
-	  print "#include \"defs.h\""
 	  print "#include \"command.h\""
 	  print "#include \"gdbcmd.h\""
 	  print ""
diff --git a/gdb/copying.c b/gdb/copying.c
index a66a55b73ea3..bc45fe0dc3a5 100644
--- a/gdb/copying.c
+++ b/gdb/copying.c
@@ -2,7 +2,6 @@
    It is created automatically by copying.awk.
    Modify copying.awk instead.  <== */
 
-#include "defs.h"
 #include "command.h"
 #include "gdbcmd.h"
 
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 169d4229e9c1..16cd60f7106d 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <signal.h>
 #include <fcntl.h>
 #include "inferior.h"
diff --git a/gdb/corelow.c b/gdb/corelow.c
index f291b2aba191..f4e8273d9622 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <signal.h>
 #include <fcntl.h>
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index 882c1a03fe29..a813b4ad15cc 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "value.h"
 #include "cp-abi.h"
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 701ec25e3344..87f13445bbaf 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -37,7 +37,6 @@
 
 %{
 
-#include "defs.h"
 
 #include <unistd.h>
 #include "gdbsupport/gdb-safe-ctype.h"
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index fb9fcf8ed6e8..ec72d72b5a78 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cp-support.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 6b7c2f5a0628..e6e811ddf503 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cp-support.h"
 #include "language.h"
 #include "demangle.h"
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index d7fce64408d7..f2a2ca5288da 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/cris-linux-tdep.c b/gdb/cris-linux-tdep.c
index d46f3e846489..7ec5505fba8e 100644
--- a/gdb/cris-linux-tdep.c
+++ b/gdb/cris-linux-tdep.c
@@ -21,7 +21,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "linux-tdep.h"
 #include "solib-svr4.h"
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 02c35da723d4..dd013d531abb 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/csky-linux-tdep.c b/gdb/csky-linux-tdep.c
index d485f1763178..a703b389d2ea 100644
--- a/gdb/csky-linux-tdep.c
+++ b/gdb/csky-linux-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "glibc-tdep.h"
 #include "linux-tdep.h"
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index c1ce8a5b02ce..5f0fd3d7170d 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_assert.h"
 #include "frame.h"
 #include "inferior.h"
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index cbb8c3f2b8a6..d8606d3c0611 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -75,7 +75,6 @@
    already in the symbol table, and the CTF string table does not contain any
    duplicated strings.  */
 
-#include "defs.h"
 #include "buildsym.h"
 #include "complaints.h"
 #include "block.h"
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index 620d900709c4..b2adad24d1a9 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -38,7 +38,6 @@
 
 %{
 
-#include "defs.h"
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 6af57062ef96..d4f9956bc9ee 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "language.h"
 #include "varobj.h"
diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c
index 3f8f7d8c24e1..0bcd75dac10c 100644
--- a/gdb/d-namespace.c
+++ b/gdb/d-namespace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "block.h"
 #include "language.h"
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index 2cdbf5ae09b5..543bb193f615 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
 #include "d-lang.h"
diff --git a/gdb/darwin-nat-info.c b/gdb/darwin-nat-info.c
index 48868c8115ec..3d3e47c998a3 100644
--- a/gdb/darwin-nat-info.c
+++ b/gdb/darwin-nat-info.c
@@ -27,7 +27,6 @@
    the future.  It'd be good to remove this at some point when compiling on
    Tiger is no longer important.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 0eb49d8734ae..0c5b54b40a3b 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 1734e8062fb1..9faaf0e7381b 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -30,7 +30,6 @@
    fledged symbol table by going back and reading the symbols
    for real.  dbx_psymtab_to_symtab() is the function that does this */
 
-#include "defs.h"
 
 #include "gdbsupport/gdb_obstack.h"
 #include <sys/stat.h>
diff --git a/gdb/dcache.c b/gdb/dcache.c
index 57b39c0e51ea..ae08f3518c11 100644
--- a/gdb/dcache.c
+++ b/gdb/dcache.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dcache.h"
 #include "gdbcmd.h"
 #include "gdbcore.h"
diff --git a/gdb/debug.c b/gdb/debug.c
index 56725b68b316..f7d245126854 100644
--- a/gdb/debug.c
+++ b/gdb/debug.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbsupport/common-debug.h"
 
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 9bb3748c8c3b..841b6f2078c7 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "diagnostics.h"
 #include <errno.h>
 #include "gdbsupport/scoped_fd.h"
diff --git a/gdb/dicos-tdep.c b/gdb/dicos-tdep.c
index 950a7d617bf5..3627426eee75 100644
--- a/gdb/dicos-tdep.c
+++ b/gdb/dicos-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "solib.h"
 #include "solib-target.h"
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index 8e7eb420cc6f..6925ad4d46ce 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c
index f288707669dd..14b7fb30badf 100644
--- a/gdb/disasm-selftests.c
+++ b/gdb/disasm-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "disasm.h"
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
diff --git a/gdb/disasm.c b/gdb/disasm.c
index cafbc078c60d..da6f3afba7a1 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "target.h"
 #include "value.h"
diff --git a/gdb/displaced-stepping.c b/gdb/displaced-stepping.c
index e727c6d5662e..7869ebae7714 100644
--- a/gdb/displaced-stepping.c
+++ b/gdb/displaced-stepping.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "displaced-stepping.h"
 
 #include "cli/cli-cmds.h"
diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index 5757de1cf77d..ad1a3f870b63 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "probe.h"
 #include "elf-bfd.h"
 #include "gdbtypes.h"
diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
index 5969ef2cdadd..7d72fe032ee1 100644
--- a/gdb/dummy-frame.c
+++ b/gdb/dummy-frame.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "dummy-frame.h"
 #include "regcache.h"
 #include "frame.h"
diff --git a/gdb/dwarf2/abbrev-cache.c b/gdb/dwarf2/abbrev-cache.c
index 01ff203aeee4..b87206c2c4ee 100644
--- a/gdb/dwarf2/abbrev-cache.c
+++ b/gdb/dwarf2/abbrev-cache.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/read.h"
 #include "dwarf2/abbrev-cache.h"
 
diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c
index d68a86ef178f..359a0094872a 100644
--- a/gdb/dwarf2/abbrev.c
+++ b/gdb/dwarf2/abbrev.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/read.h"
 #include "dwarf2/abbrev.h"
 #include "dwarf2/leb.h"
diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c
index 065e2b90a0f4..9ec0d51e9205 100644
--- a/gdb/dwarf2/ada-imported.c
+++ b/gdb/dwarf2/ada-imported.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "value.h"
 #include "dwarf2/loc.h"
diff --git a/gdb/dwarf2/aranges.c b/gdb/dwarf2/aranges.c
index 4287a5a884b0..d577db627260 100644
--- a/gdb/dwarf2/aranges.c
+++ b/gdb/dwarf2/aranges.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/aranges.h"
 #include "dwarf2/read.h"
 
diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c
index 6b8f1c95ce7a..f777c1454e65 100644
--- a/gdb/dwarf2/attribute.c
+++ b/gdb/dwarf2/attribute.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/attribute.h"
 #include "dwarf2/stringify.h"
 #include "complaints.h"
diff --git a/gdb/dwarf2/comp-unit-head.c b/gdb/dwarf2/comp-unit-head.c
index 5a8279514855..a26a6c0cd58f 100644
--- a/gdb/dwarf2/comp-unit-head.c
+++ b/gdb/dwarf2/comp-unit-head.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/comp-unit-head.h"
 #include "dwarf2/leb.h"
 #include "dwarf2/read.h"
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 2a1ca6fd225d..ca42adc92f13 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/cooked-index.h"
 #include "dwarf2/read.h"
 #include "dwarf2/stringify.h"
diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c
index 62c0a8a3ede4..a64cb1d8380f 100644
--- a/gdb/dwarf2/cu.c
+++ b/gdb/dwarf2/cu.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/cu.h"
 #include "dwarf2/read.h"
 #include "objfiles.h"
diff --git a/gdb/dwarf2/die.c b/gdb/dwarf2/die.c
index 4bdf02be429f..bfa54e517abb 100644
--- a/gdb/dwarf2/die.c
+++ b/gdb/dwarf2/die.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/die.h"
 #include "dwarf2/stringify.h"
 
diff --git a/gdb/dwarf2/dwz.c b/gdb/dwarf2/dwz.c
index f53a5b64c4a3..1eb4816fb479 100644
--- a/gdb/dwarf2/dwz.c
+++ b/gdb/dwarf2/dwz.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/dwz.h"
 
 #include "build-id.h"
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index d0256e7009d9..d92facbf0dcf 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "block.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/dwarf2/frame-tailcall.c b/gdb/dwarf2/frame-tailcall.c
index 2f6400d62c38..bcbe41f7933c 100644
--- a/gdb/dwarf2/frame-tailcall.c
+++ b/gdb/dwarf2/frame-tailcall.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "dwarf2/frame-tailcall.h"
 #include "dwarf2/loc.h"
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 530513c2684e..9ebf3ac4ac47 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/expr.h"
 #include "dwarf2.h"
 #include "dwarf2/leb.h"
diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
index d9047ef46bb2..1720e925ee60 100644
--- a/gdb/dwarf2/index-cache.c
+++ b/gdb/dwarf2/index-cache.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/index-cache.h"
 
 #include "build-id.h"
diff --git a/gdb/dwarf2/index-common.c b/gdb/dwarf2/index-common.c
index 515093a63d32..08b2f3746193 100644
--- a/gdb/dwarf2/index-common.c
+++ b/gdb/dwarf2/index-common.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/index-common.h"
 
 /* See dwarf-index-common.h.  */
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index a114001f4eec..3f812285995d 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "dwarf2/index-write.h"
 
diff --git a/gdb/dwarf2/leb.c b/gdb/dwarf2/leb.c
index 7e10dc16e59f..1b7202e6240e 100644
--- a/gdb/dwarf2/leb.c
+++ b/gdb/dwarf2/leb.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/leb.h"
 
 ULONGEST
diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
index a3ca49b64f56..eddb2ef7ae80 100644
--- a/gdb/dwarf2/line-header.c
+++ b/gdb/dwarf2/line-header.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/comp-unit-head.h"
 #include "dwarf2/leb.h"
 #include "dwarf2/line-header.h"
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 203ad536162a..205d2ba56cbb 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ui-out.h"
 #include "value.h"
 #include "frame.h"
diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c
index 6b43aa49aa46..a511d0a3b449 100644
--- a/gdb/dwarf2/macro.c
+++ b/gdb/dwarf2/macro.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/read.h"
 #include "dwarf2/leb.h"
 #include "dwarf2/expr.h"
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index 0add8040894c..c0ef8e018446 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "read-debug-names.h"
 #include "dwarf2/aranges.h"
 #include "dwarf2/cooked-index.h"
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index bf4f828b007b..8c0895b96393 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "read-gdb-index.h"
 
 #include "cli/cli-cmds.h"
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 7442094874c0..b0f27e73f422 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -27,7 +27,6 @@
 /* FIXME: Various die-reading functions need to be more careful with
    reading off the end of the section.  */
 
-#include "defs.h"
 #include "dwarf2/read.h"
 #include "dwarf2/abbrev.h"
 #include "dwarf2/aranges.h"
diff --git a/gdb/dwarf2/section.c b/gdb/dwarf2/section.c
index e813fc0fd8ee..6aab0b9aee9f 100644
--- a/gdb/dwarf2/section.c
+++ b/gdb/dwarf2/section.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/section.h"
 #include "gdb_bfd.h"
 #include "objfiles.h"
diff --git a/gdb/dwarf2/stringify.c b/gdb/dwarf2/stringify.c
index 3700e0c1e784..1a4e280fc765 100644
--- a/gdb/dwarf2/stringify.c
+++ b/gdb/dwarf2/stringify.c
@@ -24,7 +24,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2.h"
 #include "dwarf2/stringify.h"
 
diff --git a/gdb/elf-none-tdep.c b/gdb/elf-none-tdep.c
index ddf26a9b666e..00d46992b248 100644
--- a/gdb/elf-none-tdep.c
+++ b/gdb/elf-none-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "elf-none-tdep.h"
 #include "regset.h"
 #include "elf-bfd.h"
diff --git a/gdb/elfread.c b/gdb/elfread.c
index e8a0c4d7a2cf..9bfe12712db7 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "elf-bfd.h"
 #include "elf/common.h"
diff --git a/gdb/eval.c b/gdb/eval.c
index 2759b46a5dff..6b752e706355 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/event-top.c b/gdb/event-top.c
index ef4ceedccfaa..9a02ac6df273 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "ui.h"
 #include "inferior.h"
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index 3a4216382a58..368999829fce 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "exceptions.h"
 #include "breakpoint.h"
 #include "target.h"
diff --git a/gdb/exec.c b/gdb/exec.c
index f17040a7a1b1..98ad81fb99ae 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/expprint.c b/gdb/expprint.c
index d34604fb13fb..2d8bccd60c65 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/extension.c b/gdb/extension.c
index 9db8b53a0873..f4bdcc1f6110 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -20,7 +20,6 @@
 /* Note: With few exceptions, external functions and variables in this file
    have "ext_lang" in the name, and no other symbol in gdb does.  */
 
-#include "defs.h"
 #include <signal.h>
 #include "target.h"
 #include "auto-load.h"
diff --git a/gdb/f-array-walker.h b/gdb/f-array-walker.h
index 8769e570ca34..bcbaa3da5b3c 100644
--- a/gdb/f-array-walker.h
+++ b/gdb/f-array-walker.h
@@ -21,7 +21,6 @@
 #ifndef F_ARRAY_WALKER_H
 #define F_ARRAY_WALKER_H
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "f-lang.h"
 
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index faa53ba9dd0e..11cd7948682e 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -42,7 +42,6 @@
    
 %{
 
-#include "defs.h"
 #include "expression.h"
 #include "value.h"
 #include "parser-defs.h"
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 96d4ed821c65..5eeb22806bb6 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 617e87cdeb71..6e9722dbeb85 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
 #include "symtab.h"
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 19bcd746208a..cd87dd222fda 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "annotate.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 7ac5983ae5ae..2d1bb5a33682 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/block-signals.h"
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index e3ebcb82ed64..593f5b4fd4a1 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "auxv.h"
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/features/microblaze-with-stack-protect.c b/gdb/features/microblaze-with-stack-protect.c
index 574dc02db67d..e5c0956610a3 100644
--- a/gdb/features/microblaze-with-stack-protect.c
+++ b/gdb/features/microblaze-with-stack-protect.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: microblaze-with-stack-protect.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/microblaze.c b/gdb/features/microblaze.c
index 8f1fb0a142fb..32ae3b02ad76 100644
--- a/gdb/features/microblaze.c
+++ b/gdb/features/microblaze.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: microblaze.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/mips-dsp-linux.c b/gdb/features/mips-dsp-linux.c
index d9d928c80128..d8e40283cafb 100644
--- a/gdb/features/mips-dsp-linux.c
+++ b/gdb/features/mips-dsp-linux.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: mips-dsp-linux.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/mips-linux.c b/gdb/features/mips-linux.c
index 8557bc8357df..f93eef5e41dc 100644
--- a/gdb/features/mips-linux.c
+++ b/gdb/features/mips-linux.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: mips-linux.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/mips64-dsp-linux.c b/gdb/features/mips64-dsp-linux.c
index 80bbbcbd152f..7ea0bb704f4a 100644
--- a/gdb/features/mips64-dsp-linux.c
+++ b/gdb/features/mips64-dsp-linux.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: mips64-dsp-linux.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/mips64-linux.c b/gdb/features/mips64-linux.c
index 21e8c37b9333..f4dcf8bc109b 100644
--- a/gdb/features/mips64-linux.c
+++ b/gdb/features/mips64-linux.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: mips64-linux.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/nds32.c b/gdb/features/nds32.c
index 7a08d2c85bb0..e5c5d50dce10 100644
--- a/gdb/features/nds32.c
+++ b/gdb/features/nds32.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: nds32.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/nios2.c b/gdb/features/nios2.c
index 648f7ed57abe..f53b0ddb4a03 100644
--- a/gdb/features/nios2.c
+++ b/gdb/features/nios2.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: nios2.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/or1k-linux.c b/gdb/features/or1k-linux.c
index 3eb65489383f..24731458de2c 100644
--- a/gdb/features/or1k-linux.c
+++ b/gdb/features/or1k-linux.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: or1k-linux.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/or1k.c b/gdb/features/or1k.c
index 67040965bd54..ee5e2f5b2067 100644
--- a/gdb/features/or1k.c
+++ b/gdb/features/or1k.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: or1k.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-32.c b/gdb/features/rs6000/powerpc-32.c
index a4f4bed180fa..562761e69a55 100644
--- a/gdb/features/rs6000/powerpc-32.c
+++ b/gdb/features/rs6000/powerpc-32.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-32.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-32l.c b/gdb/features/rs6000/powerpc-32l.c
index f5893bff01bf..caf81b760171 100644
--- a/gdb/features/rs6000/powerpc-32l.c
+++ b/gdb/features/rs6000/powerpc-32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-403.c b/gdb/features/rs6000/powerpc-403.c
index 2783287b981e..7cff21ceed7b 100644
--- a/gdb/features/rs6000/powerpc-403.c
+++ b/gdb/features/rs6000/powerpc-403.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-403.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-403gc.c b/gdb/features/rs6000/powerpc-403gc.c
index c69a1342773b..e86b51c43467 100644
--- a/gdb/features/rs6000/powerpc-403gc.c
+++ b/gdb/features/rs6000/powerpc-403gc.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-403gc.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-405.c b/gdb/features/rs6000/powerpc-405.c
index 1146d6601bd6..2716e37d8a8c 100644
--- a/gdb/features/rs6000/powerpc-405.c
+++ b/gdb/features/rs6000/powerpc-405.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-405.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-505.c b/gdb/features/rs6000/powerpc-505.c
index a36157f6c74d..51352e78bac4 100644
--- a/gdb/features/rs6000/powerpc-505.c
+++ b/gdb/features/rs6000/powerpc-505.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-505.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-601.c b/gdb/features/rs6000/powerpc-601.c
index ceaf789f3d73..2b700bbe128f 100644
--- a/gdb/features/rs6000/powerpc-601.c
+++ b/gdb/features/rs6000/powerpc-601.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-601.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-602.c b/gdb/features/rs6000/powerpc-602.c
index eb85e69d6a0d..13591b953020 100644
--- a/gdb/features/rs6000/powerpc-602.c
+++ b/gdb/features/rs6000/powerpc-602.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-602.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-603.c b/gdb/features/rs6000/powerpc-603.c
index 223919ca2d73..88b2b2c98c62 100644
--- a/gdb/features/rs6000/powerpc-603.c
+++ b/gdb/features/rs6000/powerpc-603.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-603.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-604.c b/gdb/features/rs6000/powerpc-604.c
index 16e6c12dae93..d266ba6ee897 100644
--- a/gdb/features/rs6000/powerpc-604.c
+++ b/gdb/features/rs6000/powerpc-604.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-604.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-64.c b/gdb/features/rs6000/powerpc-64.c
index 43dee105954f..c2f741091850 100644
--- a/gdb/features/rs6000/powerpc-64.c
+++ b/gdb/features/rs6000/powerpc-64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-64l.c b/gdb/features/rs6000/powerpc-64l.c
index 83a6a1590482..dbe06acdb200 100644
--- a/gdb/features/rs6000/powerpc-64l.c
+++ b/gdb/features/rs6000/powerpc-64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-7400.c b/gdb/features/rs6000/powerpc-7400.c
index d5fbf4bd3d79..f1f52eb51e63 100644
--- a/gdb/features/rs6000/powerpc-7400.c
+++ b/gdb/features/rs6000/powerpc-7400.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-7400.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-750.c b/gdb/features/rs6000/powerpc-750.c
index 3c9e7e1d23a1..14f490565906 100644
--- a/gdb/features/rs6000/powerpc-750.c
+++ b/gdb/features/rs6000/powerpc-750.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-750.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-860.c b/gdb/features/rs6000/powerpc-860.c
index 3e9a25f8e974..b02fcc4e357e 100644
--- a/gdb/features/rs6000/powerpc-860.c
+++ b/gdb/features/rs6000/powerpc-860.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-860.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-altivec32.c b/gdb/features/rs6000/powerpc-altivec32.c
index 41cca727be8e..05f7348df9ac 100644
--- a/gdb/features/rs6000/powerpc-altivec32.c
+++ b/gdb/features/rs6000/powerpc-altivec32.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-altivec32.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-altivec32l.c b/gdb/features/rs6000/powerpc-altivec32l.c
index 9cd935551db7..0bcae972502e 100644
--- a/gdb/features/rs6000/powerpc-altivec32l.c
+++ b/gdb/features/rs6000/powerpc-altivec32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-altivec32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-altivec64.c b/gdb/features/rs6000/powerpc-altivec64.c
index 8422708ec7fa..bdc500043918 100644
--- a/gdb/features/rs6000/powerpc-altivec64.c
+++ b/gdb/features/rs6000/powerpc-altivec64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-altivec64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-altivec64l.c b/gdb/features/rs6000/powerpc-altivec64l.c
index 977af8c941f6..2392f3496576 100644
--- a/gdb/features/rs6000/powerpc-altivec64l.c
+++ b/gdb/features/rs6000/powerpc-altivec64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-altivec64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-e500.c b/gdb/features/rs6000/powerpc-e500.c
index 84f721d948f3..0442569c3181 100644
--- a/gdb/features/rs6000/powerpc-e500.c
+++ b/gdb/features/rs6000/powerpc-e500.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-e500.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-e500l.c b/gdb/features/rs6000/powerpc-e500l.c
index a1e133d1c730..4e426c3005ae 100644
--- a/gdb/features/rs6000/powerpc-e500l.c
+++ b/gdb/features/rs6000/powerpc-e500l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-e500l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-32l.c b/gdb/features/rs6000/powerpc-isa205-32l.c
index 57fb20a4b12c..3834c9800191 100644
--- a/gdb/features/rs6000/powerpc-isa205-32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-64l.c b/gdb/features/rs6000/powerpc-isa205-64l.c
index b9ce8e604fba..9a3621877c07 100644
--- a/gdb/features/rs6000/powerpc-isa205-64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-altivec32l.c b/gdb/features/rs6000/powerpc-isa205-altivec32l.c
index 54b914c3714b..e42e1b922972 100644
--- a/gdb/features/rs6000/powerpc-isa205-altivec32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-altivec32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-altivec32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-altivec64l.c b/gdb/features/rs6000/powerpc-isa205-altivec64l.c
index 42e6f03e93c2..dc43206a9d37 100644
--- a/gdb/features/rs6000/powerpc-isa205-altivec64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-altivec64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-altivec64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
index a2c6172c6d27..acc1c5b9a3e7 100644
--- a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-ppr-dscr-vsx32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
index 3e7915a0619c..6bfe08d4cb56 100644
--- a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-ppr-dscr-vsx64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-vsx32l.c b/gdb/features/rs6000/powerpc-isa205-vsx32l.c
index 4cefcc36de57..b3f40b9d009c 100644
--- a/gdb/features/rs6000/powerpc-isa205-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-vsx32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-vsx32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa205-vsx64l.c b/gdb/features/rs6000/powerpc-isa205-vsx64l.c
index 2fb151d12c51..5f548176701b 100644
--- a/gdb/features/rs6000/powerpc-isa205-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-vsx64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa205-vsx64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
index b945039ca28d..b9dfd3092159 100644
--- a/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa207-htm-vsx32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
index 3aa579fd5f91..14a911b30aaf 100644
--- a/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa207-htm-vsx64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa207-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-vsx32l.c
index e5ce7f956cfb..bcfa7c175b85 100644
--- a/gdb/features/rs6000/powerpc-isa207-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa207-vsx32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa207-vsx32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-isa207-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-vsx64l.c
index adf6d3eec7f2..43bd6e584559 100644
--- a/gdb/features/rs6000/powerpc-isa207-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa207-vsx64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-isa207-vsx64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-vsx32.c b/gdb/features/rs6000/powerpc-vsx32.c
index 6fccdb374fb3..6d60eca340fe 100644
--- a/gdb/features/rs6000/powerpc-vsx32.c
+++ b/gdb/features/rs6000/powerpc-vsx32.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-vsx32.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-vsx32l.c b/gdb/features/rs6000/powerpc-vsx32l.c
index 1efe880d379c..cf2331349788 100644
--- a/gdb/features/rs6000/powerpc-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-vsx32l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-vsx32l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-vsx64.c b/gdb/features/rs6000/powerpc-vsx64.c
index df6d0f4bef91..a5baaa2dfdc2 100644
--- a/gdb/features/rs6000/powerpc-vsx64.c
+++ b/gdb/features/rs6000/powerpc-vsx64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-vsx64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/powerpc-vsx64l.c b/gdb/features/rs6000/powerpc-vsx64l.c
index 89aa13de6627..03d2b694b7d0 100644
--- a/gdb/features/rs6000/powerpc-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-vsx64l.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: powerpc-vsx64l.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rs6000/rs6000.c b/gdb/features/rs6000/rs6000.c
index 4aa5a8764a02..210dd96e4f61 100644
--- a/gdb/features/rs6000/rs6000.c
+++ b/gdb/features/rs6000/rs6000.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: rs6000.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/rx.c b/gdb/features/rx.c
index 825a4ac4538f..f9a5584f9b80 100644
--- a/gdb/features/rx.c
+++ b/gdb/features/rx.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: rx.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-gs-linux64.c b/gdb/features/s390-gs-linux64.c
index d48f8312f20b..49ea08b2c398 100644
--- a/gdb/features/s390-gs-linux64.c
+++ b/gdb/features/s390-gs-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-gs-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux32.c b/gdb/features/s390-linux32.c
index 03ec11a26b33..43ceb9c008e2 100644
--- a/gdb/features/s390-linux32.c
+++ b/gdb/features/s390-linux32.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux32.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux32v1.c b/gdb/features/s390-linux32v1.c
index 65de6f254f77..291784fdac75 100644
--- a/gdb/features/s390-linux32v1.c
+++ b/gdb/features/s390-linux32v1.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux32v1.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux32v2.c b/gdb/features/s390-linux32v2.c
index 0e3e04dfd435..6fa26daa537c 100644
--- a/gdb/features/s390-linux32v2.c
+++ b/gdb/features/s390-linux32v2.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux32v2.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux64.c b/gdb/features/s390-linux64.c
index f0ec91992f92..74c338c1fa60 100644
--- a/gdb/features/s390-linux64.c
+++ b/gdb/features/s390-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux64v1.c b/gdb/features/s390-linux64v1.c
index 9a360c7e2676..0aebbdb6b7ae 100644
--- a/gdb/features/s390-linux64v1.c
+++ b/gdb/features/s390-linux64v1.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux64v1.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-linux64v2.c b/gdb/features/s390-linux64v2.c
index 18bc6ed4f9c1..3b3b4916ac37 100644
--- a/gdb/features/s390-linux64v2.c
+++ b/gdb/features/s390-linux64v2.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-linux64v2.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-te-linux64.c b/gdb/features/s390-te-linux64.c
index a8909b36bbf4..d49e74413137 100644
--- a/gdb/features/s390-te-linux64.c
+++ b/gdb/features/s390-te-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-te-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-tevx-linux64.c b/gdb/features/s390-tevx-linux64.c
index 8f8aec61a49f..ffe1ddf4ee13 100644
--- a/gdb/features/s390-tevx-linux64.c
+++ b/gdb/features/s390-tevx-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-tevx-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390-vx-linux64.c b/gdb/features/s390-vx-linux64.c
index 0bcc14d7d089..30262a63fce6 100644
--- a/gdb/features/s390-vx-linux64.c
+++ b/gdb/features/s390-vx-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390-vx-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-gs-linux64.c b/gdb/features/s390x-gs-linux64.c
index 074c38d668c9..501b3b24061e 100644
--- a/gdb/features/s390x-gs-linux64.c
+++ b/gdb/features/s390x-gs-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-gs-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-linux64.c b/gdb/features/s390x-linux64.c
index af5ba23dc383..8655d5a6116d 100644
--- a/gdb/features/s390x-linux64.c
+++ b/gdb/features/s390x-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-linux64v1.c b/gdb/features/s390x-linux64v1.c
index a33bdc1672f8..11bfd85c9955 100644
--- a/gdb/features/s390x-linux64v1.c
+++ b/gdb/features/s390x-linux64v1.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-linux64v1.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-linux64v2.c b/gdb/features/s390x-linux64v2.c
index 8b906a47e44c..400b1af44854 100644
--- a/gdb/features/s390x-linux64v2.c
+++ b/gdb/features/s390x-linux64v2.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-linux64v2.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-te-linux64.c b/gdb/features/s390x-te-linux64.c
index de8bf6104701..74883e30fe83 100644
--- a/gdb/features/s390x-te-linux64.c
+++ b/gdb/features/s390x-te-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-te-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-tevx-linux64.c b/gdb/features/s390x-tevx-linux64.c
index 8bd5cc6c4390..1d45d6044c10 100644
--- a/gdb/features/s390x-tevx-linux64.c
+++ b/gdb/features/s390x-tevx-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-tevx-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/s390x-vx-linux64.c b/gdb/features/s390x-vx-linux64.c
index f450c45144d6..4de6585a2276 100644
--- a/gdb/features/s390x-vx-linux64.c
+++ b/gdb/features/s390x-vx-linux64.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: s390x-vx-linux64.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/sparc/sparc32-solaris.c b/gdb/features/sparc/sparc32-solaris.c
index 3353d4f44f7a..dce96851f96a 100644
--- a/gdb/features/sparc/sparc32-solaris.c
+++ b/gdb/features/sparc/sparc32-solaris.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: sparc32-solaris.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/sparc/sparc64-solaris.c b/gdb/features/sparc/sparc64-solaris.c
index 1150c884b444..d030df63c6cc 100644
--- a/gdb/features/sparc/sparc64-solaris.c
+++ b/gdb/features/sparc/sparc64-solaris.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: sparc64-solaris.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/features/z80.c b/gdb/features/z80.c
index f8e2a1988d0e..627649cc6901 100644
--- a/gdb/features/z80.c
+++ b/gdb/features/z80.c
@@ -1,7 +1,6 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
   Original: z80.xml */
 
-#include "defs.h"
 #include "osabi.h"
 #include "target-descriptions.h"
 
diff --git a/gdb/filename-seen-cache.c b/gdb/filename-seen-cache.c
index d103f22b0b5b..a08927fb9fd4 100644
--- a/gdb/filename-seen-cache.c
+++ b/gdb/filename-seen-cache.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "filename-seen-cache.h"
 #include "filenames.h"
 
diff --git a/gdb/filename-seen-cache.h b/gdb/filename-seen-cache.h
index e351c074f222..5dc800d2b163 100644
--- a/gdb/filename-seen-cache.h
+++ b/gdb/filename-seen-cache.h
@@ -20,7 +20,6 @@
 #ifndef FILENAME_SEEN_CACHE_H
 #define FILENAME_SEEN_CACHE_H
 
-#include "defs.h"
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/gdb-hashtab.h"
 
diff --git a/gdb/filesystem.c b/gdb/filesystem.c
index 62b2829a76c5..4e05b0413a89 100644
--- a/gdb/filesystem.c
+++ b/gdb/filesystem.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "filesystem.h"
 #include "gdbarch.h"
 #include "gdbcmd.h"
diff --git a/gdb/findcmd.c b/gdb/findcmd.c
index 2bc3fe107386..2915c7067334 100644
--- a/gdb/findcmd.c
+++ b/gdb/findcmd.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
 #include "gdbcmd.h"
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 516a2ca044cc..71bfebe40a7a 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "frame.h"
diff --git a/gdb/fork-child.c b/gdb/fork-child.c
index 7bd81f41a531..e0891296f8c9 100644
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcmd.h"
 #include "terminal.h"
diff --git a/gdb/frame-base.c b/gdb/frame-base.c
index fda19b57bacb..7faa999532bb 100644
--- a/gdb/frame-base.c
+++ b/gdb/frame-base.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame-base.h"
 #include "frame.h"
 #include "gdbsupport/gdb_obstack.h"
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index e9983a9fd74f..a80421a9c5a8 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "dummy-frame.h"
diff --git a/gdb/frame.c b/gdb/frame.c
index f1f97040ff0c..f042bbb2ec25 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "target.h"
 #include "value.h"
diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c
index 5160c3b0c1d6..0b13a81c0642 100644
--- a/gdb/frv-linux-tdep.c
+++ b/gdb/frv-linux-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "target.h"
 #include "frame.h"
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index bcb2c621945b..5c026ebd53a3 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "arch-utils.h"
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 60cd2c974a12..c5a48bebe5f2 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/gcore-elf.c b/gdb/gcore-elf.c
index 5b0a014deb0d..c88fa08a5891 100644
--- a/gdb/gcore-elf.c
+++ b/gdb/gcore-elf.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gcore-elf.h"
 #include "elf-bfd.h"
 #include "target.h"
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 3d3973bfaba1..007966212a79 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "elf-bfd.h"
 #include "infcall.h"
 #include "inferior.h"
diff --git a/gdb/gdb-demangle.c b/gdb/gdb-demangle.c
index 20390aabb52e..7779beb591da 100644
--- a/gdb/gdb-demangle.c
+++ b/gdb/gdb-demangle.c
@@ -23,7 +23,6 @@
 /*  This file contains support code for C++ demangling that is common
    to a styles of demangling, and GDB specific.  */
 
-#include "defs.h"
 #include "cli/cli-utils.h"
 #include "command.h"
 #include "gdbcmd.h"
diff --git a/gdb/gdb.c b/gdb/gdb.c
index ad37e37e4669..5326df426931 100644
--- a/gdb/gdb.c
+++ b/gdb/gdb.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "main.h"
 #include "interps.h"
 #include "run-on-main-thread.h"
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 3b1df4897a32..ffff76e54b72 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdb_bfd.h"
 #include "ui-out.h"
 #include "gdbcmd.h"
diff --git a/gdb/gdbarch-selftests.c b/gdb/gdbarch-selftests.c
index 2013a0ebed3e..0dc0c5006544 100644
--- a/gdb/gdbarch-selftests.c
+++ b/gdb/gdbarch-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "target.h"
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 960a7f49e451..1e1a7e9ce615 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "symtab.h"
 #include "symfile.h"
diff --git a/gdb/glibc-tdep.c b/gdb/glibc-tdep.c
index ea1bfef60b5f..48e080ae9bf3 100644
--- a/gdb/glibc-tdep.c
+++ b/gdb/glibc-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "symtab.h"
 #include "symfile.h"
diff --git a/gdb/gmp-utils.c b/gdb/gmp-utils.c
index 4341ade16df1..aabdd5f3de5c 100644
--- a/gdb/gmp-utils.c
+++ b/gdb/gmp-utils.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gmp-utils.h"
 
 /* See gmp-utils.h.  */
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 0add13e3b89f..92b2858bd9d6 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -49,7 +49,6 @@ extern "C"
 #include <portinfo.h>
 }
 
-#include "defs.h"
 
 #include <ctype.h>
 #include <setjmp.h>
diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index 725691c3d07b..f1694b8a3a78 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -19,8 +19,6 @@
 #ifndef GNU_NAT_H
 #define GNU_NAT_H
 
-#include "defs.h"
-
 /* Work around conflict between Mach's 'thread_info' function, and GDB's
    'thread_info' class.  Make the former available as 'mach_thread_info'.  */
 #define thread_info mach_thread_info
diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
index 34c8f1916610..7b511eabdec8 100644
--- a/gdb/gnu-v2-abi.c
+++ b/gdb/gnu-v2-abi.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 133bf28f6487..90f5b29dd8e9 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "value.h"
 #include "cp-abi.h"
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 2e56e4bff610..20ab8ff76cf8 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -51,7 +51,6 @@
 
 %{
 
-#include "defs.h"
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 99bc5b74a934..8b4250b222a8 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -31,7 +31,6 @@
    - 6g mangling isn't supported yet
 */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "block.h"
 #include "symtab.h"
diff --git a/gdb/go-typeprint.c b/gdb/go-typeprint.c
index 0d2653d909c0..7778c71a3d24 100644
--- a/gdb/go-typeprint.c
+++ b/gdb/go-typeprint.c
@@ -23,7 +23,6 @@
      want a Python API for type printing
 */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "c-lang.h"
 #include "go-lang.h"
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index b16707138e65..43f279a44263 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -23,7 +23,6 @@
    Strings are handled specially here, at least for now, in case the Python
    support is unavailable.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
 #include "go-lang.h"
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 44022a260aa9..1d8c16fa71c3 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -81,7 +81,6 @@
    GDB does not use those as of this writing, and will never need
    to.  */
 
-#include "defs.h"
 
 #include <fcntl.h>
 
diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c
index f0db709e4fec..f540659d6479 100644
--- a/gdb/guile/guile.c
+++ b/gdb/guile/guile.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "breakpoint.h"
 #include "cli/cli-cmds.h"
 #include "cli/cli-script.h"
diff --git a/gdb/guile/scm-arch.c b/gdb/guile/scm-arch.c
index eaa2e5e22b6a..02adad0ec113 100644
--- a/gdb/guile/scm-arch.c
+++ b/gdb/guile/scm-arch.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "gdbarch.h"
 #include "arch-utils.h"
diff --git a/gdb/guile/scm-auto-load.c b/gdb/guile/scm-auto-load.c
index 1ffa96070dd5..90c4eedb9254 100644
--- a/gdb/guile/scm-auto-load.c
+++ b/gdb/guile/scm-auto-load.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c
index 44097a633dd6..4ca43117914e 100644
--- a/gdb/guile/scm-block.c
+++ b/gdb/guile/scm-block.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "block.h"
 #include "dictionary.h"
 #include "objfiles.h"
diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c
index 88b660329e43..a32862b0349f 100644
--- a/gdb/guile/scm-breakpoint.c
+++ b/gdb/guile/scm-breakpoint.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "value.h"
 #include "breakpoint.h"
 #include "gdbcmd.h"
diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c
index d70d4897413a..d75d2b63c8ca 100644
--- a/gdb/guile/scm-cmd.c
+++ b/gdb/guile/scm-cmd.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "charset.h"
 #include "gdbcmd.h"
diff --git a/gdb/guile/scm-disasm.c b/gdb/guile/scm-disasm.c
index 5266faa601be..0c7c4ec6246b 100644
--- a/gdb/guile/scm-disasm.c
+++ b/gdb/guile/scm-disasm.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "disasm.h"
 #include "dis-asm.h"
diff --git a/gdb/guile/scm-exception.c b/gdb/guile/scm-exception.c
index de17c089df3c..61007de935ec 100644
--- a/gdb/guile/scm-exception.c
+++ b/gdb/guile/scm-exception.c
@@ -28,7 +28,6 @@
    The non-static functions in this file have prefix gdbscm_ and
    not exscm_ on purpose.  */
 
-#include "defs.h"
 #include <signal.h>
 #include "guile-internal.h"
 
diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c
index b133e8de11d6..c94fcfe66982 100644
--- a/gdb/guile/scm-frame.c
+++ b/gdb/guile/scm-frame.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "block.h"
 #include "frame.h"
 #include "inferior.h"
diff --git a/gdb/guile/scm-gsmob.c b/gdb/guile/scm-gsmob.c
index 40871e9167de..b3efad20aba6 100644
--- a/gdb/guile/scm-gsmob.c
+++ b/gdb/guile/scm-gsmob.c
@@ -41,7 +41,6 @@
    seeing if it's already in the table.  Eqable gsmobs can also be used where
    lifetime-tracking is required.  */
 
-#include "defs.h"
 #include "hashtab.h"
 #include "objfiles.h"
 #include "guile-internal.h"
diff --git a/gdb/guile/scm-iterator.c b/gdb/guile/scm-iterator.c
index 035aa8bb8ff1..f4d5344dfc15 100644
--- a/gdb/guile/scm-iterator.c
+++ b/gdb/guile/scm-iterator.c
@@ -50,7 +50,6 @@
    There is SRFI 41, Streams.  We might support that too eventually (not with
    this interface of course).  */
 
-#include "defs.h"
 #include "guile-internal.h"
 
 /* A smob for iterating over something.
diff --git a/gdb/guile/scm-lazy-string.c b/gdb/guile/scm-lazy-string.c
index 30f5a0daeada..94032ae5332b 100644
--- a/gdb/guile/scm-lazy-string.c
+++ b/gdb/guile/scm-lazy-string.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "value.h"
 #include "valprint.h"
diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c
index b09a0ff7ffda..7a4a703e103f 100644
--- a/gdb/guile/scm-math.c
+++ b/gdb/guile/scm-math.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "charset.h"
 #include "cp-abi.h"
diff --git a/gdb/guile/scm-objfile.c b/gdb/guile/scm-objfile.c
index 5db4bd2922e0..bccf6ba156d7 100644
--- a/gdb/guile/scm-objfile.c
+++ b/gdb/guile/scm-objfile.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "language.h"
 #include "guile-internal.h"
diff --git a/gdb/guile/scm-param.c b/gdb/guile/scm-param.c
index b26e66e71d81..018bd1499c99 100644
--- a/gdb/guile/scm-param.c
+++ b/gdb/guile/scm-param.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "charset.h"
 #include "gdbcmd.h"
diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c
index 3b58fff17e72..ab78b5c43439 100644
--- a/gdb/guile/scm-ports.c
+++ b/gdb/guile/scm-ports.c
@@ -21,7 +21,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_select.h"
 #include "ui.h"
 #include "target.h"
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index 068fadb853ae..99fa243f9d72 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "top.h"
 #include "charset.h"
 #include "symtab.h"
diff --git a/gdb/guile/scm-progspace.c b/gdb/guile/scm-progspace.c
index 216985efd685..fcdcca24f068 100644
--- a/gdb/guile/scm-progspace.c
+++ b/gdb/guile/scm-progspace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "progspace.h"
 #include "objfiles.h"
diff --git a/gdb/guile/scm-safe-call.c b/gdb/guile/scm-safe-call.c
index 1c5b9fac4130..bc0a1e641c0c 100644
--- a/gdb/guile/scm-safe-call.c
+++ b/gdb/guile/scm-safe-call.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "filenames.h"
 #include "guile-internal.h"
 #include "gdbsupport/pathstuff.h"
diff --git a/gdb/guile/scm-string.c b/gdb/guile/scm-string.c
index 134445d011c2..a249bccda1eb 100644
--- a/gdb/guile/scm-string.c
+++ b/gdb/guile/scm-string.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "guile-internal.h"
 #include "gdbsupport/buildargv.h"
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 860ed5222748..368a598dc4b2 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "block.h"
 #include "frame.h"
 #include "symtab.h"
diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c
index 9a34a5d7b92e..2fd4b03b4c6d 100644
--- a/gdb/guile/scm-symtab.c
+++ b/gdb/guile/scm-symtab.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "source.h"
 #include "objfiles.h"
diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c
index 67b8179e076f..19324a69810c 100644
--- a/gdb/guile/scm-type.c
+++ b/gdb/guile/scm-type.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "top.h"
 #include "arch-utils.h"
 #include "value.h"
diff --git a/gdb/guile/scm-utils.c b/gdb/guile/scm-utils.c
index 1cacafdd1375..45f42ba0ccf0 100644
--- a/gdb/guile/scm-utils.c
+++ b/gdb/guile/scm-utils.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "guile-internal.h"
 
 /* Define VARIABLES in the gdb module.  */
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c
index f8b3eea52e28..a7b21707eba1 100644
--- a/gdb/guile/scm-value.c
+++ b/gdb/guile/scm-value.c
@@ -20,7 +20,6 @@
 /* See README file in this directory for implementation notes, coding
    conventions, et.al.  */
 
-#include "defs.h"
 #include "top.h"
 #include "arch-utils.h"
 #include "charset.h"
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index 36cbd9d4aa60..32907e29abff 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -22,7 +22,6 @@
    sac@cygnus.com
  */
 
-#include "defs.h"
 #include "value.h"
 #include "arch-utils.h"
 #include "regcache.h"
diff --git a/gdb/hppa-bsd-tdep.c b/gdb/hppa-bsd-tdep.c
index b1df3d17aa4d..dacda88c5866 100644
--- a/gdb/hppa-bsd-tdep.c
+++ b/gdb/hppa-bsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "target.h"
 #include "value.h"
diff --git a/gdb/hppa-linux-nat.c b/gdb/hppa-linux-nat.c
index 46bcb7c186ec..96faeb39d8f4 100644
--- a/gdb/hppa-linux-nat.c
+++ b/gdb/hppa-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "inferior.h"
diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c
index db0c36801316..659c265bfb86 100644
--- a/gdb/hppa-linux-tdep.c
+++ b/gdb/hppa-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "osabi.h"
 #include "target.h"
diff --git a/gdb/hppa-netbsd-nat.c b/gdb/hppa-netbsd-nat.c
index 6966aa4b8750..e7df997f6e4b 100644
--- a/gdb/hppa-netbsd-nat.c
+++ b/gdb/hppa-netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 
diff --git a/gdb/hppa-netbsd-tdep.c b/gdb/hppa-netbsd-tdep.c
index ccf32c790906..c71e191c8a58 100644
--- a/gdb/hppa-netbsd-tdep.c
+++ b/gdb/hppa-netbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/hppa-obsd-nat.c b/gdb/hppa-obsd-nat.c
index 3e9938c5e545..f6f79cd33857 100644
--- a/gdb/hppa-obsd-nat.c
+++ b/gdb/hppa-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/hppa-obsd-tdep.c b/gdb/hppa-obsd-tdep.c
index f009775425c8..c4f8d1fcfe1e 100644
--- a/gdb/hppa-obsd-tdep.c
+++ b/gdb/hppa-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 30128bafac48..8becfd5f9f9d 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/i386-bsd-nat.c b/gdb/i386-bsd-nat.c
index 612eae9e6f14..e1db6c74f9c4 100644
--- a/gdb/i386-bsd-nat.c
+++ b/gdb/i386-bsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 
diff --git a/gdb/i386-bsd-tdep.c b/gdb/i386-bsd-tdep.c
index 8470f2b6d2f9..db00e18bccfe 100644
--- a/gdb/i386-bsd-tdep.c
+++ b/gdb/i386-bsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "gdbcore.h"
diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
index 4fa86e49696c..acfa46a8b7d0 100644
--- a/gdb/i386-darwin-nat.c
+++ b/gdb/i386-darwin-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
index fc0a3dd3909e..5a5c8bffc210 100644
--- a/gdb/i386-darwin-tdep.c
+++ b/gdb/i386-darwin-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/i386-dicos-tdep.c b/gdb/i386-dicos-tdep.c
index e893a04617f8..9859c855150d 100644
--- a/gdb/i386-dicos-tdep.c
+++ b/gdb/i386-dicos-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "dicos-tdep.h"
 #include "gdbarch.h"
diff --git a/gdb/i386-fbsd-nat.c b/gdb/i386-fbsd-nat.c
index 6b567071fb39..f4538fbe407b 100644
--- a/gdb/i386-fbsd-nat.c
+++ b/gdb/i386-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c
index 2b9ef77e5e6d..d6d477ab7322 100644
--- a/gdb/i386-fbsd-tdep.c
+++ b/gdb/i386-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "osabi.h"
 #include "regcache.h"
diff --git a/gdb/i386-gnu-nat.c b/gdb/i386-gnu-nat.c
index 0b0759179aa7..52d4a4b7cec2 100644
--- a/gdb/i386-gnu-nat.c
+++ b/gdb/i386-gnu-nat.c
@@ -29,7 +29,6 @@ extern "C"
 #include <mach/exception.h>
 }
 
-#include "defs.h"
 #include "x86-nat.h"
 #include "inferior.h"
 #include "floatformat.h"
diff --git a/gdb/i386-gnu-tdep.c b/gdb/i386-gnu-tdep.c
index aa1898693b61..fb308215a7a9 100644
--- a/gdb/i386-gnu-tdep.c
+++ b/gdb/i386-gnu-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "osabi.h"
 #include "solib-svr4.h"
diff --git a/gdb/i386-go32-tdep.c b/gdb/i386-go32-tdep.c
index fd1a22fb50a9..738b2583a1dc 100644
--- a/gdb/i386-go32-tdep.c
+++ b/gdb/i386-go32-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "i386-tdep.h"
 #include "gdbsupport/x86-xstate.h"
 #include "target-descriptions.h"
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 25c57fc902cc..7278dd91ff0b 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index a2f937690c2e..44730f204db5 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "frame.h"
 #include "value.h"
diff --git a/gdb/i386-netbsd-nat.c b/gdb/i386-netbsd-nat.c
index e4f912f733b1..7eaaaf398c3b 100644
--- a/gdb/i386-netbsd-nat.c
+++ b/gdb/i386-netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/i386-netbsd-tdep.c b/gdb/i386-netbsd-tdep.c
index 9596435e9d10..a43765696270 100644
--- a/gdb/i386-netbsd-tdep.c
+++ b/gdb/i386-netbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "gdbcore.h"
diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c
index f4bb70cc5a08..674d45feba99 100644
--- a/gdb/i386-nto-tdep.c
+++ b/gdb/i386-nto-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "osabi.h"
 #include "regcache.h"
diff --git a/gdb/i386-obsd-nat.c b/gdb/i386-obsd-nat.c
index 69dd67ed6558..2b3d3912430f 100644
--- a/gdb/i386-obsd-nat.c
+++ b/gdb/i386-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/i386-obsd-tdep.c b/gdb/i386-obsd-tdep.c
index e1480ec6cc41..6e31567328eb 100644
--- a/gdb/i386-obsd-tdep.c
+++ b/gdb/i386-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "frame-unwind.h"
diff --git a/gdb/i386-sol2-nat.c b/gdb/i386-sol2-nat.c
index 7b3bc3a02ace..20ca9d68cbc8 100644
--- a/gdb/i386-sol2-nat.c
+++ b/gdb/i386-sol2-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 
 #include <sys/reg.h>
diff --git a/gdb/i386-sol2-tdep.c b/gdb/i386-sol2-tdep.c
index bc8df378219d..b85ac1751ac4 100644
--- a/gdb/i386-sol2-tdep.c
+++ b/gdb/i386-sol2-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "osabi.h"
 
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 0d4e30b9a4e4..1b1efad6fa3e 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "opcode/i386.h"
 #include "arch-utils.h"
 #include "command.h"
diff --git a/gdb/i386-windows-nat.c b/gdb/i386-windows-nat.c
index d262b5fce67e..ec6077ffce18 100644
--- a/gdb/i386-windows-nat.c
+++ b/gdb/i386-windows-nat.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "windows-nat.h"
 #include "x86-nat.h"
 #include "i386-tdep.h"
diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c
index e8ed043be8a0..b3a96d70bdf1 100644
--- a/gdb/i386-windows-tdep.c
+++ b/gdb/i386-windows-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "i386-tdep.h"
 #include "windows-tdep.h"
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 3d979e279a1e..00c9523ff258 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/ia64-libunwind-tdep.c b/gdb/ia64-libunwind-tdep.c
index 24a5162cdc65..72e4fae418d9 100644
--- a/gdb/ia64-libunwind-tdep.c
+++ b/gdb/ia64-libunwind-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "inferior.h"
 #include "frame.h"
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
index 2ea7203e7b0f..7a8e742daea3 100644
--- a/gdb/ia64-linux-nat.c
+++ b/gdb/ia64-linux-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "target.h"
 #include "gdbarch.h"
diff --git a/gdb/ia64-linux-tdep.c b/gdb/ia64-linux-tdep.c
index 68d4102ee9a2..676fdb8edac7 100644
--- a/gdb/ia64-linux-tdep.c
+++ b/gdb/ia64-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ia64-tdep.h"
 #include "arch-utils.h"
 #include "gdbcore.h"
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 88f67ccf0962..f49a8d6b5586 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "arch-utils.h"
diff --git a/gdb/ia64-vms-tdep.c b/gdb/ia64-vms-tdep.c
index f5bf2b53e5e2..20308c707205 100644
--- a/gdb/ia64-vms-tdep.c
+++ b/gdb/ia64-vms-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame-unwind.h"
 #include "ia64-tdep.h"
 #include "osabi.h"
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index d44179ca042e..1318d6b041e1 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -22,7 +22,6 @@
    new prototype target and then overriding target methods as
    necessary.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "memattr.h"
 #include "symtab.h"
diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c
index e23608f2800f..41e766095f05 100644
--- a/gdb/inf-loop.c
+++ b/gdb/inf-loop.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "infrun.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 31638fcbb2d8..ce303eb87eaf 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "command.h"
 #include "inferior.h"
 #include "terminal.h"
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 145ce25b0d1b..b2a0df7b45cf 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "infcall.h"
 #include "breakpoint.h"
 #include "tracepoint.h"
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index ac41ebf11b4f..600c90c055a5 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 5ff5eb989552..4e1d789d1ba6 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "exec.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 3dd70b97fe53..ac71e262a1f2 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "command.h"
diff --git a/gdb/infrun.c b/gdb/infrun.c
index bbb98f6dcdb3..1ea15011c999 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "displaced-stepping.h"
 #include "infrun.h"
 #include <ctype.h>
diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c
index 9f3deef8f030..f65f39be40d6 100644
--- a/gdb/inline-frame.c
+++ b/gdb/inline-frame.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "breakpoint.h"
 #include "inline-frame.h"
 #include "addrmap.h"
diff --git a/gdb/interps.c b/gdb/interps.c
index 8e9570ecb1eb..36d96eea5149 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -29,7 +29,6 @@
    the readline command interface, and it is probably simpler to just let
    them take over the input in their resume proc.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "ui-out.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
index 4177de059c0d..b9d95bbc2675 100644
--- a/gdb/iq2000-tdep.c
+++ b/gdb/iq2000-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/jit.c b/gdb/jit.c
index a7fd5c40f9d4..3843b84b0e63 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "jit.h"
 #include "jit-reader.h"
diff --git a/gdb/language.c b/gdb/language.c
index c5bbc3199637..e43e0fe7a172 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -28,7 +28,6 @@
    return data out of a "language-specific" struct pointer that is set
    whenever the working language changes.  That would be a lot faster.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/linespec.c b/gdb/linespec.c
index b5bbd8c433c9..ca154d2dcba1 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "frame.h"
 #include "command.h"
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 0d92d61f0d24..bb8119a36d05 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/linux-nat-trad.c b/gdb/linux-nat-trad.c
index 3639b2e2578b..d90d76fd9a03 100644
--- a/gdb/linux-nat-trad.c
+++ b/gdb/linux-nat-trad.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "linux-nat-trad.h"
 
 #include "nat/gdb_ptrace.h"
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 3ba072bc8d70..2602e1f240d0 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "infrun.h"
 #include "target.h"
diff --git a/gdb/linux-record.c b/gdb/linux-record.c
index 1b7330de08c4..6430c0e00884 100644
--- a/gdb/linux-record.c
+++ b/gdb/linux-record.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "gdbtypes.h"
 #include "regcache.h"
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 701e3df7a279..b967580a6431 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "linux-tdep.h"
 #include "auxv.h"
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 34a39899eeb4..65bf4a79fdf1 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <dlfcn.h>
 #include "gdb_proc_service.h"
 #include "nat/gdb_thread_db.h"
diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index b4605e48c6a3..478f1edf3e64 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/location.c b/gdb/location.c
index c3bea1fc673d..851d6e474448 100644
--- a/gdb/location.c
+++ b/gdb/location.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_assert.h"
 #include "gdbsupport/gdb-checked-static-cast.h"
 #include "location.h"
diff --git a/gdb/loongarch-linux-nat.c b/gdb/loongarch-linux-nat.c
index 9bceb8a5953d..15fca6ad781c 100644
--- a/gdb/loongarch-linux-nat.c
+++ b/gdb/loongarch-linux-nat.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "elf/common.h"
 #include "gregset.h"
 #include "inferior.h"
diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c
index cc8121bb2b8d..a57dc31cde8a 100644
--- a/gdb/loongarch-linux-tdep.c
+++ b/gdb/loongarch-linux-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "glibc-tdep.h"
 #include "inferior.h"
 #include "linux-tdep.h"
diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c
index 0b38e751d165..149fbd55db90 100644
--- a/gdb/loongarch-tdep.c
+++ b/gdb/loongarch-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dwarf2/frame.h"
 #include "elf-bfd.h"
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index ce5a399477d4..ebbc49c62a5e 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -37,7 +37,6 @@
    
 %{
 
-#include "defs.h"
 #include "expression.h"
 #include "language.h"
 #include "value.h"
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 30c2a931236b..86fef96dec18 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index d8172c0c3684..32cc930cfb8d 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index c98f9269ae62..62bfec9cf1c4 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 0895f7bd0c4b..33ec44349d76 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "sim/sim-m32c.h"
 #include "gdbtypes.h"
 #include "regcache.h"
diff --git a/gdb/m32r-linux-nat.c b/gdb/m32r-linux-nat.c
index f482fe62e235..08a4db1d39a6 100644
--- a/gdb/m32r-linux-nat.c
+++ b/gdb/m32r-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/m32r-linux-tdep.c b/gdb/m32r-linux-tdep.c
index b74d2f3f161b..a28e11358402 100644
--- a/gdb/m32r-linux-tdep.c
+++ b/gdb/m32r-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "frame.h"
 #include "value.h"
diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index 0bd6b499e6f0..215df88b21c8 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index d80b190f2c0f..70b3f129d5aa 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -20,7 +20,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/m68k-bsd-nat.c b/gdb/m68k-bsd-nat.c
index 29fd98f0921e..1fb0c20d05cd 100644
--- a/gdb/m68k-bsd-nat.c
+++ b/gdb/m68k-bsd-nat.c
@@ -19,7 +19,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/m68k-bsd-tdep.c b/gdb/m68k-bsd-tdep.c
index 3903a83f4e04..faec4713143a 100644
--- a/gdb/m68k-bsd-tdep.c
+++ b/gdb/m68k-bsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "osabi.h"
diff --git a/gdb/m68k-linux-nat.c b/gdb/m68k-linux-nat.c
index 8b1f868a6b9f..7f3373986769 100644
--- a/gdb/m68k-linux-nat.c
+++ b/gdb/m68k-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "language.h"
diff --git a/gdb/m68k-linux-tdep.c b/gdb/m68k-linux-tdep.c
index eca4ede099f7..4874db720db9 100644
--- a/gdb/m68k-linux-tdep.c
+++ b/gdb/m68k-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "frame.h"
 #include "target.h"
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index abfc605aabb6..f73f58de90aa 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/frame.h"
 #include "frame.h"
 #include "frame-base.h"
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 8022fac9378c..b65694e697d5 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "bfd.h"
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index d3879cdf94c8..ddabfede0f55 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "macrotab.h"
 #include "macroexp.h"
 #include "macroscope.h"
diff --git a/gdb/macroexp.c b/gdb/macroexp.c
index b8a9b29db245..bcae7ec8daf6 100644
--- a/gdb/macroexp.c
+++ b/gdb/macroexp.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "macrotab.h"
 #include "macroexp.h"
diff --git a/gdb/macroscope.c b/gdb/macroscope.c
index b193b0a5c02e..4c1304f119ad 100644
--- a/gdb/macroscope.c
+++ b/gdb/macroscope.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "macroscope.h"
 #include "symtab.h"
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
index 5329d2a5a939..f2012dae1ad6 100644
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/pathstuff.h"
 #include "splay-tree.h"
diff --git a/gdb/main.c b/gdb/main.c
index 17826fae95e3..bf3c776dba9c 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "ui.h"
 #include "target.h"
diff --git a/gdb/maint-test-options.c b/gdb/maint-test-options.c
index 11b0e1d1f0f0..f671771f3b37 100644
--- a/gdb/maint-test-options.c
+++ b/gdb/maint-test-options.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "cli/cli-option.h"
 
diff --git a/gdb/maint-test-settings.c b/gdb/maint-test-settings.c
index 22c7d2dd7ab7..61456911589d 100644
--- a/gdb/maint-test-settings.c
+++ b/gdb/maint-test-settings.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "gdbcmd.h"
 
 /* Command list for "maint set test-settings".  */
diff --git a/gdb/maint.c b/gdb/maint.c
index f410cf11e697..6a5a55afebf8 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -20,7 +20,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
 #include <cmath>
diff --git a/gdb/make-init-c b/gdb/make-init-c
index 7190e691c3e7..3458333c84cb 100755
--- a/gdb/make-init-c
+++ b/gdb/make-init-c
@@ -41,7 +41,6 @@ set -e
 
 echo "/* Do not modify this file.  */"
 echo "/* It is created automatically by the Makefile.  */"
-echo "#include \"defs.h\"      /* For initialize_file_ftype.  */"
 echo "#include <algorithm>"
 echo ""
 sed -n -e 's/^\(_initialize_[a-zA-Z0-9_]*\) ()$/\1/p' "$@" | while read -r name; do
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 4748b0cd7aa8..ab4d509e02a2 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -39,7 +39,6 @@
    This module can read all four of the known byte-order combinations,
    on any type of host.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
diff --git a/gdb/mem-break.c b/gdb/mem-break.c
index 552bb28b288d..712ad000daf1 100644
--- a/gdb/mem-break.c
+++ b/gdb/mem-break.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "breakpoint.h"
 #include "inferior.h"
diff --git a/gdb/memattr.c b/gdb/memattr.c
index 6d406be36337..062611e8ee6f 100644
--- a/gdb/memattr.c
+++ b/gdb/memattr.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "command.h"
 #include "gdbcmd.h"
 #include "memattr.h"
diff --git a/gdb/memory-map.c b/gdb/memory-map.c
index 7b7a0ebf9503..26c49dbb079c 100644
--- a/gdb/memory-map.c
+++ b/gdb/memory-map.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "memory-map.h"
 
 #if !defined(HAVE_LIBEXPAT)
diff --git a/gdb/memrange.c b/gdb/memrange.c
index 161e9ac8f955..11687b808b86 100644
--- a/gdb/memrange.c
+++ b/gdb/memrange.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "memrange.h"
 #include <algorithm>
 
diff --git a/gdb/memtag.c b/gdb/memtag.c
index 86b2f66de28f..54bdc0ad323c 100644
--- a/gdb/memtag.c
+++ b/gdb/memtag.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "memtag.h"
 #include "bfd.h"
 
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index f455d3eb51d6..fdb589134da0 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index 4e64283f8e94..343a167e3d87 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "mi-cmds.h"
 #include "ui-out.h"
diff --git a/gdb/mi/mi-cmd-catch.c b/gdb/mi/mi-cmd-catch.c
index 422bbe793f2c..6cba316efda4 100644
--- a/gdb/mi/mi-cmd-catch.c
+++ b/gdb/mi/mi-cmd-catch.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "breakpoint.h"
 #include "ada-lang.h"
diff --git a/gdb/mi/mi-cmd-disas.c b/gdb/mi/mi-cmd-disas.c
index 3121f0c1dd9f..99b2ae418172 100644
--- a/gdb/mi/mi-cmd-disas.c
+++ b/gdb/mi/mi-cmd-disas.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "target.h"
 #include "value.h"
diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c
index e4fa89bb82cd..ae8c5e8bf00c 100644
--- a/gdb/mi/mi-cmd-env.c
+++ b/gdb/mi/mi-cmd-env.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "value.h"
 #include "mi-out.h"
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index 95128a9ad6dc..3e2702e04ed1 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-cmds.h"
 #include "mi-getopt.h"
 #include "mi-interp.h"
diff --git a/gdb/mi/mi-cmd-info.c b/gdb/mi/mi-cmd-info.c
index 1af20f8cb3a9..628891bcc119 100644
--- a/gdb/mi/mi-cmd-info.c
+++ b/gdb/mi/mi-cmd-info.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osdata.h"
 #include "mi-cmds.h"
 #include "ada-lang.h"
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 09c31b6a9a4c..b78c169e70bc 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "frame.h"
 #include "value.h"
diff --git a/gdb/mi/mi-cmd-target.c b/gdb/mi/mi-cmd-target.c
index e9edad739960..fbc6d6c07c8f 100644
--- a/gdb/mi/mi-cmd-target.c
+++ b/gdb/mi/mi-cmd-target.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-cmds.h"
 #include "mi-getopt.h"
 #include "remote.h"
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index cb5bafe9b7b7..f31120472a70 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-cmds.h"
 #include "mi-main.h"
 #include "ui-out.h"
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 53df07c41d07..c7afb10097be 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "mi-cmds.h"
 #include "mi-main.h"
diff --git a/gdb/mi/mi-common.c b/gdb/mi/mi-common.c
index dc0ea563921b..699ead285200 100644
--- a/gdb/mi/mi-common.c
+++ b/gdb/mi/mi-common.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-common.h"
 
 static const char * const async_reason_string_lookup[] =
diff --git a/gdb/mi/mi-console.c b/gdb/mi/mi-console.c
index 74d332005759..1f8d731e39fa 100644
--- a/gdb/mi/mi-console.c
+++ b/gdb/mi/mi-console.c
@@ -24,7 +24,6 @@
    for instance, error output is normally identified by a leading
    "&".  */
 
-#include "defs.h"
 #include "mi-console.h"
 
 /* Create a console that wraps the given output stream RAW with the
diff --git a/gdb/mi/mi-getopt.c b/gdb/mi/mi-getopt.c
index cf98c56e7e05..143c5b92dcdb 100644
--- a/gdb/mi/mi-getopt.c
+++ b/gdb/mi/mi-getopt.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-getopt.h"
 /* See comments about mi_getopt and mi_getopt_silent in mi-getopt.h.
    When there is an unknown option, if ERROR_ON_UNKNOWN is true,
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 38ae22769015..07e036f5ff90 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "mi-interp.h"
 
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index f4ab17915ecb..ab788a202310 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "target.h"
 #include "inferior.h"
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index 41bb95a92737..ff93d2cd4485 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-out.h"
 
 #include <vector>
diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c
index 6975821c7ec9..8804c98d7b4b 100644
--- a/gdb/mi/mi-parse.c
+++ b/gdb/mi/mi-parse.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-cmds.h"
 #include "mi-parse.h"
 #include "charset.h"
diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index 37cf2fbcfa2b..15c032b9ae29 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "mi-cmds.h"
 #include "symtab.h"
 #include "objfiles.h"
diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
index 6236ab0a0447..999a3bc27126 100644
--- a/gdb/microblaze-linux-tdep.c
+++ b/gdb/microblaze-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 07261bd4d22f..1886c973bdc5 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "frame.h"
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index 0ef19b680fb2..53815b2f683e 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "main.h"
 #include "serial.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/minidebug.c b/gdb/minidebug.c
index b7558b71f980..b3a1f121280a 100644
--- a/gdb/minidebug.c
+++ b/gdb/minidebug.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdb_bfd.h"
 #include "symfile.h"
 #include "objfiles.h"
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 6aa2010fb014..38176c4bdcb4 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -36,7 +36,6 @@
    to figure out what full symbol table entries need to be read in.  */
 
 
-#include "defs.h"
 #include <ctype.h>
 #include "symtab.h"
 #include "bfd.h"
diff --git a/gdb/mips-fbsd-nat.c b/gdb/mips-fbsd-nat.c
index 6dd7b00bf5ed..b4d410405e3d 100644
--- a/gdb/mips-fbsd-nat.c
+++ b/gdb/mips-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/mips-fbsd-tdep.c b/gdb/mips-fbsd-tdep.c
index 8464a92bf4af..188ef4099da8 100644
--- a/gdb/mips-fbsd-tdep.c
+++ b/gdb/mips-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regset.h"
 #include "trad-frame.h"
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 435aff82bbc5..97ec72e5d731 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "command.h"
 #include "gdbcmd.h"
 #include "inferior.h"
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index 0b5e7867788d..79508f0fce75 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "target.h"
 #include "solib-svr4.h"
diff --git a/gdb/mips-netbsd-nat.c b/gdb/mips-netbsd-nat.c
index ddf6a8d15db9..3576c099fa69 100644
--- a/gdb/mips-netbsd-nat.c
+++ b/gdb/mips-netbsd-nat.c
@@ -19,7 +19,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/mips-netbsd-tdep.c b/gdb/mips-netbsd-tdep.c
index 8d3604a8b905..63068a18fe8e 100644
--- a/gdb/mips-netbsd-tdep.c
+++ b/gdb/mips-netbsd-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/mips-sde-tdep.c b/gdb/mips-sde-tdep.c
index 7b367898f043..90988cdfdac0 100644
--- a/gdb/mips-sde-tdep.c
+++ b/gdb/mips-sde-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "elf-bfd.h"
 #include "symtab.h"
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 67bed1d2ba05..c34971c60c1b 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/mips64-obsd-nat.c b/gdb/mips64-obsd-nat.c
index 2b3449c2dc12..ced3ffb2ee28 100644
--- a/gdb/mips64-obsd-nat.c
+++ b/gdb/mips64-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/mips64-obsd-tdep.c b/gdb/mips64-obsd-tdep.c
index cacb8bbee50a..543938bc08eb 100644
--- a/gdb/mips64-obsd-tdep.c
+++ b/gdb/mips64-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "osabi.h"
 #include "regcache.h"
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 40b1413e2155..53def129be70 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -23,7 +23,6 @@
 /* Read symbols from an ECOFF file.  Most of the work is done in
    mdebugread.c.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "symtab.h"
 #include "objfiles.h"
diff --git a/gdb/mn10300-linux-tdep.c b/gdb/mn10300-linux-tdep.c
index 4554cb182314..8eb59d2cee46 100644
--- a/gdb/mn10300-linux-tdep.c
+++ b/gdb/mn10300-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "mn10300-tdep.h"
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index f8c5a0906ef5..cd70f8adb68d 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "gdbtypes.h"
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 812c92d1e0af..a6b783e5c84c 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c
index e07e3cc4be2b..9d90a6e2784d 100644
--- a/gdb/msp430-tdep.c
+++ b/gdb/msp430-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "prologue-value.h"
 #include "target.h"
diff --git a/gdb/namespace.c b/gdb/namespace.c
index 33057fe08bef..231c7bd4cb66 100644
--- a/gdb/namespace.c
+++ b/gdb/namespace.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "namespace.h"
 #include "frame.h"
 #include "symtab.h"
diff --git a/gdb/nat/aarch64-hw-point.c b/gdb/nat/aarch64-hw-point.c
index 08fd230b71f3..b62c4627d963 100644
--- a/gdb/nat/aarch64-hw-point.c
+++ b/gdb/nat/aarch64-hw-point.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/break-common.h"
 #include "gdbsupport/common-regcache.h"
 #include "aarch64-hw-point.h"
diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c
index 8a06a0c30ef9..43e04fef137d 100644
--- a/gdb/nat/aarch64-linux-hw-point.c
+++ b/gdb/nat/aarch64-linux-hw-point.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/break-common.h"
 #include "gdbsupport/common-regcache.h"
 #include "nat/linux-nat.h"
diff --git a/gdb/nat/aarch64-linux.c b/gdb/nat/aarch64-linux.c
index 5ebbc9b81f8a..5a95f22a6fce 100644
--- a/gdb/nat/aarch64-linux.c
+++ b/gdb/nat/aarch64-linux.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/break-common.h"
 #include "nat/linux-nat.h"
 #include "nat/aarch64-linux-hw-point.h"
diff --git a/gdb/nat/aarch64-mte-linux-ptrace.c b/gdb/nat/aarch64-mte-linux-ptrace.c
index dfd2856a642e..ace3e1880610 100644
--- a/gdb/nat/aarch64-mte-linux-ptrace.c
+++ b/gdb/nat/aarch64-mte-linux-ptrace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/byte-vector.h"
 
 #include "linux-ptrace.h"
diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.c b/gdb/nat/aarch64-scalable-linux-ptrace.c
index a840d513c0c0..81bb8eab4a8f 100644
--- a/gdb/nat/aarch64-scalable-linux-ptrace.c
+++ b/gdb/nat/aarch64-scalable-linux-ptrace.c
@@ -19,7 +19,6 @@
 
 #include <sys/utsname.h>
 #include <sys/uio.h>
-#include "gdbsupport/common-defs.h"
 #include "elf/external.h"
 #include "elf/common.h"
 #include "aarch64-scalable-linux-ptrace.h"
diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
index 8ced1935342b..f5e99941b5c1 100644
--- a/gdb/nat/amd64-linux-siginfo.c
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include <signal.h>
 #include "amd64-linux-siginfo.h"
 
diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c
index dfc2f6c5a88e..a5900fe4ee8f 100644
--- a/gdb/nat/fork-inferior.c
+++ b/gdb/nat/fork-inferior.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "fork-inferior.h"
 #include "target/waitstatus.h"
 #include "gdbsupport/filestuff.h"
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index f8352b62b8b6..5715168d2f08 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "linux-btrace.h"
 #include "gdbsupport/common-regcache.h"
 #include "gdbsupport/gdb_wait.h"
diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c
index 292e7e7ffc83..36a245c6a4cb 100644
--- a/gdb/nat/linux-namespaces.c
+++ b/gdb/nat/linux-namespaces.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/linux-namespaces.h"
 #include "gdbsupport/filestuff.h"
 #include <fcntl.h>
diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
index c9192940f236..6ffabe90aa7d 100644
--- a/gdb/nat/linux-osdata.c
+++ b/gdb/nat/linux-osdata.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "linux-osdata.h"
 
 #include <sys/types.h>
diff --git a/gdb/nat/linux-personality.c b/gdb/nat/linux-personality.c
index 49789321aeb8..a406c73dfe81 100644
--- a/gdb/nat/linux-personality.c
+++ b/gdb/nat/linux-personality.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/linux-personality.h"
 
 #include <sys/personality.h>
diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c
index b17e3120792e..e2086952ce6b 100644
--- a/gdb/nat/linux-procfs.c
+++ b/gdb/nat/linux-procfs.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "linux-procfs.h"
 #include "gdbsupport/filestuff.h"
 #include <dirent.h>
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 4fe8ffa40538..9ea0e22913f6 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "linux-ptrace.h"
 #include "linux-procfs.h"
 #include "linux-waitpid.h"
diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c
index 7b5b095b560a..0ac2f9fb2b9e 100644
--- a/gdb/nat/linux-waitpid.c
+++ b/gdb/nat/linux-waitpid.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 
 #include "linux-nat.h"
 #include "linux-waitpid.h"
diff --git a/gdb/nat/mips-linux-watch.c b/gdb/nat/mips-linux-watch.c
index 091d235f760c..7d105e8e6eac 100644
--- a/gdb/nat/mips-linux-watch.c
+++ b/gdb/nat/mips-linux-watch.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/gdb_ptrace.h"
 #include "mips-linux-watch.h"
 
diff --git a/gdb/nat/netbsd-nat.c b/gdb/nat/netbsd-nat.c
index 5b208c15fe47..713ed6a16fa5 100644
--- a/gdb/nat/netbsd-nat.c
+++ b/gdb/nat/netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/netbsd-nat.h"
 #include "gdbsupport/common-debug.h"
 
diff --git a/gdb/nat/ppc-linux.c b/gdb/nat/ppc-linux.c
index cc6dffe7d60f..d64ed33fcf21 100644
--- a/gdb/nat/ppc-linux.c
+++ b/gdb/nat/ppc-linux.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "ppc-linux.h"
 #include "nat/gdb_ptrace.h"
 #include <elf.h>
diff --git a/gdb/nat/riscv-linux-tdesc.c b/gdb/nat/riscv-linux-tdesc.c
index 32f52772f625..0cd38435b228 100644
--- a/gdb/nat/riscv-linux-tdesc.c
+++ b/gdb/nat/riscv-linux-tdesc.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 
 #include "gdb_proc_service.h"
 #include "arch/riscv.h"
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index 86b70c8d566b..f9f6848861d3 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/windows-nat.h"
 #include "gdbsupport/common-debug.h"
 #include "target/target.h"
diff --git a/gdb/nat/x86-dregs.c b/gdb/nat/x86-dregs.c
index d22e839730aa..7ea9f49eb680 100644
--- a/gdb/nat/x86-dregs.c
+++ b/gdb/nat/x86-dregs.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "x86-dregs.h"
 #include "gdbsupport/break-common.h"
 
diff --git a/gdb/nat/x86-linux-dregs.c b/gdb/nat/x86-linux-dregs.c
index a1bc49909d97..a6c0ea63552d 100644
--- a/gdb/nat/x86-linux-dregs.c
+++ b/gdb/nat/x86-linux-dregs.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "nat/gdb_ptrace.h"
 #include <sys/user.h>
 #include "target/waitstatus.h"
diff --git a/gdb/nat/x86-linux.c b/gdb/nat/x86-linux.c
index e61f4d749ba1..7a21c8f2c268 100644
--- a/gdb/nat/x86-linux.c
+++ b/gdb/nat/x86-linux.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "x86-linux.h"
 #include "x86-linux-dregs.h"
 
diff --git a/gdb/nat/x86-xstate.c b/gdb/nat/x86-xstate.c
index 9b64ceb309e6..970dda1d8946 100644
--- a/gdb/nat/x86-xstate.c
+++ b/gdb/nat/x86-xstate.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/x86-xstate.h"
 #include "nat/x86-cpuid.h"
 #include "nat/x86-xstate.h"
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index e453cd0f6d9a..bbbc80b37cd2 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/netbsd-nat.c b/gdb/netbsd-nat.c
index 574c1ad489ca..90456de165e2 100644
--- a/gdb/netbsd-nat.c
+++ b/gdb/netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "netbsd-nat.h"
 #include "nat/netbsd-nat.h"
diff --git a/gdb/netbsd-tdep.c b/gdb/netbsd-tdep.c
index e21217d75090..953b329674a4 100644
--- a/gdb/netbsd-tdep.c
+++ b/gdb/netbsd-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "auxv.h"
 #include "solib-svr4.h"
 #include "netbsd-tdep.h"
diff --git a/gdb/nios2-linux-tdep.c b/gdb/nios2-linux-tdep.c
index 9d2d4fff04a2..bd5f6cfe3f61 100644
--- a/gdb/nios2-linux-tdep.c
+++ b/gdb/nios2-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "osabi.h"
 #include "solib-svr4.h"
diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
index 0a8eeb88bb5a..da2616b436eb 100644
--- a/gdb/nios2-tdep.c
+++ b/gdb/nios2-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index a076a237f269..95a75b46d4fc 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include <fcntl.h>
 #include <spawn.h>
diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index a16459283f50..937902b4f0a5 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <sys/stat.h>
 #include "nto-tdep.h"
 #include "top.h"
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 2424e1e8530d..e492c82845b3 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index d880b9304d27..ba88ed1bc41b 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -22,7 +22,6 @@
 /* This file contains support routines for creating, manipulating, and
    destroying objfile structures.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "symtab.h"
 #include "symfile.h"
diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c
index d9134c0b18da..69a21ad71fce 100644
--- a/gdb/obsd-nat.c
+++ b/gdb/obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbthread.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/obsd-tdep.c b/gdb/obsd-tdep.c
index da53a82b2a82..5142984bc84f 100644
--- a/gdb/obsd-tdep.c
+++ b/gdb/obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "auxv.h"
 #include "frame.h"
 #include "symtab.h"
diff --git a/gdb/observable.c b/gdb/observable.c
index 6ee456243a53..0527cc68e2c0 100644
--- a/gdb/observable.c
+++ b/gdb/observable.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "observable.h"
 #include "command.h"
 #include "gdbcmd.h"
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 2b58deed5730..2132778b4bee 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "symtab.h"
 #include "expression.h"
diff --git a/gdb/or1k-linux-nat.c b/gdb/or1k-linux-nat.c
index 9a84bc93af32..21392245f484 100644
--- a/gdb/or1k-linux-nat.c
+++ b/gdb/or1k-linux-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "gregset.h"
 #include "linux-nat.h"
diff --git a/gdb/or1k-linux-tdep.c b/gdb/or1k-linux-tdep.c
index 75ab8459e754..00045a338204 100644
--- a/gdb/or1k-linux-tdep.c
+++ b/gdb/or1k-linux-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "or1k-tdep.h"
 #include "osabi.h"
 #include "glibc-tdep.h"
diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
index ffcb50f4bcd1..d4ac0ac1b9d1 100644
--- a/gdb/or1k-tdep.c
+++ b/gdb/or1k-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/osabi.c b/gdb/osabi.c
index 9917d360b6a2..016c203f47fe 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "osabi.h"
 #include "arch-utils.h"
diff --git a/gdb/osdata.c b/gdb/osdata.c
index a1cc468a346b..6dea1003cd2c 100644
--- a/gdb/osdata.c
+++ b/gdb/osdata.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "xml-support.h"
 #include "osdata.h"
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index ea7eb8c8d7e1..0bf98b3c2a86 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -43,7 +43,6 @@
    Probably also lots of other problems, less well defined PM.  */
 %{
 
-#include "defs.h"
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 73ba436437b1..adc6402084d7 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -19,7 +19,6 @@
 
 /* This file is derived from c-lang.c */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index eb2d0283d63d..5c48c1400c4d 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -18,7 +18,6 @@
 
 /* This file is derived from p-typeprint.c */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
 #include "symtab.h"
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 2372cdf83ebf..7f6d7dc6e6bb 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -19,7 +19,6 @@
 
 /* This file is derived from c-valprint.c */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/parse.c b/gdb/parse.c
index 4b0eeaf53305..fecaa81c318a 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -29,7 +29,6 @@
    during the process of parsing; the lower levels of the tree always
    come first in the result.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "arch-utils.h"
 #include "symtab.h"
diff --git a/gdb/posix-hdep.c b/gdb/posix-hdep.c
index ae5add9790f1..a0d5c585ebc7 100644
--- a/gdb/posix-hdep.c
+++ b/gdb/posix-hdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/event-loop.h"
 #include "gdbsupport/gdb_select.h"
 #include "inferior.h"
diff --git a/gdb/ppc-fbsd-nat.c b/gdb/ppc-fbsd-nat.c
index 1925660f4573..b3b20ffdbbc1 100644
--- a/gdb/ppc-fbsd-nat.c
+++ b/gdb/ppc-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/ppc-fbsd-tdep.c b/gdb/ppc-fbsd-tdep.c
index 719ddc71d130..8f86607d5d19 100644
--- a/gdb/ppc-fbsd-tdep.c
+++ b/gdb/ppc-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "gdbcore.h"
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 028422bb1e8d..2ed6e6e50685 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbthread.h"
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 2824cb628c3d..2da2d32eb262 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/ppc-netbsd-nat.c b/gdb/ppc-netbsd-nat.c
index 06a7a3710f71..a384944376e2 100644
--- a/gdb/ppc-netbsd-nat.c
+++ b/gdb/ppc-netbsd-nat.c
@@ -21,7 +21,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 
 #include <sys/types.h>
 #include <sys/ptrace.h>
diff --git a/gdb/ppc-netbsd-tdep.c b/gdb/ppc-netbsd-tdep.c
index 58f5678d5d9c..d8e4c424ba46 100644
--- a/gdb/ppc-netbsd-tdep.c
+++ b/gdb/ppc-netbsd-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "osabi.h"
 #include "regcache.h"
diff --git a/gdb/ppc-obsd-nat.c b/gdb/ppc-obsd-nat.c
index 06a67c3e25ff..66e7b9357fa7 100644
--- a/gdb/ppc-obsd-nat.c
+++ b/gdb/ppc-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
diff --git a/gdb/ppc-obsd-tdep.c b/gdb/ppc-obsd-tdep.c
index b845e67bcaab..b50a24c6af79 100644
--- a/gdb/ppc-obsd-tdep.c
+++ b/gdb/ppc-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame.h"
 #include "frame-unwind.h"
diff --git a/gdb/ppc-ravenscar-thread.c b/gdb/ppc-ravenscar-thread.c
index 8e610573bd97..fd44a9a3ec6a 100644
--- a/gdb/ppc-ravenscar-thread.c
+++ b/gdb/ppc-ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "ppc-tdep.h"
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index ebbf1cf4295f..9d0e8a95a773 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c
index 5797d55f00b7..8f91d06a085d 100644
--- a/gdb/ppc64-tdep.c
+++ b/gdb/ppc64-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "infrun.h"
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 63e530e612e2..cb0d32aa4bcf 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/probe.c b/gdb/probe.c
index 4d68e129636e..b13baf00e714 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "probe.h"
 #include "command.h"
 #include "cli/cli-cmds.h"
diff --git a/gdb/proc-api.c b/gdb/proc-api.c
index 07395c5ab0b4..0d3f389afdb5 100644
--- a/gdb/proc-api.c
+++ b/gdb/proc-api.c
@@ -24,7 +24,6 @@
  * Pretty-print trace of api calls to the /proc api
  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "completer.h"
 
diff --git a/gdb/proc-events.c b/gdb/proc-events.c
index 76d66deb593b..55b73636cb56 100644
--- a/gdb/proc-events.c
+++ b/gdb/proc-events.c
@@ -28,7 +28,6 @@
    FIXME: At present, the syscall translation table must be
    initialized, which is not true of the other translation tables.  */
 
-#include "defs.h"
 
 #include <sys/types.h>
 #include <sys/procfs.h>
diff --git a/gdb/proc-flags.c b/gdb/proc-flags.c
index 24b0cce91be7..33075e933ecc 100644
--- a/gdb/proc-flags.c
+++ b/gdb/proc-flags.c
@@ -25,7 +25,6 @@
  *
  */
 
-#include "defs.h"
 
 #include <sys/types.h>
 #include <sys/procfs.h>
diff --git a/gdb/proc-service.c b/gdb/proc-service.c
index f2ba0975096a..1889a001a1dd 100644
--- a/gdb/proc-service.c
+++ b/gdb/proc-service.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/proc-why.c b/gdb/proc-why.c
index 5bfc3627c7e6..ec8987ddb736 100644
--- a/gdb/proc-why.c
+++ b/gdb/proc-why.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include <sys/types.h>
 #include <sys/procfs.h>
diff --git a/gdb/process-stratum-target.c b/gdb/process-stratum-target.c
index 8737938e3b49..ce8ff28958e0 100644
--- a/gdb/process-stratum-target.c
+++ b/gdb/process-stratum-target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "process-stratum-target.h"
 #include "inferior.h"
 #include <algorithm>
diff --git a/gdb/procfs.c b/gdb/procfs.c
index ba2b166727ee..77fdacfd61e1 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "infrun.h"
 #include "target.h"
diff --git a/gdb/producer.c b/gdb/producer.c
index cd615a450c2f..2ca701f5c7ca 100644
--- a/gdb/producer.c
+++ b/gdb/producer.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "producer.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/gdb_regex.h"
diff --git a/gdb/progspace-and-thread.c b/gdb/progspace-and-thread.c
index 092deb774712..e78e56d84946 100644
--- a/gdb/progspace-and-thread.c
+++ b/gdb/progspace-and-thread.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "progspace-and-thread.h"
 #include "inferior.h"
 
diff --git a/gdb/progspace.c b/gdb/progspace.c
index cda0f415a3fd..131cd2f11865 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
 #include "arch-utils.h"
diff --git a/gdb/prologue-value.c b/gdb/prologue-value.c
index 7183a9079a3f..2c0ce52421b5 100644
--- a/gdb/prologue-value.c
+++ b/gdb/prologue-value.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "prologue-value.h"
 #include "regcache.h"
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index a831e5eec40b..a4f5b04627c2 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "objfiles.h"
 #include "psymtab.h"
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index 663113d4fd5b..c6f566221d82 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "arch-utils.h"
 #include "disasm.h"
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index 42795259399c..8a3327b37226 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index 9417ebc252e9..3e30faf08560 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "block.h"
 #include "dictionary.h"
 #include "symtab.h"
diff --git a/gdb/python/py-bpevent.c b/gdb/python/py-bpevent.c
index dc962f117882..5982a26f5629 100644
--- a/gdb/python/py-bpevent.c
+++ b/gdb/python/py-bpevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-stopevent.h"
 
 /* Create and initialize a BreakpointEvent object.  This acquires new
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 95782444c4a7..cd9ef3093c16 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "python-internal.h"
 #include "python.h"
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 91e8f100e1c4..f18a8e8eaa9a 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "value.h"
 #include "python-internal.h"
diff --git a/gdb/python/py-connection.c b/gdb/python/py-connection.c
index 84f80cf6a74b..dcca76b7867b 100644
--- a/gdb/python/py-connection.c
+++ b/gdb/python/py-connection.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "process-stratum-target.h"
 #include "inferior.h"
diff --git a/gdb/python/py-continueevent.c b/gdb/python/py-continueevent.c
index e366b4d1bc3c..c859b1e91cae 100644
--- a/gdb/python/py-continueevent.c
+++ b/gdb/python/py-continueevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 #include "gdbthread.h"
 
diff --git a/gdb/python/py-dap.c b/gdb/python/py-dap.c
index 9a00130fe907..861514d90021 100644
--- a/gdb/python/py-dap.c
+++ b/gdb/python/py-dap.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "interps.h"
 #include "cli-out.h"
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index b48d5620b158..2d8ce44a0655 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "language.h"
 #include "dis-asm.h"
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index 7ac16c850f16..47a2997a09a3 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 
 void
diff --git a/gdb/python/py-evtregistry.c b/gdb/python/py-evtregistry.c
index d968815003a2..1f486e28c92e 100644
--- a/gdb/python/py-evtregistry.c
+++ b/gdb/python/py-evtregistry.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "command.h"
 #include "py-events.h"
 
diff --git a/gdb/python/py-evts.c b/gdb/python/py-evts.c
index 1fbba517a39a..4e966e197e3f 100644
--- a/gdb/python/py-evts.c
+++ b/gdb/python/py-evts.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-events.h"
 
 static struct PyModuleDef EventModuleDef =
diff --git a/gdb/python/py-exitedevent.c b/gdb/python/py-exitedevent.c
index bef16c913a1e..4837468ff997 100644
--- a/gdb/python/py-exitedevent.c
+++ b/gdb/python/py-exitedevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 
 static gdbpy_ref<>
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 617e879a040c..c74a2473a815 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -19,7 +19,6 @@
 
 
 
-#include "defs.h"
 #include "top.h"
 #include "python-internal.h"
 #include "breakpoint.h"
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 7467f845b78f..bbb42afb2ede 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "charset.h"
 #include "block.h"
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 768e3a6e0c81..0cd15977d2ff 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "symtab.h"
 #include "language.h"
diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c
index 81c4106c477d..077396cb93ec 100644
--- a/gdb/python/py-function.c
+++ b/gdb/python/py-function.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "value.h"
 #include "python-internal.h"
 #include "charset.h"
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
index bbf49bb73264..92287eea7c91 100644
--- a/gdb/python/py-gdb-readline.c
+++ b/gdb/python/py-gdb-readline.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "top.h"
 #include "cli/cli-utils.h"
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index c25519c8dd9c..795ac655ddd5 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "auto-load.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
diff --git a/gdb/python/py-infevents.c b/gdb/python/py-infevents.c
index 8a150852e089..f53d589f85b5 100644
--- a/gdb/python/py-infevents.c
+++ b/gdb/python/py-infevents.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 
 /* Construct either a gdb.InferiorCallPreEvent or a
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 995397e7f0d2..a17f25ed4985 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbthread.h"
 #include "inferior.h"
 #include "python-internal.h"
diff --git a/gdb/python/py-instruction.c b/gdb/python/py-instruction.c
index e3c99ef7a7b3..bc3945af2cf0 100644
--- a/gdb/python/py-instruction.c
+++ b/gdb/python/py-instruction.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-instruction.h"
 
 /* Python type object for the abstract gdb.Instruction class.  This class
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index 5d07f376f97c..0b7f5c9d680a 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "charset.h"
 #include "value.h"
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index 31194786eb7b..e3e71f9e4367 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 
 struct linetable_entry_object {
diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c
index 538d7f41fe3e..af48d01b9edd 100644
--- a/gdb/python/py-membuf.c
+++ b/gdb/python/py-membuf.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 
 struct membuf_object {
diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c
index 49e524a2df81..bc95e86a4566 100644
--- a/gdb/python/py-mi.c
+++ b/gdb/python/py-mi.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "py-uiout.h"
 #include "utils.h"
diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c
index aab6c5c2317a..54427d4633b1 100644
--- a/gdb/python/py-micmd.c
+++ b/gdb/python/py-micmd.c
@@ -19,7 +19,6 @@
 
 /* GDB/MI commands implemented in Python.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "arch-utils.h"
 #include "charset.h"
diff --git a/gdb/python/py-newobjfileevent.c b/gdb/python/py-newobjfileevent.c
index b7a09680613a..deaee706246c 100644
--- a/gdb/python/py-newobjfileevent.c
+++ b/gdb/python/py-newobjfileevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 
 static gdbpy_ref<>
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index ffdb7be4a9a1..60a14833b957 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "charset.h"
 #include "objfiles.h"
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 9f3c63116ec9..ba837566343e 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "value.h"
 #include "python-internal.h"
 #include "charset.h"
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index fb141fb42dc5..368b3a3c793f 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "symtab.h"
 #include "language.h"
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index 5d883a7d8127..a5b22ce9d5c8 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "charset.h"
 #include "progspace.h"
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index 347100ba404e..8c34add0d771 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "gdbcmd.h"
 #include "gdbthread.h"
diff --git a/gdb/python/py-record-full.c b/gdb/python/py-record-full.c
index 73b24053c9da..b6623a600c58 100644
--- a/gdb/python/py-record-full.c
+++ b/gdb/python/py-record-full.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-record-full.h"
 
 /* Implementation of
diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c
index 81b4c63d5974..d4891268e036 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-instruction.h"
 #include "py-record.h"
 #include "py-record-btrace.h"
diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c
index d7a40c9ba581..f03274c308a1 100644
--- a/gdb/python/py-registers.c
+++ b/gdb/python/py-registers.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "arch-utils.h"
 #include "reggroups.h"
diff --git a/gdb/python/py-signalevent.c b/gdb/python/py-signalevent.c
index 73f56035e354..bf511064fe6c 100644
--- a/gdb/python/py-signalevent.c
+++ b/gdb/python/py-signalevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-stopevent.h"
 
 gdbpy_ref<>
diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c
index fcaebe26f13c..be26bc17f859 100644
--- a/gdb/python/py-stopevent.c
+++ b/gdb/python/py-stopevent.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-stopevent.h"
 #include "py-uiout.h"
 #include "thread-fsm.h"
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 88da56527e83..754420f3b564 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "block.h"
 #include "frame.h"
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index b28f6ca8b48c..7290b8564789 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "charset.h"
 #include "symtab.h"
 #include "source.h"
diff --git a/gdb/python/py-threadevent.c b/gdb/python/py-threadevent.c
index 5c99b60b46f6..557f2b780170 100644
--- a/gdb/python/py-threadevent.c
+++ b/gdb/python/py-threadevent.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "py-event.h"
 #include "infrun.h"
 #include "gdbthread.h"
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index 089f4f877686..5dcec4bd2b11 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "python-internal.h"
 #include "gdbsupport/intrusive_list.h"
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 8793db8eed1e..863e6f6175fc 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "python-internal.h"
 #include "charset.h"
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index 56f925bc57f0..58bcf40e1c9f 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "frame-unwind.h"
 #include "gdbsupport/gdb_obstack.h"
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 3fcf48f79988..47f65f4fd441 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "charset.h"
 #include "value.h"
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index ff7943d80c39..dd17420b0b50 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "top.h"
 #include "charset.h"
 #include "value.h"
diff --git a/gdb/python/py-varobj.c b/gdb/python/py-varobj.c
index efe6b4312b64..cbfea266f605 100644
--- a/gdb/python/py-varobj.c
+++ b/gdb/python/py-varobj.c
@@ -13,7 +13,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "python-internal.h"
 #include "varobj.h"
 #include "varobj-iter.h"
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index c7041eb2ad3c..2fae04303b22 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "extension-priv.h"
 #include "objfiles.h"
diff --git a/gdb/python/python.c b/gdb/python/python.c
index e2ac315f9f59..d6e5883476e1 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "command.h"
 #include "ui-out.h"
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 75d110f20c5c..ecc9235c9174 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
 #include "ada-lang.h"
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 6350400c318a..0ef1dfbe652f 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "record.h"
 #include "record-btrace.h"
 #include "gdbthread.h"
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 24058824d749..4c3667f48bad 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "regcache.h"
 #include "gdbthread.h"
diff --git a/gdb/record.c b/gdb/record.c
index 25901d2deefd..1843969c2c9b 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "completer.h"
 #include "record.h"
diff --git a/gdb/regcache-dump.c b/gdb/regcache-dump.c
index 709dd0586336..33205a4241d8 100644
--- a/gdb/regcache-dump.c
+++ b/gdb/regcache-dump.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "regcache.h"
 #include "gdbsupport/def-vector.h"
diff --git a/gdb/regcache.c b/gdb/regcache.c
index af298893acf9..b7abbe99f3cc 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbthread.h"
 #include "target.h"
diff --git a/gdb/reggroups.c b/gdb/reggroups.c
index ee76c04623e7..8fb21bd7622d 100644
--- a/gdb/reggroups.c
+++ b/gdb/reggroups.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "reggroups.h"
 #include "gdbtypes.h"
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index 154cd0be8e5f..eaa0d8f619a6 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -19,7 +19,6 @@
 
 /* See the GDB User Guide for details of the GDB remote protocol.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "remote.h"
 #include "gdbsupport/gdb_wait.h"
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index 2088b50fd957..9acf3f8dc78e 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -31,7 +31,6 @@
    remote_async_get_pending_events_handler, while in all-stop mode,
    they are processed in remote_resume.  */
 
-#include "defs.h"
 #include "remote.h"
 #include "remote-notif.h"
 #include "observable.h"
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index e761d3a05799..5fccefe93a16 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdb_bfd.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/remote.c b/gdb/remote.c
index 14c8b020b1e9..e278711df7b5 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -19,7 +19,6 @@
 
 /* See the GDB User Guide for details of the GDB remote protocol.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include <fcntl.h>
 #include "inferior.h"
diff --git a/gdb/reverse.c b/gdb/reverse.c
index 9a011631a320..11c76b4b3355 100644
--- a/gdb/reverse.c
+++ b/gdb/reverse.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "top.h"
 #include "cli/cli-cmds.h"
diff --git a/gdb/riscv-fbsd-nat.c b/gdb/riscv-fbsd-nat.c
index 8da2e02fafec..bc9d613d207f 100644
--- a/gdb/riscv-fbsd-nat.c
+++ b/gdb/riscv-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "target.h"
 
diff --git a/gdb/riscv-fbsd-tdep.c b/gdb/riscv-fbsd-tdep.c
index 205f7a950df5..68f726743d9c 100644
--- a/gdb/riscv-fbsd-tdep.c
+++ b/gdb/riscv-fbsd-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "fbsd-tdep.h"
 #include "osabi.h"
 #include "riscv-tdep.h"
diff --git a/gdb/riscv-linux-nat.c b/gdb/riscv-linux-nat.c
index 5bccc1f53490..a5507e88ea17 100644
--- a/gdb/riscv-linux-nat.c
+++ b/gdb/riscv-linux-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "gregset.h"
 #include "linux-nat.h"
diff --git a/gdb/riscv-linux-tdep.c b/gdb/riscv-linux-tdep.c
index 0267dc65e58e..ff478cf4c287 100644
--- a/gdb/riscv-linux-tdep.c
+++ b/gdb/riscv-linux-tdep.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "riscv-tdep.h"
 #include "osabi.h"
 #include "glibc-tdep.h"
diff --git a/gdb/riscv-none-tdep.c b/gdb/riscv-none-tdep.c
index 7dcab01de6d1..e98c699a68c5 100644
--- a/gdb/riscv-none-tdep.c
+++ b/gdb/riscv-none-tdep.c
@@ -17,7 +17,6 @@
 
 /* This file contain code that is specific for bare-metal RISC-V targets.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "regcache.h"
 #include "riscv-tdep.h"
diff --git a/gdb/riscv-ravenscar-thread.c b/gdb/riscv-ravenscar-thread.c
index 794b0c44c998..291b1db8d9e4 100644
--- a/gdb/riscv-ravenscar-thread.c
+++ b/gdb/riscv-ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 604a19fe2a62..f86a37988cbd 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
@@ -49,7 +48,6 @@
 #include "dwarf2/frame.h"
 #include "user-regs.h"
 #include "valprint.h"
-#include "gdbsupport/common-defs.h"
 #include "opcode/riscv-opc.h"
 #include "cli/cli-decode.h"
 #include "observable.h"
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index 1e439f363564..acd0731dd9f4 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "prologue-value.h"
 #include "target.h"
diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c
index 066d34d446c5..908671a713a4 100644
--- a/gdb/rs6000-aix-nat.c
+++ b/gdb/rs6000-aix-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "target.h"
 #include "gdbcore.h"
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index db76af6984b9..5111f4f55c0a 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c
index c92c71dcb881..550e06882031 100644
--- a/gdb/rs6000-lynx178-tdep.c
+++ b/gdb/rs6000-lynx178-tdep.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "gdbcore.h"
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 3157213cb1fa..b7ba0042bb73 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c
index 7b9807e0eaf0..e30dabaff032 100644
--- a/gdb/run-on-main-thread.c
+++ b/gdb/run-on-main-thread.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "run-on-main-thread.h"
 #include "ser-event.h"
 #if CXX_STD_THREAD
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index ab537cc97528..64e40577a696 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include <ctype.h>
 
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index 66263b91bdc9..9300e17bdf83 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "block.h"
 #include "charset.h"
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index 53ad5d5c92b2..844e36023e04 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "prologue-value.h"
 #include "target.h"
diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c
index 60cbc26afffd..29d4ef3b71ce 100644
--- a/gdb/s12z-tdep.c
+++ b/gdb/s12z-tdep.c
@@ -18,7 +18,6 @@
 
 /* Much of this file is shamelessly copied from or1k-tdep.c and others.  */
 
-#include "defs.h"
 
 #include "arch-utils.h"
 #include "dwarf2/frame.h"
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index 1e074814d87b..fa4aaf9aa9ae 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 945b3c7cee72..bc1db550d2e7 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "auxv.h"
 #include "elf/common.h"
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 174338e18852..519e3eb0a423 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "arch-utils.h"
 #include "ax-gdb.h"
diff --git a/gdb/selftest-arch.c b/gdb/selftest-arch.c
index 99677edfa66f..a337f76083ab 100644
--- a/gdb/selftest-arch.c
+++ b/gdb/selftest-arch.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <functional>
 
 #if GDB_SELF_TEST
diff --git a/gdb/sentinel-frame.c b/gdb/sentinel-frame.c
index ca7c28952f36..4eaeae0d254f 100644
--- a/gdb/sentinel-frame.c
+++ b/gdb/sentinel-frame.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "regcache.h"
 #include "sentinel-frame.h"
 #include "inferior.h"
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index f63082685466..ccf38d2202b6 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/ser-event.c b/gdb/ser-event.c
index 374322ead23c..fe1c460aa1fe 100644
--- a/gdb/ser-event.c
+++ b/gdb/ser-event.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ser-event.h"
 #include "serial.h"
 #include "gdbsupport/filestuff.h"
diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c
index 57c44806c0e8..ae71f73cce92 100644
--- a/gdb/ser-go32.c
+++ b/gdb/ser-go32.c
@@ -21,7 +21,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "serial.h"
 /*
diff --git a/gdb/ser-mingw.c b/gdb/ser-mingw.c
index 5c2e06c29262..2603bb8dcfb4 100644
--- a/gdb/ser-mingw.c
+++ b/gdb/ser-mingw.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 #include "ser-tcp.h"
diff --git a/gdb/ser-pipe.c b/gdb/ser-pipe.c
index 842b656eb5af..49312036da02 100644
--- a/gdb/ser-pipe.c
+++ b/gdb/ser-pipe.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 #include "ser-unix.h"
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index 3f5541d0a2f2..6efc2457bdb7 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 #include "ser-tcp.h"
diff --git a/gdb/ser-uds.c b/gdb/ser-uds.c
index 39a5f6f053a0..8da4c7a22fa5 100644
--- a/gdb/ser-uds.c
+++ b/gdb/ser-uds.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index bc8b087b6eb6..db1464f8f6e8 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
 #include "ser-unix.h"
diff --git a/gdb/serial.c b/gdb/serial.c
index 734a580ed020..aeab7ebcfb08 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "serial.h"
 #include "gdbcmd.h"
diff --git a/gdb/sh-linux-tdep.c b/gdb/sh-linux-tdep.c
index c78d363400ad..affbf550a505 100644
--- a/gdb/sh-linux-tdep.c
+++ b/gdb/sh-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 
 #include "solib-svr4.h"
diff --git a/gdb/sh-netbsd-nat.c b/gdb/sh-netbsd-nat.c
index cf321984eeb6..c3c31e9bb3a0 100644
--- a/gdb/sh-netbsd-nat.c
+++ b/gdb/sh-netbsd-nat.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 
 #include <sys/types.h>
diff --git a/gdb/sh-netbsd-tdep.c b/gdb/sh-netbsd-tdep.c
index e04df2709f4b..fec6a2e03d22 100644
--- a/gdb/sh-netbsd-tdep.c
+++ b/gdb/sh-netbsd-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regset.h"
 #include "value.h"
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 16e513eb4053..1c67ea42b040 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -20,7 +20,6 @@
 /* Contributed by Steve Chamberlain
    sac@cygnus.com.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/skip.c b/gdb/skip.c
index 79db4c54e06e..f2818eccb34c 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "skip.h"
 #include "value.h"
 #include "valprint.h"
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index d58e2af0d22e..7c17601d5608 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -48,7 +48,6 @@
    symbols, etc...  The ps_* routines actually do most of their work
    by calling functions in procfs.c.  */
 
-#include "defs.h"
 #include <thread.h>
 #include <proc_service.h>
 #include <thread_db.h>
diff --git a/gdb/sol2-tdep.c b/gdb/sol2-tdep.c
index 4ee2d0ac3460..468b132165e6 100644
--- a/gdb/sol2-tdep.c
+++ b/gdb/sol2-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "symtab.h"
 #include "inferior.h"
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 8c8f219bdc59..a50bb165c193 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "solib-aix.h"
 #include "solib.h"
 #include "solist.h"
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 5ef0646d5385..6943b2df5865 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "bfd.h"
 #include "objfiles.h"
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index f1c10d0f302d..0208ed13effc 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -17,7 +17,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "solib.h"
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index f90a0a218d6c..aef609378a42 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -17,7 +17,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "solib.h"
 #include "solist.h"
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index 02ab36bb95e6..b714e4ef6cce 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "amd-dbgapi-target.h"
 #include "amdgpu-tdep.h"
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 2377ed3341dc..49dd1e9aa330 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "elf/external.h"
 #include "elf/common.h"
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index bb4c6a6c174f..6563da05a471 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "objfiles.h"
 #include "solist.h"
 #include "symtab.h"
diff --git a/gdb/solib.c b/gdb/solib.c
index 9497f5d30992..2f69c3372b0b 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include <fcntl.h>
 #include "symtab.h"
diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index 8b5bd84d19a8..6af984fb88bf 100644
--- a/gdb/source-cache.c
+++ b/gdb/source-cache.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "source-cache.h"
 #include "gdbsupport/scoped_fd.h"
 #include "source.h"
diff --git a/gdb/source.c b/gdb/source.c
index bbeb41542583..432301e2a717 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "expression.h"
diff --git a/gdb/sparc-linux-nat.c b/gdb/sparc-linux-nat.c
index f8142435162b..0b3a69256109 100644
--- a/gdb/sparc-linux-nat.c
+++ b/gdb/sparc-linux-nat.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 
 #include <sys/procfs.h>
diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c
index 1590cbdc4f05..fac4c7d773db 100644
--- a/gdb/sparc-linux-tdep.c
+++ b/gdb/sparc-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/frame.h"
 #include "frame.h"
 #include "frame-unwind.h"
diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c
index d3149ab39ef7..b8d0bed622f0 100644
--- a/gdb/sparc-nat.c
+++ b/gdb/sparc-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/sparc-netbsd-nat.c b/gdb/sparc-netbsd-nat.c
index 1f65c01d3dfb..82592ccc3cfa 100644
--- a/gdb/sparc-netbsd-nat.c
+++ b/gdb/sparc-netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "target.h"
 
diff --git a/gdb/sparc-netbsd-tdep.c b/gdb/sparc-netbsd-tdep.c
index d2b1a4bfd140..fc22e66826fd 100644
--- a/gdb/sparc-netbsd-tdep.c
+++ b/gdb/sparc-netbsd-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc-obsd-tdep.c b/gdb/sparc-obsd-tdep.c
index 8cdbc8aae6e7..d6166710709c 100644
--- a/gdb/sparc-obsd-tdep.c
+++ b/gdb/sparc-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc-ravenscar-thread.c b/gdb/sparc-ravenscar-thread.c
index 0f6dec072c3e..82f68e14cb28 100644
--- a/gdb/sparc-ravenscar-thread.c
+++ b/gdb/sparc-ravenscar-thread.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "sparc-tdep.h"
diff --git a/gdb/sparc-sol2-nat.c b/gdb/sparc-sol2-nat.c
index cee9a68459e5..8f9607f338d9 100644
--- a/gdb/sparc-sol2-nat.c
+++ b/gdb/sparc-sol2-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 
 #include <sys/procfs.h>
diff --git a/gdb/sparc-sol2-tdep.c b/gdb/sparc-sol2-tdep.c
index 525784401038..aea3766d9b53 100644
--- a/gdb/sparc-sol2-tdep.c
+++ b/gdb/sparc-sol2-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 5eec3615f536..fbc27ffcb5e6 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "dwarf2.h"
diff --git a/gdb/sparc64-fbsd-nat.c b/gdb/sparc64-fbsd-nat.c
index 7c025405e974..c10d55f0cd0e 100644
--- a/gdb/sparc64-fbsd-nat.c
+++ b/gdb/sparc64-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 #include "target.h"
 
diff --git a/gdb/sparc64-fbsd-tdep.c b/gdb/sparc64-fbsd-tdep.c
index c992c8c8f6fb..a30c7c448e5b 100644
--- a/gdb/sparc64-fbsd-tdep.c
+++ b/gdb/sparc64-fbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc64-linux-nat.c b/gdb/sparc64-linux-nat.c
index 24dfa2c01455..bd9aafd58b00 100644
--- a/gdb/sparc64-linux-nat.c
+++ b/gdb/sparc64-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "regcache.h"
 
 #include <sys/procfs.h>
diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c
index 33da5321d81a..e91bba3aadba 100644
--- a/gdb/sparc64-linux-tdep.c
+++ b/gdb/sparc64-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "dwarf2/frame.h"
diff --git a/gdb/sparc64-nat.c b/gdb/sparc64-nat.c
index a7cc4403c250..aa07bf5d3628 100644
--- a/gdb/sparc64-nat.c
+++ b/gdb/sparc64-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbarch.h"
 
 #include "sparc64-tdep.h"
diff --git a/gdb/sparc64-netbsd-nat.c b/gdb/sparc64-netbsd-nat.c
index 32dc87e5495a..111a45dd8a76 100644
--- a/gdb/sparc64-netbsd-nat.c
+++ b/gdb/sparc64-netbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/sparc64-netbsd-tdep.c b/gdb/sparc64-netbsd-tdep.c
index fe97689ae157..b101f4970d90 100644
--- a/gdb/sparc64-netbsd-tdep.c
+++ b/gdb/sparc64-netbsd-tdep.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc64-obsd-nat.c b/gdb/sparc64-obsd-nat.c
index c007edb71229..71589d109e3d 100644
--- a/gdb/sparc64-obsd-nat.c
+++ b/gdb/sparc64-obsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/sparc64-obsd-tdep.c b/gdb/sparc64-obsd-tdep.c
index 3837074a9fb7..6caeb107b9f0 100644
--- a/gdb/sparc64-obsd-tdep.c
+++ b/gdb/sparc64-obsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc64-sol2-tdep.c b/gdb/sparc64-sol2-tdep.c
index 7cef98bb681c..b7ca4ca1f5ba 100644
--- a/gdb/sparc64-sol2-tdep.c
+++ b/gdb/sparc64-sol2-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbarch.h"
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 8a90dd00d16f..a55107fa32d9 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dwarf2/frame.h"
 #include "frame.h"
diff --git a/gdb/split-name.c b/gdb/split-name.c
index eacec135530b..f29608095ab3 100644
--- a/gdb/split-name.c
+++ b/gdb/split-name.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "split-name.h"
 #include "cp-support.h"
 
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 025cb2120d19..85fe4000f329 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -24,7 +24,6 @@
    format).  Avoid placing any object file format specific code in
    this file.  */
 
-#include "defs.h"
 #include "bfd.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
diff --git a/gdb/stack.c b/gdb/stack.c
index 23e3891a0600..9c679222708e 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index b54e4d2d10a7..0b66554efae1 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "stap-probe.h"
 #include "probe.h"
 #include "ui-out.h"
diff --git a/gdb/std-regs.c b/gdb/std-regs.c
index 755e0c987e6e..3539d8a629a6 100644
--- a/gdb/std-regs.c
+++ b/gdb/std-regs.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "user-regs.h"
 #include "frame.h"
 #include "gdbtypes.h"
diff --git a/gdb/stub-termcap.c b/gdb/stub-termcap.c
index 28b046d7f7f1..ff0ef9929604 100644
--- a/gdb/stub-termcap.c
+++ b/gdb/stub-termcap.c
@@ -20,7 +20,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "defs.h"
 
 extern "C" {
 
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 3955298b1fef..bc70447600ee 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -25,7 +25,6 @@
    and then if the function returns a result printing a message after it
    returns.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
 #include "observable.h"
diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c
index 12a5f7d936b2..87fcc076986e 100644
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -41,7 +41,6 @@
    entry point.  */
 
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbcore.h"
 #include "objfiles.h"
diff --git a/gdb/symfile.c b/gdb/symfile.c
index db6d76e78bf5..2a7d41dc9746 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "bfdlink.h"
 #include "symtab.h"
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 49b9674f77ad..f80fc5ab196d 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "bfd.h"
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 33b664f94789..86603dfebc31 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "dwarf2/call-site.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/target-connection.c b/gdb/target-connection.c
index 388fd873d642..d9a529ae9bb3 100644
--- a/gdb/target-connection.c
+++ b/gdb/target-connection.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target-connection.h"
 
 #include <map>
diff --git a/gdb/target-dcache.c b/gdb/target-dcache.c
index 72886d753ec0..7c6bcd8d18c9 100644
--- a/gdb/target-dcache.c
+++ b/gdb/target-dcache.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target-dcache.h"
 #include "gdbcmd.h"
 #include "progspace.h"
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 591ae3dac7b5..8aca5cf719ba 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "gdbcmd.h"
 #include "gdbtypes.h"
@@ -1299,7 +1298,6 @@ class print_c_tdesc : public tdesc_element_visitor
     gdb_printf ("  Original: %s */\n\n",
 		lbasename (m_filename_after_features.c_str ()));
 
-    gdb_printf ("#include \"defs.h\"\n");
     gdb_printf ("#include \"osabi.h\"\n");
     gdb_printf ("#include \"target-descriptions.h\"\n");
     gdb_printf ("\n");
diff --git a/gdb/target-float.c b/gdb/target-float.c
index 415988923561..9b1b6b781d98 100644
--- a/gdb/target-float.c
+++ b/gdb/target-float.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "floatformat.h"
 #include "target-float.h"
diff --git a/gdb/target-memory.c b/gdb/target-memory.c
index 6bb67e44aa0d..f752769e415a 100644
--- a/gdb/target-memory.c
+++ b/gdb/target-memory.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "memory-map.h"
 #include "inferior.h"
diff --git a/gdb/target.c b/gdb/target.c
index bbc1badc9e19..107a84b3ca1d 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "target-dcache.h"
 #include "gdbcmd.h"
diff --git a/gdb/target/target.c b/gdb/target/target.c
index f00506a625ef..c84a6ff52daa 100644
--- a/gdb/target/target.c
+++ b/gdb/target/target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "target/target.h"
 
 /* Read LEN bytes of target memory at address MEMADDR, placing the
diff --git a/gdb/target/waitstatus.c b/gdb/target/waitstatus.c
index 411a2ecc4f82..30c0621326fd 100644
--- a/gdb/target/waitstatus.c
+++ b/gdb/target/waitstatus.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "waitstatus.h"
 
 /* See waitstatus.h.  */
diff --git a/gdb/test-target.c b/gdb/test-target.c
index 3d6629506701..4da7a08f24e6 100644
--- a/gdb/test-target.c
+++ b/gdb/test-target.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "test-target.h"
 
 #if GDB_SELF_TEST
diff --git a/gdb/thread-iter.c b/gdb/thread-iter.c
index 31fcf1fc2551..601d23c9ec34 100644
--- a/gdb/thread-iter.c
+++ b/gdb/thread-iter.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbthread.h"
 #include "inferior.h"
 
diff --git a/gdb/thread.c b/gdb/thread.c
index 22523569fdbd..60a1bef8cf0a 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "language.h"
 #include "symtab.h"
 #include "frame.h"
diff --git a/gdb/tic6x-linux-tdep.c b/gdb/tic6x-linux-tdep.c
index a9de60cf662a..c214178b66d4 100644
--- a/gdb/tic6x-linux-tdep.c
+++ b/gdb/tic6x-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "solib.h"
 #include "osabi.h"
 #include "linux-tdep.h"
diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
index aa115095df79..3a63b0cc25db 100644
--- a/gdb/tic6x-tdep.c
+++ b/gdb/tic6x-tdep.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/tid-parse.c b/gdb/tid-parse.c
index aa1480d7cf0c..623f55e14b36 100644
--- a/gdb/tid-parse.c
+++ b/gdb/tid-parse.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tid-parse.h"
 #include "inferior.h"
 #include "gdbthread.h"
diff --git a/gdb/tilegx-linux-nat.c b/gdb/tilegx-linux-nat.c
index ad707d34daf4..bbfeaefeccd2 100644
--- a/gdb/tilegx-linux-nat.c
+++ b/gdb/tilegx-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/tilegx-linux-tdep.c b/gdb/tilegx-linux-tdep.c
index e0ff0fc2a86c..cec2be2bfec0 100644
--- a/gdb/tilegx-linux-tdep.c
+++ b/gdb/tilegx-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "osabi.h"
 #include "linux-tdep.h"
 #include "glibc-tdep.h"
diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
index c25933be5585..d5ea93cf5038 100644
--- a/gdb/tilegx-tdep.c
+++ b/gdb/tilegx-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/top.c b/gdb/top.c
index cf7d3a913bac..3983a4bb559a 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "cli/cli-cmds.h"
 #include "cli/cli-script.h"
diff --git a/gdb/tracectf.c b/gdb/tracectf.c
index 2ffae6bd326a..282a8250ac10 100644
--- a/gdb/tracectf.c
+++ b/gdb/tracectf.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tracectf.h"
 #include "tracepoint.h"
 #include "regcache.h"
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index f5696bf0129e..79af963b049b 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tracefile.h"
 #include "readline/tilde.h"
 #include "gdbsupport/filestuff.h"
diff --git a/gdb/tracefile.c b/gdb/tracefile.c
index e347b3a30c0d..9db68bbac510 100644
--- a/gdb/tracefile.c
+++ b/gdb/tracefile.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tracefile.h"
 #include "tracectf.h"
 #include "exec.h"
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 418d9ea2203a..1586a043af69 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "frame.h"
diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c
index c35e08ab2805..fc9261314784 100644
--- a/gdb/trad-frame.c
+++ b/gdb/trad-frame.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "trad-frame.h"
 #include "regcache.h"
diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c
index 0e730e66b583..4b397cbf046d 100644
--- a/gdb/tramp-frame.c
+++ b/gdb/tramp-frame.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tramp-frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index 2587dfe59b4a..59e595525b00 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tui/tui.h"
 #include "tui/tui-data.h"
 #include "tui/tui-win.h"
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 03395d2df09d..462771ca1637 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "tui/tui.h"
 #include "tui/tui-data.h"
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 5dc27c32daac..07ca37603b8c 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "breakpoint.h"
diff --git a/gdb/tui/tui-file.c b/gdb/tui/tui-file.c
index 1cf840488c12..a0d72a0fbd2e 100644
--- a/gdb/tui/tui-file.c
+++ b/gdb/tui/tui-file.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tui/tui-file.h"
 #include "tui/tui-io.h"
 #include "tui/tui-command.h"
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 289a25996889..cf48e709ed8a 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "inferior.h"
 #include "command.h"
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index b16da314455e..a75708ba6624 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-interp.h"
 #include "interps.h"
 #include "ui.h"
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index ba07e3d573bb..34e85de08532 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "gdbsupport/event-loop.h"
 #include "event-top.h"
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index a96ca855d1d7..143254bcf990 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "command.h"
 #include "symtab.h"
diff --git a/gdb/tui/tui-location.c b/gdb/tui/tui-location.c
index 831ab14345eb..7e8f769d8047 100644
--- a/gdb/tui/tui-location.c
+++ b/gdb/tui/tui-location.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tui/tui.h"
 #include "tui/tui-status.h"
 #include "tui/tui-data.h"
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 05211eb7b221..88e1c5a34105 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "tui/tui.h"
 #include "tui/tui-data.h"
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index fa956b29a195..5c17aba3a1a2 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <math.h>
 #include <ctype.h>
 #include "symtab.h"
diff --git a/gdb/tui/tui-status.c b/gdb/tui/tui-status.c
index aac391d3babc..c7750af6ea0b 100644
--- a/gdb/tui/tui-status.c
+++ b/gdb/tui/tui-status.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "breakpoint.h"
 #include "frame.h"
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a2982eba0c62..ced7e254f505 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -24,7 +24,6 @@
 
    Author: Susan B. Macchia  */
 
-#include "defs.h"
 #include "command.h"
 #include "symtab.h"
 #include "breakpoint.h"
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 4263b9c049ba..c14ac5a8faf2 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "tui/tui.h"
 #include "tui/tui-data.h"
 #include "tui/tui-io.h"
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 6b8716cd27cf..4dbbe922256e 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "symtab.h"
 #include "frame.h"
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index dea6ffbf954d..19f09609a2f6 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "tui/tui.h"
 #include "tui/tui-hooks.h"
diff --git a/gdb/type-stack.c b/gdb/type-stack.c
index 614f7e8764e6..09348dfd3713 100644
--- a/gdb/type-stack.c
+++ b/gdb/type-stack.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "type-stack.h"
 
 #include "gdbtypes.h"
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 3b100dcb1482..4d0e764274a1 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
 #include "symtab.h"
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index e60921072a47..dd15ea427bcf 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -19,7 +19,6 @@
 
 /* Implement the ``struct ui_file'' object.  */
 
-#include "defs.h"
 #include "ui-file.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/gdb_select.h"
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index a5f1ba518abe..b3a2fb7f4e51 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -20,7 +20,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "expression.h"
 #include "language.h"
 #include "ui-out.h"
diff --git a/gdb/ui-style.c b/gdb/ui-style.c
index 3d9e1b5a97de..952102e30c32 100644
--- a/gdb/ui-style.c
+++ b/gdb/ui-style.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ui-style.h"
 #include "gdbsupport/gdb_regex.h"
 
diff --git a/gdb/ui.c b/gdb/ui.c
index 2a9bf519c6cd..80ee67dbae5a 100644
--- a/gdb/ui.c
+++ b/gdb/ui.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "ui.h"
 
 #include "cli/cli-cmds.h"
diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-view-selftests.c
index 299318ace434..eb3ae304790f 100644
--- a/gdb/unittests/array-view-selftests.c
+++ b/gdb/unittests/array-view-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/array-view.h"
 #include <array>
diff --git a/gdb/unittests/child-path-selftests.c b/gdb/unittests/child-path-selftests.c
index 9f77dd739955..4c4014d14776 100644
--- a/gdb/unittests/child-path-selftests.c
+++ b/gdb/unittests/child-path-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/cli-utils-selftests.c b/gdb/unittests/cli-utils-selftests.c
index 69d84bf50153..6ade3af4ffa4 100644
--- a/gdb/unittests/cli-utils-selftests.c
+++ b/gdb/unittests/cli-utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-utils.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c
index 74a218019766..6936af740fc4 100644
--- a/gdb/unittests/command-def-selftests.c
+++ b/gdb/unittests/command-def-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/unittests/common-utils-selftests.c b/gdb/unittests/common-utils-selftests.c
index b1f8fb843964..e66e38045ad5 100644
--- a/gdb/unittests/common-utils-selftests.c
+++ b/gdb/unittests/common-utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/selftest.h"
 
 namespace selftests {
diff --git a/gdb/unittests/copy_bitwise-selftests.c b/gdb/unittests/copy_bitwise-selftests.c
index 776d99ac9f12..c9f61b09cf42 100644
--- a/gdb/unittests/copy_bitwise-selftests.c
+++ b/gdb/unittests/copy_bitwise-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "utils.h"
 
diff --git a/gdb/unittests/enum-flags-selftests.c b/gdb/unittests/enum-flags-selftests.c
index 54e168173de6..b55d8c314062 100644
--- a/gdb/unittests/enum-flags-selftests.c
+++ b/gdb/unittests/enum-flags-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/valid-expr.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/unittests/environ-selftests.c b/gdb/unittests/environ-selftests.c
index c016e74ccf1e..9bd736028b3b 100644
--- a/gdb/unittests/environ-selftests.c
+++ b/gdb/unittests/environ-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/environ.h"
 #include "diagnostics.h"
diff --git a/gdb/unittests/filtered_iterator-selftests.c b/gdb/unittests/filtered_iterator-selftests.c
index 147f09dd4499..dc76fe031aa4 100644
--- a/gdb/unittests/filtered_iterator-selftests.c
+++ b/gdb/unittests/filtered_iterator-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/filtered-iterator.h"
 
diff --git a/gdb/unittests/format_pieces-selftests.c b/gdb/unittests/format_pieces-selftests.c
index b4918c67af42..a01f248c316f 100644
--- a/gdb/unittests/format_pieces-selftests.c
+++ b/gdb/unittests/format_pieces-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/format.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/frame_info_ptr-selftests.c b/gdb/unittests/frame_info_ptr-selftests.c
index f09d1c8ba015..ec83024cc3d1 100644
--- a/gdb/unittests/frame_info_ptr-selftests.c
+++ b/gdb/unittests/frame_info_ptr-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "frame.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/unittests/function-view-selftests.c b/gdb/unittests/function-view-selftests.c
index b01c02c1d9bd..dc1a6304eb68 100644
--- a/gdb/unittests/function-view-selftests.c
+++ b/gdb/unittests/function-view-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/function-view.h"
 
diff --git a/gdb/unittests/gdb_tilde_expand-selftests.c b/gdb/unittests/gdb_tilde_expand-selftests.c
index 5edf4b688b19..165885f361b9 100644
--- a/gdb/unittests/gdb_tilde_expand-selftests.c
+++ b/gdb/unittests/gdb_tilde_expand-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/selftest.h"
 #include <cstdlib>
 
diff --git a/gdb/unittests/gmp-utils-selftests.c b/gdb/unittests/gmp-utils-selftests.c
index 513ebc824979..3c6b71062a7b 100644
--- a/gdb/unittests/gmp-utils-selftests.c
+++ b/gdb/unittests/gmp-utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gmp-utils.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/intrusive_list-selftests.c b/gdb/unittests/intrusive_list-selftests.c
index 61e1343b2419..28d0134ffe6b 100644
--- a/gdb/unittests/intrusive_list-selftests.c
+++ b/gdb/unittests/intrusive_list-selftests.c
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbsupport/intrusive_list.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/unittests/lookup_name_info-selftests.c b/gdb/unittests/lookup_name_info-selftests.c
index 2fd8be9a3dbd..fe87bedac765 100644
--- a/gdb/unittests/lookup_name_info-selftests.c
+++ b/gdb/unittests/lookup_name_info-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "symtab.h"
 
diff --git a/gdb/unittests/main-thread-selftests.c b/gdb/unittests/main-thread-selftests.c
index 9fd1b99e34b0..1ba350575f10 100644
--- a/gdb/unittests/main-thread-selftests.c
+++ b/gdb/unittests/main-thread-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/block-signals.h"
 #include "gdbsupport/scope-exit.h"
diff --git a/gdb/unittests/memory-map-selftests.c b/gdb/unittests/memory-map-selftests.c
index cc059bbc1996..55d66fd61a0d 100644
--- a/gdb/unittests/memory-map-selftests.c
+++ b/gdb/unittests/memory-map-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "memory-map.h"
 
diff --git a/gdb/unittests/memrange-selftests.c b/gdb/unittests/memrange-selftests.c
index d6a10511a751..df02b6ad2658 100644
--- a/gdb/unittests/memrange-selftests.c
+++ b/gdb/unittests/memrange-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "memrange.h"
 
diff --git a/gdb/unittests/mkdir-recursive-selftests.c b/gdb/unittests/mkdir-recursive-selftests.c
index 1aaf685855b2..a96874d22282 100644
--- a/gdb/unittests/mkdir-recursive-selftests.c
+++ b/gdb/unittests/mkdir-recursive-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/unittests/observable-selftests.c b/gdb/unittests/observable-selftests.c
index bc2e001d86a0..2640f6817ee5 100644
--- a/gdb/unittests/observable-selftests.c
+++ b/gdb/unittests/observable-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/observable.h"
 
diff --git a/gdb/unittests/offset-type-selftests.c b/gdb/unittests/offset-type-selftests.c
index e5a24ab1a19b..95cc4f8ebd59 100644
--- a/gdb/unittests/offset-type-selftests.c
+++ b/gdb/unittests/offset-type-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/offset-type.h"
 #include "gdbsupport/underlying.h"
diff --git a/gdb/unittests/packed-selftests.c b/gdb/unittests/packed-selftests.c
index 852a7d364ce9..060c87c4e159 100644
--- a/gdb/unittests/packed-selftests.c
+++ b/gdb/unittests/packed-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/packed.h"
 
diff --git a/gdb/unittests/parallel-for-selftests.c b/gdb/unittests/parallel-for-selftests.c
index a9abbf0328c1..0261948361ae 100644
--- a/gdb/unittests/parallel-for-selftests.c
+++ b/gdb/unittests/parallel-for-selftests.c
@@ -24,7 +24,6 @@
    FOR_EACH.  The FOR_EACH-defined part reads like a regular function.  */
 #ifndef FOR_EACH
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/parallel-for.h"
 
diff --git a/gdb/unittests/parse-connection-spec-selftests.c b/gdb/unittests/parse-connection-spec-selftests.c
index 83c006ba9285..55a7c13c3a8c 100644
--- a/gdb/unittests/parse-connection-spec-selftests.c
+++ b/gdb/unittests/parse-connection-spec-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/netstuff.h"
 #include "diagnostics.h"
diff --git a/gdb/unittests/path-join-selftests.c b/gdb/unittests/path-join-selftests.c
index 15df04884d9b..08fad63341d8 100644
--- a/gdb/unittests/path-join-selftests.c
+++ b/gdb/unittests/path-join-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/ptid-selftests.c b/gdb/unittests/ptid-selftests.c
index a44ffa3f7c99..6fc04c12eb1c 100644
--- a/gdb/unittests/ptid-selftests.c
+++ b/gdb/unittests/ptid-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/ptid.h"
 #include <type_traits>
 
diff --git a/gdb/unittests/rsp-low-selftests.c b/gdb/unittests/rsp-low-selftests.c
index 90141abb65e7..7a1787150965 100644
--- a/gdb/unittests/rsp-low-selftests.c
+++ b/gdb/unittests/rsp-low-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/rsp-low.h"
 
diff --git a/gdb/unittests/scoped_fd-selftests.c b/gdb/unittests/scoped_fd-selftests.c
index e85f9f7d920f..1413c5018e87 100644
--- a/gdb/unittests/scoped_fd-selftests.c
+++ b/gdb/unittests/scoped_fd-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/scoped_fd.h"
diff --git a/gdb/unittests/scoped_ignore_signal-selftests.c b/gdb/unittests/scoped_ignore_signal-selftests.c
index dc1d9341b7a1..361928c53c0b 100644
--- a/gdb/unittests/scoped_ignore_signal-selftests.c
+++ b/gdb/unittests/scoped_ignore_signal-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/scoped_ignore_signal.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/scope-exit.h"
diff --git a/gdb/unittests/scoped_mmap-selftests.c b/gdb/unittests/scoped_mmap-selftests.c
index dbf836fa2d7c..7b3a6f5202b4 100644
--- a/gdb/unittests/scoped_mmap-selftests.c
+++ b/gdb/unittests/scoped_mmap-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/scoped_mmap.h"
diff --git a/gdb/unittests/scoped_restore-selftests.c b/gdb/unittests/scoped_restore-selftests.c
index 074cc4ccda1e..1fd511813923 100644
--- a/gdb/unittests/scoped_restore-selftests.c
+++ b/gdb/unittests/scoped_restore-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/scoped_restore.h"
 
diff --git a/gdb/unittests/search-memory-selftests.c b/gdb/unittests/search-memory-selftests.c
index 109ce8b528d5..11246337db33 100644
--- a/gdb/unittests/search-memory-selftests.c
+++ b/gdb/unittests/search-memory-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/search.h"
 
diff --git a/gdb/unittests/style-selftests.c b/gdb/unittests/style-selftests.c
index 8a6cf2b38682..4dc3c842c470 100644
--- a/gdb/unittests/style-selftests.c
+++ b/gdb/unittests/style-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "ui-style.h"
 
diff --git a/gdb/unittests/tracepoint-selftests.c b/gdb/unittests/tracepoint-selftests.c
index 7267b70eef97..027002845483 100644
--- a/gdb/unittests/tracepoint-selftests.c
+++ b/gdb/unittests/tracepoint-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "tracepoint.h"
 
diff --git a/gdb/unittests/tui-selftests.c b/gdb/unittests/tui-selftests.c
index e936b20f3705..684720797017 100644
--- a/gdb/unittests/tui-selftests.c
+++ b/gdb/unittests/tui-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 
 #ifdef TUI
diff --git a/gdb/unittests/ui-file-selftests.c b/gdb/unittests/ui-file-selftests.c
index eff1be7f2b2f..7c55b80cdfed 100644
--- a/gdb/unittests/ui-file-selftests.c
+++ b/gdb/unittests/ui-file-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "ui-file.h"
 
diff --git a/gdb/unittests/unique_xmalloc_ptr_char.c b/gdb/unittests/unique_xmalloc_ptr_char.c
index e36d871dd170..b7fd5b6c4a1a 100644
--- a/gdb/unittests/unique_xmalloc_ptr_char.c
+++ b/gdb/unittests/unique_xmalloc_ptr_char.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "gdbsupport/gdb_unique_ptr.h"
diff --git a/gdb/unittests/unpack-selftests.c b/gdb/unittests/unpack-selftests.c
index 2fc789231db1..35f4eeeee2fb 100644
--- a/gdb/unittests/unpack-selftests.c
+++ b/gdb/unittests/unpack-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "value.h"
diff --git a/gdb/unittests/utils-selftests.c b/gdb/unittests/utils-selftests.c
index 2f6d10400e1e..6748dc2546c7 100644
--- a/gdb/unittests/utils-selftests.c
+++ b/gdb/unittests/utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "utils.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/unittests/vec-utils-selftests.c b/gdb/unittests/vec-utils-selftests.c
index e7ff1289205d..da3bcf08d3cd 100644
--- a/gdb/unittests/vec-utils-selftests.c
+++ b/gdb/unittests/vec-utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/selftest.h"
 
 #include "gdbsupport/gdb_vecs.h"
diff --git a/gdb/unittests/xml-utils-selftests.c b/gdb/unittests/xml-utils-selftests.c
index 31f74742b0a5..627d5d8428ee 100644
--- a/gdb/unittests/xml-utils-selftests.c
+++ b/gdb/unittests/xml-utils-selftests.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbsupport/xml-utils.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/user-regs.c b/gdb/user-regs.c
index d1b510a79278..ac04f63dbb80 100644
--- a/gdb/user-regs.c
+++ b/gdb/user-regs.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "user-regs.h"
 #include "gdbtypes.h"
 #include "frame.h"
diff --git a/gdb/utils.c b/gdb/utils.c
index 68aebf373819..ded03c740997 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include <ctype.h>
 #include "gdbsupport/gdb_wait.h"
 #include "event-top.h"
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 4c1fd383a84f..6bda14f0fa15 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "trad-frame.h"
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 31b1c4762f77..6b152cadcac9 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/valops.c b/gdb/valops.c
index 52cce2872813..a17b937a9631 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 7b3ffc884f13..40ffdbe6146f 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/value.c b/gdb/value.c
index 7ddfeb7c7286..1bd180a62ccc 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/varobj.c b/gdb/varobj.c
index af64534169f8..8ce3cbdd440f 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "value.h"
 #include "expression.h"
 #include "frame.h"
diff --git a/gdb/vax-bsd-nat.c b/gdb/vax-bsd-nat.c
index 0f982ca62190..2a4db3a81218 100644
--- a/gdb/vax-bsd-nat.c
+++ b/gdb/vax-bsd-nat.c
@@ -19,7 +19,6 @@
 
 /* We define this to get types like register_t.  */
 #define _KERNTYPES
-#include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
diff --git a/gdb/vax-netbsd-tdep.c b/gdb/vax-netbsd-tdep.c
index 66c56227f418..fa528ae658a3 100644
--- a/gdb/vax-netbsd-tdep.c
+++ b/gdb/vax-netbsd-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "osabi.h"
 
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
index 125f3423be57..dd00898c298c 100644
--- a/gdb/vax-tdep.c
+++ b/gdb/vax-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "frame.h"
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index ee38b985efa7..03db1a2532c4 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -21,7 +21,6 @@
 
 /* Originally by Steve Chamberlain, sac@cygnus.com */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 361ccdd0dcbf..f9585adf8fa3 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "windows-tdep.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "xml-support.h"
diff --git a/gdb/x86-bsd-nat.c b/gdb/x86-bsd-nat.c
index e2bc7a8ad0b1..2bdd385e7f24 100644
--- a/gdb/x86-bsd-nat.c
+++ b/gdb/x86-bsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "gdbthread.h"
 
diff --git a/gdb/x86-fbsd-nat.c b/gdb/x86-fbsd-nat.c
index eea4dd37cac5..bfd15bf6748d 100644
--- a/gdb/x86-fbsd-nat.c
+++ b/gdb/x86-fbsd-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "x86-fbsd-nat.h"
 #ifdef PT_GETXSTATE_INFO
 #include "nat/x86-xstate.h"
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index b93ffca38db2..a3d8ffb60f16 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "inferior.h"
 #include "elf/common.h"
 #include "gdb_proc_service.h"
diff --git a/gdb/x86-nat.c b/gdb/x86-nat.c
index bd4a05da2375..5826716a1f8d 100644
--- a/gdb/x86-nat.c
+++ b/gdb/x86-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "x86-nat.h"
 #include "gdbcmd.h"
 #include "inferior.h"
diff --git a/gdb/x86-tdep.c b/gdb/x86-tdep.c
index 4cacf3ba511d..5d7aa9535b7c 100644
--- a/gdb/x86-tdep.c
+++ b/gdb/x86-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "x86-tdep.h"
 #include "symtab.h"
 
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index e324f4ef8caf..c4914bdcbaf0 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "bfd.h"
 
 #include <sys/types.h>
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 65de9b292f0b..583e101c25f4 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbcmd.h"
 #include "xml-builtin.h"
 #include "xml-support.h"
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index fc999f0eee30..2373d0fd77b5 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "gdbtypes.h"
 #include "xml-support.h"
 #include "xml-syscall.h"
diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c
index 0a84f2b77ed5..436c493d4f91 100644
--- a/gdb/xml-tdesc.c
+++ b/gdb/xml-tdesc.c
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "target.h"
 #include "target-descriptions.h"
 #include "xml-support.h"
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index 12b16c2d3d36..166e6af85275 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/xtensa-config.c b/gdb/xtensa-config.c
index c312fe2749ef..77eb922c1f9f 100644
--- a/gdb/xtensa-config.c
+++ b/gdb/xtensa-config.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 
 #define XTENSA_CONFIG_VERSION 0x60
 
diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c
index e32656833a16..f8509b02e07d 100644
--- a/gdb/xtensa-linux-nat.c
+++ b/gdb/xtensa-linux-nat.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/xtensa-linux-tdep.c b/gdb/xtensa-linux-tdep.c
index cc8c30b10683..7c215e300b37 100644
--- a/gdb/xtensa-linux-tdep.c
+++ b/gdb/xtensa-linux-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "xtensa-tdep.h"
 #include "osabi.h"
 #include "linux-tdep.h"
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index d116b34fd819..2c3d468d8be9 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "frame.h"
 #include "solib-svr4.h"
 #include "symtab.h"
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index f2d000f53030..ee8e36b18670 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
 #include "frame.h"
diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc
index 2307e8dbeea6..ff42795582ff 100644
--- a/gdbserver/ax.cc
+++ b/gdbserver/ax.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "ax.h"
 #include "gdbsupport/format.h"
 #include "tracepoint.h"
diff --git a/gdbserver/debug.cc b/gdbserver/debug.cc
index 9bdff962dda0..ae9ca5cd7687 100644
--- a/gdbserver/debug.cc
+++ b/gdbserver/debug.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <chrono>
 
 #if !defined (IN_PROCESS_AGENT)
diff --git a/gdbserver/dll.cc b/gdbserver/dll.cc
index 0fb6476f40e1..ff637a03fed1 100644
--- a/gdbserver/dll.cc
+++ b/gdbserver/dll.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "dll.h"
 
 #include <algorithm>
diff --git a/gdbserver/fork-child.cc b/gdbserver/fork-child.cc
index 43ff57c31673..7e4c69b31bd5 100644
--- a/gdbserver/fork-child.cc
+++ b/gdbserver/fork-child.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "gdbsupport/job-control.h"
 #include "gdbsupport/scoped_restore.h"
 #include "nat/fork-inferior.h"
diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc
index 255d86dab654..c5ae35ab7ddb 100644
--- a/gdbserver/hostio.cc
+++ b/gdbserver/hostio.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "gdbsupport/fileio.h"
 #include "hostio.h"
 
diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
index 60d565b84823..62cafd872041 100644
--- a/gdbserver/i387-fp.cc
+++ b/gdbserver/i387-fp.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "i387-fp.h"
 #include "gdbsupport/x86-xstate.h"
 #include "nat/x86-xstate.h"
diff --git a/gdbserver/inferiors.cc b/gdbserver/inferiors.cc
index c02d47aa91b8..d088340474fa 100644
--- a/gdbserver/inferiors.cc
+++ b/gdbserver/inferiors.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "gdbsupport/common-inferior.h"
 #include "gdbthread.h"
 #include "dll.h"
diff --git a/gdbserver/linux-aarch32-low.cc b/gdbserver/linux-aarch32-low.cc
index 940c10fd1cf5..ca66e7f8fbc5 100644
--- a/gdbserver/linux-aarch32-low.cc
+++ b/gdbserver/linux-aarch32-low.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "arch/arm.h"
 #include "arch/arm-linux.h"
 #include "linux-low.h"
diff --git a/gdbserver/linux-aarch32-tdesc.cc b/gdbserver/linux-aarch32-tdesc.cc
index 54c6f62e9965..b8987752b9f8 100644
--- a/gdbserver/linux-aarch32-tdesc.cc
+++ b/gdbserver/linux-aarch32-tdesc.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #include "linux-aarch32-tdesc.h"
 
diff --git a/gdbserver/linux-aarch64-ipa.cc b/gdbserver/linux-aarch64-ipa.cc
index f33374ebd6c8..99b7700ac4b9 100644
--- a/gdbserver/linux-aarch64-ipa.cc
+++ b/gdbserver/linux-aarch64-ipa.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include <elf.h>
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index 28d75d035dcb..5df67fccd08c 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "nat/aarch64-linux.h"
 #include "nat/aarch64-linux-hw-point.h"
diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbserver/linux-aarch64-tdesc.cc
index 7a41769905c4..0ed9a42cbff6 100644
--- a/gdbserver/linux-aarch64-tdesc.cc
+++ b/gdbserver/linux-aarch64-tdesc.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #include "linux-aarch64-tdesc.h"
 
diff --git a/gdbserver/linux-amd64-ipa.cc b/gdbserver/linux-amd64-ipa.cc
index 54e4c9812bb3..13c8a5bb360e 100644
--- a/gdbserver/linux-amd64-ipa.cc
+++ b/gdbserver/linux-amd64-ipa.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include "linux-x86-tdesc.h"
diff --git a/gdbserver/linux-arc-low.cc b/gdbserver/linux-arc-low.cc
index 166a4431f09f..dda224f0a74c 100644
--- a/gdbserver/linux-arc-low.cc
+++ b/gdbserver/linux-arc-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "regdef.h"
 #include "linux-low.h"
 #include "tdesc.h"
diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc
index 396ec88081b9..17b64c09affd 100644
--- a/gdbserver/linux-arm-low.cc
+++ b/gdbserver/linux-arm-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "arch/arm.h"
 #include "arch/arm-linux.h"
diff --git a/gdbserver/linux-arm-tdesc.cc b/gdbserver/linux-arm-tdesc.cc
index 24941fe667e3..559f9b0f3dc3 100644
--- a/gdbserver/linux-arm-tdesc.cc
+++ b/gdbserver/linux-arm-tdesc.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #include "linux-arm-tdesc.h"
 
diff --git a/gdbserver/linux-csky-low.cc b/gdbserver/linux-csky-low.cc
index 5497f7dc7a36..2eb5a2df17b9 100644
--- a/gdbserver/linux-csky-low.cc
+++ b/gdbserver/linux-csky-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "tdesc.h"
 #include "linux-low.h"
 #include <sys/ptrace.h>
diff --git a/gdbserver/linux-i386-ipa.cc b/gdbserver/linux-i386-ipa.cc
index 2e4646f8c032..8f14e0937d40 100644
--- a/gdbserver/linux-i386-ipa.cc
+++ b/gdbserver/linux-i386-ipa.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include "linux-x86-tdesc.h"
diff --git a/gdbserver/linux-ia64-low.cc b/gdbserver/linux-ia64-low.cc
index 7bceaadbc809..b7c3c642eb3e 100644
--- a/gdbserver/linux-ia64-low.cc
+++ b/gdbserver/linux-ia64-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 #ifdef HAVE_SYS_REG_H
diff --git a/gdbserver/linux-loongarch-low.cc b/gdbserver/linux-loongarch-low.cc
index f1e1deb878ba..584ea64a7d95 100644
--- a/gdbserver/linux-loongarch-low.cc
+++ b/gdbserver/linux-loongarch-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "tdesc.h"
 #include "elf/common.h"
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 9d5a62428034..d8842f0972db 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "nat/linux-osdata.h"
 #include "gdbsupport/agent.h"
diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc
index 1cccb25bc53d..8020e49ac6e7 100644
--- a/gdbserver/linux-m68k-low.cc
+++ b/gdbserver/linux-m68k-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 /* Linux target op definitions for the m68k architecture.  */
diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc
index 35f92fc24d45..6cf4a6d2d9b7 100644
--- a/gdbserver/linux-mips-low.cc
+++ b/gdbserver/linux-mips-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 #include "nat/gdb_ptrace.h"
diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc
index 31868ff0a4a9..c37bb5a5da9e 100644
--- a/gdbserver/linux-nios2-low.cc
+++ b/gdbserver/linux-nios2-low.cc
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "elf/common.h"
 #include "nat/gdb_ptrace.h"
diff --git a/gdbserver/linux-or1k-low.cc b/gdbserver/linux-or1k-low.cc
index bea92516e9c7..1e0fa39358ce 100644
--- a/gdbserver/linux-or1k-low.cc
+++ b/gdbserver/linux-or1k-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "elf/common.h"
 #include "nat/gdb_ptrace.h"
diff --git a/gdbserver/linux-ppc-ipa.cc b/gdbserver/linux-ppc-ipa.cc
index 299ef377843a..cbbfcfa19be0 100644
--- a/gdbserver/linux-ppc-ipa.cc
+++ b/gdbserver/linux-ppc-ipa.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include "arch/ppc-linux-tdesc.h"
diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc
index 5c45a3f6ecb0..bd3ac143660d 100644
--- a/gdbserver/linux-ppc-low.cc
+++ b/gdbserver/linux-ppc-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 #include "elf/common.h"
diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc
index 680e9f7a094b..c4554c507a8c 100644
--- a/gdbserver/linux-riscv-low.cc
+++ b/gdbserver/linux-riscv-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #include "linux-low.h"
 #include "tdesc.h"
diff --git a/gdbserver/linux-s390-ipa.cc b/gdbserver/linux-s390-ipa.cc
index 56d106674457..55ce4a41d157 100644
--- a/gdbserver/linux-s390-ipa.cc
+++ b/gdbserver/linux-s390-ipa.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <sys/mman.h>
 #include "tracepoint.h"
 #include "linux-s390-tdesc.h"
diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc
index 79937f00d6f1..ee2c192609ac 100644
--- a/gdbserver/linux-s390-low.cc
+++ b/gdbserver/linux-s390-low.cc
@@ -19,7 +19,6 @@
 
 /* This file is used for both 31-bit and 64-bit S/390 systems.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "elf/common.h"
 #include "ax.h"
diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc
index 910b6a0e2e9e..64e6de3480bc 100644
--- a/gdbserver/linux-sh-low.cc
+++ b/gdbserver/linux-sh-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 /* Linux target op definitions for the SH architecture.  */
diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc
index 8e3960a5fa7e..4192bd3984ef 100644
--- a/gdbserver/linux-sparc-low.cc
+++ b/gdbserver/linux-sparc-low.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 
 #include "nat/gdb_ptrace.h"
diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc
index 7c961901dd10..707be2e7b0f9 100644
--- a/gdbserver/linux-tic6x-low.cc
+++ b/gdbserver/linux-tic6x-low.cc
@@ -19,7 +19,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "linux-low.h"
 #include "arch/tic6x.h"
 #include "tdesc.h"
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 933d1fb012a1..2532603451af 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include <signal.h>
 #include <limits.h>
 #include <inttypes.h>
diff --git a/gdbserver/linux-x86-tdesc.cc b/gdbserver/linux-x86-tdesc.cc
index 626207fc477a..cd3b5d80e37e 100644
--- a/gdbserver/linux-x86-tdesc.cc
+++ b/gdbserver/linux-x86-tdesc.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "tdesc.h"
 #include "linux-x86-tdesc.h"
 #include "arch/i386.h"
diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc
index 9ebb2e635906..b20b62e1c0d3 100644
--- a/gdbserver/linux-xtensa-low.cc
+++ b/gdbserver/linux-xtensa-low.cc
@@ -17,7 +17,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#include "server.h"
 #include "linux-low.h"
 
 /* Linux target op definitions for the Xtensa architecture.  */
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index c23bb46c666a..eebf999c223d 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "regcache.h"
 #include "ax.h"
 
diff --git a/gdbserver/netbsd-aarch64-low.cc b/gdbserver/netbsd-aarch64-low.cc
index cfb1bb7914b0..f20a1a717733 100644
--- a/gdbserver/netbsd-aarch64-low.cc
+++ b/gdbserver/netbsd-aarch64-low.cc
@@ -19,7 +19,6 @@
 #include <sys/ptrace.h>
 #include <limits.h>
 
-#include "server.h"
 #include "netbsd-low.h"
 #include "arch/aarch64.h"
 #include "arch/aarch64-insn.h"
diff --git a/gdbserver/netbsd-amd64-low.cc b/gdbserver/netbsd-amd64-low.cc
index 5555e0ba3070..2c8c7113f7dd 100644
--- a/gdbserver/netbsd-amd64-low.cc
+++ b/gdbserver/netbsd-amd64-low.cc
@@ -19,7 +19,6 @@
 #include <sys/ptrace.h>
 #include <limits.h>
 
-#include "server.h"
 #include "netbsd-low.h"
 #include "gdbsupport/x86-xstate.h"
 #include "arch/amd64.h"
diff --git a/gdbserver/netbsd-i386-low.cc b/gdbserver/netbsd-i386-low.cc
index a694609d50df..247a39797c41 100644
--- a/gdbserver/netbsd-i386-low.cc
+++ b/gdbserver/netbsd-i386-low.cc
@@ -19,7 +19,6 @@
 #include <sys/ptrace.h>
 #include <limits.h>
 
-#include "server.h"
 #include "netbsd-low.h"
 #include "gdbsupport/x86-xstate.h"
 #include "arch/i386.h"
diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc
index bcb1bd97170f..4b58826e0914 100644
--- a/gdbserver/netbsd-low.cc
+++ b/gdbserver/netbsd-low.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "target.h"
 #include "netbsd-low.h"
 #include "nat/netbsd-nat.h"
diff --git a/gdbserver/notif.cc b/gdbserver/notif.cc
index 25e40a3c6b61..dac3c3b1bab0 100644
--- a/gdbserver/notif.cc
+++ b/gdbserver/notif.cc
@@ -47,7 +47,6 @@
 
    # 3 is done by function 'handle_notif_ack'.  */
 
-#include "server.h"
 #include "notif.h"
 
 static struct notif_server *notifs[] =
diff --git a/gdbserver/proc-service.cc b/gdbserver/proc-service.cc
index 40a0c7c43bfc..0a332b52d56b 100644
--- a/gdbserver/proc-service.cc
+++ b/gdbserver/proc-service.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 /* This file is currently tied to GNU/Linux.  It should scale well to
    another libthread_db implementation, with the appropriate gdbserver
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 55d14239e816..1bb71d103288 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "regdef.h"
 #include "gdbthread.h"
 #include "tdesc.h"
diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index 959557534013..5a8eb9ae52ae 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #if HAVE_TERMIOS_H
 #include <termios.h>
 #endif
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 74c7763d777a..c7d5cc1c1b0a 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "gdbthread.h"
 #include "gdbsupport/agent.h"
 #include "notif.h"
diff --git a/gdbserver/symbol.cc b/gdbserver/symbol.cc
index 90945dcd35dc..435acc71978f 100644
--- a/gdbserver/symbol.cc
+++ b/gdbserver/symbol.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "gdbsupport/symbol.h"
 
 /* See gdbsupport/symbol.h.  */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 23b699d33bb9..6db32da2e959 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "tracepoint.h"
 #include "gdbsupport/byte-vector.h"
 #include "hostio.h"
diff --git a/gdbserver/tdesc.cc b/gdbserver/tdesc.cc
index aff6f53029a3..3265793da962 100644
--- a/gdbserver/tdesc.cc
+++ b/gdbserver/tdesc.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "tdesc.h"
 #include "regdef.h"
 
diff --git a/gdbserver/thread-db.cc b/gdbserver/thread-db.cc
index d08c0f752632..8cef84206b8b 100644
--- a/gdbserver/thread-db.cc
+++ b/gdbserver/thread-db.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #include "linux-low.h"
 
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 461fa8fa1c55..b7d0ef2c2932 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "tracepoint.h"
 #include "gdbthread.h"
 #include "gdbsupport/rsp-low.h"
diff --git a/gdbserver/utils.cc b/gdbserver/utils.cc
index 11902f7c3fd5..3d3144e33da3 100644
--- a/gdbserver/utils.cc
+++ b/gdbserver/utils.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 
 #ifdef IN_PROCESS_AGENT
 #  define PREFIX "ipa: "
diff --git a/gdbserver/win32-i386-low.cc b/gdbserver/win32-i386-low.cc
index 44490300b693..0a761ca58ef3 100644
--- a/gdbserver/win32-i386-low.cc
+++ b/gdbserver/win32-i386-low.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "win32-low.h"
 #include "x86-low.h"
 #include "gdbsupport/x86-xstate.h"
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 58e8b089f2e4..f672e542d1bc 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "regcache.h"
 #include "gdbsupport/fileio.h"
 #include "mem-break.h"
diff --git a/gdbserver/x86-low.cc b/gdbserver/x86-low.cc
index 11d9028992c3..c59b31b78f79 100644
--- a/gdbserver/x86-low.cc
+++ b/gdbserver/x86-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "server.h"
 #include "x86-low.h"
 
 /* Clear the reference counts and forget everything we knew about the
diff --git a/gdbsupport/agent.cc b/gdbsupport/agent.cc
index 862582c78887..c70b59a4c839 100644
--- a/gdbsupport/agent.cc
+++ b/gdbsupport/agent.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "target/target.h"
 #include "gdbsupport/symbol.h"
 #include <unistd.h>
diff --git a/gdbsupport/btrace-common.cc b/gdbsupport/btrace-common.cc
index 2d54e8ba82d7..2358a9fab338 100644
--- a/gdbsupport/btrace-common.cc
+++ b/gdbsupport/btrace-common.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "btrace-common.h"
 
 
diff --git a/gdbsupport/cleanups.cc b/gdbsupport/cleanups.cc
index cc14523b2d1a..6362ea24e7c2 100644
--- a/gdbsupport/cleanups.cc
+++ b/gdbsupport/cleanups.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "cleanups.h"
 #include <vector>
 
diff --git a/gdbsupport/common-debug.cc b/gdbsupport/common-debug.cc
index 9a5309f1e721..c4d95287271d 100644
--- a/gdbsupport/common-debug.cc
+++ b/gdbsupport/common-debug.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "common-debug.h"
 
 /* See gdbsupport/common-debug.h.  */
diff --git a/gdbsupport/common-exceptions.cc b/gdbsupport/common-exceptions.cc
index 0caed27434e5..5aa16129b02b 100644
--- a/gdbsupport/common-exceptions.cc
+++ b/gdbsupport/common-exceptions.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "common-exceptions.h"
 #include <forward_list>
 
diff --git a/gdbsupport/common-inferior.cc b/gdbsupport/common-inferior.cc
index e9824dfcd36d..4211e049ba7d 100644
--- a/gdbsupport/common-inferior.cc
+++ b/gdbsupport/common-inferior.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/common-inferior.h"
 
 /* See common-inferior.h.  */
diff --git a/gdbsupport/common-regcache.cc b/gdbsupport/common-regcache.cc
index 9baca3197d10..525bb5ce7056 100644
--- a/gdbsupport/common-regcache.cc
+++ b/gdbsupport/common-regcache.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "common-regcache.h"
 
 /* Return the register's value or throw if it's not available.  */
diff --git a/gdbsupport/common-utils.cc b/gdbsupport/common-utils.cc
index 99b9cb8609bb..91c14a0f139f 100644
--- a/gdbsupport/common-utils.cc
+++ b/gdbsupport/common-utils.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "common-utils.h"
 #include "host-defs.h"
 #include "gdbsupport/gdb-safe-ctype.h"
diff --git a/gdbsupport/environ.cc b/gdbsupport/environ.cc
index f7984c565cb5..1b6ca61ee804 100644
--- a/gdbsupport/environ.cc
+++ b/gdbsupport/environ.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "environ.h"
 #include <algorithm>
 #include <utility>
diff --git a/gdbsupport/errors.cc b/gdbsupport/errors.cc
index cccdc5cafb24..c11229aa0d7b 100644
--- a/gdbsupport/errors.cc
+++ b/gdbsupport/errors.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "errors.h"
 #if defined (USE_WIN32API) || defined(__CYGWIN__)
 #include <windows.h>
diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc
index 0ab6974b8769..b18a9fdaac0a 100644
--- a/gdbsupport/event-loop.cc
+++ b/gdbsupport/event-loop.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/event-loop.h"
 
 #include <chrono>
diff --git a/gdbsupport/event-pipe.cc b/gdbsupport/event-pipe.cc
index 7e8e8d63683f..af6c943284fc 100644
--- a/gdbsupport/event-pipe.cc
+++ b/gdbsupport/event-pipe.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 #include "gdbsupport/event-pipe.h"
 #include "gdbsupport/filestuff.h"
 
diff --git a/gdbsupport/fileio.cc b/gdbsupport/fileio.cc
index 26fa6fd616eb..b115e33b581e 100644
--- a/gdbsupport/fileio.cc
+++ b/gdbsupport/fileio.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "fileio.h"
 #include <sys/stat.h>
 #include <fcntl.h>
diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc
index 9d3b417359b1..5c427e11b02a 100644
--- a/gdbsupport/filestuff.cc
+++ b/gdbsupport/filestuff.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "filestuff.h"
 #include "gdb_vecs.h"
 #include <fcntl.h>
diff --git a/gdbsupport/format.cc b/gdbsupport/format.cc
index 4e228a95ea87..12173eeba300 100644
--- a/gdbsupport/format.cc
+++ b/gdbsupport/format.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "format.h"
 
 format_pieces::format_pieces (const char **arg, bool gdb_extensions,
diff --git a/gdbsupport/gdb-dlfcn.cc b/gdbsupport/gdb-dlfcn.cc
index d8dbabd336de..1a8289ace742 100644
--- a/gdbsupport/gdb-dlfcn.cc
+++ b/gdbsupport/gdb-dlfcn.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdb-dlfcn.h"
 
 #ifdef HAVE_DLFCN_H
diff --git a/gdbsupport/gdb-hashtab.cc b/gdbsupport/gdb-hashtab.cc
index 7ef41cc332db..42f80faa403e 100644
--- a/gdbsupport/gdb-hashtab.cc
+++ b/gdbsupport/gdb-hashtab.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdb-hashtab.h"
 
 /* Allocation function for the libiberty hash table which uses an
diff --git a/gdbsupport/gdb_obstack.cc b/gdbsupport/gdb_obstack.cc
index 8bbd64fb6fae..f24b4fc998b5 100644
--- a/gdbsupport/gdb_obstack.cc
+++ b/gdbsupport/gdb_obstack.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdb_obstack.h"
 
 /* Concatenate NULL terminated variable argument list of `const char *'
diff --git a/gdbsupport/gdb_regex.cc b/gdbsupport/gdb_regex.cc
index 4c50c4fadef7..5570a1435c72 100644
--- a/gdbsupport/gdb_regex.cc
+++ b/gdbsupport/gdb_regex.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdb_regex.h"
 #include "gdbsupport/def-vector.h"
 
diff --git a/gdbsupport/gdb_tilde_expand.cc b/gdbsupport/gdb_tilde_expand.cc
index 8aa4fa02ec2c..4a0a5734ad86 100644
--- a/gdbsupport/gdb_tilde_expand.cc
+++ b/gdbsupport/gdb_tilde_expand.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include <algorithm>
 #include "filenames.h"
 #include "gdb_tilde_expand.h"
diff --git a/gdbsupport/gdb_vecs.cc b/gdbsupport/gdb_vecs.cc
index 8b7f4fb91463..71c730876d6e 100644
--- a/gdbsupport/gdb_vecs.cc
+++ b/gdbsupport/gdb_vecs.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdb_vecs.h"
 #include "host-defs.h"
 
diff --git a/gdbsupport/gdb_wait.cc b/gdbsupport/gdb_wait.cc
index 5c1c42495875..476861db2288 100644
--- a/gdbsupport/gdb_wait.cc
+++ b/gdbsupport/gdb_wait.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 
 #include "gdb_wait.h"
 
diff --git a/gdbsupport/job-control.cc b/gdbsupport/job-control.cc
index 7637cc5988f9..eff196dfdc85 100644
--- a/gdbsupport/job-control.cc
+++ b/gdbsupport/job-control.cc
@@ -18,7 +18,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "job-control.h"
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
diff --git a/gdbsupport/netstuff.cc b/gdbsupport/netstuff.cc
index af00f9cb8606..73f1d3b4dcb8 100644
--- a/gdbsupport/netstuff.cc
+++ b/gdbsupport/netstuff.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "netstuff.h"
 #include <algorithm>
 
diff --git a/gdbsupport/new-op.cc b/gdbsupport/new-op.cc
index 3d3fa999bf11..23ab0bb90aa9 100644
--- a/gdbsupport/new-op.cc
+++ b/gdbsupport/new-op.cc
@@ -23,7 +23,6 @@
 #endif
 
 #if !__has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__)
-#include "common-defs.h"
 #include "host-defs.h"
 #include <new>
 
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
index f40df1150e01..9c3816ccc630 100644
--- a/gdbsupport/pathstuff.cc
+++ b/gdbsupport/pathstuff.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "pathstuff.h"
 #include "host-defs.h"
 #include "filenames.h"
diff --git a/gdbsupport/print-utils.cc b/gdbsupport/print-utils.cc
index 1fdaf4d745a0..565a4791675f 100644
--- a/gdbsupport/print-utils.cc
+++ b/gdbsupport/print-utils.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "print-utils.h"
 /* Temporary storage using circular buffer.  */
 
diff --git a/gdbsupport/ptid.cc b/gdbsupport/ptid.cc
index 08866ef90e61..56daf92d4a9b 100644
--- a/gdbsupport/ptid.cc
+++ b/gdbsupport/ptid.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "ptid.h"
 #include "print-utils.h"
 
diff --git a/gdbsupport/rsp-low.cc b/gdbsupport/rsp-low.cc
index 37dce9d5c747..20f249f642d5 100644
--- a/gdbsupport/rsp-low.cc
+++ b/gdbsupport/rsp-low.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "rsp-low.h"
 
 /* See rsp-low.h.  */
diff --git a/gdbsupport/run-time-clock.cc b/gdbsupport/run-time-clock.cc
index 4e0f9802de2b..f754b03f0466 100644
--- a/gdbsupport/run-time-clock.cc
+++ b/gdbsupport/run-time-clock.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "run-time-clock.h"
 #if defined HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
diff --git a/gdbsupport/safe-strerror.cc b/gdbsupport/safe-strerror.cc
index 68899dfbdaad..54b3b857d4dc 100644
--- a/gdbsupport/safe-strerror.cc
+++ b/gdbsupport/safe-strerror.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include <string.h>
 
 /* There are two different versions of strerror_r; one is GNU-specific, the
diff --git a/gdbsupport/scoped_mmap.cc b/gdbsupport/scoped_mmap.cc
index 4f70ac65ec7c..c5c527b4fd4f 100644
--- a/gdbsupport/scoped_mmap.cc
+++ b/gdbsupport/scoped_mmap.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "scoped_mmap.h"
 #include "scoped_fd.h"
 #include "gdbsupport/filestuff.h"
diff --git a/gdbsupport/search.cc b/gdbsupport/search.cc
index 896aed5e6956..6c52643a4f3f 100644
--- a/gdbsupport/search.cc
+++ b/gdbsupport/search.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "gdbsupport/common-defs.h"
 
 #include "gdbsupport/search.h"
 #include "gdbsupport/byte-vector.h"
diff --git a/gdbsupport/selftest.cc b/gdbsupport/selftest.cc
index 1e6d07f287af..d3bed68038a9 100644
--- a/gdbsupport/selftest.cc
+++ b/gdbsupport/selftest.cc
@@ -16,7 +16,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "common-exceptions.h"
 #include "common-debug.h"
 #include "selftest.h"
diff --git a/gdbsupport/signals-state-save-restore.cc b/gdbsupport/signals-state-save-restore.cc
index 307e238307fb..60724f95c87e 100644
--- a/gdbsupport/signals-state-save-restore.cc
+++ b/gdbsupport/signals-state-save-restore.cc
@@ -15,7 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "signals-state-save-restore.h"
 #include "gdbsupport/gdb-sigmask.h"
 
diff --git a/gdbsupport/signals.cc b/gdbsupport/signals.cc
index 782b4904f917..4989b3fc28bd 100644
--- a/gdbsupport/signals.cc
+++ b/gdbsupport/signals.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 
 #ifdef HAVE_SIGNAL_H
 #include <signal.h>
diff --git a/gdbsupport/task-group.cc b/gdbsupport/task-group.cc
index 6844d8594e3e..e29ed25e0d35 100644
--- a/gdbsupport/task-group.cc
+++ b/gdbsupport/task-group.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "task-group.h"
 #include "thread-pool.h"
 
diff --git a/gdbsupport/tdesc.cc b/gdbsupport/tdesc.cc
index 1ee3e1f7c2ec..080d39c485dc 100644
--- a/gdbsupport/tdesc.cc
+++ b/gdbsupport/tdesc.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdbsupport/tdesc.h"
 
 tdesc_reg::tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc
index 1b46b68e12ee..04a203444204 100644
--- a/gdbsupport/thread-pool.cc
+++ b/gdbsupport/thread-pool.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "gdbsupport/thread-pool.h"
 
 #if CXX_STD_THREAD
diff --git a/gdbsupport/xml-utils.cc b/gdbsupport/xml-utils.cc
index 0490f21d763c..b89204cdf510 100644
--- a/gdbsupport/xml-utils.cc
+++ b/gdbsupport/xml-utils.cc
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "common-defs.h"
 #include "xml-utils.h"
 
 /* See xml-utils.h.  */
-- 
2.44.0


^ permalink raw reply	[relevance 1%]

* [PATCH 4/4] windows-nat: Use gdb_realpath
  @ 2024-03-22 19:04  4% ` Pedro Alves
  0 siblings, 0 replies; 200+ results
From: Pedro Alves @ 2024-03-22 19:04 UTC (permalink / raw)
  To: gdb-patches

Use gdb_realpath instead of realpath in windows-nat.c:windows_make_so,
so that we don't have to manually call free.

Change-Id: Id3cda7e177ac984c9a5f7c23f354e72bd561edff
---
 gdb/windows-nat.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 278bfb0e1f1..ee38b985efa 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -891,12 +891,9 @@ windows_make_so (const char *name, LPVOID load_addr)
     }
   else
     {
-      char *rname = realpath (name, NULL);
+      gdb::unique_xmalloc_ptr<char> rname = gdb_realpath (name);
       if (rname != nullptr)
-	{
-	  so->name = rname;
-	  free (rname);
-	}
+	so->name = rname.get ();
       else
 	{
 	  warning (_("dll path for \"%s\" inaccessible"), name);
-- 
2.43.2


^ permalink raw reply	[relevance 4%]

* [PATCH v4] Teach GDB to generate sparse core files (PR corefiles/31494)
  @ 2024-03-21 23:14  1%       ` Pedro Alves
  0 siblings, 0 replies; 200+ results
From: Pedro Alves @ 2024-03-21 23:14 UTC (permalink / raw)
  To: Lancelot SIX, gdb-patches, John Baldwin

On 2024-03-21 21:27, Lancelot SIX wrote:

> I have a couple of small comments below.

Thanks!

> 
> On 18/03/2024 17:43, Pedro Alves wrote:
>> diff --git a/gdb/gcore.c b/gdb/gcore.c

>> +
>> +/* Wrapper around bfd_set_section_contents that avoids writing
>> +   all-zero blocks to disk, so we create a sparse core file.
>> +   SKIP_ALIGN is a recursion helper -- if true, we'll skip aligning
>> +   the file position to SPARSE_BLOCK_SIZE.  */
>> +
>> +static bool
>> +sparse_bfd_set_section_contents (bfd *obfd, asection *osec,
>> +                                const gdb_byte *data,
>> +                                size_t sec_offset,
>> +                                size_t size,
>> +                                bool skip_align = false)
>> +{
>> +  /* Note, we don't have to have special handling for the case of the
>> +     last memory region ending with zeros, because our caller always
>> +     writes out the note section after the memory/load sections.  If
>> +     it didn't, we'd have to seek+write the last byte to make the file
>> +     size correct.  (Or add an ftruncate abstraction to bfd and call
>> +     that.)  */
>> +
>> +  if (!skip_align)
>> +    {
>> +      /* Align the all-zero block search with SPARSE_BLOCK_SIZE, to
>> +        better align with filesystem blocks.  If we find we're
>> +        misaligned, then write/skip the bytes needed to make us
>> +        aligned.  We do that with (one level) recursion.  */
>> +
>> +      /* We need to know the section's file offset on disk.  We can
>> +        only look at it after the bfd's 'output_has_begun' flag has
>> +        been set, as bfd hasn't computed the file offsets
>> +        otherwise.  */
>> +      if (!obfd->output_has_begun)
>> +       {
>> +         gdb_byte dummy = 0;
>> +
>> +         /* A write forces BFD to compute the bfd's section file
>> +            positions.  Zero size works for that too.  */
>> +         if (!bfd_set_section_contents (obfd, osec, &dummy, 0, 0))
>> +           return false;
>> +
>> +         gdb_assert (obfd->output_has_begun);
>> +       }
>> +
>> +      /* How much we need to write/skip in order to find the next
>> +        SPARSE_BLOCK_SIZE filepos-aligned block.  */
>> +      size_t align_remainder
>> +       = (SPARSE_BLOCK_SIZE
>> +          - (osec->filepos + sec_offset) % SPARSE_BLOCK_SIZE);
>> +
>> +      /* How much we'll actually write in the recursion call.  */
>> +      size_t align_write_size = std::min (size, align_remainder);
>> +
>> +      if (align_write_size != 0)
> 
> I think at this point align_write_size can be SPARSE_BLOCK_SIZE (i.e. sec_offset lands at a SPARSE_BLOCK_SIZE boundary in the underlying filesystem).  If that's the case, and data+sec_offset starts with block of 0s, you'll write it to disk needlessly.  

Good find.

> Not a big deal, but I'd go for:
> 
>     if (align_write_size % SPARSE_BLOCK_SIZE != 0)
> 

I wrote something different, just because I dislike repeating the modulo operation.
It forced me to come up with better variable names, but I think the result is clearer.

Also, align_write_size can only be zero if we have something to write.  But if we have nothing
to write, this whole aligning logic isn't needed either.  So I added an early size == 0 check,
which then removed the need for this indentation level here.

>> +       {
>> +         /* Recurse, skipping the alignment code.  */
>> +         if (!sparse_bfd_set_section_contents (obfd, osec, data,
>> +                                               sec_offset,
>> +                                               align_write_size, true))
>> +           return false;
>> +
>> +         /* Skip over what we've written, and proceed with
>> +            assumes-aligned logic.  */
>> +         data += align_write_size;
>> +         sec_offset += align_write_size;
>> +         size -= align_write_size;
>> +       }
>> +    }
>> +
>> +  size_t data_offset = 0;
> 
> Just because that got me to think while reading, having the first part of the procedure update data/sec_offset/size and the second part of the procedure update data_offset seems a bit inconsistent.
> 
> I would probably move the declaration of data_offset at the very begining of the procedure update it consistently:
> 
>     size_t data_offset = 0;
>     if (!skip_align)
>       {
>         […]
>         if (align_write_size % SPARSE_BLOCK_SIZE != 0)
>           {
>             […]
>             data_offset += align_write_size;
>           }
>        }
>      while (data_offset < size)
>        […]

I did this, and then while stepping through the code to confirm it all works correctly, I noticed that it
leads to code that is a little harder to debug, as data_offset is no longer neatly aligned to 0x1000
while stepping through the "assume-aligned" main algorithm.  But that may just be me, and I do see your
point, so I kept the change.

Here's the updated patch.  I also applied John's suggestion to use a continue.

---- 8< ----
From 07d61478c8d02f593d8ab8bc0270eb0a90d535dd Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>
Date: Thu, 21 Mar 2024 23:07:46 +0000
Subject: [PATCH v4] Teach GDB to generate sparse core files (PR
 corefiles/31494)

This commit teaches GDB's gcore command to generate sparse core files
(if supported by the filesystem).

To create a sparse file, all you have to do is skip writing zeros to
the file, instead lseek'ing-ahead over them.

The sparse logic is applied when writing the memory sections, as
that's where the bulk of the data and the zeros are.

The commit also tweaks gdb.base/bigcore.exp to make it exercise
gdb-generated cores in addition to kernel-generated cores.  We
couldn't do that before, because GDB's gcore on that test's program
would generate a multi-GB non-sparse core (16GB on my system).

After this commit, gdb.base/bigcore.exp generates, when testing with
GDB's gcore, a much smaller core file, roughly in line with what the
kernel produces:

 real sizes:

 $ du --hu testsuite/outputs/gdb.base/bigcore/bigcore.corefile.*
 2.2M    testsuite/outputs/gdb.base/bigcore/bigcore.corefile.gdb
 2.0M    testsuite/outputs/gdb.base/bigcore/bigcore.corefile.kernel

 apparent sizes:

 $ du --hu --apparent-size testsuite/outputs/gdb.base/bigcore/bigcore.corefile.*
 16G     testsuite/outputs/gdb.base/bigcore/bigcore.corefile.gdb
 16G     testsuite/outputs/gdb.base/bigcore/bigcore.corefile.kernel

Time to generate the core also goes down significantly.  On my machine, I get:

  when writing to an SSD, from 21.0s, down to 8.0s
  when writing to an HDD, from 31.0s, down to 8.5s

The changes to gdb.base/bigcore.exp are smaller than they look at
first sight.  It's basically mostly refactoring -- moving most of the
code to a new procedure which takes as argument who should dump the
core, and then calling the procedure twice.  I purposely did not
modernize any of the refactored code in this patch.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31494
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Change-Id: I2554a6a4a72d8c199ce31f176e0ead0c0c76cff1
---
 gdb/NEWS                           |   4 +
 gdb/doc/gdb.texinfo                |   3 +
 gdb/gcore.c                        | 186 +++++++++++++++++++++-
 gdb/testsuite/gdb.base/bigcore.exp | 238 ++++++++++++++++-------------
 4 files changed, 323 insertions(+), 108 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index d8ac0bb06a7..d1d25e4c24d 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -23,6 +23,10 @@ disassemble
   command will now give an error.  Previously the 'b' flag would
   always override the 'r' flag.
 
+gcore
+generate-core-file
+  GDB now generates sparse core files, on systems that support it.
+
 maintenance info line-table
   Add an EPILOGUE-BEGIN column to the output of the command.  It indicates
   if the line is considered the start of the epilgoue, and thus a point at
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index f093ee269e2..9224829bd93 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -13867,6 +13867,9 @@ Produce a core dump of the inferior process.  The optional argument
 specified, the file name defaults to @file{core.@var{pid}}, where
 @var{pid} is the inferior process ID.
 
+If supported by the filesystem where the core is written to,
+@value{GDBN} generates a sparse core dump file.
+
 Note that this command is implemented only for some systems (as of
 this writing, @sc{gnu}/Linux, FreeBSD, Solaris, and S390).
 
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 7c12aa3a777..3d3973bfaba 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -39,10 +39,21 @@
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/scope-exit.h"
 
+/* To generate sparse cores, we look at the data to write in chunks of
+   this size when considering whether to skip the write.  Only if we
+   have a full block of this size with all zeros do we skip writing
+   it.  A simpler algorithm that would try to skip all zeros would
+   result in potentially many more write/lseek syscalls, as normal
+   data is typically sprinkled with many small holes of zeros.  Also,
+   it's much more efficient to memcmp a block of data against an
+   all-zero buffer than to check each and every data byte against zero
+   one by one.  */
+#define SPARSE_BLOCK_SIZE 0x1000
+
 /* The largest amount of memory to read from the target at once.  We
    must throttle it to limit the amount of memory used by GDB during
    generate-core-file for programs with large resident data.  */
-#define MAX_COPY_BYTES (1024 * 1024)
+#define MAX_COPY_BYTES (256 * SPARSE_BLOCK_SIZE)
 
 static const char *default_gcore_target (void);
 static enum bfd_architecture default_gcore_arch (void);
@@ -98,7 +109,12 @@ write_gcore_file_1 (bfd *obfd)
   bfd_set_section_alignment (note_sec, 0);
   bfd_set_section_size (note_sec, note_size);
 
-  /* Now create the memory/load sections.  */
+  /* Now create the memory/load sections.  Note
+     gcore_memory_sections's sparse logic is assuming that we'll
+     always write something afterwards, which we do: just below, we
+     write the note section.  So there's no need for an ftruncate-like
+     call to grow the file to the right size if the last memory
+     sections were zeros and we skipped writing them.  */
   if (gcore_memory_sections (obfd) == 0)
     error (_("gcore: failed to get corefile memory sections from target."));
 
@@ -567,6 +583,167 @@ objfile_find_memory_regions (struct target_ops *self,
   return 0;
 }
 
+/* Check if we have a block full of zeros at DATA within the [DATA,
+   DATA+SIZE) buffer.  Returns the size of the all-zero block found.
+   Returns at most the minimum between SIZE and SPARSE_BLOCK_SIZE.  */
+
+static size_t
+get_all_zero_block_size (const gdb_byte *data, size_t size)
+{
+  size = std::min (size, (size_t) SPARSE_BLOCK_SIZE);
+
+  /* A memcmp of a whole block is much faster than a simple for loop.
+     This makes a big difference, as with a for loop, this code would
+     dominate the performance and result in doubling the time to
+     generate a core, at the time of writing.  With an optimized
+     memcmp, this doesn't even show up in the perf trace.  */
+  static const gdb_byte all_zero_block[SPARSE_BLOCK_SIZE] = {};
+  if (memcmp (data, all_zero_block, size) == 0)
+    return size;
+  return 0;
+}
+
+/* Basically a named-elements pair, used as return type of
+   find_next_all_zero_block.  */
+
+struct offset_and_size
+{
+  size_t offset;
+  size_t size;
+};
+
+/* Find the next all-zero block at DATA+OFFSET within the [DATA,
+   DATA+SIZE) buffer.  Returns the offset and the size of the all-zero
+   block if found, or zero if not found.  */
+
+static offset_and_size
+find_next_all_zero_block (const gdb_byte *data, size_t offset, size_t size)
+{
+  for (; offset < size; offset += SPARSE_BLOCK_SIZE)
+    {
+      size_t zero_block_size
+	= get_all_zero_block_size (data + offset, size - offset);
+      if (zero_block_size != 0)
+	return {offset, zero_block_size};
+    }
+  return {0, 0};
+}
+
+/* Wrapper around bfd_set_section_contents that avoids writing
+   all-zero blocks to disk, so we create a sparse core file.
+   SKIP_ALIGN is a recursion helper -- if true, we'll skip aligning
+   the file position to SPARSE_BLOCK_SIZE.  */
+
+static bool
+sparse_bfd_set_section_contents (bfd *obfd, asection *osec,
+				 const gdb_byte *data,
+				 size_t sec_offset,
+				 size_t size,
+				 bool skip_align = false)
+{
+  /* Note, we don't have to have special handling for the case of the
+     last memory region ending with zeros, because our caller always
+     writes out the note section after the memory/load sections.  If
+     it didn't, we'd have to seek+write the last byte to make the file
+     size correct.  (Or add an ftruncate abstraction to bfd and call
+     that.)  */
+
+  if (size == 0)
+    return true;
+
+  size_t data_offset = 0;
+
+  if (!skip_align)
+    {
+      /* Align the all-zero block search with SPARSE_BLOCK_SIZE, to
+	 better align with filesystem blocks.  If we find we're
+	 misaligned, then write/skip the bytes needed to make us
+	 aligned.  We do that with (one level) recursion.  */
+
+      /* We need to know the section's file offset on disk.  We can
+	 only look at it after the bfd's 'output_has_begun' flag has
+	 been set, as bfd hasn't computed the file offsets
+	 otherwise.  */
+      if (!obfd->output_has_begun)
+	{
+	  gdb_byte dummy = 0;
+
+	  /* A write forces BFD to compute the bfd's section file
+	     positions.  Zero size works for that too.  */
+	  if (!bfd_set_section_contents (obfd, osec, &dummy, 0, 0))
+	    return false;
+
+	  gdb_assert (obfd->output_has_begun);
+	}
+
+      /* How much after the last aligned offset are we writing at.  */
+      size_t aligned_offset_remainder
+	= (osec->filepos + sec_offset) % SPARSE_BLOCK_SIZE;
+
+      /* Do we need to align?  */
+      if (aligned_offset_remainder != 0)
+	{
+	  /* How much we need to advance in order to find the next
+	     SPARSE_BLOCK_SIZE filepos-aligned block.  */
+	  size_t distance_to_next_aligned
+	    = SPARSE_BLOCK_SIZE - aligned_offset_remainder;
+
+	  /* How much we'll actually write in the recursion call.  The
+	     caller may want us to write fewer bytes than
+	     DISTANCE_TO_NEXT_ALIGNED.  */
+	  size_t align_write_size = std::min (size, distance_to_next_aligned);
+
+	  /* Recurse, skipping the alignment code.  */
+	  if (!sparse_bfd_set_section_contents (obfd, osec, data,
+						sec_offset,
+						align_write_size, true))
+	    return false;
+
+	  /* Skip over what we've written, and proceed with
+	     assumes-aligned logic.  */
+	  data_offset += align_write_size;
+	}
+    }
+
+  while (data_offset < size)
+    {
+      size_t all_zero_block_size
+	= get_all_zero_block_size (data + data_offset, size - data_offset);
+      if (all_zero_block_size != 0)
+	{
+	  /* Skip writing all-zero blocks.  */
+	  data_offset += all_zero_block_size;
+	  continue;
+	}
+
+      /* We have some non-zero data to write to file.  Find the next
+	 all-zero block within the data, and only write up to it.  */
+
+      offset_and_size next_all_zero_block
+	= find_next_all_zero_block (data,
+				    data_offset + SPARSE_BLOCK_SIZE,
+				    size);
+      size_t next_data_offset = (next_all_zero_block.offset == 0
+				 ? size
+				 : next_all_zero_block.offset);
+
+      if (!bfd_set_section_contents (obfd, osec, data + data_offset,
+				     sec_offset + data_offset,
+				     next_data_offset - data_offset))
+	return false;
+
+      data_offset = next_data_offset;
+
+      /* If we already know we have an all-zero block at the next
+	 offset, we can skip calling get_all_zero_block_size for
+	 it again.  */
+      if (next_all_zero_block.offset != 0)
+	data_offset += next_all_zero_block.size;
+    }
+
+  return true;
+}
+
 static void
 gcore_copy_callback (bfd *obfd, asection *osec)
 {
@@ -599,8 +776,9 @@ gcore_copy_callback (bfd *obfd, asection *osec)
 			     bfd_section_vma (osec)));
 	  break;
 	}
-      if (!bfd_set_section_contents (obfd, osec, memhunk.data (),
-				     offset, size))
+
+      if (!sparse_bfd_set_section_contents (obfd, osec, memhunk.data (),
+					    offset, size))
 	{
 	  warning (_("Failed to write corefile contents (%s)."),
 		   bfd_errmsg (bfd_get_error ()));
diff --git a/gdb/testsuite/gdb.base/bigcore.exp b/gdb/testsuite/gdb.base/bigcore.exp
index 3f9ae48abf2..6c64d402502 100644
--- a/gdb/testsuite/gdb.base/bigcore.exp
+++ b/gdb/testsuite/gdb.base/bigcore.exp
@@ -43,23 +43,6 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-# Run GDB on the bigcore program up-to where it will dump core.
-
-clean_restart ${binfile}
-gdb_test_no_output "set print sevenbit-strings"
-gdb_test_no_output "set width 0"
-
-# Get the core into the output directory.
-set_inferior_cwd_to_output_dir
-
-if {![runto_main]} {
-    return 0
-}
-set print_core_line [gdb_get_line_number "Dump core"]
-gdb_test "tbreak $print_core_line"
-gdb_test continue ".*print_string.*"
-gdb_test next ".*0 = 0.*"
-
 # Traverse part of bigcore's linked list of memory chunks (forward or
 # backward), saving each chunk's address.
 
@@ -92,92 +75,11 @@ proc extract_heap { dir } {
     }
     return $heap
 }
-set next_heap [extract_heap next]
-set prev_heap [extract_heap prev]
-
-# Save the total allocated size within GDB so that we can check
-# the core size later.
-gdb_test_no_output "set \$bytes_allocated = bytes_allocated" "save heap size"
-
-# Now create a core dump
-
-# Rename the core file to "TESTFILE.corefile" rather than just "core",
-# to avoid problems with sys admin types that like to regularly prune
-# all files named "core" from the system.
-
-# Some systems append "core" to the name of the program; others append
-# the name of the program to "core"; still others (like Linux, as of
-# May 2003) create cores named "core.PID".
-
-# Save the process ID.  Some systems dump the core into core.PID.
-set inferior_pid [get_inferior_pid]
-
-# Dump core using SIGABRT
-set oldtimeout $timeout
-set timeout 600
-gdb_test "signal SIGABRT" "Program terminated with signal SIGABRT, .*"
-set timeout $oldtimeout
-
-# Find the corefile.
-set file [find_core_file $inferior_pid]
-if { $file != "" } {
-    remote_exec build "mv $file $corefile"
-} else {
-    untested "can't generate a core file"
-    return 0
-}
 
-# Check that the corefile is plausibly large enough.  We're trying to
-# detect the case where the operating system has truncated the file
-# just before signed wraparound.  TCL, unfortunately, has a similar
-# problem - so use catch.  It can handle the "bad" size but not
-# necessarily the "good" one.  And we must use GDB for the comparison,
-# similarly.
-
-if {[catch {file size $corefile} core_size] == 0} {
-    set core_ok 0
-    gdb_test_multiple "print \$bytes_allocated < $core_size" "check core size" {
-	-re " = 1\r\n$gdb_prompt $" {
-	    pass "check core size"
-	    set core_ok 1
-	}
-	-re " = 0\r\n$gdb_prompt $" {
-	    pass "check core size"
-	    set core_ok 0
-	}
-    }
-} { 
-    # Probably failed due to the TCL build having problems with very
-    # large values.  Since GDB uses a 64-bit off_t (when possible) it
-    # shouldn't have this problem.  Assume that things are going to
-    # work.  Without this assumption the test is skiped on systems
-    # (such as i386 GNU/Linux with patched kernel) which do pass.
-    pass "check core size"
-    set core_ok 1
-}
-if {! $core_ok} {
-    untested "check core size (system does not support large corefiles)"
-    return 0
-}
-
-# Now load up that core file
-
-set test "load corefile"
-gdb_test_multiple "core $corefile" "$test" {
-    -re "A program is being debugged already.  Kill it. .y or n. " {
-	send_gdb "y\n"
-	exp_continue
-    }
-    -re "Core was generated by.*$gdb_prompt $" {
-	pass "$test"
-    }
-}
-
-# Finally, re-traverse bigcore's linked list, checking each chunk's
-# address against the executable.  Don't use gdb_test_multiple as want
-# only one pass/fail.  Don't use exp_continue as the regular
-# expression involving $heap needs to be re-evaluated for each new
-# response.
+# Re-traverse bigcore's linked list, checking each chunk's address
+# against the executable.  Don't use gdb_test_multiple as want only
+# one pass/fail.  Don't use exp_continue as the regular expression
+# involving $heap needs to be re-evaluated for each new response.
 
 proc check_heap { dir heap } {
     global gdb_prompt
@@ -208,5 +110,133 @@ proc check_heap { dir heap } {
     }
 }
 
-check_heap next $next_heap
-check_heap prev $prev_heap
+# The bulk of the testcase.  DUMPER indicates who is supposed to dump
+# the core.  It can be either "kernel", or "gdb".
+proc test {dumper} {
+    global binfile timeout corefile gdb_prompt
+
+    # Run GDB on the bigcore program up-to where it will dump core.
+
+    clean_restart ${binfile}
+    gdb_test_no_output "set print sevenbit-strings"
+    gdb_test_no_output "set width 0"
+
+    # Get the core into the output directory.
+    set_inferior_cwd_to_output_dir
+
+    if {![runto_main]} {
+	return 0
+    }
+    set print_core_line [gdb_get_line_number "Dump core"]
+    gdb_test "tbreak $print_core_line"
+    gdb_test continue ".*print_string.*"
+    gdb_test next ".*0 = 0.*"
+
+    set next_heap [extract_heap next]
+    set prev_heap [extract_heap prev]
+
+    # Save the total allocated size within GDB so that we can check
+    # the core size later.
+    gdb_test_no_output "set \$bytes_allocated = bytes_allocated" \
+	"save heap size"
+
+    # Now create a core dump.
+
+    if {$dumper == "kernel"} {
+	# Rename the core file to "TESTFILE.corefile.$dumper" rather
+	# than just "core", to avoid problems with sys admin types
+	# that like to regularly prune all files named "core" from the
+	# system.
+
+	# Some systems append "core" to the name of the program;
+	# others append the name of the program to "core"; still
+	# others (like Linux, as of May 2003) create cores named
+	# "core.PID".
+
+	# Save the process ID.  Some systems dump the core into
+	# core.PID.
+	set inferior_pid [get_inferior_pid]
+
+	# Dump core using SIGABRT.
+	set oldtimeout $timeout
+	set timeout 600
+	gdb_test "signal SIGABRT" "Program terminated with signal SIGABRT, .*"
+	set timeout $oldtimeout
+
+	# Find the corefile.
+	set file [find_core_file $inferior_pid]
+	if { $file != "" } {
+	    remote_exec build "mv $file $corefile.$dumper"
+	} else {
+	    untested "can't generate a core file"
+	    return 0
+	}
+    } elseif {$dumper == "gdb"} {
+	gdb_gcore_cmd "$corefile.$dumper" "gcore corefile"
+    } else {
+	error "unhandled dumper: $dumper"
+    }
+
+    # Check that the corefile is plausibly large enough.  We're trying
+    # to detect the case where the operating system has truncated the
+    # file just before signed wraparound.  TCL, unfortunately, has a
+    # similar problem - so use catch.  It can handle the "bad" size
+    # but not necessarily the "good" one.  And we must use GDB for the
+    # comparison, similarly.
+
+    if {[catch {file size $corefile.$dumper} core_size] == 0} {
+	set core_ok 0
+	gdb_test_multiple "print \$bytes_allocated < $core_size" \
+	    "check core size" {
+	    -re " = 1\r\n$gdb_prompt $" {
+		pass "check core size"
+		set core_ok 1
+	    }
+	    -re " = 0\r\n$gdb_prompt $" {
+		pass "check core size"
+		set core_ok 0
+	    }
+	}
+    } {
+	# Probably failed due to the TCL build having problems with
+	# very large values.  Since GDB uses a 64-bit off_t (when
+	# possible) it shouldn't have this problem.  Assume that
+	# things are going to work.  Without this assumption the test
+	# is skiped on systems (such as i386 GNU/Linux with patched
+	# kernel) which do pass.
+	pass "check core size"
+	set core_ok 1
+    }
+    if {! $core_ok} {
+	untested "check core size (system does not support large corefiles)"
+	return 0
+    }
+
+    # Now load up that core file.
+
+    set test "load corefile"
+    gdb_test_multiple "core $corefile.$dumper" "$test" {
+	-re "A program is being debugged already.  Kill it. .y or n. " {
+	    send_gdb "y\n"
+	    exp_continue
+	}
+	-re "Core was generated by.*$gdb_prompt $" {
+	    pass "$test"
+	}
+    }
+
+    # Finally, re-traverse bigcore's linked list, checking each
+    # chunk's address against the executable.
+
+    check_heap next $next_heap
+    check_heap prev $prev_heap
+}
+
+foreach_with_prefix dumper {kernel gdb} {
+    # GDB's gcore is too slow when testing with the extended-gdbserver
+    # board, since it requires reading all the inferior memory.
+    if {$dumper == "gdb" && [target_info gdb_protocol] != ""} {
+	continue
+    }
+    test $dumper
+}

base-commit: 9bec569fda7c76849cf3eb0e4a525f627d25f980
-- 
2.43.2


^ permalink raw reply	[relevance 1%]

* [PATCH 07/12] Move "iterated_associations" into ada_parse_state
  @ 2024-03-21 19:03  4% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-03-21 19:03 UTC (permalink / raw)
  To: gdb-patches

This patch moves the "iterated_associations" global into
ada_parse_state.
---
 gdb/ada-exp.y | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 1c5ffff3290..615b74d14d8 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -97,6 +97,10 @@ struct ada_parse_state
      to implement '@', the target name symbol.  */
   std::vector<ada_assign_up> assignments;
 
+  /* Track currently active iterated assignment names.  */
+  std::unordered_map<std::string, std::vector<ada_index_var_operation *>>
+       iterated_associations;
+
 private:
 
   /* We don't have a good way to manage non-POD data in Yacc, so store
@@ -444,10 +448,6 @@ make_tick_completer (struct stoken tok)
 	  (new ada_tick_completer (std::string (tok.ptr, tok.length))));
 }
 
-/* Track currently active iterated assignment names.  */
-static std::unordered_map<std::string, std::vector<ada_index_var_operation *>>
-     iterated_associations;
-
 %}
 
 %union
@@ -1128,12 +1128,12 @@ component_group :
 			{
 			  std::string name = copy_name ($2);
 
-			  auto iter = iterated_associations.find (name);
-			  if (iter != iterated_associations.end ())
+			  auto iter = ada_parser->iterated_associations.find (name);
+			  if (iter != ada_parser->iterated_associations.end ())
 			    error (_("Nested use of index parameter '%s'"),
 				   name.c_str ());
 
-			  iterated_associations[name] = {};
+			  ada_parser->iterated_associations[name] = {};
 			}
 		component_associations
 			{
@@ -1142,12 +1142,12 @@ component_group :
 			  ada_choices_component *choices = choice_component ();
 			  choices->set_associations (pop_associations ($5));
 
-			  auto iter = iterated_associations.find (name);
-			  gdb_assert (iter != iterated_associations.end ());
+			  auto iter = ada_parser->iterated_associations.find (name);
+			  gdb_assert (iter != ada_parser->iterated_associations.end ());
 			  for (ada_index_var_operation *var : iter->second)
 			    var->set_choices (choices);
 
-			  iterated_associations.erase (name);
+			  ada_parser->iterated_associations.erase (name);
 
 			  choices->set_name (std::move (name));
 			}
@@ -1257,7 +1257,6 @@ ada_parse (struct parser_state *par_state)
   lexer_init (yyin);		/* (Re-)initialize lexer.  */
   obstack_free (&temp_parse_space, NULL);
   obstack_init (&temp_parse_space);
-  iterated_associations.clear ();
 
   int result = yyparse ();
   if (!result)
@@ -1707,8 +1706,8 @@ write_var_or_type (struct parser_state *par_state,
 
   if (block == nullptr)
     {
-      auto iter = iterated_associations.find (name_storage);
-      if (iter != iterated_associations.end ())
+      auto iter = ada_parser->iterated_associations.find (name_storage);
+      if (iter != ada_parser->iterated_associations.end ())
 	{
 	  auto op = std::make_unique<ada_index_var_operation> ();
 	  iter->second.push_back (op.get ());

-- 
2.43.0


^ permalink raw reply	[relevance 4%]

* [PATCH] Better handling for realpath() failures in windows_make_so() on Cygwin
  @ 2024-03-21  7:22  4% ` Orgad Shaneh
  0 siblings, 0 replies; 200+ results
From: Orgad Shaneh @ 2024-03-21  7:22 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jon Turney

From: Jon Turney <jon.turney@dronecode.org.uk>

Fix a memory leak which would occur in the case when the result of realpath() is
greater than or equal to SO_NAME_MAX_PATH_SIZE.

Distinguish between realpath() failing (returning NULL), and returning a path
longer than SO_NAME_MAX_PATH_SIZE

Warn rather than stopping with an error in those cases.

Original patch from Tim Chick.  Memory leak fix by Corinna Vinschen.
---
 gdb/windows-nat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index a90388922e2..29bfad5b060 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -886,13 +886,14 @@ windows_make_so (const char *name, LPVOID load_addr)
       if (rname && strlen (rname) < SO_NAME_MAX_PATH_SIZE)
 	{
 	  so->name = rname;
-	  free (rname);
 	}
       else
 	{
 	  warning (_("dll path for \"%s\" too long or inaccessible"), name);
 	  so->name = so->original_name;
 	}
+      if (rname)
+	free (rname);
     }
   /* Record cygwin1.dll .text start/end.  */
   size_t len = sizeof ("/cygwin1.dll") - 1;
-- 
2.44.0.windows.1.1.g2942425c99


^ permalink raw reply	[relevance 4%]

* Re: [PATCH 8/9] Suppress some "undefined" warnings from flake8
  @ 2024-03-20 20:32 13%       ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-03-20 20:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Simon Marchi, gdb-patches

Tom> Yeah.  I'll send v2 with this fixed.

Well, I did some branch shenanigans and b4 is unhappy, so here's the
updated version of just this one patch.

Tom

commit 19d1ac05202ade4d4129bbad0e277f67bfdb1aaf
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Mar 19 11:08:34 2024 -0600

    Suppress some "undefined" warnings from flake8
    
    flake8 warns about some identifiers in __init__.py, because it does
    not realize these come from the star-imported _gdb module.  This patch
    suppresses these warnings.
    
diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
index 2ff1f95c8fd..611d725af58 100644
--- a/gdb/python/lib/gdb/__init__.py
+++ b/gdb/python/lib/gdb/__init__.py
@@ -26,6 +26,8 @@ if sys.version_info >= (3, 4):
 else:
     from imp import reload
 
+import _gdb
+
 # Note that two indicators are needed here to silence flake8.
 from _gdb import *  # noqa: F401,F403
 
@@ -56,15 +58,14 @@ class _GdbFile(object):
             self.write(line)
 
     def flush(self):
-        flush(stream=self.stream)
+        _gdb.flush(stream=self.stream)
 
     def write(self, s):
-        write(s, stream=self.stream)
-
+        _gdb.write(s, stream=self.stream)
 
-sys.stdout = _GdbFile(STDOUT)
 
-sys.stderr = _GdbFile(STDERR)
+sys.stdout = _GdbFile(_gdb.STDOUT)
+sys.stderr = _GdbFile(_gdb.STDERR)
 
 # Default prompt hook does nothing.
 prompt_hook = None
@@ -185,7 +186,7 @@ def GdbSetPythonDirectory(dir):
 
 def current_progspace():
     "Return the current Progspace."
-    return selected_inferior().progspace
+    return _gdb.selected_inferior().progspace
 
 
 def objfiles():
@@ -222,14 +223,14 @@ def set_parameter(name, value):
             value = "on"
         else:
             value = "off"
-    execute("set " + name + " " + str(value), to_string=True)
+    _gdb.execute("set " + name + " " + str(value), to_string=True)
 
 
 @contextmanager
 def with_parameter(name, value):
     """Temporarily set the GDB parameter NAME to VALUE.
     Note that this is a context manager."""
-    old_value = parameter(name)
+    old_value = _gdb.parameter(name)
     set_parameter(name, value)
     try:
         # Nothing that useful to return.

^ permalink raw reply	[relevance 13%]

* [PATCH 2/3] Make bcache more type-safe
  @ 2024-03-20 20:23 13% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-03-20 20:23 UTC (permalink / raw)
  To: gdb-patches

The bcache uses memcpy to make copies of the data passed to it.  In
C++, this is only safe for trivially-copyable types.

This patch changes bcache to require this property, and slightly
changes the API to make it easier to use when copying a single object.
It also makes the new 'insert' template methods return the correct
type.
---
 gdb/bcache.h   | 25 ++++++++++++++++++++++++-
 gdb/gdbtypes.c |  2 +-
 gdb/macrotab.c | 12 ++++++------
 gdb/psymtab.c  |  6 ++----
 4 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/gdb/bcache.h b/gdb/bcache.h
index 17a09880d99..a77cd005ea6 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -152,7 +152,26 @@ struct bcache
      were newly added to the cache, or to false if the bytes were
      found in the cache.  */
 
-  const void *insert (const void *addr, int length, bool *added = nullptr);
+  template<typename T, typename = gdb::Requires<std::is_trivially_copyable<T>>>
+  const T *insert (const T *addr, int length, bool *added = nullptr)
+  {
+    return (const T *) this->insert ((const void *) addr, length, added);
+  }
+
+  /* Find a copy of OBJECT in this bcache.  If BCACHE has never seen
+     those bytes before, add a copy of them to BCACHE.  In either
+     case, return a pointer to BCACHE's copy of that string.  Since
+     the cached value is meant to be read-only, return a const buffer.
+     If ADDED is not NULL, set *ADDED to true if the bytes were newly
+     added to the cache, or to false if the bytes were found in the
+     cache.  */
+
+  template<typename T, typename = gdb::Requires<std::is_trivially_copyable<T>>>
+  const T *insert (const T &object, bool *added = nullptr)
+  {
+    return (const T *) this->insert ((const void *) &object, sizeof (object),
+				     added);
+  }
 
   /* Print statistics on this bcache's memory usage and efficacity at
      eliminating duplication.  TYPE should be a string describing the
@@ -173,6 +192,10 @@ struct bcache
 
 private:
 
+  /* Implementation of the templated 'insert' methods.  */
+
+  const void *insert (const void *addr, int length, bool *added);
+
   /* All the bstrings are allocated here.  */
   struct obstack m_cache {};
 
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 960a7f49e45..4fcfbc587f6 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4373,7 +4373,7 @@ check_types_worklist (std::vector<type_equality_entry> *worklist,
 
       /* If the type pair has already been visited, we know it is
 	 ok.  */
-      cache->insert (&entry, sizeof (entry), &added);
+      cache->insert (entry, &added);
       if (!added)
 	continue;
 
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
index 5329d2a5a93..a9c425b63c9 100644
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -110,8 +110,9 @@ macro_free (void *object, struct macro_table *t)
 /* If the macro table T has a bcache, then cache the LEN bytes at ADDR
    there, and return the cached copy.  Otherwise, just xmalloc a copy
    of the bytes, and return a pointer to that.  */
-static const void *
-macro_bcache (struct macro_table *t, const void *addr, int len)
+template<typename U>
+static const U *
+macro_bcache (struct macro_table *t, const U *addr, int len)
 {
   if (t->bcache)
     return t->bcache->insert (addr, len);
@@ -120,7 +121,7 @@ macro_bcache (struct macro_table *t, const void *addr, int len)
       void *copy = xmalloc (len);
 
       memcpy (copy, addr, len);
-      return copy;
+      return (const U *) copy;
     }
 }
 
@@ -131,7 +132,7 @@ macro_bcache (struct macro_table *t, const void *addr, int len)
 static const char *
 macro_bcache_str (struct macro_table *t, const char *s)
 {
-  return (const char *) macro_bcache (t, s, strlen (s) + 1);
+  return macro_bcache (t, s, strlen (s) + 1);
 }
 
 
@@ -572,8 +573,7 @@ new_macro_definition (struct macro_table *t,
 	cached_argv[i] = macro_bcache_str (t, argv[i]);
 
       /* Now bcache the array of argument pointers itself.  */
-      d->argv = ((const char * const *)
-		 macro_bcache (t, cached_argv, cached_argv_size));
+      d->argv = macro_bcache (t, cached_argv, cached_argv_size);
     }
 
   /* We don't bcache the entire definition structure because it's got
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index f1aabd5b10b..ca638515d61 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1062,10 +1062,8 @@ partial_symtab::add_psymbol (const partial_symbol &psymbol,
   bool added;
 
   /* Stash the partial symbol away in the cache.  */
-  partial_symbol *psym
-    = ((struct partial_symbol *)
-       partial_symtabs->psymbol_cache.insert
-       (&psymbol, sizeof (struct partial_symbol), &added));
+  const partial_symbol *psym = partial_symtabs->psymbol_cache.insert (psymbol,
+								      &added);
 
   /* Do not duplicate global partial symbols.  */
   if (where == psymbol_placement::GLOBAL && !added)

-- 
2.43.0


^ permalink raw reply	[relevance 13%]

* [PATCH 2/2] Run isort
  @ 2024-03-20 16:38  1% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-03-20 16:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch is the result of running 'isort .' in the gdb directory.
---
 gdb/python/lib/gdb/__init__.py                | 12 ++++----
 gdb/python/lib/gdb/command/frame_filters.py   |  1 +
 gdb/python/lib/gdb/command/missing_debug.py   |  3 +-
 gdb/python/lib/gdb/command/pretty_printers.py |  3 +-
 gdb/python/lib/gdb/command/type_printers.py   |  1 +
 gdb/python/lib/gdb/command/unwinders.py       |  3 +-
 gdb/python/lib/gdb/command/xmethods.py        |  3 +-
 gdb/python/lib/gdb/dap/__init__.py            | 29 ++++++++++---------
 gdb/python/lib/gdb/dap/breakpoint.py          |  9 +++---
 gdb/python/lib/gdb/dap/bt.py                  |  5 ++--
 gdb/python/lib/gdb/dap/disassemble.py         |  2 +-
 gdb/python/lib/gdb/dap/evaluate.py            | 10 +++----
 gdb/python/lib/gdb/dap/events.py              |  3 +-
 gdb/python/lib/gdb/dap/frames.py              |  3 +-
 gdb/python/lib/gdb/dap/io.py                  |  2 +-
 gdb/python/lib/gdb/dap/launch.py              |  8 ++---
 gdb/python/lib/gdb/dap/locations.py           |  4 +--
 gdb/python/lib/gdb/dap/memory.py              |  3 +-
 gdb/python/lib/gdb/dap/scopes.py              |  3 +-
 gdb/python/lib/gdb/dap/server.py              | 12 ++++----
 gdb/python/lib/gdb/dap/sources.py             |  5 ++--
 gdb/python/lib/gdb/dap/startup.py             |  6 ++--
 gdb/python/lib/gdb/dap/state.py               |  2 +-
 gdb/python/lib/gdb/dap/varref.py              |  7 +++--
 gdb/python/lib/gdb/disassembler.py            |  3 +-
 gdb/python/lib/gdb/frames.py                  |  7 +++--
 gdb/python/lib/gdb/function/caller_is.py      |  3 +-
 gdb/python/lib/gdb/function/strfns.py         |  3 +-
 gdb/python/lib/gdb/missing_debug.py           |  5 ++--
 gdb/python/lib/gdb/printing.py                |  5 ++--
 gdb/python/lib/gdb/prompt.py                  |  3 +-
 gdb/python/lib/gdb/styling.py                 |  4 +--
 gdb/python/lib/gdb/xmethod.py                 |  3 +-
 gdb/python/python-config.py                   |  4 +--
 gdb/syscalls/arm-linux.py                     |  2 +-
 gdb/system-gdbinit/elinos.py                  |  3 +-
 gdb/testsuite/analyze-racy-logs.py            |  2 +-
 gdb/testsuite/gdb.ada/pp-rec-component.py     |  1 +
 gdb/testsuite/gdb.base/pc-not-saved.py        |  2 +-
 gdb/testsuite/gdb.dap/stack-format.py         |  2 +-
 gdb/testsuite/gdb.dap/type_check.py           |  1 +
 .../gdb.perf/gmonster-null-lookup.py          |  4 +--
 .../gdb.perf/gmonster-pervasive-typedef.py    |  4 +--
 gdb/testsuite/gdb.perf/gmonster-print-cerr.py |  4 +--
 .../gdb.perf/gmonster-ptype-string.py         |  4 +--
 gdb/testsuite/gdb.perf/gmonster-runto-main.py |  4 +--
 .../gdb.perf/gmonster-select-file.py          |  4 +--
 .../gdb.perf/lib/perftest/measure.py          |  4 +--
 .../gdb.perf/lib/perftest/perftest.py         | 14 +++++----
 gdb/testsuite/gdb.perf/solib.py               |  3 +-
 ...ded-pretty-printers-in-newobjfile-event.py |  3 +-
 gdb/testsuite/gdb.python/py-bad-printers.py   |  1 +
 gdb/testsuite/gdb.python/py-disasm.py         |  4 +--
 gdb/testsuite/gdb.python/py-event-load.py     |  1 -
 gdb/testsuite/gdb.python/py-frame-args.py     |  1 +
 .../gdb.python/py-framefilter-addr.py         |  5 ++--
 .../gdb.python/py-framefilter-gdb.py          |  3 +-
 .../py-framefilter-invalidarg-gdb.py          |  3 +-
 .../gdb.python/py-framefilter-invalidarg.py   |  5 ++--
 gdb/testsuite/gdb.python/py-framefilter.py    |  5 ++--
 gdb/testsuite/gdb.python/py-inferior-leak.py  |  3 +-
 .../py-mi-var-info-path-expression.py         |  1 +
 gdb/testsuite/gdb.python/py-missing-debug.py  |  5 ++--
 gdb/testsuite/gdb.python/py-nested-maps.py    |  1 +
 gdb/testsuite/gdb.python/py-pp-integral.py    |  1 +
 gdb/testsuite/gdb.python/py-pp-maint.py       |  3 +-
 gdb/testsuite/gdb.python/py-pp-re-notag.py    |  1 +
 .../gdb.python/py-pp-registration.py          |  3 +-
 gdb/testsuite/gdb.python/py-prettyprint.py    |  1 +
 gdb/testsuite/gdb.python/py-send-packet.py    |  1 +
 gdb/testsuite/gdb.python/py-unwind-maint.py   |  1 +
 gdb/testsuite/gdb.python/py-unwind.py         |  3 +-
 gdb/testsuite/gdb.python/py-xmethods.py       |  6 ++--
 gdb/testsuite/gdb.rust/pp.py                  |  1 +
 gdb/testsuite/print-ts.py                     |  4 +--
 75 files changed, 163 insertions(+), 140 deletions(-)

diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
index 5b96605240e..3589117d411 100644
--- a/gdb/python/lib/gdb/__init__.py
+++ b/gdb/python/lib/gdb/__init__.py
@@ -13,11 +13,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import os
 import signal
+import sys
 import threading
 import traceback
-import os
-import sys
 from contextlib import contextmanager
 
 # Python 3 moved "reload"
@@ -27,11 +27,13 @@ else:
     from imp import reload
 
 # Note that two indicators are needed here to silence flake8.
-# isort: split
 from _gdb import *  # noqa: F401,F403
 
+# isort: split
+
 # Historically, gdb.events was always available, so ensure it's
 # still available without an explicit import.
+# isort: split
 import _gdbevents as events
 
 sys.modules["gdb.events"] = events
@@ -63,8 +65,8 @@ class _GdbFile(object):
         write(s, stream=self.stream)  # noqa: F405
 
 
-sys.stdout = _GdbFile(STDOUT)   # noqa: F405
-sys.stderr = _GdbFile(STDERR)   # noqa: F405
+sys.stdout = _GdbFile(STDOUT)  # noqa: F405
+sys.stderr = _GdbFile(STDERR)  # noqa: F405
 
 # Default prompt hook does nothing.
 prompt_hook = None
diff --git a/gdb/python/lib/gdb/command/frame_filters.py b/gdb/python/lib/gdb/command/frame_filters.py
index d774e194fba..4e1b3208d0e 100644
--- a/gdb/python/lib/gdb/command/frame_filters.py
+++ b/gdb/python/lib/gdb/command/frame_filters.py
@@ -17,6 +17,7 @@
 """GDB commands for working with frame-filters."""
 
 import sys
+
 import gdb
 import gdb.frames
 
diff --git a/gdb/python/lib/gdb/command/missing_debug.py b/gdb/python/lib/gdb/command/missing_debug.py
index 9a55e1822f5..313b88cf8c3 100644
--- a/gdb/python/lib/gdb/command/missing_debug.py
+++ b/gdb/python/lib/gdb/command/missing_debug.py
@@ -15,9 +15,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
 import re
 
+import gdb
+
 
 def validate_regexp(exp, idstring):
     """Compile exp into a compiler regular expression object.
diff --git a/gdb/python/lib/gdb/command/pretty_printers.py b/gdb/python/lib/gdb/command/pretty_printers.py
index 6a938ed8fcd..cb9b9f35f9f 100644
--- a/gdb/python/lib/gdb/command/pretty_printers.py
+++ b/gdb/python/lib/gdb/command/pretty_printers.py
@@ -17,9 +17,10 @@
 """GDB commands for working with pretty-printers."""
 
 import copy
-import gdb
 import re
 
+import gdb
+
 
 def parse_printer_regexps(arg):
     """Internal utility to parse a pretty-printer command argv.
diff --git a/gdb/python/lib/gdb/command/type_printers.py b/gdb/python/lib/gdb/command/type_printers.py
index 339f5aac6a2..a2be226850d 100644
--- a/gdb/python/lib/gdb/command/type_printers.py
+++ b/gdb/python/lib/gdb/command/type_printers.py
@@ -15,6 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import copy
+
 import gdb
 
 """GDB commands for working with type-printers."""
diff --git a/gdb/python/lib/gdb/command/unwinders.py b/gdb/python/lib/gdb/command/unwinders.py
index 886287f8794..b863b333aa0 100644
--- a/gdb/python/lib/gdb/command/unwinders.py
+++ b/gdb/python/lib/gdb/command/unwinders.py
@@ -14,9 +14,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
 import re
 
+import gdb
+
 
 def validate_regexp(exp, idstring):
     try:
diff --git a/gdb/python/lib/gdb/command/xmethods.py b/gdb/python/lib/gdb/command/xmethods.py
index fe310b7787e..f7862271858 100644
--- a/gdb/python/lib/gdb/command/xmethods.py
+++ b/gdb/python/lib/gdb/command/xmethods.py
@@ -14,9 +14,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
 import re
 
+import gdb
+
 """GDB commands for working with xmethods."""
 
 
diff --git a/gdb/python/lib/gdb/dap/__init__.py b/gdb/python/lib/gdb/dap/__init__.py
index 81d435e742f..51b95468a70 100644
--- a/gdb/python/lib/gdb/dap/__init__.py
+++ b/gdb/python/lib/gdb/dap/__init__.py
@@ -16,26 +16,27 @@
 import os
 
 # This must come before other DAP imports.
-# isort: split
 from . import startup
 
+# isort: split
+
 # Load modules that define commands.  These imports intentionally
 # ignore the unused import warning, as these modules are being loaded
 # for their side effects -- namely, registering DAP commands with the
 # server object.  "F401" is the flake8 "imported but unused" code.
-from . import breakpoint        # noqa: F401
-from . import bt                # noqa: F401
-from . import disassemble       # noqa: F401
-from . import evaluate          # noqa: F401
-from . import launch            # noqa: F401
-from . import locations         # noqa: F401
-from . import memory            # noqa: F401
-from . import modules           # noqa: F401
-from . import next              # noqa: F401
-from . import pause             # noqa: F401
-from . import scopes            # noqa: F401
-from . import sources           # noqa: F401
-from . import threads           # noqa: F401
+from . import breakpoint  # noqa: F401
+from . import bt  # noqa: F401
+from . import disassemble  # noqa: F401
+from . import evaluate  # noqa: F401
+from . import launch  # noqa: F401
+from . import locations  # noqa: F401
+from . import memory  # noqa: F401
+from . import modules  # noqa: F401
+from . import next  # noqa: F401
+from . import pause  # noqa: F401
+from . import scopes  # noqa: F401
+from . import sources  # noqa: F401
+from . import threads  # noqa: F401
 
 # isort: split
 from .server import Server
diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py
index b4fb1127c2d..b2e74277ebd 100644
--- a/gdb/python/lib/gdb/dap/breakpoint.py
+++ b/gdb/python/lib/gdb/dap/breakpoint.py
@@ -13,21 +13,20 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
 import os
 import re
-
 from contextlib import contextmanager
 
 # These are deprecated in 3.9, but required in older versions.
 from typing import Optional, Sequence
 
-from .server import request, capability, send_event
+import gdb
+
+from .server import capability, request, send_event
 from .sources import make_source
-from .startup import in_gdb_thread, log_stack, parse_and_eval, LogLevel, DAPException
+from .startup import DAPException, LogLevel, in_gdb_thread, log_stack, parse_and_eval
 from .typecheck import type_check
 
-
 # True when suppressing new breakpoint events.
 _suppress_bp = False
 
diff --git a/gdb/python/lib/gdb/dap/bt.py b/gdb/python/lib/gdb/dap/bt.py
index d65ce5fcc2a..e0c2e2a1751 100644
--- a/gdb/python/lib/gdb/dap/bt.py
+++ b/gdb/python/lib/gdb/dap/bt.py
@@ -13,16 +13,17 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
 import os
 
 # This is deprecated in 3.9, but required in older versions.
 from typing import Optional
 
+import gdb
+
 from .frames import dap_frame_generator
 from .modules import module_id
 from .scopes import symbol_value
-from .server import request, capability
+from .server import capability, request
 from .sources import make_source
 from .startup import in_gdb_thread
 from .state import set_thread
diff --git a/gdb/python/lib/gdb/dap/disassemble.py b/gdb/python/lib/gdb/dap/disassemble.py
index a7825289899..65bf3d4457b 100644
--- a/gdb/python/lib/gdb/dap/disassemble.py
+++ b/gdb/python/lib/gdb/dap/disassemble.py
@@ -15,7 +15,7 @@
 
 import gdb
 
-from .server import request, capability
+from .server import capability, request
 
 
 @request("disassemble")
diff --git a/gdb/python/lib/gdb/dap/evaluate.py b/gdb/python/lib/gdb/dap/evaluate.py
index 62519a55521..34843f423d8 100644
--- a/gdb/python/lib/gdb/dap/evaluate.py
+++ b/gdb/python/lib/gdb/dap/evaluate.py
@@ -13,15 +13,15 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
-
 # This is deprecated in 3.9, but required in older versions.
 from typing import Optional
 
+import gdb
+
 from .frames import select_frame
-from .server import capability, request, client_bool_capability
-from .startup import in_gdb_thread, parse_and_eval, DAPException
-from .varref import find_variable, VariableReference, apply_format
+from .server import capability, client_bool_capability, request
+from .startup import DAPException, in_gdb_thread, parse_and_eval
+from .varref import VariableReference, apply_format, find_variable
 
 
 class EvaluateResult(VariableReference):
diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py
index 928f23fd3ff..276d3145b9a 100644
--- a/gdb/python/lib/gdb/dap/events.py
+++ b/gdb/python/lib/gdb/dap/events.py
@@ -15,11 +15,10 @@
 
 import gdb
 
+from .modules import is_module, make_module
 from .scopes import set_finish_value
 from .server import send_event
 from .startup import exec_and_log, in_gdb_thread, log
-from .modules import is_module, make_module
-
 
 # True when the inferior is thought to be running, False otherwise.
 # This may be accessed from any thread, which can be racy.  However,
diff --git a/gdb/python/lib/gdb/dap/frames.py b/gdb/python/lib/gdb/dap/frames.py
index 161c84b025b..07a4e3ea793 100644
--- a/gdb/python/lib/gdb/dap/frames.py
+++ b/gdb/python/lib/gdb/dap/frames.py
@@ -13,14 +13,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
 import itertools
 
+import gdb
 from gdb.frames import frame_iterator
 
 from .startup import in_gdb_thread
 
-
 # A list of all the frames we've reported.  A frame's index in the
 # list is its ID.  We don't use a hash here because frames are not
 # hashable.
diff --git a/gdb/python/lib/gdb/dap/io.py b/gdb/python/lib/gdb/dap/io.py
index bbf822d60bf..03031a72393 100644
--- a/gdb/python/lib/gdb/dap/io.py
+++ b/gdb/python/lib/gdb/dap/io.py
@@ -15,7 +15,7 @@
 
 import json
 
-from .startup import start_thread, log, log_stack, LogLevel
+from .startup import LogLevel, log, log_stack, start_thread
 
 
 def read_json(stream):
diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py
index 6783d999621..2674e02eac3 100644
--- a/gdb/python/lib/gdb/dap/launch.py
+++ b/gdb/python/lib/gdb/dap/launch.py
@@ -13,14 +13,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
-
 # These are deprecated in 3.9, but required in older versions.
 from typing import Mapping, Optional, Sequence
 
+import gdb
+
 from .events import exec_and_expect_stop, expect_process, expect_stop
-from .server import request, capability
-from .startup import exec_and_log, DAPException
+from .server import capability, request
+from .startup import DAPException, exec_and_log
 
 
 # Any parameters here are necessarily extensions -- DAP requires this
diff --git a/gdb/python/lib/gdb/dap/locations.py b/gdb/python/lib/gdb/dap/locations.py
index 098091b4b42..92e68f5e235 100644
--- a/gdb/python/lib/gdb/dap/locations.py
+++ b/gdb/python/lib/gdb/dap/locations.py
@@ -13,11 +13,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
-
 # This is deprecated in 3.9, but required in older versions.
 from typing import Optional
 
+import gdb
+
 from .server import capability, request
 from .sources import decode_source
 
diff --git a/gdb/python/lib/gdb/dap/memory.py b/gdb/python/lib/gdb/dap/memory.py
index 19a61d63499..dd62b0e7ba6 100644
--- a/gdb/python/lib/gdb/dap/memory.py
+++ b/gdb/python/lib/gdb/dap/memory.py
@@ -14,9 +14,10 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import base64
+
 import gdb
 
-from .server import request, capability
+from .server import capability, request
 
 
 @request("readMemory")
diff --git a/gdb/python/lib/gdb/dap/scopes.py b/gdb/python/lib/gdb/dap/scopes.py
index be2c382b40b..8cd860141d6 100644
--- a/gdb/python/lib/gdb/dap/scopes.py
+++ b/gdb/python/lib/gdb/dap/scopes.py
@@ -16,11 +16,10 @@
 import gdb
 
 from .frames import frame_for_id
-from .startup import in_gdb_thread
 from .server import request
+from .startup import in_gdb_thread
 from .varref import BaseReference
 
-
 # Map DAP frame IDs to scopes.  This ensures that scopes are re-used.
 frame_to_scope = {}
 
diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index 70646f4d75c..7eb87177710 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -14,29 +14,29 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import functools
-import gdb
 import heapq
 import inspect
 import json
 import threading
 from contextlib import contextmanager
 
-from .io import start_json_writer, read_json
+import gdb
+
+from .io import read_json, start_json_writer
 from .startup import (
-    exec_and_log,
     DAPException,
     DAPQueue,
+    LogLevel,
+    exec_and_log,
     in_dap_thread,
     in_gdb_thread,
-    start_thread,
     log,
     log_stack,
-    LogLevel,
+    start_thread,
     thread_log,
 )
 from .typecheck import type_check
 
-
 # Map capability names to values.
 _capabilities = {}
 
diff --git a/gdb/python/lib/gdb/dap/sources.py b/gdb/python/lib/gdb/dap/sources.py
index c9b77208145..ee3464db679 100644
--- a/gdb/python/lib/gdb/dap/sources.py
+++ b/gdb/python/lib/gdb/dap/sources.py
@@ -17,9 +17,8 @@ import os
 
 import gdb
 
-from .server import request, capability
-from .startup import in_gdb_thread, DAPException
-
+from .server import capability, request
+from .startup import DAPException, in_gdb_thread
 
 # The next available source reference ID.  Must be greater than 0.
 _next_source = 1
diff --git a/gdb/python/lib/gdb/dap/startup.py b/gdb/python/lib/gdb/dap/startup.py
index aaf1e8cd657..58591c00b97 100644
--- a/gdb/python/lib/gdb/dap/startup.py
+++ b/gdb/python/lib/gdb/dap/startup.py
@@ -16,14 +16,14 @@
 # Do not import other gdbdap modules here -- this module must come
 # first.
 import functools
-import gdb
 import queue
+import sys
 import threading
 import traceback
-import sys
-
 from enum import IntEnum, auto
 
+import gdb
+
 # Adapt to different Queue types.  This is exported for use in other
 # modules as well.
 if sys.version_info[0] == 3 and sys.version_info[1] <= 6:
diff --git a/gdb/python/lib/gdb/dap/state.py b/gdb/python/lib/gdb/dap/state.py
index 9cb703157de..57ae355f45e 100644
--- a/gdb/python/lib/gdb/dap/state.py
+++ b/gdb/python/lib/gdb/dap/state.py
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-from .startup import in_gdb_thread, exec_and_log, log
+from .startup import exec_and_log, in_gdb_thread, log
 
 
 @in_gdb_thread
diff --git a/gdb/python/lib/gdb/dap/varref.py b/gdb/python/lib/gdb/dap/varref.py
index e413e4e8043..57e84a1676e 100644
--- a/gdb/python/lib/gdb/dap/varref.py
+++ b/gdb/python/lib/gdb/dap/varref.py
@@ -13,13 +13,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
-from .startup import in_gdb_thread, DAPException
-from .server import client_bool_capability
 from abc import ABC, abstractmethod
 from collections import defaultdict
 from contextlib import contextmanager
 
+import gdb
+
+from .server import client_bool_capability
+from .startup import DAPException, in_gdb_thread
 
 # A list of all the variable references created during this pause.
 all_variables = []
diff --git a/gdb/python/lib/gdb/disassembler.py b/gdb/python/lib/gdb/disassembler.py
index af7dcc5f6a8..72d311b117f 100644
--- a/gdb/python/lib/gdb/disassembler.py
+++ b/gdb/python/lib/gdb/disassembler.py
@@ -15,7 +15,6 @@
 
 """Disassembler related module."""
 
-import gdb
 import _gdb.disassembler
 
 # Re-export everything from the _gdb.disassembler module, which is
@@ -23,6 +22,8 @@ import _gdb.disassembler
 # here to silence flake8.
 from _gdb.disassembler import *  # noqa: F401,F403
 
+import gdb
+
 # Module global dictionary of gdb.disassembler.Disassembler objects.
 # The keys of this dictionary are bfd architecture names, or the
 # special value None.
diff --git a/gdb/python/lib/gdb/frames.py b/gdb/python/lib/gdb/frames.py
index 44f3217b8f8..a3be80c72a0 100644
--- a/gdb/python/lib/gdb/frames.py
+++ b/gdb/python/lib/gdb/frames.py
@@ -16,11 +16,12 @@
 
 """Internal functions for working with frame-filters."""
 
+import collections
+import itertools
+
 import gdb
+from gdb.FrameDecorator import DAPFrameDecorator, FrameDecorator
 from gdb.FrameIterator import FrameIterator
-from gdb.FrameDecorator import FrameDecorator, DAPFrameDecorator
-import itertools
-import collections
 
 
 def get_priority(filter_item):
diff --git a/gdb/python/lib/gdb/function/caller_is.py b/gdb/python/lib/gdb/function/caller_is.py
index eb87c23740b..bacd8c0ef8b 100644
--- a/gdb/python/lib/gdb/function/caller_is.py
+++ b/gdb/python/lib/gdb/function/caller_is.py
@@ -14,9 +14,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
 import re
 
+import gdb
+
 
 class CallerIs(gdb.Function):
     """Check the calling function's name.
diff --git a/gdb/python/lib/gdb/function/strfns.py b/gdb/python/lib/gdb/function/strfns.py
index 42e5b9cd35b..90c9ceab867 100644
--- a/gdb/python/lib/gdb/function/strfns.py
+++ b/gdb/python/lib/gdb/function/strfns.py
@@ -16,9 +16,10 @@
 
 """$_memeq, $_strlen, $_streq, $_regex"""
 
-import gdb
 import re
 
+import gdb
+
 
 class _MemEq(gdb.Function):
     """$_memeq - compare bytes of memory.
diff --git a/gdb/python/lib/gdb/missing_debug.py b/gdb/python/lib/gdb/missing_debug.py
index 3093a9ffe4c..6d57462c185 100644
--- a/gdb/python/lib/gdb/missing_debug.py
+++ b/gdb/python/lib/gdb/missing_debug.py
@@ -17,9 +17,10 @@
 MissingDebugHandler base class, and register_handler function.
 """
 
-import gdb
 import sys
 
+import gdb
+
 if sys.version_info >= (3, 7):
     # Functions str.isascii() and str.isalnum are available starting Python
     # 3.7.
@@ -32,7 +33,7 @@ if sys.version_info >= (3, 7):
 else:
     # Fall back to curses.ascii.isascii() and curses.ascii.isalnum() for
     # earlier versions.
-    from curses.ascii import isascii, isalnum
+    from curses.ascii import isalnum, isascii
 
 
 def _validate_name(name):
diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py
index d7933e9df76..55ba43585ec 100644
--- a/gdb/python/lib/gdb/printing.py
+++ b/gdb/python/lib/gdb/printing.py
@@ -16,11 +16,12 @@
 
 """Utilities for working with pretty-printers."""
 
-import gdb
-import gdb.types
 import itertools
 import re
 
+import gdb
+import gdb.types
+
 
 class PrettyPrinter(object):
     """A basic pretty-printer.
diff --git a/gdb/python/lib/gdb/prompt.py b/gdb/python/lib/gdb/prompt.py
index 02185b353df..4ad38e4567a 100644
--- a/gdb/python/lib/gdb/prompt.py
+++ b/gdb/python/lib/gdb/prompt.py
@@ -16,9 +16,10 @@
 
 """ Extended prompt library functions."""
 
-import gdb
 import os
 
+import gdb
+
 
 def _prompt_pwd(ignore):
     "The current working directory."
diff --git a/gdb/python/lib/gdb/styling.py b/gdb/python/lib/gdb/styling.py
index 8e5d64f15d9..1c5394e479b 100644
--- a/gdb/python/lib/gdb/styling.py
+++ b/gdb/python/lib/gdb/styling.py
@@ -19,9 +19,9 @@
 import gdb
 
 try:
-    from pygments import formatters, lexers, highlight
-    from pygments.token import Error, Comment, Text
+    from pygments import formatters, highlight, lexers
     from pygments.filters import TokenMergeFilter
+    from pygments.token import Comment, Error, Text
 
     _formatter = None
 
diff --git a/gdb/python/lib/gdb/xmethod.py b/gdb/python/lib/gdb/xmethod.py
index ea7b15c4dac..c98402d271f 100644
--- a/gdb/python/lib/gdb/xmethod.py
+++ b/gdb/python/lib/gdb/xmethod.py
@@ -16,9 +16,10 @@
 
 """Utilities for defining xmethods"""
 
-import gdb
 import re
 
+import gdb
+
 
 class XMethod(object):
     """Base class (or a template) for an xmethod description.
diff --git a/gdb/python/python-config.py b/gdb/python/python-config.py
index e89e0fd40bb..061eae1ac64 100644
--- a/gdb/python/python-config.py
+++ b/gdb/python/python-config.py
@@ -1,9 +1,9 @@
 # Program to fetch python compilation parameters.
 # Copied from python-config of the 2.7 release.
 
-import sys
-import os
 import getopt
+import os
+import sys
 import sysconfig
 
 valid_opts = ["prefix", "exec-prefix", "includes", "libs", "cflags", "ldflags", "help"]
diff --git a/gdb/syscalls/arm-linux.py b/gdb/syscalls/arm-linux.py
index 8213f5ce33d..a3f64d0a825 100644
--- a/gdb/syscalls/arm-linux.py
+++ b/gdb/syscalls/arm-linux.py
@@ -5,8 +5,8 @@
 # notice and this notice are preserved.  This file is offered as-is,
 # without any warranty.
 
-import sys
 import re
+import sys
 import time
 
 infname = sys.argv[1]
diff --git a/gdb/system-gdbinit/elinos.py b/gdb/system-gdbinit/elinos.py
index bd9d4630438..da82687a76f 100644
--- a/gdb/system-gdbinit/elinos.py
+++ b/gdb/system-gdbinit/elinos.py
@@ -15,8 +15,9 @@
 
 """Configure GDB using the ELinOS environment."""
 
-import os
 import glob
+import os
+
 import gdb
 
 
diff --git a/gdb/testsuite/analyze-racy-logs.py b/gdb/testsuite/analyze-racy-logs.py
index bd548e23a31..152490e7686 100755
--- a/gdb/testsuite/analyze-racy-logs.py
+++ b/gdb/testsuite/analyze-racy-logs.py
@@ -29,9 +29,9 @@
 # This program is invoked when the user runs "make check" and
 # specifies the RACY_ITER environment variable.
 
-import sys
 import os
 import re
+import sys
 
 # The (global) dictionary that stores the associations between a *.sum
 # file and its results.  The data inside it will be stored as:
diff --git a/gdb/testsuite/gdb.ada/pp-rec-component.py b/gdb/testsuite/gdb.ada/pp-rec-component.py
index 339e4a362a3..3d398125e06 100644
--- a/gdb/testsuite/gdb.ada/pp-rec-component.py
+++ b/gdb/testsuite/gdb.ada/pp-rec-component.py
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from time import asctime, gmtime
+
 import gdb  # silence pyflakes
 
 
diff --git a/gdb/testsuite/gdb.base/pc-not-saved.py b/gdb/testsuite/gdb.base/pc-not-saved.py
index 2e19da80b3f..8090858895e 100644
--- a/gdb/testsuite/gdb.base/pc-not-saved.py
+++ b/gdb/testsuite/gdb.base/pc-not-saved.py
@@ -14,7 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import gdb
-from gdb.unwinder import Unwinder, FrameId
+from gdb.unwinder import FrameId, Unwinder
 
 # Cached FrameId.  See set_break_bt_here_frame_id for details.
 break_bt_here_frame_id = None
diff --git a/gdb/testsuite/gdb.dap/stack-format.py b/gdb/testsuite/gdb.dap/stack-format.py
index 12c6cc473e5..b7799f41dac 100644
--- a/gdb/testsuite/gdb.dap/stack-format.py
+++ b/gdb/testsuite/gdb.dap/stack-format.py
@@ -14,9 +14,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-import gdb
 import itertools
 
+import gdb
 from gdb.FrameDecorator import DAPFrameDecorator
 
 
diff --git a/gdb/testsuite/gdb.dap/type_check.py b/gdb/testsuite/gdb.dap/type_check.py
index 513995b5571..81b106a595f 100644
--- a/gdb/testsuite/gdb.dap/type_check.py
+++ b/gdb/testsuite/gdb.dap/type_check.py
@@ -16,6 +16,7 @@
 # Test the type checker.
 
 import typing
+
 from gdb.dap.typecheck import type_check
 
 
diff --git a/gdb/testsuite/gdb.perf/gmonster-null-lookup.py b/gdb/testsuite/gdb.perf/gmonster-null-lookup.py
index b6cbcf3e825..0d5ba768843 100644
--- a/gdb/testsuite/gdb.perf/gmonster-null-lookup.py
+++ b/gdb/testsuite/gdb.perf/gmonster-null-lookup.py
@@ -17,9 +17,7 @@
 # Efficient handling of this case is important, and not just for typos.
 # Sometimes the debug info for the needed object isn't present.
 
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
 
 
 class NullLookup(perftest.TestCaseWithBasicMeasurements):
diff --git a/gdb/testsuite/gdb.perf/gmonster-pervasive-typedef.py b/gdb/testsuite/gdb.perf/gmonster-pervasive-typedef.py
index 048cf7af2d0..3e239f5292b 100644
--- a/gdb/testsuite/gdb.perf/gmonster-pervasive-typedef.py
+++ b/gdb/testsuite/gdb.perf/gmonster-pervasive-typedef.py
@@ -17,9 +17,7 @@
 # typedef used pervasively.  This exercises the perf regression introduced by
 # the original patch to pr 16253.
 
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
 
 
 class PervasiveTypedef(perftest.TestCaseWithBasicMeasurements):
diff --git a/gdb/testsuite/gdb.perf/gmonster-print-cerr.py b/gdb/testsuite/gdb.perf/gmonster-print-cerr.py
index 97f454b25fb..4f57b860bdd 100644
--- a/gdb/testsuite/gdb.perf/gmonster-print-cerr.py
+++ b/gdb/testsuite/gdb.perf/gmonster-print-cerr.py
@@ -25,9 +25,7 @@
 # is that here we do not pre-expand the symtab: we don't want include
 # GDB's slowness in searching expanded symtabs first to color these results.
 
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
 
 
 class PrintCerr(perftest.TestCaseWithBasicMeasurements):
diff --git a/gdb/testsuite/gdb.perf/gmonster-ptype-string.py b/gdb/testsuite/gdb.perf/gmonster-ptype-string.py
index 7ecc221378a..0c000ef5bb3 100644
--- a/gdb/testsuite/gdb.perf/gmonster-ptype-string.py
+++ b/gdb/testsuite/gdb.perf/gmonster-ptype-string.py
@@ -19,9 +19,7 @@
 # these before it searches the index (there is work-in-progress to fix this),
 # this test helps measure the issue.
 
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
 
 
 class GmonsterPtypeString(perftest.TestCaseWithBasicMeasurements):
diff --git a/gdb/testsuite/gdb.perf/gmonster-runto-main.py b/gdb/testsuite/gdb.perf/gmonster-runto-main.py
index e69036763a6..a183d68d012 100644
--- a/gdb/testsuite/gdb.perf/gmonster-runto-main.py
+++ b/gdb/testsuite/gdb.perf/gmonster-runto-main.py
@@ -15,9 +15,7 @@
 
 # Measure performance of running to main.
 
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
 
 
 class GmonsterRuntoMain(perftest.TestCaseWithBasicMeasurements):
diff --git a/gdb/testsuite/gdb.perf/gmonster-select-file.py b/gdb/testsuite/gdb.perf/gmonster-select-file.py
index 211211236fb..4708458384e 100644
--- a/gdb/testsuite/gdb.perf/gmonster-select-file.py
+++ b/gdb/testsuite/gdb.perf/gmonster-select-file.py
@@ -15,9 +15,7 @@
 
 # Measure performance of selecting a file to debug.
 
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
 
 
 class GmonsterSelectFile(perftest.TestCaseWithBasicMeasurements):
diff --git a/gdb/testsuite/gdb.perf/lib/perftest/measure.py b/gdb/testsuite/gdb.perf/lib/perftest/measure.py
index 942b1c4774d..00a1a9ada2b 100644
--- a/gdb/testsuite/gdb.perf/lib/perftest/measure.py
+++ b/gdb/testsuite/gdb.perf/lib/perftest/measure.py
@@ -13,10 +13,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import time
-import os
 import gc
+import os
 import sys
+import time
 
 # time.perf_counter() and time.process_time() were added in Python
 # 3.3, time.clock() was removed in Python 3.8.
diff --git a/gdb/testsuite/gdb.perf/lib/perftest/perftest.py b/gdb/testsuite/gdb.perf/lib/perftest/perftest.py
index caaae13c5b6..40ed9cc0d68 100644
--- a/gdb/testsuite/gdb.perf/lib/perftest/perftest.py
+++ b/gdb/testsuite/gdb.perf/lib/perftest/perftest.py
@@ -15,13 +15,15 @@
 
 from __future__ import absolute_import
 
-import perftest.testresult as testresult
 import perftest.reporter as reporter
-from perftest.measure import Measure
-from perftest.measure import MeasurementPerfCounter
-from perftest.measure import MeasurementProcessTime
-from perftest.measure import MeasurementWallTime
-from perftest.measure import MeasurementVmSize
+import perftest.testresult as testresult
+from perftest.measure import (
+    Measure,
+    MeasurementPerfCounter,
+    MeasurementProcessTime,
+    MeasurementVmSize,
+    MeasurementWallTime,
+)
 
 
 class TestCase(object):
diff --git a/gdb/testsuite/gdb.perf/solib.py b/gdb/testsuite/gdb.perf/solib.py
index 0dd1d7429be..470009667e8 100644
--- a/gdb/testsuite/gdb.perf/solib.py
+++ b/gdb/testsuite/gdb.perf/solib.py
@@ -16,8 +16,7 @@
 # This test case is to test the speed of GDB when it is handling the
 # shared libraries of inferior are loaded and unloaded.
 
-from perftest import perftest
-from perftest import measure
+from perftest import measure, perftest
 
 
 class SolibLoadUnload1(perftest.TestCaseWithBasicMeasurements):
diff --git a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py
index 97dc3758079..d63c0877199 100644
--- a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py
+++ b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py
@@ -18,9 +18,10 @@
 # registered when a custom event handler for the new_objfile event
 # is called.
 
-import gdb
 import os
 
+import gdb
+
 
 def new_objfile_handler(event):
     assert isinstance(event, gdb.NewObjFileEvent)
diff --git a/gdb/testsuite/gdb.python/py-bad-printers.py b/gdb/testsuite/gdb.python/py-bad-printers.py
index 068c00140a3..ac9c35e6a90 100644
--- a/gdb/testsuite/gdb.python/py-bad-printers.py
+++ b/gdb/testsuite/gdb.python/py-bad-printers.py
@@ -19,6 +19,7 @@
 # Test a printer with a bad children iterator.
 
 import re
+
 import gdb.printing
 
 
diff --git a/gdb/testsuite/gdb.python/py-disasm.py b/gdb/testsuite/gdb.python/py-disasm.py
index 281ce6b8c2a..c09eae811ee 100644
--- a/gdb/testsuite/gdb.python/py-disasm.py
+++ b/gdb/testsuite/gdb.python/py-disasm.py
@@ -13,11 +13,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
-import gdb.disassembler
 import struct
 import sys
 
+import gdb
+import gdb.disassembler
 from gdb.disassembler import Disassembler, DisassemblerResult
 
 # A global, holds the program-counter address at which we should
diff --git a/gdb/testsuite/gdb.python/py-event-load.py b/gdb/testsuite/gdb.python/py-event-load.py
index 0c9e736a0bb..cffd5c0a15d 100644
--- a/gdb/testsuite/gdb.python/py-event-load.py
+++ b/gdb/testsuite/gdb.python/py-event-load.py
@@ -17,7 +17,6 @@
 
 import gdb
 
-
 freed_objfile = None
 
 
diff --git a/gdb/testsuite/gdb.python/py-frame-args.py b/gdb/testsuite/gdb.python/py-frame-args.py
index abf89ac20f9..04ab1ac4672 100644
--- a/gdb/testsuite/gdb.python/py-frame-args.py
+++ b/gdb/testsuite/gdb.python/py-frame-args.py
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 import gdb
 
 
diff --git a/gdb/testsuite/gdb.python/py-framefilter-addr.py b/gdb/testsuite/gdb.python/py-framefilter-addr.py
index 7c64440b59c..c22d91c10ba 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-addr.py
+++ b/gdb/testsuite/gdb.python/py-framefilter-addr.py
@@ -13,10 +13,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
+import copy
 import itertools
+
+import gdb
 from gdb.FrameDecorator import FrameDecorator
-import copy
 
 
 # A FrameDecorator that just returns gdb.Frame.pc () from 'function'.
diff --git a/gdb/testsuite/gdb.python/py-framefilter-gdb.py b/gdb/testsuite/gdb.python/py-framefilter-gdb.py
index 2b786913243..ada7ad72e4c 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-gdb.py
+++ b/gdb/testsuite/gdb.python/py-framefilter-gdb.py
@@ -13,10 +13,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import itertools
+
 # This file is part of the GDB testsuite.  It tests Python-based
 # frame-filters.
 import gdb
-import itertools
 from gdb.FrameDecorator import FrameDecorator
 
 
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py b/gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py
index 60e81fc2f88..fbe0c0d4a94 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py
@@ -13,10 +13,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import itertools
+
 # This file is part of the GDB testsuite.  It tests Python-based
 # frame-filters.
 import gdb
-import itertools
 from gdb.FrameDecorator import FrameDecorator
 
 
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
index 0793a2875d8..cb25cd9902c 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
@@ -13,12 +13,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import copy
+import itertools
+
 # This file is part of the GDB testsuite.  It tests Python-based
 # frame-filters.
 import gdb
-import itertools
 from gdb.FrameDecorator import FrameDecorator
-import copy
 
 
 class Reverse_Function(FrameDecorator):
diff --git a/gdb/testsuite/gdb.python/py-framefilter.py b/gdb/testsuite/gdb.python/py-framefilter.py
index 720fbf920d0..fb679f18b4f 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.py
+++ b/gdb/testsuite/gdb.python/py-framefilter.py
@@ -13,12 +13,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import copy
+import itertools
+
 # This file is part of the GDB testsuite.  It tests Python-based
 # frame-filters.
 import gdb
-import itertools
 from gdb.FrameDecorator import FrameDecorator
-import copy
 
 
 class Reverse_Function(FrameDecorator):
diff --git a/gdb/testsuite/gdb.python/py-inferior-leak.py b/gdb/testsuite/gdb.python/py-inferior-leak.py
index c3e88015e99..ae3629a76a0 100644
--- a/gdb/testsuite/gdb.python/py-inferior-leak.py
+++ b/gdb/testsuite/gdb.python/py-inferior-leak.py
@@ -13,9 +13,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import re
 import tracemalloc
+
 import gdb
-import re
 
 # A global variable in which we store a reference to the gdb.Inferior
 # object sent to us in the new_inferior event.
diff --git a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py
index 21843e0d7ab..889188fb403 100644
--- a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py
+++ b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import sys
+
 import gdb
 import gdb.types
 
diff --git a/gdb/testsuite/gdb.python/py-missing-debug.py b/gdb/testsuite/gdb.python/py-missing-debug.py
index 502180336ab..c1bafdd6c26 100644
--- a/gdb/testsuite/gdb.python/py-missing-debug.py
+++ b/gdb/testsuite/gdb.python/py-missing-debug.py
@@ -13,10 +13,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import os
+from enum import Enum
+
 import gdb
 from gdb.missing_debug import MissingDebugHandler
-from enum import Enum
-import os
 
 # A global log that is filled in by instances of the LOG_HANDLER class
 # when they are called.
diff --git a/gdb/testsuite/gdb.python/py-nested-maps.py b/gdb/testsuite/gdb.python/py-nested-maps.py
index e949941df82..ac04bbff597 100644
--- a/gdb/testsuite/gdb.python/py-nested-maps.py
+++ b/gdb/testsuite/gdb.python/py-nested-maps.py
@@ -17,6 +17,7 @@
 # nested map like structures.
 
 import re
+
 import gdb
 
 
diff --git a/gdb/testsuite/gdb.python/py-pp-integral.py b/gdb/testsuite/gdb.python/py-pp-integral.py
index 4c981d62564..089ca5ba69b 100644
--- a/gdb/testsuite/gdb.python/py-pp-integral.py
+++ b/gdb/testsuite/gdb.python/py-pp-integral.py
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from time import asctime, gmtime
+
 import gdb  # silence pyflakes
 
 
diff --git a/gdb/testsuite/gdb.python/py-pp-maint.py b/gdb/testsuite/gdb.python/py-pp-maint.py
index 598c5441cb8..91c193fb8ca 100644
--- a/gdb/testsuite/gdb.python/py-pp-maint.py
+++ b/gdb/testsuite/gdb.python/py-pp-maint.py
@@ -17,8 +17,9 @@
 # printers.
 
 import re
-import gdb.types
+
 import gdb.printing
+import gdb.types
 
 
 def lookup_function_lookup_test(val):
diff --git a/gdb/testsuite/gdb.python/py-pp-re-notag.py b/gdb/testsuite/gdb.python/py-pp-re-notag.py
index 9cc889f819f..6aefad13d85 100644
--- a/gdb/testsuite/gdb.python/py-pp-re-notag.py
+++ b/gdb/testsuite/gdb.python/py-pp-re-notag.py
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from time import asctime, gmtime
+
 import gdb  # silence pyflakes
 
 
diff --git a/gdb/testsuite/gdb.python/py-pp-registration.py b/gdb/testsuite/gdb.python/py-pp-registration.py
index c87f75dc56f..1b7eff8ceba 100644
--- a/gdb/testsuite/gdb.python/py-pp-registration.py
+++ b/gdb/testsuite/gdb.python/py-pp-registration.py
@@ -17,8 +17,9 @@
 # printer registration.
 
 import re
-import gdb.types
+
 import gdb.printing
+import gdb.types
 
 
 def lookup_function_lookup_test(val):
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.py b/gdb/testsuite/gdb.python/py-prettyprint.py
index 79c06dd774f..e4ac3e1e510 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.py
+++ b/gdb/testsuite/gdb.python/py-prettyprint.py
@@ -17,6 +17,7 @@
 # printers.
 
 import re
+
 import gdb
 
 
diff --git a/gdb/testsuite/gdb.python/py-send-packet.py b/gdb/testsuite/gdb.python/py-send-packet.py
index 93b0a79f3c5..402b0397bc7 100644
--- a/gdb/testsuite/gdb.python/py-send-packet.py
+++ b/gdb/testsuite/gdb.python/py-send-packet.py
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import xml.etree.ElementTree as ET
+
 import gdb
 
 
diff --git a/gdb/testsuite/gdb.python/py-unwind-maint.py b/gdb/testsuite/gdb.python/py-unwind-maint.py
index f87263d85fe..1d049a999f4 100644
--- a/gdb/testsuite/gdb.python/py-unwind-maint.py
+++ b/gdb/testsuite/gdb.python/py-unwind-maint.py
@@ -16,6 +16,7 @@
 # This file is part of the GDB testsuite.  It tests python unwinders.
 
 import re
+
 import gdb.types
 from gdb.unwinder import Unwinder, register_unwinder
 
diff --git a/gdb/testsuite/gdb.python/py-unwind.py b/gdb/testsuite/gdb.python/py-unwind.py
index 6073e585169..62bfb09f443 100644
--- a/gdb/testsuite/gdb.python/py-unwind.py
+++ b/gdb/testsuite/gdb.python/py-unwind.py
@@ -14,8 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import gdb
-from gdb.unwinder import Unwinder, FrameId
-
+from gdb.unwinder import FrameId, Unwinder
 
 # These are set to test whether invalid register names cause an error.
 add_saved_register_errors = {}
diff --git a/gdb/testsuite/gdb.python/py-xmethods.py b/gdb/testsuite/gdb.python/py-xmethods.py
index 54bd10b1cbd..a2b8d578c66 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.py
+++ b/gdb/testsuite/gdb.python/py-xmethods.py
@@ -16,12 +16,10 @@
 # This file is part of the GDB testsuite.  It test the xmethods support
 # in the Python extension language.
 
-import gdb
 import re
 
-from gdb.xmethod import XMethod
-from gdb.xmethod import XMethodMatcher, XMethodWorker
-from gdb.xmethod import SimpleXMethodMatcher
+import gdb
+from gdb.xmethod import SimpleXMethodMatcher, XMethod, XMethodMatcher, XMethodWorker
 
 
 def A_plus_A(obj, opr):
diff --git a/gdb/testsuite/gdb.rust/pp.py b/gdb/testsuite/gdb.rust/pp.py
index 356737bd794..fbc0868f83a 100644
--- a/gdb/testsuite/gdb.rust/pp.py
+++ b/gdb/testsuite/gdb.rust/pp.py
@@ -17,6 +17,7 @@
 # printers.
 
 import re
+
 import gdb
 
 
diff --git a/gdb/testsuite/print-ts.py b/gdb/testsuite/print-ts.py
index 086c293eeac..0a832ba7b93 100755
--- a/gdb/testsuite/print-ts.py
+++ b/gdb/testsuite/print-ts.py
@@ -30,10 +30,10 @@
 # FORMAT must be a string compatible with "strftime".  If nothing is
 # provided, we choose a reasonable format.
 
-import fileinput
 import datetime
-import sys
+import fileinput
 import os
+import sys
 
 if len(sys.argv) > 1:
     fmt = sys.argv[1]
-- 
2.43.0


^ permalink raw reply	[relevance 1%]

* Re: [PATCH] gdb/python: Allow SIGTRAMP_FRAME python unwinders to be created.
  @ 2024-03-20 14:13  0% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-03-20 14:13 UTC (permalink / raw)
  To: Rémi Bernon, gdb-patches; +Cc: Rémi Bernon

Rémi Bernon <rbernon@codeweavers.com> writes:

> Wine now executes Win32 code on a separate stack for its Unix code. It
> switches from one stack to another on through specific functions, and
> without any custom unwinders, debugging Wine in Gdb will only let you
> see the frames of either the Win32 side, or the Unix side.
>
> The Win32 and Unix call stacks are actually interleaved, with Unix code
> sometimes calling back into Win32. Using a custom Python frame unwinder
> we can provide Gdb with the information it needs to join both toghether
> and show a complete interleaved call stack. However, Gdb will often stop
> unwinding as it will see the frames from one stack as inner the frames
> from the other stack.
>
> This allows to write custom unwinders to produce SIGTRAMP_FRAME typed
> frames, which bypasses this restriction and will show the Win32 / Unix
> gate as a signal frame.
> ---
>  gdb/python/lib/gdb/__init__.py |  8 ++++----
>  gdb/python/lib/gdb/unwinder.py |  7 ++++++-
>  gdb/python/py-unwind.c         | 16 +++++++++++++++-

As Guinevere pointed out, this will really need a test case.  But also
you'll need to update the documentation.

>  3 files changed, 25 insertions(+), 6 deletions(-)
>
> diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
> index b3124369fe8..d9226440cbc 100644
> --- a/gdb/python/lib/gdb/__init__.py
> +++ b/gdb/python/lib/gdb/__init__.py
> @@ -86,7 +86,7 @@ frame_filters = {}
>  frame_unwinders = []
>  
>  
> -def _execute_unwinders(pending_frame):
> +def _execute_unwinders(pending_frame, frame_type):

There are lots of different frame types, but in the C++ code we only
invoke for NORMAL_FRAME and SIGTRAMP_FRAME, yet a user could register an
unwinder for e.g. INLINE_FRAME, and that'll never be used.  So at a
minimum I think we need additional error checking when unwinders are
registered.

Also, there's the 'info unwinder' command which would need updating to
display the unwinder type I think.

I wonder if instead of giving frames a type, if we could have GDB ask
the unwinder if it should perform a more-inner check, and the Python
unwinders could just say no.

Guinevere has some patches that C++-ify the unwinders, so this might
make it easier to add new methods, which might make doing something like
this easier.

I think there's only two places where the more-inner check is performed,
so I'd be interested to see what drawbacks there might be to this
approach.

>      """Internal function called from GDB to execute all unwinders.
>  
>      Runs each currently enabled unwinder until it finds the one that
> @@ -105,19 +105,19 @@ def _execute_unwinders(pending_frame):
>      """
>      for objfile in objfiles():
>          for unwinder in objfile.frame_unwinders:
> -            if unwinder.enabled:
> +            if unwinder.enabled and unwinder.frame_type == frame_type:
>                  unwind_info = unwinder(pending_frame)
>                  if unwind_info is not None:
>                      return (unwind_info, unwinder.name)
>  
>      for unwinder in current_progspace().frame_unwinders:
> -        if unwinder.enabled:
> +        if unwinder.enabled and unwinder.frame_type == frame_type:
>              unwind_info = unwinder(pending_frame)
>              if unwind_info is not None:
>                  return (unwind_info, unwinder.name)
>  
>      for unwinder in frame_unwinders:
> -        if unwinder.enabled:
> +        if unwinder.enabled and unwinder.frame_type == frame_type:
>              unwind_info = unwinder(pending_frame)
>              if unwind_info is not None:
>                  return (unwind_info, unwinder.name)
> diff --git a/gdb/python/lib/gdb/unwinder.py b/gdb/python/lib/gdb/unwinder.py
> index 140b84d3374..7e23a662a32 100644
> --- a/gdb/python/lib/gdb/unwinder.py
> +++ b/gdb/python/lib/gdb/unwinder.py
> @@ -29,7 +29,7 @@ class Unwinder(object):
>          enabled: A boolean indicating whether the unwinder is enabled.
>      """
>  
> -    def __init__(self, name):
> +    def __init__(self, name, frame_type=gdb.NORMAL_FRAME):
>          """Constructor.
>  
>          Args:
> @@ -39,9 +39,14 @@ class Unwinder(object):
>          if not isinstance(name, str):
>              raise TypeError("incorrect type for name: %s" % type(name))
>  
> +        self._frame_type = frame_type
>          self._name = name
>          self._enabled = True
>  
> +    @property
> +    def frame_type(self):
> +        return self._frame_type
> +
>      @property
>      def name(self):
>          return self._name
> diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
> index 1856e41e2a1..2d36c43d342 100644
> --- a/gdb/python/py-unwind.c
> +++ b/gdb/python/py-unwind.c
> @@ -844,7 +844,8 @@ pyuw_sniffer (const struct frame_unwind *self, frame_info_ptr this_frame,
>    /* A (gdb.UnwindInfo, str) tuple, or None.  */
>    gdbpy_ref<> pyo_execute_ret
>      (PyObject_CallFunctionObjArgs (pyo_execute.get (),
> -				   pyo_pending_frame.get (), NULL));
> +				   pyo_pending_frame.get (),
> +				   PyLong_FromLong(self->type), NULL));

Nit: missing a space after PyLong_FromLong before the '('.

Thanks,
Andrew


>    if (pyo_execute_ret == nullptr)
>      {
>        /* If the unwinder is cancelled due to a Ctrl-C, then propagate
> @@ -965,6 +966,19 @@ pyuw_on_new_gdbarch (struct gdbarch *newarch)
>        unwinder->sniffer = pyuw_sniffer;
>        unwinder->dealloc_cache = pyuw_dealloc_cache;
>        frame_unwind_prepend_unwinder (newarch, unwinder);
> +
> +      struct frame_unwind *unwinder_signals
> +	  = GDBARCH_OBSTACK_ZALLOC (newarch, struct frame_unwind);
> +
> +      unwinder_signals->name = "python-sigtramp";
> +      unwinder_signals->type = SIGTRAMP_FRAME;
> +      unwinder_signals->stop_reason = default_frame_unwind_stop_reason;
> +      unwinder_signals->this_id = pyuw_this_id;
> +      unwinder_signals->prev_register = pyuw_prev_register;
> +      unwinder_signals->unwind_data = (const struct frame_data *) newarch;
> +      unwinder_signals->sniffer = pyuw_sniffer;
> +      unwinder_signals->dealloc_cache = pyuw_dealloc_cache;
> +      frame_unwind_prepend_unwinder (newarch, unwinder_signals);
>        data->unwinder_registered = 1;
>      }
>  }
> -- 
> 2.43.0


^ permalink raw reply	[relevance 0%]

* Re: [PATCH v2] Add a test for the gcore script
  @ 2024-03-20 13:28  0% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-03-20 13:28 UTC (permalink / raw)
  To: Alexandra Hájková, gdb-patches

Alexandra Hájková <ahajkova@redhat.com> writes:

> It also tests the gcore script being run without its accessible
> terminal.
>
> This test was written by Jan Kratochvil a long time ago. I modernized
> the test making it use various procs from lib/gdb.exp, reoirganising it
> and added some comments.
>
> Tested by using make check-all-boards.
>
> Co-Authored-By: Jan Kratochvil
> ---
> v2: - cosmetics
>     - Added Jan Kratochvil as the Co-Author
>     - added asserts
>     - added more comments
>     - removed unnecessary code
>
>  gdb/testsuite/gdb.base/gcorebg.c   | 68 +++++++++++++++++++++++++
>  gdb/testsuite/gdb.base/gcorebg.exp | 81 ++++++++++++++++++++++++++++++
>  gdb/testsuite/lib/gdb.exp          | 17 +++++++
>  3 files changed, 166 insertions(+)
>  create mode 100644 gdb/testsuite/gdb.base/gcorebg.c
>  create mode 100644 gdb/testsuite/gdb.base/gcorebg.exp
>
> diff --git a/gdb/testsuite/gdb.base/gcorebg.c b/gdb/testsuite/gdb.base/gcorebg.c
> new file mode 100644
> index 00000000000..0d5168c63ad
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/gcorebg.c
> @@ -0,0 +1,68 @@
> +/* Copyright 2007-2024 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <signal.h>
> +#include <string.h>
> +#include <assert.h>
> +
> +int
> +main (int argc, char **argv)
> +{
> +  pid_t pid = 0;
> +  pid_t ppid;
> +  char buf[1024*2 + 500];
> +  int gotint, res;
> +
> +  if (argc != 4)
> +    {
> +      fprintf (stderr, "Syntax: %s {standard|detached} <gcore command> <core output file>\n",
> +	       argv[0]);
> +      exit (1);
> +    }
> +
> +  pid = fork ();
> +
> +  switch (pid)
> +    {
> +      case 0:
> +	if (strcmp (argv[1], "detached") == 0)
> +	  setpgrp ();
> +	ppid = getppid ();
> +	gotint = snprintf (buf, sizeof (buf), "sh %s -o %s %d", argv[2], argv[3], (int) ppid);
> +	assert (gotint < sizeof (buf));
> +	res = system (buf);
> +	assert (res != -1);
> +	fprintf (stderr, "Killing parent PID %d\n", ppid);
> +	kill (ppid, SIGTERM);
> +	break;
> +
> +      case -1:
> +	perror ("fork err\n");
> +	exit (1);
> +	break;
> +
> +      default:
> +	fprintf (stderr, "Sleeping as PID %d\n", getpid ());
> +	/* Wait here until the child is done with gcore-ing us.  If things go right,
> +	   the child kills us with SIGTERM before this sleep returns.  */
> +	sleep (60);
> +    }
> +
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.base/gcorebg.exp b/gdb/testsuite/gdb.base/gcorebg.exp
> new file mode 100644
> index 00000000000..bcfbe994c9e
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/gcorebg.exp
> @@ -0,0 +1,81 @@
> +# Copyright 2007-2024 Free Software Foundation, Inc.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +#
> +# This is a test for the gcore script (not the gcore command form
> +# inside GDB).  It also tests the gcore script being run without its
> +# accessible terminal.
> +
> +standard_testfile
> +require {!is_remote host}
> +require {!is_remote target}
> +require has_gcore_script
> +
> +set corefile [standard_output_file ${testfile}.core]
> +
> +if {[build_executable "failed to build" $testfile ${srcfile}] == -1 } {
> +     return -1
> +}
> +
> +# Cleanup.
> +
> +proc core_clean {} {
> +    global corefile
> +
> +    foreach file [glob -nocomplain [join [list $corefile *] ""]] {
> +	verbose "Delete file $file" 1
> +	remote_file target delete $file
> +    }
> +}
> +core_clean
> +
> +# Generate the core file.
> +proc test_body { detached } {
> +    global binfile
> +    global GCORE
> +    global corefile
> +
> +    with_test_prefix "detached = $detached" {
> +	# We can't use gdb_test_multiple here because GDB is not started.
> +	set res [remote_spawn target "$binfile $detached $GCORE $corefile"]
> +	if { $res < 0 || $res == "" } {
> +	    fail "Spawning gcore"
> +	    return 1
> +	}
> +	pass "Spawned gcore"
> +
> +	remote_expect target 20 {
> +	    timeout {
> +		fail "Spawned gcore finished (timeout)"
> +		remote_exec target "kill -9 -[exp_pid -i $res]"
> +		return 1
> +	    }
> +	    "Saved corefile .*\r\nKilling parent PID " {
> +		pass "Spawned gcore finished"
> +	    }
> +	}
> +
> +	gdb_assert {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} "Core file generated by gcore"
> +	core_clean
> +    }
> +}
> +
> +# First a general gcore script spawn with its controlling terminal available.
> +
> +test_body standard
> +
> +# And now gcore script spawn without its controlling terminal available.
> +# It is spawned through `gcorebg.c' using setpgrp ().
> +
> +test_body detached
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 9a906f0f349..7943fcbbe74 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -146,6 +146,23 @@ load_lib gdb-utils.exp
>  load_lib memory.exp
>  load_lib check-test-names.exp
>  
> +# The path to the GCORE script to test.
> +global GCORE
> +if ![info exists GCORE] {
> +    set GCORE [findfile $base_dir/../../gcore]

This isn't going to find the gcore script in the build tree.  For that
you would need:

  set GCORE [findfile $base_dir/../../gdb/gcore]

instead what you have will just result in GCORE being set to 'gcore', so
we'll end up testing with whatever version of gcore happens to be
installed on the machine, which is likely not what we want (be default).

> +} else {
> +    set GCORE ""
> +}

Setting this means that we can't do:

  make check-gdb TESTS="..." RUNTESTFLAGS="GCORE=/path/to/gcore"

So I think this should be dropped.

> +verbose "using GCORE = $GCORE" 2
> +
> +proc has_gcore_script {} {

This proc should have a comment before it.

However, if you fix the above and start testing the local gcore script,
then you're going to spot a slightly bigger issue.  When you run gcore
it will correctly find the locally built gdb executable, but it doesn't
pass the --data-directory option, so we end up with a bunch of errors
from starting GDB.  Now this doesn't actually cause any FAILs from your
test, but I think we need to consider how to address this.

I don't have a specific plan in mind, but I do have a couple of ideas.

We could add a --data-directory=.... line to the built gcore script
file, like:

    "$binary_path/gdb" </dev/null \
        --data-directory "$binary_path/data-directory" \
        ... etc ...

but we'd then need to remove this before we actually installed
gcore, I'm not sure this is really an "approved" technique or not, so
this might not be well received.

We could add an option to the gcore script which would allow us to
override the data-directory setting, then instead of passing
--data-directory based on the binary we could use the actual real data
directory that GDB would use (i.e. the value of --with-gdb-datadir
configure option), but then we'd need to make sure that this directory
was relocatable in the same way that GDB uses this value, and that all
gets a little messy.

So maybe we add a data-directory option to the gcore script which is
only passed to GDB in the event that the option is specified.  This
seems much easier than the previous choice.

Or maybe we add a mechanism, either a command line option, or an
environment variable that allows the complete GDB command, including
options, to be overridden, then the test framework can just use that?

Or .... maybe there's something else that we could do?

Anyway, I think we need to figure this out before this test can be
merged.

Thanks,
Andrew



> +    if { $::GCORE != "" } {
> +	return 1
> +    } else {
> +	return 0
> +    }
> +}
> +
>  # The path to the GDB binary to test.
>  global GDB
>  
> -- 
> 2.43.0


^ permalink raw reply	[relevance 0%]

* Re: [PATCH] [gdb] Further fix "value is not available" with debug frame
  @ 2024-03-19  9:31  0% ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-03-19  9:31 UTC (permalink / raw)
  To: gdb-patches

On 3/2/24 08:26, Tom de Vries wrote:
> In commit 2aaba744467 ("[gdb] Fix "value is not available" with debug frame")
> I fixed a case in frame_unwind_register_value where using "set debug frame on"
> caused an "info frame" command to abort, reporting a "value is not available"
> error, due to the tpidruro register being unavailable.
> 
> Subsequently, commit bbb12eb9c84 ("gdb/arm: Remove tpidruro register from
> non-FreeBSD target descriptions") removed the unavailable register, which
> caused a progression on test-case gdb.base/inline-frame-cycle-unwind.exp.
> 
> While investigating the progression (see PR python/31437), I found that the
> "debug frame" output of the test-case (when reverting commit bbb12eb9c84)
> showed a smilar problem:
> ...
> Python Exception <class 'gdb.error'>: value is not available^M
> ...
> that was absent without "debug frame".
> 
> Fix this likewise in fetch_lazy_register, and update the test-case to check
> for the exception.
> 
> Furthermore, I realized that there's both value::entirely_available and
> value::entirely_unavailable, and that commit 2aaba744467 handled the case
> of !entirely_available by printing unavailable.
> 
> Instead, print:
> - "unavailable" for entirely_unavailable, and
> - "partly unavailable" for !entirely_unavailable && !entirely_available.
> 

Pushed.

Thanks,
- Tom

> Tested on x86_64-linux and arm-linux.
> ---
>   gdb/frame.c                                   |  8 ++++---
>   .../gdb.base/inline-frame-cycle-unwind.exp    |  7 +++++-
>   gdb/value.c                                   | 23 ++++++++++++-------
>   3 files changed, 26 insertions(+), 12 deletions(-)
> 
> diff --git a/gdb/frame.c b/gdb/frame.c
> index 5c7aae9edf4..c56655c55c1 100644
> --- a/gdb/frame.c
> +++ b/gdb/frame.c
> @@ -1315,9 +1315,7 @@ frame_unwind_register_value (const frame_info_ptr &next_frame, int regnum)
>   
>   	  if (value->lazy ())
>   	    gdb_printf (&debug_file, " lazy");
> -	  else if (!value->entirely_available ())
> -	    gdb_printf (&debug_file, " unavailable");
> -	  else
> +	  else if (value->entirely_available ())
>   	    {
>   	      int i;
>   	      gdb::array_view<const gdb_byte> buf = value->contents ();
> @@ -1328,6 +1326,10 @@ frame_unwind_register_value (const frame_info_ptr &next_frame, int regnum)
>   		gdb_printf (&debug_file, "%02x", buf[i]);
>   	      gdb_printf (&debug_file, "]");
>   	    }
> +	  else if (value->entirely_unavailable ())
> +	    gdb_printf (&debug_file, " unavailable");
> +	  else
> +	    gdb_printf (&debug_file, " partly unavailable");
>   	}
>   
>         frame_debug_printf ("%s", debug_file.c_str ());
> diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
> index 82632757f13..85e3cc32f0e 100644
> --- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
> +++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
> @@ -131,9 +131,14 @@ with_test_prefix "cycle at level 1" {
>   gdb_test "maint flush register-cache" \
>       "Register cache flushed\\." ""
>   gdb_test_no_output "set debug frame 1"
> +set ok 1
>   gdb_test_multiple "bt" "backtrace with debugging on" {
>       -re "^$gdb_prompt $" {
> -	pass $gdb_test_name
> +	gdb_assert { $ok } $gdb_test_name
> +    }
> +    -re "Python Exception <class 'gdb.error'>: \[^\r\n\]*\r\n" {
> +	set ok 0
> +	exp_continue
>       }
>       -re "\[^\r\n\]+\r\n" {
>   	exp_continue
> diff --git a/gdb/value.c b/gdb/value.c
> index a2b2721d183..7ddfeb7c728 100644
> --- a/gdb/value.c
> +++ b/gdb/value.c
> @@ -4014,9 +4014,6 @@ value::fetch_lazy_register ()
>   	}
>         else
>   	{
> -	  int i;
> -	  gdb::array_view<const gdb_byte> buf = new_val->contents ();
> -
>   	  if (new_val->lval () == lval_register)
>   	    gdb_printf (&debug_file, " register=%d", new_val->regnum ());
>   	  else if (new_val->lval () == lval_memory)
> @@ -4026,11 +4023,21 @@ value::fetch_lazy_register ()
>   	  else
>   	    gdb_printf (&debug_file, " computed");
>   
> -	  gdb_printf (&debug_file, " bytes=");
> -	  gdb_printf (&debug_file, "[");
> -	  for (i = 0; i < register_size (gdbarch, regnum); i++)
> -	    gdb_printf (&debug_file, "%02x", buf[i]);
> -	  gdb_printf (&debug_file, "]");
> +	  if (new_val->entirely_available ())
> +	    {
> +	      int i;
> +	      gdb::array_view<const gdb_byte> buf = new_val->contents ();
> +
> +	      gdb_printf (&debug_file, " bytes=");
> +	      gdb_printf (&debug_file, "[");
> +	      for (i = 0; i < register_size (gdbarch, regnum); i++)
> +		gdb_printf (&debug_file, "%02x", buf[i]);
> +	      gdb_printf (&debug_file, "]");
> +	    }
> +	  else if (new_val->entirely_unavailable ())
> +	    gdb_printf (&debug_file, " unavailable");
> +	  else
> +	    gdb_printf (&debug_file, " partly unavailable");
>   	}
>   
>         frame_debug_printf ("%s", debug_file.c_str ());
> 
> base-commit: 5c97cb1c80994462632ba7c62a54a3fbecaff2ca


^ permalink raw reply	[relevance 0%]

* Re: [RFC][PATCH 1/1] gdb: Support embedded source in DWARF
  @ 2024-03-18 21:18  0%     ` Will Hawkins
  0 siblings, 0 replies; 200+ results
From: Will Hawkins @ 2024-03-18 21:18 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Mon, Mar 18, 2024 at 1:24 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Will" == Will Hawkins <hawkinsw@obs.cr> writes:
>
> Will> While DW_LNCT_source is not yet finalized in the DWARF standard
> Will> (https://dwarfstd.org/issues/180201.1.html), LLVM does emit it.
>
> Will> This patch adds support for it in gdb.
>
> Thanks for the patch.
>
> Will> ChangeLog:
>
> gdb doesn't use ChangeLogs any more, so you can delete this part.

Tom,

Thank you so much for the comments! I am glad to see that (based on
the volume of comments) I am on the right track. I really appreciate
you taking the time to respond!

And, yes, I *thought* that gdb had "retired" ChangeLogs, but I wasn't
sure. I was trying to be as "correct" as possible. I will definitely
drop it in v2!

>
> Will> +   if (fe.source)
> Will> +     sf->symtab->source = cu->per_objfile->objfile->intern (fe.source);
>
> IIUC the 'source' here is the full text of the source code.
>
> In this case you don't want to use intern.  That will make a copy of the
> text.  Instead, because the section data is read-in and not unmapped or
> freed until the objfile is destroyed, you can just use the pointer
> directly.

Thank you for confirming! I thought that was the case (that the
lifetime of the objfile outlives the symtab) but I wasn't sure.

>
> Will> +/* Open an embedded  source file given a symtab S.  Returns a file descriptor
> Will> +   or negative errno for error.  */
> Will> +
> Will> +scoped_fd
> Will> +open_embedded_source(struct symtab *s,
> Will> +              gdb::unique_xmalloc_ptr<char> *fullname)
> Will> +{
>
> I think some other refactoring should be done so that gdb doesn't have
> to write the source to a file and then re-read it.
>
> Some kind of abstraction here would be appropriate.

Absolutely! I will do that!

>
> Will> --- a/gdb/symtab.h
> Will> +++ b/gdb/symtab.h
> Will> @@ -1755,6 +1755,8 @@ struct symtab
>
> Will>    const char *filename;
>
> Will> +  const char *source;
>
> This line could use an explanatory comment.

I *thought* I added one -- sorry!

>
> Will> diff --git a/include/dwarf2.h b/include/dwarf2.h
> Will> index b3d3731ee83..abe0359926b 100644
> Will> --- a/include/dwarf2.h
> Will> +++ b/include/dwarf2.h
> Will> @@ -288,7 +288,9 @@ enum dwarf_line_number_content_type
> Will>      DW_LNCT_timestamp = 0x3,
> Will>      DW_LNCT_size = 0x4,
> Will>      DW_LNCT_MD5 = 0x5,
> Will> +    DW_LNCT_SOURCE = 0x6,
> Will>      DW_LNCT_lo_user = 0x2000,
> Will> +    DW_LNCT_llvm_SOURCE = 0x2001,
>
> This should probably use "LLVM" and not "llvm".
> Also for vendor extensions we like to have some kind of comment or
> documentation explaining what it is about -- in the more distant past
> this wasn't done and as a result there are some mystery extensions.

You got it!

>
> Also I would not assign DW_LNCT_SOURCE until DWARF officially blesses
> it.
>

Will do!!

Thank you, again, Tom!

Will



> Tom

^ permalink raw reply	[relevance 0%]

* [PATCH] Rewrite gdb_bfd_error_handler
@ 2024-03-14 18:49  3% Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-03-14 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch rewrites gdb_bfd_error_handler to use 'bfd_print_error' to
generate the text of the warning, and then emits it using 'warning'.
The current code in the tree is a bit wrong because it may do the
wrong thing when BFD uses ones of its printf extensions.

This also adds locking to increment_bfd_error_count.  This is
important now that some BFD operations can be done on worker threads.

This approach makes it simpler for worker threads to intercept any
messages.

Regression tested on x86-64 Fedora 38.
---
 gdb/gdb_bfd.c | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 4df1e66a388..b579ba0cc92 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -1180,15 +1180,30 @@ get_bfd_inferior_data (struct inferior *inf)
    count.  */
 
 static unsigned long
-increment_bfd_error_count (std::string str)
+increment_bfd_error_count (const std::string &str)
 {
+#if CXX_STD_THREAD
+  std::lock_guard<std::recursive_mutex> guard (gdb_bfd_mutex);
+#endif
   struct bfd_inferior_data *bid = get_bfd_inferior_data (current_inferior ());
 
   auto &map = bid->bfd_error_string_counts;
-  return ++map[std::move (str)];
+  return ++map[str];
 }
 
-static bfd_error_handler_type default_bfd_error_handler;
+/* A print callback for bfd_print_error.  */
+
+static int
+print_error_callback (void *stream, const char *fmt, ...)
+{
+  string_file *file = (string_file *) stream;
+  size_t in_size = file->size ();
+  va_list ap;
+  va_start (ap, fmt);
+  file->vprintf (fmt, ap);
+  va_end (ap);
+  return file->size () - in_size;
+}
 
 /* Define a BFD error handler which will suppress the printing of
    messages which have been printed once already.  This is done on a
@@ -1197,20 +1212,14 @@ static bfd_error_handler_type default_bfd_error_handler;
 static void ATTRIBUTE_PRINTF (1, 0)
 gdb_bfd_error_handler (const char *fmt, va_list ap)
 {
-  va_list ap_copy;
-
-  va_copy(ap_copy, ap);
-  const std::string str = string_vprintf (fmt, ap_copy);
-  va_end (ap_copy);
+  string_file output;
+  bfd_print_error (print_error_callback, &output, fmt, ap);
+  std::string str = output.release ();
 
-  if (increment_bfd_error_count (std::move (str)) > 1)
+  if (increment_bfd_error_count (str) > 1)
     return;
 
-  /* We must call the BFD mechanism for printing format strings since
-     it supports additional format specifiers that GDB's vwarning() doesn't
-     recognize.  It also outputs additional text, i.e. "BFD: ", which
-     makes it clear that it's a BFD warning/error.  */
-  (*default_bfd_error_handler) (fmt, ap);
+  warning ("%s", str.c_str ());
 }
 
 /* See gdb_bfd.h.  */
@@ -1263,5 +1272,5 @@ When non-zero, bfd cache specific debugging is enabled."),
 			   &setdebuglist, &showdebuglist);
 
   /* Hook the BFD error/warning handler to limit amount of output.  */
-  default_bfd_error_handler = bfd_set_error_handler (gdb_bfd_error_handler);
+  bfd_set_error_handler (gdb_bfd_error_handler);
 }
-- 
2.43.0


^ permalink raw reply	[relevance 3%]

* Re: [PATCH] gdb/dwarf2: Check for missing abbrev
  @ 2024-03-14 13:56  6%     ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-03-14 13:56 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Aaron Merey, gdb-patches



On 2024-03-14 08:31, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
> 
> Simon> However, I'd like if we could analyze the problem a bit further to
> Simon> understand more precisely what happens, just to be sure that there isn't
> Simon> a more fundamental problem and we're not just papering over the problem.
> 
> The issue is corrupt DWARF -- the DIE specifies an abbrev that doesn't exist.

If it was an abbrev number that didn't exist, then peek_die_abbrev would
throw here:

  const abbrev_info *abbrev
    = reader.abbrev_table->lookup_abbrev (abbrev_number);
  if (!abbrev)
    {
      error (_("Dwarf Error: Could not find abbrev number %d in %s"
	       " at offset %s [in module %s]"),
	     abbrev_number, cu->per_cu->is_debug_types ? "TU" : "CU",
	     sect_offset_str (cu->header.sect_off), bfd_get_filename (abfd));
    }

If peek_die_abbrev returns nullptr, it's because it read abbrev number 0
specifically (which normally means "end of DIE list", but is unexpected
at this particular place).  So I'm just wondering what "kind" of
corruption causes it to be 0.  The concrete case I'm worried about is
the possibility that the file is truncated and we go read an offset that
is out of our buffer's bounds.  In that case, some bounds checking
should probably be added somehwere.  If the file is not truncated and
just contains a bunch of 0s where it shouldn't because debuginfod
crashed while writing it, then just erroring out in scan_attributes
(after the peek_die_abbrev call) is fine.

> Whether erroring here is the best result is harder to say.  For example,
> would it make more sense to terminate the scanning but still install any
> symbols seen before this point?
> 
> I tend to agree that this approach is ok, though.  If the file is
> corrupt it seems fine to lose a few symbols, or maybe even the whole
> thing.

I think that erroring out is fine, certainly better than crashing.

Simon

^ permalink raw reply	[relevance 6%]

* Re: [RFC][PATCH?] fixed some segfaults and bugs in mdebug support
  @ 2024-03-13  2:09 15%   ` Zeck S
  0 siblings, 0 replies; 200+ results
From: Zeck S @ 2024-03-13  2:09 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess, tom

[-- Attachment #1: Type: text/plain, Size: 95030 bytes --]

Just checking to see if there is still interest in taking this patch. I
could split it up somehow or remove parts of it if I need to.

On Thu, Feb 15, 2024 at 8:48 PM Zeck S <zeck654321@gmail.com> wrote:

> Tried to send this a week ago, but I see somehow send email did not thread
> it correctly.
> Trying again, I think it was because the subject line was messed up.
>
> Addressed comments, adapted some core tests, fixed more bugs.
> In addition to the modified tests, I specifically also got
> gdb.base/relocate.exp working to sort out some problems.
>
> As always, glad to address feedback, and thanks for the patience.
>
> I reverted some of my code around parse_lines addresses.
> The Procedure Descriptor Record format is weird.
> The File Descriptor Record has the final correct address
> of the LOWEST PDR, only. This is used as a base address
> for a kind of janky fixup/relocation system.
> I suspect originally the PDR addresses were directly useful in simpler
> formats.
>
> Based on comments in bfd ecofflink and documentation about something
> similar in
> "MIPS Mdebug Debugging Information" by David Anderson
> that describes HDRR offsets as offsets from the beginning of the a.out
> as a "design mistake" I think some compilers
> set the PDR address to a location in an object file.
>
> This means there's basically a garbage offset added to all the PDRs.
> So all PDRs have their addresses subtracted from the lowest to kind
> treat it as 0, and then the lowest PDRs REAL correct address
> is used from the FDR, as an offset.
>
> IDO actually always outputs the lowest PDR's address as 0
> so subtracting it out does nothing, but hurts nothing.
>
> I can find no real documentation about this.
>
> I did find precedent for what my reverted code was doing in
> section 5.3.4.1 of ""Tru64 UNIX Object File and Symbol Table Format
> Specification"
> but after I figured out what the original code was doing I
> reverted those changes to distrub the code less.
>
> ---
>  gdb/mdebugread.c                          | 230 ++++--
>  gdb/testsuite/boards/qemu-user.exp        | 267 +++++++
>  gdb/testsuite/gdb.mdebug/README           |  67 ++
>  gdb/testsuite/gdb.mdebug/break.c          |  92 +++
>  gdb/testsuite/gdb.mdebug/break.exp        | 921 ++++++++++++++++++++++
>  gdb/testsuite/gdb.mdebug/break1.c         |  59 ++
>  gdb/testsuite/gdb.mdebug/info-types-c.exp |  67 ++
>  gdb/testsuite/gdb.mdebug/info-types.c     | 116 +++
>  8 files changed, 1770 insertions(+), 49 deletions(-)
>  create mode 100644 gdb/testsuite/boards/qemu-user.exp
>  create mode 100644 gdb/testsuite/gdb.mdebug/README
>  create mode 100644 gdb/testsuite/gdb.mdebug/break.c
>  create mode 100644 gdb/testsuite/gdb.mdebug/break.exp
>  create mode 100644 gdb/testsuite/gdb.mdebug/break1.c
>  create mode 100644 gdb/testsuite/gdb.mdebug/info-types-c.exp
>  create mode 100644 gdb/testsuite/gdb.mdebug/info-types.c
>
> diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
> index cd6638224e7..0118507a8f3 100644
> --- a/gdb/mdebugread.c
> +++ b/gdb/mdebugread.c
> @@ -237,7 +237,7 @@ static struct type *new_type (char *);
>  enum block_type { FUNCTION_BLOCK, NON_FUNCTION_BLOCK };
>
>  static struct block *new_block (struct objfile *objfile,
> -                               enum block_type, enum language);
> +                               enum block_type, enum language, bool
> is_global);
>
>  static struct compunit_symtab *new_symtab (const char *, int, struct
> objfile *);
>
> @@ -246,7 +246,7 @@ static struct linetable *new_linetable (int);
>  static struct blockvector *new_bvect (int);
>
>  static struct type *parse_type (int, union aux_ext *, unsigned int, int *,
> -                               int, const char *);
> +                               int, const char *, bool);
>
>  static struct symbol *mylookup_symbol (const char *, const struct block *,
>                                        domain_enum, enum address_class);
> @@ -572,7 +572,7 @@ add_data_symbol (SYMR *sh, union aux_ext *ax, int
> bigend,
>        || sh->sc == scNil || sh->index == indexNil)
>      s->set_type (builtin_type (objfile)->nodebug_data_symbol);
>    else
> -    s->set_type (parse_type (cur_fd, ax, sh->index, 0, bigend, name));
> +    s->set_type (parse_type (cur_fd, ax, sh->index, 0, bigend, name,
> false));
>    /* Value of a data symbol is its memory address.  */
>  }
>
> @@ -624,8 +624,17 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char
> *ext_sh, int bigend,
>        break;
>      }
>
> -  if (section_index != -1)
> -    sh->value += section_offsets[section_index];
> +  if (section_index != -1) {
> +       int offset = section_offsets[section_index];
> +    if ((bfd_get_file_flags (objfile->obfd.get ()) & (EXEC_P | DYNAMIC))
> == 0)
> +    {
> +         /* This is attempting to detect .o files.
> +            Their sections are relocated in symfile.c
> default_symfile_offsets
> +            but section_offsets are set to 0 there and the offset is put
> in the vma.   */
> +         offset +=
> objfile->sections_start[section_index].the_bfd_section->vma;
> +    }
> +       sh->value += offset;
> +  }
>
>    switch (sh->st)
>      {
> @@ -705,7 +714,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char
> *ext_sh, int bigend,
>           break;
>         }
>        s->set_value_longest (svalue);
> -      s->set_type (parse_type (cur_fd, ax, sh->index, 0, bigend, name));
> +      s->set_type (parse_type (cur_fd, ax, sh->index, 0, bigend, name,
> false));
>        add_symbol (s, top_stack->cur_st, top_stack->cur_block);
>        break;
>
> @@ -761,7 +770,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char
> *ext_sh, int bigend,
>         t = builtin_type (objfile)->builtin_int;
>        else
>         {
> -         t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name);
> +         t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name,
> false);
>           if (strcmp (name, "malloc") == 0
>               && t->code () == TYPE_CODE_VOID)
>             {
> @@ -805,7 +814,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char
> *ext_sh, int bigend,
>         s->type ()->set_is_prototyped (true);
>
>        /* Create and enter a new lexical context.  */
> -      b = new_block (objfile, FUNCTION_BLOCK, s->language ());
> +      b = new_block (objfile, FUNCTION_BLOCK, s->language (), false);
>        s->set_value_block (b);
>        b->set_function (s);
>        b->set_start (sh->value);
> @@ -1135,7 +1144,13 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char
> *ext_sh, int bigend,
>         }
>
>        top_stack->blocktype = stBlock;
> -      b = new_block (objfile, NON_FUNCTION_BLOCK, psymtab_language);
> +
> +         /* Using psymtab_langauge fixes commit 76fc0f62138e.
> +            This file does not use buildsym-lecacy.
> +            start_compunit_symtab () is never called.
> +            get_current_subfile () will crash because
> +            buildsym_compunit has never been initialized. */
> +      b = new_block (objfile, NON_FUNCTION_BLOCK, psymtab_language,
> false);
>        b->set_start (sh->value + top_stack->procadr);
>        b->set_superblock (top_stack->cur_block);
>        top_stack->cur_block = b;
> @@ -1247,7 +1262,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char
> *ext_sh, int bigend,
>         f->set_loc_bitpos (sh->value);
>         bitsize = 0;
>         f->set_type (parse_type (cur_fd, ax, sh->index, &bitsize, bigend,
> -                                name));
> +                                name, false));
>         f->set_bitsize (bitsize);
>        }
>        break;
> @@ -1269,7 +1284,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char
> *ext_sh, int bigend,
>        pend = is_pending_symbol (cur_fdr, ext_sh);
>        if (pend == NULL)
>         {
> -         t = parse_type (cur_fd, ax, sh->index, NULL, bigend, name);
> +         t = parse_type (cur_fd, ax, sh->index, NULL, bigend, name, true);
>           add_pending (cur_fdr, ext_sh, t);
>         }
>        else
> @@ -1382,7 +1397,7 @@ basic_type (int bt, struct objfile *objfile)
>    if (map_bt[bt])
>      return map_bt[bt];
>
> -  type_allocator alloc (objfile, get_current_subfile ()->language);
> +  type_allocator alloc (objfile, psymtab_language);
>
>    switch (bt)
>      {
> @@ -1514,7 +1529,7 @@ basic_type (int bt, struct objfile *objfile)
>
>  static struct type *
>  parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
> -           int bigend, const char *sym_name)
> +           int bigend, const char *sym_name, bool is_stTypedef)
>  {
>    TIR t[1];
>    struct type *tp = 0;
> @@ -1571,7 +1586,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int
> aux_index, int *bs,
>         }
>      }
>
> -  type_allocator alloc (mdebugread_objfile, get_current_subfile
> ()->language);
> +  type_allocator alloc (mdebugread_objfile, psymtab_language);
>
>    /* Move on to next aux.  */
>    ax++;
> @@ -1628,7 +1643,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int
> aux_index, int *bs,
>        xref_fh = get_rfd (fd, rf);
>        xref_fd = xref_fh - debug_info->fdr;
>        tp = parse_type (xref_fd, debug_info->external_aux +
> xref_fh->iauxBase,
> -                   rn->index, NULL, xref_fh->fBigendian, sym_name);
> +                   rn->index, NULL, xref_fh->fBigendian, sym_name, false);
>      }
>
>    /* All these types really point to some (common) MIPS type
> @@ -1785,6 +1800,13 @@ parse_type (int fd, union aux_ext *ax, unsigned int
> aux_index, int *bs,
>    if (t->continued)
>      complaint (_("illegal TIR continued for %s"), sym_name);
>
> +  if (is_stTypedef)
> +    {
> +       struct type *wrap = alloc.new_type (TYPE_CODE_TYPEDEF, 0,
> sym_name);
> +       wrap->set_target_type(tp);
> +       tp = wrap;
> +    }
> +
>    return tp;
>  }
>
> @@ -1839,7 +1861,7 @@ upgrade_type (int fd, struct type **tpp, int tq,
> union aux_ext *ax, int bigend,
>
>        indx = parse_type (fh - debug_info->fdr,
>                          debug_info->external_aux + fh->iauxBase,
> -                        id, NULL, bigend, sym_name);
> +                        id, NULL, bigend, sym_name, false);
>
>        /* The bounds type should be an integer type, but might be anything
>          else due to corrupt aux entries.  */
> @@ -2155,7 +2177,7 @@ parse_external (EXTR *es, int bigend, const
> section_offsets &section_offsets,
>
>  static void
>  parse_lines (FDR *fh, PDR *pr, struct linetable *lt, int maxlines,
> -            CORE_ADDR lowest_pdr_addr)
> +                          CORE_ADDR textlow, CORE_ADDR lowest_pdr_addr)
>  {
>    unsigned char *base;
>    int j, k;
> @@ -2169,7 +2191,6 @@ parse_lines (FDR *fh, PDR *pr, struct linetable *lt,
> int maxlines,
>    for (j = 0; j < fh->cpd; j++, pr++)
>      {
>        CORE_ADDR l;
> -      CORE_ADDR adr;
>        unsigned char *halt;
>
>        /* No code for this one.  */
> @@ -2186,9 +2207,15 @@ parse_lines (FDR *fh, PDR *pr, struct linetable
> *lt, int maxlines,
>         halt = base + fh->cbLine;
>        base += pr->cbLineOffset;
>
> -      adr = pr->adr - lowest_pdr_addr;
> -
> -      l = adr >> 2;            /* in words */
> +      /* textlow is the FDR->adr, for the file containing these PDRs.
> +         FDR->adr is the absolute address of the lowest PDR.
> +         PDR->adr's themselves, are relative offsets.
> +         The PDR->adr's may start at 0, or they could have an offset
> +         based on the PDRs position in an object file.
> +         This is why the lowest PDR address is subtracted
> +         from all other PDRs addresses, to subtract out the potential
> offset.
> +         See bfd/ecofflink.c comments. */
> +      l = (textlow +  pr->adr - lowest_pdr_addr) >> 2;         /* in
> words */
>        for (lineno = pr->lnLow; base < halt;)
>         {
>           count = *base & 0x0f;
> @@ -3047,28 +3074,49 @@ parse_partial_symbols (minimal_symbol_reader
> &reader,
>                        index into the namestring which indicates the
>                        debugging type symbol.  */
>
> +                       int section;
> +                       bfd_vma address;
> +
>                     switch (p[1])
>                       {
>                       case 'S':
> +                         section = SECT_OFF_DATA (objfile);
> +                         address = sh.value;
> +                       if ((bfd_get_file_flags (objfile->obfd.get ()) &
> (EXEC_P | DYNAMIC)) == 0)
> +                       {
> +                         /* This is attempting to detect .o files.
> +                            Their sections are relocated in symfile.c
> default_symfile_offsets
> +                            but section_offsets are set to 0 there and
> the offset is put in the vma.   */
> +                         address +=
> objfile->sections_start[section].the_bfd_section->vma;
> +                       }
>                         pst->add_psymbol (gdb::string_view (namestring,
>                                                             p -
> namestring),
>                                           true, VAR_DOMAIN, LOC_STATIC,
> -                                         SECT_OFF_DATA (objfile),
> +                                         section,
>                                           psymbol_placement::STATIC,
> -                                         unrelocated_addr (sh.value),
> +                                         unrelocated_addr (address),
>                                           psymtab_language,
>                                           partial_symtabs, objfile);
>                         continue;
>                       case 'G':
> +                         section = SECT_OFF_DATA (objfile);
> +                         address = sh.value;
> +                       if ((bfd_get_file_flags (objfile->obfd.get ()) &
> (EXEC_P | DYNAMIC)) == 0)
> +                       {
> +                         /* This is attempting to detect .o files.
> +                           Their sections are relocated in symfile.c
> default_symfile_offsets
> +                           but section_offsets are set to 0 there and the
> offset is put in the vma.    */
> +                         address +=
> objfile->sections_start[section].the_bfd_section->vma;
> +                       }
>                         /* The addresses in these entries are reported
>                            to be wrong.  See the code that reads 'G's
>                            for symtabs.  */
>                         pst->add_psymbol (gdb::string_view (namestring,
>                                                             p -
> namestring),
>                                           true, VAR_DOMAIN, LOC_STATIC,
> -                                         SECT_OFF_DATA (objfile),
> +                                         section,
>                                           psymbol_placement::GLOBAL,
> -                                         unrelocated_addr (sh.value),
> +                                         unrelocated_addr (address),
>                                           psymtab_language,
>                                           partial_symtabs, objfile);
>                         continue;
> @@ -3215,12 +3263,21 @@ parse_partial_symbols (minimal_symbol_reader
> &reader,
>                             function_outside_compilation_unit_complaint
>                               (copy.c_str ());
>                           }
> +                       section = SECT_OFF_TEXT (objfile);
> +                       address = sh.value;
> +                       if ((bfd_get_file_flags (objfile->obfd.get ()) &
> (EXEC_P | DYNAMIC)) == 0)
> +                       {
> +                         /* This is attempting to detect .o files.
> +                            Their sections are relocated in symfile.c
> default_symfile_offsets
> +                            but section_offsets are set to 0 there and
> the offset is put in the vma.   */
> +                         address +=
> objfile->sections_start[section].the_bfd_section->vma;
> +                       }
>                         pst->add_psymbol (gdb::string_view (namestring,
>                                                             p -
> namestring),
>                                           true, VAR_DOMAIN, LOC_BLOCK,
> -                                         SECT_OFF_TEXT (objfile),
> +                                         section,
>                                           psymbol_placement::STATIC,
> -                                         unrelocated_addr (sh.value),
> +                                         unrelocated_addr (address),
>                                           psymtab_language,
>                                           partial_symtabs, objfile);
>                         continue;
> @@ -3236,12 +3293,21 @@ parse_partial_symbols (minimal_symbol_reader
> &reader,
>                             function_outside_compilation_unit_complaint
>                               (copy.c_str ());
>                           }
> +                       section = SECT_OFF_TEXT (objfile);
> +                       address = sh.value;
> +                       if ((bfd_get_file_flags (objfile->obfd.get ()) &
> (EXEC_P | DYNAMIC)) == 0)
> +                       {
> +                         /* This is attempting to detect .o files.
> +                            Their sections are relocated in symfile.c
> default_symfile_offsets
> +                            but section_offsets are set to 0 there and
> the offset is put in the vma.   */
> +                         address +=
> objfile->sections_start[section].the_bfd_section->vma;
> +                       }
>                         pst->add_psymbol (gdb::string_view (namestring,
>                                                             p -
> namestring),
>                                           true, VAR_DOMAIN, LOC_BLOCK,
> -                                         SECT_OFF_TEXT (objfile),
> +                                         section,
>                                           psymbol_placement::GLOBAL,
> -                                         unrelocated_addr (sh.value),
> +                                         unrelocated_addr (address),
>                                           psymtab_language,
>                                           partial_symtabs, objfile);
>                         continue;
> @@ -3419,6 +3485,9 @@ parse_partial_symbols (minimal_symbol_reader &reader,
>                   break;
>                 }
>
> +               bfd_vma address;
> +               /* some symbols don't use the above section */
> +               int section_override;
>               switch (sh.st)
>                 {
>                   unrelocated_addr high;
> @@ -3426,9 +3495,18 @@ parse_partial_symbols (minimal_symbol_reader
> &reader,
>                   int new_sdx;
>
>                 case stStaticProc:
> -                 reader.record_with_info (sym_name, minsym_value,
> +                   section_override = SECT_OFF_TEXT (objfile);
> +                       address = (bfd_vma)minsym_value;
> +                       if ((bfd_get_file_flags (objfile->obfd.get ()) &
> (EXEC_P | DYNAMIC)) == 0)
> +                       {
> +                         /* This is attempting to detect .o files.
> +                            Their sections are relocated in symfile.c
> default_symfile_offsets
> +                            but section_offsets are set to 0 there and
> the offset is put in the vma.   */
> +                         address +=
> objfile->sections_start[section_override].the_bfd_section->vma;
> +                       }
> +                 reader.record_with_info (sym_name,
> (unrelocated_addr)address,
>                                            mst_file_text,
> -                                          SECT_OFF_TEXT (objfile));
> +                                          section_override);
>
>                   /* FALLTHROUGH */
>
> @@ -3476,12 +3554,21 @@ parse_partial_symbols (minimal_symbol_reader
> &reader,
>                      still able to find the PROGRAM name via the partial
>                      symbol table, and the MAIN__ symbol via the minimal
>                      symbol table.  */
> +
> +                 address = sh.value;
> +                 if ((bfd_get_file_flags (objfile->obfd.get ()) & (EXEC_P
> | DYNAMIC)) == 0)
> +                 {
> +                        /* This is attempting to detect .o files.
> +                        Their sections are relocated in symfile.c
> default_symfile_offsets
> +                        but section_offsets are set to 0 there and the
> offset is put in the vma.       */
> +                        address +=
> objfile->sections_start[section].the_bfd_section->vma;
> +                 }
>                   if (sh.st == stProc)
>                     pst->add_psymbol (sym_name, true,
>                                       VAR_DOMAIN, LOC_BLOCK,
>                                       section,
>                                       psymbol_placement::GLOBAL,
> -                                     unrelocated_addr (sh.value),
> +                                     unrelocated_addr (address),
>                                       psymtab_language,
>                                       partial_symtabs, objfile);
>                   else
> @@ -3489,7 +3576,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
>                                       VAR_DOMAIN, LOC_BLOCK,
>                                       section,
>                                       psymbol_placement::STATIC,
> -                                     unrelocated_addr (sh.value),
> +                                     unrelocated_addr (address),
>                                       psymtab_language,
>                                       partial_symtabs, objfile);
>
> @@ -3517,13 +3604,36 @@ parse_partial_symbols (minimal_symbol_reader
> &reader,
>
>                 case stStatic:  /* Variable */
>                   if (SC_IS_DATA (sh.sc))
> -                   reader.record_with_info (sym_name, minsym_value,
> +                 {
> +                       section_override = SECT_OFF_DATA (objfile);
> +                       address = 0;
> +                       if ((bfd_get_file_flags (objfile->obfd.get ()) &
> (EXEC_P | DYNAMIC)) == 0)
> +                       {
> +                         /* This is attempting to detect .o files.
> +                            Their sections are relocated in symfile.c
> default_symfile_offsets
> +                            but section_offsets are set to 0 there and
> the offset is put in the vma.   */
> +                            address +=
> objfile->sections_start[section_override].the_bfd_section->vma;
> +                       }
> +                   reader.record_with_info (sym_name,
> (unrelocated_addr)(((bfd_vma)minsym_value + address)),
>                                              mst_file_data,
> -                                            SECT_OFF_DATA (objfile));
> +                                            section_override);
> +                 }
>                   else
> -                   reader.record_with_info (sym_name, minsym_value,
> +                 {
> +                       section_override = SECT_OFF_BSS (objfile);
> +                       address = 0;
> +                       if ((bfd_get_file_flags (objfile->obfd.get ()) &
> (EXEC_P | DYNAMIC)) == 0)
> +                       {
> +                         /* This is attempting to detect .o files.
> +                            Their sections are relocated in symfile.c
> default_symfile_offsets
> +                            but section_offsets are set to 0 there and
> the offset is put in the vma.   */
> +                         address +=
> objfile->sections_start[section_override].the_bfd_section->vma;
> +                       }
> +                   reader.record_with_info (sym_name,
> (unrelocated_addr)(((bfd_vma)minsym_value + address)),
>                                              mst_file_bss,
> -                                            SECT_OFF_BSS (objfile));
> +                                            section_override);
> +                 }
> +
>                   theclass = LOC_STATIC;
>                   break;
>
> @@ -3596,11 +3706,19 @@ parse_partial_symbols (minimal_symbol_reader
> &reader,
>                   cur_sdx++;
>                   continue;
>                 }
> +                       address = sh.value;
> +                       if ((bfd_get_file_flags (objfile->obfd.get ()) &
> (EXEC_P | DYNAMIC)) == 0)
> +                       {
> +                         /* This is attempting to detect .o files.
> +                            Their sections are relocated in symfile.c
> default_symfile_offsets
> +                            but section_offsets are set to 0 there and
> the offset is put in the vma.   */
> +                         address +=
> objfile->sections_start[section].the_bfd_section->vma;
> +                       }
>               /* Use this gdb symbol.  */
>               pst->add_psymbol (sym_name, true,
>                                 VAR_DOMAIN, theclass, section,
>                                 psymbol_placement::STATIC,
> -                               unrelocated_addr (sh.value),
> +                               unrelocated_addr (address),
>                                 psymtab_language,
>                                 partial_symtabs, objfile);
>             skip:
> @@ -3676,12 +3794,20 @@ parse_partial_symbols (minimal_symbol_reader
> &reader,
>                   theclass = LOC_STATIC;
>                   break;
>                 }
> +                 bfd_vma address = svalue;
>               char *sym_name = debug_info->ssext + psh->iss;
> +                       if ((bfd_get_file_flags (objfile->obfd.get ()) &
> (EXEC_P | DYNAMIC)) == 0)
> +                       {
> +                         /* This is attempting to detect .o files.
> +                            Their sections are relocated in symfile.c
> default_symfile_offsets
> +                            but section_offsets are set to 0 there and
> the offset is put in the vma.   */
> +                         address +=
> objfile->sections_start[section].the_bfd_section->vma;
> +                       }
>               pst->add_psymbol (sym_name, true,
>                                 VAR_DOMAIN, theclass,
>                                 section,
>                                 psymbol_placement::GLOBAL,
> -                               unrelocated_addr (svalue),
> +                               unrelocated_addr (address),
>                                 psymtab_language,
>                                 partial_symtabs, objfile);
>             }
> @@ -4163,7 +4289,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct
> objfile *objfile)
>                 }
>
>               parse_lines (fh, pr_block.data (), lines, maxlines,
> -                          lowest_pdr_addr);
> +                          (CORE_ADDR) pst->unrelocated_text_low (),
> lowest_pdr_addr);
>               if (lines->nitems < fh->cline)
>                 lines = shrink_linetable (lines);
>
> @@ -4291,7 +4417,7 @@ cross_ref (int fd, union aux_ext *ax, struct type
> **tpp,
>        rf = rn->rfd;
>      }
>
> -  type_allocator alloc (mdebugread_objfile, get_current_subfile
> ()->language);
> +  type_allocator alloc (mdebugread_objfile, psymtab_language);
>
>    /* mips cc uses a rf of -1 for opaque struct definitions.
>       Set TYPE_STUB for these types so that check_typedef will
> @@ -4412,7 +4538,8 @@ cross_ref (int fd, union aux_ext *ax, struct type
> **tpp,
>                                  sh.index,
>                                  NULL,
>                                  fh->fBigendian,
> -                                debug_info->ss + fh->issBase + sh.iss);
> +                                debug_info->ss + fh->issBase + sh.iss,
> +                                sh.st == stTypedef);
>               add_pending (fh, esh, *tpp);
>               break;
>
> @@ -4438,7 +4565,8 @@ cross_ref (int fd, union aux_ext *ax, struct type
> **tpp,
>                              sh.index,
>                              NULL,
>                              fh->fBigendian,
> -                            debug_info->ss + fh->issBase + sh.iss);
> +                            debug_info->ss + fh->issBase + sh.iss,
> +                            true);
>         }
>        else
>         {
> @@ -4542,6 +4670,8 @@ add_line (struct linetable *lt, int lineno,
> CORE_ADDR adr, int last)
>      return lineno;
>
>    lt->item[lt->nitems].line = lineno;
> +  lt->item[lt->nitems].is_stmt = 1;
> +  lt->item[lt->nitems].prologue_end = 1;
>    lt->item[lt->nitems++].set_unrelocated_pc (unrelocated_addr (adr << 2));
>    return lineno;
>  }
> @@ -4634,9 +4764,10 @@ new_symtab (const char *name, int maxlines, struct
> objfile *objfile)
>
>    /* All symtabs must have at least two blocks.  */
>    bv = new_bvect (2);
> -  bv->set_block (GLOBAL_BLOCK, new_block (objfile, NON_FUNCTION_BLOCK,
> lang));
> -  bv->set_block (STATIC_BLOCK, new_block (objfile, NON_FUNCTION_BLOCK,
> lang));
> +  bv->set_block (GLOBAL_BLOCK, new_block (objfile, NON_FUNCTION_BLOCK,
> lang, true));
> +  bv->set_block (STATIC_BLOCK, new_block (objfile, NON_FUNCTION_BLOCK,
> lang, false));
>    bv->static_block ()->set_superblock (bv->global_block ());
> +  bv->global_block ()->set_compunit_symtab(cust);
>    cust->set_blockvector (bv);
>
>    cust->set_debugformat ("ECOFF");
> @@ -4723,9 +4854,11 @@ new_bvect (int nblocks)
>
>  static struct block *
>  new_block (struct objfile *objfile, enum block_type type,
> -          enum language language)
> +          enum language language, bool is_global)
>  {
> -  struct block *retval = new (&objfile->objfile_obstack) block;
> +  struct block *retval = (is_global
> +    ? new (&objfile->objfile_obstack) global_block
> +    : new (&objfile->objfile_obstack) block);
>
>    if (type == FUNCTION_BLOCK)
>      retval->set_multidict (mdict_create_linear_expandable (language));
> @@ -4754,8 +4887,7 @@ new_type (char *name)
>  {
>    struct type *t;
>
> -  t = type_allocator (mdebugread_objfile,
> -                     get_current_subfile ()->language).new_type ();
> +  t = type_allocator (mdebugread_objfile, psymtab_language).new_type ();
>    t->set_name (name);
>    INIT_CPLUS_SPECIFIC (t);
>    return t;
> diff --git a/gdb/testsuite/boards/qemu-user.exp
> b/gdb/testsuite/boards/qemu-user.exp
> new file mode 100644
> index 00000000000..8a48ab7f6d4
> --- /dev/null
> +++ b/gdb/testsuite/boards/qemu-user.exp
> @@ -0,0 +1,267 @@
> +# Copyright 2020-2023 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# NOTICE:
> +# QEMU user mode gdbstub has multithreading problems
> +# https://gitlab.com/qemu-project/qemu/-/issues/1671
> +# run with --ignore gdb.threads/access-mem-running-thread-exit.exp
> +# since this test in particular seems to hang. Could be related.
> +
> +# This technique is from native-extended-gdbserver.exp
> +# We must load this explicitly here, and rename the procedures we want
> +# to override.  If we didn't do this, given that mi-support.exp is
> +# loaded later in the test files, the procedures loaded then would
> +# override our definitions.
> +load_lib mi-support.exp
> +
> +set qemu ""
> +set qemu_arch ""
> +set qemu_user_spawn_id ""
> +set qemu_user_last_load_file ""
> +set port "2345"
> +
> +# add sections for other architectures
> +# as needed
> +case "$target_triplet" in {
> +       { "mips" } {
> +               set qemu "qemu-mips"
> +               set qemu_arch "mips"
> +       }
> +       default {
> +               puts "No target hardware for $target_triplet"
> +       }
> +}
> +
> +# QEMU supports some of extended-remote, but not the run command
> +# which causes problems for the test suite
> +set_board_info gdb_protocol "remote"
> +set_board_info use_gdb_stub 1
> +set_board_info gdb,do_reload_on_run 1
> +set_board_info exit_is_reliable 1
> +# static link so we do not need to configure an QEMU LD prefix and install
> +# libraries for the target architecture
> +set_board_info ldflags "-static"
> +
> +# technique from simavr.exp
> +#
> +# Load executable into GDB
> +#
> +proc gdb_load { arg } {
> +    global gdb_prompt
> +    global verbose
> +    global spawn_id
> +    global qemu
> +    global qemu_user_last_load_file
> +    global qemu_user_spawn_id
> +    global port
> +
> +    # keep track of last loaded file
> +    # to simulate run restart like behavior
> +    if { $arg == "" } {
> +               set arg $qemu_user_last_load_file
> +               if { $arg == ""  } {
> +                       global last_loaded_file
> +                       # this fallback is needed
> +                       # for tests like gdb.base/break-unload-file.exp
> +                       set arg $last_loaded_file
> +               }
> +    } else {
> +       set qemu_user_last_load_file $arg
> +    }
> +
> +    if { $arg != "" } {
> +               if {[gdb_file_cmd $arg]} then { return -1 }
> +    }
> +
> +    # Close any previous qemu user instance.
> +    if { $qemu_user_spawn_id != "" } {
> +               verbose -log "qemu user: closing previous spawn id
> $qemu_user_spawn_id"
> +               if [catch { close -i $qemu_user_spawn_id } != 0] {
> +                       warning "qemu user: failed to close connection to
> previous qemu user instance"
> +               }
> +
> +               # some tests get QEMU
> +               # into a state where the process doesn't want to die
> +               # so -nowait to not hang the entire test run
> +               wait -nowait -i $qemu_user_spawn_id
> +               set qemu_user_spawn_id ""
> +    }
> +
> +    # technique from gdbserver-support.exp
> +    # Loop till we find a free port.
> +    # This is to cope with qemu sometimes getting
> +    # into a bad state and not closing.
> +    # Do a pkill -f qemu-mips -9 after running tests
> +    # to remove stragglers
> +    while 1 {
> +               # Run QEMU user
> +               set cmd "spawn -noecho $qemu -g $port $arg"
> +               verbose -log "Spawning qemu user: $cmd"
> +               eval $cmd
> +               set qemu_user_spawn_id $spawn_id
> +
> +               # without inferior_spawn_id
> +               # tests such as gdb.base/a2-run.exp
> +               # can't look at the right process output
> +               global inferior_spawn_id
> +               set inferior_spawn_id $spawn_id
> +
> +               expect {
> +                       -i $qemu_user_spawn_id
> +                       -timeout 1
> +                       -re ".*qemu: could not open gdbserver on.*" {
> +                               verbose -log "Port $port is already in
> use."
> +                               if [catch { close -i $qemu_user_spawn_id }
> != 0] {
> +                                       warning "qemu user: failed to
> close connection to previous qemu user instance"
> +                               }
> +                               # Bump the port number to avoid the
> conflict.
> +                               wait -i $qemu_user_spawn_id
> +                               incr port
> +                               continue
> +                       }
> +               }
> +               break
> +       }
> +
> +    # arch needs set because some tests
> +    # take actions that need arch to be correct
> +    # immediately, before file command loads the binary
> +    # for example gdb.base/break-unload-file.exp
> +    global qemu_arch
> +    send_gdb "set arch $qemu_arch\n"
> +
> +    # Connect to qemu user.
> +    send_gdb "target remote :$port\n"
> +    gdb_expect {
> +               # qemu user mode gdb stub does not support non stop mode
> +               # this is so tests that attempt it die quickly
> +               -re ".*Non-stop mode requested, but remote does not
> support non-stop.*" {
> +                       error "qemu user does not support non-stop"
> +               }
> +               # cannot have multiple targets connected
> +               # some tests end up causing this to be attempted in
> gdb.multi
> +               -re ".*Already connected to a remote target.
> Disconnect?.*" {
> +                       send_gdb "y\n"
> +                       gdb_expect {
> +                               -re ".*$gdb_prompt $" {
> +                                       error "connected to new target
> while connected to existing"
> +                               }
> +                       }
> +               }
> +               -re ".*$gdb_prompt $" {
> +                       if $verbose>1 then {
> +                               send_user "Connected to QEMU target\n"
> +                       }
> +               }
> +               -re "Remote debugging using .*$gdb_prompt $" {
> +                       verbose "Set target to remote for QEMU"
> +               }
> +               timeout {
> +                       verbose -log "qemu-user: unable to connect to qemu
> user, closing qemu user spawn id"
> +                       close -i $qemu_user_spawn_id
> +                       verbose -log "qemu-user: unable to connect to qemu
> user, waiting for qemu user process exit"
> +                       wait -i $qemu_user_spawn_id
> +                       set qemu_user_spawn_id ""
> +                       error "unable to connect to qemu user stub"
> +               }
> +       }
> +
> +       return 0
> +}
> +
> +# technique from native-extended-gdbserver.exp
> +# for overriding mi-support.exp procs
> +if { [info procs original_mi_gdb_load] == "" } {
> +    rename mi_gdb_load original_gdbserver_mi_gdb_load
> +}
> +
> +# same ideas as gdb_load, but adapted for mi
> +proc mi_gdb_load { arg } {
> +    global gdb_prompt
> +    global verbose
> +    global spawn_id
> +    global qemu
> +    global qemu_user_last_load_file
> +    global qemu_user_spawn_id
> +    global port
> +
> +    if { $arg == "" } {
> +               set arg $qemu_user_last_load_file
> +               if { $arg == ""  } {
> +                       global last_loaded_file
> +                       set arg $last_loaded_file
> +               }
> +    } else {
> +               set qemu_user_last_load_file $arg
> +    }
> +
> +    if { $arg != "" } {
> +               if {[mi_gdb_file_cmd $arg]} then { return -1 }
> +    }
> +
> +    #Close any previous qemu user instance.
> +    if { $qemu_user_spawn_id != "" } {
> +               verbose -log "qemu user: closing previous spawn id
> $qemu_user_spawn_id"
> +               if [catch { close -i $qemu_user_spawn_id } != 0] {
> +                       warning "qemu user: failed to close previous qemu
> user instance"
> +               }
> +
> +               # some tests get QEMU/its gdb stub
> +               # into a state where the process doesn't want to die
> +               # so -nowait to not hang the entire test run
> +               wait -nowait -i $qemu_user_spawn_id
> +               set qemu_user_spawn_id ""
> +    }
> +
> +    # technique from gdbserver-support.exp
> +    # Loop till we find a free port.
> +    while 1 {
> +               # Run QEMU user
> +               set cmd "spawn -noecho $qemu -g $port $arg"
> +               verbose -log "Spawning qemu user: $cmd"
> +               eval $cmd
> +               set qemu_user_spawn_id $spawn_id
> +
> +               # without inferior_spawn_id
> +               # tests such as gdb.base/a2-run.exp
> +               # can't look at the right process output
> +               global inferior_spawn_id
> +               set inferior_spawn_id $spawn_id
> +
> +               expect {
> +                       -i $qemu_user_spawn_id
> +                       -timeout 1
> +                       -re ".*qemu: could not open gdbserver on.*" {
> +                               verbose -log "Port $port is already in
> use."
> +                               if [catch { close -i $qemu_user_spawn_id }
> != 0] {
> +                                       warning "qemu user: failed to
> close connection to previous qemu user instance"
> +                               }
> +                               # Bump the port number to avoid the
> conflict.
> +                               wait -i $qemu_user_spawn_id
> +                               incr port
> +                               continue
> +                       }
> +               }
> +               break
> +       }
> +
> +       return 0
> +}
> +
> +# technique from stdio-gdb-server-base.exp
> +proc mi_gdb_target_load { } {
> +    global port
> +    return [mi_gdb_target_cmd "remote" ":$port"]
> +}
> diff --git a/gdb/testsuite/gdb.mdebug/README
> b/gdb/testsuite/gdb.mdebug/README
> new file mode 100644
> index 00000000000..f749d3e1cbc
> --- /dev/null
> +++ b/gdb/testsuite/gdb.mdebug/README
> @@ -0,0 +1,67 @@
> +These tests are adapted for dealing with the limitations of old compilers
> and the mdebug format.
> +
> +Execute the mdebug tests with something like:
> +runtest gdb.mdebug/info-types-c.exp CC_FOR_TARGET=idowrapper MDEBUG=1
> --target mips --target_board qemu-user
> +
> +The CC_FOR_TARGET is probably going to be a wrapper script
> +for an old compiler running in an emulator.
> +Example at the end of this readme.
> +Put it somewhere in your PATH.
> +Do not give the path to the script as CC_FOR_TARGET, that does not work.
> +
> +The qemu-user board will run mips programs in qemu user mode
> +and connect gdb to QEMU's gdb stub.
> +
> +mdebug does not record line numbers for type definitions.
> +This is why the info types tests are modified
> +
> +mdebug output can be odd in how line mappings deal with the start of
> functions.
> +This is why the break tests are modified.
> +
> +Most compilers outputting mdebug data are so old they cannot deal with
> C99 features.
> +This makes parsing standard library headers for modern implementations a
> problem.
> +Also, even past that, the headers may eventually lead to compiler
> specific code
> +in things like stddef.h that may not be appriopriate for your old
> compiler.
> +This is why break.c has some modified standard function signatures at the
> beginning.
> +
> +A few of the break tests *sometimes* fail still.
> +Several memory initialization bugs were fixed but whatever is causing that
> +is very inconsistent. Or it could be some issue with the exp file.
> +
> +The best documentation on mdebug are these documents:
> +
> +"Tru64 UNIX Object File and Symbol Table Format Specification"
> +Sections 5, 9, and 10
> +Note, the word "mdebug" is never used, but it is that format
> +carried through from DEC to Compaq.
> +
> +"MIPS Mdebug Debugging Information" by David Anderson
> +
> +A wrapper script like this was used to create .o files with IDO running
> in an emulator.
> +The final link commands are run with regular linux gcc.
> +
> +#!/bin/sh
> +
> +echo "$@" >> theargs
> +
> +for arg do
> +  if [ "$arg" = "-static" ]
> +  then
> +    link=1
> +  fi
> +done
> +
> +if [ "$link" = 1 ]
> +then
> +  mips-unknown-linux-gnu-gcc "$@" -fno-exceptions
> +else
> +for arg do
> +  shift
> +  [ "$arg" = "-fdiagnostics-color=never" ] && continue
> +  [ "$arg" = "-g" ] && continue
> +  set -- "$@" "$arg"
> +done
> +
> +/home/someuser/qemu-irix/build/irix-linux-user/qemu-irix -L
> /home/someuser/ido/ido7.1_compiler
> /home/someuser/ido/ido7.1_compiler/usr/bin/cc -Xcpluscomm -nostdlib
> -nostdinc -mips2
> +-g2 "$@" 2>/dev/null
> +fi
> diff --git a/gdb/testsuite/gdb.mdebug/break.c
> b/gdb/testsuite/gdb.mdebug/break.c
> new file mode 100644
> index 00000000000..d0b26998c77
> --- /dev/null
> +++ b/gdb/testsuite/gdb.mdebug/break.c
> @@ -0,0 +1,92 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> +   Copyright 1992-2023 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.
> */
> +
> +int printf (const char *__format, ...);
> +int fprintf (void *__stream, const char *__format, ...);
> +int atoi(const char *_Str);
> +void *malloc(int size);
> +
> +extern void * stderr;
> +
> +extern int marker1 (void);
> +extern int marker2 (int a);
> +extern void marker3 (char *a, char *b);
> +extern void marker4 (long d);
> +
> +/* We're used by a test that requires malloc, so make sure it is in
> +   the executable.  */
> +void *need_malloc ()
> +{
> +  return malloc (1);
> +}
> +
> +/*
> + *     This simple classical example of recursion is useful for
> + *     testing stack backtraces and such.
> + */
> +
> +int factorial(int);
> +
> +int
> +main (int argc, char **argv, char **envp)
> +{ /* set breakpoint 6 here */
> +  if (argc == 12345) {  /* an unlikely value < 2^16, in case uninited */
> +       fprintf (stderr, "usage:  factorial <number>\n");
> +       return 1;
> +    }
> +    printf ("%d\n", factorial (atoi ("6")));  /* set breakpoint 1 here */
> +    /* set breakpoint 12 here */
> +    marker1 ();  /* set breakpoint 11 here */
> +    marker2 (43); /* set breakpoint 20 here */
> +    marker3 ("stack", "trace"); /* set breakpoint 21 here */
> +    marker4 (177601976L);
> +    /* We're used by a test that requires malloc, so make sure it is
> +       in the executable.  */
> +    (void)malloc (1);
> +
> +    argc = (argc == 12345); /* This is silly, but we can step off of it
> */ /* set breakpoint 2 here */
> +    return argc;  /* set breakpoint 10 here */
> +} /* set breakpoint 10a here */
> +
> +int factorial (int value)
> +{ /* set breakpoint 7 here */
> +  if (value > 1) { /* set breakpoint 7a here */
> +       value *= factorial (value - 1);
> +    }
> +    return (value); /* set breakpoint 19 here */
> +}
> +
> +int multi_line_if_conditional (int a, int b, int c)
> +{ /* set breakpoint 3 here */
> +  if (a
> +      && b
> +      && c)
> +    return 0;
> +  else
> +    return 1;
> +}
> +
> +int multi_line_while_conditional (int a, int b, int c)
> +{ /* set breakpoint 4 here */
> +  while (a
> +      && b
> +      && c)
> +    {
> +      a--, b--, c--;
> +    }
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.mdebug/break.exp
> b/gdb/testsuite/gdb.mdebug/break.exp
> new file mode 100644
> index 00000000000..cb74c1b0081
> --- /dev/null
> +++ b/gdb/testsuite/gdb.mdebug/break.exp
> @@ -0,0 +1,921 @@
> +#   Copyright 1988-2023 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# This file was written by Rob Savoye. (rob@cygnus.com)
> +
> +if { [build_executable "failed to prepare" "break" {break.c break1.c}
> {debug nowarnings}] } {
> +    return -1
> +}
> +set srcfile break.c
> +set srcfile1 break1.c
> +
> +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
> +set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
> +set bp_location3 [gdb_get_line_number "set breakpoint 3 here"]
> +set bp_location4 [gdb_get_line_number "set breakpoint 4 here"]
> +set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
> +set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
> +set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
> +set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
> +
> +set main_line $bp_location6
> +
> +# In C++ mode, we see a full prototype; in C mode, we only see the
> +# function name, with no parameter info.
> +proc func {name} {
> +    return "${name}(?:\(\[^\r\n\]*\))?"
> +}
> +
> +# test simple breakpoint setting commands
> +
> +proc_with_prefix test_break {} {
> +    clean_restart break
> +
> +    # Test deleting all breakpoints when there are none installed,
> +    # GDB should not prompt for confirmation.
> +    # Note that lib/gdb.exp provides a "delete_breakpoints" proc
> +    # for general use elsewhere.
> +    send_gdb "delete breakpoints\n"
> +    gdb_expect {
> +        -re "Delete all breakpoints.*$" {
> +               send_gdb "y\n"
> +               gdb_expect {
> +                   -re "$::gdb_prompt $" {
> +                       fail "delete all breakpoints when none (unexpected
> prompt)"
> +                   }
> +                   timeout     { fail "delete all breakpoints when none
> (timeout after unexpected prompt)" }
> +               }
> +           }
> +        -re ".*$::gdb_prompt $"       { pass "delete all breakpoints when
> none" }
> +       timeout             { fail "delete all breakpoints when none
> (timeout)" }
> +    }
> +
> +    # test break at function
> +    gdb_test "break -q main" \
> +       "Breakpoint.*at.* file .*$::srcfile, line.*" \
> +       "breakpoint function"
> +
> +    # test break at quoted function
> +    gdb_test "break \"marker2\"" \
> +       "Breakpoint.*at.* file .*$::srcfile1, line.*" \
> +       "breakpoint quoted function"
> +
> +    # test break at function in file
> +    gdb_test "break $::srcfile:factorial" \
> +       "Breakpoint.*at.* file .*$::srcfile, line.*" \
> +       "breakpoint function in file"
> +
> +    # test break at line number
> +    #
> +    # Note that the default source file is the last one whose source text
> +    # was printed.  For native debugging, before we've executed the
> +    # program, this is the file containing main, but for remote debugging,
> +    # it's wherever the processor was stopped when we connected to the
> +    # board.  So, to be sure, we do a list command.
> +    gdb_test "list -q main" \
> +       ".*main \\(int argc, char \\*\\*argv, char \\*\\*envp\\).*" \
> +       "use `list' to establish default source file"
> +
> +    gdb_test "break $::bp_location1" \
> +       "Breakpoint.*at.* file .*$::srcfile, line $::bp_location1\\." \
> +       "breakpoint line number"
> +
> +    # test duplicate breakpoint
> +    gdb_test "break $::bp_location1" \
> +       "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+
> at.* file .*$::srcfile, line $::bp_location1\\." \
> +       "breakpoint duplicate"
> +
> +    # test break at line number in file
> +    gdb_test "break $::srcfile:$::bp_location2" \
> +       "Breakpoint.*at.* file .*$::srcfile, line $::bp_location2\\." \
> +       "breakpoint line number in file"
> +
> +    # Test putting a break at the start of a multi-line if conditional.
> +    # Verify the breakpoint was put at the start of the conditional.
> +    gdb_test "break multi_line_if_conditional" \
> +       "Breakpoint.*at.* file .*$::srcfile, line $::bp_location3\\." \
> +       "breakpoint at start of multi line if conditional"
> +
> +    gdb_test "break multi_line_while_conditional" \
> +       "Breakpoint.*at.* file .*$::srcfile, line $::bp_location4\\." \
> +       "breakpoint at start of multi line while conditional"
> +
> +    gdb_test "info break" \
> +       [multi_line "Num     Type\[ \]+Disp Enb Address\[ \]+What.*" \
> +                   "$::decimal\[\t \]+breakpoint     keep y.* in [func
> main] at .*$::srcfile:$::main_line.*" \
> +                   "$::decimal\[\t \]+breakpoint     keep y.* in [func
> marker2] at .*$::srcfile1:$::bp_location8.*" \
> +                   "$::decimal\[\t \]+breakpoint     keep y.* in [func
> factorial] at .*$::srcfile:$::bp_location7.*" \
> +                   "$::decimal\[\t \]+breakpoint     keep y.* in [func
> main] at .*$::srcfile:$::bp_location1.*" \
> +                   "$::decimal\[\t \]+breakpoint     keep y.* in [func
> main] at .*$::srcfile:$::bp_location1.*" \
> +                   "$::decimal\[\t \]+breakpoint     keep y.* in [func
> main] at .*$::srcfile:$::bp_location2.*" \
> +                   "$::decimal\[\t \]+breakpoint     keep y.* in [func
> multi_line_if_conditional] at .*$::srcfile:$::bp_location3.*" \
> +                   "$::decimal\[\t \]+breakpoint     keep y.* in [func
> multi_line_while_conditional] at .*$::srcfile:$::bp_location4"] \
> +       "breakpoint info"
> +
> +    #
> +    # Test info breakpoint with arguments
> +    #
> +
> +    set see1 0
> +    set see2 0
> +    set see3 0
> +    set see4 0
> +    set see5 0
> +    set see6 0
> +
> +    gdb_test_multiple "info break 2 4 6" "info break 2 4 6" {
> +       -re "1\[\t \]+breakpoint *keep y\[^\r\n\]*:$::main_line\[^\r\n\]*"
> {
> +           set see1 1
> +           exp_continue
> +       }
> +       -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at
> \[^\r\n\]*" {
> +           set see2 1
> +           exp_continue
> +       }
> +       -re "3\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location7\[^\r\n\]*" {
> +           set see3 1
> +           exp_continue
> +       }
> +       -re "4\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
> +           set see4 1
> +           exp_continue
> +       }
> +       -re "5\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
> +           set see5 1
> +           exp_continue
> +       }
> +       -re "6\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location2\[^\r\n\]*" {
> +           set see6 1
> +           exp_continue
> +       }
> +       -re ".*$::gdb_prompt $" {
> +           if {!$see1 && $see2 && !$see3 && $see4 && !$see5 && $see6} {
> +               pass "info break 2 4 6"
> +           } else {
> +               fail "info break 2 4 6"
> +           }
> +       }
> +    }
> +
> +    set see1 0
> +    set see2 0
> +    set see3 0
> +    set see4 0
> +    set see5 0
> +    set see6 0
> +
> +    gdb_test_multiple "info break 3-5" "info break 3-5" {
> +       -re "1\[\t \]+breakpoint *keep y.* in [func main] at
> .*:$::main_line\[^\r\n\]*" {
> +           set see1 1
> +           exp_continue
> +       }
> +       -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at
> \[^\r\n\]*" {
> +           set see2 1
> +           exp_continue
> +       }
> +       -re "3\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location7\[^\r\n\]*" {
> +           set see3 1
> +           exp_continue
> +       }
> +       -re "4\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
> +           set see4 1
> +           exp_continue
> +       }
> +       -re "5\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
> +           set see5 1
> +           exp_continue
> +       }
> +       -re "6\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location2\[^\r\n\]*" {
> +           set see6 1
> +           exp_continue
> +       }
> +       -re ".*$::gdb_prompt $" {
> +           if {!$see1 && !$see2 && $see3 && $see4 && $see5 && !$see6} {
> +               pass "info break 3-5"
> +           } else {
> +               fail "info break 3-5"
> +           }
> +       }
> +    }
> +
> +    #
> +    # Test disable/enable with arguments
> +    #
> +
> +    # Test with value history
> +
> +    with_test_prefix "with value history" {
> +       gdb_test "print 1"
> +       gdb_test "print 2"
> +       gdb_test "print 3"
> +       gdb_test "print 4"
> +       gdb_test "print 5"
> +       gdb_test "print 6"
> +
> +       # $2 is 2 and $$ is 5
> +       gdb_test_no_output "disable \$2 \$\$" "disable using history
> values"
> +
> +       set see1 0
> +       set see2 0
> +       set see3 0
> +       set see4 0
> +       set see5 0
> +       set see6 0
> +
> +       gdb_test_multiple "info break" "check disable with history values"
> {
> +           -re "1\[\t \]+breakpoint *keep y.* in [func main] at
> .*:$::main_line\[^\r\n\]*" {
> +               set see1 1
> +               exp_continue
> +           }
> +           -re "2\[\t \]+breakpoint *keep n\[^\r\n\]* in [func marker2]
> at \[^\r\n\]*" {
> +               set see2 1
> +               exp_continue
> +           }
> +           -re "3\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location7\[^\r\n\]*" {
> +               set see3 1
> +               exp_continue
> +           }
> +           -re "4\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
> +               set see4 1
> +               exp_continue
> +           }
> +           -re "5\[\t \]+breakpoint *keep
> n\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
> +               set see5 1
> +               exp_continue
> +           }
> +           -re "6\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location2\[^\r\n\]*" {
> +               set see6 1
> +               exp_continue
> +           }
> +           -re ".*$::gdb_prompt $" {
> +               if {$see1 && $see2 && $see3 && $see4 && $see5 && $see6} {
> +                   pass "check disable with history values"
> +               } else {
> +                   fail "check disable with history values"
> +               }
> +           }
> +       }
> +    }
> +
> +    with_test_prefix "with convenience vars" {
> +       gdb_test "enable"
> +       gdb_test "set \$foo = 3"
> +       gdb_test "set \$bar = 6"
> +       gdb_test_no_output "disable \$foo \$bar" "disable with convenience
> values"
> +
> +       set see1 0
> +       set see2 0
> +       set see3 0
> +       set see4 0
> +       set see5 0
> +       set see6 0
> +
> +       gdb_test_multiple "info break" "check disable with convenience
> values" {
> +           -re "1\[\t \]+breakpoint *keep y.* in [func main] at
> .*:$::main_line\[^\r\n\]*" {
> +               set see1 1
> +               exp_continue
> +           }
> +           -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2]
> at \[^\r\n\]*" {
> +               set see2 1
> +               exp_continue
> +           }
> +           -re "3\[\t \]+breakpoint *keep
> n\[^\r\n\]*$::bp_location7\[^\r\n\]*" {
> +               set see3 1
> +               exp_continue
> +           }
> +           -re "4\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
> +               set see4 1
> +               exp_continue
> +           }
> +           -re "5\[\t \]+breakpoint *keep
> y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
> +               set see5 1
> +               exp_continue
> +           }
> +           -re "6\[\t \]+breakpoint *keep
> n\[^\r\n\]*$::bp_location2\[^\r\n\]*" {
> +               set see6 1
> +               exp_continue
> +           }
> +           -re ".*$::gdb_prompt $" {
> +               if {$see1 && $see2 && $see3 && $see4 && $see5 && $see6} {
> +                   pass "check disable with convenience values"
> +               } else {
> +                   fail "check disable with convenience values"
> +               }
> +           }
> +       }
> +    }
> +
> +    # test with bad values
> +
> +    with_test_prefix "bad values" {
> +       gdb_test "enable"
> +       gdb_test "disable 10" "No breakpoint number 10." \
> +           "disable non-existent breakpoint 10"
> +
> +       gdb_test_no_output "set \$baz = 1.234"
> +       gdb_test "disable \$baz" \
> +           "Convenience variable must have integer value.*" \
> +           "disable with non-integer convenience var"
> +       gdb_test "disable \$grbx" \
> +           "Convenience variable must have integer value.*" \
> +           "disable with non-existent convenience var"
> +       gdb_test "disable \$10" \
> +           "History has not yet reached .10." \
> +           "disable with non-existent history value"
> +       gdb_test "disable \$1foo" \
> +           "Convenience variable must have integer value.*" \
> +           "disable with badly formed history value"
> +    }
> +
> +    # FIXME: The rest of this test doesn't work with anything that can't
> +    # handle arguments.
> +    # Huh? There doesn't *appear* to be anything that passes arguments
> +    # below.
> +
> +    #
> +    # run until the breakpoint at main is hit. For non-stubs-using
> targets.
> +    #
> +    gdb_run_cmd
> +    gdb_test "" \
> +       "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at
> .*$::srcfile:$::bp_location6.*$::bp_location6\[\t \]+\{.*" \
> +       "run until function breakpoint"
> +
> +    # Test the 'list' commands sets current file for the 'break LINENO'
> command.
> +    set bp_marker1 [gdb_get_line_number "set breakpoint 15 here"
> $::srcfile1]
> +    gdb_test "list marker1" ".*"
> +    gdb_test "break $bp_marker1" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+:
> file .*$::srcfile1, line ${bp_marker1}\\." \
> +            "break lineno"
> +    gdb_test_no_output {delete $bpnum}
> +
> +    #
> +    # run until the breakpoint at a line number
> +    #
> +    gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main
> \\(argc=.*, argv=.*, envp=.*\\) at
> .*$::srcfile:$::bp_location1.*$::bp_location1\[\t \]+printf.*factorial.*" \
> +                           "run until breakpoint set at a line number"
> +
> +    #
> +    # Run until the breakpoint set in a function in a file
> +    #
> +       set bp_location7a [gdb_get_line_number "set breakpoint 7a here"]
> +       send_gdb "del 3\n"
> +       send_gdb "del 7\n"
> +       gdb_test "break $bp_location7a" \
> +       "Breakpoint.*at.* file .*$::srcfile, line $bp_location7a\\." \
> +       "setting breakpoint at 7a"
> +
> +    for {set i 6} {$i >= 1} {incr i -1} {
> +           gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+,
> factorial \\(value=$i\\) at .*$::srcfile:$bp_location7a.*$bp_location7a\[\t
> \]+.*if .value > 1. \{.*" \
> +                           "run until file:function($i) breakpoint"
> +    }
> +
> +    send_gdb "break $::bp_location3\n"
> +
> +       send_gdb "break $::bp_location7\n"
> +
> +    send_gdb "del 2\n"
> +
> +    #
> +    # run until the file:function breakpoint at a line number in a file
> +    #
> +    gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main
> \\(argc=.*, argv=.*, envp=.*\\) at
> .*$::srcfile:$::bp_location2.*$::bp_location2\[\t \]+argc = \\(argc ==
> 12345\\);.*" \
> +                   "run until file:linenum breakpoint"
> +
> +    # Test break at offset +1
> +    set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
> +
> +    gdb_test "break +1" \
> +       "Breakpoint.*at.* file .*$::srcfile, line $bp_location10\\." \
> +       "breakpoint offset +1"
> +
> +    # Check to see if breakpoint is hit when stepped onto
> +
> +    gdb_test "step" \
> +       ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at
> .*$::srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint
> 10 here.*" \
> +       "step onto breakpoint"
> +}
> +
> +test_break
> +
> +proc_with_prefix test_tbreak {} {
> +    clean_restart break
> +
> +    # test temporary breakpoint at function
> +    gdb_test "tbreak -q main" "Temporary breakpoint.*at.* file
> .*$::srcfile, line.*" "temporary breakpoint function"
> +
> +    # test break at function in file
> +    gdb_test "tbreak $::srcfile:factorial" "Temporary breakpoint.*at.*
> file .*$::srcfile, line.*" \
> +           "Temporary breakpoint function in file"
> +
> +    # test break at line number
> +    gdb_test "tbreak $::bp_location1" \
> +       "Temporary breakpoint.*at.* file .*$::srcfile, line
> $::bp_location1.*" \
> +       "temporary breakpoint line number #1"
> +
> +    gdb_test "tbreak $::bp_location6" "Temporary breakpoint.*at.* file
> .*$::srcfile, line $::bp_location6.*" "temporary breakpoint line number #2"
> +
> +    # test break at line number in file
> +    gdb_test "tbreak $::srcfile:$::bp_location2" \
> +       "Temporary breakpoint.*at.* file .*$::srcfile, line
> $::bp_location2.*" \
> +       "temporary breakpoint line number in file #1"
> +
> +    gdb_test  "tbreak $::srcfile:$::bp_location11" "Temporary
> breakpoint.*at.* file .*$::srcfile, line $::bp_location11.*" "Temporary
> breakpoint line number in file #2"
> +
> +    # check to see what breakpoints are set (temporary this time)
> +    gdb_test "info break" \
> +       [multi_line "Num     Type.*Disp Enb Address.*What.*" \
> +                   "$::decimal\[\t \]+breakpoint     del.*y.*in [func
> main] at .*$::srcfile:$::main_line.*" \
> +                   "$::decimal\[\t \]+breakpoint     del.*y.*in [func
> factorial] at .*$::srcfile:$::bp_location7.*" \
> +                   "$::decimal\[\t \]+breakpoint     del.*y.*in [func
> main] at .*$::srcfile:$::bp_location1.*" \
> +                   "$::decimal\[\t \]+breakpoint     del.*y.*in [func
> main] at .*$::srcfile:$::bp_location6.*" \
> +                   "$::decimal\[\t \]+breakpoint     del.*y.*in [func
> main] at .*$::srcfile:$::bp_location2.*" \
> +                   "$::decimal\[\t \]+breakpoint     del.*y.*in [func
> main] at .*$::srcfile:$::bp_location11.*"] \
> +       "Temporary breakpoint info"
> +}
> +
> +test_tbreak
> +
> +# Verify that GDB responds gracefully when asked to set a breakpoint
> +# on a nonexistent source line.
> +
> +proc_with_prefix test_break_nonexistent_line {} {
> +    clean_restart break
> +
> +    if {![runto_main]} {
> +       return
> +    }
> +
> +    gdb_test_no_output "set breakpoint pending off"
> +    gdb_test "break 999" \
> +       "No line 999 in the current file." \
> +       "break on non-existent source line"
> +}
> +
> +test_break_nonexistent_line
> +
> +proc_with_prefix test_break_default {} {
> +    clean_restart break
> +
> +    if {![runto_main]} {
> +       return
> +    }
> +
> +    # Run to the desired default location. If not positioned here, the
> +    # tests below don't work.
> +    #
> +    gdb_test "until $::bp_location1" "main .* at .*:$::bp_location1.*" \
> +       "until bp_location1"
> +
> +    # Verify that GDB allows one to just say "break", which is treated
> +    # as the "default" breakpoint.  Note that GDB gets cute when printing
> +    # the informational message about other breakpoints at the same
> +    # location.  We'll hit that bird with this stone too.
> +    #
> +    gdb_test "break" "Breakpoint \[0-9\]*.*" \
> +       "break on default location, 1st time"
> +
> +    gdb_test "break" \
> +       "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*" \
> +       "break on default location, 2nd time"
> +
> +    gdb_test "break" \
> +       "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint
> \[0-9\]*.*" \
> +       "break on default location, 3rd time"
> +
> +    gdb_test "break" \
> +       "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at
> .*Breakpoint \[0-9\]*.*" \
> +       "break on default location, 4th time"
> +
> +    # Check setting a breakpoint at the default location with a condition
> attached.
> +    gdb_test "break if (1)" \
> +       "Note: breakpoints \[0-9\]*, \[0-9\]*, \[0-9\]* and \[0-9\]* also
> set at .*Breakpoint \[0-9\]*.*" \
> +       "break on the default location, 5th time, but with a condition"
> +}
> +
> +test_break_default
> +
> +# Verify that a "silent" breakpoint can be set, and that GDB is indeed
> +# "silent" about its triggering.
> +
> +proc_with_prefix test_break_silent_and_more {} {
> +    clean_restart break
> +
> +    if {![runto_main]} {
> +       return
> +    }
> +
> +    gdb_test_multiple "break $::bp_location1" \
> +       "set to-be-silent break bp_location1" {
> +           -re "Breakpoint (\[0-9\]*) at .*, line
> $::bp_location1.*$::gdb_prompt $" {
> +               set bpno $expect_out(1,string)
> +               pass "set to-be-silent break bp_location1"
> +           }
> +       }
> +
> +    gdb_test "commands $bpno\nsilent\nend" ">end" "set silent break
> bp_location1"
> +
> +    gdb_test "info break $bpno" \
> +       "\[0-9\]*\[ \t\]*breakpoint.*:$::bp_location1\r\n\[ \t\]*silent.*"
> \
> +       "info silent break bp_location1"
> +
> +    gdb_test "continue" "Continuing." \
> +       "hit silent break bp_location1"
> +
> +    gdb_test "bt" "#0  main .* at .*:$::bp_location1.*" \
> +       "stopped for silent break bp_location1"
> +
> +    # Verify the $_hit_bpnum convenience variable is set to the silent
> hit bpno.
> +    gdb_test "printf \"%d\\n\", \$_hit_bpnum" "$bpno" \
> +       "Silent breakpoint hit \$_hit_bpnum is silent $bpno"
> +
> +    # Verify that GDB can at least parse a breakpoint with the
> +    # "thread" keyword.  (We won't attempt to test here that a
> +    # thread-specific breakpoint really triggers appropriately.
> +    # The gdb.threads subdirectory contains tests for that.)
> +    #
> +    set bp_location12 [gdb_get_line_number "set breakpoint 12 here"]
> +    gdb_test "break $bp_location12 thread 999" "Unknown thread 999.*" \
> +       "thread-specific breakpoint on non-existent thread disallowed"
> +
> +    gdb_test "break $bp_location12 thread foo" \
> +       "Invalid thread ID: foo" \
> +       "thread-specific breakpoint on bogus thread ID disallowed"
> +
> +    # Verify that GDB responds gracefully to a breakpoint command with
> +    # trailing garbage.
> +    #
> +    gdb_test "break $bp_location12 foo" \
> +       "malformed linespec error: unexpected string, \"foo\".*" \
> +       "breakpoint with trailing garbage disallowed"
> +
> +    # Verify that GDB responds gracefully to a "clear" command that has
> +    # no matching breakpoint.  (First, get us off the current source line,
> +    # which we know has a breakpoint.)
> +    #
> +    gdb_test "next" "marker1.*" "step over breakpoint"
> +
> +    gdb_test "clear 81" "No breakpoint at 81.*" \
> +       "clear line has no breakpoint disallowed"
> +
> +    gdb_test "clear" "No breakpoint at this line.*" \
> +       "clear current line has no breakpoint disallowed"
> +
> +    # Verify that we can set and clear multiple breakpoints.
> +    #
> +    # We don't test that it deletes the correct breakpoints.  We do at
> +    # least test that it deletes more than one breakpoint.
> +    #
> +    gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1"
> +    gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2"
> +    gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
> +}
> +
> +test_break_silent_and_more
> +
> +# Verify that a breakpoint can be set via a convenience variable.
> +
> +proc_with_prefix test_break_line_convenience_var {} {
> +    clean_restart break
> +
> +    if { ![runto_main] } {
> +       return
> +    }
> +
> +    gdb_test_no_output "set \$foo=$::bp_location11" \
> +       "set convenience variable \$foo to bp_location11"
> +
> +    gdb_test "break \$foo" \
> +       "Breakpoint (\[0-9\]*) at .*, line $::bp_location11.*"
> +
> +    # Verify that GDB responds gracefully to an attempt to set a
> +    # breakpoint via a convenience variable whose type is not integer.
> +
> +    gdb_test_no_output "set \$foo=81.5" \
> +       "set convenience variable \$foo to 81.5"
> +
> +    gdb_test "break \$foo" \
> +       "Convenience variables used in line specs must have integer
> values.*" \
> +       "non-integer convenience variable disallowed"
> +}
> +
> +test_break_line_convenience_var
> +
> +# Verify that we can set and trigger a breakpoint in a user-called
> function.
> +
> +proc_with_prefix test_break_user_call {} {
> +    clean_restart break
> +
> +    if { ![runto_main] } {
> +       return
> +    }
> +
> +    gdb_test "break marker2" \
> +       "Breakpoint (\[0-9\]*) at .*, line $::bp_location8.*" \
> +       "set breakpoint on to-be-called function"
> +
> +    gdb_test "print marker2(99)" \
> +       "The program being debugged stopped while in a function called
> from GDB.\r\nEvaluation of the expression containing the function\r\n.[func
> marker2]. will be abandoned.\r\nWhen the function is done executing, GDB
> will silently stop.*" \
> +       "hit breakpoint on called function"
> +
> +    # As long as we're stopped (breakpointed) in a called function,
> +    # verify that we can successfully backtrace & such from here.
> +    gdb_test "bt" \
> +       "#0\[ \t\]*($::hex in )?marker2.*:$::bp_location8\r\n#1\[
> \t\]*<function called from gdb>.*" \
> +       "backtrace while in called function"
> +
> +    # Return from the called function.  For remote targets, it's
> important to do
> +    # this before runto_main, which otherwise may silently stop on the
> dummy
> +    # breakpoint inserted by GDB at the program's entry point.
> +    #
> +    gdb_test_multiple "finish" "finish from called function" {
> +       -re "Run till exit from .*marker2.* at
> .*$::bp_location8\r\n.*function called from gdb.*$::gdb_prompt $" {
> +           pass "finish from called function"
> +       }
> +       -re "Run till exit from .*marker2.* at
> .*$::bp_location8\r\n.*Value returned.*$::gdb_prompt $" {
> +           pass "finish from called function"
> +       }
> +    }
> +}
> +
> +test_break_user_call
> +
> +# Verify that GDB responds gracefully to a "finish" command with
> +# arguments.
> +
> +proc_with_prefix test_finish_arguments {} {
> +    clean_restart break
> +
> +    if {![runto_main]} {
> +       return
> +    }
> +
> +    send_gdb "finish 123\n"
> +    gdb_expect {
> +      -re "The \"finish\" command does not take any
> arguments.\r\n$::gdb_prompt $"\
> +             {pass "finish with arguments disallowed"}
> +      -re "$::gdb_prompt $"\
> +             {fail "finish with arguments disallowed"}
> +      timeout {fail "(timeout) finish with arguments disallowed"}
> +    }
> +
> +    # Verify that GDB responds gracefully to a request to "finish" from
> +    # the outermost frame.  On a stub that never exits, this will just
> +    # run to the stubs routine, so we don't get this error...  Thus the
> +    # second condition.
> +    #
> +
> +    gdb_test_multiple "finish" "finish from outermost frame disallowed" {
> +       -re "\"finish\" not meaningful in the outermost
> frame.\r\n$::gdb_prompt $" {
> +           pass "finish from outermost frame disallowed"
> +       }
> +       -re "Run till exit from.*\r\n$::gdb_prompt $" {
> +           pass "finish from outermost frame disallowed"
> +       }
> +    }
> +}
> +
> +test_finish_arguments
> +
> +#********
> +
> +
> +#
> +# Test "next" over recursive function call.
> +#
> +
> +proc_with_prefix test_next_with_recursion {} {
> +    global gdb_prompt
> +    global decimal
> +    global binfile
> +
> +    gdb_test "kill" "" "kill program" "Kill the program being debugged.*y
> or n. $" "y"
> +    delete_breakpoints
> +
> +       set bp_location7a [gdb_get_line_number "set breakpoint 7a here"]
> +       gdb_test "break $bp_location7a" \
> +       "Breakpoint.*at.* file .*$::srcfile, line $bp_location7a\\." \
> +       "setting breakpoint at 7a"
> +
> +    # Run until we call factorial with 6
> +
> +    gdb_run_cmd
> +    gdb_test "" "Break.* factorial .value=6. .*" "run to factorial(6)"
> +
> +    # Continue until we call factorial recursively with 5.
> +
> +    gdb_test "continue" \
> +       "Continuing.*Break.* factorial .value=5. .*" \
> +       "continue to factorial(5)"
> +
> +    # Do a backtrace just to confirm how many levels deep we are.
> +
> +    gdb_test "backtrace" \
> +       "#0\[ \t\]+ factorial .value=5..*" \
> +       "backtrace from factorial(5)"
> +
> +    # Now a "next" should position us at the recursive call, which
> +    # we will be performing with 4.
> +
> +    gdb_test "next" \
> +       ".* factorial .value - 1.;.*" \
> +       "next to recursive call"
> +
> +    # Disable the breakpoint at the entry to factorial by deleting them
> all.
> +    # The "next" should run until we return to the next line from this
> +    # recursive call to factorial with 4.
> +    # Buggy versions of gdb will stop instead at the innermost frame on
> +    # the line where we are trying to "next" to.
> +
> +    delete_breakpoints
> +
> +    if [istarget "mips*tx39-*"] {
> +       set timeout 60
> +    }
> +    # We used to set timeout here for all other targets as well.  This
> +    # is almost certainly wrong.  The proper timeout depends on the
> +    # target system in use, and how we communicate with it, so there
> +    # is no single value appropriate for all targets.  The timeout
> +    # should be established by the Dejagnu config file(s) for the
> +    # board, and respected by the test suite.
> +    #
> +    # For example, if I'm running GDB over an SSH tunnel talking to a
> +    # portmaster in California talking to an ancient 68k board running
> +    # a crummy ROM monitor (a situation I can only wish were
> +    # hypothetical), then I need a large timeout.  But that's not the
> +    # kind of knowledge that belongs in this file.
> +
> +    gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \
> +           "next over recursive call"
> +
> +    # OK, we should be back in the same stack frame we started from.
> +    # Do a backtrace just to confirm.
> +
> +    gdb_test "backtrace" \
> +           "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+
> in factorial .value=6..*" \
> +           "backtrace from factorial(5.1)"
> +
> +    if { ![target_info exists gdb,noresults] } {
> +       gdb_continue_to_end "recursive next test"
> +    }
> +}
> +
> +test_next_with_recursion
> +
> +
> +#********
> +
> +# build a new file with optimization enabled so that we can try
> breakpoints
> +# on targets with optimized prologues
> +
> +if { [build_executable "failed to prepare" "breako2" {break.c break1.c}
> {debug nowarnings optimize=-O2}] } {
> +    return -1
> +}
> +
> +proc_with_prefix test_break_optimized_prologue {} {
> +    clean_restart breako2
> +
> +    # test break at function
> +    gdb_test "break -q main" \
> +       "Breakpoint.*at.* file .*, line.*" \
> +       "breakpoint function, optimized file"
> +
> +    # test break at function
> +    gdb_test "break marker4" \
> +       "Breakpoint.*at.* file .*$::srcfile1, line.*" \
> +       "breakpoint small function, optimized file"
> +
> +    # run until the breakpoint at main is hit. For non-stubs-using
> targets.
> +    gdb_run_cmd
> +
> +    set test "run until function breakpoint, optimized file"
> +    gdb_test_multiple "" $test {
> +       -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at
> .*$::srcfile:$::bp_location6.*$::bp_location6\[\t \]+\{ if .argc.*
> \{.*$::gdb_prompt $" {
> +           pass $test
> +       }
> +       -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$::gdb_prompt
> $" {
> +           pass "$test (code motion)"
> +       }
> +    }
> +
> +    # run until the breakpoint at a small function
> +    #
> +    # Add a second pass pattern.  The behavior differs here between stabs
> +    # and dwarf for one-line functions.  Stabs preserves two line symbols
> +    # (one before the prologue and one after) with the same line number,
> +    # but dwarf regards these as duplicates and discards one of them.
> +    # Therefore the address after the prologue (where the breakpoint is)
> +    # has no exactly matching line symbol, and GDB reports the breakpoint
> +    # as if it were in the middle of a line rather than at the beginning.
> +
> +    set bp_location14 [gdb_get_line_number "set breakpoint 14 here"
> $::srcfile1]
> +
> +    gdb_test_multiple "continue" \
> +       "run until breakpoint set at small function, optimized file" {
> +           -re "Breakpoint $::decimal, marker4 \\(d=(d@entry=)?177601976\\)
> at .*$::srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void
> marker4.*" {
> +               pass "run until breakpoint set at small function,
> optimized file (line bp_location14)"
> +           }
> +           -re "Breakpoint $::decimal, factorial \\(.*\\)
> .*\{\r\n$::gdb_prompt" {
> +               # GCC 4.3 emits bad line number information - see
> gcc/36748.
> +               if { [test_compiler_info "gcc-4-3-*"] } {
> +                   setup_xfail *-*-*
> +               }
> +               fail "run until breakpoint set at small function,
> optimized file"
> +           }
> +       }
> +}
> +
> +test_break_optimized_prologue
> +
> +# test that 'rbreak' on a symbol that may be from a shared library doesn't
> +# cause a "Junk at end of arguments." error.
> +#
> +# On x86 GNU/Linux, this test will choke on e.g. __libc_start_main@plt.
> +#
> +# Note that this test won't necessarily choke on all targets even if
> +# all the rbreak issue is present.  rbreak needs to match and set a
> +# breakpoint on a symbol causes 'break' to choke.
> +
> +proc_with_prefix test_rbreak_shlib {} {
> +    clean_restart breako2
> +
> +    gdb_test_no_output "set breakpoint pending on" "rbreak junk pending
> setup"
> +
> +    # We expect at least one breakpoint to be set when we "rbreak main".
> +    gdb_test "rbreak main" \
> +       ".*Breakpoint.*at.* file .*$::srcfile, line.*"
> +
> +    # Run to a breakpoint.  Fail if we see "Junk at end of arguments".
> +    gdb_run_cmd
> +
> +    gdb_test_multiple "" "rbreak junk" {
> +       -re -wrap "Junk at end of arguments.*" {
> +           fail $gdb_test_name
> +       }
> +       -re -wrap ".*Breakpoint \[0-9\]+,.*" {
> +           pass $gdb_test_name
> +       }
> +    }
> +}
> +
> +test_rbreak_shlib
> +
> +# Test break via convenience variable with file name
> +
> +proc_with_prefix test_break_file_line_convenience_var {} {
> +    clean_restart breako2
> +
> +    set line [gdb_get_line_number "set breakpoint 1 here"]
> +    gdb_test_no_output "set \$l = $line"
> +
> +    set line_actual "-1"
> +    set test "break $::srcfile:\$l"
> +    gdb_test_multiple "$test" $test {
> +       -re "Breakpoint $::decimal at $::hex: file .*break\\.c, line
> ($::decimal)\\.\r\n$::gdb_prompt $" {
> +           # Save the actual line number on which the breakpoint was
> +           # actually set. On some systems (Eg: Ubuntu 16.04 with GCC
> +           # version 5.4.0), that line gets completely inlined, including
> +           # the call to printf, and so we end up inserting the breakpoint
> +           # on one of the following lines instead.
> +           set line_actual $expect_out(1,string)
> +           pass $test
> +       }
> +    }
> +
> +    gdb_test_no_output "set \$foo=81.5" \
> +       "set convenience variable \$foo to 81.5"
> +    gdb_test "break $::srcfile:\$foo" \
> +       "Convenience variables used in line specs must have integer
> values.*" \
> +       "non-integer convenience variable disallowed"
> +}
> +
> +test_break_file_line_convenience_var
> +
> +# Test that commands can be cleared without error.
> +
> +proc_with_prefix test_break_commands_clear {} {
> +    clean_restart breako2
> +
> +    set line [gdb_get_line_number "set breakpoint 1 here"]
> +    gdb_breakpoint $line
> +
> +    gdb_test "commands\nprint 232323\nend" ">end" "set some breakpoint
> commands"
> +    gdb_test "commands\nend" ">end" "clear breakpoint commands"
> +
> +    # We verify that the commands were cleared by ensuring that the last
> +    # breakpoint's location ends the output -- if there were commands,
> +    # they would have been printed after the location.
> +    gdb_test "info break" "$::srcfile:$::decimal" "verify that they were
> cleared"
> +}
> +
> +test_break_commands_clear
> diff --git a/gdb/testsuite/gdb.mdebug/break1.c
> b/gdb/testsuite/gdb.mdebug/break1.c
> new file mode 100644
> index 00000000000..5382ec06fa9
> --- /dev/null
> +++ b/gdb/testsuite/gdb.mdebug/break1.c
> @@ -0,0 +1,59 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> +   Copyright 1992-2023 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.
> */
> +
> +/* The code for this file was extracted from the gdb testsuite
> +   testcase "break.c". */
> +
> +/* A structure we use for field name completion tests.  */
> +struct some_struct
> +{
> +  int a_field;
> +  int b_field;
> +  union { int z_field; };
> +};
> +
> +struct some_struct values[50];
> +
> +/* Some definitions for tag completion.  */
> +enum some_enum { VALUE };
> +
> +enum some_enum some_enum_global;
> +
> +union some_union
> +{
> +  int f1;
> +  double f2;
> +};
> +
> +union some_union some_union_global;
> +
> +/* A variable with a name "similar" to the above struct, to test that
> +   tag completion works ok.  */
> +int some_variable;
> +
> +/* The following functions do nothing useful.  They are included
> +   simply as places to try setting breakpoints at.  They are
> +   explicitly "one-line functions" to verify that this case works
> +   (some versions of gcc have or have had problems with this).
> +
> +   These functions are in a separate source file to prevent an
> +   optimizing compiler from inlining them and optimizing them away. */
> +
> +int marker1 (void) { return (0); }     /* set breakpoint 15 here */
> +int marker2 (int a) { return (1); }    /* set breakpoint 8 here */
> +void marker3 (char *a, char *b) {}     /* set breakpoint 17 here */
> +void marker4 (long d) { values[0].a_field = d; }       /* set breakpoint
> 14 here */
> diff --git a/gdb/testsuite/gdb.mdebug/info-types-c.exp
> b/gdb/testsuite/gdb.mdebug/info-types-c.exp
> new file mode 100644
> index 00000000000..d8c3abeade0
> --- /dev/null
> +++ b/gdb/testsuite/gdb.mdebug/info-types-c.exp
> @@ -0,0 +1,67 @@
> +# Copyright 2019-2023 Free Software Foundation, Inc.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +require {info exists MDEBUG}
> +
> +global testfile
> +global srcfile
> +global binfile
> +global subdir
> +global srcdir
> +global compile_flags
> +
> +standard_testfile info-types.c
> +
> +if {[prepare_for_testing "failed to prepare" \
> +     "${testfile}" $srcfile "debug c"]} {
> +return -1
> +}
> +
> +gdb_test_no_output "set auto-solib-add off"
> +
> +if ![runto_main] then {
> +return 0
> +}
> +
> +set file_re "File .*[string_to_regexp $srcfile]:"\
> +
> +set output_lines \
> +    [list \
> +        "^All defined types:" \
> +        ".*" \
> +        $file_re \
> +        "\[\t \]+typedef enum {\\.\\.\\.} anon_enum_t;" \
> +        "\[\t \]+typedef struct {\\.\\.\\.} anon_struct_t;" \
> +        "\[\t \]+typedef union {\\.\\.\\.} anon_union_t;" \
> +        "\[\t \]+typedef struct baz_t baz;" \
> +        "\[\t \]+typedef struct baz_t \\* baz_ptr;" \
> +        "\[\t \]+typedef struct baz_t baz_t;" \
> +        "\[\t \]+enum enum_t;" \
> +        "\[\t \]+typedef enum enum_t my_enum_t;" \
> +        "\[\t \]+typedef float my_float_t;" \
> +        "\[\t \]+typedef int my_int_t;" \
> +        "\[\t \]+typedef enum {\\.\\.\\.} nested_anon_enum_t;" \
> +        "\[\t \]+typedef struct {\\.\\.\\.} nested_anon_struct_t;" \
> +        "\[\t \]+typedef union {\\.\\.\\.} nested_anon_union_t;" \
> +        "\[\t \]+typedef struct baz_t nested_baz;" \
> +        "\[\t \]+typedef struct baz_t nested_baz_t;" \
> +        "\[\t \]+typedef enum enum_t nested_enum_t;" \
> +        "\[\t \]+typedef float nested_float_t;" \
> +        "\[\t \]+typedef int nested_int_t;" \
> +        "\[\t \]+typedef union union_t nested_union_t;" \
> +        "\[\t \]+union union_t;" \
> +        "($|\r\n.*)"]
> +
> +gdb_test_lines "info types" "" [multi_line {*}$output_lines]
> diff --git a/gdb/testsuite/gdb.mdebug/info-types.c
> b/gdb/testsuite/gdb.mdebug/info-types.c
> new file mode 100644
> index 00000000000..15a74b3016a
> --- /dev/null
> +++ b/gdb/testsuite/gdb.mdebug/info-types.c
> @@ -0,0 +1,116 @@
> +/* Copyright 2019-2023 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.
> */
> +
> +typedef int my_int_t;
> +typedef float my_float_t;
> +typedef my_int_t nested_int_t;
> +typedef my_float_t nested_float_t;
> +
> +struct baz_t
> +{
> +  float f;
> +  double d;
> +};
> +
> +typedef struct baz_t baz_t;
> +typedef struct baz_t baz;
> +typedef baz_t nested_baz_t;
> +typedef baz nested_baz;
> +typedef struct baz_t *baz_ptr;
> +
> +enum enum_t
> +{
> + AA, BB, CC
> +};
> +
> +typedef enum enum_t my_enum_t;
> +typedef my_enum_t nested_enum_t;
> +
> +typedef struct
> +{
> +  double d;
> +  float f;
> +} anon_struct_t;
> +
> +typedef anon_struct_t nested_anon_struct_t;
> +
> +typedef enum
> +{
> + DD, EE, FF
> +} anon_enum_t;
> +
> +typedef anon_enum_t nested_anon_enum_t;
> +
> +union union_t
> +{
> +  int i;
> +  float f;
> +};
> +
> +typedef union union_t nested_union_t;
> +
> +typedef union
> +{
> +  int i;
> +  double d;
> +} anon_union_t;
> +
> +typedef anon_union_t nested_anon_union_t;
> +
> +volatile int var_a;
> +volatile float var_b;
> +volatile my_int_t var_c;
> +volatile my_float_t var_d;
> +volatile nested_int_t var_e;
> +volatile nested_float_t var_f;
> +volatile struct baz_t var_g;
> +volatile baz_t var_h;
> +volatile baz var_i;
> +volatile nested_baz_t var_j;
> +volatile nested_baz var_k;
> +volatile baz_ptr var_l;
> +volatile enum enum_t var_m;
> +volatile my_enum_t var_n;
> +volatile nested_enum_t var_o;
> +volatile anon_struct_t var_p;
> +volatile nested_anon_struct_t var_q;
> +volatile anon_enum_t var_r;
> +volatile nested_anon_enum_t var_s;
> +volatile union union_t var_t;
> +volatile nested_union_t var_u;
> +volatile anon_union_t var_v;
> +volatile nested_anon_union_t var_w;
> +
> +#ifdef __cplusplus
> +
> +class CL
> +{
> +  int a;
> +};
> +
> +typedef CL my_cl;
> +typedef CL *my_ptr;
> +
> +volatile CL var_cpp_a;
> +volatile my_cl var_cpp_b;
> +volatile my_ptr var_cpp_c;
> +
> +#endif /* __cplusplus */
> +
> +int
> +main ()
> +{
> +  return 0;
> +}
> --
> 2.41.0
>
>

^ permalink raw reply	[relevance 15%]

* Re: [PATCH 3/4] gdb: Migrate frame unwinders to use C++ classes
  @ 2024-03-12 16:24  0%     ` Guinevere Larsen
  0 siblings, 0 replies; 200+ results
From: Guinevere Larsen @ 2024-03-12 16:24 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 08/03/2024 18:07, Tom Tromey wrote:
>>>>>> Guinevere Larsen <blarsen@redhat.com> writes:
>> Frame unwinders have historically been a structure populated with
>> callback pointers, so that architectures (or other specific unwinders)
>> could install their own way to handle the inferior. However, since
>> moving to c++, we could use polymorphism to get the same functionality
>> in a more readable way. Polymorphism also makes it simpler to add new
>> functionality to all frame unwinders, since all that's required is
>> adding it to the base class.
>> As part of the changes to add support to disabling frame unwinders,
>> this commit makes the first baby step in  using polymorphism for the
>> frame unwinders, by making frame_unwind a virtual class, and adds a
>> couple of new classes. The main class added is frame_unwind_legacy,
>> which works the same as the previous structs, using function pointers
>> as callbacks. This class was added to allow the transition to happen
>> piecemeal. New unwinders should instead follow the lead of the other
>> classes implemented.
>> 2 of the others, frame_unwind_python and frame_unwind_trampoline, were added
>> because it seemed simpler at the moment to do that instead of reworking
>> the dynamic allocation to work with the legacy class, and can be used as
>> an example to future implementations.
>>   /* AArch64 prologue unwinder.  */
>> -static frame_unwind aarch64_prologue_unwind =
>> -{
>> +static frame_unwind_legacy aarch64_prologue_unwind (
> Some of these should probably be 'const'...  not really your problem but
> the patch points it out.
Sure, I can do this.
>
>> +/* See frame-unwind.h.  */
>> +
>> +enum unwind_stop_reason
>> +frame_unwind::stop_reason (const frame_info_ptr &this_frame,
>> +			   void **this_prologue_cache) const
>> +{
>> +  return default_frame_unwind_stop_reason (this_frame, this_prologue_cache);
>> +}
>> +
> It looks like all of these methods here could just be inline in the
> header.
>
>> -struct frame_unwind
>> +class frame_unwind
>>   {
>> -  const char *name;
>> +private:
> class defaults to private.
>
>> +  frame_unwind (const char *n, frame_type t, frame_unwind_class c,
>> +		       const struct frame_data *d)
>> +    : m_name (n), m_type (t), m_unwinder_class (c), m_unwind_data (d) { }
> This looks weird.
Any specific reason why? If the problem is the single-letter parameters, 
I can change that (it was from an earlier iteration), but other than 
that, I'm not sure what you find weird in this.
>
>> +  /* Calculate the ID of the given frame using this unwinder.  */
>> +  virtual void this_id (const frame_info_ptr &this_frame,
>> +			void **this_prologue_cache,
>> +			struct frame_id *id) const
>> +  {
>> +    error (_("No method this_id implemented for unwinder %s"), m_name);
>> +  }
> Why not pure virtual?

not all classes have these methods defined, and if we make it pure 
virtual, all classes will need to implement them (or we get linker 
errors), so it seems easier to implement a base error in here.

>
>> +  frame_unwind_legacy (const char *n, frame_type t, frame_unwind_class c,
>> +		       frame_unwind_stop_reason_ftype *sr,
>> +		       frame_this_id_ftype *ti,
>> +		       frame_prev_register_ftype *pr,
>> +		       const struct frame_data *ud,
>> +		       frame_sniffer_ftype *s,
>> +		       frame_dealloc_cache_ftype *dc = nullptr,
>> +		       frame_prev_arch_ftype *pa = nullptr)
>> +  : frame_unwind (n, t, c, ud), stop_reason_p (sr),
>> +    this_id_p (ti), prev_register_p (pr), sniffer_p (s),
>> +    dealloc_cache_p (dc), prev_arch_p (pa) { }
> I wonder if making this constexpr would help avoid running a ton of
> constructors at startup time.
according to cppreference, constexpr constructors must not have virtual 
base classes, so unfortunately it isn't possible =/
>
> Alternatively maybe an approach would be to overload
> frame_unwind_append_unwinder to automatically instantiate the frame_unwind_legacy
> object given the C-style struct.  I think this would delay
> running the constructor until the gdbarch is initialized, which
> in many cases would be never.

I tried compiling without this patch to see what's GDB startup time, 
then checked the startup time with this patch. In my system, I can't see 
a difference in startup time with the "time" command (so 0.01s precision).

I could try to find a way to delay instantiation to when the unwinder is 
installed, so we avoid unnecessary constructor calls.

>> +	  = obstack_new<frame_unwind_python>
>> +	    (gdbarch_obstack(newarch), (const struct frame_data *) newarch);
>> +
> I think it's better to derive from allocate_on_obstack instead.  This
> helps prevent errors.
I am only allocating things on the obstack because I couldn't figure out 
a better solution to dynamically allocate the unwinder in a way that 
wouldn't leak the memory if gdbarch was de-allocated. If you are dead 
set on delaying constructing the objects at startup, I would probably 
make gdbarch store unique_ptrs instead of raw pointers, or some other 
similar thing.
>
> Also a missing space.
>
> Tom
>

-- 
Cheers,
Guinevere Larsen
She/Her/Hers


^ permalink raw reply	[relevance 0%]

* Re: [PATCH 2/2] [gdb/tdep] Fix gdb.base/watch-bitfields.exp on aarch64
  @ 2024-03-12 16:01  0%     ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-03-12 16:01 UTC (permalink / raw)
  To: Luis Machado, gdb-patches

On 3/7/24 13:11, Luis Machado wrote:
> Hi Tom,
> 
> On 2/20/24 20:54, Tom de Vries wrote:
>> On aarch64-linux, with test-case gdb.base/watch-bitfields.exp I run into:
>> ...
>> (gdb) continue^M
>> Continuing.^M
>> ^M
>> Hardware watchpoint 2: -location q.a^M
>> ^M
>> Old value = 1^M
>> New value = 0^M
>> main () at watch-bitfields.c:42^M
>> 42        q.h--;^M
>> (gdb) FAIL: $exp: -location watch against bitfields: q.e: 0->5: continue
>> ...
> 
> 
> Unfortunately I don't see the same failure on a graviton (aarch64). It is usually how these
> hardware watchpoint issues go. Things behave differently depending on the setup you
> have, since the reported trap address may be different.
> 
>>
>> In a minimal form, if we step past line 37 which sets q.e, and we have a
>> watchpoint set on q.e, it triggers:
>> ...
>> $ gdb -q -batch watch-bitfields -ex "b 37" -ex run -ex "watch q.e" -ex step
>> Breakpoint 1 at 0x410204: file watch-bitfields.c, line 37.
>>
>> Breakpoint 1, main () at watch-bitfields.c:37
>> 37        q.e = 5;
>> Hardware watchpoint 2: q.e
>>
>> Hardware watchpoint 2: q.e
>>
>> Old value = 0
>> New value = 5
>> main () at /home/vries/gdb/src/gdb/testsuite/gdb.base/watch-bitfields.c:38
>> 38        q.f = 6;
>> ...
>>
>> However, if we set in addition a watchpoint on q.a, the watchpoint on q.e
>> doesn't trigger.
>>
>> How does this happen?
>>
>> Bitfield q.a is just bit 0 of byte 0, and bitfield q.e is bit 4..7 of byte 1
>> and bit 1 of byte 2.  So, watch q.a should watch byte 0, and watch q.e should
>> watch bytes 1 and 2.
>>
>> Using "maint set show-debug-regs on" (and some more detailed debug prints) we
>> get:
>> ...
>> WP2: addr=0x440028 (orig=0x440029), ctrl=0x000000d5, ref.count=1
>>    ctrl: enabled=1, offset=1, len=2
>> WP3: addr=0x440028 (orig=0x440028), ctrl=0x00000035, ref.count=1
>>    ctrl: enabled=1, offset=0, len=1
>> ...
>> which matches that.
>>
>> When executing line 37, a hardware watchpoint trap triggers and we hit
>> aarch64_stopped_data_address with addr_trap == 0x440028:
>> ...
>> (gdb) p /x addr_trap
>> $1 = 0x440028
>> ....
>> and since the loop in aarch64_stopped_data_address walks backward, we check
>> WP3 first, which matches, and consequently target_stopped_by_watchpoint
>> returns true in watchpoints_triggered.
>>
>> Likewise for target_stopped_data_address, which also returns addr == 0x440028.
>> Watchpoints_triggered matches watchpoint q.a to that address, and sets
>> watch_triggered_yes.
>>
>> However, subsequently the value of q.a is checked, and it's the same value as
>> before (becase the insn in line 37 didn't change q.a), so the watchpoint
>> hardware trap is not reported to the user.
>>
>> The problem originates from that fact that aarch64_stopped_data_address picked
>> WP3 instead of WP2.
>>
>> There's something we can do about this.  In the example above, both
>> target_stopped_by_watchpoint and target_stopped_data_address returned true.
>> Instead we can return true in target_stopped_by_watchpoint but false in
>> target_stopped_data_address.  This lets watchpoints_triggered known that a
>> watchpoint was triggered, but we don't know where, and both watchpoints
>> get set to watch_triggered_unknown.
>>
>> Subsequently, the values of both q.a and q.e are checked, and since q.e is not
>> the same value as before, the watchpoint hardware trap is reported to the user.
>>
>> Note that this works well for regular (write) watchpoints (watch command), but
>> not for read watchpoints (rwatch command), because for those no value is
>> checked.  Likewise for access watchpoints (awatch command).
>>
>> So, fix this by:
>> - passing a nullptr in aarch64_fbsd_nat_target::stopped_by_watchpoint and
>>    aarch64_linux_nat_target::stopped_by_watchpoint to make clear we're not
>>    interested in the stop address,
>> - introducing a two-phase approach in aarch64_stopped_data_address, where:
>>    - phase one handles access and read watchpoints, as before, and
>>    - phase two handles write watchpoints, where multiple matches cause:
>>      - return true if addr_p == null, and
>>      - return false if addr_p != null.
> 
> 
> To make sure I understand the approach, does the case where we have a write hardware watchpoint
> and addr_p != null (thus returning false for aarch64_stopped_data_address) mean we don't report
> any stopped data addresses, but we will still report a hardware watchpoint trigger internally and
> remove said hardware watchpoints before attempting to step-over them?
> 

Hi Luis,

thanks for the review.

So, we're talking about the situation that:
- target_stopped_by_watchpoint () == true, and
- target_stopped_data_address () == false.

If you look for the uses of target_stopped_data_address, there are only 
two, with one in infrun for debugging purposes, so the only real use is 
in watchpoints_triggered.

That one returns 1 if target_stopped_by_watchpoint () == true, 
regardless of target_stopped_data_address, and that's what causes 
stopped_by_watchpoint to be set to 1 in handle_signal_stop, which does 
al the processing related to stepping over watchpoints.

The only thing that target_stopped_data_address influences is the 
watch_triggered_{no,yes,unknown} state of individual watchpoints.

So, I think the answer to your question is yes.

> I think one of the more critical issues is gdb getting stuck on hardware watchpoint triggers it is
> not noticing, thus causing an endless loop of trying to step-over them and failing.
> 
>>
>> Tested on aarch64-linux.
>> ---
>>   gdb/aarch64-fbsd-nat.c     |   4 +-
>>   gdb/aarch64-linux-nat.c    |   4 +-
>>   gdb/aarch64-nat.c          | 133 ++++++++++++++++++++++++++-----------
>>   gdb/nat/aarch64-hw-point.c |  25 +++++++
>>   gdb/nat/aarch64-hw-point.h |   2 +
>>   5 files changed, 123 insertions(+), 45 deletions(-)
>>
>> diff --git a/gdb/aarch64-fbsd-nat.c b/gdb/aarch64-fbsd-nat.c
>> index d7aa819023b..89ed12bb8e5 100644
>> --- a/gdb/aarch64-fbsd-nat.c
>> +++ b/gdb/aarch64-fbsd-nat.c
>> @@ -164,9 +164,7 @@ aarch64_fbsd_nat_target::stopped_data_address (CORE_ADDR *addr_p)
>>   bool
>>   aarch64_fbsd_nat_target::stopped_by_watchpoint ()
>>   {
>> -  CORE_ADDR addr;
>> -
>> -  return stopped_data_address (&addr);
>> +  return stopped_data_address (nullptr);
>>   }
>>   
>>   /* Implement the "stopped_by_hw_breakpoint" target_ops method.  */
>> diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
>> index 11a41e1afae..7dc53ff9e91 100644
>> --- a/gdb/aarch64-linux-nat.c
>> +++ b/gdb/aarch64-linux-nat.c
>> @@ -972,9 +972,7 @@ aarch64_linux_nat_target::stopped_data_address (CORE_ADDR *addr_p)
>>   bool
>>   aarch64_linux_nat_target::stopped_by_watchpoint ()
>>   {
>> -  CORE_ADDR addr;
>> -
>> -  return stopped_data_address (&addr);
>> +  return stopped_data_address (nullptr);
>>   }
>>   
>>   /* Implement the "can_do_single_step" target_ops method.  */
>> diff --git a/gdb/aarch64-nat.c b/gdb/aarch64-nat.c
>> index 5d7d2be2827..9e859cf28cc 100644
>> --- a/gdb/aarch64-nat.c
>> +++ b/gdb/aarch64-nat.c
>> @@ -231,47 +231,102 @@ bool
>>   aarch64_stopped_data_address (const struct aarch64_debug_reg_state *state,
>>   			      CORE_ADDR addr_trap, CORE_ADDR *addr_p)
>>   {
>> -  int i;
>> -
>> -  for (i = aarch64_num_wp_regs - 1; i >= 0; --i)
>> -    {
>> -      const unsigned int offset
>> -	= aarch64_watchpoint_offset (state->dr_ctrl_wp[i]);
>> -      const unsigned int len = aarch64_watchpoint_length (state->dr_ctrl_wp[i]);
>> -      const CORE_ADDR addr_watch = state->dr_addr_wp[i] + offset;
>> -      const CORE_ADDR addr_watch_aligned
>> -	= align_down (state->dr_addr_wp[i], 16);
>> -      const CORE_ADDR addr_orig = state->dr_addr_orig_wp[i];
>> -
>> -      if (state->dr_ref_count_wp[i]
>> -	  && DR_CONTROL_ENABLED (state->dr_ctrl_wp[i])
>> -	  && addr_trap >= addr_watch_aligned
>> -	  && addr_trap < addr_watch + len)
>> -	{
>> -	  /* ADDR_TRAP reports the first address of the memory range
>> -	     accessed by the CPU, regardless of what was the memory
>> -	     range watched.  Thus, a large CPU access that straddles
>> -	     the ADDR_WATCH..ADDR_WATCH+LEN range may result in an
>> -	     ADDR_TRAP that is lower than the
>> -	     ADDR_WATCH..ADDR_WATCH+LEN range.  E.g.:
>> -
>> -	     addr: |   4   |   5   |   6   |   7   |   8   |
>> -				   |---- range watched ----|
>> -		   |----------- range accessed ------------|
>> -
>> -	     In this case, ADDR_TRAP will be 4.
>> -
>> -	     To match a watchpoint known to GDB core, we must never
>> -	     report *ADDR_P outside of any ADDR_WATCH..ADDR_WATCH+LEN
>> -	     range.  ADDR_WATCH <= ADDR_TRAP < ADDR_ORIG is a false
>> -	     positive on kernels older than 4.10.  See PR
>> -	     external/20207.  */
>> +  bool found = false;
>> +  for (int phase = 0; phase <= 1; ++phase)
>> +    for (int i = aarch64_num_wp_regs - 1; i >= 0; --i)
>> +      {
>> +	if (!(state->dr_ref_count_wp[i]
>> +	      && DR_CONTROL_ENABLED (state->dr_ctrl_wp[i])))
>> +	  {
>> +	    /* Watchpoint disabled.  */
>> +	    continue;
>> +	  }
>> +
>> +	const enum target_hw_bp_type type
>> +	  = aarch64_watchpoint_type (state->dr_ctrl_wp[i]);
>> +	if (type == hw_execute)
>> +	  {
>> +	    /* Watchpoint disabled.  */
>> +	    continue;
>> +	  }
>> +
>> +	if (phase == 0)
>> +	  {
>> +	    /* Phase 0: No hw_write.  */
>> +	    if (type == hw_write)
>> +	      continue;
>> +	  }
>> +	else
>> +	  {
>> +	    /* Phase 1: Only hw_write.  */
>> +	    if (type != hw_write)
>> +	      continue;
>> +	  }
>> +
>> +	const unsigned int offset
>> +	  = aarch64_watchpoint_offset (state->dr_ctrl_wp[i]);
>> +	const unsigned int len
>> +	  = aarch64_watchpoint_length (state->dr_ctrl_wp[i]);
>> +	const CORE_ADDR addr_watch = state->dr_addr_wp[i] + offset;
>> +	const CORE_ADDR addr_watch_aligned
>> +	  = align_down (state->dr_addr_wp[i], 16);
>> +	const CORE_ADDR addr_orig = state->dr_addr_orig_wp[i];
>> +
>> +	/* ADDR_TRAP reports the first address of the memory range
>> +	   accessed by the CPU, regardless of what was the memory
>> +	   range watched.  Thus, a large CPU access that straddles
>> +	   the ADDR_WATCH..ADDR_WATCH+LEN range may result in an
>> +	   ADDR_TRAP that is lower than the
>> +	   ADDR_WATCH..ADDR_WATCH+LEN range.  E.g.:
>> +
>> +	   addr: |   4	 |   5	 |   6	 |   7	 |   8	 |
>> +				 |---- range watched ----|
>> +		 |----------- range accessed ------------|
>> +
>> +	   In this case, ADDR_TRAP will be 4.  */
>> +	if (!(addr_trap >= addr_watch_aligned
>> +	      && addr_trap < addr_watch + len))
>> +	  {
>> +	    /* Not a match.  */
>> +	    continue;
>> +	  }
>> +
>> +	/* To match a watchpoint known to GDB core, we must never
>> +	   report *ADDR_P outside of any ADDR_WATCH..ADDR_WATCH+LEN
>> +	   range.  ADDR_WATCH <= ADDR_TRAP < ADDR_ORIG is a false
>> +	   positive on kernels older than 4.10.  See PR
>> +	   external/20207.  */
>> +	if (addr_p != nullptr)
>>   	  *addr_p = addr_orig;
>> -	  return true;
>> -	}
>> -    }
>>   
>> -  return false;
>> +	if (phase == 0)
>> +	  {
>> +	    /* Phase 0: Return first match.  */
>> +	    return true;
>> +	  }
>> +
>> +	/* Phase 1.  */
>> +	if (addr_p == nullptr)
>> +	  {
>> +	    /* First match, and we don't need to report an address.  No need
>> +	       to look for other matches.  */
>> +	    return true;
>> +	  }
>> +
>> +	if (!found)
>> +	  {
>> +	    /* First match, and we need to report an address.  Look for other
>> +	       matches.  */
>> +	    found = true;
>> +	    continue;
>> +	  }
>> +
>> +	/* More that one match, and we need to return an address.  No need to
> 
> 
> s/More that/More than
> 

Fixed.

>> +	   look for further matches.  */
>> +	return false;
>> +      }
>> +
>> +  return found;
>>   }
>>   
>>   /* Define AArch64 maintenance commands.  */
>> diff --git a/gdb/nat/aarch64-hw-point.c b/gdb/nat/aarch64-hw-point.c
>> index 04674dea2a6..08fd230b71f 100644
>> --- a/gdb/nat/aarch64-hw-point.c
>> +++ b/gdb/nat/aarch64-hw-point.c
>> @@ -73,6 +73,31 @@ aarch64_watchpoint_length (unsigned int ctrl)
>>     return retval;
>>   }
>>   
>> +/* Utility function that returns the type of a watchpoint according to the
>> +   content of a hardware debug control register CTRL.  */
>> +
>> +enum target_hw_bp_type
>> +aarch64_watchpoint_type (unsigned int ctrl)
>> +{
>> +  unsigned int type = DR_CONTROL_TYPE (ctrl);
>> +
>> +  switch (type)
>> +    {
>> +    case 1:
>> +      return hw_read;
>> +    case 2:
>> +      return hw_write;
>> +    case 3:
>> +      return hw_access;
>> +    case 0:
>> +      /* Reserved for a watchpoint.  It must behave as if the watchpoint is
>> +	 disabled.  */
>> +      return hw_execute;
>> +    default:
>> +      gdb_assert_not_reached ("");
>> +    }
>> +}
>> +
>>   /* Given the hardware breakpoint or watchpoint type TYPE and its
>>      length LEN, return the expected encoding for a hardware
>>      breakpoint/watchpoint control register.  */
>> diff --git a/gdb/nat/aarch64-hw-point.h b/gdb/nat/aarch64-hw-point.h
>> index 70f71db7520..bdcca932e57 100644
>> --- a/gdb/nat/aarch64-hw-point.h
>> +++ b/gdb/nat/aarch64-hw-point.h
>> @@ -73,6 +73,7 @@
>>   
>>   #define DR_CONTROL_ENABLED(ctrl)	(((ctrl) & 0x1) == 1)
>>   #define DR_CONTROL_MASK(ctrl)		(((ctrl) >> 5) & 0xff)
>> +#define DR_CONTROL_TYPE(ctrl)		(((ctrl) >> 3) & 0x3)
>>   
>>   /* Structure for managing the hardware breakpoint/watchpoint resources.
>>      DR_ADDR_* stores the address, DR_CTRL_* stores the control register
>> @@ -107,6 +108,7 @@ void aarch64_notify_debug_reg_change (ptid_t ptid, int is_watchpoint,
>>   
>>   unsigned int aarch64_watchpoint_offset (unsigned int ctrl);
>>   unsigned int aarch64_watchpoint_length (unsigned int ctrl);
>> +enum target_hw_bp_type aarch64_watchpoint_type (unsigned int ctrl);
>>   
>>   int aarch64_handle_breakpoint (enum target_hw_bp_type type, CORE_ADDR addr,
>>   			       int len, int is_insert, ptid_t ptid,
> 
> I think this is a reasonable workaround for this situation you describe. Testing on my end doesn't
> seem to cause any issues, so I think this is OK.
> 

Thanks, I'll commit shortly.

> Out of curiosity, what is your aarch64 setup where you can reproduce this failure?
> 

M1 macbook air with fedora asahi remix, and M1 mac mini with debian 
trixie (on the compile farm, as mentioned earlier).

Thanks,
- Tom

> Approved-By: Luis Machado <luis.machado@arm.com>


^ permalink raw reply	[relevance 0%]

* [PATCH 2/2] contrib: sync dg-extract-results.sh with GCC
  @ 2024-03-11 20:57  4% ` Sam James
  0 siblings, 0 replies; 200+ results
From: Sam James @ 2024-03-11 20:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: binutils, Sam James

This syncs dg-extract-results.sh with GCC.

It contains two commits: r14-4333-g346f5991569fae and r14-9393-g64273a7e6bd8ba.

contrib/ChangeLog:
	* dg-extract-results.sh: Sync with GCC.
---
 contrib/ChangeLog             |  1 +
 contrib/dg-extract-results.sh | 21 ++++++++++++---------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/contrib/ChangeLog b/contrib/ChangeLog
index 369bcc5bee2..e5c54c330f4 100644
--- a/contrib/ChangeLog
+++ b/contrib/ChangeLog
@@ -1,6 +1,7 @@
 2024-03-11  Sam James  <sam@gentoo.org>
 
 	* dg-extract-results.py: Sync with GCC.
+	* dg-extract-results.sh: Sync with GCC.
 
 2020-09-25  Simon Marchi  <simon.marchi@polymtl.ca>
 
diff --git a/contrib/dg-extract-results.sh b/contrib/dg-extract-results.sh
index ff6c50d029c..539d596a89d 100755
--- a/contrib/dg-extract-results.sh
+++ b/contrib/dg-extract-results.sh
@@ -6,7 +6,7 @@
 # The resulting file can be used with test result comparison scripts for
 # results from tests that were run in parallel.  See usage() below.
 
-# Copyright (C) 2008, 2009, 2010, 2012 Free Software Foundation
+# Copyright (C) 2008-2024 Free Software Foundation, Inc.
 # Contributed by Janis Johnson <janis187@us.ibm.com>
 #
 # This file is part of GCC.
@@ -28,14 +28,17 @@
 
 PROGNAME=dg-extract-results.sh
 
-# Try to use the python version if possible, since it tends to be faster.
+# Try to use the python version if possible, since it tends to be faster and
+# produces more stable results.
 PYTHON_VER=`echo "$0" | sed 's/sh$/py/'`
-if test "$PYTHON_VER" != "$0" &&
-   test -f "$PYTHON_VER" &&
-   python -c 'import sys, getopt, re, io, datetime, operator; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \
-     > /dev/null 2> /dev/null; then
-  exec python $PYTHON_VER "$@"
-fi
+for python in python3 python python2 ; do
+  if test "$PYTHON_VER" != "$0" &&
+     test -f "$PYTHON_VER" &&
+     ${python} -c 'import sys, getopt, re, io, datetime, operator; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \
+       > /dev/null 2> /dev/null; then
+    exec ${python} $PYTHON_VER "$@"
+  fi
+done
 
 usage() {
   cat <<EOF >&2
@@ -271,7 +274,7 @@ cat $SUM_FILES \
 
 # Write the begining of the combined summary file.
 
-head -n 2 $FIRST_SUM
+head -n 3 $FIRST_SUM
 echo
 echo "		=== $TOOL tests ==="
 echo
-- 
2.44.0


^ permalink raw reply	[relevance 4%]

* Re: [PATCH v4 6/6] gdb/testsuite: Add kfail in gdb.threads/threadcrash.exp on 32-bit arm targets
  @ 2024-03-11 18:10  0%         ` Thiago Jung Bauermann
  0 siblings, 0 replies; 200+ results
From: Thiago Jung Bauermann @ 2024-03-11 18:10 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches


Hello Tom,

Tom de Vries <tdevries@suse.de> writes:
> On 3/9/24 00:57, Thiago Jung Bauermann wrote:
>>> On 3/8/24 10:33, Tom de Vries wrote:
>>>
>>> Thiago, you mentioned you could reproduce the problem, can you check whether this catches
>>> it?
>> I applied the patch series plus the fixup above to upstream commit
>> 2755241d02d7 ("Add return value to DAP scope"), and I actually can't
>> reproduce the problem anymore, not sure why. The threads' backtraces
>> look reasonable. The only "??" are in linux/arm/clone.S:74 from
>> libc.so.6.
>> I put the gdb.log here, if there's interest:
>> https://people.linaro.org/~thiago.bauermann/gdb-pr-31294/gdb.log
>
> thanks for checking.
>
> Ideally, we need to either:
> - confirm that the problem still exists, and test and commit the kfail,
>   or
> - confirm that the problem doesn't exist, drop the kfail patch and close
>   the PR.
>
> So, can you try to confirm one or the other, f.i. going back to an earlier commit where
> you were able to reproduce the problem, running in a loop, try with/without debug info,
> etc.  AFAIU, you're the only one who can do this because the behaviour hasn't been spotted
> outside linaro.

Yes, of course. I'll see what's going on and determine whether the
problem has really been fixed.

> I went ahead and committed the series apart from this patch, which reflects that
> situation.

Thank you!

--
Thiago

^ permalink raw reply	[relevance 0%]

* [PATCH] Sync libbacktrace from gcc [PR31327]
@ 2024-03-11 17:21  2% Sam James
  0 siblings, 0 replies; 200+ results
From: Sam James @ 2024-03-11 17:21 UTC (permalink / raw)
  To: gdb-patches; +Cc: binutils, Sam James

Note that this includes Nick's fix from edf64cd235f5ecb3725e7cf1ff83bbdb6dd53340 which
landed upstream a bit differently as r13-1566-g9ed57796235abc in GCC.

This pulls in libbacktrace as of r14-9404-gc775a030af9cad in GCC trunk.
---
 libbacktrace/ChangeLog                        |  279 +-
 libbacktrace/Makefile.am                      |  124 +-
 libbacktrace/Makefile.in                      |  379 ++-
 libbacktrace/README                           |   32 +-
 libbacktrace/alloc.c                          |    2 +-
 libbacktrace/allocfail.c                      |    2 +-
 libbacktrace/allocfail.sh                     |    2 +-
 libbacktrace/atomic.c                         |    2 +-
 libbacktrace/backtrace-supported.h.in         |    2 +-
 libbacktrace/backtrace.c                      |    2 +-
 libbacktrace/backtrace.h                      |    2 +-
 libbacktrace/btest.c                          |    2 +-
 libbacktrace/config.h.in                      |   13 +
 libbacktrace/configure                        |  276 +-
 libbacktrace/configure.ac                     |   57 +-
 libbacktrace/dwarf.c                          |  124 +-
 libbacktrace/edtest.c                         |    2 +-
 libbacktrace/edtest2.c                        |    2 +-
 libbacktrace/elf.c                            | 2997 +++++++++++++++--
 libbacktrace/fileline.c                       |   77 +-
 .../install-debuginfo-for-buildid.sh.in       |    2 +-
 libbacktrace/instrumented_alloc.c             |    2 +-
 libbacktrace/internal.h                       |   11 +-
 libbacktrace/macho.c                          |    4 +-
 libbacktrace/mmap.c                           |    2 +-
 libbacktrace/mmapio.c                         |    2 +-
 libbacktrace/mtest.c                          |    2 +-
 libbacktrace/nounwind.c                       |    2 +-
 libbacktrace/pecoff.c                         |   26 +-
 libbacktrace/posix.c                          |    2 +-
 libbacktrace/print.c                          |    2 +-
 libbacktrace/read.c                           |    2 +-
 libbacktrace/simple.c                         |    2 +-
 libbacktrace/sort.c                           |    2 +-
 libbacktrace/state.c                          |    2 +-
 libbacktrace/stest.c                          |    2 +-
 libbacktrace/test_format.c                    |    2 +-
 libbacktrace/testlib.c                        |    2 +-
 libbacktrace/testlib.h                        |    2 +-
 libbacktrace/ttest.c                          |    2 +-
 libbacktrace/unittest.c                       |    2 +-
 libbacktrace/unknown.c                        |    2 +-
 libbacktrace/xcoff.c                          |    2 +-
 libbacktrace/xztest.c                         |    2 +-
 libbacktrace/ztest.c                          |    2 +-
 45 files changed, 3976 insertions(+), 487 deletions(-)

diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog
index 14df45e7072..5f131146882 100644
--- a/libbacktrace/ChangeLog
+++ b/libbacktrace/ChangeLog
@@ -1,7 +1,278 @@
-2023-01-12  Nick Clifton  <nickc@redhat.com>
+2024-03-08  Ian Lance Taylor  <iant@golang.org>
 
-	* Makefile.am (CLEANFILES): Import patch from upstream to prevent
-	allocafail.sh from being removed when running 'make clean'.
+	* elf.c (elf_uncompress_chdr): Don't assume compressed section is
+	aligned.
+
+2024-03-02  Ian Lance Taylor  <iant@golang.org>
+
+	* Makefile.am (libbacktrace_testing_ldflags): Define.
+	(*_LDFLAGS): Add $(libbacktrace_testing_ldflags) for test
+	programs.
+	* Makefile.in: Regenerate
+
+2024-03-02  Ian Lance Taylor  <iant@golang.org>
+
+	* elf.c (elf_uncompress_lzma_block): Skip all header padding bytes
+	and verify that they are zero.
+
+2024-03-02  Ian Lance Taylor  <iant@golang.org>
+
+	PR libbacktrace/114201
+	* elf.c (elf_add): Add caller_opd parameter.  Change all callers.
+	Release opd data after all recursive calls.
+
+2024-03-01  Ian Lance Taylor  <iant@golang.org>
+
+	* elf.c (elf_add): Add the symbol table from a debuginfo file.
+	* Makefile.am (MAKETESTS): Add buildidfull and gnudebuglinkfull
+	variants of buildid and gnudebuglink tests.
+	(%_gnudebuglinkfull, %_buildidfull): New patterns.
+	* Makefile.in: Regenerate.
+
+2023-11-30  Ian Lance Taylor  <iant@golang.org>
+
+	* pecoff.c: Include <windows.h> if available.
+	(coff_add): On Windows call GetModuleHandle to get base address.
+
+2023-11-29  Ian Lance Taylor  <iant@golang.org>
+
+	* fileline.c: Include <windows.h> if available.
+	(windows_get_executable_path): New static function.
+	(fileline_initialize): Call windows_get_executable_path.
+	* configure.ac: Checked for windows.h
+	* configure: Regenerate.
+	* config.h.in: Regenerate.
+
+2023-10-22  Iain Sandoe  <iain@sandoe.co.uk>
+
+	* configure: Regenerate.
+	* configure.ac: Handle Darwin rpaths.
+
+2023-08-07  Nick Alcock  <nick.alcock@oracle.com>
+
+	* configure: Regenerate.
+
+2023-08-07  Alexander von Gluck IV  <kallisti5@unixzen.com>
+
+	* configure: Regenerate.
+
+2023-08-07  Nick Alcock  <nick.alcock@oracle.com>
+
+	* configure: Regenerate.
+
+2023-08-07  Nick Alcock  <nick.alcock@oracle.com>
+
+	* configure: Regenerate.
+
+2023-08-07  H.J. Lu  <hjl.tools@gmail.com>
+
+	* configure: Regenerate.
+
+2023-08-07  H.J. Lu  <hjl.tools@gmail.com>
+
+	* configure: Regenerate.
+
+2023-08-03  Richard Biener  <rguenther@suse.de>
+
+	* zstdtest.c (test_samples): Properly compute the allocation
+	size for the uncompressed data.
+
+2023-07-31  Ian Lance Taylor  <iant@golang.org>
+
+	* configure.ac: Check for _pgmptr declaration.
+	* fileline.c (fileline_initialize): Check for _pgmfptr before
+	/proc/self/exec.
+	* configure, config.h.in: Regenerate.
+
+2023-03-28  Ian Lance Taylor  <iant@golang.org>
+
+	* elf.c (elf_zstd_read_fse): Call elf_fetch_bits after reading
+	bits, not before.  Add unlikely for error case.
+	(elf_zstd_offset_table): Regenerate.
+	(elf_zstd_read_huff): Clear 13 entries in weight_mark, not 12.
+	(elf_zstd_read_literals): For a single stream adjust by
+	total_streams_size, not compressed_size.
+
+2023-01-20  Ian Lance Taylor  <iant@golang.org>
+
+	* dwarf.c (struct function_addrs): Change low and high fields to
+	uintptr_t.
+	(struct unit_addrs): Likewise.
+	(resolve_addr_index): Change address parameter to uintptr_t*.
+	(add_unit_addr): Change lowpc and highpc parameters to uintptr_t.
+	(add_function_range): Likewise.
+	(struct pcrange): Change lowpc and highpc fields to uintptr_t.
+	(add_low_high_range): Change add_range lowpc and highpc parameters
+	to uintptr_t.
+	(add_ranges_from_ranges): Likewise.
+	(add_ranges_from_rnglists): Likewise.
+	(add_low_high_range): Chnage lowpc and highpc variables to
+	uintpr_t.
+	(add_ranges_from_rnglists): Change some local variables to
+	uintptr_t.
+	(add_ranges_from_ranges): Change base parameter to uintptr_t.
+	(add_ranges_from_rnglists): Likewise.
+	(read_function_entry): Likewise.
+	(resolve_addr_index): Add explicit casts to uintptr_t.
+	(update_pcrange): Likewise.
+	(add_ranges_from_ranges): Likewise.
+	(add_ranges_from_rnglists): Likewise.
+	(read_function_entry): Likewise.
+
+2023-01-17  Martin Liska  <mliska@suse.cz>
+
+	* Makefile.in: Regenerate.
+
+2023-01-06  Ian Lance Taylor  <iant@golang.org>
+
+	PR libbacktrace/108297
+	* configure.ac: Test whether linker supports --build-id.
+	* Makefile.am: Only run --build-id tests if supported.
+	* configure, Makefile.in: Regenerate.
+
+2022-12-17  Ian Lance Taylor  <iant@golang.org>
+
+	* elf.c (elf_fetch_backward_init): New static function.
+	(ZSTD_TABLE_SIZE): Use huffman scratch space size rather than
+	literal size.
+	(ZSTD_TABLE_WORK_LIT_SIZE): Don't define.
+	(elf_zstd_read_huff): Use elf_fetch_backward_init.
+	(elf_zstd_read_literals): New static function.
+	(ZSTD_LIT_RAW, ZSTD_LIT_RLE, ZSTD_LIT_HUFF): Don't define.
+	(struct elf_zstd_literals): Don't define.
+	(elf_zstd_literal_output): Remove static function.
+	(elf_zstd_decompress): Use elf_fetch_backward_init and
+	elf_zstd_read_literals.  Rewrite literal copying.<
+
+2022-12-10  Ian Lance Taylor  <iant@golang.org>
+
+	* elf.c (ZSTD_TABLE_*): Use elf_zstd_fse_baseline_entry.
+	(ZSTD_ENCODE_BASELINE_BITS): Define.
+	(ZSTD_DECODE_BASELINE, ZSTD_DECODE_BASEBITS): Define.
+	(elf_zstd_literal_length_base): New static const array.
+	(elf_zstd_match_length_base): Likewise.
+	(struct elf_zstd_fse_baseline_entry): Define.
+	(elf_zstd_make_literal_baseline_fse): New static function.
+	(elf_zstd_make_offset_baseline_fse): Likewise.
+	(elf_zstd_make_match_baseline_fse): Likewise.
+	(print_table, main): Use elf_zstd_fse_baseline_entry.
+	(elf_zstd_lit_table, elf_zstd_match_table): Likewise.
+	(elf_zstd_offset_table): Likewise.
+	(struct elf_zstd_seq_decode): Likewise.  Remove use_rle and rle
+	fields.
+	(elf_zstd_unpack_seq_decode): Use elf_zstd_fse_baseline_entry,
+	taking a conversion function.  Convert RLE to FSE.
+	(elf_zstd_literal_length_baseline): Remove.
+	(elf_zstd_literal_length_bits): Remove.
+	(elf_zstd_match_length_baseline): Remove.
+	(elf_zstd_match_length_bits): Remove.
+	(elf_zstd_decompress): Use elf_zstd_fse_baseline_entry.  Rewrite
+	and simplify main loop.
+
+2022-12-08  Ian Lance Taylor  <iant@golang.org>
+
+	* configure.ac: Check for zstd library and
+	--compress-debug-sections=zstd linker option.
+	* Makefile.am (zstdtest_*): New targets.
+	(zstdtest_alloc_*, ctestzstd_*): New targets.
+	(BUILDTESTS): Add zstdtest, zstdtest_alloc, ctestzstd as
+	appropriate.
+	* elf.c (ELFCOMPRESS_ZSTD): Define.
+	(elf_fetch_bits): Rename from elf_zlib_fetch.  Update uses.
+	(elf_fetch_bits_backward): New static function.
+	(ZLIB_HUFFMAN_*): Rename from HUFFMAN_*.  Update uses.
+	(ZLIB_TABLE_*): Rename from ZDEBUG_TABLE_*.  Update uses.
+	(ZSTD_TABLE_*): Define.
+	(struct elf_zstd_fse_entry): Define.
+	(elf_zstd_read_fse): New static function.
+	(elf_zstd_build_fse): Likewise.
+	(lit): Define if BACKTRACE_GENERATE_ZSTD_FSE_TABLES.
+	(match, offset, next, print_table, main): Likewise.
+	(elf_zstd_lit_table): New static const array.
+	(elf_zstd_match_table, elf_zstd_offset_table): Likewise.
+	(elf_zstd_read_huff): New static function.
+	(struct elf_zstd_seq_decode): Define.
+	(elf_zstd_unpack_seq_decode): New static function.
+	(ZSTD_LIT_*): Define.
+	(struct elf_zstd_literals): Define.
+	(elf_zstd_literal_output): New static function.
+	(ZSTD_LITERAL_LENGTH_BASELINE_OFFSET): Define.
+	(elf_zstd_literal_length_baseline): New static const array.
+	(elf_zstd_literal_length_bits): Likewise.
+	(ZSTD_MATCH_LENGTH_BASELINE_OFFSET): Define.
+	(elf_zstd_match_length_baseline): New static const array.
+	(elf_zstd_match_length_bits): Likewise.
+	(elf_zstd_decompress): New static function.
+	(ZDEBUG_TABLE_SIZE): New definition.
+	(elf_uncompress_chdr): Support ELF_COMPRESS_ZSTD.
+	(backtrace_uncompress_zstd): New function.
+	(elf_add): Use ZLIB_TABLE_SIZE for zlib-gnu sections.
+	* internal.h (backtrace_uncompress_zstd): Declare.
+	* zstdtest.c: New file.
+	* configure, config.h.in, Makefile.in: Regenerate.
+
+2022-10-12  Martin Liska  <mliska@suse.cz>
+
+	* configure: Regenerate.
+
+2022-10-11  Olivier Hainque  <hainque@adacore.com>
+	    Olivier Hainque  <hainque@adacore.com>
+
+	* configure: Regenerate.
+
+2022-07-08  Ian Lance Taylor  <iant@golang.org>
+
+	* configure.ac: Check for sys/link.h.  Use either link.h or
+	sys/link.h when checking for dl_iterate_phdr.
+	* elf.c: Include sys/link.h if available.
+	* configure, config.h.in: Regenerate.
+
+2022-07-07  Ian Lance Taylor  <iant@golang.org>
+
+	* macho.c (backtrace_initialize) [HAVE_MACH_O_DYLD_H]: Don't exit
+	loop if we can't find debug info for one shared library.
+
+2022-07-07  Ian Lance Taylor  <iant@golang.org>
+
+	* Makefile.am (MAKETESTS): New variable split out of TESTS.
+	(CLEANFILES): Replace TESTS with BUILDTESTS and MAKETESTS.
+	* Makefile.in: Regenerate.
+
+2022-06-27  Ian Lance Taylor  <iant@golang.org>
+
+	* configure.ac: Use grep instead of fgrep.
+	* configure, Makefile.in: Regenerate.
+
+2022-05-28  Ian Lance Taylor  <iant@golang.org>
+
+	PR libbacktrace/105721
+	* README: Update.
+
+2022-04-05  Ian Lance Taylor  <iant@golang.org>
+
+	* elf.c (elf_zlib_inflate): Don't skip initial aligned byte in
+	uncompressed block.
+
+2022-02-17  Ian Lance Taylor  <iant@golang.org>
+
+	* dwarf.c (find_address_ranges): Handle skeleton units.
+	(read_function_entry): Likewise.
+
+2022-02-16  Ian Lance Taylor  <iant@golang.org>
+
+	* dwarf.c (build_address_map): Initialize DWARF 5 fields of unit.
+
+2022-02-03  David Seifert  <soap@gentoo.org>
+	    Jakub Jelinek  <jakub@redhat.com>
+
+	* configure.ac: Support --disable-werror.
+	* configure: Regenerate.
+
+2021-12-28  Francois-Xavier Coudert  <fxcoudert@gmail.com>
+
+	PR libbacktrace/103822
+	* Makefile.am: Fix newline.
+	* Makefile.in: Regenerate.
 
 2021-11-12  Martin Liska  <mliska@suse.cz>
 
@@ -1789,7 +2060,7 @@
 
 	* Initial implementation.
 \f
-Copyright (C) 2012-2021 Free Software Foundation, Inc.
+Copyright (C) 2012-2024 Free Software Foundation, Inc.
 
 Copying and distribution of this file, with or without modification,
 are permitted in any medium without royalty provided the copyright
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index e4f34b5fbd7..5677ecd8865 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -1,5 +1,5 @@
 # Makefile.am -- Backtrace Makefile.
-# Copyright (C) 2012-2021 Free Software Foundation, Inc.
+# Copyright (C) 2012-2024 Free Software Foundation, Inc.
 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
@@ -85,13 +85,19 @@ libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
 
 # Testsuite.
 
-# Add a test to this variable if you want it to be built.
+# Add a test to this variable if you want it to be built as a program,
+# with SOURCES, etc.
 check_PROGRAMS =
 
 # Add a test to this variable if you want it to be run.
 TESTS =
 
-# Add a test to this variable if you want it to be built and run.
+# Add a test to this variable if you want it to be built as a Makefile
+# target and run.
+MAKETESTS =
+
+# Add a test to this variable if you want it to be built as a program,
+# with SOURCES, etc., and run.
 BUILDTESTS =
 
 # Add a file to this variable if you want it to be built for testing.
@@ -100,6 +106,10 @@ check_DATA =
 # Flags to use when compiling test programs.
 libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
 
+# Flags to use when linking test programs.
+# This avoids generating a shell script when configured with --enable-shared.
+libbacktrace_testing_ldflags = -no-install
+
 if USE_DSYMUTIL
 
 %.dSYM: %
@@ -145,18 +155,18 @@ endif HAVE_OBJCOPY_DEBUGLINK
 endif HAVE_ELF
 
 elf_%.c: elf.c
+	nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
 	SEARCH='#error "Unknown BACKTRACE_ELF_SIZE"'; \
-	REPLACE='#undef BACKTRACE_ELF_SIZE\
-	#define BACKTRACE_ELF_SIZE'; \
+	REPLACE="#undef BACKTRACE_ELF_SIZE\\$${nl}#define BACKTRACE_ELF_SIZE"; \
 	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
 		$< \
 		> $@.tmp
 	mv $@.tmp $@
 
 xcoff_%.c: xcoff.c
+	nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
 	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
-	REPLACE='#undef BACKTRACE_XCOFF_SIZE\
-	#define BACKTRACE_XCOFF_SIZE'; \
+	REPLACE="#undef BACKTRACE_XCOFF_SIZE\\$${nl}#define BACKTRACE_XCOFF_SIZE"; \
 	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
 		$< \
 		> $@.tmp
@@ -164,54 +174,63 @@ xcoff_%.c: xcoff.c
 
 test_elf_32_SOURCES = test_format.c testlib.c
 test_elf_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_elf_32_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_elf_32_LDADD = libbacktrace_noformat.la elf_32.lo
 
 BUILDTESTS += test_elf_32
 
 test_elf_64_SOURCES = test_format.c testlib.c
 test_elf_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_elf_64_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo
 
 BUILDTESTS += test_elf_64
 
 test_macho_SOURCES = test_format.c testlib.c
 test_macho_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_macho_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_macho_LDADD = libbacktrace_noformat.la macho.lo
 
 BUILDTESTS += test_macho
 
 test_xcoff_32_SOURCES = test_format.c testlib.c
 test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_xcoff_32_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
 
 BUILDTESTS += test_xcoff_32
 
 test_xcoff_64_SOURCES = test_format.c testlib.c
 test_xcoff_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_xcoff_64_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
 
 BUILDTESTS += test_xcoff_64
 
 test_pecoff_SOURCES = test_format.c testlib.c
 test_pecoff_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_pecoff_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
 
 BUILDTESTS += test_pecoff
 
 test_unknown_SOURCES = test_format.c testlib.c
 test_unknown_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_unknown_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
 
 BUILDTESTS += test_unknown
 
 unittest_SOURCES = unittest.c testlib.c
 unittest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+unittest_LDFLAGS = $(libbacktrace_testing_ldflags)
 unittest_LDADD = libbacktrace.la
 
 BUILDTESTS += unittest
 
 unittest_alloc_SOURCES = $(unittest_SOURCES)
 unittest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+unittest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 unittest_alloc_LDADD = libbacktrace_alloc.la
 
 BUILDTESTS += unittest_alloc
@@ -242,33 +261,36 @@ check_DATA += allocfail.dSYM
 endif USE_DSYMUTIL
 
 if HAVE_ELF
+if HAVE_BUILDID
 if HAVE_OBJCOPY_DEBUGLINK
 
 b2test_SOURCES = $(btest_SOURCES)
 b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-b2test_LDFLAGS = -Wl,--build-id
+b2test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags)
 b2test_LDADD = libbacktrace_elf_for_test.la
 
 check_PROGRAMS += b2test
-TESTS += b2test_buildid
+MAKETESTS += b2test_buildid b2test_buildidfull
 
 if HAVE_DWZ
 
 b3test_SOURCES = $(btest_SOURCES)
 b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-b3test_LDFLAGS = -Wl,--build-id
+b3test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags)
 b3test_LDADD = libbacktrace_elf_for_test.la
 
 check_PROGRAMS += b3test
-TESTS += b3test_dwz_buildid
+MAKETESTS += b3test_dwz_buildid b3test_dwz_buildidfull
 
 endif HAVE_DWZ
 
 endif HAVE_OBJCOPY_DEBUGLINK
+endif HAVE_BUILDID
 endif HAVE_ELF
 
 btest_SOURCES = btest.c testlib.c
 btest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
+btest_LDFLAGS = $(libbacktrace_testing_ldflags)
 btest_LDADD = libbacktrace.la
 
 BUILDTESTS += btest
@@ -281,6 +303,7 @@ if HAVE_ELF
 
 btest_lto_SOURCES = btest.c testlib.c
 btest_lto_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O -flto
+btest_lto_LDFLAGS = $(libbacktrace_testing_ldflags)
 btest_lto_LDADD = libbacktrace.la
 
 BUILDTESTS += btest_lto
@@ -289,6 +312,7 @@ endif HAVE_ELF
 
 btest_alloc_SOURCES = $(btest_SOURCES)
 btest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+btest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 btest_alloc_LDADD = libbacktrace_alloc.la
 
 BUILDTESTS += btest_alloc
@@ -311,11 +335,11 @@ if HAVE_DWZ
 	  cp $< $@; \
 	fi
 
-TESTS += btest_dwz
+MAKETESTS += btest_dwz
 
 if HAVE_OBJCOPY_DEBUGLINK
 
-TESTS += btest_dwz_gnudebuglink
+MAKETESTS += btest_dwz_gnudebuglink
 
 endif HAVE_OBJCOPY_DEBUGLINK
 
@@ -323,6 +347,7 @@ endif HAVE_DWZ
 
 stest_SOURCES = stest.c
 stest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+stest_LDFLAGS = $(libbacktrace_testing_ldflags)
 stest_LDADD = libbacktrace.la
 
 BUILDTESTS += stest
@@ -333,6 +358,7 @@ endif USE_DSYMUTIL
 
 stest_alloc_SOURCES = $(stest_SOURCES)
 stest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+stest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 stest_alloc_LDADD = libbacktrace_alloc.la
 
 BUILDTESTS += stest_alloc
@@ -345,6 +371,7 @@ if HAVE_ELF
 
 ztest_SOURCES = ztest.c testlib.c
 ztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
+ztest_LDFLAGS = $(libbacktrace_testing_ldflags)
 ztest_LDADD = libbacktrace.la
 ztest_alloc_LDADD = libbacktrace_alloc.la
 
@@ -359,13 +386,36 @@ BUILDTESTS += ztest
 
 ztest_alloc_SOURCES = $(ztest_SOURCES)
 ztest_alloc_CFLAGS = $(ztest_CFLAGS)
+ztest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 
 BUILDTESTS += ztest_alloc
 
+zstdtest_SOURCES = zstdtest.c testlib.c
+zstdtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
+zstdtest_LDFLAGS = $(libbacktrace_testing_ldflags)
+zstdtest_LDADD = libbacktrace.la
+zstdtest_alloc_LDADD = libbacktrace_alloc.la
+
+if HAVE_ZSTD
+zstdtest_LDADD += -lzstd
+zstdtest_alloc_LDADD += -lzstd
+endif
+zstdtest_LDADD += $(CLOCK_GETTIME_LINK)
+zstdtest_alloc_LDADD += $(CLOCK_GETTIME_LINK)
+
+BUILDTESTS += zstdtest
+
+zstdtest_alloc_SOURCES = $(zstdtest_SOURCES)
+zstdtest_alloc_CFLAGS = $(zstdtest_CFLAGS)
+zstdtest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
+
+BUILDTESTS += zstdtest_alloc
+
 endif HAVE_ELF
 
 edtest_SOURCES = edtest.c edtest2_build.c testlib.c
 edtest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+edtest_LDFLAGS = $(libbacktrace_testing_ldflags)
 edtest_LDADD = libbacktrace.la
 
 BUILDTESTS += edtest
@@ -376,6 +426,7 @@ endif USE_DSYMUTIL
 
 edtest_alloc_SOURCES = $(edtest_SOURCES)
 edtest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+edtest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 edtest_alloc_LDADD = libbacktrace_alloc.la
 
 if USE_DSYMUTIL
@@ -396,6 +447,7 @@ BUILDTESTS += ttest
 
 ttest_SOURCES = ttest.c testlib.c
 ttest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -pthread
+ttest_LDFLAGS = $(libbacktrace_testing_ldflags)
 ttest_LDADD = libbacktrace.la
 
 if USE_DSYMUTIL
@@ -406,6 +458,7 @@ BUILDTESTS += ttest_alloc
 
 ttest_alloc_SOURCES = $(ttest_SOURCES)
 ttest_alloc_CFLAGS = $(ttest_CFLAGS)
+ttest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 ttest_alloc_LDADD = libbacktrace_alloc.la
 
 if USE_DSYMUTIL
@@ -416,12 +469,16 @@ endif HAVE_PTHREAD
 
 if HAVE_OBJCOPY_DEBUGLINK
 
-TESTS += btest_gnudebuglink
+MAKETESTS += btest_gnudebuglink btest_gnudebuglinkfull
 
 %_gnudebuglink: %
 	$(OBJCOPY) --only-keep-debug $< $@.debug
 	$(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@
 
+%_gnudebuglinkfull: %
+	$(OBJCOPY) --only-keep-debug $< $@.debug
+	$(OBJCOPY) --strip-all --add-gnu-debuglink=$@.debug $< $@
+
 endif HAVE_OBJCOPY_DEBUGLINK
 
 %_buildid: %
@@ -430,28 +487,45 @@ endif HAVE_OBJCOPY_DEBUGLINK
 	  $<
 	$(OBJCOPY) --strip-debug $< $@
 
+%_buildidfull: %
+	./install-debuginfo-for-buildid.sh \
+	  "$(TEST_BUILD_ID_DIR)" \
+	  $<
+	$(OBJCOPY) --strip-all $< $@
+
 if HAVE_COMPRESSED_DEBUG
 
 ctestg_SOURCES = btest.c testlib.c
 ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu
+ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu $(libbacktrace_testing_ldflags)
 ctestg_LDADD = libbacktrace.la
 
 ctesta_SOURCES = btest.c testlib.c
 ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
+ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi $(libbacktrace_testing_ldflags)
 ctesta_LDADD = libbacktrace.la
 
 BUILDTESTS += ctestg ctesta
 
+if HAVE_COMPRESSED_DEBUG_ZSTD
+
+ctestzstd_SOURCES = btest.c testlib.c
+ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+ctestzstd_LDFLAGS = -Wl,--compress-debug-sections=zstd $(libbacktrace_testing_ldflags)
+ctestzstd_LDADD = libbacktrace.la
+
+BUILDTESTS += ctestzstd
+
+endif
+
 ctestg_alloc_SOURCES = $(ctestg_SOURCES)
 ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
-ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS)
+ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS) $(libbacktrace_testing_ldflags)
 ctestg_alloc_LDADD = libbacktrace_alloc.la
 
 ctesta_alloc_SOURCES = $(ctesta_SOURCES)
 ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
-ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS)
+ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS) $(libbacktrace_testing_ldflags)
 ctesta_alloc_LDADD = libbacktrace_alloc.la
 
 BUILDTESTS += ctestg_alloc ctesta_alloc
@@ -462,6 +536,7 @@ if HAVE_DWARF5
 
 dwarf5_SOURCES = btest.c testlib.c
 dwarf5_CFLAGS = $(libbacktrace_TEST_CFLAGS) -gdwarf-5
+dwarf5_LDFLAGS = $(libbacktrace_testing_ldflags)
 dwarf5_LDADD = libbacktrace.la
 
 BUILDTESTS += dwarf5
@@ -472,6 +547,7 @@ endif USE_DSYMUTIL
 
 dwarf5_alloc_SOURCES = $(dwarf5_SOURCES)
 dwarf5_alloc_CFLAGS = $(dwarf5_CFLAGS)
+dwarf5_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 dwarf5_alloc_LDADD = libbacktrace_alloc.la
 
 BUILDTESTS += dwarf5_alloc
@@ -484,6 +560,7 @@ endif
 
 mtest_SOURCES = mtest.c testlib.c
 mtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
+mtest_LDFLAGS = $(libbacktrace_testing_ldflags)
 mtest_LDADD = libbacktrace.la
 
 BUILDTESTS += mtest
@@ -494,11 +571,11 @@ endif USE_DSYMUTIL
 
 if HAVE_MINIDEBUG
 
-TESTS += mtest_minidebug
+MAKETESTS += mtest_minidebug
 
 %_minidebug: %
 	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
-	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
+	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
 	$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
 	$(OBJCOPY) --only-keep-debug $< $<.dbg
 	$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
@@ -516,10 +593,12 @@ if HAVE_ELF
 
 xztest_SOURCES = xztest.c testlib.c
 xztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
+xztest_LDFLAGS = $(libbacktrace_testing_ldflags)
 xztest_LDADD = libbacktrace.la
 
 xztest_alloc_SOURCES = $(xztest_SOURCES)
 xztest_alloc_CFLAGS = $(xztest_CFLAGS)
+xztest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 xztest_alloc_LDADD = libbacktrace_alloc.la
 
 if HAVE_LIBLZMA
@@ -536,10 +615,11 @@ endif HAVE_ELF
 
 check_PROGRAMS += $(BUILDTESTS)
 
-TESTS += $(BUILDTESTS)
+TESTS += $(MAKETESTS) $(BUILDTESTS)
 
 CLEANFILES = \
-       $(filter-out allocfail.sh,$(TESTS)) *.debug elf_for_test.c edtest2_build.c gen_edtest2_build \
+	$(MAKETESTS) $(BUILDTESTS) *.debug elf_for_test.c edtest2_build.c \
+	gen_edtest2_build \
 	*.dsyms *.fsyms *.keepsyms *.dbg *.mdbg *.mdbg.xz *.strip
 
 clean-local:
diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index 0a61880ba67..49852a21d37 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -15,7 +15,7 @@
 @SET_MAKE@
 
 # Makefile.am -- Backtrace Makefile.
-# Copyright (C) 2012-2021 Free Software Foundation, Inc.
+# Copyright (C) 2012-2024 Free Software Foundation, Inc.
 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
@@ -121,10 +121,8 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
-	$(am__EXEEXT_14)
-TESTS = $(am__append_4) $(am__append_7) $(am__append_9) \
-	$(am__append_12) $(am__append_13) $(am__append_20) \
-	$(am__append_26) $(am__EXEEXT_14)
+	$(am__EXEEXT_16)
+TESTS = $(am__append_4) $(MAKETESTS) $(am__EXEEXT_16)
 @HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_1 = libbacktrace_elf_for_test.la
 @NATIVE_TRUE@am__append_2 = test_elf_32 test_elf_64 test_macho \
 @NATIVE_TRUE@	test_xcoff_32 test_xcoff_64 test_pecoff \
@@ -135,36 +133,39 @@ TESTS = $(am__append_4) $(am__append_7) $(am__append_9) \
 @NATIVE_TRUE@@USE_DSYMUTIL_TRUE@	btest.dSYM btest_alloc.dSYM \
 @NATIVE_TRUE@@USE_DSYMUTIL_TRUE@	stest.dSYM stest_alloc.dSYM \
 @NATIVE_TRUE@@USE_DSYMUTIL_TRUE@	edtest.dSYM edtest_alloc.dSYM
-@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_6 = b2test
-@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_7 = b2test_buildid
-@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_8 = b3test
-@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_9 = b3test_dwz_buildid
+@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_6 = b2test
+@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_7 = b2test_buildid b2test_buildidfull
+@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_8 = b3test
+@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_9 = b3test_dwz_buildid b3test_dwz_buildidfull
 @HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_10 = btest_lto
 @NATIVE_TRUE@am__append_11 = btest_alloc stest stest_alloc
 @HAVE_DWZ_TRUE@@NATIVE_TRUE@am__append_12 = btest_dwz
 @HAVE_DWZ_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_13 = btest_dwz_gnudebuglink
 @HAVE_ELF_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_14 = -lz
 @HAVE_ELF_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_15 = -lz
-@HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_16 = ztest ztest_alloc
-@NATIVE_TRUE@am__append_17 = edtest edtest_alloc
-@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_18 = ttest ttest_alloc
-@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_19 =  \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_16 = ztest ztest_alloc zstdtest \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	zstdtest_alloc
+@HAVE_ELF_TRUE@@HAVE_ZSTD_TRUE@@NATIVE_TRUE@am__append_17 = -lzstd
+@HAVE_ELF_TRUE@@HAVE_ZSTD_TRUE@@NATIVE_TRUE@am__append_18 = -lzstd
+@NATIVE_TRUE@am__append_19 = edtest edtest_alloc
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_20 = ttest ttest_alloc
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_21 =  \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@	ttest.dSYM \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@	ttest_alloc.dSYM
-@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_20 = btest_gnudebuglink
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_21 = ctestg ctesta \
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctestg_alloc \
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctesta_alloc
-@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__append_22 = dwarf5 dwarf5_alloc
-@HAVE_DWARF5_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_23 =  \
+@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_22 = btest_gnudebuglink btest_gnudebuglinkfull
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_23 = ctestg ctesta
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@am__append_24 = ctestzstd
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_25 = ctestg_alloc ctesta_alloc
+@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__append_26 = dwarf5 dwarf5_alloc
+@HAVE_DWARF5_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_27 =  \
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@	dwarf5.dSYM \
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@	dwarf5_alloc.dSYM
-@NATIVE_TRUE@am__append_24 = mtest
-@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_25 = mtest.dSYM
-@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@am__append_26 = mtest_minidebug
-@HAVE_ELF_TRUE@@HAVE_LIBLZMA_TRUE@am__append_27 = -llzma
-@HAVE_ELF_TRUE@@HAVE_LIBLZMA_TRUE@am__append_28 = -llzma
-@HAVE_ELF_TRUE@am__append_29 = xztest xztest_alloc
+@NATIVE_TRUE@am__append_28 = mtest
+@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_29 = mtest.dSYM
+@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@am__append_30 = mtest_minidebug
+@HAVE_ELF_TRUE@@HAVE_LIBLZMA_TRUE@am__append_31 = -llzma
+@HAVE_ELF_TRUE@@HAVE_LIBLZMA_TRUE@am__append_32 = -llzma
+@HAVE_ELF_TRUE@am__append_33 = xztest xztest_alloc
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/cet.m4 \
@@ -221,8 +222,8 @@ libbacktrace_noformat_la_OBJECTS =  \
 	$(am_libbacktrace_noformat_la_OBJECTS)
 @NATIVE_TRUE@am_libbacktrace_noformat_la_rpath =
 @NATIVE_TRUE@am__EXEEXT_1 = allocfail$(EXEEXT)
-@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = b2test$(EXEEXT)
-@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_3 = b3test$(EXEEXT)
+@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = b2test$(EXEEXT)
+@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_3 = b3test$(EXEEXT)
 @NATIVE_TRUE@am__EXEEXT_4 = test_elf_32$(EXEEXT) test_elf_64$(EXEEXT) \
 @NATIVE_TRUE@	test_macho$(EXEEXT) test_xcoff_32$(EXEEXT) \
 @NATIVE_TRUE@	test_xcoff_64$(EXEEXT) test_pecoff$(EXEEXT) \
@@ -232,23 +233,26 @@ libbacktrace_noformat_la_OBJECTS =  \
 @NATIVE_TRUE@am__EXEEXT_6 = btest_alloc$(EXEEXT) stest$(EXEEXT) \
 @NATIVE_TRUE@	stest_alloc$(EXEEXT)
 @HAVE_ELF_TRUE@@NATIVE_TRUE@am__EXEEXT_7 = ztest$(EXEEXT) \
-@HAVE_ELF_TRUE@@NATIVE_TRUE@	ztest_alloc$(EXEEXT)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	ztest_alloc$(EXEEXT) \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	zstdtest$(EXEEXT) \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	zstdtest_alloc$(EXEEXT)
 @NATIVE_TRUE@am__EXEEXT_8 = edtest$(EXEEXT) edtest_alloc$(EXEEXT)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_9 = ttest$(EXEEXT) \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest_alloc$(EXEEXT)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_10 =  \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctestg$(EXEEXT) \
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctesta$(EXEEXT) \
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctestg_alloc$(EXEEXT) \
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctesta$(EXEEXT)
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@am__EXEEXT_11 = ctestzstd$(EXEEXT)
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_12 = ctestg_alloc$(EXEEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctesta_alloc$(EXEEXT)
-@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__EXEEXT_11 = dwarf5$(EXEEXT) \
+@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__EXEEXT_13 = dwarf5$(EXEEXT) \
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@	dwarf5_alloc$(EXEEXT)
-@NATIVE_TRUE@am__EXEEXT_12 = mtest$(EXEEXT)
-@HAVE_ELF_TRUE@am__EXEEXT_13 = xztest$(EXEEXT) xztest_alloc$(EXEEXT)
-am__EXEEXT_14 = $(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \
+@NATIVE_TRUE@am__EXEEXT_14 = mtest$(EXEEXT)
+@HAVE_ELF_TRUE@am__EXEEXT_15 = xztest$(EXEEXT) xztest_alloc$(EXEEXT)
+am__EXEEXT_16 = $(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \
 	$(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \
 	$(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12) \
-	$(am__EXEEXT_13)
+	$(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15)
 @NATIVE_TRUE@am_allocfail_OBJECTS = allocfail-allocfail.$(OBJEXT) \
 @NATIVE_TRUE@	allocfail-testlib.$(OBJEXT)
 allocfail_OBJECTS = $(am_allocfail_OBJECTS)
@@ -259,17 +263,17 @@ allocfail_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am__objects_2 = b2test-btest.$(OBJEXT) \
 @NATIVE_TRUE@	b2test-testlib.$(OBJEXT)
-@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_b2test_OBJECTS = $(am__objects_2)
+@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_b2test_OBJECTS = $(am__objects_2)
 b2test_OBJECTS = $(am_b2test_OBJECTS)
-@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_DEPENDENCIES = libbacktrace_elf_for_test.la
+@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_DEPENDENCIES = libbacktrace_elf_for_test.la
 b2test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(b2test_CFLAGS) $(CFLAGS) \
 	$(b2test_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am__objects_3 = b3test-btest.$(OBJEXT) \
 @NATIVE_TRUE@	b3test-testlib.$(OBJEXT)
-@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_b3test_OBJECTS = $(am__objects_3)
+@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_b3test_OBJECTS = $(am__objects_3)
 b3test_OBJECTS = $(am_b3test_OBJECTS)
-@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_DEPENDENCIES = libbacktrace_elf_for_test.la
+@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_DEPENDENCIES = libbacktrace_elf_for_test.la
 b3test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(b3test_CFLAGS) $(CFLAGS) \
 	$(b3test_LDFLAGS) $(LDFLAGS) -o $@
@@ -279,7 +283,7 @@ btest_OBJECTS = $(am_btest_OBJECTS)
 @NATIVE_TRUE@btest_DEPENDENCIES = libbacktrace.la
 btest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(btest_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(btest_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am__objects_4 = btest_alloc-btest.$(OBJEXT) \
 @NATIVE_TRUE@	btest_alloc-testlib.$(OBJEXT)
 @NATIVE_TRUE@am_btest_alloc_OBJECTS = $(am__objects_4)
@@ -287,7 +291,7 @@ btest_alloc_OBJECTS = $(am_btest_alloc_OBJECTS)
 @NATIVE_TRUE@btest_alloc_DEPENDENCIES = libbacktrace_alloc.la
 btest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(btest_alloc_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(btest_alloc_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_ELF_TRUE@@NATIVE_TRUE@am_btest_lto_OBJECTS =  \
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	btest_lto-btest.$(OBJEXT) \
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	btest_lto-testlib.$(OBJEXT)
@@ -295,7 +299,7 @@ btest_lto_OBJECTS = $(am_btest_lto_OBJECTS)
 @HAVE_ELF_TRUE@@NATIVE_TRUE@btest_lto_DEPENDENCIES = libbacktrace.la
 btest_lto_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(btest_lto_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(btest_lto_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am_ctesta_OBJECTS = ctesta-btest.$(OBJEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctesta-testlib.$(OBJEXT)
 ctesta_OBJECTS = $(am_ctesta_OBJECTS)
@@ -330,6 +334,13 @@ ctestg_alloc_OBJECTS = $(am_ctestg_alloc_OBJECTS)
 ctestg_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(ctestg_alloc_CFLAGS) \
 	$(CFLAGS) $(ctestg_alloc_LDFLAGS) $(LDFLAGS) -o $@
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@am_ctestzstd_OBJECTS = ctestzstd-btest.$(OBJEXT) \
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@	ctestzstd-testlib.$(OBJEXT)
+ctestzstd_OBJECTS = $(am_ctestzstd_OBJECTS)
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_DEPENDENCIES = libbacktrace.la
+ctestzstd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(ctestzstd_CFLAGS) \
+	$(CFLAGS) $(ctestzstd_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@am_dwarf5_OBJECTS =  \
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@	dwarf5-btest.$(OBJEXT) \
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@	dwarf5-testlib.$(OBJEXT)
@@ -337,7 +348,7 @@ dwarf5_OBJECTS = $(am_dwarf5_OBJECTS)
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_DEPENDENCIES = libbacktrace.la
 dwarf5_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(dwarf5_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(dwarf5_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__objects_7 =  \
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@	dwarf5_alloc-btest.$(OBJEXT) \
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@	dwarf5_alloc-testlib.$(OBJEXT)
@@ -348,7 +359,7 @@ dwarf5_alloc_OBJECTS = $(am_dwarf5_alloc_OBJECTS)
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@	libbacktrace_alloc.la
 dwarf5_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(dwarf5_alloc_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(dwarf5_alloc_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_edtest_OBJECTS = edtest-edtest.$(OBJEXT) \
 @NATIVE_TRUE@	edtest-edtest2_build.$(OBJEXT) \
 @NATIVE_TRUE@	edtest-testlib.$(OBJEXT)
@@ -356,7 +367,7 @@ edtest_OBJECTS = $(am_edtest_OBJECTS)
 @NATIVE_TRUE@edtest_DEPENDENCIES = libbacktrace.la
 edtest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(edtest_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(edtest_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am__objects_8 = edtest_alloc-edtest.$(OBJEXT) \
 @NATIVE_TRUE@	edtest_alloc-edtest2_build.$(OBJEXT) \
 @NATIVE_TRUE@	edtest_alloc-testlib.$(OBJEXT)
@@ -365,27 +376,27 @@ edtest_alloc_OBJECTS = $(am_edtest_alloc_OBJECTS)
 @NATIVE_TRUE@edtest_alloc_DEPENDENCIES = libbacktrace_alloc.la
 edtest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(edtest_alloc_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(edtest_alloc_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_mtest_OBJECTS = mtest-mtest.$(OBJEXT) \
 @NATIVE_TRUE@	mtest-testlib.$(OBJEXT)
 mtest_OBJECTS = $(am_mtest_OBJECTS)
 @NATIVE_TRUE@mtest_DEPENDENCIES = libbacktrace.la
 mtest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(mtest_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(mtest_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_stest_OBJECTS = stest-stest.$(OBJEXT)
 stest_OBJECTS = $(am_stest_OBJECTS)
 @NATIVE_TRUE@stest_DEPENDENCIES = libbacktrace.la
 stest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(stest_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(stest_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am__objects_9 = stest_alloc-stest.$(OBJEXT)
 @NATIVE_TRUE@am_stest_alloc_OBJECTS = $(am__objects_9)
 stest_alloc_OBJECTS = $(am_stest_alloc_OBJECTS)
 @NATIVE_TRUE@stest_alloc_DEPENDENCIES = libbacktrace_alloc.la
 stest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(stest_alloc_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(stest_alloc_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_test_elf_32_OBJECTS =  \
 @NATIVE_TRUE@	test_elf_32-test_format.$(OBJEXT) \
 @NATIVE_TRUE@	test_elf_32-testlib.$(OBJEXT)
@@ -394,7 +405,7 @@ test_elf_32_OBJECTS = $(am_test_elf_32_OBJECTS)
 @NATIVE_TRUE@	elf_32.lo
 test_elf_32_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_elf_32_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(test_elf_32_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_test_elf_64_OBJECTS =  \
 @NATIVE_TRUE@	test_elf_64-test_format.$(OBJEXT) \
 @NATIVE_TRUE@	test_elf_64-testlib.$(OBJEXT)
@@ -403,7 +414,7 @@ test_elf_64_OBJECTS = $(am_test_elf_64_OBJECTS)
 @NATIVE_TRUE@	elf_64.lo
 test_elf_64_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_elf_64_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(test_elf_64_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_test_macho_OBJECTS = test_macho-test_format.$(OBJEXT) \
 @NATIVE_TRUE@	test_macho-testlib.$(OBJEXT)
 test_macho_OBJECTS = $(am_test_macho_OBJECTS)
@@ -411,7 +422,7 @@ test_macho_OBJECTS = $(am_test_macho_OBJECTS)
 @NATIVE_TRUE@	macho.lo
 test_macho_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_macho_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(test_macho_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_test_pecoff_OBJECTS =  \
 @NATIVE_TRUE@	test_pecoff-test_format.$(OBJEXT) \
 @NATIVE_TRUE@	test_pecoff-testlib.$(OBJEXT)
@@ -420,7 +431,7 @@ test_pecoff_OBJECTS = $(am_test_pecoff_OBJECTS)
 @NATIVE_TRUE@	pecoff.lo
 test_pecoff_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_pecoff_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(test_pecoff_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_test_unknown_OBJECTS =  \
 @NATIVE_TRUE@	test_unknown-test_format.$(OBJEXT) \
 @NATIVE_TRUE@	test_unknown-testlib.$(OBJEXT)
@@ -429,7 +440,7 @@ test_unknown_OBJECTS = $(am_test_unknown_OBJECTS)
 @NATIVE_TRUE@	unknown.lo
 test_unknown_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_unknown_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(test_unknown_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_test_xcoff_32_OBJECTS =  \
 @NATIVE_TRUE@	test_xcoff_32-test_format.$(OBJEXT) \
 @NATIVE_TRUE@	test_xcoff_32-testlib.$(OBJEXT)
@@ -438,7 +449,7 @@ test_xcoff_32_OBJECTS = $(am_test_xcoff_32_OBJECTS)
 @NATIVE_TRUE@	xcoff_32.lo
 test_xcoff_32_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_xcoff_32_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(test_xcoff_32_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_test_xcoff_64_OBJECTS =  \
 @NATIVE_TRUE@	test_xcoff_64-test_format.$(OBJEXT) \
 @NATIVE_TRUE@	test_xcoff_64-testlib.$(OBJEXT)
@@ -447,7 +458,7 @@ test_xcoff_64_OBJECTS = $(am_test_xcoff_64_OBJECTS)
 @NATIVE_TRUE@	xcoff_64.lo
 test_xcoff_64_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_xcoff_64_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(test_xcoff_64_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am_ttest_OBJECTS =  \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest-ttest.$(OBJEXT) \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest-testlib.$(OBJEXT)
@@ -455,7 +466,7 @@ ttest_OBJECTS = $(am_ttest_OBJECTS)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_DEPENDENCIES = libbacktrace.la
 ttest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(ttest_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(ttest_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__objects_10 =  \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest_alloc-ttest.$(OBJEXT) \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest_alloc-testlib.$(OBJEXT)
@@ -466,14 +477,14 @@ ttest_alloc_OBJECTS = $(am_ttest_alloc_OBJECTS)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	libbacktrace_alloc.la
 ttest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(ttest_alloc_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(ttest_alloc_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_unittest_OBJECTS = unittest-unittest.$(OBJEXT) \
 @NATIVE_TRUE@	unittest-testlib.$(OBJEXT)
 unittest_OBJECTS = $(am_unittest_OBJECTS)
 @NATIVE_TRUE@unittest_DEPENDENCIES = libbacktrace.la
 unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(unittest_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(unittest_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am__objects_11 = unittest_alloc-unittest.$(OBJEXT) \
 @NATIVE_TRUE@	unittest_alloc-testlib.$(OBJEXT)
 @NATIVE_TRUE@am_unittest_alloc_OBJECTS = $(am__objects_11)
@@ -481,8 +492,8 @@ unittest_alloc_OBJECTS = $(am_unittest_alloc_OBJECTS)
 @NATIVE_TRUE@unittest_alloc_DEPENDENCIES = libbacktrace_alloc.la
 unittest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
-	$(unittest_alloc_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o \
-	$@
+	$(unittest_alloc_CFLAGS) $(CFLAGS) $(unittest_alloc_LDFLAGS) \
+	$(LDFLAGS) -o $@
 @HAVE_ELF_TRUE@am_xztest_OBJECTS = xztest-xztest.$(OBJEXT) \
 @HAVE_ELF_TRUE@	xztest-testlib.$(OBJEXT)
 xztest_OBJECTS = $(am_xztest_OBJECTS)
@@ -490,7 +501,7 @@ xztest_OBJECTS = $(am_xztest_OBJECTS)
 @HAVE_ELF_TRUE@	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 xztest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(xztest_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(xztest_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_ELF_TRUE@am__objects_12 = xztest_alloc-xztest.$(OBJEXT) \
 @HAVE_ELF_TRUE@	xztest_alloc-testlib.$(OBJEXT)
 @HAVE_ELF_TRUE@am_xztest_alloc_OBJECTS = $(am__objects_12)
@@ -499,7 +510,31 @@ xztest_alloc_OBJECTS = $(am_xztest_alloc_OBJECTS)
 @HAVE_ELF_TRUE@	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 xztest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(xztest_alloc_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(xztest_alloc_LDFLAGS) $(LDFLAGS) -o $@
+@HAVE_ELF_TRUE@@NATIVE_TRUE@am_zstdtest_OBJECTS =  \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	zstdtest-zstdtest.$(OBJEXT) \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	zstdtest-testlib.$(OBJEXT)
+zstdtest_OBJECTS = $(am_zstdtest_OBJECTS)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_DEPENDENCIES = libbacktrace.la \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__DEPENDENCIES_1) \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__DEPENDENCIES_1)
+zstdtest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(zstdtest_CFLAGS) \
+	$(CFLAGS) $(zstdtest_LDFLAGS) $(LDFLAGS) -o $@
+@HAVE_ELF_TRUE@@NATIVE_TRUE@am__objects_13 =  \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	zstdtest_alloc-zstdtest.$(OBJEXT) \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	zstdtest_alloc-testlib.$(OBJEXT)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@am_zstdtest_alloc_OBJECTS =  \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__objects_13)
+zstdtest_alloc_OBJECTS = $(am_zstdtest_alloc_OBJECTS)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_alloc_DEPENDENCIES =  \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	libbacktrace_alloc.la \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__DEPENDENCIES_1) \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__DEPENDENCIES_1)
+zstdtest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(zstdtest_alloc_CFLAGS) $(CFLAGS) $(zstdtest_alloc_LDFLAGS) \
+	$(LDFLAGS) -o $@
 @HAVE_ELF_TRUE@@NATIVE_TRUE@am_ztest_OBJECTS = ztest-ztest.$(OBJEXT) \
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	ztest-testlib.$(OBJEXT)
 ztest_OBJECTS = $(am_ztest_OBJECTS)
@@ -508,12 +543,12 @@ ztest_OBJECTS = $(am_ztest_OBJECTS)
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__DEPENDENCIES_1)
 ztest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(ztest_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
-@HAVE_ELF_TRUE@@NATIVE_TRUE@am__objects_13 =  \
+	$(ztest_LDFLAGS) $(LDFLAGS) -o $@
+@HAVE_ELF_TRUE@@NATIVE_TRUE@am__objects_14 =  \
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	ztest_alloc-ztest.$(OBJEXT) \
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	ztest_alloc-testlib.$(OBJEXT)
 @HAVE_ELF_TRUE@@NATIVE_TRUE@am_ztest_alloc_OBJECTS =  \
-@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__objects_13)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__objects_14)
 ztest_alloc_OBJECTS = $(am_ztest_alloc_OBJECTS)
 @HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_DEPENDENCIES =  \
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	libbacktrace_alloc.la \
@@ -521,7 +556,7 @@ ztest_alloc_OBJECTS = $(am_ztest_alloc_OBJECTS)
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__DEPENDENCIES_1)
 ztest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(ztest_alloc_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+	$(CFLAGS) $(ztest_alloc_LDFLAGS) $(LDFLAGS) -o $@
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
 am__v_P_0 = false
@@ -563,7 +598,7 @@ SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
 	$(b2test_SOURCES) $(b3test_SOURCES) $(btest_SOURCES) \
 	$(btest_alloc_SOURCES) $(btest_lto_SOURCES) $(ctesta_SOURCES) \
 	$(ctesta_alloc_SOURCES) $(ctestg_SOURCES) \
-	$(ctestg_alloc_SOURCES) $(dwarf5_SOURCES) \
+	$(ctestg_alloc_SOURCES) $(ctestzstd_SOURCES) $(dwarf5_SOURCES) \
 	$(dwarf5_alloc_SOURCES) $(edtest_SOURCES) \
 	$(edtest_alloc_SOURCES) $(mtest_SOURCES) $(stest_SOURCES) \
 	$(stest_alloc_SOURCES) $(test_elf_32_SOURCES) \
@@ -572,7 +607,8 @@ SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
 	$(test_xcoff_32_SOURCES) $(test_xcoff_64_SOURCES) \
 	$(ttest_SOURCES) $(ttest_alloc_SOURCES) $(unittest_SOURCES) \
 	$(unittest_alloc_SOURCES) $(xztest_SOURCES) \
-	$(xztest_alloc_SOURCES) $(ztest_SOURCES) \
+	$(xztest_alloc_SOURCES) $(zstdtest_SOURCES) \
+	$(zstdtest_alloc_SOURCES) $(ztest_SOURCES) \
 	$(ztest_alloc_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
@@ -988,18 +1024,28 @@ libbacktrace_la_LIBADD = \
 
 libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
 
-# Add a test to this variable if you want it to be built and run.
+# Add a test to this variable if you want it to be built as a Makefile
+# target and run.
+MAKETESTS = $(am__append_7) $(am__append_9) $(am__append_12) \
+	$(am__append_13) $(am__append_22) $(am__append_30)
+
+# Add a test to this variable if you want it to be built as a program,
+# with SOURCES, etc., and run.
 BUILDTESTS = $(am__append_2) $(am__append_10) $(am__append_11) \
-	$(am__append_16) $(am__append_17) $(am__append_18) \
-	$(am__append_21) $(am__append_22) $(am__append_24) \
-	$(am__append_29)
+	$(am__append_16) $(am__append_19) $(am__append_20) \
+	$(am__append_23) $(am__append_24) $(am__append_25) \
+	$(am__append_26) $(am__append_28) $(am__append_33)
 
 # Add a file to this variable if you want it to be built for testing.
-check_DATA = $(am__append_5) $(am__append_19) $(am__append_23) \
-	$(am__append_25)
+check_DATA = $(am__append_5) $(am__append_21) $(am__append_27) \
+	$(am__append_29)
 
 # Flags to use when compiling test programs.
 libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
+
+# Flags to use when linking test programs.
+# This avoids generating a shell script when configured with --enable-shared.
+libbacktrace_testing_ldflags = -no-install
 @NATIVE_TRUE@check_LTLIBRARIES = libbacktrace_alloc.la \
 @NATIVE_TRUE@	libbacktrace_noformat.la $(am__append_1) \
 @NATIVE_TRUE@	libbacktrace_instrumented_alloc.la
@@ -1016,30 +1062,39 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
 
 @NATIVE_TRUE@test_elf_32_SOURCES = test_format.c testlib.c
 @NATIVE_TRUE@test_elf_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@test_elf_32_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@test_elf_32_LDADD = libbacktrace_noformat.la elf_32.lo
 @NATIVE_TRUE@test_elf_64_SOURCES = test_format.c testlib.c
 @NATIVE_TRUE@test_elf_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@test_elf_64_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo
 @NATIVE_TRUE@test_macho_SOURCES = test_format.c testlib.c
 @NATIVE_TRUE@test_macho_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@test_macho_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@test_macho_LDADD = libbacktrace_noformat.la macho.lo
 @NATIVE_TRUE@test_xcoff_32_SOURCES = test_format.c testlib.c
 @NATIVE_TRUE@test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@test_xcoff_32_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
 @NATIVE_TRUE@test_xcoff_64_SOURCES = test_format.c testlib.c
 @NATIVE_TRUE@test_xcoff_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@test_xcoff_64_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
 @NATIVE_TRUE@test_pecoff_SOURCES = test_format.c testlib.c
 @NATIVE_TRUE@test_pecoff_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@test_pecoff_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
 @NATIVE_TRUE@test_unknown_SOURCES = test_format.c testlib.c
 @NATIVE_TRUE@test_unknown_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@test_unknown_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
 @NATIVE_TRUE@unittest_SOURCES = unittest.c testlib.c
 @NATIVE_TRUE@unittest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@unittest_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@unittest_LDADD = libbacktrace.la
 @NATIVE_TRUE@unittest_alloc_SOURCES = $(unittest_SOURCES)
 @NATIVE_TRUE@unittest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@unittest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@unittest_alloc_LDADD = libbacktrace_alloc.la
 @NATIVE_TRUE@libbacktrace_instrumented_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
 @NATIVE_TRUE@libbacktrace_instrumented_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) \
@@ -1051,31 +1106,37 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
 @NATIVE_TRUE@allocfail_SOURCES = allocfail.c testlib.c
 @NATIVE_TRUE@allocfail_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 @NATIVE_TRUE@allocfail_LDADD = libbacktrace_instrumented_alloc.la
-@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_SOURCES = $(btest_SOURCES)
-@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_LDFLAGS = -Wl,--build-id
-@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_LDADD = libbacktrace_elf_for_test.la
-@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_SOURCES = $(btest_SOURCES)
-@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_LDFLAGS = -Wl,--build-id
-@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_LDADD = libbacktrace_elf_for_test.la
+@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_SOURCES = $(btest_SOURCES)
+@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags)
+@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_LDADD = libbacktrace_elf_for_test.la
+@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_SOURCES = $(btest_SOURCES)
+@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags)
+@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_LDADD = libbacktrace_elf_for_test.la
 @NATIVE_TRUE@btest_SOURCES = btest.c testlib.c
 @NATIVE_TRUE@btest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
+@NATIVE_TRUE@btest_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@btest_LDADD = libbacktrace.la
 @HAVE_ELF_TRUE@@NATIVE_TRUE@btest_lto_SOURCES = btest.c testlib.c
 @HAVE_ELF_TRUE@@NATIVE_TRUE@btest_lto_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O -flto
+@HAVE_ELF_TRUE@@NATIVE_TRUE@btest_lto_LDFLAGS = $(libbacktrace_testing_ldflags)
 @HAVE_ELF_TRUE@@NATIVE_TRUE@btest_lto_LDADD = libbacktrace.la
 @NATIVE_TRUE@btest_alloc_SOURCES = $(btest_SOURCES)
 @NATIVE_TRUE@btest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@btest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@btest_alloc_LDADD = libbacktrace_alloc.la
 @NATIVE_TRUE@stest_SOURCES = stest.c
 @NATIVE_TRUE@stest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@stest_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@stest_LDADD = libbacktrace.la
 @NATIVE_TRUE@stest_alloc_SOURCES = $(stest_SOURCES)
 @NATIVE_TRUE@stest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@stest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@stest_alloc_LDADD = libbacktrace_alloc.la
 @HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c
 @HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
+@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_LDFLAGS = $(libbacktrace_testing_ldflags)
 @HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_LDADD = libbacktrace.la \
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__append_14) \
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	$(CLOCK_GETTIME_LINK)
@@ -1084,53 +1145,81 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
 @HAVE_ELF_TRUE@@NATIVE_TRUE@	$(CLOCK_GETTIME_LINK)
 @HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_SOURCES = $(ztest_SOURCES)
 @HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_CFLAGS = $(ztest_CFLAGS)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_SOURCES = zstdtest.c testlib.c
+@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
+@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_LDFLAGS = $(libbacktrace_testing_ldflags)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_LDADD = libbacktrace.la \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__append_17) \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(CLOCK_GETTIME_LINK)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_alloc_LDADD =  \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	libbacktrace_alloc.la \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(am__append_18) \
+@HAVE_ELF_TRUE@@NATIVE_TRUE@	$(CLOCK_GETTIME_LINK)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_alloc_SOURCES = $(zstdtest_SOURCES)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_alloc_CFLAGS = $(zstdtest_CFLAGS)
+@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@edtest_SOURCES = edtest.c edtest2_build.c testlib.c
 @NATIVE_TRUE@edtest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@edtest_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@edtest_LDADD = libbacktrace.la
 @NATIVE_TRUE@edtest_alloc_SOURCES = $(edtest_SOURCES)
 @NATIVE_TRUE@edtest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@NATIVE_TRUE@edtest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@edtest_alloc_LDADD = libbacktrace_alloc.la
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_SOURCES = ttest.c testlib.c
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -pthread
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_LDFLAGS = $(libbacktrace_testing_ldflags)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_LDADD = libbacktrace.la
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_alloc_SOURCES = $(ttest_SOURCES)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_alloc_CFLAGS = $(ttest_CFLAGS)
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_alloc_LDADD = libbacktrace_alloc.la
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_SOURCES = btest.c testlib.c
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu $(libbacktrace_testing_ldflags)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_LDADD = libbacktrace.la
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_SOURCES = btest.c testlib.c
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi $(libbacktrace_testing_ldflags)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDADD = libbacktrace.la
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_SOURCES = btest.c testlib.c
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_LDFLAGS = -Wl,--compress-debug-sections=zstd $(libbacktrace_testing_ldflags)
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_LDADD = libbacktrace.la
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_alloc_SOURCES = $(ctestg_SOURCES)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS)
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS) $(libbacktrace_testing_ldflags)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_alloc_LDADD = libbacktrace_alloc.la
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_alloc_SOURCES = $(ctesta_SOURCES)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS)
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS) $(libbacktrace_testing_ldflags)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_alloc_LDADD = libbacktrace_alloc.la
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_SOURCES = btest.c testlib.c
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_CFLAGS = $(libbacktrace_TEST_CFLAGS) -gdwarf-5
+@HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_LDFLAGS = $(libbacktrace_testing_ldflags)
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_LDADD = libbacktrace.la
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_alloc_SOURCES = $(dwarf5_SOURCES)
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_alloc_CFLAGS = $(dwarf5_CFLAGS)
+@HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_alloc_LDADD = libbacktrace_alloc.la
 @NATIVE_TRUE@mtest_SOURCES = mtest.c testlib.c
 @NATIVE_TRUE@mtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
+@NATIVE_TRUE@mtest_LDFLAGS = $(libbacktrace_testing_ldflags)
 @NATIVE_TRUE@mtest_LDADD = libbacktrace.la
 @HAVE_ELF_TRUE@xztest_SOURCES = xztest.c testlib.c
 @HAVE_ELF_TRUE@xztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
-@HAVE_ELF_TRUE@xztest_LDADD = libbacktrace.la $(am__append_27) \
+@HAVE_ELF_TRUE@xztest_LDFLAGS = $(libbacktrace_testing_ldflags)
+@HAVE_ELF_TRUE@xztest_LDADD = libbacktrace.la $(am__append_31) \
 @HAVE_ELF_TRUE@	$(CLOCK_GETTIME_LINK)
 @HAVE_ELF_TRUE@xztest_alloc_SOURCES = $(xztest_SOURCES)
 @HAVE_ELF_TRUE@xztest_alloc_CFLAGS = $(xztest_CFLAGS)
+@HAVE_ELF_TRUE@xztest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 @HAVE_ELF_TRUE@xztest_alloc_LDADD = libbacktrace_alloc.la \
-@HAVE_ELF_TRUE@	$(am__append_28) $(CLOCK_GETTIME_LINK)
+@HAVE_ELF_TRUE@	$(am__append_32) $(CLOCK_GETTIME_LINK)
 CLEANFILES = \
-       $(filter-out allocfail.sh,$(TESTS)) *.debug elf_for_test.c edtest2_build.c gen_edtest2_build \
+	$(MAKETESTS) $(BUILDTESTS) *.debug elf_for_test.c edtest2_build.c \
+	gen_edtest2_build \
 	*.dsyms *.fsyms *.keepsyms *.dbg *.mdbg *.mdbg.xz *.strip
 
 
@@ -1297,6 +1386,10 @@ ctestg_alloc$(EXEEXT): $(ctestg_alloc_OBJECTS) $(ctestg_alloc_DEPENDENCIES) $(EX
 	@rm -f ctestg_alloc$(EXEEXT)
 	$(AM_V_CCLD)$(ctestg_alloc_LINK) $(ctestg_alloc_OBJECTS) $(ctestg_alloc_LDADD) $(LIBS)
 
+ctestzstd$(EXEEXT): $(ctestzstd_OBJECTS) $(ctestzstd_DEPENDENCIES) $(EXTRA_ctestzstd_DEPENDENCIES) 
+	@rm -f ctestzstd$(EXEEXT)
+	$(AM_V_CCLD)$(ctestzstd_LINK) $(ctestzstd_OBJECTS) $(ctestzstd_LDADD) $(LIBS)
+
 dwarf5$(EXEEXT): $(dwarf5_OBJECTS) $(dwarf5_DEPENDENCIES) $(EXTRA_dwarf5_DEPENDENCIES) 
 	@rm -f dwarf5$(EXEEXT)
 	$(AM_V_CCLD)$(dwarf5_LINK) $(dwarf5_OBJECTS) $(dwarf5_LDADD) $(LIBS)
@@ -1377,6 +1470,14 @@ xztest_alloc$(EXEEXT): $(xztest_alloc_OBJECTS) $(xztest_alloc_DEPENDENCIES) $(EX
 	@rm -f xztest_alloc$(EXEEXT)
 	$(AM_V_CCLD)$(xztest_alloc_LINK) $(xztest_alloc_OBJECTS) $(xztest_alloc_LDADD) $(LIBS)
 
+zstdtest$(EXEEXT): $(zstdtest_OBJECTS) $(zstdtest_DEPENDENCIES) $(EXTRA_zstdtest_DEPENDENCIES) 
+	@rm -f zstdtest$(EXEEXT)
+	$(AM_V_CCLD)$(zstdtest_LINK) $(zstdtest_OBJECTS) $(zstdtest_LDADD) $(LIBS)
+
+zstdtest_alloc$(EXEEXT): $(zstdtest_alloc_OBJECTS) $(zstdtest_alloc_DEPENDENCIES) $(EXTRA_zstdtest_alloc_DEPENDENCIES) 
+	@rm -f zstdtest_alloc$(EXEEXT)
+	$(AM_V_CCLD)$(zstdtest_alloc_LINK) $(zstdtest_alloc_OBJECTS) $(zstdtest_alloc_LDADD) $(LIBS)
+
 ztest$(EXEEXT): $(ztest_OBJECTS) $(ztest_DEPENDENCIES) $(EXTRA_ztest_DEPENDENCIES) 
 	@rm -f ztest$(EXEEXT)
 	$(AM_V_CCLD)$(ztest_LINK) $(ztest_OBJECTS) $(ztest_LDADD) $(LIBS)
@@ -1520,6 +1621,18 @@ ctestg_alloc-testlib.o: testlib.c
 ctestg_alloc-testlib.obj: testlib.c
 	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestg_alloc_CFLAGS) $(CFLAGS) -c -o ctestg_alloc-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
 
+ctestzstd-btest.o: btest.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestzstd_CFLAGS) $(CFLAGS) -c -o ctestzstd-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c
+
+ctestzstd-btest.obj: btest.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestzstd_CFLAGS) $(CFLAGS) -c -o ctestzstd-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi`
+
+ctestzstd-testlib.o: testlib.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestzstd_CFLAGS) $(CFLAGS) -c -o ctestzstd-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
+
+ctestzstd-testlib.obj: testlib.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestzstd_CFLAGS) $(CFLAGS) -c -o ctestzstd-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
+
 dwarf5-btest.o: btest.c
 	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dwarf5_CFLAGS) $(CFLAGS) -c -o dwarf5-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c
 
@@ -1760,6 +1873,30 @@ xztest_alloc-testlib.o: testlib.c
 xztest_alloc-testlib.obj: testlib.c
 	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xztest_alloc_CFLAGS) $(CFLAGS) -c -o xztest_alloc-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
 
+zstdtest-zstdtest.o: zstdtest.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_CFLAGS) $(CFLAGS) -c -o zstdtest-zstdtest.o `test -f 'zstdtest.c' || echo '$(srcdir)/'`zstdtest.c
+
+zstdtest-zstdtest.obj: zstdtest.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_CFLAGS) $(CFLAGS) -c -o zstdtest-zstdtest.obj `if test -f 'zstdtest.c'; then $(CYGPATH_W) 'zstdtest.c'; else $(CYGPATH_W) '$(srcdir)/zstdtest.c'; fi`
+
+zstdtest-testlib.o: testlib.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_CFLAGS) $(CFLAGS) -c -o zstdtest-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
+
+zstdtest-testlib.obj: testlib.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_CFLAGS) $(CFLAGS) -c -o zstdtest-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
+
+zstdtest_alloc-zstdtest.o: zstdtest.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_alloc_CFLAGS) $(CFLAGS) -c -o zstdtest_alloc-zstdtest.o `test -f 'zstdtest.c' || echo '$(srcdir)/'`zstdtest.c
+
+zstdtest_alloc-zstdtest.obj: zstdtest.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_alloc_CFLAGS) $(CFLAGS) -c -o zstdtest_alloc-zstdtest.obj `if test -f 'zstdtest.c'; then $(CYGPATH_W) 'zstdtest.c'; else $(CYGPATH_W) '$(srcdir)/zstdtest.c'; fi`
+
+zstdtest_alloc-testlib.o: testlib.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_alloc_CFLAGS) $(CFLAGS) -c -o zstdtest_alloc-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
+
+zstdtest_alloc-testlib.obj: testlib.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_alloc_CFLAGS) $(CFLAGS) -c -o zstdtest_alloc-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
+
 ztest-ztest.o: ztest.c
 	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ztest_CFLAGS) $(CFLAGS) -c -o ztest-ztest.o `test -f 'ztest.c' || echo '$(srcdir)/'`ztest.c
 
@@ -2007,6 +2144,13 @@ b2test_buildid.log: b2test_buildid
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+b2test_buildidfull.log: b2test_buildidfull
+	@p='b2test_buildidfull'; \
+	b='b2test_buildidfull'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 b3test_dwz_buildid.log: b3test_dwz_buildid
 	@p='b3test_dwz_buildid'; \
 	b='b3test_dwz_buildid'; \
@@ -2014,6 +2158,13 @@ b3test_dwz_buildid.log: b3test_dwz_buildid
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+b3test_dwz_buildidfull.log: b3test_dwz_buildidfull
+	@p='b3test_dwz_buildidfull'; \
+	b='b3test_dwz_buildidfull'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 btest_dwz.log: btest_dwz
 	@p='btest_dwz'; \
 	b='btest_dwz'; \
@@ -2035,6 +2186,13 @@ btest_gnudebuglink.log: btest_gnudebuglink
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+btest_gnudebuglinkfull.log: btest_gnudebuglinkfull
+	@p='btest_gnudebuglinkfull'; \
+	b='btest_gnudebuglinkfull'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 mtest_minidebug.log: mtest_minidebug
 	@p='mtest_minidebug'; \
 	b='mtest_minidebug'; \
@@ -2154,6 +2312,20 @@ ztest_alloc.log: ztest_alloc$(EXEEXT)
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+zstdtest.log: zstdtest$(EXEEXT)
+	@p='zstdtest$(EXEEXT)'; \
+	b='zstdtest'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+zstdtest_alloc.log: zstdtest_alloc$(EXEEXT)
+	@p='zstdtest_alloc$(EXEEXT)'; \
+	b='zstdtest_alloc'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 edtest.log: edtest$(EXEEXT)
 	@p='edtest$(EXEEXT)'; \
 	b='edtest'; \
@@ -2196,6 +2368,13 @@ ctesta.log: ctesta$(EXEEXT)
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+ctestzstd.log: ctestzstd$(EXEEXT)
+	@p='ctestzstd$(EXEEXT)'; \
+	b='ctestzstd'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 ctestg_alloc.log: ctestg_alloc$(EXEEXT)
 	@p='ctestg_alloc$(EXEEXT)'; \
 	b='ctestg_alloc'; \
@@ -2408,18 +2587,18 @@ uninstall-am:
 @HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@	mv $@.tmp $@
 
 @NATIVE_TRUE@elf_%.c: elf.c
+@NATIVE_TRUE@	nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
 @NATIVE_TRUE@	SEARCH='#error "Unknown BACKTRACE_ELF_SIZE"'; \
-@NATIVE_TRUE@	REPLACE='#undef BACKTRACE_ELF_SIZE\
-@NATIVE_TRUE@	#define BACKTRACE_ELF_SIZE'; \
+@NATIVE_TRUE@	REPLACE="#undef BACKTRACE_ELF_SIZE\\$${nl}#define BACKTRACE_ELF_SIZE"; \
 @NATIVE_TRUE@	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
 @NATIVE_TRUE@		$< \
 @NATIVE_TRUE@		> $@.tmp
 @NATIVE_TRUE@	mv $@.tmp $@
 
 @NATIVE_TRUE@xcoff_%.c: xcoff.c
+@NATIVE_TRUE@	nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
 @NATIVE_TRUE@	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
-@NATIVE_TRUE@	REPLACE='#undef BACKTRACE_XCOFF_SIZE\
-@NATIVE_TRUE@	#define BACKTRACE_XCOFF_SIZE'; \
+@NATIVE_TRUE@	REPLACE="#undef BACKTRACE_XCOFF_SIZE\\$${nl}#define BACKTRACE_XCOFF_SIZE"; \
 @NATIVE_TRUE@	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
 @NATIVE_TRUE@		$< \
 @NATIVE_TRUE@		> $@.tmp
@@ -2451,15 +2630,25 @@ uninstall-am:
 @HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@	$(OBJCOPY) --only-keep-debug $< $@.debug
 @HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@	$(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@
 
+@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@%_gnudebuglinkfull: %
+@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@	$(OBJCOPY) --only-keep-debug $< $@.debug
+@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@	$(OBJCOPY) --strip-all --add-gnu-debuglink=$@.debug $< $@
+
 @NATIVE_TRUE@%_buildid: %
 @NATIVE_TRUE@	./install-debuginfo-for-buildid.sh \
 @NATIVE_TRUE@	  "$(TEST_BUILD_ID_DIR)" \
 @NATIVE_TRUE@	  $<
 @NATIVE_TRUE@	$(OBJCOPY) --strip-debug $< $@
 
+@NATIVE_TRUE@%_buildidfull: %
+@NATIVE_TRUE@	./install-debuginfo-for-buildid.sh \
+@NATIVE_TRUE@	  "$(TEST_BUILD_ID_DIR)" \
+@NATIVE_TRUE@	  $<
+@NATIVE_TRUE@	$(OBJCOPY) --strip-all $< $@
+
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@%_minidebug: %
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
-@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
+@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(OBJCOPY) --only-keep-debug $< $<.dbg
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
diff --git a/libbacktrace/README b/libbacktrace/README
index e8b225745c9..6225f92b855 100644
--- a/libbacktrace/README
+++ b/libbacktrace/README
@@ -1,23 +1,31 @@
 The libbacktrace library
-Initially written by Ian Lance Taylor <iant@google.com>
+Initially written by Ian Lance Taylor <iant@golang.org>
 
 The libbacktrace library may be linked into a program or library and
-used to produce symbolic backtraces.  Sample uses would be to print a
-detailed backtrace when an error occurs or to gather detailed
-profiling information.
+used to produce symbolic backtraces.
+Sample uses would be to print a detailed backtrace when an error
+occurs or to gather detailed profiling information.
+In general the functions provided by this library are async-signal-safe,
+meaning that they may be safely called from a signal handler.
 
-The libbacktrace library is provided under a BSD license.  See the
-source files for the exact license text.
+The libbacktrace library is provided under a BSD license.
+See the source files for the exact license text.
 
 The public functions are declared and documented in the header file
 backtrace.h, which should be #include'd by a user of the library.
 
 Building libbacktrace will generate a file backtrace-supported.h,
 which a user of the library may use to determine whether backtraces
-will work.  See the source file backtrace-supported.h.in for the
-macros that it defines.
+will work.
+See the source file backtrace-supported.h.in for the macros that it
+defines.
 
-As of September 2012, libbacktrace only supports ELF executables with
-DWARF debugging information.  The library is written to make it
-straightforward to add support for other object file and debugging
-formats.
+As of October 2020, libbacktrace supports ELF, PE/COFF, Mach-O, and
+XCOFF executables with DWARF debugging information.
+In other words, it supports GNU/Linux, *BSD, macOS, Windows, and AIX.
+The library is written to make it straightforward to add support for
+other object file and debugging formats.
+
+The library relies on the C++ unwind API defined at
+https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
+This API is provided by GCC and clang.
diff --git a/libbacktrace/alloc.c b/libbacktrace/alloc.c
index ff2c8677c06..193e770526b 100644
--- a/libbacktrace/alloc.c
+++ b/libbacktrace/alloc.c
@@ -1,5 +1,5 @@
 /* alloc.c -- Memory allocation without mmap.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/allocfail.c b/libbacktrace/allocfail.c
index bd0fbb658a9..fb92821f3f0 100644
--- a/libbacktrace/allocfail.c
+++ b/libbacktrace/allocfail.c
@@ -1,5 +1,5 @@
 /* allocfail.c -- Test for libbacktrace library
-   Copyright (C) 2018-2021 Free Software Foundation, Inc.
+   Copyright (C) 2018-2024 Free Software Foundation, Inc.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
diff --git a/libbacktrace/allocfail.sh b/libbacktrace/allocfail.sh
index 1f9894fd2e8..06326765b39 100755
--- a/libbacktrace/allocfail.sh
+++ b/libbacktrace/allocfail.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 # allocfail.sh -- Test for libbacktrace library.
-# Copyright (C) 2018-2021 Free Software Foundation, Inc.
+# Copyright (C) 2018-2024 Free Software Foundation, Inc.
 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
diff --git a/libbacktrace/atomic.c b/libbacktrace/atomic.c
index fcac485b237..21785a19e87 100644
--- a/libbacktrace/atomic.c
+++ b/libbacktrace/atomic.c
@@ -1,5 +1,5 @@
 /* atomic.c -- Support for atomic functions if not present.
-   Copyright (C) 2013-2021 Free Software Foundation, Inc.
+   Copyright (C) 2013-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/backtrace-supported.h.in b/libbacktrace/backtrace-supported.h.in
index 2035c853a62..d9f3030f55d 100644
--- a/libbacktrace/backtrace-supported.h.in
+++ b/libbacktrace/backtrace-supported.h.in
@@ -1,5 +1,5 @@
 /* backtrace-supported.h.in -- Whether stack backtrace is supported.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/backtrace.c b/libbacktrace/backtrace.c
index 7b629008525..3e6b81e9a3f 100644
--- a/libbacktrace/backtrace.c
+++ b/libbacktrace/backtrace.c
@@ -1,5 +1,5 @@
 /* backtrace.c -- Entry point for stack backtrace library.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/backtrace.h b/libbacktrace/backtrace.h
index caaa66d3686..b73e27e06cd 100644
--- a/libbacktrace/backtrace.h
+++ b/libbacktrace/backtrace.h
@@ -1,5 +1,5 @@
 /* backtrace.h -- Public header file for stack backtrace library.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/btest.c b/libbacktrace/btest.c
index 7ef6d320497..d9fc372d33d 100644
--- a/libbacktrace/btest.c
+++ b/libbacktrace/btest.c
@@ -1,5 +1,5 @@
 /* btest.c -- Test for libbacktrace library
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/config.h.in b/libbacktrace/config.h.in
index cdb416e6406..ee2616335c7 100644
--- a/libbacktrace/config.h.in
+++ b/libbacktrace/config.h.in
@@ -20,6 +20,10 @@
    don't. */
 #undef HAVE_DECL_STRNLEN
 
+/* Define to 1 if you have the declaration of `_pgmptr', and to 0 if you
+   don't. */
+#undef HAVE_DECL__PGMPTR
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
@@ -85,6 +89,9 @@
 /* Define to 1 if you have the <sys/ldr.h> header file. */
 #undef HAVE_SYS_LDR_H
 
+/* Define to 1 if you have the <sys/link.h> header file. */
+#undef HAVE_SYS_LINK_H
+
 /* Define to 1 if you have the <sys/mman.h> header file. */
 #undef HAVE_SYS_MMAN_H
 
@@ -97,9 +104,15 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to 1 if you have the <windows.h> header file. */
+#undef HAVE_WINDOWS_H
+
 /* Define if -lz is available. */
 #undef HAVE_ZLIB
 
+/* Define if -lzstd is available. */
+#undef HAVE_ZSTD
+
 /* Define to the sub-directory in which libtool stores uninstalled libraries.
    */
 #undef LT_OBJDIR
diff --git a/libbacktrace/configure b/libbacktrace/configure
index e5ca8ad9379..7ade966b54d 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -651,8 +651,14 @@ HAVE_OBJCOPY_DEBUGLINK_FALSE
 HAVE_OBJCOPY_DEBUGLINK_TRUE
 READELF
 OBJCOPY
+HAVE_COMPRESSED_DEBUG_ZSTD_FALSE
+HAVE_COMPRESSED_DEBUG_ZSTD_TRUE
+HAVE_ZSTD_FALSE
+HAVE_ZSTD_TRUE
 HAVE_COMPRESSED_DEBUG_FALSE
 HAVE_COMPRESSED_DEBUG_TRUE
+HAVE_BUILDID_FALSE
+HAVE_BUILDID_TRUE
 HAVE_ZLIB_FALSE
 HAVE_ZLIB_TRUE
 HAVE_DWARF5_FALSE
@@ -675,6 +681,8 @@ PIC_FLAG
 WARN_FLAGS
 EXTRA_FLAGS
 BACKTRACE_FILE
+ENABLE_DARWIN_AT_RPATH_FALSE
+ENABLE_DARWIN_AT_RPATH_TRUE
 OTOOL64
 OTOOL
 LIPO
@@ -799,8 +807,10 @@ with_pic
 enable_fast_install
 with_gnu_ld
 enable_libtool_lock
+enable_darwin_at_rpath
 enable_largefile
 enable_cet
+enable_werror
 with_system_libunwind
 enable_host_shared
 '
@@ -1446,8 +1456,12 @@ Optional Features:
   --enable-fast-install[=PKGS]
                           optimize for fast installation [default=yes]
   --disable-libtool-lock  avoid locking (might break parallel builds)
+  --enable-darwin-at-rpath
+                          install libraries with @rpath/library-name, requires
+                          rpaths to be added to executables
   --disable-largefile     omit support for large files
   --enable-cet            enable Intel CET in target libraries [default=auto]
+  --disable-werror        disable building with -Werror
   --enable-host-shared    build host code as shared libraries
   --enable-cet            enable Intel CET in host libraries [default=auto]
 
@@ -8040,7 +8054,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
       # deployment target is forced to an earlier version.
       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
+	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
 	  ;;
 	10.[012][,.]*)
 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
@@ -9746,6 +9760,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
     darwin* | rhapsody*)
 
 
+
+  # Publish an arg to allow the user to select that Darwin host (and target)
+  # libraries should be given install-names like @rpath/libfoo.dylib.  This
+  # requires that the user of the library then adds an 'rpath' to the DSO that
+  # needs access.
+  # NOTE: there are defaults below, for systems that support rpaths.  The person
+  # configuring can override the defaults for any system version that supports
+  # them - they are, however, forced off for system versions without support.
+  # Check whether --enable-darwin-at-rpath was given.
+if test "${enable_darwin_at_rpath+set}" = set; then :
+  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
+    # This is not supported before macOS 10.5 / Darwin9.
+    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
+      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
+$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
+	enable_darwin_at_rpath=no
+      ;;
+    esac
+   fi
+else
+  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
+    # As above, before 10.5 / Darwin9 this does not work.
+     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
+       enable_darwin_at_rpath=no
+       ;;
+
+    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
+    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
+    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
+      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
+      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
+$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
+      enable_darwin_at_rpath=yes
+      ;;
+    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
+    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
+
+    esac
+
+fi
+
+
   archive_cmds_need_lc=no
   hardcode_direct=no
   hardcode_automatic=yes
@@ -9763,9 +9820,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
   esac
   if test "$_lt_dar_can_shared" = "yes"; then
     output_verbose_link_cmd=func_echo_all
-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    _lt_install_name='\$rpath/\$soname'
+    if test "x$enable_darwin_at_rpath" = "xyes"; then
+      _lt_install_name='@rpath/\$soname'
+    fi
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
 
   else
@@ -11571,7 +11632,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11574 "configure"
+#line 11635 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11677,7 +11738,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11680 "configure"
+#line 11741 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11916,6 +11977,15 @@ CC="$lt_save_CC"
 
 
 
+ if test x$enable_darwin_at_rpath = xyes; then
+  ENABLE_DARWIN_AT_RPATH_TRUE=
+  ENABLE_DARWIN_AT_RPATH_FALSE='#'
+else
+  ENABLE_DARWIN_AT_RPATH_TRUE='#'
+  ENABLE_DARWIN_AT_RPATH_FALSE=
+fi
+
+
 # Check whether --enable-largefile was given.
 if test "${enable_largefile+set}" = set; then :
   enableval=$enable_largefile;
@@ -12362,10 +12432,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-if test -n "${with_target_subdir}"; then
-  WARN_FLAGS="$WARN_FLAGS -Werror"
+# Check whether --enable-werror was given.
+if test "${enable_werror+set}" = set; then :
+  enableval=$enable_werror;
 fi
 
+if test "x$enable_werror" != "xno" && test -n "${with_target_subdir}"; then :
+  WARN_FLAGS="$WARN_FLAGS -Werror"
+fi
 
 
 if test -n "${with_target_subdir}"; then
@@ -13323,26 +13397,31 @@ fi
 
 
 # Check for dl_iterate_phdr.
-for ac_header in link.h
+for ac_header in link.h sys/link.h
 do :
-  ac_fn_c_check_header_mongrel "$LINENO" "link.h" "ac_cv_header_link_h" "$ac_includes_default"
-if test "x$ac_cv_header_link_h" = xyes; then :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LINK_H 1
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
 
 done
 
-if test "$ac_cv_header_link_h" = "no"; then
+if test "$ac_cv_header_link_h" = "no" -a "$ac_cv_header_sys_link_h" = "no"; then
   have_dl_iterate_phdr=no
 else
   if test -n "${with_target_subdir}"; then
+    link_h=link.h
+    if test "$ac_cv_header_link_h" = "no"; then
+       link_h=sys/link.h
+    fi
     # When built as a GCC target library, we can't do a link test.
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <link.h>
+#include <$link_h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
@@ -13430,6 +13509,19 @@ $as_echo "#define HAVE_LOADQUERY 1" >>confdefs.h
 
 fi
 
+for ac_header in windows.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default"
+if test "x$ac_cv_header_windows_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_WINDOWS_H 1
+_ACEOF
+
+fi
+
+done
+
+
 # Check for the fcntl function.
 if test -n "${with_target_subdir}"; then
    case "${host}" in
@@ -13506,6 +13598,19 @@ $as_echo "#define HAVE_GETEXECNAME 1" >>confdefs.h
 
 fi
 
+# Check for _pgmptr variable, contains the executable filename on windows
+ac_fn_c_check_decl "$LINENO" "_pgmptr" "ac_cv_have_decl__pgmptr" "$ac_includes_default"
+if test "x$ac_cv_have_decl__pgmptr" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL__PGMPTR $ac_have_decl
+_ACEOF
+
+
 # Check for sysctl definitions.
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for KERN_PROC" >&5
@@ -13765,6 +13870,44 @@ else
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether --build-id is supported" >&5
+$as_echo_n "checking whether --build-id is supported... " >&6; }
+if ${libbacktrace_cv_ld_buildid+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  LDFLAGS_hold=$LDFLAGS
+LDFLAGS="$LDFLAGS -Wl,--build-id"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  libbacktrace_cv_ld_buildid=yes
+else
+  libbacktrace_cv_ld_buildid=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LDFLAGS=$LDFLAGS_hold
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_ld_buildid" >&5
+$as_echo "$libbacktrace_cv_ld_buildid" >&6; }
+ if test "$libbacktrace_cv_ld_buildid" = yes; then
+  HAVE_BUILDID_TRUE=
+  HAVE_BUILDID_FALSE='#'
+else
+  HAVE_BUILDID_TRUE='#'
+  HAVE_BUILDID_FALSE=
+fi
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether --compress-debug-sections is supported" >&5
 $as_echo_n "checking whether --compress-debug-sections is supported... " >&6; }
 if ${libgo_cv_ld_compress+:} false; then :
@@ -13803,6 +13946,95 @@ else
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZSTD_compress in -lzstd" >&5
+$as_echo_n "checking for ZSTD_compress in -lzstd... " >&6; }
+if ${ac_cv_lib_zstd_ZSTD_compress+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lzstd  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ZSTD_compress ();
+int
+main ()
+{
+return ZSTD_compress ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_zstd_ZSTD_compress=yes
+else
+  ac_cv_lib_zstd_ZSTD_compress=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_zstd_ZSTD_compress" >&5
+$as_echo "$ac_cv_lib_zstd_ZSTD_compress" >&6; }
+if test "x$ac_cv_lib_zstd_ZSTD_compress" = xyes; then :
+
+$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+
+fi
+
+ if test "$ac_cv_lib_zstd_ZSTD_compress" = yes; then
+  HAVE_ZSTD_TRUE=
+  HAVE_ZSTD_FALSE='#'
+else
+  HAVE_ZSTD_TRUE='#'
+  HAVE_ZSTD_FALSE=
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether --compress-debug-sections=zstd is supported" >&5
+$as_echo_n "checking whether --compress-debug-sections=zstd is supported... " >&6; }
+if ${libgo_cv_ld_compress_zstd+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  LDFLAGS_hold=$LDFLAGS
+LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zstd"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  libgo_cv_ld_compress_zstd=yes
+else
+  libgo_cv_ld_compress_zstd=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LDFLAGS=$LDFLAGS_hold
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgo_cv_ld_compress_zstd" >&5
+$as_echo "$libgo_cv_ld_compress_zstd" >&6; }
+ if test "$libgo_cv_ld_compress_zstd" = yes; then
+  HAVE_COMPRESSED_DEBUG_ZSTD_TRUE=
+  HAVE_COMPRESSED_DEBUG_ZSTD_FALSE='#'
+else
+  HAVE_COMPRESSED_DEBUG_ZSTD_TRUE='#'
+  HAVE_COMPRESSED_DEBUG_ZSTD_FALSE=
+fi
+
+
 
 # Extract the first word of "objcopy", so it can be a program name with args.
 set dummy objcopy; ac_word=$2
@@ -13887,7 +14119,7 @@ else
   libbacktrace_cv_objcopy_debuglink=no
 elif ! test -n "${OBJCOPY}"; then
   libbacktrace_cv_objcopy_debuglink=no
-elif ${OBJCOPY} --help | fgrep add-gnu-debuglink >/dev/null 2>&1; then
+elif ${OBJCOPY} --help | grep add-gnu-debuglink >/dev/null 2>&1; then
   libbacktrace_cv_objcopy_debuglink=yes
 else
   libbacktrace_cv_objcopy_debuglink=no
@@ -14329,6 +14561,10 @@ if test -z "${HAVE_DWZ_TRUE}" && test -z "${HAVE_DWZ_FALSE}"; then
   as_fn_error $? "conditional \"HAVE_DWZ\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
+  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${HAVE_ELF_TRUE}" && test -z "${HAVE_ELF_FALSE}"; then
   as_fn_error $? "conditional \"HAVE_ELF\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -14345,10 +14581,22 @@ if test -z "${HAVE_ZLIB_TRUE}" && test -z "${HAVE_ZLIB_FALSE}"; then
   as_fn_error $? "conditional \"HAVE_ZLIB\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${HAVE_BUILDID_TRUE}" && test -z "${HAVE_BUILDID_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_BUILDID\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${HAVE_COMPRESSED_DEBUG_TRUE}" && test -z "${HAVE_COMPRESSED_DEBUG_FALSE}"; then
   as_fn_error $? "conditional \"HAVE_COMPRESSED_DEBUG\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${HAVE_ZSTD_TRUE}" && test -z "${HAVE_ZSTD_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_ZSTD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${HAVE_COMPRESSED_DEBUG_ZSTD_TRUE}" && test -z "${HAVE_COMPRESSED_DEBUG_ZSTD_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_COMPRESSED_DEBUG_ZSTD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${HAVE_OBJCOPY_DEBUGLINK_TRUE}" && test -z "${HAVE_OBJCOPY_DEBUGLINK_FALSE}"; then
   as_fn_error $? "conditional \"HAVE_OBJCOPY_DEBUGLINK\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index 43a33a66b82..0f61f2b28ab 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -1,5 +1,5 @@
 # configure.ac -- Backtrace configure script.
-# Copyright (C) 2012-2021 Free Software Foundation, Inc.
+# Copyright (C) 2012-2024 Free Software Foundation, Inc.
 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
@@ -84,6 +84,8 @@ AM_CONDITIONAL(HAVE_DWZ, test "$DWZ" != "")
 LT_INIT
 AM_PROG_LIBTOOL
 
+AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
+
 AC_SYS_LARGEFILE
 
 backtrace_supported=yes
@@ -145,10 +147,10 @@ ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
 			  -Wmissing-format-attribute -Wcast-qual],
 			  [WARN_FLAGS])
 
-if test -n "${with_target_subdir}"; then
-  WARN_FLAGS="$WARN_FLAGS -Werror"
-fi
-
+AC_ARG_ENABLE([werror],
+  [AS_HELP_STRING([--disable-werror], [disable building with -Werror])])
+AS_IF([test "x$enable_werror" != "xno" && test -n "${with_target_subdir}"],
+  [WARN_FLAGS="$WARN_FLAGS -Werror"])
 AC_SUBST(WARN_FLAGS)
 
 if test -n "${with_target_subdir}"; then
@@ -335,13 +337,17 @@ fi
 AC_SUBST(BACKTRACE_USES_MALLOC)
 
 # Check for dl_iterate_phdr.
-AC_CHECK_HEADERS(link.h)
-if test "$ac_cv_header_link_h" = "no"; then
+AC_CHECK_HEADERS(link.h sys/link.h)
+if test "$ac_cv_header_link_h" = "no" -a "$ac_cv_header_sys_link_h" = "no"; then
   have_dl_iterate_phdr=no
 else
   if test -n "${with_target_subdir}"; then
+    link_h=link.h
+    if test "$ac_cv_header_link_h" = "no"; then
+       link_h=sys/link.h
+    fi
     # When built as a GCC target library, we can't do a link test.
-    AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
+    AC_EGREP_HEADER([dl_iterate_phdr], [$link_h], [have_dl_iterate_phdr=yes],
 		    [have_dl_iterate_phdr=no])
   else
     AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes],
@@ -373,6 +379,8 @@ if test "$have_loadquery" = "yes"; then
   AC_DEFINE(HAVE_LOADQUERY, 1, [Define if AIX loadquery is available.])
 fi
 
+AC_CHECK_HEADERS(windows.h)
+
 # Check for the fcntl function.
 if test -n "${with_target_subdir}"; then
    case "${host}" in
@@ -403,6 +411,9 @@ if test "$have_getexecname" = "yes"; then
   AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
 fi
 
+# Check for _pgmptr variable, contains the executable filename on windows
+AC_CHECK_DECLS([_pgmptr])
+
 # Check for sysctl definitions.
 
 AC_CACHE_CHECK([for KERN_PROC],
@@ -480,7 +491,18 @@ AC_CHECK_LIB([z], [compress],
     [AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
 AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
 
-dnl Test whether the linker supports the --compress_debug_sections option.
+dnl Test whether the linker supports the --build-id option.
+AC_CACHE_CHECK([whether --build-id is supported],
+[libbacktrace_cv_ld_buildid],
+[LDFLAGS_hold=$LDFLAGS
+LDFLAGS="$LDFLAGS -Wl,--build-id"
+AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
+[libbacktrace_cv_ld_buildid=yes],
+[libbacktrace_cv_ld_buildid=no])
+LDFLAGS=$LDFLAGS_hold])
+AM_CONDITIONAL(HAVE_BUILDID, test "$libbacktrace_cv_ld_buildid" = yes)
+
+dnl Test whether the linker supports the --compress-debug-sections option.
 AC_CACHE_CHECK([whether --compress-debug-sections is supported],
 [libgo_cv_ld_compress],
 [LDFLAGS_hold=$LDFLAGS
@@ -491,6 +513,21 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
 LDFLAGS=$LDFLAGS_hold])
 AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
 
+AC_CHECK_LIB([zstd], [ZSTD_compress],
+    [AC_DEFINE(HAVE_ZSTD, 1, [Define if -lzstd is available.])])
+AM_CONDITIONAL(HAVE_ZSTD, test "$ac_cv_lib_zstd_ZSTD_compress" = yes)
+
+dnl Test whether the linker supports --compress-debug-sections=zstd option.
+AC_CACHE_CHECK([whether --compress-debug-sections=zstd is supported],
+[libgo_cv_ld_compress_zstd],
+[LDFLAGS_hold=$LDFLAGS
+LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zstd"
+AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
+[libgo_cv_ld_compress_zstd=yes],
+[libgo_cv_ld_compress_zstd=no])
+LDFLAGS=$LDFLAGS_hold])
+AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZSTD, test "$libgo_cv_ld_compress_zstd" = yes)
+
 AC_ARG_VAR(OBJCOPY, [location of objcopy])
 AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,)
 AC_CHECK_PROG(READELF, readelf, readelf)
@@ -500,7 +537,7 @@ AC_CACHE_CHECK([whether objcopy supports debuglink],
   libbacktrace_cv_objcopy_debuglink=no
 elif ! test -n "${OBJCOPY}"; then
   libbacktrace_cv_objcopy_debuglink=no
-elif ${OBJCOPY} --help | fgrep add-gnu-debuglink >/dev/null 2>&1; then
+elif ${OBJCOPY} --help | grep add-gnu-debuglink >/dev/null 2>&1; then
   libbacktrace_cv_objcopy_debuglink=yes
 else
   libbacktrace_cv_objcopy_debuglink=no
diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c
index e6b1f238cd3..ed0672964c2 100644
--- a/libbacktrace/dwarf.c
+++ b/libbacktrace/dwarf.c
@@ -1,5 +1,5 @@
 /* dwarf.c -- Get file/line information from DWARF for backtraces.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
@@ -136,7 +136,7 @@ enum attr_val_encoding
   /* An address.  */
   ATTR_VAL_ADDRESS,
   /* An index into the .debug_addr section, whose value is relative to
-   * the DW_AT_addr_base attribute of the compilation unit.  */
+     the DW_AT_addr_base attribute of the compilation unit.  */
   ATTR_VAL_ADDRESS_INDEX,
   /* A unsigned integer.  */
   ATTR_VAL_UINT,
@@ -274,8 +274,8 @@ struct function
 struct function_addrs
 {
   /* Range is LOW <= PC < HIGH.  */
-  uint64_t low;
-  uint64_t high;
+  uintptr_t low;
+  uintptr_t high;
   /* Function for this address range.  */
   struct function *function;
 };
@@ -356,8 +356,8 @@ struct unit
 struct unit_addrs
 {
   /* Range is LOW <= PC < HIGH.  */
-  uint64_t low;
-  uint64_t high;
+  uintptr_t low;
+  uintptr_t high;
   /* Compilation unit for this address range.  */
   struct unit *u;
 };
@@ -1094,7 +1094,7 @@ resolve_addr_index (const struct dwarf_sections *dwarf_sections,
 		    uint64_t addr_base, int addrsize, int is_bigendian,
 		    uint64_t addr_index,
 		    backtrace_error_callback error_callback, void *data,
-		    uint64_t *address)
+		    uintptr_t *address)
 {
   uint64_t offset;
   struct dwarf_buf addr_buf;
@@ -1115,7 +1115,7 @@ resolve_addr_index (const struct dwarf_sections *dwarf_sections,
   addr_buf.data = data;
   addr_buf.reported_underflow = 0;
 
-  *address = read_address (&addr_buf, addrsize);
+  *address = (uintptr_t) read_address (&addr_buf, addrsize);
   return 1;
 }
 
@@ -1194,7 +1194,7 @@ function_addrs_search (const void *vkey, const void *ventry)
 
 static int
 add_unit_addr (struct backtrace_state *state, void *rdata,
-	       uint64_t lowpc, uint64_t highpc,
+	       uintptr_t lowpc, uintptr_t highpc,
 	       backtrace_error_callback error_callback, void *data,
 	       void *pvec)
 {
@@ -1530,10 +1530,10 @@ lookup_abbrev (struct abbrevs *abbrevs, uint64_t code,
    lowpc/highpc is set or ranges is set.  */
 
 struct pcrange {
-  uint64_t lowpc;		/* The low PC value.  */
+  uintptr_t lowpc;             /* The low PC value.  */
   int have_lowpc;		/* Whether a low PC value was found.  */
   int lowpc_is_addr_index;	/* Whether lowpc is in .debug_addr.  */
-  uint64_t highpc;		/* The high PC value.  */
+  uintptr_t highpc;            /* The high PC value.  */
   int have_highpc;		/* Whether a high PC value was found.  */
   int highpc_is_relative;	/* Whether highpc is relative to lowpc.  */
   int highpc_is_addr_index;	/* Whether highpc is in .debug_addr.  */
@@ -1553,12 +1553,12 @@ update_pcrange (const struct attr* attr, const struct attr_val* val,
     case DW_AT_low_pc:
       if (val->encoding == ATTR_VAL_ADDRESS)
 	{
-	  pcrange->lowpc = val->u.uint;
+	  pcrange->lowpc = (uintptr_t) val->u.uint;
 	  pcrange->have_lowpc = 1;
 	}
       else if (val->encoding == ATTR_VAL_ADDRESS_INDEX)
 	{
-	  pcrange->lowpc = val->u.uint;
+	  pcrange->lowpc = (uintptr_t) val->u.uint;
 	  pcrange->have_lowpc = 1;
 	  pcrange->lowpc_is_addr_index = 1;
 	}
@@ -1567,18 +1567,18 @@ update_pcrange (const struct attr* attr, const struct attr_val* val,
     case DW_AT_high_pc:
       if (val->encoding == ATTR_VAL_ADDRESS)
 	{
-	  pcrange->highpc = val->u.uint;
+	  pcrange->highpc = (uintptr_t) val->u.uint;
 	  pcrange->have_highpc = 1;
 	}
       else if (val->encoding == ATTR_VAL_UINT)
 	{
-	  pcrange->highpc = val->u.uint;
+	  pcrange->highpc = (uintptr_t) val->u.uint;
 	  pcrange->have_highpc = 1;
 	  pcrange->highpc_is_relative = 1;
 	}
       else if (val->encoding == ATTR_VAL_ADDRESS_INDEX)
 	{
-	  pcrange->highpc = val->u.uint;
+	  pcrange->highpc = (uintptr_t) val->u.uint;
 	  pcrange->have_highpc = 1;
 	  pcrange->highpc_is_addr_index = 1;
 	}
@@ -1613,16 +1613,16 @@ add_low_high_range (struct backtrace_state *state,
 		    uintptr_t base_address, int is_bigendian,
 		    struct unit *u, const struct pcrange *pcrange,
 		    int (*add_range) (struct backtrace_state *state,
-				      void *rdata, uint64_t lowpc,
-				      uint64_t highpc,
+				      void *rdata, uintptr_t lowpc,
+				      uintptr_t highpc,
 				      backtrace_error_callback error_callback,
 				      void *data, void *vec),
 		    void *rdata,
 		    backtrace_error_callback error_callback, void *data,
 		    void *vec)
 {
-  uint64_t lowpc;
-  uint64_t highpc;
+  uintptr_t lowpc;
+  uintptr_t highpc;
 
   lowpc = pcrange->lowpc;
   if (pcrange->lowpc_is_addr_index)
@@ -1660,10 +1660,10 @@ add_ranges_from_ranges (
     struct backtrace_state *state,
     const struct dwarf_sections *dwarf_sections,
     uintptr_t base_address, int is_bigendian,
-    struct unit *u, uint64_t base,
+    struct unit *u, uintptr_t base,
     const struct pcrange *pcrange,
     int (*add_range) (struct backtrace_state *state, void *rdata,
-		      uint64_t lowpc, uint64_t highpc,
+		      uintptr_t lowpc, uintptr_t highpc,
 		      backtrace_error_callback error_callback, void *data,
 		      void *vec),
     void *rdata,
@@ -1702,12 +1702,12 @@ add_ranges_from_ranges (
 	break;
 
       if (is_highest_address (low, u->addrsize))
-	base = high;
+	base = (uintptr_t) high;
       else
 	{
 	  if (!add_range (state, rdata, 
-			  low + base + base_address,
-			  high + base + base_address,
+			  (uintptr_t) low + base + base_address,
+			  (uintptr_t) high + base + base_address,
 			  error_callback, data, vec))
 	    return 0;
 	}
@@ -1727,10 +1727,10 @@ add_ranges_from_rnglists (
     struct backtrace_state *state,
     const struct dwarf_sections *dwarf_sections,
     uintptr_t base_address, int is_bigendian,
-    struct unit *u, uint64_t base,
+    struct unit *u, uintptr_t base,
     const struct pcrange *pcrange,
     int (*add_range) (struct backtrace_state *state, void *rdata,
-		      uint64_t lowpc, uint64_t highpc,
+		      uintptr_t lowpc, uintptr_t highpc,
 		      backtrace_error_callback error_callback, void *data,
 		      void *vec),
     void *rdata,
@@ -1796,8 +1796,8 @@ add_ranges_from_rnglists (
 	case DW_RLE_startx_endx:
 	  {
 	    uint64_t index;
-	    uint64_t low;
-	    uint64_t high;
+	    uintptr_t low;
+	    uintptr_t high;
 
 	    index = read_uleb128 (&rnglists_buf);
 	    if (!resolve_addr_index (dwarf_sections, u->addr_base,
@@ -1819,8 +1819,8 @@ add_ranges_from_rnglists (
 	case DW_RLE_startx_length:
 	  {
 	    uint64_t index;
-	    uint64_t low;
-	    uint64_t length;
+	    uintptr_t low;
+	    uintptr_t length;
 
 	    index = read_uleb128 (&rnglists_buf);
 	    if (!resolve_addr_index (dwarf_sections, u->addr_base,
@@ -1850,16 +1850,16 @@ add_ranges_from_rnglists (
 	  break;
 
 	case DW_RLE_base_address:
-	  base = read_address (&rnglists_buf, u->addrsize);
+	  base = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
 	  break;
 
 	case DW_RLE_start_end:
 	  {
-	    uint64_t low;
-	    uint64_t high;
+	    uintptr_t low;
+	    uintptr_t high;
 
-	    low = read_address (&rnglists_buf, u->addrsize);
-	    high = read_address (&rnglists_buf, u->addrsize);
+	    low = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
+	    high = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
 	    if (!add_range (state, rdata, low + base_address,
 			    high + base_address, error_callback, data,
 			    vec))
@@ -1869,11 +1869,11 @@ add_ranges_from_rnglists (
 
 	case DW_RLE_start_length:
 	  {
-	    uint64_t low;
-	    uint64_t length;
+	    uintptr_t low;
+	    uintptr_t length;
 
-	    low = read_address (&rnglists_buf, u->addrsize);
-	    length = read_uleb128 (&rnglists_buf);
+	    low = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
+	    length = (uintptr_t) read_uleb128 (&rnglists_buf);
 	    low += base_address;
 	    if (!add_range (state, rdata, low, low + length,
 			    error_callback, data, vec))
@@ -1903,9 +1903,9 @@ static int
 add_ranges (struct backtrace_state *state,
 	    const struct dwarf_sections *dwarf_sections,
 	    uintptr_t base_address, int is_bigendian,
-	    struct unit *u, uint64_t base, const struct pcrange *pcrange,
+	    struct unit *u, uintptr_t base, const struct pcrange *pcrange,
 	    int (*add_range) (struct backtrace_state *state, void *rdata, 
-			      uint64_t lowpc, uint64_t highpc,
+			      uintptr_t lowpc, uintptr_t highpc,
 			      backtrace_error_callback error_callback,
 			      void *data, void *vec),
 	    void *rdata,
@@ -1989,14 +1989,16 @@ find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
 	      break;
 
 	    case DW_AT_stmt_list:
-	      if (abbrev->tag == DW_TAG_compile_unit
+	      if ((abbrev->tag == DW_TAG_compile_unit
+		   || abbrev->tag == DW_TAG_skeleton_unit)
 		  && (val.encoding == ATTR_VAL_UINT
 		      || val.encoding == ATTR_VAL_REF_SECTION))
 		u->lineoff = val.u.uint;
 	      break;
 
 	    case DW_AT_name:
-	      if (abbrev->tag == DW_TAG_compile_unit)
+	      if (abbrev->tag == DW_TAG_compile_unit
+		  || abbrev->tag == DW_TAG_skeleton_unit)
 		{
 		  name_val = val;
 		  have_name_val = 1;
@@ -2004,7 +2006,8 @@ find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
 	      break;
 
 	    case DW_AT_comp_dir:
-	      if (abbrev->tag == DW_TAG_compile_unit)
+	      if (abbrev->tag == DW_TAG_compile_unit
+		  || abbrev->tag == DW_TAG_skeleton_unit)
 		{
 		  comp_dir_val = val;
 		  have_comp_dir_val = 1;
@@ -2012,19 +2015,22 @@ find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
 	      break;
 
 	    case DW_AT_str_offsets_base:
-	      if (abbrev->tag == DW_TAG_compile_unit
+	      if ((abbrev->tag == DW_TAG_compile_unit
+		   || abbrev->tag == DW_TAG_skeleton_unit)
 		  && val.encoding == ATTR_VAL_REF_SECTION)
 		u->str_offsets_base = val.u.uint;
 	      break;
 
 	    case DW_AT_addr_base:
-	      if (abbrev->tag == DW_TAG_compile_unit
+	      if ((abbrev->tag == DW_TAG_compile_unit
+		   || abbrev->tag == DW_TAG_skeleton_unit)
 		  && val.encoding == ATTR_VAL_REF_SECTION)
 		u->addr_base = val.u.uint;
 	      break;
 
 	    case DW_AT_rnglists_base:
-	      if (abbrev->tag == DW_TAG_compile_unit
+	      if ((abbrev->tag == DW_TAG_compile_unit
+		   || abbrev->tag == DW_TAG_skeleton_unit)
 		  && val.encoding == ATTR_VAL_REF_SECTION)
 		u->rnglists_base = val.u.uint;
 	      break;
@@ -2052,7 +2058,8 @@ find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
 	}
 
       if (abbrev->tag == DW_TAG_compile_unit
-	  || abbrev->tag == DW_TAG_subprogram)
+	  || abbrev->tag == DW_TAG_subprogram
+	  || abbrev->tag == DW_TAG_skeleton_unit)
 	{
 	  if (!add_ranges (state, dwarf_sections, base_address,
 			   is_bigendian, u, pcrange.lowpc, &pcrange,
@@ -2060,9 +2067,10 @@ find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
 			   (void *) addrs))
 	    return 0;
 
-	  /* If we found the PC range in the DW_TAG_compile_unit, we
-	     can stop now.  */
-	  if (abbrev->tag == DW_TAG_compile_unit
+	  /* If we found the PC range in the DW_TAG_compile_unit or
+	     DW_TAG_skeleton_unit, we can stop now.  */
+	  if ((abbrev->tag == DW_TAG_compile_unit
+	       || abbrev->tag == DW_TAG_skeleton_unit)
 	      && (pcrange.have_ranges
 		  || (pcrange.have_lowpc && pcrange.have_highpc)))
 	    return 1;
@@ -2221,6 +2229,9 @@ build_address_map (struct backtrace_state *state, uintptr_t base_address,
       u->comp_dir = NULL;
       u->abs_filename = NULL;
       u->lineoff = 0;
+      u->str_offsets_base = 0;
+      u->addr_base = 0;
+      u->rnglists_base = 0;
 
       /* The actual line number mappings will be read as needed.  */
       u->lines = NULL;
@@ -3172,7 +3183,7 @@ read_referenced_name (struct dwarf_data *ddata, struct unit *u,
 
 static int
 add_function_range (struct backtrace_state *state, void *rdata,
-		    uint64_t lowpc, uint64_t highpc,
+		    uintptr_t lowpc, uintptr_t highpc,
 		    backtrace_error_callback error_callback, void *data,
 		    void *pvec)
 {
@@ -3212,7 +3223,7 @@ add_function_range (struct backtrace_state *state, void *rdata,
 
 static int
 read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
-		     struct unit *u, uint64_t base, struct dwarf_buf *unit_buf,
+		     struct unit *u, uintptr_t base, struct dwarf_buf *unit_buf,
 		     const struct line_header *lhdr,
 		     backtrace_error_callback error_callback, void *data,
 		     struct function_vector *vec_function,
@@ -3271,11 +3282,12 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
 
 	  /* The compile unit sets the base address for any address
 	     ranges in the function entries.  */
-	  if (abbrev->tag == DW_TAG_compile_unit
+	  if ((abbrev->tag == DW_TAG_compile_unit
+	       || abbrev->tag == DW_TAG_skeleton_unit)
 	      && abbrev->attrs[i].name == DW_AT_low_pc)
 	    {
 	      if (val.encoding == ATTR_VAL_ADDRESS)
-		base = val.u.uint;
+		base = (uintptr_t) val.u.uint;
 	      else if (val.encoding == ATTR_VAL_ADDRESS_INDEX)
 		{
 		  if (!resolve_addr_index (&ddata->dwarf_sections,
diff --git a/libbacktrace/edtest.c b/libbacktrace/edtest.c
index c5ced130c32..d99b8a60295 100644
--- a/libbacktrace/edtest.c
+++ b/libbacktrace/edtest.c
@@ -1,5 +1,5 @@
 /* edtest.c -- Test for libbacktrace storage allocation stress handling
-   Copyright (C) 2017-2021 Free Software Foundation, Inc.
+   Copyright (C) 2017-2024 Free Software Foundation, Inc.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
diff --git a/libbacktrace/edtest2.c b/libbacktrace/edtest2.c
index cffb4fdb6d9..29e93a7f76a 100644
--- a/libbacktrace/edtest2.c
+++ b/libbacktrace/edtest2.c
@@ -1,5 +1,5 @@
 /* edtest2.c -- Test for libbacktrace storage allocation stress handling (p2)
-   Copyright (C) 2017-2021 Free Software Foundation, Inc.
+   Copyright (C) 2017-2024 Free Software Foundation, Inc.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index 8b87b2dd6b9..3cd87020b03 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -1,5 +1,5 @@
 /* elf.c -- Get debug data from an ELF file for backtraces.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
@@ -40,7 +40,12 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include <unistd.h>
 
 #ifdef HAVE_DL_ITERATE_PHDR
-#include <link.h>
+ #ifdef HAVE_LINK_H
+  #include <link.h>
+ #endif
+ #ifdef HAVE_SYS_LINK_H
+  #include <sys/link.h>
+ #endif
 #endif
 
 #include "backtrace.h"
@@ -179,6 +184,7 @@ dl_iterate_phdr (int (*callback) (struct dl_phdr_info *,
 #undef STT_FUNC
 #undef NT_GNU_BUILD_ID
 #undef ELFCOMPRESS_ZLIB
+#undef ELFCOMPRESS_ZSTD
 
 /* Basic types.  */
 
@@ -336,6 +342,7 @@ typedef struct
 #endif /* BACKTRACE_ELF_SIZE != 32 */
 
 #define ELFCOMPRESS_ZLIB 1
+#define ELFCOMPRESS_ZSTD 2
 
 /* Names of sections, indexed by enum dwarf_section in internal.h.  */
 
@@ -1108,7 +1115,7 @@ elf_uncompress_failed(void)
    on error.  */
 
 static int
-elf_zlib_fetch (const unsigned char **ppin, const unsigned char *pinend,
+elf_fetch_bits (const unsigned char **ppin, const unsigned char *pinend,
 		uint64_t *pval, unsigned int *pbits)
 {
   unsigned int bits;
@@ -1155,6 +1162,118 @@ elf_zlib_fetch (const unsigned char **ppin, const unsigned char *pinend,
   return 1;
 }
 
+/* This is like elf_fetch_bits, but it fetchs the bits backward, and ensures at
+   least 16 bits.  This is for zstd.  */
+
+static int
+elf_fetch_bits_backward (const unsigned char **ppin,
+			 const unsigned char *pinend,
+			 uint64_t *pval, unsigned int *pbits)
+{
+  unsigned int bits;
+  const unsigned char *pin;
+  uint64_t val;
+  uint32_t next;
+
+  bits = *pbits;
+  if (bits >= 16)
+    return 1;
+  pin = *ppin;
+  val = *pval;
+
+  if (unlikely (pin <= pinend))
+    {
+      if (bits == 0)
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      return 1;
+    }
+
+  pin -= 4;
+
+#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) \
+  && defined(__ORDER_BIG_ENDIAN__)				\
+  && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__			\
+      || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+  /* We've ensured that PIN is aligned.  */
+  next = *(const uint32_t *)pin;
+
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+  next = __builtin_bswap32 (next);
+#endif
+#else
+  next = pin[0] | (pin[1] << 8) | (pin[2] << 16) | (pin[3] << 24);
+#endif
+
+  val <<= 32;
+  val |= next;
+  bits += 32;
+
+  if (unlikely (pin < pinend))
+    {
+      val >>= (pinend - pin) * 8;
+      bits -= (pinend - pin) * 8;
+    }
+
+  *ppin = pin;
+  *pval = val;
+  *pbits = bits;
+  return 1;
+}
+
+/* Initialize backward fetching when the bitstream starts with a 1 bit in the
+   last byte in memory (which is the first one that we read).  This is used by
+   zstd decompression.  Returns 1 on success, 0 on error.  */
+
+static int
+elf_fetch_backward_init (const unsigned char **ppin,
+			 const unsigned char *pinend,
+			 uint64_t *pval, unsigned int *pbits)
+{
+  const unsigned char *pin;
+  unsigned int stream_start;
+  uint64_t val;
+  unsigned int bits;
+
+  pin = *ppin;
+  stream_start = (unsigned int)*pin;
+  if (unlikely (stream_start == 0))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+  val = 0;
+  bits = 0;
+
+  /* Align to a 32-bit boundary.  */
+  while ((((uintptr_t)pin) & 3) != 0)
+    {
+      val <<= 8;
+      val |= (uint64_t)*pin;
+      bits += 8;
+      --pin;
+    }
+
+  val <<= 8;
+  val |= (uint64_t)*pin;
+  bits += 8;
+
+  *ppin = pin;
+  *pval = val;
+  *pbits = bits;
+  if (!elf_fetch_bits_backward (ppin, pinend, pval, pbits))
+    return 0;
+
+  *pbits -= __builtin_clz (stream_start) - (sizeof (unsigned int) - 1) * 8 + 1;
+
+  if (!elf_fetch_bits_backward (ppin, pinend, pval, pbits))
+    return 0;
+
+  return 1;
+}
+
 /* Huffman code tables, like the rest of the zlib format, are defined
    by RFC 1951.  We store a Huffman code table as a series of tables
    stored sequentially in memory.  Each entry in a table is 16 bits.
@@ -1189,14 +1308,14 @@ elf_zlib_fetch (const unsigned char **ppin, const unsigned char *pinend,
 /* Number of entries we allocate to for one code table.  We get a page
    for the two code tables we need.  */
 
-#define HUFFMAN_TABLE_SIZE (1024)
+#define ZLIB_HUFFMAN_TABLE_SIZE (1024)
 
 /* Bit masks and shifts for the values in the table.  */
 
-#define HUFFMAN_VALUE_MASK 0x01ff
-#define HUFFMAN_BITS_SHIFT 9
-#define HUFFMAN_BITS_MASK 0x7
-#define HUFFMAN_SECONDARY_SHIFT 12
+#define ZLIB_HUFFMAN_VALUE_MASK 0x01ff
+#define ZLIB_HUFFMAN_BITS_SHIFT 9
+#define ZLIB_HUFFMAN_BITS_MASK 0x7
+#define ZLIB_HUFFMAN_SECONDARY_SHIFT 12
 
 /* For working memory while inflating we need two code tables, we need
    an array of code lengths (max value 15, so we use unsigned char),
@@ -1204,17 +1323,17 @@ elf_zlib_fetch (const unsigned char **ppin, const unsigned char *pinend,
    latter two arrays must be large enough to hold the maximum number
    of code lengths, which RFC 1951 defines as 286 + 30.  */
 
-#define ZDEBUG_TABLE_SIZE \
-  (2 * HUFFMAN_TABLE_SIZE * sizeof (uint16_t) \
+#define ZLIB_TABLE_SIZE \
+  (2 * ZLIB_HUFFMAN_TABLE_SIZE * sizeof (uint16_t) \
    + (286 + 30) * sizeof (uint16_t)	      \
    + (286 + 30) * sizeof (unsigned char))
 
-#define ZDEBUG_TABLE_CODELEN_OFFSET \
-  (2 * HUFFMAN_TABLE_SIZE * sizeof (uint16_t) \
+#define ZLIB_TABLE_CODELEN_OFFSET \
+  (2 * ZLIB_HUFFMAN_TABLE_SIZE * sizeof (uint16_t) \
    + (286 + 30) * sizeof (uint16_t))
 
-#define ZDEBUG_TABLE_WORK_OFFSET \
-  (2 * HUFFMAN_TABLE_SIZE * sizeof (uint16_t))
+#define ZLIB_TABLE_WORK_OFFSET \
+  (2 * ZLIB_HUFFMAN_TABLE_SIZE * sizeof (uint16_t))
 
 #ifdef BACKTRACE_GENERATE_FIXED_HUFFMAN_TABLE
 
@@ -1247,7 +1366,7 @@ elf_zlib_inflate_table (unsigned char *codes, size_t codes_len,
      next value after VAL with the same bit length.  */
 
   next = (uint16_t *) (((unsigned char *) zdebug_table)
-		       + ZDEBUG_TABLE_WORK_OFFSET);
+		       + ZLIB_TABLE_WORK_OFFSET);
 
   memset (&count[0], 0, 16 * sizeof (uint16_t));
   for (i = 0; i < codes_len; ++i)
@@ -1275,7 +1394,7 @@ elf_zlib_inflate_table (unsigned char *codes, size_t codes_len,
   /* For each length, fill in the table for the codes of that
      length.  */
 
-  memset (table, 0, HUFFMAN_TABLE_SIZE * sizeof (uint16_t));
+  memset (table, 0, ZLIB_HUFFMAN_TABLE_SIZE * sizeof (uint16_t));
 
   /* Handle the values that do not require a secondary table.  */
 
@@ -1309,13 +1428,13 @@ elf_zlib_inflate_table (unsigned char *codes, size_t codes_len,
 	  /* In the compressed bit stream, the value VAL is encoded as
 	     J bits with the value C.  */
 
-	  if (unlikely ((val & ~HUFFMAN_VALUE_MASK) != 0))
+	  if (unlikely ((val & ~ZLIB_HUFFMAN_VALUE_MASK) != 0))
 	    {
 	      elf_uncompress_failed ();
 	      return 0;
 	    }
 
-	  tval = val | ((j - 1) << HUFFMAN_BITS_SHIFT);
+	  tval = val | ((j - 1) << ZLIB_HUFFMAN_BITS_SHIFT);
 
 	  /* The table lookup uses 8 bits.  If J is less than 8, we
 	     don't know what the other bits will be.  We need to fill
@@ -1465,7 +1584,7 @@ elf_zlib_inflate_table (unsigned char *codes, size_t codes_len,
 		{
 		  /* Start a new secondary table.  */
 
-		  if (unlikely ((next_secondary & HUFFMAN_VALUE_MASK)
+		  if (unlikely ((next_secondary & ZLIB_HUFFMAN_VALUE_MASK)
 				!= next_secondary))
 		    {
 		      elf_uncompress_failed ();
@@ -1476,22 +1595,23 @@ elf_zlib_inflate_table (unsigned char *codes, size_t codes_len,
 		  secondary_bits = j - 8;
 		  next_secondary += 1 << secondary_bits;
 		  table[primary] = (secondary
-				    + ((j - 8) << HUFFMAN_BITS_SHIFT)
-				    + (1U << HUFFMAN_SECONDARY_SHIFT));
+				    + ((j - 8) << ZLIB_HUFFMAN_BITS_SHIFT)
+				    + (1U << ZLIB_HUFFMAN_SECONDARY_SHIFT));
 		}
 	      else
 		{
 		  /* There is an existing entry.  It had better be a
 		     secondary table with enough bits.  */
-		  if (unlikely ((tprimary & (1U << HUFFMAN_SECONDARY_SHIFT))
+		  if (unlikely ((tprimary
+				 & (1U << ZLIB_HUFFMAN_SECONDARY_SHIFT))
 				== 0))
 		    {
 		      elf_uncompress_failed ();
 		      return 0;
 		    }
-		  secondary = tprimary & HUFFMAN_VALUE_MASK;
-		  secondary_bits = ((tprimary >> HUFFMAN_BITS_SHIFT)
-				    & HUFFMAN_BITS_MASK);
+		  secondary = tprimary & ZLIB_HUFFMAN_VALUE_MASK;
+		  secondary_bits = ((tprimary >> ZLIB_HUFFMAN_BITS_SHIFT)
+				    & ZLIB_HUFFMAN_BITS_MASK);
 		  if (unlikely (secondary_bits < j - 8))
 		    {
 		      elf_uncompress_failed ();
@@ -1502,7 +1622,7 @@ elf_zlib_inflate_table (unsigned char *codes, size_t codes_len,
 
 	  /* Fill in secondary table entries.  */
 
-	  tval = val | ((j - 8) << HUFFMAN_BITS_SHIFT);
+	  tval = val | ((j - 8) << ZLIB_HUFFMAN_BITS_SHIFT);
 
 	  for (ind = code >> 8;
 	       ind < (1U << secondary_bits);
@@ -1545,7 +1665,7 @@ elf_zlib_inflate_table (unsigned char *codes, size_t codes_len,
 
 #include <stdio.h>
 
-static uint16_t table[ZDEBUG_TABLE_SIZE];
+static uint16_t table[ZLIB_TABLE_SIZE];
 static unsigned char codes[288];
 
 int
@@ -1773,7 +1893,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 	  const uint16_t *tlit;
 	  const uint16_t *tdist;
 
-	  if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+	  if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 	    return 0;
 
 	  last = val & 1;
@@ -1796,7 +1916,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 	      /* An uncompressed block.  */
 
 	      /* If we've read ahead more than a byte, back up.  */
-	      while (bits > 8)
+	      while (bits >= 8)
 		{
 		  --pin;
 		  bits -= 8;
@@ -1861,7 +1981,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 	      /* Read a Huffman encoding table.  The various magic
 		 numbers here are from RFC 1951.  */
 
-	      if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+	      if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 		return 0;
 
 	      nlit = (val & 0x1f) + 257;
@@ -1886,7 +2006,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 	      /* There are always at least 4 elements in the
 		 table.  */
 
-	      if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+	      if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 		return 0;
 
 	      codebits[16] = val & 7;
@@ -1906,7 +2026,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 	      if (nclen == 5)
 		goto codebitsdone;
 
-	      if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+	      if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 		return 0;
 
 	      codebits[7] = val & 7;
@@ -1944,7 +2064,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 	      if (nclen == 10)
 		goto codebitsdone;
 
-	      if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+	      if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 		return 0;
 
 	      codebits[11] = val & 7;
@@ -1982,7 +2102,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 	      if (nclen == 15)
 		goto codebitsdone;
 
-	      if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+	      if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 		return 0;
 
 	      codebits[2] = val & 7;
@@ -2021,7 +2141,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 		 at the end of zdebug_table to hold them.  */
 
 	      plenbase = (((unsigned char *) zdebug_table)
-			  + ZDEBUG_TABLE_CODELEN_OFFSET);
+			  + ZLIB_TABLE_CODELEN_OFFSET);
 	      plen = plenbase;
 	      plenend = plen + nlit + ndist;
 	      while (plen < plenend)
@@ -2030,24 +2150,25 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 		  unsigned int b;
 		  uint16_t v;
 
-		  if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+		  if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 		    return 0;
 
 		  t = zdebug_table[val & 0xff];
 
 		  /* The compression here uses bit lengths up to 7, so
 		     a secondary table is never necessary.  */
-		  if (unlikely ((t & (1U << HUFFMAN_SECONDARY_SHIFT)) != 0))
+		  if (unlikely ((t & (1U << ZLIB_HUFFMAN_SECONDARY_SHIFT))
+				!= 0))
 		    {
 		      elf_uncompress_failed ();
 		      return 0;
 		    }
 
-		  b = (t >> HUFFMAN_BITS_SHIFT) & HUFFMAN_BITS_MASK;
+		  b = (t >> ZLIB_HUFFMAN_BITS_SHIFT) & ZLIB_HUFFMAN_BITS_MASK;
 		  val >>= b + 1;
 		  bits -= b + 1;
 
-		  v = t & HUFFMAN_VALUE_MASK;
+		  v = t & ZLIB_HUFFMAN_VALUE_MASK;
 		  if (v < 16)
 		    *plen++ = v;
 		  else if (v == 16)
@@ -2064,7 +2185,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 			}
 
 		      /* We used up to 7 bits since the last
-			 elf_zlib_fetch, so we have at least 8 bits
+			 elf_fetch_bits, so we have at least 8 bits
 			 available here.  */
 
 		      c = 3 + (val & 0x3);
@@ -2099,7 +2220,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 		      /* Store zero 3 to 10 times.  */
 
 		      /* We used up to 7 bits since the last
-			 elf_zlib_fetch, so we have at least 8 bits
+			 elf_fetch_bits, so we have at least 8 bits
 			 available here.  */
 
 		      c = 3 + (val & 0x7);
@@ -2145,7 +2266,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 		      /* Store zero 11 to 138 times.  */
 
 		      /* We used up to 7 bits since the last
-			 elf_zlib_fetch, so we have at least 8 bits
+			 elf_fetch_bits, so we have at least 8 bits
 			 available here.  */
 
 		      c = 11 + (val & 0x7f);
@@ -2182,10 +2303,11 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 					   zdebug_table))
 		return 0;
 	      if (!elf_zlib_inflate_table (plen + nlit, ndist, zdebug_table,
-					   zdebug_table + HUFFMAN_TABLE_SIZE))
+					   (zdebug_table
+					    + ZLIB_HUFFMAN_TABLE_SIZE)))
 		return 0;
 	      tlit = zdebug_table;
-	      tdist = zdebug_table + HUFFMAN_TABLE_SIZE;
+	      tdist = zdebug_table + ZLIB_HUFFMAN_TABLE_SIZE;
 	    }
 
 	  /* Inflate values until the end of the block.  This is the
@@ -2198,14 +2320,14 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 	      uint16_t v;
 	      unsigned int lit;
 
-	      if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+	      if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 		return 0;
 
 	      t = tlit[val & 0xff];
-	      b = (t >> HUFFMAN_BITS_SHIFT) & HUFFMAN_BITS_MASK;
-	      v = t & HUFFMAN_VALUE_MASK;
+	      b = (t >> ZLIB_HUFFMAN_BITS_SHIFT) & ZLIB_HUFFMAN_BITS_MASK;
+	      v = t & ZLIB_HUFFMAN_VALUE_MASK;
 
-	      if ((t & (1U << HUFFMAN_SECONDARY_SHIFT)) == 0)
+	      if ((t & (1U << ZLIB_HUFFMAN_SECONDARY_SHIFT)) == 0)
 		{
 		  lit = v;
 		  val >>= b + 1;
@@ -2214,8 +2336,8 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 	      else
 		{
 		  t = tlit[v + 0x100 + ((val >> 8) & ((1U << b) - 1))];
-		  b = (t >> HUFFMAN_BITS_SHIFT) & HUFFMAN_BITS_MASK;
-		  lit = t & HUFFMAN_VALUE_MASK;
+		  b = (t >> ZLIB_HUFFMAN_BITS_SHIFT) & ZLIB_HUFFMAN_BITS_MASK;
+		  lit = t & ZLIB_HUFFMAN_VALUE_MASK;
 		  val >>= b + 8;
 		  bits -= b + 8;
 		}
@@ -2260,7 +2382,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 		    {
 		      unsigned int extra;
 
-		      if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+		      if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 			return 0;
 
 		      /* This is an expression for the table of length
@@ -2275,14 +2397,14 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 		      bits -= extra;
 		    }
 
-		  if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+		  if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 		    return 0;
 
 		  t = tdist[val & 0xff];
-		  b = (t >> HUFFMAN_BITS_SHIFT) & HUFFMAN_BITS_MASK;
-		  v = t & HUFFMAN_VALUE_MASK;
+		  b = (t >> ZLIB_HUFFMAN_BITS_SHIFT) & ZLIB_HUFFMAN_BITS_MASK;
+		  v = t & ZLIB_HUFFMAN_VALUE_MASK;
 
-		  if ((t & (1U << HUFFMAN_SECONDARY_SHIFT)) == 0)
+		  if ((t & (1U << ZLIB_HUFFMAN_SECONDARY_SHIFT)) == 0)
 		    {
 		      dist = v;
 		      val >>= b + 1;
@@ -2291,8 +2413,9 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 		  else
 		    {
 		      t = tdist[v + 0x100 + ((val >> 8) & ((1U << b) - 1))];
-		      b = (t >> HUFFMAN_BITS_SHIFT) & HUFFMAN_BITS_MASK;
-		      dist = t & HUFFMAN_VALUE_MASK;
+		      b = ((t >> ZLIB_HUFFMAN_BITS_SHIFT)
+			   & ZLIB_HUFFMAN_BITS_MASK);
+		      dist = t & ZLIB_HUFFMAN_VALUE_MASK;
 		      val >>= b + 8;
 		      bits -= b + 8;
 		    }
@@ -2332,7 +2455,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
 			{
 			  unsigned int extra;
 
-			  if (!elf_zlib_fetch (&pin, pinend, &val, &bits))
+			  if (!elf_fetch_bits (&pin, pinend, &val, &bits))
 			    return 0;
 
 			  /* This is an expression for the table of
@@ -2537,186 +2660,2583 @@ elf_zlib_inflate_and_verify (const unsigned char *pin, size_t sin,
   return 1;
 }
 
-/* Uncompress the old compressed debug format, the one emitted by
-   --compress-debug-sections=zlib-gnu.  The compressed data is in
-   COMPRESSED / COMPRESSED_SIZE, and the function writes to
-   *UNCOMPRESSED / *UNCOMPRESSED_SIZE.  ZDEBUG_TABLE is work space to
-   hold Huffman tables.  Returns 0 on error, 1 on successful
-   decompression or if something goes wrong.  In general we try to
-   carry on, by returning 1, even if we can't decompress.  */
+/* For working memory during zstd compression, we need
+   - a literal length FSE table: 512 64-bit values == 4096 bytes
+   - a match length FSE table: 512 64-bit values == 4096 bytes
+   - a offset FSE table: 256 64-bit values == 2048 bytes
+   - a Huffman tree: 2048 uint16_t values == 4096 bytes
+   - scratch space, one of
+     - to build an FSE table: 512 uint16_t values == 1024 bytes
+     - to build a Huffman tree: 512 uint16_t + 256 uint32_t == 2048 bytes
+*/
 
-static int
-elf_uncompress_zdebug (struct backtrace_state *state,
-		       const unsigned char *compressed, size_t compressed_size,
-		       uint16_t *zdebug_table,
-		       backtrace_error_callback error_callback, void *data,
-		       unsigned char **uncompressed, size_t *uncompressed_size)
-{
-  size_t sz;
-  size_t i;
-  unsigned char *po;
+#define ZSTD_TABLE_SIZE					\
+  (2 * 512 * sizeof (struct elf_zstd_fse_baseline_entry)	\
+   + 256 * sizeof (struct elf_zstd_fse_baseline_entry)		\
+   + 2048 * sizeof (uint16_t)					\
+   + 512 * sizeof (uint16_t) + 256 * sizeof (uint32_t))
 
-  *uncompressed = NULL;
-  *uncompressed_size = 0;
+#define ZSTD_TABLE_LITERAL_FSE_OFFSET (0)
 
-  /* The format starts with the four bytes ZLIB, followed by the 8
-     byte length of the uncompressed data in big-endian order,
-     followed by a zlib stream.  */
+#define ZSTD_TABLE_MATCH_FSE_OFFSET			\
+  (512 * sizeof (struct elf_zstd_fse_baseline_entry))
 
-  if (compressed_size < 12 || memcmp (compressed, "ZLIB", 4) != 0)
-    return 1;
+#define ZSTD_TABLE_OFFSET_FSE_OFFSET			\
+  (ZSTD_TABLE_MATCH_FSE_OFFSET				\
+   + 512 * sizeof (struct elf_zstd_fse_baseline_entry))
 
-  sz = 0;
-  for (i = 0; i < 8; i++)
-    sz = (sz << 8) | compressed[i + 4];
+#define ZSTD_TABLE_HUFFMAN_OFFSET					\
+  (ZSTD_TABLE_OFFSET_FSE_OFFSET						\
+   + 256 * sizeof (struct elf_zstd_fse_baseline_entry))
 
-  if (*uncompressed != NULL && *uncompressed_size >= sz)
-    po = *uncompressed;
-  else
-    {
-      po = (unsigned char *) backtrace_alloc (state, sz, error_callback, data);
-      if (po == NULL)
-	return 0;
-    }
+#define ZSTD_TABLE_WORK_OFFSET \
+  (ZSTD_TABLE_HUFFMAN_OFFSET + 2048 * sizeof (uint16_t))
 
-  if (!elf_zlib_inflate_and_verify (compressed + 12, compressed_size - 12,
-				    zdebug_table, po, sz))
-    return 1;
+/* An entry in a zstd FSE table.  */
 
-  *uncompressed = po;
-  *uncompressed_size = sz;
+struct elf_zstd_fse_entry
+{
+  /* The value that this FSE entry represents.  */
+  unsigned char symbol;
+  /* The number of bits to read to determine the next state.  */
+  unsigned char bits;
+  /* Add the bits to this base to get the next state.  */
+  uint16_t base;
+};
 
-  return 1;
-}
+static int
+elf_zstd_build_fse (const int16_t *, int, uint16_t *, int,
+		    struct elf_zstd_fse_entry *);
 
-/* Uncompress the new compressed debug format, the official standard
-   ELF approach emitted by --compress-debug-sections=zlib-gabi.  The
-   compressed data is in COMPRESSED / COMPRESSED_SIZE, and the
-   function writes to *UNCOMPRESSED / *UNCOMPRESSED_SIZE.
-   ZDEBUG_TABLE is work space as for elf_uncompress_zdebug.  Returns 0
-   on error, 1 on successful decompression or if something goes wrong.
-   In general we try to carry on, by returning 1, even if we can't
-   decompress.  */
+/* Read a zstd FSE table and build the decoding table in *TABLE, updating *PPIN
+   as it reads.  ZDEBUG_TABLE is scratch space; it must be enough for 512
+   uint16_t values (1024 bytes).  MAXIDX is the maximum number of symbols
+   permitted. *TABLE_BITS is the maximum number of bits for symbols in the
+   table: the size of *TABLE is at least 1 << *TABLE_BITS.  This updates
+   *TABLE_BITS to the actual number of bits.  Returns 1 on success, 0 on
+   error.  */
 
 static int
-elf_uncompress_chdr (struct backtrace_state *state,
-		     const unsigned char *compressed, size_t compressed_size,
-		     uint16_t *zdebug_table,
-		     backtrace_error_callback error_callback, void *data,
-		     unsigned char **uncompressed, size_t *uncompressed_size)
+elf_zstd_read_fse (const unsigned char **ppin, const unsigned char *pinend,
+		   uint16_t *zdebug_table, int maxidx,
+		   struct elf_zstd_fse_entry *table, int *table_bits)
 {
-  const b_elf_chdr *chdr;
-  unsigned char *po;
+  const unsigned char *pin;
+  int16_t *norm;
+  uint16_t *next;
+  uint64_t val;
+  unsigned int bits;
+  int accuracy_log;
+  uint32_t remaining;
+  uint32_t threshold;
+  int bits_needed;
+  int idx;
+  int prev0;
 
-  *uncompressed = NULL;
-  *uncompressed_size = 0;
+  pin = *ppin;
 
-  /* The format starts with an ELF compression header.  */
-  if (compressed_size < sizeof (b_elf_chdr))
-    return 1;
+  norm = (int16_t *) zdebug_table;
+  next = zdebug_table + 256;
+
+  if (unlikely (pin + 3 >= pinend))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
 
-  chdr = (const b_elf_chdr *) compressed;
+  /* Align PIN to a 32-bit boundary.  */
 
-  if (chdr->ch_type != ELFCOMPRESS_ZLIB)
+  val = 0;
+  bits = 0;
+  while ((((uintptr_t) pin) & 3) != 0)
     {
-      /* Unsupported compression algorithm.  */
-      return 1;
+      val |= (uint64_t)*pin << bits;
+      bits += 8;
+      ++pin;
     }
 
-  if (*uncompressed != NULL && *uncompressed_size >= chdr->ch_size)
-    po = *uncompressed;
-  else
+  if (!elf_fetch_bits (&pin, pinend, &val, &bits))
+    return 0;
+
+  accuracy_log = (val & 0xf) + 5;
+  if (accuracy_log > *table_bits)
     {
-      po = (unsigned char *) backtrace_alloc (state, chdr->ch_size,
-					      error_callback, data);
-      if (po == NULL)
-	return 0;
+      elf_uncompress_failed ();
+      return 0;
     }
+  *table_bits = accuracy_log;
+  val >>= 4;
+  bits -= 4;
 
-  if (!elf_zlib_inflate_and_verify (compressed + sizeof (b_elf_chdr),
-				    compressed_size - sizeof (b_elf_chdr),
-				    zdebug_table, po, chdr->ch_size))
-    return 1;
+  /* This code is mostly copied from the reference implementation.  */
 
-  *uncompressed = po;
-  *uncompressed_size = chdr->ch_size;
+  /* The number of remaining probabilities, plus 1.  This sets the number of
+     bits that need to be read for the next value.  */
+  remaining = (1 << accuracy_log) + 1;
 
-  return 1;
-}
+  /* The current difference between small and large values, which depends on
+     the number of remaining values.  Small values use one less bit.  */
+  threshold = 1 << accuracy_log;
 
-/* This function is a hook for testing the zlib support.  It is only
-   used by tests.  */
+  /* The number of bits used to compute threshold.  */
+  bits_needed = accuracy_log + 1;
 
-int
-backtrace_uncompress_zdebug (struct backtrace_state *state,
-			     const unsigned char *compressed,
-			     size_t compressed_size,
-			     backtrace_error_callback error_callback,
-			     void *data, unsigned char **uncompressed,
-			     size_t *uncompressed_size)
-{
-  uint16_t *zdebug_table;
-  int ret;
+  /* The next character value.  */
+  idx = 0;
 
-  zdebug_table = ((uint16_t *) backtrace_alloc (state, ZDEBUG_TABLE_SIZE,
-						error_callback, data));
-  if (zdebug_table == NULL)
-    return 0;
-  ret = elf_uncompress_zdebug (state, compressed, compressed_size,
-			       zdebug_table, error_callback, data,
-			       uncompressed, uncompressed_size);
-  backtrace_free (state, zdebug_table, ZDEBUG_TABLE_SIZE,
-		  error_callback, data);
-  return ret;
-}
+  /* Whether the last count was 0.  */
+  prev0 = 0;
 
-/* Number of LZMA states.  */
-#define LZMA_STATES (12)
+  while (remaining > 1 && idx <= maxidx)
+    {
+      uint32_t max;
+      int32_t count;
 
-/* Number of LZMA position states.  The pb value of the property byte
-   is the number of bits to include in these states, and the maximum
-   value of pb is 4.  */
-#define LZMA_POS_STATES (16)
+      if (!elf_fetch_bits (&pin, pinend, &val, &bits))
+	return 0;
 
-/* Number of LZMA distance states.  These are used match distances
-   with a short match length: up to 4 bytes.  */
-#define LZMA_DIST_STATES (4)
+      if (prev0)
+	{
+	  int zidx;
 
-/* Number of LZMA distance slots.  LZMA uses six bits to encode larger
-   match lengths, so 1 << 6 possible probabilities.  */
-#define LZMA_DIST_SLOTS (64)
+	  /* Previous count was 0, so there is a 2-bit repeat flag.  If the
+	     2-bit flag is 0b11, it adds 3 and then there is another repeat
+	     flag.  */
+	  zidx = idx;
+	  while ((val & 0xfff) == 0xfff)
+	    {
+	      zidx += 3 * 6;
+	      val >>= 12;
+	      bits -= 12;
+	      if  (!elf_fetch_bits (&pin, pinend, &val, &bits))
+		return 0;
+	    }
+	  while ((val & 3) == 3)
+	    {
+	      zidx += 3;
+	      val >>= 2;
+	      bits -= 2;
+	      if (!elf_fetch_bits (&pin, pinend, &val, &bits))
+		return 0;
+	    }
+	  /* We have at least 13 bits here, don't need to fetch.  */
+	  zidx += val & 3;
+	  val >>= 2;
+	  bits -= 2;
 
-/* LZMA distances 0 to 3 are encoded directly, larger values use a
-   probability model.  */
-#define LZMA_DIST_MODEL_START (4)
+	  if (unlikely (zidx > maxidx))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
 
-/* The LZMA probability model ends at 14.  */
-#define LZMA_DIST_MODEL_END (14)
+	  for (; idx < zidx; idx++)
+	    norm[idx] = 0;
 
-/* LZMA distance slots for distances less than 127.  */
-#define LZMA_FULL_DISTANCES (128)
+	  prev0 = 0;
+	  continue;
+	}
 
-/* LZMA uses four alignment bits.  */
-#define LZMA_ALIGN_SIZE (16)
+      max = (2 * threshold - 1) - remaining;
+      if ((val & (threshold - 1)) < max)
+	{
+	  /* A small value.  */
+	  count = (int32_t) ((uint32_t) val & (threshold - 1));
+	  val >>= bits_needed - 1;
+	  bits -= bits_needed - 1;
+	}
+      else
+	{
+	  /* A large value.  */
+	  count = (int32_t) ((uint32_t) val & (2 * threshold - 1));
+	  if (count >= (int32_t) threshold)
+	    count -= (int32_t) max;
+	  val >>= bits_needed;
+	  bits -= bits_needed;
+	}
 
-/* LZMA match length is encoded with 4, 5, or 10 bits, some of which
-   are already known.  */
-#define LZMA_LEN_LOW_SYMBOLS (8)
-#define LZMA_LEN_MID_SYMBOLS (8)
-#define LZMA_LEN_HIGH_SYMBOLS (256)
+      count--;
+      if (count >= 0)
+	remaining -= count;
+      else
+	remaining--;
+      if (unlikely (idx >= 256))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      norm[idx] = (int16_t) count;
+      ++idx;
 
-/* LZMA literal encoding.  */
-#define LZMA_LITERAL_CODERS_MAX (16)
-#define LZMA_LITERAL_CODER_SIZE (0x300)
+      prev0 = count == 0;
 
-/* LZMA is based on a large set of probabilities, each managed
-   independently.  Each probability is an 11 bit number that we store
-   in a uint16_t.  We use a single large array of probabilities.  */
+      while (remaining < threshold)
+	{
+	  bits_needed--;
+	  threshold >>= 1;
+	}
+    }
 
-/* Lengths of entries in the LZMA probabilities array.  The names used
-   here are copied from the Linux kernel implementation.  */
+  if (unlikely (remaining != 1))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
 
-#define LZMA_PROB_IS_MATCH_LEN (LZMA_STATES * LZMA_POS_STATES)
+  /* If we've read ahead more than a byte, back up.  */
+  while (bits >= 8)
+    {
+      --pin;
+      bits -= 8;
+    }
+
+  *ppin = pin;
+
+  for (; idx <= maxidx; idx++)
+    norm[idx] = 0;
+
+  return elf_zstd_build_fse (norm, idx, next, *table_bits, table);
+}
+
+/* Build the FSE decoding table from a list of probabilities.  This reads from
+   NORM of length IDX, uses NEXT as scratch space, and writes to *TABLE, whose
+   size is TABLE_BITS.  */
+
+static int
+elf_zstd_build_fse (const int16_t *norm, int idx, uint16_t *next,
+		    int table_bits, struct elf_zstd_fse_entry *table)
+{
+  int table_size;
+  int high_threshold;
+  int i;
+  int pos;
+  int step;
+  int mask;
+
+  table_size = 1 << table_bits;
+  high_threshold = table_size - 1;
+  for (i = 0; i < idx; i++)
+    {
+      int16_t n;
+
+      n = norm[i];
+      if (n >= 0)
+	next[i] = (uint16_t) n;
+      else
+	{
+	  table[high_threshold].symbol = (unsigned char) i;
+	  high_threshold--;
+	  next[i] = 1;
+	}
+    }
+
+  pos = 0;
+  step = (table_size >> 1) + (table_size >> 3) + 3;
+  mask = table_size - 1;
+  for (i = 0; i < idx; i++)
+    {
+      int n;
+      int j;
+
+      n = (int) norm[i];
+      for (j = 0; j < n; j++)
+	{
+	  table[pos].symbol = (unsigned char) i;
+	  pos = (pos + step) & mask;
+	  while (unlikely (pos > high_threshold))
+	    pos = (pos + step) & mask;
+	}
+    }
+  if (unlikely (pos != 0))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  for (i = 0; i < table_size; i++)
+    {
+      unsigned char sym;
+      uint16_t next_state;
+      int high_bit;
+      int bits;
+
+      sym = table[i].symbol;
+      next_state = next[sym];
+      ++next[sym];
+
+      if (next_state == 0)
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      high_bit = 31 - __builtin_clz (next_state);
+
+      bits = table_bits - high_bit;
+      table[i].bits = (unsigned char) bits;
+      table[i].base = (uint16_t) ((next_state << bits) - table_size);
+    }
+
+  return 1;
+}
+
+/* Encode the baseline and bits into a single 32-bit value.  */
+
+#define ZSTD_ENCODE_BASELINE_BITS(baseline, basebits)	\
+  ((uint32_t)(baseline) | ((uint32_t)(basebits) << 24))
+
+#define ZSTD_DECODE_BASELINE(baseline_basebits)	\
+  ((uint32_t)(baseline_basebits) & 0xffffff)
+
+#define ZSTD_DECODE_BASEBITS(baseline_basebits)	\
+  ((uint32_t)(baseline_basebits) >> 24)
+
+/* Given a literal length code, we need to read a number of bits and add that
+   to a baseline.  For states 0 to 15 the baseline is the state and the number
+   of bits is zero.  */
+
+#define ZSTD_LITERAL_LENGTH_BASELINE_OFFSET (16)
+
+static const uint32_t elf_zstd_literal_length_base[] =
+{
+  ZSTD_ENCODE_BASELINE_BITS(16, 1),
+  ZSTD_ENCODE_BASELINE_BITS(18, 1),
+  ZSTD_ENCODE_BASELINE_BITS(20, 1),
+  ZSTD_ENCODE_BASELINE_BITS(22, 1),
+  ZSTD_ENCODE_BASELINE_BITS(24, 2),
+  ZSTD_ENCODE_BASELINE_BITS(28, 2),
+  ZSTD_ENCODE_BASELINE_BITS(32, 3),
+  ZSTD_ENCODE_BASELINE_BITS(40, 3),
+  ZSTD_ENCODE_BASELINE_BITS(48, 4),
+  ZSTD_ENCODE_BASELINE_BITS(64, 6),
+  ZSTD_ENCODE_BASELINE_BITS(128, 7),
+  ZSTD_ENCODE_BASELINE_BITS(256, 8),
+  ZSTD_ENCODE_BASELINE_BITS(512, 9),
+  ZSTD_ENCODE_BASELINE_BITS(1024, 10),
+  ZSTD_ENCODE_BASELINE_BITS(2048, 11),
+  ZSTD_ENCODE_BASELINE_BITS(4096, 12),
+  ZSTD_ENCODE_BASELINE_BITS(8192, 13),
+  ZSTD_ENCODE_BASELINE_BITS(16384, 14),
+  ZSTD_ENCODE_BASELINE_BITS(32768, 15),
+  ZSTD_ENCODE_BASELINE_BITS(65536, 16)
+};
+
+/* The same applies to match length codes.  For states 0 to 31 the baseline is
+   the state + 3 and the number of bits is zero.  */
+
+#define ZSTD_MATCH_LENGTH_BASELINE_OFFSET (32)
+
+static const uint32_t elf_zstd_match_length_base[] =
+{
+  ZSTD_ENCODE_BASELINE_BITS(35, 1),
+  ZSTD_ENCODE_BASELINE_BITS(37, 1),
+  ZSTD_ENCODE_BASELINE_BITS(39, 1),
+  ZSTD_ENCODE_BASELINE_BITS(41, 1),
+  ZSTD_ENCODE_BASELINE_BITS(43, 2),
+  ZSTD_ENCODE_BASELINE_BITS(47, 2),
+  ZSTD_ENCODE_BASELINE_BITS(51, 3),
+  ZSTD_ENCODE_BASELINE_BITS(59, 3),
+  ZSTD_ENCODE_BASELINE_BITS(67, 4),
+  ZSTD_ENCODE_BASELINE_BITS(83, 4),
+  ZSTD_ENCODE_BASELINE_BITS(99, 5),
+  ZSTD_ENCODE_BASELINE_BITS(131, 7),
+  ZSTD_ENCODE_BASELINE_BITS(259, 8),
+  ZSTD_ENCODE_BASELINE_BITS(515, 9),
+  ZSTD_ENCODE_BASELINE_BITS(1027, 10),
+  ZSTD_ENCODE_BASELINE_BITS(2051, 11),
+  ZSTD_ENCODE_BASELINE_BITS(4099, 12),
+  ZSTD_ENCODE_BASELINE_BITS(8195, 13),
+  ZSTD_ENCODE_BASELINE_BITS(16387, 14),
+  ZSTD_ENCODE_BASELINE_BITS(32771, 15),
+  ZSTD_ENCODE_BASELINE_BITS(65539, 16)
+};
+
+/* An entry in an FSE table used for literal/match/length values.  For these we
+   have to map the symbol to a baseline value, and we have to read zero or more
+   bits and add that value to the baseline value.  Rather than look the values
+   up in a separate table, we grow the FSE table so that we get better memory
+   caching.  */
+
+struct elf_zstd_fse_baseline_entry
+{
+  /* The baseline for the value that this FSE entry represents..  */
+  uint32_t baseline;
+  /* The number of bits to read to add to the baseline.  */
+  unsigned char basebits;
+  /* The number of bits to read to determine the next state.  */
+  unsigned char bits;
+  /* Add the bits to this base to get the next state.  */
+  uint16_t base;
+};
+
+/* Convert the literal length FSE table FSE_TABLE to an FSE baseline table at
+   BASELINE_TABLE.  Note that FSE_TABLE and BASELINE_TABLE will overlap.  */
+
+static int
+elf_zstd_make_literal_baseline_fse (
+    const struct elf_zstd_fse_entry *fse_table,
+    int table_bits,
+    struct elf_zstd_fse_baseline_entry *baseline_table)
+{
+  size_t count;
+  const struct elf_zstd_fse_entry *pfse;
+  struct elf_zstd_fse_baseline_entry *pbaseline;
+
+  /* Convert backward to avoid overlap.  */
+
+  count = 1U << table_bits;
+  pfse = fse_table + count;
+  pbaseline = baseline_table + count;
+  while (pfse > fse_table)
+    {
+      unsigned char symbol;
+      unsigned char bits;
+      uint16_t base;
+
+      --pfse;
+      --pbaseline;
+      symbol = pfse->symbol;
+      bits = pfse->bits;
+      base = pfse->base;
+      if (symbol < ZSTD_LITERAL_LENGTH_BASELINE_OFFSET)
+	{
+	  pbaseline->baseline = (uint32_t)symbol;
+	  pbaseline->basebits = 0;
+	}
+      else
+	{
+	  unsigned int idx;
+	  uint32_t basebits;
+
+	  if (unlikely (symbol > 35))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+	  idx = symbol - ZSTD_LITERAL_LENGTH_BASELINE_OFFSET;
+	  basebits = elf_zstd_literal_length_base[idx];
+	  pbaseline->baseline = ZSTD_DECODE_BASELINE(basebits);
+	  pbaseline->basebits = ZSTD_DECODE_BASEBITS(basebits);
+	}
+      pbaseline->bits = bits;
+      pbaseline->base = base;
+    }
+
+  return 1;
+}
+
+/* Convert the offset length FSE table FSE_TABLE to an FSE baseline table at
+   BASELINE_TABLE.  Note that FSE_TABLE and BASELINE_TABLE will overlap.  */
+
+static int
+elf_zstd_make_offset_baseline_fse (
+    const struct elf_zstd_fse_entry *fse_table,
+    int table_bits,
+    struct elf_zstd_fse_baseline_entry *baseline_table)
+{
+  size_t count;
+  const struct elf_zstd_fse_entry *pfse;
+  struct elf_zstd_fse_baseline_entry *pbaseline;
+
+  /* Convert backward to avoid overlap.  */
+
+  count = 1U << table_bits;
+  pfse = fse_table + count;
+  pbaseline = baseline_table + count;
+  while (pfse > fse_table)
+    {
+      unsigned char symbol;
+      unsigned char bits;
+      uint16_t base;
+
+      --pfse;
+      --pbaseline;
+      symbol = pfse->symbol;
+      bits = pfse->bits;
+      base = pfse->base;
+      if (unlikely (symbol > 31))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+
+      /* The simple way to write this is
+
+	   pbaseline->baseline = (uint32_t)1 << symbol;
+	   pbaseline->basebits = symbol;
+
+	 That will give us an offset value that corresponds to the one
+	 described in the RFC.  However, for offset values > 3, we have to
+	 subtract 3.  And for offset values 1, 2, 3 we use a repeated offset.
+	 The baseline is always a power of 2, and is never 0, so for these low
+	 values we will see one entry that is baseline 1, basebits 0, and one
+	 entry that is baseline 2, basebits 1.  All other entries will have
+	 baseline >= 4 and basebits >= 2.
+
+	 So we can check for RFC offset <= 3 by checking for basebits <= 1.
+	 And that means that we can subtract 3 here and not worry about doing
+	 it in the hot loop.  */
+
+      pbaseline->baseline = (uint32_t)1 << symbol;
+      if (symbol >= 2)
+	pbaseline->baseline -= 3;
+      pbaseline->basebits = symbol;
+      pbaseline->bits = bits;
+      pbaseline->base = base;
+    }
+
+  return 1;
+}
+
+/* Convert the match length FSE table FSE_TABLE to an FSE baseline table at
+   BASELINE_TABLE.  Note that FSE_TABLE and BASELINE_TABLE will overlap.  */
+
+static int
+elf_zstd_make_match_baseline_fse (
+    const struct elf_zstd_fse_entry *fse_table,
+    int table_bits,
+    struct elf_zstd_fse_baseline_entry *baseline_table)
+{
+  size_t count;
+  const struct elf_zstd_fse_entry *pfse;
+  struct elf_zstd_fse_baseline_entry *pbaseline;
+
+  /* Convert backward to avoid overlap.  */
+
+  count = 1U << table_bits;
+  pfse = fse_table + count;
+  pbaseline = baseline_table + count;
+  while (pfse > fse_table)
+    {
+      unsigned char symbol;
+      unsigned char bits;
+      uint16_t base;
+
+      --pfse;
+      --pbaseline;
+      symbol = pfse->symbol;
+      bits = pfse->bits;
+      base = pfse->base;
+      if (symbol < ZSTD_MATCH_LENGTH_BASELINE_OFFSET)
+	{
+	  pbaseline->baseline = (uint32_t)symbol + 3;
+	  pbaseline->basebits = 0;
+	}
+      else
+	{
+	  unsigned int idx;
+	  uint32_t basebits;
+
+	  if (unlikely (symbol > 52))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+	  idx = symbol - ZSTD_MATCH_LENGTH_BASELINE_OFFSET;
+	  basebits = elf_zstd_match_length_base[idx];
+	  pbaseline->baseline = ZSTD_DECODE_BASELINE(basebits);
+	  pbaseline->basebits = ZSTD_DECODE_BASEBITS(basebits);
+	}
+      pbaseline->bits = bits;
+      pbaseline->base = base;
+    }
+
+  return 1;
+}
+
+#ifdef BACKTRACE_GENERATE_ZSTD_FSE_TABLES
+
+/* Used to generate the predefined FSE decoding tables for zstd.  */
+
+#include <stdio.h>
+
+/* These values are straight from RFC 8878.  */
+
+static int16_t lit[36] =
+{
+   4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
+   2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 1, 1, 1, 1,
+  -1,-1,-1,-1
+};
+
+static int16_t match[53] =
+{
+   1, 4, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
+   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1,-1,
+  -1,-1,-1,-1,-1
+};
+
+static int16_t offset[29] =
+{
+  1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1
+};
+
+static uint16_t next[256];
+
+static void
+print_table (const struct elf_zstd_fse_baseline_entry *table, size_t size)
+{
+  size_t i;
+
+  printf ("{\n");
+  for (i = 0; i < size; i += 3)
+    {
+      int j;
+
+      printf (" ");
+      for (j = 0; j < 3 && i + j < size; ++j)
+	printf (" { %u, %d, %d, %d },", table[i + j].baseline,
+		table[i + j].basebits, table[i + j].bits,
+		table[i + j].base);
+      printf ("\n");
+    }
+  printf ("};\n");
+}
+
+int
+main ()
+{
+  struct elf_zstd_fse_entry lit_table[64];
+  struct elf_zstd_fse_baseline_entry lit_baseline[64];
+  struct elf_zstd_fse_entry match_table[64];
+  struct elf_zstd_fse_baseline_entry match_baseline[64];
+  struct elf_zstd_fse_entry offset_table[32];
+  struct elf_zstd_fse_baseline_entry offset_baseline[32];
+
+  if (!elf_zstd_build_fse (lit, sizeof lit / sizeof lit[0], next,
+			   6, lit_table))
+    {
+      fprintf (stderr, "elf_zstd_build_fse failed\n");
+      exit (EXIT_FAILURE);
+    }
+
+  if (!elf_zstd_make_literal_baseline_fse (lit_table, 6, lit_baseline))
+    {
+      fprintf (stderr, "elf_zstd_make_literal_baseline_fse failed\n");
+      exit (EXIT_FAILURE);
+    }
+
+  printf ("static const struct elf_zstd_fse_baseline_entry "
+	  "elf_zstd_lit_table[64] =\n");
+  print_table (lit_baseline,
+	       sizeof lit_baseline / sizeof lit_baseline[0]);
+  printf ("\n");
+
+  if (!elf_zstd_build_fse (match, sizeof match / sizeof match[0], next,
+			   6, match_table))
+    {
+      fprintf (stderr, "elf_zstd_build_fse failed\n");
+      exit (EXIT_FAILURE);
+    }
+
+  if (!elf_zstd_make_match_baseline_fse (match_table, 6, match_baseline))
+    {
+      fprintf (stderr, "elf_zstd_make_match_baseline_fse failed\n");
+      exit (EXIT_FAILURE);
+    }
+
+  printf ("static const struct elf_zstd_fse_baseline_entry "
+	  "elf_zstd_match_table[64] =\n");
+  print_table (match_baseline,
+	       sizeof match_baseline / sizeof match_baseline[0]);
+  printf ("\n");
+
+  if (!elf_zstd_build_fse (offset, sizeof offset / sizeof offset[0], next,
+			   5, offset_table))
+    {
+      fprintf (stderr, "elf_zstd_build_fse failed\n");
+      exit (EXIT_FAILURE);
+    }
+
+  if (!elf_zstd_make_offset_baseline_fse (offset_table, 5, offset_baseline))
+    {
+      fprintf (stderr, "elf_zstd_make_offset_baseline_fse failed\n");
+      exit (EXIT_FAILURE);
+    }
+
+  printf ("static const struct elf_zstd_fse_baseline_entry "
+	  "elf_zstd_offset_table[32] =\n");
+  print_table (offset_baseline,
+	       sizeof offset_baseline / sizeof offset_baseline[0]);
+  printf ("\n");
+
+  return 0;
+}
+
+#endif
+
+/* The fixed tables generated by the #ifdef'ed out main function
+   above.  */
+
+static const struct elf_zstd_fse_baseline_entry elf_zstd_lit_table[64] =
+{
+  { 0, 0, 4, 0 }, { 0, 0, 4, 16 }, { 1, 0, 5, 32 },
+  { 3, 0, 5, 0 }, { 4, 0, 5, 0 }, { 6, 0, 5, 0 },
+  { 7, 0, 5, 0 }, { 9, 0, 5, 0 }, { 10, 0, 5, 0 },
+  { 12, 0, 5, 0 }, { 14, 0, 6, 0 }, { 16, 1, 5, 0 },
+  { 20, 1, 5, 0 }, { 22, 1, 5, 0 }, { 28, 2, 5, 0 },
+  { 32, 3, 5, 0 }, { 48, 4, 5, 0 }, { 64, 6, 5, 32 },
+  { 128, 7, 5, 0 }, { 256, 8, 6, 0 }, { 1024, 10, 6, 0 },
+  { 4096, 12, 6, 0 }, { 0, 0, 4, 32 }, { 1, 0, 4, 0 },
+  { 2, 0, 5, 0 }, { 4, 0, 5, 32 }, { 5, 0, 5, 0 },
+  { 7, 0, 5, 32 }, { 8, 0, 5, 0 }, { 10, 0, 5, 32 },
+  { 11, 0, 5, 0 }, { 13, 0, 6, 0 }, { 16, 1, 5, 32 },
+  { 18, 1, 5, 0 }, { 22, 1, 5, 32 }, { 24, 2, 5, 0 },
+  { 32, 3, 5, 32 }, { 40, 3, 5, 0 }, { 64, 6, 4, 0 },
+  { 64, 6, 4, 16 }, { 128, 7, 5, 32 }, { 512, 9, 6, 0 },
+  { 2048, 11, 6, 0 }, { 0, 0, 4, 48 }, { 1, 0, 4, 16 },
+  { 2, 0, 5, 32 }, { 3, 0, 5, 32 }, { 5, 0, 5, 32 },
+  { 6, 0, 5, 32 }, { 8, 0, 5, 32 }, { 9, 0, 5, 32 },
+  { 11, 0, 5, 32 }, { 12, 0, 5, 32 }, { 15, 0, 6, 0 },
+  { 18, 1, 5, 32 }, { 20, 1, 5, 32 }, { 24, 2, 5, 32 },
+  { 28, 2, 5, 32 }, { 40, 3, 5, 32 }, { 48, 4, 5, 32 },
+  { 65536, 16, 6, 0 }, { 32768, 15, 6, 0 }, { 16384, 14, 6, 0 },
+  { 8192, 13, 6, 0 },
+};
+
+static const struct elf_zstd_fse_baseline_entry elf_zstd_match_table[64] =
+{
+  { 3, 0, 6, 0 }, { 4, 0, 4, 0 }, { 5, 0, 5, 32 },
+  { 6, 0, 5, 0 }, { 8, 0, 5, 0 }, { 9, 0, 5, 0 },
+  { 11, 0, 5, 0 }, { 13, 0, 6, 0 }, { 16, 0, 6, 0 },
+  { 19, 0, 6, 0 }, { 22, 0, 6, 0 }, { 25, 0, 6, 0 },
+  { 28, 0, 6, 0 }, { 31, 0, 6, 0 }, { 34, 0, 6, 0 },
+  { 37, 1, 6, 0 }, { 41, 1, 6, 0 }, { 47, 2, 6, 0 },
+  { 59, 3, 6, 0 }, { 83, 4, 6, 0 }, { 131, 7, 6, 0 },
+  { 515, 9, 6, 0 }, { 4, 0, 4, 16 }, { 5, 0, 4, 0 },
+  { 6, 0, 5, 32 }, { 7, 0, 5, 0 }, { 9, 0, 5, 32 },
+  { 10, 0, 5, 0 }, { 12, 0, 6, 0 }, { 15, 0, 6, 0 },
+  { 18, 0, 6, 0 }, { 21, 0, 6, 0 }, { 24, 0, 6, 0 },
+  { 27, 0, 6, 0 }, { 30, 0, 6, 0 }, { 33, 0, 6, 0 },
+  { 35, 1, 6, 0 }, { 39, 1, 6, 0 }, { 43, 2, 6, 0 },
+  { 51, 3, 6, 0 }, { 67, 4, 6, 0 }, { 99, 5, 6, 0 },
+  { 259, 8, 6, 0 }, { 4, 0, 4, 32 }, { 4, 0, 4, 48 },
+  { 5, 0, 4, 16 }, { 7, 0, 5, 32 }, { 8, 0, 5, 32 },
+  { 10, 0, 5, 32 }, { 11, 0, 5, 32 }, { 14, 0, 6, 0 },
+  { 17, 0, 6, 0 }, { 20, 0, 6, 0 }, { 23, 0, 6, 0 },
+  { 26, 0, 6, 0 }, { 29, 0, 6, 0 }, { 32, 0, 6, 0 },
+  { 65539, 16, 6, 0 }, { 32771, 15, 6, 0 }, { 16387, 14, 6, 0 },
+  { 8195, 13, 6, 0 }, { 4099, 12, 6, 0 }, { 2051, 11, 6, 0 },
+  { 1027, 10, 6, 0 },
+};
+
+static const struct elf_zstd_fse_baseline_entry elf_zstd_offset_table[32] =
+{
+  { 1, 0, 5, 0 }, { 61, 6, 4, 0 }, { 509, 9, 5, 0 },
+  { 32765, 15, 5, 0 }, { 2097149, 21, 5, 0 }, { 5, 3, 5, 0 },
+  { 125, 7, 4, 0 }, { 4093, 12, 5, 0 }, { 262141, 18, 5, 0 },
+  { 8388605, 23, 5, 0 }, { 29, 5, 5, 0 }, { 253, 8, 4, 0 },
+  { 16381, 14, 5, 0 }, { 1048573, 20, 5, 0 }, { 1, 2, 5, 0 },
+  { 125, 7, 4, 16 }, { 2045, 11, 5, 0 }, { 131069, 17, 5, 0 },
+  { 4194301, 22, 5, 0 }, { 13, 4, 5, 0 }, { 253, 8, 4, 16 },
+  { 8189, 13, 5, 0 }, { 524285, 19, 5, 0 }, { 2, 1, 5, 0 },
+  { 61, 6, 4, 16 }, { 1021, 10, 5, 0 }, { 65533, 16, 5, 0 },
+  { 268435453, 28, 5, 0 }, { 134217725, 27, 5, 0 }, { 67108861, 26, 5, 0 },
+  { 33554429, 25, 5, 0 }, { 16777213, 24, 5, 0 },
+};
+
+/* Read a zstd Huffman table and build the decoding table in *TABLE, reading
+   and updating *PPIN.  This sets *PTABLE_BITS to the number of bits of the
+   table, such that the table length is 1 << *TABLE_BITS.  ZDEBUG_TABLE is
+   scratch space; it must be enough for 512 uint16_t values + 256 32-bit values
+   (2048 bytes).  Returns 1 on success, 0 on error.  */
+
+static int
+elf_zstd_read_huff (const unsigned char **ppin, const unsigned char *pinend,
+		    uint16_t *zdebug_table, uint16_t *table, int *ptable_bits)
+{
+  const unsigned char *pin;
+  unsigned char hdr;
+  unsigned char *weights;
+  size_t count;
+  uint32_t *weight_mark;
+  size_t i;
+  uint32_t weight_mask;
+  size_t table_bits;
+
+  pin = *ppin;
+  if (unlikely (pin >= pinend))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+  hdr = *pin;
+  ++pin;
+
+  weights = (unsigned char *) zdebug_table;
+
+  if (hdr < 128)
+    {
+      /* Table is compressed using FSE.  */
+
+      struct elf_zstd_fse_entry *fse_table;
+      int fse_table_bits;
+      uint16_t *scratch;
+      const unsigned char *pfse;
+      const unsigned char *pback;
+      uint64_t val;
+      unsigned int bits;
+      unsigned int state1, state2;
+
+      /* SCRATCH is used temporarily by elf_zstd_read_fse.  It overlaps
+	 WEIGHTS.  */
+      scratch = zdebug_table;
+      fse_table = (struct elf_zstd_fse_entry *) (scratch + 512);
+      fse_table_bits = 6;
+
+      pfse = pin;
+      if (!elf_zstd_read_fse (&pfse, pinend, scratch, 255, fse_table,
+			      &fse_table_bits))
+	return 0;
+
+      if (unlikely (pin + hdr > pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+
+      /* We no longer need SCRATCH.  Start recording weights.  We need up to
+	 256 bytes of weights and 64 bytes of rank counts, so it won't overlap
+	 FSE_TABLE.  */
+
+      pback = pin + hdr - 1;
+
+      if (!elf_fetch_backward_init (&pback, pfse, &val, &bits))
+	return 0;
+
+      bits -= fse_table_bits;
+      state1 = (val >> bits) & ((1U << fse_table_bits) - 1);
+      bits -= fse_table_bits;
+      state2 = (val >> bits) & ((1U << fse_table_bits) - 1);
+
+      /* There are two independent FSE streams, tracked by STATE1 and STATE2.
+	 We decode them alternately.  */
+
+      count = 0;
+      while (1)
+	{
+	  struct elf_zstd_fse_entry *pt;
+	  uint64_t v;
+
+	  pt = &fse_table[state1];
+
+	  if (unlikely (pin < pinend) && bits < pt->bits)
+	    {
+	      if (unlikely (count >= 254))
+		{
+		  elf_uncompress_failed ();
+		  return 0;
+		}
+	      weights[count] = (unsigned char) pt->symbol;
+	      weights[count + 1] = (unsigned char) fse_table[state2].symbol;
+	      count += 2;
+	      break;
+	    }
+
+	  if (unlikely (pt->bits == 0))
+	    v = 0;
+	  else
+	    {
+	      if (!elf_fetch_bits_backward (&pback, pfse, &val, &bits))
+		return 0;
+
+	      bits -= pt->bits;
+	      v = (val >> bits) & (((uint64_t)1 << pt->bits) - 1);
+	    }
+
+	  state1 = pt->base + v;
+
+	  if (unlikely (count >= 255))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+
+	  weights[count] = pt->symbol;
+	  ++count;
+
+	  pt = &fse_table[state2];
+
+	  if (unlikely (pin < pinend && bits < pt->bits))
+	    {
+	      if (unlikely (count >= 254))
+		{
+		  elf_uncompress_failed ();
+		  return 0;
+		}
+	      weights[count] = (unsigned char) pt->symbol;
+	      weights[count + 1] = (unsigned char) fse_table[state1].symbol;
+	      count += 2;
+	      break;
+	    }
+
+	  if (unlikely (pt->bits == 0))
+	    v = 0;
+	  else
+	    {
+	      if (!elf_fetch_bits_backward (&pback, pfse, &val, &bits))
+		return 0;
+
+	      bits -= pt->bits;
+	      v = (val >> bits) & (((uint64_t)1 << pt->bits) - 1);
+	    }
+
+	  state2 = pt->base + v;
+
+	  if (unlikely (count >= 255))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+
+	  weights[count] = pt->symbol;
+	  ++count;
+	}
+
+      pin += hdr;
+    }
+  else
+    {
+      /* Table is not compressed.  Each weight is 4 bits.  */
+
+      count = hdr - 127;
+      if (unlikely (pin + ((count + 1) / 2) >= pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      for (i = 0; i < count; i += 2)
+	{
+	  unsigned char b;
+
+	  b = *pin;
+	  ++pin;
+	  weights[i] = b >> 4;
+	  weights[i + 1] = b & 0xf;
+	}
+    }
+
+  weight_mark = (uint32_t *) (weights + 256);
+  memset (weight_mark, 0, 13 * sizeof (uint32_t));
+  weight_mask = 0;
+  for (i = 0; i < count; ++i)
+    {
+      unsigned char w;
+
+      w = weights[i];
+      if (unlikely (w > 12))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      ++weight_mark[w];
+      if (w > 0)
+	weight_mask += 1U << (w - 1);
+    }
+  if (unlikely (weight_mask == 0))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  table_bits = 32 - __builtin_clz (weight_mask);
+  if (unlikely (table_bits > 11))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  /* Work out the last weight value, which is omitted because the weights must
+     sum to a power of two.  */
+  {
+    uint32_t left;
+    uint32_t high_bit;
+
+    left = ((uint32_t)1 << table_bits) - weight_mask;
+    if (left == 0)
+      {
+	elf_uncompress_failed ();
+	return 0;
+      }
+    high_bit = 31 - __builtin_clz (left);
+    if (((uint32_t)1 << high_bit) != left)
+      {
+	elf_uncompress_failed ();
+	return 0;
+      }
+
+    if (unlikely (count >= 256))
+      {
+	elf_uncompress_failed ();
+	return 0;
+      }
+
+    weights[count] = high_bit + 1;
+    ++count;
+    ++weight_mark[high_bit + 1];
+  }
+
+  if (weight_mark[1] < 2 || (weight_mark[1] & 1) != 0)
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  /* Change WEIGHT_MARK from a count of weights to the index of the first
+     symbol for that weight.  We shift the indexes to also store how many we
+     have seen so far, below.  */
+  {
+    uint32_t next;
+
+    next = 0;
+    for (i = 0; i < table_bits; ++i)
+      {
+	uint32_t cur;
+
+	cur = next;
+	next += weight_mark[i + 1] << i;
+	weight_mark[i + 1] = cur;
+      }
+  }
+
+  for (i = 0; i < count; ++i)
+    {
+      unsigned char weight;
+      uint32_t length;
+      uint16_t tval;
+      size_t start;
+      uint32_t j;
+
+      weight = weights[i];
+      if (weight == 0)
+	continue;
+
+      length = 1U << (weight - 1);
+      tval = (i << 8) | (table_bits + 1 - weight);
+      start = weight_mark[weight];
+      for (j = 0; j < length; ++j)
+	table[start + j] = tval;
+      weight_mark[weight] += length;
+    }
+
+  *ppin = pin;
+  *ptable_bits = (int)table_bits;
+
+  return 1;
+}
+
+/* Read and decompress the literals and store them ending at POUTEND.  This
+   works because we are going to use all the literals in the output, so they
+   must fit into the output buffer.  HUFFMAN_TABLE, and PHUFFMAN_TABLE_BITS
+   store the Huffman table across calls.  SCRATCH is used to read a Huffman
+   table.  Store the start of the decompressed literals in *PPLIT.  Update
+   *PPIN.  Return 1 on success, 0 on error.  */
+
+static int
+elf_zstd_read_literals (const unsigned char **ppin,
+			const unsigned char *pinend,
+			unsigned char *pout,
+			unsigned char *poutend,
+			uint16_t *scratch,
+			uint16_t *huffman_table,
+			int *phuffman_table_bits,
+			unsigned char **pplit)
+{
+  const unsigned char *pin;
+  unsigned char *plit;
+  unsigned char hdr;
+  uint32_t regenerated_size;
+  uint32_t compressed_size;
+  int streams;
+  uint32_t total_streams_size;
+  unsigned int huffman_table_bits;
+  uint64_t huffman_mask;
+
+  pin = *ppin;
+  if (unlikely (pin >= pinend))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+  hdr = *pin;
+  ++pin;
+
+  if ((hdr & 3) == 0 || (hdr & 3) == 1)
+    {
+      int raw;
+
+      /* Raw_Literals_Block or RLE_Literals_Block */
+
+      raw = (hdr & 3) == 0;
+
+      switch ((hdr >> 2) & 3)
+	{
+	case 0: case 2:
+	  regenerated_size = hdr >> 3;
+	  break;
+	case 1:
+	  if (unlikely (pin >= pinend))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+	  regenerated_size = (hdr >> 4) + ((uint32_t)(*pin) << 4);
+	  ++pin;
+	  break;
+	case 3:
+	  if (unlikely (pin + 1 >= pinend))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+	  regenerated_size = ((hdr >> 4)
+			      + ((uint32_t)*pin << 4)
+			      + ((uint32_t)pin[1] << 12));
+	  pin += 2;
+	  break;
+	default:
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+
+      if (unlikely ((size_t)(poutend - pout) < regenerated_size))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+
+      plit = poutend - regenerated_size;
+
+      if (raw)
+	{
+	  if (unlikely (pin + regenerated_size >= pinend))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+	  memcpy (plit, pin, regenerated_size);
+	  pin += regenerated_size;
+	}
+      else
+	{
+	  if (pin >= pinend)
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+	  memset (plit, *pin, regenerated_size);
+	  ++pin;
+	}
+
+      *ppin = pin;
+      *pplit = plit;
+
+      return 1;
+    }
+
+  /* Compressed_Literals_Block or Treeless_Literals_Block */
+
+  switch ((hdr >> 2) & 3)
+    {
+    case 0: case 1:
+      if (unlikely (pin + 1 >= pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      regenerated_size = (hdr >> 4) | ((uint32_t)(*pin & 0x3f) << 4);
+      compressed_size = (uint32_t)*pin >> 6 | ((uint32_t)pin[1] << 2);
+      pin += 2;
+      streams = ((hdr >> 2) & 3) == 0 ? 1 : 4;
+      break;
+    case 2:
+      if (unlikely (pin + 2 >= pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      regenerated_size = (((uint32_t)hdr >> 4)
+			  | ((uint32_t)*pin << 4)
+			  | (((uint32_t)pin[1] & 3) << 12));
+      compressed_size = (((uint32_t)pin[1] >> 2)
+			 | ((uint32_t)pin[2] << 6));
+      pin += 3;
+      streams = 4;
+      break;
+    case 3:
+      if (unlikely (pin + 3 >= pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      regenerated_size = (((uint32_t)hdr >> 4)
+			  | ((uint32_t)*pin << 4)
+			  | (((uint32_t)pin[1] & 0x3f) << 12));
+      compressed_size = (((uint32_t)pin[1] >> 6)
+			 | ((uint32_t)pin[2] << 2)
+			 | ((uint32_t)pin[3] << 10));
+      pin += 4;
+      streams = 4;
+      break;
+    default:
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  if (unlikely (pin + compressed_size > pinend))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  pinend = pin + compressed_size;
+  *ppin = pinend;
+
+  if (unlikely ((size_t)(poutend - pout) < regenerated_size))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  plit = poutend - regenerated_size;
+
+  *pplit = plit;
+
+  total_streams_size = compressed_size;
+  if ((hdr & 3) == 2)
+    {
+      const unsigned char *ptable;
+
+      /* Compressed_Literals_Block.  Read Huffman tree.  */
+
+      ptable = pin;
+      if (!elf_zstd_read_huff (&ptable, pinend, scratch, huffman_table,
+			       phuffman_table_bits))
+	return 0;
+
+      if (unlikely (total_streams_size < (size_t)(ptable - pin)))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+
+      total_streams_size -= ptable - pin;
+      pin = ptable;
+    }
+  else
+    {
+      /* Treeless_Literals_Block.  Reuse previous Huffman tree.  */
+      if (unlikely (*phuffman_table_bits == 0))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+    }
+
+  /* Decompress COMPRESSED_SIZE bytes of data at PIN using the huffman table,
+     storing REGENERATED_SIZE bytes of decompressed data at PLIT.  */
+
+  huffman_table_bits = (unsigned int)*phuffman_table_bits;
+  huffman_mask = ((uint64_t)1 << huffman_table_bits) - 1;
+
+  if (streams == 1)
+    {
+      const unsigned char *pback;
+      const unsigned char *pbackend;
+      uint64_t val;
+      unsigned int bits;
+      uint32_t i;
+
+      pback = pin + total_streams_size - 1;
+      pbackend = pin;
+      if (!elf_fetch_backward_init (&pback, pbackend, &val, &bits))
+	return 0;
+
+      /* This is one of the inner loops of the decompression algorithm, so we
+	 put some effort into optimization.  We can't get more than 64 bytes
+	 from a single call to elf_fetch_bits_backward, and we can't subtract
+	 more than 11 bits at a time.  */
+
+      if (regenerated_size >= 64)
+	{
+	  unsigned char *plitstart;
+	  unsigned char *plitstop;
+
+	  plitstart = plit;
+	  plitstop = plit + regenerated_size - 64;
+	  while (plit < plitstop)
+	    {
+	      uint16_t t;
+
+	      if (!elf_fetch_bits_backward (&pback, pbackend, &val, &bits))
+		return 0;
+
+	      if (bits < 16)
+		break;
+
+	      while (bits >= 33)
+		{
+		  t = huffman_table[(val >> (bits - huffman_table_bits))
+				    & huffman_mask];
+		  *plit = t >> 8;
+		  ++plit;
+		  bits -= t & 0xff;
+
+		  t = huffman_table[(val >> (bits - huffman_table_bits))
+				    & huffman_mask];
+		  *plit = t >> 8;
+		  ++plit;
+		  bits -= t & 0xff;
+
+		  t = huffman_table[(val >> (bits - huffman_table_bits))
+				    & huffman_mask];
+		  *plit = t >> 8;
+		  ++plit;
+		  bits -= t & 0xff;
+		}
+
+	      while (bits > 11)
+		{
+		  t = huffman_table[(val >> (bits - huffman_table_bits))
+				    & huffman_mask];
+		  *plit = t >> 8;
+		  ++plit;
+		  bits -= t & 0xff;
+		}
+	    }
+
+	  regenerated_size -= plit - plitstart;
+	}
+
+      for (i = 0; i < regenerated_size; ++i)
+	{
+	  uint16_t t;
+
+	  if (!elf_fetch_bits_backward (&pback, pbackend, &val, &bits))
+	    return 0;
+
+	  if (unlikely (bits < huffman_table_bits))
+	    {
+	      t = huffman_table[(val << (huffman_table_bits - bits))
+				& huffman_mask];
+	      if (unlikely (bits < (t & 0xff)))
+		{
+		  elf_uncompress_failed ();
+		  return 0;
+		}
+	    }
+	  else
+	    t = huffman_table[(val >> (bits - huffman_table_bits))
+			      & huffman_mask];
+
+	  *plit = t >> 8;
+	  ++plit;
+	  bits -= t & 0xff;
+	}
+
+      return 1;
+    }
+
+  {
+    uint32_t stream_size1, stream_size2, stream_size3, stream_size4;
+    uint32_t tot;
+    const unsigned char *pback1, *pback2, *pback3, *pback4;
+    const unsigned char *pbackend1, *pbackend2, *pbackend3, *pbackend4;
+    uint64_t val1, val2, val3, val4;
+    unsigned int bits1, bits2, bits3, bits4;
+    unsigned char *plit1, *plit2, *plit3, *plit4;
+    uint32_t regenerated_stream_size;
+    uint32_t regenerated_stream_size4;
+    uint16_t t1, t2, t3, t4;
+    uint32_t i;
+    uint32_t limit;
+
+    /* Read jump table.  */
+    if (unlikely (pin + 5 >= pinend))
+      {
+	elf_uncompress_failed ();
+	return 0;
+      }
+    stream_size1 = (uint32_t)*pin | ((uint32_t)pin[1] << 8);
+    pin += 2;
+    stream_size2 = (uint32_t)*pin | ((uint32_t)pin[1] << 8);
+    pin += 2;
+    stream_size3 = (uint32_t)*pin | ((uint32_t)pin[1] << 8);
+    pin += 2;
+    tot = stream_size1 + stream_size2 + stream_size3;
+    if (unlikely (tot > total_streams_size - 6))
+      {
+	elf_uncompress_failed ();
+	return 0;
+      }
+    stream_size4 = total_streams_size - 6 - tot;
+
+    pback1 = pin + stream_size1 - 1;
+    pbackend1 = pin;
+
+    pback2 = pback1 + stream_size2;
+    pbackend2 = pback1 + 1;
+
+    pback3 = pback2 + stream_size3;
+    pbackend3 = pback2 + 1;
+
+    pback4 = pback3 + stream_size4;
+    pbackend4 = pback3 + 1;
+
+    if (!elf_fetch_backward_init (&pback1, pbackend1, &val1, &bits1))
+      return 0;
+    if (!elf_fetch_backward_init (&pback2, pbackend2, &val2, &bits2))
+      return 0;
+    if (!elf_fetch_backward_init (&pback3, pbackend3, &val3, &bits3))
+      return 0;
+    if (!elf_fetch_backward_init (&pback4, pbackend4, &val4, &bits4))
+      return 0;
+
+    regenerated_stream_size = (regenerated_size + 3) / 4;
+
+    plit1 = plit;
+    plit2 = plit1 + regenerated_stream_size;
+    plit3 = plit2 + regenerated_stream_size;
+    plit4 = plit3 + regenerated_stream_size;
+
+    regenerated_stream_size4 = regenerated_size - regenerated_stream_size * 3;
+
+    /* We can't get more than 64 literal bytes from a single call to
+       elf_fetch_bits_backward.  The fourth stream can be up to 3 bytes less,
+       so use as the limit.  */
+
+    limit = regenerated_stream_size4 <= 64 ? 0 : regenerated_stream_size4 - 64;
+    i = 0;
+    while (i < limit)
+      {
+	if (!elf_fetch_bits_backward (&pback1, pbackend1, &val1, &bits1))
+	  return 0;
+	if (!elf_fetch_bits_backward (&pback2, pbackend2, &val2, &bits2))
+	  return 0;
+	if (!elf_fetch_bits_backward (&pback3, pbackend3, &val3, &bits3))
+	  return 0;
+	if (!elf_fetch_bits_backward (&pback4, pbackend4, &val4, &bits4))
+	  return 0;
+
+	/* We can't subtract more than 11 bits at a time.  */
+
+	do
+	  {
+	    t1 = huffman_table[(val1 >> (bits1 - huffman_table_bits))
+			       & huffman_mask];
+	    t2 = huffman_table[(val2 >> (bits2 - huffman_table_bits))
+			       & huffman_mask];
+	    t3 = huffman_table[(val3 >> (bits3 - huffman_table_bits))
+			       & huffman_mask];
+	    t4 = huffman_table[(val4 >> (bits4 - huffman_table_bits))
+			       & huffman_mask];
+
+	    *plit1 = t1 >> 8;
+	    ++plit1;
+	    bits1 -= t1 & 0xff;
+
+	    *plit2 = t2 >> 8;
+	    ++plit2;
+	    bits2 -= t2 & 0xff;
+
+	    *plit3 = t3 >> 8;
+	    ++plit3;
+	    bits3 -= t3 & 0xff;
+
+	    *plit4 = t4 >> 8;
+	    ++plit4;
+	    bits4 -= t4 & 0xff;
+
+	    ++i;
+	  }
+	while (bits1 > 11 && bits2 > 11 && bits3 > 11 && bits4 > 11);
+      }
+
+    while (i < regenerated_stream_size)
+      {
+	int use4;
+
+	use4 = i < regenerated_stream_size4;
+
+	if (!elf_fetch_bits_backward (&pback1, pbackend1, &val1, &bits1))
+	  return 0;
+	if (!elf_fetch_bits_backward (&pback2, pbackend2, &val2, &bits2))
+	  return 0;
+	if (!elf_fetch_bits_backward (&pback3, pbackend3, &val3, &bits3))
+	  return 0;
+	if (use4)
+	  {
+	    if (!elf_fetch_bits_backward (&pback4, pbackend4, &val4, &bits4))
+	      return 0;
+	  }
+
+	if (unlikely (bits1 < huffman_table_bits))
+	  {
+	    t1 = huffman_table[(val1 << (huffman_table_bits - bits1))
+			       & huffman_mask];
+	    if (unlikely (bits1 < (t1 & 0xff)))
+	      {
+		elf_uncompress_failed ();
+		return 0;
+	      }
+	  }
+	else
+	  t1 = huffman_table[(val1 >> (bits1 - huffman_table_bits))
+			     & huffman_mask];
+
+	if (unlikely (bits2 < huffman_table_bits))
+	  {
+	    t2 = huffman_table[(val2 << (huffman_table_bits - bits2))
+			       & huffman_mask];
+	    if (unlikely (bits2 < (t2 & 0xff)))
+	      {
+		elf_uncompress_failed ();
+		return 0;
+	      }
+	  }
+	else
+	  t2 = huffman_table[(val2 >> (bits2 - huffman_table_bits))
+			     & huffman_mask];
+
+	if (unlikely (bits3 < huffman_table_bits))
+	  {
+	    t3 = huffman_table[(val3 << (huffman_table_bits - bits3))
+			       & huffman_mask];
+	    if (unlikely (bits3 < (t3 & 0xff)))
+	      {
+		elf_uncompress_failed ();
+		return 0;
+	      }
+	  }
+	else
+	  t3 = huffman_table[(val3 >> (bits3 - huffman_table_bits))
+			     & huffman_mask];
+
+	if (use4)
+	  {
+	    if (unlikely (bits4 < huffman_table_bits))
+	      {
+		t4 = huffman_table[(val4 << (huffman_table_bits - bits4))
+				   & huffman_mask];
+		if (unlikely (bits4 < (t4 & 0xff)))
+		  {
+		    elf_uncompress_failed ();
+		    return 0;
+		  }
+	      }
+	    else
+	      t4 = huffman_table[(val4 >> (bits4 - huffman_table_bits))
+				 & huffman_mask];
+
+	    *plit4 = t4 >> 8;
+	    ++plit4;
+	    bits4 -= t4 & 0xff;
+	  }
+
+	*plit1 = t1 >> 8;
+	++plit1;
+	bits1 -= t1 & 0xff;
+
+	*plit2 = t2 >> 8;
+	++plit2;
+	bits2 -= t2 & 0xff;
+
+	*plit3 = t3 >> 8;
+	++plit3;
+	bits3 -= t3 & 0xff;
+
+	++i;
+      }
+  }
+
+  return 1;
+}
+
+/* The information used to decompress a sequence code, which can be a literal
+   length, an offset, or a match length.  */
+
+struct elf_zstd_seq_decode
+{
+  const struct elf_zstd_fse_baseline_entry *table;
+  int table_bits;
+};
+
+/* Unpack a sequence code compression mode.  */
+
+static int
+elf_zstd_unpack_seq_decode (int mode,
+			    const unsigned char **ppin,
+			    const unsigned char *pinend,
+			    const struct elf_zstd_fse_baseline_entry *predef,
+			    int predef_bits,
+			    uint16_t *scratch,
+			    int maxidx,
+			    struct elf_zstd_fse_baseline_entry *table,
+			    int table_bits,
+			    int (*conv)(const struct elf_zstd_fse_entry *,
+					int,
+					struct elf_zstd_fse_baseline_entry *),
+			    struct elf_zstd_seq_decode *decode)
+{
+  switch (mode)
+    {
+    case 0:
+      decode->table = predef;
+      decode->table_bits = predef_bits;
+      break;
+
+    case 1:
+      {
+	struct elf_zstd_fse_entry entry;
+
+	if (unlikely (*ppin >= pinend))
+	  {
+	    elf_uncompress_failed ();
+	    return 0;
+	  }
+	entry.symbol = **ppin;
+	++*ppin;
+	entry.bits = 0;
+	entry.base = 0;
+	decode->table_bits = 0;
+	if (!conv (&entry, 0, table))
+	  return 0;
+      }
+      break;
+
+    case 2:
+      {
+	struct elf_zstd_fse_entry *fse_table;
+
+	/* We use the same space for the simple FSE table and the baseline
+	   table.  */
+	fse_table = (struct elf_zstd_fse_entry *)table;
+	decode->table_bits = table_bits;
+	if (!elf_zstd_read_fse (ppin, pinend, scratch, maxidx, fse_table,
+				&decode->table_bits))
+	  return 0;
+	if (!conv (fse_table, decode->table_bits, table))
+	  return 0;
+	decode->table = table;
+      }
+      break;
+
+    case 3:
+      if (unlikely (decode->table_bits == -1))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      break;
+
+    default:
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  return 1;
+}
+
+/* Decompress a zstd stream from PIN/SIN to POUT/SOUT.  Code based on RFC 8878.
+   Return 1 on success, 0 on error.  */
+
+static int
+elf_zstd_decompress (const unsigned char *pin, size_t sin,
+		     unsigned char *zdebug_table, unsigned char *pout,
+		     size_t sout)
+{
+  const unsigned char *pinend;
+  unsigned char *poutstart;
+  unsigned char *poutend;
+  struct elf_zstd_seq_decode literal_decode;
+  struct elf_zstd_fse_baseline_entry *literal_fse_table;
+  struct elf_zstd_seq_decode match_decode;
+  struct elf_zstd_fse_baseline_entry *match_fse_table;
+  struct elf_zstd_seq_decode offset_decode;
+  struct elf_zstd_fse_baseline_entry *offset_fse_table;
+  uint16_t *huffman_table;
+  int huffman_table_bits;
+  uint32_t repeated_offset1;
+  uint32_t repeated_offset2;
+  uint32_t repeated_offset3;
+  uint16_t *scratch;
+  unsigned char hdr;
+  int has_checksum;
+  uint64_t content_size;
+  int last_block;
+
+  pinend = pin + sin;
+  poutstart = pout;
+  poutend = pout + sout;
+
+  literal_decode.table = NULL;
+  literal_decode.table_bits = -1;
+  literal_fse_table = ((struct elf_zstd_fse_baseline_entry *)
+		       (zdebug_table + ZSTD_TABLE_LITERAL_FSE_OFFSET));
+
+  match_decode.table = NULL;
+  match_decode.table_bits = -1;
+  match_fse_table = ((struct elf_zstd_fse_baseline_entry *)
+		     (zdebug_table + ZSTD_TABLE_MATCH_FSE_OFFSET));
+
+  offset_decode.table = NULL;
+  offset_decode.table_bits = -1;
+  offset_fse_table = ((struct elf_zstd_fse_baseline_entry *)
+		      (zdebug_table + ZSTD_TABLE_OFFSET_FSE_OFFSET));
+  huffman_table = ((uint16_t *)
+		   (zdebug_table + ZSTD_TABLE_HUFFMAN_OFFSET));
+  huffman_table_bits = 0;
+  scratch = ((uint16_t *)
+	     (zdebug_table + ZSTD_TABLE_WORK_OFFSET));
+
+  repeated_offset1 = 1;
+  repeated_offset2 = 4;
+  repeated_offset3 = 8;
+
+  if (unlikely (sin < 4))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  /* These values are the zstd magic number.  */
+  if (unlikely (pin[0] != 0x28
+		|| pin[1] != 0xb5
+		|| pin[2] != 0x2f
+		|| pin[3] != 0xfd))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  pin += 4;
+
+  if (unlikely (pin >= pinend))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  hdr = *pin++;
+
+  /* We expect a single frame.  */
+  if (unlikely ((hdr & (1 << 5)) == 0))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+  /* Reserved bit must be zero.  */
+  if (unlikely ((hdr & (1 << 3)) != 0))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+  /* We do not expect a dictionary.  */
+  if (unlikely ((hdr & 3) != 0))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+  has_checksum = (hdr & (1 << 2)) != 0;
+  switch (hdr >> 6)
+    {
+    case 0:
+      if (unlikely (pin >= pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      content_size = (uint64_t) *pin++;
+      break;
+    case 1:
+      if (unlikely (pin + 1 >= pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      content_size = (((uint64_t) pin[0]) | (((uint64_t) pin[1]) << 8)) + 256;
+      pin += 2;
+      break;
+    case 2:
+      if (unlikely (pin + 3 >= pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      content_size = ((uint64_t) pin[0]
+		      | (((uint64_t) pin[1]) << 8)
+		      | (((uint64_t) pin[2]) << 16)
+		      | (((uint64_t) pin[3]) << 24));
+      pin += 4;
+      break;
+    case 3:
+      if (unlikely (pin + 7 >= pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      content_size = ((uint64_t) pin[0]
+		      | (((uint64_t) pin[1]) << 8)
+		      | (((uint64_t) pin[2]) << 16)
+		      | (((uint64_t) pin[3]) << 24)
+		      | (((uint64_t) pin[4]) << 32)
+		      | (((uint64_t) pin[5]) << 40)
+		      | (((uint64_t) pin[6]) << 48)
+		      | (((uint64_t) pin[7]) << 56));
+      pin += 8;
+      break;
+    default:
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  if (unlikely (content_size != (size_t) content_size
+		|| (size_t) content_size != sout))
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  last_block = 0;
+  while (!last_block)
+    {
+      uint32_t block_hdr;
+      int block_type;
+      uint32_t block_size;
+
+      if (unlikely (pin + 2 >= pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+      block_hdr = ((uint32_t) pin[0]
+		   | (((uint32_t) pin[1]) << 8)
+		   | (((uint32_t) pin[2]) << 16));
+      pin += 3;
+
+      last_block = block_hdr & 1;
+      block_type = (block_hdr >> 1) & 3;
+      block_size = block_hdr >> 3;
+
+      switch (block_type)
+	{
+	case 0:
+	  /* Raw_Block */
+	  if (unlikely ((size_t) block_size > (size_t) (pinend - pin)))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+	  if (unlikely ((size_t) block_size > (size_t) (poutend - pout)))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+	  memcpy (pout, pin, block_size);
+	  pout += block_size;
+	  pin += block_size;
+	  break;
+
+	case 1:
+	  /* RLE_Block */
+	  if (unlikely (pin >= pinend))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+	  if (unlikely ((size_t) block_size > (size_t) (poutend - pout)))
+	    {
+	      elf_uncompress_failed ();
+	      return 0;
+	    }
+	  memset (pout, *pin, block_size);
+	  pout += block_size;
+	  pin++;
+	  break;
+
+	case 2:
+	  {
+	    const unsigned char *pblockend;
+	    unsigned char *plitstack;
+	    unsigned char *plit;
+	    uint32_t literal_count;
+	    unsigned char seq_hdr;
+	    size_t seq_count;
+	    size_t seq;
+	    const unsigned char *pback;
+	    uint64_t val;
+	    unsigned int bits;
+	    unsigned int literal_state;
+	    unsigned int offset_state;
+	    unsigned int match_state;
+
+	    /* Compressed_Block */
+	    if (unlikely ((size_t) block_size > (size_t) (pinend - pin)))
+	      {
+		elf_uncompress_failed ();
+		return 0;
+	      }
+
+	    pblockend = pin + block_size;
+
+	    /* Read the literals into the end of the output space, and leave
+	       PLIT pointing at them.  */
+
+	    if (!elf_zstd_read_literals (&pin, pblockend, pout, poutend,
+					 scratch, huffman_table,
+					 &huffman_table_bits,
+					 &plitstack))
+	      return 0;
+	    plit = plitstack;
+	    literal_count = poutend - plit;
+
+	    seq_hdr = *pin;
+	    pin++;
+	    if (seq_hdr < 128)
+	      seq_count = seq_hdr;
+	    else if (seq_hdr < 255)
+	      {
+		if (unlikely (pin >= pinend))
+		  {
+		    elf_uncompress_failed ();
+		    return 0;
+		  }
+		seq_count = ((seq_hdr - 128) << 8) + *pin;
+		pin++;
+	      }
+	    else
+	      {
+		if (unlikely (pin + 1 >= pinend))
+		  {
+		    elf_uncompress_failed ();
+		    return 0;
+		  }
+		seq_count = *pin + (pin[1] << 8) + 0x7f00;
+		pin += 2;
+	      }
+
+	    if (seq_count > 0)
+	      {
+		int (*pfn)(const struct elf_zstd_fse_entry *,
+			   int, struct elf_zstd_fse_baseline_entry *);
+
+		if (unlikely (pin >= pinend))
+		  {
+		    elf_uncompress_failed ();
+		    return 0;
+		  }
+		seq_hdr = *pin;
+		++pin;
+
+		pfn = elf_zstd_make_literal_baseline_fse;
+		if (!elf_zstd_unpack_seq_decode ((seq_hdr >> 6) & 3,
+						 &pin, pinend,
+						 &elf_zstd_lit_table[0], 6,
+						 scratch, 35,
+						 literal_fse_table, 9, pfn,
+						 &literal_decode))
+		  return 0;
+
+		pfn = elf_zstd_make_offset_baseline_fse;
+		if (!elf_zstd_unpack_seq_decode ((seq_hdr >> 4) & 3,
+						 &pin, pinend,
+						 &elf_zstd_offset_table[0], 5,
+						 scratch, 31,
+						 offset_fse_table, 8, pfn,
+						 &offset_decode))
+		  return 0;
+
+		pfn = elf_zstd_make_match_baseline_fse;
+		if (!elf_zstd_unpack_seq_decode ((seq_hdr >> 2) & 3,
+						 &pin, pinend,
+						 &elf_zstd_match_table[0], 6,
+						 scratch, 52,
+						 match_fse_table, 9, pfn,
+						 &match_decode))
+		  return 0;
+	      }
+
+	    pback = pblockend - 1;
+	    if (!elf_fetch_backward_init (&pback, pin, &val, &bits))
+	      return 0;
+
+	    bits -= literal_decode.table_bits;
+	    literal_state = ((val >> bits)
+			     & ((1U << literal_decode.table_bits) - 1));
+
+	    if (!elf_fetch_bits_backward (&pback, pin, &val, &bits))
+	      return 0;
+	    bits -= offset_decode.table_bits;
+	    offset_state = ((val >> bits)
+			    & ((1U << offset_decode.table_bits) - 1));
+
+	    if (!elf_fetch_bits_backward (&pback, pin, &val, &bits))
+	      return 0;
+	    bits -= match_decode.table_bits;
+	    match_state = ((val >> bits)
+			   & ((1U << match_decode.table_bits) - 1));
+
+	    seq = 0;
+	    while (1)
+	      {
+		const struct elf_zstd_fse_baseline_entry *pt;
+		uint32_t offset_basebits;
+		uint32_t offset_baseline;
+		uint32_t offset_bits;
+		uint32_t offset_base;
+		uint32_t offset;
+		uint32_t match_baseline;
+		uint32_t match_bits;
+		uint32_t match_base;
+		uint32_t match;
+		uint32_t literal_baseline;
+		uint32_t literal_bits;
+		uint32_t literal_base;
+		uint32_t literal;
+		uint32_t need;
+		uint32_t add;
+
+		pt = &offset_decode.table[offset_state];
+		offset_basebits = pt->basebits;
+		offset_baseline = pt->baseline;
+		offset_bits = pt->bits;
+		offset_base = pt->base;
+
+		/* This case can be more than 16 bits, which is all that
+		   elf_fetch_bits_backward promises.  */
+		need = offset_basebits;
+		add = 0;
+		if (unlikely (need > 16))
+		  {
+		    if (!elf_fetch_bits_backward (&pback, pin, &val, &bits))
+		      return 0;
+		    bits -= 16;
+		    add = (val >> bits) & ((1U << 16) - 1);
+		    need -= 16;
+		    add <<= need;
+		  }
+		if (need > 0)
+		  {
+		    if (!elf_fetch_bits_backward (&pback, pin, &val, &bits))
+		      return 0;
+		    bits -= need;
+		    add += (val >> bits) & ((1U << need) - 1);
+		  }
+
+		offset = offset_baseline + add;
+
+		pt = &match_decode.table[match_state];
+		need = pt->basebits;
+		match_baseline = pt->baseline;
+		match_bits = pt->bits;
+		match_base = pt->base;
+
+		add = 0;
+		if (need > 0)
+		  {
+		    if (!elf_fetch_bits_backward (&pback, pin, &val, &bits))
+		      return 0;
+		    bits -= need;
+		    add = (val >> bits) & ((1U << need) - 1);
+		  }
+
+		match = match_baseline + add;
+
+		pt = &literal_decode.table[literal_state];
+		need = pt->basebits;
+		literal_baseline = pt->baseline;
+		literal_bits = pt->bits;
+		literal_base = pt->base;
+
+		add = 0;
+		if (need > 0)
+		  {
+		    if (!elf_fetch_bits_backward (&pback, pin, &val, &bits))
+		      return 0;
+		    bits -= need;
+		    add = (val >> bits) & ((1U << need) - 1);
+		  }
+
+		literal = literal_baseline + add;
+
+		/* See the comment in elf_zstd_make_offset_baseline_fse.  */
+		if (offset_basebits > 1)
+		  {
+		    repeated_offset3 = repeated_offset2;
+		    repeated_offset2 = repeated_offset1;
+		    repeated_offset1 = offset;
+		  }
+		else
+		  {
+		    if (unlikely (literal == 0))
+		      ++offset;
+		    switch (offset)
+		      {
+		      case 1:
+			offset = repeated_offset1;
+			break;
+		      case 2:
+			offset = repeated_offset2;
+			repeated_offset2 = repeated_offset1;
+			repeated_offset1 = offset;
+			break;
+		      case 3:
+			offset = repeated_offset3;
+			repeated_offset3 = repeated_offset2;
+			repeated_offset2 = repeated_offset1;
+			repeated_offset1 = offset;
+			break;
+		      case 4:
+			offset = repeated_offset1 - 1;
+			repeated_offset3 = repeated_offset2;
+			repeated_offset2 = repeated_offset1;
+			repeated_offset1 = offset;
+			break;
+		      }
+		  }
+
+		++seq;
+		if (seq < seq_count)
+		  {
+		    uint32_t v;
+
+		    /* Update the three states.  */
+
+		    if (!elf_fetch_bits_backward (&pback, pin, &val, &bits))
+		      return 0;
+
+		    need = literal_bits;
+		    bits -= need;
+		    v = (val >> bits) & (((uint32_t)1 << need) - 1);
+
+		    literal_state = literal_base + v;
+
+		    if (!elf_fetch_bits_backward (&pback, pin, &val, &bits))
+		      return 0;
+
+		    need = match_bits;
+		    bits -= need;
+		    v = (val >> bits) & (((uint32_t)1 << need) - 1);
+
+		    match_state = match_base + v;
+
+		    if (!elf_fetch_bits_backward (&pback, pin, &val, &bits))
+		      return 0;
+
+		    need = offset_bits;
+		    bits -= need;
+		    v = (val >> bits) & (((uint32_t)1 << need) - 1);
+
+		    offset_state = offset_base + v;
+		  }
+
+		/* The next sequence is now in LITERAL, OFFSET, MATCH.  */
+
+		/* Copy LITERAL bytes from the literals.  */
+
+		if (unlikely ((size_t)(poutend - pout) < literal))
+		  {
+		    elf_uncompress_failed ();
+		    return 0;
+		  }
+
+		if (unlikely (literal_count < literal))
+		  {
+		    elf_uncompress_failed ();
+		    return 0;
+		  }
+
+		literal_count -= literal;
+
+		/* Often LITERAL is small, so handle small cases quickly.  */
+		switch (literal)
+		  {
+		  case 8:
+		    *pout++ = *plit++;
+		    /* FALLTHROUGH */
+		  case 7:
+		    *pout++ = *plit++;
+		    /* FALLTHROUGH */
+		  case 6:
+		    *pout++ = *plit++;
+		    /* FALLTHROUGH */
+		  case 5:
+		    *pout++ = *plit++;
+		    /* FALLTHROUGH */
+		  case 4:
+		    *pout++ = *plit++;
+		    /* FALLTHROUGH */
+		  case 3:
+		    *pout++ = *plit++;
+		    /* FALLTHROUGH */
+		  case 2:
+		    *pout++ = *plit++;
+		    /* FALLTHROUGH */
+		  case 1:
+		    *pout++ = *plit++;
+		    break;
+
+		  case 0:
+		    break;
+
+		  default:
+		    if (unlikely ((size_t)(plit - pout) < literal))
+		      {
+			uint32_t move;
+
+			move = plit - pout;
+			while (literal > move)
+			  {
+			    memcpy (pout, plit, move);
+			    pout += move;
+			    plit += move;
+			    literal -= move;
+			  }
+		      }
+
+		    memcpy (pout, plit, literal);
+		    pout += literal;
+		    plit += literal;
+		  }
+
+		if (match > 0)
+		  {
+		    /* Copy MATCH bytes from the decoded output at OFFSET.  */
+
+		    if (unlikely ((size_t)(poutend - pout) < match))
+		      {
+			elf_uncompress_failed ();
+			return 0;
+		      }
+
+		    if (unlikely ((size_t)(pout - poutstart) < offset))
+		      {
+			elf_uncompress_failed ();
+			return 0;
+		      }
+
+		    if (offset >= match)
+		      {
+			memcpy (pout, pout - offset, match);
+			pout += match;
+		      }
+		    else
+		      {
+			while (match > 0)
+			  {
+			    uint32_t copy;
+
+			    copy = match < offset ? match : offset;
+			    memcpy (pout, pout - offset, copy);
+			    match -= copy;
+			    pout += copy;
+			  }
+		      }
+		  }
+
+		if (unlikely (seq >= seq_count))
+		  {
+		    /* Copy remaining literals.  */
+		    if (literal_count > 0 && plit != pout)
+		      {
+			if (unlikely ((size_t)(poutend - pout)
+				      < literal_count))
+			  {
+			    elf_uncompress_failed ();
+			    return 0;
+			  }
+
+			if ((size_t)(plit - pout) < literal_count)
+			  {
+			    uint32_t move;
+
+			    move = plit - pout;
+			    while (literal_count > move)
+			      {
+				memcpy (pout, plit, move);
+				pout += move;
+				plit += move;
+				literal_count -= move;
+			      }
+			  }
+
+			memcpy (pout, plit, literal_count);
+		      }
+
+		    pout += literal_count;
+
+		    break;
+		  }
+	      }
+
+	    pin = pblockend;
+	  }
+	  break;
+
+	case 3:
+	default:
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+    }
+
+  if (has_checksum)
+    {
+      if (unlikely (pin + 4 > pinend))
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
+
+      /* We don't currently verify the checksum.  Currently running GNU ld with
+	 --compress-debug-sections=zstd does not seem to generate a
+	 checksum.  */
+
+      pin += 4;
+    }
+
+  if (pin != pinend)
+    {
+      elf_uncompress_failed ();
+      return 0;
+    }
+
+  return 1;
+}
+
+#define ZDEBUG_TABLE_SIZE \
+  (ZLIB_TABLE_SIZE > ZSTD_TABLE_SIZE ? ZLIB_TABLE_SIZE : ZSTD_TABLE_SIZE)
+
+/* Uncompress the old compressed debug format, the one emitted by
+   --compress-debug-sections=zlib-gnu.  The compressed data is in
+   COMPRESSED / COMPRESSED_SIZE, and the function writes to
+   *UNCOMPRESSED / *UNCOMPRESSED_SIZE.  ZDEBUG_TABLE is work space to
+   hold Huffman tables.  Returns 0 on error, 1 on successful
+   decompression or if something goes wrong.  In general we try to
+   carry on, by returning 1, even if we can't decompress.  */
+
+static int
+elf_uncompress_zdebug (struct backtrace_state *state,
+		       const unsigned char *compressed, size_t compressed_size,
+		       uint16_t *zdebug_table,
+		       backtrace_error_callback error_callback, void *data,
+		       unsigned char **uncompressed, size_t *uncompressed_size)
+{
+  size_t sz;
+  size_t i;
+  unsigned char *po;
+
+  *uncompressed = NULL;
+  *uncompressed_size = 0;
+
+  /* The format starts with the four bytes ZLIB, followed by the 8
+     byte length of the uncompressed data in big-endian order,
+     followed by a zlib stream.  */
+
+  if (compressed_size < 12 || memcmp (compressed, "ZLIB", 4) != 0)
+    return 1;
+
+  sz = 0;
+  for (i = 0; i < 8; i++)
+    sz = (sz << 8) | compressed[i + 4];
+
+  if (*uncompressed != NULL && *uncompressed_size >= sz)
+    po = *uncompressed;
+  else
+    {
+      po = (unsigned char *) backtrace_alloc (state, sz, error_callback, data);
+      if (po == NULL)
+	return 0;
+    }
+
+  if (!elf_zlib_inflate_and_verify (compressed + 12, compressed_size - 12,
+				    zdebug_table, po, sz))
+    return 1;
+
+  *uncompressed = po;
+  *uncompressed_size = sz;
+
+  return 1;
+}
+
+/* Uncompress the new compressed debug format, the official standard
+   ELF approach emitted by --compress-debug-sections=zlib-gabi.  The
+   compressed data is in COMPRESSED / COMPRESSED_SIZE, and the
+   function writes to *UNCOMPRESSED / *UNCOMPRESSED_SIZE.
+   ZDEBUG_TABLE is work space as for elf_uncompress_zdebug.  Returns 0
+   on error, 1 on successful decompression or if something goes wrong.
+   In general we try to carry on, by returning 1, even if we can't
+   decompress.  */
+
+static int
+elf_uncompress_chdr (struct backtrace_state *state,
+		     const unsigned char *compressed, size_t compressed_size,
+		     uint16_t *zdebug_table,
+		     backtrace_error_callback error_callback, void *data,
+		     unsigned char **uncompressed, size_t *uncompressed_size)
+{
+  b_elf_chdr chdr;
+  char *alc;
+  size_t alc_len;
+  unsigned char *po;
+
+  *uncompressed = NULL;
+  *uncompressed_size = 0;
+
+  /* The format starts with an ELF compression header.  */
+  if (compressed_size < sizeof (b_elf_chdr))
+    return 1;
+
+  /* The lld linker can misalign a compressed section, so we can't safely read
+     the fields directly as we can for other ELF sections.  See
+     https://github.com/ianlancetaylor/libbacktrace/pull/120.  */
+  memcpy (&chdr, compressed, sizeof (b_elf_chdr));
+
+  alc = NULL;
+  alc_len = 0;
+  if (*uncompressed != NULL && *uncompressed_size >= chdr.ch_size)
+    po = *uncompressed;
+  else
+    {
+      alc_len = chdr.ch_size;
+      alc = backtrace_alloc (state, alc_len, error_callback, data);
+      if (alc == NULL)
+	return 0;
+      po = (unsigned char *) alc;
+    }
+
+  switch (chdr.ch_type)
+    {
+    case ELFCOMPRESS_ZLIB:
+      if (!elf_zlib_inflate_and_verify (compressed + sizeof (b_elf_chdr),
+					compressed_size - sizeof (b_elf_chdr),
+					zdebug_table, po, chdr.ch_size))
+	goto skip;
+      break;
+
+    case ELFCOMPRESS_ZSTD:
+      if (!elf_zstd_decompress (compressed + sizeof (b_elf_chdr),
+				compressed_size - sizeof (b_elf_chdr),
+				(unsigned char *)zdebug_table, po,
+				chdr.ch_size))
+	goto skip;
+      break;
+
+    default:
+      /* Unsupported compression algorithm.  */
+      goto skip;
+    }
+
+  *uncompressed = po;
+  *uncompressed_size = chdr.ch_size;
+
+  return 1;
+
+ skip:
+  if (alc != NULL && alc_len > 0)
+    backtrace_free (state, alc, alc_len, error_callback, data);
+  return 1;
+}
+
+/* This function is a hook for testing the zlib support.  It is only
+   used by tests.  */
+
+int
+backtrace_uncompress_zdebug (struct backtrace_state *state,
+			     const unsigned char *compressed,
+			     size_t compressed_size,
+			     backtrace_error_callback error_callback,
+			     void *data, unsigned char **uncompressed,
+			     size_t *uncompressed_size)
+{
+  uint16_t *zdebug_table;
+  int ret;
+
+  zdebug_table = ((uint16_t *) backtrace_alloc (state, ZDEBUG_TABLE_SIZE,
+						error_callback, data));
+  if (zdebug_table == NULL)
+    return 0;
+  ret = elf_uncompress_zdebug (state, compressed, compressed_size,
+			       zdebug_table, error_callback, data,
+			       uncompressed, uncompressed_size);
+  backtrace_free (state, zdebug_table, ZDEBUG_TABLE_SIZE,
+		  error_callback, data);
+  return ret;
+}
+
+/* This function is a hook for testing the zstd support.  It is only used by
+   tests.  */
+
+int
+backtrace_uncompress_zstd (struct backtrace_state *state,
+			   const unsigned char *compressed,
+			   size_t compressed_size,
+			   backtrace_error_callback error_callback,
+			   void *data, unsigned char *uncompressed,
+			   size_t uncompressed_size)
+{
+  unsigned char *zdebug_table;
+  int ret;
+
+  zdebug_table = ((unsigned char *) backtrace_alloc (state, ZDEBUG_TABLE_SIZE,
+						     error_callback, data));
+  if (zdebug_table == NULL)
+    return 0;
+  ret = elf_zstd_decompress (compressed, compressed_size,
+			     zdebug_table, uncompressed, uncompressed_size);
+  backtrace_free (state, zdebug_table, ZDEBUG_TABLE_SIZE,
+		  error_callback, data);
+  return ret;
+}
+
+/* Number of LZMA states.  */
+#define LZMA_STATES (12)
+
+/* Number of LZMA position states.  The pb value of the property byte
+   is the number of bits to include in these states, and the maximum
+   value of pb is 4.  */
+#define LZMA_POS_STATES (16)
+
+/* Number of LZMA distance states.  These are used match distances
+   with a short match length: up to 4 bytes.  */
+#define LZMA_DIST_STATES (4)
+
+/* Number of LZMA distance slots.  LZMA uses six bits to encode larger
+   match lengths, so 1 << 6 possible probabilities.  */
+#define LZMA_DIST_SLOTS (64)
+
+/* LZMA distances 0 to 3 are encoded directly, larger values use a
+   probability model.  */
+#define LZMA_DIST_MODEL_START (4)
+
+/* The LZMA probability model ends at 14.  */
+#define LZMA_DIST_MODEL_END (14)
+
+/* LZMA distance slots for distances less than 127.  */
+#define LZMA_FULL_DISTANCES (128)
+
+/* LZMA uses four alignment bits.  */
+#define LZMA_ALIGN_SIZE (16)
+
+/* LZMA match length is encoded with 4, 5, or 10 bits, some of which
+   are already known.  */
+#define LZMA_LEN_LOW_SYMBOLS (8)
+#define LZMA_LEN_MID_SYMBOLS (8)
+#define LZMA_LEN_HIGH_SYMBOLS (256)
+
+/* LZMA literal encoding.  */
+#define LZMA_LITERAL_CODERS_MAX (16)
+#define LZMA_LITERAL_CODER_SIZE (0x300)
+
+/* LZMA is based on a large set of probabilities, each managed
+   independently.  Each probability is an 11 bit number that we store
+   in a uint16_t.  We use a single large array of probabilities.  */
+
+/* Lengths of entries in the LZMA probabilities array.  The names used
+   here are copied from the Linux kernel implementation.  */
+
+#define LZMA_PROB_IS_MATCH_LEN (LZMA_STATES * LZMA_POS_STATES)
 #define LZMA_PROB_IS_REP_LEN LZMA_STATES
 #define LZMA_PROB_IS_REP0_LEN LZMA_STATES
 #define LZMA_PROB_IS_REP1_LEN LZMA_STATES
@@ -3051,6 +5571,7 @@ elf_uncompress_lzma_block (const unsigned char *compressed,
   uint64_t header_compressed_size;
   uint64_t header_uncompressed_size;
   unsigned char lzma2_properties;
+  size_t crc_offset;
   uint32_t computed_crc;
   uint32_t stream_crc;
   size_t uncompressed_offset;
@@ -3154,19 +5675,20 @@ elf_uncompress_lzma_block (const unsigned char *compressed,
   /* The properties describe the dictionary size, but we don't care
      what that is.  */
 
-  /* Block header padding.  */
-  if (unlikely (off + 4 > compressed_size))
+  /* Skip to just before CRC, verifying zero bytes in between.  */
+  crc_offset = block_header_offset + block_header_size - 4;
+  if (unlikely (crc_offset + 4 > compressed_size))
     {
       elf_uncompress_failed ();
       return 0;
     }
-
-  off = (off + 3) &~ (size_t) 3;
-
-  if (unlikely (off + 4 > compressed_size))
+  for (; off < crc_offset; off++)
     {
-      elf_uncompress_failed ();
-      return 0;
+      if (compressed[off] != 0)
+	{
+	  elf_uncompress_failed ();
+	  return 0;
+	}
     }
 
   /* Block header CRC.  */
@@ -3984,8 +6506,9 @@ backtrace_uncompress_lzma (struct backtrace_state *state,
 static int
 elf_add (struct backtrace_state *state, const char *filename, int descriptor,
 	 const unsigned char *memory, size_t memory_size,
-	 uintptr_t base_address, backtrace_error_callback error_callback,
-	 void *data, fileline *fileline_fn, int *found_sym, int *found_dwarf,
+	 uintptr_t base_address, struct elf_ppc64_opd_data *caller_opd,
+	 backtrace_error_callback error_callback, void *data,
+	 fileline *fileline_fn, int *found_sym, int *found_dwarf,
 	 struct dwarf_data **fileline_entry, int exe, int debuginfo,
 	 const char *with_buildid_data, uint32_t with_buildid_size)
 {
@@ -4040,6 +6563,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
   struct elf_view split_debug_view[DEBUG_MAX];
   unsigned char split_debug_view_valid[DEBUG_MAX];
   struct elf_ppc64_opd_data opd_data, *opd;
+  int opd_view_valid;
   struct dwarf_sections dwarf_sections;
 
   if (!debuginfo)
@@ -4067,6 +6591,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
   debug_view_valid = 0;
   memset (&split_debug_view_valid[0], 0, sizeof split_debug_view_valid);
   opd = NULL;
+  opd_view_valid = 0;
 
   if (!elf_get_view (state, descriptor, memory, memory_size, 0, sizeof ehdr,
 		     error_callback, data, &ehdr_view))
@@ -4350,12 +6875,18 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
 	  opd->addr = shdr->sh_addr;
 	  opd->data = (const char *) opd_data.view.view.data;
 	  opd->size = shdr->sh_size;
+	  opd_view_valid = 1;
 	}
     }
 
+  /* A debuginfo file may not have a useful .opd section, but we can use the
+     one from the original executable.  */
+  if (opd == NULL)
+    opd = caller_opd;
+
   if (symtab_shndx == 0)
     symtab_shndx = dynsym_shndx;
-  if (symtab_shndx != 0 && !debuginfo)
+  if (symtab_shndx != 0)
     {
       const b_elf_shdr *symtab_shdr;
       unsigned int strtab_shndx;
@@ -4431,9 +6962,9 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
 	    elf_release_view (state, &debuglink_view, error_callback, data);
 	  if (debugaltlink_view_valid)
 	    elf_release_view (state, &debugaltlink_view, error_callback, data);
-	  ret = elf_add (state, "", d, NULL, 0, base_address, error_callback,
-			 data, fileline_fn, found_sym, found_dwarf, NULL, 0,
-			 1, NULL, 0);
+	  ret = elf_add (state, "", d, NULL, 0, base_address, opd,
+			 error_callback, data, fileline_fn, found_sym,
+			 found_dwarf, NULL, 0, 1, NULL, 0);
 	  if (ret < 0)
 	    backtrace_close (d, error_callback, data);
 	  else if (descriptor >= 0)
@@ -4448,12 +6979,6 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
       buildid_view_valid = 0;
     }
 
-  if (opd)
-    {
-      elf_release_view (state, &opd->view, error_callback, data);
-      opd = NULL;
-    }
-
   if (debuglink_name != NULL)
     {
       int d;
@@ -4468,9 +6993,9 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
 	  elf_release_view (state, &debuglink_view, error_callback, data);
 	  if (debugaltlink_view_valid)
 	    elf_release_view (state, &debugaltlink_view, error_callback, data);
-	  ret = elf_add (state, "", d, NULL, 0, base_address, error_callback,
-			 data, fileline_fn, found_sym, found_dwarf, NULL, 0,
-			 1, NULL, 0);
+	  ret = elf_add (state, "", d, NULL, 0, base_address, opd,
+			 error_callback, data, fileline_fn, found_sym,
+			 found_dwarf, NULL, 0, 1, NULL, 0);
 	  if (ret < 0)
 	    backtrace_close (d, error_callback, data);
 	  else if (descriptor >= 0)
@@ -4496,7 +7021,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
 	{
 	  int ret;
 
-	  ret = elf_add (state, filename, d, NULL, 0, base_address,
+	  ret = elf_add (state, filename, d, NULL, 0, base_address, opd,
 			 error_callback, data, fileline_fn, found_sym,
 			 found_dwarf, &fileline_altlink, 0, 1,
 			 debugaltlink_buildid_data, debugaltlink_buildid_size);
@@ -4533,7 +7058,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
       if (ret)
 	{
 	  ret = elf_add (state, filename, -1, gnu_debugdata_uncompressed,
-			 gnu_debugdata_uncompressed_size, base_address,
+			 gnu_debugdata_uncompressed_size, base_address, opd,
 			 error_callback, data, fileline_fn, found_sym,
 			 found_dwarf, NULL, 0, 0, NULL, 0);
 	  if (ret >= 0 && descriptor >= 0)
@@ -4542,6 +7067,13 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
 	}
     }
 
+  if (opd_view_valid)
+    {
+      elf_release_view (state, &opd->view, error_callback, data);
+      opd_view_valid = 0;
+      opd = NULL;
+    }
+
   /* Read all the debug sections in a single view, since they are
      probably adjacent in the file.  If any of sections are
      uncompressed, we never release this view.  */
@@ -4666,7 +7198,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
 	  if (zdebug_table == NULL)
 	    {
 	      zdebug_table = ((uint16_t *)
-			      backtrace_alloc (state, ZDEBUG_TABLE_SIZE,
+			      backtrace_alloc (state, ZLIB_TABLE_SIZE,
 					       error_callback, data));
 	      if (zdebug_table == NULL)
 		goto fail;
@@ -4692,8 +7224,15 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
 	}
     }
 
+  if (zdebug_table != NULL)
+    {
+      backtrace_free (state, zdebug_table, ZLIB_TABLE_SIZE,
+		      error_callback, data);
+      zdebug_table = NULL;
+    }
+
   /* Uncompress the official ELF format
-     (--compress-debug-sections=zlib-gabi).  */
+     (--compress-debug-sections=zlib-gabi, --compress-debug-sections=zstd).  */
   for (i = 0; i < (int) DEBUG_MAX; ++i)
     {
       unsigned char *uncompressed_data;
@@ -4781,7 +7320,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
       if (split_debug_view_valid[i])
 	elf_release_view (state, &split_debug_view[i], error_callback, data);
     }
-  if (opd)
+  if (opd_view_valid)
     elf_release_view (state, &opd->view, error_callback, data);
   if (descriptor >= 0)
     backtrace_close (descriptor, error_callback, data);
@@ -4845,7 +7384,7 @@ phdr_callback (struct dl_phdr_info *info, size_t size ATTRIBUTE_UNUSED,
 	return 0;
     }
 
-  if (elf_add (pd->state, filename, descriptor, NULL, 0, info->dlpi_addr,
+  if (elf_add (pd->state, filename, descriptor, NULL, 0, info->dlpi_addr, NULL,
 	       pd->error_callback, pd->data, &elf_fileline_fn, pd->found_sym,
 	       &found_dwarf, NULL, 0, 0, NULL, 0))
     {
@@ -4874,9 +7413,9 @@ backtrace_initialize (struct backtrace_state *state, const char *filename,
   fileline elf_fileline_fn = elf_nodebug;
   struct phdr_data pd;
 
-  ret = elf_add (state, filename, descriptor, NULL, 0, 0, error_callback, data,
-		 &elf_fileline_fn, &found_sym, &found_dwarf, NULL, 1, 0, NULL,
-		 0);
+  ret = elf_add (state, filename, descriptor, NULL, 0, 0, NULL, error_callback,
+		 data, &elf_fileline_fn, &found_sym, &found_dwarf, NULL, 1, 0,
+		 NULL, 0);
   if (!ret)
     return 0;
 
diff --git a/libbacktrace/fileline.c b/libbacktrace/fileline.c
index 0472f4721ab..68e80c6d274 100644
--- a/libbacktrace/fileline.c
+++ b/libbacktrace/fileline.c
@@ -1,5 +1,5 @@
 /* fileline.c -- Get file and line number information in a backtrace.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,18 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include <mach-o/dyld.h>
 #endif
 
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_MEAN_AND_LEAN
+#define WIN32_MEAN_AND_LEAN
+#endif
+
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+
+#include <windows.h>
+#endif
+
 #include "backtrace.h"
 #include "internal.h"
 
@@ -155,6 +167,47 @@ macho_get_executable_path (struct backtrace_state *state,
 
 #endif /* !defined (HAVE_MACH_O_DYLD_H) */
 
+#if HAVE_DECL__PGMPTR
+
+#define windows_executable_filename() _pgmptr
+
+#else /* !HAVE_DECL__PGMPTR */
+
+#define windows_executable_filename() NULL
+
+#endif /* !HAVE_DECL__PGMPTR */
+
+#ifdef HAVE_WINDOWS_H
+
+#define FILENAME_BUF_SIZE (MAX_PATH)
+
+static char *
+windows_get_executable_path (char *buf, backtrace_error_callback error_callback,
+			     void *data)
+{
+  size_t got;
+  int error;
+
+  got = GetModuleFileNameA (NULL, buf, FILENAME_BUF_SIZE - 1);
+  error = GetLastError ();
+  if (got == 0
+      || (got == FILENAME_BUF_SIZE - 1 && error == ERROR_INSUFFICIENT_BUFFER))
+    {
+      error_callback (data,
+		      "could not get the filename of the current executable",
+		      error);
+      return NULL;
+    }
+  return buf;
+}
+
+#else /* !defined (HAVE_WINDOWS_H) */
+
+#define windows_get_executable_path(buf, error_callback, data) NULL
+#define FILENAME_BUF_SIZE 64
+
+#endif /* !defined (HAVE_WINDOWS_H) */
+
 /* Initialize the fileline information from the executable.  Returns 1
    on success, 0 on failure.  */
 
@@ -168,7 +221,7 @@ fileline_initialize (struct backtrace_state *state,
   int called_error_callback;
   int descriptor;
   const char *filename;
-  char buf[64];
+  char buf[FILENAME_BUF_SIZE];
 
   if (!state->threaded)
     failed = state->fileline_initialization_failed;
@@ -192,7 +245,7 @@ fileline_initialize (struct backtrace_state *state,
 
   descriptor = -1;
   called_error_callback = 0;
-  for (pass = 0; pass < 8; ++pass)
+  for (pass = 0; pass < 10; ++pass)
     {
       int does_not_exist;
 
@@ -205,25 +258,33 @@ fileline_initialize (struct backtrace_state *state,
 	  filename = getexecname ();
 	  break;
 	case 2:
-	  filename = "/proc/self/exe";
+	  /* Test this before /proc/self/exe, as the latter exists but points
+	     to the wine binary (and thus doesn't work).  */
+	  filename = windows_executable_filename ();
 	  break;
 	case 3:
-	  filename = "/proc/curproc/file";
+	  filename = "/proc/self/exe";
 	  break;
 	case 4:
+	  filename = "/proc/curproc/file";
+	  break;
+	case 5:
 	  snprintf (buf, sizeof (buf), "/proc/%ld/object/a.out",
 		    (long) getpid ());
 	  filename = buf;
 	  break;
-	case 5:
+	case 6:
 	  filename = sysctl_exec_name1 (state, error_callback, data);
 	  break;
-	case 6:
+	case 7:
 	  filename = sysctl_exec_name2 (state, error_callback, data);
 	  break;
-	case 7:
+	case 8:
 	  filename = macho_get_executable_path (state, error_callback, data);
 	  break;
+	case 9:
+	  filename = windows_get_executable_path (buf, error_callback, data);
+	  break;
 	default:
 	  abort ();
 	}
diff --git a/libbacktrace/install-debuginfo-for-buildid.sh.in b/libbacktrace/install-debuginfo-for-buildid.sh.in
index 91dfdfe89a4..0b83a366023 100644
--- a/libbacktrace/install-debuginfo-for-buildid.sh.in
+++ b/libbacktrace/install-debuginfo-for-buildid.sh.in
@@ -2,7 +2,7 @@
 
 # install-debug-info-for-buildid.sh -- Helper script for libbacktrace library
 # testing.
-# Copyright (C) 2019-2021 Free Software Foundation, Inc.
+# Copyright (C) 2019-2024 Free Software Foundation, Inc.
 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
diff --git a/libbacktrace/instrumented_alloc.c b/libbacktrace/instrumented_alloc.c
index 13af81a6dcb..4a520bf8770 100644
--- a/libbacktrace/instrumented_alloc.c
+++ b/libbacktrace/instrumented_alloc.c
@@ -1,6 +1,6 @@
 /* instrumented_alloc.c -- Memory allocation instrumented to fail when
    requested, for testing purposes.
-   Copyright (C) 2018-2021 Free Software Foundation, Inc.
+   Copyright (C) 2018-2024 Free Software Foundation, Inc.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
diff --git a/libbacktrace/internal.h b/libbacktrace/internal.h
index bb481f373bf..4fa0af8cb6c 100644
--- a/libbacktrace/internal.h
+++ b/libbacktrace/internal.h
@@ -1,5 +1,5 @@
 /* internal.h -- Internal header file for stack backtrace library.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
@@ -368,6 +368,15 @@ extern int backtrace_uncompress_zdebug (struct backtrace_state *,
 					unsigned char **uncompressed,
 					size_t *uncompressed_size);
 
+/* A test-only hook for elf_zstd_decompress.  */
+
+extern int backtrace_uncompress_zstd (struct backtrace_state *,
+				      const unsigned char *compressed,
+				      size_t compressed_size,
+				      backtrace_error_callback, void *data,
+				      unsigned char *uncompressed,
+				      size_t uncompressed_size);
+
 /* A test-only hook for elf_uncompress_lzma.  */
 
 extern int backtrace_uncompress_lzma (struct backtrace_state *,
diff --git a/libbacktrace/macho.c b/libbacktrace/macho.c
index 66e101e0a4b..b4856346ccc 100644
--- a/libbacktrace/macho.c
+++ b/libbacktrace/macho.c
@@ -1,5 +1,5 @@
 /* elf.c -- Get debug data from a Mach-O file for backtraces.
-   Copyright (C) 2020-2021 Free Software Foundation, Inc.
+   Copyright (C) 2020-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
@@ -1268,7 +1268,7 @@ backtrace_initialize (struct backtrace_state *state, const char *filename,
       mff = macho_nodebug;
       if (!macho_add (state, name, d, 0, NULL, base_address, 0,
 		      error_callback, data, &mff, &mfs))
-	return 0;
+	continue;
 
       if (mff != macho_nodebug)
 	macho_fileline_fn = mff;
diff --git a/libbacktrace/mmap.c b/libbacktrace/mmap.c
index d7313be73f7..322ed945669 100644
--- a/libbacktrace/mmap.c
+++ b/libbacktrace/mmap.c
@@ -1,5 +1,5 @@
 /* mmap.c -- Memory allocation with mmap.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/mmapio.c b/libbacktrace/mmapio.c
index 7f6fa8d2748..b780c3d07df 100644
--- a/libbacktrace/mmapio.c
+++ b/libbacktrace/mmapio.c
@@ -1,5 +1,5 @@
 /* mmapio.c -- File views using mmap.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/mtest.c b/libbacktrace/mtest.c
index 7e0189a2899..9afe7089514 100644
--- a/libbacktrace/mtest.c
+++ b/libbacktrace/mtest.c
@@ -1,5 +1,5 @@
 /* mtest.c -- Minidebug test for libbacktrace library
-   Copyright (C) 2020-2021 Free Software Foundation, Inc.
+   Copyright (C) 2020-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/nounwind.c b/libbacktrace/nounwind.c
index 0eea7139b69..ba1b06b6241 100644
--- a/libbacktrace/nounwind.c
+++ b/libbacktrace/nounwind.c
@@ -1,5 +1,5 @@
 /* backtrace.c -- Entry point for stack backtrace library.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/pecoff.c b/libbacktrace/pecoff.c
index 720251900b4..9e437d810c7 100644
--- a/libbacktrace/pecoff.c
+++ b/libbacktrace/pecoff.c
@@ -1,5 +1,5 @@
 /* pecoff.c -- Get debug data from a PE/COFFF file for backtraces.
-   Copyright (C) 2015-2021 Free Software Foundation, Inc.
+   Copyright (C) 2015-2024 Free Software Foundation, Inc.
    Adapted from elf.c by Tristan Gingold, AdaCore.
 
 Redistribution and use in source and binary forms, with or without
@@ -39,6 +39,18 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include "backtrace.h"
 #include "internal.h"
 
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_MEAN_AND_LEAN
+#define WIN32_MEAN_AND_LEAN
+#endif
+
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+
+#include <windows.h>
+#endif
+
 /* Coff file header.  */
 
 typedef struct {
@@ -610,6 +622,7 @@ coff_add (struct backtrace_state *state, int descriptor,
   int debug_view_valid;
   int is_64;
   uintptr_t image_base;
+  uintptr_t base_address = 0;
   struct dwarf_sections dwarf_sections;
 
   *found_sym = 0;
@@ -856,7 +869,16 @@ coff_add (struct backtrace_state *state, int descriptor,
 				  + (sections[i].offset - min_offset));
     }
 
-  if (!backtrace_dwarf_add (state, /* base_address */ 0, &dwarf_sections,
+#ifdef HAVE_WINDOWS_H
+  {
+    uintptr_t module_handle;
+
+    module_handle = (uintptr_t) GetModuleHandle (NULL);
+    base_address = module_handle - image_base;
+  }
+#endif
+
+  if (!backtrace_dwarf_add (state, base_address, &dwarf_sections,
 			    0, /* FIXME: is_bigendian */
 			    NULL, /* altlink */
 			    error_callback, data, fileline_fn,
diff --git a/libbacktrace/posix.c b/libbacktrace/posix.c
index 924631d2e61..79f4950f84b 100644
--- a/libbacktrace/posix.c
+++ b/libbacktrace/posix.c
@@ -1,5 +1,5 @@
 /* posix.c -- POSIX file I/O routines for the backtrace library.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/print.c b/libbacktrace/print.c
index 93d0d3abb49..3e61f02ebbc 100644
--- a/libbacktrace/print.c
+++ b/libbacktrace/print.c
@@ -1,5 +1,5 @@
 /* print.c -- Print the current backtrace.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/read.c b/libbacktrace/read.c
index 1811c8d2e08..7af66602fd9 100644
--- a/libbacktrace/read.c
+++ b/libbacktrace/read.c
@@ -1,5 +1,5 @@
 /* read.c -- File views without mmap.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/simple.c b/libbacktrace/simple.c
index 785e726e6be..fd3fac688fa 100644
--- a/libbacktrace/simple.c
+++ b/libbacktrace/simple.c
@@ -1,5 +1,5 @@
 /* simple.c -- The backtrace_simple function.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/sort.c b/libbacktrace/sort.c
index a60a980e65e..fedfe21cbdf 100644
--- a/libbacktrace/sort.c
+++ b/libbacktrace/sort.c
@@ -1,5 +1,5 @@
 /* sort.c -- Sort without allocating memory
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/state.c b/libbacktrace/state.c
index 0f368a23907..b564a18b548 100644
--- a/libbacktrace/state.c
+++ b/libbacktrace/state.c
@@ -1,5 +1,5 @@
 /* state.c -- Create the backtrace state.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/stest.c b/libbacktrace/stest.c
index 19a204de195..f695596aa29 100644
--- a/libbacktrace/stest.c
+++ b/libbacktrace/stest.c
@@ -1,5 +1,5 @@
 /* stest.c -- Test for libbacktrace internal sort function
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/test_format.c b/libbacktrace/test_format.c
index 9deb6f5b2a7..10bd24b9fc5 100644
--- a/libbacktrace/test_format.c
+++ b/libbacktrace/test_format.c
@@ -1,5 +1,5 @@
 /* test_format.c -- Test for libbacktrace library
-   Copyright (C) 2018-2021 Free Software Foundation, Inc.
+   Copyright (C) 2018-2024 Free Software Foundation, Inc.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
diff --git a/libbacktrace/testlib.c b/libbacktrace/testlib.c
index 3d24c19e702..a73984fb3e9 100644
--- a/libbacktrace/testlib.c
+++ b/libbacktrace/testlib.c
@@ -1,5 +1,5 @@
 /* testlib.c -- test functions for libbacktrace library
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/testlib.h b/libbacktrace/testlib.h
index 29542a5886d..f4759543d61 100644
--- a/libbacktrace/testlib.h
+++ b/libbacktrace/testlib.h
@@ -1,5 +1,5 @@
 /* testlib.h -- Header for test functions for libbacktrace library
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/ttest.c b/libbacktrace/ttest.c
index 3758b33f025..5401a2a9207 100644
--- a/libbacktrace/ttest.c
+++ b/libbacktrace/ttest.c
@@ -1,5 +1,5 @@
 /* ttest.c -- Test for libbacktrace library
-   Copyright (C) 2017-2021 Free Software Foundation, Inc.
+   Copyright (C) 2017-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/unittest.c b/libbacktrace/unittest.c
index 3c85623048a..2fd1c9b0fca 100644
--- a/libbacktrace/unittest.c
+++ b/libbacktrace/unittest.c
@@ -1,5 +1,5 @@
 /* unittest.c -- Test for libbacktrace library
-   Copyright (C) 2018-2021 Free Software Foundation, Inc.
+   Copyright (C) 2018-2024 Free Software Foundation, Inc.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
diff --git a/libbacktrace/unknown.c b/libbacktrace/unknown.c
index a62cbf11eb3..23e4cc95990 100644
--- a/libbacktrace/unknown.c
+++ b/libbacktrace/unknown.c
@@ -1,5 +1,5 @@
 /* unknown.c -- used when backtrace configury does not know file format.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/xcoff.c b/libbacktrace/xcoff.c
index 2ded8f0024f..e22f15dd5ce 100644
--- a/libbacktrace/xcoff.c
+++ b/libbacktrace/xcoff.c
@@ -1,5 +1,5 @@
 /* xcoff.c -- Get debug data from an XCOFF file for backtraces.
-   Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Copyright (C) 2012-2024 Free Software Foundation, Inc.
    Adapted from elf.c.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/xztest.c b/libbacktrace/xztest.c
index 6c60ff50159..5b3b811c38e 100644
--- a/libbacktrace/xztest.c
+++ b/libbacktrace/xztest.c
@@ -1,5 +1,5 @@
 /* xztest.c -- Test for libbacktrace LZMA decoder.
-   Copyright (C) 2020-2021 Free Software Foundation, Inc.
+   Copyright (C) 2020-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libbacktrace/ztest.c b/libbacktrace/ztest.c
index 4e79c09517d..02b83acb5b8 100644
--- a/libbacktrace/ztest.c
+++ b/libbacktrace/ztest.c
@@ -1,5 +1,5 @@
 /* ztest.c -- Test for libbacktrace inflate code.
-   Copyright (C) 2017-2021 Free Software Foundation, Inc.
+   Copyright (C) 2017-2024 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without
-- 
2.44.0


^ permalink raw reply	[relevance 2%]

* Re: [PATCH] gdb: Change "list ." command's error when no debuginfo is available
  @ 2024-03-11 10:55  0%     ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-03-11 10:55 UTC (permalink / raw)
  To: Guinevere Larsen, gdb-patches; +Cc: Simon Marchi

Guinevere Larsen <blarsen@redhat.com> writes:

> On 06/03/2024 14:18, Andrew Burgess wrote:
>> Guinevere Larsen <blarsen@redhat.com> writes:
>>
>>> From: Simon Marchi <simark@simark.ca>
>>>
>>> Currently, when a user tries to list the current location, there are 2
>>> different error messages that can happen, either:
>>>
>>>      (gdb) list .
>>>      No symbol table is loaded.  Use the "file" command.
>>> or
>>>      (gdb) list .
>>>      No debug information available to print source lines.
>>>
>>> The difference here is if gdb can find any symtabs at all or not, which
>>> is not a difference a user should concern themselves with.
>> Why not?
>>
>> Maybe "No symbol table is loaded" isn't the clearest, maybe "No debug
>> information is loaded" might be better, but the first message tells me
>> that there is no debug information, maybe GDB failed to find it, or
>> maybe I need to provide it.  The second tells me that GDB did find debug
>> information that covers this address, but it lacks the required detail
>> to help, maybe I forgot -g when compiling?
>
> The situation where I see the second message pops up is when we're, for 
> example, in the main function and there are symbols for libc. I may be 
> misunderstanding something, but I don't think that debug information 
> covers the address the inferior is in.
>
> The situation that we were specifically thinking about was that
>
>>
>> I'm not 100% against this change, I just don't find the motivation super
>> compelling.
>>
>>>                                                              This commit
>>> changes it so that the error is always:
>>>
>>>      (gdb) list .
>>>      No debug information available to print source lines at current PC (0x55555555511d).
>>> or
>>>      (gdb) list .
>>>      No debug information available to print source lines at default location.
>>>
>>> The difference now is if the inferior has started already, which is
>>> controlled by the user and may be useful.
>>>
>>> Unfortunately, it isn't as easy to differentiate if the symtab found for
>>> other list parameters is correct, so other invocations, such as "list +"
>>> still retain their original error message.
>>>
>>> Co-Authored-By: Simon Marchi <simark@simark.ca>
>>> ---
>>>   gdb/cli/cli-cmds.c | 48 ++++++++++++++++++++++++++++++++--------------
>> For sure this patch should have an associated test change.
> That's a good point... Do you know how I'd be able to get a test running 
> with no symbols whatsoever, even if the system that is doing the testing 
> has libc symbols?

Could you compile a test binary statically, and then strip all debug
information from it?  Would that do what you need?

Thanks,
Andrew



>
> -- 
> Cheers,
> Guinevere Larsen
> She/Her/Hers
>
>>
>> Thanks,
>> Andrew
>>
>>>   1 file changed, 34 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
>>> index df11f956245..31f0b6d9907 100644
>>> --- a/gdb/cli/cli-cmds.c
>>> +++ b/gdb/cli/cli-cmds.c
>>> @@ -1236,37 +1236,39 @@ list_command (const char *arg, int from_tty)
>>>     /* Pull in the current default source line if necessary.  */
>>>     if (arg == NULL || ((arg[0] == '+' || arg[0] == '-' || arg[0] == '.') && arg[1] == '\0'))
>>>       {
>>> -      set_default_source_symtab_and_line ();
>>> -      symtab_and_line cursal = get_current_source_symtab_and_line ();
>>> -
>>>         /* If this is the first "list" since we've set the current
>>>   	 source line, center the listing around that line.  */
>>>         if (get_first_line_listed () == 0 && (arg == nullptr || arg[0] != '.'))
>>>   	{
>>> -	  list_around_line (arg, cursal);
>>> +	  set_default_source_symtab_and_line ();
>>> +	  list_around_line (arg, get_current_source_symtab_and_line ());
>>>   	}
>>>   
>>>         /* "l" and "l +" lists the next few lines, unless we're listing past
>>>   	 the end of the file.  */
>>>         else if (arg == nullptr || arg[0] == '+')
>>>   	{
>>> +	  set_default_source_symtab_and_line ();
>>> +	  const symtab_and_line cursal = get_current_source_symtab_and_line ();
>>>   	  if (last_symtab_line (cursal.symtab) >= cursal.line)
>>>   	    print_source_lines (cursal.symtab,
>>>   				source_lines_range (cursal.line), 0);
>>>   	  else
>>> -	    {
>>> -	      error (_("End of the file was already reached, use \"list .\" to"
>>> -		       " list the current location again"));
>>> -	    }
>>> +	    error (_("End of the file was already reached, use \"list .\" to"
>>> +		     " list the current location again"));
>>>   	}
>>>   
>>>         /* "l -" lists previous ten lines, the ones before the ten just
>>>   	 listed.  */
>>>         else if (arg[0] == '-')
>>>   	{
>>> +	  set_default_source_symtab_and_line ();
>>> +	  const symtab_and_line cursal = get_current_source_symtab_and_line ();
>>> +
>>>   	  if (get_first_line_listed () == 1)
>>>   	    error (_("Already at the start of %s."),
>>>   		   symtab_to_filename_for_display (cursal.symtab));
>>> +
>>>   	  source_lines_range range (get_first_line_listed (),
>>>   				    source_lines_range::BACKWARD);
>>>   	  print_source_lines (cursal.symtab, range, 0);
>>> @@ -1275,25 +1277,43 @@ list_command (const char *arg, int from_tty)
>>>         /* "list ." lists the default location again.  */
>>>         else if (arg[0] == '.')
>>>   	{
>>> +	  std::optional<const symtab_and_line> cursal;
>>>   	  if (target_has_stack ())
>>>   	    {
>>>   	      /* Find the current line by getting the PC of the currently
>>>   		 selected frame, and finding the line associated to it.  */
>>>   	      frame_info_ptr frame = get_selected_frame (nullptr);
>>>   	      CORE_ADDR curr_pc = get_frame_pc (frame);
>>> -	      cursal = find_pc_line (curr_pc, 0);
>>> +	      cursal.emplace (find_pc_line (curr_pc, 0));
>>> +
>>> +	      if (cursal->symtab == nullptr)
>>> +		error
>>> +		  (_("No debug information available to print source lines at "
>>> +		     "current PC (%s)."), paddress (get_frame_arch (frame),
>>> +						    curr_pc));
>>>   	    }
>>>   	  else
>>>   	    {
>>>   	      /* The inferior is not running, so reset the current source
>>>   		 location to the default (usually the main function).  */
>>>   	      clear_current_source_symtab_and_line ();
>>> -	      set_default_source_symtab_and_line ();
>>> -	      cursal = get_current_source_symtab_and_line ();
>>> +	      try
>>> +		{
>>> +		  set_default_source_symtab_and_line ();
>>> +		}
>>> +	      catch (const gdb_exception &e)
>>> +		{
>>> +		  error (_("No debug information available to print source "
>>> +			   "lines at default location"));
>>> +		}
>>> +	      cursal.emplace (get_current_source_symtab_and_line ());
>>> +
>>> +	      // Not sure if always true, just guessing.
>>> +	      gdb_assert (cursal->symtab != nullptr);
>>>   	    }
>>> -	  if (cursal.symtab == nullptr)
>>> -	    error (_("No debug information available to print source lines."));
>>> -	  list_around_line (arg, cursal);
>>> +
>>> +	  list_around_line (arg, *cursal);
>>> +
>>>   	  /* Set the repeat args so just pressing "enter" after using "list ."
>>>   	     will print the following lines instead of the same lines again. */
>>>   	  if (from_tty)
>>> -- 
>>> 2.43.0


^ permalink raw reply	[relevance 0%]

* Re: [PATCH] gdb, btrace: fix error diagnostics
  @ 2024-03-08  9:07  0% ` Guinevere Larsen
  0 siblings, 0 replies; 200+ results
From: Guinevere Larsen @ 2024-03-08  9:07 UTC (permalink / raw)
  To: Markus Metzger, gdb-patches

On 07/03/2024 16:01, Markus Metzger wrote:
> When we improved error messages in
>
>      cd393cec3ab gdb, btrace: improve error messages
>
> we cleared the original errno.  When the error reason can not be explained
> in a more detailed error message, and we fall back to the default error
> message, it now gives Success as error.
>
> Restore the original errno to fix that.

Hi!

LGTM, Reviewed-By: Guinevere Larsen <blarsen@redhat.com>

-- 
Cheers,
Guinevere Larsen
She/Her/Hers

> ---
>   gdb/nat/linux-btrace.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
> index 50de2415589..f8352b62b8b 100644
> --- a/gdb/nat/linux-btrace.c
> +++ b/gdb/nat/linux-btrace.c
> @@ -422,7 +422,8 @@ cpu_supports_bts (void)
>   static void
>   diagnose_perf_event_open_fail ()
>   {
> -  switch (errno)
> +  int orig_errno = errno;
> +  switch (orig_errno)
>       {
>       case EPERM:
>       case EACCES:
> @@ -443,7 +444,7 @@ diagnose_perf_event_open_fail ()
>         break;
>       }
>   
> -  error (_("Failed to start recording: %s"), safe_strerror (errno));
> +  error (_("Failed to start recording: %s"), safe_strerror (orig_errno));
>   }
>   
>   /* Get the linux version of a btrace_target_info.  */



^ permalink raw reply	[relevance 0%]

* [PATCH 4/6] gdb, btrace: set wait status to ignore if nothing is moving
  @ 2024-03-07 13:28  5% ` Markus Metzger
  0 siblings, 0 replies; 200+ results
From: Markus Metzger @ 2024-03-07 13:28 UTC (permalink / raw)
  To: gdb-patches

When record_btrace::wait() is called and no threads are moving, we set the
wait status to no_resumed.  Change that to ignore.

This helps with enabling per-inferior run-control for the record btrace
target as it avoids breaking out of do_target_wait() too early with
no_resumed when there would have been an event on another thread.
---
 gdb/record-btrace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 9f2999268d8..8b20ab53ca7 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -2280,14 +2280,14 @@ btrace_step_spurious (void)
   return status;
 }
 
-/* Return a target_waitstatus indicating that the thread was not resumed.  */
+/* Return a target_waitstatus indicating that nothing is moving.  */
 
 static struct target_waitstatus
-btrace_step_no_resumed (void)
+btrace_step_no_moving_threads (void)
 {
   struct target_waitstatus status;
 
-  status.set_no_resumed ();
+  status.set_ignore ();
 
   return status;
 }
@@ -2556,7 +2556,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
 
   if (moving.empty ())
     {
-      *status = btrace_step_no_resumed ();
+      *status = btrace_step_no_moving_threads ();
 
       DEBUG ("wait ended by %s: %s", null_ptid.to_string ().c_str (),
 	     status->to_string ().c_str ());
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 5%]

* Re: [External] : Re: [PATCH v3] gdb : Signal to pstack/gdb kills the attached process.
  @ 2024-03-07  8:41  0%                     ` Partha Satapathy
  0 siblings, 0 replies; 200+ results
From: Partha Satapathy @ 2024-03-07  8:41 UTC (permalink / raw)
  To: Guinevere Larsen, gdb-patches, bert.barbe, rajesh.sivaramasubramaniom

On 3/5/2024 2:17 PM, Guinevere Larsen wrote:
> On 19/02/2024 06:10, Partha Satapathy wrote:
>> On 1/24/2024 8:49 PM, Partha Satapathy wrote:
>>> On 1/10/2024 9:29 PM, Partha Satapathy wrote:
>>>> On 12/5/2023 6:43 PM, Guinevere Larsen wrote:
>>>>> On 17/11/2023 15:48, Partha Satapathy wrote:
>>>>>> On 11/6/2023 7:08 PM, Guinevere Larsen wrote:
>>>>>>> On 02/11/2023 19:27, Partha Satapathy wrote:
>>>>>>>> On 11/2/2023 11:54 PM, Partha Satapathy wrote:
>>>>>>>>> On 10/25/2023 9:24 PM, Guinevere Larsen wrote:
>>>>>>>>>> Hi!
>>>>>>>>>>
>>>>>>>>>> Thanks for working on this issue, and sorry about the delay in 
>>>>>>>>>> getting this reviewed. For future reference, we (at least I) 
>>>>>>>>>> tend to try and go for patches with many pings, so it is 
>>>>>>>>>> better to ping existing patches than re-sending them :)
>>>>>>>>>
>>>>>>>>> I some how missed this mail, hence a delay in reply.
>>>>>>>>> I sorry for this and unfortunately have made the mistake once 
>>>>>>>>> again.
>>>>>>>>> Hope the extra threads can be deleted and I will keep my 
>>>>>>>>> discussion bound to this thread.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I'm not very knowledgeable on how GDB does signal handling, so 
>>>>>>>>>> I'm going to review this patch at face value. I hope someone 
>>>>>>>>>> who does know how this part works gets a look at this soon!
>>>>>>>>>>
>>>>>>>>>> On 16/10/2023 11:28, Partha Satapathy wrote:
>>>>>>>>>>> Problem :
>>>>>>>>>>> While gdb attaching a target, If ctrl-c pressed in the midst 
>>>>>>>>>>> of the process attach,  the sigint is passed to the debugged 
>>>>>>>>>>> process. This triggers exit of the debugged.
>>>>>>>>>>>
>>>>>>>>>>> Let’s take the example of pstack,  which dumps the stack of 
>>>>>>>>>>> all threads in a process. In some cases printing of stack can 
>>>>>>>>>>> take significant time and ctrl-c is pressed to abort 
>>>>>>>>>>> pstack/gdb application. This in turn kills the debugged 
>>>>>>>>>>> process, which can be critical for the system. In this case 
>>>>>>>>>>> the intention of “ctrl+c” to kill pstack/gdb, but not the 
>>>>>>>>>>> target application.
>>>>>>>>>>>
>>>>>>>>>>> Reproduction:
>>>>>>>>>>>
>>>>>>>>>>> The debugged application generally attached to process by:
>>>>>>>>>>> gdb -p <<pid>>
>>>>>>>>>>> or gdb /proc/<<pid>>/exe pid
>>>>>>>>>>> pstack uses the latter  method to attach the debugged to gdb. 
>>>>>>>>>>> If the application is large or process of reading symbols is 
>>>>>>>>>>> slow, gives a good window to press the ctrl+c during attach. 
>>>>>>>>>>> Spawning "gdb" under "strace -k" makes gdb a lot slower and 
>>>>>>>>>>> gives a larger window to easily press the
>>>>>>>>>>> ctrl+c at the precise period i.e. during the attach of the 
>>>>>>>>>>> debugged
>>>>>>>>>>> process. The above strace hack will enhance rate of 
>>>>>>>>>>> reproduction of the issue. Testcase:
>>>>>>>>>>>
>>>>>>>>>>> With GDB 13.1
>>>>>>>>>>> ps aux | grep abrtd
>>>>>>>>>>> root     2195168   /usr/sbin/abrtd -d -s
>>>>>>>>>>>
>>>>>>>>>>> #strace -k -o log gdb -p 2195168
>>>>>>>>>>> Attaching to process 2195168
>>>>>>>>>>> [New LWP 2195177]
>>>>>>>>>>> [New LWP 2195179]
>>>>>>>>>>> ^C[Thread debugging using libthread_db enabled]
>>>>>>>>>>> <<<<   Note the ctrl+c is pressed after attach is initiated 
>>>>>>>>>>> and it’s
>>>>>>>>>>> still reading the symbols from library >>>> Using host 
>>>>>>>>>>> libthread_db library "/lib64/libthread_db.so.1".
>>>>>>>>>>> 0x00007fe3ed6d70d1 in poll () from /lib64/libc.so.6
>>>>>>>>>>> (gdb) q
>>>>>>>>>>> A debugging session is active.
>>>>>>>>>>>           Inferior 1 [process 2195168] will be detached Quit 
>>>>>>>>>>> anyway? (y or n) y Detaching from program: /usr/sbin/abrtd, 
>>>>>>>>>>> process 2195168
>>>>>>>>>>>
>>>>>>>>>>> # ps aux | grep 2195168
>>>>>>>>>>> <<<< Process exited >>>>
>>>>>>>>>>>
>>>>>>>>>>> Description:
>>>>>>>>>>>
>>>>>>>>>>> We are installing a signal handler in gdb that marks the 
>>>>>>>>>>> Ctrl-c/sigint received by gdb. GDB passes this sigint to the 
>>>>>>>>>>> debugged at some definite points during the window of process 
>>>>>>>>>>> attach. The process of attaching debugged involves steps like 
>>>>>>>>>>> PTRACE_ATTACH , reading symbols, getting the stop signal from 
>>>>>>>>>>> the debugged and get ready with GDB prompt. Note:
>>>>>>>>>>> one of the example of this is sigint passing is:
>>>>>>>>>>> "     - installs a SIGINT handler that forwards SIGINT to the 
>>>>>>>>>>> inferior.
>>>>>>>>>>>          Otherwise a Ctrl-C pressed just while waiting for 
>>>>>>>>>>> the initial
>>>>>>>>>>>          stop would end up as a spurious Quit.
>>>>>>>>>>> "
>>>>>>>>>>>
>>>>>>>>>>> There are few other places where sigint is passed to the 
>>>>>>>>>>> debugged during attach of process to gdb. As the debugger and 
>>>>>>>>>>> debugged are not fully attached during this period, the 
>>>>>>>>>>> sigint takes its default action and terminates the process.
>>>>>>>>>>>
>>>>>>>>>>> Solution:
>>>>>>>>>>>
>>>>>>>>>>> While gdb attaches process, the target is not the current 
>>>>>>>>>>> session leader. Hence, until attach is complete and GDB 
>>>>>>>>>>> prompt is availed, the sigint should not be passed to the 
>>>>>>>>>>> debugged. A similar approach is taken for "gdb) run &". In 
>>>>>>>>>>> target_terminal::inferior()
>>>>>>>>>>>     /* A background resume (``run&'') should leave GDB in 
>>>>>>>>>>> control of the
>>>>>>>>>>>        terminal.  */
>>>>>>>>>>>     if (ui->prompt_state != PROMPT_BLOCKED)
>>>>>>>>>>>       return;
>>>>>>>>>>>
>>>>>>>>>>> The passing of signal is skipped if the process ran in 
>>>>>>>>>>> background. With this approach we can skip passing the sigint 
>>>>>>>>>>> if the process is attached to gdb and process attach is not 
>>>>>>>>>>> complete.
>>>>>>>>>>> Here is the proposed solution:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Fix :
>>>>>>>>>>>
>>>>>>>>>>> While gdb attaching a target, If ctrl-c/sigint pressed in the 
>>>>>>>>>>> midst of the process attach, the sigint is passed to the 
>>>>>>>>>>> debugged process.
>>>>>>>>>>> This triggers exit of the debugged.
>>>>>>>>>>>
>>>>>>>>>>> This issue is evident while getting the process stack with 
>>>>>>>>>>> ./gdb --quiet -nx  -ex 'set width 0' -ex 'set height 0'
>>>>>>>>>>> -ex 'set pagination no' -ex 'set confirm off'
>>>>>>>>>>> -ex 'thread apply all bt' -ex quit /proc/<PID>/exe <PID> and 
>>>>>>>>>>> press the ctrl+c while attach.
>>>>>>>>>>>
>>>>>>>>>>> The above method is also used in pstack application which is 
>>>>>>>>>>> a wrapper over gdb to print the process stack. A Ctrl+C 
>>>>>>>>>>> intended to kill gdb or pstack, but kills the debugged even 
>>>>>>>>>>> if it is attached and not spawned by gdb.
>>>>>>>>>>
>>>>>>>>>> This is a very good description of the error you've 
>>>>>>>>>> encountered, but given the repetition on this "fix:" part, I'm 
>>>>>>>>>> wondering, what is meant to be the commit message? Is it just 
>>>>>>>>>> these last few lines, or is it the whole thing? If it is just 
>>>>>>>>>> this last bit, I think it would benefit from some more 
>>>>>>>>>> explanation of the solution. If it is the whole message, I 
>>>>>>>>>> think you can reduce a bit the repetition.
>>>>>>>>>>
>>>>>>>>>> Also, at many points you say "debugged process" and "target". 
>>>>>>>>>> In GDB-land we call that the "inferior". Target has a very 
>>>>>>>>>> specific meaning in the context of GDB (roughly the CPU you're 
>>>>>>>>>> running, and some extra bits here and there).
>>>>>>>>>>
>>>>>>>>>> I also have a few comments on the specific changes, that are 
>>>>>>>>>> inlined.
>>>>>>>>>>
>>>>>>>>>>> ---
>>>>>>>>>>>   gdb/inferior.h | 3 +++
>>>>>>>>>>>   gdb/target.c   | 4 ++++
>>>>>>>>>>>   gdb/top.c      | 2 ++
>>>>>>>>>>>   3 files changed, 9 insertions(+)
>>>>>>>>>>>
>>>>>>>>>>> diff --git a/gdb/inferior.h b/gdb/inferior.h index 
>>>>>>>>>>> 4d001b0ad50e..b7048d10bbe4 100644
>>>>>>>>>>> --- a/gdb/inferior.h
>>>>>>>>>>> +++ b/gdb/inferior.h
>>>>>>>>>>> @@ -557,6 +557,9 @@ class inferior : public refcounted_object,
>>>>>>>>>>>     /* True if this child process was attached rather than 
>>>>>>>>>>> forked.  */
>>>>>>>>>>>     bool attach_flag = false;
>>>>>>>>>>>
>>>>>>>>>>> +  /* True if target process synced and gdb ui is out of 
>>>>>>>>>>> block. */ bool
>>>>>>>>>>
>>>>>>>>>> This comment is oddly worded. Based on the change to 
>>>>>>>>>> gdb/top.c, I think you could reword it like this:
>>>>>>>>>>
>>>>>>>>>> /* True if inferior has been fully synced and the prompt is no 
>>>>>>>>>> longer blocked.  */
>>>>>>>>>>
>>>>>>>>>>> + sync_flag = false;
>>>>>>>>>> Typo here, the variable's type should be on this line.
>>>>>>>>>>> +
>>>>>>>>>>>     /* If this inferior is a vfork child, then this is the 
>>>>>>>>>>> pointer to
>>>>>>>>>>>        its vfork parent, if GDB is still attached to it.  */
>>>>>>>>>>>     inferior *vfork_parent = NULL;
>>>>>>>>>>> diff --git a/gdb/target.c b/gdb/target.c index 
>>>>>>>>>>> d5bfd7d0849b..f7c115497451 100644
>>>>>>>>>>> --- a/gdb/target.c
>>>>>>>>>>> +++ b/gdb/target.c
>>>>>>>>>>> @@ -3826,6 +3826,10 @@ target_pass_ctrlc (void)
>>>>>>>>>>>                   through the target_stack.  */
>>>>>>>>>>>                scoped_restore_current_inferior restore_inferior;
>>>>>>>>>>>                set_current_inferior (inf);
>>>>>>>>>>> +             if ((current_inferior()->attach_flag) &&
>>>>>>>>>>
>>>>>>>>>> A couple of style issues here: when the indentation would have 
>>>>>>>>>> 8 spaces, you should use a tab instead;
>>>>>>>>>>
>>>>>>>>>> There should be a space between the function name and the 
>>>>>>>>>> parameters;
>>>>>>>>>> And when you need to cut a logical expression in half, the 
>>>>>>>>>> operator should be at the start of a new line.
>>>>>>>>>>
>>>>>>>>>>> + !(current_inferior()->sync_flag)) {
>>>>>>>>>> In this case, since it is just one line, there is no need to 
>>>>>>>>>> have the curly braces. However, when they are needed, they 
>>>>>>>>>> should be on the following line, and 2 spaces further in 
>>>>>>>>>> indentation.
>>>>>>>>>>> + return;
>>>>>>>>>>> +             }
>>>>>>>>>>>                current_inferior ()->top_target ()->pass_ctrlc 
>>>>>>>>>>> ();
>>>>>>>>>>>                return;
>>>>>>>>>>>              }
>>>>>>>>>>> diff --git a/gdb/top.c b/gdb/top.c
>>>>>>>>>>> index 621aa6883233..26cc6caac0e5 100644
>>>>>>>>>>> --- a/gdb/top.c
>>>>>>>>>>> +++ b/gdb/top.c
>>>>>>>>>>> @@ -542,6 +542,8 @@ wait_sync_command_done (void)
>>>>>>>>>>>     while (gdb_do_one_event () >= 0)
>>>>>>>>>>>       if (ui->prompt_state != PROMPT_BLOCKED)
>>>>>>>>>>>         break;
>>>>>>>>>>> +
>>>>>>>>>>> +  current_inferior()->sync_flag = true;
>>>>>>>>>>
>>>>>>>>>> I'm not very knowledgeable on this part of GDB, so take this 
>>>>>>>>>> with a grain of salt, but I wonder if this is the best place 
>>>>>>>>>> to put this.
>>>>>>>>>>
>>>>>>>>>> Since you only set this flag as false when first creating the 
>>>>>>>>>> inferior structure, I don't see why it should be re-set every 
>>>>>>>>>> time we're waiting for a command to be done. You could set the 
>>>>>>>>>> sync flag to false every command, but that feels like 
>>>>>>>>>> overkill. I feel like there should be some a mechanism in GDB 
>>>>>>>>>> already that knows if we're the session leader or not, and 
>>>>>>>>>> thus handles things correctly, but I don't know what it is.
>>>>>>>>>>
>>>>>>>>>> Another possibility, based on the exact problem you had, is to 
>>>>>>>>>> put this at the end of either symbol expansions, or the 
>>>>>>>>>> reasons they are being expanded in the first place (which I 
>>>>>>>>>> suspect is something like trying to identify the language or 
>>>>>>>>>> name of the main function).
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> wait_sync_command_done() is not frequently called with command 
>>>>>>>>> execution.
>>>>>>>>> strace -k -o log ./gdb -p <<pid>>
>>>>>>>>> (gdb) ls
>>>>>>>>> Undefined command: "ls".  Try "help".
>>>>>>>>> (gdb) !ls
>>>>>>>>> (gdb) disassemble main
>>>>>>>>>
>>>>>>>>> confirmed the function wait_sync_command_done() is not part of 
>>>>>>>>> this trace. wait_sync_command_done() is called from 
>>>>>>>>> run_inferior_call()
>>>>>>>>> and serve as inferior startup and wait for it to stop.
>>>>>>>>>
>>>>>>>>> /* Subroutine of call_function_by_hand to simplify it.
>>>>>>>>>     Start up the inferior and wait for it to stop.
>>>>>>>>>     Return the exception if there's an error, or an exception with
>>>>>>>>>     reason >= 0 if there's no error.
>>>>>>>>>
>>>>>>>>>     This is done inside a TRY_CATCH so the caller needn't worry 
>>>>>>>>> about
>>>>>>>>>     thrown errors.  The caller should rethrow if there's an 
>>>>>>>>> error.  */
>>>>>>>>>
>>>>>>>>> static struct gdb_exception
>>>>>>>>> run_inferior_call (std::unique_ptr<call_thread_fsm> sm,
>>>>>>>>>                     struct thread_info *call_thread, CORE_ADDR 
>>>>>>>>> real_pc)
>>>>>>>>> {
>>>>>>>>>
>>>>>>>>>        /* Inferior function calls are always synchronous, even 
>>>>>>>>> if the
>>>>>>>>>           target supports asynchronous execution. */
>>>>>>>>>        wait_sync_command_done ();
>>>>>>>>>
>>>>>>>>> So wait_sync_command_done called once per inferior at startup.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Hi Guinevere,
>>>>>>>>>
>>>>>>>>> Thanks for the review and sorry for the delay in reply.
>>>>>>>>> Please find comments inline.
>>>>>>>>>
>>>>>>>>> I will send the V2 incorporating rest of the comment.
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>> Partha
>>>>>>>>
>>>>>>> Hi! Thanks for the updated version. It looks much better!
>>>>>>>
>>>>>>> However, I still cant apply the patch. Are you sure you're 
>>>>>>> developing on the master branch of our upstream repository? 
>>>>>>> (https://urldefense.com/v3/__https://sourceware.org/git/binutils-gdb.git__;!!ACWV5N9M2RV99hQ!N_X8-tLG80n66yoOg95U0435CrvbbnDiHbebshHmNxivPGKLL5ZTy2le27VURzCGpKU6zzBqP4Jtu3d5km1jRA$ )
>>>>>>>
>>>>>>> I have been manually changing the source code to test the patch, 
>>>>>>> but it should cleanly apply for other maintainer to have an 
>>>>>>> easier time reviewing things.
>>>>>>>
>>>>>>>>
>>>>>>>> Problem: While gdb is attaching an inferior, if ctrl-c is 
>>>>>>>> pressed in the
>>>>>>>> middle of the process attach,  the sigint is passed to the debugged
>>>>>>>> process. This triggers the exit of the inferior. For example in 
>>>>>>>> pstack,
>>>>>>>> printing a stack can take significant time, and ctrl-c is 
>>>>>>>> pressed to
>>>>>>>> abort the pstack/gdb application. This in turn kills the debugged
>>>>>>>> process, which can be critical for the system. In this case, the
>>>>>>>> intention of ctrl+c is to kill pstack/gdb, but not the inferior
>>>>>>>> application.
>>>>>>>> gdb -p <<pid>>
>>>>>>>> or gdb /proc/<<pid>>/exe pid
>>>>>>>> Attaching to process
>>>>>>>> << ctrl+c is pressed during attach
>>>>>>>> (gdb) q
>>>>>>>> <<<< inferior process exited >>>>
>>>>>>>>
>>>>>>>> A Ctrl-C/sigint received by gdb during the attachment of an 
>>>>>>>> inferior
>>>>>>>> passed to the debugged at some definite points during the window of
>>>>>>>> process attachment. The process of attaching an inferior is a 
>>>>>>>> multistep
>>>>>>>> process, and it takes time to get ready with the GDB prompt. As the
>>>>>>>> debugger and debugger are not fully attached during this period, 
>>>>>>>> the
>>>>>>>> sigint takes its default action to terminate the process.
>>>>>>>>
>>>>>>>> Solution: While GDB attaches processes, the inferior is not the 
>>>>>>>> current
>>>>>>>> session leader. Hence, until attach is complete and the GDB 
>>>>>>>> prompt is
>>>>>>>> available, the sigint should not be passed to the inferior.
>>>>>>>> The signal should be skipped if the process runs in the 
>>>>>>>> background. With
>>>>>>>> this approach, we can skip passing the signature if the process is
>>>>>>>> attached to the GDB and the process attach is not complete.
>>>>>>>> ---
>>>>>>>>  gdb/inferior.h | 3 +++
>>>>>>>>  gdb/target.c   | 4 ++++
>>>>>>>>  gdb/top.c      | 2 ++
>>>>>>>>  3 files changed, 9 insertions(+)
>>>>>>>>
>>>>>>>> diff --git a/gdb/inferior.h b/gdb/inferior.h
>>>>>>>> index 4d001b0ad50e..d5d01bd0d09c 100644
>>>>>>>> --- a/gdb/inferior.h
>>>>>>>> +++ b/gdb/inferior.h
>>>>>>>> @@ -557,6 +557,9 @@ class inferior : public refcounted_object,
>>>>>>>>    /* True if this child process was attached rather than 
>>>>>>>> forked. */
>>>>>>>>    bool attach_flag = false;
>>>>>>>>
>>>>>>>> +  /* True if inferior has been fully synced and prompt is no 
>>>>>>>> longer blocked.  */
>>>>>>>> +  bool sync_flag = false;
>>>>>>>> +
>>>>>>>>    /* If this inferior is a vfork child, then this is the 
>>>>>>>> pointer to
>>>>>>>>       its vfork parent, if GDB is still attached to it.  */
>>>>>>>>    inferior *vfork_parent = NULL;
>>>>>>>> diff --git a/gdb/target.c b/gdb/target.c
>>>>>>>> index d5bfd7d0849b..4eff3130bad7 100644
>>>>>>>> --- a/gdb/target.c
>>>>>>>> +++ b/gdb/target.c
>>>>>>>> @@ -3826,6 +3826,10 @@ struct target_ops *
>>>>>>>>                  through the target_stack.  */
>>>>>>>>               scoped_restore_current_inferior restore_inferior;
>>>>>>>>               set_current_inferior (inf);
>>>>>>>> +             if ((current_inferior ()->attach_flag)
>>>>>>>> +                 && !(current_inferior ()->sync_flag))
>>>>>>>> +                   return;
>>>>>>> also, there's still 8 spaces here. All 8 space-identations should 
>>>>>>> be replaced with tabs.
>>>>>>>> +
>>>>>>>>               current_inferior ()->top_target ()->pass_ctrlc ();
>>>>>>>>               return;
>>>>>>>>             }
>>>>>>>> diff --git a/gdb/top.c b/gdb/top.c
>>>>>>>> index a685dbf5122e..f05fdd161a42 100644
>>>>>>>> --- a/gdb/top.c
>>>>>>>> +++ b/gdb/top.c
>>>>>>>> @@ -542,6 +542,8 @@ struct ui_out **
>>>>>>>>    while (gdb_do_one_event () >= 0)
>>>>>>>>      if (ui->prompt_state != PROMPT_BLOCKED)
>>>>>>>>        break;
>>>>>>>> +
>>>>>>>> +  current_inferior ()->sync_flag = true;
>>>>>>>
>>>>>>> I'm still not 100% convinced this is the best place to put this. 
>>>>>>> Mainly because this function is also called by 
>>>>>>> maybe_wait_sync_command_done; it didn't show up in your testing 
>>>>>>> because when we run gdb from a terminal, the UI is synchronous 
>>>>>>> (so it fails the first part of the IF condition), but this would 
>>>>>>> be exercised in other situations. And 
>>>>>>> maybe_wait_sync_command_done is called after every single command.
>>>>>>>
>>>>>>> I tried adding this to setup_inferior, which looked like the 
>>>>>>> perfect place for it, but it unfortunately didn't work. Since 
>>>>>>> done is better than perfect, I'm not going to block this patch on 
>>>>>>> this, but I'd love to see a more logical place for this code.
>>>>>>>
>>>>>>
>>>>>> Hi Guinevere,
>>>>>>
>>>>>> Can't agree more on setup_inferior is the best place to reset this 
>>>>>> variable. Updated V3 of review accordingly. Added a 
>>>>>> check_quit_flag which will clear quit_flag, if set before 
>>>>>> setup_inferior.
>>>>>>
>>>>>>
>>>>>> Author: Partha Sarathi Satapathy <partha.satapathy@oracle.com>
>>>>>> Date:   Fri Nov 17 11:42:11 2023 +0000
>>>>>>
>>>>>> gdb : Signal to pstack/gdb kills the attached process.
>>>>>>
>>>>>> Problem: While gdb is attaching an inferior, if ctrl-c is pressed 
>>>>>> in the
>>>>>> middle of the process attach,  the sigint is passed to the debugged
>>>>>> process. This triggers the exit of the inferior. For example in 
>>>>>> pstack,
>>>>>> printing a stack can take significant time, and ctrl-c is pressed to
>>>>>> abort the pstack/gdb application. This in turn kills the debugged
>>>>>> process, which can be critical for the system. In this case, the
>>>>>> intention of ctrl+c is to kill pstack/gdb, but not the inferior
>>>>>> application.
>>>>>> gdb -p <<pid>>
>>>>>> or gdb /proc/<<pid>>/exe pid
>>>>>> Attaching to process
>>>>>> << ctrl+c is pressed during attach
>>>>>> (gdb) q
>>>>>> <<<< inferior process exited >>>>
>>>>>>
>>>>>> A Ctrl-C/sigint received by gdb during the attachment of an inferior
>>>>>> passed to the debugged at some definite points during the window of
>>>>>> process attachment. The process of attaching an inferior is a 
>>>>>> multistep
>>>>>> process, and it takes time to get ready with the GDB prompt. As the
>>>>>> debugger and debugger are not fully attached during this period, the
>>>>>> sigint takes its default action to terminate the process.
>>>>>>
>>>>>> Solution: While GDB attaches processes, the inferior is not the 
>>>>>> current
>>>>>> session leader. Hence, until attach is complete and the GDB prompt is
>>>>>> available, the sigint should not be passed to the inferior.
>>>>>> The signal should be skipped if the process runs in the 
>>>>>> background. With
>>>>>> this approach, we can skip passing the signature if the process is
>>>>>> attached to the GDB and the process attach is not complete.
>>>>>
>>>>> Hi!
>>>>>
>>>>> Sorry about the delay on this. I think this is patch looks good to 
>>>>> me, Reviewed-By: Guinevere Larsen <blarsen@redhat.com>
>>>>>
>>>>> I hope some maintainer for this area look at this soon!
>>>>>
>>>>
>>>> Hi Team,
>>>>
>>>> Great if we can get a update on further proceedings on this.
>>>>
>>>> Thanks
>>>> Partha
>>>
>>> Hi Guinevere and Team,
>>>
>>> Great if we can have further update on this.
>>> One more thing notice the online thread for this issue:
>>> https://urldefense.com/v3/__https://sourceware.org/pipermail/gdb-patches/2023-November/204251.html__;!!ACWV5N9M2RV99hQ!IQdn9yPks2xKcRBSz9b4tX70VzdhNoeJeDSZcP_19T3lqehiY8L3kI4fu0TrxTl30v7JqxkkW_XHAA77K1CGhg$ is missing last couple of communications.
>>>
>>> Thanks
>>> Partha
>>
>> Hi Team,
>>
>> Can you please help with further proceedings on this.
>>
>> Thanks
>> Partha
>>
> Hi Partha! I'm sorry this is taking so long. I would suggest that you 
> rebase your patch on the master branch and send a version 4 which is 
> just the rebase to ping this. You also don't need to keep our previous 
> comments on the v4 email, since folks will be able to see this history, 
> and that will make it easier for maintainers to review your code
> 
> If you do send a v4, remember to add my review tag to the end of the 
> commit message :)
> 
> I hope this gets an approval soon.
> 

Author: Partha Sarathi Satapathy <partha.satapathy@oracle.com>
Date:   Fri Nov 17 09:18:56 2023 +0000

gdb : Signal to pstack/gdb kills the attached process.

Problem: While gdb is attaching an inferior, if ctrl-c is pressed in the
middle of the process attach,  the sigint is passed to the debugged
process. This triggers the exit of the inferior. For example in pstack,
printing a stack can take significant time, and ctrl-c is pressed to
abort the pstack/gdb application. This in turn kills the debugged
process, which can be critical for the system. In this case, the
intention of ctrl+c is to kill pstack/gdb, but not the inferior
application.
gdb -p <<pid>>
or gdb /proc/<<pid>>/exe pid
Attaching to process
<< ctrl+c is pressed during attach
(gdb) q
<<<< inferior process exited >>>>

A Ctrl-C/sigint received by gdb during the attachment of an inferior
passed to the debugged at some definite points during the window of
process attachment. The process of attaching an inferior is a multistep
process, and it takes time to get ready with the GDB prompt. As the
debugger and debugger are not fully attached during this period, the
sigint takes its default action to terminate the process.

Solution: While GDB attaches processes, the inferior is not the current
session leader. Hence, until attach is complete and the GDB prompt is
available, the sigint should not be passed to the inferior.
The signal should be skipped if the process runs in the background. With
this approach, we can skip passing the signature if the process is
attached to the GDB and the process attach is not complete.

Reviewed-By: Guinevere Larsen <blarsen@redhat.com>
---
  gdb/infcmd.c   | 2 ++
  gdb/inferior.h | 3 +++
  gdb/target.c   | 3 +++
  3 files changed, 8 insertions(+)

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index c1fdbb300c67..8ab2d50477f4 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2528,6 +2528,8 @@ enum async_reply_reason
    target_post_attach (inferior_ptid.pid ());

    post_create_inferior (from_tty);
+  current_inferior ()->sync_flag = true;
+  check_quit_flag();
  }

  /* What to do after the first program stops after attaching.  */
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 7be28423aeb1..a6065da19a87 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -600,6 +600,9 @@ class inferior : public refcounted_object,
    /* True if this child process was attached rather than forked.  */
    bool attach_flag = false;

+  /* True if inferior has been fully synced and prompt is no longer 
blocked */
+  bool sync_flag = false;
+
    /* If this inferior is a vfork child, then this is the pointer to
       its vfork parent, if GDB is still attached to it.  */
    inferior *vfork_parent = NULL;
diff --git a/gdb/target.c b/gdb/target.c
index bbc1badc9e19..7c7df9c2ed87 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3794,6 +3794,9 @@ struct target_ops *
                  through the target_stack.  */
               scoped_restore_current_inferior restore_inferior;
               set_current_inferior (inf);
+             if ((current_inferior ()->attach_flag)
+               && !(current_inferior ()->sync_flag))
+                 return;
               current_inferior ()->top_target ()->pass_ctrlc ();
               return;
             }
--
1.8.3.1


Hi Team,

Here is the V4 for review and its a rebase to latest.

Thanks
Partha

^ permalink raw reply	[relevance 0%]

* Re: [PATCH 2/2] remote.c: Make packet_ok return struct packet_result
  @ 2024-03-06 16:13  5%   ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-03-06 16:13 UTC (permalink / raw)
  To: Alexandra Hájková, gdb-patches

Alexandra Hájková <ahajkova@redhat.com> writes:

> This allows to print the error message stored in a packet_result
> to be easily used in the calling function.
> ---
>  gdb/remote.c | 166 +++++++++++++++++++++++----------------------------
>  1 file changed, 76 insertions(+), 90 deletions(-)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index 8caee0dcff9..85f5624f2b6 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -765,8 +765,8 @@ struct remote_features
>  
>  /* Check result value in BUF for packet WHICH_PACKET and update the packet's
>     support configuration accordingly.  */
> -  packet_status packet_ok (const char *buf, const int which_packet);
> -  packet_status packet_ok (const gdb::char_vector &buf, const int which_packet);
> +  packet_result packet_ok (const char *buf, const int which_packet);
> +  packet_result packet_ok (const gdb::char_vector &buf, const int which_packet);
>  
>    /* Configuration of a remote target's memory read packet.  */
>    memory_packet_config m_memory_read_packet_config;
> @@ -2499,7 +2499,7 @@ packet_check_result (const gdb::char_vector &buf, bool accept_msg)
>    return packet_check_result (buf.data (), accept_msg);
>  }
>  
> -packet_status
> +packet_result
>  remote_features::packet_ok (const char *buf, const int which_packet)
>  {
>    packet_config *config = &m_protocol_packets[which_packet];
> @@ -2545,10 +2545,10 @@ remote_features::packet_ok (const char *buf, const int which_packet)
>        break;
>      }
>  
> -  return result.status ();
> +  return result;
>  }
>  
> -packet_status
> +packet_result
>  remote_features::packet_ok (const gdb::char_vector &buf, const int which_packet)
>  {
>    return packet_ok (buf.data (), which_packet);
> @@ -2735,14 +2735,15 @@ remote_target::remote_query_attached (int pid)
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_qAttached))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_qAttached);
> +  switch (result.status())
>      {
>      case PACKET_OK:
>        if (strcmp (rs->buf.data (), "1") == 0)
>  	return 1;
>        break;
>      case PACKET_ERROR:
> -      warning (_("Remote failure reply: %s"), rs->buf.data ());
> +      warning (_("Remote failure reply: %s"), result.err_msg());
>        break;
>      case PACKET_UNKNOWN:
>        break;
> @@ -3047,7 +3048,6 @@ remote_target::set_syscall_catchpoint (int pid, bool needed, int any_count,
>  				       gdb::array_view<const int> syscall_counts)
>  {
>    const char *catch_packet;
> -  enum packet_status result;
>    int n_sysno = 0;
>  
>    if (m_features.packet_support (PACKET_QCatchSyscalls) == PACKET_DISABLE)
> @@ -3103,8 +3103,8 @@ remote_target::set_syscall_catchpoint (int pid, bool needed, int any_count,
>  
>    putpkt (catch_packet);
>    getpkt (&rs->buf);
> -  result = m_features.packet_ok (rs->buf, PACKET_QCatchSyscalls);
> -  if (result == PACKET_OK)
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_QCatchSyscalls);
> +  if (result.status() == PACKET_OK)
>      return 0;
>    else
>      return -1;
> @@ -5109,7 +5109,8 @@ remote_target::start_remote_1 (int from_tty, int extended_p)
>      {
>        putpkt ("QStartNoAckMode");
>        getpkt (&rs->buf);
> -      if (m_features.packet_ok (rs->buf, PACKET_QStartNoAckMode) == PACKET_OK)
> +      if ((m_features.packet_ok (rs->buf, PACKET_QStartNoAckMode)).status ()
> +	  == PACKET_OK)
>  	rs->noack_mode = 1;
>      }
>  
> @@ -5894,9 +5895,10 @@ remote_target::remote_query_supported ()
>  
>        /* If an error occurred, warn, but do not return - just reset the
>  	 buffer to empty and go on to disable features.  */
> -      if (m_features.packet_ok (rs->buf, PACKET_qSupported) == PACKET_ERROR)
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_qSupported);
> +      if (result.status () == PACKET_ERROR)
>  	{
> -	  warning (_("Remote failure reply: %s"), rs->buf.data ());
> +	  warning (_("Remote failure reply: %s"), result.err_msg ());
>  	  rs->buf[0] = 0;
>  	}
>      }
> @@ -6548,7 +6550,8 @@ extended_remote_target::attach (const char *args, int from_tty)
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_vAttach))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_vAttach);
> +  switch (result.status ())
>      {
>      case PACKET_OK:
>        if (!target_is_non_stop_p ())
> @@ -6560,7 +6563,7 @@ extended_remote_target::attach (const char *args, int from_tty)
>        else if (strcmp (rs->buf.data (), "OK") != 0)
>  	error (_("Attaching to %s failed with: %s"),
>  	       target_pid_to_str (ptid_t (pid)).c_str (),
> -	       rs->buf.data ());
> +	       result.err_msg ());

I don't think this change is correct.  Notice that we're inside a
PACKET_OK case at this point.  This is slightly confusing.  When a
packet has packet_status PACKET_OK, it means the contents are not one of
the error forms, but otherwise the content could be anything.  'FOO'
would be PACKET_OK, as would the string 'OK'.

I wonder if this error() call should have a slightly different message,
maybe:

  error (_("Attaching to %s returned unexpected packet: %s"),
         target_pid_to_str (ptid_t (pid)).c_str (),
         rs->buf.data ());

But the important thing is that we need to print the packet contents,
not 'result.err_msg ()' as that will not have been set.

Meanwhile, within this same switch statement, the 'default' case is
where PACKET_ERROR is handled, in this case it might be nice to add
printing of 'result.err_msg ()' as currently we don't do that.  Maybe
the 'default:' case label should be changed to 'case PACKET_ERROR:',
relying on 'default:' here just seems sloppy.

>        break;
>      case PACKET_UNKNOWN:
>        error (_("This target does not support attaching to a process"));
> @@ -7489,14 +7492,15 @@ remote_target::remote_interrupt_ns ()
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_vCtrlC))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_vCtrlC);
> +  switch (result.status ())
>      {
>      case PACKET_OK:
>        break;
>      case PACKET_UNKNOWN:
>        error (_("No support for interrupting the remote target."));
>      case PACKET_ERROR:
> -      error (_("Interrupting target failed: %s"), rs->buf.data ());
> +      error (_("Interrupting target failed: %s"), result.err_msg ());
>      }
>  }
>  
> @@ -8792,7 +8796,8 @@ remote_target::fetch_register_using_p (struct regcache *regcache,
>  
>    buf = rs->buf.data ();
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_p))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_p);
> +  switch (result.status ())
>      {
>      case PACKET_OK:
>        break;
> @@ -8801,7 +8806,7 @@ remote_target::fetch_register_using_p (struct regcache *regcache,
>      case PACKET_ERROR:
>        error (_("Could not fetch register \"%s\"; remote failure reply '%s'"),
>  	     gdbarch_register_name (regcache->arch (), reg->regnum),
> -	     buf);
> +	     result.err_msg ());
>      }
>  
>    /* If this register is unfetchable, tell the regcache.  */
> @@ -9098,13 +9103,14 @@ remote_target::store_register_using_P (const struct regcache *regcache,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_P))
> +  packet_result result = m_features.packet_ok (rs->buf, PACKET_P);
> +  switch (result.status ())
>      {
>      case PACKET_OK:
>        return 1;
>      case PACKET_ERROR:
>        error (_("Could not write register \"%s\"; remote failure reply '%s'"),
> -	     gdbarch_register_name (gdbarch, reg->regnum), rs->buf.data ());
> +	     gdbarch_register_name (gdbarch, reg->regnum), result.err_msg ());
>      case PACKET_UNKNOWN:
>        return 0;
>      default:
> @@ -10535,7 +10541,7 @@ remote_target::remote_vkill (int pid)
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_vKill))
> +  switch ((m_features.packet_ok (rs->buf, PACKET_vKill)).status ())
>      {
>      case PACKET_OK:
>        return 0;
> @@ -10691,7 +10697,7 @@ remote_target::extended_remote_run (const std::string &args)
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_vRun))
> +  switch ((m_features.packet_ok (rs->buf, PACKET_vRun)).status ())
>      {
>      case PACKET_OK:
>        /* We have a wait response.  All is well.  */
> @@ -10798,11 +10804,12 @@ remote_target::extended_remote_set_inferior_cwd ()
>  
>        putpkt (rs->buf);
>        getpkt (&rs->buf);
> -      if (m_features.packet_ok (rs->buf, PACKET_QSetWorkingDir) != PACKET_OK)
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_QSetWorkingDir);
> +      if (result.status () != PACKET_OK)
>  	error (_("\
>  Remote replied unexpectedly while setting the inferior's working\n\
>  directory: %s"),
> -	       rs->buf.data ());
> +	       result.err_msg ());

We need to be careful here too.  There's a risk that we might get
PACKET_UNKNOWN in which case calling 'result.err_msg ()' will be
invalid.  I think you might need to change this into a switch statement
and handle each case differently:

  PACKET_OK - nothing to do,
  PACKET_ERROR - print a message including the error text,
  PACKET_UNKNOWN - tell the user that the remote doesn't support this.

>  
>      }
>  }
> @@ -10971,7 +10978,7 @@ remote_target::insert_breakpoint (struct gdbarch *gdbarch,
>        putpkt (rs->buf);
>        getpkt (&rs->buf);
>  
> -      switch (m_features.packet_ok (rs->buf, PACKET_Z0))
> +      switch ((m_features.packet_ok (rs->buf, PACKET_Z0)).status ())
>  	{
>  	case PACKET_ERROR:
>  	  return -1;
> @@ -11072,8 +11079,8 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
> -					  + to_underlying (packet))))
> +  switch ((m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
> +					  + to_underlying (packet)))).status ())
>      {
>      case PACKET_ERROR:
>        return -1;
> @@ -11121,8 +11128,8 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
> -					  + to_underlying (packet))))
> +  switch ((m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
> +					  + to_underlying (packet)))).status ())
>      {
>      case PACKET_ERROR:
>      case PACKET_UNKNOWN:
> @@ -11284,7 +11291,7 @@ remote_target::insert_hw_breakpoint (struct gdbarch *gdbarch,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_Z1))
> +  switch ((m_features.packet_ok (rs->buf, PACKET_Z1)).status ())
>      {
>      case PACKET_ERROR:
>        if (rs->buf[1] == '.')

So the code here (the existing code, not what you've written) is a real
mess.  In the PACKET_ERROR case we attempt to "find" an error message in
the case that the packet is an 'E.msg' style packet.

However, if we do then we call 'error()', meanwhile, if the packet isn't
an 'E.msg' style packet, we return -1, which is pretty different than
throwing an exception.

This caught my eye because when I say the 'E.msg' check I thought, Oh,
we can just capture the packet_result object and call ::err_msg(),
however, this leads to an obvious question: should we throw an
exception, or return -1?

The comment in target.h for target_insert_hw_breakpoint suggests that
the function can _either_ return non-zero OR throw an exception on
error, so I'd be tempted to move to an always throw an error solution
for the PACKET_ERROR case.

> @@ -11331,7 +11338,7 @@ remote_target::remove_hw_breakpoint (struct gdbarch *gdbarch,
>    putpkt (rs->buf);
>    getpkt (&rs->buf);
>  
> -  switch (m_features.packet_ok (rs->buf, PACKET_Z1))
> +  switch ((m_features.packet_ok (rs->buf, PACKET_Z1)).status ())
>      {
>      case PACKET_ERROR:
>      case PACKET_UNKNOWN:
> @@ -11372,7 +11379,7 @@ remote_target::verify_memory (const gdb_byte *data, CORE_ADDR lma, ULONGEST size
>  
>        getpkt (&rs->buf);
>  
> -      status = m_features.packet_ok (rs->buf, PACKET_qCRC);
> +      status = (m_features.packet_ok (rs->buf, PACKET_qCRC)).status ();
>        if (status == PACKET_ERROR)
>  	return -1;
>        else if (status == PACKET_OK)
> @@ -11494,7 +11501,7 @@ remote_target::remote_write_qxfer (const char *object_name,
>  
>    if (putpkt_binary (rs->buf.data (), i + buf_len) < 0
>        || getpkt (&rs->buf) < 0
> -      || m_features.packet_ok (rs->buf, which_packet) != PACKET_OK)
> +      || (m_features.packet_ok (rs->buf, which_packet)).status () != PACKET_OK)
>      return TARGET_XFER_E_IO;
>  
>    unpack_varlen_hex (rs->buf.data (), &n);
> @@ -11559,7 +11566,7 @@ remote_target::remote_read_qxfer (const char *object_name,
>    rs->buf[0] = '\0';
>    packet_len = getpkt (&rs->buf);
>    if (packet_len < 0
> -      || m_features.packet_ok (rs->buf, which_packet) != PACKET_OK)
> +      || (m_features.packet_ok (rs->buf, which_packet)).status () != PACKET_OK)
>      return TARGET_XFER_E_IO;
>  
>    if (rs->buf[0] != 'l' && rs->buf[0] != 'm')
> @@ -11864,7 +11871,8 @@ remote_target::search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
>  
>    if (putpkt_binary (rs->buf.data (), i + escaped_pattern_len) < 0
>        || getpkt (&rs->buf) < 0
> -      || m_features.packet_ok (rs->buf, PACKET_qSearch_memory) != PACKET_OK)
> +      || (m_features.packet_ok (rs->buf, PACKET_qSearch_memory)).status ()
> +      != PACKET_OK)
>      {
>        /* The request may not have worked because the command is not
>  	 supported.  If so, fall back to the simple way.  */
> @@ -12257,7 +12265,6 @@ remote_target::get_thread_local_address (ptid_t ptid, CORE_ADDR lm,
>        struct remote_state *rs = get_remote_state ();
>        char *p = rs->buf.data ();
>        char *endp = p + get_remote_packet_size ();
> -      enum packet_status result;
>  
>        strcpy (p, "qGetTLSAddr:");
>        p += strlen (p);
> @@ -12270,15 +12277,15 @@ remote_target::get_thread_local_address (ptid_t ptid, CORE_ADDR lm,
>  
>        putpkt (rs->buf);
>        getpkt (&rs->buf);
> -      result = m_features.packet_ok (rs->buf, PACKET_qGetTLSAddr);
> -      if (result == PACKET_OK)
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_qGetTLSAddr);
> +      if (result.status () == PACKET_OK)
>  	{
>  	  ULONGEST addr;
>  
>  	  unpack_varlen_hex (rs->buf.data (), &addr);
>  	  return addr;
>  	}
> -      else if (result == PACKET_UNKNOWN)
> +      else if (result.status () == PACKET_UNKNOWN)
>  	throw_error (TLS_GENERIC_ERROR,
>  		     _("Remote target doesn't support qGetTLSAddr packet"));
>        else
> @@ -12303,7 +12310,6 @@ remote_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr)
>        struct remote_state *rs = get_remote_state ();
>        char *p = rs->buf.data ();
>        char *endp = p + get_remote_packet_size ();
> -      enum packet_status result;
>  
>        strcpy (p, "qGetTIBAddr:");
>        p += strlen (p);
> @@ -12312,8 +12318,8 @@ remote_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr)
>  
>        putpkt (rs->buf);
>        getpkt (&rs->buf);
> -      result = m_features.packet_ok (rs->buf, PACKET_qGetTIBAddr);
> -      if (result == PACKET_OK)
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_qGetTIBAddr);
> +      if (result.status () == PACKET_OK)
>  	{
>  	  ULONGEST val;
>  	  unpack_varlen_hex (rs->buf.data (), &val);
> @@ -12321,7 +12327,7 @@ remote_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr)
>  	    *addr = (CORE_ADDR) val;
>  	  return true;
>  	}
> -      else if (result == PACKET_UNKNOWN)
> +      else if (result.status () == PACKET_UNKNOWN)
>  	error (_("Remote target doesn't support qGetTIBAddr packet"));
>        else
>  	error (_("Remote target failed to process qGetTIBAddr request"));

This seems like somewhere that we could make use of result.err_msg().
Not a hard requirement, but given the nature of this series I think this
would be appropriate.

> @@ -12580,7 +12586,7 @@ remote_target::remote_hostio_send_command (int command_bytes, int which_packet,
>        return -1;
>      }
>  
> -  switch (m_features.packet_ok (rs->buf, which_packet))
> +  switch ((m_features.packet_ok (rs->buf, which_packet)).status ())
>      {
>      case PACKET_ERROR:
>        *remote_errno = FILEIO_EINVAL;
> @@ -13868,7 +13874,6 @@ remote_target::get_trace_status (struct trace_status *ts)
>  {
>    /* Initialize it just to avoid a GCC false warning.  */
>    char *p = NULL;
> -  enum packet_status result;
>    struct remote_state *rs = get_remote_state ();
>  
>    if (m_features.packet_support (PACKET_qTStatus) == PACKET_DISABLE)
> @@ -13894,17 +13899,17 @@ remote_target::get_trace_status (struct trace_status *ts)
>        throw;
>      }
>  
> -  result = m_features.packet_ok (p, PACKET_qTStatus);
> +  packet_result result = m_features.packet_ok (p, PACKET_qTStatus);
>  
>    /* If the remote target doesn't do tracing, flag it.  */
> -  if (result == PACKET_UNKNOWN)
> +  if (result.status () == PACKET_UNKNOWN)
>      return -1;
>  
>    /* We're working with a live target.  */
>    ts->filename = NULL;
>  
>    if (*p++ != 'T')
> -    error (_("Bogus trace status reply from target: %s"), rs->buf.data ());
> +    error (_("Bogus trace status reply from target: %s"), result.err_msg ());

This is another place where we've not confirmed that we have a
PACKET_ERROR, it's just that the packet contents don't match the
"expected" format.

Maybe the original PACKET_UNKNOWN check should be changed into a switch
that can also check for PACKET_ERROR and error() with an appropriate
message?

But right here, when we find invalid packet contents, we have to print
'rs->buf.data ()'.

>  
>    /* Function 'parse_trace_status' sets default value of each field of
>       'ts' at first, so we don't have to do it here.  */
> @@ -14248,7 +14253,6 @@ remote_target::set_trace_buffer_size (LONGEST val)
>        struct remote_state *rs = get_remote_state ();
>        char *buf = rs->buf.data ();
>        char *endbuf = buf + get_remote_packet_size ();
> -      enum packet_status result;
>  
>        gdb_assert (val >= 0 || val == -1);
>        buf += xsnprintf (buf, endbuf - buf, "QTBuffer:size:");
> @@ -14263,10 +14267,10 @@ remote_target::set_trace_buffer_size (LONGEST val)
>  
>        putpkt (rs->buf);
>        remote_get_noisy_reply ();
> -      result = m_features.packet_ok (rs->buf, PACKET_QTBuffer_size);
> +      packet_result result = m_features.packet_ok (rs->buf, PACKET_QTBuffer_size);
>  
> -      if (result != PACKET_OK)
> -	warning (_("Bogus reply from target: %s"), rs->buf.data ());
> +      if (result.status () != PACKET_OK)
> +	warning (_("Bogus reply from target: %s"), result.err_msg ());

Again, we don't know this is a PACKET_ERROR so ::err_msg() might not be
valid.

Thanks,
Andrew


^ permalink raw reply	[relevance 5%]

* Re: [PATCH v2 1/1] gdb: Fix assertion in 'value_primitive_field'
  @ 2024-03-06 14:48  0%   ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-03-06 14:48 UTC (permalink / raw)
  To: Stephan Rohr, gdb-patches; +Cc: tom

Stephan Rohr <stephan.rohr@intel.com> writes:

> From: "Rohr, Stephan" <stephan.rohr@intel.com>
>
> GDB asserts that the data location of a value's field with a dynamic
> data location is resolved when fetching the field's value in
> 'value_primitive_field'.  This assertion was hit because of bogus DWARF
> generated by the Intel Fortran compiler.  While that compiler should fix
> the DWARF, we prefer GDB to error out here instead, e.g. to allow the
> user to continue debugging other parts of the program.
> ---
>  .../locexpr-data-member-dynamic-location.c    |  31 ++++
>  .../locexpr-data-member-dynamic-location.exp  | 136 ++++++++++++++++++
>  gdb/value.c                                   |   4 +-
>  3 files changed, 170 insertions(+), 1 deletion(-)
>  create mode 100644 gdb/testsuite/gdb.dwarf2/locexpr-data-member-dynamic-location.c
>  create mode 100644 gdb/testsuite/gdb.dwarf2/locexpr-data-member-dynamic-location.exp
>
> diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-dynamic-location.c b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-dynamic-location.c
> new file mode 100644
> index 00000000000..3c3f6910298
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-dynamic-location.c
> @@ -0,0 +1,31 @@
> +/* Copyright 2024 Free Software Foundation, Inc.
> +
> +   This file is part of GDB.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +struct container
> +{
> +  int *data;
> +  int size;
> +};
> +
> +int var_a_data[] = {5, 8, 13, 21, 34};
> +struct container var_a = {var_a_data, 5};
> +
> +int
> +main (void)
> +{
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-dynamic-location.exp b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-dynamic-location.exp
> new file mode 100644
> index 00000000000..8d13ac04651
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-dynamic-location.exp
> @@ -0,0 +1,136 @@
> +# Copyright 2024 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +#
> +# Tests that GDB prints an error when fetching a value's (dynamic) field
> +# with unresolved data location.  For a reproducer, we setup the following
> +# struct type:
> +#
> +#   struct container
> +#     {
> +#       int *data;
> +#       int size;
> +#     };
> +#
> +# We use 'DW_AT_upper_bound' to create a non-static field 'data'.  The error
> +# reproduces with invalid DWARF, i.e. when pushing the memory location of an
> +# instance 'var_a' of struct 'container' on the DWARF stack:
> +#
> +#   DW_AT_location {
> +#     DW_OP_addr [gdb_target_symbol var_a]
> +#     DW_OP_deref
> +#     DW_OP_stack_value
> +#   } SPECIAL_expr}
> +
> +load_lib dwarf.exp
> +
> +# This test can only be run on targets which support DWARF-2 and use gas.
> +if {![dwarf2_support]} {
> +    return 0
> +}
> +
> +standard_testfile .c -dw.S
> +
> +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
> +    return -1
> +}
> +
> +# Make some DWARF for the test.
> +set asm_file [standard_output_file $srcfile2]
> +Dwarf::assemble $asm_file {
> +    cu {} {
> +	DW_TAG_compile_unit {} {
> +	    declare_labels integer_label array_label struct_label var_a_label
> +	    set int_size [get_sizeof "int" 4]
> +	    set addr_size [get_sizeof "void *" 8]
> +
> +	    integer_label: DW_TAG_base_type {
> +		{DW_AT_byte_size $int_size DW_FORM_sdata}
> +		{DW_AT_encoding  @DW_ATE_signed}
> +	    }
> +
> +	    array_label: DW_TAG_array_type {
> +		{DW_AT_type :$integer_label}
> +		{DW_AT_data_location {
> +		    DW_OP_push_object_address
> +		    DW_OP_deref
> +		} SPECIAL_expr}
> +	    } {
> +		DW_TAG_subrange_type {
> +		    {DW_AT_type :$integer_label}
> +		    {DW_AT_upper_bound {
> +			DW_OP_push_object_address
> +			DW_OP_plus_uconst $addr_size
> +			DW_OP_deref_size $int_size
> +			DW_OP_lit1
> +			DW_OP_minus
> +		    } SPECIAL_expr}
> +		}
> +	    }
> +
> +	    struct_label: DW_TAG_structure_type {
> +		{DW_AT_byte_size 12 DW_FORM_udata}
> +	    } {
> +		DW_TAG_member {
> +		    {DW_AT_name "data"}
> +		    {DW_AT_type :${array_label}}
> +		    {DW_AT_data_member_location 0 DW_FORM_udata}
> +		}
> +
> +		DW_TAG_member {
> +		    {DW_AT_name "size"}
> +		    {DW_AT_type :${integer_label}}
> +		    {DW_AT_data_member_location $addr_size DW_FORM_udata}
> +		}
> +	    }
> +
> +	    DW_TAG_variable {
> +		{DW_AT_name var_a_valid_location}
> +		{DW_AT_type :$struct_label}
> +		{DW_AT_location {
> +		    DW_OP_addr [gdb_target_symbol var_a]
> +		} SPECIAL_expr}
> +	    }
> +
> +	    DW_TAG_variable {
> +		{DW_AT_name var_a_invalid_location}
> +		{DW_AT_type :$struct_label}
> +		{DW_AT_location {
> +		    DW_OP_addr [gdb_target_symbol var_a]
> +		    DW_OP_deref
> +		    DW_OP_stack_value
> +		} SPECIAL_expr}
> +	    }
> +	}
> +    }
> +}
> +
> +# Now that we've generated the DWARF debugging info, rebuild our
> +# program using our debug info instead of the info generated by
> +# the compiler.
> +
> +if { [prepare_for_testing "failed to prepare" ${testfile} \
> +	  [list $srcfile $asm_file] {nodebug}] } {
> +    return -1
> +}
> +
> +if ![runto_main] {
> +    return -1
> +}
> +
> +gdb_test "print var_a_valid_location" \
> +	 " = \\{data = \\{5, 8, 13, 21, 34\\}, size = 5\\}"
> +
> +gdb_test "print var_a_invalid_location" \
> +	 " = \\{data = <error reading variable: cannot read data.*"

When I tried this test I see this output:

  (gdb) print var_a_valid_location
  $1 = {data = {5, 8, 13, 21, 34}, size = 5}
  (gdb) PASS: gdb.dwarf2/locexpr-data-member-dynamic-location.exp: print var_a_valid_location
  print var_a_invalid_location
  ../../src/gdb/../gdbsupport/array-view.h:191: internal-error: slice: Assertion `start + size <= m_size' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  ----- Backtrace -----
  FAIL: gdb.dwarf2/locexpr-data-member-dynamic-location.exp: print var_a_invalid_location (GDB internal error)
  Resyncing due to internal error.
  0x60958a gdb_internal_backtrace_1
          ../../src/gdb/bt-utils.c:122
  0x60962d _Z22gdb_internal_backtracev
          ../../src/gdb/bt-utils.c:168
  0xf2e67d internal_vproblem
          ../../src/gdb/utils.c:421
  0xf2ea4c _Z15internal_verrorPKciS0_P13__va_list_tag
          ../../src/gdb/utils.c:501
  0x1722a94 _Z18internal_error_locPKciS0_z
          ../../src/gdbsupport/errors.cc:58
  0x438931 _ZNK3gdb10array_viewIKhE5sliceEmm
          ../../src/gdb/../gdbsupport/array-view.h:191
  0x78479a _ZN18dwarf_expr_context12fetch_resultEP4typeS1_lb
          ../../src/gdb/dwarf2/expr.c:1038
  0x784954 _ZN18dwarf_expr_context8evaluateEPKhmbP18dwarf2_per_cu_dataRK14frame_info_ptrPK18property_addr_infoP4typeSB_l
          ../../src/gdb/dwarf2/expr.c:1089
  0x7d61be dwarf2_evaluate_loc_desc_full
          ../../src/gdb/dwarf2/loc.c:1525
  0x7d6396 _Z24dwarf2_evaluate_loc_descP4typeRK14frame_info_ptrPKhmP18dwarf2_per_cu_dataP18dwarf2_per_objfileb
          ../../src/gdb/dwarf2/loc.c:1569
  0x7d932c locexpr_read_variable
          ../../src/gdb/dwarf2/loc.c:3061
  0x8c6e91 _ZNK13language_defn14read_var_valueEP6symbolPK5blockRK14frame_info_ptr
          ../../src/gdb/findvar.c:505
  0x8c78cf _Z14read_var_valueP6symbolPK5blockRK14frame_info_ptr
          ../../src/gdb/findvar.c:715
  0xf4aab8 _Z17value_of_variableP6symbolPK5block
          ../../src/gdb/valops.c:1379
  0x8878ef _Z18evaluate_var_value6nosidePK5blockP6symbol
          ../../src/gdb/eval.c:535
  0x8879e2 _ZN4expr19var_value_operation8evaluateEP4typeP10expression6noside
          ../../src/gdb/eval.c:561
  0x886bd2 _ZN10expression8evaluateEP4type6noside
          ../../src/gdb/eval.c:111
  0xb6aeb4 process_print_command_args
          ../../src/gdb/printcmd.c:1325
  0xb6af58 print_command_1
          ../../src/gdb/printcmd.c:1338
  0xb6b279 print_command
          ../../src/gdb/printcmd.c:1405
  0x67ec70 do_simple_func
          ../../src/gdb/cli/cli-decode.c:95
  0x683c79 _Z8cmd_funcP16cmd_list_elementPKci
          ../../src/gdb/cli/cli-decode.c:2742
  0xe66aa0 _Z15execute_commandPKci
          ../../src/gdb/top.c:571
  0x89152e _Z15command_handlerPKc
          ../../src/gdb/event-top.c:567
  0x891a37 _Z20command_line_handlerOSt10unique_ptrIcN3gdb13xfree_deleterIcEEE
          ../../src/gdb/event-top.c:803
  0xeaac2d tui_command_line_handler
          ../../src/gdb/tui/tui-interp.c:104
  0x890e3e gdb_rl_callback_handler
          ../../src/gdb/event-top.c:259
  0xfdcaf5 rl_callback_read_char
          ../../../src/readline/readline/callback.c:290
  0x890ca6 gdb_rl_callback_read_char_wrapper_noexcept
          ../../src/gdb/event-top.c:195
  0x890d42 gdb_rl_callback_read_char_wrapper
          ../../src/gdb/event-top.c:234
  0xee7387 stdin_event_handler
          ../../src/gdb/ui.c:155
  0x1723a4c handle_file_event
          ../../src/gdbsupport/event-loop.cc:573
  0x1723fe2 gdb_wait_for_event
          ../../src/gdbsupport/event-loop.cc:694
  0x1722ecc _Z16gdb_do_one_eventi
          ../../src/gdbsupport/event-loop.cc:264
  0xa5cae0 start_event_loop
          ../../src/gdb/main.c:401
  0xa5cc41 captured_command_loop
          ../../src/gdb/main.c:465
  0xa5e61f captured_main
          ../../src/gdb/main.c:1339
  0xa5e6b9 _Z8gdb_mainP18captured_main_args
          ../../src/gdb/main.c:1358
  0x4188c1 main
          ../../src/gdb/gdb.c:39

Looking at the assert that triggered you likely need to compile with
'-D_GLIBCXX_DEBUG=1', but it's also worth adding
'-D_GLIBCXX_DEBUG_PEDANTIC=1' too as this will enable even more error
checking within libstdc++.

Thanks,
Andrew




> diff --git a/gdb/value.c b/gdb/value.c
> index a2b2721d183..145e70074a9 100644
> --- a/gdb/value.c
> +++ b/gdb/value.c
> @@ -3060,7 +3060,9 @@ value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type)
>  
>        gdb_assert (0 == offset);
>        /* We expect an already resolved data location.  */
> -      gdb_assert (TYPE_DATA_LOCATION (type)->is_constant ());
> +      if (!TYPE_DATA_LOCATION (type)->is_constant ())
> +	error (_("cannot read %s, expected an already resolved data "
> +		 "location."), arg_type->field (fieldno).name ());
>        /* For dynamic data types defer memory allocation
>  	 until we actual access the value.  */
>        v = value::allocate_lazy (type);
> -- 
> 2.34.1
>
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 0%]

* Re: [PATCH v2] Remove tui-out.[ch]
  @ 2024-03-06 13:42  0% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-03-06 13:42 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: Tom Tromey

Tom Tromey <tom@tromey.com> writes:

> The other day on irc, we were discussing the "m_line" hack in
> tui-out.c, and I mentioned that it would be nice to replace this with
> a new ui_out_flag.
>
> Later, I looked at ui_out_flag and found:
>
>       ui_source_list = (1 << 0),
>
> ... and sure enough, this is tested already.
>
> This patch removes tui-out.[ch] and changes the TUI to use an ordinary
> cli-out object without this flag set.
>
> As far as I can tell, this doesn't affect behavior at all -- the TUI
> tests all pass, and interactively I tried switching stack frames,
> "list", etc, and it all seems to work.
>
> New in v2: fixed the problem pointed out by Keith, and added a test
> case for that scenario.

This LGTM.  Keith might also want to look at this so I'll just add:

Reviewed-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


> ---
>  gdb/Makefile.in                           |   2 -
>  gdb/source.c                              |  27 ++----
>  gdb/testsuite/gdb.tui/tui-missing-src.exp |   2 +
>  gdb/tui/tui-io.c                          |   3 +-
>  gdb/tui/tui-out.c                         | 111 ----------------------
>  gdb/tui/tui-out.h                         |  64 -------------
>  6 files changed, 12 insertions(+), 197 deletions(-)
>  delete mode 100644 gdb/tui/tui-out.c
>  delete mode 100644 gdb/tui/tui-out.h
>
> diff --git a/gdb/Makefile.in b/gdb/Makefile.in
> index 0e0f19c40c9..340ff266a6e 100644
> --- a/gdb/Makefile.in
> +++ b/gdb/Makefile.in
> @@ -318,7 +318,6 @@ SUBDIR_TUI_SRCS = \
>  	tui/tui-io.c \
>  	tui/tui-layout.c \
>  	tui/tui-location.c \
> -	tui/tui-out.c \
>  	tui/tui-regs.c \
>  	tui/tui-source.c \
>  	tui/tui-status.c \
> @@ -1605,7 +1604,6 @@ HFILES_NO_SRCDIR = \
>  	tui/tui-io.h \
>  	tui/tui-layout.h \
>  	tui/tui-location.h \
> -	tui/tui-out.h \
>  	tui/tui-regs.h \
>  	tui/tui-source.h \
>  	tui/tui-status.h \
> diff --git a/gdb/source.c b/gdb/source.c
> index 2c465a1251f..bbeb4154258 100644
> --- a/gdb/source.c
> +++ b/gdb/source.c
> @@ -1341,30 +1341,21 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
>  		   styled_string (file_name_style.style (), filename),
>  		   safe_strerror (errcode));
>  	}
> -      else
> +      else if (uiout->is_mi_like_p () || uiout->test_flags (ui_source_list))
>  	{
> +	  /* CLI expects only the "file" field.  MI expects both
> +	     fields.  ui_source_list is set only for CLI, not for
> +	     TUI.  */
> +
>  	  uiout->field_signed ("line", line);
>  	  uiout->text ("\tin ");
>  
> -	  /* CLI expects only the "file" field.  TUI expects only the
> -	     "fullname" field (and TUI does break if "file" is printed).
> -	     MI expects both fields.  ui_source_list is set only for CLI,
> -	     not for TUI.  */
> -	  if (uiout->is_mi_like_p () || uiout->test_flags (ui_source_list))
> -	    uiout->field_string ("file", symtab_to_filename_for_display (s),
> -				 file_name_style.style ());
> -	  if (uiout->is_mi_like_p () || !uiout->test_flags (ui_source_list))
> +	  uiout->field_string ("file", symtab_to_filename_for_display (s),
> +			       file_name_style.style ());
> +	  if (uiout->is_mi_like_p ())
>  	    {
>  	      const char *s_fullname = symtab_to_fullname (s);
> -	      char *local_fullname;
> -
> -	      /* 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 = (char *) alloca (strlen (s_fullname) + 1);
> -	      strcpy (local_fullname, s_fullname);
> -
> -	      uiout->field_string ("fullname", local_fullname);
> +	      uiout->field_string ("fullname", s_fullname);
>  	    }
>  
>  	  uiout->text ("\n");
> diff --git a/gdb/testsuite/gdb.tui/tui-missing-src.exp b/gdb/testsuite/gdb.tui/tui-missing-src.exp
> index 19da9389a46..1929a1e3568 100644
> --- a/gdb/testsuite/gdb.tui/tui-missing-src.exp
> +++ b/gdb/testsuite/gdb.tui/tui-missing-src.exp
> @@ -89,6 +89,8 @@ Term::check_box_contents "check source box is empty" \
>  Term::command "set pagination off"
>  Term::command "start"
>  Term::command "next"
> +Term::check_contents "next does not show source line" \
> +    "\\(gdb\\) next *\n\\(gdb\\)"
>  Term::command "step"
>  Term::check_contents "checking if inside f2 ()" "f2 \\(x=4\\)"
>  Term::check_box_contents "f2.c must be displayed in source window" \
> diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
> index 94554fd447d..ba07e3d573b 100644
> --- a/gdb/tui/tui-io.c
> +++ b/gdb/tui/tui-io.c
> @@ -33,7 +33,6 @@
>  #include "tui/tui-win.h"
>  #include "tui/tui-wingeneral.h"
>  #include "tui/tui-file.h"
> -#include "tui/tui-out.h"
>  #include "ui-out.h"
>  #include "cli-out.h"
>  #include <fcntl.h>
> @@ -917,7 +916,7 @@ tui_initialize_io (void)
>    tui_stdout = new pager_file (new tui_file (stdout, true));
>    tui_stderr = new tui_file (stderr, false);
>    tui_stdlog = new timestamped_file (tui_stderr);
> -  tui_out = new tui_ui_out (tui_stdout);
> +  tui_out = new cli_ui_out (tui_stdout, 0);
>  
>    /* Create the default UI.  */
>    tui_old_uiout = new cli_ui_out (gdb_stdout);
> diff --git a/gdb/tui/tui-out.c b/gdb/tui/tui-out.c
> deleted file mode 100644
> index 2ce7309b902..00000000000
> --- a/gdb/tui/tui-out.c
> +++ /dev/null
> @@ -1,111 +0,0 @@
> -/* Output generating routines for GDB CLI.
> -
> -   Copyright (C) 1999-2024 Free Software Foundation, Inc.
> -
> -   Contributed by Cygnus Solutions.
> -   Written by Fernando Nasser for Cygnus.
> -
> -   This file is part of GDB.
> -
> -   This program is free software; you can redistribute it and/or modify
> -   it under the terms of the GNU General Public License as published by
> -   the Free Software Foundation; either version 3 of the License, or
> -   (at your option) any later version.
> -
> -   This program is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -   GNU General Public License for more details.
> -
> -   You should have received a copy of the GNU General Public License
> -   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> -
> -#include "defs.h"
> -#include "ui-out.h"
> -#include "tui-out.h"
> -#include "tui.h"
> -
> -/* Output an int field.  */
> -
> -void
> -tui_ui_out::do_field_signed (int fldno, int width, ui_align alignment,
> -			     const char *fldname, LONGEST value)
> -{
> -  if (suppress_output ())
> -    return;
> -
> -  /* Don't print line number, keep it for later.  */
> -  if (m_start_of_line == 0 && strcmp (fldname, "line") == 0)
> -    {
> -      m_start_of_line++;
> -      m_line = value;
> -      return;
> -    }
> -  m_start_of_line++;
> -
> -  cli_ui_out::do_field_signed (fldno, width, alignment, fldname, value);
> -}
> -
> -/* Other cli_field_* end up here so alignment and field separators are
> -   both handled by tui_field_string.  */
> -
> -void
> -tui_ui_out::do_field_string (int fldno, int width, ui_align align,
> -			     const char *fldname, const char *string,
> -			     const ui_file_style &style)
> -{
> -  if (suppress_output ())
> -    return;
> -
> -  m_start_of_line++;
> -
> -  if (fldname && m_line > 0 && strcmp (fldname, "fullname") == 0)
> -    return;
> -
> -  cli_ui_out::do_field_string (fldno, width, align, fldname, string, style);
> -}
> -
> -void
> -tui_ui_out::do_field_fmt (int fldno, int width, ui_align align,
> -			  const char *fldname, const ui_file_style &style,
> -			  const char *format, va_list args)
> -{
> -  if (suppress_output ())
> -    return;
> -
> -  m_start_of_line++;
> -
> -  cli_ui_out::do_field_fmt (fldno, width, align, fldname, style, format, args);
> -}
> -
> -void
> -tui_ui_out::do_text (const char *string)
> -{
> -  if (suppress_output ())
> -    return;
> -
> -  m_start_of_line++;
> -  if (m_line > 0)
> -    {
> -      /* Printing a source line, so suppress regular output -- the
> -	 line was shown on the TUI's source window by tui_show_source
> -	 above instead.  */
> -      if (strchr (string, '\n') != 0)
> -	{
> -	  /* We've reached the end of the line, so go back to letting
> -	     text output go to the console.  */
> -	  m_line = 0;
> -	  m_start_of_line = 0;
> -	}
> -      return;
> -    }
> -  if (strchr (string, '\n'))
> -    m_start_of_line = 0;
> -
> -  cli_ui_out::do_text (string);
> -}
> -
> -tui_ui_out::tui_ui_out (ui_file *stream)
> -  : cli_ui_out (stream, 0)
> -{
> -}
> diff --git a/gdb/tui/tui-out.h b/gdb/tui/tui-out.h
> deleted file mode 100644
> index e4ebb1e7408..00000000000
> --- a/gdb/tui/tui-out.h
> +++ /dev/null
> @@ -1,64 +0,0 @@
> -/* Copyright (C) 2016-2024 Free Software Foundation, Inc.
> -
> -   This file is part of GDB.
> -
> -   This program is free software; you can redistribute it and/or modify
> -   it under the terms of the GNU General Public License as published by
> -   the Free Software Foundation; either version 3 of the License, or
> -   (at your option) any later version.
> -
> -   This program is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -   GNU General Public License for more details.
> -
> -   You should have received a copy of the GNU General Public License
> -   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> -
> -#ifndef TUI_TUI_OUT_H
> -#define TUI_TUI_OUT_H
> -
> -#include "cli-out.h"
> -
> -/* A ui_out class for the TUI.  This is just like the CLI's ui_out,
> -   except that it overrides output methods to detect when a source
> -   line is being printed and show the source in the TUI's source
> -   window instead of printing the line in the console window.  */
> -class tui_ui_out : public cli_ui_out
> -{
> -public:
> -
> -  explicit tui_ui_out (ui_file *stream);
> -
> -protected:
> -
> -  void do_field_signed (int fldno, int width, ui_align align, const char *fldname,
> -			LONGEST value) override;
> -  void do_field_string (int fldno, int width, ui_align align, const char *fldname,
> -			const char *string, const ui_file_style &style) override;
> -  void do_field_fmt (int fldno, int width, ui_align align, const char *fldname,
> -		     const ui_file_style &style,
> -		     const char *format, va_list args) override
> -    ATTRIBUTE_PRINTF (7, 0);
> -  void do_text (const char *string) override;
> -
> -private:
> -
> -  /* These fields are used to make print_source_lines show the source
> -     in the TUI's source window instead of in the console.
> -     M_START_OF_LINE is incremented whenever something is output to
> -     the ui_out.  If an integer field named "line" is printed on the
> -     ui_out, and nothing else has been printed yet (both
> -     M_START_OF_LINE and M_LINE are still 0), we assume
> -     print_source_lines is starting to print a source line, and thus
> -     record the line number in M_LINE.  Afterwards, when we see a
> -     string field named "fullname" being output, we take the fullname
> -     and the recorded line and show the source line in the TUI's
> -     source window.  tui_ui_out::do_text() suppresses text output
> -     until it sees an endline being printed, at which point these
> -     variables are reset back to 0.  */
> -  int m_line = 0;
> -  int m_start_of_line = 0;
> -};
> -
> -#endif /* TUI_TUI_OUT_H */
> -- 
> 2.43.0


^ permalink raw reply	[relevance 0%]

* Re: [PATCH 00/11] sim: riscv: simulation of single and double precision floating point instructions
  @ 2024-03-06 13:24  0% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-03-06 13:24 UTC (permalink / raw)
  To: bhushan.attarde, gdb-patches; +Cc: vapier, Jaydeep.Patil, Bhushan Attarde

<bhushan.attarde@imgtec.com> writes:

> From: Bhushan Attarde <bhushan.attarde@imgtec.com>
>
> Hi All,
>
> This patch series (total 11 patches) adds simulation of riscv single
> and double

I think something went wrong with the threading when you sent these
emails, patches 1->3 are threaded together, then the other emails are
split into two separate thread blocks:

  https://inbox.sourceware.org/gdb-patches/20240226142234.1628932-1-bhushan.attarde@imgtec.com/
  https://inbox.sourceware.org/gdb-patches/20240226142628.1629048-1-bhushan.attarde@imgtec.com/
  https://inbox.sourceware.org/gdb-patches/20240226142845.1629113-1-bhushan.attarde@imgtec.com/

Could you repost them please with the threading fixed, this makes it far
easier to apply the complete series, plus keeps all the reviews within a
single thread.

Thanks,
Andrew


> precision floating point instructions. This includes load-store, move, compare,
> classify, sign injection, min, max, MAC, conversion and basic arithmetic
> instructions. Each patch also includes tests for the corresponding instructions.
>
> The tool-chain sources used are from:
> https://github.com/riscv-collab/riscv-gnu-toolchain.git
>
> And gdb sources are replaced with latest upstream sources from:
> https://sourceware.org/git/binutils-gdb.git
>
> GDB is configured with --target=riscv64-unknown-elf option.
>
> Contributions from:
>   Bhushan Attarde (Bhushan.Attarde@imgtec.com)
>   Jaydeep Patil (Jaydeep.Patil@imgtec.com)
>
> Bhushan Attarde (11):
>   sim: riscv: Add single precision floating-point load-store, move,
>     compare and classify instructions
>   sim: riscv: Add single precision floating-point sign injection, min
>     and max instructions
>   sim: riscv: Add floating-point CSR instructions
>   sim: riscv: Add single precision floating-point MAC instructions
>   sim: riscv: Add single precision floating-point basic arithmetic
>     instructions
>   sim: riscv: Add single-precision floating-point conversion
>     instructions
>   sim: riscv: Add double precision floating-point load-store, move,
>     compare and classify instructions
>   sim: riscv: Add double precision floating-point sign-injection, min
>     and max instructions
>   sim: riscv: Add double precision floating-point MAC instructions
>   sim: riscv: Add double precision floating-point basic arithmetic
>     instructions
>   sim: riscv: Add double precision floating-point conversion
>     instructions
>
>  sim/riscv/model_list.def               |    4 +
>  sim/riscv/sim-main.c                   | 1544 ++++++++++++++++++++++++
>  sim/testsuite/riscv/d-basic-arith.s    |  128 ++
>  sim/testsuite/riscv/d-conversion.s     |  111 ++
>  sim/testsuite/riscv/d-fp-compare.s     |   94 ++
>  sim/testsuite/riscv/d-fp-load-store.s  |   58 +
>  sim/testsuite/riscv/d-fp-sign-inject.s |   87 ++
>  sim/testsuite/riscv/f-csr.s            |   56 +
>  sim/testsuite/riscv/s-basic-arith.s    |  131 ++
>  sim/testsuite/riscv/s-conversion-l.s   |   60 +
>  sim/testsuite/riscv/s-conversion.s     |   61 +
>  sim/testsuite/riscv/s-fp-compare.s     |   97 ++
>  sim/testsuite/riscv/s-fp-load-store.s  |   62 +
>  sim/testsuite/riscv/s-fp-sign-inject.s |   90 ++
>  14 files changed, 2583 insertions(+)
>  create mode 100644 sim/testsuite/riscv/d-basic-arith.s
>  create mode 100755 sim/testsuite/riscv/d-conversion.s
>  create mode 100755 sim/testsuite/riscv/d-fp-compare.s
>  create mode 100755 sim/testsuite/riscv/d-fp-load-store.s
>  create mode 100644 sim/testsuite/riscv/d-fp-sign-inject.s
>  create mode 100644 sim/testsuite/riscv/f-csr.s
>  create mode 100644 sim/testsuite/riscv/s-basic-arith.s
>  create mode 100644 sim/testsuite/riscv/s-conversion-l.s
>  create mode 100644 sim/testsuite/riscv/s-conversion.s
>  create mode 100644 sim/testsuite/riscv/s-fp-compare.s
>  create mode 100644 sim/testsuite/riscv/s-fp-load-store.s
>  create mode 100644 sim/testsuite/riscv/s-fp-sign-inject.s
>
> -- 
> 2.25.1


^ permalink raw reply	[relevance 0%]

* [PATCHv11 5/5] gdb: rename unwindonsignal to unwind-on-signal
  @ 2024-03-05 15:40  6%   ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-03-05 15:40 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess, Eli Zaretskii

We now have unwind-on-timeout and unwind-on-terminating-exception, and
then the odd one out unwindonsignal.

I'm not a great fan of these squashed together command names, so in
this commit I propose renaming this to unwind-on-signal.

Obviously I've added the hidden alias unwindonsignal so any existing
GDB scripts will keep working.

There's one test that I've extended to test the alias works, but in
most of the other test scripts I've changed over to use the new name.

The docs are updated to reference the new name.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---
 gdb/NEWS                                      |  9 +++++
 gdb/doc/gdb.texinfo                           | 16 ++++++---
 gdb/infcall.c                                 | 21 ++++++-----
 gdb/testsuite/gdb.base/callfuncs.exp          |  4 +--
 gdb/testsuite/gdb.base/infcall-failure.exp    |  4 +--
 gdb/testsuite/gdb.base/unwindonsignal.exp     | 36 +++++++++++++------
 gdb/testsuite/gdb.compile/compile-cplus.exp   |  6 ++--
 gdb/testsuite/gdb.compile/compile.exp         |  6 ++--
 gdb/testsuite/gdb.cp/gdb2495.exp              | 16 ++++-----
 gdb/testsuite/gdb.fortran/function-calls.exp  |  2 +-
 gdb/testsuite/gdb.mi/mi-condbreak-fail.exp    |  6 ++--
 gdb/testsuite/gdb.mi/mi-condbreak-throw.exp   |  2 +-
 gdb/testsuite/gdb.mi/mi-syn-frame.exp         |  2 +-
 .../infcall-from-bp-cond-simple.exp           |  2 +-
 .../gdb.threads/thread-unwindonsignal.exp     |  8 ++---
 15 files changed, 89 insertions(+), 51 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index d6139ed5001..bf2d40e57a6 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -25,6 +25,10 @@ maintenance info line-table
   if the line is considered the start of the epilgoue, and thus a point at
   which the frame can be considered destroyed.
 
+set unwindonsignal on|off
+show unwindonsignal
+  These commands are now aliases for the new set/show unwind-on-signal.
+
 * New commands
 
 info missing-debug-handler
@@ -74,6 +78,11 @@ show unwind-on-timeout
   dummy frame that was added for the inferior call, and restoring the
   inferior state to how it was before the inferior call started.
 
+set unwind-on-signal on|off
+show unwind-on-signal
+  These new commands replaces the existing set/show unwindonsignal.  The
+  old command is maintained as an alias.
+
 * New features in the GDB remote stub, GDBserver
 
   ** The --remote-debug and --event-loop-debug command line options
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 0c53f1254f1..fe2cf73d509 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -20900,7 +20900,7 @@
 It is possible for the function you call via the @code{print} or
 @code{call} command to generate a signal (e.g., if there's a bug in
 the function, or if you passed it incorrect arguments).  What happens
-in that case is controlled by the @code{set unwindonsignal} command.
+in that case is controlled by the @code{set unwind-on-signal} command.
 
 Similarly, with a C@t{++} program it is possible for the function you
 call via the @code{print} or @code{call} command to generate an
@@ -20914,7 +20914,8 @@
 
 @anchor{stack unwind settings}
 @table @code
-@item set unwindonsignal
+@item set unwind-on-signal
+@kindex set unwind-on-signal
 @kindex set unwindonsignal
 @cindex unwind stack in called functions
 @cindex call dummy stack unwinding
@@ -20925,11 +20926,18 @@
 default), @value{GDBN} stops in the frame where the signal was
 received.
 
-@item show unwindonsignal
+The command @code{set unwindonsignal} is an alias for this command,
+and is maintained for backward compatibility.
+
+@item show unwind-on-signal
+@kindex show unwind-on-signal
 @kindex show unwindonsignal
 Show the current setting of stack unwinding in the functions called by
 @value{GDBN}.
 
+The command @code{show unwindonsignal} is an alias for this command,
+and is maintained for backward compatibility.
+
 @item set unwind-on-terminating-exception
 @kindex set unwind-on-terminating-exception
 @cindex unwind stack in called functions with unhandled exceptions
@@ -20994,7 +21002,7 @@
 If a called function is interrupted for any reason, including hitting
 a breakpoint, or triggering a watchpoint, and the stack is not unwound
 due to @code{set unwind-on-terminating-exception on}, @code{set
-unwind-on-timeout on}, or @code{set unwindonsignal on} (@pxref{stack
+unwind-on-timeout on}, or @code{set unwind-on-signal on} (@pxref{stack
 unwind settings}), then the dummy-frame, created by @value{GDBN} to
 facilitate the call to the program function, will be visible in the
 backtrace, for example frame @code{#3} in the following backtrace:
diff --git a/gdb/infcall.c b/gdb/infcall.c
index bbe906420d1..c9267e7a129 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -1752,7 +1752,7 @@ When the function is done executing, GDB will silently stop."),
 The program being debugged received signal %s, %s\n\
 while in a function called from GDB.  GDB has restored the context\n\
 to what it was before the call.  To change this behavior use\n\
-\"set unwindonsignal off\".  Evaluation of the expression containing\n\
+\"set unwind-on-signal off\".  Evaluation of the expression containing\n\
 the function (%s) will be abandoned."),
 		     gdb_signal_to_name (stop_signal),
 		     gdb_signal_to_string (stop_signal),
@@ -1771,7 +1771,7 @@ the function (%s) will be abandoned."),
 	      error (_("\
 The program being debugged was signaled while in a function called from GDB.\n\
 GDB remains in the frame where the signal was received.\n\
-To change this behavior use \"set unwindonsignal on\".\n\
+To change this behavior use \"set unwind-on-signal on\".\n\
 Evaluation of the expression containing the function\n\
 (%s) will be abandoned.\n\
 When the function is done executing, GDB will silently stop."),
@@ -1903,17 +1903,22 @@ The default is to perform the conversion."),
 			   show_coerce_float_to_double_p,
 			   &setlist, &showlist);
 
-  add_setshow_boolean_cmd ("unwindonsignal", no_class,
-			   &unwind_on_signal_p, _("\
+  set_show_commands setshow_unwind_on_signal_cmds
+    = add_setshow_boolean_cmd ("unwind-on-signal", no_class,
+			       &unwind_on_signal_p, _("\
 Set unwinding of stack if a signal is received while in a call dummy."), _("\
 Show unwinding of stack if a signal is received while in a call dummy."), _("\
-The unwindonsignal lets the user determine what gdb should do if a signal\n\
+The unwind-on-signal lets the user determine what gdb should do if a signal\n\
 is received while in a function called from gdb (call dummy).  If set, gdb\n\
 unwinds the stack and restore the context to what as it was before the call.\n\
 The default is to stop in the frame where the signal was received."),
-			   NULL,
-			   show_unwind_on_signal_p,
-			   &setlist, &showlist);
+			       NULL,
+			       show_unwind_on_signal_p,
+			       &setlist, &showlist);
+  add_alias_cmd ("unwindonsignal", setshow_unwind_on_signal_cmds.set,
+		 no_class, 1, &setlist);
+  add_alias_cmd ("unwindonsignal", setshow_unwind_on_signal_cmds.show,
+		 no_class, 1, &showlist);
 
   add_setshow_boolean_cmd ("unwind-on-terminating-exception", no_class,
 			   &unwind_on_terminating_exception_p, _("\
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index 603bbfe0aa8..494b6dfa96f 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -46,7 +46,7 @@ proc do_function_calls {prototypes} {
 
     # If any of these calls segv we don't want to affect subsequent tests.
     # E.g., we want to ensure register values are restored.
-    gdb_test_no_output "set unwindonsignal on"
+    gdb_test_no_output "set unwind-on-signal on"
 
     gdb_test "p t_char_values(0,0)" " = 0"
     gdb_test "p t_char_values('a','b')" " = 1"
@@ -237,7 +237,7 @@ proc do_function_calls {prototypes} {
     	"call inferior func with struct - returns char *"
 
     # Restore default value.
-    gdb_test_no_output "set unwindonsignal off"
+    gdb_test_no_output "set unwind-on-signal off"
 }
 
 # Procedure to get current content of all registers.
diff --git a/gdb/testsuite/gdb.base/infcall-failure.exp b/gdb/testsuite/gdb.base/infcall-failure.exp
index 89ddfb81546..8d08555682a 100644
--- a/gdb/testsuite/gdb.base/infcall-failure.exp
+++ b/gdb/testsuite/gdb.base/infcall-failure.exp
@@ -137,7 +137,7 @@ proc_with_prefix run_cond_hits_segfault_test { async_p non_stop_p } {
 	     "Error in testing condition for breakpoint ${bp_1_num}:" \
 	     "The program being debugged was signaled while in a function called from GDB\\." \
 	     "GDB remains in the frame where the signal was received\\." \
-	     "To change this behavior use \"set unwindonsignal on\"\\." \
+	     "To change this behavior use \"set unwind-on-signal on\"\\." \
 	     "Evaluation of the expression containing the function" \
 	     "\\(func_segfault\\) will be abandoned\\." \
 	     "When the function is done executing, GDB will silently stop\\."]
@@ -166,7 +166,7 @@ proc_with_prefix run_call_hits_segfault_test { async_p non_stop_p } {
 	     "${::decimal}\\s+\[^\r\n\]+Segfault here\[^\r\n\]+" \
 	     "The program being debugged was signaled while in a function called from GDB\\." \
 	     "GDB remains in the frame where the signal was received\\." \
-	     "To change this behavior use \"set unwindonsignal on\"\\." \
+	     "To change this behavior use \"set unwind-on-signal on\"\\." \
 	     "Evaluation of the expression containing the function" \
 	     "\\(func_segfault\\) will be abandoned\\." \
 	     "When the function is done executing, GDB will silently stop\\."]
diff --git a/gdb/testsuite/gdb.base/unwindonsignal.exp b/gdb/testsuite/gdb.base/unwindonsignal.exp
index 7e8de6bee77..31793556c2c 100644
--- a/gdb/testsuite/gdb.base/unwindonsignal.exp
+++ b/gdb/testsuite/gdb.base/unwindonsignal.exp
@@ -34,13 +34,29 @@ gdb_test "break stop_here" "Breakpoint \[0-9\]* at .*"
 gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, stop_here.*" \
     "continue to breakpoint at stop_here"
 
-# Turn on unwindonsignal.
-gdb_test_no_output "set unwindonsignal on" \
-	"setting unwindonsignal"
+# Turn on unwind-on-signal.
+gdb_test_no_output "set unwind-on-signal on" \
+	"setting unwind-on-signal"
 
-gdb_test "show unwindonsignal" \
+gdb_test "show unwind-on-signal" \
 	"Unwinding of stack .* is on." \
-	"showing unwindonsignal"
+	"showing unwind-on-signal"
+
+# For backward compatibility we maintain a 'unwindonsignal' alias for
+# 'unwind-on-signal', check it now.
+gdb_test "show unwindonsignal" \
+    "Unwinding of stack .* is on\\." \
+    "showing unwindonsignal alias"
+
+gdb_test_no_output "set unwindonsignal off" \
+    "setting unwindonsignal alias to off"
+
+gdb_test "show unwind-on-signal" \
+    "Unwinding of stack .* is off\\." \
+    "showing unwind-on-signal after setting via alias"
+
+gdb_test_no_output "set unwindonsignal on" \
+    "setting unwindonsignal alias to on"
 
 # Call function (causing the program to get a signal), and see if gdb handles
 # it properly.
@@ -49,7 +65,7 @@ if {[gdb_test "call gen_signal ()"  \
 	      "The program being debugged received signal SIGABRT, Aborted" \
 	      "while in a function called from GDB\\.  GDB has restored the context" \
 	      "to what it was before the call\\.  To change this behavior use" \
-	      "\"set unwindonsignal off\"\\.  Evaluation of the expression containing" \
+	      "\"set unwind-on-signal off\"\\.  Evaluation of the expression containing" \
 	      "the function \\(gen_signal\\) will be abandoned\\."] \
 	 "unwindonsignal, inferior function call signaled"] != 0} {
     return 0
@@ -58,15 +74,15 @@ if {[gdb_test "call gen_signal ()"  \
 # Verify the stack got unwound.
 gdb_test "bt" \
     "#0 *\[x0-9a-f in\]*stop_here \\(.*\\) at .*#1 *\[x0-9a-f in\]*main \\(.*\\) at .*" \
-	"unwindonsignal, stack unwound"
+	"stack unwound"
 
 # Verify the dummy frame got removed from dummy_frame_stack.
 gdb_test_multiple "maint print dummy-frames" \
-	"unwindonsignal, dummy frame removed" {
+	"unwind-on-signal, dummy frame removed" {
     -re "\[\r\n\]*.*stack=.*code=.*\[\r\n\]+$gdb_prompt $" {
-	fail "unwindonsignal, dummy frame removed"
+	fail $gdb_test_name
     }
     -re "\[\r\n\]+$gdb_prompt $" {
-	pass "unwindonsignal, dummy frame removed"
+	pass $gdb_test_name
     }
 }
diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gdb.compile/compile-cplus.exp
index 40191a08b1a..711f299574d 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus.exp
@@ -131,13 +131,13 @@ gdb_test "return" "\r\n#0  main .*" "return" \
 	 "Make _gdb_expr\\(__gdb_regs\\*\\) return now\\? \\(y or n\\) " "y"
 gdb_test "info sym $infcall_pc" "\r\nNo symbol matches .*" "info sym not found"
 
-gdb_test_no_output "set unwindonsignal on"
+gdb_test_no_output "set unwind-on-signal on"
 gdb_test "compile code *(volatile int *) 0 = 0;" \
     [multi_line \
 	 "The program being debugged received signal SIGSEGV, Segmentation fault" \
 	 "while in a function called from GDB\\.  GDB has restored the context" \
 	 "to what it was before the call\\.  To change this behavior use" \
-	 "\"set unwindonsignal off\"\\.  Evaluation of the expression containing" \
+	 "\"set unwind-on-signal off\"\\.  Evaluation of the expression containing" \
 	 "the function \\(_gdb_expr\\(__gdb_regs\\*\\)\\) will be abandoned\\."] \
     "compile code segfault second"
 
@@ -313,7 +313,7 @@ gdb_test "compile code static const int readonly = 1; *(int *) &readonly = 2;" \
 	 "The program being debugged received signal SIGSEGV, Segmentation fault" \
 	 "while in a function called from GDB\\.  GDB has restored the context" \
 	 "to what it was before the call\\.  To change this behavior use" \
-	 "\"set unwindonsignal off\"\\.  Evaluation of the expression containing" \
+	 "\"set unwind-on-signal off\"\\.  Evaluation of the expression containing" \
 	 "the function \\(_gdb_expr\\(__gdb_regs\\*\\)\\) will be abandoned\\."]
 gdb_test_no_output "set debug compile off"
 
diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp
index fed7b04a4c3..528ae247637 100644
--- a/gdb/testsuite/gdb.compile/compile.exp
+++ b/gdb/testsuite/gdb.compile/compile.exp
@@ -157,13 +157,13 @@ gdb_test "return" "\r\n#0  main .*" "return" \
 	 "Make _gdb_expr return now\\? \\(y or n\\) " "y"
 gdb_test "info sym $infcall_pc" "\r\nNo symbol matches .*" "info sym not found"
 
-gdb_test_no_output "set unwindonsignal on"
+gdb_test_no_output "set unwind-on-signal on"
 gdb_test "compile code *(volatile int *) 0 = 0;" \
     [multi_line \
 	 "The program being debugged received signal SIGSEGV, Segmentation fault" \
 	 "while in a function called from GDB\\.  GDB has restored the context" \
 	 "to what it was before the call\\.  To change this behavior use" \
-	 "\"set unwindonsignal off\"\\.  Evaluation of the expression containing" \
+	 "\"set unwind-on-signal off\"\\.  Evaluation of the expression containing" \
 	 "the function \\(_gdb_expr\\) will be abandoned\\."] \
     "compile code segfault second"
 
@@ -321,7 +321,7 @@ gdb_test "compile code static const int readonly = 1; *(int *) &readonly = 2;" \
 	 "The program being debugged received signal SIGSEGV, Segmentation fault" \
 	 "while in a function called from GDB\\.  GDB has restored the context" \
 	 "to what it was before the call\\.  To change this behavior use" \
-	 "\"set unwindonsignal off\"\\.  Evaluation of the expression containing" \
+	 "\"set unwind-on-signal off\"\\.  Evaluation of the expression containing" \
 	 "the function \\(_gdb_expr\\) will be abandoned\\."]
 gdb_test_no_output "set debug compile off"
 
diff --git a/gdb/testsuite/gdb.cp/gdb2495.exp b/gdb/testsuite/gdb.cp/gdb2495.exp
index 1b3168ee963..7fbadb2c4f1 100644
--- a/gdb/testsuite/gdb.cp/gdb2495.exp
+++ b/gdb/testsuite/gdb.cp/gdb2495.exp
@@ -98,10 +98,10 @@ if {![runto_main]} {
 # behaviour; it should not.  Test both on and off states.
 
 # Turn on unwind on signal behaviour.
-gdb_test_no_output "set unwindonsignal on"
+gdb_test_no_output "set unwind-on-signal on"
 
 # Check that it is turned on.
-gdb_test "show unwindonsignal" \
+gdb_test "show unwind-on-signal" \
     "signal is received while in a call dummy is on.*" \
     "turn on unwind on signal"
 
@@ -112,20 +112,20 @@ gdb_test "p exceptions.raise_signal(1)" \
 	 "The program being debugged received signal SIGABRT, Aborted" \
 	 "while in a function called from GDB\\.  GDB has restored the context" \
 	 "to what it was before the call\\.  To change this behavior use" \
-	 "\"set unwindonsignal off\"\\.  Evaluation of the expression containing" \
+	 "\"set unwind-on-signal off\"\\.  Evaluation of the expression containing" \
 	 "the function \\(SimpleException::raise_signal\\(int\\)\\) will be abandoned\\."]\
-    "check for unwindonsignal off message"
+    "check for unwind-on-signal off message"
 
 # And reverse - turn off again.
-gdb_test_no_output "set unwindonsignal off"
+gdb_test_no_output "set unwind-on-signal off"
 
 # Check that it is actually turned off.
-gdb_test "show unwindonsignal" \
+gdb_test "show unwind-on-signal" \
     "signal is received while in a call dummy is off.*" \
     "turn off unwind on signal"
 
 # Check to see if new behaviour interferes with
 # normal signal handling in inferior function calls.
 gdb_test "p exceptions.raise_signal(1)" \
-    "To change this behavior use \"set unwindonsignal on\".*" \
-    "check for unwindonsignal on message"
+    "To change this behavior use \"set unwind-on-signal on\".*" \
+    "check for unwind-on-signal on message"
diff --git a/gdb/testsuite/gdb.fortran/function-calls.exp b/gdb/testsuite/gdb.fortran/function-calls.exp
index 3e698a55e9e..e0b35d697ad 100644
--- a/gdb/testsuite/gdb.fortran/function-calls.exp
+++ b/gdb/testsuite/gdb.fortran/function-calls.exp
@@ -44,7 +44,7 @@ if {![runto [gdb_get_line_number "post_init"]]} {
 }
 
 # Use inspired by gdb.base/callfuncs.exp.
-gdb_test_no_output "set unwindonsignal on"
+gdb_test_no_output "set unwind-on-signal on"
 
 # Baseline: function and subroutine call with no arguments.
 gdb_test "p no_arg()" " = .TRUE."
diff --git a/gdb/testsuite/gdb.mi/mi-condbreak-fail.exp b/gdb/testsuite/gdb.mi/mi-condbreak-fail.exp
index f84f874593d..fdcfa9bb40c 100644
--- a/gdb/testsuite/gdb.mi/mi-condbreak-fail.exp
+++ b/gdb/testsuite/gdb.mi/mi-condbreak-fail.exp
@@ -43,7 +43,7 @@ proc run_test { unwind_on_signal } {
 	return
     }
 
-    mi_gdb_test "-gdb-set unwindonsignal ${unwind_on_signal}" {\^done} \
+    mi_gdb_test "-gdb-set unwind-on-signal ${unwind_on_signal}" {\^done} \
 	"set unwind-on-signal"
 
     # Create the conditional breakpoint.
@@ -70,7 +70,7 @@ proc run_test { unwind_on_signal } {
 		 "&\"The program being debugged received signal SIGSEGV, Segmentation fault\\\\n\"" \
 		 "&\"while in a function called from GDB\\.  GDB has restored the context\\\\n\"" \
 		 "&\"to what it was before the call\\.  To change this behavior use\\\\n\"" \
-		 "&\"\\\\\"set unwindonsignal off\\\\\"\\.  Evaluation of the expression containing\\\\n\"" \
+		 "&\"\\\\\"set unwind-on-signal off\\\\\"\\.  Evaluation of the expression containing\\\\n\"" \
 		 "&\"the function \\(cond_fail\\) will be abandoned\\.\\\\n\"" \
 		 "=breakpoint-modified,bkpt={number=\"$bpnum\",type=\"breakpoint\",\[^\r\n\]+times=\"1\",\[^\r\n\]+}" \
 		 "~\"\\\\n\"" \
@@ -92,7 +92,7 @@ proc run_test { unwind_on_signal } {
 		 "&\"Error in testing condition for breakpoint $bpnum:\\\\n\"" \
 		 "&\"The program being debugged was signaled while in a function called from GDB\\.\\\\n\"" \
 		 "&\"GDB remains in the frame where the signal was received\\.\\\\n\"" \
-		 "&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\.\\\\n\"" \
+		 "&\"To change this behavior use \\\\\"set unwind-on-signal on\\\\\"\\.\\\\n\"" \
 		 "&\"Evaluation of the expression containing the function\\\\n\"" \
 		 "&\"\\(cond_fail\\) will be abandoned\\.\\\\n\"" \
 		 "&\"When the function is done executing, GDB will silently stop\\.\\\\n\"" \
diff --git a/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp b/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp
index 4f4e3c1f37b..e35ad8f9999 100644
--- a/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp
+++ b/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp
@@ -103,7 +103,7 @@ proc run_test { unwind_on_exception } {
 		 "&\"Error in testing condition for breakpoint $bpnum:\\\\n\"" \
 		 "&\"The program being debugged was signaled while in a function called from GDB\\.\\\\n\"" \
 		 "&\"GDB remains in the frame where the signal was received\\.\\\\n\"" \
-		 "&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\.\\\\n\"" \
+		 "&\"To change this behavior use \\\\\"set unwind-on-signal on\\\\\"\\.\\\\n\"" \
 		 "&\"Evaluation of the expression containing the function\\\\n\"" \
 		 "&\"\\(cond_throw\\(\\)\\) will be abandoned\\.\\\\n\"" \
 		 "&\"When the function is done executing, GDB will silently stop\\.\\\\n\"" \
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.exp b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
index 4e4a72225a8..b059d126968 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.exp
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
@@ -94,7 +94,7 @@ mi_gdb_test "409-stack-list-frames 0 0" \
 # 
 
 mi_gdb_test "410-data-evaluate-expression bar()" \
-  ".*410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\".\\\\nEvaluation of the expression containing the function\\\\n\\(bar\\) will be abandoned.\\\\nWhen the function is done executing, GDB will silently stop.\"" \
+  ".*410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwind-on-signal on\\\\\".\\\\nEvaluation of the expression containing the function\\\\n\\(bar\\) will be abandoned.\\\\nWhen the function is done executing, GDB will silently stop.\"" \
   "call inferior function which raises exception"
 
 mi_gdb_test "411-stack-list-frames" "411\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"}.*\\\]" "backtrace from inferior function at exception"
diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
index d6069ebaa58..c9508c9d67e 100644
--- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
+++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
@@ -173,7 +173,7 @@ proc_with_prefix run_bp_cond_segfaults { target_async target_non_stop } {
 	     "Error in testing condition for breakpoint ${bp_1_num}:" \
 	     "The program being debugged was signaled while in a function called from GDB\\." \
 	     "GDB remains in the frame where the signal was received\\." \
-	     "To change this behavior use \"set unwindonsignal on\"\\." \
+	     "To change this behavior use \"set unwind-on-signal on\"\\." \
 	     "Evaluation of the expression containing the function" \
 	     "\\(function_that_segfaults\\) will be abandoned\\." \
 	     "When the function is done executing, GDB will silently stop\\."]
diff --git a/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp b/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp
index 4beefd8c9c8..11d9fb2d6d4 100644
--- a/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp
+++ b/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test use of unwindonsignal when a hand function call that gets interrupted
+# Test use of unwind-on-signal when a hand function call that gets interrupted
 # by a signal in another thread.
 
 set NR_THREADS 4
@@ -49,12 +49,12 @@ gdb_test "continue" \
 # We want the main thread (hand_call_with_signal) and
 # thread 1 (sigabrt_handler) to both run.
 
-# Do turn on unwindonsignal.
+# Do turn on unwind-on-signal.
 # We want to test gdb handling of the current thread changing when
 # unwindonsignal is in effect.
-gdb_test_no_output "set unwindonsignal on" \
+gdb_test_no_output "set unwind-on-signal on" \
 	"setting unwindonsignal"
-gdb_test "show unwindonsignal" \
+gdb_test "show unwind-on-signal" \
 	"Unwinding of stack .* is on." \
 	"showing unwindonsignal"
 
-- 
2.25.4


^ permalink raw reply	[relevance 6%]

* [PATCH 1/1] testsuite, btrace: update btrace testsuite to test all btrace recording methods
  @ 2024-03-04  8:23  2% ` Abdul Basit Ijaz
  0 siblings, 0 replies; 200+ results
From: Abdul Basit Ijaz @ 2024-03-04  8:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: abdul.b.ijaz, markus.t.metzger, blarsen

From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>

With this change, gdb.btrace will, instead of selecting the
default recording method, run all tests for all available and
applicable methods. This increases testing coverage.

2024-03-02 Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
---
 gdb/testsuite/gdb.btrace/buffer-size.exp      |  37 +-
 gdb/testsuite/gdb.btrace/data.exp             |  64 +--
 gdb/testsuite/gdb.btrace/delta.exp            | 102 +++--
 gdb/testsuite/gdb.btrace/dlopen.exp           |  37 +-
 .../gdb.btrace/enable-new-thread.exp          |  35 +-
 gdb/testsuite/gdb.btrace/enable-running.exp   |  59 +--
 gdb/testsuite/gdb.btrace/enable.exp           | 153 ++++---
 gdb/testsuite/gdb.btrace/exception.exp        | 103 +++--
 .../gdb.btrace/function_call_history.exp      | 414 +++++++++---------
 gdb/testsuite/gdb.btrace/gcore.exp            |  34 +-
 .../gdb.btrace/instruction_history.exp        | 303 ++++++-------
 gdb/testsuite/gdb.btrace/multi-inferior.exp   |  62 +--
 .../gdb.btrace/multi-thread-step.exp          | 106 ++---
 gdb/testsuite/gdb.btrace/nohist.exp           |  30 +-
 gdb/testsuite/gdb.btrace/non-stop.exp         | 305 ++++++-------
 gdb/testsuite/gdb.btrace/reconnect.exp        |  94 ++--
 gdb/testsuite/gdb.btrace/record_goto-step.exp |  39 +-
 gdb/testsuite/gdb.btrace/record_goto.exp      | 310 ++++++-------
 gdb/testsuite/gdb.btrace/rn-dl-bind.exp       |  61 +--
 gdb/testsuite/gdb.btrace/segv.exp             |  40 +-
 gdb/testsuite/gdb.btrace/step.exp             |  48 +-
 gdb/testsuite/gdb.btrace/stepi.exp            | 205 ++++-----
 gdb/testsuite/gdb.btrace/tailcall-only.exp    |  92 ++--
 gdb/testsuite/gdb.btrace/tailcall.exp         | 133 +++---
 gdb/testsuite/gdb.btrace/tsx.exp              |   2 +-
 .../gdb.btrace/unknown_functions.exp          |  66 +--
 gdb/testsuite/gdb.btrace/vdso.exp             |  34 +-
 .../gdb.python/py-record-btrace-threads.exp   |  75 ++--
 gdb/testsuite/lib/gdb.exp                     | 124 +++---
 29 files changed, 1689 insertions(+), 1478 deletions(-)

diff --git a/gdb/testsuite/gdb.btrace/buffer-size.exp b/gdb/testsuite/gdb.btrace/buffer-size.exp
index 1008fa8037b..196a62ed133 100644
--- a/gdb/testsuite/gdb.btrace/buffer-size.exp
+++ b/gdb/testsuite/gdb.btrace/buffer-size.exp
@@ -20,23 +20,30 @@
 require allow_btrace_tests
 
 standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
-    return -1
-}
 
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
-gdb_test_no_output "set record btrace bts buffer-size 1"
-gdb_test_no_output "set record btrace pt buffer-size 1"
-gdb_test "show record btrace bts buffer-size" "The record/replay bts buffer size is 1\."
-gdb_test "show record btrace pt buffer-size" "The record/replay pt buffer size is 1\."
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
 
-gdb_test_no_output "record btrace"
-gdb_test "info record" [multi_line \
-  "Active record target: record-btrace" \
-  "Recording format: \[^\\\r\\\n\]*" \
-  "Buffer size: 4kB\." \
-  "Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
-  ]
+    gdb_test_no_output "set record btrace ${method} buffer-size 1"
+    gdb_test "show record btrace ${method} buffer-size" "The record/replay ${method} buffer size is 1\."
+
+    gdb_test_no_output "record btrace ${method}"
+    gdb_test "info record" [multi_line \
+	"Active record target: record-btrace" \
+	"Recording format: \[^\\\r\\\n\]*" \
+	"Buffer size: 4kB\." \
+	"Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
+	]
+}
diff --git a/gdb/testsuite/gdb.btrace/data.exp b/gdb/testsuite/gdb.btrace/data.exp
index 30a946c3633..eeb4b23f073 100644
--- a/gdb/testsuite/gdb.btrace/data.exp
+++ b/gdb/testsuite/gdb.btrace/data.exp
@@ -20,41 +20,49 @@
 require allow_btrace_tests
 
 standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
-    return -1
-}
 
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
-# trace the test code
-gdb_test_no_output "record btrace"
-gdb_test "next" ".*main\.3.*"
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
 
-# reverse step into test
-gdb_test "reverse-step" ".*test\.4.*"
+    # trace the test code
+    gdb_test_no_output "record btrace ${method}"
+    gdb_test "next" ".*main\.3.*"
 
-# we can't read memory while we're replaying
-with_test_prefix "replay" {
-    with_test_prefix "default" {
-	gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
-	gdb_test "print loc" "unavailable\[^\\\r\\\n\]*"
-    }
+    # reverse step into test
+    gdb_test "reverse-step" ".*test\.4.*"
 
-    # we can read memory if we explicitly allow it.
-    with_test_prefix "read-write" {
-	gdb_test_no_output "set record btrace replay-memory-access read-write"
-	gdb_test "print glob" "1"
-    }
+    # we can't read memory while we're replaying
+    with_test_prefix "replay" {
+	with_test_prefix "default" {
+	    gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
+	    gdb_test "print loc" "unavailable\[^\\\r\\\n\]*"
+	}
+
+	# we can read memory if we explicitly allow it.
+	with_test_prefix "read-write" {
+	    gdb_test_no_output "set record btrace replay-memory-access read-write"
+	    gdb_test "print glob" "1"
+	}
 
-    # we can't if we don't explicitly allow it.
-    with_test_prefix "read-only" {
-	gdb_test_no_output "set record btrace replay-memory-access read-only"
-	gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
+	# we can't if we don't explicitly allow it.
+	with_test_prefix "read-only" {
+	    gdb_test_no_output "set record btrace replay-memory-access read-only"
+	    gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
+	}
     }
-}
 
-# stop replaying and try again
-gdb_test "record goto end" ".*main\.3.*"
-gdb_test "print glob" "1"
+    # stop replaying and try again
+    gdb_test "record goto end" ".*main\.3.*"
+    gdb_test "print glob" "1"
+}
diff --git a/gdb/testsuite/gdb.btrace/delta.exp b/gdb/testsuite/gdb.btrace/delta.exp
index 4e4d06a1812..a6b25b78a54 100644
--- a/gdb/testsuite/gdb.btrace/delta.exp
+++ b/gdb/testsuite/gdb.btrace/delta.exp
@@ -20,64 +20,72 @@
 require allow_btrace_tests
 
 standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
-if ![runto_main] {
-    return -1
+proc check_trace {} {
+    gdb_test "info record" [multi_line \
+	"Active record target: record-btrace" \
+	"Recording format: .*" \
+	"Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \
+	]
 }
 
-# proceed to some sequential code
-gdb_test "next"
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
 
-# start tracing
-gdb_test_no_output "record btrace"
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
 
-# we start without trace
-with_test_prefix "no trace" {
-  gdb_test "info record" [multi_line \
-    "Active record target: record-btrace" \
-    "Recording format: .*" \
-    "Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for .*" \
-    ]
-  gdb_test "record instruction-history" "No trace\."
-  gdb_test "record function-call-history" "No trace\."
-}
+    # proceed to some sequential code
+    gdb_test "next"
 
-# we record each single-step, even if we have not seen a branch, yet.
-gdb_test "stepi"
+    # start tracing
+    gdb_test_no_output "record btrace ${method}"
 
-proc check_trace {} {
-  gdb_test "info record" [multi_line \
-    "Active record target: record-btrace" \
-    "Recording format: .*" \
-    "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \
-    ]
-}
+    # we start without trace
+    with_test_prefix "no trace" {
+	gdb_test "info record" [multi_line \
+	    "Active record target: record-btrace" \
+	    "Recording format: .*" \
+	    "Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for .*" \
+	    ]
+	gdb_test "record instruction-history" "No trace\."
+	gdb_test "record function-call-history" "No trace\."
+    }
 
-# make sure we don't extend the trace when we ask twice.
-with_test_prefix "once" {
-  check_trace
-}
+    # we record each single-step, even if we have not seen a branch, yet.
+    gdb_test "stepi"
 
-with_test_prefix "twice" {
-  check_trace
-}
+    # make sure we don't extend the trace when we ask twice.
+    with_test_prefix "once" {
+	check_trace
+    }
 
-# check that we can reverse-stepi that instruction
-with_test_prefix "reverse" {
-    gdb_test "reverse-stepi"
-    gdb_test "info record" [multi_line \
-      "Active record target: record-btrace" \
-      "Recording format: .*" \
-      "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \
-      "Replay in progress\.  At instruction 1\." \
-    ]
-}
+    with_test_prefix "twice" {
+	check_trace
+    }
 
-# and back
-with_test_prefix "forward" {
-    gdb_test "stepi"
-    check_trace
+    # check that we can reverse-stepi that instruction
+    with_test_prefix "reverse" {
+	gdb_test "reverse-stepi"
+	gdb_test "info record" [multi_line \
+	    "Active record target: record-btrace" \
+	    "Recording format: .*" \
+	    "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \
+	    "Replay in progress\.  At instruction 1\." \
+	    ]
+    }
+
+    # and back
+    with_test_prefix "forward" {
+	gdb_test "stepi"
+	check_trace
+    }
 }
diff --git a/gdb/testsuite/gdb.btrace/dlopen.exp b/gdb/testsuite/gdb.btrace/dlopen.exp
index d0e5a65e346..360a9807a2a 100644
--- a/gdb/testsuite/gdb.btrace/dlopen.exp
+++ b/gdb/testsuite/gdb.btrace/dlopen.exp
@@ -28,23 +28,30 @@ if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
     return -1
 }
 
-if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
+if { [build_executable "failed to prepare" $testfile $srcfile \
 	  [list additional_flags=-DDSO_NAME=\"$binfile_lib\" libs=-ldl]] } {
     return -1
 }
 
-if ![runto_main] {
-    return -1
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
+
+    # Trace the test function
+    #
+    gdb_test_no_output "record btrace ${method}"
+    gdb_test "next"
+
+    # The memory containing the library call we traced is already gone.
+    # Trace decode used to run into a SEGV after corrupting the cleanup chain.
+    #
+    # The test passes if we don't crash GDB.
+    #
+    gdb_test "info record"
 }
-
-# Trace the test function
-#
-gdb_test_no_output "record btrace"
-gdb_test "next"
-
-# The memory containing the library call we traced is already gone.
-# Trace decode used to run into a SEGV after corrupting the cleanup chain.
-#
-# The test passes if we don't crash GDB.
-#
-gdb_test "info record"
diff --git a/gdb/testsuite/gdb.btrace/enable-new-thread.exp b/gdb/testsuite/gdb.btrace/enable-new-thread.exp
index dbbe6a78516..46b63f061ee 100644
--- a/gdb/testsuite/gdb.btrace/enable-new-thread.exp
+++ b/gdb/testsuite/gdb.btrace/enable-new-thread.exp
@@ -20,21 +20,11 @@
 require allow_btrace_tests
 
 standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
-    return -1
-}
 
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile {debug pthreads}] {
     return -1
 }
 
-# Record the main thread.  Recording will automatically be enabled for the
-# other thread.
-gdb_test "record btrace"
-
-gdb_breakpoint [gdb_get_line_number "bp.1" $srcfile]
-gdb_continue_to_breakpoint "cont to bp.1" ".*/\\* bp\.1 \\*/.*"
-
 proc check_thread_recorded { num } {
     global decimal
 
@@ -49,5 +39,24 @@ proc check_thread_recorded { num } {
     }
 }
 
-check_thread_recorded 1
-check_thread_recorded 2
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+
+    if ![runto_main] {
+	continue
+    }
+
+    # Record the main thread.  Recording will automatically be enabled for the
+    # other thread.
+    gdb_test "record btrace ${method}"
+
+    gdb_breakpoint [gdb_get_line_number "bp.1" $srcfile]
+    gdb_continue_to_breakpoint "cont to bp.1" ".*/\\* bp\.1 \\*/.*"
+
+    check_thread_recorded 1
+    check_thread_recorded 2
+}
diff --git a/gdb/testsuite/gdb.btrace/enable-running.exp b/gdb/testsuite/gdb.btrace/enable-running.exp
index 0d3555ae739..bc8432f15ca 100644
--- a/gdb/testsuite/gdb.btrace/enable-running.exp
+++ b/gdb/testsuite/gdb.btrace/enable-running.exp
@@ -16,32 +16,13 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 require allow_btrace_tests
-
 standard_testfile
+
 if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug}] != "" } {
     untested "failed to prepare"
     return -1
 }
 
-# We need to enable non-stop mode for the remote case.
-save_vars { GDBFLAGS } {
-    append GDBFLAGS " -ex \"set non-stop on\""
-    clean_restart $testfile
-}
-
-if ![runto_main] {
-    return -1
-}
-
-set bp_1 [gdb_get_line_number "bp.1" $srcfile]
-
-gdb_breakpoint $bp_1
-gdb_continue_to_breakpoint "cont to $bp_1" ".*$bp_1\r\n.*"
-gdb_test "cont&" "Continuing\."
-
-# All threads are running.  Let's start recording.
-gdb_test_no_output "record btrace"
-
 proc check_tracing_enabled { thread } {
     global gdb_prompt
 
@@ -87,10 +68,36 @@ proc check_tracing_enabled { thread } {
     }
 }
 
-# Check that recording was started on each thread.
-foreach thread {1 2 3 4} {
-    check_tracing_enabled $thread
-}
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+
+    # We need to enable non-stop mode for the remote case.
+    save_vars { GDBFLAGS } {
+	append GDBFLAGS " -ex \"set non-stop on\""
+	clean_restart $testfile
+    }
+
+    if ![runto_main] {
+	continue
+    }
+
+    set bp_1 [gdb_get_line_number "bp.1" $srcfile]
 
-# Stop recording while all threads are running.
-gdb_test "record stop" "Process record is stopped \[^\\\r\\\n\]*"
+    gdb_breakpoint $bp_1
+    gdb_continue_to_breakpoint "cont to $bp_1" ".*$bp_1\r\n.*"
+    gdb_test "cont&" "Continuing\."
+
+    # All threads are running.  Let's start recording.
+    gdb_test_no_output "record btrace ${method}"
+
+    # Check that recording was started on each thread.
+    foreach thread {1 2 3 4} {
+	check_tracing_enabled $thread
+    }
+
+    # Stop recording while all threads are running.
+    gdb_test "record stop" "Process record is stopped \[^\\\r\\\n\]*"
+}
diff --git a/gdb/testsuite/gdb.btrace/enable.exp b/gdb/testsuite/gdb.btrace/enable.exp
index 4e39c07472b..8a8d09c8871 100644
--- a/gdb/testsuite/gdb.btrace/enable.exp
+++ b/gdb/testsuite/gdb.btrace/enable.exp
@@ -19,79 +19,90 @@
 
 require allow_btrace_tests
 
-# start fresh - without an executable
-gdb_exit
-gdb_start
-
-# record cannot be stopped, if it was never active
-gdb_test "record stop" "No recording is currently active\\..*" "record stop without target"
-
-# btrace cannot be enabled without a running inferior
-gdb_test "record btrace" "The program is not being run\\." "record btrace without running program"
-
-# no function and no instruction history without btrace enabled
-gdb_test "record function-call-history" "No recording is currently active\\..*" "record function-call-history without target"
-gdb_test "record instruction-history" "No recording is currently active\\..*" "record instruction-history without target"
-gdb_test "info record" "No recording is currently active\\." "info record without target"
-
 standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile {} {debug}] {
-    return -1
-}
-
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile {} {debug}] {
     return -1
 }
 
-# enable btrace
-gdb_test_no_output "record btrace" "record btrace"
-gdb_test "record function-call-history" "No trace\\." "record function-call-history without trace"
-gdb_test "record instruction-history" "No trace\\." "record instruction-history without trace"
-
-# btrace cannot be enabled twice
-gdb_test "record btrace" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record btrace the second time"
-
-# full record cannot be activated as long as btrace is active
-gdb_test "record full" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record full cannot be enabled"
-
-# no trace recorded yet
-gdb_test "info record" "Active record target: record-btrace\r
-.*\r
-Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for thread 1.*\\." "info record without trace"
-
-# stop btrace record
-gdb_test "record stop" "Process record is stopped and all execution logs are deleted\\."
-gdb_test "record stop" "No recording is currently active\\..*" "record stop the second time"
-
-# enable btrace again
-gdb_test_no_output "record btrace" "record btrace re-enable"
-gdb_test "record btrace" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record btrace re-enable twice"
-
-# continue to the end and make sure we don't die
-gdb_test "continue" ".*Inferior.*exited.*" "continue to end"
-
-# allow_gdbserver_tests requires GDB not running.
-gdb_exit
-
-# skip the rerun test when using gdbserver
-# otherwise rerun twice, target should be automatically disabled
-load_lib gdbserver-support.exp
-require allow_gdbserver_tests
-clean_restart $testfile
-if ![runto_main] {
-    return -1
-}
-if ![runto_main] {
-    return -1
-}
-
-# make sure record-btrace can be enabled after re-run
-clean_restart $testfile
-if ![runto_main] {
-    return -1
-}
-gdb_test_no_output "record btrace" "enable after restart"
-if ![runto_main] {
-    return -1
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
+
+    # start fresh - without an executable
+    gdb_exit
+    gdb_start
+
+    # record cannot be stopped, if it was never active
+    gdb_test "record stop" "No recording is currently active\\..*" "record stop without target"
+
+    # btrace cannot be enabled without a running inferior
+    gdb_test "record btrace ${method}" "The program is not being run\\." "record btrace without running program"
+
+    # no function and no instruction history without btrace enabled
+    gdb_test "record function-call-history" "No recording is currently active\\..*" "record function-call-history without target"
+    gdb_test "record instruction-history" "No recording is currently active\\..*" "record instruction-history without target"
+    gdb_test "info record" "No recording is currently active\\." "info record without target"
+
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
+
+    # enable btrace
+    gdb_test_no_output "record btrace ${method}" "record btrace ${method}"
+    gdb_test "record function-call-history" "No trace\\." "record function-call-history without trace"
+    gdb_test "record instruction-history" "No trace\\." "record instruction-history without trace"
+
+    # btrace cannot be enabled twice
+    gdb_test "record btrace ${method}" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record btrace ${method} the second time"
+
+    # full record cannot be activated as long as btrace is active
+    gdb_test "record full" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record full cannot be enabled"
+
+    # no trace recorded yet
+    gdb_test "info record" "Active record target: record-btrace\r.*Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for thread 1.*\\." "info record without trace"
+
+    # stop btrace record
+    gdb_test "record stop" "Process record is stopped and all execution logs are deleted\\."
+    gdb_test "record stop" "No recording is currently active\\..*" "record stop the second time"
+
+    # enable btrace again
+    gdb_test_no_output "record btrace ${method}" "record btrace ${method} re-enable"
+    gdb_test "record btrace ${method}" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record btrace ${method} re-enable twice"
+
+    # continue to the end and make sure we don't die
+    gdb_test "continue" ".*Inferior.*exited.*" "continue to end"
+
+    # allow_gdbserver_tests requires GDB not running.
+    gdb_exit
+
+    # skip the rerun test when using gdbserver
+    # otherwise rerun twice, target should be automatically disabled
+    load_lib gdbserver-support.exp
+    require allow_gdbserver_tests
+    clean_restart $testfile
+    if ![runto_main] {
+	continue
+    }
+    if ![runto_main] {
+	continue
+    }
+
+    # make sure record-btrace can be enabled after re-run
+    clean_restart $testfile
+    if ![runto_main] {
+	continue
+    }
+    gdb_test_no_output "record btrace" "enable after restart"
+    if ![runto_main] {
+	continue
+    }
+    gdb_test_no_output "record btrace" "enable after re-run"
 }
-gdb_test_no_output "record btrace" "enable after re-run"
diff --git a/gdb/testsuite/gdb.btrace/exception.exp b/gdb/testsuite/gdb.btrace/exception.exp
index 61cc6c904b6..a4b6a4fab62 100755
--- a/gdb/testsuite/gdb.btrace/exception.exp
+++ b/gdb/testsuite/gdb.btrace/exception.exp
@@ -22,59 +22,68 @@ require allow_btrace_tests
 # We expect a specific function call history.  This gets messed up with
 # PIE on 32-bit.
 standard_testfile exception.cc
-if [prepare_for_testing "failed to prepare" $testfile $srcfile \
+
+if [build_executable "failed to prepare" $testfile $srcfile \
 	{nopie c++ debug}] {
     return -1
 }
 
-if ![runto_main] {
-    return -1
-}
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
 
-# we want to see the full trace for this test
-gdb_test_no_output "set record function-call-history-size 0"
+    if ![runto_main] {
+	continue
+    }
 
-# set bp
-set bp_1 [gdb_get_line_number "bp.1" $srcfile]
-set bp_2 [gdb_get_line_number "bp.2" $srcfile]
-gdb_breakpoint $bp_1
-gdb_breakpoint $bp_2
+    # we want to see the full trace for this test
+    gdb_test_no_output "set record function-call-history-size 0"
 
-# trace the code between the two breakpoints
-gdb_continue_to_breakpoint "cont to bp.1" ".*$srcfile:$bp_1\r\n.*"
-# increase the BTS buffer size - the trace can be quite big
-gdb_test_no_output "set record btrace bts buffer-size 128000"
-gdb_test_no_output "record btrace"
-gdb_continue_to_breakpoint "cont to bp.2" ".*$srcfile:$bp_2\r\n.*"
+    # set bp
+    set bp_1 [gdb_get_line_number "bp.1" $srcfile]
+    set bp_2 [gdb_get_line_number "bp.2" $srcfile]
+    gdb_breakpoint $bp_1
+    gdb_breakpoint $bp_2
 
-# show the flat branch trace
-send_gdb "record function-call-history 1\n"
-gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \
-  [multi_line \
-    "1\tmain\\(\\)" \
-    "2\ttest\\(\\)" \
-    "3\tfoo\\(\\)" \
-    "4\tbar\\(\\)" \
-    "5\tbad\\(\\)\r" \
-  ] "" \
-  [multi_line \
-    "\[0-9\]*\ttest\\(\\)" \
-    "\[0-9\]*\tmain\\(\\)" \
-  ] "" \
-  ]
+    # trace the code between the two breakpoints
+    gdb_continue_to_breakpoint "cont to bp.1" ".*$srcfile:$bp_1\r\n.*"
+    # increase the BTS buffer size - the trace can be quite big for bts method
+    gdb_test_no_output "set record btrace ${method} buffer-size 128000"
+    gdb_test_no_output "record btrace ${method}"
+    gdb_continue_to_breakpoint "cont to bp.2" ".*$srcfile:$bp_2\r\n.*"
 
-# show the branch trace with calls indented
-send_gdb "record function-call-history /c 1\n"
-gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
-  [multi_line \
-    "1\tmain\\(\\)" \
-    "2\t  test\\(\\)" \
-    "3\t    foo\\(\\)" \
-    "4\t      bar\\(\\)" \
-    "5\t        bad\\(\\)\r" \
-  ] "" \
-  [multi_line \
-    "\[0-9\]*\t  test\\(\\)" \
-    "\[0-9\]*\tmain\\(\\)" \
-  ] "" \
-  ]
+    # show the flat branch trace
+    send_gdb "record function-call-history 1\n"
+    gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \
+	[multi_line \
+	    "1\tmain\\(\\)" \
+	    "2\ttest\\(\\)" \
+	    "3\tfoo\\(\\)" \
+	    "4\tbar\\(\\)" \
+	    "5\tbad\\(\\)\r" \
+	] "" \
+	[multi_line \
+	    "\[0-9\]*\ttest\\(\\)" \
+	    "\[0-9\]*\tmain\\(\\)" \
+	] "" \
+    ]
+
+    # show the branch trace with calls indented
+    send_gdb "record function-call-history /c 1\n"
+    gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
+	[multi_line \
+	    "1\tmain\\(\\)" \
+	    "2\t  test\\(\\)" \
+	    "3\t    foo\\(\\)" \
+	    "4\t      bar\\(\\)" \
+	    "5\t        bad\\(\\)\r" \
+	] "" \
+	[multi_line \
+	    "\[0-9\]*\t  test\\(\\)" \
+	    "\[0-9\]*\tmain\\(\\)" \
+	] "" \
+    ]
+}
diff --git a/gdb/testsuite/gdb.btrace/function_call_history.exp b/gdb/testsuite/gdb.btrace/function_call_history.exp
index ce3d1a02ff6..1e332ff8e1c 100644
--- a/gdb/testsuite/gdb.btrace/function_call_history.exp
+++ b/gdb/testsuite/gdb.btrace/function_call_history.exp
@@ -22,22 +22,11 @@ require allow_btrace_tests
 # We expect a specific function call history.  This gets messed up with
 # PIE on 32-bit.
 standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile {} {nopie debug}] {
-    return -1
-}
 
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile {} {nopie debug}] {
     return -1
 }
 
-# start btrace
-gdb_test_no_output "record btrace"
-
-# set bp after increment loop and continue
-set bp_location [gdb_get_line_number "bp.1" $testfile.c]
-gdb_breakpoint $bp_location
-gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
-
 proc rec_fun_all {} {
   gdb_test "record function-call-history 1" [multi_line \
     "1\tmain" \
@@ -63,194 +52,215 @@ proc rec_fun_all {} {
     "21\tmain"]
 }
 
-# show function call history with unlimited size, we expect to see all 21 entries
-gdb_test_no_output "set record function-call-history-size 0"
-with_test_prefix "size unlimited" rec_fun_all
-
-# show function call history with size of 21, we expect to see all 21 entries
-gdb_test_no_output "set record function-call-history-size 21"
-with_test_prefix "size 21" rec_fun_all
-
-# show first 15 entries
-gdb_test_no_output "set record function-call-history-size 15"
-gdb_test "record function-call-history 1" [multi_line \
-  "1\tmain" \
-  "2\tinc" \
-  "3\tmain" \
-  "4\tinc" \
-  "5\tmain" \
-  "6\tinc" \
-  "7\tmain" \
-  "8\tinc" \
-  "9\tmain" \
-  "10\tinc" \
-  "11\tmain" \
-  "12\tinc" \
-  "13\tmain" \
-  "14\tinc" \
-  "15\tmain"] "forward - 1"
-
-# show last 6 entries
-gdb_test "record function-call-history +" [multi_line \
-  "16\tinc" \
-  "17\tmain" \
-  "18\tinc" \
-  "19\tmain" \
-  "20\tinc" \
-  "21\tmain"] "forward - 2"
-
-# moving further should not work
-gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 3"
-
-# make sure we cannot move any further a second time
-gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 4"
-
-# moving back showing the latest 15 function calls
-gdb_test "record function-call-history -" [multi_line \
-  "7\tmain" \
-  "8\tinc" \
-  "9\tmain" \
-  "10\tinc" \
-  "11\tmain" \
-  "12\tinc" \
-  "13\tmain" \
-  "14\tinc" \
-  "15\tmain" \
-  "16\tinc" \
-  "17\tmain" \
-  "18\tinc" \
-  "19\tmain" \
-  "20\tinc" \
-  "21\tmain"] "backward - 1"
-
-# moving further back shows the 6 first function calls
-gdb_test "record function-call-history -" [multi_line \
-  "1\tmain" \
-  "2\tinc" \
-  "3\tmain" \
-  "4\tinc" \
-  "5\tmain" \
-  "6\tinc"] "backward - 2"
-
-# moving further back shouldn't work
-gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 3"
-
-# make sure we cannot move any further back
-gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 4"
-
-# don't mess around with path names
-gdb_test_no_output "set filename-display basename"
-
-# moving forward again, but this time with file and line number, expected to see the first 15 entries
-gdb_test "record function-call-history /l +" [multi_line \
-  "\[0-9\]*\tmain\tat $srcfile:40,41" \
-  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
-  "\[0-9\]*\tmain\tat $srcfile:40,41" \
-  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
-  "\[0-9\]*\tmain\tat $srcfile:40,41" \
-  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
-  "\[0-9\]*\tmain\tat $srcfile:40,41" \
-  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
-  "\[0-9\]*\tmain\tat $srcfile:40,41" \
-  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
-  "\[0-9\]*\tmain\tat $srcfile:40,41" \
-  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
-  "\[0-9\]*\tmain\tat $srcfile:40,41" \
-  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
-  "\[0-9\]*\tmain\tat $srcfile:40,41" \
-  ] "forward /l - 1"
-
-# moving forward and expect to see the latest 6 entries
-gdb_test "record function-call-history /l +" [multi_line \
-  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
-  "\[0-9\]*\tmain\tat $srcfile:40,41" \
-  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
-  "\[0-9\]*\tmain\tat $srcfile:40,41" \
-  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
-  "\[0-9\]*\tmain\tat $srcfile:40,43" \
-  ] "forward /l - 2"
-
-# moving further forward shouldn't work
-gdb_test "record function-call-history /l +" "At the end of the branch trace record\\." "forward /l - 3"
-gdb_test "record function-call-history /l" "At the end of the branch trace record\\." "forward /l - 4"
-
-set expected_range [multi_line \
-  "4\tinc" \
-  "5\tmain" \
-  "6\tinc" \
-  "7\tmain" \
-  "8\tinc" \
-  "9\tmain" \
-  "10\tinc"]
-
-# show functions in instruction range
-gdb_test "record function-call-history 4,10" $expected_range
-gdb_test "record function-call-history 4,+7" $expected_range
-gdb_test "record function-call-history 10,-7" $expected_range
-gdb_test "record function-call-history 4,4" "4\tinc"
-
-# set bp after fib recursion and continue
-set bp_location [gdb_get_line_number "bp.2" $testfile.c]
-gdb_breakpoint $bp_location
-gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
-
-# at this point we expect to have main, fib, ..., fib, main, where fib occurs 9 times,
-# so we limit the output to only show the latest 11 function calls
-gdb_test_no_output "set record function-call-history-size 11"
-gdb_test "record function-call-history" [multi_line \
-  "21\tmain" \
-  "22\tfib" \
-  "23\tfib" \
-  "24\tfib" \
-  "25\tfib" \
-  "26\tfib" \
-  "27\tfib" \
-  "28\tfib" \
-  "29\tfib" \
-  "30\tfib" \
-  "31\tmain"] "recursive"
-
-# show indented function call history for fib
-gdb_test "record function-call-history /c 21, +11" [multi_line \
-  "21\tmain" \
-  "22\t  fib" \
-  "23\t    fib" \
-  "24\t  fib" \
-  "25\t    fib" \
-  "26\t      fib" \
-  "27\t    fib" \
-  "28\t      fib" \
-  "29\t    fib" \
-  "30\t  fib" \
-  "31\tmain" \
-  ] "indented"
-
-# make sure we can handle incomplete trace with respect to indentation
-if ![runto_main] {
-    return -1
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+
+    if ![runto_main] {
+	continue
+    }
+
+    # start btrace
+    gdb_test_no_output "record btrace ${method}"
+
+    # set bp after increment loop and continue
+    set bp_location [gdb_get_line_number "bp.1" $testfile.c]
+    gdb_breakpoint $bp_location
+    gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
+
+    # show function call history with unlimited size, we expect to see all 21 entries
+    gdb_test_no_output "set record function-call-history-size 0"
+    with_test_prefix "size unlimited" rec_fun_all
+
+    # show function call history with size of 21, we expect to see all 21 entries
+    gdb_test_no_output "set record function-call-history-size 21"
+    with_test_prefix "size 21" rec_fun_all
+
+    # show first 15 entries
+    gdb_test_no_output "set record function-call-history-size 15"
+    gdb_test "record function-call-history 1" [multi_line \
+	"1\tmain" \
+	"2\tinc" \
+	"3\tmain" \
+	"4\tinc" \
+	"5\tmain" \
+	"6\tinc" \
+	"7\tmain" \
+	"8\tinc" \
+	"9\tmain" \
+	"10\tinc" \
+	"11\tmain" \
+	"12\tinc" \
+	"13\tmain" \
+	"14\tinc" \
+	"15\tmain"] "forward - 1"
+
+    # show last 6 entries
+    gdb_test "record function-call-history +" [multi_line \
+	"16\tinc" \
+	"17\tmain" \
+	"18\tinc" \
+	"19\tmain" \
+	"20\tinc" \
+	"21\tmain"] "forward - 2"
+
+    # moving further should not work
+    gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 3"
+
+    # make sure we cannot move any further a second time
+    gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 4"
+
+    # moving back showing the latest 15 function calls
+    gdb_test "record function-call-history -" [multi_line \
+	"7\tmain" \
+	"8\tinc" \
+	"9\tmain" \
+	"10\tinc" \
+	"11\tmain" \
+	"12\tinc" \
+	"13\tmain" \
+	"14\tinc" \
+	"15\tmain" \
+	"16\tinc" \
+	"17\tmain" \
+	"18\tinc" \
+	"19\tmain" \
+	"20\tinc" \
+	"21\tmain"] "backward - 1"
+
+    # moving further back shows the 6 first function calls
+    gdb_test "record function-call-history -" [multi_line \
+	"1\tmain" \
+	"2\tinc" \
+	"3\tmain" \
+	"4\tinc" \
+	"5\tmain" \
+	"6\tinc"] "backward - 2"
+
+    # moving further back shouldn't work
+    gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 3"
+
+    # make sure we cannot move any further back
+    gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 4"
+
+    # don't mess around with path names
+    gdb_test_no_output "set filename-display basename"
+
+    # moving forward again, but this time with file and line number, expected to see the first 15 entries
+    gdb_test "record function-call-history /l +" [multi_line \
+	"\[0-9\]*\tmain\tat $srcfile:40,41" \
+	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
+	"\[0-9\]*\tmain\tat $srcfile:40,41" \
+	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
+	"\[0-9\]*\tmain\tat $srcfile:40,41" \
+	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
+	"\[0-9\]*\tmain\tat $srcfile:40,41" \
+	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
+	"\[0-9\]*\tmain\tat $srcfile:40,41" \
+	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
+	"\[0-9\]*\tmain\tat $srcfile:40,41" \
+	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
+	"\[0-9\]*\tmain\tat $srcfile:40,41" \
+	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
+	"\[0-9\]*\tmain\tat $srcfile:40,41" \
+    ] "forward /l - 1"
+
+    # moving forward and expect to see the latest 6 entries
+    gdb_test "record function-call-history /l +" [multi_line \
+	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
+	"\[0-9\]*\tmain\tat $srcfile:40,41" \
+	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
+	"\[0-9\]*\tmain\tat $srcfile:40,41" \
+	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
+	"\[0-9\]*\tmain\tat $srcfile:40,43" \
+
+    ] "forward /l - 2"
+
+    # moving further forward shouldn't work
+    gdb_test "record function-call-history /l +" "At the end of the branch trace record\\." "forward /l - 3"
+    gdb_test "record function-call-history /l" "At the end of the branch trace record\\." "forward /l - 4"
+
+    set expected_range [multi_line \
+	"4\tinc" \
+	"5\tmain" \
+	"6\tinc" \
+	"7\tmain" \
+	"8\tinc" \
+	"9\tmain" \
+	"10\tinc"]
+
+    # show functions in instruction range
+    gdb_test "record function-call-history 4,10" $expected_range
+    gdb_test "record function-call-history 4,+7" $expected_range
+    gdb_test "record function-call-history 10,-7" $expected_range
+    gdb_test "record function-call-history 4,4" "4\tinc"
+
+    # set bp after fib recursion and continue
+    set bp_location [gdb_get_line_number "bp.2" $testfile.c]
+    gdb_breakpoint $bp_location
+    gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
+
+    # at this point we expect to have main, fib, ..., fib, main, where fib occurs 9 times,
+    # so we limit the output to only show the latest 11 function calls
+    gdb_test_no_output "set record function-call-history-size 11"
+    gdb_test "record function-call-history" [multi_line \
+	"21\tmain" \
+	"22\tfib" \
+	"23\tfib" \
+	"24\tfib" \
+	"25\tfib" \
+	"26\tfib" \
+	"27\tfib" \
+	"28\tfib" \
+	"29\tfib" \
+	"30\tfib" \
+	"31\tmain"] "recursive"
+
+    # show indented function call history for fib
+    gdb_test "record function-call-history /c 21, +11" [multi_line \
+	"21\tmain" \
+	"22\t  fib" \
+	"23\t    fib" \
+	"24\t  fib" \
+	"25\t    fib" \
+	"26\t      fib" \
+	"27\t    fib" \
+	"28\t      fib" \
+	"29\t    fib" \
+	"30\t  fib" \
+	"31\tmain" \
+    ] "indented"
+
+    # make sure we can handle incomplete trace with respect to indentation
+    if ![runto_main] {
+	return -1
+    }
+    # navigate to the fib in line 24 above
+    gdb_breakpoint fib
+    gdb_continue_to_breakpoint "cont to fib.1"
+    gdb_continue_to_breakpoint "cont to fib.2"
+    gdb_continue_to_breakpoint "cont to fib.3"
+    gdb_continue_to_breakpoint "cont to fib.4"
+
+    # start tracing
+    gdb_test_no_output "record btrace ${method}" "start recording after rerun"
+
+    # continue until line 30 above
+    delete_breakpoints
+    set bp_location [gdb_get_line_number "bp.2" $testfile.c]
+    gdb_breakpoint $bp_location
+    gdb_continue_to_breakpoint "cont to bp.2" ".*$testfile.c:$bp_location\r\n.*"
+
+    # let's look at the trace. we expect to see the tail of the above listing.
+    gdb_test "record function-call-history /c" [multi_line \
+	"1\t      fib" \
+	"2\t    fib" \
+	"3\t      fib" \
+	"4\t    fib" \
+	"5\t  fib" \
+	"6\tmain" \
+    ] "indented tail"
 }
-# navigate to the fib in line 24 above
-gdb_breakpoint fib
-gdb_continue_to_breakpoint "cont to fib.1"
-gdb_continue_to_breakpoint "cont to fib.2"
-gdb_continue_to_breakpoint "cont to fib.3"
-gdb_continue_to_breakpoint "cont to fib.4"
-
-# start tracing
-gdb_test_no_output "record btrace" "start recording after rerun"
-
-# continue until line 30 above
-delete_breakpoints
-set bp_location [gdb_get_line_number "bp.2" $testfile.c]
-gdb_breakpoint $bp_location
-gdb_continue_to_breakpoint "cont to bp.2" ".*$testfile.c:$bp_location\r\n.*"
-
-# let's look at the trace. we expect to see the tail of the above listing.
-gdb_test "record function-call-history /c" [multi_line \
-  "1\t      fib" \
-  "2\t    fib" \
-  "3\t      fib" \
-  "4\t    fib" \
-  "5\t  fib" \
-  "6\tmain" \
-  ] "indented tail"
diff --git a/gdb/testsuite/gdb.btrace/gcore.exp b/gdb/testsuite/gdb.btrace/gcore.exp
index ff607b5643c..5400598d4b7 100644
--- a/gdb/testsuite/gdb.btrace/gcore.exp
+++ b/gdb/testsuite/gdb.btrace/gcore.exp
@@ -20,22 +20,30 @@
 require allow_btrace_tests
 
 standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
-    return -1
-}
 
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
-# trace the call to the test function
-gdb_test_no_output "record btrace"
-gdb_test "next" ".*main\.3.*"
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
 
-# start replaying
-gdb_test "record goto begin" ".*main\.2.*"
+    # trace the call to the test function
+    gdb_test_no_output "record btrace ${method}"
+    gdb_test "next" ".*main\.3.*"
 
-# generate a core file - this used to assert
-set corefile [host_standard_output_file core]
-gdb_test "generate-core-file $corefile" "Saved corefile $corefile" \
-    "generate-core-file core"
+    # start replaying
+    gdb_test "record goto begin" ".*main\.2.*"
+
+    # generate a core file - this used to assert
+    set corefile [standard_output_file core]
+    gdb_test "generate-core-file $corefile" "Saved corefile $corefile" \
+	"generate-core-file core"
+}
diff --git a/gdb/testsuite/gdb.btrace/instruction_history.exp b/gdb/testsuite/gdb.btrace/instruction_history.exp
index d3ff313c570..4b783a1c0aa 100644
--- a/gdb/testsuite/gdb.btrace/instruction_history.exp
+++ b/gdb/testsuite/gdb.btrace/instruction_history.exp
@@ -20,88 +20,10 @@
 require allow_btrace_tests
 
 standard_testfile .c .S
-if [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" {debug}] {
+if [build_executable "failed to prepare" $testfile "$srcfile $srcfile2" {debug}] {
     return -1
 }
 
-if ![runto_main] {
-    return -1
-}
-
-# set bp before loop and continue
-set bp_location [gdb_get_line_number "bp.1" $srcfile2]
-gdb_breakpoint $srcfile2:$bp_location
-gdb_continue_to_breakpoint "cont to $bp_location" ".*$srcfile2:$bp_location.*"
-
-# start btrace
-gdb_test_no_output "record btrace"
-
-# set bp after loop and continue
-set bp_location [gdb_get_line_number "bp.2" $srcfile2]
-gdb_breakpoint $srcfile2:$bp_location
-gdb_continue_to_breakpoint "cont to $bp_location" ".*$srcfile2:$bp_location.*"
-
-# The following test cases test if "browsing" through the
-# instruction history works as expected. So for the tests
-# it is necessary to count the number of lines that are
-# shown by the "record instruction-history" command.
-
-set traced {}
-set testname "determine number of recorded instructions"
-gdb_test_multiple "info record" $testname {
-    -re "Active record target: record-btrace\r\n.*\r\nRecorded \(\[0-9\]*\) instructions in \(\[0-9\]*\) functions \\\(0 gaps\\\) for thread 1 .*\\.\r\n$gdb_prompt $" {
-        set traced $expect_out(1,string)
-        pass $testname
-    }
-}
-
-# we have exactly 11 instructions here
-set message "exactly 11 instructions"
-if { $traced != 11 } {
-    fail $message
-} else {
-    pass $message
-}
-
-# test that we see the expected instructions
-gdb_test "record instruction-history 3,7" [multi_line \
-  "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  "4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
-  "5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  "6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  ]
-
-gdb_test "record instruction-history /f 3,+5" [multi_line \
-  "3\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  "4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
-  "5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  "6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  ]
-
-gdb_test "record instruction-history /p 7,-5" [multi_line \
-  "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  "4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
-  "5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  "6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  ]
-
-gdb_test "record instruction-history /pf 3,7" [multi_line \
-  "3\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  "4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
-  "5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  "6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  ]
-
-gdb_test "record instruction-history 3,3" "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>"
-
-# the following tests are checking the iterators
-# to avoid lots of regexps, we just check the number of lines that
-# were printed during command execution.
-
 # test_lines_output returns the output lines from command as a list.
 proc test_lines_output { command message } {
     global gdb_prompt
@@ -118,83 +40,168 @@ proc test_lines_length { command message } {
     return [llength [test_lines_output $command $message]]
 }
 
-# show instruction history with unlimited size, we expect to see
-# all $traced instructions
-gdb_test_no_output "set record instruction-history-size 0"
-set message "record instruction-history - unlimited"
-set lines [test_lines_length "record instruction-history 1" $message]
-if { $traced != $lines } {
-    fail $message
-} else {
-    pass $message
-}
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
 
-gdb_test_no_output "set record instruction-history-size $traced"
-set message "record instruction-history - traced"
-set lines [test_lines_length "record instruction-history 1" $message]
-if { $traced != $lines } {
-    fail $message
-} else {
-    pass $message
-}
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
+    # set bp before loop and continue
+    set bp_location [gdb_get_line_number "bp.1" $srcfile2]
+    gdb_breakpoint $srcfile2:$bp_location
+    gdb_continue_to_breakpoint "cont to $bp_location" ".*$srcfile2:$bp_location.*"
+
+    # start btrace
+    gdb_test_no_output "record btrace ${method}"
+
+    # set bp after loop and continue
+    set bp_location [gdb_get_line_number "bp.2" $srcfile2]
+    gdb_breakpoint $srcfile2:$bp_location
+    gdb_continue_to_breakpoint "cont to $bp_location" ".*$srcfile2:$bp_location.*"
+
+    # The following test cases test if "browsing" through the
+    # instruction history works as expected.  So for the tests
+    # it is necessary to count the number of lines that are
+    # shown by the "record instruction-history" command.
+
+    set traced {}
+    set testname "determine number of recorded instructions"
+    gdb_test_multiple "info record" $testname {
+	-re "Active record target: record-btrace\r\n.*\r\nRecorded \(\[0-9\]*\) instructions in \(\[0-9\]*\) functions \\\(0 gaps\\\) for thread 1 .*\\.\r\n$gdb_prompt $" {
+	    set traced $expect_out(1,string)
+	    pass $testname
+	}
+    }
 
-# test that the iterator works
-set history_size 4
-gdb_test_no_output "set record instruction-history-size $history_size"
-set message "browse history forward start"
-set lines [test_lines_length "record instruction-history 1" $message]
-if { $lines != $history_size } {
-    fail $message
-} else {
-    pass $message
-}
+    # we have exactly 11 instructions here
+    set message "exactly 11 instructions"
+    if { $traced != 11 } {
+	fail $message
+    } else {
+	pass $message
+    }
 
-set message "browse history forward middle"
-set lines [test_lines_length "record instruction-history +" $message]
-if { $lines != $history_size } {
-    fail $message
-} else {
-    pass $message
-}
+    # test that we see the expected instructions
+    gdb_test "record instruction-history 3,7" [multi_line \
+	"3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	"4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
+	"5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	"6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
+	"7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	]
+
+    gdb_test "record instruction-history /f 3,+5" [multi_line \
+	"3\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	"4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
+	"5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	"6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
+	"7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	]
+
+    gdb_test "record instruction-history /p 7,-5" [multi_line \
+	"3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	"4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
+	"5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	"6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
+	"7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	]
+
+    gdb_test "record instruction-history /pf 3,7" [multi_line \
+	"3\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	"4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
+	"5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	"6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
+	"7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+	]
+
+    gdb_test "record instruction-history 3,3" "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>"
+
+    # the following tests are checking the iterators
+    # to avoid lots of regexps, we just check the number of lines that
+    # were printed during command execution.
+
+    # show instruction history with unlimited size, we expect to see
+    # all $traced instructions
+    gdb_test_no_output "set record instruction-history-size 0"
+    set message "record instruction-history - unlimited"
+    set lines [test_lines_length "record instruction-history 1" $message]
+    if { $traced != $lines } {
+	fail $message
+    } else {
+	pass $message
+    }
 
-set message "browse history forward last"
-set lines [test_lines_length "record instruction-history +" $message]
-if { $lines != 3 } {
-    fail $message
-} else {
-    pass $message
-}
+    gdb_test_no_output "set record instruction-history-size $traced"
+    set message "record instruction-history - traced"
+    set lines [test_lines_length "record instruction-history 1" $message]
+    if { $traced != $lines } {
+	fail $message
+    } else {
+	pass $message
+    }
 
-gdb_test "record instruction-history" "At the end of the branch trace record\\." "browse history forward beyond 1"
+    # test that the iterator works
+    set history_size 4
+    gdb_test_no_output "set record instruction-history-size $history_size"
+    set message "browse history forward start"
+    set lines [test_lines_length "record instruction-history 1" $message]
+    if { $lines != $history_size } {
+	fail $message
+    } else {
+	pass $message
+    }
 
-# make sure we cannot move further
-gdb_test "record instruction-history" "At the end of the branch trace record\\." "browse history forward beyond 2"
+    set message "browse history forward middle"
+    set lines [test_lines_length "record instruction-history +" $message]
+    if { $lines != $history_size } {
+	fail $message
+    } else {
+	pass $message
+    }
 
-set message "browse history backward last"
-set lines [test_lines_length "record instruction-history -" $message]
-if { $lines != $history_size } {
-    fail $message
-} else {
-    pass $message
-}
+    set message "browse history forward last"
+    set lines [test_lines_length "record instruction-history +" $message]
+    if { $lines != 3 } {
+	fail $message
+    } else {
+	pass $message
+    }
 
-set message "browse history backward middle"
-set lines [test_lines_length "record instruction-history -" $message]
-if { $lines != $history_size } {
-    fail $message
-} else {
-    pass $message
-}
+    gdb_test "record instruction-history" "At the end of the branch trace record\\." "browse history forward beyond 1"
 
-set message "browse history backward first"
-set lines [test_lines_length "record instruction-history -" $message]
-if { $lines != 3 } {
-    fail $message
-} else {
-    pass $message
-}
+    # make sure we cannot move further
+    gdb_test "record instruction-history" "At the end of the branch trace record\\." "browse history forward beyond 2"
+
+    set message "browse history backward last"
+    set lines [test_lines_length "record instruction-history -" $message]
+    if { $lines != $history_size } {
+	fail $message
+    } else {
+	pass $message
+    }
+
+    set message "browse history backward middle"
+    set lines [test_lines_length "record instruction-history -" $message]
+    if { $lines != $history_size } {
+	fail $message
+    } else {
+	pass $message
+    }
+
+    set message "browse history backward first"
+    set lines [test_lines_length "record instruction-history -" $message]
+    if { $lines != 3 } {
+	fail $message
+    } else {
+	pass $message
+    }
 
-gdb_test "record instruction-history -" "At the start of the branch trace record\\." "browse history backward beyond 1"
+    gdb_test "record instruction-history -" "At the start of the branch trace record\\." "browse history backward beyond 1"
 
-# make sure we cannot move further back
-gdb_test "record instruction-history -" "At the start of the branch trace record\\." "browse history backward beyond 2"
+    # make sure we cannot move further back
+    gdb_test "record instruction-history -" "At the start of the branch trace record\\." "browse history backward beyond 2"
+}
diff --git a/gdb/testsuite/gdb.btrace/multi-inferior.exp b/gdb/testsuite/gdb.btrace/multi-inferior.exp
index 6996b182e65..06ca93a9686 100644
--- a/gdb/testsuite/gdb.btrace/multi-inferior.exp
+++ b/gdb/testsuite/gdb.btrace/multi-inferior.exp
@@ -27,46 +27,54 @@ require allow_btrace_tests
 require !use_gdb_stub
 
 standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile {} {debug}] {
+if [build_executable "failed to prepare" $testfile {} {debug}] {
     return -1
 }
 
 set host_binfile [gdb_remote_download host $binfile]
 
-with_test_prefix "inferior 1" {
-    if ![runto_main] {
-	return -1
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
     }
-}
-
-with_test_prefix "inferior 2" {
-    gdb_test "add-inferior -exec $host_binfile" "Added inferior 2.*" \
-	"add second inferior"
-    gdb_test "inferior 2" "Switching to inferior 2.*"
+    clean_restart "${testfile}"
 
-    if ![runto_main] {
-	return -1
+    with_test_prefix "inferior 1" {
+	if ![runto_main] {
+	    continue
+	}
     }
 
-    gdb_test_no_output "record btrace" "record btrace"
-}
+    with_test_prefix "inferior 2" {
+	gdb_test "add-inferior -exec $host_binfile" "Added inferior 2.*" \
+	    "add second inferior"
+	gdb_test "inferior 2" "Switching to inferior 2.*"
 
-with_test_prefix "inferior 1" {
-    gdb_test "inferior 1" "Switching to inferior 1.*"
+	if ![runto_main] {
+	    continue
+	}
 
-    gdb_test "info record" "No recording is currently active\\."
-    gdb_test_no_output "record btrace" "record btrace"
-}
+	gdb_test_no_output "record btrace ${method}" "record btrace ${method}"
+    }
 
-with_test_prefix "inferior 3" {
-    gdb_test "add-inferior -exec ${host_binfile}" "Added inferior 3.*" \
-	"add third inferior"
-    gdb_test "inferior 3" "Switching to inferior 3.*"
+    with_test_prefix "inferior 1" {
+	gdb_test "inferior 1" "Switching to inferior 1.*"
 
-    if ![runto_main] {
-	return -1
+	gdb_test "info record" "No recording is currently active\\."
+	gdb_test_no_output "record btrace ${method}" "record btrace ${method}"
     }
 
-    gdb_test "info record" "No recording is currently active\\."
-    gdb_test_no_output "record btrace" "record btrace"
+    with_test_prefix "inferior 3" {
+	gdb_test "add-inferior -exec ${host_binfile}" "Added inferior 3.*" \
+	    "add third inferior"
+	gdb_test "inferior 3" "Switching to inferior 3.*"
+
+	if ![runto_main] {
+	    continue
+	}
+
+	gdb_test "info record" "No recording is currently active\\."
+	gdb_test_no_output "record btrace ${method}" "record btrace ${method}"
+    }
 }
diff --git a/gdb/testsuite/gdb.btrace/multi-thread-step.exp b/gdb/testsuite/gdb.btrace/multi-thread-step.exp
index 154db9ae515..6ab5969f457 100644
--- a/gdb/testsuite/gdb.btrace/multi-thread-step.exp
+++ b/gdb/testsuite/gdb.btrace/multi-thread-step.exp
@@ -24,16 +24,6 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debu
     untested "failed to prepare"
     return -1
 }
-clean_restart $testfile
-
-if ![runto_main] {
-    return -1
-}
-
-# set up breakpoints
-set bp_1 [gdb_get_line_number "bp.1" $srcfile]
-set bp_2 [gdb_get_line_number "bp.2" $srcfile]
-set bp_3 [gdb_get_line_number "bp.3" $srcfile]
 
 proc gdb_cont_to_line { line } {
     gdb_breakpoint $line
@@ -61,14 +51,6 @@ proc check_not_replaying { thread } {
     }
 }
 
-# trace the code between the two breakpoints
-delete_breakpoints
-gdb_cont_to_line $srcfile:$bp_1
-# make sure GDB knows about the new thread
-gdb_test "info threads" ".*"
-gdb_test_no_output "record btrace"
-gdb_cont_to_line $srcfile:$bp_2
-
 proc test_navigate {} {
     with_test_prefix "navigate" {
         gdb_test "thread 1" ".*"
@@ -168,46 +150,70 @@ proc test_goto_end {} {
     }
 }
 
-foreach schedlock { "replay" "on" "step" } {
-    with_test_prefix "schedlock-$schedlock" {
-        gdb_test_no_output "set scheduler-locking $schedlock"
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
+
+    # set up breakpoints
+    set bp_1 [gdb_get_line_number "bp.1" $srcfile]
+    set bp_2 [gdb_get_line_number "bp.2" $srcfile]
+    set bp_3 [gdb_get_line_number "bp.3" $srcfile]
 
-        test_navigate
-        test_step
-        if { $schedlock == "step" } {
-            test_cont_all
-        } else {
-            test_cont
-        }
-        test_rstep
-        test_goto_end
+    # trace the code between the two breakpoints
+    delete_breakpoints
+    gdb_cont_to_line $srcfile:$bp_1
+    # make sure GDB knows about the new thread
+    gdb_test "info threads" ".*"
+    gdb_test_no_output "record btrace ${method}"
+    gdb_cont_to_line $srcfile:$bp_2
+
+    foreach schedlock { "replay" "on" "step" } {
+	with_test_prefix "schedlock-$schedlock" {
+	    gdb_test_no_output "set scheduler-locking $schedlock"
+
+	    test_navigate
+	    test_step
+	    if { $schedlock == "step" } {
+		test_cont_all
+	    } else {
+		test_cont
+	    }
+	    test_rstep
+	    test_goto_end
+	}
     }
-}
 
-# schedlock-off is difficult to test since we can't really say where the other
-# thread will be when the resumed thread stops.
+    # schedlock-off is difficult to test since we can't really say where the other
+    # thread will be when the resumed thread stops.
 
-# navigate back into the history for thread 1 and continue thread 2
-with_test_prefix "cont-to-end" {
-    # this test only works for scheduler-locking replay
-    gdb_test_no_output "set scheduler-locking replay"
+    # navigate back into the history for thread 1 and continue thread 2
+    with_test_prefix "cont-to-end" {
+	# this test only works for scheduler-locking replay
+	gdb_test_no_output "set scheduler-locking replay"
 
-    gdb_test "thread 1" ".*"
-    with_test_prefix "thread 1" {
-        gdb_test "record goto begin" ".*"
+	gdb_test "thread 1" ".*"
+	with_test_prefix "thread 1" {
+	    gdb_test "record goto begin" ".*"
 
-        check_replay_insn 1 1
-    }
-    gdb_test "thread 2" ".*"
-    with_test_prefix "thread 2" {
-        gdb_test "record goto end" ".*"
+	    check_replay_insn 1 1
+	}
+	gdb_test "thread 2" ".*"
+	with_test_prefix "thread 2" {
+	    gdb_test "record goto end" ".*"
 
-        check_not_replaying 2
+	    check_not_replaying 2
 
-        # if we reach the breakpoint, thread 2 terminated...
-        gdb_cont_to_line $srcfile:$bp_3
+	    # if we reach the breakpoint, thread 2 terminated...
+	    gdb_cont_to_line $srcfile:$bp_3
 
-        # and thread 1 stopped replaying
-        check_not_replaying 1
+	    # and thread 1 stopped replaying
+	    check_not_replaying 1
+	}
     }
 }
diff --git a/gdb/testsuite/gdb.btrace/nohist.exp b/gdb/testsuite/gdb.btrace/nohist.exp
index d71909181c4..3a7dd264c53 100644
--- a/gdb/testsuite/gdb.btrace/nohist.exp
+++ b/gdb/testsuite/gdb.btrace/nohist.exp
@@ -20,11 +20,8 @@
 require allow_btrace_tests
 
 standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
-    return -1
-}
 
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
@@ -36,14 +33,25 @@ proc check_not_replaying {} {
     ]
 }
 
-gdb_test_no_output "record btrace"
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
 
-with_test_prefix "forward" {
-    check_not_replaying
-}
+    gdb_test_no_output "record btrace ${method}"
+
+    with_test_prefix "forward" {
+	check_not_replaying
+    }
 
-gdb_test "reverse-continue" "No more reverse-execution history\.\r\n.*"
+    gdb_test "reverse-continue" "No more reverse-execution history\.\r\n.*"
 
-with_test_prefix "backward" {
-    check_not_replaying
+    with_test_prefix "backward" {
+	check_not_replaying
+    }
 }
diff --git a/gdb/testsuite/gdb.btrace/non-stop.exp b/gdb/testsuite/gdb.btrace/non-stop.exp
index 62c940e4cd6..ed05a2cf480 100644
--- a/gdb/testsuite/gdb.btrace/non-stop.exp
+++ b/gdb/testsuite/gdb.btrace/non-stop.exp
@@ -23,29 +23,6 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debu
     return -1
 }
 
-save_vars { GDBFLAGS } {
-    append GDBFLAGS " -ex \"set non-stop on\""
-    clean_restart $testfile
-}
-
-if ![runto_main] {
-    return -1
-}
-
-# set up breakpoints
-set bp_1 [gdb_get_line_number "bp.1" $srcfile]
-set bp_2 [gdb_get_line_number "bp.2" $srcfile]
-set bp_3 [gdb_get_line_number "bp.3" $srcfile]
-
-gdb_breakpoint $bp_1
-gdb_breakpoint $bp_2
-
-# get the line number containing most of the trace
-set loop [gdb_get_line_number "loop" $srcfile]
-
-# a stop on the above line as reported by GDB
-set loop_line "$loop\[^\\\r\\\n\]*/\\\* loop \\\*/"
-
 # make sure $line matches the full expected output per thread.
 # and let's hope that GDB never mixes the output from different threads.
 proc gdb_cont_to { threads cmd line nthreads } {
@@ -89,165 +66,195 @@ proc gdb_cont_to_no_history { threads cmd nthreads } {
         $nthreads
 }
 
-# trace the code between the two breakpoints
-with_test_prefix "prepare" {
-    gdb_cont_to_bp_line "$srcfile:$bp_1" all 2
-}
-with_test_prefix "record" {
-    gdb_test_no_output "record btrace"
-    gdb_cont_to_bp_line "$srcfile:$bp_2" all 2
-}
-
-# we don't need those breakpoints any longer.
-# they will only disturb our stepping.
-delete_breakpoints
-
-# show the threads - this is useful for debugging fails
-gdb_test "thread apply all info rec" ".*"
-gdb_test "info threads" ".*"
-
-with_test_prefix "navigate" {
-    gdb_test "thread apply 1 record goto 3" "$loop_line"
-    gdb_test "thread apply 2 record goto 4" "$loop_line"
-    gdb_test "thread apply 1 info record" \
-        ".*Replay in progress\.  At instruction 3\." "thread 1 at insn 3"
-    gdb_test "thread apply 2 info record" \
-        ".*Replay in progress\.  At instruction 4\." "thread 2 at insn 4"
-
-    gdb_test "thread apply all record goto 5" "$loop_line"
-    gdb_test "thread apply 1 info record" \
-        ".*Replay in progress\.  At instruction 5\." "thread 1 at insn 5"
-    gdb_test "thread apply 2 info record" \
-        ".*Replay in progress\.  At instruction 5\." "thread 2 at insn 5"
-}
-
-with_test_prefix "step" {
-    with_test_prefix "thread 1" {
-        gdb_test "thread apply 1 stepi 2" "$loop_line"
-        gdb_test "thread apply 1 info record" \
-            ".*Replay in progress\.  At instruction 7\."
-        gdb_test "thread apply 2 info record" \
-            ".*Replay in progress\.  At instruction 5\."
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
     }
 
-    with_test_prefix "thread 2" {
-        gdb_test "thread apply 2 stepi 3" "$loop_line"
-        gdb_test "thread apply 1 info record" \
-            ".*Replay in progress\.  At instruction 7\."
-        gdb_test "thread apply 2 info record" \
-            ".*Replay in progress\.  At instruction 8\."
+    save_vars { GDBFLAGS } {
+	append GDBFLAGS " -ex \"set non-stop on\""
+	clean_restart $testfile
     }
 
-    with_test_prefix "all" {
-        gdb_cont_to all "stepi 4" "$loop_line" 2
-        gdb_test "thread apply 1 info record" \
-            ".*Replay in progress\.  At instruction 11\."
-        gdb_test "thread apply 2 info record" \
-            ".*Replay in progress\.  At instruction 12\."
+    if ![runto_main] {
+	continue
     }
-}
 
-with_test_prefix "reverse-step" {
-    with_test_prefix "thread 1" {
-        gdb_test "thread apply 1 reverse-stepi 2" "$loop_line"
-        gdb_test "thread apply 1 info record" \
-            ".*Replay in progress\.  At instruction 9\."
-        gdb_test "thread apply 2 info record" \
-            ".*Replay in progress\.  At instruction 12\."
-    }
+    # set up breakpoints
+    set bp_1 [gdb_get_line_number "bp.1" $srcfile]
+    set bp_2 [gdb_get_line_number "bp.2" $srcfile]
+    set bp_3 [gdb_get_line_number "bp.3" $srcfile]
+
+    gdb_breakpoint $bp_1
+    gdb_breakpoint $bp_2
 
-    with_test_prefix "thread 2" {
-        gdb_test "thread apply 2 reverse-stepi 3" "$loop_line"
-        gdb_test "thread apply 1 info record" \
-            ".*Replay in progress\.  At instruction 9\."
-        gdb_test "thread apply 2 info record" \
-            ".*Replay in progress\.  At instruction 9\."
+    # get the line number containing most of the trace
+    set loop [gdb_get_line_number "loop" $srcfile]
+
+    # a stop on the above line as reported by GDB
+    set loop_line "$loop\[^\\\r\\\n\]*/\\\* loop \\\*/"
+
+    # trace the code between the two breakpoints
+    with_test_prefix "prepare" {
+	gdb_cont_to_bp_line "$srcfile:$bp_1" all 2
+    }
+    with_test_prefix "record" {
+	gdb_test_no_output "record btrace ${method}"
+	gdb_cont_to_bp_line "$srcfile:$bp_2" all 2
     }
 
-    with_test_prefix "all" {
-        gdb_cont_to all "reverse-stepi 4" "$loop_line" 2
-        gdb_test "thread apply 1 info record" \
-            ".*Replay in progress\.  At instruction 5\."
-        gdb_test "thread apply 2 info record" \
-            ".*Replay in progress\.  At instruction 5\."
+    # we don't need those breakpoints any longer.
+    # they will only disturb our stepping.
+    delete_breakpoints
+
+    # show the threads - this is useful for debugging fails
+    gdb_test "thread apply all info rec" ".*"
+    gdb_test "info threads" ".*"
+
+    with_test_prefix "navigate" {
+	gdb_test "thread apply 1 record goto 3" "$loop_line"
+	gdb_test "thread apply 2 record goto 4" "$loop_line"
+	gdb_test "thread apply 1 info record" \
+	    ".*Replay in progress\.  At instruction 3\." "thread 1 at insn 3"
+	gdb_test "thread apply 2 info record" \
+	    ".*Replay in progress\.  At instruction 4\." "thread 2 at insn 4"
+
+	gdb_test "thread apply all record goto 5" "$loop_line"
+	gdb_test "thread apply 1 info record" \
+	    ".*Replay in progress\.  At instruction 5\." "thread 1 at insn 5"
+	gdb_test "thread apply 2 info record" \
+	    ".*Replay in progress\.  At instruction 5\." "thread 2 at insn 5"
     }
-}
 
-with_test_prefix "continue" {
-    with_test_prefix "thread 1" {
-	with_test_prefix "continue" {
-	    gdb_cont_to_no_history 1 "continue" 1
+    with_test_prefix "step" {
+	with_test_prefix "thread 1" {
+	    gdb_test "thread apply 1 stepi 2" "$loop_line"
 	    gdb_test "thread apply 1 info record" \
-		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+		".*Replay in progress\.  At instruction 7\."
 	    gdb_test "thread apply 2 info record" \
 		".*Replay in progress\.  At instruction 5\."
 	}
-	with_test_prefix "reverse-continue" {
-	    gdb_cont_to_no_history 1 "reverse-continue" 1
+
+	with_test_prefix "thread 2" {
+	    gdb_test "thread apply 2 stepi 3" "$loop_line"
 	    gdb_test "thread apply 1 info record" \
-		".*Replay in progress\.  At instruction 1\."
+		".*Replay in progress\.  At instruction 7\."
 	    gdb_test "thread apply 2 info record" \
-		".*Replay in progress\.  At instruction 5\."
+		".*Replay in progress\.  At instruction 8\."
+	}
+
+	with_test_prefix "all" {
+	    gdb_cont_to all "stepi 4" "$loop_line" 2
+	    gdb_test "thread apply 1 info record" \
+		".*Replay in progress\.  At instruction 11\."
+	    gdb_test "thread apply 2 info record" \
+		".*Replay in progress\.  At instruction 12\."
 	}
     }
 
-    with_test_prefix "thread 2" {
-	with_test_prefix "continue" {
-	    gdb_cont_to_no_history 2 "continue" 1
+    with_test_prefix "reverse-step" {
+	with_test_prefix "thread 1" {
+	    gdb_test "thread apply 1 reverse-stepi 2" "$loop_line"
 	    gdb_test "thread apply 1 info record" \
-		".*Replay in progress\.  At instruction 1\."
+		".*Replay in progress\.  At instruction 9\."
 	    gdb_test "thread apply 2 info record" \
-		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+		".*Replay in progress\.  At instruction 12\."
+	}
+
+	with_test_prefix "thread 2" {
+	    gdb_test "thread apply 2 reverse-stepi 3" "$loop_line"
+	    gdb_test "thread apply 1 info record" \
+		".*Replay in progress\.  At instruction 9\."
+	    gdb_test "thread apply 2 info record" \
+		".*Replay in progress\.  At instruction 9\."
 	}
-	with_test_prefix "reverse-continue" {
-	    gdb_cont_to_no_history 2 "reverse-continue" 1
+
+	with_test_prefix "all" {
+	    gdb_cont_to all "reverse-stepi 4" "$loop_line" 2
 	    gdb_test "thread apply 1 info record" \
-		".*Replay in progress\.  At instruction 1\."
+		".*Replay in progress\.  At instruction 5\."
 	    gdb_test "thread apply 2 info record" \
-		".*Replay in progress\.  At instruction 1\."
+		".*Replay in progress\.  At instruction 5\."
 	}
     }
-}
 
-# a thread may only resume if no thread is still replaying
-with_test_prefix "no progress" {
-    with_test_prefix "thread 1" {
-        gdb_test "thread apply 1 record goto end" ".*"
-        gdb_test "thread apply 2 record goto begin" ".*"
-
-        gdb_cont_to_no_history 1 "continue" 1
-        gdb_cont_to_no_history 1 "step" 1
-        gdb_test "thread apply 1 info record" \
-            ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
-        gdb_test "thread apply 2 info record" \
-            ".*Replay in progress\.  At instruction 1\."
+    with_test_prefix "continue" {
+	with_test_prefix "thread 1" {
+	    with_test_prefix "continue" {
+		gdb_cont_to_no_history 1 "continue" 1
+		gdb_test "thread apply 1 info record" \
+		    ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+		gdb_test "thread apply 2 info record" \
+		    ".*Replay in progress\.  At instruction 5\."
+	    }
+	    with_test_prefix "reverse-continue" {
+		gdb_cont_to_no_history 1 "reverse-continue" 1
+		gdb_test "thread apply 1 info record" \
+		    ".*Replay in progress\.  At instruction 1\."
+		gdb_test "thread apply 2 info record" \
+		    ".*Replay in progress\.  At instruction 5\."
+	    }
+	}
+
+	with_test_prefix "thread 2" {
+	    with_test_prefix "continue" {
+		gdb_cont_to_no_history 2 "continue" 1
+		gdb_test "thread apply 1 info record" \
+		    ".*Replay in progress\.  At instruction 1\."
+		gdb_test "thread apply 2 info record" \
+		    ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+	    }
+	    with_test_prefix "reverse-continue" {
+		gdb_cont_to_no_history 2 "reverse-continue" 1
+		gdb_test "thread apply 1 info record" \
+		    ".*Replay in progress\.  At instruction 1\."
+		gdb_test "thread apply 2 info record" \
+		    ".*Replay in progress\.  At instruction 1\."
+	    }
+	}
     }
 
-    with_test_prefix "thread 2" {
-        gdb_test "thread apply 1 record goto begin" ".*"
-        gdb_test "thread apply 2 record goto end" ".*"
+    # a thread may only resume if no thread is still replaying
+    with_test_prefix "no progress" {
+	with_test_prefix "thread 1" {
+	    gdb_test "thread apply 1 record goto end" ".*"
+	    gdb_test "thread apply 2 record goto begin" ".*"
 
-        gdb_cont_to_no_history 2 "continue" 1
-        gdb_cont_to_no_history 2 "step" 1
-        gdb_test "thread apply 1 info record" \
-            ".*Replay in progress\.  At instruction 1\."
-        gdb_test "thread apply 2 info record" \
-            ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
-    }
+	    gdb_cont_to_no_history 1 "continue" 1
+	    gdb_cont_to_no_history 1 "step" 1
+	    gdb_test "thread apply 1 info record" \
+		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+	    gdb_test "thread apply 2 info record" \
+		".*Replay in progress\.  At instruction 1\."
+	}
+
+	with_test_prefix "thread 2" {
+	    gdb_test "thread apply 1 record goto begin" ".*"
+	    gdb_test "thread apply 2 record goto end" ".*"
 
-    with_test_prefix "all" {
-        gdb_test "thread apply all record goto begin" ".*"
+	    gdb_cont_to_no_history 2 "continue" 1
+	    gdb_cont_to_no_history 2 "step" 1
+	    gdb_test "thread apply 1 info record" \
+		".*Replay in progress\.  At instruction 1\."
+	    gdb_test "thread apply 2 info record" \
+		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+	}
 
-        gdb_cont_to_no_history all "continue" 2
-        gdb_test "thread apply 1 info record" \
-            ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
-        gdb_test "thread apply 2 info record" \
-            ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+	with_test_prefix "all" {
+	    gdb_test "thread apply all record goto begin" ".*"
+
+	    gdb_cont_to_no_history all "continue" 2
+	    gdb_test "thread apply 1 info record" \
+		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+	    gdb_test "thread apply 2 info record" \
+		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
+	}
     }
-}
 
-# now that both threads stopped replaying we may resume recording
-with_test_prefix "cont to end" {
-    gdb_breakpoint $bp_3
-    gdb_cont_to_bp_line "$srcfile:$bp_3" all 1
+    # now that both threads stopped replaying we may resume recording
+    with_test_prefix "cont to end" {
+	gdb_breakpoint $bp_3
+	gdb_cont_to_bp_line "$srcfile:$bp_3" all 1
+    }
 }
diff --git a/gdb/testsuite/gdb.btrace/reconnect.exp b/gdb/testsuite/gdb.btrace/reconnect.exp
index 41f702a38b3..349d7f7cda9 100644
--- a/gdb/testsuite/gdb.btrace/reconnect.exp
+++ b/gdb/testsuite/gdb.btrace/reconnect.exp
@@ -23,59 +23,69 @@ require allow_btrace_tests
 require allow_gdbserver_tests
 
 standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
 set target_binfile [gdb_remote_download target $binfile]
 
-# Make sure we're disconnected and no recording is active, in case
-# we're testing with an extended-remote board, therefore already
-# connected.
-with_test_prefix "preparation" {
-  gdb_test "record stop" ".*"
-  gdb_test "disconnect" ".*"
-}
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
 
-# Start fresh gdbserver.
-set gdbserver_reconnect_p 1
-set res [gdbserver_start "" $target_binfile]
-set gdbserver_protocol [lindex $res 0]
-set gdbserver_gdbport [lindex $res 1]
-gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
+    clean_restart "${testfile}"
 
-# Create a record, check, reconnect
-with_test_prefix "first" {
-  gdb_test_no_output "record btrace" "record btrace enable"
-  gdb_test "stepi 19" ".*"
+    # Make sure we're disconnected and no recording is active, in case
+    # we're testing with an extended-remote board, therefore already
+    # connected.
+    with_test_prefix "preparation" {
+	gdb_test "record stop" ".*"
+	gdb_test "disconnect" ".*"
+    }
 
-  gdb_test "info record" [multi_line \
-    "Active record target: .*" \
-    "Recorded 19 instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
-  ]
+    # Start fresh gdbserver.
+    set gdbserver_reconnect_p 1
+    set res [gdbserver_start "" $target_binfile]
+    set gdbserver_protocol [lindex $res 0]
+    set gdbserver_gdbport [lindex $res 1]
+    gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
 
-  gdb_test "disconnect" "Ending remote debugging."
-  gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
-}
+    # Create a record, check, reconnect
+    with_test_prefix "first" {
+	gdb_test_no_output "record btrace ${method}" "record btrace ${method} enable"
+	gdb_test "stepi 19" ".*"
 
-# Test if we can access the recorded data from first connect.
-# Note: BTS loses the first function call entry with its associated
-# instructions for technical reasons.  This is why we test for
-# "a number between 10 and 19", so we catch at least the case where
-# there are 0 instructions in the record.
-with_test_prefix "second" {
-  gdb_test "info record" [multi_line \
-    "Active record target: .*" \
-    "Recorded 1. instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
-  ]
+	gdb_test "info record" [multi_line \
+	    "Active record target: .*" \
+	    "Recorded 19 instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
+	    ]
 
-  gdb_test "record stop" "Process record is stopped and all execution logs are deleted."
+	gdb_test "disconnect" "Ending remote debugging."
+	gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
+    }
 
-  gdb_test "disconnect" "Ending remote debugging."
-  gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
-}
+    # Test if we can access the recorded data from first connect.
+    # Note: BTS loses the first function call entry with its associated
+    # instructions for technical reasons.  This is why we test for
+    # "a number between 10 and 19", so we catch at least the case where
+    # there are 0 instructions in the record.
+    with_test_prefix "second" {
+	gdb_test "info record" [multi_line \
+	    "Active record target: .*" \
+	    "Recorded 1. instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
+	    ]
+
+	gdb_test "record stop" "Process record is stopped and all execution logs are deleted."
+
+	gdb_test "disconnect" "Ending remote debugging."
+	gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
+    }
 
-# Test that recording is now off.
-with_test_prefix "third" {
-  gdb_test "info record" "No recording is currently active."
+    # Test that recording is now off.
+    with_test_prefix "third" {
+	gdb_test "info record" "No recording is currently active."
+    }
+    gdb_test "disconnect" ".*"
 }
diff --git a/gdb/testsuite/gdb.btrace/record_goto-step.exp b/gdb/testsuite/gdb.btrace/record_goto-step.exp
index e7adc62eedd..f4f89c7b1c7 100644
--- a/gdb/testsuite/gdb.btrace/record_goto-step.exp
+++ b/gdb/testsuite/gdb.btrace/record_goto-step.exp
@@ -20,25 +20,34 @@
 require allow_btrace_tests
 
 standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
-    return -1
-}
 
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
-set bp [gdb_get_line_number "fun4.3" $srcfile]
-gdb_breakpoint $srcfile:$bp
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+
+    if ![runto_main] {
+	continue
+    }
 
-# record the execution until we hit a breakpoint
-gdb_test_no_output "record btrace"
-gdb_continue_to_breakpoint "cont to $bp" ".*fun4\.3.*"
+    set bp [gdb_get_line_number "fun4.3" $srcfile]
+    gdb_breakpoint $srcfile:$bp
 
-# reverse-step, then jump to the end of the trace
-gdb_test "reverse-next" ".*fun4\.2.*"
-gdb_test "record goto end" ".*fun4\.3.*"
+    # record the execution until we hit a breakpoint
+    gdb_test_no_output "record btrace ${method}"
+    gdb_continue_to_breakpoint "cont to $bp" ".*fun4\.3.*"
 
-# test that we can step away from a breakpoint after jumping to
-# the breakpoint PC
-gdb_test "next" ".*fun4\.4.*"
+    # reverse-step, then jump to the end of the trace
+    gdb_test "reverse-next" ".*fun4\.2.*"
+    gdb_test "record goto end" ".*fun4\.3.*"
+
+    # test that we can step away from a breakpoint after jumping to
+    # the breakpoint PC
+    gdb_test "next" ".*fun4\.4.*"
+}
diff --git a/gdb/testsuite/gdb.btrace/record_goto.exp b/gdb/testsuite/gdb.btrace/record_goto.exp
index cd6ab387c40..df1cb970996 100644
--- a/gdb/testsuite/gdb.btrace/record_goto.exp
+++ b/gdb/testsuite/gdb.btrace/record_goto.exp
@@ -19,6 +19,11 @@
 
 require allow_btrace_tests
 
+# When GDB prints the file for a stop location, it may print the full path
+# depending on what information the compiler added.  This regexp allows for
+# that path to be present, but does not require it.
+set optional_filepath {[^\n]*}
+
 # The "record goto" command jumps to a specific instruction in the execution
 # trace.  To guarantee that we always get the same execution trace, we use
 # an assembly source file.
@@ -43,157 +48,162 @@ if [info exists COMPILE] {
     return -1
 }
 
-if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
+if [build_executable "failed to prepare" $testfile $srcfile $opts] {
     return -1
 }
 
-if ![runto_main] {
-    return -1
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
+
+    # we want a small context sizes to simplify the test
+    gdb_test_no_output "set record instruction-history-size 3"
+    gdb_test_no_output "set record function-call-history-size 3"
+
+    # trace the call to the test function
+    gdb_test_no_output "record btrace ${method}"
+    gdb_test "next"
+
+    # start by listing all functions
+    gdb_test "record function-call-history /ci 1, +20" [multi_line \
+	"1\tmain\tinst 1,1" \
+	"2\t  fun4\tinst 2,4" \
+	"3\t    fun1\tinst 5,8" \
+	"4\t  fun4\tinst 9,9" \
+	"5\t    fun2\tinst 10,12" \
+	"6\t      fun1\tinst 13,16" \
+	"7\t    fun2\tinst 17,18" \
+	"8\t  fun4\tinst 19,19" \
+	"9\t    fun3\tinst 20,22" \
+	"10\t      fun1\tinst 23,26" \
+	"11\t    fun3\tinst 27,27" \
+	"12\t      fun2\tinst 28,30" \
+	"13\t        fun1\tinst 31,34" \
+	"14\t      fun2\tinst 35,36" \
+	"15\t    fun3\tinst 37,38" \
+	"16\t  fun4\tinst 39,40" \
+	]
+
+    # let's see if we can go back in history
+    gdb_test \
+	"record goto 19" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:43.*"
+
+    # the function call history should start at the new location
+    gdb_test "record function-call-history /ci" [multi_line \
+	"8\t  fun4\tinst 19,19" \
+	"9\t    fun3\tinst 20,22" \
+	"10\t      fun1\tinst 23,26" \
+	] "function-call-history from 19 forwards"
+
+    # the instruction history should start at the new location
+    gdb_test "record instruction-history" [multi_line \
+	"19.*" \
+	"20.*" \
+	"21.*" \
+	] "instruction-history from 19 forwards"
+
+    # let's go to another place in the history
+    gdb_test \
+	"record goto 27" \
+	".*fun3 \\(\\) at ${optional_filepath}record_goto.c:35.*"
+
+    # check the back trace at that location
+    gdb_test "backtrace" [multi_line \
+	"#0.*fun3.*at ${optional_filepath}record_goto.c:35.*" \
+	"#1.*fun4.*at ${optional_filepath}record_goto.c:43.*" \
+	"#2.*main.*at ${optional_filepath}record_goto.c:49.*" \
+	"Backtrace stopped: not enough registers or memory available to unwind further" \
+	]
+
+    # walk the backtrace
+    gdb_test "up" ".*fun4.*at ${optional_filepath}record_goto.c:43.*" "up to fun4"
+    gdb_test "up" ".*main.*at ${optional_filepath}record_goto.c:49.*" "up to main"
+
+    # the function call history should start at the new location
+    gdb_test "record function-call-history /ci -" [multi_line \
+	"9\t    fun3\tinst 20,22" \
+	"10\t      fun1\tinst 23,26" \
+	"11\t    fun3\tinst 27,27" \
+	] "function-call-history from 27 backwards"
+
+    # the instruction history should start at the new location
+    gdb_test "record instruction-history -" [multi_line \
+	"25.*" \
+	"26.*" \
+	"27.*" \
+	] "instruction-history from 27 backwards"
+
+    # test that we can go to the begin of the trace
+    gdb_test "record goto begin" ".*main \\(\\) at ${optional_filepath}record_goto.c:49.*"
+
+    # check that we're filling up the context correctly
+    gdb_test "record function-call-history /ci -" [multi_line \
+	"1\tmain\tinst 1,1" \
+	"2\t  fun4\tinst 2,4" \
+	"3\t    fun1\tinst 5,8" \
+	] "function-call-history from begin backwards"
+
+    # check that we're filling up the context correctly
+    gdb_test "record instruction-history -" [multi_line \
+	"1.*" \
+	"2.*" \
+	"3.*" \
+	] "instruction-history from begin backwards"
+
+    # we should get the exact same history from the first instruction
+    gdb_test "record goto 2" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:40.*"
+
+    # check that we're filling up the context correctly
+    gdb_test "record function-call-history /ci -" [multi_line \
+	"1\tmain\tinst 1,1" \
+	"2\t  fun4\tinst 2,4" \
+	"3\t    fun1\tinst 5,8" \
+	] "function-call-history from 2 backwards"
+
+    # check that we're filling up the context correctly
+    gdb_test "record instruction-history -" [multi_line \
+	"1.*" \
+	"2.*" \
+	"3.*" \
+	] "instruction-history from 2 backwards"
+
+    # check that we can go to the end of the trace
+    gdb_test "record goto end" ".*main \\(\\) at ${optional_filepath}record_goto.c:50.*"
+
+    # check that we're filling up the context correctly
+    gdb_test "record function-call-history /ci" [multi_line \
+	"14\t      fun2\tinst 35,36" \
+	"15\t    fun3\tinst 37,38" \
+	"16\t  fun4\tinst 39,40" \
+	] "function-call-history from end forwards"
+
+    # check that we're filling up the context correctly
+    gdb_test "record instruction-history" [multi_line \
+	"38.*" \
+	"39.*" \
+	"40.*" \
+	] "instruction-history from end forwards"
+
+    # we should get the exact same history from the second to last instruction
+    gdb_test "record goto 39" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:44.*"
+
+    # check that we're filling up the context correctly
+    gdb_test "record function-call-history /ci" [multi_line \
+	"14\t      fun2\tinst 35,36" \
+	"15\t    fun3\tinst 37,38" \
+	"16\t  fun4\tinst 39,40" \
+	] "function-call-history from 39 forwards"
+
+    # check that we're filling up the context correctly
+    gdb_test "record instruction-history" [multi_line \
+	"38.*" \
+	"39.*" \
+	"40.*" \
+	] "instruction-history from 39 forwards"
 }
-
-# When GDB prints the file for a stop location, it may print the full path
-# depending on what information the compiler added.  This regexp allows for
-# that path to be present, but does not require it.
-set optional_filepath {[^\n]*}
-
-# we want a small context sizes to simplify the test
-gdb_test_no_output "set record instruction-history-size 3"
-gdb_test_no_output "set record function-call-history-size 3"
-
-# trace the call to the test function
-gdb_test_no_output "record btrace"
-gdb_test "next"
-
-# start by listing all functions
-gdb_test "record function-call-history /ci 1, +20" [multi_line \
-  "1\tmain\tinst 1,1" \
-  "2\t  fun4\tinst 2,4" \
-  "3\t    fun1\tinst 5,8" \
-  "4\t  fun4\tinst 9,9" \
-  "5\t    fun2\tinst 10,12" \
-  "6\t      fun1\tinst 13,16" \
-  "7\t    fun2\tinst 17,18" \
-  "8\t  fun4\tinst 19,19" \
-  "9\t    fun3\tinst 20,22" \
-  "10\t      fun1\tinst 23,26" \
-  "11\t    fun3\tinst 27,27" \
-  "12\t      fun2\tinst 28,30" \
-  "13\t        fun1\tinst 31,34" \
-  "14\t      fun2\tinst 35,36" \
-  "15\t    fun3\tinst 37,38" \
-  "16\t  fun4\tinst 39,40" \
-  ]
-
-# let's see if we can go back in history
-gdb_test "record goto 19" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:43.*"
-
-# the function call history should start at the new location
-gdb_test "record function-call-history /ci" [multi_line \
-  "8\t  fun4\tinst 19,19" \
-  "9\t    fun3\tinst 20,22" \
-  "10\t      fun1\tinst 23,26" \
-  ] "function-call-history from 19 forwards"
-
-# the instruction history should start at the new location
-gdb_test "record instruction-history" [multi_line \
-  "19.*" \
-  "20.*" \
-  "21.*" \
-  ] "instruction-history from 19 forwards"
-
-# let's go to another place in the history
-gdb_test "record goto 27" ".*fun3 \\(\\) at ${optional_filepath}record_goto.c:35.*"
-
-# check the back trace at that location
-gdb_test "backtrace" [multi_line \
-  "#0.*fun3.*at ${optional_filepath}record_goto.c:35.*" \
-  "#1.*fun4.*at ${optional_filepath}record_goto.c:43.*" \
-  "#2.*main.*at ${optional_filepath}record_goto.c:49.*" \
-  "Backtrace stopped: not enough registers or memory available to unwind further" \
-  ]
-
-# walk the backtrace
-gdb_test "up" ".*fun4.*at ${optional_filepath}record_goto.c:43.*" "up to fun4"
-gdb_test "up" ".*main.*at ${optional_filepath}record_goto.c:49.*" "up to main"
-
-# the function call history should start at the new location
-gdb_test "record function-call-history /ci -" [multi_line \
-  "9\t    fun3\tinst 20,22" \
-  "10\t      fun1\tinst 23,26" \
-  "11\t    fun3\tinst 27,27" \
-  ] "function-call-history from 27 backwards"
-
-# the instruction history should start at the new location
-gdb_test "record instruction-history -" [multi_line \
-  "25.*" \
-  "26.*" \
-  "27.*" \
-  ] "instruction-history from 27 backwards"
-
-# test that we can go to the begin of the trace
-gdb_test "record goto begin" ".*main \\(\\) at ${optional_filepath}record_goto.c:49.*"
-
-# check that we're filling up the context correctly
-gdb_test "record function-call-history /ci -" [multi_line \
-  "1\tmain\tinst 1,1" \
-  "2\t  fun4\tinst 2,4" \
-  "3\t    fun1\tinst 5,8" \
-  ] "function-call-history from begin backwards"
-
-# check that we're filling up the context correctly
-gdb_test "record instruction-history -" [multi_line \
-  "1.*" \
-  "2.*" \
-  "3.*" \
-  ] "instruction-history from begin backwards"
-
-# we should get the exact same history from the first instruction
-gdb_test "record goto 2" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:40.*"
-
-# check that we're filling up the context correctly
-gdb_test "record function-call-history /ci -" [multi_line \
-  "1\tmain\tinst 1,1" \
-  "2\t  fun4\tinst 2,4" \
-  "3\t    fun1\tinst 5,8" \
-  ] "function-call-history from 2 backwards"
-
-# check that we're filling up the context correctly
-gdb_test "record instruction-history -" [multi_line \
-  "1.*" \
-  "2.*" \
-  "3.*" \
-  ] "instruction-history from 2 backwards"
-
-# check that we can go to the end of the trace
-gdb_test "record goto end" ".*main \\(\\) at ${optional_filepath}record_goto.c:50.*"
-
-# check that we're filling up the context correctly
-gdb_test "record function-call-history /ci" [multi_line \
-  "14\t      fun2\tinst 35,36" \
-  "15\t    fun3\tinst 37,38" \
-  "16\t  fun4\tinst 39,40" \
-  ] "function-call-history from end forwards"
-
-# check that we're filling up the context correctly
-gdb_test "record instruction-history" [multi_line \
-  "38.*" \
-  "39.*" \
-  "40.*" \
-  ] "instruction-history from end forwards"
-
-# we should get the exact same history from the second to last instruction
-gdb_test "record goto 39" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:44.*"
-
-# check that we're filling up the context correctly
-gdb_test "record function-call-history /ci" [multi_line \
-  "14\t      fun2\tinst 35,36" \
-  "15\t    fun3\tinst 37,38" \
-  "16\t  fun4\tinst 39,40" \
-  ] "function-call-history from 39 forwards"
-
-# check that we're filling up the context correctly
-gdb_test "record instruction-history" [multi_line \
-  "38.*" \
-  "39.*" \
-  "40.*" \
-  ] "instruction-history from 39 forwards"
diff --git a/gdb/testsuite/gdb.btrace/rn-dl-bind.exp b/gdb/testsuite/gdb.btrace/rn-dl-bind.exp
index 756be2fe404..e7189100a36 100644
--- a/gdb/testsuite/gdb.btrace/rn-dl-bind.exp
+++ b/gdb/testsuite/gdb.btrace/rn-dl-bind.exp
@@ -24,39 +24,48 @@
 require allow_btrace_tests
 
 standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile \
-	{debug ldflags=-Wl,-z,lazy}] {
-    return -1
-}
 
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile \
+	{c++ debug ldflags=-Wl,-z,lazy}] {
     return -1
 }
 
-# trace the code for the call to test
-gdb_test_no_output "record btrace"
-gdb_test "next" ".*main\.2.*"
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
 
-# just dump the function-call-history to help debugging
-gdb_test_no_output "set record function-call-history-size 0"
-gdb_test "record function-call-history /cli 1" ".*"
+    if ![runto_main] {
+	continue
+    }
 
-# check that we can reverse-next and next
-with_test_prefix "main" {
-    gdb_test "reverse-next" ".*main\.1.*"
+    # trace the code for the call to test
+    gdb_test_no_output "record btrace ${method}"
     gdb_test "next" ".*main\.2.*"
-}
 
-# now go into test and try to (reverse-)next over the library call
-#
-# reverse-stepping through the epilogue is not very reliable; depending on
-# debug information we may stop at the closing brace or at the return.
-#
-# instead, run to test
-gdb_breakpoint test {temporary}
-gdb_test "reverse-continue" ".*test\.1.*"
+    # just dump the function-call-history to help debugging
+    gdb_test_no_output "set record function-call-history-size 0"
+    gdb_test "record function-call-history /cli 1" ".*"
+
+    # check that we can reverse-next and next
+    with_test_prefix "main" {
+	gdb_test "reverse-next" ".*main\.1.*"
+	gdb_test "next" ".*main\.2.*"
+    }
+
+    # now go into test and try to (reverse-)next over the library call
+    #
+    # reverse-stepping through the epilogue is not very reliable; depending on
+    # debug information we may stop at the closing brace or at the return.
+    #
+    # instead, run to test
+    gdb_breakpoint test {temporary}
+    gdb_test "reverse-continue" ".*test\.1.*"
 
-with_test_prefix "test" {
-    gdb_test "next" ".*test\.2.*"
-    gdb_test "reverse-next" ".*test\.1.*"
+    with_test_prefix "test" {
+	gdb_test "next" ".*test\.2.*"
+	gdb_test "reverse-next" ".*test\.1.*"
+    }
 }
diff --git a/gdb/testsuite/gdb.btrace/segv.exp b/gdb/testsuite/gdb.btrace/segv.exp
index 9804b93a877..20c13b05d9a 100644
--- a/gdb/testsuite/gdb.btrace/segv.exp
+++ b/gdb/testsuite/gdb.btrace/segv.exp
@@ -20,24 +20,32 @@
 require allow_btrace_tests
 
 standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
-    return -1
-}
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
-# trace the test code
-gdb_test_no_output "record btrace"
-gdb_test "continue" [multi_line \
-  "Program received signal SIGSEGV, Segmentation fault\." \
-  "0x0* in \\\?\\\? \\\(\\\)" \
-  ] "cont to segv"
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
 
-# we cannot do any high-level stepping
-gdb_test "reverse-finish" "Cannot find bounds of current function"
-gdb_test "reverse-next" "Cannot find bounds of current function"
-gdb_test "reverse-step" "Cannot find bounds of current function"
+    # trace the test code
+    gdb_test_no_output "record btrace ${method}"
+    gdb_test "continue" [multi_line \
+	"Program received signal SIGSEGV, Segmentation fault\." \
+	"0x0* in \\\?\\\? \\\(\\\)" \
+    ] "cont to segv"
 
-# but we can do instruction stepping
-gdb_test "reverse-stepi" "test\.call\[^\\\r\\\n\]*"
+    # we cannot do any high-level stepping
+    gdb_test "reverse-finish" "Cannot find bounds of current function"
+    gdb_test "reverse-next" "Cannot find bounds of current function"
+    gdb_test "reverse-step" "Cannot find bounds of current function"
+
+    # but we can do instruction stepping
+    gdb_test "reverse-stepi" "test\.call\[^\\\r\\\n\]*"
+}
diff --git a/gdb/testsuite/gdb.btrace/step.exp b/gdb/testsuite/gdb.btrace/step.exp
index 0adc18bd924..678461045a2 100644
--- a/gdb/testsuite/gdb.btrace/step.exp
+++ b/gdb/testsuite/gdb.btrace/step.exp
@@ -20,29 +20,37 @@
 require allow_btrace_tests
 
 standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
-    return -1
-}
 
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
-# trace the call to the test function
-with_test_prefix "record" {
-    gdb_test_no_output "record btrace"
-    gdb_test "next"
-}
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
+
+    # trace the call to the test function
+    with_test_prefix "record" {
+	gdb_test_no_output "record btrace ${method}"
+	gdb_test "next"
+    }
 
-# let's step around a bit
-with_test_prefix "replay" {
-    gdb_test "reverse-next" ".*main\.2.*" "reverse-next.1"
-    gdb_test "step" ".*fun4\.2.*" "step.1"
-    gdb_test "next" ".*fun4\.3.*" "next.1"
-    gdb_test "step" ".*fun2\.2.*" "step.2"
-    gdb_test "finish" ".*fun4\.4.*" "finish.1"
-    gdb_test "reverse-step" ".*fun2\.3.*" "reverse-step.1"
-    gdb_test "reverse-finish" ".*fun4\.3.*" "reverse-finish.1"
-    gdb_test "reverse-next" ".*fun4\.2.*" "reverse-next.2"
-    gdb_test "reverse-finish" ".*main\.2.*" "reverse-finish.2"
+    # let's step around a bit
+    with_test_prefix "replay" {
+	gdb_test "reverse-next" ".*main\.2.*" "reverse-next.1"
+	gdb_test "step" ".*fun4\.2.*" "step.1"
+	gdb_test "next" ".*fun4\.3.*" "next.1"
+	gdb_test "step" ".*fun2\.2.*" "step.2"
+	gdb_test "finish" ".*fun4\.4.*" "finish.1"
+	gdb_test "reverse-step" ".*fun2\.3.*" "reverse-step.1"
+	gdb_test "reverse-finish" ".*fun4\.3.*" "reverse-finish.1"
+	gdb_test "reverse-next" ".*fun4\.2.*" "reverse-next.2"
+	gdb_test "reverse-finish" ".*main\.2.*" "reverse-finish.2"
+    }
 }
diff --git a/gdb/testsuite/gdb.btrace/stepi.exp b/gdb/testsuite/gdb.btrace/stepi.exp
index a70a5adf046..c8346f28eef 100644
--- a/gdb/testsuite/gdb.btrace/stepi.exp
+++ b/gdb/testsuite/gdb.btrace/stepi.exp
@@ -41,11 +41,7 @@ if [info exists COMPILE] {
     return -1
 }
 
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {}] {
-    return -1
-}
-
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
@@ -60,119 +56,130 @@ proc check_replay_at { insn } {
     ] "check replay at $insn"
 }
 
-# trace the call to the test function
-with_test_prefix "record" {
-    gdb_test_no_output "record btrace"
-    gdb_test "next" ".*" "next.1"
-}
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
 
-# we start with stepping to make sure that the trace is fetched automatically
-with_test_prefix "fetch" {
-    gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.1"
-    gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.2"
+    # trace the call to the test function
+    with_test_prefix "record" {
+	gdb_test_no_output "record btrace ${method}"
+	gdb_test "next" ".*" "next.1"
+    }
 
-    # let's check where we are in the trace
-    check_replay_at 39
-}
+    # we start with stepping to make sure that the trace is fetched automatically
+    with_test_prefix "fetch" {
+	gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.1"
+	gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.2"
 
-# let's step forward and check again
-with_test_prefix "stepi" {
-    gdb_test "stepi" ".*fun4\.5.*"
-    check_replay_at 40
-}
+	# let's check where we are in the trace
+	check_replay_at 39
+    }
 
-# with the next step, we stop replaying
-with_test_prefix "end" {
-    gdb_test "stepi" ".*main\.3.*"
-    gdb_test "info record" [multi_line \
-      "Active record target: record-btrace" \
-      ".*" \
-      "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
-			       ]
-}
+    # let's step forward and check again
+    with_test_prefix "stepi" {
+	gdb_test "stepi" ".*fun4\.5.*"
+	check_replay_at 40
+    }
 
-# let's try nexti
-with_test_prefix "reverse-nexti.1" {
-    gdb_test "reverse-nexti" ".*main\.2.*"
-    check_replay_at 1
-}
+    # with the next step, we stop replaying
+    with_test_prefix "end" {
+	gdb_test "stepi" ".*main\.3.*"
+	gdb_test "info record" [multi_line \
+	    "Active record target: record-btrace" \
+	    ".*" \
+	    "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
+	    ]
+    }
 
-# we can't reverse-nexti any further
-with_test_prefix "reverse-nexti.2" {
-    gdb_test "reverse-nexti" \
-	"No more reverse-execution history\.\r\n.*main\.2.*" \
-	"reverse-nexti.2"
-    check_replay_at 1
-}
+    # let's try nexti
+    with_test_prefix "reverse-nexti.1" {
+	gdb_test "reverse-nexti" ".*main\.2.*"
+	check_replay_at 1
+    }
 
-# but we can step back again
-with_test_prefix "nexti" {
-    gdb_test "nexti" ".*main\.3.*"
-    gdb_test "info record" [multi_line \
-      "Active record target: record-btrace" \
-      ".*" \
-      "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
-			       ]
-}
+    # we can't reverse-nexti any further
+    with_test_prefix "reverse-nexti.2" {
+	gdb_test "reverse-nexti" \
+	    "No more reverse-execution history\.\r\n.*main\.2.*" \
+	    "reverse-nexti.2"
+	check_replay_at 1
+    }
 
-# let's step from a goto position somewhere in the middle
-with_test_prefix "goto" {
-    gdb_test "record goto 22" ".*fun3\.2.*"
-    with_test_prefix "goto 22" { check_replay_at 22 }
+    # but we can step back again
+    with_test_prefix "nexti" {
+	gdb_test "nexti" ".*main\.3.*"
+	gdb_test "info record" [multi_line \
+	    "Active record target: record-btrace" \
+	    ".*" \
+	    "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
+	    ]
+    }
 
-    gdb_test "stepi" ".*fun1\.1.*" "stepi.3"
-    with_test_prefix "stepi to 23" { check_replay_at 23 }
+    # let's step from a goto position somewhere in the middle
+    with_test_prefix "goto" {
+	gdb_test "record goto 22" ".*fun3\.2.*"
+	with_test_prefix "goto 22" { check_replay_at 22 }
 
-    gdb_test "reverse-stepi" ".*fun3\.2.*" "reverse-stepi.3"
-    with_test_prefix "reverse-stepi to 22" { check_replay_at 22 }
+	gdb_test "stepi" ".*fun1\.1.*" "stepi.3"
+	with_test_prefix "stepi to 23" { check_replay_at 23 }
 
-    gdb_test "nexti" ".*fun3\.3.*"
-    with_test_prefix "nexti to 27" { check_replay_at 27 }
+	gdb_test "reverse-stepi" ".*fun3\.2.*" "reverse-stepi.3"
+	with_test_prefix "reverse-stepi to 22" { check_replay_at 22 }
 
-    gdb_test "reverse-nexti" ".*fun3\.2.*" "reverse-nexti.3"
-    with_test_prefix "reverse-nexti to 22" { check_replay_at 22 }
-}
+	gdb_test "nexti" ".*fun3\.3.*"
+	with_test_prefix "nexti to 27" { check_replay_at 27 }
 
-# let's try to step off the left end
-with_test_prefix "goto begin" {
-    gdb_test "record goto begin" ".*main\.2.*"
-    check_replay_at 1
+	gdb_test "reverse-nexti" ".*fun3\.2.*" "reverse-nexti.3"
+	with_test_prefix "reverse-nexti to 22" { check_replay_at 22 }
+    }
 
-    with_test_prefix "reverse-stepi" {
-	gdb_test "reverse-stepi" \
-	    "No more reverse-execution history\.\r\n.*main\.2.*" \
-	    "reverse-stepi.1"
-	gdb_test "reverse-stepi" \
-	    "No more reverse-execution history\.\r\n.*main\.2.*" \
-	    "reverse-stepi.2"
+    # let's try to step off the left end
+    with_test_prefix "goto begin" {
+	gdb_test "record goto begin" ".*main\.2.*"
 	check_replay_at 1
+
+	with_test_prefix "reverse-stepi" {
+	    gdb_test "reverse-stepi" \
+		"No more reverse-execution history\.\r\n.*main\.2.*" \
+		"reverse-stepi.1"
+	    gdb_test "reverse-stepi" \
+		"No more reverse-execution history\.\r\n.*main\.2.*" \
+		"reverse-stepi.2"
+	    check_replay_at 1
+	}
+
+	with_test_prefix "reverse-nexti" {
+	    gdb_test "reverse-nexti" \
+		"No more reverse-execution history\.\r\n.*main\.2.*" \
+		"reverse-nexti.1"
+	    gdb_test "reverse-nexti" \
+		"No more reverse-execution history\.\r\n.*main\.2.*" \
+		"reverse-nexti.2"
+	    check_replay_at 1
+	}
+
+	# we can step forward, though
+	with_test_prefix "stepi" {
+	    gdb_test "stepi" ".*fun4\.1.*"
+	    check_replay_at 2
+	}
     }
 
-    with_test_prefix "reverse-nexti" {
-	gdb_test "reverse-nexti" \
+    # let's try to step off the left end again
+    with_test_prefix "reverse-stepi" {
+	gdb_test "reverse-stepi" ".*main\.2.*" "reverse-stepi.1"
+	gdb_test "reverse-stepi" \
 	    "No more reverse-execution history\.\r\n.*main\.2.*" \
-	    "reverse-nexti.1"
-	gdb_test "reverse-nexti" \
+	    "reverse-stepi.2"
+	gdb_test "reverse-stepi" \
 	    "No more reverse-execution history\.\r\n.*main\.2.*" \
-	    "reverse-nexti.2"
+	    "reverse-stepi.3"
 	check_replay_at 1
     }
-
-    # we can step forward, though
-    with_test_prefix "stepi" {
-	gdb_test "stepi" ".*fun4\.1.*"
-	check_replay_at 2
-    }
-}
-
-# let's try to step off the left end again
-with_test_prefix "reverse-stepi" {
-    gdb_test "reverse-stepi" ".*main\.2.*" "reverse-stepi.1"
-    gdb_test "reverse-stepi" \
-	"No more reverse-execution history\.\r\n.*main\.2.*" \
-	"reverse-stepi.2"
-    gdb_test "reverse-stepi" \
-	"No more reverse-execution history\.\r\n.*main\.2.*" \
-	"reverse-stepi.3"
-    check_replay_at 1
 }
diff --git a/gdb/testsuite/gdb.btrace/tailcall-only.exp b/gdb/testsuite/gdb.btrace/tailcall-only.exp
index ae3b04e3b66..c90ba8b1bd3 100644
--- a/gdb/testsuite/gdb.btrace/tailcall-only.exp
+++ b/gdb/testsuite/gdb.btrace/tailcall-only.exp
@@ -21,7 +21,6 @@
 #
 
 require allow_btrace_tests
-
 # This test requires the compiler to generate a tail call.  To guarantee that
 # we always get one, we use an assembly source file.
 #
@@ -29,6 +28,7 @@ require allow_btrace_tests
 #
 # Luckily, they are similar enough that a single test script can handle
 # both.
+
 set opts {}
 if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.btrace/tailcall-only.exp COMPILE=1"
@@ -45,55 +45,63 @@ if [info exists COMPILE] {
     return -1
 }
 
-if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
+if [build_executable "failed to prepare" $testfile $srcfile $opts] {
     return -1
 }
 
-if ![runto_main] {
-    return -1
-}
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
 
-# we want to see the full trace for this test
-gdb_test_no_output "set record function-call-history-size 0"
+    if ![runto_main] {
+	continue
+    }
 
-# trace foo
-gdb_test "step" ".*" "prepare for recording"
-gdb_test_no_output "record btrace"
-gdb_test "stepi 4" ".*" "record branch trace"
+    # we want to see the full trace for this test
+    gdb_test_no_output "set record function-call-history-size 0"
 
-# for debugging
-gdb_test "info record" ".*"
+    # trace foo
+    gdb_test "step" ".*" "prepare for recording"
+    gdb_test_no_output "record btrace ${method}"
+    gdb_test "stepi 4" ".*" "record branch trace"
 
-# show the branch trace with calls indented
-gdb_test "record function-call-history /c 1" [multi_line \
-  "1\tfoo" \
-  "2\t  foo_1" \
-  "3\t    bar" \
-  "4\t      bar_1"
-  ] "function-call-history"
+    # for debugging
+    gdb_test "info record" ".*"
 
-# We can step
-gdb_test "record goto begin" ".*foo.*"
-gdb_test "stepi" ".*foo_1.*" "step into foo_1"
-gdb_test "step" ".*bar.*" "step into bar"
-gdb_test "stepi" ".*bar_1.*" "step into bar_1"
+    # show the branch trace with calls indented
+    gdb_test "record function-call-history /c 1" [multi_line \
+	"1\tfoo" \
+	"2\t  foo_1" \
+	"3\t    bar" \
+	"4\t      bar_1"
+	] "function-call-history"
 
-# We can neither finish nor return.
-gdb_test "finish" "Cannot find the caller frame.*"
-gdb_test_multiple "return" "return" {
-  -re "Make .* return now.*y or n. $" {
-    send_gdb "y\n"
-    exp_continue
-  }
-  -re "Cannot find the caller frame.*$gdb_prompt $" {
-    pass "return"
-  }
-}
+    # We can step
+    gdb_test "record goto begin" ".*foo.*"
+    gdb_test "stepi" ".*foo_1.*" "step into foo_1"
+    gdb_test "step" ".*bar.*" "step into bar"
+    gdb_test "stepi" ".*bar_1.*" "step into bar_1"
 
-# But we can reverse-finish
-gdb_test "reverse-finish" ".*bar.*"
-gdb_test "reverse-step" ".*foo_1.*"
+    # We can neither finish nor return.
+    gdb_test "finish" "Cannot find the caller frame.*"
+    gdb_test_multiple "return" "return" {
+	-re "Make .* return now.*y or n. $" {
+	    send_gdb "y\n"
+	    continue
+	}
+	-re "Cannot find the caller frame.*$gdb_prompt $" {
+	    pass "return"
+	}
+    }
 
-# Info frame isn't useful but doesn't crash as it used to.
-gdb_test "up" ".*foo.*"
-gdb_test "info frame" ".*"
+    # But we can reverse-finish
+    gdb_test "reverse-finish" ".*bar.*"
+    gdb_test "reverse-step" ".*foo_1.*"
+
+    # Info frame isn't useful but doesn't crash as it used to.
+    gdb_test "up" ".*foo.*"
+    gdb_test "info frame" ".*"
+}
diff --git a/gdb/testsuite/gdb.btrace/tailcall.exp b/gdb/testsuite/gdb.btrace/tailcall.exp
index 198cfa988dd..2116dae6a1c 100644
--- a/gdb/testsuite/gdb.btrace/tailcall.exp
+++ b/gdb/testsuite/gdb.btrace/tailcall.exp
@@ -32,20 +32,17 @@ if [info exists COMPILE] {
     standard_testfile tailcall.c
     lappend opts debug optimize=-O2
 } elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} {
-	if {[is_amd64_regs_target]} {
-		standard_testfile x86_64-tailcall.S
-	} else {
-		standard_testfile i686-tailcall.S
-	}
+    if {[is_amd64_regs_target]} {
+	standard_testfile x86_64-tailcall.S
+    } else {
+	standard_testfile i686-tailcall.S
+    }
 } else {
     unsupported "target architecture not supported"
     return -1
 }
 
-if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
-    return -1
-}
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile $opts] {
     return -1
 }
 
@@ -54,63 +51,75 @@ if ![runto_main] {
 # that path to be present, but does not require it.
 set optional_filepath {[^\n]*}
 
-# we want to see the full trace for this test
-gdb_test_no_output "set record function-call-history-size 0"
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+
+    if ![runto_main] {
+	continue
+    }
 
-# trace the call to foo
-gdb_test_no_output "record btrace"
-gdb_test "next 2"
+    # we want to see the full trace for this test
+    gdb_test_no_output "set record function-call-history-size 0"
 
-# show the flat branch trace
-gdb_test "record function-call-history 1" [multi_line \
-  "1\tmain" \
-  "2\tfoo" \
-  "3\tbar" \
-  "4\tmain" \
-  ] "flat"
+    # trace the call to foo
+    gdb_test_no_output "record btrace ${method}"
+    gdb_test "next 2"
 
-# show the branch trace with calls indented
-gdb_test "record function-call-history /c 1" [multi_line \
-  "1\tmain" \
-  "2\t  foo" \
-  "3\t    bar" \
-  "4\tmain" \
-  ] "indented"
+    # show the flat branch trace
+    gdb_test "record function-call-history 1" [multi_line \
+	"1\tmain" \
+	"2\tfoo" \
+	"3\tbar" \
+	"4\tmain" \
+	] "flat"
 
-# go into bar
-gdb_test "record goto 4" ".*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*"
+    # show the branch trace with calls indented
+    gdb_test "record function-call-history /c 1" [multi_line \
+	"1\tmain" \
+	"2\t  foo" \
+	"3\t    bar" \
+	"4\tmain" \
+	] "indented"
 
-# check the backtrace
-gdb_test "backtrace" [multi_line \
-  "#0.*bar \\(\\) at ${optional_filepath}tailcall.c:24" \
-  "#1.*foo \\(\\) at ${optional_filepath}tailcall.c:29" \
-  "#2.*main \\(\\) at ${optional_filepath}tailcall.c:37" \
-  "Backtrace stopped: not enough registers or memory available to unwind further" \
-  ]
+    # go into bar
+    gdb_test "record goto 4" ".*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*"
 
-# walk the backtrace
-gdb_test "up" "#1\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" "up to foo"
-gdb_test "up" "#2\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" "up to main"
-gdb_test "down" "#1\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" "down to foo"
+    # check the backtrace
+    gdb_test "backtrace" [multi_line \
+	"#0.*bar \\(\\) at ${optional_filepath}tailcall.c:24" \
+	"#1.*foo \\(\\) at ${optional_filepath}tailcall.c:29" \
+	"#2.*main \\(\\) at ${optional_filepath}tailcall.c:37" \
+	"Backtrace stopped: not enough registers or memory available to unwind further" \
+	]
 
-# test stepping into and out of tailcalls.
-gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
-    "finish.1"
-gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*" \
-    "reverse-step.1"
-gdb_test "reverse-finish" "\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" \
-    "reverse-finish.1"
-gdb_test "reverse-step" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" \
-    "reverse-step.2"
-gdb_test "next" "\[^\r\n\]*38.*" \
-    "next.1"
-gdb_test "reverse-next" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" \
-    "reverse-next.1"
-gdb_test "step" "\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" \
-    "step.1"
-gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
-    "finish.2"
-gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*" \
-    "reverse-step.3"
-gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
-    "finish.3"
+    # walk the backtrace
+    gdb_test "up" "#1\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" "up to foo"
+    gdb_test "up" "#2\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" "up to main"
+    gdb_test "down" "#1\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" "down to foo"
+
+    # test stepping into and out of tailcalls.
+    gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
+	"finish.1"
+    gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*" \
+	"reverse-step.1"
+    gdb_test "reverse-finish" "\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" \
+	"reverse-finish.1"
+    gdb_test "reverse-step" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" \
+	"reverse-step.2"
+    gdb_test "next" "\[^\r\n\]*38.*" \
+	"next.1"
+    gdb_test "reverse-next" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" \
+	"reverse-next.1"
+    gdb_test "step" "\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" \
+	"step.1"
+    gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
+	"finish.2"
+    gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*" \
+	"reverse-step.3"
+    gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
+	"finish.3"
+}
diff --git a/gdb/testsuite/gdb.btrace/tsx.exp b/gdb/testsuite/gdb.btrace/tsx.exp
index d312b15027c..11e230c8547 100644
--- a/gdb/testsuite/gdb.btrace/tsx.exp
+++ b/gdb/testsuite/gdb.btrace/tsx.exp
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-require allow_btrace_pt_tests allow_tsx_tests
+require allow_btrace_pt_tests allow_tsx_tests allow_btrace_tests
 
 standard_testfile .c x86-tsx.S
 if [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" {debug}] {
diff --git a/gdb/testsuite/gdb.btrace/unknown_functions.exp b/gdb/testsuite/gdb.btrace/unknown_functions.exp
index b335e74c87a..618df4c9761 100644
--- a/gdb/testsuite/gdb.btrace/unknown_functions.exp
+++ b/gdb/testsuite/gdb.btrace/unknown_functions.exp
@@ -18,47 +18,53 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 require allow_btrace_tests
-
 standard_testfile
 
 # We expect a specific function call history.  This gets messed up with
 # PIE on 32-bit.
 #
 # Also discard local symbols.
-if [prepare_for_testing "failed to prepare" $testfile $srcfile \
+if [build_executable "failed to prepare" $testfile $srcfile \
 	{ldflags=-Wl,-x nopie}] {
     return -1
 }
 
-if ![runto test] {
-    return -1
-}
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto test] {
+	continue
+    }
 
-# we want to see the full trace for this test
-gdb_test_no_output "set record function-call-history-size 0"
+    # we want to see the full trace for this test
+    gdb_test_no_output "set record function-call-history-size 0"
 
-# trace from one call of test to the next
-gdb_test_no_output "record btrace"
-gdb_continue_to_breakpoint "cont to test" ".*test.*"
+    # trace from one call of test to the next
+    gdb_test_no_output "record btrace ${method}"
+    gdb_continue_to_breakpoint "cont to test" ".*test.*"
 
-# show the flat branch trace
-gdb_test "record function-call-history 1" [multi_line \
-  "1\ttest" \
-  "2\t\\\?\\\?" \
-  "3\t\\\?\\\?" \
-  "4\t\\\?\\\?" \
-  "5\ttest" \
-  "6\tmain" \
-  "7\ttest" \
-  ] "flat"
+    # show the flat branch trace
+    gdb_test "record function-call-history 1" [multi_line \
+	"1\ttest" \
+	"2\t\\\?\\\?" \
+	"3\t\\\?\\\?" \
+	"4\t\\\?\\\?" \
+	"5\ttest" \
+	"6\tmain" \
+	"7\ttest" \
+	] "flat"
 
-# show the branch trace with calls indented
-gdb_test "record function-call-history /c 1" [multi_line \
-  "1\t  test" \
-  "2\t    \\\?\\\?" \
-  "3\t      \\\?\\\?" \
-  "4\t    \\\?\\\?" \
-  "5\t  test" \
-  "6\tmain" \
-  "7\t  test" \
-  ] "indented"
+    # show the branch trace with calls indented
+    gdb_test "record function-call-history /c 1" [multi_line \
+	"1\t  test" \
+	"2\t    \\\?\\\?" \
+	"3\t      \\\?\\\?" \
+	"4\t    \\\?\\\?" \
+	"5\t  test" \
+	"6\tmain" \
+	"7\t  test" \
+	] "indented"
+}
diff --git a/gdb/testsuite/gdb.btrace/vdso.exp b/gdb/testsuite/gdb.btrace/vdso.exp
index edbb222f7b6..cf01ed6fcd1 100644
--- a/gdb/testsuite/gdb.btrace/vdso.exp
+++ b/gdb/testsuite/gdb.btrace/vdso.exp
@@ -23,22 +23,29 @@
 require allow_btrace_tests
 
 standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
-    return -1
-}
 
-if ![runto_main] {
+if [build_executable "failed to prepare" $testfile $srcfile] {
     return -1
 }
 
-# capture the disassembly of gettimeofday while live debugging
-set live_gettimeofday [capture_command_output "disassemble gettimeofday" ""]
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
+
+    # capture the disassembly of gettimeofday while live debugging
+    set live_gettimeofday [capture_command_output "disassemble gettimeofday" ""]
 
-# trace the test code
-gdb_test_no_output "record btrace"
-gdb_test "stepi" ".*"
+    # trace the test code
+    gdb_test_no_output "record btrace ${method}"
+    gdb_test "stepi" ".*"
 
-with_test_prefix "replay" {
+    with_test_prefix "replay" {
 	# start replaying
 	gdb_test "record goto begin" ".*"
 	gdb_test "info record" "Replay in progress\.\[^\\\r\\\n\]*"
@@ -48,8 +55,9 @@ with_test_prefix "replay" {
 
 	# the two disassemblies must be identical
 	if ![string compare $live_gettimeofday $replay_gettimeofday]  {
-		pass "disassemble gettimeofday"
-	} else {
-		fail "disassemble gettimeofday"
+	    pass "disassemble gettimeofday"
+	} else 	{
+	    fail "disassemble gettimeofday"
 	}
+    }
 }
diff --git a/gdb/testsuite/gdb.python/py-record-btrace-threads.exp b/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
index d7238790bc4..e673cc6b5ae 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
@@ -25,45 +25,52 @@ if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {deb
     untested "failed to prepare"
     return -1
 }
-clean_restart $testfile
 
-if { ![runto_main] } {
-    return -1
-}
+foreach_with_prefix method {"bts" "pt"} {
+    if { ![target_supports_btrace $method] } {
+	unsupported "target does not support record-btrace ${method}"
+	continue
+    }
 
-# set up breakpoints
-gdb_breakpoint $srcfile:[gdb_get_line_number "bp1" $srcfile]
-gdb_breakpoint $srcfile:[gdb_get_line_number "bp2" $srcfile]
+    clean_restart "${testfile}"
+    if ![runto_main] {
+	continue
+    }
 
-# record data
-gdb_continue_to_breakpoint "cont to bp.1" ".*bp1.*"
-gdb_test_no_output "record btrace"
-gdb_continue_to_breakpoint "cont to bp.2" ".*bp2.*"
+    # set up breakpoints
+    gdb_breakpoint $srcfile:[gdb_get_line_number "bp1" $srcfile]
+    gdb_breakpoint $srcfile:[gdb_get_line_number "bp2" $srcfile]
 
-# acquire the record objects for thread 1 and thread 2
-gdb_test "thread 1" ".*"
-gdb_test "record function-call-history" ".*" "fch thread 1"
-gdb_test_no_output "python rec1 = gdb.current_recording()"
-gdb_test "thread 2" ".*"
-gdb_test "record function-call-history" ".*" "fch thread 2"
-gdb_test_no_output "python rec2 = gdb.current_recording()"
+    # record data
+    gdb_continue_to_breakpoint "cont to bp.1" ".*bp1.*"
+    gdb_test_no_output "record btrace ${method}"
+    gdb_continue_to_breakpoint "cont to bp.2" ".*bp2.*"
 
-# Thread 1 is supposed to call func1 (), thread 2 is supposed to call func2 ().
-# Check that the function call history for the current thread contains a call
-# to the right function and does not contain a call to the wrong function.
-proc check_insn_for_thread { self other } {
-  with_test_prefix "checking thread $self" {
-    gdb_test_no_output "python fch = rec$self.function_call_history"
-    gdb_test_no_output "python f1calls = \{x for x in fch if x.symbol and x.symbol.name == \"func1\"\}"
-    gdb_test_no_output "python f2calls = \{x for x in fch if x.symbol and x.symbol.name == \"func2\"\}"
+    # acquire the record objects for thread 1 and thread 2
+    gdb_test "thread 1" ".*"
+    gdb_test "record function-call-history" ".*" "fch thread 1"
+    gdb_test_no_output "python rec1 = gdb.current_recording()"
+    gdb_test "thread 2" ".*"
+    gdb_test "record function-call-history" ".*" "fch thread 2"
+    gdb_test_no_output "python rec2 = gdb.current_recording()"
 
-    gdb_test "python print(not f${self}calls)" "False"
-    gdb_test "python print(not f${other}calls)" "True"
-  }
-}
+    # Thread 1 is supposed to call func1 (), thread 2 is supposed to call func2 ().
+    # Check that the function call history for the current thread contains a call
+    # to the right function and does not contain a call to the wrong function.
+    proc check_insn_for_thread { self other } {
+	with_test_prefix "checking thread $self" {
+	    gdb_test_no_output "python fch = rec$self.function_call_history"
+	    gdb_test_no_output "python f1calls = \{x for x in fch if x.symbol and x.symbol.name == \"func1\"\}"
+	    gdb_test_no_output "python f2calls = \{x for x in fch if x.symbol and x.symbol.name == \"func2\"\}"
+
+	    gdb_test "python print(not f${self}calls)" "False"
+	    gdb_test "python print(not f${other}calls)" "True"
+	}
+    }
 
-foreach_with_prefix thread { 1 2 } {
-  gdb_test "thread $thread"
-  check_insn_for_thread 1 2
-  check_insn_for_thread 2 1
+    foreach_with_prefix thread { 1 2 } {
+	gdb_test "thread $thread"
+	check_insn_for_thread 1 2
+	check_insn_for_thread 2 1
+    }
 }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fe4ac7d2719..62eadc9696f 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4008,68 +4008,29 @@ gdb_caching_proc allow_avx512fp16_tests {} {
     return $allow_avx512fp16_tests
 }
 
-# Run a test on the target to see if it supports btrace hardware.  Return 1 if so,
-# 0 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
+# Check if btrace is supported on the target.  Return 1 if
+# so, 0 if it does not.
 
 gdb_caching_proc allow_btrace_tests {} {
-    global srcdir subdir gdb_prompt inferior_exited_re
-
-    set me "allow_btrace_tests"
     if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
-	verbose "$me:  target does not support btrace, returning 0" 2
-	return 0
-    }
-
-    # Compile a test program.
-    set src { int main() { return 0; } }
-    if {![gdb_simple_compile $me $src executable]} {
+	verbose "target_supports_btrace:  target does not support btrace, returning 0" 2
 	return 0
     }
 
-    # No error message, compilation succeeded so now run it via gdb.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $obj
-    if ![runto_main] {
+    if { ![allow_btrace_bts_tests] && ![allow_btrace_pt_tests] } {
 	return 0
     }
-    # In case of an unexpected output, we return 2 as a fail value.
-    set allow_btrace_tests 2
-    gdb_test_multiple "record btrace" "check btrace support" {
-        -re "You can't do that when your target is.*\r\n$gdb_prompt $" {
-	    set allow_btrace_tests 0
-        }
-        -re "Target does not support branch tracing.*\r\n$gdb_prompt $" {
-	    set allow_btrace_tests 0
-        }
-        -re "Could not enable branch tracing.*\r\n$gdb_prompt $" {
-	    set allow_btrace_tests 0
-        }
-        -re "^record btrace\r\n$gdb_prompt $" {
-	    set allow_btrace_tests 1
-        }
-    }
-    gdb_exit
-    remote_file build delete $obj
-
-    verbose "$me:  returning $allow_btrace_tests" 2
-    return $allow_btrace_tests
+    return 1
 }
 
-# Run a test on the target to see if it supports btrace pt hardware.
+# Run a test on the target to see if it supports btrace input method.
 # Return 1 if so, 0 if it does not.  Based on 'check_vmx_hw_available'
 # from the GCC testsuite.
 
-gdb_caching_proc allow_btrace_pt_tests {} {
+proc check_btrace_method_support {method} {
     global srcdir subdir gdb_prompt inferior_exited_re
 
-    set me "allow_btrace_pt_tests"
-    if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
-	verbose "$me:  target does not support btrace, returning 1" 2
-	return 0
-    }
+    set me "check_btrace_${method}_support"
 
     # Compile a test program.
     set src { int main() { return 0; } }
@@ -4087,31 +4048,62 @@ gdb_caching_proc allow_btrace_pt_tests {} {
 	return 0
     }
     # In case of an unexpected output, we return 2 as a fail value.
-    set allow_btrace_pt_tests 2
-    gdb_test_multiple "record btrace pt" "check btrace pt support" {
-        -re "You can't do that when your target is.*\r\n$gdb_prompt $" {
-	    set allow_btrace_pt_tests 0
-        }
-        -re "Target does not support branch tracing.*\r\n$gdb_prompt $" {
-	    set allow_btrace_pt_tests 0
-        }
-        -re "Could not enable branch tracing.*\r\n$gdb_prompt $" {
-	    set allow_btrace_pt_tests 0
-        }
-        -re "support was disabled at compile time.*\r\n$gdb_prompt $" {
-	    set allow_btrace_pt_tests 0
-        }
-        -re "^record btrace pt\r\n$gdb_prompt $" {
-	    set allow_btrace_pt_tests 1
-        }
+    set supports_method 2
+    gdb_test_multiple "record btrace ${method}" "check btrace ${method} support" {
+	-re -wrap "You can't do that when your target is.*" {
+	    set supports_method 0
+	}
+	-re -wrap "Target does not support branch tracing.*" {
+	    set supports_method 0
+	}
+	-re -wrap "Could not enable branch tracing.*" {
+	    set supports_method 0
+	}
+	-re -wrap "support was disabled at compile time.*" {
+	    set supports_method 0
+	}
+	-re -wrap "" {
+	    set supports_method 1
+	}
     }
     gdb_exit
     remote_file build delete $obj
 
-    verbose "$me:  returning $allow_btrace_pt_tests" 2
-    return $allow_btrace_pt_tests
+    verbose "$me:  returning $supports_method" 2
+    return $supports_method
 }
 
+# Run a test on the target to see if it supports btrace 'bts' method.  Return
+# 1 if so, 0 if it does not.
+
+gdb_caching_proc allow_btrace_bts_tests {} {
+    return [check_btrace_method_support "bts"]
+}
+
+# Run a test on the target to see if it supports btrace 'pt' method.  Return
+# 1 if so, 0 if it does not.  Based on 'check_vmx_hw_available' from the GCC
+# testsuite.
+
+gdb_caching_proc allow_btrace_pt_tests {} {
+    return [check_btrace_method_support "pt"]
+}
+
+# Wrapper function to check if input btrace method is supported.  Returns 1
+# if it is supported otherwise returns 0.
+
+proc target_supports_btrace {method} {
+    if {[string match "pt" "${method}"]} {
+	return [allow_btrace_pt_tests]
+    } elseif {[string match "bts" "${method}"]} {
+	return [allow_btrace_bts_tests]
+    }
+
+    verbose -log "warning: unknown btrace recording method '${method}'"
+    # Skip test for unknown method name.
+    return 0
+}
+
+
 # Run a test on the target to see if it supports Aarch64 SVE hardware.
 # Return 1 if so, 0 if it does not.  Note this causes a restart of GDB.
 
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 2%]

* [PATCH v2 3/3] Use ui-out tables in linux-tdep.c
  @ 2024-03-03 18:43  8% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-03-03 18:43 UTC (permalink / raw)
  To: gdb-patches

This changes a couple of spots in linux-tdep.c to use a ui-out table.
It also changes the output to style the file names.
---
 gdb/linux-tdep.c | 114 ++++++++++++++++++++++---------------------------------
 1 file changed, 46 insertions(+), 68 deletions(-)

diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 701e3df7a27..4bac4d81abd 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -43,6 +43,7 @@
 #include "gcore-elf.h"
 #include "solib-svr4.h"
 #include "memtag.h"
+#include "cli/cli-style.h"
 
 #include <ctype.h>
 #include <unordered_map>
@@ -457,7 +458,7 @@ struct mapping
 {
   ULONGEST addr;
   ULONGEST endaddr;
-  std::string_view permissions;
+  std::string permissions;
   ULONGEST offset;
   std::string_view device;
   ULONGEST inode;
@@ -899,20 +900,19 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
 	{
 	  char *line;
 
-	  gdb_printf (_("Mapped address spaces:\n\n"));
-	  if (gdbarch_addr_bit (gdbarch) == 32)
-	    {
-	      gdb_printf ("\t%10s %10s %10s %10s  %s %s\n",
-			  "Start Addr", "  End Addr", "      Size",
-			  "    Offset", "Perms  ", "objfile");
-	    }
-	  else
-	    {
-	      gdb_printf ("  %18s %18s %10s %10s  %s %s\n",
-			  "Start Addr", "  End Addr", "      Size",
-			  "    Offset", "Perms ", "objfile");
-	    }
-
+	  struct ui_out *uiout = current_uiout;
+	  uiout->text (_("Mapped address spaces:\n\n"));
+	  ui_out_emit_table table_emitter (uiout, 6, -1, "mappings");
+	  int width = gdbarch_addr_bit (gdbarch) == 32 ? 10 : 18;
+	  uiout->table_header (width, ui_right, "start", "Start Addr");
+	  uiout->table_header (width, ui_right, "end", "End Addr");
+	  uiout->table_header (10, ui_right, "size", "Size");
+	  uiout->table_header (10, ui_right, "offset", "Offset");
+	  uiout->table_header (5, ui_right, "permissions", "Perms");
+	  uiout->table_header (10, ui_left, "objfile", "objfile");
+
+	  uiout->table_body ();
+	  ui_file_style filenames = file_name_style.style ();
 	  char *saveptr;
 	  for (line = strtok_r (map.get (), "\n", &saveptr);
 	       line;
@@ -920,28 +920,14 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
 	    {
 	      struct mapping m = read_mapping (line);
 
-	      if (gdbarch_addr_bit (gdbarch) == 32)
-		{
-		  gdb_printf ("\t%10s %10s %10s %10s  %-5.*s  %s\n",
-			      paddress (gdbarch, m.addr),
-			      paddress (gdbarch, m.endaddr),
-			      hex_string (m.endaddr - m.addr),
-			      hex_string (m.offset),
-			      (int) m.permissions.size (),
-			      m.permissions.data (),
-			      m.filename);
-		}
-	      else
-		{
-		  gdb_printf ("  %18s %18s %10s %10s  %-5.*s  %s\n",
-			      paddress (gdbarch, m.addr),
-			      paddress (gdbarch, m.endaddr),
-			      hex_string (m.endaddr - m.addr),
-			      hex_string (m.offset),
-			      (int) m.permissions.size (),
-			      m.permissions.data (),
-			      m.filename);
-		}
+	      ui_out_emit_tuple tuple_emitter (uiout, nullptr);
+	      uiout->field_core_addr ("start", gdbarch, m.addr);
+	      uiout->field_core_addr ("end", gdbarch, m.endaddr);
+	      uiout->field_string ("size", hex_string (m.endaddr - m.addr));
+	      uiout->field_string ("offset", hex_string (m.offset));
+	      uiout->field_string ("permissions", m.permissions);
+	      uiout->field_string ("objfile", m.filename, filenames);
+	      uiout->text ("\n");
 	    }
 	}
       else
@@ -1242,42 +1228,34 @@ linux_read_core_file_mappings
 static void
 linux_core_info_proc_mappings (struct gdbarch *gdbarch, const char *args)
 {
+  struct ui_out *uiout = current_uiout;
+  std::optional<ui_out_emit_table> table_emitter;
+  ui_file_style filenames = file_name_style.style ();
+
   linux_read_core_file_mappings (gdbarch, current_program_space->core_bfd (),
-    [=] (ULONGEST count)
+    [&] (ULONGEST count)
       {
 	gdb_printf (_("Mapped address spaces:\n\n"));
-	if (gdbarch_addr_bit (gdbarch) == 32)
-	  {
-	    gdb_printf ("\t%10s %10s %10s %10s %s\n",
-			"Start Addr",
-			"  End Addr",
-			"      Size", "    Offset", "objfile");
-	  }
-	else
-	  {
-	    gdb_printf ("  %18s %18s %10s %10s %s\n",
-			"Start Addr",
-			"  End Addr",
-			"      Size", "    Offset", "objfile");
-	  }
+	table_emitter.emplace (uiout, 5, -1, "mappings");
+	int width = gdbarch_addr_bit (gdbarch) == 32 ? 10 : 18;
+	uiout->table_header (width, ui_right, "start", "Start Addr");
+	uiout->table_header (width, ui_right, "end", "End Addr");
+	uiout->table_header (10, ui_right, "size", "Size");
+	uiout->table_header (10, ui_right, "offset", "Offset");
+	uiout->table_header (10, ui_left, "objfile", "objfile");
+
+	uiout->table_body ();
       },
-    [=] (int num, ULONGEST start, ULONGEST end, ULONGEST file_ofs,
+    [&] (int num, ULONGEST start, ULONGEST end, ULONGEST file_ofs,
 	 const char *filename, const bfd_build_id *build_id)
       {
-	if (gdbarch_addr_bit (gdbarch) == 32)
-	  gdb_printf ("\t%10s %10s %10s %10s %s\n",
-		      paddress (gdbarch, start),
-		      paddress (gdbarch, end),
-		      hex_string (end - start),
-		      hex_string (file_ofs),
-		      filename);
-	else
-	  gdb_printf ("  %18s %18s %10s %10s %s\n",
-		      paddress (gdbarch, start),
-		      paddress (gdbarch, end),
-		      hex_string (end - start),
-		      hex_string (file_ofs),
-		      filename);
+	ui_out_emit_tuple tuple_emitter (uiout, nullptr);
+	uiout->field_core_addr ("start", gdbarch, start);
+	uiout->field_core_addr ("end", gdbarch, end);
+	uiout->field_string ("size", hex_string (end - start));
+	uiout->field_string ("offset", hex_string (file_ofs));
+	uiout->field_string ("objfile", filename, filenames);
+	uiout->text ("\n");
       });
 }
 
@@ -1390,7 +1368,7 @@ parse_smaps_data (const char *data,
 
       /* Decode permissions.  */
       auto has_perm = [&m] (char c)
-	{ return m.permissions.find (c) != std::string_view::npos; };
+	{ return m.permissions.find (c) != std::string::npos; };
       read = has_perm ('r');
       write = has_perm ('w');
       exec = has_perm ('x');

-- 
2.43.0


^ permalink raw reply	[relevance 8%]

* [PATCH] gdb/compile: Use std::filesystem::remove_all in cleanup
@ 2024-03-03 16:47 10% Lancelot SIX
  0 siblings, 0 replies; 200+ results
From: Lancelot SIX @ 2024-03-03 16:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: lsix, Lancelot SIX

In a previous review, I noticed that some code in gdb/compile/compile.c
could use c++17's `std::filesystem::remove_all` instead of using some
`system ("rm -rf ...");`.

This patch implements this.

Note that I use the noexcept overload of std::filesystem::remove_all and
explicitly check for an error code.  This means that this code called
during the cleanup procedure cannot throw, and does not risk preventing
other cleanup functions to be called.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31420
Change-Id: If5668bf3e15e66c020e5c3b4fa999f861690e4cf
---
 gdb/compile/compile.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 27cff2553ee..45452f19abb 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -40,7 +40,9 @@
 #include "osabi.h"
 #include "gdbsupport/gdb_wait.h"
 #include "valprint.h"
+#include <filesystem>
 #include <optional>
+#include <system_error>
 #include "gdbsupport/gdb_unlinker.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/scoped_ignore_signal.h"
@@ -450,15 +452,11 @@ get_compile_file_tempdir (void)
   tempdir_name = xstrdup (tempdir_name);
   add_final_cleanup ([] ()
     {
-      char *zap;
-      int wstat;
-
-      gdb_assert (startswith (tempdir_name, TMP_PREFIX));
-      zap = concat ("rm -rf ", tempdir_name, (char *) NULL);
-      wstat = system (zap);
-      if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0)
-	warning (_("Could not remove temporary directory %s"), tempdir_name);
-      XDELETEVEC (zap);
+      std::error_code error;
+      if (std::filesystem::remove_all (tempdir_name, error)
+	  == static_cast<std::uintmax_t> (-1))
+	warning (_("Could not remove temporary directory %s (%s)"),
+		 tempdir_name, error.message ().c_str ());
     });
   return tempdir_name;
 }

base-commit: 90f8d97c8efa75f7f019b868eca9c626bc35203d
-- 
2.34.1


^ permalink raw reply	[relevance 10%]

* [PATCH] Support MSYS2 platform
  @ 2024-03-03 11:07 10% ` Orgad Shaneh
  0 siblings, 0 replies; 200+ results
From: Orgad Shaneh @ 2024-03-03 11:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: Orgad Shaneh

From: Orgad Shaneh <orgads@gmail.com>

Apply MSYS2 patches upstream.

MSYS2 is similar to (and based on) cygwin, but it supports native paths,
and focuses on building native Windows software.

https://www.msys2.org/docs/what-is-msys2/
---
 ar-lib                                      |  4 +-
 bfd/acinclude.m4                            |  2 +-
 bfd/config.bfd                              |  4 +-
 bfd/configure                               | 36 +++++++-----
 bfd/configure.ac                            |  4 ++
 binutils/NEWS                               |  2 +
 binutils/configure                          | 36 +++++++-----
 binutils/configure.ac                       |  6 +-
 binutils/dllwrap.c                          | 13 ++++-
 binutils/testsuite/binutils-all/dlltool.exp |  1 +
 compile                                     |  4 +-
 config.guess                                |  3 +
 config.rpath                                |  8 +--
 config/dfp.m4                               |  3 +-
 config/elf.m4                               |  2 +-
 config/lthostflags.m4                       |  2 +-
 config/mmap.m4                              |  4 +-
 config/picflag.m4                           |  2 +
 config/tcl.m4                               |  4 +-
 configure                                   | 22 ++++----
 configure.ac                                | 20 +++----
 gas/configure                               | 32 ++++++-----
 gas/configure.tgt                           |  2 +-
 gas/testsuite/gas/all/gas.exp               |  6 +-
 gdb/NEWS                                    |  7 +++
 gdb/configure                               | 53 +++++++++++-------
 gdb/configure.ac                            |  6 +-
 gdb/configure.host                          |  2 +
 gdb/configure.nat                           |  7 ++-
 gdb/configure.tgt                           |  7 ++-
 gdb/testsuite/gdb.base/bigcore.exp          |  3 +-
 gdb/testsuite/gdb.base/fileio.exp           |  2 +-
 gdb/testsuite/gdb.base/maint.exp            |  2 +-
 gdb/testsuite/gdb.base/shreloc.exp          |  4 +-
 gdb/testsuite/gdb.base/solib-weak.exp       |  3 +-
 gdb/testsuite/gdb.dwarf2/dw2-dos-drive.exp  |  3 +-
 gdb/testsuite/gdb.server/wrapper.exp        |  3 +-
 gdb/testsuite/lib/gdb.exp                   | 22 ++++++--
 gdb/windows-nat.c                           |  8 +++
 gdbserver/configure.srv                     |  4 +-
 gnulib/configure                            |  8 +--
 gnulib/import/m4/double-slash-root.m4       |  2 +-
 gnulib/import/m4/dup2.m4                    |  2 +-
 gnulib/import/m4/fcntl.m4                   |  2 +-
 gprof/configure                             | 28 ++++++----
 ld/configure                                | 45 +++++++++------
 ld/configure.tgt                            |  6 +-
 ld/emultempl/pe.em                          |  4 +-
 ld/emultempl/pep.em                         |  2 +-
 ld/pe-dll.c                                 |  9 +++
 ld/testsuite/ld-auto-import/auto-import.exp | 62 +++++++++++++++++++++
 ld/testsuite/ld-fastcall/fastcall.exp       |  1 +
 ld/testsuite/ld-pe/pe-compile.exp           |  1 +
 ld/testsuite/ld-pe/pe.exp                   |  5 +-
 ld/testsuite/ld-pe/weakdef-1.d              |  2 +-
 libctf/configure                            | 32 +++++++----
 libctf/configure.ac                         |  4 ++
 libdecnumber/configure                      |  3 +-
 libiberty/configure                         |  4 +-
 libiberty/configure.ac                      |  2 +-
 libtool.m4                                  | 36 +++++++-----
 ltmain.sh                                   | 52 ++++++++---------
 ltoptions.m4                                |  2 +-
 opcodes/configure                           | 34 +++++++----
 opcodes/configure.ac                        |  4 ++
 readline/readline/configure                 |  2 +-
 readline/readline/configure.ac              |  2 +-
 readline/readline/support/config.guess      |  3 +
 readline/readline/support/config.rpath      | 10 ++--
 readline/readline/support/shlib-install     |  4 +-
 readline/readline/support/shobj-conf        | 18 ++++++
 sim/configure                               | 28 ++++++----
 zlib/configure                              | 28 ++++++----
 73 files changed, 532 insertions(+), 273 deletions(-)

diff --git a/ar-lib b/ar-lib
index 05094d34c69..1b16134da54 100755
--- a/ar-lib
+++ b/ar-lib
@@ -53,7 +53,7 @@ func_file_conv ()
 	  MINGW*)
 	    file_conv=mingw
 	    ;;
-	  CYGWIN*)
+	  CYGWIN*|MSYS*)
 	    file_conv=cygwin
 	    ;;
 	  *)
@@ -65,7 +65,7 @@ func_file_conv ()
 	mingw)
 	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
 	  ;;
-	cygwin)
+	cygwin|msys)
 	  file=`cygpath -m "$file" || echo "$file"`
 	  ;;
 	wine)
diff --git a/bfd/acinclude.m4 b/bfd/acinclude.m4
index 0ba7957760d..4ae2c97951f 100644
--- a/bfd/acinclude.m4
+++ b/bfd/acinclude.m4
@@ -21,7 +21,7 @@ AC_DEFUN([BFD_BINARY_FOPEN],
 [AC_REQUIRE([AC_CANONICAL_TARGET])
 case "${host}" in
 changequote(,)dnl
-*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-msys* | *-*-windows*)
 changequote([,])dnl
   AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;;
 esac])dnl
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 6553aac1e99..6aa7f2b1c07 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -715,7 +715,7 @@ case "${targ}" in
     targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec i386_pei_vec x86_64_pe_vec x86_64_pei_vec"
     want64=true
     ;;
-  x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin)
+  x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin | x86_64-*-msys)
     targ_defvec=x86_64_pe_vec
     targ_selvecs="x86_64_pe_vec x86_64_pei_vec x86_64_pe_big_vec x86_64_elf64_vec i386_pe_vec i386_pei_vec i386_elf32_vec iamcu_elf32_vec pdb_vec"
     want64=true
@@ -774,7 +774,7 @@ case "${targ}" in
     targ_defvec=i386_elf32_vec
     targ_selvecs="iamcu_elf32_vec i386_coff_vec"
     ;;
-  i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe)
+  i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-msys* | i[3-7]86-*-winnt | i[3-7]86-*-pe)
     targ_defvec=i386_pe_vec
     targ_selvecs="i386_pe_vec i386_pe_big_vec i386_pei_vec i386_elf32_vec iamcu_elf32_vec pdb_vec"
     targ_underscore=yes
diff --git a/bfd/configure b/bfd/configure
index 23ffa6da332..d3667447d0a 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -5674,7 +5674,7 @@ else
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -6016,7 +6016,7 @@ bsdi[45]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -6632,7 +6632,7 @@ case $host_os in
 aix*)
   symcode='[BCDT]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
@@ -8218,7 +8218,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -8300,7 +8300,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
@@ -8762,7 +8762,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -8877,7 +8877,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -9308,7 +9308,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -10209,14 +10209,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -10238,6 +10238,12 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    msys*)
+      # Msys DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
@@ -10890,7 +10896,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
@@ -15179,7 +15185,7 @@ _ACEOF
 
 
 case "${host}" in
-*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-msys* | *-*-windows*)
 
 $as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
  ;;
@@ -15550,7 +15556,7 @@ $as_echo "$bfd_cv_ld_as_needed" >&6; }
 
 LIBM=
 case $host in
-*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-msys* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
   # These system don't have libm, or don't need it
   ;;
 *-ncr-sysv4.3*)
@@ -15704,6 +15710,10 @@ if test "$enable_shared" = "yes"; then
     SHARED_LDFLAGS="-no-undefined"
     SHARED_LIBADD="-L`pwd`/../libiberty -liberty $SHARED_LIBADD -lcygwin -lkernel32"
   ;;
+  *-*-msys*)
+    SHARED_LDFLAGS="-no-undefined"
+    SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lmsys-2.0 -lkernel32"
+  ;;
   esac
 
   if test -n "$SHARED_LIBADD"; then
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 7fcc5d4a947..b5dfe025c71 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -289,6 +289,10 @@ if test "$enable_shared" = "yes"; then
     SHARED_LDFLAGS="-no-undefined"
     SHARED_LIBADD="-L`pwd`/../libiberty -liberty $SHARED_LIBADD -lcygwin -lkernel32"
   ;;
+  *-*-msys*)
+    SHARED_LDFLAGS="-no-undefined"
+    SHARED_LIBADD="-L`pwd`/../libiberty -liberty $SHARED_LIBADD -lmsys-2.0 -lkernel32"
+  ;;
   esac
 
   if test -n "$SHARED_LIBADD"; then
diff --git a/binutils/NEWS b/binutils/NEWS
index 9c7c8f1f603..2cf7b86bb7f 100644
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -6,6 +6,8 @@
   section they will now also display the contents of the .eh_frame_hdr section,
   if present.
 
+* Added built-in support for building on MSYS2 platform.
+
 Changes in 2.42:
 
 * The objdump program has a new command line option -Z/--decompress which
diff --git a/binutils/configure b/binutils/configure
index 2b9f52720c3..cf2b7face1b 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -5569,7 +5569,7 @@ else
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -5911,7 +5911,7 @@ bsdi[45]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -6527,7 +6527,7 @@ case $host_os in
 aix*)
   symcode='[BCDT]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
@@ -8144,7 +8144,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -8226,7 +8226,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
@@ -8688,7 +8688,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -8803,7 +8803,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -9234,7 +9234,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -10135,14 +10135,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -10164,6 +10164,12 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    msys*)
+      # MSYS DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
@@ -10816,7 +10822,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
@@ -15901,7 +15907,7 @@ fi
 
 
 case "${host}" in
-*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-msys* | *-*-windows*)
 
 $as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
  ;;
@@ -16454,7 +16460,7 @@ do
 	BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
 	BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
 	;;
-    i[3-7]86-*-pe* | i[3-7]86-*-cygwin* | i[3-7]86-*-mingw32** | all)
+    i[3-7]86-*-pe* | i[3-7]86-*-cygwin* |  i[3-7]86-*-msys* | i[3-7]86-*-mingw32** | all)
 	BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
 	if test -z "$DLLTOOL_DEFAULT"; then
 	    DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_I386"
@@ -16496,7 +16502,7 @@ do
 	BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
 	BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
 	;;
-    x86_64-*-mingw* | x86_64-*-cygwin*)
+    x86_64-*-mingw* | x86_64-*-cygwin* | x86_64-*-msys*)
 	BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
 	if test -z "$DLLTOOL_DEFAULT"; then
 	    DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_MX86_64"
@@ -16520,7 +16526,7 @@ do
     powerpc*-*-aix* | rs6000-*-aix*)
 	od_vectors="$od_vectors objdump_private_desc_xcoff"
 	;;
-    *-*-pe* | *-*-cygwin* | *-*-mingw*)
+    *-*-pe* | *-*-cygwin* | *-*-msys* | *-*-mingw*)
 	 od_vectors="$od_vectors objdump_private_desc_pe"
 	 ;;
     *-*-darwin*)
diff --git a/binutils/configure.ac b/binutils/configure.ac
index dac72c1bdd4..5555efcf789 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -398,7 +398,7 @@ changequote([,])dnl
 	BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
 	;;
 changequote(,)dnl
-    i[3-7]86-*-pe* | i[3-7]86-*-cygwin* | i[3-7]86-*-mingw32** | all)
+    i[3-7]86-*-pe* | i[3-7]86-*-cygwin* | i[3-7]86-*-msys* | i[3-7]86-*-mingw32** | all)
 changequote([,])dnl
 	BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
 	if test -z "$DLLTOOL_DEFAULT"; then
@@ -443,7 +443,7 @@ changequote([,])dnl
 	BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
 	BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
 	;;
-    x86_64-*-mingw* | x86_64-*-cygwin*)
+    x86_64-*-mingw* | x86_64-*-cygwin* | x86_64-*-msys*)
 	BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
 	if test -z "$DLLTOOL_DEFAULT"; then
 	    DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_MX86_64"
@@ -467,7 +467,7 @@ changequote([,])dnl
     powerpc*-*-aix* | rs6000-*-aix*)
 	od_vectors="$od_vectors objdump_private_desc_xcoff"
 	;;
-    *-*-pe* | *-*-cygwin* | *-*-mingw*)
+    *-*-pe* | *-*-cygwin* | *-*-msys* | *-*-mingw*)
 	 od_vectors="$od_vectors objdump_private_desc_pe"
 	 ;;
     *-*-darwin*)
diff --git a/binutils/dllwrap.c b/binutils/dllwrap.c
index bf119cee5d6..99d9bfb6779 100644
--- a/binutils/dllwrap.c
+++ b/binutils/dllwrap.c
@@ -78,6 +78,7 @@ static int is_leading_underscore = -1;
 typedef enum {
   UNKNOWN_TARGET,
   CYGWIN_TARGET,
+  MSYS_TARGET,
   MINGW_TARGET
 }
 target_type;
@@ -833,6 +834,8 @@ Creating one, but that may not be what you want"));
   /* Set the target platform.  */
   if (strstr (target, "cygwin"))
     which_target = CYGWIN_TARGET;
+  else if (strstr (target, "msys"))
+    which_target = MSYS_TARGET;
   else if (strstr (target, "mingw"))
     which_target = MINGW_TARGET;
   else
@@ -884,6 +887,10 @@ Creating one, but that may not be what you want"));
 	  driver_flags = cygwin_driver_flags;
 	  break;
 
+	case MSYS_TARGET:
+	  driver_flags = cygwin_driver_flags;
+	  break;
+
 	case MINGW_TARGET:
 	  driver_flags = mingw32_driver_flags;
 	  break;
@@ -917,6 +924,10 @@ Creating one, but that may not be what you want"));
 	  name_entry = "_cygwin_dll_entry";
 	  break;
 
+	case MSYS_TARGET:
+	  name_entry = "_msys_dll_entry";
+	  break;
+
 	case MINGW_TARGET:
 	  name_entry = "DllMainCRTStartup";
 	  break;
@@ -980,7 +991,7 @@ Creating one, but that may not be what you want"));
 	{
 	  dyn_string_append_cstr (step_pre1, " --export-all --exclude-symbol=");
 	  dyn_string_append_cstr (step_pre1,
-	  "_cygwin_dll_entry@12,DllMainCRTStartup@12,DllMain@12,DllEntryPoint@12");
+	  "_cygwin_dll_entry@12,_msys_dll_entry@12,DllMainCRTStartup@12,DllMain@12,DllEntryPoint@12");
 	}
       dyn_string_append_cstr (step_pre1, " --output-def ");
       dyn_string_append_cstr (step_pre1, def_file_name);
diff --git a/binutils/testsuite/binutils-all/dlltool.exp b/binutils/testsuite/binutils-all/dlltool.exp
index ac1306bdf77..0a9e61336ff 100644
--- a/binutils/testsuite/binutils-all/dlltool.exp
+++ b/binutils/testsuite/binutils-all/dlltool.exp
@@ -22,6 +22,7 @@ if {![istarget "i*86-*-*"]
 
 if {![istarget "i*86-*-*pe*"] \
     && ![istarget "i*86-*-cygwin*"] \
+    && ![istarget "i*86-*-msys*"] \
     && ![istarget "i*86-*-mingw32*"] \
     && ![istarget "arm-*-pe*"] \
     && ![istarget "x86_64-*-mingw*"] } {
diff --git a/compile b/compile
index a85b723c7e6..a4ecdb2519c 100755
--- a/compile
+++ b/compile
@@ -53,7 +53,7 @@ func_file_conv ()
 	  MINGW*)
 	    file_conv=mingw
 	    ;;
-	  CYGWIN*)
+	  CYGWIN*|MSYS*)
 	    file_conv=cygwin
 	    ;;
 	  *)
@@ -67,7 +67,7 @@ func_file_conv ()
 	mingw/*)
 	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
 	  ;;
-	cygwin/*)
+	cygwin/*|msys/*)
 	  file=`cygpath -m "$file" || echo "$file"`
 	  ;;
 	wine/*)
diff --git a/config.guess b/config.guess
index cdfc4392047..2f27dc5a459 100755
--- a/config.guess
+++ b/config.guess
@@ -953,6 +953,9 @@ EOF
 	;;
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
 	GUESS=x86_64-pc-cygwin
+	exit ;;
+    amd64:MSYS*:*:* | x86_64:MSYS*:*:*)
+	echo x86_64-pc-msys
 	;;
     prep*:SunOS:5.*:*)
 	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
diff --git a/config.rpath b/config.rpath
index 4dea75957c2..4f12c27e029 100755
--- a/config.rpath
+++ b/config.rpath
@@ -109,7 +109,7 @@ hardcode_direct=no
 hardcode_minus_L=no
 
 case "$host_os" in
-  cygwin* | mingw* | pw32*)
+  cygwin* | msys* | mingw* | pw32*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -149,7 +149,7 @@ if test "$with_gnu_ld" = yes; then
         ld_shlibs=no
       fi
       ;;
-    cygwin* | mingw* | pw32*)
+    cygwin* | msys* | mingw* | pw32*)
       # hardcode_libdir_flag_spec is actually meaningless, as there is
       # no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -268,7 +268,7 @@ else
       ;;
     bsdi4*)
       ;;
-    cygwin* | mingw* | pw32*)
+    cygwin* | msys* | mingw* | pw32*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -437,7 +437,7 @@ case "$host_os" in
     ;;
   bsdi4*)
     ;;
-  cygwin* | mingw* | pw32*)
+  cygwin* | msys* | mingw* | pw32*)
     shrext=.dll
     ;;
   darwin* | rhapsody*)
diff --git a/config/dfp.m4 b/config/dfp.m4
index d1d151b2da7..6cc4d27ca6d 100644
--- a/config/dfp.m4
+++ b/config/dfp.m4
@@ -42,7 +42,8 @@ Valid choices are 'yes', 'bid', 'dpd', and 'no'.]) ;;
     powerpc*-*-linux* | i?86*-*-linux* | x86_64*-*-linux* | s390*-*-linux* | \
     i?86*-*-elfiamcu | i?86*-*-gnu* | x86_64*-*-gnu* | \
     i?86*-*-mingw* | x86_64*-*-mingw* | \
-    i?86*-*-cygwin* | x86_64*-*-cygwin*)
+    i?86*-*-cygwin* | x86_64*-*-cygwin* | \
+    i?86*-*-msys* | x86_64*-*-msys*)
       enable_decimal_float=yes
       ;;
     *)
diff --git a/config/elf.m4 b/config/elf.m4
index 1772a44318e..7d4f5054562 100644
--- a/config/elf.m4
+++ b/config/elf.m4
@@ -15,7 +15,7 @@ AC_REQUIRE([AC_CANONICAL_TARGET])
 
 target_elf=no
 case $target in
-  *-darwin* | *-aix* | *-cygwin* | *-mingw* | *-aout* | *-*coff* | \
+  *-darwin* | *-aix* | *-cygwin* |*-msys* |  *-mingw* | *-aout* | *-*coff* | \
   *-msdosdjgpp* | *-vms* | *-wince* | *-*-pe* | \
   alpha*-dec-osf* | *-interix* | hppa[[12]]*-*-hpux* | \
   nvptx-*-none)
diff --git a/config/lthostflags.m4 b/config/lthostflags.m4
index bc0f59ee79e..ad977d43dc5 100644
--- a/config/lthostflags.m4
+++ b/config/lthostflags.m4
@@ -13,7 +13,7 @@ AC_DEFUN([ACX_LT_HOST_FLAGS], [
 AC_REQUIRE([AC_CANONICAL_SYSTEM])
 
 case $host in
-  *-cygwin* | *-mingw*)
+  *-cygwin* | *-msys* | *-mingw*)
     # 'host' will be top-level target in the case of a target lib,
     # we must compare to with_cross_host to decide if this is a native
     # or cross-compiler and select where to install dlls appropriately.
diff --git a/config/mmap.m4 b/config/mmap.m4
index fba0d9d3657..df2c778524c 100644
--- a/config/mmap.m4
+++ b/config/mmap.m4
@@ -42,7 +42,7 @@ else
    # Systems known to be in this category are Windows (all variants),
    # VMS, and Darwin.
    case "$host_os" in
-     *vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
+     *vms* | cygwin* | msys* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
         gcc_cv_func_mmap_dev_zero=no ;;
      *)
         gcc_cv_func_mmap_dev_zero=yes;;
@@ -74,7 +74,7 @@ else
    # above for use of /dev/zero.
    # Systems known to be in this category are Windows, VMS, and SCO Unix.
    case "$host_os" in
-     *vms* | cygwin* | pe | mingw* | sco* | udk* )
+     *vms* | cygwin* | msys* | pe | mingw* | sco* | udk* )
         gcc_cv_func_mmap_anon=no ;;
      *)
         gcc_cv_func_mmap_anon=yes;;
diff --git a/config/picflag.m4 b/config/picflag.m4
index 3f3ac744c96..e7eb1f51989 100644
--- a/config/picflag.m4
+++ b/config/picflag.m4
@@ -25,6 +25,8 @@ case "${$2}" in
 	;;
     i[[34567]]86-*-cygwin* | x86_64-*-cygwin*)
 	;;
+    i[[34567]]86-*-msys* | x86_64-*-msys*)
+	;;
     i[[34567]]86-*-mingw* | x86_64-*-mingw*)
 	;;
     i[[34567]]86-*-interix[[3-9]]*)
diff --git a/config/tcl.m4 b/config/tcl.m4
index 4542a4b23d7..209bd8d9b8e 100644
--- a/config/tcl.m4
+++ b/config/tcl.m4
@@ -33,7 +33,7 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [
 
 	    # First check to see if --with-tcl was specified.
 	    case "${host}" in
-		*-*-cygwin*) platDir="win" ;;
+		*-*-cygwin* | *-*-msys*) platDir="win" ;;
 		*) platDir="unix" ;;
 	    esac
 	    if test x"${with_tclconfig}" != x ; then
@@ -165,7 +165,7 @@ AC_DEFUN([SC_PATH_TKCONFIG], [
 
 	    # then check for a private Tk library
 	    case "${host}" in
-		*-*-cygwin*) platDir="win" ;;
+		*-*-cygwin* | *-*-msys*) platDir="win" ;;
 		*) platDir="unix" ;;
 	    esac
 	    if test x"${ac_cv_c_tkconfig}" = x ; then
diff --git a/configure b/configure
index 6466b97f3ec..6acbc3b0972 100755
--- a/configure
+++ b/configure
@@ -3180,7 +3180,7 @@ fi
 # Configure extra directories which are host specific
 
 case "${host}" in
-  *-cygwin*)
+  *-cygwin* | *-msys*)
     configdirs="$configdirs libtermcap" ;;
 esac
 
@@ -3608,7 +3608,7 @@ esac
 # Disable the go frontend on systems where it is known to not work. Please keep
 # this in sync with contrib/config-list.mk.
 case "${target}" in
-*-*-darwin* | *-*-cygwin* | *-*-mingw* | bpf-* )
+*-*-darwin* | *-*-cygwin* | *-*-msys* | *-*-mingw* | bpf-* )
     unsupported_languages="$unsupported_languages go"
     ;;
 esac
@@ -3640,7 +3640,7 @@ if test x$enable_libgo = x; then
 	# PR 46986
 	noconfigdirs="$noconfigdirs target-libgo"
 	;;
-    *-*-cygwin* | *-*-mingw*)
+    *-*-cygwin* | *-*-msys* | *-*-mingw*)
 	noconfigdirs="$noconfigdirs target-libgo"
 	;;
     bpf-*-*)
@@ -3935,7 +3935,7 @@ case "${target}" in
   i[3456789]86-*-mingw*)
     target_configdirs="$target_configdirs target-winsup"
     ;;
-  *-*-cygwin*)
+  *-*-cygwin* | *-*-msys*)
     target_configdirs="$target_configdirs target-libtermcap target-winsup"
     noconfigdirs="$noconfigdirs target-libgloss"
     # always build newlib if winsup directory is present.
@@ -4091,7 +4091,7 @@ case "${host}" in
   i[3456789]86-*-msdosdjgpp*)
     host_makefile_frag="config/mh-djgpp"
     ;;
-  *-cygwin*)
+  *-cygwin* | *-msys*)
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking to see if cat works as expected" >&5
 $as_echo_n "checking to see if cat works as expected... " >&6; }
@@ -8687,7 +8687,7 @@ fi
 
 target_elf=no
 case $target in
-  *-darwin* | *-aix* | *-cygwin* | *-mingw* | *-aout* | *-*coff* | \
+  *-darwin* | *-aix* | *-cygwin* |*-msys* |  *-mingw* | *-aout* | *-*coff* | \
   *-msdosdjgpp* | *-vms* | *-wince* | *-*-pe* | \
   alpha*-dec-osf* | *-interix* | hppa[12]*-*-hpux* | \
   nvptx-*-none)
@@ -8705,7 +8705,7 @@ if test $target_elf = yes; then :
 else
   if test x"$default_enable_lto" = x"yes" ; then
     case $target in
-      *-apple-darwin[912]* | *-cygwin* | *-mingw* | *djgpp*) ;;
+      *-apple-darwin[912]* | *-cygwin* | *-msys* | *-mingw* | *djgpp*) ;;
       # On other non-ELF platforms, LTO has yet to be validated.
       *) enable_lto=no ;;
     esac
@@ -8716,7 +8716,7 @@ else
   # warn during gcc/ subconfigure; unless you're bootstrapping with
   # -flto it won't be needed until after installation anyway.
     case $target in
-      *-cygwin* | *-mingw* | *-apple-darwin* | *djgpp*) ;;
+      *-cygwin* | *-msys* | *-mingw* | *-apple-darwin* | *djgpp*) ;;
       *) if test x"$enable_lto" = x"yes"; then
 	as_fn_error $? "LTO support is not enabled for this target." "$LINENO" 5
         fi
@@ -8726,7 +8726,7 @@ else
   # Among non-ELF, only Windows platforms support the lto-plugin so far.
   # Build it unless LTO was explicitly disabled.
   case $target in
-    *-cygwin* | *-mingw*) build_lto_plugin=$enable_lto ;;
+    *-cygwin* | *-msys* | *-mingw*) build_lto_plugin=$enable_lto ;;
     *) ;;
   esac
 
@@ -9831,7 +9831,7 @@ rm -f conftest*
 case "${host}" in
   *-*-hpux*) RPATH_ENVVAR=SHLIB_PATH ;;
   *-*-darwin*) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
-  *-*-mingw* | *-*-cygwin ) RPATH_ENVVAR=PATH ;;
+  *-*-mingw* | *-*-cygwin | *-*-msys ) RPATH_ENVVAR=PATH ;;
   *) RPATH_ENVVAR=LD_LIBRARY_PATH ;;
 esac
 
@@ -10406,7 +10406,7 @@ case " $target_configdirs " in
   case " $target_configargs " in
   *" --with-newlib "*)
    case "$target" in
-    *-cygwin*)
+    *-cygwin* | *-msys*)
       FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/winsup/cygwin -isystem $$s/winsup/cygwin/include'
       ;;
    esac
diff --git a/configure.ac b/configure.ac
index 1300a805fd8..e12cef9fbd0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -442,7 +442,7 @@ AC_ARG_ENABLE(default_compressed_debug_sections_algorithm,
 # Configure extra directories which are host specific
 
 case "${host}" in
-  *-cygwin*)
+  *-cygwin* | *-msys*)
     configdirs="$configdirs libtermcap" ;;
 esac
 
@@ -838,7 +838,7 @@ esac
 # Disable the go frontend on systems where it is known to not work. Please keep
 # this in sync with contrib/config-list.mk.
 case "${target}" in
-*-*-darwin* | *-*-cygwin* | *-*-mingw* | bpf-* )
+*-*-darwin* | *-*-cygwin* | *-*-msys* | *-*-mingw* | bpf-* )
     unsupported_languages="$unsupported_languages go"
     ;;
 esac
@@ -867,7 +867,7 @@ if test x$enable_libgo = x; then
 	# PR 46986
 	noconfigdirs="$noconfigdirs target-libgo"
 	;;
-    *-*-cygwin* | *-*-mingw*)
+    *-*-cygwin* | *-*-msys* | *-*-mingw*)
 	noconfigdirs="$noconfigdirs target-libgo"
 	;;
     bpf-*-*)
@@ -1162,7 +1162,7 @@ case "${target}" in
   i[[3456789]]86-*-mingw*)
     target_configdirs="$target_configdirs target-winsup"
     ;;
-  *-*-cygwin*)
+  *-*-cygwin* | *-*-msys*)
     target_configdirs="$target_configdirs target-libtermcap target-winsup"
     noconfigdirs="$noconfigdirs target-libgloss"
     # always build newlib if winsup directory is present.
@@ -1318,7 +1318,7 @@ case "${host}" in
   i[[3456789]]86-*-msdosdjgpp*)
     host_makefile_frag="config/mh-djgpp"
     ;;
-  *-cygwin*)
+  *-cygwin* | *-msys*)
     ACX_CHECK_CYGWIN_CAT_WORKS
     host_makefile_frag="config/mh-cygwin"
     ;;
@@ -1928,7 +1928,7 @@ ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always.
   build_lto_plugin=yes
 ],[if test x"$default_enable_lto" = x"yes" ; then
     case $target in
-      *-apple-darwin[[912]]* | *-cygwin* | *-mingw* | *djgpp*) ;;
+      *-apple-darwin[[912]]* | *-cygwin* | *-msys* | *-mingw* | *djgpp*) ;;
       # On other non-ELF platforms, LTO has yet to be validated.
       *) enable_lto=no ;;
     esac
@@ -1939,7 +1939,7 @@ ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always.
   # warn during gcc/ subconfigure; unless you're bootstrapping with
   # -flto it won't be needed until after installation anyway.
     case $target in
-      *-cygwin* | *-mingw* | *-apple-darwin* | *djgpp*) ;;
+      *-cygwin* | *-msys* | *-mingw* | *-apple-darwin* | *djgpp*) ;;
       *) if test x"$enable_lto" = x"yes"; then
 	AC_MSG_ERROR([LTO support is not enabled for this target.])
         fi
@@ -1949,7 +1949,7 @@ ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always.
   # Among non-ELF, only Windows platforms support the lto-plugin so far.
   # Build it unless LTO was explicitly disabled.
   case $target in
-    *-cygwin* | *-mingw*) build_lto_plugin=$enable_lto ;;
+    *-cygwin* | *-msys* | *-mingw*) build_lto_plugin=$enable_lto ;;
     *) ;;
   esac
 ])
@@ -2958,7 +2958,7 @@ rm -f conftest*
 case "${host}" in
   *-*-hpux*) RPATH_ENVVAR=SHLIB_PATH ;;
   *-*-darwin*) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
-  *-*-mingw* | *-*-cygwin ) RPATH_ENVVAR=PATH ;;
+  *-*-mingw* | *-*-cygwin | *-*-msys ) RPATH_ENVVAR=PATH ;;
   *) RPATH_ENVVAR=LD_LIBRARY_PATH ;;
 esac
 
@@ -3528,7 +3528,7 @@ case " $target_configdirs " in
   case " $target_configargs " in
   *" --with-newlib "*)
    case "$target" in
-    *-cygwin*)
+    *-cygwin* | *-msys*)
       FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/winsup/cygwin -isystem $$s/winsup/cygwin/include'
       ;;
    esac
diff --git a/gas/configure b/gas/configure
index e6811fe73bd..1be9325d829 100755
--- a/gas/configure
+++ b/gas/configure
@@ -5263,7 +5263,7 @@ else
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -5605,7 +5605,7 @@ bsdi[45]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -6221,7 +6221,7 @@ case $host_os in
 aix*)
   symcode='[BCDT]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
@@ -7838,7 +7838,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -7920,7 +7920,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
@@ -8382,7 +8382,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -8497,7 +8497,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -8928,7 +8928,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -9829,14 +9829,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -9858,6 +9858,12 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    msys*)
+      # MSYS DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
@@ -10510,7 +10516,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
@@ -15593,7 +15599,7 @@ case "${need_libm}" in
 yes)
   LIBM=
 case $host in
-*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-msys* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
   # These system don't have libm, or don't need it
   ;;
 *-ncr-sysv4.3*)
@@ -15926,7 +15932,7 @@ _ACEOF
 
 
 case "${host}" in
-*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-msys* | *-*-windows*)
 
 $as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
  ;;
diff --git a/gas/configure.tgt b/gas/configure.tgt
index 7c66734e362..e6003c95697 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -252,7 +252,7 @@ case ${generic_target} in
   i386-*-msdos*)			fmt=aout ;;
   i386-*-moss*)				fmt=elf ;;
   i386-*-pe)				fmt=coff em=pe ;;
-  i386-*-cygwin*)
+  i386-*-cygwin* | i386-*-msys*)
    case ${cpu} in
      x86_64*)				fmt=coff em=pep ;;
      i*)				fmt=coff em=pe ;;
diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index b9ff43997cb..10298699496 100644
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -181,8 +181,8 @@ switch -glob $target_triplet {
 	# failures.
 	setup_xfail "bfin-*-*" "i\[3-7\]86-*-*coff" \
 	    "i\[3-7\]86-*-*pe" "i\[3-7\]86-*-go32*" \
-	    "i\[3-7\]86-*-cygwin*" "i\[3-7\]86-*-mingw*" \
-	    "x86_64-*-cygwin*" "x86_64-*-mingw*"
+	    "i\[3-7\]86-*-cygwin*" "i\[3-7\]86-*-msys*" "i\[3-7\]86-*-mingw*" \
+	    "x86_64-*-cygwin*" "x86_64-*-msys*" "x86_64-*-mingw*"
 	run_dump_test redef3
 	gas_test_error "redef4.s" "" ".set for symbol already used as label"
 	gas_test_error "redef5.s" "" ".set for symbol already defined through .comm"
@@ -326,6 +326,7 @@ if {   ([istarget *-*-coff*] && ![istarget *c4x*-*-coff] && ![istarget *c54x*-*-
      || [istarget i*86-*-aix*] \
      || [istarget i*86-*-go32*] \
      || [istarget i*86-*-cygwin*] \
+     || [istarget i*86-*-msys*] \
      || [istarget x86_64-*-mingw*] \
      || [istarget i*86-*-*nt] \
      || [istarget i*86-*-interix*] } {
@@ -399,6 +400,7 @@ if {    ![istarget avr-*-*]
 
 if {  ([istarget "i*86-*-*pe*"] && ![istarget "i*86-*-openbsd*"]) \
     || [istarget "i*86-*-cygwin*"] \
+    || [istarget "i*86-*-msys*"] \
     || [istarget "i*86-*-mingw32*"] } {
   gas_test "fastcall.s" ""   "" "fastcall labels"
 }
diff --git a/gdb/NEWS b/gdb/NEWS
index 2638b3e0d9c..b4d658f9b35 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -13,6 +13,8 @@
   the background, resulting in faster startup.  This can be controlled
   using "maint set dwarf synchronous".
 
+* Added built-in support for building on MSYS2 platform.
+
 * Changed commands
 
 disassemble
@@ -47,6 +49,11 @@ set remote thread-options-packet
 show remote thread-options-packet
   Set/show the use of the thread options packet.
 
+* New targets
+
+i686/MSYS			i686-*-msys*
+x86_64/MSYS			x86_64-*-msys*
+
 * New features in the GDB remote stub, GDBserver
 
   ** The --remote-debug and --event-loop-debug command line options
diff --git a/gdb/configure b/gdb/configure
index d0fd1760b88..37995cc54ea 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -5942,7 +5942,7 @@ else
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -6284,7 +6284,7 @@ bsdi[45]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -6942,7 +6942,7 @@ case $host_os in
 aix*)
   symcode='[BCDT]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
@@ -8560,7 +8560,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -8642,7 +8642,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
@@ -9104,7 +9104,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -9219,7 +9219,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -9650,7 +9650,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -10551,14 +10551,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -10580,6 +10580,12 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    msys*)
+      # Msys DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
@@ -11232,7 +11238,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
@@ -12454,7 +12460,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
         esac
         ;;
 
-      cygwin* | mingw* | pw32* | cegcc*)
+      cygwin* | msys* | mingw* | pw32* | cegcc*)
         # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
         # as there is no search path for DLLs.
         hardcode_libdir_flag_spec_CXX='-L$libdir'
@@ -13424,7 +13430,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
     beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
       # PIC is the default for these OSes.
       ;;
-    mingw* | cygwin* | os2* | pw32* | cegcc*)
+    mingw* | cygwin* | msys* | os2* | pw32* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -13964,7 +13970,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   pw32*)
     export_symbols_cmds_CXX="$ltdll_cmds"
   ;;
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   *)
@@ -14228,14 +14234,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -14257,6 +14263,11 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      ;;
+    msys*)
+      # Msys DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
@@ -26997,7 +27008,7 @@ fi
 # have a separate termcap library, or no curses library at all.
 
 case $host_os in
-  cygwin*)
+  cygwin* | msys*)
     if test -d "$srcdir/libtermcap"; then
       LIBS="../libtermcap/libtermcap.a $LIBS"
       ac_cv_search_tgetent="../libtermcap/libtermcap.a"
@@ -31432,7 +31443,7 @@ WIN32LIBS=
 if test x"$gdb_cv_os_cygwin" = xyes; then
     WIN32LIBS="-luser32"
     case "${target}" in
-	*cygwin*) WIN32LIBS="$WIN32LIBS -limagehlp"
+	*cygwin* | *msys*) WIN32LIBS="$WIN32LIBS -limagehlp"
 	;;
     esac
 fi
@@ -32130,7 +32141,7 @@ WIN32LDAPP=
 
 
 case "${host}" in
-*-*-cygwin* | *-*-mingw* )
+*-*-cygwin* | *-*-msys* | *-*-mingw* )
     configdir="win"
     ;;
 *)
@@ -32173,7 +32184,7 @@ else
 
 	    # First check to see if --with-tcl was specified.
 	    case "${host}" in
-		*-*-cygwin*) platDir="win" ;;
+		*-*-cygwin* | *-*-msys*) platDir="win" ;;
 		*) platDir="unix" ;;
 	    esac
 	    if test x"${with_tclconfig}" != x ; then
@@ -32302,7 +32313,7 @@ else
 
 	    # then check for a private Tk library
 	    case "${host}" in
-		*-*-cygwin*) platDir="win" ;;
+		*-*-cygwin* | *-*-msys*) platDir="win" ;;
 		*) platDir="unix" ;;
 	    esac
 	    if test x"${ac_cv_c_tkconfig}" = x ; then
diff --git a/gdb/configure.ac b/gdb/configure.ac
index aa91bfb3a17..cc2a83a84a5 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -586,7 +586,7 @@ fi
 # have a separate termcap library, or no curses library at all.
 
 case $host_os in
-  cygwin*)
+  cygwin* | msys*)
     if test -d "$srcdir/libtermcap"; then
       LIBS="../libtermcap/libtermcap.a $LIBS"
       ac_cv_search_tgetent="../libtermcap/libtermcap.a"
@@ -1841,7 +1841,7 @@ WIN32LIBS=
 if test x"$gdb_cv_os_cygwin" = xyes; then
     WIN32LIBS="-luser32"
     case "${target}" in
-	*cygwin*) WIN32LIBS="$WIN32LIBS -limagehlp"
+	*cygwin* | *msys*) WIN32LIBS="$WIN32LIBS -limagehlp"
 	;;
     esac
 fi
@@ -1905,7 +1905,7 @@ AC_SUBST(WIN32LIBS)
 AC_SUBST(WIN32LDAPP)
 
 case "${host}" in
-*-*-cygwin* | *-*-mingw* )
+*-*-cygwin* | *-*-msys* | *-*-mingw* )
     configdir="win"
     ;;
 *)
diff --git a/gdb/configure.host b/gdb/configure.host
index da71675b201..deb1bd7ec48 100644
--- a/gdb/configure.host
+++ b/gdb/configure.host
@@ -115,6 +115,7 @@ i[34567]86-*-openbsd*)	gdb_host=obsd ;;
 i[34567]86-*-solaris2* | x86_64-*-solaris2*)
 			gdb_host=sol2 ;;
 i[34567]86-*-cygwin*)	gdb_host=cygwin ;;
+i[34567]86-*-msys*)	gdb_host=msys ;;
 
 ia64-*-linux*)		gdb_host=linux ;;
 
@@ -184,6 +185,7 @@ x86_64-*-mingw*)        gdb_host=mingw64
 			gdb_host_obs=mingw-hdep.o
 			;;
 x86_64-*-cygwin*)	gdb_host=cygwin64 ;;
+x86_64-*-msys*)	gdb_host=msys64 ;;
 m32r*-*-linux*)          gdb_host=linux ;;
 
 xtensa*-*-linux*)	gdb_host=linux ;;
diff --git a/gdb/configure.nat b/gdb/configure.nat
index 8b98511cef7..d17b1926031 100644
--- a/gdb/configure.nat
+++ b/gdb/configure.nat
@@ -77,6 +77,9 @@ case ${gdb_host} in
     cygwin*)
 	NATDEPFILES='x86-nat.o nat/x86-dregs.o windows-nat.o nat/windows-nat.o'
 	;;
+    msys*)
+	NATDEPFILES='x86-nat.o nat/x86-dregs.o windows-nat.o nat/windows-nat.o'
+	;;
     mingw*)
 	NATDEPFILES='x86-nat.o nat/x86-dregs.o windows-nat.o nat/windows-nat.o'
 	;;
@@ -123,7 +126,7 @@ case ${gdb_host} in
 		;;
 	esac
 	;;
-    cygwin)
+    cygwin | msys)
 	case ${gdb_host_cpu} in
 	    i386)
 		# Native config information for GDB on i386
@@ -132,7 +135,7 @@ case ${gdb_host} in
 		;;
 	esac
 	;;
-    cygwin64)
+    cygwin64 | msys64)
 	case ${gdb_host_cpu} in
 	    i386)
 		# Native config information for GDB on amd64
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 47a674201f9..136da0a333b 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -334,6 +334,11 @@ i[34567]86-*-cygwin*)
 	# Target: Intel 386 running win32
 	gdb_target_obs="i386-windows-tdep.o windows-tdep.o"
 	;;
+i[34567]86-*-msys*)
+	# Target: Intel 386 running win32
+	gdb_target_obs="i386-windows-tdep.o windows-tdep.o"
+	build_gdbserver=yes
+	;;
 i[34567]86-*-mingw32*)
 	# Target: Intel 386 running win32
 	gdb_target_obs="i386-windows-tdep.o windows-tdep.o"
@@ -725,7 +730,7 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
 	gdb_target_obs="amd64-fbsd-tdep.o ${i386_tobjs} \
 			i386-bsd-tdep.o i386-fbsd-tdep.o"
 	;;
-x86_64-*-mingw* | x86_64-*-cygwin*)
+x86_64-*-mingw* | x86_64-*-cygwin* | x86_64-*-msys*)
         # Target: MingW/amd64
 	gdb_target_obs="amd64-windows-tdep.o \
                         ${i386_tobjs} i386-windows-tdep.o \
diff --git a/gdb/testsuite/gdb.base/bigcore.exp b/gdb/testsuite/gdb.base/bigcore.exp
index 3f9ae48abf2..c3e39a9cbad 100644
--- a/gdb/testsuite/gdb.base/bigcore.exp
+++ b/gdb/testsuite/gdb.base/bigcore.exp
@@ -30,7 +30,8 @@ require isnative
 if { [istarget "*-*-*bsd*"]
      || [istarget "*-*-solaris*"] 
      || [istarget "*-*-darwin*"] 
-     || [istarget "*-*-cygwin*"] } {
+     || [istarget "*-*-cygwin*"] 
+     || [istarget "*-*-msys*"] } {
     untested "kernel lacks sparse corefile support (PR gdb/1551)"
     return
 }
diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
index 4b01248ca2d..657e6f582b8 100644
--- a/gdb/testsuite/gdb.base/fileio.exp
+++ b/gdb/testsuite/gdb.base/fileio.exp
@@ -240,7 +240,7 @@ gdb_test continue \
 
 # This test fails on Cygwin because unlink() succeeds on Win32 systems
 # in that situation.
-if [ishost *cygwin*] {
+if { ([ishost *cygwin*] || [ishost *msys*]) } {
     setup_xfail "*-*-*"
 }
 # If the user is root, we will always have write permission.
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index d6aa22321f1..632bac4063c 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -188,7 +188,7 @@ gdb_test "maint set per-command off" \
 # The timeout value is raised, because printing all the symbols and
 # statistical information about Cygwin and Windows libraries takes a lot
 # of time.
-if [istarget "*-*-cygwin*"] {
+if { ([istarget "*-*-cygwin*"] || [istarget "*-*-msys*"]) } {
 	set oldtimeout $timeout
 	set timeout [expr $timeout + 500]
 }
diff --git a/gdb/testsuite/gdb.base/shreloc.exp b/gdb/testsuite/gdb.base/shreloc.exp
index 82e6ec6a735..6d81d8c0199 100644
--- a/gdb/testsuite/gdb.base/shreloc.exp
+++ b/gdb/testsuite/gdb.base/shreloc.exp
@@ -38,7 +38,7 @@ set lib2_sl [standard_output_file shreloc2.sl]
 set lib_opts "debug"
 set exec_opts [list debug shlib=$lib1_sl shlib=$lib2_sl]
 
-if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"]) } {
+if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"] || [istarget "*pc-msys"]) } {
     lappend lib_opts "ldflags=-Wl,--image-base,0x04000000"
 }
 
@@ -219,7 +219,7 @@ if [send_gdb_discard "maint print msymbols ${msymfile}"] {
     }
 }
 
-if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"]) } {
+if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"] || [istarget "*pc-msys"]) } {
     #
     # We know the names of some absolute symbols included in the
     # portable-executable (DLL) format. Check that they didn't get
diff --git a/gdb/testsuite/gdb.base/solib-weak.exp b/gdb/testsuite/gdb.base/solib-weak.exp
index 1ed552cc09a..986faba7ee7 100644
--- a/gdb/testsuite/gdb.base/solib-weak.exp
+++ b/gdb/testsuite/gdb.base/solib-weak.exp
@@ -22,7 +22,8 @@ require allow_shlib_tests
 # These targets have shared libraries, but weak symbols are not meaningful.
 if {([istarget *-*-mingw*]
      || [istarget *-*-cygwin*]
-     || [istarget *-*-pe*])} {
+     || [istarget *-*-pe*]
+     || [istarget *-*-msys*]) } {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dos-drive.exp b/gdb/testsuite/gdb.dwarf2/dw2-dos-drive.exp
index f21f6bf1157..71fc1cf89b0 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-dos-drive.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-dos-drive.exp
@@ -30,7 +30,8 @@ gdb_test_no_output "set breakpoint pending off"
 gdb_test "break 'z:file.c':func" {Breakpoint [0-9]+ at .*}
 
 set dos [expr [istarget "*-*-cygwin*"] || [istarget "i?86-*-mingw*"] \
-	      || [istarget "*-*-msdosdjgpp*"] || [istarget "*-*-go32*"] ]
+	      || [istarget "*-*-msdosdjgpp*"] || [istarget "*-*-go32*"] \
+	      || [istarget "*-*-msys*"] ]
 
 if { $dos } {
     gdb_test "break file.c:func" {Breakpoint [0-9]+ at .*}
diff --git a/gdb/testsuite/gdb.server/wrapper.exp b/gdb/testsuite/gdb.server/wrapper.exp
index 1ca19bff552..e48948f27a5 100644
--- a/gdb/testsuite/gdb.server/wrapper.exp
+++ b/gdb/testsuite/gdb.server/wrapper.exp
@@ -24,7 +24,8 @@ standard_testfile
 require allow_gdbserver_tests
 
 if { [istarget *-*-mingw*]
-     || [istarget *-*-cygwin*] } {
+     || [istarget *-*-cygwin*]
+     || [istarget *-*-msys*] } {
     unsupported "gdbserver does not support --wrapper on this target (PR server/15967)"
     return -1
 }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fe4ac7d2719..fcc1d1c2ac2 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2646,7 +2646,8 @@ proc allow_shlib_tests {} {
 	 || [istarget *-*-solaris2*]
 	 || [istarget *-*-mingw*]
 	 || [istarget *-*-cygwin*]
-	 || [istarget *-*-pe*])} {
+	 || [istarget *-*-pe*]
+	 || [istarget *-*-msys*])} {
 	return 1
     }
 
@@ -5323,7 +5324,8 @@ proc gdb_compile {source dest type options} {
 		lappend source "-Wl,$shlib_name"
 	    } elseif { ([istarget "*-*-mingw*"]
 			|| [istarget *-*-cygwin*]
-			|| [istarget *-*-pe*])} {
+			|| [istarget *-*-pe*]
+			|| [istarget *-*-msys*])} {
 		lappend source "${shlib_name}.a"
             } else {
                lappend source $shlib_name
@@ -5331,7 +5333,8 @@ proc gdb_compile {source dest type options} {
             if { $shlib_found == 0 } {
                 set shlib_found 1
 		if { ([istarget "*-*-mingw*"]
-		      || [istarget *-*-cygwin*]) } {
+		      || [istarget *-*-cygwin*]
+		      || [istarget *-*-msys*]) } {
 		    lappend new_options "ldflags=-Wl,--enable-auto-import"
 		}
 		if { [test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"] } {
@@ -5424,6 +5427,7 @@ proc gdb_compile {source dest type options} {
     if { $shlib_load || $shlib_found } {
 	if { ([istarget "*-*-mingw*"]
 	      || [istarget *-*-cygwin*]
+	      || [istarget *-*-msys*]
 	      || [istarget *-*-pe*]) } {
 	    # Do not need anything.
 	} elseif { [istarget *-*-freebsd*] || [istarget *-*-openbsd*] } {
@@ -5522,7 +5526,8 @@ proc gdb_compile {source dest type options} {
     if { $type == "executable" } {
 	if { ([istarget "*-*-mingw*"]
 	      || [istarget "*-*-*djgpp"]
-	      || [istarget "*-*-cygwin*"])} {
+	      || [istarget "*-*-cygwin*"]
+	      || [istarget "*-*-msys*"])} {
 	    # Force output to unbuffered mode, by linking in an object file
 	    # with a global contructor that calls setvbuf.
 	    #
@@ -5668,6 +5673,7 @@ proc gdb_compile_shlib_1 {sources dest options} {
         }
 	"clang-*" {
 	    if { [istarget "*-*-cygwin*"]
+		 || [istarget *-*-msys*]
 		 || [istarget "*-*-mingw*"] } {
 		lappend obj_options "additional_flags=-fPIC"
 	    } else {
@@ -5678,6 +5684,7 @@ proc gdb_compile_shlib_1 {sources dest options} {
             if { [istarget "powerpc*-*-aix*"]
                    || [istarget "rs6000*-*-aix*"]
                    || [istarget "*-*-cygwin*"]
+                   || [istarget "*-*-msys*"]
                    || [istarget "*-*-mingw*"]
                    || [istarget "*-*-pe*"] } {
                 lappend obj_options "additional_flags=-fPIC"
@@ -5743,6 +5750,7 @@ proc gdb_compile_shlib_1 {sources dest options} {
 
 	if { ([istarget "*-*-mingw*"]
 	      || [istarget *-*-cygwin*]
+	      || [istarget *-*-msys*]
 	      || [istarget *-*-pe*]) } {
 	    if { [is_remote host] } {
 		set name [file tail ${dest}]
@@ -5770,6 +5778,7 @@ proc gdb_compile_shlib_1 {sources dest options} {
     if { [is_remote host]
 	 && ([istarget "*-*-mingw*"]
 	     || [istarget *-*-cygwin*]
+	     || [istarget *-*-msys*]
 	     || [istarget *-*-pe*]) } {
 	set dest_tail_name [file tail ${dest}]
 	remote_upload host $dest_tail_name.a ${dest}.a
@@ -6201,7 +6210,7 @@ proc kill_wait_spawned_process { proc_spawn_id } {
 proc spawn_id_get_pid { spawn_id } {
     set testpid [exp_pid -i $spawn_id]
 
-    if { [istarget "*-*-cygwin*"] } {
+    if { ([istarget "*-*-cygwin*"] || [istarget *-*-msys*]) } {
 	# testpid is the Cygwin PID, GDB uses the Windows PID, which
 	# might be different due to the way fork/exec works.
 	set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
@@ -7760,6 +7769,7 @@ gdb_caching_proc gdb_has_argv0 {} {
 	  || [istarget *-*-aix*]
 	  || [istarget *-*-gnu*]
 	  || [istarget *-*-cygwin*] || [istarget *-*-mingw32*]
+	  || [istarget *-*-msys*]
 	  || [istarget *-*-*djgpp*] || [istarget *-*-go32*]
 	  || [istarget *-wince-pe] || [istarget *-*-mingw32ce*]
 	  || [istarget *-*-osf*]
@@ -7794,7 +7804,7 @@ gdb_caching_proc gdb_has_argv0 {} {
 
 proc get_build_id { filename } {
     if { ([istarget "*-*-mingw*"]
-	  || [istarget *-*-cygwin*]) } {
+	  || [istarget *-*-cygwin*] || [istarget *-*-msys*]) } {
 	set objdump_program [gdb_find_objdump]
 	set result [catch {set data [exec $objdump_program -p $filename | grep signature | cut "-d " -f4]} output]
 	verbose "result is $result"
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index a90388922e2..5428715270d 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -894,11 +894,19 @@ windows_make_so (const char *name, LPVOID load_addr)
 	  so->name = so->original_name;
 	}
     }
+#ifdef __MSYS__
+  /* Record msys-2.0.dll .text start/end.  */
+  size_t len = sizeof ("/msys-2.0.dll") - 1;
+  if (so->name.size () >= len
+      && strcasecmp (so->name.c_str () + so->name.size () - len,
+		     "/msys-2.0.dll") == 0)
+#else
   /* Record cygwin1.dll .text start/end.  */
   size_t len = sizeof ("/cygwin1.dll") - 1;
   if (so->name.size () >= len
       && strcasecmp (so->name.c_str () + so->name.size () - len,
 		     "/cygwin1.dll") == 0)
+#endif
     {
       asection *text = NULL;
 
diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
index 9e861a75088..a9e16f79a10 100644
--- a/gdbserver/configure.srv
+++ b/gdbserver/configure.srv
@@ -94,7 +94,7 @@ case "${gdbserver_host}" in
 			srv_linux_regsets=yes
 			srv_linux_thread_db=yes
 			;;
-  i[34567]86-*-cygwin*)	srv_regobj=""
+  i[34567]86-*-cygwin* | i[34567]86-*-msys*)	srv_regobj=""
 			srv_tgtobj="x86-low.o nat/x86-dregs.o win32-low.o"
 			srv_tgtobj="${srv_tgtobj} win32-i386-low.o"
 			srv_tgtobj="${srv_tgtobj} nat/windows-nat.o"
@@ -387,7 +387,7 @@ case "${gdbserver_host}" in
 			srv_tgtobj="${srv_tgtobj} arch/amd64.o arch/i386.o"
 			srv_mingw=yes
 			;;
-  x86_64-*-cygwin*)	srv_regobj=""
+  x86_64-*-cygwin* | x86_64-*-msys*)	srv_regobj=""
 			srv_tgtobj="x86-low.o nat/x86-dregs.o"
 			srv_tgtobj="${srv_tgtobj} nat/x86-xstate.o i387-fp.o"
 			srv_tgtobj="${srv_tgtobj} win32-low.o win32-i386-low.o"
diff --git a/gnulib/configure b/gnulib/configure
index cb2a11359a1..f1fd9a3febc 100755
--- a/gnulib/configure
+++ b/gnulib/configure
@@ -9124,7 +9124,7 @@ else
         # special semantics and is distinct from /, please report it to
         # <bug-gnulib@gnu.org>.
         case $host in
-          *-cygwin | i370-ibm-openedition)
+          *-cygwin | *-msys | i370-ibm-openedition)
             gl_cv_double_slash_root=yes ;;
           *)
             # Be optimistic and assume that / and // are the same when we
@@ -23563,7 +23563,7 @@ else
         # special semantics and is distinct from /, please report it to
         # <bug-gnulib@gnu.org>.
         case $host in
-          *-cygwin | i370-ibm-openedition)
+          *-cygwin | *-msys | i370-ibm-openedition)
             gl_cv_double_slash_root=yes ;;
           *)
             # Be optimistic and assume that / and // are the same when we
@@ -23711,7 +23711,7 @@ else
   case "$host_os" in
          mingw*) # on this platform, dup2 always returns 0 for success
            gl_cv_func_dup2_works="guessing no" ;;
-         cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
+         cygwin* | msys*) # on cygwin 1.5.x, dup2(1,1) returns 0
            gl_cv_func_dup2_works="guessing no" ;;
          aix* | freebsd*)
                  # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
@@ -24112,7 +24112,7 @@ if ${gl_cv_func_fcntl_f_dupfd_works+:} false; then :
 else
   if test "$cross_compiling" = yes; then :
   case $host_os in
-            aix* | cygwin* | haiku*)
+            aix* | cygwin* | msys* | haiku*)
                gl_cv_func_fcntl_f_dupfd_works="guessing no" ;;
             *) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;;
           esac
diff --git a/gnulib/import/m4/double-slash-root.m4 b/gnulib/import/m4/double-slash-root.m4
index 09ff5f0d17a..1e11243ff02 100644
--- a/gnulib/import/m4/double-slash-root.m4
+++ b/gnulib/import/m4/double-slash-root.m4
@@ -16,7 +16,7 @@ AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
         # special semantics and is distinct from /, please report it to
         # <bug-gnulib@gnu.org>.
         case $host in
-          *-cygwin | i370-ibm-openedition)
+          *-cygwin | *-msys | i370-ibm-openedition)
             gl_cv_double_slash_root=yes ;;
           *)
             # Be optimistic and assume that / and // are the same when we
diff --git a/gnulib/import/m4/dup2.m4 b/gnulib/import/m4/dup2.m4
index 7e777cdee6a..62ad578c090 100644
--- a/gnulib/import/m4/dup2.m4
+++ b/gnulib/import/m4/dup2.m4
@@ -69,7 +69,7 @@ AC_DEFUN([gl_FUNC_DUP2],
       [case "$host_os" in
          mingw*) # on this platform, dup2 always returns 0 for success
            gl_cv_func_dup2_works="guessing no" ;;
-         cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
+         cygwin* | msys*) # on cygwin 1.5.x, dup2(1,1) returns 0
            gl_cv_func_dup2_works="guessing no" ;;
          aix* | freebsd*)
                  # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
diff --git a/gnulib/import/m4/fcntl.m4 b/gnulib/import/m4/fcntl.m4
index 428e5709d30..84f84fbb3dc 100644
--- a/gnulib/import/m4/fcntl.m4
+++ b/gnulib/import/m4/fcntl.m4
@@ -70,7 +70,7 @@ AC_DEFUN([gl_FUNC_FCNTL],
          [gl_cv_func_fcntl_f_dupfd_works=yes],
          [gl_cv_func_fcntl_f_dupfd_works=no],
          [case $host_os in
-            aix* | cygwin* | haiku*)
+            aix* | cygwin* | msys* | haiku*)
                gl_cv_func_fcntl_f_dupfd_works="guessing no" ;;
             *) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;;
           esac])])
diff --git a/gprof/configure b/gprof/configure
index 6c9d8701c48..4186345c74a 100755
--- a/gprof/configure
+++ b/gprof/configure
@@ -5141,7 +5141,7 @@ else
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -5483,7 +5483,7 @@ bsdi[45]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -6099,7 +6099,7 @@ case $host_os in
 aix*)
   symcode='[BCDT]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
@@ -7716,7 +7716,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -7798,7 +7798,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
@@ -8260,7 +8260,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -8375,7 +8375,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -8806,7 +8806,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -9707,14 +9707,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -9736,6 +9736,12 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    msys*)
+      # MSYS DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
@@ -10388,7 +10394,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
diff --git a/ld/configure b/ld/configure
index 96ef1f8bb65..1c1253d6c0f 100755
--- a/ld/configure
+++ b/ld/configure
@@ -6168,7 +6168,7 @@ else
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -6510,7 +6510,7 @@ bsdi[45]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -7126,7 +7126,7 @@ case $host_os in
 aix*)
   symcode='[BCDT]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
@@ -8744,7 +8744,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -8826,7 +8826,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
@@ -9288,7 +9288,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -9403,7 +9403,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -9834,7 +9834,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -10735,14 +10735,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -10764,6 +10764,12 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    msys*)
+      # MSYS DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
@@ -11416,7 +11422,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
@@ -12638,7 +12644,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
         esac
         ;;
 
-      cygwin* | mingw* | pw32* | cegcc*)
+      cygwin* | msys* | mingw* | pw32* | cegcc*)
         # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
         # as there is no search path for DLLs.
         hardcode_libdir_flag_spec_CXX='-L$libdir'
@@ -13608,7 +13614,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
     beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
       # PIC is the default for these OSes.
       ;;
-    mingw* | cygwin* | os2* | pw32* | cegcc*)
+    mingw* | cygwin* | msys* | os2* | pw32* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -14148,7 +14154,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   pw32*)
     export_symbols_cmds_CXX="$ltdll_cmds"
   ;;
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   *)
@@ -14412,14 +14418,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -14441,6 +14447,11 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      ;;
+    msys*)
+      # MSYS DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
@@ -18741,7 +18752,7 @@ done
 
 
 case "${host}" in
-*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-msys* | *-*-windows*)
 
 $as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
  ;;
diff --git a/ld/configure.tgt b/ld/configure.tgt
index f937f78b876..415378110d9 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -429,7 +429,7 @@ i[3-7]86-*-winnt*)	targ_emul=i386pe ;
 i[3-7]86-*-pe)		targ_emul=i386pe ;
 			targ_extra_ofiles="deffilep.o pdb.o pe-dll.o"
 			;;
-i[3-7]86-*-cygwin*)	targ_emul=i386pe ;
+i[3-7]86-*-cygwin* | i[3-7]86-*-msys*)	targ_emul=i386pe ;
 			targ_extra_ofiles="deffilep.o pdb.o pe-dll.o" ;
 			test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api'
 			;;
@@ -1060,7 +1060,7 @@ x86_64-*-pe | x86_64-*-pep) targ_emul=i386pep ;
 			targ_extra_emuls=i386pe ;
 			targ_extra_ofiles="deffilep.o pdb.o pep-dll-x86_64.o pe-dll.o"
 			;;
-x86_64-*-cygwin)	targ_emul=i386pep ;
+x86_64-*-cygwin | x86_64-*-msys)	targ_emul=i386pep ;
 			targ_extra_emuls=i386pe
 			targ_extra_ofiles="deffilep.o pdb.o pep-dll.o pe-dll.o"
 			test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api'
@@ -1145,7 +1145,7 @@ spu-*-elf*)
   NATIVE_LIB_DIRS='/lib'
   ;;
 
-i[03-9x]86-*-cygwin* | x86_64-*-cygwin*)
+i[03-9x]86-*-cygwin* | x86_64-*-cygwin* | i[03-9x]86-*-msys* | x86_64-*-msys*)
   NATIVE_LIB_DIRS='/usr/lib /usr/lib/w32api'
   ;;
 
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 9ab5e6ef481..090db3f8acc 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -7,7 +7,7 @@ else
 fi
 
 case ${target} in
-  *-*-cygwin*)
+  *-*-cygwin* | *-*-msys*)
     cygwin_behavior=1
     ;;
   *)
@@ -208,7 +208,7 @@ EOF
 # merge_rdata defaults to 0 for cygwin:
 #  http://cygwin.com/ml/cygwin-apps/2013-04/msg00187.html
 case ${target} in
-  *-*-cygwin*)
+  *-*-cygwin* | *-*-msys*)
     default_auto_import=1
     default_merge_rdata=0
     ;;
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 00c4ea9e15a..f625973dffa 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -7,7 +7,7 @@ else
 fi
 
 case ${target} in
-  *-*-cygwin*)
+  *-*-cygwin* | *-*-msys*)
     move_default_addr_high=1
     cygwin_behavior=1
     ;;
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 95eef84f607..536d4b60832 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -210,6 +210,7 @@ static const autofilter_entry_type autofilter_symbollist_i386[] =
   { STRING_COMMA_LEN ("_NULL_IMPORT_DESCRIPTOR") },
   /* Entry point symbols, and entry hooks.  */
   { STRING_COMMA_LEN ("cygwin_crt0") },
+  { STRING_COMMA_LEN ("msys_crt0") },
 #ifdef pe_use_plus
   { STRING_COMMA_LEN ("DllMain") },
   { STRING_COMMA_LEN ("DllEntryPoint") },
@@ -217,6 +218,9 @@ static const autofilter_entry_type autofilter_symbollist_i386[] =
   { STRING_COMMA_LEN ("_cygwin_dll_entry") },
   { STRING_COMMA_LEN ("_cygwin_crt0_common") },
   { STRING_COMMA_LEN ("_cygwin_noncygwin_dll_entry") },
+  { STRING_COMMA_LEN ("_msys_dll_entry") },
+  { STRING_COMMA_LEN ("_msys_crt0_common") },
+  { STRING_COMMA_LEN ("_msys_nonmsys_dll_entry") },
 #else
   { STRING_COMMA_LEN ("DllMain@12") },
   { STRING_COMMA_LEN ("DllEntryPoint@0") },
@@ -225,6 +229,10 @@ static const autofilter_entry_type autofilter_symbollist_i386[] =
   { STRING_COMMA_LEN ("_cygwin_crt0_common@8") },
   { STRING_COMMA_LEN ("_cygwin_noncygwin_dll_entry@12") },
   { STRING_COMMA_LEN ("cygwin_attach_dll") },
+  { STRING_COMMA_LEN ("_msys_dll_entry@12") },
+  { STRING_COMMA_LEN ("_msys_crt0_common@8") },
+  { STRING_COMMA_LEN ("_msys_nonmsys_dll_entry@12") },
+  { STRING_COMMA_LEN ("msys_attach_dll") },
 #endif
   { STRING_COMMA_LEN ("cygwin_premain0") },
   { STRING_COMMA_LEN ("cygwin_premain1") },
@@ -348,6 +356,7 @@ static const autofilter_entry_type autofilter_liblist[] =
 {
   { STRING_COMMA_LEN ("libcegcc") },
   { STRING_COMMA_LEN ("libcygwin") },
+  { STRING_COMMA_LEN ("libmsys-2.0") },
   { STRING_COMMA_LEN ("libgcc") },
   { STRING_COMMA_LEN ("libgcc_s") },
   { STRING_COMMA_LEN ("libstdc++") },
diff --git a/ld/testsuite/ld-auto-import/auto-import.exp b/ld/testsuite/ld-auto-import/auto-import.exp
index 5827df43865..7608556429c 100644
--- a/ld/testsuite/ld-auto-import/auto-import.exp
+++ b/ld/testsuite/ld-auto-import/auto-import.exp
@@ -174,3 +174,65 @@ if [istarget *-pc-cygwin] {
     	fail $msg
     }
 }
+
+if [istarget *-pc-msys] {
+    # Set some libs needed for msys.
+    set MYLIBS "-L/usr/lib -lmsys-2.0 -L/usr/lib/w32api -lkernel32"
+    
+    # Compile the dll.
+    if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/dll.c $tmpdir/dll.o] {
+	fail "compiling shared lib"
+    }
+    if ![ld_special_link "$ld -shared --enable-auto-import -e __cygwin_dll_entry@12 --out-implib=$tmpdir/libstandard.dll.a" $tmpdir/dll.dll "$tmpdir/dll.o $MYLIBS"] {
+	fail "linking shared lib"
+    }
+
+    # Create symbolic link.
+    catch "exec ln -fs dll.dll $tmpdir/libsymlinked_dll.dll.a" ln_catch
+
+    # Compile and link the client program.
+    if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/client.c $tmpdir/client.o] {
+        fail "compiling client"
+    }
+
+    # Check linking with import library.
+    set msg "linking auto-import client using a standard import library"
+    if [ld_special_link $ld $tmpdir/client-linklib.exe "--enable-auto-import --enable-runtime-pseudo-reloc /lib/crt0.o $tmpdir/client.o -L$tmpdir -lstandard $MYLIBS"] {
+	pass $msg
+    } else {
+	fail $msg 
+    }
+
+    # Check linking directly with dll.
+    set msg "linking auto-import client using the dll"
+    if [ld_special_link $ld $tmpdir/client-linkdll.exe "--enable-auto-import --enable-runtime-pseudo-reloc /lib/crt0.o $tmpdir/client.o -L$tmpdir -ldll $MYLIBS"] {
+	pass $msg
+    } else {
+	fail $msg 
+    }
+
+    # Check linking with symlinked dll.
+    set msg "linking auto-import client using symbolic linked dll"
+    if [ld_special_link $ld $tmpdir/client-symlinkeddll.exe "--enable-auto-import --enable-runtime-pseudo-reloc /lib/crt0.o $tmpdir/client.o -L$tmpdir -lsymlinked_dll $MYLIBS"] {
+	pass $msg
+    } else {
+	fail $msg 
+    }
+
+    # Check linking with disabled auto-import, this must produce linking error.
+    set msg "linking with disabled auto-import"
+    if ![ld_special_link $ld $tmpdir/client-failed.exe "--disable-auto-import --enable-runtime-pseudo-reloc /lib/crt0.o $tmpdir/client.o -L$tmpdir -ldll $MYLIBS"] {
+	pass $msg
+    } else {
+	fail $msg
+    }
+
+    # Check that the app works - ie that there is output when the applications runs.
+    set msg "application runtime segfault check" 
+    catch "exec $tmpdir/client-linklib.exe" exec_output
+    if ![string match "" $exec_output] then {
+    	pass $msg
+    } else {
+    	fail $msg
+    }
+}
diff --git a/ld/testsuite/ld-fastcall/fastcall.exp b/ld/testsuite/ld-fastcall/fastcall.exp
index 532259e1f83..c0d05b4dbd5 100644
--- a/ld/testsuite/ld-fastcall/fastcall.exp
+++ b/ld/testsuite/ld-fastcall/fastcall.exp
@@ -26,6 +26,7 @@ if {![istarget "i*86-*-*"] && ![istarget "x86_64-*-mingw*"] } {
 
 if {  !([istarget "i*86-*-*pe*"] && ![istarget "i*86-*-opensd*"]) \
     && ![istarget "i*86-*-cygwin*"] \
+    && ![istarget "i*86-*-msys*"] \
     && ![istarget "x86_64-*-mingw*"] \
     && ![istarget "i*86-*-mingw*"] } {
     return
diff --git a/ld/testsuite/ld-pe/pe-compile.exp b/ld/testsuite/ld-pe/pe-compile.exp
index ff867ce1118..1f70251795d 100644
--- a/ld/testsuite/ld-pe/pe-compile.exp
+++ b/ld/testsuite/ld-pe/pe-compile.exp
@@ -116,6 +116,7 @@ run_ver_script_test "vers-script-3"
 run_ver_script_test "vers-script-4"
 
 if {[istarget i*86-*-cygwin*]
+    || [istarget i*86-*-msys*]
     || [istarget i*86-*-pe]
     || [istarget i*86-*-mingw*]
     || [istarget x86_64-*-mingw*] } {
diff --git a/ld/testsuite/ld-pe/pe.exp b/ld/testsuite/ld-pe/pe.exp
index 6a30366ff61..365c94894d0 100644
--- a/ld/testsuite/ld-pe/pe.exp
+++ b/ld/testsuite/ld-pe/pe.exp
@@ -26,6 +26,7 @@ if {![is_pecoff_format]} {
 
 # This test can only be run on PE/COFF platforms that support .secrel32.
 if {[istarget i*86-*-cygwin*]
+    || [istarget i*86-*-msys*]
     || [istarget i*86-*-pe]
     || [istarget i*86-*-mingw*]
     || [istarget x86_64-*-mingw*]
@@ -42,7 +43,7 @@ if {[istarget i*86-*-cygwin*]
 	{"TLS directory entry" "" "" "" "tlssec.s"
 	 {{objdump -p tlssec64.d}} "tlssec.dll"}
       }
-    } elseif {[istarget i*86-*-cygwin*] } {
+    } elseif {[istarget i*86-*-cygwin*] || [istarget i*86-*-msys*] } {
       set pe_tests {
 	{".secrel32" "--disable-auto-import --disable-reloc-section" "" "" {secrel1.s secrel2.s}
 	 {{objdump -s secrel.d}} "secrel.x"}
@@ -127,7 +128,7 @@ run_ld_link_tests $pr19803_dll
 
 if {[istarget x86_64-*-mingw*] } {
 	run_dump_test "cfi"
-} elseif {[istarget i*86-*-cygwin*] || [istarget i*86-*-mingw*] } {
+} elseif {[istarget i*86-*-cygwin*] || [istarget i*86-*-msys*] || [istarget i*86-*-mingw*] } {
 	run_dump_test "cfi32"
 }
 
diff --git a/ld/testsuite/ld-pe/weakdef-1.d b/ld/testsuite/ld-pe/weakdef-1.d
index 57a85656ea5..a653170629b 100644
--- a/ld/testsuite/ld-pe/weakdef-1.d
+++ b/ld/testsuite/ld-pe/weakdef-1.d
@@ -1,5 +1,5 @@
 #source: weakdef-1.s
-#target: i*86-*-cygwin* i*86-*-pe i*86-*-mingw*
+#target: i*86-*-cygwin* i*86-*-msys* i*86-*-pe i*86-*-mingw*
 #ld: -e _start --gc-sections
 #objdump: -d
 
diff --git a/libctf/configure b/libctf/configure
index 3701bd8e796..3426511bcfa 100755
--- a/libctf/configure
+++ b/libctf/configure
@@ -8112,7 +8112,7 @@ else
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -8454,7 +8454,7 @@ bsdi[45]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -9070,7 +9070,7 @@ case $host_os in
 aix*)
   symcode='[BCDT]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
@@ -10657,7 +10657,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -10739,7 +10739,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
@@ -11201,7 +11201,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -11316,7 +11316,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -11747,7 +11747,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -12648,14 +12648,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -12677,6 +12677,12 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    msys*)
+      # Msys DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
@@ -13329,7 +13335,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
@@ -16881,6 +16887,10 @@ if test "$enable_shared" = "yes"; then
       SHARED_LDFLAGS="-no-undefined"
       CTF_LIBADD="$CTF_LIBADD -lcygwin"
       ;;
+    *-*-msys*)
+      SHARED_LDFLAGS="-no-undefined"
+      CTF_LIBADD="$CTF_LIBADD -lmsys-2.0"
+      ;;
   esac
 fi
 
diff --git a/libctf/configure.ac b/libctf/configure.ac
index e4e430615bd..ead6a24d183 100644
--- a/libctf/configure.ac
+++ b/libctf/configure.ac
@@ -229,6 +229,10 @@ if test "$enable_shared" = "yes"; then
       SHARED_LDFLAGS="-no-undefined"
       CTF_LIBADD="$CTF_LIBADD -lcygwin"
       ;;
+    *-*-msys*)
+      SHARED_LDFLAGS="-no-undefined"
+      CTF_LIBADD="$CTF_LIBADD -lmsys-2.0"
+      ;;
   esac
 fi
 AC_SUBST(SHARED_LDFLAGS)
diff --git a/libdecnumber/configure b/libdecnumber/configure
index e4600c10e55..8ecb083a560 100755
--- a/libdecnumber/configure
+++ b/libdecnumber/configure
@@ -4769,7 +4769,8 @@ else
     powerpc*-*-linux* | i?86*-*-linux* | x86_64*-*-linux* | s390*-*-linux* | \
     i?86*-*-elfiamcu | i?86*-*-gnu* | x86_64*-*-gnu* | \
     i?86*-*-mingw* | x86_64*-*-mingw* | \
-    i?86*-*-cygwin* | x86_64*-*-cygwin*)
+    i?86*-*-cygwin* | x86_64*-*-cygwin* | \
+    i?86*-*-msys* | x86_64*-*-msys*)
       enable_decimal_float=yes
       ;;
     *)
diff --git a/libiberty/configure b/libiberty/configure
index 5c69fee56c1..0b710e6035c 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -5339,6 +5339,8 @@ case "${host}" in
 	;;
     i[34567]86-*-cygwin* | x86_64-*-cygwin*)
 	;;
+    i[34567]86-*-msys* | x86_64-*-msys*)
+	;;
     i[34567]86-*-mingw* | x86_64-*-mingw*)
 	;;
     i[34567]86-*-interix[3-9]*)
@@ -6722,7 +6724,7 @@ fi
 
 
 case "${host}" in
-  *-*-cygwin* | *-*-mingw*)
+  *-*-cygwin* | *-*-msys* | *-*-mingw*)
     $as_echo "#define HAVE_SYS_ERRLIST 1" >>confdefs.h
 
     $as_echo "#define HAVE_SYS_NERR 1" >>confdefs.h
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index 0888e638896..5f5a87405be 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -582,7 +582,7 @@ AC_SUBST(CHECK)
 AC_SUBST(target_header_dir)
 
 case "${host}" in
-  *-*-cygwin* | *-*-mingw*)
+  *-*-cygwin* | *-*-msys* | *-*-mingw*)
     AC_DEFINE(HAVE_SYS_ERRLIST)
     AC_DEFINE(HAVE_SYS_NERR)
     ;;
diff --git a/libtool.m4 b/libtool.m4
index e36fdd3c0e2..8602498fc03 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -1523,7 +1523,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -1765,7 +1765,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
@@ -2236,14 +2236,14 @@ bsdi[[45]]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -2264,6 +2264,12 @@ cygwin* | mingw* | pw32* | cegcc*)
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+m4_if([$1], [],[
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
+      ;;
+    msys*)
+      # Msys DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
 m4_if([$1], [],[
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
       ;;
@@ -3047,7 +3053,7 @@ bsdi[[45]]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -3344,7 +3350,7 @@ AC_DEFUN([LT_LIB_M],
 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
 LIBM=
 case $host in
-*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-msys* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
   # These system don't have libm, or don't need it
   ;;
 *-ncr-sysv4.3*)
@@ -3419,7 +3425,7 @@ case $host_os in
 aix*)
   symcode='[[BCDT]]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[[ABCDGISTW]]'
   ;;
 hpux*)
@@ -3666,7 +3672,7 @@ m4_if([$1], [CXX], [
     beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
       # PIC is the default for these OSes.
       ;;
-    mingw* | cygwin* | os2* | pw32* | cegcc*)
+    mingw* | cygwin* | msys* | os2* | pw32* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -3979,7 +3985,7 @@ m4_if([$1], [CXX], [
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -4062,7 +4068,7 @@ m4_if([$1], [CXX], [
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       m4_if([$1], [GCJ], [],
@@ -4295,7 +4301,7 @@ m4_if([$1], [CXX], [
   pw32*)
     _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
   ;;
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   *)
@@ -4347,7 +4353,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -4462,7 +4468,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
       # as there is no search path for DLLs.
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
@@ -4835,7 +4841,7 @@ _LT_EOF
       _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -5779,7 +5785,7 @@ if test "$_lt_caught_CXX_error" != yes; then
         esac
         ;;
 
-      cygwin* | mingw* | pw32* | cegcc*)
+      cygwin* | msys* | mingw* | pw32* | cegcc*)
         # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
         # as there is no search path for DLLs.
         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
diff --git a/ltmain.sh b/ltmain.sh
index 70990740b6c..e8161587051 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -976,7 +976,7 @@ func_enable_tag ()
 
 
   case $host in
-    *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* )
+    *cygwin* | *msys* | *mingw* | *pw32* | *cegcc* | *solaris2* )
       # don't eliminate duplications in $postdeps and $predeps
       opt_duplicate_compiler_generated_deps=:
       ;;
@@ -1453,7 +1453,7 @@ func_mode_compile ()
 
     # On Cygwin there's no "real" PIC flag so we must build both object types
     case $host_os in
-    cygwin* | mingw* | pw32* | os2* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | os2* | cegcc*)
       pic_mode=default
       ;;
     esac
@@ -2279,7 +2279,7 @@ func_mode_install ()
 	      'exit $?'
 	  tstripme="$stripme"
 	  case $host_os in
-	  cygwin* | mingw* | pw32* | cegcc*)
+	  cygwin* | msys* | mingw* | pw32* | cegcc*)
 	    case $realname in
 	    *.dll.a)
 	      tstripme=""
@@ -2385,7 +2385,7 @@ func_mode_install ()
 
 	# Do a test to see if this is really a libtool program.
 	case $host in
-	*cygwin* | *mingw*)
+	*cygwin* | *msys* | *mingw*)
 	    if func_ltwrapper_executable_p "$file"; then
 	      func_ltwrapper_scriptname "$file"
 	      wrapper=$func_ltwrapper_scriptname_result
@@ -2460,7 +2460,7 @@ func_mode_install ()
 	# remove .exe since cygwin /usr/bin/install will append another
 	# one anyway
 	case $install_prog,$host in
-	*/usr/bin/install*,*cygwin*)
+	*/usr/bin/install*,*cygwin*|*/usr/bin/install*,*msys*)
 	  case $file:$destfile in
 	  *.exe:*.exe)
 	    # this is ok
@@ -2595,7 +2595,7 @@ extern \"C\" {
 	      $RM $export_symbols
 	      ${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' < "$nlist" > "$export_symbols"
 	      case $host in
-	      *cygwin* | *mingw* | *cegcc* )
+	      *cygwin* | *msys* | *mingw* | *cegcc* )
                 echo EXPORTS > "$output_objdir/$outputname.def"
                 cat "$export_symbols" >> "$output_objdir/$outputname.def"
 	        ;;
@@ -2607,7 +2607,7 @@ extern \"C\" {
 	      $GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T
 	      $MV "$nlist"T "$nlist"
 	      case $host in
-	        *cygwin* | *mingw* | *cegcc* )
+	        *cygwin* | *msys* | *mingw* | *cegcc* )
 	          echo EXPORTS > "$output_objdir/$outputname.def"
 	          cat "$nlist" >> "$output_objdir/$outputname.def"
 	          ;;
@@ -2663,7 +2663,7 @@ typedef struct {
 } lt_dlsymlist;
 "
 	  case $host in
-	  *cygwin* | *mingw* | *cegcc* )
+	  *cygwin* | *msys* | *mingw* | *cegcc* )
 	    echo >> "$output_objdir/$my_dlsyms" "\
 /* DATA imports from DLLs on WIN32 con't be const, because
    runtime relocations are performed -- see ld's documentation
@@ -2749,7 +2749,7 @@ static const void *lt_preloaded_setup() {
 	# Transform the symbol file into the correct name.
 	symfileobj="$output_objdir/${my_outputname}S.$objext"
 	case $host in
-	*cygwin* | *mingw* | *cegcc* )
+	*cygwin* | *msys* | *mingw* | *cegcc* )
 	  if test -f "$output_objdir/$my_outputname.def"; then
 	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
 	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
@@ -3192,7 +3192,7 @@ func_to_host_path ()
             func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null |
               $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
             ;;
-          *cygwin* )
+          *cygwin* | *msys* )
             func_to_host_path_result=`cygpath -w "$1" |
 	      $SED -e "$lt_sed_naive_backslashify"`
             ;;
@@ -3265,7 +3265,7 @@ func_to_host_pathlist ()
 	      ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null |
 	      $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
             ;;
-          *cygwin* )
+          *cygwin* | *msys* )
             func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" |
               $SED -e "$lt_sed_naive_backslashify"`
             ;;
@@ -3571,7 +3571,7 @@ main (int argc, char *argv[])
 	{
 EOF
 	    case "$host" in
-	      *mingw* | *cygwin* )
+	      *mingw* | *cygwin* | *msys* )
 		# make stdout use "unix" line endings
 		echo "          setmode(1,_O_BINARY);"
 		;;
@@ -4233,7 +4233,7 @@ func_mode_link ()
 {
     $opt_debug
     case $host in
-    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+    *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
       # It is impossible to link a dll without this setting, and
       # we shouldn't force the makefile maintainer to figure out
       # which system we are compiling for in order to pass an extra
@@ -4713,7 +4713,7 @@ func_mode_link ()
 	  ;;
 	esac
 	case $host in
-	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+	*-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
 	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$dir:"*) ;;
@@ -4733,7 +4733,7 @@ func_mode_link ()
       -l*)
 	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
 	  case $host in
-	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
+	  *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
 	    # These systems don't actually have a C or math library (as such)
 	    continue
 	    ;;
@@ -4813,7 +4813,7 @@ func_mode_link ()
 
       -no-install)
 	case $host in
-	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
+	*-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
 	  # The PATH hackery in wrapper scripts is required on Windows
 	  # and Darwin in order for the loader to find any dlls it needs.
 	  func_warning "\`-no-install' is ignored for $host"
@@ -5772,7 +5772,7 @@ func_mode_link ()
 	if test -n "$library_names" &&
 	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
 	  case $host in
-	  *cygwin* | *mingw* | *cegcc*)
+	  *cygwin* | *msys* | *mingw* | *cegcc*)
 	      # No point in relinking DLLs because paths are not encoded
 	      notinst_deplibs="$notinst_deplibs $lib"
 	      need_relink=no
@@ -5842,7 +5842,7 @@ func_mode_link ()
 	    elif test -n "$soname_spec"; then
 	      # bleh windows
 	      case $host in
-	      *cygwin* | mingw* | *cegcc*)
+	      *cygwin* | *msys* | mingw* | *cegcc*)
 	        func_arith $current - $age
 		major=$func_arith_result
 		versuffix="-$major"
@@ -6693,7 +6693,7 @@ func_mode_link ()
       if test "$build_libtool_libs" = yes; then
 	if test -n "$rpath"; then
 	  case $host in
-	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
+	  *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
 	    # these systems don't actually have a c library (as such)!
 	    ;;
 	  *-*-rhapsody* | *-*-darwin1.[012])
@@ -7194,7 +7194,7 @@ EOF
 
 	orig_export_symbols=
 	case $host_os in
-	cygwin* | mingw* | cegcc*)
+	cygwin* | msys* | mingw* | cegcc*)
 	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
 	    # exporting using user supplied symfile
 	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
@@ -7710,7 +7710,7 @@ EOF
 
     prog)
       case $host in
-	*cygwin*) func_stripname '' '.exe' "$output"
+	*cygwin* | *msys*) func_stripname '' '.exe' "$output"
 	          output=$func_stripname_result.exe;;
       esac
       test -n "$vinfo" && \
@@ -7823,7 +7823,7 @@ EOF
 	  esac
 	fi
 	case $host in
-	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+	*-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
 	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$libdir:"*) ;;
@@ -7901,7 +7901,7 @@ EOF
         # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
         wrappers_required=no
         ;;
-      *cygwin* | *mingw* )
+      *cygwin* | *msys* | *mingw* )
         if test "$build_libtool_libs" != yes; then
           wrappers_required=no
         fi
@@ -8029,14 +8029,14 @@ EOF
 	esac
 	# test for cygwin because mv fails w/o .exe extensions
 	case $host in
-	  *cygwin*)
+	  *cygwin* | *msys*)
 	    exeext=.exe
 	    func_stripname '' '.exe' "$outputname"
 	    outputname=$func_stripname_result ;;
 	  *) exeext= ;;
 	esac
 	case $host in
-	  *cygwin* | *mingw* )
+	  *cygwin* | *msys* | *mingw* )
 	    func_dirname_and_basename "$output" "" "."
 	    output_name=$func_basename_result
 	    output_path=$func_dirname_result
@@ -8343,7 +8343,7 @@ EOF
 	  # tests/bindir.at for full details.
 	  tdlname=$dlname
 	  case $host,$output,$installed,$module,$dlname in
-	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
+	    *cygwin*,*lai,yes,no,*.dll | *msys*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
 	      # If a -bindir argument was supplied, place the dll there.
 	      if test "x$bindir" != x ;
 	      then
diff --git a/ltoptions.m4 b/ltoptions.m4
index 5ef12ced2a8..5e7bc34702b 100644
--- a/ltoptions.m4
+++ b/ltoptions.m4
@@ -126,7 +126,7 @@ LT_OPTION_DEFINE([LT_INIT], [win32-dll],
 [enable_win32_dll=yes
 
 case $host in
-*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
+*-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
   AC_CHECK_TOOL(AS, as, false)
   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
   AC_CHECK_TOOL(OBJDUMP, objdump, false)
diff --git a/opcodes/configure b/opcodes/configure
index 9b3cc5ce4a1..e70d76d12f1 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -5608,7 +5608,7 @@ else
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -5950,7 +5950,7 @@ bsdi[45]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -6566,7 +6566,7 @@ case $host_os in
 aix*)
   symcode='[BCDT]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
@@ -8153,7 +8153,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -8235,7 +8235,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
@@ -8697,7 +8697,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -8812,7 +8812,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -9243,7 +9243,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -10144,14 +10144,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -10173,6 +10173,12 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    msys*)
+      # Msys DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
@@ -10825,7 +10831,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
@@ -14207,7 +14213,7 @@ $as_echo "$bfd_cv_ld_as_needed" >&6; }
 
 LIBM=
 case $host in
-*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-msys* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
   # These system don't have libm, or don't need it
   ;;
 *-ncr-sysv4.3*)
@@ -14383,6 +14389,10 @@ if test "$enable_shared" = "yes"; then
       SHARED_LDFLAGS="-no-undefined"
       SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty $SHARED_LIBADD"
       ;;
+    *-*-msys*)
+      SHARED_LDFLAGS="-no-undefined"
+      SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lmsys-2.0"
+      ;;
     *)
       SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}"
       SHARED_DEPENDENCIES="../bfd/libbfd.la"
diff --git a/opcodes/configure.ac b/opcodes/configure.ac
index d812ff54a95..2c6843e7bff 100644
--- a/opcodes/configure.ac
+++ b/opcodes/configure.ac
@@ -198,6 +198,10 @@ if test "$enable_shared" = "yes"; then
       SHARED_LDFLAGS="-no-undefined"
       SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty $SHARED_LIBADD"
       ;;
+    *-*-msys*)
+      SHARED_LDFLAGS="-no-undefined"
+      SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty $SHARED_LIBADD"
+      ;;
     *)
       SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}"
       SHARED_DEPENDENCIES="../bfd/libbfd.la"
diff --git a/readline/readline/configure b/readline/readline/configure
index 6ea4545e26f..2aec06a0d99 100755
--- a/readline/readline/configure
+++ b/readline/readline/configure
@@ -2615,7 +2615,7 @@ fi
 CROSS_COMPILE=
 if test "x$cross_compiling" = "xyes"; then
     case "${host}" in
-    *-cygwin*)
+    *-cygwin* | *-msys*)
         cross_cache=${srcdir}/cross-build/cygwin.cache
         ;;
     *-mingw*)
diff --git a/readline/readline/configure.ac b/readline/readline/configure.ac
index 912c99b6575..4e9ee84b7a4 100644
--- a/readline/readline/configure.ac
+++ b/readline/readline/configure.ac
@@ -85,7 +85,7 @@ dnl build machine.
 CROSS_COMPILE=
 if test "x$cross_compiling" = "xyes"; then
     case "${host}" in
-    *-cygwin*)
+    *-cygwin* | *-msys*)
         cross_cache=${srcdir}/cross-build/cygwin.cache
         ;;
     *-mingw*)
diff --git a/readline/readline/support/config.guess b/readline/readline/support/config.guess
index cc7a8107011..85c30845c7c 100755
--- a/readline/readline/support/config.guess
+++ b/readline/readline/support/config.guess
@@ -918,6 +918,9 @@ EOF
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
 	echo x86_64-pc-cygwin
 	exit ;;
+    amd64:MSYS*:*:* | x86_64:MSYS*:*:*)
+	echo x86_64-pc-msys
+	exit ;;
     prep*:SunOS:5.*:*)
 	echo powerpcle-unknown-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')"
 	exit ;;
diff --git a/readline/readline/support/config.rpath b/readline/readline/support/config.rpath
index fc5913d7878..54df9203647 100755
--- a/readline/readline/support/config.rpath
+++ b/readline/readline/support/config.rpath
@@ -57,7 +57,7 @@ else
     aix*)
       wl='-Wl,'
       ;;
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       ;;
     hpux9* | hpux10* | hpux11*)
       wl='-Wl,'
@@ -149,7 +149,7 @@ hardcode_direct=no
 hardcode_minus_L=no
 
 case "$host_os" in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -198,7 +198,7 @@ if test "$with_gnu_ld" = yes; then
         ld_shlibs=no
       fi
       ;;
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # hardcode_libdir_flag_spec is actually meaningless, as there is
       # no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -348,7 +348,7 @@ else
       ;;
     bsdi[45]*)
       ;;
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -533,7 +533,7 @@ case "$host_os" in
   bsdi[45]*)
     library_names_spec='$libname$shrext'
     ;;
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     shrext=.dll
     library_names_spec='$libname.dll.a $libname.lib'
     ;;
diff --git a/readline/readline/support/shlib-install b/readline/readline/support/shlib-install
index 661355d32b2..39d0fddb96e 100755
--- a/readline/readline/support/shlib-install
+++ b/readline/readline/support/shlib-install
@@ -75,7 +75,7 @@ hpux*|darwin*|macosx*|linux*|solaris2*)
 	if [ -z "$uninstall" ]; then
 		chmod 755 ${INSTALLDIR}/${LIBNAME}
 	fi ;;
-cygwin*|mingw*)
+cygwin*|msys*|mingw*)
 	IMPLIBNAME=`echo ${LIBNAME} \
 		| sed -e 's,^cyg,lib,' -e 's,[0-9]*.dll$,.dll.a,'`
 	if [ -z "$uninstall" ]; then
@@ -162,7 +162,7 @@ hpux1*)
 	fi
 	;;
 
-cygwin*|mingw*)
+cygwin*|msys*|mingw*)
 	# Links to .dlls don't work.  Hence shobj-conf used DLLVERSION.dll
 	# instead of so.SHLIB_MAJOR.SHLIB_MINOR.  The postinstall above
 	# took care of everything else.
diff --git a/readline/readline/support/shobj-conf b/readline/readline/support/shobj-conf
index 5a3f9776e91..595e92384f2 100755
--- a/readline/readline/support/shobj-conf
+++ b/readline/readline/support/shobj-conf
@@ -494,6 +494,24 @@ cygwin*)
 	fi
 	;;
 
+msys*)
+	SHOBJ_LD='$(CC)'
+	SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
+	SHLIB_LIBPREF='msys-'
+	SHLIB_LIBSUFF='dll'
+	SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
+	SHLIB_LIBS='$(TERMCAP_LIB)'
+
+	SHLIB_DOT=
+	# For official cygwin releases, DLLVERSION will be defined in the
+	# environment of configure, and will be incremented any time the API
+	# changes in a non-backwards compatible manner.  Otherwise, it is just
+	# SHLIB_MAJOR.
+	if [ -n "$DLLVERSION" ] ; then
+		SHLIB_DLLVERSION="$DLLVERSION"
+	fi
+	;;
+
 mingw*)
 	SHOBJ_LD='$(CC)'
 	SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
diff --git a/sim/configure b/sim/configure
index 1ebef377973..cdb71136bc1 100755
--- a/sim/configure
+++ b/sim/configure
@@ -6347,7 +6347,7 @@ else
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -6689,7 +6689,7 @@ bsdi[45]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -7347,7 +7347,7 @@ case $host_os in
 aix*)
   symcode='[BCDT]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
@@ -9953,7 +9953,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -10035,7 +10035,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
@@ -10497,7 +10497,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -10612,7 +10612,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -11043,7 +11043,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -11944,14 +11944,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -11973,6 +11973,12 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    msys*)
+      # Msys DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
@@ -12625,7 +12631,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
diff --git a/zlib/configure b/zlib/configure
index 2d551360683..705b179bf8c 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -4931,7 +4931,7 @@ else
     lt_cv_sys_max_cmd_len=-1;
     ;;
 
-  cygwin* | mingw* | cegcc*)
+  cygwin* | msys* | mingw* | cegcc*)
     # On Win9x/ME, this test blows up -- it succeeds, but takes
     # about 5 minutes as the teststring grows exponentially.
     # Worse, since 9x/ME are not pre-emptively multitasking,
@@ -5273,7 +5273,7 @@ bsdi[45]*)
   lt_cv_file_magic_test_file=/shlib/libc.so
   ;;
 
-cygwin*)
+cygwin* | msys*)
   # func_win32_libid is a shell function defined in ltmain.sh
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
@@ -5889,7 +5889,7 @@ case $host_os in
 aix*)
   symcode='[BCDT]'
   ;;
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
@@ -7780,7 +7780,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
@@ -7862,7 +7862,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
       fi
       ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
@@ -8324,7 +8324,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   extract_expsyms_cmds=
 
   case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -8439,7 +8439,7 @@ _LT_EOF
       fi
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -8876,7 +8876,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec=-rdynamic
       ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -9780,14 +9780,14 @@ bsdi[45]*)
   # libtool to hard-code these into programs
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
+cygwin* | msys* | mingw* | pw32* | cegcc*)
   version_type=windows
   shrext_cmds=".dll"
   need_version=no
   need_lib_prefix=no
 
   case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+  yes,cygwin* | yes,msys* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
     postinstall_cmds='base_file=`basename \${file}`~
@@ -9809,6 +9809,12 @@ cygwin* | mingw* | pw32* | cegcc*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
       soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    msys*)
+      # Msys DLLs use 'msys-' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
@@ -10464,7 +10470,7 @@ else
     lt_cv_dlopen_libs=
     ;;
 
-  cygwin*)
+  cygwin* | msys*)
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
     ;;
-- 
2.40.1


^ permalink raw reply	[relevance 10%]

* [PATCH] gdb: iterate over targets, not inferiors, to commit resumed
@ 2024-03-01 15:52  4% Tankut Baris Aktemur
  0 siblings, 0 replies; 200+ results
From: Tankut Baris Aktemur @ 2024-03-01 15:52 UTC (permalink / raw)
  To: gdb-patches

When committing resumed threads of targets, iterate over targets, not
inferiors, so that we don't call commit_resumed multiple times for
targets that have multiple inferiors.  This gives more concise code.

Similarly, iterate over targets when setting the commit_resumed_state
of targets.

No behavioral change is expected or intended with this patch.
---
 gdb/infrun.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index bbb98f6dcdb..af9c00d32e3 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3210,16 +3210,10 @@ maybe_set_commit_resumed_all_targets ()
 {
   scoped_restore_current_thread restore_thread;
 
-  for (inferior *inf : all_non_exited_inferiors ())
+  for (auto *proc_target : all_non_exited_process_targets ())
     {
-      process_stratum_target *proc_target = inf->process_target ();
-
       if (proc_target->commit_resumed_state)
-	{
-	  /* We already set this in a previous iteration, via another
-	     inferior sharing the process_stratum target.  */
-	  continue;
-	}
+	continue;
 
       /* If the target has no resumed threads, it would be useless to
 	 ask it to commit the resumed threads.  */
@@ -3243,7 +3237,7 @@ maybe_set_commit_resumed_all_targets ()
 	  continue;
 	}
 
-      switch_to_inferior_no_thread (inf);
+      switch_to_target_no_thread (proc_target);
 
       if (target_has_pending_events ())
 	{
@@ -3267,14 +3261,12 @@ maybe_call_commit_resumed_all_targets ()
 {
   scoped_restore_current_thread restore_thread;
 
-  for (inferior *inf : all_non_exited_inferiors ())
+  for (auto *proc_target : all_non_exited_process_targets ())
     {
-      process_stratum_target *proc_target = inf->process_target ();
-
       if (!proc_target->commit_resumed_state)
 	continue;
 
-      switch_to_inferior_no_thread (inf);
+      switch_to_target_no_thread (proc_target);
 
       infrun_debug_printf ("calling commit_resumed for target %s",
 			   proc_target->shortname());
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[relevance 4%]

* [PATCH v3 2/2] [gdb/dap] Fix stray KeyboardInterrupt after cancel
  @ 2024-02-29 13:59  4% ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-02-29 13:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

When running test-case gdb.dap/pause.exp 100 times in a loop, it passes
100/100.

But if we remove the two "sleep 0.2" from the test-case, we run into
(copied from dap.log and edited for readability):
...
Traceback (most recent call last):
  File "startup.py", line 251, in message
    def message():

KeyboardInterrupt
Quit
...

This happens as follows.

CancellationHandler.cancel calls gdb.interrupt to cancel a request in flight.

The idea is that this interrupt triggers while in fn here in message (a nested
function of send_gdb_with_response):
...
    def message():
        try:
            val = fn()
            result_q.put(val)
        except (Exception, KeyboardInterrupt) as e:
            result_q.put(e)
...
but instead it triggers outside the try/except.

Fix this by:
- in CancellationHandler, renaming variable in_flight to in_flight_dap_thread,
  and adding a variable in_flight_gdb_thread to be able to distinguish when
  a request is in flight in the dap thread or the gdb thread.
- adding a wrapper Cancellable to to deal with cancelling the wrapped
  event
- using Cancellable in send_gdb and send_gdb_with_response to wrap the posted
  event
- in CancellationHandler.cancel, only call gdb.interrupt if
  req == self.in_flight_gdb_thread.

This makes the test-case pass 100/100, also when adding the extra stressor of
"taskset -c 0", which makes the fail more likely without the patch.

Tested on aarch64-linux.

PR dap/31275
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31275
---
 gdb/python/lib/gdb/dap/server.py | 88 ++++++++++++++++++++++++--------
 gdb/testsuite/gdb.dap/pause.exp  |  4 +-
 2 files changed, 69 insertions(+), 23 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index fe1f8bbd428..cba5a308ff1 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -19,6 +19,7 @@ import heapq
 import inspect
 import json
 import threading
+from contextlib import contextmanager
 
 from .io import start_json_writer, read_json
 from .startup import (
@@ -59,24 +60,19 @@ class CancellationHandler:
         # Methods on this class acquire this lock before proceeding.
         self.lock = threading.Lock()
         # The request currently being handled, or None.
-        self.in_flight = None
+        self.in_flight_dap_thread = None
+        self.in_flight_gdb_thread = None
         self.reqs = []
 
     def starting(self, req):
-        """Call at the start of the given request.
-
-        Throws the appropriate exception if the request should be
-        immediately cancelled."""
+        """Call at the start of the given request."""
         with self.lock:
-            self.in_flight = req
-            while len(self.reqs) > 0 and self.reqs[0] <= req:
-                if heapq.heappop(self.reqs) == req:
-                    raise KeyboardInterrupt()
+            self.in_flight_dap_thread = req
 
     def done(self, req):
         """Indicate that the request is done."""
         with self.lock:
-            self.in_flight = None
+            self.in_flight_dap_thread = None
 
     def cancel(self, req):
         """Call to cancel a request.
@@ -85,7 +81,7 @@ class CancellationHandler:
         If the request is in flight, it is interrupted.
         If the request has not yet been seen, the cancellation is queued."""
         with self.lock:
-            if req == self.in_flight:
+            if req == self.in_flight_gdb_thread:
                 gdb.interrupt()
             else:
                 # We don't actually ignore the request here, but in
@@ -96,6 +92,29 @@ class CancellationHandler:
                 # to try to check for this.
                 heapq.heappush(self.reqs, req)
 
+    @contextmanager
+    def interruptable_region(self, req):
+        """Return a new context manager that sets in_flight_gdb_thread to
+        REQ."""
+        if req is None:
+            # No request is handled in the region, just execute the region.
+            yield
+            return
+        try:
+            with self.lock:
+                # If the request is cancelled, don't execute the region.
+                while len(self.reqs) > 0 and self.reqs[0] <= req:
+                    if heapq.heappop(self.reqs) == req:
+                        raise KeyboardInterrupt()
+                # Request is being handled by the gdb thread.
+                self.in_flight_gdb_thread = req
+            # Execute region.  This may be interrupted by gdb.interrupt.
+            yield
+        finally:
+            with self.lock:
+                # Request is no longer handled by the gdb thread.
+                self.in_flight_gdb_thread = None
+
 
 class Server:
     """The DAP server class."""
@@ -434,13 +453,45 @@ class Invoker(object):
         exec_and_log(self.cmd)
 
 
+class Cancellable(object):
+
+    def __init__(self, fn, result_q=None):
+        self.fn = fn
+        self.result_q = result_q
+        with _server.canceller.lock:
+            self.req = _server.canceller.in_flight_dap_thread
+
+    # This is invoked in the gdb thread to run self.fn.
+    @in_gdb_thread
+    def __call__(self):
+        try:
+            with _server.canceller.interruptable_region(self.req):
+                val = self.fn()
+                if self.result_q is not None:
+                    self.result_q.put(val)
+        except (Exception, KeyboardInterrupt) as e:
+            if self.result_q is not None:
+                # Pass result or exception to caller.
+                self.result_q.put(e)
+            elif isinstance(e, KeyboardInterrupt):
+                # Fn was cancelled.
+                pass
+            else:
+                # Exception happened.  Ignore and log it.
+                err_string = "%s, %s" % (err, type(err))
+                thread_log("caught exception: " + err_string)
+                log_stack()
+
+
 def send_gdb(cmd):
     """Send CMD to the gdb thread.
     CMD can be either a function or a string.
     If it is a string, it is passed to gdb.execute."""
     if isinstance(cmd, str):
         cmd = Invoker(cmd)
-    gdb.post_event(cmd)
+
+    # Post the event and don't wait for the result.
+    gdb.post_event(Cancellable(cmd))
 
 
 def send_gdb_with_response(fn):
@@ -452,17 +503,12 @@ def send_gdb_with_response(fn):
     """
     if isinstance(fn, str):
         fn = Invoker(fn)
-    result_q = DAPQueue()
 
-    def message():
-        try:
-            val = fn()
-            result_q.put(val)
-        except (Exception, KeyboardInterrupt) as e:
-            result_q.put(e)
-
-    send_gdb(message)
+    # Post the event and wait for the result in result_q.
+    result_q = DAPQueue()
+    gdb.post_event(Cancellable(fn, result_q))
     val = result_q.get()
+
     if isinstance(val, (Exception, KeyboardInterrupt)):
         raise val
     return val
diff --git a/gdb/testsuite/gdb.dap/pause.exp b/gdb/testsuite/gdb.dap/pause.exp
index 9038d0f037f..1271b3bf95a 100644
--- a/gdb/testsuite/gdb.dap/pause.exp
+++ b/gdb/testsuite/gdb.dap/pause.exp
@@ -119,7 +119,7 @@ set cont_id [dap_send_request evaluate \
 		      $gdbfile]]
 
 # Wait a little to try to ensure the command is running.
-sleep 0.2
+#sleep 0.2
 set cancel_id [dap_send_request cancel \
 		   [format {o requestId [i %d]} $cont_id]]
 
@@ -140,7 +140,7 @@ set cont_id [dap_send_request evaluate \
 		      $gdbfile]]
 
 # Wait a little to try to ensure the command is running.
-sleep 0.2
+#sleep 0.2
 set cancel_id [dap_send_request cancel \
 		   [format {o requestId [i %d]} $cont_id]]
 
-- 
2.35.3


^ permalink raw reply	[relevance 4%]

* Re: [PATCH] aarch64: Use aarch64_debug_printf in a few more places
  @ 2024-02-28  4:38  0% ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-02-28  4:38 UTC (permalink / raw)
  To: John Baldwin, gdb-patches



On 2024-02-27 17:20, John Baldwin wrote:
> No functional change
> ---
>  gdb/arch/aarch64-insn.c | 51 +++++++++++++++--------------------------
>  1 file changed, 19 insertions(+), 32 deletions(-)
> 
> diff --git a/gdb/arch/aarch64-insn.c b/gdb/arch/aarch64-insn.c
> index 10818757cd4..3e40a51c443 100644
> --- a/gdb/arch/aarch64-insn.c
> +++ b/gdb/arch/aarch64-insn.c
> @@ -98,13 +98,10 @@ aarch64_decode_b (CORE_ADDR addr, uint32_t insn, int *is_bl,
>        *is_bl = (insn >> 31) & 0x1;
>        *offset = sbits (insn, 0, 25) * 4;
>  
> -      if (aarch64_debug)
> -	{
> -	  debug_printf ("decode: 0x%s 0x%x %s 0x%s\n",
> -			core_addr_to_string_nz (addr), insn,
> -			*is_bl ? "bl" : "b",
> -			core_addr_to_string_nz (addr + *offset));
> -	}
> +      aarch64_debug_printf ("decode: 0x%s 0x%x %s 0x%s\n",
> +			    core_addr_to_string_nz (addr), insn,
> +			    *is_bl ? "bl" : "b",
> +			    core_addr_to_string_nz (addr + *offset));

You should remove the \n, I think, the _debug_printf functions adds one.

Otherwise, LGTM.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon

^ permalink raw reply	[relevance 0%]

* [PATCH] Rely on std::uncaught_exceptions
@ 2024-02-27 17:25  4% Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-02-27 17:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

std::uncaught_exceptions is a C++17 feature, so I think we can remove
this conditional code from inferior.h.
---
 gdb/inferior.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/gdb/inferior.h b/gdb/inferior.h
index 7be28423aeb..e8729658b38 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -86,13 +86,7 @@ struct infcall_suspend_state_deleter
 	/* If we are restoring the inferior state due to an exception,
 	   some error message will be printed.  So, only warn the user
 	   when we cannot restore during normal execution.  */
-	bool unwinding;
-#if __cpp_lib_uncaught_exceptions
-	unwinding = std::uncaught_exceptions () > 0;
-#else
-	unwinding = std::uncaught_exception ();
-#endif
-	if (!unwinding)
+	if (std::uncaught_exceptions () == 0)
 	  warning (_("Failed to restore inferior state: %s"), e.what ());
       }
   }
-- 
2.43.0


^ permalink raw reply	[relevance 4%]

* [PATCH v4 4/4] Use the .py file in gdb.dap/pause.exp
  @ 2024-02-27 14:45  6% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-02-27 14:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom de Vries

Tom de Vries pointed out that the gdb.dap/pause.exp test writes a
Python file but then does not use it.  This patch corrects the
oversight.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354
Reviewed-By: Tom de Vries <tdevries@suse.de>
---
 gdb/testsuite/gdb.dap/pause.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.dap/pause.exp b/gdb/testsuite/gdb.dap/pause.exp
index 4d13dadd3ad..9038d0f037f 100644
--- a/gdb/testsuite/gdb.dap/pause.exp
+++ b/gdb/testsuite/gdb.dap/pause.exp
@@ -134,7 +134,7 @@ dap_read_response cancel $cancel_id
 # does not continue the inferior) can be canceled.
 #
 
-write_file py "while True:\n  pass"
+set gdbfile [write_file py "while True:\n  pass"]
 set cont_id [dap_send_request evaluate \
 		 [format {o expression [s "source %s"] context [s repl]} \
 		      $gdbfile]]

-- 
2.43.0


^ permalink raw reply	[relevance 6%]

* [PUSHED] arc: Don't build arc-analyze-prologue.S with -g
  @ 2024-02-27 14:12 23% ` Shahab Vahedi
  0 siblings, 0 replies; 200+ results
From: Shahab Vahedi @ 2024-02-27 14:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Yuriy Kolerov, Shahab Vahedi

From: Yuriy Kolerov <kolerov93@gmail.com>

arc-analyze-prologue.S test does not contain debug information thus
it must be compiled without -g option. Otherwise GDB will try to
unwind frames using debug information (which does not exist for .S
code!) instead of analyzing frames manually.

Approved-By: Shahab Vahedi <shahab@synopsys.com>
---
 gdb/testsuite/gdb.arch/arc-analyze-prologue.exp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.arch/arc-analyze-prologue.exp b/gdb/testsuite/gdb.arch/arc-analyze-prologue.exp
index 32387c00169..b8d9a8fb75f 100644
--- a/gdb/testsuite/gdb.arch/arc-analyze-prologue.exp
+++ b/gdb/testsuite/gdb.arch/arc-analyze-prologue.exp
@@ -19,7 +19,13 @@ require {istarget "arc*-*-*"}
 
 standard_testfile .S
 
-if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
+# arc-analyze-prologue.S test does not contain debug information thus it must
+# be compiled without -g option. Otherwise GDB will try to unwind frames using
+# debug information (which does not exist for .S code!) instead of analyzing
+# frames manually.
+set options {}
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile $options] } {
     return -1
 }
 
-- 
2.35.8


^ permalink raw reply	[relevance 23%]

* Re: [PATCH 1/5] Rewrite final cleanups
  @ 2024-02-27 14:03  0%       ` Lancelot SIX
  0 siblings, 0 replies; 200+ results
From: Lancelot SIX @ 2024-02-27 14:03 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Mon, Feb 26, 2024 at 11:53:35AM -0700, Tom Tromey wrote:
> >>>>> "Lancelot" == Lancelot SIX <lsix@lancelotsix.com> writes:
> 
> >> tempdir_name = xstrdup (tempdir_name);
> >> -  make_final_cleanup (do_rmdir, tempdir_name);
> >> +  add_final_cleanup ([] ()
> >> +    {
> >> +      char *zap;
> >> +      int wstat;
> >> +
> >> +      gdb_assert (startswith (tempdir_name, TMP_PREFIX));
> >> +      zap = concat ("rm -rf ", tempdir_name, (char *) NULL);
> >> +      wstat = system (zap);
> >> +      if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0)
> >> +	warning (_("Could not remove temporary directory %s"), tempdir_name);
> >> +      XDELETEVEC (zap);
> 
> Lancelot> I am aware that this is orthogonal to this patch and can be address by
> Lancelot> another patch, but in the way to c++ification, this could be replaced
> Lancelot> with:
> 
> Lancelot>   std::filesystem::remove_all (tempdir_name);
> 
> Yeah, I think it's better to do this kind of thing as a separate
> cleanup.
> 
> Also I wonder if all the compilers we support ship std::filesystem.
> (I have no idea.)
> 
> >> void
> >> do_final_cleanups ()
> >> {
> >> -  do_my_cleanups (&final_cleanup_chain, SENTINEL_CLEANUP);
> >> +  for (auto &func : all_cleanups)
> >> +    func ();
> >> +  all_cleanups.clear ();
> 
> Lancelot> I am wondering if we want special handling if one of the cleanup
> Lancelot> function ever throws.  It is probably acceptable to expect callbacks to
> Lancelot> never throw (unfortunately, we can’t have use std::function<void ()
> Lancelot> noexcept> to have this in the type system).  If we accept that callbacks
> Lancelot> can throw, is it OK to skip pending cleanup functions?
> 
> We could catch and ignore exceptions here.
> I'm not sure how important this really is.  The current code has ignored
> it for decades.

My train of thought was
1) This `system ("rm -rf ...")` could be replaced with
std::filesystem::remove_all
2) At least one overload of remove_all can throw
3) What would happen if a cleanup throws (either an existing one, or one
to change/introduce in the future).

I don't think this is a critical issue in any way, just something to
consider in a C -> C++ transition.  The options I can think of are:
- let exceptions go through (some cleanup code might not get a chance to
  execute),
- catch and ignore any exception,
- catch exceptions and re-throw the first one captured after all cleanup
  code has had a chance to run.

I can see pros and cons to each of those, and I don't think I have a
strong preference either way.

FWIW, I skimmed through the rest of the series, and looks reasonable to
me.

Best,
Lancelot.

> 
> Tom

^ permalink raw reply	[relevance 0%]

* Re: [PATCH v3 5/5] Use the .py file in gdb.dap/pause.exp
  @ 2024-02-27  9:36  0%   ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-02-27  9:36 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/20/24 20:46, Tom Tromey wrote:
> Tom de Vries pointed out that the gdb.dap/pause.exp test writes a
> Python file but then does not use it.  This patch corrects the
> oversight.
> 

LGTM.

Reviewed-By: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom

> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354
> ---
>   gdb/testsuite/gdb.dap/pause.exp | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/gdb.dap/pause.exp b/gdb/testsuite/gdb.dap/pause.exp
> index 4d13dadd3ad..9038d0f037f 100644
> --- a/gdb/testsuite/gdb.dap/pause.exp
> +++ b/gdb/testsuite/gdb.dap/pause.exp
> @@ -134,7 +134,7 @@ dap_read_response cancel $cancel_id
>   # does not continue the inferior) can be canceled.
>   #
>   
> -write_file py "while True:\n  pass"
> +set gdbfile [write_file py "while True:\n  pass"]
>   set cont_id [dap_send_request evaluate \
>   		 [format {o expression [s "source %s"] context [s repl]} \
>   		      $gdbfile]]
> 


^ permalink raw reply	[relevance 0%]

* [PATCH 10/11] sim: riscv: Add double precision floating-point basic arithmetic instructions
  @ 2024-02-26 14:28 23% ` bhushan.attarde
  0 siblings, 0 replies; 200+ results
From: bhushan.attarde @ 2024-02-26 14:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: aburgess, vapier, Jaydeep.Patil, Bhushan Attarde

From: Bhushan Attarde <bhushan.attarde@imgtec.com>

Added simulation of following single precision floating-point instructions
fadd.d, fsub.d, fmul.d, fdiv.d and fsqrt.d.

Update test file sim/testsuite/riscv/d-basic-arith.s to test these instructions.
---
 sim/riscv/sim-main.c                | 45 ++++++++++++++++++++++++++
 sim/testsuite/riscv/d-basic-arith.s | 50 +++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)

diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
index 4a102df74e0..e715ca2501e 100644
--- a/sim/riscv/sim-main.c
+++ b/sim/riscv/sim-main.c
@@ -1421,6 +1421,31 @@ float64_math (SIM_CPU *cpu, int rd, int rs1, int rs2, int rs3, int rm,
 		  frd_name, frs1_name, frs2_name, frs3_name, rm);
       result = -((a * b) + c);
       break;
+    case FADD:
+      TRACE_INSN (cpu, "fadd.d %s, %s, %s, rm=%d;",
+		  frd_name, frs1_name, frs2_name, rm);
+      result = a + b;
+      break;
+    case FSUB:
+      TRACE_INSN (cpu, "fsub.d %s, %s, %s, rm=%d;",
+		  frd_name, frs1_name, frs2_name, rm);
+      result = a - b;
+      break;
+    case FMUL:
+      TRACE_INSN (cpu, "fmul.d %s, %s, %s, rm=%d;",
+	frd_name, frs1_name, frs2_name, rm);
+      result = a * b;
+      break;
+    case FDIV:
+      TRACE_INSN (cpu, "fdiv.d %s, %s, %s, rm=%d;",
+		  frd_name, frs1_name, frs2_name, rm);
+      result = a / b;
+      break;
+    case FSQRT:
+      TRACE_INSN (cpu, "fsqrt.d %s, %s, rm=%d;",
+		  frd_name, frs1_name, rm);
+      result = sqrtf (a);
+      break;
     }
 
   if (rm == RMM)
@@ -1840,6 +1865,26 @@ execute_d (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
     case MATCH_FNMSUB_D | MASK_RM:
       float64_math (cpu, rd, rs1, rs2, rs3, rm, FNMSUB);
       break;
+    case MATCH_FADD_D:
+    case MATCH_FADD_D | MASK_RM:
+      float64_math (cpu, rd, rs1, rs2, 0, rm, FADD);
+      break;
+    case MATCH_FSUB_D:
+    case MATCH_FSUB_D | MASK_RM:
+      float64_math (cpu, rd, rs1, rs2, 0, rm, FSUB);
+      break;
+    case MATCH_FMUL_D:
+    case MATCH_FMUL_D | MASK_RM:
+      float64_math (cpu, rd, rs1, rs2, 0, rm, FMUL);
+      break;
+    case MATCH_FDIV_D:
+    case MATCH_FDIV_D | MASK_RM:
+      float64_math (cpu, rd, rs1, rs2, 0, rm, FDIV);
+      break;
+    case MATCH_FSQRT_D:
+    case MATCH_FSQRT_D | MASK_RM:
+      float64_math (cpu, rd, rs1, rs2, 0, rm, FSQRT);
+      break;
     default:
       TRACE_INSN (cpu, "UNHANDLED INSN: %s", op->name);
       sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc, sim_signalled, SIM_SIGILL);
diff --git a/sim/testsuite/riscv/d-basic-arith.s b/sim/testsuite/riscv/d-basic-arith.s
index 996f603e91d..2f529c68f47 100644
--- a/sim/testsuite/riscv/d-basic-arith.s
+++ b/sim/testsuite/riscv/d-basic-arith.s
@@ -11,9 +11,16 @@
 
 _arg1:
 	.double -12.5
+	.double 1.5
+	.double 2.2
+	.double 18.5
+	.double 5.0
 
 _arg2:
 	.double 2.5
+	.double 0.5
+	.double 1.1
+	.double 0.1
 
 _arg3:
 	.double 7.45
@@ -23,6 +30,11 @@ _result:
 	.double 38.7000008
 	.double -38.7000008
 	.double 23.7999992
+	.double 2.0
+	.double 1.1
+	.double 1.85
+	.double 185
+	.double 2.2360680103302002
 
 	start
 	.option push
@@ -70,6 +82,44 @@ _result:
 	feq.d	a5,fa4,fa4
 	bne	a5,a4,test_fail
 
+	# Test fadd instruction.
+	fld	fa0,8(a0)
+	fld	fa1,8(a1)
+	fld	fa2,32(a3)
+	fadd.d	fa4,fa0,fa1,rne
+	feq.d	a5,fa4,fa2
+	bne	a5,a4,test_fail
+
+	# Test fsub instruction.
+	fld	fa0,16(a0)
+	fld	fa1,16(a1)
+	fld	fa2,40(a3)
+	fsub.d	fa4,fa0,fa1,rne
+	feq.d	a5,fa4,fa2
+	bne	a5,a4,test_fail
+
+	# Test fmul instruction.
+	fld	fa0,24(a0)
+	fld	fa1,24(a1)
+	fld	fa2,48(a3)
+	fmul.d	fa4,fa0,fa1,rne
+	feq.d	a5,fa4,fa2
+	bne	a5,a4,test_fail
+
+	# Test fdiv instruction.
+	fld	fa0,24(a0)	# Use same input values as of fmul
+	fld	fa1,24(a1)
+	fld	fa2,56(a3)
+	fdiv.d	fa4,fa0,fa1,rne
+	feq.d	a5,fa4,fa2
+	bne	a5,a4,test_fail
+
+	# Test fsqrt instruction.
+	fld	fa0,32(a0)
+	fld	fa2,64(a3)
+	fsqrt.d	fa4,fa0,rne
+	feq.d	a5,fa4,fa2
+	bne	a5,a4,test_fail
 
 test_pass:
 	pass
-- 
2.25.1


^ permalink raw reply	[relevance 23%]

* [PATCH 05/11] sim: riscv: Add single precision floating-point basic arithmetic instructions
  @ 2024-02-26 14:26 29% ` bhushan.attarde
  0 siblings, 0 replies; 200+ results
From: bhushan.attarde @ 2024-02-26 14:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: aburgess, vapier, Jaydeep.Patil, Bhushan Attarde

From: Bhushan Attarde <bhushan.attarde@imgtec.com>

Added simulation of following single precision floating-point instructions
fadd.s, fsub.s, fmul.s, fdiv.s and fsqrt.s.

Updated test file sim/testsuite/riscv/s-basic-arith.s to test these
instructions.
---
 sim/riscv/sim-main.c                | 50 ++++++++++++++++++++++++++++
 sim/testsuite/riscv/s-basic-arith.s | 51 +++++++++++++++++++++++++++++
 2 files changed, 101 insertions(+)

diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
index dd91431ad12..5d8ff9dc6ee 100644
--- a/sim/riscv/sim-main.c
+++ b/sim/riscv/sim-main.c
@@ -91,6 +91,11 @@ static const struct riscv_opcode *riscv_hash[OP_MASK_OP + 1];
 #define FMSUB	8
 #define FNMADD	9
 #define FNMSUB	10
+#define FADD	11
+#define FSUB	12
+#define FMUL	13
+#define FDIV	14
+#define FSQRT	15
 
 static INLINE void
 store_rd (SIM_CPU *cpu, int rd, unsigned_word val)
@@ -942,6 +947,31 @@ float32_math (SIM_CPU *cpu, int rd, int rs1, int rs2,
       TRACE_INSN (cpu, "fmin.s %s, %s, %s;", frd_name, frs1_name, frs2_name);
       result = fminf (a, b);
       break;
+    case FADD:
+      TRACE_INSN (cpu, "fadd.s %s, %s, %s, rm=%d;",
+		  frd_name, frs1_name, frs2_name, rm);
+      result = a + b;
+      break;
+    case FSUB:
+      TRACE_INSN (cpu, "fsub.s %s, %s, %s, rm=%d;",
+		  frd_name, frs1_name, frs2_name, rm);
+      result = a - b;
+      break;
+    case FMUL:
+      TRACE_INSN (cpu, "fmul.s %s, %s, %s, rm=%d;",
+	frd_name, frs1_name, frs2_name, rm);
+      result = a * b;
+      break;
+    case FDIV:
+      TRACE_INSN (cpu, "fdiv.s %s, %s, %s, rm=%d;",
+		  frd_name, frs1_name, frs2_name, rm);
+      result = a / b;
+      break;
+    case FSQRT:
+      TRACE_INSN (cpu, "fsqrt.s %s, %s, rm=%d;",
+		  frd_name, frs1_name, rm);
+      result = sqrtf (a);
+      break;
     }
 
   if (rm == RMM)
@@ -1173,6 +1203,26 @@ execute_f (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
     case MATCH_FNMSUB_S | MASK_RM:
       float32_math (cpu, rd, rs1, rs2, rs3, rm, FNMSUB);
       break;
+    case MATCH_FADD_S:
+    case MATCH_FADD_S | MASK_RM:
+      float32_math (cpu, rd, rs1, rs2, rs3, rm, FADD);
+      break;
+    case MATCH_FSUB_S:
+    case MATCH_FSUB_S | MASK_RM:
+      float32_math (cpu, rd, rs1, rs2, rs3, rm, FSUB);
+      break;
+    case MATCH_FMUL_S:
+    case MATCH_FMUL_S | MASK_RM:
+      float32_math (cpu, rd, rs1, rs2, rs3, rm, FMUL);
+      break;
+    case MATCH_FDIV_S:
+    case MATCH_FDIV_S | MASK_RM:
+      float32_math (cpu, rd, rs1, rs2, rs3, rm, FDIV);
+      break;
+    case MATCH_FSQRT_S:
+    case MATCH_FSQRT_S | MASK_RM:
+      float32_math (cpu, rd, rs1, rs2, rs3, rm, FSQRT);
+      break;
     default:
       TRACE_INSN (cpu, "UNHANDLED INSN: %s", op->name);
       sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc, sim_signalled, SIM_SIGILL);
diff --git a/sim/testsuite/riscv/s-basic-arith.s b/sim/testsuite/riscv/s-basic-arith.s
index a05a0d0a2c3..15d07f9e6cd 100644
--- a/sim/testsuite/riscv/s-basic-arith.s
+++ b/sim/testsuite/riscv/s-basic-arith.s
@@ -14,9 +14,16 @@
 
 _arg1:
 	.float -12.5
+	.float 1.5
+	.float 2.2
+	.float 1.75
+	.float 5.0
 
 _arg2:
 	.float 2.5
+	.float 0.5
+	.float 1.1
+	.float 0.1
 
 _arg3:
 	.float 7.45
@@ -26,6 +33,11 @@ _result:
 	.float 38.7000008
 	.float -38.7000008
 	.float 23.7999992
+	.float 2.0
+	.float 1.1
+	.float 0.175
+	.float 17.5
+	.float 2.23606801
 
 	start
 	.option push
@@ -73,6 +85,45 @@ _result:
 	feq.s	a5,fa4,fa4
 	bne	a5,a4,test_fail
 
+	# Test fadd instruction.
+	flw	fa0,4(a0)
+	flw	fa1,4(a1)
+	flw	fa2,16(a3)
+	fadd.s	fa4,fa0,fa1,rne
+	feq.s	a5,fa4,fa2
+	bne	a5,a4,test_fail
+
+	# Test fsub instruction.
+	flw	fa0,8(a0)
+	flw	fa1,8(a1)
+	flw	fa2,20(a3)
+	fsub.s	fa4,fa0,fa1,rne
+	feq.s	a5,fa4,fa2
+	bne	a5,a4,test_fail
+
+	# Test fmul instruction.
+	flw	fa0,12(a0)
+	flw	fa1,12(a1)
+	flw	fa2,24(a3)
+	fmul.s	fa4,fa0,fa1,rne
+	feq.s	a5,fa4,fa2
+	bne	a5,a4,test_fail
+
+	# Test fdiv instruction.
+	flw	fa0,12(a0)	# Use same input values as of fmul
+	flw	fa1,12(a1)
+	flw	fa2,28(a3)
+	fdiv.s	fa4,fa0,fa1,rne
+	feq.s	a5,fa4,fa2
+	bne	a5,a4,test_fail
+
+	# Test fsqrt instruction.
+	flw	fa0,16(a0)
+	flw	fa2,32(a3)
+	fsqrt.s	fa4,fa0,rne
+	feq.s	a5,fa4,fa2
+	bne	a5,a4,test_fail
+
 test_pass:
 	pass
 
-- 
2.25.1


^ permalink raw reply	[relevance 29%]

* [PATCH v2 2/2] [gdb/dap] Fix stray KeyboardInterrupt after cancel
  @ 2024-02-26 11:58  4% ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-02-26 11:58 UTC (permalink / raw)
  To: gdb-patches

When running test-case gdb.dap/pause.exp 100 times in a loop, it passes
100/100.

But if we remove the two "sleep 0.2" from the test-case, we run into
(copied from dap.log and edited for readability):
...
Traceback (most recent call last):
  File "startup.py", line 251, in message
    def message():

KeyboardInterrupt
Quit
...

This happens as follows.

CancellationHandler.cancel calls gdb.interrupt to cancel a request in flight.

The idea is that this interrupt triggers while in fn here in message (a nested
function of send_gdb_with_response):
...
    def message():
        try:
            val = fn()
            result_q.put(val)
        except (Exception, KeyboardInterrupt) as e:
            result_q.put(e)
...
but instead it triggers outside the try/except.

Fix this by:
- in CancellationHandler, renaming variable in_flight to in_flight_dap_thread,
  and adding a variable in_flight_gdb_thread to be able to distinguish when
  a request is in flight in the dap thread or the gdb thread.
- adding a wrapper Cancellable to to deal with cancelling the wrapped
  event
- using Cancellable in send_gdb and send_gdb_with_response to wrap the posted
  event
- in CancellationHandler.cancel, only call gdb.interrupt if
  req == self.in_flight_gdb_thread.

This makes the test-case pass 100/100, also when adding the extra stressor of
"taskset -c 0", which makes the fail more likely without the patch.

Tested on aarch64-linux.

PR dap/31275
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31275
---
 gdb/python/lib/gdb/dap/server.py | 88 ++++++++++++++++++++++++--------
 1 file changed, 67 insertions(+), 21 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index e957b886fb8..59f486f5729 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -19,6 +19,7 @@ import heapq
 import inspect
 import json
 import threading
+from contextlib import contextmanager
 
 from .io import start_json_writer, read_json
 from .startup import (
@@ -59,24 +60,19 @@ class CancellationHandler:
         # Methods on this class acquire this lock before proceeding.
         self.lock = threading.Lock()
         # The request currently being handled, or None.
-        self.in_flight = None
+        self.in_flight_dap_thread = None
+        self.in_flight_gdb_thread = None
         self.reqs = []
 
     def starting(self, req):
-        """Call at the start of the given request.
-
-        Throws the appropriate exception if the request should be
-        immediately cancelled."""
+        """Call at the start of the given request."""
         with self.lock:
-            self.in_flight = req
-            while len(self.reqs) > 0 and self.reqs[0] <= req:
-                if heapq.heappop(self.reqs) == req:
-                    raise KeyboardInterrupt()
+            self.in_flight_dap_thread = req
 
     def done(self, req):
         """Indicate that the request is done."""
         with self.lock:
-            self.in_flight = None
+            self.in_flight_dap_thread = None
 
     def cancel(self, req):
         """Call to cancel a request.
@@ -85,7 +81,7 @@ class CancellationHandler:
         If the request is in flight, it is interrupted.
         If the request has not yet been seen, the cancellation is queued."""
         with self.lock:
-            if req == self.in_flight:
+            if req == self.in_flight_gdb_thread:
                 gdb.interrupt()
             else:
                 # We don't actually ignore the request here, but in
@@ -96,6 +92,29 @@ class CancellationHandler:
                 # to try to check for this.
                 heapq.heappush(self.reqs, req)
 
+    @contextmanager
+    def interruptable_region(self, req):
+        """Return a new context manager that sets in_flight_gdb_thread to
+        REQ."""
+        if req is None:
+            # No request is handled in the region, just execute the region.
+            yield None
+            return
+        with self.lock:
+            # If the request is cancelled, don't execute the region.
+            while len(self.reqs) > 0 and self.reqs[0] <= req:
+                if heapq.heappop(self.reqs) == req:
+                    raise KeyboardInterrupt()
+            # Request is being handled by the gdb thread.
+            self.in_flight_gdb_thread = req
+        try:
+            # Execute region.  This may be interrupted by gdb.interrupt.
+            yield None
+        finally:
+            # Request has been handled by the gdb thread,
+            with self.lock:
+                self.in_flight_gdb_thread = None
+
 
 class Server:
     """The DAP server class."""
@@ -433,13 +452,45 @@ class Invoker(object):
         exec_and_log(self.cmd)
 
 
+class Cancellable(object):
+
+    def __init__(self, fn, result_q=None):
+        self.fn = fn
+        self.result_q = result_q
+        with _server.canceller.lock:
+            self.req = _server.canceller.in_flight_dap_thread
+
+    # This is invoked in the gdb thread to run self.fn.
+    @in_gdb_thread
+    def __call__(self):
+        try:
+            with _server.canceller.interruptable_region(self.req):
+                val = self.fn()
+                if self.result_q is not None:
+                    self.result_q.put(val)
+        except (Exception, KeyboardInterrupt) as e:
+            if self.result_q is not None:
+                # Pass result or exception to caller.
+                self.result_q.put(e)
+            elif isinstance(e, KeyboardInterrupt):
+                # Fn was cancelled.
+                pass
+            else:
+                # Exception happened.  Ignore and log it.
+                err_string = "%s, %s" % (err, type(err))
+                thread_log("caught exception: " + err_string)
+                log_stack()
+
+
 def send_gdb(cmd):
     """Send CMD to the gdb thread.
     CMD can be either a function or a string.
     If it is a string, it is passed to gdb.execute."""
     if isinstance(cmd, str):
         cmd = Invoker(cmd)
-    gdb.post_event(cmd)
+
+    # Post the event and don't wait for the result.
+    gdb.post_event(Cancellable(cmd))
 
 
 def send_gdb_with_response(fn):
@@ -451,17 +502,12 @@ def send_gdb_with_response(fn):
     """
     if isinstance(fn, str):
         fn = Invoker(fn)
-    result_q = DAPQueue()
-
-    def message():
-        try:
-            val = fn()
-            result_q.put(val)
-        except (Exception, KeyboardInterrupt) as e:
-            result_q.put(e)
 
-    send_gdb(message)
+    # Post the event and wait for the result in result_q.
+    result_q = DAPQueue()
+    gdb.post_event(Cancellable(fn, result_q))
     val = result_q.get()
+
     if isinstance(val, (Exception, KeyboardInterrupt)):
         raise val
     return val
-- 
2.35.3


^ permalink raw reply	[relevance 4%]

* [PATCH v2] Port GDB to Hurd x86_64.
  @ 2024-02-24  5:28  2% ` Flavio Cruz
  0 siblings, 0 replies; 200+ results
From: Flavio Cruz @ 2024-02-24  5:28 UTC (permalink / raw)
  To: gdb-patches, jhb; +Cc: bug-hurd, samuel.thibault, simark, Flavio Cruz

This port extends the existing i686 port to support x86_64 by trying to
reuse existing code whenever it makes sense.

* gdb/amd64-gnu-tdep.c: Adds logic for handling signal frames and
  position of amd64 registers in the different Hurd structs.
  The signal code is very similar to i686, except the trampoline code
  is adapted.
* gdb/config/i386/nm-i386gnu.h: renamed to gdb/config/i386/nm-x86-gnu.h
  and adapt it for x86_64.
* gdb/config/i386/i386gnu.mn: renamed to gdb/config/i386/nm-x86-gnu.mn
  and reuse it for x86_64.
* gdb/configure.host: recognize gnu64 as a host.
* gdb/configure.nat: recognize gnu64 host and update existing i386gnu to
  reuse the new shared files.
* gdb/configure.tgt: recognize x86_64-*-gnu* triplet and use
  amd64-gnu-tdep.c.
* gdb/i386-gnu-tdep.c: added i386_gnu_thread_state_reg_offset that is
  copied from i386-gnu-nat.c. This makes it similar to amd64.
* gdb/i386-gnu-nat.c: rename it to x86-gnu-nat.c since we reuse this for
  i386 and amd64. Updated REG_ADDR to use one of the structures. Added
  VALID_REGISTER to make sure it's a register we can provide at this time
  (not all of them are available in amd64). FLAGS_REGISTER is either rfl
  or efl depending on the arch. Renamed functions and class from i386 to x86
  whenever they can be reused.

Tested on Hurd x86_64 and i686.
---

I addressed John's comments and moved amd64_gnu_thread_state_* and
i386_gnu_thread_state_* to x86-gnu-nat.c. The new patch also contains a few
changes that makes backtracing through shared libraries work.


 gdb/amd64-gnu-tdep.c                          | 230 ++++++++++++++++++
 .../i386/{nm-i386gnu.h => nm-x86-gnu.h}       |   7 +
 gdb/config/i386/{i386gnu.mn => x86-gnu.mn}    |   0
 gdb/configure.host                            |   1 +
 gdb/configure.nat                             |  27 +-
 gdb/configure.tgt                             |   6 +-
 gdb/i386-gnu-tdep.c                           |  13 +-
 gdb/{i386-gnu-nat.c => x86-gnu-nat.c}         | 171 +++++++++----
 8 files changed, 399 insertions(+), 56 deletions(-)
 create mode 100644 gdb/amd64-gnu-tdep.c
 rename gdb/config/i386/{nm-i386gnu.h => nm-x86-gnu.h} (83%)
 rename gdb/config/i386/{i386gnu.mn => x86-gnu.mn} (100%)
 rename gdb/{i386-gnu-nat.c => x86-gnu-nat.c} (69%)

diff --git a/gdb/amd64-gnu-tdep.c b/gdb/amd64-gnu-tdep.c
new file mode 100644
index 00000000000..0776ec70dd7
--- /dev/null
+++ b/gdb/amd64-gnu-tdep.c
@@ -0,0 +1,230 @@
+/* Target-dependent code for the GNU Hurd.
+   Copyright (C) 2024 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "defs.h"
+#include "gdbcore.h"
+#include "osabi.h"
+#include "solib-svr4.h"
+
+#include "amd64-tdep.h"
+#include "glibc-tdep.h"
+
+/* Recognizing signal handler frames.  */
+
+/* When the GNU/Hurd libc calls a signal handler, the return address points
+   inside the trampoline assembly snippet.
+
+   If the trampoline function name can not be identified, we resort to reading
+   memory from the process in order to identify it.  */
+
+static const gdb_byte gnu_sigtramp_code[] =
+{
+/* rpc_wait_trampoline: */
+  0x48, 0xc7, 0xc0, 0xe7, 0xff, 0xff, 0xff,	/* mov    $-25,%rax */
+  0x0f, 0x05,					/* syscall */
+  0x49, 0x89, 0x04, 0x24,			/* mov    %rax,(%r12) */
+  0x48, 0x89, 0xdc,				/* mov    %rbx,%rsp */
+
+/* trampoline: */
+  0x5f,			                        /* pop    %rdi */
+  0x5e,						/* pop    %rsi */
+  0x5a,						/* pop    %rdx */
+  0x48, 0x83, 0xc4, 0x08,			/* add    $0x8,%rsp */
+  0x41, 0xff, 0xd5,				/* call   *%r13 */
+
+/* RA HERE */
+  0x48, 0x8b, 0x7c, 0x24, 0x10,			/* mov    0x10(%rsp),%rdi */
+  0xc3,						/* ret */
+
+/* firewall: */
+  0xf4,						/* hlt */
+};
+
+#define GNU_SIGTRAMP_LEN (sizeof gnu_sigtramp_code)
+#define GNU_SIGTRAMP_TAIL 7			/* length of tail after RA */
+
+/* If THIS_FRAME is a sigtramp routine, return the address of the
+   start of the routine.  Otherwise, return 0.  */
+
+static CORE_ADDR
+amd64_gnu_sigtramp_start (frame_info_ptr this_frame)
+{
+  CORE_ADDR pc = get_frame_pc (this_frame);
+  gdb_byte buf[GNU_SIGTRAMP_LEN];
+
+  if (!safe_frame_unwind_memory (this_frame,
+				 pc + GNU_SIGTRAMP_TAIL - GNU_SIGTRAMP_LEN,
+				 buf))
+    return 0;
+
+  if (memcmp (buf, gnu_sigtramp_code, GNU_SIGTRAMP_LEN) != 0)
+    return 0;
+
+  return pc;
+}
+
+/* Return whether THIS_FRAME corresponds to a Hurd sigtramp routine.  */
+
+static int
+amd64_gnu_sigtramp_p (frame_info_ptr this_frame)
+{
+  CORE_ADDR pc = get_frame_pc (this_frame);
+  const char *name;
+
+  find_pc_partial_function (pc, &name, NULL, NULL);
+
+  /* If we have a NAME, we can check for the trampoline function */
+  if (name != NULL && strcmp (name, "trampoline") == 0)
+    return 1;
+
+  return amd64_gnu_sigtramp_start (this_frame) != 0;
+}
+
+/* Offset to sc_i386_thread_state in sigcontext, from <bits/sigcontext.h>.  */
+#define AMD64_GNU_SIGCONTEXT_THREAD_STATE_OFFSET 32
+
+/* Assuming THIS_FRAME is a Hurd sigtramp routine, return the
+   address of the associated sigcontext structure.  */
+
+static CORE_ADDR
+amd64_gnu_sigcontext_addr (frame_info_ptr this_frame)
+{
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  CORE_ADDR pc;
+  CORE_ADDR sp;
+  gdb_byte buf[8];
+
+  get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
+  sp = extract_unsigned_integer (buf, 8, byte_order);
+
+  pc = amd64_gnu_sigtramp_start (this_frame);
+  if (pc)
+    {
+      CORE_ADDR sigcontext_addr;
+
+      /* The sigcontext structure address is passed as the third argument
+       * of the signal handler but %RDX is not saved across calls. Luckily,
+       * the structured is saved underneath the &__sigreturn and a dummy word
+       * to fill the slot for the address for __sigreturn to return to.
+       */
+      read_memory (sp + 16, buf, 8);
+      sigcontext_addr = extract_unsigned_integer (buf, 8, byte_order);
+      return sigcontext_addr + AMD64_GNU_SIGCONTEXT_THREAD_STATE_OFFSET;
+    }
+
+  error (_("Couldn't recognize signal trampoline."));
+  return 0;
+}
+
+/* Mapping between the general-purpose registers in `struct
+   sigcontext' format (starting at sc_i386_thread_state)
+   and GDB's register cache layout.  */
+
+/* From <bits/sigcontext.h>.  */
+static int amd64_gnu_sc_reg_offset[] =
+{
+  15 * 8,			/* %rax */
+  12 * 8,			/* %rbx */
+  14 * 8,			/* %rcx */
+  13 * 8,			/* %rdx */
+  10 * 8,			/* %rsi */
+  9 * 8,			/* %rdi */
+  10 * 8,			/* %rbp */
+  11 * 8,			/* %rsp */
+  0 * 8,			/* %r8 ...  */
+  8 * 8,
+  7 * 8,
+  6 * 8,
+  3 * 8,
+  2 * 8,
+  1 * 8,
+  0 * 8,			/* ... %r15 */
+  16 * 8,			/* %rip */
+  18 * 8,			/* %eflags */
+  17 * 8,			/* %cs */
+};
+
+/* From <sys/ucontext.h>.  */
+static int amd64_gnu_gregset_reg_offset[] =
+{
+  10 * 8,			/* %rax */
+  5 * 8,			/* %rbx */
+  11 * 8,			/* %rcx */
+  12 * 8,			/* %rdx */
+  13 * 8,			/* %rsi */
+  14 * 8,			/* %rdi */
+  4 * 8,			/* %rbp */
+  19 * 8,			/* %rsp */
+  9 * 8,			/* %r8 ...  */
+  8 * 8,
+  7 * 8,
+  6 * 8,
+  3 * 8,
+  2 * 8,
+  1 * 8,
+  0 * 8,			/* ... %r15 */
+  16 * 8,			/* %rip */
+  18 * 8,			/* %eflags */
+  17 * 8,			/* %cs */
+  -1,				  /* %ss */
+  -1,				  /* %ds */
+  -1,				  /* %es */
+  -1,				  /* %fs */
+  -1,				  /* %gs */
+};
+
+static void
+amd64_gnu_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+
+  amd64_init_abi (info, gdbarch,
+      amd64_target_description (X86_XSTATE_SSE_MASK, true));
+
+  /* Enable TLS support.  */
+  set_gdbarch_fetch_tls_load_module_address (gdbarch,
+      svr4_fetch_objfile_link_map);
+
+  /* Hurd uses SVR4-style shared libraries.  */
+  set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
+
+  /* Hurd uses the dynamic linker included in the GNU C Library.  */
+  set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
+
+  tdep->gregset_reg_offset = amd64_gnu_gregset_reg_offset;
+  tdep->gregset_num_regs = ARRAY_SIZE (amd64_gnu_gregset_reg_offset);
+  tdep->sizeof_gregset = 21 * 8; /* sizeof (struct i386_thread_state); */
+
+  tdep->sigtramp_p = amd64_gnu_sigtramp_p;
+  tdep->sigcontext_addr = amd64_gnu_sigcontext_addr;
+  tdep->sc_reg_offset = amd64_gnu_sc_reg_offset;
+  tdep->sc_num_regs = ARRAY_SIZE (amd64_gnu_sc_reg_offset);
+
+  /* Hurd uses SVR4-style shared libraries.  */
+  set_solib_svr4_fetch_link_map_offsets
+    (gdbarch, svr4_lp64_fetch_link_map_offsets);
+}
+
+void _initialize_amd64_gnu_tdep ();
+void
+_initialize_amd64_gnu_tdep ()
+{
+  gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
+			  GDB_OSABI_HURD, amd64_gnu_init_abi);
+}
diff --git a/gdb/config/i386/nm-i386gnu.h b/gdb/config/i386/nm-x86-gnu.h
similarity index 83%
rename from gdb/config/i386/nm-i386gnu.h
rename to gdb/config/i386/nm-x86-gnu.h
index d2d5de83948..ed4d1729227 100644
--- a/gdb/config/i386/nm-i386gnu.h
+++ b/gdb/config/i386/nm-x86-gnu.h
@@ -22,9 +22,16 @@
 /* Thread flavors used in re-setting the T bit.  */
 #define THREAD_STATE_FLAVOR		i386_REGS_SEGS_STATE
 #define THREAD_STATE_SIZE		i386_THREAD_STATE_COUNT
+#ifdef __x86_64__
+#define THREAD_STATE_SET_TRACED(state) \
+	((struct i386_thread_state *) (state))->rfl |= 0x100
+#define THREAD_STATE_CLEAR_TRACED(state) \
+	((((struct i386_thread_state *) (state))->rfl &= ~0x100), 1)
+#else
 #define THREAD_STATE_SET_TRACED(state) \
   	((struct i386_thread_state *) (state))->efl |= 0x100
 #define THREAD_STATE_CLEAR_TRACED(state) \
   	((((struct i386_thread_state *) (state))->efl &= ~0x100), 1)
+#endif /* __x86_64__ */
 
 #endif /* CONFIG_I386_NM_I386GNU_H */
diff --git a/gdb/config/i386/i386gnu.mn b/gdb/config/i386/x86-gnu.mn
similarity index 100%
rename from gdb/config/i386/i386gnu.mn
rename to gdb/config/i386/x86-gnu.mn
diff --git a/gdb/configure.host b/gdb/configure.host
index da71675b201..999af8e59ae 100644
--- a/gdb/configure.host
+++ b/gdb/configure.host
@@ -184,6 +184,7 @@ x86_64-*-mingw*)        gdb_host=mingw64
 			gdb_host_obs=mingw-hdep.o
 			;;
 x86_64-*-cygwin*)	gdb_host=cygwin64 ;;
+x86_64-*-gnu*)		gdb_host=gnu64 ;;
 m32r*-*-linux*)          gdb_host=linux ;;
 
 xtensa*-*-linux*)	gdb_host=linux ;;
diff --git a/gdb/configure.nat b/gdb/configure.nat
index 8b98511cef7..ef404fb791a 100644
--- a/gdb/configure.nat
+++ b/gdb/configure.nat
@@ -211,23 +211,44 @@ case ${gdb_host} in
 		;;
 	esac
 	;;
+    gnu64)
+	case ${gdb_host_cpu} in
+	    i386)
+		# Host: x86_64 running the GNU Hurd
+		NATDEPFILES='x86-gnu-nat.o gnu-nat.o \
+		     x86-nat.o nat/x86-dregs.o nat/x86-xstate.o \
+		     amd64-nat.o fork-child.o \
+		     nat/fork-inferior.o \
+		     notify_S.o process_reply_S.o msg_reply_S.o \
+		     msg_U.o exc_request_U.o exc_request_S.o'
+		HAVE_NATIVE_GCORE_HOST=1
+
+		NAT_FILE='nm-x86-gnu.h'
+		MH_CFLAGS='-D_GNU_SOURCE'
+
+		XM_CLIBS='-lshouldbeinlibc'
+
+		nat_makefile_frag="${srcdir}/config/${gdb_host_cpu}/x86-gnu.mn"
+		;;
+	esac
+	;;
     i386gnu)
 	case ${gdb_host_cpu} in
 	    i386)
 		# Host: Intel 386 running the GNU Hurd
-		NATDEPFILES='i386-gnu-nat.o gnu-nat.o \
+		NATDEPFILES='x86-gnu-nat.o gnu-nat.o \
 		     x86-nat.o nat/x86-dregs.o fork-child.o \
 		     nat/fork-inferior.o \
 		     notify_S.o process_reply_S.o msg_reply_S.o \
 		     msg_U.o exc_request_U.o exc_request_S.o'
 		HAVE_NATIVE_GCORE_HOST=1
 
-		NAT_FILE='nm-i386gnu.h'
+		NAT_FILE='nm-x86-gnu.h'
 		MH_CFLAGS='-D_GNU_SOURCE'
 
 		XM_CLIBS='-lshouldbeinlibc'
 
-		nat_makefile_frag="${srcdir}/config/${gdb_host_cpu}/i386gnu.mn"
+		nat_makefile_frag="${srcdir}/config/${gdb_host_cpu}/x86-gnu.mn"
 		;;
 	esac
 	;;
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 47a674201f9..df9e9917ad1 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -328,7 +328,7 @@ i[34567]86-*-linux*)
 	;;
 i[34567]86-*-gnu*)
 	# Target: Intel 386 running the GNU Hurd
-	gdb_target_obs="i386-gnu-tdep.o solib-svr4.o"
+	gdb_target_obs="i386-gnu-tdep.o glibc-tdep.o solib-svr4.o"
 	;;
 i[34567]86-*-cygwin*)
 	# Target: Intel 386 running win32
@@ -744,6 +744,10 @@ x86_64-*-openbsd*)
 x86_64-*-rtems*)
 	gdb_target_obs="${amd64_tobjs} ${i386_tobjs} i386-bsd-tdep.o"
 	;;
+x86_64-*-gnu*)
+	# Target: x86_64 running the GNU Hurd
+	gdb_target_obs="amd64-gnu-tdep.o glibc-tdep.o solib-svr4.o"
+	;;
 xtensa*-*-*linux*)
 	# Target: GNU/Linux Xtensa
 	gdb_target_obs="xtensa-linux-tdep.o symfile-mem.o linux-tdep.o"
diff --git a/gdb/i386-gnu-tdep.c b/gdb/i386-gnu-tdep.c
index 9ff47147513..b94e23670de 100644
--- a/gdb/i386-gnu-tdep.c
+++ b/gdb/i386-gnu-tdep.c
@@ -21,6 +21,7 @@
 #include "osabi.h"
 #include "solib-svr4.h"
 
+#include "glibc-tdep.h"
 #include "i386-tdep.h"
 
 /* Recognizing signal handler frames.  */
@@ -72,8 +73,7 @@ i386_gnu_sigtramp_start (frame_info_ptr this_frame)
   return pc;
 }
 
-/* Return whether THIS_FRAME corresponds to a GNU/Linux sigtramp
-   routine.  */
+/* Return whether THIS_FRAME corresponds to a Hurd sigtramp routine.  */
 
 static int
 i386_gnu_sigtramp_p (frame_info_ptr this_frame)
@@ -178,9 +178,18 @@ i386gnu_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* GNU uses ELF.  */
   i386_elf_init_abi (info, gdbarch);
 
+  /* Hurd uses SVR4-style shared libraries.  */
+  set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
 
+  /* Hurd uses the dynamic linker included in the GNU C Library.  */
+  set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
+
+  /* Enable TLS support.  */
+  set_gdbarch_fetch_tls_load_module_address (gdbarch,
+					     svr4_fetch_objfile_link_map);
+
   tdep->gregset_reg_offset = i386gnu_gregset_reg_offset;
   tdep->gregset_num_regs = ARRAY_SIZE (i386gnu_gregset_reg_offset);
   tdep->sizeof_gregset = 19 * 4;
diff --git a/gdb/i386-gnu-nat.c b/gdb/x86-gnu-nat.c
similarity index 69%
rename from gdb/i386-gnu-nat.c
rename to gdb/x86-gnu-nat.c
index 0b0759179aa..15a92fbdb39 100644
--- a/gdb/i386-gnu-nat.c
+++ b/gdb/x86-gnu-nat.c
@@ -35,7 +35,13 @@ extern "C"
 #include "floatformat.h"
 #include "regcache.h"
 
+
+#ifdef __x86_64__
+#include "amd64-tdep.h"
+#include "amd64-nat.h"
+#else
 #include "i386-tdep.h"
+#endif
 
 #include "inf-child.h"
 #include "i387-tdep.h"
@@ -43,21 +49,82 @@ extern "C"
 /* Offset to the thread_state_t location where REG is stored.  */
 #define REG_OFFSET(reg) offsetof (struct i386_thread_state, reg)
 
+#ifdef __x86_64__
+
 /* At REG_OFFSET[N] is the offset to the thread_state_t location where
    the GDB register N is stored.  */
-static int reg_offset[] =
+static int amd64_gnu_thread_state_reg_offset[] =
 {
-  REG_OFFSET (eax), REG_OFFSET (ecx), REG_OFFSET (edx), REG_OFFSET (ebx),
-  REG_OFFSET (uesp), REG_OFFSET (ebp), REG_OFFSET (esi), REG_OFFSET (edi),
-  REG_OFFSET (eip), REG_OFFSET (efl), REG_OFFSET (cs), REG_OFFSET (ss),
-  REG_OFFSET (ds), REG_OFFSET (es), REG_OFFSET (fs), REG_OFFSET (gs)
+  REG_OFFSET (rax),		/* %rax */
+  REG_OFFSET (rbx),		/* %rbx */
+  REG_OFFSET (rcx),		/* %rcx */
+  REG_OFFSET (rdx),		/* %rdx */
+  REG_OFFSET (rsi),		/* %rsi */
+  REG_OFFSET (rdi),		/* %rdi */
+  REG_OFFSET (rbp),		/* %rbp */
+  REG_OFFSET (ursp),	/* %rsp */
+  REG_OFFSET (r8),		/* %r8 ...  */
+  REG_OFFSET (r9),
+  REG_OFFSET (r10),
+  REG_OFFSET (r11),
+  REG_OFFSET (r12),
+  REG_OFFSET (r13),
+  REG_OFFSET (r14),
+  REG_OFFSET (r15),		/* ... %r15 */
+  REG_OFFSET (rip),		/* %rip */
+  REG_OFFSET (rfl),		/* %rflags */
+  REG_OFFSET (cs)	    /* %cs */
 };
 
-#define REG_ADDR(state, regnum) ((char *)(state) + reg_offset[regnum])
+static const int amd64_gnu_thread_state_num_regs =
+  ARRAY_SIZE (amd64_gnu_thread_state_reg_offset);
+
+#define REG_ADDR(state, regnum) \
+  ((char *)(state) + amd64_gnu_thread_state_reg_offset[regnum])
+#define VALID_REGISTER(regnum) \
+  ((regnum) >= 0 && (regnum) < amd64_gnu_thread_state_num_regs)
+#define NUM_GREGS amd64_gnu_thread_state_num_regs
+#define FLAGS_REGISTER rfl
+
+#else
+
+/* At REG_OFFSET[N] is the offset to the thread_state_t location where
+   the GDB register N is stored.  */
+static int i386_gnu_thread_state_reg_offset[] =
+{
+  REG_OFFSET (eax),	/* %eax */
+  REG_OFFSET (ecx),	/* %ecx */
+  REG_OFFSET (edx),	/* %edx */
+  REG_OFFSET (ebx),	/* %ebx */
+  REG_OFFSET (uesp),	/* %esp */
+  REG_OFFSET (ebp),	/* %ebp */
+  REG_OFFSET (esi),	/* %esi */
+  REG_OFFSET (edi),	/* %edi */
+  REG_OFFSET (eip),	/* %eip */
+  REG_OFFSET (efl),	/* %efl */
+  REG_OFFSET (cs),	/* %cs */
+  REG_OFFSET (ss),	/* %ss */
+  REG_OFFSET (ds),	/* %ds */
+  REG_OFFSET (es),	/* %es */
+  REG_OFFSET (fs),	/* %fs */
+  REG_OFFSET (gs)	/* gs */
+};
+
+static const int i386_gnu_thread_state_num_regs =
+  ARRAY_SIZE (i386_gnu_thread_state_reg_offset);
+
+#define REG_ADDR(state, regnum) \
+  ((char *)(state) + i386_gnu_thread_state_reg_offset[regnum])
+#define VALID_REGISTER(regnum) \
+  ((regnum) >= 0 && (regnum) < i386_gnu_thread_state_num_regs)
+#define NUM_GREGS i386_gnu_thread_state_num_regs
+#define FLAGS_REGISTER efl
+
+#endif  /* __x86_64__ */
 
 \f
 
-/* The i386 GNU Hurd target.  */
+/* The x86 GNU Hurd target.  */
 
 #ifdef i386_DEBUG_STATE
 using gnu_base_target = x86_nat_target<gnu_nat_target>;
@@ -65,13 +132,13 @@ using gnu_base_target = x86_nat_target<gnu_nat_target>;
 using gnu_base_target = gnu_nat_target;
 #endif
 
-struct i386_gnu_nat_target final : public gnu_base_target
+struct x86_gnu_nat_target final : public gnu_base_target
 {
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 };
 
-static i386_gnu_nat_target the_i386_gnu_nat_target;
+static x86_gnu_nat_target the_x86_gnu_nat_target;
 
 /* Get the whole floating-point state of THREAD and record the values
    of the corresponding (pseudo) registers.  */
@@ -106,7 +173,7 @@ fetch_fpregs (struct regcache *regcache, struct proc *thread)
 
 /* Fetch register REGNO, or all regs if REGNO is -1.  */
 void
-i386_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
+x86_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
 {
   struct proc *thread;
   ptid_t ptid = regcache->ptid ();
@@ -119,7 +186,7 @@ i386_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
     error (_("Can't fetch registers from thread %s: No such thread"),
 	   target_pid_to_str (ptid).c_str ());
 
-  if (regno < I386_NUM_GREGS || regno == -1)
+  if (VALID_REGISTER (regno) || regno == -1)
     {
       thread_state_t state;
 
@@ -138,7 +205,7 @@ i386_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
 
 	  proc_debug (thread, "fetching all register");
 
-	  for (i = 0; i < I386_NUM_GREGS; i++)
+	  for (i = 0; i < NUM_GREGS; i++)
 	    regcache->raw_supply (i, REG_ADDR (state, i));
 	  thread->fetched_regs = ~0;
 	}
@@ -153,7 +220,7 @@ i386_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
 	}
     }
 
-  if (regno >= I386_NUM_GREGS || regno == -1)
+  if (!VALID_REGISTER(regno) || regno == -1)
     {
       proc_debug (thread, "fetching floating-point registers");
 
@@ -196,7 +263,7 @@ store_fpregs (const struct regcache *regcache, struct proc *thread, int regno)
 
 /* Store at least register REGNO, or all regs if REGNO == -1.  */
 void
-i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
+x86_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
 {
   struct proc *thread;
   struct gdbarch *gdbarch = regcache->arch ();
@@ -210,7 +277,7 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
     error (_("Couldn't store registers into thread %s: No such thread"),
 	   target_pid_to_str (ptid).c_str ());
 
-  if (regno < I386_NUM_GREGS || regno == -1)
+  if (VALID_REGISTER (regno) || regno == -1)
     {
       thread_state_t state;
       thread_state_data_t old_state;
@@ -231,14 +298,14 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
 
       /* Save the T bit.  We might try to restore the %eflags register
 	 below, but changing the T bit would seriously confuse GDB.  */
-      trace = ((struct i386_thread_state *)state)->efl & 0x100;
+      trace = ((struct i386_thread_state *)state)->FLAGS_REGISTER & 0x100;
 
       if (!was_aborted && was_valid)
 	/* See which registers have changed after aborting the thread.  */
 	{
 	  int check_regno;
 
-	  for (check_regno = 0; check_regno < I386_NUM_GREGS; check_regno++)
+	  for (check_regno = 0; check_regno < NUM_GREGS; check_regno++)
 	    if ((thread->fetched_regs & (1 << check_regno))
 		&& memcpy (REG_ADDR (&old_state, check_regno),
 			   REG_ADDR (state, check_regno),
@@ -263,7 +330,7 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
 
 	  proc_debug (thread, "storing all registers");
 
-	  for (i = 0; i < I386_NUM_GREGS; i++)
+	  for (i = 0; i < NUM_GREGS; i++)
 	    if (REG_VALID == regcache->get_register_status (i))
 	      regcache->raw_collect (i, REG_ADDR (state, i));
 	}
@@ -277,11 +344,11 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
 	}
 
       /* Restore the T bit.  */
-      ((struct i386_thread_state *)state)->efl &= ~0x100;
-      ((struct i386_thread_state *)state)->efl |= trace;
+      ((struct i386_thread_state *)state)->FLAGS_REGISTER &= ~0x100;
+      ((struct i386_thread_state *)state)->FLAGS_REGISTER |= trace;
     }
 
-  if (regno >= I386_NUM_GREGS || regno == -1)
+  if (!VALID_REGISTER (regno) || regno == -1)
     {
       proc_debug (thread, "storing floating-point registers");
 
@@ -296,7 +363,7 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
 /* Get debug registers for thread THREAD.  */
 
 static void
-i386_gnu_dr_get (struct i386_debug_state *regs, struct proc *thread)
+x86_gnu_dr_get (struct i386_debug_state *regs, struct proc *thread)
 {
   mach_msg_type_number_t count = i386_DEBUG_STATE_COUNT;
   kern_return_t err;
@@ -311,7 +378,7 @@ i386_gnu_dr_get (struct i386_debug_state *regs, struct proc *thread)
 /* Set debug registers for thread THREAD.  */
 
 static void
-i386_gnu_dr_set (const struct i386_debug_state *regs, struct proc *thread)
+x86_gnu_dr_set (const struct i386_debug_state *regs, struct proc *thread)
 {
   kern_return_t err;
 
@@ -325,23 +392,23 @@ i386_gnu_dr_set (const struct i386_debug_state *regs, struct proc *thread)
 /* Set DR_CONTROL in THREAD.  */
 
 static void
-i386_gnu_dr_set_control_one (struct proc *thread, void *arg)
+x86_gnu_dr_set_control_one (struct proc *thread, void *arg)
 {
   unsigned long *control = (unsigned long *) arg;
   struct i386_debug_state regs;
 
-  i386_gnu_dr_get (&regs, thread);
+  x86_gnu_dr_get (&regs, thread);
   regs.dr[DR_CONTROL] = *control;
-  i386_gnu_dr_set (&regs, thread);
+  x86_gnu_dr_set (&regs, thread);
 }
 
 /* Set DR_CONTROL to CONTROL in all threads.  */
 
 static void
-i386_gnu_dr_set_control (unsigned long control)
+x86_gnu_dr_set_control (unsigned long control)
 {
   inf_update_procs (gnu_current_inf);
-  inf_threads (gnu_current_inf, i386_gnu_dr_set_control_one, &control);
+  inf_threads (gnu_current_inf, x86_gnu_dr_set_control_one, &control);
 }
 
 /* Parameters to set a debugging address.  */
@@ -355,20 +422,20 @@ struct reg_addr
 /* Set address REGNUM (zero based) to ADDR in THREAD.  */
 
 static void
-i386_gnu_dr_set_addr_one (struct proc *thread, void *arg)
+x86_gnu_dr_set_addr_one (struct proc *thread, void *arg)
 {
   struct reg_addr *reg_addr = (struct reg_addr *) arg;
   struct i386_debug_state regs;
 
-  i386_gnu_dr_get (&regs, thread);
+  x86_gnu_dr_get (&regs, thread);
   regs.dr[reg_addr->regnum] = reg_addr->addr;
-  i386_gnu_dr_set (&regs, thread);
+  x86_gnu_dr_set (&regs, thread);
 }
 
 /* Set address REGNUM (zero based) to ADDR in all threads.  */
 
 static void
-i386_gnu_dr_set_addr (int regnum, CORE_ADDR addr)
+x86_gnu_dr_set_addr (int regnum, CORE_ADDR addr)
 {
   struct reg_addr reg_addr;
 
@@ -378,13 +445,13 @@ i386_gnu_dr_set_addr (int regnum, CORE_ADDR addr)
   reg_addr.addr = addr;
 
   inf_update_procs (gnu_current_inf);
-  inf_threads (gnu_current_inf, i386_gnu_dr_set_addr_one, &reg_addr);
+  inf_threads (gnu_current_inf, x86_gnu_dr_set_addr_one, &reg_addr);
 }
 
 /* Get debug register REGNUM value from only the one LWP of PTID.  */
 
 static unsigned long
-i386_gnu_dr_get_reg (ptid_t ptid, int regnum)
+x86_gnu_dr_get_reg (ptid_t ptid, int regnum)
 {
   struct i386_debug_state regs;
   struct proc *thread;
@@ -393,7 +460,7 @@ i386_gnu_dr_get_reg (ptid_t ptid, int regnum)
   inf_update_procs (gnu_current_inf);
 
   thread = inf_tid_to_thread (gnu_current_inf, ptid.lwp ());
-  i386_gnu_dr_get (&regs, thread);
+  x86_gnu_dr_get (&regs, thread);
 
   return regs.dr[regnum];
 }
@@ -401,46 +468,50 @@ i386_gnu_dr_get_reg (ptid_t ptid, int regnum)
 /* Return the inferior's debug register REGNUM.  */
 
 static CORE_ADDR
-i386_gnu_dr_get_addr (int regnum)
+x86_gnu_dr_get_addr (int regnum)
 {
   gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
 
-  return i386_gnu_dr_get_reg (inferior_ptid, regnum);
+  return x86_gnu_dr_get_reg (inferior_ptid, regnum);
 }
 
 /* Get DR_STATUS from only the one thread of INFERIOR_PTID.  */
 
 static unsigned long
-i386_gnu_dr_get_status (void)
+x86_gnu_dr_get_status (void)
 {
-  return i386_gnu_dr_get_reg (inferior_ptid, DR_STATUS);
+  return x86_gnu_dr_get_reg (inferior_ptid, DR_STATUS);
 }
 
 /* Return the inferior's DR7 debug control register.  */
 
 static unsigned long
-i386_gnu_dr_get_control (void)
+x86_gnu_dr_get_control (void)
 {
-  return i386_gnu_dr_get_reg (inferior_ptid, DR_CONTROL);
+  return x86_gnu_dr_get_reg (inferior_ptid, DR_CONTROL);
 }
 #endif /* i386_DEBUG_STATE */
 
-void _initialize_i386gnu_nat ();
+void _initialize_x86_gnu_nat ();
 void
-_initialize_i386gnu_nat ()
+_initialize_x86_gnu_nat ()
 {
 #ifdef i386_DEBUG_STATE
-  x86_dr_low.set_control = i386_gnu_dr_set_control;
+  x86_dr_low.set_control = x86_gnu_dr_set_control;
   gdb_assert (DR_FIRSTADDR == 0 && DR_LASTADDR < i386_DEBUG_STATE_COUNT);
-  x86_dr_low.set_addr = i386_gnu_dr_set_addr;
-  x86_dr_low.get_addr = i386_gnu_dr_get_addr;
-  x86_dr_low.get_status = i386_gnu_dr_get_status;
-  x86_dr_low.get_control = i386_gnu_dr_get_control;
+  x86_dr_low.set_addr = x86_gnu_dr_set_addr;
+  x86_dr_low.get_addr = x86_gnu_dr_get_addr;
+  x86_dr_low.get_status = x86_gnu_dr_get_status;
+  x86_dr_low.get_control = x86_gnu_dr_get_control;
+#ifdef __x86_64__
+  x86_set_debug_register_length (8);
+#else
   x86_set_debug_register_length (4);
+#endif
 #endif /* i386_DEBUG_STATE */
 
-  gnu_target = &the_i386_gnu_nat_target;
+  gnu_target = &the_x86_gnu_nat_target;
 
   /* Register the target.  */
-  add_inf_child_target (&the_i386_gnu_nat_target);
+  add_inf_child_target (&the_x86_gnu_nat_target);
 }
-- 
2.39.2


^ permalink raw reply	[relevance 2%]

* Re: [PATCH] [gdb/dap] Fix exit race
  @ 2024-02-23 17:01  4% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-02-23 17:01 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> When running test-case gdb.dap/eof.exp, we're likely to get a coredump due to
Tom> a segfault in new_threadstate.

Tom> -                send_gdb("quit")

I think we need a different fix for this.

This patch on its own caused a regression in the internal AdaCore test
suite -- the exit status of gdb is now wrong.  Now, I'm not 100% sure
why this is.  Like, maybe the AdaCore test suite is killing gdb if it
pauses.

However, I thought I'd try to reproduce this in the gdb test suite.  I
wrote the appended.

With this patch in place, dap_shutdown just hangs, which happens because
gdb doesn't exit on its own accord.

I tried adding send_gdb("quit") to Server.main_loop, but of course this
just reintroduces the crash here.  But I tend to think this would be the
right thing to do, and so adding some kind of special case in gdb's
Python layer would be appropriate.

Tom

diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp
index 72c22d00711..54795a34e39 100644
--- a/gdb/testsuite/lib/dap-support.exp
+++ b/gdb/testsuite/lib/dap-support.exp
@@ -400,6 +400,15 @@ proc dap_check_log_file_re { re } {
 proc dap_shutdown {{terminate false}} {
     dap_check_request_and_response "shutdown" disconnect \
 	[format {o terminateDebuggee [l %s]} $terminate]
+
+    # Check gdb's exit status.
+    global gdb_spawn_id
+    set result [wait -i $gdb_spawn_id]
+    gdb_assert {[lindex $result 2] == 0}
+    gdb_assert {[lindex $result 3] == 0}
+
+    clear_gdb_spawn_id
+
     dap_check_log_file
 }
 

^ permalink raw reply	[relevance 4%]

* [PATCH] Fix throw_winerror_with_name build error on x86-64 Cygwin
@ 2024-02-23 16:55 17% Pedro Alves
  0 siblings, 0 replies; 200+ results
From: Pedro Alves @ 2024-02-23 16:55 UTC (permalink / raw)
  To: gdb-patches

The GDB build currently fails on x86-64 Cygwin, with:

 src/gdbsupport/errors.cc: In function ‘void throw_winerror_with_name(const char*, ULONGEST)’:
 src/gdbsupport/errors.cc:152:12: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ULONGEST’ {aka ‘long unsigned int’} [-Werror=format=]
   152 |   error (_("%s (error %d): %s"), string, err, strwinerror (err));
       |            ^

Fix this by adding a cast.  While at it, the error codes are really a
DWORD that results from a GetLastError() call, so I think unsigned is
more appropriate.  That is also what strwinerror already does:

    sprintf (buf, "unknown win32 error (%u)", (unsigned) error);

The cast is necessary on MinGW GDB as well, where ULONGEST is unsigned
long long, but for some reason, I don't get a warning there.

Change-Id: I3f5faa779765fd8021abf58bb5f68d556b309d17
---
 gdbsupport/errors.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdbsupport/errors.cc b/gdbsupport/errors.cc
index 8ac3ed0da79..cccdc5cafb2 100644
--- a/gdbsupport/errors.cc
+++ b/gdbsupport/errors.cc
@@ -149,7 +149,7 @@ strwinerror (ULONGEST error)
 void
 throw_winerror_with_name (const char *string, ULONGEST err)
 {
-  error (_("%s (error %d): %s"), string, err, strwinerror (err));
+  error (_("%s (error %u): %s"), string, (unsigned) err, strwinerror (err));
 }
 
 #endif /* USE_WIN32API */

base-commit: e433bca4847acd34b6178a392335ed10060639ec
-- 
2.43.2


^ permalink raw reply	[relevance 17%]

* Re: [PATCH v2 0/6] Add vDefaultInferiorFd feature
  @ 2024-02-22 14:38  0% ` Alexandra Petlanova Hajkova
  0 siblings, 0 replies; 200+ results
From: Alexandra Petlanova Hajkova @ 2024-02-22 14:38 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2805 bytes --]

ping

On Fri, Jan 19, 2024 at 12:57 PM Alexandra Hájková <ahajkova@redhat.com>
wrote:

> Currently, when GDBserver is run locally using stdio, the inferior
> is unable to read from STDIN so we can't give it any input.
> The main motivation to address this issue is to use GDB together
> with Valgrind, using vgdb --multi feature which allows to run
> Valgrind from inside GDB. Valgrind then acts as a locally run
> GDBserver that uses stdio.
>
> Add a new DefaultInferiorFd feature and the corresponding packet.
> This feature allows GDB to send, to GDBserver, the file descriptor
> numbers of the terminal to which GDB is connected. The inferior is
> then started connected to the same terminal as GDB. This allows the
> inferior run by local GDBserver to read from GDB's STDIN and write
> its output to GDB's STOUT/ERR the same way as native target.
>
> v2: - [2/6]:- add an error handling in a case dup would fail
>             - hoist the calls to mark_fd_no_cloexec near the dup()s
>       [3/6] - improve documentation formatting
>             - rephrase and extend the documentation
>             - cosmetics
>             - add a new target method so that gdbserver doesn't advertise
>               this new feauture on platforms it does not work at
>       [4/3] - cosmetics
>
> Alexandra Hájková (6):
>   gdb.server/non-existing-program.exp: Use gdbserver_start.
>   gdb/ser-pipe.c: Duplicate the file descriptors
>   Add new vDefaultInferiorFd packet
>   gdbserver/linux-low.cc: Connect the inferior to the terminal
>   remote.c: Add terminal handling functions
>   Add defaultinf.exp test to the testsuite
>
>  gdb/doc/gdb.texinfo                           |  42 ++++++
>  gdb/remote.c                                  |  83 +++++++++++
>  gdb/ser-pipe.c                                |  40 ++++++
>  gdb/serial.c                                  |   4 +
>  gdb/serial.h                                  |   4 +
>  gdb/testsuite/gdb.server/defaultinf.c         |  39 +++++
>  gdb/testsuite/gdb.server/defaultinf.exp       |  59 ++++++++
>  .../gdb.server/non-existing-program.exp       |  54 ++-----
>  gdb/testsuite/lib/gdbserver-support.exp       |  62 +++++---
>  gdbserver/linux-low.cc                        |  38 ++++-
>  gdbserver/linux-low.h                         |   2 +
>  gdbserver/server.cc                           | 135 +++++++++++++++++-
>  gdbserver/server.h                            |  12 ++
>  gdbserver/target.cc                           |   6 +
>  gdbserver/target.h                            |   6 +
>  15 files changed, 524 insertions(+), 62 deletions(-)
>  create mode 100644 gdb/testsuite/gdb.server/defaultinf.c
>  create mode 100644 gdb/testsuite/gdb.server/defaultinf.exp
>
> --
> 2.43.0
>
>

^ permalink raw reply	[relevance 0%]

* [PATCH v5] gdb: Modify the output of "info breakpoints" and "delete breakpoints"
@ 2024-02-22  7:29  6% Tiezhu Yang
  0 siblings, 0 replies; 200+ results
From: Tiezhu Yang @ 2024-02-22  7:29 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner, Tom Tromey, Guinevere Larsen, Eli Zaretskii

The output of "info breakpoints" includes breakpoint, watchpoint,
tracepoint, and catchpoint if they are created, so it should show
all the four types are deleted in the output of "info breakpoints"
to report empty list after "delete breakpoints".

It should also change the output of "delete breakpoints" to make it
clear that watchpoints, tracepoints, and catchpoints are also being
deleted. This is suggested by Guinevere Larsen, thank you.

$ make check-gdb TESTS="gdb.base/access-mem-running.exp"
$ gdb/gdb gdb/testsuite/outputs/gdb.base/access-mem-running/access-mem-running
[...]
(gdb) break main
Breakpoint 1 at 0x12000073c: file /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c, line 32.
(gdb) watch global_counter
Hardware watchpoint 2: global_counter
(gdb) trace maybe_stop_here
Tracepoint 3 at 0x12000071c: file /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c, line 27.
(gdb) catch fork
Catchpoint 4 (fork)
(gdb) info breakpoints
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x000000012000073c in main at /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c:32
2       hw watchpoint  keep y                      global_counter
3       tracepoint     keep y   0x000000012000071c in maybe_stop_here at /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c:27
	not installed on target
4       catchpoint     keep y                      fork

Without this patch:

(gdb) delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) info breakpoints 3
No breakpoint or watchpoint matching '3'.

With this patch:

(gdb) delete breakpoints
Delete all breakpoints, watchpoints, tracepoints, and catchpoints? (y or n) y
(gdb) info breakpoints
No breakpoints, watchpoints, tracepoints, or catchpoints.
(gdb) info breakpoints 3
No breakpoint, watchpoint, tracepoint, or catchpoint matching '3'.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Approved-by: Kevin Buettner <kevinb@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---

v5: only use SPACEs in gdb.texinfo

 gdb/breakpoint.c                              | 25 +++++++-----
 gdb/doc/gdb.texinfo                           | 38 ++++++++++---------
 gdb/ppc-linux-nat.c                           |  4 +-
 gdb/testsuite/gdb.arch/i386-dr3-watch.exp     |  2 +-
 .../gdb.base/annota-input-while-running.exp   |  2 +-
 gdb/testsuite/gdb.base/break-unload-file.exp  |  4 +-
 gdb/testsuite/gdb.base/break.exp              | 10 ++---
 .../gdb.base/breakpoint-in-ro-region.exp      |  2 +-
 .../continue-after-aborted-step-over.exp      |  2 +-
 gdb/testsuite/gdb.base/default.exp            |  2 +-
 gdb/testsuite/gdb.base/del.exp                |  4 +-
 gdb/testsuite/gdb.base/ena-dis-br.exp         |  2 +-
 gdb/testsuite/gdb.base/foll-fork.exp          |  6 +--
 gdb/testsuite/gdb.base/hbreak-unmapped.exp    |  4 +-
 gdb/testsuite/gdb.base/hbreak2.exp            |  2 +-
 gdb/testsuite/gdb.base/help.exp               |  3 +-
 gdb/testsuite/gdb.base/new-ui.exp             |  8 ++--
 gdb/testsuite/gdb.base/save-bp.exp            |  8 ++--
 gdb/testsuite/gdb.base/sepdebug.exp           |  2 +-
 gdb/testsuite/gdb.base/server-del-break.exp   |  4 +-
 gdb/testsuite/gdb.cp/annota2.exp              |  4 +-
 gdb/testsuite/gdb.cp/annota3.exp              |  4 +-
 gdb/testsuite/gdb.cp/ovldbreak.exp            | 10 ++---
 gdb/testsuite/gdb.cp/save-bp-qualified.exp    |  4 +-
 .../gdb.dwarf2/dw2-inline-header-1.exp        |  4 +-
 .../gdb.dwarf2/dw2-inline-header-2.exp        |  8 ++--
 .../gdb.dwarf2/dw2-inline-header-3.exp        |  4 +-
 .../gdb.dwarf2/dw2-inline-small-func.exp      |  4 +-
 gdb/testsuite/gdb.guile/scm-breakpoint.exp    |  6 +--
 gdb/testsuite/gdb.linespec/cpexplicit.exp     |  4 +-
 gdb/testsuite/gdb.linespec/explicit.exp       |  4 +-
 gdb/testsuite/gdb.mi/mi-py-modify-bp.exp      |  2 +-
 gdb/testsuite/gdb.mi/mi-return.exp            |  2 +-
 .../gdb.mi/mi-thread-specific-bp.exp          |  2 +-
 .../gdb.multi/inferior-specific-bp.exp        |  2 +-
 gdb/testsuite/gdb.opt/inline-small-func.exp   |  4 +-
 gdb/testsuite/gdb.python/py-breakpoint.exp    |  8 ++--
 .../gdb.reverse/ppc_record_test_isa_3_1.exp   |  2 +-
 .../continue-pending-after-query.exp          |  2 +-
 .../gdb.threads/continue-pending-status.exp   |  6 +--
 gdb/testsuite/gdb.threads/thread_check.exp    |  4 +-
 gdb/testsuite/lib/gdb.exp                     |  6 +--
 gdb/testsuite/lib/mi-support.exp              | 10 ++---
 gdbserver/mem-break.cc                        |  7 ++--
 gdbserver/mem-break.h                         |  7 ++--
 45 files changed, 132 insertions(+), 122 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 5f05657a8b3..102bd7fad41 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7080,10 +7080,11 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
       if (!filter)
 	{
 	  if (bp_num_list == NULL || *bp_num_list == '\0')
-	    uiout->message ("No breakpoints or watchpoints.\n");
+	    uiout->message ("No breakpoints, watchpoints, tracepoints, "
+			    "or catchpoints.\n");
 	  else
-	    uiout->message ("No breakpoint or watchpoint matching '%s'.\n",
-			    bp_num_list);
+	    uiout->message ("No breakpoint, watchpoint, tracepoint, "
+			    "or catchpoint matching '%s'.\n", bp_num_list);
 	}
     }
   else
@@ -12699,9 +12700,9 @@ delete_command (const char *arg, int from_tty)
     {
       int breaks_to_delete = 0;
 
-      /* Delete all breakpoints if no argument.  Do not delete
-	 internal breakpoints, these have to be deleted with an
-	 explicit breakpoint number argument.  */
+      /* Delete all breakpoints, watchpoints, tracepoints, and catchpoints
+	 if no argument.  Do not delete internal breakpoints, these have to
+	 be deleted with an explicit breakpoint number argument.  */
       for (breakpoint &b : all_breakpoints ())
 	if (user_breakpoint_p (&b))
 	  {
@@ -12711,7 +12712,9 @@ delete_command (const char *arg, int from_tty)
 
       /* Ask user only if there are some breakpoints to delete.  */
       if (!from_tty
-	  || (breaks_to_delete && query (_("Delete all breakpoints? "))))
+	  || (breaks_to_delete
+	      && query (_("Delete all breakpoints, watchpoints, tracepoints, "
+			  "and catchpoints? "))))
 	for (breakpoint &b : all_breakpoints_safe ())
 	  if (user_breakpoint_p (&b))
 	    delete_breakpoint (&b);
@@ -14236,7 +14239,7 @@ delete_trace_command (const char *arg, int from_tty)
     {
       int breaks_to_delete = 0;
 
-      /* Delete all breakpoints if no argument.
+      /* Delete all tracepoints if no argument.
 	 Do not delete internal or call-dummy breakpoints, these
 	 have to be deleted with an explicit breakpoint number 
 	 argument.  */
@@ -14830,7 +14833,8 @@ This command may be abbreviated \"disable\"."),
 Delete all or some breakpoints.\n\
 Usage: delete [BREAKPOINTNUM]...\n\
 Arguments are breakpoint numbers with spaces in between.\n\
-To delete all breakpoints, give no argument.\n\
+To delete all breakpoints, watchpoints, tracepoints, and catchpoints,\n\
+give no argument.\n\
 \n\
 Also a prefix command for deletion of other GDB objects."),
 		      &deletelist, 1, &cmdlist);
@@ -14841,7 +14845,8 @@ Also a prefix command for deletion of other GDB objects."),
 Delete all or some breakpoints or auto-display expressions.\n\
 Usage: delete breakpoints [BREAKPOINTNUM]...\n\
 Arguments are breakpoint numbers with spaces in between.\n\
-To delete all breakpoints, give no argument.\n\
+To delete all breakpoints, watchpoints, tracepoints, and catchpoints,\n\
+give no argument.\n\
 This command may be abbreviated \"delete\"."),
 	   &deletelist);
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 79805486dd6..34cd567f811 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -4343,7 +4343,8 @@ running or not, what process it is, and why it stopped.
 @end table
 
 @menu
-* Breakpoints::                 Breakpoints, watchpoints, and catchpoints
+* Breakpoints::                 Breakpoints, watchpoints, tracepoints,
+                                and catchpoints
 * Continuing and Stepping::     Resuming execution
 * Skipping Over Functions and Files::
                                 Skipping over functions and files
@@ -4721,15 +4722,15 @@ optionally be surrounded by spaces.
 @cindex @code{$_} and @code{info breakpoints}
 @item info breakpoints @r{[}@var{list}@dots{}@r{]}
 @itemx info break @r{[}@var{list}@dots{}@r{]}
-Print a table of all breakpoints, watchpoints, and catchpoints set and
-not deleted.  Optional argument @var{n} means print information only
-about the specified breakpoint(s) (or watchpoint(s) or catchpoint(s)).
+Print a table of all breakpoints, watchpoints, tracepoints, and catchpoints set
+and not deleted.  Optional argument @var{n} means print information only about
+the specified breakpoint(s) (or watchpoint(s) or tracepoint(s) or catchpoint(s)).
 For each breakpoint, following columns are printed:
 
 @table @emph
 @item Breakpoint Numbers
 @item Type
-Breakpoint, watchpoint, or catchpoint.
+Breakpoint, watchpoint, tracepoint, or catchpoint.
 @item Disposition
 Whether the breakpoint is marked to be disabled or deleted when hit.
 @item Enabled or Disabled
@@ -5650,10 +5651,11 @@ in @ref{Location Specifications}.
 @kindex delete
 @kindex d @r{(@code{delete})}
 @item delete @r{[}breakpoints@r{]} @r{[}@var{list}@dots{}@r{]}
-Delete the breakpoints, watchpoints, or catchpoints of the breakpoint
-list specified as argument.  If no argument is specified, delete all
-breakpoints (@value{GDBN} asks confirmation, unless you have @code{set
-confirm off}).  You can abbreviate this command as @code{d}.
+Delete the breakpoints, watchpoints, tracepoints, or catchpoints of the
+breakpoint list specified as argument.  If no argument is specified, delete
+all breakpoints, watchpoints, tracepoints, and catchpoints (@value{GDBN} asks
+confirmation, unless you have @code{set confirm off}).  You can abbreviate this
+command as @code{d}.
 @end table
 
 @node Disabling
@@ -5665,10 +5667,10 @@ prefer to @dfn{disable} it.  This makes the breakpoint inoperative as if
 it had been deleted, but remembers the information on the breakpoint so
 that you can @dfn{enable} it again later.
 
-You disable and enable breakpoints, watchpoints, and catchpoints with
-the @code{enable} and @code{disable} commands, optionally specifying
-one or more breakpoint numbers as arguments.  Use @code{info break} to
-print a list of all breakpoints, watchpoints, and catchpoints if you
+You disable and enable breakpoints, watchpoints, tracepoints, and catchpoints
+with the @code{enable} and @code{disable} commands, optionally specifying
+one or more breakpoint numbers as arguments.  Use @code{info break} to print
+a list of all breakpoints, watchpoints, tracepoints, and catchpoints if you
 do not know which numbers to use.
 
 Disabling and enabling a breakpoint that has multiple locations
@@ -5696,7 +5698,7 @@ set with the @code{tbreak} command starts out in this state.
 @end itemize
 
 You can use the following commands to enable or disable breakpoints,
-watchpoints, and catchpoints:
+watchpoints, tracepoints, and catchpoints:
 
 @table @code
 @kindex disable
@@ -5874,7 +5876,7 @@ is decremented each time.  @xref{Convenience Vars, ,Convenience
 Variables}.
 @end table
 
-Ignore counts apply to breakpoints, watchpoints, and catchpoints.
+Ignore counts apply to breakpoints, watchpoints, tracepoints, and catchpoints.
 
 
 @node Break Commands
@@ -32987,8 +32989,8 @@ list of thread groups to which this breakpoint applies
 number of times the breakpoint has been hit
 @end table
 
-If there are no breakpoints or watchpoints, the @code{BreakpointTable}
-@code{body} field is an empty list.
+If there are no breakpoints, watchpoints, tracepoints, or catchpoints,
+the @code{BreakpointTable} @code{body} field is an empty list.
 
 @subsubheading @value{GDBN} Command
 
@@ -33980,7 +33982,7 @@ to execute until it reaches a debugger stop event.  If the
 it reaches a stop event.  Stop events may include
 @itemize @bullet
 @item
-breakpoints or watchpoints
+breakpoints, watchpoints, tracepoints, or catchpoints
 @item
 signals or exceptions
 @item
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 0adaa6dbed6..028422bb1e8 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2358,8 +2358,8 @@ ppc_linux_nat_target::can_use_watchpoint_cond_accel (void)
 
   auto process_it = m_process_info.find (inferior_ptid.pid ());
 
-  /* No breakpoints or watchpoints have been requested for this process,
-     we have at least one free DVC register.  */
+  /* No breakpoints, watchpoints, tracepoints, or catchpoints have been
+     requested for this process, we have at least one free DVC register.  */
   if (process_it == m_process_info.end ())
     return true;
 
diff --git a/gdb/testsuite/gdb.arch/i386-dr3-watch.exp b/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
index e2c89b879ad..84b3806d234 100644
--- a/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
+++ b/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
@@ -76,7 +76,7 @@ gdb_test_multiple "watch gap1" "$test" {
 gdb_test "delete" \
     "" \
     "delete all watchpoints" \
-    {Delete all breakpoints\? \(y or n\) $} \
+    {Delete all breakpoints, watchpoints, tracepoints, and catchpoints\? \(y or n\) $} \
     "y"
 
 # If debug registers were left occupied by mistake, we'll fail to set
diff --git a/gdb/testsuite/gdb.base/annota-input-while-running.exp b/gdb/testsuite/gdb.base/annota-input-while-running.exp
index 1d1f523672d..46256226f44 100644
--- a/gdb/testsuite/gdb.base/annota-input-while-running.exp
+++ b/gdb/testsuite/gdb.base/annota-input-while-running.exp
@@ -57,7 +57,7 @@ gdb_annota_test "set annotate 2" ".*" "annotation set at level 2"
 
 set test "delete breakpoints"
 gdb_test_multiple "delete" $test {
-    -re "Delete all breakpoints. .y or n." {
+    -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints. .y or n." {
 	send_gdb "y\n"
 	exp_continue
     }
diff --git a/gdb/testsuite/gdb.base/break-unload-file.exp b/gdb/testsuite/gdb.base/break-unload-file.exp
index 2641feccec9..2d62cc51cec 100644
--- a/gdb/testsuite/gdb.base/break-unload-file.exp
+++ b/gdb/testsuite/gdb.base/break-unload-file.exp
@@ -121,8 +121,8 @@ proc test_break { initial_load always_inserted break_command } {
 	# re-insert, GDB would fill the shadow buffer with a
 	# breakpoint instruction).  Avoid delete_breakpoints as that
 	# doesn't record a pass/fail.
-	gdb_test "delete" "" "delete all breakpoints" \
-	    "Delete all breakpoints.*y or n.*$" "y"
+	gdb_test "delete" "" "delete all breakpoints, watchpoints, tracepoints, and catchpoints" \
+	    "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*y or n.*$" "y"
 
 	# Re-add symbols back.
 	set test "file \$binfile"
diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index eda486a4945..cdb4c22a034 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -49,17 +49,17 @@ proc_with_prefix test_break {} {
     # for general use elsewhere.
     send_gdb "delete breakpoints\n"
     gdb_expect {
-	 -re "Delete all breakpoints.*$" {
+	 -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*$" {
 		send_gdb "y\n"
 		gdb_expect {
 		    -re "$::gdb_prompt $" {
-			fail "delete all breakpoints when none (unexpected prompt)"
+			fail "delete all breakpoints, watchpoints, tracepoints, and catchpoints when none (unexpected prompt)"
 		    }
-		    timeout	{ fail "delete all breakpoints when none (timeout after unexpected prompt)" }
+		    timeout	{ fail "delete all breakpoints, watchpoints, tracepoints, and catchpoints when none (timeout after unexpected prompt)" }
 		}
 	    }
-	 -re ".*$::gdb_prompt $"       { pass "delete all breakpoints when none" }
-	timeout	            { fail "delete all breakpoints when none (timeout)" }
+	 -re ".*$::gdb_prompt $"       { pass "delete all breakpoints, watchpoints, tracepoints, and catchpoints when none" }
+	timeout	            { fail "delete all breakpoints, watchpoints, tracepoints, and catchpoints when none (timeout)" }
     }
 
     # test break at function
diff --git a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
index 48fc75cdfc8..b0a51961870 100644
--- a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
+++ b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
@@ -234,7 +234,7 @@ proc test_single_step { always_inserted auto_hw } {
     }
 
     gdb_test "maint info breakpoints 0" \
-	"No breakpoint or watchpoint matching '0'\." \
+	"No breakpoint, watchpoint, tracepoint, or catchpoint matching '0'\." \
 	"single-step breakpoint is not left behind"
 
     # Confirm the thread really advanced.
diff --git a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
index 4aefc446ab7..d5861357585 100644
--- a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
+++ b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
@@ -27,7 +27,7 @@
 #
 #  Command aborted.
 #  delete breakpoints
-#  Delete all breakpoints? (y or n) y
+#  Delete all breakpoints, watchpoints, tracepoints, and catchpoints? (y or n) y
 #  (gdb) b function
 #  Breakpoint 3 at 0x40048b: file test.c, line 33.
 #  continue
diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 98dad7cb309..291722e62c8 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -265,7 +265,7 @@ gdb_test "info args" "No frame selected."
 #test info bogus-gdb-command
 gdb_test "info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\".  Try \"help info\".*"
 #test info breakpoints
-gdb_test "info breakpoints" "No breakpoints or watchpoints."
+gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints."
 #test info copying
 # The license text is very big, so it may overwhelm Expect's output buffer
 # and cause the test to fail occasionally.  To avoid this problem, verify
diff --git a/gdb/testsuite/gdb.base/del.exp b/gdb/testsuite/gdb.base/del.exp
index 2a715e8e775..58937de656f 100644
--- a/gdb/testsuite/gdb.base/del.exp
+++ b/gdb/testsuite/gdb.base/del.exp
@@ -35,7 +35,7 @@ proc test_delete_alias { alias } {
              "remove all breakpoints"
 
     gdb_test "info break" \
-             "No breakpoints or watchpoints." \
+	     "No breakpoints, watchpoints, tracepoints, or catchpoints." \
              "info break after clearing breakpoints"
 
 
@@ -50,7 +50,7 @@ proc test_delete_alias { alias } {
              "Remove last breakpoint"
 
     gdb_test "info break" \
-             "No breakpoints or watchpoints." \
+	     "No breakpoints, watchpoints, tracepoints, or catchpoints." \
              "info break after removing break on main"
 }
 
diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp
index e7259f672de..924133e0d90 100644
--- a/gdb/testsuite/gdb.base/ena-dis-br.exp
+++ b/gdb/testsuite/gdb.base/ena-dis-br.exp
@@ -140,7 +140,7 @@ gdb_test "continue" \
     "continue to auto-deleted break marker3"
 
 gdb_test "info break $bp" \
-    ".*No breakpoint or watchpoint matching.*" \
+    ".*No breakpoint, watchpoint, tracepoint, or catchpoint matching.*" \
     "info auto-deleted break marker3"
 
 # Verify that we can set a breakpoint and manually disable it (we've
diff --git a/gdb/testsuite/gdb.base/foll-fork.exp b/gdb/testsuite/gdb.base/foll-fork.exp
index abbbeece6bd..ecf2111d4fd 100644
--- a/gdb/testsuite/gdb.base/foll-fork.exp
+++ b/gdb/testsuite/gdb.base/foll-fork.exp
@@ -289,7 +289,7 @@ proc_with_prefix catch_fork_child_follow {second_inferior} {
     gdb_test "delete breakpoints" \
 	"" \
 	"set follow-fork child, cleanup" \
-	"Delete all breakpoints. \\(y or n\\) $" \
+	"Delete all breakpoints, watchpoints, tracepoints, and catchpoints. \\(y or n\\) $" \
 	"y"
 }
 
@@ -316,7 +316,7 @@ proc_with_prefix catch_fork_unpatch_child {} {
 	"Catchpoint \[0-9\]* \\(forked process \[0-9\]*\\),.*" \
 	"unpatch child, catch fork"
 
-    # Delete all breakpoints and catchpoints.
+    # Delete all breakpoints, watchpoints, tracepoints, and catchpoints.
     delete_breakpoints
 
     # Force $srcfile as the current GDB source can be in glibc sourcetree.
@@ -393,7 +393,7 @@ proc_with_prefix tcatch_fork_parent_follow {} {
     gdb_test "delete breakpoints" \
 	"" \
 	"set follow-fork parent, cleanup" \
-	"Delete all breakpoints. \\(y or n\\) $" \
+	"Delete all breakpoints, watchpoints, tracepoints, and catchpoints. \\(y or n\\) $" \
 	"y"
 }
 
diff --git a/gdb/testsuite/gdb.base/hbreak-unmapped.exp b/gdb/testsuite/gdb.base/hbreak-unmapped.exp
index fd88f37f098..ccb4b20c458 100644
--- a/gdb/testsuite/gdb.base/hbreak-unmapped.exp
+++ b/gdb/testsuite/gdb.base/hbreak-unmapped.exp
@@ -71,5 +71,5 @@ gdb_test "info break" "hw breakpoint.*y.*0x0\+\[ \t\]\+" \
 gdb_test_no_output "delete \$bpnum" "" "delete" \
     "delete hw breakpoint"
 
-gdb_test "info break" "No breakpoints or watchpoints\." \
-    "info break shows no breakpoints"
+gdb_test "info break" "No breakpoints, watchpoints, tracepoints, or catchpoints\." \
+    "info break shows no breakpoints, watchpoints, tracepoints, or catchpoints"
diff --git a/gdb/testsuite/gdb.base/hbreak2.exp b/gdb/testsuite/gdb.base/hbreak2.exp
index 211baa2a849..8f5735b790f 100644
--- a/gdb/testsuite/gdb.base/hbreak2.exp
+++ b/gdb/testsuite/gdb.base/hbreak2.exp
@@ -228,7 +228,7 @@ gdb_test "continue" \
     "continue to hardware breakpoint at }"
 
 #
-# Delete all breakpoints so we can start over, course this can be a test too.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so we can start over, course this can be a test too.
 #
 delete_breakpoints
 
diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp
index daa8c4aade8..5ea5c79d3ec 100644
--- a/gdb/testsuite/gdb.base/help.exp
+++ b/gdb/testsuite/gdb.base/help.exp
@@ -89,7 +89,8 @@ set expected_help_delete {
     "Delete all or some breakpoints\.\[\r\n\]+"
     "Usage: delete \\\[BREAKPOINTNUM\\\]...\[\r\n\]+"
     "Arguments are breakpoint numbers with spaces in between\.\[\r\n\]+"
-    "To delete all breakpoints, give no argument\.\[\r\n\]+"
+    "To delete all breakpoints, watchpoints, tracepoints, and catchpoints,\.\[\r\n\]+"
+    "give no argument\.\[\r\n\]+"
     "Also a prefix command for deletion of other GDB objects\.\[\r\n\]+"
 }
 test_prefix_command_help {"d" "delete"} $expected_help_delete "help delete \"d\" abbreviation"
diff --git a/gdb/testsuite/gdb.base/new-ui.exp b/gdb/testsuite/gdb.base/new-ui.exp
index a58d62f9ed1..97166925c1b 100644
--- a/gdb/testsuite/gdb.base/new-ui.exp
+++ b/gdb/testsuite/gdb.base/new-ui.exp
@@ -130,17 +130,17 @@ proc_with_prefix do_test {} {
     # Verify that we get proper queries on the main UI, but that they are
     # auto-answered on secondary UIs.
     with_spawn_id $gdb_main_spawn_id {
-	gdb_test "delete" "" "delete all breakpoint on main console" \
-		 "Delete all breakpoints. .y or n. $" "n"
+	gdb_test "delete" "" "delete all breakpoints, watchpoints, tracepoints, and catchpoints on main console" \
+		 "Delete all breakpoints, watchpoints, tracepoints, and catchpoints. .y or n. $" "n"
     }
     with_spawn_id $extra_spawn_id {
 	# Check output in two stages in order to override
 	# gdb_test_multiple's internal "got interactive prompt" fail
 	# that would otherwise match if the expect buffer happens to
 	# fill with partial output that ends in "(y or n) ".
-	set test "delete all breakpoints on extra console"
+	set test "delete all breakpoints, watchpoints, tracepoints, and catchpoints on extra console"
 	gdb_test_multiple "delete" $test {
-	    -re "Delete all breakpoints. .y or n. " {
+	    -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints. .y or n. " {
 		gdb_test "" \
 		    ".answered Y; input not from terminal." \
 		    $test
diff --git a/gdb/testsuite/gdb.base/save-bp.exp b/gdb/testsuite/gdb.base/save-bp.exp
index ee870101fde..2872d7b2c6c 100644
--- a/gdb/testsuite/gdb.base/save-bp.exp
+++ b/gdb/testsuite/gdb.base/save-bp.exp
@@ -22,8 +22,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile] } {
 if ![runto_main] {
     return -1
 }
-# Delete all breakpoints so that the "runto_main" breakpoint above
-# does not interfere with our testing.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the "runto_main" breakpoint above does not interfere with our testing.
 delete_breakpoints
 
 # Insert a bunch of breakpoints... The goal is to create breakpoints
@@ -64,8 +64,8 @@ clean_restart $testfile
 if ![runto_main] {
     return -1
 }
-# Delete all breakpoints so that the "runto_main" breakpoint above
-# does not interfere with our testing.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the "runto_main" breakpoint above does not interfere with our testing.
 delete_breakpoints
 
 # ... and restore the breakpoints.
diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp
index 4182eb2b6a8..ee9bea2045a 100644
--- a/gdb/testsuite/gdb.base/sepdebug.exp
+++ b/gdb/testsuite/gdb.base/sepdebug.exp
@@ -219,7 +219,7 @@ gdb_test "step" \
     "step onto breakpoint"
 
 #
-# delete all breakpoints so we can start over, course this can be a test too
+# delete all breakpoints, watchpoints, tracepoints, and catchpoints so we can start over, course this can be a test too
 #
 delete_breakpoints
 
diff --git a/gdb/testsuite/gdb.base/server-del-break.exp b/gdb/testsuite/gdb.base/server-del-break.exp
index e18bb7d79c2..db598783d88 100644
--- a/gdb/testsuite/gdb.base/server-del-break.exp
+++ b/gdb/testsuite/gdb.base/server-del-break.exp
@@ -29,10 +29,10 @@ gdb_test "break -q main" \
 
 # Try deleting all breakpoints, using the "server" command prefix.
 # Prefixing the "delete breakpoints" with "server" should turn
-# the confirmation request ("Delete all breakpoints? (y or n)")
+# the confirmation request ("Delete all breakpoints, watchpoints, tracepoints, and catchpoints? (y or n)")
 # off, hence we expect the operation to be executed without output.
 gdb_test_no_output "server delete breakpoints"
 
 # Double-check that the all breakpoints were in fact deleted.
 gdb_test "info break" \
-         "No breakpoints or watchpoints."
+	 "No breakpoints, watchpoints, tracepoints, or catchpoints."
diff --git a/gdb/testsuite/gdb.cp/annota2.exp b/gdb/testsuite/gdb.cp/annota2.exp
index 3cd43bfb069..1b1c26b0d86 100644
--- a/gdb/testsuite/gdb.cp/annota2.exp
+++ b/gdb/testsuite/gdb.cp/annota2.exp
@@ -158,11 +158,11 @@ gdb_test_multiple "continue" "continue until exit" {
 }
 
 #
-# delete all breakpoints
+# delete all breakpoints, watchpoints, tracepoints, and catchpoints
 #
 send_gdb "delete\n"
 gdb_expect {
-  -re ".*Delete all breakpoints. \\(y or n\\) \r\n\032\032query.*$" {
+  -re ".*Delete all breakpoints, watchpoints, tracepoints, and catchpoints. \\(y or n\\) \r\n\032\032query.*$" {
            send_gdb "y\n"
            gdb_expect {
 	     -re "\r\n\032\032post-query\r\n${breakpoints_invalid}$gdb_prompt$" { pass "delete bps" }
diff --git a/gdb/testsuite/gdb.cp/annota3.exp b/gdb/testsuite/gdb.cp/annota3.exp
index 978f3d566a7..e5da031a25c 100644
--- a/gdb/testsuite/gdb.cp/annota3.exp
+++ b/gdb/testsuite/gdb.cp/annota3.exp
@@ -114,11 +114,11 @@ lappend el "\r\n\032\032stopped\r\n"
 gdb_expect_list "continue to exit" "$gdb_prompt$" $el
 
 #
-# delete all breakpoints
+# delete all breakpoints, watchpoints, tracepoints, and catchpoints
 #
 send_gdb "delete\n"
 gdb_expect {
-  -re ".*Delete all breakpoints. \\(y or n\\) \r\n\032\032query.*$" {
+  -re ".*Delete all breakpoints, watchpoints, tracepoints, and catchpoints. \\(y or n\\) \r\n\032\032query.*$" {
            send_gdb "y\n"
            gdb_expect {
 	     -re "\r\n\032\032post-query\r\n$gdb_prompt$" { pass "delete bps" }
diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp
index 01e7724e289..882a83ba8f3 100644
--- a/gdb/testsuite/gdb.cp/ovldbreak.exp
+++ b/gdb/testsuite/gdb.cp/ovldbreak.exp
@@ -309,23 +309,23 @@ with_test_prefix "multiple breakpoints" {
 
 send_gdb "delete breakpoints\n"
 gdb_expect {
-    -re "Delete all breakpoints.* $" {
+    -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.* $" {
         send_gdb "y\n"
         gdb_expect {
             -re ".*$gdb_prompt $" {
-                pass "delete all breakpoints"
+		pass "delete all breakpoints, watchpoints, tracepoints, and catchpoints"
             }
             timeout {
-                fail "delete all breakpoints (timeout)"
+		fail "delete all breakpoints, watchpoints, tracepoints, and catchpoints (timeout)"
             }
         }
     }
     timeout {
-        fail "delete all breakpoints (timeout)"
+	fail "delete all breakpoints, watchpoints, tracepoints, and catchpoints (timeout)"
     }
 }
 
-gdb_test "info breakpoints" "No breakpoints or watchpoints." "breakpoint info (after delete)"
+gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints." "breakpoint info (after delete)"
 
 
 
diff --git a/gdb/testsuite/gdb.cp/save-bp-qualified.exp b/gdb/testsuite/gdb.cp/save-bp-qualified.exp
index 8eb5c98a7f6..3f6ee0fb29f 100644
--- a/gdb/testsuite/gdb.cp/save-bp-qualified.exp
+++ b/gdb/testsuite/gdb.cp/save-bp-qualified.exp
@@ -29,8 +29,8 @@ proc restart {} {
     if ![runto_main] {
 	return 0
     }
-    # Delete all breakpoints so that the "runto_main" breakpoint above
-    # does not interfere with our testing.
+    # Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+    # the "runto_main" breakpoint above does not interfere with our testing.
     delete_breakpoints
 
     return 1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
index 7eaa37ea0b4..5268e7815ad 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
@@ -160,8 +160,8 @@ proc do_test { start_label func_name tag } {
 	return -1
     }
 
-    # Delete all breakpoints so that the output of "info breakpoints"
-    # below will only contain a single breakpoint.
+    # Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+    # the output of "info breakpoints" below will only contain a single breakpoint.
     delete_breakpoints
 
     # Place a breakpoint within the function in the header file.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
index 8b59bebfa0f..d3a1fd38ed2 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
@@ -148,8 +148,8 @@ if ![runto_main] {
     return -1
 }
 
-# Delete all breakpoints so that the output of "info breakpoints"
-# below will only contain a single breakpoint.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the output of "info breakpoints" below will only contain a single breakpoint.
 delete_breakpoints
 
 # Place a breakpoint within the function in the header file.
@@ -162,8 +162,8 @@ gdb_test "info breakpoints" \
     ".* in callee at \[^\r\n\]+${srcfile4}:22\\y.*" \
     "check for breakpoint at ${srcfile4}"
 
-# Delete all breakpoints so that the output of "info breakpoints"
-# below will only contain a single breakpoint.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the output of "info breakpoints" below will only contain a single breakpoint.
 delete_breakpoints
 
 # Place a breakpoint within the function in the header file.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
index 9a0dac70ab4..66d9f645cf3 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
@@ -137,8 +137,8 @@ if ![runto_main] {
     return -1
 }
 
-# Delete all breakpoints so that the output of "info breakpoints"
-# below will only contain a single breakpoint.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the output of "info breakpoints" below will only contain a single breakpoint.
 delete_breakpoints
 
 # Place a breakpoint within the function in the header file.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
index 907d5383ba4..1ba346b9758 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
@@ -122,8 +122,8 @@ if ![runto_main] {
     return -1
 }
 
-# Delete all breakpoints so that the output of "info breakpoints"
-# below will only contain a single breakpoint.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the output of "info breakpoints" below will only contain a single breakpoint.
 delete_breakpoints
 
 # Place a breakpoint within the function in the header file.
diff --git a/gdb/testsuite/gdb.guile/scm-breakpoint.exp b/gdb/testsuite/gdb.guile/scm-breakpoint.exp
index 2e38e262379..73e24135254 100644
--- a/gdb/testsuite/gdb.guile/scm-breakpoint.exp
+++ b/gdb/testsuite/gdb.guile/scm-breakpoint.exp
@@ -224,7 +224,7 @@ proc_with_prefix test_bkpt_invisible { } {
     gdb_test "guile (print (breakpoint-visible? ibp))" \
 	"= #f" "check breakpoint invisibility"
     gdb_test "info breakpoints" \
-	"No breakpoints or watchpoints.*" \
+	"No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"check info breakpoints does not show invisible breakpoints"
     gdb_test "maint info breakpoints" \
 	"scm-breakpoint\.c:$ibp_location.*" \
@@ -287,7 +287,7 @@ proc_with_prefix test_bkpt_internal { } {
     gdb_scm_test_silent_cmd "guile (register-breakpoint! wp1)" \
 	"register wp1"
     gdb_test "info breakpoints" \
-	"No breakpoints or watchpoints.*" \
+	"No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"check info breakpoints does not show invisible watchpoint"
     gdb_test "maint info breakpoints" \
 	".*watchpoint.*result.*" \
@@ -511,7 +511,7 @@ proc_with_prefix test_bkpt_temporary { } {
 	".*$srcfile:$ibp_location.*"
     gdb_test "guile (print (breakpoint-temporary? ibp))" "Invalid object: <gdb:breakpoint>.*" \
 	"check temporary breakpoint is deleted after being hit"
-    gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
+    gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"check info breakpoints shows temporary breakpoint is deleted"
 }
 
diff --git a/gdb/testsuite/gdb.linespec/cpexplicit.exp b/gdb/testsuite/gdb.linespec/cpexplicit.exp
index 4e7b462f414..5c93c34ab4a 100644
--- a/gdb/testsuite/gdb.linespec/cpexplicit.exp
+++ b/gdb/testsuite/gdb.linespec/cpexplicit.exp
@@ -31,8 +31,8 @@ namespace eval $testfile {
     # at LOCATION.
     proc test_breakpoint {linespec location} {
 
-	# Delete all breakpoints, set a new breakpoint at LINESPEC,
-	# and attempt to run to it.
+	# Delete all breakpoints, watchpoints, tracepoints, and catchpoints,
+	# set a new breakpoint at LINESPEC, and attempt to run to it.
 	delete_breakpoints
 	gdb_breakpoint $linespec
 	gdb_continue_to_breakpoint $linespec $location
diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
index 6e80931f7c7..625f9cee0fc 100644
--- a/gdb/testsuite/gdb.linespec/explicit.exp
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -33,8 +33,8 @@ namespace eval $testfile {
     proc test_breakpoint {linespec location} {
 
 	set testname "set breakpoint at \"$linespec\""
-	# Delete all breakpoints, set a new breakpoint at LINESPEC,
-	# and attempt to run to it.
+	# Delete all breakpoints, watchpoints, tracepoints, and catchpoints,
+	# set a new breakpoint at LINESPEC, and attempt to run to it.
 	delete_breakpoints
 	if {[gdb_breakpoint $linespec]} {
 	    pass $testname
diff --git a/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp b/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp
index 54f63d6d797..79fcf9f68b4 100644
--- a/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp
+++ b/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp
@@ -34,7 +34,7 @@ set remote_python_file [gdb_remote_download host \
 mi_clean_restart $binfile
 mi_runto_main
 
-# Delete all breakpoints.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints.
 mi_delete_breakpoints
 
 # Create a breakpoint.  At this point the breakpoint is global, but
diff --git a/gdb/testsuite/gdb.mi/mi-return.exp b/gdb/testsuite/gdb.mi/mi-return.exp
index ce4e9710671..dafa1504a1a 100644
--- a/gdb/testsuite/gdb.mi/mi-return.exp
+++ b/gdb/testsuite/gdb.mi/mi-return.exp
@@ -50,7 +50,7 @@ mi_runto callee4
 
 mi_gdb_test "205-break-delete" \
 	"205\\^done.*" \
-	"delete all breakpoints"
+	"delete all breakpoints, watchpoints, tracepoints, and catchpoints"
 
 test_return_simple
 
diff --git a/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp
index 8245f06c1b7..715e0f7e804 100644
--- a/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp
+++ b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp
@@ -56,7 +56,7 @@ foreach_mi_ui_mode mode {
     # trigger an assertion.
     if {$mode eq "separate"} {
 	with_spawn_id $gdb_main_spawn_id {
-	    gdb_test "info breakpoints" "No breakpoints or watchpoints\\." \
+	    gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints\\." \
 		"check CLI 'info breakpoints' when there are no breakpoints"
 	}
     }
diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
index 84326100469..5cc451b0ecc 100644
--- a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
+++ b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
@@ -176,4 +176,4 @@ gdb_test "remove-inferiors 1" \
 
 # Now check 'info breakpoints' to ensure the breakpoint is gone.
 gdb_test "info breakpoints $bp_number" \
-    "No breakpoint or watchpoint matching '$bp_number'\\."
+    "No breakpoint, watchpoint, tracepoint, or catchpoint matching '$bp_number'\\."
diff --git a/gdb/testsuite/gdb.opt/inline-small-func.exp b/gdb/testsuite/gdb.opt/inline-small-func.exp
index c71dfb9cd8f..9090e23dd61 100644
--- a/gdb/testsuite/gdb.opt/inline-small-func.exp
+++ b/gdb/testsuite/gdb.opt/inline-small-func.exp
@@ -45,8 +45,8 @@ if ![runto_main] {
     return -1
 }
 
-# Delete all breakpoints so that the output of "info breakpoints"
-# below will only contain a single breakpoint.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the output of "info breakpoints" below will only contain a single breakpoint.
 delete_breakpoints
 
 # Place a breakpoint within the function in the header file.
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
index 67da48d2f48..ef4c929fb15 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -333,7 +333,7 @@ proc_with_prefix test_bkpt_invisible { } {
 	"py-breakpoint\.c:$ibp_location*" "Check breakpoint location 2"
     gdb_test "python print (ilist\[0\].visible)" \
 	"False" "Check breakpoint visibility 2"
-    gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
+    gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"Check info breakpoints does not show invisible breakpoints"
     gdb_test "maint info breakpoints" \
 	"py-breakpoint\.c:$ibp_location.*" \
@@ -428,7 +428,7 @@ proc_with_prefix test_bkpt_internal { } {
     gdb_py_test_silent_cmd  "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE, internal=True )" \
 	"Set watchpoint" 0
     gdb_test "info breakpoints" \
-	"No breakpoints or watchpoints.*" \
+	"No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"Check info breakpoints does not show invisible breakpoints"
     gdb_test "maint info breakpoints" \
 	".*watchpoint.*result.*" \
@@ -591,7 +591,7 @@ proc_with_prefix test_bkpt_temporary { } {
 	"Check temporary stop callback executed before deletion."
     gdb_test "python print (ibp.temporary)" "RuntimeError: Breakpoint 2 is invalid.*" \
 	"Check temporary breakpoint is deleted after being hit"
-    gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
+    gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"Check info breakpoints shows temporary breakpoint is deleted"
 }
 
@@ -600,7 +600,7 @@ proc_with_prefix test_bkpt_temporary { } {
 proc_with_prefix test_bkpt_address {} {
     global gdb_prompt decimal srcfile
 
-    # Delete all breakpoints
+    # Delete all breakpoints, watchpoints, tracepoints, and catchpoints
     delete_breakpoints
 
     gdb_test "python gdb.Breakpoint(\"*main\")" \
diff --git a/gdb/testsuite/gdb.reverse/ppc_record_test_isa_3_1.exp b/gdb/testsuite/gdb.reverse/ppc_record_test_isa_3_1.exp
index 0306a9de7ca..06257f9471e 100644
--- a/gdb/testsuite/gdb.reverse/ppc_record_test_isa_3_1.exp
+++ b/gdb/testsuite/gdb.reverse/ppc_record_test_isa_3_1.exp
@@ -105,7 +105,7 @@ gdb_test_no_output "set exec-direction forward" "start forward test3"
 gdb_test "record stop" ".*Process record is stopped.*" "stopped recording 2"
 set test_del_bkpts "delete breakpoints, answer prompt 2"
 
-# Delete all breakpoints and catchpoints.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints.
 delete_breakpoints
 
 gdb_test_no_output "record" "start recording test2"
diff --git a/gdb/testsuite/gdb.threads/continue-pending-after-query.exp b/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
index 41487c9a845..7f2a60a673f 100644
--- a/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
+++ b/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
@@ -67,7 +67,7 @@ proc test {} {
     set test "delete breakpoints, answer prompt"
     set saw_prompt 0
     gdb_test_multiple "delete breakpoints" $test {
-	-re "Delete all breakpoints.*y or n.*$" {
+	-re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*y or n.*$" {
 	    set saw_prompt 1
 	    send_gdb "y\n"
 	    exp_continue
diff --git a/gdb/testsuite/gdb.threads/continue-pending-status.exp b/gdb/testsuite/gdb.threads/continue-pending-status.exp
index f998625a00c..32da7ec2d52 100644
--- a/gdb/testsuite/gdb.threads/continue-pending-status.exp
+++ b/gdb/testsuite/gdb.threads/continue-pending-status.exp
@@ -89,9 +89,9 @@ for {set i 0} {$i < $attempts} {incr i} {
 	    "Switching to thread $thread .*" \
 	    "switch to non-event thread"
 
-	# Delete all breakpoints so that continuing doesn't switch
-	# back to the event thread to do a step-over, which would mask
-	# away the original bug, which depended on the event thread
+	# Delete all breakpoints, watchpoints, tracepoints, and catchpoints
+	# so that continuing doesn't switch back to the event thread to do a step-over,
+	# which would mask away the original bug, which depended on the event thread
 	# still having TARGET_STOPPED_BY_SW_BREAKPOINT stop_reason.
 	delete_breakpoints
 
diff --git a/gdb/testsuite/gdb.threads/thread_check.exp b/gdb/testsuite/gdb.threads/thread_check.exp
index ba80a8971a5..83fa86dc359 100644
--- a/gdb/testsuite/gdb.threads/thread_check.exp
+++ b/gdb/testsuite/gdb.threads/thread_check.exp
@@ -28,7 +28,7 @@
 # - create 2 breakpoints #1 main() #2 tf() (the thread function)
 # - run gdb till #1 main() breakpoint is reached
 # - continue to breakpoint #2 tf()
-# - delete all breakpoints 
+# - delete all breakpoints, watchpoints, tracepoints, and catchpoints
 # - exit gdb.
 
 
@@ -71,7 +71,7 @@ gdb_test "backtrace" \
 
 
 #
-# delete all breakpoints
+# delete all breakpoints, watchpoints, tracepoints, and catchpoints
 #
 delete_breakpoints
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 9a906f0f349..7357d56f89a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -373,10 +373,10 @@ proc delete_breakpoints {} {
     #
     set timeout 100
 
-    set msg "delete all breakpoints in delete_breakpoints"
+    set msg "delete all breakpoints, watchpoints, tracepoints, and catchpoints in delete_breakpoints"
     set deleted 0
     gdb_test_multiple "delete breakpoints" "$msg" {
-	-re "Delete all breakpoints.*y or n.*$" {
+	-re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*y or n.*$" {
 	    send_gdb "y\n" answer
 	    exp_continue
 	}
@@ -390,7 +390,7 @@ proc delete_breakpoints {} {
 	set deleted 0
 	set msg "info breakpoints"
 	gdb_test_multiple $msg $msg {
-	    -re "No breakpoints or watchpoints..*$gdb_prompt $" {
+	    -re "No breakpoints, watchpoints, tracepoints, or catchpoints..*$gdb_prompt $" {
 		set deleted 1
 	    }
 	    -re "$gdb_prompt $" {
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 001e4ee0970..b3a27efb155 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -355,25 +355,25 @@ proc mi_delete_breakpoints {} {
 # FIXME: The mi operation won't accept a prompt back and will use the 'all' arg
     send_gdb "102-break-delete\n"
     gdb_expect 30 {
-	 -re "Delete all breakpoints.*y or n.*$" {
+	 -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*y or n.*$" {
 	    send_gdb "y\n"
 	    exp_continue
 	 }
 	 -re "102-break-delete\r\n102\\\^done\r\n$mi_gdb_prompt$" {
 	     # This happens if there were no breakpoints
 	 }
-	 timeout { perror "Delete all breakpoints in mi_delete_breakpoints (timeout)" ; return }
+	 timeout { perror "Delete all breakpoints, watchpoints, tracepoints, and catchpoints in mi_delete_breakpoints (timeout)" ; return }
     }
 
-# The correct output is not "No breakpoints or watchpoints." but an
+# The correct output is not "No breakpoints, watchpoints, tracepoints, or catchpoints." but an
 # empty BreakpointTable. Also, a query is not acceptable with mi.
     send_gdb "103-break-list\n"
     gdb_expect 30 {
 	 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{\}\r\n$mi_gdb_prompt$" {}
 	 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[\\\]\}\r\n$mi_gdb_prompt$" {}
-	 -re "103-break-list\r\n103\\\^doneNo breakpoints or watchpoints.\r\n\r\n$mi_gdb_prompt$" {warning "Unexpected console text received"}
+	 -re "103-break-list\r\n103\\\^doneNo breakpoints, watchpoints, tracepoints, or catchpoints.\r\n\r\n$mi_gdb_prompt$" {warning "Unexpected console text received"}
 	 -re "$mi_gdb_prompt$" { perror "Breakpoints not deleted" ; return }
-	 -re "Delete all breakpoints.*or n.*$" {
+	 -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*or n.*$" {
 	    warning "Unexpected prompt for breakpoints deletion"
 	    send_gdb "y\n"
 	    exp_continue
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index e2cb13feef0..c23bb46c666 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -1999,7 +1999,8 @@ check_mem_write (CORE_ADDR mem_addr, unsigned char *buf,
     delete_disabled_breakpoints ();
 }
 
-/* Delete all breakpoints, and un-insert them from the inferior.  */
+/* Delete all breakpoints, watchpoints, tracepoints, and catchpoints,
+   and un-insert them from the inferior.  */
 
 void
 delete_all_breakpoints (void)
@@ -2021,8 +2022,8 @@ mark_breakpoints_out (struct process_info *proc)
     raw_bp->inserted = 0;
 }
 
-/* Release all breakpoints, but do not try to un-insert them from the
-   inferior.  */
+/* Release all breakpoints, watchpoints, tracepoints, and catchpoints,
+   but do not try to un-insert them from the inferior.  */
 
 void
 free_all_breakpoints (struct process_info *proc)
diff --git a/gdbserver/mem-break.h b/gdbserver/mem-break.h
index 99689c9998c..36521184226 100644
--- a/gdbserver/mem-break.h
+++ b/gdbserver/mem-break.h
@@ -216,7 +216,8 @@ void check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len);
 void check_mem_write (CORE_ADDR mem_addr,
 		      unsigned char *buf, const unsigned char *myaddr, int mem_len);
 
-/* Delete all breakpoints.  */
+/* Delete all breakpoints, watchpoints, tracepoints, and catchpoints,
+   and un-insert them from the inferior.  */
 
 void delete_all_breakpoints (void);
 
@@ -224,8 +225,8 @@ void delete_all_breakpoints (void);
 
 void mark_breakpoints_out (struct process_info *proc);
 
-/* Delete all breakpoints, but do not try to un-insert them from the
-   inferior.  */
+/* Delete all breakpoints, watchpoints, tracepoints, and catchpoints,
+   but do not try to un-insert them from the inferior.  */
 
 void free_all_breakpoints (struct process_info *proc);
 
-- 
2.42.0


^ permalink raw reply	[relevance 6%]

* [PATCH v4] gdb: Modify the output of "info breakpoints" and "delete breakpoints"
@ 2024-02-22  3:36  6% Tiezhu Yang
  0 siblings, 0 replies; 200+ results
From: Tiezhu Yang @ 2024-02-22  3:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner, Tom Tromey, Bruno Larsen, Eli Zaretskii

The output of "info breakpoints" includes breakpoint, watchpoint,
tracepoint, and catchpoint if they are created, so it should show
all the four types are deleted in the output of "info breakpoints"
to report empty list after "delete breakpoints".

It should also change the output of "delete breakpoints" to make it
clear that watchpoints, tracepoints, and catchpoints are also being
deleted. This is suggested by Guinevere Larsen, thank you.

$ make check-gdb TESTS="gdb.base/access-mem-running.exp"
$ gdb/gdb gdb/testsuite/outputs/gdb.base/access-mem-running/access-mem-running
[...]
(gdb) break main
Breakpoint 1 at 0x12000073c: file /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c, line 32.
(gdb) watch global_counter
Hardware watchpoint 2: global_counter
(gdb) trace maybe_stop_here
Tracepoint 3 at 0x12000071c: file /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c, line 27.
(gdb) catch fork
Catchpoint 4 (fork)
(gdb) info breakpoints
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x000000012000073c in main at /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c:32
2       hw watchpoint  keep y                      global_counter
3       tracepoint     keep y   0x000000012000071c in maybe_stop_here at /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c:27
	not installed on target
4       catchpoint     keep y                      fork

Without this patch:

(gdb) delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) info breakpoints 3
No breakpoint or watchpoint matching '3'.

With this patch:

(gdb) delete breakpoints
Delete all breakpoints, watchpoints, tracepoints, and catchpoints? (y or n) y
(gdb) info breakpoints
No breakpoints, watchpoints, tracepoints, or catchpoints.
(gdb) info breakpoints 3
No breakpoint, watchpoint, tracepoint, or catchpoint matching '3'.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---

v4: make the lines shorter than 80 columns

 gdb/breakpoint.c                              | 25 +++++++-----
 gdb/doc/gdb.texinfo                           | 38 ++++++++++---------
 gdb/ppc-linux-nat.c                           |  4 +-
 gdb/testsuite/gdb.arch/i386-dr3-watch.exp     |  2 +-
 .../gdb.base/annota-input-while-running.exp   |  2 +-
 gdb/testsuite/gdb.base/break-unload-file.exp  |  4 +-
 gdb/testsuite/gdb.base/break.exp              | 10 ++---
 .../gdb.base/breakpoint-in-ro-region.exp      |  2 +-
 .../continue-after-aborted-step-over.exp      |  2 +-
 gdb/testsuite/gdb.base/default.exp            |  2 +-
 gdb/testsuite/gdb.base/del.exp                |  4 +-
 gdb/testsuite/gdb.base/ena-dis-br.exp         |  2 +-
 gdb/testsuite/gdb.base/foll-fork.exp          |  6 +--
 gdb/testsuite/gdb.base/hbreak-unmapped.exp    |  4 +-
 gdb/testsuite/gdb.base/hbreak2.exp            |  2 +-
 gdb/testsuite/gdb.base/help.exp               |  3 +-
 gdb/testsuite/gdb.base/new-ui.exp             |  8 ++--
 gdb/testsuite/gdb.base/save-bp.exp            |  8 ++--
 gdb/testsuite/gdb.base/sepdebug.exp           |  2 +-
 gdb/testsuite/gdb.base/server-del-break.exp   |  4 +-
 gdb/testsuite/gdb.cp/annota2.exp              |  4 +-
 gdb/testsuite/gdb.cp/annota3.exp              |  4 +-
 gdb/testsuite/gdb.cp/ovldbreak.exp            | 10 ++---
 gdb/testsuite/gdb.cp/save-bp-qualified.exp    |  4 +-
 .../gdb.dwarf2/dw2-inline-header-1.exp        |  4 +-
 .../gdb.dwarf2/dw2-inline-header-2.exp        |  8 ++--
 .../gdb.dwarf2/dw2-inline-header-3.exp        |  4 +-
 .../gdb.dwarf2/dw2-inline-small-func.exp      |  4 +-
 gdb/testsuite/gdb.guile/scm-breakpoint.exp    |  6 +--
 gdb/testsuite/gdb.linespec/cpexplicit.exp     |  4 +-
 gdb/testsuite/gdb.linespec/explicit.exp       |  4 +-
 gdb/testsuite/gdb.mi/mi-py-modify-bp.exp      |  2 +-
 gdb/testsuite/gdb.mi/mi-return.exp            |  2 +-
 .../gdb.mi/mi-thread-specific-bp.exp          |  2 +-
 .../gdb.multi/inferior-specific-bp.exp        |  2 +-
 gdb/testsuite/gdb.opt/inline-small-func.exp   |  4 +-
 gdb/testsuite/gdb.python/py-breakpoint.exp    |  8 ++--
 .../gdb.reverse/ppc_record_test_isa_3_1.exp   |  2 +-
 .../continue-pending-after-query.exp          |  2 +-
 .../gdb.threads/continue-pending-status.exp   |  6 +--
 gdb/testsuite/gdb.threads/thread_check.exp    |  4 +-
 gdb/testsuite/lib/gdb.exp                     |  6 +--
 gdb/testsuite/lib/mi-support.exp              | 10 ++---
 gdbserver/mem-break.cc                        |  7 ++--
 gdbserver/mem-break.h                         |  7 ++--
 45 files changed, 132 insertions(+), 122 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 5f05657a8b3..102bd7fad41 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7080,10 +7080,11 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
       if (!filter)
 	{
 	  if (bp_num_list == NULL || *bp_num_list == '\0')
-	    uiout->message ("No breakpoints or watchpoints.\n");
+	    uiout->message ("No breakpoints, watchpoints, tracepoints, "
+			    "or catchpoints.\n");
 	  else
-	    uiout->message ("No breakpoint or watchpoint matching '%s'.\n",
-			    bp_num_list);
+	    uiout->message ("No breakpoint, watchpoint, tracepoint, "
+			    "or catchpoint matching '%s'.\n", bp_num_list);
 	}
     }
   else
@@ -12699,9 +12700,9 @@ delete_command (const char *arg, int from_tty)
     {
       int breaks_to_delete = 0;
 
-      /* Delete all breakpoints if no argument.  Do not delete
-	 internal breakpoints, these have to be deleted with an
-	 explicit breakpoint number argument.  */
+      /* Delete all breakpoints, watchpoints, tracepoints, and catchpoints
+	 if no argument.  Do not delete internal breakpoints, these have to
+	 be deleted with an explicit breakpoint number argument.  */
       for (breakpoint &b : all_breakpoints ())
 	if (user_breakpoint_p (&b))
 	  {
@@ -12711,7 +12712,9 @@ delete_command (const char *arg, int from_tty)
 
       /* Ask user only if there are some breakpoints to delete.  */
       if (!from_tty
-	  || (breaks_to_delete && query (_("Delete all breakpoints? "))))
+	  || (breaks_to_delete
+	      && query (_("Delete all breakpoints, watchpoints, tracepoints, "
+			  "and catchpoints? "))))
 	for (breakpoint &b : all_breakpoints_safe ())
 	  if (user_breakpoint_p (&b))
 	    delete_breakpoint (&b);
@@ -14236,7 +14239,7 @@ delete_trace_command (const char *arg, int from_tty)
     {
       int breaks_to_delete = 0;
 
-      /* Delete all breakpoints if no argument.
+      /* Delete all tracepoints if no argument.
 	 Do not delete internal or call-dummy breakpoints, these
 	 have to be deleted with an explicit breakpoint number 
 	 argument.  */
@@ -14830,7 +14833,8 @@ This command may be abbreviated \"disable\"."),
 Delete all or some breakpoints.\n\
 Usage: delete [BREAKPOINTNUM]...\n\
 Arguments are breakpoint numbers with spaces in between.\n\
-To delete all breakpoints, give no argument.\n\
+To delete all breakpoints, watchpoints, tracepoints, and catchpoints,\n\
+give no argument.\n\
 \n\
 Also a prefix command for deletion of other GDB objects."),
 		      &deletelist, 1, &cmdlist);
@@ -14841,7 +14845,8 @@ Also a prefix command for deletion of other GDB objects."),
 Delete all or some breakpoints or auto-display expressions.\n\
 Usage: delete breakpoints [BREAKPOINTNUM]...\n\
 Arguments are breakpoint numbers with spaces in between.\n\
-To delete all breakpoints, give no argument.\n\
+To delete all breakpoints, watchpoints, tracepoints, and catchpoints,\n\
+give no argument.\n\
 This command may be abbreviated \"delete\"."),
 	   &deletelist);
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 79805486dd6..654c4824ebf 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -4343,7 +4343,8 @@ running or not, what process it is, and why it stopped.
 @end table
 
 @menu
-* Breakpoints::                 Breakpoints, watchpoints, and catchpoints
+* Breakpoints::                 Breakpoints, watchpoints, tracepoints,
+				and catchpoints
 * Continuing and Stepping::     Resuming execution
 * Skipping Over Functions and Files::
                                 Skipping over functions and files
@@ -4721,15 +4722,15 @@ optionally be surrounded by spaces.
 @cindex @code{$_} and @code{info breakpoints}
 @item info breakpoints @r{[}@var{list}@dots{}@r{]}
 @itemx info break @r{[}@var{list}@dots{}@r{]}
-Print a table of all breakpoints, watchpoints, and catchpoints set and
-not deleted.  Optional argument @var{n} means print information only
-about the specified breakpoint(s) (or watchpoint(s) or catchpoint(s)).
+Print a table of all breakpoints, watchpoints, tracepoints, and catchpoints set
+and not deleted.  Optional argument @var{n} means print information only about
+the specified breakpoint(s) (or watchpoint(s) or tracepoint(s) or catchpoint(s)).
 For each breakpoint, following columns are printed:
 
 @table @emph
 @item Breakpoint Numbers
 @item Type
-Breakpoint, watchpoint, or catchpoint.
+Breakpoint, watchpoint, tracepoint, or catchpoint.
 @item Disposition
 Whether the breakpoint is marked to be disabled or deleted when hit.
 @item Enabled or Disabled
@@ -5650,10 +5651,11 @@ in @ref{Location Specifications}.
 @kindex delete
 @kindex d @r{(@code{delete})}
 @item delete @r{[}breakpoints@r{]} @r{[}@var{list}@dots{}@r{]}
-Delete the breakpoints, watchpoints, or catchpoints of the breakpoint
-list specified as argument.  If no argument is specified, delete all
-breakpoints (@value{GDBN} asks confirmation, unless you have @code{set
-confirm off}).  You can abbreviate this command as @code{d}.
+Delete the breakpoints, watchpoints, tracepoints, or catchpoints of the
+breakpoint list specified as argument.  If no argument is specified, delete
+all breakpoints, watchpoints, tracepoints, and catchpoints (@value{GDBN} asks
+confirmation, unless you have @code{set confirm off}).  You can abbreviate this
+command as @code{d}.
 @end table
 
 @node Disabling
@@ -5665,10 +5667,10 @@ prefer to @dfn{disable} it.  This makes the breakpoint inoperative as if
 it had been deleted, but remembers the information on the breakpoint so
 that you can @dfn{enable} it again later.
 
-You disable and enable breakpoints, watchpoints, and catchpoints with
-the @code{enable} and @code{disable} commands, optionally specifying
-one or more breakpoint numbers as arguments.  Use @code{info break} to
-print a list of all breakpoints, watchpoints, and catchpoints if you
+You disable and enable breakpoints, watchpoints, tracepoints, and catchpoints
+with the @code{enable} and @code{disable} commands, optionally specifying
+one or more breakpoint numbers as arguments.  Use @code{info break} to print
+a list of all breakpoints, watchpoints, tracepoints, and catchpoints if you
 do not know which numbers to use.
 
 Disabling and enabling a breakpoint that has multiple locations
@@ -5696,7 +5698,7 @@ set with the @code{tbreak} command starts out in this state.
 @end itemize
 
 You can use the following commands to enable or disable breakpoints,
-watchpoints, and catchpoints:
+watchpoints, tracepoints, and catchpoints:
 
 @table @code
 @kindex disable
@@ -5874,7 +5876,7 @@ is decremented each time.  @xref{Convenience Vars, ,Convenience
 Variables}.
 @end table
 
-Ignore counts apply to breakpoints, watchpoints, and catchpoints.
+Ignore counts apply to breakpoints, watchpoints, tracepoints, and catchpoints.
 
 
 @node Break Commands
@@ -32987,8 +32989,8 @@ list of thread groups to which this breakpoint applies
 number of times the breakpoint has been hit
 @end table
 
-If there are no breakpoints or watchpoints, the @code{BreakpointTable}
-@code{body} field is an empty list.
+If there are no breakpoints, watchpoints, tracepoints, or catchpoints,
+the @code{BreakpointTable} @code{body} field is an empty list.
 
 @subsubheading @value{GDBN} Command
 
@@ -33980,7 +33982,7 @@ to execute until it reaches a debugger stop event.  If the
 it reaches a stop event.  Stop events may include
 @itemize @bullet
 @item
-breakpoints or watchpoints
+breakpoints, watchpoints, tracepoints, or catchpoints
 @item
 signals or exceptions
 @item
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 0adaa6dbed6..028422bb1e8 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2358,8 +2358,8 @@ ppc_linux_nat_target::can_use_watchpoint_cond_accel (void)
 
   auto process_it = m_process_info.find (inferior_ptid.pid ());
 
-  /* No breakpoints or watchpoints have been requested for this process,
-     we have at least one free DVC register.  */
+  /* No breakpoints, watchpoints, tracepoints, or catchpoints have been
+     requested for this process, we have at least one free DVC register.  */
   if (process_it == m_process_info.end ())
     return true;
 
diff --git a/gdb/testsuite/gdb.arch/i386-dr3-watch.exp b/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
index e2c89b879ad..84b3806d234 100644
--- a/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
+++ b/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
@@ -76,7 +76,7 @@ gdb_test_multiple "watch gap1" "$test" {
 gdb_test "delete" \
     "" \
     "delete all watchpoints" \
-    {Delete all breakpoints\? \(y or n\) $} \
+    {Delete all breakpoints, watchpoints, tracepoints, and catchpoints\? \(y or n\) $} \
     "y"
 
 # If debug registers were left occupied by mistake, we'll fail to set
diff --git a/gdb/testsuite/gdb.base/annota-input-while-running.exp b/gdb/testsuite/gdb.base/annota-input-while-running.exp
index 1d1f523672d..46256226f44 100644
--- a/gdb/testsuite/gdb.base/annota-input-while-running.exp
+++ b/gdb/testsuite/gdb.base/annota-input-while-running.exp
@@ -57,7 +57,7 @@ gdb_annota_test "set annotate 2" ".*" "annotation set at level 2"
 
 set test "delete breakpoints"
 gdb_test_multiple "delete" $test {
-    -re "Delete all breakpoints. .y or n." {
+    -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints. .y or n." {
 	send_gdb "y\n"
 	exp_continue
     }
diff --git a/gdb/testsuite/gdb.base/break-unload-file.exp b/gdb/testsuite/gdb.base/break-unload-file.exp
index 2641feccec9..2d62cc51cec 100644
--- a/gdb/testsuite/gdb.base/break-unload-file.exp
+++ b/gdb/testsuite/gdb.base/break-unload-file.exp
@@ -121,8 +121,8 @@ proc test_break { initial_load always_inserted break_command } {
 	# re-insert, GDB would fill the shadow buffer with a
 	# breakpoint instruction).  Avoid delete_breakpoints as that
 	# doesn't record a pass/fail.
-	gdb_test "delete" "" "delete all breakpoints" \
-	    "Delete all breakpoints.*y or n.*$" "y"
+	gdb_test "delete" "" "delete all breakpoints, watchpoints, tracepoints, and catchpoints" \
+	    "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*y or n.*$" "y"
 
 	# Re-add symbols back.
 	set test "file \$binfile"
diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index eda486a4945..cdb4c22a034 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -49,17 +49,17 @@ proc_with_prefix test_break {} {
     # for general use elsewhere.
     send_gdb "delete breakpoints\n"
     gdb_expect {
-	 -re "Delete all breakpoints.*$" {
+	 -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*$" {
 		send_gdb "y\n"
 		gdb_expect {
 		    -re "$::gdb_prompt $" {
-			fail "delete all breakpoints when none (unexpected prompt)"
+			fail "delete all breakpoints, watchpoints, tracepoints, and catchpoints when none (unexpected prompt)"
 		    }
-		    timeout	{ fail "delete all breakpoints when none (timeout after unexpected prompt)" }
+		    timeout	{ fail "delete all breakpoints, watchpoints, tracepoints, and catchpoints when none (timeout after unexpected prompt)" }
 		}
 	    }
-	 -re ".*$::gdb_prompt $"       { pass "delete all breakpoints when none" }
-	timeout	            { fail "delete all breakpoints when none (timeout)" }
+	 -re ".*$::gdb_prompt $"       { pass "delete all breakpoints, watchpoints, tracepoints, and catchpoints when none" }
+	timeout	            { fail "delete all breakpoints, watchpoints, tracepoints, and catchpoints when none (timeout)" }
     }
 
     # test break at function
diff --git a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
index 48fc75cdfc8..b0a51961870 100644
--- a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
+++ b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
@@ -234,7 +234,7 @@ proc test_single_step { always_inserted auto_hw } {
     }
 
     gdb_test "maint info breakpoints 0" \
-	"No breakpoint or watchpoint matching '0'\." \
+	"No breakpoint, watchpoint, tracepoint, or catchpoint matching '0'\." \
 	"single-step breakpoint is not left behind"
 
     # Confirm the thread really advanced.
diff --git a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
index 4aefc446ab7..d5861357585 100644
--- a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
+++ b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
@@ -27,7 +27,7 @@
 #
 #  Command aborted.
 #  delete breakpoints
-#  Delete all breakpoints? (y or n) y
+#  Delete all breakpoints, watchpoints, tracepoints, and catchpoints? (y or n) y
 #  (gdb) b function
 #  Breakpoint 3 at 0x40048b: file test.c, line 33.
 #  continue
diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 98dad7cb309..291722e62c8 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -265,7 +265,7 @@ gdb_test "info args" "No frame selected."
 #test info bogus-gdb-command
 gdb_test "info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\".  Try \"help info\".*"
 #test info breakpoints
-gdb_test "info breakpoints" "No breakpoints or watchpoints."
+gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints."
 #test info copying
 # The license text is very big, so it may overwhelm Expect's output buffer
 # and cause the test to fail occasionally.  To avoid this problem, verify
diff --git a/gdb/testsuite/gdb.base/del.exp b/gdb/testsuite/gdb.base/del.exp
index 2a715e8e775..58937de656f 100644
--- a/gdb/testsuite/gdb.base/del.exp
+++ b/gdb/testsuite/gdb.base/del.exp
@@ -35,7 +35,7 @@ proc test_delete_alias { alias } {
              "remove all breakpoints"
 
     gdb_test "info break" \
-             "No breakpoints or watchpoints." \
+	     "No breakpoints, watchpoints, tracepoints, or catchpoints." \
              "info break after clearing breakpoints"
 
 
@@ -50,7 +50,7 @@ proc test_delete_alias { alias } {
              "Remove last breakpoint"
 
     gdb_test "info break" \
-             "No breakpoints or watchpoints." \
+	     "No breakpoints, watchpoints, tracepoints, or catchpoints." \
              "info break after removing break on main"
 }
 
diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp
index e7259f672de..924133e0d90 100644
--- a/gdb/testsuite/gdb.base/ena-dis-br.exp
+++ b/gdb/testsuite/gdb.base/ena-dis-br.exp
@@ -140,7 +140,7 @@ gdb_test "continue" \
     "continue to auto-deleted break marker3"
 
 gdb_test "info break $bp" \
-    ".*No breakpoint or watchpoint matching.*" \
+    ".*No breakpoint, watchpoint, tracepoint, or catchpoint matching.*" \
     "info auto-deleted break marker3"
 
 # Verify that we can set a breakpoint and manually disable it (we've
diff --git a/gdb/testsuite/gdb.base/foll-fork.exp b/gdb/testsuite/gdb.base/foll-fork.exp
index abbbeece6bd..ecf2111d4fd 100644
--- a/gdb/testsuite/gdb.base/foll-fork.exp
+++ b/gdb/testsuite/gdb.base/foll-fork.exp
@@ -289,7 +289,7 @@ proc_with_prefix catch_fork_child_follow {second_inferior} {
     gdb_test "delete breakpoints" \
 	"" \
 	"set follow-fork child, cleanup" \
-	"Delete all breakpoints. \\(y or n\\) $" \
+	"Delete all breakpoints, watchpoints, tracepoints, and catchpoints. \\(y or n\\) $" \
 	"y"
 }
 
@@ -316,7 +316,7 @@ proc_with_prefix catch_fork_unpatch_child {} {
 	"Catchpoint \[0-9\]* \\(forked process \[0-9\]*\\),.*" \
 	"unpatch child, catch fork"
 
-    # Delete all breakpoints and catchpoints.
+    # Delete all breakpoints, watchpoints, tracepoints, and catchpoints.
     delete_breakpoints
 
     # Force $srcfile as the current GDB source can be in glibc sourcetree.
@@ -393,7 +393,7 @@ proc_with_prefix tcatch_fork_parent_follow {} {
     gdb_test "delete breakpoints" \
 	"" \
 	"set follow-fork parent, cleanup" \
-	"Delete all breakpoints. \\(y or n\\) $" \
+	"Delete all breakpoints, watchpoints, tracepoints, and catchpoints. \\(y or n\\) $" \
 	"y"
 }
 
diff --git a/gdb/testsuite/gdb.base/hbreak-unmapped.exp b/gdb/testsuite/gdb.base/hbreak-unmapped.exp
index fd88f37f098..ccb4b20c458 100644
--- a/gdb/testsuite/gdb.base/hbreak-unmapped.exp
+++ b/gdb/testsuite/gdb.base/hbreak-unmapped.exp
@@ -71,5 +71,5 @@ gdb_test "info break" "hw breakpoint.*y.*0x0\+\[ \t\]\+" \
 gdb_test_no_output "delete \$bpnum" "" "delete" \
     "delete hw breakpoint"
 
-gdb_test "info break" "No breakpoints or watchpoints\." \
-    "info break shows no breakpoints"
+gdb_test "info break" "No breakpoints, watchpoints, tracepoints, or catchpoints\." \
+    "info break shows no breakpoints, watchpoints, tracepoints, or catchpoints"
diff --git a/gdb/testsuite/gdb.base/hbreak2.exp b/gdb/testsuite/gdb.base/hbreak2.exp
index 211baa2a849..8f5735b790f 100644
--- a/gdb/testsuite/gdb.base/hbreak2.exp
+++ b/gdb/testsuite/gdb.base/hbreak2.exp
@@ -228,7 +228,7 @@ gdb_test "continue" \
     "continue to hardware breakpoint at }"
 
 #
-# Delete all breakpoints so we can start over, course this can be a test too.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so we can start over, course this can be a test too.
 #
 delete_breakpoints
 
diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp
index daa8c4aade8..5ea5c79d3ec 100644
--- a/gdb/testsuite/gdb.base/help.exp
+++ b/gdb/testsuite/gdb.base/help.exp
@@ -89,7 +89,8 @@ set expected_help_delete {
     "Delete all or some breakpoints\.\[\r\n\]+"
     "Usage: delete \\\[BREAKPOINTNUM\\\]...\[\r\n\]+"
     "Arguments are breakpoint numbers with spaces in between\.\[\r\n\]+"
-    "To delete all breakpoints, give no argument\.\[\r\n\]+"
+    "To delete all breakpoints, watchpoints, tracepoints, and catchpoints,\.\[\r\n\]+"
+    "give no argument\.\[\r\n\]+"
     "Also a prefix command for deletion of other GDB objects\.\[\r\n\]+"
 }
 test_prefix_command_help {"d" "delete"} $expected_help_delete "help delete \"d\" abbreviation"
diff --git a/gdb/testsuite/gdb.base/new-ui.exp b/gdb/testsuite/gdb.base/new-ui.exp
index a58d62f9ed1..97166925c1b 100644
--- a/gdb/testsuite/gdb.base/new-ui.exp
+++ b/gdb/testsuite/gdb.base/new-ui.exp
@@ -130,17 +130,17 @@ proc_with_prefix do_test {} {
     # Verify that we get proper queries on the main UI, but that they are
     # auto-answered on secondary UIs.
     with_spawn_id $gdb_main_spawn_id {
-	gdb_test "delete" "" "delete all breakpoint on main console" \
-		 "Delete all breakpoints. .y or n. $" "n"
+	gdb_test "delete" "" "delete all breakpoints, watchpoints, tracepoints, and catchpoints on main console" \
+		 "Delete all breakpoints, watchpoints, tracepoints, and catchpoints. .y or n. $" "n"
     }
     with_spawn_id $extra_spawn_id {
 	# Check output in two stages in order to override
 	# gdb_test_multiple's internal "got interactive prompt" fail
 	# that would otherwise match if the expect buffer happens to
 	# fill with partial output that ends in "(y or n) ".
-	set test "delete all breakpoints on extra console"
+	set test "delete all breakpoints, watchpoints, tracepoints, and catchpoints on extra console"
 	gdb_test_multiple "delete" $test {
-	    -re "Delete all breakpoints. .y or n. " {
+	    -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints. .y or n. " {
 		gdb_test "" \
 		    ".answered Y; input not from terminal." \
 		    $test
diff --git a/gdb/testsuite/gdb.base/save-bp.exp b/gdb/testsuite/gdb.base/save-bp.exp
index ee870101fde..2872d7b2c6c 100644
--- a/gdb/testsuite/gdb.base/save-bp.exp
+++ b/gdb/testsuite/gdb.base/save-bp.exp
@@ -22,8 +22,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile] } {
 if ![runto_main] {
     return -1
 }
-# Delete all breakpoints so that the "runto_main" breakpoint above
-# does not interfere with our testing.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the "runto_main" breakpoint above does not interfere with our testing.
 delete_breakpoints
 
 # Insert a bunch of breakpoints... The goal is to create breakpoints
@@ -64,8 +64,8 @@ clean_restart $testfile
 if ![runto_main] {
     return -1
 }
-# Delete all breakpoints so that the "runto_main" breakpoint above
-# does not interfere with our testing.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the "runto_main" breakpoint above does not interfere with our testing.
 delete_breakpoints
 
 # ... and restore the breakpoints.
diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp
index 4182eb2b6a8..ee9bea2045a 100644
--- a/gdb/testsuite/gdb.base/sepdebug.exp
+++ b/gdb/testsuite/gdb.base/sepdebug.exp
@@ -219,7 +219,7 @@ gdb_test "step" \
     "step onto breakpoint"
 
 #
-# delete all breakpoints so we can start over, course this can be a test too
+# delete all breakpoints, watchpoints, tracepoints, and catchpoints so we can start over, course this can be a test too
 #
 delete_breakpoints
 
diff --git a/gdb/testsuite/gdb.base/server-del-break.exp b/gdb/testsuite/gdb.base/server-del-break.exp
index e18bb7d79c2..db598783d88 100644
--- a/gdb/testsuite/gdb.base/server-del-break.exp
+++ b/gdb/testsuite/gdb.base/server-del-break.exp
@@ -29,10 +29,10 @@ gdb_test "break -q main" \
 
 # Try deleting all breakpoints, using the "server" command prefix.
 # Prefixing the "delete breakpoints" with "server" should turn
-# the confirmation request ("Delete all breakpoints? (y or n)")
+# the confirmation request ("Delete all breakpoints, watchpoints, tracepoints, and catchpoints? (y or n)")
 # off, hence we expect the operation to be executed without output.
 gdb_test_no_output "server delete breakpoints"
 
 # Double-check that the all breakpoints were in fact deleted.
 gdb_test "info break" \
-         "No breakpoints or watchpoints."
+	 "No breakpoints, watchpoints, tracepoints, or catchpoints."
diff --git a/gdb/testsuite/gdb.cp/annota2.exp b/gdb/testsuite/gdb.cp/annota2.exp
index 3cd43bfb069..1b1c26b0d86 100644
--- a/gdb/testsuite/gdb.cp/annota2.exp
+++ b/gdb/testsuite/gdb.cp/annota2.exp
@@ -158,11 +158,11 @@ gdb_test_multiple "continue" "continue until exit" {
 }
 
 #
-# delete all breakpoints
+# delete all breakpoints, watchpoints, tracepoints, and catchpoints
 #
 send_gdb "delete\n"
 gdb_expect {
-  -re ".*Delete all breakpoints. \\(y or n\\) \r\n\032\032query.*$" {
+  -re ".*Delete all breakpoints, watchpoints, tracepoints, and catchpoints. \\(y or n\\) \r\n\032\032query.*$" {
            send_gdb "y\n"
            gdb_expect {
 	     -re "\r\n\032\032post-query\r\n${breakpoints_invalid}$gdb_prompt$" { pass "delete bps" }
diff --git a/gdb/testsuite/gdb.cp/annota3.exp b/gdb/testsuite/gdb.cp/annota3.exp
index 978f3d566a7..e5da031a25c 100644
--- a/gdb/testsuite/gdb.cp/annota3.exp
+++ b/gdb/testsuite/gdb.cp/annota3.exp
@@ -114,11 +114,11 @@ lappend el "\r\n\032\032stopped\r\n"
 gdb_expect_list "continue to exit" "$gdb_prompt$" $el
 
 #
-# delete all breakpoints
+# delete all breakpoints, watchpoints, tracepoints, and catchpoints
 #
 send_gdb "delete\n"
 gdb_expect {
-  -re ".*Delete all breakpoints. \\(y or n\\) \r\n\032\032query.*$" {
+  -re ".*Delete all breakpoints, watchpoints, tracepoints, and catchpoints. \\(y or n\\) \r\n\032\032query.*$" {
            send_gdb "y\n"
            gdb_expect {
 	     -re "\r\n\032\032post-query\r\n$gdb_prompt$" { pass "delete bps" }
diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp
index 01e7724e289..882a83ba8f3 100644
--- a/gdb/testsuite/gdb.cp/ovldbreak.exp
+++ b/gdb/testsuite/gdb.cp/ovldbreak.exp
@@ -309,23 +309,23 @@ with_test_prefix "multiple breakpoints" {
 
 send_gdb "delete breakpoints\n"
 gdb_expect {
-    -re "Delete all breakpoints.* $" {
+    -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.* $" {
         send_gdb "y\n"
         gdb_expect {
             -re ".*$gdb_prompt $" {
-                pass "delete all breakpoints"
+		pass "delete all breakpoints, watchpoints, tracepoints, and catchpoints"
             }
             timeout {
-                fail "delete all breakpoints (timeout)"
+		fail "delete all breakpoints, watchpoints, tracepoints, and catchpoints (timeout)"
             }
         }
     }
     timeout {
-        fail "delete all breakpoints (timeout)"
+	fail "delete all breakpoints, watchpoints, tracepoints, and catchpoints (timeout)"
     }
 }
 
-gdb_test "info breakpoints" "No breakpoints or watchpoints." "breakpoint info (after delete)"
+gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints." "breakpoint info (after delete)"
 
 
 
diff --git a/gdb/testsuite/gdb.cp/save-bp-qualified.exp b/gdb/testsuite/gdb.cp/save-bp-qualified.exp
index 8eb5c98a7f6..3f6ee0fb29f 100644
--- a/gdb/testsuite/gdb.cp/save-bp-qualified.exp
+++ b/gdb/testsuite/gdb.cp/save-bp-qualified.exp
@@ -29,8 +29,8 @@ proc restart {} {
     if ![runto_main] {
 	return 0
     }
-    # Delete all breakpoints so that the "runto_main" breakpoint above
-    # does not interfere with our testing.
+    # Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+    # the "runto_main" breakpoint above does not interfere with our testing.
     delete_breakpoints
 
     return 1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
index 7eaa37ea0b4..5268e7815ad 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
@@ -160,8 +160,8 @@ proc do_test { start_label func_name tag } {
 	return -1
     }
 
-    # Delete all breakpoints so that the output of "info breakpoints"
-    # below will only contain a single breakpoint.
+    # Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+    # the output of "info breakpoints" below will only contain a single breakpoint.
     delete_breakpoints
 
     # Place a breakpoint within the function in the header file.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
index 8b59bebfa0f..d3a1fd38ed2 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
@@ -148,8 +148,8 @@ if ![runto_main] {
     return -1
 }
 
-# Delete all breakpoints so that the output of "info breakpoints"
-# below will only contain a single breakpoint.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the output of "info breakpoints" below will only contain a single breakpoint.
 delete_breakpoints
 
 # Place a breakpoint within the function in the header file.
@@ -162,8 +162,8 @@ gdb_test "info breakpoints" \
     ".* in callee at \[^\r\n\]+${srcfile4}:22\\y.*" \
     "check for breakpoint at ${srcfile4}"
 
-# Delete all breakpoints so that the output of "info breakpoints"
-# below will only contain a single breakpoint.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the output of "info breakpoints" below will only contain a single breakpoint.
 delete_breakpoints
 
 # Place a breakpoint within the function in the header file.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
index 9a0dac70ab4..66d9f645cf3 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
@@ -137,8 +137,8 @@ if ![runto_main] {
     return -1
 }
 
-# Delete all breakpoints so that the output of "info breakpoints"
-# below will only contain a single breakpoint.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the output of "info breakpoints" below will only contain a single breakpoint.
 delete_breakpoints
 
 # Place a breakpoint within the function in the header file.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
index 907d5383ba4..1ba346b9758 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
@@ -122,8 +122,8 @@ if ![runto_main] {
     return -1
 }
 
-# Delete all breakpoints so that the output of "info breakpoints"
-# below will only contain a single breakpoint.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the output of "info breakpoints" below will only contain a single breakpoint.
 delete_breakpoints
 
 # Place a breakpoint within the function in the header file.
diff --git a/gdb/testsuite/gdb.guile/scm-breakpoint.exp b/gdb/testsuite/gdb.guile/scm-breakpoint.exp
index 2e38e262379..73e24135254 100644
--- a/gdb/testsuite/gdb.guile/scm-breakpoint.exp
+++ b/gdb/testsuite/gdb.guile/scm-breakpoint.exp
@@ -224,7 +224,7 @@ proc_with_prefix test_bkpt_invisible { } {
     gdb_test "guile (print (breakpoint-visible? ibp))" \
 	"= #f" "check breakpoint invisibility"
     gdb_test "info breakpoints" \
-	"No breakpoints or watchpoints.*" \
+	"No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"check info breakpoints does not show invisible breakpoints"
     gdb_test "maint info breakpoints" \
 	"scm-breakpoint\.c:$ibp_location.*" \
@@ -287,7 +287,7 @@ proc_with_prefix test_bkpt_internal { } {
     gdb_scm_test_silent_cmd "guile (register-breakpoint! wp1)" \
 	"register wp1"
     gdb_test "info breakpoints" \
-	"No breakpoints or watchpoints.*" \
+	"No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"check info breakpoints does not show invisible watchpoint"
     gdb_test "maint info breakpoints" \
 	".*watchpoint.*result.*" \
@@ -511,7 +511,7 @@ proc_with_prefix test_bkpt_temporary { } {
 	".*$srcfile:$ibp_location.*"
     gdb_test "guile (print (breakpoint-temporary? ibp))" "Invalid object: <gdb:breakpoint>.*" \
 	"check temporary breakpoint is deleted after being hit"
-    gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
+    gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"check info breakpoints shows temporary breakpoint is deleted"
 }
 
diff --git a/gdb/testsuite/gdb.linespec/cpexplicit.exp b/gdb/testsuite/gdb.linespec/cpexplicit.exp
index 4e7b462f414..5c93c34ab4a 100644
--- a/gdb/testsuite/gdb.linespec/cpexplicit.exp
+++ b/gdb/testsuite/gdb.linespec/cpexplicit.exp
@@ -31,8 +31,8 @@ namespace eval $testfile {
     # at LOCATION.
     proc test_breakpoint {linespec location} {
 
-	# Delete all breakpoints, set a new breakpoint at LINESPEC,
-	# and attempt to run to it.
+	# Delete all breakpoints, watchpoints, tracepoints, and catchpoints,
+	# set a new breakpoint at LINESPEC, and attempt to run to it.
 	delete_breakpoints
 	gdb_breakpoint $linespec
 	gdb_continue_to_breakpoint $linespec $location
diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
index 6e80931f7c7..625f9cee0fc 100644
--- a/gdb/testsuite/gdb.linespec/explicit.exp
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -33,8 +33,8 @@ namespace eval $testfile {
     proc test_breakpoint {linespec location} {
 
 	set testname "set breakpoint at \"$linespec\""
-	# Delete all breakpoints, set a new breakpoint at LINESPEC,
-	# and attempt to run to it.
+	# Delete all breakpoints, watchpoints, tracepoints, and catchpoints,
+	# set a new breakpoint at LINESPEC, and attempt to run to it.
 	delete_breakpoints
 	if {[gdb_breakpoint $linespec]} {
 	    pass $testname
diff --git a/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp b/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp
index 54f63d6d797..79fcf9f68b4 100644
--- a/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp
+++ b/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp
@@ -34,7 +34,7 @@ set remote_python_file [gdb_remote_download host \
 mi_clean_restart $binfile
 mi_runto_main
 
-# Delete all breakpoints.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints.
 mi_delete_breakpoints
 
 # Create a breakpoint.  At this point the breakpoint is global, but
diff --git a/gdb/testsuite/gdb.mi/mi-return.exp b/gdb/testsuite/gdb.mi/mi-return.exp
index ce4e9710671..dafa1504a1a 100644
--- a/gdb/testsuite/gdb.mi/mi-return.exp
+++ b/gdb/testsuite/gdb.mi/mi-return.exp
@@ -50,7 +50,7 @@ mi_runto callee4
 
 mi_gdb_test "205-break-delete" \
 	"205\\^done.*" \
-	"delete all breakpoints"
+	"delete all breakpoints, watchpoints, tracepoints, and catchpoints"
 
 test_return_simple
 
diff --git a/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp
index 8245f06c1b7..715e0f7e804 100644
--- a/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp
+++ b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp
@@ -56,7 +56,7 @@ foreach_mi_ui_mode mode {
     # trigger an assertion.
     if {$mode eq "separate"} {
 	with_spawn_id $gdb_main_spawn_id {
-	    gdb_test "info breakpoints" "No breakpoints or watchpoints\\." \
+	    gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints\\." \
 		"check CLI 'info breakpoints' when there are no breakpoints"
 	}
     }
diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
index 84326100469..5cc451b0ecc 100644
--- a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
+++ b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
@@ -176,4 +176,4 @@ gdb_test "remove-inferiors 1" \
 
 # Now check 'info breakpoints' to ensure the breakpoint is gone.
 gdb_test "info breakpoints $bp_number" \
-    "No breakpoint or watchpoint matching '$bp_number'\\."
+    "No breakpoint, watchpoint, tracepoint, or catchpoint matching '$bp_number'\\."
diff --git a/gdb/testsuite/gdb.opt/inline-small-func.exp b/gdb/testsuite/gdb.opt/inline-small-func.exp
index c71dfb9cd8f..9090e23dd61 100644
--- a/gdb/testsuite/gdb.opt/inline-small-func.exp
+++ b/gdb/testsuite/gdb.opt/inline-small-func.exp
@@ -45,8 +45,8 @@ if ![runto_main] {
     return -1
 }
 
-# Delete all breakpoints so that the output of "info breakpoints"
-# below will only contain a single breakpoint.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
+# the output of "info breakpoints" below will only contain a single breakpoint.
 delete_breakpoints
 
 # Place a breakpoint within the function in the header file.
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
index 67da48d2f48..ef4c929fb15 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -333,7 +333,7 @@ proc_with_prefix test_bkpt_invisible { } {
 	"py-breakpoint\.c:$ibp_location*" "Check breakpoint location 2"
     gdb_test "python print (ilist\[0\].visible)" \
 	"False" "Check breakpoint visibility 2"
-    gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
+    gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"Check info breakpoints does not show invisible breakpoints"
     gdb_test "maint info breakpoints" \
 	"py-breakpoint\.c:$ibp_location.*" \
@@ -428,7 +428,7 @@ proc_with_prefix test_bkpt_internal { } {
     gdb_py_test_silent_cmd  "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE, internal=True )" \
 	"Set watchpoint" 0
     gdb_test "info breakpoints" \
-	"No breakpoints or watchpoints.*" \
+	"No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"Check info breakpoints does not show invisible breakpoints"
     gdb_test "maint info breakpoints" \
 	".*watchpoint.*result.*" \
@@ -591,7 +591,7 @@ proc_with_prefix test_bkpt_temporary { } {
 	"Check temporary stop callback executed before deletion."
     gdb_test "python print (ibp.temporary)" "RuntimeError: Breakpoint 2 is invalid.*" \
 	"Check temporary breakpoint is deleted after being hit"
-    gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
+    gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints.*" \
 	"Check info breakpoints shows temporary breakpoint is deleted"
 }
 
@@ -600,7 +600,7 @@ proc_with_prefix test_bkpt_temporary { } {
 proc_with_prefix test_bkpt_address {} {
     global gdb_prompt decimal srcfile
 
-    # Delete all breakpoints
+    # Delete all breakpoints, watchpoints, tracepoints, and catchpoints
     delete_breakpoints
 
     gdb_test "python gdb.Breakpoint(\"*main\")" \
diff --git a/gdb/testsuite/gdb.reverse/ppc_record_test_isa_3_1.exp b/gdb/testsuite/gdb.reverse/ppc_record_test_isa_3_1.exp
index 0306a9de7ca..06257f9471e 100644
--- a/gdb/testsuite/gdb.reverse/ppc_record_test_isa_3_1.exp
+++ b/gdb/testsuite/gdb.reverse/ppc_record_test_isa_3_1.exp
@@ -105,7 +105,7 @@ gdb_test_no_output "set exec-direction forward" "start forward test3"
 gdb_test "record stop" ".*Process record is stopped.*" "stopped recording 2"
 set test_del_bkpts "delete breakpoints, answer prompt 2"
 
-# Delete all breakpoints and catchpoints.
+# Delete all breakpoints, watchpoints, tracepoints, and catchpoints.
 delete_breakpoints
 
 gdb_test_no_output "record" "start recording test2"
diff --git a/gdb/testsuite/gdb.threads/continue-pending-after-query.exp b/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
index 41487c9a845..7f2a60a673f 100644
--- a/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
+++ b/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
@@ -67,7 +67,7 @@ proc test {} {
     set test "delete breakpoints, answer prompt"
     set saw_prompt 0
     gdb_test_multiple "delete breakpoints" $test {
-	-re "Delete all breakpoints.*y or n.*$" {
+	-re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*y or n.*$" {
 	    set saw_prompt 1
 	    send_gdb "y\n"
 	    exp_continue
diff --git a/gdb/testsuite/gdb.threads/continue-pending-status.exp b/gdb/testsuite/gdb.threads/continue-pending-status.exp
index f998625a00c..32da7ec2d52 100644
--- a/gdb/testsuite/gdb.threads/continue-pending-status.exp
+++ b/gdb/testsuite/gdb.threads/continue-pending-status.exp
@@ -89,9 +89,9 @@ for {set i 0} {$i < $attempts} {incr i} {
 	    "Switching to thread $thread .*" \
 	    "switch to non-event thread"
 
-	# Delete all breakpoints so that continuing doesn't switch
-	# back to the event thread to do a step-over, which would mask
-	# away the original bug, which depended on the event thread
+	# Delete all breakpoints, watchpoints, tracepoints, and catchpoints
+	# so that continuing doesn't switch back to the event thread to do a step-over,
+	# which would mask away the original bug, which depended on the event thread
 	# still having TARGET_STOPPED_BY_SW_BREAKPOINT stop_reason.
 	delete_breakpoints
 
diff --git a/gdb/testsuite/gdb.threads/thread_check.exp b/gdb/testsuite/gdb.threads/thread_check.exp
index ba80a8971a5..83fa86dc359 100644
--- a/gdb/testsuite/gdb.threads/thread_check.exp
+++ b/gdb/testsuite/gdb.threads/thread_check.exp
@@ -28,7 +28,7 @@
 # - create 2 breakpoints #1 main() #2 tf() (the thread function)
 # - run gdb till #1 main() breakpoint is reached
 # - continue to breakpoint #2 tf()
-# - delete all breakpoints 
+# - delete all breakpoints, watchpoints, tracepoints, and catchpoints
 # - exit gdb.
 
 
@@ -71,7 +71,7 @@ gdb_test "backtrace" \
 
 
 #
-# delete all breakpoints
+# delete all breakpoints, watchpoints, tracepoints, and catchpoints
 #
 delete_breakpoints
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 9a906f0f349..7357d56f89a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -373,10 +373,10 @@ proc delete_breakpoints {} {
     #
     set timeout 100
 
-    set msg "delete all breakpoints in delete_breakpoints"
+    set msg "delete all breakpoints, watchpoints, tracepoints, and catchpoints in delete_breakpoints"
     set deleted 0
     gdb_test_multiple "delete breakpoints" "$msg" {
-	-re "Delete all breakpoints.*y or n.*$" {
+	-re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*y or n.*$" {
 	    send_gdb "y\n" answer
 	    exp_continue
 	}
@@ -390,7 +390,7 @@ proc delete_breakpoints {} {
 	set deleted 0
 	set msg "info breakpoints"
 	gdb_test_multiple $msg $msg {
-	    -re "No breakpoints or watchpoints..*$gdb_prompt $" {
+	    -re "No breakpoints, watchpoints, tracepoints, or catchpoints..*$gdb_prompt $" {
 		set deleted 1
 	    }
 	    -re "$gdb_prompt $" {
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 001e4ee0970..b3a27efb155 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -355,25 +355,25 @@ proc mi_delete_breakpoints {} {
 # FIXME: The mi operation won't accept a prompt back and will use the 'all' arg
     send_gdb "102-break-delete\n"
     gdb_expect 30 {
-	 -re "Delete all breakpoints.*y or n.*$" {
+	 -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*y or n.*$" {
 	    send_gdb "y\n"
 	    exp_continue
 	 }
 	 -re "102-break-delete\r\n102\\\^done\r\n$mi_gdb_prompt$" {
 	     # This happens if there were no breakpoints
 	 }
-	 timeout { perror "Delete all breakpoints in mi_delete_breakpoints (timeout)" ; return }
+	 timeout { perror "Delete all breakpoints, watchpoints, tracepoints, and catchpoints in mi_delete_breakpoints (timeout)" ; return }
     }
 
-# The correct output is not "No breakpoints or watchpoints." but an
+# The correct output is not "No breakpoints, watchpoints, tracepoints, or catchpoints." but an
 # empty BreakpointTable. Also, a query is not acceptable with mi.
     send_gdb "103-break-list\n"
     gdb_expect 30 {
 	 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{\}\r\n$mi_gdb_prompt$" {}
 	 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[\\\]\}\r\n$mi_gdb_prompt$" {}
-	 -re "103-break-list\r\n103\\\^doneNo breakpoints or watchpoints.\r\n\r\n$mi_gdb_prompt$" {warning "Unexpected console text received"}
+	 -re "103-break-list\r\n103\\\^doneNo breakpoints, watchpoints, tracepoints, or catchpoints.\r\n\r\n$mi_gdb_prompt$" {warning "Unexpected console text received"}
 	 -re "$mi_gdb_prompt$" { perror "Breakpoints not deleted" ; return }
-	 -re "Delete all breakpoints.*or n.*$" {
+	 -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints.*or n.*$" {
 	    warning "Unexpected prompt for breakpoints deletion"
 	    send_gdb "y\n"
 	    exp_continue
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index e2cb13feef0..c23bb46c666 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -1999,7 +1999,8 @@ check_mem_write (CORE_ADDR mem_addr, unsigned char *buf,
     delete_disabled_breakpoints ();
 }
 
-/* Delete all breakpoints, and un-insert them from the inferior.  */
+/* Delete all breakpoints, watchpoints, tracepoints, and catchpoints,
+   and un-insert them from the inferior.  */
 
 void
 delete_all_breakpoints (void)
@@ -2021,8 +2022,8 @@ mark_breakpoints_out (struct process_info *proc)
     raw_bp->inserted = 0;
 }
 
-/* Release all breakpoints, but do not try to un-insert them from the
-   inferior.  */
+/* Release all breakpoints, watchpoints, tracepoints, and catchpoints,
+   but do not try to un-insert them from the inferior.  */
 
 void
 free_all_breakpoints (struct process_info *proc)
diff --git a/gdbserver/mem-break.h b/gdbserver/mem-break.h
index 99689c9998c..36521184226 100644
--- a/gdbserver/mem-break.h
+++ b/gdbserver/mem-break.h
@@ -216,7 +216,8 @@ void check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len);
 void check_mem_write (CORE_ADDR mem_addr,
 		      unsigned char *buf, const unsigned char *myaddr, int mem_len);
 
-/* Delete all breakpoints.  */
+/* Delete all breakpoints, watchpoints, tracepoints, and catchpoints,
+   and un-insert them from the inferior.  */
 
 void delete_all_breakpoints (void);
 
@@ -224,8 +225,8 @@ void delete_all_breakpoints (void);
 
 void mark_breakpoints_out (struct process_info *proc);
 
-/* Delete all breakpoints, but do not try to un-insert them from the
-   inferior.  */
+/* Delete all breakpoints, watchpoints, tracepoints, and catchpoints,
+   but do not try to un-insert them from the inferior.  */
 
 void free_all_breakpoints (struct process_info *proc);
 
-- 
2.42.0


^ permalink raw reply	[relevance 6%]

* [PATCH v2 2/2] gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable}
  @ 2024-02-21 16:46 11% ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-02-21 16:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This code was there to support g++ 4, which didn't support
std::is_trivially_constructible and std::is_trivially_copyable.  Since
we now require g++ >= 9, I think it's fair to assume that GDB will
always be compiled with a compiler that supports those.

Change-Id: Ie7c1649139a2f48bf662cac92d7f3e38fb1f1ba1
---
 gdb/trad-frame.c                     |  2 --
 gdb/unittests/array-view-selftests.c |  4 ----
 gdb/unittests/enum-flags-selftests.c |  4 ----
 gdb/unittests/packed-selftests.c     |  4 ----
 gdbsupport/check-defines.el          |  2 --
 gdbsupport/packed.h                  |  2 --
 gdbsupport/poison.h                  |  8 --------
 gdbsupport/traits.h                  | 21 ---------------------
 8 files changed, 47 deletions(-)

diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c
index 8b63927b133c..c35e08ab2805 100644
--- a/gdb/trad-frame.c
+++ b/gdb/trad-frame.c
@@ -61,9 +61,7 @@ trad_frame_reset_saved_regs (struct gdbarch *gdbarch,
 trad_frame_saved_reg *
 trad_frame_alloc_saved_regs (struct gdbarch *gdbarch)
 {
-#ifdef HAVE_IS_TRIVIALLY_CONSTRUCTIBLE
   static_assert (std::is_trivially_constructible<trad_frame_saved_reg>::value);
-#endif
 
   int numregs = gdbarch_num_cooked_regs (gdbarch);
   trad_frame_saved_reg *this_saved_regs
diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-view-selftests.c
index 9d2448fefc10..299318ace434 100644
--- a/gdb/unittests/array-view-selftests.c
+++ b/gdb/unittests/array-view-selftests.c
@@ -30,15 +30,11 @@ namespace array_view_tests {
 #define CHECK_TRAIT(TRAIT)			\
   static_assert (std::TRAIT<gdb::array_view<gdb_byte>>::value, "")
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 CHECK_TRAIT (is_trivially_copyable);
 CHECK_TRAIT (is_trivially_move_assignable);
 CHECK_TRAIT (is_trivially_move_constructible);
 CHECK_TRAIT (is_trivially_destructible);
 
-#endif
-
 #undef CHECK_TRAIT
 
 /* Wrapper around std::is_convertible to make the code using it a bit
diff --git a/gdb/unittests/enum-flags-selftests.c b/gdb/unittests/enum-flags-selftests.c
index 607b8ac66a64..54e168173de6 100644
--- a/gdb/unittests/enum-flags-selftests.c
+++ b/gdb/unittests/enum-flags-selftests.c
@@ -63,14 +63,10 @@ DEF_ENUM_FLAGS_TYPE (RE, EF);
 DEF_ENUM_FLAGS_TYPE (RE2, EF2);
 DEF_ENUM_FLAGS_TYPE (URE, UEF);
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 /* So that std::vectors of types that have enum_flags fields can
    reallocate efficiently memcpy.  */
 static_assert (std::is_trivially_copyable<EF>::value);
 
-#endif
-
 /* A couple globals used as lvalues in the CHECK_VALID expressions
    below.  Their names (and types) match the uppercase type names
    exposed by CHECK_VALID just to make the expressions easier to
diff --git a/gdb/unittests/packed-selftests.c b/gdb/unittests/packed-selftests.c
index 3f20861ad4a2..852a7d364ce9 100644
--- a/gdb/unittests/packed-selftests.c
+++ b/gdb/unittests/packed-selftests.c
@@ -46,16 +46,12 @@ static_assert (alignof (packed<test_enum, 4>) == 1);
 #define CHECK_TRAIT(TRAIT)			\
   static_assert (std::TRAIT<packed<test_enum, 1>>::value, "")
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 CHECK_TRAIT (is_trivially_copyable);
 CHECK_TRAIT (is_trivially_copy_constructible);
 CHECK_TRAIT (is_trivially_move_constructible);
 CHECK_TRAIT (is_trivially_copy_assignable);
 CHECK_TRAIT (is_trivially_move_assignable);
 
-#endif
-
 #undef CHECK_TRAIT
 
 /* Entry point.  */
diff --git a/gdbsupport/check-defines.el b/gdbsupport/check-defines.el
index 7603effc29de..b7cf61ba8599 100644
--- a/gdbsupport/check-defines.el
+++ b/gdbsupport/check-defines.el
@@ -35,8 +35,6 @@
 (put (intern "HAVE_USEFUL_SBRK") :check-ok t)
 (put (intern "HAVE_SOCKETS") :check-ok t)
 (put (intern "HAVE_F_GETFD") :check-ok t)
-(put (intern "HAVE_IS_TRIVIALLY_COPYABLE") :check-ok t)
-(put (intern "HAVE_IS_TRIVIALLY_CONSTRUCTIBLE") :check-ok t)
 (put (intern "HAVE_DOS_BASED_FILE_SYSTEM") :check-ok t)
 
 (defun check-read-config.in (file)
diff --git a/gdbsupport/packed.h b/gdbsupport/packed.h
index 8035535386b0..5c817d4c9cce 100644
--- a/gdbsupport/packed.h
+++ b/gdbsupport/packed.h
@@ -80,9 +80,7 @@ struct ATTRIBUTE_GCC_STRUCT packed
     static_assert (alignof (packed) == 1);
 
     /* Make sure packed can be wrapped with std::atomic.  */
-#if HAVE_IS_TRIVIALLY_COPYABLE
     static_assert (std::is_trivially_copyable<packed>::value);
-#endif
     static_assert (std::is_copy_constructible<packed>::value);
     static_assert (std::is_move_constructible<packed>::value);
     static_assert (std::is_copy_assignable<packed>::value);
diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h
index 0d0159eb7f81..7b4f8e8a178d 100644
--- a/gdbsupport/poison.h
+++ b/gdbsupport/poison.h
@@ -56,8 +56,6 @@ template <typename T,
 	  typename = gdb::Requires<gdb::Not<IsMemsettable<T>>>>
 void *memset (T *s, int c, size_t n) = delete;
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 /* Similarly, poison memcpy and memmove of non trivially-copyable
    types, which is undefined.  */
 
@@ -83,17 +81,11 @@ template <typename D, typename S,
 	  typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
 void *memmove (D *dest, const S *src, size_t n) = delete;
 
-#endif /* HAVE_IS_TRIVIALLY_COPYABLE */
-
 /* Poison XNEW and friends to catch usages of malloc-style allocations on
    objects that require new/delete.  */
 
 template<typename T>
-#if HAVE_IS_TRIVIALLY_CONSTRUCTIBLE
 using IsMallocable = std::is_trivially_constructible<T>;
-#else
-using IsMallocable = std::true_type;
-#endif
 
 template<typename T>
 using IsFreeable = gdb::Or<std::is_trivially_destructible<T>, std::is_void<T>>;
diff --git a/gdbsupport/traits.h b/gdbsupport/traits.h
index eb97b9659904..92fe59f34af7 100644
--- a/gdbsupport/traits.h
+++ b/gdbsupport/traits.h
@@ -20,27 +20,6 @@
 
 #include <type_traits>
 
-/* GCC does not understand __has_feature.  */
-#if !defined(__has_feature)
-# define __has_feature(x) 0
-#endif
-
-/* HAVE_IS_TRIVIALLY_COPYABLE is defined as 1 iff
-   std::is_trivially_copyable is available.  GCC only implemented it
-   in GCC 5.  */
-#if (__has_feature(is_trivially_copyable) \
-     || (defined __GNUC__ && __GNUC__ >= 5))
-# define HAVE_IS_TRIVIALLY_COPYABLE 1
-#endif
-
-/* HAVE_IS_TRIVIALLY_CONSTRUCTIBLE is defined as 1 iff
-   std::is_trivially_constructible is available.  GCC only implemented it
-   in GCC 5.  */
-#if (__has_feature(is_trivially_constructible) \
-     || (defined __GNUC__ && __GNUC__ >= 5))
-# define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1
-#endif
-
 namespace gdb {
 
 /* Implementation of the detection idiom:
-- 
2.43.2


^ permalink raw reply	[relevance 11%]

* [PATCH v2 1/3] [gdb/dap] Factor out thread_log
@ 2024-02-21 13:20  5% Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-02-21 13:20 UTC (permalink / raw)
  To: gdb-patches

In thread_wrapper I used a style where a message is prefixed with the thread
name.

Factor this out into a new function thread_log.

Also treat the GDB main thread special, because it's usual name is MainThread:
...
MainThread: <msg>
...
which is the default name assigned by python, so instead use the more
explicit:
...
GDB main: <msg>
...

Tested on aarch64-linux.
---
 gdb/python/lib/gdb/dap/startup.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/startup.py b/gdb/python/lib/gdb/dap/startup.py
index 0a42c91e8f4..29fe78ecd53 100644
--- a/gdb/python/lib/gdb/dap/startup.py
+++ b/gdb/python/lib/gdb/dap/startup.py
@@ -64,7 +64,6 @@ def start_thread(name, target, args=()):
     correctly blocked."""
 
     def thread_wrapper(*args):
-        thread_name = threading.current_thread().name
         # Catch any exception, and log it.  If we let it escape here, it'll be
         # printed in gdb_stderr, which is not safe to access from anywhere but
         # gdb's main thread.
@@ -72,11 +71,11 @@ def start_thread(name, target, args=()):
             target(*args)
         except Exception as err:
             err_string = "%s, %s" % (err, type(err))
-            log(thread_name + ": caught exception: " + err_string)
+            thread_log("caught exception: " + err_string)
             log_stack()
         finally:
             # Log when a thread terminates.
-            log(thread_name + ": terminating")
+            thread_log("terminating")
 
     result = gdb.Thread(name=name, target=thread_wrapper, args=args, daemon=True)
     result.start()
@@ -178,6 +177,16 @@ def log(something, level=LogLevel.DEFAULT):
             dap_log.log_file.flush()
 
 
+def thread_log(something, level=LogLevel.DEFAULT):
+    """Log SOMETHING to the log file, if logging is enabled, and prefix
+    the thread name."""
+    if threading.current_thread() is _gdb_thread:
+        thread_name = "GDB main"
+    else:
+        thread_name = threading.current_thread().name
+    log(thread_name + ": " + something, level)
+
+
 def log_stack(level=LogLevel.DEFAULT):
     """Log a stack trace to the log file, if logging is enabled."""
     with dap_log.lock:

base-commit: 7c34de9efdb13fff482ed0c4de0dffee1e1880f3
-- 
2.35.3


^ permalink raw reply	[relevance 5%]

* [PUSHED] arc: Determine a branch target of DBNZ correctly
  @ 2024-02-21 13:17 14% ` Shahab Vahedi
  0 siblings, 0 replies; 200+ results
From: Shahab Vahedi @ 2024-02-21 13:17 UTC (permalink / raw)
  To: gdb-patches; +Cc: Yuriy Kolerov

From: Yuriy Kolerov <kolerov93@gmail.com>

DBNZ instruction was moved from BRANCH class to a separate one - DBNZ.
Thus, it must be processed separately in arc_insn_get_branch_target
to correctly determine an offset for a possible branch.

The testsuite for DBNZ instruction verifies these cases:

     1. Check that dbnz does not branch and falls through if its source
        register is 0 after decrementing. GDB must successfully break
        on the following instruction after stepping over.
     2. Check that dbnz branches to the target correctly if its source register
        is not 0 after decrementing - GDB must successfully break on the target
        instruction if a forward branch is performed after stepping over.
     3. The same as point 2 but for a backward branching case.

Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
---
 gdb/arc-tdep.c                      | 10 +++
 gdb/testsuite/gdb.arch/arc-dbnz.S   | 47 ++++++++++++++
 gdb/testsuite/gdb.arch/arc-dbnz.exp | 97 +++++++++++++++++++++++++++++
 3 files changed, 154 insertions(+)
 create mode 100644 gdb/testsuite/gdb.arch/arc-dbnz.S
 create mode 100644 gdb/testsuite/gdb.arch/arc-dbnz.exp

diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 12d8aee949f..7dd43cc239f 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -466,6 +466,16 @@ arc_insn_get_branch_target (const struct arc_instruction &insn)
 	 instruction, hence last two bits should be truncated.  */
       return pcrel_addr + align_down (insn.address, 4);
     }
+  /* DBNZ is the only branch instruction that keeps a branch address in
+     the second operand. It must be intercepted and treated differently. */
+  else if (insn.insn_class == DBNZ)
+    {
+      CORE_ADDR pcrel_addr = arc_insn_get_operand_value_signed (insn, 1);
+
+      /* Offset is relative to the 4-byte aligned address of the current
+	 instruction, hence last two bits should be truncated. */
+      return pcrel_addr + align_down (insn.address, 4);
+    }
   /* B, Bcc, BL, BLcc, LP, LPcc: PC = currentPC + operand.  */
   else if (insn.insn_class == BRANCH || insn.insn_class == LOOP)
     {
diff --git a/gdb/testsuite/gdb.arch/arc-dbnz.S b/gdb/testsuite/gdb.arch/arc-dbnz.S
new file mode 100644
index 00000000000..45e1dfe8305
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/arc-dbnz.S
@@ -0,0 +1,47 @@
+; This testcase is part of GDB, the GNU debugger.
+
+; Copyright 2024 Free Software Foundation, Inc.
+
+; This program is free software; you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation; either version 3 of the License, or
+; (at your option) any later version.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+	.section .text
+	.align 4
+	.global main
+	.type main, @function
+
+main:
+	mov r0,1
+dbnz1:
+	; r0 == 0 after decrementing. dbnz doesn't do branch.
+	dbnz r0,@end
+
+	mov r0,5
+dbnz2:
+	; r0 == 3 after decrementing and delay slot. dbnz does branch.
+	dbnz.d r0,@dbnz3
+	sub r0,r0,1
+
+dbnz4:
+	; r0 == 1 after decrementing. dbnz does branch.
+	dbnz r0,@end
+
+dbnz3:
+	; r0 == 2 after decrementing. dbnz does branch.
+	dbnz r0,@dbnz4
+
+end:
+	mov r0,0
+	j [blink]
+
+	.section .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.arch/arc-dbnz.exp b/gdb/testsuite/gdb.arch/arc-dbnz.exp
new file mode 100644
index 00000000000..f1fce0e5a7f
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/arc-dbnz.exp
@@ -0,0 +1,97 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test dbnz instruction. It decrements its source register operand, and if
+# the result is non-zero it branches to the location defined by a signed
+# half-word displacement operand.
+#
+# It's necessary to verify these cases:
+#
+#     1. Check that dbnz does not branch and falls through if its source
+#        register is 0 after decrementing. GDB must successfully break
+#        on the following instruction after stepping over.
+#     2. Check that dbnz branches to the target correctly if its source register
+#        is not 0 after decrementing - GDB must successfully break on the target
+#        instruction if a forward branch is performed after stepping over.
+#     3. The same as point 2 but for a backward branching case.
+
+require {istarget "arc*-*-*"}
+
+standard_testfile .S
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
+    return -1
+}
+
+if ![runto_main] {
+    return 0
+}
+
+gdb_test "break dbnz1" \
+	 "Breakpoint $decimal at .*" \
+	 "set breakpoint on the 1st dbnz"
+
+gdb_test "break dbnz2" \
+	 "Breakpoint $decimal at .*" \
+	 "set breakpoint on the 2nd dbnz"
+
+gdb_test "break dbnz3" \
+	 "Breakpoint $decimal at .*" \
+	 "set breakpoint on the 3rd dbnz"
+
+gdb_test "break dbnz4" \
+	 "Breakpoint $decimal at .*" \
+	 "set breakpoint on the 4th dbnz"
+
+gdb_test "break end" \
+	 "Breakpoint $decimal at .*" \
+	 "set breakpoint at the end"
+
+gdb_test "continue" \
+	 "Breakpoint $decimal, dbnz1.*dbnz r0,@end" \
+	 "continue to the 1st dbnz"
+
+gdb_test "x /i \$pc" \
+	 "$hex <.*>:\[ \t\]+dbnz\[ \t\]+r0,24.*" \
+	 "stayng on the 1st dbnz instruction"
+
+gdb_test "stepi" \
+	 "mov r0,5" \
+	 "step over the 1st dbnz, branch is not taken"
+
+gdb_test "stepi" \
+	 "Breakpoint $decimal, dbnz2.*dbnz\\.d r0,@dbnz3" \
+	 "step over r0 initialization, staying on the 2nd dbnz"
+
+# Linux steps over delay slot after "stepi", but stubs with hardware stepping
+# like nSIM's stub may step right on delay slot. Thus use "continue" instead of
+# "stepi" to make this test work for all platforms.
+gdb_test "continue" \
+	 "Breakpoint $decimal, dbnz3.*dbnz r0,@dbnz4" \
+	 "step over the 2nd dbnz, branch is taken, staying on the 3rd dbnz"
+
+gdb_test "stepi" \
+	 "Breakpoint $decimal, dbnz4.*dbnz r0,@end" \
+	 "step over the 3rd dbnz, branch is taken, staying on the 4th dbnz"
+
+gdb_test "stepi" \
+	 "Breakpoint $decimal, end.*mov r0,0" \
+	 "step over the 4th dbnz, branch is taken, staying on the epilogue"
+
+gdb_test "info register r0" \
+	 "r0\[ \t\]+0x1\[ \t\]+1" \
+	 "r0 contains 1 after all dbnz instructions"
-- 
2.35.8


^ permalink raw reply	[relevance 14%]

* RE: [PATCH 1/1] gdb: Document C++17 build requirement.
  @ 2024-02-21  8:39  0%   ` Willgerodt, Felix
  0 siblings, 0 replies; 200+ results
From: Willgerodt, Felix @ 2024-02-21  8:39 UTC (permalink / raw)
  To: Lancelot SIX; +Cc: gdb-patches

Thanks for fixing the wiki!

I went ahead and pushed this under the "obvious" rule. I hope that is ok.

Regards,
Felix

> -----Original Message-----
> From: Lancelot SIX <lsix@lancelotsix.com>
> Sent: Montag, 19. Februar 2024 19:14
> To: Willgerodt, Felix <felix.willgerodt@intel.com>
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH 1/1] gdb: Document C++17 build requirement.
> 
> Hi Felix,
> 
> Thank for catching this, I missed that part of the documentation when
> doing the C++17 migration.
> 
> I have updated the wiki to reflect the C++17 requirement.
> 
> Reviewed-By: Lancelot Six <lancelot.six@amd.com>
> 
> Best,
> Lancelot.
> 
> On Mon, Feb 19, 2024 at 03:56:55PM +0100, Felix Willgerodt wrote:
> > We require C++17 to build for a while now:
> > https://sourceware.org/git/?p=binutils-
> gdb.git;a=commit;h=f74dc26792a0679e29db45e56367331ff48666d1
> >
> > I also found another place we probably should update:
> > https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#C.2B-
> .2B-_dialect
> > But I don't know how to do that.
> >
> > ---
> >  gdb/doc/gdb.texinfo | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> > index e4b89cfccfc..79805486dd6 100644
> > --- a/gdb/doc/gdb.texinfo
> > +++ b/gdb/doc/gdb.texinfo
> > @@ -40555,9 +40555,9 @@ Other packages will be used only if they are found.
> >
> >  @heading Tools/Packages Necessary for Building @value{GDBN}
> >  @table @asis
> > -@item C@t{++}11 compiler
> > -@value{GDBN} is written in C@t{++}11.  It should be buildable with any
> > -recent C@t{++}11 compiler, e.g.@: GCC.
> > +@item C@t{++}17 compiler
> > +@value{GDBN} is written in C@t{++}17.  It should be buildable with any
> > +recent C@t{++}17 compiler, e.g.@: GCC.
> >
> >  @item GNU make
> >  @value{GDBN}'s build system relies on features only found in the GNU
> > --
> > 2.34.1
> >
> > Intel Deutschland GmbH
> > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
> > Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
> > Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
> > Chairperson of the Supervisory Board: Nicole Lau
> > Registered Office: Munich
> > Commercial Register: Amtsgericht Muenchen HRB 186928
> >
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[relevance 0%]

* [PATCH 2/2] gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable}
  @ 2024-02-21  2:19 11% ` Simon Marchi
  0 siblings, 0 replies; 200+ results
From: Simon Marchi @ 2024-02-21  2:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This code was there to support g++ 4, which didn't support
std::is_trivially_constructible and std::is_trivially_copyable.  Since
we now require g++ >= 9, I think it's fair to assume that GDB will
always be compiled with a compiler that supports those.

Change-Id: Ie7c1649139a2f48bf662cac92d7f3e38fb1f1ba1
---
 gdb/trad-frame.c                     |  2 --
 gdb/unittests/array-view-selftests.c |  4 ----
 gdb/unittests/enum-flags-selftests.c |  4 ----
 gdb/unittests/packed-selftests.c     |  4 ----
 gdbsupport/check-defines.el          |  2 --
 gdbsupport/packed.h                  |  2 --
 gdbsupport/poison.h                  |  8 --------
 gdbsupport/traits.h                  | 21 ---------------------
 8 files changed, 47 deletions(-)

diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c
index 8b63927b133c..c35e08ab2805 100644
--- a/gdb/trad-frame.c
+++ b/gdb/trad-frame.c
@@ -61,9 +61,7 @@ trad_frame_reset_saved_regs (struct gdbarch *gdbarch,
 trad_frame_saved_reg *
 trad_frame_alloc_saved_regs (struct gdbarch *gdbarch)
 {
-#ifdef HAVE_IS_TRIVIALLY_CONSTRUCTIBLE
   static_assert (std::is_trivially_constructible<trad_frame_saved_reg>::value);
-#endif
 
   int numregs = gdbarch_num_cooked_regs (gdbarch);
   trad_frame_saved_reg *this_saved_regs
diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-view-selftests.c
index 9d2448fefc10..299318ace434 100644
--- a/gdb/unittests/array-view-selftests.c
+++ b/gdb/unittests/array-view-selftests.c
@@ -30,15 +30,11 @@ namespace array_view_tests {
 #define CHECK_TRAIT(TRAIT)			\
   static_assert (std::TRAIT<gdb::array_view<gdb_byte>>::value, "")
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 CHECK_TRAIT (is_trivially_copyable);
 CHECK_TRAIT (is_trivially_move_assignable);
 CHECK_TRAIT (is_trivially_move_constructible);
 CHECK_TRAIT (is_trivially_destructible);
 
-#endif
-
 #undef CHECK_TRAIT
 
 /* Wrapper around std::is_convertible to make the code using it a bit
diff --git a/gdb/unittests/enum-flags-selftests.c b/gdb/unittests/enum-flags-selftests.c
index 607b8ac66a64..54e168173de6 100644
--- a/gdb/unittests/enum-flags-selftests.c
+++ b/gdb/unittests/enum-flags-selftests.c
@@ -63,14 +63,10 @@ DEF_ENUM_FLAGS_TYPE (RE, EF);
 DEF_ENUM_FLAGS_TYPE (RE2, EF2);
 DEF_ENUM_FLAGS_TYPE (URE, UEF);
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 /* So that std::vectors of types that have enum_flags fields can
    reallocate efficiently memcpy.  */
 static_assert (std::is_trivially_copyable<EF>::value);
 
-#endif
-
 /* A couple globals used as lvalues in the CHECK_VALID expressions
    below.  Their names (and types) match the uppercase type names
    exposed by CHECK_VALID just to make the expressions easier to
diff --git a/gdb/unittests/packed-selftests.c b/gdb/unittests/packed-selftests.c
index 3f20861ad4a2..852a7d364ce9 100644
--- a/gdb/unittests/packed-selftests.c
+++ b/gdb/unittests/packed-selftests.c
@@ -46,16 +46,12 @@ static_assert (alignof (packed<test_enum, 4>) == 1);
 #define CHECK_TRAIT(TRAIT)			\
   static_assert (std::TRAIT<packed<test_enum, 1>>::value, "")
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 CHECK_TRAIT (is_trivially_copyable);
 CHECK_TRAIT (is_trivially_copy_constructible);
 CHECK_TRAIT (is_trivially_move_constructible);
 CHECK_TRAIT (is_trivially_copy_assignable);
 CHECK_TRAIT (is_trivially_move_assignable);
 
-#endif
-
 #undef CHECK_TRAIT
 
 /* Entry point.  */
diff --git a/gdbsupport/check-defines.el b/gdbsupport/check-defines.el
index 7603effc29de..b7cf61ba8599 100644
--- a/gdbsupport/check-defines.el
+++ b/gdbsupport/check-defines.el
@@ -35,8 +35,6 @@
 (put (intern "HAVE_USEFUL_SBRK") :check-ok t)
 (put (intern "HAVE_SOCKETS") :check-ok t)
 (put (intern "HAVE_F_GETFD") :check-ok t)
-(put (intern "HAVE_IS_TRIVIALLY_COPYABLE") :check-ok t)
-(put (intern "HAVE_IS_TRIVIALLY_CONSTRUCTIBLE") :check-ok t)
 (put (intern "HAVE_DOS_BASED_FILE_SYSTEM") :check-ok t)
 
 (defun check-read-config.in (file)
diff --git a/gdbsupport/packed.h b/gdbsupport/packed.h
index 8035535386b0..5c817d4c9cce 100644
--- a/gdbsupport/packed.h
+++ b/gdbsupport/packed.h
@@ -80,9 +80,7 @@ struct ATTRIBUTE_GCC_STRUCT packed
     static_assert (alignof (packed) == 1);
 
     /* Make sure packed can be wrapped with std::atomic.  */
-#if HAVE_IS_TRIVIALLY_COPYABLE
     static_assert (std::is_trivially_copyable<packed>::value);
-#endif
     static_assert (std::is_copy_constructible<packed>::value);
     static_assert (std::is_move_constructible<packed>::value);
     static_assert (std::is_copy_assignable<packed>::value);
diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h
index 0d0159eb7f81..7b4f8e8a178d 100644
--- a/gdbsupport/poison.h
+++ b/gdbsupport/poison.h
@@ -56,8 +56,6 @@ template <typename T,
 	  typename = gdb::Requires<gdb::Not<IsMemsettable<T>>>>
 void *memset (T *s, int c, size_t n) = delete;
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 /* Similarly, poison memcpy and memmove of non trivially-copyable
    types, which is undefined.  */
 
@@ -83,17 +81,11 @@ template <typename D, typename S,
 	  typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
 void *memmove (D *dest, const S *src, size_t n) = delete;
 
-#endif /* HAVE_IS_TRIVIALLY_COPYABLE */
-
 /* Poison XNEW and friends to catch usages of malloc-style allocations on
    objects that require new/delete.  */
 
 template<typename T>
-#if HAVE_IS_TRIVIALLY_CONSTRUCTIBLE
 using IsMallocable = std::is_trivially_constructible<T>;
-#else
-using IsMallocable = std::true_type;
-#endif
 
 template<typename T>
 using IsFreeable = gdb::Or<std::is_trivially_destructible<T>, std::is_void<T>>;
diff --git a/gdbsupport/traits.h b/gdbsupport/traits.h
index eb97b9659904..92fe59f34af7 100644
--- a/gdbsupport/traits.h
+++ b/gdbsupport/traits.h
@@ -20,27 +20,6 @@
 
 #include <type_traits>
 
-/* GCC does not understand __has_feature.  */
-#if !defined(__has_feature)
-# define __has_feature(x) 0
-#endif
-
-/* HAVE_IS_TRIVIALLY_COPYABLE is defined as 1 iff
-   std::is_trivially_copyable is available.  GCC only implemented it
-   in GCC 5.  */
-#if (__has_feature(is_trivially_copyable) \
-     || (defined __GNUC__ && __GNUC__ >= 5))
-# define HAVE_IS_TRIVIALLY_COPYABLE 1
-#endif
-
-/* HAVE_IS_TRIVIALLY_CONSTRUCTIBLE is defined as 1 iff
-   std::is_trivially_constructible is available.  GCC only implemented it
-   in GCC 5.  */
-#if (__has_feature(is_trivially_constructible) \
-     || (defined __GNUC__ && __GNUC__ >= 5))
-# define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1
-#endif
-
 namespace gdb {
 
 /* Implementation of the detection idiom:
-- 
2.43.2


^ permalink raw reply	[relevance 11%]

* [PATCH 2/2] Drop special way of getting inferior context after a Cygwin signal
  @ 2024-02-20 16:56  3% ` Pedro Alves
  0 siblings, 0 replies; 200+ results
From: Pedro Alves @ 2024-02-20 16:56 UTC (permalink / raw)
  To: gdb-patches

From: Jon Turney <jon.turney@dronecode.org.uk>

Simplify Cygwin signal handling by dropping the special way of getting
inferior context after a Cygwin signal.

I think the reason this existed was because previously we were not
able to unwind through the alternate stack used by _sigfe frames, so
without the hint of the "user" code IP, the backtrace from a signal
was unusable.

Now we can unwind through _sigfe frames, drop all this complexity.

(Restoring this specially obtained context to the inferior (as the
code currently does) skips over the actual signal delivery and
handling.  Cygwin has carried for a long time a patch which clears the
ContextFlags in the signal context, so we never attempt to restore it
to the inferior, but that interfers with gdb's ability to modify that
context e.g. if it decides it wants to turn on FLAG_TRACE_BIT.)

Change-Id: I214edd5a99fd17c1a31ad18138d4a6cc420225e3
---
 gdb/windows-nat.c | 52 ++++++++++++++---------------------------------
 1 file changed, 15 insertions(+), 37 deletions(-)

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 7f3044fc61d..a90388922e2 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -98,10 +98,6 @@ struct windows_per_inferior : public windows_process_info
   void handle_unload_dll () override;
   bool handle_access_violation (const EXCEPTION_RECORD *rec) override;
 
-
-  int have_saved_context = 0;	/* True if we've saved context from a
-				   cygwin signal.  */
-
   uintptr_t dr[8] {};
 
   int windows_initialization_done = 0;
@@ -140,9 +136,6 @@ struct windows_per_inferior : public windows_process_info
   std::vector<windows_solib> solibs;
 
 #ifdef __CYGWIN__
-  CONTEXT saved_context {};	/* Contains the saved context from a
-				   cygwin signal.  */
-
   /* The starting and ending address of the cygwin1.dll text segment.  */
   CORE_ADDR cygwin_load_start = 0;
   CORE_ADDR cygwin_load_end = 0;
@@ -718,19 +711,6 @@ windows_nat_target::fetch_registers (struct regcache *regcache, int r)
 
   if (th->reload_context)
     {
-#ifdef __CYGWIN__
-      if (windows_process.have_saved_context)
-	{
-	  /* Lie about where the program actually is stopped since
-	     cygwin has informed us that we should consider the signal
-	     to have occurred at another location which is stored in
-	     "saved_context.  */
-	  memcpy (&th->context, &windows_process.saved_context,
-		  __COPY_CONTEXT_SIZE);
-	  windows_process.have_saved_context = 0;
-	}
-      else
-#endif
 #ifdef __x86_64__
       if (windows_process.wow64_process)
 	{
@@ -1048,33 +1028,32 @@ windows_per_inferior::handle_output_debug_string
 #ifdef __CYGWIN__
   else
     {
-      /* Got a cygwin signal marker.  A cygwin signal is followed by
-	 the signal number itself and then optionally followed by the
-	 thread id and address to saved context within the DLL.  If
-	 these are supplied, then the given thread is assumed to have
-	 issued the signal and the context from the thread is assumed
-	 to be stored at the given address in the inferior.  Tell gdb
-	 to treat this like a real signal.  */
+      /* Got a cygwin signal marker.  A cygwin signal marker is
+	 followed by the signal number itself, and (since Cygwin 1.7)
+	 the thread id, and the address of a saved context in the
+	 inferior (That context has an IP which is the return address
+	 in "user" code of the cygwin internal signal handling code,
+	 but is not otherwise usable).
+
+	 Tell gdb to treat this like the given thread issued a real
+	 signal.  */
       char *p;
       int sig = strtol (s.get () + sizeof (_CYGWIN_SIGNAL_STRING) - 1, &p, 0);
       gdb_signal gotasig = gdb_signal_from_host (sig);
+      LPCVOID x = 0;
 
       if (gotasig)
 	{
-	  LPCVOID x;
-	  SIZE_T n;
-
 	  ourstatus->set_stopped (gotasig);
 	  retval = strtoul (p, &p, 0);
 	  if (!retval)
 	    retval = current_event.dwThreadId;
-	  else if ((x = (LPCVOID) (uintptr_t) strtoull (p, NULL, 0))
-		   && ReadProcessMemory (handle, x,
-					 &saved_context,
-					 __COPY_CONTEXT_SIZE, &n)
-		   && n == __COPY_CONTEXT_SIZE)
-	    have_saved_context = 1;
+	  else
+	    x = (LPCVOID) (uintptr_t) strtoull (p, NULL, 0);
 	}
+
+      DEBUG_EVENTS ("gdb: cygwin signal %d, thread 0x%x, CONTEXT @ %p",
+		    gotasig, retval, x);
     }
 #endif
 
@@ -1607,7 +1586,6 @@ windows_nat_target::get_windows_debug_event
 
   event_code = windows_process.current_event.dwDebugEventCode;
   ourstatus->set_spurious ();
-  windows_process.have_saved_context = 0;
 
   switch (event_code)
     {
-- 
2.43.2


^ permalink raw reply	[relevance 3%]

* [PATCH v2 4/5] Rewrite "python" command exception handling
  @ 2024-02-20 15:21  5% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-02-20 15:21 UTC (permalink / raw)
  To: gdb-patches

The "python" command (and the Python implementation of the gdb
"source" command) does not handle Python exceptions in the same way as
other gdb-facing Python code.  In particular, exceptions are turned
into a generic error rather than being routed through
gdbpy_handle_exception, which takes care of converting to 'quit' as
appropriate.

I think this was done this way because PyRun_SimpleFile and friends do
not propagate the Python exception -- they simply indicate that one
occurred.

This patch reimplements these functions to respect the general gdb
convention here.  As a bonus, some Windows-specific code can be
removed, as can the _execute_file function.

The bulk of this change is tweaking the test suite to match the new
way that exceptions are displayed.  These changes are largely
uninteresting.  However, it's worth pointing out the py-error.exp
change.  Here, the failure changes because the test changes the host
charset to something that isn't supported by Python.  This then
results in a weird error in the new setup.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354
---
 gdb/python/lib/gdb/__init__.py                    |  27 ------
 gdb/python/python.c                               | 109 +++++++++-------------
 gdb/testsuite/gdb.ada/tasks.exp                   |   8 +-
 gdb/testsuite/gdb.python/py-arch.exp              |   2 +-
 gdb/testsuite/gdb.python/py-block.exp             |   4 +-
 gdb/testsuite/gdb.python/py-breakpoint.exp        |  18 ++--
 gdb/testsuite/gdb.python/py-connection.exp        |   8 +-
 gdb/testsuite/gdb.python/py-disasm.exp            |  32 +++----
 gdb/testsuite/gdb.python/py-error.exp             |   9 +-
 gdb/testsuite/gdb.python/py-finish-breakpoint.exp |   2 +-
 gdb/testsuite/gdb.python/py-format-address.exp    |  28 +++---
 gdb/testsuite/gdb.python/py-format-string.exp     |   8 +-
 gdb/testsuite/gdb.python/py-frame.exp             |  18 ++--
 gdb/testsuite/gdb.python/py-inferior.exp          |  24 ++---
 gdb/testsuite/gdb.python/py-lazy-string.exp       |   6 +-
 gdb/testsuite/gdb.python/py-mi-cmd.exp            |  40 ++++----
 gdb/testsuite/gdb.python/py-missing-debug.exp     |  16 ++--
 gdb/testsuite/gdb.python/py-objfile.exp           |   2 +-
 gdb/testsuite/gdb.python/py-parameter.exp         |  14 +--
 gdb/testsuite/gdb.python/py-pp-registration.exp   |   2 +-
 gdb/testsuite/gdb.python/py-progspace-events.exp  |   2 +-
 gdb/testsuite/gdb.python/py-progspace.exp         |   8 +-
 gdb/testsuite/gdb.python/py-record-btrace.exp     |   4 +-
 gdb/testsuite/gdb.python/py-record-full.exp       |   4 +-
 gdb/testsuite/gdb.python/py-template.exp          |   2 +-
 gdb/testsuite/gdb.python/py-thrhandle.exp         |   2 +-
 gdb/testsuite/gdb.python/py-type.exp              |  20 ++--
 gdb/testsuite/gdb.python/py-unwind.exp            |  24 ++---
 gdb/testsuite/gdb.python/py-value.exp             |  36 +++----
 gdb/testsuite/gdb.python/python.exp               |  10 +-
 gdb/testsuite/gdb.python/tui-window-names.exp     |  16 ++--
 gdb/testsuite/gdb.python/tui-window.exp           |   2 +-
 32 files changed, 233 insertions(+), 274 deletions(-)

diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
index ce8a6aae01e..cb3732e55f5 100644
--- a/gdb/python/lib/gdb/__init__.py
+++ b/gdb/python/lib/gdb/__init__.py
@@ -127,33 +127,6 @@ def _execute_unwinders(pending_frame):
     return None
 
 
-def _execute_file(filepath):
-    """This function is used to replace Python 2's PyRun_SimpleFile.
-
-    Loads and executes the given file.
-
-    We could use the runpy module, but its documentation says:
-    "Furthermore, any functions and classes defined by the executed code are
-    not guaranteed to work correctly after a runpy function has returned."
-    """
-    globals = sys.modules["__main__"].__dict__
-    set_file = False
-    # Set file (if not set) so that the imported file can use it (e.g. to
-    # access file-relative paths). This matches what PyRun_SimpleFile does.
-    if not hasattr(globals, "__file__"):
-        globals["__file__"] = filepath
-        set_file = True
-    try:
-        with open(filepath, "rb") as file:
-            # We pass globals also as locals to match what Python does
-            # in PyRun_SimpleFile.
-            compiled = compile(file.read(), filepath, "exec")
-            exec(compiled, globals, globals)
-    finally:
-        if set_file:
-            del globals["__file__"]
-
-
 # Convenience variable to GDB's python directory
 PYTHONDIR = os.path.dirname(os.path.dirname(__file__))
 
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 09b1029e0b7..5fcdceab848 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -284,12 +284,14 @@ gdbpy_check_quit_flag (const struct extension_language_defn *extlang)
   return PyOS_InterruptOccurred ();
 }
 
-/* Evaluate a Python command like PyRun_SimpleString, but uses
-   Py_single_input which prints the result of expressions, and does
-   not automatically print the stack on errors.  */
+/* Evaluate a Python command like PyRun_SimpleString, but takes a
+   Python start symbol, and does not automatically print the stack on
+   errors.  FILENAME is used to set the file name in error
+   messages.  */
 
 static int
-eval_python_command (const char *command)
+eval_python_command (const char *command, int start_symbol,
+		     const char *filename = "<string>")
 {
   PyObject *m, *d;
 
@@ -300,8 +302,15 @@ eval_python_command (const char *command)
   d = PyModule_GetDict (m);
   if (d == NULL)
     return -1;
-  gdbpy_ref<> v (PyRun_StringFlags (command, Py_single_input, d, d, NULL));
-  if (v == NULL)
+
+  /* Use this API because it is in Python 3.2.  */
+  gdbpy_ref<> code (Py_CompileStringExFlags (command, filename, start_symbol,
+					     nullptr, -1));
+  if (code == nullptr)
+    return -1;
+
+  gdbpy_ref<> result (PyEval_EvalCode (code.get (), d, d));
+  if (result == nullptr)
     return -1;
 
   return 0;
@@ -324,7 +333,8 @@ python_interactive_command (const char *arg, int from_tty)
   if (arg && *arg)
     {
       std::string script = std::string (arg) + "\n";
-      err = eval_python_command (script.c_str ());
+      /* Py_single_input causes the result to be displayed.  */
+      err = eval_python_command (script.c_str (), Py_single_input);
     }
   else
     {
@@ -333,14 +343,12 @@ python_interactive_command (const char *arg, int from_tty)
     }
 
   if (err)
-    {
-      gdbpy_print_stack ();
-      error (_("Error while executing Python code."));
-    }
+    gdbpy_handle_exception ();
 }
 
-/* A wrapper around PyRun_SimpleFile.  FILE is the Python script to run
-   named FILENAME.
+/* Like PyRun_SimpleFile, but if there is an exception, it is not
+   automatically displayed.  FILE is the Python script to run named
+   FILENAME.
 
    On Windows hosts few users would build Python themselves (this is no
    trivial task on this platform), and thus use binaries built by
@@ -349,39 +357,13 @@ python_interactive_command (const char *arg, int from_tty)
    library.  Python, being built with VC, would use one version of the
    msvcr DLL (Eg. msvcr100.dll), while MinGW uses msvcrt.dll.
    A FILE * from one runtime does not necessarily operate correctly in
-   the other runtime.
+   the other runtime.  */
 
-   To work around this potential issue, we run code in Python to load
-   the script.  */
-
-static void
+static int
 python_run_simple_file (FILE *file, const char *filename)
 {
-#ifndef _WIN32
-
-  PyRun_SimpleFile (file, filename);
-
-#else /* _WIN32 */
-
-  /* Because we have a string for a filename, and are using Python to
-     open the file, we need to expand any tilde in the path first.  */
-  gdb::unique_xmalloc_ptr<char> full_path (tilde_expand (filename));
-
-  if (gdb_python_module == nullptr
-      || ! PyObject_HasAttrString (gdb_python_module, "_execute_file"))
-    error (_("Installation error: gdb._execute_file function is missing"));
-
-  gdbpy_ref<> return_value
-    (PyObject_CallMethod (gdb_python_module, "_execute_file", "s",
-			  full_path.get ()));
-  if (return_value == nullptr)
-    {
-      /* Use PyErr_PrintEx instead of gdbpy_print_stack to better match the
-	 behavior of the non-Windows codepath.  */
-      PyErr_PrintEx(0);
-    }
-
-#endif /* _WIN32 */
+  std::string contents = read_remainder_of_file (file);
+  return eval_python_command (contents.c_str (), Py_file_input, filename);
 }
 
 /* Given a command_line, return a command string suitable for passing
@@ -408,17 +390,15 @@ static void
 gdbpy_eval_from_control_command (const struct extension_language_defn *extlang,
 				 struct command_line *cmd)
 {
-  int ret;
-
   if (cmd->body_list_1 != nullptr)
     error (_("Invalid \"python\" block structure."));
 
   gdbpy_enter enter_py;
 
   std::string script = compute_python_string (cmd->body_list_0.get ());
-  ret = PyRun_SimpleString (script.c_str ());
-  if (ret)
-    error (_("Error while executing Python code."));
+  int ret = eval_python_command (script.c_str (), Py_file_input);
+  if (ret != 0)
+    gdbpy_handle_exception ();
 }
 
 /* Implementation of the gdb "python" command.  */
@@ -433,8 +413,9 @@ python_command (const char *arg, int from_tty)
   arg = skip_spaces (arg);
   if (arg && *arg)
     {
-      if (PyRun_SimpleString (arg))
-	error (_("Error while executing Python code."));
+      int ret = eval_python_command (arg, Py_file_input);
+      if (ret != 0)
+	gdbpy_handle_exception ();
     }
   else
     {
@@ -1021,7 +1002,9 @@ gdbpy_source_script (const struct extension_language_defn *extlang,
 		     FILE *file, const char *filename)
 {
   gdbpy_enter enter_py;
-  python_run_simple_file (file, filename);
+  int result = python_run_simple_file (file, filename);
+  if (result != 0)
+    gdbpy_handle_exception ();
 }
 
 \f
@@ -1653,7 +1636,9 @@ gdbpy_source_objfile_script (const struct extension_language_defn *extlang,
   scoped_restore restire_current_objfile
     = make_scoped_restore (&gdbpy_current_objfile, objfile);
 
-  python_run_simple_file (file, filename);
+  int result = python_run_simple_file (file, filename);
+  if (result != 0)
+    gdbpy_print_stack ();
 }
 
 /* Set the current objfile to OBJFILE and then execute SCRIPT
@@ -1674,7 +1659,9 @@ gdbpy_execute_objfile_script (const struct extension_language_defn *extlang,
   scoped_restore restire_current_objfile
     = make_scoped_restore (&gdbpy_current_objfile, objfile);
 
-  PyRun_SimpleString (script);
+  int ret = eval_python_command (script, Py_file_input);
+  if (ret != 0)
+    gdbpy_print_stack ();
 }
 
 /* Return the current Objfile, or None if there isn't one.  */
@@ -2332,21 +2319,15 @@ test_python ()
       {
 	CMD (output);
       }
-    catch (const gdb_exception &e)
+    catch (const gdb_exception_quit &e)
       {
 	saw_exception = true;
-	SELF_CHECK (e.reason == RETURN_ERROR);
-	SELF_CHECK (e.error == GENERIC_ERROR);
-	SELF_CHECK (*e.message == "Error while executing Python code.");
+	SELF_CHECK (e.reason == RETURN_QUIT);
+	SELF_CHECK (e.error == GDB_NO_ERROR);
+	SELF_CHECK (*e.message == "Quit");
       }
     SELF_CHECK (saw_exception);
-    std::string ref_output_0 ("Traceback (most recent call last):\n"
-			      "  File \"<string>\", line 0, in <module>\n"
-			      "KeyboardInterrupt\n");
-    std::string ref_output_1 ("Traceback (most recent call last):\n"
-			      "  File \"<string>\", line 1, in <module>\n"
-			      "KeyboardInterrupt\n");
-    SELF_CHECK (output == ref_output_0 || output == ref_output_1);
+    SELF_CHECK (output.empty ());
   }
 
 #undef CMD
diff --git a/gdb/testsuite/gdb.ada/tasks.exp b/gdb/testsuite/gdb.ada/tasks.exp
index dd03a2e4a96..6e588408c9d 100644
--- a/gdb/testsuite/gdb.ada/tasks.exp
+++ b/gdb/testsuite/gdb.ada/tasks.exp
@@ -98,15 +98,15 @@ if {[allow_python_tests]} {
     gdb_test "python print(bp.thread)" "None"
     gdb_test "python bp.thread = 1" \
 	[multi_line \
-	     "RuntimeError: Cannot set both task and thread attributes\\." \
-	     "Error while executing Python code\\."] \
+	     "RuntimeError.*: Cannot set both task and thread attributes\\." \
+	     "Error occurred in Python.*"] \
 	"try setting the thread, but expect an error"
     gdb_test_no_output "python bp.task = None"
     gdb_test_no_output "python bp.thread = 1"
     gdb_test "python bp.task = 3" \
 	[multi_line \
-	     "RuntimeError: Cannot set both task and thread attributes\\." \
-	     "Error while executing Python code\\."] \
+	     "RuntimeError.*: Cannot set both task and thread attributes\\." \
+	     "Error occurred in Python.*"] \
 	"try setting the task, but expect an error"
 
     # Reset the breakpoint to the state required for the rest of this
diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp
index 1b0759a657d..3c58bf1281f 100644
--- a/gdb/testsuite/gdb.python/py-arch.exp
+++ b/gdb/testsuite/gdb.python/py-arch.exp
@@ -91,7 +91,7 @@ foreach size {0 1 2 3 4 8 16} {
 }
 
 gdb_test "python arch.integer_type(95)" \
-    ".*ValueError: no integer type of that size is available.*" \
+    ".*ValueError.* no integer type of that size is available.*" \
     "call integer_type with invalid size"
 
 # Test for gdb.architecture_names().  First we're going to grab the
diff --git a/gdb/testsuite/gdb.python/py-block.exp b/gdb/testsuite/gdb.python/py-block.exp
index 5e8fba43ea0..942611af305 100644
--- a/gdb/testsuite/gdb.python/py-block.exp
+++ b/gdb/testsuite/gdb.python/py-block.exp
@@ -44,9 +44,9 @@ gdb_test "python print (block.function)" "None" "first anonymous block"
 gdb_test "python print (block.start)" "${decimal}" "check start not None"
 gdb_test "python print (block.end)" "${decimal}" "check end not None"
 gdb_test "python print (block\['f'\].name == 'f')" "True" "check variable access"
-gdb_test "python print (block\['nonexistent'\])" ".*KeyError: 'nonexistent'.*" \
+gdb_test "python print (block\['nonexistent'\])" ".*KeyError.*: nonexistent.*" \
          "check nonexistent variable"
-gdb_test "python print (block\[42\])" ".*TypeError: Expected a string.*" \
+gdb_test "python print (block\[42\])" ".*TypeError.*: Expected a string.*" \
          "check non-string key"
 
 # Test global/static blocks
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
index 67da48d2f48..1d0e96a15dd 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -190,7 +190,7 @@ proc_with_prefix test_bkpt_deletion { } {
     gdb_py_test_silent_cmd  "python dp1.delete()" \
 	"Delete Breakpoint" 0
     gdb_test "python print (dp1.number)" \
-	"RuntimeError: Breakpoint 2 is invalid.*" \
+	"RuntimeError.*: Breakpoint 2 is invalid.*" \
 	"Check breakpoint invalidated"
     gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" \
 	"Get Breakpoint List" 0
@@ -275,7 +275,7 @@ proc_with_prefix test_bkpt_thread_and_inferior { } {
 	gdb_test "python print(bp.thread)" "1"
 	gdb_test "python print(bp.inferior)" "None"
 	gdb_test "python bp.inferior = 1" \
-	    "RuntimeError: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*"
+	    "RuntimeError.*: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*"
 	gdb_test_no_output "python bp.thread = None"
 	gdb_test_no_output "python bp.inferior = 1" \
 	    "set the inferior now the thread has been cleared"
@@ -289,7 +289,7 @@ proc_with_prefix test_bkpt_thread_and_inferior { } {
 	gdb_test "python print(bp.thread)" "None"
 	gdb_test "python print(bp.inferior)" "1"
 	gdb_test "python bp.thread = 1" \
-	    "RuntimeError: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*"
+	    "RuntimeError.*: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*"
 	gdb_test_no_output "python bp.inferior = None"
 	gdb_test_no_output "python bp.thread = 1" \
 	    "set the thread now the inferior has been cleared"
@@ -522,7 +522,7 @@ proc_with_prefix test_bkpt_eval_funcs { } {
 	"end" ""
 
     gdb_test "python eval_bp2.stop = stop_func"  \
-	"RuntimeError: Only one stop condition allowed.  There is currently a GDB.*" \
+	"RuntimeError.*: Only one stop condition allowed.  There is currently a GDB.*" \
 	"assign stop function to a breakpoint that has a condition"
 
     delete_breakpoints
@@ -589,7 +589,7 @@ proc_with_prefix test_bkpt_temporary { } {
 	".*$srcfile:$ibp_location.*"
     gdb_test "python print (ibp.count)" "1" \
 	"Check temporary stop callback executed before deletion."
-    gdb_test "python print (ibp.temporary)" "RuntimeError: Breakpoint 2 is invalid.*" \
+    gdb_test "python print (ibp.temporary)" "RuntimeError.*: Breakpoint 2 is invalid.*" \
 	"Check temporary breakpoint is deleted after being hit"
     gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
 	"Check info breakpoints shows temporary breakpoint is deleted"
@@ -707,7 +707,7 @@ proc_with_prefix test_bkpt_explicit_loc {} {
 
     delete_breakpoints
     gdb_test "python bp1 = gdb.Breakpoint (line=bp1)" \
-	"RuntimeError: Line keyword should be an integer or a string.*" \
+	"RuntimeError.*: Line keyword should be an integer or a string.*" \
 	"set explicit breakpoint by invalid line type"
 
     delete_breakpoints
@@ -736,7 +736,7 @@ proc_with_prefix test_bkpt_explicit_loc {} {
 
     delete_breakpoints
     gdb_test "python bp1 = gdb.Breakpoint (source=\"$srcfile\")" \
-	"RuntimeError: Specifying a source must also include a line, label or function.*" \
+	"RuntimeError.*: Specifying a source must also include a line, label or function.*" \
 	"set invalid explicit breakpoint by source only"
 
     gdb_test "python bp1 = gdb.Breakpoint (source=\"foo.c\", line=\"5\")" \
@@ -859,8 +859,8 @@ proc_with_prefix test_catchpoints {} {
     # the python api.
     gdb_test "python gdb.Breakpoint (\"syscall\", type=gdb.BP_CATCHPOINT)" \
 	[multi_line \
-	     "gdb.error: BP_CATCHPOINT not supported" \
-	     "Error while executing Python code\\."] \
+	     "gdb.error.*: BP_CATCHPOINT not supported" \
+	     "Error occurred in Python:.*"] \
 	"create a catchpoint via the api"
 
     # Setup a catchpoint.
diff --git a/gdb/testsuite/gdb.python/py-connection.exp b/gdb/testsuite/gdb.python/py-connection.exp
index fa995f19d3d..ca78b37c4f1 100644
--- a/gdb/testsuite/gdb.python/py-connection.exp
+++ b/gdb/testsuite/gdb.python/py-connection.exp
@@ -65,10 +65,10 @@ gdb_test "python print(conn.is_valid())" "False" "is_valid returns False"
 # Now check that accessing properties of the invalid connection cases
 # an error.
 gdb_test "python print(conn.num)" \
-    "RuntimeError: Connection no longer exists\\.\r\n.*"
+    "RuntimeError.*: Connection no longer exists\\.\r\n.*"
 gdb_test "python print(conn.type)" \
-    "RuntimeError: Connection no longer exists\\.\r\n.*"
+    "RuntimeError.*: Connection no longer exists\\.\r\n.*"
 gdb_test "python print(conn.description)" \
-    "RuntimeError: Connection no longer exists\\.\r\n.*"
+    "RuntimeError.*: Connection no longer exists\\.\r\n.*"
 gdb_test "python print(conn.details)" \
-    "RuntimeError: Connection no longer exists\\.\r\n.*"
+    "RuntimeError.*: Connection no longer exists\\.\r\n.*"
diff --git a/gdb/testsuite/gdb.python/py-disasm.exp b/gdb/testsuite/gdb.python/py-disasm.exp
index 0458b33c5a9..7c6f972a7e7 100644
--- a/gdb/testsuite/gdb.python/py-disasm.exp
+++ b/gdb/testsuite/gdb.python/py-disasm.exp
@@ -164,16 +164,16 @@ foreach plan $test_plans {
 with_test_prefix "DisassemblerResult errors" {
     gdb_test "python gdb.disassembler.DisassemblerResult(0, 'abc')" \
 	[multi_line \
-	     "ValueError: Length must be greater than 0." \
-	     "Error while executing Python code."]
+	     "ValueError.*: Length must be greater than 0." \
+	     "Error occurred in Python.*"]
     gdb_test "python gdb.disassembler.DisassemblerResult(-1, 'abc')" \
 	[multi_line \
-	     "ValueError: Length must be greater than 0." \
-	     "Error while executing Python code."]
+	     "ValueError.*: Length must be greater than 0." \
+	     "Error occurred in Python.*"]
     gdb_test "python gdb.disassembler.DisassemblerResult(1, '')" \
 	[multi_line \
-	     "ValueError: String must not be empty." \
-	     "Error while executing Python code."]
+	     "ValueError.*: String must not be empty.*" \
+	     "Error occurred in Python.*"]
 }
 
 # Check that the architecture specific disassemblers can override the
@@ -255,8 +255,8 @@ with_test_prefix "Bad DisassembleInfo creation" {
     gdb_test "python print(my_info.is_valid())" "True"
     gdb_test "python gdb.disassembler.builtin_disassemble(my_info)" \
 	[multi_line \
-	     "RuntimeError: DisassembleInfo is no longer valid\\." \
-	     "Error while executing Python code\\."]
+	     "RuntimeError.*: DisassembleInfo is no longer valid\\." \
+	     "Error occurred in Python.*"]
 }
 
 # Some of the disassembler related types should not be sub-typed,
@@ -274,8 +274,8 @@ with_test_prefix "check inheritance" {
 	    "     pass" "" \
 	    "end" \
 	    [multi_line \
-		 "TypeError: type '${type_ptn}' is not an acceptable base type" \
-		 "Error while executing Python code\\."]
+		 "TypeError.*: type '${type_ptn}' is not an acceptable base type" \
+		 "Error occurred in Python.*"]
     }
 }
 
@@ -283,15 +283,15 @@ with_test_prefix "check inheritance" {
 # Test some error conditions when creating a DisassemblerResult object.
 gdb_test "python result = gdb.disassembler.DisassemblerResult()" \
     [multi_line \
-	 "TypeError: [missing_arg_pattern length 1]" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: [missing_arg_pattern length 1]" \
+	 "Error occurred in Python.*"] \
     "try to create a DisassemblerResult without a length argument"
 
 foreach len {0 -1} {
     gdb_test "python result = gdb.disassembler.DisassemblerResult($len)" \
 	[multi_line \
-	     "ValueError: Length must be greater than 0\\." \
-	     "Error while executing Python code\\."] \
+	     "ValueError.*: Length must be greater than 0\\." \
+	     "Error occurred in Python.*"] \
 	"try to create a DisassemblerResult with length $len"
 }
 
@@ -300,7 +300,7 @@ foreach len {0 -1} {
 foreach type {DisassemblerTextPart DisassemblerAddressPart} {
     gdb_test "python result = gdb.disassembler.${type}()" \
 	[multi_line \
-	     "RuntimeError: Cannot create instances of DisassemblerPart\\." \
-	     "Error while executing Python code\\."] \
+	     "RuntimeError.*: Cannot create instances of DisassemblerPart\\." \
+	     "Error occurred in Python.*"] \
 	 "try to create an instance of ${type}"
 }
diff --git a/gdb/testsuite/gdb.python/py-error.exp b/gdb/testsuite/gdb.python/py-error.exp
index 58e8549453f..6eb9cc3d659 100644
--- a/gdb/testsuite/gdb.python/py-error.exp
+++ b/gdb/testsuite/gdb.python/py-error.exp
@@ -50,7 +50,12 @@ if {$test2 == ""} {
 set remote_python_file [gdb_remote_download host \
 			    ${srcdir}/${subdir}/${testfile}.py]
 
-# argc=LookupError: unknown encoding: IBM1047
-gdb_test "source $remote_python_file" "Traceback.*ClassName.*\r\nLookupError: unknown encoding: $charset" $test2
+# With the new way that "source" works, it isn't really possible for
+# this to fail "correctly".  Converting the filename to a Python
+# unicode object will fail -- and, mysteriously, without setting a
+# real exception.
+gdb_test "source $remote_python_file" \
+    "An error occurred in Python.*" \
+    $test2
 
 gdb_test "p 1" " = 1" "no delayed error"
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
index 6b72ddb2186..c2a85b1237c 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
@@ -85,7 +85,7 @@ with_test_prefix "normal conditions" {
 
     gdb_test "finish" "main.*" "return to main()"
     gdb_test "python MyFinishBreakpoint (None, gdb.selected_frame ())" \
-	"ValueError: \"FinishBreakpoint\" not meaningful in the outermost frame..*" \
+	"ValueError.*: \"FinishBreakpoint\" not meaningful in the outermost frame..*" \
 	"check FinishBP not allowed in main"
 }
 
diff --git a/gdb/testsuite/gdb.python/py-format-address.exp b/gdb/testsuite/gdb.python/py-format-address.exp
index 06654d98954..8e7cf47e03a 100644
--- a/gdb/testsuite/gdb.python/py-format-address.exp
+++ b/gdb/testsuite/gdb.python/py-format-address.exp
@@ -84,27 +84,27 @@ gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, None, None))"
 # Now forget the architecture, this should fail.
 gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, inf.progspace))" \
     [multi_line \
-	 "ValueError: The architecture and progspace arguments must both be supplied" \
-	 "Error while executing Python code\\."] \
+	 "ValueError.*: The architecture and progspace arguments must both be supplied" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address passing program space only"
 
 gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, inf.progspace, None))" \
     [multi_line \
-	 "ValueError: The architecture and progspace arguments must both be supplied" \
-	 "Error while executing Python code\\."] \
+	 "ValueError.*: The architecture and progspace arguments must both be supplied" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address passing real program space, but architecture is None"
 
 # Now skip the program space argument.
 gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, architecture=inf.architecture()))" \
     [multi_line \
-	 "ValueError: The architecture and progspace arguments must both be supplied" \
-	 "Error while executing Python code\\."] \
+	 "ValueError.*: The architecture and progspace arguments must both be supplied" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address passing architecture only"
 
 gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, None, inf.architecture()))" \
     [multi_line \
-	 "ValueError: The architecture and progspace arguments must both be supplied" \
-	 "Error while executing Python code\\."] \
+	 "ValueError.*: The architecture and progspace arguments must both be supplied" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address passing real architecture, but progspace is None"
 
 # Now, before we add a second inferior, lets just check we can format
@@ -155,14 +155,14 @@ gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, inf2.progspace,
 # Try pasing incorrect object types for program space and architecture.
 gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, inf2.progspace, inf2.progspace))" \
     [multi_line \
-	 "TypeError: The architecture argument is not a gdb.Architecture object" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: The architecture argument is not a gdb.Architecture object" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address pass wrong object type for architecture"
 
 gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, inf2.architecture(), inf2.architecture()))" \
     [multi_line \
-	 "TypeError: The progspace argument is not a gdb.Progspace object" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: The progspace argument is not a gdb.Progspace object" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address pass wrong object type for progspace"
 
 # Now invalidate inferior 2's program space, and try using that.
@@ -171,6 +171,6 @@ gdb_test "python arch = inf2.architecture()"
 gdb_test "remove-inferior 2"
 gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, pspace, arch))" \
     [multi_line \
-	 "ValueError: The progspace argument is not valid" \
-	 "Error while executing Python code\\."] \
+	 "ValueError.*: The progspace argument is not valid" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address called with an invalid program space"
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index cd434b8fd4b..0c70ad562c7 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -1102,22 +1102,22 @@ proc_with_prefix test_invalid_args {} {
   check_format_string \
     "a_point_t" \
     "12" \
-    "TypeError: format_string\\(\\) takes 0 positional arguments but 1 were given.*"
+    "TypeError.*: format_string\\(\\) takes 0 positional arguments but 1 were given.*"
 
   check_format_string \
     "a_point_t" \
     "invalid=True" \
-    "TypeError: 'invalid' is an invalid keyword argument for this function.*"
+    "TypeError.*: 'invalid' is an invalid keyword argument for this function.*"
 
   check_format_string \
     "a_point_t" \
     "raw='hello'" \
-    "TypeError: argument 1 must be bool, not str.*"
+    "TypeError.*: argument 1 must be bool, not str.*"
 
   check_format_string \
     "a_point_t" \
     "format='xd'" \
-    "ValueError: a single character is required.*"
+    "ValueError.*: a single character is required.*"
 }
 
 # Check the styling argument to format_string.  This function needs to
diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp
index 110ddf24480..8f776eb08a5 100644
--- a/gdb/testsuite/gdb.python/py-frame.exp
+++ b/gdb/testsuite/gdb.python/py-frame.exp
@@ -77,25 +77,25 @@ gdb_test "python print (bf1.read_var(\"i\", sb).type)" "int" "test int i"
 # Test what happens when we provide a block of the wrong type.
 gdb_test "python print (bf1.read_var(\"i\", \"some_block\"))" \
     [multi_line \
-	 "TypeError: argument 2 must be gdb\\.Block, not str" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: argument 2 must be gdb\\.Block, not str" \
+	 "Error occurred in Python.*"] \
     "check invalid block type error"
 gdb_test "python print (bf1.read_var(block = \"some_block\", variable = \"i\"))" \
     [multi_line \
-	 "TypeError: argument 2 must be gdb\\.Block, not str" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: argument 2 must be gdb\\.Block, not str" \
+	 "Error occurred in Python.*"] \
     "check invalid block type error when named args are used"
 
 # Test what happens when we provide a variable of the wrong type.
 gdb_test "python print (bf1.read_var(None))" \
     [multi_line \
-	 "TypeError: argument 1 must be gdb\\.Symbol or str, not NoneType" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: argument 1 must be gdb\\.Symbol or str, not NoneType" \
+	 "Error occurred in Python.*"] \
     "check read_var error when variable is None"
 gdb_test "python print (bf1.read_var(sb))" \
     [multi_line \
-	 "TypeError: argument 1 must be gdb\\.Symbol or str, not gdb\\.Block" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: argument 1 must be gdb\\.Symbol or str, not gdb\\.Block" \
+	 "Error occurred in Python.*"] \
     "check read_var error when variable is a gdb.Block"
 
 gdb_breakpoint "f2"
@@ -141,7 +141,7 @@ gdb_test "python print ('result = %s' % f0.pc ())" " = \[0-9\]+" "test Frame.pc"
 gdb_test "python print ('result = %s' % (f0.older () == f1))" " = True" "test Frame.older"
 gdb_test "python print ('result = %s' % (f1.newer () == f0))" " = True" "test Frame.newer"
 gdb_test "python print ('result = %s' % f0.read_var ('variable_which_surely_doesnt_exist'))" \
-  "ValueError: Variable 'variable_which_surely_doesnt_exist' not found.*Error while executing Python code." \
+  "ValueError.*: Variable 'variable_which_surely_doesnt_exist' not found.*Error occurred in Python.*" \
   "test Frame.read_var - error"
 gdb_test "python print ('result = %s' % f0.read_var ('a'))" " = 1" "test Frame.read_var - success"
 
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index 2968e027812..c14f2d2796c 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -122,8 +122,8 @@ gdb_test "python print(worker_thread._user_attribute)" "123" \
     "read back user defined attribute"
 gdb_test "python print(main_thread._user_attribute)" \
     [multi_line \
-	 "AttributeError: 'gdb\\.InferiorThread' object has no attribute '_user_attribute'" \
-	 "Error while executing Python code\\."] \
+	 "AttributeError.*: 'gdb\\.InferiorThread' object has no attribute '_user_attribute'" \
+	 "Error occurred in Python.*"] \
     "attempt to read non-existent user defined attribute"
 
 # Proceed to the next test.
@@ -162,8 +162,8 @@ set num [add_inferior]
 # but that the first inferior does still have the attribute.
 gdb_test "python print(gdb.inferiors()\[1\]._user_attr)" \
     [multi_line \
-	 "AttributeError: 'gdb\\.Inferior' object has no attribute '_user_attr'" \
-	 "Error while executing Python code\\."] \
+	 "AttributeError.*: 'gdb\\.Inferior' object has no attribute '_user_attr'" \
+	 "Error occurred in Python.*"] \
     "check new inferior doesn't have user defined attribute"
 gdb_test "python print(gdb.inferiors()\[0\]._user_attr)" \
     "123" "read back user defined attribute again"
@@ -366,21 +366,21 @@ with_test_prefix "is_valid" {
     # Test that other properties and methods handle the removed inferior
     # correctly.
     gdb_test "python print (inf_list\[1\].num)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].connection_num)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].connection)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].pid)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].was_attached)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].progspace)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].threads ())" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].thread_from_thread_handle (1))" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
 }
 
 # Test gdb.selected_inferior()
diff --git a/gdb/testsuite/gdb.python/py-lazy-string.exp b/gdb/testsuite/gdb.python/py-lazy-string.exp
index 8e7eca846b0..a00f47b1e2a 100644
--- a/gdb/testsuite/gdb.python/py-lazy-string.exp
+++ b/gdb/testsuite/gdb.python/py-lazy-string.exp
@@ -40,13 +40,13 @@ gdb_test "python print (nullstr.length)" "0" "null lazy string length"
 gdb_test "python print (nullstr.address)" "0" "null lazy string address"
 gdb_test "python print (nullstr.type)" "const char \\*" "null lazy string type"
 gdb_test "python print(nullstr.value())" \
-    "gdb.MemoryError: Cannot create a value from NULL.*Error while executing Python code." \
+    "gdb.MemoryError.*: Cannot create a value from NULL.*Error occurred in Python.*" \
     "create value from NULL"
 gdb_test "python print(null.lazy_string(length=3).value())" \
-    "gdb.MemoryError: Cannot create a lazy string with address 0x0, and a non-zero length.*Error while executing Python code." \
+    "gdb.MemoryError.*: Cannot create a lazy string with address 0x0, and a non-zero length.*Error occurred in Python.*" \
     "null lazy string with non-zero length"
 gdb_test "python print(null.lazy_string(length=-2))" \
-    "ValueError: Invalid length.*Error while executing Python code." \
+    "ValueError.*: Invalid length.*Error occurred in Python.*" \
     "bad length"
 
 foreach var_spec { { "ptr" "pointer" "const char \\*" -1 } \
diff --git a/gdb/testsuite/gdb.python/py-mi-cmd.exp b/gdb/testsuite/gdb.python/py-mi-cmd.exp
index d9fba23b39b..28c71cd75f3 100644
--- a/gdb/testsuite/gdb.python/py-mi-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-mi-cmd.exp
@@ -70,7 +70,7 @@ mi_gdb_test "-pycmd bk2" \
 
 mi_gdb_test "-pycmd bk3" \
     [multi_line \
-	 "&\"TypeError: __repr__ returned non-string \\(type BadKey\\)..\"" \
+	 "&\"TypeError.*: __repr__ returned non-string \\(type BadKey\\)..\"" \
 	 "\\^error,msg=\"Error occurred in Python: __repr__ returned non-string \\(type BadKey\\)\""] \
     "-pycmd bk3"
 
@@ -156,23 +156,23 @@ mi_gdb_test "-pycmd-new int" \
     "-pycmd-new int - defined from MI"
 
 mi_gdb_test "python pycmd1('')" \
-    ".*&\"ValueError: MI command name is empty\\...\".*\\^error,msg=\"Error while executing Python code\\.\"" \
+    ".*&\"ValueError.*: MI command name is empty\\...\".*\\^error,msg=\"Error occurred in Python.*\"" \
     "empty MI command name"
 
 mi_gdb_test "python pycmd1('-')" \
     [multi_line \
 	 ".*" \
-	 "&\"ValueError: MI command name does not start with '-' followed by at least one letter or digit\\...\"" \
-	 "&\"Error while executing Python code\\...\"" \
-	 "\\^error,msg=\"Error while executing Python code\\.\""] \
+	 "&\"ValueError.*: MI command name does not start with '-' followed by at least one letter or digit\\...\"" \
+	 "&\"Error occurred in Python.*..\"" \
+	 "\\^error,msg=\"Error occurred in Python.*\""] \
     "invalid MI command name"
 
 mi_gdb_test "python pycmd1('-bad-character-@')" \
     [multi_line \
 	 ".*" \
-	 "&\"ValueError: MI command name contains invalid character: @\\...\"" \
-	 "&\"Error while executing Python code\\...\"" \
-	 "\\^error,msg=\"Error while executing Python code\\.\""] \
+	 "&\"ValueError.*: MI command name contains invalid character: @\\...\"" \
+	 "&\"Error occurred in Python.*..\"" \
+	 "\\^error,msg=\"Error occurred in Python.*\""] \
     "invalid character in MI command name"
 
 mi_gdb_test "python cmd=pycmd1('-abc')" \
@@ -258,9 +258,9 @@ mi_gdb_test "-aa" \
 mi_gdb_test "python aa.__init__('-bb', 'message three', 'zzz')" \
     [multi_line \
 	 ".*" \
-	 "&\"ValueError: can't reinitialize object with a different command name..\"" \
-	 "&\"Error while executing Python code\\...\"" \
-	 "\\^error,msg=\"Error while executing Python code\\.\""] \
+	 "&\"ValueError.*: can't reinitialize object with a different command name..\"" \
+	 "&\"Error occurred in Python.*..\"" \
+	 "\\^error,msg=\"Error occurred in Python.*\""] \
     "attempt to reinitialise aa variable to a new command name"
 
 mi_gdb_test "-aa" \
@@ -274,9 +274,9 @@ mi_gdb_test "python aa.installed = False" \
 mi_gdb_test "python aa.__init__('-bb', 'message three', 'zzz')" \
     [multi_line \
 	 ".*" \
-	 "&\"ValueError: can't reinitialize object with a different command name..\"" \
-	 "&\"Error while executing Python code\\...\"" \
-	 "\\^error,msg=\"Error while executing Python code\\.\""] \
+	 "&\"ValueError.*: can't reinitialize object with a different command name..\"" \
+	 "&\"Error occurred in Python.*..\"" \
+	 "\\^error,msg=\"Error occurred in Python.*\""] \
     "attempt to reinitialise aa variable to a new command name while uninstalled"
 
 mi_gdb_test "python aa.__init__('-aa', 'message three', 'zzz')" \
@@ -299,7 +299,7 @@ mi_gdb_test "python no_invoke('-no-invoke')" ".*\\^done" \
 mi_gdb_test "-no-invoke" \
     [multi_line \
 	 ".*" \
-	 "&\"AttributeError: 'no_invoke' object has no attribute 'invoke'..\"" \
+	 "&\"AttributeError.*: 'no_invoke' object has no attribute 'invoke'..\"" \
 	 "\\^error,msg=\"Error occurred in Python: 'no_invoke' object has no attribute 'invoke'\""] \
     "execute -no-invoke command, which is missing the invoke method"
 
@@ -312,14 +312,14 @@ mi_gdb_test "python delattr(no_invoke, 'invoke')" ".*\\^done"
 mi_gdb_test "-hello" \
     [multi_line \
 	 ".*" \
-	 "&\"AttributeError: 'no_invoke' object has no attribute 'invoke'..\"" \
+	 "&\"AttributeError.*: 'no_invoke' object has no attribute 'invoke'..\"" \
 	 "\\^error,msg=\"Error occurred in Python: 'no_invoke' object has no attribute 'invoke'\""] \
     "execute -hello command, that had its invoke method removed"
 mi_gdb_test "python cmd.invoke = 'string'" ".*\\^done"
 mi_gdb_test "-hello" \
     [multi_line \
 	 ".*" \
-	 "&\"TypeError: 'str' object is not callable..\"" \
+	 "&\"TypeError.*: 'str' object is not callable..\"" \
 	 "\\^error,msg=\"Error occurred in Python: 'str' object is not callable\""] \
     "execute command with invoke set to a string"
 
@@ -327,9 +327,9 @@ mi_gdb_test "-hello" \
 mi_gdb_test "python cmd = pycmd2('-data-disassemble')" \
     [multi_line \
 	 ".*" \
-	 "&\"RuntimeError: unable to add command, name is already in use..\"" \
-	 "&\"Error while executing Python code\\...\"" \
-	 "\\^error,msg=\"Error while executing Python code\\.\""] \
+	 "&\"RuntimeError.*: unable to add command, name is already in use..\"" \
+	 "&\"Error occurred in Python.*..\"" \
+	 "\\^error,msg=\"Error occurred in Python.*\""] \
     "try to register a command that replaces -data-disassemble"
 
 
diff --git a/gdb/testsuite/gdb.python/py-missing-debug.exp b/gdb/testsuite/gdb.python/py-missing-debug.exp
index 0aa4aaa010b..d1eef34c3f3 100644
--- a/gdb/testsuite/gdb.python/py-missing-debug.exp
+++ b/gdb/testsuite/gdb.python/py-missing-debug.exp
@@ -201,8 +201,8 @@ proc check_bad_name {name} {
     set name_re [string_to_regexp $name]
     set re \
 	[multi_line \
-	     "ValueError: invalid character '.' in handler name: $name_re" \
-	     "Error while executing Python code\\."]
+	     "ValueError.*: invalid character '.' in handler name: $name_re" \
+	     "Error occurred in Python.*"]
 
     gdb_test "python register(\"$name\")" $re \
 	"check that '$name' is not accepted"
@@ -442,13 +442,13 @@ with_test_prefix "check handler replacement" {
     # the same name.
     gdb_test "python gdb.missing_debug.register_handler(pspace, log_handler(\"Foo\"))" \
 	[multi_line \
-	     "RuntimeError: Handler Foo already exists\\." \
-	     "Error while executing Python code\\."]
+	     "RuntimeError.*: Handler Foo already exists\\." \
+	     "Error occurred in Python.*"]
 
     gdb_test "python gdb.missing_debug.register_handler(handler=log_handler(\"Foo\"), locus=pspace)" \
 	[multi_line \
-	     "RuntimeError: Handler Foo already exists\\." \
-	     "Error while executing Python code\\."]
+	     "RuntimeError.*: Handler Foo already exists\\." \
+	     "Error occurred in Python.*"]
 
     # And now try again, but this time with 'replace=True', we
     # shouldn't get an error in this case.
@@ -464,8 +464,8 @@ with_test_prefix "check handler replacement" {
 
     gdb_test "python gdb.missing_debug.register_handler(pspace, log_handler(\"Foo\"))" \
 	[multi_line \
-	     "RuntimeError: Handler Foo already exists\\." \
-	     "Error while executing Python code\\."] \
+	     "RuntimeError.*: Handler Foo already exists\\." \
+	     "Error occurred in Python.*"] \
 	"still get an error when handler is disabled"
 
     gdb_test_no_output \
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index 1ddc3ddab36..2f5b7752b43 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -30,7 +30,7 @@ if {![runto_main]} {
     return 0
 }
 
-set python_error_text "Error while executing Python code\\."
+set python_error_text "Error occurred in Python.*"
 
 gdb_py_test_silent_cmd "python sym = gdb.lookup_symbol(\"some_var\")" \
     "Find a symbol in objfile" 1
diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp
index 94702f42816..de524f49ad6 100644
--- a/gdb/testsuite/gdb.python/py-parameter.exp
+++ b/gdb/testsuite/gdb.python/py-parameter.exp
@@ -342,7 +342,7 @@ proc_with_prefix test_gdb_parameter { } {
     } {
 	clean_restart
 
-	set param_range_error ".*gdb.error: integer -1 out of range.*"
+	set param_range_error ".*gdb.error.*: integer -1 out of range.*"
 	switch -- $param {
 	    "listsize" {
 		set param_get_zero None
@@ -438,8 +438,8 @@ proc_with_prefix test_integer_parameter { } {
 	    "test_param_$kind = TestNodocParam ('test-$kind')" "" \
 	    "end"
 
-	set param_range_error "RuntimeError: Range exceeded.*"
-	set param_integer_error "RuntimeError: The value must be integer.*"
+	set param_range_error "RuntimeError.*: Range exceeded.*"
+	set param_integer_error "RuntimeError.*: The value must be integer.*"
 	switch -- $kind {
 	    PARAM_UINTEGER {
 		set param_get_zero None
@@ -610,13 +610,13 @@ proc_with_prefix test_ambiguous_parameter {} {
 
     # Test ambiguous names.
     gdb_test "python print(gdb.parameter('test-ambiguou'))" \
-	"Parameter .* is ambiguous.*Error while executing Python code."
+	"Parameter .* is ambiguous.*Error occurred in Python.*"
     gdb_test "python print(gdb.parameter('test-ambiguous-'))" \
-	"Parameter .* is ambiguous.*Error while executing Python code."
+	"Parameter .* is ambiguous.*Error occurred in Python.*"
     gdb_test "python print(gdb.parameter('test-ambiguous-v'))" \
-	"Parameter .* is ambiguous.*Error while executing Python code."
+	"Parameter .* is ambiguous.*Error occurred in Python.*"
     gdb_test "python print(gdb.parameter('test-ambiguous-value-1a'))" \
-	"Could not find parameter.*Error while executing Python code."
+	"Could not find parameter.*Error occurred in Python.*"
 }
 
 test_directories
diff --git a/gdb/testsuite/gdb.python/py-pp-registration.exp b/gdb/testsuite/gdb.python/py-pp-registration.exp
index 68599d67a16..4bfdf5e5612 100644
--- a/gdb/testsuite/gdb.python/py-pp-registration.exp
+++ b/gdb/testsuite/gdb.python/py-pp-registration.exp
@@ -102,7 +102,7 @@ with_test_prefix "replace" {
     gdb_test_no_output "py gdb.printing.register_pretty_printer(gdb, lookup_function_lookup_test)"
     gdb_test_no_output "py gdb.printing.register_pretty_printer(progspace, my_pretty_printer1)"
     gdb_test "py gdb.printing.register_pretty_printer(progspace, my_pretty_printer2, replace=False)" \
-	"RuntimeError: pretty-printer already registered: pp-test\r\nError while executing Python code."
+	"RuntimeError.*: pretty-printer already registered: pp-test\r\nError occurred in Python.*"
 
     with_test_prefix "test printers 1" {
 	test_printers "s1"
diff --git a/gdb/testsuite/gdb.python/py-progspace-events.exp b/gdb/testsuite/gdb.python/py-progspace-events.exp
index 47a9985317e..95e4ca8da0b 100644
--- a/gdb/testsuite/gdb.python/py-progspace-events.exp
+++ b/gdb/testsuite/gdb.python/py-progspace-events.exp
@@ -107,7 +107,7 @@ set warning_msg \
 
 gdb_test "step" \
     [multi_line \
-	 "^FreeProgspaceEvent: <gdb.Progspace object at $hex>(?:\r\n$warning_msg)*" \
+	 "^FreeProgspaceEvent.*: <gdb.Progspace object at $hex>(?:\r\n$warning_msg)*" \
 	 "do_parent_stuff \\(\\) at \[^\r\n\]+" \
 	 "$decimal\\s+\[^\r\n\]+"]
 
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index f76e1f9359a..0ae5b5673d8 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -55,8 +55,8 @@ gdb_test "python print (progspace.random_attribute)" "42" \
 
 # Check that we can't create new (invalid) gdb.Progspace objects.
 gdb_test "python gdb.Progspace()" \
-    [multi_line "TypeError: cannot create 'gdb.Progspace' instances" \
-	 "Error while executing Python code\\."] \
+    [multi_line "TypeError.*: cannot create 'gdb.Progspace' instances" \
+	 "Error occurred in Python.*"] \
     "check for error when calling gdb.Progspace() directly"
 
 if {![runto_main]} {
@@ -111,7 +111,7 @@ gdb_py_test_silent_cmd "python progspace2 = gdb.current_progspace()" \
 gdb_test "inferior 1" "Switching to inferior 1.*"
 gdb_test_no_output "remove-inferiors 2"
 gdb_test "python print (progspace2.objfiles ())" \
-    "RuntimeError: Program space no longer exists.*"
+    "RuntimeError.*: Program space no longer exists.*"
 
 gdb_test "python print (progspace2.symbol_file)" \
-    "RuntimeError: Program space no longer exists.*"
+    "RuntimeError.*: Program space no longer exists.*"
diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp
index 71ff52ed137..fba0b98f794 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
@@ -34,12 +34,12 @@ with_test_prefix "no or double record" {
 
     gdb_test_no_output "python gdb.start_recording(\"btrace\")"
     gdb_test "python gdb.start_recording(\"btrace\")" \
-	".*gdb\.error: The process is already being recorded\..*" \
+	".*gdb\.error.*: The process is already being recorded\..*" \
 	"already recording"
 
     gdb_test_no_output "python gdb.stop_recording()" "first"
     gdb_test "python gdb.stop_recording()" \
-	".*gdb\.error: No recording is currently active\..*" "second"
+	".*gdb\.error.*: No recording is currently active\..*" "second"
 }
 
 with_test_prefix "preopened record btrace" {
diff --git a/gdb/testsuite/gdb.python/py-record-full.exp b/gdb/testsuite/gdb.python/py-record-full.exp
index 19497fb3cd1..da38d1cab6b 100644
--- a/gdb/testsuite/gdb.python/py-record-full.exp
+++ b/gdb/testsuite/gdb.python/py-record-full.exp
@@ -34,12 +34,12 @@ with_test_prefix "no or double record" {
 
     gdb_test_no_output "python gdb.start_recording(\"full\")"
     gdb_test "python gdb.start_recording(\"full\")" \
-	".*gdb\.error: The process is already being recorded\..*" \
+	".*gdb\.error.*: The process is already being recorded\..*" \
 	"already recording"
 
     gdb_test_no_output "python gdb.stop_recording()" "first"
     gdb_test "python gdb.stop_recording()" \
-	".*gdb\.error: No recording is currently active\..*" "second"
+	".*gdb\.error.*: No recording is currently active\..*" "second"
 }
 
 with_test_prefix "preopened record full" {
diff --git a/gdb/testsuite/gdb.python/py-template.exp b/gdb/testsuite/gdb.python/py-template.exp
index fbb745506e2..bba80e3b870 100644
--- a/gdb/testsuite/gdb.python/py-template.exp
+++ b/gdb/testsuite/gdb.python/py-template.exp
@@ -50,7 +50,7 @@ proc test_template_arg {exefile type} {
     gdb_test "python print (foo.type.template_argument(0))" $t $type
 
     gdb_test "python print(foo.type.template_argument(-1))" \
-	"Template argument number must be non-negative\r\nError while executing Python code." \
+	"Template argument number must be non-negative\r\nError occurred in Python.*" \
 	"negative template argument number in template test of $type"
 }
 
diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp
index 60399774b1b..939f0a86f48 100644
--- a/gdb/testsuite/gdb.python/py-thrhandle.exp
+++ b/gdb/testsuite/gdb.python/py-thrhandle.exp
@@ -90,7 +90,7 @@ gdb_test "python print(gdb.selected_inferior().thread_from_handle(gdb.parse_and_
 # We should see an exception when passing an object of the wrong type.
 
 gdb_test "python print(gdb.selected_inferior().thread_from_handle(gdb.lookup_symbol('main')))" \
-         ".*TypeError: Argument 'handle' must be a thread handle object.*" \
+         ".*TypeError.*: Argument 'handle' must be a thread handle object.*" \
 	 "TypeError when passing a symbol object to thread_from_handle"
 
 # We should see an exception when passing too large of an object.
diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp
index 1e9e7152f78..74e123441c4 100644
--- a/gdb/testsuite/gdb.python/py-type.exp
+++ b/gdb/testsuite/gdb.python/py-type.exp
@@ -121,10 +121,10 @@ proc test_fields {lang} {
     gdb_test "python print (not not st.type)" "True" "check conversion to bool"
 
     # Test rejection of mapping operations on scalar types
-    gdb_test "python print (len (st.type\['a'\].type))" "TypeError: Type is not a structure, union, enum, or function type.*"
-    gdb_test "python print (st.type\['a'\].type.has_key ('x'))" "TypeError: Type is not a structure, union, enum, or function type.*"
-    gdb_test "python print (st.type\['a'\].type\['x'\])" "TypeError: Type is not a structure, union, enum, or function type.*"
-    gdb_test "python print (st.type\['a'\].type.keys ())" "TypeError: Type is not a structure, union, enum, or function type.*"
+    gdb_test "python print (len (st.type\['a'\].type))" "TypeError.*: Type is not a structure, union, enum, or function type.*"
+    gdb_test "python print (st.type\['a'\].type.has_key ('x'))" "TypeError.*: Type is not a structure, union, enum, or function type.*"
+    gdb_test "python print (st.type\['a'\].type\['x'\])" "TypeError.*: Type is not a structure, union, enum, or function type.*"
+    gdb_test "python print (st.type\['a'\].type.keys ())" "TypeError.*: Type is not a structure, union, enum, or function type.*"
 
     # Test conversion to bool on scalar types
     gdb_test "python print (not not st.type\['a'\].type)" "True"
@@ -167,7 +167,7 @@ proc test_fields {lang} {
     gdb_test "python print (gdb.parse_and_eval ('a_function').type.fields ()\[1\].type)" "char"
 
     # Test calling `fields` on a non-aggregate type.
-    gdb_test "python gdb.lookup_type('int').fields()" "TypeError: Type is not a structure, union, enum, or function type.*"
+    gdb_test "python gdb.lookup_type('int').fields()" "TypeError.*: Type is not a structure, union, enum, or function type.*"
   }
 }
 
@@ -224,7 +224,7 @@ proc test_range {} {
       # Test where a range does not exist.
       gdb_py_test_silent_cmd "print (st)" "print value (st)" 1
       gdb_py_test_silent_cmd "python st = gdb.history (0)" "get value (st) from history" 1
-      gdb_test "python print (st.type.range())" "RuntimeError: This type does not have a range.*" "check range for non ranged type."
+      gdb_test "python print (st.type.range())" "RuntimeError.*: This type does not have a range.*" "check range for non ranged type."
     }
   }
 }
@@ -264,7 +264,7 @@ proc test_template {} {
 proc test_is_signed {lang} {
     if {$lang == "c++"} {
 	gdb_test "python print(gdb.parse_and_eval ('c').type.is_signed)"  \
-	"ValueError: Type must be a scalar type.*"
+	"ValueError.*: Type must be a scalar type.*"
 	gdb_test "python print(gdb.parse_and_eval ('&c').type.is_signed == False)" "True"
     }
 
@@ -274,13 +274,13 @@ proc test_is_signed {lang} {
 
     gdb_test "python print(gdb.parse_and_eval ('ss.x').type.is_signed == True)" "True"
     gdb_test "python print(gdb.parse_and_eval ('ss').type.is_signed)" \
-	"ValueError: Type must be a scalar type.*"
+	"ValueError.*: Type must be a scalar type.*"
     gdb_test "python print(gdb.parse_and_eval ('uu').type.is_signed)"  \
-	"ValueError: Type must be a scalar type.*"
+	"ValueError.*: Type must be a scalar type.*"
     gdb_test "python print(gdb.parse_and_eval ('uu.i').type.is_signed == True)" "True"
     gdb_test "python print(gdb.parse_and_eval ('uu.f').type.is_signed == True)" "True"
     gdb_test "python print(gdb.parse_and_eval ('uu.a').type.is_signed)"  \
-	"ValueError: Type must be a scalar type.*"
+	"ValueError.*: Type must be a scalar type.*"
 
     gdb_test "python print(gdb.parse_and_eval ('&ss.x').type.is_signed == False)" "True"
     gdb_test "python print(gdb.parse_and_eval ('&uu').type.is_signed == False)" "True"
diff --git a/gdb/testsuite/gdb.python/py-unwind.exp b/gdb/testsuite/gdb.python/py-unwind.exp
index 1f88be0ac97..d5efc0216cf 100644
--- a/gdb/testsuite/gdb.python/py-unwind.exp
+++ b/gdb/testsuite/gdb.python/py-unwind.exp
@@ -97,8 +97,8 @@ check_for_fixed_backtrace "check backtrace after flush"
 # output to be sure.
 gdb_test "python global_test_unwinder.enabled = \"off\"" \
     [multi_line \
-	 "TypeError: incorrect type for enabled attribute: <class 'str'>" \
-	 "Error while executing Python code\\."]
+	 "TypeError.*: incorrect type for enabled attribute: <class 'str'>" \
+	 "Error occurred in Python.*"]
 check_info_unwinder "info unwinder after failed disable" on
 
 # While we're doing silly stuff, lets try to change the name of this
@@ -109,8 +109,8 @@ set pattern_1 "can't set attribute(?: 'name')?"
 set pattern_2 "property 'name' of 'TestUnwinder' object has no setter"
 gdb_test "python global_test_unwinder.name = \"foo\"" \
     [multi_line \
-	 "AttributeError: (?:${pattern_1}|${pattern_2})" \
-	 "Error while executing Python code\\."]
+	 "AttributeError.*: (?:${pattern_1}|${pattern_2})" \
+	 "Error occurred in Python.*"]
 check_info_unwinder "info unwinder after failed name change" on
 
 # Now actually disable the unwinder by manually adjusting the
@@ -149,8 +149,8 @@ gdb_test "python print(read_register_error)" "Bad register" \
 # Try to create an unwinder object with a non-string name.
 gdb_test "python obj = simple_unwinder(True)" \
     [multi_line \
-	 "TypeError: incorrect type for name: <class 'bool'>" \
-	 "Error while executing Python code\\."]
+	 "TypeError.*: incorrect type for name: <class 'bool'>" \
+	 "Error occurred in Python.*"]
 
 # Now register the simple_unwinder with a valid name, and use the
 # unwinder to capture a PendingFrame object.
@@ -195,8 +195,8 @@ foreach cmd {"pf.read_register(\"pc\")" \
 		 "pf.function()" } {
     gdb_test "python $cmd" \
 	[multi_line \
-	     "ValueError: gdb\\.PendingFrame is invalid\\." \
-	     "Error while executing Python code\\."]
+	     "ValueError.*: gdb\\.PendingFrame is invalid\\." \
+	     "Error occurred in Python.*"]
 }
 
 # Turn on the useful unwinder so we have the full backtrace again, and
@@ -265,11 +265,11 @@ gdb_test_multiline "Sub-class gdb.UnwindInfo " \
     "    pass" "" \
     "end" \
     [multi_line \
-	 "TypeError: type 'gdb\\.UnwindInfo' is not an acceptable base type" \
-	 "Error while executing Python code\\."]
+	 "TypeError.*: type 'gdb\\.UnwindInfo' is not an acceptable base type" \
+	 "Error occurred in Python.*"]
 
 # Check we can't directly instantiate a gdb.UnwindInfo.
 gdb_test "python uw = gdb.UnwindInfo()" \
     [multi_line \
-     "TypeError: cannot create 'gdb\\.UnwindInfo' instances" \
-     "Error while executing Python code\\."]
+     "TypeError.*: cannot create 'gdb\\.UnwindInfo' instances" \
+     "Error occurred in Python.*"]
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index ff6b8b931f4..aa674e8aa0d 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -159,7 +159,7 @@ proc test_value_numeric_ops {} {
   }
 
   gdb_test_multiple "python print ('result = ' + str(i+gdb.Value('foo')))" "catch throw of GDB error" {
-      -re "Traceback.*$gdb_prompt $"  {pass "catch throw of GDB error"}
+      -re "Error occurred in Python.*$gdb_prompt $"  {pass "catch throw of GDB error"}
       -re "result = .*$gdb_prompt $"  {fail "catch throw of GDB error"}
       -re "$gdb_prompt $"	      {fail "catch throw of GDB error"}
   }
@@ -270,7 +270,7 @@ proc test_value_in_inferior {} {
   if {$can_read_0} {
     untested $test
   } else {
-    gdb_test "python print (gdb.parse_and_eval('*(int*)0'))" "gdb.MemoryError: Cannot access memory at address 0x0.*" $test
+    gdb_test "python print (gdb.parse_and_eval('*(int*)0'))" "gdb.MemoryError.*: Cannot access memory at address 0x0.*" $test
   }
 
   # Test Python lazy value handling
@@ -281,10 +281,10 @@ proc test_value_in_inferior {} {
     gdb_test "python inval = gdb.parse_and_eval('*(int*)0')"
     gdb_test "python print (inval.is_lazy)" "True"
     gdb_test "python inval2 = inval+1" \
-	"gdb.MemoryError: Cannot access memory at address 0x0.*" \
+	"gdb.MemoryError.*: Cannot access memory at address 0x0.*" \
 	"$test, first test"
     gdb_test "python inval.fetch_lazy ()" \
-	"gdb.MemoryError: Cannot access memory at address 0x0.*" \
+	"gdb.MemoryError.*: Cannot access memory at address 0x0.*" \
 	"$test, second test"
   }
   set argc_value [get_integer_valueof "argc" 0]
@@ -338,7 +338,7 @@ proc test_value_in_inferior {} {
   # non-memory value.
   gdb_py_test_silent_cmd "python str = '\"str\"'" "set up str variable" 1
   gdb_test "python print (gdb.parse_and_eval (str).string (length = 10))" \
-      "gdb.error: Attempt to take address of value not located in memory.\r\nError while executing Python code."
+      "gdb.error.*: Attempt to take address of value not located in memory.\r\nError occurred in Python.*"
 
   gdb_test "python print (gdb.parse_and_eval ('shadowed'))" \
       97 "shadowed local value"
@@ -385,7 +385,7 @@ proc test_objfiles {} {
     gdb_test "python print (gdb.objfiles()\[0\].pretty_printers)" "\\\[\\\]"
 
     gdb_test "python gdb.objfiles()\[0\].pretty_printers = 0" \
-      "pretty_printers attribute must be a list.*Error while executing Python code."
+      "pretty_printers attribute must be a list.*Error occurred in Python.*"
 }
 
 proc test_value_after_death {} {
@@ -463,7 +463,7 @@ proc test_subscript_regression {exefile lang} {
 
  # Try to access an int with a subscript.  This should fail.
  gdb_test "python print (intv)" "1" "baseline print of an int Python value"
- gdb_test "python print (intv\[0\])" "gdb.error: Cannot subscript requested type.*" \
+ gdb_test "python print (intv\[0\])" "gdb.error.*: Cannot subscript requested type.*" \
      "Attempt to access an integer with a subscript"
 
  # Try to access a string with a subscript.  This should pass.
@@ -478,7 +478,7 @@ proc test_subscript_regression {exefile lang} {
 
  # Try to access a single dimension array with a subscript to the
  # result.  This should fail.
- gdb_test "python print (pointer\[intv\]\[0\])" "gdb.error: Cannot subscript requested type.*" \
+ gdb_test "python print (pointer\[intv\]\[0\])" "gdb.error.*: Cannot subscript requested type.*" \
      "Attempt to access a single dimension array with a two subscripts"
 
  # Lastly, test subscript access to an array with multiple
@@ -568,7 +568,7 @@ proc test_value_from_buffer {} {
   gdb_test_no_output \
       { python compare_value_bytes_to_mem(v, (int(addr) + (2 * size_a0)), size_a0) }
   gdb_test "python v=gdb.Value(b\[2*size_a0+1:\],tp); print(v)" \
-           "ValueError: Size of type is larger than that of buffer object\..*" \
+           "ValueError.*: Size of type is larger than that of buffer object\..*" \
 	   "attempt to convert smaller buffer than size of type"
   gdb_py_test_silent_cmd "python atp=tp.array(2) ; print(atp)" \
                          "make array type" 0
@@ -580,17 +580,17 @@ proc test_value_from_buffer {} {
   gdb_test "python print(va\[0\])" "1" "print first array element"
   gdb_test "python print(va\[1\])" "2" "print second array element"
   gdb_test "python print(va\[2\])" "3" "print third array element"
-  gdb_test "python print(va\[3\])" "gdb\.error: no such vector element.*" \
+  gdb_test "python print(va\[3\])" "gdb\.error.*: no such vector element.*" \
            "print out of bounds array element"
   gdb_py_test_silent_cmd "python atpbig=tp.array(3)" "make bigger array type" 0
   gdb_test "python vabig=gdb.Value(b,atpbig)" \
-           "ValueError: Size of type is larger than that of buffer object\..*" \
+           "ValueError.*: Size of type is larger than that of buffer object\..*" \
 	   "attempt to construct large value with small buffer" 
   gdb_test "python v=gdb.Value(2048,tp)" \
-           "TypeError: Object must support the python buffer protocol\..*" \
+           "TypeError.*: Object must support the python buffer protocol\..*" \
            "attempt to construct value from buffer with non-buffer object"
   gdb_test "python v=gdb.Value(b,'int'); print(v)" \
-           "TypeError: type argument must be a gdb\.Type\..*" \
+           "TypeError.*: type argument must be a gdb\.Type\..*" \
 	   "attempt to construct value with string as type"
 }
 
@@ -616,7 +616,7 @@ proc test_add_to_history {} {
     # Try adding something that can't be converted to a gdb.Value,
     # this should give an error.
     gdb_test "python idx = gdb.add_history(gdb.GdbError(\"an error\"))" \
-	"TypeError: Could not convert Python object: .*"
+	"TypeError.*: Could not convert Python object: .*"
 }
 
 # Check we can create sub-classes of gdb.Value.
@@ -658,8 +658,8 @@ proc_with_prefix test_value_bytes { } {
   # Test accessing the bytes of an optimised out value.
   gdb_test "python print(gdb.Value(gdb.Value(5).type.optimized_out()).bytes)" \
       [multi_line \
-	   "gdb\\.error: value has been optimized out" \
-	   "Error while executing Python code\\."]
+	   "gdb\\.error.*: value has been optimized out" \
+	   "Error occurred in Python.*"]
 
   # A Python helper function.  Fetch VAR_NAME from the inferior as a
   # gdb.Value.  Read the bytes of the value based on its address, and
@@ -724,11 +724,11 @@ proc_with_prefix test_value_bytes { } {
   gdb_test_no_output "python bytes_as_int.append(0)"
   gdb_test_no_output "python too_many_bytes = bytes(bytes_as_int)"
   gdb_test "python i_value.bytes = too_many_bytes" \
-      "ValueError: Size of type is not equal to that of buffer object\\..*"
+      "ValueError.*: Size of type is not equal to that of buffer object\\..*"
   gdb_test_no_output "python bytes_as_int = bytes_as_int\[0:-2\]"
   gdb_test_no_output "python too_few_bytes = bytes(bytes_as_int)"
   gdb_test "python i_value.bytes = too_few_bytes" \
-      "ValueError: Size of type is not equal to that of buffer object\\..*"
+      "ValueError.*: Size of type is not equal to that of buffer object\\..*"
 
   # Check we get an exception writing to a not_lval.
   gdb_test_no_output "python i_value = gdb.Value(9)" \
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index c0d398c29b3..175a6de7ca0 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -132,7 +132,7 @@ gdb_test_multiline "post event insertion" \
   "end" ""
 
 gdb_test "python print (someVal)" "1" "test post event execution"
-gdb_test "python gdb.post_event(str(1))" "RuntimeError: Posted event is not callable.*" \
+gdb_test "python gdb.post_event(str(1))" "RuntimeError.*: Posted event is not callable.*" \
     "test non callable class"
 
 send_gdb "python gdb.post_event(lambda: invalid())\n"
@@ -162,7 +162,7 @@ gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
 	pass $test
     }
 }
-gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination beforehand: q"
+gdb_test "q" "Quit.*" "verify pagination beforehand: q"
 
 gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=True) == \"\\n\" * [expr $lines + 1]: print (\"yes\")" "yes" "gdb.execute does not page"
 
@@ -178,7 +178,7 @@ gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
 	pass $test
     }
 }
-gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination afterwards: q"
+gdb_test "q" "Quit.*" "verify pagination afterwards: q"
 
 gdb_test_no_output "set height 0"
 
@@ -223,7 +223,7 @@ runto $lineno
 
 # Test gdb.decode_line.
 gdb_test "python gdb.decode_line(\"main.c:43\")" \
-    "gdb.error: No source file named main.c.*" "test decode_line no source named main"
+    "gdb.error.*: No source file named main.c.*" "test decode_line no source named main"
 
 with_test_prefix "test decode_line current location" {
     gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "decode current line" 1
@@ -253,7 +253,7 @@ with_test_prefix "test decode_line" {
     gdb_test "python print (symtab\[1\]\[0\].line)" "26" "python.c:26 line number"
 
     gdb_test "python gdb.decode_line(\"randomfunc\")" \
-	"gdb.error: Function \"randomfunc\" not defined.*" "randomfunc"
+	"gdb.error.*: Function \"randomfunc\" not defined.*" "randomfunc"
     gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "func1()" 1
     gdb_test "python print (len(symtab))" "2" "func1 length 2"
     gdb_test "python print (len(symtab\[1\]))" "1" "func1 length 1"
diff --git a/gdb/testsuite/gdb.python/tui-window-names.exp b/gdb/testsuite/gdb.python/tui-window-names.exp
index 03cd86bae7e..8236fc9a1a3 100644
--- a/gdb/testsuite/gdb.python/tui-window-names.exp
+++ b/gdb/testsuite/gdb.python/tui-window-names.exp
@@ -39,21 +39,21 @@ foreach c {$ * \{ \} ( ) @ #} {
     set re [string_to_regexp "$c"]
     gdb_test "python gdb.register_window_type('te${c}st', failwin)" \
 	[multi_line \
-	     "gdb.error: invalid character '${re}' in window name" \
-	     "Error while executing Python code\\." ]
+	     "gdb.error.*: invalid character '${re}' in window name" \
+	     "Error occurred in Python.*" ]
 
     gdb_test "python gdb.register_window_type('${c}test', failwin)" \
 	[multi_line \
-	     "gdb.error: invalid character '${re}' in window name" \
-	     "Error while executing Python code\\." ]
+	     "gdb.error.*: invalid character '${re}' in window name" \
+	     "Error occurred in Python.*" ]
 }
 
 # Check that whitespace within a window name is rejected.
 foreach c [list " " "\\t" "\\n" "\\r"] {
     gdb_test "python gdb.register_window_type('te${c}st', failwin)" \
 	[multi_line \
-	     "gdb.error: invalid whitespace character in window name" \
-	     "Error while executing Python code\\." ]
+	     "gdb.error.*: invalid whitespace character in window name" \
+	     "Error occurred in Python.*" ]
 }
 
 # Check some of the characters which are allowed within a window name,
@@ -62,8 +62,8 @@ foreach c {1 _ - .} {
     set re [string_to_regexp "$c"]
     gdb_test "python gdb.register_window_type('${c}test', failwin)" \
 	[multi_line \
-	     "gdb.error: window name must start with a letter, not '${re}'" \
-	     "Error while executing Python code\\." ]
+	     "gdb.error.*: window name must start with a letter, not '${re}'" \
+	     "Error occurred in Python.*" ]
 }
 
 # Check different capitalisations.
diff --git a/gdb/testsuite/gdb.python/tui-window.exp b/gdb/testsuite/gdb.python/tui-window.exp
index ad91fff79cc..e7ff1621fe8 100644
--- a/gdb/testsuite/gdb.python/tui-window.exp
+++ b/gdb/testsuite/gdb.python/tui-window.exp
@@ -50,7 +50,7 @@ Term::check_contents "Window display" "Test: 0"
 
 Term::command "python delete_window_title ()"
 Term::check_contents "error message after trying to delete title" \
-    "TypeError: Cannot delete \"title\" attribute\\."
+    "TypeError.*: Cannot delete \"title\" attribute\\."
 Term::check_contents "title is unchanged" \
     "This Is The Title"
 

-- 
2.43.0


^ permalink raw reply	[relevance 5%]

* Re: [PATCH] gdb: pass frames as `const frame_info_ptr &`
  @ 2024-02-20 11:24  0% ` Andrew Burgess
  0 siblings, 0 replies; 200+ results
From: Andrew Burgess @ 2024-02-20 11:24 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches; +Cc: Simon Marchi


Thank you for this!

I've wanted this change since frame_info_ptr was first added, but never
got around to actually writing the patch.

I haven't looked through every line of this, but I did flick through,
and what I saw looks good.  I also applied the patch and did a build
with no issues, except...

... you've introduced trailing whitespace in 5 places!  I've marked them
all in the patch below.

I'd be happy to see this merged.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

Simon Marchi <simon.marchi@polymtl.ca> writes:

> From: Simon Marchi <simon.marchi@efficios.com>
>
> We currently pass frames to function by value, as `frame_info_ptr`.
> This is somewhat expensive:
>
>  - the size of `frame_info_ptr` is 64 bytes, which is a bit big to pass
>    by value
>  - the constructors and destructor link/unlink the object in the global
>    `frame_info_ptr::frame_list` list.  This is an `intrusive_list`, so
>    it's not so bad: it's just assigning a few points, there's no memory
>    allocation as if it was `std::list`, but still it's useless to do
>    that over and over.
>
> As suggested by Tom Tromey, change many function signatures to accept
> `const frame_info_ptr &` instead of `frame_info_ptr`.
>
> Some functions reassign their `frame_info_ptr` parameter, like:
>
>   void
>   the_func (frame_info_ptr frame)
>   {
>     for (; frame != nullptr; frame = get_prev_frame (frame))
>       {
>         ...
>       }
>   }
>
> I wondered what to do about them, do I leave them as-is or change them
> (and need to introduce a separate local variable that can be
> re-assigned).  I opted for the later for consistency.  It might not be
> clear why some functions take `const frame_info_ptr &` while others take
> `frame_info_ptr`.  Also, if a function took a `frame_info_ptr` because
> it did re-assign its parameter, I doubt that we would think to change it
> to `const frame_info_ptr &` should the implementation change such that
> it doesn't need to take `frame_info_ptr` anymore.  It seems better to
> have a simple rule and apply it everywhere.
>
> Change-Id: I59d10addef687d157f82ccf4d54f5dde9a963fd0
> ---
>  gdb/aarch64-fbsd-tdep.c                  |   6 +-
>  gdb/aarch64-linux-tdep.c                 |   8 +-
>  gdb/aarch64-tdep.c                       |  46 +++---
>  gdb/ada-lang.c                           |  10 +-
>  gdb/ada-lang.h                           |   2 +-
>  gdb/alpha-linux-tdep.c                   |   2 +-
>  gdb/alpha-mdebug-tdep.c                  |  16 +--
>  gdb/alpha-netbsd-tdep.c                  |   2 +-
>  gdb/alpha-obsd-tdep.c                    |   2 +-
>  gdb/alpha-tdep.c                         |  22 +--
>  gdb/alpha-tdep.h                         |   2 +-
>  gdb/amd64-darwin-tdep.c                  |   2 +-
>  gdb/amd64-fbsd-tdep.c                    |   2 +-
>  gdb/amd64-linux-tdep.c                   |   6 +-
>  gdb/amd64-netbsd-tdep.c                  |   4 +-
>  gdb/amd64-obsd-tdep.c                    |  12 +-
>  gdb/amd64-sol2-tdep.c                    |   2 +-
>  gdb/amd64-tdep.c                         |  42 +++---
>  gdb/amd64-windows-tdep.c                 |  12 +-
>  gdb/amdgpu-tdep.c                        |   8 +-
>  gdb/arc-linux-tdep.c                     |   4 +-
>  gdb/arc-tdep.c                           |  20 +--
>  gdb/arc-tdep.h                           |   4 +-
>  gdb/arch-utils.c                         |   9 +-
>  gdb/arch-utils.h                         |   8 +-
>  gdb/arm-fbsd-tdep.c                      |   2 +-
>  gdb/arm-linux-tdep.c                     |  12 +-
>  gdb/arm-obsd-tdep.c                      |   2 +-
>  gdb/arm-tdep.c                           |  74 +++++-----
>  gdb/arm-tdep.h                           |   4 +-
>  gdb/arm-wince-tdep.c                     |   2 +-
>  gdb/avr-tdep.c                           |  14 +-
>  gdb/bfin-linux-tdep.c                    |   2 +-
>  gdb/bfin-tdep.c                          |  12 +-
>  gdb/blockframe.c                         |   4 +-
>  gdb/bpf-tdep.c                           |   8 +-
>  gdb/cp-abi.c                             |   2 +-
>  gdb/cp-abi.h                             |   4 +-
>  gdb/cris-tdep.c                          |  36 ++---
>  gdb/csky-linux-tdep.c                    |   4 +-
>  gdb/csky-tdep.c                          |  22 +--
>  gdb/dtrace-probe.c                       |   4 +-
>  gdb/dummy-frame.c                        |   8 +-
>  gdb/dummy-frame.h                        |   2 +-
>  gdb/dwarf2/ada-imported.c                |   2 +-
>  gdb/dwarf2/call-site.h                   |   4 +-
>  gdb/dwarf2/expr.c                        |   8 +-
>  gdb/dwarf2/expr.h                        |   4 +-
>  gdb/dwarf2/frame-tailcall.c              |  23 +--
>  gdb/dwarf2/frame-tailcall.h              |   4 +-
>  gdb/dwarf2/frame.c                       |  40 +++---
>  gdb/dwarf2/frame.h                       |  25 ++--
>  gdb/dwarf2/loc.c                         |  51 +++----
>  gdb/dwarf2/loc.h                         |  26 ++--
>  gdb/extension-priv.h                     |   2 +-
>  gdb/extension.c                          |   2 +-
>  gdb/extension.h                          |   2 +-
>  gdb/findvar.c                            |  24 ++--
>  gdb/frame-base.c                         |   8 +-
>  gdb/frame-base.h                         |  10 +-
>  gdb/frame-unwind.c                       |  24 ++--
>  gdb/frame-unwind.h                       |  51 ++++---
>  gdb/frame.c                              | 171 ++++++++++++-----------
>  gdb/frame.h                              | 142 +++++++++----------
>  gdb/frv-linux-tdep.c                     |  10 +-
>  gdb/frv-tdep.c                           |  10 +-
>  gdb/ft32-tdep.c                          |   8 +-
>  gdb/gdbarch-gen.h                        |  72 +++++-----
>  gdb/gdbarch.c                            |  36 ++---
>  gdb/gdbarch_components.py                |  36 ++---
>  gdb/gnu-v3-abi.c                         |   2 +-
>  gdb/h8300-tdep.c                         |  12 +-
>  gdb/hppa-bsd-tdep.c                      |   2 +-
>  gdb/hppa-linux-tdep.c                    |   8 +-
>  gdb/hppa-netbsd-tdep.c                   |   4 +-
>  gdb/hppa-tdep.c                          |  32 ++---
>  gdb/hppa-tdep.h                          |   8 +-
>  gdb/i386-bsd-tdep.c                      |   2 +-
>  gdb/i386-darwin-tdep.c                   |   4 +-
>  gdb/i386-darwin-tdep.h                   |   2 +-
>  gdb/i386-fbsd-tdep.c                     |   2 +-
>  gdb/i386-gnu-tdep.c                      |   6 +-
>  gdb/i386-linux-tdep.c                    |  10 +-
>  gdb/i386-netbsd-tdep.c                   |   4 +-
>  gdb/i386-nto-tdep.c                      |   4 +-
>  gdb/i386-obsd-tdep.c                     |  10 +-
>  gdb/i386-sol2-tdep.c                     |   2 +-
>  gdb/i386-tdep.c                          |  64 ++++-----
>  gdb/i386-tdep.h                          |  12 +-
>  gdb/i386-windows-tdep.c                  |   2 +-
>  gdb/i387-tdep.c                          |   6 +-
>  gdb/i387-tdep.h                          |   6 +-
>  gdb/ia64-libunwind-tdep.c                |  10 +-
>  gdb/ia64-libunwind-tdep.h                |   8 +-
>  gdb/ia64-tdep.c                          |  44 +++---
>  gdb/ia64-tdep.h                          |   2 +-
>  gdb/infcmd.c                             |  11 +-
>  gdb/inferior.h                           |   4 +-
>  gdb/infrun.c                             |  22 +--
>  gdb/infrun.h                             |   2 +-
>  gdb/inline-frame.c                       |   8 +-
>  gdb/inline-frame.h                       |   2 +-
>  gdb/iq2000-tdep.c                        |  10 +-
>  gdb/jit.c                                |   6 +-
>  gdb/language.h                           |   2 +-
>  gdb/lm32-tdep.c                          |   8 +-
>  gdb/loongarch-linux-tdep.c               |   4 +-
>  gdb/loongarch-tdep.c                     |  10 +-
>  gdb/loongarch-tdep.h                     |   2 +-
>  gdb/m32c-tdep.c                          |  10 +-
>  gdb/m32r-linux-tdep.c                    |  14 +-
>  gdb/m32r-tdep.c                          |   8 +-
>  gdb/m68hc11-tdep.c                       |  16 +--
>  gdb/m68k-linux-tdep.c                    |  12 +-
>  gdb/m68k-tdep.c                          |  18 +--
>  gdb/mep-tdep.c                           |   8 +-
>  gdb/mi/mi-cmd-stack.c                    |   6 +-
>  gdb/mi/mi-main.c                         |   4 +-
>  gdb/microblaze-linux-tdep.c              |   4 +-
>  gdb/microblaze-tdep.c                    |  10 +-
>  gdb/minsyms.c                            |   2 +-
>  gdb/mips-fbsd-tdep.c                     |   4 +-
>  gdb/mips-linux-tdep.c                    |  22 +--
>  gdb/mips-netbsd-tdep.c                   |   2 +-
>  gdb/mips-sde-tdep.c                      |  12 +-
>  gdb/mips-tdep.c                          |  96 ++++++-------
>  gdb/mips-tdep.h                          |   2 +-
>  gdb/mips64-obsd-tdep.c                   |   2 +-
>  gdb/mn10300-linux-tdep.c                 |   4 +-
>  gdb/mn10300-tdep.c                       |   8 +-
>  gdb/moxie-tdep.c                         |   8 +-
>  gdb/msp430-tdep.c                        |  10 +-
>  gdb/nds32-tdep.c                         |  20 +--
>  gdb/nios2-linux-tdep.c                   |   4 +-
>  gdb/nios2-tdep.c                         |  22 +--
>  gdb/nios2-tdep.h                         |   2 +-
>  gdb/observable.h                         |   2 +-
>  gdb/or1k-linux-tdep.c                    |   4 +-
>  gdb/or1k-tdep.c                          |  12 +-
>  gdb/ppc-fbsd-tdep.c                      |   8 +-
>  gdb/ppc-linux-tdep.c                     |  12 +-
>  gdb/ppc-netbsd-tdep.c                    |   2 +-
>  gdb/ppc-obsd-tdep.c                      |   8 +-
>  gdb/ppc-sysv-tdep.c                      |   3 +-
>  gdb/ppc-tdep.h                           |   4 +-
>  gdb/ppc64-tdep.c                         |  20 +--
>  gdb/ppc64-tdep.h                         |   2 +-
>  gdb/printcmd.c                           |   2 +-
>  gdb/probe.c                              |   2 +-
>  gdb/probe.h                              |   4 +-
>  gdb/python/py-event.h                    |   2 +-
>  gdb/python/py-frame.c                    |   2 +-
>  gdb/python/py-framefilter.c              |  14 +-
>  gdb/python/py-inferior.c                 |   2 +-
>  gdb/python/py-infevents.c                |   4 +-
>  gdb/python/py-unwind.c                   |   6 +-
>  gdb/python/python-internal.h             |   4 +-
>  gdb/record-btrace.c                      |  14 +-
>  gdb/riscv-fbsd-tdep.c                    |   2 +-
>  gdb/riscv-linux-tdep.c                   |   6 +-
>  gdb/riscv-tdep.c                         |  12 +-
>  gdb/riscv-tdep.h                         |   2 +-
>  gdb/rl78-tdep.c                          |  12 +-
>  gdb/rs6000-aix-tdep.c                    |   8 +-
>  gdb/rs6000-tdep.c                        |  34 ++---
>  gdb/rx-tdep.c                            |  16 +--
>  gdb/s12z-tdep.c                          |  10 +-
>  gdb/s390-linux-tdep.c                    |   8 +-
>  gdb/s390-tdep.c                          |  36 ++---
>  gdb/s390-tdep.h                          |   2 +-
>  gdb/sentinel-frame.c                     |   6 +-
>  gdb/sh-linux-tdep.c                      |   6 +-
>  gdb/sh-tdep.c                            |  16 +--
>  gdb/sol2-tdep.c                          |   2 +-
>  gdb/sol2-tdep.h                          |   2 +-
>  gdb/sparc-linux-tdep.c                   |   6 +-
>  gdb/sparc-netbsd-tdep.c                  |  12 +-
>  gdb/sparc-obsd-tdep.c                    |   8 +-
>  gdb/sparc-sol2-tdep.c                    |   8 +-
>  gdb/sparc-tdep.c                         |  18 +--
>  gdb/sparc-tdep.h                         |  10 +-
>  gdb/sparc64-fbsd-tdep.c                  |   8 +-
>  gdb/sparc64-linux-tdep.c                 |   8 +-
>  gdb/sparc64-netbsd-tdep.c                |  10 +-
>  gdb/sparc64-obsd-tdep.c                  |  16 +--
>  gdb/sparc64-sol2-tdep.c                  |   8 +-
>  gdb/sparc64-tdep.c                       |  10 +-
>  gdb/sparc64-tdep.h                       |   2 +-
>  gdb/stack.c                              |  42 +++---
>  gdb/stack.h                              |   4 +-
>  gdb/stap-probe.c                         |   4 +-
>  gdb/std-regs.c                           |   8 +-
>  gdb/symtab.h                             |   8 +-
>  gdb/tic6x-linux-tdep.c                   |   4 +-
>  gdb/tic6x-tdep.c                         |  22 +--
>  gdb/tic6x-tdep.h                         |   2 +-
>  gdb/tilegx-linux-tdep.c                  |   2 +-
>  gdb/tilegx-tdep.c                        |  12 +-
>  gdb/tracepoint.c                         |   2 +-
>  gdb/trad-frame.c                         |   8 +-
>  gdb/trad-frame.h                         |   8 +-
>  gdb/tramp-frame.c                        |  10 +-
>  gdb/tramp-frame.h                        |   4 +-
>  gdb/tui/tui-disasm.c                     |   2 +-
>  gdb/tui/tui-disasm.h                     |   2 +-
>  gdb/tui/tui-hooks.c                      |   2 +-
>  gdb/tui/tui-regs.c                       |   4 +-
>  gdb/tui/tui-regs.h                       |   2 +-
>  gdb/tui/tui-source.c                     |   2 +-
>  gdb/tui/tui-source.h                     |   2 +-
>  gdb/tui/tui-status.c                     |   4 +-
>  gdb/tui/tui-status.h                     |   2 +-
>  gdb/tui/tui-winsource.h                  |   2 +-
>  gdb/unittests/frame_info_ptr-selftests.c |   2 +-
>  gdb/user-regs.c                          |   4 +-
>  gdb/user-regs.h                          |   4 +-
>  gdb/v850-tdep.c                          |  10 +-
>  gdb/valops.c                             |   4 +-
>  gdb/value.c                              |  23 +--
>  gdb/value.h                              |  35 ++---
>  gdb/vax-tdep.c                           |  14 +-
>  gdb/xstormy16-tdep.c                     |  12 +-
>  gdb/xtensa-tdep.c                        |  20 +--
>  gdb/z80-tdep.c                           |   6 +-
>  224 files changed, 1351 insertions(+), 1339 deletions(-)
>
> diff --git a/gdb/aarch64-fbsd-tdep.c b/gdb/aarch64-fbsd-tdep.c
> index 2b043c0e7350..44ca6c90c818 100644
> --- a/gdb/aarch64-fbsd-tdep.c
> +++ b/gdb/aarch64-fbsd-tdep.c
> @@ -88,9 +88,9 @@ static const struct regcache_map_entry aarch64_fbsd_tls_regmap[] =
>  
>  static void
>  aarch64_fbsd_sigframe_init (const struct tramp_frame *self,
> -			     frame_info_ptr this_frame,
> -			     struct trad_frame_cache *this_cache,
> -			     CORE_ADDR func)
> +			    const frame_info_ptr &this_frame,
> +			    struct trad_frame_cache *this_cache,
> +			    CORE_ADDR func)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
> index 7812ec5b7a1e..4ebc173a0a00 100644
> --- a/gdb/aarch64-linux-tdep.c
> +++ b/gdb/aarch64-linux-tdep.c
> @@ -381,8 +381,8 @@ aarch64_linux_restore_vregs (struct gdbarch *gdbarch,
>     SIGNAL_FRAME.  */
>  
>  static void
> -aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame,
> -				  struct aarch64_linux_sigframe &signal_frame)
> +aarch64_linux_read_signal_frame_info (const frame_info_ptr &this_frame,
> +				      aarch64_linux_sigframe &signal_frame)
>  {
>    signal_frame.sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM);
>    signal_frame.sigcontext_address
> @@ -570,7 +570,7 @@ aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame,
>  
>  static void
>  aarch64_linux_sigframe_init (const struct tramp_frame *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     struct trad_frame_cache *this_cache,
>  			     CORE_ADDR func)
>  {
> @@ -704,7 +704,7 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self,
>  /* Implements the "prev_arch" method of struct tramp_frame.  */
>  
>  static struct gdbarch *
> -aarch64_linux_sigframe_prev_arch (frame_info_ptr this_frame,
> +aarch64_linux_sigframe_prev_arch (const frame_info_ptr &this_frame,
>  				  void **frame_cache)
>  {
>    struct trad_frame_cache *cache
> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
> index b97e2153e14f..d1d5486f90dd 100644
> --- a/gdb/aarch64-tdep.c
> +++ b/gdb/aarch64-tdep.c
> @@ -268,7 +268,7 @@ class instruction_reader : public abstract_instruction_reader
>  
>  static CORE_ADDR
>  aarch64_frame_unmask_lr (aarch64_gdbarch_tdep *tdep,
> -			 frame_info_ptr this_frame, CORE_ADDR addr)
> +			 const frame_info_ptr &this_frame, CORE_ADDR addr)
>  {
>    if (tdep->has_pauth ()
>        && frame_unwind_register_unsigned (this_frame,
> @@ -298,7 +298,7 @@ aarch64_frame_unmask_lr (aarch64_gdbarch_tdep *tdep,
>  /* Implement the "get_pc_address_flags" gdbarch method.  */
>  
>  static std::string
> -aarch64_get_pc_address_flags (frame_info_ptr frame, CORE_ADDR pc)
> +aarch64_get_pc_address_flags (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    if (pc != 0 && get_frame_pc_masked (frame))
>      return "PAC";
> @@ -995,7 +995,7 @@ aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>     cache CACHE.  */
>  
>  static void
> -aarch64_scan_prologue (frame_info_ptr this_frame,
> +aarch64_scan_prologue (const frame_info_ptr &this_frame,
>  		       struct aarch64_prologue_cache *cache)
>  {
>    CORE_ADDR block_addr = get_frame_address_in_block (this_frame);
> @@ -1049,7 +1049,7 @@ aarch64_scan_prologue (frame_info_ptr this_frame,
>     not available.  */
>  
>  static void
> -aarch64_make_prologue_cache_1 (frame_info_ptr this_frame,
> +aarch64_make_prologue_cache_1 (const frame_info_ptr &this_frame,
>  			       struct aarch64_prologue_cache *cache)
>  {
>    CORE_ADDR unwound_fp;
> @@ -1087,7 +1087,7 @@ aarch64_make_prologue_cache_1 (frame_info_ptr this_frame,
>     *THIS_CACHE.  */
>  
>  static struct aarch64_prologue_cache *
> -aarch64_make_prologue_cache (frame_info_ptr this_frame, void **this_cache)
> +aarch64_make_prologue_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct aarch64_prologue_cache *cache;
>  
> @@ -1114,7 +1114,7 @@ aarch64_make_prologue_cache (frame_info_ptr this_frame, void **this_cache)
>  /* Implement the "stop_reason" frame_unwind method.  */
>  
>  static enum unwind_stop_reason
> -aarch64_prologue_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +aarch64_prologue_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  					   void **this_cache)
>  {
>    struct aarch64_prologue_cache *cache
> @@ -1140,7 +1140,7 @@ aarch64_prologue_frame_unwind_stop_reason (frame_info_ptr this_frame,
>     PC and the caller's SP when we were called.  */
>  
>  static void
> -aarch64_prologue_this_id (frame_info_ptr this_frame,
> +aarch64_prologue_this_id (const frame_info_ptr &this_frame,
>  			  void **this_cache, struct frame_id *this_id)
>  {
>    struct aarch64_prologue_cache *cache
> @@ -1155,7 +1155,7 @@ aarch64_prologue_this_id (frame_info_ptr this_frame,
>  /* Implement the "prev_register" frame_unwind method.  */
>  
>  static struct value *
> -aarch64_prologue_prev_register (frame_info_ptr this_frame,
> +aarch64_prologue_prev_register (const frame_info_ptr &this_frame,
>  				void **this_cache, int prev_regnum)
>  {
>    struct aarch64_prologue_cache *cache
> @@ -1221,7 +1221,7 @@ static frame_unwind aarch64_prologue_unwind =
>     *THIS_CACHE.  */
>  
>  static struct aarch64_prologue_cache *
> -aarch64_make_stub_cache (frame_info_ptr this_frame, void **this_cache)
> +aarch64_make_stub_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct aarch64_prologue_cache *cache;
>  
> @@ -1251,7 +1251,7 @@ aarch64_make_stub_cache (frame_info_ptr this_frame, void **this_cache)
>  /* Implement the "stop_reason" frame_unwind method.  */
>  
>  static enum unwind_stop_reason
> -aarch64_stub_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +aarch64_stub_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  				       void **this_cache)
>  {
>    struct aarch64_prologue_cache *cache
> @@ -1266,7 +1266,7 @@ aarch64_stub_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  /* Our frame ID for a stub frame is the current SP and LR.  */
>  
>  static void
> -aarch64_stub_this_id (frame_info_ptr this_frame,
> +aarch64_stub_this_id (const frame_info_ptr &this_frame,
>  		      void **this_cache, struct frame_id *this_id)
>  {
>    struct aarch64_prologue_cache *cache
> @@ -1282,7 +1282,7 @@ aarch64_stub_this_id (frame_info_ptr this_frame,
>  
>  static int
>  aarch64_stub_unwind_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache)
>  {
>    CORE_ADDR addr_in_block;
> @@ -1313,7 +1313,7 @@ static frame_unwind aarch64_stub_unwind =
>  /* Return the frame base address of *THIS_FRAME.  */
>  
>  static CORE_ADDR
> -aarch64_normal_frame_base (frame_info_ptr this_frame, void **this_cache)
> +aarch64_normal_frame_base (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct aarch64_prologue_cache *cache
>      = aarch64_make_prologue_cache (this_frame, this_cache);
> @@ -1334,7 +1334,7 @@ static frame_base aarch64_normal_base =
>     *THIS_FRAME.  */
>  
>  static struct value *
> -aarch64_dwarf2_prev_register (frame_info_ptr this_frame,
> +aarch64_dwarf2_prev_register (const frame_info_ptr &this_frame,
>  			      void **this_cache, int regnum)
>  {
>    gdbarch *arch = get_frame_arch (this_frame);
> @@ -1361,7 +1361,7 @@ static const unsigned char op_lit1 = DW_OP_lit1;
>  static void
>  aarch64_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			       struct dwarf2_frame_state_reg *reg,
> -			       frame_info_ptr this_frame)
> +			       const frame_info_ptr &this_frame)
>  {
>    aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
>  
> @@ -2780,7 +2780,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value,
>  /* Implement the "get_longjmp_target" gdbarch method.  */
>  
>  static int
> -aarch64_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +aarch64_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    CORE_ADDR jb_addr;
>    gdb_byte buf[X_REGISTER_SIZE];
> @@ -3105,7 +3105,7 @@ aarch64_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
>  /* Helper for aarch64_pseudo_read_value.  */
>  
>  static value *
> -aarch64_pseudo_read_value_1 (frame_info_ptr next_frame,
> +aarch64_pseudo_read_value_1 (const frame_info_ptr &next_frame,
>  			     const int pseudo_reg_num, int raw_regnum_offset)
>  {
>    unsigned v_regnum = AARCH64_V0_REGNUM + raw_regnum_offset;
> @@ -3197,7 +3197,7 @@ aarch64_za_offsets_from_regnum (struct gdbarch *gdbarch, int regnum)
>  /* Given REGNUM, a SME pseudo-register number, return its value in RESULT.  */
>  
>  static value *
> -aarch64_sme_pseudo_register_read (gdbarch *gdbarch, frame_info_ptr next_frame,
> +aarch64_sme_pseudo_register_read (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  				  const int pseudo_reg_num)
>  {
>    aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
> @@ -3231,7 +3231,7 @@ aarch64_sme_pseudo_register_read (gdbarch *gdbarch, frame_info_ptr next_frame,
>  /* Implement the "pseudo_register_read_value" gdbarch method.  */
>  
>  static value *
> -aarch64_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
> +aarch64_pseudo_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  			   const int pseudo_reg_num)
>  {
>    aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
> @@ -3296,7 +3296,7 @@ aarch64_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
>  /* Helper for aarch64_pseudo_write.  */
>  
>  static void
> -aarch64_pseudo_write_1 (gdbarch *gdbarch, frame_info_ptr next_frame,
> +aarch64_pseudo_write_1 (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  			int regnum_offset,
>  			gdb::array_view<const gdb_byte> buf)
>  {
> @@ -3322,7 +3322,7 @@ aarch64_pseudo_write_1 (gdbarch *gdbarch, frame_info_ptr next_frame,
>     pseudo-register.  */
>  
>  static void
> -aarch64_sme_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame,
> +aarch64_sme_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  				   const int regnum,
>  				   gdb::array_view<const gdb_byte> data)
>  {
> @@ -3364,7 +3364,7 @@ aarch64_sme_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame,
>  /* Implement the "pseudo_register_write" gdbarch method.  */
>  
>  static void
> -aarch64_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
> +aarch64_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  		      const int pseudo_reg_num,
>  		      gdb::array_view<const gdb_byte> buf)
>  {
> @@ -3437,7 +3437,7 @@ aarch64_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
>  /* Callback function for user_reg_add.  */
>  
>  static struct value *
> -value_of_aarch64_user_reg (frame_info_ptr frame, const void *baton)
> +value_of_aarch64_user_reg (const frame_info_ptr &frame, const void *baton)
>  {
>    const int *reg_p = (const int *) baton;
>  
> diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
> index a3fd695e0034..3f3985400104 100644
> --- a/gdb/ada-lang.c
> +++ b/gdb/ada-lang.c
> @@ -11720,7 +11720,7 @@ ada_exception_support_info_sniffer (void)
>     to most users.  */
>  
>  static int
> -is_known_support_routine (frame_info_ptr frame)
> +is_known_support_routine (const frame_info_ptr &frame)
>  {
>    enum language func_lang;
>    int i;
> @@ -11779,9 +11779,9 @@ is_known_support_routine (frame_info_ptr frame)
>     part of the Ada run-time, starting from FI and moving upward.  */
>  
>  void
> -ada_find_printable_frame (frame_info_ptr fi)
> +ada_find_printable_frame (const frame_info_ptr &initial_fi)
>  {
> -  for (; fi != NULL; fi = get_prev_frame (fi))
> +  for (frame_info_ptr fi = initial_fi; fi != nullptr; fi = get_prev_frame (fi))
>      {
>        if (!is_known_support_routine (fi))
>  	{
> @@ -12913,7 +12913,7 @@ ada_add_standard_exceptions (compiled_regex *preg,
>  
>  static void
>  ada_add_exceptions_from_frame (compiled_regex *preg,
> -			       frame_info_ptr frame,
> +			       const frame_info_ptr &frame,
>  			       std::vector<ada_exc_info> *exceptions)
>  {
>    const struct block *block = get_frame_block (frame, 0);
> @@ -13339,7 +13339,7 @@ class ada_language : public language_defn
>  
>    struct value *read_var_value (struct symbol *var,
>  				const struct block *var_block,
> -				frame_info_ptr frame) const override
> +				const frame_info_ptr &frame) const override
>    {
>      /* The only case where default_read_var_value is not sufficient
>         is when VAR is a renaming...  */
> diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
> index aefd335ff390..5083d004ac98 100644
> --- a/gdb/ada-lang.h
> +++ b/gdb/ada-lang.h
> @@ -341,7 +341,7 @@ extern enum ada_renaming_category ada_parse_renaming (struct symbol *,
>  						      const char **,
>  						      int *, const char **);
>  
> -extern void ada_find_printable_frame (frame_info_ptr fi);
> +extern void ada_find_printable_frame (const frame_info_ptr &fi);
>  
>  extern const char *ada_main_name ();
>  
> diff --git a/gdb/alpha-linux-tdep.c b/gdb/alpha-linux-tdep.c
> index 1a19626d9f09..5f5e46d514e4 100644
> --- a/gdb/alpha-linux-tdep.c
> +++ b/gdb/alpha-linux-tdep.c
> @@ -126,7 +126,7 @@ alpha_linux_pc_in_sigtramp (struct gdbarch *gdbarch,
>  }
>  
>  static CORE_ADDR
> -alpha_linux_sigcontext_addr (frame_info_ptr this_frame)
> +alpha_linux_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    CORE_ADDR pc;
> diff --git a/gdb/alpha-mdebug-tdep.c b/gdb/alpha-mdebug-tdep.c
> index 7691a53148ae..2d13cd3b7c1a 100644
> --- a/gdb/alpha-mdebug-tdep.c
> +++ b/gdb/alpha-mdebug-tdep.c
> @@ -185,7 +185,7 @@ struct alpha_mdebug_unwind_cache
>     and store the resulting register save locations in the structure.  */
>  
>  static struct alpha_mdebug_unwind_cache *
> -alpha_mdebug_frame_unwind_cache (frame_info_ptr this_frame, 
> +alpha_mdebug_frame_unwind_cache (const frame_info_ptr &this_frame,

Trailing white space.

>  				 void **this_prologue_cache)
>  {
>    struct alpha_mdebug_unwind_cache *info;
> @@ -262,7 +262,7 @@ alpha_mdebug_frame_unwind_cache (frame_info_ptr this_frame,
>     frame.  This will be used to create a new GDB frame struct.  */
>  
>  static void
> -alpha_mdebug_frame_this_id (frame_info_ptr this_frame,
> +alpha_mdebug_frame_this_id (const frame_info_ptr &this_frame,
>  			    void **this_prologue_cache,
>  			    struct frame_id *this_id)
>  {
> @@ -275,7 +275,7 @@ alpha_mdebug_frame_this_id (frame_info_ptr this_frame,
>  /* Retrieve the value of REGNUM in FRAME.  Don't give up!  */
>  
>  static struct value *
> -alpha_mdebug_frame_prev_register (frame_info_ptr this_frame,
> +alpha_mdebug_frame_prev_register (const frame_info_ptr &this_frame,
>  				  void **this_prologue_cache, int regnum)
>  {
>    struct alpha_mdebug_unwind_cache *info
> @@ -306,7 +306,7 @@ alpha_mdebug_max_frame_size_exceeded (struct mdebug_extra_func_info *proc_desc)
>  
>  static int
>  alpha_mdebug_frame_sniffer (const struct frame_unwind *self,
> -			    frame_info_ptr this_frame,
> +			    const frame_info_ptr &this_frame,
>  			    void **this_cache)
>  {
>    CORE_ADDR pc = get_frame_address_in_block (this_frame);
> @@ -343,7 +343,7 @@ static const struct frame_unwind alpha_mdebug_frame_unwind =
>  };
>  
>  static CORE_ADDR
> -alpha_mdebug_frame_base_address (frame_info_ptr this_frame,
> +alpha_mdebug_frame_base_address (const frame_info_ptr &this_frame,
>  				 void **this_prologue_cache)
>  {
>    struct alpha_mdebug_unwind_cache *info
> @@ -353,7 +353,7 @@ alpha_mdebug_frame_base_address (frame_info_ptr this_frame,
>  }
>  
>  static CORE_ADDR
> -alpha_mdebug_frame_locals_address (frame_info_ptr this_frame,
> +alpha_mdebug_frame_locals_address (const frame_info_ptr &this_frame,
>  				   void **this_prologue_cache)
>  {
>    struct alpha_mdebug_unwind_cache *info
> @@ -363,7 +363,7 @@ alpha_mdebug_frame_locals_address (frame_info_ptr this_frame,
>  }
>  
>  static CORE_ADDR
> -alpha_mdebug_frame_args_address (frame_info_ptr this_frame,
> +alpha_mdebug_frame_args_address (const frame_info_ptr &this_frame,
>  				 void **this_prologue_cache)
>  {
>    struct alpha_mdebug_unwind_cache *info
> @@ -380,7 +380,7 @@ static const struct frame_base alpha_mdebug_frame_base = {
>  };
>  
>  static const struct frame_base *
> -alpha_mdebug_frame_base_sniffer (frame_info_ptr this_frame)
> +alpha_mdebug_frame_base_sniffer (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_address_in_block (this_frame);
>    struct mdebug_extra_func_info *proc_desc;
> diff --git a/gdb/alpha-netbsd-tdep.c b/gdb/alpha-netbsd-tdep.c
> index 0213fe5b94f3..569fe42a2a94 100644
> --- a/gdb/alpha-netbsd-tdep.c
> +++ b/gdb/alpha-netbsd-tdep.c
> @@ -235,7 +235,7 @@ alphanbsd_pc_in_sigtramp (struct gdbarch *gdbarch,
>  }
>  
>  static CORE_ADDR
> -alphanbsd_sigcontext_addr (frame_info_ptr frame)
> +alphanbsd_sigcontext_addr (const frame_info_ptr &frame)
>  {
>    /* FIXME: This is not correct for all versions of NetBSD/alpha.
>       We will probably need to disassemble the trampoline to figure
> diff --git a/gdb/alpha-obsd-tdep.c b/gdb/alpha-obsd-tdep.c
> index b22e584a4e48..610866835c85 100644
> --- a/gdb/alpha-obsd-tdep.c
> +++ b/gdb/alpha-obsd-tdep.c
> @@ -69,7 +69,7 @@ alphaobsd_pc_in_sigtramp (struct gdbarch *gdbarch,
>  }
>  
>  static CORE_ADDR
> -alphaobsd_sigcontext_addr (frame_info_ptr this_frame)
> +alphaobsd_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    CORE_ADDR pc = get_frame_pc (this_frame);
> diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
> index cafadae45c74..e5e0860fe241 100644
> --- a/gdb/alpha-tdep.c
> +++ b/gdb/alpha-tdep.c
> @@ -233,7 +233,7 @@ alpha_convert_register_p (struct gdbarch *gdbarch, int regno,
>  }
>  
>  static int
> -alpha_register_to_value (frame_info_ptr frame, int regnum,
> +alpha_register_to_value (const frame_info_ptr &frame, int regnum,
>  			 struct type *valtype, gdb_byte *out,
>  			int *optimizedp, int *unavailablep)
>  {
> @@ -260,7 +260,7 @@ alpha_register_to_value (frame_info_ptr frame, int regnum,
>  }
>  
>  static void
> -alpha_value_to_register (frame_info_ptr frame, int regnum,
> +alpha_value_to_register (const frame_info_ptr &frame, int regnum,
>  			 struct type *valtype, const gdb_byte *in)
>  {
>    int reg_size = register_size (get_frame_arch (frame), regnum);
> @@ -840,7 +840,7 @@ alpha_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
>     into the "pc".  This routine returns true on success.  */
>  
>  static int
> -alpha_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +alpha_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
> @@ -871,7 +871,7 @@ struct alpha_sigtramp_unwind_cache
>  };
>  
>  static struct alpha_sigtramp_unwind_cache *
> -alpha_sigtramp_frame_unwind_cache (frame_info_ptr this_frame,
> +alpha_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
>  				   void **this_prologue_cache)
>  {
>    struct alpha_sigtramp_unwind_cache *info;
> @@ -912,7 +912,7 @@ alpha_sigtramp_register_address (struct gdbarch *gdbarch,
>     frame.  This will be used to create a new GDB frame struct.  */
>  
>  static void
> -alpha_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +alpha_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  			      void **this_prologue_cache,
>  			      struct frame_id *this_id)
>  {
> @@ -954,7 +954,7 @@ alpha_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  /* Retrieve the value of REGNUM in FRAME.  Don't give up!  */
>  
>  static struct value *
> -alpha_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +alpha_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  				    void **this_prologue_cache, int regnum)
>  {
>    struct alpha_sigtramp_unwind_cache *info
> @@ -979,7 +979,7 @@ alpha_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  alpha_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -			      frame_info_ptr this_frame,
> +			      const frame_info_ptr &this_frame,
>  			      void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1221,7 +1221,7 @@ alpha_heuristic_analyze_probing_loop (struct gdbarch *gdbarch, CORE_ADDR *pc,
>  }
>  
>  static struct alpha_heuristic_unwind_cache *
> -alpha_heuristic_frame_unwind_cache (frame_info_ptr this_frame,
> +alpha_heuristic_frame_unwind_cache (const frame_info_ptr &this_frame,
>  				    void **this_prologue_cache,
>  				    CORE_ADDR start_pc)
>  {
> @@ -1398,7 +1398,7 @@ alpha_heuristic_frame_unwind_cache (frame_info_ptr this_frame,
>     frame.  This will be used to create a new GDB frame struct.  */
>  
>  static void
> -alpha_heuristic_frame_this_id (frame_info_ptr this_frame,
> +alpha_heuristic_frame_this_id (const frame_info_ptr &this_frame,
>  			       void **this_prologue_cache,
>  			       struct frame_id *this_id)
>  {
> @@ -1411,7 +1411,7 @@ alpha_heuristic_frame_this_id (frame_info_ptr this_frame,
>  /* Retrieve the value of REGNUM in FRAME.  Don't give up!  */
>  
>  static struct value *
> -alpha_heuristic_frame_prev_register (frame_info_ptr this_frame,
> +alpha_heuristic_frame_prev_register (const frame_info_ptr &this_frame,
>  				     void **this_prologue_cache, int regnum)
>  {
>    struct alpha_heuristic_unwind_cache *info
> @@ -1438,7 +1438,7 @@ static const struct frame_unwind alpha_heuristic_frame_unwind =
>  };
>  
>  static CORE_ADDR
> -alpha_heuristic_frame_base_address (frame_info_ptr this_frame,
> +alpha_heuristic_frame_base_address (const frame_info_ptr &this_frame,
>  				    void **this_prologue_cache)
>  {
>    struct alpha_heuristic_unwind_cache *info
> diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h
> index f9c7e295609a..0423abb25584 100644
> --- a/gdb/alpha-tdep.h
> +++ b/gdb/alpha-tdep.h
> @@ -81,7 +81,7 @@ struct alpha_gdbarch_tdep : gdbarch_tdep_base
>  
>    /* Translate a signal handler stack base address into the address of
>       the sigcontext structure for that signal handler.  */
> -  CORE_ADDR (*sigcontext_addr) (frame_info_ptr) = nullptr;
> +  CORE_ADDR (*sigcontext_addr) (const frame_info_ptr &) = nullptr;
>  
>    /* Does the PC fall in a signal trampoline.  */
>    /* NOTE: cagney/2004-04-30: Do not copy/clone this code.  Instead
> diff --git a/gdb/amd64-darwin-tdep.c b/gdb/amd64-darwin-tdep.c
> index bfba7a5284a6..001f5379def2 100644
> --- a/gdb/amd64-darwin-tdep.c
> +++ b/gdb/amd64-darwin-tdep.c
> @@ -75,7 +75,7 @@ const int amd64_darwin_thread_state_num_regs =
>     address of the associated sigcontext structure.  */
>  
>  static CORE_ADDR
> -amd64_darwin_sigcontext_addr (frame_info_ptr this_frame)
> +amd64_darwin_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c
> index 9144801a5d29..a837bd197ffe 100644
> --- a/gdb/amd64-fbsd-tdep.c
> +++ b/gdb/amd64-fbsd-tdep.c
> @@ -169,7 +169,7 @@ const struct regset amd64_fbsd_segbases_regset =
>  
>  static void
>  amd64_fbsd_sigframe_init (const struct tramp_frame *self,
> -			  frame_info_ptr this_frame,
> +			  const frame_info_ptr &this_frame,
>  			  struct trad_frame_cache *this_cache,
>  			  CORE_ADDR func)
>  {
> diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
> index fe7f5d4a2597..1deb13b4e9ad 100644
> --- a/gdb/amd64-linux-tdep.c
> +++ b/gdb/amd64-linux-tdep.c
> @@ -133,7 +133,7 @@ static const gdb_byte amd64_x32_linux_sigtramp_code[] =
>     the routine.  Otherwise, return 0.  */
>  
>  static CORE_ADDR
> -amd64_linux_sigtramp_start (frame_info_ptr this_frame)
> +amd64_linux_sigtramp_start (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch;
>    const gdb_byte *sigtramp_code;
> @@ -175,7 +175,7 @@ amd64_linux_sigtramp_start (frame_info_ptr this_frame)
>     routine.  */
>  
>  static int
> -amd64_linux_sigtramp_p (frame_info_ptr this_frame)
> +amd64_linux_sigtramp_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    const char *name;
> @@ -201,7 +201,7 @@ amd64_linux_sigtramp_p (frame_info_ptr this_frame)
>     address of the associated sigcontext structure.  */
>  
>  static CORE_ADDR
> -amd64_linux_sigcontext_addr (frame_info_ptr this_frame)
> +amd64_linux_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> diff --git a/gdb/amd64-netbsd-tdep.c b/gdb/amd64-netbsd-tdep.c
> index d1a7cf3a0492..40500ee5f76c 100644
> --- a/gdb/amd64-netbsd-tdep.c
> +++ b/gdb/amd64-netbsd-tdep.c
> @@ -35,7 +35,7 @@
>     routine.  */
>  
>  static int
> -amd64nbsd_sigtramp_p (frame_info_ptr this_frame)
> +amd64nbsd_sigtramp_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    const char *name;
> @@ -48,7 +48,7 @@ amd64nbsd_sigtramp_p (frame_info_ptr this_frame)
>     return the address of the associated mcontext structure.  */
>  
>  static CORE_ADDR
> -amd64nbsd_mcontext_addr (frame_info_ptr this_frame)
> +amd64nbsd_mcontext_addr (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR addr;
>  
> diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c
> index 9cca6b12c84e..6b37e8954ee4 100644
> --- a/gdb/amd64-obsd-tdep.c
> +++ b/gdb/amd64-obsd-tdep.c
> @@ -45,7 +45,7 @@ static const int amd64obsd_page_size = 4096;
>     routine.  */
>  
>  static int
> -amd64obsd_sigtramp_p (frame_info_ptr this_frame)
> +amd64obsd_sigtramp_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    CORE_ADDR start_pc = (pc & ~(amd64obsd_page_size - 1));
> @@ -98,7 +98,7 @@ amd64obsd_sigtramp_p (frame_info_ptr this_frame)
>     address of the associated sigcontext structure.  */
>  
>  static CORE_ADDR
> -amd64obsd_sigcontext_addr (frame_info_ptr this_frame)
> +amd64obsd_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    ULONGEST offset = (pc & (amd64obsd_page_size - 1));
> @@ -315,7 +315,7 @@ amd64obsd_collect_uthread (const struct regcache *regcache,
>  #define amd64obsd_tf_reg_offset amd64obsd_sc_reg_offset
>  
>  static struct trad_frame_cache *
> -amd64obsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
> +amd64obsd_trapframe_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -362,7 +362,7 @@ amd64obsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -amd64obsd_trapframe_this_id (frame_info_ptr this_frame,
> +amd64obsd_trapframe_this_id (const frame_info_ptr &this_frame,
>  			     void **this_cache, struct frame_id *this_id)
>  {
>    struct trad_frame_cache *cache =
> @@ -372,7 +372,7 @@ amd64obsd_trapframe_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -amd64obsd_trapframe_prev_register (frame_info_ptr this_frame,
> +amd64obsd_trapframe_prev_register (const frame_info_ptr &this_frame,
>  				   void **this_cache, int regnum)
>  {
>    struct trad_frame_cache *cache =
> @@ -383,7 +383,7 @@ amd64obsd_trapframe_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  amd64obsd_trapframe_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache)
>  {
>    ULONGEST cs;
> diff --git a/gdb/amd64-sol2-tdep.c b/gdb/amd64-sol2-tdep.c
> index 30a5dfa4c5ea..6cc84017f740 100644
> --- a/gdb/amd64-sol2-tdep.c
> +++ b/gdb/amd64-sol2-tdep.c
> @@ -67,7 +67,7 @@ static int amd64_sol2_gregset_reg_offset[] = {
>     'mcontext_t' that contains the saved set of machine registers.  */
>  
>  static CORE_ADDR
> -amd64_sol2_mcontext_addr (frame_info_ptr this_frame)
> +amd64_sol2_mcontext_addr (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR sp, ucontext_addr;
>  
> diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
> index a8ff9246b8ad..f5968ab4d0f9 100644
> --- a/gdb/amd64-tdep.c
> +++ b/gdb/amd64-tdep.c
> @@ -348,7 +348,7 @@ amd64_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
>  }
>  
>  static value *
> -amd64_pseudo_register_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
> +amd64_pseudo_register_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  				  int regnum)
>  {
>    i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> @@ -379,7 +379,7 @@ amd64_pseudo_register_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
>  }
>  
>  static void
> -amd64_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame,
> +amd64_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  			     int regnum, gdb::array_view<const gdb_byte> buf)
>  {
>    i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> @@ -2510,7 +2510,7 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
>  /* Normal frames.  */
>  
>  static void
> -amd64_frame_cache_1 (frame_info_ptr this_frame,
> +amd64_frame_cache_1 (const frame_info_ptr &this_frame,
>  		     struct amd64_frame_cache *cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2579,7 +2579,7 @@ amd64_frame_cache_1 (frame_info_ptr this_frame,
>  }
>  
>  static struct amd64_frame_cache *
> -amd64_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +amd64_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct amd64_frame_cache *cache;
>  
> @@ -2603,7 +2603,7 @@ amd64_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static enum unwind_stop_reason
> -amd64_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +amd64_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  				void **this_cache)
>  {
>    struct amd64_frame_cache *cache =
> @@ -2620,7 +2620,7 @@ amd64_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  }
>  
>  static void
> -amd64_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +amd64_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		     struct frame_id *this_id)
>  {
>    struct amd64_frame_cache *cache =
> @@ -2638,7 +2638,7 @@ amd64_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -amd64_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +amd64_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			   int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2692,7 +2692,7 @@ amd64_gen_return_address (struct gdbarch *gdbarch,
>     on both platforms.  */
>  
>  static struct amd64_frame_cache *
> -amd64_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +amd64_sigtramp_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> @@ -2732,7 +2732,7 @@ amd64_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static enum unwind_stop_reason
> -amd64_sigtramp_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +amd64_sigtramp_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  					 void **this_cache)
>  {
>    struct amd64_frame_cache *cache =
> @@ -2745,7 +2745,7 @@ amd64_sigtramp_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  }
>  
>  static void
> -amd64_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +amd64_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  			      void **this_cache, struct frame_id *this_id)
>  {
>    struct amd64_frame_cache *cache =
> @@ -2763,7 +2763,7 @@ amd64_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -amd64_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +amd64_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  				    void **this_cache, int regnum)
>  {
>    /* Make sure we've initialized the cache.  */
> @@ -2774,7 +2774,7 @@ amd64_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  amd64_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -			      frame_info_ptr this_frame,
> +			      const frame_info_ptr &this_frame,
>  			      void **this_cache)
>  {
>    gdbarch *arch = get_frame_arch (this_frame);
> @@ -2816,7 +2816,7 @@ static const struct frame_unwind amd64_sigtramp_frame_unwind =
>  \f
>  
>  static CORE_ADDR
> -amd64_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +amd64_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct amd64_frame_cache *cache =
>      amd64_frame_cache (this_frame, this_cache);
> @@ -2878,7 +2878,7 @@ amd64_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
>  
>  static int
>  amd64_epilogue_frame_sniffer_1 (const struct frame_unwind *self,
> -				frame_info_ptr this_frame,
> +				const frame_info_ptr &this_frame,
>  				void **this_prologue_cache, bool override_p)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2911,7 +2911,7 @@ amd64_epilogue_frame_sniffer_1 (const struct frame_unwind *self,
>  
>  static int
>  amd64_epilogue_override_frame_sniffer (const struct frame_unwind *self,
> -				       frame_info_ptr this_frame,
> +				       const frame_info_ptr &this_frame,
>  				       void **this_prologue_cache)
>  {
>    return amd64_epilogue_frame_sniffer_1 (self, this_frame, this_prologue_cache,
> @@ -2920,7 +2920,7 @@ amd64_epilogue_override_frame_sniffer (const struct frame_unwind *self,
>  
>  static int
>  amd64_epilogue_frame_sniffer (const struct frame_unwind *self,
> -			      frame_info_ptr this_frame,
> +			      const frame_info_ptr &this_frame,
>  			      void **this_prologue_cache)
>  {
>    return amd64_epilogue_frame_sniffer_1 (self, this_frame, this_prologue_cache,
> @@ -2928,7 +2928,7 @@ amd64_epilogue_frame_sniffer (const struct frame_unwind *self,
>  }
>  
>  static struct amd64_frame_cache *
> -amd64_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +amd64_epilogue_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -2969,7 +2969,7 @@ amd64_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static enum unwind_stop_reason
> -amd64_epilogue_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +amd64_epilogue_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  					 void **this_cache)
>  {
>    struct amd64_frame_cache *cache
> @@ -2982,7 +2982,7 @@ amd64_epilogue_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  }
>  
>  static void
> -amd64_epilogue_frame_this_id (frame_info_ptr this_frame,
> +amd64_epilogue_frame_this_id (const frame_info_ptr &this_frame,
>  			      void **this_cache,
>  			      struct frame_id *this_id)
>  {
> @@ -3018,7 +3018,7 @@ static const struct frame_unwind amd64_epilogue_frame_unwind =
>  };
>  
>  static struct frame_id
> -amd64_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +amd64_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR fp;
>  
> @@ -3081,7 +3081,7 @@ const struct regset amd64_fpregset =
>     success.  */
>  
>  static int
> -amd64_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +amd64_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    gdb_byte buf[8];
>    CORE_ADDR jb_addr;
> diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
> index 50304e15cb8a..7c5169fd98c5 100644
> --- a/gdb/amd64-windows-tdep.c
> +++ b/gdb/amd64-windows-tdep.c
> @@ -517,7 +517,7 @@ pc_in_range (CORE_ADDR pc, const struct amd64_windows_frame_cache *cache)
>     Return 1 if an epilogue sequence was recognized, 0 otherwise.  */
>  
>  static int
> -amd64_windows_frame_decode_epilogue (frame_info_ptr this_frame,
> +amd64_windows_frame_decode_epilogue (const frame_info_ptr &this_frame,
>  				     struct amd64_windows_frame_cache *cache)
>  {
>    /* According to MSDN an epilogue "must consist of either an add RSP,constant
> @@ -697,7 +697,7 @@ amd64_windows_frame_decode_epilogue (frame_info_ptr this_frame,
>  /* Decode and execute unwind insns at UNWIND_INFO.  */
>  
>  static void
> -amd64_windows_frame_decode_insns (frame_info_ptr this_frame,
> +amd64_windows_frame_decode_insns (const frame_info_ptr &this_frame,
>  				  struct amd64_windows_frame_cache *cache,
>  				  CORE_ADDR unwind_info)
>  {
> @@ -1077,7 +1077,7 @@ amd64_windows_find_unwind_info (struct gdbarch *gdbarch, CORE_ADDR pc,
>     for THIS_FRAME.  */
>  
>  static struct amd64_windows_frame_cache *
> -amd64_windows_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +amd64_windows_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -1123,7 +1123,7 @@ amd64_windows_frame_cache (frame_info_ptr this_frame, void **this_cache)
>     using the standard Windows x64 SEH info.  */
>  
>  static struct value *
> -amd64_windows_frame_prev_register (frame_info_ptr this_frame,
> +amd64_windows_frame_prev_register (const frame_info_ptr &this_frame,
>  				   void **this_cache, int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1169,7 +1169,7 @@ amd64_windows_frame_prev_register (frame_info_ptr this_frame,
>     the standard Windows x64 SEH info.  */
>  
>  static void
> -amd64_windows_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +amd64_windows_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		   struct frame_id *this_id)
>  {
>    struct amd64_windows_frame_cache *cache =
> @@ -1235,7 +1235,7 @@ amd64_windows_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>  /* Check Win64 DLL jmp trampolines and find jump destination.  */
>  
>  static CORE_ADDR
> -amd64_windows_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +amd64_windows_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    CORE_ADDR destination = 0;
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
> index 44252e559cdc..ac137d9acc44 100644
> --- a/gdb/amdgpu-tdep.c
> +++ b/gdb/amdgpu-tdep.c
> @@ -846,7 +846,7 @@ struct amdgpu_frame_cache
>  };
>  
>  static amdgpu_frame_cache *
> -amdgpu_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +amdgpu_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    if (*this_cache != nullptr)
>      return (struct amdgpu_frame_cache *) *this_cache;
> @@ -862,7 +862,7 @@ amdgpu_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -amdgpu_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +amdgpu_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		      frame_id *this_id)
>  {
>    struct amdgpu_frame_cache *cache
> @@ -880,13 +880,13 @@ amdgpu_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static frame_id
> -amdgpu_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +amdgpu_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    return frame_id_build (0, get_frame_pc (this_frame));
>  }
>  
>  static struct value *
> -amdgpu_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +amdgpu_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			    int regnum)
>  {
>    return frame_unwind_got_register (this_frame, regnum, regnum);
> diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
> index 03ff49a2b197..ca630ab6df0c 100644
> --- a/gdb/arc-linux-tdep.c
> +++ b/gdb/arc-linux-tdep.c
> @@ -159,7 +159,7 @@ static const int arc_linux_core_reg_offsets[] = {
>     Returns TRUE if this is a sigtramp frame.  */
>  
>  static bool
> -arc_linux_is_sigtramp (frame_info_ptr this_frame)
> +arc_linux_is_sigtramp (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    CORE_ADDR pc = get_frame_pc (this_frame);
> @@ -257,7 +257,7 @@ arc_linux_is_sigtramp (frame_info_ptr this_frame)
>     etc) in GDB hardcode values.  */
>  
>  static CORE_ADDR
> -arc_linux_sigcontext_addr (frame_info_ptr this_frame)
> +arc_linux_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    const int ucontext_offset = 0x80;
>    const int sigcontext_offset = 0x14;
> diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
> index 84e211ce9ad5..12d8aee949fd 100644
> --- a/gdb/arc-tdep.c
> +++ b/gdb/arc-tdep.c
> @@ -998,7 +998,7 @@ arc_store_return_value (struct gdbarch *gdbarch, struct type *type,
>  /* Implement the "get_longjmp_target" gdbarch method.  */
>  
>  static int
> -arc_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +arc_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    arc_debug_printf ("called");
>  
> @@ -1062,7 +1062,7 @@ arc_return_value (struct gdbarch *gdbarch, struct value *function,
>     frame pointer.  */
>  
>  static CORE_ADDR
> -arc_frame_base_address (frame_info_ptr this_frame, void **prologue_cache)
> +arc_frame_base_address (const frame_info_ptr &this_frame, void **prologue_cache)
>  {
>    return (CORE_ADDR) get_frame_register_unsigned (this_frame, ARC_FP_REGNUM);
>  }
> @@ -1643,7 +1643,7 @@ arc_print_frame_cache (struct gdbarch *gdbarch, const char *message,
>  /* Frame unwinder for normal frames.  */
>  
>  static struct arc_frame_cache *
> -arc_make_frame_cache (frame_info_ptr this_frame)
> +arc_make_frame_cache (const frame_info_ptr &this_frame)
>  {
>    arc_debug_printf ("called");
>  
> @@ -1710,7 +1710,7 @@ arc_make_frame_cache (frame_info_ptr this_frame)
>  /* Implement the "this_id" frame_unwind method.  */
>  
>  static void
> -arc_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +arc_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		   struct frame_id *this_id)
>  {
>    arc_debug_printf ("called");
> @@ -1755,7 +1755,7 @@ arc_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  /* Implement the "prev_register" frame_unwind method.  */
>  
>  static struct value *
> -arc_frame_prev_register (frame_info_ptr this_frame,
> +arc_frame_prev_register (const frame_info_ptr &this_frame,
>  			 void **this_cache, int regnum)
>  {
>    if (*this_cache == NULL)
> @@ -1792,7 +1792,7 @@ arc_frame_prev_register (frame_info_ptr this_frame,
>  static void
>  arc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			   struct dwarf2_frame_state_reg *reg,
> -			   frame_info_ptr info)
> +			   const frame_info_ptr &info)
>  {
>    if (regnum == gdbarch_pc_regnum (gdbarch))
>      /* The return address column.  */
> @@ -1806,7 +1806,7 @@ arc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>      from within signal handlers.  */
>  
>  static struct arc_frame_cache *
> -arc_make_sigtramp_frame_cache (frame_info_ptr this_frame)
> +arc_make_sigtramp_frame_cache (const frame_info_ptr &this_frame)
>  {
>    arc_debug_printf ("called");
>  
> @@ -1845,7 +1845,7 @@ arc_make_sigtramp_frame_cache (frame_info_ptr this_frame)
>     frames.  */
>  
>  static void
> -arc_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +arc_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  			    void **this_cache, struct frame_id *this_id)
>  {
>    arc_debug_printf ("called");
> @@ -1864,7 +1864,7 @@ arc_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  /* Get a register from a signal handler frame.  */
>  
>  static struct value *
> -arc_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +arc_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  				  void **this_cache, int regnum)
>  {
>    arc_debug_printf ("regnum = %d", regnum);
> @@ -1882,7 +1882,7 @@ arc_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  arc_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -			    frame_info_ptr this_frame,
> +			    const frame_info_ptr &this_frame,
>  			    void **this_cache)
>  {
>    arc_debug_printf ("called");
> diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
> index 6fc1131a4352..c59490dec004 100644
> --- a/gdb/arc-tdep.h
> +++ b/gdb/arc-tdep.h
> @@ -131,10 +131,10 @@ struct arc_gdbarch_tdep : gdbarch_tdep_base
>    bool has_hw_loops = false;
>  
>    /* Detect sigtramp.  */
> -  bool (*is_sigtramp) (frame_info_ptr) = nullptr;
> +  bool (*is_sigtramp) (const frame_info_ptr &) = nullptr;
>  
>    /* Get address of sigcontext for sigtramp.  */
> -  CORE_ADDR (*sigcontext_addr) (frame_info_ptr) = nullptr;
> +  CORE_ADDR (*sigcontext_addr) (const frame_info_ptr &) = nullptr;
>  
>    /* Offset of registers in `struct sigcontext'.  */
>    const int *sc_reg_offset = nullptr;
> diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
> index 1faa013c16f0..ae3354f65799 100644
> --- a/gdb/arch-utils.c
> +++ b/gdb/arch-utils.c
> @@ -140,7 +140,7 @@ default_get_memtag (struct gdbarch *gdbarch, struct value *address,
>  }
>  
>  CORE_ADDR
> -generic_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +generic_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    return 0;
>  }
> @@ -166,7 +166,7 @@ generic_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
>  
>  int
>  default_code_of_frame_writable (struct gdbarch *gdbarch,
> -				frame_info_ptr frame)
> +				const frame_info_ptr &frame)
>  {
>    return 1;
>  }
> @@ -1079,7 +1079,7 @@ default_type_align (struct gdbarch *gdbarch, struct type *type)
>  /* See arch-utils.h.  */
>  
>  std::string
> -default_get_pc_address_flags (frame_info_ptr frame, CORE_ADDR pc)
> +default_get_pc_address_flags (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    return "";
>  }
> @@ -1105,7 +1105,8 @@ default_use_target_description_from_corefile_notes (struct gdbarch *gdbarch,
>  }
>  
>  CORE_ADDR
> -default_get_return_buf_addr (struct type *val_type, frame_info_ptr cur_frame)
> +default_get_return_buf_addr (struct type *val_type,
> +			     const frame_info_ptr &cur_frame)
>  {
>    return 0;
>  }
> diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
> index 0f37aaf20f82..2dcd8f6dc53b 100644
> --- a/gdb/arch-utils.h
> +++ b/gdb/arch-utils.h
> @@ -158,7 +158,7 @@ struct value *default_get_memtag (struct gdbarch *gdbarch,
>  				  struct value *address,
>  				  memtag_type tag_type);
>  
> -extern CORE_ADDR generic_skip_trampoline_code (frame_info_ptr frame,
> +extern CORE_ADDR generic_skip_trampoline_code (const frame_info_ptr &frame,
>  					       CORE_ADDR pc);
>  
>  extern CORE_ADDR generic_skip_solib_resolver (struct gdbarch *gdbarch,
> @@ -171,7 +171,7 @@ extern int generic_stack_frame_destroyed_p (struct gdbarch *gdbarch,
>  					    CORE_ADDR pc);
>  
>  extern int default_code_of_frame_writable (struct gdbarch *gdbarch,
> -					   frame_info_ptr frame);
> +					   const frame_info_ptr &frame);
>  
>  /* By default, registers are not convertible.  */
>  extern int generic_convert_register_p (struct gdbarch *gdbarch, int regnum,
> @@ -295,7 +295,7 @@ extern ULONGEST default_type_align (struct gdbarch *gdbarch,
>  				    struct type *type);
>  
>  /* Default implementation of gdbarch get_pc_address_flags method.  */
> -extern std::string default_get_pc_address_flags (frame_info_ptr frame,
> +extern std::string default_get_pc_address_flags (const frame_info_ptr &frame,
>  						 CORE_ADDR pc);
>  
>  /* Default implementation of gdbarch read_core_file_mappings method.  */
> @@ -313,7 +313,7 @@ extern bool default_use_target_description_from_corefile_notes
>  
>  /* Default implementation of gdbarch default_get_return_buf_addr method.  */
>  extern CORE_ADDR default_get_return_buf_addr (struct type *val_typegdbarch,
> -					      frame_info_ptr cur_frame);
> +					      const frame_info_ptr &cur_frame);
>  
>  /* Default implementation of gdbarch default_dwarf2_omit_typedef_p method.  */
>  extern bool default_dwarf2_omit_typedef_p (struct type *target_type,
> diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
> index 143aaf121b71..b485951c3764 100644
> --- a/gdb/arm-fbsd-tdep.c
> +++ b/gdb/arm-fbsd-tdep.c
> @@ -105,7 +105,7 @@ static const struct regcache_map_entry arm_fbsd_tls_regmap[] =
>  
>  static void
>  arm_fbsd_sigframe_init (const struct tramp_frame *self,
> -			frame_info_ptr this_frame,
> +			const frame_info_ptr &this_frame,
>  			struct trad_frame_cache *this_cache,
>  			CORE_ADDR func)
>  {
> diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
> index b559de0fb2d6..cc79247aaf12 100644
> --- a/gdb/arm-linux-tdep.c
> +++ b/gdb/arm-linux-tdep.c
> @@ -277,7 +277,7 @@ static struct arm_get_next_pcs_ops arm_linux_get_next_pcs_ops = {
>  };
>  
>  static void
> -arm_linux_sigtramp_cache (frame_info_ptr this_frame,
> +arm_linux_sigtramp_cache (const frame_info_ptr &this_frame,
>  			  struct trad_frame_cache *this_cache,
>  			  CORE_ADDR func, int regs_offset)
>  {
> @@ -300,7 +300,7 @@ arm_linux_sigtramp_cache (frame_info_ptr this_frame,
>  /* See arm-linux.h for stack layout details.  */
>  static void
>  arm_linux_sigreturn_init (const struct tramp_frame *self,
> -			  frame_info_ptr this_frame,
> +			  const frame_info_ptr &this_frame,
>  			  struct trad_frame_cache *this_cache,
>  			  CORE_ADDR func)
>  {
> @@ -320,7 +320,7 @@ arm_linux_sigreturn_init (const struct tramp_frame *self,
>  
>  static void
>  arm_linux_rt_sigreturn_init (const struct tramp_frame *self,
> -			  frame_info_ptr this_frame,
> +			  const frame_info_ptr &this_frame,
>  			  struct trad_frame_cache *this_cache,
>  			  CORE_ADDR func)
>  {
> @@ -343,7 +343,7 @@ arm_linux_rt_sigreturn_init (const struct tramp_frame *self,
>  
>  static void
>  arm_linux_restart_syscall_init (const struct tramp_frame *self,
> -				frame_info_ptr this_frame,
> +				const frame_info_ptr &this_frame,
>  				struct trad_frame_cache *this_cache,
>  				CORE_ADDR func)
>  {
> @@ -756,7 +756,7 @@ arm_linux_core_read_description (struct gdbarch *gdbarch,
>     will return to ARM or Thumb code.  Return 0 if it is not a
>     rt_sigreturn/sigreturn syscall.  */
>  static int
> -arm_linux_sigreturn_return_addr (frame_info_ptr frame,
> +arm_linux_sigreturn_return_addr (const frame_info_ptr &frame,
>  				 unsigned long svc_number,
>  				 CORE_ADDR *pc, int *is_thumb)
>  {
> @@ -1720,7 +1720,7 @@ arm_linux_syscall_record (struct regcache *regcache, unsigned long svc_number)
>  /* Implement the skip_trampoline_code gdbarch method.  */
>  
>  static CORE_ADDR
> -arm_linux_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +arm_linux_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    CORE_ADDR target_pc = arm_skip_stub (frame, pc);
>  
> diff --git a/gdb/arm-obsd-tdep.c b/gdb/arm-obsd-tdep.c
> index 9aa2408f36e3..0bdecec3b6fb 100644
> --- a/gdb/arm-obsd-tdep.c
> +++ b/gdb/arm-obsd-tdep.c
> @@ -30,7 +30,7 @@
>  
>  static void
>  armobsd_sigframe_init (const struct tramp_frame *self,
> -		       frame_info_ptr this_frame,
> +		       const frame_info_ptr &this_frame,
>  		       struct trad_frame_cache *cache,
>  		       CORE_ADDR func)
>  {
> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
> index 081e934cf862..3b4ae15df07e 100644
> --- a/gdb/arm-tdep.c
> +++ b/gdb/arm-tdep.c
> @@ -339,7 +339,7 @@ arm_cache_init (struct arm_prologue_cache *cache, struct gdbarch *gdbarch)
>  /* Similar to the previous function, but extracts GDBARCH from FRAME.  */
>  
>  static void
> -arm_cache_init (struct arm_prologue_cache *cache, frame_info_ptr frame)
> +arm_cache_init (struct arm_prologue_cache *cache, const frame_info_ptr &frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
> @@ -628,7 +628,7 @@ arm_is_thumb (struct regcache *regcache)
>     frame.  */
>  
>  int
> -arm_frame_is_thumb (frame_info_ptr frame)
> +arm_frame_is_thumb (const frame_info_ptr &frame)
>  {
>    /* Check the architecture of FRAME.  */
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -2213,7 +2213,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
>  }
>  
>  static void
> -arm_scan_prologue (frame_info_ptr this_frame,
> +arm_scan_prologue (const frame_info_ptr &this_frame,
>  		   struct arm_prologue_cache *cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2310,7 +2310,7 @@ arm_scan_prologue (frame_info_ptr this_frame,
>  }
>  
>  static struct arm_prologue_cache *
> -arm_make_prologue_cache (frame_info_ptr this_frame)
> +arm_make_prologue_cache (const frame_info_ptr &this_frame)
>  {
>    int reg;
>    struct arm_prologue_cache *cache;
> @@ -2344,7 +2344,7 @@ arm_make_prologue_cache (frame_info_ptr this_frame)
>  /* Implementation of the stop_reason hook for arm_prologue frames.  */
>  
>  static enum unwind_stop_reason
> -arm_prologue_unwind_stop_reason (frame_info_ptr this_frame,
> +arm_prologue_unwind_stop_reason (const frame_info_ptr &this_frame,
>  				 void **this_cache)
>  {
>    struct arm_prologue_cache *cache;
> @@ -2372,7 +2372,7 @@ arm_prologue_unwind_stop_reason (frame_info_ptr this_frame,
>     and the caller's SP when we were called.  */
>  
>  static void
> -arm_prologue_this_id (frame_info_ptr this_frame,
> +arm_prologue_this_id (const frame_info_ptr &this_frame,
>  		      void **this_cache,
>  		      struct frame_id *this_id)
>  {
> @@ -2400,7 +2400,7 @@ arm_prologue_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -arm_prologue_prev_register (frame_info_ptr this_frame,
> +arm_prologue_prev_register (const frame_info_ptr &this_frame,
>  			    void **this_cache,
>  			    int prev_regnum)
>  {
> @@ -2794,7 +2794,7 @@ arm_find_exidx_entry (CORE_ADDR memaddr, CORE_ADDR *start)
>     for the ARM Architecture" document.  */
>  
>  static struct arm_prologue_cache *
> -arm_exidx_fill_cache (frame_info_ptr this_frame, gdb_byte *entry)
> +arm_exidx_fill_cache (const frame_info_ptr &this_frame, gdb_byte *entry)
>  {
>    CORE_ADDR vsp = 0;
>    int vsp_valid = 0;
> @@ -3092,7 +3092,7 @@ arm_exidx_fill_cache (frame_info_ptr this_frame, gdb_byte *entry)
>  
>  static int
>  arm_exidx_unwind_sniffer (const struct frame_unwind *self,
> -			  frame_info_ptr this_frame,
> +			  const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -3199,7 +3199,7 @@ struct frame_unwind arm_exidx_unwind = {
>  };
>  
>  static struct arm_prologue_cache *
> -arm_make_epilogue_frame_cache (frame_info_ptr this_frame)
> +arm_make_epilogue_frame_cache (const frame_info_ptr &this_frame)
>  {
>    struct arm_prologue_cache *cache;
>    int reg;
> @@ -3231,7 +3231,7 @@ arm_make_epilogue_frame_cache (frame_info_ptr this_frame)
>     'struct frame_uwnind' for epilogue unwinder.  */
>  
>  static void
> -arm_epilogue_frame_this_id (frame_info_ptr this_frame,
> +arm_epilogue_frame_this_id (const frame_info_ptr &this_frame,
>  			    void **this_cache,
>  			    struct frame_id *this_id)
>  {
> @@ -3259,7 +3259,7 @@ arm_epilogue_frame_this_id (frame_info_ptr this_frame,
>     'struct frame_uwnind' for epilogue unwinder.  */
>  
>  static struct value *
> -arm_epilogue_frame_prev_register (frame_info_ptr this_frame,
> +arm_epilogue_frame_prev_register (const frame_info_ptr &this_frame,
>  				  void **this_cache, int regnum)
>  {
>    if (*this_cache == NULL)
> @@ -3278,7 +3278,7 @@ static int thumb_stack_frame_destroyed_p (struct gdbarch *gdbarch,
>  
>  static int
>  arm_epilogue_frame_sniffer (const struct frame_unwind *self,
> -			    frame_info_ptr this_frame,
> +			    const frame_info_ptr &this_frame,
>  			    void **this_prologue_cache)
>  {
>    if (frame_relative_level (this_frame) == 0)
> @@ -3335,7 +3335,7 @@ static const struct frame_unwind arm_epilogue_frame_unwind =
>     The trampoline 'bx r2' doesn't belong to main.  */
>  
>  static CORE_ADDR
> -arm_skip_bx_reg (frame_info_ptr frame, CORE_ADDR pc)
> +arm_skip_bx_reg (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    /* The heuristics of recognizing such trampoline is that FRAME is
>       executing in Thumb mode and the instruction on PC is 'bx Rm'.  */
> @@ -3367,7 +3367,7 @@ arm_skip_bx_reg (frame_info_ptr frame, CORE_ADDR pc)
>  }
>  
>  static struct arm_prologue_cache *
> -arm_make_stub_cache (frame_info_ptr this_frame)
> +arm_make_stub_cache (const frame_info_ptr &this_frame)
>  {
>    struct arm_prologue_cache *cache;
>  
> @@ -3386,7 +3386,7 @@ arm_make_stub_cache (frame_info_ptr this_frame)
>  /* Our frame ID for a stub frame is the current SP and LR.  */
>  
>  static void
> -arm_stub_this_id (frame_info_ptr this_frame,
> +arm_stub_this_id (const frame_info_ptr &this_frame,
>  		  void **this_cache,
>  		  struct frame_id *this_id)
>  {
> @@ -3404,7 +3404,7 @@ arm_stub_this_id (frame_info_ptr this_frame,
>  
>  static int
>  arm_stub_unwind_sniffer (const struct frame_unwind *self,
> -			 frame_info_ptr this_frame,
> +			 const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache)
>  {
>    CORE_ADDR addr_in_block;
> @@ -3442,7 +3442,7 @@ struct frame_unwind arm_stub_unwind = {
>     returned.  */
>  
>  static struct arm_prologue_cache *
> -arm_m_exception_cache (frame_info_ptr this_frame)
> +arm_m_exception_cache (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
> @@ -3828,7 +3828,7 @@ arm_m_exception_cache (frame_info_ptr this_frame)
>  /* Implementation of the stop_reason hook for arm_m_exception frames.  */
>  
>  static enum unwind_stop_reason
> -arm_m_exception_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +arm_m_exception_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  					  void **this_cache)
>  {
>    struct arm_prologue_cache *cache;
> @@ -3850,7 +3850,7 @@ arm_m_exception_frame_unwind_stop_reason (frame_info_ptr this_frame,
>     'struct frame_uwnind'.  */
>  
>  static void
> -arm_m_exception_this_id (frame_info_ptr this_frame,
> +arm_m_exception_this_id (const frame_info_ptr &this_frame,
>  			 void **this_cache,
>  			 struct frame_id *this_id)
>  {
> @@ -3871,7 +3871,7 @@ arm_m_exception_this_id (frame_info_ptr this_frame,
>     'struct frame_uwnind'.  */
>  
>  static struct value *
> -arm_m_exception_prev_register (frame_info_ptr this_frame,
> +arm_m_exception_prev_register (const frame_info_ptr &this_frame,
>  			       void **this_cache,
>  			       int prev_regnum)
>  {
> @@ -3936,7 +3936,7 @@ arm_m_exception_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  arm_m_exception_unwind_sniffer (const struct frame_unwind *self,
> -				frame_info_ptr this_frame,
> +				const frame_info_ptr &this_frame,
>  				void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -3964,7 +3964,7 @@ struct frame_unwind arm_m_exception_unwind =
>  };
>  
>  static CORE_ADDR
> -arm_normal_frame_base (frame_info_ptr this_frame, void **this_cache)
> +arm_normal_frame_base (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct arm_prologue_cache *cache;
>  
> @@ -3997,7 +3997,7 @@ struct arm_dwarf2_prev_register_cache
>  };
>  
>  static struct value *
> -arm_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache,
> +arm_dwarf2_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			  int regnum)
>  {
>    struct gdbarch * gdbarch = get_frame_arch (this_frame);
> @@ -4897,7 +4897,7 @@ print_fpu_flags (struct ui_file *file, int flags)
>     (if present) or emulator.  */
>  static void
>  arm_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
> -		      frame_info_ptr frame, const char *args)
> +		      const frame_info_ptr &frame, const char *args)
>  {
>    unsigned long status = get_frame_register_unsigned (frame, ARM_FPS_REGNUM);
>    int type;
> @@ -5244,7 +5244,7 @@ static const unsigned char op_lit0 = DW_OP_lit0;
>  static void
>  arm_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			   struct dwarf2_frame_state_reg *reg,
> -			   frame_info_ptr this_frame)
> +			   const frame_info_ptr &this_frame)
>  {
>    arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
>  
> @@ -9343,7 +9343,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function,
>  
>  
>  static int
> -arm_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +arm_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
> @@ -9415,7 +9415,7 @@ arm_is_sgstubs_section (struct obj_section *sec)
>     return the target PC.  Otherwise return 0.  */
>  
>  CORE_ADDR
> -arm_skip_stub (frame_info_ptr frame, CORE_ADDR pc)
> +arm_skip_stub (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    const char *name;
>    int namelen;
> @@ -9821,7 +9821,7 @@ arm_neon_quad_read (struct gdbarch *gdbarch, readable_regcache *regcache,
>     register, in [0, 15].  */
>  
>  static value *
> -arm_neon_quad_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
> +arm_neon_quad_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  			  int pseudo_reg_num, int quad_reg_index)
>  {
>    std::string raw_reg_name = string_printf ("d%d", quad_reg_index << 1);
> @@ -9836,7 +9836,7 @@ arm_neon_quad_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
>  /* Read the contents of the MVE pseudo register REGNUM and return it as a
>     value.  */
>  static value *
> -arm_mve_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
> +arm_mve_pseudo_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  			   int pseudo_reg_num)
>  {
>    arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
> @@ -9847,7 +9847,7 @@ arm_mve_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
>  }
>  
>  static value *
> -arm_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
> +arm_pseudo_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  		       const int pseudo_reg_num)
>  {
>    arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
> @@ -9909,7 +9909,7 @@ arm_neon_quad_write (struct gdbarch *gdbarch, struct regcache *regcache,
>  }
>  
>  static void
> -arm_neon_quad_write (gdbarch *gdbarch, frame_info_ptr next_frame,
> +arm_neon_quad_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  		     int quad_reg_index, gdb::array_view<const gdb_byte> buf)
>  {
>    std::string raw_reg_name = string_printf ("d%d", quad_reg_index << 1);
> @@ -9923,7 +9923,7 @@ arm_neon_quad_write (gdbarch *gdbarch, frame_info_ptr next_frame,
>  /* Store the contents of BUF to the MVE pseudo register REGNUM.  */
>  
>  static void
> -arm_mve_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
> +arm_mve_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  		      int pseudo_reg_num, gdb::array_view<const gdb_byte> buf)
>  {
>    arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
> @@ -9933,7 +9933,7 @@ arm_mve_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
>  }
>  
>  static void
> -arm_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
> +arm_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  		  const int pseudo_reg_num,
>  		  gdb::array_view<const gdb_byte> buf)
>  {
> @@ -9973,7 +9973,7 @@ arm_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
>  }
>  
>  static struct value *
> -value_of_arm_user_reg (frame_info_ptr frame, const void *baton)
> +value_of_arm_user_reg (const frame_info_ptr &frame, const void *baton)
>  {
>    const int *reg_p = (const int *) baton;
>    return value_of_register (*reg_p, get_next_frame_sentinel_okay (frame));
> @@ -10067,7 +10067,7 @@ arm_register_g_packet_guesses (struct gdbarch *gdbarch)
>  /* Implement the code_of_frame_writable gdbarch method.  */
>  
>  static int
> -arm_code_of_frame_writable (struct gdbarch *gdbarch, frame_info_ptr frame)
> +arm_code_of_frame_writable (struct gdbarch *gdbarch, const frame_info_ptr &frame)
>  {
>    arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
>  
> @@ -10095,7 +10095,7 @@ arm_gnu_triplet_regexp (struct gdbarch *gdbarch)
>  /* Implement the "get_pc_address_flags" gdbarch method.  */
>  
>  static std::string
> -arm_get_pc_address_flags (frame_info_ptr frame, CORE_ADDR pc)
> +arm_get_pc_address_flags (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    if (get_frame_pc_masked (frame))
>      return "PAC";
> diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
> index 506387b529de..11839b0ff4d0 100644
> --- a/gdb/arm-tdep.h
> +++ b/gdb/arm-tdep.h
> @@ -279,7 +279,7 @@ extern void
>  		       arm_displaced_step_copy_insn_closure *dsc, int regno,
>  		       ULONGEST val, enum pc_write_style write_pc);
>  
> -CORE_ADDR arm_skip_stub (frame_info_ptr, CORE_ADDR);
> +CORE_ADDR arm_skip_stub (const frame_info_ptr &, CORE_ADDR);
>  
>  ULONGEST arm_get_next_pcs_read_memory_unsigned_integer (CORE_ADDR memaddr,
>  							int len,
> @@ -292,7 +292,7 @@ int arm_get_next_pcs_is_thumb (struct arm_get_next_pcs *self);
>  
>  std::vector<CORE_ADDR> arm_software_single_step (struct regcache *);
>  int arm_is_thumb (struct regcache *regcache);
> -int arm_frame_is_thumb (frame_info_ptr frame);
> +int arm_frame_is_thumb (const frame_info_ptr &frame);
>  
>  extern void arm_displaced_step_fixup (struct gdbarch *,
>  				      displaced_step_copy_insn_closure *,
> diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c
> index a31da71de082..b722851e7e1a 100644
> --- a/gdb/arm-wince-tdep.c
> +++ b/gdb/arm-wince-tdep.c
> @@ -36,7 +36,7 @@ static const gdb_byte arm_wince_thumb_le_breakpoint[] = { 0xfe, 0xdf };
>  #define ARM_WINCE_JB_PC			10
>  
>  static CORE_ADDR
> -arm_pe_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +arm_pe_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
> index 63b45be7563d..2d38f41cd7fa 100644
> --- a/gdb/avr-tdep.c
> +++ b/gdb/avr-tdep.c
> @@ -979,7 +979,7 @@ avr_return_value (struct gdbarch *gdbarch, struct value *function,
>     for it IS the sp for the next frame.  */
>  
>  static struct avr_unwind_cache *
> -avr_frame_unwind_cache (frame_info_ptr this_frame,
> +avr_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			void **this_prologue_cache)
>  {
>    CORE_ADDR start_pc, current_pc;
> @@ -1059,7 +1059,7 @@ avr_frame_unwind_cache (frame_info_ptr this_frame,
>  }
>  
>  static CORE_ADDR
> -avr_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +avr_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    ULONGEST pc;
>  
> @@ -1069,7 +1069,7 @@ avr_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  }
>  
>  static CORE_ADDR
> -avr_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +avr_unwind_sp (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    ULONGEST sp;
>  
> @@ -1082,7 +1082,7 @@ avr_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>     frame.  This will be used to create a new GDB frame struct.  */
>  
>  static void
> -avr_frame_this_id (frame_info_ptr this_frame,
> +avr_frame_this_id (const frame_info_ptr &this_frame,
>  		   void **this_prologue_cache,
>  		   struct frame_id *this_id)
>  {
> @@ -1107,7 +1107,7 @@ avr_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -avr_frame_prev_register (frame_info_ptr this_frame,
> +avr_frame_prev_register (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache, int regnum)
>  {
>    struct avr_unwind_cache *info
> @@ -1166,7 +1166,7 @@ static const struct frame_unwind avr_frame_unwind = {
>  };
>  
>  static CORE_ADDR
> -avr_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +avr_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct avr_unwind_cache *info
>      = avr_frame_unwind_cache (this_frame, this_cache);
> @@ -1186,7 +1186,7 @@ static const struct frame_base avr_frame_base = {
>     save_dummy_frame_tos(), and the PC match the dummy frame's breakpoint.  */
>  
>  static struct frame_id
> -avr_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +avr_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    ULONGEST base;
>  
> diff --git a/gdb/bfin-linux-tdep.c b/gdb/bfin-linux-tdep.c
> index 35fdf3f2acb5..31aa14765ae8 100644
> --- a/gdb/bfin-linux-tdep.c
> +++ b/gdb/bfin-linux-tdep.c
> @@ -95,7 +95,7 @@ static const int bfin_linux_sigcontext_reg_offset[BFIN_NUM_REGS] =
>  
>  static void
>  bfin_linux_sigframe_init (const struct tramp_frame *self,
> -			  frame_info_ptr this_frame,
> +			  const frame_info_ptr &this_frame,
>  			  struct trad_frame_cache *this_cache,
>  			  CORE_ADDR func)
>  {
> diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
> index 877fd94d7df0..357866ef9532 100644
> --- a/gdb/bfin-tdep.c
> +++ b/gdb/bfin-tdep.c
> @@ -288,7 +288,7 @@ bfin_alloc_frame_cache (void)
>  }
>  
>  static struct bfin_frame_cache *
> -bfin_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +bfin_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct bfin_frame_cache *cache;
>    int i;
> @@ -340,7 +340,7 @@ bfin_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -bfin_frame_this_id (frame_info_ptr this_frame,
> +bfin_frame_this_id (const frame_info_ptr &this_frame,
>  		    void **this_cache,
>  		    struct frame_id *this_id)
>  {
> @@ -355,7 +355,7 @@ bfin_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -bfin_frame_prev_register (frame_info_ptr this_frame,
> +bfin_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **this_cache,
>  			  int regnum)
>  {
> @@ -724,7 +724,7 @@ bfin_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
>  }
>  
>  static CORE_ADDR
> -bfin_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +bfin_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct bfin_frame_cache *cache = bfin_frame_cache (this_frame, this_cache);
>  
> @@ -732,7 +732,7 @@ bfin_frame_base_address (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static CORE_ADDR
> -bfin_frame_local_address (frame_info_ptr this_frame, void **this_cache)
> +bfin_frame_local_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct bfin_frame_cache *cache = bfin_frame_cache (this_frame, this_cache);
>  
> @@ -740,7 +740,7 @@ bfin_frame_local_address (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static CORE_ADDR
> -bfin_frame_args_address (frame_info_ptr this_frame, void **this_cache)
> +bfin_frame_args_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct bfin_frame_cache *cache = bfin_frame_cache (this_frame, this_cache);
>  
> diff --git a/gdb/blockframe.c b/gdb/blockframe.c
> index 6076ad64a4a8..451818332de3 100644
> --- a/gdb/blockframe.c
> +++ b/gdb/blockframe.c
> @@ -52,7 +52,7 @@
>     slot instruction.  */
>  
>  const struct block *
> -get_frame_block (frame_info_ptr frame, CORE_ADDR *addr_in_block)
> +get_frame_block (const frame_info_ptr &frame, CORE_ADDR *addr_in_block)
>  {
>    CORE_ADDR pc;
>    const struct block *bl;
> @@ -115,7 +115,7 @@ get_pc_function_start (CORE_ADDR pc)
>  /* Return the symbol for the function executing in frame FRAME.  */
>  
>  struct symbol *
> -get_frame_function (frame_info_ptr frame)
> +get_frame_function (const frame_info_ptr &frame)
>  {
>    const struct block *bl = get_frame_block (frame, 0);
>  
> diff --git a/gdb/bpf-tdep.c b/gdb/bpf-tdep.c
> index 4409a1e696c9..1b3f3e72c5b7 100644
> --- a/gdb/bpf-tdep.c
> +++ b/gdb/bpf-tdep.c
> @@ -154,7 +154,7 @@ bpf_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
>  /* Given THIS_FRAME, return its ID.  */
>  
>  static void
> -bpf_frame_this_id (frame_info_ptr this_frame,
> +bpf_frame_this_id (const frame_info_ptr &this_frame,
>  		   void **this_prologue_cache,
>  		   struct frame_id *this_id)
>  {
> @@ -165,7 +165,7 @@ bpf_frame_this_id (frame_info_ptr this_frame,
>  /* Return the reason why we can't unwind past THIS_FRAME.  */
>  
>  static enum unwind_stop_reason
> -bpf_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +bpf_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  			      void **this_cache)
>  {
>    return UNWIND_OUTERMOST;
> @@ -174,7 +174,7 @@ bpf_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  /* Ask THIS_FRAME to unwind its register.  */
>  
>  static struct value *
> -bpf_frame_prev_register (frame_info_ptr this_frame,
> +bpf_frame_prev_register (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache, int regnum)
>  {
>    return frame_unwind_got_register (this_frame, regnum, regnum);
> @@ -235,7 +235,7 @@ bpf_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
>  /* Assuming THIS_FRAME is a dummy frame, return its frame ID.  */
>  
>  static struct frame_id
> -bpf_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +bpf_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR sp = get_frame_register_unsigned (this_frame,
>  					      gdbarch_sp_regnum (gdbarch));
> diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
> index a6de59bf292a..882c1a03fe29 100644
> --- a/gdb/cp-abi.c
> +++ b/gdb/cp-abi.c
> @@ -153,7 +153,7 @@ cplus_make_method_ptr (struct type *type, gdb_byte *contents,
>  }
>  
>  CORE_ADDR
> -cplus_skip_trampoline (frame_info_ptr frame,
> +cplus_skip_trampoline (const frame_info_ptr &frame,
>  		       CORE_ADDR stop_pc)
>  {
>    if (current_cp_abi.skip_trampoline == NULL)
> diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h
> index a993e1dd18a0..fdbe48431290 100644
> --- a/gdb/cp-abi.h
> +++ b/gdb/cp-abi.h
> @@ -204,7 +204,7 @@ extern std::string cplus_typename_from_type_info (struct value *value);
>     address of the routine we are thunking to and continue to there
>     instead.  */
>  
> -CORE_ADDR cplus_skip_trampoline (frame_info_ptr frame,
> +CORE_ADDR cplus_skip_trampoline (const frame_info_ptr &frame,
>  				 CORE_ADDR stop_pc);
>  
>  /* Return a struct that provides pass-by-reference information
> @@ -247,7 +247,7 @@ struct cp_abi_ops
>    struct type *(*get_typeid_type) (struct gdbarch *gdbarch);
>    struct type *(*get_type_from_type_info) (struct value *value);
>    std::string (*get_typename_from_type_info) (struct value *value);
> -  CORE_ADDR (*skip_trampoline) (frame_info_ptr, CORE_ADDR);
> +  CORE_ADDR (*skip_trampoline) (const frame_info_ptr &, CORE_ADDR);
>    struct language_pass_by_ref_info (*pass_by_reference) (struct type *type);
>  };
>  
> diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
> index 1f108740ad21..02c35da723d4 100644
> --- a/gdb/cris-tdep.c
> +++ b/gdb/cris-tdep.c
> @@ -193,7 +193,7 @@ static const unsigned short rt_sigtramp_code[] =
>     the routine.  Otherwise, return 0.  */
>  
>  static CORE_ADDR
> -cris_sigtramp_start (frame_info_ptr this_frame)
> +cris_sigtramp_start (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    gdb_byte buf[SIGTRAMP_LEN];
> @@ -221,7 +221,7 @@ cris_sigtramp_start (frame_info_ptr this_frame)
>     the routine.  Otherwise, return 0.  */
>  
>  static CORE_ADDR
> -cris_rt_sigtramp_start (frame_info_ptr this_frame)
> +cris_rt_sigtramp_start (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    gdb_byte buf[SIGTRAMP_LEN];
> @@ -249,7 +249,7 @@ cris_rt_sigtramp_start (frame_info_ptr this_frame)
>     return the address of the associated sigcontext structure.  */
>  
>  static CORE_ADDR
> -cris_sigcontext_addr (frame_info_ptr this_frame)
> +cris_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -309,7 +309,7 @@ struct cris_unwind_cache
>  };
>  
>  static struct cris_unwind_cache *
> -cris_sigtramp_frame_unwind_cache (frame_info_ptr this_frame,
> +cris_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
>  				  void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -402,7 +402,7 @@ cris_sigtramp_frame_unwind_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -cris_sigtramp_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +cris_sigtramp_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			     struct frame_id *this_id)
>  {
>    struct cris_unwind_cache *cache =
> @@ -412,10 +412,10 @@ cris_sigtramp_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  
>  /* Forward declaration.  */
>  
> -static struct value *cris_frame_prev_register (frame_info_ptr this_frame,
> +static struct value *cris_frame_prev_register (const frame_info_ptr &this_frame,
>  					       void **this_cache, int regnum);
>  static struct value *
> -cris_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +cris_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  				   void **this_cache, int regnum)
>  {
>    /* Make sure we've initialized the cache.  */
> @@ -425,7 +425,7 @@ cris_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  cris_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_cache)
>  {
>    if (cris_sigtramp_start (this_frame) 
> @@ -448,7 +448,7 @@ static const struct frame_unwind cris_sigtramp_frame_unwind =
>  
>  static int
>  crisv32_single_step_through_delay (struct gdbarch *gdbarch,
> -				   frame_info_ptr this_frame)
> +				   const frame_info_ptr &this_frame)
>  {
>    cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
>    ULONGEST erp;
> @@ -645,11 +645,11 @@ static void set_cris_dwarf2_cfi (const char *ignore_args, int from_tty,
>  				 struct cmd_list_element *c);
>  
>  static CORE_ADDR cris_scan_prologue (CORE_ADDR pc, 
> -				     frame_info_ptr this_frame,
> +				     const frame_info_ptr &this_frame,
>  				     struct cris_unwind_cache *info);
>  
>  static CORE_ADDR crisv32_scan_prologue (CORE_ADDR pc, 
> -					frame_info_ptr this_frame,
> +					const frame_info_ptr &this_frame,
>  					struct cris_unwind_cache *info);
>  
>  /* When arguments must be pushed onto the stack, they go on in reverse
> @@ -692,7 +692,7 @@ pop_stack_item (struct cris_stack_item *si)
>     for it IS the sp for the next frame.  */
>  
>  static struct cris_unwind_cache *
> -cris_frame_unwind_cache (frame_info_ptr this_frame,
> +cris_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -729,7 +729,7 @@ cris_frame_unwind_cache (frame_info_ptr this_frame,
>     frame.  This will be used to create a new GDB frame struct.  */
>  
>  static void
> -cris_frame_this_id (frame_info_ptr this_frame,
> +cris_frame_this_id (const frame_info_ptr &this_frame,
>  		    void **this_prologue_cache,
>  		    struct frame_id *this_id)
>  {
> @@ -755,7 +755,7 @@ cris_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -cris_frame_prev_register (frame_info_ptr this_frame,
> +cris_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache, int regnum)
>  {
>    struct cris_unwind_cache *info
> @@ -912,7 +912,7 @@ static const struct frame_unwind cris_frame_unwind =
>  };
>  
>  static CORE_ADDR
> -cris_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +cris_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct cris_unwind_cache *info
>      = cris_frame_unwind_cache (this_frame, this_cache);
> @@ -1004,7 +1004,7 @@ static const struct frame_base cris_frame_base =
>     determine that it is a prologue (1).  */
>  
>  static CORE_ADDR 
> -cris_scan_prologue (CORE_ADDR pc, frame_info_ptr this_frame,
> +cris_scan_prologue (CORE_ADDR pc, const frame_info_ptr &this_frame,
>  		    struct cris_unwind_cache *info)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1287,7 +1287,7 @@ cris_scan_prologue (CORE_ADDR pc, frame_info_ptr this_frame,
>  }
>  
>  static CORE_ADDR 
> -crisv32_scan_prologue (CORE_ADDR pc, frame_info_ptr this_frame,
> +crisv32_scan_prologue (CORE_ADDR pc, const frame_info_ptr &this_frame,
>  		    struct cris_unwind_cache *info)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1756,7 +1756,7 @@ cris_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int reg)
>  static void
>  cris_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			    struct dwarf2_frame_state_reg *reg,
> -			    frame_info_ptr this_frame)
> +			    const frame_info_ptr &this_frame)
>  {
>    /* The return address column.  */
>    if (regnum == gdbarch_pc_regnum (gdbarch))
> diff --git a/gdb/csky-linux-tdep.c b/gdb/csky-linux-tdep.c
> index d3105dc54753..d485f1763178 100644
> --- a/gdb/csky-linux-tdep.c
> +++ b/gdb/csky-linux-tdep.c
> @@ -310,7 +310,7 @@ csky_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
>  
>  static void
>  csky_linux_rt_sigreturn_init (const struct tramp_frame *self,
> -			      frame_info_ptr this_frame,
> +			      const frame_info_ptr &this_frame,
>  			      struct trad_frame_cache *this_cache,
>  			      CORE_ADDR func)
>  {
> @@ -355,7 +355,7 @@ csky_linux_rt_sigreturn_tramp_frame = {
>  
>  static void
>  csky_linux_rt_sigreturn_init_pt_regs (const struct tramp_frame *self,
> -				      frame_info_ptr this_frame,
> +				      const frame_info_ptr &this_frame,
>  				      struct trad_frame_cache *this_cache,
>  				      CORE_ADDR func)
>  {
> diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
> index 2aa6c0abcb85..c1ce8a5b02ce 100644
> --- a/gdb/csky-tdep.c
> +++ b/gdb/csky-tdep.c
> @@ -958,7 +958,7 @@ csky_analyze_prologue (struct gdbarch *gdbarch,
>  		       CORE_ADDR start_pc,
>  		       CORE_ADDR limit_pc,
>  		       CORE_ADDR end_pc,
> -		       frame_info_ptr this_frame,
> +		       const frame_info_ptr &this_frame,
>  		       struct csky_unwind_cache *this_cache,
>  		       lr_type_t lr_type)
>  {
> @@ -2063,7 +2063,7 @@ csky_analyze_lr_type (struct gdbarch *gdbarch,
>  /* Heuristic unwinder.  */
>  
>  static struct csky_unwind_cache *
> -csky_frame_unwind_cache (frame_info_ptr this_frame)
> +csky_frame_unwind_cache (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR prologue_start, prologue_end, func_end, prev_pc, block_addr;
>    struct csky_unwind_cache *cache;
> @@ -2122,7 +2122,7 @@ csky_frame_unwind_cache (frame_info_ptr this_frame)
>  /* Implement the this_id function for the normal unwinder.  */
>  
>  static void
> -csky_frame_this_id (frame_info_ptr this_frame,
> +csky_frame_this_id (const frame_info_ptr &this_frame,
>  		    void **this_prologue_cache, struct frame_id *this_id)
>  {
>    struct csky_unwind_cache *cache;
> @@ -2143,7 +2143,7 @@ csky_frame_this_id (frame_info_ptr this_frame,
>  /* Implement the prev_register function for the normal unwinder.  */
>  
>  static struct value *
> -csky_frame_prev_register (frame_info_ptr this_frame,
> +csky_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache, int regnum)
>  {
>    struct csky_unwind_cache *cache;
> @@ -2172,7 +2172,7 @@ static const struct frame_unwind csky_unwind_cache = {
>  };
>  
>  static CORE_ADDR
> -csky_check_long_branch (frame_info_ptr frame, CORE_ADDR pc)
> +csky_check_long_branch (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    gdb_byte buf[8];
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -2209,7 +2209,7 @@ csky_check_long_branch (frame_info_ptr frame, CORE_ADDR pc)
>  
>  static int
>  csky_stub_unwind_sniffer (const struct frame_unwind *self,
> -			  frame_info_ptr this_frame,
> +			  const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache)
>  {
>    CORE_ADDR addr_in_block, pc;
> @@ -2240,7 +2240,7 @@ csky_stub_unwind_sniffer (const struct frame_unwind *self,
>  }
>  
>  static struct csky_unwind_cache *
> -csky_make_stub_cache (frame_info_ptr this_frame)
> +csky_make_stub_cache (const frame_info_ptr &this_frame)
>  {
>    struct csky_unwind_cache *cache;
>  
> @@ -2252,7 +2252,7 @@ csky_make_stub_cache (frame_info_ptr this_frame)
>  }
>  
>  static void
> -csky_stub_this_id (frame_info_ptr this_frame,
> +csky_stub_this_id (const frame_info_ptr &this_frame,
>  		  void **this_cache,
>  		  struct frame_id *this_id)
>  {
> @@ -2267,7 +2267,7 @@ csky_stub_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -csky_stub_prev_register (frame_info_ptr this_frame,
> +csky_stub_prev_register (const frame_info_ptr &this_frame,
>  			    void **this_cache,
>  			    int prev_regnum)
>  {
> @@ -2307,7 +2307,7 @@ static frame_unwind csky_stub_unwind = {
>     for the normal unwinder.  */
>  
>  static CORE_ADDR
> -csky_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +csky_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct csky_unwind_cache *cache;
>  
> @@ -2330,7 +2330,7 @@ static const struct frame_base csky_frame_base = {
>  static void
>  csky_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			    struct dwarf2_frame_state_reg *reg,
> -			    frame_info_ptr this_frame)
> +			    const frame_info_ptr &this_frame)
>  {
>    if (regnum == gdbarch_pc_regnum (gdbarch))
>      reg->how = DWARF2_FRAME_REG_RA;
> diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
> index 8bde53ea8fd1..5757de1cf77d 100644
> --- a/gdb/dtrace-probe.c
> +++ b/gdb/dtrace-probe.c
> @@ -129,7 +129,7 @@ class dtrace_probe : public probe
>  
>    /* See probe.h.  */
>    struct value *evaluate_argument (unsigned n,
> -				   frame_info_ptr frame) override;
> +				   const frame_info_ptr &frame) override;
>  
>    /* See probe.h.  */
>    void compile_to_ax (struct agent_expr *aexpr,
> @@ -708,7 +708,7 @@ dtrace_probe::can_evaluate_arguments () const
>  
>  struct value *
>  dtrace_probe::evaluate_argument (unsigned n,
> -				 frame_info_ptr frame)
> +				 const frame_info_ptr &frame)
>  {
>    struct gdbarch *gdbarch = this->get_gdbarch ();
>    struct dtrace_probe_arg *arg;
> diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
> index 309483d95d41..5969ef2cdadd 100644
> --- a/gdb/dummy-frame.c
> +++ b/gdb/dummy-frame.c
> @@ -288,7 +288,7 @@ struct dummy_frame_cache
>  
>  static int
>  dummy_frame_sniffer (const struct frame_unwind *self,
> -		     frame_info_ptr this_frame,
> +		     const frame_info_ptr &this_frame,
>  		     void **this_prologue_cache)
>  {
>    /* When unwinding a normal frame, the stack structure is determined
> @@ -334,7 +334,7 @@ dummy_frame_sniffer (const struct frame_unwind *self,
>     register value is taken from the local copy of the register buffer.  */
>  
>  static struct value *
> -dummy_frame_prev_register (frame_info_ptr this_frame,
> +dummy_frame_prev_register (const frame_info_ptr &this_frame,
>  			   void **this_prologue_cache,
>  			   int regnum)
>  {
> @@ -364,7 +364,7 @@ dummy_frame_prev_register (frame_info_ptr this_frame,
>     dummy cache is located and saved in THIS_PROLOGUE_CACHE.  */
>  
>  static void
> -dummy_frame_this_id (frame_info_ptr this_frame,
> +dummy_frame_this_id (const frame_info_ptr &this_frame,
>  		     void **this_prologue_cache,
>  		     struct frame_id *this_id)
>  {
> @@ -390,7 +390,7 @@ const struct frame_unwind dummy_frame_unwind =
>  /* See dummy-frame.h.  */
>  
>  struct frame_id
> -default_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +default_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR sp, pc;
>  
> diff --git a/gdb/dummy-frame.h b/gdb/dummy-frame.h
> index 753be1aa54c4..7d963ad9beb6 100644
> --- a/gdb/dummy-frame.h
> +++ b/gdb/dummy-frame.h
> @@ -78,6 +78,6 @@ extern int find_dummy_frame_dtor (dummy_frame_dtor_ftype *dtor,
>     for THIS_FRAME assuming that the frame is a dummy frame.  */
>  
>  extern struct frame_id default_dummy_id (struct gdbarch *gdbarch,
> -					 frame_info_ptr this_frame);
> +					 const frame_info_ptr &this_frame);
>  
>  #endif /* !defined (DUMMY_FRAME_H)  */
> diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c
> index 1a0bc1d528e2..065e2b90a0f4 100644
> --- a/gdb/dwarf2/ada-imported.c
> +++ b/gdb/dwarf2/ada-imported.c
> @@ -32,7 +32,7 @@ get_imported_name (const struct symbol *sym)
>  /* Implement the read_variable method from symbol_computed_ops.  */
>  
>  static struct value *
> -ada_imported_read_variable (struct symbol *symbol, frame_info_ptr frame)
> +ada_imported_read_variable (struct symbol *symbol, const frame_info_ptr &frame)
>  {
>    const char *name = get_imported_name (symbol);
>    bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (name, false);
> diff --git a/gdb/dwarf2/call-site.h b/gdb/dwarf2/call-site.h
> index 5434c8452606..0a0c7e83b813 100644
> --- a/gdb/dwarf2/call-site.h
> +++ b/gdb/dwarf2/call-site.h
> @@ -94,7 +94,7 @@ struct call_site_target
>  
>    void iterate_over_addresses (struct gdbarch *call_site_gdbarch,
>  			       const struct call_site *call_site,
> -			       frame_info_ptr caller_frame,
> +			       const frame_info_ptr &caller_frame,
>  			       iterate_ftype callback) const;
>  
>  private:
> @@ -201,7 +201,7 @@ struct call_site
>       throw NO_ENTRY_VALUE_ERROR.  */
>  
>    void iterate_over_addresses (struct gdbarch *call_site_gdbarch,
> -			       frame_info_ptr caller_frame,
> +			       const frame_info_ptr &caller_frame,
>  			       call_site_target::iterate_ftype callback)
>      const
>    {
> diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
> index 9cfae104f31c..d0256e7009d9 100644
> --- a/gdb/dwarf2/expr.c
> +++ b/gdb/dwarf2/expr.c
> @@ -49,7 +49,7 @@ static const registry<gdbarch>::key<dwarf_gdbarch_types> dwarf_arch_cookie;
>  /* Ensure that a FRAME is defined, throw an exception otherwise.  */
>  
>  static void
> -ensure_have_frame (frame_info_ptr frame, const char *op_name)
> +ensure_have_frame (const frame_info_ptr &frame, const char *op_name)
>  {
>    if (frame == nullptr)
>      throw_error (GENERIC_ERROR,
> @@ -78,7 +78,7 @@ bits_to_bytes (ULONGEST start, ULONGEST n_bits)
>  /* See expr.h.  */
>  
>  CORE_ADDR
> -read_addr_from_reg (frame_info_ptr frame, int reg)
> +read_addr_from_reg (const frame_info_ptr &frame, int reg)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    int regnum = dwarf_reg_to_regnum_or_error (gdbarch, reg);
> @@ -112,7 +112,7 @@ static piece_closure *
>  allocate_piece_closure (dwarf2_per_cu_data *per_cu,
>  			dwarf2_per_objfile *per_objfile,
>  			std::vector<dwarf_expr_piece> &&pieces,
> -			frame_info_ptr frame)
> +			const frame_info_ptr &frame)
>  {
>    piece_closure *c = new piece_closure;
>  
> @@ -1076,7 +1076,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
>  
>  value *
>  dwarf_expr_context::evaluate (const gdb_byte *addr, size_t len, bool as_lval,
> -			      dwarf2_per_cu_data *per_cu, frame_info_ptr frame,
> +			      dwarf2_per_cu_data *per_cu, const frame_info_ptr &frame,
>  			      const struct property_addr_info *addr_info,
>  			      struct type *type, struct type *subobj_type,
>  			      LONGEST subobj_offset)
> diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
> index 6acd07811f85..b02cc5316406 100644
> --- a/gdb/dwarf2/expr.h
> +++ b/gdb/dwarf2/expr.h
> @@ -137,7 +137,7 @@ struct dwarf_expr_context
>       The ADDR_INFO property can be specified to override the range of
>       memory addresses with the passed in buffer.  */
>    value *evaluate (const gdb_byte *addr, size_t len, bool as_lval,
> -		   dwarf2_per_cu_data *per_cu, frame_info_ptr frame,
> +		   dwarf2_per_cu_data *per_cu, const frame_info_ptr &frame,
>  		   const struct property_addr_info *addr_info = nullptr,
>  		   struct type *type = nullptr,
>  		   struct type *subobj_type = nullptr,
> @@ -256,7 +256,7 @@ struct dwarf_expr_context
>  
>  /* Return the value of register number REG (a DWARF register number),
>     read as an address in a given FRAME.  */
> -CORE_ADDR read_addr_from_reg (frame_info_ptr frame, int reg);
> +CORE_ADDR read_addr_from_reg (const frame_info_ptr &frame, int reg);
>  
>  void dwarf_expr_require_composition (const gdb_byte *, const gdb_byte *,
>  				     const char *);
> diff --git a/gdb/dwarf2/frame-tailcall.c b/gdb/dwarf2/frame-tailcall.c
> index 27a820a6168f..2f6400d62c38 100644
> --- a/gdb/dwarf2/frame-tailcall.c
> +++ b/gdb/dwarf2/frame-tailcall.c
> @@ -90,7 +90,7 @@ cache_eq (const void *arg1, const void *arg2)
>     tailcall_cache.  */
>  
>  static struct tailcall_cache *
> -cache_new_ref1 (frame_info_ptr next_bottom_frame)
> +cache_new_ref1 (const frame_info_ptr &next_bottom_frame)
>  {
>    struct tailcall_cache *cache = XCNEW (struct tailcall_cache);
>    void **slot;
> @@ -137,7 +137,7 @@ cache_unref (struct tailcall_cache *cache)
>     return 0.  */
>  
>  static int
> -frame_is_tailcall (frame_info_ptr fi)
> +frame_is_tailcall (const frame_info_ptr &fi)
>  {
>    return frame_unwinder_is (fi, &dwarf2_tailcall_frame_unwind);
>  }
> @@ -146,12 +146,13 @@ frame_is_tailcall (frame_info_ptr fi)
>     call chain.  Otherwise return NULL.  No new reference is created.  */
>  
>  static struct tailcall_cache *
> -cache_find (frame_info_ptr fi)
> +cache_find (const frame_info_ptr &initial_fi)
>  {
>    struct tailcall_cache *cache;
>    struct tailcall_cache search;
>    void **slot;
>  
> +  frame_info_ptr fi = initial_fi;
>    while (frame_is_tailcall (fi))
>      {
>        fi = get_next_frame (fi);
> @@ -173,7 +174,7 @@ cache_find (frame_info_ptr fi)
>     If THIS_FRAME is CACHE-> NEXT_BOTTOM_FRAME return -1.  */
>  
>  static int
> -existing_next_levels (frame_info_ptr this_frame,
> +existing_next_levels (const frame_info_ptr &this_frame,
>  		      struct tailcall_cache *cache)
>  {
>    int retval = (frame_relative_level (this_frame)
> @@ -210,7 +211,7 @@ pretended_chain_levels (struct call_site_chain *chain)
>     Specific virtual tail call frames are tracked by INLINE_DEPTH.  */
>  
>  static void
> -tailcall_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +tailcall_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			struct frame_id *this_id)
>  {
>    struct tailcall_cache *cache = (struct tailcall_cache *) *this_cache;
> @@ -232,7 +233,7 @@ tailcall_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>     CACHE.  */
>  
>  static CORE_ADDR
> -pretend_pc (frame_info_ptr this_frame, struct tailcall_cache *cache)
> +pretend_pc (const frame_info_ptr &this_frame, struct tailcall_cache *cache)
>  {
>    int next_levels = existing_next_levels (this_frame, cache);
>    struct call_site_chain *chain = cache->chain;
> @@ -264,7 +265,7 @@ pretend_pc (frame_info_ptr this_frame, struct tailcall_cache *cache)
>     frames unwind the NULL case differently.  */
>  
>  struct value *
> -dwarf2_tailcall_prev_register_first (frame_info_ptr this_frame,
> +dwarf2_tailcall_prev_register_first (const frame_info_ptr &this_frame,
>  				     void **tailcall_cachep, int regnum)
>  {
>    struct gdbarch *this_gdbarch = get_frame_arch (this_frame);
> @@ -294,7 +295,7 @@ dwarf2_tailcall_prev_register_first (frame_info_ptr this_frame,
>     dwarf2_tailcall_prev_register_first.  */
>  
>  static struct value *
> -tailcall_frame_prev_register (frame_info_ptr this_frame,
> +tailcall_frame_prev_register (const frame_info_ptr &this_frame,
>  			       void **this_cache, int regnum)
>  {
>    struct tailcall_cache *cache = (struct tailcall_cache *) *this_cache;
> @@ -316,7 +317,7 @@ tailcall_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  tailcall_frame_sniffer (const struct frame_unwind *self,
> -			 frame_info_ptr this_frame, void **this_cache)
> +			 const frame_info_ptr &this_frame, void **this_cache)
>  {
>    frame_info_ptr next_frame;
>    int next_levels;
> @@ -363,7 +364,7 @@ tailcall_frame_sniffer (const struct frame_unwind *self,
>     address pushed on the stack.  */
>  
>  void
> -dwarf2_tailcall_sniffer_first (frame_info_ptr this_frame,
> +dwarf2_tailcall_sniffer_first (const frame_info_ptr &this_frame,
>  			       void **tailcall_cachep,
>  			       const LONGEST *entry_cfa_sp_offsetp)
>  {
> @@ -458,7 +459,7 @@ tailcall_frame_dealloc_cache (frame_info *self, void *this_cache)
>     call frames have gdbarch of the bottom (callee) frame.  */
>  
>  static struct gdbarch *
> -tailcall_frame_prev_arch (frame_info_ptr this_frame,
> +tailcall_frame_prev_arch (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache)
>  {
>    struct tailcall_cache *cache = (struct tailcall_cache *) *this_prologue_cache;
> diff --git a/gdb/dwarf2/frame-tailcall.h b/gdb/dwarf2/frame-tailcall.h
> index b0809c8b7131..3f49487ac2a7 100644
> --- a/gdb/dwarf2/frame-tailcall.h
> +++ b/gdb/dwarf2/frame-tailcall.h
> @@ -26,12 +26,12 @@ struct frame_unwind;
>  /* The tail call frame unwinder.  */
>  
>  extern void
> -  dwarf2_tailcall_sniffer_first (frame_info_ptr this_frame,
> +  dwarf2_tailcall_sniffer_first (const frame_info_ptr &this_frame,
>  				 void **tailcall_cachep,
>  				 const LONGEST *entry_cfa_sp_offsetp);
>  
>  extern struct value *
> -  dwarf2_tailcall_prev_register_first (frame_info_ptr this_frame,
> +  dwarf2_tailcall_prev_register_first (const frame_info_ptr &this_frame,
>  				       void **tailcall_cachep, int regnum);
>  
>  extern const struct frame_unwind dwarf2_tailcall_frame_unwind;
> diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
> index fc6704f434ee..530513c2684e 100644
> --- a/gdb/dwarf2/frame.c
> +++ b/gdb/dwarf2/frame.c
> @@ -233,7 +233,7 @@ register %s (#%d) at %s"),
>  
>  static CORE_ADDR
>  execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size,
> -		  frame_info_ptr this_frame, CORE_ADDR initial,
> +		  const frame_info_ptr &this_frame, CORE_ADDR initial,
>  		  int initial_in_stack_memory, dwarf2_per_objfile *per_objfile)
>  {
>    dwarf_expr_context ctx (per_objfile, addr_size);
> @@ -589,17 +589,17 @@ execute_cfa_program_test (struct gdbarch *gdbarch)
>  static void dwarf2_frame_default_init_reg (struct gdbarch *gdbarch,
>  					   int regnum,
>  					   struct dwarf2_frame_state_reg *reg,
> -					   frame_info_ptr this_frame);
> +					   const frame_info_ptr &this_frame);
>  
>  struct dwarf2_frame_ops
>  {
>    /* Pre-initialize the register state REG for register REGNUM.  */
>    void (*init_reg) (struct gdbarch *, int, struct dwarf2_frame_state_reg *,
> -		    frame_info_ptr)
> +		    const frame_info_ptr &)
>      = dwarf2_frame_default_init_reg;
>  
>    /* Check whether the THIS_FRAME is a signal trampoline.  */
> -  int (*signal_frame_p) (struct gdbarch *, frame_info_ptr) = nullptr;
> +  int (*signal_frame_p) (struct gdbarch *, const frame_info_ptr &) = nullptr;
>  
>    /* Convert .eh_frame register number to DWARF register number, or
>       adjust .debug_frame register number.  */
> @@ -625,7 +625,7 @@ get_frame_ops (struct gdbarch *gdbarch)
>  static void
>  dwarf2_frame_default_init_reg (struct gdbarch *gdbarch, int regnum,
>  			       struct dwarf2_frame_state_reg *reg,
> -			       frame_info_ptr this_frame)
> +			       const frame_info_ptr &this_frame)
>  {
>    /* If we have a register that acts as a program counter, mark it as
>       a destination for the return address.  If we have a register that
> @@ -666,7 +666,7 @@ void
>  dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
>  			   void (*init_reg) (struct gdbarch *, int,
>  					     struct dwarf2_frame_state_reg *,
> -					     frame_info_ptr))
> +					     const frame_info_ptr &))
>  {
>    struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
>  
> @@ -678,7 +678,7 @@ dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
>  static void
>  dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  		       struct dwarf2_frame_state_reg *reg,
> -		       frame_info_ptr this_frame)
> +		       const frame_info_ptr &this_frame)
>  {
>    struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
>  
> @@ -691,7 +691,7 @@ dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  void
>  dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
>  				 int (*signal_frame_p) (struct gdbarch *,
> -							frame_info_ptr))
> +							const frame_info_ptr &))
>  {
>    struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
>  
> @@ -703,7 +703,7 @@ dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
>  
>  static int
>  dwarf2_frame_signal_frame_p (struct gdbarch *gdbarch,
> -			     frame_info_ptr this_frame)
> +			     const frame_info_ptr &this_frame)
>  {
>    struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
>  
> @@ -890,7 +890,7 @@ struct dwarf2_frame_cache
>  };
>  
>  static struct dwarf2_frame_cache *
> -dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +dwarf2_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    const int num_regs = gdbarch_num_cooked_regs (gdbarch);
> @@ -1120,7 +1120,7 @@ incomplete CFI data; unspecified registers (e.g., %s) at %s"),
>  }
>  
>  static enum unwind_stop_reason
> -dwarf2_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +dwarf2_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  				 void **this_cache)
>  {
>    struct dwarf2_frame_cache *cache
> @@ -1136,7 +1136,7 @@ dwarf2_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  }
>  
>  static void
> -dwarf2_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +dwarf2_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		      struct frame_id *this_id)
>  {
>    struct dwarf2_frame_cache *cache =
> @@ -1151,7 +1151,7 @@ dwarf2_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -dwarf2_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +dwarf2_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			    int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1253,7 +1253,7 @@ dwarf2_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
>  /* See frame.h.  */
>  
>  void *
> -dwarf2_frame_get_fn_data (frame_info_ptr this_frame, void **this_cache,
> +dwarf2_frame_get_fn_data (const frame_info_ptr &this_frame, void **this_cache,
>  			  fn_prev_register cookie)
>  {
>    struct dwarf2_frame_fn_data *fn_data = nullptr;
> @@ -1271,7 +1271,7 @@ dwarf2_frame_get_fn_data (frame_info_ptr this_frame, void **this_cache,
>  /* See frame.h.  */
>  
>  void *
> -dwarf2_frame_allocate_fn_data (frame_info_ptr this_frame, void **this_cache,
> +dwarf2_frame_allocate_fn_data (const frame_info_ptr &this_frame, void **this_cache,
>  			       fn_prev_register cookie, unsigned long size)
>  {
>    struct dwarf2_frame_fn_data *fn_data = nullptr;
> @@ -1307,7 +1307,7 @@ dwarf2_frame_dealloc_cache (frame_info *self, void *this_cache)
>  
>  static int
>  dwarf2_frame_sniffer (const struct frame_unwind *self,
> -		      frame_info_ptr this_frame, void **this_cache)
> +		      const frame_info_ptr &this_frame, void **this_cache)
>  {
>    if (!dwarf2_frame_unwinders_enabled_p)
>      return 0;
> @@ -1383,7 +1383,7 @@ dwarf2_append_unwinders (struct gdbarch *gdbarch)
>     response to the "info frame" command.  */
>  
>  static CORE_ADDR
> -dwarf2_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +dwarf2_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct dwarf2_frame_cache *cache =
>      dwarf2_frame_cache (this_frame, this_cache);
> @@ -1400,7 +1400,7 @@ static const struct frame_base dwarf2_frame_base =
>  };
>  
>  const struct frame_base *
> -dwarf2_frame_base_sniffer (frame_info_ptr this_frame)
> +dwarf2_frame_base_sniffer (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR block_addr = get_frame_address_in_block (this_frame);
>  
> @@ -1415,8 +1415,10 @@ dwarf2_frame_base_sniffer (frame_info_ptr this_frame)
>     DW_OP_call_frame_cfa.  */
>  
>  CORE_ADDR
> -dwarf2_frame_cfa (frame_info_ptr this_frame)
> +dwarf2_frame_cfa (const frame_info_ptr &initial_this_frame)
>  {
> +  frame_info_ptr this_frame = initial_this_frame;
> +
>    if (frame_unwinder_is (this_frame, &record_btrace_tailcall_frame_unwind)
>        || frame_unwinder_is (this_frame, &record_btrace_frame_unwind))
>      throw_error (NOT_AVAILABLE_ERROR,
> diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h
> index 1ef35ee29482..2167310fbdf0 100644
> --- a/gdb/dwarf2/frame.h
> +++ b/gdb/dwarf2/frame.h
> @@ -66,7 +66,7 @@ enum dwarf2_frame_reg_rule
>  
>  /* Register state.  */
>  
> -typedef struct value *(*fn_prev_register) (frame_info_ptr this_frame,
> +typedef struct value *(*fn_prev_register) (const frame_info_ptr &this_frame,
>  					   void **this_cache, int regnum);
>  
>  struct dwarf2_frame_state_reg
> @@ -207,18 +207,17 @@ extern bool dwarf2_frame_unwinders_enabled_p;
>  /* Set the architecture-specific register state initialization
>     function for GDBARCH to INIT_REG.  */
>  
> -extern void dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
> -				       void (*init_reg) (struct gdbarch *, int,
> -					     struct dwarf2_frame_state_reg *,
> -					     frame_info_ptr));
> +extern void dwarf2_frame_set_init_reg (
> +  gdbarch *gdbarch, void (*init_reg) (struct gdbarch *, int,
> +				      dwarf2_frame_state_reg *,
> +				      const frame_info_ptr &));
>  
>  /* Set the architecture-specific signal trampoline recognition
>     function for GDBARCH to SIGNAL_FRAME_P.  */
>  
> -extern void
> -  dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
> -				   int (*signal_frame_p) (struct gdbarch *,
> -							  frame_info_ptr));
> +extern void dwarf2_frame_set_signal_frame_p
> +  (gdbarch *gdbarch, int (*signal_frame_p) (struct gdbarch *,
> +			  const frame_info_ptr &));
>  
>  /* Set the architecture-specific adjustment of .eh_frame and .debug_frame
>     register numbers.  */
> @@ -236,11 +235,11 @@ void dwarf2_append_unwinders (struct gdbarch *gdbarch);
>     NULL if it can't be handled by the DWARF CFI frame unwinder.  */
>  
>  extern const struct frame_base *
> -  dwarf2_frame_base_sniffer (frame_info_ptr this_frame);
> +  dwarf2_frame_base_sniffer (const frame_info_ptr &this_frame);
>  
>  /* Compute the DWARF CFA for a frame.  */
>  
> -CORE_ADDR dwarf2_frame_cfa (frame_info_ptr this_frame);
> +CORE_ADDR dwarf2_frame_cfa (const frame_info_ptr &this_frame);
>  
>  /* Find the CFA information for PC.
>  
> @@ -276,7 +275,7 @@ extern int dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
>     COOKIE is the key for the prev_function implementation.
>     SIZE is the size of the custom data object to allocate.  */
>  
> -extern void *dwarf2_frame_allocate_fn_data (frame_info_ptr this_frame,
> +extern void *dwarf2_frame_allocate_fn_data (const frame_info_ptr &this_frame,
>  					    void **this_cache,
>  					    fn_prev_register cookie,
>  					    unsigned long size);
> @@ -291,7 +290,7 @@ extern void *dwarf2_frame_allocate_fn_data (frame_info_ptr this_frame,
>     THIS_CACHE is the dwarf2 cache object to store the pointer on.
>     COOKIE is the key for the prev_function implementation.  */
>  
> -extern void *dwarf2_frame_get_fn_data (frame_info_ptr this_frame,
> +extern void *dwarf2_frame_get_fn_data (const frame_info_ptr &this_frame,
>  				       void **this_cache,
>  				       fn_prev_register cookie);
>  
> diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
> index 0f0d14fad3ff..203ad536162a 100644
> --- a/gdb/dwarf2/loc.c
> +++ b/gdb/dwarf2/loc.c
> @@ -48,7 +48,7 @@
>  #include "gdbsupport/byte-vector.h"
>  
>  static struct value *dwarf2_evaluate_loc_desc_full
> -  (struct type *type, frame_info_ptr frame, const gdb_byte *data,
> +  (struct type *type, const frame_info_ptr &frame, const gdb_byte *data,
>     size_t size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile,
>     struct type *subobj_type, LONGEST subobj_byte_offset, bool as_lval = true);
>  
> @@ -503,7 +503,7 @@ locexpr_find_frame_base_location (struct symbol *framefunc, CORE_ADDR pc,
>     LOC_BLOCK functions using a DWARF expression as its DW_AT_frame_base.  */
>  
>  static CORE_ADDR
> -locexpr_get_frame_base (struct symbol *framefunc, frame_info_ptr frame)
> +locexpr_get_frame_base (struct symbol *framefunc, const frame_info_ptr &frame)
>  {
>    struct gdbarch *gdbarch;
>    struct type *type;
> @@ -561,7 +561,7 @@ loclist_find_frame_base_location (struct symbol *framefunc, CORE_ADDR pc,
>     LOC_BLOCK functions using a DWARF location list as its DW_AT_frame_base.  */
>  
>  static CORE_ADDR
> -loclist_get_frame_base (struct symbol *framefunc, frame_info_ptr frame)
> +loclist_get_frame_base (struct symbol *framefunc, const frame_info_ptr &frame)
>  {
>    struct gdbarch *gdbarch;
>    struct type *type;
> @@ -649,11 +649,10 @@ show_entry_values_debug (struct ui_file *file, int from_tty,
>  /* See gdbtypes.h.  */
>  
>  void
> -call_site_target::iterate_over_addresses
> -     (struct gdbarch *call_site_gdbarch,
> -      const struct call_site *call_site,
> -      frame_info_ptr caller_frame,
> -      iterate_ftype callback) const
> +call_site_target::iterate_over_addresses (gdbarch *call_site_gdbarch,
> +					  const call_site *call_site,
> +					  const frame_info_ptr &caller_frame,
> +					  iterate_ftype callback) const
>  {
>    switch (m_loc_kind)
>      {
> @@ -1138,9 +1137,9 @@ call_site_parameter_matches (struct call_site_parameter *parameter,
>  /* See loc.h.  */
>  
>  struct call_site_parameter *
> -dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame,
> -				   enum call_site_parameter_kind kind,
> -				   union call_site_parameter_u kind_u,
> +dwarf_expr_reg_to_entry_parameter (const frame_info_ptr &initial_frame,
> +				   call_site_parameter_kind kind,
> +				   call_site_parameter_u kind_u,
>  				   dwarf2_per_cu_data **per_cu_return,
>  				   dwarf2_per_objfile **per_objfile_return)
>  {
> @@ -1152,6 +1151,7 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame,
>    /* Initialize it just to avoid a GCC false warning.  */
>    struct call_site_parameter *parameter = NULL;
>    CORE_ADDR target_addr;
> +  frame_info_ptr frame = initial_frame;
>  
>    while (get_frame_type (frame) == INLINE_FRAME)
>      {
> @@ -1263,7 +1263,7 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame,
>  static struct value *
>  dwarf_entry_parameter_to_value (struct call_site_parameter *parameter,
>  				CORE_ADDR deref_size, struct type *type,
> -				frame_info_ptr caller_frame,
> +				const frame_info_ptr &caller_frame,
>  				dwarf2_per_cu_data *per_cu,
>  				dwarf2_per_objfile *per_objfile)
>  {
> @@ -1339,7 +1339,7 @@ static const struct lval_funcs entry_data_value_funcs =
>  
>  /* See dwarf2/loc.h.  */
>  struct value *
> -value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame,
> +value_of_dwarf_reg_entry (struct type *type, const frame_info_ptr &frame,
>  			  enum call_site_parameter_kind kind,
>  			  union call_site_parameter_u kind_u)
>  {
> @@ -1395,7 +1395,7 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame,
>     cannot resolve the parameter for any reason.  */
>  
>  static struct value *
> -value_of_dwarf_block_entry (struct type *type, frame_info_ptr frame,
> +value_of_dwarf_block_entry (struct type *type, const frame_info_ptr &frame,
>  			    const gdb_byte *block, size_t block_len)
>  {
>    union call_site_parameter_u kind_u;
> @@ -1456,7 +1456,7 @@ struct value *
>  indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset,
>  			    dwarf2_per_cu_data *per_cu,
>  			    dwarf2_per_objfile *per_objfile,
> -			    frame_info_ptr frame, struct type *type,
> +			    const frame_info_ptr &frame, struct type *type,
>  			    bool resolve_abstract_p)
>  {
>    /* Fetch the location expression of the DIE we're pointing to.  */
> @@ -1496,7 +1496,7 @@ indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset,
>     SUBOBJ_BYTE_OFFSET within the variable of type TYPE.  */
>  
>  static struct value *
> -dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
> +dwarf2_evaluate_loc_desc_full (struct type *type, const frame_info_ptr &frame,
>  			       const gdb_byte *data, size_t size,
>  			       dwarf2_per_cu_data *per_cu,
>  			       dwarf2_per_objfile *per_objfile,
> @@ -1561,7 +1561,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
>     passes 0 as the byte_offset.  */
>  
>  struct value *
> -dwarf2_evaluate_loc_desc (struct type *type, frame_info_ptr frame,
> +dwarf2_evaluate_loc_desc (struct type *type, const frame_info_ptr &frame,
>  			  const gdb_byte *data, size_t size,
>  			  dwarf2_per_cu_data *per_cu,
>  			  dwarf2_per_objfile *per_objfile, bool as_lval)
> @@ -1584,7 +1584,7 @@ dwarf2_evaluate_loc_desc (struct type *type, frame_info_ptr frame,
>  
>  static int
>  dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
> -			   frame_info_ptr frame,
> +			   const frame_info_ptr &frame,
>  			   const struct property_addr_info *addr_stack,
>  			   CORE_ADDR *valp,
>  			   gdb::array_view<CORE_ADDR> push_values,
> @@ -1644,9 +1644,9 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
>  /* See dwarf2/loc.h.  */
>  
>  bool
> -dwarf2_evaluate_property (const struct dynamic_prop *prop,
> -			  frame_info_ptr frame,
> -			  const struct property_addr_info *addr_stack,
> +dwarf2_evaluate_property (const dynamic_prop *prop,
> +			  const frame_info_ptr &initial_frame,
> +			  const property_addr_info *addr_stack,
>  			  CORE_ADDR *value,
>  			  gdb::array_view<CORE_ADDR> push_values)
>  {
> @@ -1657,6 +1657,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
>       Without this here this could happen if the code below selects a
>       frame.  */
>    scoped_restore_current_language save_language;
> +  frame_info_ptr frame = initial_frame;
>  
>    if (frame == NULL && has_stack_frames ())
>      frame = get_selected_frame (NULL);
> @@ -3051,7 +3052,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
>  /* Return the value of SYMBOL in FRAME using the DWARF-2 expression
>     evaluator to calculate the location.  */
>  static struct value *
> -locexpr_read_variable (struct symbol *symbol, frame_info_ptr frame)
> +locexpr_read_variable (struct symbol *symbol, const frame_info_ptr &frame)
>  {
>    struct dwarf2_locexpr_baton *dlbaton
>      = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
> @@ -3069,7 +3070,7 @@ locexpr_read_variable (struct symbol *symbol, frame_info_ptr frame)
>     will be thrown.  */
>  
>  static struct value *
> -locexpr_read_variable_at_entry (struct symbol *symbol, frame_info_ptr frame)
> +locexpr_read_variable_at_entry (struct symbol *symbol, const frame_info_ptr &frame)
>  {
>    struct dwarf2_locexpr_baton *dlbaton
>      = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
> @@ -3884,7 +3885,7 @@ const struct symbol_computed_ops dwarf2_locexpr_funcs = {
>  /* Return the value of SYMBOL in FRAME using the DWARF-2 expression
>     evaluator to calculate the location.  */
>  static struct value *
> -loclist_read_variable (struct symbol *symbol, frame_info_ptr frame)
> +loclist_read_variable (struct symbol *symbol, const frame_info_ptr &frame)
>  {
>    struct dwarf2_loclist_baton *dlbaton
>      = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol);
> @@ -3909,7 +3910,7 @@ loclist_read_variable (struct symbol *symbol, frame_info_ptr frame)
>     if it cannot resolve the parameter for any reason.  */
>  
>  static struct value *
> -loclist_read_variable_at_entry (struct symbol *symbol, frame_info_ptr frame)
> +loclist_read_variable_at_entry (struct symbol *symbol, const frame_info_ptr &frame)
>  {
>    struct dwarf2_loclist_baton *dlbaton
>      = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol);
> diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h
> index fb98e26b72db..4fb743618e7c 100644
> --- a/gdb/dwarf2/loc.h
> +++ b/gdb/dwarf2/loc.h
> @@ -65,9 +65,9 @@ value *compute_var_value (const char *name);
>     Function always returns non-NULL, it throws NO_ENTRY_VALUE_ERROR
>     otherwise.  */
>  
> -struct call_site_parameter *dwarf_expr_reg_to_entry_parameter
> -  (frame_info_ptr frame, enum call_site_parameter_kind kind,
> -   union call_site_parameter_u kind_u, dwarf2_per_cu_data **per_cu_return,
> +call_site_parameter *dwarf_expr_reg_to_entry_parameter
> +  (const frame_info_ptr &frame, call_site_parameter_kind kind,
> +   call_site_parameter_u kind_u, dwarf2_per_cu_data **per_cu_return,
>     dwarf2_per_objfile **per_objfile_return);
>  
>  
> @@ -76,13 +76,11 @@ struct call_site_parameter *dwarf_expr_reg_to_entry_parameter
>     of FRAME.  AS_LVAL defines if the resulting struct value is expected to
>     be a value or a location description.  */
>  
> -struct value *dwarf2_evaluate_loc_desc (struct type *type,
> -					frame_info_ptr frame,
> -					const gdb_byte *data,
> -					size_t size,
> -					dwarf2_per_cu_data *per_cu,
> -					dwarf2_per_objfile *per_objfile,
> -					bool as_lval = true);
> +value *dwarf2_evaluate_loc_desc (type *type, const frame_info_ptr &frame,
> +				 const gdb_byte *data, size_t size,
> +				 dwarf2_per_cu_data *per_cu,
> +				 dwarf2_per_objfile *per_objfile,
> +				 bool as_lval = true);
>  
>  /* A chain of addresses that might be needed to resolve a dynamic
>     property.  */
> @@ -121,8 +119,8 @@ struct property_addr_info
>     bottom of the stack.  */
>  
>  bool dwarf2_evaluate_property (const struct dynamic_prop *prop,
> -			       frame_info_ptr frame,
> -			       const struct property_addr_info *addr_stack,
> +			       const frame_info_ptr &frame,
> +			       const property_addr_info *addr_stack,
>  			       CORE_ADDR *value,
>  			       gdb::array_view<CORE_ADDR> push_values = {});
>  
> @@ -296,7 +294,7 @@ extern void invalid_synthetic_pointer ();
>  
>  extern struct value *indirect_synthetic_pointer
>    (sect_offset die, LONGEST byte_offset, dwarf2_per_cu_data *per_cu,
> -   dwarf2_per_objfile *per_objfile, frame_info_ptr frame,
> +   dwarf2_per_objfile *per_objfile, const frame_info_ptr &frame,
>     struct type *type, bool resolve_abstract_p = false);
>  
>  /* Read parameter of TYPE at (callee) FRAME's function entry.  KIND and KIND_U
> @@ -307,7 +305,7 @@ extern struct value *indirect_synthetic_pointer
>     it cannot resolve the parameter for any reason.  */
>  
>  extern struct value *value_of_dwarf_reg_entry (struct type *type,
> -					       struct frame_info_ptr frame,
> +					       const frame_info_ptr &frame,
>  					       enum call_site_parameter_kind kind,
>  					       union call_site_parameter_u kind_u);
>  #endif /* DWARF2LOC_H */
> diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
> index 4eece07ac12f..b709494927d4 100644
> --- a/gdb/extension-priv.h
> +++ b/gdb/extension-priv.h
> @@ -180,7 +180,7 @@ struct extension_language_ops
>       or SCR_BT_COMPLETED on success.  */
>    enum ext_lang_bt_status (*apply_frame_filter)
>      (const struct extension_language_defn *,
> -     frame_info_ptr frame, frame_filter_flags flags,
> +     const frame_info_ptr &frame, frame_filter_flags flags,
>       enum ext_lang_frame_args args_type,
>       struct ui_out *out, int frame_low, int frame_high);
>  
> diff --git a/gdb/extension.c b/gdb/extension.c
> index 2555161c2a79..42e05199d2c8 100644
> --- a/gdb/extension.c
> +++ b/gdb/extension.c
> @@ -525,7 +525,7 @@ apply_ext_lang_val_pretty_printer (struct value *val,
>     rather than trying filters in other extension languages.  */
>  
>  enum ext_lang_bt_status
> -apply_ext_lang_frame_filter (frame_info_ptr frame,
> +apply_ext_lang_frame_filter (const frame_info_ptr &frame,
>  			     frame_filter_flags flags,
>  			     enum ext_lang_frame_args args_type,
>  			     struct ui_out *out,
> diff --git a/gdb/extension.h b/gdb/extension.h
> index 6dc19c36fc2a..0514d7930a22 100644
> --- a/gdb/extension.h
> +++ b/gdb/extension.h
> @@ -295,7 +295,7 @@ extern int apply_ext_lang_val_pretty_printer
>     const struct language_defn *language);
>  
>  extern enum ext_lang_bt_status apply_ext_lang_frame_filter
> -  (frame_info_ptr frame, frame_filter_flags flags,
> +  (const frame_info_ptr &frame, frame_filter_flags flags,
>     enum ext_lang_frame_args args_type,
>     struct ui_out *out, int frame_low, int frame_high);
>  
> diff --git a/gdb/findvar.c b/gdb/findvar.c
> index 2fcfccda1c7a..516a2ca044cc 100644
> --- a/gdb/findvar.c
> +++ b/gdb/findvar.c
> @@ -246,7 +246,7 @@ copy_integer_to_size (gdb_byte *dest, int dest_size, const gdb_byte *source,
>  /* See value.h.  */
>  
>  value *
> -value_of_register (int regnum, frame_info_ptr next_frame)
> +value_of_register (int regnum, const frame_info_ptr &next_frame)
>  {
>    gdbarch *gdbarch = frame_unwind_arch (next_frame);
>  
> @@ -263,7 +263,7 @@ value_of_register (int regnum, frame_info_ptr next_frame)
>  /* See value.h.  */
>  
>  value *
> -value_of_register_lazy (frame_info_ptr next_frame, int regnum)
> +value_of_register_lazy (const frame_info_ptr &next_frame, int regnum)
>  {
>    gdbarch *gdbarch = frame_unwind_arch (next_frame);
>  
> @@ -377,7 +377,7 @@ symbol_read_needs_frame (struct symbol *sym)
>  
>  static frame_info_ptr
>  get_hosting_frame (struct symbol *var, const struct block *var_block,
> -		   frame_info_ptr frame)
> +		   const frame_info_ptr &initial_frame)
>  {
>    const struct block *frame_block = NULL;
>  
> @@ -389,7 +389,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
>       synthetic symbols.  Without block information, we must assume they are
>       local to FRAME. In this case, there is nothing to do.  */
>    else if (var_block == NULL)
> -    return frame;
> +    return initial_frame;
>  
>    /* We currently assume that all symbols with a location list need a frame.
>       This is true in practice because selecting the location description
> @@ -398,15 +398,16 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
>       We want to get <optimized out> instead of <frame required> when evaluating
>       them so return a frame instead of raising an error.  */
>    else if (var_block->is_global_block () || var_block->is_static_block ())
> -    return frame;
> +    return initial_frame;
>  
>    /* We have to handle the "my_func::my_local_var" notation.  This requires us
>       to look for upper frames when we find no block for the current frame: here
>       and below, handle when frame_block == NULL.  */
> -  if (frame != NULL)
> -    frame_block = get_frame_block (frame, NULL);
> +  if (initial_frame != nullptr)
> +    frame_block = get_frame_block (initial_frame, NULL);
>  
>    /* Climb up the call stack until reaching the frame we are looking for.  */
> +  frame_info_ptr frame = initial_frame;
>    while (frame != NULL && frame_block != var_block)
>      {
>        /* Stacks can be quite deep: give the user a chance to stop this.  */
> @@ -476,12 +477,13 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
>  struct value *
>  language_defn::read_var_value (struct symbol *var,
>  			       const struct block *var_block,
> -			       frame_info_ptr frame) const
> +			       const frame_info_ptr &frame_param) const
>  {
>    struct value *v;
>    struct type *type = var->type ();
>    CORE_ADDR addr;
>    enum symbol_needs_kind sym_need;
> +  frame_info_ptr frame = frame_param;
>  
>    /* Call check_typedef on our type to make sure that, if TYPE is
>       a TYPE_CODE_TYPEDEF, its length is set to the length of the target type
> @@ -704,7 +706,7 @@ language_defn::read_var_value (struct symbol *var,
>  
>  struct value *
>  read_var_value (struct symbol *var, const struct block *var_block,
> -		frame_info_ptr frame)
> +		const frame_info_ptr &frame)
>  {
>    const struct language_defn *lang = language_def (var->language ());
>  
> @@ -789,7 +791,7 @@ read_frame_register_value (value *value)
>  /* Return a value of type TYPE, stored in register REGNUM, in frame FRAME.  */
>  
>  struct value *
> -value_from_register (struct type *type, int regnum, frame_info_ptr frame)
> +value_from_register (struct type *type, int regnum, const frame_info_ptr &frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    struct type *type1 = check_typedef (type);
> @@ -836,7 +838,7 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame)
>     Will abort if register value is not available.  */
>  
>  CORE_ADDR
> -address_from_register (int regnum, frame_info_ptr frame)
> +address_from_register (int regnum, const frame_info_ptr &frame)
>  {
>    type *type = builtin_type (get_frame_arch (frame))->builtin_data_ptr;
>    value_ref_ptr v = release_value (value_from_register (type, regnum, frame));
> diff --git a/gdb/frame-base.c b/gdb/frame-base.c
> index 9dd04eefa5b3..fda19b57bacb 100644
> --- a/gdb/frame-base.c
> +++ b/gdb/frame-base.c
> @@ -29,19 +29,19 @@
>     really need to override this.  */
>  
>  static CORE_ADDR
> -default_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +default_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    return get_frame_base (this_frame); /* sigh! */
>  }
>  
>  static CORE_ADDR
> -default_frame_locals_address (frame_info_ptr this_frame, void **this_cache)
> +default_frame_locals_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    return default_frame_base_address (this_frame, this_cache);
>  }
>  
>  static CORE_ADDR
> -default_frame_args_address (frame_info_ptr this_frame, void **this_cache)
> +default_frame_args_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    return default_frame_base_address (this_frame, this_cache);
>  }
> @@ -99,7 +99,7 @@ frame_base_set_default (struct gdbarch *gdbarch,
>  }
>  
>  const struct frame_base *
> -frame_base_find_by_frame (frame_info_ptr this_frame)
> +frame_base_find_by_frame (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct frame_base_table *table = get_frame_base_table (gdbarch);
> diff --git a/gdb/frame-base.h b/gdb/frame-base.h
> index 9ca948114665..ae22431d5ef1 100644
> --- a/gdb/frame-base.h
> +++ b/gdb/frame-base.h
> @@ -42,17 +42,17 @@ struct regcache;
>  
>  /* A generic base address.  */
>  
> -typedef CORE_ADDR (frame_this_base_ftype) (frame_info_ptr this_frame,
> +typedef CORE_ADDR (frame_this_base_ftype) (const frame_info_ptr &this_frame,
>  					   void **this_base_cache);
>  
>  /* The base address of the frame's local variables.  */
>  
> -typedef CORE_ADDR (frame_this_locals_ftype) (frame_info_ptr this_frame,
> +typedef CORE_ADDR (frame_this_locals_ftype) (const frame_info_ptr &this_frame,
>  					     void **this_base_cache);
>  
>  /* The base address of the frame's arguments / parameters.  */
>  
> -typedef CORE_ADDR (frame_this_args_ftype) (frame_info_ptr this_frame,
> +typedef CORE_ADDR (frame_this_args_ftype) (const frame_info_ptr &this_frame,
>  					   void **this_base_cache);
>  
>  struct frame_base
> @@ -68,7 +68,7 @@ struct frame_base
>  /* Given THIS frame, return the frame base methods for THIS frame,
>     or NULL if it can't handle THIS frame.  */
>  
> -typedef const struct frame_base *(frame_base_sniffer_ftype) (frame_info_ptr this_frame);
> +typedef const struct frame_base *(frame_base_sniffer_ftype) (const frame_info_ptr &this_frame);
>  
>  /* Append a frame base sniffer to the list.  The sniffers are polled
>     in the order that they are appended.  */
> @@ -86,6 +86,6 @@ extern void frame_base_set_default (struct gdbarch *gdbarch,
>  /* Iterate through the list of frame base handlers until one returns
>     an implementation.  */
>  
> -extern const struct frame_base *frame_base_find_by_frame (frame_info_ptr this_frame);
> +extern const struct frame_base *frame_base_find_by_frame (const frame_info_ptr &this_frame);
>  
>  #endif
> diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
> index 27aa9e10677d..e9983a9fd74f 100644
> --- a/gdb/frame-unwind.c
> +++ b/gdb/frame-unwind.c
> @@ -123,7 +123,7 @@ frame_unwind_append_unwinder (struct gdbarch *gdbarch,
>     unchanged and returns 0.  */
>  
>  static int
> -frame_unwind_try_unwinder (frame_info_ptr this_frame, void **this_cache,
> +frame_unwind_try_unwinder (const frame_info_ptr &this_frame, void **this_cache,
>  			  const struct frame_unwind *unwinder)
>  {
>    int res = 0;
> @@ -183,7 +183,7 @@ frame_unwind_try_unwinder (frame_info_ptr this_frame, void **this_cache,
>     by this function.  Possibly initialize THIS_CACHE.  */
>  
>  void
> -frame_unwind_find_by_frame (frame_info_ptr this_frame, void **this_cache)
> +frame_unwind_find_by_frame (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    FRAME_SCOPED_DEBUG_ENTER_EXIT;
>    frame_debug_printf ("this_frame=%d", frame_relative_level (this_frame));
> @@ -217,7 +217,7 @@ frame_unwind_find_by_frame (frame_info_ptr this_frame, void **this_cache)
>  
>  int
>  default_frame_sniffer (const struct frame_unwind *self,
> -		       frame_info_ptr this_frame,
> +		       const frame_info_ptr &this_frame,
>  		       void **this_prologue_cache)
>  {
>    return 1;
> @@ -226,7 +226,7 @@ default_frame_sniffer (const struct frame_unwind *self,
>  /* The default frame unwinder stop_reason callback.  */
>  
>  enum unwind_stop_reason
> -default_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +default_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  				  void **this_cache)
>  {
>    struct frame_id this_id = get_frame_id (this_frame);
> @@ -240,7 +240,7 @@ default_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  /* See frame-unwind.h.  */
>  
>  CORE_ADDR
> -default_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +default_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    int pc_regnum = gdbarch_pc_regnum (gdbarch);
>    CORE_ADDR pc = frame_unwind_register_unsigned (next_frame, pc_regnum);
> @@ -251,7 +251,7 @@ default_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  /* See frame-unwind.h.  */
>  
>  CORE_ADDR
> -default_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +default_unwind_sp (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    int sp_regnum = gdbarch_sp_regnum (gdbarch);
>    return frame_unwind_register_unsigned (next_frame, sp_regnum);
> @@ -263,7 +263,7 @@ default_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  /* Return a value which indicates that FRAME did not save REGNUM.  */
>  
>  struct value *
> -frame_unwind_got_optimized (frame_info_ptr frame, int regnum)
> +frame_unwind_got_optimized (const frame_info_ptr &frame, int regnum)
>  {
>    struct gdbarch *gdbarch = frame_unwind_arch (frame);
>    struct type *type = register_type (gdbarch, regnum);
> @@ -275,7 +275,7 @@ frame_unwind_got_optimized (frame_info_ptr frame, int regnum)
>     register NEW_REGNUM.  */
>  
>  struct value *
> -frame_unwind_got_register (frame_info_ptr frame,
> +frame_unwind_got_register (const frame_info_ptr &frame,
>  			   int regnum, int new_regnum)
>  {
>    return value_of_register_lazy (get_next_frame_sentinel_okay (frame),
> @@ -286,7 +286,7 @@ frame_unwind_got_register (frame_info_ptr frame,
>     ADDR.  */
>  
>  struct value *
> -frame_unwind_got_memory (frame_info_ptr frame, int regnum, CORE_ADDR addr)
> +frame_unwind_got_memory (const frame_info_ptr &frame, int regnum, CORE_ADDR addr)
>  {
>    struct gdbarch *gdbarch = frame_unwind_arch (frame);
>    struct value *v = value_at_lazy (register_type (gdbarch, regnum), addr);
> @@ -299,7 +299,7 @@ frame_unwind_got_memory (frame_info_ptr frame, int regnum, CORE_ADDR addr)
>     REGNUM has a known constant (computed) value of VAL.  */
>  
>  struct value *
> -frame_unwind_got_constant (frame_info_ptr frame, int regnum,
> +frame_unwind_got_constant (const frame_info_ptr &frame, int regnum,
>  			   ULONGEST val)
>  {
>    struct gdbarch *gdbarch = frame_unwind_arch (frame);
> @@ -313,7 +313,7 @@ frame_unwind_got_constant (frame_info_ptr frame, int regnum,
>  }
>  
>  struct value *
> -frame_unwind_got_bytes (frame_info_ptr frame, int regnum, const gdb_byte *buf)
> +frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum, const gdb_byte *buf)
>  {
>    struct gdbarch *gdbarch = frame_unwind_arch (frame);
>    struct value *reg_val;
> @@ -329,7 +329,7 @@ frame_unwind_got_bytes (frame_info_ptr frame, int regnum, const gdb_byte *buf)
>     CORE_ADDR to a target address if necessary.  */
>  
>  struct value *
> -frame_unwind_got_address (frame_info_ptr frame, int regnum,
> +frame_unwind_got_address (const frame_info_ptr &frame, int regnum,
>  			  CORE_ADDR addr)
>  {
>    struct gdbarch *gdbarch = frame_unwind_arch (frame);
> diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h
> index 9e978890e843..53fcd6869e95 100644
> --- a/gdb/frame-unwind.h
> +++ b/gdb/frame-unwind.h
> @@ -50,37 +50,37 @@ struct value;
>     to set *THIS_PROLOGUE_CACHE to NULL.  */
>  
>  typedef int (frame_sniffer_ftype) (const struct frame_unwind *self,
> -				   frame_info_ptr this_frame,
> +				   const frame_info_ptr &this_frame,
>  				   void **this_prologue_cache);
>  
> -typedef enum unwind_stop_reason (frame_unwind_stop_reason_ftype)
> -  (frame_info_ptr this_frame, void **this_prologue_cache);
> +typedef unwind_stop_reason (frame_unwind_stop_reason_ftype)
> +  (const frame_info_ptr &this_frame, void **this_prologue_cache);
>  
>  /* A default frame sniffer which always accepts the frame.  Used by
>     fallback prologue unwinders.  */
>  
>  int default_frame_sniffer (const struct frame_unwind *self,
> -			   frame_info_ptr this_frame,
> +			   const frame_info_ptr &this_frame,
>  			   void **this_prologue_cache);
>  
>  /* A default stop_reason callback which always claims the frame is
>     unwindable.  */
>  
>  enum unwind_stop_reason
> -  default_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +  default_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  				    void **this_cache);
>  
>  /* A default unwind_pc callback that simply unwinds the register identified
>     by GDBARCH_PC_REGNUM.  */
>  
>  extern CORE_ADDR default_unwind_pc (struct gdbarch *gdbarch,
> -				    frame_info_ptr next_frame);
> +				    const frame_info_ptr &next_frame);
>  
>  /* A default unwind_sp callback that simply unwinds the register identified
>     by GDBARCH_SP_REGNUM.  */
>  
>  extern CORE_ADDR default_unwind_sp (struct gdbarch *gdbarch,
> -				    frame_info_ptr next_frame);
> +				    const frame_info_ptr &next_frame);
>  
>  /* Assuming the frame chain: (outer) prev <-> this <-> next (inner);
>     use THIS frame, and through it the NEXT frame's register unwind
> @@ -105,7 +105,7 @@ extern CORE_ADDR default_unwind_sp (struct gdbarch *gdbarch,
>     with the other unwind methods.  Memory for that cache should be
>     allocated using FRAME_OBSTACK_ZALLOC().  */
>  
> -typedef void (frame_this_id_ftype) (frame_info_ptr this_frame,
> +typedef void (frame_this_id_ftype) (const frame_info_ptr &this_frame,
>  				    void **this_prologue_cache,
>  				    struct frame_id *this_id);
>  
> @@ -140,9 +140,9 @@ typedef void (frame_this_id_ftype) (frame_info_ptr this_frame,
>     with the other unwind methods.  Memory for that cache should be
>     allocated using FRAME_OBSTACK_ZALLOC().  */
>  
> -typedef struct value * (frame_prev_register_ftype)
> -  (frame_info_ptr this_frame, void **this_prologue_cache,
> -   int regnum);
> +typedef value *(frame_prev_register_ftype) (const frame_info_ptr &this_frame,
> +					    void **this_prologue_cache,
> +					    int regnum);
>  
>  /* Deallocate extra memory associated with the frame cache if any.  */
>  
> @@ -153,8 +153,8 @@ typedef void (frame_dealloc_cache_ftype) (frame_info *self,
>     use THIS frame, and implicitly the NEXT frame's register unwind
>     method, return PREV frame's architecture.  */
>  
> -typedef struct gdbarch *(frame_prev_arch_ftype) (frame_info_ptr this_frame,
> -						 void **this_prologue_cache);
> +typedef gdbarch *(frame_prev_arch_ftype) (const frame_info_ptr &this_frame,
> +					  void **this_prologue_cache);
>  
>  struct frame_unwind
>  {
> @@ -193,7 +193,7 @@ extern void frame_unwind_append_unwinder (struct gdbarch *gdbarch,
>     unwinder implementation.  THIS_FRAME->UNWIND must be NULL, it will get set
>     by this function.  Possibly initialize THIS_CACHE.  */
>  
> -extern void frame_unwind_find_by_frame (frame_info_ptr this_frame,
> +extern void frame_unwind_find_by_frame (const frame_info_ptr &this_frame,
>  					void **this_cache);
>  
>  /* Helper functions for value-based register unwinding.  These return
> @@ -201,39 +201,38 @@ extern void frame_unwind_find_by_frame (frame_info_ptr this_frame,
>  
>  /* Return a value which indicates that FRAME did not save REGNUM.  */
>  
> -struct value *frame_unwind_got_optimized (frame_info_ptr frame,
> -					  int regnum);
> +value *frame_unwind_got_optimized (const frame_info_ptr &frame, int regnum);
>  
>  /* Return a value which indicates that FRAME copied REGNUM into
>     register NEW_REGNUM.  */
>  
> -struct value *frame_unwind_got_register (frame_info_ptr frame, int regnum,
> -					 int new_regnum);
> +value *frame_unwind_got_register (const frame_info_ptr &frame, int regnum,
> +				  int new_regnum);
>  
>  /* Return a value which indicates that FRAME saved REGNUM in memory at
>     ADDR.  */
>  
> -struct value *frame_unwind_got_memory (frame_info_ptr frame, int regnum,
> -				       CORE_ADDR addr);
> +value *frame_unwind_got_memory (const frame_info_ptr &frame, int regnum,
> +				CORE_ADDR addr);
>  
>  /* Return a value which indicates that FRAME's saved version of
>     REGNUM has a known constant (computed) value of VAL.  */
>  
> -struct value *frame_unwind_got_constant (frame_info_ptr frame, int regnum,
> -					 ULONGEST val);
> +value *frame_unwind_got_constant (const frame_info_ptr &frame, int regnum,
> +				  ULONGEST val);
>  
>  /* Return a value which indicates that FRAME's saved version of
>     REGNUM has a known constant (computed) value which is stored
>     inside BUF.  */
>  
> -struct value *frame_unwind_got_bytes (frame_info_ptr frame, int regnum,
> -				      const gdb_byte *buf);
> +value *frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum,
> +			       const gdb_byte *buf);
>  
>  /* Return a value which indicates that FRAME's saved version of REGNUM
>     has a known constant (computed) value of ADDR.  Convert the
>     CORE_ADDR to a target address if necessary.  */
>  
> -struct value *frame_unwind_got_address (frame_info_ptr frame, int regnum,
> -					CORE_ADDR addr);
> +value *frame_unwind_got_address (const frame_info_ptr &frame, int regnum,
> +				 CORE_ADDR addr);
>  
>  #endif
> diff --git a/gdb/frame.c b/gdb/frame.c
> index 72a34fcfedca..9c3f0dfd4f2d 100644
> --- a/gdb/frame.c
> +++ b/gdb/frame.c
> @@ -71,7 +71,7 @@ get_frame_cache_generation ()
>  /* The values behind the global "set backtrace ..." settings.  */
>  set_backtrace_options user_set_backtrace_options;
>  
> -static frame_info_ptr get_prev_frame_raw (frame_info_ptr this_frame);
> +static frame_info_ptr get_prev_frame_raw (const frame_info_ptr &this_frame);
>  static const char *frame_stop_reason_symbol_string (enum unwind_stop_reason reason);
>  static frame_info_ptr create_new_frame (frame_id id);
>  
> @@ -197,7 +197,7 @@ struct frame_info
>  /* See frame.h.  */
>  
>  void
> -set_frame_previous_pc_masked (frame_info_ptr frame)
> +set_frame_previous_pc_masked (const frame_info_ptr &frame)
>  {
>    frame->prev_pc.masked = true;
>  }
> @@ -205,7 +205,7 @@ set_frame_previous_pc_masked (frame_info_ptr frame)
>  /* See frame.h.  */
>  
>  bool
> -get_frame_pc_masked (frame_info_ptr frame)
> +get_frame_pc_masked (const frame_info_ptr &frame)
>  {
>    gdb_assert (frame->next != nullptr);
>    gdb_assert (frame->next->prev_pc.status == CC_VALUE);
> @@ -528,7 +528,7 @@ frame_info::to_string () const
>     Return NULL if FRAME is the start of an artificial-only chain.  */
>  
>  static frame_info_ptr
> -skip_artificial_frames (frame_info_ptr frame)
> +skip_artificial_frames (const frame_info_ptr &initial_frame)
>  {
>    /* Note we use get_prev_frame_always, and not get_prev_frame.  The
>       latter will truncate the frame chain, leading to this function
> @@ -537,6 +537,7 @@ skip_artificial_frames (frame_info_ptr frame)
>  
>       Note that for record targets we may get a frame chain that consists
>       of artificial frames only.  */
> +  frame_info_ptr frame = initial_frame;
>    while (get_frame_type (frame) == INLINE_FRAME
>  	 || get_frame_type (frame) == TAILCALL_FRAME)
>      {
> @@ -549,8 +550,9 @@ skip_artificial_frames (frame_info_ptr frame)
>  }
>  
>  frame_info_ptr
> -skip_unwritable_frames (frame_info_ptr frame)
> +skip_unwritable_frames (const frame_info_ptr &initial_frame)
>  {
> +  frame_info_ptr frame = initial_frame;
>    while (gdbarch_code_of_frame_writable (get_frame_arch (frame), frame) == 0)
>      {
>        frame = get_prev_frame (frame);
> @@ -564,8 +566,9 @@ skip_unwritable_frames (frame_info_ptr frame)
>  /* See frame.h.  */
>  
>  frame_info_ptr
> -skip_tailcall_frames (frame_info_ptr frame)
> +skip_tailcall_frames (const frame_info_ptr &initial_frame)
>  {
> +  frame_info_ptr frame = initial_frame;
>    while (get_frame_type (frame) == TAILCALL_FRAME)
>      {
>        /* Note that for record targets we may get a frame chain that consists of
> @@ -582,7 +585,7 @@ skip_tailcall_frames (frame_info_ptr frame)
>     frame.  */
>  
>  static void
> -compute_frame_id (frame_info_ptr fi)
> +compute_frame_id (const frame_info_ptr &fi)
>  {
>    FRAME_SCOPED_DEBUG_ENTER_EXIT;
>  
> @@ -628,7 +631,7 @@ compute_frame_id (frame_info_ptr fi)
>     frame.  */
>  
>  struct frame_id
> -get_frame_id (frame_info_ptr fi)
> +get_frame_id (const frame_info_ptr &fi)
>  {
>    if (fi == NULL)
>      return null_frame_id;
> @@ -659,26 +662,24 @@ get_frame_id (frame_info_ptr fi)
>  }
>  
>  struct frame_id
> -get_stack_frame_id (frame_info_ptr next_frame)
> +get_stack_frame_id (const frame_info_ptr &next_frame)
>  {
>    return get_frame_id (skip_artificial_frames (next_frame));
>  }
>  
>  struct frame_id
> -frame_unwind_caller_id (frame_info_ptr next_frame)
> +frame_unwind_caller_id (const frame_info_ptr &initial_next_frame)
>  {
> -  frame_info_ptr this_frame;
> -
>    /* Use get_prev_frame_always, and not get_prev_frame.  The latter
>       will truncate the frame chain, leading to this function
>       unintentionally returning a null_frame_id (e.g., when a caller
>       requests the frame ID of "main()"s caller.  */
>  
> -  next_frame = skip_artificial_frames (next_frame);
> +  frame_info_ptr next_frame = skip_artificial_frames (initial_next_frame);
>    if (next_frame == NULL)
>      return null_frame_id;
>  
> -  this_frame = get_prev_frame_always (next_frame);
> +  frame_info_ptr this_frame = get_prev_frame_always (next_frame);
>    if (this_frame)
>      return get_frame_id (skip_artificial_frames (this_frame));
>    else
> @@ -965,7 +966,7 @@ frame_find_by_id (struct frame_id id)
>  }
>  
>  static CORE_ADDR
> -frame_unwind_pc (frame_info_ptr this_frame)
> +frame_unwind_pc (const frame_info_ptr &this_frame)
>  {
>    if (this_frame->prev_pc.status == CC_UNKNOWN)
>      {
> @@ -1039,20 +1040,20 @@ frame_unwind_pc (frame_info_ptr this_frame)
>  }
>  
>  CORE_ADDR
> -frame_unwind_caller_pc (frame_info_ptr this_frame)
> +frame_unwind_caller_pc (const frame_info_ptr &initial_this_frame)
>  {
> -  this_frame = skip_artificial_frames (this_frame);
> +  frame_info_ptr this_frame = skip_artificial_frames (initial_this_frame);
>  
>    /* We must have a non-artificial frame.  The caller is supposed to check
>       the result of frame_unwind_caller_id (), which returns NULL_FRAME_ID
>       in this case.  */
> -  gdb_assert (this_frame != NULL);
> +  gdb_assert (this_frame != nullptr);
>  
>    return frame_unwind_pc (this_frame);
>  }
>  
>  bool
> -get_frame_func_if_available (frame_info_ptr this_frame, CORE_ADDR *pc)
> +get_frame_func_if_available (const frame_info_ptr &this_frame, CORE_ADDR *pc)
>  {
>    frame_info *next_frame = this_frame->next;
>  
> @@ -1095,7 +1096,7 @@ get_frame_func_if_available (frame_info_ptr this_frame, CORE_ADDR *pc)
>  }
>  
>  CORE_ADDR
> -get_frame_func (frame_info_ptr this_frame)
> +get_frame_func (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc;
>  
> @@ -1106,7 +1107,7 @@ get_frame_func (frame_info_ptr this_frame)
>  }
>  
>  std::unique_ptr<readonly_detached_regcache>
> -frame_save_as_regcache (frame_info_ptr this_frame)
> +frame_save_as_regcache (const frame_info_ptr &this_frame)
>  {
>    auto cooked_read = [this_frame] (int regnum, gdb::array_view<gdb_byte> buf)
>      {
> @@ -1123,7 +1124,7 @@ frame_save_as_regcache (frame_info_ptr this_frame)
>  }
>  
>  void
> -frame_pop (frame_info_ptr this_frame)
> +frame_pop (const frame_info_ptr &this_frame)
>  {
>    frame_info_ptr prev_frame;
>  
> @@ -1172,7 +1173,7 @@ frame_pop (frame_info_ptr this_frame)
>  }
>  
>  void
> -frame_register_unwind (frame_info_ptr next_frame, int regnum,
> +frame_register_unwind (const frame_info_ptr &next_frame, int regnum,
>  		       int *optimizedp, int *unavailablep,
>  		       enum lval_type *lvalp, CORE_ADDR *addrp,
>  		       int *realnump, gdb_byte *bufferp)
> @@ -1215,7 +1216,7 @@ frame_register_unwind (frame_info_ptr next_frame, int regnum,
>  }
>  
>  void
> -frame_unwind_register (frame_info_ptr next_frame, int regnum, gdb_byte *buf)
> +frame_unwind_register (const frame_info_ptr &next_frame, int regnum, gdb_byte *buf)
>  {
>    int optimized;
>    int unavailable;
> @@ -1235,14 +1236,14 @@ frame_unwind_register (frame_info_ptr next_frame, int regnum, gdb_byte *buf)
>  }
>  
>  void
> -get_frame_register (frame_info_ptr frame,
> +get_frame_register (const frame_info_ptr &frame,
>  		    int regnum, gdb_byte *buf)
>  {
>    frame_unwind_register (frame_info_ptr (frame->next), regnum, buf);
>  }
>  
>  struct value *
> -frame_unwind_register_value (frame_info_ptr next_frame, int regnum)
> +frame_unwind_register_value (const frame_info_ptr &next_frame, int regnum)
>  {
>    FRAME_SCOPED_DEBUG_ENTER_EXIT;
>  
> @@ -1334,13 +1335,13 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum)
>  }
>  
>  struct value *
> -get_frame_register_value (frame_info_ptr frame, int regnum)
> +get_frame_register_value (const frame_info_ptr &frame, int regnum)
>  {
>    return frame_unwind_register_value (frame_info_ptr (frame->next), regnum);
>  }
>  
>  LONGEST
> -frame_unwind_register_signed (frame_info_ptr next_frame, int regnum)
> +frame_unwind_register_signed (const frame_info_ptr &next_frame, int regnum)
>  {
>    struct gdbarch *gdbarch = frame_unwind_arch (next_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -1366,13 +1367,13 @@ frame_unwind_register_signed (frame_info_ptr next_frame, int regnum)
>  }
>  
>  LONGEST
> -get_frame_register_signed (frame_info_ptr frame, int regnum)
> +get_frame_register_signed (const frame_info_ptr &frame, int regnum)
>  {
>    return frame_unwind_register_signed (frame_info_ptr (frame->next), regnum);
>  }
>  
>  ULONGEST
> -frame_unwind_register_unsigned (frame_info_ptr next_frame, int regnum)
> +frame_unwind_register_unsigned (const frame_info_ptr &next_frame, int regnum)
>  {
>    struct gdbarch *gdbarch = frame_unwind_arch (next_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -1400,13 +1401,13 @@ frame_unwind_register_unsigned (frame_info_ptr next_frame, int regnum)
>  }
>  
>  ULONGEST
> -get_frame_register_unsigned (frame_info_ptr frame, int regnum)
> +get_frame_register_unsigned (const frame_info_ptr &frame, int regnum)
>  {
>    return frame_unwind_register_unsigned (frame_info_ptr (frame->next), regnum);
>  }
>  
>  bool
> -read_frame_register_unsigned (frame_info_ptr frame, int regnum,
> +read_frame_register_unsigned (const frame_info_ptr &frame, int regnum,
>  			      ULONGEST *val)
>  {
>    struct value *regval = get_frame_register_value (frame, regnum);
> @@ -1427,7 +1428,7 @@ read_frame_register_unsigned (frame_info_ptr frame, int regnum,
>  }
>  
>  void
> -put_frame_register (frame_info_ptr next_frame, int regnum,
> +put_frame_register (const frame_info_ptr &next_frame, int regnum,
>  		     gdb::array_view<const gdb_byte> buf)
>  {
>    gdbarch *gdbarch = frame_unwind_arch (next_frame);
> @@ -1475,7 +1476,7 @@ put_frame_register (frame_info_ptr next_frame, int regnum,
>     Returns 0 if the register value could not be found.  */
>  
>  bool
> -deprecated_frame_register_read (frame_info_ptr frame, int regnum,
> +deprecated_frame_register_read (const frame_info_ptr &frame, int regnum,
>  				gdb_byte *myaddr)
>  {
>    int optimized;
> @@ -1492,7 +1493,7 @@ deprecated_frame_register_read (frame_info_ptr frame, int regnum,
>  }
>  
>  bool
> -get_frame_register_bytes (frame_info_ptr next_frame, int regnum,
> +get_frame_register_bytes (const frame_info_ptr &next_frame, int regnum,
>  			  CORE_ADDR offset, gdb::array_view<gdb_byte> buffer,
>  			  int *optimizedp, int *unavailablep)
>  {
> @@ -1569,7 +1570,7 @@ get_frame_register_bytes (frame_info_ptr next_frame, int regnum,
>  }
>  
>  void
> -put_frame_register_bytes (frame_info_ptr next_frame, int regnum,
> +put_frame_register_bytes (const frame_info_ptr &next_frame, int regnum,
>  			  CORE_ADDR offset,
>  			  gdb::array_view<const gdb_byte> buffer)
>  {
> @@ -1658,7 +1659,7 @@ frame_obstack_zalloc (unsigned long size)
>    return data;
>  }
>  
> -static frame_info_ptr get_prev_frame_always_1 (frame_info_ptr this_frame);
> +static frame_info_ptr get_prev_frame_always_1 (const frame_info_ptr &this_frame);
>  
>  frame_info_ptr
>  get_current_frame (void)
> @@ -1920,7 +1921,7 @@ invalidate_selected_frame ()
>  /* See frame.h.  */
>  
>  void
> -select_frame (frame_info_ptr fi)
> +select_frame (const frame_info_ptr &fi)
>  {
>    gdb_assert (fi != nullptr);
>  
> @@ -2062,7 +2063,7 @@ create_new_frame (CORE_ADDR stack, CORE_ADDR pc)
>     frame chain and onto the sentinel frame.  */
>  
>  frame_info_ptr
> -get_next_frame (frame_info_ptr this_frame)
> +get_next_frame (const frame_info_ptr &this_frame)
>  {
>    if (this_frame->level > 0)
>      return frame_info_ptr (this_frame->next);
> @@ -2075,7 +2076,7 @@ get_next_frame (frame_info_ptr this_frame)
>     unlike get_next_frame(), NULL will never be returned.  */
>  
>  frame_info_ptr
> -get_next_frame_sentinel_okay (frame_info_ptr this_frame)
> +get_next_frame_sentinel_okay (const frame_info_ptr &this_frame)
>  {
>    gdb_assert (this_frame != NULL);
>  
> @@ -2141,12 +2142,13 @@ reinit_frame_cache (void)
>     relative to this particular frame.  */
>  
>  static void
> -frame_register_unwind_location (frame_info_ptr this_frame, int regnum,
> -				int *optimizedp, enum lval_type *lvalp,
> +frame_register_unwind_location (const frame_info_ptr &initial_this_frame,
> +				int regnum, int *optimizedp, lval_type *lvalp,
>  				CORE_ADDR *addrp, int *realnump)
>  {
> -  gdb_assert (this_frame == NULL || this_frame->level >= 0);
> +  gdb_assert (initial_this_frame == nullptr || initial_this_frame->level >= 0);
>  
> +  frame_info_ptr this_frame = initial_this_frame;
>    while (this_frame != NULL)
>      {
>        int unavailable;
> @@ -2185,7 +2187,7 @@ frame_register_unwind_location (frame_info_ptr this_frame, int regnum,
>     of the previous frame, should also be a duplicate.  */
>  
>  static frame_info_ptr
> -get_prev_frame_maybe_check_cycle (frame_info_ptr this_frame)
> +get_prev_frame_maybe_check_cycle (const frame_info_ptr &this_frame)
>  {
>    frame_info_ptr prev_frame = get_prev_frame_raw (this_frame);
>  
> @@ -2273,7 +2275,7 @@ get_prev_frame_maybe_check_cycle (frame_info_ptr this_frame)
>     there is no such frame.  This may throw an exception.  */
>  
>  static frame_info_ptr
> -get_prev_frame_always_1 (frame_info_ptr this_frame)
> +get_prev_frame_always_1 (const frame_info_ptr &this_frame)
>  {
>    FRAME_SCOPED_DEBUG_ENTER_EXIT;
>  
> @@ -2429,7 +2431,7 @@ get_prev_frame_always_1 (frame_info_ptr this_frame)
>     frame.  */
>  
>  frame_info_ptr
> -get_prev_frame_always (frame_info_ptr this_frame)
> +get_prev_frame_always (const frame_info_ptr &this_frame)
>  {
>    frame_info_ptr prev_frame = NULL;
>  
> @@ -2469,7 +2471,7 @@ get_prev_frame_always (frame_info_ptr this_frame)
>     this_frame.  */
>  
>  static frame_info_ptr
> -get_prev_frame_raw (frame_info_ptr this_frame)
> +get_prev_frame_raw (const frame_info_ptr &this_frame)
>  {
>    frame_info *prev_frame;
>  
> @@ -2522,7 +2524,7 @@ get_prev_frame_raw (frame_info_ptr this_frame)
>  /* Debug routine to print a NULL frame being returned.  */
>  
>  static void
> -frame_debug_got_null_frame (frame_info_ptr this_frame,
> +frame_debug_got_null_frame (const frame_info_ptr &this_frame,
>  			    const char *reason)
>  {
>    if (frame_debug)
> @@ -2537,7 +2539,7 @@ frame_debug_got_null_frame (frame_info_ptr this_frame,
>  /* Is this (non-sentinel) frame in the "main"() function?  */
>  
>  static bool
> -inside_main_func (frame_info_ptr this_frame)
> +inside_main_func (const frame_info_ptr &this_frame)
>  {
>    if (current_program_space->symfile_object_file == nullptr)
>      return false;
> @@ -2585,7 +2587,7 @@ inside_main_func (frame_info_ptr this_frame)
>  /* Test whether THIS_FRAME is inside the process entry point function.  */
>  
>  static bool
> -inside_entry_func (frame_info_ptr this_frame)
> +inside_entry_func (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR entry_point;
>  
> @@ -2605,7 +2607,7 @@ inside_entry_func (frame_info_ptr this_frame)
>     checking whether the program-counter is zero.  */
>  
>  frame_info_ptr
> -get_prev_frame (frame_info_ptr this_frame)
> +get_prev_frame (const frame_info_ptr &this_frame)
>  {
>    FRAME_SCOPED_DEBUG_ENTER_EXIT;
>  
> @@ -2703,14 +2705,14 @@ get_prev_frame (frame_info_ptr this_frame)
>  }
>  
>  CORE_ADDR
> -get_frame_pc (frame_info_ptr frame)
> +get_frame_pc (const frame_info_ptr &frame)
>  {
>    gdb_assert (frame->next != NULL);
>    return frame_unwind_pc (frame_info_ptr (frame->next));
>  }
>  
>  bool
> -get_frame_pc_if_available (frame_info_ptr frame, CORE_ADDR *pc)
> +get_frame_pc_if_available (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>  
>    gdb_assert (frame->next != NULL);
> @@ -2733,7 +2735,7 @@ get_frame_pc_if_available (frame_info_ptr frame, CORE_ADDR *pc)
>  /* Return an address that falls within THIS_FRAME's code block.  */
>  
>  CORE_ADDR
> -get_frame_address_in_block (frame_info_ptr this_frame)
> +get_frame_address_in_block (const frame_info_ptr &this_frame)
>  {
>    /* A draft address.  */
>    CORE_ADDR pc = get_frame_pc (this_frame);
> @@ -2793,7 +2795,7 @@ get_frame_address_in_block (frame_info_ptr this_frame)
>  }
>  
>  bool
> -get_frame_address_in_block_if_available (frame_info_ptr this_frame,
> +get_frame_address_in_block_if_available (const frame_info_ptr &this_frame,
>  					 CORE_ADDR *pc)
>  {
>  
> @@ -2812,7 +2814,7 @@ get_frame_address_in_block_if_available (frame_info_ptr this_frame,
>  }
>  
>  symtab_and_line
> -find_frame_sal (frame_info_ptr frame)
> +find_frame_sal (const frame_info_ptr &frame)
>  {
>    frame_info_ptr next_frame;
>    int notcurrent;
> @@ -2870,7 +2872,7 @@ find_frame_sal (frame_info_ptr frame)
>  /* Per "frame.h", return the ``address'' of the frame.  Code should
>     really be using get_frame_id().  */
>  CORE_ADDR
> -get_frame_base (frame_info_ptr fi)
> +get_frame_base (const frame_info_ptr &fi)
>  {
>    return get_frame_id (fi).stack_addr;
>  }
> @@ -2878,7 +2880,7 @@ get_frame_base (frame_info_ptr fi)
>  /* High-level offsets into the frame.  Used by the debug info.  */
>  
>  CORE_ADDR
> -get_frame_base_address (frame_info_ptr fi)
> +get_frame_base_address (const frame_info_ptr &fi)
>  {
>    if (get_frame_type (fi) != NORMAL_FRAME)
>      return 0;
> @@ -2892,7 +2894,7 @@ get_frame_base_address (frame_info_ptr fi)
>  }
>  
>  CORE_ADDR
> -get_frame_locals_address (frame_info_ptr fi)
> +get_frame_locals_address (const frame_info_ptr &fi)
>  {
>    if (get_frame_type (fi) != NORMAL_FRAME)
>      return 0;
> @@ -2907,7 +2909,7 @@ get_frame_locals_address (frame_info_ptr fi)
>  }
>  
>  CORE_ADDR
> -get_frame_args_address (frame_info_ptr fi)
> +get_frame_args_address (const frame_info_ptr &fi)
>  {
>    if (get_frame_type (fi) != NORMAL_FRAME)
>      return 0;
> @@ -2925,7 +2927,7 @@ get_frame_args_address (frame_info_ptr fi)
>     otherwise.  */
>  
>  bool
> -frame_unwinder_is (frame_info_ptr fi, const frame_unwind *unwinder)
> +frame_unwinder_is (const frame_info_ptr &fi, const frame_unwind *unwinder)
>  {
>    if (fi->unwind == nullptr)
>      frame_unwind_find_by_frame (fi, &fi->prologue_cache);
> @@ -2937,7 +2939,7 @@ frame_unwinder_is (frame_info_ptr fi, const frame_unwind *unwinder)
>     or -1 for a NULL frame.  */
>  
>  int
> -frame_relative_level (frame_info_ptr fi)
> +frame_relative_level (const frame_info_ptr &fi)
>  {
>    if (fi == NULL)
>      return -1;
> @@ -2946,7 +2948,7 @@ frame_relative_level (frame_info_ptr fi)
>  }
>  
>  enum frame_type
> -get_frame_type (frame_info_ptr frame)
> +get_frame_type (const frame_info_ptr &frame)
>  {
>    if (frame->unwind == NULL)
>      /* Initialize the frame's unwinder because that's what
> @@ -2956,13 +2958,13 @@ get_frame_type (frame_info_ptr frame)
>  }
>  
>  struct program_space *
> -get_frame_program_space (frame_info_ptr frame)
> +get_frame_program_space (const frame_info_ptr &frame)
>  {
>    return frame->pspace;
>  }
>  
>  struct program_space *
> -frame_unwind_program_space (frame_info_ptr this_frame)
> +frame_unwind_program_space (const frame_info_ptr &this_frame)
>  {
>    gdb_assert (this_frame);
>  
> @@ -2973,7 +2975,7 @@ frame_unwind_program_space (frame_info_ptr this_frame)
>  }
>  
>  const address_space *
> -get_frame_address_space (frame_info_ptr frame)
> +get_frame_address_space (const frame_info_ptr &frame)
>  {
>    return frame->aspace;
>  }
> @@ -2981,14 +2983,14 @@ get_frame_address_space (frame_info_ptr frame)
>  /* Memory access methods.  */
>  
>  void
> -get_frame_memory (frame_info_ptr this_frame, CORE_ADDR addr,
> +get_frame_memory (const frame_info_ptr &this_frame, CORE_ADDR addr,
>  		  gdb::array_view<gdb_byte> buffer)
>  {
>    read_memory (addr, buffer.data (), buffer.size ());
>  }
>  
>  LONGEST
> -get_frame_memory_signed (frame_info_ptr this_frame, CORE_ADDR addr,
> +get_frame_memory_signed (const frame_info_ptr &this_frame, CORE_ADDR addr,
>  			 int len)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2998,7 +3000,7 @@ get_frame_memory_signed (frame_info_ptr this_frame, CORE_ADDR addr,
>  }
>  
>  ULONGEST
> -get_frame_memory_unsigned (frame_info_ptr this_frame, CORE_ADDR addr,
> +get_frame_memory_unsigned (const frame_info_ptr &this_frame, CORE_ADDR addr,
>  			   int len)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -3008,7 +3010,7 @@ get_frame_memory_unsigned (frame_info_ptr this_frame, CORE_ADDR addr,
>  }
>  
>  bool
> -safe_frame_unwind_memory (frame_info_ptr this_frame,
> +safe_frame_unwind_memory (const frame_info_ptr &this_frame,
>  			  CORE_ADDR addr, gdb::array_view<gdb_byte> buffer)
>  {
>    /* NOTE: target_read_memory returns zero on success!  */
> @@ -3018,13 +3020,13 @@ safe_frame_unwind_memory (frame_info_ptr this_frame,
>  /* Architecture methods.  */
>  
>  struct gdbarch *
> -get_frame_arch (frame_info_ptr this_frame)
> +get_frame_arch (const frame_info_ptr &this_frame)
>  {
>    return frame_unwind_arch (frame_info_ptr (this_frame->next));
>  }
>  
>  struct gdbarch *
> -frame_unwind_arch (frame_info_ptr next_frame)
> +frame_unwind_arch (const frame_info_ptr &next_frame)
>  {
>    if (!next_frame->prev_arch.p)
>      {
> @@ -3050,14 +3052,14 @@ frame_unwind_arch (frame_info_ptr next_frame)
>  }
>  
>  struct gdbarch *
> -frame_unwind_caller_arch (frame_info_ptr next_frame)
> +frame_unwind_caller_arch (const frame_info_ptr &initial_next_frame)
>  {
> -  next_frame = skip_artificial_frames (next_frame);
> +  frame_info_ptr next_frame = skip_artificial_frames (initial_next_frame);
>  
>    /* We must have a non-artificial frame.  The caller is supposed to check
>       the result of frame_unwind_caller_id (), which returns NULL_FRAME_ID
>       in this case.  */
> -  gdb_assert (next_frame != NULL);
> +  gdb_assert (next_frame != nullptr);
>  
>    return frame_unwind_arch (next_frame);
>  }
> @@ -3065,7 +3067,7 @@ frame_unwind_caller_arch (frame_info_ptr next_frame)
>  /* Gets the language of FRAME.  */
>  
>  enum language
> -get_frame_language (frame_info_ptr frame)
> +get_frame_language (const frame_info_ptr &frame)
>  {
>    CORE_ADDR pc = 0;
>    bool pc_p = false;
> @@ -3106,7 +3108,7 @@ get_frame_language (frame_info_ptr frame)
>  /* Stack pointer methods.  */
>  
>  CORE_ADDR
> -get_frame_sp (frame_info_ptr this_frame)
> +get_frame_sp (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>  
> @@ -3118,9 +3120,9 @@ get_frame_sp (frame_info_ptr this_frame)
>  /* See frame.h.  */
>  
>  frame_info_ptr
> -frame_follow_static_link (frame_info_ptr frame)
> +frame_follow_static_link (const frame_info_ptr &initial_frame)
>  {
> -  const block *frame_block = get_frame_block (frame, nullptr);
> +  const block *frame_block = get_frame_block (initial_frame, nullptr);
>    if (frame_block == nullptr)
>      return {};
>  
> @@ -3132,11 +3134,12 @@ frame_follow_static_link (frame_info_ptr frame)
>  
>    CORE_ADDR upper_frame_base;
>  
> -  if (!dwarf2_evaluate_property (static_link, frame, NULL, &upper_frame_base))
> +  if (!dwarf2_evaluate_property (static_link, initial_frame, NULL, &upper_frame_base))
>      return {};
>  
>    /* Now climb up the stack frame until we reach the frame we are interested
>       in.  */
> +  frame_info_ptr frame = initial_frame;
>    for (; frame != nullptr; frame = get_prev_frame (frame))
>      {
>        struct symbol *framefunc = get_frame_function (frame);
> @@ -3163,7 +3166,7 @@ frame_follow_static_link (frame_info_ptr frame)
>  /* Return the reason why we can't unwind past FRAME.  */
>  
>  enum unwind_stop_reason
> -get_frame_unwind_stop_reason (frame_info_ptr frame)
> +get_frame_unwind_stop_reason (const frame_info_ptr &frame)
>  {
>    /* Fill-in STOP_REASON.  */
>    get_prev_frame_always (frame);
> @@ -3190,7 +3193,7 @@ unwind_stop_reason_to_string (enum unwind_stop_reason reason)
>  }
>  
>  const char *
> -frame_stop_reason_string (frame_info_ptr fi)
> +frame_stop_reason_string (const frame_info_ptr &fi)
>  {
>    gdb_assert (fi->prev_p);
>    gdb_assert (fi->prev == NULL);
> @@ -3225,7 +3228,7 @@ frame_stop_reason_symbol_string (enum unwind_stop_reason reason)
>     FRAME.  */
>  
>  void
> -frame_cleanup_after_sniffer (frame_info_ptr frame)
> +frame_cleanup_after_sniffer (const frame_info_ptr &frame)
>  {
>    /* The sniffer should not allocate a prologue cache if it did not
>       match this frame.  */
> @@ -3255,7 +3258,7 @@ frame_cleanup_after_sniffer (frame_info_ptr frame)
>     frame_cleanup_after_sniffer.  */
>  
>  void
> -frame_prepare_for_sniffer (frame_info_ptr frame,
> +frame_prepare_for_sniffer (const frame_info_ptr &frame,
>  			   const struct frame_unwind *unwind)
>  {
>    gdb_assert (frame->unwind == NULL);
> diff --git a/gdb/frame.h b/gdb/frame.h
> index c3787d4649cf..e784c17b4807 100644
> --- a/gdb/frame.h
> +++ b/gdb/frame.h
> @@ -450,7 +450,7 @@ extern void reinit_frame_cache (void);
>  extern frame_info_ptr get_selected_frame (const char *message = nullptr);
>  
>  /* Select a specific frame.  */
> -extern void select_frame (frame_info_ptr);
> +extern void select_frame (const frame_info_ptr &);
>  
>  /* Save the frame ID and frame level of the selected frame in FRAME_ID
>     and FRAME_LEVEL, to be restored later with restore_selected_frame.
> @@ -475,19 +475,19 @@ extern void restore_selected_frame (frame_id frame_id, int frame_level)
>  
>  /* Given a FRAME, return the next (more inner, younger) or previous
>     (more outer, older) frame.  */
> -extern frame_info_ptr get_prev_frame (frame_info_ptr);
> -extern frame_info_ptr get_next_frame (frame_info_ptr);
> +extern frame_info_ptr get_prev_frame (const frame_info_ptr &);
> +extern frame_info_ptr get_next_frame (const frame_info_ptr &);
>  
>  /* Like get_next_frame(), but allows return of the sentinel frame.  NULL
>     is never returned.  */
> -extern frame_info_ptr get_next_frame_sentinel_okay (frame_info_ptr);
> +extern frame_info_ptr get_next_frame_sentinel_okay (const frame_info_ptr &);
>  
>  /* Return a "struct frame_info" corresponding to the frame that called
>     THIS_FRAME.  Returns NULL if there is no such frame.
>  
>     Unlike get_prev_frame, this function always tries to unwind the
>     frame.  */
> -extern frame_info_ptr get_prev_frame_always (frame_info_ptr);
> +extern frame_info_ptr get_prev_frame_always (const frame_info_ptr &);
>  
>  /* Given a frame's ID, relocate the frame.  Returns NULL if the frame
>     is not found.  */
> @@ -499,12 +499,12 @@ extern frame_info_ptr frame_find_by_id (frame_id id);
>     this frame.
>  
>     This replaced: frame->pc; */
> -extern CORE_ADDR get_frame_pc (frame_info_ptr);
> +extern CORE_ADDR get_frame_pc (const frame_info_ptr &);
>  
>  /* Same as get_frame_pc, but return a boolean indication of whether
>     the PC is actually available, instead of throwing an error.  */
>  
> -extern bool get_frame_pc_if_available (frame_info_ptr frame, CORE_ADDR *pc);
> +extern bool get_frame_pc_if_available (const frame_info_ptr &frame, CORE_ADDR *pc);
>  
>  /* An address (not necessarily aligned to an instruction boundary)
>     that falls within THIS frame's code block.
> @@ -519,32 +519,32 @@ extern bool get_frame_pc_if_available (frame_info_ptr frame, CORE_ADDR *pc);
>     function returns the frame's PC-1 which "should" be an address in
>     the frame's block.  */
>  
> -extern CORE_ADDR get_frame_address_in_block (frame_info_ptr this_frame);
> +extern CORE_ADDR get_frame_address_in_block (const frame_info_ptr &this_frame);
>  
>  /* Same as get_frame_address_in_block, but returns a boolean
>     indication of whether the frame address is determinable (when the
>     PC is unavailable, it will not be), instead of possibly throwing an
>     error trying to read an unavailable PC.  */
>  
> -extern bool get_frame_address_in_block_if_available (frame_info_ptr this_frame,
> +extern bool get_frame_address_in_block_if_available (const frame_info_ptr &this_frame,
>  						     CORE_ADDR *pc);
>  
>  /* The frame's inner-most bound.  AKA the stack-pointer.  Confusingly
>     known as top-of-stack.  */
>  
> -extern CORE_ADDR get_frame_sp (frame_info_ptr);
> +extern CORE_ADDR get_frame_sp (const frame_info_ptr &);
>  
>  /* Following on from the `resume' address.  Return the entry point
>     address of the function containing that resume address, or zero if
>     that function isn't known.  */
> -extern CORE_ADDR get_frame_func (frame_info_ptr fi);
> +extern CORE_ADDR get_frame_func (const frame_info_ptr &fi);
>  
>  /* Same as get_frame_func, but returns a boolean indication of whether
>     the frame function is determinable (when the PC is unavailable, it
>     will not be), instead of possibly throwing an error trying to read
>     an unavailable PC.  */
>  
> -extern bool get_frame_func_if_available (frame_info_ptr fi, CORE_ADDR *);
> +extern bool get_frame_func_if_available (const frame_info_ptr &fi, CORE_ADDR *);
>  
>  /* Closely related to the resume address, various symbol table
>     attributes that are determined by the PC.  Note that for a normal
> @@ -564,12 +564,12 @@ extern bool get_frame_func_if_available (frame_info_ptr fi, CORE_ADDR *);
>     find_frame_symtab(), find_frame_function().  Each will need to be
>     carefully considered to determine if the real intent was for it to
>     apply to the PC or the adjusted PC.  */
> -extern symtab_and_line find_frame_sal (frame_info_ptr frame);
> +extern symtab_and_line find_frame_sal (const frame_info_ptr &frame);
>  
>  /* Set the current source and line to the location given by frame
>     FRAME, if possible.  */
>  
> -void set_current_sal_from_frame (frame_info_ptr);
> +void set_current_sal_from_frame (const frame_info_ptr &);
>  
>  /* Return the frame base (what ever that is) (DEPRECATED).
>  
> @@ -593,59 +593,59 @@ void set_current_sal_from_frame (frame_info_ptr);
>  
>     This replaced: frame->frame; */
>  
> -extern CORE_ADDR get_frame_base (frame_info_ptr);
> +extern CORE_ADDR get_frame_base (const frame_info_ptr &);
>  
>  /* Return the per-frame unique identifier.  Can be used to relocate a
>     frame after a frame cache flush (and other similar operations).  If
>     FI is NULL, return the null_frame_id.  */
> -extern struct frame_id get_frame_id (frame_info_ptr fi);
> -extern struct frame_id get_stack_frame_id (frame_info_ptr fi);
> -extern struct frame_id frame_unwind_caller_id (frame_info_ptr next_frame);
> +extern frame_id get_frame_id (const frame_info_ptr &fi);
> +extern frame_id get_stack_frame_id (const frame_info_ptr &fi);
> +extern frame_id frame_unwind_caller_id (const frame_info_ptr &next_frame);
>  
>  /* Assuming that a frame is `normal', return its base-address, or 0 if
>     the information isn't available.  NOTE: This address is really only
>     meaningful to the frame's high-level debug info.  */
> -extern CORE_ADDR get_frame_base_address (frame_info_ptr);
> +extern CORE_ADDR get_frame_base_address (const frame_info_ptr &);
>  
>  /* Assuming that a frame is `normal', return the base-address of the
>     local variables, or 0 if the information isn't available.  NOTE:
>     This address is really only meaningful to the frame's high-level
>     debug info.  Typically, the argument and locals share a single
>     base-address.  */
> -extern CORE_ADDR get_frame_locals_address (frame_info_ptr);
> +extern CORE_ADDR get_frame_locals_address (const frame_info_ptr &);
>  
>  /* Assuming that a frame is `normal', return the base-address of the
>     parameter list, or 0 if that information isn't available.  NOTE:
>     This address is really only meaningful to the frame's high-level
>     debug info.  Typically, the argument and locals share a single
>     base-address.  */
> -extern CORE_ADDR get_frame_args_address (frame_info_ptr);
> +extern CORE_ADDR get_frame_args_address (const frame_info_ptr &);
>  
>  /* The frame's level: 0 for innermost, 1 for its caller, ...; or -1
>     for an invalid frame).  */
> -extern int frame_relative_level (frame_info_ptr fi);
> +extern int frame_relative_level (const frame_info_ptr &fi);
>  
>  /* Return the frame's type.  */
>  
> -extern enum frame_type get_frame_type (frame_info_ptr);
> +extern enum frame_type get_frame_type (const frame_info_ptr &);
>  
>  /* Return the frame's program space.  */
> -extern struct program_space *get_frame_program_space (frame_info_ptr);
> +extern struct program_space *get_frame_program_space (const frame_info_ptr &);
>  
>  /* Unwind THIS frame's program space from the NEXT frame.  */
> -extern struct program_space *frame_unwind_program_space (frame_info_ptr);
> +extern struct program_space *frame_unwind_program_space (const frame_info_ptr &);
>  
>  class address_space;
>  
>  /* Return the frame's address space.  */
> -extern const address_space *get_frame_address_space (frame_info_ptr);
> +extern const address_space *get_frame_address_space (const frame_info_ptr &);
>  
>  /* A frame may have a "static link".  That is, in some languages, a
>     nested function may have access to variables from the enclosing
>     block and frame.  This function looks for a frame's static link.
>     If found, returns the corresponding frame; otherwise, returns a
>     null frame_info_ptr.  */
> -extern frame_info_ptr frame_follow_static_link (frame_info_ptr frame);
> +extern frame_info_ptr frame_follow_static_link (const frame_info_ptr &frame);
>  
>  /* For frames where we can not unwind further, describe why.  */
>  
> @@ -665,7 +665,7 @@ enum unwind_stop_reason
>  
>  /* Return the reason why we can't unwind past this frame.  */
>  
> -enum unwind_stop_reason get_frame_unwind_stop_reason (frame_info_ptr);
> +enum unwind_stop_reason get_frame_unwind_stop_reason (const frame_info_ptr &);
>  
>  /* Translate a reason code to an informative string.  This converts the
>     generic stop reason codes into a generic string describing the code.
> @@ -682,13 +682,13 @@ const char *unwind_stop_reason_to_string (enum unwind_stop_reason);
>  
>     Should only be called for frames that don't have a previous frame.  */
>  
> -const char *frame_stop_reason_string (frame_info_ptr);
> +const char *frame_stop_reason_string (const frame_info_ptr &);
>  
>  /* Unwind the stack frame so that the value of REGNUM, in the previous
>     (up, older) frame is returned.  If VALUEP is NULL, don't
>     fetch/compute the value.  Instead just return the location of the
>     value.  */
> -extern void frame_register_unwind (frame_info_ptr frame, int regnum,
> +extern void frame_register_unwind (const frame_info_ptr &frame, int regnum,
>  				   int *optimizedp, int *unavailablep,
>  				   enum lval_type *lvalp,
>  				   CORE_ADDR *addrp, int *realnump,
> @@ -700,23 +700,23 @@ extern void frame_register_unwind (frame_info_ptr frame, int regnum,
>     fetch fails.  The value methods never return NULL, but usually
>     do return a lazy value.  */
>  
> -extern void frame_unwind_register (frame_info_ptr next_frame,
> +extern void frame_unwind_register (const frame_info_ptr &next_frame,
>  				   int regnum, gdb_byte *buf);
> -extern void get_frame_register (frame_info_ptr frame,
> +extern void get_frame_register (const frame_info_ptr &frame,
>  				int regnum, gdb_byte *buf);
>  
> -struct value *frame_unwind_register_value (frame_info_ptr next_frame,
> +struct value *frame_unwind_register_value (const frame_info_ptr &next_frame,
>  					   int regnum);
> -struct value *get_frame_register_value (frame_info_ptr frame,
> +struct value *get_frame_register_value (const frame_info_ptr &frame,
>  					int regnum);
>  
> -extern LONGEST frame_unwind_register_signed (frame_info_ptr next_frame,
> +extern LONGEST frame_unwind_register_signed (const frame_info_ptr &next_frame,
>  					     int regnum);
> -extern LONGEST get_frame_register_signed (frame_info_ptr frame,
> +extern LONGEST get_frame_register_signed (const frame_info_ptr &frame,
>  					  int regnum);
> -extern ULONGEST frame_unwind_register_unsigned (frame_info_ptr next_frame,
> -						int regnum);
> -extern ULONGEST get_frame_register_unsigned (frame_info_ptr frame,
> +extern ULONGEST frame_unwind_register_unsigned
> +  (const frame_info_ptr &next_frame, int regnum);
> +extern ULONGEST get_frame_register_unsigned (const frame_info_ptr &frame,
>  					     int regnum);
>  
>  /* Read a register from this, or unwind a register from the next
> @@ -724,39 +724,39 @@ extern ULONGEST get_frame_register_unsigned (frame_info_ptr frame,
>     get_frame_register_value, that do not throw if the result is
>     optimized out or unavailable.  */
>  
> -extern bool read_frame_register_unsigned (frame_info_ptr frame,
> +extern bool read_frame_register_unsigned (const frame_info_ptr &frame,
>  					  int regnum, ULONGEST *val);
>  
>  /* The reverse.  Store a register value relative to NEXT_FRAME's previous frame.
>     Note: this call makes the frame's state undefined.  The register and frame
>     caches must be flushed.  */
> -extern void put_frame_register (frame_info_ptr next_frame, int regnum,
> +extern void put_frame_register (const frame_info_ptr &next_frame, int regnum,
>  				gdb::array_view<const gdb_byte> buf);
>  
>  /* Read LEN bytes from one or multiple registers starting with REGNUM in
>     NEXT_FRAME's previous frame, starting at OFFSET, into BUF.  If the register
>     contents are optimized out or unavailable, set *OPTIMIZEDP, *UNAVAILABLEP
>     accordingly.  */
> -extern bool get_frame_register_bytes (frame_info_ptr next_frame, int regnum,
> -				      CORE_ADDR offset,
> +extern bool get_frame_register_bytes (const frame_info_ptr &next_frame,
> +				      int regnum, CORE_ADDR offset,
>  				      gdb::array_view<gdb_byte> buffer,
>  				      int *optimizedp, int *unavailablep);
>  
>  /* Write bytes from BUFFER to one or multiple registers starting with REGNUM
>     in NEXT_FRAME's previous frame, starting at OFFSET.  */
> -extern void put_frame_register_bytes (frame_info_ptr next_frame, int regnum,
> -				      CORE_ADDR offset,
> +extern void put_frame_register_bytes (const frame_info_ptr &next_frame,
> +				      int regnum, CORE_ADDR offset,
>  				      gdb::array_view<const gdb_byte> buffer);
>  
>  /* Unwind the PC.  Strictly speaking return the resume address of the
>     calling frame.  For GDB, `pc' is the resume address and not a
>     specific register.  */
>  
> -extern CORE_ADDR frame_unwind_caller_pc (frame_info_ptr frame);
> +extern CORE_ADDR frame_unwind_caller_pc (const frame_info_ptr &next_frame);
>  
>  /* Discard the specified frame.  Restoring the registers to the state
>     of the caller.  */
> -extern void frame_pop (frame_info_ptr frame);
> +extern void frame_pop (const frame_info_ptr &frame);
>  
>  /* Return memory from the specified frame.  A frame knows its thread /
>     LWP and hence can find its way down to a target.  The assumption
> @@ -771,26 +771,26 @@ extern void frame_pop (frame_info_ptr frame);
>     If architecture / memory changes are always separated by special
>     adaptor frames this should be ok.  */
>  
> -extern void get_frame_memory (frame_info_ptr this_frame, CORE_ADDR addr,
> +extern void get_frame_memory (const frame_info_ptr &this_frame, CORE_ADDR addr,
>  			      gdb::array_view<gdb_byte> buffer);
> -extern LONGEST get_frame_memory_signed (frame_info_ptr this_frame,
> +extern LONGEST get_frame_memory_signed (const frame_info_ptr &this_frame,
>  					CORE_ADDR memaddr, int len);
> -extern ULONGEST get_frame_memory_unsigned (frame_info_ptr this_frame,
> +extern ULONGEST get_frame_memory_unsigned (const frame_info_ptr &this_frame,
>  					   CORE_ADDR memaddr, int len);
>  
>  /* Same as above, but return true zero when the entire memory read
>     succeeds, false otherwise.  */
> -extern bool safe_frame_unwind_memory (frame_info_ptr this_frame, CORE_ADDR addr,
> +extern bool safe_frame_unwind_memory (const frame_info_ptr &this_frame, CORE_ADDR addr,
>  				      gdb::array_view<gdb_byte> buffer);
>  
>  /* Return this frame's architecture.  */
> -extern struct gdbarch *get_frame_arch (frame_info_ptr this_frame);
> +extern gdbarch *get_frame_arch (const frame_info_ptr &this_frame);
>  
>  /* Return the previous frame's architecture.  */
> -extern struct gdbarch *frame_unwind_arch (frame_info_ptr next_frame);
> +extern gdbarch *frame_unwind_arch (const frame_info_ptr &next_frame);
>  
>  /* Return the previous frame's architecture, skipping inline functions.  */
> -extern struct gdbarch *frame_unwind_caller_arch (frame_info_ptr frame);
> +extern gdbarch *frame_unwind_caller_arch (const frame_info_ptr &next_frame);
>  
>  
>  /* Values for the source flag to be used in print_frame_info ().
> @@ -830,9 +830,9 @@ extern void *frame_obstack_zalloc (unsigned long size);
>  class readonly_detached_regcache;
>  /* Create a regcache, and copy the frame's registers into it.  */
>  std::unique_ptr<readonly_detached_regcache> frame_save_as_regcache
> -    (frame_info_ptr this_frame);
> +    (const frame_info_ptr &this_frame);
>  
> -extern const struct block *get_frame_block (frame_info_ptr,
> +extern const struct block *get_frame_block (const frame_info_ptr &,
>  					    CORE_ADDR *addr_in_block);
>  
>  /* Return the `struct block' that belongs to the selected thread's
> @@ -863,7 +863,7 @@ extern const struct block *get_frame_block (frame_info_ptr,
>  
>  extern const struct block *get_selected_block (CORE_ADDR *addr_in_block);
>  
> -extern struct symbol *get_frame_function (frame_info_ptr);
> +extern struct symbol *get_frame_function (const frame_info_ptr &);
>  
>  extern CORE_ADDR get_pc_function_start (CORE_ADDR);
>  
> @@ -873,22 +873,22 @@ extern frame_info_ptr find_relative_frame (frame_info_ptr, int *);
>     the function call.  */
>  
>  extern void print_stack_frame_to_uiout (struct ui_out *uiout,
> -					frame_info_ptr, int print_level,
> +					const frame_info_ptr &, int print_level,
>  					enum print_what print_what,
>  					int set_current_sal);
>  
> -extern void print_stack_frame (frame_info_ptr, int print_level,
> +extern void print_stack_frame (const frame_info_ptr &, int print_level,
>  			       enum print_what print_what,
>  			       int set_current_sal);
>  
>  extern void print_frame_info (const frame_print_options &fp_opts,
> -			      frame_info_ptr, int print_level,
> +			      const frame_info_ptr &, int print_level,
>  			      enum print_what print_what, int args,
>  			      int set_current_sal);
>  
>  extern frame_info_ptr block_innermost_frame (const struct block *);
>  
> -extern bool deprecated_frame_register_read (frame_info_ptr frame, int regnum,
> +extern bool deprecated_frame_register_read (const frame_info_ptr &frame, int regnum,
>  					    gdb_byte *buf);
>  
>  /* From stack.c.  */
> @@ -960,10 +960,10 @@ struct frame_arg
>  };
>  
>  extern void read_frame_arg (const frame_print_options &fp_opts,
> -			    symbol *sym, frame_info_ptr frame,
> +			    symbol *sym, const frame_info_ptr &frame,
>  			    struct frame_arg *argp,
>  			    struct frame_arg *entryargp);
> -extern void read_frame_local (struct symbol *sym, frame_info_ptr frame,
> +extern void read_frame_local (struct symbol *sym, const frame_info_ptr &frame,
>  			      struct frame_arg *argp);
>  
>  extern void info_args_command (const char *, int);
> @@ -976,13 +976,13 @@ extern void return_command (const char *, int);
>     If sniffing fails, the caller should be sure to call
>     frame_cleanup_after_sniffer.  */
>  
> -extern void frame_prepare_for_sniffer (frame_info_ptr frame,
> +extern void frame_prepare_for_sniffer (const frame_info_ptr &frame,
>  				       const struct frame_unwind *unwind);
>  
>  /* Clean up after a failed (wrong unwinder) attempt to unwind past
>     FRAME.  */
>  
> -extern void frame_cleanup_after_sniffer (frame_info_ptr frame);
> +extern void frame_cleanup_after_sniffer (const frame_info_ptr &frame);
>  
>  /* Notes (cagney/2002-11-27, drow/2003-09-06):
>  
> @@ -1023,22 +1023,22 @@ extern frame_info_ptr create_new_frame (CORE_ADDR base, CORE_ADDR pc);
>  /* Return true if the frame unwinder for frame FI is UNWINDER; false
>     otherwise.  */
>  
> -extern bool frame_unwinder_is (frame_info_ptr fi, const frame_unwind *unwinder);
> +extern bool frame_unwinder_is (const frame_info_ptr &fi, const frame_unwind *unwinder);
>  
>  /* Return the language of FRAME.  */
>  
> -extern enum language get_frame_language (frame_info_ptr frame);
> +extern enum language get_frame_language (const frame_info_ptr &frame);
>  
>  /* Return the first non-tailcall frame above FRAME or FRAME if it is not a
>     tailcall frame.  Return NULL if FRAME is the start of a tailcall-only
>     chain.  */
>  
> -extern frame_info_ptr skip_tailcall_frames (frame_info_ptr frame);
> +extern frame_info_ptr skip_tailcall_frames (const frame_info_ptr &frame);
>  
>  /* Return the first frame above FRAME or FRAME of which the code is
>     writable.  */
>  
> -extern frame_info_ptr skip_unwritable_frames (frame_info_ptr frame);
> +extern frame_info_ptr skip_unwritable_frames (const frame_info_ptr &frame);
>  
>  /* Data for the "set backtrace" settings.  */
>  
> @@ -1070,11 +1070,11 @@ unsigned int get_frame_cache_generation ();
>  
>  /* Mark that the PC value is masked for the previous frame.  */
>  
> -extern void set_frame_previous_pc_masked (frame_info_ptr frame);
> +extern void set_frame_previous_pc_masked (const frame_info_ptr &frame);
>  
>  /* Get whether the PC value is masked for the given frame.  */
>  
> -extern bool get_frame_pc_masked (frame_info_ptr frame);
> +extern bool get_frame_pc_masked (const frame_info_ptr &frame);
>  
>  
>  #endif /* !defined (FRAME_H)  */
> diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c
> index e02d3390a33d..5160c3b0c1d6 100644
> --- a/gdb/frv-linux-tdep.c
> +++ b/gdb/frv-linux-tdep.c
> @@ -168,7 +168,7 @@ frv_linux_pc_in_sigtramp (struct gdbarch *gdbarch, CORE_ADDR pc,
>        } __attribute__((aligned(8)));  */
>  
>  static LONGEST
> -frv_linux_sigcontext_reg_addr (frame_info_ptr this_frame, int regno,
> +frv_linux_sigcontext_reg_addr (const frame_info_ptr &this_frame, int regno,
>  			       CORE_ADDR *sc_addr_cache_ptr)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -258,7 +258,7 @@ frv_linux_sigcontext_reg_addr (frame_info_ptr this_frame, int regno,
>  /* Signal trampolines.  */
>  
>  static struct trad_frame_cache *
> -frv_linux_sigtramp_frame_cache (frame_info_ptr this_frame,
> +frv_linux_sigtramp_frame_cache (const frame_info_ptr &this_frame,
>  				void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -297,7 +297,7 @@ frv_linux_sigtramp_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -frv_linux_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +frv_linux_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				  void **this_cache,
>  				  struct frame_id *this_id)
>  {
> @@ -307,7 +307,7 @@ frv_linux_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -frv_linux_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +frv_linux_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  					void **this_cache, int regnum)
>  {
>    /* Make sure we've initialized the cache.  */
> @@ -318,7 +318,7 @@ frv_linux_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  frv_linux_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				  frame_info_ptr this_frame,
> +				  const frame_info_ptr &this_frame,
>  				  void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
> index 1994dd782ad5..bcb2c621945b 100644
> --- a/gdb/frv-tdep.c
> +++ b/gdb/frv-tdep.c
> @@ -510,7 +510,7 @@ is_argument_reg (int reg)
>     prologue analysis.  */
>  static CORE_ADDR
>  frv_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
> -		      frame_info_ptr this_frame,
> +		      const frame_info_ptr &this_frame,
>  		      struct frv_unwind_cache *info)
>  {
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -1084,7 +1084,7 @@ frv_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>  
>  
>  static struct frv_unwind_cache *
> -frv_frame_unwind_cache (frame_info_ptr this_frame,
> +frv_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1367,7 +1367,7 @@ frv_return_value (struct gdbarch *gdbarch, struct value *function,
>     frame.  This will be used to create a new GDB frame struct.  */
>  
>  static void
> -frv_frame_this_id (frame_info_ptr this_frame,
> +frv_frame_this_id (const frame_info_ptr &this_frame,
>  		    void **this_prologue_cache, struct frame_id *this_id)
>  {
>    struct frv_unwind_cache *info
> @@ -1397,7 +1397,7 @@ frv_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -frv_frame_prev_register (frame_info_ptr this_frame,
> +frv_frame_prev_register (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache, int regnum)
>  {
>    struct frv_unwind_cache *info
> @@ -1416,7 +1416,7 @@ static const struct frame_unwind frv_frame_unwind = {
>  };
>  
>  static CORE_ADDR
> -frv_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +frv_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct frv_unwind_cache *info
>      = frv_frame_unwind_cache (this_frame, this_cache);
> diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
> index 069d40f56fb2..60cd2c974a12 100644
> --- a/gdb/ft32-tdep.c
> +++ b/gdb/ft32-tdep.c
> @@ -450,7 +450,7 @@ ft32_alloc_frame_cache (void)
>  /* Populate a ft32_frame_cache object for this_frame.  */
>  
>  static struct ft32_frame_cache *
> -ft32_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +ft32_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct ft32_frame_cache *cache;
>    CORE_ADDR current_pc;
> @@ -490,7 +490,7 @@ ft32_frame_cache (frame_info_ptr this_frame, void **this_cache)
>     frame.  This will be used to create a new GDB frame struct.  */
>  
>  static void
> -ft32_frame_this_id (frame_info_ptr this_frame,
> +ft32_frame_this_id (const frame_info_ptr &this_frame,
>  		    void **this_prologue_cache, struct frame_id *this_id)
>  {
>    struct ft32_frame_cache *cache = ft32_frame_cache (this_frame,
> @@ -506,7 +506,7 @@ ft32_frame_this_id (frame_info_ptr this_frame,
>  /* Get the value of register regnum in the previous stack frame.  */
>  
>  static struct value *
> -ft32_frame_prev_register (frame_info_ptr this_frame,
> +ft32_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache, int regnum)
>  {
>    struct ft32_frame_cache *cache = ft32_frame_cache (this_frame,
> @@ -538,7 +538,7 @@ static const struct frame_unwind ft32_frame_unwind =
>  /* Return the base address of this_frame.  */
>  
>  static CORE_ADDR
> -ft32_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +ft32_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct ft32_frame_cache *cache = ft32_frame_cache (this_frame,
>  						     this_cache);
> diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
> index 7a57bdcebe23..13dd0ed5d5e1 100644
> --- a/gdb/gdbarch-gen.h
> +++ b/gdb/gdbarch-gen.h
> @@ -196,8 +196,8 @@ extern void set_gdbarch_pseudo_register_read (struct gdbarch *gdbarch, gdbarch_p
>  
>  extern bool gdbarch_pseudo_register_read_value_p (struct gdbarch *gdbarch);
>  
> -typedef struct value * (gdbarch_pseudo_register_read_value_ftype) (struct gdbarch *gdbarch, frame_info_ptr next_frame, int cookednum);
> -extern struct value * gdbarch_pseudo_register_read_value (struct gdbarch *gdbarch, frame_info_ptr next_frame, int cookednum);
> +typedef struct value * (gdbarch_pseudo_register_read_value_ftype) (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int cookednum);
> +extern struct value * gdbarch_pseudo_register_read_value (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int cookednum);
>  extern void set_gdbarch_pseudo_register_read_value (struct gdbarch *gdbarch, gdbarch_pseudo_register_read_value_ftype *pseudo_register_read_value);
>  
>  /* Write bytes in BUF to pseudo register with number PSEUDO_REG_NUM.
> @@ -207,8 +207,8 @@ extern void set_gdbarch_pseudo_register_read_value (struct gdbarch *gdbarch, gdb
>  
>  extern bool gdbarch_pseudo_register_write_p (struct gdbarch *gdbarch);
>  
> -typedef void (gdbarch_pseudo_register_write_ftype) (struct gdbarch *gdbarch, frame_info_ptr next_frame, int pseudo_reg_num, gdb::array_view<const gdb_byte> buf);
> -extern void gdbarch_pseudo_register_write (struct gdbarch *gdbarch, frame_info_ptr next_frame, int pseudo_reg_num, gdb::array_view<const gdb_byte> buf);
> +typedef void (gdbarch_pseudo_register_write_ftype) (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int pseudo_reg_num, gdb::array_view<const gdb_byte> buf);
> +extern void gdbarch_pseudo_register_write (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int pseudo_reg_num, gdb::array_view<const gdb_byte> buf);
>  extern void set_gdbarch_pseudo_register_write (struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype *pseudo_register_write);
>  
>  /* Write bytes to a pseudo register.
> @@ -335,8 +335,8 @@ extern void set_gdbarch_register_type (struct gdbarch *gdbarch, gdbarch_register
>     should match the address at which the breakpoint was set in the dummy
>     frame. */
>  
> -typedef struct frame_id (gdbarch_dummy_id_ftype) (struct gdbarch *gdbarch, frame_info_ptr this_frame);
> -extern struct frame_id gdbarch_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame);
> +typedef struct frame_id (gdbarch_dummy_id_ftype) (struct gdbarch *gdbarch, const frame_info_ptr &this_frame);
> +extern struct frame_id gdbarch_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame);
>  extern void set_gdbarch_dummy_id (struct gdbarch *gdbarch, gdbarch_dummy_id_ftype *dummy_id);
>  
>  /* Implement DUMMY_ID and PUSH_DUMMY_CALL, then delete
> @@ -362,22 +362,22 @@ extern void set_gdbarch_push_dummy_code (struct gdbarch *gdbarch, gdbarch_push_d
>  
>  /* Return true if the code of FRAME is writable. */
>  
> -typedef int (gdbarch_code_of_frame_writable_ftype) (struct gdbarch *gdbarch, frame_info_ptr frame);
> -extern int gdbarch_code_of_frame_writable (struct gdbarch *gdbarch, frame_info_ptr frame);
> +typedef int (gdbarch_code_of_frame_writable_ftype) (struct gdbarch *gdbarch, const frame_info_ptr &frame);
> +extern int gdbarch_code_of_frame_writable (struct gdbarch *gdbarch, const frame_info_ptr &frame);
>  extern void set_gdbarch_code_of_frame_writable (struct gdbarch *gdbarch, gdbarch_code_of_frame_writable_ftype *code_of_frame_writable);
>  
> -typedef void (gdbarch_print_registers_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, int regnum, int all);
> -extern void gdbarch_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, int regnum, int all);
> +typedef void (gdbarch_print_registers_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, const frame_info_ptr &frame, int regnum, int all);
> +extern void gdbarch_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, const frame_info_ptr &frame, int regnum, int all);
>  extern void set_gdbarch_print_registers_info (struct gdbarch *gdbarch, gdbarch_print_registers_info_ftype *print_registers_info);
>  
> -typedef void (gdbarch_print_float_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, const char *args);
> -extern void gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, const char *args);
> +typedef void (gdbarch_print_float_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, const frame_info_ptr &frame, const char *args);
> +extern void gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, const frame_info_ptr &frame, const char *args);
>  extern void set_gdbarch_print_float_info (struct gdbarch *gdbarch, gdbarch_print_float_info_ftype *print_float_info);
>  
>  extern bool gdbarch_print_vector_info_p (struct gdbarch *gdbarch);
>  
> -typedef void (gdbarch_print_vector_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, const char *args);
> -extern void gdbarch_print_vector_info (struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, const char *args);
> +typedef void (gdbarch_print_vector_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, const frame_info_ptr &frame, const char *args);
> +extern void gdbarch_print_vector_info (struct gdbarch *gdbarch, struct ui_file *file, const frame_info_ptr &frame, const char *args);
>  extern void set_gdbarch_print_vector_info (struct gdbarch *gdbarch, gdbarch_print_vector_info_ftype *print_vector_info);
>  
>  /* MAP a GDB RAW register number onto a simulator register number.  See
> @@ -402,8 +402,8 @@ extern void set_gdbarch_cannot_store_register (struct gdbarch *gdbarch, gdbarch_
>  
>  extern bool gdbarch_get_longjmp_target_p (struct gdbarch *gdbarch);
>  
> -typedef int (gdbarch_get_longjmp_target_ftype) (frame_info_ptr frame, CORE_ADDR *pc);
> -extern int gdbarch_get_longjmp_target (struct gdbarch *gdbarch, frame_info_ptr frame, CORE_ADDR *pc);
> +typedef int (gdbarch_get_longjmp_target_ftype) (const frame_info_ptr &frame, CORE_ADDR *pc);
> +extern int gdbarch_get_longjmp_target (struct gdbarch *gdbarch, const frame_info_ptr &frame, CORE_ADDR *pc);
>  extern void set_gdbarch_get_longjmp_target (struct gdbarch *gdbarch, gdbarch_get_longjmp_target_ftype *get_longjmp_target);
>  
>  extern int gdbarch_believe_pcc_promotion (struct gdbarch *gdbarch);
> @@ -413,12 +413,12 @@ typedef int (gdbarch_convert_register_p_ftype) (struct gdbarch *gdbarch, int reg
>  extern int gdbarch_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type);
>  extern void set_gdbarch_convert_register_p (struct gdbarch *gdbarch, gdbarch_convert_register_p_ftype *convert_register_p);
>  
> -typedef int (gdbarch_register_to_value_ftype) (frame_info_ptr frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep);
> -extern int gdbarch_register_to_value (struct gdbarch *gdbarch, frame_info_ptr frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep);
> +typedef int (gdbarch_register_to_value_ftype) (const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep);
> +extern int gdbarch_register_to_value (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep);
>  extern void set_gdbarch_register_to_value (struct gdbarch *gdbarch, gdbarch_register_to_value_ftype *register_to_value);
>  
> -typedef void (gdbarch_value_to_register_ftype) (frame_info_ptr frame, int regnum, struct type *type, const gdb_byte *buf);
> -extern void gdbarch_value_to_register (struct gdbarch *gdbarch, frame_info_ptr frame, int regnum, struct type *type, const gdb_byte *buf);
> +typedef void (gdbarch_value_to_register_ftype) (const frame_info_ptr &frame, int regnum, struct type *type, const gdb_byte *buf);
> +extern void gdbarch_value_to_register (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, const gdb_byte *buf);
>  extern void set_gdbarch_value_to_register (struct gdbarch *gdbarch, gdbarch_value_to_register_ftype *value_to_register);
>  
>  /* Construct a value representing the contents of register REGNUM in
> @@ -484,8 +484,8 @@ extern void set_gdbarch_return_value_as_value (struct gdbarch *gdbarch, gdbarch_
>  
>     May return 0 when unable to determine that address. */
>  
> -typedef CORE_ADDR (gdbarch_get_return_buf_addr_ftype) (struct type *val_type, frame_info_ptr cur_frame);
> -extern CORE_ADDR gdbarch_get_return_buf_addr (struct gdbarch *gdbarch, struct type *val_type, frame_info_ptr cur_frame);
> +typedef CORE_ADDR (gdbarch_get_return_buf_addr_ftype) (struct type *val_type, const frame_info_ptr &cur_frame);
> +extern CORE_ADDR gdbarch_get_return_buf_addr (struct gdbarch *gdbarch, struct type *val_type, const frame_info_ptr &cur_frame);
>  extern void set_gdbarch_get_return_buf_addr (struct gdbarch *gdbarch, gdbarch_get_return_buf_addr_ftype *get_return_buf_addr);
>  
>  /* Return true if the typedef record needs to be replaced.".
> @@ -635,12 +635,12 @@ extern void set_gdbarch_get_thread_local_address (struct gdbarch *gdbarch, gdbar
>  extern CORE_ADDR gdbarch_frame_args_skip (struct gdbarch *gdbarch);
>  extern void set_gdbarch_frame_args_skip (struct gdbarch *gdbarch, CORE_ADDR frame_args_skip);
>  
> -typedef CORE_ADDR (gdbarch_unwind_pc_ftype) (struct gdbarch *gdbarch, frame_info_ptr next_frame);
> -extern CORE_ADDR gdbarch_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame);
> +typedef CORE_ADDR (gdbarch_unwind_pc_ftype) (struct gdbarch *gdbarch, const frame_info_ptr &next_frame);
> +extern CORE_ADDR gdbarch_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame);
>  extern void set_gdbarch_unwind_pc (struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype *unwind_pc);
>  
> -typedef CORE_ADDR (gdbarch_unwind_sp_ftype) (struct gdbarch *gdbarch, frame_info_ptr next_frame);
> -extern CORE_ADDR gdbarch_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame);
> +typedef CORE_ADDR (gdbarch_unwind_sp_ftype) (struct gdbarch *gdbarch, const frame_info_ptr &next_frame);
> +extern CORE_ADDR gdbarch_unwind_sp (struct gdbarch *gdbarch, const frame_info_ptr &next_frame);
>  extern void set_gdbarch_unwind_sp (struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype *unwind_sp);
>  
>  /* DEPRECATED_FRAME_LOCALS_ADDRESS as been replaced by the per-frame
> @@ -648,8 +648,8 @@ extern void set_gdbarch_unwind_sp (struct gdbarch *gdbarch, gdbarch_unwind_sp_ft
>  
>  extern bool gdbarch_frame_num_args_p (struct gdbarch *gdbarch);
>  
> -typedef int (gdbarch_frame_num_args_ftype) (frame_info_ptr frame);
> -extern int gdbarch_frame_num_args (struct gdbarch *gdbarch, frame_info_ptr frame);
> +typedef int (gdbarch_frame_num_args_ftype) (const frame_info_ptr &frame);
> +extern int gdbarch_frame_num_args (struct gdbarch *gdbarch, const frame_info_ptr &frame);
>  extern void set_gdbarch_frame_num_args (struct gdbarch *gdbarch, gdbarch_frame_num_args_ftype *frame_num_args);
>  
>  extern bool gdbarch_frame_align_p (struct gdbarch *gdbarch);
> @@ -768,8 +768,8 @@ extern void set_gdbarch_software_single_step (struct gdbarch *gdbarch, gdbarch_s
>  
>  extern bool gdbarch_single_step_through_delay_p (struct gdbarch *gdbarch);
>  
> -typedef int (gdbarch_single_step_through_delay_ftype) (struct gdbarch *gdbarch, frame_info_ptr frame);
> -extern int gdbarch_single_step_through_delay (struct gdbarch *gdbarch, frame_info_ptr frame);
> +typedef int (gdbarch_single_step_through_delay_ftype) (struct gdbarch *gdbarch, const frame_info_ptr &frame);
> +extern int gdbarch_single_step_through_delay (struct gdbarch *gdbarch, const frame_info_ptr &frame);
>  extern void set_gdbarch_single_step_through_delay (struct gdbarch *gdbarch, gdbarch_single_step_through_delay_ftype *single_step_through_delay);
>  
>  /* FIXME: cagney/2003-08-28: Need to find a better way of selecting the
> @@ -779,8 +779,8 @@ typedef int (gdbarch_print_insn_ftype) (bfd_vma vma, struct disassemble_info *in
>  extern int gdbarch_print_insn (struct gdbarch *gdbarch, bfd_vma vma, struct disassemble_info *info);
>  extern void set_gdbarch_print_insn (struct gdbarch *gdbarch, gdbarch_print_insn_ftype *print_insn);
>  
> -typedef CORE_ADDR (gdbarch_skip_trampoline_code_ftype) (frame_info_ptr frame, CORE_ADDR pc);
> -extern CORE_ADDR gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, frame_info_ptr frame, CORE_ADDR pc);
> +typedef CORE_ADDR (gdbarch_skip_trampoline_code_ftype) (const frame_info_ptr &frame, CORE_ADDR pc);
> +extern CORE_ADDR gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, const frame_info_ptr &frame, CORE_ADDR pc);
>  extern void set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype *skip_trampoline_code);
>  
>  /* Vtable of solib operations functions. */
> @@ -927,8 +927,8 @@ extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch, gdbarch_re
>  
>  extern bool gdbarch_fetch_pointer_argument_p (struct gdbarch *gdbarch);
>  
> -typedef CORE_ADDR (gdbarch_fetch_pointer_argument_ftype) (frame_info_ptr frame, int argi, struct type *type);
> -extern CORE_ADDR gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, frame_info_ptr frame, int argi, struct type *type);
> +typedef CORE_ADDR (gdbarch_fetch_pointer_argument_ftype) (const frame_info_ptr &frame, int argi, struct type *type);
> +extern CORE_ADDR gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, const frame_info_ptr &frame, int argi, struct type *type);
>  extern void set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument);
>  
>  /* Iterate over all supported register notes in a core file.  For each
> @@ -1732,8 +1732,8 @@ extern void set_gdbarch_type_align (struct gdbarch *gdbarch, gdbarch_type_align_
>  
>  /* Return a string containing any flags for the given PC in the given FRAME. */
>  
> -typedef std::string (gdbarch_get_pc_address_flags_ftype) (frame_info_ptr frame, CORE_ADDR pc);
> -extern std::string gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, frame_info_ptr frame, CORE_ADDR pc);
> +typedef std::string (gdbarch_get_pc_address_flags_ftype) (const frame_info_ptr &frame, CORE_ADDR pc);
> +extern std::string gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, const frame_info_ptr &frame, CORE_ADDR pc);
>  extern void set_gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, gdbarch_get_pc_address_flags_ftype *get_pc_address_flags);
>  
>  /* Read core file mappings */
> diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
> index b9be3948d1ee..80a04bf0caf8 100644
> --- a/gdb/gdbarch.c
> +++ b/gdb/gdbarch.c
> @@ -1894,7 +1894,7 @@ gdbarch_pseudo_register_read_value_p (struct gdbarch *gdbarch)
>  }
>  
>  struct value *
> -gdbarch_pseudo_register_read_value (struct gdbarch *gdbarch, frame_info_ptr next_frame, int cookednum)
> +gdbarch_pseudo_register_read_value (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int cookednum)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->pseudo_register_read_value != NULL);
> @@ -1918,7 +1918,7 @@ gdbarch_pseudo_register_write_p (struct gdbarch *gdbarch)
>  }
>  
>  void
> -gdbarch_pseudo_register_write (struct gdbarch *gdbarch, frame_info_ptr next_frame, int pseudo_reg_num, gdb::array_view<const gdb_byte> buf)
> +gdbarch_pseudo_register_write (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int pseudo_reg_num, gdb::array_view<const gdb_byte> buf)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->pseudo_register_write != NULL);
> @@ -2240,7 +2240,7 @@ set_gdbarch_register_type (struct gdbarch *gdbarch,
>  }
>  
>  struct frame_id
> -gdbarch_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +gdbarch_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->dummy_id != NULL);
> @@ -2339,7 +2339,7 @@ set_gdbarch_push_dummy_code (struct gdbarch *gdbarch,
>  }
>  
>  int
> -gdbarch_code_of_frame_writable (struct gdbarch *gdbarch, frame_info_ptr frame)
> +gdbarch_code_of_frame_writable (struct gdbarch *gdbarch, const frame_info_ptr &frame)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->code_of_frame_writable != NULL);
> @@ -2356,7 +2356,7 @@ set_gdbarch_code_of_frame_writable (struct gdbarch *gdbarch,
>  }
>  
>  void
> -gdbarch_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, int regnum, int all)
> +gdbarch_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, const frame_info_ptr &frame, int regnum, int all)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->print_registers_info != NULL);
> @@ -2373,7 +2373,7 @@ set_gdbarch_print_registers_info (struct gdbarch *gdbarch,
>  }
>  
>  void
> -gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, const char *args)
> +gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, const frame_info_ptr &frame, const char *args)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->print_float_info != NULL);
> @@ -2397,7 +2397,7 @@ gdbarch_print_vector_info_p (struct gdbarch *gdbarch)
>  }
>  
>  void
> -gdbarch_print_vector_info (struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, const char *args)
> +gdbarch_print_vector_info (struct gdbarch *gdbarch, struct ui_file *file, const frame_info_ptr &frame, const char *args)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->print_vector_info != NULL);
> @@ -2472,7 +2472,7 @@ gdbarch_get_longjmp_target_p (struct gdbarch *gdbarch)
>  }
>  
>  int
> -gdbarch_get_longjmp_target (struct gdbarch *gdbarch, frame_info_ptr frame, CORE_ADDR *pc)
> +gdbarch_get_longjmp_target (struct gdbarch *gdbarch, const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->get_longjmp_target != NULL);
> @@ -2523,7 +2523,7 @@ set_gdbarch_convert_register_p (struct gdbarch *gdbarch,
>  }
>  
>  int
> -gdbarch_register_to_value (struct gdbarch *gdbarch, frame_info_ptr frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep)
> +gdbarch_register_to_value (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->register_to_value != NULL);
> @@ -2540,7 +2540,7 @@ set_gdbarch_register_to_value (struct gdbarch *gdbarch,
>  }
>  
>  void
> -gdbarch_value_to_register (struct gdbarch *gdbarch, frame_info_ptr frame, int regnum, struct type *type, const gdb_byte *buf)
> +gdbarch_value_to_register (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, const gdb_byte *buf)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->value_to_register != NULL);
> @@ -2656,7 +2656,7 @@ set_gdbarch_return_value_as_value (struct gdbarch *gdbarch,
>  }
>  
>  CORE_ADDR
> -gdbarch_get_return_buf_addr (struct gdbarch *gdbarch, struct type *val_type, frame_info_ptr cur_frame)
> +gdbarch_get_return_buf_addr (struct gdbarch *gdbarch, struct type *val_type, const frame_info_ptr &cur_frame)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->get_return_buf_addr != NULL);
> @@ -3048,7 +3048,7 @@ set_gdbarch_frame_args_skip (struct gdbarch *gdbarch,
>  }
>  
>  CORE_ADDR
> -gdbarch_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +gdbarch_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->unwind_pc != NULL);
> @@ -3065,7 +3065,7 @@ set_gdbarch_unwind_pc (struct gdbarch *gdbarch,
>  }
>  
>  CORE_ADDR
> -gdbarch_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +gdbarch_unwind_sp (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->unwind_sp != NULL);
> @@ -3089,7 +3089,7 @@ gdbarch_frame_num_args_p (struct gdbarch *gdbarch)
>  }
>  
>  int
> -gdbarch_frame_num_args (struct gdbarch *gdbarch, frame_info_ptr frame)
> +gdbarch_frame_num_args (struct gdbarch *gdbarch, const frame_info_ptr &frame)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->frame_num_args != NULL);
> @@ -3348,7 +3348,7 @@ gdbarch_single_step_through_delay_p (struct gdbarch *gdbarch)
>  }
>  
>  int
> -gdbarch_single_step_through_delay (struct gdbarch *gdbarch, frame_info_ptr frame)
> +gdbarch_single_step_through_delay (struct gdbarch *gdbarch, const frame_info_ptr &frame)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->single_step_through_delay != NULL);
> @@ -3382,7 +3382,7 @@ set_gdbarch_print_insn (struct gdbarch *gdbarch,
>  }
>  
>  CORE_ADDR
> -gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, frame_info_ptr frame, CORE_ADDR pc)
> +gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->skip_trampoline_code != NULL);
> @@ -3723,7 +3723,7 @@ gdbarch_fetch_pointer_argument_p (struct gdbarch *gdbarch)
>  }
>  
>  CORE_ADDR
> -gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, frame_info_ptr frame, int argi, struct type *type)
> +gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, const frame_info_ptr &frame, int argi, struct type *type)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->fetch_pointer_argument != NULL);
> @@ -5414,7 +5414,7 @@ set_gdbarch_type_align (struct gdbarch *gdbarch,
>  }
>  
>  std::string
> -gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, frame_info_ptr frame, CORE_ADDR pc)
> +gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    gdb_assert (gdbarch != NULL);
>    gdb_assert (gdbarch->get_pc_address_flags != NULL);
> diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py
> index d76b820c1b55..762d48a0187f 100644
> --- a/gdb/gdbarch_components.py
> +++ b/gdb/gdbarch_components.py
> @@ -414,7 +414,7 @@ never be called.
>  """,
>      type="struct value *",
>      name="pseudo_register_read_value",
> -    params=[("frame_info_ptr", "next_frame"), ("int", "cookednum")],
> +    params=[("const frame_info_ptr &", "next_frame"), ("int", "cookednum")],
>      predicate=True,
>  )
>  
> @@ -428,7 +428,7 @@ NEXT_FRAME.
>      type="void",
>      name="pseudo_register_write",
>      params=[
> -        ("frame_info_ptr", "next_frame"),
> +        ("const frame_info_ptr &", "next_frame"),
>          ("int", "pseudo_reg_num"),
>          ("gdb::array_view<const gdb_byte>", "buf"),
>      ],
> @@ -628,7 +628,7 @@ frame.
>  """,
>      type="struct frame_id",
>      name="dummy_id",
> -    params=[("frame_info_ptr", "this_frame")],
> +    params=[("const frame_info_ptr &", "this_frame")],
>      predefault="default_dummy_id",
>      invalid=False,
>  )
> @@ -689,7 +689,7 @@ Return true if the code of FRAME is writable.
>  """,
>      type="int",
>      name="code_of_frame_writable",
> -    params=[("frame_info_ptr", "frame")],
> +    params=[("const frame_info_ptr &", "frame")],
>      predefault="default_code_of_frame_writable",
>      invalid=False,
>  )
> @@ -699,7 +699,7 @@ Method(
>      name="print_registers_info",
>      params=[
>          ("struct ui_file *", "file"),
> -        ("frame_info_ptr", "frame"),
> +        ("const frame_info_ptr &", "frame"),
>          ("int", "regnum"),
>          ("int", "all"),
>      ],
> @@ -712,7 +712,7 @@ Method(
>      name="print_float_info",
>      params=[
>          ("struct ui_file *", "file"),
> -        ("frame_info_ptr", "frame"),
> +        ("const frame_info_ptr &", "frame"),
>          ("const char *", "args"),
>      ],
>      predefault="default_print_float_info",
> @@ -724,7 +724,7 @@ Method(
>      name="print_vector_info",
>      params=[
>          ("struct ui_file *", "file"),
> -        ("frame_info_ptr", "frame"),
> +        ("const frame_info_ptr &", "frame"),
>          ("const char *", "args"),
>      ],
>      predicate=True,
> @@ -767,7 +767,7 @@ FRAME corresponds to the longjmp frame.
>  """,
>      type="int",
>      name="get_longjmp_target",
> -    params=[("frame_info_ptr", "frame"), ("CORE_ADDR *", "pc")],
> +    params=[("const frame_info_ptr &", "frame"), ("CORE_ADDR *", "pc")],
>      predicate=True,
>  )
>  
> @@ -789,7 +789,7 @@ Function(
>      type="int",
>      name="register_to_value",
>      params=[
> -        ("frame_info_ptr", "frame"),
> +        ("const frame_info_ptr &", "frame"),
>          ("int", "regnum"),
>          ("struct type *", "type"),
>          ("gdb_byte *", "buf"),
> @@ -803,7 +803,7 @@ Function(
>      type="void",
>      name="value_to_register",
>      params=[
> -        ("frame_info_ptr", "frame"),
> +        ("const frame_info_ptr &", "frame"),
>          ("int", "regnum"),
>          ("struct type *", "type"),
>          ("const gdb_byte *", "buf"),
> @@ -923,7 +923,7 @@ convention".
>  May return 0 when unable to determine that address.""",
>      type="CORE_ADDR",
>      name="get_return_buf_addr",
> -    params=[("struct type *", "val_type"), ("frame_info_ptr", "cur_frame")],
> +    params=[("struct type *", "val_type"), ("const frame_info_ptr &", "cur_frame")],
>      predefault="default_get_return_buf_addr",
>      invalid=False,
>  )
> @@ -1157,7 +1157,7 @@ Value(
>  Method(
>      type="CORE_ADDR",
>      name="unwind_pc",
> -    params=[("frame_info_ptr", "next_frame")],
> +    params=[("const frame_info_ptr &", "next_frame")],
>      predefault="default_unwind_pc",
>      invalid=False,
>  )
> @@ -1165,7 +1165,7 @@ Method(
>  Method(
>      type="CORE_ADDR",
>      name="unwind_sp",
> -    params=[("frame_info_ptr", "next_frame")],
> +    params=[("const frame_info_ptr &", "next_frame")],
>      predefault="default_unwind_sp",
>      invalid=False,
>  )
> @@ -1177,7 +1177,7 @@ frame-base.  Enable frame-base before frame-unwind.
>  """,
>      type="int",
>      name="frame_num_args",
> -    params=[("frame_info_ptr", "frame")],
> +    params=[("const frame_info_ptr &", "frame")],
>      predicate=True,
>  )
>  
> @@ -1357,7 +1357,7 @@ further single-step is needed before the instruction finishes.
>  """,
>      type="int",
>      name="single_step_through_delay",
> -    params=[("frame_info_ptr", "frame")],
> +    params=[("const frame_info_ptr &", "frame")],
>      predicate=True,
>  )
>  
> @@ -1376,7 +1376,7 @@ disassembler.  Perhaps objdump can handle it?
>  Function(
>      type="CORE_ADDR",
>      name="skip_trampoline_code",
> -    params=[("frame_info_ptr", "frame"), ("CORE_ADDR", "pc")],
> +    params=[("const frame_info_ptr &", "frame"), ("CORE_ADDR", "pc")],
>      predefault="generic_skip_trampoline_code",
>      invalid=False,
>  )
> @@ -1596,7 +1596,7 @@ Fetch the pointer to the ith function argument.
>      type="CORE_ADDR",
>      name="fetch_pointer_argument",
>      params=[
> -        ("frame_info_ptr", "frame"),
> +        ("const frame_info_ptr &", "frame"),
>          ("int", "argi"),
>          ("struct type *", "type"),
>      ],
> @@ -2744,7 +2744,7 @@ Return a string containing any flags for the given PC in the given FRAME.
>  """,
>      type="std::string",
>      name="get_pc_address_flags",
> -    params=[("frame_info_ptr", "frame"), ("CORE_ADDR", "pc")],
> +    params=[("const frame_info_ptr &", "frame"), ("CORE_ADDR", "pc")],
>      predefault="default_get_pc_address_flags",
>      invalid=False,
>  )
> diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
> index faefe9259436..133bf28f6487 100644
> --- a/gdb/gnu-v3-abi.c
> +++ b/gdb/gnu-v3-abi.c
> @@ -1225,7 +1225,7 @@ gnuv3_get_type_from_type_info (struct value *type_info_ptr)
>     of the routine we are thunking to and continue to there instead.  */
>  
>  static CORE_ADDR 
> -gnuv3_skip_trampoline (frame_info_ptr frame, CORE_ADDR stop_pc)
> +gnuv3_skip_trampoline (const frame_info_ptr &frame, CORE_ADDR stop_pc)
>  {
>    CORE_ADDR real_stop_pc, method_stop_pc, func_addr;
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
> index da5b10517ada..36cbd9d4aa60 100644
> --- a/gdb/h8300-tdep.c
> +++ b/gdb/h8300-tdep.c
> @@ -404,7 +404,7 @@ h8300_analyze_prologue (struct gdbarch *gdbarch,
>  }
>  
>  static struct h8300_frame_cache *
> -h8300_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +h8300_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct h8300_frame_cache *cache;
> @@ -466,7 +466,7 @@ h8300_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -h8300_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +h8300_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		     struct frame_id *this_id)
>  {
>    struct h8300_frame_cache *cache =
> @@ -480,7 +480,7 @@ h8300_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -h8300_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +h8300_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			   int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -511,7 +511,7 @@ static const struct frame_unwind h8300_frame_unwind = {
>  };
>  
>  static CORE_ADDR
> -h8300_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +h8300_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct h8300_frame_cache *cache = h8300_frame_cache (this_frame, this_cache);
>    return cache->base;
> @@ -991,7 +991,7 @@ h8300sx_register_name (struct gdbarch *gdbarch, int regno)
>  
>  static void
>  h8300_print_register (struct gdbarch *gdbarch, struct ui_file *file,
> -		      frame_info_ptr frame, int regno)
> +		      const frame_info_ptr &frame, int regno)
>  {
>    LONGEST rval;
>    const char *name = gdbarch_register_name (gdbarch, regno);
> @@ -1068,7 +1068,7 @@ h8300_print_register (struct gdbarch *gdbarch, struct ui_file *file,
>  
>  static void
>  h8300_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
> -			    frame_info_ptr frame, int regno, int cpregs)
> +			    const frame_info_ptr &frame, int regno, int cpregs)
>  {
>    if (regno < 0)
>      {
> diff --git a/gdb/hppa-bsd-tdep.c b/gdb/hppa-bsd-tdep.c
> index 78e3f3eb6727..b1df3d17aa4d 100644
> --- a/gdb/hppa-bsd-tdep.c
> +++ b/gdb/hppa-bsd-tdep.c
> @@ -104,7 +104,7 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
>  static void
>  hppabsd_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			       struct dwarf2_frame_state_reg *reg,
> -			       frame_info_ptr this_frame)
> +			       const frame_info_ptr &this_frame)
>  {
>    if (regnum == HPPA_PCOQ_HEAD_REGNUM)
>      reg->how = DWARF2_FRAME_REG_RA;
> diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c
> index 4f94b4168107..db0c36801316 100644
> --- a/gdb/hppa-linux-tdep.c
> +++ b/gdb/hppa-linux-tdep.c
> @@ -193,7 +193,7 @@ struct hppa_linux_sigtramp_unwind_cache
>  };
>  
>  static struct hppa_linux_sigtramp_unwind_cache *
> -hppa_linux_sigtramp_frame_unwind_cache (frame_info_ptr this_frame,
> +hppa_linux_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
>  					void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -268,7 +268,7 @@ hppa_linux_sigtramp_frame_unwind_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -hppa_linux_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +hppa_linux_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				   void **this_prologue_cache,
>  				   struct frame_id *this_id)
>  {
> @@ -278,7 +278,7 @@ hppa_linux_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -hppa_linux_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +hppa_linux_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  					 void **this_prologue_cache,
>  					 int regnum)
>  {
> @@ -296,7 +296,7 @@ hppa_linux_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>     we can find the beginning of the struct rt_sigframe.  */
>  static int
>  hppa_linux_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				   frame_info_ptr this_frame,
> +				   const frame_info_ptr &this_frame,
>  				   void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> diff --git a/gdb/hppa-netbsd-tdep.c b/gdb/hppa-netbsd-tdep.c
> index f6995e77b2af..ccf32c790906 100644
> --- a/gdb/hppa-netbsd-tdep.c
> +++ b/gdb/hppa-netbsd-tdep.c
> @@ -64,7 +64,7 @@ static int hppanbsd_mc_reg_offset[] =
>  };
>  
>  static void hppanbsd_sigtramp_cache_init (const struct tramp_frame *,
> -					 frame_info_ptr,
> +					 const frame_info_ptr &,
>  					 struct trad_frame_cache *,
>  					 CORE_ADDR);
>  
> @@ -99,7 +99,7 @@ static const struct tramp_frame hppanbsd_sigtramp_si4 =
>  
>  static void
>  hppanbsd_sigtramp_cache_init (const struct tramp_frame *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     struct trad_frame_cache *this_cache,
>  			     CORE_ADDR func)
>  {
> diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
> index 32e46b831cbc..ab7dd56a240d 100644
> --- a/gdb/hppa-tdep.c
> +++ b/gdb/hppa-tdep.c
> @@ -1829,7 +1829,7 @@ hppa_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>  /* Return an unwind entry that falls within the frame's code block.  */
>  
>  static struct unwind_table_entry *
> -hppa_find_unwind_entry_in_block (frame_info_ptr this_frame)
> +hppa_find_unwind_entry_in_block (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_address_in_block (this_frame);
>  
> @@ -1850,7 +1850,7 @@ struct hppa_frame_cache
>  };
>  
>  static struct hppa_frame_cache *
> -hppa_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +hppa_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -2251,7 +2251,7 @@ hppa_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -hppa_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +hppa_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		    struct frame_id *this_id)
>  {
>    struct hppa_frame_cache *info;
> @@ -2264,7 +2264,7 @@ hppa_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -hppa_frame_prev_register (frame_info_ptr this_frame,
> +hppa_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **this_cache, int regnum)
>  {
>    struct hppa_frame_cache *info = hppa_frame_cache (this_frame, this_cache);
> @@ -2275,7 +2275,7 @@ hppa_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  hppa_frame_unwind_sniffer (const struct frame_unwind *self,
> -			   frame_info_ptr this_frame, void **this_cache)
> +			   const frame_info_ptr &this_frame, void **this_cache)
>  {
>    if (hppa_find_unwind_entry_in_block (this_frame))
>      return 1;
> @@ -2303,7 +2303,7 @@ static const struct frame_unwind hppa_frame_unwind =
>     identify the stack and pc for the frame.  */
>  
>  static struct hppa_frame_cache *
> -hppa_fallback_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +hppa_fallback_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -2376,7 +2376,7 @@ hppa_fallback_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -hppa_fallback_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +hppa_fallback_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			     struct frame_id *this_id)
>  {
>    struct hppa_frame_cache *info = 
> @@ -2386,7 +2386,7 @@ hppa_fallback_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -hppa_fallback_frame_prev_register (frame_info_ptr this_frame,
> +hppa_fallback_frame_prev_register (const frame_info_ptr &this_frame,
>  				   void **this_cache, int regnum)
>  {
>    struct hppa_frame_cache *info
> @@ -2415,7 +2415,7 @@ struct hppa_stub_unwind_cache
>  };
>  
>  static struct hppa_stub_unwind_cache *
> -hppa_stub_frame_unwind_cache (frame_info_ptr this_frame,
> +hppa_stub_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			      void **this_cache)
>  {
>    struct hppa_stub_unwind_cache *info;
> @@ -2436,7 +2436,7 @@ hppa_stub_frame_unwind_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -hppa_stub_frame_this_id (frame_info_ptr this_frame,
> +hppa_stub_frame_this_id (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache,
>  			 struct frame_id *this_id)
>  {
> @@ -2448,7 +2448,7 @@ hppa_stub_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -hppa_stub_frame_prev_register (frame_info_ptr this_frame,
> +hppa_stub_frame_prev_register (const frame_info_ptr &this_frame,
>  			       void **this_prologue_cache, int regnum)
>  {
>    struct hppa_stub_unwind_cache *info
> @@ -2463,7 +2463,7 @@ hppa_stub_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  hppa_stub_unwind_sniffer (const struct frame_unwind *self,
> -			  frame_info_ptr this_frame,
> +			  const frame_info_ptr &this_frame,
>  			  void **this_cache)
>  {
>    CORE_ADDR pc = get_frame_address_in_block (this_frame);
> @@ -2489,7 +2489,7 @@ static const struct frame_unwind hppa_stub_frame_unwind = {
>  };
>  
>  CORE_ADDR
> -hppa_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +hppa_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    ULONGEST ipsw;
>    CORE_ADDR pc;
> @@ -2675,7 +2675,7 @@ hppa_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
>  /* Get the ARGIth function argument for the current function.  */
>  
>  static CORE_ADDR
> -hppa_fetch_pointer_argument (frame_info_ptr frame, int argi, 
> +hppa_fetch_pointer_argument (const frame_info_ptr &frame, int argi, 

Trailing white space.

>  			     struct type *type)
>  {
>    return get_frame_register_unsigned (frame, HPPA_R0_REGNUM + 26 - argi);
> @@ -2706,7 +2706,7 @@ hppa_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
>  }
>  
>  struct value *
> -hppa_frame_prev_register_helper (frame_info_ptr this_frame,
> +hppa_frame_prev_register_helper (const frame_info_ptr &this_frame,
>  				 trad_frame_saved_reg saved_regs[],
>  				 int regnum)
>  {
> @@ -2884,7 +2884,7 @@ hppa_in_solib_call_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc)
>     systems: $$dyncall, import stubs and PLT stubs.  */
>  
>  CORE_ADDR
> -hppa_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +hppa_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
> diff --git a/gdb/hppa-tdep.h b/gdb/hppa-tdep.h
> index 2372dd6dd12d..0f706536cc9d 100644
> --- a/gdb/hppa-tdep.h
> +++ b/gdb/hppa-tdep.h
> @@ -109,7 +109,7 @@ struct hppa_gdbarch_tdep : gdbarch_tdep_base
>       not interested in them.  If we detect that we are returning to a stub,
>       adjust the pc to the real caller.  This improves the behavior of commands
>       that traverse frames such as "up" and "finish".  */
> -  void (*unwind_adjust_stub) (frame_info_ptr this_frame, CORE_ADDR base,
> +  void (*unwind_adjust_stub) (const frame_info_ptr &this_frame, CORE_ADDR base,
>  			      trad_frame_saved_reg *saved_regs) = nullptr;
>  
>    /* These are solib-dependent methods.  They are really HPUX only, but
> @@ -201,17 +201,17 @@ int hppa_extract_14 (unsigned);
>  CORE_ADDR hppa_symbol_address(const char *sym);
>  
>  extern struct value *
> -  hppa_frame_prev_register_helper (frame_info_ptr this_frame,
> +  hppa_frame_prev_register_helper (const frame_info_ptr &this_frame,
>  				   trad_frame_saved_reg *saved_regs,
>  				   int regnum);
>  
>  extern CORE_ADDR hppa_read_pc (struct regcache *regcache);
>  extern void hppa_write_pc (struct regcache *regcache, CORE_ADDR pc);
>  extern CORE_ADDR hppa_unwind_pc (struct gdbarch *gdbarch,
> -				 frame_info_ptr next_frame);
> +				 const frame_info_ptr &next_frame);
>  
>  extern int hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
>  					  CORE_ADDR pc);
> -extern CORE_ADDR hppa_skip_trampoline_code (frame_info_ptr, CORE_ADDR pc);
> +extern CORE_ADDR hppa_skip_trampoline_code (const frame_info_ptr &, CORE_ADDR pc);
>  
>  #endif  /* hppa-tdep.h */
> diff --git a/gdb/i386-bsd-tdep.c b/gdb/i386-bsd-tdep.c
> index eb20bc6e2b54..8470f2b6d2f9 100644
> --- a/gdb/i386-bsd-tdep.c
> +++ b/gdb/i386-bsd-tdep.c
> @@ -32,7 +32,7 @@
>     address of the associated sigcontext structure.  */
>  
>  static CORE_ADDR
> -i386bsd_sigcontext_addr (frame_info_ptr this_frame)
> +i386bsd_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
> index 8da6b4df2b78..fc0a3dd3909e 100644
> --- a/gdb/i386-darwin-tdep.c
> +++ b/gdb/i386-darwin-tdep.c
> @@ -66,7 +66,7 @@ const int i386_darwin_thread_state_num_regs =
>     address of the associated sigcontext structure.  */
>  
>  static CORE_ADDR
> -i386_darwin_sigcontext_addr (frame_info_ptr this_frame)
> +i386_darwin_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -99,7 +99,7 @@ i386_darwin_sigcontext_addr (frame_info_ptr this_frame)
>  
>  int
>  darwin_dwarf_signal_frame_p (struct gdbarch *gdbarch,
> -			     frame_info_ptr this_frame)
> +			     const frame_info_ptr &this_frame)
>  {
>    return i386_sigtramp_p (this_frame);
>  }
> diff --git a/gdb/i386-darwin-tdep.h b/gdb/i386-darwin-tdep.h
> index 8f955f6828b7..0b867fab94c1 100644
> --- a/gdb/i386-darwin-tdep.h
> +++ b/gdb/i386-darwin-tdep.h
> @@ -27,6 +27,6 @@
>  extern int i386_darwin_thread_state_reg_offset[];
>  extern const int i386_darwin_thread_state_num_regs;
>  
> -int darwin_dwarf_signal_frame_p (struct gdbarch *, frame_info_ptr);
> +int darwin_dwarf_signal_frame_p (struct gdbarch *, const frame_info_ptr &);
>  
>  #endif /* I386_DARWIN_TDEP_H */
> diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c
> index ea1db3abd6ba..2b9ef77e5e6d 100644
> --- a/gdb/i386-fbsd-tdep.c
> +++ b/gdb/i386-fbsd-tdep.c
> @@ -156,7 +156,7 @@ const struct regset i386_fbsd_segbases_regset =
>  
>  static void
>  i386_fbsd_sigframe_init (const struct tramp_frame *self,
> -			 frame_info_ptr this_frame,
> +			 const frame_info_ptr &this_frame,
>  			 struct trad_frame_cache *this_cache,
>  			 CORE_ADDR func)
>  {
> diff --git a/gdb/i386-gnu-tdep.c b/gdb/i386-gnu-tdep.c
> index 9ff471475131..aa1898693b61 100644
> --- a/gdb/i386-gnu-tdep.c
> +++ b/gdb/i386-gnu-tdep.c
> @@ -56,7 +56,7 @@ static const gdb_byte gnu_sigtramp_code[] =
>     start of the routine.  Otherwise, return 0.  */
>  
>  static CORE_ADDR
> -i386_gnu_sigtramp_start (frame_info_ptr this_frame)
> +i386_gnu_sigtramp_start (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    gdb_byte buf[GNU_SIGTRAMP_LEN];
> @@ -76,7 +76,7 @@ i386_gnu_sigtramp_start (frame_info_ptr this_frame)
>     routine.  */
>  
>  static int
> -i386_gnu_sigtramp_p (frame_info_ptr this_frame)
> +i386_gnu_sigtramp_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    const char *name;
> @@ -97,7 +97,7 @@ i386_gnu_sigtramp_p (frame_info_ptr this_frame)
>     address of the associated sigcontext structure.  */
>  
>  static CORE_ADDR
> -i386_gnu_sigcontext_addr (frame_info_ptr this_frame)
> +i386_gnu_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
> index 996dda0077f8..a2f937690c2e 100644
> --- a/gdb/i386-linux-tdep.c
> +++ b/gdb/i386-linux-tdep.c
> @@ -122,7 +122,7 @@ static const gdb_byte linux_sigtramp_code[] =
>     start of the routine.  Otherwise, return 0.  */
>  
>  static CORE_ADDR
> -i386_linux_sigtramp_start (frame_info_ptr this_frame)
> +i386_linux_sigtramp_start (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    gdb_byte buf[LINUX_SIGTRAMP_LEN];
> @@ -190,7 +190,7 @@ static const gdb_byte linux_rt_sigtramp_code[] =
>     start of the routine.  Otherwise, return 0.  */
>  
>  static CORE_ADDR
> -i386_linux_rt_sigtramp_start (frame_info_ptr this_frame)
> +i386_linux_rt_sigtramp_start (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    gdb_byte buf[LINUX_RT_SIGTRAMP_LEN];
> @@ -227,7 +227,7 @@ i386_linux_rt_sigtramp_start (frame_info_ptr this_frame)
>     routine.  */
>  
>  static int
> -i386_linux_sigtramp_p (frame_info_ptr this_frame)
> +i386_linux_sigtramp_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    const char *name;
> @@ -252,7 +252,7 @@ i386_linux_sigtramp_p (frame_info_ptr this_frame)
>  
>  static int
>  i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
> -				 frame_info_ptr this_frame)
> +				 const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    const char *name;
> @@ -275,7 +275,7 @@ i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
>     address of the associated sigcontext structure.  */
>  
>  static CORE_ADDR
> -i386_linux_sigcontext_addr (frame_info_ptr this_frame)
> +i386_linux_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> diff --git a/gdb/i386-netbsd-tdep.c b/gdb/i386-netbsd-tdep.c
> index 270413e59d87..9596435e9d10 100644
> --- a/gdb/i386-netbsd-tdep.c
> +++ b/gdb/i386-netbsd-tdep.c
> @@ -97,7 +97,7 @@ static int i386nbsd_mc_reg_offset[] =
>  };
>  
>  static void i386nbsd_sigtramp_cache_init (const struct tramp_frame *,
> -					  frame_info_ptr,
> +					  const frame_info_ptr &,
>  					  struct trad_frame_cache *,
>  					  CORE_ADDR);
>  
> @@ -329,7 +329,7 @@ static const struct tramp_frame i386nbsd_sigtramp_si4 =
>  
>  static void
>  i386nbsd_sigtramp_cache_init (const struct tramp_frame *self,
> -			      frame_info_ptr this_frame,
> +			      const frame_info_ptr &this_frame,
>  			      struct trad_frame_cache *this_cache,
>  			      CORE_ADDR func)
>  {
> diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c
> index 5e959df4df36..f4bb70cc5a08 100644
> --- a/gdb/i386-nto-tdep.c
> +++ b/gdb/i386-nto-tdep.c
> @@ -270,7 +270,7 @@ i386nto_regset_fill (const struct regcache *regcache, int regset, char *data)
>     routine.  */
>  
>  static int
> -i386nto_sigtramp_p (frame_info_ptr this_frame)
> +i386nto_sigtramp_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    const char *name;
> @@ -283,7 +283,7 @@ i386nto_sigtramp_p (frame_info_ptr this_frame)
>     address of the associated sigcontext structure.  */
>  
>  static CORE_ADDR
> -i386nto_sigcontext_addr (frame_info_ptr this_frame)
> +i386nto_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> diff --git a/gdb/i386-obsd-tdep.c b/gdb/i386-obsd-tdep.c
> index 38ba280e4056..e1480ec6cc41 100644
> --- a/gdb/i386-obsd-tdep.c
> +++ b/gdb/i386-obsd-tdep.c
> @@ -64,7 +64,7 @@ static const int i386obsd_sigreturn_offset[] = {
>     routine.  */
>  
>  static int
> -i386obsd_sigtramp_p (frame_info_ptr this_frame)
> +i386obsd_sigtramp_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    CORE_ADDR start_pc = (pc & ~(i386obsd_page_size - 1));
> @@ -303,7 +303,7 @@ static int i386obsd_tf_reg_offset[] =
>  };
>  
>  static struct trad_frame_cache *
> -i386obsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
> +i386obsd_trapframe_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -350,7 +350,7 @@ i386obsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -i386obsd_trapframe_this_id (frame_info_ptr this_frame,
> +i386obsd_trapframe_this_id (const frame_info_ptr &this_frame,
>  			    void **this_cache, struct frame_id *this_id)
>  {
>    struct trad_frame_cache *cache =
> @@ -360,7 +360,7 @@ i386obsd_trapframe_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -i386obsd_trapframe_prev_register (frame_info_ptr this_frame,
> +i386obsd_trapframe_prev_register (const frame_info_ptr &this_frame,
>  				  void **this_cache, int regnum)
>  {
>    struct trad_frame_cache *cache =
> @@ -371,7 +371,7 @@ i386obsd_trapframe_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  i386obsd_trapframe_sniffer (const struct frame_unwind *self,
> -			    frame_info_ptr this_frame,
> +			    const frame_info_ptr &this_frame,
>  			    void **this_prologue_cache)
>  {
>    ULONGEST cs;
> diff --git a/gdb/i386-sol2-tdep.c b/gdb/i386-sol2-tdep.c
> index ae4e2946789c..bc8df378219d 100644
> --- a/gdb/i386-sol2-tdep.c
> +++ b/gdb/i386-sol2-tdep.c
> @@ -50,7 +50,7 @@ static int i386_sol2_gregset_reg_offset[] =
>     `mcontext_t' that contains the saved set of machine registers.  */
>  
>  static CORE_ADDR
> -i386_sol2_mcontext_addr (frame_info_ptr this_frame)
> +i386_sol2_mcontext_addr (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR sp, ucontext_addr;
>  
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index d8691f038454..b487a3f74788 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -1965,7 +1965,7 @@ i386_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>  /* This function is 64-bit safe.  */
>  
>  static CORE_ADDR
> -i386_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +i386_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    gdb_byte buf[8];
>  
> @@ -1977,7 +1977,7 @@ i386_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  /* Normal frames.  */
>  
>  static void
> -i386_frame_cache_1 (frame_info_ptr this_frame,
> +i386_frame_cache_1 (const frame_info_ptr &this_frame,
>  		    struct i386_frame_cache *cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2078,7 +2078,7 @@ i386_frame_cache_1 (frame_info_ptr this_frame,
>  }
>  
>  static struct i386_frame_cache *
> -i386_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +i386_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct i386_frame_cache *cache;
>  
> @@ -2102,7 +2102,7 @@ i386_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -i386_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +i386_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		    struct frame_id *this_id)
>  {
>    struct i386_frame_cache *cache = i386_frame_cache (this_frame, this_cache);
> @@ -2121,7 +2121,7 @@ i386_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static enum unwind_stop_reason
> -i386_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +i386_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  			       void **this_cache)
>  {
>    struct i386_frame_cache *cache = i386_frame_cache (this_frame, this_cache);
> @@ -2137,7 +2137,7 @@ i386_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -i386_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +i386_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			  int regnum)
>  {
>    struct i386_frame_cache *cache = i386_frame_cache (this_frame, this_cache);
> @@ -2230,7 +2230,7 @@ i386_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
>  
>  static int
>  i386_epilogue_frame_sniffer_1 (const struct frame_unwind *self,
> -			       frame_info_ptr this_frame,
> +			       const frame_info_ptr &this_frame,
>  			       void **this_prologue_cache, bool override_p)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2263,7 +2263,7 @@ i386_epilogue_frame_sniffer_1 (const struct frame_unwind *self,
>  
>  static int
>  i386_epilogue_override_frame_sniffer (const struct frame_unwind *self,
> -				      frame_info_ptr this_frame,
> +				      const frame_info_ptr &this_frame,
>  				      void **this_prologue_cache)
>  {
>    return i386_epilogue_frame_sniffer_1 (self, this_frame, this_prologue_cache,
> @@ -2272,7 +2272,7 @@ i386_epilogue_override_frame_sniffer (const struct frame_unwind *self,
>  
>  static int
>  i386_epilogue_frame_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache)
>  {
>    return i386_epilogue_frame_sniffer_1 (self, this_frame, this_prologue_cache,
> @@ -2280,7 +2280,7 @@ i386_epilogue_frame_sniffer (const struct frame_unwind *self,
>  }
>  
>  static struct i386_frame_cache *
> -i386_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +i386_epilogue_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct i386_frame_cache *cache;
>    CORE_ADDR sp;
> @@ -2315,7 +2315,7 @@ i386_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static enum unwind_stop_reason
> -i386_epilogue_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +i386_epilogue_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  					void **this_cache)
>  {
>    struct i386_frame_cache *cache =
> @@ -2328,7 +2328,7 @@ i386_epilogue_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  }
>  
>  static void
> -i386_epilogue_frame_this_id (frame_info_ptr this_frame,
> +i386_epilogue_frame_this_id (const frame_info_ptr &this_frame,
>  			     void **this_cache,
>  			     struct frame_id *this_id)
>  {
> @@ -2342,7 +2342,7 @@ i386_epilogue_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -i386_epilogue_frame_prev_register (frame_info_ptr this_frame,
> +i386_epilogue_frame_prev_register (const frame_info_ptr &this_frame,
>  				   void **this_cache, int regnum)
>  {
>    /* Make sure we've initialized the cache.  */
> @@ -2435,7 +2435,7 @@ i386_in_stack_tramp_p (CORE_ADDR pc)
>  
>  static int
>  i386_stack_tramp_frame_sniffer (const struct frame_unwind *self,
> -				frame_info_ptr this_frame,
> +				const frame_info_ptr &this_frame,
>  				void **this_cache)
>  {
>    if (frame_relative_level (this_frame) == 0)
> @@ -2475,7 +2475,7 @@ i386_gen_return_address (struct gdbarch *gdbarch,
>  /* Signal trampolines.  */
>  
>  static struct i386_frame_cache *
> -i386_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +i386_sigtramp_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> @@ -2524,7 +2524,7 @@ i386_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static enum unwind_stop_reason
> -i386_sigtramp_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +i386_sigtramp_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  					void **this_cache)
>  {
>    struct i386_frame_cache *cache =
> @@ -2537,7 +2537,7 @@ i386_sigtramp_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  }
>  
>  static void
> -i386_sigtramp_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +i386_sigtramp_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			     struct frame_id *this_id)
>  {
>    struct i386_frame_cache *cache =
> @@ -2553,7 +2553,7 @@ i386_sigtramp_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -i386_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +i386_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  				   void **this_cache, int regnum)
>  {
>    /* Make sure we've initialized the cache.  */
> @@ -2564,7 +2564,7 @@ i386_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  i386_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache)
>  {
>    gdbarch *arch = get_frame_arch (this_frame);
> @@ -2606,7 +2606,7 @@ static const struct frame_unwind i386_sigtramp_frame_unwind =
>  \f
>  
>  static CORE_ADDR
> -i386_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +i386_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct i386_frame_cache *cache = i386_frame_cache (this_frame, this_cache);
>  
> @@ -2622,7 +2622,7 @@ static const struct frame_base i386_frame_base =
>  };
>  
>  static struct frame_id
> -i386_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +i386_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR fp;
>  
> @@ -2649,7 +2649,7 @@ i386_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
>     success.  */
>  
>  static int
> -i386_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +i386_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    gdb_byte buf[4];
>    CORE_ADDR sp, jb_addr;
> @@ -3395,7 +3395,7 @@ i386_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
>     the MMX registers need to be mapped onto floating point registers.  */
>  
>  static int
> -i386_mmx_regnum_to_fp_regnum (frame_info_ptr next_frame, int regnum)
> +i386_mmx_regnum_to_fp_regnum (const frame_info_ptr &next_frame, int regnum)
>  {
>    gdbarch *arch = frame_unwind_arch (next_frame);
>    i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
> @@ -3413,7 +3413,7 @@ i386_mmx_regnum_to_fp_regnum (frame_info_ptr next_frame, int regnum)
>     the data into an already-allocated value.  */
>  
>  value *
> -i386_pseudo_register_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
> +i386_pseudo_register_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  				 const int pseudo_reg_num)
>  {
>    if (i386_mmx_regnum_p (gdbarch, pseudo_reg_num))
> @@ -3517,7 +3517,7 @@ i386_pseudo_register_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
>  }
>  
>  void
> -i386_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame,
> +i386_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>  			    const int pseudo_reg_num,
>  			    gdb::array_view<const gdb_byte> buf)
>  {
> @@ -3750,7 +3750,7 @@ i386_convert_register_p (struct gdbarch *gdbarch,
>     return its contents in TO.  */
>  
>  static int
> -i386_register_to_value (frame_info_ptr frame, int regnum,
> +i386_register_to_value (const frame_info_ptr &frame, int regnum,
>  			struct type *type, gdb_byte *to,
>  			int *optimizedp, int *unavailablep)
>  {
> @@ -3790,7 +3790,7 @@ i386_register_to_value (frame_info_ptr frame, int regnum,
>     REGNUM in frame FRAME.  */
>  
>  static void
> -i386_value_to_register (frame_info_ptr frame, int regnum,
> +i386_value_to_register (const frame_info_ptr &frame, int regnum,
>  			struct type *type, const gdb_byte *from)
>  {
>    int len = type->length ();
> @@ -3944,7 +3944,7 @@ i386_iterate_over_regset_sections (struct gdbarch *gdbarch,
>  /* Stuff for WIN32 PE style DLL's but is pretty generic really.  */
>  
>  CORE_ADDR
> -i386_pe_skip_trampoline_code (frame_info_ptr frame,
> +i386_pe_skip_trampoline_code (const frame_info_ptr &frame,
>  			      CORE_ADDR pc, char *name)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -3975,7 +3975,7 @@ i386_pe_skip_trampoline_code (frame_info_ptr frame,
>     routine.  */
>  
>  int
> -i386_sigtramp_p (frame_info_ptr this_frame)
> +i386_sigtramp_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    const char *name;
> @@ -4011,7 +4011,7 @@ i386_print_insn (bfd_vma pc, struct disassemble_info *info)
>     routine.  */
>  
>  static int
> -i386_svr4_sigtramp_p (frame_info_ptr this_frame)
> +i386_svr4_sigtramp_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    const char *name;
> @@ -4026,7 +4026,7 @@ i386_svr4_sigtramp_p (frame_info_ptr this_frame)
>     address of the associated sigcontext (ucontext) structure.  */
>  
>  static CORE_ADDR
> -i386_svr4_sigcontext_addr (frame_info_ptr this_frame)
> +i386_svr4_sigcontext_addr (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -4582,7 +4582,7 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
>  /* Get the ARGIth function argument for the current function.  */
>  
>  static CORE_ADDR
> -i386_fetch_pointer_argument (frame_info_ptr frame, int argi,
> +i386_fetch_pointer_argument (const frame_info_ptr &frame, int argi,
>  			     struct type *type)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
> index e7699f0f1894..a85e0a984a0f 100644
> --- a/gdb/i386-tdep.h
> +++ b/gdb/i386-tdep.h
> @@ -227,10 +227,10 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
>    CORE_ADDR sigtramp_end = 0;
>  
>    /* Detect sigtramp.  */
> -  int (*sigtramp_p) (frame_info_ptr) = nullptr;
> +  int (*sigtramp_p) (const frame_info_ptr &) = nullptr;
>  
>    /* Get address of sigcontext for sigtramp.  */
> -  CORE_ADDR (*sigcontext_addr) (frame_info_ptr) = nullptr;
> +  CORE_ADDR (*sigcontext_addr) (const frame_info_ptr &) = nullptr;
>  
>    /* Offset of registers in `struct sigcontext'.  */
>    int *sc_reg_offset = 0;
> @@ -377,11 +377,11 @@ extern struct type *i386_pseudo_register_type (struct gdbarch *gdbarch,
>  					       int regnum);
>  
>  extern value *i386_pseudo_register_read_value (gdbarch *gdbarch,
> -					       frame_info_ptr next_frame,
> +					       const frame_info_ptr &next_frame,
>  					       int regnum);
>  
>  extern void i386_pseudo_register_write (gdbarch *gdbarch,
> -					frame_info_ptr next_frame, int regnum,
> +					const frame_info_ptr &next_frame, int regnum,
>  					gdb::array_view<const gdb_byte> buf);
>  
>  extern int i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
> @@ -398,7 +398,7 @@ extern int i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
>  #define I386_MAX_INSN_LEN (16)
>  
>  /* Functions exported from i386-tdep.c.  */
> -extern CORE_ADDR i386_pe_skip_trampoline_code (frame_info_ptr frame,
> +extern CORE_ADDR i386_pe_skip_trampoline_code (const frame_info_ptr &frame,
>  					       CORE_ADDR pc, char *name);
>  extern CORE_ADDR i386_skip_main_prologue (struct gdbarch *gdbarch,
>  					  CORE_ADDR pc);
> @@ -417,7 +417,7 @@ extern CORE_ADDR i386_thiscall_push_dummy_call (struct gdbarch *gdbarch,
>  						bool thiscall);
>  
>  /* Return whether the THIS_FRAME corresponds to a sigtramp routine.  */
> -extern int i386_sigtramp_p (frame_info_ptr this_frame);
> +extern int i386_sigtramp_p (const frame_info_ptr &this_frame);
>  
>  /* Return non-zero if REGNUM is a member of the specified group.  */
>  extern int i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
> diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c
> index f1cc10fe3c55..cd5c580a3e8d 100644
> --- a/gdb/i386-windows-tdep.c
> +++ b/gdb/i386-windows-tdep.c
> @@ -90,7 +90,7 @@ static int i386_windows_gregset_reg_offset[] =
>  #define I386_WINDOWS_SIZEOF_GREGSET 716
>  
>  static CORE_ADDR
> -i386_windows_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +i386_windows_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    return i386_pe_skip_trampoline_code (frame, pc, NULL);
>  }
> diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
> index d73e3ba40ae1..3d979e279a1e 100644
> --- a/gdb/i387-tdep.c
> +++ b/gdb/i387-tdep.c
> @@ -202,7 +202,7 @@ print_i387_control_word (int control_p,
>  
>  void
>  i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
> -		       frame_info_ptr frame, const char *args)
> +		       const frame_info_ptr &frame, const char *args)
>  {
>    i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
>    ULONGEST fctrl;
> @@ -345,7 +345,7 @@ i387_convert_register_p (struct gdbarch *gdbarch, int regnum,
>     return its contents in TO.  */
>  
>  int
> -i387_register_to_value (frame_info_ptr frame, int regnum,
> +i387_register_to_value (const frame_info_ptr &frame, int regnum,
>  			struct type *type, gdb_byte *to,
>  			int *optimizedp, int *unavailablep)
>  {
> @@ -380,7 +380,7 @@ i387_register_to_value (frame_info_ptr frame, int regnum,
>     REGNUM in frame FRAME.  */
>  
>  void
> -i387_value_to_register (frame_info_ptr frame, int regnum,
> +i387_value_to_register (const frame_info_ptr &frame, int regnum,
>  			struct type *type, const gdb_byte *from)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h
> index aa1cce7d9523..30d769478a6c 100644
> --- a/gdb/i387-tdep.h
> +++ b/gdb/i387-tdep.h
> @@ -90,7 +90,7 @@ struct x86_xsave_layout;
>  
>  extern void i387_print_float_info (struct gdbarch *gdbarch,
>  				   struct ui_file *file,
> -				   frame_info_ptr frame,
> +				   const frame_info_ptr &frame,
>  				   const char *args);
>  
>  /* Return nonzero if a value of type TYPE stored in register REGNUM
> @@ -102,14 +102,14 @@ extern int i387_convert_register_p (struct gdbarch *gdbarch, int regnum,
>  /* Read a value of type TYPE from register REGNUM in frame FRAME, and
>     return its contents in TO.  */
>  
> -extern int i387_register_to_value (frame_info_ptr frame, int regnum,
> +extern int i387_register_to_value (const frame_info_ptr &frame, int regnum,
>  				   struct type *type, gdb_byte *to,
>  				   int *optimizedp, int *unavailablep);
>  
>  /* Write the contents FROM of a value of type TYPE into register
>     REGNUM in frame FRAME.  */
>  
> -extern void i387_value_to_register (frame_info_ptr frame, int regnum,
> +extern void i387_value_to_register (const frame_info_ptr &frame, int regnum,
>  				    struct type *type, const gdb_byte *from);
>  \f
>  
> diff --git a/gdb/ia64-libunwind-tdep.c b/gdb/ia64-libunwind-tdep.c
> index a61e90fc5bea..24a5162cdc65 100644
> --- a/gdb/ia64-libunwind-tdep.c
> +++ b/gdb/ia64-libunwind-tdep.c
> @@ -153,7 +153,7 @@ libunwind_frame_set_descr (struct gdbarch *gdbarch,
>  }
>  
>  static struct libunwind_frame_cache *
> -libunwind_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +libunwind_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    unw_accessors_t *acc;
>    unw_addr_space_t as;
> @@ -247,7 +247,7 @@ libunwind_find_dyn_list (unw_addr_space_t as, unw_dyn_info_t *di, void *arg)
>     libunwind frame unwinding.  */
>  int
>  libunwind_frame_sniffer (const struct frame_unwind *self,
> -			 frame_info_ptr this_frame, void **this_cache)
> +			 const frame_info_ptr &this_frame, void **this_cache)
>  {
>    unw_cursor_t cursor;
>    unw_accessors_t *acc;
> @@ -292,7 +292,7 @@ libunwind_frame_sniffer (const struct frame_unwind *self,
>  }
>  
>  void
> -libunwind_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +libunwind_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			 struct frame_id *this_id)
>  {
>    struct libunwind_frame_cache *cache =
> @@ -303,7 +303,7 @@ libunwind_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  struct value *
> -libunwind_frame_prev_register (frame_info_ptr this_frame,
> +libunwind_frame_prev_register (const frame_info_ptr &this_frame,
>  			       void **this_cache, int regnum)
>  {
>    struct libunwind_frame_cache *cache =
> @@ -387,7 +387,7 @@ libunwind_search_unwind_table (void *as, long ip, void *di,
>  /* Verify if we are in a sigtramp frame and we can use libunwind to unwind.  */
>  int
>  libunwind_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				  frame_info_ptr this_frame,
> +				  const frame_info_ptr &this_frame,
>  				  void **this_cache)
>  {
>    unw_cursor_t cursor;
> diff --git a/gdb/ia64-libunwind-tdep.h b/gdb/ia64-libunwind-tdep.h
> index e490e839fc27..4f064bfc333f 100644
> --- a/gdb/ia64-libunwind-tdep.h
> +++ b/gdb/ia64-libunwind-tdep.h
> @@ -48,19 +48,19 @@ struct libunwind_descr
>  };
>  
>  int libunwind_frame_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_cache);
>  			  
>  int libunwind_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				      frame_info_ptr this_frame,
> +				      const frame_info_ptr &this_frame,
>  				      void **this_cache);
>  
>  void libunwind_frame_set_descr (struct gdbarch *arch,
>  				struct libunwind_descr *descr);
>  
> -void libunwind_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +void libunwind_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			      struct frame_id *this_id);
> -struct value *libunwind_frame_prev_register (frame_info_ptr this_frame,
> +struct value *libunwind_frame_prev_register (const frame_info_ptr &this_frame,
>  					     void **this_cache, int regnum);
>  void libunwind_frame_dealloc_cache (frame_info_ptr self, void *cache);
>  
> diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
> index afff210986ba..88f67ccf0962 100644
> --- a/gdb/ia64-tdep.c
> +++ b/gdb/ia64-tdep.c
> @@ -1219,7 +1219,7 @@ ia64_convert_register_p (struct gdbarch *gdbarch, int regno, struct type *type)
>  }
>  
>  static int
> -ia64_register_to_value (frame_info_ptr frame, int regnum,
> +ia64_register_to_value (const frame_info_ptr &frame, int regnum,
>  			struct type *valtype, gdb_byte *out,
>  			int *optimizedp, int *unavailablep)
>  {
> @@ -1239,7 +1239,7 @@ ia64_register_to_value (frame_info_ptr frame, int regnum,
>  }
>  
>  static void
> -ia64_value_to_register (frame_info_ptr frame, int regnum,
> +ia64_value_to_register (const frame_info_ptr &frame, int regnum,
>  			 struct type *valtype, const gdb_byte *in)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -1361,7 +1361,7 @@ ia64_alloc_frame_cache (void)
>  
>  static CORE_ADDR
>  examine_prologue (CORE_ADDR pc, CORE_ADDR lim_pc,
> -		  frame_info_ptr this_frame,
> +		  const frame_info_ptr &this_frame,
>  		  struct ia64_frame_cache *cache)
>  {
>    CORE_ADDR next_pc;
> @@ -1842,7 +1842,7 @@ ia64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>  /* Normal frames.  */
>  
>  static struct ia64_frame_cache *
> -ia64_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +ia64_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -1887,7 +1887,7 @@ ia64_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -ia64_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +ia64_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		    struct frame_id *this_id)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1908,7 +1908,7 @@ ia64_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -ia64_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +ia64_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			  int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2176,7 +2176,7 @@ static const struct frame_unwind ia64_frame_unwind =
>  /* Signal trampolines.  */
>  
>  static void
> -ia64_sigtramp_frame_init_saved_regs (frame_info_ptr this_frame,
> +ia64_sigtramp_frame_init_saved_regs (const frame_info_ptr &this_frame,
>  				     struct ia64_frame_cache *cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2230,7 +2230,7 @@ ia64_sigtramp_frame_init_saved_regs (frame_info_ptr this_frame,
>  }
>  
>  static struct ia64_frame_cache *
> -ia64_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +ia64_sigtramp_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -2261,7 +2261,7 @@ ia64_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -ia64_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +ia64_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  			     void **this_cache, struct frame_id *this_id)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2282,7 +2282,7 @@ ia64_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -ia64_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +ia64_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  				   void **this_cache, int regnum)
>  {
>    struct ia64_frame_cache *cache =
> @@ -2335,7 +2335,7 @@ ia64_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  ia64_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_cache)
>  {
>    gdbarch *arch = get_frame_arch (this_frame);
> @@ -2365,7 +2365,7 @@ static const struct frame_unwind ia64_sigtramp_frame_unwind =
>  \f
>  
>  static CORE_ADDR
> -ia64_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +ia64_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct ia64_frame_cache *cache = ia64_frame_cache (this_frame, this_cache);
>  
> @@ -2541,7 +2541,7 @@ ia64_access_fpreg (unw_addr_space_t as, unw_regnum_t uw_regnum,
>  		   unw_fpreg_t *val, int write, void *arg)
>  {
>    int regnum = ia64_uw2gdb_regnum (uw_regnum);
> -  frame_info_ptr this_frame = (frame_info_ptr) arg;
> +  frame_info_ptr this_frame = (const frame_info_ptr &) arg;
>    
>    /* We never call any libunwind routines that need to write registers.  */
>    gdb_assert (!write);
> @@ -2894,7 +2894,7 @@ ia64_get_dyn_info_list (unw_addr_space_t as,
>  /* Frame interface functions for libunwind.  */
>  
>  static void
> -ia64_libunwind_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +ia64_libunwind_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			      struct frame_id *this_id)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2928,7 +2928,7 @@ ia64_libunwind_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -ia64_libunwind_frame_prev_register (frame_info_ptr this_frame,
> +ia64_libunwind_frame_prev_register (const frame_info_ptr &this_frame,
>  				    void **this_cache, int regnum)
>  {
>    int reg = regnum;
> @@ -3001,7 +3001,7 @@ ia64_libunwind_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  ia64_libunwind_frame_sniffer (const struct frame_unwind *self,
> -			      frame_info_ptr this_frame,
> +			      const frame_info_ptr &this_frame,
>  			      void **this_cache)
>  {
>    if (libunwind_is_initialized ()
> @@ -3024,7 +3024,7 @@ static const struct frame_unwind ia64_libunwind_frame_unwind =
>  };
>  
>  static void
> -ia64_libunwind_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +ia64_libunwind_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				       void **this_cache,
>  				       struct frame_id *this_id)
>  {
> @@ -3060,7 +3060,7 @@ ia64_libunwind_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -ia64_libunwind_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +ia64_libunwind_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  					     void **this_cache, int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -3087,7 +3087,7 @@ ia64_libunwind_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  ia64_libunwind_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				       frame_info_ptr this_frame,
> +				       const frame_info_ptr &this_frame,
>  				       void **this_cache)
>  {
>    if (libunwind_is_initialized ())
> @@ -3864,7 +3864,7 @@ static const struct ia64_infcall_ops ia64_infcall_ops =
>  };
>  
>  static struct frame_id
> -ia64_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +ia64_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>    gdb_byte buf[8];
> @@ -3886,7 +3886,7 @@ ia64_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
>  }
>  
>  static CORE_ADDR 
> -ia64_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +ia64_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>    gdb_byte buf[8];
> @@ -3911,7 +3911,7 @@ ia64_print_insn (bfd_vma memaddr, struct disassemble_info *info)
>  /* The default "size_of_register_frame" gdbarch_tdep routine for ia64.  */
>  
>  static int
> -ia64_size_of_register_frame (frame_info_ptr this_frame, ULONGEST cfm)
> +ia64_size_of_register_frame (const frame_info_ptr &this_frame, ULONGEST cfm)
>  {
>    return (cfm & 0x7f);
>  }
> diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h
> index a623a7e58aef..64be38b4d766 100644
> --- a/gdb/ia64-tdep.h
> +++ b/gdb/ia64-tdep.h
> @@ -240,7 +240,7 @@ struct ia64_gdbarch_tdep : gdbarch_tdep_base
>  
>       Normally, the size of the register frame is always obtained by
>       extracting the lowest 7 bits ("cfm & 0x7f").  */
> -  int (*size_of_register_frame) (frame_info_ptr this_frame, ULONGEST cfm)
> +  int (*size_of_register_frame) (const frame_info_ptr &this_frame, ULONGEST cfm)
>      = nullptr;
>  
>    /* Determine the function address FADDR belongs to a shared library.
> diff --git a/gdb/infcmd.c b/gdb/infcmd.c
> index 4e17a6b06295..c1fdbb300c67 100644
> --- a/gdb/infcmd.c
> +++ b/gdb/infcmd.c
> @@ -1743,7 +1743,7 @@ finish_backward (struct finish_command_fsm *sm)
>     frame that called the function we're about to step out of.  */
>  
>  static void
> -finish_forward (struct finish_command_fsm *sm, frame_info_ptr frame)
> +finish_forward (struct finish_command_fsm *sm, const frame_info_ptr &frame)
>  {
>    struct frame_id frame_id = get_frame_id (frame);
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -1768,9 +1768,10 @@ finish_forward (struct finish_command_fsm *sm, frame_info_ptr frame)
>  /* Skip frames for "finish".  */
>  
>  static frame_info_ptr
> -skip_finish_frames (frame_info_ptr frame)
> +skip_finish_frames (const frame_info_ptr &initial_frame)
>  {
>    frame_info_ptr start;
> +  frame_info_ptr frame = initial_frame;
>  
>    do
>      {
> @@ -2256,7 +2257,7 @@ default_print_one_register_info (struct ui_file *file,
>  void
>  default_print_registers_info (struct gdbarch *gdbarch,
>  			      struct ui_file *file,
> -			      frame_info_ptr frame,
> +			      const frame_info_ptr &frame,
>  			      int regnum, int print_all)
>  {
>    int i;
> @@ -2416,7 +2417,7 @@ info_registers_command (const char *addr_exp, int from_tty)
>  
>  static void
>  print_vector_info (struct ui_file *file,
> -		   frame_info_ptr frame, const char *args)
> +		   const frame_info_ptr &frame, const char *args)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>  
> @@ -2953,7 +2954,7 @@ interrupt_command (const char *args, int from_tty)
>  
>  void
>  default_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
> -			  frame_info_ptr frame, const char *args)
> +			  const frame_info_ptr &frame, const char *args)
>  {
>    int regnum;
>    int printed_something = 0;
> diff --git a/gdb/inferior.h b/gdb/inferior.h
> index f577bb1642d0..7be28423aeb1 100644
> --- a/gdb/inferior.h
> +++ b/gdb/inferior.h
> @@ -156,7 +156,7 @@ extern void reopen_exec_file (void);
>  
>  extern void default_print_registers_info (struct gdbarch *gdbarch,
>  					  struct ui_file *file,
> -					  frame_info_ptr frame,
> +					  const frame_info_ptr &frame,
>  					  int regnum, int all);
>  
>  /* Default implementation of gdbarch_print_float_info.  Print
> @@ -164,7 +164,7 @@ extern void default_print_registers_info (struct gdbarch *gdbarch,
>  
>  extern void default_print_float_info (struct gdbarch *gdbarch,
>  				      struct ui_file *file,
> -				      frame_info_ptr frame,
> +				      const frame_info_ptr &frame,
>  				      const char *args);
>  
>  /* Try to determine whether TTY is GDB's input terminal.  Returns
> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index fa68ab8296e9..bbb98f6dcdb3 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -88,9 +88,9 @@ static void follow_inferior_reset_breakpoints (void);
>  
>  static bool currently_stepping (struct thread_info *tp);
>  
> -static void insert_hp_step_resume_breakpoint_at_frame (frame_info_ptr);
> +static void insert_hp_step_resume_breakpoint_at_frame (const frame_info_ptr &);
>  
> -static void insert_step_resume_breakpoint_at_caller (frame_info_ptr);
> +static void insert_step_resume_breakpoint_at_caller (const frame_info_ptr &);
>  
>  static void insert_longjmp_resume_breakpoint (struct gdbarch *, CORE_ADDR);
>  
> @@ -3838,7 +3838,7 @@ static void handle_step_into_function_backward (struct gdbarch *gdbarch,
>  						struct execution_control_state *ecs);
>  static void handle_signal_stop (struct execution_control_state *ecs);
>  static void check_exception_resume (struct execution_control_state *,
> -				    frame_info_ptr);
> +				    const frame_info_ptr &);
>  
>  static void end_stepping_range (struct execution_control_state *ecs);
>  static void stop_waiting (struct execution_control_state *ecs);
> @@ -4771,7 +4771,7 @@ fetch_inferior_event ()
>  /* See infrun.h.  */
>  
>  void
> -set_step_info (thread_info *tp, frame_info_ptr frame,
> +set_step_info (thread_info *tp, const frame_info_ptr &frame,
>  	       struct symtab_and_line sal)
>  {
>    /* This can be removed once this function no longer implicitly relies on the
> @@ -5003,8 +5003,10 @@ adjust_pc_after_break (struct thread_info *thread,
>  }
>  
>  static bool
> -stepped_in_from (frame_info_ptr frame, struct frame_id step_frame_id)
> +stepped_in_from (const frame_info_ptr &initial_frame, frame_id step_frame_id)
>  {
> +  frame_info_ptr frame = initial_frame;
> +
>    for (frame = get_prev_frame (frame);
>         frame != nullptr;
>         frame = get_prev_frame (frame))
> @@ -8742,7 +8744,7 @@ insert_step_resume_breakpoint_at_sal (struct gdbarch *gdbarch,
>     RETURN_FRAME.pc.  */
>  
>  static void
> -insert_hp_step_resume_breakpoint_at_frame (frame_info_ptr return_frame)
> +insert_hp_step_resume_breakpoint_at_frame (const frame_info_ptr &return_frame)
>  {
>    gdb_assert (return_frame != nullptr);
>  
> @@ -8773,7 +8775,7 @@ insert_hp_step_resume_breakpoint_at_frame (frame_info_ptr return_frame)
>     of frame_unwind_caller_id for an example).  */
>  
>  static void
> -insert_step_resume_breakpoint_at_caller (frame_info_ptr next_frame)
> +insert_step_resume_breakpoint_at_caller (const frame_info_ptr &next_frame)
>  {
>    /* We shouldn't have gotten here if we don't know where the call site
>       is.  */
> @@ -8820,7 +8822,7 @@ insert_longjmp_resume_breakpoint (struct gdbarch *gdbarch, CORE_ADDR pc)
>  static void
>  insert_exception_resume_breakpoint (struct thread_info *tp,
>  				    const struct block *b,
> -				    frame_info_ptr frame,
> +				    const frame_info_ptr &frame,
>  				    struct symbol *sym)
>  {
>    try
> @@ -8863,7 +8865,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
>  static void
>  insert_exception_resume_from_probe (struct thread_info *tp,
>  				    const struct bound_probe *probe,
> -				    frame_info_ptr frame)
> +				    const frame_info_ptr &frame)
>  {
>    struct value *arg_value;
>    CORE_ADDR handler;
> @@ -8892,7 +8894,7 @@ insert_exception_resume_from_probe (struct thread_info *tp,
>  
>  static void
>  check_exception_resume (struct execution_control_state *ecs,
> -			frame_info_ptr frame)
> +			const frame_info_ptr &frame)
>  {
>    struct bound_probe probe;
>    struct symbol *func;
> diff --git a/gdb/infrun.h b/gdb/infrun.h
> index ba72212d5622..6339fd997e15 100644
> --- a/gdb/infrun.h
> +++ b/gdb/infrun.h
> @@ -207,7 +207,7 @@ extern int stepping_past_nonsteppable_watchpoint (void);
>  
>  /* Record in TP the frame and location we're currently stepping through.  */
>  extern void set_step_info (thread_info *tp,
> -			   frame_info_ptr frame,
> +			   const frame_info_ptr &frame,
>  			   struct symtab_and_line sal);
>  
>  /* Notify interpreters and observers that the current inferior has stopped with
> diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c
> index 02dbcd12af1f..9f3deef8f030 100644
> --- a/gdb/inline-frame.c
> +++ b/gdb/inline-frame.c
> @@ -150,7 +150,7 @@ clear_inline_frame_state (thread_info *thread)
>  }
>  
>  static void
> -inline_frame_this_id (frame_info_ptr this_frame,
> +inline_frame_this_id (const frame_info_ptr &this_frame,
>  		      void **this_cache,
>  		      struct frame_id *this_id)
>  {
> @@ -186,7 +186,7 @@ inline_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -inline_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +inline_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			    int regnum)
>  {
>    /* Use get_frame_register_value instead of
> @@ -208,7 +208,7 @@ inline_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
>  
>  static int
>  inline_frame_sniffer (const struct frame_unwind *self,
> -		      frame_info_ptr this_frame,
> +		      const frame_info_ptr &this_frame,
>  		      void **this_cache)
>  {
>    CORE_ADDR this_pc;
> @@ -441,7 +441,7 @@ inline_skipped_symbol (thread_info *thread)
>     skip_inline_frames).  */
>  
>  int
> -frame_inlined_callees (frame_info_ptr this_frame)
> +frame_inlined_callees (const frame_info_ptr &this_frame)
>  {
>    frame_info_ptr next_frame;
>    int inline_count = 0;
> diff --git a/gdb/inline-frame.h b/gdb/inline-frame.h
> index e19b60e010f6..bbe617c7c5b2 100644
> --- a/gdb/inline-frame.h
> +++ b/gdb/inline-frame.h
> @@ -68,6 +68,6 @@ struct symbol *inline_skipped_symbol (thread_info *thread);
>     the callees may not have associated frames (see
>     skip_inline_frames).  */
>  
> -int frame_inlined_callees (frame_info_ptr this_frame);
> +int frame_inlined_callees (const frame_info_ptr &this_frame);
>  
>  #endif /* !defined (INLINE_FRAME_H) */
> diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
> index 937a3513df44..4177de059c0d 100644
> --- a/gdb/iq2000-tdep.c
> +++ b/gdb/iq2000-tdep.c
> @@ -198,7 +198,7 @@ static CORE_ADDR
>  iq2000_scan_prologue (struct gdbarch *gdbarch,
>  		      CORE_ADDR scan_start,
>  		      CORE_ADDR scan_end,
> -		      frame_info_ptr fi,
> +		      const frame_info_ptr &fi,
>  		      struct iq2000_frame_cache *cache)
>  {
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -358,7 +358,7 @@ iq2000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>  }
>  
>  static struct iq2000_frame_cache *
> -iq2000_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +iq2000_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct iq2000_frame_cache *cache;
> @@ -391,7 +391,7 @@ iq2000_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static struct value *
> -iq2000_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +iq2000_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			    int regnum)
>  {
>    struct iq2000_frame_cache *cache = iq2000_frame_cache (this_frame,
> @@ -411,7 +411,7 @@ iq2000_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static void
> -iq2000_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +iq2000_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		      struct frame_id *this_id)
>  {
>    struct iq2000_frame_cache *cache = iq2000_frame_cache (this_frame,
> @@ -435,7 +435,7 @@ static const struct frame_unwind iq2000_frame_unwind = {
>  };
>  
>  static CORE_ADDR
> -iq2000_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +iq2000_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct iq2000_frame_cache *cache = iq2000_frame_cache (this_frame,
>  							 this_cache);
> diff --git a/gdb/jit.c b/gdb/jit.c
> index f1dbf39f73fd..3ca9cdabf9da 100644
> --- a/gdb/jit.c
> +++ b/gdb/jit.c
> @@ -1008,7 +1008,7 @@ jit_dealloc_cache (frame_info *this_frame, void *cache)
>  
>  static int
>  jit_frame_sniffer (const struct frame_unwind *self,
> -		   frame_info_ptr this_frame, void **cache)
> +		   const frame_info_ptr &this_frame, void **cache)
>  {
>    struct jit_unwind_private *priv_data;
>    struct gdb_unwind_callbacks callbacks;
> @@ -1054,7 +1054,7 @@ jit_frame_sniffer (const struct frame_unwind *self,
>     the loaded plugin.  */
>  
>  static void
> -jit_frame_this_id (frame_info_ptr this_frame, void **cache,
> +jit_frame_this_id (const frame_info_ptr &this_frame, void **cache,
>  		   struct frame_id *this_id)
>  {
>    struct jit_unwind_private priv;
> @@ -1083,7 +1083,7 @@ jit_frame_this_id (frame_info_ptr this_frame, void **cache,
>     the register from the cache.  */
>  
>  static struct value *
> -jit_frame_prev_register (frame_info_ptr this_frame, void **cache, int reg)
> +jit_frame_prev_register (const frame_info_ptr &this_frame, void **cache, int reg)
>  {
>    struct jit_unwind_private *priv = (struct jit_unwind_private *) *cache;
>    struct gdbarch *gdbarch;
> diff --git a/gdb/language.h b/gdb/language.h
> index 5bef965c2c86..c2eae4f74343 100644
> --- a/gdb/language.h
> +++ b/gdb/language.h
> @@ -321,7 +321,7 @@ struct language_defn
>  
>    virtual struct value *read_var_value (struct symbol *var,
>  					const struct block *var_block,
> -					frame_info_ptr frame) const;
> +					const frame_info_ptr &frame) const;
>  
>    /* Return information about whether TYPE should be passed
>       (and returned) by reference at the language level.  The default
> diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
> index 12e9b5ad4fd6..b4605e48c6a3 100644
> --- a/gdb/lm32-tdep.c
> +++ b/gdb/lm32-tdep.c
> @@ -379,7 +379,7 @@ lm32_return_value (struct gdbarch *gdbarch, struct value *function,
>     for it IS the sp for the next frame.  */
>  
>  static struct lm32_frame_cache *
> -lm32_frame_cache (frame_info_ptr this_frame, void **this_prologue_cache)
> +lm32_frame_cache (const frame_info_ptr &this_frame, void **this_prologue_cache)
>  {
>    CORE_ADDR current_pc;
>    ULONGEST prev_sp;
> @@ -425,7 +425,7 @@ lm32_frame_cache (frame_info_ptr this_frame, void **this_prologue_cache)
>  }
>  
>  static void
> -lm32_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +lm32_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		    struct frame_id *this_id)
>  {
>    struct lm32_frame_cache *cache = lm32_frame_cache (this_frame, this_cache);
> @@ -438,7 +438,7 @@ lm32_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -lm32_frame_prev_register (frame_info_ptr this_frame,
> +lm32_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache, int regnum)
>  {
>    struct lm32_frame_cache *info;
> @@ -458,7 +458,7 @@ static const struct frame_unwind lm32_frame_unwind = {
>  };
>  
>  static CORE_ADDR
> -lm32_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +lm32_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct lm32_frame_cache *info = lm32_frame_cache (this_frame, this_cache);
>  
> diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c
> index f1471d53ff4c..5ea648acd813 100644
> --- a/gdb/loongarch-linux-tdep.c
> +++ b/gdb/loongarch-linux-tdep.c
> @@ -446,7 +446,7 @@ const struct regset loongarch_lbtregset =
>  
>  static void
>  loongarch_linux_rt_sigframe_init (const struct tramp_frame *self,
> -				  frame_info_ptr this_frame,
> +				  const frame_info_ptr &this_frame,
>  				  struct trad_frame_cache *this_cache,
>  				  CORE_ADDR func)
>  {
> @@ -521,7 +521,7 @@ loongarch_iterate_over_regset_sections (struct gdbarch *gdbarch,
>     instruction to be executed.  */
>  
>  static CORE_ADDR
> -loongarch_linux_syscall_next_pc (frame_info_ptr frame)
> +loongarch_linux_syscall_next_pc (const frame_info_ptr &frame)
>  {
>    const CORE_ADDR pc = get_frame_pc (frame);
>    ULONGEST a7 = get_frame_register_unsigned (frame, LOONGARCH_A7_REGNUM);
> diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c
> index 0f4622a55be3..0b38e751d165 100644
> --- a/gdb/loongarch-tdep.c
> +++ b/gdb/loongarch-tdep.c
> @@ -113,7 +113,7 @@ loongarch_insn_is_sc (insn_t insn)
>  
>  static CORE_ADDR
>  loongarch_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc,
> -			 CORE_ADDR limit_pc, frame_info_ptr this_frame,
> +			 CORE_ADDR limit_pc, const frame_info_ptr &this_frame,
>  			 struct trad_frame_cache *this_cache)
>  {
>    CORE_ADDR cur_pc = start_pc, prologue_end = 0;
> @@ -390,7 +390,7 @@ loongarch_software_single_step (struct regcache *regcache)
>  /* Callback function for user_reg_add.  */
>  
>  static struct value *
> -value_of_loongarch_user_reg (frame_info_ptr frame, const void *baton)
> +value_of_loongarch_user_reg (const frame_info_ptr &frame, const void *baton)
>  {
>    return value_of_register ((long long) baton,
>  			    get_next_frame_sentinel_okay (frame));
> @@ -407,7 +407,7 @@ loongarch_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
>  /* Generate, or return the cached frame cache for frame unwinder.  */
>  
>  static struct trad_frame_cache *
> -loongarch_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +loongarch_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct trad_frame_cache *cache;
>    CORE_ADDR pc;
> @@ -429,7 +429,7 @@ loongarch_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  /* Implement the this_id callback for frame unwinder.  */
>  
>  static void
> -loongarch_frame_this_id (frame_info_ptr this_frame, void **prologue_cache,
> +loongarch_frame_this_id (const frame_info_ptr &this_frame, void **prologue_cache,
>  			 struct frame_id *this_id)
>  {
>    struct trad_frame_cache *info;
> @@ -441,7 +441,7 @@ loongarch_frame_this_id (frame_info_ptr this_frame, void **prologue_cache,
>  /* Implement the prev_register callback for frame unwinder.  */
>  
>  static struct value *
> -loongarch_frame_prev_register (frame_info_ptr this_frame,
> +loongarch_frame_prev_register (const frame_info_ptr &this_frame,
>  			       void **prologue_cache, int regnum)
>  {
>    struct trad_frame_cache *info;
> diff --git a/gdb/loongarch-tdep.h b/gdb/loongarch-tdep.h
> index bfe398898c00..5c8108182ad6 100644
> --- a/gdb/loongarch-tdep.h
> +++ b/gdb/loongarch-tdep.h
> @@ -41,7 +41,7 @@ struct loongarch_gdbarch_tdep : gdbarch_tdep_base
>    struct loongarch_gdbarch_features abi_features;
>  
>    /* Return the expected next PC if FRAME is stopped at a syscall instruction.  */
> -  CORE_ADDR (*syscall_next_pc) (frame_info_ptr frame) = nullptr;
> +  CORE_ADDR (*syscall_next_pc) (const frame_info_ptr &frame) = nullptr;
>  };
>  
>  #endif /* LOONGARCH_TDEP_H  */
> diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
> index 8da15fefe800..0895f7bd0c4b 100644
> --- a/gdb/m32c-tdep.c
> +++ b/gdb/m32c-tdep.c
> @@ -1854,7 +1854,7 @@ m32c_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR ip)
>  /* Stack unwinding.  */
>  
>  static struct m32c_prologue *
> -m32c_analyze_frame_prologue (frame_info_ptr this_frame,
> +m32c_analyze_frame_prologue (const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache)
>  {
>    if (! *this_prologue_cache)
> @@ -1878,7 +1878,7 @@ m32c_analyze_frame_prologue (frame_info_ptr this_frame,
>  
>  
>  static CORE_ADDR
> -m32c_frame_base (frame_info_ptr this_frame,
> +m32c_frame_base (const frame_info_ptr &this_frame,
>  		void **this_prologue_cache)
>  {
>    struct m32c_prologue *p
> @@ -1918,7 +1918,7 @@ m32c_frame_base (frame_info_ptr this_frame,
>  
>  
>  static void
> -m32c_this_id (frame_info_ptr this_frame,
> +m32c_this_id (const frame_info_ptr &this_frame,
>  	      void **this_prologue_cache,
>  	      struct frame_id *this_id)
>  {
> @@ -1931,7 +1931,7 @@ m32c_this_id (frame_info_ptr this_frame,
>  
>  
>  static struct value *
> -m32c_prev_register (frame_info_ptr this_frame,
> +m32c_prev_register (const frame_info_ptr &this_frame,
>  		    void **this_prologue_cache, int regnum)
>  {
>    gdbarch *arch = get_frame_arch (this_frame);
> @@ -2309,7 +2309,7 @@ m32c_return_value (struct gdbarch *gdbarch,
>     code sequence seems more fragile.  */
>  
>  static CORE_ADDR
> -m32c_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR stop_pc)
> +m32c_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR stop_pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (gdbarch);
> diff --git a/gdb/m32r-linux-tdep.c b/gdb/m32r-linux-tdep.c
> index ec054fa263ef..b74d2f3f161b 100644
> --- a/gdb/m32r-linux-tdep.c
> +++ b/gdb/m32r-linux-tdep.c
> @@ -85,7 +85,7 @@ static const gdb_byte linux_sigtramp_code[] = {
>     the routine.  Otherwise, return 0.  */
>  
>  static CORE_ADDR
> -m32r_linux_sigtramp_start (CORE_ADDR pc, frame_info_ptr this_frame)
> +m32r_linux_sigtramp_start (CORE_ADDR pc, const frame_info_ptr &this_frame)
>  {
>    gdb_byte buf[4];
>  
> @@ -133,7 +133,7 @@ static const gdb_byte linux_rt_sigtramp_code[] = {
>     of the routine.  Otherwise, return 0.  */
>  
>  static CORE_ADDR
> -m32r_linux_rt_sigtramp_start (CORE_ADDR pc, frame_info_ptr this_frame)
> +m32r_linux_rt_sigtramp_start (CORE_ADDR pc, const frame_info_ptr &this_frame)
>  {
>    gdb_byte buf[4];
>  
> @@ -173,7 +173,7 @@ m32r_linux_rt_sigtramp_start (CORE_ADDR pc, frame_info_ptr this_frame)
>  
>  static int
>  m32r_linux_pc_in_sigtramp (CORE_ADDR pc, const char *name,
> -			   frame_info_ptr this_frame)
> +			   const frame_info_ptr &this_frame)
>  {
>    /* If we have NAME, we can optimize the search.  The trampolines are
>       named __restore and __restore_rt.  However, they aren't dynamically
> @@ -223,7 +223,7 @@ struct m32r_frame_cache
>  };
>  
>  static struct m32r_frame_cache *
> -m32r_linux_sigtramp_frame_cache (frame_info_ptr this_frame,
> +m32r_linux_sigtramp_frame_cache (const frame_info_ptr &this_frame,
>  				 void **this_cache)
>  {
>    struct m32r_frame_cache *cache;
> @@ -266,7 +266,7 @@ m32r_linux_sigtramp_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -m32r_linux_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +m32r_linux_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				   void **this_cache,
>  				   struct frame_id *this_id)
>  {
> @@ -277,7 +277,7 @@ m32r_linux_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -m32r_linux_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +m32r_linux_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  					 void **this_cache, int regnum)
>  {
>    struct m32r_frame_cache *cache =
> @@ -288,7 +288,7 @@ m32r_linux_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  m32r_linux_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				   frame_info_ptr this_frame,
> +				   const frame_info_ptr &this_frame,
>  				   void **this_cache)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
> diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
> index 73855947e632..0bd6b499e6f0 100644
> --- a/gdb/m32r-tdep.c
> +++ b/gdb/m32r-tdep.c
> @@ -516,7 +516,7 @@ struct m32r_unwind_cache
>     for it IS the sp for the next frame.  */
>  
>  static struct m32r_unwind_cache *
> -m32r_frame_unwind_cache (frame_info_ptr this_frame,
> +m32r_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache)
>  {
>    CORE_ADDR pc, scan_limit;
> @@ -793,7 +793,7 @@ m32r_return_value (struct gdbarch *gdbarch, struct value *function,
>     frame.  This will be used to create a new GDB frame struct.  */
>  
>  static void
> -m32r_frame_this_id (frame_info_ptr this_frame,
> +m32r_frame_this_id (const frame_info_ptr &this_frame,
>  		    void **this_prologue_cache, struct frame_id *this_id)
>  {
>    struct m32r_unwind_cache *info
> @@ -823,7 +823,7 @@ m32r_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -m32r_frame_prev_register (frame_info_ptr this_frame,
> +m32r_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache, int regnum)
>  {
>    struct m32r_unwind_cache *info
> @@ -842,7 +842,7 @@ static const struct frame_unwind m32r_frame_unwind = {
>  };
>  
>  static CORE_ADDR
> -m32r_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +m32r_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct m32r_unwind_cache *info
>      = m32r_frame_unwind_cache (this_frame, this_cache);
> diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
> index a8466e31b58e..d80b190f2c0f 100644
> --- a/gdb/m68hc11-tdep.c
> +++ b/gdb/m68hc11-tdep.c
> @@ -777,7 +777,7 @@ m68hc11_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>     for it IS the sp for the next frame.  */
>  
>  static struct m68hc11_unwind_cache *
> -m68hc11_frame_unwind_cache (frame_info_ptr this_frame,
> +m68hc11_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			    void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -874,7 +874,7 @@ m68hc11_frame_unwind_cache (frame_info_ptr this_frame,
>     frame.  This will be used to create a new GDB frame struct.  */
>  
>  static void
> -m68hc11_frame_this_id (frame_info_ptr this_frame,
> +m68hc11_frame_this_id (const frame_info_ptr &this_frame,
>  		       void **this_prologue_cache,
>  		       struct frame_id *this_id)
>  {
> @@ -899,7 +899,7 @@ m68hc11_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -m68hc11_frame_prev_register (frame_info_ptr this_frame,
> +m68hc11_frame_prev_register (const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache, int regnum)
>  {
>    struct value *value;
> @@ -947,7 +947,7 @@ static const struct frame_unwind m68hc11_frame_unwind = {
>  };
>  
>  static CORE_ADDR
> -m68hc11_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +m68hc11_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct m68hc11_unwind_cache *info
>      = m68hc11_frame_unwind_cache (this_frame, this_cache);
> @@ -956,7 +956,7 @@ m68hc11_frame_base_address (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static CORE_ADDR
> -m68hc11_frame_args_address (frame_info_ptr this_frame, void **this_cache)
> +m68hc11_frame_args_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    CORE_ADDR addr;
>    struct m68hc11_unwind_cache *info
> @@ -983,7 +983,7 @@ static const struct frame_base m68hc11_frame_base = {
>     save_dummy_frame_tos(), and the PC match the dummy frame's breakpoint.  */
>  
>  static struct frame_id
> -m68hc11_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +m68hc11_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    ULONGEST tos;
>    CORE_ADDR pc = get_frame_pc (this_frame);
> @@ -997,7 +997,7 @@ m68hc11_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
>  /* Get and print the register from the given frame.  */
>  static void
>  m68hc11_print_register (struct gdbarch *gdbarch, struct ui_file *file,
> -			frame_info_ptr frame, int regno)
> +			const frame_info_ptr &frame, int regno)
>  {
>    LONGEST rval;
>  
> @@ -1084,7 +1084,7 @@ m68hc11_print_register (struct gdbarch *gdbarch, struct ui_file *file,
>  /* Same as 'info reg' but prints the registers in a different way.  */
>  static void
>  m68hc11_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
> -			      frame_info_ptr frame, int regno, int cpregs)
> +			      const frame_info_ptr &frame, int regno, int cpregs)
>  {
>    if (regno >= 0)
>      {
> diff --git a/gdb/m68k-linux-tdep.c b/gdb/m68k-linux-tdep.c
> index 9004b2e55b44..eca4ede099f7 100644
> --- a/gdb/m68k-linux-tdep.c
> +++ b/gdb/m68k-linux-tdep.c
> @@ -61,7 +61,7 @@
>     non-RT and RT signal trampolines.  */
>  
>  static int
> -m68k_linux_pc_in_sigtramp (frame_info_ptr this_frame)
> +m68k_linux_pc_in_sigtramp (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -219,7 +219,7 @@ m68k_linux_inferior_created (inferior *inf)
>  }
>  
>  static struct m68k_linux_sigtramp_info
> -m68k_linux_get_sigtramp_info (frame_info_ptr this_frame)
> +m68k_linux_get_sigtramp_info (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -248,7 +248,7 @@ m68k_linux_get_sigtramp_info (frame_info_ptr this_frame)
>  /* Signal trampolines.  */
>  
>  static struct trad_frame_cache *
> -m68k_linux_sigtramp_frame_cache (frame_info_ptr this_frame,
> +m68k_linux_sigtramp_frame_cache (const frame_info_ptr &this_frame,
>  				 void **this_cache)
>  {
>    struct frame_id this_id;
> @@ -286,7 +286,7 @@ m68k_linux_sigtramp_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -m68k_linux_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +m68k_linux_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				   void **this_cache,
>  				   struct frame_id *this_id)
>  {
> @@ -296,7 +296,7 @@ m68k_linux_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -m68k_linux_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +m68k_linux_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  					 void **this_cache,
>  					 int regnum)
>  {
> @@ -308,7 +308,7 @@ m68k_linux_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  m68k_linux_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				   frame_info_ptr this_frame,
> +				   const frame_info_ptr &this_frame,
>  				   void **this_prologue_cache)
>  {
>    return m68k_linux_pc_in_sigtramp (this_frame);
> diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
> index 1ae5c33e8420..abfc605aabb6 100644
> --- a/gdb/m68k-tdep.c
> +++ b/gdb/m68k-tdep.c
> @@ -205,7 +205,7 @@ m68k_convert_register_p (struct gdbarch *gdbarch,
>     return its contents in TO.  */
>  
>  static int
> -m68k_register_to_value (frame_info_ptr frame, int regnum,
> +m68k_register_to_value (const frame_info_ptr &frame, int regnum,
>  			struct type *type, gdb_byte *to,
>  			int *optimizedp, int *unavailablep)
>  {
> @@ -232,7 +232,7 @@ m68k_register_to_value (frame_info_ptr frame, int regnum,
>     REGNUM in frame FRAME.  */
>  
>  static void
> -m68k_value_to_register (frame_info_ptr frame, int regnum,
> +m68k_value_to_register (const frame_info_ptr &frame, int regnum,
>  			struct type *type, const gdb_byte *from)
>  {
>    gdb_byte to[M68K_MAX_REGISTER_SIZE];
> @@ -900,7 +900,7 @@ m68k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
>  }
>  
>  static CORE_ADDR
> -m68k_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +m68k_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    gdb_byte buf[8];
>  
> @@ -911,7 +911,7 @@ m68k_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  /* Normal frames.  */
>  
>  static struct m68k_frame_cache *
> -m68k_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +m68k_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -976,7 +976,7 @@ m68k_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -m68k_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +m68k_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		    struct frame_id *this_id)
>  {
>    struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
> @@ -990,7 +990,7 @@ m68k_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -m68k_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +m68k_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			  int regnum)
>  {
>    struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
> @@ -1019,7 +1019,7 @@ static const struct frame_unwind m68k_frame_unwind =
>  };
>  \f
>  static CORE_ADDR
> -m68k_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +m68k_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
>  
> @@ -1035,7 +1035,7 @@ static const struct frame_base m68k_frame_base =
>  };
>  
>  static struct frame_id
> -m68k_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +m68k_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR fp;
>  
> @@ -1052,7 +1052,7 @@ m68k_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
>     This routine returns true on success.  */
>  
>  static int
> -m68k_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +m68k_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    gdb_byte *buf;
>    CORE_ADDR sp, jb_addr;
> diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
> index 573711e8ba43..f455d3eb51d6 100644
> --- a/gdb/mep-tdep.c
> +++ b/gdb/mep-tdep.c
> @@ -1913,7 +1913,7 @@ typedef BP_MANIPULATION (mep_break_insn) mep_breakpoint;
>  
>  
>  static struct mep_prologue *
> -mep_analyze_frame_prologue (frame_info_ptr this_frame,
> +mep_analyze_frame_prologue (const frame_info_ptr &this_frame,
>  			    void **this_prologue_cache)
>  {
>    if (! *this_prologue_cache)
> @@ -1943,7 +1943,7 @@ mep_analyze_frame_prologue (frame_info_ptr this_frame,
>  /* Given the next frame and a prologue cache, return this frame's
>     base.  */
>  static CORE_ADDR
> -mep_frame_base (frame_info_ptr this_frame,
> +mep_frame_base (const frame_info_ptr &this_frame,
>  		void **this_prologue_cache)
>  {
>    struct mep_prologue *p
> @@ -1971,7 +1971,7 @@ mep_frame_base (frame_info_ptr this_frame,
>  
>  
>  static void
> -mep_frame_this_id (frame_info_ptr this_frame,
> +mep_frame_this_id (const frame_info_ptr &this_frame,
>  		   void **this_prologue_cache,
>  		   struct frame_id *this_id)
>  {
> @@ -1981,7 +1981,7 @@ mep_frame_this_id (frame_info_ptr this_frame,
>  
>  
>  static struct value *
> -mep_frame_prev_register (frame_info_ptr this_frame,
> +mep_frame_prev_register (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache, int regnum)
>  {
>    struct mep_prologue *p
> diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
> index d4202b99514a..09c31b6a9a4c 100644
> --- a/gdb/mi/mi-cmd-stack.c
> +++ b/gdb/mi/mi-cmd-stack.c
> @@ -44,7 +44,7 @@ enum what_to_list { locals, arguments, all };
>  static void list_args_or_locals (const frame_print_options &fp_opts,
>  				 enum what_to_list what,
>  				 enum print_values values,
> -				 frame_info_ptr fi,
> +				 const frame_info_ptr &fi,
>  				 int skip_unavailable);
>  
>  /* True if we want to allow Python-based frame filters.  */
> @@ -62,7 +62,7 @@ mi_cmd_enable_frame_filters (const char *command, const char *const *argv,
>  /* Like apply_ext_lang_frame_filter, but take a print_values */
>  
>  static enum ext_lang_bt_status
> -mi_apply_ext_lang_frame_filter (frame_info_ptr frame,
> +mi_apply_ext_lang_frame_filter (const frame_info_ptr &frame,
>  				frame_filter_flags flags,
>  				enum print_values print_values,
>  				struct ui_out *out,
> @@ -577,7 +577,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
>  static void
>  list_args_or_locals (const frame_print_options &fp_opts,
>  		     enum what_to_list what, enum print_values values,
> -		     frame_info_ptr fi, int skip_unavailable)
> +		     const frame_info_ptr &fi, int skip_unavailable)
>  {
>    const struct block *block;
>    const char *name_of_result;
> diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
> index db670e318f89..f4ab17915ecb 100644
> --- a/gdb/mi/mi-main.c
> +++ b/gdb/mi/mi-main.c
> @@ -89,7 +89,7 @@ static void mi_execute_async_cli_command (const char *cli_command,
>  					  const char *const *argv, int argc);
>  static bool register_changed_p (int regnum, readonly_detached_regcache *,
>  			       readonly_detached_regcache *);
> -static void output_register (frame_info_ptr, int regnum, int format,
> +static void output_register (const frame_info_ptr &, int regnum, int format,
>  			     int skip_unavailable);
>  
>  /* Controls whether the frontend wants MI in async mode.  */
> @@ -1097,7 +1097,7 @@ mi_cmd_data_list_register_values (const char *command, const char *const *argv,
>     unavailable.  */
>  
>  static void
> -output_register (frame_info_ptr frame, int regnum, int format,
> +output_register (const frame_info_ptr &frame, int regnum, int format,
>  		 int skip_unavailable)
>  {
>    struct ui_out *uiout = current_uiout;
> diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
> index 7d620a3688b9..6236ab0a0447 100644
> --- a/gdb/microblaze-linux-tdep.c
> +++ b/gdb/microblaze-linux-tdep.c
> @@ -62,7 +62,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
>  }
>  
>  static void
> -microblaze_linux_sigtramp_cache (frame_info_ptr next_frame,
> +microblaze_linux_sigtramp_cache (const frame_info_ptr &next_frame,
>  				 struct trad_frame_cache *this_cache,
>  				 CORE_ADDR func, LONGEST offset,
>  				 int bias)
> @@ -90,7 +90,7 @@ microblaze_linux_sigtramp_cache (frame_info_ptr next_frame,
>  
>  static void
>  microblaze_linux_sighandler_cache_init (const struct tramp_frame *self,
> -					frame_info_ptr next_frame,
> +					const frame_info_ptr &next_frame,
>  					struct trad_frame_cache *this_cache,
>  					CORE_ADDR func)
>  {
> diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
> index fc83634d1e67..07261bd4d22f 100644
> --- a/gdb/microblaze-tdep.c
> +++ b/gdb/microblaze-tdep.c
> @@ -368,7 +368,7 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
>  }
>  
>  static CORE_ADDR
> -microblaze_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +microblaze_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    gdb_byte buf[4];
>    CORE_ADDR pc;
> @@ -417,7 +417,7 @@ microblaze_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
>  /* Normal frames.  */
>  
>  static struct microblaze_frame_cache *
> -microblaze_frame_cache (frame_info_ptr next_frame, void **this_cache)
> +microblaze_frame_cache (const frame_info_ptr &next_frame, void **this_cache)
>  {
>    struct microblaze_frame_cache *cache;
>    struct gdbarch *gdbarch = get_frame_arch (next_frame);
> @@ -443,7 +443,7 @@ microblaze_frame_cache (frame_info_ptr next_frame, void **this_cache)
>  }
>  
>  static void
> -microblaze_frame_this_id (frame_info_ptr next_frame, void **this_cache,
> +microblaze_frame_this_id (const frame_info_ptr &next_frame, void **this_cache,
>  		       struct frame_id *this_id)
>  {
>    struct microblaze_frame_cache *cache =
> @@ -457,7 +457,7 @@ microblaze_frame_this_id (frame_info_ptr next_frame, void **this_cache,
>  }
>  
>  static struct value *
> -microblaze_frame_prev_register (frame_info_ptr this_frame,
> +microblaze_frame_prev_register (const frame_info_ptr &this_frame,
>  				 void **this_cache, int regnum)
>  {
>    struct microblaze_frame_cache *cache =
> @@ -490,7 +490,7 @@ static const struct frame_unwind microblaze_frame_unwind =
>  };
>  \f
>  static CORE_ADDR
> -microblaze_frame_base_address (frame_info_ptr next_frame,
> +microblaze_frame_base_address (const frame_info_ptr &next_frame,
>  			       void **this_cache)
>  {
>    struct microblaze_frame_cache *cache =
> diff --git a/gdb/minsyms.c b/gdb/minsyms.c
> index 1b85424586fc..2a43175a170d 100644
> --- a/gdb/minsyms.c
> +++ b/gdb/minsyms.c
> @@ -1564,7 +1564,7 @@ lookup_solib_trampoline_symbol_by_pc (CORE_ADDR pc)
>     a duplicate function in case this matters someday.  */
>  
>  CORE_ADDR
> -find_solib_trampoline_target (frame_info_ptr frame, CORE_ADDR pc)
> +find_solib_trampoline_target (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct minimal_symbol *tsymbol = lookup_solib_trampoline_symbol_by_pc (pc);
>  
> diff --git a/gdb/mips-fbsd-tdep.c b/gdb/mips-fbsd-tdep.c
> index 97ad5e79cab5..8464a92bf4af 100644
> --- a/gdb/mips-fbsd-tdep.c
> +++ b/gdb/mips-fbsd-tdep.c
> @@ -275,7 +275,7 @@ mips_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
>  
>  static void
>  mips_fbsd_sigframe_init (const struct tramp_frame *self,
> -			 frame_info_ptr this_frame,
> +			 const frame_info_ptr &this_frame,
>  			 struct trad_frame_cache *cache,
>  			 CORE_ADDR func)
>  {
> @@ -367,7 +367,7 @@ static const struct tramp_frame mips_fbsd_sigframe =
>  
>  static void
>  mips64_fbsd_sigframe_init (const struct tramp_frame *self,
> -			   frame_info_ptr this_frame,
> +			   const frame_info_ptr &this_frame,
>  			   struct trad_frame_cache *cache,
>  			   CORE_ADDR func)
>  {
> diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
> index 9ecf698113b1..0b5e7867788d 100644
> --- a/gdb/mips-linux-tdep.c
> +++ b/gdb/mips-linux-tdep.c
> @@ -94,7 +94,7 @@ enum
>  #define MIPS_LINUX_JB_PC 0
>  
>  static int
> -mips_linux_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +mips_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    CORE_ADDR jb_addr;
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -247,7 +247,7 @@ mips_fill_gregset_wrapper (const struct regset *regset,
>  #define MIPS64_LINUX_JB_PC 0
>  
>  static int
> -mips64_linux_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +mips64_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    CORE_ADDR jb_addr;
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -714,21 +714,21 @@ mips_linux_skip_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
>     efficient way, but simplest.  First, declare all the unwinders.  */
>  
>  static void mips_linux_o32_sigframe_init (const struct tramp_frame *self,
> -					  frame_info_ptr this_frame,
> +					  const frame_info_ptr &this_frame,
>  					  struct trad_frame_cache *this_cache,
>  					  CORE_ADDR func);
>  
>  static void mips_linux_n32n64_sigframe_init (const struct tramp_frame *self,
> -					     frame_info_ptr this_frame,
> +					     const frame_info_ptr &this_frame,
>  					     struct trad_frame_cache *this_cache,
>  					     CORE_ADDR func);
>  
>  static int mips_linux_sigframe_validate (const struct tramp_frame *self,
> -					 frame_info_ptr this_frame,
> +					 const frame_info_ptr &this_frame,
>  					 CORE_ADDR *pc);
>  
>  static int micromips_linux_sigframe_validate (const struct tramp_frame *self,
> -					      frame_info_ptr this_frame,
> +					      const frame_info_ptr &this_frame,
>  					      CORE_ADDR *pc);
>  
>  #define MIPS_NR_LINUX 4000
> @@ -957,7 +957,7 @@ static const struct tramp_frame micromips_linux_n64_rt_sigframe = {
>  
>  static void
>  mips_linux_o32_sigframe_init (const struct tramp_frame *self,
> -			      frame_info_ptr this_frame,
> +			      const frame_info_ptr &this_frame,
>  			      struct trad_frame_cache *this_cache,
>  			      CORE_ADDR func)
>  {
> @@ -1150,7 +1150,7 @@ mips_linux_o32_sigframe_init (const struct tramp_frame *self,
>  
>  static void
>  mips_linux_n32n64_sigframe_init (const struct tramp_frame *self,
> -				 frame_info_ptr this_frame,
> +				 const frame_info_ptr &this_frame,
>  				 struct trad_frame_cache *this_cache,
>  				 CORE_ADDR func)
>  {
> @@ -1235,7 +1235,7 @@ mips_linux_n32n64_sigframe_init (const struct tramp_frame *self,
>  
>  static int
>  mips_linux_sigframe_validate (const struct tramp_frame *self,
> -			      frame_info_ptr this_frame,
> +			      const frame_info_ptr &this_frame,
>  			      CORE_ADDR *pc)
>  {
>    return mips_pc_is_mips (*pc);
> @@ -1245,7 +1245,7 @@ mips_linux_sigframe_validate (const struct tramp_frame *self,
>  
>  static int
>  micromips_linux_sigframe_validate (const struct tramp_frame *self,
> -				   frame_info_ptr this_frame,
> +				   const frame_info_ptr &this_frame,
>  				   CORE_ADDR *pc)
>  {
>    if (mips_pc_is_micromips (get_frame_arch (this_frame), *pc))
> @@ -1290,7 +1290,7 @@ mips_linux_restart_reg_p (struct gdbarch *gdbarch)
>     instruction to be executed.  */
>  
>  static CORE_ADDR
> -mips_linux_syscall_next_pc (frame_info_ptr frame)
> +mips_linux_syscall_next_pc (const frame_info_ptr &frame)
>  {
>    CORE_ADDR pc = get_frame_pc (frame);
>    ULONGEST v0 = get_frame_register_unsigned (frame, MIPS_V0_REGNUM);
> diff --git a/gdb/mips-netbsd-tdep.c b/gdb/mips-netbsd-tdep.c
> index 1452109090f9..8d3604a8b905 100644
> --- a/gdb/mips-netbsd-tdep.c
> +++ b/gdb/mips-netbsd-tdep.c
> @@ -254,7 +254,7 @@ static const unsigned char sigtramp_retcode_mipseb[RETCODE_SIZE] =
>  					 NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch))
>  
>  static int
> -mipsnbsd_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +mipsnbsd_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> diff --git a/gdb/mips-sde-tdep.c b/gdb/mips-sde-tdep.c
> index e54440e20b5d..7b367898f043 100644
> --- a/gdb/mips-sde-tdep.c
> +++ b/gdb/mips-sde-tdep.c
> @@ -33,7 +33,7 @@
>     in the SDE frame unwinder.  */
>  
>  static struct trad_frame_cache *
> -mips_sde_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +mips_sde_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    const struct mips_regnum *regs = mips_regnum (gdbarch);
> @@ -121,7 +121,7 @@ mips_sde_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  /* Implement the this_id function for the SDE frame unwinder.  */
>  
>  static void
> -mips_sde_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +mips_sde_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			struct frame_id *this_id)
>  {
>    struct trad_frame_cache *this_trad_cache
> @@ -133,7 +133,7 @@ mips_sde_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  /* Implement the prev_register function for the SDE frame unwinder.  */
>  
>  static struct value *
> -mips_sde_frame_prev_register (frame_info_ptr this_frame,
> +mips_sde_frame_prev_register (const frame_info_ptr &this_frame,
>  			      void **this_cache,
>  			      int prev_regnum)
>  {
> @@ -147,7 +147,7 @@ mips_sde_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  mips_sde_frame_sniffer (const struct frame_unwind *self,
> -			frame_info_ptr this_frame,
> +			const frame_info_ptr &this_frame,
>  			void **this_cache)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
> @@ -176,7 +176,7 @@ static const struct frame_unwind mips_sde_frame_unwind =
>     for the normal unwinder.  */
>  
>  static CORE_ADDR
> -mips_sde_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +mips_sde_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct trad_frame_cache *this_trad_cache
>      = mips_sde_frame_cache (this_frame, this_cache);
> @@ -193,7 +193,7 @@ static const struct frame_base mips_sde_frame_base =
>  };
>  
>  static const struct frame_base *
> -mips_sde_frame_base_sniffer (frame_info_ptr this_frame)
> +mips_sde_frame_base_sniffer (const frame_info_ptr &this_frame)
>  {
>    if (mips_sde_frame_sniffer (&mips_sde_frame_unwind, this_frame, NULL))
>      return &mips_sde_frame_base;
> diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
> index bf0b66c4b002..8339d2f1d4c6 100644
> --- a/gdb/mips-tdep.c
> +++ b/gdb/mips-tdep.c
> @@ -74,7 +74,7 @@ static int mips16_insn_at_pc_has_delay_slot (struct gdbarch *gdbarch,
>  					     CORE_ADDR addr, int mustbe32);
>  
>  static void mips_print_float_info (struct gdbarch *, struct ui_file *,
> -				   frame_info_ptr, const char *);
> +				   const frame_info_ptr &, const char *);
>  
>  /* A useful bit in the CP0 status register (MIPS_PS_REGNUM).  */
>  /* This bit is set if we are emulating 32-bit FPRs on a 64-bit chip.  */
> @@ -562,7 +562,7 @@ mips_xfer_register (struct gdbarch *gdbarch, struct regcache *regcache,
>     physical 64-bit registers, but should treat them as 32-bit registers.  */
>  
>  static int
> -mips2_fp_compat (frame_info_ptr frame)
> +mips2_fp_compat (const frame_info_ptr &frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    /* MIPS1 and MIPS2 have only 32 bit FPRs, and the FR bit is not
> @@ -942,7 +942,7 @@ mips_convert_register_p (struct gdbarch *gdbarch,
>  }
>  
>  static int
> -mips_register_to_value (frame_info_ptr frame, int regnum,
> +mips_register_to_value (const frame_info_ptr &frame, int regnum,
>  			struct type *type, gdb_byte *to,
>  			int *optimizedp, int *unavailablep)
>  {
> @@ -984,7 +984,7 @@ mips_register_to_value (frame_info_ptr frame, int regnum,
>  }
>  
>  static void
> -mips_value_to_register (frame_info_ptr frame, int regnum,
> +mips_value_to_register (const frame_info_ptr &frame, int regnum,
>  			struct type *type, const gdb_byte *from)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -1409,7 +1409,7 @@ mips_read_pc (readable_regcache *regcache)
>  }
>  
>  static CORE_ADDR
> -mips_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +mips_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    CORE_ADDR pc;
>  
> @@ -1431,7 +1431,7 @@ mips_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  }
>  
>  static CORE_ADDR
> -mips_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +mips_unwind_sp (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    return frame_unwind_register_signed
>  	   (next_frame, gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM);
> @@ -1443,7 +1443,7 @@ mips_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>     breakpoint.  */
>  
>  static struct frame_id
> -mips_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +mips_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    return frame_id_build
>  	   (get_frame_register_signed (this_frame,
> @@ -2526,7 +2526,7 @@ mips16_get_imm (unsigned short prev_inst,	/* previous instruction */
>  static CORE_ADDR
>  mips16_scan_prologue (struct gdbarch *gdbarch,
>  		      CORE_ADDR start_pc, CORE_ADDR limit_pc,
> -		      frame_info_ptr this_frame,
> +		      const frame_info_ptr &this_frame,
>  		      struct mips_frame_cache *this_cache)
>  {
>    int prev_non_prologue_insn = 0;
> @@ -2862,7 +2862,7 @@ mips16_scan_prologue (struct gdbarch *gdbarch,
>     mips_insn32 unwinder.  */
>  
>  static struct mips_frame_cache *
> -mips_insn16_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +mips_insn16_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct mips_frame_cache *cache;
> @@ -2898,7 +2898,7 @@ mips_insn16_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -mips_insn16_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +mips_insn16_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			   struct frame_id *this_id)
>  {
>    struct mips_frame_cache *info = mips_insn16_frame_cache (this_frame,
> @@ -2910,7 +2910,7 @@ mips_insn16_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -mips_insn16_frame_prev_register (frame_info_ptr this_frame,
> +mips_insn16_frame_prev_register (const frame_info_ptr &this_frame,
>  				 void **this_cache, int regnum)
>  {
>    struct mips_frame_cache *info = mips_insn16_frame_cache (this_frame,
> @@ -2920,7 +2920,7 @@ mips_insn16_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  mips_insn16_frame_sniffer (const struct frame_unwind *self,
> -			   frame_info_ptr this_frame, void **this_cache)
> +			   const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    CORE_ADDR pc = get_frame_pc (this_frame);
> @@ -2941,7 +2941,7 @@ static const struct frame_unwind mips_insn16_frame_unwind =
>  };
>  
>  static CORE_ADDR
> -mips_insn16_frame_base_address (frame_info_ptr this_frame,
> +mips_insn16_frame_base_address (const frame_info_ptr &this_frame,
>  				void **this_cache)
>  {
>    struct mips_frame_cache *info = mips_insn16_frame_cache (this_frame,
> @@ -2958,7 +2958,7 @@ static const struct frame_base mips_insn16_frame_base =
>  };
>  
>  static const struct frame_base *
> -mips_insn16_frame_base_sniffer (frame_info_ptr this_frame)
> +mips_insn16_frame_base_sniffer (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    CORE_ADDR pc = get_frame_pc (this_frame);
> @@ -2987,7 +2987,7 @@ micromips_decode_imm9 (int imm)
>  static CORE_ADDR
>  micromips_scan_prologue (struct gdbarch *gdbarch,
>  			 CORE_ADDR start_pc, CORE_ADDR limit_pc,
> -			 frame_info_ptr this_frame,
> +			 const frame_info_ptr &this_frame,
>  			 struct mips_frame_cache *this_cache)
>  {
>    CORE_ADDR end_prologue_addr;
> @@ -3296,7 +3296,7 @@ micromips_scan_prologue (struct gdbarch *gdbarch,
>     mips_insn32 unwinder.  Likewise MIPS16 and the mips_insn16 unwinder. */
>  
>  static struct mips_frame_cache *
> -mips_micro_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +mips_micro_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct mips_frame_cache *cache;
> @@ -3333,7 +3333,7 @@ mips_micro_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -mips_micro_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +mips_micro_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			  struct frame_id *this_id)
>  {
>    struct mips_frame_cache *info = mips_micro_frame_cache (this_frame,
> @@ -3345,7 +3345,7 @@ mips_micro_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -mips_micro_frame_prev_register (frame_info_ptr this_frame,
> +mips_micro_frame_prev_register (const frame_info_ptr &this_frame,
>  				void **this_cache, int regnum)
>  {
>    struct mips_frame_cache *info = mips_micro_frame_cache (this_frame,
> @@ -3355,7 +3355,7 @@ mips_micro_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  mips_micro_frame_sniffer (const struct frame_unwind *self,
> -			  frame_info_ptr this_frame, void **this_cache)
> +			  const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    CORE_ADDR pc = get_frame_pc (this_frame);
> @@ -3377,7 +3377,7 @@ static const struct frame_unwind mips_micro_frame_unwind =
>  };
>  
>  static CORE_ADDR
> -mips_micro_frame_base_address (frame_info_ptr this_frame,
> +mips_micro_frame_base_address (const frame_info_ptr &this_frame,
>  			       void **this_cache)
>  {
>    struct mips_frame_cache *info = mips_micro_frame_cache (this_frame,
> @@ -3394,7 +3394,7 @@ static const struct frame_base mips_micro_frame_base =
>  };
>  
>  static const struct frame_base *
> -mips_micro_frame_base_sniffer (frame_info_ptr this_frame)
> +mips_micro_frame_base_sniffer (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    CORE_ADDR pc = get_frame_pc (this_frame);
> @@ -3432,7 +3432,7 @@ reset_saved_regs (struct gdbarch *gdbarch, struct mips_frame_cache *this_cache)
>  static CORE_ADDR
>  mips32_scan_prologue (struct gdbarch *gdbarch,
>  		      CORE_ADDR start_pc, CORE_ADDR limit_pc,
> -		      frame_info_ptr this_frame,
> +		      const frame_info_ptr &this_frame,
>  		      struct mips_frame_cache *this_cache)
>  {
>    int prev_non_prologue_insn;
> @@ -3677,7 +3677,7 @@ mips32_scan_prologue (struct gdbarch *gdbarch,
>     unwinder.  Likewise microMIPS and the mips_micro unwinder. */
>  
>  static struct mips_frame_cache *
> -mips_insn32_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +mips_insn32_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct mips_frame_cache *cache;
> @@ -3714,7 +3714,7 @@ mips_insn32_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -mips_insn32_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +mips_insn32_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			   struct frame_id *this_id)
>  {
>    struct mips_frame_cache *info = mips_insn32_frame_cache (this_frame,
> @@ -3726,7 +3726,7 @@ mips_insn32_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -mips_insn32_frame_prev_register (frame_info_ptr this_frame,
> +mips_insn32_frame_prev_register (const frame_info_ptr &this_frame,
>  				 void **this_cache, int regnum)
>  {
>    struct mips_frame_cache *info = mips_insn32_frame_cache (this_frame,
> @@ -3736,7 +3736,7 @@ mips_insn32_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  mips_insn32_frame_sniffer (const struct frame_unwind *self,
> -			   frame_info_ptr this_frame, void **this_cache)
> +			   const frame_info_ptr &this_frame, void **this_cache)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    if (mips_pc_is_mips (pc))
> @@ -3756,7 +3756,7 @@ static const struct frame_unwind mips_insn32_frame_unwind =
>  };
>  
>  static CORE_ADDR
> -mips_insn32_frame_base_address (frame_info_ptr this_frame,
> +mips_insn32_frame_base_address (const frame_info_ptr &this_frame,
>  				void **this_cache)
>  {
>    struct mips_frame_cache *info = mips_insn32_frame_cache (this_frame,
> @@ -3773,7 +3773,7 @@ static const struct frame_base mips_insn32_frame_base =
>  };
>  
>  static const struct frame_base *
> -mips_insn32_frame_base_sniffer (frame_info_ptr this_frame)
> +mips_insn32_frame_base_sniffer (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    if (mips_pc_is_mips (pc))
> @@ -3783,7 +3783,7 @@ mips_insn32_frame_base_sniffer (frame_info_ptr this_frame)
>  }
>  
>  static struct trad_frame_cache *
> -mips_stub_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +mips_stub_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    CORE_ADDR pc;
>    CORE_ADDR start_addr;
> @@ -3818,7 +3818,7 @@ mips_stub_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -mips_stub_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +mips_stub_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			 struct frame_id *this_id)
>  {
>    struct trad_frame_cache *this_trad_cache
> @@ -3827,7 +3827,7 @@ mips_stub_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -mips_stub_frame_prev_register (frame_info_ptr this_frame,
> +mips_stub_frame_prev_register (const frame_info_ptr &this_frame,
>  			       void **this_cache, int regnum)
>  {
>    struct trad_frame_cache *this_trad_cache
> @@ -3837,7 +3837,7 @@ mips_stub_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  mips_stub_frame_sniffer (const struct frame_unwind *self,
> -			 frame_info_ptr this_frame, void **this_cache)
> +			 const frame_info_ptr &this_frame, void **this_cache)
>  {
>    gdb_byte dummy[4];
>    CORE_ADDR pc = get_frame_address_in_block (this_frame);
> @@ -3873,7 +3873,7 @@ static const struct frame_unwind mips_stub_frame_unwind =
>  };
>  
>  static CORE_ADDR
> -mips_stub_frame_base_address (frame_info_ptr this_frame,
> +mips_stub_frame_base_address (const frame_info_ptr &this_frame,
>  			      void **this_cache)
>  {
>    struct trad_frame_cache *this_trad_cache
> @@ -3890,7 +3890,7 @@ static const struct frame_base mips_stub_frame_base =
>  };
>  
>  static const struct frame_base *
> -mips_stub_frame_base_sniffer (frame_info_ptr this_frame)
> +mips_stub_frame_base_sniffer (const frame_info_ptr &this_frame)
>  {
>    if (mips_stub_frame_sniffer (&mips_stub_frame_unwind, this_frame, NULL))
>      return &mips_stub_frame_base;
> @@ -6256,7 +6256,7 @@ mips_o64_return_value (struct gdbarch *gdbarch, struct value *function,
>     into rare_buffer.  */
>  
>  static void
> -mips_read_fp_register_single (frame_info_ptr frame, int regno,
> +mips_read_fp_register_single (const frame_info_ptr &frame, int regno,
>  			      gdb_byte *rare_buffer)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -6290,7 +6290,7 @@ mips_read_fp_register_single (frame_info_ptr frame, int regno,
>     register.  */
>  
>  static void
> -mips_read_fp_register_double (frame_info_ptr frame, int regno,
> +mips_read_fp_register_double (const frame_info_ptr &frame, int regno,
>  			      gdb_byte *rare_buffer)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -6328,7 +6328,7 @@ mips_read_fp_register_double (frame_info_ptr frame, int regno,
>  }
>  
>  static void
> -mips_print_fp_register (struct ui_file *file, frame_info_ptr frame,
> +mips_print_fp_register (struct ui_file *file, const frame_info_ptr &frame,
>  			int regnum)
>  {				/* Do values for FP (float) regs.  */
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -6393,7 +6393,7 @@ mips_print_fp_register (struct ui_file *file, frame_info_ptr frame,
>  }
>  
>  static void
> -mips_print_register (struct ui_file *file, frame_info_ptr frame,
> +mips_print_register (struct ui_file *file, const frame_info_ptr &frame,
>  		     int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -6448,7 +6448,7 @@ print_fpu_flags (struct ui_file *file, int flags)
>  
>  static void
>  mips_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
> -		      frame_info_ptr frame, const char *args)
> +		      const frame_info_ptr &frame, const char *args)
>  {
>    int fcsr = mips_regnum (gdbarch)->fp_control_status;
>    enum mips_fpu_type type = mips_get_fpu_type (gdbarch);
> @@ -6515,7 +6515,7 @@ mips_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
>     Print regs in pretty columns.  */
>  
>  static int
> -print_fp_register_row (struct ui_file *file, frame_info_ptr frame,
> +print_fp_register_row (struct ui_file *file, const frame_info_ptr &frame,
>  		       int regnum)
>  {
>    gdb_printf (file, " ");
> @@ -6528,7 +6528,7 @@ print_fp_register_row (struct ui_file *file, frame_info_ptr frame,
>  /* Print a row's worth of GP (int) registers, with name labels above.  */
>  
>  static int
> -print_gp_register_row (struct ui_file *file, frame_info_ptr frame,
> +print_gp_register_row (struct ui_file *file, const frame_info_ptr &frame,
>  		       int start_regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -6631,7 +6631,7 @@ print_gp_register_row (struct ui_file *file, frame_info_ptr frame,
>  
>  static void
>  mips_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
> -			   frame_info_ptr frame, int regnum, int all)
> +			   const frame_info_ptr &frame, int regnum, int all)
>  {
>    if (regnum != -1)		/* Do one specified register.  */
>      {
> @@ -6663,7 +6663,7 @@ mips_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
>  
>  static int
>  mips_single_step_through_delay (struct gdbarch *gdbarch,
> -				frame_info_ptr frame)
> +				const frame_info_ptr &frame)
>  {
>    CORE_ADDR pc = get_frame_pc (frame);
>    enum mips_isa isa;
> @@ -7569,7 +7569,7 @@ mips_is_stub_mode (const char *mode)
>     The limit on the search is arbitrarily set to 20 instructions.  FIXME.  */
>  
>  static CORE_ADDR
> -mips_get_mips16_fn_stub_pc (frame_info_ptr frame, CORE_ADDR pc)
> +mips_get_mips16_fn_stub_pc (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -7692,7 +7692,7 @@ mips_get_mips16_fn_stub_pc (frame_info_ptr frame, CORE_ADDR pc)
>     gory details.  */
>  
>  static CORE_ADDR
> -mips_skip_mips16_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +mips_skip_mips16_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    CORE_ADDR start_addr;
> @@ -7820,7 +7820,7 @@ mips_in_return_stub (struct gdbarch *gdbarch, CORE_ADDR pc, const char *name)
>     so that $t9 has the correct value at function entry.  */
>  
>  static CORE_ADDR
> -mips_skip_pic_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +mips_skip_pic_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -7873,7 +7873,7 @@ mips_skip_pic_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
>  }
>  
>  static CORE_ADDR
> -mips_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +mips_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    CORE_ADDR requested_pc = pc;
>    CORE_ADDR target_pc;
> @@ -8074,7 +8074,7 @@ mips_register_g_packet_guesses (struct gdbarch *gdbarch)
>  }
>  
>  static struct value *
> -value_of_mips_user_reg (frame_info_ptr frame, const void *baton)
> +value_of_mips_user_reg (const frame_info_ptr &frame, const void *baton)
>  {
>    const int *reg_p = (const int *) baton;
>    return value_of_register (*reg_p, get_next_frame_sentinel_okay (frame));
> diff --git a/gdb/mips-tdep.h b/gdb/mips-tdep.h
> index b64f37cebbba..eec1fb56f4e1 100644
> --- a/gdb/mips-tdep.h
> +++ b/gdb/mips-tdep.h
> @@ -125,7 +125,7 @@ struct mips_gdbarch_tdep : gdbarch_tdep_base
>  
>    /* Return the expected next PC if FRAME is stopped at a syscall
>       instruction.  */
> -  CORE_ADDR (*syscall_next_pc) (frame_info_ptr frame) = nullptr;
> +  CORE_ADDR (*syscall_next_pc) (const frame_info_ptr &frame) = nullptr;
>  };
>  
>  /* Register numbers of various important registers.  */
> diff --git a/gdb/mips64-obsd-tdep.c b/gdb/mips64-obsd-tdep.c
> index 6ea49c16a56b..cacb8bbee50a 100644
> --- a/gdb/mips64-obsd-tdep.c
> +++ b/gdb/mips64-obsd-tdep.c
> @@ -77,7 +77,7 @@ mips64obsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
>  
>  static void
>  mips64obsd_sigframe_init (const struct tramp_frame *self,
> -			  frame_info_ptr this_frame,
> +			  const frame_info_ptr &this_frame,
>  			  struct trad_frame_cache *cache,
>  			  CORE_ADDR func)
>  {
> diff --git a/gdb/mn10300-linux-tdep.c b/gdb/mn10300-linux-tdep.c
> index 276e01cdf8ac..4554cb182314 100644
> --- a/gdb/mn10300-linux-tdep.c
> +++ b/gdb/mn10300-linux-tdep.c
> @@ -464,7 +464,7 @@ am33_iterate_over_regset_sections (struct gdbarch *gdbarch,
>  \f
>  static void
>  am33_linux_sigframe_cache_init (const struct tramp_frame *self,
> -				frame_info_ptr this_frame,
> +				const frame_info_ptr &this_frame,
>  				struct trad_frame_cache *this_cache,
>  				CORE_ADDR func);
>  
> @@ -607,7 +607,7 @@ struct sigcontext {
>  
>  static void
>  am33_linux_sigframe_cache_init (const struct tramp_frame *self,
> -				frame_info_ptr this_frame,
> +				const frame_info_ptr &this_frame,
>  				struct trad_frame_cache *this_cache,
>  				CORE_ADDR func)
>  {
> diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
> index 4d65fed38e76..f8c5a0906ef5 100644
> --- a/gdb/mn10300-tdep.c
> +++ b/gdb/mn10300-tdep.c
> @@ -1042,7 +1042,7 @@ mn10300_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>     use the current frame PC as the limit, then
>     invoke mn10300_analyze_prologue and return its result.  */
>  static struct mn10300_prologue *
> -mn10300_analyze_frame_prologue (frame_info_ptr this_frame,
> +mn10300_analyze_frame_prologue (const frame_info_ptr &this_frame,
>  			   void **this_prologue_cache)
>  {
>    if (!*this_prologue_cache)
> @@ -1071,7 +1071,7 @@ mn10300_analyze_frame_prologue (frame_info_ptr this_frame,
>  /* Given the next frame and a prologue cache, return this frame's
>     base.  */
>  static CORE_ADDR
> -mn10300_frame_base (frame_info_ptr this_frame, void **this_prologue_cache)
> +mn10300_frame_base (const frame_info_ptr &this_frame, void **this_prologue_cache)
>  {
>    struct mn10300_prologue *p
>      = mn10300_analyze_frame_prologue (this_frame, this_prologue_cache);
> @@ -1095,7 +1095,7 @@ mn10300_frame_base (frame_info_ptr this_frame, void **this_prologue_cache)
>  }
>  
>  static void
> -mn10300_frame_this_id (frame_info_ptr this_frame,
> +mn10300_frame_this_id (const frame_info_ptr &this_frame,
>  		       void **this_prologue_cache,
>  		       struct frame_id *this_id)
>  {
> @@ -1106,7 +1106,7 @@ mn10300_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -mn10300_frame_prev_register (frame_info_ptr this_frame,
> +mn10300_frame_prev_register (const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache, int regnum)
>  {
>    struct mn10300_prologue *p
> diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
> index 4a80355ada55..812c92d1e0af 100644
> --- a/gdb/moxie-tdep.c
> +++ b/gdb/moxie-tdep.c
> @@ -514,7 +514,7 @@ moxie_alloc_frame_cache (void)
>  /* Populate a moxie_frame_cache object for this_frame.  */
>  
>  static struct moxie_frame_cache *
> -moxie_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +moxie_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct moxie_frame_cache *cache;
>    CORE_ADDR current_pc;
> @@ -551,7 +551,7 @@ moxie_frame_cache (frame_info_ptr this_frame, void **this_cache)
>     frame.  This will be used to create a new GDB frame struct.  */
>  
>  static void
> -moxie_frame_this_id (frame_info_ptr this_frame,
> +moxie_frame_this_id (const frame_info_ptr &this_frame,
>  		    void **this_prologue_cache, struct frame_id *this_id)
>  {
>    struct moxie_frame_cache *cache = moxie_frame_cache (this_frame,
> @@ -567,7 +567,7 @@ moxie_frame_this_id (frame_info_ptr this_frame,
>  /* Get the value of register regnum in the previous stack frame.  */
>  
>  static struct value *
> -moxie_frame_prev_register (frame_info_ptr this_frame,
> +moxie_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache, int regnum)
>  {
>    struct moxie_frame_cache *cache = moxie_frame_cache (this_frame,
> @@ -598,7 +598,7 @@ static const struct frame_unwind moxie_frame_unwind = {
>  /* Return the base address of this_frame.  */
>  
>  static CORE_ADDR
> -moxie_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +moxie_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct moxie_frame_cache *cache = moxie_frame_cache (this_frame,
>  						       this_cache);
> diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c
> index 6bbb1d43300f..e07e3cc4be2b 100644
> --- a/gdb/msp430-tdep.c
> +++ b/gdb/msp430-tdep.c
> @@ -458,7 +458,7 @@ msp430_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>     return that struct as the value of this function.  */
>  
>  static struct msp430_prologue *
> -msp430_analyze_frame_prologue (frame_info_ptr this_frame,
> +msp430_analyze_frame_prologue (const frame_info_ptr &this_frame,
>  			       void **this_prologue_cache)
>  {
>    if (!*this_prologue_cache)
> @@ -486,7 +486,7 @@ msp430_analyze_frame_prologue (frame_info_ptr this_frame,
>  /* Given a frame and a prologue cache, return this frame's base.  */
>  
>  static CORE_ADDR
> -msp430_frame_base (frame_info_ptr this_frame, void **this_prologue_cache)
> +msp430_frame_base (const frame_info_ptr &this_frame, void **this_prologue_cache)
>  {
>    struct msp430_prologue *p
>      = msp430_analyze_frame_prologue (this_frame, this_prologue_cache);
> @@ -498,7 +498,7 @@ msp430_frame_base (frame_info_ptr this_frame, void **this_prologue_cache)
>  /* Implement the "frame_this_id" method for unwinding frames.  */
>  
>  static void
> -msp430_this_id (frame_info_ptr this_frame,
> +msp430_this_id (const frame_info_ptr &this_frame,
>  		void **this_prologue_cache, struct frame_id *this_id)
>  {
>    *this_id = frame_id_build (msp430_frame_base (this_frame,
> @@ -509,7 +509,7 @@ msp430_this_id (frame_info_ptr this_frame,
>  /* Implement the "frame_prev_register" method for unwinding frames.  */
>  
>  static struct value *
> -msp430_prev_register (frame_info_ptr this_frame,
> +msp430_prev_register (const frame_info_ptr &this_frame,
>  		      void **this_prologue_cache, int regnum)
>  {
>    struct msp430_prologue *p
> @@ -805,7 +805,7 @@ msp430_in_return_stub (struct gdbarch *gdbarch, CORE_ADDR pc,
>  
>  /* Implement the "skip_trampoline_code" gdbarch method.  */
>  static CORE_ADDR
> -msp430_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +msp430_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct bound_minimal_symbol bms;
>    const char *stub_name;
> diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
> index d4be42ce777e..e453cd0f6d9a 100644
> --- a/gdb/nds32-tdep.c
> +++ b/gdb/nds32-tdep.c
> @@ -265,7 +265,7 @@ static const struct
>     register.  */
>  
>  static struct value *
> -value_of_nds32_reg (frame_info_ptr frame, const void *baton)
> +value_of_nds32_reg (const frame_info_ptr &frame, const void *baton)
>  {
>    return value_of_register ((int) (intptr_t) baton,
>  			    get_next_frame_sentinel_okay (frame));
> @@ -902,7 +902,7 @@ nds32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>     a pointer to the current nds32_frame_cache in *THIS_CACHE.  */
>  
>  static struct nds32_frame_cache *
> -nds32_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +nds32_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct nds32_frame_cache *cache;
> @@ -953,7 +953,7 @@ nds32_frame_cache (frame_info_ptr this_frame, void **this_cache)
>     PC and the caller's SP when we were called.  */
>  
>  static void
> -nds32_frame_this_id (frame_info_ptr this_frame,
> +nds32_frame_this_id (const frame_info_ptr &this_frame,
>  		     void **this_cache, struct frame_id *this_id)
>  {
>    struct nds32_frame_cache *cache = nds32_frame_cache (this_frame, this_cache);
> @@ -968,7 +968,7 @@ nds32_frame_this_id (frame_info_ptr this_frame,
>  /* Implement the "prev_register" frame_unwind method.  */
>  
>  static struct value *
> -nds32_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +nds32_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			   int regnum)
>  {
>    struct nds32_frame_cache *cache = nds32_frame_cache (this_frame, this_cache);
> @@ -1002,7 +1002,7 @@ static const struct frame_unwind nds32_frame_unwind =
>  /* Return the frame base address of *THIS_FRAME.  */
>  
>  static CORE_ADDR
> -nds32_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +nds32_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct nds32_frame_cache *cache = nds32_frame_cache (this_frame, this_cache);
>  
> @@ -1288,7 +1288,7 @@ nds32_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR addr)
>  
>  static int
>  nds32_epilogue_frame_sniffer (const struct frame_unwind *self,
> -			      frame_info_ptr this_frame, void **this_cache)
> +			      const frame_info_ptr &this_frame, void **this_cache)
>  {
>    if (frame_relative_level (this_frame) == 0)
>      return nds32_stack_frame_destroyed_p (get_frame_arch (this_frame),
> @@ -1303,7 +1303,7 @@ nds32_epilogue_frame_sniffer (const struct frame_unwind *self,
>     *THIS_CACHE.  */
>  
>  static struct nds32_frame_cache *
> -nds32_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +nds32_epilogue_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct nds32_frame_cache *cache;
> @@ -1335,7 +1335,7 @@ nds32_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  /* Implement the "this_id" frame_unwind method.  */
>  
>  static void
> -nds32_epilogue_frame_this_id (frame_info_ptr this_frame,
> +nds32_epilogue_frame_this_id (const frame_info_ptr &this_frame,
>  			      void **this_cache, struct frame_id *this_id)
>  {
>    struct nds32_frame_cache *cache
> @@ -1351,7 +1351,7 @@ nds32_epilogue_frame_this_id (frame_info_ptr this_frame,
>  /* Implement the "prev_register" frame_unwind method.  */
>  
>  static struct value *
> -nds32_epilogue_frame_prev_register (frame_info_ptr this_frame,
> +nds32_epilogue_frame_prev_register (const frame_info_ptr &this_frame,
>  				    void **this_cache, int regnum)
>  {
>    struct nds32_frame_cache *cache
> @@ -1825,7 +1825,7 @@ nds32_return_value (struct gdbarch *gdbarch, struct value *func_type,
>  /* Implement the "get_longjmp_target" gdbarch method.  */
>  
>  static int
> -nds32_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +nds32_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    gdb_byte buf[4];
>    CORE_ADDR jb_addr;
> diff --git a/gdb/nios2-linux-tdep.c b/gdb/nios2-linux-tdep.c
> index 1ff097781069..9d2d4fff04a2 100644
> --- a/gdb/nios2-linux-tdep.c
> +++ b/gdb/nios2-linux-tdep.c
> @@ -134,7 +134,7 @@ nios2_iterate_over_regset_sections (struct gdbarch *gdbarch,
>  
>  static void
>  nios2_linux_rt_sigreturn_init (const struct tramp_frame *self,
> -			       frame_info_ptr next_frame,
> +			       const frame_info_ptr &next_frame,
>  			       struct trad_frame_cache *this_cache,
>  			       CORE_ADDR func)
>  {
> @@ -187,7 +187,7 @@ static struct tramp_frame nios2_r2_linux_rt_sigreturn_tramp_frame =
>     instruction to be executed.  */
>  
>  static CORE_ADDR
> -nios2_linux_syscall_next_pc (frame_info_ptr frame,
> +nios2_linux_syscall_next_pc (const frame_info_ptr &frame,
>  			     const struct nios2_opcode *op)
>  {
>    CORE_ADDR pc = get_frame_pc (frame);
> diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
> index 196f50bc8694..0a8eeb88bb5a 100644
> --- a/gdb/nios2-tdep.c
> +++ b/gdb/nios2-tdep.c
> @@ -1189,7 +1189,7 @@ static CORE_ADDR
>  nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
>  			const CORE_ADDR current_pc,
>  			struct nios2_unwind_cache *cache,
> -			frame_info_ptr this_frame)
> +			const frame_info_ptr &this_frame)
>  {
>    /* Maximum number of possibly-prologue instructions to check.
>       Note that this number should not be too large, else we can
> @@ -1880,7 +1880,7 @@ nios2_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
>  /* Implement the unwind_pc gdbarch method.  */
>  
>  static CORE_ADDR
> -nios2_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +nios2_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    gdb_byte buf[4];
>  
> @@ -1893,7 +1893,7 @@ nios2_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>     *THIS_PROLOGUE_CACHE first.  */
>  
>  static struct nios2_unwind_cache *
> -nios2_frame_unwind_cache (frame_info_ptr this_frame,
> +nios2_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1920,7 +1920,7 @@ nios2_frame_unwind_cache (frame_info_ptr this_frame,
>  /* Implement the this_id function for the normal unwinder.  */
>  
>  static void
> -nios2_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +nios2_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		     struct frame_id *this_id)
>  {
>    struct nios2_unwind_cache *cache =
> @@ -1936,7 +1936,7 @@ nios2_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  /* Implement the prev_register function for the normal unwinder.  */
>  
>  static struct value *
> -nios2_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +nios2_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			   int regnum)
>  {
>    struct nios2_unwind_cache *cache =
> @@ -1966,7 +1966,7 @@ nios2_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
>     for the normal unwinder.  */
>  
>  static CORE_ADDR
> -nios2_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +nios2_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct nios2_unwind_cache *info
>      = nios2_frame_unwind_cache (this_frame, this_cache);
> @@ -2000,7 +2000,7 @@ static const struct frame_base nios2_frame_base =
>     in the stub unwinder.  */
>  
>  static struct trad_frame_cache *
> -nios2_stub_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +nios2_stub_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    CORE_ADDR pc;
>    CORE_ADDR start_addr;
> @@ -2033,7 +2033,7 @@ nios2_stub_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  /* Implement the this_id function for the stub unwinder.  */
>  
>  static void
> -nios2_stub_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +nios2_stub_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			  struct frame_id *this_id)
>  {
>    struct trad_frame_cache *this_trad_cache
> @@ -2045,7 +2045,7 @@ nios2_stub_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  /* Implement the prev_register function for the stub unwinder.  */
>  
>  static struct value *
> -nios2_stub_frame_prev_register (frame_info_ptr this_frame,
> +nios2_stub_frame_prev_register (const frame_info_ptr &this_frame,
>  				void **this_cache, int regnum)
>  {
>    struct trad_frame_cache *this_trad_cache
> @@ -2061,7 +2061,7 @@ nios2_stub_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  nios2_stub_frame_sniffer (const struct frame_unwind *self,
> -			  frame_info_ptr this_frame, void **cache)
> +			  const frame_info_ptr &this_frame, void **cache)
>  {
>    gdb_byte dummy[4];
>    CORE_ADDR pc = get_frame_address_in_block (this_frame);
> @@ -2218,7 +2218,7 @@ nios2_software_single_step (struct regcache *regcache)
>  /* Implement the get_longjump_target gdbarch method.  */
>  
>  static int
> -nios2_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +nios2_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    nios2_gdbarch_tdep *tdep = gdbarch_tdep<nios2_gdbarch_tdep> (gdbarch);
> diff --git a/gdb/nios2-tdep.h b/gdb/nios2-tdep.h
> index ae68131736af..57e0de7076d0 100644
> --- a/gdb/nios2-tdep.h
> +++ b/gdb/nios2-tdep.h
> @@ -73,7 +73,7 @@ struct nios2_gdbarch_tdep : gdbarch_tdep_base
>  {
>    /* Assumes FRAME is stopped at a syscall (trap) instruction; returns
>       the expected next PC.  */
> -  CORE_ADDR (*syscall_next_pc) (frame_info_ptr frame,
> +  CORE_ADDR (*syscall_next_pc) (const frame_info_ptr &frame,
>  				const struct nios2_opcode *op) = nullptr;
>  
>    /* Returns true if PC points to a kernel helper function.  */
> diff --git a/gdb/observable.h b/gdb/observable.h
> index 0e9226982772..2aa3ef3fd4ee 100644
> --- a/gdb/observable.h
> +++ b/gdb/observable.h
> @@ -217,7 +217,7 @@ extern observable<ptid_t /* thread */, CORE_ADDR /* address */>
>      inferior_call_post;
>  
>  /* A register in the inferior has been modified by the gdb user.  */
> -extern observable<frame_info_ptr /* frame */, int /* regnum */>
> +extern observable<const frame_info_ptr &/* frame */, int /* regnum */>
>      register_changed;
>  
>  /* The user-selected inferior, thread and/or frame has changed.  The
> diff --git a/gdb/or1k-linux-tdep.c b/gdb/or1k-linux-tdep.c
> index 5b65559bdeb0..75ab8459e754 100644
> --- a/gdb/or1k-linux-tdep.c
> +++ b/gdb/or1k-linux-tdep.c
> @@ -62,7 +62,7 @@ or1k_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
>  /* Signal trampoline support.  */
>  
>  static void or1k_linux_sigframe_init (const struct tramp_frame *self,
> -				       frame_info_ptr this_frame,
> +				       const frame_info_ptr &this_frame,
>  				       struct trad_frame_cache *this_cache,
>  				       CORE_ADDR func);
>  
> @@ -116,7 +116,7 @@ static const struct tramp_frame or1k_linux_sigframe = {
>  
>  static void
>  or1k_linux_sigframe_init (const struct tramp_frame *self,
> -			   frame_info_ptr this_frame,
> +			   const frame_info_ptr &this_frame,
>  			   struct trad_frame_cache *this_cache,
>  			   CORE_ADDR func)
>  {
> diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
> index c8365dc9d721..ffcb50f4bcd1 100644
> --- a/gdb/or1k-tdep.c
> +++ b/gdb/or1k-tdep.c
> @@ -378,7 +378,7 @@ or1k_delay_slot_p (struct gdbarch *gdbarch, CORE_ADDR pc)
>  
>  static int
>  or1k_single_step_through_delay (struct gdbarch *gdbarch,
> -				frame_info_ptr this_frame)
> +				const frame_info_ptr &this_frame)
>  {
>    ULONGEST val;
>    CORE_ADDR ppc;
> @@ -558,7 +558,7 @@ or1k_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
>  /* Implement the unwind_pc gdbarch method.  */
>  
>  static CORE_ADDR
> -or1k_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +or1k_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    CORE_ADDR pc;
>  
> @@ -578,7 +578,7 @@ or1k_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  /* Implement the unwind_sp gdbarch method.  */
>  
>  static CORE_ADDR
> -or1k_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +or1k_unwind_sp (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    CORE_ADDR sp;
>  
> @@ -889,7 +889,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
>     Reportedly, this is only valid for frames less than 0x7fff in size.  */
>  
>  static struct trad_frame_cache *
> -or1k_frame_cache (frame_info_ptr this_frame, void **prologue_cache)
> +or1k_frame_cache (const frame_info_ptr &this_frame, void **prologue_cache)
>  {
>    struct gdbarch *gdbarch;
>    struct trad_frame_cache *info;
> @@ -1102,7 +1102,7 @@ or1k_frame_cache (frame_info_ptr this_frame, void **prologue_cache)
>  /* Implement the this_id function for the stub unwinder.  */
>  
>  static void
> -or1k_frame_this_id (frame_info_ptr this_frame,
> +or1k_frame_this_id (const frame_info_ptr &this_frame,
>  		    void **prologue_cache, struct frame_id *this_id)
>  {
>    struct trad_frame_cache *info = or1k_frame_cache (this_frame,
> @@ -1114,7 +1114,7 @@ or1k_frame_this_id (frame_info_ptr this_frame,
>  /* Implement the prev_register function for the stub unwinder.  */
>  
>  static struct value *
> -or1k_frame_prev_register (frame_info_ptr this_frame,
> +or1k_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **prologue_cache, int regnum)
>  {
>    struct trad_frame_cache *info = or1k_frame_cache (this_frame,
> diff --git a/gdb/ppc-fbsd-tdep.c b/gdb/ppc-fbsd-tdep.c
> index e70056a2ac80..719ddc71d130 100644
> --- a/gdb/ppc-fbsd-tdep.c
> +++ b/gdb/ppc-fbsd-tdep.c
> @@ -150,7 +150,7 @@ static const int ppcfbsd_sigreturn_offset[] = {
>  
>  static int
>  ppcfbsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				frame_info_ptr this_frame,
> +				const frame_info_ptr &this_frame,
>  				void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -197,7 +197,7 @@ ppcfbsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
>  }
>  
>  static struct trad_frame_cache *
> -ppcfbsd_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +ppcfbsd_sigtramp_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
> @@ -243,7 +243,7 @@ ppcfbsd_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -ppcfbsd_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +ppcfbsd_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				void **this_cache, struct frame_id *this_id)
>  {
>    struct trad_frame_cache *cache =
> @@ -253,7 +253,7 @@ ppcfbsd_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -ppcfbsd_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +ppcfbsd_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  				      void **this_cache, int regnum)
>  {
>    struct trad_frame_cache *cache =
> diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
> index a7c1104b29f4..2824cb628c3d 100644
> --- a/gdb/ppc-linux-tdep.c
> +++ b/gdb/ppc-linux-tdep.c
> @@ -338,7 +338,7 @@ powerpc_linux_in_dynsym_resolve_code (CORE_ADDR pc)
>     stub sequence.  */
>  
>  static CORE_ADDR
> -ppc_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +ppc_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    unsigned int insnbuf[POWERPC32_PLT_CHECK_LEN];
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -1169,7 +1169,7 @@ ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
>  }
>  
>  static void
> -ppc_linux_sigtramp_cache (frame_info_ptr this_frame,
> +ppc_linux_sigtramp_cache (const frame_info_ptr &this_frame,
>  			  struct trad_frame_cache *this_cache,
>  			  CORE_ADDR func, LONGEST offset,
>  			  int bias)
> @@ -1241,7 +1241,7 @@ ppc_linux_sigtramp_cache (frame_info_ptr this_frame,
>  
>  static void
>  ppc32_linux_sigaction_cache_init (const struct tramp_frame *self,
> -				  frame_info_ptr this_frame,
> +				  const frame_info_ptr &this_frame,
>  				  struct trad_frame_cache *this_cache,
>  				  CORE_ADDR func)
>  {
> @@ -1253,7 +1253,7 @@ ppc32_linux_sigaction_cache_init (const struct tramp_frame *self,
>  
>  static void
>  ppc64_linux_sigaction_cache_init (const struct tramp_frame *self,
> -				  frame_info_ptr this_frame,
> +				  const frame_info_ptr &this_frame,
>  				  struct trad_frame_cache *this_cache,
>  				  CORE_ADDR func)
>  {
> @@ -1265,7 +1265,7 @@ ppc64_linux_sigaction_cache_init (const struct tramp_frame *self,
>  
>  static void
>  ppc32_linux_sighandler_cache_init (const struct tramp_frame *self,
> -				   frame_info_ptr this_frame,
> +				   const frame_info_ptr &this_frame,
>  				   struct trad_frame_cache *this_cache,
>  				   CORE_ADDR func)
>  {
> @@ -1277,7 +1277,7 @@ ppc32_linux_sighandler_cache_init (const struct tramp_frame *self,
>  
>  static void
>  ppc64_linux_sighandler_cache_init (const struct tramp_frame *self,
> -				   frame_info_ptr this_frame,
> +				   const frame_info_ptr &this_frame,
>  				   struct trad_frame_cache *this_cache,
>  				   CORE_ADDR func)
>  {
> diff --git a/gdb/ppc-netbsd-tdep.c b/gdb/ppc-netbsd-tdep.c
> index 0245969e8648..58f5678d5d9c 100644
> --- a/gdb/ppc-netbsd-tdep.c
> +++ b/gdb/ppc-netbsd-tdep.c
> @@ -97,7 +97,7 @@ extern const struct tramp_frame ppcnbsd2_sigtramp;
>  
>  static void
>  ppcnbsd_sigtramp_cache_init (const struct tramp_frame *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     struct trad_frame_cache *this_cache,
>  			     CORE_ADDR func)
>  {
> diff --git a/gdb/ppc-obsd-tdep.c b/gdb/ppc-obsd-tdep.c
> index d9e21e3a3269..b845e67bcaab 100644
> --- a/gdb/ppc-obsd-tdep.c
> +++ b/gdb/ppc-obsd-tdep.c
> @@ -117,7 +117,7 @@ static const int ppcobsd_sigreturn_offset[] = {
>  
>  static int
>  ppcobsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				frame_info_ptr this_frame,
> +				const frame_info_ptr &this_frame,
>  				void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -158,7 +158,7 @@ ppcobsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
>  }
>  
>  static struct trad_frame_cache *
> -ppcobsd_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +ppcobsd_sigtramp_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
> @@ -212,7 +212,7 @@ ppcobsd_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -ppcobsd_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +ppcobsd_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				void **this_cache, struct frame_id *this_id)
>  {
>    struct trad_frame_cache *cache =
> @@ -222,7 +222,7 @@ ppcobsd_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -ppcobsd_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +ppcobsd_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  				      void **this_cache, int regnum)
>  {
>    struct trad_frame_cache *cache =
> diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
> index 59365fc490c7..ebbf1cf4295f 100644
> --- a/gdb/ppc-sysv-tdep.c
> +++ b/gdb/ppc-sysv-tdep.c
> @@ -2163,7 +2163,8 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
>  }
>  
>  CORE_ADDR
> -ppc_sysv_get_return_buf_addr (struct type *val_type, frame_info_ptr cur_frame)
> +ppc_sysv_get_return_buf_addr (struct type *val_type,
> +			      const frame_info_ptr &cur_frame)
>  {
>    /* The PowerPC ABI specifies aggregates that are not returned by value
>       are returned in a storage buffer provided by the caller.  The
> diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
> index d4a62d2e33c2..db31c7f199ac 100644
> --- a/gdb/ppc-tdep.h
> +++ b/gdb/ppc-tdep.h
> @@ -177,7 +177,7 @@ extern void ppc_collect_vsxregset (const struct regset *regset,
>  
>  /* Implementation of the gdbarch get_return_buf_addr hook.  */
>  
> -extern CORE_ADDR ppc_sysv_get_return_buf_addr (type*, frame_info_ptr);
> +extern CORE_ADDR ppc_sysv_get_return_buf_addr (type*, const frame_info_ptr &);
>  
>  /* Private data that this module attaches to struct gdbarch.  */
>  
> @@ -424,7 +424,7 @@ struct ppc_insn_pattern
>    int optional;                 /* If non-zero, this insn may be absent.  */
>  };
>  
> -extern int ppc_insns_match_pattern (frame_info_ptr frame, CORE_ADDR pc,
> +extern int ppc_insns_match_pattern (const frame_info_ptr &frame, CORE_ADDR pc,
>  				    const struct ppc_insn_pattern *pattern,
>  				    unsigned int *insns);
>  extern CORE_ADDR ppc_insn_d_field (unsigned int insn);
> diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c
> index d415836c69df..5797d55f00b7 100644
> --- a/gdb/ppc64-tdep.c
> +++ b/gdb/ppc64-tdep.c
> @@ -85,7 +85,7 @@
>     Return the function's entry point.  */
>  
>  static CORE_ADDR
> -ppc64_plt_entry_point (frame_info_ptr frame, CORE_ADDR plt_off)
> +ppc64_plt_entry_point (const frame_info_ptr &frame, CORE_ADDR plt_off)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -108,7 +108,7 @@ ppc64_plt_entry_point (frame_info_ptr frame, CORE_ADDR plt_off)
>  }
>  
>  static CORE_ADDR
> -ppc64_plt_pcrel_entry_point (frame_info_ptr frame, CORE_ADDR plt_off,
> +ppc64_plt_pcrel_entry_point (const frame_info_ptr &frame, CORE_ADDR plt_off,
>  			     CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -546,7 +546,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage12[] =
>     dynamic linker lazy symbol resolution stubs.)  */
>  
>  static CORE_ADDR
> -ppc64_standard_linkage1_target (frame_info_ptr frame, unsigned int *insn)
> +ppc64_standard_linkage1_target (const frame_info_ptr &frame, unsigned int *insn)
>  {
>    CORE_ADDR plt_off = ((ppc_insn_d_field (insn[0]) << 16)
>  		       + ppc_insn_ds_field (insn[2]));
> @@ -555,7 +555,7 @@ ppc64_standard_linkage1_target (frame_info_ptr frame, unsigned int *insn)
>  }
>  
>  static CORE_ADDR
> -ppc64_standard_linkage2_target (frame_info_ptr frame, unsigned int *insn)
> +ppc64_standard_linkage2_target (const frame_info_ptr &frame, unsigned int *insn)
>  {
>    CORE_ADDR plt_off = ((ppc_insn_d_field (insn[1]) << 16)
>  		       + ppc_insn_ds_field (insn[3]));
> @@ -564,7 +564,7 @@ ppc64_standard_linkage2_target (frame_info_ptr frame, unsigned int *insn)
>  }
>  
>  static CORE_ADDR
> -ppc64_standard_linkage3_target (frame_info_ptr frame, unsigned int *insn)
> +ppc64_standard_linkage3_target (const frame_info_ptr &frame, unsigned int *insn)
>  {
>    CORE_ADDR plt_off = ppc_insn_ds_field (insn[1]);
>  
> @@ -572,7 +572,7 @@ ppc64_standard_linkage3_target (frame_info_ptr frame, unsigned int *insn)
>  }
>  
>  static CORE_ADDR
> -ppc64_standard_linkage4_target (frame_info_ptr frame, unsigned int *insn)
> +ppc64_standard_linkage4_target (const frame_info_ptr &frame, unsigned int *insn)
>  {
>    CORE_ADDR plt_off = ((ppc_insn_d_field (insn[1]) << 16)
>  		       + ppc_insn_ds_field (insn[2]));
> @@ -581,7 +581,7 @@ ppc64_standard_linkage4_target (frame_info_ptr frame, unsigned int *insn)
>  }
>  
>  static CORE_ADDR
> -ppc64_pcrel_linkage1_target (frame_info_ptr frame, unsigned int *insn,
> +ppc64_pcrel_linkage1_target (const frame_info_ptr &frame, unsigned int *insn,
>  			     CORE_ADDR pc)
>  {
>    /* insn[0] is for the std instruction.  */
> @@ -591,7 +591,7 @@ ppc64_pcrel_linkage1_target (frame_info_ptr frame, unsigned int *insn,
>  }
>  
>  static CORE_ADDR
> -ppc64_pcrel_linkage2_target (frame_info_ptr frame, unsigned int *insn,
> +ppc64_pcrel_linkage2_target (const frame_info_ptr &frame, unsigned int *insn,
>  			     CORE_ADDR pc)
>  {
>    CORE_ADDR plt_off;
> @@ -611,7 +611,7 @@ ppc64_pcrel_linkage2_target (frame_info_ptr frame, unsigned int *insn,
>     check whether we are in the middle of a PLT stub.  */
>  
>  static CORE_ADDR
> -ppc64_skip_trampoline_code_1 (frame_info_ptr frame, CORE_ADDR pc)
> +ppc64_skip_trampoline_code_1 (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>  #define MAX(a,b) ((a) > (b) ? (a) : (b))
>    unsigned int insns[MAX (MAX (MAX (ARRAY_SIZE (ppc64_standard_linkage1),
> @@ -707,7 +707,7 @@ ppc64_skip_trampoline_code_1 (frame_info_ptr frame, CORE_ADDR pc)
>     ppc_elfv2_skip_entrypoint.  */
>  
>  CORE_ADDR
> -ppc64_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +ppc64_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>  
> diff --git a/gdb/ppc64-tdep.h b/gdb/ppc64-tdep.h
> index 4dc6e6a87091..ff0e3fdd033e 100644
> --- a/gdb/ppc64-tdep.h
> +++ b/gdb/ppc64-tdep.h
> @@ -24,7 +24,7 @@ struct gdbarch;
>  class frame_info_ptr;
>  struct target_ops;
>  
> -extern CORE_ADDR ppc64_skip_trampoline_code (frame_info_ptr frame,
> +extern CORE_ADDR ppc64_skip_trampoline_code (const frame_info_ptr &frame,
>  					     CORE_ADDR pc);
>  
>  extern CORE_ADDR ppc64_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
> index 7f47f489a943..43c0f447fa8a 100644
> --- a/gdb/printcmd.c
> +++ b/gdb/printcmd.c
> @@ -2330,7 +2330,7 @@ clear_dangling_display_expressions (struct objfile *objfile)
>  
>  void
>  print_variable_and_value (const char *name, struct symbol *var,
> -			  frame_info_ptr frame,
> +			  const frame_info_ptr &frame,
>  			  struct ui_file *stream, int indent)
>  {
>  
> diff --git a/gdb/probe.c b/gdb/probe.c
> index a68283ab5ce7..4d68e129636e 100644
> --- a/gdb/probe.c
> +++ b/gdb/probe.c
> @@ -786,7 +786,7 @@ ignore_probes_command (const char *arg, int from_tty)
>  /* See comments in probe.h.  */
>  
>  struct value *
> -probe_safe_evaluate_at_pc (frame_info_ptr frame, unsigned n)
> +probe_safe_evaluate_at_pc (const frame_info_ptr &frame, unsigned n)
>  {
>    struct bound_probe probe;
>    unsigned n_args;
> diff --git a/gdb/probe.h b/gdb/probe.h
> index 31b0b8b8f739..41e728ad049e 100644
> --- a/gdb/probe.h
> +++ b/gdb/probe.h
> @@ -143,7 +143,7 @@ class probe
>       corresponding to it.  The argument number is represented N.
>       This function can throw an exception.  */
>    virtual struct value *evaluate_argument (unsigned n,
> -					   frame_info_ptr frame) = 0;
> +					   const frame_info_ptr &frame) = 0;
>  
>    /* Compile the Nth argument of the probe to an agent expression.
>       The argument number is represented by N.  */
> @@ -301,7 +301,7 @@ extern struct cmd_list_element **info_probes_cmdlist_get (void);
>     probe at that location, or if the probe does not have enough arguments,
>     this returns NULL.  */
>  
> -extern struct value *probe_safe_evaluate_at_pc (frame_info_ptr frame,
> +extern struct value *probe_safe_evaluate_at_pc (const frame_info_ptr &frame,
>  						unsigned n);
>  
>  /* Return true if the PROVIDER/NAME probe from OBJFILE_NAME needs to be
> diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
> index 30dd054305b6..388c513e5e9b 100644
> --- a/gdb/python/py-event.h
> +++ b/gdb/python/py-event.h
> @@ -55,7 +55,7 @@ enum inferior_call_kind
>  
>  extern int emit_inferior_call_event (inferior_call_kind kind,
>  				     ptid_t thread, CORE_ADDR addr);
> -extern int emit_register_changed_event (frame_info_ptr frame,
> +extern int emit_register_changed_event (const frame_info_ptr &frame,
>  					int regnum);
>  extern int emit_memory_changed_event (CORE_ADDR addr, ssize_t len);
>  extern int evpy_emit_event (PyObject *event,
> diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
> index a1061fc0d729..7467f845b78f 100644
> --- a/gdb/python/py-frame.c
> +++ b/gdb/python/py-frame.c
> @@ -361,7 +361,7 @@ frapy_function (PyObject *self, PyObject *args)
>     Sets a Python exception and returns NULL on error.  */
>  
>  PyObject *
> -frame_info_to_frame_object (frame_info_ptr frame)
> +frame_info_to_frame_object (const frame_info_ptr &frame)
>  {
>    gdbpy_ref<frame_object> frame_obj (PyObject_New (frame_object,
>  						   &frame_object_type));
> diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
> index fd2757d686d6..768e3a6e0c81 100644
> --- a/gdb/python/py-framefilter.c
> +++ b/gdb/python/py-framefilter.c
> @@ -416,7 +416,7 @@ enumerate_args (PyObject *iter,
>  		enum ext_lang_frame_args args_type,
>  		bool raw_frame_args,
>  		int print_args_field,
> -		frame_info_ptr frame)
> +		const frame_info_ptr &frame)
>  {
>    struct value_print_options opts;
>  
> @@ -548,7 +548,7 @@ enumerate_locals (PyObject *iter,
>  		  int indent,
>  		  enum ext_lang_frame_args args_type,
>  		  int print_args_field,
> -		  frame_info_ptr frame)
> +		  const frame_info_ptr &frame)
>  {
>    struct value_print_options opts;
>  
> @@ -636,7 +636,7 @@ static enum ext_lang_bt_status
>  py_mi_print_variables (PyObject *filter, struct ui_out *out,
>  		       struct value_print_options *opts,
>  		       enum ext_lang_frame_args args_type,
> -		       frame_info_ptr frame,
> +		       const frame_info_ptr &frame,
>  		       bool raw_frame_args_p)
>  {
>    gdbpy_ref<> args_iter (get_py_iter_from_func (filter, "frame_args"));
> @@ -671,7 +671,7 @@ py_print_locals (PyObject *filter,
>  		 struct ui_out *out,
>  		 enum ext_lang_frame_args args_type,
>  		 int indent,
> -		 frame_info_ptr frame)
> +		 const frame_info_ptr &frame)
>  {
>    gdbpy_ref<> locals_iter (get_py_iter_from_func (filter, "frame_locals"));
>    if (locals_iter == NULL)
> @@ -697,7 +697,7 @@ py_print_args (PyObject *filter,
>  	       struct ui_out *out,
>  	       enum ext_lang_frame_args args_type,
>  	       bool raw_frame_args,
> -	       frame_info_ptr frame)
> +	       const frame_info_ptr &frame)
>  {
>    gdbpy_ref<> args_iter (get_py_iter_from_func (filter, "frame_args"));
>    if (args_iter == NULL)
> @@ -1082,7 +1082,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
>     frame FRAME.  */
>  
>  static PyObject *
> -bootstrap_python_frame_filters (frame_info_ptr frame,
> +bootstrap_python_frame_filters (const frame_info_ptr &frame,
>  				int frame_low, int frame_high)
>  {
>    gdbpy_ref<> frame_obj (frame_info_to_frame_object (frame));
> @@ -1137,7 +1137,7 @@ bootstrap_python_frame_filters (frame_info_ptr frame,
>  
>  enum ext_lang_bt_status
>  gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
> -			  frame_info_ptr frame, frame_filter_flags flags,
> +			  const frame_info_ptr &frame, frame_filter_flags flags,
>  			  enum ext_lang_frame_args args_type,
>  			  struct ui_out *out, int frame_low, int frame_high)
>  {
> diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
> index 834f7274d1e7..caf6c1bdd53e 100644
> --- a/gdb/python/py-inferior.c
> +++ b/gdb/python/py-inferior.c
> @@ -159,7 +159,7 @@ python_on_memory_change (struct inferior *inferior, CORE_ADDR addr, ssize_t len,
>     command). */
>  
>  static void
> -python_on_register_change (frame_info_ptr frame, int regnum)
> +python_on_register_change (const frame_info_ptr &frame, int regnum)
>  {
>    gdbpy_enter enter_py (current_inferior ()->arch ());
>  
> diff --git a/gdb/python/py-infevents.c b/gdb/python/py-infevents.c
> index 39677af24f56..5b87576ac733 100644
> --- a/gdb/python/py-infevents.c
> +++ b/gdb/python/py-infevents.c
> @@ -62,7 +62,7 @@ create_inferior_call_event_object (inferior_call_kind flag, ptid_t ptid,
>     register number. */
>  
>  static gdbpy_ref<>
> -create_register_changed_event_object (frame_info_ptr frame, 
> +create_register_changed_event_object (const frame_info_ptr &frame,

Trailing white space.

>  				      int regnum)
>  {
>    gdbpy_ref<> event = create_event_object (&register_changed_event_object_type);
> @@ -151,7 +151,7 @@ emit_memory_changed_event (CORE_ADDR addr, ssize_t len)
>     will create a new Python register changed event object. */
>  
>  int
> -emit_register_changed_event (frame_info_ptr frame, int regnum)
> +emit_register_changed_event (const frame_info_ptr &frame, int regnum)
>  {
>    if (evregpy_no_listeners_p (gdb_py_events.register_changed))
>      return 0;
> diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
> index c55b5aa85ec8..56f925bc57f0 100644
> --- a/gdb/python/py-unwind.c
> +++ b/gdb/python/py-unwind.c
> @@ -769,7 +769,7 @@ pending_framepy_level (PyObject *self, PyObject *args)
>  /* frame_unwind.this_id method.  */
>  
>  static void
> -pyuw_this_id (frame_info_ptr this_frame, void **cache_ptr,
> +pyuw_this_id (const frame_info_ptr &this_frame, void **cache_ptr,
>  	      struct frame_id *this_id)
>  {
>    *this_id = ((cached_frame_info *) *cache_ptr)->frame_id;
> @@ -779,7 +779,7 @@ pyuw_this_id (frame_info_ptr this_frame, void **cache_ptr,
>  /* frame_unwind.prev_register.  */
>  
>  static struct value *
> -pyuw_prev_register (frame_info_ptr this_frame, void **cache_ptr,
> +pyuw_prev_register (const frame_info_ptr &this_frame, void **cache_ptr,
>  		    int regnum)
>  {
>    PYUW_SCOPED_DEBUG_ENTER_EXIT;
> @@ -802,7 +802,7 @@ pyuw_prev_register (frame_info_ptr this_frame, void **cache_ptr,
>  /* Frame sniffer dispatch.  */
>  
>  static int
> -pyuw_sniffer (const struct frame_unwind *self, frame_info_ptr this_frame,
> +pyuw_sniffer (const struct frame_unwind *self, const frame_info_ptr &this_frame,
>  	      void **cache_ptr)
>  {
>    PYUW_SCOPED_DEBUG_ENTER_EXIT;
> diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
> index 7c05007cbab5..c68aff5340e7 100644
> --- a/gdb/python/python-internal.h
> +++ b/gdb/python/python-internal.h
> @@ -384,7 +384,7 @@ extern enum ext_lang_rc gdbpy_apply_val_pretty_printer
>     const struct language_defn *language);
>  extern enum ext_lang_bt_status gdbpy_apply_frame_filter
>    (const struct extension_language_defn *,
> -   frame_info_ptr frame, frame_filter_flags flags,
> +   const frame_info_ptr &frame, frame_filter_flags flags,
>     enum ext_lang_frame_args args_type,
>     struct ui_out *out, int frame_low, int frame_high);
>  extern void gdbpy_preserve_values (const struct extension_language_defn *,
> @@ -444,7 +444,7 @@ PyObject *block_to_block_object (const struct block *block,
>  				 struct objfile *objfile);
>  PyObject *value_to_value_object (struct value *v);
>  PyObject *type_to_type_object (struct type *);
> -PyObject *frame_info_to_frame_object (frame_info_ptr frame);
> +PyObject *frame_info_to_frame_object (const frame_info_ptr &frame);
>  PyObject *symtab_to_linetable_object (PyObject *symtab);
>  gdbpy_ref<> pspace_to_pspace_object (struct program_space *);
>  PyObject *pspy_get_printers (PyObject *, void *);
> diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
> index 030547ad51fd..6350400c318a 100644
> --- a/gdb/record-btrace.c
> +++ b/gdb/record-btrace.c
> @@ -1649,7 +1649,7 @@ bfcache_eq (const void *arg1, const void *arg2)
>  /* Create a new btrace frame cache.  */
>  
>  static struct btrace_frame_cache *
> -bfcache_new (frame_info_ptr frame)
> +bfcache_new (const frame_info_ptr &frame)
>  {
>    struct btrace_frame_cache *cache;
>    void **slot;
> @@ -1667,7 +1667,7 @@ bfcache_new (frame_info_ptr frame)
>  /* Extract the branch trace function from a branch trace frame.  */
>  
>  static const struct btrace_function *
> -btrace_get_frame_function (frame_info_ptr frame)
> +btrace_get_frame_function (const frame_info_ptr &frame)
>  {
>    const struct btrace_frame_cache *cache;
>    struct btrace_frame_cache pattern;
> @@ -1686,7 +1686,7 @@ btrace_get_frame_function (frame_info_ptr frame)
>  /* Implement stop_reason method for record_btrace_frame_unwind.  */
>  
>  static enum unwind_stop_reason
> -record_btrace_frame_unwind_stop_reason (frame_info_ptr this_frame,
> +record_btrace_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
>  					void **this_cache)
>  {
>    const struct btrace_frame_cache *cache;
> @@ -1705,7 +1705,7 @@ record_btrace_frame_unwind_stop_reason (frame_info_ptr this_frame,
>  /* Implement this_id method for record_btrace_frame_unwind.  */
>  
>  static void
> -record_btrace_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +record_btrace_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			     struct frame_id *this_id)
>  {
>    const struct btrace_frame_cache *cache;
> @@ -1735,7 +1735,7 @@ record_btrace_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  /* Implement prev_register method for record_btrace_frame_unwind.  */
>  
>  static struct value *
> -record_btrace_frame_prev_register (frame_info_ptr this_frame,
> +record_btrace_frame_prev_register (const frame_info_ptr &this_frame,
>  				   void **this_cache,
>  				   int regnum)
>  {
> @@ -1781,7 +1781,7 @@ record_btrace_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  record_btrace_frame_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_cache)
>  {
>    const struct btrace_function *bfun;
> @@ -1836,7 +1836,7 @@ record_btrace_frame_sniffer (const struct frame_unwind *self,
>  
>  static int
>  record_btrace_tailcall_frame_sniffer (const struct frame_unwind *self,
> -				      frame_info_ptr this_frame,
> +				      const frame_info_ptr &this_frame,
>  				      void **this_cache)
>  {
>    const struct btrace_function *bfun, *callee;
> diff --git a/gdb/riscv-fbsd-tdep.c b/gdb/riscv-fbsd-tdep.c
> index ca56a39cb71c..205f7a950df5 100644
> --- a/gdb/riscv-fbsd-tdep.c
> +++ b/gdb/riscv-fbsd-tdep.c
> @@ -108,7 +108,7 @@ riscv_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
>  
>  static void
>  riscv_fbsd_sigframe_init (const struct tramp_frame *self,
> -			  frame_info_ptr this_frame,
> +			  const frame_info_ptr &this_frame,
>  			  struct trad_frame_cache *this_cache,
>  			  CORE_ADDR func)
>  {
> diff --git a/gdb/riscv-linux-tdep.c b/gdb/riscv-linux-tdep.c
> index 9dfbe789a699..0267dc65e58e 100644
> --- a/gdb/riscv-linux-tdep.c
> +++ b/gdb/riscv-linux-tdep.c
> @@ -86,7 +86,7 @@ riscv_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
>  /* Signal trampoline support.  */
>  
>  static void riscv_linux_sigframe_init (const struct tramp_frame *self,
> -				       frame_info_ptr this_frame,
> +				       const frame_info_ptr &this_frame,
>  				       struct trad_frame_cache *this_cache,
>  				       CORE_ADDR func);
>  
> @@ -125,7 +125,7 @@ static const struct tramp_frame riscv_linux_sigframe = {
>  
>  static void
>  riscv_linux_sigframe_init (const struct tramp_frame *self,
> -			   frame_info_ptr this_frame,
> +			   const frame_info_ptr &this_frame,
>  			   struct trad_frame_cache *this_cache,
>  			   CORE_ADDR func)
>  {
> @@ -163,7 +163,7 @@ riscv_linux_sigframe_init (const struct tramp_frame *self,
>     instruction to be executed.  */
>  
>  static CORE_ADDR
> -riscv_linux_syscall_next_pc (frame_info_ptr frame)
> +riscv_linux_syscall_next_pc (const frame_info_ptr &frame)
>  {
>    const CORE_ADDR pc = get_frame_pc (frame);
>    const ULONGEST a7 = get_frame_register_unsigned (frame, RISCV_A7_REGNUM);
> diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
> index 9a7cfa35afd9..68ef3233e8d9 100644
> --- a/gdb/riscv-tdep.c
> +++ b/gdb/riscv-tdep.c
> @@ -165,7 +165,7 @@ static const reggroup *csr_reggroup = nullptr;
>  /* Callback function for user_reg_add.  */
>  
>  static struct value *
> -value_of_riscv_user_reg (frame_info_ptr frame, const void *baton)
> +value_of_riscv_user_reg (const frame_info_ptr &frame, const void *baton)
>  {
>    const int *reg_p = (const int *) baton;
>    return value_of_register (*reg_p, get_next_frame_sentinel_okay (frame));
> @@ -1135,7 +1135,7 @@ riscv_register_type (struct gdbarch *gdbarch, int regnum)
>  static void
>  riscv_print_one_register_info (struct gdbarch *gdbarch,
>  			       struct ui_file *file,
> -			       frame_info_ptr frame,
> +			       const frame_info_ptr &frame,
>  			       int regnum)
>  {
>    const char *name = gdbarch_register_name (gdbarch, regnum);
> @@ -1504,7 +1504,7 @@ riscv_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
>  static void
>  riscv_print_registers_info (struct gdbarch *gdbarch,
>  			    struct ui_file *file,
> -			    frame_info_ptr frame,
> +			    const frame_info_ptr &frame,
>  			    int regnum, int print_all)
>  {
>    if (regnum != -1)
> @@ -3806,7 +3806,7 @@ riscv_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
>     unwinder.  */
>  
>  static struct riscv_unwind_cache *
> -riscv_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +riscv_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    CORE_ADDR pc, start_addr;
>    struct riscv_unwind_cache *cache;
> @@ -3866,7 +3866,7 @@ riscv_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  /* Implement the this_id callback for RiscV frame unwinder.  */
>  
>  static void
> -riscv_frame_this_id (frame_info_ptr this_frame,
> +riscv_frame_this_id (const frame_info_ptr &this_frame,
>  		     void **prologue_cache,
>  		     struct frame_id *this_id)
>  {
> @@ -3887,7 +3887,7 @@ riscv_frame_this_id (frame_info_ptr this_frame,
>  /* Implement the prev_register callback for RiscV frame unwinder.  */
>  
>  static struct value *
> -riscv_frame_prev_register (frame_info_ptr this_frame,
> +riscv_frame_prev_register (const frame_info_ptr &this_frame,
>  			   void **prologue_cache,
>  			   int regnum)
>  {
> diff --git a/gdb/riscv-tdep.h b/gdb/riscv-tdep.h
> index ea6b25938ec1..4bdc2e7a3d5d 100644
> --- a/gdb/riscv-tdep.h
> +++ b/gdb/riscv-tdep.h
> @@ -112,7 +112,7 @@ struct riscv_gdbarch_tdep : gdbarch_tdep_base
>  
>    /* Return the expected next PC assuming FRAME is stopped at a syscall
>       instruction.  */
> -  CORE_ADDR (*syscall_next_pc) (frame_info_ptr frame) = nullptr;
> +  CORE_ADDR (*syscall_next_pc) (const frame_info_ptr &frame) = nullptr;
>  };
>  
>  
> diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
> index aecda0ed2cc1..1e439f363564 100644
> --- a/gdb/rl78-tdep.c
> +++ b/gdb/rl78-tdep.c
> @@ -1079,7 +1079,7 @@ rl78_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>  /* Implement the "unwind_pc" gdbarch method.  */
>  
>  static CORE_ADDR
> -rl78_unwind_pc (struct gdbarch *arch, frame_info_ptr next_frame)
> +rl78_unwind_pc (struct gdbarch *arch, const frame_info_ptr &next_frame)
>  {
>    return rl78_addr_bits_remove
>  	   (arch, frame_unwind_register_unsigned (next_frame,
> @@ -1092,7 +1092,7 @@ rl78_unwind_pc (struct gdbarch *arch, frame_info_ptr next_frame)
>     return that struct as the value of this function.  */
>  
>  static struct rl78_prologue *
> -rl78_analyze_frame_prologue (frame_info_ptr this_frame,
> +rl78_analyze_frame_prologue (const frame_info_ptr &this_frame,
>  			   void **this_prologue_cache)
>  {
>    if (!*this_prologue_cache)
> @@ -1119,7 +1119,7 @@ rl78_analyze_frame_prologue (frame_info_ptr this_frame,
>  /* Given a frame and a prologue cache, return this frame's base.  */
>  
>  static CORE_ADDR
> -rl78_frame_base (frame_info_ptr this_frame, void **this_prologue_cache)
> +rl78_frame_base (const frame_info_ptr &this_frame, void **this_prologue_cache)
>  {
>    struct rl78_prologue *p
>      = rl78_analyze_frame_prologue (this_frame, this_prologue_cache);
> @@ -1131,7 +1131,7 @@ rl78_frame_base (frame_info_ptr this_frame, void **this_prologue_cache)
>  /* Implement the "frame_this_id" method for unwinding frames.  */
>  
>  static void
> -rl78_this_id (frame_info_ptr this_frame,
> +rl78_this_id (const frame_info_ptr &this_frame,
>  	      void **this_prologue_cache, struct frame_id *this_id)
>  {
>    *this_id = frame_id_build (rl78_frame_base (this_frame,
> @@ -1142,7 +1142,7 @@ rl78_this_id (frame_info_ptr this_frame,
>  /* Implement the "frame_prev_register" method for unwinding frames.  */
>  
>  static struct value *
> -rl78_prev_register (frame_info_ptr this_frame,
> +rl78_prev_register (const frame_info_ptr &this_frame,
>  		    void **this_prologue_cache, int regnum)
>  {
>    struct rl78_prologue *p
> @@ -1316,7 +1316,7 @@ rl78_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
>  /* Implement the "dummy_id" gdbarch method.  */
>  
>  static struct frame_id
> -rl78_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +rl78_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    return
>      frame_id_build (rl78_make_data_address
> diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
> index 6fdbf63d6a86..db76af6984b9 100644
> --- a/gdb/rs6000-aix-tdep.c
> +++ b/gdb/rs6000-aix-tdep.c
> @@ -240,7 +240,7 @@ static const struct regset rs6000_aix_vsxregset = {
>  };
>  
>  static struct trad_frame_cache *
> -aix_sighandle_frame_cache (frame_info_ptr this_frame,
> +aix_sighandle_frame_cache (const frame_info_ptr &this_frame,
>  			   void **this_cache)
>  {
>    LONGEST backchain;
> @@ -296,7 +296,7 @@ aix_sighandle_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -aix_sighandle_frame_this_id (frame_info_ptr this_frame,
> +aix_sighandle_frame_this_id (const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache,
>  			     struct frame_id *this_id)
>  {
> @@ -306,7 +306,7 @@ aix_sighandle_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -aix_sighandle_frame_prev_register (frame_info_ptr this_frame,
> +aix_sighandle_frame_prev_register (const frame_info_ptr &this_frame,
>  				   void **this_prologue_cache, int regnum)
>  {
>    struct trad_frame_cache *this_trad_cache
> @@ -316,7 +316,7 @@ aix_sighandle_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  aix_sighandle_frame_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
> diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
> index f61e0843c1c7..baae79427e74 100644
> --- a/gdb/rs6000-tdep.c
> +++ b/gdb/rs6000-tdep.c
> @@ -743,7 +743,7 @@ insn_changes_sp_or_jumps (unsigned long insn)
>  	   limit for the size of an epilogue.  */
>  
>  static int
> -rs6000_in_function_epilogue_frame_p (frame_info_ptr curfrm,
> +rs6000_in_function_epilogue_frame_p (const frame_info_ptr &curfrm,
>  				     struct gdbarch *gdbarch, CORE_ADDR pc)
>  {
>    ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
> @@ -816,7 +816,7 @@ rs6000_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
>  
>  /* Get the ith function argument for the current function.  */
>  static CORE_ADDR
> -rs6000_fetch_pointer_argument (frame_info_ptr frame, int argi, 
> +rs6000_fetch_pointer_argument (const frame_info_ptr &frame, int argi,

Trailing white space.

>  			       struct type *type)
>  {
>    return get_frame_register_unsigned (frame, 3 + argi);
> @@ -2316,7 +2316,7 @@ rs6000_in_solib_return_trampoline (struct gdbarch *gdbarch,
>     code that should be skipped.  */
>  
>  static CORE_ADDR
> -rs6000_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +rs6000_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
> @@ -2698,7 +2698,7 @@ ieee_128_float_regnum_adjust (struct gdbarch *gdbarch, struct type *type,
>  }
>  
>  static int
> -rs6000_register_to_value (frame_info_ptr frame,
> +rs6000_register_to_value (const frame_info_ptr &frame,
>  			  int regnum,
>  			  struct type *type,
>  			  gdb_byte *to,
> @@ -2727,7 +2727,7 @@ rs6000_register_to_value (frame_info_ptr frame,
>  }
>  
>  static void
> -rs6000_value_to_register (frame_info_ptr frame,
> +rs6000_value_to_register (const frame_info_ptr &frame,
>  			  int regnum,
>  			  struct type *type,
>  			  const gdb_byte *from)
> @@ -3617,7 +3617,7 @@ struct rs6000_frame_cache
>  };
>  
>  static struct rs6000_frame_cache *
> -rs6000_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +rs6000_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct rs6000_frame_cache *cache;
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -3810,7 +3810,7 @@ rs6000_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -rs6000_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +rs6000_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		      struct frame_id *this_id)
>  {
>    struct rs6000_frame_cache *info = rs6000_frame_cache (this_frame,
> @@ -3830,7 +3830,7 @@ rs6000_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -rs6000_frame_prev_register (frame_info_ptr this_frame,
> +rs6000_frame_prev_register (const frame_info_ptr &this_frame,
>  			    void **this_cache, int regnum)
>  {
>    struct rs6000_frame_cache *info = rs6000_frame_cache (this_frame,
> @@ -3853,7 +3853,7 @@ static const struct frame_unwind rs6000_frame_unwind =
>     SP is restored and prev-PC is stored in LR.  */
>  
>  static struct rs6000_frame_cache *
> -rs6000_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +rs6000_epilogue_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct rs6000_frame_cache *cache;
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -3934,7 +3934,7 @@ rs6000_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache)
>     Return the frame ID of an epilogue frame.  */
>  
>  static void
> -rs6000_epilogue_frame_this_id (frame_info_ptr this_frame,
> +rs6000_epilogue_frame_this_id (const frame_info_ptr &this_frame,
>  			       void **this_cache, struct frame_id *this_id)
>  {
>    CORE_ADDR pc;
> @@ -3952,7 +3952,7 @@ rs6000_epilogue_frame_this_id (frame_info_ptr this_frame,
>     Return the register value of REGNUM in previous frame.  */
>  
>  static struct value *
> -rs6000_epilogue_frame_prev_register (frame_info_ptr this_frame,
> +rs6000_epilogue_frame_prev_register (const frame_info_ptr &this_frame,
>  				     void **this_cache, int regnum)
>  {
>    struct rs6000_frame_cache *info =
> @@ -3965,7 +3965,7 @@ rs6000_epilogue_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  rs6000_epilogue_frame_sniffer (const struct frame_unwind *self,
> -			       frame_info_ptr this_frame,
> +			       const frame_info_ptr &this_frame,
>  			       void **this_prologue_cache)
>  {
>    if (frame_relative_level (this_frame) == 0)
> @@ -3991,7 +3991,7 @@ static const struct frame_unwind rs6000_epilogue_frame_unwind =
>  \f
>  
>  static CORE_ADDR
> -rs6000_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +rs6000_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct rs6000_frame_cache *info = rs6000_frame_cache (this_frame,
>  							this_cache);
> @@ -4006,7 +4006,7 @@ static const struct frame_base rs6000_frame_base = {
>  };
>  
>  static const struct frame_base *
> -rs6000_frame_base_sniffer (frame_info_ptr this_frame)
> +rs6000_frame_base_sniffer (const frame_info_ptr &this_frame)
>  {
>    return &rs6000_frame_base;
>  }
> @@ -4017,7 +4017,7 @@ rs6000_frame_base_sniffer (frame_info_ptr this_frame)
>  static void
>  ppc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			    struct dwarf2_frame_state_reg *reg,
> -			    frame_info_ptr this_frame)
> +			    const frame_info_ptr &this_frame)
>  {
>    ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
>  
> @@ -8647,7 +8647,7 @@ show_powerpc_exact_watchpoints (struct ui_file *file, int from_tty,
>  /* Read a PPC instruction from memory.  */
>  
>  static unsigned int
> -read_insn (frame_info_ptr frame, CORE_ADDR pc)
> +read_insn (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -8669,7 +8669,7 @@ read_insn (frame_info_ptr frame, CORE_ADDR pc)
>     necessarily the i'th instruction in memory.  */
>  
>  int
> -ppc_insns_match_pattern (frame_info_ptr frame, CORE_ADDR pc,
> +ppc_insns_match_pattern (const frame_info_ptr &frame, CORE_ADDR pc,
>  			 const struct ppc_insn_pattern *pattern,
>  			 unsigned int *insns)
>  {
> diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
> index 5ea01e79bb5b..53ad5d5c92b2 100644
> --- a/gdb/rx-tdep.c
> +++ b/gdb/rx-tdep.c
> @@ -383,7 +383,7 @@ rx_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>     return that struct as the value of this function.  */
>  
>  static struct rx_prologue *
> -rx_analyze_frame_prologue (frame_info_ptr this_frame,
> +rx_analyze_frame_prologue (const frame_info_ptr &this_frame,
>  			   enum rx_frame_type frame_type,
>  			   void **this_prologue_cache)
>  {
> @@ -412,7 +412,7 @@ rx_analyze_frame_prologue (frame_info_ptr this_frame,
>     instruction.  */
>  
>  static enum rx_frame_type
> -rx_frame_type (frame_info_ptr this_frame, void **this_cache)
> +rx_frame_type (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    const char *name;
>    CORE_ADDR pc, start_pc, lim_pc;
> @@ -466,7 +466,7 @@ rx_frame_type (frame_info_ptr this_frame, void **this_cache)
>     base.  */
>  
>  static CORE_ADDR
> -rx_frame_base (frame_info_ptr this_frame, void **this_cache)
> +rx_frame_base (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    enum rx_frame_type frame_type = rx_frame_type (this_frame, this_cache);
>    struct rx_prologue *p
> @@ -493,7 +493,7 @@ rx_frame_base (frame_info_ptr this_frame, void **this_cache)
>  /* Implement the "frame_this_id" method for unwinding frames.  */
>  
>  static void
> -rx_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +rx_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		  struct frame_id *this_id)
>  {
>    *this_id = frame_id_build (rx_frame_base (this_frame, this_cache),
> @@ -503,7 +503,7 @@ rx_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  /* Implement the "frame_prev_register" method for unwinding frames.  */
>  
>  static struct value *
> -rx_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +rx_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			int regnum)
>  {
>    enum rx_frame_type frame_type = rx_frame_type (this_frame, this_cache);
> @@ -577,7 +577,7 @@ exception_frame_p (enum rx_frame_type frame_type)
>  
>  static int
>  rx_frame_sniffer_common (const struct frame_unwind *self,
> -			 frame_info_ptr this_frame,
> +			 const frame_info_ptr &this_frame,
>  			 void **this_cache,
>  			 int (*sniff_p)(enum rx_frame_type) )
>  {
> @@ -610,7 +610,7 @@ rx_frame_sniffer_common (const struct frame_unwind *self,
>  
>  static int
>  rx_frame_sniffer (const struct frame_unwind *self,
> -		  frame_info_ptr this_frame,
> +		  const frame_info_ptr &this_frame,
>  		  void **this_cache)
>  {
>    return rx_frame_sniffer_common (self, this_frame, this_cache,
> @@ -621,7 +621,7 @@ rx_frame_sniffer (const struct frame_unwind *self,
>  
>  static int
>  rx_exception_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_cache)
>  {
>    return rx_frame_sniffer_common (self, this_frame, this_cache,
> diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c
> index 4b2ed85c1670..60cbc26afffd 100644
> --- a/gdb/s12z-tdep.c
> +++ b/gdb/s12z-tdep.c
> @@ -241,7 +241,7 @@ push_pull_get_stack_adjustment (int n_operands,
>  /* Initialize a prologue cache.  */
>  
>  static struct trad_frame_cache *
> -s12z_frame_cache (frame_info_ptr this_frame, void **prologue_cache)
> +s12z_frame_cache (const frame_info_ptr &this_frame, void **prologue_cache)
>  {
>    struct trad_frame_cache *info;
>  
> @@ -420,7 +420,7 @@ s12z_frame_cache (frame_info_ptr this_frame, void **prologue_cache)
>  
>  /* Implement the this_id function for the stub unwinder.  */
>  static void
> -s12z_frame_this_id (frame_info_ptr this_frame,
> +s12z_frame_this_id (const frame_info_ptr &this_frame,
>  		    void **prologue_cache, struct frame_id *this_id)
>  {
>    struct trad_frame_cache *info = s12z_frame_cache (this_frame,
> @@ -432,7 +432,7 @@ s12z_frame_this_id (frame_info_ptr this_frame,
>  
>  /* Implement the prev_register function for the stub unwinder.  */
>  static struct value *
> -s12z_frame_prev_register (frame_info_ptr this_frame,
> +s12z_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **prologue_cache, int regnum)
>  {
>    struct trad_frame_cache *info = s12z_frame_cache (this_frame,
> @@ -491,7 +491,7 @@ static const char ccw_bits[] =
>  static void
>  s12z_print_ccw_info (struct gdbarch *gdbarch,
>  		     struct ui_file *file,
> -		     frame_info_ptr frame,
> +		     const frame_info_ptr &frame,
>  		     int reg)
>  {
>    value *v = value_of_register (reg, get_next_frame_sentinel_okay (frame));
> @@ -524,7 +524,7 @@ s12z_print_ccw_info (struct gdbarch *gdbarch,
>  static void
>  s12z_print_registers_info (struct gdbarch *gdbarch,
>  			    struct ui_file *file,
> -			    frame_info_ptr frame,
> +			    const frame_info_ptr &frame,
>  			    int regnum, int print_all)
>  {
>    const int numregs = (gdbarch_num_regs (gdbarch)
> diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
> index 4f73d5a4c017..945b3c7cee72 100644
> --- a/gdb/s390-linux-tdep.c
> +++ b/gdb/s390-linux-tdep.c
> @@ -387,7 +387,7 @@ struct s390_sigtramp_unwind_cache {
>     s390_sigtramp_frame_unwind.  */
>  
>  static struct s390_sigtramp_unwind_cache *
> -s390_sigtramp_frame_unwind_cache (frame_info_ptr this_frame,
> +s390_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
>  				  void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -497,7 +497,7 @@ s390_sigtramp_frame_unwind_cache (frame_info_ptr this_frame,
>  /* Implement this_id frame_unwind method for s390_sigtramp_frame_unwind.  */
>  
>  static void
> -s390_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +s390_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache,
>  			     struct frame_id *this_id)
>  {
> @@ -509,7 +509,7 @@ s390_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  /* Implement prev_register frame_unwind method for sigtramp frames.  */
>  
>  static struct value *
> -s390_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +s390_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  				   void **this_prologue_cache, int regnum)
>  {
>    struct s390_sigtramp_unwind_cache *info
> @@ -521,7 +521,7 @@ s390_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  s390_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     void **this_prologue_cache)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
> diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
> index 134bf984e5b6..1fd08ddf018e 100644
> --- a/gdb/s390-tdep.c
> +++ b/gdb/s390-tdep.c
> @@ -1991,7 +1991,7 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
>     breakpoint.  */
>  
>  static struct frame_id
> -s390_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +s390_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    int word_size = gdbarch_ptr_bit (gdbarch) / 8;
>    CORE_ADDR sp = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
> @@ -2175,7 +2175,7 @@ s390_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
>  /* Implement unwind_pc gdbarch method.  */
>  
>  static CORE_ADDR
> -s390_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +s390_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
>    ULONGEST pc;
> @@ -2186,7 +2186,7 @@ s390_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  /* Implement unwind_sp gdbarch method.  */
>  
>  static CORE_ADDR
> -s390_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +s390_unwind_sp (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    ULONGEST sp;
>    sp = frame_unwind_register_unsigned (next_frame, S390_SP_REGNUM);
> @@ -2196,7 +2196,7 @@ s390_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  /* Helper routine to unwind pseudo registers.  */
>  
>  static struct value *
> -s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum)
> +s390_unwind_pseudo_register (const frame_info_ptr &this_frame, int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
> @@ -2267,7 +2267,7 @@ s390_adjust_frame_regnum (struct gdbarch *gdbarch, int num, int eh_frame_p)
>     s390_dwarf2_frame_init_reg.  */
>  
>  static struct value *
> -s390_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache,
> +s390_dwarf2_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			   int regnum)
>  {
>    return s390_unwind_pseudo_register (this_frame, regnum);
> @@ -2278,7 +2278,7 @@ s390_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache,
>  static void
>  s390_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			    struct dwarf2_frame_state_reg *reg,
> -			    frame_info_ptr this_frame)
> +			    const frame_info_ptr &this_frame)
>  {
>    /* The condition code (and thus PSW mask) is call-clobbered.  */
>    if (regnum == S390_PSWM_REGNUM)
> @@ -2312,7 +2312,7 @@ s390_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>     register translation.  */
>  
>  struct value *
> -s390_trad_frame_prev_register (frame_info_ptr this_frame,
> +s390_trad_frame_prev_register (const frame_info_ptr &this_frame,
>  			       trad_frame_saved_reg saved_regs[],
>  			       int regnum)
>  {
> @@ -2337,7 +2337,7 @@ struct s390_unwind_cache {
>     prologue analysis.  Helper for s390_frame_unwind_cache.  */
>  
>  static int
> -s390_prologue_frame_unwind_cache (frame_info_ptr this_frame,
> +s390_prologue_frame_unwind_cache (const frame_info_ptr &this_frame,
>  				  struct s390_unwind_cache *info)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2524,7 +2524,7 @@ s390_prologue_frame_unwind_cache (frame_info_ptr this_frame,
>     back chain unwinding.  Helper for s390_frame_unwind_cache.  */
>  
>  static void
> -s390_backchain_frame_unwind_cache (frame_info_ptr this_frame,
> +s390_backchain_frame_unwind_cache (const frame_info_ptr &this_frame,
>  				   struct s390_unwind_cache *info)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2581,7 +2581,7 @@ s390_backchain_frame_unwind_cache (frame_info_ptr this_frame,
>     s390_frame_unwind and s390_frame_base.  */
>  
>  static struct s390_unwind_cache *
> -s390_frame_unwind_cache (frame_info_ptr this_frame,
> +s390_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache)
>  {
>    struct s390_unwind_cache *info;
> @@ -2615,7 +2615,7 @@ s390_frame_unwind_cache (frame_info_ptr this_frame,
>  /* Implement this_id frame_unwind method for s390_frame_unwind.  */
>  
>  static void
> -s390_frame_this_id (frame_info_ptr this_frame,
> +s390_frame_this_id (const frame_info_ptr &this_frame,
>  		    void **this_prologue_cache,
>  		    struct frame_id *this_id)
>  {
> @@ -2635,7 +2635,7 @@ s390_frame_this_id (frame_info_ptr this_frame,
>  /* Implement prev_register frame_unwind method for s390_frame_unwind.  */
>  
>  static struct value *
> -s390_frame_prev_register (frame_info_ptr this_frame,
> +s390_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache, int regnum)
>  {
>    struct s390_unwind_cache *info
> @@ -2670,7 +2670,7 @@ struct s390_stub_unwind_cache
>     s390_stub_frame_unwind.  */
>  
>  static struct s390_stub_unwind_cache *
> -s390_stub_frame_unwind_cache (frame_info_ptr this_frame,
> +s390_stub_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			      void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2698,7 +2698,7 @@ s390_stub_frame_unwind_cache (frame_info_ptr this_frame,
>  /* Implement this_id frame_unwind method for s390_stub_frame_unwind.  */
>  
>  static void
> -s390_stub_frame_this_id (frame_info_ptr this_frame,
> +s390_stub_frame_this_id (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache,
>  			 struct frame_id *this_id)
>  {
> @@ -2710,7 +2710,7 @@ s390_stub_frame_this_id (frame_info_ptr this_frame,
>  /* Implement prev_register frame_unwind method for s390_stub_frame_unwind.  */
>  
>  static struct value *
> -s390_stub_frame_prev_register (frame_info_ptr this_frame,
> +s390_stub_frame_prev_register (const frame_info_ptr &this_frame,
>  			       void **this_prologue_cache, int regnum)
>  {
>    struct s390_stub_unwind_cache *info
> @@ -2722,7 +2722,7 @@ s390_stub_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  s390_stub_frame_sniffer (const struct frame_unwind *self,
> -			 frame_info_ptr this_frame,
> +			 const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache)
>  {
>    CORE_ADDR addr_in_block;
> @@ -2753,7 +2753,7 @@ static const struct frame_unwind s390_stub_frame_unwind = {
>  /* Frame base handling.  */
>  
>  static CORE_ADDR
> -s390_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +s390_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct s390_unwind_cache *info
>      = s390_frame_unwind_cache (this_frame, this_cache);
> @@ -2761,7 +2761,7 @@ s390_frame_base_address (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static CORE_ADDR
> -s390_local_base_address (frame_info_ptr this_frame, void **this_cache)
> +s390_local_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct s390_unwind_cache *info
>      = s390_frame_unwind_cache (this_frame, this_cache);
> diff --git a/gdb/s390-tdep.h b/gdb/s390-tdep.h
> index 58a7d08c9b0b..10f775f468f8 100644
> --- a/gdb/s390-tdep.h
> +++ b/gdb/s390-tdep.h
> @@ -316,7 +316,7 @@ enum
>  /* Frame unwinding.  */
>  
>  extern struct value *s390_trad_frame_prev_register
> -    (frame_info_ptr this_frame, struct trad_frame_saved_reg saved_regs[],
> +    (const frame_info_ptr &this_frame, struct trad_frame_saved_reg saved_regs[],
>       int regnum);
>  
>  extern const struct target_desc *tdesc_s390_linux32;
> diff --git a/gdb/sentinel-frame.c b/gdb/sentinel-frame.c
> index 6b6cbeb3a3f2..ca7c28952f36 100644
> --- a/gdb/sentinel-frame.c
> +++ b/gdb/sentinel-frame.c
> @@ -42,7 +42,7 @@ sentinel_frame_cache (struct regcache *regcache)
>  /* Here the register value is taken direct from the register cache.  */
>  
>  static struct value *
> -sentinel_frame_prev_register (frame_info_ptr this_frame,
> +sentinel_frame_prev_register (const frame_info_ptr &this_frame,
>  			      void **this_prologue_cache,
>  			      int regnum)
>  {
> @@ -59,7 +59,7 @@ sentinel_frame_prev_register (frame_info_ptr this_frame,
>  }
>  
>  static void
> -sentinel_frame_this_id (frame_info_ptr this_frame,
> +sentinel_frame_this_id (const frame_info_ptr &this_frame,
>  			void **this_prologue_cache,
>  			struct frame_id *this_id)
>  {
> @@ -70,7 +70,7 @@ sentinel_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct gdbarch *
> -sentinel_frame_prev_arch (frame_info_ptr this_frame,
> +sentinel_frame_prev_arch (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache)
>  {
>    struct frame_unwind_cache *cache
> diff --git a/gdb/sh-linux-tdep.c b/gdb/sh-linux-tdep.c
> index 8fee028bb42e..c78d363400ad 100644
> --- a/gdb/sh-linux-tdep.c
> +++ b/gdb/sh-linux-tdep.c
> @@ -77,7 +77,7 @@ static const struct sh_corefile_regmap fpregs_table[] =
>  /* SH signal handler frame support.  */
>  
>  static void
> -sh_linux_sigtramp_cache (frame_info_ptr this_frame,
> +sh_linux_sigtramp_cache (const frame_info_ptr &this_frame,
>  			 struct trad_frame_cache *this_cache,
>  			 CORE_ADDR func, int regs_offset)
>  {
> @@ -114,7 +114,7 @@ sh_linux_sigtramp_cache (frame_info_ptr this_frame,
>  
>  static void
>  sh_linux_sigreturn_init (const struct tramp_frame *self,
> -			 frame_info_ptr this_frame,
> +			 const frame_info_ptr &this_frame,
>  			 struct trad_frame_cache *this_cache,
>  			 CORE_ADDR func)
>  {
> @@ -125,7 +125,7 @@ sh_linux_sigreturn_init (const struct tramp_frame *self,
>  
>  static void
>  sh_linux_rt_sigreturn_init (const struct tramp_frame *self,
> -			    frame_info_ptr this_frame,
> +			    const frame_info_ptr &this_frame,
>  			    struct trad_frame_cache *this_cache,
>  			    CORE_ADDR func)
>  {
> diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
> index 3a4ff96428a6..16e513eb4053 100644
> --- a/gdb/sh-tdep.c
> +++ b/gdb/sh-tdep.c
> @@ -1755,7 +1755,7 @@ sh_sh2a_register_sim_regno (struct gdbarch *gdbarch, int nr)
>  static void
>  sh_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			  struct dwarf2_frame_state_reg *reg,
> -			  frame_info_ptr this_frame)
> +			  const frame_info_ptr &this_frame)
>  {
>    /* Mark the PC as the destination for the return address.  */
>    if (regnum == gdbarch_pc_regnum (gdbarch))
> @@ -1825,7 +1825,7 @@ sh_alloc_frame_cache (void)
>  }
>  
>  static struct sh_frame_cache *
> -sh_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +sh_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct sh_frame_cache *cache;
> @@ -1892,7 +1892,7 @@ sh_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static struct value *
> -sh_frame_prev_register (frame_info_ptr this_frame,
> +sh_frame_prev_register (const frame_info_ptr &this_frame,
>  			void **this_cache, int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1917,7 +1917,7 @@ sh_frame_prev_register (frame_info_ptr this_frame,
>  }
>  
>  static void
> -sh_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +sh_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		  struct frame_id *this_id)
>  {
>    struct sh_frame_cache *cache = sh_frame_cache (this_frame, this_cache);
> @@ -1940,7 +1940,7 @@ static const struct frame_unwind sh_frame_unwind = {
>  };
>  
>  static CORE_ADDR
> -sh_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +sh_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct sh_frame_cache *cache = sh_frame_cache (this_frame, this_cache);
>  
> @@ -1955,7 +1955,7 @@ static const struct frame_base sh_frame_base = {
>  };
>  
>  static struct sh_frame_cache *
> -sh_make_stub_cache (frame_info_ptr this_frame)
> +sh_make_stub_cache (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct sh_frame_cache *cache;
> @@ -1969,7 +1969,7 @@ sh_make_stub_cache (frame_info_ptr this_frame)
>  }
>  
>  static void
> -sh_stub_this_id (frame_info_ptr this_frame, void **this_cache,
> +sh_stub_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		 struct frame_id *this_id)
>  {
>    struct sh_frame_cache *cache;
> @@ -1983,7 +1983,7 @@ sh_stub_this_id (frame_info_ptr this_frame, void **this_cache,
>  
>  static int
>  sh_stub_unwind_sniffer (const struct frame_unwind *self,
> -			frame_info_ptr this_frame,
> +			const frame_info_ptr &this_frame,
>  			void **this_prologue_cache)
>  {
>    CORE_ADDR addr_in_block;
> diff --git a/gdb/sol2-tdep.c b/gdb/sol2-tdep.c
> index de6794635a57..4ee2d0ac3460 100644
> --- a/gdb/sol2-tdep.c
> +++ b/gdb/sol2-tdep.c
> @@ -52,7 +52,7 @@ sol2_pc_in_sigtramp (CORE_ADDR pc, const char *name)
>  /* Return whether THIS_FRAME corresponds to a Solaris sigtramp routine.  */
>  
>  int
> -sol2_sigtramp_p (frame_info_ptr this_frame)
> +sol2_sigtramp_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
>    const char *name;
> diff --git a/gdb/sol2-tdep.h b/gdb/sol2-tdep.h
> index d669b484d0da..a189666f05ee 100644
> --- a/gdb/sol2-tdep.h
> +++ b/gdb/sol2-tdep.h
> @@ -22,7 +22,7 @@
>  
>  struct gdbarch;
>  
> -int sol2_sigtramp_p (frame_info_ptr this_frame);
> +int sol2_sigtramp_p (const frame_info_ptr &this_frame);
>  
>  void sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
>  
> diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c
> index 430522b97029..1590cbdc4f05 100644
> --- a/gdb/sparc-linux-tdep.c
> +++ b/gdb/sparc-linux-tdep.c
> @@ -42,7 +42,7 @@
>  /* Signal trampoline support.  */
>  
>  static void sparc32_linux_sigframe_init (const struct tramp_frame *self,
> -					 frame_info_ptr this_frame,
> +					 const frame_info_ptr &this_frame,
>  					 struct trad_frame_cache *this_cache,
>  					 CORE_ADDR func);
>  
> @@ -117,7 +117,7 @@ enum
>  
>  static void
>  sparc32_linux_sigframe_init (const struct tramp_frame *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     struct trad_frame_cache *this_cache,
>  			     CORE_ADDR func)
>  {
> @@ -159,7 +159,7 @@ sparc32_linux_sigframe_init (const struct tramp_frame *self,
>     address.  */
>  
>  static CORE_ADDR
> -sparc32_linux_step_trap (frame_info_ptr frame, unsigned long insn)
> +sparc32_linux_step_trap (const frame_info_ptr &frame, unsigned long insn)
>  {
>    if (insn == 0x91d02010)
>      {
> diff --git a/gdb/sparc-netbsd-tdep.c b/gdb/sparc-netbsd-tdep.c
> index 486381f497b4..d2b1a4bfd140 100644
> --- a/gdb/sparc-netbsd-tdep.c
> +++ b/gdb/sparc-netbsd-tdep.c
> @@ -95,7 +95,7 @@ sparc32nbsd_pc_in_sigtramp (CORE_ADDR pc, const char *name)
>  }
>  
>  trad_frame_saved_reg *
> -sparc32nbsd_sigcontext_saved_regs (frame_info_ptr this_frame)
> +sparc32nbsd_sigcontext_saved_regs (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    trad_frame_saved_reg *saved_regs;
> @@ -180,7 +180,7 @@ sparc32nbsd_sigcontext_saved_regs (frame_info_ptr this_frame)
>  }
>  
>  static struct sparc_frame_cache *
> -sparc32nbsd_sigcontext_frame_cache (frame_info_ptr this_frame,
> +sparc32nbsd_sigcontext_frame_cache (const frame_info_ptr &this_frame,
>  				    void **this_cache)
>  {
>    struct sparc_frame_cache *cache;
> @@ -211,7 +211,7 @@ sparc32nbsd_sigcontext_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -sparc32nbsd_sigcontext_frame_this_id (frame_info_ptr this_frame,
> +sparc32nbsd_sigcontext_frame_this_id (const frame_info_ptr &this_frame,
>  				      void **this_cache,
>  				      struct frame_id *this_id)
>  {
> @@ -222,7 +222,7 @@ sparc32nbsd_sigcontext_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -sparc32nbsd_sigcontext_frame_prev_register (frame_info_ptr this_frame,
> +sparc32nbsd_sigcontext_frame_prev_register (const frame_info_ptr &this_frame,
>  					    void **this_cache, int regnum)
>  {
>    struct sparc_frame_cache *cache =
> @@ -233,7 +233,7 @@ sparc32nbsd_sigcontext_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  sparc32nbsd_sigcontext_frame_sniffer (const struct frame_unwind *self,
> -				      frame_info_ptr this_frame,
> +				      const frame_info_ptr &this_frame,
>  				      void **this_cache)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
> @@ -264,7 +264,7 @@ static const struct frame_unwind sparc32nbsd_sigcontext_frame_unwind =
>     address.  */
>  
>  CORE_ADDR
> -sparcnbsd_step_trap (frame_info_ptr frame, unsigned long insn)
> +sparcnbsd_step_trap (const frame_info_ptr &frame, unsigned long insn)
>  {
>    if ((X_I (insn) == 0 && X_RS1 (insn) == 0 && X_RS2 (insn) == 0)
>        || (X_I (insn) == 1 && X_RS1 (insn) == 0 && (insn & 0x7f) == 0))
> diff --git a/gdb/sparc-obsd-tdep.c b/gdb/sparc-obsd-tdep.c
> index 2155a30e20b1..8cdbc8aae6e7 100644
> --- a/gdb/sparc-obsd-tdep.c
> +++ b/gdb/sparc-obsd-tdep.c
> @@ -68,7 +68,7 @@ sparc32obsd_pc_in_sigtramp (CORE_ADDR pc, const char *name)
>  }
>  
>  static struct sparc_frame_cache *
> -sparc32obsd_sigtramp_frame_cache (frame_info_ptr this_frame,
> +sparc32obsd_sigtramp_frame_cache (const frame_info_ptr &this_frame,
>  				  void **this_cache)
>  {
>    struct sparc_frame_cache *cache;
> @@ -100,7 +100,7 @@ sparc32obsd_sigtramp_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -sparc32obsd_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +sparc32obsd_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				    void **this_cache,
>  				    struct frame_id *this_id)
>  {
> @@ -111,7 +111,7 @@ sparc32obsd_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -sparc32obsd_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +sparc32obsd_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  					  void **this_cache, int regnum)
>  {
>    struct sparc_frame_cache *cache =
> @@ -122,7 +122,7 @@ sparc32obsd_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  sparc32obsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				    frame_info_ptr this_frame,
> +				    const frame_info_ptr &this_frame,
>  				    void **this_cache)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
> diff --git a/gdb/sparc-sol2-tdep.c b/gdb/sparc-sol2-tdep.c
> index a0a6c4cd7177..525784401038 100644
> --- a/gdb/sparc-sol2-tdep.c
> +++ b/gdb/sparc-sol2-tdep.c
> @@ -100,7 +100,7 @@ static const struct regset sparc32_sol2_fpregset =
>  \f
>  
>  static struct sparc_frame_cache *
> -sparc32_sol2_sigtramp_frame_cache (frame_info_ptr this_frame,
> +sparc32_sol2_sigtramp_frame_cache (const frame_info_ptr &this_frame,
>  				   void **this_cache)
>  {
>    struct sparc_frame_cache *cache;
> @@ -151,7 +151,7 @@ sparc32_sol2_sigtramp_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -sparc32_sol2_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +sparc32_sol2_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				     void **this_cache,
>  				     struct frame_id *this_id)
>  {
> @@ -162,7 +162,7 @@ sparc32_sol2_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -sparc32_sol2_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +sparc32_sol2_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  					   void **this_cache,
>  					   int regnum)
>  {
> @@ -174,7 +174,7 @@ sparc32_sol2_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  sparc32_sol2_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				     frame_info_ptr this_frame,
> +				     const frame_info_ptr &this_frame,
>  				     void **this_cache)
>  {
>    return sol2_sigtramp_p (this_frame);
> diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
> index f84e168ab9fd..5eec3615f536 100644
> --- a/gdb/sparc-tdep.c
> +++ b/gdb/sparc-tdep.c
> @@ -1182,7 +1182,7 @@ sparc32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
>  /* Normal frames.  */
>  
>  struct sparc_frame_cache *
> -sparc_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +sparc_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct sparc_frame_cache *cache;
>  
> @@ -1239,7 +1239,7 @@ sparc32_struct_return_from_sym (struct symbol *sym)
>  }
>  
>  struct sparc_frame_cache *
> -sparc32_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +sparc32_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct sparc_frame_cache *cache;
>    struct symbol *sym;
> @@ -1275,7 +1275,7 @@ sparc32_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -sparc32_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +sparc32_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		       struct frame_id *this_id)
>  {
>    struct sparc_frame_cache *cache =
> @@ -1289,7 +1289,7 @@ sparc32_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -sparc32_frame_prev_register (frame_info_ptr this_frame,
> +sparc32_frame_prev_register (const frame_info_ptr &this_frame,
>  			     void **this_cache, int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1359,7 +1359,7 @@ static const struct frame_unwind sparc32_frame_unwind =
>  \f
>  
>  static CORE_ADDR
> -sparc32_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +sparc32_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct sparc_frame_cache *cache =
>      sparc32_frame_cache (this_frame, this_cache);
> @@ -1376,7 +1376,7 @@ static const struct frame_base sparc32_frame_base =
>  };
>  
>  static struct frame_id
> -sparc_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +sparc_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR sp;
>  
> @@ -1549,7 +1549,7 @@ sparc32_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
>  }
>  
>  static int
> -sparc32_dwarf2_struct_return_p (frame_info_ptr this_frame)
> +sparc32_dwarf2_struct_return_p (const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc = get_frame_address_in_block (this_frame);
>    struct symbol *sym = find_pc_function (pc);
> @@ -1562,7 +1562,7 @@ sparc32_dwarf2_struct_return_p (frame_info_ptr this_frame)
>  static void
>  sparc32_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			       struct dwarf2_frame_state_reg *reg,
> -			       frame_info_ptr this_frame)
> +			       const frame_info_ptr &this_frame)
>  {
>    int off;
>  
> @@ -1721,7 +1721,7 @@ sparc_analyze_control_transfer (struct regcache *regcache,
>  }
>  
>  static CORE_ADDR
> -sparc_step_trap (frame_info_ptr frame, unsigned long insn)
> +sparc_step_trap (const frame_info_ptr &frame, unsigned long insn)
>  {
>    return 0;
>  }
> diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h
> index c4ea4ff9d558..2d8c50768be0 100644
> --- a/gdb/sparc-tdep.h
> +++ b/gdb/sparc-tdep.h
> @@ -85,7 +85,7 @@ struct sparc_gdbarch_tdep : gdbarch_tdep_base
>    size_t plt_entry_size = 0;
>  
>    /* Alternative location for trap return.  Used for single-stepping.  */
> -  CORE_ADDR (*step_trap) (frame_info_ptr frame, unsigned long insn)
> +  CORE_ADDR (*step_trap) (const frame_info_ptr &frame, unsigned long insn)
>      = nullptr;
>  
>    /* ISA-specific data types.  */
> @@ -207,10 +207,10 @@ extern CORE_ADDR sparc_analyze_prologue (struct gdbarch *gdbarch,
>  					 struct sparc_frame_cache *cache);
>  
>  extern struct sparc_frame_cache *
> -  sparc_frame_cache (frame_info_ptr this_frame, void **this_cache);
> +  sparc_frame_cache (const frame_info_ptr &this_frame, void **this_cache);
>  
>  extern struct sparc_frame_cache *
> -  sparc32_frame_cache (frame_info_ptr this_frame, void **this_cache);
> +  sparc32_frame_cache (const frame_info_ptr &this_frame, void **this_cache);
>  
>  extern int
>    sparc_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc);
> @@ -255,13 +255,13 @@ extern const struct sparc_gregmap sparc32nbsd_gregmap;
>  
>  /* Return the address of a system call's alternative return
>     address.  */
> -extern CORE_ADDR sparcnbsd_step_trap (frame_info_ptr frame,
> +extern CORE_ADDR sparcnbsd_step_trap (const frame_info_ptr &frame,
>  				      unsigned long insn);
>  
>  extern void sparc32nbsd_init_abi (struct gdbarch_info info,
>  				  struct gdbarch *gdbarch);
>  
>  extern struct trad_frame_saved_reg *
> -  sparc32nbsd_sigcontext_saved_regs (frame_info_ptr next_frame);
> +  sparc32nbsd_sigcontext_saved_regs (const frame_info_ptr &next_frame);
>  
>  #endif /* sparc-tdep.h */
> diff --git a/gdb/sparc64-fbsd-tdep.c b/gdb/sparc64-fbsd-tdep.c
> index 8c97ce87209f..c992c8c8f6fb 100644
> --- a/gdb/sparc64-fbsd-tdep.c
> +++ b/gdb/sparc64-fbsd-tdep.c
> @@ -89,7 +89,7 @@ sparc64fbsd_pc_in_sigtramp (CORE_ADDR pc, const char *name)
>  }
>  
>  static struct sparc_frame_cache *
> -sparc64fbsd_sigtramp_frame_cache (frame_info_ptr this_frame,
> +sparc64fbsd_sigtramp_frame_cache (const frame_info_ptr &this_frame,
>  				   void **this_cache)
>  {
>    struct sparc_frame_cache *cache;
> @@ -162,7 +162,7 @@ sparc64fbsd_sigtramp_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -sparc64fbsd_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +sparc64fbsd_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				    void **this_cache,
>  				    struct frame_id *this_id)
>  {
> @@ -173,7 +173,7 @@ sparc64fbsd_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -sparc64fbsd_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +sparc64fbsd_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  					  void **this_cache, int regnum)
>  {
>    struct sparc_frame_cache *cache =
> @@ -184,7 +184,7 @@ sparc64fbsd_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  sparc64fbsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				    frame_info_ptr this_frame,
> +				    const frame_info_ptr &this_frame,
>  				    void **this_cache)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
> diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c
> index ba9d694776f3..33da5321d81a 100644
> --- a/gdb/sparc64-linux-tdep.c
> +++ b/gdb/sparc64-linux-tdep.c
> @@ -52,7 +52,7 @@
>  /* Signal trampoline support.  */
>  
>  static void sparc64_linux_sigframe_init (const struct tramp_frame *self,
> -					 frame_info_ptr this_frame,
> +					 const frame_info_ptr &this_frame,
>  					 struct trad_frame_cache *this_cache,
>  					 CORE_ADDR func);
>  
> @@ -73,7 +73,7 @@ static const struct tramp_frame sparc64_linux_rt_sigframe =
>  
>  static void
>  sparc64_linux_sigframe_init (const struct tramp_frame *self,
> -			     frame_info_ptr this_frame,
> +			     const frame_info_ptr &this_frame,
>  			     struct trad_frame_cache *this_cache,
>  			     CORE_ADDR func)
>  {
> @@ -176,7 +176,7 @@ sparc64_linux_report_signal_info (struct gdbarch *gdbarch, struct ui_out *uiout,
>     address.  */
>  
>  static CORE_ADDR
> -sparc64_linux_step_trap (frame_info_ptr frame, unsigned long insn)
> +sparc64_linux_step_trap (const frame_info_ptr &frame, unsigned long insn)
>  {
>    /* __NR_rt_sigreturn is 101  */
>    if ((insn == 0x91d0206d)
> @@ -306,7 +306,7 @@ sparc64_linux_get_syscall_number (struct gdbarch *gdbarch,
>  /* Implement the "get_longjmp_target" gdbarch method.  */
>  
>  static int
> -sparc64_linux_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +sparc64_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    CORE_ADDR jb_addr;
> diff --git a/gdb/sparc64-netbsd-tdep.c b/gdb/sparc64-netbsd-tdep.c
> index 82405f8b62ba..fe97689ae157 100644
> --- a/gdb/sparc64-netbsd-tdep.c
> +++ b/gdb/sparc64-netbsd-tdep.c
> @@ -86,7 +86,7 @@ sparc64nbsd_pc_in_sigtramp (CORE_ADDR pc, const char *name)
>  
>  trad_frame_saved_reg *
>  sparc64nbsd_sigcontext_saved_regs (CORE_ADDR sigcontext_addr,
> -				   frame_info_ptr this_frame)
> +				   const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    trad_frame_saved_reg *saved_regs;
> @@ -149,7 +149,7 @@ sparc64nbsd_sigcontext_saved_regs (CORE_ADDR sigcontext_addr,
>  }
>  
>  static struct sparc_frame_cache *
> -sparc64nbsd_sigcontext_frame_cache (frame_info_ptr this_frame,
> +sparc64nbsd_sigcontext_frame_cache (const frame_info_ptr &this_frame,
>  				    void **this_cache)
>  {
>    struct sparc_frame_cache *cache;
> @@ -185,7 +185,7 @@ sparc64nbsd_sigcontext_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -sparc64nbsd_sigcontext_frame_this_id (frame_info_ptr this_frame,
> +sparc64nbsd_sigcontext_frame_this_id (const frame_info_ptr &this_frame,
>  				      void **this_cache,
>  				      struct frame_id *this_id)
>  {
> @@ -196,7 +196,7 @@ sparc64nbsd_sigcontext_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -sparc64nbsd_sigcontext_frame_prev_register (frame_info_ptr this_frame,
> +sparc64nbsd_sigcontext_frame_prev_register (const frame_info_ptr &this_frame,
>  					    void **this_cache, int regnum)
>  {
>    struct sparc_frame_cache *cache =
> @@ -207,7 +207,7 @@ sparc64nbsd_sigcontext_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  sparc64nbsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				    frame_info_ptr this_frame,
> +				    const frame_info_ptr &this_frame,
>  				    void **this_cache)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
> diff --git a/gdb/sparc64-obsd-tdep.c b/gdb/sparc64-obsd-tdep.c
> index 7f22c4b0fc0f..3837074a9fb7 100644
> --- a/gdb/sparc64-obsd-tdep.c
> +++ b/gdb/sparc64-obsd-tdep.c
> @@ -150,7 +150,7 @@ sparc64obsd_pc_in_sigtramp (CORE_ADDR pc, const char *name)
>  }
>  
>  static struct sparc_frame_cache *
> -sparc64obsd_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +sparc64obsd_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct sparc_frame_cache *cache;
>    CORE_ADDR addr;
> @@ -186,7 +186,7 @@ sparc64obsd_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -sparc64obsd_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +sparc64obsd_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			   struct frame_id *this_id)
>  {
>    struct sparc_frame_cache *cache =
> @@ -196,7 +196,7 @@ sparc64obsd_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -sparc64obsd_frame_prev_register (frame_info_ptr this_frame,
> +sparc64obsd_frame_prev_register (const frame_info_ptr &this_frame,
>  				 void **this_cache, int regnum)
>  {
>    struct sparc_frame_cache *cache =
> @@ -207,7 +207,7 @@ sparc64obsd_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  sparc64obsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				    frame_info_ptr this_frame,
> +				    const frame_info_ptr &this_frame,
>  				    void **this_cache)
>  {
>    CORE_ADDR pc = get_frame_pc (this_frame);
> @@ -234,7 +234,7 @@ static const struct frame_unwind sparc64obsd_frame_unwind =
>  /* Kernel debugging support.  */
>  
>  static struct sparc_frame_cache *
> -sparc64obsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
> +sparc64obsd_trapframe_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct sparc_frame_cache *cache;
>    CORE_ADDR sp, trapframe_addr;
> @@ -263,7 +263,7 @@ sparc64obsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -sparc64obsd_trapframe_this_id (frame_info_ptr this_frame,
> +sparc64obsd_trapframe_this_id (const frame_info_ptr &this_frame,
>  			       void **this_cache, struct frame_id *this_id)
>  {
>    struct sparc_frame_cache *cache =
> @@ -273,7 +273,7 @@ sparc64obsd_trapframe_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -sparc64obsd_trapframe_prev_register (frame_info_ptr this_frame,
> +sparc64obsd_trapframe_prev_register (const frame_info_ptr &this_frame,
>  				     void **this_cache, int regnum)
>  {
>    struct sparc_frame_cache *cache =
> @@ -284,7 +284,7 @@ sparc64obsd_trapframe_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  sparc64obsd_trapframe_sniffer (const struct frame_unwind *self,
> -			       frame_info_ptr this_frame,
> +			       const frame_info_ptr &this_frame,
>  			       void **this_cache)
>  {
>    CORE_ADDR pc;
> diff --git a/gdb/sparc64-sol2-tdep.c b/gdb/sparc64-sol2-tdep.c
> index 95db72bcbe72..7cef98bb681c 100644
> --- a/gdb/sparc64-sol2-tdep.c
> +++ b/gdb/sparc64-sol2-tdep.c
> @@ -99,7 +99,7 @@ static const struct regset sparc64_sol2_fpregset =
>  \f
>  
>  static struct sparc_frame_cache *
> -sparc64_sol2_sigtramp_frame_cache (frame_info_ptr this_frame,
> +sparc64_sol2_sigtramp_frame_cache (const frame_info_ptr &this_frame,
>  				   void **this_cache)
>  {
>    struct sparc_frame_cache *cache;
> @@ -154,7 +154,7 @@ sparc64_sol2_sigtramp_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -sparc64_sol2_sigtramp_frame_this_id (frame_info_ptr this_frame,
> +sparc64_sol2_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
>  				     void **this_cache,
>  				     struct frame_id *this_id)
>  {
> @@ -165,7 +165,7 @@ sparc64_sol2_sigtramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -sparc64_sol2_sigtramp_frame_prev_register (frame_info_ptr this_frame,
> +sparc64_sol2_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
>  					   void **this_cache,
>  					   int regnum)
>  {
> @@ -177,7 +177,7 @@ sparc64_sol2_sigtramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static int
>  sparc64_sol2_sigtramp_frame_sniffer (const struct frame_unwind *self,
> -				     frame_info_ptr this_frame,
> +				     const frame_info_ptr &this_frame,
>  				     void **this_cache)
>  {
>    return sol2_sigtramp_p (this_frame);
> diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
> index 39ad976eaaeb..8a90dd00d16f 100644
> --- a/gdb/sparc64-tdep.c
> +++ b/gdb/sparc64-tdep.c
> @@ -1063,13 +1063,13 @@ sparc64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
>  /* Normal frames.  */
>  
>  static struct sparc_frame_cache *
> -sparc64_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +sparc64_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    return sparc_frame_cache (this_frame, this_cache);
>  }
>  
>  static void
> -sparc64_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +sparc64_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		       struct frame_id *this_id)
>  {
>    struct sparc_frame_cache *cache =
> @@ -1083,7 +1083,7 @@ sparc64_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -sparc64_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +sparc64_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			     int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -1147,7 +1147,7 @@ static const struct frame_unwind sparc64_frame_unwind =
>  \f
>  
>  static CORE_ADDR
> -sparc64_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +sparc64_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct sparc_frame_cache *cache =
>      sparc64_frame_cache (this_frame, this_cache);
> @@ -1766,7 +1766,7 @@ sparc64_return_value (struct gdbarch *gdbarch, struct value *function,
>  static void
>  sparc64_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			       struct dwarf2_frame_state_reg *reg,
> -			       frame_info_ptr this_frame)
> +			       const frame_info_ptr &this_frame)
>  {
>    switch (regnum)
>      {
> diff --git a/gdb/sparc64-tdep.h b/gdb/sparc64-tdep.h
> index 8e097f1e86ff..6fcd91ee8d35 100644
> --- a/gdb/sparc64-tdep.h
> +++ b/gdb/sparc64-tdep.h
> @@ -131,7 +131,7 @@ extern const struct sparc_gregmap sparc64nbsd_gregmap;
>  
>  extern struct trad_frame_saved_reg *
>    sparc64nbsd_sigcontext_saved_regs (CORE_ADDR sigcontext_addr,
> -				     frame_info_ptr next_frame);
> +				     const frame_info_ptr &next_frame);
>  
>  extern const struct sparc_fpregmap sparc64_bsd_fpregmap;
>  
> diff --git a/gdb/stack.c b/gdb/stack.c
> index ab4d52849051..23e3891a0600 100644
> --- a/gdb/stack.c
> +++ b/gdb/stack.c
> @@ -215,14 +215,14 @@ static const gdb::option::option_def backtrace_command_option_defs[] = {
>  
>  /* Prototypes for local functions.  */
>  
> -static void print_frame_local_vars (frame_info_ptr frame,
> +static void print_frame_local_vars (const frame_info_ptr &frame,
>  				    bool quiet,
>  				    const char *regexp, const char *t_regexp,
>  				    int num_tabs, struct ui_file *stream);
>  
>  static void print_frame (struct ui_out *uiout,
>  			 const frame_print_options &opts,
> -			 frame_info_ptr frame, int print_level,
> +			 const frame_info_ptr &frame, int print_level,
>  			 enum print_what print_what,  int print_args,
>  			 struct symtab_and_line sal);
>  
> @@ -315,7 +315,7 @@ static last_displayed_symtab_info_type last_displayed_symtab_info;
>  /* See stack.h.  */
>  
>  bool
> -frame_show_address (frame_info_ptr frame,
> +frame_show_address (const frame_info_ptr &frame,
>  		    struct symtab_and_line sal)
>  {
>    /* If there is a line number, but no PC, then there is no location
> @@ -338,7 +338,7 @@ frame_show_address (frame_info_ptr frame,
>  /* See frame.h.  */
>  
>  void
> -print_stack_frame_to_uiout (struct ui_out *uiout, frame_info_ptr frame,
> +print_stack_frame_to_uiout (struct ui_out *uiout, const frame_info_ptr &frame,
>  			    int print_level, enum print_what print_what,
>  			    int set_current_sal)
>  {
> @@ -354,7 +354,7 @@ print_stack_frame_to_uiout (struct ui_out *uiout, frame_info_ptr frame,
>     source line, the actual PC is printed at the beginning.  */
>  
>  void
> -print_stack_frame (frame_info_ptr frame, int print_level,
> +print_stack_frame (const frame_info_ptr &frame, int print_level,
>  		   enum print_what print_what,
>  		   int set_current_sal)
>  {
> @@ -382,7 +382,7 @@ print_stack_frame (frame_info_ptr frame, int print_level,
>     argument (not just the first nameless argument).  */
>  
>  static void
> -print_frame_nameless_args (frame_info_ptr frame, long start, int num,
> +print_frame_nameless_args (const frame_info_ptr &frame, long start, int num,
>  			   int first, struct ui_file *stream)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> @@ -504,7 +504,7 @@ print_frame_arg (const frame_print_options &fp_opts,
>     exception.  */
>  
>  void
> -read_frame_local (struct symbol *sym, frame_info_ptr frame,
> +read_frame_local (struct symbol *sym, const frame_info_ptr &frame,
>  		  struct frame_arg *argp)
>  {
>    argp->sym = sym;
> @@ -526,7 +526,7 @@ read_frame_local (struct symbol *sym, frame_info_ptr frame,
>  
>  void
>  read_frame_arg (const frame_print_options &fp_opts,
> -		symbol *sym, frame_info_ptr frame,
> +		symbol *sym, const frame_info_ptr &frame,
>  		struct frame_arg *argp, struct frame_arg *entryargp)
>  {
>    struct value *val = NULL, *entryval = NULL;
> @@ -721,7 +721,7 @@ read_frame_arg (const frame_print_options &fp_opts,
>  
>  static void
>  print_frame_args (const frame_print_options &fp_opts,
> -		  struct symbol *func, frame_info_ptr frame,
> +		  struct symbol *func, const frame_info_ptr &frame,
>  		  int num, struct ui_file *stream)
>  {
>    struct ui_out *uiout = current_uiout;
> @@ -920,7 +920,7 @@ print_frame_args (const frame_print_options &fp_opts,
>     line is in the center of the next 'list'.  */
>  
>  void
> -set_current_sal_from_frame (frame_info_ptr frame)
> +set_current_sal_from_frame (const frame_info_ptr &frame)
>  {
>    symtab_and_line sal = find_frame_sal (frame);
>    if (sal.symtab != NULL)
> @@ -986,7 +986,7 @@ print_frame_info_to_print_what (const char *print_frame_info)
>  /* Print the PC from FRAME, plus any flags, to UIOUT.  */
>  
>  static void
> -print_pc (struct ui_out *uiout, struct gdbarch *gdbarch, frame_info_ptr frame,
> +print_pc (struct ui_out *uiout, struct gdbarch *gdbarch, const frame_info_ptr &frame,
>  	  CORE_ADDR pc)
>  {
>    uiout->field_core_addr ("addr", gdbarch, pc);
> @@ -1021,7 +1021,7 @@ get_user_print_what_frame_info (std::optional<enum print_what> *what)
>  
>  static void
>  do_print_frame_info (struct ui_out *uiout, const frame_print_options &fp_opts,
> -		     frame_info_ptr frame, int print_level,
> +		     const frame_info_ptr &frame, int print_level,
>  		     enum print_what print_what, int print_args,
>  		     int set_current_sal)
>  {
> @@ -1189,7 +1189,7 @@ do_print_frame_info (struct ui_out *uiout, const frame_print_options &fp_opts,
>  
>  void
>  print_frame_info (const frame_print_options &fp_opts,
> -		  frame_info_ptr frame, int print_level,
> +		  const frame_info_ptr &frame, int print_level,
>  		  enum print_what print_what, int print_args,
>  		  int set_current_sal)
>  {
> @@ -1269,7 +1269,7 @@ get_last_displayed_sal ()
>     corresponding to FRAME.  */
>  
>  gdb::unique_xmalloc_ptr<char>
> -find_frame_funname (frame_info_ptr frame, enum language *funlang,
> +find_frame_funname (const frame_info_ptr &frame, enum language *funlang,
>  		    struct symbol **funcp)
>  {
>    struct symbol *func;
> @@ -1324,7 +1324,7 @@ find_frame_funname (frame_info_ptr frame, enum language *funlang,
>  static void
>  print_frame (struct ui_out *uiout,
>  	     const frame_print_options &fp_opts,
> -	     frame_info_ptr frame, int print_level,
> +	     const frame_info_ptr &frame, int print_level,
>  	     enum print_what print_what, int print_args,
>  	     struct symtab_and_line sal)
>  {
> @@ -1478,7 +1478,7 @@ frame_selection_by_function_completer (struct cmd_list_element *ignore,
>     level 1') then SELECTED_FRAME_P will be false.  */
>  
>  static void
> -info_frame_command_core (frame_info_ptr fi, bool selected_frame_p)
> +info_frame_command_core (const frame_info_ptr &fi, bool selected_frame_p)
>  {
>    struct symbol *func;
>    struct symtab *s;
> @@ -1836,7 +1836,7 @@ trailing_outermost_frame (int count)
>     SELECT_FRAME.  */
>  
>  static void
> -select_frame_command_core (frame_info_ptr fi, bool ignored)
> +select_frame_command_core (const frame_info_ptr &fi, bool ignored)
>  {
>    frame_info_ptr prev_frame = get_selected_frame ();
>    select_frame (fi);
> @@ -1849,7 +1849,7 @@ select_frame_command_core (frame_info_ptr fi, bool ignored)
>     reprint the current frame summary).   */
>  
>  static void
> -frame_command_core (frame_info_ptr fi, bool ignored)
> +frame_command_core (const frame_info_ptr &fi, bool ignored)
>  {
>    frame_info_ptr prev_frame = get_selected_frame ();
>    select_frame (fi);
> @@ -1873,7 +1873,7 @@ frame_command_core (frame_info_ptr fi, bool ignored)
>     'frame' will all cause SELECTED_FRAME_P to be true.  In all other cases
>     SELECTED_FRAME_P is false.  */
>  
> -template <void (*FPTR) (frame_info_ptr fi, bool selected_frame_p)>
> +template <void (*FPTR) (const frame_info_ptr &fi, bool selected_frame_p)>
>  class frame_command_helper
>  {
>  public:
> @@ -2338,7 +2338,7 @@ prepare_reg (const char *regexp, std::optional<compiled_regex> *reg)
>     explaining why no local variables could be printed.  */
>  
>  static void
> -print_frame_local_vars (frame_info_ptr frame,
> +print_frame_local_vars (const frame_info_ptr &frame,
>  			bool quiet,
>  			const char *regexp, const char *t_regexp,
>  			int num_tabs, struct ui_file *stream)
> @@ -2500,7 +2500,7 @@ iterate_over_block_arg_vars (const struct block *b,
>     explaining why no argument variables could be printed.  */
>  
>  static void
> -print_frame_arg_vars (frame_info_ptr frame,
> +print_frame_arg_vars (const frame_info_ptr &frame,
>  		      bool quiet,
>  		      const char *regexp, const char *t_regexp,
>  		      struct ui_file *stream)
> diff --git a/gdb/stack.h b/gdb/stack.h
> index eb52c1d193fe..e7242c710367 100644
> --- a/gdb/stack.h
> +++ b/gdb/stack.h
> @@ -20,7 +20,7 @@
>  #ifndef STACK_H
>  #define STACK_H
>  
> -gdb::unique_xmalloc_ptr<char> find_frame_funname (frame_info_ptr frame,
> +gdb::unique_xmalloc_ptr<char> find_frame_funname (const frame_info_ptr &frame,
>  						  enum language *funlang,
>  						  struct symbol **funcp);
>  
> @@ -43,7 +43,7 @@ void get_user_print_what_frame_info (std::optional<enum print_what> *what);
>  /* Return true if we should display the address in addition to the location,
>     because we are in the middle of a statement.  */
>  
> -bool frame_show_address (frame_info_ptr frame, struct symtab_and_line sal);
> +bool frame_show_address (const frame_info_ptr &frame, struct symtab_and_line sal);
>  
>  /* Forget the last sal we displayed.  */
>  
> diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
> index e5796f2ff76d..b54e4d2d10a7 100644
> --- a/gdb/stap-probe.c
> +++ b/gdb/stap-probe.c
> @@ -151,7 +151,7 @@ class stap_probe : public probe
>  
>    /* See probe.h.  */
>    struct value *evaluate_argument (unsigned n,
> -				   frame_info_ptr frame) override;
> +				   const frame_info_ptr &frame) override;
>  
>    /* See probe.h.  */
>    void compile_to_ax (struct agent_expr *aexpr,
> @@ -1438,7 +1438,7 @@ stap_probe::can_evaluate_arguments () const
>     corresponding to it.  Assertion is thrown if N does not exist.  */
>  
>  struct value *
> -stap_probe::evaluate_argument (unsigned n, frame_info_ptr frame)
> +stap_probe::evaluate_argument (unsigned n, const frame_info_ptr &frame)
>  {
>    struct stap_probe_arg *arg;
>    struct gdbarch *gdbarch = get_frame_arch (frame);
> diff --git a/gdb/std-regs.c b/gdb/std-regs.c
> index 8901f326c8dd..755e0c987e6e 100644
> --- a/gdb/std-regs.c
> +++ b/gdb/std-regs.c
> @@ -27,7 +27,7 @@
>  #include "gdbarch.h"
>  
>  static struct value *
> -value_of_builtin_frame_fp_reg (frame_info_ptr frame, const void *baton)
> +value_of_builtin_frame_fp_reg (const frame_info_ptr &frame, const void *baton)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>  
> @@ -53,7 +53,7 @@ value_of_builtin_frame_fp_reg (frame_info_ptr frame, const void *baton)
>  }
>  
>  static struct value *
> -value_of_builtin_frame_pc_reg (frame_info_ptr frame, const void *baton)
> +value_of_builtin_frame_pc_reg (const frame_info_ptr &frame, const void *baton)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>  
> @@ -73,7 +73,7 @@ value_of_builtin_frame_pc_reg (frame_info_ptr frame, const void *baton)
>  }
>  
>  static struct value *
> -value_of_builtin_frame_sp_reg (frame_info_ptr frame, const void *baton)
> +value_of_builtin_frame_sp_reg (const frame_info_ptr &frame, const void *baton)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>  
> @@ -84,7 +84,7 @@ value_of_builtin_frame_sp_reg (frame_info_ptr frame, const void *baton)
>  }
>  
>  static struct value *
> -value_of_builtin_frame_ps_reg (frame_info_ptr frame, const void *baton)
> +value_of_builtin_frame_ps_reg (const frame_info_ptr &frame, const void *baton)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>  
> diff --git a/gdb/symtab.h b/gdb/symtab.h
> index ca5a5b0f7fde..5bd63979132c 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -1114,13 +1114,13 @@ struct symbol_computed_ops
>       FRAME may be zero.  */
>  
>    struct value *(*read_variable) (struct symbol * symbol,
> -				  frame_info_ptr frame);
> +				  const frame_info_ptr &frame);
>  
>    /* Read variable SYMBOL like read_variable at (callee) FRAME's function
>       entry.  SYMBOL should be a function parameter, otherwise
>       NO_ENTRY_VALUE_ERROR will be thrown.  */
>    struct value *(*read_variable_at_entry) (struct symbol *symbol,
> -					   frame_info_ptr frame);
> +					   const frame_info_ptr &frame);
>  
>    /* Find the "symbol_needs_kind" value for the given symbol.  This
>       value determines whether reading the symbol needs memory (e.g., a
> @@ -1192,7 +1192,7 @@ struct symbol_block_ops
>       computed with DW_AT_static_link and this method must be used to compute
>       the corresponding DW_AT_frame_base attribute.  */
>    CORE_ADDR (*get_frame_base) (struct symbol *framefunc,
> -			       frame_info_ptr frame);
> +			       const frame_info_ptr &frame);
>  
>    /* Return the block for this function.  So far, this is used to
>       implement function aliases.  So, if this is set, then it's not
> @@ -2350,7 +2350,7 @@ struct gnu_ifunc_fns
>  
>  extern const struct gnu_ifunc_fns *gnu_ifunc_fns_p;
>  
> -extern CORE_ADDR find_solib_trampoline_target (frame_info_ptr, CORE_ADDR);
> +extern CORE_ADDR find_solib_trampoline_target (const frame_info_ptr &, CORE_ADDR);
>  
>  struct symtab_and_line
>  {
> diff --git a/gdb/tic6x-linux-tdep.c b/gdb/tic6x-linux-tdep.c
> index 870ba368fda1..a9de60cf662a 100644
> --- a/gdb/tic6x-linux-tdep.c
> +++ b/gdb/tic6x-linux-tdep.c
> @@ -79,7 +79,7 @@ tic6x_register_sigcontext_offset (unsigned int regnum, struct gdbarch *gdbarch)
>  
>  static void
>  tic6x_linux_rt_sigreturn_init (const struct tramp_frame *self,
> -			       frame_info_ptr this_frame,
> +			       const frame_info_ptr &this_frame,
>  			       struct trad_frame_cache *this_cache,
>  			       CORE_ADDR func)
>  {
> @@ -149,7 +149,7 @@ static struct tramp_frame tic6x_linux_rt_sigreturn_tramp_frame =
>     instruction to be executed.  */
>  
>  static CORE_ADDR
> -tic6x_linux_syscall_next_pc (frame_info_ptr frame)
> +tic6x_linux_syscall_next_pc (const frame_info_ptr &frame)
>  {
>    ULONGEST syscall_number = get_frame_register_unsigned (frame,
>  							 TIC6X_B0_REGNUM);
> diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
> index c81f0100a27a..aa115095df79 100644
> --- a/gdb/tic6x-tdep.c
> +++ b/gdb/tic6x-tdep.c
> @@ -142,7 +142,7 @@ static CORE_ADDR
>  tic6x_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
>  			const CORE_ADDR current_pc,
>  			struct tic6x_unwind_cache *cache,
> -			frame_info_ptr this_frame)
> +			const frame_info_ptr &this_frame)
>  {
>    unsigned int src_reg, base_reg, dst_reg;
>    int i;
> @@ -340,7 +340,7 @@ tic6x_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
>  static void
>  tic6x_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  			     struct dwarf2_frame_state_reg *reg,
> -			     frame_info_ptr this_frame)
> +			     const frame_info_ptr &this_frame)
>  {
>    /* Mark the PC as the destination for the return address.  */
>    if (regnum == gdbarch_pc_regnum (gdbarch))
> @@ -365,7 +365,7 @@ tic6x_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
>  /* This is the implementation of gdbarch method unwind_pc.  */
>  
>  static CORE_ADDR
> -tic6x_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +tic6x_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    gdb_byte buf[8];
>  
> @@ -376,7 +376,7 @@ tic6x_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  /* Frame base handling.  */
>  
>  static struct tic6x_unwind_cache*
> -tic6x_frame_unwind_cache (frame_info_ptr this_frame,
> +tic6x_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			  void **this_prologue_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -404,7 +404,7 @@ tic6x_frame_unwind_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -tic6x_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +tic6x_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		     struct frame_id *this_id)
>  {
>    struct tic6x_unwind_cache *cache =
> @@ -418,7 +418,7 @@ tic6x_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -tic6x_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
> +tic6x_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
>  			   int regnum)
>  {
>    struct tic6x_unwind_cache *cache =
> @@ -445,7 +445,7 @@ tic6x_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static CORE_ADDR
> -tic6x_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +tic6x_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct tic6x_unwind_cache *info
>      = tic6x_frame_unwind_cache (this_frame, this_cache);
> @@ -473,7 +473,7 @@ static const struct frame_base tic6x_frame_base =
>  
>  
>  static struct tic6x_unwind_cache *
> -tic6x_make_stub_cache (frame_info_ptr this_frame)
> +tic6x_make_stub_cache (const frame_info_ptr &this_frame)
>  {
>    struct tic6x_unwind_cache *cache;
>  
> @@ -489,7 +489,7 @@ tic6x_make_stub_cache (frame_info_ptr this_frame)
>  }
>  
>  static void
> -tic6x_stub_this_id (frame_info_ptr this_frame, void **this_cache,
> +tic6x_stub_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		    struct frame_id *this_id)
>  {
>    struct tic6x_unwind_cache *cache;
> @@ -503,7 +503,7 @@ tic6x_stub_this_id (frame_info_ptr this_frame, void **this_cache,
>  
>  static int
>  tic6x_stub_unwind_sniffer (const struct frame_unwind *self,
> -			   frame_info_ptr this_frame,
> +			   const frame_info_ptr &this_frame,
>  			   void **this_prologue_cache)
>  {
>    CORE_ADDR addr_in_block;
> @@ -1103,7 +1103,7 @@ tic6x_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
>  /* This is the implementation of gdbarch method get_longjmp_target.  */
>  
>  static int
> -tic6x_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +tic6x_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> diff --git a/gdb/tic6x-tdep.h b/gdb/tic6x-tdep.h
> index 61978ea76813..886e1b8b3098 100644
> --- a/gdb/tic6x-tdep.h
> +++ b/gdb/tic6x-tdep.h
> @@ -50,7 +50,7 @@ struct tic6x_gdbarch_tdep : gdbarch_tdep_base
>  {
>    /* Return the expected next PC if FRAME is stopped at a syscall
>       instruction.  */
> -  CORE_ADDR (*syscall_next_pc) (frame_info_ptr frame) = nullptr;
> +  CORE_ADDR (*syscall_next_pc) (const frame_info_ptr &frame) = nullptr;
>  
>    const gdb_byte *breakpoint = nullptr; /* Breakpoint instruction.  */
>  
> diff --git a/gdb/tilegx-linux-tdep.c b/gdb/tilegx-linux-tdep.c
> index efd2e9f8f23b..e0ff0fc2a86c 100644
> --- a/gdb/tilegx-linux-tdep.c
> +++ b/gdb/tilegx-linux-tdep.c
> @@ -34,7 +34,7 @@
>  
>  static void
>  tilegx_linux_sigframe_init (const struct tramp_frame *self,
> -			    frame_info_ptr this_frame,
> +			    const frame_info_ptr &this_frame,
>  			    struct trad_frame_cache *this_cache,
>  			    CORE_ADDR func)
>  {
> diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
> index 8264937788f0..c25933be5585 100644
> --- a/gdb/tilegx-tdep.c
> +++ b/gdb/tilegx-tdep.c
> @@ -362,7 +362,7 @@ static CORE_ADDR
>  tilegx_analyze_prologue (struct gdbarch* gdbarch,
>  			 CORE_ADDR start_addr, CORE_ADDR end_addr,
>  			 struct tilegx_frame_cache *cache,
> -			 frame_info_ptr next_frame)
> +			 const frame_info_ptr &next_frame)
>  {
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>    CORE_ADDR next_addr;
> @@ -774,7 +774,7 @@ tilegx_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
>  /* This is the implementation of gdbarch method get_longjmp_target.  */
>  
>  static int
> -tilegx_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
> +tilegx_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -833,7 +833,7 @@ typedef BP_MANIPULATION (tilegx_break_insn) tilegx_breakpoint;
>  /* Normal frames.  */
>  
>  static struct tilegx_frame_cache *
> -tilegx_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +tilegx_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct tilegx_frame_cache *cache;
> @@ -864,7 +864,7 @@ tilegx_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  /* Retrieve the value of REGNUM in FRAME.  */
>  
>  static struct value*
> -tilegx_frame_prev_register (frame_info_ptr this_frame,
> +tilegx_frame_prev_register (const frame_info_ptr &this_frame,
>  			    void **this_cache,
>  			    int regnum)
>  {
> @@ -878,7 +878,7 @@ tilegx_frame_prev_register (frame_info_ptr this_frame,
>  /* Build frame id.  */
>  
>  static void
> -tilegx_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +tilegx_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		      struct frame_id *this_id)
>  {
>    struct tilegx_frame_cache *info =
> @@ -892,7 +892,7 @@ tilegx_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static CORE_ADDR
> -tilegx_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +tilegx_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct tilegx_frame_cache *cache =
>      tilegx_frame_cache (this_frame, this_cache);
> diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
> index 7005ca83455c..418d9ea2203a 100644
> --- a/gdb/tracepoint.c
> +++ b/gdb/tracepoint.c
> @@ -206,7 +206,7 @@ set_tracepoint_num (int num)
>     the traceframe context (line, function, file).  */
>  
>  static void
> -set_traceframe_context (frame_info_ptr trace_frame)
> +set_traceframe_context (const frame_info_ptr &trace_frame)
>  {
>    CORE_ADDR trace_pc;
>    struct symbol *traceframe_fun;
> diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c
> index 78bfb2fdd4e4..8b63927b133c 100644
> --- a/gdb/trad-frame.c
> +++ b/gdb/trad-frame.c
> @@ -36,7 +36,7 @@ struct trad_frame_cache
>  };
>  
>  struct trad_frame_cache *
> -trad_frame_cache_zalloc (frame_info_ptr this_frame)
> +trad_frame_cache_zalloc (const frame_info_ptr &this_frame)
>  {
>    struct trad_frame_cache *this_trad_cache;
>  
> @@ -83,7 +83,7 @@ trad_frame_alloc_saved_regs (struct gdbarch *gdbarch)
>     for all potential instruction sequences).  */
>  
>  trad_frame_saved_reg *
> -trad_frame_alloc_saved_regs (frame_info_ptr this_frame)
> +trad_frame_alloc_saved_regs (const frame_info_ptr &this_frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>  
> @@ -184,7 +184,7 @@ trad_frame_set_reg_value_bytes (struct trad_frame_cache *this_trad_cache,
>  
>  
>  struct value *
> -trad_frame_get_prev_register (frame_info_ptr this_frame,
> +trad_frame_get_prev_register (const frame_info_ptr &this_frame,
>  			      trad_frame_saved_reg this_saved_regs[],
>  			      int regnum)
>  {
> @@ -209,7 +209,7 @@ trad_frame_get_prev_register (frame_info_ptr this_frame,
>  
>  struct value *
>  trad_frame_get_register (struct trad_frame_cache *this_trad_cache,
> -			 frame_info_ptr this_frame,
> +			 const frame_info_ptr &this_frame,
>  			 int regnum)
>  {
>    return trad_frame_get_prev_register (this_frame, this_trad_cache->prev_regs,
> diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h
> index 96d2953a2674..ca8792baa17d 100644
> --- a/gdb/trad-frame.h
> +++ b/gdb/trad-frame.h
> @@ -31,7 +31,7 @@ struct trad_frame_cache;
>     The entire cache is populated in a single pass and then generic
>     routines are used to extract the various cache values.  */
>  
> -struct trad_frame_cache *trad_frame_cache_zalloc (frame_info_ptr);
> +struct trad_frame_cache *trad_frame_cache_zalloc (const frame_info_ptr &);
>  
>  /* This frame's ID.  */
>  void trad_frame_set_id (struct trad_frame_cache *this_trad_cache,
> @@ -59,7 +59,7 @@ void trad_frame_set_reg_value_bytes (struct trad_frame_cache *this_trad_cache,
>  				     gdb::array_view<const gdb_byte> bytes);
>  
>  struct value *trad_frame_get_register (struct trad_frame_cache *this_trad_cache,
> -				       frame_info_ptr this_frame,
> +				       const frame_info_ptr &this_frame,
>  				       int regnum);
>  
>  /* Describes the kind of encoding a stored register has.  */
> @@ -194,12 +194,12 @@ void trad_frame_reset_saved_regs (struct gdbarch *gdbarch,
>  				  trad_frame_saved_reg *regs);
>  
>  /* Return a freshly allocated (and initialized) trad_frame array.  */
> -trad_frame_saved_reg *trad_frame_alloc_saved_regs (frame_info_ptr);
> +trad_frame_saved_reg *trad_frame_alloc_saved_regs (const frame_info_ptr &);
>  trad_frame_saved_reg *trad_frame_alloc_saved_regs (struct gdbarch *);
>  
>  /* Given the trad_frame info, return the location of the specified
>     register.  */
> -struct value *trad_frame_get_prev_register (frame_info_ptr this_frame,
> +struct value *trad_frame_get_prev_register (const frame_info_ptr &this_frame,
>  					    trad_frame_saved_reg this_saved_regs[],
>  					    int regnum);
>  
> diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c
> index 51abd347db42..0e730e66b583 100644
> --- a/gdb/tramp-frame.c
> +++ b/gdb/tramp-frame.c
> @@ -40,7 +40,7 @@ struct tramp_frame_cache
>  };
>  
>  static struct trad_frame_cache *
> -tramp_frame_cache (frame_info_ptr this_frame,
> +tramp_frame_cache (const frame_info_ptr &this_frame,
>  		   void **this_cache)
>  {
>    struct tramp_frame_cache *tramp_cache
> @@ -58,7 +58,7 @@ tramp_frame_cache (frame_info_ptr this_frame,
>  }
>  
>  static void
> -tramp_frame_this_id (frame_info_ptr this_frame,
> +tramp_frame_this_id (const frame_info_ptr &this_frame,
>  		     void **this_cache,
>  		     struct frame_id *this_id)
>  {
> @@ -69,7 +69,7 @@ tramp_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -tramp_frame_prev_register (frame_info_ptr this_frame,
> +tramp_frame_prev_register (const frame_info_ptr &this_frame,
>  			   void **this_cache,
>  			   int prev_regnum)
>  {
> @@ -81,7 +81,7 @@ tramp_frame_prev_register (frame_info_ptr this_frame,
>  
>  static CORE_ADDR
>  tramp_frame_start (const struct tramp_frame *tramp,
> -		   frame_info_ptr this_frame, CORE_ADDR pc)
> +		   const frame_info_ptr &this_frame, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -121,7 +121,7 @@ tramp_frame_start (const struct tramp_frame *tramp,
>  
>  static int
>  tramp_frame_sniffer (const struct frame_unwind *self,
> -		     frame_info_ptr this_frame,
> +		     const frame_info_ptr &this_frame,
>  		     void **this_cache)
>  {
>    const struct tramp_frame *tramp = self->unwind_data->tramp_frame;
> diff --git a/gdb/tramp-frame.h b/gdb/tramp-frame.h
> index 36185c1f4e0b..d9e54f5981a2 100644
> --- a/gdb/tramp-frame.h
> +++ b/gdb/tramp-frame.h
> @@ -66,7 +66,7 @@ struct tramp_frame
>    /* Initialize a trad-frame cache corresponding to the tramp-frame.
>       FUNC is the address of the instruction TRAMP[0] in memory.  */
>    void (*init) (const struct tramp_frame *self,
> -		frame_info_ptr this_frame,
> +		const frame_info_ptr &this_frame,
>  		struct trad_frame_cache *this_cache,
>  		CORE_ADDR func);
>    /* Return non-zero if the tramp-frame is valid for the PC requested.
> @@ -74,7 +74,7 @@ struct tramp_frame
>       sequence against if required.  If this is NULL, then the tramp-frame
>       is valid for any PC.  */
>    int (*validate) (const struct tramp_frame *self,
> -		   frame_info_ptr this_frame,
> +		   const frame_info_ptr &this_frame,
>  		   CORE_ADDR *pc);
>  
>    /* Given the current frame in THIS_FRAME and a frame cache in FRAME_CACHE,
> diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
> index 45c60db99203..5dc27c32daac 100644
> --- a/gdb/tui/tui-disasm.c
> +++ b/gdb/tui/tui-disasm.c
> @@ -490,7 +490,7 @@ tui_disasm_window::addr_is_displayed (CORE_ADDR addr) const
>  }
>  
>  void
> -tui_disasm_window::maybe_update (frame_info_ptr fi, symtab_and_line sal)
> +tui_disasm_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal)
>  {
>    CORE_ADDR low;
>  
> diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
> index 9c4eabbb0929..0aef091069b7 100644
> --- a/gdb/tui/tui-disasm.h
> +++ b/gdb/tui/tui-disasm.h
> @@ -41,7 +41,7 @@ struct tui_disasm_window : public tui_source_window_base
>  
>    bool location_matches_p (struct bp_location *loc, int line_no) override;
>  
> -  void maybe_update (frame_info_ptr fi, symtab_and_line sal) override;
> +  void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) override;
>  
>    void erase_source_content () override
>    {
> diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
> index 28d0b742ed76..289a25996889 100644
> --- a/gdb/tui/tui-hooks.c
> +++ b/gdb/tui/tui-hooks.c
> @@ -66,7 +66,7 @@ tui_all_objfiles_removed (program_space *pspace)
>  /* Observer for the register_changed notification.  */
>  
>  static void
> -tui_register_changed (frame_info_ptr frame, int regno)
> +tui_register_changed (const frame_info_ptr &frame, int regno)
>  {
>    frame_info_ptr fi;
>  
> diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
> index 504aed4b81f9..e7c1839656c8 100644
> --- a/gdb/tui/tui-regs.c
> +++ b/gdb/tui/tui-regs.c
> @@ -85,7 +85,7 @@ tab_expansion_file::write (const char *buf, long length_buf)
>     representation of it.  */
>  
>  static std::string
> -tui_register_format (frame_info_ptr frame, int regnum)
> +tui_register_format (const frame_info_ptr &frame, int regnum)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>  
> @@ -406,7 +406,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
>     given a particular frame.  If the values have changed, they are
>     updated with the new value and highlighted.  */
>  void
> -tui_data_window::check_register_values (frame_info_ptr frame)
> +tui_data_window::check_register_values (const frame_info_ptr &frame)
>  {
>    if (frame == nullptr)
>      set_register_group (nullptr);
> diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
> index 9d9cae40fe07..07b951316b6b 100644
> --- a/gdb/tui/tui-regs.h
> +++ b/gdb/tui/tui-regs.h
> @@ -74,7 +74,7 @@ struct tui_data_window : public tui_win_info
>      return DATA_NAME;
>    }
>  
> -  void check_register_values (frame_info_ptr frame);
> +  void check_register_values (const frame_info_ptr &frame);
>  
>    void set_register_group (const reggroup *group);
>  
> diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
> index 635cb2f35a65..fa956b29a195 100644
> --- a/gdb/tui/tui-source.c
> +++ b/gdb/tui/tui-source.c
> @@ -199,7 +199,7 @@ tui_source_window::line_is_displayed (int line) const
>  }
>  
>  void
> -tui_source_window::maybe_update (frame_info_ptr fi, symtab_and_line sal)
> +tui_source_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal)
>  {
>    int start_line = (sal.line - ((height - box_size ()) / 2)) + 1;
>    if (start_line <= 0)
> diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
> index 0bf43b663e73..6d4ad4e39c27 100644
> --- a/gdb/tui/tui-source.h
> +++ b/gdb/tui/tui-source.h
> @@ -46,7 +46,7 @@ struct tui_source_window : public tui_source_window_base
>  
>    bool showing_source_p (const char *filename) const;
>  
> -  void maybe_update (frame_info_ptr fi, symtab_and_line sal) override;
> +  void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) override;
>  
>    void erase_source_content () override
>    {
> diff --git a/gdb/tui/tui-status.c b/gdb/tui/tui-status.c
> index df4675fe5dfb..aac391d3babc 100644
> --- a/gdb/tui/tui-status.c
> +++ b/gdb/tui/tui-status.c
> @@ -213,7 +213,7 @@ tui_status_window::make_status_line () const
>     name is demangled if demangling is turned on.  Returns a pointer to
>     a static area holding the result.  */
>  static char*
> -tui_get_function_from_frame (frame_info_ptr fi)
> +tui_get_function_from_frame (const frame_info_ptr &fi)
>  {
>    static char name[256];
>    string_file stream;
> @@ -267,7 +267,7 @@ tui_status_window::rerender ()
>     refresh.  */
>  
>  void
> -tui_show_frame_info (frame_info_ptr fi)
> +tui_show_frame_info (const frame_info_ptr &fi)
>  {
>    bool status_changed_p;
>  
> diff --git a/gdb/tui/tui-status.h b/gdb/tui/tui-status.h
> index efef5375e86e..0af446641042 100644
> --- a/gdb/tui/tui-status.h
> +++ b/gdb/tui/tui-status.h
> @@ -51,6 +51,6 @@ struct tui_status_window
>  };
>  
>  extern void tui_show_status_content (void);
> -extern void tui_show_frame_info (frame_info_ptr);
> +extern void tui_show_frame_info (const frame_info_ptr &);
>  
>  #endif /* TUI_TUI_STATUS_H */
> diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
> index 628fc22c03ca..646597306f26 100644
> --- a/gdb/tui/tui-winsource.h
> +++ b/gdb/tui/tui-winsource.h
> @@ -159,7 +159,7 @@ struct tui_source_window_base : public tui_win_info
>  
>    /* Update the window to display the given location.  Does nothing if
>       the location is already displayed.  */
> -  virtual void maybe_update (frame_info_ptr fi, symtab_and_line sal) = 0;
> +  virtual void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) = 0;
>  
>    void update_source_window_as_is  (struct gdbarch *gdbarch,
>  				    const struct symtab_and_line &sal);
> diff --git a/gdb/unittests/frame_info_ptr-selftests.c b/gdb/unittests/frame_info_ptr-selftests.c
> index f0981b836dd3..f09d1c8ba015 100644
> --- a/gdb/unittests/frame_info_ptr-selftests.c
> +++ b/gdb/unittests/frame_info_ptr-selftests.c
> @@ -36,7 +36,7 @@ validate_user_created_frame (frame_id id)
>  }
>  
>  static frame_info_ptr
> -user_created_frame_callee (frame_info_ptr frame)
> +user_created_frame_callee (const frame_info_ptr &frame)
>  {
>    validate_user_created_frame (get_frame_id (frame));
>  
> diff --git a/gdb/user-regs.c b/gdb/user-regs.c
> index 61c8f8bd2c02..d1b510a79278 100644
> --- a/gdb/user-regs.c
> +++ b/gdb/user-regs.c
> @@ -44,7 +44,7 @@ struct user_reg
>    /* Avoid the "read" symbol name as it conflicts with a preprocessor symbol
>       in the NetBSD header for Stack Smashing Protection, that wraps the read(2)
>       syscall.  */
> -  struct value *(*xread) (frame_info_ptr frame, const void *baton);
> +  struct value *(*xread) (const frame_info_ptr &frame, const void *baton);
>    const void *baton;
>    struct user_reg *next;
>  };
> @@ -203,7 +203,7 @@ user_reg_map_regnum_to_name (struct gdbarch *gdbarch, int regnum)
>  }
>  
>  struct value *
> -value_of_user_reg (int regnum, frame_info_ptr frame)
> +value_of_user_reg (int regnum, const frame_info_ptr &frame)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    int maxregs = gdbarch_num_cooked_regs (gdbarch);
> diff --git a/gdb/user-regs.h b/gdb/user-regs.h
> index cbe0cded2d5e..baa3581a0baf 100644
> --- a/gdb/user-regs.h
> +++ b/gdb/user-regs.h
> @@ -56,9 +56,9 @@ extern const char *user_reg_map_regnum_to_name (struct gdbarch *gdbarch,
>     bytes as, at the time the register is being added, the type needed
>     to describe the register has not bee initialized.  */
>  
> -typedef struct value *(user_reg_read_ftype) (frame_info_ptr frame,
> +typedef struct value *(user_reg_read_ftype) (const frame_info_ptr &frame,
>  					     const void *baton);
> -extern struct value *value_of_user_reg (int regnum, frame_info_ptr frame);
> +extern struct value *value_of_user_reg (int regnum, const frame_info_ptr &frame);
>  
>  /* Add a builtin register (present in all architectures).  */
>  extern void user_reg_add_builtin (const char *name,
> diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
> index 5b22ee2f4c42..4c1fd383a84f 100644
> --- a/gdb/v850-tdep.c
> +++ b/gdb/v850-tdep.c
> @@ -1212,7 +1212,7 @@ v850_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
>  }
>  
>  static struct v850_frame_cache *
> -v850_alloc_frame_cache (frame_info_ptr this_frame)
> +v850_alloc_frame_cache (const frame_info_ptr &this_frame)
>  {
>    struct v850_frame_cache *cache;
>  
> @@ -1231,7 +1231,7 @@ v850_alloc_frame_cache (frame_info_ptr this_frame)
>  }
>  
>  static struct v850_frame_cache *
> -v850_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +v850_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct v850_frame_cache *cache;
> @@ -1297,7 +1297,7 @@ v850_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  
>  
>  static struct value *
> -v850_frame_prev_register (frame_info_ptr this_frame,
> +v850_frame_prev_register (const frame_info_ptr &this_frame,
>  			  void **this_cache, int regnum)
>  {
>    struct v850_frame_cache *cache = v850_frame_cache (this_frame, this_cache);
> @@ -1308,7 +1308,7 @@ v850_frame_prev_register (frame_info_ptr this_frame,
>  }
>  
>  static void
> -v850_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +v850_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		    struct frame_id *this_id)
>  {
>    struct v850_frame_cache *cache = v850_frame_cache (this_frame, this_cache);
> @@ -1331,7 +1331,7 @@ static const struct frame_unwind v850_frame_unwind = {
>  };
>  
>  static CORE_ADDR
> -v850_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +v850_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct v850_frame_cache *cache = v850_frame_cache (this_frame, this_cache);
>  
> diff --git a/gdb/valops.c b/gdb/valops.c
> index 399d0f109e14..be907440a59b 100644
> --- a/gdb/valops.c
> +++ b/gdb/valops.c
> @@ -976,7 +976,7 @@ value_one (struct type *type)
>     e.g. in case the type is a variable length array.  */
>  
>  static struct value *
> -get_value_at (struct type *type, CORE_ADDR addr, frame_info_ptr frame,
> +get_value_at (struct type *type, CORE_ADDR addr, const frame_info_ptr &frame,
>  	      int lazy)
>  {
>    struct value *val;
> @@ -1029,7 +1029,7 @@ value_at_non_lval (struct type *type, CORE_ADDR addr)
>     e.g. in case the type is a variable length array.  */
>  
>  struct value *
> -value_at_lazy (struct type *type, CORE_ADDR addr, frame_info_ptr frame)
> +value_at_lazy (struct type *type, CORE_ADDR addr, const frame_info_ptr &frame)
>  {
>    return get_value_at (type, addr, frame, 1);
>  }
> diff --git a/gdb/value.c b/gdb/value.c
> index bea34e556a60..c7e940badb97 100644
> --- a/gdb/value.c
> +++ b/gdb/value.c
> @@ -962,11 +962,11 @@ value::allocate (struct type *type)
>  /* See value.h  */
>  
>  value *
> -value::allocate_register_lazy (frame_info_ptr next_frame, int regnum,
> -			       struct type *type)
> +value::allocate_register_lazy (const frame_info_ptr &initial_next_frame,
> +			       int regnum, struct type *type)
>  {
>    if (type == nullptr)
> -    type = register_type (frame_unwind_arch (next_frame), regnum);
> +    type = register_type (frame_unwind_arch (initial_next_frame), regnum);
>  
>    value *result = value::allocate_lazy (type);
>  
> @@ -978,6 +978,7 @@ value::allocate_register_lazy (frame_info_ptr next_frame, int regnum,
>       NEXT_FRAME will not have a valid frame id yet.  Find the next non-inline
>       frame (possibly the sentinel frame).  This is where registers are unwound
>       from anyway.  */
> +  frame_info_ptr next_frame = initial_next_frame;
>    while (get_frame_type (next_frame) == INLINE_FRAME)
>      next_frame = get_next_frame_sentinel_okay (next_frame);
>  
> @@ -992,7 +993,7 @@ value::allocate_register_lazy (frame_info_ptr next_frame, int regnum,
>  /* See value.h  */
>  
>  value *
> -value::allocate_register (frame_info_ptr next_frame, int regnum,
> +value::allocate_register (const frame_info_ptr &next_frame, int regnum,
>  			  struct type *type)
>  {
>    value *result = value::allocate_register_lazy (next_frame, regnum, type);
> @@ -3598,7 +3599,7 @@ struct value *
>  value_from_contents_and_address (struct type *type,
>  				 const gdb_byte *valaddr,
>  				 CORE_ADDR address,
> -				 frame_info_ptr frame)
> +				 const frame_info_ptr &frame)
>  {
>    gdb::array_view<const gdb_byte> view;
>    if (valaddr != nullptr)
> @@ -4070,7 +4071,7 @@ value::fetch_lazy ()
>  /* See value.h.  */
>  
>  value *
> -pseudo_from_raw_part (frame_info_ptr next_frame, int pseudo_reg_num,
> +pseudo_from_raw_part (const frame_info_ptr &next_frame, int pseudo_reg_num,
>  		      int raw_reg_num, int raw_offset)
>  {
>    value *pseudo_reg_val
> @@ -4084,7 +4085,7 @@ pseudo_from_raw_part (frame_info_ptr next_frame, int pseudo_reg_num,
>  /* See value.h.  */
>  
>  void
> -pseudo_to_raw_part (frame_info_ptr next_frame,
> +pseudo_to_raw_part (const frame_info_ptr &next_frame,
>  		    gdb::array_view<const gdb_byte> pseudo_buf,
>  		    int raw_reg_num, int raw_offset)
>  {
> @@ -4101,7 +4102,7 @@ pseudo_to_raw_part (frame_info_ptr next_frame,
>  /* See value.h.  */
>  
>  value *
> -pseudo_from_concat_raw (frame_info_ptr next_frame, int pseudo_reg_num,
> +pseudo_from_concat_raw (const frame_info_ptr &next_frame, int pseudo_reg_num,
>  			int raw_reg_1_num, int raw_reg_2_num)
>  {
>    value *pseudo_reg_val
> @@ -4126,7 +4127,7 @@ pseudo_from_concat_raw (frame_info_ptr next_frame, int pseudo_reg_num,
>  /* See value.h. */
>  
>  void
> -pseudo_to_concat_raw (frame_info_ptr next_frame,
> +pseudo_to_concat_raw (const frame_info_ptr &next_frame,
>  		      gdb::array_view<const gdb_byte> pseudo_buf,
>  		      int raw_reg_1_num, int raw_reg_2_num)
>  {
> @@ -4149,7 +4150,7 @@ pseudo_to_concat_raw (frame_info_ptr next_frame,
>  /* See value.h.  */
>  
>  value *
> -pseudo_from_concat_raw (frame_info_ptr next_frame, int pseudo_reg_num,
> +pseudo_from_concat_raw (const frame_info_ptr &next_frame, int pseudo_reg_num,
>  			int raw_reg_1_num, int raw_reg_2_num,
>  			int raw_reg_3_num)
>  {
> @@ -4180,7 +4181,7 @@ pseudo_from_concat_raw (frame_info_ptr next_frame, int pseudo_reg_num,
>  /* See value.h. */
>  
>  void
> -pseudo_to_concat_raw (frame_info_ptr next_frame,
> +pseudo_to_concat_raw (const frame_info_ptr &next_frame,
>  		      gdb::array_view<const gdb_byte> pseudo_buf,
>  		      int raw_reg_1_num, int raw_reg_2_num, int raw_reg_3_num)
>  {
> diff --git a/gdb/value.h b/gdb/value.h
> index c7d3866038ab..e8d3c9fd907a 100644
> --- a/gdb/value.h
> +++ b/gdb/value.h
> @@ -162,13 +162,14 @@ struct value
>    /* Allocate a lazy value representing register REGNUM in the frame previous
>       to NEXT_FRAME.  If TYPE is non-nullptr, use it as the value type.
>       Otherwise, use `register_type` to obtain the type.  */
> -  static struct value *allocate_register_lazy (frame_info_ptr next_frame,
> -					  int regnum, type *type = nullptr);
> +  static struct value *allocate_register_lazy (const frame_info_ptr &next_frame,
> +					       int regnum,
> +					       type *type = nullptr);
>  
>    /* Same as `allocate_register_lazy`, but make the value non-lazy.
>    
>       The caller is responsible for filling the value's contents.  */
> -  static struct value *allocate_register (frame_info_ptr next_frame,
> +  static struct value *allocate_register (const frame_info_ptr &next_frame,
>  					  int regnum, type *type = nullptr);
>  
>    /* Create a computed lvalue, with type TYPE, function pointers
> @@ -1110,7 +1111,7 @@ extern struct value *value_at (struct type *type, CORE_ADDR addr);
>     properties.  */
>  
>  extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr,
> -				    frame_info_ptr frame = nullptr);
> +				    const frame_info_ptr &frame = nullptr);
>  
>  /* Like value_at, but ensures that the result is marked not_lval.
>     This can be important if the memory is "volatile".  */
> @@ -1120,7 +1121,7 @@ extern struct value *value_from_contents_and_address_unresolved
>       (struct type *, const gdb_byte *, CORE_ADDR);
>  extern struct value *value_from_contents_and_address
>       (struct type *, const gdb_byte *, CORE_ADDR,
> -      frame_info_ptr frame = nullptr);
> +      const frame_info_ptr &frame = nullptr);
>  extern struct value *value_from_contents (struct type *, const gdb_byte *);
>  
>  extern value *default_value_from_register (gdbarch *gdbarch, type *type,
> @@ -1128,10 +1129,10 @@ extern value *default_value_from_register (gdbarch *gdbarch, type *type,
>  					   const frame_info_ptr &this_frame);
>  
>  extern struct value *value_from_register (struct type *type, int regnum,
> -					  frame_info_ptr frame);
> +					  const frame_info_ptr &frame);
>  
>  extern CORE_ADDR address_from_register (int regnum,
> -					frame_info_ptr frame);
> +					const frame_info_ptr &frame);
>  
>  extern struct value *value_of_variable (struct symbol *var,
>  					const struct block *b);
> @@ -1142,11 +1143,11 @@ extern struct value *address_of_variable (struct symbol *var,
>  /* Return a value with the contents of register REGNUM as found in the frame
>     previous to NEXT_FRAME.  */
>  
> -extern value *value_of_register (int regnum, frame_info_ptr next_frame);
> +extern value *value_of_register (int regnum, const frame_info_ptr &next_frame);
>  
>  /* Same as the above, but the value is not fetched.  */
>  
> -extern value *value_of_register_lazy (frame_info_ptr next_frame, int regnum);
> +extern value *value_of_register_lazy (const frame_info_ptr &next_frame, int regnum);
>  
>  /* Return the symbol's reading requirement.  */
>  
> @@ -1159,7 +1160,7 @@ extern int symbol_read_needs_frame (struct symbol *);
>  
>  extern struct value *read_var_value (struct symbol *var,
>  				     const struct block *var_block,
> -				     frame_info_ptr frame);
> +				     const frame_info_ptr &frame);
>  
>  extern struct value *allocate_repeat_value (struct type *type, int count);
>  
> @@ -1556,7 +1557,7 @@ extern int val_print_string (struct type *elttype, const char *encoding,
>  
>  extern void print_variable_and_value (const char *name,
>  				      struct symbol *var,
> -				      frame_info_ptr frame,
> +				      const frame_info_ptr &frame,
>  				      struct ui_file *stream,
>  				      int indent);
>  
> @@ -1667,13 +1668,13 @@ struct scoped_array_length_limiting
>     The size of the pseudo register specifies how many bytes to use.  The
>     offset plus the size must not overflow the raw register's size.  */
>  
> -value *pseudo_from_raw_part (frame_info_ptr next_frame, int pseudo_reg_num,
> +value *pseudo_from_raw_part (const frame_info_ptr &next_frame, int pseudo_reg_num,
>  			     int raw_reg_num, int raw_offset);
>  
>  /* Write PSEUDO_BUF, the contents of a pseudo register, to part of raw register
>     RAW_REG_NUM starting at RAW_OFFSET.  */
>  
> -void pseudo_to_raw_part (frame_info_ptr next_frame,
> +void pseudo_to_raw_part (const frame_info_ptr &next_frame,
>  			 gdb::array_view<const gdb_byte> pseudo_buf,
>  			 int raw_reg_num, int raw_offset);
>  
> @@ -1683,26 +1684,26 @@ void pseudo_to_raw_part (frame_info_ptr next_frame,
>     The sum of the sizes of raw registers must be equal to the size of the
>     pseudo register.  */
>  
> -value *pseudo_from_concat_raw (frame_info_ptr next_frame, int pseudo_reg_num,
> +value *pseudo_from_concat_raw (const frame_info_ptr &next_frame, int pseudo_reg_num,
>  			       int raw_reg_1_num, int raw_reg_2_num);
>  
>  /* Write PSEUDO_BUF, the contents of a pseudo register, to the two raw registers
>     RAW_REG_1_NUM and RAW_REG_2_NUM.  */
>  
> -void pseudo_to_concat_raw (frame_info_ptr next_frame,
> +void pseudo_to_concat_raw (const frame_info_ptr &next_frame,
>  			   gdb::array_view<const gdb_byte> pseudo_buf,
>  			   int raw_reg_1_num, int raw_reg_2_num);
>  
>  /* Same as the above, but with three raw registers.  */
>  
> -value *pseudo_from_concat_raw (frame_info_ptr next_frame, int pseudo_reg_num,
> +value *pseudo_from_concat_raw (const frame_info_ptr &next_frame, int pseudo_reg_num,
>  			       int raw_reg_1_num, int raw_reg_2_num,
>  			       int raw_reg_3_num);
>  
>  /* Write PSEUDO_BUF, the contents of a pseudo register, to the three raw
>     registers RAW_REG_1_NUM, RAW_REG_2_NUM and RAW_REG_3_NUM.  */
>  
> -void pseudo_to_concat_raw (frame_info_ptr next_frame,
> +void pseudo_to_concat_raw (const frame_info_ptr &next_frame,
>  			   gdb::array_view<const gdb_byte> pseudo_buf,
>  			   int raw_reg_1_num, int raw_reg_2_num,
>  			   int raw_reg_3_num);
> diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
> index 979dc1786e0a..125f3423be57 100644
> --- a/gdb/vax-tdep.c
> +++ b/gdb/vax-tdep.c
> @@ -187,7 +187,7 @@ vax_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
>  }
>  
>  static struct frame_id
> -vax_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +vax_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR fp;
>  
> @@ -303,7 +303,7 @@ struct vax_frame_cache
>  };
>  
>  static struct vax_frame_cache *
> -vax_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +vax_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct vax_frame_cache *cache;
>    CORE_ADDR addr;
> @@ -365,7 +365,7 @@ vax_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static void
> -vax_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +vax_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		   struct frame_id *this_id)
>  {
>    struct vax_frame_cache *cache = vax_frame_cache (this_frame, this_cache);
> @@ -378,7 +378,7 @@ vax_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -vax_frame_prev_register (frame_info_ptr this_frame,
> +vax_frame_prev_register (const frame_info_ptr &this_frame,
>  			 void **this_cache, int regnum)
>  {
>    struct vax_frame_cache *cache = vax_frame_cache (this_frame, this_cache);
> @@ -399,7 +399,7 @@ static const struct frame_unwind vax_frame_unwind =
>  \f
>  
>  static CORE_ADDR
> -vax_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +vax_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct vax_frame_cache *cache = vax_frame_cache (this_frame, this_cache);
>  
> @@ -407,7 +407,7 @@ vax_frame_base_address (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static CORE_ADDR
> -vax_frame_args_address (frame_info_ptr this_frame, void **this_cache)
> +vax_frame_args_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    return get_frame_register_unsigned (this_frame, VAX_AP_REGNUM);
>  }
> @@ -423,7 +423,7 @@ static const struct frame_base vax_frame_base =
>  /* Return number of arguments for FRAME.  */
>  
>  static int
> -vax_frame_num_args (frame_info_ptr frame)
> +vax_frame_num_args (const frame_info_ptr &frame)
>  {
>    CORE_ADDR args;
>  
> diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
> index b19c9491fd0f..16c6d41a961b 100644
> --- a/gdb/xstormy16-tdep.c
> +++ b/gdb/xstormy16-tdep.c
> @@ -306,7 +306,7 @@ static CORE_ADDR
>  xstormy16_analyze_prologue (struct gdbarch *gdbarch,
>  			    CORE_ADDR start_addr, CORE_ADDR end_addr,
>  			    struct xstormy16_frame_cache *cache,
> -			    frame_info_ptr this_frame)
> +			    const frame_info_ptr &this_frame)
>  {
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>    CORE_ADDR next_addr;
> @@ -581,7 +581,7 @@ xstormy16_find_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
>  }
>  
>  static CORE_ADDR
> -xstormy16_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
> +xstormy16_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (frame);
>    CORE_ADDR tmp = xstormy16_resolve_jmp_table_entry (gdbarch, pc);
> @@ -653,7 +653,7 @@ xstormy16_alloc_frame_cache (void)
>  }
>  
>  static struct xstormy16_frame_cache *
> -xstormy16_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +xstormy16_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    struct xstormy16_frame_cache *cache;
> @@ -689,7 +689,7 @@ xstormy16_frame_cache (frame_info_ptr this_frame, void **this_cache)
>  }
>  
>  static struct value *
> -xstormy16_frame_prev_register (frame_info_ptr this_frame, 
> +xstormy16_frame_prev_register (const frame_info_ptr &this_frame,

Trailing white space.

Thanks,
Andrew

>  			       void **this_cache, int regnum)
>  {
>    struct xstormy16_frame_cache *cache = xstormy16_frame_cache (this_frame,
> @@ -707,7 +707,7 @@ xstormy16_frame_prev_register (frame_info_ptr this_frame,
>  }
>  
>  static void
> -xstormy16_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +xstormy16_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  			 struct frame_id *this_id)
>  {
>    struct xstormy16_frame_cache *cache = xstormy16_frame_cache (this_frame,
> @@ -721,7 +721,7 @@ xstormy16_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static CORE_ADDR
> -xstormy16_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +xstormy16_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct xstormy16_frame_cache *cache = xstormy16_frame_cache (this_frame,
>  							       this_cache);
> diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
> index 2563d65f91e2..d116b34fd819 100644
> --- a/gdb/xtensa-tdep.c
> +++ b/gdb/xtensa-tdep.c
> @@ -1026,7 +1026,7 @@ xtensa_frame_align (struct gdbarch *gdbarch, CORE_ADDR address)
>  
>  
>  static CORE_ADDR
> -xtensa_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
> +xtensa_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
>  {
>    gdb_byte buf[8];
>    CORE_ADDR pc;
> @@ -1044,7 +1044,7 @@ xtensa_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
>  
>  
>  static struct frame_id
> -xtensa_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
> +xtensa_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
>  {
>    CORE_ADDR pc, fp;
>    xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
> @@ -1217,16 +1217,16 @@ xtensa_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR current_pc)
>  	cache->prev_sp = SP of the previous frame.  */
>  
>  static void
> -call0_frame_cache (frame_info_ptr this_frame,
> +call0_frame_cache (const frame_info_ptr &this_frame,
>  		   xtensa_frame_cache_t *cache, CORE_ADDR pc);
>  
>  static void
> -xtensa_window_interrupt_frame_cache (frame_info_ptr this_frame,
> +xtensa_window_interrupt_frame_cache (const frame_info_ptr &this_frame,
>  				     xtensa_frame_cache_t *cache,
>  				     CORE_ADDR pc);
>  
>  static struct xtensa_frame_cache *
> -xtensa_frame_cache (frame_info_ptr this_frame, void **this_cache)
> +xtensa_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    xtensa_frame_cache_t *cache;
>    CORE_ADDR ra, wb, ws, pc, sp, ps;
> @@ -1392,7 +1392,7 @@ This message will not be repeated in this session.\n"));
>  
>  
>  static void
> -xtensa_frame_this_id (frame_info_ptr this_frame,
> +xtensa_frame_this_id (const frame_info_ptr &this_frame,
>  		      void **this_cache,
>  		      struct frame_id *this_id)
>  {
> @@ -1406,7 +1406,7 @@ xtensa_frame_this_id (frame_info_ptr this_frame,
>  }
>  
>  static struct value *
> -xtensa_frame_prev_register (frame_info_ptr this_frame,
> +xtensa_frame_prev_register (const frame_info_ptr &this_frame,
>  			    void **this_cache,
>  			    int regnum)
>  {
> @@ -1509,7 +1509,7 @@ xtensa_unwind =
>  };
>  
>  static CORE_ADDR
> -xtensa_frame_base_address (frame_info_ptr this_frame, void **this_cache)
> +xtensa_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
>  {
>    struct xtensa_frame_cache *cache =
>      xtensa_frame_cache (this_frame, this_cache);
> @@ -2543,7 +2543,7 @@ call0_analyze_prologue (struct gdbarch *gdbarch,
>  /* Initialize frame cache for the current frame in CALL0 ABI.  */
>  
>  static void
> -call0_frame_cache (frame_info_ptr this_frame,
> +call0_frame_cache (const frame_info_ptr &this_frame,
>  		   xtensa_frame_cache_t *cache, CORE_ADDR pc)
>  {
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
> @@ -2892,7 +2892,7 @@ execute_code (struct gdbarch *gdbarch, CORE_ADDR current_pc, CORE_ADDR wb)
>  /* Handle Window Overflow / Underflow exception frames.  */
>  
>  static void
> -xtensa_window_interrupt_frame_cache (frame_info_ptr this_frame,
> +xtensa_window_interrupt_frame_cache (const frame_info_ptr &this_frame,
>  				     xtensa_frame_cache_t *cache,
>  				     CORE_ADDR pc)
>  {
> diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
> index f03eafdc6f72..f2d000f53030 100644
> --- a/gdb/z80-tdep.c
> +++ b/gdb/z80-tdep.c
> @@ -555,7 +555,7 @@ z80_return_value (struct gdbarch *gdbarch, struct value *function,
>  
>  /* function unwinds current stack frame and returns next one */
>  static struct z80_unwind_cache *
> -z80_frame_unwind_cache (frame_info_ptr this_frame,
> +z80_frame_unwind_cache (const frame_info_ptr &this_frame,
>  			void **this_prologue_cache)
>  {
>    CORE_ADDR start_pc, current_pc;
> @@ -658,7 +658,7 @@ z80_frame_unwind_cache (frame_info_ptr this_frame,
>  /* Given a GDB frame, determine the address of the calling function's
>     frame.  This will be used to create a new GDB frame struct.  */
>  static void
> -z80_frame_this_id (frame_info_ptr this_frame, void **this_cache,
> +z80_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
>  		   struct frame_id *this_id)
>  {
>    struct frame_id id;
> @@ -682,7 +682,7 @@ z80_frame_this_id (frame_info_ptr this_frame, void **this_cache,
>  }
>  
>  static struct value *
> -z80_frame_prev_register (frame_info_ptr this_frame,
> +z80_frame_prev_register (const frame_info_ptr &this_frame,
>  			 void **this_prologue_cache, int regnum)
>  {
>    struct z80_unwind_cache *info
>
> base-commit: b47cef7ca8a2fa55acdab367c87c1ea076aec4b2
> -- 
> 2.43.1


^ permalink raw reply	[relevance 0%]

* Re: [PATCH v3] gdb: Modify the output of "info breakpoints" and "delete breakpoints"
  @ 2024-02-19 19:54  0% ` Kevin Buettner
  0 siblings, 0 replies; 200+ results
From: Kevin Buettner @ 2024-02-19 19:54 UTC (permalink / raw)
  To: Tiezhu Yang; +Cc: gdb-patches, Tom Tromey, Guinevere Larsen

On Mon, 19 Feb 2024 15:52:30 +0800
Tiezhu Yang <yangtiezhu@loongson.cn> wrote:

> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 5f05657a8b3..8215290a13c 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -7080,9 +7080,9 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
>        if (!filter)
>  	{
>  	  if (bp_num_list == NULL || *bp_num_list == '\0')
> -	    uiout->message ("No breakpoints or watchpoints.\n");
> +	    uiout->message ("No breakpoints, watchpoints, tracepoints, or catchpoints.\n");

The GDB coding standard specifies an 80 column limit for all source
files except for .exp files.  Therefore, I suggest breaking the line
above as follows:

	    uiout->message ("No breakpoints, watchpoints, tracepoints, "
			    "or catchpoints.\n");

The coding standard can be found here:

https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards

>  	  else
> -	    uiout->message ("No breakpoint or watchpoint matching
> '%s'.\n",
> +	    uiout->message ("No breakpoint, watchpoint, tracepoint,
> or catchpoint matching '%s'.\n", bp_num_list);

Likewise, with respect to line length.

[...]
> @@ -12711,7 +12711,7 @@ delete_command (const char *arg, int from_tty)
>  
>        /* Ask user only if there are some breakpoints to delete.  */
>        if (!from_tty
> -	  || (breaks_to_delete && query (_("Delete all breakpoints? "))))
> +	  || (breaks_to_delete && query (_("Delete all breakpoints, watchpoints, tracepoints, and catchpoints? "))))

Likewise.  (For this one, you might also consider moving the '&&...'
portion to a new line.)

[...]
> @@ -14830,7 +14830,7 @@ This command may be abbreviated \"disable\"."),
>  Delete all or some breakpoints.\n\
>  Usage: delete [BREAKPOINTNUM]...\n\
>  Arguments are breakpoint numbers with spaces in between.\n\
> -To delete all breakpoints, give no argument.\n\
> +To delete all breakpoints, watchpoints, tracepoints, and catchpoints, give no argument.\n\

I think Eli mentioned this one in his review.  This line needs to be
split so that it's no longer than 80 characters.

>  \n\
>  Also a prefix command for deletion of other GDB objects."),
>  		      &deletelist, 1, &cmdlist);
> @@ -14841,7 +14841,7 @@ Also a prefix command for deletion of other GDB objects."),
>  Delete all or some breakpoints or auto-display expressions.\n\
>  Usage: delete breakpoints [BREAKPOINTNUM]...\n\
>  Arguments are breakpoint numbers with spaces in between.\n\
> -To delete all breakpoints, give no argument.\n\
> +To delete all breakpoints, watchpoints, tracepoints, and catchpoints, give no argument.\n\

Likewise.

> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo

I'm skipping the texinfo file since that's Eli's area...

[...]
> diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
> index 0adaa6dbed6..52057c25f89 100644
> --- a/gdb/ppc-linux-nat.c
> +++ b/gdb/ppc-linux-nat.c
> @@ -2358,7 +2358,7 @@ ppc_linux_nat_target::can_use_watchpoint_cond_accel (void)
>  
>    auto process_it = m_process_info.find (inferior_ptid.pid ());
>  
> -  /* No breakpoints or watchpoints have been requested for this process,
> +  /* No breakpoints, watchpoints, tracepoints, or catchpoints have been requested for this process,
>       we have at least one free DVC register.  */

Adjust this comment so that the it doesn't exceed the 80 column limit.

[...]
> diff --git a/gdb/testsuite/gdb.arch/i386-dr3-watch.exp b/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
> index e2c89b879ad..84b3806d234 100644
> --- a/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
> +++ b/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
> @@ -76,7 +76,7 @@ gdb_test_multiple "watch gap1" "$test" {
>  gdb_test "delete" \
>      "" \
>      "delete all watchpoints" \
> -    {Delete all breakpoints\? \(y or n\) $} \
> +    {Delete all breakpoints, watchpoints, tracepoints, and catchpoints\? \(y or n\) $} \

FYI, things like this are okay since they're in .exp files.  But if you see
a way to shorten it without making it less readable, I encourage you to do
so.

I won't comment on the other long lines in .exp files...

Kevin


^ permalink raw reply	[relevance 0%]

* [PATCH v2] gdbserver: Fix overflow detection in gdbserver
  @ 2024-02-19 14:19 16% ` Kirill Radkin
  0 siblings, 0 replies; 200+ results
From: Kirill Radkin @ 2024-02-19 14:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kirill Radkin

> I don't understand this early return.
> If using an unsigned type here is intended to be invalid, then I think
> that should be enforced at compile time.

Early return removed.

> However, it seems pretty simple to handle unsigned here as well.

Added.

Currently gdbserver uses require_int() function to
parse the requested offset (in vFile::pread
packet and the like). This function allows integers up to 0x7fffffff
(to fit in 32-bit int), however the offset (for pread
system call) has an off_t type which can be larger than
32-bit.

This patch allows require_int() function to parse offset
up to the maximum value implied by the off_t type.
---
 gdb/testsuite/gdb.server/pread-offset-size.S  | 23 +++++++++
 .../gdb.server/pread-offset-size.exp          | 50 +++++++++++++++++++
 gdbserver/hostio.cc                           | 17 +++++--
 3 files changed, 86 insertions(+), 4 deletions(-)
 create mode 100644 gdb/testsuite/gdb.server/pread-offset-size.S
 create mode 100644 gdb/testsuite/gdb.server/pread-offset-size.exp

diff --git a/gdb/testsuite/gdb.server/pread-offset-size.S b/gdb/testsuite/gdb.server/pread-offset-size.S
new file mode 100644
index 00000000000..b07058e5550
--- /dev/null
+++ b/gdb/testsuite/gdb.server/pread-offset-size.S
@@ -0,0 +1,23 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2023 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+	.text
+	.globl	_start
+_start:
+	.skip 3742415472
+	.globl	f
+f:
diff --git a/gdb/testsuite/gdb.server/pread-offset-size.exp b/gdb/testsuite/gdb.server/pread-offset-size.exp
new file mode 100644
index 00000000000..221491bfa04
--- /dev/null
+++ b/gdb/testsuite/gdb.server/pread-offset-size.exp
@@ -0,0 +1,50 @@
+# Copyright (C) 2023 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Test sending of large binary files (>2 GB) from gdbserver
+# (it was unavailable earlier)
+
+load_lib gdbserver-support.exp
+
+if {![allow_gdbserver_tests]} {
+    return
+}
+
+standard_testfile .S
+
+if { [prepare_for_testing ${testfile}.exp $testfile \
+      $srcfile {debug additional_flags=-nostdlib} ] } {
+    return -1
+}
+
+gdb_exit
+gdb_start
+
+gdb_test_no_output "set remote exec-file $binfile" \
+"set remote exec-file"
+
+# Make sure we're disconnected, in case we're testing with an
+# extended-remote board, therefore already connected.
+gdb_test "disconnect" ".*"
+
+set res [gdbserver_spawn ""]
+set gdbserver_protocol [lindex $res 0]
+set gdbserver_gdbport [lindex $res 1]
+
+gdb_test "target $gdbserver_protocol $gdbserver_gdbport" \
+"Remote debugging using .*" \
+"target $gdbserver_protocol $gdbserver_gdbport"
+
+gdb_test "break f" "Breakpoint 1.*"
diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc
index ea70c26da0f..fcee553c5a3 100644
--- a/gdbserver/hostio.cc
+++ b/gdbserver/hostio.cc
@@ -90,12 +90,18 @@ require_filename (char **pp, char *filename)
   return 0;
 }
 
+template <typename T>
 static int
-require_int (char **pp, int *value)
+require_int (char **pp, T *value)
 {
+  constexpr bool is_signed = std::is_signed<T>::value;
+
   char *p;
   int count, firstdigit;
 
+  /* Max count of hexadecimal digits in off_t (1 hex digit is 4 bits) */
+  int max_count = sizeof(T) * CHAR_BIT / 4;
+
   p = *pp;
   *value = 0;
   count = 0;
@@ -112,7 +118,8 @@ require_int (char **pp, int *value)
 	firstdigit = nib;
 
       /* Don't allow overflow.  */
-      if (count >= 8 || (count == 7 && firstdigit >= 0x8))
+      if (count >= max_count || (is_signed && count == (max_count - 1)
+				 && firstdigit >= 0x8))
 	return -1;
 
       *value = *value * 16 + nib;
@@ -344,7 +351,8 @@ handle_open (char *own_buf)
 static void
 handle_pread (char *own_buf, int *new_packet_len)
 {
-  int fd, ret, len, offset, bytes_sent;
+  int fd, ret, len, bytes_sent;
+  off_t offset;
   char *p, *data;
   static int max_reply_size = -1;
 
@@ -411,7 +419,8 @@ handle_pread (char *own_buf, int *new_packet_len)
 static void
 handle_pwrite (char *own_buf, int packet_len)
 {
-  int fd, ret, len, offset;
+  int fd, ret, len;
+  off_t offset;
   char *p, *data;
 
   p = own_buf + strlen ("vFile:pwrite:");
-- 
2.34.1


^ permalink raw reply	[relevance 16%]

* [PATCH 2/8] [gdb/dap] Factor out thread_log
  @ 2024-02-19  8:23  5% ` Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-02-19  8:23 UTC (permalink / raw)
  To: gdb-patches

In thread_wrapper I used a style where a message is prefixed with the thread
name.

Factor this out into a new function thread_log.

Also treat the GDB main thread special, because it's usual name is MainThread:
...
MainThread: <msg>
...
which is the default name assigned by python, so instead use the more
explicit:
...
GDB main: <msg>
...

Tested on aarch64-linux.
---
 gdb/python/lib/gdb/dap/startup.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/startup.py b/gdb/python/lib/gdb/dap/startup.py
index daaeb28e997..e68c5ba344e 100644
--- a/gdb/python/lib/gdb/dap/startup.py
+++ b/gdb/python/lib/gdb/dap/startup.py
@@ -64,7 +64,6 @@ def start_thread(name, target, args=()):
     correctly blocked."""
 
     def thread_wrapper(*args):
-        thread_name = threading.current_thread().name
         # Catch any exception, and log it.  If we let it escape here, it'll be
         # printed in gdb_stderr, which is not safe to access from anywhere but
         # gdb's main thread.
@@ -72,11 +71,11 @@ def start_thread(name, target, args=()):
             target(*args)
         except Exception as err:
             err_string = "%s, %s" % (err, type(err))
-            log(thread_name + ": caught exception: " + err_string)
+            thread_log("caught exception: " + err_string)
             log_stack()
         finally:
             # Log when a thread terminates.
-            log(thread_name + ": terminating")
+            thread_log("terminating")
 
     result = gdb.Thread(name=name, target=thread_wrapper, args=args, daemon=True)
     result.start()
@@ -174,6 +173,14 @@ def log(something, level=LogLevel.DEFAULT):
         dap_log.log_file.flush()
 
 
+def thread_log(something, level=LogLevel.DEFAULT):
+    if threading.current_thread() is _gdb_thread:
+        thread_name = "GDB main"
+    else:
+        thread_name = threading.current_thread().name
+    log(thread_name + ": " + something, level)
+
+
 def log_stack(level=LogLevel.DEFAULT):
     """Log a stack trace to the log file, if logging is enabled."""
     if dap_log.log_file is not None and level <= _log_level.value:
-- 
2.35.3


^ permalink raw reply	[relevance 5%]

* [PATCH 4/5] Rewrite "python" command exception handling
  @ 2024-02-16 18:37  5% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-02-16 18:37 UTC (permalink / raw)
  To: gdb-patches

The "python" command (and the Python implementation of the gdb
"source" command) does not handle Python exceptions in the same way as
other gdb-facing Python code.  In particular, exceptions are turned
into a generic error rather than being routed through
gdbpy_handle_exception, which takes care of converting to 'quit' as
appropriate.

I think this was done this way because PyRun_SimpleFile and friends do
not propagate the Python exception -- they simply indicate that one
occurred.

This patch reimplements these functions to respect the general gdb
convention here.  As a bonus, some Windows-specific code can be
removed, as can the _execute_file function.

The bulk of this change is tweaking the test suite to match the new
way that exceptions are displayed.  These changes are largely
uninteresting.  However, it's worth pointing out the py-error.exp
change.  Here, the failure changes because the test changes the host
charset to something that isn't supported by Python.  This then
results in a weird error in the new setup.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354
---
 gdb/python/lib/gdb/__init__.py                    |  27 ------
 gdb/python/python.c                               | 109 +++++++++-------------
 gdb/testsuite/gdb.ada/tasks.exp                   |   8 +-
 gdb/testsuite/gdb.python/py-arch.exp              |   2 +-
 gdb/testsuite/gdb.python/py-block.exp             |   4 +-
 gdb/testsuite/gdb.python/py-breakpoint.exp        |  18 ++--
 gdb/testsuite/gdb.python/py-connection.exp        |   8 +-
 gdb/testsuite/gdb.python/py-disasm.exp            |  32 +++----
 gdb/testsuite/gdb.python/py-error.exp             |   9 +-
 gdb/testsuite/gdb.python/py-finish-breakpoint.exp |   2 +-
 gdb/testsuite/gdb.python/py-format-address.exp    |  28 +++---
 gdb/testsuite/gdb.python/py-format-string.exp     |   8 +-
 gdb/testsuite/gdb.python/py-frame.exp             |  18 ++--
 gdb/testsuite/gdb.python/py-inferior.exp          |  24 ++---
 gdb/testsuite/gdb.python/py-lazy-string.exp       |   6 +-
 gdb/testsuite/gdb.python/py-mi-cmd.exp            |  40 ++++----
 gdb/testsuite/gdb.python/py-missing-debug.exp     |  16 ++--
 gdb/testsuite/gdb.python/py-objfile.exp           |   2 +-
 gdb/testsuite/gdb.python/py-parameter.exp         |  14 +--
 gdb/testsuite/gdb.python/py-pp-registration.exp   |   2 +-
 gdb/testsuite/gdb.python/py-progspace-events.exp  |   2 +-
 gdb/testsuite/gdb.python/py-progspace.exp         |   8 +-
 gdb/testsuite/gdb.python/py-record-btrace.exp     |   4 +-
 gdb/testsuite/gdb.python/py-record-full.exp       |   4 +-
 gdb/testsuite/gdb.python/py-template.exp          |   2 +-
 gdb/testsuite/gdb.python/py-thrhandle.exp         |   2 +-
 gdb/testsuite/gdb.python/py-type.exp              |  20 ++--
 gdb/testsuite/gdb.python/py-unwind.exp            |  24 ++---
 gdb/testsuite/gdb.python/py-value.exp             |  36 +++----
 gdb/testsuite/gdb.python/python.exp               |  10 +-
 gdb/testsuite/gdb.python/tui-window-names.exp     |  16 ++--
 gdb/testsuite/gdb.python/tui-window.exp           |   2 +-
 32 files changed, 233 insertions(+), 274 deletions(-)

diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
index ce8a6aae01e..cb3732e55f5 100644
--- a/gdb/python/lib/gdb/__init__.py
+++ b/gdb/python/lib/gdb/__init__.py
@@ -127,33 +127,6 @@ def _execute_unwinders(pending_frame):
     return None
 
 
-def _execute_file(filepath):
-    """This function is used to replace Python 2's PyRun_SimpleFile.
-
-    Loads and executes the given file.
-
-    We could use the runpy module, but its documentation says:
-    "Furthermore, any functions and classes defined by the executed code are
-    not guaranteed to work correctly after a runpy function has returned."
-    """
-    globals = sys.modules["__main__"].__dict__
-    set_file = False
-    # Set file (if not set) so that the imported file can use it (e.g. to
-    # access file-relative paths). This matches what PyRun_SimpleFile does.
-    if not hasattr(globals, "__file__"):
-        globals["__file__"] = filepath
-        set_file = True
-    try:
-        with open(filepath, "rb") as file:
-            # We pass globals also as locals to match what Python does
-            # in PyRun_SimpleFile.
-            compiled = compile(file.read(), filepath, "exec")
-            exec(compiled, globals, globals)
-    finally:
-        if set_file:
-            del globals["__file__"]
-
-
 # Convenience variable to GDB's python directory
 PYTHONDIR = os.path.dirname(os.path.dirname(__file__))
 
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 09b1029e0b7..c41a7b6cbc4 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -284,12 +284,14 @@ gdbpy_check_quit_flag (const struct extension_language_defn *extlang)
   return PyOS_InterruptOccurred ();
 }
 
-/* Evaluate a Python command like PyRun_SimpleString, but uses
-   Py_single_input which prints the result of expressions, and does
-   not automatically print the stack on errors.  */
+/* Evaluate a Python command like PyRun_SimpleString, but takes a
+   Python start symbol, and does not automatically print the stack on
+   errors.  FILENAME is used to set the file name in error
+   messages.  */
 
 static int
-eval_python_command (const char *command)
+eval_python_command (const char *command, int start_symbol,
+		     const char *filename = "<string>")
 {
   PyObject *m, *d;
 
@@ -300,8 +302,15 @@ eval_python_command (const char *command)
   d = PyModule_GetDict (m);
   if (d == NULL)
     return -1;
-  gdbpy_ref<> v (PyRun_StringFlags (command, Py_single_input, d, d, NULL));
-  if (v == NULL)
+
+  /* Use this API because it is in Python 3.2.  */
+  gdbpy_ref<> code (Py_CompileStringExFlags (command, filename, start_symbol,
+					     nullptr, -1));
+  if (code == nullptr)
+    return -1;
+
+  gdbpy_ref<> result (PyEval_EvalCode (code.get (), d, d));
+  if (result == nullptr)
     return -1;
 
   return 0;
@@ -324,7 +333,8 @@ python_interactive_command (const char *arg, int from_tty)
   if (arg && *arg)
     {
       std::string script = std::string (arg) + "\n";
-      err = eval_python_command (script.c_str ());
+      /* Py_single_input causes the result to be displayed.  */
+      err = eval_python_command (script.c_str (), Py_single_input);
     }
   else
     {
@@ -333,14 +343,12 @@ python_interactive_command (const char *arg, int from_tty)
     }
 
   if (err)
-    {
-      gdbpy_print_stack ();
-      error (_("Error while executing Python code."));
-    }
+    gdbpy_handle_exception ();
 }
 
-/* A wrapper around PyRun_SimpleFile.  FILE is the Python script to run
-   named FILENAME.
+/* Like PyRun_SimpleFile, but if there is an exception, it is not
+   automatically displayed.  FILE is the Python script to run named
+   FILENAME.
 
    On Windows hosts few users would build Python themselves (this is no
    trivial task on this platform), and thus use binaries built by
@@ -349,39 +357,13 @@ python_interactive_command (const char *arg, int from_tty)
    library.  Python, being built with VC, would use one version of the
    msvcr DLL (Eg. msvcr100.dll), while MinGW uses msvcrt.dll.
    A FILE * from one runtime does not necessarily operate correctly in
-   the other runtime.
+   the other runtime.  */
 
-   To work around this potential issue, we run code in Python to load
-   the script.  */
-
-static void
+static int
 python_run_simple_file (FILE *file, const char *filename)
 {
-#ifndef _WIN32
-
-  PyRun_SimpleFile (file, filename);
-
-#else /* _WIN32 */
-
-  /* Because we have a string for a filename, and are using Python to
-     open the file, we need to expand any tilde in the path first.  */
-  gdb::unique_xmalloc_ptr<char> full_path (tilde_expand (filename));
-
-  if (gdb_python_module == nullptr
-      || ! PyObject_HasAttrString (gdb_python_module, "_execute_file"))
-    error (_("Installation error: gdb._execute_file function is missing"));
-
-  gdbpy_ref<> return_value
-    (PyObject_CallMethod (gdb_python_module, "_execute_file", "s",
-			  full_path.get ()));
-  if (return_value == nullptr)
-    {
-      /* Use PyErr_PrintEx instead of gdbpy_print_stack to better match the
-	 behavior of the non-Windows codepath.  */
-      PyErr_PrintEx(0);
-    }
-
-#endif /* _WIN32 */
+  std::string contents = read_text_file_to_string (file);
+  return eval_python_command (contents.c_str (), Py_file_input, filename);
 }
 
 /* Given a command_line, return a command string suitable for passing
@@ -408,17 +390,15 @@ static void
 gdbpy_eval_from_control_command (const struct extension_language_defn *extlang,
 				 struct command_line *cmd)
 {
-  int ret;
-
   if (cmd->body_list_1 != nullptr)
     error (_("Invalid \"python\" block structure."));
 
   gdbpy_enter enter_py;
 
   std::string script = compute_python_string (cmd->body_list_0.get ());
-  ret = PyRun_SimpleString (script.c_str ());
-  if (ret)
-    error (_("Error while executing Python code."));
+  int ret = eval_python_command (script.c_str (), Py_file_input);
+  if (ret != 0)
+    gdbpy_handle_exception ();
 }
 
 /* Implementation of the gdb "python" command.  */
@@ -433,8 +413,9 @@ python_command (const char *arg, int from_tty)
   arg = skip_spaces (arg);
   if (arg && *arg)
     {
-      if (PyRun_SimpleString (arg))
-	error (_("Error while executing Python code."));
+      int ret = eval_python_command (arg, Py_file_input);
+      if (ret != 0)
+	gdbpy_handle_exception ();
     }
   else
     {
@@ -1021,7 +1002,9 @@ gdbpy_source_script (const struct extension_language_defn *extlang,
 		     FILE *file, const char *filename)
 {
   gdbpy_enter enter_py;
-  python_run_simple_file (file, filename);
+  int result = python_run_simple_file (file, filename);
+  if (result != 0)
+    gdbpy_handle_exception ();
 }
 
 \f
@@ -1653,7 +1636,9 @@ gdbpy_source_objfile_script (const struct extension_language_defn *extlang,
   scoped_restore restire_current_objfile
     = make_scoped_restore (&gdbpy_current_objfile, objfile);
 
-  python_run_simple_file (file, filename);
+  int result = python_run_simple_file (file, filename);
+  if (result != 0)
+    gdbpy_print_stack ();
 }
 
 /* Set the current objfile to OBJFILE and then execute SCRIPT
@@ -1674,7 +1659,9 @@ gdbpy_execute_objfile_script (const struct extension_language_defn *extlang,
   scoped_restore restire_current_objfile
     = make_scoped_restore (&gdbpy_current_objfile, objfile);
 
-  PyRun_SimpleString (script);
+  int ret = eval_python_command (script, Py_file_input);
+  if (ret != 0)
+    gdbpy_print_stack ();
 }
 
 /* Return the current Objfile, or None if there isn't one.  */
@@ -2332,21 +2319,15 @@ test_python ()
       {
 	CMD (output);
       }
-    catch (const gdb_exception &e)
+    catch (const gdb_exception_quit &e)
       {
 	saw_exception = true;
-	SELF_CHECK (e.reason == RETURN_ERROR);
-	SELF_CHECK (e.error == GENERIC_ERROR);
-	SELF_CHECK (*e.message == "Error while executing Python code.");
+	SELF_CHECK (e.reason == RETURN_QUIT);
+	SELF_CHECK (e.error == GDB_NO_ERROR);
+	SELF_CHECK (*e.message == "Quit");
       }
     SELF_CHECK (saw_exception);
-    std::string ref_output_0 ("Traceback (most recent call last):\n"
-			      "  File \"<string>\", line 0, in <module>\n"
-			      "KeyboardInterrupt\n");
-    std::string ref_output_1 ("Traceback (most recent call last):\n"
-			      "  File \"<string>\", line 1, in <module>\n"
-			      "KeyboardInterrupt\n");
-    SELF_CHECK (output == ref_output_0 || output == ref_output_1);
+    SELF_CHECK (output.empty ());
   }
 
 #undef CMD
diff --git a/gdb/testsuite/gdb.ada/tasks.exp b/gdb/testsuite/gdb.ada/tasks.exp
index dd03a2e4a96..6e588408c9d 100644
--- a/gdb/testsuite/gdb.ada/tasks.exp
+++ b/gdb/testsuite/gdb.ada/tasks.exp
@@ -98,15 +98,15 @@ if {[allow_python_tests]} {
     gdb_test "python print(bp.thread)" "None"
     gdb_test "python bp.thread = 1" \
 	[multi_line \
-	     "RuntimeError: Cannot set both task and thread attributes\\." \
-	     "Error while executing Python code\\."] \
+	     "RuntimeError.*: Cannot set both task and thread attributes\\." \
+	     "Error occurred in Python.*"] \
 	"try setting the thread, but expect an error"
     gdb_test_no_output "python bp.task = None"
     gdb_test_no_output "python bp.thread = 1"
     gdb_test "python bp.task = 3" \
 	[multi_line \
-	     "RuntimeError: Cannot set both task and thread attributes\\." \
-	     "Error while executing Python code\\."] \
+	     "RuntimeError.*: Cannot set both task and thread attributes\\." \
+	     "Error occurred in Python.*"] \
 	"try setting the task, but expect an error"
 
     # Reset the breakpoint to the state required for the rest of this
diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp
index 1b0759a657d..3c58bf1281f 100644
--- a/gdb/testsuite/gdb.python/py-arch.exp
+++ b/gdb/testsuite/gdb.python/py-arch.exp
@@ -91,7 +91,7 @@ foreach size {0 1 2 3 4 8 16} {
 }
 
 gdb_test "python arch.integer_type(95)" \
-    ".*ValueError: no integer type of that size is available.*" \
+    ".*ValueError.* no integer type of that size is available.*" \
     "call integer_type with invalid size"
 
 # Test for gdb.architecture_names().  First we're going to grab the
diff --git a/gdb/testsuite/gdb.python/py-block.exp b/gdb/testsuite/gdb.python/py-block.exp
index 5e8fba43ea0..942611af305 100644
--- a/gdb/testsuite/gdb.python/py-block.exp
+++ b/gdb/testsuite/gdb.python/py-block.exp
@@ -44,9 +44,9 @@ gdb_test "python print (block.function)" "None" "first anonymous block"
 gdb_test "python print (block.start)" "${decimal}" "check start not None"
 gdb_test "python print (block.end)" "${decimal}" "check end not None"
 gdb_test "python print (block\['f'\].name == 'f')" "True" "check variable access"
-gdb_test "python print (block\['nonexistent'\])" ".*KeyError: 'nonexistent'.*" \
+gdb_test "python print (block\['nonexistent'\])" ".*KeyError.*: nonexistent.*" \
          "check nonexistent variable"
-gdb_test "python print (block\[42\])" ".*TypeError: Expected a string.*" \
+gdb_test "python print (block\[42\])" ".*TypeError.*: Expected a string.*" \
          "check non-string key"
 
 # Test global/static blocks
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
index 67da48d2f48..1d0e96a15dd 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -190,7 +190,7 @@ proc_with_prefix test_bkpt_deletion { } {
     gdb_py_test_silent_cmd  "python dp1.delete()" \
 	"Delete Breakpoint" 0
     gdb_test "python print (dp1.number)" \
-	"RuntimeError: Breakpoint 2 is invalid.*" \
+	"RuntimeError.*: Breakpoint 2 is invalid.*" \
 	"Check breakpoint invalidated"
     gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" \
 	"Get Breakpoint List" 0
@@ -275,7 +275,7 @@ proc_with_prefix test_bkpt_thread_and_inferior { } {
 	gdb_test "python print(bp.thread)" "1"
 	gdb_test "python print(bp.inferior)" "None"
 	gdb_test "python bp.inferior = 1" \
-	    "RuntimeError: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*"
+	    "RuntimeError.*: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*"
 	gdb_test_no_output "python bp.thread = None"
 	gdb_test_no_output "python bp.inferior = 1" \
 	    "set the inferior now the thread has been cleared"
@@ -289,7 +289,7 @@ proc_with_prefix test_bkpt_thread_and_inferior { } {
 	gdb_test "python print(bp.thread)" "None"
 	gdb_test "python print(bp.inferior)" "1"
 	gdb_test "python bp.thread = 1" \
-	    "RuntimeError: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*"
+	    "RuntimeError.*: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*"
 	gdb_test_no_output "python bp.inferior = None"
 	gdb_test_no_output "python bp.thread = 1" \
 	    "set the thread now the inferior has been cleared"
@@ -522,7 +522,7 @@ proc_with_prefix test_bkpt_eval_funcs { } {
 	"end" ""
 
     gdb_test "python eval_bp2.stop = stop_func"  \
-	"RuntimeError: Only one stop condition allowed.  There is currently a GDB.*" \
+	"RuntimeError.*: Only one stop condition allowed.  There is currently a GDB.*" \
 	"assign stop function to a breakpoint that has a condition"
 
     delete_breakpoints
@@ -589,7 +589,7 @@ proc_with_prefix test_bkpt_temporary { } {
 	".*$srcfile:$ibp_location.*"
     gdb_test "python print (ibp.count)" "1" \
 	"Check temporary stop callback executed before deletion."
-    gdb_test "python print (ibp.temporary)" "RuntimeError: Breakpoint 2 is invalid.*" \
+    gdb_test "python print (ibp.temporary)" "RuntimeError.*: Breakpoint 2 is invalid.*" \
 	"Check temporary breakpoint is deleted after being hit"
     gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
 	"Check info breakpoints shows temporary breakpoint is deleted"
@@ -707,7 +707,7 @@ proc_with_prefix test_bkpt_explicit_loc {} {
 
     delete_breakpoints
     gdb_test "python bp1 = gdb.Breakpoint (line=bp1)" \
-	"RuntimeError: Line keyword should be an integer or a string.*" \
+	"RuntimeError.*: Line keyword should be an integer or a string.*" \
 	"set explicit breakpoint by invalid line type"
 
     delete_breakpoints
@@ -736,7 +736,7 @@ proc_with_prefix test_bkpt_explicit_loc {} {
 
     delete_breakpoints
     gdb_test "python bp1 = gdb.Breakpoint (source=\"$srcfile\")" \
-	"RuntimeError: Specifying a source must also include a line, label or function.*" \
+	"RuntimeError.*: Specifying a source must also include a line, label or function.*" \
 	"set invalid explicit breakpoint by source only"
 
     gdb_test "python bp1 = gdb.Breakpoint (source=\"foo.c\", line=\"5\")" \
@@ -859,8 +859,8 @@ proc_with_prefix test_catchpoints {} {
     # the python api.
     gdb_test "python gdb.Breakpoint (\"syscall\", type=gdb.BP_CATCHPOINT)" \
 	[multi_line \
-	     "gdb.error: BP_CATCHPOINT not supported" \
-	     "Error while executing Python code\\."] \
+	     "gdb.error.*: BP_CATCHPOINT not supported" \
+	     "Error occurred in Python:.*"] \
 	"create a catchpoint via the api"
 
     # Setup a catchpoint.
diff --git a/gdb/testsuite/gdb.python/py-connection.exp b/gdb/testsuite/gdb.python/py-connection.exp
index fa995f19d3d..ca78b37c4f1 100644
--- a/gdb/testsuite/gdb.python/py-connection.exp
+++ b/gdb/testsuite/gdb.python/py-connection.exp
@@ -65,10 +65,10 @@ gdb_test "python print(conn.is_valid())" "False" "is_valid returns False"
 # Now check that accessing properties of the invalid connection cases
 # an error.
 gdb_test "python print(conn.num)" \
-    "RuntimeError: Connection no longer exists\\.\r\n.*"
+    "RuntimeError.*: Connection no longer exists\\.\r\n.*"
 gdb_test "python print(conn.type)" \
-    "RuntimeError: Connection no longer exists\\.\r\n.*"
+    "RuntimeError.*: Connection no longer exists\\.\r\n.*"
 gdb_test "python print(conn.description)" \
-    "RuntimeError: Connection no longer exists\\.\r\n.*"
+    "RuntimeError.*: Connection no longer exists\\.\r\n.*"
 gdb_test "python print(conn.details)" \
-    "RuntimeError: Connection no longer exists\\.\r\n.*"
+    "RuntimeError.*: Connection no longer exists\\.\r\n.*"
diff --git a/gdb/testsuite/gdb.python/py-disasm.exp b/gdb/testsuite/gdb.python/py-disasm.exp
index 0458b33c5a9..7c6f972a7e7 100644
--- a/gdb/testsuite/gdb.python/py-disasm.exp
+++ b/gdb/testsuite/gdb.python/py-disasm.exp
@@ -164,16 +164,16 @@ foreach plan $test_plans {
 with_test_prefix "DisassemblerResult errors" {
     gdb_test "python gdb.disassembler.DisassemblerResult(0, 'abc')" \
 	[multi_line \
-	     "ValueError: Length must be greater than 0." \
-	     "Error while executing Python code."]
+	     "ValueError.*: Length must be greater than 0." \
+	     "Error occurred in Python.*"]
     gdb_test "python gdb.disassembler.DisassemblerResult(-1, 'abc')" \
 	[multi_line \
-	     "ValueError: Length must be greater than 0." \
-	     "Error while executing Python code."]
+	     "ValueError.*: Length must be greater than 0." \
+	     "Error occurred in Python.*"]
     gdb_test "python gdb.disassembler.DisassemblerResult(1, '')" \
 	[multi_line \
-	     "ValueError: String must not be empty." \
-	     "Error while executing Python code."]
+	     "ValueError.*: String must not be empty.*" \
+	     "Error occurred in Python.*"]
 }
 
 # Check that the architecture specific disassemblers can override the
@@ -255,8 +255,8 @@ with_test_prefix "Bad DisassembleInfo creation" {
     gdb_test "python print(my_info.is_valid())" "True"
     gdb_test "python gdb.disassembler.builtin_disassemble(my_info)" \
 	[multi_line \
-	     "RuntimeError: DisassembleInfo is no longer valid\\." \
-	     "Error while executing Python code\\."]
+	     "RuntimeError.*: DisassembleInfo is no longer valid\\." \
+	     "Error occurred in Python.*"]
 }
 
 # Some of the disassembler related types should not be sub-typed,
@@ -274,8 +274,8 @@ with_test_prefix "check inheritance" {
 	    "     pass" "" \
 	    "end" \
 	    [multi_line \
-		 "TypeError: type '${type_ptn}' is not an acceptable base type" \
-		 "Error while executing Python code\\."]
+		 "TypeError.*: type '${type_ptn}' is not an acceptable base type" \
+		 "Error occurred in Python.*"]
     }
 }
 
@@ -283,15 +283,15 @@ with_test_prefix "check inheritance" {
 # Test some error conditions when creating a DisassemblerResult object.
 gdb_test "python result = gdb.disassembler.DisassemblerResult()" \
     [multi_line \
-	 "TypeError: [missing_arg_pattern length 1]" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: [missing_arg_pattern length 1]" \
+	 "Error occurred in Python.*"] \
     "try to create a DisassemblerResult without a length argument"
 
 foreach len {0 -1} {
     gdb_test "python result = gdb.disassembler.DisassemblerResult($len)" \
 	[multi_line \
-	     "ValueError: Length must be greater than 0\\." \
-	     "Error while executing Python code\\."] \
+	     "ValueError.*: Length must be greater than 0\\." \
+	     "Error occurred in Python.*"] \
 	"try to create a DisassemblerResult with length $len"
 }
 
@@ -300,7 +300,7 @@ foreach len {0 -1} {
 foreach type {DisassemblerTextPart DisassemblerAddressPart} {
     gdb_test "python result = gdb.disassembler.${type}()" \
 	[multi_line \
-	     "RuntimeError: Cannot create instances of DisassemblerPart\\." \
-	     "Error while executing Python code\\."] \
+	     "RuntimeError.*: Cannot create instances of DisassemblerPart\\." \
+	     "Error occurred in Python.*"] \
 	 "try to create an instance of ${type}"
 }
diff --git a/gdb/testsuite/gdb.python/py-error.exp b/gdb/testsuite/gdb.python/py-error.exp
index 58e8549453f..6eb9cc3d659 100644
--- a/gdb/testsuite/gdb.python/py-error.exp
+++ b/gdb/testsuite/gdb.python/py-error.exp
@@ -50,7 +50,12 @@ if {$test2 == ""} {
 set remote_python_file [gdb_remote_download host \
 			    ${srcdir}/${subdir}/${testfile}.py]
 
-# argc=LookupError: unknown encoding: IBM1047
-gdb_test "source $remote_python_file" "Traceback.*ClassName.*\r\nLookupError: unknown encoding: $charset" $test2
+# With the new way that "source" works, it isn't really possible for
+# this to fail "correctly".  Converting the filename to a Python
+# unicode object will fail -- and, mysteriously, without setting a
+# real exception.
+gdb_test "source $remote_python_file" \
+    "An error occurred in Python.*" \
+    $test2
 
 gdb_test "p 1" " = 1" "no delayed error"
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
index 6b72ddb2186..c2a85b1237c 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
@@ -85,7 +85,7 @@ with_test_prefix "normal conditions" {
 
     gdb_test "finish" "main.*" "return to main()"
     gdb_test "python MyFinishBreakpoint (None, gdb.selected_frame ())" \
-	"ValueError: \"FinishBreakpoint\" not meaningful in the outermost frame..*" \
+	"ValueError.*: \"FinishBreakpoint\" not meaningful in the outermost frame..*" \
 	"check FinishBP not allowed in main"
 }
 
diff --git a/gdb/testsuite/gdb.python/py-format-address.exp b/gdb/testsuite/gdb.python/py-format-address.exp
index 06654d98954..8e7cf47e03a 100644
--- a/gdb/testsuite/gdb.python/py-format-address.exp
+++ b/gdb/testsuite/gdb.python/py-format-address.exp
@@ -84,27 +84,27 @@ gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, None, None))"
 # Now forget the architecture, this should fail.
 gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, inf.progspace))" \
     [multi_line \
-	 "ValueError: The architecture and progspace arguments must both be supplied" \
-	 "Error while executing Python code\\."] \
+	 "ValueError.*: The architecture and progspace arguments must both be supplied" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address passing program space only"
 
 gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, inf.progspace, None))" \
     [multi_line \
-	 "ValueError: The architecture and progspace arguments must both be supplied" \
-	 "Error while executing Python code\\."] \
+	 "ValueError.*: The architecture and progspace arguments must both be supplied" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address passing real program space, but architecture is None"
 
 # Now skip the program space argument.
 gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, architecture=inf.architecture()))" \
     [multi_line \
-	 "ValueError: The architecture and progspace arguments must both be supplied" \
-	 "Error while executing Python code\\."] \
+	 "ValueError.*: The architecture and progspace arguments must both be supplied" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address passing architecture only"
 
 gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, None, inf.architecture()))" \
     [multi_line \
-	 "ValueError: The architecture and progspace arguments must both be supplied" \
-	 "Error while executing Python code\\."] \
+	 "ValueError.*: The architecture and progspace arguments must both be supplied" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address passing real architecture, but progspace is None"
 
 # Now, before we add a second inferior, lets just check we can format
@@ -155,14 +155,14 @@ gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, inf2.progspace,
 # Try pasing incorrect object types for program space and architecture.
 gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, inf2.progspace, inf2.progspace))" \
     [multi_line \
-	 "TypeError: The architecture argument is not a gdb.Architecture object" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: The architecture argument is not a gdb.Architecture object" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address pass wrong object type for architecture"
 
 gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, inf2.architecture(), inf2.architecture()))" \
     [multi_line \
-	 "TypeError: The progspace argument is not a gdb.Progspace object" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: The progspace argument is not a gdb.Progspace object" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address pass wrong object type for progspace"
 
 # Now invalidate inferior 2's program space, and try using that.
@@ -171,6 +171,6 @@ gdb_test "python arch = inf2.architecture()"
 gdb_test "remove-inferior 2"
 gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, pspace, arch))" \
     [multi_line \
-	 "ValueError: The progspace argument is not valid" \
-	 "Error while executing Python code\\."] \
+	 "ValueError.*: The progspace argument is not valid" \
+	 "Error occurred in Python.*"] \
     "gdb.format_address called with an invalid program space"
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index cd434b8fd4b..0c70ad562c7 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -1102,22 +1102,22 @@ proc_with_prefix test_invalid_args {} {
   check_format_string \
     "a_point_t" \
     "12" \
-    "TypeError: format_string\\(\\) takes 0 positional arguments but 1 were given.*"
+    "TypeError.*: format_string\\(\\) takes 0 positional arguments but 1 were given.*"
 
   check_format_string \
     "a_point_t" \
     "invalid=True" \
-    "TypeError: 'invalid' is an invalid keyword argument for this function.*"
+    "TypeError.*: 'invalid' is an invalid keyword argument for this function.*"
 
   check_format_string \
     "a_point_t" \
     "raw='hello'" \
-    "TypeError: argument 1 must be bool, not str.*"
+    "TypeError.*: argument 1 must be bool, not str.*"
 
   check_format_string \
     "a_point_t" \
     "format='xd'" \
-    "ValueError: a single character is required.*"
+    "ValueError.*: a single character is required.*"
 }
 
 # Check the styling argument to format_string.  This function needs to
diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp
index 110ddf24480..8f776eb08a5 100644
--- a/gdb/testsuite/gdb.python/py-frame.exp
+++ b/gdb/testsuite/gdb.python/py-frame.exp
@@ -77,25 +77,25 @@ gdb_test "python print (bf1.read_var(\"i\", sb).type)" "int" "test int i"
 # Test what happens when we provide a block of the wrong type.
 gdb_test "python print (bf1.read_var(\"i\", \"some_block\"))" \
     [multi_line \
-	 "TypeError: argument 2 must be gdb\\.Block, not str" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: argument 2 must be gdb\\.Block, not str" \
+	 "Error occurred in Python.*"] \
     "check invalid block type error"
 gdb_test "python print (bf1.read_var(block = \"some_block\", variable = \"i\"))" \
     [multi_line \
-	 "TypeError: argument 2 must be gdb\\.Block, not str" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: argument 2 must be gdb\\.Block, not str" \
+	 "Error occurred in Python.*"] \
     "check invalid block type error when named args are used"
 
 # Test what happens when we provide a variable of the wrong type.
 gdb_test "python print (bf1.read_var(None))" \
     [multi_line \
-	 "TypeError: argument 1 must be gdb\\.Symbol or str, not NoneType" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: argument 1 must be gdb\\.Symbol or str, not NoneType" \
+	 "Error occurred in Python.*"] \
     "check read_var error when variable is None"
 gdb_test "python print (bf1.read_var(sb))" \
     [multi_line \
-	 "TypeError: argument 1 must be gdb\\.Symbol or str, not gdb\\.Block" \
-	 "Error while executing Python code\\."] \
+	 "TypeError.*: argument 1 must be gdb\\.Symbol or str, not gdb\\.Block" \
+	 "Error occurred in Python.*"] \
     "check read_var error when variable is a gdb.Block"
 
 gdb_breakpoint "f2"
@@ -141,7 +141,7 @@ gdb_test "python print ('result = %s' % f0.pc ())" " = \[0-9\]+" "test Frame.pc"
 gdb_test "python print ('result = %s' % (f0.older () == f1))" " = True" "test Frame.older"
 gdb_test "python print ('result = %s' % (f1.newer () == f0))" " = True" "test Frame.newer"
 gdb_test "python print ('result = %s' % f0.read_var ('variable_which_surely_doesnt_exist'))" \
-  "ValueError: Variable 'variable_which_surely_doesnt_exist' not found.*Error while executing Python code." \
+  "ValueError.*: Variable 'variable_which_surely_doesnt_exist' not found.*Error occurred in Python.*" \
   "test Frame.read_var - error"
 gdb_test "python print ('result = %s' % f0.read_var ('a'))" " = 1" "test Frame.read_var - success"
 
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index 2968e027812..c14f2d2796c 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -122,8 +122,8 @@ gdb_test "python print(worker_thread._user_attribute)" "123" \
     "read back user defined attribute"
 gdb_test "python print(main_thread._user_attribute)" \
     [multi_line \
-	 "AttributeError: 'gdb\\.InferiorThread' object has no attribute '_user_attribute'" \
-	 "Error while executing Python code\\."] \
+	 "AttributeError.*: 'gdb\\.InferiorThread' object has no attribute '_user_attribute'" \
+	 "Error occurred in Python.*"] \
     "attempt to read non-existent user defined attribute"
 
 # Proceed to the next test.
@@ -162,8 +162,8 @@ set num [add_inferior]
 # but that the first inferior does still have the attribute.
 gdb_test "python print(gdb.inferiors()\[1\]._user_attr)" \
     [multi_line \
-	 "AttributeError: 'gdb\\.Inferior' object has no attribute '_user_attr'" \
-	 "Error while executing Python code\\."] \
+	 "AttributeError.*: 'gdb\\.Inferior' object has no attribute '_user_attr'" \
+	 "Error occurred in Python.*"] \
     "check new inferior doesn't have user defined attribute"
 gdb_test "python print(gdb.inferiors()\[0\]._user_attr)" \
     "123" "read back user defined attribute again"
@@ -366,21 +366,21 @@ with_test_prefix "is_valid" {
     # Test that other properties and methods handle the removed inferior
     # correctly.
     gdb_test "python print (inf_list\[1\].num)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].connection_num)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].connection)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].pid)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].was_attached)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].progspace)" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].threads ())" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
     gdb_test "python print (inf_list\[1\].thread_from_thread_handle (1))" \
-	"RuntimeError: Inferior no longer exists.*"
+	"RuntimeError.*: Inferior no longer exists.*"
 }
 
 # Test gdb.selected_inferior()
diff --git a/gdb/testsuite/gdb.python/py-lazy-string.exp b/gdb/testsuite/gdb.python/py-lazy-string.exp
index 8e7eca846b0..a00f47b1e2a 100644
--- a/gdb/testsuite/gdb.python/py-lazy-string.exp
+++ b/gdb/testsuite/gdb.python/py-lazy-string.exp
@@ -40,13 +40,13 @@ gdb_test "python print (nullstr.length)" "0" "null lazy string length"
 gdb_test "python print (nullstr.address)" "0" "null lazy string address"
 gdb_test "python print (nullstr.type)" "const char \\*" "null lazy string type"
 gdb_test "python print(nullstr.value())" \
-    "gdb.MemoryError: Cannot create a value from NULL.*Error while executing Python code." \
+    "gdb.MemoryError.*: Cannot create a value from NULL.*Error occurred in Python.*" \
     "create value from NULL"
 gdb_test "python print(null.lazy_string(length=3).value())" \
-    "gdb.MemoryError: Cannot create a lazy string with address 0x0, and a non-zero length.*Error while executing Python code." \
+    "gdb.MemoryError.*: Cannot create a lazy string with address 0x0, and a non-zero length.*Error occurred in Python.*" \
     "null lazy string with non-zero length"
 gdb_test "python print(null.lazy_string(length=-2))" \
-    "ValueError: Invalid length.*Error while executing Python code." \
+    "ValueError.*: Invalid length.*Error occurred in Python.*" \
     "bad length"
 
 foreach var_spec { { "ptr" "pointer" "const char \\*" -1 } \
diff --git a/gdb/testsuite/gdb.python/py-mi-cmd.exp b/gdb/testsuite/gdb.python/py-mi-cmd.exp
index d9fba23b39b..28c71cd75f3 100644
--- a/gdb/testsuite/gdb.python/py-mi-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-mi-cmd.exp
@@ -70,7 +70,7 @@ mi_gdb_test "-pycmd bk2" \
 
 mi_gdb_test "-pycmd bk3" \
     [multi_line \
-	 "&\"TypeError: __repr__ returned non-string \\(type BadKey\\)..\"" \
+	 "&\"TypeError.*: __repr__ returned non-string \\(type BadKey\\)..\"" \
 	 "\\^error,msg=\"Error occurred in Python: __repr__ returned non-string \\(type BadKey\\)\""] \
     "-pycmd bk3"
 
@@ -156,23 +156,23 @@ mi_gdb_test "-pycmd-new int" \
     "-pycmd-new int - defined from MI"
 
 mi_gdb_test "python pycmd1('')" \
-    ".*&\"ValueError: MI command name is empty\\...\".*\\^error,msg=\"Error while executing Python code\\.\"" \
+    ".*&\"ValueError.*: MI command name is empty\\...\".*\\^error,msg=\"Error occurred in Python.*\"" \
     "empty MI command name"
 
 mi_gdb_test "python pycmd1('-')" \
     [multi_line \
 	 ".*" \
-	 "&\"ValueError: MI command name does not start with '-' followed by at least one letter or digit\\...\"" \
-	 "&\"Error while executing Python code\\...\"" \
-	 "\\^error,msg=\"Error while executing Python code\\.\""] \
+	 "&\"ValueError.*: MI command name does not start with '-' followed by at least one letter or digit\\...\"" \
+	 "&\"Error occurred in Python.*..\"" \
+	 "\\^error,msg=\"Error occurred in Python.*\""] \
     "invalid MI command name"
 
 mi_gdb_test "python pycmd1('-bad-character-@')" \
     [multi_line \
 	 ".*" \
-	 "&\"ValueError: MI command name contains invalid character: @\\...\"" \
-	 "&\"Error while executing Python code\\...\"" \
-	 "\\^error,msg=\"Error while executing Python code\\.\""] \
+	 "&\"ValueError.*: MI command name contains invalid character: @\\...\"" \
+	 "&\"Error occurred in Python.*..\"" \
+	 "\\^error,msg=\"Error occurred in Python.*\""] \
     "invalid character in MI command name"
 
 mi_gdb_test "python cmd=pycmd1('-abc')" \
@@ -258,9 +258,9 @@ mi_gdb_test "-aa" \
 mi_gdb_test "python aa.__init__('-bb', 'message three', 'zzz')" \
     [multi_line \
 	 ".*" \
-	 "&\"ValueError: can't reinitialize object with a different command name..\"" \
-	 "&\"Error while executing Python code\\...\"" \
-	 "\\^error,msg=\"Error while executing Python code\\.\""] \
+	 "&\"ValueError.*: can't reinitialize object with a different command name..\"" \
+	 "&\"Error occurred in Python.*..\"" \
+	 "\\^error,msg=\"Error occurred in Python.*\""] \
     "attempt to reinitialise aa variable to a new command name"
 
 mi_gdb_test "-aa" \
@@ -274,9 +274,9 @@ mi_gdb_test "python aa.installed = False" \
 mi_gdb_test "python aa.__init__('-bb', 'message three', 'zzz')" \
     [multi_line \
 	 ".*" \
-	 "&\"ValueError: can't reinitialize object with a different command name..\"" \
-	 "&\"Error while executing Python code\\...\"" \
-	 "\\^error,msg=\"Error while executing Python code\\.\""] \
+	 "&\"ValueError.*: can't reinitialize object with a different command name..\"" \
+	 "&\"Error occurred in Python.*..\"" \
+	 "\\^error,msg=\"Error occurred in Python.*\""] \
     "attempt to reinitialise aa variable to a new command name while uninstalled"
 
 mi_gdb_test "python aa.__init__('-aa', 'message three', 'zzz')" \
@@ -299,7 +299,7 @@ mi_gdb_test "python no_invoke('-no-invoke')" ".*\\^done" \
 mi_gdb_test "-no-invoke" \
     [multi_line \
 	 ".*" \
-	 "&\"AttributeError: 'no_invoke' object has no attribute 'invoke'..\"" \
+	 "&\"AttributeError.*: 'no_invoke' object has no attribute 'invoke'..\"" \
 	 "\\^error,msg=\"Error occurred in Python: 'no_invoke' object has no attribute 'invoke'\""] \
     "execute -no-invoke command, which is missing the invoke method"
 
@@ -312,14 +312,14 @@ mi_gdb_test "python delattr(no_invoke, 'invoke')" ".*\\^done"
 mi_gdb_test "-hello" \
     [multi_line \
 	 ".*" \
-	 "&\"AttributeError: 'no_invoke' object has no attribute 'invoke'..\"" \
+	 "&\"AttributeError.*: 'no_invoke' object has no attribute 'invoke'..\"" \
 	 "\\^error,msg=\"Error occurred in Python: 'no_invoke' object has no attribute 'invoke'\""] \
     "execute -hello command, that had its invoke method removed"
 mi_gdb_test "python cmd.invoke = 'string'" ".*\\^done"
 mi_gdb_test "-hello" \
     [multi_line \
 	 ".*" \
-	 "&\"TypeError: 'str' object is not callable..\"" \
+	 "&\"TypeError.*: 'str' object is not callable..\"" \
 	 "\\^error,msg=\"Error occurred in Python: 'str' object is not callable\""] \
     "execute command with invoke set to a string"
 
@@ -327,9 +327,9 @@ mi_gdb_test "-hello" \
 mi_gdb_test "python cmd = pycmd2('-data-disassemble')" \
     [multi_line \
 	 ".*" \
-	 "&\"RuntimeError: unable to add command, name is already in use..\"" \
-	 "&\"Error while executing Python code\\...\"" \
-	 "\\^error,msg=\"Error while executing Python code\\.\""] \
+	 "&\"RuntimeError.*: unable to add command, name is already in use..\"" \
+	 "&\"Error occurred in Python.*..\"" \
+	 "\\^error,msg=\"Error occurred in Python.*\""] \
     "try to register a command that replaces -data-disassemble"
 
 
diff --git a/gdb/testsuite/gdb.python/py-missing-debug.exp b/gdb/testsuite/gdb.python/py-missing-debug.exp
index 0aa4aaa010b..d1eef34c3f3 100644
--- a/gdb/testsuite/gdb.python/py-missing-debug.exp
+++ b/gdb/testsuite/gdb.python/py-missing-debug.exp
@@ -201,8 +201,8 @@ proc check_bad_name {name} {
     set name_re [string_to_regexp $name]
     set re \
 	[multi_line \
-	     "ValueError: invalid character '.' in handler name: $name_re" \
-	     "Error while executing Python code\\."]
+	     "ValueError.*: invalid character '.' in handler name: $name_re" \
+	     "Error occurred in Python.*"]
 
     gdb_test "python register(\"$name\")" $re \
 	"check that '$name' is not accepted"
@@ -442,13 +442,13 @@ with_test_prefix "check handler replacement" {
     # the same name.
     gdb_test "python gdb.missing_debug.register_handler(pspace, log_handler(\"Foo\"))" \
 	[multi_line \
-	     "RuntimeError: Handler Foo already exists\\." \
-	     "Error while executing Python code\\."]
+	     "RuntimeError.*: Handler Foo already exists\\." \
+	     "Error occurred in Python.*"]
 
     gdb_test "python gdb.missing_debug.register_handler(handler=log_handler(\"Foo\"), locus=pspace)" \
 	[multi_line \
-	     "RuntimeError: Handler Foo already exists\\." \
-	     "Error while executing Python code\\."]
+	     "RuntimeError.*: Handler Foo already exists\\." \
+	     "Error occurred in Python.*"]
 
     # And now try again, but this time with 'replace=True', we
     # shouldn't get an error in this case.
@@ -464,8 +464,8 @@ with_test_prefix "check handler replacement" {
 
     gdb_test "python gdb.missing_debug.register_handler(pspace, log_handler(\"Foo\"))" \
 	[multi_line \
-	     "RuntimeError: Handler Foo already exists\\." \
-	     "Error while executing Python code\\."] \
+	     "RuntimeError.*: Handler Foo already exists\\." \
+	     "Error occurred in Python.*"] \
 	"still get an error when handler is disabled"
 
     gdb_test_no_output \
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index 1ddc3ddab36..2f5b7752b43 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -30,7 +30,7 @@ if {![runto_main]} {
     return 0
 }
 
-set python_error_text "Error while executing Python code\\."
+set python_error_text "Error occurred in Python.*"
 
 gdb_py_test_silent_cmd "python sym = gdb.lookup_symbol(\"some_var\")" \
     "Find a symbol in objfile" 1
diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp
index 94702f42816..de524f49ad6 100644
--- a/gdb/testsuite/gdb.python/py-parameter.exp
+++ b/gdb/testsuite/gdb.python/py-parameter.exp
@@ -342,7 +342,7 @@ proc_with_prefix test_gdb_parameter { } {
     } {
 	clean_restart
 
-	set param_range_error ".*gdb.error: integer -1 out of range.*"
+	set param_range_error ".*gdb.error.*: integer -1 out of range.*"
 	switch -- $param {
 	    "listsize" {
 		set param_get_zero None
@@ -438,8 +438,8 @@ proc_with_prefix test_integer_parameter { } {
 	    "test_param_$kind = TestNodocParam ('test-$kind')" "" \
 	    "end"
 
-	set param_range_error "RuntimeError: Range exceeded.*"
-	set param_integer_error "RuntimeError: The value must be integer.*"
+	set param_range_error "RuntimeError.*: Range exceeded.*"
+	set param_integer_error "RuntimeError.*: The value must be integer.*"
 	switch -- $kind {
 	    PARAM_UINTEGER {
 		set param_get_zero None
@@ -610,13 +610,13 @@ proc_with_prefix test_ambiguous_parameter {} {
 
     # Test ambiguous names.
     gdb_test "python print(gdb.parameter('test-ambiguou'))" \
-	"Parameter .* is ambiguous.*Error while executing Python code."
+	"Parameter .* is ambiguous.*Error occurred in Python.*"
     gdb_test "python print(gdb.parameter('test-ambiguous-'))" \
-	"Parameter .* is ambiguous.*Error while executing Python code."
+	"Parameter .* is ambiguous.*Error occurred in Python.*"
     gdb_test "python print(gdb.parameter('test-ambiguous-v'))" \
-	"Parameter .* is ambiguous.*Error while executing Python code."
+	"Parameter .* is ambiguous.*Error occurred in Python.*"
     gdb_test "python print(gdb.parameter('test-ambiguous-value-1a'))" \
-	"Could not find parameter.*Error while executing Python code."
+	"Could not find parameter.*Error occurred in Python.*"
 }
 
 test_directories
diff --git a/gdb/testsuite/gdb.python/py-pp-registration.exp b/gdb/testsuite/gdb.python/py-pp-registration.exp
index 68599d67a16..4bfdf5e5612 100644
--- a/gdb/testsuite/gdb.python/py-pp-registration.exp
+++ b/gdb/testsuite/gdb.python/py-pp-registration.exp
@@ -102,7 +102,7 @@ with_test_prefix "replace" {
     gdb_test_no_output "py gdb.printing.register_pretty_printer(gdb, lookup_function_lookup_test)"
     gdb_test_no_output "py gdb.printing.register_pretty_printer(progspace, my_pretty_printer1)"
     gdb_test "py gdb.printing.register_pretty_printer(progspace, my_pretty_printer2, replace=False)" \
-	"RuntimeError: pretty-printer already registered: pp-test\r\nError while executing Python code."
+	"RuntimeError.*: pretty-printer already registered: pp-test\r\nError occurred in Python.*"
 
     with_test_prefix "test printers 1" {
 	test_printers "s1"
diff --git a/gdb/testsuite/gdb.python/py-progspace-events.exp b/gdb/testsuite/gdb.python/py-progspace-events.exp
index 47a9985317e..95e4ca8da0b 100644
--- a/gdb/testsuite/gdb.python/py-progspace-events.exp
+++ b/gdb/testsuite/gdb.python/py-progspace-events.exp
@@ -107,7 +107,7 @@ set warning_msg \
 
 gdb_test "step" \
     [multi_line \
-	 "^FreeProgspaceEvent: <gdb.Progspace object at $hex>(?:\r\n$warning_msg)*" \
+	 "^FreeProgspaceEvent.*: <gdb.Progspace object at $hex>(?:\r\n$warning_msg)*" \
 	 "do_parent_stuff \\(\\) at \[^\r\n\]+" \
 	 "$decimal\\s+\[^\r\n\]+"]
 
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index f76e1f9359a..0ae5b5673d8 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -55,8 +55,8 @@ gdb_test "python print (progspace.random_attribute)" "42" \
 
 # Check that we can't create new (invalid) gdb.Progspace objects.
 gdb_test "python gdb.Progspace()" \
-    [multi_line "TypeError: cannot create 'gdb.Progspace' instances" \
-	 "Error while executing Python code\\."] \
+    [multi_line "TypeError.*: cannot create 'gdb.Progspace' instances" \
+	 "Error occurred in Python.*"] \
     "check for error when calling gdb.Progspace() directly"
 
 if {![runto_main]} {
@@ -111,7 +111,7 @@ gdb_py_test_silent_cmd "python progspace2 = gdb.current_progspace()" \
 gdb_test "inferior 1" "Switching to inferior 1.*"
 gdb_test_no_output "remove-inferiors 2"
 gdb_test "python print (progspace2.objfiles ())" \
-    "RuntimeError: Program space no longer exists.*"
+    "RuntimeError.*: Program space no longer exists.*"
 
 gdb_test "python print (progspace2.symbol_file)" \
-    "RuntimeError: Program space no longer exists.*"
+    "RuntimeError.*: Program space no longer exists.*"
diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp
index 71ff52ed137..fba0b98f794 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
@@ -34,12 +34,12 @@ with_test_prefix "no or double record" {
 
     gdb_test_no_output "python gdb.start_recording(\"btrace\")"
     gdb_test "python gdb.start_recording(\"btrace\")" \
-	".*gdb\.error: The process is already being recorded\..*" \
+	".*gdb\.error.*: The process is already being recorded\..*" \
 	"already recording"
 
     gdb_test_no_output "python gdb.stop_recording()" "first"
     gdb_test "python gdb.stop_recording()" \
-	".*gdb\.error: No recording is currently active\..*" "second"
+	".*gdb\.error.*: No recording is currently active\..*" "second"
 }
 
 with_test_prefix "preopened record btrace" {
diff --git a/gdb/testsuite/gdb.python/py-record-full.exp b/gdb/testsuite/gdb.python/py-record-full.exp
index 19497fb3cd1..da38d1cab6b 100644
--- a/gdb/testsuite/gdb.python/py-record-full.exp
+++ b/gdb/testsuite/gdb.python/py-record-full.exp
@@ -34,12 +34,12 @@ with_test_prefix "no or double record" {
 
     gdb_test_no_output "python gdb.start_recording(\"full\")"
     gdb_test "python gdb.start_recording(\"full\")" \
-	".*gdb\.error: The process is already being recorded\..*" \
+	".*gdb\.error.*: The process is already being recorded\..*" \
 	"already recording"
 
     gdb_test_no_output "python gdb.stop_recording()" "first"
     gdb_test "python gdb.stop_recording()" \
-	".*gdb\.error: No recording is currently active\..*" "second"
+	".*gdb\.error.*: No recording is currently active\..*" "second"
 }
 
 with_test_prefix "preopened record full" {
diff --git a/gdb/testsuite/gdb.python/py-template.exp b/gdb/testsuite/gdb.python/py-template.exp
index fbb745506e2..bba80e3b870 100644
--- a/gdb/testsuite/gdb.python/py-template.exp
+++ b/gdb/testsuite/gdb.python/py-template.exp
@@ -50,7 +50,7 @@ proc test_template_arg {exefile type} {
     gdb_test "python print (foo.type.template_argument(0))" $t $type
 
     gdb_test "python print(foo.type.template_argument(-1))" \
-	"Template argument number must be non-negative\r\nError while executing Python code." \
+	"Template argument number must be non-negative\r\nError occurred in Python.*" \
 	"negative template argument number in template test of $type"
 }
 
diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp
index 60399774b1b..939f0a86f48 100644
--- a/gdb/testsuite/gdb.python/py-thrhandle.exp
+++ b/gdb/testsuite/gdb.python/py-thrhandle.exp
@@ -90,7 +90,7 @@ gdb_test "python print(gdb.selected_inferior().thread_from_handle(gdb.parse_and_
 # We should see an exception when passing an object of the wrong type.
 
 gdb_test "python print(gdb.selected_inferior().thread_from_handle(gdb.lookup_symbol('main')))" \
-         ".*TypeError: Argument 'handle' must be a thread handle object.*" \
+         ".*TypeError.*: Argument 'handle' must be a thread handle object.*" \
 	 "TypeError when passing a symbol object to thread_from_handle"
 
 # We should see an exception when passing too large of an object.
diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp
index 1e9e7152f78..74e123441c4 100644
--- a/gdb/testsuite/gdb.python/py-type.exp
+++ b/gdb/testsuite/gdb.python/py-type.exp
@@ -121,10 +121,10 @@ proc test_fields {lang} {
     gdb_test "python print (not not st.type)" "True" "check conversion to bool"
 
     # Test rejection of mapping operations on scalar types
-    gdb_test "python print (len (st.type\['a'\].type))" "TypeError: Type is not a structure, union, enum, or function type.*"
-    gdb_test "python print (st.type\['a'\].type.has_key ('x'))" "TypeError: Type is not a structure, union, enum, or function type.*"
-    gdb_test "python print (st.type\['a'\].type\['x'\])" "TypeError: Type is not a structure, union, enum, or function type.*"
-    gdb_test "python print (st.type\['a'\].type.keys ())" "TypeError: Type is not a structure, union, enum, or function type.*"
+    gdb_test "python print (len (st.type\['a'\].type))" "TypeError.*: Type is not a structure, union, enum, or function type.*"
+    gdb_test "python print (st.type\['a'\].type.has_key ('x'))" "TypeError.*: Type is not a structure, union, enum, or function type.*"
+    gdb_test "python print (st.type\['a'\].type\['x'\])" "TypeError.*: Type is not a structure, union, enum, or function type.*"
+    gdb_test "python print (st.type\['a'\].type.keys ())" "TypeError.*: Type is not a structure, union, enum, or function type.*"
 
     # Test conversion to bool on scalar types
     gdb_test "python print (not not st.type\['a'\].type)" "True"
@@ -167,7 +167,7 @@ proc test_fields {lang} {
     gdb_test "python print (gdb.parse_and_eval ('a_function').type.fields ()\[1\].type)" "char"
 
     # Test calling `fields` on a non-aggregate type.
-    gdb_test "python gdb.lookup_type('int').fields()" "TypeError: Type is not a structure, union, enum, or function type.*"
+    gdb_test "python gdb.lookup_type('int').fields()" "TypeError.*: Type is not a structure, union, enum, or function type.*"
   }
 }
 
@@ -224,7 +224,7 @@ proc test_range {} {
       # Test where a range does not exist.
       gdb_py_test_silent_cmd "print (st)" "print value (st)" 1
       gdb_py_test_silent_cmd "python st = gdb.history (0)" "get value (st) from history" 1
-      gdb_test "python print (st.type.range())" "RuntimeError: This type does not have a range.*" "check range for non ranged type."
+      gdb_test "python print (st.type.range())" "RuntimeError.*: This type does not have a range.*" "check range for non ranged type."
     }
   }
 }
@@ -264,7 +264,7 @@ proc test_template {} {
 proc test_is_signed {lang} {
     if {$lang == "c++"} {
 	gdb_test "python print(gdb.parse_and_eval ('c').type.is_signed)"  \
-	"ValueError: Type must be a scalar type.*"
+	"ValueError.*: Type must be a scalar type.*"
 	gdb_test "python print(gdb.parse_and_eval ('&c').type.is_signed == False)" "True"
     }
 
@@ -274,13 +274,13 @@ proc test_is_signed {lang} {
 
     gdb_test "python print(gdb.parse_and_eval ('ss.x').type.is_signed == True)" "True"
     gdb_test "python print(gdb.parse_and_eval ('ss').type.is_signed)" \
-	"ValueError: Type must be a scalar type.*"
+	"ValueError.*: Type must be a scalar type.*"
     gdb_test "python print(gdb.parse_and_eval ('uu').type.is_signed)"  \
-	"ValueError: Type must be a scalar type.*"
+	"ValueError.*: Type must be a scalar type.*"
     gdb_test "python print(gdb.parse_and_eval ('uu.i').type.is_signed == True)" "True"
     gdb_test "python print(gdb.parse_and_eval ('uu.f').type.is_signed == True)" "True"
     gdb_test "python print(gdb.parse_and_eval ('uu.a').type.is_signed)"  \
-	"ValueError: Type must be a scalar type.*"
+	"ValueError.*: Type must be a scalar type.*"
 
     gdb_test "python print(gdb.parse_and_eval ('&ss.x').type.is_signed == False)" "True"
     gdb_test "python print(gdb.parse_and_eval ('&uu').type.is_signed == False)" "True"
diff --git a/gdb/testsuite/gdb.python/py-unwind.exp b/gdb/testsuite/gdb.python/py-unwind.exp
index 1f88be0ac97..d5efc0216cf 100644
--- a/gdb/testsuite/gdb.python/py-unwind.exp
+++ b/gdb/testsuite/gdb.python/py-unwind.exp
@@ -97,8 +97,8 @@ check_for_fixed_backtrace "check backtrace after flush"
 # output to be sure.
 gdb_test "python global_test_unwinder.enabled = \"off\"" \
     [multi_line \
-	 "TypeError: incorrect type for enabled attribute: <class 'str'>" \
-	 "Error while executing Python code\\."]
+	 "TypeError.*: incorrect type for enabled attribute: <class 'str'>" \
+	 "Error occurred in Python.*"]
 check_info_unwinder "info unwinder after failed disable" on
 
 # While we're doing silly stuff, lets try to change the name of this
@@ -109,8 +109,8 @@ set pattern_1 "can't set attribute(?: 'name')?"
 set pattern_2 "property 'name' of 'TestUnwinder' object has no setter"
 gdb_test "python global_test_unwinder.name = \"foo\"" \
     [multi_line \
-	 "AttributeError: (?:${pattern_1}|${pattern_2})" \
-	 "Error while executing Python code\\."]
+	 "AttributeError.*: (?:${pattern_1}|${pattern_2})" \
+	 "Error occurred in Python.*"]
 check_info_unwinder "info unwinder after failed name change" on
 
 # Now actually disable the unwinder by manually adjusting the
@@ -149,8 +149,8 @@ gdb_test "python print(read_register_error)" "Bad register" \
 # Try to create an unwinder object with a non-string name.
 gdb_test "python obj = simple_unwinder(True)" \
     [multi_line \
-	 "TypeError: incorrect type for name: <class 'bool'>" \
-	 "Error while executing Python code\\."]
+	 "TypeError.*: incorrect type for name: <class 'bool'>" \
+	 "Error occurred in Python.*"]
 
 # Now register the simple_unwinder with a valid name, and use the
 # unwinder to capture a PendingFrame object.
@@ -195,8 +195,8 @@ foreach cmd {"pf.read_register(\"pc\")" \
 		 "pf.function()" } {
     gdb_test "python $cmd" \
 	[multi_line \
-	     "ValueError: gdb\\.PendingFrame is invalid\\." \
-	     "Error while executing Python code\\."]
+	     "ValueError.*: gdb\\.PendingFrame is invalid\\." \
+	     "Error occurred in Python.*"]
 }
 
 # Turn on the useful unwinder so we have the full backtrace again, and
@@ -265,11 +265,11 @@ gdb_test_multiline "Sub-class gdb.UnwindInfo " \
     "    pass" "" \
     "end" \
     [multi_line \
-	 "TypeError: type 'gdb\\.UnwindInfo' is not an acceptable base type" \
-	 "Error while executing Python code\\."]
+	 "TypeError.*: type 'gdb\\.UnwindInfo' is not an acceptable base type" \
+	 "Error occurred in Python.*"]
 
 # Check we can't directly instantiate a gdb.UnwindInfo.
 gdb_test "python uw = gdb.UnwindInfo()" \
     [multi_line \
-     "TypeError: cannot create 'gdb\\.UnwindInfo' instances" \
-     "Error while executing Python code\\."]
+     "TypeError.*: cannot create 'gdb\\.UnwindInfo' instances" \
+     "Error occurred in Python.*"]
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index ff6b8b931f4..aa674e8aa0d 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -159,7 +159,7 @@ proc test_value_numeric_ops {} {
   }
 
   gdb_test_multiple "python print ('result = ' + str(i+gdb.Value('foo')))" "catch throw of GDB error" {
-      -re "Traceback.*$gdb_prompt $"  {pass "catch throw of GDB error"}
+      -re "Error occurred in Python.*$gdb_prompt $"  {pass "catch throw of GDB error"}
       -re "result = .*$gdb_prompt $"  {fail "catch throw of GDB error"}
       -re "$gdb_prompt $"	      {fail "catch throw of GDB error"}
   }
@@ -270,7 +270,7 @@ proc test_value_in_inferior {} {
   if {$can_read_0} {
     untested $test
   } else {
-    gdb_test "python print (gdb.parse_and_eval('*(int*)0'))" "gdb.MemoryError: Cannot access memory at address 0x0.*" $test
+    gdb_test "python print (gdb.parse_and_eval('*(int*)0'))" "gdb.MemoryError.*: Cannot access memory at address 0x0.*" $test
   }
 
   # Test Python lazy value handling
@@ -281,10 +281,10 @@ proc test_value_in_inferior {} {
     gdb_test "python inval = gdb.parse_and_eval('*(int*)0')"
     gdb_test "python print (inval.is_lazy)" "True"
     gdb_test "python inval2 = inval+1" \
-	"gdb.MemoryError: Cannot access memory at address 0x0.*" \
+	"gdb.MemoryError.*: Cannot access memory at address 0x0.*" \
 	"$test, first test"
     gdb_test "python inval.fetch_lazy ()" \
-	"gdb.MemoryError: Cannot access memory at address 0x0.*" \
+	"gdb.MemoryError.*: Cannot access memory at address 0x0.*" \
 	"$test, second test"
   }
   set argc_value [get_integer_valueof "argc" 0]
@@ -338,7 +338,7 @@ proc test_value_in_inferior {} {
   # non-memory value.
   gdb_py_test_silent_cmd "python str = '\"str\"'" "set up str variable" 1
   gdb_test "python print (gdb.parse_and_eval (str).string (length = 10))" \
-      "gdb.error: Attempt to take address of value not located in memory.\r\nError while executing Python code."
+      "gdb.error.*: Attempt to take address of value not located in memory.\r\nError occurred in Python.*"
 
   gdb_test "python print (gdb.parse_and_eval ('shadowed'))" \
       97 "shadowed local value"
@@ -385,7 +385,7 @@ proc test_objfiles {} {
     gdb_test "python print (gdb.objfiles()\[0\].pretty_printers)" "\\\[\\\]"
 
     gdb_test "python gdb.objfiles()\[0\].pretty_printers = 0" \
-      "pretty_printers attribute must be a list.*Error while executing Python code."
+      "pretty_printers attribute must be a list.*Error occurred in Python.*"
 }
 
 proc test_value_after_death {} {
@@ -463,7 +463,7 @@ proc test_subscript_regression {exefile lang} {
 
  # Try to access an int with a subscript.  This should fail.
  gdb_test "python print (intv)" "1" "baseline print of an int Python value"
- gdb_test "python print (intv\[0\])" "gdb.error: Cannot subscript requested type.*" \
+ gdb_test "python print (intv\[0\])" "gdb.error.*: Cannot subscript requested type.*" \
      "Attempt to access an integer with a subscript"
 
  # Try to access a string with a subscript.  This should pass.
@@ -478,7 +478,7 @@ proc test_subscript_regression {exefile lang} {
 
  # Try to access a single dimension array with a subscript to the
  # result.  This should fail.
- gdb_test "python print (pointer\[intv\]\[0\])" "gdb.error: Cannot subscript requested type.*" \
+ gdb_test "python print (pointer\[intv\]\[0\])" "gdb.error.*: Cannot subscript requested type.*" \
      "Attempt to access a single dimension array with a two subscripts"
 
  # Lastly, test subscript access to an array with multiple
@@ -568,7 +568,7 @@ proc test_value_from_buffer {} {
   gdb_test_no_output \
       { python compare_value_bytes_to_mem(v, (int(addr) + (2 * size_a0)), size_a0) }
   gdb_test "python v=gdb.Value(b\[2*size_a0+1:\],tp); print(v)" \
-           "ValueError: Size of type is larger than that of buffer object\..*" \
+           "ValueError.*: Size of type is larger than that of buffer object\..*" \
 	   "attempt to convert smaller buffer than size of type"
   gdb_py_test_silent_cmd "python atp=tp.array(2) ; print(atp)" \
                          "make array type" 0
@@ -580,17 +580,17 @@ proc test_value_from_buffer {} {
   gdb_test "python print(va\[0\])" "1" "print first array element"
   gdb_test "python print(va\[1\])" "2" "print second array element"
   gdb_test "python print(va\[2\])" "3" "print third array element"
-  gdb_test "python print(va\[3\])" "gdb\.error: no such vector element.*" \
+  gdb_test "python print(va\[3\])" "gdb\.error.*: no such vector element.*" \
            "print out of bounds array element"
   gdb_py_test_silent_cmd "python atpbig=tp.array(3)" "make bigger array type" 0
   gdb_test "python vabig=gdb.Value(b,atpbig)" \
-           "ValueError: Size of type is larger than that of buffer object\..*" \
+           "ValueError.*: Size of type is larger than that of buffer object\..*" \
 	   "attempt to construct large value with small buffer" 
   gdb_test "python v=gdb.Value(2048,tp)" \
-           "TypeError: Object must support the python buffer protocol\..*" \
+           "TypeError.*: Object must support the python buffer protocol\..*" \
            "attempt to construct value from buffer with non-buffer object"
   gdb_test "python v=gdb.Value(b,'int'); print(v)" \
-           "TypeError: type argument must be a gdb\.Type\..*" \
+           "TypeError.*: type argument must be a gdb\.Type\..*" \
 	   "attempt to construct value with string as type"
 }
 
@@ -616,7 +616,7 @@ proc test_add_to_history {} {
     # Try adding something that can't be converted to a gdb.Value,
     # this should give an error.
     gdb_test "python idx = gdb.add_history(gdb.GdbError(\"an error\"))" \
-	"TypeError: Could not convert Python object: .*"
+	"TypeError.*: Could not convert Python object: .*"
 }
 
 # Check we can create sub-classes of gdb.Value.
@@ -658,8 +658,8 @@ proc_with_prefix test_value_bytes { } {
   # Test accessing the bytes of an optimised out value.
   gdb_test "python print(gdb.Value(gdb.Value(5).type.optimized_out()).bytes)" \
       [multi_line \
-	   "gdb\\.error: value has been optimized out" \
-	   "Error while executing Python code\\."]
+	   "gdb\\.error.*: value has been optimized out" \
+	   "Error occurred in Python.*"]
 
   # A Python helper function.  Fetch VAR_NAME from the inferior as a
   # gdb.Value.  Read the bytes of the value based on its address, and
@@ -724,11 +724,11 @@ proc_with_prefix test_value_bytes { } {
   gdb_test_no_output "python bytes_as_int.append(0)"
   gdb_test_no_output "python too_many_bytes = bytes(bytes_as_int)"
   gdb_test "python i_value.bytes = too_many_bytes" \
-      "ValueError: Size of type is not equal to that of buffer object\\..*"
+      "ValueError.*: Size of type is not equal to that of buffer object\\..*"
   gdb_test_no_output "python bytes_as_int = bytes_as_int\[0:-2\]"
   gdb_test_no_output "python too_few_bytes = bytes(bytes_as_int)"
   gdb_test "python i_value.bytes = too_few_bytes" \
-      "ValueError: Size of type is not equal to that of buffer object\\..*"
+      "ValueError.*: Size of type is not equal to that of buffer object\\..*"
 
   # Check we get an exception writing to a not_lval.
   gdb_test_no_output "python i_value = gdb.Value(9)" \
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index c0d398c29b3..175a6de7ca0 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -132,7 +132,7 @@ gdb_test_multiline "post event insertion" \
   "end" ""
 
 gdb_test "python print (someVal)" "1" "test post event execution"
-gdb_test "python gdb.post_event(str(1))" "RuntimeError: Posted event is not callable.*" \
+gdb_test "python gdb.post_event(str(1))" "RuntimeError.*: Posted event is not callable.*" \
     "test non callable class"
 
 send_gdb "python gdb.post_event(lambda: invalid())\n"
@@ -162,7 +162,7 @@ gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
 	pass $test
     }
 }
-gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination beforehand: q"
+gdb_test "q" "Quit.*" "verify pagination beforehand: q"
 
 gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=True) == \"\\n\" * [expr $lines + 1]: print (\"yes\")" "yes" "gdb.execute does not page"
 
@@ -178,7 +178,7 @@ gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
 	pass $test
     }
 }
-gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination afterwards: q"
+gdb_test "q" "Quit.*" "verify pagination afterwards: q"
 
 gdb_test_no_output "set height 0"
 
@@ -223,7 +223,7 @@ runto $lineno
 
 # Test gdb.decode_line.
 gdb_test "python gdb.decode_line(\"main.c:43\")" \
-    "gdb.error: No source file named main.c.*" "test decode_line no source named main"
+    "gdb.error.*: No source file named main.c.*" "test decode_line no source named main"
 
 with_test_prefix "test decode_line current location" {
     gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "decode current line" 1
@@ -253,7 +253,7 @@ with_test_prefix "test decode_line" {
     gdb_test "python print (symtab\[1\]\[0\].line)" "26" "python.c:26 line number"
 
     gdb_test "python gdb.decode_line(\"randomfunc\")" \
-	"gdb.error: Function \"randomfunc\" not defined.*" "randomfunc"
+	"gdb.error.*: Function \"randomfunc\" not defined.*" "randomfunc"
     gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "func1()" 1
     gdb_test "python print (len(symtab))" "2" "func1 length 2"
     gdb_test "python print (len(symtab\[1\]))" "1" "func1 length 1"
diff --git a/gdb/testsuite/gdb.python/tui-window-names.exp b/gdb/testsuite/gdb.python/tui-window-names.exp
index 03cd86bae7e..8236fc9a1a3 100644
--- a/gdb/testsuite/gdb.python/tui-window-names.exp
+++ b/gdb/testsuite/gdb.python/tui-window-names.exp
@@ -39,21 +39,21 @@ foreach c {$ * \{ \} ( ) @ #} {
     set re [string_to_regexp "$c"]
     gdb_test "python gdb.register_window_type('te${c}st', failwin)" \
 	[multi_line \
-	     "gdb.error: invalid character '${re}' in window name" \
-	     "Error while executing Python code\\." ]
+	     "gdb.error.*: invalid character '${re}' in window name" \
+	     "Error occurred in Python.*" ]
 
     gdb_test "python gdb.register_window_type('${c}test', failwin)" \
 	[multi_line \
-	     "gdb.error: invalid character '${re}' in window name" \
-	     "Error while executing Python code\\." ]
+	     "gdb.error.*: invalid character '${re}' in window name" \
+	     "Error occurred in Python.*" ]
 }
 
 # Check that whitespace within a window name is rejected.
 foreach c [list " " "\\t" "\\n" "\\r"] {
     gdb_test "python gdb.register_window_type('te${c}st', failwin)" \
 	[multi_line \
-	     "gdb.error: invalid whitespace character in window name" \
-	     "Error while executing Python code\\." ]
+	     "gdb.error.*: invalid whitespace character in window name" \
+	     "Error occurred in Python.*" ]
 }
 
 # Check some of the characters which are allowed within a window name,
@@ -62,8 +62,8 @@ foreach c {1 _ - .} {
     set re [string_to_regexp "$c"]
     gdb_test "python gdb.register_window_type('${c}test', failwin)" \
 	[multi_line \
-	     "gdb.error: window name must start with a letter, not '${re}'" \
-	     "Error while executing Python code\\." ]
+	     "gdb.error.*: window name must start with a letter, not '${re}'" \
+	     "Error occurred in Python.*" ]
 }
 
 # Check different capitalisations.
diff --git a/gdb/testsuite/gdb.python/tui-window.exp b/gdb/testsuite/gdb.python/tui-window.exp
index ad91fff79cc..e7ff1621fe8 100644
--- a/gdb/testsuite/gdb.python/tui-window.exp
+++ b/gdb/testsuite/gdb.python/tui-window.exp
@@ -50,7 +50,7 @@ Term::check_contents "Window display" "Test: 0"
 
 Term::command "python delete_window_title ()"
 Term::check_contents "error message after trying to delete title" \
-    "TypeError: Cannot delete \"title\" attribute\\."
+    "TypeError.*: Cannot delete \"title\" attribute\\."
 Term::check_contents "title is unchanged" \
     "This Is The Title"
 

-- 
2.43.0


^ permalink raw reply	[relevance 5%]

* [PATCH v2] Port GDB to Hurd x86_64.
       [not found]     <20240214191045.e4ndamwvpzjbkudq@begin>
@ 2024-02-15  6:56  2% ` Flavio Cruz
  0 siblings, 0 replies; 200+ results
From: Flavio Cruz @ 2024-02-15  6:56 UTC (permalink / raw)
  To: bug-hurd; +Cc: Flavio Cruz

This port extends the existing i686 port to support x86_64 by trying to
reuse existing code whenever it makes sense.

* gdb/amd64-gnu-tdep.c: Adds logic for handling signal frames and
  position of amd64 registers in the different Hurd structs, including
  i386_thread_state. The signal code is very similar to i686, except the
  trampoline code is adapted.
* gdb/amd64-gnu-tdep.h: export register offsets for x86-gnu-nat.c.
* gdb/config/i386/nm-i386gnu.h: renamed to gdb/config/i386/nm-x86-gnu.h
  and adapt it for x86_64.
* gdb/config/i386/i386gnu.mn: renamed to gdb/config/i386/nm-x86-gnu.mn
  and reuse it for x86_64.
* gdb/configure.host: recognize gnu64 as a host.
* gdb/configure.nat: recognize gnu64 host and update existing i386gnu to
  reuse the new shared files.
* gdb/configure.tgt: recognize x86_64-*-gnu* triplet and use
  amd64-gnu-tdep.c.
* gdb/i386-gnu-tdep.c: added i386_gnu_thread_state_reg_offset that is
  copied from i386-gnu-nat.c. This makes it similar to amd64.
* gdb/i386-gnu-tdep.h: export register offsets and number of registers.
* gdb/i386-gnu-nat.c: rename it to x86-gnu-nat.c since we reuse this for
  i386 and amd64. Updated REG_ADDR to use one of the structures. Added
  VALID_REGISTER to make sure it's a register we can provide at this time
  (not all of them are available in amd64). FLAGS_REGISTER is either rfl
  or efl depending on the arch. Renamed functions and class from i386 to x86
  whenever they can be reused.

Tested on Hurd x86_64 and i686.
---

Latest changes:
- Changed svr4_ilp32_fetch_link_map_offsets to
  svr4_lp64_fetch_link_map_offsets in amd64-gnu-tdep.c (duh).
- Added set_gdbarch_* to work better with the glibc and shared
  library features like TLS and PLT in amd64-gnu-tdep.c and also
  i386-gnu-tdep.c

It does seem to work with shared libraries now and I can backtrace inside
library functions from libhurduser up to libc.

 gdb/amd64-gnu-tdep.c                          | 267 ++++++++++++++++++
 gdb/amd64-gnu-tdep.h                          |  29 ++
 .../i386/{nm-i386gnu.h => nm-x86-gnu.h}       |   7 +
 gdb/config/i386/{i386gnu.mn => x86-gnu.mn}    |   0
 gdb/configure.host                            |   1 +
 gdb/configure.nat                             |  27 +-
 gdb/configure.tgt                             |   6 +-
 gdb/i386-gnu-tdep.c                           |  47 ++-
 gdb/i386-gnu-tdep.h                           |  29 ++
 gdb/{i386-gnu-nat.c => x86-gnu-nat.c}         | 128 +++++----
 10 files changed, 479 insertions(+), 62 deletions(-)
 create mode 100644 gdb/amd64-gnu-tdep.c
 create mode 100644 gdb/amd64-gnu-tdep.h
 rename gdb/config/i386/{nm-i386gnu.h => nm-x86-gnu.h} (83%)
 rename gdb/config/i386/{i386gnu.mn => x86-gnu.mn} (100%)
 create mode 100644 gdb/i386-gnu-tdep.h
 rename gdb/{i386-gnu-nat.c => x86-gnu-nat.c} (75%)

diff --git a/gdb/amd64-gnu-tdep.c b/gdb/amd64-gnu-tdep.c
new file mode 100644
index 00000000000..a5e67df5f21
--- /dev/null
+++ b/gdb/amd64-gnu-tdep.c
@@ -0,0 +1,267 @@
+/* Target-dependent code for the GNU Hurd.
+   Copyright (C) 2024 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "defs.h"
+#include "gdbcore.h"
+#include "osabi.h"
+#include "solib-svr4.h"
+
+#include "amd64-tdep.h"
+#include "amd64-gnu-tdep.h"
+#include "glibc-tdep.h"
+
+extern "C"
+{
+#include <mach.h>
+}
+
+/* Recognizing signal handler frames.  */
+
+/* When the GNU/Hurd libc calls a signal handler, the return address points
+   inside the trampoline assembly snippet.
+
+   If the trampoline function name can not be identified, we resort to reading
+   memory from the process in order to identify it.  */
+
+static const gdb_byte gnu_sigtramp_code[] =
+{
+/* rpc_wait_trampoline: */
+  0x48, 0xc7, 0xc0, 0xe7, 0xff, 0xff, 0xff,	/* mov    $-25,%rax */
+  0x0f, 0x05,					/* syscall */
+  0x49, 0x89, 0x04, 0x24,			/* mov    %rax,(%r12) */
+  0x48, 0x89, 0xdc,				/* mov    %rbx,%rsp */
+
+/* trampoline: */
+  0x5f,			                        /* pop    %rdi */
+  0x5e,						/* pop    %rsi */
+  0x5a,						/* pop    %rdx */
+  0x48, 0x83, 0xc4, 0x08,			/* add    $0x8,%rsp */
+  0x41, 0xff, 0xd5,				/* call   *%r13 */
+
+/* RA HERE */
+  0x48, 0x8b, 0x7c, 0x24, 0x10,			/* mov    0x10(%rsp),%rdi */
+  0xc3,						/* ret */
+
+/* firewall: */
+  0xf4,						/* hlt */
+};
+
+#define GNU_SIGTRAMP_LEN (sizeof gnu_sigtramp_code)
+#define GNU_SIGTRAMP_TAIL 7			/* length of tail after RA */
+
+/* If THIS_FRAME is a sigtramp routine, return the address of the
+   start of the routine.  Otherwise, return 0.  */
+
+static CORE_ADDR
+amd64_gnu_sigtramp_start (frame_info_ptr this_frame)
+{
+  CORE_ADDR pc = get_frame_pc (this_frame);
+  gdb_byte buf[GNU_SIGTRAMP_LEN];
+
+  if (!safe_frame_unwind_memory (this_frame,
+				 pc + GNU_SIGTRAMP_TAIL - GNU_SIGTRAMP_LEN,
+				 buf))
+    return 0;
+
+  if (memcmp (buf, gnu_sigtramp_code, GNU_SIGTRAMP_LEN) != 0)
+    return 0;
+
+  return pc;
+}
+
+/* Return whether THIS_FRAME corresponds to a Hurd sigtramp routine.  */
+
+static int
+amd64_gnu_sigtramp_p (frame_info_ptr this_frame)
+{
+  CORE_ADDR pc = get_frame_pc (this_frame);
+  const char *name;
+
+  find_pc_partial_function (pc, &name, NULL, NULL);
+
+  /* If we have a NAME, we can check for the trampoline function */
+  if (name != NULL && strcmp (name, "trampoline") == 0)
+    return 1;
+
+  return amd64_gnu_sigtramp_start (this_frame) != 0;
+}
+
+/* Offset to sc_i386_thread_state in sigcontext, from <bits/sigcontext.h>.  */
+#define AMD64_GNU_SIGCONTEXT_THREAD_STATE_OFFSET 32
+
+/* Assuming THIS_FRAME is a Hurd sigtramp routine, return the
+   address of the associated sigcontext structure.  */
+
+static CORE_ADDR
+amd64_gnu_sigcontext_addr (frame_info_ptr this_frame)
+{
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  CORE_ADDR pc;
+  CORE_ADDR sp;
+  gdb_byte buf[8];
+
+  get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
+  sp = extract_unsigned_integer (buf, 8, byte_order);
+
+  pc = amd64_gnu_sigtramp_start (this_frame);
+  if (pc)
+    {
+      CORE_ADDR sigcontext_addr;
+
+      /* The sigcontext structure address is passed as the third argument
+       * of the signal handler but %RDX is not saved across calls. Luckily,
+       * the structured is saved underneath the &__sigreturn and a dummy word
+       * to fill the slot for the address for __sigreturn to return to.
+       */
+      read_memory (sp + 16, buf, 8);
+      sigcontext_addr = extract_unsigned_integer (buf, 8, byte_order);
+      return sigcontext_addr + AMD64_GNU_SIGCONTEXT_THREAD_STATE_OFFSET;
+    }
+
+  error (_("Couldn't recognize signal trampoline."));
+  return 0;
+}
+
+/* Mapping between the general-purpose registers in `struct
+   sigcontext' format (starting at sc_i386_thread_state)
+   and GDB's register cache layout.  */
+
+/* From <bits/sigcontext.h>.  */
+static int amd64_gnu_sc_reg_offset[] =
+{
+  15 * 8,			/* %rax */
+  12 * 8,			/* %rbx */
+  14 * 8,			/* %rcx */
+  13 * 8,			/* %rdx */
+  10 * 8,			/* %rsi */
+  9 * 8,			/* %rdi */
+  10 * 8,			/* %rbp */
+  11 * 8,			/* %rsp */
+  0 * 8,			/* %r8 ...  */
+  8 * 8,
+  7 * 8,
+  6 * 8,
+  3 * 8,
+  2 * 8,
+  1 * 8,
+  0 * 8,			/* ... %r15 */
+  16 * 8,			/* %rip */
+  18 * 8,			/* %eflags */
+  17 * 8,			/* %cs */
+};
+
+/* From <sys/ucontext.h>.  */
+static int amd64_gnu_gregset_reg_offset[] =
+{
+  10 * 8,			/* %rax */
+  5 * 8,			/* %rbx */
+  11 * 8,			/* %rcx */
+  12 * 8,			/* %rdx */
+  13 * 8,			/* %rsi */
+  14 * 8,			/* %rdi */
+  4 * 8,			/* %rbp */
+  19 * 8,			/* %rsp */
+  9 * 8,			/* %r8 ...  */
+  8 * 8,
+  7 * 8,
+  6 * 8,
+  3 * 8,
+  2 * 8,
+  1 * 8,
+  0 * 8,			/* ... %r15 */
+  16 * 8,			/* %rip */
+  18 * 8,			/* %eflags */
+  17 * 8,			/* %cs */
+  -1,				  /* %ss */
+  -1,				  /* %ds */
+  -1,				  /* %es */
+  -1,				  /* %fs */
+  -1,				  /* %gs */
+};
+
+/* Offset to the thread_state_t location where REG is stored.  */
+#define REG_OFFSET(reg) offsetof (struct i386_thread_state, reg)
+
+/* At REG_OFFSET[N] is the offset to the thread_state_t location where
+   the GDB register N is stored.  */
+int amd64_gnu_thread_state_reg_offset[] =
+{
+  REG_OFFSET (rax),		/* %rax */
+  REG_OFFSET (rbx),		/* %rbx */
+  REG_OFFSET (rcx),		/* %rcx */
+  REG_OFFSET (rdx),		/* %rdx */
+  REG_OFFSET (rsi),		/* %rsi */
+  REG_OFFSET (rdi),		/* %rdi */
+  REG_OFFSET (rbp),		/* %rbp */
+  REG_OFFSET (ursp),	/* %rsp */
+  REG_OFFSET (r8),		/* %r8 ...  */
+  REG_OFFSET (r9),
+  REG_OFFSET (r10),
+  REG_OFFSET (r11),
+  REG_OFFSET (r12),
+  REG_OFFSET (r13),
+  REG_OFFSET (r14),
+  REG_OFFSET (r15),		/* ... %r15 */
+  REG_OFFSET (rip),		/* %rip */
+  REG_OFFSET (rfl),		/* %rflags */
+  REG_OFFSET (cs)	    /* %cs */
+};
+
+const int amd64_gnu_thread_state_num_regs =
+  ARRAY_SIZE (amd64_gnu_thread_state_reg_offset);
+
+static void
+amd64_gnu_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+
+  amd64_init_abi (info, gdbarch,
+      amd64_target_description (X86_XSTATE_SSE_MASK, true));
+
+  /* Enable TLS support.  */
+  set_gdbarch_fetch_tls_load_module_address (gdbarch,
+      svr4_fetch_objfile_link_map);
+
+  /* Hurd uses SVR4-style shared libraries.  */
+  set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
+
+  /* Hurd uses the dynamic linker included in the GNU C Library.  */
+  set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
+
+  tdep->gregset_reg_offset = amd64_gnu_gregset_reg_offset;
+  tdep->gregset_num_regs = ARRAY_SIZE (amd64_gnu_gregset_reg_offset);
+  tdep->sizeof_gregset = 21 * 8; /* sizeof (struct i386_thread_state); */
+
+  tdep->sigtramp_p = amd64_gnu_sigtramp_p;
+  tdep->sigcontext_addr = amd64_gnu_sigcontext_addr;
+  tdep->sc_reg_offset = amd64_gnu_sc_reg_offset;
+  tdep->sc_num_regs = ARRAY_SIZE (amd64_gnu_sc_reg_offset);
+
+  /* Hurd uses SVR4-style shared libraries.  */
+  set_solib_svr4_fetch_link_map_offsets
+    (gdbarch, svr4_lp64_fetch_link_map_offsets);
+}
+
+void _initialize_amd64_gnu_tdep ();
+void
+_initialize_amd64_gnu_tdep ()
+{
+  gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
+			  GDB_OSABI_HURD, amd64_gnu_init_abi);
+}
diff --git a/gdb/amd64-gnu-tdep.h b/gdb/amd64-gnu-tdep.h
new file mode 100644
index 00000000000..70a6e4bfeb6
--- /dev/null
+++ b/gdb/amd64-gnu-tdep.h
@@ -0,0 +1,29 @@
+/* Target-dependent code for Hurd x86-64.
+
+   Copyright (C) 2024 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef AMD64_GNU_TDEP_H
+#define AMD64_GNU_TDEP_H
+
+/* Mapping between the general-purpose registers in Hurd x86_64 thread
+   state and GDB's register cache layout.
+   Indexed by amd64_regnum.  */
+extern int amd64_gnu_thread_state_reg_offset[];
+extern const int amd64_gnu_thread_state_num_regs;
+
+#endif /* AMD64_GNU_TDEP_H */
diff --git a/gdb/config/i386/nm-i386gnu.h b/gdb/config/i386/nm-x86-gnu.h
similarity index 83%
rename from gdb/config/i386/nm-i386gnu.h
rename to gdb/config/i386/nm-x86-gnu.h
index d2d5de83948..ed4d1729227 100644
--- a/gdb/config/i386/nm-i386gnu.h
+++ b/gdb/config/i386/nm-x86-gnu.h
@@ -22,9 +22,16 @@
 /* Thread flavors used in re-setting the T bit.  */
 #define THREAD_STATE_FLAVOR		i386_REGS_SEGS_STATE
 #define THREAD_STATE_SIZE		i386_THREAD_STATE_COUNT
+#ifdef __x86_64__
+#define THREAD_STATE_SET_TRACED(state) \
+	((struct i386_thread_state *) (state))->rfl |= 0x100
+#define THREAD_STATE_CLEAR_TRACED(state) \
+	((((struct i386_thread_state *) (state))->rfl &= ~0x100), 1)
+#else
 #define THREAD_STATE_SET_TRACED(state) \
   	((struct i386_thread_state *) (state))->efl |= 0x100
 #define THREAD_STATE_CLEAR_TRACED(state) \
   	((((struct i386_thread_state *) (state))->efl &= ~0x100), 1)
+#endif /* __x86_64__ */
 
 #endif /* CONFIG_I386_NM_I386GNU_H */
diff --git a/gdb/config/i386/i386gnu.mn b/gdb/config/i386/x86-gnu.mn
similarity index 100%
rename from gdb/config/i386/i386gnu.mn
rename to gdb/config/i386/x86-gnu.mn
diff --git a/gdb/configure.host b/gdb/configure.host
index da71675b201..999af8e59ae 100644
--- a/gdb/configure.host
+++ b/gdb/configure.host
@@ -184,6 +184,7 @@ x86_64-*-mingw*)        gdb_host=mingw64
 			gdb_host_obs=mingw-hdep.o
 			;;
 x86_64-*-cygwin*)	gdb_host=cygwin64 ;;
+x86_64-*-gnu*)		gdb_host=gnu64 ;;
 m32r*-*-linux*)          gdb_host=linux ;;
 
 xtensa*-*-linux*)	gdb_host=linux ;;
diff --git a/gdb/configure.nat b/gdb/configure.nat
index 8b98511cef7..ef404fb791a 100644
--- a/gdb/configure.nat
+++ b/gdb/configure.nat
@@ -211,23 +211,44 @@ case ${gdb_host} in
 		;;
 	esac
 	;;
+    gnu64)
+	case ${gdb_host_cpu} in
+	    i386)
+		# Host: x86_64 running the GNU Hurd
+		NATDEPFILES='x86-gnu-nat.o gnu-nat.o \
+		     x86-nat.o nat/x86-dregs.o nat/x86-xstate.o \
+		     amd64-nat.o fork-child.o \
+		     nat/fork-inferior.o \
+		     notify_S.o process_reply_S.o msg_reply_S.o \
+		     msg_U.o exc_request_U.o exc_request_S.o'
+		HAVE_NATIVE_GCORE_HOST=1
+
+		NAT_FILE='nm-x86-gnu.h'
+		MH_CFLAGS='-D_GNU_SOURCE'
+
+		XM_CLIBS='-lshouldbeinlibc'
+
+		nat_makefile_frag="${srcdir}/config/${gdb_host_cpu}/x86-gnu.mn"
+		;;
+	esac
+	;;
     i386gnu)
 	case ${gdb_host_cpu} in
 	    i386)
 		# Host: Intel 386 running the GNU Hurd
-		NATDEPFILES='i386-gnu-nat.o gnu-nat.o \
+		NATDEPFILES='x86-gnu-nat.o gnu-nat.o \
 		     x86-nat.o nat/x86-dregs.o fork-child.o \
 		     nat/fork-inferior.o \
 		     notify_S.o process_reply_S.o msg_reply_S.o \
 		     msg_U.o exc_request_U.o exc_request_S.o'
 		HAVE_NATIVE_GCORE_HOST=1
 
-		NAT_FILE='nm-i386gnu.h'
+		NAT_FILE='nm-x86-gnu.h'
 		MH_CFLAGS='-D_GNU_SOURCE'
 
 		XM_CLIBS='-lshouldbeinlibc'
 
-		nat_makefile_frag="${srcdir}/config/${gdb_host_cpu}/i386gnu.mn"
+		nat_makefile_frag="${srcdir}/config/${gdb_host_cpu}/x86-gnu.mn"
 		;;
 	esac
 	;;
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 47a674201f9..df9e9917ad1 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -328,7 +328,7 @@ i[34567]86-*-linux*)
 	;;
 i[34567]86-*-gnu*)
 	# Target: Intel 386 running the GNU Hurd
-	gdb_target_obs="i386-gnu-tdep.o solib-svr4.o"
+	gdb_target_obs="i386-gnu-tdep.o glibc-tdep.o solib-svr4.o"
 	;;
 i[34567]86-*-cygwin*)
 	# Target: Intel 386 running win32
@@ -744,6 +744,10 @@ x86_64-*-openbsd*)
 x86_64-*-rtems*)
 	gdb_target_obs="${amd64_tobjs} ${i386_tobjs} i386-bsd-tdep.o"
 	;;
+x86_64-*-gnu*)
+	# Target: x86_64 running the GNU Hurd
+	gdb_target_obs="amd64-gnu-tdep.o glibc-tdep.o solib-svr4.o"
+	;;
 xtensa*-*-*linux*)
 	# Target: GNU/Linux Xtensa
 	gdb_target_obs="xtensa-linux-tdep.o symfile-mem.o linux-tdep.o"
diff --git a/gdb/i386-gnu-tdep.c b/gdb/i386-gnu-tdep.c
index 9ff47147513..d0d9059e883 100644
--- a/gdb/i386-gnu-tdep.c
+++ b/gdb/i386-gnu-tdep.c
@@ -21,7 +21,14 @@
 #include "osabi.h"
 #include "solib-svr4.h"
 
+#include "glibc-tdep.h"
 #include "i386-tdep.h"
+#include "i386-gnu-tdep.h"
+
+extern "C"
+{
+#include <mach.h>
+}
 
 /* Recognizing signal handler frames.  */
 
@@ -72,8 +79,7 @@ i386_gnu_sigtramp_start (frame_info_ptr this_frame)
   return pc;
 }
 
-/* Return whether THIS_FRAME corresponds to a GNU/Linux sigtramp
-   routine.  */
+/* Return whether THIS_FRAME corresponds to a Hurd sigtramp routine.  */
 
 static int
 i386_gnu_sigtramp_p (frame_info_ptr this_frame)
@@ -170,6 +176,34 @@ static int i386gnu_gregset_reg_offset[] =
   0 * 4,		/* %gs */
 };
 
+/* Offset to the thread_state_t location where REG is stored.  */
+#define REG_OFFSET(reg) offsetof (struct i386_thread_state, reg)
+
+/* At REG_OFFSET[N] is the offset to the thread_state_t location where
+   the GDB register N is stored.  */
+int i386_gnu_thread_state_reg_offset[] =
+{
+  REG_OFFSET (eax),	/* %eax */
+  REG_OFFSET (ecx),	/* %ecx */
+  REG_OFFSET (edx),	/* %edx */
+  REG_OFFSET (ebx),	/* %ebx */
+  REG_OFFSET (uesp),	/* %esp */
+  REG_OFFSET (ebp),	/* %ebp */
+  REG_OFFSET (esi),	/* %esi */
+  REG_OFFSET (edi),	/* %edi */
+  REG_OFFSET (eip),	/* %eip */
+  REG_OFFSET (efl),	/* %efl */
+  REG_OFFSET (cs),	/* %cs */
+  REG_OFFSET (ss),	/* %ss */
+  REG_OFFSET (ds),	/* %ds */
+  REG_OFFSET (es),	/* %es */
+  REG_OFFSET (fs),	/* %fs */
+  REG_OFFSET (gs)	/* gs */
+};
+
+const int i386_gnu_thread_state_num_regs =
+  ARRAY_SIZE (i386_gnu_thread_state_reg_offset);
+
 static void
 i386gnu_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
@@ -178,9 +212,18 @@ i386gnu_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* GNU uses ELF.  */
   i386_elf_init_abi (info, gdbarch);
 
+  /* Hurd uses SVR4-style shared libraries.  */
+  set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
 
+  /* Hurd uses the dynamic linker included in the GNU C Library.  */
+  set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
+
+  /* Enable TLS support.  */
+  set_gdbarch_fetch_tls_load_module_address (gdbarch,
+					     svr4_fetch_objfile_link_map);
+
   tdep->gregset_reg_offset = i386gnu_gregset_reg_offset;
   tdep->gregset_num_regs = ARRAY_SIZE (i386gnu_gregset_reg_offset);
   tdep->sizeof_gregset = 19 * 4;
diff --git a/gdb/i386-gnu-tdep.h b/gdb/i386-gnu-tdep.h
new file mode 100644
index 00000000000..32e9a73c667
--- /dev/null
+++ b/gdb/i386-gnu-tdep.h
@@ -0,0 +1,29 @@
+/* Target-dependent code for Hurd i386.
+
+   Copyright (C) 2024 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef I386_GNU_TDEP_H
+#define I386_GNU_TDEP_H
+
+/* Mapping between the general-purpose registers in Hurd i386 thread
+   state and GDB's register cache layout.
+   Indexed by amd64_regnum.  */
+extern int i386_gnu_thread_state_reg_offset[];
+extern const int i386_gnu_thread_state_num_regs;
+
+#endif /* I386_GNU_TDEP_H */
diff --git a/gdb/i386-gnu-nat.c b/gdb/x86-gnu-nat.c
similarity index 75%
rename from gdb/i386-gnu-nat.c
rename to gdb/x86-gnu-nat.c
index 0b0759179aa..9a28c5e6a11 100644
--- a/gdb/i386-gnu-nat.c
+++ b/gdb/x86-gnu-nat.c
@@ -35,29 +35,41 @@ extern "C"
 #include "floatformat.h"
 #include "regcache.h"
 
+#ifdef __x86_64__
+#include "amd64-tdep.h"
+#include "amd64-nat.h"
+#include "amd64-gnu-tdep.h"
+#else
 #include "i386-tdep.h"
+#include "i386-gnu-tdep.h"
+#endif
 
 #include "inf-child.h"
 #include "i387-tdep.h"
 
-/* Offset to the thread_state_t location where REG is stored.  */
-#define REG_OFFSET(reg) offsetof (struct i386_thread_state, reg)
+#ifdef __x86_64__
 
-/* At REG_OFFSET[N] is the offset to the thread_state_t location where
-   the GDB register N is stored.  */
-static int reg_offset[] =
-{
-  REG_OFFSET (eax), REG_OFFSET (ecx), REG_OFFSET (edx), REG_OFFSET (ebx),
-  REG_OFFSET (uesp), REG_OFFSET (ebp), REG_OFFSET (esi), REG_OFFSET (edi),
-  REG_OFFSET (eip), REG_OFFSET (efl), REG_OFFSET (cs), REG_OFFSET (ss),
-  REG_OFFSET (ds), REG_OFFSET (es), REG_OFFSET (fs), REG_OFFSET (gs)
-};
+#define REG_ADDR(state, regnum) \
+  ((char *)(state) + amd64_gnu_thread_state_reg_offset[regnum])
+#define VALID_REGISTER(regnum) \
+  ((regnum) >= 0 && (regnum) < amd64_gnu_thread_state_num_regs)
+#define NUM_GREGS amd64_gnu_thread_state_num_regs
+#define FLAGS_REGISTER rfl
 
-#define REG_ADDR(state, regnum) ((char *)(state) + reg_offset[regnum])
+#else
+
+#define REG_ADDR(state, regnum) \
+  ((char *)(state) + i386_gnu_thread_state_reg_offset[regnum])
+#define VALID_REGISTER(regnum) \
+  ((regnum) >= 0 && (regnum) < i386_gnu_thread_state_num_regs)
+#define NUM_GREGS i386_gnu_thread_state_num_regs
+#define FLAGS_REGISTER efl
+
+#endif  /* __x86_64__ */
 
 \f
 
-/* The i386 GNU Hurd target.  */
+/* The x86 GNU Hurd target.  */
 
 #ifdef i386_DEBUG_STATE
 using gnu_base_target = x86_nat_target<gnu_nat_target>;
@@ -65,13 +77,13 @@ using gnu_base_target = x86_nat_target<gnu_nat_target>;
 using gnu_base_target = gnu_nat_target;
 #endif
 
-struct i386_gnu_nat_target final : public gnu_base_target
+struct x86_gnu_nat_target final : public gnu_base_target
 {
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 };
 
-static i386_gnu_nat_target the_i386_gnu_nat_target;
+static x86_gnu_nat_target the_x86_gnu_nat_target;
 
 /* Get the whole floating-point state of THREAD and record the values
    of the corresponding (pseudo) registers.  */
@@ -106,7 +118,7 @@ fetch_fpregs (struct regcache *regcache, struct proc *thread)
 
 /* Fetch register REGNO, or all regs if REGNO is -1.  */
 void
-i386_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
+x86_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
 {
   struct proc *thread;
   ptid_t ptid = regcache->ptid ();
@@ -119,7 +131,7 @@ i386_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
     error (_("Can't fetch registers from thread %s: No such thread"),
 	   target_pid_to_str (ptid).c_str ());
 
-  if (regno < I386_NUM_GREGS || regno == -1)
+  if (VALID_REGISTER (regno) || regno == -1)
     {
       thread_state_t state;
 
@@ -138,7 +150,7 @@ i386_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
 
 	  proc_debug (thread, "fetching all register");
 
-	  for (i = 0; i < I386_NUM_GREGS; i++)
+	  for (i = 0; i < NUM_GREGS; i++)
 	    regcache->raw_supply (i, REG_ADDR (state, i));
 	  thread->fetched_regs = ~0;
 	}
@@ -153,7 +165,7 @@ i386_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
 	}
     }
 
-  if (regno >= I386_NUM_GREGS || regno == -1)
+  if (!VALID_REGISTER(regno) || regno == -1)
     {
       proc_debug (thread, "fetching floating-point registers");
 
@@ -196,7 +208,7 @@ store_fpregs (const struct regcache *regcache, struct proc *thread, int regno)
 
 /* Store at least register REGNO, or all regs if REGNO == -1.  */
 void
-i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
+x86_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
 {
   struct proc *thread;
   struct gdbarch *gdbarch = regcache->arch ();
@@ -210,7 +222,7 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
     error (_("Couldn't store registers into thread %s: No such thread"),
 	   target_pid_to_str (ptid).c_str ());
 
-  if (regno < I386_NUM_GREGS || regno == -1)
+  if (VALID_REGISTER (regno) || regno == -1)
     {
       thread_state_t state;
       thread_state_data_t old_state;
@@ -231,14 +243,14 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
 
       /* Save the T bit.  We might try to restore the %eflags register
 	 below, but changing the T bit would seriously confuse GDB.  */
-      trace = ((struct i386_thread_state *)state)->efl & 0x100;
+      trace = ((struct i386_thread_state *)state)->FLAGS_REGISTER & 0x100;
 
       if (!was_aborted && was_valid)
 	/* See which registers have changed after aborting the thread.  */
 	{
 	  int check_regno;
 
-	  for (check_regno = 0; check_regno < I386_NUM_GREGS; check_regno++)
+	  for (check_regno = 0; check_regno < NUM_GREGS; check_regno++)
 	    if ((thread->fetched_regs & (1 << check_regno))
 		&& memcpy (REG_ADDR (&old_state, check_regno),
 			   REG_ADDR (state, check_regno),
@@ -263,7 +275,7 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
 
 	  proc_debug (thread, "storing all registers");
 
-	  for (i = 0; i < I386_NUM_GREGS; i++)
+	  for (i = 0; i < NUM_GREGS; i++)
 	    if (REG_VALID == regcache->get_register_status (i))
 	      regcache->raw_collect (i, REG_ADDR (state, i));
 	}
@@ -277,11 +289,11 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
 	}
 
       /* Restore the T bit.  */
-      ((struct i386_thread_state *)state)->efl &= ~0x100;
-      ((struct i386_thread_state *)state)->efl |= trace;
+      ((struct i386_thread_state *)state)->FLAGS_REGISTER &= ~0x100;
+      ((struct i386_thread_state *)state)->FLAGS_REGISTER |= trace;
     }
 
-  if (regno >= I386_NUM_GREGS || regno == -1)
+  if (!VALID_REGISTER (regno) || regno == -1)
     {
       proc_debug (thread, "storing floating-point registers");
 
@@ -296,7 +308,7 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
 /* Get debug registers for thread THREAD.  */
 
 static void
-i386_gnu_dr_get (struct i386_debug_state *regs, struct proc *thread)
+x86_gnu_dr_get (struct i386_debug_state *regs, struct proc *thread)
 {
   mach_msg_type_number_t count = i386_DEBUG_STATE_COUNT;
   kern_return_t err;
@@ -311,7 +323,7 @@ i386_gnu_dr_get (struct i386_debug_state *regs, struct proc *thread)
 /* Set debug registers for thread THREAD.  */
 
 static void
-i386_gnu_dr_set (const struct i386_debug_state *regs, struct proc *thread)
+x86_gnu_dr_set (const struct i386_debug_state *regs, struct proc *thread)
 {
   kern_return_t err;
 
@@ -325,23 +337,23 @@ i386_gnu_dr_set (const struct i386_debug_state *regs, struct proc *thread)
 /* Set DR_CONTROL in THREAD.  */
 
 static void
-i386_gnu_dr_set_control_one (struct proc *thread, void *arg)
+x86_gnu_dr_set_control_one (struct proc *thread, void *arg)
 {
   unsigned long *control = (unsigned long *) arg;
   struct i386_debug_state regs;
 
-  i386_gnu_dr_get (&regs, thread);
+  x86_gnu_dr_get (&regs, thread);
   regs.dr[DR_CONTROL] = *control;
-  i386_gnu_dr_set (&regs, thread);
+  x86_gnu_dr_set (&regs, thread);
 }
 
 /* Set DR_CONTROL to CONTROL in all threads.  */
 
 static void
-i386_gnu_dr_set_control (unsigned long control)
+x86_gnu_dr_set_control (unsigned long control)
 {
   inf_update_procs (gnu_current_inf);
-  inf_threads (gnu_current_inf, i386_gnu_dr_set_control_one, &control);
+  inf_threads (gnu_current_inf, x86_gnu_dr_set_control_one, &control);
 }
 
 /* Parameters to set a debugging address.  */
@@ -355,20 +367,20 @@ struct reg_addr
 /* Set address REGNUM (zero based) to ADDR in THREAD.  */
 
 static void
-i386_gnu_dr_set_addr_one (struct proc *thread, void *arg)
+x86_gnu_dr_set_addr_one (struct proc *thread, void *arg)
 {
   struct reg_addr *reg_addr = (struct reg_addr *) arg;
   struct i386_debug_state regs;
 
-  i386_gnu_dr_get (&regs, thread);
+  x86_gnu_dr_get (&regs, thread);
   regs.dr[reg_addr->regnum] = reg_addr->addr;
-  i386_gnu_dr_set (&regs, thread);
+  x86_gnu_dr_set (&regs, thread);
 }
 
 /* Set address REGNUM (zero based) to ADDR in all threads.  */
 
 static void
-i386_gnu_dr_set_addr (int regnum, CORE_ADDR addr)
+x86_gnu_dr_set_addr (int regnum, CORE_ADDR addr)
 {
   struct reg_addr reg_addr;
 
@@ -378,13 +390,13 @@ i386_gnu_dr_set_addr (int regnum, CORE_ADDR addr)
   reg_addr.addr = addr;
 
   inf_update_procs (gnu_current_inf);
-  inf_threads (gnu_current_inf, i386_gnu_dr_set_addr_one, &reg_addr);
+  inf_threads (gnu_current_inf, x86_gnu_dr_set_addr_one, &reg_addr);
 }
 
 /* Get debug register REGNUM value from only the one LWP of PTID.  */
 
 static unsigned long
-i386_gnu_dr_get_reg (ptid_t ptid, int regnum)
+x86_gnu_dr_get_reg (ptid_t ptid, int regnum)
 {
   struct i386_debug_state regs;
   struct proc *thread;
@@ -393,7 +405,7 @@ i386_gnu_dr_get_reg (ptid_t ptid, int regnum)
   inf_update_procs (gnu_current_inf);
 
   thread = inf_tid_to_thread (gnu_current_inf, ptid.lwp ());
-  i386_gnu_dr_get (&regs, thread);
+  x86_gnu_dr_get (&regs, thread);
 
   return regs.dr[regnum];
 }
@@ -401,46 +413,50 @@ i386_gnu_dr_get_reg (ptid_t ptid, int regnum)
 /* Return the inferior's debug register REGNUM.  */
 
 static CORE_ADDR
-i386_gnu_dr_get_addr (int regnum)
+x86_gnu_dr_get_addr (int regnum)
 {
   gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
 
-  return i386_gnu_dr_get_reg (inferior_ptid, regnum);
+  return x86_gnu_dr_get_reg (inferior_ptid, regnum);
 }
 
 /* Get DR_STATUS from only the one thread of INFERIOR_PTID.  */
 
 static unsigned long
-i386_gnu_dr_get_status (void)
+x86_gnu_dr_get_status (void)
 {
-  return i386_gnu_dr_get_reg (inferior_ptid, DR_STATUS);
+  return x86_gnu_dr_get_reg (inferior_ptid, DR_STATUS);
 }
 
 /* Return the inferior's DR7 debug control register.  */
 
 static unsigned long
-i386_gnu_dr_get_control (void)
+x86_gnu_dr_get_control (void)
 {
-  return i386_gnu_dr_get_reg (inferior_ptid, DR_CONTROL);
+  return x86_gnu_dr_get_reg (inferior_ptid, DR_CONTROL);
 }
 #endif /* i386_DEBUG_STATE */
 
-void _initialize_i386gnu_nat ();
+void _initialize_x86_gnu_nat ();
 void
-_initialize_i386gnu_nat ()
+_initialize_x86_gnu_nat ()
 {
 #ifdef i386_DEBUG_STATE
-  x86_dr_low.set_control = i386_gnu_dr_set_control;
+  x86_dr_low.set_control = x86_gnu_dr_set_control;
   gdb_assert (DR_FIRSTADDR == 0 && DR_LASTADDR < i386_DEBUG_STATE_COUNT);
-  x86_dr_low.set_addr = i386_gnu_dr_set_addr;
-  x86_dr_low.get_addr = i386_gnu_dr_get_addr;
-  x86_dr_low.get_status = i386_gnu_dr_get_status;
-  x86_dr_low.get_control = i386_gnu_dr_get_control;
+  x86_dr_low.set_addr = x86_gnu_dr_set_addr;
+  x86_dr_low.get_addr = x86_gnu_dr_get_addr;
+  x86_dr_low.get_status = x86_gnu_dr_get_status;
+  x86_dr_low.get_control = x86_gnu_dr_get_control;
+#ifdef __x86_64__
+  x86_set_debug_register_length (8);
+#else
   x86_set_debug_register_length (4);
+#endif
 #endif /* i386_DEBUG_STATE */
 
-  gnu_target = &the_i386_gnu_nat_target;
+  gnu_target = &the_x86_gnu_nat_target;
 
   /* Register the target.  */
-  add_inf_child_target (&the_i386_gnu_nat_target);
+  add_inf_child_target (&the_x86_gnu_nat_target);
 }
-- 
2.39.2




^ permalink raw reply	[relevance 2%]

* RE: [PATCH 1/1] testsuite, btrace: update btrace testsuite to test all btrace recording methods
  @ 2024-02-15 10:19  0%     ` Ijaz, Abdul B
  0 siblings, 0 replies; 200+ results
From: Ijaz, Abdul B @ 2024-02-15 10:19 UTC (permalink / raw)
  To: Guinevere Larsen, gdb-patches; +Cc: Metzger, Markus T

Hi Larsen,

Thanks a lot for the feedback. Please see my response below and let me know so I will update V2 patch accordingly.

>>  With this change, gdb.btrace will, instead of selecting the
>> default recording method, run all tests for all available and
>> applicable methods. This increases testing coverage.

Larsen > Why did you create a new function, 
Larsen > target_supports_btrace, to do the exact function that allow_btrace_tests 
Larseb > does, and make this second function work completely differently? It 
Larsen > makes more sense to me to have it the other way around,

Abdul > There was common part in both old functions "allow_btrace_tests" and
 "allow_btrace_pt_tests" where in first step it was checked whether btrace is supported
 on the CPU currently in use. So after the change now only this common part is moved to
 this new function "target_supports_btrace" i.e.
"{ ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] }" .
So before checking if the recording method "bts" or "pt" is supported we check whether
the target CPU supports the btrace. So from the purpose of function you can see it suits
well to what it does. Otherwise let me know I can switch the names between
"target_supports_btrace" and "allow_btrace_tests". So only difference after the change
is if target supports btrace is checked separately and then rest is same i.e. other two functions
only check if "bts" and "pt" recording methods can be used.

Abdul >> +gdb_caching_proc target_supports_btrace {} {
Abdul >>       if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
Abdul >> -	verbose "$me:  target does not support btrace, returning 0" 2
Abdul >> +	verbose "target_supports_btrace:  target does not support btrace, returning 0" 2
Abdul >>   	return 0
Abdul >>       }
Abdul >> +    return 1

Larsen > As I mentioned previously, I think the proc name shouldn't be changed, 
and the new proc should be called target_supports_btrace with a 
parameter, or target_supports_btrace_method and the parameter.

Abdul > Please see the response above if it answers your concerns. Otherwise I will update the function name so to switch names between "target_supports_btrace" and "allow_btrace_tests".

Larsen > Also, now you're not  testing further than if the target is an intel 
board. I think it would be better if first you tried the istarget above, 
then checked if either bts or pt is supported using the procs below. 
Since they are caching procs, there's no problem in calling them here 
then calling them again in the test files anyway.

Abdul >  I can see the advantage of calling the  functions here  to check support for bts and pt so  that if none of the method is supported then tests will not go
any further. Will update in V2 patch and call them here also and in case both of them are not supported then will return 0. But as you also mentioned
 we still have to call them in every test.

>> +++ b/gdb/testsuite/gdb.btrace/tsx.exp
>> @@ -15,7 +15,7 @@
>>   # You should have received a copy of the GNU General Public License
>>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>>   
>> -require allow_btrace_pt_tests allow_tsx_tests
>> +require allow_btrace_pt_tests allow_tsx_tests target_supports_btrace

Larsen > Do you happen to know why this test only works with pt style btrace? I 
apparently dont have TSX hardware, so I can't test things by hand and 
figure it out, unfortunately.

Abdul >  This test was specifically written to test only test "PT" related changes that is why it is also
not updated to test bts. I try to run it for bts and it gives following output which is not handled in the test:
(gdb) PASS: gdb.btrace/tsx.exp: record btrace bts
next^M
25        return 0;^M
(gdb) PASS: gdb.btrace/tsx.exp: next
record instruction-history^M
1          0x0000555555555131 <main+8>: call   0x55555555513d <test>^M
2          0x000055555555513d <test+0>: xbegin 0x55555555514c <test+15>^M
3          0x0000555555555143 <test+6>: mov    $0x0,%eax^M
4          0x0000555555555148 <test+11>:        xend^M
5          0x000055555555514b <test+14>:        ret^M
6          0x000055555555514c <test+15>:        mov    $0x1,%eax^M
7          0x0000555555555151 <test+20>:        ret^M
(gdb) FAIL: gdb.btrace/tsx.exp: speculation indication


Larsen > if it is the point of the test to only use pt, I don't think the 
addition of "target_supports_btrace" makes sense, since the 
allow_btrace_pt_tests already covers what you need. I think just a 
comment at the top of the file saying that this is a btrace pt specific 
test would suffice.

Abdul > As mentioned above target_support_btrace has check only for CPU which is not anymore in allow_btrace_pt_tests. As this check is removed from allow_btrace_pt_tests function " if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {"  so that is why both are checked.

Larsen > Otherwise, I'd like to see this test also using the BTS style.

Adbul > I have added the fail output of test above. So if you think its expected I can update the test to handle this in the test for bts case.

>> --- a/gdb/testsuite/gdb.python/py-record-btrace.exp
>> +++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
>> +require allow_btrace_bts_tests allow_btrace_pt_tests allow_python_tests
>> +require target_supports_btrace

Larsen > In this test you're requiring that both pt and bts methods of recording 
are available. Is that really necessary?
> Also, the target_supports_btrace here is reduntant, since the previous 
line is even more restrictive.

Abdul > "allow_btrace_pt_tests" function is not needed here and will be removed in V2.  As mentioned above target_supports_btrace is prerequisite before checking if the recording method "bts" or "pt" is supported so that is the reason for having it.

Thanks & Best Regards
Abdul Basit

-----Original Message-----
From: Guinevere Larsen <blarsen@redhat.com> 
Sent: Tuesday, February 13, 2024 11:16 AM
To: Ijaz, Abdul B <abdul.b.ijaz@intel.com>; gdb-patches@sourceware.org
Subject: Re: [PATCH 1/1] testsuite, btrace: update btrace testsuite to test all btrace recording methods

On 12/02/2024 17:26, Abdul Basit Ijaz wrote:
> From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>
>
> With this change, gdb.btrace will, instead of selecting the
> default recording method, run all tests for all available and
> applicable methods. This increases testing coverage.
Hi! Thanks for doing this, I think this is a great change. There's only 
one thing I don't quite understand: Why did you create a new function, 
target_supports_btrace, to do the exact function that allow_btrace_tests 
does, and make this second function work completely differently? It 
makes more sense to me to have it the other way around, where 
"allow_btrace_tests" is a generic test for any kind of btrace and 
"target_supports_btrace ${method}" tests support for the specified 
method, since it makes the diff easier to read and sounds more 
straightforward to me.

I have also a few test-specific comments inlined.

-- 
Cheers,
Guinevere Larsen
She/Her/Hers

>
> 2024-02-12 Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
> ---
>   gdb/testsuite/gdb.btrace/buffer-size.exp      |  39 +-
>   gdb/testsuite/gdb.btrace/data.exp             |  66 +--
>   gdb/testsuite/gdb.btrace/delta.exp            | 104 +++--
>   gdb/testsuite/gdb.btrace/dlopen.exp           |  39 +-
>   .../gdb.btrace/enable-new-thread.exp          |  37 +-
>   gdb/testsuite/gdb.btrace/enable-running.exp   |  61 +--
>   gdb/testsuite/gdb.btrace/enable.exp           | 155 ++++---
>   gdb/testsuite/gdb.btrace/exception.exp        | 105 +++--
>   .../gdb.btrace/function_call_history.exp      | 416 +++++++++---------
>   gdb/testsuite/gdb.btrace/gcore.exp            |  36 +-
>   .../gdb.btrace/instruction_history.exp        | 305 ++++++-------
>   gdb/testsuite/gdb.btrace/multi-inferior.exp   |  64 +--
>   .../gdb.btrace/multi-thread-step.exp          | 108 ++---
>   gdb/testsuite/gdb.btrace/nohist.exp           |  32 +-
>   gdb/testsuite/gdb.btrace/non-stop.exp         | 307 ++++++-------
>   gdb/testsuite/gdb.btrace/reconnect.exp        |  96 ++--
>   gdb/testsuite/gdb.btrace/record_goto-step.exp |  42 +-
>   gdb/testsuite/gdb.btrace/record_goto.exp      | 312 ++++++-------
>   gdb/testsuite/gdb.btrace/rn-dl-bind.exp       |  63 +--
>   gdb/testsuite/gdb.btrace/segv.exp             |  42 +-
>   gdb/testsuite/gdb.btrace/step.exp             |  50 ++-
>   gdb/testsuite/gdb.btrace/stepi.exp            | 207 ++++-----
>   gdb/testsuite/gdb.btrace/tailcall-only.exp    |  94 ++--
>   gdb/testsuite/gdb.btrace/tailcall.exp         | 138 +++---
>   gdb/testsuite/gdb.btrace/tsx.exp              |   2 +-
>   .../gdb.btrace/unknown_functions.exp          |  68 +--
>   gdb/testsuite/gdb.btrace/vdso.exp             |  36 +-
>   .../gdb.python/py-record-btrace-threads.exp   |  77 ++--
>   gdb/testsuite/gdb.python/py-record-btrace.exp |   3 +-
>   gdb/testsuite/lib/gdb.exp                     |  60 ++-
>   30 files changed, 1710 insertions(+), 1454 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.btrace/buffer-size.exp b/gdb/testsuite/gdb.btrace/buffer-size.exp
> index 1008fa8037b..8de92b43fce 100644
> --- a/gdb/testsuite/gdb.btrace/buffer-size.exp
> +++ b/gdb/testsuite/gdb.btrace/buffer-size.exp
> @@ -17,26 +17,33 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile record_goto.c
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
> -    return -1
> -}
>   
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
> -gdb_test_no_output "set record btrace bts buffer-size 1"
> -gdb_test_no_output "set record btrace pt buffer-size 1"
> -gdb_test "show record btrace bts buffer-size" "The record/replay bts buffer size is 1\."
> -gdb_test "show record btrace pt buffer-size" "The record/replay pt buffer size is 1\."
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -gdb_test_no_output "record btrace"
> -gdb_test "info record" [multi_line \
> -  "Active record target: record-btrace" \
> -  "Recording format: \[^\\\r\\\n\]*" \
> -  "Buffer size: 4kB\." \
> -  "Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
> -  ]
> +    gdb_test_no_output "set record btrace ${method} buffer-size 1"
> +    gdb_test "show record btrace ${method} buffer-size" "The record/replay ${method} buffer size is 1\."
> +
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_test "info record" [multi_line \
> +	"Active record target: record-btrace" \
> +	"Recording format: \[^\\\r\\\n\]*" \
> +	"Buffer size: 4kB\." \
> +	"Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
> +	]
> +}
> diff --git a/gdb/testsuite/gdb.btrace/data.exp b/gdb/testsuite/gdb.btrace/data.exp
> index 30a946c3633..d93c97caf24 100644
> --- a/gdb/testsuite/gdb.btrace/data.exp
> +++ b/gdb/testsuite/gdb.btrace/data.exp
> @@ -17,44 +17,52 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
> -    return -1
> -}
>   
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
> -# trace the test code
> -gdb_test_no_output "record btrace"
> -gdb_test "next" ".*main\.3.*"
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# reverse step into test
> -gdb_test "reverse-step" ".*test\.4.*"
> +    # trace the test code
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_test "next" ".*main\.3.*"
>   
> -# we can't read memory while we're replaying
> -with_test_prefix "replay" {
> -    with_test_prefix "default" {
> -	gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
> -	gdb_test "print loc" "unavailable\[^\\\r\\\n\]*"
> -    }
> +    # reverse step into test
> +    gdb_test "reverse-step" ".*test\.4.*"
>   
> -    # we can read memory if we explicitly allow it.
> -    with_test_prefix "read-write" {
> -	gdb_test_no_output "set record btrace replay-memory-access read-write"
> -	gdb_test "print glob" "1"
> -    }
> +    # we can't read memory while we're replaying
> +    with_test_prefix "replay" {
> +	with_test_prefix "default" {
> +	    gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
> +	    gdb_test "print loc" "unavailable\[^\\\r\\\n\]*"
> +	}
> +
> +	# we can read memory if we explicitly allow it.
> +	with_test_prefix "read-write" {
> +	    gdb_test_no_output "set record btrace replay-memory-access read-write"
> +	    gdb_test "print glob" "1"
> +	}
>   
> -    # we can't if we don't explicitly allow it.
> -    with_test_prefix "read-only" {
> -	gdb_test_no_output "set record btrace replay-memory-access read-only"
> -	gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
> +	# we can't if we don't explicitly allow it.
> +	with_test_prefix "read-only" {
> +	    gdb_test_no_output "set record btrace replay-memory-access read-only"
> +	    gdb_test "print glob" "unavailable\[^\\\r\\\n\]*"
> +	}
>       }
> -}
>   
> -# stop replaying and try again
> -gdb_test "record goto end" ".*main\.3.*"
> -gdb_test "print glob" "1"
> +    # stop replaying and try again
> +    gdb_test "record goto end" ".*main\.3.*"
> +    gdb_test "print glob" "1"
> +}
> diff --git a/gdb/testsuite/gdb.btrace/delta.exp b/gdb/testsuite/gdb.btrace/delta.exp
> index 4e4d06a1812..e1d30ebbc06 100644
> --- a/gdb/testsuite/gdb.btrace/delta.exp
> +++ b/gdb/testsuite/gdb.btrace/delta.exp
> @@ -17,67 +17,75 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile record_goto.c
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
> -if ![runto_main] {
> -    return -1
> +proc check_trace {} {
> +    gdb_test "info record" [multi_line \
> +	"Active record target: record-btrace" \
> +	"Recording format: .*" \
> +	"Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \
> +	]
>   }
>   
> -# proceed to some sequential code
> -gdb_test "next"
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
>   
> -# start tracing
> -gdb_test_no_output "record btrace"
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# we start without trace
> -with_test_prefix "no trace" {
> -  gdb_test "info record" [multi_line \
> -    "Active record target: record-btrace" \
> -    "Recording format: .*" \
> -    "Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for .*" \
> -    ]
> -  gdb_test "record instruction-history" "No trace\."
> -  gdb_test "record function-call-history" "No trace\."
> -}
> +    # proceed to some sequential code
> +    gdb_test "next"
>   
> -# we record each single-step, even if we have not seen a branch, yet.
> -gdb_test "stepi"
> +    # start tracing
> +    gdb_test_no_output "record btrace ${method}"
>   
> -proc check_trace {} {
> -  gdb_test "info record" [multi_line \
> -    "Active record target: record-btrace" \
> -    "Recording format: .*" \
> -    "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \
> -    ]
> -}
> +    # we start without trace
> +    with_test_prefix "no trace" {
> +	gdb_test "info record" [multi_line \
> +	    "Active record target: record-btrace" \
> +	    "Recording format: .*" \
> +	    "Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for .*" \
> +	    ]
> +	gdb_test "record instruction-history" "No trace\."
> +	gdb_test "record function-call-history" "No trace\."
> +    }
>   
> -# make sure we don't extend the trace when we ask twice.
> -with_test_prefix "once" {
> -  check_trace
> -}
> +    # we record each single-step, even if we have not seen a branch, yet.
> +    gdb_test "stepi"
>   
> -with_test_prefix "twice" {
> -  check_trace
> -}
> +    # make sure we don't extend the trace when we ask twice.
> +    with_test_prefix "once" {
> +	check_trace
> +    }
>   
> -# check that we can reverse-stepi that instruction
> -with_test_prefix "reverse" {
> -    gdb_test "reverse-stepi"
> -    gdb_test "info record" [multi_line \
> -      "Active record target: record-btrace" \
> -      "Recording format: .*" \
> -      "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \
> -      "Replay in progress\.  At instruction 1\." \
> -    ]
> -}
> +    with_test_prefix "twice" {
> +	check_trace
> +    }
>   
> -# and back
> -with_test_prefix "forward" {
> -    gdb_test "stepi"
> -    check_trace
> +    # check that we can reverse-stepi that instruction
> +    with_test_prefix "reverse" {
> +	gdb_test "reverse-stepi"
> +	gdb_test "info record" [multi_line \
> +	    "Active record target: record-btrace" \
> +	    "Recording format: .*" \
> +	    "Recorded 1 instructions in 1 functions \\\(0 gaps\\\) for .*" \
> +	    "Replay in progress\.  At instruction 1\." \
> +	    ]
> +    }
> +
> +    # and back
> +    with_test_prefix "forward" {
> +	gdb_test "stepi"
> +	check_trace
> +    }
>   }
> diff --git a/gdb/testsuite/gdb.btrace/dlopen.exp b/gdb/testsuite/gdb.btrace/dlopen.exp
> index d0e5a65e346..a21cc383a81 100644
> --- a/gdb/testsuite/gdb.btrace/dlopen.exp
> +++ b/gdb/testsuite/gdb.btrace/dlopen.exp
> @@ -15,7 +15,7 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests allow_shlib_tests
> +require target_supports_btrace allow_shlib_tests
>   
>   standard_testfile
>   
> @@ -28,23 +28,30 @@ if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
>       return -1
>   }
>   
> -if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
> +if { [build_executable "failed to prepare" $testfile $srcfile \
>   	  [list additional_flags=-DDSO_NAME=\"$binfile_lib\" libs=-ldl]] } {
>       return -1
>   }
>   
> -if ![runto_main] {
> -    return -1
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
> +
> +    # Trace the test function
> +    #
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_test "next"
> +
> +    # The memory containing the library call we traced is already gone.
> +    # Trace decode used to run into a SEGV after corrupting the cleanup chain.
> +    #
> +    # The test passes if we don't crash GDB.
> +    #
> +    gdb_test "info record"
>   }
> -
> -# Trace the test function
> -#
> -gdb_test_no_output "record btrace"
> -gdb_test "next"
> -
> -# The memory containing the library call we traced is already gone.
> -# Trace decode used to run into a SEGV after corrupting the cleanup chain.
> -#
> -# The test passes if we don't crash GDB.
> -#
> -gdb_test "info record"
> diff --git a/gdb/testsuite/gdb.btrace/enable-new-thread.exp b/gdb/testsuite/gdb.btrace/enable-new-thread.exp
> index dbbe6a78516..125485b385a 100644
> --- a/gdb/testsuite/gdb.btrace/enable-new-thread.exp
> +++ b/gdb/testsuite/gdb.btrace/enable-new-thread.exp
> @@ -17,24 +17,14 @@
>   
>   # Test that new threads of recorded inferiors also get recorded.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
> -    return -1
> -}
>   
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile {debug pthreads}] {
>       return -1
>   }
>   
> -# Record the main thread.  Recording will automatically be enabled for the
> -# other thread.
> -gdb_test "record btrace"
> -
> -gdb_breakpoint [gdb_get_line_number "bp.1" $srcfile]
> -gdb_continue_to_breakpoint "cont to bp.1" ".*/\\* bp\.1 \\*/.*"
> -
>   proc check_thread_recorded { num } {
>       global decimal
>   
> @@ -49,5 +39,24 @@ proc check_thread_recorded { num } {
>       }
>   }
>   
> -check_thread_recorded 1
> -check_thread_recorded 2
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +
> +    if ![runto_main] {
> +	continue
> +    }
> +
> +    # Record the main thread.  Recording will automatically be enabled for the
> +    # other thread.
> +    gdb_test "record btrace ${method}"
> +
> +    gdb_breakpoint [gdb_get_line_number "bp.1" $srcfile]
> +    gdb_continue_to_breakpoint "cont to bp.1" ".*/\\* bp\.1 \\*/.*"
> +
> +    check_thread_recorded 1
> +    check_thread_recorded 2
> +}
> diff --git a/gdb/testsuite/gdb.btrace/enable-running.exp b/gdb/testsuite/gdb.btrace/enable-running.exp
> index 0d3555ae739..96ff5f50c7e 100644
> --- a/gdb/testsuite/gdb.btrace/enable-running.exp
> +++ b/gdb/testsuite/gdb.btrace/enable-running.exp
> @@ -15,33 +15,14 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> -
> +require target_supports_btrace
>   standard_testfile
> +
>   if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug}] != "" } {
>       untested "failed to prepare"
>       return -1
>   }
>   
> -# We need to enable non-stop mode for the remote case.
> -save_vars { GDBFLAGS } {
> -    append GDBFLAGS " -ex \"set non-stop on\""
> -    clean_restart $testfile
> -}
> -
> -if ![runto_main] {
> -    return -1
> -}
> -
> -set bp_1 [gdb_get_line_number "bp.1" $srcfile]
> -
> -gdb_breakpoint $bp_1
> -gdb_continue_to_breakpoint "cont to $bp_1" ".*$bp_1\r\n.*"
> -gdb_test "cont&" "Continuing\."
> -
> -# All threads are running.  Let's start recording.
> -gdb_test_no_output "record btrace"
> -
>   proc check_tracing_enabled { thread } {
>       global gdb_prompt
>   
> @@ -87,10 +68,36 @@ proc check_tracing_enabled { thread } {
>       }
>   }
>   
> -# Check that recording was started on each thread.
> -foreach thread {1 2 3 4} {
> -    check_tracing_enabled $thread
> -}
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +
> +    # We need to enable non-stop mode for the remote case.
> +    save_vars { GDBFLAGS } {
> +	append GDBFLAGS " -ex \"set non-stop on\""
> +	clean_restart $testfile
> +    }
> +
> +    if ![runto_main] {
> +	continue
> +    }
> +
> +    set bp_1 [gdb_get_line_number "bp.1" $srcfile]
>   
> -# Stop recording while all threads are running.
> -gdb_test "record stop" "Process record is stopped \[^\\\r\\\n\]*"
> +    gdb_breakpoint $bp_1
> +    gdb_continue_to_breakpoint "cont to $bp_1" ".*$bp_1\r\n.*"
> +    gdb_test "cont&" "Continuing\."
> +
> +    # All threads are running.  Let's start recording.
> +    gdb_test_no_output "record btrace ${method}"
> +
> +    # Check that recording was started on each thread.
> +    foreach thread {1 2 3 4} {
> +	check_tracing_enabled $thread
> +    }
> +
> +    # Stop recording while all threads are running.
> +    gdb_test "record stop" "Process record is stopped \[^\\\r\\\n\]*"
> +}
> diff --git a/gdb/testsuite/gdb.btrace/enable.exp b/gdb/testsuite/gdb.btrace/enable.exp
> index 4e39c07472b..56c26de53cd 100644
> --- a/gdb/testsuite/gdb.btrace/enable.exp
> +++ b/gdb/testsuite/gdb.btrace/enable.exp
> @@ -17,81 +17,92 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> -
> -# start fresh - without an executable
> -gdb_exit
> -gdb_start
> -
> -# record cannot be stopped, if it was never active
> -gdb_test "record stop" "No recording is currently active\\..*" "record stop without target"
> -
> -# btrace cannot be enabled without a running inferior
> -gdb_test "record btrace" "The program is not being run\\." "record btrace without running program"
> -
> -# no function and no instruction history without btrace enabled
> -gdb_test "record function-call-history" "No recording is currently active\\..*" "record function-call-history without target"
> -gdb_test "record instruction-history" "No recording is currently active\\..*" "record instruction-history without target"
> -gdb_test "info record" "No recording is currently active\\." "info record without target"
> +require target_supports_btrace
>   
>   standard_testfile
> -if [prepare_for_testing "failed to prepare" $testfile {} {debug}] {
> -    return -1
> -}
> -
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile {} {debug}] {
>       return -1
>   }
>   
> -# enable btrace
> -gdb_test_no_output "record btrace" "record btrace"
> -gdb_test "record function-call-history" "No trace\\." "record function-call-history without trace"
> -gdb_test "record instruction-history" "No trace\\." "record instruction-history without trace"
> -
> -# btrace cannot be enabled twice
> -gdb_test "record btrace" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record btrace the second time"
> -
> -# full record cannot be activated as long as btrace is active
> -gdb_test "record full" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record full cannot be enabled"
> -
> -# no trace recorded yet
> -gdb_test "info record" "Active record target: record-btrace\r
> -.*\r
> -Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for thread 1.*\\." "info record without trace"
> -
> -# stop btrace record
> -gdb_test "record stop" "Process record is stopped and all execution logs are deleted\\."
> -gdb_test "record stop" "No recording is currently active\\..*" "record stop the second time"
> -
> -# enable btrace again
> -gdb_test_no_output "record btrace" "record btrace re-enable"
> -gdb_test "record btrace" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record btrace re-enable twice"
> -
> -# continue to the end and make sure we don't die
> -gdb_test "continue" ".*Inferior.*exited.*" "continue to end"
> -
> -# allow_gdbserver_tests requires GDB not running.
> -gdb_exit
> -
> -# skip the rerun test when using gdbserver
> -# otherwise rerun twice, target should be automatically disabled
> -load_lib gdbserver-support.exp
> -require allow_gdbserver_tests
> -clean_restart $testfile
> -if ![runto_main] {
> -    return -1
> -}
> -if ![runto_main] {
> -    return -1
> -}
> -
> -# make sure record-btrace can be enabled after re-run
> -clean_restart $testfile
> -if ![runto_main] {
> -    return -1
> -}
> -gdb_test_no_output "record btrace" "enable after restart"
> -if ![runto_main] {
> -    return -1
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
> +
> +    # start fresh - without an executable
> +    gdb_exit
> +    gdb_start
> +
> +    # record cannot be stopped, if it was never active
> +    gdb_test "record stop" "No recording is currently active\\..*" "record stop without target"
> +
> +    # btrace cannot be enabled without a running inferior
> +    gdb_test "record btrace ${method}" "The program is not being run\\." "record btrace without running program"
> +
> +    # no function and no instruction history without btrace enabled
> +    gdb_test "record function-call-history" "No recording is currently active\\..*" "record function-call-history without target"
> +    gdb_test "record instruction-history" "No recording is currently active\\..*" "record instruction-history without target"
> +    gdb_test "info record" "No recording is currently active\\." "info record without target"
> +
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
> +
> +    # enable btrace
> +    gdb_test_no_output "record btrace ${method}" "record btrace ${method}"
> +    gdb_test "record function-call-history" "No trace\\." "record function-call-history without trace"
> +    gdb_test "record instruction-history" "No trace\\." "record instruction-history without trace"
> +
> +    # btrace cannot be enabled twice
> +    gdb_test "record btrace ${method}" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record btrace ${method} the second time"
> +
> +    # full record cannot be activated as long as btrace is active
> +    gdb_test "record full" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record full cannot be enabled"
> +
> +    # no trace recorded yet
> +    gdb_test "info record" "Active record target: record-btrace\r.*Recorded 0 instructions in 0 functions \\\(0 gaps\\\) for thread 1.*\\." "info record without trace"
> +
> +    # stop btrace record
> +    gdb_test "record stop" "Process record is stopped and all execution logs are deleted\\."
> +    gdb_test "record stop" "No recording is currently active\\..*" "record stop the second time"
> +
> +    # enable btrace again
> +    gdb_test_no_output "record btrace ${method}" "record btrace ${method} re-enable"
> +    gdb_test "record btrace ${method}" "The process is already being recorded\\.  Use \"record stop\" to stop recording first\\." "record btrace ${method} re-enable twice"
> +
> +    # continue to the end and make sure we don't die
> +    gdb_test "continue" ".*Inferior.*exited.*" "continue to end"
> +
> +    # allow_gdbserver_tests requires GDB not running.
> +    gdb_exit
> +
> +    # skip the rerun test when using gdbserver
> +    # otherwise rerun twice, target should be automatically disabled
> +    load_lib gdbserver-support.exp
> +    require allow_gdbserver_tests
> +    clean_restart $testfile
> +    if ![runto_main] {
> +	continue
> +    }
> +    if ![runto_main] {
> +	continue
> +    }
> +
> +    # make sure record-btrace can be enabled after re-run
> +    clean_restart $testfile
> +    if ![runto_main] {
> +	continue
> +    }
> +    gdb_test_no_output "record btrace" "enable after restart"
> +    if ![runto_main] {
> +	continue
> +    }
> +    gdb_test_no_output "record btrace" "enable after re-run"
>   }
> -gdb_test_no_output "record btrace" "enable after re-run"
> diff --git a/gdb/testsuite/gdb.btrace/exception.exp b/gdb/testsuite/gdb.btrace/exception.exp
> index 61cc6c904b6..c208d50e560 100755
> --- a/gdb/testsuite/gdb.btrace/exception.exp
> +++ b/gdb/testsuite/gdb.btrace/exception.exp
> @@ -17,64 +17,73 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   # We expect a specific function call history.  This gets messed up with
>   # PIE on 32-bit.
>   standard_testfile exception.cc
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile \
> +
> +if [build_executable "failed to prepare" $testfile $srcfile \
>   	{nopie c++ debug}] {
>       return -1
>   }
>   
> -if ![runto_main] {
> -    return -1
> -}
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
>   
> -# we want to see the full trace for this test
> -gdb_test_no_output "set record function-call-history-size 0"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# set bp
> -set bp_1 [gdb_get_line_number "bp.1" $srcfile]
> -set bp_2 [gdb_get_line_number "bp.2" $srcfile]
> -gdb_breakpoint $bp_1
> -gdb_breakpoint $bp_2
> +    # we want to see the full trace for this test
> +    gdb_test_no_output "set record function-call-history-size 0"
>   
> -# trace the code between the two breakpoints
> -gdb_continue_to_breakpoint "cont to bp.1" ".*$srcfile:$bp_1\r\n.*"
> -# increase the BTS buffer size - the trace can be quite big
> -gdb_test_no_output "set record btrace bts buffer-size 128000"
> -gdb_test_no_output "record btrace"
> -gdb_continue_to_breakpoint "cont to bp.2" ".*$srcfile:$bp_2\r\n.*"
> +    # set bp
> +    set bp_1 [gdb_get_line_number "bp.1" $srcfile]
> +    set bp_2 [gdb_get_line_number "bp.2" $srcfile]
> +    gdb_breakpoint $bp_1
> +    gdb_breakpoint $bp_2
>   
> -# show the flat branch trace
> -send_gdb "record function-call-history 1\n"
> -gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \
> -  [multi_line \
> -    "1\tmain\\(\\)" \
> -    "2\ttest\\(\\)" \
> -    "3\tfoo\\(\\)" \
> -    "4\tbar\\(\\)" \
> -    "5\tbad\\(\\)\r" \
> -  ] "" \
> -  [multi_line \
> -    "\[0-9\]*\ttest\\(\\)" \
> -    "\[0-9\]*\tmain\\(\\)" \
> -  ] "" \
> -  ]
> +    # trace the code between the two breakpoints
> +    gdb_continue_to_breakpoint "cont to bp.1" ".*$srcfile:$bp_1\r\n.*"
> +    # increase the BTS buffer size - the trace can be quite big for bts method
> +    gdb_test_no_output "set record btrace ${method} buffer-size 128000"
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_continue_to_breakpoint "cont to bp.2" ".*$srcfile:$bp_2\r\n.*"
>   
> -# show the branch trace with calls indented
> -send_gdb "record function-call-history /c 1\n"
> -gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
> -  [multi_line \
> -    "1\tmain\\(\\)" \
> -    "2\t  test\\(\\)" \
> -    "3\t    foo\\(\\)" \
> -    "4\t      bar\\(\\)" \
> -    "5\t        bad\\(\\)\r" \
> -  ] "" \
> -  [multi_line \
> -    "\[0-9\]*\t  test\\(\\)" \
> -    "\[0-9\]*\tmain\\(\\)" \
> -  ] "" \
> -  ]
> +    # show the flat branch trace
> +    send_gdb "record function-call-history 1\n"
> +    gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \
> +	[multi_line \
> +	    "1\tmain\\(\\)" \
> +	    "2\ttest\\(\\)" \
> +	    "3\tfoo\\(\\)" \
> +	    "4\tbar\\(\\)" \
> +	    "5\tbad\\(\\)\r" \
> +	] "" \
> +	[multi_line \
> +	    "\[0-9\]*\ttest\\(\\)" \
> +	    "\[0-9\]*\tmain\\(\\)" \
> +	] "" \
> +    ]
> +
> +    # show the branch trace with calls indented
> +    send_gdb "record function-call-history /c 1\n"
> +    gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
> +	[multi_line \
> +	    "1\tmain\\(\\)" \
> +	    "2\t  test\\(\\)" \
> +	    "3\t    foo\\(\\)" \
> +	    "4\t      bar\\(\\)" \
> +	    "5\t        bad\\(\\)\r" \
> +	] "" \
> +	[multi_line \
> +	    "\[0-9\]*\t  test\\(\\)" \
> +	    "\[0-9\]*\tmain\\(\\)" \
> +	] "" \
> +    ]
> +}
> diff --git a/gdb/testsuite/gdb.btrace/function_call_history.exp b/gdb/testsuite/gdb.btrace/function_call_history.exp
> index ce3d1a02ff6..c7ece1db52c 100644
> --- a/gdb/testsuite/gdb.btrace/function_call_history.exp
> +++ b/gdb/testsuite/gdb.btrace/function_call_history.exp
> @@ -17,27 +17,20 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   # We expect a specific function call history.  This gets messed up with
>   # PIE on 32-bit.
>   standard_testfile
> -if [prepare_for_testing "failed to prepare" $testfile {} {nopie debug}] {
> +if {![target_supports_btrace]} {
> +    unsupported "target does not support btrace."
This is duplicating the previous "require target_supports_btrace" line
>       return -1
>   }
>   
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile {} {nopie debug}] {
>       return -1
>   }
>   
> -# start btrace
> -gdb_test_no_output "record btrace"
> -
> -# set bp after increment loop and continue
> -set bp_location [gdb_get_line_number "bp.1" $testfile.c]
> -gdb_breakpoint $bp_location
> -gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
> -
>   proc rec_fun_all {} {
>     gdb_test "record function-call-history 1" [multi_line \
>       "1\tmain" \
> @@ -63,194 +56,215 @@ proc rec_fun_all {} {
>       "21\tmain"]
>   }
>   
> -# show function call history with unlimited size, we expect to see all 21 entries
> -gdb_test_no_output "set record function-call-history-size 0"
> -with_test_prefix "size unlimited" rec_fun_all
> -
> -# show function call history with size of 21, we expect to see all 21 entries
> -gdb_test_no_output "set record function-call-history-size 21"
> -with_test_prefix "size 21" rec_fun_all
> -
> -# show first 15 entries
> -gdb_test_no_output "set record function-call-history-size 15"
> -gdb_test "record function-call-history 1" [multi_line \
> -  "1\tmain" \
> -  "2\tinc" \
> -  "3\tmain" \
> -  "4\tinc" \
> -  "5\tmain" \
> -  "6\tinc" \
> -  "7\tmain" \
> -  "8\tinc" \
> -  "9\tmain" \
> -  "10\tinc" \
> -  "11\tmain" \
> -  "12\tinc" \
> -  "13\tmain" \
> -  "14\tinc" \
> -  "15\tmain"] "forward - 1"
> -
> -# show last 6 entries
> -gdb_test "record function-call-history +" [multi_line \
> -  "16\tinc" \
> -  "17\tmain" \
> -  "18\tinc" \
> -  "19\tmain" \
> -  "20\tinc" \
> -  "21\tmain"] "forward - 2"
> -
> -# moving further should not work
> -gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 3"
> -
> -# make sure we cannot move any further a second time
> -gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 4"
> -
> -# moving back showing the latest 15 function calls
> -gdb_test "record function-call-history -" [multi_line \
> -  "7\tmain" \
> -  "8\tinc" \
> -  "9\tmain" \
> -  "10\tinc" \
> -  "11\tmain" \
> -  "12\tinc" \
> -  "13\tmain" \
> -  "14\tinc" \
> -  "15\tmain" \
> -  "16\tinc" \
> -  "17\tmain" \
> -  "18\tinc" \
> -  "19\tmain" \
> -  "20\tinc" \
> -  "21\tmain"] "backward - 1"
> -
> -# moving further back shows the 6 first function calls
> -gdb_test "record function-call-history -" [multi_line \
> -  "1\tmain" \
> -  "2\tinc" \
> -  "3\tmain" \
> -  "4\tinc" \
> -  "5\tmain" \
> -  "6\tinc"] "backward - 2"
> -
> -# moving further back shouldn't work
> -gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 3"
> -
> -# make sure we cannot move any further back
> -gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 4"
> -
> -# don't mess around with path names
> -gdb_test_no_output "set filename-display basename"
> -
> -# moving forward again, but this time with file and line number, expected to see the first 15 entries
> -gdb_test "record function-call-history /l +" [multi_line \
> -  "\[0-9\]*\tmain\tat $srcfile:40,41" \
> -  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> -  "\[0-9\]*\tmain\tat $srcfile:40,41" \
> -  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> -  "\[0-9\]*\tmain\tat $srcfile:40,41" \
> -  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> -  "\[0-9\]*\tmain\tat $srcfile:40,41" \
> -  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> -  "\[0-9\]*\tmain\tat $srcfile:40,41" \
> -  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> -  "\[0-9\]*\tmain\tat $srcfile:40,41" \
> -  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> -  "\[0-9\]*\tmain\tat $srcfile:40,41" \
> -  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> -  "\[0-9\]*\tmain\tat $srcfile:40,41" \
> -  ] "forward /l - 1"
> -
> -# moving forward and expect to see the latest 6 entries
> -gdb_test "record function-call-history /l +" [multi_line \
> -  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> -  "\[0-9\]*\tmain\tat $srcfile:40,41" \
> -  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> -  "\[0-9\]*\tmain\tat $srcfile:40,41" \
> -  "\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> -  "\[0-9\]*\tmain\tat $srcfile:40,43" \
> -  ] "forward /l - 2"
> -
> -# moving further forward shouldn't work
> -gdb_test "record function-call-history /l +" "At the end of the branch trace record\\." "forward /l - 3"
> -gdb_test "record function-call-history /l" "At the end of the branch trace record\\." "forward /l - 4"
> -
> -set expected_range [multi_line \
> -  "4\tinc" \
> -  "5\tmain" \
> -  "6\tinc" \
> -  "7\tmain" \
> -  "8\tinc" \
> -  "9\tmain" \
> -  "10\tinc"]
> -
> -# show functions in instruction range
> -gdb_test "record function-call-history 4,10" $expected_range
> -gdb_test "record function-call-history 4,+7" $expected_range
> -gdb_test "record function-call-history 10,-7" $expected_range
> -gdb_test "record function-call-history 4,4" "4\tinc"
> -
> -# set bp after fib recursion and continue
> -set bp_location [gdb_get_line_number "bp.2" $testfile.c]
> -gdb_breakpoint $bp_location
> -gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
> -
> -# at this point we expect to have main, fib, ..., fib, main, where fib occurs 9 times,
> -# so we limit the output to only show the latest 11 function calls
> -gdb_test_no_output "set record function-call-history-size 11"
> -gdb_test "record function-call-history" [multi_line \
> -  "21\tmain" \
> -  "22\tfib" \
> -  "23\tfib" \
> -  "24\tfib" \
> -  "25\tfib" \
> -  "26\tfib" \
> -  "27\tfib" \
> -  "28\tfib" \
> -  "29\tfib" \
> -  "30\tfib" \
> -  "31\tmain"] "recursive"
> -
> -# show indented function call history for fib
> -gdb_test "record function-call-history /c 21, +11" [multi_line \
> -  "21\tmain" \
> -  "22\t  fib" \
> -  "23\t    fib" \
> -  "24\t  fib" \
> -  "25\t    fib" \
> -  "26\t      fib" \
> -  "27\t    fib" \
> -  "28\t      fib" \
> -  "29\t    fib" \
> -  "30\t  fib" \
> -  "31\tmain" \
> -  ] "indented"
> -
> -# make sure we can handle incomplete trace with respect to indentation
> -if ![runto_main] {
> -    return -1
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +
> +    if ![runto_main] {
> +	continue
> +    }
> +
> +    # start btrace
> +    gdb_test_no_output "record btrace ${method}"
> +
> +    # set bp after increment loop and continue
> +    set bp_location [gdb_get_line_number "bp.1" $testfile.c]
> +    gdb_breakpoint $bp_location
> +    gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
> +
> +    # show function call history with unlimited size, we expect to see all 21 entries
> +    gdb_test_no_output "set record function-call-history-size 0"
> +    with_test_prefix "size unlimited" rec_fun_all
> +
> +    # show function call history with size of 21, we expect to see all 21 entries
> +    gdb_test_no_output "set record function-call-history-size 21"
> +    with_test_prefix "size 21" rec_fun_all
> +
> +    # show first 15 entries
> +    gdb_test_no_output "set record function-call-history-size 15"
> +    gdb_test "record function-call-history 1" [multi_line \
> +	"1\tmain" \
> +	"2\tinc" \
> +	"3\tmain" \
> +	"4\tinc" \
> +	"5\tmain" \
> +	"6\tinc" \
> +	"7\tmain" \
> +	"8\tinc" \
> +	"9\tmain" \
> +	"10\tinc" \
> +	"11\tmain" \
> +	"12\tinc" \
> +	"13\tmain" \
> +	"14\tinc" \
> +	"15\tmain"] "forward - 1"
> +
> +    # show last 6 entries
> +    gdb_test "record function-call-history +" [multi_line \
> +	"16\tinc" \
> +	"17\tmain" \
> +	"18\tinc" \
> +	"19\tmain" \
> +	"20\tinc" \
> +	"21\tmain"] "forward - 2"
> +
> +    # moving further should not work
> +    gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 3"
> +
> +    # make sure we cannot move any further a second time
> +    gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 4"
> +
> +    # moving back showing the latest 15 function calls
> +    gdb_test "record function-call-history -" [multi_line \
> +	"7\tmain" \
> +	"8\tinc" \
> +	"9\tmain" \
> +	"10\tinc" \
> +	"11\tmain" \
> +	"12\tinc" \
> +	"13\tmain" \
> +	"14\tinc" \
> +	"15\tmain" \
> +	"16\tinc" \
> +	"17\tmain" \
> +	"18\tinc" \
> +	"19\tmain" \
> +	"20\tinc" \
> +	"21\tmain"] "backward - 1"
> +
> +    # moving further back shows the 6 first function calls
> +    gdb_test "record function-call-history -" [multi_line \
> +	"1\tmain" \
> +	"2\tinc" \
> +	"3\tmain" \
> +	"4\tinc" \
> +	"5\tmain" \
> +	"6\tinc"] "backward - 2"
> +
> +    # moving further back shouldn't work
> +    gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 3"
> +
> +    # make sure we cannot move any further back
> +    gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 4"
> +
> +    # don't mess around with path names
> +    gdb_test_no_output "set filename-display basename"
> +
> +    # moving forward again, but this time with file and line number, expected to see the first 15 entries
> +    gdb_test "record function-call-history /l +" [multi_line \
> +	"\[0-9\]*\tmain\tat $srcfile:40,41" \
> +	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> +	"\[0-9\]*\tmain\tat $srcfile:40,41" \
> +	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> +	"\[0-9\]*\tmain\tat $srcfile:40,41" \
> +	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> +	"\[0-9\]*\tmain\tat $srcfile:40,41" \
> +	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> +	"\[0-9\]*\tmain\tat $srcfile:40,41" \
> +	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> +	"\[0-9\]*\tmain\tat $srcfile:40,41" \
> +	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> +	"\[0-9\]*\tmain\tat $srcfile:40,41" \
> +	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> +	"\[0-9\]*\tmain\tat $srcfile:40,41" \
> +    ] "forward /l - 1"
> +
> +    # moving forward and expect to see the latest 6 entries
> +    gdb_test "record function-call-history /l +" [multi_line \
> +	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> +	"\[0-9\]*\tmain\tat $srcfile:40,41" \
> +	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> +	"\[0-9\]*\tmain\tat $srcfile:40,41" \
> +	"\[0-9\]*\tinc\tat $srcfile:22,2\[34\]" \
> +	"\[0-9\]*\tmain\tat $srcfile:40,43" \
> +
> +    ] "forward /l - 2"
> +
> +    # moving further forward shouldn't work
> +    gdb_test "record function-call-history /l +" "At the end of the branch trace record\\." "forward /l - 3"
> +    gdb_test "record function-call-history /l" "At the end of the branch trace record\\." "forward /l - 4"
> +
> +    set expected_range [multi_line \
> +	"4\tinc" \
> +	"5\tmain" \
> +	"6\tinc" \
> +	"7\tmain" \
> +	"8\tinc" \
> +	"9\tmain" \
> +	"10\tinc"]
> +
> +    # show functions in instruction range
> +    gdb_test "record function-call-history 4,10" $expected_range
> +    gdb_test "record function-call-history 4,+7" $expected_range
> +    gdb_test "record function-call-history 10,-7" $expected_range
> +    gdb_test "record function-call-history 4,4" "4\tinc"
> +
> +    # set bp after fib recursion and continue
> +    set bp_location [gdb_get_line_number "bp.2" $testfile.c]
> +    gdb_breakpoint $bp_location
> +    gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
> +
> +    # at this point we expect to have main, fib, ..., fib, main, where fib occurs 9 times,
> +    # so we limit the output to only show the latest 11 function calls
> +    gdb_test_no_output "set record function-call-history-size 11"
> +    gdb_test "record function-call-history" [multi_line \
> +	"21\tmain" \
> +	"22\tfib" \
> +	"23\tfib" \
> +	"24\tfib" \
> +	"25\tfib" \
> +	"26\tfib" \
> +	"27\tfib" \
> +	"28\tfib" \
> +	"29\tfib" \
> +	"30\tfib" \
> +	"31\tmain"] "recursive"
> +
> +    # show indented function call history for fib
> +    gdb_test "record function-call-history /c 21, +11" [multi_line \
> +	"21\tmain" \
> +	"22\t  fib" \
> +	"23\t    fib" \
> +	"24\t  fib" \
> +	"25\t    fib" \
> +	"26\t      fib" \
> +	"27\t    fib" \
> +	"28\t      fib" \
> +	"29\t    fib" \
> +	"30\t  fib" \
> +	"31\tmain" \
> +    ] "indented"
> +
> +    # make sure we can handle incomplete trace with respect to indentation
> +    if ![runto_main] {
> +	return -1
> +    }
> +    # navigate to the fib in line 24 above
> +    gdb_breakpoint fib
> +    gdb_continue_to_breakpoint "cont to fib.1"
> +    gdb_continue_to_breakpoint "cont to fib.2"
> +    gdb_continue_to_breakpoint "cont to fib.3"
> +    gdb_continue_to_breakpoint "cont to fib.4"
> +
> +    # start tracing
> +    gdb_test_no_output "record btrace ${method}" "start recording after rerun"
> +
> +    # continue until line 30 above
> +    delete_breakpoints
> +    set bp_location [gdb_get_line_number "bp.2" $testfile.c]
> +    gdb_breakpoint $bp_location
> +    gdb_continue_to_breakpoint "cont to bp.2" ".*$testfile.c:$bp_location\r\n.*"
> +
> +    # let's look at the trace. we expect to see the tail of the above listing.
> +    gdb_test "record function-call-history /c" [multi_line \
> +	"1\t      fib" \
> +	"2\t    fib" \
> +	"3\t      fib" \
> +	"4\t    fib" \
> +	"5\t  fib" \
> +	"6\tmain" \
> +    ] "indented tail"
>   }
> -# navigate to the fib in line 24 above
> -gdb_breakpoint fib
> -gdb_continue_to_breakpoint "cont to fib.1"
> -gdb_continue_to_breakpoint "cont to fib.2"
> -gdb_continue_to_breakpoint "cont to fib.3"
> -gdb_continue_to_breakpoint "cont to fib.4"
> -
> -# start tracing
> -gdb_test_no_output "record btrace" "start recording after rerun"
> -
> -# continue until line 30 above
> -delete_breakpoints
> -set bp_location [gdb_get_line_number "bp.2" $testfile.c]
> -gdb_breakpoint $bp_location
> -gdb_continue_to_breakpoint "cont to bp.2" ".*$testfile.c:$bp_location\r\n.*"
> -
> -# let's look at the trace. we expect to see the tail of the above listing.
> -gdb_test "record function-call-history /c" [multi_line \
> -  "1\t      fib" \
> -  "2\t    fib" \
> -  "3\t      fib" \
> -  "4\t    fib" \
> -  "5\t  fib" \
> -  "6\tmain" \
> -  ] "indented tail"
> diff --git a/gdb/testsuite/gdb.btrace/gcore.exp b/gdb/testsuite/gdb.btrace/gcore.exp
> index ff607b5643c..d63ac2e83e8 100644
> --- a/gdb/testsuite/gdb.btrace/gcore.exp
> +++ b/gdb/testsuite/gdb.btrace/gcore.exp
> @@ -17,25 +17,33 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile record_goto.c
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
> -    return -1
> -}
>   
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
> -# trace the call to the test function
> -gdb_test_no_output "record btrace"
> -gdb_test "next" ".*main\.3.*"
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# start replaying
> -gdb_test "record goto begin" ".*main\.2.*"
> +    # trace the call to the test function
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_test "next" ".*main\.3.*"
>   
> -# generate a core file - this used to assert
> -set corefile [host_standard_output_file core]
> -gdb_test "generate-core-file $corefile" "Saved corefile $corefile" \
> -    "generate-core-file core"
> +    # start replaying
> +    gdb_test "record goto begin" ".*main\.2.*"
> +
> +    # generate a core file - this used to assert
> +    set corefile [standard_output_file core]
> +    gdb_test "generate-core-file $corefile" "Saved corefile $corefile" \
> +	"generate-core-file core"
> +}
> diff --git a/gdb/testsuite/gdb.btrace/instruction_history.exp b/gdb/testsuite/gdb.btrace/instruction_history.exp
> index d3ff313c570..32c21a91670 100644
> --- a/gdb/testsuite/gdb.btrace/instruction_history.exp
> +++ b/gdb/testsuite/gdb.btrace/instruction_history.exp
> @@ -17,91 +17,13 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile .c .S
> -if [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" {debug}] {
> +if [build_executable "failed to prepare" $testfile "$srcfile $srcfile2" {debug}] {
>       return -1
>   }
>   
> -if ![runto_main] {
> -    return -1
> -}
> -
> -# set bp before loop and continue
> -set bp_location [gdb_get_line_number "bp.1" $srcfile2]
> -gdb_breakpoint $srcfile2:$bp_location
> -gdb_continue_to_breakpoint "cont to $bp_location" ".*$srcfile2:$bp_location.*"
> -
> -# start btrace
> -gdb_test_no_output "record btrace"
> -
> -# set bp after loop and continue
> -set bp_location [gdb_get_line_number "bp.2" $srcfile2]
> -gdb_breakpoint $srcfile2:$bp_location
> -gdb_continue_to_breakpoint "cont to $bp_location" ".*$srcfile2:$bp_location.*"
> -
> -# The following test cases test if "browsing" through the
> -# instruction history works as expected. So for the tests
> -# it is necessary to count the number of lines that are
> -# shown by the "record instruction-history" command.
> -
> -set traced {}
> -set testname "determine number of recorded instructions"
> -gdb_test_multiple "info record" $testname {
> -    -re "Active record target: record-btrace\r\n.*\r\nRecorded \(\[0-9\]*\) instructions in \(\[0-9\]*\) functions \\\(0 gaps\\\) for thread 1 .*\\.\r\n$gdb_prompt $" {
> -        set traced $expect_out(1,string)
> -        pass $testname
> -    }
> -}
> -
> -# we have exactly 11 instructions here
> -set message "exactly 11 instructions"
> -if { $traced != 11 } {
> -    fail $message
> -} else {
> -    pass $message
> -}
> -
> -# test that we see the expected instructions
> -gdb_test "record instruction-history 3,7" [multi_line \
> -  "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  "4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
> -  "5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  "6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
> -  "7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  ]
> -
> -gdb_test "record instruction-history /f 3,+5" [multi_line \
> -  "3\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  "4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
> -  "5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  "6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
> -  "7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  ]
> -
> -gdb_test "record instruction-history /p 7,-5" [multi_line \
> -  "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  "4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
> -  "5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  "6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
> -  "7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  ]
> -
> -gdb_test "record instruction-history /pf 3,7" [multi_line \
> -  "3\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  "4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
> -  "5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  "6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
> -  "7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> -  ]
> -
> -gdb_test "record instruction-history 3,3" "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>"
> -
> -# the following tests are checking the iterators
> -# to avoid lots of regexps, we just check the number of lines that
> -# were printed during command execution.
> -
>   # test_lines_output returns the output lines from command as a list.
>   proc test_lines_output { command message } {
>       global gdb_prompt
> @@ -118,83 +40,168 @@ proc test_lines_length { command message } {
>       return [llength [test_lines_output $command $message]]
>   }
>   
> -# show instruction history with unlimited size, we expect to see
> -# all $traced instructions
> -gdb_test_no_output "set record instruction-history-size 0"
> -set message "record instruction-history - unlimited"
> -set lines [test_lines_length "record instruction-history 1" $message]
> -if { $traced != $lines } {
> -    fail $message
> -} else {
> -    pass $message
> -}
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
>   
> -gdb_test_no_output "set record instruction-history-size $traced"
> -set message "record instruction-history - traced"
> -set lines [test_lines_length "record instruction-history 1" $message]
> -if { $traced != $lines } {
> -    fail $message
> -} else {
> -    pass $message
> -}
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
> +    # set bp before loop and continue
> +    set bp_location [gdb_get_line_number "bp.1" $srcfile2]
> +    gdb_breakpoint $srcfile2:$bp_location
> +    gdb_continue_to_breakpoint "cont to $bp_location" ".*$srcfile2:$bp_location.*"
> +
> +    # start btrace
> +    gdb_test_no_output "record btrace ${method}"
> +
> +    # set bp after loop and continue
> +    set bp_location [gdb_get_line_number "bp.2" $srcfile2]
> +    gdb_breakpoint $srcfile2:$bp_location
> +    gdb_continue_to_breakpoint "cont to $bp_location" ".*$srcfile2:$bp_location.*"
> +
> +    # The following test cases test if "browsing" through the
> +    # instruction history works as expected.  So for the tests
> +    # it is necessary to count the number of lines that are
> +    # shown by the "record instruction-history" command.
> +
> +    set traced {}
> +    set testname "determine number of recorded instructions"
> +    gdb_test_multiple "info record" $testname {
> +	-re "Active record target: record-btrace\r\n.*\r\nRecorded \(\[0-9\]*\) instructions in \(\[0-9\]*\) functions \\\(0 gaps\\\) for thread 1 .*\\.\r\n$gdb_prompt $" {
> +	    set traced $expect_out(1,string)
> +	    pass $testname
> +	}
> +    }
>   
> -# test that the iterator works
> -set history_size 4
> -gdb_test_no_output "set record instruction-history-size $history_size"
> -set message "browse history forward start"
> -set lines [test_lines_length "record instruction-history 1" $message]
> -if { $lines != $history_size } {
> -    fail $message
> -} else {
> -    pass $message
> -}
> +    # we have exactly 11 instructions here
> +    set message "exactly 11 instructions"
> +    if { $traced != 11 } {
> +	fail $message
> +    } else {
> +	pass $message
> +    }
>   
> -set message "browse history forward middle"
> -set lines [test_lines_length "record instruction-history +" $message]
> -if { $lines != $history_size } {
> -    fail $message
> -} else {
> -    pass $message
> -}
> +    # test that we see the expected instructions
> +    gdb_test "record instruction-history 3,7" [multi_line \
> +	"3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	"4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
> +	"5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	"6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
> +	"7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	]
> +
> +    gdb_test "record instruction-history /f 3,+5" [multi_line \
> +	"3\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	"4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
> +	"5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	"6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
> +	"7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	]
> +
> +    gdb_test "record instruction-history /p 7,-5" [multi_line \
> +	"3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	"4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
> +	"5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	"6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
> +	"7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	]
> +
> +    gdb_test "record instruction-history /pf 3,7" [multi_line \
> +	"3\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	"4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
> +	"5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	"6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
> +	"7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
> +	]
> +
> +    gdb_test "record instruction-history 3,3" "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>"
> +
> +    # the following tests are checking the iterators
> +    # to avoid lots of regexps, we just check the number of lines that
> +    # were printed during command execution.
> +
> +    # show instruction history with unlimited size, we expect to see
> +    # all $traced instructions
> +    gdb_test_no_output "set record instruction-history-size 0"
> +    set message "record instruction-history - unlimited"
> +    set lines [test_lines_length "record instruction-history 1" $message]
> +    if { $traced != $lines } {
> +	fail $message
> +    } else {
> +	pass $message
> +    }
>   
> -set message "browse history forward last"
> -set lines [test_lines_length "record instruction-history +" $message]
> -if { $lines != 3 } {
> -    fail $message
> -} else {
> -    pass $message
> -}
> +    gdb_test_no_output "set record instruction-history-size $traced"
> +    set message "record instruction-history - traced"
> +    set lines [test_lines_length "record instruction-history 1" $message]
> +    if { $traced != $lines } {
> +	fail $message
> +    } else {
> +	pass $message
> +    }
>   
> -gdb_test "record instruction-history" "At the end of the branch trace record\\." "browse history forward beyond 1"
> +    # test that the iterator works
> +    set history_size 4
> +    gdb_test_no_output "set record instruction-history-size $history_size"
> +    set message "browse history forward start"
> +    set lines [test_lines_length "record instruction-history 1" $message]
> +    if { $lines != $history_size } {
> +	fail $message
> +    } else {
> +	pass $message
> +    }
>   
> -# make sure we cannot move further
> -gdb_test "record instruction-history" "At the end of the branch trace record\\." "browse history forward beyond 2"
> +    set message "browse history forward middle"
> +    set lines [test_lines_length "record instruction-history +" $message]
> +    if { $lines != $history_size } {
> +	fail $message
> +    } else {
> +	pass $message
> +    }
>   
> -set message "browse history backward last"
> -set lines [test_lines_length "record instruction-history -" $message]
> -if { $lines != $history_size } {
> -    fail $message
> -} else {
> -    pass $message
> -}
> +    set message "browse history forward last"
> +    set lines [test_lines_length "record instruction-history +" $message]
> +    if { $lines != 3 } {
> +	fail $message
> +    } else {
> +	pass $message
> +    }
>   
> -set message "browse history backward middle"
> -set lines [test_lines_length "record instruction-history -" $message]
> -if { $lines != $history_size } {
> -    fail $message
> -} else {
> -    pass $message
> -}
> +    gdb_test "record instruction-history" "At the end of the branch trace record\\." "browse history forward beyond 1"
>   
> -set message "browse history backward first"
> -set lines [test_lines_length "record instruction-history -" $message]
> -if { $lines != 3 } {
> -    fail $message
> -} else {
> -    pass $message
> -}
> +    # make sure we cannot move further
> +    gdb_test "record instruction-history" "At the end of the branch trace record\\." "browse history forward beyond 2"
> +
> +    set message "browse history backward last"
> +    set lines [test_lines_length "record instruction-history -" $message]
> +    if { $lines != $history_size } {
> +	fail $message
> +    } else {
> +	pass $message
> +    }
> +
> +    set message "browse history backward middle"
> +    set lines [test_lines_length "record instruction-history -" $message]
> +    if { $lines != $history_size } {
> +	fail $message
> +    } else {
> +	pass $message
> +    }
> +
> +    set message "browse history backward first"
> +    set lines [test_lines_length "record instruction-history -" $message]
> +    if { $lines != 3 } {
> +	fail $message
> +    } else {
> +	pass $message
> +    }
>   
> -gdb_test "record instruction-history -" "At the start of the branch trace record\\." "browse history backward beyond 1"
> +    gdb_test "record instruction-history -" "At the start of the branch trace record\\." "browse history backward beyond 1"
>   
> -# make sure we cannot move further back
> -gdb_test "record instruction-history -" "At the start of the branch trace record\\." "browse history backward beyond 2"
> +    # make sure we cannot move further back
> +    gdb_test "record instruction-history -" "At the start of the branch trace record\\." "browse history backward beyond 2"
> +}
> diff --git a/gdb/testsuite/gdb.btrace/multi-inferior.exp b/gdb/testsuite/gdb.btrace/multi-inferior.exp
> index 6996b182e65..8d30932c81f 100644
> --- a/gdb/testsuite/gdb.btrace/multi-inferior.exp
> +++ b/gdb/testsuite/gdb.btrace/multi-inferior.exp
> @@ -22,51 +22,59 @@
>   #
>   # Each inferior can be recorded separately.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   require !use_gdb_stub
>   
>   standard_testfile
> -if [prepare_for_testing "failed to prepare" $testfile {} {debug}] {
> +if [build_executable "failed to prepare" $testfile {} {debug}] {
>       return -1
>   }
>   
>   set host_binfile [gdb_remote_download host $binfile]
>   
> -with_test_prefix "inferior 1" {
> -    if ![runto_main] {
> -	return -1
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
>       }
> -}
> -
> -with_test_prefix "inferior 2" {
> -    gdb_test "add-inferior -exec $host_binfile" "Added inferior 2.*" \
> -	"add second inferior"
> -    gdb_test "inferior 2" "Switching to inferior 2.*"
> +    clean_restart "${testfile}"
>   
> -    if ![runto_main] {
> -	return -1
> +    with_test_prefix "inferior 1" {
> +	if ![runto_main] {
> +	    continue
> +	}
>       }
>   
> -    gdb_test_no_output "record btrace" "record btrace"
> -}
> +    with_test_prefix "inferior 2" {
> +	gdb_test "add-inferior -exec $host_binfile" "Added inferior 2.*" \
> +	    "add second inferior"
> +	gdb_test "inferior 2" "Switching to inferior 2.*"
>   
> -with_test_prefix "inferior 1" {
> -    gdb_test "inferior 1" "Switching to inferior 1.*"
> +	if ![runto_main] {
> +	    continue
> +	}
>   
> -    gdb_test "info record" "No recording is currently active\\."
> -    gdb_test_no_output "record btrace" "record btrace"
> -}
> +	gdb_test_no_output "record btrace ${method}" "record btrace ${method}"
> +    }
>   
> -with_test_prefix "inferior 3" {
> -    gdb_test "add-inferior -exec ${host_binfile}" "Added inferior 3.*" \
> -	"add third inferior"
> -    gdb_test "inferior 3" "Switching to inferior 3.*"
> +    with_test_prefix "inferior 1" {
> +	gdb_test "inferior 1" "Switching to inferior 1.*"
>   
> -    if ![runto_main] {
> -	return -1
> +	gdb_test "info record" "No recording is currently active\\."
> +	gdb_test_no_output "record btrace ${method}" "record btrace ${method}"
>       }
>   
> -    gdb_test "info record" "No recording is currently active\\."
> -    gdb_test_no_output "record btrace" "record btrace"
> +    with_test_prefix "inferior 3" {
> +	gdb_test "add-inferior -exec ${host_binfile}" "Added inferior 3.*" \
> +	    "add third inferior"
> +	gdb_test "inferior 3" "Switching to inferior 3.*"
> +
> +	if ![runto_main] {
> +	    continue
> +	}
> +
> +	gdb_test "info record" "No recording is currently active\\."
> +	gdb_test_no_output "record btrace ${method}" "record btrace ${method}"
> +    }
>   }
> diff --git a/gdb/testsuite/gdb.btrace/multi-thread-step.exp b/gdb/testsuite/gdb.btrace/multi-thread-step.exp
> index 154db9ae515..aada8b4a67e 100644
> --- a/gdb/testsuite/gdb.btrace/multi-thread-step.exp
> +++ b/gdb/testsuite/gdb.btrace/multi-thread-step.exp
> @@ -17,23 +17,13 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile
>   if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug}] != "" } {
>       untested "failed to prepare"
>       return -1
>   }
> -clean_restart $testfile
> -
> -if ![runto_main] {
> -    return -1
> -}
> -
> -# set up breakpoints
> -set bp_1 [gdb_get_line_number "bp.1" $srcfile]
> -set bp_2 [gdb_get_line_number "bp.2" $srcfile]
> -set bp_3 [gdb_get_line_number "bp.3" $srcfile]
>   
>   proc gdb_cont_to_line { line } {
>       gdb_breakpoint $line
> @@ -61,14 +51,6 @@ proc check_not_replaying { thread } {
>       }
>   }
>   
> -# trace the code between the two breakpoints
> -delete_breakpoints
> -gdb_cont_to_line $srcfile:$bp_1
> -# make sure GDB knows about the new thread
> -gdb_test "info threads" ".*"
> -gdb_test_no_output "record btrace"
> -gdb_cont_to_line $srcfile:$bp_2
> -
>   proc test_navigate {} {
>       with_test_prefix "navigate" {
>           gdb_test "thread 1" ".*"
> @@ -168,46 +150,70 @@ proc test_goto_end {} {
>       }
>   }
>   
> -foreach schedlock { "replay" "on" "step" } {
> -    with_test_prefix "schedlock-$schedlock" {
> -        gdb_test_no_output "set scheduler-locking $schedlock"
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
> +
> +    # set up breakpoints
> +    set bp_1 [gdb_get_line_number "bp.1" $srcfile]
> +    set bp_2 [gdb_get_line_number "bp.2" $srcfile]
> +    set bp_3 [gdb_get_line_number "bp.3" $srcfile]
>   
> -        test_navigate
> -        test_step
> -        if { $schedlock == "step" } {
> -            test_cont_all
> -        } else {
> -            test_cont
> -        }
> -        test_rstep
> -        test_goto_end
> +    # trace the code between the two breakpoints
> +    delete_breakpoints
> +    gdb_cont_to_line $srcfile:$bp_1
> +    # make sure GDB knows about the new thread
> +    gdb_test "info threads" ".*"
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_cont_to_line $srcfile:$bp_2
> +
> +    foreach schedlock { "replay" "on" "step" } {
> +	with_test_prefix "schedlock-$schedlock" {
> +	    gdb_test_no_output "set scheduler-locking $schedlock"
> +
> +	    test_navigate
> +	    test_step
> +	    if { $schedlock == "step" } {
> +		test_cont_all
> +	    } else {
> +		test_cont
> +	    }
> +	    test_rstep
> +	    test_goto_end
> +	}
>       }
> -}
>   
> -# schedlock-off is difficult to test since we can't really say where the other
> -# thread will be when the resumed thread stops.
> +    # schedlock-off is difficult to test since we can't really say where the other
> +    # thread will be when the resumed thread stops.
>   
> -# navigate back into the history for thread 1 and continue thread 2
> -with_test_prefix "cont-to-end" {
> -    # this test only works for scheduler-locking replay
> -    gdb_test_no_output "set scheduler-locking replay"
> +    # navigate back into the history for thread 1 and continue thread 2
> +    with_test_prefix "cont-to-end" {
> +	# this test only works for scheduler-locking replay
> +	gdb_test_no_output "set scheduler-locking replay"
>   
> -    gdb_test "thread 1" ".*"
> -    with_test_prefix "thread 1" {
> -        gdb_test "record goto begin" ".*"
> +	gdb_test "thread 1" ".*"
> +	with_test_prefix "thread 1" {
> +	    gdb_test "record goto begin" ".*"
>   
> -        check_replay_insn 1 1
> -    }
> -    gdb_test "thread 2" ".*"
> -    with_test_prefix "thread 2" {
> -        gdb_test "record goto end" ".*"
> +	    check_replay_insn 1 1
> +	}
> +	gdb_test "thread 2" ".*"
> +	with_test_prefix "thread 2" {
> +	    gdb_test "record goto end" ".*"
>   
> -        check_not_replaying 2
> +	    check_not_replaying 2
>   
> -        # if we reach the breakpoint, thread 2 terminated...
> -        gdb_cont_to_line $srcfile:$bp_3
> +	    # if we reach the breakpoint, thread 2 terminated...
> +	    gdb_cont_to_line $srcfile:$bp_3
>   
> -        # and thread 1 stopped replaying
> -        check_not_replaying 1
> +	    # and thread 1 stopped replaying
> +	    check_not_replaying 1
> +	}
>       }
>   }
> diff --git a/gdb/testsuite/gdb.btrace/nohist.exp b/gdb/testsuite/gdb.btrace/nohist.exp
> index d71909181c4..3b0b2eeacb0 100644
> --- a/gdb/testsuite/gdb.btrace/nohist.exp
> +++ b/gdb/testsuite/gdb.btrace/nohist.exp
> @@ -17,14 +17,11 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile record_goto.c
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
> -    return -1
> -}
>   
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
> @@ -36,14 +33,25 @@ proc check_not_replaying {} {
>       ]
>   }
>   
> -gdb_test_no_output "record btrace"
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -with_test_prefix "forward" {
> -    check_not_replaying
> -}
> +    gdb_test_no_output "record btrace ${method}"
> +
> +    with_test_prefix "forward" {
> +	check_not_replaying
> +    }
>   
> -gdb_test "reverse-continue" "No more reverse-execution history\.\r\n.*"
> +    gdb_test "reverse-continue" "No more reverse-execution history\.\r\n.*"
>   
> -with_test_prefix "backward" {
> -    check_not_replaying
> +    with_test_prefix "backward" {
> +	check_not_replaying
> +    }
>   }
> diff --git a/gdb/testsuite/gdb.btrace/non-stop.exp b/gdb/testsuite/gdb.btrace/non-stop.exp
> index 62c940e4cd6..4d73221fc3f 100644
> --- a/gdb/testsuite/gdb.btrace/non-stop.exp
> +++ b/gdb/testsuite/gdb.btrace/non-stop.exp
> @@ -15,7 +15,7 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile
>   if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug}] != "" } {
> @@ -23,29 +23,6 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debu
>       return -1
>   }
>   
> -save_vars { GDBFLAGS } {
> -    append GDBFLAGS " -ex \"set non-stop on\""
> -    clean_restart $testfile
> -}
> -
> -if ![runto_main] {
> -    return -1
> -}
> -
> -# set up breakpoints
> -set bp_1 [gdb_get_line_number "bp.1" $srcfile]
> -set bp_2 [gdb_get_line_number "bp.2" $srcfile]
> -set bp_3 [gdb_get_line_number "bp.3" $srcfile]
> -
> -gdb_breakpoint $bp_1
> -gdb_breakpoint $bp_2
> -
> -# get the line number containing most of the trace
> -set loop [gdb_get_line_number "loop" $srcfile]
> -
> -# a stop on the above line as reported by GDB
> -set loop_line "$loop\[^\\\r\\\n\]*/\\\* loop \\\*/"
> -
>   # make sure $line matches the full expected output per thread.
>   # and let's hope that GDB never mixes the output from different threads.
>   proc gdb_cont_to { threads cmd line nthreads } {
> @@ -89,165 +66,195 @@ proc gdb_cont_to_no_history { threads cmd nthreads } {
>           $nthreads
>   }
>   
> -# trace the code between the two breakpoints
> -with_test_prefix "prepare" {
> -    gdb_cont_to_bp_line "$srcfile:$bp_1" all 2
> -}
> -with_test_prefix "record" {
> -    gdb_test_no_output "record btrace"
> -    gdb_cont_to_bp_line "$srcfile:$bp_2" all 2
> -}
> -
> -# we don't need those breakpoints any longer.
> -# they will only disturb our stepping.
> -delete_breakpoints
> -
> -# show the threads - this is useful for debugging fails
> -gdb_test "thread apply all info rec" ".*"
> -gdb_test "info threads" ".*"
> -
> -with_test_prefix "navigate" {
> -    gdb_test "thread apply 1 record goto 3" "$loop_line"
> -    gdb_test "thread apply 2 record goto 4" "$loop_line"
> -    gdb_test "thread apply 1 info record" \
> -        ".*Replay in progress\.  At instruction 3\." "thread 1 at insn 3"
> -    gdb_test "thread apply 2 info record" \
> -        ".*Replay in progress\.  At instruction 4\." "thread 2 at insn 4"
> -
> -    gdb_test "thread apply all record goto 5" "$loop_line"
> -    gdb_test "thread apply 1 info record" \
> -        ".*Replay in progress\.  At instruction 5\." "thread 1 at insn 5"
> -    gdb_test "thread apply 2 info record" \
> -        ".*Replay in progress\.  At instruction 5\." "thread 2 at insn 5"
> -}
> -
> -with_test_prefix "step" {
> -    with_test_prefix "thread 1" {
> -        gdb_test "thread apply 1 stepi 2" "$loop_line"
> -        gdb_test "thread apply 1 info record" \
> -            ".*Replay in progress\.  At instruction 7\."
> -        gdb_test "thread apply 2 info record" \
> -            ".*Replay in progress\.  At instruction 5\."
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
>       }
>   
> -    with_test_prefix "thread 2" {
> -        gdb_test "thread apply 2 stepi 3" "$loop_line"
> -        gdb_test "thread apply 1 info record" \
> -            ".*Replay in progress\.  At instruction 7\."
> -        gdb_test "thread apply 2 info record" \
> -            ".*Replay in progress\.  At instruction 8\."
> +    save_vars { GDBFLAGS } {
> +	append GDBFLAGS " -ex \"set non-stop on\""
> +	clean_restart $testfile
>       }
>   
> -    with_test_prefix "all" {
> -        gdb_cont_to all "stepi 4" "$loop_line" 2
> -        gdb_test "thread apply 1 info record" \
> -            ".*Replay in progress\.  At instruction 11\."
> -        gdb_test "thread apply 2 info record" \
> -            ".*Replay in progress\.  At instruction 12\."
> +    if ![runto_main] {
> +	continue
>       }
> -}
>   
> -with_test_prefix "reverse-step" {
> -    with_test_prefix "thread 1" {
> -        gdb_test "thread apply 1 reverse-stepi 2" "$loop_line"
> -        gdb_test "thread apply 1 info record" \
> -            ".*Replay in progress\.  At instruction 9\."
> -        gdb_test "thread apply 2 info record" \
> -            ".*Replay in progress\.  At instruction 12\."
> -    }
> +    # set up breakpoints
> +    set bp_1 [gdb_get_line_number "bp.1" $srcfile]
> +    set bp_2 [gdb_get_line_number "bp.2" $srcfile]
> +    set bp_3 [gdb_get_line_number "bp.3" $srcfile]
> +
> +    gdb_breakpoint $bp_1
> +    gdb_breakpoint $bp_2
>   
> -    with_test_prefix "thread 2" {
> -        gdb_test "thread apply 2 reverse-stepi 3" "$loop_line"
> -        gdb_test "thread apply 1 info record" \
> -            ".*Replay in progress\.  At instruction 9\."
> -        gdb_test "thread apply 2 info record" \
> -            ".*Replay in progress\.  At instruction 9\."
> +    # get the line number containing most of the trace
> +    set loop [gdb_get_line_number "loop" $srcfile]
> +
> +    # a stop on the above line as reported by GDB
> +    set loop_line "$loop\[^\\\r\\\n\]*/\\\* loop \\\*/"
> +
> +    # trace the code between the two breakpoints
> +    with_test_prefix "prepare" {
> +	gdb_cont_to_bp_line "$srcfile:$bp_1" all 2
> +    }
> +    with_test_prefix "record" {
> +	gdb_test_no_output "record btrace ${method}"
> +	gdb_cont_to_bp_line "$srcfile:$bp_2" all 2
>       }
>   
> -    with_test_prefix "all" {
> -        gdb_cont_to all "reverse-stepi 4" "$loop_line" 2
> -        gdb_test "thread apply 1 info record" \
> -            ".*Replay in progress\.  At instruction 5\."
> -        gdb_test "thread apply 2 info record" \
> -            ".*Replay in progress\.  At instruction 5\."
> +    # we don't need those breakpoints any longer.
> +    # they will only disturb our stepping.
> +    delete_breakpoints
> +
> +    # show the threads - this is useful for debugging fails
> +    gdb_test "thread apply all info rec" ".*"
> +    gdb_test "info threads" ".*"
> +
> +    with_test_prefix "navigate" {
> +	gdb_test "thread apply 1 record goto 3" "$loop_line"
> +	gdb_test "thread apply 2 record goto 4" "$loop_line"
> +	gdb_test "thread apply 1 info record" \
> +	    ".*Replay in progress\.  At instruction 3\." "thread 1 at insn 3"
> +	gdb_test "thread apply 2 info record" \
> +	    ".*Replay in progress\.  At instruction 4\." "thread 2 at insn 4"
> +
> +	gdb_test "thread apply all record goto 5" "$loop_line"
> +	gdb_test "thread apply 1 info record" \
> +	    ".*Replay in progress\.  At instruction 5\." "thread 1 at insn 5"
> +	gdb_test "thread apply 2 info record" \
> +	    ".*Replay in progress\.  At instruction 5\." "thread 2 at insn 5"
>       }
> -}
>   
> -with_test_prefix "continue" {
> -    with_test_prefix "thread 1" {
> -	with_test_prefix "continue" {
> -	    gdb_cont_to_no_history 1 "continue" 1
> +    with_test_prefix "step" {
> +	with_test_prefix "thread 1" {
> +	    gdb_test "thread apply 1 stepi 2" "$loop_line"
>   	    gdb_test "thread apply 1 info record" \
> -		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> +		".*Replay in progress\.  At instruction 7\."
>   	    gdb_test "thread apply 2 info record" \
>   		".*Replay in progress\.  At instruction 5\."
>   	}
> -	with_test_prefix "reverse-continue" {
> -	    gdb_cont_to_no_history 1 "reverse-continue" 1
> +
> +	with_test_prefix "thread 2" {
> +	    gdb_test "thread apply 2 stepi 3" "$loop_line"
>   	    gdb_test "thread apply 1 info record" \
> -		".*Replay in progress\.  At instruction 1\."
> +		".*Replay in progress\.  At instruction 7\."
>   	    gdb_test "thread apply 2 info record" \
> -		".*Replay in progress\.  At instruction 5\."
> +		".*Replay in progress\.  At instruction 8\."
> +	}
> +
> +	with_test_prefix "all" {
> +	    gdb_cont_to all "stepi 4" "$loop_line" 2
> +	    gdb_test "thread apply 1 info record" \
> +		".*Replay in progress\.  At instruction 11\."
> +	    gdb_test "thread apply 2 info record" \
> +		".*Replay in progress\.  At instruction 12\."
>   	}
>       }
>   
> -    with_test_prefix "thread 2" {
> -	with_test_prefix "continue" {
> -	    gdb_cont_to_no_history 2 "continue" 1
> +    with_test_prefix "reverse-step" {
> +	with_test_prefix "thread 1" {
> +	    gdb_test "thread apply 1 reverse-stepi 2" "$loop_line"
>   	    gdb_test "thread apply 1 info record" \
> -		".*Replay in progress\.  At instruction 1\."
> +		".*Replay in progress\.  At instruction 9\."
>   	    gdb_test "thread apply 2 info record" \
> -		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> +		".*Replay in progress\.  At instruction 12\."
> +	}
> +
> +	with_test_prefix "thread 2" {
> +	    gdb_test "thread apply 2 reverse-stepi 3" "$loop_line"
> +	    gdb_test "thread apply 1 info record" \
> +		".*Replay in progress\.  At instruction 9\."
> +	    gdb_test "thread apply 2 info record" \
> +		".*Replay in progress\.  At instruction 9\."
>   	}
> -	with_test_prefix "reverse-continue" {
> -	    gdb_cont_to_no_history 2 "reverse-continue" 1
> +
> +	with_test_prefix "all" {
> +	    gdb_cont_to all "reverse-stepi 4" "$loop_line" 2
>   	    gdb_test "thread apply 1 info record" \
> -		".*Replay in progress\.  At instruction 1\."
> +		".*Replay in progress\.  At instruction 5\."
>   	    gdb_test "thread apply 2 info record" \
> -		".*Replay in progress\.  At instruction 1\."
> +		".*Replay in progress\.  At instruction 5\."
>   	}
>       }
> -}
>   
> -# a thread may only resume if no thread is still replaying
> -with_test_prefix "no progress" {
> -    with_test_prefix "thread 1" {
> -        gdb_test "thread apply 1 record goto end" ".*"
> -        gdb_test "thread apply 2 record goto begin" ".*"
> -
> -        gdb_cont_to_no_history 1 "continue" 1
> -        gdb_cont_to_no_history 1 "step" 1
> -        gdb_test "thread apply 1 info record" \
> -            ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> -        gdb_test "thread apply 2 info record" \
> -            ".*Replay in progress\.  At instruction 1\."
> +    with_test_prefix "continue" {
> +	with_test_prefix "thread 1" {
> +	    with_test_prefix "continue" {
> +		gdb_cont_to_no_history 1 "continue" 1
> +		gdb_test "thread apply 1 info record" \
> +		    ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> +		gdb_test "thread apply 2 info record" \
> +		    ".*Replay in progress\.  At instruction 5\."
> +	    }
> +	    with_test_prefix "reverse-continue" {
> +		gdb_cont_to_no_history 1 "reverse-continue" 1
> +		gdb_test "thread apply 1 info record" \
> +		    ".*Replay in progress\.  At instruction 1\."
> +		gdb_test "thread apply 2 info record" \
> +		    ".*Replay in progress\.  At instruction 5\."
> +	    }
> +	}
> +
> +	with_test_prefix "thread 2" {
> +	    with_test_prefix "continue" {
> +		gdb_cont_to_no_history 2 "continue" 1
> +		gdb_test "thread apply 1 info record" \
> +		    ".*Replay in progress\.  At instruction 1\."
> +		gdb_test "thread apply 2 info record" \
> +		    ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> +	    }
> +	    with_test_prefix "reverse-continue" {
> +		gdb_cont_to_no_history 2 "reverse-continue" 1
> +		gdb_test "thread apply 1 info record" \
> +		    ".*Replay in progress\.  At instruction 1\."
> +		gdb_test "thread apply 2 info record" \
> +		    ".*Replay in progress\.  At instruction 1\."
> +	    }
> +	}
>       }
>   
> -    with_test_prefix "thread 2" {
> -        gdb_test "thread apply 1 record goto begin" ".*"
> -        gdb_test "thread apply 2 record goto end" ".*"
> +    # a thread may only resume if no thread is still replaying
> +    with_test_prefix "no progress" {
> +	with_test_prefix "thread 1" {
> +	    gdb_test "thread apply 1 record goto end" ".*"
> +	    gdb_test "thread apply 2 record goto begin" ".*"
>   
> -        gdb_cont_to_no_history 2 "continue" 1
> -        gdb_cont_to_no_history 2 "step" 1
> -        gdb_test "thread apply 1 info record" \
> -            ".*Replay in progress\.  At instruction 1\."
> -        gdb_test "thread apply 2 info record" \
> -            ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> -    }
> +	    gdb_cont_to_no_history 1 "continue" 1
> +	    gdb_cont_to_no_history 1 "step" 1
> +	    gdb_test "thread apply 1 info record" \
> +		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> +	    gdb_test "thread apply 2 info record" \
> +		".*Replay in progress\.  At instruction 1\."
> +	}
> +
> +	with_test_prefix "thread 2" {
> +	    gdb_test "thread apply 1 record goto begin" ".*"
> +	    gdb_test "thread apply 2 record goto end" ".*"
>   
> -    with_test_prefix "all" {
> -        gdb_test "thread apply all record goto begin" ".*"
> +	    gdb_cont_to_no_history 2 "continue" 1
> +	    gdb_cont_to_no_history 2 "step" 1
> +	    gdb_test "thread apply 1 info record" \
> +		".*Replay in progress\.  At instruction 1\."
> +	    gdb_test "thread apply 2 info record" \
> +		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> +	}
>   
> -        gdb_cont_to_no_history all "continue" 2
> -        gdb_test "thread apply 1 info record" \
> -            ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> -        gdb_test "thread apply 2 info record" \
> -            ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> +	with_test_prefix "all" {
> +	    gdb_test "thread apply all record goto begin" ".*"
> +
> +	    gdb_cont_to_no_history all "continue" 2
> +	    gdb_test "thread apply 1 info record" \
> +		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> +	    gdb_test "thread apply 2 info record" \
> +		".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*"
> +	}
>       }
> -}
>   
> -# now that both threads stopped replaying we may resume recording
> -with_test_prefix "cont to end" {
> -    gdb_breakpoint $bp_3
> -    gdb_cont_to_bp_line "$srcfile:$bp_3" all 1
> +    # now that both threads stopped replaying we may resume recording
> +    with_test_prefix "cont to end" {
> +	gdb_breakpoint $bp_3
> +	gdb_cont_to_bp_line "$srcfile:$bp_3" all 1
> +    }
>   }
> diff --git a/gdb/testsuite/gdb.btrace/reconnect.exp b/gdb/testsuite/gdb.btrace/reconnect.exp
> index 41f702a38b3..cf147a33d58 100644
> --- a/gdb/testsuite/gdb.btrace/reconnect.exp
> +++ b/gdb/testsuite/gdb.btrace/reconnect.exp
> @@ -19,63 +19,73 @@
>   
>   load_lib gdbserver-support.exp
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   require allow_gdbserver_tests
>   
>   standard_testfile
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
>   set target_binfile [gdb_remote_download target $binfile]
>   
> -# Make sure we're disconnected and no recording is active, in case
> -# we're testing with an extended-remote board, therefore already
> -# connected.
> -with_test_prefix "preparation" {
> -  gdb_test "record stop" ".*"
> -  gdb_test "disconnect" ".*"
> -}
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
>   
> -# Start fresh gdbserver.
> -set gdbserver_reconnect_p 1
> -set res [gdbserver_start "" $target_binfile]
> -set gdbserver_protocol [lindex $res 0]
> -set gdbserver_gdbport [lindex $res 1]
> -gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
> +    clean_restart "${testfile}"
>   
> -# Create a record, check, reconnect
> -with_test_prefix "first" {
> -  gdb_test_no_output "record btrace" "record btrace enable"
> -  gdb_test "stepi 19" ".*"
> +    # Make sure we're disconnected and no recording is active, in case
> +    # we're testing with an extended-remote board, therefore already
> +    # connected.
> +    with_test_prefix "preparation" {
> +	gdb_test "record stop" ".*"
> +	gdb_test "disconnect" ".*"
> +    }
>   
> -  gdb_test "info record" [multi_line \
> -    "Active record target: .*" \
> -    "Recorded 19 instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
> -  ]
> +    # Start fresh gdbserver.
> +    set gdbserver_reconnect_p 1
> +    set res [gdbserver_start "" $target_binfile]
> +    set gdbserver_protocol [lindex $res 0]
> +    set gdbserver_gdbport [lindex $res 1]
> +    gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
>   
> -  gdb_test "disconnect" "Ending remote debugging."
> -  gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
> -}
> +    # Create a record, check, reconnect
> +    with_test_prefix "first" {
> +	gdb_test_no_output "record btrace ${method}" "record btrace ${method} enable"
> +	gdb_test "stepi 19" ".*"
>   
> -# Test if we can access the recorded data from first connect.
> -# Note: BTS loses the first function call entry with its associated
> -# instructions for technical reasons.  This is why we test for
> -# "a number between 10 and 19", so we catch at least the case where
> -# there are 0 instructions in the record.
> -with_test_prefix "second" {
> -  gdb_test "info record" [multi_line \
> -    "Active record target: .*" \
> -    "Recorded 1. instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
> -  ]
> +	gdb_test "info record" [multi_line \
> +	    "Active record target: .*" \
> +	    "Recorded 19 instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
> +	    ]
>   
> -  gdb_test "record stop" "Process record is stopped and all execution logs are deleted."
> +	gdb_test "disconnect" "Ending remote debugging."
> +	gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
> +    }
>   
> -  gdb_test "disconnect" "Ending remote debugging."
> -  gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
> -}
> +    # Test if we can access the recorded data from first connect.
> +    # Note: BTS loses the first function call entry with its associated
> +    # instructions for technical reasons.  This is why we test for
> +    # "a number between 10 and 19", so we catch at least the case where
> +    # there are 0 instructions in the record.
> +    with_test_prefix "second" {
> +	gdb_test "info record" [multi_line \
> +	    "Active record target: .*" \
> +	    "Recorded 1. instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
> +	    ]
> +
> +	gdb_test "record stop" "Process record is stopped and all execution logs are deleted."
> +
> +	gdb_test "disconnect" "Ending remote debugging."
> +	gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
> +    }
>   
> -# Test that recording is now off.
> -with_test_prefix "third" {
> -  gdb_test "info record" "No recording is currently active."
> +    # Test that recording is now off.
> +    with_test_prefix "third" {
> +	gdb_test "info record" "No recording is currently active."
> +    }
> +    gdb_test "disconnect" ".*"
>   }
> diff --git a/gdb/testsuite/gdb.btrace/record_goto-step.exp b/gdb/testsuite/gdb.btrace/record_goto-step.exp
> index e7adc62eedd..333bec8e209 100644
> --- a/gdb/testsuite/gdb.btrace/record_goto-step.exp
> +++ b/gdb/testsuite/gdb.btrace/record_goto-step.exp
> @@ -17,28 +17,42 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile record_goto.c
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
> +
> +if {![target_supports_btrace]} {
> +    unsupported "target does not support btrace."
>       return -1
>   }
>   
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
> -set bp [gdb_get_line_number "fun4.3" $srcfile]
> -gdb_breakpoint $srcfile:$bp
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# record the execution until we hit a breakpoint
> -gdb_test_no_output "record btrace"
> -gdb_continue_to_breakpoint "cont to $bp" ".*fun4\.3.*"
> +    set bp [gdb_get_line_number "fun4.3" $srcfile]
> +    gdb_breakpoint $srcfile:$bp
>   
> -# reverse-step, then jump to the end of the trace
> -gdb_test "reverse-next" ".*fun4\.2.*"
> -gdb_test "record goto end" ".*fun4\.3.*"
> +    # record the execution until we hit a breakpoint
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_continue_to_breakpoint "cont to $bp" ".*fun4\.3.*"
>   
> -# test that we can step away from a breakpoint after jumping to
> -# the breakpoint PC
> -gdb_test "next" ".*fun4\.4.*"
> +    # reverse-step, then jump to the end of the trace
> +    gdb_test "reverse-next" ".*fun4\.2.*"
> +    gdb_test "record goto end" ".*fun4\.3.*"
> +
> +    # test that we can step away from a breakpoint after jumping to
> +    # the breakpoint PC
> +    gdb_test "next" ".*fun4\.4.*"
> +}
> diff --git a/gdb/testsuite/gdb.btrace/record_goto.exp b/gdb/testsuite/gdb.btrace/record_goto.exp
> index cd6ab387c40..0fd0d5841ae 100644
> --- a/gdb/testsuite/gdb.btrace/record_goto.exp
> +++ b/gdb/testsuite/gdb.btrace/record_goto.exp
> @@ -17,7 +17,12 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
> +
> +# When GDB prints the file for a stop location, it may print the full path
> +# depending on what information the compiler added.  This regexp allows for
> +# that path to be present, but does not require it.
> +set optional_filepath {[^\n]*}
>   
>   # The "record goto" command jumps to a specific instruction in the execution
>   # trace.  To guarantee that we always get the same execution trace, we use
> @@ -43,157 +48,162 @@ if [info exists COMPILE] {
>       return -1
>   }
>   
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
> +if [build_executable "failed to prepare" $testfile $srcfile $opts] {
>       return -1
>   }
>   
> -if ![runto_main] {
> -    return -1
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
> +
> +    # we want a small context sizes to simplify the test
> +    gdb_test_no_output "set record instruction-history-size 3"
> +    gdb_test_no_output "set record function-call-history-size 3"
> +
> +    # trace the call to the test function
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_test "next"
> +
> +    # start by listing all functions
> +    gdb_test "record function-call-history /ci 1, +20" [multi_line \
> +	"1\tmain\tinst 1,1" \
> +	"2\t  fun4\tinst 2,4" \
> +	"3\t    fun1\tinst 5,8" \
> +	"4\t  fun4\tinst 9,9" \
> +	"5\t    fun2\tinst 10,12" \
> +	"6\t      fun1\tinst 13,16" \
> +	"7\t    fun2\tinst 17,18" \
> +	"8\t  fun4\tinst 19,19" \
> +	"9\t    fun3\tinst 20,22" \
> +	"10\t      fun1\tinst 23,26" \
> +	"11\t    fun3\tinst 27,27" \
> +	"12\t      fun2\tinst 28,30" \
> +	"13\t        fun1\tinst 31,34" \
> +	"14\t      fun2\tinst 35,36" \
> +	"15\t    fun3\tinst 37,38" \
> +	"16\t  fun4\tinst 39,40" \
> +	]
> +
> +    # let's see if we can go back in history
> +    gdb_test \
> +	"record goto 19" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:43.*"
> +
> +    # the function call history should start at the new location
> +    gdb_test "record function-call-history /ci" [multi_line \
> +	"8\t  fun4\tinst 19,19" \
> +	"9\t    fun3\tinst 20,22" \
> +	"10\t      fun1\tinst 23,26" \
> +	] "function-call-history from 19 forwards"
> +
> +    # the instruction history should start at the new location
> +    gdb_test "record instruction-history" [multi_line \
> +	"19.*" \
> +	"20.*" \
> +	"21.*" \
> +	] "instruction-history from 19 forwards"
> +
> +    # let's go to another place in the history
> +    gdb_test \
> +	"record goto 27" \
> +	".*fun3 \\(\\) at ${optional_filepath}record_goto.c:35.*"
> +
> +    # check the back trace at that location
> +    gdb_test "backtrace" [multi_line \
> +	"#0.*fun3.*at ${optional_filepath}record_goto.c:35.*" \
> +	"#1.*fun4.*at ${optional_filepath}record_goto.c:43.*" \
> +	"#2.*main.*at ${optional_filepath}record_goto.c:49.*" \
> +	"Backtrace stopped: not enough registers or memory available to unwind further" \
> +	]
> +
> +    # walk the backtrace
> +    gdb_test "up" ".*fun4.*at ${optional_filepath}record_goto.c:43.*" "up to fun4"
> +    gdb_test "up" ".*main.*at ${optional_filepath}record_goto.c:49.*" "up to main"
> +
> +    # the function call history should start at the new location
> +    gdb_test "record function-call-history /ci -" [multi_line \
> +	"9\t    fun3\tinst 20,22" \
> +	"10\t      fun1\tinst 23,26" \
> +	"11\t    fun3\tinst 27,27" \
> +	] "function-call-history from 27 backwards"
> +
> +    # the instruction history should start at the new location
> +    gdb_test "record instruction-history -" [multi_line \
> +	"25.*" \
> +	"26.*" \
> +	"27.*" \
> +	] "instruction-history from 27 backwards"
> +
> +    # test that we can go to the begin of the trace
> +    gdb_test "record goto begin" ".*main \\(\\) at ${optional_filepath}record_goto.c:49.*"
> +
> +    # check that we're filling up the context correctly
> +    gdb_test "record function-call-history /ci -" [multi_line \
> +	"1\tmain\tinst 1,1" \
> +	"2\t  fun4\tinst 2,4" \
> +	"3\t    fun1\tinst 5,8" \
> +	] "function-call-history from begin backwards"
> +
> +    # check that we're filling up the context correctly
> +    gdb_test "record instruction-history -" [multi_line \
> +	"1.*" \
> +	"2.*" \
> +	"3.*" \
> +	] "instruction-history from begin backwards"
> +
> +    # we should get the exact same history from the first instruction
> +    gdb_test "record goto 2" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:40.*"
> +
> +    # check that we're filling up the context correctly
> +    gdb_test "record function-call-history /ci -" [multi_line \
> +	"1\tmain\tinst 1,1" \
> +	"2\t  fun4\tinst 2,4" \
> +	"3\t    fun1\tinst 5,8" \
> +	] "function-call-history from 2 backwards"
> +
> +    # check that we're filling up the context correctly
> +    gdb_test "record instruction-history -" [multi_line \
> +	"1.*" \
> +	"2.*" \
> +	"3.*" \
> +	] "instruction-history from 2 backwards"
> +
> +    # check that we can go to the end of the trace
> +    gdb_test "record goto end" ".*main \\(\\) at ${optional_filepath}record_goto.c:50.*"
> +
> +    # check that we're filling up the context correctly
> +    gdb_test "record function-call-history /ci" [multi_line \
> +	"14\t      fun2\tinst 35,36" \
> +	"15\t    fun3\tinst 37,38" \
> +	"16\t  fun4\tinst 39,40" \
> +	] "function-call-history from end forwards"
> +
> +    # check that we're filling up the context correctly
> +    gdb_test "record instruction-history" [multi_line \
> +	"38.*" \
> +	"39.*" \
> +	"40.*" \
> +	] "instruction-history from end forwards"
> +
> +    # we should get the exact same history from the second to last instruction
> +    gdb_test "record goto 39" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:44.*"
> +
> +    # check that we're filling up the context correctly
> +    gdb_test "record function-call-history /ci" [multi_line \
> +	"14\t      fun2\tinst 35,36" \
> +	"15\t    fun3\tinst 37,38" \
> +	"16\t  fun4\tinst 39,40" \
> +	] "function-call-history from 39 forwards"
> +
> +    # check that we're filling up the context correctly
> +    gdb_test "record instruction-history" [multi_line \
> +	"38.*" \
> +	"39.*" \
> +	"40.*" \
> +	] "instruction-history from 39 forwards"
>   }
> -
> -# When GDB prints the file for a stop location, it may print the full path
> -# depending on what information the compiler added.  This regexp allows for
> -# that path to be present, but does not require it.
> -set optional_filepath {[^\n]*}
> -
> -# we want a small context sizes to simplify the test
> -gdb_test_no_output "set record instruction-history-size 3"
> -gdb_test_no_output "set record function-call-history-size 3"
> -
> -# trace the call to the test function
> -gdb_test_no_output "record btrace"
> -gdb_test "next"
> -
> -# start by listing all functions
> -gdb_test "record function-call-history /ci 1, +20" [multi_line \
> -  "1\tmain\tinst 1,1" \
> -  "2\t  fun4\tinst 2,4" \
> -  "3\t    fun1\tinst 5,8" \
> -  "4\t  fun4\tinst 9,9" \
> -  "5\t    fun2\tinst 10,12" \
> -  "6\t      fun1\tinst 13,16" \
> -  "7\t    fun2\tinst 17,18" \
> -  "8\t  fun4\tinst 19,19" \
> -  "9\t    fun3\tinst 20,22" \
> -  "10\t      fun1\tinst 23,26" \
> -  "11\t    fun3\tinst 27,27" \
> -  "12\t      fun2\tinst 28,30" \
> -  "13\t        fun1\tinst 31,34" \
> -  "14\t      fun2\tinst 35,36" \
> -  "15\t    fun3\tinst 37,38" \
> -  "16\t  fun4\tinst 39,40" \
> -  ]
> -
> -# let's see if we can go back in history
> -gdb_test "record goto 19" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:43.*"
> -
> -# the function call history should start at the new location
> -gdb_test "record function-call-history /ci" [multi_line \
> -  "8\t  fun4\tinst 19,19" \
> -  "9\t    fun3\tinst 20,22" \
> -  "10\t      fun1\tinst 23,26" \
> -  ] "function-call-history from 19 forwards"
> -
> -# the instruction history should start at the new location
> -gdb_test "record instruction-history" [multi_line \
> -  "19.*" \
> -  "20.*" \
> -  "21.*" \
> -  ] "instruction-history from 19 forwards"
> -
> -# let's go to another place in the history
> -gdb_test "record goto 27" ".*fun3 \\(\\) at ${optional_filepath}record_goto.c:35.*"
> -
> -# check the back trace at that location
> -gdb_test "backtrace" [multi_line \
> -  "#0.*fun3.*at ${optional_filepath}record_goto.c:35.*" \
> -  "#1.*fun4.*at ${optional_filepath}record_goto.c:43.*" \
> -  "#2.*main.*at ${optional_filepath}record_goto.c:49.*" \
> -  "Backtrace stopped: not enough registers or memory available to unwind further" \
> -  ]
> -
> -# walk the backtrace
> -gdb_test "up" ".*fun4.*at ${optional_filepath}record_goto.c:43.*" "up to fun4"
> -gdb_test "up" ".*main.*at ${optional_filepath}record_goto.c:49.*" "up to main"
> -
> -# the function call history should start at the new location
> -gdb_test "record function-call-history /ci -" [multi_line \
> -  "9\t    fun3\tinst 20,22" \
> -  "10\t      fun1\tinst 23,26" \
> -  "11\t    fun3\tinst 27,27" \
> -  ] "function-call-history from 27 backwards"
> -
> -# the instruction history should start at the new location
> -gdb_test "record instruction-history -" [multi_line \
> -  "25.*" \
> -  "26.*" \
> -  "27.*" \
> -  ] "instruction-history from 27 backwards"
> -
> -# test that we can go to the begin of the trace
> -gdb_test "record goto begin" ".*main \\(\\) at ${optional_filepath}record_goto.c:49.*"
> -
> -# check that we're filling up the context correctly
> -gdb_test "record function-call-history /ci -" [multi_line \
> -  "1\tmain\tinst 1,1" \
> -  "2\t  fun4\tinst 2,4" \
> -  "3\t    fun1\tinst 5,8" \
> -  ] "function-call-history from begin backwards"
> -
> -# check that we're filling up the context correctly
> -gdb_test "record instruction-history -" [multi_line \
> -  "1.*" \
> -  "2.*" \
> -  "3.*" \
> -  ] "instruction-history from begin backwards"
> -
> -# we should get the exact same history from the first instruction
> -gdb_test "record goto 2" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:40.*"
> -
> -# check that we're filling up the context correctly
> -gdb_test "record function-call-history /ci -" [multi_line \
> -  "1\tmain\tinst 1,1" \
> -  "2\t  fun4\tinst 2,4" \
> -  "3\t    fun1\tinst 5,8" \
> -  ] "function-call-history from 2 backwards"
> -
> -# check that we're filling up the context correctly
> -gdb_test "record instruction-history -" [multi_line \
> -  "1.*" \
> -  "2.*" \
> -  "3.*" \
> -  ] "instruction-history from 2 backwards"
> -
> -# check that we can go to the end of the trace
> -gdb_test "record goto end" ".*main \\(\\) at ${optional_filepath}record_goto.c:50.*"
> -
> -# check that we're filling up the context correctly
> -gdb_test "record function-call-history /ci" [multi_line \
> -  "14\t      fun2\tinst 35,36" \
> -  "15\t    fun3\tinst 37,38" \
> -  "16\t  fun4\tinst 39,40" \
> -  ] "function-call-history from end forwards"
> -
> -# check that we're filling up the context correctly
> -gdb_test "record instruction-history" [multi_line \
> -  "38.*" \
> -  "39.*" \
> -  "40.*" \
> -  ] "instruction-history from end forwards"
> -
> -# we should get the exact same history from the second to last instruction
> -gdb_test "record goto 39" ".*fun4 \\(\\) at ${optional_filepath}record_goto.c:44.*"
> -
> -# check that we're filling up the context correctly
> -gdb_test "record function-call-history /ci" [multi_line \
> -  "14\t      fun2\tinst 35,36" \
> -  "15\t    fun3\tinst 37,38" \
> -  "16\t  fun4\tinst 39,40" \
> -  ] "function-call-history from 39 forwards"
> -
> -# check that we're filling up the context correctly
> -gdb_test "record instruction-history" [multi_line \
> -  "38.*" \
> -  "39.*" \
> -  "40.*" \
> -  ] "instruction-history from 39 forwards"
> diff --git a/gdb/testsuite/gdb.btrace/rn-dl-bind.exp b/gdb/testsuite/gdb.btrace/rn-dl-bind.exp
> index 756be2fe404..f97a1de29d1 100644
> --- a/gdb/testsuite/gdb.btrace/rn-dl-bind.exp
> +++ b/gdb/testsuite/gdb.btrace/rn-dl-bind.exp
> @@ -21,42 +21,51 @@
>   # Test that we can reverse-next over the dynamic linker's symbol
>   # lookup code.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile \
> -	{debug ldflags=-Wl,-z,lazy}] {
> -    return -1
> -}
>   
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile \
> +	{c++ debug ldflags=-Wl,-z,lazy}] {
>       return -1
>   }
>   
> -# trace the code for the call to test
> -gdb_test_no_output "record btrace"
> -gdb_test "next" ".*main\.2.*"
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
>   
> -# just dump the function-call-history to help debugging
> -gdb_test_no_output "set record function-call-history-size 0"
> -gdb_test "record function-call-history /cli 1" ".*"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# check that we can reverse-next and next
> -with_test_prefix "main" {
> -    gdb_test "reverse-next" ".*main\.1.*"
> +    # trace the code for the call to test
> +    gdb_test_no_output "record btrace ${method}"
>       gdb_test "next" ".*main\.2.*"
> -}
>   
> -# now go into test and try to (reverse-)next over the library call
> -#
> -# reverse-stepping through the epilogue is not very reliable; depending on
> -# debug information we may stop at the closing brace or at the return.
> -#
> -# instead, run to test
> -gdb_breakpoint test {temporary}
> -gdb_test "reverse-continue" ".*test\.1.*"
> +    # just dump the function-call-history to help debugging
> +    gdb_test_no_output "set record function-call-history-size 0"
> +    gdb_test "record function-call-history /cli 1" ".*"
> +
> +    # check that we can reverse-next and next
> +    with_test_prefix "main" {
> +	gdb_test "reverse-next" ".*main\.1.*"
> +	gdb_test "next" ".*main\.2.*"
> +    }
> +
> +    # now go into test and try to (reverse-)next over the library call
> +    #
> +    # reverse-stepping through the epilogue is not very reliable; depending on
> +    # debug information we may stop at the closing brace or at the return.
> +    #
> +    # instead, run to test
> +    gdb_breakpoint test {temporary}
> +    gdb_test "reverse-continue" ".*test\.1.*"
>   
> -with_test_prefix "test" {
> -    gdb_test "next" ".*test\.2.*"
> -    gdb_test "reverse-next" ".*test\.1.*"
> +    with_test_prefix "test" {
> +	gdb_test "next" ".*test\.2.*"
> +	gdb_test "reverse-next" ".*test\.1.*"
> +    }
>   }
> diff --git a/gdb/testsuite/gdb.btrace/segv.exp b/gdb/testsuite/gdb.btrace/segv.exp
> index 9804b93a877..c330093f0d4 100644
> --- a/gdb/testsuite/gdb.btrace/segv.exp
> +++ b/gdb/testsuite/gdb.btrace/segv.exp
> @@ -17,27 +17,35 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
> -    return -1
> -}
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
> -# trace the test code
> -gdb_test_no_output "record btrace"
> -gdb_test "continue" [multi_line \
> -  "Program received signal SIGSEGV, Segmentation fault\." \
> -  "0x0* in \\\?\\\? \\\(\\\)" \
> -  ] "cont to segv"
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# we cannot do any high-level stepping
> -gdb_test "reverse-finish" "Cannot find bounds of current function"
> -gdb_test "reverse-next" "Cannot find bounds of current function"
> -gdb_test "reverse-step" "Cannot find bounds of current function"
> +    # trace the test code
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_test "continue" [multi_line \
> +	"Program received signal SIGSEGV, Segmentation fault\." \
> +	"0x0* in \\\?\\\? \\\(\\\)" \
> +    ] "cont to segv"
>   
> -# but we can do instruction stepping
> -gdb_test "reverse-stepi" "test\.call\[^\\\r\\\n\]*"
> +    # we cannot do any high-level stepping
> +    gdb_test "reverse-finish" "Cannot find bounds of current function"
> +    gdb_test "reverse-next" "Cannot find bounds of current function"
> +    gdb_test "reverse-step" "Cannot find bounds of current function"
> +
> +    # but we can do instruction stepping
> +    gdb_test "reverse-stepi" "test\.call\[^\\\r\\\n\]*"
> +}
> diff --git a/gdb/testsuite/gdb.btrace/step.exp b/gdb/testsuite/gdb.btrace/step.exp
> index 0adc18bd924..6d36a73f735 100644
> --- a/gdb/testsuite/gdb.btrace/step.exp
> +++ b/gdb/testsuite/gdb.btrace/step.exp
> @@ -17,32 +17,40 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile record_goto.c
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
> -    return -1
> -}
>   
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
> -# trace the call to the test function
> -with_test_prefix "record" {
> -    gdb_test_no_output "record btrace"
> -    gdb_test "next"
> -}
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
> +
> +    # trace the call to the test function
> +    with_test_prefix "record" {
> +	gdb_test_no_output "record btrace ${method}"
> +	gdb_test "next"
> +    }
>   
> -# let's step around a bit
> -with_test_prefix "replay" {
> -    gdb_test "reverse-next" ".*main\.2.*" "reverse-next.1"
> -    gdb_test "step" ".*fun4\.2.*" "step.1"
> -    gdb_test "next" ".*fun4\.3.*" "next.1"
> -    gdb_test "step" ".*fun2\.2.*" "step.2"
> -    gdb_test "finish" ".*fun4\.4.*" "finish.1"
> -    gdb_test "reverse-step" ".*fun2\.3.*" "reverse-step.1"
> -    gdb_test "reverse-finish" ".*fun4\.3.*" "reverse-finish.1"
> -    gdb_test "reverse-next" ".*fun4\.2.*" "reverse-next.2"
> -    gdb_test "reverse-finish" ".*main\.2.*" "reverse-finish.2"
> +    # let's step around a bit
> +    with_test_prefix "replay" {
> +	gdb_test "reverse-next" ".*main\.2.*" "reverse-next.1"
> +	gdb_test "step" ".*fun4\.2.*" "step.1"
> +	gdb_test "next" ".*fun4\.3.*" "next.1"
> +	gdb_test "step" ".*fun2\.2.*" "step.2"
> +	gdb_test "finish" ".*fun4\.4.*" "finish.1"
> +	gdb_test "reverse-step" ".*fun2\.3.*" "reverse-step.1"
> +	gdb_test "reverse-finish" ".*fun4\.3.*" "reverse-finish.1"
> +	gdb_test "reverse-next" ".*fun4\.2.*" "reverse-next.2"
> +	gdb_test "reverse-finish" ".*main\.2.*" "reverse-finish.2"
> +    }
>   }
> diff --git a/gdb/testsuite/gdb.btrace/stepi.exp b/gdb/testsuite/gdb.btrace/stepi.exp
> index a70a5adf046..3b33ae3106c 100644
> --- a/gdb/testsuite/gdb.btrace/stepi.exp
> +++ b/gdb/testsuite/gdb.btrace/stepi.exp
> @@ -17,7 +17,7 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   # This test is stepping on instruction level.  To guarantee that we always
>   # get the same execution trace, we use an assembly source file.
> @@ -41,11 +41,7 @@ if [info exists COMPILE] {
>       return -1
>   }
>   
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile {}] {
> -    return -1
> -}
> -
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
> @@ -60,119 +56,130 @@ proc check_replay_at { insn } {
>       ] "check replay at $insn"
>   }
>   
> -# trace the call to the test function
> -with_test_prefix "record" {
> -    gdb_test_no_output "record btrace"
> -    gdb_test "next" ".*" "next.1"
> -}
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# we start with stepping to make sure that the trace is fetched automatically
> -with_test_prefix "fetch" {
> -    gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.1"
> -    gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.2"
> +    # trace the call to the test function
> +    with_test_prefix "record" {
> +	gdb_test_no_output "record btrace ${method}"
> +	gdb_test "next" ".*" "next.1"
> +    }
>   
> -    # let's check where we are in the trace
> -    check_replay_at 39
> -}
> +    # we start with stepping to make sure that the trace is fetched automatically
> +    with_test_prefix "fetch" {
> +	gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.1"
> +	gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.2"
>   
> -# let's step forward and check again
> -with_test_prefix "stepi" {
> -    gdb_test "stepi" ".*fun4\.5.*"
> -    check_replay_at 40
> -}
> +	# let's check where we are in the trace
> +	check_replay_at 39
> +    }
>   
> -# with the next step, we stop replaying
> -with_test_prefix "end" {
> -    gdb_test "stepi" ".*main\.3.*"
> -    gdb_test "info record" [multi_line \
> -      "Active record target: record-btrace" \
> -      ".*" \
> -      "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
> -			       ]
> -}
> +    # let's step forward and check again
> +    with_test_prefix "stepi" {
> +	gdb_test "stepi" ".*fun4\.5.*"
> +	check_replay_at 40
> +    }
>   
> -# let's try nexti
> -with_test_prefix "reverse-nexti.1" {
> -    gdb_test "reverse-nexti" ".*main\.2.*"
> -    check_replay_at 1
> -}
> +    # with the next step, we stop replaying
> +    with_test_prefix "end" {
> +	gdb_test "stepi" ".*main\.3.*"
> +	gdb_test "info record" [multi_line \
> +	    "Active record target: record-btrace" \
> +	    ".*" \
> +	    "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
> +	    ]
> +    }
>   
> -# we can't reverse-nexti any further
> -with_test_prefix "reverse-nexti.2" {
> -    gdb_test "reverse-nexti" \
> -	"No more reverse-execution history\.\r\n.*main\.2.*" \
> -	"reverse-nexti.2"
> -    check_replay_at 1
> -}
> +    # let's try nexti
> +    with_test_prefix "reverse-nexti.1" {
> +	gdb_test "reverse-nexti" ".*main\.2.*"
> +	check_replay_at 1
> +    }
>   
> -# but we can step back again
> -with_test_prefix "nexti" {
> -    gdb_test "nexti" ".*main\.3.*"
> -    gdb_test "info record" [multi_line \
> -      "Active record target: record-btrace" \
> -      ".*" \
> -      "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
> -			       ]
> -}
> +    # we can't reverse-nexti any further
> +    with_test_prefix "reverse-nexti.2" {
> +	gdb_test "reverse-nexti" \
> +	    "No more reverse-execution history\.\r\n.*main\.2.*" \
> +	    "reverse-nexti.2"
> +	check_replay_at 1
> +    }
>   
> -# let's step from a goto position somewhere in the middle
> -with_test_prefix "goto" {
> -    gdb_test "record goto 22" ".*fun3\.2.*"
> -    with_test_prefix "goto 22" { check_replay_at 22 }
> +    # but we can step back again
> +    with_test_prefix "nexti" {
> +	gdb_test "nexti" ".*main\.3.*"
> +	gdb_test "info record" [multi_line \
> +	    "Active record target: record-btrace" \
> +	    ".*" \
> +	    "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
> +	    ]
> +    }
>   
> -    gdb_test "stepi" ".*fun1\.1.*" "stepi.3"
> -    with_test_prefix "stepi to 23" { check_replay_at 23 }
> +    # let's step from a goto position somewhere in the middle
> +    with_test_prefix "goto" {
> +	gdb_test "record goto 22" ".*fun3\.2.*"
> +	with_test_prefix "goto 22" { check_replay_at 22 }
>   
> -    gdb_test "reverse-stepi" ".*fun3\.2.*" "reverse-stepi.3"
> -    with_test_prefix "reverse-stepi to 22" { check_replay_at 22 }
> +	gdb_test "stepi" ".*fun1\.1.*" "stepi.3"
> +	with_test_prefix "stepi to 23" { check_replay_at 23 }
>   
> -    gdb_test "nexti" ".*fun3\.3.*"
> -    with_test_prefix "nexti to 27" { check_replay_at 27 }
> +	gdb_test "reverse-stepi" ".*fun3\.2.*" "reverse-stepi.3"
> +	with_test_prefix "reverse-stepi to 22" { check_replay_at 22 }
>   
> -    gdb_test "reverse-nexti" ".*fun3\.2.*" "reverse-nexti.3"
> -    with_test_prefix "reverse-nexti to 22" { check_replay_at 22 }
> -}
> +	gdb_test "nexti" ".*fun3\.3.*"
> +	with_test_prefix "nexti to 27" { check_replay_at 27 }
>   
> -# let's try to step off the left end
> -with_test_prefix "goto begin" {
> -    gdb_test "record goto begin" ".*main\.2.*"
> -    check_replay_at 1
> +	gdb_test "reverse-nexti" ".*fun3\.2.*" "reverse-nexti.3"
> +	with_test_prefix "reverse-nexti to 22" { check_replay_at 22 }
> +    }
>   
> -    with_test_prefix "reverse-stepi" {
> -	gdb_test "reverse-stepi" \
> -	    "No more reverse-execution history\.\r\n.*main\.2.*" \
> -	    "reverse-stepi.1"
> -	gdb_test "reverse-stepi" \
> -	    "No more reverse-execution history\.\r\n.*main\.2.*" \
> -	    "reverse-stepi.2"
> +    # let's try to step off the left end
> +    with_test_prefix "goto begin" {
> +	gdb_test "record goto begin" ".*main\.2.*"
>   	check_replay_at 1
> +
> +	with_test_prefix "reverse-stepi" {
> +	    gdb_test "reverse-stepi" \
> +		"No more reverse-execution history\.\r\n.*main\.2.*" \
> +		"reverse-stepi.1"
> +	    gdb_test "reverse-stepi" \
> +		"No more reverse-execution history\.\r\n.*main\.2.*" \
> +		"reverse-stepi.2"
> +	    check_replay_at 1
> +	}
> +
> +	with_test_prefix "reverse-nexti" {
> +	    gdb_test "reverse-nexti" \
> +		"No more reverse-execution history\.\r\n.*main\.2.*" \
> +		"reverse-nexti.1"
> +	    gdb_test "reverse-nexti" \
> +		"No more reverse-execution history\.\r\n.*main\.2.*" \
> +		"reverse-nexti.2"
> +	    check_replay_at 1
> +	}
> +
> +	# we can step forward, though
> +	with_test_prefix "stepi" {
> +	    gdb_test "stepi" ".*fun4\.1.*"
> +	    check_replay_at 2
> +	}
>       }
>   
> -    with_test_prefix "reverse-nexti" {
> -	gdb_test "reverse-nexti" \
> +    # let's try to step off the left end again
> +    with_test_prefix "reverse-stepi" {
> +	gdb_test "reverse-stepi" ".*main\.2.*" "reverse-stepi.1"
> +	gdb_test "reverse-stepi" \
>   	    "No more reverse-execution history\.\r\n.*main\.2.*" \
> -	    "reverse-nexti.1"
> -	gdb_test "reverse-nexti" \
> +	    "reverse-stepi.2"
> +	gdb_test "reverse-stepi" \
>   	    "No more reverse-execution history\.\r\n.*main\.2.*" \
> -	    "reverse-nexti.2"
> +	    "reverse-stepi.3"
>   	check_replay_at 1
>       }
> -
> -    # we can step forward, though
> -    with_test_prefix "stepi" {
> -	gdb_test "stepi" ".*fun4\.1.*"
> -	check_replay_at 2
> -    }
> -}
> -
> -# let's try to step off the left end again
> -with_test_prefix "reverse-stepi" {
> -    gdb_test "reverse-stepi" ".*main\.2.*" "reverse-stepi.1"
> -    gdb_test "reverse-stepi" \
> -	"No more reverse-execution history\.\r\n.*main\.2.*" \
> -	"reverse-stepi.2"
> -    gdb_test "reverse-stepi" \
> -	"No more reverse-execution history\.\r\n.*main\.2.*" \
> -	"reverse-stepi.3"
> -    check_replay_at 1
>   }
> diff --git a/gdb/testsuite/gdb.btrace/tailcall-only.exp b/gdb/testsuite/gdb.btrace/tailcall-only.exp
> index ae3b04e3b66..fbc7d96ec5e 100644
> --- a/gdb/testsuite/gdb.btrace/tailcall-only.exp
> +++ b/gdb/testsuite/gdb.btrace/tailcall-only.exp
> @@ -20,8 +20,7 @@
>   # calls.  This used to cause a crash in get_frame_type.
>   #
>   
> -require allow_btrace_tests
> -
> +require target_supports_btrace
>   # This test requires the compiler to generate a tail call.  To guarantee that
>   # we always get one, we use an assembly source file.
>   #
> @@ -29,6 +28,7 @@ require allow_btrace_tests
>   #
>   # Luckily, they are similar enough that a single test script can handle
>   # both.
> +
>   set opts {}
>   if [info exists COMPILE] {
>       # make check RUNTESTFLAGS="gdb.btrace/tailcall-only.exp COMPILE=1"
> @@ -45,55 +45,63 @@ if [info exists COMPILE] {
>       return -1
>   }
>   
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
> +if [build_executable "failed to prepare" $testfile $srcfile $opts] {
>       return -1
>   }
>   
> -if ![runto_main] {
> -    return -1
> -}
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
>   
> -# we want to see the full trace for this test
> -gdb_test_no_output "set record function-call-history-size 0"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# trace foo
> -gdb_test "step" ".*" "prepare for recording"
> -gdb_test_no_output "record btrace"
> -gdb_test "stepi 4" ".*" "record branch trace"
> +    # we want to see the full trace for this test
> +    gdb_test_no_output "set record function-call-history-size 0"
>   
> -# for debugging
> -gdb_test "info record" ".*"
> +    # trace foo
> +    gdb_test "step" ".*" "prepare for recording"
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_test "stepi 4" ".*" "record branch trace"
>   
> -# show the branch trace with calls indented
> -gdb_test "record function-call-history /c 1" [multi_line \
> -  "1\tfoo" \
> -  "2\t  foo_1" \
> -  "3\t    bar" \
> -  "4\t      bar_1"
> -  ] "function-call-history"
> +    # for debugging
> +    gdb_test "info record" ".*"
>   
> -# We can step
> -gdb_test "record goto begin" ".*foo.*"
> -gdb_test "stepi" ".*foo_1.*" "step into foo_1"
> -gdb_test "step" ".*bar.*" "step into bar"
> -gdb_test "stepi" ".*bar_1.*" "step into bar_1"
> +    # show the branch trace with calls indented
> +    gdb_test "record function-call-history /c 1" [multi_line \
> +	"1\tfoo" \
> +	"2\t  foo_1" \
> +	"3\t    bar" \
> +	"4\t      bar_1"
> +	] "function-call-history"
>   
> -# We can neither finish nor return.
> -gdb_test "finish" "Cannot find the caller frame.*"
> -gdb_test_multiple "return" "return" {
> -  -re "Make .* return now.*y or n. $" {
> -    send_gdb "y\n"
> -    exp_continue
> -  }
> -  -re "Cannot find the caller frame.*$gdb_prompt $" {
> -    pass "return"
> -  }
> -}
> +    # We can step
> +    gdb_test "record goto begin" ".*foo.*"
> +    gdb_test "stepi" ".*foo_1.*" "step into foo_1"
> +    gdb_test "step" ".*bar.*" "step into bar"
> +    gdb_test "stepi" ".*bar_1.*" "step into bar_1"
>   
> -# But we can reverse-finish
> -gdb_test "reverse-finish" ".*bar.*"
> -gdb_test "reverse-step" ".*foo_1.*"
> +    # We can neither finish nor return.
> +    gdb_test "finish" "Cannot find the caller frame.*"
> +    gdb_test_multiple "return" "return" {
> +	-re "Make .* return now.*y or n. $" {
> +	    send_gdb "y\n"
> +	    continue
> +	}
> +	-re "Cannot find the caller frame.*$gdb_prompt $" {
> +	    pass "return"
> +	}
> +    }
>   
> -# Info frame isn't useful but doesn't crash as it used to.
> -gdb_test "up" ".*foo.*"
> -gdb_test "info frame" ".*"
> +    # But we can reverse-finish
> +    gdb_test "reverse-finish" ".*bar.*"
> +    gdb_test "reverse-step" ".*foo_1.*"
> +
> +    # Info frame isn't useful but doesn't crash as it used to.
> +    gdb_test "up" ".*foo.*"
> +    gdb_test "info frame" ".*"
> +}
> diff --git a/gdb/testsuite/gdb.btrace/tailcall.exp b/gdb/testsuite/gdb.btrace/tailcall.exp
> index 198cfa988dd..11f583bdf52 100644
> --- a/gdb/testsuite/gdb.btrace/tailcall.exp
> +++ b/gdb/testsuite/gdb.btrace/tailcall.exp
> @@ -17,7 +17,10 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> +if {![target_supports_btrace]} {
> +    unsupported "target does not support btrace."
> +    return -1
> +}
The new standard for the testsuite is to use require, instead of this 
if-untested-return style.
>   
>   # This test requires the compiler to generate a tail call.  To guarantee that
>   # we always get one, we use an assembly source file.
> @@ -32,20 +35,17 @@ if [info exists COMPILE] {
>       standard_testfile tailcall.c
>       lappend opts debug optimize=-O2
>   } elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} {
> -	if {[is_amd64_regs_target]} {
> -		standard_testfile x86_64-tailcall.S
> -	} else {
> -		standard_testfile i686-tailcall.S
> -	}
> +    if {[is_amd64_regs_target]} {
> +	standard_testfile x86_64-tailcall.S
> +    } else {
> +	standard_testfile i686-tailcall.S
> +    }
>   } else {
>       unsupported "target architecture not supported"
>       return -1
>   }
>   
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
> -    return -1
> -}
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile $opts] {
>       return -1
>   }
>   
> @@ -54,63 +54,75 @@ if ![runto_main] {
>   # that path to be present, but does not require it.
>   set optional_filepath {[^\n]*}
>   
> -# we want to see the full trace for this test
> -gdb_test_no_output "set record function-call-history-size 0"
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
>   
> -# trace the call to foo
> -gdb_test_no_output "record btrace"
> -gdb_test "next 2"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# show the flat branch trace
> -gdb_test "record function-call-history 1" [multi_line \
> -  "1\tmain" \
> -  "2\tfoo" \
> -  "3\tbar" \
> -  "4\tmain" \
> -  ] "flat"
> +    # we want to see the full trace for this test
> +    gdb_test_no_output "set record function-call-history-size 0"
>   
> -# show the branch trace with calls indented
> -gdb_test "record function-call-history /c 1" [multi_line \
> -  "1\tmain" \
> -  "2\t  foo" \
> -  "3\t    bar" \
> -  "4\tmain" \
> -  ] "indented"
> +    # trace the call to foo
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_test "next 2"
>   
> -# go into bar
> -gdb_test "record goto 4" ".*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*"
> +    # show the flat branch trace
> +    gdb_test "record function-call-history 1" [multi_line \
> +	"1\tmain" \
> +	"2\tfoo" \
> +	"3\tbar" \
> +	"4\tmain" \
> +	] "flat"
>   
> -# check the backtrace
> -gdb_test "backtrace" [multi_line \
> -  "#0.*bar \\(\\) at ${optional_filepath}tailcall.c:24" \
> -  "#1.*foo \\(\\) at ${optional_filepath}tailcall.c:29" \
> -  "#2.*main \\(\\) at ${optional_filepath}tailcall.c:37" \
> -  "Backtrace stopped: not enough registers or memory available to unwind further" \
> -  ]
> +    # show the branch trace with calls indented
> +    gdb_test "record function-call-history /c 1" [multi_line \
> +	"1\tmain" \
> +	"2\t  foo" \
> +	"3\t    bar" \
> +	"4\tmain" \
> +	] "indented"
>   
> -# walk the backtrace
> -gdb_test "up" "#1\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" "up to foo"
> -gdb_test "up" "#2\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" "up to main"
> -gdb_test "down" "#1\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" "down to foo"
> +    # go into bar
> +    gdb_test "record goto 4" ".*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*"
>   
> -# test stepping into and out of tailcalls.
> -gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
> -    "finish.1"
> -gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*" \
> -    "reverse-step.1"
> -gdb_test "reverse-finish" "\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" \
> -    "reverse-finish.1"
> -gdb_test "reverse-step" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" \
> -    "reverse-step.2"
> -gdb_test "next" "\[^\r\n\]*38.*" \
> -    "next.1"
> -gdb_test "reverse-next" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" \
> -    "reverse-next.1"
> -gdb_test "step" "\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" \
> -    "step.1"
> -gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
> -    "finish.2"
> -gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*" \
> -    "reverse-step.3"
> -gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
> -    "finish.3"
> +    # check the backtrace
> +    gdb_test "backtrace" [multi_line \
> +	"#0.*bar \\(\\) at ${optional_filepath}tailcall.c:24" \
> +	"#1.*foo \\(\\) at ${optional_filepath}tailcall.c:29" \
> +	"#2.*main \\(\\) at ${optional_filepath}tailcall.c:37" \
> +	"Backtrace stopped: not enough registers or memory available to unwind further" \
> +	]
> +
> +    # walk the backtrace
> +    gdb_test "up" "#1\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" "up to foo"
> +    gdb_test "up" "#2\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" "up to main"
> +    gdb_test "down" "#1\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" "down to foo"
> +
> +    # test stepping into and out of tailcalls.
> +    gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
> +	"finish.1"
> +    gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*" \
> +	"reverse-step.1"
> +    gdb_test "reverse-finish" "\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" \
> +	"reverse-finish.1"
> +    gdb_test "reverse-step" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" \
> +	"reverse-step.2"
> +    gdb_test "next" "\[^\r\n\]*38.*" \
> +	"next.1"
> +    gdb_test "reverse-next" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:37\r\n.*" \
> +	"reverse-next.1"
> +    gdb_test "step" "\[^\r\n\]*foo \\(\\) at ${optional_filepath}tailcall.c:29\r\n.*" \
> +	"step.1"
> +    gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
> +	"finish.2"
> +    gdb_test "reverse-step" "\[^\r\n\]*bar \\(\\) at ${optional_filepath}tailcall.c:24\r\n.*" \
> +	"reverse-step.3"
> +    gdb_test "finish" "\[^\r\n\]*main \\(\\) at ${optional_filepath}tailcall.c:38\r\n.*" \
> +	"finish.3"
> +}
> diff --git a/gdb/testsuite/gdb.btrace/tsx.exp b/gdb/testsuite/gdb.btrace/tsx.exp
> index d312b15027c..11af6ff1bf7 100644
> --- a/gdb/testsuite/gdb.btrace/tsx.exp
> +++ b/gdb/testsuite/gdb.btrace/tsx.exp
> @@ -15,7 +15,7 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_pt_tests allow_tsx_tests
> +require allow_btrace_pt_tests allow_tsx_tests target_supports_btrace

Do you happen to know why this test only works with pt style btrace? I 
apparently dont have TSX hardware, so I can't test things by hand and 
figure it out, unfortunately.

if it is the point of the test to only use pt, I don't think the 
addition of "target_supports_btrace" makes sense, since the 
allow_btrace_pt_tests already covers what you need. I think just a 
comment at the top of the file saying that this is a btrace pt specific 
test would suffice.

Otherwise, I'd like to see this test also using the BTS style.

>   
>   standard_testfile .c x86-tsx.S
>   if [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" {debug}] {
> diff --git a/gdb/testsuite/gdb.btrace/unknown_functions.exp b/gdb/testsuite/gdb.btrace/unknown_functions.exp
> index b335e74c87a..9fca4a9eec5 100644
> --- a/gdb/testsuite/gdb.btrace/unknown_functions.exp
> +++ b/gdb/testsuite/gdb.btrace/unknown_functions.exp
> @@ -17,48 +17,54 @@
>   # You should have received a copy of the GNU General Public License
>   # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   
> -require allow_btrace_tests
> -
> +require target_supports_btrace
>   standard_testfile
>   
>   # We expect a specific function call history.  This gets messed up with
>   # PIE on 32-bit.
>   #
>   # Also discard local symbols.
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile \
> +if [build_executable "failed to prepare" $testfile $srcfile \
>   	{ldflags=-Wl,-x nopie}] {
>       return -1
>   }
>   
> -if ![runto test] {
> -    return -1
> -}
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto test] {
> +	continue
> +    }
>   
> -# we want to see the full trace for this test
> -gdb_test_no_output "set record function-call-history-size 0"
> +    # we want to see the full trace for this test
> +    gdb_test_no_output "set record function-call-history-size 0"
>   
> -# trace from one call of test to the next
> -gdb_test_no_output "record btrace"
> -gdb_continue_to_breakpoint "cont to test" ".*test.*"
> +    # trace from one call of test to the next
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_continue_to_breakpoint "cont to test" ".*test.*"
>   
> -# show the flat branch trace
> -gdb_test "record function-call-history 1" [multi_line \
> -  "1\ttest" \
> -  "2\t\\\?\\\?" \
> -  "3\t\\\?\\\?" \
> -  "4\t\\\?\\\?" \
> -  "5\ttest" \
> -  "6\tmain" \
> -  "7\ttest" \
> -  ] "flat"
> +    # show the flat branch trace
> +    gdb_test "record function-call-history 1" [multi_line \
> +	"1\ttest" \
> +	"2\t\\\?\\\?" \
> +	"3\t\\\?\\\?" \
> +	"4\t\\\?\\\?" \
> +	"5\ttest" \
> +	"6\tmain" \
> +	"7\ttest" \
> +	] "flat"
>   
> -# show the branch trace with calls indented
> -gdb_test "record function-call-history /c 1" [multi_line \
> -  "1\t  test" \
> -  "2\t    \\\?\\\?" \
> -  "3\t      \\\?\\\?" \
> -  "4\t    \\\?\\\?" \
> -  "5\t  test" \
> -  "6\tmain" \
> -  "7\t  test" \
> -  ] "indented"
> +    # show the branch trace with calls indented
> +    gdb_test "record function-call-history /c 1" [multi_line \
> +	"1\t  test" \
> +	"2\t    \\\?\\\?" \
> +	"3\t      \\\?\\\?" \
> +	"4\t    \\\?\\\?" \
> +	"5\t  test" \
> +	"6\tmain" \
> +	"7\t  test" \
> +	] "indented"
> +}
> diff --git a/gdb/testsuite/gdb.btrace/vdso.exp b/gdb/testsuite/gdb.btrace/vdso.exp
> index edbb222f7b6..36e7b9eefba 100644
> --- a/gdb/testsuite/gdb.btrace/vdso.exp
> +++ b/gdb/testsuite/gdb.btrace/vdso.exp
> @@ -20,25 +20,36 @@
>   #
>   # Test that we can access the vdso memory during replay for stepping.
>   
> -require allow_btrace_tests
> +require target_supports_btrace
>   
>   standard_testfile
> -if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
> +if {![target_supports_btrace]} {
> +    unsupported "target does not support btrace."
>       return -1
>   }
>   
> -if ![runto_main] {
> +if [build_executable "failed to prepare" $testfile $srcfile] {
>       return -1
>   }
>   
> -# capture the disassembly of gettimeofday while live debugging
> -set live_gettimeofday [capture_command_output "disassemble gettimeofday" ""]
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# trace the test code
> -gdb_test_no_output "record btrace"
> -gdb_test "stepi" ".*"
> +    # capture the disassembly of gettimeofday while live debugging
> +    set live_gettimeofday [capture_command_output "disassemble gettimeofday" ""]
>   
> -with_test_prefix "replay" {
> +    # trace the test code
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_test "stepi" ".*"
> +
> +    with_test_prefix "replay" {
>   	# start replaying
>   	gdb_test "record goto begin" ".*"
>   	gdb_test "info record" "Replay in progress\.\[^\\\r\\\n\]*"
> @@ -48,8 +59,9 @@ with_test_prefix "replay" {
>   
>   	# the two disassemblies must be identical
>   	if ![string compare $live_gettimeofday $replay_gettimeofday]  {
> -		pass "disassemble gettimeofday"
> -	} else {
> -		fail "disassemble gettimeofday"
> +	    pass "disassemble gettimeofday"
> +	} else 	{
> +	    fail "disassemble gettimeofday"
>   	}
> +    }
>   }
> diff --git a/gdb/testsuite/gdb.python/py-record-btrace-threads.exp b/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
> index d7238790bc4..337a6f8b7c7 100644
> --- a/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
> +++ b/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
> @@ -17,7 +17,7 @@
>   
>   load_lib gdb-python.exp
>   
> -require allow_btrace_tests allow_python_tests
> +require target_supports_btrace allow_python_tests
>   
>   standard_testfile
>   
> @@ -25,45 +25,52 @@ if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {deb
>       untested "failed to prepare"
>       return -1
>   }
> -clean_restart $testfile
>   
> -if { ![runto_main] } {
> -    return -1
> -}
> +foreach_with_prefix method {"bts" "pt"} {
> +    if { ![allow_btrace_tests $method] } {
> +	unsupported "target does not support record-btrace ${method}"
> +	continue
> +    }
>   
> -# set up breakpoints
> -gdb_breakpoint $srcfile:[gdb_get_line_number "bp1" $srcfile]
> -gdb_breakpoint $srcfile:[gdb_get_line_number "bp2" $srcfile]
> +    clean_restart "${testfile}"
> +    if ![runto_main] {
> +	continue
> +    }
>   
> -# record data
> -gdb_continue_to_breakpoint "cont to bp.1" ".*bp1.*"
> -gdb_test_no_output "record btrace"
> -gdb_continue_to_breakpoint "cont to bp.2" ".*bp2.*"
> +    # set up breakpoints
> +    gdb_breakpoint $srcfile:[gdb_get_line_number "bp1" $srcfile]
> +    gdb_breakpoint $srcfile:[gdb_get_line_number "bp2" $srcfile]
>   
> -# acquire the record objects for thread 1 and thread 2
> -gdb_test "thread 1" ".*"
> -gdb_test "record function-call-history" ".*" "fch thread 1"
> -gdb_test_no_output "python rec1 = gdb.current_recording()"
> -gdb_test "thread 2" ".*"
> -gdb_test "record function-call-history" ".*" "fch thread 2"
> -gdb_test_no_output "python rec2 = gdb.current_recording()"
> +    # record data
> +    gdb_continue_to_breakpoint "cont to bp.1" ".*bp1.*"
> +    gdb_test_no_output "record btrace ${method}"
> +    gdb_continue_to_breakpoint "cont to bp.2" ".*bp2.*"
>   
> -# Thread 1 is supposed to call func1 (), thread 2 is supposed to call func2 ().
> -# Check that the function call history for the current thread contains a call
> -# to the right function and does not contain a call to the wrong function.
> -proc check_insn_for_thread { self other } {
> -  with_test_prefix "checking thread $self" {
> -    gdb_test_no_output "python fch = rec$self.function_call_history"
> -    gdb_test_no_output "python f1calls = \{x for x in fch if x.symbol and x.symbol.name == \"func1\"\}"
> -    gdb_test_no_output "python f2calls = \{x for x in fch if x.symbol and x.symbol.name == \"func2\"\}"
> +    # acquire the record objects for thread 1 and thread 2
> +    gdb_test "thread 1" ".*"
> +    gdb_test "record function-call-history" ".*" "fch thread 1"
> +    gdb_test_no_output "python rec1 = gdb.current_recording()"
> +    gdb_test "thread 2" ".*"
> +    gdb_test "record function-call-history" ".*" "fch thread 2"
> +    gdb_test_no_output "python rec2 = gdb.current_recording()"
>   
> -    gdb_test "python print(not f${self}calls)" "False"
> -    gdb_test "python print(not f${other}calls)" "True"
> -  }
> -}
> +    # Thread 1 is supposed to call func1 (), thread 2 is supposed to call func2 ().
> +    # Check that the function call history for the current thread contains a call
> +    # to the right function and does not contain a call to the wrong function.
> +    proc check_insn_for_thread { self other } {
> +	with_test_prefix "checking thread $self" {
> +	    gdb_test_no_output "python fch = rec$self.function_call_history"
> +	    gdb_test_no_output "python f1calls = \{x for x in fch if x.symbol and x.symbol.name == \"func1\"\}"
> +	    gdb_test_no_output "python f2calls = \{x for x in fch if x.symbol and x.symbol.name == \"func2\"\}"
> +
> +	    gdb_test "python print(not f${self}calls)" "False"
> +	    gdb_test "python print(not f${other}calls)" "True"
> +	}
> +    }
>   
> -foreach_with_prefix thread { 1 2 } {
> -  gdb_test "thread $thread"
> -  check_insn_for_thread 1 2
> -  check_insn_for_thread 2 1
> +    foreach_with_prefix thread { 1 2 } {
> +	gdb_test "thread $thread"
> +	check_insn_for_thread 1 2
> +	check_insn_for_thread 2 1
> +    }
>   }
> diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp
> index 71ff52ed137..021271e1d14 100644
> --- a/gdb/testsuite/gdb.python/py-record-btrace.exp
> +++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
> @@ -17,7 +17,8 @@
>   
>   # Skip this test if btrace is disabled.
>   
> -require allow_btrace_tests allow_python_tests
> +require allow_btrace_bts_tests allow_btrace_pt_tests allow_python_tests
> +require target_supports_btrace
In this test you're requiring that both pt and bts methods of recording 
are available. Is that really necessary?
Also, the target_supports_btrace here is reduntant, since the previous 
line is even more restrictive.
>   
>   load_lib gdb-python.exp
>   
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 9a906f0f349..241aec7b161 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -4008,17 +4008,25 @@ gdb_caching_proc allow_avx512fp16_tests {} {
>       return $allow_avx512fp16_tests
>   }
>   
> -# Run a test on the target to see if it supports btrace hardware.  Return 1 if so,
> -# 0 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
> -
> -gdb_caching_proc allow_btrace_tests {} {
> -    global srcdir subdir gdb_prompt inferior_exited_re
> +# Check if btrace is supported on the target.  Return 1 if
> +# so, 0 if it does not.
>   
> -    set me "allow_btrace_tests"
> +gdb_caching_proc target_supports_btrace {} {
>       if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
> -	verbose "$me:  target does not support btrace, returning 0" 2
> +	verbose "target_supports_btrace:  target does not support btrace, returning 0" 2
>   	return 0
>       }
> +    return 1

As I mentioned previously, I think the proc name shouldn't be changed, 
and the new proc should be called target_supports_btrace with a 
parameter, or target_supports_btrace_method and the parameter.

Also, now you're not  testing further than if the target is an intel 
board. I think it would be better if first you tried the istarget above, 
then checked if either bts or pt is supported using the procs below. 
Since they are caching procs, there's no problem in calling them here 
then calling them again in the test files anyway.

> +}
> +
> +# Run a test on the target to see if it supports btrace 'bts' method.  Return
> +# 1 if so, 0 if it does not.  Based on 'check_vmx_hw_available' from the GCC
> +# testsuite.
> +
> +gdb_caching_proc allow_btrace_bts_tests {} {
> +    global srcdir subdir gdb_prompt inferior_exited_re
> +
> +    set me "allow_btrace_bts_tests"
>   
>       # Compile a test program.
>       set src { int main() { return 0; } }
> @@ -4037,19 +4045,19 @@ gdb_caching_proc allow_btrace_tests {} {
>       }
>       # In case of an unexpected output, we return 2 as a fail value.
>       set allow_btrace_tests 2
> -    gdb_test_multiple "record btrace" "check btrace support" {
> -        -re "You can't do that when your target is.*\r\n$gdb_prompt $" {
> +    gdb_test_multiple "record btrace bts" "check btrace bts support" {
> +	-re "You can't do that when your target is.*\r\n$gdb_prompt $" {
>   	    set allow_btrace_tests 0
> -        }
> -        -re "Target does not support branch tracing.*\r\n$gdb_prompt $" {
> +	}
> +	-re "Target does not support branch tracing.*\r\n$gdb_prompt $" {
>   	    set allow_btrace_tests 0
> -        }
> -        -re "Could not enable branch tracing.*\r\n$gdb_prompt $" {
> +	}
> +	-re "Could not enable branch tracing.*\r\n$gdb_prompt $" {
>   	    set allow_btrace_tests 0
> -        }
> -        -re "^record btrace\r\n$gdb_prompt $" {
> +	}
> +	-re "^record btrace bts\r\n$gdb_prompt $" {
>   	    set allow_btrace_tests 1
> -        }
> +	}
>       }
>       gdb_exit
>       remote_file build delete $obj
> @@ -4066,10 +4074,6 @@ gdb_caching_proc allow_btrace_pt_tests {} {
>       global srcdir subdir gdb_prompt inferior_exited_re
>   
>       set me "allow_btrace_pt_tests"
> -    if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
> -	verbose "$me:  target does not support btrace, returning 1" 2
> -	return 0
> -    }
>   
>       # Compile a test program.
>       set src { int main() { return 0; } }
> @@ -4112,6 +4116,22 @@ gdb_caching_proc allow_btrace_pt_tests {} {
>       return $allow_btrace_pt_tests
>   }
>   
> +# Wrapper function to check if input btrace method is supported.  Returns 1
> +# if it is supported otherwise returns 0.
> +
> +proc allow_btrace_tests {method} {
> +    if {[string match "pt" "${method}"]} {
> +	return [allow_btrace_pt_tests]
> +    } elseif {[string match "bts" "${method}"]} {
> +	return [allow_btrace_bts_tests]
> +    }
> +
> +    verbose -log "warning: unknown btrace recording method '${method}'"
> +    # Skip test for unknown method name.
> +    return 0
> +}
> +
> +
>   # Run a test on the target to see if it supports Aarch64 SVE hardware.
>   # Return 1 if so, 0 if it does not.  Note this causes a restart of GDB.
>   

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[relevance 0%]

* Re: [PATCH 1/3] Fix "run" failure with GDBserver
  @ 2024-02-13 21:11  3%     ` Pedro Alves
  0 siblings, 0 replies; 200+ results
From: Pedro Alves @ 2024-02-13 21:11 UTC (permalink / raw)
  To: Lancelot SIX; +Cc: gdb-patches

On 2024-02-13 15:19, Lancelot SIX wrote:
> Hi Pedro,

Hi!

> 
> On Mon, Feb 12, 2024 at 08:01:51PM +0000, Pedro Alves wrote:

>> ---
>>  gdb/testsuite/gdb.base/run-fail-twice.exp | 67 +++++++++++++++++++++++
>>  gdbserver/server.cc                       | 10 +++-
>>  2 files changed, 76 insertions(+), 1 deletion(-)
>>  create mode 100644 gdb/testsuite/gdb.base/run-fail-twice.exp
>>
> 
> Looks like you forgot the gdb/testsuite/gdb.base/run-fail-twice.c file?

Indeed...  Added now.

> 
>> diff --git a/gdb/testsuite/gdb.base/run-fail-twice.exp b/gdb/testsuite/gdb.base/run-fail-twice.exp

>> +
>> +# Test doing a "run" that fails, and then another "run".
>> +
>> +# The purpose of this testcase is to test the "run" command.  If we
>> +# cannot use it, then there is no point in running this testcase.
>> +require !use_gdb_stub

I've switched this to:

 require target_can_use_run_cmd

>> +
>> +standard_testfile
>> +
>> +if {[build_executable "failed to build" $testfile $srcfile {debug}]} {
>> +    return -1
>> +}
>> +
>> +proc test_run {testname} {
>> +    gdb_run_cmd

I switched to calling "run" directly, as that's what we're testing anyhow.

>> +    gdb_test_multiple "" $testname {
>> +	-re -wrap "During startup program exited with code 126\\." {
>> +	    # What we get on GNU/Linux.
>> +	    pass $gdb_test_name
>> +	}
>> +	-re -wrap "Error creating process.*" {
>> +	    # What we get on Windows.
>> +	    pass $gdb_test_name
>> +	}
>> +	-re -wrap "Running .* on the remote target failed" {
>> +	    # What we get with older GDBserver and other remote
>> +	    # targets.
>> +	    pass $gdb_test_name
>> +	}
>> +    }
>> +}
>> +
>> +proc_with_prefix test {} {
>> +    global gdb_prompt binfile
>> +
>> +    clean_restart $binfile
>> +
>> +    gdb_test_no_output "set confirm off"
>> +
>> +    gdb_remote_download host $binfile $binfile.nox
>> +    remote_exec target "chmod \"a-x\" $binfile.nox"
>> +    gdb_test "exec-file $binfile.nox" \
> 
> Couldn't you use gdb_test_no_output and remove the 2nd argument?

I can!  And I did.

> 
>> +	"" \
>> +	"exec-file \$binfile.nox"
>> +    gdb_test "set remote exec-file $binfile.nox" \
>> +	"" \
> 
> Same here.
> 

Ditto.

Here's the updated patch.

---- 8< ----
From 04b71816555898fa804a76aa0412b1bad1dc9692 Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>
Subject: [PATCH] Fix "run" failure with GDBserver

If starting the inferior process with "run" (vRun packet) fails,
GDBserver throws an error that escapes all the way to the top level.
When an error escapes all the way like that, GDBserver interprets it
as a disconnection, and either goes back to waiting for a new GDB
connection, or exits, if --once was specified.

E.g., with the testcase program added by this commit, we see:

On GDB side:

 ...
 (gdb) tar extended-remote :999
 ...
 Remote debugging using :9999
 (gdb) r
 Starting program:
 Running ".../gdb.base/run-fail-twice/run-fail-twice.nox" on the remote target failed
 (gdb)

On GDBserver side:

 $ gdbserver --once --multi :9999
 Remote debugging from host 127.0.0.1, port 34344
 bash: line 1: .../gdb.base/run-fail-twice/run-fail-twice.nox: Permission denied
 bash: line 1: exec: .../gdb.base/run-fail-twice/run-fail-twice.nox: cannot execute: Permission denied
 gdbserver: During startup program exited with code 126.
 $   # gdbserver exited

This is wrong, as we've connected with extended-remote/--multi.
GDBserver should just report an error to vCont, and continue connected
to GDB, waiting for other commands.

This commit fixes GDBserver by catching the error locally in
handle_v_run.

Change-Id: Ib386f267522603f554b52a885b15229c9639e870
---
 gdb/testsuite/gdb.base/run-fail-twice.c   | 20 +++++++
 gdb/testsuite/gdb.base/run-fail-twice.exp | 63 +++++++++++++++++++++++
 gdbserver/server.cc                       | 10 +++-
 3 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.base/run-fail-twice.c
 create mode 100644 gdb/testsuite/gdb.base/run-fail-twice.exp

diff --git a/gdb/testsuite/gdb.base/run-fail-twice.c b/gdb/testsuite/gdb.base/run-fail-twice.c
new file mode 100644
index 00000000000..fddf841eb3e
--- /dev/null
+++ b/gdb/testsuite/gdb.base/run-fail-twice.c
@@ -0,0 +1,20 @@
+/* Copyright 2024 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int
+main (int argc, char **argv)
+{
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/run-fail-twice.exp b/gdb/testsuite/gdb.base/run-fail-twice.exp
new file mode 100644
index 00000000000..676fc486fbf
--- /dev/null
+++ b/gdb/testsuite/gdb.base/run-fail-twice.exp
@@ -0,0 +1,63 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test doing a "run" that fails, and then another "run".
+
+require target_can_use_run_cmd
+
+standard_testfile
+
+if {[build_executable "failed to build" $testfile $srcfile {debug}]} {
+    return -1
+}
+
+proc test_run {testname} {
+    gdb_test_multiple "run" $testname {
+	-re -wrap "During startup program exited with code 126\\." {
+	    # What we get on GNU/Linux.
+	    pass $gdb_test_name
+	}
+	-re -wrap "Error creating process.*" {
+	    # What we get on Windows.
+	    pass $gdb_test_name
+	}
+	-re -wrap "Running .* on the remote target failed" {
+	    # What we get with remote targets.
+	    pass $gdb_test_name
+	}
+    }
+}
+
+proc_with_prefix test {} {
+    global gdb_prompt binfile
+
+    clean_restart $binfile
+
+    gdb_test_no_output "set confirm off"
+
+    gdb_remote_download host $binfile $binfile.nox
+    remote_exec target "chmod \"a-x\" $binfile.nox"
+    gdb_test_no_output \
+	"exec-file $binfile.nox" \
+	"exec-file \$binfile.nox"
+    gdb_test_no_output \
+	"set remote exec-file $binfile.nox" \
+	"set remote exec-file \$binfile.nox"
+
+    test_run "bad run 1"
+    test_run "bad run 2"
+}
+
+test
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 74c7763d777..14a19bc1882 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3428,7 +3428,15 @@ handle_v_run (char *own_buf)
   free_vector_argv (program_args);
   program_args = new_argv;
 
-  target_create_inferior (program_path.get (), program_args);
+  try
+    {
+      target_create_inferior (program_path.get (), program_args);
+    }
+  catch (const gdb_exception_error &exception)
+    {
+      sprintf (own_buf, "E.%s", exception.what ());
+      return;
+    }
 
   if (cs.last_status.kind () == TARGET_WAITKIND_STOPPED)
     {

base-commit: a16034bf6417dc2259fef43fd5bcc2dd1dac562f
-- 
2.43.0



^ permalink raw reply	[relevance 3%]

* [PATCH v2 2/2] Add return value to DAP scope
  @ 2024-02-13 16:58  2% ` Tom Tromey
  0 siblings, 0 replies; 200+ results
From: Tom Tromey @ 2024-02-13 16:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kévin Le Gouguec

A bug report in the DAP specification repository pointed out that it
is typical for DAP implementations to put a function's return value
into the outermost scope.

This patch changes gdb to follow this convention.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31341
Reviewed-By: Kévin Le Gouguec <legouguec@adacore.com>
---
 gdb/python/lib/gdb/dap/events.py   |  3 ++
 gdb/python/lib/gdb/dap/scopes.py   | 39 +++++++++++++++++-
 gdb/testsuite/gdb.dap/step-out.c   | 36 +++++++++++++++++
 gdb/testsuite/gdb.dap/step-out.exp | 82 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 158 insertions(+), 2 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py
index 41302229ee5..928f23fd3ff 100644
--- a/gdb/python/lib/gdb/dap/events.py
+++ b/gdb/python/lib/gdb/dap/events.py
@@ -15,6 +15,7 @@
 
 import gdb
 
+from .scopes import set_finish_value
 from .server import send_event
 from .startup import exec_and_log, in_gdb_thread, log
 from .modules import is_module, make_module
@@ -218,6 +219,8 @@ def _on_stop(event):
     }
     if isinstance(event, gdb.BreakpointEvent):
         obj["hitBreakpointIds"] = [x.number for x in event.breakpoints]
+    if hasattr(event, "details") and "finish-value" in event.details:
+        set_finish_value(event.details["finish-value"])
 
     global _expected_pause
     global _expected_stop_reason
diff --git a/gdb/python/lib/gdb/dap/scopes.py b/gdb/python/lib/gdb/dap/scopes.py
index ff553259ea9..be2c382b40b 100644
--- a/gdb/python/lib/gdb/dap/scopes.py
+++ b/gdb/python/lib/gdb/dap/scopes.py
@@ -25,17 +25,32 @@ from .varref import BaseReference
 frame_to_scope = {}
 
 
+# If the most recent stop was due to a 'finish', and the return value
+# could be computed, then this holds that value.  Otherwise it holds
+# None.
+_last_return_value = None
+
+
 # When the inferior is re-started, we erase all scope references.  See
 # the section "Lifetime of Objects References" in the spec.
 @in_gdb_thread
 def clear_scopes(event):
     global frame_to_scope
     frame_to_scope = {}
+    global _last_return_value
+    _last_return_value = None
 
 
 gdb.events.cont.connect(clear_scopes)
 
 
+@in_gdb_thread
+def set_finish_value(val):
+    """Set the current 'finish' value on a stop."""
+    global _last_return_value
+    _last_return_value = val
+
+
 # A helper function to compute the value of a symbol.  SYM is either a
 # gdb.Symbol, or an object implementing the SymValueWrapper interface.
 # FRAME is a frame wrapper, as produced by a frame filter.  Returns a
@@ -76,7 +91,7 @@ class _ScopeReference(BaseReference):
         result["presentationHint"] = self.hint
         # How would we know?
         result["expensive"] = False
-        result["namedVariables"] = len(self.var_list)
+        result["namedVariables"] = self.child_count()
         if self.line is not None:
             result["line"] = self.line
             # FIXME construct a Source object
@@ -93,6 +108,22 @@ class _ScopeReference(BaseReference):
         return symbol_value(self.var_list[idx], self.frame)
 
 
+# A _ScopeReference that prepends the most recent return value.  Note
+# that this object is only created if such a value actually exists.
+class _FinishScopeReference(_ScopeReference):
+    def __init__(self, *args):
+        super().__init__(*args)
+
+    def child_count(self):
+        return super().child_count() + 1
+
+    def fetch_one_child(self, idx):
+        if idx == 0:
+            global _last_return_value
+            return ("(return)", _last_return_value)
+        return super().fetch_one_child(idx - 1)
+
+
 class _RegisterReference(_ScopeReference):
     def __init__(self, name, frame):
         super().__init__(
@@ -109,6 +140,7 @@ class _RegisterReference(_ScopeReference):
 
 @request("scopes")
 def scopes(*, frameId: int, **extra):
+    global _last_return_value
     global frame_to_scope
     if frameId in frame_to_scope:
         scopes = frame_to_scope[frameId]
@@ -120,10 +152,13 @@ def scopes(*, frameId: int, **extra):
         args = tuple(frame.frame_args() or ())
         if args:
             scopes.append(_ScopeReference("Arguments", "arguments", frame, args))
+        has_return_value = frameId == 0 and _last_return_value is not None
         # Make sure to handle the None case as well as the empty
         # iterator case.
         locs = tuple(frame.frame_locals() or ())
-        if locs:
+        if has_return_value:
+            scopes.append(_FinishScopeReference("Locals", "locals", frame, locs))
+        elif locs:
             scopes.append(_ScopeReference("Locals", "locals", frame, locs))
         scopes.append(_RegisterReference("Registers", frame))
         frame_to_scope[frameId] = scopes
diff --git a/gdb/testsuite/gdb.dap/step-out.c b/gdb/testsuite/gdb.dap/step-out.c
new file mode 100644
index 00000000000..8c7e6942342
--- /dev/null
+++ b/gdb/testsuite/gdb.dap/step-out.c
@@ -0,0 +1,36 @@
+/* Copyright 2024 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+struct result
+{
+  int x;
+};
+
+struct result
+function_breakpoint_here (int q)
+{
+  struct result val;
+  val.x = q;
+  return val;
+}
+
+int
+main ()
+{
+  int q = 23;
+  return function_breakpoint_here (q).x - q;
+}
diff --git a/gdb/testsuite/gdb.dap/step-out.exp b/gdb/testsuite/gdb.dap/step-out.exp
new file mode 100644
index 00000000000..757f4ebdaca
--- /dev/null
+++ b/gdb/testsuite/gdb.dap/step-out.exp
@@ -0,0 +1,82 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that stepOut puts the return value in scope.
+
+require allow_dap_tests
+
+load_lib dap-support.exp
+
+standard_testfile
+
+if {[build_executable ${testfile}.exp $testfile] == -1} {
+    return
+}
+
+if {[dap_initialize] == ""} {
+    return
+}
+
+set obj [dap_check_request_and_response "set breakpoint on function" \
+	     setFunctionBreakpoints \
+	     {o breakpoints [a [o name [s function_breakpoint_here]]]}]
+set fn_bpno [dap_get_breakpoint_number $obj]
+
+dap_check_request_and_response "configurationDone" configurationDone
+
+if {[dap_launch $testfile] == ""} {
+    return
+}
+dap_wait_for_event_and_check "inferior started" thread "body reason" started
+
+dap_wait_for_event_and_check "stopped at function breakpoint" stopped \
+    "body reason" breakpoint \
+    "body hitBreakpointIds" $fn_bpno
+
+dap_check_request_and_response "return from function" stepOut \
+    {o threadId [i 1]}
+dap_wait_for_event_and_check "stopped after return" stopped \
+    "body reason" step
+
+set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \
+		    {o threadId [i 1]}] \
+	    0]
+set frame_id [dict get [lindex [dict get $bt body stackFrames] 0] id]
+
+set scopes [dap_check_request_and_response "get scopes" scopes \
+		[format {o frameId [i %d]} $frame_id]]
+set scopes [dict get [lindex $scopes 0] body scopes]
+
+gdb_assert {[llength $scopes] == 2} "two scopes"
+
+lassign $scopes scope reg_scope
+gdb_assert {[dict get $scope name] == "Locals"} "scope is locals"
+gdb_assert {[dict get $scope presentationHint] == "locals"} \
+    "locals presentation hint"
+gdb_assert {[dict get $scope namedVariables] == 2} "two vars in scope"
+
+set num [dict get $scope variablesReference]
+set refs [lindex [dap_check_request_and_response "fetch arguments" \
+		      "variables" \
+		      [format {o variablesReference [i %d]} $num]] \
+	      0]
+set varlist [lindex [dict get $refs body variables] 0]
+
+gdb_assert {[dict get $varlist variablesReference] > 0} \
+    "variable has children"
+gdb_assert {[dict get $varlist name] == "(return)"} \
+    "variable is return value"
+
+dap_shutdown

-- 
2.43.0


^ permalink raw reply	[relevance 2%]

* [PATCH] [gdb/testsuite] Fix another fail and tcl error in gdb.dap/sources.exp
@ 2024-02-13 16:18  5% Tom de Vries
  0 siblings, 0 replies; 200+ results
From: Tom de Vries @ 2024-02-13 16:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

With gdb.dap/sources.exp on aarch64-linux, I'm running into:
...
{"request_seq": 3, "type": "response", "command": "loadedSources", \
  "success": false, "message": "notStopped", "seq": 7}Content-Length: 92^M
^M
{"type": "event", "event": "thread", \
  "body": {"reason": "started", "threadId": 1}, \
  "seq": 8}FAIL: gdb.dap/sources.exp: loadedSources success
ERROR: tcl error sourcing gdb.dap/sources.exp.
ERROR: tcl error code TCL LOOKUP DICT body
ERROR: key "body" not known in dictionary
    while executing
"dict get [lindex $obj 0] body sources"
...

These are the same type of tcl error and FAIL I just fixed for a later
request in the same test-case.

Fix this by:
- moving the wait-for-stop to before the loadedSources request to fix the
  FAIL, and
- checking for $obj == "" to fix the tcl error.

Also make the code a bit less indented and more readable by wrapping the tests
in a proc, allowing the use of return to bail out, while still running
dap_shutdown afterwards.

Tested on aarch64-linux.
---
 gdb/testsuite/gdb.dap/sources.exp | 41 ++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/gdb/testsuite/gdb.dap/sources.exp b/gdb/testsuite/gdb.dap/sources.exp
index 9b56337e5a8..ee853cc68aa 100644
--- a/gdb/testsuite/gdb.dap/sources.exp
+++ b/gdb/testsuite/gdb.dap/sources.exp
@@ -33,30 +33,37 @@ if {[dap_launch $testfile stop_at_main 1] == ""} {
     return
 }
 
-set obj [dap_check_request_and_response loadedSources loadedSources]
-set path ""
-foreach src [dict get [lindex $obj 0] body sources] {
-    if {[file tail [dict get $src name]] == "sources.c"} {
-	set path [dict get $src path]
-    }	
-}
-
-if {$path == ""} {
-    fail "sources.c in loadedSources"
-} else {
-    pass "sources.c in loadedSources"
-
+proc do_tests {} {
     dap_wait_for_event_and_check "stopped at function breakpoint" stopped \
 	"body reason" breakpoint
 
+    set obj [dap_check_request_and_response loadedSources loadedSources]
+    if { $obj == "" } {
+	return
+    }
+
+    set path ""
+    foreach src [dict get [lindex $obj 0] body sources] {
+	if {[file tail [dict get $src name]] == "sources.c"} {
+	    set path [dict get $src path]
+	}
+    }
+    gdb_assert {$path != "" } "sources.c in loadedSources"
+    if {$path == ""} {
+	return
+    }
+
     set obj [dap_check_request_and_response "get source" source \
 		 [format {o source [o path [s %s]] \
-			    sourceReference [i 0]} $path]]
-    if { $obj != "" } {
-	set text [dict get [lindex $obj 0] body content]
-	gdb_assert {[string first "Distinguishing comment" $text] != -1}
+			      sourceReference [i 0]} $path]]
+    if { $obj == "" } {
+	return
     }
+
+    set text [dict get [lindex $obj 0] body content]
+    gdb_assert {[string first "Distinguishing comment" $text] != -1}
 }
 
+do_tests
 
 dap_shutdown

base-commit: a16034bf6417dc2259fef43fd5bcc2dd1dac562f
-- 
2.35.3


^ permalink raw reply	[relevance 5%]

Results 1-200 of ~20000   | reverse | sort options + mbox downloads above
-- links below jump to the message on this page --
2022-04-08 20:05     [PATCH] gdb: reject inserting breakpoints between functions Simon Marchi
     [not found]     ` <6630b03f.050a0220.6a68d.6289SMTPIN_ADDED_BROKEN@mx.google.com>
2024-05-01  9:47  9%   ` Andrew Burgess
2022-06-27 21:10     [PATCH] gdb+gdbserver/Linux: Remove USE_SIGTRAP_SIGINFO fallback Pedro Alves
2024-04-17 16:40  0% ` Pedro Alves
2023-10-16  9:28     [PATCH] gdb : Signal to pstack/gdb kills the attached process Partha Satapathy
2023-10-25 15:54     ` Guinevere Larsen
2023-11-02 18:24       ` [External] : " Partha Satapathy
2023-11-02 18:27         ` [External] : Re: [PATCH v2] " Partha Satapathy
2023-11-06 13:38           ` Guinevere Larsen
2023-11-17 14:48             ` [External] : Re: [PATCH v3] " Partha Satapathy
2023-12-05 13:13               ` Guinevere Larsen
2024-01-10 15:59                 ` Partha Satapathy
2024-01-24 15:19                   ` Partha Satapathy
2024-02-19  5:10                     ` Partha Satapathy
2024-03-05  8:47                       ` Guinevere Larsen
2024-03-07  8:41  0%                     ` Partha Satapathy
2023-12-25  5:42     [RFC][PATCH?] fixed some segfaults and bugs in mdebug support Zeck S
2024-02-16  2:45     ` Zeck S
2024-03-13  2:09 15%   ` Zeck S
2024-01-02 15:57     [PATCHv10 0/5] Infcalls from B/P conditions in multi-threaded inferiors Andrew Burgess
2024-03-05 15:40     ` [PATCHv11 " Andrew Burgess
2024-03-05 15:40  6%   ` [PATCHv11 5/5] gdb: rename unwindonsignal to unwind-on-signal Andrew Burgess
2024-01-18 15:34     [PATCH 3/4 v5] gdb/debuginfod: Support on-demand debuginfo downloading Andrew Burgess
2024-01-19  5:12     ` Aaron Merey
2024-03-27 10:58       ` Andrew Burgess
2024-03-27 23:56  0%     ` Aaron Merey
2024-01-19 11:56     [PATCH v2 0/6] Add vDefaultInferiorFd feature Alexandra Hájková
2024-02-22 14:38  0% ` Alexandra Petlanova Hajkova
2024-02-03  2:15     [PATCH v4] gdb/debuginfod: Ctrl-C asks to cancel further downloads Aaron Merey
2024-02-22 22:26     ` [PING][PATCH " Aaron Merey
2024-05-17 14:11  0%   ` [PING*2][PATCH " Aaron Merey
2024-02-08 16:19     [PATCH] gdbserver: Fix overflow detection in gdbserver Tom Tromey
2024-02-19 14:19 16% ` [PATCH v2] " Kirill Radkin
2024-02-12 14:40     [PATCH 1/2] remote.c: Use packet_check_result Alexandra Hájková
2024-02-12 14:40     ` [PATCH 2/2] remote.c: Make packet_ok return struct packet_result Alexandra Hájková
2024-03-06 16:13  5%   ` Andrew Burgess
2024-02-12 16:26     [PATCH 0/1] update btrace tests to test all recording methods Abdul Basit Ijaz
2024-02-12 16:26     ` [PATCH 1/1] testsuite, btrace: update btrace testsuite to test all btrace " Abdul Basit Ijaz
2024-02-13 10:16       ` Guinevere Larsen
2024-02-15 10:19  0%     ` Ijaz, Abdul B
2024-02-12 20:01     [PATCH 0/3] "run" and "attach" failure handling problems Pedro Alves
2024-02-12 20:01     ` [PATCH 1/3] Fix "run" failure with GDBserver Pedro Alves
2024-02-13 15:19       ` Lancelot SIX
2024-02-13 21:11  3%     ` Pedro Alves
2024-02-13 14:36     [PATCH] gdb: Change "list ." command's error when no debuginfo is available Guinevere Larsen
2024-03-06 13:18     ` Andrew Burgess
2024-03-06 13:38       ` Guinevere Larsen
2024-03-11 10:55  0%     ` Andrew Burgess
2024-02-13 15:01     [PATCH] [gdb/dap] Fix exit race Tom de Vries
2024-02-23 17:01  4% ` Tom Tromey
2024-02-13 16:18  5% [PATCH] [gdb/testsuite] Fix another fail and tcl error in gdb.dap/sources.exp Tom de Vries
2024-02-13 16:58     [PATCH v2 0/2] Add "finish" return value to DAP Tom Tromey
2024-02-13 16:58  2% ` [PATCH v2 2/2] Add return value to DAP scope Tom Tromey
2024-02-14 13:00     [PATCH^4] gdb: mips: Add MIPSR6 support Milos Kalicanin
2024-04-05 15:12  0% ` Andrew Burgess
2024-02-14 18:16     [PATCH] arc: Determine a branch target of DBNZ correctly Yuriy Kolerov
2024-02-21 13:17 14% ` [PUSHED] " Shahab Vahedi
2024-02-14 21:58     [PATCH] gdb/python: Allow SIGTRAMP_FRAME python unwinders to be created Rémi Bernon
2024-03-20 14:13  0% ` Andrew Burgess
     [not found]     <20240214191045.e4ndamwvpzjbkudq@begin>
2024-02-15  6:56  2% ` [PATCH v2] Port GDB to Hurd x86_64 Flavio Cruz
2024-02-16 18:37     [PATCH 0/5] Fix DAP pause bug Tom Tromey
2024-02-16 18:37  5% ` [PATCH 4/5] Rewrite "python" command exception handling Tom Tromey
2024-02-19  7:52     [PATCH v3] gdb: Modify the output of "info breakpoints" and "delete breakpoints" Tiezhu Yang
2024-02-19 19:54  0% ` Kevin Buettner
2024-02-19  8:23     [PATCH 1/8] [gdb/testsuite] Set up dap log file in gdb.dap/type_checker.exp Tom de Vries
2024-02-19  8:23  5% ` [PATCH 2/8] [gdb/dap] Factor out thread_log Tom de Vries
2024-02-19 14:56     [PATCH 1/1] gdb: Document C++17 build requirement Felix Willgerodt
2024-02-19 18:13     ` Lancelot SIX
2024-02-21  8:39  0%   ` Willgerodt, Felix
2024-02-19 18:07     [PATCH] gdb: pass frames as `const frame_info_ptr &` Simon Marchi
2024-02-20 11:24  0% ` Andrew Burgess
2024-02-20 15:21     [PATCH v2 0/5] Fix DAP pause bug Tom Tromey
2024-02-20 15:21  5% ` [PATCH v2 4/5] Rewrite "python" command exception handling Tom Tromey
2024-02-20 16:56     [PATCH 0/2] Rework Cygwin signal handling Pedro Alves
2024-02-20 16:56  3% ` [PATCH 2/2] Drop special way of getting inferior context after a Cygwin signal Pedro Alves
2024-02-20 19:46     [PATCH v3 0/5] Fix DAP pause bug Tom Tromey
2024-02-20 19:46     ` [PATCH v3 5/5] Use the .py file in gdb.dap/pause.exp Tom Tromey
2024-02-27  9:36  0%   ` Tom de Vries
2024-02-20 20:54     [PATCH 1/2] [gdb/tdep] Fix gdb.base/watchpoint-unaligned.exp on aarch64 Tom de Vries
2024-02-20 20:54     ` [PATCH 2/2] [gdb/tdep] Fix gdb.base/watch-bitfields.exp " Tom de Vries
2024-03-07 12:11       ` Luis Machado
2024-03-12 16:01  0%     ` Tom de Vries
2024-02-21  2:19     [PATCH 1/2] gdb: remove some GCC version checks Simon Marchi
2024-02-21  2:19 11% ` [PATCH 2/2] gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable} Simon Marchi
2024-02-21 13:20  5% [PATCH v2 1/3] [gdb/dap] Factor out thread_log Tom de Vries
2024-02-21 15:01     [PATCH v2] Add a test for the gcore script Alexandra Hájková
2024-03-20 13:28  0% ` Andrew Burgess
2024-02-21 16:46     [PATCH v2 1/2] gdb: remove some GCC version checks Simon Marchi
2024-02-21 16:46 11% ` [PATCH v2 2/2] gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable} Simon Marchi
2024-02-22  3:36  6% [PATCH v4] gdb: Modify the output of "info breakpoints" and "delete breakpoints" Tiezhu Yang
2024-02-22  7:29  6% [PATCH v5] " Tiezhu Yang
2024-02-22  8:02     [PATCH] arc: Don't build arc-analyze-prologue.S with -g Yuriy Kolerov
2024-02-27 14:12 23% ` [PUSHED] " Shahab Vahedi
2024-02-23  0:25     [PATCH] Port GDB to Hurd x86_64 John Baldwin
2024-02-24  5:28  2% ` [PATCH v2] " Flavio Cruz
2024-02-23 16:55 17% [PATCH] Fix throw_winerror_with_name build error on x86-64 Cygwin Pedro Alves
2024-02-23 21:11     [PATCH 0/5] Restore DAP 'quit' request Tom Tromey
2024-02-23 21:11     ` [PATCH 1/5] Rewrite final cleanups Tom Tromey
2024-02-25 22:30       ` Lancelot SIX
2024-02-26 18:53         ` Tom Tromey
2024-02-27 14:03  0%       ` Lancelot SIX
2024-02-26 11:58     [PATCH v2 1/2] [gdb/dap] Move send_gdb and send_gdb_with_response to server module Tom de Vries
2024-02-26 11:58  4% ` [PATCH v2 2/2] [gdb/dap] Fix stray KeyboardInterrupt after cancel Tom de Vries
2024-02-26 14:22     [PATCH 00/11] sim: riscv: simulation of single and double precision floating point instructions bhushan.attarde
2024-03-06 13:24  0% ` Andrew Burgess
2024-02-26 14:26     [PATCH 04/11] sim: riscv: Add single precision floating-point MAC instructions bhushan.attarde
2024-02-26 14:26 29% ` [PATCH 05/11] sim: riscv: Add single precision floating-point basic arithmetic instructions bhushan.attarde
2024-02-26 14:28     [PATCH 09/11] sim: riscv: Add double precision floating-point MAC instructions bhushan.attarde
2024-02-26 14:28 23% ` [PATCH 10/11] sim: riscv: Add double precision floating-point basic arithmetic instructions bhushan.attarde
2024-02-27 14:45     [PATCH v4 0/4] Fix DAP pause bug Tom Tromey
2024-02-27 14:45  6% ` [PATCH v4 4/4] Use the .py file in gdb.dap/pause.exp Tom Tromey
2024-02-27 17:25  4% [PATCH] Rely on std::uncaught_exceptions Tom Tromey
2024-02-27 22:20     [PATCH] aarch64: Use aarch64_debug_printf in a few more places John Baldwin
2024-02-28  4:38  0% ` Simon Marchi
2024-02-29 13:59     [PATCH v3 1/2] [gdb/dap] Move send_gdb and send_gdb_with_response to server module Tom de Vries
2024-02-29 13:59  4% ` [PATCH v3 2/2] [gdb/dap] Fix stray KeyboardInterrupt after cancel Tom de Vries
2024-03-01 15:52  4% [PATCH] gdb: iterate over targets, not inferiors, to commit resumed Tankut Baris Aktemur
2024-03-02  7:26     [PATCH] [gdb] Further fix "value is not available" with debug frame Tom de Vries
2024-03-19  9:31  0% ` Tom de Vries
2024-03-03  9:43     [PATCH] Support MSYS2 platform Orgad Shaneh
2024-03-03 11:07 10% ` Orgad Shaneh
2024-03-03 16:47 10% [PATCH] gdb/compile: Use std::filesystem::remove_all in cleanup Lancelot SIX
2024-03-03 18:43     [PATCH v2 0/3] Use ui-out tables in a few spots Tom Tromey
2024-03-03 18:43  8% ` [PATCH v2 3/3] Use ui-out tables in linux-tdep.c Tom Tromey
2024-03-04  8:23     [PATCH 0/1] update btrace tests to test all recording methods Abdul Basit Ijaz
2024-03-04  8:23  2% ` [PATCH 1/1] testsuite, btrace: update btrace testsuite to test all btrace " Abdul Basit Ijaz
2024-03-05 11:36     [PATCH v2 0/1] Fix assertion in 'value_primitive_field' Stephan Rohr
2024-03-05 11:36     ` [PATCH v2 1/1] gdb: " Stephan Rohr
2024-03-06 14:48  0%   ` Andrew Burgess
2024-03-05 15:21     [PATCHv9 00/14] thread-specific breakpoints in just some inferiors Andrew Burgess
2024-03-31 10:31     ` [PATCHv10 0/9] " Andrew Burgess
2024-03-31 10:31 11%   ` [PATCHv10 9/9] gdb: only insert thread-specific breakpoints in the relevant inferior Andrew Burgess
2024-03-05 21:38     [PATCH v2] Remove tui-out.[ch] Tom Tromey
2024-03-06 13:42  0% ` Andrew Burgess
2024-03-06 12:51     [PATCH 0/4] Modernize frame unwinders and add disable feature Guinevere Larsen
2024-03-06 12:51     ` [PATCH 3/4] gdb: Migrate frame unwinders to use C++ classes Guinevere Larsen
2024-03-08 17:07       ` Tom Tromey
2024-03-12 16:24  0%     ` Guinevere Larsen
2024-03-07 13:28     [PATCH 0/6] pr gdb/19340 Markus Metzger
2024-03-07 13:28  5% ` [PATCH 4/6] gdb, btrace: set wait status to ignore if nothing is moving Markus Metzger
2024-03-07 15:01     [PATCH] gdb, btrace: fix error diagnostics Markus Metzger
2024-03-08  9:07  0% ` Guinevere Larsen
2024-03-08  9:33     [PATCH v4 0/6] Fixes to gdb.threads/threadcrash.exp Tom de Vries
2024-03-08  9:33     ` [PATCH v4 6/6] gdb/testsuite: Add kfail in gdb.threads/threadcrash.exp on 32-bit arm targets Tom de Vries
2024-03-08 10:24       ` Tom de Vries
2024-03-08 23:57         ` Thiago Jung Bauermann
2024-03-11 10:15           ` Tom de Vries
2024-03-11 18:10  0%         ` Thiago Jung Bauermann
2024-03-11 17:21  2% [PATCH] Sync libbacktrace from gcc [PR31327] Sam James
2024-03-11 20:57     [PATCH 1/2] contrib: sync dg-extract-results.py with GCC Sam James
2024-03-11 20:57  4% ` [PATCH 2/2] contrib: sync dg-extract-results.sh " Sam James
2024-03-13 20:18     [PATCH] gdb/dwarf2: Check for missing abbrev Aaron Merey
2024-03-14  1:39     ` Simon Marchi
2024-03-14 12:31       ` Tom Tromey
2024-03-14 13:56  6%     ` Simon Marchi
2024-03-14 18:49  3% [PATCH] Rewrite gdb_bfd_error_handler Tom Tromey
2024-03-15 18:27     [PATCH] Teach GDB to generate sparse core files (PR corefiles/31494) Pedro Alves
2024-03-18 13:29     ` [PATCH v2] " Pedro Alves
2024-03-18 17:43       ` [PATCH v3] " Pedro Alves
2024-03-21 21:27         ` Lancelot SIX
2024-03-21 23:14  1%       ` [PATCH v4] " Pedro Alves
2024-03-18 16:22     [RFC][PATCH 0/1] Add support for embedded source in GDB Will Hawkins
2024-03-18 16:22     ` [RFC][PATCH 1/1] gdb: Support embedded source in DWARF Will Hawkins
2024-03-18 17:24       ` Tom Tromey
2024-03-18 21:18  0%     ` Will Hawkins
2024-03-19 13:58     [PATCH v2 1/2] remote.c: Use packet_check_result Alexandra Hájková
2024-03-19 13:58     ` [PATCH v2 2/2] remote.c: Make packet_ok return struct packet_result Alexandra Hájková
2024-03-26  9:48  0%   ` Andrew Burgess
2024-03-19 17:33     [PATCH 0/9] Make gdb/python flake-clean Tom Tromey
2024-03-19 17:33     ` [PATCH 8/9] Suppress some "undefined" warnings from flake8 Tom Tromey
2024-03-20 18:58       ` Simon Marchi
2024-03-20 20:30         ` Tom Tromey
2024-03-20 20:32 13%       ` Tom Tromey
2024-03-20 16:38     [PATCH 0/2] Use isort in gdb Tom Tromey
2024-03-20 16:38  1% ` [PATCH 2/2] Run isort Tom Tromey
2024-03-20 20:23     [PATCH 0/3] Better type safety for bcache Tom Tromey
2024-03-20 20:23 13% ` [PATCH 2/3] Make bcache more type-safe Tom Tromey
2024-03-21  6:53     [PATCH] Better handling for realpath() failures in windows_make_so() on Cygwin Orgad Shaneh
2024-03-21  7:22  4% ` Orgad Shaneh
2024-03-21 19:03     [PATCH 00/12] Ada iterated assignment, plus parser cleanups Tom Tromey
2024-03-21 19:03  4% ` [PATCH 07/12] Move "iterated_associations" into ada_parse_state Tom Tromey
2024-03-21 23:11     [RFC PATCH 0/3] Fix attaching to process when it has zombie threads Thiago Jung Bauermann
2024-03-21 23:11     ` [RFC PATCH 3/3] gdb/nat/linux: " Thiago Jung Bauermann
2024-03-22 16:52       ` Pedro Alves
2024-04-16  4:48         ` Thiago Jung Bauermann
2024-04-17 15:32  0%       ` Pedro Alves
2024-03-22 13:55     [PATCH 1/1] gdb, testsuite: Handle unused compiler option fdiagnostics-color=never Abdul Basit Ijaz
2024-03-29 19:50     ` Keith Seitz
2024-05-14 11:22  7%   ` Ijaz, Abdul B
2024-03-22 19:04     [PATCH 0/4] Down with SO_NAME_MAX_PATH_SIZE and windows_make_so spring cleaning Pedro Alves
2024-03-22 19:04  4% ` [PATCH 4/4] windows-nat: Use gdb_realpath Pedro Alves
2024-03-23  2:14     [PATCH v2 0/4] Include early include files with `-include` Simon Marchi
2024-03-23  2:14  1% ` [PATCH v2 4/4] gdb, gdbserver, gdbsupport: remove includes of early headers Simon Marchi
2024-03-23 20:27     [PATCH 0/2] Make linux checkpoints work with multiple inferiors Kevin Buettner
2024-03-23 20:27 10% ` [PATCH 1/2] " Kevin Buettner
2024-03-24  1:18  3% [PATCH] Make source.c:search_command_helper use source cache Will Hawkins
2024-03-25 14:05  5% [PATCH] [gdb/testsuite] Fix gdb.ada/tagged-lookup.exp with gcc <= 12 Tom de Vries
2024-03-26 19:06     [PATCH v3 0/4] Include early include files with `-include` Simon Marchi
2024-03-26 19:06  1% ` [PATCH v3 4/4] gdb, gdbserver, gdbsupport: remove includes of early headers Simon Marchi
2024-03-27  7:47     [PATCH 0/3] Add amd64 LAM watchpoint support Schimpe, Christina
2024-03-27  7:47     ` [PATCH 1/3] gdb: Make tagged pointer support configurable Schimpe, Christina
2024-03-28 11:58  0%   ` Luis Machado
2024-03-27 15:22     [PATCH v3 0/1] gdb: Fix assertion in 'value_primitive_field' Stephan Rohr
2024-03-27 15:22     ` [PATCH v3 1/1] " Stephan Rohr
2024-04-16 17:52  0%   ` Tom Tromey
2024-03-28  7:00     [PATCH 0/4] Add another way to check for MTE-tagged addresses on remote targets Gustavo Romero
2024-03-28  7:00  3% ` [PATCH 4/4] gdb: Add new remote packet to check if address is tagged Gustavo Romero
2024-03-28 12:05     [PATCH v6 00/10] GDB support for DW_AT_trampoline Abdul Basit Ijaz
2024-03-28 12:05  2% ` [PATCH v6 04/10] gdb: Skip trampoline frames for the backtrace command Abdul Basit Ijaz
2024-03-28 14:33  4% [PATCH] [gdb/tui] Fix centering and highlighting of current line Tom de Vries
2024-03-28 17:35     [PATCH 1/3] gdb: print 'stop_requested' in infrun_debug_show_threads Tankut Baris Aktemur
2024-03-28 17:35  4% ` [PATCH 2/3] gdb: boolify thread_info's 'stop_requested' field Tankut Baris Aktemur
2024-03-28 22:48     [PATCH v2 0/4] Add another way to check for MTE-tagged addresses on remote targets Gustavo Romero
2024-03-28 22:48     ` [PATCH v2 4/4] gdb: Add new remote packet to check if address is tagged Gustavo Romero
2024-03-29 23:35       ` Thiago Jung Bauermann
2024-04-04  5:32  0%     ` Gustavo Romero
2024-03-29 11:42     [PATCH 0/6] Further filename completion improvements Andrew Burgess
2024-04-20  9:10     ` [PATCHv2 0/8] " Andrew Burgess
2024-04-20  9:10  2%   ` [PATCHv2 7/8] gdb: apply escaping to filenames in 'complete' results Andrew Burgess
2024-03-29 13:00     [PATCH v3 1/2] remote.c: Use packet_check_result Alexandra Hájková
2024-04-04  8:52  0% ` Andrew Burgess
2024-03-30 11:01 11% [PATCH] gdb: ensure has dwarf info before reading DWZ file Lancelot SIX
2024-03-30 18:54  4% [PATCH] Normalize "on|off" text in manual Tom Tromey
2024-03-31 10:45     [PATCH] Fix an out of bounds array access in, find_epilogue_using_linetable Bernd Edlinger
2024-04-01  9:07     ` Tom de Vries
2024-04-01 16:41       ` Bernd Edlinger
2024-04-05 15:11         ` Tom de Vries
2024-04-05 18:13  5%       ` Bernd Edlinger
2024-04-01 21:26  3% [PATCH] Add wildcard matching to substitute-path rules Max Yvon Zimmermann
2024-04-02 10:20     [PATCH 2/2] gdbserver, remote: introduce "id_str" in the "qXfer:threads:read" XML Tankut Baris Aktemur
2024-04-03 14:57  5% ` [PATCH v2] " Tankut Baris Aktemur
2024-04-03  9:00     Fix max-depth test case for AIX Aditya Kamath1
2024-04-03 14:13     ` Andrew Burgess
2024-04-03 14:58       ` Tom Tromey
2024-04-10  6:01  5%     ` Aditya Kamath1
2024-04-03 14:44 10% [PATCH] Revert "gdb/compile: Use std::filesystem::remove_all in cleanup" Lancelot SIX
2024-04-03 16:57     [PATCH v2] gdb: Support embedded source in DWARF Will Hawkins
2024-04-03 20:34     ` Tom Tromey
2024-04-03 21:20  0%   ` Will Hawkins
2024-04-04  0:17  3% [PATCH v2] Add wildcard matching to substitute-path rules Max Yvon Zimmermann
2024-04-04  6:48     [PATCH v3 0/7] Add another way to check tagged addresses on remote targets Gustavo Romero
2024-04-04  6:48     ` [PATCH v3 5/7] gdb: Introduce is_address_tagged target hook Gustavo Romero
2024-04-04 15:45       ` Luis Machado
2024-04-08 20:47  4%     ` Gustavo Romero
2024-04-05  7:51  5% [PATCH] sim: riscv: Fix some compatiblity issues with gcc Bernd Edlinger
2024-04-05 12:21     [PATCH 0/4] gcore and config.status related Makefile changes Andrew Burgess
2024-04-06 17:03     ` [PATCHv2 0/6] " Andrew Burgess
2024-04-06 17:03  5%   ` [PATCHv2 6/6] gdb/build: apply silent-rules.mk to the data-directory Makefile.in Andrew Burgess
2024-04-05 15:10     [PATCH v3 1/2] [gdb/symtab] Fix an out of bounds array access in find_epilogue_using_linetable Tom de Vries
2024-04-05 15:10  4% ` [PATCH v3 2/2] [gdb/testsuite] Add gdb.dwarf2/dw2-epilogue-begin-2.exp Tom de Vries
2024-04-05 16:13     [PATCH v3] gdb: Support embedded source in DWARF Will Hawkins
2024-04-05 16:18  0% ` Will Hawkins
2024-04-07 19:08     [PATCH] gdb: Add missing install-dvi Makefile target Christophe Lyon
2024-04-07 19:10     ` [PATCH v2] gdb, gdbserver: " Christophe Lyon
2024-04-09 23:00       ` Luis Machado
2024-04-10  8:10         ` Christophe Lyon
2024-04-10 10:02           ` Christophe Lyon
2024-04-10 13:00  0%         ` Luis Machado
2024-04-08 20:19     [PATCH v2 0/5] Modernize frame unwinders and add disable feature Guinevere Larsen
2024-04-08 20:19     ` [PATCH v2 4/5] gdb: introduce ability to disable frame unwinders Guinevere Larsen
2024-04-09  2:47  0%   ` Eli Zaretskii
2024-04-08 21:11     [PATCH gdb/symtab v2 0/7] Compute DWARF entry parents across CUs Tom Tromey
2024-04-08 21:11  3% ` [PATCH gdb/testsuite v2 7/7] Add gdb.dwarf2/backward-spec-inter-cu.exp Tom Tromey
2024-04-09  4:57 27% [PATCH v4] gdb: Support embedded source in DWARF Will Hawkins
2024-04-09  7:48     [PATCH v3 0/3] Introduce the 'x' RSP packet Tankut Baris Aktemur
2024-04-09  7:48 11% ` [PATCH v3 2/3] gdbserver: allow suppressing the next putpkt remote-debug log Tankut Baris Aktemur
2024-04-09  9:27     [PATCH v5 1/2] [gdb/symtab] Fix an out of bounds array access in find_epilogue_using_linetable Tom de Vries
2024-04-09  9:27     ` [PATCH v5 2/2] [gdb/symtab] Handle two-linetable function " Tom de Vries
2024-04-22 13:39  0%   ` Andrew Burgess
2024-04-09 15:46  7% [PATCH] Avoid complaint warning on mingw Tom Tromey
2024-04-10 13:43     [PATCH v2] sim: riscv: Fix some compatibility issues with gcc Bernd Edlinger
2024-04-12 14:48     ` Andrew Burgess
2024-04-12 17:18  0%   ` Bernd Edlinger
2024-04-11  5:25     [PATCH v2 0/6] fix PR gdb/19340 Markus Metzger
2024-04-11  5:26  5% ` [PATCH v2 4/6] gdb, btrace: set wait status to ignore if nothing is moving Markus Metzger
2024-04-11 10:52     [PATCH] [gdb/python] Throw MemoryError in inferior.read_memory if malloc fails Tom de Vries
2024-04-11 16:07     ` Tom Tromey
2024-04-12  7:09  9%   ` Tom de Vries
2024-04-11 11:05  8% [PUSHED] gdb: fix format in remote.c Tankut Baris Aktemur
2024-04-11 11:39     [PATCH] gdb/linux-nat: Fix mem access ptrace fallback (PR threads/31579) Pedro Alves
2024-04-12 16:05     ` Andrew Burgess
2024-04-12 17:02       ` Pedro Alves
2024-04-15 16:05  0%     ` Tom Tromey
2024-04-12 17:00     [PATCH] gdb/doc: use silent-rules.mk in the Makefile Andrew Burgess
2024-04-12 18:31     ` Eli Zaretskii
2024-04-12 22:32       ` Andrew Burgess
2024-04-13  7:02         ` Eli Zaretskii
2024-04-15 13:55           ` Andrew Burgess
2024-04-15 14:18             ` Simon Marchi
2024-04-16  7:48               ` Andrew Burgess
2024-04-16  8:47                 ` Andrew Burgess
2024-04-16 15:01                   ` Simon Marchi
2024-04-17 21:00 12%                 ` Andrew Burgess
2024-04-12 18:55     [PATCH v5] gdb: Support embedded source in DWARF Will Hawkins
2024-04-12 20:12     ` Tom de Vries
2024-04-14  2:50       ` Will Hawkins
2024-04-14  7:01         ` Tom de Vries
2024-04-14  7:15           ` Will Hawkins
2024-04-15 16:13  0%         ` Will Hawkins
2024-04-14  3:24     [PATCH v2 0/2] Make linux checkpoints work with multiple inferiors Kevin Buettner
2024-04-14  3:24 10% ` [PATCH v2 1/2] " Kevin Buettner
2024-04-14 19:44     [PATCH v3 0/3] " Kevin Buettner
2024-04-14 19:44     ` [PATCH v3 3/3] Make thread_db_target::pid_to_str checkpoint-aware Kevin Buettner
2024-05-03 15:55  8%   ` Pedro Alves
2024-04-15  8:36     [PATCH] sim: riscv: Fix confusion with c.jal vs. c.addiw Bernd Edlinger
2024-04-15  8:56     ` Andrew Burgess
2024-04-15  9:05  0%   ` Bernd Edlinger
2024-04-15 14:19     [PATCH 0/3] Small cleanups in gdb/record*.c code Andrew Burgess
2024-04-15 14:19     ` [PATCH 3/3] gdb/record: minor clean, remove some unneeded arguments Andrew Burgess
2024-04-16 14:12  7%   ` Keith Seitz
2024-04-15 14:46  4% [PATCH 1/2] sim: riscv: fix a divw division by -1 bug Bernd Edlinger
2024-04-15 14:46  7% [PATCH 2/2] sim: riscv: Simplify the signed div by -1 code Bernd Edlinger
2024-04-16 14:07     [PATCH v4 0/8] Add another way to check tagged addresses on remote targets Gustavo Romero
2024-04-16 14:07     ` [PATCH v4 6/8] gdb: Add qIsAddressTagged packet Gustavo Romero
2024-04-16 18:04       ` Luis Machado
2024-04-17 20:57  0%     ` Gustavo Romero
2024-04-16 15:52     [PATCH] gdb/make-target-delegates.py: don't handle "void" in parse_argtypes Simon Marchi
2024-04-16 16:06     ` John Baldwin
2024-04-16 16:14  0%   ` Simon Marchi
2024-04-16 17:05     [PATCH 0/5] Fix race in DWARF reader, 2nd approach Tom Tromey
2024-04-16 17:05  5% ` [PATCH 3/5] Remove call to dwarf2_per_objfile::adjust from read_call_site_scope Tom Tromey
2024-04-16 20:00  5% [PATCH v2] gdb: Change "list ." command's error when no debuginfo is available Guinevere Larsen
2024-04-17 13:44     [PATCH] Use section name in DWARF error message Tom Tromey
2024-04-17 14:48  0% ` Simon Marchi
2024-04-17 14:06     [PATCH] Disallow trailing whitespace in docstrings Tom Tromey
2024-04-17 19:02  0% ` Philippe Waroquiers
2024-04-17 20:54     [PATCH 1/6] gdb: add includes in target-debug.h Simon Marchi
2024-04-17 20:54     ` [PATCH 3/6] gdb: make target debug functions return std::string Simon Marchi
2024-04-19 19:20       ` Tom Tromey
2024-04-19 19:41  0%     ` Simon Marchi
2024-04-17 21:04     [PATCH v5 0/8] Add another way to check tagged addresses on remote targets Gustavo Romero
2024-04-17 21:04     ` [PATCH v5 6/8] gdb: Add qIsAddressTagged packet Gustavo Romero
2024-04-18 10:37  0%   ` Luis Machado
2024-04-17 22:05     [PATCH 0/4] Add include guard checker and reformatter Tom Tromey
2024-04-17 22:05  1% ` [PATCH 4/4] Run check-include-guards.py Tom Tromey
2024-04-17 22:52     [PATCH] Remove some alloca uses Tom Tromey
2024-04-22  9:41  4% ` [PUSHED] gdb: fix unknown variable typo in c-exp.y Andrew Burgess
2024-04-18  3:27     Deprecation/removal of nios2 target support Sandra Loosemore
2024-04-18 15:44     ` Joseph Myers
2024-04-18 15:57  0%   ` Joel Sherrill
2024-04-18  6:32     [PATCH v2] [gdb/testsuite] Handle ptrace operation not permitted in can_spawn_for_attach Tom de Vries
2024-04-24 19:40     ` Pedro Alves
2024-04-24 21:35       ` Tom de Vries
2024-04-26 18:50         ` Pedro Alves
2024-05-01  8:42  0%       ` Tom de Vries
2024-04-18  7:36     [RFC 0/3] Wait for inferior after attaching Tankut Baris Aktemur
2024-04-18  7:36  9% ` [PATCH 1/3] gdb: print target in print_target_wait_results Tankut Baris Aktemur
2024-04-18 13:26  8% [PATCH] Fix AIX thread exit events not being reported and UI to show kernel thread ID Aditya Kamath1
2024-04-18 15:41     [PATCH v2 0/4] Add include guard checker and reformatter Tom Tromey
2024-04-18 15:41  1% ` [PATCH v2 4/4] Run check-include-guards.py Tom Tromey
2024-04-18 20:10     [PATCH v6 0/8] Add another way to check tagged addresses on remote targets Gustavo Romero
2024-04-18 20:10     ` [PATCH v6 6/8] gdb: Add qIsAddressTagged packet Gustavo Romero
2024-04-19  7:52  0%   ` Luis Machado
2024-04-19 14:55     [PATCH v3 0/4] Add include guard checker and reformatter Tom Tromey
2024-04-19 14:55  1% ` [PATCH v3 4/4] Run check-include-guards.py Tom Tromey
2024-04-19 15:03     [PATCH v4 0/4] Add include guard checker and reformatter Tom Tromey
2024-04-19 15:03  1% ` [PATCH v4 4/4] Run check-include-guards.py Tom Tromey
2024-04-19 15:13     [PATCH 00/12] Fix attach/run failure handling - gdbserver & Windows, document "E.MESSAGE" RSP errors, more Pedro Alves
2024-04-19 15:13     ` [PATCH 09/12] gdb_target_is_native -> gdb_protocol_is_native Pedro Alves
2024-04-19 18:50       ` Tom Tromey
2024-05-09  8:47         ` Bernd Edlinger
2024-05-09  9:47           ` Pedro Alves
2024-05-09 11:54             ` Bernd Edlinger
2024-05-09 12:05               ` Pedro Alves
2024-05-09 13:19                 ` Bernd Edlinger
2024-05-09 13:31                   ` Pedro Alves
2024-05-09 15:01                     ` Bernd Edlinger
2024-05-09 15:49                       ` Pedro Alves
2024-05-09 18:44  0%                     ` Bernd Edlinger
2024-04-19 19:46     [PATCH v2 1/4] gdb: make target debug functions return std::string Simon Marchi
2024-04-19 19:46 15% ` [PATCH v2 4/4] gdb: add target_debug_printf and target_debug_printf_nofunc Simon Marchi
2024-04-20 21:33     [PATCH 0/2] Add testcase for libc memory operations Thiago Jung Bauermann
2024-04-20 21:33     ` [PATCH 2/2] gdb/testsuite: Add gdb.base/memops-watchpoint.exp Thiago Jung Bauermann
2024-04-21 21:20       ` Kevin Buettner
2024-04-22  0:24         ` Thiago Jung Bauermann
2024-04-22 23:04  0%       ` Thiago Jung Bauermann
2024-04-21 17:00     [PATCH 00/10] Fix some C++ name canonicalizer problems Tom Tromey
2024-04-21 17:00  6% ` [PATCH 01/10] Remove test code from cp-name-parser.y Tom Tromey
2024-04-21 22:26     [PATCH v2 0/2] Add testcase for libc memory operations Thiago Jung Bauermann
2024-04-21 22:26     ` [PATCH v2 2/2] gdb/testsuite: Add gdb.base/memops-watchpoint.exp Thiago Jung Bauermann
2024-04-22 14:39  0%   ` Luis Machado
2024-04-22  8:45  8% [PATCH] gdb/remote: fix qRcmd error handling Andrew Burgess
2024-04-22  9:45     [PATCH] sim: riscv: Fix some issues with class-a instructions Bernd Edlinger
2024-04-22 15:01     ` Andrew Burgess
2024-04-23 13:56  0%   ` Bernd Edlinger
2024-04-22 12:12  4% [PATCH v2] Add a test for the gcore script Alexandra Hájková
2024-04-22 14:33  5% [Patch v2] Fix AIX thread exit events not being reported and UI to show kernel thread ID Aditya Kamath1
2024-04-22 23:06     [PATCH v3 0/2] Add testcase for libc memory operations Thiago Jung Bauermann
2024-04-22 23:07     ` [PATCH v3 2/2] gdb/testsuite: Add gdb.base/memops-watchpoint.exp Thiago Jung Bauermann
2024-04-23 17:52       ` Kevin Buettner
2024-04-24 17:05         ` Thiago Jung Bauermann
2024-04-24 23:22           ` Kevin Buettner
2024-04-26  1:42  0%         ` Thiago Jung Bauermann
2024-04-23 10:45     [PATCH v3] Add a test for the gcore script Alexandra Hájková
2024-04-29 12:09  0% ` Andrew Burgess
2024-04-23 13:22     [PATCH 0/7] More cleanup of defs.h Simon Marchi
2024-04-23 13:22  7% ` [PATCH 1/7] gdb: move declarations of check_quit_flag and set_quit_flag to extension.h Simon Marchi
2024-04-23 14:30     [PATCH v2] sim: riscv: Fix some issues with class-a instructions Bernd Edlinger
2024-04-25 13:15  0% ` Bernd Edlinger
2024-04-24 23:15     [PATCH v3 0/3] Fix attaching to process when it has zombie threads Thiago Jung Bauermann
2024-04-24 23:15     ` [PATCH v3 2/3] gdb/nat: Factor linux_proc_get_stat_field out of linux_common_core_of_thread Thiago Jung Bauermann
2024-04-25  8:59       ` Luis Machado
2024-04-25  9:04         ` Luis Machado
2024-04-25 12:48  0%       ` Thiago Jung Bauermann
2024-04-25 18:09     [PATCH 0/3] Add more info to DAP disassemble response Tom Tromey
2024-04-25 18:09  5% ` [PATCH 3/3] Add symbol, line, and location to DAP disassemble result Tom Tromey
2024-04-26  1:46  5% [PATCH v4] gdb/testsuite: Add gdb.base/memops-watchpoint.exp Thiago Jung Bauermann
2024-04-26  7:49  6% [PATCH v3] sim: riscv: Fix some issues with class-a instructions Bernd Edlinger
2024-04-26  7:50  7% [PATCH] sim: riscv: Fix undefined behaviour in mulh and similar Bernd Edlinger
     [not found]     <20240421124954.3285-1-ssbssa.ref@yahoo.de>
2024-04-21 12:49     ` [PATCH] Allow calling of user-defined function call operators Hannes Domani
2024-04-25 18:34       ` Guinevere Larsen
2024-04-27 16:43  0%     ` Hannes Domani
2024-04-29  4:38     [PATCH] sim: riscv: Fix Zicsr and fence instructions Bernd Edlinger
2024-04-29 10:01     ` Andrew Burgess
2024-04-29 13:30  0%   ` Bernd Edlinger
2024-04-29 11:40     [PATCH] Fix AIX thread exit events not being reported and UI to show kernel thread ID Aditya Vidyadhar Kamath
2024-04-29 11:48     ` Aditya Kamath1
2024-04-30 16:41  0%   ` John Baldwin
2024-04-29 11:46  9% Aditya Vidyadhar Kamath
2024-04-29 13:57     [PATCH v2] sim: riscv: Fix Zicsr and fence instructions Bernd Edlinger
2024-05-01 15:39     ` Andrew Burgess
2024-05-03 11:51  0%   ` Bernd Edlinger
2024-04-30 13:15     [PATCH v2 0/3] Add more info to DAP disassemble response Tom Tromey
2024-04-30 13:15  5% ` [PATCH v2 3/3] Add symbol, line, and location to DAP disassemble result Tom Tromey
2024-04-30 18:35     [PATCH v3] gdb: Change "list ." command's error when no debuginfo is available Guinevere Larsen
2024-05-08 14:25     ` Andrew Burgess
2024-05-08 17:13       ` Guinevere Larsen
2024-05-10  6:26  0%     ` Tom de Vries
2024-05-02 13:23     [PATCH] sim: fix a warning in dv-sockser.c at connected_p() Bernd Edlinger
2024-05-02 16:15     ` Tom Tromey
2024-05-03  9:00  0%   ` Bernd Edlinger
2024-05-02 14:29     [PATCH v3] [RFC] Fix AIX thread exit events not being reported and UI to show kernel thread ID Aditya Vidyadhar Kamath
2024-05-02 14:41  5% ` Aditya Kamath1
2024-05-03 14:26     [PATCH v4] " Aditya Vidyadhar Kamath
2024-05-03 14:34  5% ` Aditya Kamath1
2024-05-03 15:09     [PATCH v5] " Aditya Vidyadhar Kamath
2024-05-03 15:14     ` Aditya Kamath1
2024-05-07  9:57  5%   ` Aditya Kamath1
2024-05-03 22:58     [PATCH 0/3] On-demand debuginfo downloading Aaron Merey
2024-05-03 22:59     ` [PATCH 3/3 v6] gdb/debuginfod: Add .debug_line downloading Aaron Merey
2024-05-17 14:10  0%   ` [PING][PATCH " Aaron Merey
2024-05-04  0:05     [PATCH 0/5] Add support for AArch64 MOPS instructions Thiago Jung Bauermann
2024-05-04  0:05  4% ` [PATCH 3/5] gdb/testsuite: Add gdb.arch/aarch64-mops-watchpoint.exp Thiago Jung Bauermann
2024-05-05 20:57     Optionally print source code to gdb console window Robert Rossi
2024-05-06 22:18 10% ` Robert Rossi
     [not found]     <20240427163606.1780-1-ssbssa.ref@yahoo.de>
2024-04-27 16:36     ` [PATCH v2] Allow calling of user-defined function call operators Hannes Domani
2024-05-03 18:29       ` Guinevere Larsen
2024-05-03 18:51         ` Hannes Domani
2024-05-06 12:29  0%       ` Guinevere Larsen
2024-05-06 21:10     [PATCH] Pass stream to remote_console_output Tom Tromey
2024-05-10 11:01  0% ` Andrew Burgess
2024-05-07  2:22     [PATCH v2 0/5] Add support for AArch64 MOPS instructions Thiago Jung Bauermann
2024-05-07  2:22  4% ` [PATCH v2 3/5] gdb/testsuite: Add gdb.arch/aarch64-mops-watchpoint.exp Thiago Jung Bauermann
2024-05-07 23:41     [PATCH 00/34] Windows non-stop mode Pedro Alves
2024-05-07 23:42  2% ` [PATCH 33/34] Windows gdb: Watchpoints while running (internal vs external stops) Pedro Alves
2024-05-08  9:29     [PATCH 0/2] binutils-gdb: Remove Itanium (IA-64) architecture Tiezhu Yang
2024-05-08  9:29  7% ` [PATCH 2/2] gdb: " Tiezhu Yang
2024-05-08 14:54     [PATCH v3 0/5] Modernize frame unwinders and add disable feature Guinevere Larsen
2024-05-08 14:54  5% ` [PATCH v3 4/5] gdb: introduce ability to disable frame unwinders Guinevere Larsen
2024-05-08 15:00  7% [PATCH] gdb: more filename styling Andrew Burgess
2024-05-08 15:27  5% [PATCH] gdb: add a new build_id_equal function Andrew Burgess
2024-05-08 16:46     [PATCHv6 0/9] x86/Linux Target Description Changes Andrew Burgess
2024-05-11 10:08     ` [PATCHv7 " Andrew Burgess
2024-05-11 10:08       ` [PATCHv7 7/9] gdb/gdbserver: share some code relating to target description creation Andrew Burgess
2024-05-17 11:59  4%     ` Willgerodt, Felix
2024-05-09  2:42  1% [PATCH v4] [gdb/testsuite] New test: gdb.base/check-errno.exp Kevin Buettner
2024-05-09 10:53     [PATCH 1/1 V5] gdb : Signal to pstack/gdb kills the attached process Partha Satapathy
2024-05-10 20:19     ` Pedro Alves
2024-05-13 14:49       ` Pedro Alves
2024-05-16  7:15  5%     ` Partha Satapathy
2024-05-09 21:10     [PATCH v5] [gdb/testsuite] New test: gdb.base/check-errno.exp Kevin Buettner
2024-05-10  8:40     ` Tom de Vries
2024-05-11 19:30  0%   ` Kevin Buettner
2024-05-10  5:24     [PATCH v3 0/5] Add support for AArch64 MOPS instructions Thiago Jung Bauermann
2024-05-10  5:24     ` [PATCH v3 4/5] gdb/testsuite: Add gdb.arch/aarch64-mops-single-step.exp Thiago Jung Bauermann
2024-05-10 13:07  4%   ` Luis Machado
2024-05-10 10:52  4% [PATCH v5] Add a test for the gcore script Alexandra Hájková
2024-05-11  9:37     [PATCH 0/4] gdb/doc: build fixes and improvements Andrew Burgess
2024-05-11  9:37  7% ` [PATCH 2/4] gdb/doc: don't try to copy GDBvn.texi from the source tree Andrew Burgess
2024-05-11 21:45  1% [PATCH v6] [gdb/testsuite] New test: gdb.base/errno.exp Kevin Buettner
2024-05-14 13:37     [PATCH] Don't allow new-ui to start the TUI Tom Tromey
2024-05-17 14:11  0% ` Andrew Burgess
2024-05-14 17:16     [PATCH v2 0/1] gdb, testsuite: Handle unused compiler option fdiagnostics-color=never Abdul Basit Ijaz
2024-05-14 17:16     ` [PATCH v2 1/1] " Abdul Basit Ijaz
2024-05-15 16:17       ` Tom Tromey
2024-05-15 19:06  6%     ` Ijaz, Abdul B
2024-05-15 20:19  2% [PATCH^5] gdb: mips: Add MIPSR6 support Milos Kalicanin
2024-05-15 20:30  6% [PATCH v3 0/1] gdb, testsuite: Handle unused compiler option fdiagnostics-color=never Abdul Basit Ijaz
2024-05-15 20:31     [PATCH v3 1/1] " Abdul Basit Ijaz
2024-05-16 16:10  0% ` Tom Tromey
2024-05-17 10:47  6% [PATCH 1/2] [gdb/macro] Ignore in-file macro definition with 0 line complaint for clang Tom de Vries
2024-05-17 14:18     [PATCH 0/4] More build-id checking when opening core files Andrew Burgess
2024-05-20 13:08     ` [PATCHv2 " Andrew Burgess
2024-05-20 13:08  6%   ` [PATCHv2 4/4] gdb: unify build-id to objfile lookup code Andrew Burgess
     [not found]     <20240518134123.1243-1-ssbssa.ref@yahoo.de>
2024-05-18 13:41  6% ` [PATCH v3] Allow calling of user-defined function call operators Hannes Domani
2024-05-21  4:46  4% [PATCH v2] sim: fix a warning in dv-sockser.c at connected_p() Bernd Edlinger
2024-05-21 15:44     [PATCH 01/11] [gdb/testsuite] Add gdb.base/fission-macro.exp Tom de Vries
2024-05-21 15:44  5% ` [PATCH 11/11] [gdb/testsuite] Don't use readelf in gdb/contrib/cc-with-tweaks.sh Tom de Vries
2024-05-21 16:18  3% [PATCH v3] Add "error_message+" feature to qSupported Alexandra Hájková

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).