public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix attach-twice.c testcase for AIX.
@ 2024-01-25  3:57 Aditya Kamath1
  2024-01-25 11:29 ` Ulrich Weigand
  0 siblings, 1 reply; 5+ messages in thread
From: Aditya Kamath1 @ 2024-01-25  3:57 UTC (permalink / raw)
  To: Ulrich Weigand, Aditya Kamath1 via Gdb-patches; +Cc: Sangamesh Mallayya


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

Respected community members,

Hi,

Please find attached a patch. (See: 0001-Fix-attach-twice.c-testcase-for-AIX.patch)

This is a small fix to resolve the attach-twice untested test case in AIX. Currently we are getting an error

gdb/testsuite/gdb.base/attach-twice.c:43:7: error: too few arguments to function 'ptrace'

which is why this testcase is untested. In AIX, we use 5 arguments for ptrace. Kindly give me your feedback for the same.

Have a nice day ahead.

Thanks and regards,
Aditya.

[-- Attachment #2: 0001-Fix-attach-twice.c-testcase-for-AIX.patch --]
[-- Type: application/octet-stream, Size: 1640 bytes --]

From 000cf41f3048f5df1a90fbeda5a6091c68b97734 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Wed, 24 Jan 2024 21:51:04 -0600
Subject: [PATCH] Fix attach-twice.c testcase for AIX.

Currently, in AIX attach-twice.exp testcase is untested due to the below error.
gdb/testsuite/gdb.base/attach-twice.c:43:7: error: too few arguments to function 'ptrace'

This is because in AIX ptrace has five arguments. This patch is a fix for the same such that
this test case runs in AIX and other targets as well.
---
 gdb/testsuite/gdb.base/attach-twice.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.base/attach-twice.c b/gdb/testsuite/gdb.base/attach-twice.c
index ecb882a0e7b..19687116739 100644
--- a/gdb/testsuite/gdb.base/attach-twice.c
+++ b/gdb/testsuite/gdb.base/attach-twice.c
@@ -26,6 +26,14 @@
 #define PTRACE_ATTACH PT_ATTACH
 #endif
 
+#ifdef _AIX
+#define PTRACE_FUNC ptrace64 (PTRACE_ATTACH, getppid (), NULL, 0, NULL)
+#elif
+/* The 4th argument to ptrace () is 0 on purpose, as it is compatible
+     between kernels that accept void* (like Linux) and int (NetBSD).  */
+#define PTRACE_FUNC ptrace (PTRACE_ATTACH, getppid (), NULL, 0); 
+#endif
+
 int
 main (void)
 {
@@ -38,9 +46,7 @@ main (void)
       exit (1);
     case 0:
       errno = 0;
-      /* The 4th argument to ptrace () is 0 on purpose, as it is compatible
-	 between kernels that accept void* (like Linux) and int (NetBSD).  */
-      ptrace (PTRACE_ATTACH, getppid (), NULL, 0);
+      PTRACE_FUNC;
       if (errno != 0)
 	perror ("PTRACE_ATTACH");
       break;
-- 
2.41.0


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

* Re: [PATCH] Fix attach-twice.c testcase for AIX.
  2024-01-25  3:57 [PATCH] Fix attach-twice.c testcase for AIX Aditya Kamath1
@ 2024-01-25 11:29 ` Ulrich Weigand
  2024-01-25 12:34   ` Aditya Kamath1
  0 siblings, 1 reply; 5+ messages in thread
From: Ulrich Weigand @ 2024-01-25 11:29 UTC (permalink / raw)
  To: gdb-patches, Aditya Kamath1; +Cc: Sangamesh Mallayya

Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:
  
>This is a small fix to resolve the attach-twice untested test case in AIX.
>Currently we are getting an error
>
>gdb/testsuite/gdb.base/attach-twice.c:43:7: error: too few arguments to function 'ptrace'
>
>which is why this testcase is untested. In AIX, we use 5 arguments for ptrace.

I see.  I guess the change is reasonable, however:

- It doesn't seem really useful to introduce the PTRACE_FUNC macro;
  just put the #ifdef _AIX directly in place instead.

- In addition to the fifth argument, your patch also changes ptrace to
  ptrace64 - is that necessary?  If not, it seems leaving it as ptrace
  would be less surprising.

Bye,
Ulrich


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

* Re: [PATCH] Fix attach-twice.c testcase for AIX.
  2024-01-25 11:29 ` Ulrich Weigand
@ 2024-01-25 12:34   ` Aditya Kamath1
  2024-01-25 13:57     ` Ulrich Weigand
  0 siblings, 1 reply; 5+ messages in thread
From: Aditya Kamath1 @ 2024-01-25 12:34 UTC (permalink / raw)
  To: Ulrich Weigand, gdb-patches; +Cc: Sangamesh Mallayya


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

Respected Ulrich and community members,

Please find attached the patch. (See: 0001-Fix-attach-twice.c-testcase-for-AIX.patch)

>- It doesn't seem really useful to introduce the PTRACE_FUNC macro;
  >just put the #ifdef _AIX directly in place instead.

We now have this.

>- In addition to the fifth argument, your patch also changes ptrace to
 >ptrace64 - is that necessary?  If not, it seems leaving it as ptrace
 > would be less surprising.

