This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] dwarf2_physname


On 09/01/2009 03:11 PM, Daniel Jacobowitz wrote:
I assume this patch is a distant descendant of the one I sent you a
while back.  Is its goal to create a useful name for each symbol, or
to match the one produced by some other source - probably the
demangler?  What sort of template cases have you looked at?

Yes, this is based on the patches you sent me a long, long time ago. The goal is to generate a physname that is unique; it may match the output of the demangler, but that is not a requirement. It is supposed to construct valid, fully-qualified names, i.e, you won't see "std::string" as a physname. It's really "std::basic_string<blah blah blah>".


The template cases I've looked at are checked-in on the archer-keiths-realcpp-test branch. I've just committed the latest and greatest version of realcpp.{exp,cc} here: http://tinyurl.com/lkaadh (git.sourceware.org -- sorry for the tinyurl thing, git URL names are loooooooong).

Unfortunately, I cannot speak to other compilers, only gcc.

Here's one case I remember having trouble with.

template<char *S>  int f()
{
   return S[0];
}

char Foo[3];
char Bar[3];

int main()
{
   return f<Foo>() + f<Bar>();
}

What do you want to do with this? Print it and break/list it?


On my archer-keiths-expr-cumulative branch (which does NOT use linkage_name):

(gdb) info func f
All functions matching regular expression "f":

File a.cc:
int f<(char*)(&Bar)>();
int f<(char*)(&Foo)>();

Non-debugging symbols:
0x08048420  frame_dummy
0x08048490  __libc_csu_fini
0x0804852c  _fini
(gdb) p f<(char*)(&Foo)>
$1 = {int (void)} 0x8048465 <f<(char*)(&Foo)>()>
(gdb) list 'f<(char*)(&Foo)>'
1	template<char *S> int f()
2	{
3	  return S[0];
4	}
5	
6	char Foo[3];
7	char Bar[3];
8	
9	int main()
10	{
(gdb) b 'f<(char*)(&Foo)>'
Breakpoint 1 at 0x8048468: file a.cc, line 3.
(gdb) r
Starting program: /home/keiths/tmp/a

Breakpoint 1, f<(char*)(&Foo)> () at a.cc:3
3	  return S[0];
(gdb) bt
#0  f<(char*)(&Foo)> () at a.cc:3
#1  0x08048453 in main () at a.cc:11
(gdb)

I know that "f<(char*)(&Foo)>" is ugly, but that is the name that gcc gives us (DW_AT_name for this DIE), so we have to use it. [I am assuming we could get this cleaned up/"fixed" in gcc.]

On FSF gdb HEAD, you can do something similar with "int f<&Foo>" (yes, you *have* to add the return type) instead of "f<(char*)(&Foo)>"...

Keith


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]