How can one debug mex code called by fminsearch?

10 vues (au cours des 30 derniers jours)
Pierre
Pierre le 18 Sep 2023
Modifié(e) : Pierre le 21 Sep 2023
On Windows or MacOS, I've never been able to debug a mex file without disabling Java with the option -nojvm. Otherwise I always get segmentation violation errors or bad access exceptions from Java code (a dog's breakfast, clearly) that my debugger catches.
Up to now this worked for my needs, with the minor annoyance of having to shut off all graphical output.
Now I'm trying to debug a mex code called by fminsearch. This function can use an option 'Display' 'off' (or 'none"). You'd have thought that it would play nice with -nojvm but not at all, its still insists on calling some graphics even without any need, and matlab stops with:
Error in callAllOptimPlotFcns (line 64)
fig = figure('visible','off');
Unrecognized function or variable 'Error'.
What am I supposed to do now (apart from banging my head on a wall)?
Thanks for the help.
  1 commentaire
Pierre
Pierre le 21 Sep 2023
Modifié(e) : Pierre le 21 Sep 2023
Actually this error was caused by a previous line specifying a value for 'PlotFcns'. If this is nonempty, even with 'Display' set to 'off' (or equivalently, 'none'), Matlab will make a call to Java graphics. If fminsearch options' 'PlotFcns' is [] (the default) and 'Display' is 'off', it is indeed possible to run fminsearch with -nojvm.
This leaves open the question how you can debug Matlab on MacOS with Java activated. At this hour I haven't found a way.

Connectez-vous pour commenter.

Réponses (1)

Steven Lord
Steven Lord le 18 Sep 2023
What happened after you handled the SIGSEGV and SIGBUS signals as described in the last section, "Debug MEX with JVM", on this documentation page? Were you able to debug your MEX-file on Mac with the JVM successfully after that?
  1 commentaire
Pierre
Pierre le 18 Sep 2023
Modifié(e) : Pierre le 18 Sep 2023
Actually, on MacOS, my current platform, I can deal with SIGBUS and SIGSEGV. But that's not the end of it: EXC_BAD_ACCESS exceptions still mess up everything. LLDB gets indefinitely stuck on those.
I tried "settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_ACCESS" in LLDB but, to my disappointment, it didn't change a thing: LLDB still can't get past such an exception in the Java 2D queue flusher.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by