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.