How do I debug an external with Xcode 3.2?

aengus's icon

Hi,

Can someone tell me how to debug a Max 5 external in Xcode 3.2?

Thanks,

Aengus.

Emmanuel Jourdan's icon

It's pretty straightforward. From the SDK

• Make a patch with your object and messages to test it (object can be bogus)
• Set MaxMSP Runtime to be executable for your object (this is saved locally)
• Build and Debug
• Set breakpoint in your object

the only thing is that you have to make a patch before, because you can't debug with Max directly (because of the copy protection).

HTH,

aengus's icon

Thanks for that. So do you have to set a breakpoint to see meaningful code while the debugging? Or can you just wait until your external crashes? (this is why I'm debugging!)

Emmanuel Jourdan's icon

well, it probably depends. I bet the reason why you're debug is that you suspect that it's going to crash. If you have some steps to make it crash you'll get the stack for each thread before crashing so it might help you to figure something out.

Monami's icon

If I may add some of my tips...

In my experience so that any breakpoint get trigger you need one in the main, if not the debugger seems to ignore all breakpoint.

And to save the time of always coping your newly build external to the max 5 folder, I suggest making a symbolik link in the sdk-install folder that point somewhere in the max 5 folder and change the maxmspsdk.xconfig to
INSTALL_PATH = /

The next thing I would like to know how, don't know if you know it Emmanuel is it possible to setup the MaxRuntime and send it arguments so that it load the debbug patch on launch...

thanks
Mani

Carlos Guedes's icon

Hi, this may seem a dumb question: How do you "build and debug" in XCode? I've tried to do that command (Build->Build and Debug) and that option is shaded in the menu... so nothing happens. THanks,
Carlos

AlexHarker's icon

@Monami - you shouldn't need to put a breakpoint in main() if you don't need it - I've never had to do that to get breakpoints to work.

@Carlos Guedes - you need to set up an executable to debug with (MaxMSP Runtime), as you are not making an application, so you need to tell XCode what application to use for debugging.

You need to go to Project->New Custom Executable

select MaxMSP Runtime from your apps folder.
Now you should be able to use Build->Debug, but you'll need a patch (as mentioned above), and also need to make sure that your external gets into your search path somehow before you load the patch (also mentioned above).

Regard,

Alex

Carlos Guedes's icon

Thanks a lot!

Monami's icon

@AlexHarker - I know you should be right... but it actually depends... I am using OO classses really similar to the c++ template of Wakefield and somehow if for example I place a breakpoint in the constructor of my object It never stop there... I even log to the ,ax window to be sure the program pass there and it does. But I discovered that if I put a breakpoint somewhere else like in the main that I know will be hit then I can move to the next breakpoint...

I don't understand it. At first I tought it was because it was the api that was calling the function but I was wrong since it stop at a breakpoint I have put in the create function that you pass to class_new. That same create function is calling the placement new of my object but any breakpoint in the constructor of the object won't be hit unless an other breakpoint was hit before...

that's my story :)

Mani

Timothy Place's icon

Xcode provides the opportunity to help get you warmed-up for debugging by providing you with a bunch of bugs for free. One of them is that it doesn't always pick up your breakpoints when you launch the executable.

When debugging, particularly with the Runtime, I find that I often need to remove a break-point and re-add it (after the runtime has loaded my external) in order for Xcode to actually break on the breakpoint. It's all just part of the game ;-).

martinrobinson's icon

@Monami - if you trying to set a breakpoint in a c++ .h file (which if you're using templates is likely, I suspect) - you might need to switch off "Load symbols lazily" in Xcode preferences -> Debugging.

babazaroni's icon

I believe David Z. wrote a tutorial on debugging with xcode.

Does anyone have a link to it on the cycling 74 site?

Thanks