public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/12156] New: cannot break on static functions with gcc flto (link time optimization)
@ 2010-10-23 14:51 chantry.xavier at gmail dot com
  2010-11-15 17:11 ` [Bug breakpoints/12156] " tromey at redhat dot com
  2010-11-21 18:08 ` chantry.xavier at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: chantry.xavier at gmail dot com @ 2010-10-23 14:51 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=12156

           Summary: cannot break on static functions with gcc flto (link
                    time optimization)
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
        AssignedTo: unassigned@sourceware.org
        ReportedBy: chantry.xavier@gmail.com


Created attachment 5082
  --> http://sourceware.org/bugzilla/attachment.cgi?id=5082
minimal test case with one static function foo

When compiling with gcc -flto, static symbols get a number suffix/extension.
e.g. foo becomes foo.2043

break foo<tab> expands to break foo.2043, but neither works.

The only way to actually set the break point is to specify the address
directly.

[xavier@xps-m1530 ~]$ gcc -flto test.c 
[xavier@xps-m1530 ~]$ objdump -d a.out | grep foo
00000000004004c4 <foo.2043>:
  4004d8:    e8 e7 ff ff ff           callq  4004c4 <foo.2043>
[xavier@xps-m1530 ~]$ gdb a.out 
GNU gdb (GDB) 7.2.50.20101022-cvs
Copyright (C) 2010 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-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/xavier/a.out...(no debugging symbols found)...done.
(gdb) break foo.2043 
Can't find member of namespace, class, struct, or union named "foo.2043"
Hint: try 'foo.2043<TAB> or 'foo.2043<ESC-?>
(Note leading single quote.)
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (foo.2043) pending.
(gdb) break foo
Function "foo" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (foo) pending.
(gdb) run
Starting program: /home/xavier/a.out 
bar

Program exited with code 04.
(gdb) break *0x4004c4
Breakpoint 3 at 0x4004c4
(gdb) run
Starting program: /home/xavier/a.out 

Breakpoint 3, 0x00000000004004c4 in foo.2043 ()
(gdb) c
Continuing.
bar

Program exited with code 04.
(gdb)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug breakpoints/12156] cannot break on static functions with gcc flto (link time optimization)
  2010-10-23 14:51 [Bug breakpoints/12156] New: cannot break on static functions with gcc flto (link time optimization) chantry.xavier at gmail dot com
@ 2010-11-15 17:11 ` tromey at redhat dot com
  2010-11-21 18:08 ` chantry.xavier at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: tromey at redhat dot com @ 2010-11-15 17:11 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=12156

Tom Tromey <tromey at redhat dot com> changed:

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

--- Comment #1 from Tom Tromey <tromey at redhat dot com> 2010-11-15 17:05:22 UTC ---
Try the hint that gdb suggests:

Hint: try 'foo.2043<TAB> or 'foo.2043<ESC-?>

So:  break 'foo.2043'

I think this could be better, so I'm leaving the PR open.

Also, I think this is an LTO bug.  It seems to me that it should emit
debuginfo naming the symbol as "foo".

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug breakpoints/12156] cannot break on static functions with gcc flto (link time optimization)
  2010-10-23 14:51 [Bug breakpoints/12156] New: cannot break on static functions with gcc flto (link time optimization) chantry.xavier at gmail dot com
  2010-11-15 17:11 ` [Bug breakpoints/12156] " tromey at redhat dot com
@ 2010-11-21 18:08 ` chantry.xavier at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: chantry.xavier at gmail dot com @ 2010-11-21 18:08 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=12156

--- Comment #2 from Xavier <chantry.xavier at gmail dot com> 2010-11-20 09:36:04 UTC ---
(In reply to comment #1)
> Try the hint that gdb suggests:
> 
> Hint: try 'foo.2043<TAB> or 'foo.2043<ESC-?>
> 
> So:  break 'foo.2043'
> 
> I think this could be better, so I'm leaving the PR open.
> 

I don't remember if I tried this or not before, I just remember I was a bit
confused by this message.

Anyway 'foo.2043<TAB> expands to 'foo.2043', but the behavior is exactly the
same.

(gdb) break 'foo.2043
Can't find member of namespace, class, struct, or union named "foo.2043"
Hint: try 'foo.2043<TAB> or 'foo.2043<ESC-?>
(Note leading single quote.)
Make breakpoint pending on future shared library load? (y or [n]) 

> Also, I think this is an LTO bug.  It seems to me that it should emit
> debuginfo naming the symbol as "foo".

Shall I report it to gcc bugtracker then?

I was wondering if this was simply a bug and if there was not a reason for this
naming.

In gcc man page about -flto, there is :
Link time optimization does not play well with generating debugging
information.  Combining -flto or -fwhopr with -g is experimental.

Without -flto, I don't need to build with -g to get symbol names, I can break
on any functions.
I only need -g if I want to get the source, see the parameters of functions,
etc.
So I wonder if this warning message captures the 'foo.2043' problem.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

end of thread, other threads:[~2010-11-20  9:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-23 14:51 [Bug breakpoints/12156] New: cannot break on static functions with gcc flto (link time optimization) chantry.xavier at gmail dot com
2010-11-15 17:11 ` [Bug breakpoints/12156] " tromey at redhat dot com
2010-11-21 18:08 ` chantry.xavier at gmail 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).