Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* 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

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