From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KAAaDmC3o2KlPwEAWB0awg (envelope-from ) for ; Fri, 10 Jun 2022 17:28:00 -0400 Received: by simark.ca (Postfix, from userid 112) id 35D0F1E223; Fri, 10 Jun 2022 17:28:00 -0400 (EDT) Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=Ko8Z4h0p; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 42F2A1E143 for ; Fri, 10 Jun 2022 17:27:58 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D587E3856DE8 for ; Fri, 10 Jun 2022 21:27:57 +0000 (GMT) Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 5A4723857BB4 for ; Fri, 10 Jun 2022 21:27:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A4723857BB4 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 42C36100448F0 for ; Fri, 10 Jun 2022 21:27:00 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id zm9jnqBPIxkuLzm9jnXifG; Fri, 10 Jun 2022 21:27:00 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=VbMygHl9 c=1 sm=1 tr=0 ts=62a3b724 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=JPEYwPQDsx4A:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=BHGwbUmQYd4g2UOYznwA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=AGZW5mzhhev2PfrtW61EUUYFy87VwZl8uixUsCRZArc=; b=Ko8Z4h0pO1Ev1xW0ZjWa7OkahG Wwjg9j+WnUl7q5AYMtQfdUmrKAmLM+WL3Daai8vPFnaYHNlmJ1QfA99Zwm3Ap9AYs5QRT1XhU/MOr J8evT077NAMELBoeAV1WC/+BM; Received: from 71-211-171-143.hlrn.qwest.net ([71.211.171.143]:45652 helo=prentzel.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1nzm9j-003s0K-AG; Fri, 10 Jun 2022 15:26:59 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 2/4] Use new and delete for gdbarch Date: Fri, 10 Jun 2022 15:26:55 -0600 Message-Id: <20220610212657.1170222-3-tom@tromey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610212657.1170222-1-tom@tromey.com> References: <20220610212657.1170222-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.171.143 X-Source-L: No X-Exim-ID: 1nzm9j-003s0K-AG X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-171-143.hlrn.qwest.net (prentzel.Home) [71.211.171.143]:45652 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" This changes gdbarch to use new and delete. --- gdb/arch-utils.c | 12 +- gdb/gdbarch.c | 418 +++++++++++++++++++++++------------------------ gdb/gdbarch.py | 26 +-- 3 files changed, 219 insertions(+), 237 deletions(-) diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index d6834c5a1f5..e61bd366822 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -1168,7 +1168,7 @@ pstring_list (const char *const *list) obstack *gdbarch_obstack (gdbarch *arch) { - return arch->obstack; + return &arch->obstack; } /* See gdbarch.h. */ @@ -1176,7 +1176,7 @@ obstack *gdbarch_obstack (gdbarch *arch) char * gdbarch_obstack_strdup (struct gdbarch *arch, const char *string) { - return obstack_strdup (arch->obstack, string); + return obstack_strdup (&arch->obstack, string); } @@ -1189,13 +1189,9 @@ gdbarch_obstack_strdup (struct gdbarch *arch, const char *string) void gdbarch_free (struct gdbarch *arch) { - struct obstack *obstack; - gdb_assert (arch != NULL); gdb_assert (!arch->initialized_p); - obstack = arch->obstack; - obstack_free (obstack, 0); /* Includes the ARCH. */ - xfree (obstack); + delete arch; } struct gdbarch_tdep * @@ -1292,7 +1288,7 @@ gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *data) the entire architecture, as that way it isn't possible for pre-init code to refer to undefined architecture fields. */ - gdbarch->data[data->index] = data->pre_init (gdbarch->obstack); + gdbarch->data[data->index] = data->pre_init (&gdbarch->obstack); else if (gdbarch->initialized_p && data->post_init != NULL) /* Post architecture creation: pass the entire architecture diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 68ef0480219..c51660ddd4c 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -30,10 +30,10 @@ struct gdbarch { /* Has this architecture been fully initialized? */ - int initialized_p; + bool initialized_p = false; /* An obstack bound to the lifetime of the architecture. */ - struct obstack *obstack; + auto_obstack obstack; /* basic architectural information. */ const struct bfd_arch_info * bfd_arch_info; @@ -43,211 +43,211 @@ struct gdbarch const struct target_desc * target_desc; /* target specific vector. */ - struct gdbarch_tdep *tdep; - gdbarch_dump_tdep_ftype *dump_tdep; + struct gdbarch_tdep *tdep = nullptr; + gdbarch_dump_tdep_ftype *dump_tdep = nullptr; /* per-architecture data-pointers. */ - unsigned nr_data; - void **data; - - int short_bit; - int int_bit; - int long_bit; - int long_long_bit; - int bfloat16_bit; - const struct floatformat ** bfloat16_format; - int half_bit; - const struct floatformat ** half_format; - int float_bit; - const struct floatformat ** float_format; - int double_bit; - const struct floatformat ** double_format; - int long_double_bit; - const struct floatformat ** long_double_format; - int wchar_bit; - int wchar_signed; - gdbarch_floatformat_for_type_ftype *floatformat_for_type; - int ptr_bit; - int addr_bit; - int dwarf2_addr_size; - int char_signed; - gdbarch_read_pc_ftype *read_pc; - gdbarch_write_pc_ftype *write_pc; - gdbarch_virtual_frame_pointer_ftype *virtual_frame_pointer; - gdbarch_pseudo_register_read_ftype *pseudo_register_read; - gdbarch_pseudo_register_read_value_ftype *pseudo_register_read_value; - gdbarch_pseudo_register_write_ftype *pseudo_register_write; - int num_regs; - int num_pseudo_regs; - gdbarch_ax_pseudo_register_collect_ftype *ax_pseudo_register_collect; - gdbarch_ax_pseudo_register_push_stack_ftype *ax_pseudo_register_push_stack; - gdbarch_report_signal_info_ftype *report_signal_info; - int sp_regnum; - int pc_regnum; - int ps_regnum; - int fp0_regnum; - gdbarch_stab_reg_to_regnum_ftype *stab_reg_to_regnum; - gdbarch_ecoff_reg_to_regnum_ftype *ecoff_reg_to_regnum; - gdbarch_sdb_reg_to_regnum_ftype *sdb_reg_to_regnum; - gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum; - gdbarch_register_name_ftype *register_name; - gdbarch_register_type_ftype *register_type; - gdbarch_dummy_id_ftype *dummy_id; - int deprecated_fp_regnum; - gdbarch_push_dummy_call_ftype *push_dummy_call; - int call_dummy_location; - gdbarch_push_dummy_code_ftype *push_dummy_code; - gdbarch_code_of_frame_writable_ftype *code_of_frame_writable; - gdbarch_print_registers_info_ftype *print_registers_info; - gdbarch_print_float_info_ftype *print_float_info; - gdbarch_print_vector_info_ftype *print_vector_info; - gdbarch_register_sim_regno_ftype *register_sim_regno; - gdbarch_cannot_fetch_register_ftype *cannot_fetch_register; - gdbarch_cannot_store_register_ftype *cannot_store_register; - gdbarch_get_longjmp_target_ftype *get_longjmp_target; - int believe_pcc_promotion; - gdbarch_convert_register_p_ftype *convert_register_p; - gdbarch_register_to_value_ftype *register_to_value; - gdbarch_value_to_register_ftype *value_to_register; - gdbarch_value_from_register_ftype *value_from_register; - gdbarch_pointer_to_address_ftype *pointer_to_address; - gdbarch_address_to_pointer_ftype *address_to_pointer; - gdbarch_integer_to_address_ftype *integer_to_address; - gdbarch_return_value_ftype *return_value; - gdbarch_return_in_first_hidden_param_p_ftype *return_in_first_hidden_param_p; - gdbarch_skip_prologue_ftype *skip_prologue; - gdbarch_skip_main_prologue_ftype *skip_main_prologue; - gdbarch_skip_entrypoint_ftype *skip_entrypoint; - gdbarch_inner_than_ftype *inner_than; - gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc; - gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc; - gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind; - gdbarch_breakpoint_kind_from_current_state_ftype *breakpoint_kind_from_current_state; - gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address; - gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint; - gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint; - CORE_ADDR decr_pc_after_break; - CORE_ADDR deprecated_function_start_offset; - gdbarch_remote_register_number_ftype *remote_register_number; - gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address; - gdbarch_get_thread_local_address_ftype *get_thread_local_address; - CORE_ADDR frame_args_skip; - gdbarch_unwind_pc_ftype *unwind_pc; - gdbarch_unwind_sp_ftype *unwind_sp; - gdbarch_frame_num_args_ftype *frame_num_args; - gdbarch_frame_align_ftype *frame_align; - gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr; - int frame_red_zone_size; - gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr; - gdbarch_addr_bits_remove_ftype *addr_bits_remove; - int significant_addr_bit; - gdbarch_memtag_to_string_ftype *memtag_to_string; - gdbarch_tagged_address_p_ftype *tagged_address_p; - gdbarch_memtag_matches_p_ftype *memtag_matches_p; - gdbarch_set_memtags_ftype *set_memtags; - gdbarch_get_memtag_ftype *get_memtag; - CORE_ADDR memtag_granule_size; - gdbarch_software_single_step_ftype *software_single_step; - gdbarch_single_step_through_delay_ftype *single_step_through_delay; - gdbarch_print_insn_ftype *print_insn; - gdbarch_skip_trampoline_code_ftype *skip_trampoline_code; - gdbarch_skip_solib_resolver_ftype *skip_solib_resolver; - gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline; - gdbarch_in_indirect_branch_thunk_ftype *in_indirect_branch_thunk; - gdbarch_stack_frame_destroyed_p_ftype *stack_frame_destroyed_p; - gdbarch_elf_make_msymbol_special_ftype *elf_make_msymbol_special; - gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special; - gdbarch_make_symbol_special_ftype *make_symbol_special; - gdbarch_adjust_dwarf2_addr_ftype *adjust_dwarf2_addr; - gdbarch_adjust_dwarf2_line_ftype *adjust_dwarf2_line; - int cannot_step_breakpoint; - int have_nonsteppable_watchpoint; - gdbarch_address_class_type_flags_ftype *address_class_type_flags; - gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name; - gdbarch_execute_dwarf_cfa_vendor_op_ftype *execute_dwarf_cfa_vendor_op; - gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags; - gdbarch_register_reggroup_p_ftype *register_reggroup_p; - gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument; - gdbarch_iterate_over_regset_sections_ftype *iterate_over_regset_sections; - gdbarch_make_corefile_notes_ftype *make_corefile_notes; - gdbarch_find_memory_regions_ftype *find_memory_regions; - gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries; - gdbarch_core_xfer_shared_libraries_aix_ftype *core_xfer_shared_libraries_aix; - gdbarch_core_pid_to_str_ftype *core_pid_to_str; - gdbarch_core_thread_name_ftype *core_thread_name; - gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo; - const char * gcore_bfd_target; - int vtable_function_descriptors; - int vbit_in_delta; - gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint; - ULONGEST max_insn_length; - gdbarch_displaced_step_copy_insn_ftype *displaced_step_copy_insn; - gdbarch_displaced_step_hw_singlestep_ftype *displaced_step_hw_singlestep; - gdbarch_displaced_step_fixup_ftype *displaced_step_fixup; - gdbarch_displaced_step_prepare_ftype *displaced_step_prepare; - gdbarch_displaced_step_finish_ftype *displaced_step_finish; - gdbarch_displaced_step_copy_insn_closure_by_addr_ftype *displaced_step_copy_insn_closure_by_addr; - gdbarch_displaced_step_restore_all_in_ptid_ftype *displaced_step_restore_all_in_ptid; - gdbarch_relocate_instruction_ftype *relocate_instruction; - gdbarch_overlay_update_ftype *overlay_update; - gdbarch_core_read_description_ftype *core_read_description; - int sofun_address_maybe_missing; - gdbarch_process_record_ftype *process_record; - gdbarch_process_record_signal_ftype *process_record_signal; - gdbarch_gdb_signal_from_target_ftype *gdb_signal_from_target; - gdbarch_gdb_signal_to_target_ftype *gdb_signal_to_target; - gdbarch_get_siginfo_type_ftype *get_siginfo_type; - gdbarch_record_special_symbol_ftype *record_special_symbol; - gdbarch_get_syscall_number_ftype *get_syscall_number; - const char * xml_syscall_file; - struct syscalls_info * syscalls_info; - const char *const * stap_integer_prefixes; - const char *const * stap_integer_suffixes; - const char *const * stap_register_prefixes; - const char *const * stap_register_suffixes; - const char *const * stap_register_indirection_prefixes; - const char *const * stap_register_indirection_suffixes; - const char * stap_gdb_register_prefix; - const char * stap_gdb_register_suffix; - gdbarch_stap_is_single_operand_ftype *stap_is_single_operand; - gdbarch_stap_parse_special_token_ftype *stap_parse_special_token; - gdbarch_stap_adjust_register_ftype *stap_adjust_register; - gdbarch_dtrace_parse_probe_argument_ftype *dtrace_parse_probe_argument; - gdbarch_dtrace_probe_is_enabled_ftype *dtrace_probe_is_enabled; - gdbarch_dtrace_enable_probe_ftype *dtrace_enable_probe; - gdbarch_dtrace_disable_probe_ftype *dtrace_disable_probe; - int has_global_solist; - int has_global_breakpoints; - gdbarch_has_shared_address_space_ftype *has_shared_address_space; - gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at; - gdbarch_guess_tracepoint_registers_ftype *guess_tracepoint_registers; - gdbarch_auto_charset_ftype *auto_charset; - gdbarch_auto_wide_charset_ftype *auto_wide_charset; - const char * solib_symbols_extension; - int has_dos_based_file_system; - gdbarch_gen_return_address_ftype *gen_return_address; - gdbarch_info_proc_ftype *info_proc; - gdbarch_core_info_proc_ftype *core_info_proc; - gdbarch_iterate_over_objfiles_in_search_order_ftype *iterate_over_objfiles_in_search_order; - struct ravenscar_arch_ops * ravenscar_ops; - gdbarch_insn_is_call_ftype *insn_is_call; - gdbarch_insn_is_ret_ftype *insn_is_ret; - gdbarch_insn_is_jump_ftype *insn_is_jump; - gdbarch_program_breakpoint_here_p_ftype *program_breakpoint_here_p; - gdbarch_auxv_parse_ftype *auxv_parse; - gdbarch_print_auxv_entry_ftype *print_auxv_entry; - gdbarch_vsyscall_range_ftype *vsyscall_range; - gdbarch_infcall_mmap_ftype *infcall_mmap; - gdbarch_infcall_munmap_ftype *infcall_munmap; - gdbarch_gcc_target_options_ftype *gcc_target_options; - gdbarch_gnu_triplet_regexp_ftype *gnu_triplet_regexp; - gdbarch_addressable_memory_unit_size_ftype *addressable_memory_unit_size; - const char * disassembler_options_implicit; - char ** disassembler_options; - const disasm_options_and_args_t * valid_disassembler_options; - gdbarch_type_align_ftype *type_align; - gdbarch_get_pc_address_flags_ftype *get_pc_address_flags; - gdbarch_read_core_file_mappings_ftype *read_core_file_mappings; + 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; + const struct floatformat ** bfloat16_format = 0; + int half_bit = 0; + const struct floatformat ** half_format = 0; + int float_bit = 0; + const struct floatformat ** float_format = 0; + int double_bit = 0; + const struct floatformat ** double_format = 0; + int long_double_bit = 0; + 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 addr_bit = 0; + int dwarf2_addr_size = 0; + int char_signed = 0; + gdbarch_read_pc_ftype *read_pc = nullptr; + gdbarch_write_pc_ftype *write_pc = nullptr; + gdbarch_virtual_frame_pointer_ftype *virtual_frame_pointer = nullptr; + 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_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; + gdbarch_register_type_ftype *register_type = nullptr; + gdbarch_dummy_id_ftype *dummy_id = nullptr; + int deprecated_fp_regnum = 0; + gdbarch_push_dummy_call_ftype *push_dummy_call = nullptr; + int call_dummy_location = 0; + 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_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_get_longjmp_target_ftype *get_longjmp_target = nullptr; + int believe_pcc_promotion = 0; + gdbarch_convert_register_p_ftype *convert_register_p = nullptr; + 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_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_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_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; + CORE_ADDR decr_pc_after_break = 0; + CORE_ADDR deprecated_function_start_offset = 0; + gdbarch_remote_register_number_ftype *remote_register_number = nullptr; + 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_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; + 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; + 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; + 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_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_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; + 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_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags = nullptr; + gdbarch_register_reggroup_p_ftype *register_reggroup_p = nullptr; + 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; + gdbarch_find_memory_regions_ftype *find_memory_regions = nullptr; + gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries = nullptr; + gdbarch_core_xfer_shared_libraries_aix_ftype *core_xfer_shared_libraries_aix = nullptr; + gdbarch_core_pid_to_str_ftype *core_pid_to_str = nullptr; + gdbarch_core_thread_name_ftype *core_thread_name = nullptr; + gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo = nullptr; + 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; + 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_prepare_ftype *displaced_step_prepare = nullptr; + gdbarch_displaced_step_finish_ftype *displaced_step_finish = nullptr; + 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_overlay_update_ftype *overlay_update = nullptr; + gdbarch_core_read_description_ftype *core_read_description = nullptr; + int sofun_address_maybe_missing = 0; + gdbarch_process_record_ftype *process_record = nullptr; + gdbarch_process_record_signal_ftype *process_record_signal = nullptr; + gdbarch_gdb_signal_from_target_ftype *gdb_signal_from_target = nullptr; + gdbarch_gdb_signal_to_target_ftype *gdb_signal_to_target = nullptr; + gdbarch_get_siginfo_type_ftype *get_siginfo_type = nullptr; + gdbarch_record_special_symbol_ftype *record_special_symbol = nullptr; + gdbarch_get_syscall_number_ftype *get_syscall_number = nullptr; + const char * xml_syscall_file = 0; + struct syscalls_info * syscalls_info = 0; + const char *const * stap_integer_prefixes = 0; + const char *const * stap_integer_suffixes = 0; + const char *const * stap_register_prefixes = 0; + const char *const * stap_register_suffixes = 0; + const char *const * stap_register_indirection_prefixes = 0; + const char *const * stap_register_indirection_suffixes = 0; + const char * stap_gdb_register_prefix = 0; + const char * stap_gdb_register_suffix = 0; + gdbarch_stap_is_single_operand_ftype *stap_is_single_operand = nullptr; + gdbarch_stap_parse_special_token_ftype *stap_parse_special_token = nullptr; + gdbarch_stap_adjust_register_ftype *stap_adjust_register = nullptr; + gdbarch_dtrace_parse_probe_argument_ftype *dtrace_parse_probe_argument = nullptr; + gdbarch_dtrace_probe_is_enabled_ftype *dtrace_probe_is_enabled = nullptr; + gdbarch_dtrace_enable_probe_ftype *dtrace_enable_probe = nullptr; + 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; + const char * solib_symbols_extension = 0; + int has_dos_based_file_system = 0; + gdbarch_gen_return_address_ftype *gen_return_address = nullptr; + 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_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; + 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; }; /* Create a new ``struct gdbarch'' based on information provided by @@ -259,13 +259,7 @@ gdbarch_alloc (const struct gdbarch_info *info, { struct gdbarch *gdbarch; - /* Create an obstack for allocating all the per-architecture memory, - then use that to allocate the architecture vector. */ - struct obstack *obstack = XNEW (struct obstack); - obstack_init (obstack); - gdbarch = XOBNEW (obstack, struct gdbarch); - memset (gdbarch, 0, sizeof (*gdbarch)); - gdbarch->obstack = obstack; + gdbarch = new struct gdbarch; alloc_gdbarch_data (gdbarch); diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py index 0b084d568cb..deadf7964a6 100755 --- a/gdb/gdbarch.py +++ b/gdb/gdbarch.py @@ -257,29 +257,29 @@ with open("gdbarch.c", "w") as f: print("struct gdbarch", file=f) print("{", file=f) print(" /* Has this architecture been fully initialized? */", file=f) - print(" bool initialized_p;", file=f) + print(" bool initialized_p = false;", file=f) print(file=f) print(" /* An obstack bound to the lifetime of the architecture. */", file=f) - print(" struct obstack *obstack;", file=f) + print(" auto_obstack obstack;", file=f) print(file=f) print(" /* basic architectural information. */", file=f) for c in filter(info, components): print(f" {c.type} {c.name};", file=f) print(file=f) print(" /* target specific vector. */", file=f) - print(" struct gdbarch_tdep *tdep;", file=f) - print(" gdbarch_dump_tdep_ftype *dump_tdep;", file=f) + print(" struct gdbarch_tdep *tdep = nullptr;", file=f) + print(" gdbarch_dump_tdep_ftype *dump_tdep = nullptr;", file=f) print(file=f) print(" /* per-architecture data-pointers. */", file=f) - print(" unsigned nr_data;", file=f) - print(" void **data;", file=f) + print(" unsigned nr_data = 0;", file=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};", file=f) + print(f" {c.type} {c.name} = 0;", file=f) else: assert isinstance(c, Function) - print(f" gdbarch_{c.name}_ftype *{c.name};", file=f) + print(f" gdbarch_{c.name}_ftype *{c.name} = nullptr;", file=f) print("};", file=f) print(file=f) # @@ -294,15 +294,7 @@ with open("gdbarch.c", "w") as f: print("{", file=f) print(" struct gdbarch *gdbarch;", file=f) print("", file=f) - print( - " /* Create an obstack for allocating all the per-architecture memory,", file=f - ) - print(" then use that to allocate the architecture vector. */", file=f) - print(" struct obstack *obstack = XNEW (struct obstack);", file=f) - print(" obstack_init (obstack);", file=f) - print(" gdbarch = XOBNEW (obstack, struct gdbarch);", file=f) - print(" memset (gdbarch, 0, sizeof (*gdbarch));", file=f) - print(" gdbarch->obstack = obstack;", file=f) + print(" gdbarch = new struct gdbarch;", file=f) print(file=f) print(" alloc_gdbarch_data (gdbarch);", file=f) print(file=f) -- 2.34.1