This is the mail archive of the gdb@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: how to view content in stl vector


Am Montag, 18. Juni 2007 14:36:50 schrieb Daniel Jacobowitz:
> On Mon, Jun 18, 2007 at 02:26:36PM +0200, Maik Beckmann wrote:
> > Is storing of typenames possible at all?
>
> No.  GDB's command line scripting language does not support this sort
> of thing.  My plan is a more sophisticated Python integration.
>
> > A workaround for this would be a native c++ map-dump function, which
> > naturally would be implemented as function template, but I didn't find
> > out how to call an instantiated function template  :(
>
> It should work just fine.... I don't know for sure though.

This is an example:

source:
 - main.cpp 
 - Foo.h 
 - Foo.cpp

<main.cpp>
call foo(i)
No symbol "foo" in current context.
call bar(i)
$1 = true
</main.cpp>

<Foo.h>
#ifndef FOO_H_
#define FOO_H_

template<typename T>
bool foo(T val);

bool bar(int val);

#endif /*FOO_H_*/

</Foo.h>

<Foo.cpp>
#include "Foo.h"
#include <iostream>


template<typename T>
bool foo(T val)
{
    std::cout << "Hello from foo" << std::endl;

    return true;
}

template bool foo(int); // instantiates foo<int>(int)

bool bar(int val)
{
    std::cout << "Hello from bar" << std::endl;

    return true;
}
</Foo.cpp>

gdb says
<gdb>
call foo(i) # the template function
No symbol "foo" in current context.
call bar(i)
$1 = true
<gdb>


MfG, Maik


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