+2017-11-17 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * inferiors.h (struct process_info): Add constructor, initialize
+ fields..
+ <syscalls_to_catch>: Change type to std::vector<int>.
+ * inferiors.c (add_process): Allocate process_info with new.
+ (remove_process): Free process_info with delete.
+ * linux-low.c (handle_extended_wait): Adjust.
+ (gdb_catching_syscalls_p, gdb_catch_this_syscall_p): Adjust.
+ * server.c (handle_general_set): Adjust.
+
2017-11-16 Pedro Alves <palves@redhat.com>
* remote-utils.c (remote_close): Block SIGIO signals instead of
struct process_info *
add_process (int pid, int attached)
{
- struct process_info *process = XCNEW (struct process_info);
-
- process->pid = pid;
- process->attached = attached;
+ process_info *process = new process_info (pid, attached);
all_processes.push_back (process);
free_all_breakpoints (process);
gdb_assert (find_thread_process (process) == NULL);
all_processes.remove (process);
- VEC_free (int, process->syscalls_to_catch);
- free (process);
+ delete process;
}
process_info *
struct process_info
{
+ process_info (int pid_, int attached_)
+ : pid (pid_), attached (attached_)
+ {}
+
/* This process' pid. */
int pid;
/* True if GDB asked us to detach from this process, but we remained
attached anyway. */
- int gdb_detached;
+ int gdb_detached = 0;
/* The symbol cache. */
- struct sym_cache *symbol_cache;
+ struct sym_cache *symbol_cache = NULL;
/* The list of memory breakpoints. */
- struct breakpoint *breakpoints;
+ struct breakpoint *breakpoints = NULL;
/* The list of raw memory breakpoints. */
- struct raw_breakpoint *raw_breakpoints;
+ struct raw_breakpoint *raw_breakpoints = NULL;
/* The list of installed fast tracepoints. */
- struct fast_tracepoint_jump *fast_tracepoint_jumps;
+ struct fast_tracepoint_jump *fast_tracepoint_jumps = NULL;
/* The list of syscalls to report, or just a single element, ANY_SYSCALL,
for unfiltered syscall reporting. */
- VEC (int) *syscalls_to_catch;
+ std::vector<int> syscalls_to_catch;
- const struct target_desc *tdesc;
+ const struct target_desc *tdesc = NULL;
/* Private target data. */
- struct process_info_private *priv;
+ struct process_info_private *priv = NULL;
};
/* Get the pid of PROC. */
else if (event == PTRACE_EVENT_EXEC && report_exec_events)
{
struct process_info *proc;
- VEC (int) *syscalls_to_catch;
+ std::vector<int> syscalls_to_catch;
ptid_t event_ptid;
pid_t event_pid;
/* Save the syscall list from the execing process. */
proc = get_thread_process (event_thr);
- syscalls_to_catch = proc->syscalls_to_catch;
- proc->syscalls_to_catch = NULL;
+ syscalls_to_catch = std::move (proc->syscalls_to_catch);
/* Delete the execing process and all its threads. */
linux_mourn (proc);
/* Restore the list to catch. Don't rely on the client, which is free
to avoid sending a new list when the architecture doesn't change.
Also, for ANY_SYSCALL, the architecture doesn't really matter. */
- proc->syscalls_to_catch = syscalls_to_catch;
+ proc->syscalls_to_catch = std::move (syscalls_to_catch);
/* Report the event. */
*orig_event_lwp = event_lwp;
struct thread_info *thread = get_lwp_thread (event_child);
struct process_info *proc = get_thread_process (thread);
- return !VEC_empty (int, proc->syscalls_to_catch);
+ return !proc->syscalls_to_catch.empty ();
}
/* Returns 1 if GDB is interested in the event_child syscall.
static int
gdb_catch_this_syscall_p (struct lwp_info *event_child)
{
- int i, iter;
int sysno;
struct thread_info *thread = get_lwp_thread (event_child);
struct process_info *proc = get_thread_process (thread);
- if (VEC_empty (int, proc->syscalls_to_catch))
+ if (proc->syscalls_to_catch.empty ())
return 0;
- if (VEC_index (int, proc->syscalls_to_catch, 0) == ANY_SYSCALL)
+ if (proc->syscalls_to_catch[0] == ANY_SYSCALL)
return 1;
get_syscall_trapinfo (event_child, &sysno);
- for (i = 0;
- VEC_iterate (int, proc->syscalls_to_catch, i, iter);
- i++)
+
+ for (int iter : proc->syscalls_to_catch)
if (iter == sysno)
return 1;
}
process = current_process ();
- VEC_truncate (int, process->syscalls_to_catch, 0);
+ process->syscalls_to_catch.clear ();
if (enabled)
{
while (*p != '\0')
{
p = decode_address_to_semicolon (&sysno, p);
- VEC_safe_push (int, process->syscalls_to_catch, (int) sysno);
+ process->syscalls_to_catch.push_back (sysno);
}
}
else
- VEC_safe_push (int, process->syscalls_to_catch, ANY_SYSCALL);
+ process->syscalls_to_catch.push_back (ANY_SYSCALL);
}
write_ok (own_buf);