Skip to content

Commit

Permalink
Merge pull request #37 from timholy/teh/perf_trackbase
Browse files Browse the repository at this point in the history
Update for recent changes/opportunities in Revise
  • Loading branch information
timholy authored Aug 28, 2018
2 parents 13579d7 + 826f945 commit 1b025bf
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
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

0 comments on commit 1b025bf

Please sign in to comment.