Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:10:59+00:00 2026-06-12T13:10:59+00:00

Consider we have called debug() for several functions to make a breakpoint on them.

  • 0

Consider we have called debug() for several functions to make a breakpoint on them. When we find and solve the bug, is there anyway to undebug() all functions already marked by debug() by a single command?

Here is a good benchmark to see if your proposed method really works perfectly:

> library(limma) # bioconductor
> debug(read.ilmn)
> read.ilmn("a.txt") # No problem if this file does not exist
Browse[2]> debug(.read.oneilmnfile) # This is the debug browser for read.ilmn()
Browse[2]> Q # To exit debug browser
> undebug.all() # Here run your proposed function to undebug everything!
> read.ilmn("a.txt")
# Now if the debug browser is not started, you are lucky to pass this test!

You may see the accepted answer below. Any case for which this answer does not work, or cleaner versions, are more than welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:11:00+00:00Added an answer on June 12, 2026 at 1:11 pm

    This was my solution …

    edit: revised to deal with finding objects in namespaces. The code is already getting a little bit crufty, since I don’t really understand the methods for manipulating/querying namespaces all that well, and since I was working by trial and error. Cleaner versions would be welcome. There are almost certainly other corner cases that will fail.

    ## return the names of the objects (from a vector of list of
    ## names of objects) that are functions and have debug flag set
    isdebugged_safe <- function(x,ns=NULL)  {
        g <- if (is.null(ns)) get(x) else getFromNamespace(x,ns)
        is.function(g) && isdebugged(g)
    }
    
    which_debugged <- function(objnames,ns=NULL) {
        if (!length(objnames)) return(character(0))
        objnames[sapply(objnames,isdebugged_safe,ns=ns)]
    }
    
    all_debugged <- function(where=search(), show_empty=FALSE) {
        ss <- setNames(lapply(where,function(x) {
            which_debugged(ls(x,all.names=TRUE))
            }),gsub("package:","",where))
        ## find attached namespaces
        ## (is there a better way to test whether a 
        ##    namespace exists with a given name??)
        ns <- unlist(sapply(gsub("package:","",where),
                     function(x) {
                         if (inherits({n <- try(getNamespace(x),silent=TRUE)},
                             "try-error")) NULL else x
                     }))
        ss_ns <- setNames(lapply(ns,function(x) {
            objects <- ls(getNamespace(x),all.names=TRUE)
            which_debugged(objects,ns=x)
            }),ns)
        if (!show_empty) {
            ss <- ss[sapply(ss,length)>0]
            ss_ns <- ss_ns[sapply(ss_ns,length)>0]
        }
        ## drop overlaps
        for (i in names(ss))
            ss_ns[[i]] <- setdiff(ss_ns[[i]],ss[[i]])
        list(env=ss,ns=ss_ns)
    }
    
    undebug_all <- function(where=search()) {
        aa <- all_debugged(where)
        lapply(aa$env,undebug)
        ## now debug namespaces
        invisible(mapply(function(ns,fun) {
            undebug(getFromNamespace(fun,ns))
        },names(aa$ns),aa$ns))
    }
    

    The code is also posted at http://www.math.mcmaster.ca/bolker/R/misc/undebug_all.R

    Example:

    library(nlme)
    debug(lme)
    ## define functions
    source(url("http://www.math.mcmaster.ca/bolker/R/misc/undebug_all.R"))
    undebug_all()
    fm1 <- lme(distance ~ age, data = Orthodont) # from ?lme
    

    In this case lme runs without entering the debugger.

    Another, harder example:

    library(limma)
    source(url("http://www.math.mcmaster.ca/bolker/R/misc/undebug_all.R"))
    debug(read.ilmn)
    debug(limma:::.read.oneilmnfile)
    all_debugged()
    undebug_all()
    read.ilmn()
    read.ilmn("a.txt")
    

    Note that read.ilmn() and read.ilmn("a.txt") appear to behave differently from a debugging standpoint (I don’t understand why …)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please consider such scenerio: I have component called TMenuItemSelector which has two published properties:
Consider I have a game-creation framework, with a basic class called Game. // Action
Please Consider this scenario: We have a base class called clsMain : class clsMain
Consider i have a registartion table and there is field prefLocationId and it contains
Consider I have a directory called root that has two directories: x and y
Consider I have a DataContext db , and there is an Entity class User
Consider the following data model: Suppose I have a table called SuperAwesomeData where each
Lets consider I have a string called string s = jpeg, jpg, gif, png;
Let's consider we have a module called mod which has a function func .
Consider this example - I have a class called Report that has a field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.