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
This commit is contained in:
Simon Marchi 2021-01-20 20:55:05 -05:00
parent a6c11cbb14
commit 6bd434d6ca
43 changed files with 124 additions and 68 deletions

View File

@ -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

View File

@ -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. */

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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. */

View File

@ -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,

View File

@ -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,
};

View File

@ -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 *);

View File

@ -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 */

View File

@ -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 } },

View File

@ -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

View File

@ -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. */

View File

@ -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,

View File

@ -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 ();

View File

@ -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 },

View File

@ -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. */

View File

@ -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;

View File

@ -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. */

View File

@ -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;

View File

@ -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 },

View File

@ -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"},

View File

@ -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)
};

View File

@ -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;

View File

@ -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
{

View File

@ -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 *), \

View File

@ -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 */

View File

@ -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. */

View File

@ -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 */

View File

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

View File

@ -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;

View File

@ -19,7 +19,7 @@ namespace assign_1 {
struct exception {};
int counter = 0;
static int counter = 0;
struct mixin_counter
{

View File

@ -19,7 +19,7 @@ namespace assign_2 {
struct exception {};
int counter = 0;
static int counter = 0;
struct mixin_counter
{

View File

@ -19,7 +19,7 @@ namespace assign_3 {
struct exception {};
int counter = 0;
static int counter = 0;
struct mixin_counter
{

View File

@ -19,7 +19,7 @@ namespace assign_4 {
struct exception {};
int counter = 0;
static int counter = 0;
struct mixin_counter
{

View File

@ -17,7 +17,7 @@
namespace assign_5 {
int counter = 0;
static int counter = 0;
struct mixin_counter
{

View File

@ -17,7 +17,7 @@
namespace assign_6 {
int counter = 0;
static int counter = 0;
struct mixin_counter
{

View File

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

View File

@ -146,7 +146,7 @@ CORE_ADDR current_insn_ptr;
int emit_error;
struct bytecode_address
static struct bytecode_address
{
int pc;
CORE_ADDR address;

View File

@ -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;

View File

@ -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 ()

View File

@ -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,

View File

@ -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