]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/testsuite/ChangeLog
[gdb/exp] Fix printing of type of optimized out vla
authorTom de Vries <tdevries@suse.de>
Tue, 3 Jul 2018 09:06:45 +0000 (11:06 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 18 Jul 2018 20:02:34 +0000 (22:02 +0200)
commit42dc7699a26be0157c438dcaeb89da38287c6d2d
tree2c95f69d19e01533c075469ac109a619e0044a23
parent6592ceed489043051d02d41dc71f51e8ef8aa6f0
[gdb/exp] Fix printing of type of optimized out vla

Consider this snippet from gcc/testsuite/gcc.dg/guality/vla-1.c:
...
int __attribute__((noinline))
f1 (int i)
{
  char a[i + 1];
  a[0] = 5;             /* { dg-final { gdb-test .+1 "i" "5" } } */
  return a[0];          /* { dg-final { gdb-test . "sizeof (a)" "6" } } */
}
...

When we compile the test-case with -O1 -g, and query the size of optimized
out vla 'a', we get:
...
$ ./gdb -batch -ex "b f1" -ex "r" -ex "p sizeof (a)" vla-1.exe
Breakpoint 1 at 0x4004a8: file vla-1.c, line 17.

Breakpoint 1, f1 (i=i@entry=5) at vla-1.c:17
17        return a[0];
$1 = 0
...
while we expect a size of '6'.

The problem is that default_read_var_value does not resolve the dynamic type
of a variable if the variable is optimized out.

This patch fixes that, and consequently gdb prints '6', as expected.

Tested on x86_64-linux.

2018-07-18  Tom de Vries  <tdevries@suse.de>

* findvar.c (default_read_var_value): Also resolve dynamic type for
LOC_OPTIMIZED_OUT vars.

* gdb.base/vla-optimized-out.c: New test.
* gdb.base/vla-optimized-out.exp: New file.
gdb/ChangeLog
gdb/findvar.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/vla-optimized-out.c [new file with mode: 0644]
gdb/testsuite/gdb.base/vla-optimized-out.exp [new file with mode: 0644]