public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Fix max-depth test case for AIX.
@ 2024-04-03  9:00 Aditya Kamath1
  2024-04-03 14:13 ` Andrew Burgess
  0 siblings, 1 reply; 7+ messages in thread
From: Aditya Kamath1 @ 2024-04-03  9:00 UTC (permalink / raw)
  To: Ulrich Weigand, Aditya Kamath1 via Gdb-patches; +Cc: Sangamesh Mallayya


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

Respected community members,

Please find attached a patch. (See: 0001-Fix-max-depth-test-case-for-AIX.patch)

This patch is a small fix to ensure max-depth test case is passing all test cases in AIX.

In AIX, if in the main program the variables are unused then the linker optimises
these variables and the dwarf will not have proper address to the same. Hence, we cannot access these
variables.

Breakpoint 1, main () at /current_gdb/binutils-gdb/gdb/testsuite/gdb.base/max-depth.c:231
231       return 0;
(gdb) set print max-depth 0
(gdb) p s1
Cannot access memory at address 0xefffffff
(gdb) FAIL: gdb.base/max-depth-c.exp: exp='s1': depth=0: p s1
set print max-depth 1
(gdb) p s1
Cannot access memory at address 0xefffffff
(gdb) FAIL: gdb.base/max-depth-c.exp: exp='s1': depth=1: p s1
set print max-depth 2
(gdb) p s1
Cannot access memory at address 0xefffffff

In the log above we can see the address getting assigned is incorrect.

So, can we use this fix? The idea is just to stop the linker from optimizing unused varaibles out in AIX.  Let me know what you think.

Have a nice day ahead.

Thanks and regards,
Aditya.

[-- Attachment #2: 0001-Fix-max-depth-test-case-for-AIX.patch --]
[-- Type: application/octet-stream, Size: 966 bytes --]

From da0e236d30473eea91766e124d49a2256b7cf398 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Mon, 1 Apr 2024 03:12:29 -0500
Subject: [PATCH] Fix max-depth test case for AIX.

In AIX, if in the main program the variables are unused then the linker optimises
these variables and the dwarf will not have proper address to the same. Hence we cannot access these
variables.

This patch is a fix to the same so that all the test case of max-depth can passs in AIX as well.
---
 gdb/testsuite/gdb.base/max-depth.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdb/testsuite/gdb.base/max-depth.c b/gdb/testsuite/gdb.base/max-depth.c
index fee5de5af34..e4b4459eed5 100644
--- a/gdb/testsuite/gdb.base/max-depth.c
+++ b/gdb/testsuite/gdb.base/max-depth.c
@@ -228,5 +228,9 @@ struct V7 : virtual V4, virtual V5, virtual V6 { int v7 = 1; } v7;
 int
 main ()
 {
+  #ifdef _AIX
+  s1.x = 0;
+  #endif
+
   return 0;
 }
-- 
2.41.0


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

* Re: Fix max-depth test case for AIX.
  2024-04-03  9:00 Fix max-depth test case for AIX Aditya Kamath1
@ 2024-04-03 14:13 ` Andrew Burgess
  2024-04-03 14:58   ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2024-04-03 14:13 UTC (permalink / raw)
  To: Aditya Kamath1, Ulrich Weigand, Aditya Kamath1 via Gdb-patches
  Cc: Sangamesh Mallayya

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

