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

A fine debugger #23

Merged
merged 63 commits into from
Mar 20, 2019
Merged

A fine debugger #23

merged 63 commits into from
Mar 20, 2019

Conversation

oxinabox
Copy link
Owner

@oxinabox oxinabox commented Mar 9, 2019

This combines #14 and #19
I've just done the merge on this branch rather than master as neither felt complete without the other.

When this is complete one will have a debugger that works with line-numbers.

@oxinabox
Copy link
Owner Author

If anyone would care to give this a quick review, that would be appreciated.

It is basically working,
I am just chasing down some errors that seem to occur only on travis
(https://travis-ci.com/oxinabox/MagneticReadHead.jl/jobs/185076830#L263)
and I probably want to write some more "interactive" tests, where I drive the debugger with preprogrammed commands.

It would be good to merge this, rather than continuing to add features to thiis PR.

@oxinabox oxinabox changed the title WIP: A fine debugger A fine debugger Mar 15, 2019
Copy link

@timholy timholy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very intriguing, @oxinabox! I can't pretend I understand this yet, but it looks like an interesting approach. Doing this kind of thing was the first thing I thought of when I first heard about Cassette, but I still haven't taken the plunge yet.

How's the run-time performance of the instrumented code? Over at JuliaInterpreter we're a lot slower than compiled code; I'm sure this is slower too, but it would be interesting to compare the magnitudes. My naive guess is this might be slower to compile but faster to run? (We have also thought about creating "compiled Frames," but that's in the future.)

We're gearing up for a release announcement of our debugger stack. How close is this? Would you be interested in making a discourse announcement at around the same time? Or is this still too much of a research project?

if mdata === nothing
error(
"According to CodeTracking.jl $mod is not loaded. " *
"Revise.jl might be malfuncting."
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to work with you on this. Do you have a reproducible trigger?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, I added that when I was seeing Nothing related errors. I think on CI.
I'll let you know when I do.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may have been a Standard Library.
As of the commit i just made we now attempt to do Revise.track(mod)
if pkgfiles comes up with nothing


function containing_methods(file, linenum)
#TODO: raise issue on CodeTracking.jl to expose public way
# to get list of all loaded modules
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use Base.loaded_modules?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into it

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is that includes standard libraries, which are not tracked by default.
And that is probably a wise choice by Revise?

src/method_utils.jl Outdated Show resolved Hide resolved
@oxinabox
Copy link
Owner Author

How's the run-time performance of the instrumented code?

I've only just started some basic timings (using Optimum solving Rossenbock).
And I need to setup a better timing system since I am just using time_ns() right now. And am running twice.

Not great, I can get maybe down to 2 orders of magnitude of the original code, if I set_nodebug!() on all modules, barring the one I am interested in debugging.
If I don't knock out things with set_nodebug then I think it is like 4+ orders if magnitude, because it instruments everything.
But that seems too long, the runtime cost should only be 1 order of magnitude.

I have a feeling I am breaking compilation caching, since it is no faster the second time I run anything.

Also that I should implement my own cache for the instrumentation step.

@oxinabox
Copy link
Owner Author

oxinabox commented Mar 18, 2019

We're gearing up for a release announcement of our debugger stack. How close is this? Would you be interested in making a discourse announcement at around the same time? Or is this still too much of a research project?

When this PR is merged, I think it will be time for an announcement.
And all that is really hard blocking this from being merged is fixing the tests for filename+line number breakpoints.
It will still be beta, but i will want user feedback to help discover issues.

There are some other thing I want to do that I don't want to put in this PR, like the ability to go back-up the callstack and read variables. Which shouldn't be too hard.
But those can come later.

Long term, I hope this can be complentairy to your work on Debugger.jl.
I like the notion that one should be able to switch between "compiled-mode" and "interpreted-mode".
Also I would like to be sharing some of the UI stuff, probably before too long,as I don't fancy writing a text-ui thing that can show position in callstack on one side, and position in file on the other.
And the interface to Juno of course should be the same.

I really need to catch up on the state of Debugger.jl

@timholy
Copy link

timholy commented Mar 18, 2019

I really need to catch up on the state of Debugger.jl

The real guts are in JuliaInterpreter.jl; as of this morning there are some fairly decent docs, though a bit forward-looking since none of Debugger/Rebugger/Juno have released & tagged versions that support it (but Debugger.jl has it on master, and Rebugger on timholy/Rebugger.jl#61).

Debugger.jl can be thought of as "just a REPL mode," i.e., the UI part. Rebugger.jl has (on that branch) a meta-i key binding that's "just a different REPL mode" to interface with JuliaInterpreter. These two REPL-modes have different philosophies: Debugger is more like gdb, Rebugger more like an IDE. Juno will be a "real IDE" (see JunoLab/Juno.jl#257).

@timholy
Copy link

timholy commented Mar 18, 2019

One option would be for you to implement the debug_command API of JuliaInterpreter & then maybe you could use Debugger.jl for your UI?

@oxinabox
Copy link
Owner Author

I have a feeling I am breaking compilation caching, since it is no faster the second time I run anything.

Further timing actually shows I am

Normally calling:

1.318972 seconds (4.85 M allocations: 244.061 MiB, 9.40% gc time)
0.000079 seconds (535 allocations: 21.297 KiB)

With using @iron_debug but with basically maximum set_nodebug on, so very little should be getting instrumented:

5.116838 seconds (17.96 M allocations: 921.936 MiB, 5.17% gc time)
0.016707 seconds (39.39 k allocations: 2.019 MiB)

So it is indeed faster after compiling.

Also that I should implement my own cache for the instrumentation step.

I tried this. It didn't work.

@oxinabox
Copy link
Owner Author

Ok, that last cruicial feature is in. Thanks to @timholy's fixes for random files outside of packages in CodeTracking 0.4.0.
Which means I can make a Beta testing announcement when you make an announcement for Debugger.jl

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

Successfully merging this pull request may close these issues.

2 participants