Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH]-Change gdb.base/examine-backwards.exp testcase for AIX
@ 2023-11-06 11:02 Aditya Kamath1
  2023-11-06 11:56 ` Ulrich Weigand
  0 siblings, 1 reply; 7+ messages in thread
From: Aditya Kamath1 @ 2023-11-06 11:02 UTC (permalink / raw)
  To: Ulrich Weigand, Aditya Kamath1 via Gdb-patches; +Cc: Sangamesh Mallayya


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

Respected GDB community members,

Hi,

This is a patch requesting to modify the gdb.base/examine-backwards testcase so that AIX can also pass this test. Currently we fail by saying

Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/aditya/gdb_tests/examine-backward...
(gdb) b main
Breakpoint 1 at 0x100004ac: file /home/aditya/gdb_tests/examine-backward.c, line 96.
(gdb) r
Starting program: /home/aditya/gdb_tests/examine-backward

Breakpoint 1, main () at /home/aditya/gdb_tests/examine-backward.c:96
96        int dummy = Barrier[0] + TestStrings[0] + TestStringsH[0] + TestStringsW[0];
(gdb) x/6s TestStrings
0xffffffff:       <error: Cannot access memory at address 0xffffffff>
0xffffffff:       <error: Cannot access memory at address 0xffffffff>
0xffffffff:       <error: Cannot access memory at address 0xffffffff>
0xffffffff:       <error: Cannot access memory at address 0xffffffff>
0xffffffff:       <error: Cannot access memory at address 0xffffffff>
0xffffffff:       <error: Cannot access memory at address 0xffffffff>
(gdb)

This is because linker has not assigned any address to the variable TestStrings  and still treats it as unused.

In the dwarf dump in AIX for the gdb.base/examine-backward.c file’s binary we see:-

<1><  252>      DW_TAG_variable
                DW_AT_name                  TestStrings
                DW_AT_decl_file             1
                DW_AT_decl_line             43
                DW_AT_decl_column           21
                DW_AT_type                  <247>
                DW_AT_external              yes
                DW_AT_location              DW_OP_addr 0xffffffff
<1><  278>      DW_TAG_array_type
                DW_AT_type                  <312>
                DW_AT_sibling               <294>
<2><  287>      DW_TAG_subrange_type
                DW_AT_type                  <166>
                DW_AT_upper_bound           72
<1><  294>      DW_TAG_const_type
                DW_AT_type                  <278>
<1><  299>      DW_TAG_base_type
                DW_AT_byte_size             2
                DW_AT_encoding              DW_ATE_signed
                DW_AT_name                  short int
<1><  312>      DW_TAG_const_type
                DW_AT_type                  <299>
<1><  317>      DW_TAG_variable
                DW_AT_name                  TestStringsH
                DW_AT_decl_file             1

This is a problem. After we modify the test case as done by this patch say using {+  char *dummy_string = TestStrings;} we get,

(gdb) b main
Breakpoint 1 at 0x100004ac: file /home/aditya/gdb_tests/examine-backward.c, line 96.
(gdb) r
Starting program: /home/aditya/gdb_tests/examine-backward

Breakpoint 1, main () at /home/aditya/gdb_tests/examine-backward.c:96
96        int dummy = Barrier[0] + TestStrings[0] + TestStringsH[0] + TestStringsW[0];
(gdb) x/6s TestStrings
0x10000c74 <TestStrings>:   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
0x10000c8f <TestStrings+27>:        ""
0x10000c90 <TestStrings+28>:        ""
0x10000c91 <TestStrings+29>:        "�\201��\201\222�\201��\201\222"
0x10000c9e <TestStrings+42>:        "012345678901234567890123456789"
0x10000cbd <TestStrings+73>:        "!!!!!!"
(gdb)

Dwarf dump after modification of the test case:-
<1><  242>      DW_TAG_variable
                DW_AT_name                  TestStrings
                DW_AT_decl_file             1
                DW_AT_decl_line             43
                DW_AT_decl_column           21
                DW_AT_type                  <237>
                DW_AT_external              yes
                DW_AT_location              DW_OP_addr 0x10000c74

Test case numbers after patch applied:-
                === gdb Summary ===

# of expected passes            70
# of unsupported tests          1

Before we applied this patch, we had around 28 failures. 1 unsupported is info proc mappings which is not there in AIX as of now.

Kindly let me know what you think. I know that we have some dummy variables that is used to negate a similar problem using clang with lto. But if we can produce something that works for both AIX GCC and other targets Clang with LTO it will be great, and we can create a patch.

Have a nice day ahead.

Thanks and regards,
Aditya Kamath.

[-- Attachment #1.2: Type: text/html, Size: 15113 bytes --]

[-- Attachment #2: 0001-Change-gdb.base-examine-backwards.exp-for-AIX.patch --]
[-- Type: application/octet-stream, Size: 1294 bytes --]

From 14f0452ef34f1a47f14717d081bdc890babeded7 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Mon, 6 Nov 2023 04:42:38 -0600
Subject: [PATCH] Change gdb.base/examine-backwards.exp for AIX.

In AIX unused variables are collected as garbage by the linker and in the dwarf dump
an address which all f's in hexadecimal are assigned. Hence the testcase fails with many failures stating
it cannot access memory.

This patch is a small change to get it working in AIX as well.
---
 gdb/testsuite/gdb.base/examine-backward.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gdb/testsuite/gdb.base/examine-backward.c b/gdb/testsuite/gdb.base/examine-backward.c
index e30b58fb005..995dc6a0b78 100644
--- a/gdb/testsuite/gdb.base/examine-backward.c
+++ b/gdb/testsuite/gdb.base/examine-backward.c
@@ -95,6 +95,12 @@ main (void)
   /* Clang++ eliminates the variables if nothing references them.  */
   int dummy = Barrier[0] + TestStrings[0] + TestStringsH[0] + TestStringsW[0];
 
+  #ifdef _AIX
+  char *dummy_string = TestStrings;
+  dummy_string = TestStringsH;
+  dummy_string = TestStringsW;
+  #endif
+
   /* Backward disassemble test requires at least 20 instructions in
      this function.  Adding a simple bubble sort.  */
   int i, j;
-- 
2.38.3


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

* Re: [PATCH]-Change gdb.base/examine-backwards.exp testcase for AIX
  2023-11-06 11:02 [PATCH]-Change gdb.base/examine-backwards.exp testcase for AIX Aditya Kamath1
@ 2023-11-06 11:56 ` Ulrich Weigand
  2023-11-06 12:08   ` Aditya Kamath1
  0 siblings, 1 reply; 7+ messages in thread
From: Ulrich Weigand @ 2023-11-06 11:56 UTC (permalink / raw)
  To: gdb-patches, Aditya Kamath1; +Cc: Sangamesh Mallayya

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

>Kindly let me know what you think. I know that we have some dummy variables
>that is used to negate a similar problem using clang with lto. But if we
>can produce something that works for both AIX GCC and other targets Clang
>with LTO it will be great, and we can create a patch. 

I assume the existing dummy assignment
  int dummy = Barrier[0] + TestStrings[0] + TestStringsH[0] + TestStringsW[0];
is optimized out on AIX for some reason?

Does it work if you move "dummy" to be global variable,
and/or make the Barrier and TestStrings* variable non-const?

Bye,
Ulrich


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

* Re: [PATCH]-Change gdb.base/examine-backwards.exp testcase for AIX
  2023-11-06 11:56 ` Ulrich Weigand