> Respected community members,
>
> Please find attached a patch. (See: 0001-Fix-max-depth-test-case-for-AIX.patch)
>
> This patch is a small fix to ensure max-depth test case is passing all test cases in AIX.
>
> In AIX, if in the main program the variables are unused then the linker optimises
> these variables and the dwarf will not have proper address to the same. Hence, we cannot access these
> variables.
>
> Breakpoint 1, main () at /current_gdb/binutils-gdb/gdb/testsuite/gdb.base/max-depth.c:231
> 231       return 0;
> (gdb) set print max-depth 0
> (gdb) p s1
> Cannot access memory at address 0xefffffff
> (gdb) FAIL: gdb.base/max-depth-c.exp: exp='s1': depth=0: p s1
> set print max-depth 1
> (gdb) p s1
> Cannot access memory at address 0xefffffff
> (gdb) FAIL: gdb.base/max-depth-c.exp: exp='s1': depth=1: p s1
> set print max-depth 2
> (gdb) p s1
> Cannot access memory at address 0xefffffff
>
> In the log above we can see the address getting assigned is incorrect.
>
> So, can we use this fix? The idea is just to stop the linker from optimizing unused varaibles out in AIX.  Let me know what you think.
>
> Have a nice day ahead.
>
> Thanks and regards,
> Aditya.
> From da0e236d30473eea91766e124d49a2256b7cf398 Mon Sep 17 00:00:00 2001
> From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
> Date: Mon, 1 Apr 2024 03:12:29 -0500
> Subject: [PATCH] Fix max-depth test case for AIX.
>
> In AIX, if in the main program the variables are unused then the linker optimises
> these variables and the dwarf will not have proper address to the same. Hence we cannot access these
> variables.
>
> This patch is a fix to the same so that all the test case of max-depth can passs in AIX as well.
> ---
>  gdb/testsuite/gdb.base/max-depth.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/gdb/testsuite/gdb.base/max-depth.c b/gdb/testsuite/gdb.base/max-depth.c
> index fee5de5af34..e4b4459eed5 100644
> --- a/gdb/testsuite/gdb.base/max-depth.c
> +++ b/gdb/testsuite/gdb.base/max-depth.c
> @@ -228,5 +228,9 @@ struct V7 : virtual V4, virtual V5, virtual V6 { int v7 = 1; } v7;
>  int
>  main ()
>  {
> +  #ifdef _AIX
> +  s1.x = 0;
> +  #endif

Is it only `s1` that's a problem?  None of the other variables are used
either, and the they are all checked by the test.

Given what the test is doing I don't think there's any need for the
#ifdef, I'd suggest just adding a comment explaining why we need to
ensure the variables are referenced, and reference them.

Thanks,
Andrew


> +
>    return 0;
>  }
> -- 
> 2.41.0


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

* Re: Fix max-depth test case for AIX.
  2024-04-03 14:13 ` Andrew Burgess
@ 2024-04-03 14:58   ` Tom Tromey
  2024-04-10  6:01     ` Aditya Kamath1
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2024-04-03 14:58 UTC (permalink / raw)
  To: Andrew Burgess
  Cc: Aditya Kamath1, Ulrich Weigand, Aditya Kamath1 via Gdb-patches,
	Sangamesh Mallayya

Andrew> Given what the test is doing I don't think there's any need for the
Andrew> #ifdef, I'd suggest just adding a comment explaining why we need to
Andrew> ensure the variables are referenced, and reference them.

Agreed.  Look for 'Do_Nothing' in the Ada tests to see how this is
handled for Ada programs.  I feel like we've done something similar in
some cases for C as well.

Tom

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

* RE: Fix max-depth test case for AIX.
  2024-04-03 14:58   ` Tom Tromey
