* Breakpoint not hit because of function pointers or something similar
@ 2010-05-04 13:23 Anton MOUKHARSKI
2010-05-10 19:27 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Anton MOUKHARSKI @ 2010-05-04 13:23 UTC (permalink / raw)
To: gdb
Hello,
I am trying to hit a breakpoint that appears early in the code, but gdb
(ddd) misses it each time. At first I thought it was because of
templates, but gdb seems to cope with that. I have a code similar to
this one (C++, don't read it in detail at first) :
int main(int argc,const char **argv)
{
ABM proc(params...);
proc.execute(fileinr);
return EXIT_SUCCESS;
}
And the main code where I want my breakpoint is :
template <class T>
bool doit( Process & process, const string & fileinr, Finder & )
{
//stuff
return(1);
}
The link between the two is somewhere here :
ABM, which is a child of Process, contains the following code in it's
(only) constructor :
registerProcessType( "Volume", "S8", &doit<int8_t> );
registerProcessType( "Volume", "U8", &doit<uint8_t> );
registerProcessType( "Volume", "S16", &doit<int16_t> );
registerProcessType( "Volume", "U16", &doit<uint16_t> );
registerProcessType( "Volume", "S32", &doit<int32_t> );
registerProcessType( "Volume", "U32", &doit<uint32_t> );
registerProcessType( "Volume", "FLOAT", &doit<float> );
registerProcessType( "Volume", "DOUBLE", &doit<double> );
registerProcessType( "Volume", "RGB", &doit<int16_t> );
registerProcessType( "Volume", "RGBA", &doit<int16_t> );
Process' execute function is given below :
bool Process::execute( const string & filename )
{
Finder f;
if( !f.check( filename ) )
{
f.launchException();
throw format_error( filename );
return( false );
}
return( execute( f, filename ) );
}
bool Process::execute( Finder & f, const string & filename )
{
string otype = f.objectType();
string dtype = f.dataType();
map<string, map<string, ProcFunc> >::const_iterator
ip = _execs.find( otype );
if( ip == _execs.end() )
{
throw datatype_format_error( string( "unsupported data type " )
+ otype + " / " + dtype, filename );
return( false );
}
map<string, ProcFunc>::const_iterator ip2 = (*ip).second.find( dtype );
if( ip2 == (*ip).second.end() )
{
// Try alternate data types
vector<string> posstypes = f.possibleDataTypes();
unsigned i, n = posstypes.size();
for( i=0; i<n; ++i )
if( posstypes[i] != dtype )
{
ip2 = (*ip).second.find( posstypes[i] );
if( ip2 != (*ip).second.end() )
{
// force new datatype into finder
f.setDataType( posstypes[i] );
break;
}
}
if( i == n )
{
throw datatype_format_error( string( "unsupported data type " )
+ otype + " / " + dtype, filename );
return( false );
}
}
// execute process function
return( (*ip2).second( *this, filename, f ) );
}
I know I haven't given all usefull code snippets but I'm guessing the
problem is that the choice of which function to execute (here, "doit"),
is only known at execution time ("function pointers").
So is there anyway to tell gdb that I don't wan't a breakpoint relative
to a linenumber in a source file or a simple function name but to the
instance of the right function, or maybe to use brutal memory
addresses.... anyway something to avoid stepping into the code 50000 times.
Any ideas?
Thanks,
If you need more info/I have missed some rules please don't hesitate to ask,
Anton Moukharski
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Breakpoint not hit because of function pointers or something similar
2010-05-04 13:23 Breakpoint not hit because of function pointers or something similar Anton MOUKHARSKI
@ 2010-05-10 19:27 ` Tom Tromey
[not found] ` <4BE9232A.40904@cea.fr>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2010-05-10 19:27 UTC (permalink / raw)
To: Anton MOUKHARSKI; +Cc: gdb
>>>>> "Anton" == Anton MOUKHARSKI <anton.moukharski@cea.fr> writes:
Anton> I am trying to hit a breakpoint that appears early in the code, but
Anton> gdb (ddd) misses it each time. At first I thought it was because of
Anton> templates, but gdb seems to cope with that. I have a code similar to
Anton> this one (C++, don't read it in detail at first) :
It would be helpful if you mentioned your gdb version, your platform,
and exactly what you tried in gdb.
Anton> So is there anyway to tell gdb that I don't wan't a breakpoint
Anton> relative to a linenumber in a source file or a simple function name
Anton> but to the instance of the right function, or maybe to use brutal
Anton> memory addresses.... anyway something to avoid stepping into the code
Anton> 50000 times.
Anton> Any ideas?
You can try putting a breakpoint on the particular template
instantiation you care about. I'm not completely sure this is what
you're asking, though.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Breakpoint not hit because of function pointers or something similar
[not found] ` <4BE9232A.40904@cea.fr>
@ 2010-05-11 18:59 ` Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2010-05-11 18:59 UTC (permalink / raw)
To: Anton MOUKHARSKI; +Cc: gdb
>>>>> "Anton" == Anton MOUKHARSKI <anton.moukharski@cea.fr> writes:
Anton> Platform is Mandriva Linux release 2008.0 (Official) for i586 Kernel
Anton> 2.6.22.19-desktop-2mdv. Gdb version is GNU gdb 6.6-3.1mdv2008.0 (Mandriva
Anton> Linux release 2008.0).
6.6 is rather old. I would suggest upgrading first.
Anton> Again, the problem seems to be that the function in which I put
Anton> my breakpoint is called via a function-pointer (ip2 in the code
Anton> below); the function which is called below the call of
Anton> "process.execute()" is determined at execution time.
We will need a small, self-contained example showing the problem.
To my knowledge, gdb does not get confused if functions are called via
pointers. That works just fine when I am debugging gdb itself, for
instance.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-11 18:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-04 13:23 Breakpoint not hit because of function pointers or something similar Anton MOUKHARSKI
2010-05-10 19:27 ` Tom Tromey
[not found] ` <4BE9232A.40904@cea.fr>
2010-05-11 18:59 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox