[5/7] gdb/fortran: Don't include module symbols when searching for types
Commit Message
Currently the 'info types' command will return symbols that correspond
to Fortran modules. This because the symbols are created with domain
MODULE_DOMAIN, but address_class LOC_TYPEDEF, which is the same
address_class as type symbols.
This commit explicitly prevents MODULE_DOMAIN symbols from appearing
when we search for symbols in the TYPES_DOMAIN, this prevents the
module symbols from appearing in the output of 'info types'.
gdb/ChangeLog:
* symtab.c (search_symbols): Don't include MODULE_DOMAIN symbols
when searching for types.
gdb/testsuite/ChangeLog:
* gdb.fortran/info-types.exp: Add module.
* gdb.fortran/info-types.f90: Update expected results.
---
gdb/ChangeLog | 5 +++++
gdb/symtab.c | 3 ++-
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.fortran/info-types.exp | 4 +++-
gdb/testsuite/gdb.fortran/info-types.f90 | 11 +++++++++++
5 files changed, 26 insertions(+), 2 deletions(-)
Comments
* Andrew Burgess <andrew.burgess@embecosm.com> [2019-07-27 17:22:33 +0100]:
> Currently the 'info types' command will return symbols that correspond
> to Fortran modules. This because the symbols are created with domain
> MODULE_DOMAIN, but address_class LOC_TYPEDEF, which is the same
> address_class as type symbols.
>
> This commit explicitly prevents MODULE_DOMAIN symbols from appearing
> when we search for symbols in the TYPES_DOMAIN, this prevents the
> module symbols from appearing in the output of 'info types'.
>
> gdb/ChangeLog:
>
> * symtab.c (search_symbols): Don't include MODULE_DOMAIN symbols
> when searching for types.
>
> gdb/testsuite/ChangeLog:
>
> * gdb.fortran/info-types.exp: Add module.
> * gdb.fortran/info-types.f90: Update expected results.
I've now pushed this patch as it only depended on the previous patch
in this series.
Thanks,
Andrew
> ---
> gdb/ChangeLog | 5 +++++
> gdb/symtab.c | 3 ++-
> gdb/testsuite/ChangeLog | 5 +++++
> gdb/testsuite/gdb.fortran/info-types.exp | 4 +++-
> gdb/testsuite/gdb.fortran/info-types.f90 | 11 +++++++++++
> 5 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index 84038d15dff..d3a209608b7 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -4539,7 +4539,8 @@ search_symbols (const char *regexp, enum search_domain kind,
> || treg_matches_sym_type_name (*treg,
> sym)))
> || (kind == TYPES_DOMAIN
> - && SYMBOL_CLASS (sym) == LOC_TYPEDEF))))
> + && SYMBOL_CLASS (sym) == LOC_TYPEDEF
> + && SYMBOL_DOMAIN (sym) != MODULE_DOMAIN))))
> {
> /* match */
> result.emplace_back (i, sym);
> diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
> index 9571dc45593..81e67395e8a 100644
> --- a/gdb/testsuite/gdb.fortran/info-types.exp
> +++ b/gdb/testsuite/gdb.fortran/info-types.exp
> @@ -42,4 +42,6 @@ gdb_test "info types" \
> "\[\t \]+${character1}" \
> "\[\t \]+${integer4}" \
> "\[\t \]+${logical4}" \
> - "16:\[\t \]+Type s1;" ]
> + "20:\[\t \]+Type __vtype_mod1_M1t1;" \
> + "17:\[\t \]+Type m1t1;" \
> + "22:\[\t \]+Type s1;" ]
> diff --git a/gdb/testsuite/gdb.fortran/info-types.f90 b/gdb/testsuite/gdb.fortran/info-types.f90
> index 21c9d9df63c..0e27e1ddf08 100644
> --- a/gdb/testsuite/gdb.fortran/info-types.f90
> +++ b/gdb/testsuite/gdb.fortran/info-types.f90
> @@ -13,13 +13,24 @@
> ! You should have received a copy of the GNU General Public License
> ! along with this program. If not, see <http://www.gnu.org/licenses/>.
>
> +module mod1
> + type :: m1t1
> + integer :: b
> + end type m1t1
> +end module mod1
> +
> program info_types_test
> + use mod1
> +
> type :: s1
> integer :: a
> end type s1
>
> logical :: l
> type (s1) :: var_a
> + type (m1t1) :: var_b
> +
> var_a%a = 1
> + var_b%b = 2
> l = .FALSE.
> end program info_types_test
> --
> 2.14.5
>
On 28-08-19 14:37, Andrew Burgess wrote:
> * Andrew Burgess <andrew.burgess@embecosm.com> [2019-07-27 17:22:33 +0100]:
>
>> Currently the 'info types' command will return symbols that correspond
>> to Fortran modules. This because the symbols are created with domain
>> MODULE_DOMAIN, but address_class LOC_TYPEDEF, which is the same
>> address_class as type symbols.
>>
>> This commit explicitly prevents MODULE_DOMAIN symbols from appearing
>> when we search for symbols in the TYPES_DOMAIN, this prevents the
>> module symbols from appearing in the output of 'info types'.
>>
>> gdb/ChangeLog:
>>
>> * symtab.c (search_symbols): Don't include MODULE_DOMAIN symbols
>> when searching for types.
>>
>> gdb/testsuite/ChangeLog:
>>
>> * gdb.fortran/info-types.exp: Add module.
>> * gdb.fortran/info-types.f90: Update expected results.
>
> I've now pushed this patch as it only depended on the previous patch
> in this series.
Also, this test-case times out with check-read1, due to the many
"Non-debugging symbols" that are parsed by a single .*.
Thanks,
- Tom
On 29-08-19 11:09, Tom de Vries wrote:
> On 28-08-19 14:37, Andrew Burgess wrote:
>> * Andrew Burgess <andrew.burgess@embecosm.com> [2019-07-27 17:22:33 +0100]:
>>
>>> Currently the 'info types' command will return symbols that correspond
>>> to Fortran modules. This because the symbols are created with domain
>>> MODULE_DOMAIN, but address_class LOC_TYPEDEF, which is the same
>>> address_class as type symbols.
>>>
>>> This commit explicitly prevents MODULE_DOMAIN symbols from appearing
>>> when we search for symbols in the TYPES_DOMAIN, this prevents the
>>> module symbols from appearing in the output of 'info types'.
>>>
>>> gdb/ChangeLog:
>>>
>>> * symtab.c (search_symbols): Don't include MODULE_DOMAIN symbols
>>> when searching for types.
>>>
>>> gdb/testsuite/ChangeLog:
>>>
>>> * gdb.fortran/info-types.exp: Add module.
>>> * gdb.fortran/info-types.f90: Update expected results.
>>
>> I've now pushed this patch as it only depended on the previous patch
>> in this series.
>
> Also, this test-case times out with check-read1, due to the many
> "Non-debugging symbols" that are parsed by a single .*.
Sorry, wrong thread, this is about gdb.base/info-var.exp:
...
FAIL: gdb.base/info-var.exp: info variables (timeout)
FAIL: gdb.base/info-var.exp: info variables -n (timeout)
FAIL: gdb.base/info-var.exp: info variables -n global (timeout)
...
Thanks,
- Tom
@@ -4539,7 +4539,8 @@ search_symbols (const char *regexp, enum search_domain kind,
|| treg_matches_sym_type_name (*treg,
sym)))
|| (kind == TYPES_DOMAIN
- && SYMBOL_CLASS (sym) == LOC_TYPEDEF))))
+ && SYMBOL_CLASS (sym) == LOC_TYPEDEF
+ && SYMBOL_DOMAIN (sym) != MODULE_DOMAIN))))
{
/* match */
result.emplace_back (i, sym);
@@ -42,4 +42,6 @@ gdb_test "info types" \
"\[\t \]+${character1}" \
"\[\t \]+${integer4}" \
"\[\t \]+${logical4}" \
- "16:\[\t \]+Type s1;" ]
+ "20:\[\t \]+Type __vtype_mod1_M1t1;" \
+ "17:\[\t \]+Type m1t1;" \
+ "22:\[\t \]+Type s1;" ]
@@ -13,13 +13,24 @@
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
+module mod1
+ type :: m1t1
+ integer :: b
+ end type m1t1
+end module mod1
+
program info_types_test
+ use mod1
+
type :: s1
integer :: a
end type s1
logical :: l
type (s1) :: var_a
+ type (m1t1) :: var_b
+
var_a%a = 1
+ var_b%b = 2
l = .FALSE.
end program info_types_test