Commit Graph

3 Commits

Author SHA1 Message Date
Tom de Vries 63b4ecf76f [gdb/testsuite] Add comment in gdb.base/vla-optimized-out.c
2018-07-26  Tom de Vries  <tdevries@suse.de>

	* gdb.base/vla-optimized-out.c: Add comment about origin of test-case.
2018-07-26 10:22:22 +02:00
Tom de Vries 232a00325b [gdb/testsuite] Make noclone conditional in vla-optimized-out.c
Make the noclone attribute on f1 in vla-optimized-out.c conditional.  This
makes the test-case by default identical to
gcc/testsuite/gcc.dg/guality/vla-1.c.

Tested on x86_64-linux.

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

	* gdb.base/vla-optimized-out.c: Make noclone attribute conditional on
	NOCLONE macro.
	* gdb.base/vla-optimized-out.exp: Use additional_flags -DNOCLONE.
2018-07-20 17:04:02 +02:00
Tom de Vries 42dc7699a2 [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.
2018-07-18 22:02:34 +02:00