diff options
author | Kamil Rytarowski <n54@gmx.com> | 2020-09-02 19:18:55 +0200 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2020-09-10 15:38:23 +0200 |
commit | feedfcc77379667e4af19e266abc00072e2d262d (patch) | |
tree | a09c6c200a540c425ac6222b34cea648c8ada783 /gdb | |
parent | c489f8c6e61e0b60a4108e10be3681885b253864 (diff) | |
download | gdb-feedfcc77379667e4af19e266abc00072e2d262d.zip gdb-feedfcc77379667e4af19e266abc00072e2d262d.tar.gz gdb-feedfcc77379667e4af19e266abc00072e2d262d.tar.bz2 |
Add netbsd_nat::enable_proc_events in gdb/nat
Add generic function to enable debugger events in a process.
gdb/ChangeLog:
* netbsd-nat.h (netbsd_nat::enable_proc_events): Add.
* netbsd-nat.c: Include <sys/ptrace.h>.
* (netbsd_nat::enable_proc_events): Add.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/nat/netbsd-nat.c | 18 | ||||
-rw-r--r-- | gdb/nat/netbsd-nat.h | 7 |
3 files changed, 31 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 21f30e4..41bd699 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2020-09-10 Kamil Rytarowski <n54@gmx.com> + * netbsd-nat.h (netbsd_nat::enable_proc_events): Add. + * netbsd-nat.c: Include <sys/ptrace.h>. + * (netbsd_nat::enable_proc_events): Add. + +2020-09-10 Kamil Rytarowski <n54@gmx.com> + * netbsd-nat.h: Include "gdbsupport/function-view.h". * (netbsd_nat::thread_alive, netbsd_nat::thread_name) (netbsd_nat::for_each_thread): Add. diff --git a/gdb/nat/netbsd-nat.c b/gdb/nat/netbsd-nat.c index 3f8b8b8..d805b89 100644 --- a/gdb/nat/netbsd-nat.c +++ b/gdb/nat/netbsd-nat.c @@ -22,6 +22,7 @@ #include "gdbsupport/common-debug.h" #include <sys/types.h> +#include <sys/ptrace.h> #include <sys/sysctl.h> #include <cstring> @@ -163,4 +164,21 @@ for_each_thread (pid_t pid, gdb::function_view<void (ptid_t)> callback) netbsd_thread_lister (pid, fn); } +/* See netbsd-nat.h. */ + +void +enable_proc_events (pid_t pid) +{ + int events; + + if (ptrace (PT_GET_EVENT_MASK, pid, &events, sizeof (events)) == -1) + perror_with_name (("ptrace")); + + events |= PTRACE_LWP_CREATE; + events |= PTRACE_LWP_EXIT; + + if (ptrace (PT_SET_EVENT_MASK, pid, &events, sizeof (events)) == -1) + perror_with_name (("ptrace")); +} + } diff --git a/gdb/nat/netbsd-nat.h b/gdb/nat/netbsd-nat.h index 3f2650f..6472cc5 100644 --- a/gdb/nat/netbsd-nat.h +++ b/gdb/nat/netbsd-nat.h @@ -50,6 +50,13 @@ extern const char *thread_name (ptid_t ptid); extern void for_each_thread (pid_t pid, gdb::function_view<void (ptid_t)> callback); + +/* Enable additional event reporting in a new process specified by PID. + + This function assumes internally that the queried process is stopped and + traced. */ + +extern void enable_proc_events (pid_t pid); } #endif |