From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 41BC4385828E; Fri, 6 Oct 2023 13:07:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41BC4385828E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696597671; bh=3GD5OkCGpKh49WCus+xaRul+dOyvgwE/yASMAj8Jdxo=; h=From:To:Subject:Date:From; b=OotadJO235oAqbIOF3917RA5Vwkt1jXe9q/RvxjCj3ixBoPrpak2TUFxkBr5GAHoX 3oI/rZbCzS2POm6XJeQavf/5pSPcyrIETOPAggADN3SGOYjngtHdIjwVuj8DsPW3OL 6KNnL9Z2v8xXvUxrQeqZ2Pd8jbKC/s1LcL7x0pkw= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/30946] New: [gdb/symtab, gdb-index] FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=0: nest_prefix=1: before start: info symbol contains_keyword::increment Date: Fri, 06 Oct 2023 13:07:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: symtab X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30946 Bug ID: 30946 Summary: [gdb/symtab, gdb-index] FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=3D0: nest_prefix=3D1: before start: info symbol contains_keyword::increment Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: symtab Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- Consider test-case gdb.fortran/nested-funcs-2.exp. It runs fine with target board unix, and also when using target board cc-with-gdb-index. But the latter is somewhat deceptive. With target board unix: ... $ gdb -q -batch \ -iex "set trace-commands on" \ nested-funcs-2 \ -ex "maint info symtabs" \ -ex "info symbol contains_keyword::increment" +maint info symtabs +info symbol contains_keyword::increment increment in section .text ... we start from a position where no symtab is expanded. But with cc-with-gdb-index, we start from a position where the only relevant symtab is already expanded: ... +maint info symtabs ... name nested-funcs-2.f90 ... +info symbol contains_keyword::increment increment in section .text ... What happens is that when loading the exec, gdb attempts to auto-detect the language and/or name of the main function. In the target-board unix case, the cooked index is used to answer this question, and no symtab expansion happens. When doing the symbol lookup, t= he correct symtab is expanded, and the result is found in the expanded symtab. In the target-board cc-with-gdb-index case, it results in the expansion of = the symtab, which means that the test-case is not actually testing that symtab expansion is properly triggered by the symbol lookup. We can prevent the early expansion by hard-coding the language: ... $ gdb -q -batch \ -iex "set trace-commands on" \ -iex "set lang fortran" \ nested-funcs-2 \ -ex "maint info symtabs" \ -ex "info symbol contains_keyword::increment" +set lang fortran +maint info symtabs +info symbol contains_keyword::increment No symbol "contains_keyword::increment" in current context. ... and that exposes that the functionality doesn't work. We can demonstrate the same when running the test-case by applying this demonstrator patch: ... diff --git a/gdb/testsuite/gdb.fortran/nested-funcs-2.exp b/gdb/testsuite/gdb.fortran/nested-funcs-2.exp index 8c3b61aa161..6fb4899ee5b 100644 --- a/gdb/testsuite/gdb.fortran/nested-funcs-2.exp +++ b/gdb/testsuite/gdb.fortran/nested-funcs-2.exp @@ -32,11 +32,13 @@ set int4 [fortran_int4] # nested subroutine symbols will be prefixed with their parent # subroutine scope. proc do_bp_tests {with_src_prefix_p with_nest_prefix_p} { - global testfile srcfile + global binfile srcfile global int4 global hex - clean_restart ${testfile} + clean_restart + gdb_test "set lang fortran" + gdb_load $binfile if { $with_src_prefix_p } { set src_prefix "${srcfile}:" ... which gets us these FAILs: ... Running /data/vries/gdb/src/gdb/testsuite/gdb.fortran/nested-funcs-2.exp ... FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=3D0: nest_prefix=3D1: befo= re start: info symbol contains_keyword::increment FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=3D0: nest_prefix=3D1: befo= re start: whatis contains_keyword::increment FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=3D0: nest_prefix=3D1: befo= re start: ptype contains_keyword::increment FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=3D0: nest_prefix=3D1: befo= re start: print contains_keyword::increment FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=3D1: nest_prefix=3D1: befo= re start: info symbol contains_keyword::increment FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=3D1: nest_prefix=3D1: befo= re start: whatis contains_keyword::increment FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=3D1: nest_prefix=3D1: befo= re start: ptype contains_keyword::increment FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=3D1: nest_prefix=3D1: befo= re start: print contains_keyword::increment ... The patch "[gdb/symtab] Add name_of_main and language_of_main to the DWARF index" ( https://sourceware.org/pipermail/gdb-patches/2023-August/201568.ht= ml ) also prevents the early expansion mentioned above, and applying it makes th= is test-case fail in the same way, without the demonstrator patch (which is ho= w I found this in the first place). --=20 You are receiving this mail because: You are on the CC list for the bug.=