On Mon, 01 Feb 2010, Xavi wrote:

Hi,

> HB_TRACEFM(), with my next commit. I'm waiting for Przemek and others
> are ready. ;)

Can you send .diff file here so we can check what exactly this
modification does?

> >Is there a macro I can use to identify this sub-function? I could leave
> >it in the code wrapped conditional code for debug only.
> Yes if you have a C99 compiler, just have to redefine the macro in your code 
> .-
> #ifdef HB_TRACEFM
> #  undef  HB_TRACEFM
> #  define HB_TRACEFM( x )  hb_fm_xInfoEx( #x, __FILE__, __LINE__, __func__ ); 
> x
> #endif

We do not have hb_fm_xInfoEx() in our code so I guess it's part of
modifications you want to commit. __func__ is C99 macro. It makes
log more readable but __FILE__ + __LINE__ is enough to detect exact
place and function name if you have source code so it's not critical
information. For current unmodified code requested functionality
(without function name) can be reached by:
   extern HB_EXPORT void * hb_xgrab_fm( ULONG ulSize,
                                        const char * szFile, int iLine );
   [...]
   void * hb_xgrab_fm( ULONG ulSize, const char * szFile, int iLine )
   {
      hb_tr_file_ = szFile;
      hb_tr_line_ = iLine;
      return hb_xgrab( szFile );
   }

   #if HB_TR_LEVEL >= HB_TR_DEBUG
      #define HB_XGRABFM( n )    hb_xgrab_fm( n, __FILE__, __SIZE__ )
   #else
      #define HB_XGRABFM( n )    hb_xgrab( n )
   #endif

with most of C compilers the same effect can be reached using only
macros without hb_xgrab_fm() function, i.e.:

   #if HB_TR_LEVEL >= HB_TR_DEBUG
      #define HB_XGRABFM( n )    ( hb_tr_file_ = __FILE__, \
                                   hb_tr_line_ = __LINE__, \
                                   hb_xgrab( n ) )
   #else
      #define HB_XGRABFM( n )    hb_xgrab( n )
   #endif

If user wants does not want to set HB_TR_LEVEL=DEBUG then the
above macro can be extend to dynamically change and restore
debug level, i.e.:

   #if HB_TR_LEVEL >= HB_TR_DEBUG
      #define HB_XGRABFM( n )    { int iLevel = hb_tracelevel( HB_TR_DEBUG ); \
                                   void * ptr; \
                                   hb_tr_file_ = __FILE__; \
                                   hb_tr_line_ = __LINE__; \
                                   ptr = hb_xgrab( n ); \
                                   hb_tracelevel( iLevel ); \
                                   ( void ) ptr; }
   #else
      #define HB_XGRABFM( n )    hb_xgrab( n )
   #endif

anyhow such version can be compiled only by few C compilers, i.e. by GCC.
To make it simpler we can change a little bit fm.c and HB_TRACE_STEALTH()
macro so user can use the first version independently to HB_TR_LEVEL setting.
BTW such modifications in HB_TRACE_STEALTH() macro should be done also to
fix yet another problem in current code so I'll commit them ASAP.

best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to