public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/7] First cleanup of defs.h
@ 2024-04-22 20:10 Simon Marchi
  2024-04-22 20:10 ` [PATCH 1/7] gdb: move two declarations out " Simon Marchi
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Simon Marchi @ 2024-04-22 20:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Here is a first batch of patches that remove things from defs.h, trying
to sort them in more appropriate places.

Simon Marchi (7):
  gdb: move two declarations out of defs.h
  gdb: move `enum compile_i_scope_types` to compile/compile.h
  gdb: remove extract_long_unsigned_integer
  gdb: move store/extract integer functions to
    extract-store-integer.{c,h}
  gdb: move RequireLongest to gdbsupport/traits.h
  gdb: don't include hashtab.h in defs.h
  gdb: don't include gdbsupport/array-view.h in defs.h

 gdb/Makefile.in                     |   2 +
 gdb/aarch64-fbsd-tdep.c             |   1 +
 gdb/aarch64-linux-tdep.c            |   1 +
 gdb/aarch64-tdep.c                  |   1 +
 gdb/ada-lang.c                      |   1 +
 gdb/ada-tasks.c                     |   1 +
 gdb/ada-valprint.c                  |   1 +
 gdb/alpha-tdep.c                    |   1 +
 gdb/amd64-darwin-tdep.c             |   1 +
 gdb/amd64-linux-tdep.c              |   1 +
 gdb/amd64-obsd-tdep.c               |   1 +
 gdb/amd64-tdep.c                    |   1 +
 gdb/amd64-windows-tdep.c            |   1 +
 gdb/arc-tdep.c                      |   1 +
 gdb/arch-utils.c                    |   1 +
 gdb/arm-linux-tdep.c                |   1 +
 gdb/arm-none-tdep.c                 |   1 +
 gdb/arm-tdep.c                      |   1 +
 gdb/auxv.c                          |   1 +
 gdb/avr-tdep.c                      |   1 +
 gdb/bfin-linux-tdep.c               |   1 +
 gdb/bfin-tdep.c                     |   1 +
 gdb/bsd-uthread.c                   |   1 +
 gdb/c-lang.c                        |   1 +
 gdb/c-valprint.c                    |   1 +
 gdb/cli/cli-script.h                |   1 +
 gdb/compile/compile-object-load.h   |   1 +
 gdb/compile/compile.h               |  28 +++
 gdb/corefile.c                      |   1 +
 gdb/cp-valprint.c                   |   1 +
 gdb/cris-tdep.c                     |   1 +
 gdb/csky-tdep.c                     |   1 +
 gdb/darwin-nat.c                    |   1 +
 gdb/defs.h                          | 132 ------------
 gdb/dtrace-probe.c                  |   1 +
 gdb/dwarf2/die.h                    |   1 +
 gdb/dwarf2/index-common.h           |   3 +
 gdb/elfread.c                       |   1 +
 gdb/extension.h                     |   1 +
 gdb/extract-store-integer.c         | 308 ++++++++++++++++++++++++++++
 gdb/extract-store-integer.h         | 113 ++++++++++
 gdb/fbsd-tdep.c                     |   1 +
 gdb/findvar.c                       | 292 +-------------------------
 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/gnu-v3-abi.c                    |   1 +
 gdb/h8300-tdep.c                    |   1 +
 gdb/hppa-bsd-tdep.c                 |   1 +
 gdb/hppa-linux-tdep.c               |   1 +
 gdb/hppa-tdep.c                     |   1 +
 gdb/i386-bsd-tdep.c                 |   1 +
 gdb/i386-darwin-tdep.c              |   1 +
 gdb/i386-gnu-tdep.c                 |   1 +
 gdb/i386-linux-tdep.c               |   1 +
 gdb/i386-nto-tdep.c                 |   1 +
 gdb/i386-obsd-tdep.c                |   1 +
 gdb/i386-tdep.c                     |   1 +
 gdb/i387-tdep.c                     |   1 +
 gdb/ia64-linux-tdep.c               |   1 +
 gdb/ia64-tdep.c                     |   1 +
 gdb/inferior.c                      |   4 +-
 gdb/inferior.h                      |   3 +
 gdb/iq2000-tdep.c                   |   1 +
 gdb/jit.c                           |   1 +
 gdb/linux-nat-trad.c                |   1 +
 gdb/linux-record.c                  |   1 +
 gdb/lm32-tdep.c                     |   1 +
 gdb/loongarch-linux-tdep.c          |   1 +
 gdb/loongarch-tdep.c                |   1 +
 gdb/m32c-tdep.c                     |   1 +
 gdb/m32r-linux-tdep.c               |   1 +
 gdb/m32r-tdep.c                     |   1 +
 gdb/m68hc11-tdep.c                  |   1 +
 gdb/m68k-linux-tdep.c               |   1 +
 gdb/m68k-tdep.c                     |   1 +
 gdb/mep-tdep.c                      |   1 +
 gdb/mi/mi-main.c                    |   1 +
 gdb/microblaze-tdep.c               |   1 +
 gdb/mips-fbsd-tdep.c                |   1 +
 gdb/mips-linux-tdep.c               |   1 +
 gdb/mips-netbsd-tdep.c              |   1 +
 gdb/mips-tdep.c                     |   1 +
 gdb/mn10300-tdep.c                  |   1 +
 gdb/moxie-tdep.c                    |   1 +
 gdb/msp430-tdep.c                   |   1 +
 gdb/nds32-tdep.c                    |   1 +
 gdb/nios2-tdep.c                    |   1 +
 gdb/nto-tdep.c                      |   1 +
 gdb/or1k-tdep.c                     |   1 +
 gdb/p-lang.c                        |   1 +
 gdb/p-valprint.c                    |   1 +
 gdb/ppc-fbsd-tdep.c                 |   1 +
 gdb/ppc-linux-nat.c                 |   1 +
 gdb/ppc-linux-tdep.c                |   1 +
 gdb/ppc-obsd-tdep.c                 |   1 +
 gdb/ppc-sysv-tdep.c                 |   1 +
 gdb/ppc64-tdep.c                    |   1 +
 gdb/printcmd.c                      |   1 +
 gdb/procfs.c                        |   1 +
 gdb/progspace.c                     |   4 +-
 gdb/progspace.h                     |   3 +
 gdb/ravenscar-thread.c              |   1 +
 gdb/record-full.c                   |   1 +
 gdb/regcache.c                      |   1 +
 gdb/regcache.h                      |   1 +
 gdb/remote-fileio.c                 |   1 +
 gdb/riscv-fbsd-tdep.c               |   1 +
 gdb/riscv-tdep.c                    |   1 +
 gdb/rl78-tdep.c                     |   1 +
 gdb/rs6000-aix-tdep.c               |   1 +
 gdb/rs6000-lynx178-tdep.c           |   1 +
 gdb/rs6000-tdep.c                   |   1 +
 gdb/rx-tdep.c                       |   1 +
 gdb/s390-linux-nat.c                |   1 +
 gdb/s390-tdep.c                     |   1 +
 gdb/sh-tdep.c                       |   1 +
 gdb/solib-darwin.c                  |   1 +
 gdb/solib-dsbt.c                    |   1 +
 gdb/solib-frv.c                     |   1 +
 gdb/solib-svr4.c                    |   1 +
 gdb/solib.c                         |   1 +
 gdb/sparc-linux-tdep.c              |   1 +
 gdb/sparc-obsd-tdep.c               |   1 +
 gdb/sparc-tdep.c                    |   1 +
 gdb/sparc64-linux-tdep.c            |   1 +
 gdb/sparc64-obsd-tdep.c             |   1 +
 gdb/sparc64-tdep.c                  |   1 +
 gdb/stack.c                         |   1 +
 gdb/stap-probe.c                    |   1 +
 gdb/symfile.c                       |   1 +
 gdb/target.c                        |   1 +
 gdb/tic6x-tdep.c                    |   1 +
 gdb/tilegx-tdep.c                   |   1 +
 gdb/tracefile-tfile.c               |   1 +
 gdb/tracefile.c                     |   1 +
 gdb/trad-frame.c                    |   1 +
 gdb/tramp-frame.c                   |   1 +
 gdb/unittests/gmp-utils-selftests.c |   1 +
 gdb/v850-tdep.c                     |   1 +
 gdb/valarith.c                      |   1 +
 gdb/valops.c                        |   1 +
 gdb/valprint.c                      |   1 +
 gdb/value.c                         |   1 +
 gdb/vax-tdep.c                      |   1 +
 gdb/windows-tdep.c                  |   1 +
 gdb/xstormy16-tdep.c                |   1 +
 gdb/xtensa-tdep.c                   |   1 +
 gdb/z80-tdep.c                      |   1 +
 gdbsupport/traits.h                 |   4 +
 152 files changed, 609 insertions(+), 427 deletions(-)
 create mode 100644 gdb/extract-store-integer.c
 create mode 100644 gdb/extract-store-integer.h


base-commit: fdaa4939e5024ea809c0d4d1aa6043a60b37d9b5
-- 
2.44.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/7] gdb: move two declarations out of defs.h
  2024-04-22 20:10 [PATCH 0/7] First cleanup of defs.h Simon Marchi
@ 2024-04-22 20:10 ` Simon Marchi
  2024-04-22 20:10 ` [PATCH 2/7] gdb: move `enum compile_i_scope_types` to compile/compile.h Simon Marchi
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Simon Marchi @ 2024-04-22 20:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Move declarations of initialize_progspace and initialize_inferiors to
progspace.h and inferior.h, respectively.

Change-Id: I62292ffda429861b9f27d8c836a56d161dfa548d
---
 gdb/defs.h      | 5 -----
 gdb/inferior.c  | 4 ++--
 gdb/inferior.h  | 3 +++
 gdb/progspace.c | 4 ++--
 gdb/progspace.h | 3 +++
 5 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index cf471bf5d662..ce8f29b2cf6a 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -588,11 +588,6 @@ extern int (*deprecated_ui_load_progress_hook) (const char *section,
 /* * A width that can achieve a better legibility for GDB MI mode.  */
 #define GDB_MI_MSG_WIDTH  80
 
-/* From progspace.c */
-
-extern void initialize_progspace (void);
-extern void initialize_inferiors (void);
-
 /* * Special block numbers */
 
 enum block_enum
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 4e1d789d1ba6..5621ea40a6d7 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -1078,10 +1078,10 @@ static const struct internalvar_funcs inferior_funcs =
   NULL,
 };
 
-\f
+/* See inferior.h.  */
 
 void
-initialize_inferiors (void)
+initialize_inferiors ()
 {
   struct cmd_list_element *c = NULL;
 
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 7be28423aeb1..e239aa5b3cf0 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -327,6 +327,9 @@ struct inferior_control_state
   enum stop_kind stop_soon;
 };
 
+/* Initialize the inferior-related global state.  */
+extern void initialize_inferiors ();
+
 /* Return a pointer to the current inferior.  */
 extern inferior *current_inferior ();
 
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 131cd2f11865..c3a9909dcd4b 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -435,10 +435,10 @@ program_space::clear_solib_cache ()
   deleted_solibs.clear ();
 }
 
-\f
+/* See progspace.h.  */
 
 void
-initialize_progspace (void)
+initialize_progspace ()
 {
   add_cmd ("program-spaces", class_maintenance,
 	   maintenance_info_program_spaces_command,
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 7f5e23df1264..bbf54efa07ad 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -424,6 +424,9 @@ extern std::vector<struct program_space *>program_spaces;
 /* The current program space.  This is always non-null.  */
 extern struct program_space *current_program_space;
 
+/* Initialize progspace-related global state.  */
+extern void initialize_progspace ();
+
 /* Copies program space SRC to DEST.  Copies the main executable file,
    and the main symbol file.  Returns DEST.  */
 extern struct program_space *clone_program_space (struct program_space *dest,
-- 
2.44.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/7] gdb: move `enum compile_i_scope_types` to compile/compile.h
  2024-04-22 20:10 [PATCH 0/7] First cleanup of defs.h Simon Marchi
  2024-04-22 20:10 ` [PATCH 1/7] gdb: move two declarations out " Simon Marchi
@ 2024-04-22 20:10 ` Simon Marchi
  2024-04-22 20:10 ` [PATCH 3/7] gdb: remove extract_long_unsigned_integer Simon Marchi
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Simon Marchi @ 2024-04-22 20:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Move it out of defs.h, adjust the includes here and there.

Change-Id: I11901fdce55d54f5e51723e123cef154cfb1bbc5
---
 gdb/cli/cli-script.h              |  1 +
 gdb/compile/compile-object-load.h |  1 +
 gdb/compile/compile.h             | 28 ++++++++++++++++++++++++++++
 gdb/defs.h                        | 28 ----------------------------
 4 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h
index d36743e5a316..512e37b8bf35 100644
--- a/gdb/cli/cli-script.h
+++ b/gdb/cli/cli-script.h
@@ -17,6 +17,7 @@
 #ifndef CLI_CLI_SCRIPT_H
 #define CLI_CLI_SCRIPT_H
 
+#include "compile/compile.h"
 #include "gdbsupport/function-view.h"
 
 struct ui_file;
diff --git a/gdb/compile/compile-object-load.h b/gdb/compile/compile-object-load.h
index eb6eb0dd8717..83665b5c4c42 100644
--- a/gdb/compile/compile-object-load.h
+++ b/gdb/compile/compile-object-load.h
@@ -18,6 +18,7 @@
 #define COMPILE_COMPILE_OBJECT_LOAD_H
 
 #include "compile-internal.h"
+#include "compile.h"
 #include <list>
 
 struct munmap_list
diff --git a/gdb/compile/compile.h b/gdb/compile/compile.h
index d584df6661cc..4be6f50d4f38 100644
--- a/gdb/compile/compile.h
+++ b/gdb/compile/compile.h
@@ -19,6 +19,7 @@
 #define COMPILE_COMPILE_H
 
 #include "gcc-c-interface.h"
+#include "gdbsupport/gdb-hashtab.h"
 
 struct ui_file;
 struct gdbarch;
@@ -27,6 +28,33 @@ struct dwarf2_per_objfile;
 struct symbol;
 struct dynamic_prop;
 
+/* Scope types enumerator.  List the types of scopes the compiler will
+   accept.  */
+
+enum compile_i_scope_types
+  {
+    COMPILE_I_INVALID_SCOPE,
+
+    /* A simple scope.  Wrap an expression into a simple scope that
+       takes no arguments, returns no value, and uses the generic
+       function name "_gdb_expr". */
+
+    COMPILE_I_SIMPLE_SCOPE,
+
+    /* Do not wrap the expression,
+       it has to provide function "_gdb_expr" on its own.  */
+    COMPILE_I_RAW_SCOPE,
+
+    /* A printable expression scope.  Wrap an expression into a scope
+       suitable for the "compile print" command.  It uses the generic
+       function name "_gdb_expr".  COMPILE_I_PRINT_ADDRESS_SCOPE variant
+       is the usual one, taking address of the object.
+       COMPILE_I_PRINT_VALUE_SCOPE is needed for arrays where the array
+       name already specifies its address.  See get_out_value_type.  */
+    COMPILE_I_PRINT_ADDRESS_SCOPE,
+    COMPILE_I_PRINT_VALUE_SCOPE,
+  };
+
 /* An object of this type holds state associated with a given
    compilation job.  */
 
diff --git a/gdb/defs.h b/gdb/defs.h
index ce8f29b2cf6a..057581d27641 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -63,34 +63,6 @@
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/array-view.h"
 
-/* Scope types enumerator.  List the types of scopes the compiler will
-   accept.  */
-
-enum compile_i_scope_types
-  {
-    COMPILE_I_INVALID_SCOPE,
-
-    /* A simple scope.  Wrap an expression into a simple scope that
-       takes no arguments, returns no value, and uses the generic
-       function name "_gdb_expr". */
-
-    COMPILE_I_SIMPLE_SCOPE,
-
-    /* Do not wrap the expression,
-       it has to provide function "_gdb_expr" on its own.  */
-    COMPILE_I_RAW_SCOPE,
-
-    /* A printable expression scope.  Wrap an expression into a scope
-       suitable for the "compile print" command.  It uses the generic
-       function name "_gdb_expr".  COMPILE_I_PRINT_ADDRESS_SCOPE variant
-       is the usual one, taking address of the object.
-       COMPILE_I_PRINT_VALUE_SCOPE is needed for arrays where the array
-       name already specifies its address.  See get_out_value_type.  */
-    COMPILE_I_PRINT_ADDRESS_SCOPE,
-    COMPILE_I_PRINT_VALUE_SCOPE,
-  };
-
-
 template<typename T>
 using RequireLongest = gdb::Requires<gdb::Or<std::is_same<T, LONGEST>,
 					     std::is_same<T, ULONGEST>>>;
-- 
2.44.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 3/7] gdb: remove extract_long_unsigned_integer
  2024-04-22 20:10 [PATCH 0/7] First cleanup of defs.h Simon Marchi
  2024-04-22 20:10 ` [PATCH 1/7] gdb: move two declarations out " Simon Marchi
  2024-04-22 20:10 ` [PATCH 2/7] gdb: move `enum compile_i_scope_types` to compile/compile.h Simon Marchi
@ 2024-04-22 20:10 ` Simon Marchi
  2024-04-22 20:10 ` [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c,h} Simon Marchi
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Simon Marchi @ 2024-04-22 20:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

It is unused.

Change-Id: I5d4091368c4dfc29752b12061e38f1df8353ba74
---
 gdb/defs.h    |  3 ---
 gdb/findvar.c | 53 ---------------------------------------------------
 2 files changed, 56 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index 057581d27641..be5c9b7261b6 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -457,9 +457,6 @@ extract_unsigned_integer (const gdb_byte *addr, int len,
 				   byte_order);
 }
 
-extern int extract_long_unsigned_integer (const gdb_byte *, int,
-					  enum bfd_endian, LONGEST *);
-
 extern CORE_ADDR extract_typed_address (const gdb_byte *buf,
 					struct type *type);
 
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 71bfebe40a7a..734494961696 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -92,59 +92,6 @@ template LONGEST extract_integer<LONGEST> (gdb::array_view<const gdb_byte> buf,
 template ULONGEST extract_integer<ULONGEST>
   (gdb::array_view<const gdb_byte> buf, enum bfd_endian byte_order);
 
-/* Sometimes a long long unsigned integer can be extracted as a
-   LONGEST value.  This is done so that we can print these values
-   better.  If this integer can be converted to a LONGEST, this
-   function returns 1 and sets *PVAL.  Otherwise it returns 0.  */
-
-int
-extract_long_unsigned_integer (const gdb_byte *addr, int orig_len,
-			       enum bfd_endian byte_order, LONGEST *pval)
-{
-  const gdb_byte *p;
-  const gdb_byte *first_addr;
-  int len;
-
-  len = orig_len;
-  if (byte_order == BFD_ENDIAN_BIG)
-    {
-      for (p = addr;
-	   len > (int) sizeof (LONGEST) && p < addr + orig_len;
-	   p++)
-	{
-	  if (*p == 0)
-	    len--;
-	  else
-	    break;
-	}
-      first_addr = p;
-    }
-  else
-    {
-      first_addr = addr;
-      for (p = addr + orig_len - 1;
-	   len > (int) sizeof (LONGEST) && p >= addr;
-	   p--)
-	{
-	  if (*p == 0)
-	    len--;
-	  else
-	    break;
-	}
-    }
-
-  if (len <= (int) sizeof (LONGEST))
-    {
-      *pval = (LONGEST) extract_unsigned_integer (first_addr,
-						  sizeof (LONGEST),
-						  byte_order);
-      return 1;
-    }
-
-  return 0;
-}
-
-
 /* Treat the bytes at BUF as a pointer of type TYPE, and return the
    address it represents.  */
 CORE_ADDR
-- 
2.44.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c,h}
  2024-04-22 20:10 [PATCH 0/7] First cleanup of defs.h Simon Marchi
                   ` (2 preceding siblings ...)
  2024-04-22 20:10 ` [PATCH 3/7] gdb: remove extract_long_unsigned_integer Simon Marchi
