Dudebbing windows externs in MSVC

Jun 11, 2008 at 5:57am

Dudebbing windows externs in MSVC

Hello,

Could anyone give me a quick outline of how to debug a extern for Max on Windows using MS VC++ Express?

I should probably outline how I get this working on the Mac in case it bears no resemblance to the process on Windows.

I’m familiar with doing this in Xcode by setting the custom executable environment as the MaxMSPRuntime which GDB then attaches to when doing build->debug. Then I usually drag and drop the external I want to debug onto the MaxMSPRuntime. This loads the external and I get any debug messages (in the console output back in Xcode) that I generate in main() using printf() or similar. Finally I load a pre-built patch that tests the extern and again I get any debug messages.

In MSVC I have tried launching MaxMSPRntime then attaching MSVC’s debugger using Debug->Attach…. Then, as on the Mac, I drag and drop the extern and load the pre-built patch. This gives me post() messages in Max but I don’t get any printf() debug messages in the debugger output back in MSVC. I can only assume it’s not attaching correctly.

Any hints?

#38331
Jun 11, 2008 at 8:29pm

i’ve used msvc to debug externals when they cause a crash… there’s that “kill program or debug” message box that pops up, which brings you to another one that allows you to attach an instance of msvc. i’m not sure how to get it to debug without a crash though.
my guess is that stuff like printf wouldn’t really work there anyway… i’m not sure that the debugger connects to the max standard i/o streams, which it would need to do for that stuff to work.
in a worst case scenario, you could just use a log file…

#133423
Jun 12, 2008 at 9:09am

…I just noticed my rather interesting spelling of debugging in the original post… anyway:

Thanks, thezer0ist I guess I’ll need to use a log file unless someone knows how to get similar behaviour to Xcode. I don’t want to use post() since the problem I’m having is in inside some C++ class where I don’t want to include the MaxAPI, ext.h etc.

#133424
Jun 14, 2008 at 11:55am

my approach to that kind of thing has always been a combination of wrapper functions and variadic macros, which allow me to switch the debug output from one method to another simply by changing a single #define statement…

something like…

void _dbg_print_log(const char *fmt, …)
{
print message to log file
}

void _dbg_print_max(const char *fmt, …)
{
print message using post()
}

#ifdef DEBUG_OUT_MAX
#define dbg_print(fmt, …) _dbg_print_max(fmt, __VAR_ARGS)
#else
#define dbg_print(fmt, …) _dbg_print_log(fmt, __VAR_ARGS)
#endif

i’m not sure about the syntax of the macros… i generally end up spending a few minutes looking at reference materials for stuff like __VAR_ARGS (which i’m sure is supposed to be something else)

#133425

You must be logged in to reply to this topic.