@ 2024-04-10  6:01     ` Aditya Kamath1
  2024-04-16 17:24       ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Aditya Kamath1 @ 2024-04-10  6:01 UTC (permalink / raw)
  To: Tom Tromey, Andrew Burgess
  Cc: Ulrich Weigand, Aditya Kamath1 via Gdb-patches, Sangamesh Mallayya


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

Respected Tom, Andrew and community members,

Hi,

Thank you for your feedback.

Please find attached a patch. (See: 0001-Fix-max-depth-test-case-for-AIX.patch)

Andrew> Given what the test is doing I don't think there's any need for the
Andrew> #ifdef, I'd suggest just adding a comment explaining why we need to
Andrew> ensure the variables are referenced, and reference them.

>Agreed.  Look for 'Do_Nothing' in the Ada tests to see how this is
>handled for Ada programs.  I feel like we've done something similar in
>some cases for C as well.

Thank you Tom. I referred the gdb.ada/varsize_limit/pck.adb file for the Do_nothing function.

package body Pck is
   procedure Do_Nothing (A : System.Address) is
   begin
      null;
   end Do_Nothing;
   function Ident (S : String) return String is
   begin
      return S;
   end Ident;
end Pck;

Here Do_nothing is doing nothing. Did something similar. Let me know if any changes needed.

Output in AIX after this patch is applied.

/current_gdb/binutils-gdb/gdb/gdb version  15.0.50.20240325-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /current_gdb/binutils-gdb/gdb/data-directory

                === gdb Summary ===

# of expected passes            92
/current_gdb/binutils-gdb/gdb/gdb version  15.0.50.20240325-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /current_gdb/binutils-gdb/gdb/data-directory

Have a nice day ahead.

Thanks and regards,
Aditya.


From: Tom Tromey <tom@tromey.com>
Date: Wednesday, 3 April 2024 at 8:28 PM
To: Andrew Burgess <aburgess@redhat.com>
Cc: Aditya Kamath1 <Aditya.Kamath1@ibm.com>, Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, Aditya Kamath1 via Gdb-patches <gdb-patches@sourceware.org>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: [EXTERNAL] Re: Fix max-depth test case for AIX.
Andrew> Given what the test is doing I don't think there's any need for the
Andrew> #ifdef, I'd suggest just adding a comment explaining why we need to
Andrew> ensure the variables are referenced, and reference them.

Agreed.  Look for 'Do_Nothing' in the Ada tests to see how this is
handled for Ada programs.  I feel like we've done something similar in
some cases for C as well.

Tom

[-- Attachment #2: 0001-Fix-max-depth-test-case-for-AIX.patch --]
[-- Type: application/octet-stream, Size: 1223 bytes --]

From 3117e666bad264e460596903acbcd008dc3f9287 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Wed, 10 Apr 2024 00:52:05 -0500
Subject: [PATCH] Fix max-depth test case for AIX.

In AIX, if in the main program the global variables are unused then the linker optimises
these variables and the dwarf will not have proper address to the same. Hence we cannot access these
variables.

This patch is a fix to the same so that all the test case of max-depth can passs in AIX as well.
---
 gdb/testsuite/gdb.base/max-depth.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/testsuite/gdb.base/max-depth.c b/gdb/testsuite/gdb.base/max-depth.c
index fee5de5af34..7e46b134c10 100644
--- a/gdb/testsuite/gdb.base/max-depth.c
+++ b/gdb/testsuite/gdb.base/max-depth.c
@@ -225,8 +225,17 @@ struct V7 : virtual V4, virtual V5, virtual V6 { int v7 = 1; } v7;
 
 #endif /* __cplusplus */
 
+void Do_nothing (struct s1 sone)
+{
+  /*  This Function does nothing.  */
+}
+
 int
 main ()
 {
+  /*  In targets like AIX, linker optimises out unused global
+      variables.  The do_nothing () function stops the linker
+      from doing so.  */
+  Do_nothing (s1);
   return 0;
 }
-- 
2.41.0


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

* Re: Fix max-depth test case for AIX.
  2024-04-10  6:01     ` Aditya Kamath1
@ 2024-04-16 17:24       ` Tom Tromey
  2024-04-17 10:40         ` Aditya Kamath1
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2024-04-16 17:24 UTC (permalink / raw)
  To: Aditya Kamath1
  Cc: Tom Tromey, Andrew Burgess, Ulrich Weigand,
	Aditya Kamath1 via Gdb-patches, Sangamesh Mallayya

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

> From 3117e666bad264e460596903acbcd008dc3f9287 Mon Sep 17 00:00:00 2001
> From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
> Date: Wed, 10 Apr 2024 00:52:05 -0500
> Subject: [PATCH] Fix max-depth test case for AIX.

> In AIX, if in the main program the global variables are unused then the linker optimises
> these variables and the dwarf will not have proper address to the same. Hence we cannot access these
> variables.

This is ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

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