@ 2024-04-22 20:10 ` Simon Marchi
  2024-04-23 18:03   ` [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c, h} Pedro Alves
  2024-04-22 20:10 ` [PATCH 5/7] gdb: move RequireLongest to gdbsupport/traits.h Simon Marchi
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Simon Marchi @ 2024-04-22 20:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Move the declarations out of defs.h, and the implementations out of
findvar.c.

I opted for a new file, because this functionality of converting
integers to bytes and vice-versa seems a bit to generic to live in
findvar.c.

Change-Id: I524858fca33901ee2150c582bac16042148d2251
---
 gdb/Makefile.in                     |   2 +
 gdb/aarch64-fbsd-tdep.c             |   1 +
 gdb/aarch64-linux-tdep.c            |   1 +
 gdb/aarch64-tdep.c                  |   1 +
 gdb/ada-lang.c                      |   1 +
 gdb/ada-tasks.c                     |   1 +
 gdb/ada-valprint.c                  |   1 +
 gdb/alpha-tdep.c                    |   1 +
 gdb/amd64-darwin-tdep.c             |   1 +
 gdb/amd64-linux-tdep.c              |   1 +
 gdb/amd64-obsd-tdep.c               |   1 +
 gdb/amd64-tdep.c                    |   1 +
 gdb/amd64-windows-tdep.c            |   1 +
 gdb/arc-tdep.c                      |   1 +
 gdb/arch-utils.c                    |   1 +
 gdb/arm-linux-tdep.c                |   1 +
 gdb/arm-none-tdep.c                 |   1 +
 gdb/arm-tdep.c                      |   1 +
 gdb/auxv.c                          |   1 +
 gdb/avr-tdep.c                      |   1 +
 gdb/bfin-linux-tdep.c               |   1 +
 gdb/bfin-tdep.c                     |   1 +
 gdb/bsd-uthread.c                   |   1 +
 gdb/c-lang.c                        |   1 +
 gdb/c-valprint.c                    |   1 +
 gdb/corefile.c                      |   1 +
 gdb/cp-valprint.c                   |   1 +
 gdb/cris-tdep.c                     |   1 +
 gdb/csky-tdep.c                     |   1 +
 gdb/darwin-nat.c                    |   1 +
 gdb/defs.h                          |  89 --------
 gdb/dtrace-probe.c                  |   1 +
 gdb/dwarf2/index-common.h           |   2 +
 gdb/elfread.c                       |   1 +
 gdb/extract-store-integer.c         | 308 ++++++++++++++++++++++++++++
 gdb/extract-store-integer.h         | 111 ++++++++++
 gdb/fbsd-tdep.c                     |   1 +
 gdb/findvar.c                       | 239 +--------------------
 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/gnu-v3-abi.c                    |   1 +
 gdb/h8300-tdep.c                    |   1 +
 gdb/hppa-bsd-tdep.c                 |   1 +
 gdb/hppa-linux-tdep.c               |   1 +
 gdb/hppa-tdep.c                     |   1 +
 gdb/i386-bsd-tdep.c                 |   1 +
 gdb/i386-darwin-tdep.c              |   1 +
 gdb/i386-gnu-tdep.c                 |   1 +
 gdb/i386-linux-tdep.c               |   1 +
 gdb/i386-nto-tdep.c                 |   1 +
 gdb/i386-obsd-tdep.c                |   1 +
 gdb/i386-tdep.c                     |   1 +
 gdb/i387-tdep.c                     |   1 +
 gdb/ia64-linux-tdep.c               |   1 +
 gdb/ia64-tdep.c                     |   1 +
 gdb/iq2000-tdep.c                   |   1 +
 gdb/jit.c                           |   1 +
 gdb/linux-nat-trad.c                |   1 +
 gdb/linux-record.c                  |   1 +
 gdb/lm32-tdep.c                     |   1 +
 gdb/loongarch-linux-tdep.c          |   1 +
 gdb/loongarch-tdep.c                |   1 +
 gdb/m32c-tdep.c                     |   1 +
 gdb/m32r-linux-tdep.c               |   1 +
 gdb/m32r-tdep.c                     |   1 +
 gdb/m68hc11-tdep.c                  |   1 +
 gdb/m68k-linux-tdep.c               |   1 +
 gdb/m68k-tdep.c                     |   1 +
 gdb/mep-tdep.c                      |   1 +
 gdb/mi/mi-main.c                    |   1 +
 gdb/microblaze-tdep.c               |   1 +
 gdb/mips-fbsd-tdep.c                |   1 +
 gdb/mips-linux-tdep.c               |   1 +
 gdb/mips-netbsd-tdep.c              |   1 +
 gdb/mips-tdep.c                     |   1 +
 gdb/mn10300-tdep.c                  |   1 +
 gdb/moxie-tdep.c                    |   1 +
 gdb/msp430-tdep.c                   |   1 +
 gdb/nds32-tdep.c                    |   1 +
 gdb/nios2-tdep.c                    |   1 +
 gdb/nto-tdep.c                      |   1 +
 gdb/or1k-tdep.c                     |   1 +
 gdb/p-lang.c                        |   1 +
 gdb/p-valprint.c                    |   1 +
 gdb/ppc-fbsd-tdep.c                 |   1 +
 gdb/ppc-linux-nat.c                 |   1 +
 gdb/ppc-linux-tdep.c                |   1 +
 gdb/ppc-obsd-tdep.c                 |   1 +
 gdb/ppc-sysv-tdep.c                 |   1 +
 gdb/ppc64-tdep.c                    |   1 +
 gdb/printcmd.c                      |   1 +
 gdb/procfs.c                        |   1 +
 gdb/ravenscar-thread.c              |   1 +
 gdb/record-full.c                   |   1 +
 gdb/regcache.c                      |   1 +
 gdb/remote-fileio.c                 |   1 +
 gdb/riscv-fbsd-tdep.c               |   1 +
 gdb/riscv-tdep.c                    |   1 +
 gdb/rl78-tdep.c                     |   1 +
 gdb/rs6000-aix-tdep.c               |   1 +
 gdb/rs6000-lynx178-tdep.c           |   1 +
 gdb/rs6000-tdep.c                   |   1 +
 gdb/rx-tdep.c                       |   1 +
 gdb/s390-linux-nat.c                |   1 +
 gdb/s390-tdep.c                     |   1 +
 gdb/sh-tdep.c                       |   1 +
 gdb/solib-darwin.c                  |   1 +
 gdb/solib-dsbt.c                    |   1 +
 gdb/solib-frv.c                     |   1 +
 gdb/solib-svr4.c                    |   1 +
 gdb/solib.c                         |   1 +
 gdb/sparc-linux-tdep.c              |   1 +
 gdb/sparc-obsd-tdep.c               |   1 +
 gdb/sparc-tdep.c                    |   1 +
 gdb/sparc64-linux-tdep.c            |   1 +
 gdb/sparc64-obsd-tdep.c             |   1 +
 gdb/sparc64-tdep.c                  |   1 +
 gdb/stack.c                         |   1 +
 gdb/stap-probe.c                    |   1 +
 gdb/symfile.c                       |   1 +
 gdb/target.c                        |   1 +
 gdb/tic6x-tdep.c                    |   1 +
 gdb/tilegx-tdep.c                   |   1 +
 gdb/tracefile-tfile.c               |   1 +
 gdb/tracefile.c                     |   1 +
 gdb/trad-frame.c                    |   1 +
 gdb/tramp-frame.c                   |   1 +
 gdb/unittests/gmp-utils-selftests.c |   1 +
 gdb/v850-tdep.c                     |   1 +
 gdb/valarith.c                      |   1 +
 gdb/valops.c                        |   1 +
 gdb/valprint.c                      |   1 +
 gdb/value.c                         |   1 +
 gdb/vax-tdep.c                      |   1 +
 gdb/windows-tdep.c                  |   1 +
 gdb/xstormy16-tdep.c                |   1 +
 gdb/xtensa-tdep.c                   |   1 +
 gdb/z80-tdep.c                      |   1 +
 141 files changed, 559 insertions(+), 327 deletions(-)
 create mode 100644 gdb/extract-store-integer.c
 create mode 100644 gdb/extract-store-integer.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 23894ea4a4da..618c5bbb3399 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1109,6 +1109,7 @@ COMMON_SFILES = \
 	dwarf2/read-gdb-index.c \
 	dwarf2/section.c \
 	dwarf2/stringify.c \
+	extract-store-integer.c \
 	eval.c \
 	event-top.c \
 	exceptions.c \
@@ -1362,6 +1363,7 @@ HFILES_NO_SRCDIR = \
 	expression.h \
 	extension.h \
 	extension-priv.h \
+	extract-store-integer.h \
 	f-array-walker.h \
 	f-lang.h \
 	fbsd-nat.h \
diff --git a/gdb/aarch64-fbsd-tdep.c b/gdb/aarch64-fbsd-tdep.c
index e2ff57e83900..844023c2e7b7 100644
--- a/gdb/aarch64-fbsd-tdep.c
+++ b/gdb/aarch64-fbsd-tdep.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
+#include "extract-store-integer.h"
 #include "gdbarch.h"
 #include "fbsd-tdep.h"
 #include "aarch64-tdep.h"
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 359798759076..ad55cf2caa3b 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -19,6 +19,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
+#include "extract-store-integer.h"
 #include "gdbarch.h"
 #include "glibc-tdep.h"
 #include "linux-tdep.h"
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 06eda102468a..a01ae39d25cf 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -19,6 +19,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "language.h"
 #include "gdbcmd.h"
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a3870020e8d8..5ab6e8b14b72 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -19,6 +19,7 @@
 
 
 #include <ctype.h>
+#include "extract-store-integer.h"
 #include "gdbsupport/gdb_regex.h"
 #include "frame.h"
 #include "symtab.h"
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 864c5cfdf1c6..547395d36d60 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -15,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "observable.h"
 #include "gdbcmd.h"
 #include "target.h"
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 6acfb9a48b69..6d3fca9bdeba 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <ctype.h>
+#include "extract-store-integer.h"
 #include "gdbtypes.h"
 #include "expression.h"
 #include "value.h"
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index c93bd69657f6..ada8afd37258 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/amd64-darwin-tdep.c b/gdb/amd64-darwin-tdep.c
index b0bead084fea..f2741e2cff85 100644
--- a/gdb/amd64-darwin-tdep.c
+++ b/gdb/amd64-darwin-tdep.c
@@ -18,6 +18,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 "extract-store-integer.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 9d560ac4fbf4..c52b04368726 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -19,6 +19,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c
index f6f63bbf8ed0..5b1e77b3e86e 100644
--- a/gdb/amd64-obsd-tdep.c
+++ b/gdb/amd64-obsd-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 0bb7a24cbd08..053067e2cf23 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -19,6 +19,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 "extract-store-integer.h"
 #include "language.h"
 #include "opcode/i386.h"
 #include "dis-asm.h"
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index a559d967b3c9..3dfc80005339 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -15,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "osabi.h"
 #include "amd64-tdep.h"
 #include "gdbsupport/x86-xstate.h"
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 5684f324233c..f35f4c4be74a 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -23,6 +23,7 @@
 #include "elf-bfd.h"
 #include "disasm.h"
 #include "dwarf2/frame.h"
+#include "extract-store-integer.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index cb149c36bc94..b8a18a58af2a 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -19,6 +19,7 @@
 
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "gdbcmd.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 8511abcd11d6..43869e4fcfe2 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "target.h"
 #include "value.h"
 #include "gdbtypes.h"
diff --git a/gdb/arm-none-tdep.c b/gdb/arm-none-tdep.c
index 453e75234d4b..4212af3c6f14 100644
--- a/gdb/arm-none-tdep.c
+++ b/gdb/arm-none-tdep.c
@@ -19,6 +19,7 @@
 
 #include "arm-tdep.h"
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "regcache.h"
 #include "elf-bfd.h"
 #include "regset.h"
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index b4062a8f9225..97728d9100c7 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -20,6 +20,7 @@
 
 #include <ctype.h>
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "language.h"
 #include "inferior.h"
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 1dc0587c0075..616564c43a3f 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "target.h"
 #include "gdbtypes.h"
 #include "command.h"
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index be95034abd5c..68b2646d202d 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -22,6 +22,7 @@
 /* Portions of this file were taken from the original gdb-4.18 patch developed
    by Denis Chertykov, denisc@overta.ru */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/bfin-linux-tdep.c b/gdb/bfin-linux-tdep.c
index f67e06478eb1..0b1b018e7367 100644
--- a/gdb/bfin-linux-tdep.c
+++ b/gdb/bfin-linux-tdep.c
@@ -20,6 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "regcache.h"
 #include "tramp-frame.h"
 #include "trad-frame.h"
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index dbc339d93366..b89b7dfa6d8b 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -19,6 +19,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 "extract-store-integer.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "arch-utils.h"
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 576a9ec1cfbb..a686f173fbf2 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
 #include "inferior.h"
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 922bf8c0de34..2b6cf087f548 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 28a6a6afea2f..ca24b1536bcf 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 16cd60f7106d..984c7bef8800 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -19,6 +19,7 @@
 
 #include <signal.h>
 #include <fcntl.h>
+#include "extract-store-integer.h"
 #include "inferior.h"
 #include "symtab.h"
 #include "command.h"
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index f2a2ca5288da..2e776f40a637 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index dd013d531abb..8ca9fbc5251a 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -20,6 +20,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 "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index 5f0fd3d7170d..49aa1f680122 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -19,6 +19,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 "extract-store-integer.h"
 #include "gdbsupport/gdb_assert.h"
 #include "frame.h"
 #include "inferior.h"
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 0c5b54b40a3b..33896a88d2b8 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -18,6 +18,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 "extract-store-integer.h"
 #include "top.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/defs.h b/gdb/defs.h
index be5c9b7261b6..5da8ce728153 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -422,95 +422,6 @@ enum symbol_needs_kind
   SYMBOL_NEEDS_FRAME
 };
 
-/* In findvar.c.  */
-
-template<typename T, typename = RequireLongest<T>>
-T extract_integer (gdb::array_view<const gdb_byte>, enum bfd_endian byte_order);
-
-static inline LONGEST
-extract_signed_integer (gdb::array_view<const gdb_byte> buf,
-			enum bfd_endian byte_order)
-{
-  return extract_integer<LONGEST> (buf, byte_order);
-}
-
-static inline LONGEST
-extract_signed_integer (const gdb_byte *addr, int len,
-			enum bfd_endian byte_order)
-{
-  return extract_signed_integer (gdb::array_view<const gdb_byte> (addr, len),
-				 byte_order);
-}
-
-static inline ULONGEST
-extract_unsigned_integer (gdb::array_view<const gdb_byte> buf,
-			  enum bfd_endian byte_order)
-{
-  return extract_integer<ULONGEST> (buf, byte_order);
-}
-
-static inline ULONGEST
-extract_unsigned_integer (const gdb_byte *addr, int len,
-			  enum bfd_endian byte_order)
-{
-  return extract_unsigned_integer (gdb::array_view<const gdb_byte> (addr, len),
-				   byte_order);
-}
-
-extern CORE_ADDR extract_typed_address (const gdb_byte *buf,
-					struct type *type);
-
-/* All 'store' functions accept a host-format integer and store a
-   target-format integer at ADDR which is LEN bytes long.  */
-
-template<typename T, typename = RequireLongest<T>>
-extern void store_integer (gdb::array_view<gdb_byte> dst,
-			   bfd_endian byte_order, T val);
-
-template<typename T>
-static inline void
-store_integer (gdb_byte *addr, int len, bfd_endian byte_order, T val)
-{
-  return store_integer (gdb::make_array_view (addr, len), byte_order, val);
-}
-
-static inline void
-store_signed_integer (gdb::array_view<gdb_byte> dst, bfd_endian byte_order,
-		      LONGEST val)
-{
-  return store_integer (dst, byte_order, val);
-}
-
-static inline void
-store_signed_integer (gdb_byte *addr, int len, bfd_endian byte_order,
-		      LONGEST val)
-{
-  return store_signed_integer (gdb::make_array_view (addr, len), byte_order,
-			       val);
-}
-
-static inline void
-store_unsigned_integer (gdb::array_view<gdb_byte> dst, bfd_endian byte_order,
-			ULONGEST val)
-{
-  return store_integer (dst, byte_order, val);
-}
-
-static inline void
-store_unsigned_integer (gdb_byte *addr, int len, bfd_endian byte_order,
-			ULONGEST val)
-{
-  return store_unsigned_integer (gdb::make_array_view (addr, len), byte_order,
-				 val);
-}
-
-extern void store_typed_address (gdb_byte *buf, struct type *type,
-				 CORE_ADDR addr);
-
-extern void copy_integer_to_size (gdb_byte *dest, int dest_size,
-				  const gdb_byte *source, int source_size,
-				  bool is_signed, enum bfd_endian byte_order);
-
 /* Hooks for alternate command interfaces.  */
 
 struct target_waitstatus;
diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index ad1a3f870b63..0f4e1643483f 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -19,6 +19,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 "extract-store-integer.h"
 #include "probe.h"
 #include "elf-bfd.h"
 #include "gdbtypes.h"
diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h
index dca41517b3d8..0a871a7e364a 100644
--- a/gdb/dwarf2/index-common.h
+++ b/gdb/dwarf2/index-common.h
@@ -20,6 +20,8 @@
 #ifndef DWARF_INDEX_COMMON_H
 #define DWARF_INDEX_COMMON_H
 
+#include "extract-store-integer.h"
+
 /* The suffix for an index file.  */
 #define INDEX4_SUFFIX ".gdb-index"
 #define INDEX5_SUFFIX ".debug_names"
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 9bfe12712db7..7a6a8cadcedd 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -24,6 +24,7 @@
 #include "elf/common.h"
 #include "elf/internal.h"
 #include "elf/mips.h"
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "symfile.h"
 #include "objfiles.h"
diff --git a/gdb/extract-store-integer.c b/gdb/extract-store-integer.c
new file mode 100644
index 000000000000..a3b7e40d6424
--- /dev/null
+++ b/gdb/extract-store-integer.c
@@ -0,0 +1,308 @@
+/* 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 "extract-store-integer.h"
+#include "gdbtypes.h"
+#include "gdbarch.h"
+#include "gdbsupport/selftest.h"
+
+template<typename T, typename>
+T
+extract_integer (gdb::array_view<const gdb_byte> buf, enum bfd_endian byte_order)
+{
+  typename std::make_unsigned<T>::type retval = 0;
+
+  if (buf.size () > (int) sizeof (T))
+    error (_("\
+That operation is not available on integers of more than %d bytes."),
+	   (int) sizeof (T));
+
+  /* Start at the most significant end of the integer, and work towards
+     the least significant.  */
+  if (byte_order == BFD_ENDIAN_BIG)
+    {
+      size_t i = 0;
+
+      if (std::is_signed<T>::value)
+	{
+	  /* Do the sign extension once at the start.  */
+	  retval = ((LONGEST) buf[i] ^ 0x80) - 0x80;
+	  ++i;
+	}
+      for (; i < buf.size (); ++i)
+	retval = (retval << 8) | buf[i];
+    }
+  else
+    {
+      ssize_t i = buf.size () - 1;
+
+      if (std::is_signed<T>::value)
+	{
+	  /* Do the sign extension once at the start.  */
+	  retval = ((LONGEST) buf[i] ^ 0x80) - 0x80;
+	  --i;
+	}
+      for (; i >= 0; --i)
+	retval = (retval << 8) | buf[i];
+    }
+  return retval;
+}
+
+/* Explicit instantiations.  */
+template LONGEST extract_integer<LONGEST> (gdb::array_view<const gdb_byte> buf,
+					   enum bfd_endian byte_order);
+template ULONGEST extract_integer<ULONGEST>
+  (gdb::array_view<const gdb_byte> buf, enum bfd_endian byte_order);
+
+/* Sometimes a long long unsigned integer can be extracted as a
+   LONGEST value.  This is done so that we can print these values
+   better.  If this integer can be converted to a LONGEST, this
+   function returns 1 and sets *PVAL.  Otherwise it returns 0.  */
+
+int
+extract_long_unsigned_integer (const gdb_byte *addr, int orig_len,
+			       enum bfd_endian byte_order, LONGEST *pval)
+{
+  const gdb_byte *p;
+  const gdb_byte *first_addr;
+  int len;
+
+  len = orig_len;
+  if (byte_order == BFD_ENDIAN_BIG)
+    {
+      for (p = addr;
+	   len > (int) sizeof (LONGEST) && p < addr + orig_len;
+	   p++)
+	{
+	  if (*p == 0)
+	    len--;
+	  else
+	    break;
+	}
+      first_addr = p;
+    }
+  else
+    {
+      first_addr = addr;
+      for (p = addr + orig_len - 1;
+	   len > (int) sizeof (LONGEST) && p >= addr;
+	   p--)
+	{
+	  if (*p == 0)
+	    len--;
+	  else
+	    break;
+	}
+    }
+
+  if (len <= (int) sizeof (LONGEST))
+    {
+      *pval = (LONGEST) extract_unsigned_integer (first_addr,
+						  sizeof (LONGEST),
+						  byte_order);
+      return 1;
+    }
+
+  return 0;
+}
+
+
+/* Treat the bytes at BUF as a pointer of type TYPE, and return the
+   address it represents.  */
+CORE_ADDR
+extract_typed_address (const gdb_byte *buf, struct type *type)
+{
+  gdb_assert (type->is_pointer_or_reference ());
+  return gdbarch_pointer_to_address (type->arch (), type, buf);
+}
+
+/* All 'store' functions accept a host-format integer and store a
+   target-format integer at ADDR which is LEN bytes long.  */
+template<typename T, typename>
+void
+store_integer (gdb::array_view<gdb_byte> dst, enum bfd_endian byte_order,
+	       T val)
+{
+  gdb_byte *p;
+  gdb_byte *startaddr = dst.data ();
+  gdb_byte *endaddr = startaddr + dst.size ();
+
+  /* Start at the least significant end of the integer, and work towards
+     the most significant.  */
+  if (byte_order == BFD_ENDIAN_BIG)
+    {
+      for (p = endaddr - 1; p >= startaddr; --p)
+	{
+	  *p = val & 0xff;
+	  val >>= 8;
+	}
+    }
+  else
+    {
+      for (p = startaddr; p < endaddr; ++p)
+	{
+	  *p = val & 0xff;
+	  val >>= 8;
+	}
+    }
+}
+
+/* Explicit instantiations.  */
+template void store_integer (gdb::array_view<gdb_byte> dst,
+			     bfd_endian byte_order, LONGEST val);
+
+template void store_integer (gdb::array_view<gdb_byte> dst,
+			     bfd_endian byte_order, ULONGEST val);
+
+/* Store the address ADDR as a pointer of type TYPE at BUF, in target
+   form.  */
+void
+store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr)
+{
+  gdb_assert (type->is_pointer_or_reference ());
+  gdbarch_address_to_pointer (type->arch (), type, buf, addr);
+}
+
+/* Copy a value from SOURCE of size SOURCE_SIZE bytes to DEST of size DEST_SIZE
+   bytes.  If SOURCE_SIZE is greater than DEST_SIZE, then truncate the most
+   significant bytes.  If SOURCE_SIZE is less than DEST_SIZE then either sign
+   or zero extended according to IS_SIGNED.  Values are stored in memory with
+   endianness BYTE_ORDER.  */
+
+void
+copy_integer_to_size (gdb_byte *dest, int dest_size, const gdb_byte *source,
+		      int source_size, bool is_signed,
+		      enum bfd_endian byte_order)
+{
+  signed int size_diff = dest_size - source_size;
+
+  /* Copy across everything from SOURCE that can fit into DEST.  */
+
+  if (byte_order == BFD_ENDIAN_BIG && size_diff > 0)
+    memcpy (dest + size_diff, source, source_size);
+  else if (byte_order == BFD_ENDIAN_BIG && size_diff < 0)
+    memcpy (dest, source - size_diff, dest_size);
+  else
+    memcpy (dest, source, std::min (source_size, dest_size));
+
+  /* Fill the remaining space in DEST by either zero extending or sign
+     extending.  */
+
+  if (size_diff > 0)
+    {
+      gdb_byte extension = 0;
+      if (is_signed
+	  && ((byte_order != BFD_ENDIAN_BIG && source[source_size - 1] & 0x80)
+	      || (byte_order == BFD_ENDIAN_BIG && source[0] & 0x80)))
+	extension = 0xff;
+
+      /* Extend into MSBs of SOURCE.  */
+      if (byte_order == BFD_ENDIAN_BIG)
+	memset (dest, extension, size_diff);
+      else
+	memset (dest + source_size, extension, size_diff);
+    }
+}
+
+#if GDB_SELF_TEST
+namespace selftests {
+
+/* Function to test copy_integer_to_size.  Store SOURCE_VAL with size
+   SOURCE_SIZE to a buffer, making sure no sign extending happens at this
+   stage.  Copy buffer to a new buffer using copy_integer_to_size.  Extract
+   copied value and compare to DEST_VALU.  Copy again with a signed
+   copy_integer_to_size and compare to DEST_VALS.  Do everything for both
+   LITTLE and BIG target endians.  Use unsigned values throughout to make
+   sure there are no implicit sign extensions.  */
+
+static void
+do_cint_test (ULONGEST dest_valu, ULONGEST dest_vals, int dest_size,
+	      ULONGEST src_val, int src_size)
+{
+  for (int i = 0; i < 2 ; i++)
+    {
+      gdb_byte srcbuf[sizeof (ULONGEST)] = {};
+      gdb_byte destbuf[sizeof (ULONGEST)] = {};
+      enum bfd_endian byte_order = i ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
+
+      /* Fill the src buffer (and later the dest buffer) with non-zero junk,
+	 to ensure zero extensions aren't hidden.  */
+      memset (srcbuf, 0xaa, sizeof (srcbuf));
+
+      /* Store (and later extract) using unsigned to ensure there are no sign
+	 extensions.  */
+      store_unsigned_integer (srcbuf, src_size, byte_order, src_val);
+
+      /* Test unsigned.  */
+      memset (destbuf, 0xaa, sizeof (destbuf));
+      copy_integer_to_size (destbuf, dest_size, srcbuf, src_size, false,
+			    byte_order);
+      SELF_CHECK (dest_valu == extract_unsigned_integer (destbuf, dest_size,
+							 byte_order));
+
+      /* Test signed.  */
+      memset (destbuf, 0xaa, sizeof (destbuf));
+      copy_integer_to_size (destbuf, dest_size, srcbuf, src_size, true,
+			    byte_order);
+      SELF_CHECK (dest_vals == extract_unsigned_integer (destbuf, dest_size,
+							 byte_order));
+    }
+}
+
+static void
+copy_integer_to_size_test ()
+{
+  /* Destination is bigger than the source, which has the signed bit unset.  */
+  do_cint_test (0x12345678, 0x12345678, 8, 0x12345678, 4);
+  do_cint_test (0x345678, 0x345678, 8, 0x12345678, 3);
+
+  /* Destination is bigger than the source, which has the signed bit set.  */
+  do_cint_test (0xdeadbeef, 0xffffffffdeadbeef, 8, 0xdeadbeef, 4);
+  do_cint_test (0xadbeef, 0xffffffffffadbeef, 8, 0xdeadbeef, 3);
+
+  /* Destination is smaller than the source.  */
+  do_cint_test (0x5678, 0x5678, 2, 0x12345678, 3);
+  do_cint_test (0xbeef, 0xbeef, 2, 0xdeadbeef, 3);
+
+  /* Destination and source are the same size.  */
+  do_cint_test (0x8765432112345678, 0x8765432112345678, 8, 0x8765432112345678,
+		8);
+  do_cint_test (0x432112345678, 0x432112345678, 6, 0x8765432112345678, 6);
+  do_cint_test (0xfeedbeaddeadbeef, 0xfeedbeaddeadbeef, 8, 0xfeedbeaddeadbeef,
+		8);
+  do_cint_test (0xbeaddeadbeef, 0xbeaddeadbeef, 6, 0xfeedbeaddeadbeef, 6);
+
+  /* Destination is bigger than the source.  Source is bigger than 32bits.  */
+  do_cint_test (0x3412345678, 0x3412345678, 8, 0x3412345678, 6);
+  do_cint_test (0xff12345678, 0xff12345678, 8, 0xff12345678, 6);
+  do_cint_test (0x432112345678, 0x432112345678, 8, 0x8765432112345678, 6);
+  do_cint_test (0xff2112345678, 0xffffff2112345678, 8, 0xffffff2112345678, 6);
+}
+
+} // namespace selftests
+
+#endif
+
+void _initialize_extract_store_integer ();
+void
+_initialize_extract_store_integer ()
+{
+#if GDB_SELF_TEST
+  selftests::register_test ("copy_integer_to_size",
+			    selftests::copy_integer_to_size_test);
+#endif
+}
diff --git a/gdb/extract-store-integer.h b/gdb/extract-store-integer.h
new file mode 100644
index 000000000000..1ba5f82da9a7
--- /dev/null
+++ b/gdb/extract-store-integer.h
@@ -0,0 +1,111 @@
+/* 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 GDB_EXTRACT_STORE_INTEGER_H
+#define GDB_EXTRACT_STORE_INTEGER_H
+
+template<typename T, typename = RequireLongest<T>>
+T extract_integer (gdb::array_view<const gdb_byte>, enum bfd_endian byte_order);
+
+static inline LONGEST
+extract_signed_integer (gdb::array_view<const gdb_byte> buf,
+			enum bfd_endian byte_order)
+{
+  return extract_integer<LONGEST> (buf, byte_order);
+}
+
+static inline LONGEST
+extract_signed_integer (const gdb_byte *addr, int len,
+			enum bfd_endian byte_order)
+{
+  return extract_signed_integer (gdb::array_view<const gdb_byte> (addr, len),
+				 byte_order);
+}
+
+static inline ULONGEST
+extract_unsigned_integer (gdb::array_view<const gdb_byte> buf,
+			  enum bfd_endian byte_order)
+{
+  return extract_integer<ULONGEST> (buf, byte_order);
+}
+
+static inline ULONGEST
+extract_unsigned_integer (const gdb_byte *addr, int len,
+			  enum bfd_endian byte_order)
+{
+  return extract_unsigned_integer (gdb::array_view<const gdb_byte> (addr, len),
+				   byte_order);
+}
+
+extern int extract_long_unsigned_integer (const gdb_byte *, int,
+					  enum bfd_endian, LONGEST *);
+
+extern CORE_ADDR extract_typed_address (const gdb_byte *buf,
+					struct type *type);
+
+/* All 'store' functions accept a host-format integer and store a
+   target-format integer at ADDR which is LEN bytes long.  */
+
+template<typename T, typename = RequireLongest<T>>
+extern void store_integer (gdb::array_view<gdb_byte> dst,
+			   bfd_endian byte_order, T val);
+
+template<typename T>
+static inline void
+store_integer (gdb_byte *addr, int len, bfd_endian byte_order, T val)
+{
+  return store_integer (gdb::make_array_view (addr, len), byte_order, val);
+}
+
+static inline void
+store_signed_integer (gdb::array_view<gdb_byte> dst, bfd_endian byte_order,
+		      LONGEST val)
+{
+  return store_integer (dst, byte_order, val);
+}
+
+static inline void
+store_signed_integer (gdb_byte *addr, int len, bfd_endian byte_order,
+		      LONGEST val)
+{
+  return store_signed_integer (gdb::make_array_view (addr, len), byte_order,
+			       val);
+}
+
+static inline void
+store_unsigned_integer (gdb::array_view<gdb_byte> dst, bfd_endian byte_order,
+			ULONGEST val)
+{
+  return store_integer (dst, byte_order, val);
+}
+
+static inline void
+store_unsigned_integer (gdb_byte *addr, int len, bfd_endian byte_order,
+			ULONGEST val)
+{
+  return store_unsigned_integer (gdb::make_array_view (addr, len), byte_order,
+				 val);
+}
+
+extern void store_typed_address (gdb_byte *buf, struct type *type,
+				 CORE_ADDR addr);
+
+extern void copy_integer_to_size (gdb_byte *dest, int dest_size,
+				  const gdb_byte *source, int source_size,
+				  bool is_signed, enum bfd_endian byte_order);
+
+#endif /* GDB_EXTRACT_STORE_INTEGER_H */
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 593f5b4fd4a1..a80f604fa780 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "auxv.h"
+#include "extract-store-integer.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "objfiles.h"
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 734494961696..660eb11c8b8e 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "frame.h"
@@ -30,7 +31,6 @@
 #include "block.h"
 #include "objfiles.h"
 #include "language.h"
-#include "gdbsupport/selftest.h"
 
 /* Basic byte-swapping routines.  All 'extract' functions return a
    host-format integer from a target-format integer at ADDR which is
@@ -44,151 +44,6 @@
 you lose
 #endif
 
-template<typename T, typename>
-T
-extract_integer (gdb::array_view<const gdb_byte> buf, enum bfd_endian byte_order)
-{
-  typename std::make_unsigned<T>::type retval = 0;
-
-  if (buf.size () > (int) sizeof (T))
-    error (_("\
-That operation is not available on integers of more than %d bytes."),
-	   (int) sizeof (T));
-
-  /* Start at the most significant end of the integer, and work towards
-     the least significant.  */
-  if (byte_order == BFD_ENDIAN_BIG)
-    {
-      size_t i = 0;
-
-      if (std::is_signed<T>::value)
-	{
-	  /* Do the sign extension once at the start.  */
-	  retval = ((LONGEST) buf[i] ^ 0x80) - 0x80;
-	  ++i;
-	}
-      for (; i < buf.size (); ++i)
-	retval = (retval << 8) | buf[i];
-    }
-  else
-    {
-      ssize_t i = buf.size () - 1;
-
-      if (std::is_signed<T>::value)
-	{
-	  /* Do the sign extension once at the start.  */
-	  retval = ((LONGEST) buf[i] ^ 0x80) - 0x80;
-	  --i;
-	}
-      for (; i >= 0; --i)
-	retval = (retval << 8) | buf[i];
-    }
-  return retval;
-}
-
-/* Explicit instantiations.  */
-template LONGEST extract_integer<LONGEST> (gdb::array_view<const gdb_byte> buf,
-					   enum bfd_endian byte_order);
-template ULONGEST extract_integer<ULONGEST>
-  (gdb::array_view<const gdb_byte> buf, enum bfd_endian byte_order);
-
-/* Treat the bytes at BUF as a pointer of type TYPE, and return the
-   address it represents.  */
-CORE_ADDR
-extract_typed_address (const gdb_byte *buf, struct type *type)
-{
-  gdb_assert (type->is_pointer_or_reference ());
-  return gdbarch_pointer_to_address (type->arch (), type, buf);
-}
-
-/* All 'store' functions accept a host-format integer and store a
-   target-format integer at ADDR which is LEN bytes long.  */
-template<typename T, typename>
-void
-store_integer (gdb::array_view<gdb_byte> dst, enum bfd_endian byte_order,
-	       T val)
-{
-  gdb_byte *p;
-  gdb_byte *startaddr = dst.data ();
-  gdb_byte *endaddr = startaddr + dst.size ();
-
-  /* Start at the least significant end of the integer, and work towards
-     the most significant.  */
-  if (byte_order == BFD_ENDIAN_BIG)
-    {
-      for (p = endaddr - 1; p >= startaddr; --p)
-	{
-	  *p = val & 0xff;
-	  val >>= 8;
-	}
-    }
-  else
-    {
-      for (p = startaddr; p < endaddr; ++p)
-	{
-	  *p = val & 0xff;
-	  val >>= 8;
-	}
-    }
-}
-
-/* Explicit instantiations.  */
-template void store_integer (gdb::array_view<gdb_byte> dst,
-			     bfd_endian byte_order, LONGEST val);
-
-template void store_integer (gdb::array_view<gdb_byte> dst,
-			     bfd_endian byte_order, ULONGEST val);
-
-/* Store the address ADDR as a pointer of type TYPE at BUF, in target
-   form.  */
-void
-store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr)
-{
-  gdb_assert (type->is_pointer_or_reference ());
-  gdbarch_address_to_pointer (type->arch (), type, buf, addr);
-}
-
-/* Copy a value from SOURCE of size SOURCE_SIZE bytes to DEST of size DEST_SIZE
-   bytes.  If SOURCE_SIZE is greater than DEST_SIZE, then truncate the most
-   significant bytes.  If SOURCE_SIZE is less than DEST_SIZE then either sign
-   or zero extended according to IS_SIGNED.  Values are stored in memory with
-   endianness BYTE_ORDER.  */
-
-void
-copy_integer_to_size (gdb_byte *dest, int dest_size, const gdb_byte *source,
-		      int source_size, bool is_signed,
-		      enum bfd_endian byte_order)
-{
-  signed int size_diff = dest_size - source_size;
-
-  /* Copy across everything from SOURCE that can fit into DEST.  */
-
-  if (byte_order == BFD_ENDIAN_BIG && size_diff > 0)
-    memcpy (dest + size_diff, source, source_size);
-  else if (byte_order == BFD_ENDIAN_BIG && size_diff < 0)
-    memcpy (dest, source - size_diff, dest_size);
-  else
-    memcpy (dest, source, std::min (source_size, dest_size));
-
-  /* Fill the remaining space in DEST by either zero extending or sign
-     extending.  */
-
-  if (size_diff > 0)
-    {
-      gdb_byte extension = 0;
-      if (is_signed
-	  && ((byte_order != BFD_ENDIAN_BIG && source[source_size - 1] & 0x80)
-	      || (byte_order == BFD_ENDIAN_BIG && source[0] & 0x80)))
-	extension = 0xff;
-
-      /* Extend into MSBs of SOURCE.  */
-      if (byte_order == BFD_ENDIAN_BIG)
-	memset (dest, extension, size_diff);
-      else
-	memset (dest + source_size, extension, size_diff);
-    }
-}
-
 /* See value.h.  */
 
 value *
@@ -800,95 +655,3 @@ address_from_register (int regnum, const frame_info_ptr &frame)
 
   return value_as_address (v.get ());
 }
-
-#if GDB_SELF_TEST
-namespace selftests {
-namespace findvar_tests {
-
-/* Function to test copy_integer_to_size.  Store SOURCE_VAL with size
-   SOURCE_SIZE to a buffer, making sure no sign extending happens at this
-   stage.  Copy buffer to a new buffer using copy_integer_to_size.  Extract
-   copied value and compare to DEST_VALU.  Copy again with a signed
-   copy_integer_to_size and compare to DEST_VALS.  Do everything for both
-   LITTLE and BIG target endians.  Use unsigned values throughout to make
-   sure there are no implicit sign extensions.  */
-
-static void
-do_cint_test (ULONGEST dest_valu, ULONGEST dest_vals, int dest_size,
-	      ULONGEST src_val, int src_size)
-{
-  for (int i = 0; i < 2 ; i++)
-    {
-      gdb_byte srcbuf[sizeof (ULONGEST)] = {};
-      gdb_byte destbuf[sizeof (ULONGEST)] = {};
-      enum bfd_endian byte_order = i ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
-
-      /* Fill the src buffer (and later the dest buffer) with non-zero junk,
-	 to ensure zero extensions aren't hidden.  */
-      memset (srcbuf, 0xaa, sizeof (srcbuf));
-
-      /* Store (and later extract) using unsigned to ensure there are no sign
-	 extensions.  */
-      store_unsigned_integer (srcbuf, src_size, byte_order, src_val);
-
-      /* Test unsigned.  */
-      memset (destbuf, 0xaa, sizeof (destbuf));
-      copy_integer_to_size (destbuf, dest_size, srcbuf, src_size, false,
-			    byte_order);
-      SELF_CHECK (dest_valu == extract_unsigned_integer (destbuf, dest_size,
-							 byte_order));
-
-      /* Test signed.  */
-      memset (destbuf, 0xaa, sizeof (destbuf));
-      copy_integer_to_size (destbuf, dest_size, srcbuf, src_size, true,
-			    byte_order);
-      SELF_CHECK (dest_vals == extract_unsigned_integer (destbuf, dest_size,
-							 byte_order));
-    }
-}
-
-static void
-copy_integer_to_size_test ()
-{
-  /* Destination is bigger than the source, which has the signed bit unset.  */
-  do_cint_test (0x12345678, 0x12345678, 8, 0x12345678, 4);
-  do_cint_test (0x345678, 0x345678, 8, 0x12345678, 3);
-
-  /* Destination is bigger than the source, which has the signed bit set.  */
-  do_cint_test (0xdeadbeef, 0xffffffffdeadbeef, 8, 0xdeadbeef, 4);
-  do_cint_test (0xadbeef, 0xffffffffffadbeef, 8, 0xdeadbeef, 3);
-
-  /* Destination is smaller than the source.  */
-  do_cint_test (0x5678, 0x5678, 2, 0x12345678, 3);
-  do_cint_test (0xbeef, 0xbeef, 2, 0xdeadbeef, 3);
-
-  /* Destination and source are the same size.  */
-  do_cint_test (0x8765432112345678, 0x8765432112345678, 8, 0x8765432112345678,
-		8);
-  do_cint_test (0x432112345678, 0x432112345678, 6, 0x8765432112345678, 6);
-  do_cint_test (0xfeedbeaddeadbeef, 0xfeedbeaddeadbeef, 8, 0xfeedbeaddeadbeef,
-		8);
-  do_cint_test (0xbeaddeadbeef, 0xbeaddeadbeef, 6, 0xfeedbeaddeadbeef, 6);
-
-  /* Destination is bigger than the source.  Source is bigger than 32bits.  */
-  do_cint_test (0x3412345678, 0x3412345678, 8, 0x3412345678, 6);
-  do_cint_test (0xff12345678, 0xff12345678, 8, 0xff12345678, 6);
-  do_cint_test (0x432112345678, 0x432112345678, 8, 0x8765432112345678, 6);
-  do_cint_test (0xff2112345678, 0xffffff2112345678, 8, 0xffffff2112345678, 6);
-}
-
-} // namespace findvar_test
-} // namespace selftests
-
-#endif
-
-void _initialize_findvar ();
-void
-_initialize_findvar ()
-{
-#if GDB_SELF_TEST
-  selftests::register_test
-    ("copy_integer_to_size",
-     selftests::findvar_tests::copy_integer_to_size_test);
-#endif
-}
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index a80421a9c5a8..e5f108d32573 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "dummy-frame.h"
diff --git a/gdb/frame.c b/gdb/frame.c
index f042bbb2ec25..719fa051afc6 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "frame.h"
+#include "extract-store-integer.h"
 #include "target.h"
 #include "value.h"
 #include "inferior.h"
diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c
index 0b13a81c0642..46424453ef01 100644
--- a/gdb/frv-linux-tdep.c
+++ b/gdb/frv-linux-tdep.c
@@ -18,6 +18,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 "extract-store-integer.h"
 #include "gdbcore.h"
 #include "target.h"
 #include "frame.h"
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index 5c026ebd53a3..1b5e15f831b7 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "arch-utils.h"
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index c5a48bebe5f2..8f7aa51b58a6 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 90f5b29dd8e9..1311a99ad8c2 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -18,6 +18,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 "extract-store-integer.h"
 #include "language.h"
 #include "value.h"
 #include "cp-abi.h"
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index 32907e29abff..e91d664ffa37 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -22,6 +22,7 @@
    sac@cygnus.com
  */
 
+#include "extract-store-integer.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 dacda88c5866..67fee6bb1c80 100644
--- a/gdb/hppa-bsd-tdep.c
+++ b/gdb/hppa-bsd-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "objfiles.h"
 #include "target.h"
 #include "value.h"
diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c
index 659c265bfb86..8f73f8d2374d 100644
--- a/gdb/hppa-linux-tdep.c
+++ b/gdb/hppa-linux-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "gdbcore.h"
 #include "osabi.h"
 #include "target.h"
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 8becfd5f9f9d..be8ea5798931 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -21,6 +21,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "bfd.h"
+#include "extract-store-integer.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "completer.h"
diff --git a/gdb/i386-bsd-tdep.c b/gdb/i386-bsd-tdep.c
index db00e18bccfe..ba7817a39b9e 100644
--- a/gdb/i386-bsd-tdep.c
+++ b/gdb/i386-bsd-tdep.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "regcache.h"
diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
index 5a5c8bffc210..0481296a46ba 100644
--- a/gdb/i386-darwin-tdep.c
+++ b/gdb/i386-darwin-tdep.c
@@ -18,6 +18,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 "extract-store-integer.h"
 #include "frame.h"
 #include "inferior.h"
 #include "gdbcore.h"
diff --git a/gdb/i386-gnu-tdep.c b/gdb/i386-gnu-tdep.c
index fb308215a7a9..98e11518a91b 100644
--- a/gdb/i386-gnu-tdep.c
+++ b/gdb/i386-gnu-tdep.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 "extract-store-integer.h"
 #include "gdbcore.h"
 #include "osabi.h"
 #include "solib-svr4.h"
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 44730f204db5..a78f03fac8d1 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "gdbcore.h"
 #include "frame.h"
 #include "value.h"
diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c
index 674d45feba99..6f3441597a2e 100644
--- a/gdb/i386-nto-tdep.c
+++ b/gdb/i386-nto-tdep.c
@@ -19,6 +19,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 "extract-store-integer.h"
 #include "frame.h"
 #include "osabi.h"
 #include "regcache.h"
diff --git a/gdb/i386-obsd-tdep.c b/gdb/i386-obsd-tdep.c
index 6e31567328eb..3539c6599a01 100644
--- a/gdb/i386-obsd-tdep.c
+++ b/gdb/i386-obsd-tdep.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 1b1efad6fa3e..4b1c60ee9246 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "opcode/i386.h"
 #include "arch-utils.h"
 #include "command.h"
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 00c9523ff258..45bd43a50a9b 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/ia64-linux-tdep.c b/gdb/ia64-linux-tdep.c
index 676fdb8edac7..12083e94ca37 100644
--- a/gdb/ia64-linux-tdep.c
+++ b/gdb/ia64-linux-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.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 f49a8d6b5586..6376cf8d0699 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "arch-utils.h"
diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
index b9d95bbc2675..5776c66f78ad 100644
--- a/gdb/iq2000-tdep.c
+++ b/gdb/iq2000-tdep.c
@@ -20,6 +20,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 "extract-store-integer.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/jit.c b/gdb/jit.c
index 3843b84b0e63..92cac0d342a5 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -19,6 +19,7 @@
 
 
 #include "jit.h"
+#include "extract-store-integer.h"
 #include "jit-reader.h"
 #include "block.h"
 #include "breakpoint.h"
diff --git a/gdb/linux-nat-trad.c b/gdb/linux-nat-trad.c
index d90d76fd9a03..b2c982d997e3 100644
--- a/gdb/linux-nat-trad.c
+++ b/gdb/linux-nat-trad.c
@@ -19,6 +19,7 @@
 
 #include "linux-nat-trad.h"
 
+#include "extract-store-integer.h"
 #include "nat/gdb_ptrace.h"
 #include "inf-ptrace.h"
 #include "gdbarch.h"
diff --git a/gdb/linux-record.c b/gdb/linux-record.c
index 6430c0e00884..549ea1bd713f 100644
--- a/gdb/linux-record.c
+++ b/gdb/linux-record.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "target.h"
 #include "gdbtypes.h"
 #include "regcache.h"
diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index 478f1edf3e64..98a072810510 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -18,6 +18,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 "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c
index a57dc31cde8a..715780603034 100644
--- a/gdb/loongarch-linux-tdep.c
+++ b/gdb/loongarch-linux-tdep.c
@@ -18,6 +18,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 "extract-store-integer.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 149fbd55db90..af0d6896143c 100644
--- a/gdb/loongarch-tdep.c
+++ b/gdb/loongarch-tdep.c
@@ -20,6 +20,7 @@
 #include "arch-utils.h"
 #include "dwarf2/frame.h"
 #include "elf-bfd.h"
+#include "extract-store-integer.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
 #include "loongarch-tdep.h"
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 33ec44349d76..d9890d0e4644 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "sim/sim-m32c.h"
 #include "gdbtypes.h"
 #include "regcache.h"
diff --git a/gdb/m32r-linux-tdep.c b/gdb/m32r-linux-tdep.c
index a28e11358402..8eea6620df9e 100644
--- a/gdb/m32r-linux-tdep.c
+++ b/gdb/m32r-linux-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "gdbcore.h"
 #include "frame.h"
 #include "value.h"
diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index 215df88b21c8..e2129409c19c 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.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 70b3f129d5aa..e117d8e29197 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -20,6 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/m68k-linux-tdep.c b/gdb/m68k-linux-tdep.c
index 4874db720db9..7250ce09826f 100644
--- a/gdb/m68k-linux-tdep.c
+++ b/gdb/m68k-linux-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "gdbcore.h"
 #include "frame.h"
 #include "target.h"
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index f73f58de90aa..1b8cc927e0c9 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "dwarf2/frame.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index fdb589134da0..7d87d6410086 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -19,6 +19,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 "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index ab788a202310..7f8a34ba18f1 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -20,6 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "target.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 1886c973bdc5..8d045c69c109 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -19,6 +19,7 @@
 
 #include "arch-utils.h"
 #include "dis-asm.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "trad-frame.h"
 #include "symtab.h"
diff --git a/gdb/mips-fbsd-tdep.c b/gdb/mips-fbsd-tdep.c
index 188ef4099da8..7452057e74bb 100644
--- a/gdb/mips-fbsd-tdep.c
+++ b/gdb/mips-fbsd-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "osabi.h"
 #include "regset.h"
 #include "trad-frame.h"
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index 79508f0fce75..7bd96a8e2007 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "gdbcore.h"
 #include "target.h"
 #include "solib-svr4.h"
diff --git a/gdb/mips-netbsd-tdep.c b/gdb/mips-netbsd-tdep.c
index 63068a18fe8e..b8134a671bfd 100644
--- a/gdb/mips-netbsd-tdep.c
+++ b/gdb/mips-netbsd-tdep.c
@@ -19,6 +19,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 "extract-store-integer.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "regset.h"
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index c34971c60c1b..0abac41e3f9e 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -20,6 +20,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 "extract-store-integer.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index cd70f8adb68d..d44eebfcb175 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -19,6 +19,7 @@
 
 #include "arch-utils.h"
 #include "dis-asm.h"
+#include "extract-store-integer.h"
 #include "gdbtypes.h"
 #include "regcache.h"
 #include "gdbcore.h"
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index a6b783e5c84c..3bfde1be6659 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.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 9d90a6e2784d..017ebb432d4b 100644
--- a/gdb/msp430-tdep.c
+++ b/gdb/msp430-tdep.c
@@ -21,6 +21,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "prologue-value.h"
 #include "target.h"
 #include "regcache.h"
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index bbbc80b37cd2..8ad51d0798bf 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -18,6 +18,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 "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
index da2616b436eb..956eb023eb9f 100644
--- a/gdb/nios2-tdep.c
+++ b/gdb/nios2-tdep.c
@@ -19,6 +19,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 "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index 937902b4f0a5..eeef52db4a16 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -21,6 +21,7 @@
 
 #include <sys/stat.h>
 #include "nto-tdep.h"
+#include "extract-store-integer.h"
 #include "top.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
index d4ac0ac1b9d1..db74b590f182 100644
--- a/gdb/or1k-tdep.c
+++ b/gdb/or1k-tdep.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 "extract-store-integer.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index adc6402084d7..ddacccce1b29 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -19,6 +19,7 @@
 
 /* This file is derived from c-lang.c */
 
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 7f6d7dc6e6bb..87c0c35cb997 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -19,6 +19,7 @@
 
 /* This file is derived from c-valprint.c */
 
+#include "extract-store-integer.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/ppc-fbsd-tdep.c b/gdb/ppc-fbsd-tdep.c
index 8f86607d5d19..3f0f93f1ac0e 100644
--- a/gdb/ppc-fbsd-tdep.c
+++ b/gdb/ppc-fbsd-tdep.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "frame-unwind.h"
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 2ed6e6e50685..c73c7c90b4cd 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.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 2da2d32eb262..e70eb2e8b66f 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/ppc-obsd-tdep.c b/gdb/ppc-obsd-tdep.c
index b50a24c6af79..1bd79b3b3e18 100644
--- a/gdb/ppc-obsd-tdep.c
+++ b/gdb/ppc-obsd-tdep.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbtypes.h"
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index 9d0e8a95a773..47e6292992e7 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -18,6 +18,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 "extract-store-integer.h"
 #include "language.h"
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c
index 8f91d06a085d..79bc4da71e20 100644
--- a/gdb/ppc64-tdep.c
+++ b/gdb/ppc64-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "infrun.h"
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index ae56b9d2fa91..79da7ea4e22e 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 77fdacfd61e1..d61340420e72 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -20,6 +20,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 "extract-store-integer.h"
 #include "inferior.h"
 #include "infrun.h"
 #include "target.h"
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index ecc9235c9174..55d54f4bdf13 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
 #include "ada-lang.h"
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 2e67cf5b4280..9d8c4ee438fd 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "gdbcmd.h"
 #include "regcache.h"
 #include "gdbthread.h"
diff --git a/gdb/regcache.c b/gdb/regcache.c
index c35a8138a39a..0e754ec54379 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "inferior.h"
 #include "gdbthread.h"
 #include "target.h"
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index eaa0d8f619a6..9615dedaebd5 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -19,6 +19,7 @@
 
 /* See the GDB User Guide for details of the GDB remote protocol.  */
 
+#include "extract-store-integer.h"
 #include "gdbcmd.h"
 #include "remote.h"
 #include "gdbsupport/gdb_wait.h"
diff --git a/gdb/riscv-fbsd-tdep.c b/gdb/riscv-fbsd-tdep.c
index 68f726743d9c..4761edc6667f 100644
--- a/gdb/riscv-fbsd-tdep.c
+++ b/gdb/riscv-fbsd-tdep.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 "extract-store-integer.h"
 #include "fbsd-tdep.h"
 #include "osabi.h"
 #include "riscv-tdep.h"
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index fe4da1a1f9d1..89091689f6e8 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "inferior.h"
 #include "symtab.h"
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index acd0731dd9f4..46a7ee9c3d4d 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -20,6 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "prologue-value.h"
 #include "target.h"
 #include "regcache.h"
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index 5111f4f55c0a..3faefe58cebd 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -19,6 +19,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 "extract-store-integer.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 550e06882031..17244b3c45a7 100644
--- a/gdb/rs6000-lynx178-tdep.c
+++ b/gdb/rs6000-lynx178-tdep.c
@@ -15,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "osabi.h"
 #include "regcache.h"
 #include "gdbcore.h"
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index b7ba0042bb73..e0698928dc85 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index 844e36023e04..6b12fe0a3148 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -20,6 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "prologue-value.h"
 #include "target.h"
 #include "regcache.h"
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index fa4aaf9aa9ae..6bb84b2ff696 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -19,6 +19,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 "extract-store-integer.h"
 #include "regcache.h"
 #include "inferior.h"
 #include "target.h"
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 519e3eb0a423..6687127d0aa4 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -23,6 +23,7 @@
 #include "dwarf2/frame.h"
 #include "elf/s390.h"
 #include "elf-bfd.h"
+#include "extract-store-integer.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
 #include "gdbarch.h"
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 1c67ea42b040..efbe15647679 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -20,6 +20,7 @@
 /* Contributed by Steve Chamberlain
    sac@cygnus.com.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 6943b2df5865..f0828fdf102d 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -19,6 +19,7 @@
 
 
 #include "bfd.h"
+#include "extract-store-integer.h"
 #include "objfiles.h"
 #include "gdbcore.h"
 #include "target.h"
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index 0208ed13effc..11225f72ed01 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -17,6 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
+#include "extract-store-integer.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "solib.h"
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index aef609378a42..39508fab4c83 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -17,6 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
+#include "extract-store-integer.h"
 #include "gdbcore.h"
 #include "solib.h"
 #include "solist.h"
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 49dd1e9aa330..1dd04c29c985 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -22,6 +22,7 @@
 #include "elf/common.h"
 #include "elf/mips.h"
 
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "bfd.h"
 #include "symfile.h"
diff --git a/gdb/solib.c b/gdb/solib.c
index 2f69c3372b0b..a656b623458b 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -19,6 +19,7 @@
 
 
 #include <fcntl.h>
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "bfd.h"
 #include "build-id.h"
diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c
index fac4c7d773db..2cf83ebd9067 100644
--- a/gdb/sparc-linux-tdep.c
+++ b/gdb/sparc-linux-tdep.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "dwarf2/frame.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbtypes.h"
diff --git a/gdb/sparc-obsd-tdep.c b/gdb/sparc-obsd-tdep.c
index d6166710709c..3182a7778d33 100644
--- a/gdb/sparc-obsd-tdep.c
+++ b/gdb/sparc-obsd-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index fbc27ffcb5e6..edbc03878dc2 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -21,6 +21,7 @@
 #include "dis-asm.h"
 #include "dwarf2.h"
 #include "dwarf2/frame.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c
index e91bba3aadba..de444659d9fa 100644
--- a/gdb/sparc64-linux-tdep.c
+++ b/gdb/sparc64-linux-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "dwarf2/frame.h"
diff --git a/gdb/sparc64-obsd-tdep.c b/gdb/sparc64-obsd-tdep.c
index 6caeb107b9f0..cef6efd33795 100644
--- a/gdb/sparc64-obsd-tdep.c
+++ b/gdb/sparc64-obsd-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index a55107fa32d9..9c8deaac0210 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -19,6 +19,7 @@
 
 #include "arch-utils.h"
 #include "dwarf2/frame.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/stack.c b/gdb/stack.c
index 9c679222708e..2922265515d5 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "value.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 0b66554efae1..8646f874dcc9 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "stap-probe.h"
+#include "extract-store-integer.h"
 #include "probe.h"
 #include "ui-out.h"
 #include "objfiles.h"
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 2a7d41dc9746..b7570a32dc0b 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -21,6 +21,7 @@
 
 #include "arch-utils.h"
 #include "bfdlink.h"
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
diff --git a/gdb/target.c b/gdb/target.c
index d9ff7d648252..091dc4cc8ac0 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -20,6 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "target.h"
+#include "extract-store-integer.h"
 #include "target-dcache.h"
 #include "gdbcmd.h"
 #include "symtab.h"
diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
index 3a63b0cc25db..ac6e291bacc2 100644
--- a/gdb/tic6x-tdep.c
+++ b/gdb/tic6x-tdep.c
@@ -19,6 +19,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 "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
index d5ea93cf5038..70a956139a3f 100644
--- a/gdb/tilegx-tdep.c
+++ b/gdb/tilegx-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index 79af963b049b..eb879c179700 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "tracefile.h"
 #include "readline/tilde.h"
 #include "gdbsupport/filestuff.h"
diff --git a/gdb/tracefile.c b/gdb/tracefile.c
index 9db68bbac510..2d89ab739ffc 100644
--- a/gdb/tracefile.c
+++ b/gdb/tracefile.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "tracefile.h"
+#include "extract-store-integer.h"
 #include "tracectf.h"
 #include "exec.h"
 #include "regcache.h"
diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c
index fc9261314784..e64374a67af6 100644
--- a/gdb/trad-frame.c
+++ b/gdb/trad-frame.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "trad-frame.h"
 #include "regcache.h"
diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c
index 4b397cbf046d..4f7c62d11fa0 100644
--- a/gdb/tramp-frame.c
+++ b/gdb/tramp-frame.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "tramp-frame.h"
+#include "extract-store-integer.h"
 #include "frame-unwind.h"
 #include "gdbcore.h"
 #include "symtab.h"
diff --git a/gdb/unittests/gmp-utils-selftests.c b/gdb/unittests/gmp-utils-selftests.c
index 3c6b71062a7b..f8f978179ead 100644
--- a/gdb/unittests/gmp-utils-selftests.c
+++ b/gdb/unittests/gmp-utils-selftests.c
@@ -19,6 +19,7 @@
 
 #include "gmp-utils.h"
 #include "gdbsupport/selftest.h"
+#include "extract-store-integer.h"
 
 #include <math.h>
 
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 6bda14f0fa15..531fdb48ab0b 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "trad-frame.h"
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 6b152cadcac9..7034fa6096b4 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "value.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/valops.c b/gdb/valops.c
index a17b937a9631..f9b54a5d9a93 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 40ffdbe6146f..13e80c06c9f7 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/value.c b/gdb/value.c
index 1bd180a62ccc..4df19fde3046 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "arch-utils.h"
+#include "extract-store-integer.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
index dd00898c298c..a42c872feff1 100644
--- a/gdb/vax-tdep.c
+++ b/gdb/vax-tdep.c
@@ -19,6 +19,7 @@
 
 #include "arch-utils.h"
 #include "dis-asm.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index f9585adf8fa3..af5ccd1a6297 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -16,6 +16,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "windows-tdep.h"
+#include "extract-store-integer.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "xml-support.h"
 #include "gdbarch.h"
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index 166e6af85275..a0f6c319b126 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 2c3d468d8be9..9dcd3ef06fa1 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -17,6 +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/>.  */
 
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "solib-svr4.h"
 #include "symtab.h"
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index ee8e36b18670..530139dbb61c 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -19,6 +19,7 @@
 
 #include "arch-utils.h"
 #include "dis-asm.h"
+#include "extract-store-integer.h"
 #include "frame.h"
 #include "frame-unwind.h"
 #include "frame-base.h"
-- 
2.44.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 5/7] gdb: move RequireLongest to gdbsupport/traits.h
  2024-04-22 20:10 [PATCH 0/7] First cleanup of defs.h Simon Marchi
                   ` (3 preceding siblings ...)
  2024-04-22 20:10 ` [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c,h} Simon Marchi
@ 2024-04-22 20:10 ` Simon Marchi
  2024-04-22 20:10 ` [PATCH 6/7] gdb: don't include hashtab.h in defs.h Simon Marchi
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Simon Marchi @ 2024-04-22 20:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Move it out of defs.h.

Change-Id: Ie1743d41a57f81667650048563e66073c72230cf
---
 gdb/defs.h                  | 4 ----
 gdb/extract-store-integer.h | 2 ++
 gdb/regcache.h              | 1 +
 gdbsupport/traits.h         | 4 ++++
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index 5da8ce728153..535ca6716732 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -63,10 +63,6 @@
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/array-view.h"
 
-template<typename T>
-using RequireLongest = gdb::Requires<gdb::Or<std::is_same<T, LONGEST>,
-					     std::is_same<T, ULONGEST>>>;
-
 /* Just in case they're not defined in stdio.h.  */
 
 #ifndef SEEK_SET
diff --git a/gdb/extract-store-integer.h b/gdb/extract-store-integer.h
index 1ba5f82da9a7..fd195dc64362 100644
--- a/gdb/extract-store-integer.h
+++ b/gdb/extract-store-integer.h
@@ -18,6 +18,8 @@
 #ifndef GDB_EXTRACT_STORE_INTEGER_H
 #define GDB_EXTRACT_STORE_INTEGER_H
 
+#include "gdbsupport/traits.h"
+
 template<typename T, typename = RequireLongest<T>>
 T extract_integer (gdb::array_view<const gdb_byte>, enum bfd_endian byte_order);
 
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 1d049fe7ae8d..2f4b7d94c693 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -23,6 +23,7 @@
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/common-regcache.h"
 #include "gdbsupport/function-view.h"
+#include "gdbsupport/traits.h"
 
 struct regcache;
 struct regset;
diff --git a/gdbsupport/traits.h b/gdbsupport/traits.h
index 92fe59f34af7..85cbc94bc6c9 100644
--- a/gdbsupport/traits.h
+++ b/gdbsupport/traits.h
@@ -143,4 +143,8 @@ template<typename Condition>
 using Requires = typename std::enable_if<Condition::value, void>::type;
 }
 
+template<typename T>
+using RequireLongest = gdb::Requires<gdb::Or<std::is_same<T, LONGEST>,
+					     std::is_same<T, ULONGEST>>>;
+
 #endif /* COMMON_TRAITS_H */
-- 
2.44.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 6/7] gdb: don't include hashtab.h in defs.h
  2024-04-22 20:10 [PATCH 0/7] First cleanup of defs.h Simon Marchi
                   ` (4 preceding siblings ...)
  2024-04-22 20:10 ` [PATCH 5/7] gdb: move RequireLongest to gdbsupport/traits.h Simon Marchi
@ 2024-04-22 20:10 ` Simon Marchi
  2024-04-22 20:10 ` [PATCH 7/7] gdb: don't include gdbsupport/array-view.h " Simon Marchi
  2024-04-22 22:55 ` [PATCH 0/7] First cleanup of defs.h John Baldwin
  7 siblings, 0 replies; 13+ messages in thread
