public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.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	[thread overview]
Message-ID: <bug-30946-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=30946

            Bug ID: 30946
           Summary: [gdb/symtab, gdb-index] FAIL:
                    gdb.fortran/nested-funcs-2.exp: src_prefix=0:
                    nest_prefix=1: 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, the
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=0: nest_prefix=1: before
start: info symbol contains_keyword::increment
FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=0: nest_prefix=1: before
start: whatis contains_keyword::increment
FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=0: nest_prefix=1: before
start: ptype contains_keyword::increment
FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=0: nest_prefix=1: before
start: print contains_keyword::increment
FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=1: nest_prefix=1: before
start: info symbol contains_keyword::increment
FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=1: nest_prefix=1: before
start: whatis contains_keyword::increment
FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=1: nest_prefix=1: before
start: ptype contains_keyword::increment
FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=1: nest_prefix=1: before
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.html )
also prevents the early expansion mentioned above, and applying it makes this
test-case fail in the same way, without the demonstrator patch (which is how I
found this in the first place).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2023-10-06 13:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06 13:07 vries at gcc dot gnu.org [this message]
2023-10-10  8:26 ` [Bug symtab/30946] " cvs-commit at gcc dot gnu.org
2023-12-10 16:15 ` tromey at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-30946-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).