aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2015-08-26 17:16:07 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2015-08-26 17:18:12 -0400
commit8d7493201cf01c9836403695f67f7e157341bfd5 (patch)
treec3ec1ab17cf4923b2478e71d98352ea8edb72c62 /gdb/gdbserver
parent17d8546e6067d0133f19275d1ccc25cf93cfc7bc (diff)
downloadgdb-8d7493201cf01c9836403695f67f7e157341bfd5.zip
gdb-8d7493201cf01c9836403695f67f7e157341bfd5.tar.gz
gdb-8d7493201cf01c9836403695f67f7e157341bfd5.tar.bz2
Replace some xmalloc-family functions with XNEW-family ones
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.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog55
-rw-r--r--gdb/gdbserver/ax.c4
-rw-r--r--gdb/gdbserver/dll.c3
-rw-r--r--gdb/gdbserver/event-loop.c8
-rw-r--r--gdb/gdbserver/hostio.c2
-rw-r--r--gdb/gdbserver/inferiors.c8
-rw-r--r--gdb/gdbserver/linux-aarch64-low.c2
-rw-r--r--gdb/gdbserver/linux-arm-low.c4
-rw-r--r--gdb/gdbserver/linux-low.c29
-rw-r--r--gdb/gdbserver/linux-mips-low.c6
-rw-r--r--gdb/gdbserver/linux-x86-low.c4
-rw-r--r--gdb/gdbserver/lynx-low.c2
-rw-r--r--gdb/gdbserver/mem-break.c18
-rw-r--r--gdb/gdbserver/regcache.c3
-rw-r--r--gdb/gdbserver/remote-utils.c2
-rw-r--r--gdb/gdbserver/server.c9
-rw-r--r--gdb/gdbserver/spu-low.c4
-rw-r--r--gdb/gdbserver/target.c2
-rw-r--r--gdb/gdbserver/thread-db.c4
-rw-r--r--gdb/gdbserver/tracepoint.c27
-rw-r--r--gdb/gdbserver/win32-low.c4
21 files changed, 122 insertions, 78 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 6d77e94..5b9b170 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -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.
diff --git a/gdb/gdbserver/ax.c b/gdb/gdbserver/ax.c
index f94a27d..d834fbb 100644
--- a/gdb/gdbserver/ax.c
+++ b/gdb/gdbserver/ax.c
@@ -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;
diff --git a/gdb/gdbserver/dll.c b/gdb/gdbserver/dll.c
index 1608527..c4f838c 100644
--- a/gdb/gdbserver/dll.c
+++ b/gdb/gdbserver/dll.c
@@ -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;
diff --git a/gdb/gdbserver/event-loop.c b/gdb/gdbserver/event-loop.c
index d27bc94..dd07093 100644
--- a/gdb/gdbserver/event-loop.c
+++ b/gdb/gdbserver/event-loop.c
@@ -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;
}
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c
index 8788f07..a631d9e 100644
--- a/gdb/gdbserver/hostio.c
+++ b/gdb/gdbserver/hostio.c
@@ -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;
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index ce87d8c..21f45fa 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -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;
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index dbe4951..da0ea9b 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -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);
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 6a27e6e..a277bb6 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -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++)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 2bc91c2..a8fa91c 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -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);
diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c
index 770f0df..d1181b6 100644
--- a/gdb/gdbserver/linux-mips-low.c
+++ b/gdb/gdbserver/linux-mips-low.c
@@ -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;
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 73fe6cd..20d4257 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -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;
diff --git a/gdb/gdbserver/lynx-low.c b/gdb/gdbserver/lynx-low.c
index ee4d0e8..1a187c8 100644
--- a/gdb/gdbserver/lynx-low.c
+++ b/gdb/gdbserver/lynx-low.c
@@ -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;
diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c
index 4eaa52b..9356741 100644
--- a/gdb/gdbserver/mem-break.c
+++ b/gdb/gdbserver/mem-break.c
@@ -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);
diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
index ef955ff..59bdc53 100644
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -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);
}
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index c6c516c..0c4a693 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -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;
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 34fcd2b..c52cf16 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -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;
diff --git a/gdb/gdbserver/spu-low.c b/gdb/gdbserver/spu-low.c
index a110a0e..878ed82 100644
--- a/gdb/gdbserver/spu-low.c
+++ b/gdb/gdbserver/spu-low.c
@@ -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)
diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c
index 8fcfe9b..7540f2f 100644
--- a/gdb/gdbserver/target.c
+++ b/gdb/gdbserver/target.c
@@ -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));
}
diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c
index 3da636e..cd07c52 100644
--- a/gdb/gdbserver/thread-db.c
+++ b/gdb/gdbserver/thread-db.c
@@ -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;
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 5d0ed73..fd010ae 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -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;
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 7ccb3dd..86386ce 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -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);