From: Simon Marchi @ 2024-04-22 20:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Nothing in defs.h actually uses this.

Add some includes for some spots using things from hashtab.h.  Note that
if the GDB build doesn't use libxxhash, hashtab.h is included by
gdbsupport/common-utils.h, so all files still see hashtab.h.  It puzzled
me for some time why I didn't see build failures in my build (which
didn't use libxxhash) but the buildbot gave build failures (it uses
libxxhash).

Change-Id: I8efd68decdaf579f048941c7537cd689885caa2a
---
 gdb/defs.h                | 2 --
 gdb/dwarf2/die.h          | 1 +
 gdb/dwarf2/index-common.h | 1 +
 gdb/extension.h           | 1 +
 4 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index 535ca6716732..8ef36c16df97 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -82,8 +82,6 @@
 #define O_BINARY 0
 #endif
 
-#include "hashtab.h"
-
 /* * System root path, used to find libraries etc.  */
 extern std::string gdb_sysroot;
 
diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h
index a749b95ee28d..d4eab0838bfe 100644
--- a/gdb/dwarf2/die.h
+++ b/gdb/dwarf2/die.h
@@ -22,6 +22,7 @@
 
 #include "complaints.h"
 #include "dwarf2/attribute.h"
+#include "hashtab.h"
 
 /* This data structure holds a complete die structure.  */
 struct die_info
diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h
index 0a871a7e364a..339012949cd7 100644
--- a/gdb/dwarf2/index-common.h
+++ b/gdb/dwarf2/index-common.h
@@ -21,6 +21,7 @@
 #define DWARF_INDEX_COMMON_H
 
 #include "extract-store-integer.h"
+#include "hashtab.h"
 
 /* The suffix for an index file.  */
 #define INDEX4_SUFFIX ".gdb-index"
diff --git a/gdb/extension.h b/gdb/extension.h
index 5260bcbde003..9ba1299f95e1 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -22,6 +22,7 @@
 
 #include "mi/mi-cmds.h"
 #include "gdbsupport/array-view.h"
+#include "hashtab.h"
 #include <optional>
 
 struct breakpoint;
-- 
2.44.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 7/7] gdb: don't include gdbsupport/array-view.h in defs.h
  2024-04-22 20:10 [PATCH 0/7] First cleanup of defs.h Simon Marchi
                   ` (5 preceding siblings ...)
  2024-04-22 20:10 ` [PATCH 6/7] gdb: don't include hashtab.h in defs.h Simon Marchi
@ 2024-04-22 20:10 ` Simon Marchi
  2024-04-22 22:55 ` [PATCH 0/7] First cleanup of defs.h John Baldwin
  7 siblings, 0 replies; 13+ messages in thread
From: Simon Marchi @ 2024-04-22 20:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Nothing in defs.h actually uses this.  Everything that I (and the
buildbot) can compile still compiles, so I guess that all users of
array_view already include it one way or another.  Worst case, if this
causes some build failure, the fix will be one #include away.

Change-Id: I981be98b0653cc18c929d85e9afd8732332efd15
---
 gdb/defs.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index 8ef36c16df97..91724d30195f 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -61,7 +61,6 @@
 
 #include "gdbsupport/host-defs.h"
 #include "gdbsupport/enum-flags.h"
-#include "gdbsupport/array-view.h"
 
 /* Just in case they're not defined in stdio.h.  */
 
-- 
2.44.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/7] First cleanup of defs.h
  2024-04-22 20:10 [PATCH 0/7] First cleanup of defs.h Simon Marchi
                   ` (6 preceding siblings ...)
  2024-04-22 20:10 ` [PATCH 7/7] gdb: don't include gdbsupport/array-view.h " Simon Marchi
@ 2024-04-22 22:55 ` John Baldwin
  2024-04-23  1:38   ` Simon Marchi
  7 siblings, 1 reply; 13+ messages in thread
From: John Baldwin @ 2024-04-22 22:55 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 4/22/24 1:10 PM, Simon Marchi wrote:
> Here is a first batch of patches that remove things from defs.h, trying
> to sort them in more appropriate places.
> 
> Simon Marchi (7):
>    gdb: move two declarations out of defs.h
>    gdb: move `enum compile_i_scope_types` to compile/compile.h
>    gdb: remove extract_long_unsigned_integer
>    gdb: move store/extract integer functions to
>      extract-store-integer.{c,h}
>    gdb: move RequireLongest to gdbsupport/traits.h
>    gdb: don't include hashtab.h in defs.h
>    gdb: don't include gdbsupport/array-view.h in defs.h

These all look ok to me.

Approved-By: John Baldwin <jhb@FreeBSD.org>

-- 
John Baldwin


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/7] First cleanup of defs.h
  2024-04-22 22:55 ` [PATCH 0/7] First cleanup of defs.h John Baldwin
@ 2024-04-23  1:38   ` Simon Marchi
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Marchi @ 2024-04-23  1:38 UTC (permalink / raw)
  To: John Baldwin, Simon Marchi, gdb-patches



On 2024-04-22 18:55, John Baldwin wrote:
> On 4/22/24 1:10 PM, Simon Marchi wrote:
>> Here is a first batch of patches that remove things from defs.h, trying
>> to sort them in more appropriate places.
>>
>> Simon Marchi (7):
>>    gdb: move two declarations out of defs.h
>>    gdb: move `enum compile_i_scope_types` to compile/compile.h
>>    gdb: remove extract_long_unsigned_integer
>>    gdb: move store/extract integer functions to
>>      extract-store-integer.{c,h}
>>    gdb: move RequireLongest to gdbsupport/traits.h
>>    gdb: don't include hashtab.h in defs.h
>>    gdb: don't include gdbsupport/array-view.h in defs.h
> 
> These all look ok to me.
> 
> Approved-By: John Baldwin <jhb@FreeBSD.org>
> 

