Re: Debugger doesn't stop in template method?
Re: Debugger doesn't stop in template method?
- Subject: Re: Debugger doesn't stop in template method?
- From: Jim Ingham <email@hidden>
- Date: Wed, 14 Jan 2004 10:04:30 -0800
Jim,
There are several things that could cause this. The most likely is
that gdb currently has the assumption that there is a 1 to 1 mapping
from source lines into code. So if you have two instantiations of this
template, gdb is going to set the breakpoint on the first one it finds
and stops there. That is not likely to work well when you have
templates.
We know we need to fix this. The naive solution of exhaustively
searching all the line number records for this file & line combination
is inefficient, however. We don't want to do that for every
breakpoint we set - in a big app with lots of code, this would get
pretty time consuming. It would be better if the debug info would tell
us when there are entities (templates, inlined methods, etc) which
break this assumption, and even better, where all the instantiations
got put.
There are two ways to work around this. One is to use the "rbreak"
command in the gdb console. This command will set a breakpoint on all
symbols that match a given regular expression. So if you use Foo.*Bar
or something like that will get all the instances of the template. The
caveat with this is that rbreak only searches in the code that is
loaded at the time you issue the command. So if you are using ZeroLink
or if the code is in a shared library, you have to make sure the code
is loaded before you call rbreak.
The other way is to break on the symbol for the code explicitly. You
can use either the C++ specialized form (though I have had cases where
gdb's expression parser chokes on complex template forms, so this
doesn't always work) or on the mangled form (which you can get by
running nm on a .o file that contains the specialization, and then by
inspection you can usually pick out the one you want. You can then run
it back through cxxfilt or gdb's "maint demangle" command to be sure...
Jim
On Jan 13, 2004, at 2:03 PM, Jim Correia wrote:
I have a template class.
template<class T>
OSErr Foo<T>::Bar(Baz<T> &aBaz)
{
char *str = nil;
doSomething();
doSomethingElse();
}
If I set a breakpoint inside that function the debugger doesn't stop.
(It doesn't warn me in the console that it couldn't set the breakpoint
either.)
The file does have debug info - if I stop in doSomething I can step
until it exits and back up into Foo::Bar.
Is this a known problem? Is there a workaround? (Do I need to build a
sample project that shows the problem and write up a radar issue?)
Thanks,
Jim
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.
--
Jim Ingham email@hidden
Developer Tools
Apple Computer
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.