Gábor Csárdi
2018-Apr-28 11:57 UTC
[Rd] debugonce() functions are not considered as debugged
debugonce() sets a different flag (RSTEP), and this is not queried by isdebugged(), and it is also not unset by undebug(). Is this expected? If yes, is there a way to query and unset the RSTEP flag from R code? ? f <- function() { } ? debugonce(f) ? isdebugged(f) [1] FALSE ? undebug(f) Warning message: In undebug(f) : argument is not being debugged ? f() debugging in: f() debug at #1: { } Browse[2]>
Gabe Becker
2018-May-01 17:05 UTC
[Rd] debugonce() functions are not considered as debugged
Gabor, Others can speak to the origins of this more directly, but from what I recall this has been true at least since I was working in this space on the debugcall stuff a couple years ago. I imagine the reasoning is what you would expect: a single bit of course can't tell R both that a function is debugged AND that it should undebug after the first call. I don't know of any R-facing way to check for debugonce status, though its possible I missed it That said, it would be possible to alter how the two bits are used so that debugonce sets both of them, and debug (not once) only sets one, rather them being treated as mutually exclusive. This would alter the behavior so that debugonce'ed functions that haven't been called yet are considered debugged, e.g., by isdebugged. This would not, strictly speaking, be backwards compatible, but by the very nature of what debugging means, it would not break any existing script code. It could, and likely would, effect code implementing GUIs, however. R-core - is this a patch that you are interested in and would consider incorporating? If so I can volunteer to work on it. Best, ~G On Sat, Apr 28, 2018 at 4:57 AM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote:> debugonce() sets a different flag (RSTEP), and this is not queried by > isdebugged(), and it is also not unset by undebug(). > > Is this expected? If yes, is there a way to query and unset the RSTEP flag > from R code? > > ? f <- function() { } > ? debugonce(f) > ? isdebugged(f) > [1] FALSE > > ? undebug(f) > Warning message: > In undebug(f) : argument is not being debugged > > ? f() > debugging in: f() > debug at #1: { > } > Browse[2]> > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > >-- Gabriel Becker, Ph.D Scientist Bioinformatics and Computational Biology Genentech Research [[alternative HTML version deleted]]
Tomas Kalibera
2018-May-21 16:01 UTC
[Rd] debugonce() functions are not considered as debugged
debug(fun) marks "fun" for debugging, it makes sure that whenever "fun" is called, the debugger is entered undebug(fun) removes this mark; it won't stop any current debugging of that function isdebugged(fun) tells whether this mark is set or not; it does not tell whether "fun" is currently running in a debugger/browser debugonce(func) adds a different mark to the function, one that makes sure the first time "fun" is called, the debugger is entered; this is the same as when entering that function via "s" while debugging its caller. There is no way to query or unset this mark. Do you have a good use case when it would be useful to query/unset the mark for debugonce? Best, Tomas On 04/28/2018 01:57 PM, G?bor Cs?rdi wrote:> debugonce() sets a different flag (RSTEP), and this is not queried by > isdebugged(), and it is also not unset by undebug(). > > Is this expected? If yes, is there a way to query and unset the RSTEP flag > from R code? > > ? f <- function() { } > ? debugonce(f) > ? isdebugged(f) > [1] FALSE > > ? undebug(f) > Warning message: > In undebug(f) : argument is not being debugged > > ? f() > debugging in: f() > debug at #1: { > } > Browse[2]> > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Gábor Csárdi
2018-May-22 16:07 UTC
[Rd] debugonce() functions are not considered as debugged
On Mon, May 21, 2018 at 5:01 PM Tomas Kalibera <tomas.kalibera at gmail.com> wrote: [...]> Do you have a good use case when it would be useful to query/unset the > mark for debugonce?Well, I suppose the same use cases when it is useful to query/unset the other debug mark. To be more specific, in debug helpers for a tool that works with callbacks from a central event loop, it is nice to be able to tell which callbacks are "debugged" currently, either via `debug()` or `debugonce()`. Gabor> Best, > Tomas> On 04/28/2018 01:57 PM, G?bor Cs?rdi wrote: > > debugonce() sets a different flag (RSTEP), and this is not queried by > > isdebugged(), and it is also not unset by undebug(). > > > > Is this expected? If yes, is there a way to query and unset the RSTEPflag> > from R code? > > > > ? f <- function() { } > > ? debugonce(f) > > ? isdebugged(f) > > [1] FALSE > > > > ? undebug(f) > > Warning message: > > In undebug(f) : argument is not being debugged > > > > ? f() > > debugging in: f() > > debug at #1: { > > } > > Browse[2]> > > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel