diff options
author | Hannes Domani <ssbssa@yahoo.de> | 2020-04-27 13:14:24 +0200 |
---|---|---|
committer | Hannes Domani <ssbssa@yahoo.de> | 2020-04-30 18:20:16 +0200 |
commit | ee9d1e5f76033cd8432713a76381ade76697df04 (patch) | |
tree | f5651b71bd5710d1e475e63cb96717ff2188eed2 /gdb/testsuite | |
parent | d5cf82c0d7a7b13727a2f26425afc9051656a716 (diff) | |
download | gdb-ee9d1e5f76033cd8432713a76381ade76697df04.zip gdb-ee9d1e5f76033cd8432713a76381ade76697df04.tar.gz gdb-ee9d1e5f76033cd8432713a76381ade76697df04.tar.bz2 |
Calculate size of array of stubbed type
Sizes of stubbed types are calculated on demand in check_typedef, so the
same must also be done for arrays of stubbed types.
A stubbed type is usually a structure that has only been forward declared,
but can also happen if the structure has a virtual function that's not
inline in the class definition.
For these stubbed types, the size must be recalculated once the full
definition is available.
gdb/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
PR gdb/18706
* gdbtypes.c (check_typedef): Calculate size of array of
stubbed type.
gdb/testsuite/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
PR gdb/18706
* gdb.cp/stub-array-size.cc: New test.
* gdb.cp/stub-array-size.exp: New file.
* gdb.cp/stub-array-size.h: New test.
* gdb.cp/stub-array-size2.cc: New test.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/stub-array-size.cc | 25 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/stub-array-size.exp | 30 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/stub-array-size.h | 21 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/stub-array-size2.cc | 22 |
5 files changed, 106 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6b25cd8..e2bf45b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2020-04-30 Hannes Domani <ssbssa@yahoo.de> + PR gdb/18706 + * gdb.cp/stub-array-size.cc: New test. + * gdb.cp/stub-array-size.exp: New file. + * gdb.cp/stub-array-size.h: New test. + * gdb.cp/stub-array-size2.cc: New test. + +2020-04-30 Hannes Domani <ssbssa@yahoo.de> + * gdb.python/py-format-string.exp: Adjust pretty_arrays expected output to the new format. diff --git a/gdb/testsuite/gdb.cp/stub-array-size.cc b/gdb/testsuite/gdb.cp/stub-array-size.cc new file mode 100644 index 0000000..281d70d --- /dev/null +++ b/gdb/testsuite/gdb.cp/stub-array-size.cc @@ -0,0 +1,25 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2020 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "stub-array-size.h" + +A a[10]; + +int main() +{ + return 0; +}; diff --git a/gdb/testsuite/gdb.cp/stub-array-size.exp b/gdb/testsuite/gdb.cp/stub-array-size.exp new file mode 100644 index 0000000..c43d35b --- /dev/null +++ b/gdb/testsuite/gdb.cp/stub-array-size.exp @@ -0,0 +1,30 @@ +# Copyright 2020 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# This file is part of the gdb testsuite. + +# Test size of arrays of stubbed types (structures where the full definition +# is not immediately available). + +if {[skip_cplus_tests]} { continue } + +standard_testfile .cc stub-array-size2.cc + +if {[prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \ + {c++ debug}]} { + return -1 +} + +gdb_test "print sizeof(a)/sizeof(a\[0\])" "10" diff --git a/gdb/testsuite/gdb.cp/stub-array-size.h b/gdb/testsuite/gdb.cp/stub-array-size.h new file mode 100644 index 0000000..5006633 --- /dev/null +++ b/gdb/testsuite/gdb.cp/stub-array-size.h @@ -0,0 +1,21 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2020 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +struct A +{ + virtual ~A(); +}; diff --git a/gdb/testsuite/gdb.cp/stub-array-size2.cc b/gdb/testsuite/gdb.cp/stub-array-size2.cc new file mode 100644 index 0000000..8eda4bd --- /dev/null +++ b/gdb/testsuite/gdb.cp/stub-array-size2.cc @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2020 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "stub-array-size.h" + +A::~A() +{ +} |