Mex Debugging with VS Code

54 次查看(过去 30 天)
Samuel Mason
Samuel Mason 2018-10-22
编辑: Lipi Vora 2018-10-24
Trying to setup debugging of mex files through vs-code, following this tutorial. After compiling the mex file via
mex -g ${files}.cpp -L${linkedfiles.lib}
and attaching the debugger to MATLAB's process, this warning is shown at the top of the debug console within VS Code:
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
followed with (after many [New Thread xxxx.xxxx]]:
0x00007ffef41bd8c1 in ntdll!DbgBreakPoint () from C:\WINDOWS\SYSTEM32\ntdll.dll
The debugger also shows that any breakpoints added are "unverified", and when running the compiled mex file, any breakpoints are ignored.
All compiled files and VS Code workspace are in MATLAB's workspace folder.
Mex Compiler Config:
>> cc = mex.getCompilerConfigurations('C++')
cc =
CompilerConfiguration with properties:
Name: 'MinGW64 Compiler (C++)'
Manufacturer: 'GNU'
Language: 'C++'
Version: '5.3.0'
Location: 'C:\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0\mingw64'
ShortName: 'mingw64-g++'
Priority: 'E'
Details: [1×1 mex.CompilerConfigurationDetails]
LinkerName: 'C:\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0\mingw64\bin\g++'
LinkerVersion: ''
MexOpt: 'C:\Users\masom\AppData\Roaming\MathWorks\MATLAB\R2018a\mex_C++_win64.xml'
Launch.json:
{
"name": "(gdb) Attach to Matlab",
"type": "cppdbg",
"request": "attach",
"program": "C:/Program Files/MATLAB/R2018a/bin/win64/MATLAB.exe",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"miDebuggerPath": "C:/mingw-w64/x86_64-5.3.0-posix-seh-rt_v4-rev0/mingw64/bin/gdb.exe",
"setupCommands": [
{
"text": "handle SIGSEGV nostop"
},
{
"text": "handle SIGSEGV noprint"
}
]
}

回答(1 个)

Lipi Vora
Lipi Vora 2018-10-24
编辑:Lipi Vora 2018-10-24
Hi,
I followed the steps mentioned in the tutorial for an example MEX file found in my case in, “C:\Program Files\MATLAB\R2018a\extern\examples\mex\arrayProduct.c” MATLAB folder. I am able to hit breakpoints in the “arrayProduct” function in VS Code. I would recommend you try the steps with a sample MEX file to eliminate issues that might be arising specific to your source code.

类别

Help CenterFile Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by