MATLAB: How to debug S-functions generated using the legacy code tool in Simulink 6.5 (R2006b)

debuggerlegacy_code_compilesimulink

I need to debug my S-function which I created using the following command:
legacy_code('sfcn_cmex_generate', def);
legacy_code('compile',def);
where, def contains the legacy code tool data structure.

Best Answer

This bug has been fixed in Release 2007b (R2007b). For previous product releases, read below for any possible workarounds:
To create a debuggable S-function, pass the '-g' switch to the LEGACY_CODE command as follows:
legacy_code('sfcn_cmex_generate', def);
legacy_code('compile',def,'-g');