From: Anton MOUKHARSKI <anton.moukharski@cea.fr>
To: gdb@sourceware.org
Subject: Breakpoint not hit because of function pointers or something similar
Date: Tue, 04 May 2010 13:23:00 -0000 [thread overview]
Message-ID: <4BE01FC1.8050309@cea.fr> (raw)
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
next reply other threads:[~2010-05-04 13:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-04 13:23 Anton MOUKHARSKI [this message]
2010-05-10 19:27 ` Tom Tromey
[not found] ` <4BE9232A.40904@cea.fr>
2010-05-11 18:59 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BE01FC1.8050309@cea.fr \
--to=anton.moukharski@cea.fr \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox