public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion
@ 2023-07-21  7:34 vries at gcc dot gnu.org
  2023-07-21  8:16 ` [Bug symtab/30661] " vries at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-07-21  7:34 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30661
           Summary: [gdb/symtab] main symbol language lookup causes symtab
                    expansion
           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 a hello world:
...
$ gcc -g hello.c 
...

With gdb-12-branch:
...
$ gdb -q -batch a.out -ex "maint info symtabs"
$
...

With gdb-13-branch:
...
$ gdb -q -batch a.out -ex "maint info symtabs"
{ objfile /data/vries/gdb/a.out ((struct objfile *) 0x146ca90)
  { ((struct compunit_symtab *) 0x1460fc0)
    debugformat DWARF 4
    producer GNU C11 7.5.0 -mtune=generic -march=x86-64 -g
    name hello.c
  ...
...

This is a feature that was added to work around the slowness in expansion of
lto debug info, in order to not have to wait too long for the "file a.out" to
finish.

Feature was added in commit d3214198119 ("[gdb] Use partial symbol table to
find language for main").

This seems to have regressed.

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug symtab/30661] [gdb/symtab] main symbol language lookup causes symtab expansion
  2023-07-21  7:34 [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion vries at gcc dot gnu.org
@ 2023-07-21  8:16 ` vries at gcc dot gnu.org
  2023-07-21  9:02 ` vries at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-07-21  8:16 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #0)
> This seems to have regressed.

Between gdb-13-branchpoint and gdb-13-branch, bisecting points to:
...
commit 7f4307436fdab42da2b385040b90294f301ea55b
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Feb 13 17:44:54 2023 -0700

    Fix "start" for D, Rust, etc
...

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug symtab/30661] [gdb/symtab] main symbol language lookup causes symtab expansion
  2023-07-21  7:34 [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion vries at gcc dot gnu.org
  2023-07-21  8:16 ` [Bug symtab/30661] " vries at gcc dot gnu.org
@ 2023-07-21  9:02 ` vries at gcc dot gnu.org
  2023-07-21  9:53 ` vries at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-07-21  9:02 UTC (permalink / raw)
  To: gdb-prs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Using this:
...
vries@xerxes:~/gdb/src> git diff
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 25635d9b72e..0b2d35f4b86 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -62,7 +62,7 @@ bool
 language_requires_canonicalization (enum language lang)
 {
   return (lang == language_ada
-         || lang == language_c
+         || lang == language_d
          || lang == language_cplus);
 }

@@ -242,6 +242,10 @@ cooked_index_shard::add (sect_offset die_offset, enum
dwarf_tag tag,
      implicit "main" discovery.  */
   if ((flags & IS_MAIN) != 0)
     m_main = result;
+  else if (!language_requires_canonicalization (per_cu->lang ())
+          && m_main == nullptr
+          && strcmp (name, "main") == 0)
+    m_main = result;

   return result;
 }
...
we get the old behaviour back, without regressing on
gdb.dlang/dlang-start-2.exp (can't run gdb.dlang/dlang-start.exp).

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug symtab/30661] [gdb/symtab] main symbol language lookup causes symtab expansion
  2023-07-21  7:34 [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion vries at gcc dot gnu.org
  2023-07-21  8:16 ` [Bug symtab/30661] " vries at gcc dot gnu.org
  2023-07-21  9:02 ` vries at gcc dot gnu.org
@ 2023-07-21  9:53 ` vries at gcc dot gnu.org
  2023-07-21 14:12 ` vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-07-21  9:53 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #2)
> Using this:
> ...
> diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
> index 25635d9b72e..0b2d35f4b86 100644
> --- a/gdb/dwarf2/cooked-index.c
> +++ b/gdb/dwarf2/cooked-index.c
> @@ -62,7 +62,7 @@ bool
>  language_requires_canonicalization (enum language lang)
>  {
>    return (lang == language_ada
> -	  || lang == language_c
> +	  || lang == language_d
>  	  || lang == language_cplus);
>  }
>  
> @@ -242,6 +242,10 @@ cooked_index_shard::add (sect_offset die_offset, enum
> dwarf_tag tag,
>       implicit "main" discovery.  */
>    if ((flags & IS_MAIN) != 0)
>      m_main = result;
> +  else if (!language_requires_canonicalization (per_cu->lang ())
> +	   && m_main == nullptr
> +	   && strcmp (name, "main") == 0)
> +    m_main = result;
>  
>    return result;
>  }
> ...
> we get the old behaviour back, without regressing on
> gdb.dlang/dlang-start-2.exp (can't run gdb.dlang/dlang-start.exp).

Hmm, on the other hand I also want this to work for c++, so I guess a different
fix is needed.

Anyway, FWIW, tested on top of trunk on x86_64-linux, no regressions.

Also, I found the source of the requirement to mark C as a language that
requires canonicalization: c_canonicalize_name.

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug symtab/30661] [gdb/symtab] main symbol language lookup causes symtab expansion
  2023-07-21  7:34 [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-07-21  9:53 ` vries at gcc dot gnu.org
@ 2023-07-21 14:12 ` vries at gcc dot gnu.org
  2023-07-31 14:16 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-07-21 14:12 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
Created attachment 14993
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14993&action=edit
Tentative patch

Currently testing.

Todo: add C and C++ test-cases.

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug symtab/30661] [gdb/symtab] main symbol language lookup causes symtab expansion
  2023-07-21  7:34 [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-07-21 14:12 ` vries at gcc dot gnu.org
@ 2023-07-31 14:16 ` vries at gcc dot gnu.org
  2023-08-04 11:24 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-07-31 14:16 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
Related reading: PR30174.

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug symtab/30661] [gdb/symtab] main symbol language lookup causes symtab expansion
  2023-07-21  7:34 [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-07-31 14:16 ` vries at gcc dot gnu.org
@ 2023-08-04 11:24 ` vries at gcc dot gnu.org
  2023-08-05 15:57 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-08-04 11:24 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2023-August/201347.html

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug symtab/30661] [gdb/symtab] main symbol language lookup causes symtab expansion
  2023-07-21  7:34 [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-08-04 11:24 ` vries at gcc dot gnu.org
@ 2023-08-05 15:57 ` cvs-commit at gcc dot gnu.org
  2023-08-05 16:01 ` vries at gcc dot gnu.org
  2023-10-30 16:14 ` josh.cottingham at linaro dot org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-05 15:57 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #7 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d06730bc0205f7c35bfccf057ef0ef83a12206d6

commit d06730bc0205f7c35bfccf057ef0ef83a12206d6
Author: Tom de Vries <tdevries@suse.de>
Date:   Sat Aug 5 17:57:13 2023 +0200

    [gdb/symtab] Find main language without symtab expansion

    When loading an executable using "file a.out", the language is set
according
    to a.out, which can involve looking up the language of symbol "main", which
    will cause the symtab expansion for the containing CU.

    Expansion of lto debug info can be slow, so in commit d3214198119 ("[gdb]
Use
    partial symbol table to find language for main") a feature was added to
avoid
    the symtab expansion.

    This feature stopped working after commit 7f4307436fd ("Fix "start" for D,
    Rust, etc").

    [ The commit addresses problems related to command start, which requires
finding
    the main function:
    - for language D, "main" was found instead of "D main", and
    - for Rust, the correct function was found, but attributed the wrong name
      (not fully qualified). ]

    Reimplement the feature by adding
    cooked_index_functions::lookup_global_symbol_language.

    Tested on x86_64-linux.

    PR symtab/30661
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30661

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug symtab/30661] [gdb/symtab] main symbol language lookup causes symtab expansion
  2023-07-21  7:34 [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion vries at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-08-05 15:57 ` cvs-commit at gcc dot gnu.org
@ 2023-08-05 16:01 ` vries at gcc dot gnu.org
  2023-10-30 16:14 ` josh.cottingham at linaro dot org
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-08-05 16:01 UTC (permalink / raw)
  To: gdb-prs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |14.1

--- Comment #8 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed.

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug symtab/30661] [gdb/symtab] main symbol language lookup causes symtab expansion
  2023-07-21  7:34 [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion vries at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2023-08-05 16:01 ` vries at gcc dot gnu.org
@ 2023-10-30 16:14 ` josh.cottingham at linaro dot org
  8 siblings, 0 replies; 10+ messages in thread
From: josh.cottingham at linaro dot org @ 2023-10-30 16:14 UTC (permalink / raw)
  To: gdb-prs

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

Josh Cottingham <josh.cottingham at linaro dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |josh.cottingham at linaro dot org

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-10-30 16:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21  7:34 [Bug symtab/30661] New: [gdb/symtab] main symbol language lookup causes symtab expansion vries at gcc dot gnu.org
2023-07-21  8:16 ` [Bug symtab/30661] " vries at gcc dot gnu.org
2023-07-21  9:02 ` vries at gcc dot gnu.org
2023-07-21  9:53 ` vries at gcc dot gnu.org
2023-07-21 14:12 ` vries at gcc dot gnu.org
2023-07-31 14:16 ` vries at gcc dot gnu.org
2023-08-04 11:24 ` vries at gcc dot gnu.org
2023-08-05 15:57 ` cvs-commit at gcc dot gnu.org
2023-08-05 16:01 ` vries at gcc dot gnu.org
2023-10-30 16:14 ` josh.cottingham at linaro dot org

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).