From 6bd434d6caa4c08a5ea87fe327d802c1e00a5c5e Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Wed, 20 Jan 2021 20:55:05 -0500
Subject: [PATCH] gdb: make some variables static

I'm trying to enable clang's -Wmissing-variable-declarations warning.
This patch fixes all the obvious spots where we can simply add "static"
(at least, found when building on x86-64 Linux).

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_linux_record_tdep): Make static.
	* aarch64-tdep.c (tdesc_aarch64_list, aarch64_prologue_unwind,
	aarch64_stub_unwind, aarch64_normal_base, ): Make static.
	* arm-linux-tdep.c (arm_prologue_unwind): Make static.
	* arm-tdep.c (struct frame_unwind): Make static.
	* auto-load.c (auto_load_safe_path_vec): Make static.
	* csky-tdep.c (csky_stub_unwind): Make static.
	* gdbarch.c (gdbarch_data_registry): Make static.
	* gnu-v2-abi.c (gnu_v2_abi_ops): Make static.
	* i386-netbsd-tdep.c (i386nbsd_mc_reg_offset): Make static.
	* i386-tdep.c (i386_frame_setup_skip_insns,
	i386_tramp_chain_in_reg_insns, i386_tramp_chain_on_stack_insns):
	Make static.
	* infrun.c (observer_mode): Make static.
	* linux-nat.c (sigchld_action): Make static.
	* linux-thread-db.c (thread_db_list): Make static.
	* maint-test-options.c (maintenance_test_options_list):
	* mep-tdep.c (mep_csr_registers): Make static.
	* mi/mi-cmds.c (struct mi_cmd_stats): Remove struct type name.
	(stats): Make static.
	* nat/linux-osdata.c (struct osdata_type): Make static.
	* ppc-netbsd-tdep.c (ppcnbsd_reg_offsets): Make static.
	* progspace.c (last_program_space_num): Make static.
	* python/py-param.c (struct parm_constant): Remove struct type
	name.
	(parm_constants): Make static.
	* python/py-record-btrace.c (btpy_list_methods): Make static.
	* python/py-record.c (recpy_gap_type): Make static.
	* record.c (record_goto_cmdlist): Make static.
	* regcache.c (regcache_descr_handle): Make static.
	* registry.h (DEFINE_REGISTRY): Make definition static.
	* symmisc.c (std_in, std_out, std_err): Make static.
	* top.c (previous_saved_command_line): Make static.
	* tracepoint.c (trace_user, trace_notes, trace_stop_notes): Make
	static.
	* unittests/command-def-selftests.c (nr_duplicates,
	nr_invalid_prefixcmd, lists): Make static.
	* unittests/observable-selftests.c (test_notification): Make
	static.
	* unittests/optional/assignment/1.cc (counter): Make static.
	* unittests/optional/assignment/2.cc (counter): Make static.
	* unittests/optional/assignment/3.cc (counter): Make static.
	* unittests/optional/assignment/4.cc (counter): Make static.
	* unittests/optional/assignment/5.cc (counter): Make static.
	* unittests/optional/assignment/6.cc (counter): Make static.

gdbserver/ChangeLog:

	* ax.cc (bytecode_address_table): Make static.
	* debug.cc (debug_file): Make static.
	* linux-low.cc (stopping_threads): Make static.
	(step_over_bkpt): Make static.
	* linux-x86-low.cc (amd64_emit_ops, i386_emit_ops): Make static.
	* tracepoint.cc (stop_tracing_bkpt, flush_trace_buffer_bkpt,
	alloced_trace_state_variables, trace_buffer_ctrl,
	tracing_start_time, tracing_stop_time, tracing_user_name,
	tracing_notes, tracing_stop_note): Make static.

