Make process_info::syscalls_to_catch an std::vector
This patch makes the syscalls_to_catch field of process_info an std::vector<int>. The process_info structure must now be newed/deleted. In handle_extended_wait, the code that handles exec events destroys the existing process_info and creates a new one. It moves the content of syscalls_to_catch from the old to the new vector. I used std::move for that (through an intermediary variable), which should have the same behavior as the old code. gdb/gdbserver/ChangeLog: * 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.
This commit is contained in:
parent
37269bc92c
commit
f27866ba9c
gdb/gdbserver
@ -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>
|
2017-11-16 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* remote-utils.c (remote_close): Block SIGIO signals instead of
|
* remote-utils.c (remote_close): Block SIGIO signals instead of
|
||||||
|
@ -194,10 +194,7 @@ clear_inferiors (void)
|
|||||||
struct process_info *
|
struct process_info *
|
||||||
add_process (int pid, int attached)
|
add_process (int pid, int attached)
|
||||||
{
|
{
|
||||||
struct process_info *process = XCNEW (struct process_info);
|
process_info *process = new process_info (pid, attached);
|
||||||
|
|
||||||
process->pid = pid;
|
|
||||||
process->attached = attached;
|
|
||||||
|
|
||||||
all_processes.push_back (process);
|
all_processes.push_back (process);
|
||||||
|
|
||||||
@ -215,8 +212,7 @@ remove_process (struct process_info *process)
|
|||||||
free_all_breakpoints (process);
|
free_all_breakpoints (process);
|
||||||
gdb_assert (find_thread_process (process) == NULL);
|
gdb_assert (find_thread_process (process) == NULL);
|
||||||
all_processes.remove (process);
|
all_processes.remove (process);
|
||||||
VEC_free (int, process->syscalls_to_catch);
|
delete process;
|
||||||
free (process);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process_info *
|
process_info *
|
||||||
|
@ -33,6 +33,10 @@ struct process_info_private;
|
|||||||
|
|
||||||
struct process_info
|
struct process_info
|
||||||
{
|
{
|
||||||
|
process_info (int pid_, int attached_)
|
||||||
|
: pid (pid_), attached (attached_)
|
||||||
|
{}
|
||||||
|
|
||||||
/* This process' pid. */
|
/* This process' pid. */
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
@ -42,28 +46,28 @@ struct process_info
|
|||||||
|
|
||||||
/* True if GDB asked us to detach from this process, but we remained
|
/* True if GDB asked us to detach from this process, but we remained
|
||||||
attached anyway. */
|
attached anyway. */
|
||||||
int gdb_detached;
|
int gdb_detached = 0;
|
||||||
|
|
||||||
/* The symbol cache. */
|
/* The symbol cache. */
|
||||||
struct sym_cache *symbol_cache;
|
struct sym_cache *symbol_cache = NULL;
|
||||||
|
|
||||||
/* The list of memory breakpoints. */
|
/* The list of memory breakpoints. */
|
||||||
struct breakpoint *breakpoints;
|
struct breakpoint *breakpoints = NULL;
|
||||||
|
|
||||||
/* The list of raw memory breakpoints. */
|
/* The list of raw memory breakpoints. */
|
||||||
struct raw_breakpoint *raw_breakpoints;
|
struct raw_breakpoint *raw_breakpoints = NULL;
|
||||||
|
|
||||||
/* The list of installed fast tracepoints. */
|
/* 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,
|
/* The list of syscalls to report, or just a single element, ANY_SYSCALL,
|
||||||
for unfiltered syscall reporting. */
|
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. */
|
/* Private target data. */
|
||||||
struct process_info_private *priv;
|
struct process_info_private *priv = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Get the pid of PROC. */
|
/* Get the pid of PROC. */
|
||||||
|
@ -683,7 +683,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
|
|||||||
else if (event == PTRACE_EVENT_EXEC && report_exec_events)
|
else if (event == PTRACE_EVENT_EXEC && report_exec_events)
|
||||||
{
|
{
|
||||||
struct process_info *proc;
|
struct process_info *proc;
|
||||||
VEC (int) *syscalls_to_catch;
|
std::vector<int> syscalls_to_catch;
|
||||||
ptid_t event_ptid;
|
ptid_t event_ptid;
|
||||||
pid_t event_pid;
|
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. */
|
/* Save the syscall list from the execing process. */
|
||||||
proc = get_thread_process (event_thr);
|
proc = get_thread_process (event_thr);
|
||||||
syscalls_to_catch = proc->syscalls_to_catch;
|
syscalls_to_catch = std::move (proc->syscalls_to_catch);
|
||||||
proc->syscalls_to_catch = NULL;
|
|
||||||
|
|
||||||
/* Delete the execing process and all its threads. */
|
/* Delete the execing process and all its threads. */
|
||||||
linux_mourn (proc);
|
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
|
/* 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.
|
to avoid sending a new list when the architecture doesn't change.
|
||||||
Also, for ANY_SYSCALL, the architecture doesn't really matter. */
|
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. */
|
/* Report the event. */
|
||||||
*orig_event_lwp = event_lwp;
|
*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 thread_info *thread = get_lwp_thread (event_child);
|
||||||
struct process_info *proc = get_thread_process (thread);
|
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.
|
/* 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
|
static int
|
||||||
gdb_catch_this_syscall_p (struct lwp_info *event_child)
|
gdb_catch_this_syscall_p (struct lwp_info *event_child)
|
||||||
{
|
{
|
||||||
int i, iter;
|
|
||||||
int sysno;
|
int sysno;
|
||||||
struct thread_info *thread = get_lwp_thread (event_child);
|
struct thread_info *thread = get_lwp_thread (event_child);
|
||||||
struct process_info *proc = get_thread_process (thread);
|
struct process_info *proc = get_thread_process (thread);
|
||||||
|
|
||||||
if (VEC_empty (int, proc->syscalls_to_catch))
|
if (proc->syscalls_to_catch.empty ())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VEC_index (int, proc->syscalls_to_catch, 0) == ANY_SYSCALL)
|
if (proc->syscalls_to_catch[0] == ANY_SYSCALL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
get_syscall_trapinfo (event_child, &sysno);
|
get_syscall_trapinfo (event_child, &sysno);
|
||||||
for (i = 0;
|
|
||||||
VEC_iterate (int, proc->syscalls_to_catch, i, iter);
|
for (int iter : proc->syscalls_to_catch)
|
||||||
i++)
|
|
||||||
if (iter == sysno)
|
if (iter == sysno)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ handle_general_set (char *own_buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
process = current_process ();
|
process = current_process ();
|
||||||
VEC_truncate (int, process->syscalls_to_catch, 0);
|
process->syscalls_to_catch.clear ();
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
@ -634,11 +634,11 @@ handle_general_set (char *own_buf)
|
|||||||
while (*p != '\0')
|
while (*p != '\0')
|
||||||
{
|
{
|
||||||
p = decode_address_to_semicolon (&sysno, p);
|
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
|
else
|
||||||
VEC_safe_push (int, process->syscalls_to_catch, ANY_SYSCALL);
|
process->syscalls_to_catch.push_back (ANY_SYSCALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_ok (own_buf);
|
write_ok (own_buf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user