[KinoSearch] DEBUG() and ASSERT()

Marvin Humphrey marvin at rectangular.com
Mon Oct 15 23:15:26 PDT 2007




On Oct 15, 2007, at 7:13 PM, Nathan Kurz wrote:

> All looks good to me at a cursory viewing.  Well done on making it
> conform to the KinoSearch standard while keeping the API.

Cool, thankee.  :)

> I vaguely recall that there was some reason I had used multiple  
> static functions
> defined in the Debug.h file, but for this project what you did seems
> better.

There can certainly be good reasons to do that.  For example, in the  
current Debug.h, compilers without support for variadic macros (e.g.  
MSVC) get statically declared functions no-op functions to hopefully  
optimize away:

   static void KINO_DEBUG_PRINT(char *_ignore_me, ...) { }

However, I didn't see anything like that in the Debug.h you sent  
along.  Maybe it was there at one time but it's gone now.

> I think the advantage of relying on an environment variable is that
> you can use the same executable for debug and live on a server.

You can fake that up in your own app like so:

   BEGIN {
     if ( $ENV{MYAPP_DEBUG} ) {
       eval 'use KinoSearch "DEBUG";'
       die $@ if $@;
     }
   }
   use KinoSearch::Searcher;
   ...

>> I don't suppose we could get full C stack traces happenin', could we?
>
> Not sure if I understand where you want this.   For a
> die_with_stacktrace() function that could be called from the C
> library?  Seems possible, if we don't mind that it is gcc specific.

Right now, the CONFESS macro triggers a call to Carp::confess, which  
includes the Perl stack trace... but not the C stack trace.  All it  
shows from C is the final error message, with file, line, function  
when the compiler supports variadic macros.  There are often several  
layers in the C stack which are not shown.  It would sure be handy to  
include the C stack trace...

Unfortunately, looking into this more closely, I see that support for  
execinfo.h is not widespread.

   http://lists.apple.com/archives/Xcode-users/2006/Apr/msg00483.html

Probably best to back-burner the idea.

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/



_______________________________________________
KinoSearch mailing list
KinoSearch at rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch




More information about the kinosearch mailing list