필터 지우기
필터 지우기

How can one debug mex code called by fminsearch?

조회 수: 3 (최근 30일)
Pierre
Pierre 2023년 9월 18일
편집: Pierre 2023년 9월 21일
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
Pierre
Pierre 2023년 9월 21일
편집: Pierre 2023년 9월 21일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2023년 9월 18일
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
Pierre
Pierre 2023년 9월 18일
편집: Pierre 2023년 9월 18일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by