This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch 1/3] Template Lookup
- From: Tom Tromey <tromey at redhat dot com>
- To: sami wagiaalla <swagiaal at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 31 Aug 2010 16:05:40 -0600
- Subject: Re: [patch 1/3] Template Lookup
- References: <4C446F1C.60507@redhat.com> <4C460A3E.2040004@redhat.com> <m3pqxfa934.fsf@fleche.redhat.com> <4C7690B4.7020504@redhat.com>
>>>>> "Sami" == sami wagiaalla <swagiaal@redhat.com> writes:
Sami> Hmm.. can you give me an example of this ? I tried to construct an
Sami> example with an extern function but I learned that cplus does not
Sami> allow extern template functions.
Ordinarily, to make a test involving psymtab expansion, you have to make
two compilation units.
Put this into one file:
template<typename T> double f (T x) { return x; }
int g (void)
{
return f(1.0) + f(2);
}
Put this in another file:
extern int g(void);
int main()
{
return g();
}
Compile, debug, and "start".
Now in main:
(gdb) p f(1.0)
No symbol "f" in current context.
(gdb) p f<double>(1.0)
$1 = 1
... but if you step into g, it works:
(gdb) s
g () at q1.cc:5
5 return f(1.0) + f(2);
(gdb) p f(1.0)
$2 = 1
Tom> There are a couple instances of this that have to be updated in light of
Tom> Doug's recent change to how this is done.
Sami> What is the change that Doug made ?
He added various set_lang_ functions.
Maybe I'm mistaken about the need for this, as there doesn't seem to be
a special function for C++.
Tom