]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Replace some xmalloc-family functions with XNEW-family ones
authorSimon Marchi <simon.marchi@ericsson.com>
Wed, 26 Aug 2015 21:16:07 +0000 (17:16 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Wed, 26 Aug 2015 21:18:12 +0000 (17:18 -0400)
This patch is part of the make-gdb-buildable-in-C++ effort.  The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family.  This avoids adding an explicit cast, so
it keeps the code a bit more readable.  Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.

I only changed calls that were obviously allocating memory for one or
multiple "objects".  Allocation of variable sizes (such as strings or
buffer handling) will be for later (and won't use XNEW).

  - xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
  - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
  - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
  - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
  - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num)
  - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
  - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num)
  - alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
  - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)

Some instances of xmalloc followed by memset to zero the buffer were
replaced by XCNEW or XCNEWVEC.

I regtested on x86-64, Ubuntu 14.04, but the patch touches many
architecture-specific files.  For those I'll have to rely on the
buildbot or people complaining that I broke their gdb.

gdb/ChangeLog:

* aarch64-linux-nat.c (aarch64_add_process): Likewise.
* aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
* ada-exp.y (write_ambiguous_var): Likewise.
* ada-lang.c (resolve_subexp): Likewise.
(user_select_syms): Likewise.
(assign_aggregate): Likewise.
(ada_evaluate_subexp): Likewise.
(cache_symbol): Likewise.
* addrmap.c (allocate_key): Likewise.
(addrmap_create_mutable): Likewise.
* aix-thread.c (sync_threadlists): Likewise.
* alpha-tdep.c (alpha_push_dummy_call): Likewise.
(alpha_gdbarch_init): Likewise.
* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
* arm-linux-nat.c (arm_linux_add_process): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* arm-tdep.c (push_stack_item): Likewise.
(arm_displaced_step_copy_insn): Likewise.
(arm_gdbarch_init): Likewise.
(_initialize_arm_tdep): Likewise.
* avr-tdep.c (push_stack_item): Likewise.
* ax-general.c (new_agent_expr): Likewise.
* block.c (block_initialize_namespace): Likewise.
* breakpoint.c (alloc_counted_command_line): Likewise.
(update_dprintf_command_list): Likewise.
(parse_breakpoint_sals): Likewise.
(decode_static_tracepoint_spec): Likewise.
(until_break_command): Likewise.
(clear_command): Likewise.
(update_global_location_list): Likewise.
(get_breakpoint_objfile_data) Likewise.
* btrace.c (ftrace_new_function): Likewise.
(btrace_set_insn_history): Likewise.
(btrace_set_call_history): Likewise.
* buildsym.c (add_symbol_to_list): Likewise.
(record_pending_block): Likewise.
(start_subfile): Likewise.
(start_buildsym_compunit): Likewise.
(push_subfile): Likewise.
(end_symtab_get_static_block): Likewise.
(buildsym_init): Likewise.
* cli/cli-cmds.c (source_command): Likewise.
* cli/cli-decode.c (add_cmd): Likewise.
* cli/cli-script.c (build_command_line): Likewise.
(setup_user_args): Likewise.
(realloc_body_list): Likewise.
(process_next_line): Likewise.
(copy_command_lines): Likewise.
* cli/cli-setshow.c (do_set_command): Likewise.
* coff-pe-read.c (read_pe_exported_syms): Likewise.
* coffread.c (coff_locate_sections): Likewise.
(coff_symtab_read): Likewise.
(coff_read_struct_type): Likewise.
* common/cleanups.c (make_my_cleanup2): Likewise.
* common/common-exceptions.c (throw_it): Likewise.
* common/filestuff.c (make_cleanup_close): Likewise.
* common/format.c (parse_format_string): Likewise.
* common/queue.h (DEFINE_QUEUE_P): Likewise.
* compile/compile-object-load.c (munmap_list_add): Likewise.
(compile_object_load): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (append_args): Likewise.
* corefile.c (specify_exec_file_hook): Likewise.
* cp-support.c (make_symbol_overload_list): Likewise.
* cris-tdep.c (push_stack_item): Likewise.
(cris_gdbarch_init): Likewise.
* ctf.c (ctf_trace_file_writer_new): Likewise.
* dbxread.c (init_header_files): Likewise.
(add_new_header_file): Likewise.
(init_bincl_list): Likewise.
(dbx_end_psymtab): Likewise.
(start_psymtab): Likewise.
(dbx_end_psymtab): Likewise.
* dcache.c (dcache_init): Likewise.
* dictionary.c (dict_create_hashed): Likewise.
(dict_create_hashed_expandable): Likewise.
(dict_create_linear): Likewise.
(dict_create_linear_expandable): Likewise.
* dtrace-probe.c (dtrace_process_dof_probe): Likewise.
* dummy-frame.c (register_dummy_frame_dtor): Likewise.
* dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
(decode_frame_entry_1): Likewise.
* dwarf2expr.c (new_dwarf_expr_context): Likewise.
* dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
* dwarf2read.c (dwarf2_has_info): Likewise.
(create_signatured_type_table_from_index): Likewise.
(dwarf2_read_index): Likewise.
(dw2_get_file_names_reader): Likewise.
(create_all_type_units): Likewise.
(read_cutu_die_from_dwo): Likewise.
(init_tu_and_read_dwo_dies): Likewise.
(init_cutu_and_read_dies): Likewise.
(create_all_comp_units): Likewise.
(queue_comp_unit): Likewise.
(inherit_abstract_dies): Likewise.
(read_call_site_scope): Likewise.
(dwarf2_add_field): Likewise.
(dwarf2_add_typedef): Likewise.
(dwarf2_add_member_fn): Likewise.
(attr_to_dynamic_prop): Likewise.
(abbrev_table_alloc_abbrev): Likewise.
(abbrev_table_read_table): Likewise.
(add_include_dir): Likewise.
(add_file_name): Likewise.
(dwarf_decode_line_header): Likewise.
(dwarf2_const_value_attr): Likewise.
(dwarf_alloc_block): Likewise.
(parse_macro_definition): Likewise.
(set_die_type): Likewise.
(write_psymtabs_to_index): Likewise.
(create_cus_from_index): Likewise.
(dwarf2_create_include_psymtab): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(build_type_psymtab_dependencies): Likewise.
(read_comp_units_from_section): Likewise.
(compute_compunit_symtab_includes): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(read_func_scope): Likewise.
(process_structure_scope): Likewise.
(mark_common_block_symbol_computed): Likewise.
(load_partial_dies): Likewise.
(dwarf2_symbol_mark_computed): Likewise.
* elfread.c (elf_symfile_segments): Likewise.
(elf_read_minimal_symbols): Likewise.
* environ.c (make_environ): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* event-loop.c (create_file_handler): Likewise.
(create_async_signal_handler): Likewise.
(create_async_event_handler): Likewise.
(create_timer): Likewise.
* exec.c (build_section_table): Likewise.
* fbsd-nat.c (fbsd_remember_child): Likewise.
* fork-child.c (fork_inferior): Likewise.
* frv-tdep.c (new_variant): Likewise.
* gdbarch.sh (gdbarch_alloc): Likewise.
(append_name): Likewise.
* gdbtypes.c (rank_function): Likewise.
(copy_type_recursive): Likewise.
(add_dyn_prop): Likewise.
* gnu-nat.c (make_proc): Likewise.
(make_inf): Likewise.
(gnu_write_inferior): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
(build_std_type_info_type): Likewise.
* guile/scm-param.c (compute_enum_list): Likewise.
* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
* guile/scm-value.c (gdbscm_value_call): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
(read_unwind_info): Likewise.
* ia64-tdep.c (ia64_gdbarch_init): Likewise.
* infcall.c (dummy_frame_context_saver_setup): Likewise.
(call_function_by_hand_dummy): Likewise.
* infcmd.c (step_once): Likewise.
(finish_forward): Likewise.
(attach_command): Likewise.
(notice_new_inferior): Likewise.
* inferior.c (add_inferior_silent): Likewise.
* infrun.c (add_displaced_stepping_state): Likewise.
(save_infcall_control_state): Likewise.
(save_inferior_ptid): Likewise.
(_initialize_infrun): Likewise.
* jit.c (bfd_open_from_target_memory): Likewise.
(jit_gdbarch_data_init): Likewise.
* language.c (add_language): Likewise.
* linespec.c (decode_line_2): Likewise.
* linux-nat.c (add_to_pid_list): Likewise.
(add_initial_lwp): Likewise.
* linux-thread-db.c (add_thread_db_info): Likewise.
(record_thread): Likewise.
(info_auto_load_libthread_db): Likewise.
* m32c-tdep.c (m32c_gdbarch_init): Likewise.
* m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
* m68k-tdep.c (m68k_gdbarch_init): Likewise.
* m88k-tdep.c (m88k_analyze_prologue): Likewise.
* macrocmd.c (macro_define_command): Likewise.
* macroexp.c (gather_arguments): Likewise.
* macroscope.c (sal_macro_scope): Likewise.
* macrotab.c (new_macro_table): Likewise.
* mdebugread.c (push_parse_stack): Likewise.
(parse_partial_symbols): Likewise.
(parse_symbol): Likewise.
(psymtab_to_symtab_1): Likewise.
(new_block): Likewise.
(new_psymtab): Likewise.
(mdebug_build_psymtabs): Likewise.
(add_pending): Likewise.
(elfmdebug_build_psymtabs): Likewise.
* mep-tdep.c (mep_gdbarch_init): Likewise.
* mi/mi-main.c (mi_execute_command): Likewise.
* mi/mi-parse.c (mi_parse_argv): Likewise.
* minidebug.c (lzma_open): Likewise.
* minsyms.c (terminate_minimal_symbol_table): Likewise.
* mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
* msp430-tdep.c (msp430_gdbarch_init): Likewise.
* mt-tdep.c (mt_registers_info): Likewise.
* nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
* nat/linux-btrace.c (linux_enable_bts): Likewise.
(linux_enable_pt): Likewise.
* nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
(linux_xfer_osdata_processgroups): Likewise.
* nios2-tdep.c (nios2_gdbarch_init): Likewise.
* nto-procfs.c (procfs_meminfo): Likewise.
* objc-lang.c (start_msglist): Likewise.
(selectors_info): Likewise.
(classes_info): Likewise.
(find_methods): Likewise.
* objfiles.c (allocate_objfile): Likewise.
(update_section_map): Likewise.
* osabi.c (gdbarch_register_osabi): Likewise.
(gdbarch_register_osabi_sniffer): Likewise.
* parse.c (start_arglist): Likewise.
* ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
(hwdebug_insert_point): Likewise.
* printcmd.c (display_command): Likewise.
(ui_printf): Likewise.
* procfs.c (create_procinfo): Likewise.
(load_syscalls): Likewise.
(proc_get_LDT_entry): Likewise.
(proc_update_threads): Likewise.
* prologue-value.c (make_pv_area): Likewise.
(pv_area_store): Likewise.
* psymtab.c (extend_psymbol_list): Likewise.
(init_psymbol_list): Likewise.
(allocate_psymtab): Likewise.
* python/py-inferior.c (add_thread_object): Likewise.
* python/py-param.c (compute_enum_values): Likewise.
* python/py-value.c (valpy_call): Likewise.
* python/py-varobj.c (py_varobj_iter_next): Likewise.
* python/python.c (ensure_python_env): Likewise.
* record-btrace.c (record_btrace_start_replaying): Likewise.
* record-full.c (record_full_reg_alloc): Likewise.
(record_full_mem_alloc): Likewise.
(record_full_end_alloc): Likewise.
(record_full_core_xfer_partial): Likewise.
* regcache.c (get_thread_arch_aspace_regcache): Likewise.
* remote-fileio.c (remote_fileio_init_fd_map): Likewise.
* remote-notif.c (remote_notif_state_allocate): Likewise.
* remote.c (demand_private_info): Likewise.
(remote_notif_stop_alloc_reply): Likewise.
(remote_enable_btrace): Likewise.
* reverse.c (save_bookmark_command): Likewise.
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
* rx-tdep.c (rx_gdbarch_init): Likewise.
* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
* ser-go32.c (dos_get_tty_state): Likewise.
(dos_copy_tty_state): Likewise.
* ser-mingw.c (ser_windows_open): Likewise.
(ser_console_wait_handle): Likewise.
(ser_console_get_tty_state): Likewise.
(make_pipe_state): Likewise.
(net_windows_open): Likewise.
* ser-unix.c (hardwire_get_tty_state): Likewise.
(hardwire_copy_tty_state): Likewise.
* solib-aix.c (solib_aix_new_lm_info): Likewise.
* solib-dsbt.c (dsbt_current_sos): Likewise.
(dsbt_relocate_main_executable): Likewise.
* solib-frv.c (frv_current_sos): Likewise.
(frv_relocate_main_executable): Likewise.
* solib-spu.c (spu_bfd_fopen): Likewise.
* solib-svr4.c (lm_info_read): Likewise.
(svr4_copy_library_list): Likewise.
(svr4_default_sos): Likewise.
* source.c (find_source_lines): Likewise.
(line_info): Likewise.
(add_substitute_path_rule): Likewise.
* spu-linux-nat.c (spu_bfd_open): Likewise.
* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
* stabsread.c (dbx_lookup_type): Likewise.
(read_type): Likewise.
(read_member_functions): Likewise.
(read_struct_fields): Likewise.
(read_baseclasses): Likewise.
(read_args): Likewise.
(_initialize_stabsread): Likewise.
* stack.c (func_command): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (addrs_section_sort): Likewise.
(addr_info_make_relative): Likewise.
(load_section_callback): Likewise.
(add_symbol_file_command): Likewise.
(init_filename_language_table): Likewise.
* symtab.c (create_filename_seen_cache): Likewise.
(sort_search_symbols_remove_dups): Likewise.
(search_symbols): Likewise.
* target.c (make_cleanup_restore_target_terminal): Likewise.
* thread.c (new_thread): Likewise.
(enable_thread_stack_temporaries): Likewise.
(make_cleanup_restore_current_thread): Likewise.
(thread_apply_all_command): Likewise.
* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
* top.c (gdb_readline_wrapper): Likewise.
* tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
* tracepoint.c (trace_find_line_command): Likewise.
(all_tracepoint_actions_and_cleanup): Likewise.
(make_cleanup_restore_current_traceframe): Likewise.
(get_uploaded_tp): Likewise.
(get_uploaded_tsv): Likewise.
* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
(tui_alloc_win_info): Likewise.
(tui_alloc_content): Likewise.
(tui_add_content_elements): Likewise.
* tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
(tui_set_disassem_content): Likewise.
* ui-file.c (ui_file_new): Likewise.
(stdio_file_new): Likewise.
(tee_file_new): Likewise.
* utils.c (make_cleanup_restore_integer): Likewise.
(add_internal_problem_command): Likewise.
* v850-tdep.c (v850_gdbarch_init): Likewise.
* valops.c (find_oload_champ): Likewise.
* value.c (allocate_value_lazy): Likewise.
(record_latest_value): Likewise.
(create_internalvar): Likewise.
* varobj.c (install_variable): Likewise.
(new_variable): Likewise.
(new_root_variable): Likewise.
(cppush): Likewise.
(_initialize_varobj): Likewise.
* windows-nat.c (windows_make_so): Likewise.
* x86-nat.c (x86_add_process): Likewise.
* xcoffread.c (arrange_linetable): Likewise.
(allocate_include_entry): Likewise.
(process_linenos): Likewise.
(SYMBOL_DUP): Likewise.
(xcoff_start_psymtab): Likewise.
(xcoff_end_psymtab): Likewise.
* xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.

gdb/gdbserver/ChangeLog:

* ax.c (gdb_parse_agent_expr): Likewise.
(compile_bytecodes): Likewise.
* dll.c (loaded_dll): Likewise.
* event-loop.c (append_callback_event): Likewise.
(create_file_handler): Likewise.
(create_file_event): Likewise.
* hostio.c (handle_open): Likewise.
* inferiors.c (add_thread): Likewise.
(add_process): Likewise.
* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
* linux-arm-low.c (arm_new_process): Likewise.
(arm_new_thread): Likewise.
* linux-low.c (add_to_pid_list): Likewise.
(linux_add_process): Likewise.
(handle_extended_wait): Likewise.
(add_lwp): Likewise.
(enqueue_one_deferred_signal): Likewise.
(enqueue_pending_signal): Likewise.
(linux_resume_one_lwp_throw): Likewise.
(linux_resume_one_thread): Likewise.
(linux_read_memory): Likewise.
(linux_write_memory): Likewise.
* linux-mips-low.c (mips_linux_new_process): Likewise.
(mips_linux_new_thread): Likewise.
(mips_add_watchpoint): Likewise.
* linux-x86-low.c (initialize_low_arch): Likewise.
* lynx-low.c (lynx_add_process): Likewise.
* mem-break.c (set_raw_breakpoint_at): Likewise.
(set_breakpoint): Likewise.
(add_condition_to_breakpoint): Likewise.
(add_commands_to_breakpoint): Likewise.
(clone_agent_expr): Likewise.
(clone_one_breakpoint): Likewise.
* regcache.c (new_register_cache): Likewise.
* remote-utils.c (look_up_one_symbol): Likewise.
* server.c (queue_stop_reply): Likewise.
(start_inferior): Likewise.
(queue_stop_reply_callback): Likewise.
(handle_target_event): Likewise.
* spu-low.c (fetch_ppc_memory): Likewise.
(store_ppc_memory): Likewise.
* target.c (set_target_ops): Likewise.
* thread-db.c (thread_db_load_search): Likewise.
(try_thread_db_load_1): Likewise.
* tracepoint.c (add_tracepoint): Likewise.
(add_tracepoint_action): Likewise.
(create_trace_state_variable): Likewise.
(cmd_qtdpsrc): Likewise.
(cmd_qtro): Likewise.
(add_while_stepping_state): Likewise.
* win32-low.c (child_add_thread): Likewise.
(get_image_name): Likewise.

177 files changed:
gdb/ChangeLog
gdb/aarch64-linux-nat.c
gdb/aarch64-tdep.c
gdb/ada-exp.y
gdb/ada-lang.c
gdb/addrmap.c
gdb/aix-thread.c
gdb/alpha-tdep.c
gdb/amd64-windows-tdep.c
gdb/arm-linux-nat.c
gdb/arm-linux-tdep.c
gdb/arm-tdep.c
gdb/avr-tdep.c
gdb/ax-general.c
gdb/block.c
gdb/breakpoint.c
gdb/btrace.c
gdb/buildsym.c
gdb/cli/cli-cmds.c
gdb/cli/cli-decode.c
gdb/cli/cli-script.c
gdb/cli/cli-setshow.c
gdb/coff-pe-read.c
gdb/coffread.c
gdb/common/cleanups.c
gdb/common/common-exceptions.c
gdb/common/filestuff.c
gdb/common/format.c
gdb/common/queue.h
gdb/compile/compile-object-load.c
gdb/compile/compile-object-run.c
gdb/compile/compile.c
gdb/corefile.c
gdb/cp-support.c
gdb/cris-tdep.c
gdb/ctf.c
gdb/dbxread.c
gdb/dcache.c
gdb/dictionary.c
gdb/dtrace-probe.c
gdb/dummy-frame.c
gdb/dwarf2-frame-tailcall.c
gdb/dwarf2-frame.c
gdb/dwarf2expr.c
gdb/dwarf2loc.c
gdb/dwarf2read.c
gdb/elfread.c
gdb/environ.c
gdb/eval.c
gdb/event-loop.c
gdb/exec.c
gdb/fbsd-nat.c
gdb/fork-child.c
gdb/frv-tdep.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/gdbserver/ChangeLog
gdb/gdbserver/ax.c
gdb/gdbserver/dll.c
gdb/gdbserver/event-loop.c
gdb/gdbserver/hostio.c
gdb/gdbserver/inferiors.c
gdb/gdbserver/linux-aarch64-low.c
gdb/gdbserver/linux-arm-low.c
gdb/gdbserver/linux-low.c
gdb/gdbserver/linux-mips-low.c
gdb/gdbserver/linux-x86-low.c
gdb/gdbserver/lynx-low.c
gdb/gdbserver/mem-break.c
gdb/gdbserver/regcache.c
gdb/gdbserver/remote-utils.c
gdb/gdbserver/server.c
gdb/gdbserver/spu-low.c
gdb/gdbserver/target.c
gdb/gdbserver/thread-db.c
gdb/gdbserver/tracepoint.c
gdb/gdbserver/win32-low.c
gdb/gdbtypes.c
gdb/gnu-nat.c
gdb/gnu-v3-abi.c
gdb/guile/scm-param.c
gdb/guile/scm-utils.c
gdb/guile/scm-value.c
gdb/h8300-tdep.c
gdb/ia64-tdep.c
gdb/infcall.c
gdb/infcmd.c
gdb/inferior.c
gdb/infrun.c
gdb/jit.c
gdb/language.c
gdb/linespec.c
gdb/linux-nat.c
gdb/linux-thread-db.c
gdb/m32c-tdep.c
gdb/m68hc11-tdep.c
gdb/m68k-tdep.c
gdb/m88k-tdep.c
gdb/macrocmd.c
gdb/macroexp.c
gdb/macroscope.c
gdb/macrotab.c
gdb/mdebugread.c
gdb/mep-tdep.c
gdb/mi/mi-main.c
gdb/mi/mi-parse.c
gdb/minidebug.c
gdb/mips-linux-nat.c
gdb/mips-tdep.c
gdb/mn10300-tdep.c
gdb/msp430-tdep.c
gdb/mt-tdep.c
gdb/nat/aarch64-linux.c
gdb/nat/linux-btrace.c
gdb/nat/linux-osdata.c
gdb/nios2-tdep.c
gdb/nto-procfs.c
gdb/objc-lang.c
gdb/objfiles.c
gdb/osabi.c
gdb/parse.c
gdb/ppc-linux-nat.c
gdb/printcmd.c
gdb/procfs.c
gdb/prologue-value.c
gdb/psymtab.c
gdb/python/py-inferior.c
gdb/python/py-param.c
gdb/python/py-value.c
gdb/python/py-varobj.c
gdb/python/python.c
gdb/record-btrace.c
gdb/record-full.c
gdb/regcache.c
gdb/remote-fileio.c
gdb/remote-notif.c
gdb/remote.c
gdb/reverse.c
gdb/rl78-tdep.c
gdb/rx-tdep.c
gdb/s390-linux-nat.c
gdb/ser-go32.c
gdb/ser-mingw.c
gdb/ser-unix.c
gdb/solib-aix.c
gdb/solib-dsbt.c
gdb/solib-frv.c
gdb/solib-spu.c
gdb/solib-svr4.c
gdb/source.c
gdb/spu-linux-nat.c
gdb/spu-tdep.c
gdb/stabsread.c
gdb/stack.c
gdb/stap-probe.c
gdb/symfile.c
gdb/symtab.c
gdb/target.c
gdb/thread.c
gdb/tic6x-tdep.c
gdb/top.c
gdb/tracefile-tfile.c
gdb/tracepoint.c
gdb/tui/tui-data.c
gdb/tui/tui-disasm.c
gdb/ui-file.c
gdb/utils.c
gdb/v850-tdep.c
gdb/valops.c
gdb/value.c
gdb/varobj.c
gdb/windows-nat.c
gdb/x86-nat.c
gdb/xcoffread.c
gdb/xml-support.c
gdb/xtensa-tdep.c

