diff options
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 55 | ||||
-rw-r--r-- | gdb/gdbserver/ax.c | 4 | ||||
-rw-r--r-- | gdb/gdbserver/dll.c | 3 | ||||
-rw-r--r-- | gdb/gdbserver/event-loop.c | 8 | ||||
-rw-r--r-- | gdb/gdbserver/hostio.c | 2 | ||||
-rw-r--r-- | gdb/gdbserver/inferiors.c | 8 | ||||
-rw-r--r-- | gdb/gdbserver/linux-aarch64-low.c | 2 | ||||
-rw-r--r-- | gdb/gdbserver/linux-arm-low.c | 4 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.c | 29 | ||||
-rw-r--r-- | gdb/gdbserver/linux-mips-low.c | 6 | ||||
-rw-r--r-- | gdb/gdbserver/linux-x86-low.c | 4 | ||||
-rw-r--r-- | gdb/gdbserver/lynx-low.c | 2 | ||||
-rw-r--r-- | gdb/gdbserver/mem-break.c | 18 | ||||
-rw-r--r-- | gdb/gdbserver/regcache.c | 3 | ||||
-rw-r--r-- | gdb/gdbserver/remote-utils.c | 2 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 9 | ||||
-rw-r--r-- | gdb/gdbserver/spu-low.c | 4 | ||||
-rw-r--r-- | gdb/gdbserver/target.c | 2 | ||||
-rw-r--r-- | gdb/gdbserver/thread-db.c | 4 | ||||
-rw-r--r-- | gdb/gdbserver/tracepoint.c | 27 | ||||
-rw-r--r-- | gdb/gdbserver/win32-low.c | 4 |
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); |