Thanks, pushed.

Simon

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c, h}
  2024-04-22 20:10 ` [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c,h} Simon Marchi
@ 2024-04-23 18:03   ` Pedro Alves
  2024-04-23 19:10     ` Simon Marchi
  0 siblings, 1 reply; 13+ messages in thread
From: Pedro Alves @ 2024-04-23 18:03 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 2024-04-22 21:10, Simon Marchi wrote:

> diff --git a/gdb/extract-store-integer.c b/gdb/extract-store-integer.c
> new file mode 100644
> index 000000000000..a3b7e40d6424
> --- /dev/null
> +++ b/gdb/extract-store-integer.c
> @@ -0,0 +1,308 @@
> +/* Copyright (C) 2024 Free Software Foundation, Inc.
> +

The code moved here isn't new.  (Copyright covers contents, not files.)


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c, h}
  2024-04-23 18:03   ` [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c, h} Pedro Alves
@ 2024-04-23 19:10     ` Simon Marchi
  2024-04-23 19:40       ` Pedro Alves
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Marchi @ 2024-04-23 19:10 UTC (permalink / raw)
  To: Pedro Alves, Simon Marchi, gdb-patches



On 2024-04-23 14:03, Pedro Alves wrote:
> On 2024-04-22 21:10, Simon Marchi wrote:
> 
>> diff --git a/gdb/extract-store-integer.c b/gdb/extract-store-integer.c
>> new file mode 100644
>> index 000000000000..a3b7e40d6424
>> --- /dev/null
>> +++ b/gdb/extract-store-integer.c
>> @@ -0,0 +1,308 @@
>> +/* Copyright (C) 2024 Free Software Foundation, Inc.
>> +
> 
> The code moved here isn't new.  (Copyright covers contents, not files.)
> 

How would you go about finding the correct start year?  I can just use
the same year as defs.h (1986-2024), but that may not be correct either
for that particular content.

Simon

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c, h}
  2024-04-23 19:10     ` Simon Marchi
@ 2024-04-23 19:40       ` Pedro Alves
  0 siblings, 0 replies; 13+ messages in thread
From: Pedro Alves @ 2024-04-23 19:40 UTC (permalink / raw)
  To: Simon Marchi, Simon Marchi, gdb-patches

On 2024-04-23 20:10, Simon Marchi wrote:
> 
> 
> On 2024-04-23 14:03, Pedro Alves wrote:
>> On 2024-04-22 21:10, Simon Marchi wrote:
>>
>>> diff --git a/gdb/extract-store-integer.c b/gdb/extract-store-integer.c
>>> new file mode 100644
>>> index 000000000000..a3b7e40d6424
>>> --- /dev/null
>>> +++ b/gdb/extract-store-integer.c
>>> @@ -0,0 +1,308 @@
>>> +/* Copyright (C) 2024 Free Software Foundation, Inc.
>>> +
>>
>> The code moved here isn't new.  (Copyright covers contents, not files.)
>>
> 
> How would you go about finding the correct start year?  I can just use
> the same year as defs.h (1986-2024), but that may not be correct either
> for that particular content.
> 

Preserving the original dates is the easiest.  Either that or some git blaming.
Grepping the old ChangeLog files will also often give you the right dates, if
there's a "(foo_function): New."


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-04-23 19:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-22 20:10 [PATCH 0/7] First cleanup of defs.h Simon Marchi
2024-04-22 20:10 ` [PATCH 1/7] gdb: move two declarations out " Simon Marchi
2024-04-22 20:10 ` [PATCH 2/7] gdb: move `enum compile_i_scope_types` to compile/compile.h Simon Marchi
2024-04-22 20:10 ` [PATCH 3/7] gdb: remove extract_long_unsigned_integer Simon Marchi
2024-04-22 20:10 ` [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c,h} Simon Marchi
2024-04-23 18:03   ` [PATCH 4/7] gdb: move store/extract integer functions to extract-store-integer.{c, h} Pedro Alves
2024-04-23 19:10     ` Simon Marchi
2024-04-23 19:40       ` Pedro Alves
2024-04-22 20:10 ` [PATCH 5/7] gdb: move RequireLongest to gdbsupport/traits.h Simon Marchi
2024-04-22 20:10 ` [PATCH 6/7] gdb: don't include hashtab.h in defs.h Simon Marchi
2024-04-22 20:10 ` [PATCH 7/7] gdb: don't include gdbsupport/array-view.h " Simon Marchi
2024-04-22 22:55 ` [PATCH 0/7] First cleanup of defs.h John Baldwin
2024-04-23  1:38   ` Simon Marchi

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).