index b9493e44e1929ccbf0ccfd84c112cc09c28adc41..154228ff8351e30771902b7355f2689296aed87d 100644 (file)
@@ -1,3 +1,341 @@
+2015-08-26  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * aarch64-linux-nat.c (aarch64_add_process): Likewise.
+       * aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
+       * ada-exp.y (write_ambiguous_var): Likewise.
+       * ada-lang.c (resolve_subexp): Likewise.
+       (user_select_syms): Likewise.
+       (assign_aggregate): Likewise.
+       (ada_evaluate_subexp): Likewise.
+       (cache_symbol): Likewise.
+       * addrmap.c (allocate_key): Likewise.
+       (addrmap_create_mutable): Likewise.
+       * aix-thread.c (sync_threadlists): Likewise.
+       * alpha-tdep.c (alpha_push_dummy_call): Likewise.
+       (alpha_gdbarch_init): Likewise.
+       * amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
+       * arm-linux-nat.c (arm_linux_add_process): Likewise.
+       * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
+       * arm-tdep.c (push_stack_item): Likewise.
+       (arm_displaced_step_copy_insn): Likewise.
+       (arm_gdbarch_init): Likewise.
+       (_initialize_arm_tdep): Likewise.
+       * avr-tdep.c (push_stack_item): Likewise.
+       * ax-general.c (new_agent_expr): Likewise.
+       * block.c (block_initialize_namespace): Likewise.
+       * breakpoint.c (alloc_counted_command_line): Likewise.
+       (update_dprintf_command_list): Likewise.
+       (parse_breakpoint_sals): Likewise.
+       (decode_static_tracepoint_spec): Likewise.
+       (until_break_command): Likewise.
+       (clear_command): Likewise.
+       (update_global_location_list): Likewise.
+       (get_breakpoint_objfile_data) Likewise.
+       * btrace.c (ftrace_new_function): Likewise.
+       (btrace_set_insn_history): Likewise.
+       (btrace_set_call_history): Likewise.
+       * buildsym.c (add_symbol_to_list): Likewise.
+       (record_pending_block): Likewise.
+       (start_subfile): Likewise.
+       (start_buildsym_compunit): Likewise.
+       (push_subfile): Likewise.
+       (end_symtab_get_static_block): Likewise.
+       (buildsym_init): Likewise.
+       * cli/cli-cmds.c (source_command): Likewise.
+       * cli/cli-decode.c (add_cmd): Likewise.
+       * cli/cli-script.c (build_command_line): Likewise.
+       (setup_user_args): Likewise.
+       (realloc_body_list): Likewise.
+       (process_next_line): Likewise.
+       (copy_command_lines): Likewise.
+       * cli/cli-setshow.c (do_set_command): Likewise.
+       * coff-pe-read.c (read_pe_exported_syms): Likewise.
+       * coffread.c (coff_locate_sections): Likewise.
+       (coff_symtab_read): Likewise.
+       (coff_read_struct_type): Likewise.
+       * common/cleanups.c (make_my_cleanup2): Likewise.
+       * common/common-exceptions.c (throw_it): Likewise.
+       * common/filestuff.c (make_cleanup_close): Likewise.
+       * common/format.c (parse_format_string): Likewise.
+       * common/queue.h (DEFINE_QUEUE_P): Likewise.
+       * compile/compile-object-load.c (munmap_list_add): Likewise.
+       (compile_object_load): Likewise.
+       * compile/compile-object-run.c (compile_object_run): Likewise.
+       * compile/compile.c (append_args): Likewise.
+       * corefile.c (specify_exec_file_hook): Likewise.
+       * cp-support.c (make_symbol_overload_list): Likewise.
+       * cris-tdep.c (push_stack_item): Likewise.
+       (cris_gdbarch_init): Likewise.
+       * ctf.c (ctf_trace_file_writer_new): Likewise.
+       * dbxread.c (init_header_files): Likewise.
+       (add_new_header_file): Likewise.
+       (init_bincl_list): Likewise.
+       (dbx_end_psymtab): Likewise.
+       (start_psymtab): Likewise.
+       (dbx_end_psymtab): Likewise.
+       * dcache.c (dcache_init): Likewise.
+       * dictionary.c (dict_create_hashed): Likewise.
+       (dict_create_hashed_expandable): Likewise.
+       (dict_create_linear): Likewise.
+       (dict_create_linear_expandable): Likewise.
+       * dtrace-probe.c (dtrace_process_dof_probe): Likewise.
+       * dummy-frame.c (register_dummy_frame_dtor): Likewise.
+       * dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
+       * dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
+       (decode_frame_entry_1): Likewise.
+       * dwarf2expr.c (new_dwarf_expr_context): Likewise.
+       * dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
+       * dwarf2read.c (dwarf2_has_info): Likewise.
+       (create_signatured_type_table_from_index): Likewise.
+       (dwarf2_read_index): Likewise.
+       (dw2_get_file_names_reader): Likewise.
+       (create_all_type_units): Likewise.
+       (read_cutu_die_from_dwo): Likewise.
+       (init_tu_and_read_dwo_dies): Likewise.
+       (init_cutu_and_read_dies): Likewise.
+       (create_all_comp_units): Likewise.
+       (queue_comp_unit): Likewise.
+       (inherit_abstract_dies): Likewise.
+       (read_call_site_scope): Likewise.
+       (dwarf2_add_field): Likewise.
+       (dwarf2_add_typedef): Likewise.
+       (dwarf2_add_member_fn): Likewise.
+       (attr_to_dynamic_prop): Likewise.
+       (abbrev_table_alloc_abbrev): Likewise.
+       (abbrev_table_read_table): Likewise.
+       (add_include_dir): Likewise.
+       (add_file_name): Likewise.
+       (dwarf_decode_line_header): Likewise.
+       (dwarf2_const_value_attr): Likewise.
+       (dwarf_alloc_block): Likewise.
+       (parse_macro_definition): Likewise.
+       (set_die_type): Likewise.
+       (write_psymtabs_to_index): Likewise.
+       (create_cus_from_index): Likewise.
+       (dwarf2_create_include_psymtab): Likewise.
+       (process_psymtab_comp_unit_reader): Likewise.
+       (build_type_psymtab_dependencies): Likewise.
+       (read_comp_units_from_section): Likewise.
+       (compute_compunit_symtab_includes): Likewise.
+       (create_dwo_unit_in_dwp_v1): Likewise.
+       (create_dwo_unit_in_dwp_v2): Likewise.
+       (read_func_scope): Likewise.
+       (process_structure_scope): Likewise.
+       (mark_common_block_symbol_computed): Likewise.
+       (load_partial_dies): Likewise.
+       (dwarf2_symbol_mark_computed): Likewise.
+       * elfread.c (elf_symfile_segments): Likewise.
+       (elf_read_minimal_symbols): Likewise.
+       * environ.c (make_environ): Likewise.
+       * eval.c (evaluate_subexp_standard): Likewise.
+       * event-loop.c (create_file_handler): Likewise.
+       (create_async_signal_handler): Likewise.
+       (create_async_event_handler): Likewise.
+       (create_timer): Likewise.
+       * exec.c (build_section_table): Likewise.
+       * fbsd-nat.c (fbsd_remember_child): Likewise.
+       * fork-child.c (fork_inferior): Likewise.
+       * frv-tdep.c (new_variant): Likewise.
+       * gdbarch.sh (gdbarch_alloc): Likewise.
+       (append_name): Likewise.
+       * gdbtypes.c (rank_function): Likewise.
+       (copy_type_recursive): Likewise.
+       (add_dyn_prop): Likewise.
+       * gnu-nat.c (make_proc): Likewise.
+       (make_inf): Likewise.
+       (gnu_write_inferior): Likewise.
+       * gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
+       (build_std_type_info_type): Likewise.
+       * guile/scm-param.c (compute_enum_list): Likewise.
+       * guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
+       * guile/scm-value.c (gdbscm_value_call): Likewise.
+       * h8300-tdep.c (h8300_gdbarch_init): Likewise.
+       * hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
+       (read_unwind_info): Likewise.
+       * ia64-tdep.c (ia64_gdbarch_init): Likewise.
+       * infcall.c (dummy_frame_context_saver_setup): Likewise.
+       (call_function_by_hand_dummy): Likewise.
+       * infcmd.c (step_once): Likewise.
+       (finish_forward): Likewise.
+       (attach_command): Likewise.
+       (notice_new_inferior): Likewise.
+       * inferior.c (add_inferior_silent): Likewise.
+       * infrun.c (add_displaced_stepping_state): Likewise.
+       (save_infcall_control_state): Likewise.
+       (save_inferior_ptid): Likewise.
+       (_initialize_infrun): Likewise.
+       * jit.c (bfd_open_from_target_memory): Likewise.
+       (jit_gdbarch_data_init): Likewise.
+       * language.c (add_language): Likewise.
+       * linespec.c (decode_line_2): Likewise.
+       * linux-nat.c (add_to_pid_list): Likewise.
+       (add_initial_lwp): Likewise.
+       * linux-thread-db.c (add_thread_db_info): Likewise.
+       (record_thread): Likewise.
+       (info_auto_load_libthread_db): Likewise.
+       * m32c-tdep.c (m32c_gdbarch_init): Likewise.
+       * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
+       * m68k-tdep.c (m68k_gdbarch_init): Likewise.
+       * m88k-tdep.c (m88k_analyze_prologue): Likewise.
+       * macrocmd.c (macro_define_command): Likewise.
+       * macroexp.c (gather_arguments): Likewise.
+       * macroscope.c (sal_macro_scope): Likewise.
+       * macrotab.c (new_macro_table): Likewise.
+       * mdebugread.c (push_parse_stack): Likewise.
+       (parse_partial_symbols): Likewise.
+       (parse_symbol): Likewise.
+       (psymtab_to_symtab_1): Likewise.
+       (new_block): Likewise.
+       (new_psymtab): Likewise.
+       (mdebug_build_psymtabs): Likewise.
+       (add_pending): Likewise.
+       (elfmdebug_build_psymtabs): Likewise.
+       * mep-tdep.c (mep_gdbarch_init): Likewise.
+       * mi/mi-main.c (mi_execute_command): Likewise.
+       * mi/mi-parse.c (mi_parse_argv): Likewise.
+       * minidebug.c (lzma_open): Likewise.
+       * minsyms.c (terminate_minimal_symbol_table): Likewise.
+       * mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
+       * mips-tdep.c (mips_gdbarch_init): Likewise.
+       * mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
+       * msp430-tdep.c (msp430_gdbarch_init): Likewise.
+       * mt-tdep.c (mt_registers_info): Likewise.
+       * nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
+       * nat/linux-btrace.c (linux_enable_bts): Likewise.
+       (linux_enable_pt): Likewise.
+       * nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
+       (linux_xfer_osdata_processgroups): Likewise.
+       * nios2-tdep.c (nios2_gdbarch_init): Likewise.
+       * nto-procfs.c (procfs_meminfo): Likewise.
+       * objc-lang.c (start_msglist): Likewise.
+       (selectors_info): Likewise.
+       (classes_info): Likewise.
+       (find_methods): Likewise.
+       * objfiles.c (allocate_objfile): Likewise.
+       (update_section_map): Likewise.
+       * osabi.c (gdbarch_register_osabi): Likewise.
+       (gdbarch_register_osabi_sniffer): Likewise.
+       * parse.c (start_arglist): Likewise.
+       * ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
+       (hwdebug_insert_point): Likewise.
+       * printcmd.c (display_command): Likewise.
+       (ui_printf): Likewise.
+       * procfs.c (create_procinfo): Likewise.
+       (load_syscalls): Likewise.
+       (proc_get_LDT_entry): Likewise.
+       (proc_update_threads): Likewise.
+       * prologue-value.c (make_pv_area): Likewise.
+       (pv_area_store): Likewise.
+       * psymtab.c (extend_psymbol_list): Likewise.
+       (init_psymbol_list): Likewise.
+       (allocate_psymtab): Likewise.
+       * python/py-inferior.c (add_thread_object): Likewise.
+       * python/py-param.c (compute_enum_values): Likewise.
+       * python/py-value.c (valpy_call): Likewise.
+       * python/py-varobj.c (py_varobj_iter_next): Likewise.
+       * python/python.c (ensure_python_env): Likewise.
+       * record-btrace.c (record_btrace_start_replaying): Likewise.
+       * record-full.c (record_full_reg_alloc): Likewise.
+       (record_full_mem_alloc): Likewise.
+       (record_full_end_alloc): Likewise.
+       (record_full_core_xfer_partial): Likewise.
+       * regcache.c (get_thread_arch_aspace_regcache): Likewise.
+       * remote-fileio.c (remote_fileio_init_fd_map): Likewise.
+       * remote-notif.c (remote_notif_state_allocate): Likewise.
+       * remote.c (demand_private_info): Likewise.
+       (remote_notif_stop_alloc_reply): Likewise.
+       (remote_enable_btrace): Likewise.
+       * reverse.c (save_bookmark_command): Likewise.
+       * rl78-tdep.c (rl78_gdbarch_init): Likewise.
+       * rx-tdep.c (rx_gdbarch_init): Likewise.
+       * s390-linux-nat.c (s390_insert_watchpoint): Likewise.
+       * ser-go32.c (dos_get_tty_state): Likewise.
+       (dos_copy_tty_state): Likewise.
+       * ser-mingw.c (ser_windows_open): Likewise.
+       (ser_console_wait_handle): Likewise.
+       (ser_console_get_tty_state): Likewise.
+       (make_pipe_state): Likewise.
+       (net_windows_open): Likewise.
+       * ser-unix.c (hardwire_get_tty_state): Likewise.
+       (hardwire_copy_tty_state): Likewise.
+       * solib-aix.c (solib_aix_new_lm_info): Likewise.
+       * solib-dsbt.c (dsbt_current_sos): Likewise.
+       (dsbt_relocate_main_executable): Likewise.
+       * solib-frv.c (frv_current_sos): Likewise.
+       (frv_relocate_main_executable): Likewise.
+       * solib-spu.c (spu_bfd_fopen): Likewise.
+       * solib-svr4.c (lm_info_read): Likewise.
+       (svr4_copy_library_list): Likewise.
+       (svr4_default_sos): Likewise.
+       * source.c (find_source_lines): Likewise.
+       (line_info): Likewise.
+       (add_substitute_path_rule): Likewise.
+       * spu-linux-nat.c (spu_bfd_open): Likewise.
+       * spu-tdep.c (info_spu_dma_cmdlist): Likewise.
+       * stabsread.c (dbx_lookup_type): Likewise.
+       (read_type): Likewise.
+       (read_member_functions): Likewise.
+       (read_struct_fields): Likewise.
+       (read_baseclasses): Likewise.
+       (read_args): Likewise.
+       (_initialize_stabsread): Likewise.
+       * stack.c (func_command): Likewise.
+       * stap-probe.c (handle_stap_probe): Likewise.
+       * symfile.c (addrs_section_sort): Likewise.
+       (addr_info_make_relative): Likewise.
+       (load_section_callback): Likewise.
+       (add_symbol_file_command): Likewise.
+       (init_filename_language_table): Likewise.
+       * symtab.c (create_filename_seen_cache): Likewise.
+       (sort_search_symbols_remove_dups): Likewise.
+       (search_symbols): Likewise.
+       * target.c (make_cleanup_restore_target_terminal): Likewise.
+       * thread.c (new_thread): Likewise.
+       (enable_thread_stack_temporaries): Likewise.
+       (make_cleanup_restore_current_thread): Likewise.
+       (thread_apply_all_command): Likewise.
+       * tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
+       * top.c (gdb_readline_wrapper): Likewise.
+       * tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
+       * tracepoint.c (trace_find_line_command): Likewise.
+       (all_tracepoint_actions_and_cleanup): Likewise.
+       (make_cleanup_restore_current_traceframe): Likewise.
+       (get_uploaded_tp): Likewise.
+       (get_uploaded_tsv): Likewise.
+       * tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
+       (tui_alloc_win_info): Likewise.
+       (tui_alloc_content): Likewise.
+       (tui_add_content_elements): Likewise.
+       * tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
+       (tui_set_disassem_content): Likewise.
+       * ui-file.c (ui_file_new): Likewise.
+       (stdio_file_new): Likewise.
+       (tee_file_new): Likewise.
+       * utils.c (make_cleanup_restore_integer): Likewise.
+       (add_internal_problem_command): Likewise.
+       * v850-tdep.c (v850_gdbarch_init): Likewise.
+       * valops.c (find_oload_champ): Likewise.
+       * value.c (allocate_value_lazy): Likewise.
+       (record_latest_value): Likewise.
+       (create_internalvar): Likewise.
+       * varobj.c (install_variable): Likewise.
+       (new_variable): Likewise.
+       (new_root_variable): Likewise.
+       (cppush): Likewise.
+       (_initialize_varobj): Likewise.
+       * windows-nat.c (windows_make_so): Likewise.
+       * x86-nat.c (x86_add_process): Likewise.
+       * xcoffread.c (arrange_linetable): Likewise.
+       (allocate_include_entry): Likewise.
+       (process_linenos): Likewise.
+       (SYMBOL_DUP): Likewise.
+       (xcoff_start_psymtab): Likewise.
+       (xcoff_end_psymtab): Likewise.
+       * xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
+       * xtensa-tdep.c (xtensa_register_type): Likewise.
+       * gdbarch.c: Regenerate.
+       * gdbarch.h: Regenerate.
+
 2015-08-25  Don Breazeal  <donb@codesourcery.com>
 
        * infrun.c (follow_exec): Re-order operations for
index f6edb6841f6a4966c31a681b454da220ed934094..9747461c9d896c42222e308db9fede819b577751 100644 (file)
@@ -90,7 +90,7 @@ aarch64_add_process (pid_t pid)
 {
   struct aarch64_process_info *proc;
 
-  proc = xcalloc (1, sizeof (*proc));
+  proc = XCNEW (struct aarch64_process_info);
   proc->pid = pid;
 
   proc->next = aarch64_process_list;
index c722dc5c9cdc238fc48265745f7a356b031e0b00..9a44446fd3130658f09c043b4ba228379eb2c9a6 100644 (file)
@@ -2773,7 +2773,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       return best_arch->gdbarch;
     }
 
-  tdep = xcalloc (1, sizeof (struct gdbarch_tdep));
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   /* This should be low enough for everything.  */
index 2b671d44b6aaecbdfb2f2f2ca41c943bb3307556..1c45bcbc747d2e5c2b0a7c31c6eec074e91328ff 100644 (file)
@@ -1163,8 +1163,8 @@ static void
 write_ambiguous_var (struct parser_state *par_state,
                     const struct block *block, char *name, int len)
 {
-  struct symbol *sym =
-    obstack_alloc (&temp_parse_space, sizeof (struct symbol));
+  struct symbol *sym = XOBNEW (&temp_parse_space, struct symbol);
+
   memset (sym, 0, sizeof (struct symbol));
   SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN;
   SYMBOL_LINKAGE_NAME (sym) = obstack_copy0 (&temp_parse_space, name, len);
index 4d7d22ec057113c4a2c3842adb243a7246396e07..7e6b6dcaeb03c59c679e7aed558fbe34104dc433 100644 (file)
@@ -3300,7 +3300,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
       error (_("Unexpected operator during name resolution"));
     }
 
-  argvec = (struct value * *) alloca (sizeof (struct value *) * (nargs + 1));
+  argvec = XALLOCAVEC (struct value *, nargs + 1);
   for (i = 0; i < nargs; i += 1)
     argvec[i] = resolve_subexp (expp, pos, 1, NULL);
   argvec[i] = NULL;
