Exemplo n.º 1
0
static TA_RetCode freeListAndElement( TA_Libc *libHandle, TA_List *list, TA_RetCode (*freeFunc)( TA_Libc *libHandle, void *toBeFreed ) )
{
   TA_PROLOG;
   TA_RetCode retCode;
   void *node;

   TA_TRACE_BEGIN( libHandle, freeListAndElement );

   if( list != NULL )
   {
      while( (node = TA_ListRemoveTail( list )) != NULL )
      {
         retCode = freeFunc( libHandle, node );
         if( retCode != TA_SUCCESS )
         {
            TA_FATAL( libHandle, NULL, node, retCode );
            TA_TRACE_RETURN( TA_ALLOC_ERR );
         }
      }

      retCode = TA_ListFree( list );
      if( retCode != TA_SUCCESS )
      {
         TA_FATAL( libHandle, NULL, list, retCode );
         TA_TRACE_RETURN( TA_ALLOC_ERR );
      }
   }

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemplo n.º 2
0
void TA_PrivTraceBegin( const char *funcname,
                        const char *filename, 
                        unsigned int lineNb )
{
   #if defined( TA_DEBUG) && defined( TA_SINGLE_THREAD )
   unsigned int newTracePositionNeeded; /* Boolean */
   TA_TracePosition *tracePosition;
   TA_TraceGlobal *global;
   TA_RetCode retCode;
   #endif

   /* Entry point of a function are "checkpoint" for code
    * coverage.
    */
   TA_PrivTraceCheckpoint( funcname, filename, lineNb );

   /* If debugging a single thread, maintain a call stack. */
   #if defined( TA_DEBUG ) && defined( TA_SINGLE_THREAD )
      if( TA_IsTraceEnabled() )
      {
         /* Disable tracing within tracing! */
         TA_TraceDisable();

         /* Get access to the global. */
         retCode = TA_GetGlobal( &TA_TraceGlobalControl, (void **)&global );
         if( retCode != TA_SUCCESS )
            return;

         tracePosition = TA_ListRemoveTail( global->callStack );
         newTracePositionNeeded = 1;
         if( tracePosition )
         {
             /* Check if last trace in the stack is the same function. */
             if( (tracePosition->filename == filename) &&
                 (tracePosition->funcname == funcname) )
            {
               /* Same fucntion, so just increment the repetition. */
               tracePosition->repetition++;
               newTracePositionNeeded = 0;
            }
            else /* Not the same function, put back this trace. */
               TA_ListAddTail( global->callStack, tracePosition );
         }

         /* New function, so add the trace to the stack. */
         if( newTracePositionNeeded )
         {
            tracePosition = newTracePosition( funcname, filename, lineNb );
            if( tracePosition )      
               TA_ListAddTail( global->callStack, (void *)tracePosition );
         }

         /* Re-enable tracing. */
         TA_TraceDisable();
      }
   #endif
}
Exemplo n.º 3
0
TA_RetCode TA_PrivTraceReturn( const char *funcname,
                               const char *filename,
                               unsigned int lineNb,
                               TA_RetCode retCode )
{
   #if defined( TA_SINGLE_THREAD )
   TA_TracePosition *tracePosition;
   TA_TraceGlobal *global;
   TA_RetCode localRetCode;
   #endif

   TA_PrivTraceCheckpoint( funcname, filename, lineNb );

   /* If debugging a single threaded, maintain a calling stack. */
   #if defined( TA_DEBUG ) && defined( TA_SINGLE_THREAD )
      if( !TA_IsTraceEnabled() )
      {
         /* Disable tracing within tracing! */
         TA_TraceDisable();

         /* Get access to the global. */
         localRetCode = TA_GetGlobal(  &TA_TraceGlobalControl, (void **)&global );
         if( localRetCode != TA_SUCCESS )
            return retCode;

         tracePosition = TA_ListRemoveTail( global->callStack );

         if( tracePosition )
         {
            --tracePosition->repetition;
            if( tracePosition->repetition == 0 )
               TA_Free(  tracePosition );
            else
               TA_ListAddTail( global->callStack, tracePosition );
         }

         TA_TraceEnable();
      }
   #endif

	return retCode;
}