Debugging things that work in the Plugin Host, but break in a DAW

I’m running Ubuntu and I find that my plugin works well in the Plugin Host, but when I run it in Ardour or Bitwig, it blows up as soon as I open the GUI. What do I do?

I’m toying with logging to a file, but the logging thread gets killed when the plugin dies and doesn’t give me complete logs. How do the pros debug this?
EDIT: I am finding this to be useful.

Hi. For most hosts you should be able to set the host executable as the program to execute for the debugger session. Alternatively, when the host is running you’ll be able to attach the debugger to that process and start debugging. I think Bitwig starts plugins in separate processes so make sure you get the correct process (maybe you can turn this off so they run inprocess?)