public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Aditya Kamath1 <Aditya.Kamath1@ibm.com>
To: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Fix attach-twice.c testcase for AIX.
Date: Thu, 25 Jan 2024 12:34:05 +0000	[thread overview]
Message-ID: <CH2PR15MB3544853FA6086198B44B5784D67A2@CH2PR15MB3544.namprd15.prod.outlook.com> (raw)
In-Reply-To: <e6c9aca1cc7f042e9309f36e7073f6fd7530175a.camel@de.ibm.com>


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


  reply	other threads:[~2024-01-25 12:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25  3:57 Aditya Kamath1
2024-01-25 11:29 ` Ulrich Weigand
2024-01-25 12:34   ` Aditya Kamath1 [this message]
2024-01-25 13:57     ` Ulrich Weigand
2024-01-25 14:42       ` Aditya Kamath1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CH2PR15MB3544853FA6086198B44B5784D67A2@CH2PR15MB3544.namprd15.prod.outlook.com \
    --to=aditya.kamath1@ibm.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).