Précédent   Forum du club des développeurs et IT Pro > C et C++ > Outils pour C & C++ > GDB
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 10/05/2010, 18h37   #1
Kharski
Invité de passage
 
Inscription : août 2008
Messages : 5
Détails du profil
Informations forums :
Inscription : août 2008
Messages : 5
Points : 0
Points : 0
Par défaut point d'arrêt non-atteint sûrement à cause de pointeurs de fonction

Bonjour,
j'essaye d'atteindre un point d'arrêt situé assez tôt dans mon code, mais je n'y arrive pas. Je pensais que gdb ne se débrouillait pas avec les templates C++ mais ça a l'air d'aller, je pense donc que c'est un problème de pointeurs de fonction. En effet le nom de la fonction à exécuter (ici "doit") est déterminée à l'exécution. Extraits de code :

Code :
1
2
3
4
5
6
int main(int argc,const char **argv)
{
   ABM proc(params...);
   proc.execute(fileinr);
   return EXIT_SUCCESS;
}
Ici l'endroit où j'ai mon point d'arrêt :

Code :
1
2
3
4
5
6
template <class T>
bool doit( Process & process, const string & fileinr, Finder & )
{
    //stuff
    return(1);
}
Le lien entre les deux : ABM est un fils de Process, et son unique constructeur comporte :

Code :
1
2
3
4
5
6
7
8
9
10
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> );
"" de Process est défini comme suit :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 ) );
}

Donc enfin la question : comment placer correctement mon point d'arrêt, puissque la méthode "breakpoint cheminSource/nomSource.extensionSource:numeroDeLigne" ne marche pas dans ce cas-ci. Je suis pour l'instant obligé de faire du pas à pas, ce qui combiné à du parallélisme est très très vite lassant... problème assez classique mais je n'ai rien trouvé sur le net!

D'avance merci,
AM
Kharski est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 15h48.


 
 
 
 
Partenaires

Hébergement Web