Best way to debug a plugin?

Hello,
i try to use a plugin (midi->midi) in ardour. I wrote this plugin in c++ using JUCE. It crashes when i use two instances of the plugin on different tracks.
I put some output messages (cout) in the code of the plugin to find where the problem is, but it seems that the crash occurs not in the plugin but in Ardour. Is there a way to have some debug messages from ardour to help?
I am new with writting plugins, so can i ask please what is the usual common practice to debug plugins?
Thanks a lot,
Frédéric.

PS: the only last message i get before crash is:

(ardour-7.4.0:16480): Gtk-CRITICAL **: 12:03:38.161: gtk_box_pack: assertion 'child->parent == NULL' failed
Erreur de segmentation (core dumped)
faure@admine-XPS-13-9380:~$ ardour-request-device: watched PID no longer exists - releasing device.

Hi Frédéric,

What’s your OS and IDE? Can point you to to some tutorials.

Hi Adam,
thanks for your reply, my OS is Ubuntu 22.04 on linux, and I use Projucer, Linux Makefile. Then i test the plugin with Ardour. To try debug i put some cout<<“messages”<<endl; in my code, and i look in a terminal.

Cool, I would recommend Visual Studio Code for debugging on Linux.

https://forum.juce.com/t/how-to-debug-application-in-linux-vs-code/53974/4r

And if you didn’t already find it…

(though i think that one is in the JUCE docs)

Let me know if you need more help.

1 Like

Thanks. i succeeded to compile and execute. I am using emacs to write the c++ code, compile, etc. The plugin works well on ardour if i use only a single instance of it, and crashes if i use two instances. This is my problem. There are global variables in my plugin, may be the problem comes from there. Do you know if i can use debugger gdb with ardour?

I would expect so! I have not done that myself, though…

I found this page that explains: https://ardour.org/debugging_ardour.html

Avoid using global variables at all cost. This could be the reason your plug-in works with only one instance and starts to behave incorrectly with two. Not global variables themselves of course but what your code is doing with them. Also, did you try to build a simple empty plug-in (or the GainPlugin demo) and see if it works correctly (multiple instances in Ardour) ?

Thank you for this explanation. Yes indeed, i am new with Plugins, and my mistake was to use global variables without care. Now i have checked this, used also ardour with debug mode and everything goes better. Thanks a lot.

1 Like

Glad to hear it. Good luck with your project.