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>,
	"simark@simark.ca" <simark@simark.ca>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Modify altivec-regs.exp testcase for AIX
Date: Mon, 6 Mar 2023 07:49:34 +0000	[thread overview]
Message-ID: <CH2PR15MB3544B34C1C748B42FAAF1CFFD6B69@CH2PR15MB3544.namprd15.prod.outlook.com> (raw)
In-Reply-To: <aac264442b8f051f7fe01d56cd4e3d8c70caa243.camel@de.ibm.com>


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

Hi Ulrich and community,

Please find attached the patch. {See: 0001-Modify-altivec-regs.exp-testcase-for-AIX.patch}. I have modified the test case as per your guidance.

>#ifdef _AIX
 > /* On AIX, the debugger cannot access vector registers before they
 >    are first used by the inferior.  Perform such an access here.  */
 > x = ((vector unsigned int) vec_splat_u8 (0));
>#endif

This is something new I learnt. Thank you so much. The idea is nice. This way power-pc Linux GDB folks won’t be affected.

Kindly push this patch if there are no further changes.

Have a nice day.

Thanks and regards,
Aditya.

From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Date: Friday, 3 March 2023 at 9:20 PM
To: gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>, simark@simark.ca <simark@simark.ca>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Modify altivec-regs.exp testcase for AIX
Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:
>>I think it would be preferable to instead extend the
>>test case (when compiled on AIX only) by adding some
>>other instruction early in main, but before that
>>assignment to x, that touches a vector register,
>>and then perform the GDB register tests after that
>>new instruction and before the assignment to x.
>
>So I do not have the knowledge to do that. I had seen the align-c
>test case which uses a tcl script and can do the same. However
>in .exp file how can we do it? Do you have an example which I
>can look into and learn how to does it, anything different also
>is fine. Kindly let me know. It will be of help to me,
>to contribute the same.

The test case source file currently looks like this:

int
main ()
{
  vector unsigned int y;
  vector unsigned int x;
  vector unsigned int z;
  int a;

  /* This line may look unnecessary but we do need it, because we want to
     have a line to do a next over (so that gdb refetches the registers)
     and we don't want the code to change any vector registers.
     The splat operations below modify the VRs,i
     so we don't want to execute them yet.  */
  a = 9;
  x = ((vector unsigned int) vec_splat_u8 (-2));
  y = ((vector unsigned int) vec_splat_u8 (1));


I was thinking of simply modifying it along those lines:

int
main ()
{
  vector unsigned int y;
  vector unsigned int x;
  vector unsigned int z;
  int a;

#ifdef _AIX
  /* On AIX, the debugger cannot access vector registers before they
     are first used by the inferior.  Perform such an access here.  */
  x = ((vector unsigned int) vec_splat_u8 (0));
#endif

  /* This line may look unnecessary but we do need it, because we want to
     have a line to do a next over (so that gdb refetches the registers)
     and we don't want the code to change any vector registers.
     The splat operations below modify the VRs,i
     so we don't want to execute them yet.  */
  a = 9;  /* start here */
  x = ((vector unsigned int) vec_splat_u8 (-2));
  y = ((vector unsigned int) vec_splat_u8 (1));


And then, in the .exp file, instead of just doing a runto_main,
set a breakpoint on the /* start here */ line, and continue
until that is hit.  Something along the lines of:

    gdb_breakpoint [gdb_get_line_number "start here"]
    gdb_continue_to_breakpoint "start here"

(You can look at many other test cases as examples.)

On non-AIX platforms, this will have no actual effect,
as the /* start here */ line is still the first line
in the main routine.  But on AIX, it will have the expected
effect that we first touch a vector register, and then do
exactly the same test sequence as elsewhere.


Bye,
Ulrich

[-- Attachment #2: 0001-Modify-altivec-regs.exp-testcase-for-AIX.patch --]
[-- Type: application/octet-stream, Size: 2080 bytes --]

From 20d571d02a5fd7dce6f97523d0385a308077bc4f Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Mon, 6 Mar 2023 01:31:34 -0600
Subject: [PATCH] Modify altivec-regs.exp testcase for AIX

On AIX, the debugger cannot access vector registers before they
are first used by the inferior.  Hence we change the test case
such that some vector registers are accessed by the variable 'x' in AIX
and other targets are not affected as a consequence of the same.
---
 gdb/testsuite/gdb.arch/altivec-regs.c   | 8 +++++++-
 gdb/testsuite/gdb.arch/altivec-regs.exp | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.arch/altivec-regs.c b/gdb/testsuite/gdb.arch/altivec-regs.c
index 4d4fe3f5dbb..a87f6a0a054 100644
--- a/gdb/testsuite/gdb.arch/altivec-regs.c
+++ b/gdb/testsuite/gdb.arch/altivec-regs.c
@@ -20,12 +20,18 @@ main ()
   vector unsigned int z; 
   int a;
 
+  #ifdef _AIX
+  /* On AIX, the debugger cannot access vector registers before they
+     are first used by the inferior.  Perform such an access here.  */
+  x = ((vector unsigned int) vec_splat_u8 (0));
+  #endif
+
   /* This line may look unnecessary but we do need it, because we want to
      have a line to do a next over (so that gdb refetches the registers)
      and we don't want the code to change any vector registers.
      The splat operations below modify the VRs,i
      so we don't want to execute them yet.  */
-  a = 9;
+  a = 9; /* start here */
   x = ((vector unsigned int) vec_splat_u8 (-2));
   y = ((vector unsigned int) vec_splat_u8 (1));
 	
diff --git a/gdb/testsuite/gdb.arch/altivec-regs.exp b/gdb/testsuite/gdb.arch/altivec-regs.exp
index 42521a0a9ab..41f77435a38 100644
--- a/gdb/testsuite/gdb.arch/altivec-regs.exp
+++ b/gdb/testsuite/gdb.arch/altivec-regs.exp
@@ -56,6 +56,9 @@ if ![runto_main] then {
     return 0
 }
 
+gdb_breakpoint [gdb_get_line_number "start here"]
+gdb_continue_to_breakpoint "start here"
+
 gdb_test "set print frame-arguments all"
 
 # set all the registers integer portions to 1
-- 
2.38.3


  reply	other threads:[~2023-03-06  7:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14  7:38 Aditya Kamath1
2022-10-14  7:38 ` Aditya Kamath1
2022-10-14 12:47 ` Ulrich Weigand
2022-10-17  6:51   ` Aditya Kamath1
2022-10-17  6:51     ` Aditya Kamath1
2022-10-17  9:57     ` Ulrich Weigand
2022-10-17  9:57       ` Ulrich Weigand
2022-10-19  6:00       ` Aditya Kamath1
2022-10-19  6:00         ` Aditya Kamath1
2023-02-23 12:54         ` Aditya Kamath1
2023-02-24 15:37           ` Ulrich Weigand
2023-03-01 13:45             ` Aditya Kamath1
2023-03-03 15:50               ` Ulrich Weigand
2023-03-06  7:49                 ` Aditya Kamath1 [this message]
2023-03-07  9:56                   ` Ulrich Weigand

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=CH2PR15MB3544B34C1C748B42FAAF1CFFD6B69@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 \
    --cc=simark@simark.ca \
    /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).