How to debug MEX-files in Eclipse compiled with MinGW64 and -g flags in MATLAB R2017a and earlier
14 views (last 30 days)
Show older comments
MathWorks Support Team
on 1 Sep 2015
Edited: MathWorks Support Team
on 15 Apr 2024
How to debug MEX-files in Eclipse compiled with MinGW64 and -g flags in MATLAB R2017a and earlier?
Accepted Answer
MathWorks Support Team
on 15 Apr 2024
Edited: MathWorks Support Team
on 15 Apr 2024
NOTE: These instructions are valid for debugging with MinGW 4.9.2. For newer versions, please refer to the following link:
Follow the steps below to debug a MEX-file compiled with MingGW64 and the -g flag:
1. Start Eclipse and choose a new workspace.
You can download Eclipse from the following link:
2. In Eclipse, select the following options:
"File" > "New" > "Project"... and select "General" >"Project"
3. Choose a name for your project and click "Finish".
4. Generate a new text file by choosing:
"File" > "New" > "Other"..." and then "General" > "Untitled Text File"
Enter the following in the text file :
handle SIGSEGV nostop
Then save the file as "gdbinit" in "mexdebug" folder as shown in the figure.
5. Drag the C/C++ source code of your MEX-file into the project. When asked to copy or link, choose "Link to file", so that the source codes stay in their original locations.
6. Then go to:
"Run" -> "Debug Configurations..."
And Select "C/C++ Attach to Application" and select the "New" button.
7. On the "Debugger" tab, enter the location of the file created under 4 as "GDB command file".
8. Click "Debug".
9. Select MATLAB.exe from the list.
10. The debugger will suspend MATLAB. Use "Resume" button to continue running MATLAB.
11. Open the C/C++ code in Eclipse and place a breakpoint.
12. Run the MEX-file in MATLAB.
13. When the breakpoint is hit you will stop in the debugger and you can for example step through the code and inspect variables.
0 Comments
More Answers (0)
See Also
Categories
Find more on MATLAB Support for MinGW-w64 C/C++ Compiler in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!