diff options
author | Tom de Vries <tdevries@suse.de> | 2018-07-03 11:06:45 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2018-07-18 22:02:34 +0200 |
commit | 42dc7699a26be0157c438dcaeb89da38287c6d2d (patch) | |
tree | 2c95f69d19e01533c075469ac109a619e0044a23 /gdb/findvar.c | |
parent | 6592ceed489043051d02d41dc71f51e8ef8aa6f0 (diff) | |
download | gdb-42dc7699a26be0157c438dcaeb89da38287c6d2d.zip gdb-42dc7699a26be0157c438dcaeb89da38287c6d2d.tar.gz gdb-42dc7699a26be0157c438dcaeb89da38287c6d2d.tar.bz2 |
[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.
Diffstat (limited to 'gdb/findvar.c')
-rw-r--r-- | gdb/findvar.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/findvar.c b/gdb/findvar.c index 8ad5e25..ebaff92 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -789,6 +789,8 @@ default_read_var_value (struct symbol *var, const struct block *var_block, break; case LOC_OPTIMIZED_OUT: + if (is_dynamic_type (type)) + type = resolve_dynamic_type (type, NULL, /* Unused address. */ 0); return allocate_optimized_out_value (type); default: |