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

Update for recent changes/opportunities in Revise #37

Merged
merged 3 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
HeaderREPLs = "≥0.2.0"
Revise = "≥0.6.9"
Revise = "≥0.7.3"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
julia 0.7
Revise 0.6.9
Revise 0.7.3
HeaderREPLs 0.2
15 changes: 12 additions & 3 deletions src/debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function pregenerated_stacktrace(trace; topname = :capture_stacktrace)
end
else
method ∈ methodsused && continue
def = Revise.get_def(method)
def = Revise.get_def(method; modified_files=String[])
def isa ExLike || continue
push!(defs, def)
push!(usrtrace, method)
Expand Down Expand Up @@ -370,6 +370,7 @@ The returned `uuid` can be used for accessing the stored data.
function method_capture_from_callee(method, def; overwrite::Bool=false)
uuid = get(storemap, (method, overwrite), nothing)
uuid != nothing && return uuid
def = pop_annotations(def)
sigr, body = get_signature(def), unquote(funcdef_body(def))
sigr == nothing && throw(SignatureError(method))
sigex = convert(Expr, sigr)
Expand Down Expand Up @@ -425,7 +426,7 @@ function method_capture_from_callee(method; kwargs...)
# Could use a default arg above but this generates a more understandable error message
local def
try
def = get_def(method)
def = get_def(method; modified_files=String[])
catch err
throw(DefMissing(method, err))
end
Expand All @@ -437,7 +438,7 @@ function generate_let_command(method::Method, uuid::UUID)
s = stored[uuid]
@assert method == s.method
argstring = '(' * join(s.varnames, ", ") * (length(s.varnames)==1 ? ",)" : ')')
body = convert(Expr, striplines!(deepcopy(funcdef_body(get_def(method)))))
body = convert(Expr, striplines!(deepcopy(funcdef_body(get_def(method; modified_files=String[])))))
return """
@eval $(method.module) let $argstring = Main.Rebugger.getstored(\"$uuid\")
$body
Expand Down Expand Up @@ -577,6 +578,14 @@ function rename_method!(ex::ExLike, name::Symbol, callerobj)
end
rename_method(ex::ExLike, name::Symbol, callerobj) = rename_method!(copy(ex), name, callerobj)

function pop_annotations(def::ExLike)
while Revise.is_trivial_block_wrapper(def) || (
def isa ExLike && def.head == :macrocall && def.args[1] ∈ Revise.poppable_macro)
def = def.args[end]
end
def
end

# Use to re-evaluate an expression without leaving "breadcrumbs" about where
# the eval is coming from. This is used below to prevent the re-evaluaton of an
# original method from being attributed to Rebugger itself in future backtraces.
Expand Down
5 changes: 4 additions & 1 deletion src/ui.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ function stepin(s::LineEdit.MIState)
repl.header.warnmsg = "Expression at point is not a call expression"
handled = true
elseif err isa EvalException
repl.header.errmsg = "$(typeof(err.exception)) exception while evaluating $(err.exprstring)"
io = IOBuffer()
showerror(io, err.exception)
errstr = String(take!(io))
repl.header.errmsg = "$errstr while evaluating $(err.exprstring)"
handled = true
elseif err isa DefMissing
repl.header.errmsg = "The expression for method $(err.method) was unavailable. Perhaps it was untracked or generated by code."
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Base.show(io::IO, ::ErrorsOnShow) = throw(ArgumentError("no show"))
@test Rebugger.stored[uuid2].varvals == ([8,9], 2, "13", Int, 0, empty_kwvarargs, Vector{Int}, Int)

def = quote
modifies!(x) = (x[1] += 1; x)
@inline modifies!(x) = (x[1] += 1; x)
end
f = Core.eval(RebuggerTesting, def)
@test f([8,9]) == [9,9]
Expand Down