From: Tom Tromey Date: Mon, 14 Sep 2020 18:09:59 +0000 (-0600) Subject: Apply 'const' in more places X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=27087b7f6ce8c6d304b149df2484436d97e6334b;p=binutils-gdb.git Apply 'const' in more places Many global arrays in gdb could be marked "const" but are not. This patch changes some of them. (There may be other arrays that could benefit from this treatment. I only examined arrays of strings.) This lets the linker move some symbols to the readonly data section. For example, previously: 0000000000000000 d _ZL18can_use_agent_enum is now: 0000000000000030 r _ZL18can_use_agent_enum 2020-09-14 Tom Tromey * x86-tdep.h (x86_in_indirect_branch_thunk): Update. * x86-tdep.c (x86_is_thunk_register_name) (x86_in_indirect_branch_thunk): Update. * sparc64-tdep.c (sparc64_fpu_register_names) (sparc64_cp0_register_names, sparc64_register_names) (sparc64_pseudo_register_names): Now const. * sparc-tdep.h (struct gdbarch_tdep) : Now const. * sparc-tdep.c (sparc_core_register_names) (sparc32_fpu_register_names, sparc32_cp0_register_names) (sparc32_pseudo_register_names): Now const. (validate_tdesc_registers): Update. * rust-lang.c (rust_extensions): Now const. * p-lang.c (p_extensions): Now const. * objc-lang.c (objc_extensions): Now const. * nto-tdep.c (nto_thread_state_str): Now const. * moxie-tdep.c (moxie_register_names): Now const. * mips-tdep.h (struct gdbarch_tdep) : Now const. * mips-tdep.c (mips_generic_reg_names, mips_tx39_reg_names) (mips_linux_reg_names): Now const. (mips_gdbarch_init): Update. * microblaze-tdep.c (microblaze_register_names): Now const. * m68k-tdep.c (m68k_register_names): Now const. * m32r-tdep.c (m32r_register_names): Now const. * ia64-tdep.c (ia64_register_names): Now const. * i386-tdep.h (struct gdbarch_tdep) : Now const. * i386-tdep.c (i386_register_names, i386_zmm_names) (i386_zmmh_names, i386_k_names, i386_ymm_names, i386_ymmh_names) (i386_mpx_names, i386_pkeys_names, i386_bnd_names) (i386_mmx_names, i386_byte_names, i386_word_names): Now const. * f-lang.c (f_extensions): Now const. * d-lang.c (d_extensions): Now const. * csky-tdep.c (csky_register_names): Now const. * charset.c (default_charset_names, charset_enum): Now const. (_initialize_charset): Update. * c-lang.c (c_extensions, cplus_extensions, asm_extensions): Now const. * bsd-uthread.c (bsd_uthread_solib_names): Now const. (bsd_uthread_solib_loaded): Update. (bsd_uthread_state): Now const. * amd64-tdep.c (amd64_register_names, amd64_ymm_names) (amd64_ymm_avx512_names, amd64_ymmh_names) (amd64_ymmh_avx512_names, amd64_mpx_names, amd64_k_names) (amd64_zmmh_names, amd64_zmm_names, amd64_xmm_avx512_names) (amd64_pkeys_names, amd64_byte_names, amd64_word_names) (amd64_dword_names): Now const. * agent.c (can_use_agent_enum): Now const. * ada-tasks.c (task_states, long_task_states): Now const. * ada-lang.c (known_runtime_file_name_patterns) (known_auxiliary_function_name_patterns, attribute_names) (standard_exc, ada_extensions): Now const. gdbserver/ChangeLog 2020-09-14 Tom Tromey * tracepoint.cc (eval_result_names): Now const. * ax.cc (gdb_agent_op_names): Now const. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0ca89098a04..771a9d52010 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,61 @@ +2020-09-14 Tom Tromey + + * x86-tdep.h (x86_in_indirect_branch_thunk): Update. + * x86-tdep.c (x86_is_thunk_register_name) + (x86_in_indirect_branch_thunk): Update. + * sparc64-tdep.c (sparc64_fpu_register_names) + (sparc64_cp0_register_names, sparc64_register_names) + (sparc64_pseudo_register_names): Now const. + * sparc-tdep.h (struct gdbarch_tdep) : Now const. + * sparc-tdep.c (sparc_core_register_names) + (sparc32_fpu_register_names, sparc32_cp0_register_names) + (sparc32_pseudo_register_names): Now const. + (validate_tdesc_registers): Update. + * rust-lang.c (rust_extensions): Now const. + * p-lang.c (p_extensions): Now const. + * objc-lang.c (objc_extensions): Now const. + * nto-tdep.c (nto_thread_state_str): Now const. + * moxie-tdep.c (moxie_register_names): Now const. + * mips-tdep.h (struct gdbarch_tdep) : + Now const. + * mips-tdep.c (mips_generic_reg_names, mips_tx39_reg_names) + (mips_linux_reg_names): Now const. + (mips_gdbarch_init): Update. + * microblaze-tdep.c (microblaze_register_names): Now const. + * m68k-tdep.c (m68k_register_names): Now const. + * m32r-tdep.c (m32r_register_names): Now const. + * ia64-tdep.c (ia64_register_names): Now const. + * i386-tdep.h (struct gdbarch_tdep) : Now const. + * i386-tdep.c (i386_register_names, i386_zmm_names) + (i386_zmmh_names, i386_k_names, i386_ymm_names, i386_ymmh_names) + (i386_mpx_names, i386_pkeys_names, i386_bnd_names) + (i386_mmx_names, i386_byte_names, i386_word_names): Now const. + * f-lang.c (f_extensions): Now const. + * d-lang.c (d_extensions): Now const. + * csky-tdep.c (csky_register_names): Now const. + * charset.c (default_charset_names, charset_enum): Now const. + (_initialize_charset): Update. + * c-lang.c (c_extensions, cplus_extensions, asm_extensions): Now + const. + * bsd-uthread.c (bsd_uthread_solib_names): Now const. + (bsd_uthread_solib_loaded): Update. + (bsd_uthread_state): Now const. + * amd64-tdep.c (amd64_register_names, amd64_ymm_names) + (amd64_ymm_avx512_names, amd64_ymmh_names) + (amd64_ymmh_avx512_names, amd64_mpx_names, amd64_k_names) + (amd64_zmmh_names, amd64_zmm_names, amd64_xmm_avx512_names) + (amd64_pkeys_names, amd64_byte_names, amd64_word_names) + (amd64_dword_names): Now const. + * agent.c (can_use_agent_enum): Now const. + * ada-tasks.c (task_states, long_task_states): Now const. + * ada-lang.c (known_runtime_file_name_patterns) + (known_auxiliary_function_name_patterns, attribute_names) + (standard_exc, ada_extensions): Now const. + 2020-09-14 Simon Marchi * bcache.h (struct bcache) : Remove constructor. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a2280d6b322..5f0e68ea892 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -315,11 +315,11 @@ static int warning_limit = 2; expression evaluation. */ static int warnings_issued = 0; -static const char *known_runtime_file_name_patterns[] = { +static const char * const known_runtime_file_name_patterns[] = { ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS NULL }; -static const char *known_auxiliary_function_name_patterns[] = { +static const char * const known_auxiliary_function_name_patterns[] = { ADA_KNOWN_AUXILIARY_FUNCTION_NAME_PATTERNS NULL }; @@ -8828,7 +8828,7 @@ ada_to_fixed_value (struct value *val) /* Table mapping attribute numbers to names. NOTE: Keep up to date with enum ada_attribute definition in ada-lang.h. */ -static const char *attribute_names[] = { +static const char * const attribute_names[] = { "", "first", @@ -11503,7 +11503,7 @@ ada_modulus (struct type *type) an Ada83 compiler). As such, we do not include Numeric_Error from this list of standard exceptions. */ -static const char *standard_exc[] = { +static const char * const standard_exc[] = { "constraint_error", "program_error", "storage_error", @@ -13704,7 +13704,7 @@ ada_get_symbol_name_matcher (const lookup_name_info &lookup_name) } } -static const char *ada_extensions[] = +static const char * const ada_extensions[] = { ".adb", ".ads", ".a", ".ada", ".dg", NULL }; diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index d54c8b320a4..734b25034f4 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -64,7 +64,7 @@ enum task_states }; /* A short description corresponding to each possible task state. */ -static const char *task_states[] = { +static const char * const task_states[] = { N_("Unactivated"), N_("Runnable"), N_("Terminated"), @@ -86,7 +86,7 @@ static const char *task_states[] = { }; /* A longer description corresponding to each possible task state. */ -static const char *long_task_states[] = { +static const char * const long_task_states[] = { N_("Unactivated"), N_("Runnable"), N_("Terminated"), diff --git a/gdb/agent.c b/gdb/agent.c index 77ece234996..895e75efb7d 100644 --- a/gdb/agent.c +++ b/gdb/agent.c @@ -27,7 +27,7 @@ static const char can_use_agent_on[] = "on"; static const char can_use_agent_off[] = "off"; -static const char *can_use_agent_enum[] = +static const char * const can_use_agent_enum[] = { can_use_agent_on, can_use_agent_off, diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 59f7c9f885f..e801f83ddbc 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -59,7 +59,7 @@ /* Register information. */ -static const char *amd64_register_names[] = +static const char * const amd64_register_names[] = { "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "rsp", @@ -77,7 +77,7 @@ static const char *amd64_register_names[] = "mxcsr", }; -static const char *amd64_ymm_names[] = +static const char * const amd64_ymm_names[] = { "ymm0", "ymm1", "ymm2", "ymm3", "ymm4", "ymm5", "ymm6", "ymm7", @@ -85,7 +85,7 @@ static const char *amd64_ymm_names[] = "ymm12", "ymm13", "ymm14", "ymm15" }; -static const char *amd64_ymm_avx512_names[] = +static const char * const amd64_ymm_avx512_names[] = { "ymm16", "ymm17", "ymm18", "ymm19", "ymm20", "ymm21", "ymm22", "ymm23", @@ -93,7 +93,7 @@ static const char *amd64_ymm_avx512_names[] = "ymm28", "ymm29", "ymm30", "ymm31" }; -static const char *amd64_ymmh_names[] = +static const char * const amd64_ymmh_names[] = { "ymm0h", "ymm1h", "ymm2h", "ymm3h", "ymm4h", "ymm5h", "ymm6h", "ymm7h", @@ -101,7 +101,7 @@ static const char *amd64_ymmh_names[] = "ymm12h", "ymm13h", "ymm14h", "ymm15h" }; -static const char *amd64_ymmh_avx512_names[] = +static const char * const amd64_ymmh_avx512_names[] = { "ymm16h", "ymm17h", "ymm18h", "ymm19h", "ymm20h", "ymm21h", "ymm22h", "ymm23h", @@ -109,18 +109,18 @@ static const char *amd64_ymmh_avx512_names[] = "ymm28h", "ymm29h", "ymm30h", "ymm31h" }; -static const char *amd64_mpx_names[] = +static const char * const amd64_mpx_names[] = { "bnd0raw", "bnd1raw", "bnd2raw", "bnd3raw", "bndcfgu", "bndstatus" }; -static const char *amd64_k_names[] = +static const char * const amd64_k_names[] = { "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" }; -static const char *amd64_zmmh_names[] = +static const char * const amd64_zmmh_names[] = { "zmm0h", "zmm1h", "zmm2h", "zmm3h", "zmm4h", "zmm5h", "zmm6h", "zmm7h", @@ -132,7 +132,7 @@ static const char *amd64_zmmh_names[] = "zmm28h", "zmm29h", "zmm30h", "zmm31h" }; -static const char *amd64_zmm_names[] = +static const char * const amd64_zmm_names[] = { "zmm0", "zmm1", "zmm2", "zmm3", "zmm4", "zmm5", "zmm6", "zmm7", @@ -144,14 +144,14 @@ static const char *amd64_zmm_names[] = "zmm28", "zmm29", "zmm30", "zmm31" }; -static const char *amd64_xmm_avx512_names[] = { +static const char * const amd64_xmm_avx512_names[] = { "xmm16", "xmm17", "xmm18", "xmm19", "xmm20", "xmm21", "xmm22", "xmm23", "xmm24", "xmm25", "xmm26", "xmm27", "xmm28", "xmm29", "xmm30", "xmm31" }; -static const char *amd64_pkeys_names[] = { +static const char * const amd64_pkeys_names[] = { "pkru" }; @@ -298,7 +298,7 @@ amd64_arch_reg_to_regnum (int reg) /* Register names for byte pseudo-registers. */ -static const char *amd64_byte_names[] = +static const char * const amd64_byte_names[] = { "al", "bl", "cl", "dl", "sil", "dil", "bpl", "spl", "r8l", "r9l", "r10l", "r11l", "r12l", "r13l", "r14l", "r15l", @@ -310,7 +310,7 @@ static const char *amd64_byte_names[] = /* Register names for word pseudo-registers. */ -static const char *amd64_word_names[] = +static const char * const amd64_word_names[] = { "ax", "bx", "cx", "dx", "si", "di", "bp", "", "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w" @@ -318,7 +318,7 @@ static const char *amd64_word_names[] = /* Register names for dword pseudo-registers. */ -static const char *amd64_dword_names[] = +static const char * const amd64_dword_names[] = { "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp", "esp", "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d", diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 15d538c16db..11ce0f439bf 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -269,7 +269,7 @@ bsd_uthread_inferior_created (struct target_ops *ops, int from_tty) } /* Likely candidates for the threads library. */ -static const char *bsd_uthread_solib_names[] = +static const char * const bsd_uthread_solib_names[] = { "/usr/lib/libc_r.so", /* FreeBSD */ "/usr/lib/libpthread.so", /* OpenBSD */ @@ -279,7 +279,7 @@ static const char *bsd_uthread_solib_names[] = static void bsd_uthread_solib_loaded (struct so_list *so) { - const char **names = bsd_uthread_solib_names; + const char * const *names = bsd_uthread_solib_names; for (names = bsd_uthread_solib_names; *names; names++) { @@ -488,7 +488,7 @@ bsd_uthread_target::update_thread_list () } /* Possible states a thread can be in. */ -static const char *bsd_uthread_state[] = +static const char * const bsd_uthread_state[] = { "RUNNING", "SIGTHREAD", diff --git a/gdb/c-lang.c b/gdb/c-lang.c index f29f2cef610..03628704349 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -871,7 +871,7 @@ const struct exp_descriptor exp_descriptor_c = evaluate_subexp_c }; -static const char *c_extensions[] = +static const char * const c_extensions[] = { ".c", NULL }; @@ -972,7 +972,7 @@ enum cplus_primitive_types { nr_cplus_primitive_types }; -static const char *cplus_extensions[] = +static const char * const cplus_extensions[] = { ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++", NULL }; @@ -1170,7 +1170,7 @@ protected: static cplus_language cplus_language_defn; -static const char *asm_extensions[] = +static const char * const asm_extensions[] = { ".s", ".sx", ".S", NULL }; diff --git a/gdb/charset.c b/gdb/charset.c index 4e459c2b45d..a72eb03bc00 100644 --- a/gdb/charset.c +++ b/gdb/charset.c @@ -271,13 +271,13 @@ show_target_wide_charset_name (struct ui_file *file, value); } -static const char *default_charset_names[] = +static const char * const default_charset_names[] = { DEFAULT_CHARSET_NAMES 0 }; -static const char **charset_enum; +static const char * const *charset_enum; /* If the target wide character set has big- or little-endian @@ -1004,7 +1004,7 @@ _initialize_charset () find_charset_names (); if (charsets.charsets.size () > 1) - charset_enum = (const char **) charsets.charsets.data (); + charset_enum = (const char * const *) charsets.charsets.data (); else charset_enum = default_charset_names; diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index c9245fc4ac7..f2015a40ac3 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -162,7 +162,7 @@ csky_write_pc (regcache *regcache, CORE_ADDR val) /* C-Sky ABI register names. */ -static const char *csky_register_names[] = +static const char * const csky_register_names[] = { /* General registers 0 - 31. */ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 4ebb011ee9b..837a0646003 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -124,7 +124,7 @@ enum d_primitive_types { nr_d_primitive_types }; -static const char *d_extensions[] = +static const char * const d_extensions[] = { ".d", NULL }; diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 54d56f0d781..49f7b0368e2 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -471,7 +471,7 @@ operator_check_f (struct expression *exp, int pos, return 0; } -static const char *f_extensions[] = +static const char * const f_extensions[] = { ".f", ".F", ".for", ".FOR", ".ftn", ".FTN", ".fpp", ".FPP", ".f90", ".F90", ".f95", ".F95", ".f03", ".F03", ".f08", ".F08", diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 64e42dcbfe6..14e5b310a2a 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -69,7 +69,7 @@ /* Register names. */ -static const char *i386_register_names[] = +static const char * const i386_register_names[] = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", @@ -84,56 +84,56 @@ static const char *i386_register_names[] = "mxcsr" }; -static const char *i386_zmm_names[] = +static const char * const i386_zmm_names[] = { "zmm0", "zmm1", "zmm2", "zmm3", "zmm4", "zmm5", "zmm6", "zmm7" }; -static const char *i386_zmmh_names[] = +static const char * const i386_zmmh_names[] = { "zmm0h", "zmm1h", "zmm2h", "zmm3h", "zmm4h", "zmm5h", "zmm6h", "zmm7h" }; -static const char *i386_k_names[] = +static const char * const i386_k_names[] = { "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" }; -static const char *i386_ymm_names[] = +static const char * const i386_ymm_names[] = { "ymm0", "ymm1", "ymm2", "ymm3", "ymm4", "ymm5", "ymm6", "ymm7", }; -static const char *i386_ymmh_names[] = +static const char * const i386_ymmh_names[] = { "ymm0h", "ymm1h", "ymm2h", "ymm3h", "ymm4h", "ymm5h", "ymm6h", "ymm7h", }; -static const char *i386_mpx_names[] = +static const char * const i386_mpx_names[] = { "bnd0raw", "bnd1raw", "bnd2raw", "bnd3raw", "bndcfgu", "bndstatus" }; -static const char* i386_pkeys_names[] = +static const char * const i386_pkeys_names[] = { "pkru" }; /* Register names for MPX pseudo-registers. */ -static const char *i386_bnd_names[] = +static const char * const i386_bnd_names[] = { "bnd0", "bnd1", "bnd2", "bnd3" }; /* Register names for MMX pseudo-registers. */ -static const char *i386_mmx_names[] = +static const char * const i386_mmx_names[] = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" @@ -141,7 +141,7 @@ static const char *i386_mmx_names[] = /* Register names for byte pseudo-registers. */ -static const char *i386_byte_names[] = +static const char * const i386_byte_names[] = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" @@ -149,7 +149,7 @@ static const char *i386_byte_names[] = /* Register names for word pseudo-registers. */ -static const char *i386_word_names[] = +static const char * const i386_word_names[] = { "ax", "cx", "dx", "bx", "", "bp", "si", "di" diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index 79b3b1f9428..c61ffcfb76e 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -145,21 +145,21 @@ struct gdbarch_tdep int xsave_xcr0_offset; /* Register names. */ - const char **register_names; + const char * const *register_names; /* Register number for %ymm0h. Set this to -1 to indicate the absence of upper YMM register support. */ int ymm0h_regnum; /* Upper YMM register names. Only used for tdesc_numbered_register. */ - const char **ymmh_register_names; + const char * const *ymmh_register_names; /* Register number for %ymm16h. Set this to -1 to indicate the absence of support for YMM16-31. */ int ymm16h_regnum; /* YMM16-31 register names. Only used for tdesc_numbered_register. */ - const char **ymm16h_register_names; + const char * const *ymm16h_register_names; /* Register number for %bnd0r. Set this to -1 to indicate the absence bound registers. */ @@ -174,23 +174,23 @@ struct gdbarch_tdep int bndcfgu_regnum; /* MPX register names. Only used for tdesc_numbered_register. */ - const char **mpx_register_names; + const char * const *mpx_register_names; /* Register number for %zmm0h. Set this to -1 to indicate the absence of ZMM_HI256 register support. */ int zmm0h_regnum; /* OpMask register names. */ - const char **k_register_names; + const char * const *k_register_names; /* ZMM register names. Only used for tdesc_numbered_register. */ - const char **zmmh_register_names; + const char * const *zmmh_register_names; /* XMM16-31 register names. Only used for tdesc_numbered_register. */ - const char **xmm_avx512_register_names; + const char * const *xmm_avx512_register_names; /* YMM16-31 register names. Only used for tdesc_numbered_register. */ - const char **ymm_avx512_register_names; + const char * const *ymm_avx512_register_names; /* Number of PKEYS registers. */ int num_pkeys_regs; @@ -199,7 +199,7 @@ struct gdbarch_tdep int pkru_regnum; /* PKEYS register names. */ - const char **pkeys_register_names; + const char * const *pkeys_register_names; /* Register number for %fsbase. Set this to -1 to indicate the absence of segment base registers. */ diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 6abf8336954..72093b643ea 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -144,7 +144,7 @@ enum pseudo_regs { FIRST_PSEUDO_REGNUM = NUM_IA64_RAW_REGS, /* Array of register names; There should be ia64_num_regs strings in the initializer. */ -static const char *ia64_register_names[] = +static const char * const ia64_register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index 011a0d2a9c3..e8bf33dda17 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -202,7 +202,7 @@ m32r_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) } } -static const char *m32r_register_names[] = { +static const char * const m32r_register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "fp", "lr", "sp", "psw", "cbr", "spi", "spu", "bpc", "pc", "accl", "acch", diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 7685c5da1bb..76046c0b1dd 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -157,7 +157,7 @@ m68k_register_type (struct gdbarch *gdbarch, int regnum) return builtin_type (gdbarch)->builtin_int32; } -static const char *m68k_register_names[] = { +static const char * const m68k_register_names[] = { "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", "ps", "pc", diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c index 5c804133040..edabe9eb543 100644 --- a/gdb/microblaze-tdep.c +++ b/gdb/microblaze-tdep.c @@ -65,7 +65,7 @@ /* The registers of the Xilinx microblaze processor. */ -static const char *microblaze_register_names[] = +static const char * const microblaze_register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 9e2a9cba529..48ee82228d9 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -578,7 +578,7 @@ enum /* Generic MIPS. */ -static const char *mips_generic_reg_names[NUM_MIPS_PROCESSOR_REGS] = { +static const char * const mips_generic_reg_names[NUM_MIPS_PROCESSOR_REGS] = { "sr", "lo", "hi", "bad", "cause", "pc", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", @@ -589,7 +589,7 @@ static const char *mips_generic_reg_names[NUM_MIPS_PROCESSOR_REGS] = { /* Names of tx39 registers. */ -static const char *mips_tx39_reg_names[NUM_MIPS_PROCESSOR_REGS] = { +static const char * const mips_tx39_reg_names[NUM_MIPS_PROCESSOR_REGS] = { "sr", "lo", "hi", "bad", "cause", "pc", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", @@ -601,7 +601,7 @@ static const char *mips_tx39_reg_names[NUM_MIPS_PROCESSOR_REGS] = { }; /* Names of registers with Linux kernels. */ -static const char *mips_linux_reg_names[NUM_MIPS_PROCESSOR_REGS] = { +static const char * const mips_linux_reg_names[NUM_MIPS_PROCESSOR_REGS] = { "sr", "lo", "hi", "bad", "cause", "pc", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", @@ -8049,7 +8049,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) enum mips_fpu_type fpu_type; struct tdesc_arch_data *tdesc_data = NULL; int elf_fpu_type = Val_GNU_MIPS_ABI_FP_ANY; - const char **reg_names; + const char * const *reg_names; struct mips_regnum mips_regnum, *regnum; enum mips_isa mips_isa; int dspacc; diff --git a/gdb/mips-tdep.h b/gdb/mips-tdep.h index 99546201395..513466820aa 100644 --- a/gdb/mips-tdep.h +++ b/gdb/mips-tdep.h @@ -104,7 +104,7 @@ struct gdbarch_tdep add any that do not need to be public. */ const struct mips_regnum *regnum; /* Register names table for the current register set. */ - const char **mips_processor_reg_names; + const char * const *mips_processor_reg_names; /* The size of register data available from the target, if known. This doesn't quite obsolete the manual diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c index 1f552481662..e5d3c52190b 100644 --- a/gdb/moxie-tdep.c +++ b/gdb/moxie-tdep.c @@ -70,7 +70,7 @@ typedef BP_MANIPULATION (moxie_break_insn) moxie_breakpoint; /* Moxie register names. */ -static const char *moxie_register_names[] = { +static const char * const moxie_register_names[] = { "$fp", "$sp", "$r0", "$r1", "$r2", "$r3", "$r4", "$r5", "$r6", "$r7", "$r8", "$r9", "$r10", "$r11", "$r12", diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c index a16cc8df87a..e1b776415bb 100644 --- a/gdb/nto-tdep.c +++ b/gdb/nto-tdep.c @@ -355,7 +355,7 @@ nto_elf_osabi_sniffer (bfd *abfd) return osabi; } -static const char *nto_thread_state_str[] = +static const char * const nto_thread_state_str[] = { "DEAD", /* 0 0x00 */ "RUNNING", /* 1 0x01 */ diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 63cdac1b035..4e1d2cdcf2d 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -319,7 +319,7 @@ static const struct op_print objc_op_print_tab[] = {NULL, OP_NULL, PREC_NULL, 0} }; -static const char *objc_extensions[] = +static const char * const objc_extensions[] = { ".m", NULL }; diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 07afbdda5bb..18490843a99 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -248,7 +248,7 @@ enum pascal_primitive_types { nr_pascal_primitive_types }; -static const char *p_extensions[] = +static const char * const p_extensions[] = { ".pas", ".p", ".pp", NULL }; diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index b8ab59bd207..0bc65eb15bc 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1902,7 +1902,7 @@ static const struct exp_descriptor exp_descriptor_rust = rust_evaluate_subexp }; -static const char *rust_extensions[] = +static const char * const rust_extensions[] = { ".rs", NULL }; diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 681b8009008..e3401fe33ee 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -363,11 +363,17 @@ sparc_arg_by_memory_p (const struct type *type) #define SPARC32_CP0_REGISTERS \ "y", "psr", "wim", "tbr", "pc", "npc", "fsr", "csr" -static const char *sparc_core_register_names[] = { SPARC_CORE_REGISTERS }; -static const char *sparc32_fpu_register_names[] = { SPARC32_FPU_REGISTERS }; -static const char *sparc32_cp0_register_names[] = { SPARC32_CP0_REGISTERS }; +static const char * const sparc_core_register_names[] = { + SPARC_CORE_REGISTERS +}; +static const char * const sparc32_fpu_register_names[] = { + SPARC32_FPU_REGISTERS +}; +static const char * const sparc32_cp0_register_names[] = { + SPARC32_CP0_REGISTERS +}; -static const char *sparc32_register_names[] = +static const char * const sparc32_register_names[] = { SPARC_CORE_REGISTERS, SPARC32_FPU_REGISTERS, @@ -380,7 +386,7 @@ static const char *sparc32_register_names[] = /* We provide the aliases %d0..%d30 for the floating registers as "psuedo" registers. */ -static const char *sparc32_pseudo_register_names[] = +static const char * const sparc32_pseudo_register_names[] = { "d0", "d2", "d4", "d6", "d8", "d10", "d12", "d14", "d16", "d18", "d20", "d22", "d24", "d26", "d28", "d30" @@ -1784,7 +1790,7 @@ static int validate_tdesc_registers (const struct target_desc *tdesc, struct tdesc_arch_data *tdesc_data, const char *feature_name, - const char *register_names[], + const char * const register_names[], unsigned int registers_num, unsigned int reg_start) { diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h index 625b3e8914a..594f47a4038 100644 --- a/gdb/sparc-tdep.h +++ b/gdb/sparc-tdep.h @@ -64,9 +64,9 @@ struct gdbarch_tdep int npc_regnum; /* Register names specific for architecture (sparc32 vs. sparc64) */ - const char **fpu_register_names; + const char * const *fpu_register_names; size_t fpu_registers_num; - const char **cp0_register_names; + const char * const *cp0_register_names; size_t cp0_registers_num; /* Register sets. */ diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 95979ab76f5..372df041905 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -764,10 +764,14 @@ sparc64_fprs_type (struct gdbarch *gdbarch) "fprs", \ "y" -static const char *sparc64_fpu_register_names[] = { SPARC64_FPU_REGISTERS }; -static const char *sparc64_cp0_register_names[] = { SPARC64_CP0_REGISTERS }; +static const char * const sparc64_fpu_register_names[] = { + SPARC64_FPU_REGISTERS +}; +static const char * const sparc64_cp0_register_names[] = { + SPARC64_CP0_REGISTERS +}; -static const char *sparc64_register_names[] = +static const char * const sparc64_register_names[] = { SPARC_CORE_REGISTERS, SPARC64_FPU_REGISTERS, @@ -780,7 +784,7 @@ static const char *sparc64_register_names[] = /* We provide the aliases %d0..%d62 and %q0..%q60 for the floating registers as "psuedo" registers. */ -static const char *sparc64_pseudo_register_names[] = +static const char * const sparc64_pseudo_register_names[] = { "cwp", "pstate", "asi", "ccr", diff --git a/gdb/x86-tdep.c b/gdb/x86-tdep.c index 5f03cfe9109..8b1ea34c898 100644 --- a/gdb/x86-tdep.c +++ b/gdb/x86-tdep.c @@ -26,8 +26,8 @@ (exclusive). */ static bool -x86_is_thunk_register_name (const char *name, const char **names, int lo, - int hi) +x86_is_thunk_register_name (const char *name, const char * const *names, + int lo, int hi) { int reg; for (reg = lo; reg < hi; ++reg) @@ -40,7 +40,7 @@ x86_is_thunk_register_name (const char *name, const char **names, int lo, /* See x86-tdep.h. */ bool -x86_in_indirect_branch_thunk (CORE_ADDR pc, const char **register_names, +x86_in_indirect_branch_thunk (CORE_ADDR pc, const char * const *register_names, int lo, int hi) { struct bound_minimal_symbol bmfun = lookup_minimal_symbol_by_pc (pc); diff --git a/gdb/x86-tdep.h b/gdb/x86-tdep.h index 6ff62db3ff1..0f3e4256bc5 100644 --- a/gdb/x86-tdep.h +++ b/gdb/x86-tdep.h @@ -24,7 +24,7 @@ REGISTER_NAMES[LO] (inclusive) to REGISTER_NAMES[HI] (exclusive). */ extern bool x86_in_indirect_branch_thunk (CORE_ADDR pc, - const char **register_names, + const char * const *register_names, int lo, int hi); #endif /* x86-tdep.h */ diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog index 0c8af7c6c10..3b08ef393bc 100644 --- a/gdbserver/ChangeLog +++ b/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2020-09-14 Tom Tromey + + * tracepoint.cc (eval_result_names): Now const. + * ax.cc (gdb_agent_op_names): Now const. + 2020-09-10 Kamil Rytarowski * netbsd-low.cc: Add. diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc index 42d28128fa6..361e7a272f7 100644 --- a/gdbserver/ax.cc +++ b/gdbserver/ax.cc @@ -65,7 +65,7 @@ enum gdb_agent_op gdb_agent_op_last }; -static const char *gdb_agent_op_names [gdb_agent_op_last] = +static const char * const gdb_agent_op_names [gdb_agent_op_last] = { "?undef?" #define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) , # NAME diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc index e587d6561dc..6881f31c0ce 100644 --- a/gdbserver/tracepoint.cc +++ b/gdbserver/tracepoint.cc @@ -863,7 +863,7 @@ EXTERN_C_POP static struct tracepoint *last_tracepoint; -static const char *eval_result_names[] = +static const char * const eval_result_names[] = { "terror:in the attic", /* this should never be reported */ "terror:empty expression",