* RE: Fix max-depth test case for AIX.
  2024-04-16 17:24       ` Tom Tromey
@ 2024-04-17 10:40         ` Aditya Kamath1
  2024-04-17 10:44           ` Ulrich Weigand
  0 siblings, 1 reply; 7+ messages in thread
From: Aditya Kamath1 @ 2024-04-17 10:40 UTC (permalink / raw)
  To: Tom Tromey
  Cc: Tom Tromey, Andrew Burgess, Ulrich Weigand,
	Aditya Kamath1 via Gdb-patches, Sangamesh Mallayya


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

Respected community members,

Hi,

>This is ok.
>Approved-By: Tom Tromey tom@tromey.com<mailto:tom@tromey.com>

Thank you Tom.

Can someone kindly commit this patch. Attaching it again. I do not have the access to do the same.

Have a nice day ahead.

Thanks and regards,
Aditya.




From: Tom Tromey <tom@tromey.com>
Date: Tuesday, 16 April 2024 at 10:54 PM
To: Aditya Kamath1 <Aditya.Kamath1@ibm.com>
Cc: Tom Tromey <tom@tromey.com>, Andrew Burgess <aburgess@redhat.com>, Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, Aditya Kamath1 via Gdb-patches <gdb-patches@sourceware.org>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: [EXTERNAL] Re: Fix max-depth test case for AIX.
>>>>> Aditya Kamath1 <Aditya.Kamath1@ibm.com> writes:

> From 3117e666bad264e460596903acbcd008dc3f9287 Mon Sep 17 00:00:00 2001
> From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
> Date: Wed, 10 Apr 2024 00:52:05 -0500
> Subject: [PATCH] Fix max-depth test case for AIX.

> In AIX, if in the main program the global variables are unused then the linker optimises
> these variables and the dwarf will not have proper address to the same. Hence we cannot access these
> variables.

This is ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

[-- Attachment #2: 0001-Fix-max-depth-test-case-for-AIX.patch --]
[-- Type: application/octet-stream, Size: 1223 bytes --]

From 3117e666bad264e460596903acbcd008dc3f9287 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Wed, 10 Apr 2024 00:52:05 -0500
Subject: [PATCH] Fix max-depth test case for AIX.

In AIX, if in the main program the global variables are unused then the linker optimises
these variables and the dwarf will not have proper address to the same. Hence we cannot access these
variables.

This patch is a fix to the same so that all the test case of max-depth can passs in AIX as well.
---
 gdb/testsuite/gdb.base/max-depth.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/testsuite/gdb.base/max-depth.c b/gdb/testsuite/gdb.base/max-depth.c
index fee5de5af34..7e46b134c10 100644
--- a/gdb/testsuite/gdb.base/max-depth.c
+++ b/gdb/testsuite/gdb.base/max-depth.c
@@ -225,8 +225,17 @@ struct V7 : virtual V4, virtual V5, virtual V6 { int v7 = 1; } v7;
 
 #endif /* __cplusplus */
 
+void Do_nothing (struct s1 sone)
+{
+  /*  This Function does nothing.  */
+}
+
 int
 main ()
 {
+  /*  In targets like AIX, linker optimises out unused global
+      variables.  The do_nothing () function stops the linker
+      from doing so.  */
+  Do_nothing (s1);
   return 0;
 }
-- 
2.41.0


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

* Re: Fix max-depth test case for AIX.
  2024-04-17 10:40         ` Aditya Kamath1
@ 2024-04-17 10:44           ` Ulrich Weigand
  0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Weigand @ 2024-04-17 10:44 UTC (permalink / raw)
  To: Aditya Kamath1, tom; +Cc: gdb-patches, Sangamesh Mallayya, Andrew Burgess

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

>Can someone kindly commit this patch. Attaching it again. I do not have the access to do the same.

I've checked the patch in.

Thanks,
Ulrich


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

end of thread, other threads:[~2024-04-17 10:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-03  9:00 Fix max-depth test case for AIX Aditya Kamath1
2024-04-03 14:13 ` Andrew Burgess
2024-04-03 14:58   ` Tom Tromey
2024-04-10  6:01     ` Aditya Kamath1
2024-04-16 17:24       ` Tom Tromey
2024-04-17 10:40         ` Aditya Kamath1
2024-04-17 10:44           ` Ulrich Weigand

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