public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Inline initialization of gdbarch members
@ 2022-10-31 15:08 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-10-31 15:08 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6c8912c64bcbfd109af0500577409690074e9d27

commit 6c8912c64bcbfd109af0500577409690074e9d27
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Oct 18 09:48:09 2022 -0600

    Inline initialization of gdbarch members
    
    This changes gdbarch to use the "predefault" to initialize its members
    inline.  This required changing a couple of the Value instantiations
    to avoid a use of "gdbarch" during initialization, but on the whole I
    think this is better -- it removes a hidden ordering dependency.

Diff:
---
 gdb/gdbarch-components.py |   8 +-
 gdb/gdbarch.c             | 290 ++++++++++++++++------------------------------
 gdb/gdbarch.py            |  19 +--
 3 files changed, 111 insertions(+), 206 deletions(-)

diff --git a/gdb/gdbarch-components.py b/gdb/gdbarch-components.py
index 46e7565f293..c997a709cbb 100644
--- a/gdb/gdbarch-components.py
+++ b/gdb/gdbarch-components.py
@@ -151,7 +151,7 @@ Number of bits in a short or unsigned short for the target machine.
     invalid=False,
 )
 
-Value(
+int_bit = Value(
     comment="""
 Number of bits in an int or unsigned int for the target machine.
 """,
@@ -161,7 +161,7 @@ Number of bits in an int or unsigned int for the target machine.
     invalid=False,
 )
 
-Value(
+long_bit = Value(
     comment="""
 Number of bits in a long or unsigned long for the target machine.
 """,
@@ -178,7 +178,7 @@ machine.
 """,
     type="int",
     name="long_long_bit",
-    predefault="2*gdbarch->long_bit",
+    predefault="2*" + long_bit.predefault,
     invalid=False,
 )
 
@@ -314,7 +314,7 @@ ptr_bit is the size of a pointer on the target
 """,
     type="int",
     name="ptr_bit",
-    predefault="gdbarch->int_bit",
+    predefault=int_bit.predefault,
     invalid=False,
 )
 
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index a096f2a9c2c..6ff4fee5b3f 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -52,124 +52,124 @@ struct gdbarch
   unsigned nr_data = 0;
   void **data = nullptr;
 
-  int short_bit = 0;
-  int int_bit = 0;
-  int long_bit = 0;
-  int long_long_bit = 0;
-  int bfloat16_bit = 0;
+  int short_bit = 2*TARGET_CHAR_BIT;
+  int int_bit = 4*TARGET_CHAR_BIT;
+  int long_bit = 4*TARGET_CHAR_BIT;
+  int long_long_bit = 2*4*TARGET_CHAR_BIT;
+  int bfloat16_bit = 2*TARGET_CHAR_BIT;
   const struct floatformat ** bfloat16_format = 0;
-  int half_bit = 0;
+  int half_bit = 2*TARGET_CHAR_BIT;
   const struct floatformat ** half_format = 0;
-  int float_bit = 0;
+  int float_bit = 4*TARGET_CHAR_BIT;
   const struct floatformat ** float_format = 0;
-  int double_bit = 0;
+  int double_bit = 8*TARGET_CHAR_BIT;
   const struct floatformat ** double_format = 0;
-  int long_double_bit = 0;
+  int long_double_bit = 8*TARGET_CHAR_BIT;
   const struct floatformat ** long_double_format = 0;
-  int wchar_bit = 0;
-  int wchar_signed = 0;
-  gdbarch_floatformat_for_type_ftype *floatformat_for_type = nullptr;
-  int ptr_bit = 0;
+  int wchar_bit = 4*TARGET_CHAR_BIT;
+  int wchar_signed = -1;
+  gdbarch_floatformat_for_type_ftype *floatformat_for_type = default_floatformat_for_type;
+  int ptr_bit = 4*TARGET_CHAR_BIT;
   int addr_bit = 0;
   int dwarf2_addr_size = 0;
-  int char_signed = 0;
+  int char_signed = -1;
   gdbarch_read_pc_ftype *read_pc = nullptr;
   gdbarch_write_pc_ftype *write_pc = nullptr;
-  gdbarch_virtual_frame_pointer_ftype *virtual_frame_pointer = nullptr;
+  gdbarch_virtual_frame_pointer_ftype *virtual_frame_pointer = legacy_virtual_frame_pointer;
   gdbarch_pseudo_register_read_ftype *pseudo_register_read = nullptr;
   gdbarch_pseudo_register_read_value_ftype *pseudo_register_read_value = nullptr;
   gdbarch_pseudo_register_write_ftype *pseudo_register_write = nullptr;
-  int num_regs = 0;
+  int num_regs = -1;
   int num_pseudo_regs = 0;
   gdbarch_ax_pseudo_register_collect_ftype *ax_pseudo_register_collect = nullptr;
   gdbarch_ax_pseudo_register_push_stack_ftype *ax_pseudo_register_push_stack = nullptr;
   gdbarch_report_signal_info_ftype *report_signal_info = nullptr;
-  int sp_regnum = 0;
-  int pc_regnum = 0;
-  int ps_regnum = 0;
-  int fp0_regnum = 0;
-  gdbarch_stab_reg_to_regnum_ftype *stab_reg_to_regnum = nullptr;
-  gdbarch_ecoff_reg_to_regnum_ftype *ecoff_reg_to_regnum = nullptr;
-  gdbarch_sdb_reg_to_regnum_ftype *sdb_reg_to_regnum = nullptr;
-  gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum = nullptr;
-  gdbarch_register_name_ftype *register_name = nullptr;
+  int sp_regnum = -1;
+  int pc_regnum = -1;
+  int ps_regnum = -1;
+  int fp0_regnum = -1;
+  gdbarch_stab_reg_to_regnum_ftype *stab_reg_to_regnum = no_op_reg_to_regnum;
+  gdbarch_ecoff_reg_to_regnum_ftype *ecoff_reg_to_regnum = no_op_reg_to_regnum;
+  gdbarch_sdb_reg_to_regnum_ftype *sdb_reg_to_regnum = no_op_reg_to_regnum;
+  gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum = no_op_reg_to_regnum;
+  gdbarch_register_name_ftype *register_name = 0;
   gdbarch_register_type_ftype *register_type = nullptr;
-  gdbarch_dummy_id_ftype *dummy_id = nullptr;
-  int deprecated_fp_regnum = 0;
+  gdbarch_dummy_id_ftype *dummy_id = default_dummy_id;
+  int deprecated_fp_regnum = -1;
   gdbarch_push_dummy_call_ftype *push_dummy_call = nullptr;
-  int call_dummy_location = 0;
+  int call_dummy_location = AT_ENTRY_POINT;
   gdbarch_push_dummy_code_ftype *push_dummy_code = nullptr;
-  gdbarch_code_of_frame_writable_ftype *code_of_frame_writable = nullptr;
-  gdbarch_print_registers_info_ftype *print_registers_info = nullptr;
-  gdbarch_print_float_info_ftype *print_float_info = nullptr;
+  gdbarch_code_of_frame_writable_ftype *code_of_frame_writable = default_code_of_frame_writable;
+  gdbarch_print_registers_info_ftype *print_registers_info = default_print_registers_info;
+  gdbarch_print_float_info_ftype *print_float_info = default_print_float_info;
   gdbarch_print_vector_info_ftype *print_vector_info = nullptr;
-  gdbarch_register_sim_regno_ftype *register_sim_regno = nullptr;
-  gdbarch_cannot_fetch_register_ftype *cannot_fetch_register = nullptr;
-  gdbarch_cannot_store_register_ftype *cannot_store_register = nullptr;
+  gdbarch_register_sim_regno_ftype *register_sim_regno = legacy_register_sim_regno;
+  gdbarch_cannot_fetch_register_ftype *cannot_fetch_register = cannot_register_not;
+  gdbarch_cannot_store_register_ftype *cannot_store_register = cannot_register_not;
   gdbarch_get_longjmp_target_ftype *get_longjmp_target = nullptr;
   int believe_pcc_promotion = 0;
-  gdbarch_convert_register_p_ftype *convert_register_p = nullptr;
+  gdbarch_convert_register_p_ftype *convert_register_p = generic_convert_register_p;
   gdbarch_register_to_value_ftype *register_to_value = nullptr;
   gdbarch_value_to_register_ftype *value_to_register = nullptr;
-  gdbarch_value_from_register_ftype *value_from_register = nullptr;
-  gdbarch_pointer_to_address_ftype *pointer_to_address = nullptr;
-  gdbarch_address_to_pointer_ftype *address_to_pointer = nullptr;
+  gdbarch_value_from_register_ftype *value_from_register = default_value_from_register;
+  gdbarch_pointer_to_address_ftype *pointer_to_address = unsigned_pointer_to_address;
+  gdbarch_address_to_pointer_ftype *address_to_pointer = unsigned_address_to_pointer;
   gdbarch_integer_to_address_ftype *integer_to_address = nullptr;
   gdbarch_return_value_ftype *return_value = nullptr;
-  gdbarch_return_in_first_hidden_param_p_ftype *return_in_first_hidden_param_p = nullptr;
-  gdbarch_skip_prologue_ftype *skip_prologue = nullptr;
+  gdbarch_return_in_first_hidden_param_p_ftype *return_in_first_hidden_param_p = default_return_in_first_hidden_param_p;
+  gdbarch_skip_prologue_ftype *skip_prologue = 0;
   gdbarch_skip_main_prologue_ftype *skip_main_prologue = nullptr;
   gdbarch_skip_entrypoint_ftype *skip_entrypoint = nullptr;
-  gdbarch_inner_than_ftype *inner_than = nullptr;
-  gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc = nullptr;
-  gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc = nullptr;
-  gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind = nullptr;
-  gdbarch_breakpoint_kind_from_current_state_ftype *breakpoint_kind_from_current_state = nullptr;
+  gdbarch_inner_than_ftype *inner_than = 0;
+  gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc = default_breakpoint_from_pc;
+  gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc = 0;
+  gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind = NULL;
+  gdbarch_breakpoint_kind_from_current_state_ftype *breakpoint_kind_from_current_state = default_breakpoint_kind_from_current_state;
   gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address = nullptr;
-  gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint = nullptr;
-  gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint = nullptr;
+  gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint = default_memory_insert_breakpoint;
+  gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint = default_memory_remove_breakpoint;
   CORE_ADDR decr_pc_after_break = 0;
   CORE_ADDR deprecated_function_start_offset = 0;
-  gdbarch_remote_register_number_ftype *remote_register_number = nullptr;
+  gdbarch_remote_register_number_ftype *remote_register_number = default_remote_register_number;
   gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address = nullptr;
   gdbarch_get_thread_local_address_ftype *get_thread_local_address = nullptr;
   CORE_ADDR frame_args_skip = 0;
-  gdbarch_unwind_pc_ftype *unwind_pc = nullptr;
-  gdbarch_unwind_sp_ftype *unwind_sp = nullptr;
+  gdbarch_unwind_pc_ftype *unwind_pc = default_unwind_pc;
+  gdbarch_unwind_sp_ftype *unwind_sp = default_unwind_sp;
   gdbarch_frame_num_args_ftype *frame_num_args = nullptr;
   gdbarch_frame_align_ftype *frame_align = nullptr;
-  gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr = nullptr;
+  gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr = default_stabs_argument_has_addr;
   int frame_red_zone_size = 0;
-  gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr = nullptr;
-  gdbarch_addr_bits_remove_ftype *addr_bits_remove = nullptr;
+  gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity;
+  gdbarch_addr_bits_remove_ftype *addr_bits_remove = core_addr_identity;
   int significant_addr_bit = 0;
-  gdbarch_memtag_to_string_ftype *memtag_to_string = nullptr;
-  gdbarch_tagged_address_p_ftype *tagged_address_p = nullptr;
-  gdbarch_memtag_matches_p_ftype *memtag_matches_p = nullptr;
-  gdbarch_set_memtags_ftype *set_memtags = nullptr;
-  gdbarch_get_memtag_ftype *get_memtag = nullptr;
+  gdbarch_memtag_to_string_ftype *memtag_to_string = default_memtag_to_string;
+  gdbarch_tagged_address_p_ftype *tagged_address_p = default_tagged_address_p;
+  gdbarch_memtag_matches_p_ftype *memtag_matches_p = default_memtag_matches_p;
+  gdbarch_set_memtags_ftype *set_memtags = default_set_memtags;
+  gdbarch_get_memtag_ftype *get_memtag = default_get_memtag;
   CORE_ADDR memtag_granule_size = 0;
   gdbarch_software_single_step_ftype *software_single_step = nullptr;
   gdbarch_single_step_through_delay_ftype *single_step_through_delay = nullptr;
-  gdbarch_print_insn_ftype *print_insn = nullptr;
-  gdbarch_skip_trampoline_code_ftype *skip_trampoline_code = nullptr;
+  gdbarch_print_insn_ftype *print_insn = default_print_insn;
+  gdbarch_skip_trampoline_code_ftype *skip_trampoline_code = generic_skip_trampoline_code;
   const struct target_so_ops * so_ops = 0;
-  gdbarch_skip_solib_resolver_ftype *skip_solib_resolver = nullptr;
-  gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline = nullptr;
-  gdbarch_in_indirect_branch_thunk_ftype *in_indirect_branch_thunk = nullptr;
-  gdbarch_stack_frame_destroyed_p_ftype *stack_frame_destroyed_p = nullptr;
+  gdbarch_skip_solib_resolver_ftype *skip_solib_resolver = generic_skip_solib_resolver;
+  gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline = generic_in_solib_return_trampoline;
+  gdbarch_in_indirect_branch_thunk_ftype *in_indirect_branch_thunk = default_in_indirect_branch_thunk;
+  gdbarch_stack_frame_destroyed_p_ftype *stack_frame_destroyed_p = generic_stack_frame_destroyed_p;
   gdbarch_elf_make_msymbol_special_ftype *elf_make_msymbol_special = nullptr;
-  gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special = nullptr;
-  gdbarch_make_symbol_special_ftype *make_symbol_special = nullptr;
-  gdbarch_adjust_dwarf2_addr_ftype *adjust_dwarf2_addr = nullptr;
-  gdbarch_adjust_dwarf2_line_ftype *adjust_dwarf2_line = nullptr;
+  gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special = default_coff_make_msymbol_special;
+  gdbarch_make_symbol_special_ftype *make_symbol_special = default_make_symbol_special;
+  gdbarch_adjust_dwarf2_addr_ftype *adjust_dwarf2_addr = default_adjust_dwarf2_addr;
+  gdbarch_adjust_dwarf2_line_ftype *adjust_dwarf2_line = default_adjust_dwarf2_line;
   int cannot_step_breakpoint = 0;
   int have_nonsteppable_watchpoint = 0;
   gdbarch_address_class_type_flags_ftype *address_class_type_flags = nullptr;
   gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name = nullptr;
-  gdbarch_execute_dwarf_cfa_vendor_op_ftype *execute_dwarf_cfa_vendor_op = nullptr;
+  gdbarch_execute_dwarf_cfa_vendor_op_ftype *execute_dwarf_cfa_vendor_op = default_execute_dwarf_cfa_vendor_op;
   gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags = nullptr;
-  gdbarch_register_reggroup_p_ftype *register_reggroup_p = nullptr;
+  gdbarch_register_reggroup_p_ftype *register_reggroup_p = default_register_reggroup_p;
   gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument = nullptr;
   gdbarch_iterate_over_regset_sections_ftype *iterate_over_regset_sections = nullptr;
   gdbarch_make_corefile_notes_ftype *make_corefile_notes = nullptr;
@@ -185,16 +185,16 @@ struct gdbarch
   const char * gcore_bfd_target = 0;
   int vtable_function_descriptors = 0;
   int vbit_in_delta = 0;
-  gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint = nullptr;
+  gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint = default_skip_permanent_breakpoint;
   ULONGEST max_insn_length = 0;
   gdbarch_displaced_step_copy_insn_ftype *displaced_step_copy_insn = nullptr;
-  gdbarch_displaced_step_hw_singlestep_ftype *displaced_step_hw_singlestep = nullptr;
-  gdbarch_displaced_step_fixup_ftype *displaced_step_fixup = nullptr;
+  gdbarch_displaced_step_hw_singlestep_ftype *displaced_step_hw_singlestep = default_displaced_step_hw_singlestep;
+  gdbarch_displaced_step_fixup_ftype *displaced_step_fixup = NULL;
   gdbarch_displaced_step_prepare_ftype *displaced_step_prepare = nullptr;
-  gdbarch_displaced_step_finish_ftype *displaced_step_finish = nullptr;
+  gdbarch_displaced_step_finish_ftype *displaced_step_finish = NULL;
   gdbarch_displaced_step_copy_insn_closure_by_addr_ftype *displaced_step_copy_insn_closure_by_addr = nullptr;
   gdbarch_displaced_step_restore_all_in_ptid_ftype *displaced_step_restore_all_in_ptid = nullptr;
-  gdbarch_relocate_instruction_ftype *relocate_instruction = nullptr;
+  gdbarch_relocate_instruction_ftype *relocate_instruction = NULL;
   gdbarch_overlay_update_ftype *overlay_update = nullptr;
   gdbarch_core_read_description_ftype *core_read_description = nullptr;
   int sofun_address_maybe_missing = 0;
@@ -224,36 +224,36 @@ struct gdbarch
   gdbarch_dtrace_disable_probe_ftype *dtrace_disable_probe = nullptr;
   int has_global_solist = 0;
   int has_global_breakpoints = 0;
-  gdbarch_has_shared_address_space_ftype *has_shared_address_space = nullptr;
-  gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at = nullptr;
-  gdbarch_guess_tracepoint_registers_ftype *guess_tracepoint_registers = nullptr;
-  gdbarch_auto_charset_ftype *auto_charset = nullptr;
-  gdbarch_auto_wide_charset_ftype *auto_wide_charset = nullptr;
+  gdbarch_has_shared_address_space_ftype *has_shared_address_space = default_has_shared_address_space;
+  gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at = default_fast_tracepoint_valid_at;
+  gdbarch_guess_tracepoint_registers_ftype *guess_tracepoint_registers = default_guess_tracepoint_registers;
+  gdbarch_auto_charset_ftype *auto_charset = default_auto_charset;
+  gdbarch_auto_wide_charset_ftype *auto_wide_charset = default_auto_wide_charset;
   const char * solib_symbols_extension = 0;
   int has_dos_based_file_system = 0;
-  gdbarch_gen_return_address_ftype *gen_return_address = nullptr;
+  gdbarch_gen_return_address_ftype *gen_return_address = default_gen_return_address;
   gdbarch_info_proc_ftype *info_proc = nullptr;
   gdbarch_core_info_proc_ftype *core_info_proc = nullptr;
-  gdbarch_iterate_over_objfiles_in_search_order_ftype *iterate_over_objfiles_in_search_order = nullptr;
-  struct ravenscar_arch_ops * ravenscar_ops = 0;
-  gdbarch_insn_is_call_ftype *insn_is_call = nullptr;
-  gdbarch_insn_is_ret_ftype *insn_is_ret = nullptr;
-  gdbarch_insn_is_jump_ftype *insn_is_jump = nullptr;
-  gdbarch_program_breakpoint_here_p_ftype *program_breakpoint_here_p = nullptr;
+  gdbarch_iterate_over_objfiles_in_search_order_ftype *iterate_over_objfiles_in_search_order = default_iterate_over_objfiles_in_search_order;
+  struct ravenscar_arch_ops * ravenscar_ops = NULL;
+  gdbarch_insn_is_call_ftype *insn_is_call = default_insn_is_call;
+  gdbarch_insn_is_ret_ftype *insn_is_ret = default_insn_is_ret;
+  gdbarch_insn_is_jump_ftype *insn_is_jump = default_insn_is_jump;
+  gdbarch_program_breakpoint_here_p_ftype *program_breakpoint_here_p = default_program_breakpoint_here_p;
   gdbarch_auxv_parse_ftype *auxv_parse = nullptr;
-  gdbarch_print_auxv_entry_ftype *print_auxv_entry = nullptr;
-  gdbarch_vsyscall_range_ftype *vsyscall_range = nullptr;
-  gdbarch_infcall_mmap_ftype *infcall_mmap = nullptr;
-  gdbarch_infcall_munmap_ftype *infcall_munmap = nullptr;
-  gdbarch_gcc_target_options_ftype *gcc_target_options = nullptr;
-  gdbarch_gnu_triplet_regexp_ftype *gnu_triplet_regexp = nullptr;
-  gdbarch_addressable_memory_unit_size_ftype *addressable_memory_unit_size = nullptr;
+  gdbarch_print_auxv_entry_ftype *print_auxv_entry = default_print_auxv_entry;
+  gdbarch_vsyscall_range_ftype *vsyscall_range = default_vsyscall_range;
+  gdbarch_infcall_mmap_ftype *infcall_mmap = default_infcall_mmap;
+  gdbarch_infcall_munmap_ftype *infcall_munmap = default_infcall_munmap;
+  gdbarch_gcc_target_options_ftype *gcc_target_options = default_gcc_target_options;
+  gdbarch_gnu_triplet_regexp_ftype *gnu_triplet_regexp = default_gnu_triplet_regexp;
+  gdbarch_addressable_memory_unit_size_ftype *addressable_memory_unit_size = default_addressable_memory_unit_size;
   const char * disassembler_options_implicit = 0;
   char ** disassembler_options = 0;
   const disasm_options_and_args_t * valid_disassembler_options = 0;
-  gdbarch_type_align_ftype *type_align = nullptr;
-  gdbarch_get_pc_address_flags_ftype *get_pc_address_flags = nullptr;
-  gdbarch_read_core_file_mappings_ftype *read_core_file_mappings = nullptr;
+  gdbarch_type_align_ftype *type_align = default_type_align;
+  gdbarch_get_pc_address_flags_ftype *get_pc_address_flags = default_get_pc_address_flags;
+  gdbarch_read_core_file_mappings_ftype *read_core_file_mappings = default_read_core_file_mappings;
 };
 
 /* Create a new ``struct gdbarch'' based on information provided by
@@ -275,102 +275,6 @@ gdbarch_alloc (const struct gdbarch_info *info,
   gdbarch->osabi = info->osabi;
   gdbarch->target_desc = info->target_desc;
 
-  /* Force the explicit initialization of these.  */
-  gdbarch->short_bit = 2*TARGET_CHAR_BIT;
-  gdbarch->int_bit = 4*TARGET_CHAR_BIT;
-  gdbarch->long_bit = 4*TARGET_CHAR_BIT;
-  gdbarch->long_long_bit = 2*gdbarch->long_bit;
-  gdbarch->bfloat16_bit = 2*TARGET_CHAR_BIT;
-  gdbarch->half_bit = 2*TARGET_CHAR_BIT;
-  gdbarch->float_bit = 4*TARGET_CHAR_BIT;
-  gdbarch->double_bit = 8*TARGET_CHAR_BIT;
-  gdbarch->long_double_bit = 8*TARGET_CHAR_BIT;
-  gdbarch->wchar_bit = 4*TARGET_CHAR_BIT;
-  gdbarch->wchar_signed = -1;
-  gdbarch->floatformat_for_type = default_floatformat_for_type;
-  gdbarch->ptr_bit = gdbarch->int_bit;
-  gdbarch->char_signed = -1;
-  gdbarch->virtual_frame_pointer = legacy_virtual_frame_pointer;
-  gdbarch->num_regs = -1;
-  gdbarch->sp_regnum = -1;
-  gdbarch->pc_regnum = -1;
-  gdbarch->ps_regnum = -1;
-  gdbarch->fp0_regnum = -1;
-  gdbarch->stab_reg_to_regnum = no_op_reg_to_regnum;
-  gdbarch->ecoff_reg_to_regnum = no_op_reg_to_regnum;
-  gdbarch->sdb_reg_to_regnum = no_op_reg_to_regnum;
-  gdbarch->dwarf2_reg_to_regnum = no_op_reg_to_regnum;
-  gdbarch->dummy_id = default_dummy_id;
-  gdbarch->deprecated_fp_regnum = -1;
-  gdbarch->call_dummy_location = AT_ENTRY_POINT;
-  gdbarch->code_of_frame_writable = default_code_of_frame_writable;
-  gdbarch->print_registers_info = default_print_registers_info;
-  gdbarch->print_float_info = default_print_float_info;
-  gdbarch->register_sim_regno = legacy_register_sim_regno;
-  gdbarch->cannot_fetch_register = cannot_register_not;
-  gdbarch->cannot_store_register = cannot_register_not;
-  gdbarch->convert_register_p = generic_convert_register_p;
-  gdbarch->value_from_register = default_value_from_register;
-  gdbarch->pointer_to_address = unsigned_pointer_to_address;
-  gdbarch->address_to_pointer = unsigned_address_to_pointer;
-  gdbarch->return_in_first_hidden_param_p = default_return_in_first_hidden_param_p;
-  gdbarch->breakpoint_from_pc = default_breakpoint_from_pc;
-  gdbarch->sw_breakpoint_from_kind = NULL;
-  gdbarch->breakpoint_kind_from_current_state = default_breakpoint_kind_from_current_state;
-  gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint;
-  gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint;
-  gdbarch->remote_register_number = default_remote_register_number;
-  gdbarch->unwind_pc = default_unwind_pc;
-  gdbarch->unwind_sp = default_unwind_sp;
-  gdbarch->stabs_argument_has_addr = default_stabs_argument_has_addr;
-  gdbarch->convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity;
-  gdbarch->addr_bits_remove = core_addr_identity;
-  gdbarch->memtag_to_string = default_memtag_to_string;
-  gdbarch->tagged_address_p = default_tagged_address_p;
-  gdbarch->memtag_matches_p = default_memtag_matches_p;
-  gdbarch->set_memtags = default_set_memtags;
-  gdbarch->get_memtag = default_get_memtag;
-  gdbarch->print_insn = default_print_insn;
-  gdbarch->skip_trampoline_code = generic_skip_trampoline_code;
-  gdbarch->skip_solib_resolver = generic_skip_solib_resolver;
-  gdbarch->in_solib_return_trampoline = generic_in_solib_return_trampoline;
-  gdbarch->in_indirect_branch_thunk = default_in_indirect_branch_thunk;
-  gdbarch->stack_frame_destroyed_p = generic_stack_frame_destroyed_p;
-  gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special;
-  gdbarch->make_symbol_special = default_make_symbol_special;
-  gdbarch->adjust_dwarf2_addr = default_adjust_dwarf2_addr;
-  gdbarch->adjust_dwarf2_line = default_adjust_dwarf2_line;
-  gdbarch->execute_dwarf_cfa_vendor_op = default_execute_dwarf_cfa_vendor_op;
-  gdbarch->register_reggroup_p = default_register_reggroup_p;
-  gdbarch->skip_permanent_breakpoint = default_skip_permanent_breakpoint;
-  gdbarch->displaced_step_hw_singlestep = default_displaced_step_hw_singlestep;
-  gdbarch->displaced_step_fixup = NULL;
-  gdbarch->displaced_step_finish = NULL;
-  gdbarch->relocate_instruction = NULL;
-  gdbarch->has_shared_address_space = default_has_shared_address_space;
-  gdbarch->fast_tracepoint_valid_at = default_fast_tracepoint_valid_at;
-  gdbarch->guess_tracepoint_registers = default_guess_tracepoint_registers;
-  gdbarch->auto_charset = default_auto_charset;
-  gdbarch->auto_wide_charset = default_auto_wide_charset;
-  gdbarch->gen_return_address = default_gen_return_address;
-  gdbarch->iterate_over_objfiles_in_search_order = default_iterate_over_objfiles_in_search_order;
-  gdbarch->ravenscar_ops = NULL;
-  gdbarch->insn_is_call = default_insn_is_call;
-  gdbarch->insn_is_ret = default_insn_is_ret;
-  gdbarch->insn_is_jump = default_insn_is_jump;
-  gdbarch->program_breakpoint_here_p = default_program_breakpoint_here_p;
-  gdbarch->print_auxv_entry = default_print_auxv_entry;
-  gdbarch->vsyscall_range = default_vsyscall_range;
-  gdbarch->infcall_mmap = default_infcall_mmap;
-  gdbarch->infcall_munmap = default_infcall_munmap;
-  gdbarch->gcc_target_options = default_gcc_target_options;
-  gdbarch->gnu_triplet_regexp = default_gnu_triplet_regexp;
-  gdbarch->addressable_memory_unit_size = default_addressable_memory_unit_size;
-  gdbarch->type_align = default_type_align;
-  gdbarch->get_pc_address_flags = default_get_pc_address_flags;
-  gdbarch->read_core_file_mappings = default_read_core_file_mappings;
-  /* gdbarch_alloc() */
-
   return gdbarch;
 }
 
diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py
index ae8a3f73fd6..a4c1818b0c0 100755
--- a/gdb/gdbarch.py
+++ b/gdb/gdbarch.py
@@ -286,11 +286,18 @@ with open("gdbarch.c", "w") as f:
     print("  void **data = nullptr;", file=f)
     print(file=f)
     for c in filter(not_info, components):
-        if isinstance(c, Value):
-            print(f"  {c.type} {c.name} = 0;", file=f)
+        if isinstance(c, Function):
+            print(f"  gdbarch_{c.name}_ftype *", file=f, end="")
+        else:
+            print(f"  {c.type} ", file=f, end="")
+        print(f"{c.name} = ", file=f, end="")
+        if c.predefault is not None:
+            print(f"{c.predefault};", file=f)
+        elif isinstance(c, Value):
+            print("0;", file=f)
         else:
             assert isinstance(c, Function)
-            print(f"  gdbarch_{c.name}_ftype *{c.name} = nullptr;", file=f)
+            print("nullptr;", file=f)
     print("};", file=f)
     print(file=f)
     #
@@ -312,12 +319,6 @@ with open("gdbarch.c", "w") as f:
     for c in filter(info, components):
         print(f"  gdbarch->{c.name} = info->{c.name};", file=f)
     print(file=f)
-    print("  /* Force the explicit initialization of these.  */", file=f)
-    for c in filter(not_info, components):
-        if c.predefault and c.predefault != "0":
-            print(f"  gdbarch->{c.name} = {c.predefault};", file=f)
-    print("  /* gdbarch_alloc() */", file=f)
-    print(file=f)
     print("  return gdbarch;", file=f)
     print("}", file=f)
     print(file=f)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-31 15:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-31 15:08 [binutils-gdb] Inline initialization of gdbarch members Tom Tromey

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