Skip to content
Prev 44900 / 63424 Next

debugging C/Fortran code with Visual Studio and Intel compilers

On 13-01-18 6:24 AM, Vitaliy FEOKTISTOV wrote:
I've rarely used those compilers, but I've used two strategies for 
situations like that.

1.  Start Rgui.exe in some debugger that works with your compiler.  It 
won't know how to handle R debug info (and unless you've recompiled R 
there won't be any), but you should be able to set breakpoints in your 
own code.  If your debugger won't set code in an unloaded DLL, you can 
run R, attach the package, then interrupt R to set breakpoints.

2.  If you want to trigger a call to the debugger from your code, there 
are Windows API functions to do that (but I never had any luck with 
them); you may also be able to execute

   asm("int $3");

in your function to trigger a debug interrupt.  This is a little 
dangerous, because I think it will crash R if a debugger is not attached.

Or you can use the old fashioned debugging methods, and just insert lots 
of Rprintf() calls into your C code.  This is quite painful, but 
sometimes is necessary.

Duncan Murdoch