필터 지우기
필터 지우기

How to debug MEX-files in Eclipse compiled with MinGW64 and -g flags in MATLAB R2017a and earlier

조회 수: 27 (최근 30일)
How to debug MEX-files in Eclipse compiled with MinGW64 and -g flags in MATLAB R2017a and earlier?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2024년 4월 15일
편집: MathWorks Support Team 2024년 4월 15일
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개)

Community Treasure Hunt

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

Start Hunting!

Translated by