Change-Id: Ic1d8034723b7802502bda23770893be2338ab020
---
 gdb/ChangeLog                          | 48 ++++++++++++++++++++++++++
 gdb/aarch64-linux-tdep.c               |  2 +-
 gdb/aarch64-tdep.c                     |  8 ++---
 gdb/arm-linux-tdep.c                   |  2 +-
 gdb/arm-tdep.c                         |  2 +-
 gdb/auto-load.c                        |  2 +-
 gdb/csky-tdep.c                        |  2 +-
 gdb/gdbarch.c                          |  2 +-
 gdb/gnu-v2-abi.c                       |  2 +-
 gdb/i386-netbsd-tdep.c                 |  2 +-
 gdb/i386-tdep.c                        |  6 ++--
 gdb/infrun.c                           |  2 +-
 gdb/linux-nat.c                        |  2 +-
 gdb/linux-thread-db.c                  |  2 +-
 gdb/maint-test-options.c               |  2 +-
 gdb/mep-tdep.c                         |  2 +-
 gdb/mi/mi-cmds.c                       |  5 ++-
 gdb/nat/linux-osdata.c                 |  2 +-
 gdb/ppc-netbsd-tdep.c                  |  2 +-
 gdb/progspace.c                        |  2 +-
 gdb/python/py-param.c                  |  7 ++--
 gdb/python/py-record-btrace.c          |  2 +-
 gdb/python/py-record.c                 |  2 +-
 gdb/record.c                           |  2 +-
 gdb/regcache.c                         |  2 +-
 gdb/registry.h                         |  2 +-
 gdb/symmisc.c                          |  6 ++--
 gdb/top.c                              |  2 +-
 gdb/tracepoint.c                       |  6 ++--
 gdb/unittests/command-def-selftests.c  |  6 ++--
 gdb/unittests/observable-selftests.c   |  2 +-
 gdb/unittests/optional/assignment/1.cc |  2 +-
 gdb/unittests/optional/assignment/2.cc |  2 +-
 gdb/unittests/optional/assignment/3.cc |  2 +-
 gdb/unittests/optional/assignment/4.cc |  2 +-
 gdb/unittests/optional/assignment/5.cc |  2 +-
 gdb/unittests/optional/assignment/6.cc |  2 +-
 gdbserver/ChangeLog                    | 12 +++++++
 gdbserver/ax.cc                        |  2 +-
 gdbserver/debug.cc                     |  2 +-
 gdbserver/linux-low.cc                 |  4 +--
 gdbserver/linux-x86-low.cc             |  4 +--
 gdbserver/tracepoint.cc                | 18 +++++-----
 43 files changed, 124 insertions(+), 68 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4c686a95eda..a2759ef32b3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,51 @@
+2021-01-20  Simon Marchi  <simon.marchi@polymtl.ca>
+
+	* aarch64-linux-tdep.c (aarch64_linux_record_tdep): Make static.
+	* aarch64-tdep.c (tdesc_aarch64_list, aarch64_prologue_unwind,
+	aarch64_stub_unwind, aarch64_normal_base, ): Make static.
+	* arm-linux-tdep.c (arm_prologue_unwind): Make static.
+	* arm-tdep.c (struct frame_unwind): Make static.
+	* auto-load.c (auto_load_safe_path_vec): Make static.
+	* csky-tdep.c (csky_stub_unwind): Make static.
+	* gdbarch.c (gdbarch_data_registry): Make static.
+	* gnu-v2-abi.c (gnu_v2_abi_ops): Make static.
+	* i386-netbsd-tdep.c (i386nbsd_mc_reg_offset): Make static.
+	* i386-tdep.c (i386_frame_setup_skip_insns,
+	i386_tramp_chain_in_reg_insns, i386_tramp_chain_on_stack_insns):
+	Make static.
+	* infrun.c (observer_mode): Make static.
+	* linux-nat.c (sigchld_action): Make static.
+	* linux-thread-db.c (thread_db_list): Make static.
+	* maint-test-options.c (maintenance_test_options_list):
+	* mep-tdep.c (mep_csr_registers): Make static.
+	* mi/mi-cmds.c (struct mi_cmd_stats): Remove struct type name.
+	(stats): Make static.
+	* nat/linux-osdata.c (struct osdata_type): Make static.
+	* ppc-netbsd-tdep.c (ppcnbsd_reg_offsets): Make static.
+	* progspace.c (last_program_space_num): Make static.
+	* python/py-param.c (struct parm_constant): Remove struct type
+	name.
+	(parm_constants): Make static.
+	* python/py-record-btrace.c (btpy_list_methods): Make static.
+	* python/py-record.c (recpy_gap_type): Make static.
+	* record.c (record_goto_cmdlist): Make static.
+	* regcache.c (regcache_descr_handle): Make static.
+	* registry.h (DEFINE_REGISTRY): Make definition static.
+	* symmisc.c (std_in, std_out, std_err): Make static.
+	* top.c (previous_saved_command_line): Make static.
+	* tracepoint.c (trace_user, trace_notes, trace_stop_notes): Make
+	static.
+	* unittests/command-def-selftests.c (nr_duplicates,
+	nr_invalid_prefixcmd, lists): Make static.
+	* unittests/observable-selftests.c (test_notification): Make
+	static.
+	* unittests/optional/assignment/1.cc (counter): Make static.
+	* unittests/optional/assignment/2.cc (counter): Make static.
+	* unittests/optional/assignment/3.cc (counter): Make static.
+	* unittests/optional/assignment/4.cc (counter): Make static.
+	* unittests/optional/assignment/5.cc (counter): Make static.
+	* unittests/optional/assignment/6.cc (counter): Make static.
+
 2021-01-20  Joel Sherrill  <joel@rtems.org>
 
 	PR gdb/27219
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 954b05ca740..b1bbd55e5c3 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -849,7 +849,7 @@ aarch64_stap_parse_special_token (struct gdbarch *gdbarch,
 
 /* AArch64 process record-replay constructs: syscall, signal etc.  */
 
-struct linux_record_tdep aarch64_linux_record_tdep;
+static linux_record_tdep aarch64_linux_record_tdep;
 
 /* Enum that defines the AArch64 linux specific syscall identifiers used for
    process record/replay.  */
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 3e26a95a14c..d1e15497a46 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -58,7 +58,7 @@
 #define HA_MAX_NUM_FLDS		4
 
 /* All possible aarch64 target descriptors.  */
-struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/];
+static target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/];
 
 /* The standard register names, and all the valid aliases for them.  */
 static const struct