@@ -3741,7 +3741,7 @@ int
 user_select_syms (struct block_symbol *syms, int nsyms, int max_results)
 {
   int i;
-  int *chosen = (int *) alloca (sizeof (int) * nsyms);
+  int *chosen = XALLOCAVEC (int , nsyms);
   int n_chosen;
   int first_choice = (max_results == 1) ? 1 : 2;
   const char *select_mode = multiple_symbols_select_mode ();
@@ -9790,7 +9790,7 @@ assign_aggregate (struct value *container,
 
   num_specs = num_component_specs (exp, *pos - 3);
   max_indices = 4 * num_specs + 4;
-  indices = alloca (max_indices * sizeof (indices[0]));
+  indices = XALLOCAVEC (LONGEST, max_indices);
   indices[0] = indices[1] = low_index - 1;
   indices[2] = indices[3] = high_index + 1;
   num_indices = 4;
@@ -10600,8 +10600,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
       /* Allocate arg vector, including space for the function to be
          called in argvec[0] and a terminating NULL.  */
       nargs = longest_to_int (exp->elts[pc + 1].longconst);
-      argvec =
-        (struct value **) alloca (sizeof (struct value *) * (nargs + 2));
+      argvec = XALLOCAVEC (struct value *, nargs + 2);
 
       if (exp->elts[*pos].opcode == OP_VAR_VALUE
           && SYMBOL_DOMAIN (exp->elts[pc + 5].symbol) == UNDEF_DOMAIN)
index 4eb08cd268087356b50bc1cbc3d7e3c62ec42de0..a124aeaaab363764a18d2f6875011476cba45565 100644 (file)
@@ -244,7 +244,7 @@ struct addrmap_mutable
 static splay_tree_key
 allocate_key (struct addrmap_mutable *map, CORE_ADDR addr)
 {
-  CORE_ADDR *key = obstack_alloc (map->obstack, sizeof (*key));
+  CORE_ADDR *key = XOBNEW (map->obstack, CORE_ADDR);
 
   *key = addr;
   return (splay_tree_key) key;
@@ -567,7 +567,7 @@ splay_compare_CORE_ADDR_ptr (splay_tree_key ak, splay_tree_key bk)
 struct addrmap *
 addrmap_create_mutable (struct obstack *obstack)
 {
-  struct addrmap_mutable *map = obstack_alloc (obstack, sizeof (*map));
+  struct addrmap_mutable *map = XOBNEW (obstack, struct addrmap_mutable);
 
   map->addrmap.funcs = &addrmap_mutable_funcs;
   map->obstack = obstack;
index e97f793911a5cd797086501891d21154d0b31ef8..8491dee0917c0d546927ef0371fb68c27e2e151b 100644 (file)
@@ -703,7 +703,7 @@ sync_threadlists (void)
 
   pcount = 0;
   psize = 1;
-  pbuf = (struct pd_thread *) xmalloc (psize * sizeof *pbuf);
+  pbuf = XNEWVEC (struct pd_thread, psize);
 
   for (cmd = PTHDB_LIST_FIRST;; cmd = PTHDB_LIST_NEXT)
     {
@@ -740,7 +740,7 @@ sync_threadlists (void)
 
   gcount = 0;
   iterate_over_threads (giter_count, &gcount);
-  g = gbuf = (struct thread_info **) xmalloc (gcount * sizeof *gbuf);
+  g = gbuf = XNEWVEC (struct thread_info *, gcount);
   iterate_over_threads (giter_accum, &g);
   qsort (gbuf, gcount, sizeof *gbuf, gcmp);
 
@@ -757,7 +757,7 @@ sync_threadlists (void)
       else if (gi == gcount)
        {
          thread = add_thread (ptid_build (infpid, 0, pbuf[pi].pthid));
-         thread->priv = xmalloc (sizeof (struct private_thread_info));
+         thread->priv = XNEW (struct private_thread_info);
          thread->priv->pdtid = pbuf[pi].pdtid;
          thread->priv->tid = pbuf[pi].tid;
          pi++;
@@ -789,7 +789,7 @@ sync_threadlists (void)
          else
            {
              thread = add_thread (pptid);
-             thread->priv = xmalloc (sizeof (struct private_thread_info));
+             thread->priv = XNEW (struct private_thread_info);
              thread->priv->pdtid = pdtid;
              thread->priv->tid = tid;
              pi++;
index d9b8517b2d84870626a40f2643d06a5cb132c478..765409687d9d9b6624541ec59056ad9b90b8d375 100644 (file)
@@ -305,8 +305,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       int len;
       int offset;
     };
-  struct alpha_arg *alpha_args
-    = (struct alpha_arg *) alloca (nargs * sizeof (struct alpha_arg));
+  struct alpha_arg *alpha_args = XALLOCAVEC (struct alpha_arg, nargs);
   struct alpha_arg *m_arg;
   gdb_byte arg_reg_buffer[ALPHA_REGISTER_SIZE * ALPHA_NUM_ARG_REGS];
   int required_arg_regs;
@@ -1754,7 +1753,7 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   if (arches != NULL)
     return arches->gdbarch;
 
-  tdep = xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   /* Lowest text address.  This is used by heuristic_proc_start()
index a092298654044abcb2ff49bc99e336f44175cbed..8b6e52bb6d82804ea949c074a2a33c5d23b28f6e 100644 (file)
@@ -158,7 +158,7 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs,
 {
   int reg_idx = 0;
   int i;
-  struct value **stack_args = alloca (nargs * sizeof (struct value *));
+  struct value **stack_args = XALLOCAVEC (struct value *, nargs);
   int num_stack_args = 0;
   int num_elements = 0;
   int element = 0;
@@ -169,7 +169,7 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs,
      in inferior memory.  So use a copy of the ARGS table, to avoid
      modifying the original one.  */
   {
-    struct value **args1 = alloca (nargs * sizeof (struct value *));
+    struct value **args1 = XALLOCAVEC (struct value *, nargs);
 
     memcpy (args1, args, nargs * sizeof (struct value *));
     sp = amd64_windows_adjust_args_passed_by_pointer (args1, nargs, sp);
index fb65a5d3f9b37ebc8dfea12bde568493cdcacebb..a63b181697cccc3a7f0267ffde3f866d7d4d6c3c 100644 (file)
@@ -791,7 +791,7 @@ arm_linux_add_process (pid_t pid)
 {
   struct arm_linux_process_info *proc;
 
-  proc = xcalloc (1, sizeof (*proc));
+  proc = XCNEW (struct arm_linux_process_info);
   proc->pid = pid;
 
   proc->next = arm_linux_process_list;
index 4772d822acd02cda42d0c290f818c81cb6c85a3b..b3ad8686e4852099bdcb4f508153b323a0eb5a45 100644 (file)
@@ -1100,8 +1100,7 @@ arm_linux_displaced_step_copy_insn (struct gdbarch *gdbarch,
                                    CORE_ADDR from, CORE_ADDR to,
                                    struct regcache *regs)
 {
-  struct displaced_step_closure *dsc
-    = xmalloc (sizeof (struct displaced_step_closure));
+  struct displaced_step_closure *dsc = XNEW (struct displaced_step_closure);
 
   /* Detect when we enter an (inaccessible by GDB) Linux kernel helper, and
      stop at the return location.  */
index 73f26b93da9d5fc1e095f88b03d75005e714b465..bcee29cca44652256d4b54adc9a9bc720b2fcb11 100644 (file)
@@ -3402,7 +3402,7 @@ static struct stack_item *
 push_stack_item (struct stack_item *prev, const void *contents, int len)
 {
   struct stack_item *si;
-  si = xmalloc (sizeof (struct stack_item));
+  si = XNEW (struct stack_item);
   si->data = xmalloc (len);
   si->len = len;
   si->prev = prev;
@@ -8737,8 +8737,8 @@ arm_displaced_step_copy_insn (struct gdbarch *gdbarch,
                              CORE_ADDR from, CORE_ADDR to,
                              struct regcache *regs)
 {
-  struct displaced_step_closure *dsc
-    = xmalloc (sizeof (struct displaced_step_closure));
+  struct displaced_step_closure *dsc = XNEW (struct displaced_step_closure);
+
   arm_process_displaced_insn (gdbarch, from, to, regs, dsc);
   arm_displaced_init_closure (gdbarch, from, to, dsc);
 
@@ -10290,7 +10290,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       return best_arch->gdbarch;
     }
 
-  tdep = xcalloc (1, sizeof (struct gdbarch_tdep));
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   /* Record additional information about the architecture we are defining.
@@ -10571,8 +10571,8 @@ _initialize_arm_tdep (void)
 
   /* Initialize the array that will be passed to
      add_setshow_enum_cmd().  */
-  valid_disassembly_styles
-    = xmalloc ((num_disassembly_options + 1) * sizeof (char *));
+  valid_disassembly_styles = XNEWVEC (const char *,
+                                     num_disassembly_options + 1);
   for (i = 0; i < num_disassembly_options; i++)
     {
       numregs = get_arm_regnames (i, &setname, &setdesc, &regnames);
index dff0be996175af715798d9559e571a3123026dcc..aaa2921e0152f84df6d730637083f50467484d1f 100644 (file)
@@ -1205,7 +1205,7 @@ static struct stack_item *
 push_stack_item (struct stack_item *prev, const bfd_byte *contents, int len)
 {
   struct stack_item *si;
-  si = xmalloc (sizeof (struct stack_item));
+  si = XNEW (struct stack_item);
   si->data = xmalloc (len);
   si->len = len;
   si->prev = prev;
index 485b2ad10307469c1c454b9298c2402f30713318..8dbe5729c019e30cfced004cc783dd5456d73a69 100644 (file)
@@ -41,7 +41,7 @@ static void generic_ext (struct agent_expr *x, enum agent_op op, int n);
 struct agent_expr *
 new_agent_expr (struct gdbarch *gdbarch, CORE_ADDR scope)
 {
-  struct agent_expr *x = xmalloc (sizeof (*x));
+  struct agent_expr *x = XNEW (struct agent_expr);
 
   x->len = 0;
   x->size = 1;                 /* Change this to a larger value once
index f4b8e4f234e080544292611abe7ab9359b42c7f8..3195baa441bc175dc31568aed78e1ba840ff482c 100644 (file)
@@ -351,8 +351,7 @@ block_initialize_namespace (struct block *block, struct obstack *obstack)
 {
   if (BLOCK_NAMESPACE (block) == NULL)
     {
-      BLOCK_NAMESPACE (block)
-       = obstack_alloc (obstack, sizeof (struct block_namespace_info));
+      BLOCK_NAMESPACE (block) = XOBNEW (obstack, struct block_namespace_info);
       BLOCK_NAMESPACE (block)->scope = NULL;
       BLOCK_NAMESPACE (block)->using_decl = NULL;
     }
index 052aeb963df2e0599f1340dcd8cab978a5213dad..50672222ee893eee7c73551f3116adad2e5859ad 100644 (file)
@@ -725,11 +725,11 @@ clear_breakpoint_hit_counts (void)
 static struct counted_command_line *
 alloc_counted_command_line (struct command_line *commands)
 {
-  struct counted_command_line *result
-    = xmalloc (sizeof (struct counted_command_line));
+  struct counted_command_line *result = XNEW (struct counted_command_line);
 
   result->refc = 1;
   result->commands = commands;
+
   return result;
 }
 
@@ -3395,8 +3395,8 @@ get_breakpoint_objfile_data (struct objfile *objfile)
   bp_objfile_data = objfile_data (objfile, breakpoint_objfile_key);
   if (bp_objfile_data == NULL)
     {
-      bp_objfile_data = obstack_alloc (&objfile->objfile_obstack,
-                                      sizeof (*bp_objfile_data));
+      bp_objfile_data =
+       XOBNEW (&objfile->objfile_obstack, struct breakpoint_objfile_data);
 
       memset (bp_objfile_data, 0, sizeof (*bp_objfile_data));
       set_objfile_data (objfile, breakpoint_objfile_key, bp_objfile_data);
@@ -9081,8 +9081,7 @@ update_dprintf_command_list (struct breakpoint *b)
   gdb_assert (printf_line != NULL);
   /* Manufacture a printf sequence.  */
   {
-    struct command_line *printf_cmd_line
-      = xmalloc (sizeof (struct command_line));
+    struct command_line *printf_cmd_line = XNEW (struct command_line);
 
     printf_cmd_line->control_type = simple_control;
     printf_cmd_line->body_count = 0;
@@ -9374,8 +9373,7 @@ parse_breakpoint_sals (const struct event_location *location,
              CORE_ADDR pc;
 
              init_sal (&sal);          /* Initialize to zeroes.  */
-             lsal.sals.sals = (struct symtab_and_line *)
-               xmalloc (sizeof (struct symtab_and_line));
+             lsal.sals.sals = XNEW (struct symtab_and_line);
 
              /* Set sal's pspace, pc, symtab, and line to the values
                 corresponding to the last call to print_frame_info.
@@ -9602,7 +9600,7 @@ decode_static_tracepoint_spec (const char **arg_p)
     error (_("No known static tracepoint marker named %s"), marker_str);
 
   sals.nelts = VEC_length(static_tracepoint_marker_p, markers);
-  sals.sals = xmalloc (sizeof *sals.sals * sals.nelts);
+  sals.sals = XNEWVEC (struct symtab_and_line, sals.nelts);
 
   for (i = 0; i < sals.nelts; i++)
     {
@@ -11592,8 +11590,8 @@ until_break_command (char *arg, int from_tty, int anywhere)
 
   if (target_can_async_p () && is_running (inferior_ptid))
     {
-      struct until_break_command_continuation_args *args;
-      args = xmalloc (sizeof (*args));
+      struct until_break_command_continuation_args *args =
+        XNEW (struct until_break_command_continuation_args);
 
       args->breakpoint = breakpoint;
       args->breakpoint2 = breakpoint2;
@@ -11827,8 +11825,7 @@ clear_command (char *arg, int from_tty)
     }
   else
     {
-      sals.sals = (struct symtab_and_line *)
-       xmalloc (sizeof (struct symtab_and_line));
+      sals.sals = XNEW (struct symtab_and_line);
       make_cleanup (xfree, sals.sals);
       init_sal (&sal);         /* Initialize to zeroes.  */
 
@@ -12245,7 +12242,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
     for (loc = b->loc; loc; loc = loc->next)
       bp_location_count++;
 
-  bp_location = xmalloc (sizeof (*bp_location) * bp_location_count);
+  bp_location = XNEWVEC (struct bp_location *, bp_location_count);
   locp = bp_location;
   ALL_BREAKPOINTS (b)
     for (loc = b->loc; loc; loc = loc->next)
index abdf639f23772fca53e7b68ab4ee73d24ac7990a..e205ea867c4e318009f0a36a0b197452e32c90dc 100644 (file)
@@ -193,7 +193,7 @@ ftrace_new_function (struct btrace_function *prev,
 {
   struct btrace_function *bfun;
 
-  bfun = xzalloc (sizeof (*bfun));
+  bfun = XCNEW (struct btrace_function);
 
   bfun->msym = mfun;
   bfun->sym = fun;
@@ -2196,7 +2196,7 @@ btrace_set_insn_history (struct btrace_thread_info *btinfo,
                         const struct btrace_insn_iterator *end)
 {
   if (btinfo->insn_history == NULL)
-    btinfo->insn_history = xzalloc (sizeof (*btinfo->insn_history));
+    btinfo->insn_history = XCNEW (struct btrace_insn_history);
 
   btinfo->insn_history->begin = *begin;
   btinfo->insn_history->end = *end;
@@ -2212,7 +2212,7 @@ btrace_set_call_history (struct btrace_thread_info *btinfo,
   gdb_assert (begin->btinfo == end->btinfo);
 
   if (btinfo->call_history == NULL)
-    btinfo->call_history = xzalloc (sizeof (*btinfo->call_history));
+    btinfo->call_history = XCNEW (struct btrace_call_history);
 
   btinfo->call_history->begin = *begin;
   btinfo->call_history->end = *end;
index 36ec62fd5abea7060788ba05060733f41612cdbe..54c1d0328b66c641ea798dd96fc2a9f1a52b3515 100644 (file)
@@ -232,7 +232,7 @@ add_symbol_to_list (struct symbol *symbol, struct pending **listhead)
        }
       else
        {
-         link = (struct pending *) xmalloc (sizeof (struct pending));
+         link = XNEW (struct pending);
        }
 
       link->next = *listhead;
@@ -550,8 +550,7 @@ record_pending_block (struct objfile *objfile, struct block *block,
   if (pending_blocks == NULL)
     obstack_init (&pending_block_obstack);
 
-  pblock = (struct pending_block *)
-    obstack_alloc (&pending_block_obstack, sizeof (struct pending_block));
+  pblock = XOBNEW (&pending_block_obstack, struct pending_block);
   pblock->block = block;
   if (opblock)
     {
@@ -705,7 +704,7 @@ start_subfile (const char *name)
 
   /* This subfile is not known.  Add an entry for it.  */
 
-  subfile = (struct subfile *) xmalloc (sizeof (struct subfile));
+  subfile = XNEW (struct subfile);
   memset (subfile, 0, sizeof (struct subfile));
   subfile->buildsym_compunit = buildsym_compunit;
 
@@ -773,8 +772,7 @@ start_buildsym_compunit (struct objfile *objfile, const char *comp_dir)
 {
   struct buildsym_compunit *bscu;
 
-  bscu = (struct buildsym_compunit *)
-    xmalloc (sizeof (struct buildsym_compunit));
+  bscu = XNEW (struct buildsym_compunit);
   memset (bscu, 0, sizeof (struct buildsym_compunit));
 
   bscu->objfile = objfile;
@@ -866,8 +864,7 @@ patch_subfile_names (struct subfile *subfile, char *name)
 void
 push_subfile (void)
 {
-  struct subfile_stack *tem
-    = (struct subfile_stack *) xmalloc (sizeof (struct subfile_stack));
+  struct subfile_stack *tem = XNEW (struct subfile_stack);
 
   tem->next = subfile_stack;
   subfile_stack = tem;
@@ -1265,7 +1262,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
       for (pb = pending_blocks; pb != NULL; pb = pb->next)
        count++;
 
-      barray = xmalloc (sizeof (*barray) * count);
+      barray = XNEWVEC (struct block *, count);
       back_to = make_cleanup (xfree, barray);
 
       bp = barray;
@@ -1768,8 +1765,7 @@ buildsym_init (void)
   if (context_stack == NULL)
     {
       context_stack_size = INITIAL_CONTEXT_STACK_SIZE;
-      context_stack = (struct context_stack *)
-       xmalloc (context_stack_size * sizeof (struct context_stack));
+      context_stack = XNEWVEC (struct context_stack, context_stack_size);
     }
 
   /* Ensure the really_free_pendings cleanup was called after
index bcd7802194c0d6edb658a5e714fb00f5e9dc831e..aa9a9a58d56a0819d1fda94c92c36e4ba2f47a71 100644 (file)
@@ -636,7 +636,7 @@ source_command (char *args, int from_tty)
 {
   struct cleanup *old_cleanups;
   char *file = args;
-  int *old_source_verbose = xmalloc (sizeof(int));
+  int *old_source_verbose = XNEW (int);
   int search_path = 0;
 
   *old_source_verbose = source_verbose;
index e4061571856189c9d01c13bc8489829c6dec6c36..f5b6fc479fdcaa8404216cc494e8a0b0c7bc7e5b 100644 (file)
@@ -192,8 +192,7 @@ struct cmd_list_element *
 add_cmd (const char *name, enum command_class theclass, cmd_cfunc_ftype *fun,
         const char *doc, struct cmd_list_element **list)
 {
-  struct cmd_list_element *c
-    = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
+  struct cmd_list_element *c = XNEW (struct cmd_list_element);
   struct cmd_list_element *p, *iter;
 
   /* Turn each alias of the old command into an alias of the new
index 4bd18a73b6f3f644711bd507d4ba81a244cd6bf7..1717240d68dcd7795b5007455ea61e30fa56ea25 100644 (file)
@@ -109,15 +109,12 @@ build_command_line (enum command_control_type type, char *args)
     error (_("if/while commands require arguments."));
   gdb_assert (args != NULL);
 
-  cmd = (struct command_line *) xmalloc (sizeof (struct command_line));
+  cmd = XNEW (struct command_line);
   cmd->next = NULL;
   cmd->control_type = type;
 
   cmd->body_count = 1;
-  cmd->body_list
-    = (struct command_line **) xmalloc (sizeof (struct command_line *)
-                                       * cmd->body_count);
-  memset (cmd->body_list, 0, sizeof (struct command_line *) * cmd->body_count);
+  cmd->body_list = XCNEWVEC (struct command_line *, cmd->body_count);
   cmd->line = xstrdup (args);
 
   return cmd;
@@ -722,7 +719,7 @@ setup_user_args (char *p)
   struct cleanup *old_chain;
   unsigned int arg_count = 0;
 
-  args = (struct user_args *) xmalloc (sizeof (struct user_args));
+  args = XNEW (struct user_args);
   memset (args, 0, sizeof (struct user_args));
 
   args->next = user_args;
@@ -918,11 +915,9 @@ realloc_body_list (struct command_line *command, int new_length)
   if (new_length <= n)
     return;
 
-  body_list = (struct command_line **)
-    xmalloc (sizeof (struct command_line *) * new_length);
+  body_list = XCNEWVEC (struct command_line *, new_length);
 
   memcpy (body_list, command->body_list, sizeof (struct command_line *) * n);
-  memset (body_list + n, 0, sizeof (struct command_line *) * (new_length - n));
 
   xfree (command->body_list);
   command->body_list = body_list;
@@ -1076,8 +1071,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
        }
       else if (p_end - p == 10 && startswith (p, "loop_break"))
        {
-         *command = (struct command_line *)
-           xmalloc (sizeof (struct command_line));
+         *command = XNEW (struct command_line);
          (*command)->next = NULL;
          (*command)->line = NULL;
          (*command)->control_type = break_control;
@@ -1086,8 +1080,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
        }
       else if (p_end - p == 13 && startswith (p, "loop_continue"))
        {
-         *command = (struct command_line *)
-           xmalloc (sizeof (struct command_line));
+         *command = XNEW (struct command_line);
          (*command)->next = NULL;
          (*command)->line = NULL;
          (*command)->control_type = continue_control;
@@ -1101,8 +1094,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
   if (!parse_commands || not_handled)
     {
       /* A normal command.  */
-      *command = (struct command_line *)
-       xmalloc (sizeof (struct command_line));
+      *command = XNEW (struct command_line);
       (*command)->next = NULL;
       (*command)->line = savestring (p, p_end - p);
       (*command)->control_type = simple_control;
@@ -1414,7 +1406,7 @@ copy_command_lines (struct command_line *cmds)
 
   if (cmds)
     {
-      result = (struct command_line *) xmalloc (sizeof (struct command_line));
+      result = XNEW (struct command_line);
 
       result->next = copy_command_lines (cmds->next);
       result->line = xstrdup (cmds->line);
@@ -1424,8 +1416,7 @@ copy_command_lines (struct command_line *cmds)
         {
           int i;
 
-          result->body_list = (struct command_line **)
-            xmalloc (sizeof (struct command_line *) * cmds->body_count);
+          result->body_list = XNEWVEC (struct command_line *, cmds->body_count);
 
           for (i = 0; i < cmds->body_count; i++)
             result->body_list[i] = copy_command_lines (cmds->body_list[i]);
index 8d01b52472d293fc43fac69c44226b083ce77a53..ca41d8e5bb58c2678add4cda66bb7a81780a3191 100644 (file)
@@ -475,8 +475,8 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
 
          p = p->prefix;
        }
-      cp = name = xmalloc (length);
-      cmds = xmalloc (sizeof (struct cmd_list_element *) * i);
+      cp = name = (char *) xmalloc (length);
+      cmds = XNEWVEC (struct cmd_list_element *, i);
 
       /* Track back through filed 'prefix' and cache them in CMDS.  */
       for (i = 0, p = c; p != NULL; i++)
index 451a15ccc41b3ee0159b7b2002d70c3ffb34a988..2154c3577ea47192ae874fd29fa6c99e83a73e59 100644 (file)
@@ -356,8 +356,7 @@ read_pe_exported_syms (struct objfile *objfile)
 
   char const *target = bfd_get_target (objfile->obfd);
 
-  section_data = xzalloc (PE_SECTION_TABLE_SIZE
-                        * sizeof (struct read_pe_section_data));
+  section_data = XCNEWVEC (struct read_pe_section_data, PE_SECTION_TABLE_SIZE);
 
   make_cleanup (free_current_contents, &section_data);
 
index c0f42670e72e9df24de996031a1f0e2f27f476a9..a5033d1666a8d26c06ad8cc768318eecd2a11345 100644 (file)
@@ -253,8 +253,7 @@ coff_locate_sections (bfd *abfd, asection *sectp, void *csip)
        {
          struct stab_section_list *n, **pn;
 
-         n = ((struct stab_section_list *)
-              xmalloc (sizeof (struct stab_section_list)));
+         n = XNEW (struct stab_section_list);
          n->section = sectp;
          n->next = NULL;
          for (pn = &csi->stabsects; *pn != NULL; pn = &(*pn)->next)
@@ -841,9 +840,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
   if (type_vector)             /* Get rid of previous one.  */
     xfree (type_vector);
   type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
-  type_vector = (struct type **)
-    xmalloc (type_vector_length * sizeof (struct type *));
-  memset (type_vector, 0, type_vector_length * sizeof (struct type *));
+  type_vector = XCNEWVEC (struct type *, type_vector_length);
 
   coff_start_symtab (objfile, "");
 
@@ -2102,7 +2099,7 @@ coff_read_struct_type (int index, int length, int lastsym,
        case C_MOU:
 
          /* Get space to record the next field's data.  */
-         newobj = (struct nextfield *) alloca (sizeof (struct nextfield));
+         newobj = XALLOCA (struct nextfield);
          newobj->next = list;
          list = newobj;
 
@@ -2119,7 +2116,7 @@ coff_read_struct_type (int index, int length, int lastsym,
        case C_FIELD:
 
          /* Get space to record the next field's data.  */
-         newobj = (struct nextfield *) alloca (sizeof (struct nextfield));
+         newobj = XALLOCA (struct nextfield);
          newobj->next = list;
          list = newobj;
 
index e57e4ccf546b3721cf766fa4ea37e3ae97991a02..2b48e867932d98f7a5913670940673d6aff0c77a 100644 (file)
@@ -79,8 +79,7 @@ static struct cleanup *
 make_my_cleanup2 (struct cleanup **pmy_chain, make_cleanup_ftype *function,
                  void *arg,  void (*free_arg) (void *))
 {
-  struct cleanup *newobj
-    = (struct cleanup *) xmalloc (sizeof (struct cleanup));
+  struct cleanup *newobj = XNEW (struct cleanup);
   struct cleanup *old_chain = *pmy_chain;
 
   newobj->next = *pmy_chain;
index b300a9d911efe606ccb28617607e67e7e46ce1cb..8ee96aba528232e9f510b617bb42d68cbcb7602c 100644 (file)
@@ -336,9 +336,8 @@ throw_it (enum return_reason reason, enum errors error, const char *fmt,
       int old_size = exception_messages_size;
 
       exception_messages_size = depth + 10;
-      exception_messages = (char **) xrealloc (exception_messages,
-                                              exception_messages_size
-                                              * sizeof (char *));
+      exception_messages = XRESIZEVEC (char *, exception_messages,
+                                      exception_messages_size);
       memset (exception_messages + old_size, 0,
              (exception_messages_size - old_size) * sizeof (char *));
     }
index 25ea8fa61b4fe81b04e1d03b8fb8387d5cb4fa4b..c829a8928321eda3ed28e809a1a619603104d3ff 100644 (file)
@@ -420,7 +420,7 @@ do_close_cleanup (void *arg)
 struct cleanup *
 make_cleanup_close (int fd)
 {
-  int *saved_fd = xmalloc (sizeof (fd));
+  int *saved_fd = XNEW (int);
 
   *saved_fd = fd;
   return make_cleanup_dtor (do_close_cleanup, saved_fd, xfree);
index deea93ca9536be8d616164b93d1fe255f19b764b..1602e53a295b36d443af221d580ec2cfe2c31dbc 100644 (file)
@@ -103,8 +103,7 @@ parse_format_string (const char **arg)
 
   max_pieces = strlen (string) + 2;
 
-  pieces = (struct format_piece *)
-    xmalloc (max_pieces * sizeof (struct format_piece));
+  pieces = XNEWVEC (struct format_piece, max_pieces);
 
   next_frag = 0;
 
index fce43493955be3d70a183719d619e3b3bb17bfd5..99459a0b3c53e392e04b9065999b3d618fea3c34 100644 (file)
@@ -125,8 +125,7 @@ QUEUE(TYPE)                                 \
 void                                                                   \
 queue_ ## TYPE ## _enque (QUEUE (TYPE) *q, TYPE v)                     \
 {                                                                      \
-  QUEUE_ELEM (TYPE) *p                                                 \
-    = xmalloc (sizeof (QUEUE_ELEM (TYPE)));                            \
+  QUEUE_ELEM (TYPE) *p = XNEW (QUEUE_ELEM (TYPE));                     \
                                                                        \
   gdb_assert (q != NULL);                                              \
   p->data = v;                                                         \
@@ -229,9 +228,8 @@ queue_ ## TYPE ## _iterate (QUEUE (TYPE) *q,                                \
 QUEUE (TYPE) *                                                         \
 queue_ ## TYPE ## _alloc (void (*free_func) (TYPE))                    \
 {                                                                      \
-  QUEUE (TYPE) *q;                                                     \
+  QUEUE (TYPE) *q = XNEW (QUEUE (TYPE));                               \
                                                                        \
-  q = (QUEUE (TYPE) *) xmalloc (sizeof (QUEUE (TYPE)));                \
   q->head = NULL;                                                      \
   q->tail = NULL;                                                      \
   q->free_func = free_func;                                            \
index 16775ab5a5136feb518a4dccb043e4c026cf2a0b..73868c2f5123a489e392fa64524fae2fc64a61dd 100644 (file)
@@ -46,7 +46,7 @@ struct munmap_list
 static void
 munmap_list_add (struct munmap_list **headp, CORE_ADDR addr, CORE_ADDR size)
 {
-  struct munmap_list *head_new = xmalloc (sizeof (*head_new));
+  struct munmap_list *head_new = XNEW (struct munmap_list);
 
   head_new->next = *headp;
   *headp = head_new;
@@ -827,7 +827,7 @@ compile_object_load (const char *object_file, const char *source_file,
 
   discard_cleanups (cleanups_free_objfile);
 
-  retval = xmalloc (sizeof (*retval));
+  retval = XNEW (struct compile_module);
   retval->objfile = objfile;
   retval->source_file = xstrdup (source_file);
   retval->func_sym = func_sym;
index ce47831c9988ce91fe15b57f92f09dc49e9d8531..6a39d13f50db0a73909b926cc4ad075ffa4fc271 100644 (file)
@@ -155,7 +155,7 @@ compile_object_run (struct compile_module *module)
       func_val = value_from_pointer (lookup_pointer_type (func_type),
                                   BLOCK_START (SYMBOL_BLOCK_VALUE (func_sym)));
 
-      vargs = alloca (sizeof (*vargs) * TYPE_NFIELDS (func_type));
+      vargs = XALLOCAVEC (struct value *, TYPE_NFIELDS (func_type));
       if (TYPE_NFIELDS (func_type) >= 1)
        {
          gdb_assert (regs_addr != 0);
index 499c53052f0e9fd9948315d3d05dbfd6fc16358d..d3ce3ba289d54d7ce89e6410216ee8bf4d55f97b 100644 (file)
@@ -338,7 +338,7 @@ append_args (int *argcp, char ***argvp, int argc, char **argv)
 {
   int argi;
 
-  *argvp = xrealloc (*argvp, (*argcp + argc + 1) * sizeof (**argvp));
+  *argvp = XRESIZEVEC (char *, *argvp, (*argcp + argc + 1));
 
   for (argi = 0; argi < argc; argi++)
     (*argvp)[(*argcp)++] = xstrdup (argv[argi]);
index 5246f7192ecaf0dc8ff0df360a5d4db4770d719d..eba36d6419aa76bc9d5be4c7a14cf328a4a6f1b3 100644 (file)
@@ -107,8 +107,7 @@ specify_exec_file_hook (void (*hook) (const char *))
        {
          /* If this is the first extra hook, initialize the hook
             array.  */
-         exec_file_extra_hooks = (hook_type *)
-           xmalloc (sizeof (hook_type));
+         exec_file_extra_hooks = XNEW (hook_type);
          exec_file_extra_hooks[0] = deprecated_exec_file_display_hook;
          deprecated_exec_file_display_hook = call_extra_exec_file_hooks;
          exec_file_hook_count = 1;
index dc0a0578d92f5473ea32c1ccef1c5d0cec9c6c5c..3995bcc32623b4bd33d0e70f380241a706785489 100644 (file)
@@ -1192,8 +1192,7 @@ make_symbol_overload_list (const char *func_name,
 
   sym_return_val_size = 100;
   sym_return_val_index = 0;
-  sym_return_val = xmalloc ((sym_return_val_size + 1) *
-                           sizeof (struct symbol *));
+  sym_return_val = XNEWVEC (struct symbol *, sym_return_val_size + 1);
   sym_return_val[0] = NULL;
 
   old_cleanups = make_cleanup (xfree, sym_return_val);
index 227388748d2afa5a50ae5bb4d6308c87f077eddb..88a64411176300415f97f79b7fac52ebb4df59c4 100644 (file)
@@ -671,8 +671,7 @@ struct stack_item
 static struct stack_item *
 push_stack_item (struct stack_item *prev, const gdb_byte *contents, int len)
 {
-  struct stack_item *si;
-  si = xmalloc (sizeof (struct stack_item));
+  struct stack_item *si = XNEW (struct stack_item);
   si->data = xmalloc (len);
   si->len = len;
   si->prev = prev;
@@ -4037,7 +4036,7 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     }
 
   /* No matching architecture was found.  Create a new one.  */
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   tdep->cris_version = usr_cmd_cris_version;
index 98913213084a5440fbb3ddd9157a7287294ed0ab..6e7c6163ba3b3324c88c68c8b0a057167b7dbf90 100644 (file)
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -810,8 +810,7 @@ static const struct trace_file_write_ops ctf_write_ops =
 struct trace_file_writer *
 ctf_trace_file_writer_new (void)
 {
-  struct ctf_trace_file_writer *writer
-    = xmalloc (sizeof (struct ctf_trace_file_writer));
+  struct ctf_trace_file_writer *writer = XNEW (struct ctf_trace_file_writer);
 
   writer->base.ops = &ctf_write_ops;
 
index fdf4e0916e21d5a3af66e11bb78f2f8f86084d69..029b98e38cf52ff3ce5e5aa68f462ebb984f344a 100644 (file)
@@ -319,7 +319,7 @@ void
 init_header_files (void)
 {
   n_allocated_this_object_header_files = 10;
-  this_object_header_files = (int *) xmalloc (10 * sizeof (int));
+  this_object_header_files = XNEWVEC (int, 10);
 }
 
 /* Add header file number I for this object file
@@ -405,9 +405,7 @@ add_new_header_file (char *name, int instance)
   hfile->name = xstrdup (name);
   hfile->instance = instance;
   hfile->length = 10;
-  hfile->vector
-    = (struct type **) xmalloc (10 * sizeof (struct type *));
-  memset (hfile->vector, 0, 10 * sizeof (struct type *));
+  hfile->vector = XCNEWVEC (struct type *, 10);
 
   add_this_object_header_file (i);
 }
@@ -890,8 +888,8 @@ static void
 init_bincl_list (int number, struct objfile *objfile)
 {
   bincls_allocated = number;
-  next_bincl = bincl_list = (struct header_file_location *)
-    xmalloc (bincls_allocated * sizeof (struct header_file_location));
+  next_bincl = bincl_list = XNEWVEC (struct header_file_location,
+                                    bincls_allocated);
 }
 
 /* Add a bincl to the list.  */
@@ -2170,8 +2168,8 @@ start_psymtab (struct objfile *objfile, char *filename, CORE_ADDR textlow,
     start_psymtab_common (objfile, filename, textlow,
                          global_syms, static_syms);
 
-  result->read_symtab_private = obstack_alloc (&objfile->objfile_obstack,
-                                              sizeof (struct symloc));
+  result->read_symtab_private =
+    XOBNEW (&objfile->objfile_obstack, struct symloc);
   LDSYMOFF (result) = ldsymoff;
   result->read_symtab = dbx_read_symtab;
   SYMBOL_SIZE (result) = symbol_size;
@@ -2288,9 +2286,9 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
   pst->number_of_dependencies = number_dependencies;
   if (number_dependencies)
     {
-      pst->dependencies = (struct partial_symtab **)
-       obstack_alloc (&objfile->objfile_obstack,
-                      number_dependencies * sizeof (struct partial_symtab *));
+      pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack,
+                                    struct partial_symtab *,
+                                    number_dependencies);
       memcpy (pst->dependencies, dependency_list,
              number_dependencies * sizeof (struct partial_symtab *));
     }
@@ -2303,7 +2301,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
        allocate_psymtab (include_list[i], objfile);
 
       subpst->read_symtab_private =
-       obstack_alloc (&objfile->objfile_obstack, sizeof (struct symloc));
+       XOBNEW (&objfile->objfile_obstack, struct symloc);
       LDSYMOFF (subpst) =
        LDSYMLEN (subpst) =
        subpst->textlow =
@@ -2311,9 +2309,8 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
 
       /* We could save slight bits of space by only making one of these,
          shared by the entire set of include files.  FIXME-someday.  */
-      subpst->dependencies = (struct partial_symtab **)
-       obstack_alloc (&objfile->objfile_obstack,
-                      sizeof (struct partial_symtab *));
+      subpst->dependencies =
+       XOBNEW (&objfile->objfile_obstack, struct partial_symtab *);
       subpst->dependencies[0] = pst;
       subpst->number_of_dependencies = 1;
 
index f87c529cfcd5c7980cda5d0edfcf055d8daad073..f1cabb02aebe2d15f2afd1d550b0a5cad6d0b487 100644 (file)
@@ -444,9 +444,7 @@ dcache_splay_tree_compare (splay_tree_key a, splay_tree_key b)
 DCACHE *
 dcache_init (void)
 {
-  DCACHE *dcache;
-
-  dcache = (DCACHE *) xmalloc (sizeof (*dcache));
+  DCACHE *dcache = XNEW (DCACHE);
 
   dcache->tree = splay_tree_new (dcache_splay_tree_compare,
                                 NULL,
index a16955a071a8d6e2ac5505f06380e395dc4e4828..1829b1280782ec790efd8b203611523dcdc2ad56 100644 (file)
@@ -361,7 +361,7 @@ dict_create_hashed (struct obstack *obstack,
   struct symbol **buckets;
   const struct pending *list_counter;
 
-  retval = obstack_alloc (obstack, sizeof (struct dictionary));
+  retval = XOBNEW (obstack, struct dictionary);
   DICT_VECTOR (retval) = &dict_hashed_vector;
 
   /* Calculate the number of symbols, and allocate space for them.  */
@@ -373,7 +373,7 @@ dict_create_hashed (struct obstack *obstack,
     }
   nbuckets = DICT_HASHTABLE_SIZE (nsyms);
   DICT_HASHED_NBUCKETS (retval) = nbuckets;
-  buckets = obstack_alloc (obstack, nbuckets * sizeof (struct symbol *));
+  buckets = XOBNEWVEC (obstack, struct symbol *, nbuckets);
   memset (buckets, 0, nbuckets * sizeof (struct symbol *));
   DICT_HASHED_BUCKETS (retval) = buckets;
 
@@ -399,9 +399,8 @@ dict_create_hashed (struct obstack *obstack,
 extern struct dictionary *
 dict_create_hashed_expandable (void)
 {
-  struct dictionary *retval;
+  struct dictionary *retval = XNEW (struct dictionary);
 
-  retval = xmalloc (sizeof (struct dictionary));
   DICT_VECTOR (retval) = &dict_hashed_expandable_vector;
   DICT_HASHED_NBUCKETS (retval) = DICT_EXPANDABLE_INITIAL_CAPACITY;
   DICT_HASHED_BUCKETS (retval) = xcalloc (DICT_EXPANDABLE_INITIAL_CAPACITY,
@@ -425,7 +424,7 @@ dict_create_linear (struct obstack *obstack,
   struct symbol **syms;
   const struct pending *list_counter;
 
-  retval = obstack_alloc (obstack, sizeof (struct dictionary));
+  retval = XOBNEW (obstack, struct dictionary);
   DICT_VECTOR (retval) = &dict_linear_vector;
 
   /* Calculate the number of symbols, and allocate space for them.  */
@@ -436,7 +435,7 @@ dict_create_linear (struct obstack *obstack,
       nsyms += list_counter->nsyms;
     }
   DICT_LINEAR_NSYMS (retval) = nsyms;
-  syms = obstack_alloc (obstack, nsyms * sizeof (struct symbol *));
+  syms = XOBNEWVEC (obstack, struct symbol *, nsyms );
   DICT_LINEAR_SYMS (retval) = syms;
 
   /* Now fill in the symbols.  Start filling in from the back, so as
@@ -464,9 +463,8 @@ dict_create_linear (struct obstack *obstack,
 struct dictionary *
 dict_create_linear_expandable (void)
 {
-  struct dictionary *retval;
+  struct dictionary *retval = XNEW (struct dictionary);
 
-  retval = xmalloc (sizeof (struct dictionary));
   DICT_VECTOR (retval) = &dict_linear_expandable_vector;
   DICT_LINEAR_NSYMS (retval) = 0;
   DICT_LINEAR_EXPANDABLE_CAPACITY (retval)
index 9816f0792a8ffe45fd3175ec086e344628be2a2a..03b6264e7cb61089746b577d733ffe89bc4e1529 100644 (file)
@@ -386,8 +386,8 @@ dtrace_process_dof_probe (struct objfile *objfile,
     {
       uint32_t probe_offset
        = ((uint32_t *) offtab)[DOF_UINT (dof, probe->dofpr_offidx) + i];
-      struct dtrace_probe *ret
-       = obstack_alloc (&objfile->per_bfd->storage_obstack, sizeof (*ret));
+      struct dtrace_probe *ret =
+       XOBNEW (&objfile->per_bfd->storage_obstack, struct dtrace_probe);
 
       ret->p.pops = &dtrace_probe_ops;
       ret->p.arch = gdbarch;
index f1d3de8346532eba72bcd859ab174dbb0ee00548..b6993a23a4590eac40664a4f68c3fcc044b75f79 100644 (file)
@@ -241,7 +241,7 @@ register_dummy_frame_dtor (struct frame_id dummy_id, ptid_t ptid,
   dp = lookup_dummy_frame (&id);
   gdb_assert (dp != NULL);
   d = *dp;
-  list = xmalloc (sizeof (*list));
+  list = XNEW (struct dummy_frame_dtor_list);
   list->next = d->dtor_list;
   d->dtor_list = list;
   list->dtor = dtor;
index f964ab263d5966df409341afdcb82ff735e6f641..e4a8112960639b558f107edd2d86ea2f951ee6d0 100644 (file)
@@ -91,11 +91,9 @@ cache_eq (const void *arg1, const void *arg2)
 static struct tailcall_cache *
 cache_new_ref1 (struct frame_info *next_bottom_frame)
 {
-  struct tailcall_cache *cache;
+  struct tailcall_cache *cache = XCNEW (struct tailcall_cache);
   void **slot;
 
-  cache = xzalloc (sizeof (*cache));
-
   cache->next_bottom_frame = next_bottom_frame;
   cache->refc = 1;
 
index 8fb2ac77718ff3b47b06269eaf142b9c5145bcbc..f9afe0b105b55907b798ad0f07b7e08030540fcd 100644 (file)
@@ -1908,9 +1908,7 @@ decode_frame_entry_1 (struct comp_unit *unit, const gdb_byte *start,
       if (find_cie (cie_table, cie_pointer))
        return end;
 
-      cie = (struct dwarf2_cie *)
-       obstack_alloc (&unit->objfile->objfile_obstack,
-                      sizeof (struct dwarf2_cie));
+      cie = XOBNEW (&unit->objfile->objfile_obstack, struct dwarf2_cie);
       cie->initial_instructions = NULL;
       cie->cie_pointer = cie_pointer;
 
@@ -2089,9 +2087,7 @@ decode_frame_entry_1 (struct comp_unit *unit, const gdb_byte *start,
       if (cie_pointer >= unit->dwarf_frame_size)
        return NULL;
 
-      fde = (struct dwarf2_fde *)
-       obstack_alloc (&unit->objfile->objfile_obstack,
-                      sizeof (struct dwarf2_fde));
+      fde = XOBNEW (&unit->objfile->objfile_obstack, struct dwarf2_fde);
       fde->cie = find_cie (cie_table, cie_pointer);
       if (fde->cie == NULL)
        {
@@ -2395,8 +2391,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
     }
 
   /* Copy fde_table to obstack: it is needed at runtime.  */
-  fde_table2 = (struct dwarf2_fde_table *)
-    obstack_alloc (&objfile->objfile_obstack, sizeof (*fde_table2));
+  fde_table2 = XOBNEW (&objfile->objfile_obstack, struct dwarf2_fde_table);
 
   if (fde_table.num_entries == 0)
     {
index 862a75387fe2a347f5648b5248bc384ca40fd597..09b56b6755711ed74d6a89ff0cdae4c967ff9178 100644 (file)
@@ -94,11 +94,10 @@ new_dwarf_expr_context (void)
 {
   struct dwarf_expr_context *retval;
 
-  retval = xcalloc (1, sizeof (struct dwarf_expr_context));
+  retval = XCNEW (struct dwarf_expr_context);
   retval->stack_len = 0;
   retval->stack_allocated = 10;
-  retval->stack = xmalloc (retval->stack_allocated
-                          * sizeof (struct dwarf_stack_value));
+  retval->stack = XNEWVEC (struct dwarf_stack_value, retval->stack_allocated);
   retval->num_pieces = 0;
   retval->pieces = 0;
   retval->max_recursion_depth = 0x100;
index efe4357422fc57f128295df942437d7fb076a83f..91cb99a76de99d35203ae4575a705d5c25c30506 100644 (file)
@@ -2908,7 +2908,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
   unsigned int addr_size_bits = 8 * addr_size;
   int bits_big_endian = gdbarch_bits_big_endian (arch);
 
-  offsets = xmalloc ((op_end - op_ptr) * sizeof (int));
+  offsets = XNEWVEC (int, op_end - op_ptr);
   cleanups = make_cleanup (xfree, offsets);
 
   for (i = 0; i < op_end - op_ptr; ++i)
index 77d37ddf83284ff77a51a1db8c0aa93d4ed1d937..6ec859556f1221a229eafd75e30edc342d6a0224 100644 (file)
@@ -2048,7 +2048,7 @@ dwarf2_has_info (struct objfile *objfile,
     {
       /* Initialize per-objfile state.  */
       struct dwarf2_per_objfile *data
-       = obstack_alloc (&objfile->objfile_obstack, sizeof (*data));
+       = XOBNEW (&objfile->objfile_obstack, struct dwarf2_per_objfile);
 
       memset (data, 0, sizeof (*data));
       set_objfile_data (objfile, dwarf2_objfile_data_key, data);
@@ -2819,10 +2819,9 @@ create_cus_from_index (struct objfile *objfile,
   struct dwz_file *dwz;
 
   dwarf2_per_objfile->n_comp_units = (cu_list_elements + dwz_elements) / 2;
-  dwarf2_per_objfile->all_comp_units
-    = obstack_alloc (&objfile->objfile_obstack,
-                    dwarf2_per_objfile->n_comp_units
-                    * sizeof (struct dwarf2_per_cu_data *));
+  dwarf2_per_objfile->all_comp_units =
+    XOBNEWVEC (&objfile->objfile_obstack, struct dwarf2_per_cu_data *,
+              dwarf2_per_objfile->n_comp_units);
 
   create_cus_from_index_list (objfile, cu_list, cu_list_elements,
                              &dwarf2_per_objfile->info, 0, 0);
@@ -2849,9 +2848,8 @@ create_signatured_type_table_from_index (struct objfile *objfile,
   dwarf2_per_objfile->n_type_units
     = dwarf2_per_objfile->n_allocated_type_units
     = elements / 3;
-  dwarf2_per_objfile->all_type_units
-    = xmalloc (dwarf2_per_objfile->n_type_units
-              * sizeof (struct signatured_type *));
+  dwarf2_per_objfile->all_type_units =
+    XNEWVEC (struct signatured_type *, dwarf2_per_objfile->n_type_units);
 
   sig_types_hash = allocate_signatured_type_table (objfile);
 
@@ -3230,7 +3228,7 @@ dwarf2_read_index (struct objfile *objfile)
 
   create_addrmap_from_index (objfile, &local_map);
 
-  map = obstack_alloc (&objfile->objfile_obstack, sizeof (struct mapped_index));
+  map = XOBNEW (&objfile->objfile_obstack, struct mapped_index);
   *map = local_map;
 
   dwarf2_per_objfile->index_table = map;
@@ -3314,7 +3312,7 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
       return;
     }
 
-  qfn = obstack_alloc (&objfile->objfile_obstack, sizeof (*qfn));
+  qfn = XOBNEW (&objfile->objfile_obstack, struct quick_file_names);
   qfn->hash.dwo_unit = cu->dwo_unit;
   qfn->hash.line_offset.sect_off = line_offset;
   gdb_assert (slot != NULL);
@@ -3323,8 +3321,8 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
   find_file_and_directory (comp_unit_die, cu, &name, &comp_dir);
 
   qfn->num_file_names = lh->num_file_names;
-  qfn->file_names = obstack_alloc (&objfile->objfile_obstack,
-                                  lh->num_file_names * sizeof (char *));
+  qfn->file_names =
+    XOBNEWVEC (&objfile->objfile_obstack, const char *, lh->num_file_names);
   for (i = 0; i < lh->num_file_names; ++i)
     qfn->file_names[i] = file_full_name (i + 1, lh, comp_dir);
   qfn->real_names = NULL;
@@ -4506,9 +4504,8 @@ dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
   subpst->textlow = 0;
   subpst->texthigh = 0;
 
-  subpst->dependencies = (struct partial_symtab **)
-    obstack_alloc (&objfile->objfile_obstack,
-                   sizeof (struct partial_symtab *));
+  subpst->dependencies
+    = XOBNEW (&objfile->objfile_obstack, struct partial_symtab *);
   subpst->dependencies[0] = pst;
   subpst->number_of_dependencies = 1;
 
@@ -4780,9 +4777,8 @@ create_all_type_units (struct objfile *objfile)
   dwarf2_per_objfile->n_type_units
     = dwarf2_per_objfile->n_allocated_type_units
     = htab_elements (types_htab);
-  dwarf2_per_objfile->all_type_units
-    = xmalloc (dwarf2_per_objfile->n_type_units
-              * sizeof (struct signatured_type *));
+  dwarf2_per_objfile->all_type_units =
+    XNEWVEC (struct signatured_type *, dwarf2_per_objfile->n_type_units);
   iter = &dwarf2_per_objfile->all_type_units[0];
   htab_traverse_noresize (types_htab, add_signatured_type_cu_to_table, &iter);
   gdb_assert (iter - &dwarf2_per_objfile->all_type_units[0]
@@ -5130,8 +5126,7 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu,
   else if (stub_comp_dir != NULL)
     {
       /* Reconstruct the comp_dir attribute to simplify the code below.  */
-      comp_dir = (struct attribute *)
-       obstack_alloc (&cu->comp_unit_obstack, sizeof (*comp_dir));
+      comp_dir = XOBNEW (&cu->comp_unit_obstack, struct attribute);
       comp_dir->name = DW_AT_comp_dir;
       comp_dir->form = DW_FORM_string;
       DW_STRING_IS_CANONICAL (comp_dir) = 0;
@@ -5349,7 +5344,7 @@ init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu,
     {
       /* If !use_existing_cu, this_cu->cu must be NULL.  */
       gdb_assert (this_cu->cu == NULL);
-      cu = xmalloc (sizeof (*cu));
+      cu = XNEW (struct dwarf2_cu);
       init_one_comp_unit (cu, this_cu);
       /* If an error occurs while loading, release our storage.  */
       free_cu_cleanup = make_cleanup (free_heap_comp_unit, cu);
@@ -5486,7 +5481,7 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
     {
       /* If !use_existing_cu, this_cu->cu must be NULL.  */
       gdb_assert (this_cu->cu == NULL);
-      cu = xmalloc (sizeof (*cu));
+      cu = XNEW (struct dwarf2_cu);
       init_one_comp_unit (cu, this_cu);
       /* If an error occurs while loading, release our storage.  */
       free_cu_cleanup = make_cleanup (free_heap_comp_unit, cu);
@@ -6027,8 +6022,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
       /* Fill in 'dependencies' here; we fill in 'users' in a
         post-pass.  */
       pst->number_of_dependencies = len;
-      pst->dependencies = obstack_alloc (&objfile->objfile_obstack,
-                                        len * sizeof (struct symtab *));
+      pst->dependencies =
+       XOBNEWVEC (&objfile->objfile_obstack, struct partial_symtab *, len);
       for (i = 0;
           VEC_iterate (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs,
                        i, iter);
@@ -6299,8 +6294,8 @@ build_type_psymtab_dependencies (void **slot, void *info)
   gdb_assert (IS_TYPE_UNIT_GROUP (per_cu));
 
   pst->number_of_dependencies = len;
-  pst->dependencies = obstack_alloc (&objfile->objfile_obstack,
-                                    len * sizeof (struct psymtab *));
+  pst->dependencies =
+    XOBNEWVEC (&objfile->objfile_obstack, struct partial_symtab *, len);
   for (i = 0;
        VEC_iterate (sig_type_ptr, tu_group->tus, i, iter);
        ++i)
@@ -6565,8 +6560,7 @@ read_comp_units_from_section (struct objfile *objfile,
       length = read_initial_length (abfd, info_ptr, &initial_length_size);
 
       /* Save the compilation unit for later lookup.  */
-      this_cu = obstack_alloc (&objfile->objfile_obstack,
-                              sizeof (struct dwarf2_per_cu_data));
+      this_cu = XOBNEW (&objfile->objfile_obstack, struct dwarf2_per_cu_data);
       memset (this_cu, 0, sizeof (*this_cu));
       this_cu->offset = offset;
       this_cu->length = length + initial_length_size;
@@ -6601,8 +6595,7 @@ create_all_comp_units (struct objfile *objfile)
 
   n_comp_units = 0;
   n_allocated = 10;
-  all_comp_units = xmalloc (n_allocated
-                           * sizeof (struct dwarf2_per_cu_data *));
+  all_comp_units = XNEWVEC (struct dwarf2_per_cu_data *, n_allocated);
 
   read_comp_units_from_section (objfile, &dwarf2_per_objfile->info, 0,
                                &n_allocated, &n_comp_units, &all_comp_units);
@@ -6613,9 +6606,9 @@ create_all_comp_units (struct objfile *objfile)
                                  &n_allocated, &n_comp_units,
                                  &all_comp_units);
 
-  dwarf2_per_objfile->all_comp_units
-    = obstack_alloc (&objfile->objfile_obstack,
-                    n_comp_units * sizeof (struct dwarf2_per_cu_data *));
+  dwarf2_per_objfile->all_comp_units = XOBNEWVEC (&objfile->objfile_obstack,
+                                                 struct dwarf2_per_cu_data *,
+                                                 n_comp_units);
   memcpy (dwarf2_per_objfile->all_comp_units, all_comp_units,
          n_comp_units * sizeof (struct dwarf2_per_cu_data *));
   xfree (all_comp_units);
@@ -7460,7 +7453,7 @@ queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
   struct dwarf2_queue_item *item;
 
   per_cu->queued = 1;
-  item = xmalloc (sizeof (*item));
+  item = XNEW (struct dwarf2_queue_item);
   item->per_cu = per_cu;
   item->pretend_language = pretend_language;
   item->next = NULL;
@@ -7973,8 +7966,8 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu)
       /* Now we have a transitive closure of all the included symtabs.  */
       len = VEC_length (compunit_symtab_ptr, result_symtabs);
       cust->includes
-       = obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack,
-                        (len + 1) * sizeof (struct compunit_symtab *));
+       = XOBNEWVEC (&dwarf2_per_objfile->objfile->objfile_obstack,
+                    struct compunit_symtab *, len + 1);
       for (ix = 0;
           VEC_iterate (compunit_symtab_ptr, result_symtabs, ix,
                        compunit_symtab_iter);
@@ -10148,8 +10141,8 @@ create_dwo_unit_in_dwp_v1 (struct dwp_file *dwp_file,
   dwo_unit = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct dwo_unit);
   dwo_unit->dwo_file = dwo_file;
   dwo_unit->signature = signature;
-  dwo_unit->section = obstack_alloc (&objfile->objfile_obstack,
-                                    sizeof (struct dwarf2_section_info));
+  dwo_unit->section =
+    XOBNEW (&objfile->objfile_obstack, struct dwarf2_section_info);
   *dwo_unit->section = sections.info_or_types;
   /* dwo_unit->{offset,length,type_offset_in_tu} are set later.  */
 
@@ -10362,8 +10355,8 @@ create_dwo_unit_in_dwp_v2 (struct dwp_file *dwp_file,
   dwo_unit = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct dwo_unit);
   dwo_unit->dwo_file = dwo_file;
   dwo_unit->signature = signature;
-  dwo_unit->section = obstack_alloc (&objfile->objfile_obstack,
-                                    sizeof (struct dwarf2_section_info));
+  dwo_unit->section =
+    XOBNEW (&objfile->objfile_obstack, struct dwarf2_section_info);
   *dwo_unit->section = create_dwp_v2_section (is_debug_types
                                              ? &dwp_file->sections.types
                                              : &dwp_file->sections.info,
@@ -11223,7 +11216,7 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
       child_die = sibling_die (child_die);
       die_children_count++;
     }
-  offsets = xmalloc (sizeof (*offsets) * die_children_count);
+  offsets = XNEWVEC (sect_offset, die_children_count);
   cleanups = make_cleanup (xfree, offsets);
 
   offsets_end = offsets;
@@ -11479,9 +11472,8 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 
       templ_func->n_template_arguments = VEC_length (symbolp, template_args);
       templ_func->template_arguments
-       = obstack_alloc (&objfile->objfile_obstack,
-                        (templ_func->n_template_arguments
-                         * sizeof (struct symbol *)));
+        = XOBNEWVEC (&objfile->objfile_obstack, struct symbol *,
+                    templ_func->n_template_arguments);
       memcpy (templ_func->template_arguments,
              VEC_address (symbolp, template_args),
              (templ_func->n_template_arguments * sizeof (struct symbol *)));
@@ -11689,7 +11681,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
     {
       struct dwarf2_locexpr_baton *dlbaton;
 
-      dlbaton = obstack_alloc (&objfile->objfile_obstack, sizeof (*dlbaton));
+      dlbaton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
       dlbaton->data = DW_BLOCK (attr)->data;
       dlbaton->size = DW_BLOCK (attr)->size;
       dlbaton->per_cu = cu->per_cu;
@@ -12456,7 +12448,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
   const char *fieldname = "";
 
   /* Allocate a new field list entry and link it in.  */
-  new_field = (struct nextfield *) xmalloc (sizeof (struct nextfield));
+  new_field = XNEW (struct nextfield);
   make_cleanup (xfree, new_field);
   memset (new_field, 0, sizeof (struct nextfield));
 
@@ -12642,7 +12634,7 @@ dwarf2_add_typedef (struct field_info *fip, struct die_info *die,
   char *fieldname = "";
 
   /* Allocate a new field list entry and link it in.  */
-  new_field = xzalloc (sizeof (*new_field));
+  new_field = XCNEW (struct typedef_field_list);
   make_cleanup (xfree, new_field);
 
   gdb_assert (die->tag == DW_TAG_typedef);
@@ -12846,7 +12838,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
 
   /* Create a new member function field and chain it to the field list
      entry.  */
-  new_fnfield = (struct nextfnfield *) xmalloc (sizeof (struct nextfnfield));
+  new_fnfield = XNEW (struct nextfnfield);
   make_cleanup (xfree, new_fnfield);
   memset (new_fnfield, 0, sizeof (struct nextfnfield));
   new_fnfield->next = flp->head;
@@ -13303,9 +13295,9 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
          TYPE_N_TEMPLATE_ARGUMENTS (type)
            = VEC_length (symbolp, template_args);
          TYPE_TEMPLATE_ARGUMENTS (type)
-           = obstack_alloc (&objfile->objfile_obstack,
-                            (TYPE_N_TEMPLATE_ARGUMENTS (type)
-                             * sizeof (struct symbol *)));
+           = XOBNEWVEC (&objfile->objfile_obstack,
+                        struct symbol *,
+                        TYPE_N_TEMPLATE_ARGUMENTS (type));
          memcpy (TYPE_TEMPLATE_ARGUMENTS (type),
                  VEC_address (symbolp, template_args),
                  (TYPE_N_TEMPLATE_ARGUMENTS (type)
@@ -13899,8 +13891,7 @@ mark_common_block_symbol_computed (struct symbol *sym,
   gdb_assert (attr_form_is_block (member_loc)
              || attr_form_is_constant (member_loc));
 
-  baton = obstack_alloc (&objfile->objfile_obstack,
-                        sizeof (struct dwarf2_locexpr_baton));
+  baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
   baton->per_cu = cu->per_cu;
   gdb_assert (baton->per_cu);
 
@@ -14813,7 +14804,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
 
   if (attr_form_is_block (attr))
     {
-      baton = obstack_alloc (obstack, sizeof (*baton));
+      baton = XOBNEW (obstack, struct dwarf2_property_baton);
       baton->referenced_type = NULL;
       baton->locexpr.per_cu = cu->per_cu;
       baton->locexpr.size = DW_BLOCK (attr)->size;
@@ -14841,7 +14832,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
          case DW_AT_location:
            if (attr_form_is_section_offset (target_attr))
              {
-               baton = obstack_alloc (obstack, sizeof (*baton));
+               baton = XOBNEW (obstack, struct dwarf2_property_baton);
                baton->referenced_type = die_type (target_die, target_cu);
                fill_in_loclist_baton (cu, &baton->loclist, target_attr);
                prop->data.baton = baton;
@@ -14850,7 +14841,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
              }
            else if (attr_form_is_block (target_attr))
              {
-               baton = obstack_alloc (obstack, sizeof (*baton));
+               baton = XOBNEW (obstack, struct dwarf2_property_baton);
                baton->referenced_type = die_type (target_die, target_cu);
                baton->locexpr.per_cu = cu->per_cu;
                baton->locexpr.size = DW_BLOCK (target_attr)->size;
@@ -14874,7 +14865,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
                                                &offset))
                return 0;
 
-             baton = obstack_alloc (obstack, sizeof (*baton));
+             baton = XOBNEW (obstack, struct dwarf2_property_baton);
              baton->referenced_type = read_type_die (target_die->parent,
                                                      target_cu);
              baton->offset_info.offset = offset;
@@ -15271,9 +15262,9 @@ abbrev_table_alloc_abbrev (struct abbrev_table *abbrev_table)
 {
   struct abbrev_info *abbrev;
 
-  abbrev = (struct abbrev_info *)
-    obstack_alloc (&abbrev_table->abbrev_obstack, sizeof (struct abbrev_info));
+  abbrev = XOBNEW (&abbrev_table->abbrev_obstack, struct abbrev_info);
   memset (abbrev, 0, sizeof (struct abbrev_info));
+
   return abbrev;
 }
 
@@ -15332,9 +15323,9 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
   abbrev_table = XNEW (struct abbrev_table);
   abbrev_table->offset = offset;
   obstack_init (&abbrev_table->abbrev_obstack);
-  abbrev_table->abbrevs = obstack_alloc (&abbrev_table->abbrev_obstack,
-                                        (ABBREV_HASH_SIZE
-                                         * sizeof (struct abbrev_info *)));
+  abbrev_table->abbrevs =
+    XOBNEWVEC (&abbrev_table->abbrev_obstack, struct abbrev_info *,
+              ABBREV_HASH_SIZE);
   memset (abbrev_table->abbrevs, 0,
          ABBREV_HASH_SIZE * sizeof (struct abbrev_info *));
 
@@ -15344,7 +15335,7 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
   abbrev_ptr += bytes_read;
 
   allocated_attrs = ATTR_ALLOC_CHUNK;
-  cur_attrs = xmalloc (allocated_attrs * sizeof (struct attr_abbrev));
+  cur_attrs = XNEWVEC (struct attr_abbrev, allocated_attrs);
 
   /* Loop until we reach an abbrev number of 0.  */
   while (abbrev_number)
@@ -15384,9 +15375,9 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
          abbrev_ptr += bytes_read;
        }
 
-      cur_abbrev->attrs = obstack_alloc (&abbrev_table->abbrev_obstack,
-                                        (cur_abbrev->num_attrs
-                                         * sizeof (struct attr_abbrev)));
+      cur_abbrev->attrs =
+       XOBNEWVEC (&abbrev_table->abbrev_obstack, struct attr_abbrev,
+                  cur_abbrev->num_attrs);
       memcpy (cur_abbrev->attrs, cur_attrs,
              cur_abbrev->num_attrs * sizeof (struct attr_abbrev));
 
@@ -15522,8 +15513,7 @@ load_partial_dies (const struct die_reader_specs *reader,
                            hashtab_obstack_allocate,
                            dummy_obstack_deallocate);
 
-  part_die = obstack_alloc (&cu->comp_unit_obstack,
-                           sizeof (struct partial_die_info));
+  part_die = XOBNEW (&cu->comp_unit_obstack, struct partial_die_info);
 
   while (1)
     {
@@ -15723,8 +15713,7 @@ load_partial_dies (const struct die_reader_specs *reader,
          *slot = part_die;
        }
 
-      part_die = obstack_alloc (&cu->comp_unit_obstack,
-                               sizeof (struct partial_die_info));
+      part_die = XOBNEW (&cu->comp_unit_obstack, struct partial_die_info);
 
       /* For some DIEs we want to follow their children (if any).  For C
         we have no reason to follow the children of structures; for other
@@ -17209,15 +17198,13 @@ add_include_dir (struct line_header *lh, const char *include_dir)
   if (lh->include_dirs_size == 0)
     {
       lh->include_dirs_size = 1; /* for testing */
-      lh->include_dirs = xmalloc (lh->include_dirs_size
-                                  * sizeof (*lh->include_dirs));
+      lh->include_dirs = XNEWVEC (const char *, lh->include_dirs_size);
     }
   else if (lh->num_include_dirs >= lh->include_dirs_size)
     {
       lh->include_dirs_size *= 2;
-      lh->include_dirs = xrealloc (lh->include_dirs,
-                                   (lh->include_dirs_size
-                                    * sizeof (*lh->include_dirs)));
+      lh->include_dirs = XRESIZEVEC (const char *, lh->include_dirs,
+                                    lh->include_dirs_size);
     }
 
   lh->include_dirs[lh->num_include_dirs++] = include_dir;
@@ -17242,8 +17229,7 @@ add_file_name (struct line_header *lh,
   if (lh->file_names_size == 0)
     {
       lh->file_names_size = 1; /* for testing */
-      lh->file_names = xmalloc (lh->file_names_size
-                                * sizeof (*lh->file_names));
+      lh->file_names = XNEWVEC (struct file_entry, lh->file_names_size);
     }
   else if (lh->num_file_names >= lh->file_names_size)
     {
@@ -17330,7 +17316,7 @@ dwarf_decode_line_header (unsigned int offset, struct dwarf2_cu *cu)
       return 0;
     }
 
-  lh = xmalloc (sizeof (*lh));
+  lh = XNEW (struct line_header);
   memset (lh, 0, sizeof (*lh));
   back_to = make_cleanup ((make_cleanup_ftype *) free_line_header,
                           (void *) lh);
@@ -17390,8 +17376,7 @@ dwarf_decode_line_header (unsigned int offset, struct dwarf2_cu *cu)
   line_ptr += 1;
   lh->opcode_base = read_1_byte (abfd, line_ptr);
   line_ptr += 1;
-  lh->standard_opcode_lengths
-    = xmalloc (lh->opcode_base * sizeof (lh->standard_opcode_lengths[0]));
+  lh->standard_opcode_lengths = XNEWVEC (unsigned char, lh->opcode_base);
 
   lh->standard_opcode_lengths[0] = 1;  /* This should never be used anyway.  */
   for (i = 1; i < lh->opcode_base; ++i)
@@ -18764,7 +18749,7 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type,
        /* Symbols of this form are reasonably rare, so we just
           piggyback on the existing location code rather than writing
           a new implementation of symbol_computed_ops.  */
-       *baton = obstack_alloc (obstack, sizeof (struct dwarf2_locexpr_baton));
+       *baton = XOBNEW (obstack, struct dwarf2_locexpr_baton);
        (*baton)->per_cu = cu->per_cu;
        gdb_assert ((*baton)->per_cu);
 
@@ -20815,11 +20800,7 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
 static struct dwarf_block *
 dwarf_alloc_block (struct dwarf2_cu *cu)
 {
-  struct dwarf_block *blk;
-
-  blk = (struct dwarf_block *)
-    obstack_alloc (&cu->comp_unit_obstack, sizeof (struct dwarf_block));
-  return (blk);
+  return XOBNEW (&cu->comp_unit_obstack, struct dwarf_block);
 }
 
 static struct die_info *
@@ -21019,7 +21000,7 @@ parse_macro_definition (struct macro_source_file *file, int line,
       char *name = copy_string (body, p - body);
       int argc = 0;
       int argv_size = 1;
-      char **argv = xmalloc (argv_size * sizeof (*argv));
+      char **argv = XNEWVEC (char *, argv_size);
 
       p++;
 
@@ -21879,8 +21860,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
     {
       struct dwarf2_loclist_baton *baton;
 
-      baton = obstack_alloc (&objfile->objfile_obstack,
-                            sizeof (struct dwarf2_loclist_baton));
+      baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_loclist_baton);
 
       fill_in_loclist_baton (cu, baton, attr);
 
@@ -21898,8 +21878,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
     {
       struct dwarf2_locexpr_baton *baton;
 
-      baton = obstack_alloc (&objfile->objfile_obstack,
-                            sizeof (struct dwarf2_locexpr_baton));
+      baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
       baton->per_cu = cu->per_cu;
       gdb_assert (baton->per_cu);
 
@@ -22365,7 +22344,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
     complaint (&symfile_complaints,
               _("A problem internal to GDB: DIE 0x%x has type already set"),
               die->offset.sect_off);
-  *slot = obstack_alloc (&objfile->objfile_obstack, sizeof (**slot));
+  *slot = XOBNEW (&objfile->objfile_obstack,
+                 struct dwarf2_per_cu_offset_and_type);
   **slot = ofs;
   return type;
 }
@@ -23282,9 +23262,8 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
                                     eq_psymtab_cu_index,
                                     NULL, xcalloc, xfree);
   make_cleanup_htab_delete (cu_index_htab);
-  psymtab_cu_index_map = (struct psymtab_cu_index_map *)
-    xmalloc (sizeof (struct psymtab_cu_index_map)
-            * dwarf2_per_objfile->n_comp_units);
+  psymtab_cu_index_map = XNEWVEC (struct psymtab_cu_index_map,
+                                 dwarf2_per_objfile->n_comp_units);
   make_cleanup (xfree, psymtab_cu_index_map);
 
   /* The CU list is already sorted, so we don't need to do additional
index 1e5251550294d4fad1ad4dab02b59a80081f2edd..fa900a09b76c7a2db2a154df743b8831de6a0048 100644 (file)
@@ -95,7 +95,7 @@ elf_symfile_segments (bfd *abfd)
     return NULL;
 
   num_segments = 0;
-  segments = alloca (sizeof (Elf_Internal_Phdr *) * num_phdrs);
+  segments = XALLOCAVEC (Elf_Internal_Phdr *, num_phdrs);
   for (i = 0; i < num_phdrs; i++)
     if (phdrs[i].p_type == PT_LOAD)
       segments[num_segments++] = &phdrs[i];
@@ -1124,7 +1124,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
       long i;
 
       make_cleanup (xfree, synthsyms);
-      synth_symbol_table = xmalloc (sizeof (asymbol *) * synthcount);
+      synth_symbol_table = XNEWVEC (asymbol *, synthcount);
       for (i = 0; i < synthcount; i++)
        synth_symbol_table[i] = synthsyms + i;
       make_cleanup (xfree, synth_symbol_table);
index 824a6f5d46e9b7d967825144e845f5feac03f0a4..cd314fe2ac5640a01d7e3e135bc750e82a6f8a03 100644 (file)
@@ -29,7 +29,7 @@ make_environ (void)
 {
   struct gdb_environ *e;
 
-  e = (struct gdb_environ *) xmalloc (sizeof (struct gdb_environ));
+  e = XNEW (struct gdb_environ);
 
   e->allocated = 10;
   e->vector = (char **) xmalloc ((e->allocated + 1) * sizeof (char *));
index 2beea10dbb2324f3a266064a2f1f7a7b82b7a667..a668e76d53d2c2541730840c505ccdc18dde21ec 100644 (file)
@@ -998,7 +998,7 @@ evaluate_subexp_standard (struct type *expect_type,
          return set;
        }
 
-      argvec = (struct value **) alloca (sizeof (struct value *) * nargs);
+      argvec = XALLOCAVEC (struct value *, nargs);
       for (tem = 0; tem < nargs; tem++)
        {
          /* Ensure that array expressions are coerced into pointer
@@ -1082,8 +1082,7 @@ evaluate_subexp_standard (struct type *expect_type,
 
        selector = exp->elts[pc + 1].longconst;
        nargs = exp->elts[pc + 2].longconst;
-       argvec = (struct value **) alloca (sizeof (struct value *) 
-                                          * (nargs + 5));
+       argvec = XALLOCAVEC (struct value *, nargs + 5);
 
        (*pos) += 3;
 
index aee37bb63882ef37761f281bd4a8d2173747df3e..b1f3dd81a23748c51fb023ffb5978ceeb15ee6cd 100644 (file)
@@ -455,7 +455,7 @@ create_file_handler (int fd, int mask, handler_func * proc,
      change the data associated with it.  */
   if (file_ptr == NULL)
     {
-      file_ptr = (file_handler *) xmalloc (sizeof (file_handler));
+      file_ptr = XNEW (file_handler);
       file_ptr->fd = fd;
       file_ptr->ready_mask = 0;
       file_ptr->next_file = gdb_notifier.first_file_handler;
@@ -472,7 +472,7 @@ create_file_handler (int fd, int mask, handler_func * proc,
                                           * sizeof (struct pollfd)));
          else
            gdb_notifier.poll_fds =
-             (struct pollfd *) xmalloc (sizeof (struct pollfd));
+             XNEW (struct pollfd);
          (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->fd = fd;
          (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->events = mask;
          (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->revents = 0;
@@ -875,8 +875,7 @@ create_async_signal_handler (sig_handler_func * proc,
 {
   async_signal_handler *async_handler_ptr;
 
-  async_handler_ptr =
-    (async_signal_handler *) xmalloc (sizeof (async_signal_handler));
+  async_handler_ptr = XNEW (async_signal_handler);
   async_handler_ptr->ready = 0;
   async_handler_ptr->next_handler = NULL;
   async_handler_ptr->proc = proc;
@@ -990,7 +989,7 @@ create_async_event_handler (async_event_handler_func *proc,
 {
   async_event_handler *h;
 
-  h = xmalloc (sizeof (*h));
+  h = XNEW (struct async_event_handler);
   h->ready = 0;
   h->next_handler = NULL;
   h->proc = proc;
@@ -1090,7 +1089,7 @@ create_timer (int milliseconds, timer_handler_func * proc,
 
   gettimeofday (&time_now, NULL);
 
-  timer_ptr = (struct gdb_timer *) xmalloc (sizeof (*timer_ptr));
+  timer_ptr = XNEW (struct gdb_timer);
   timer_ptr->when.tv_sec = time_now.tv_sec + delta.tv_sec;
   timer_ptr->when.tv_usec = time_now.tv_usec + delta.tv_usec;
   /* Carry?  */
index f1b10496e2792247029779711da0d0b7512bfc0c..8ddb3df01d67737ae996c6b688e42cfabc4ea2c6 100644 (file)
@@ -475,7 +475,7 @@ build_section_table (struct bfd *some_bfd, struct target_section **start,
   count = bfd_count_sections (some_bfd);
   if (*start)
     xfree (* start);
-  *start = (struct target_section *) xmalloc (count * sizeof (**start));
+  *start = XNEWVEC (struct target_section, count);
   *end = *start;
   bfd_map_over_sections (some_bfd, add_to_section_table, (char *) end);
   if (*end > *start + count)
index 9705d45a161e0f3be43a112759d1ffc4a5bb627b..44d9e054a796733ab4b5e816b675e993f70fc666 100644 (file)
@@ -257,9 +257,7 @@ static struct fbsd_fork_child_info *fbsd_pending_children;
 static void
 fbsd_remember_child (pid_t pid)
 {
-  struct fbsd_fork_child_info *info;
-
-  info = xcalloc (1, sizeof *info);
+  struct fbsd_fork_child_info *info = XCNEW (struct fbsd_fork_child_info);
 
   info->child = pid;
   info->next = fbsd_pending_children;
index 4ba62b09ac9123a25946d30d7febf3465c0695aa..959f5780b7d374b030c1564a82959de4618b9b24 100644 (file)
@@ -170,7 +170,7 @@ fork_inferior (char *exec_file_arg, char *allargs, char **env,
         argument.  */
       int argc = (strlen (allargs) + 1) / 2 + 2;
 
-      argv = (char **) alloca (argc * sizeof (*argv));
+      argv = XALLOCAVEC (char *, argc);
       argv[0] = exec_file;
       breakup_args (allargs, &argv[1]);
     }
index f7fd00b85071e0c63f25ca38700b15d758561e70..19ff87eeb72b4ad5a4185fb711e80bf19d956fd4 100644 (file)
@@ -136,9 +136,8 @@ new_variant (void)
   struct gdbarch_tdep *var;
   int r;
 
-  var = xmalloc (sizeof (*var));
-  memset (var, 0, sizeof (*var));
-  
+  var = XCNEW (struct gdbarch_tdep);
+
   var->frv_abi = FRV_ABI_EABI;
   var->num_gprs = 64;
   var->num_fprs = 64;
index 07b38a3b633d631423345a95bca24b39f6e7b6ca..94e457adae4c62566fbce4515aa2f5583aeb9258 100644 (file)
@@ -345,7 +345,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
      then use that to allocate the architecture vector.  */
   struct obstack *obstack = XNEW (struct obstack);
   obstack_init (obstack);
-  gdbarch = obstack_alloc (obstack, sizeof (*gdbarch));
+  gdbarch = XOBNEW (obstack, struct gdbarch);
   memset (gdbarch, 0, sizeof (*gdbarch));
   gdbarch->obstack = obstack;
 
@@ -4894,7 +4894,7 @@ static struct gdbarch_registration *gdbarch_registry = NULL;
 static void
 append_name (const char ***buf, int *nr, const char *name)
 {
-  *buf = xrealloc (*buf, sizeof (char**) * (*nr + 1));
+  *buf = XRESIZEVEC (const char **, *buf, *nr + 1);
   (*buf)[*nr] = name;
   *nr += 1;
 }
index c1e2c1ab3e6d304e0efb6ae425388e8b494d16cb..7df37c9e165a54ab0af428111672165a23a601de 100644 (file)
@@ -924,7 +924,7 @@ extern void set_gdbarch_max_insn_length (struct gdbarch *gdbarch, ULONGEST max_i
    If your architecture doesn't need to adjust instructions before
    single-stepping them, consider using simple_displaced_step_copy_insn
    here.
-
+  
    If the instruction cannot execute out of line, return NULL.  The
    core falls back to stepping past the instruction in-line instead in
    that case. */
index 994a87bf2039f6d263867f04218dc4cdd13f46a4..5831b7b78a2099fba474df075e78769d4bbf5283 100755 (executable)
@@ -1741,7 +1741,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
      then use that to allocate the architecture vector.  */
   struct obstack *obstack = XNEW (struct obstack);
   obstack_init (obstack);
-  gdbarch = obstack_alloc (obstack, sizeof (*gdbarch));
+  gdbarch = XOBNEW (obstack, struct gdbarch);
   memset (gdbarch, 0, sizeof (*gdbarch));
   gdbarch->obstack = obstack;
 
@@ -2201,7 +2201,7 @@ static struct gdbarch_registration *gdbarch_registry = NULL;
 static void
 append_name (const char ***buf, int *nr, const char *name)
 {
-  *buf = xrealloc (*buf, sizeof (char**) * (*nr + 1));
+  *buf = XRESIZEVEC (const char **, *buf, *nr + 1);
   (*buf)[*nr] = name;
   *nr += 1;
 }
index 6d77e94dd22ff9c1981247b03ad6b0e31eb30094..5b9b1705912262ddd4390aaa06a5bc1dc0bbb5bf 100644 (file)
@@ -1,3 +1,58 @@
+2015-08-26  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * ax.c (gdb_parse_agent_expr): Likewise.
+       (compile_bytecodes): Likewise.
+       * dll.c (loaded_dll): Likewise.
+       * event-loop.c (append_callback_event): Likewise.
+       (create_file_handler): Likewise.
+       (create_file_event): Likewise.
+       * hostio.c (handle_open): Likewise.
+       * inferiors.c (add_thread): Likewise.
+       (add_process): Likewise.
+       * linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
+       * linux-arm-low.c (arm_new_process): Likewise.
+       (arm_new_thread): Likewise.
+       * linux-low.c (add_to_pid_list): Likewise.
+       (linux_add_process): Likewise.
+       (handle_extended_wait): Likewise.
+       (add_lwp): Likewise.
+       (enqueue_one_deferred_signal): Likewise.
+       (enqueue_pending_signal): Likewise.
+       (linux_resume_one_lwp_throw): Likewise.
+       (linux_resume_one_thread): Likewise.
+       (linux_read_memory): Likewise.
+       (linux_write_memory): Likewise.
+       * linux-mips-low.c (mips_linux_new_process): Likewise.
+       (mips_linux_new_thread): Likewise.
+       (mips_add_watchpoint): Likewise.
+       * linux-x86-low.c (initialize_low_arch): Likewise.
+       * lynx-low.c (lynx_add_process): Likewise.
+       * mem-break.c (set_raw_breakpoint_at): Likewise.
+       (set_breakpoint): Likewise.
+       (add_condition_to_breakpoint): Likewise.
+       (add_commands_to_breakpoint): Likewise.
+       (clone_agent_expr): Likewise.
+       (clone_one_breakpoint): Likewise.
+       * regcache.c (new_register_cache): Likewise.
+       * remote-utils.c (look_up_one_symbol): Likewise.
+       * server.c (queue_stop_reply): Likewise.
+       (start_inferior): Likewise.
+       (queue_stop_reply_callback): Likewise.
+       (handle_target_event): Likewise.
+       * spu-low.c (fetch_ppc_memory): Likewise.
+       (store_ppc_memory): Likewise.
+       * target.c (set_target_ops): Likewise.
+       * thread-db.c (thread_db_load_search): Likewise.
+       (try_thread_db_load_1): Likewise.
+       * tracepoint.c (add_tracepoint): Likewise.
+       (add_tracepoint_action): Likewise.
+       (create_trace_state_variable): Likewise.
+       (cmd_qtdpsrc): Likewise.
+       (cmd_qtro): Likewise.
+       (add_while_stepping_state): Likewise.
+       * win32-low.c (child_add_thread): Likewise.
+       (get_image_name): Likewise.
+
 2015-08-25  Yao Qi  <yao.qi@linaro.org>
 
        * linux-aarch64-low.c (aarch64_linux_new_thread): Remove.
index f94a27d96bb7aa2935c1e794bd7cfc72bc1ba880..d834fbb3c21e526fd1549a6c3b7f32f9bd982010 100644 (file)
@@ -102,7 +102,7 @@ gdb_parse_agent_expr (char **actparm)
   ++act;  /* skip the X */
   act = unpack_varlen_hex (act, &xlen);
   ++act;  /* skip a comma */
-  aexpr = xmalloc (sizeof (struct agent_expr));
+  aexpr = XNEW (struct agent_expr);
   aexpr->length = xlen;
   aexpr->bytes = xmalloc (xlen);
   hex2bin (act, aexpr->bytes, xlen);
@@ -430,7 +430,7 @@ compile_bytecodes (struct agent_expr *aexpr)
 
       /* Record the compiled-code address of the bytecode, for use by
         jump instructions.  */
-      aentry = xmalloc (sizeof (struct bytecode_address));
+      aentry = XNEW (struct bytecode_address);
       aentry->pc = pc;
       aentry->address = current_insn_ptr;
       aentry->goto_pc = -1;
index 1608527fffca2978c07748237a67061e0cd5920e..c4f838ca92c1a74f4d2d63b96f8b151a106b44ca 100644 (file)
@@ -60,8 +60,7 @@ match_dll (struct inferior_list_entry *inf, void *arg)
 void
 loaded_dll (const char *name, CORE_ADDR base_addr)
 {
-  struct dll_info *new_dll = xmalloc (sizeof (*new_dll));
-  memset (new_dll, 0, sizeof (*new_dll));
+  struct dll_info *new_dll = XCNEW (struct dll_info);
 
   new_dll->entry.id = minus_one_ptid;
 
index d27bc94ee95d1066096046aa9625f2129f747dfc..dd070938f1f53204e3c72273ef3b1fe7416f3590 100644 (file)
@@ -197,9 +197,8 @@ process_event (void)
 int
 append_callback_event (callback_handler_func *proc, gdb_client_data data)
 {
-  struct callback_event *event_ptr;
+  struct callback_event *event_ptr = XNEW (struct callback_event);
 
-  event_ptr = xmalloc (sizeof (*event_ptr));
   event_ptr->id = callback_list.num_callbacks++;
   event_ptr->proc = proc;
   event_ptr->data = data;
@@ -289,7 +288,7 @@ create_file_handler (gdb_fildes_t fd, int mask, handler_func *proc,
      just change the data associated with it.  */
   if (file_ptr == NULL)
     {
-      file_ptr = xmalloc (sizeof (*file_ptr));
+      file_ptr = XNEW (struct file_handler);
       file_ptr->fd = fd;
       file_ptr->ready_mask = 0;
       file_ptr->next_file = gdb_notifier.first_file_handler;
@@ -447,9 +446,10 @@ create_file_event (gdb_fildes_t fd)
 {
   gdb_event *file_event_ptr;
 
-  file_event_ptr = xmalloc (sizeof (gdb_event));
+  file_event_ptr = XNEW (gdb_event);
   file_event_ptr->proc = handle_file_event;
   file_event_ptr->fd = fd;
+
   return file_event_ptr;
 }
 
index 8788f0739180f7c2642c6ea7487c24bc9fd49acf..a631d9e771c04d8be23d4fa8b5f685edd0618e7d 100644 (file)
@@ -331,7 +331,7 @@ handle_open (char *own_buf)
     }
 
   /* Record the new file descriptor.  */
-  new_fd = xmalloc (sizeof (struct fd_list));
+  new_fd = XNEW (struct fd_list);
   new_fd->fd = fd;
   new_fd->next = open_fds;
   open_fds = new_fd;
index ce87d8c0a55596643001e73d3d5e8a2d06fdfba0..21f45fadf319e81c626636c5eacea2f204635743 100644 (file)
@@ -105,9 +105,7 @@ remove_inferior (struct inferior_list *list,
 struct thread_info *
 add_thread (ptid_t thread_id, void *target_data)
 {
-  struct thread_info *new_thread = xmalloc (sizeof (*new_thread));
-
-  memset (new_thread, 0, sizeof (*new_thread));
+  struct thread_info *new_thread = XCNEW (struct thread_info);
 
   new_thread->entry.id = thread_id;
   new_thread->last_resume_kind = resume_continue;
@@ -274,9 +272,7 @@ clear_inferiors (void)
 struct process_info *
 add_process (int pid, int attached)
 {
-  struct process_info *process;
-
-  process = xcalloc (1, sizeof (*process));
+  struct process_info *process = XCNEW (struct process_info);
 
   process->entry.id = pid_to_ptid (pid);
   process->attached = attached;
index dbe495182375950311b01e0e22b12cdd459d8ecf..da0ea9b89464f8a0f313b6ed992848a152be7cf4 100644 (file)
@@ -431,7 +431,7 @@ ps_get_thread_area (const struct ps_prochandle *ph,
 static struct arch_process_info *
 aarch64_linux_new_process (void)
 {
-  struct arch_process_info *info = xcalloc (1, sizeof (*info));
+  struct arch_process_info *info = XCNEW (struct arch_process_info);
 
   aarch64_init_debug_reg_state (&info->debug_reg_state);
 
index 6a27e6e724a754a7bdc4f13aefe78b75979f6d02..a277bb6876fb9f98a4e83dacf23b7d585f7e33f4 100644 (file)
@@ -664,7 +664,7 @@ arm_stopped_data_address (void)
 static struct arch_process_info *
 arm_new_process (void)
 {
-  struct arch_process_info *info = xcalloc (1, sizeof (*info));
+  struct arch_process_info *info = XCNEW (struct arch_process_info);
   return info;
 }
 
@@ -672,7 +672,7 @@ arm_new_process (void)
 static void
 arm_new_thread (struct lwp_info *lwp)
 {
-  struct arch_lwp_info *info = xcalloc (1, sizeof (*info));
+  struct arch_lwp_info *info = XCNEW (struct arch_lwp_info);
   int i;
 
   for (i = 0; i < MAX_BPTS; i++)
index 2bc91c276d6c4fd4ba7b4c60847357f000a0e79f..a8fa91c1d0f8b0216f154338766bbcaee0098872 100644 (file)
@@ -208,7 +208,7 @@ struct simple_pid_list *stopped_pids;
 static void
 add_to_pid_list (struct simple_pid_list **listp, int pid, int status)
 {
-  struct simple_pid_list *new_pid = xmalloc (sizeof (struct simple_pid_list));
+  struct simple_pid_list *new_pid = XNEW (struct simple_pid_list);
 
   new_pid->pid = pid;
   new_pid->status = status;
@@ -409,7 +409,7 @@ linux_add_process (int pid, int attached)
   struct process_info *proc;
 
   proc = add_process (pid, attached);
-  proc->priv = xcalloc (1, sizeof (*proc->priv));
+  proc->priv = XCNEW (struct process_info_private);
 
   if (the_low_target.new_process != NULL)
     proc->priv->arch_private = the_low_target.new_process ();
@@ -506,7 +506,7 @@ handle_extended_wait (struct lwp_info *event_lwp, int wstat)
                                 &child_proc->raw_breakpoints,
                                 parent_proc->breakpoints);
 
-         tdesc = xmalloc (sizeof (struct target_desc));
+         tdesc = XNEW (struct target_desc);
          copy_target_description (tdesc, parent_proc->tdesc);
          child_proc->tdesc = tdesc;
 
@@ -760,7 +760,7 @@ add_lwp (ptid_t ptid)
 {
   struct lwp_info *lwp;
 
-  lwp = (struct lwp_info *) xcalloc (1, sizeof (*lwp));
+  lwp = XCNEW (struct lwp_info);
 
   lwp->waitstatus.kind = TARGET_WAITKIND_IGNORE;
 
@@ -1984,10 +1984,10 @@ enqueue_one_deferred_signal (struct lwp_info *lwp, int *wstat)
        }
     }
 
-  p_sig = xmalloc (sizeof (*p_sig));
+  p_sig = XCNEW (struct pending_signals);
   p_sig->prev = lwp->pending_signals_to_report;
   p_sig->signal = WSTOPSIG (*wstat);
-  memset (&p_sig->info, 0, sizeof (siginfo_t));
+
   ptrace (PTRACE_GETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
          &p_sig->info);
 
@@ -3761,9 +3761,8 @@ stop_all_lwps (int suspend, struct lwp_info *except)
 static void
 enqueue_pending_signal (struct lwp_info *lwp, int signal, siginfo_t *info)
 {
-  struct pending_signals *p_sig;
+  struct pending_signals *p_sig = XNEW (struct pending_signals);
 
-  p_sig = xmalloc (sizeof (*p_sig));
   p_sig->prev = lwp->pending_signals;
   p_sig->signal = signal;
   if (info == NULL)
@@ -3817,8 +3816,8 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp,
          || lwp->bp_reinsert != 0
          || fast_tp_collecting))
     {
-      struct pending_signals *p_sig;
-      p_sig = xmalloc (sizeof (*p_sig));
+      struct pending_signals *p_sig = XNEW (struct pending_signals);
+
       p_sig->prev = lwp->pending_signals;
       p_sig->signal = signal;
       if (info == NULL)
@@ -4518,11 +4517,10 @@ linux_resume_one_thread (struct inferior_list_entry *entry, void *arg)
       /* If we have a new signal, enqueue the signal.  */
       if (lwp->resume->sig != 0)
        {
-         struct pending_signals *p_sig;
-         p_sig = xmalloc (sizeof (*p_sig));
+         struct pending_signals *p_sig = XCNEW (struct pending_signals);
+
          p_sig->prev = lwp->pending_signals;
          p_sig->signal = lwp->resume->sig;
-         memset (&p_sig->info, 0, sizeof (siginfo_t));
 
          /* If this is the same signal we were previously stopped by,
             make sure to queue its siginfo.  We can ignore the return
@@ -5276,7 +5274,7 @@ linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
   count = ((((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)
           / sizeof (PTRACE_XFER_TYPE));
   /* Allocate buffer of that many longwords.  */
-  buffer = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE));
+  buffer = XALLOCAVEC (PTRACE_XFER_TYPE, count);
 
   /* Read all the longwords */
   errno = 0;
@@ -5321,8 +5319,7 @@ linux_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
     / sizeof (PTRACE_XFER_TYPE);
 
   /* Allocate buffer of that many longwords.  */
-  register PTRACE_XFER_TYPE *buffer = (PTRACE_XFER_TYPE *)
-    alloca (count * sizeof (PTRACE_XFER_TYPE));
+  register PTRACE_XFER_TYPE *buffer = XALLOCAVEC (PTRACE_XFER_TYPE, count);
 
   int pid = lwpid_of (current_thread);
 
index 770f0df52d503e651551c3f7c4d23ec83bcb2d19..d1181b6c71f368de86dd1e950906ea29270793a6 100644 (file)
@@ -325,7 +325,7 @@ update_watch_registers_callback (struct inferior_list_entry *entry,
 static struct arch_process_info *
 mips_linux_new_process (void)
 {
-  struct arch_process_info *info = xcalloc (1, sizeof (*info));
+  struct arch_process_info *info = XCNEW (struct arch_process_info);
 
   return info;
 }
@@ -337,7 +337,7 @@ mips_linux_new_process (void)
 static void
 mips_linux_new_thread (struct lwp_info *lwp)
 {
-  struct arch_lwp_info *info = xcalloc (1, sizeof (*info));
+  struct arch_lwp_info *info = XCNEW (struct arch_lwp_info);
 
   info->watch_registers_changed = 1;
 
@@ -353,7 +353,7 @@ mips_add_watchpoint (struct arch_process_info *private, CORE_ADDR addr,
   struct mips_watchpoint *new_watch;
   struct mips_watchpoint **pw;
 
-  new_watch = xmalloc (sizeof (struct mips_watchpoint));
+  new_watch = XNEW (struct mips_watchpoint);
   new_watch->addr = addr;
   new_watch->len = len;
   new_watch->type = watch_type;
index 73fe6cd56c2b5bb09f5ee9e35725c7d373a8ef4c..20d4257e5fb01e3a84b972584ce2dfce3373c010 100644 (file)
@@ -3305,7 +3305,7 @@ initialize_low_arch (void)
   init_registers_x32_avx_linux ();
   init_registers_x32_avx512_linux ();
 
-  tdesc_amd64_linux_no_xml = xmalloc (sizeof (struct target_desc));
+  tdesc_amd64_linux_no_xml = XNEW (struct target_desc);
   copy_target_description (tdesc_amd64_linux_no_xml, tdesc_amd64_linux);
   tdesc_amd64_linux_no_xml->xmltarget = xmltarget_amd64_linux_no_xml;
 #endif
@@ -3315,7 +3315,7 @@ initialize_low_arch (void)
   init_registers_i386_avx512_linux ();
   init_registers_i386_mpx_linux ();
 
-  tdesc_i386_linux_no_xml = xmalloc (sizeof (struct target_desc));
+  tdesc_i386_linux_no_xml = XNEW (struct target_desc);
   copy_target_description (tdesc_i386_linux_no_xml, tdesc_i386_linux);
   tdesc_i386_linux_no_xml->xmltarget = xmltarget_i386_linux_no_xml;
 
index ee4d0e8395853b7e902adee0e7ed60cf7697cf5d..1a187c86d6141e49097e331b31b5722a8de64430 100644 (file)
@@ -218,7 +218,7 @@ lynx_add_process (int pid, int attached)
 
   proc = add_process (pid, attached);
   proc->tdesc = lynx_tdesc;
-  proc->priv = xcalloc (1, sizeof (*proc->priv));
+  proc->priv = XCNEW (struct process_info_private);
   proc->priv->last_wait_event_ptid = null_ptid;
 
   return proc;
index 4eaa52bffba1ee12a1ea1ba104cabaaa20263c23..93567413867416a818411ea55c93677eaf259140 100644 (file)
@@ -404,7 +404,7 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int size,
       return bp;
     }
 
-  bp = xcalloc (1, sizeof (*bp));
+  bp = XCNEW (struct raw_breakpoint);
   bp->pc = where;
   bp->size = size;
   bp->refcount = 1;
@@ -755,7 +755,7 @@ set_breakpoint (enum bkpt_type type, enum raw_bkpt_type raw_type,
       return NULL;
     }
 
-  bp = xcalloc (1, sizeof (struct breakpoint));
+  bp = XCNEW (struct breakpoint);
   bp->type = type;
 
   bp->raw = raw;
@@ -1169,7 +1169,7 @@ add_condition_to_breakpoint (struct breakpoint *bp,
   struct point_cond_list *new_cond;
 
   /* Create new condition.  */
-  new_cond = xcalloc (1, sizeof (*new_cond));
+  new_cond = XCNEW (struct point_cond_list);
   new_cond->cond = condition;
 
   /* Add condition to the list.  */
@@ -1267,7 +1267,7 @@ add_commands_to_breakpoint (struct breakpoint *bp,
   struct point_command_list *new_cmd;
 
   /* Create new command.  */
-  new_cmd = xcalloc (1, sizeof (*new_cmd));
+  new_cmd = XCNEW (struct point_command_list);
   new_cmd->cmd = commands;
   new_cmd->persistence = persist;
 
@@ -1937,7 +1937,7 @@ clone_agent_expr (const struct agent_expr *src_ax)
 {
   struct agent_expr *ax;
 
-  ax = xcalloc (1, sizeof (*ax));
+  ax = XCNEW (struct agent_expr);
   ax->length = src_ax->length;
   ax->bytes = xcalloc (ax->length, 1);
   memcpy (ax->bytes, src_ax->bytes, ax->length);
@@ -1959,7 +1959,7 @@ clone_one_breakpoint (const struct breakpoint *src)
   struct point_command_list *cmd_tail = NULL;
 
   /* Clone the raw breakpoint.  */
-  dest_raw = xcalloc (1, sizeof (*dest_raw));
+  dest_raw = XCNEW (struct raw_breakpoint);
   dest_raw->raw_type = src->raw->raw_type;
   dest_raw->refcount = src->raw->refcount;
   dest_raw->pc = src->raw->pc;
@@ -1968,7 +1968,7 @@ clone_one_breakpoint (const struct breakpoint *src)
   dest_raw->inserted = src->raw->inserted;
 
   /* Clone the high-level breakpoint.  */
-  dest = xcalloc (1, sizeof (*dest));
+  dest = XCNEW (struct breakpoint);
   dest->type = src->type;
   dest->raw = dest_raw;
   dest->handler = src->handler;
@@ -1977,7 +1977,7 @@ clone_one_breakpoint (const struct breakpoint *src)
   for (current_cond = src->cond_list; current_cond != NULL;
        current_cond = current_cond->next)
     {
-      new_cond = xcalloc (1, sizeof (*new_cond));
+      new_cond = XCNEW (struct point_cond_list);
       new_cond->cond = clone_agent_expr (current_cond->cond);
       APPEND_TO_LIST (&dest->cond_list, new_cond, cond_tail);
     }
@@ -1986,7 +1986,7 @@ clone_one_breakpoint (const struct breakpoint *src)
   for (current_cmd = src->command_list; current_cmd != NULL;
        current_cmd = current_cmd->next)
     {
-      new_cmd = xcalloc (1, sizeof (*new_cmd));
+      new_cmd = XCNEW (struct point_command_list);
       new_cmd->cmd = clone_agent_expr (current_cmd->cmd);
       new_cmd->persistence = current_cmd->persistence;
       APPEND_TO_LIST (&dest->command_list, new_cmd, cmd_tail);
index ef955ffc5a6d3ed9f7f6ed6ecfd9d03e418ea3db..59bdc530d8ce5cb32eef51e6eeb762ee3af36f60 100644 (file)
@@ -159,11 +159,10 @@ init_register_cache (struct regcache *regcache,
 struct regcache *
 new_register_cache (const struct target_desc *tdesc)
 {
-  struct regcache *regcache;
+  struct regcache *regcache = XCNEW (struct regcache);
 
   gdb_assert (tdesc->registers_size != 0);
 
-  regcache = xmalloc (sizeof (*regcache));
   return init_register_cache (regcache, tdesc, NULL);
 }
 
index c6c516ccdc6f7bd405abbb23f1d7a8c803bb9ce3..0c4a6936439601fcb892ef41d337494fefd02386 100644 (file)
@@ -1492,7 +1492,7 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
   decode_address (addrp, p, q - p);
 
   /* Save the symbol in our cache.  */
-  sym = xmalloc (sizeof (*sym));
+  sym = XNEW (struct sym_cache);
   sym->name = xstrdup (name);
   sym->addr = *addrp;
   sym->next = proc->symbol_cache;
index 34fcd2b00836dc035f85fc44839a4cbfb9b512e8..c52cf168d946e2a03e257fd4991e2f5f95ca5edc 100644 (file)
@@ -137,7 +137,7 @@ DEFINE_QUEUE_P (notif_event_p);
 static void
 queue_stop_reply (ptid_t ptid, struct target_waitstatus *status)
 {
-  struct vstop_notif *new_notif = xmalloc (sizeof (*new_notif));
+  struct vstop_notif *new_notif = XNEW (struct vstop_notif);
 
   new_notif->ptid = ptid;
   new_notif->status = *status;
@@ -206,7 +206,7 @@ start_inferior (char **argv)
        count++;
       for (i = 0; argv[i] != NULL; i++)
        count++;
-      new_argv = alloca (sizeof (char *) * count);
+      new_argv = XALLOCAVEC (char *, count);
       count = 0;
       for (i = 0; wrapper_argv[i] != NULL; i++)
        new_argv[count++] = wrapper_argv[i];
@@ -2915,7 +2915,7 @@ queue_stop_reply_callback (struct inferior_list_entry *entry, void *arg)
      manage the thread's last_status field.  */
   if (the_target->thread_stopped == NULL)
     {
-      struct vstop_notif *new_notif = xmalloc (sizeof (*new_notif));
+      struct vstop_notif *new_notif = XNEW (struct vstop_notif);
 
       new_notif->ptid = entry->id;
       new_notif->status = thread->last_status;
@@ -4282,8 +4282,7 @@ handle_target_event (int err, gdb_client_data client_data)
        }
       else
        {
-         struct vstop_notif *vstop_notif
-           = xmalloc (sizeof (struct vstop_notif));
+         struct vstop_notif *vstop_notif = XNEW (struct vstop_notif);
 
          vstop_notif->status = last_status;
          vstop_notif->ptid = last_ptid;
index a110a0e76ff85d089ac4cccce2c3c4eee70fb31a..878ed82cf0e34ec5a688f75bb7518f5b74804ce6 100644 (file)
@@ -147,7 +147,7 @@ fetch_ppc_memory (CORE_ADDR memaddr, char *myaddr, int len)
 
   int tid = ptid_get_lwp (current_ptid);
 
-  buffer = (PTRACE_TYPE_RET *) alloca (count * sizeof (PTRACE_TYPE_RET));
+  buffer = XALLOCAVEC (PTRACE_TYPE_RET, count);
   for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
     if ((ret = fetch_ppc_memory_1 (tid, addr, &buffer[i])) != 0)
       return ret;
@@ -172,7 +172,7 @@ store_ppc_memory (CORE_ADDR memaddr, char *myaddr, int len)
 
   int tid = ptid_get_lwp (current_ptid);
 
-  buffer = (PTRACE_TYPE_RET *) alloca (count * sizeof (PTRACE_TYPE_RET));
+  buffer = XALLOCAVEC (PTRACE_TYPE_RET, count);
 
   if (addr != memaddr || len < (int) sizeof (PTRACE_TYPE_RET))
     if ((ret = fetch_ppc_memory_1 (tid, addr, &buffer[0])) != 0)
index 8fcfe9b0ab658a937a60c0549b8234dc91692425..7540f2f5c9ca21deb52a8af35fefacc4a0abeecf 100644 (file)
@@ -181,7 +181,7 @@ start_non_stop (int nonstop)
 void
 set_target_ops (struct target_ops *target)
 {
-  the_target = (struct target_ops *) xmalloc (sizeof (*the_target));
+  the_target = XNEW (struct target_ops);
   memcpy (the_target, target, sizeof (*the_target));
 }
 
index 3da636e59e4d4f2739657c6e83f4cf2e3ac822cd..cd07c52d197a82d04442c13cc04b1aeb16aacf76 100644 (file)
@@ -562,7 +562,7 @@ thread_db_load_search (void)
 
   gdb_assert (proc->priv->thread_db == NULL);
 
-  tdb = xcalloc (1, sizeof (*tdb));
+  tdb = XCNEW (struct thread_db);
   proc->priv->thread_db = tdb;
 
   tdb->td_ta_new_p = &td_ta_new;
@@ -607,7 +607,7 @@ try_thread_db_load_1 (void *handle)
 
   gdb_assert (proc->priv->thread_db == NULL);
 
-  tdb = xcalloc (1, sizeof (*tdb));
+  tdb = XCNEW (struct thread_db);
   proc->priv->thread_db = tdb;
 
   tdb->handle = handle;
index 5d0ed73b19009dfd525d5a95e378e5b0cc21d3d9..fd010aed7fb9e8c0c8fdd68bb2177e4b367e92a0 100644 (file)
@@ -1803,7 +1803,7 @@ add_tracepoint (int num, CORE_ADDR addr)
 {
   struct tracepoint *tpoint, **tp_next;
 
-  tpoint = xmalloc (sizeof (struct tracepoint));
+  tpoint = XNEW (struct tracepoint);
   tpoint->number = num;
   tpoint->address = addr;
   tpoint->numactions = 0;
@@ -1938,11 +1938,11 @@ add_tracepoint_action (struct tracepoint *tpoint, char *packet)
        {
        case 'M':
          {
-           struct collect_memory_action *maction;
+           struct collect_memory_action *maction =
+             XNEW (struct collect_memory_action);
            ULONGEST basereg;
            int is_neg;
 
-           maction = xmalloc (sizeof *maction);
            maction->base.type = *act;
            maction->base.ops = &m_tracepoint_action_ops;
            action = &maction->base;
@@ -1966,9 +1966,9 @@ add_tracepoint_action (struct tracepoint *tpoint, char *packet)
          }
        case 'R':
          {
-           struct collect_registers_action *raction;
+           struct collect_registers_action *raction =
+             XNEW (struct collect_registers_action);
 
-           raction = xmalloc (sizeof *raction);
            raction->base.type = *act;
            raction->base.ops = &r_tracepoint_action_ops;
            action = &raction->base;
@@ -1982,9 +1982,9 @@ add_tracepoint_action (struct tracepoint *tpoint, char *packet)
          }
        case 'L':
          {
-           struct collect_static_trace_data_action *raction;
+           struct collect_static_trace_data_action *raction =
+             XNEW (struct collect_static_trace_data_action);
 
-           raction = xmalloc (sizeof *raction);
            raction->base.type = *act;
            raction->base.ops = &l_tracepoint_action_ops;
            action = &raction->base;
@@ -1999,9 +1999,8 @@ add_tracepoint_action (struct tracepoint *tpoint, char *packet)
          break;
        case 'X':
          {
-           struct eval_expr_action *xaction;
+           struct eval_expr_action *xaction = XNEW (struct eval_expr_action);
 
-           xaction = xmalloc (sizeof (*xaction));
            xaction->base.type = *act;
            xaction->base.ops = &x_tracepoint_action_ops;
            action = &xaction->base;
@@ -2088,7 +2087,7 @@ create_trace_state_variable (int num, int gdb)
     return tsv;
 
   /* Create a new variable.  */
-  tsv = xmalloc (sizeof (struct trace_state_variable));
+  tsv = XNEW (struct trace_state_variable);
   tsv->number = num;
   tsv->initial_value = 0;
   tsv->value = 0;
@@ -2698,7 +2697,7 @@ cmd_qtdpsrc (char *own_buf)
   nbytes = hex2bin (packet, (gdb_byte *) src, strlen (packet) / 2);
   src[nbytes] = '\0';
 
-  newlast = xmalloc (sizeof (struct source_string));
+  newlast = XNEW (struct source_string);
   newlast->type = srctype;
   newlast->str = src;
   newlast->next = NULL;
@@ -2888,7 +2887,8 @@ cmd_qtro (char *own_buf)
       packet = unpack_varlen_hex (packet, &start);
       ++packet;  /* skip a comma */
       packet = unpack_varlen_hex (packet, &end);
-      roreg = xmalloc (sizeof (struct readonly_region));
+
+      roreg = XNEW (struct readonly_region);
       roreg->start = start;
       roreg->end = end;
       roreg->next = readonly_regions;
@@ -4326,9 +4326,8 @@ static void
 add_while_stepping_state (struct thread_info *tinfo,
                          int tp_number, CORE_ADDR tp_address)
 {
-  struct wstep_state *wstep;
+  struct wstep_state *wstep = XNEW (struct wstep_state);
 
-  wstep = xmalloc (sizeof (*wstep));
   wstep->next = tinfo->while_stepping;
 
   wstep->tp_number = tp_number;
index 7ccb3dde182b0f439a330bcc599f8829c09d3609..86386ce70c84ecdc8d7e56b0eb751788e78be2c7 100644 (file)
@@ -214,7 +214,7 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb)
   if ((th = thread_rec (ptid, FALSE)))
     return th;
 
-  th = xcalloc (1, sizeof (*th));
+  th = XCNEW (win32_thread_info);
   th->tid = tid;
   th->h = h;
   th->thread_local_base = (CORE_ADDR) (uintptr_t) tlb;
@@ -1084,7 +1084,7 @@ get_image_name (HANDLE h, void *address, int unicode)
     ReadProcessMemory (h, address_ptr, buf, len, &done);
   else
     {
-      WCHAR *unicode_address = (WCHAR *) alloca (len * sizeof (WCHAR));
+      WCHAR *unicode_address = XALLOCAVEC (WCHAR, len);
       ReadProcessMemory (h, address_ptr, unicode_address, len * sizeof (WCHAR),
                         &done);
 
index 301c6fcfc9be6cde2a54c1ae504da478b1282583..5c8e49c5d33c9c41bfbffe38db8ea275dc9d312a 100644 (file)
@@ -3022,10 +3022,9 @@ rank_function (struct type **parms, int nparms,
               struct value **args, int nargs)
 {
   int i;
-  struct badness_vector *bv;
+  struct badness_vector *bv = XNEW (struct badness_vector);
   int min_len = nparms < nargs ? nparms : nargs;
 
-  bv = xmalloc (sizeof (struct badness_vector));
   bv->length = nargs + 1;      /* add 1 for the length-match rank.  */
   bv->rank = XNEWVEC (struct rank, nargs + 1);
 
@@ -4386,8 +4385,7 @@ copy_type_recursive (struct objfile *objfile,
 
   /* We must add the new type to the hash table immediately, in case
      we encounter this type again during a recursive call below.  */
-  stored
-    = obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair));
+  stored = XOBNEW (&objfile->objfile_obstack, struct type_pair);
   stored->old = type;
   stored->newobj = new_type;
   *slot = stored;
@@ -4455,7 +4453,7 @@ copy_type_recursive (struct objfile *objfile,
   /* For range types, copy the bounds information.  */
   if (TYPE_CODE (type) == TYPE_CODE_RANGE)
     {
-      TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
+      TYPE_RANGE_DATA (new_type) = XNEW (struct range_bounds);
       *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
     }
 
index d830773b1905b986cef3f6ad132b639287c3efbe..c2dfe5d9b6d395a7fabb6c993a3f62685b9c5cc5 100644 (file)
@@ -539,7 +539,7 @@ make_proc (struct inf *inf, mach_port_t port, int tid)
 {
   error_t err;
   mach_port_t prev_port = MACH_PORT_NULL;
-  struct proc *proc = xmalloc (sizeof (struct proc));
+  struct proc *proc = XNEW (struct proc);
 
   proc->port = port;
   proc->tid = tid;
@@ -636,7 +636,7 @@ _proc_free (struct proc *proc)
 static struct inf *
 make_inf (void)
 {
-  struct inf *inf = xmalloc (sizeof (struct inf));
+  struct inf *inf = XNEW (struct inf);
 
   inf->task = 0;
   inf->threads = 0;
@@ -2419,9 +2419,7 @@ gnu_write_inferior (task_t task, CORE_ADDR addr,
          }
 
        /* Chain the regions for later use.  */
-       region_element =
-         (struct vm_region_list *)
-         obstack_alloc (&region_obstack, sizeof (struct vm_region_list));
+       region_element = XOBNEW (&region_obstack, struct vm_region_list);
 
        region_element->protection = protection;
        region_element->start = region_address;
index 85eed7067126ae5f27d7316cc320f6b08a8338e2..3b6cc774c6f5ea69049e1402c8de9b384d8fbbb5 100644 (file)
@@ -125,8 +125,7 @@ build_gdb_vtable_type (struct gdbarch *arch)
      the alignment that type requires, and then use that here.  */
 
   /* Build the field list.  */
-  field_list = xmalloc (sizeof (struct field [4]));
-  memset (field_list, 0, sizeof (struct field [4]));
+  field_list = XCNEWVEC (struct field, 4);
   field = &field_list[0];
   offset = 0;
 
@@ -1025,8 +1024,7 @@ build_std_type_info_type (struct gdbarch *arch)
   struct type *char_ptr_type
     = make_pointer_type (make_cv_type (1, 0, char_type, NULL), NULL);
 
-  field_list = xmalloc (sizeof (struct field [2]));
-  memset (field_list, 0, sizeof (struct field [2]));
+  field_list = XCNEWVEC (struct field, 2);
   field = &field_list[0];
   offset = 0;
 
index 9737c25e03b435374b80ea667a9d6229d6843db0..3ddd98f310890bb3a60a920cb68302ceb2c42e25 100644 (file)
@@ -503,8 +503,7 @@ compute_enum_list (SCM enum_values_scm, int arg_pos, const char *func_name)
                                 _("enumeration list is empty"));
     }
 
-  enum_values = xmalloc ((size + 1) * sizeof (char *));
-  memset (enum_values, 0, (size + 1) * sizeof (char *));
+  enum_values = XCNEWVEC (char *, size + 1);
 
   i = 0;
   while (!scm_is_eq (enum_values_scm, SCM_EOL))
index 07401e6476e3362a5beda722619af17e52d08127..b0873f336c6282de7923526a02efa5c8292ba93a 100644 (file)
@@ -432,8 +432,8 @@ gdbscm_parse_function_args (const char *func_name,
 
   if (num_keywords > 0)
     {
-      SCM *keyword_args = (SCM *) alloca (num_keywords * sizeof (SCM));
-      int *keyword_positions = (int *) alloca (num_keywords * sizeof (int));
+      SCM *keyword_args = XALLOCAVEC (SCM, num_keywords);
+      int *keyword_positions = XALLOCAVEC (int, num_keywords);
 
       gdb_assert (*p == '#');
       ++p;
index d26ab0d745937a03cd7c2b87f9579c79b72dec6e..25c29574985cf6301d9684fe59529d105f812b22 100644 (file)
@@ -851,7 +851,7 @@ gdbscm_value_call (SCM self, SCM args)
       SCM except_scm;
       long i;
 
-      vargs = alloca (sizeof (struct value *) * args_count);
+      vargs = XALLOCAVEC (struct value *, args_count);
       for (i = 0; i < args_count; i++)
        {
          SCM arg = scm_car (args);
index e7f75a946df90d465b180ab93adca704c74393da..48879024394d157594df592787b225bffa751c3a 100644 (file)
@@ -1267,7 +1267,7 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return arches->gdbarch;
 
 #if 0
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
 #endif
 
   if (info.bfd_arch_info->arch != bfd_arch_h8300)
index c237aaaf310aeabb8b3eae1b5a2a131583cedc8e..a468be96ad7453eaa697497398ea12b23bd428f8 100644 (file)
@@ -3963,7 +3963,7 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   if (arches != NULL)
     return arches->gdbarch;
 
-  tdep = xzalloc (sizeof (struct gdbarch_tdep));
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   tdep->size_of_register_frame = ia64_size_of_register_frame;
index 139c361aa403fb59b16886d13e2b03fa0228f1f4..ad5f004da7e253e8c78fb27ed60039132cbf78dd 100644 (file)
@@ -570,9 +570,9 @@ dummy_frame_context_saver_get_regs (struct dummy_frame_context_saver *saver)
 struct dummy_frame_context_saver *
 dummy_frame_context_saver_setup (struct frame_id dummy_id, ptid_t ptid)
 {
-  struct dummy_frame_context_saver *saver;
+  struct dummy_frame_context_saver *saver =
+    XNEW (struct dummy_frame_context_saver);
 
-  saver = xmalloc (sizeof (*saver));
   saver->retbuf = NULL;
   saver->drop_done = 0;
   register_dummy_frame_dtor (dummy_id, inferior_ptid,
@@ -922,7 +922,7 @@ call_function_by_hand_dummy (struct value *function,
       struct value **new_args;
 
       /* Add the new argument to the front of the argument list.  */
-      new_args = xmalloc (sizeof (struct value *) * (nargs + 1));
+      new_args = XNEWVEC (struct value *, nargs + 1);
       new_args[0] = value_from_pointer (lookup_pointer_type (values_type),
                                        struct_addr);
       memcpy (&new_args[1], &args[0], sizeof (struct value *) * nargs);
index 393ccb9a079975ba7c38476c89f25a177407fced..bdde49dc22ff5762d1a5c2293dba39f46f8f204a 100644 (file)
@@ -1121,9 +1121,9 @@ step_once (int skip_subroutines, int single_inst, int count, int thread)
         further stepping.  */
       if (target_can_async_p ())
        {
-         struct step_1_continuation_args *args;
+         struct step_1_continuation_args *args =
+           XNEW (struct step_1_continuation_args);
 
-         args = xmalloc (sizeof (*args));
          args->skip_subroutines = skip_subroutines;
          args->single_inst = single_inst;
          args->count = count;
@@ -1790,7 +1790,7 @@ finish_forward (struct symbol *function, struct frame_info *frame)
 
   /* We want to print return value, please...  */
   tp->control.proceed_to_finish = 1;
-  cargs = xmalloc (sizeof (*cargs));
+  cargs = XNEW (struct finish_command_continuation_args);
 
   cargs->thread = thread;
   cargs->breakpoint = breakpoint;
@@ -2677,7 +2677,7 @@ attach_command (char *args, int from_tty)
          /* sync_execution mode.  Wait for stop.  */
          struct attach_command_continuation_args *a;
 
-         a = xmalloc (sizeof (*a));
+         a = XNEW (struct attach_command_continuation_args);
          a->args = xstrdup (args);
          a->from_tty = from_tty;
          a->async_exec = async_exec;
@@ -2745,7 +2745,7 @@ notice_new_inferior (ptid_t ptid, int leave_running, int from_tty)
        {
          struct attach_command_continuation_args *a;
 
-         a = xmalloc (sizeof (*a));
+         a = XNEW (struct attach_command_continuation_args);
          a->args = xstrdup ("");
          a->from_tty = from_tty;
          a->async_exec = async_exec;
index 2e44f175bb1442a438c536b55d5018d6c4b220fb..04e9a286d5681c7c5d8d24215a20b1af490b054d 100644 (file)
@@ -128,7 +128,7 @@ add_inferior_silent (int pid)
 {
   struct inferior *inf;
 
-  inf = xmalloc (sizeof (*inf));
+  inf = XNEW (struct inferior);
   memset (inf, 0, sizeof (*inf));
   inf->pid = pid;
 
index c3e7dd78842cf3e0371785df9f12fb807f45a768..70dffca440a3772a7e1e07f08640541d1f6110b1 100644 (file)
@@ -1562,7 +1562,7 @@ add_displaced_stepping_state (int pid)
     if (state->pid == pid)
       return state;
 
-  state = xcalloc (1, sizeof (*state));
+  state = XCNEW (struct displaced_step_inferior_state);
   state->pid = pid;
   state->next = displaced_step_inferior_states;
   displaced_step_inferior_states = state;
@@ -8586,7 +8586,8 @@ struct infcall_control_state
 struct infcall_control_state *
 save_infcall_control_state (void)
 {
-  struct infcall_control_state *inf_status = xmalloc (sizeof (*inf_status));
+  struct infcall_control_state *inf_status =
+    XNEW (struct infcall_control_state);
   struct thread_info *tp = inferior_thread ();
   struct inferior *inf = current_inferior ();
 
@@ -8726,9 +8727,8 @@ restore_inferior_ptid (void *arg)
 struct cleanup *
 save_inferior_ptid (void)
 {
-  ptid_t *saved_ptid_ptr;
+  ptid_t *saved_ptid_ptr = XNEW (ptid_t);
 
-  saved_ptid_ptr = xmalloc (sizeof (ptid_t));
   *saved_ptid_ptr = inferior_ptid;
   return make_cleanup (restore_inferior_ptid, saved_ptid_ptr);
 }
@@ -8914,15 +8914,11 @@ leave it stopped or free to run as needed."),
                           &showlist);
 
   numsigs = (int) GDB_SIGNAL_LAST;
-  signal_stop = (unsigned char *) xmalloc (sizeof (signal_stop[0]) * numsigs);
-  signal_print = (unsigned char *)
-    xmalloc (sizeof (signal_print[0]) * numsigs);
-  signal_program = (unsigned char *)
-    xmalloc (sizeof (signal_program[0]) * numsigs);
-  signal_catch = (unsigned char *)
-    xmalloc (sizeof (signal_catch[0]) * numsigs);
-  signal_pass = (unsigned char *)
-    xmalloc (sizeof (signal_pass[0]) * numsigs);
+  signal_stop = XNEWVEC (unsigned char, numsigs);
+  signal_print = XNEWVEC (unsigned char, numsigs);
+  signal_program = XNEWVEC (unsigned char, numsigs);
+  signal_catch = XNEWVEC (unsigned char, numsigs);
+  signal_pass = XNEWVEC (unsigned char, numsigs);
   for (i = 0; i < numsigs; i++)
     {
       signal_stop[i] = 1;
index f977ea66f5ac3a739ab88120f286f3cb66367e97..10da21daae4520828dfcad567654832c876ed445 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -136,7 +136,7 @@ mem_bfd_iovec_stat (struct bfd *abfd, void *stream, struct stat *sb)
 static struct bfd *
 bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size, char *target)
 {
-  struct target_buffer *buffer = xmalloc (sizeof (struct target_buffer));
+  struct target_buffer *buffer = XNEW (struct target_buffer);
 
   buffer->base = addr;
   buffer->size = size;
@@ -1458,10 +1458,11 @@ free_objfile_data (struct objfile *objfile, void *data)
 static void *
 jit_gdbarch_data_init (struct obstack *obstack)
 {
-  struct jit_gdbarch_data_type *data;
+  struct jit_gdbarch_data_type *data =
+    XOBNEW (obstack, struct jit_gdbarch_data_type);
 
-  data = obstack_alloc (obstack, sizeof (struct jit_gdbarch_data_type));
   data->unwinder_registered = 0;
+
   return data;
 }
 
index 4937b7d0c8e4633bd7b50c0333e8f61ec235cf58..121e8ad0e8cce2b6b36d658559d559d8046f0552 100644 (file)
@@ -556,8 +556,7 @@ add_language (const struct language_defn *lang)
   if (!languages)
     {
       languages_allocsize = DEFAULT_ALLOCSIZE;
-      languages = (const struct language_defn **) xmalloc
-       (languages_allocsize * sizeof (*languages));
+      languages = XNEWVEC (const struct language_defn *, languages_allocsize);
     }
   if (languages_size >= languages_allocsize)
     {
index 00fa4ba82420099e485624a77d32efbc4fbe4e3d..8f102fac1a316c0ed0596b7db559670a998fef0b 100644 (file)
@@ -1332,7 +1332,7 @@ decode_line_2 (struct linespec_state *self,
 
   /* Prepare ITEMS array.  */
   items_count = result->nelts;
-  items = xmalloc (sizeof (*items) * items_count);
+  items = XNEWVEC (struct decode_line_2_item, items_count);
   make_cleanup (xfree, items);
   for (i = 0; i < items_count; ++i)
     {
index 19e242a5ece718dcadf998bff1261a208949e013..4da361defdaac51b0f707254527f62b78866dff0 100644 (file)
@@ -336,7 +336,7 @@ lwp_stop_reason (struct lwp_info *lwp)
 static void
 add_to_pid_list (struct simple_pid_list **listp, int pid, int status)
 {
-  struct simple_pid_list *new_pid = xmalloc (sizeof (struct simple_pid_list));
+  struct simple_pid_list *new_pid = XNEW (struct simple_pid_list);
 
   new_pid->pid = pid;
   new_pid->status = status;
@@ -822,7 +822,7 @@ add_initial_lwp (ptid_t ptid)
 
   gdb_assert (ptid_lwp_p (ptid));
 
-  lp = (struct lwp_info *) xmalloc (sizeof (struct lwp_info));
+  lp = XNEW (struct lwp_info);
 
   memset (lp, 0, sizeof (struct lwp_info));
 
index 84599d3d90987fd86e809e9b5e36cf4687ea4b2e..d6bf56f0a49dd7877ba9f3f8364c6c66334217f4 100644 (file)
@@ -211,9 +211,8 @@ static void record_thread (struct thread_db_info *info,
 static struct thread_db_info *
 add_thread_db_info (void *handle)
 {
-  struct thread_db_info *info;
+  struct thread_db_info *info = XCNEW (struct thread_db_info);
 
-  info = xcalloc (1, sizeof (*info));
   info->pid = ptid_get_pid (inferior_ptid);
   info->handle = handle;
 
@@ -1308,8 +1307,7 @@ record_thread (struct thread_db_info *info,
     return;
 
   /* Construct the thread's private data.  */
-  priv = xmalloc (sizeof (struct private_thread_info));
-  memset (priv, 0, sizeof (struct private_thread_info));
+  priv = XCNEW (struct private_thread_info);
 
   priv->th = *th_p;
   priv->tid = ti_p->ti_tid;
@@ -1998,7 +1996,7 @@ info_auto_load_libthread_db (char *args, int from_tty)
     if (info->filename != NULL)
       info_count++;
 
-  array = xmalloc (sizeof (*array) * info_count);
+  array = XNEWVEC (struct thread_db_info *, info_count);
   back_to = make_cleanup (xfree, array);
 
   info_count = 0;
index 60b5cfb6420879f2dade14a2b318f39741e942e3..3be74057a51d2ccca56fdc2dcdac1ceb0b43774c 100644 (file)
@@ -2638,7 +2638,7 @@ m32c_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     return arches->gdbarch;
 
-  tdep = xcalloc (1, sizeof (*tdep));
+  tdep = XCNEW (struct gdbarch_tdep);
   arch = gdbarch_alloc (&info, tdep);
 
   /* Essential types.  */
index b7b5bbe9014ac41f0a547736a8e9f3cb75aa4f8e..69ed9dce24532b9fc80ad5ca0d7dec9d79a4689b 100644 (file)
@@ -1451,7 +1451,7 @@ m68hc11_gdbarch_init (struct gdbarch_info info,
     }
 
   /* Need a new architecture.  Fill in a target specific vector.  */
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->elf_flags = elf_flags;
 
index d7347b6c98ea01f0e7a4eb9613e22d2a8b186c1d..f833741e529319b93358447de2b76b7d8f87b2db 100644 (file)
@@ -1185,7 +1185,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       return best_arch->gdbarch;
     }
 
-  tdep = xzalloc (sizeof (struct gdbarch_tdep));
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->fpregs_present = has_fp;
   tdep->flavour = flavour;
index 57754672917929a60d4c851f302d8c21fb59c52e..47a8f579fd347dc46037b82f02f8131a4f82763f 100644 (file)
@@ -533,11 +533,9 @@ m88k_analyze_prologue (struct gdbarch *gdbarch,
   /* Provide a dummy cache if necessary.  */
   if (cache == NULL)
     {
-      size_t sizeof_saved_regs =
-       (M88K_R31_REGNUM + 1) * sizeof (struct trad_frame_saved_reg);
-
-      cache = alloca (sizeof (struct m88k_frame_cache));
-      cache->saved_regs = alloca (sizeof_saved_regs);
+      cache->saved_regs
+       = XALLOCAVEC (struct trad_frame_saved_reg, M88K_R31_REGNUM + 1);
+      cache = XALLOCA (struct m88k_frame_cache);
 
       /* We only initialize the members we care about.  */
       cache->saved_regs[M88K_R1_REGNUM].addr = -1;
index 3db1239f2419defd6c19af8f01d738da15bf30ad..2eb9dffd4fc46637a426576f4778302760ba12eb 100644 (file)
@@ -387,7 +387,7 @@ macro_define_command (char *exp, int from_tty)
     {
       /* Function-like macro.  */
       int alloced = 5;
-      char **argv = (char **) xmalloc (alloced * sizeof (char *));
+      char **argv = XNEWVEC (char *, alloced);
 
       new_macro.kind = macro_function_like;
       new_macro.argc = 0;
index 60290174ca180fe04d6ebbe2e0867fcd8b8dc94f..e6c9c86c30a5a519248197c2d4c066c0d6dc94e4 100644 (file)
@@ -814,7 +814,7 @@ gather_arguments (const char *name, struct macro_buffer *src,
 
   args_len = 0;
   args_size = 6;
-  args = (struct macro_buffer *) xmalloc (sizeof (*args) * args_size);
+  args = XNEWVEC (struct macro_buffer, args_size);
 
   for (;;)
     {
index dae9ef50a023f11f647df1ad63d3b3ce33c27813..00fb21efdf0177411368cf07c3fd4781dd10fef7 100644 (file)
@@ -48,7 +48,7 @@ sal_macro_scope (struct symtab_and_line sal)
   if (COMPUNIT_MACRO_TABLE (cust) == NULL)
     return NULL;
 
-  ms = (struct macro_scope *) xmalloc (sizeof (*ms));
+  ms = XNEW (struct macro_scope);
 
   main_file = macro_main (COMPUNIT_MACRO_TABLE (cust));
   inclusion = macro_lookup_inclusion (main_file, sal.symtab->filename);
index 4c5341ea98ca9b78b2c8784717e2272f408c9bc5..30c020b511d1fd708df411682a8afc3e42324d52 100644 (file)
@@ -1054,9 +1054,9 @@ new_macro_table (struct obstack *obstack, struct bcache *b,
 
   /* First, get storage for the `struct macro_table' itself.  */
   if (obstack)
-    t = obstack_alloc (obstack, sizeof (*t));
+    t = XOBNEW (obstack, struct macro_table);
   else
-    t = xmalloc (sizeof (*t));
+    t = XNEW (struct macro_table);
 
   memset (t, 0, sizeof (*t));
   t->obstack = obstack;
index fc39ce55ee4620eaed649123d0e9a59218b579c9..1e684328054297200efe6ce14b28bc74ea6cf8f7 100644 (file)
@@ -436,7 +436,7 @@ push_parse_stack (void)
   if (top_stack && top_stack->prev)
     newobj = top_stack->prev;
   else
-    newobj = (struct parse_stack *) xzalloc (sizeof (struct parse_stack));
+    newobj = XCNEW (struct parse_stack);
   /* Initialize new frame with previous content.  */
   if (top_stack)
     {
@@ -2395,8 +2395,7 @@ parse_partial_symbols (struct objfile *objfile)
   /* Allocate the map FDR -> PST.
      Minor hack: -O3 images might claim some global data belongs
      to FDR -1.  We`ll go along with that.  */
-  fdr_to_pst = (struct pst_map *)
-    xzalloc ((hdr->ifdMax + 1) * sizeof *fdr_to_pst);
+  fdr_to_pst = XCNEWVEC (struct pst_map, hdr->ifdMax + 1);
   old_chain = make_cleanup (xfree, fdr_to_pst);
   fdr_to_pst++;
   {
@@ -2415,7 +2414,7 @@ parse_partial_symbols (struct objfile *objfile)
          hdr->ifdMax * sizeof (struct mdebug_pending *));
 
   /* Pass 0 over external syms: swap them in.  */
-  ext_block = (EXTR *) xmalloc (hdr->iextMax * sizeof (EXTR));
+  ext_block = XNEWVEC (EXTR, hdr->iextMax);
   make_cleanup (xfree, ext_block);
 
   ext_out = (char *) debug_info->external_ext;
@@ -4135,7 +4134,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
          PDR *pdr_in;
          PDR *pdr_in_end;
 
-         pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR));
+         pr_block = XNEWVEC (PDR, fh->cpd);
          old_chain = make_cleanup (xfree, pr_block);
 
          pdr_ptr = ((char *) debug_info->external_pdr
@@ -4238,7 +4237,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
              PDR *pdr_in;
              PDR *pdr_in_end;
 
-             pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR));
+             pr_block = XNEWVEC (PDR, fh->cpd);
 
              old_chain = make_cleanup (xfree, pr_block);
 
@@ -4831,7 +4830,7 @@ new_block (enum block_type type)
   /* FIXME: carlton/2003-09-11: This should use allocate_block to
      allocate the block.  Which, in turn, suggests that the block
      should be allocated on an obstack.  */
-  struct block *retval = xzalloc (sizeof (struct block));
+  struct block *retval = XCNEW (struct block);
 
   if (type == FUNCTION_BLOCK)
     BLOCK_DICT (retval) = dict_create_linear_expandable ();
index d2831dbe63cc52ee1b989ca1a0cc5b489d48d7d8..d6025765ae42a3db468c8bb9ee1c1d01f6cf638c 100644 (file)
@@ -2441,7 +2441,7 @@ mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     if (gdbarch_tdep (arches->gdbarch)->me_module == me_module)
       return arches->gdbarch;
 
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   /* Get a CGEN CPU descriptor for this architecture.  */
index 3fa1bd6f26515251ee55e8c9ac4c19d0bd163394..907ed69af754ab91177ffcc355701a77fe0cbb98 100644 (file)
@@ -2119,8 +2119,7 @@ mi_execute_command (const char *cmd, int from_tty)
 
       if (do_timings)
        {
-         command->cmd_start = (struct mi_timestamp *)
-           xmalloc (sizeof (struct mi_timestamp));
+         command->cmd_start = XNEW (struct mi_timestamp);
          timestamp (command->cmd_start);
        }
 
index 9231d3b0ea07f0b41728fe7880e5dfe79411c576..1e11c599d341e075ec21cc1e924860cfaffc8840 100644 (file)
@@ -111,7 +111,7 @@ mi_parse_argv (const char *args, struct mi_parse *parse)
 {
   const char *chp = args;
   int argc = 0;
-  char **argv = xmalloc ((argc + 1) * sizeof (char *));
+  char **argv = XNEWVEC (char *, argc + 1);
 
   argv[argc] = NULL;
   while (1)
index 98c2187f7ffc134e0780e126b92565f9efc85360..17c12f9210a0e0ca57328066bbef715523d76507 100644 (file)
@@ -118,7 +118,7 @@ lzma_open (struct bfd *nbfd, void *open_closure)
     }
   xfree (indexdata);
 
-  lstream = xzalloc (sizeof (struct gdb_lzma_stream));
+  lstream = XCNEW (struct gdb_lzma_stream);
   lstream->section = section;
   lstream->index = index;
 
index aba4b4b56c0aee82970aa5de2162ce3222ad67a3..54dcfc8ff969385a71478de0e41067f7af2db048 100644 (file)
@@ -673,8 +673,7 @@ mips_linux_insert_watchpoint (struct target_ops *self,
     return -1;
 
   /* It fit.  Stick it on the end of the list.  */
-  new_watch = (struct mips_watchpoint *)
-    xmalloc (sizeof (struct mips_watchpoint));
+  new_watch = XNEW (struct mips_watchpoint);
   new_watch->addr = addr;
   new_watch->len = len;
   new_watch->type = type;
index e0706dba3765352405821e73c34191c6c9fe95af..89ccea88d4d0122df259d52d60ff73bce4d6300e 100644 (file)
@@ -8608,7 +8608,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     }
 
   /* Need a new architecture.  Fill in a target specific vector.  */
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->elf_flags = elf_flags;
   tdep->mips64_transfers_32bit_regs_p = mips64_transfers_32bit_regs_p;
index 985821ce3ee8c2cbcc68f1e254c12e99d08e3cd0..b5e1fa7baecb24a8f7161ac03e0160ab6f543dd5 100644 (file)
@@ -1403,7 +1403,7 @@ mn10300_gdbarch_init (struct gdbarch_info info,
   if (arches != NULL)
     return arches->gdbarch;
 
-  tdep = xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   switch (info.bfd_arch_info->mach)
index 622ce552040f5af90eeba9720474cf32bc21c6d3..56276aff298f6d480898c562a7f44080c1fde551 100644 (file)
@@ -951,7 +951,7 @@ msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->elf_flags = elf_flags;
   tdep->isa = isa;
index a9c1fbb40b44e3398dac032841b03b7c5d082a23..ddc95229bb094e8ddd5ee1441048cc3ae64fbac9 100644 (file)
@@ -681,7 +681,7 @@ mt_registers_info (struct gdbarch *gdbarch,
          regsize = register_size (gdbarch, regnum);
 
          buff = alloca (regsize);
-         bytes = alloca (regsize * sizeof (*bytes));
+         bytes = XALLOCAVEC (unsigned int, regsize);
 
          deprecated_frame_register_read (frame, regnum, buff);
 
index 121542a22d7118762d75d8901d98f967da4c9243..ba94b002b04d5b0c3fb993be7008b49de4384291 100644 (file)
@@ -68,7 +68,7 @@ aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
 void
 aarch64_linux_new_thread (struct lwp_info *lwp)
 {
-  struct arch_lwp_info *info = xcalloc (1, sizeof (*info));
+  struct arch_lwp_info *info = XNEW (struct arch_lwp_info);
 
   /* Mark that all the hardware breakpoint/watchpoint register pairs
      for this thread need to be initialized (with data from
index 88ddc612782fb92abbd325f1e3aa54e3ba4a2db3..51725ff4a2a1939748e3036c8d982ea44a674590 100644 (file)
@@ -647,7 +647,7 @@ linux_enable_bts (ptid_t ptid, const struct btrace_config_bts *conf)
   __u64 data_offset;
   int pid, pg;
 
-  tinfo = xzalloc (sizeof (*tinfo));
+  tinfo = XCNEW (struct btrace_target_info);
   tinfo->ptid = ptid;
   tinfo->ptr_bits = linux_determine_kernel_ptr_bits ();
 
@@ -780,7 +780,7 @@ linux_enable_pt (ptid_t ptid, const struct btrace_config_pt *conf)
   if (pid == 0)
     pid = ptid_get_pid (ptid);
 
-  tinfo = xzalloc (sizeof (*tinfo));
+  tinfo = XCNEW (struct btrace_target_info);
   tinfo->ptid = ptid;
   tinfo->ptr_bits = 0;
 
index 502356fd90cb948c35ccd6eb81f4b87f74c00135..03e4a86cfb14d07bd2b9960c599f40a17f7353d8 100644 (file)
@@ -337,7 +337,7 @@ linux_xfer_osdata_processes (gdb_byte *readbuf,
                strcpy (user, "?");
 
              /* Find CPU cores used by the process.  */
-             cores = (int *) xcalloc (num_cores, sizeof (int));
+             cores = XCNEWVEC (int, num_cores);
              task_count = get_cores_used_by_process (pid, cores, num_cores);
              cores_str = (char *) xcalloc (task_count, sizeof ("4294967295") + 1);
 
@@ -460,7 +460,7 @@ linux_xfer_osdata_processgroups (gdb_byte *readbuf,
        {
          struct dirent *dp;
          const size_t list_block_size = 512;
-         PID_T *process_list = (PID_T *) xmalloc (list_block_size * 2 * sizeof (PID_T));
+         PID_T *process_list = XNEWVEC (PID_T, list_block_size * 2);
          size_t process_count = 0;
          size_t i;
 
index 11073eeebd4773070447d7e1a5b114da72999e8d..aa59528a10455493061def32137c1bf2ac4042d0 100644 (file)
@@ -2284,7 +2284,7 @@ nios2_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = xcalloc (1, sizeof (struct gdbarch_tdep));
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   /* longjmp support not enabled by default.  */
index b7727628689c6085295488a7562496a7a26189a7..2d1c49a061c94e7fc16e332568af017eb99d32f6 100644 (file)
@@ -486,7 +486,7 @@ procfs_meminfo (char *args, int from_tty)
       return;
     }
 
-  mapinfos = xmalloc (num * sizeof (procfs_mapinfo));
+  mapinfos = XNEWVEC (procfs_mapping, num);
 
   num_mapinfos = num;
   mapinfo_p = mapinfos;
index 661d22fb42edcf39db85602e75df15f4c3058e26..44dfed73021b0206aa8b420eea73c2a216bf291e 100644 (file)
@@ -413,8 +413,7 @@ static char *msglist_sel;
 void
 start_msglist(void)
 {
-  struct selname *newobj =
-    (struct selname *) xmalloc (sizeof (struct selname));
+  struct selname *newobj = XNEW (struct selname);
 
   newobj->next = selname_chain;
   newobj->msglist_len = msglist_len;
@@ -626,7 +625,7 @@ selectors_info (char *regexp, int from_tty)
       printf_filtered (_("Selectors matching \"%s\":\n\n"), 
                       regexp ? regexp : "*");
 
-      sym_arr = alloca (matches * sizeof (struct symbol *));
+      sym_arr = XALLOCAVEC (struct symbol *, matches);
       matches = 0;
       ALL_MSYMBOLS (objfile, msymbol)
        {
@@ -763,7 +762,7 @@ classes_info (char *regexp, int from_tty)
     {
       printf_filtered (_("Classes matching \"%s\":\n\n"), 
                       regexp ? regexp : "*");
-      sym_arr = alloca (matches * sizeof (struct symbol *));
+      sym_arr = XALLOCAVEC (struct symbol *, matches);
       matches = 0;
       ALL_MSYMBOLS (objfile, msymbol)
        {
@@ -1035,8 +1034,7 @@ find_methods (char type, const char *theclass, const char *category,
 
       if (objc_csym == NULL)
        {
-         objc_csym = obstack_alloc (&objfile->objfile_obstack,
-                                    sizeof (*objc_csym));
+         objc_csym = XOBNEW (&objfile->objfile_obstack, unsigned int);
          *objc_csym = objfile_csym;
          set_objfile_data (objfile, objc_objfile_data, objc_csym);
        }
index 93d8b7dea89b483050586bafdde01890490f40e7..907126c3866b71ef80fa5ec88bfda7afe851593d 100644 (file)
@@ -373,7 +373,7 @@ allocate_objfile (bfd *abfd, const char *name, int flags)
   struct objfile *objfile;
   char *expanded_name;
 
-  objfile = (struct objfile *) xzalloc (sizeof (struct objfile));
+  objfile = XCNEW (struct objfile);
   objfile->psymbol_cache = psymbol_bcache_init ();
   /* We could use obstack_specify_allocation here instead, but
      gdb_obstack.h specifies the alloc/dealloc functions.  */
@@ -1385,7 +1385,7 @@ update_section_map (struct program_space *pspace,
       return;
     }
 
-  map = xmalloc (alloc_size * sizeof (*map));
+  map = XNEWVEC (struct obj_section *, alloc_size);
 
   i = 0;
   ALL_PSPACE_OBJFILES (pspace, objfile)
index 2c75567f9c2218919d984e8bee6e0e441f45ddf2..6a269a853c1fd7d9096a2ca008b7c98c2e4076b7 100644 (file)
@@ -187,8 +187,7 @@ gdbarch_register_osabi (enum bfd_architecture arch, unsigned long machine,
        }
     }
 
-  (*handler_p)
-    = (struct gdb_osabi_handler *) xmalloc (sizeof (struct gdb_osabi_handler));
+  (*handler_p) = XNEW (struct gdb_osabi_handler);
   (*handler_p)->next = NULL;
   (*handler_p)->arch_info = arch_info;
   (*handler_p)->osabi = osabi;
@@ -228,8 +227,7 @@ gdbarch_register_osabi_sniffer (enum bfd_architecture arch,
 {
   struct gdb_osabi_sniffer *sniffer;
 
-  sniffer =
-    (struct gdb_osabi_sniffer *) xmalloc (sizeof (struct gdb_osabi_sniffer));
+  sniffer = XNEW (struct gdb_osabi_sniffer);
   sniffer->arch = arch;
   sniffer->flavour = flavour;
   sniffer->sniffer = sniffer_fn;
index 373b0b305241abcf1a769597ab8a3ad56c535d0e..acd48a5de50584bc20184ccbbc39fef932c0891b 100644 (file)
@@ -142,7 +142,7 @@ start_arglist (void)
 {
   struct funcall *newobj;
 
-  newobj = (struct funcall *) xmalloc (sizeof (struct funcall));
+  newobj = XNEW (struct funcall);
   newobj->next = funcall_chain;
   newobj->arglist_len = arglist_len;
   arglist_len = 0;
index 3d99d1ed2bba9d2702555f3a1ec0941d0162768d..55aec00863523055a3669cf1aae2842c3de8032f 100644 (file)
@@ -1528,9 +1528,8 @@ hwdebug_find_thread_points_by_tid (int tid, int alloc_new)
      if the wanted one does not exist?  */
   if (alloc_new)
     {
-      t = xmalloc (sizeof (struct thread_points));
-      t->hw_breaks
-       = xzalloc (max_slots_number * sizeof (struct hw_break_tuple));
+      t = XNEW (struct thread_points);
+      t->hw_breaks = XCNEWVEC (struct hw_break_tuple, max_slots_number);
       t->tid = tid;
       VEC_safe_push (thread_points_p, ppc_threads, t);
     }
@@ -1546,7 +1545,7 @@ hwdebug_insert_point (struct ppc_hw_breakpoint *b, int tid)
 {
   int i;
   long slot;
-  struct ppc_hw_breakpoint *p = xmalloc (sizeof (struct ppc_hw_breakpoint));
+  struct ppc_hw_breakpoint *p = XNEW (struct ppc_hw_breakpoint);
   struct hw_break_tuple *hw_breaks;
   struct cleanup *c = make_cleanup (xfree, p);
   struct thread_points *t;
index 553cc71bf916a4c3838bf18e86eaae7d641ce35b..5729b2472db30201df0ada6f20f4e11496a77d1b 100644 (file)
@@ -1534,7 +1534,7 @@ display_command (char *arg, int from_tty)
   innermost_block = NULL;
   expr = parse_expression (exp);
 
-  newobj = (struct display *) xmalloc (sizeof (struct display));
+  newobj = XNEW (struct display);
 
   newobj->exp_string = xstrdup (exp);
   newobj->exp = expr;
@@ -2256,7 +2256,7 @@ ui_printf (const char *arg, struct ui_file *stream)
   int allocated_args = 20;
   struct cleanup *old_cleanups;
 
-  val_args = xmalloc (allocated_args * sizeof (struct value *));
+  val_args = XNEWVEC (struct value *, allocated_args);
   old_cleanups = make_cleanup (free_current_contents, &val_args);
 
   if (s == 0)
index 3d4f7be3e36742c00a7f80e8217057abafb2a14c..20afdeea3bcb10215195d132de740752821652ca 100644 (file)
@@ -690,7 +690,7 @@ create_procinfo (int pid, int tid)
                                                   create it if it
                                                   doesn't exist yet?  */
 
-  pi = (procinfo *) xmalloc (sizeof (procinfo));
+  pi = XNEW (procinfo);
   memset (pi, 0, sizeof (procinfo));
   pi->pid = pid;
   pi->tid = tid;
@@ -918,7 +918,7 @@ load_syscalls (procinfo *pi)
       maxcall = syscalls[i].pr_number;
 
   pi->num_syscalls = maxcall+1;
-  pi->syscall_names = xmalloc (pi->num_syscalls * sizeof (char *));
+  pi->syscall_names = XNEWVEC (char *, pi->num_syscalls);
 
   for (i = 0; i < pi->num_syscalls; i++)
     pi->syscall_names[i] = NULL;
@@ -2490,7 +2490,7 @@ proc_get_LDT_entry (procinfo *pi, int key)
   /* Allocate space for one LDT entry.
      This alloc must persist, because we return a pointer to it.  */
   if (ldt_entry == NULL)
-    ldt_entry = (struct ssd *) xmalloc (sizeof (struct ssd));
+    ldt_entry = XNEW (struct ssd);
 
   /* Open the file descriptor for the LDT table.  */
   sprintf (pathname, "/proc/%d/ldt", pi->pid);
@@ -2731,7 +2731,7 @@ proc_update_threads (procinfo *pi)
   if ((nlwp = proc_get_nthreads (pi)) <= 1)
     return 1;  /* Process is not multi-threaded; nothing to do.  */
 
-  prstatus = xmalloc (sizeof (gdb_prstatus_t) * (nlwp + 1));
+  prstatus = XNEWVEC (gdb_prstatus_t, nlwp + 1);
 
   old_chain = make_cleanup (xfree, prstatus);
   if (ioctl (pi->ctl_fd, PIOCLSTATUS, prstatus) < 0)
@@ -2825,7 +2825,7 @@ proc_update_threads (procinfo *pi)
   if (nthreads < 2)
     return 0;          /* Nothing to do for 1 or fewer threads.  */
 
-  threads = xmalloc (nthreads * sizeof (tid_t));
+  threads = XNEWVEC (tid_t, nthreads);
 
   if (ioctl (pi->ctl_fd, PIOCTLIST, threads) < 0)
     proc_error (pi, "procfs: update_threads (PIOCTLIST)", __LINE__);
index 5cd83a554807cc5dfc2cc79b4f6a995d965b3191..f239371ea8196c98682426b2c263e0cd91ae3c07 100644 (file)
@@ -314,7 +314,7 @@ struct pv_area
 struct pv_area *
 make_pv_area (int base_reg, int addr_bit)
 {
-  struct pv_area *a = (struct pv_area *) xmalloc (sizeof (*a));
+  struct pv_area *a = XNEW (struct pv_area);
 
   memset (a, 0, sizeof (*a));
 
@@ -490,7 +490,7 @@ pv_area_store (struct pv_area *area,
   else
     {
       CORE_ADDR offset = addr.k;
-      struct area_entry *e = (struct area_entry *) xmalloc (sizeof (*e));
+      struct area_entry *e = XNEW (struct area_entry);
 
       e->offset = offset;
       e->size = size;
index 3c9f5acf4bc062773538b33182fb9581377954ed..f9fafc751dc848ada0cfa5530c30ee2a076067f8 100644 (file)
@@ -1676,8 +1676,7 @@ extend_psymbol_list (struct psymbol_allocation_list *listp,
   if (listp->size == 0)
     {
       new_size = 255;
-      listp->list = (struct partial_symbol **)
-       xmalloc (new_size * sizeof (struct partial_symbol *));
+      listp->list = XNEWVEC (struct partial_symbol *, new_size);
     }
   else
     {
@@ -1758,16 +1757,14 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
   if (objfile->global_psymbols.size > 0)
     {
       objfile->global_psymbols.next =
-       objfile->global_psymbols.list = (struct partial_symbol **)
-       xmalloc ((objfile->global_psymbols.size
-                 * sizeof (struct partial_symbol *)));
+       objfile->global_psymbols.list =
+         XNEWVEC (struct partial_symbol *, objfile->global_psymbols.size);
     }
   if (objfile->static_psymbols.size > 0)
     {
       objfile->static_psymbols.next =
-       objfile->static_psymbols.list = (struct partial_symbol **)
-       xmalloc ((objfile->static_psymbols.size
-                 * sizeof (struct partial_symbol *)));
+       objfile->static_psymbols.list =
+         XNEWVEC (struct partial_symbol *, objfile->static_psymbols.size);
     }
 }
 
index fe8a705cd7618613b9d68fdf0793d95b0664695b..3cfa1d562fb4368a5ee00aef5406fa14f3829a6d 100644 (file)
@@ -332,7 +332,7 @@ add_thread_object (struct thread_info *tp)
 
   inf_obj = (inferior_object *) thread_obj->inf_obj;
 
-  entry = xmalloc (sizeof (struct threadlist_entry));
+  entry = XNEW (struct threadlist_entry);
   entry->thread_obj = thread_obj;
   entry->next = inf_obj->threads;
 
index 06b9ae9c44ec84ead84bb896223dac041bf6cd40..dcc110f002409c91b27d6e7f0b3d666735377e2b 100644 (file)
@@ -594,9 +594,8 @@ compute_enum_values (parmpy_object *self, PyObject *enum_values)
       return 0;
     }
 
-  self->enumeration = xmalloc ((size + 1) * sizeof (char *));
+  self->enumeration = XCNEWVEC (const char *, size + 1);
   back_to = make_cleanup (free_current_contents, &self->enumeration);
-  memset (self->enumeration, 0, (size + 1) * sizeof (char *));
 
   for (i = 0; i < size; ++i)
     {
index ec26bc8c005c8e6e874d6ffcf27f32a4691c8fe6..ac6b224b005887c3714b0e51ad5dead599dea1ba 100644 (file)
@@ -858,7 +858,7 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
     {
       int i;
 
-      vargs = alloca (sizeof (struct value *) * args_count);
+      vargs = XALLOCAVEC (struct value *, args_count);
       for (i = 0; i < args_count; i++)
        {
          PyObject *item = PyTuple_GetItem (args, i);
index ec44d5698418ac6fe4fa924aa7b6081f2d62df68..57f8267f657e0e3208ad56cdae45c82def798061 100644 (file)
@@ -113,7 +113,7 @@ py_varobj_iter_next (struct varobj_iter *self)
       error (_("Invalid item from the child list"));
     }
 
-  vitem = xmalloc (sizeof *vitem);
+  vitem = XNEW (struct varobj_item);
   vitem->value = convert_value_from_python (py_v);
   if (vitem->value == NULL)
     gdbpy_print_stack ();
index 14da62c06d62f34ef0be44cdbde8eac92b046cbd..3a33c752ef91f3323ead457cba195b8afe977172 100644 (file)
@@ -248,7 +248,7 @@ struct cleanup *
 ensure_python_env (struct gdbarch *gdbarch,
                    const struct language_defn *language)
 {
-  struct python_env *env = xmalloc (sizeof *env);
+  struct python_env *env = XNEW (struct python_env);
 
   /* We should not ever enter Python unless initialized.  */
   if (!gdb_python_initialized)
index 2f4317161fec8de6f9e0dba0a4bf1a7de45831cb..9e16ab412dfef3a7a63ed766dac45568361e3465 100644 (file)
@@ -1743,7 +1743,7 @@ record_btrace_start_replaying (struct thread_info *tp)
 
       /* We start replaying at the end of the branch trace.  This corresponds
         to the current instruction.  */
-      replay = xmalloc (sizeof (*replay));
+      replay = XNEW (struct btrace_insn_iterator);
       btrace_insn_end (replay, btinfo);
 
       /* Skip gaps at the end of the trace.  */
index 8c1ca752dba6c70fabd778a8a4e231296bd5db00..06bfdb81306683889eaa9fd3329d58a4f3554e0f 100644 (file)
@@ -244,7 +244,7 @@ record_full_reg_alloc (struct regcache *regcache, int regnum)
   struct record_full_entry *rec;
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
 
-  rec = xcalloc (1, sizeof (struct record_full_entry));
+  rec = XCNEW (struct record_full_entry);
   rec->type = record_full_reg;
   rec->u.reg.num = regnum;
   rec->u.reg.len = register_size (gdbarch, regnum);
@@ -272,7 +272,7 @@ record_full_mem_alloc (CORE_ADDR addr, int len)
 {
   struct record_full_entry *rec;
 
-  rec = xcalloc (1, sizeof (struct record_full_entry));
+  rec = XCNEW (struct record_full_entry);
   rec->type = record_full_mem;
   rec->u.mem.addr = addr;
   rec->u.mem.len = len;
@@ -300,7 +300,7 @@ record_full_end_alloc (void)
 {
   struct record_full_entry *rec;
 
-  rec = xcalloc (1, sizeof (struct record_full_entry));
+  rec = XCNEW (struct record_full_entry);
   rec->type = record_full_end;
 
   return rec;
@@ -2084,9 +2084,7 @@ record_full_core_xfer_partial (struct target_ops *ops,
                      if (!entry)
                        {
                          /* Add a new entry.  */
-                         entry = (struct record_full_core_buf_entry *)
-                           xmalloc
-                           (sizeof (struct record_full_core_buf_entry));
+                         entry = XNEW (struct record_full_core_buf_entry);
                          entry->p = p;
                          if (!bfd_malloc_and_get_section
                                (p->the_bfd_section->owner,
index d440dd44a12c34a0bd3e65e8a7cfd0b647d84155..f1e03d3af27496aeae48eba4f4204af9b51f5cc8 100644 (file)
@@ -496,7 +496,7 @@ get_thread_arch_aspace_regcache (ptid_t ptid, struct gdbarch *gdbarch,
   new_regcache = regcache_xmalloc_1 (gdbarch, aspace, 0);
   new_regcache->ptid = ptid;
 
-  list = xmalloc (sizeof (struct regcache_list));
+  list = XNEW (struct regcache_list);
   list->regcache = new_regcache;
   list->next = current_regcache;
   current_regcache = list;
index 6569822c7f6cca00882b8b9525cdfffb5b02379f..a6bb34dede10a4d6037a8a18a6d9b7f7de7d7e69 100644 (file)
@@ -57,7 +57,7 @@ remote_fileio_init_fd_map (void)
 
   if (!remote_fio_data.fd_map)
     {
-      remote_fio_data.fd_map = (int *) xmalloc (10 * sizeof (int));
+      remote_fio_data.fd_map = XNEWVEC (int, 10);
       remote_fio_data.fd_map_size = 10;
       remote_fio_data.fd_map[0] = FIO_FD_CONSOLE_IN;
       remote_fio_data.fd_map[1] = FIO_FD_CONSOLE_OUT;
index 2d24a9a57f736ff412a82884f145eb8b1d5e0453..3241e7851258dbd218efad59f438bbc6390c45e8 100644 (file)
@@ -238,7 +238,7 @@ do_notif_event_xfree (void *arg)
 struct remote_notif_state *
 remote_notif_state_allocate (void)
 {
-  struct remote_notif_state *notif_state = xzalloc (sizeof (*notif_state));
+  struct remote_notif_state *notif_state = XCNEW (struct remote_notif_state);
 
   notif_state->notif_queue = QUEUE_alloc (notif_client_p, NULL);
 
index 6c9a1b3e972dc99d8f926b08f04823a0174e4737..e11cb5f689d30e7c0d8f5705379eb6a3a8b4ba13 100644 (file)
@@ -1800,7 +1800,7 @@ demand_private_info (ptid_t ptid)
 
   if (!info->priv)
     {
-      info->priv = xmalloc (sizeof (*(info->priv)));
+      info->priv = XNEW (struct private_thread_info);
       info->private_dtor = free_private_thread_info;
       info->priv->core = -1;
       info->priv->extra = 0;
@@ -5659,8 +5659,8 @@ stop_reply_dtr (struct notif_event *event)
 static struct notif_event *
 remote_notif_stop_alloc_reply (void)
 {
-  struct notif_event *r
-    = (struct notif_event *) XNEW (struct stop_reply);
+  /* We cast to a pointer to the "base class".  */
+  struct notif_event *r = (struct notif_event *) XNEW (struct stop_reply);
 
   r->dtr = stop_reply_dtr;
 
@@ -12332,7 +12332,7 @@ remote_enable_btrace (struct target_ops *self, ptid_t ptid,
               target_pid_to_str (ptid));
     }
 
-  tinfo = xzalloc (sizeof (*tinfo));
+  tinfo = XCNEW (struct btrace_target_info);
   tinfo->ptid = ptid;
 
   /* If we fail to read the configuration, we lose some information, but the
index ed55a3a4ddab585b0d4a64cad0da68c77e7f919b..ec8e4fc4591c41bfb7d7247feb71dd1e22b8cf1d 100644 (file)
@@ -142,7 +142,7 @@ save_bookmark_command (char *args, int from_tty)
     error (_("target_get_bookmark failed."));
 
   /* Set up a bookmark struct.  */
-  b = xcalloc (1, sizeof (struct bookmark));
+  b = XCNEW (struct bookmark);
   b->number = ++bookmark_count;
   init_sal (&b->sal);
   b->pc = regcache_read_pc (get_current_regcache ());
index a5861d82611921ba1ff04a1f10bd7c7c989f24e2..0f8790fa8a8db5d50d4e6e3e114ff4d05de4fe9d 100644 (file)
@@ -1396,7 +1396,7 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->elf_flags = elf_flags;
 
index 0bd91ff5f4b6221497aa31d6da55b4c035abf8b5..abafa8d30a764f1777fb5de30a3cc81a461b51ad 100644 (file)
@@ -1045,7 +1045,7 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->elf_flags = elf_flags;
 
index 92205899f60723255bfa2bbcc39712828f1230d6..3bb99c8077b6a34b3056152dee20069de960d9e5 100644 (file)
@@ -558,7 +558,7 @@ s390_insert_watchpoint (struct target_ops *self,
                        struct expression *cond)
 {
   struct lwp_info *lp;
-  struct watch_area *area = xmalloc (sizeof (struct watch_area));
+  struct watch_area *area = XNEW (struct watch_area);
 
   if (!area)
     return -1;
index bbcf6afe60c4302079ac4ec609c544505f17c277..bf23ae2977e34b7f006e45fbd73305db963e3924 100644 (file)
@@ -643,7 +643,7 @@ dos_get_tty_state (struct serial *scb)
        return NULL;
     }
 
-  state = (struct dos_ttystate *) xmalloc (sizeof *state);
+  state = XNEW (struct dos_ttystate);
   *state = *port;
   return (serial_ttystate) state;
 }
@@ -653,7 +653,7 @@ dos_copy_tty_state (struct serial *scb, serial_ttystate ttystate)
 {
   struct dos_ttystate *state;
 
-  state = (struct dos_ttystate *) xmalloc (sizeof *state);
+  state = XNEW (struct dos_ttystate);
   *state = *(struct dos_ttystate *) ttystate;
 
   return (serial_ttystate) state;
index a6ec374be9541b61ac3fd748f5930097bd273c8b..e3a0ec951d4989ba67ae91d00521b38c72c99cbd 100644 (file)
@@ -87,8 +87,7 @@ ser_windows_open (struct serial *scb, const char *name)
       return -1;
     }
 
-  state = xmalloc (sizeof (struct ser_windows_state));
-  memset (state, 0, sizeof (struct ser_windows_state));
+  state = XCNEW (struct ser_windows_state);
   scb->state = state;
 
   /* Create a manual reset event to watch the input buffer.  */
@@ -720,8 +719,7 @@ ser_console_wait_handle (struct serial *scb, HANDLE *read, HANDLE *except)
          return;
        }
 
-      state = xmalloc (sizeof (struct ser_console_state));
-      memset (state, 0, sizeof (struct ser_console_state));
+      state = XCNEW (struct ser_console_state);
       scb->state = state;
 
       if (is_tty)
@@ -792,7 +790,7 @@ ser_console_get_tty_state (struct serial *scb)
     {
       struct ser_console_ttystate *state;
 
-      state = (struct ser_console_ttystate *) xmalloc (sizeof *state);
+      state = XNEW (struct ser_console_ttystate);
       state->is_a_tty = 1;
       return state;
     }
@@ -817,9 +815,8 @@ struct pipe_state
 static struct pipe_state *
 make_pipe_state (void)
 {
-  struct pipe_state *ps = XNEW (struct pipe_state);
+  struct pipe_state *ps = XCNEW (struct pipe_state);
 
-  memset (ps, 0, sizeof (*ps));
   ps->wait.read_event = INVALID_HANDLE_VALUE;
   ps->wait.except_event = INVALID_HANDLE_VALUE;
   ps->wait.start_select = INVALID_HANDLE_VALUE;
@@ -1208,8 +1205,7 @@ net_windows_open (struct serial *scb, const char *name)
   if (ret != 0)
     return ret;
 
-  state = xmalloc (sizeof (struct net_windows_state));
-  memset (state, 0, sizeof (struct net_windows_state));
+  state = XCNEW (struct net_windows_state);
   scb->state = state;
 
   /* Associate an event with the socket.  */
index f2d9ca607c0a105d4f9a19b4e28b8df53b161385..3f0a79a5a2fc9457eed6c1fa69eecd15a09b197e 100644 (file)
@@ -178,9 +178,7 @@ set_tty_state (struct serial *scb, struct hardwire_ttystate *state)
 static serial_ttystate
 hardwire_get_tty_state (struct serial *scb)
 {
-  struct hardwire_ttystate *state;
-
-  state = (struct hardwire_ttystate *) xmalloc (sizeof *state);
+  struct hardwire_ttystate *state = XNEW (struct hardwire_ttystate);
 
   if (get_tty_state (scb, state))
     {
@@ -194,9 +192,8 @@ hardwire_get_tty_state (struct serial *scb)
 static serial_ttystate
 hardwire_copy_tty_state (struct serial *scb, serial_ttystate ttystate)
 {
-  struct hardwire_ttystate *state;
+  struct hardwire_ttystate *state = XNEW (struct hardwire_ttystate);
 
-  state = (struct hardwire_ttystate *) xmalloc (sizeof *state);
   *state = *(struct hardwire_ttystate *) ttystate;
 
   return (serial_ttystate) state;
index 99258f6065ab1e165eb4df4708fa28239eddb26b..a1e6b8eee70ba79b1d55f67781b708c77e530b14 100644 (file)
@@ -66,7 +66,7 @@ DEF_VEC_P(lm_info_p);
 static struct lm_info *
 solib_aix_new_lm_info (struct lm_info *info)
 {
-  struct lm_info *result = xmalloc (sizeof (struct lm_info));
+  struct lm_info *result = XNEW (struct lm_info);
 
   memcpy (result, info, sizeof (struct lm_info));
   result->filename = xstrdup (info->filename);
index 7da5833897c02e181fb13d1097529b3d6376479a..7261e73372bac6812a2484fb274256aaff940524 100644 (file)
@@ -709,8 +709,8 @@ dsbt_current_sos (void)
              break;
            }
 
-         sop = xcalloc (1, sizeof (struct so_list));
-         sop->lm_info = xcalloc (1, sizeof (struct lm_info));
+         sop = XCNEW (struct so_list);
+         sop->lm_info = XCNEW (struct lm_info);
          sop->lm_info->map = loadmap;
          /* Fetch the name.  */
          addr = extract_unsigned_integer (lm_buf.l_name,
@@ -941,7 +941,7 @@ dsbt_relocate_main_executable (void)
   ldm = info->exec_loadmap;
 
   xfree (info->main_executable_lm_info);
-  info->main_executable_lm_info = xcalloc (1, sizeof (struct lm_info));
+  info->main_executable_lm_info = XCNEW (struct lm_info);
   info->main_executable_lm_info->map = ldm;
 
   new_offsets = xcalloc (symfile_objfile->num_sections,
index f7ef38bc320e230d4b29ab5dfabc86585152d520..179974f24d94ad8033c22530dcbd81b6ecc628bc 100644 (file)
@@ -388,8 +388,8 @@ frv_current_sos (void)
              break;
            }
 
-         sop = xcalloc (1, sizeof (struct so_list));
-         sop->lm_info = xcalloc (1, sizeof (struct lm_info));
+         sop = XCNEW (struct so_list);
+         sop->lm_info = XCNEW (struct lm_info);
          sop->lm_info->map = loadmap;
          sop->lm_info->got_value = got_addr;
          sop->lm_info->lm_addr = lm_addr;
@@ -799,7 +799,7 @@ frv_relocate_main_executable (void)
 
   if (main_executable_lm_info)
     xfree (main_executable_lm_info);
-  main_executable_lm_info = xcalloc (1, sizeof (struct lm_info));
+  main_executable_lm_info = XCNEW (struct lm_info);
   main_executable_lm_info->map = ldm;
 
   new_offsets = xcalloc (symfile_objfile->num_sections,
index 64a5c9ce58518b00f33ce01f4a14959ccf29343b..a629ec9818c78f36c71863a160ced3f8661deb7f 100644 (file)
@@ -322,8 +322,8 @@ static bfd *
 spu_bfd_fopen (char *name, CORE_ADDR addr)
 {
   bfd *nbfd;
+  CORE_ADDR *open_closure = XNEW (CORE_ADDR);
 
-  CORE_ADDR *open_closure = xmalloc (sizeof (CORE_ADDR));
   *open_closure = addr;
 
   nbfd = gdb_bfd_openr_iovec (name, "elf32-spu",
index 1fb07d51b6db6f23901e90a81ce716a3a5146b50..36b6c598a4fae80819d34cbfef43e32a5adcdffe 100644 (file)
@@ -210,7 +210,7 @@ lm_info_read (CORE_ADDR lm_addr)
     {
       struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
 
-      lm_info = xzalloc (sizeof (*lm_info));
+      lm_info = XCNEW (struct lm_info);
       lm_info->lm_addr = lm_addr;
 
       lm_info->l_addr_inferior = extract_typed_address (&lm[lmo->l_addr_offset],
@@ -1133,10 +1133,10 @@ svr4_copy_library_list (struct so_list *src)
     {
       struct so_list *newobj;
 
-      newobj = xmalloc (sizeof (struct so_list));
+      newobj = XNEW (struct so_list);
       memcpy (newobj, src, sizeof (struct so_list));
 
-      newobj->lm_info = xmalloc (sizeof (struct lm_info));
+      newobj->lm_info = XNEW (struct lm_info);
       memcpy (newobj->lm_info, src->lm_info, sizeof (struct lm_info));
 
       newobj->next = NULL;
@@ -1323,7 +1323,7 @@ svr4_default_sos (void)
 
   newobj = XCNEW (struct so_list);
 
-  newobj->lm_info = xzalloc (sizeof (struct lm_info));
+  newobj->lm_info = XCNEW (struct lm_info);
 
   /* Nothing will ever check the other fields if we set l_addr_p.  */
   newobj->lm_info->l_addr = info->debug_loader_offset;
index 0c23b7e6d4ed541fb548f966ed152058d966b9c5..fab974c2119a76916ffc2d12616f0abfa61532c7 100644 (file)
@@ -1197,7 +1197,7 @@ find_source_lines (struct symtab *s, int desc)
   int size;
 
   gdb_assert (s);
-  line_charpos = (int *) xmalloc (lines_allocated * sizeof (int));
+  line_charpos = XNEWVEC (int, lines_allocated);
   if (fstat (desc, &st) < 0)
     perror_with_name (symtab_to_filename_for_display (s));
 
@@ -1508,8 +1508,7 @@ line_info (char *arg, int from_tty)
        sal.line = current_source_line;
 
       sals.nelts = 1;
-      sals.sals = (struct symtab_and_line *)
-       xmalloc (sizeof (struct symtab_and_line));
+      sals.sals = XNEW (struct symtab_and_line);
       sals.sals[0] = sal;
     }
   else
@@ -1816,9 +1815,8 @@ void
 add_substitute_path_rule (char *from, char *to)
 {
   struct substitute_path_rule *rule;
-  struct substitute_path_rule *new_rule;
+  struct substitute_path_rule *new_rule = XNEW (struct substitute_path_rule);
 
-  new_rule = xmalloc (sizeof (struct substitute_path_rule));
   new_rule->from = xstrdup (from);
   new_rule->to = xstrdup (to);
   new_rule->next = NULL;
index fd1f996fdd695e14f9951615b33e653083d69978..716212163ecc7dd8e6ad36d26fa0eb89d7bf51d4 100644 (file)
@@ -324,7 +324,7 @@ spu_bfd_open (ULONGEST addr)
   struct bfd *nbfd;
   asection *spu_name;
 
-  ULONGEST *open_closure = xmalloc (sizeof (ULONGEST));
+  ULONGEST *open_closure = XNEW (ULONGEST);
   *open_closure = addr;
 
   nbfd = gdb_bfd_openr_iovec ("<in-memory>", "elf32-spu",
index 75372df47a75bb61b85168cc7f90f9e6924c6744..4c3f77754ece5940171488e314a98600c8f44205 100644 (file)
@@ -2356,7 +2356,7 @@ info_spu_dma_cmdlist (gdb_byte *buf, int nr, enum bfd_endian byte_order)
              NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     };
 
-  int *seq = alloca (nr * sizeof (int));
+  int *seq = XALLOCAVEC (int, nr);
   int done = 0;
   struct cleanup *chain;
   int i, j;
index 03c9eb1364699e3b0d6896e62d293427cf6d2b1e..900344287bf55993f71bc6b005bfb377bb205d7b 100644 (file)
@@ -277,8 +277,7 @@ dbx_lookup_type (int typenums[2], struct objfile *objfile)
          if (old_len == 0)
            {
              type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
-             type_vector = (struct type **)
-               xmalloc (type_vector_length * sizeof (struct type *));
+             type_vector = XNEWVEC (struct type *, type_vector_length);
            }
          while (index >= type_vector_length)
            {
@@ -1809,7 +1808,7 @@ again:
         while (**pp && **pp != '#')
           {
             struct type *arg_type = read_type (pp, objfile);
-            struct type_list *newobj = alloca (sizeof (*newobj));
+            struct type_list *newobj = XALLOCA (struct type_list);
             newobj->type = arg_type;
             newobj->next = arg_types;
             arg_types = newobj;
@@ -2304,10 +2303,8 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type,
       look_ahead_type = NULL;
       length = 0;
 
-      new_fnlist = (struct next_fnfieldlist *)
-       xmalloc (sizeof (struct next_fnfieldlist));
+      new_fnlist = XCNEW (struct next_fnfieldlist);
       make_cleanup (xfree, new_fnlist);
-      memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
 
       if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && is_cplus_marker ((*pp)[2]))
        {
@@ -2346,10 +2343,8 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type,
 
       do
        {
-         new_sublist =
-           (struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
+         new_sublist = XCNEW (struct next_fnfield);
          make_cleanup (xfree, new_sublist);
-         memset (new_sublist, 0, sizeof (struct next_fnfield));
 
          /* Check for and handle cretinous dbx symbol name continuation!  */
          if (look_ahead_type == NULL)
@@ -2637,17 +2632,16 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type,
 
              /* Create a new fn_fieldlist for the destructors.  */
 
-             destr_fnlist = (struct next_fnfieldlist *)
-               xmalloc (sizeof (struct next_fnfieldlist));
+             destr_fnlist = XCNEW (struct next_fnfieldlist);
              make_cleanup (xfree, destr_fnlist);
-             memset (destr_fnlist, 0, sizeof (struct next_fnfieldlist));
+
              destr_fnlist->fn_fieldlist.name
                = obconcat (&objfile->objfile_obstack, "~",
                            new_fnlist->fn_fieldlist.name, (char *) NULL);
 
-             destr_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
-               obstack_alloc (&objfile->objfile_obstack,
-                              sizeof (struct fn_field) * has_destructor);
+             destr_fnlist->fn_fieldlist.fn_fields =
+               XOBNEWVEC (&objfile->objfile_obstack,
+                          struct fn_field, has_destructor);
              memset (destr_fnlist->fn_fieldlist.fn_fields, 0,
                  sizeof (struct fn_field) * has_destructor);
              tmp_sublist = sublist;
@@ -3017,9 +3011,9 @@ read_struct_fields (struct field_info *fip, char **pp, struct type *type,
     {
       STABS_CONTINUE (pp, objfile);
       /* Get space to record the next field's data.  */
-      newobj = (struct nextfield *) xmalloc (sizeof (struct nextfield));
+      newobj = XCNEW (struct nextfield);
       make_cleanup (xfree, newobj);
-      memset (newobj, 0, sizeof (struct nextfield));
+
       newobj->next = fip->list;
       fip->list = newobj;
 
@@ -3139,9 +3133,9 @@ read_baseclasses (struct field_info *fip, char **pp, struct type *type,
 
   for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
     {
-      newobj = (struct nextfield *) xmalloc (sizeof (struct nextfield));
+      newobj = XCNEW (struct nextfield);
       make_cleanup (xfree, newobj);
-      memset (newobj, 0, sizeof (struct nextfield));
+
       newobj->next = fip->list;
       fip->list = newobj;
       FIELD_BITSIZE (newobj->field) = 0;       /* This should be an unpacked
@@ -4299,8 +4293,7 @@ read_args (char **pp, int end, struct objfile *objfile, int *nargsp,
       *varargsp = 0;
     }
 
-  rval = (struct field *) xmalloc (n * sizeof (struct field));
-  memset (rval, 0, n * sizeof (struct field));
+  rval = XCNEWVEC (struct field, n);
   for (i = 0; i < n; i++)
     rval[i].type = types[i];
   *nargsp = n;
@@ -4844,13 +4837,11 @@ _initialize_stabsread (void)
 
   undef_types_allocated = 20;
   undef_types_length = 0;
-  undef_types = (struct type **)
-    xmalloc (undef_types_allocated * sizeof (struct type *));
+  undef_types = XNEWVEC (struct type *, undef_types_allocated);
 
   noname_undefs_allocated = 20;
   noname_undefs_length = 0;
-  noname_undefs = (struct nat *)
-    xmalloc (noname_undefs_allocated * sizeof (struct nat));
+  noname_undefs = XNEWVEC (struct nat, noname_undefs_allocated);
 
   stab_register_index = register_symbol_register_impl (LOC_REGISTER,
                                                       &stab_register_funcs);
index 6d87f6fe6c779413a46d1cdc90f5b9a6ff7bd2ad..7d37dd179fad4ba3f57616d49099c69da2f0ec86 100644 (file)
@@ -2523,8 +2523,7 @@ func_command (char *arg, int from_tty)
   frame = parse_frame_specification ("0");
   sals = decode_line_with_current_source (arg, DECODE_LINE_FUNFIRSTLINE);
   cleanups = make_cleanup (xfree, sals.sals);
-  func_bounds = (struct function_bounds *) xmalloc (
-                             sizeof (struct function_bounds) * sals.nelts);
+  func_bounds = XNEWVEC (struct function_bounds, sals.nelts);
   make_cleanup (xfree, func_bounds);
   for (i = 0; (i < sals.nelts && !found); i++)
     {
index 9ee97672bb1e480463193f9520feaf05c4612741..266402ee534ffc3ef598b6d1a21449276ffa5cbb 100644 (file)
@@ -1467,7 +1467,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
   const char *probe_args = NULL;
   struct stap_probe *ret;
 
-  ret = obstack_alloc (&objfile->per_bfd->storage_obstack, sizeof (*ret));
+  ret = XOBNEW (&objfile->per_bfd->storage_obstack, struct stap_probe);
   ret->p.pops = &stap_probe_ops;
   ret->p.arch = gdbarch;
 
index 0b57c286cc784872d391f948b7ec2ec0202329fb..cbb6d25037efda6e8f57a8eecf2105f1ad144f17 100644 (file)
@@ -555,7 +555,7 @@ addrs_section_sort (struct section_addr_info *addrs)
   int i;
 
   /* `+ 1' for the NULL terminator.  */
-  array = xmalloc (sizeof (*array) * (addrs->num_sections + 1));
+  array = XNEWVEC (struct other_sections *, addrs->num_sections + 1);
   for (i = 0; i < addrs->num_sections; i++)
     array[i] = &addrs->other[i];
   array[i] = NULL;
@@ -614,8 +614,7 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
   /* Now create ADDRS_TO_ABFD_ADDRS from ADDRS_SORTED and
      ABFD_ADDRS_SORTED.  */
 
-  addrs_to_abfd_addrs = xzalloc (sizeof (*addrs_to_abfd_addrs)
-                                * addrs->num_sections);
+  addrs_to_abfd_addrs = XCNEWVEC (struct other_sections *, addrs->num_sections);
   make_cleanup (xfree, addrs_to_abfd_addrs);
 
   while (*addrs_sorted)
@@ -2023,7 +2022,7 @@ load_section_callback (bfd *abfd, asection *asec, void *data)
   new_request = VEC_safe_push (memory_write_request_s,
                               args->requests, NULL);
   memset (new_request, 0, sizeof (struct memory_write_request));
-  section_data = xcalloc (1, sizeof (struct load_progress_section_data));
+  section_data = XCNEW (struct load_progress_section_data);
   new_request->begin = bfd_section_lma (abfd, asec) + args->load_offset;
   new_request->end = new_request->begin + size; /* FIXME Should size
                                                   be in instead?  */
@@ -2256,8 +2255,7 @@ add_symbol_file_command (char *args, int from_tty)
   struct cleanup *my_cleanups = make_cleanup (null_cleanup, NULL);
 
   num_sect_opts = 16;
-  sect_opts = (struct sect_opt *) xmalloc (num_sect_opts
-                                          * sizeof (struct sect_opt));
+  sect_opts = XNEWVEC (struct sect_opt, num_sect_opts);
 
   dont_repeat ();
 
@@ -2833,8 +2831,8 @@ init_filename_language_table (void)
     {
       fl_table_size = 20;
       fl_table_next = 0;
-      filename_language_table =
-       xmalloc (fl_table_size * sizeof (*filename_language_table));
+      filename_language_table = XNEWVEC (filename_language, fl_table_size);
+
       add_filename_language (".c", language_c);
       add_filename_language (".d", language_d);
       add_filename_language (".C", language_cplus);
index 527826527d7d1831138a237f46678678aca71533..1ba691e2a35cc4e7b01572a43ea48b5597637046 100644 (file)
@@ -4135,9 +4135,8 @@ struct filename_seen_cache
 static struct filename_seen_cache *
 create_filename_seen_cache (void)
 {
-  struct filename_seen_cache *cache;
+  struct filename_seen_cache *cache = XNEW (struct filename_seen_cache);
 
-  cache = XNEW (struct filename_seen_cache);
   cache->tab = htab_create_alloc (INITIAL_FILENAME_SEEN_CACHE_SIZE,
                                  filename_hash, filename_eq,
                                  NULL, xcalloc, xfree);
@@ -4372,8 +4371,8 @@ sort_search_symbols_remove_dups (struct symbol_search *found, int nfound,
   gdb_assert (found != NULL && nfound > 0);
 
   /* Build an array out of the list so we can easily sort them.  */
-  symbols = (struct symbol_search **) xmalloc (sizeof (struct symbol_search *)
-                                              * nfound);
+  symbols = XNEWVEC (struct symbol_search *, nfound);
+
   symp = found;
   for (i = 0; i < nfound; i++)
     {
@@ -4659,11 +4658,10 @@ search_symbols (const char *regexp, enum search_domain kind,
                            && SYMBOL_CLASS (sym) == LOC_TYPEDEF))))
              {
                /* match */
-               struct symbol_search *psr = (struct symbol_search *)
-                 xmalloc (sizeof (struct symbol_search));
+               struct symbol_search *psr = XCNEW (struct symbol_search);
+
                psr->block = i;
                psr->symbol = sym;
-               memset (&psr->msymbol, 0, sizeof (psr->msymbol));
                psr->next = NULL;
                if (tail == NULL)
                  found = psr;
@@ -4714,8 +4712,7 @@ search_symbols (const char *regexp, enum search_domain kind,
                        .symbol == NULL)
                      {
                        /* match */
-                       struct symbol_search *psr = (struct symbol_search *)
-                         xmalloc (sizeof (struct symbol_search));
+                       struct symbol_search *psr = XNEW (struct symbol_search);
                        psr->block = i;
                        psr->msymbol.minsym = msymbol;
                        psr->msymbol.objfile = objfile;
index 5ce7f4675f617320e7f7dfafff28fd6ffa71a383..1710e0ceed912e356b33c980a69cd92d0bbee517 100644 (file)
@@ -552,7 +552,7 @@ cleanup_restore_target_terminal (void *arg)
 struct cleanup *
 make_cleanup_restore_target_terminal (void)
 {
-  enum terminal_state *ts = xmalloc (sizeof (*ts));
+  enum terminal_state *ts = XNEW (enum terminal_state);
 
   *ts = terminal_state;
 
index 4dde722fcc13ac2a089699e4cd23cbf0380d7d1b..29c4790bd1c06f5291ef6cb82fbebabc04526618 100644 (file)
@@ -220,9 +220,7 @@ init_thread_list (void)
 static struct thread_info *
 new_thread (ptid_t ptid)
 {
-  struct thread_info *tp;
-
-  tp = xcalloc (1, sizeof (*tp));
+  struct thread_info *tp = XCNEW (struct thread_info);
 
   tp->ptid = ptid;
   tp->num = ++highest_thread_num;
@@ -765,7 +763,7 @@ enable_thread_stack_temporaries (ptid_t ptid)
 
   tp->stack_temporaries_enabled = 1;
   tp->stack_temporaries = NULL;
-  data = (ptid_t *) xmalloc (sizeof (ptid_t));
+  data = XNEW (ptid_t);
   *data = ptid;
   c = make_cleanup (disable_thread_stack_temporaries, data);
 
@@ -1511,9 +1509,8 @@ make_cleanup_restore_current_thread (void)
 {
   struct thread_info *tp;
   struct frame_info *frame;
-  struct current_thread_cleanup *old;
+  struct current_thread_cleanup *old = XNEW (struct current_thread_cleanup);
 
-  old = xmalloc (sizeof (struct current_thread_cleanup));
   old->inferior_ptid = inferior_ptid;
   old->inf_id = current_inferior ()->num;
   old->was_removable = current_inferior ()->removable;
@@ -1617,7 +1614,7 @@ thread_apply_all_command (char *cmd, int from_tty)
 
       /* Save a copy of the thread_list in case we execute detach
          command.  */
-      tp_array = xmalloc (sizeof (struct thread_info *) * tc);
+      tp_array = XNEWVEC (struct thread_info *, tc);
       make_cleanup (xfree, tp_array);
 
       ALL_NON_EXITED_THREADS (tp)
index 3fc56423fff05e467d7d495d6129af40403eae19..2cc38c5de3f8d5f4b8e273ada4992138854e3f66 100644 (file)
@@ -1268,7 +1268,7 @@ tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        return arches->gdbarch;
     }
 
-  tdep = xcalloc (1, sizeof (struct gdbarch_tdep));
+  tdep = XCNEW (struct gdbarch_tdep);
 
   tdep->has_gp = has_gp;
   gdbarch = gdbarch_alloc (&info, tdep);
index cb3c7618c41bf47015e9ea0778491b415b42b9e5..65143d1bba355f41be6e40d5b700d6561fd4d849 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -842,7 +842,7 @@ gdb_readline_wrapper (const char *prompt)
   struct gdb_readline_wrapper_cleanup *cleanup;
   char *retval;
 
-  cleanup = xmalloc (sizeof (*cleanup));
+  cleanup = XNEW (struct gdb_readline_wrapper_cleanup);
   cleanup->handler_orig = input_handler;
   input_handler = gdb_readline_wrapper_line;
 
index 9747036b871421bc7d722337a1e13651e6f47dca..8cc36b82695e82f56a5f3e26421482fdb4b66d83 100644 (file)
@@ -327,7 +327,7 @@ struct trace_file_writer *
 tfile_trace_file_writer_new (void)
 {
   struct tfile_trace_file_writer *writer
-    = xmalloc (sizeof (struct tfile_trace_file_writer));
+    = XNEW (struct tfile_trace_file_writer);
 
   writer->base.ops = &tfile_write_ops;
   writer->fp = NULL;
index af553a325ca61eb82f3aa36f2c20724900ba5701..1e079e9fc13670ac098db73f4cdd6d253435c046 100644 (file)
@@ -2584,8 +2584,7 @@ trace_find_line_command (char *args, int from_tty)
     {
       sal = find_pc_line (get_frame_pc (get_current_frame ()), 0);
       sals.nelts = 1;
-      sals.sals = (struct symtab_and_line *)
-       xmalloc (sizeof (struct symtab_and_line));
+      sals.sals = XNEW (struct symtab_and_line);
       sals.sals[0] = sal;
     }
   else
@@ -3041,7 +3040,7 @@ all_tracepoint_actions_and_cleanup (struct breakpoint *t)
       make_cleanup (xfree, default_collect_line);
 
       validate_actionline (default_collect_line, t);
-      default_collect_action = xmalloc (sizeof (struct command_line));
+      default_collect_action = XNEW (struct command_line);
       make_cleanup (xfree, default_collect_action);
       default_collect_action->next = actions;
       default_collect_action->line = default_collect_line;
@@ -3253,9 +3252,9 @@ restore_current_traceframe_cleanup_dtor (void *arg)
 struct cleanup *
 make_cleanup_restore_current_traceframe (void)
 {
-  struct current_traceframe_cleanup *old;
+  struct current_traceframe_cleanup *old =
+    XNEW (struct current_traceframe_cleanup);
 
-  old = xmalloc (sizeof (struct current_traceframe_cleanup));
   old->traceframe_number = traceframe_number;
 
   return make_cleanup_dtor (do_restore_current_traceframe_cleanup, old,
@@ -3273,8 +3272,8 @@ get_uploaded_tp (int num, ULONGEST addr, struct uploaded_tp **utpp)
   for (utp = *utpp; utp; utp = utp->next)
     if (utp->number == num && utp->addr == addr)
       return utp;
-  utp = (struct uploaded_tp *) xmalloc (sizeof (struct uploaded_tp));
-  memset (utp, 0, sizeof (struct uploaded_tp));
+
+  utp = XCNEW (struct uploaded_tp);
   utp->number = num;
   utp->addr = addr;
   utp->actions = NULL;
@@ -3282,6 +3281,7 @@ get_uploaded_tp (int num, ULONGEST addr, struct uploaded_tp **utpp)
   utp->cmd_strings = NULL;
   utp->next = *utpp;
   *utpp = utp;
+
   return utp;
 }
 
@@ -3309,11 +3309,12 @@ get_uploaded_tsv (int num, struct uploaded_tsv **utsvp)
   for (utsv = *utsvp; utsv; utsv = utsv->next)
     if (utsv->number == num)
       return utsv;
-  utsv = (struct uploaded_tsv *) xmalloc (sizeof (struct uploaded_tsv));
-  memset (utsv, 0, sizeof (struct uploaded_tsv));
+
+  utsv = XCNEW (struct uploaded_tsv);
   utsv->number = num;
   utsv->next = *utsvp;
   *utsvp = utsv;
+
   return utsv;
 }
 
index f610d9cfb2fc0dd44410ec43fc1a95508059397c..4623bf003c3ffa516be72ffa68539257f95ff579 100644 (file)
@@ -439,9 +439,9 @@ tui_initialize_static_data (void)
 struct tui_gen_win_info *
 tui_alloc_generic_win_info (void)
 {
-  struct tui_gen_win_info *win;
+  struct tui_gen_win_info *win = XNEW (struct tui_gen_win_info);
 
-  if ((win = XNEW (struct tui_gen_win_info)) != NULL)
+  if (win != NULL)
     tui_init_generic_part (win);
 
   return win;
@@ -556,9 +556,8 @@ init_win_info (struct tui_win_info *win_info)
 struct tui_win_info *
 tui_alloc_win_info (enum tui_win_type type)
 {
-  struct tui_win_info *win_info;
+  struct tui_win_info *win_info = XNEW (struct tui_win_info);
 
-  win_info = XNEW (struct tui_win_info);
   if (win_info != NULL)
     {
       win_info->generic.type = type;
@@ -577,7 +576,7 @@ tui_alloc_content (int num_elements, enum tui_win_type type)
   char *element_block_ptr;
   int i;
 
-  content = xmalloc (sizeof (struct tui_win_element *) *num_elements);
+  content = XNEWVEC (struct tui_win_element *, num_elements);
   if (content != NULL)
     {
       /*
@@ -634,7 +633,8 @@ tui_add_content_elements (struct tui_gen_win_info *win_info,
     {
       for (i = index_start; (i < num_elements + index_start); i++)
        {
-         if ((element_ptr = XNEW (struct tui_win_element)) != NULL)
+         element_ptr = XNEW (struct tui_win_element);
+         if (element_ptr != NULL)
            {
              win_info->content[i] = (void *) element_ptr;
              init_content_element (element_ptr, win_info->type);
index f86c216677ded129fcee52ebb72eca642c5ffee7..70ee90724f6bc7d39cfaef5c864f77a896ac3cdb 100644 (file)
@@ -99,8 +99,7 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from)
   if (max_lines <= 1)
      return pc;
 
-  asm_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
-                                         * max_lines);
+  asm_lines = XALLOCAVEC (struct tui_asm_line, max_lines);
   memset (asm_lines, 0, sizeof (struct tui_asm_line) * max_lines);
 
   new_low = pc;
@@ -198,8 +197,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
                                                           hilite.  */
 
   /* Get temporary table that will hold all strings (addr & insn).  */
-  asm_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
-                                         * max_lines);
+  asm_lines = XALLOCAVEC (struct tui_asm_line, max_lines);
   memset (asm_lines, 0, sizeof (struct tui_asm_line) * max_lines);
 
   tui_disassemble (gdbarch, asm_lines, pc, max_lines);
index f7f80e63da30213c9744cbd66f00d4d4da584cef..3aa2a7cac8b6bf3114ba1824111dc948d3e6d7d3 100644 (file)
@@ -56,7 +56,7 @@ int ui_file_magic;
 struct ui_file *
 ui_file_new (void)
 {
-  struct ui_file *file = xmalloc (sizeof (struct ui_file));
+  struct ui_file *file = XNEW (struct ui_file);
 
   file->magic = &ui_file_magic;
   set_ui_file_data (file, NULL, null_file_delete);
@@ -514,7 +514,7 @@ static struct ui_file *
 stdio_file_new (FILE *file, int close_p)
 {
   struct ui_file *ui_file = ui_file_new ();
-  struct stdio_file *stdio = xmalloc (sizeof (struct stdio_file));
+  struct stdio_file *stdio = XNEW (struct stdio_file);
 
   stdio->magic = &stdio_file_magic;
   stdio->file = file;
@@ -751,7 +751,7 @@ tee_file_new (struct ui_file *one, int close_one,
              struct ui_file *two, int close_two)
 {
   struct ui_file *ui_file = ui_file_new ();
-  struct tee_file *tee = xmalloc (sizeof (struct tee_file));
+  struct tee_file *tee = XNEW (struct tee_file);
 
   tee->magic = &tee_file_magic;
   tee->one = one;
index 3a05680161e7439cf86e50f65bbad66af775ffdb..fdc486dc1b56c1c4dcd69ea8f066ad0c7dff7829 100644 (file)
@@ -291,8 +291,7 @@ restore_integer (void *p)
 struct cleanup *
 make_cleanup_restore_integer (int *variable)
 {
-  struct restore_integer_closure *c =
-    xmalloc (sizeof (struct restore_integer_closure));
+  struct restore_integer_closure *c = XNEW (struct restore_integer_closure);
 
   c->variable = variable;
   c->value = *variable;
@@ -860,8 +859,8 @@ add_internal_problem_command (struct internal_problem *problem)
   char *set_doc;
   char *show_doc;
 
-  set_cmd_list = xmalloc (sizeof (*set_cmd_list));
-  show_cmd_list = xmalloc (sizeof (*set_cmd_list));
+  set_cmd_list = XNEW (struct cmd_list_element *);
+  show_cmd_list = XNEW (struct cmd_list_element *);
   *set_cmd_list = NULL;
   *show_cmd_list = NULL;
 
index 5698fa9cb2a7160b392c25e4a7d7e63c0d2c7532..401c3597b028e413c754feea388abe245515c373 100644 (file)
@@ -1380,7 +1380,7 @@ v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
       return arches->gdbarch;
     }
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   tdep->e_flags = e_flags;
   tdep->e_machine = e_machine;
 
index 26fdfa666f7f4c11e5815b164b72253d5249d757..173ef4e7bd12871281a9d149a82af1c31b5845ab 100644 (file)
@@ -3028,8 +3028,7 @@ find_oload_champ (struct value **args, int nargs,
          else
            nparms = TYPE_NFIELDS (SYMBOL_TYPE (oload_syms[ix]));
 
-         parm_types = (struct type **)
-           xmalloc (nparms * (sizeof (struct type *)));
+         parm_types = XNEWVEC (struct type *, nparms);
          for (jj = 0; jj < nparms; jj++)
            parm_types[jj] = (fns_ptr != NULL
                              ? (TYPE_FN_FIELD_ARGS (fns_ptr, ix)[jj].type)
index 63ee94df70a1f65c7290f969274829692a5d3dbf..91bf49e43899a3a47822e83e8362bb376d90498f 100644 (file)
@@ -930,7 +930,7 @@ allocate_value_lazy (struct type *type)
      description correctly.  */
   check_typedef (type);
 
-  val = (struct value *) xzalloc (sizeof (struct value));
+  val = XCNEW (struct value);
   val->contents = NULL;
   val->next = all_values;
   all_values = val;
@@ -1823,11 +1823,8 @@ record_latest_value (struct value *val)
   i = value_history_count % VALUE_HISTORY_CHUNK;
   if (i == 0)
     {
-      struct value_history_chunk *newobj
-       = (struct value_history_chunk *)
+      struct value_history_chunk *newobj = XCNEW (struct value_history_chunk);
 
-      xmalloc (sizeof (struct value_history_chunk));
-      memset (newobj->values, 0, sizeof newobj->values);
       newobj->next = value_history_chain;
       value_history_chain = newobj;
     }
@@ -2087,9 +2084,8 @@ complete_internalvar (const char *name)
 struct internalvar *
 create_internalvar (const char *name)
 {
-  struct internalvar *var;
+  struct internalvar *var = XNEW (struct internalvar);
 
-  var = (struct internalvar *) xmalloc (sizeof (struct internalvar));
   var->name = concat (name, (char *)NULL);
   var->kind = INTERNALVAR_VOID;
   var->next = internalvars;
index 15eb90f8611e6f022233469ba1df0464da8c3686..2a95c869483d6d814103dbecf6e40ac582ad0b33 100644 (file)
@@ -1955,7 +1955,7 @@ install_variable (struct varobj *var)
     error (_("Duplicate variable object name"));
 
   /* Add varobj to hash table.  */
-  newvl = xmalloc (sizeof (struct vlist));
+  newvl = XNEW (struct vlist);
   newvl->next = *(varobj_table + index);
   newvl->var = var;
   *(varobj_table + index) = newvl;
@@ -2113,7 +2113,7 @@ new_variable (void)
 {
   struct varobj *var;
 
-  var = (struct varobj *) xmalloc (sizeof (struct varobj));
+  var = XNEW (struct varobj);
   var->name = NULL;
   var->path_expr = NULL;
   var->obj_name = NULL;
@@ -2129,8 +2129,7 @@ new_variable (void)
   var->print_value = NULL;
   var->frozen = 0;
   var->not_fetched = 0;
-  var->dynamic
-    = (struct varobj_dynamic *) xmalloc (sizeof (struct varobj_dynamic));
+  var->dynamic = XNEW (struct varobj_dynamic);
   var->dynamic->children_requested = 0;
   var->from = -1;
   var->to = -1;
@@ -2148,7 +2147,7 @@ new_root_variable (void)
 {
   struct varobj *var = new_variable ();
 
-  var->root = (struct varobj_root *) xmalloc (sizeof (struct varobj_root));
+  var->root = XNEW (struct varobj_root);
   var->root->lang_ops = NULL;
   var->root->exp = NULL;
   var->root->valid_block = NULL;
@@ -2251,7 +2250,7 @@ cppush (struct cpstack **pstack, char *name)
 {
   struct cpstack *s;
 
-  s = (struct cpstack *) xmalloc (sizeof (struct cpstack));
+  s = XNEW (struct cpstack);
   s->name = name;
   s->next = *pstack;
   *pstack = s;
@@ -2792,10 +2791,7 @@ extern void _initialize_varobj (void);
 void
 _initialize_varobj (void)
 {
-  int sizeof_table = sizeof (struct vlist *) * VAROBJ_TABLE_SIZE;
-
-  varobj_table = xmalloc (sizeof_table);
-  memset (varobj_table, 0, sizeof_table);
+  varobj_table = XCNEWVEC (struct vlist *, VAROBJ_TABLE_SIZE);
 
   add_setshow_zuinteger_cmd ("varobj", class_maintenance,
                             &varobjdebug,
index 0b13c72c93ef5b881240931cbd180d2b3e4bbf2c..4ab74b4a6ea7a7f21609041fefe7206d60508a8f 100644 (file)
@@ -607,7 +607,7 @@ windows_make_so (const char *name, LPVOID load_addr)
     }
 #endif
   so = XCNEW (struct so_list);
-  so->lm_info = (struct lm_info *) xmalloc (sizeof (struct lm_info));
+  so->lm_info = XNEW (struct lm_info);
   so->lm_info->load_addr = load_addr;
   strcpy (so->so_original_name, name);
 #ifndef __CYGWIN__
index 13a5d9530e3cfbc2405209ebd8d11f184c621e2e..bfdf0d0814307371cad3377451d4e6bf35b2ea58 100644 (file)
@@ -75,11 +75,9 @@ x86_find_process_pid (pid_t pid)
 static struct x86_process_info *
 x86_add_process (pid_t pid)
 {
-  struct x86_process_info *proc;
+  struct x86_process_info *proc = XCNEW (struct x86_process_info);
 
-  proc = xcalloc (1, sizeof (*proc));
   proc->pid = pid;
-
   proc->next = x86_process_list;
   x86_process_list = proc;
 
index 7a0f0742cdd5c8cadd15cbef10ba23b0fe452f5b..46958013549110d1d314e81120c27c5178bd6dd4 100644 (file)
@@ -435,8 +435,7 @@ arrange_linetable (struct linetable *oldLineTb)
 #define NUM_OF_FUNCTIONS 20
 
   fentry_size = NUM_OF_FUNCTIONS;
-  fentry = (struct linetable_entry *)
-    xmalloc (fentry_size * sizeof (struct linetable_entry));
+  fentry = XNEWVEC (struct linetable_entry, fentry_size);
 
   for (function_count = 0, ii = 0; ii < oldLineTb->nitems; ++ii)
     {
@@ -584,18 +583,14 @@ allocate_include_entry (void)
 {
   if (inclTable == NULL)
     {
-      inclTable = (InclTable *)
-       xmalloc (sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
-      memset (inclTable,
-             '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
+      inclTable = XCNEWVEC (InclTable, INITIAL_INCLUDE_TABLE_LENGTH);
       inclLength = INITIAL_INCLUDE_TABLE_LENGTH;
       inclIndx = 0;
     }
   else if (inclIndx >= inclLength)
     {
       inclLength += INITIAL_INCLUDE_TABLE_LENGTH;
-      inclTable = (InclTable *)
-       xrealloc (inclTable, sizeof (InclTable) * inclLength);
+      inclTable = XRESIZEVEC (InclTable, inclTable, inclLength);
       memset (inclTable + inclLength - INITIAL_INCLUDE_TABLE_LENGTH,
              '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
     }
@@ -679,8 +674,7 @@ process_linenos (CORE_ADDR start, CORE_ADDR end)
            {
              /* Have a new subfile for the include file.  */
 
-             tmpSubfile = inclTable[ii].subfile =
-               (struct subfile *) xmalloc (sizeof (struct subfile));
+             tmpSubfile = inclTable[ii].subfile = XNEW (struct subfile);
 
              memset (tmpSubfile, '\0', sizeof (struct subfile));
              firstLine = &(inclTable[ii].funStartLine);
@@ -1515,8 +1509,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 }
 
 #define        SYMBOL_DUP(SYMBOL1, SYMBOL2)    \
-  (SYMBOL2) = (struct symbol *)                \
-       obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol)); \
+  (SYMBOL2) = XOBNEW (&objfile->objfile_obstack, struct symbol); \
   *(SYMBOL2) = *(SYMBOL1);
 
 
@@ -2023,8 +2016,8 @@ xcoff_start_psymtab (struct objfile *objfile,
                          0,
                          global_syms, static_syms);
 
-  result->read_symtab_private = obstack_alloc (&objfile->objfile_obstack,
-                                              sizeof (struct symloc));
+  result->read_symtab_private =
+    XOBNEW (&objfile->objfile_obstack, struct symloc);
   ((struct symloc *) result->read_symtab_private)->first_symnum = first_symnum;
   result->read_symtab = xcoff_read_symtab;
 
@@ -2064,9 +2057,9 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
   pst->number_of_dependencies = number_dependencies;
   if (number_dependencies)
     {
-      pst->dependencies = (struct partial_symtab **)
-       obstack_alloc (&objfile->objfile_obstack,
-                   number_dependencies * sizeof (struct partial_symtab *));
+      pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack,
+                                    struct partial_symtab *,
+                                    number_dependencies);
       memcpy (pst->dependencies, dependency_list,
              number_dependencies * sizeof (struct partial_symtab *));
     }
@@ -2087,9 +2080,8 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
 
       /* We could save slight bits of space by only making one of these,
          shared by the entire set of include files.  FIXME-someday.  */
-      subpst->dependencies = (struct partial_symtab **)
-       obstack_alloc (&objfile->objfile_obstack,
-                      sizeof (struct partial_symtab *));
+      subpst->dependencies =
+         XOBNEW (&objfile->objfile_obstack, struct partial_symtab *);
       subpst->dependencies[0] = pst;
       subpst->number_of_dependencies = 1;
 
index 9756acb83558174e56053e9098958bf3a41a4c8f..054d56b8653c01f39c9b218af37ab94c16b400d4 100644 (file)
@@ -666,7 +666,7 @@ gdb_xml_parse_attr_ulongest (struct gdb_xml_parser *parser,
     gdb_xml_error (parser, _("Can't convert %s=\"%s\" to an integer"),
                   attribute->name, value);
 
-  ret = xmalloc (sizeof (result));
+  ret = XNEW (ULONGEST);
   memcpy (ret, &result, sizeof (result));
   return ret;
 }
index 4b693edf2683ff988944765126ce209cf19cce3d..c3b22e0fb57a69f3e78e93ccb1c2784bfd677c8b 100644 (file)
@@ -317,7 +317,8 @@ xtensa_register_type (struct gdbarch *gdbarch, int regnum)
              if (tp == NULL)
                {
                  char *name = xstrprintf ("int%d", size * 8);
-                 tp = xmalloc (sizeof (struct ctype_cache));
+
+                 tp = XNEW (struct ctype_cache);
                  tp->next = tdep->type_entries;
                  tdep->type_entries = tp;
                  tp->size = size;