public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Move OpenBSD-only functions from inf-ptrace to obsd-nat
@ 2020-04-16 16:58 Kamil Rytarowski
  2020-04-16 20:07 ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Kamil Rytarowski @ 2020-04-16 16:58 UTC (permalink / raw)
  To: gdb-patches

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.
---
 gdb/ChangeLog    | 15 +++++++++++
 gdb/inf-ptrace.c | 70 ------------------------------------------------
 gdb/inf-ptrace.h | 11 --------
 gdb/obsd-nat.c   | 63 +++++++++++++++++++++++++++++++++++++++++++
 gdb/obsd-nat.h   | 12 +++++++++
 5 files changed, 90 insertions(+), 81 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6c280e3f49f..0ac4ca9f4ef 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,18 @@
+2020-04-15  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-16  Pedro Alves  <palves@redhat.com>

 	* inferior.c (delete_inferior): Use delete operator directly
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 1fa7aa3f73e..cfc0f54f5f1 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -68,42 +68,6 @@ typedef std::unique_ptr<struct target_ops, target_unpusher> target_unpush_up;
 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 */
 \f

 /* Prepare to be traced.  */
@@ -159,23 +123,6 @@ inf_ptrace_target::create_inferior (const char *exec_file,
   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.  */

 void
@@ -255,23 +202,6 @@ inf_ptrace_target::attach (const char *args, int from_tty)
   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.  */

 void
diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h
index 05c1277ec4e..fb0fd629c9d 100644
--- a/gdb/inf-ptrace.h
+++ b/gdb/inf-ptrace.h
@@ -43,17 +43,6 @@ struct inf_ptrace_target : public inf_child_target

   void create_inferior (const char *, const std::string &,
 			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;

diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c
index b1f3d0b1b43..6667a0add7f 100644
--- a/gdb/obsd-nat.c
+++ b/gdb/obsd-nat.c
@@ -161,3 +161,66 @@ obsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 }

 #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 */
diff --git a/gdb/obsd-nat.h b/gdb/obsd-nat.h
index 8b39afc6a25..e5962004d4c 100644
--- a/gdb/obsd-nat.h
+++ b/gdb/obsd-nat.h
@@ -28,6 +28,18 @@ class obsd_nat_target : public inf_ptrace_target
   std::string pid_to_str (ptid_t) override;
   void update_thread_list () 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 */
--
2.25.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Move OpenBSD-only functions from inf-ptrace to obsd-nat
  2020-04-16 16:58 [PATCH] Move OpenBSD-only functions from inf-ptrace to obsd-nat Kamil Rytarowski
@ 2020-04-16 20:07 ` Tom Tromey
  2020-04-16 21:32   ` Kamil Rytarowski
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2020-04-16 20:07 UTC (permalink / raw)
  To: Kamil Rytarowski; +Cc: gdb-patches

>>>>> ">" == Kamil Rytarowski <n54@gmx.com> writes:

>> 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...

I guess these aren't used on Linux, but what about rs6000-nat.c?  Those
are the only non-BSD users of inf_ptrace_target that I can see.

I'm not a big fan of the current code, because makes methods conditional
on this define.  It would be better I guess to have an intermediate
subclass for this situation.  That would make it clear what code does or
does not rely on this.

You don't have to do that, but I don't think we can put this in without
knowing about the rs6000-nat case.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Move OpenBSD-only functions from inf-ptrace to obsd-nat
  2020-04-16 20:07 ` Tom Tromey
@ 2020-04-16 21:32   ` Kamil Rytarowski
  2020-04-20 10:30     ` Kamil Rytarowski
  2020-04-24 15:35     ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Kamil Rytarowski @ 2020-04-16 21:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches


[-- Attachment #1.1: Type: text/plain, Size: 1383 bytes --]

On 16.04.2020 22:07, Tom Tromey wrote:
>>>>>> ">" == Kamil Rytarowski <n54@gmx.com> writes:
> 
>>> All major BSDs implement PT_GET_PROCESS_STATE, but they differ in
>>> details and want to implement follow-fork functionality differently.
> 

Actually I was wrong in this detail. FreeBSD implements
PT_SET_EVENT_MASK, but not PT_GET_PROCESS_STATE.

>>> gdb/ChangeLog:
> 
>>> 	* inf-ptrace.h (follow_fork, insert_fork_catchpoint)
>>> 	(remove_fork_catchpoint, post_startup_inferior)
>>> 	(post_attach): Move...
> 
> I guess these aren't used on Linux, but what about rs6000-nat.c?  Those
> are the only non-BSD users of inf_ptrace_target that I can see.
> 
> I'm not a big fan of the current code, because makes methods conditional
> on this define.  It would be better I guess to have an intermediate
> subclass for this situation.  That would make it clear what code does or
> does not rely on this.
> 

Personally, I would like to see more separation of OS specific features
into OS-private files.

> You don't have to do that, but I don't think we can put this in without
> knowing about the rs6000-nat case.
> 
> Tom
> 

IBM RS/6000 is AIX and it does not support PT_GET_PROCESS_STATE. At
least not in the versions I could check.

There was however support for PT_GET_PROCESS_STATE in HPUX, but HPUX
handling was removed from GDB in 2015.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Move OpenBSD-only functions from inf-ptrace to obsd-nat
  2020-04-16 21:32   ` Kamil Rytarowski
@ 2020-04-20 10:30     ` Kamil Rytarowski
  2020-04-24  9:15       ` Kamil Rytarowski
  2020-04-24 15:35     ` Tom Tromey
  1 sibling, 1 reply; 6+ messages in thread
From: Kamil Rytarowski @ 2020-04-20 10:30 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches


[-- Attachment #1.1: Type: text/plain, Size: 1550 bytes --]

Ping?

I rely on this patch with my other to be submitted code.

On 16.04.2020 23:32, Kamil Rytarowski wrote:
> On 16.04.2020 22:07, Tom Tromey wrote:
>>>>>>> ">" == Kamil Rytarowski <n54@gmx.com> writes:
>>
>>>> All major BSDs implement PT_GET_PROCESS_STATE, but they differ in
>>>> details and want to implement follow-fork functionality differently.
>>
> 
> Actually I was wrong in this detail. FreeBSD implements
> PT_SET_EVENT_MASK, but not PT_GET_PROCESS_STATE.
> 
>>>> gdb/ChangeLog:
>>
>>>> 	* inf-ptrace.h (follow_fork, insert_fork_catchpoint)
>>>> 	(remove_fork_catchpoint, post_startup_inferior)
>>>> 	(post_attach): Move...
>>
>> I guess these aren't used on Linux, but what about rs6000-nat.c?  Those
>> are the only non-BSD users of inf_ptrace_target that I can see.
>>
>> I'm not a big fan of the current code, because makes methods conditional
>> on this define.  It would be better I guess to have an intermediate
>> subclass for this situation.  That would make it clear what code does or
>> does not rely on this.
>>
> 
> Personally, I would like to see more separation of OS specific features
> into OS-private files.
> 
>> You don't have to do that, but I don't think we can put this in without
>> knowing about the rs6000-nat case.
>>
>> Tom
>>
> 
> IBM RS/6000 is AIX and it does not support PT_GET_PROCESS_STATE. At
> least not in the versions I could check.
> 
> There was however support for PT_GET_PROCESS_STATE in HPUX, but HPUX
> handling was removed from GDB in 2015.
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Move OpenBSD-only functions from inf-ptrace to obsd-nat
  2020-04-20 10:30     ` Kamil Rytarowski
@ 2020-04-24  9:15       ` Kamil Rytarowski
  0 siblings, 0 replies; 6+ messages in thread
From: Kamil Rytarowski @ 2020-04-24  9:15 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches


[-- Attachment #1.1: Type: text/plain, Size: 1656 bytes --]

Ping?

On 20.04.2020 12:30, Kamil Rytarowski wrote:
> Ping?
> 
> I rely on this patch with my other to be submitted code.
> 
> On 16.04.2020 23:32, Kamil Rytarowski wrote:
>> On 16.04.2020 22:07, Tom Tromey wrote:
>>>>>>>> ">" == Kamil Rytarowski <n54@gmx.com> writes:
>>>
>>>>> All major BSDs implement PT_GET_PROCESS_STATE, but they differ in
>>>>> details and want to implement follow-fork functionality differently.
>>>
>>
>> Actually I was wrong in this detail. FreeBSD implements
>> PT_SET_EVENT_MASK, but not PT_GET_PROCESS_STATE.
>>
>>>>> gdb/ChangeLog:
>>>
>>>>> 	* inf-ptrace.h (follow_fork, insert_fork_catchpoint)
>>>>> 	(remove_fork_catchpoint, post_startup_inferior)
>>>>> 	(post_attach): Move...
>>>
>>> I guess these aren't used on Linux, but what about rs6000-nat.c?  Those
>>> are the only non-BSD users of inf_ptrace_target that I can see.
>>>
>>> I'm not a big fan of the current code, because makes methods conditional
>>> on this define.  It would be better I guess to have an intermediate
>>> subclass for this situation.  That would make it clear what code does or
>>> does not rely on this.
>>>
>>
>> Personally, I would like to see more separation of OS specific features
>> into OS-private files.
>>
>>> You don't have to do that, but I don't think we can put this in without
>>> knowing about the rs6000-nat case.
>>>
>>> Tom
>>>
>>
>> IBM RS/6000 is AIX and it does not support PT_GET_PROCESS_STATE. At
>> least not in the versions I could check.
>>
>> There was however support for PT_GET_PROCESS_STATE in HPUX, but HPUX
>> handling was removed from GDB in 2015.
>>
> 
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Move OpenBSD-only functions from inf-ptrace to obsd-nat
  2020-04-16 21:32   ` Kamil Rytarowski
  2020-04-20 10:30     ` Kamil Rytarowski
@ 2020-04-24 15:35     ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2020-04-24 15:35 UTC (permalink / raw)
  To: Kamil Rytarowski; +Cc: Tom Tromey, gdb-patches

>>>>> "Kamil" == Kamil Rytarowski <n54@gmx.com> writes:

>> You don't have to do that, but I don't think we can put this in without
>> knowing about the rs6000-nat case.

Kamil> IBM RS/6000 is AIX and it does not support PT_GET_PROCESS_STATE. At
Kamil> least not in the versions I could check.

Kamil> There was however support for PT_GET_PROCESS_STATE in HPUX, but HPUX
Kamil> handling was removed from GDB in 2015.

Thanks.  This is ok then.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-24 15:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-16 16:58 [PATCH] Move OpenBSD-only functions from inf-ptrace to obsd-nat Kamil Rytarowski
2020-04-16 20:07 ` Tom Tromey
2020-04-16 21:32   ` Kamil Rytarowski
2020-04-20 10:30     ` Kamil Rytarowski
2020-04-24  9:15       ` Kamil Rytarowski
2020-04-24 15:35     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).