From: Aditya Kamath1 <Aditya.Kamath1@ibm.com>
To: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
Aditya Kamath1 via Gdb-patches <gdb-patches@sourceware.org>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: [PATCH]-Change gdb.base/examine-backwards.exp testcase for AIX
Date: Mon, 6 Nov 2023 11:02:55 +0000 [thread overview]
Message-ID: <CH2PR15MB354467CDAA3D6ED369CAD73FD6AAA@CH2PR15MB3544.namprd15.prod.outlook.com> (raw)
[-- 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
next reply other threads:[~2023-11-06 11:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-06 11:02 Aditya Kamath1 [this message]
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
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=CH2PR15MB354467CDAA3D6ED369CAD73FD6AAA@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