@ 2023-11-06 12:08   ` Aditya Kamath1
  2023-11-06 13:07     ` Ulrich Weigand
  0 siblings, 1 reply; 7+ messages in thread
From: Aditya Kamath1 @ 2023-11-06 12:08 UTC (permalink / raw)
  To: Ulrich Weigand, gdb-patches; +Cc: Sangamesh Mallayya

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

Hi Ulrich and community members,

>I assume the existing dummy assignment
 > int dummy = Barrier[0] + TestStrings[0] + TestStringsH[0] + TestStringsW[0];
> is optimized out on AIX for some reason?

> Does it work if you move "dummy" to be global variable,
> and/or make the Barrier and TestStrings* variable non-const?

Yes Ulrich. It works if we make variables non-const. Kindly see the output below.

gmake check RUNTESTFLAGS='gdb.base/examine-backward.exp CC_FOR_TARGET="/opt/freeware/bin/gcc" CXX_FOR_TARGET="/opt/freeware/bin/g++" CXXFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64" CFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64"'
gmake check-single……….
(gdb) set charset ASCII
(gdb) set print elements 20
(gdb) x/6s &TestStrings
0x110000158 <TestStrings>:      "ABCDEFGHIJKLMNOPQRST"...
0x11000016c <TestStrings+20>:   "UVWXYZ"
0x110000173 <TestStrings+27>:   ""
0x110000174 <TestStrings+28>:   ""
0x110000175 <TestStrings+29>:   "\343\201\273\343\201\222\343\201\273\343\201\222"
0x110000182 <TestStrings+42>:   "01234567890123456789"...
(gdb) x/-1xb…………………
                === gdb Summary ===

