public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16874] New: Can't break on function in anonymous namespace
@ 2014-04-25  8:06 rguenth at gcc dot gnu.org
  2014-04-25  9:10 ` [Bug c++/16874] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-04-25  8:06 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 16874
           Summary: Can't break on function in anonymous namespace
           Product: gdb
           Version: 7.7
            Status: NEW
          Severity: critical
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: rguenth at gcc dot gnu.org

namespace { int foo (void) { return 0; } } int main() { return foo (); }

> gdb ./a.out
GNU gdb (GDB; devel:gcc) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.opensuse.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...

warning: /etc/gdbinit.d/gdb-heap.py: No such file or directory
Reading symbols from ./a.out...done.
(gdb) b foo
Function "foo" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) start
Temporary breakpoint 1 at 0x4005ec: file t.C, line 1.
Starting program: /tmp/a.out 

Temporary breakpoint 1, main () at t.C:1
1       namespace { int foo (void) { return 0; } } int main() { return foo ();
}
(gdb) b foo
Function "foo" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n


so it doesn't work, not from toplevel context before starting the program
nor from a context within the TU that contains the anonymous namespace.

Breaks debugging of GCC big times - try to break on
cfgexpand.c:pass_expand::execute - we want to be able to do that from a
context that is not necessarily local to that TU.

-- 
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++/16874] Can't break on function in anonymous namespace
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
@ 2014-04-25  9:10 ` rguenth at gcc dot gnu.org
  2014-07-29 21:04 ` dmalcolm at redhat dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-04-25  9:10 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> ---
And funnily

(gdb) b '(anonymous namespace)::pass_expand::<tab>

auto-"completes" to '(anonymous namespace)::

how useful.  All auto-completion seems to strip everything up to the
first ::.  Bah.

-- 
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++/16874] Can't break on function in anonymous namespace
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
  2014-04-25  9:10 ` [Bug c++/16874] " rguenth at gcc dot gnu.org
@ 2014-07-29 21:04 ` dmalcolm at redhat dot com
  2014-08-06 14:12 ` [Bug c++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward dmalcolm at redhat dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dmalcolm at redhat dot com @ 2014-07-29 21:04 UTC (permalink / raw)
  To: gdb-prs

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

Dave Malcolm <dmalcolm at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmalcolm at redhat dot com

--- Comment #3 from Dave Malcolm <dmalcolm at redhat dot com> ---
FWIW I've written a custom breakpoint-setting command using gdb's Python
interface to try to workaround this from the gcc side:
https://gcc.gnu.org/ml/gcc-patches/2014-07/msg02011.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++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
  2014-04-25  9:10 ` [Bug c++/16874] " rguenth at gcc dot gnu.org
  2014-07-29 21:04 ` dmalcolm at redhat dot com
@ 2014-08-06 14:12 ` dmalcolm at redhat dot com
  2014-09-13  8:10 ` markus at trippelsdorf dot de
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dmalcolm at redhat dot com @ 2014-08-06 14:12 UTC (permalink / raw)
  To: gdb-prs

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

Dave Malcolm <dmalcolm at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Can't break on function in  |Setting a breakpoint on
                   |anonymous namespace         |function in anonymous
                   |                            |namespace is unnecessarily
                   |                            |awkward

--- Comment #4 from Dave Malcolm <dmalcolm at redhat dot com> ---
Renaming.  It *is* possible to set a breakpoint on a function in an anonymous
namespace, it's just way too tricky to do it right now, given that
(A) you have to type the full qualified name, and
(B) tab-completion is broken

and these make it sufficiently difficult that it's effectively not possible for
a non-expert user.

So please can (A) and (B) be 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++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-08-06 14:12 ` [Bug c++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward dmalcolm at redhat dot com
@ 2014-09-13  8:10 ` markus at trippelsdorf dot de
  2014-09-19 14:55 ` patrick at parcs dot ath.cx
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: markus at trippelsdorf dot de @ 2014-09-13  8:10 UTC (permalink / raw)
  To: gdb-prs

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

Markus Trippelsdorf <markus at trippelsdorf dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |markus at trippelsdorf dot de

-- 
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++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2014-09-13  8:10 ` markus at trippelsdorf dot de
@ 2014-09-19 14:55 ` patrick at parcs dot ath.cx
  2014-09-19 15:22 ` markus at trippelsdorf dot de
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: patrick at parcs dot ath.cx @ 2014-09-19 14:55 UTC (permalink / raw)
  To: gdb-prs

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

patrick at parcs dot ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |patrick at parcs dot ath.cx

--- Comment #5 from patrick at parcs dot ath.cx ---
You can do

gdb> break *foo

or if foo is inside an anonymous namespace of another TU, you can do

gdb> break *'foo.c'::foo

Is this functionality sufficient for your use case?

-- 
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++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2014-09-19 14:55 ` patrick at parcs dot ath.cx
@ 2014-09-19 15:22 ` markus at trippelsdorf dot de
  2014-09-19 15:26 ` patrick at parcs dot ath.cx
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: markus at trippelsdorf dot de @ 2014-09-19 15:22 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from Markus Trippelsdorf <markus at trippelsdorf dot de> ---
(In reply to patrick from comment #5)
> You can do
> 
> gdb> break *foo
No symbol "foo" in current context.

markus@x4 ~ % gdb -v
GNU gdb (GDB) 7.8.50.20140729-cvs

-- 
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++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2014-09-19 15:22 ` markus at trippelsdorf dot de
@ 2014-09-19 15:26 ` patrick at parcs dot ath.cx
  2014-09-22  7:51 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: patrick at parcs dot ath.cx @ 2014-09-19 15:26 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #7 from patrick at parcs dot ath.cx ---
(In reply to Markus Trippelsdorf from comment #6)
> (In reply to patrick from comment #5)
> > You can do
> > 
> > gdb> break *foo
> No symbol "foo" in current context.
> 
> markus@x4 ~ % gdb -v
> GNU gdb (GDB) 7.8.50.20140729-cvs

The program has to be running for "break *" to work, it seems.

Try:

gdb> break main
gdb> run
gdb> break *foo

-- 
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++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2014-09-19 15:26 ` patrick at parcs dot ath.cx
@ 2014-09-22  7:51 ` rguenth at gcc dot gnu.org
  2014-11-26  4:32 ` patrick at parcs dot ath.cx
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-09-22  7:51 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> ---
The workaround works to some extent, but tab-completion is still broken
and for

t1.C
-----
namespace { int foo (void) { return 0; } }
int bar(void);
int main() { return foo () + bar (); }

t2.C
-----
namespace { int foo2 (void) { return 1; } }
int bar () { return foo2 (); }

it doesn't allow me to set a breakpoint on t2.C::foo2 until I enter bar().
That is, using 'b *<name>' seems to do symbol lookup from the current
scope only.

For the GCC case the workaround doesn't work in practice for this reason.

b '(anonymous namespace)::foo2'

works from any context (but is quite awkward due to tab-completion being
broken).

-- 
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++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2014-09-22  7:51 ` rguenth at gcc dot gnu.org
@ 2014-11-26  4:32 ` patrick at parcs dot ath.cx
  2015-08-13  6:54 ` markus at trippelsdorf dot de
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: patrick at parcs dot ath.cx @ 2014-11-26  4:32 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #9 from patrick at parcs dot ath.cx ---
Created attachment 7974
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7974&action=edit
Candidate patch

Here is a candidate patch that fixes this issue by allowing the user to omit
the "(anonymous namespace)::" prefix when referencing symbols that are defined
inside an anonymous namespace.  Tab completion is fixed accordingly, e.g. by
allowing one to tab-complete "pass_exp" into "pass_expand" even though
pass_expand is actually (anonymous namespace)::pass_expand.  This should work
in breakpoint and expression context.

So the patch enables you to do

(gdb) break pass_exp<TAB>::execu<TAB>

to break on (anonymous namespace)::pass_expand::execute.

-- 
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++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2014-11-26  4:32 ` patrick at parcs dot ath.cx
@ 2015-08-13  6:54 ` markus at trippelsdorf dot de
  2015-08-26  1:19 ` patrick at parcs dot ath.cx
  2020-07-22 14:38 ` palves at redhat dot com
  11 siblings, 0 replies; 13+ messages in thread
From: markus at trippelsdorf dot de @ 2015-08-13  6:54 UTC (permalink / raw)
  To: gdb-prs

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

Markus Trippelsdorf <markus at trippelsdorf dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #7974|0                           |1
        is obsolete|                            |

--- Comment #10 from Markus Trippelsdorf <markus at trippelsdorf dot de> ---
Created attachment 8515
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8515&action=edit
updated patch

I've updated Patrick's patch for gdb trunk.

It works fine:
Example from comment0:

 % gdb ./a.out
Reading symbols from ./a.out...done.
(gdb) b fo<tab> 
Breakpoint 1 at 0x40058a: file anon_namesp.cpp, line 1.
(gdb) run
Starting program: /home/markus/a.out 
Breakpoint 1, (anonymous namespace)::foo () at anon_namesp.cpp:1

Example from comment8:

Reading symbols from ./a.out...done.
(gdb) b fo<tab><tab>
foo()   foo2()  
(gdb) b foo2() 
Breakpoint 1 at 0x4005b3: file t2.cpp, line 1.
(gdb) run
Starting program: /home/markus/a.out 
Breakpoint 1, (anonymous namespace)::foo2 () at t2.cpp:1
1       namespace { int foo2 (void) { return 1; } }

Any chance to move this issue forward?

-- 
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++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2015-08-13  6:54 ` markus at trippelsdorf dot de
@ 2015-08-26  1:19 ` patrick at parcs dot ath.cx
  2020-07-22 14:38 ` palves at redhat dot com
  11 siblings, 0 replies; 13+ messages in thread
From: patrick at parcs dot ath.cx @ 2015-08-26  1:19 UTC (permalink / raw)
  To: gdb-prs

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

patrick at parcs dot ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at sourceware dot org   |patrick at parcs dot ath.cx

--- Comment #11 from patrick at parcs dot ath.cx ---
I will try to.

-- 
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++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward
  2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2015-08-26  1:19 ` patrick at parcs dot ath.cx
@ 2020-07-22 14:38 ` palves at redhat dot com
  11 siblings, 0 replies; 13+ messages in thread
From: palves at redhat dot com @ 2020-07-22 14:38 UTC (permalink / raw)
  To: gdb-prs

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

Pedro Alves <palves at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #18 from Pedro Alves <palves at redhat dot com> ---
I believe that since that series I mentioned is merged for a while and we
haven't heard related negative pushback since, we can close this bug.  Please
reopen if you believe otherwise.

-- 
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:[~2020-07-22 14:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-25  8:06 [Bug c++/16874] New: Can't break on function in anonymous namespace rguenth at gcc dot gnu.org
2014-04-25  9:10 ` [Bug c++/16874] " rguenth at gcc dot gnu.org
2014-07-29 21:04 ` dmalcolm at redhat dot com
2014-08-06 14:12 ` [Bug c++/16874] Setting a breakpoint on function in anonymous namespace is unnecessarily awkward dmalcolm at redhat dot com
2014-09-13  8:10 ` markus at trippelsdorf dot de
2014-09-19 14:55 ` patrick at parcs dot ath.cx
2014-09-19 15:22 ` markus at trippelsdorf dot de
2014-09-19 15:26 ` patrick at parcs dot ath.cx
2014-09-22  7:51 ` rguenth at gcc dot gnu.org
2014-11-26  4:32 ` patrick at parcs dot ath.cx
2015-08-13  6:54 ` markus at trippelsdorf dot de
2015-08-26  1:19 ` patrick at parcs dot ath.cx
2020-07-22 14:38 ` palves at redhat 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).