Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug macro makes function disappear inside an iprofile block #74

Open
mattcbro opened this issue Sep 14, 2015 · 6 comments
Open

Debug macro makes function disappear inside an iprofile block #74

mattcbro opened this issue Sep 14, 2015 · 6 comments

Comments

@mattcbro
Copy link

Consider the following code in badprofile.jl

using IProfile
using Debug

@iprofile begin

# add the debug macro makes the function disappear if inside an iprofile block
@debug function imgone()
    print("I'm Here\n")
    @bp
end

end

Observe what happens if you try to use this code.
julia> require("badprofile")

julia> imgone()
ERROR: imgone not defined

julia>

Now suppose I remove the @debug macro from imgone. I then get the correct behavior
julia> require("badprofile")

julia> imgone()
I'm Here

There is some kind of nasty interaction between these macros in the two packages. Now it may be unreasonable to do debugging inside a profiling block, however one is supposed to be able to turn the profiler off without messing with the iprofile begin and end block.

Not sure if this is a debug problem or iprofile problem or both. This is not a show stopper by any means, but if it's intended behavior perhaps it should be documented or something.

@mattcbro
Copy link
Author

Sorry forgot to mention that I'm using Julia 0.3.11 on x86_64-linux-gnu.

@toivoh
Copy link
Owner

toivoh commented Sep 15, 2015

Indeed, it seems like a nasty interaction. As far as I can tell, the only thing that @debug will do with the function is to wrap it in an esc() and a few begin blocks. But maybe it won't even get that far. @timholy: Do you remember what @iprofile will do when it encounters a macro invocation? Or an esc expression?

@timholy
Copy link
Contributor

timholy commented Sep 15, 2015

It's been so long since I've thought about IProfile, I don't remember much of anything about it.

In these situations, macroexpand is your friend for anyone who feels like digging into this.

@mattcbro
Copy link
Author

There are a few other interactions with debug that I've wondered about along similiar lines. I notice issues when putting breakpoints in functions that are called through pmap or @parallel and so forth.

I think the REPL breaks down with IO on separate threads. For similar reasons debug doesn't seem to work inside IJulia.

As for Iprofile, I kind of like how it works. It's easier to understand for me.

@toivoh
Copy link
Owner

toivoh commented Sep 24, 2015

Yes, anyone who'd like to, please feel free to dig into this! I don't think I will be able to prioritize it myself.

@toivoh
Copy link
Owner

toivoh commented Sep 24, 2015

@mattcbro: That's a few issues in one message :)
Regarding parellel execution: The instrumentation that Debug creates was never designed to work with code that could be sent to and executed in another process (or thread for that matter). My recommendation would be to wrap any code that might run anywhere else than the current thread with @notrap, see #71.

The IO trouble seems to be inherited from Julia's readline(). If that get fixed then it should get fixed for Debug too. See #52.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants