mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-10 18:28:27 +08:00
Move OpenBSD-only functions from inf-ptrace to obsd-nat
All major BSDs implement PT_GET_PROCESS_STATE, but they differ in details and want to implement follow-fork functionality differently. gdb/ChangeLog: * inf-ptrace.h (follow_fork, insert_fork_catchpoint) (remove_fork_catchpoint, post_startup_inferior) (post_attach): Move... * obsd-nat.h (follow_fork, insert_fork_catchpoint) (remove_fork_catchpoint, post_startup_inferior) (post_attach): ...here. * inf-ptrace.c (follow_fork, insert_fork_catchpoint) (remove_fork_catchpoint, post_startup_inferior) (post_attach): Move... * obsd-nat.c (follow_fork, insert_fork_catchpoint) (remove_fork_catchpoint, post_startup_inferior) (post_attach): ...here.
This commit is contained in:
@ -1,3 +1,18 @@
|
|||||||
|
2020-04-24 Kamil Rytarowski <n54@gmx.com>
|
||||||
|
|
||||||
|
* inf-ptrace.h (follow_fork, insert_fork_catchpoint)
|
||||||
|
(remove_fork_catchpoint, post_startup_inferior)
|
||||||
|
(post_attach): Move...
|
||||||
|
* obsd-nat.h (follow_fork, insert_fork_catchpoint)
|
||||||
|
(remove_fork_catchpoint, post_startup_inferior)
|
||||||
|
(post_attach): ...here.
|
||||||
|
* inf-ptrace.c (follow_fork, insert_fork_catchpoint)
|
||||||
|
(remove_fork_catchpoint, post_startup_inferior)
|
||||||
|
(post_attach): Move...
|
||||||
|
* obsd-nat.c (follow_fork, insert_fork_catchpoint)
|
||||||
|
(remove_fork_catchpoint, post_startup_inferior)
|
||||||
|
(post_attach): ...here.
|
||||||
|
|
||||||
2020-04-24 Tom Tromey <tromey@adacore.com>
|
2020-04-24 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
* nat/windows-nat.h (struct windows_thread_info)
|
* nat/windows-nat.h (struct windows_thread_info)
|
||||||
|
@ -68,42 +68,6 @@ typedef std::unique_ptr<struct target_ops, target_unpusher> target_unpush_up;
|
|||||||
inf_ptrace_target::~inf_ptrace_target ()
|
inf_ptrace_target::~inf_ptrace_target ()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#ifdef PT_GET_PROCESS_STATE
|
|
||||||
|
|
||||||
/* Target hook for follow_fork. On entry and at return inferior_ptid is
|
|
||||||
the ptid of the followed inferior. */
|
|
||||||
|
|
||||||
bool
|
|
||||||
inf_ptrace_target::follow_fork (bool follow_child, bool detach_fork)
|
|
||||||
{
|
|
||||||
if (!follow_child)
|
|
||||||
{
|
|
||||||
struct thread_info *tp = inferior_thread ();
|
|
||||||
pid_t child_pid = tp->pending_follow.value.related_pid.pid ();
|
|
||||||
|
|
||||||
/* Breakpoints have already been detached from the child by
|
|
||||||
infrun.c. */
|
|
||||||
|
|
||||||
if (ptrace (PT_DETACH, child_pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
|
|
||||||
perror_with_name (("ptrace"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
inf_ptrace_target::insert_fork_catchpoint (int pid)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
inf_ptrace_target::remove_fork_catchpoint (int pid)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* PT_GET_PROCESS_STATE */
|
|
||||||
|
|
||||||
|
|
||||||
/* Prepare to be traced. */
|
/* Prepare to be traced. */
|
||||||
@ -159,23 +123,6 @@ inf_ptrace_target::create_inferior (const char *exec_file,
|
|||||||
target_post_startup_inferior (ptid);
|
target_post_startup_inferior (ptid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PT_GET_PROCESS_STATE
|
|
||||||
|
|
||||||
void
|
|
||||||
inf_ptrace_target::post_startup_inferior (ptid_t pid)
|
|
||||||
{
|
|
||||||
ptrace_event_t pe;
|
|
||||||
|
|
||||||
/* Set the initial event mask. */
|
|
||||||
memset (&pe, 0, sizeof pe);
|
|
||||||
pe.pe_set_event |= PTRACE_FORK;
|
|
||||||
if (ptrace (PT_SET_EVENT_MASK, pid.pid (),
|
|
||||||
(PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
|
|
||||||
perror_with_name (("ptrace"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Clean up a rotting corpse of an inferior after it died. */
|
/* Clean up a rotting corpse of an inferior after it died. */
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -255,23 +202,6 @@ inf_ptrace_target::attach (const char *args, int from_tty)
|
|||||||
unpusher.release ();
|
unpusher.release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PT_GET_PROCESS_STATE
|
|
||||||
|
|
||||||
void
|
|
||||||
inf_ptrace_target::post_attach (int pid)
|
|
||||||
{
|
|
||||||
ptrace_event_t pe;
|
|
||||||
|
|
||||||
/* Set the initial event mask. */
|
|
||||||
memset (&pe, 0, sizeof pe);
|
|
||||||
pe.pe_set_event |= PTRACE_FORK;
|
|
||||||
if (ptrace (PT_SET_EVENT_MASK, pid,
|
|
||||||
(PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
|
|
||||||
perror_with_name (("ptrace"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Detach from the inferior. If FROM_TTY is non-zero, be chatty about it. */
|
/* Detach from the inferior. If FROM_TTY is non-zero, be chatty about it. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -43,17 +43,6 @@ struct inf_ptrace_target : public inf_child_target
|
|||||||
|
|
||||||
void create_inferior (const char *, const std::string &,
|
void create_inferior (const char *, const std::string &,
|
||||||
char **, int) override;
|
char **, int) override;
|
||||||
#ifdef PT_GET_PROCESS_STATE
|
|
||||||
bool follow_fork (bool, bool) override;
|
|
||||||
|
|
||||||
int insert_fork_catchpoint (int) override;
|
|
||||||
|
|
||||||
int remove_fork_catchpoint (int) override;
|
|
||||||
|
|
||||||
void post_startup_inferior (ptid_t) override;
|
|
||||||
|
|
||||||
void post_attach (int) override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void mourn_inferior () override;
|
void mourn_inferior () override;
|
||||||
|
|
||||||
|
@ -161,3 +161,66 @@ obsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PT_GET_THREAD_FIRST */
|
#endif /* PT_GET_THREAD_FIRST */
|
||||||
|
|
||||||
|
#ifdef PT_GET_PROCESS_STATE
|
||||||
|
|
||||||
|
void
|
||||||
|
obsd_nat_target::post_attach (int pid)
|
||||||
|
{
|
||||||
|
ptrace_event_t pe;
|
||||||
|
|
||||||
|
/* Set the initial event mask. */
|
||||||
|
memset (&pe, 0, sizeof pe);
|
||||||
|
pe.pe_set_event |= PTRACE_FORK;
|
||||||
|
if (ptrace (PT_SET_EVENT_MASK, pid,
|
||||||
|
(PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
|
||||||
|
perror_with_name (("ptrace"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
obsd_nat_target::post_startup_inferior (ptid_t pid)
|
||||||
|
{
|
||||||
|
ptrace_event_t pe;
|
||||||
|
|
||||||
|
/* Set the initial event mask. */
|
||||||
|
memset (&pe, 0, sizeof pe);
|
||||||
|
pe.pe_set_event |= PTRACE_FORK;
|
||||||
|
if (ptrace (PT_SET_EVENT_MASK, pid.pid (),
|
||||||
|
(PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
|
||||||
|
perror_with_name (("ptrace"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Target hook for follow_fork. On entry and at return inferior_ptid is
|
||||||
|
the ptid of the followed inferior. */
|
||||||
|
|
||||||
|
bool
|
||||||
|
obsd_nat_target::follow_fork (bool follow_child, bool detach_fork)
|
||||||
|
{
|
||||||
|
if (!follow_child)
|
||||||
|
{
|
||||||
|
struct thread_info *tp = inferior_thread ();
|
||||||
|
pid_t child_pid = tp->pending_follow.value.related_pid.pid ();
|
||||||
|
|
||||||
|
/* Breakpoints have already been detached from the child by
|
||||||
|
infrun.c. */
|
||||||
|
|
||||||
|
if (ptrace (PT_DETACH, child_pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
|
||||||
|
perror_with_name (("ptrace"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
obsd_nat_target::insert_fork_catchpoint (int pid)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
obsd_nat_target::remove_fork_catchpoint (int pid)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* PT_GET_PROCESS_STATE */
|
||||||
|
@ -28,6 +28,18 @@ class obsd_nat_target : public inf_ptrace_target
|
|||||||
std::string pid_to_str (ptid_t) override;
|
std::string pid_to_str (ptid_t) override;
|
||||||
void update_thread_list () override;
|
void update_thread_list () override;
|
||||||
ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
|
ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
|
||||||
|
|
||||||
|
#ifdef PT_GET_PROCESS_STATE
|
||||||
|
bool follow_fork (bool, bool) override;
|
||||||
|
|
||||||
|
int insert_fork_catchpoint (int) override;
|
||||||
|
|
||||||
|
int remove_fork_catchpoint (int) override;
|
||||||
|
|
||||||
|
void post_startup_inferior (ptid_t) override;
|
||||||
|
|
||||||
|
void post_attach (int) override;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* obsd-nat.h */
|
#endif /* obsd-nat.h */
|
||||||
|
Reference in New Issue
Block a user