Hi all, I am in the middle of debugging which is stopped using "browser()"... in myfile.R at around line #25. I was then stuck in a big loop which I want to escape and stop the program at the line after the big loop. In the debugging mode, I used Browse[2]> setBreakpoint("myfile.R#38") I then typed "c" and "ENTER", thinking that it will continue to execute until when it comes across line #38 and then stop there... But it didn't work - it continued the execution until the end of the function, right at the line "return(results)"... What happened? How to solve this problem? Thanks a lot! [[alternative HTML version deleted]]
R. Michael Weylandt <michael.weylandt@gmail.com>
2011-Dec-06 04:40 UTC
[R] help! what's wrong with setBreakpoint
A function is a parsed object stored in memory; your edit applies to the source, but not to the memory object being executed. There is no way, to my knowledge, to use browser to alter the execution flow of an function once it's going (other than changing values of course). You need to edit the function definition to put the breakpoint where desired and then reread and rerun the function. Michael On Dec 5, 2011, at 10:32 PM, Michael <comtech.usa at gmail.com> wrote:> Hi all, > > I am in the middle of debugging which is stopped using "browser()"... in > myfile.R at around line #25. > > I was then stuck in a big loop which I want to escape and stop the program > at the line after the big loop. > > In the debugging mode, I used > > Browse[2]> setBreakpoint("myfile.R#38") > > I then typed "c" and "ENTER", thinking that it will continue to execute > until when it comes across line #38 and then stop there... > > But it didn't work - it continued the execution until the end of the > function, right at the line "return(results)"... > > What happened? How to solve this problem? > > Thanks a lot! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
On 11-12-05 10:32 PM, Michael wrote:> Hi all, > > I am in the middle of debugging which is stopped using "browser()"... in > myfile.R at around line #25. > > I was then stuck in a big loop which I want to escape and stop the program > at the line after the big loop. > > In the debugging mode, I used > > Browse[2]> setBreakpoint("myfile.R#38")What did it print?> > I then typed "c" and "ENTER", thinking that it will continue to execute > until when it comes across line #38 and then stop there... > > But it didn't work - it continued the execution until the end of the > function, right at the line "return(results)"... > > What happened? How to solve this problem?One of the complications in R is that you can have multiple copies of a function in memory. You may (or may not, what did it print??) have set a breakpoint in one copy, then run another. Or you may have edited that function after originally sourcing it, and lost the source reference. An alternative to using setBreakpoint is just to edit a call to browser() into the function. It's less convenient, but more robust. Duncan Murdoch> Thanks a lot! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.