Debug C++ patches

Hi,

Is there a way to debug C++ patches?
Assuming I already have an IDE configured with a JTAG probe.

You can access the SWD pins on the owl digital board.
I use st-util [1] and a gdb session to debug with SWD, works quite well.
However debugging dynamic patches is more complicated, since you’ve got two binaries.

[1] https://github.com/texane/stlink

Yes, that was what I meant. So the firmware is basically a bootloader for the patches, right?
I suppose that in order to debug a patch, you have to debug the firmware with a hardcoded patch. Would it work?

I’m writing a granular effect and I’m having a lot of trouble without a debugger.

"So the firmware is basically a bootloader for the patches, right?"
Not exactly: all the interrupts reside in the firmware, which hands over control to the dynamic patch every time a block is processed.

And yes you can avoid all that by compiling your patch into the firmware. Simply edit factory.h and factory.cpp. For debugging, I would strip it down to just the Gain patch and your patch.

On the issue of debugging I should also mention that, using dynamic patches, you can send debug messages very easily to OwlControl.

Call any of these functions from anywhere in your code:


void debugMessage(const char* msg);
void debugMessage(const char* msg, int);
void debugMessage(const char* msg, int, int);
void debugMessage(const char* msg, int, int, int);
void debugMessage(const char* msg, float);
void debugMessage(const char* msg, float, float);
void debugMessage(const char* msg, float, float, float);

There’s float Patch::getElapsedBlockTime() and int Patch::getElapsedCycles() to help you pinpoint performance bottlenecks.

And a fairly standard ASSERT(cond, msg). Typical use:


  ASSERT(size >= offset+length, "Array too small");

Note that only the most recent message will be picked up by OwlControl, which polls the device every few seconds.

Thanks! I have my JLink hooked to the OWL.

I’ve been looking at the firmware and I see now why I couldn’t receive note on messages within the patch. What would I need to add this functionality? For what I see it could be just implementing the handler on MidiHandler class saving the necessary values on ProgramVector and implementing a function to retrieve those values on PatchController in the patch side.

Would that be right?

That sounds about right.
Though if you want to handle polyphony you will need a message queue or circular buffer.
ProgramVector is used to communicate between the main firmware and the patch. If you are planning to stick with static patch compilation then you could access the MidiHandler directly.