@@ -1109,7 +1109,7 @@ aarch64_prologue_prev_register (struct frame_info *this_frame,
 }
 
 /* AArch64 prologue unwinder.  */
-struct frame_unwind aarch64_prologue_unwind =
+static frame_unwind aarch64_prologue_unwind =
 {
   NORMAL_FRAME,
   aarch64_prologue_frame_unwind_stop_reason,
@@ -1203,7 +1203,7 @@ aarch64_stub_unwind_sniffer (const struct frame_unwind *self,
 }
 
 /* AArch64 stub unwinder.  */
-struct frame_unwind aarch64_stub_unwind =
+static frame_unwind aarch64_stub_unwind =
 {
   NORMAL_FRAME,
   aarch64_stub_frame_unwind_stop_reason,
@@ -1225,7 +1225,7 @@ aarch64_normal_frame_base (struct frame_info *this_frame, void **this_cache)
 }
 
 /* AArch64 default frame base information.  */
-struct frame_base aarch64_normal_base =
+static frame_base aarch64_normal_base =
 {
   &aarch64_prologue_unwind,
   aarch64_normal_frame_base,
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index ada7f113746..20cae5bdc91 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -1248,7 +1248,7 @@ arm_stap_parse_special_token (struct gdbarch *gdbarch,
 
 /* ARM process record-replay constructs: syscall, signal etc.  */
 
-struct linux_record_tdep arm_linux_record_tdep;
+static linux_record_tdep arm_linux_record_tdep;
 
 /* arm_canonicalize_syscall maps from the native arm Linux set
    of syscall ids into a canonical set of syscall ids used by
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 0184c252f10..7916c974ac0 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -2024,7 +2024,7 @@ arm_prologue_prev_register (struct frame_info *this_frame,
 				       prev_regnum);
 }
 
-struct frame_unwind arm_prologue_unwind = {
+static frame_unwind arm_prologue_unwind = {
   NORMAL_FRAME,
   arm_prologue_unwind_stop_reason,
   arm_prologue_this_id,
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index b9acb8f8609..522f43b704c 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -170,7 +170,7 @@ static char *auto_load_safe_path;
 /* Vector of directory elements of AUTO_LOAD_SAFE_PATH with each one normalized
    by tilde_expand and possibly each entries has added its gdb_realpath
    counterpart.  */
-std::vector<gdb::unique_xmalloc_ptr<char>> auto_load_safe_path_vec;
+static std::vector<gdb::unique_xmalloc_ptr<char>> auto_load_safe_path_vec;
 
 /* Expand $datadir and $debugdir in STRING according to the rules of
    substitute_path_component.  */
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index 3ec18a2cf90..609b684265f 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -1998,7 +1998,7 @@ csky_stub_prev_register (struct frame_info *this_frame,
 				       prev_regnum);
 }
 
-struct frame_unwind csky_stub_unwind = {
+static frame_unwind csky_stub_unwind = {
   NORMAL_FRAME,
   default_frame_unwind_stop_reason,
   csky_stub_this_id,
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 4bdf4068504..43d1c154a7f 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -5314,7 +5314,7 @@ struct gdbarch_data_registry
   struct gdbarch_data_registration *registrations;
 };
 
-struct gdbarch_data_registry gdbarch_data_registry =
+static struct gdbarch_data_registry gdbarch_data_registry =
 {
   0, NULL,
 };
diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
index 45b8bb642a8..466ae6c0802 100644
--- a/gdb/gnu-v2-abi.c
+++ b/gdb/gnu-v2-abi.c
@@ -29,7 +29,7 @@
 #include "cp-support.h"
 #include <ctype.h>
 
-struct cp_abi_ops gnu_v2_abi_ops;
+static cp_abi_ops gnu_v2_abi_ops;
 
 static int vb_match (struct type *, int, struct type *);
 
diff --git a/gdb/i386-netbsd-tdep.c b/gdb/i386-netbsd-tdep.c
index 873bbe9a357..76dcc4db150 100644
--- a/gdb/i386-netbsd-tdep.c
+++ b/gdb/i386-netbsd-tdep.c
@@ -76,7 +76,7 @@ static int i386nbsd_sc_reg_offset[] =
 };
 
 /* From <machine/mcontext.h>.  */
-int i386nbsd_mc_reg_offset[] =
+static int i386nbsd_mc_reg_offset[] =
 {
   11 * 4,			/* %eax */
   10 * 4,			/* %ecx */
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 991218de4c4..6386716c3b8 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -1467,7 +1467,7 @@ i386_match_insn_block (CORE_ADDR pc, struct i386_insn *insn_patterns)
    yet, and only the scratch registers %eax, %ecx and %edx can be
    touched.  */
 
-struct i386_insn i386_frame_setup_skip_insns[] =
+static i386_insn i386_frame_setup_skip_insns[] =
 {
   /* Check for `movb imm8, r' and `movl imm32, r'.
     
@@ -2333,7 +2333,7 @@ static const struct frame_unwind i386_epilogue_frame_unwind =
 
 /* Static chain passed in register.  */
 
-struct i386_insn i386_tramp_chain_in_reg_insns[] =
+static i386_insn i386_tramp_chain_in_reg_insns[] =
 {
   /* `movl imm32, %eax' and `movl imm32, %ecx' */
   { 5, { 0xb8 }, { 0xfe } },
@@ -2346,7 +2346,7 @@ struct i386_insn i386_tramp_chain_in_reg_insns[] =
 
 /* Static chain passed on stack (when regparm=3).  */
 
-struct i386_insn i386_tramp_chain_on_stack_insns[] =
+static i386_insn i386_tramp_chain_on_stack_insns[] =
 {
   /* `push imm32' */
   { 5, { 0x68 }, { 0xff } },
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 940f575e22a..3f143971707 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -221,7 +221,7 @@ show_non_stop (struct ui_file *file, int from_tty,
    non-stop, in which all GDB operations that might affect the
    target's execution have been disabled.  */
 
-bool observer_mode = false;
+static bool observer_mode = false;
 static bool observer_mode_1 = false;
 
 static void
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index dc524cf10dc..3c7117bff6e 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -757,7 +757,7 @@ static sigset_t suspend_mask;
 static sigset_t blocked_mask;
 
 /* SIGCHLD action.  */
-struct sigaction sigchld_action;
+static struct sigaction sigchld_action;
 
 /* Block child signals (SIGCHLD and linux threads signals), and store
    the previous mask in PREV_MASK.  */
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 2ce31dc0270..0a32e40f4d5 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -209,7 +209,7 @@ struct thread_db_info
 
 /* List of known processes using thread_db, and the required
    bookkeeping.  */
-struct thread_db_info *thread_db_list;
+static thread_db_info *thread_db_list;
 
 static void thread_db_find_new_threads_1 (thread_info *stopped);
 static void thread_db_find_new_threads_2 (thread_info *stopped,
diff --git a/gdb/maint-test-options.c b/gdb/maint-test-options.c
index 9483f560dea..16ecd1dd7e5 100644
--- a/gdb/maint-test-options.c
+++ b/gdb/maint-test-options.c
@@ -409,7 +409,7 @@ maintenance_test_options_unknown_is_operand_command_completer
 }
 
 /* Command list for maint test-options.  */
-struct cmd_list_element *maintenance_test_options_list;
+static cmd_list_element *maintenance_test_options_list;
 
 
 void _initialize_maint_test_options ();
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index eaa713f5e44..0dcfa48d67c 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -661,7 +661,7 @@ struct mep_csr_register
    We just list the register numbers here explicitly to help catch
    typos.  */
 #define CSR(name) MEP_RAW_ ## name ## _REGNUM, MEP_ ## name ## _REGNUM
-struct mep_csr_register mep_csr_registers[] = {
+static mep_csr_register mep_csr_registers[] = {
   { CSR(PC),    0xffffffff },   /* manual says r/o, but we can write it */
   { CSR(LP),    0xffffffff },
   { CSR(SAR),   0x0000003f },
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 93a826235c3..df4290ae5dc 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -220,13 +220,12 @@ mi_lookup (const char *command)
 
 /* Used for collecting hash hit/miss statistics.  */
 
-struct mi_cmd_stats
+static struct
 {
   int hit;
   int miss;
   int rehash;
-};
-struct mi_cmd_stats stats;
+} stats;
 
 /* Look up a command.  */
 
diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
index ce436c15935..7034dd82376 100644
--- a/gdb/nat/linux-osdata.c
+++ b/gdb/nat/linux-osdata.c
@@ -1284,7 +1284,7 @@ linux_xfer_osdata_modules (struct buffer *buffer)
 
 static void linux_xfer_osdata_info_os_types (struct buffer *buffer);
 
-struct osdata_type {
+static struct osdata_type {
   const char *type;
   const char *title;
   const char *description;
diff --git a/gdb/ppc-netbsd-tdep.c b/gdb/ppc-netbsd-tdep.c
index 1230014b113..31f11993889 100644
--- a/gdb/ppc-netbsd-tdep.c
+++ b/gdb/ppc-netbsd-tdep.c
@@ -33,7 +33,7 @@
 #include "solib-svr4.h"
 
 /* Register offsets from <machine/reg.h>.  */
-struct ppc_reg_offsets ppcnbsd_reg_offsets;
+static ppc_reg_offsets ppcnbsd_reg_offsets;
 
 
 /* Core file support.  */
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 86839701252..ebbc784dcfb 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -29,7 +29,7 @@
 #include <algorithm>
 
 /* The last program space number assigned.  */
-int last_program_space_num = 0;
+static int last_program_space_num = 0;
 
 /* The head of the program spaces list.  */
 std::vector<struct program_space *> program_spaces;
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index d37fd301e96..49819ce4f10 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -29,13 +29,10 @@
 #include "arch-utils.h"
 
 /* Parameter constants and their values.  */
-struct parm_constant
-{
+static struct {
   const char *name;
   int value;
-};
-
-struct parm_constant parm_constants[] =
+} parm_constants[] =
 {
   { "PARAM_BOOLEAN", var_boolean }, /* ARI: var_boolean */
   { "PARAM_AUTO_BOOLEAN", var_auto_boolean },
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index d5a3da91d19..1c10a0598da 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -808,7 +808,7 @@ recpy_bt_goto (PyObject *self, PyObject *args)
 
 /* BtraceList methods.  */
 
-struct PyMethodDef btpy_list_methods[] =
+static PyMethodDef btpy_list_methods[] =
 {
   { "count", btpy_list_count, METH_O, "count number of occurrences"},
   { "index", btpy_list_index, METH_O, "index of entry"},
diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c
index ddfb5d8fdac..1747f74d7e6 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -45,7 +45,7 @@ PyTypeObject recpy_func_type = {
 
 /* Python RecordGap type.  */
 
-PyTypeObject recpy_gap_type = {
+static PyTypeObject recpy_gap_type = {
   PyVarObject_HEAD_INIT (NULL, 0)
 };
 
diff --git a/gdb/record.c b/gdb/record.c
index 9e19261f460..cd541b56f43 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -48,7 +48,7 @@ static unsigned int record_call_history_size = 10;
 static unsigned int record_call_history_size_setshow_var;
 
 struct cmd_list_element *record_cmdlist = NULL;
-struct cmd_list_element *record_goto_cmdlist = NULL;
+static struct cmd_list_element *record_goto_cmdlist = NULL;
 struct cmd_list_element *set_record_cmdlist = NULL;
 struct cmd_list_element *show_record_cmdlist = NULL;
 struct cmd_list_element *info_record_cmdlist = NULL;
diff --git a/gdb/regcache.c b/gdb/regcache.c
index a0407c74ee9..27c0ae5ae23 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -41,7 +41,7 @@
 /* Per-architecture object describing the layout of a register cache.
    Computed once when the architecture is created.  */
 
-struct gdbarch_data *regcache_descr_handle;
+static struct gdbarch_data *regcache_descr_handle;
 
 struct regcache_descr
 {
diff --git a/gdb/registry.h b/gdb/registry.h
index 972ebf33c94..7b0b284c7ae 100644
--- a/gdb/registry.h
+++ b/gdb/registry.h
@@ -154,7 +154,7 @@ void *registry_data (struct registry_fields *fields,
 /* Define a new registry implementation.  */
 
 #define DEFINE_REGISTRY(TAG, ACCESS)					\
-struct registry_data_registry TAG ## _data_registry = { NULL, 0 };	\
+static struct registry_data_registry TAG ## _data_registry = { NULL, 0 }; \
 									\
 const struct TAG ## _data *						\
 register_ ## TAG ## _data_with_cleanup (void (*save) (struct TAG *, void *), \
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 07631e11c5c..a8f8856f721 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -47,9 +47,9 @@
    debugging GDB with itself.  Because stdin et al need not be constants,
    we initialize them in the _initialize_symmisc function at the bottom
    of the file.  */
-FILE *std_in;
-FILE *std_out;
-FILE *std_err;
+static FILE *std_in;
+static FILE *std_out;
+static FILE *std_err;
 
 /* Prototypes for local functions */
 
diff --git a/gdb/top.c b/gdb/top.c
index 2c13864e120..4b0defd58fc 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -161,7 +161,7 @@ static const char *repeat_arguments;
    command.  We need this as when a command is running, saved_command_line
    already contains the line of the currently executing command.  */
 
-char *previous_saved_command_line;
+static char *previous_saved_command_line;
 
 /* If not NULL, the arguments that should be passed if the
    previous_saved_command_line is repeated.  */
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 17d70a6a8d4..0cbd2c68224 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -145,15 +145,15 @@ static int trace_buffer_size = -1;
 
 /* Textual notes applying to the current and/or future trace runs.  */
 
-char *trace_user = NULL;
+static char *trace_user = NULL;
 
 /* Textual notes applying to the current and/or future trace runs.  */
 
-char *trace_notes = NULL;
+static char *trace_notes = NULL;
 
 /* Textual notes applying to the stopping of a trace.  */
 
-char *trace_stop_notes = NULL;
+static char *trace_stop_notes = NULL;
 
 /* support routines */
 
diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c
index 7b0cb2dad10..e6aadf3124f 100644
--- a/gdb/unittests/command-def-selftests.c
+++ b/gdb/unittests/command-def-selftests.c
@@ -107,13 +107,13 @@ help_doc_invariants_tests ()
 namespace command_structure_tests {
 
 /* Nr of commands in which a duplicated list is found.  */
-unsigned int nr_duplicates = 0;
+static unsigned int nr_duplicates = 0;
 /* Nr of commands in a list having no valid prefix cmd.  */
-unsigned int nr_invalid_prefixcmd = 0;
+static unsigned int nr_invalid_prefixcmd = 0;
 
 /* A map associating a list with the prefix leading to it.  */
 
-std::map<cmd_list_element **, const char *> lists;
+static std::map<cmd_list_element **, const char *> lists;
 
 /* Store each command list in lists, associated with the prefix to reach it.  A
    list must only be found once.
diff --git a/gdb/unittests/observable-selftests.c b/gdb/unittests/observable-selftests.c
index 1b22e86e3a9..e19eaf81024 100644
--- a/gdb/unittests/observable-selftests.c
+++ b/gdb/unittests/observable-selftests.c
@@ -24,7 +24,7 @@
 namespace selftests {
 namespace observers {
 
-gdb::observers::observable<int> test_notification ("test_notification");
+static gdb::observers::observable<int> test_notification ("test_notification");
 
 static int test_first_observer = 0;
 static int test_second_observer = 0;
diff --git a/gdb/unittests/optional/assignment/1.cc b/gdb/unittests/optional/assignment/1.cc
index f711c4d9c17..80eaa24a2ab 100644
--- a/gdb/unittests/optional/assignment/1.cc
+++ b/gdb/unittests/optional/assignment/1.cc
@@ -19,7 +19,7 @@ namespace assign_1 {
 
 struct exception {};
 
-int counter = 0;
+static int counter = 0;
 
 struct mixin_counter
 {
diff --git a/gdb/unittests/optional/assignment/2.cc b/gdb/unittests/optional/assignment/2.cc
index fdc07f1e952..85c41c55513 100644
--- a/gdb/unittests/optional/assignment/2.cc
+++ b/gdb/unittests/optional/assignment/2.cc
@@ -19,7 +19,7 @@ namespace assign_2 {
 
 struct exception {};
 
-int counter = 0;
+static int counter = 0;
 
 struct mixin_counter
 {
diff --git a/gdb/unittests/optional/assignment/3.cc b/gdb/unittests/optional/assignment/3.cc
index e479f9c8a87..03f6018c218 100644
--- a/gdb/unittests/optional/assignment/3.cc
+++ b/gdb/unittests/optional/assignment/3.cc
@@ -19,7 +19,7 @@ namespace assign_3 {
 
 struct exception {};
 
-int counter = 0;
+static int counter = 0;
 
 struct mixin_counter
 {
diff --git a/gdb/unittests/optional/assignment/4.cc b/gdb/unittests/optional/assignment/4.cc
index 2bfe5620385..aa04292f975 100644
--- a/gdb/unittests/optional/assignment/4.cc
+++ b/gdb/unittests/optional/assignment/4.cc
@@ -19,7 +19,7 @@ namespace assign_4 {
 
 struct exception {};
 
-int counter = 0;
+static int counter = 0;
 
 struct mixin_counter
 {
diff --git a/gdb/unittests/optional/assignment/5.cc b/gdb/unittests/optional/assignment/5.cc
index 4112e9f2dcf..8c27e7b6f22 100644
--- a/gdb/unittests/optional/assignment/5.cc
+++ b/gdb/unittests/optional/assignment/5.cc
@@ -17,7 +17,7 @@
 
 namespace assign_5 {
 
-int counter = 0;
+static int counter = 0;
 
 struct mixin_counter
 {
diff --git a/gdb/unittests/optional/assignment/6.cc b/gdb/unittests/optional/assignment/6.cc
index 423b3e79a89..da01fd5d924 100644
--- a/gdb/unittests/optional/assignment/6.cc
+++ b/gdb/unittests/optional/assignment/6.cc
@@ -17,7 +17,7 @@
 
 namespace assign_6 {
 
-int counter = 0;
+static int counter = 0;
 
 struct mixin_counter
 {
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog
index 7231d9a47b4..2f883e05b5c 100644
--- a/gdbserver/ChangeLog
+++ b/gdbserver/ChangeLog
@@ -1,3 +1,15 @@
+2021-01-20  Simon Marchi  <simon.marchi@polymtl.ca>
+
+	* ax.cc (bytecode_address_table): Make static.
+	* debug.cc (debug_file): Make static.
+	* linux-low.cc (stopping_threads): Make static.
+	(step_over_bkpt): Make static.
+	* linux-x86-low.cc (amd64_emit_ops, i386_emit_ops): Make static.
+	* tracepoint.cc (stop_tracing_bkpt, flush_trace_buffer_bkpt,
+	alloced_trace_state_variables, trace_buffer_ctrl,
+	tracing_start_time, tracing_stop_time, tracing_user_name,
+	tracing_notes, tracing_stop_note): Make static.
+
 2021-01-20  Tom de Vries  <tdevries@suse.de>
 
 	* linux-x86-low.cc (collect_register_i386): New function.
diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc
index 9a968c598e0..a217a3d3dad 100644
--- a/gdbserver/ax.cc
+++ b/gdbserver/ax.cc
@@ -146,7 +146,7 @@ CORE_ADDR current_insn_ptr;
 
 int emit_error;
 
-struct bytecode_address
+static struct bytecode_address
 {
   int pc;
   CORE_ADDR address;
diff --git a/gdbserver/debug.cc b/gdbserver/debug.cc
index b3a5fe1b15c..12f6db0316f 100644
--- a/gdbserver/debug.cc
+++ b/gdbserver/debug.cc
@@ -24,7 +24,7 @@ int remote_debug = 0;
 #endif
 
 /* Output file for debugging.  Default to standard error.  */
-FILE *debug_file = stderr;
+static FILE *debug_file = stderr;
 
 /* See debug.h.  */
 int debug_threads;
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 4b43d171d2d..d167914d63e 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -253,7 +253,7 @@ enum stopping_threads_kind
   };
 
 /* This is set while stop_all_lwps is in effect.  */
-enum stopping_threads_kind stopping_threads = NOT_STOPPING_THREADS;
+static stopping_threads_kind stopping_threads = NOT_STOPPING_THREADS;
 
 /* FIXME make into a target method?  */
 int using_threads = 1;
@@ -272,7 +272,7 @@ static int check_ptrace_stopped_lwp_gone (struct lwp_info *lp);
 
 /* When the event-loop is doing a step-over, this points at the thread
    being stepped.  */
-ptid_t step_over_bkpt;
+static ptid_t step_over_bkpt;
 
 bool
 linux_process_target::low_supports_breakpoints ()
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index d3273a18f47..58ca4bab295 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -2219,7 +2219,7 @@ amd64_emit_ge_goto (int *offset_p, int *size_p)
     *size_p = 4;
 }
 
-struct emit_ops amd64_emit_ops =
+static emit_ops amd64_emit_ops =
   {
     amd64_emit_prologue,
     amd64_emit_epilogue,
@@ -2888,7 +2888,7 @@ i386_emit_ge_goto (int *offset_p, int *size_p)
     *size_p = 4;
 }
 
-struct emit_ops i386_emit_ops =
+static emit_ops i386_emit_ops =
   {
     i386_emit_prologue,
     i386_emit_epilogue,
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 5c5dac0c04e..bc8fb267e90 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -402,11 +402,11 @@ tracepoint_handler (CORE_ADDR address)
 }
 
 /* Breakpoint at "stop_tracing" in the inferior lib.  */
-struct breakpoint *stop_tracing_bkpt;
+static struct breakpoint *stop_tracing_bkpt;
 static int stop_tracing_handler (CORE_ADDR);
 
 /* Breakpoint at "flush_trace_buffer" in the inferior lib.  */
-struct breakpoint *flush_trace_buffer_bkpt;
+static struct breakpoint *flush_trace_buffer_bkpt;
 static int flush_trace_buffer_handler (CORE_ADDR);
 
 static void download_trace_state_variables (void);
@@ -912,7 +912,7 @@ struct trace_state_variable
 /* Linked list of all trace state variables.  */
 
 #ifdef IN_PROCESS_AGENT
-struct trace_state_variable *alloced_trace_state_variables;
+static struct trace_state_variable *alloced_trace_state_variables;
 #endif
 
 IP_AGENT_EXPORT_VAR struct trace_state_variable *trace_state_variables;
@@ -1170,7 +1170,7 @@ IP_AGENT_EXPORT_VAR unsigned int trace_buffer_ctrl_curr;
    it doesn't need to sync with itself.  Define it as array anyway so
    that the rest of the code base doesn't need to care for the
    difference.  */
-struct trace_buffer_control trace_buffer_ctrl[1];
+static trace_buffer_control trace_buffer_ctrl[1];
 # define TRACE_BUFFER_CTRL_CURR 0
 #endif
 
@@ -1264,23 +1264,23 @@ static int tracing_stop_tpnum;
 /* 64-bit timestamps for the trace run's start and finish, expressed
    in microseconds from the Unix epoch.  */
 
-LONGEST tracing_start_time;
-LONGEST tracing_stop_time;
+static LONGEST tracing_start_time;
+static LONGEST tracing_stop_time;
 
 /* The (optional) user-supplied name of the user that started the run.
    This is an arbitrary string, and may be NULL.  */
 
-char *tracing_user_name;
+static char *tracing_user_name;
 
 /* Optional user-supplied text describing the run.  This is
    an arbitrary string, and may be NULL.  */
 
-char *tracing_notes;
+static char *tracing_notes;
 
 /* Optional user-supplied text explaining a tstop command.  This is an
    arbitrary string, and may be NULL.  */
 
-char *tracing_stop_note;
+static char *tracing_stop_note;
 
 #endif
 
-- 
GitLab