Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* info functions bug?
@ 2007-08-21 11:32 Andrew STUBBS
  2007-08-21 12:04 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew STUBBS @ 2007-08-21 11:32 UTC (permalink / raw)
  To: GDB List

Hi,

There seems to be a problem with 'info functions'. It prints the return 
type of template functions twice.

Here's some example code:


template <typename TT>
TT& max(TT& a, TT& b)
{
   return (a>b ? a : b);
}

int
main()
{
   int a = 1, b = 2;
   float c = 1.1, d = 2.2;
   max(a,b);
   max(c,d);
   return 0;
}


This is correctly interpreted by nm and c++filt as follows:


$ nm -C a.out | grep max
88001878 W float& max<float>(float&, float&)
88001830 W int& max<int>(int&, int&)


But GDB gives a slightly different name:


(gdb) info functions max
All functions matching regular expression "max":

File t.cpp:
float &float& max<float>(float&, float&);
int &int& max<int>(int&, int&);


This name is not accepted when setting a breakpoint, but remove the 
extra return type and all is well:


(gdb) b float &float& max<float>(float&, float&)
Function "float &float& max<float>(float&, float&)" not defined.
(gdb) b float& max<float>(float&, float&)
Breakpoint 2 at 0x8800188a: file t.cpp, line 4.


(Irritatingly, 'break max' doesn't work - it doesn't even prompt.)

Presumably this is not the intended output for this type of function?

Andrew


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

* Re: info functions bug?
  2007-08-21 11:32 info functions bug? Andrew STUBBS
@ 2007-08-21 12:04 ` Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2007-08-21 12:04 UTC (permalink / raw)
  To: Andrew STUBBS; +Cc: GDB List

On Tue, Aug 21, 2007 at 12:31:53PM +0100, Andrew STUBBS wrote:
> Hi,
> 
> There seems to be a problem with 'info functions'. It prints the return type of 
> template functions twice.

Yes, this is a known problem with handling of template functions.
It's related to all the things we were talking about yesterday.
It comes from the demangled name differences: template mangled names
include the return type, non-template C++ mangled names do not.

My patches (rather bit-rotten now I'm afraid) to avoid relying on
mangled names improved the situation a bit.  I don't think there's
an easier way though :-(

-- 
Daniel Jacobowitz
CodeSourcery


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

end of thread, other threads:[~2007-08-21 12:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-21 11:32 info functions bug? Andrew STUBBS
2007-08-21 12:04 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox