diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2020-01-23 14:55:50 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-01-23 14:55:50 -0500 |
commit | e7eee665a1524cc4569d0c2f5c9d4aa2be64c9e8 (patch) | |
tree | 3a6604516329537f266caad46f6e5ced02e5ecb4 /gdb/nat | |
parent | c162ed3e66aa985fa2e79d0e7ccd2da80a532c1e (diff) | |
download | gdb-e7eee665a1524cc4569d0c2f5c9d4aa2be64c9e8.zip gdb-e7eee665a1524cc4569d0c2f5c9d4aa2be64c9e8.tar.gz gdb-e7eee665a1524cc4569d0c2f5c9d4aa2be64c9e8.tar.bz2 |
gdb: fix darwin-nat.c build / adapt to multi-target
The darwin-nat.c file doesn't build since the multi-target changes
(5b6d1e4f, "Multi-target support"). This patch makes it build. I have
access to a macOS vm, so I am able to build it, but I wasn't able to
successfully codesign it and try to actually debug something, so I don't
know if it works. I don't have much more time to put on this to figure
it out, so I thought I'd sent the patch anyway, as it's at least a step
in the right direction.
The bulk of the patch is to change a bunch of functions to be methods of
the darwin_nat_target object, so that this can pass `this` to
find_inferior_ptid and other functions that now require a
process_stratum_target pointer.
The darwin_ptrace_him function (renamed to darwin_nat_target::ptrace_him
in this patch) is passed to fork_inferior as the `init_trace_fun`
parameter. Since the method can't be passed as a plain function pointer
(we need the `this` pointer), I changed the `init_trace_fun` parameter
of fork_inferior to be a gdb::function_view, so we can pass a lambda and
capture `this`.
The changes in darwin-nat.h are only to move definition higher in the
file, so that forward declarations are not needed.
gdb/ChangeLog:
* darwin-nat.h (struct darwin_exception_msg, enum
darwin_msg_state, struct darwin_thread_info, darwin_thread_t):
Move up.
(class darwin_nat_target) <wait_1, check_new_threads,
decode_exception_message, decode_message, stop_inferior,
init_thread_list, ptrace_him, cancel_breakpoint>: Declare.
* darwin-nat.c (darwin_check_new_threads): Rename to...
(darwin_nat_target::check_new_threads): ... this.
(darwin_suspend_inferior_it): Remove.
(darwin_decode_exception_message): Rename to...
(darwin_nat_target::decode_exception_message): ... this.
(darwin_nat_target::resume): Pass target to find_inferior_ptid.
(darwin_decode_message): Rename to...
(darwin_nat_target::decode_message): ... this.
(cancel_breakpoint): Rename to...
(darwin_nat_target::cancel_breakpoint): ... this.
(darwin_wait): Rename to...
(darwin_nat_target::wait_1): ... this. Use range-based for loop
instead of iterate_over_inferiors.
(darwin_nat_target::wait): Call wait_1 instead of darwin_wait.
(darwin_stop_inferior): Rename to...
(darwin_nat_target::stop_inferior): ... this.
(darwin_nat_target::kill): Call wait_1 instead of darwin_wait.
(darwin_init_thread_list): Rename to...
(darwin_nat_target::init_thread_list): ... this.
(darwin_ptrace_him): Rename to...
(darwin_nat_target::ptrace_him): ... this.
(darwin_nat_target::create_inferior): Pass lambda function to
fork_inferior.
(darwin_nat_target::detach): Call stop_inferior instead of
darwin_stop_inferior.
* fork-inferior.h (fork_inferior): Change init_trace_fun
parameter to gdb::function_view.
* fork-inferior.c (fork_inferior): Likewise.
Diffstat (limited to 'gdb/nat')
-rw-r--r-- | gdb/nat/fork-inferior.c | 5 | ||||
-rw-r--r-- | gdb/nat/fork-inferior.h | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c index 78f972a..1185ef8 100644 --- a/gdb/nat/fork-inferior.c +++ b/gdb/nat/fork-inferior.c @@ -267,7 +267,8 @@ execv_argv::init_for_shell (const char *exec_file, pid_t fork_inferior (const char *exec_file_arg, const std::string &allargs, char **env, void (*traceme_fun) (), - void (*init_trace_fun) (int), void (*pre_trace_fun) (), + gdb::function_view<void (int)> init_trace_fun, + void (*pre_trace_fun) (), const char *shell_file_arg, void (*exec_fun)(const char *file, char * const *argv, char * const *env)) @@ -439,7 +440,7 @@ fork_inferior (const char *exec_file_arg, const std::string &allargs, initialize anything target-vector-specific that needs initializing. */ if (init_trace_fun) - (*init_trace_fun) (pid); + init_trace_fun (pid); /* We are now in the child process of interest, having exec'd the correct program, and are poised at the first instruction of the diff --git a/gdb/nat/fork-inferior.h b/gdb/nat/fork-inferior.h index 9cbe9bd..cf6f137 100644 --- a/gdb/nat/fork-inferior.h +++ b/gdb/nat/fork-inferior.h @@ -21,6 +21,7 @@ #define NAT_FORK_INFERIOR_H #include <string> +#include "gdbsupport/function-view.h" struct process_stratum_target; @@ -42,7 +43,7 @@ struct process_stratum_target; extern pid_t fork_inferior (const char *exec_file_arg, const std::string &allargs, char **env, void (*traceme_fun) (), - void (*init_trace_fun) (int), + gdb::function_view<void (int)> init_trace_fun, void (*pre_trace_fun) (), const char *shell_file_arg, void (*exec_fun) (const char *file, |