Connecting Debug to the MATLAB Process - 2020.2 English

Model Composer and System Generator User Guide (UG1483)

Document ID
UG1483
Release Date
2020-11-18
Version
2020.2 English
With the breakpoint established, you can link GDB to the MATLABĀ® process by using the GDB attach command, and specifying the process ID (PID) returned by the xmcImportFunctionSettings command when you set up the debug build mode, as previously discussed. Use the following command:
(gdb) attach <PID>
Important: After it is attached to GDB, the MATLAB process will be suspended. You must use the continue command to have the process resume running after the gdb prompt is returned:
(gdb) continue

At this point you are ready to start the SimulinkĀ® simulation, and begin debugging your design.

When using Visual Studio, you can launch the application, and then select Debug > Attach to Process command to attach to the MATLAB process. This command opens an Attach to Process dialog box that lets you select the MATLAB process from the list of running processes, to attach to the Visual Studio debugging session.

Figure 1. Visual Studio - Attach to Process
Important: When attaching Visual Studio to the MATLAB process, you must also click Select to set the Attach to field, and explicitly choose Native Code from the drop down menu. The Automatic:Native mode option may not work for some versions of Visual Studio.