Yes it is. Thank you for reminding me. As per this document (https://www.ibm.com/docs/en/aix/7.2?topic=p-ptrace-ptracex-ptrace64-subroutine) we will need to keep it as ptrace64 if we execute in 64 bit mode. So I have taken care of the same in this version of the patch.

Kindly let me know if this version is okay.

Have a nice day ahead.

Thanks and regards,
Aditya.



From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Date: Thursday, 25 January 2024 at 4:59 PM
To: gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Fix attach-twice.c testcase for AIX.
Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:

>This is a small fix to resolve the attach-twice untested test case in AIX.
>Currently we are getting an error
>
>gdb/testsuite/gdb.base/attach-twice.c:43:7: error: too few arguments to function 'ptrace'
>
>which is why this testcase is untested. In AIX, we use 5 arguments for ptrace.

I see.  I guess the change is reasonable, however:

- It doesn't seem really useful to introduce the PTRACE_FUNC macro;
  just put the #ifdef _AIX directly in place instead.

- In addition to the fifth argument, your patch also changes ptrace to
  ptrace64 - is that necessary?  If not, it seems leaving it as ptrace
  would be less surprising.

Bye,
Ulrich

[-- Attachment #2: 0001-Fix-attach-twice.c-testcase-for-AIX.patch --]
[-- Type: application/octet-stream, Size: 1443 bytes --]

From 9b2deb724046d86e9744db6b90bb94756eb666b7 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Thu, 25 Jan 2024 06:28:29 -0600
Subject: [PATCH] Fix attach-twice.c testcase for AIX.

Currently, in AIX attach-twice.exp testcase is untested due to the below error.
gdb/testsuite/gdb.base/attach-twice.c:43:7: error: too few arguments to function 'ptrace'

This is because in AIX ptrace has five arguments. This patch is a fix for the same such that
this test case runs in AIX and other targets as well.
---
 gdb/testsuite/gdb.base/attach-twice.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gdb/testsuite/gdb.base/attach-twice.c b/gdb/testsuite/gdb.base/attach-twice.c
index ecb882a0e7b..7b0af35a566 100644
--- a/gdb/testsuite/gdb.base/attach-twice.c
+++ b/gdb/testsuite/gdb.base/attach-twice.c
@@ -38,9 +38,15 @@ main (void)
       exit (1);
     case 0:
       errno = 0;
+      #if defined(_AIX) && defined (__64BIT__)
+      ptrace64 (PTRACE_ATTACH, getppid (), NULL, 0, NULL);
+      #elif defined(_AIX) && !defined (__64BIT__)
+      ptrace (PTRACE_ATTACH, getppid (), NULL, 0, NULL);
+      #else
       /* The 4th argument to ptrace () is 0 on purpose, as it is compatible
 	 between kernels that accept void* (like Linux) and int (NetBSD).  */
       ptrace (PTRACE_ATTACH, getppid (), NULL, 0);
+      #endif
       if (errno != 0)
 	perror ("PTRACE_ATTACH");
       break;
-- 
2.41.0


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

* Re: [PATCH] Fix attach-twice.c testcase for AIX.
  2024-01-25 12:34   ` Aditya Kamath1
@ 2024-01-25 13:57     ` Ulrich Weigand
  2024-01-25 14:42       ` Aditya Kamath1
  0 siblings, 1 reply; 5+ messages in thread
From: Ulrich Weigand @ 2024-01-25 13:57 UTC (permalink / raw)
  To: gdb-patches, Aditya Kamath1; +Cc: Sangamesh Mallayya

Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:

>Yes it is. Thank you for reminding me. As per this document
>(https://www.ibm.com/docs/en/aix/7.2?topic=p-ptrace-ptracex-ptrace64-subroutine)
>we will need to keep it as ptrace64 if we execute in 64 bit mode.
>So I have taken care of the same in this version of the patch.

This is OK.  I've applied the patch now.

Thanks,
Ulrich


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

* Re: [PATCH] Fix attach-twice.c testcase for AIX.
  2024-01-25 13:57     ` Ulrich Weigand
@ 2024-01-25 14:42       ` Aditya Kamath1
  0 siblings, 0 replies; 5+ messages in thread
From: Aditya Kamath1 @ 2024-01-25 14:42 UTC (permalink / raw)
  To: Ulrich Weigand, gdb-patches; +Cc: Sangamesh Mallayya

[-- Attachment #1: Type: text/plain, Size: 711 bytes --]

Thanks

From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Date: Thursday, 25 January 2024 at 7:27 PM
To: gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Fix attach-twice.c testcase for AIX.
Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:

>Yes it is. Thank you for reminding me. As per this document
>(https://www.ibm.com/docs/en/aix/7.2?topic=p-ptrace-ptracex-ptrace64-subroutine)
>we will need to keep it as ptrace64 if we execute in 64 bit mode.
>So I have taken care of the same in this version of the patch.

This is OK.  I've applied the patch now.

Thanks,
Ulrich

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

end of thread, other threads:[~2024-01-25 14:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25  3:57 [PATCH] Fix attach-twice.c testcase for AIX Aditya Kamath1
2024-01-25 11:29 ` Ulrich Weigand
2024-01-25 12:34   ` Aditya Kamath1
2024-01-25 13:57     ` Ulrich Weigand
2024-01-25 14:42       ` Aditya Kamath1

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