# of expected passes            70
# of unsupported tests          1

So shall we remove this const and create the git patch?

Please see the diff pasted below.

Thanks and regards,
Aditya.

diff --git a/gdb/testsuite/gdb.base/examine-backward.c b/gdb/testsuite/gdb.base/examine-backward.c
index 995dc6a0b78..354c2e2f323 100644
--- a/gdb/testsuite/gdb.base/examine-backward.c
+++ b/gdb/testsuite/gdb.base/examine-backward.c
@@ -36,11 +36,11 @@ literals.  The content of each array is the same as followings:
    TestStrings, to avoid showing garbage when we look for strings
    backwards from TestStrings.  */
-const unsigned char Barrier[] = {
+unsigned char Barrier[] = {
   0x00,
};
-const unsigned char TestStrings[] = {
+unsigned char TestStrings[] = {
   0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
   0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
   0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
@@ -54,7 +54,7 @@ const unsigned char TestStrings[] = {
   0x00
};
-const short TestStringsH[] = {
+short TestStringsH[] = {
   0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048,
   0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050,
   0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
@@ -67,7 +67,7 @@ const short TestStringsH[] = {
   0x0000
};
-const int TestStringsW[] = {
+int TestStringsW[] = {
   0x00000041, 0x00000042, 0x00000043, 0x00000044,
   0x00000045, 0x00000046, 0x00000047, 0x00000048,
   0x00000049, 0x0000004a, 0x0000004b, 0x0000004c,
From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Date: Monday, 6 November 2023 at 5:26 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]-Change gdb.base/examine-backwards.exp testcase for AIX
Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:

>Kindly let me know what you think. I know that we have some dummy variables
>that is used to negate a similar problem using clang with lto. But if we
>can produce something that works for both AIX GCC and other targets Clang
>with LTO it will be great, and we can create a patch.

I assume the existing dummy assignment
  int dummy = Barrier[0] + TestStrings[0] + TestStringsH[0] + TestStringsW[0];
is optimized out on AIX for some reason?

Does it work if you move "dummy" to be global variable,
and/or make the Barrier and TestStrings* variable non-const?

Bye,
Ulrich

[-- Attachment #2: Type: text/html, Size: 11573 bytes --]

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

* Re: [PATCH]-Change gdb.base/examine-backwards.exp testcase for AIX
  2023-11-06 12:08   ` Aditya Kamath1
@ 2023-11-06 13:07     ` Ulrich Weigand
  2023-11-06 13:28       ` Aditya Kamath1
  0 siblings, 1 reply; 7+ messages in thread
From: Ulrich Weigand @ 2023-11-06 13:07 UTC (permalink / raw)
  To: gdb-patches, Aditya Kamath1; +Cc: Sangamesh Mallayya

Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:
>> I assume the existing dummy assignment
>>   int dummy = Barrier[0] + TestStrings[0] + TestStringsH[0] + TestStringsW[0];
>> is optimized out on AIX for some reason?
>>
>> Does it work if you move "dummy" to be global variable,
>> and/or make the Barrier and TestStrings* variable non-const?
> 
>Yes Ulrich. It works if we make variables non-const. Kindly see the output below.

OK, good.

>So shall we remove this const and create the git patch?

Yes, I think this would be the better solution.

Bye,
Ulrich


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

* Re: [PATCH]-Change gdb.base/examine-backwards.exp testcase for AIX
  2023-11-06 13:07     ` Ulrich Weigand
@ 2023-11-06 13:28       ` Aditya Kamath1
  2023-11-06 14:03         ` Ulrich Weigand
  0 siblings, 1 reply; 7+ messages in thread
From: Aditya Kamath1 @ 2023-11-06 13:28 UTC (permalink / raw)
  To: Ulrich Weigand, gdb-patches; +Cc: Sangamesh Mallayya


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

Hi Ulrich,

Please find attached the patch. See:- 0001-Change-gdb.base-examine-backwards.exp-for-AIX.patch

>>So shall we remove this const and create the git patch?

>Yes, I think this would be the better solution.

Kindly push this patch if there are no changes. If not let me know.

Thanks and regards,
Aditya.


From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Date: Monday, 6 November 2023 at 6:37 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]-Change gdb.base/examine-backwards.exp testcase for AIX
Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:
>> I assume the existing dummy assignment
>>   int dummy = Barrier[0] + TestStrings[0] + TestStringsH[0] + TestStringsW[0];
>> is optimized out on AIX for some reason?
>>
>> Does it work if you move "dummy" to be global variable,
>> and/or make the Barrier and TestStrings* variable non-const?
>
>Yes Ulrich. It works if we make variables non-const. Kindly see the output below.

OK, good.

>So shall we remove this const and create the git patch?

Yes, I think this would be the better solution.

Bye,
Ulrich

[-- Attachment #1.2: Type: text/html, Size: 3686 bytes --]

[-- Attachment #2: 0001-Change-gdb.base-examine-backwards.exp-for-AIX.patch --]
[-- Type: application/octet-stream, Size: 1968 bytes --]

From a4b0d9061af90c1470ac1fb9a0b66252bca70f06 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Mon, 6 Nov 2023 07:26:24 -0600
Subject: [PATCH] Change gdb.base/examine-backwards.exp for AIX.

In AIX unused or constant variables are collected as garbage by the linker and in the dwarf dump
an address with all f's in hexadecimal are assigned. Hence the testcase fails with many failures stating
it cannot access memory.

This patch is a small change to get it working in AIX as well.
---
 gdb/testsuite/gdb.base/examine-backward.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.base/examine-backward.c b/gdb/testsuite/gdb.base/examine-backward.c
index e30b58fb005..354c2e2f323 100644
--- a/gdb/testsuite/gdb.base/examine-backward.c
+++ b/gdb/testsuite/gdb.base/examine-backward.c
@@ -36,11 +36,11 @@ literals.  The content of each array is the same as followings:
    TestStrings, to avoid showing garbage when we look for strings
    backwards from TestStrings.  */
 
-const unsigned char Barrier[] = {
+unsigned char Barrier[] = {
   0x00,
 };
 
-const unsigned char TestStrings[] = {
+unsigned char TestStrings[] = {
   0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
   0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
   0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
@@ -54,7 +54,7 @@ const unsigned char TestStrings[] = {
   0x00
 };
 
-const short TestStringsH[] = {
+short TestStringsH[] = {
   0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048,
   0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050,
   0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
@@ -67,7 +67,7 @@ const short TestStringsH[] = {
   0x0000
 };
 
-const int TestStringsW[] = {
+int TestStringsW[] = {
   0x00000041, 0x00000042, 0x00000043, 0x00000044,
   0x00000045, 0x00000046, 0x00000047, 0x00000048,
   0x00000049, 0x0000004a, 0x0000004b, 0x0000004c,
-- 
2.38.3


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

* Re: [PATCH]-Change gdb.base/examine-backwards.exp testcase for AIX
  2023-11-06 13:28       ` Aditya Kamath1
@ 2023-11-06 14:03         ` Ulrich Weigand
  2023-11-06 14:18           ` Aditya Kamath1
  0 siblings, 1 reply; 7+ messages in thread
From: Ulrich Weigand @ 2023-11-06 14:03 UTC (permalink / raw)
  To: gdb-patches, Aditya Kamath1; +Cc: Sangamesh Mallayya

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

>>>So shall we remove this const and create the git patch?
>
>>Yes, I think this would be the better solution.
> 
>Kindly push this patch if there are no changes. If not let me know.

This is OK.  I've checked this in now.

Thanks,
Ulrich


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

* Re: [PATCH]-Change gdb.base/examine-backwards.exp testcase for AIX
  2023-11-06 14:03         ` Ulrich Weigand
@ 2023-11-06 14:18           ` Aditya Kamath1
  0 siblings, 0 replies; 7+ messages in thread
From: Aditya Kamath1 @ 2023-11-06 14:18 UTC (permalink / raw)
  To: Ulrich Weigand, gdb-patches; +Cc: Sangamesh Mallayya

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

Thank you Ulrich

From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Date: Monday, 6 November 2023 at 7:33 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]-Change gdb.base/examine-backwards.exp testcase for AIX
Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:

>>>So shall we remove this const and create the git patch?
>
>>Yes, I think this would be the better solution.
>
>Kindly push this patch if there are no changes. If not let me know.

This is OK.  I've checked this in now.

Thanks,
Ulrich

[-- Attachment #2: Type: text/html, Size: 2615 bytes --]

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

end of thread, other threads:[~2023-11-06 14:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-06 11:02 [PATCH]-Change gdb.base/examine-backwards.exp testcase for AIX Aditya Kamath1
2023-11-06 11:56 ` Ulrich Weigand
2023-11-06 12:08   ` Aditya Kamath1
2023-11-06 13:07     ` Ulrich Weigand
2023-11-06 13:28       ` Aditya Kamath1
2023-11-06 14:03         ` Ulrich Weigand
2023-11-06 14:18           ` Aditya Kamath1

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox