Sometimes I can edit my code when I am debugging. But sometimes I cannot: the code is frozen. I could not figure out the conditions under which the code is frozen. Any tips? Thanks.
With the debugger active, copy and edit the code interactively in the console. Or, copy the code to a new R script, make changes to the copy, and run the new code while the debugger is still active. Hope this helps.
Thanks for answering my question. But sometimes I can edit the code that is being debugged, sometimes not. I would like to know under what conditions the code gets frozen so that I cannot edit it.
While you're debugging, the debugger tries its best to take you to the file containing the code that's running. However, sometimes it can't, usually for one of three reasons:
- The code that's running doesn't have source references, so the debugger doesn't know what file it came from.
- The code that's running doesn't match the file it came from, usually because the file has changed since it was last run/built.
- The file containing the code that's running has unsaved changes.
In any of these cases, it can't show you the (editable) file since it doesn't match reality, so it will make a read-only copy of the code that's actually running and show you that instead. That's why the code looks frozen.
Thanks for your answer, Jonathan.
Looking at the three reasons why code gets frozen, 2 and 3 are easy to deal with, since it is my own code. It remains 1:
" 1. The code that's running doesn't have source references, so the debugger doesn't know what file it came from."
. You provided a link to the paper Source References by Duncan Murdoch. It is a bit old, as it has been published in 2010 and parts of it are well over my head. Is there a simple way to add source references to my code so that I can debug "live"?
Thanks for your help.
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.