]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/testsuite] Fix spurious FAILs with examine-backward.exp, again
authorTom de Vries <tdevries@suse.de>
Tue, 21 Nov 2023 12:15:29 +0000 (13:15 +0100)
committerTom de Vries <tdevries@suse.de>
Tue, 21 Nov 2023 12:15:29 +0000 (13:15 +0100)
commit42ffc15774fc791f2ac9a719e81589c8e91bdb98
tree082b00b3287c477e42dda74ed69dc58afbfa5ed9
parentcc1cc4061bcfb71d99b4e000c0dd0fdd9907a043
[gdb/testsuite] Fix spurious FAILs with examine-backward.exp, again

Commit 59a561480d5 ("Fix spurious FAILs with examine-backward.exp") describes
the problem that:
...
The test case examine-backward.exp issues the command "x/-s" after the end
of the first string in TestStrings, but without making sure that this
string is preceded by a string terminator.  Thus GDB may spuriously print
some random characters from before that string, and then the test fails.
...

The commit fixes the problem by adding a Barrier variable before the TestStrings
variable:
...
+const char Barrier[] = { 0x0 };
 const char TestStrings[] = {
...

There is however no guarantee that Barrier is placed immediately before
TestStrings.

Before recent commit 169fe7ab54b ("Change gdb.base/examine-backwards.exp for
AIX.") on x86_64-linux, I see:
...
0000000000400660 R Barrier
0000000000400680 R TestStrings
...

So while the Barrier variable is the first before the TestStrings variable,
it's not immediately preceding TestStrings.

After commit 169fe7ab54b:
...
0000000000402259 B Barrier
0000000000402020 D TestStrings
...
they're not even in the same section anymore.

Fix this reliably by adding the zero in the array itself:
...
char TestStringsBase[] = {
  0x0,
  ...
};
char *TestStrings = &TestStringsBase[1];
...
and do likewise for TestStringsH and TestStringsW.

Tested on x86_64-linux.

PR testsuite/31064
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31064
gdb/testsuite/gdb.base/examine-backward.c
gdb/testsuite/gdb.base/examine-backward.exp