Skip to content
Prev 279515 / 398506 Next

help! what's wrong with setBreakpoint

On 06/12/2011 11:11 AM, Michael wrote:
From a later one of your messages (adding a call to browser() didn't do 
anything), I think you weren't.  Now you know how to check.

Debugging code in packages can be tricky.  There are several strategies 
that I've used in different circumstances:

1.  source() the original source files from the command line.  Then 
you're not in a namespace, so you don't have that to confuse you.  (But 
if you don't source everything, you may find the source'd functions 
can't see the ones you skipped.)

2.  Set the environment variable R_KEEP_PKG_SOURCE to yes, then install 
the package; do all my debugging via things like

setBreakpoint("srcfile.R#30", env=somefunction)

where somefunction is in the package being debugged.  You can't make 
permanent changes to the functions this way, but you can add debugging 
code in the setBreakpoint call.

3.  Edit the source and re-install the package.   This is a bit of a 
pain, but it's the best way to reproduce the real execution environment.

Duncan Murdoch