views:

62

answers:

1

I am trying to find out how to enable (& use) Borland's WARN & TRACE macros.

My starting point was this link: http://bcbjournal.org/articles/vol2/9809/Debugging_with_diagnostic_macros.htm?PHPSESSID=37bf58851bfeb5c199d1af31d7b2e7ff

However, that appears to be for BCB5, and not the 2006 Borland Developer Studio.

  • I've set the two defines (__WARN & __TRACE)
  • I've included the .h file ()
  • I've added some macros, and everything compiles & links fine.

But when I run the application (in DEBUG mode), no debug output file is created.

What am I missing here?

A: 

I was investigating this debug TRACE feature too since I use Borland's toolchain. A couple things I noted while I was figure this out.

  • Make sure __TRACE and __WARN are define before #include <checks.h>. You can also remove the #define __TRACE and __WARN from the translation unit and instead pass it to bcc32 using the -D macroname option during compilation.
  • _GetDiagGroupDef is unresolved for BDS2006. It seems the compiler toolchain that comes with BDS2006 and later seems to be missing some function and class implementation that checks.h uses -- in particular _GetDiagGroupDef. I get unresolved references from the linker when compiling a test sample that uses checks.h. This doesn't happen when I use BCB 5.5.1 btw. Using grep/findstr it appears checks.cpp is compiled into the runtime library of BCB5.5.1 but it's missing from BDS2006 toolchain. I'm surprised you didn't run into the same problem, perhaps I didn't install some components. I found a copy of checks.cpp from an older borland toolchain here. Compiling and linking that should fix the unresolved errors.
  • The tutorial says that the outdbg1.txt is a temporary file and it only shows up in the borland IDE -- for that file to actually exist you must save it. This suggest to me that their TRACE/WARN Macros doesn't actually output a debug file. It's probably outputting the debug info to a stderr stream.

If that's really the case then redirecting the stderr stream to a file should give what you're looking for. Compile your sample program, then run it with something like this:

myprogram.exe 2> outdbg1.txt

All in all, you'll probably want to find alternative tools to aid you in the debugging process. Unfortunately, the TRACE & WARN macros provided here are poorly documented and for later versions of borland/embarcadero's toolchain it doesn't even work properly because the rtl doesn't have the needed functions/classes compiled into it. As such, the following is worth investigating:

  1. OutputDebugString API. This has the advantage that any monitor program that uses this API can receive debug message strings from your program that's being debugged.
  2. xUnit Testing Framework. Google Test is worth checking out.
  3. and of course your standard integrated IDE debugger :P
Victor T.