Giter VIP home page Giter VIP logo

astinterpreter.jl's People

Contributors

aviks avatar jakebolewski avatar jeffbezanson avatar keno avatar mauro3 avatar timholy avatar tkelman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

astinterpreter.jl's Issues

fancy-mode broken

Not a high priority at all, but I noticed this:

julia> using ASTInterpreter
WARNING: module Lexer should explicitly import √ from Base

julia> eval(ASTInterpreter, :(fancy_mode = true))
true

julia> @enter gcd(100,25)
ERROR: MethodError: no method matching ⨳(::Symbol, ::Symbol, ::JuliaParser.Lexer.SourceLocToken, ::JuliaParser.Lexer.SourceLocToken)
Closest candidates are:
  ⨳(::Symbol, ::Union{JuliaParser.Lexer.SourceExpr,JuliaParser.Lexer.SourceLocToken,LineNumberNode}...)
  ⨳(::JuliaParser.Lexer.SourceLocToken, ::Any...)
  ⨳(::JuliaParser.Lexer.Token, ::Any...)
  ...
 in parse_LtoR(::JuliaParser.Parser.ParseState, ::JuliaParser.Lexer.TokenStream{JuliaParser.Lexer.SourceLocToken}, ::JuliaParser.Parser.#parse_term, ::Set{Symbol}, ::JuliaParser.Lexer.SourceLocToken) at /home/bezanson/.julia/v0.5/JuliaParser/src/parser.jl:232
 in parse_LtoR(::JuliaParser.Parser.ParseState, ::JuliaParser.Lexer.TokenStream{JuliaParser.Lexer.SourceLocToken}, ::JuliaParser.Parser.#parse_term, ::Set{Symbol}) at /home/bezanson/.julia/v0.5/JuliaParser/src/parser.jl:224
 in parse_shift(::JuliaParser.Parser.ParseState, ::JuliaParser.Lexer.TokenStream{JuliaParser.Lexer.SourceLocToken}) at /home/bezanson/.julia/v0.5/JuliaParser/src/parser.jl:414

Printing for return

Probably should explicitly highlight the return if available and just print nothing otherwise.

ERROR: UndefRefError: access to undefined reference

i'm not sure where in Gallium/ASTInterpreter this fails

Scenario: single stepping through a Gadfly function

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-dev+4096 (2016-05-15 02:07 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 6056e10* (0 days old master)
|__/                   |  x86_64-linux-gnu

julia> using Gallium

julia> using Gadfly

julia> breakpoint(render)
WARNING: Base.ASCIIString is deprecated, use String instead.
  likely near no file:0
in render at /home/lobi/.julia/v0.5/Gadfly/src/geom/point.jl
Locations (+: active, -: inactive, *: source):
 + render(geom::Gadfly.Geom.PolygonGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/polygon.jl:40
 + render(guide::Gadfly.Guide.XTicks, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, dynamic::Bool) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:573
 + render(geom::Gadfly.Geom.SubplotGrid, theme::Gadfly.Theme, superplot_aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geom/subplot.jl:146
 + render(guide::Gadfly.Guide.ColorKey, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:404
 + render(geom::Gadfly.Geom.RectangularBinGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/rectbin.jl:51
 + render(geom::Gadfly.Geom.YErrorBarGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/errorbar.jl:70
 + render(geom::Gadfly.Geom.XErrorBarGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/errorbar.jl:105
 + render(geom::Gadfly.Geom.RibbonGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/ribbon.jl:26
 + render(guide::Gadfly.Guide.XLabel, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:921
 + render(guide::Gadfly.Guide.YLabel, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:985
 + render(guide::Gadfly.Guide.Title, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:1038
 + render(geom::Gadfly.Geom.HexagonalBinGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/hexbin.jl:34
 + render(guide::Gadfly.Guide.YTicks, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, dynamic::Bool) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:754
 + render(geom::Gadfly.Geom.BoxplotGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/boxplot.jl:21
 + render(geom::Gadfly.Geom.ViolinGeometry, theme::Gadfly.Theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/violin.jl:22
 + render(plot::Gadfly.Plot) at /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:799
 + render(geom::Gadfly.Geom.PointGeometry, theme::Gadfly.Theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/point.jl:31
 + render(geom::Gadfly.Geom.HLineGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/hline.jl:25
 + render(geom::Gadfly.Geom.VLineGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/vline.jl:24
 + render(geom::Gadfly.Geom.ErrorBarGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/errorbar.jl:56
 + render(guide::Gadfly.Guide.ZoomSlider, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:76
 + render(guide::Gadfly.Guide.PanelBackground, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:55
 + render(geom::Gadfly.Geom.LineGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/line.jl:72
 + render(geom::Gadfly.Geom.LabelGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/label.jl:272
 + render(geom::Gadfly.Geom.BarGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) at /home/lobi/.julia/v0.5/Gadfly/src/geom/bar.jl:273
 + render(geom::Gadfly.Geom.PolygonGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.RibbonGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.ErrorBarGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.BoxplotGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.LineGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.RectangularBinGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.ViolinGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.HLineGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.VLineGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.LabelGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.HexagonalBinGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.BarGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(geom::Gadfly.Geom.PointGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Array{Gadfly.Aesthetics,1}, subplot_layer_datas::Array{Gadfly.Data,1}, scales::Dict{Symbol,Gadfly.ScaleElement}) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 + render(guide::Gadfly.Guide.XLabel, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, dynamic::Bool) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:50
 + render(guide::Gadfly.Guide.ColorKey, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, dynamic::Bool) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:50
 + render(guide::Gadfly.Guide.YLabel, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, dynamic::Bool) at /home/lobi/.julia/v0.5/Ga + render(guide::Gadfly.Guide.ZoomSlider, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, dynamic::Bool) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:50
 + render(guide::Gadfly.Guide.PanelBackground, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, dynamic::Bool) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:50
 * Any matching method added to Gadfly.#render
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/polygon.jl:40
 * Any matching specialization of render(guide, theme, aes, dynamic) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:573
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:573
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:1067
 * Any matching specialization of render(geom, theme, superplot_aes, subplot_layer_aess, subplot_layer_datas, scales) at /home/lobi/.julia/v0.5/Gadfly/src/geom/subplot.jl:146
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:1089
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:404
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/rectbin.jl:51
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/errorbar.jl:70
 * Any matching specialization of render(geom, theme, aes, data, scales, subplot_layer_aess) at null:0
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:1228
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/errorbar.jl:105
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/ribbon.jl:26
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:921
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:985
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:1038
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/hexbin.jl:34
 * Any matching specialization of render(guide, theme, aes, dynamic) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:754
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:754
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/beeswarm.jl:26
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/boxplot.jl:21
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/violin.jl:22
 * Any matching specialization of render(plot) at /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:799
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/point.jl:31
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/hline.jl:25
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/vline.jl:24
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/errorbar.jl:56
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:76
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:55
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/line.jl:72
dfly/src/guide.jl:50
 + render(guide::Gadfly.Guide.Title, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, dynamic::Bool) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:50
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/label.jl:272
 * Any matching specialization of render(geom, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/geom/bar.jl:273
 * Any matching specialization of render(geom, theme, aes, subplot_layer_aess, subplot_layer_datas, scales) at /home/lobi/.julia/v0.5/Gadfly/src/geometry.jl:48
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:506
 * Any matching specialization of render(guide, theme, aes) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:50
 * Any matching specialization of render(guide, theme, aes, dynamic) at /home/lobi/.julia/v0.5/Gadfly/src/guide.jl:50


julia> plot(x=randn(10),y=randn(10),Geom.histogram2d)
WARNING: Base.ASCIIString is deprecated, use String instead.
  likely near no file:0
WARNING: Base.ASCIIString is deprecated, use String instead.
  likely near no file:0
WARNING: Base.ASCIIString is deprecated, use String instead.
  likely near no file:0
WARNING: Base.ASCIIString is deprecated, use String instead.
  likely near no file:0
WARNING: Base.ASCIIString is deprecated, use String instead.
  likely near no file:0
WARNING: Base.ASCIIString is deprecated, use String instead.
  likely near no file:0
WARNING: Base.UTF8String is deprecated, use String instead.
  likely near no file:0
WARNING: Base.UTF8String is deprecated, use String instead.
  likely near no file:0
WARNING: Base.UTF8String is deprecated, use String instead.
  likely near no file:0
WARNING: Base.UTF8String is deprecated, use String instead.
  likely near no file:0
WARNING: Base.UTF8String is deprecated, use String instead.
  likely near no file:0
In /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:799
798   function render(plot::Plot)
799       (plot, coord, plot_aes,
800        layer_aess, layer_stats, layer_subplot_aess, layer_subplot_datas,
801        scales, guides) = render_prepare(plot)

About to run: Gadfly.render_prepare
1|debug > s
In /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:427
426   function render_prepare(plot::Plot)
427       if isempty(plot.layers)
428           layer = Layer()
429           layer.geom = Geom.point()

About to run: Core.Box

1|debug > s
In boot.jl:235
234       Box(x::ANY) = new(x)
235       Box() = new()
236   end
237   

About to run: Core.Box

1|debug > s
In boot.jl:235
234       Box(x::ANY) = new(x)
235       Box() = new()
236   end
237   

About to run: ^[[Areturn 
Core.Box(#undef)

1|debug > s
In /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:427
426   function render_prepare(plot::Plot)
427       if isempty(plot.layers)
428           layer = Layer()
429           layer.geom = Geom.point()

About to run: (Core.Box)()

1|debug > s
In boot.jl:235
234       Box(x::ANY) = new(x)
235       Box() = new()
236   end
237   

About to run: Core.Box

1|debug > 
In boot.jl:235
234       Box(x::ANY) = new(x)
235       Box() = new()
236   end
237   

About to run: return Core.Box(#undef)

1|debug > 
In /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:427
426   function render_prepare(plot::Plot)
427       if isempty(plot.layers)
428           layer = Layer()
429           layer.geom = Geom.point()

About to run: (Core.Box)()

1|debug > 
In boot.jl:235
234       Box(x::ANY) = new(x)
235       Box() = new()
236   end
237   

About to run: Core.Box

1|debug > 
In boot.jl:235
234       Box(x::ANY) = new(x)
235       Box() = new()
236   end
237   

About to run: return Core.Box(#undef)

1|debug > 
In /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:427
426   function render_prepare(plot::Plot)
427       if isempty(plot.layers)
428           layer = Layer()
429           layer.geom = Geom.point()

About to run: (getfield)(Gadfly.Plot([Gadfly.Layer(nothing,Dict{Any,Any}(),Gadfly.StatisticElement[],Gadfly.Geom.RectangularBinGeometry(Gadfly.Stat.Histogram2DStatistic(3,150,3,150),Symbol("")),nothing,0)],nothing,Data(
  x=[2.156048746729853,0.043781013542880325,0.3000119308712364,-0.09828362367914963,-0.3033370912755028,-2.196892224265205,0.23457302204862754,-0.967823125791486,1.5642695912345441,-0.057579632614796324]
  y=[0.11217122028073197,1.0212474395300306,-0.3377752295435214,-0.8836106308920646,-1.862793427218974,-0.724814180649498,0.7963097239474038,-1.084543529842187,0.9161830329709968,-0.7611091777582755]
  titles=Dict{Symbol,AbstractString}(Pair{Symbol,AbstractString}(:y,"y"),Pair{Symbol,AbstractString}(:x,"x"))
)
,Gadfly.ScaleElement[],Gadfly.StatisticElement[],nothing,Gadfly.GuideElement[],Gadfly.Theme(LCHab{Float32}(70.0f0,60.0f0,240.0f0),0.9mm,0.3mm,nothing,nothing,nothing,1.0,nothing,5.0mm,RGB{U8}(0.816,0.816,0.878),[0.5mm,0.5mm],RGB{U8}(0.627,0.627,0.627),0.2mm,"'PT Sans Caption','Helvetica Neue','Helvetica',sans-serif",2.822222222222222mm,RGB{U8}(0.424,0.376,0.42),"'PT Sans','Helvetica Neue','Helvetica',sans-serif",3.880555555555555mm,RGB{U8}(0.337,0.29,0.333),"'PT Sans Caption','Helvetica Neue','Helvetica',sans-serif",2.822222222222222mm,RGB{U8}(0.298,0.251,0.294),"'PT Sans','Helvetica Neue','Helvetica',sans-serif",3.880555555555555mm,RGB{U8}(0.212,0.165,0.208),"'PT Sans','Helvetica Neue','Helvetica',sans-serif",2.822222222222222mm,RGB{U8}(0.298,0.251,0.294),40,-0.05mm,1.0mm,3.0mm,Gadfly.default_stroke_color,0.3mm,Gadfly.default_discrete_highlight_color,Gadfly.default_continuous_highlight_color,Gadfly.default_lowlight_color,0.6,Gadfly.default_middle_color,0.6mm,:left,:square,:right,nothing,Function[Compose.circle,Gadfly.square,Gadfly.diamond,Gadfly.cross,Gadfly.xcross,Gadfly.utriangle,Gadfly.dtriangle,Gadfly.star1,Gadfly.star2,Gadfly.hexagon,Gadfly.octagon],2.0mm,1000,10.0,0.5,0.2,4),Dict{Symbol,Any}(Pair{Symbol,Any}(:y,[0.11217122028073197,1.0212474395300306,-0.3377752295435214,-0.8836106308920646,-1.862793427218974,-0.724814180649498,0.7963097239474038,-1.084543529842187,0.9161830329709968,-0.7611091777582755]),Pair{Symbol,Any}(:x,[2.156048746729853,0.043781013542880325,0.3000119308712364,-0.09828362367914963,-0.3033370912755028,-2.196892224265205,0.23457302204862754,-0.967823125791486,1.5642695912345441,-0.057579632614796324]))),layers)

1|debug > 
In abstractarray.jl:377
376   
377   isempty(a::AbstractArray) = (length(a) == 0)
378   
379   ## Conversions ##

About to run: Base.==

1|debug > 
In array.jl:23
22  
23  length(a::Array) = arraylen(a)
24  elsize{T}(a::Array{T}) = isbits(T) ? sizeof(T) : sizeof(Ptr)
25  sizeof(a::Array) = elsize(a) * length(a)

About to run: Base.arraylen

1|debug > 
In array.jl:23
22  
23  length(a::Array) = arraylen(a)
24  elsize{T}(a::Array{T}) = isbits(T) ? sizeof(T) : sizeof(Ptr)
25  sizeof(a::Array) = elsize(a) * length(a)

About to run: return 1

1|debug > 
In abstractarray.jl:377
376   
377   isempty(a::AbstractArray) = (length(a) == 0)
378   
379   ## Conversions ##

About to run: (==)(1,0)

1|debug > 
In promotion.jl:248
247   
248   =={T<:Number}(x::T, y::T) = x === y
249    <{T<:Real}(x::T, y::T) = no_op_err("<" , T)
250   <={T<:Real}(x::T, y::T) = no_op_err("<=", T)

About to run: Base.===

1|debug > 
In promotion.jl:248
247   
248   =={T<:Number}(x::T, y::T) = x === y
249    <{T<:Real}(x::T, y::T) = no_op_err("<" , T)
250   <={T<:Real}(x::T, y::T) = no_op_err("<=", T)

About to run: return false

1|debug > 
In abstractarray.jl:377
376   
377   isempty(a::AbstractArray) = (length(a) == 0)
378   
379   ## Conversions ##

About to run: return false

1|debug > 
In /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:427
432   
433       # TODO: When subplots are given in multiple layers, we should rearrange,
434       # putting the layers in one subplot instead.
435       if sum([isa(layer.geom, Geom.SubplotGeometry) for layer in plot.layers]) > 1
436           error("""
437               Subplot geometries can not be used in multiple layers. Instead

About to run: (getfield)(Gadfly.Plot([Gadfly.Layer(nothing,Dict{Any,Any}(),Gadfly.StatisticElement[],Gadfly.Geom.RectangularBinGeometry(Gadfly.Stat.Histogram2DStatistic(3,150,3,150),Symbol("")),nothing,0)],nothing,Data(
  x=[2.156048746729853,0.043781013542880325,0.3000119308712364,-0.09828362367914963,-0.3033370912755028,-2.196892224265205,0.23457302204862754,-0.967823125791486,1.5642695912345441,-0.057579632614796324]
  y=[0.11217122028073197,1.0212474395300306,-0.3377752295435214,-0.8836106308920646,-1.862793427218974,-0.724814180649498,0.7963097239474038,-1.084543529842187,0.9161830329709968,-0.7611091777582755]
  titles=Dict{Symbol,AbstractString}(Pair{Symbol,AbstractString}(:y,"y"),Pair{Symbol,AbstractString}(:x,"x"))
)
,Gadfly.ScaleElement[],Gadfly.StatisticElement[],nothing,Gadfly.GuideElement[],Gadfly.Theme(LCHab{Float32}(70.0f0,60.0f0,240.0f0),0.9mm,0.3mm,nothing,nothing,nothing,1.0,nothing,5.0mm,RGB{U8}(0.816,0.816,0.878),[0.5mm,0.5mm],RGB{U8}(0.627,0.627,0.627),0.2mm,"'PT Sans Caption','Helvetica Neue','Helvetica',sans-serif",2.822222222222222mm,RGB{U8}(0.424,0.376,0.42),"'PT Sans','Helvetica Neue','Helvetica',sans-serif",3.880555555555555mm,RGB{U8}(0.337,0.29,0.333),"'PT Sans Caption','Helvetica Neue','Helvetica',sans-serif",2.822222222222222mm,RGB{U8}(0.298,0.251,0.294),"'PT Sans','Helvetica Neue','Helvetica',sans-serif",3.880555555555555mm,RGB{U8}(0.212,0.165,0.208),"'PT Sans','Helvetica Neue','Helvetica',sans-serif",2.822222222222222mm,RGB{U8}(0.298,0.251,0.294),40,-0.05mm,1.0mm,3.0mm,Gadfly.default_stroke_color,0.3mm,Gadfly.default_discrete_highlight_color,Gadfly.default_continuous_highlight_color,Gadfly.default_lowlight_color,0.6,Gadfly.default_middle_color,0.6mm,:left,:square,:right,nothing,Function[Compose.circle,Gadfly.square,Gadfly.diamond,Gadfly.cross,Gadfly.xcross,Gadfly.utriangle,Gadfly.dtriangle,Gadfly.star1,Gadfly.star2,Gadfly.hexagon,Gadfly.octagon],2.0mm,1000,10.0,0.5,0.2,4),Dict{Symbol,Any}(Pair{Symbol,Any}(:y,[0.11217122028073197,1.0212474395300306,-0.3377752295435214,-0.8836106308920646,-1.862793427218974,-0.724814180649498,0.7963097239474038,-1.084543529842187,0.9161830329709968,-0.7611091777582755]),Pair{Symbol,Any}(:x,[2.156048746729853,0.043781013542880325,0.3000119308712364,-0.09828362367914963,-0.3033370912755028,-2.196892224265205,0.23457302204862754,-0.967823125791486,1.5642695912345441,-0.057579632614796324]))),layers)

1|debug > 
In array.jl:23
22  
23  length(a::Array) = arraylen(a)
24  elsize{T}(a::Array{T}) = isbits(T) ? sizeof(T) : sizeof(Ptr)
25  sizeof(a::Array) = elsize(a) * length(a)

About to run: Base.arraylen

1|debug > 
In array.jl:23
22  
23  length(a::Array) = arraylen(a)
24  elsize{T}(a::Array{T}) = isbits(T) ? sizeof(T) : sizeof(Ptr)
25  sizeof(a::Array) = elsize(a) * length(a)

About to run: return 1

1|debug > 
In /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:427
432   
433       # TODO: When subplots are given in multiple layers, we should rearrange,
434       # putting the layers in one subplot instead.
435       if sum([isa(layer.geom, Geom.SubplotGeometry) for layer in plot.layers]) > 1
436           error("""
437               Subplot geometries can not be used in multiple layers. Instead

About to run: (Array{T,N})(Any,1)

1|debug > 
In boot.jl:319
318   Array{T}(::Type{T}, d::Int...) = Array{T}(d)
319   Array{T}(::Type{T}, m::Int)               = Array{T,1}(m)
320   Array{T}(::Type{T}, m::Int,n::Int)        = Array{T,2}(m,n)
321   Array{T}(::Type{T}, m::Int,n::Int,o::Int) = Array{T,3}(m,n,o)

About to run: Core.apply_type

1|debug > 
In boot.jl:301
300       ccall(:jl_new_array, Array{T,N}, (Any,Any), Array{T,N}, d)
301   (::Type{Array{T,1}}){T}(m::Int) =
302       ccall(:jl_alloc_array_1d, Array{T,1}, (Any,Int), Array{T,1}, m)
303   (::Type{Array{T,2}}){T}(m::Int, n::Int) =

About to run: Core.cconvert

1|debug > 
In boot.jl:293
292   convert{T}(::Type{T}, x::T) = x
293   cconvert{T}(::Type{T}, x) = convert(T, x)
294   unsafe_convert{T}(::Type{T}, x::T) = x
295   

About to run: Core.convert

1|debug > 
In boot.jl:292
291   convert(::Type{Any}, x::ANY) = x
292   convert{T}(::Type{T}, x::T) = x
293   cconvert{T}(::Type{T}, x) = convert(T, x)
294   unsafe_convert{T}(::Type{T}, x::T) = x

About to run: x

1|debug > 
In boot.jl:292
291   convert(::Type{Any}, x::ANY) = x
292   convert{T}(::Type{T}, x::T) = x
293   cconvert{T}(::Type{T}, x) = convert(T, x)
294   unsafe_convert{T}(::Type{T}, x::T) = x

About to run: return 1

1|debug > 
In boot.jl:293
292   convert{T}(::Type{T}, x::T) = x
293   cconvert{T}(::Type{T}, x) = convert(T, x)
294   unsafe_convert{T}(::Type{T}, x::T) = x
295   

About to run: return 1

1|debug > 
In boot.jl:301
300       ccall(:jl_new_array, Array{T,N}, (Any,Any), Array{T,N}, d)
301   (::Type{Array{T,1}}){T}(m::Int) =
302       ccall(:jl_alloc_array_1d, Array{T,1}, (Any,Int), Array{T,1}, m)
303   (::Type{Array{T,2}}){T}(m::Int, n::Int) =

About to run: (Core.apply_type)(Array{T,N},Any,1)

1|debug > 
In boot.jl:294
293   cconvert{T}(::Type{T}, x) = convert(T, x)
294   unsafe_convert{T}(::Type{T}, x::T) = x
295   
296   typealias NTuple{N,T} Tuple{Vararg{T,N}}

About to run: x

1|debug > 
In boot.jl:294
293   cconvert{T}(::Type{T}, x) = convert(T, x)
294   unsafe_convert{T}(::Type{T}, x::T) = x
295   
296   typealias NTuple{N,T} Tuple{Vararg{T,N}}

About to run: return 1

1|debug > 
In boot.jl:301
300       ccall(:jl_new_array, Array{T,N}, (Any,Any), Array{T,N}, d)
301   (::Type{Array{T,1}}){T}(m::Int) =
302       ccall(:jl_alloc_array_1d, Array{T,1}, (Any,Int), Array{T,1}, m)
303   (::Type{Array{T,2}}){T}(m::Int, n::Int) =

About to run: ((intrinsic function #88))(jl_alloc_array_1d,Array{Any,1},svec(Any,Int64),Array{Any,1},0,1,1)

1|debug > 
In boot.jl:301
300       ccall(:jl_new_array, Array{T,N}, (Any,Any), Array{T,N}, d)
301   (::Type{Array{T,1}}){T}(m::Int) =
302       ccall(:jl_alloc_array_1d, Array{T,1}, (Any,Int), Array{T,1}, m)
303   (::Type{Array{T,2}}){T}(m::Int, n::Int) =

Error showing value of type Gadfly.Plot:
ERROR: UndefRefError: access to undefined reference
 in astcopy(::Array{Any,1}) at ./expr.jl:32 (repeats 2 times)
 in copy(::Expr) at ./expr.jl:25
 in #print_status#14(::Bool, ::Function, ::ASTInterpreter.Interpreter, ::Array{Any,1}) at /home/lobi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:280
 in (::ASTInterpreter.##59#65{ASTInterpreter.Interpreter,ASTInterpreter.InterpreterState,Base.LineEdit.Prompt,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at /home/lobi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1440
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1570
 [inlined code] from ./LineEdit.jl:18
 in RunDebugREPL(::ASTInterpreter.Interpreter) at /home/lobi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1501
 [inlined code] from ./promotion.jl:248
 in (::Gallium.##78#80)(::Gadfly.Plot) at ./<no file>:4294967295
 [inlined code] from /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:913
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/html")}, ::Gadfly.Plot) at /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:1061
 [inlined code] from ./essentials.jl:82
 in display(::Gadfly.Plot) at /home/lobi/.julia/v0.5/Gadfly/src/Gadfly.jl:1013
 in print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:134
 in print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:121
 in (::Base.REPL.##18#19{Bool,Base.REPL.##29#38{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:630
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1570
 in run_frontend(::Base.REPL.LineEditREPL, ::Base.REPL.REPLBackendRef) at ./REPL.jl:881
 in run_repl(::Base.REPL.LineEditREPL, ::Function) at ./REPL.jl:166
 in _start() at ./client.jl:361

Weird module scoping(?) in ``@enter``

Sorry for the uninformative title, but I can't wrap my head around this. using the ForwardDiff package seems to break ASTInterpreter completely:

julia> using Gallium

julia> macroexpand(:(@enter 1+1))
quote  # /Users/huchette/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl, line 1451:
    #1#theargs = (+,1,1) # /Users/huchette/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl, line 1452:
    ASTInterpreter.ASTInterpreter.RunDebugREPL(ASTInterpreter.ASTInterpreter.enter_call_expr(ASTInterpreter.nothing,ASTInterpreter.Expr(:call,#1#theargs...)))
end

julia> using ForwardDiff

julia> macroexpand(:(@enter 1+1))
:($(Expr(:error, MethodError(ForwardDiff.data,(:+,)))))

julia> macroexpand(:(@enter a[2]))
:($(Expr(:error, MethodError(ForwardDiff.data,(:a,)))))

This is on ASTInterpreter/Gallium master (as of this morning), and ForwardDiff v0.1.6. Note that I don't see this behavior on ForwardDiff master. This doesn't happen for other modules I've tested, e.g. DataStructures.

Also, ForwardDiff has a data function, but it's not exported. I'm guessing this is the culprit somehow.

unsupported syntax error while stepping through a generated function

x=rand(2,2); I = [1:2, 1:2]; y=rand(2,2);
function foo(x, I, y)
      Base._unsafe_batchsetindex!(x,y,I...)
end

@enter foo(x,I,y)

julia> @enter foo(x,I,y)
In REPL[9]:2
1 function foo(x, I, y)
2       Base._unsafe_batchsetindex!(x,y,I...)
3 end

About to run: top(_apply)
1|debug > s
In multidimensional.jl:375
374   @generated function _unsafe_batchsetindex!(A::AbstractArray, X, I::Union{Real,AbstractArray,Colon}...)
375       N = length(I)
376       quote
377           @nexprs $N d->(I_d = I[d])

About to run: (length)((1:2,1:2))

1|debug > n
ERROR: unsupported or misplaced expression block
 in _step_expr(::ASTInterpreter.Interpreter) at /home/shashi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:575
 [inlined code] from /home/shashi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:595
 in next_until!(::ASTInterpreter.#call_or_assignment#34, ::ASTInterpreter.Interpreter) at /home/shashi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:611
 in next_line!(::ASTInterpreter.Interpreter) at /home/shashi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:660
 [inlined code] from ./bool.jl:16
 in execute_command(::ASTInterpreter.InterpreterState, ::ASTInterpreter.Interpreter, ::Val{:n}, ::ASCIIString) at /home/shashi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1253
 in (::ASTInterpreter.##58#64{ASTInterpreter.Interpreter,ASTInterpreter.#prompt#62,ASTInterpreter.InterpreterState,Base.LineEdit.Prompt,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at /home/shashi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1314
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1570
 [inlined code] from ./LineEdit.jl:18
 in RunDebugREPL(::ASTInterpreter.Interpreter) at /home/shashi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1414
 in eval(::Module, ::Any) at ./boot.jl:236

I was unable to reproduce it in the small.

Specific use-case

So every once in a while I need to debug an error or segfault in ODBC and it's currently pretty painful because I have to manually step through so many levels of code (user-level, lower-level, API level, etc.). One use-case I thought of watching the presentation today would involve doing something like:

@enterall ODBC.query("select * from table") > output.debug

which would effectively do @enter, then prehood fr v to print the current frame variables for every frame, then si through every frame. Obviously this would generate huge walls of text as you're literally stepping in and through every call and printing the variables at each step, but sometimes that's almost what I want anyway when debugging some hard-to-find segfault. I could print it out and read it on the train in the morning :)

Anyway, I thought I'd post in case this is already trivial or if there's a quick pointer on how to write something like this if only for my own use.

use normal expression printer when we don't have source code

The terminal graphic tree display is really cool but it's too verbose for most purposes. We should just show the expressions the way julia usually does.
Example:

julia> f() = [i+1 for i = 1:2]
f (generic function with 1 method)

julia> @enter f()
Body
├─ none: 1
├─ :(GenSym(0) = (Main.colon)(1,2))
│  ├─ GenSym(0)
│  └─ Call
│     ├─ Main.colon
│     ├─ 1
│     └─ 2
├─ :(GenSym(1) = (top(length))(GenSym(0)))
│  ├─ GenSym(1)
│  └─ Call
│     ├─ top(length)
│     └─ GenSym(0)
├─ 0: 
├─ :(GenSym(2) = (top(Array))($(Expr(:static_typeof, GenSym(3))),GenSym(1)))
│  ├─ GenSym(2)
│  └─ Call
│     ├─ top(Array)
│     ├─ :($(Expr(:static_typeof, GenSym(3))))
│     │  └─ GenSym(3)
│     └─ GenSym(1)
├─ :(#s54 = 1)
│  ├─ #s54
│  └─ 1
├─ :(#s53 = (top(start))(GenSym(0)))
│  ├─ #s53
│  └─ Call
│     ├─ top(start)
│     └─ GenSym(0)
├─ :(#s52 = (top(typeassert))((top(convert))((top(typeof))(GenSym(1)),0),(top(typeof))(GenSym(1))))
│  ├─ #s52
│  └─ Call
│     ├─ top(typeassert)
│     ├─ Call
│     │  ├─ top(convert)
│     │  ├─ Call
│     │  │  ├─ top(typeof)
│     │  │  └─ GenSym(1)
│     │  └─ 0
│     └─ Call
│        ├─ top(typeof)
│        └─ GenSym(1)
├─ 3: 
├─ :(unless (top(!=))(#s52,GenSym(1)) goto 2)
│  ├─ Call
│  │  ├─ top(!=)
│  │  ├─ #s52
│  │  └─ GenSym(1)
│  └─ 2
├─ :(GenSym(4) = (top(+))(#s52,1))
│  ├─ GenSym(4)
│  └─ Call
│     ├─ top(+)
│     ├─ #s52
│     └─ 1
├─ :(#s52 = (top(typeassert))((top(convert))((top(typeof))(GenSym(1)),GenSym(4)),(top(typeof))(GenSym(1))))
│  ├─ #s52
│  └─ Call
│     ├─ top(typeassert)
│     ├─ Call
│     │  ├─ top(convert)
│     │  ├─ Call
│     │  │  ├─ top(typeof)
│     │  │  └─ GenSym(1)
│     │  └─ GenSym(4)
│     └─ Call
│        ├─ top(typeof)
│        └─ GenSym(1)
├─ :(GenSym(5) = (top(next))(GenSym(0),#s53))
│  ├─ GenSym(5)
│  └─ Call
│     ├─ top(next)
│     ├─ GenSym(0)
│     └─ #s53
├─ :(#s51 = (top(start))(GenSym(5)))
│  ├─ #s51
│  └─ Call
│     ├─ top(start)
│     └─ GenSym(5)
├─ :(GenSym(6) = (top(indexed_next))(GenSym(5),1,#s51))
│  ├─ GenSym(6)
│  └─ Call
│     ├─ top(indexed_next)
│     ├─ GenSym(5)
│     ├─ 1
│     └─ #s51
├─ :(i = (top(getfield))(GenSym(6),1))
│  ├─ i
│  └─ Call
│     ├─ top(getfield)
│     ├─ GenSym(6)
│     └─ 1
├─ :(#s51 = (top(getfield))(GenSym(6),2))
│  ├─ #s51
│  └─ Call
│     ├─ top(getfield)
│     ├─ GenSym(6)
│     └─ 2
├─ :(GenSym(7) = (top(indexed_next))(GenSym(5),2,#s51))
│  ├─ GenSym(7)
│  └─ Call
│     ├─ top(indexed_next)
│     ├─ GenSym(5)
│     ├─ 2
│     └─ #s51
├─ :(#s53 = (top(getfield))(GenSym(7),1))
│  ├─ #s53
│  └─ Call
│     ├─ top(getfield)
│     ├─ GenSym(7)
│     └─ 1
├─ :(#s51 = (top(getfield))(GenSym(7),2))
│  ├─ #s51
│  └─ Call
│     ├─ top(getfield)
│     ├─ GenSym(7)
│     └─ 2
├─ :(GenSym(3) = i + 1)
│  ├─ GenSym(3)
│  └─ Call
│     ├─ Main.+
│     ├─ i
│     └─ 1
├─ :($(Expr(:type_goto, 0, GenSym(3))))
│  ├─ 0
│  └─ GenSym(3)
├─ :($(Expr(:inbounds, true)))
│  └─ true
├─ Call
│  ├─ top(setindex!)
│  ├─ GenSym(2)
│  ├─ GenSym(3)
│  └─ #s54
├─ :($(Expr(:inbounds, :(Main.pop))))
│  └─ Main.pop
├─ :(#s54 = (top(+))(#s54,1))
│  ├─ #s54
│  └─ Call
│     ├─ top(+)
│     ├─ #s54
│     └─ 1
├─ 4: 
├─ goto 3
├─ 2: 
├─ 1: 
└─ Return
   └─ GenSym(2)

ASTInterpreter ignores Gallium's breakpoints

Currently I don't see a way to run until the next breakpoint is hit. Am I missing the equivalent of a continue statement? finish is close, but only works within the current function.

more complex interactive expressions don't work

For example

julia> @enter gcd(100,25)
16  function gcd{T<:Union{Int64,UInt64,Int128,UInt128}}(a::T, b::T)
17      a == 0 && return abs(b)
18      b == 0 && return abs(a)
19      za = trailing_zeros(a)

About to run: Base.==
1|julia > for i=1:5;println(i);end
ERROR: BoundsError: attempt to access 0-element Array{Any,1}
  at index [0]
 in getindex(::Array{Any,1}, ::Int64) at ./array.jl:240
 in collectcalls(::LineNumbers.SourceFile, ::Expr, ::JuliaParser.Lexer.SourceNode, ::Bool) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:682
 in process_loctree(::JuliaParser.Lexer.SourceExpr, ::ASCIIString, ::LambdaInfo, ::Bool) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:766
 in (::ASTInterpreter.##55#64)(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1257

Give the ASTInterpreter prompt its own copy of the TTY objects

While stepping through the base printing code, the printing subsystem can get confused because the debug prompt also tries to use it. In order to bypass this, we could create new TTY objects backed by the same file descriptor for use by the debugger.

``@enter`` on type leads to MethodError

julia> type Foo
       x
       end

julia> @enter Foo("bar")
ERROR: MethodError: no method matching length(::LineNumberNode)
 in make_annotations(::ASTInterpreter.##1#3, ::LineNumberNode, ::Expr, ::Bool) at /Users/huchette/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:194 (repeats 2 times)
 in make_shadowtree(::Expr) at /Users/huchette/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:71
 in #enter#5(::Void, ::ASCIIString, ::Any, ::LambdaInfo, ::Expr, ::ASTInterpreter.Environment, ::Array{Any,1}) at /Users/huchette/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:95
 [inlined code] from ./int.jl:32
 in #enter#6(::Array{Any,1}, ::Any, ::Method, ::ASTInterpreter.Environment, ::Array{Any,1}) at /Users/huchette/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:112
 [inlined code] from ./boot.jl:303
 in enter_call_expr(::Void, ::Expr) at /Users/huchette/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:937
 in eval(::Module, ::Any) at ./boot.jl:237

Line Numbers

It would be good to display source line numbers next to the code, esp when lines may be expanded for if lowering, etc.

Triggers nextind depwarn

1|debug >
136       @eval begin
137           ($f)(x::Float64) = nan_dom_err(ccall(($(string(f)),libm), Float64, (Float64,), x), x)
138           ($f)(x::Float32) = nan_dom_err(ccall(($(string(f,"f")),libm), Float32, (Float32,), x), x)
139           ($f)(x::Real) = ($f)(float(x))


WARNING: nextind(a::Any,i::Integer) is deprecated, use i + 1 instead.
 [inlined code] from ./error.jl:26
 in depwarn(::ASCIIString, ::Symbol) at ./deprecated.jl:64
 in nextind(::SimpleVector, ::Int64) at ./deprecated.jl:50
 in nextind(::AbstractTrees.PreOrderDFS, ::Array{Any,1}) at /home/ubuntu/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:364
 in next(::AbstractTrees.PreOrderDFS, ::Array{Any,1}) at /home/ubuntu/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:389
 [inlined code] from /home/ubuntu/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:246
 in treemap!(::ASTInterpreter.##15#21{ASTInterpreter.Interpreter}, ::AbstractTrees.PreOrderDFS) at /home/ubuntu/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:511
 in #print_status#14(::Bool, ::Any, ::ASTInterpreter.Interpreter, ::Array{Any,1}) at /home/ubuntu/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:265
 [inlined code] from /home/ubuntu/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:259
 in (::ASTInterpreter.##done_stepping#53#62)(::Bool, ::Any, ::Base.LineEdit.MIState, ::ASTInterpreter.Interpreter) at /home/ubuntu/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1104
 [inlined code] from ./boot.jl:303
 in (::ASTInterpreter.##54#63)(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at /home/ubuntu/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1150
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1570
 [inlined code] from ./LineEdit.jl:18
 in RunDebugREPL(::ASTInterpreter.Interpreter) at /home/ubuntu/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1335
 [inlined code] from ./boot.jl:303
 in (::Gallium.##16#17)(::Int64) at ./<no file>:4294967295
 [inlined code] from ./none:7
 in inaloop(::Int64) at /home/ubuntu/.julia/v0.5/Gallium/examples/testprograms/misc.jl:6
 in eval(::Module, ::Any) at ./boot.jl:237
while loading no file, in expression starting on line 0
About to run: ((intrinsic function #89))(("sin","libopenlibm"),Float64,svec(Float64),1.0,1.0)

fr v : ERROR: LoadError: MethodError: no method matching print_frame

So.

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-dev+3733 (2016-04-25 14:57 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 64aae5a* (0 days old master)
|__/                   |  x86_64-linux-gnu

julia> using Gallium

julia> Gallium.breakpoint_on_error()
Gallium.Hooking.Hook(Ptr{Void} @0x00007f3a0263a130,UInt8[0x55,0x48,0x89,0xe5,0x53,0x48,0x89,0xfb,0x48,0x83,0xec,0x08,0xe8,0x5f,0x2a,0x02,0x00],Gallium.breakpoint_on_error_hit)

julia> include("perlin.jl")
ERROR: ArgumentError: Winston not found in path.
Run Pkg.add("Winston") to install the Winston package

In loading.jl:317
343           name = string(mod)
344           path = find_in_node_path(name, nothing, 1)
345           if path === nothing
346               throw(ArgumentError("$name not found in path.\nRun Pkg.add(\"$name\") to install the $name package"))
347           end
348           try

1|debug > fr v
ERROR: LoadError: MethodError: no method matching print_frame(::Base.TTY, ::Int64, ::Gallium.NativeStack)
Closest candidates are:
  print_frame(::IO, ::Any, ::ASTInterpreter.Interpreter)
  print_frame(::Any, ::Any, ::Gallium.JuliaStackFrame)
 in execute_command(::ASTInterpreter.InterpreterState, ::Gallium.NativeStack, ::Val{:fr}, ::ASCIIString) at /home/lobi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1199
 in (::ASTInterpreter.##58#64{Gallium.NativeStack})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at /home/lobi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1307
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1570
 [inlined code] from ./LineEdit.jl:18
 in RunDebugREPL(::Gallium.NativeStack) at /home/lobi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1407
 [inlined code] from /home/lobi/.julia/v0.5/Gallium/src/Gallium.jl:46
 in breakpoint_on_error_hit(::Gallium.Hooking.Hook, ::Gallium.X86_64.BasicRegs) at /home/lobi/.julia/v0.5/Gallium/src/Gallium.jl:678
 in _callback(::Ptr{Void}) at /home/lobi/.julia/v0.5/Gallium/src/Hooking/Hooking.jl:150
 in callback(::Ptr{Void}) at /home/lobi/.julia/v0.5/Gallium/src/Hooking/Hooking.jl:184
 in include(::ASCIIString) at ./boot.jl:233
 in include_from_node1(::ASCIIString) at ./loading.jl:426
 in eval(::Module, ::Any) at ./boot.jl:236
while loading /home/lobi/juliarepo/perlin.jl, in expression starting on line 34

julia> Pkg.status()
6 required packages:
 - Cairo                         0.2.31
 - Compose                       0.4.2+             wip-v05-197
 - Fontconfig                    0.0.2
 - Gadfly                        0.4.2+             master
 - Gallium                       0.0.1+             master
 - Gtk                           0.9.3
50 additional packages:
 - ASTInterpreter                0.0.1+             master
 - AbstractTrees                 0.0.1+             master
 - ArrayViews                    0.6.4
 - BinDeps                       0.3.21
 - Calculus                      0.1.14
 - Codecs                        0.1.5
 - ColorTypes                    0.2.2
 - Colors                        0.6.3
 - Compat                        0.7.14
 - Contour                       0.1.0
 - Cxx                           0.0.0-             master (unregistered)
 - DWARF                         0.0.1+             master
 - DataArrays                    0.2.20
 - DataFrames                    0.7.0
 - DataStructures                0.4.4
 - Distances                     0.3.0
 - Distributions                 0.8.10
 - Docile                        0.5.23
 - DualNumbers                   0.2.2
 - ELF                           0.0.1+             master
 - FileIO                        0.0.4
 - FixedPointNumbers             0.1.3
 - FixedSizeArrays               0.1.0
 - GZip                          0.2.18
 - Graphics                      0.1.3
 - Grid                          0.4.0
 - Hexagons                      0.0.4
 - Iterators                     0.1.9
 - JSON                          0.5.0
 - JuliaParser                   0.7.1+             master
 - KernelDensity                 0.1.2
 - Loess                         0.0.6
 - MachO                         0.0.1+             master
 - Measures                      0.0.2
 - NaNMath                       0.2.1
 - ObjFileBase                   0.0.1+             master
 - Optim                         0.4.4
 - PDMats                        0.4.1
 - Reactive                      0.3.2+             master
 - Reexport                      0.0.3
 - SHA                           0.1.2
 - Showoff                       0.0.6+             v05-pr11
 - SortingAlgorithms             0.0.6
 - StatsBase                     0.8.0
 - StatsFuns                     0.2.0
 - StructIO                      0.0.1+             master
 - TerminalUI                    0.0.1+             master
 - URIParser                     0.1.3
 - VT100                         0.0.1+             master
 - WoodburyMatrices              0.1.5

both julia v0.5 and all Pkg updated() recent.

Need to distinguish between variables set to nothing and undefined variables

julia> foo(x) = x
foo (generic function with 1 method)

julia> using ASTInterpreter
WARNING: module Lexer should explicitly import √ from Base

julia> @enter foo(nothing)
Body
├─ none: 1
└─ Return
   └─ x
1|julia > x
ERROR: local variable x not defined
 in error(::ASCIIString) at ./error.jl:21
 in _step_expr(::ASTInterpreter.Interpreter) at /home/ubuntu/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:474
 [inlined code] from /home/ubuntu/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:525
 in #finish!#72(::Bool, ::Bool, ::Any, ::ASTInterpreter.Interpreter) at /home/ubuntu/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1167
 in (::ASTInterpreter.##59#68)(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at /home/ubuntu/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1106
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1611
 [inlined code] from ./LineEdit.jl:18
 in RunDebugREPL(::ASTInterpreter.Interpreter) at /home/ubuntu/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1142
 in eval(::Module, ::Any) at ./boot.jl:267

cc @JeffBezanson

Adjust `for` lowering

For Lowering seems a little awkward. I think it might be better to group next and the second done separately.

Bounds error in print_sourcecode

julia> v = rand(3)
3-element Array{Float64,1}:
 0.854781
 0.587036
 0.414249

julia> io = IOContext(STDOUT, multiline=true, limit=true)
IOContext(Base.TTY(open, 0 bytes waiting))

julia> @enter Base.showarray(io, v)
ERROR: BoundsError: attempt to access 450-element Array{UInt64,1} at index [1500]
 in #print_sourcecode#12(::JuliaParser.LineNumbers.SourceFile, ::Function, ::String, ::Int64, ::Symbol, ::Int32) at /home/tim/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:248
 in (::ASTInterpreter.#kw##print_sourcecode)(::Array{Any,1}, ::ASTInterpreter.#print_sourcecode, ::String, ::Int64, ::Symbol, ::Int32) at ./null:0
 in print_sourcecode(::LambdaInfo, ::String, ::Int64) at /home/tim/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:245
 in #print_status#14(::Bool, ::Function, ::ASTInterpreter.Interpreter, ::Array{Int64,1}) at /home/tim/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:321
 in print_status(::ASTInterpreter.Interpreter) at /home/tim/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:306
 in RunDebugREPL(::ASTInterpreter.Interpreter) at /home/tim/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1614
 in eval(::Module, ::Any) at ./boot.jl:225
 in macro expansion at ./REPL.jl:92 [inlined]
 in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46

stepping in this function skips too much

I can only hit n or s once in this function before it returns:

julia> function f()
        x = 1
        y = 2
       end
f (generic function with 1 method)

julia> @enter f()
Body
├─ none: 2
├─ :(x = 1)
│  ├─ x
│  └─ 1
├─ none: 3
├─ :(y = 2)
│  ├─ y
│  └─ 2
└─ Return
   └─ 2
debug > n
Returning 2

julia> 

ERROR: LoadError: Failed to precompile ASTInterpreter

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-dev+4032 (2016-05-10 19:55 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit c9d4051* (2 days old master)
|__/                   |  x86_64-linux-gnu

julia> Pkg.update()
INFO: Updating METADATA...
INFO: Updating cache of StatsBase...
INFO: Updating cache of Compat...
INFO: Updating cache of StatsFuns...
INFO: Updating cache of Showoff...
INFO: Updating Showoff master...
INFO: Updating Reactive master...
INFO: Updating ELF master...
INFO: Updating Gallium master... 63e3fa82 → 5ccf1d76
INFO: Updating JuliaParser master... 49fd298b → 77e1f403
INFO: Updating Compose master...
INFO: Updating ASTInterpreter master... 2e40b4f8 → db844242
INFO: Updating StructIO master...
INFO: Updating ObjFileBase master...
INFO: Updating VT100 master...
INFO: Updating Gadfly master...
INFO: Updating AbstractTrees master...
INFO: Updating MachO master...
INFO: Updating DWARF master...
INFO: Updating TerminalUI master...
INFO: Updating Cxx master...
INFO: Computing changes...
INFO: Upgrading Compat: v0.7.15 => v0.7.17
INFO: Upgrading StatsBase: v0.8.0 => v0.8.1
INFO: Upgrading StatsFuns: v0.2.0 => v0.2.1
false

julia> using Gallium
INFO: Recompiling stale cache file /home/lobi/.julia/lib/v0.5/Gallium.ji for module Gallium.
INFO: Recompiling stale cache file /home/lobi/.julia/lib/v0.5/ASTInterpreter.ji for module ASTInterpreter.
INFO: Recompiling stale cache file /home/lobi/.julia/lib/v0.5/JuliaParser.ji for module JuliaParser.
INFO: Recompiling stale cache file /home/lobi/.julia/lib/v0.5/Compat.ji for module Compat.
INFO: Recompiling stale cache file /home/lobi/.julia/lib/v0.5/ColorTypes.ji for module ColorTypes.
INFO: Recompiling stale cache file /home/lobi/.julia/lib/v0.5/FixedPointNumbers.ji for module FixedPointNumbers.
INFO: Recompiling stale cache file /home/lobi/.julia/lib/v0.5/Colors.ji for module Colors.
INFO: Recompiling stale cache file /home/lobi/.julia/lib/v0.5/VT100.ji for module VT100.
WARNING: Base.UTF8String is deprecated, use String instead.
  likely near /home/lobi/.julia/v0.5/VT100/src/VT100.jl:114
WARNING: Base.UTF8String is deprecated, use String instead.
  likely near /home/lobi/.julia/v0.5/VT100/src/VT100.jl:227
INFO: Recompiling stale cache file /home/lobi/.julia/lib/v0.5/TerminalUI.ji for module TerminalUI.
INFO: Recompiling stale cache file /home/lobi/.julia/lib/v0.5/Reactive.ji for module Reactive.
WARNING: could not import REPL.MIRepl into TerminalUI
top(typeassert)
Tuple{Int64,Type{Int64}}
ERROR: LoadError: no method found for the specified argument types
while loading /home/lobi/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl, in expression starting on line 1546
ERROR: LoadError: Failed to precompile ASTInterpreter to /home/lobi/.julia/lib/v0.5/ASTInterpreter.ji
 [inlined code] from ./error.jl:21
 in compilecache(::String) at ./loading.jl:505
 in recompile_stale(::Symbol, ::String) at ./loading.jl:581
 in _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:173
 in _require_from_serialized(::Int64, ::Symbol, ::Bool) at ./loading.jl:202
 in require(::Symbol) at ./loading.jl:332
 in include_from_node1(::String) at ./loading.jl:426
 [inlined code] from ./boot.jl:230
 in anonymous at ./<no file>:4294967295
 in eval(::Module, ::Any) at ./boot.jl:230
 [inlined code] from ./sysimg.jl:11
 in process_options(::Base.JLOptions) at ./client.jl:240
 in _start() at ./client.jl:319
while loading /home/lobi/.julia/v0.5/Gallium/src/Gallium.jl, in expression starting on line 3
ERROR: Failed to precompile Gallium to /home/lobi/.julia/lib/v0.5/Gallium.ji
 [inlined code] from ./error.jl:21
 in compilecache(::String) at ./loading.jl:505
 in recompile_stale(::Symbol, ::String) at ./loading.jl:581
 in _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:173
 in _require_from_serialized(::Int64, ::Symbol, ::Bool) at ./loading.jl:202
 in require(::Symbol) at ./loading.jl:332
 in eval(::Module, ::Any) at ./boot.jl:230

If Lowering

The unless that results from an if is currently not given a source location.

Loop iteration stepping mode

A useful additional stepping mode would be to step one iteration of the current loop, landing back at the same statement, but one iteration later.

Help command

Have a simple command (e.g. ? or h) which displays a list of other commands.

Error calling print_shadow

This causes the RunDebugREPL function to fail. The error seems to be down to calling print_trees on the ShadowTree directly in the print_shadowtree method, rather than on its members tree and shadow. print_trees on the ShadowTree seems unsupported due to this error.

julia> ASTInterpreter.print_shadowtree(interp.shadowtree)
Body
ERROR: MethodError: Cannot `convert` an object of type LineNumberNode to an object of type AbstractTrees.Tree
This may have arisen from a call to the constructor AbstractTrees.Tree(...),
since type constructors fall back to convert methods.
Closest candidates are:
  convert{T}(::Type{T}, ::T)
  (::Type{BoundsError})(::ANY)
  (::Type{BoundsError})(::ANY, ::ANY)
  ...
 in (::AbstractTrees.##5#6{AbstractTrees.ShadowTree})(::Tuple{LineNumberNode,AbstractTrees.AnnotationNode{Any}}) at /Users/aviks/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:161
 in map(::Any, ::Base.Zip2{Array{Any,1},Array{AbstractTrees.AnnotationNode{Any},1}}) at ./abstractarray.jl:1107
 [inlined code] from ./iterator.jl:43
 in children(::AbstractTrees.ShadowTree) at /Users/aviks/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:161
 in #_print_tree#2(::Int64, ::Array{Int64,1}, ::AbstractTrees.TreeCharSet, ::Bool, ::Array{Any,1}, ::Void, ::Void, ::Any, ::ASTInterpreter.##9#10{Void}, ::Base.TTY, ::AbstractTrees.ShadowTree, ::Int64) at /Users/aviks/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:110
 [inlined code] from ./boot.jl:331
 in #_print_tree#1(::Array{Any,1}, ::AbstractTrees.#_print_tree, ::Any, ::Base.TTY, ::AbstractTrees.ShadowTree) at /Users/aviks/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:104
 [inlined code] from ./boot.jl:331
 in #print_tree#3(::Array{Any,1}, ::Any, ::Any, ::Base.TTY, ::AbstractTrees.ShadowTree) at /Users/aviks/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:132
 [inlined code] from ./boot.jl:331
 in print_shadowtree(::AbstractTrees.ShadowTree, ::Void, ::Void) at /Users/aviks/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:118
 in print_shadowtree(::AbstractTrees.ShadowTree) at /Users/aviks/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:112
 in eval(::Module, ::Any) at ./boot.jl:267

how should variables in interactive expressions work?

If we support arbitrary expressions at the julia prompt within the debugger, then they can have their own local variables, including compiler-inserted temporary vars. Currently expressions share an environment with the debugged function:

julia> @enter gcd(100,25)
16  function gcd{T<:Union{Int64,UInt64,Int128,UInt128}}(a::T, b::T)
17      a == 0 && return abs(b)
18      b == 0 && return abs(a)
19      za = trailing_zeros(a)

About to run: Base.==
1|julia > foo = 42
42

1|debug > bt
[1] gcd{T<:Union{Int128,Int64,UInt128,UInt64}}(a::T, b::T) at intfuncs.jl:17
  | #self#::Base.#gcd = gcd
  | za = <undefined>
  | k = <undefined>
  | zb = <undefined>
  | T::DataType = Int64
  | u = <undefined>
  | foo::Int64 = 42

Here I was able to add a new variable to the local scope. This might be a feature, but we don't necessarily want this for all variables introduced by the expression, e.g. compiler-inserted vars, and let-bound vars. It's also more difficult to support with the new IR.

Instead, we could give an interactive expression its whole own environment, initialized by starting the code we generate with var = val for each local of the debugged function. Then we run it, and copy certain variables back to the debugged function's environment afterwards.

Segfault in eval

It might not be supported to macroexpand and evaling a macro call with @enter but it probably shouldn't cause a segfault either. On laster commit of this package I get

julia> using DistributedArrays

julia> using Gallium

julia> @enter eval(macroexpand(:(@DArray [1 for i = 1:3, j = 1:3])))
In boot.jl:233
232
233   eval(e::ANY) = eval(Main, e)
234   eval(m::Module, e::ANY) = ccall(:jl_toplevel_eval_in, Any, (Any, Any), m, e)
235

About to run: (eval)(Main,<suppressed 326 bytes of output>)
1|debug > s
In boot.jl:234
233   eval(e::ANY) = eval(Main, e)
234   eval(m::Module, e::ANY) = ccall(:jl_toplevel_eval_in, Any, (Any, Any), m, e)
235
236   kwfunc(f::ANY) = ccall(:jl_get_keyword_sorter, Any, (Any,), f)

About to run: (Core.svec)(Any,Any)
1|debug > n

signal (11): Segmentation fault
while loading no file, in expression starting on line 1700
jl_subtype_le at /home/andreas/julia-dev/src/jltypes.c:2684
jl_f_isa at /home/andreas/julia-dev/src/builtins.c:382
#73 at /home/andreas/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1583
jl_call_method_internal at /home/andreas/julia-dev/src/julia_internal.h:177 [inlined]
jl_apply_generic at /home/andreas/julia-dev/src/gf.c:2027
run_interface at ./LineEdit.jl:1570
jl_call_method_internal at /home/andreas/julia-dev/src/julia_internal.h:177 [inlined]
jl_apply_generic at /home/andreas/julia-dev/src/gf.c:2027
RunDebugREPL at /home/andreas/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1659
jl_call_method_internal at /home/andreas/julia-dev/src/julia_internal.h:177 [inlined]
jl_apply_generic at /home/andreas/julia-dev/src/gf.c:2027
do_call at /home/andreas/julia-dev/src/interpreter.c:66
eval at /home/andreas/julia-dev/src/interpreter.c:190
eval_body at /home/andreas/julia-dev/src/interpreter.c:462
jl_toplevel_eval_flex at /home/andreas/julia-dev/src/toplevel.c:552 [inlined]
jl_toplevel_eval at /home/andreas/julia-dev/src/toplevel.c:580
jl_toplevel_eval_in_warn at /home/andreas/julia-dev/src/builtins.c:576
eval at ./boot.jl:234
jl_call_method_internal at /home/andreas/julia-dev/src/julia_internal.h:177 [inlined]
jl_apply_generic at /home/andreas/julia-dev/src/gf.c:2027
eval_user_input at ./REPL.jl:62
jl_call_method_internal at /home/andreas/julia-dev/src/julia_internal.h:177 [inlined]
jl_apply_generic at /home/andreas/julia-dev/src/gf.c:2027
macro expansion at ./REPL.jl:92 [inlined]
#1 at ./event.jl:46
jl_call_method_internal at /home/andreas/julia-dev/src/julia_internal.h:177 [inlined]
jl_apply_generic at /home/andreas/julia-dev/src/gf.c:2027
jl_apply at /home/andreas/julia-dev/src/julia.h:1394 [inlined]
start_task at /home/andreas/julia-dev/src/task.c:253
unknown function (ip: 0xffffffffffffffff)
Allocations: 15967368 (Pool: 15963236; Big: 4132); GC: 26
[1]    183548 segmentation fault  ./julia

Feature request: finish block command

It would be nice to have a command which finished the current block, i.e. probably most useful to finish the current loop, without having to set a breakpoint after the loop.

BoundsError when printing a local variable

Haven't figured this one out yet:

julia> @enter gcd(100,25)
17      a == 0 && return abs(b)
18      b == 0 && return abs(a)
19      za = trailing_zeros(a)
20  

About to run: Base.==
debug > n
17      a == 0 && return abs(b)
18      b == 0 && return abs(a)
19      za = trailing_zeros(a)
20      zb = trailing_zeros(b)
21  

About to run: 25 == 0

debug > `a
Returning 100
ERROR: BoundsError: attempt to access 0-element Array{Any,1}
  at index [0]
 [inlined code] from ./array.jl:252
 in setindex!(::AbstractTrees.Tree, ::Int64, ::Array{Any,1}) at /home/jeff/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:197
 in setindex!(::AbstractTrees.ShadowTree, ::Tuple{Int64,AbstractTrees.AnnotationNode{Any}}, ::Array{Any,1}) at /home/jeff/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:210
 [inlined code] from /home/jeff/.julia/v0.5/AbstractTrees/src/AbstractTrees.jl:145
 in _evaluated!(::ASTInterpreter.Interpreter, ::Any) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:583
 in _step_expr(::ASTInterpreter.Interpreter) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:514
 [inlined code] from /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:517
 in #finish!#56(::Bool, ::Bool, ::Any, ::ASTInterpreter.Interpreter) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1018
 in (::ASTInterpreter.##51#54)(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:918
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1611
 [inlined code] from ./LineEdit.jl:18
 in RunDebugREPL(::ASTInterpreter.Interpreter) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:993
 in eval(::Module, ::Any) at ./boot.jl:267

History

The history provider is hooked up, but not exposed on the command line.

ERROR: type JuliaStackFrame has no field next_expr

Setup:

using Gallium

Gallium.breakpoint(gcd, Tuple{Int,Int})

f(x) = (y = x+5; gcd(y, 25))

f(100)

After many s commands:

About to run: Base.reinterpret
1|debug > n
70  
71  unsigned(x::Int) = reinterpret(UInt, x)
72  signed(x::UInt) = reinterpret(Int, x)
73  

About to run: return 0x0000000000000069

1|debug > n
20      zb = trailing_zeros(b)
21      k = min(za, zb)
22      u = unsigned(abs(a >> za))
23      v = unsigned(abs(b >> zb))
24      while u != v
25          if u > v

About to run: (>>)(25,0)

1|debug > n
nERROR: type JuliaStackFrame has no field next_expr
 in _evaluated!(::Gallium.JuliaStackFrame, ::Int64) at /home/bezanson/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:595
 [inlined code] from /home/bezanson/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:598
 in finish_until!(::ASTInterpreter.Interpreter, ::ASTInterpreter.Interpreter) at /home/bezanson/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:953
 in (::ASTInterpreter.##54#63)(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at /home/bezanson/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1108
 [inlined code] from ./LineEdit.jl:1099
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1570
 [inlined code] from ./LineEdit.jl:18
 in RunDebugREPL(::ASTInterpreter.Interpreter) at /home/bezanson/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1189
 [inlined code] from /home/bezanson/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:48
 in (::Gallium.##18#19)(::Int64, ::Int64) at ./<no file>:4294967295
 in f(::Int64) at ./none:1
 in eval(::Module, ::Any) at ./boot.jl:243

Step through keyword/optional argument wrappers

I'm not quite sure what to do about this. On the one hand, you probably don't want to see them. On the other hand the optional arguments could have nontrivial code in them. Perhaps step through them in line-stepping mode and do show them when single stepping. Also @JeffBezanson any other such wrappers we should take into account?

Line-based stepping

I believe the basic algorithm should be as follows:

1. Step until you hit a line number node, or a branch
2. If a branch, follow it, check if your new location is a different line, if not goto 1
3. Step until the next call

BoundsError in this code

File test.jl contains:

g() = println(0, 1, (2,3)..., (4,5)...)

I get:

julia> include("test.jl")
g (generic function with 1 method)

julia> @enter g()
ERROR: BoundsError: attempt to access 1-element Array{UInt64,1}:
 0x0000000000000000
  at index [0]
 [inlined code] from ./promotion.jl:240
 in #compute_source_offsets#13(::LineNumbers.SourceFile, ::Any, ::ASCIIString, ::UInt64, ::Int64, ::Int64) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:243
 [inlined code] from ./promotion.jl:135
 in #print_sourcecode#12(::LineNumbers.SourceFile, ::Any, ::LambdaInfo, ::ASCIIString, ::Int64) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:211
 [inlined code] from /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:211
 in #print_status#14(::Bool, ::Any, ::ASTInterpreter.Interpreter, ::Array{Int64,1}) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:258
 in RunDebugREPL(::ASTInterpreter.Interpreter) at /home/jeff/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1329
 in eval(::Module, ::Any) at ./boot.jl:237

Stack Navigation

bt will show the interpreter stack, but it's currently not possible which stack to evaluate expressions in/ which stack frame to step in. This should be fairly easy to add by separating the notion of the active interpreter and the interpreter stack. There is some amount of design that needs to happen around what happens if you say do s while in a higher frame. I'd be inclined to have it pop all the frames above it and continue in that frame, but I'm open to persuasion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.