public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/29896] New: GDB git doesn't recognize template function name
@ 2022-12-13 2:05 vimacs.hacks at gmail dot com
2022-12-13 3:21 ` [Bug c++/29896] " simark at simark dot ca
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: vimacs.hacks at gmail dot com @ 2022-12-13 2:05 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
Bug ID: 29896
Summary: GDB git doesn't recognize template function name
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: vimacs.hacks at gmail dot com
Target Milestone: ---
First posted on https://sourceware.org/pipermail/gdb/2022-November/050431.html
GDB 12.1 works as expected in this case.
For the following C++ program built with "g++ -g -o test test.cc" (no matter
what optimization level used):
template <typename T = int>
int t0(int n)
{
int sum = 0;
for (int i = 0; i < n; ++i) {
sum += i * i;
}
return sum;
}
int t1(int n)
{
int sum = 0;
for (int i = 0; i < n; ++i) {
sum += i * i;
}
return sum;
}
int main()
{
int a = t0(5);
int b = t1(5);
return a + b;
}
We cannot use "b t0" command, however, after I use tab completion once, GDB
recognize this:
(gdb) b t0
Function "t0" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) #b t0<int>(int)
(gdb) b t0
Breakpoint 1 at 0x117d: file test.cc, line 4.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
@ 2022-12-13 3:21 ` simark at simark dot ca
2022-12-13 3:32 ` vimacs.hacks at gmail dot com
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: simark at simark dot ca @ 2022-12-13 3:21 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
Simon Marchi <simark at simark dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
CC| |simark at simark dot ca
Last reconfirmed| |2022-12-13
Target Milestone|--- |13.1
Status|UNCONFIRMED |NEW
--- Comment #1 from Simon Marchi <simark at simark dot ca> ---
Confirmed. It's a bit hard to bisect because we hit a bunch of other crashes
and compilation failure, but it's most likely due to the new DWARF reader.
Adding the 13.1 milestone, hopefully we can fix it, since it's a regression.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
2022-12-13 3:21 ` [Bug c++/29896] " simark at simark dot ca
@ 2022-12-13 3:32 ` vimacs.hacks at gmail dot com
2022-12-13 19:33 ` tromey at sourceware dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: vimacs.hacks at gmail dot com @ 2022-12-13 3:32 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
--- Comment #2 from vimacs.hacks at gmail dot com <vimacs.hacks at gmail dot com> ---
Yes, it's hard to bisect. I once tried when I posted that mail.
I'm a little surprised GDB can recognize the function after a tab completion,
it looks like GDB can cache the completed names.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
2022-12-13 3:21 ` [Bug c++/29896] " simark at simark dot ca
2022-12-13 3:32 ` vimacs.hacks at gmail dot com
@ 2022-12-13 19:33 ` tromey at sourceware dot org
2022-12-14 0:42 ` tromey at sourceware dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: tromey at sourceware dot org @ 2022-12-13 19:33 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
What happens is that the first scan (the cooked index) takes
the name from the DWARF and gets "t0<>". The cooked index
just uses strncasecmp to find entries, so it doesn't find
this name.
Full symbol name matching, I think, is done with strncmp_iw_with_mode,
which handles a lot of weird cases and ignores the "<>":
/* Skip template parameters in STRING1 if STRING2 does not contain
any. E.g.:
[...]
So, that sucks.
I'm not completely sure how to solve it. Perhaps stripping
the template parmaeters before recording the entry in the index would
work.
One idea is to have two entries, both with and without the parameters,
but I wonder about combinatorial explosion if there are nested templates
like a<>::b<>::c<>::d<> -- since the entries record parent information.
Another idea is to change the hashing and the lookup to use
strncmp_iw_with_mode somehow, at least for C++ names.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
` (2 preceding siblings ...)
2022-12-13 19:33 ` tromey at sourceware dot org
@ 2022-12-14 0:42 ` tromey at sourceware dot org
2022-12-15 14:28 ` tromey at sourceware dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: tromey at sourceware dot org @ 2022-12-14 0:42 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |29366
Referenced Bugs:
https://sourceware.org/bugzilla/show_bug.cgi?id=29366
[Bug 29366] [meta] New DWARF indexer meta bug
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
` (3 preceding siblings ...)
2022-12-14 0:42 ` tromey at sourceware dot org
@ 2022-12-15 14:28 ` tromey at sourceware dot org
2022-12-15 17:37 ` tromey at sourceware dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: tromey at sourceware dot org @ 2022-12-15 14:28 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
> Another idea is to change the hashing
I forgot the index uses a sorted vector, not a hash table.
I tried using strcmp_iw_ordered, but that doesn't really
have the right semantics. Now I'm working on a patch to
implement a custom comparison function.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
` (4 preceding siblings ...)
2022-12-15 14:28 ` tromey at sourceware dot org
@ 2022-12-15 17:37 ` tromey at sourceware dot org
2022-12-15 19:08 ` tromey at sourceware dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: tromey at sourceware dot org @ 2022-12-15 17:37 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at sourceware dot org |tromey at sourceware dot org
--- Comment #5 from Tom Tromey <tromey at sourceware dot org> ---
Patch seems to work.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
` (5 preceding siblings ...)
2022-12-15 17:37 ` tromey at sourceware dot org
@ 2022-12-15 19:08 ` tromey at sourceware dot org
2023-01-17 14:06 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: tromey at sourceware dot org @ 2022-12-15 19:08 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
--- Comment #6 from Tom Tromey <tromey at sourceware dot org> ---
https://sourceware.org/pipermail/gdb-patches/2022-December/194795.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
` (6 preceding siblings ...)
2022-12-15 19:08 ` tromey at sourceware dot org
@ 2023-01-17 14:06 ` cvs-commit at gcc dot gnu.org
2023-01-17 14:15 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-17 14:06 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
--- 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 Tromey <tromey@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ac37b79cc440e37fc704d425a6e450afb3c7ee89
commit ac37b79cc440e37fc704d425a6e450afb3c7ee89
Author: Tom Tromey <tromey@adacore.com>
Date: Wed Dec 14 14:37:41 2022 -0700
Fix parameter-less template regression in new DWARF reader
PR c++/29896 points out a regression in the new DWARF reader. It does
not properly handle a case like "break fn", where "fn" is a template
function.
This happens because the new index uses strncasecmp to compare.
However, to make this work correctly, we need a custom function that
ignores template parameters.
This patch adds a custom comparison function and fixes the bug. A new
test case is included.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29896
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
` (7 preceding siblings ...)
2023-01-17 14:06 ` cvs-commit at gcc dot gnu.org
@ 2023-01-17 14:15 ` cvs-commit at gcc dot gnu.org
2023-01-17 14:15 ` tromey at sourceware dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-17 14:15 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
--- Comment #8 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-13-branch branch has been updated by Tom Tromey
<tromey@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=83d3152401cce0c6fd5cd2d4a140bbf5d89a5d9c
commit 83d3152401cce0c6fd5cd2d4a140bbf5d89a5d9c
Author: Tom Tromey <tromey@adacore.com>
Date: Wed Dec 14 14:37:41 2022 -0700
Fix parameter-less template regression in new DWARF reader
PR c++/29896 points out a regression in the new DWARF reader. It does
not properly handle a case like "break fn", where "fn" is a template
function.
This happens because the new index uses strncasecmp to compare.
However, to make this work correctly, we need a custom function that
ignores template parameters.
This patch adds a custom comparison function and fixes the bug. A new
test case is included.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29896
(cherry picked from commit ac37b79cc440e37fc704d425a6e450afb3c7ee89)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
` (8 preceding siblings ...)
2023-01-17 14:15 ` cvs-commit at gcc dot gnu.org
@ 2023-01-17 14:15 ` tromey at sourceware dot org
2023-01-18 22:08 ` tromey at sourceware dot org
2023-02-02 3:38 ` brobecker at gnat dot com
11 siblings, 0 replies; 13+ messages in thread
From: tromey at sourceware dot org @ 2023-01-17 14:15 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #9 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
` (9 preceding siblings ...)
2023-01-17 14:15 ` tromey at sourceware dot org
@ 2023-01-18 22:08 ` tromey at sourceware dot org
2023-02-02 3:38 ` brobecker at gnat dot com
11 siblings, 0 replies; 13+ messages in thread
From: tromey at sourceware dot org @ 2023-01-18 22:08 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #10 from Tom Tromey <tromey at sourceware dot org> ---
Fix has a bug:
https://sourceware.org/pipermail/gdb-patches/2023-January/195828.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/29896] GDB git doesn't recognize template function name
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
` (10 preceding siblings ...)
2023-01-18 22:08 ` tromey at sourceware dot org
@ 2023-02-02 3:38 ` brobecker at gnat dot com
11 siblings, 0 replies; 13+ messages in thread
From: brobecker at gnat dot com @ 2023-02-02 3:38 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29896
Joel Brobecker <brobecker at gnat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
CC| |brobecker at gnat dot com
Resolution|--- |FIXED
--- Comment #11 from Joel Brobecker <brobecker at gnat dot com> ---
For the record, Tom fixed this via this commit:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c121e82c39659d1140b1a6a3cfd72c765741b9f5
This was also ported to the gdb-13-branch:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7ba1fc5a18e0e5f61ab0939aed4f8b816a7a477a
Closing. Thanks Tom!
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-02-02 3:38 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13 2:05 [Bug c++/29896] New: GDB git doesn't recognize template function name vimacs.hacks at gmail dot com
2022-12-13 3:21 ` [Bug c++/29896] " simark at simark dot ca
2022-12-13 3:32 ` vimacs.hacks at gmail dot com
2022-12-13 19:33 ` tromey at sourceware dot org
2022-12-14 0:42 ` tromey at sourceware dot org
2022-12-15 14:28 ` tromey at sourceware dot org
2022-12-15 17:37 ` tromey at sourceware dot org
2022-12-15 19:08 ` tromey at sourceware dot org
2023-01-17 14:06 ` cvs-commit at gcc dot gnu.org
2023-01-17 14:15 ` cvs-commit at gcc dot gnu.org
2023-01-17 14:15 ` tromey at sourceware dot org
2023-01-18 22:08 ` tromey at sourceware dot org
2023-02-02 3:38 ` brobecker at gnat dot com
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).