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

Make @enter not go into the Debugger source. #64

Merged
merged 4 commits into from
Jul 14, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
23 changes: 18 additions & 5 deletions src/MagneticReadHead.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,24 @@ end
Begin debugging and break on the start of the_code.
"""
macro enter(body)
quote
ctx = HandEvalCtx($(__module__), StepContinue)
iron_debug(ctx) do
ctx.metadata.stepping_mode = StepIn
$(esc(body))
if body isa Expr && body.head==:call && body.args[1] isa Symbol
body = MacroTools.striplines(body)
#break_target = body.args[1] #
break_target = :(InteractiveUtils.which($(body.args[1]), Base.typesof($(body.args[2:end])...)))
quote
ctx = HandEvalCtx($(__module__), StepContinue)
set_breakpoint!($(esc(break_target)))
try
iron_debug(ctx) do
$(esc(body))
end
finally
rm_breakpoint!($(esc(break_target)))
end
end
else
quote
error("Expression too complex to `@enter`. Please use `@run` with manual breakpoint set")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/breakpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ for (name, list) in ((:breakpoint, :breakon_rules), (:uninstrumented, :no_instru
@eval function $(rm!)(the_rules::BreakpointRules, args...)
old_num_rules = length(the_rules.$list)
to_remove = rules(args...)
filter!(x->x∈to_remove, the_rules.$list)
filter!(!in(to_remove), the_rules.$list)
if length(the_rules.$list) == old_num_rules
@info("No matching $($name) was found, so none removed")
@info("No matching rule was found, so none removed")
end
return the_rules.$list
end
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test_files = (
"test_behavour.jl",
"test_breadcrumbs.jl",
"test_breakpoint_rules.jl",
"test_breakpoints.jl",
"test_inner_repl.jl",
"test_locate.jl",
"test_method_utils.jl",
Expand Down
10 changes: 10 additions & 0 deletions test/test_breakpoints.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using MagneticReadHead
using Test

@testset "Should be able to add and remove breakpoints" begin
@test length(set_breakpoint!(Test)) == 1
@test length(rm_breakpoint!(Test)) == 0

@test length(set_uninstrumented!(Test)) == 1
@test length(rm_uninstrumented!(Test)) == 0
end
22 changes: 22 additions & 0 deletions test/test_ui.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ clear_breakpoints!(); clear_uninstrumenteds!()
@test first.(record) == [eg2, eg2, eg2]
#end

###############################################

clear_breakpoints!(); clear_uninstrumenteds!()
#@testset "@enter" begin
make_readline_patch(["CC"])
record = make_recording_breakpoint_hit_patch()

@enter eg1()
@test first.(record) == [eg1]
@test isempty(list_breakpoints())
#end

clear_breakpoints!(); clear_uninstrumenteds!()
#@testset "@enter, too complex" begin
make_readline_patch(["CC"])
record = make_recording_breakpoint_hit_patch()

@test_throws ErrorException (@enter (()->eg1())())
@test isempty(list_breakpoints())
#end



###############################################
clear_breakpoints!(); clear_uninstrumenteds!()
Expand Down