aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/gdbserver/ChangeLog11
-rw-r--r--gdb/gdbserver/inferiors.c8
-rw-r--r--gdb/gdbserver/inferiors.h20
-rw-r--r--gdb/gdbserver/linux-low.c19
-rw-r--r--gdb/gdbserver/server.c6
5 files changed, 36 insertions, 28 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index d091b43..ab59f52 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,14 @@
+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
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index a0ece4d..f4101c7 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -194,10 +194,7 @@ clear_inferiors (void)
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);
@@ -215,8 +212,7 @@ remove_process (struct process_info *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 *
diff --git a/gdb/gdbserver/inferiors.h b/gdb/gdbserver/inferiors.h
index fb0e2fd..4c66a74 100644
--- a/gdb/gdbserver/inferiors.h
+++ b/gdb/gdbserver/inferiors.h
@@ -33,6 +33,10 @@ struct process_info_private;
struct process_info
{
+ process_info (int pid_, int attached_)
+ : pid (pid_), attached (attached_)
+ {}
+
/* This process' pid. */
int pid;
@@ -42,28 +46,28 @@ struct process_info
/* 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. */
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index b367e53..b267c70 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -683,7 +683,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
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;
@@ -699,8 +699,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
/* 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);
@@ -731,7 +730,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
/* 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;
@@ -3182,7 +3181,7 @@ gdb_catching_syscalls_p (struct lwp_info *event_child)
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.
@@ -3191,21 +3190,19 @@ gdb_catching_syscalls_p (struct lwp_info *event_child)
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;
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index e827b9c..f0dac95 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -623,7 +623,7 @@ handle_general_set (char *own_buf)
}
process = current_process ();
- VEC_truncate (int, process->syscalls_to_catch, 0);
+ process->syscalls_to_catch.clear ();
if (enabled)
{
@@ -634,11 +634,11 @@ handle_general_set (char *own_buf)
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);