Skip to content

Commit 23f1561

Browse files
committed
Rename all the things
1 parent 6bd2cb9 commit 23f1561

7 files changed

+63
-49
lines changed

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
# Commands
88

9-
`@iron_debug foo()`: run `foo()` inside the debugger.
9+
`@run foo()`: run `foo()` inside the debugger.
1010
When a breakpoint is hit, then you will be given an Iron REPL to work with-in,
1111
allowing you to view/manipulate the arguments.
12+
`@enter foo()` performs similarly, after immediately breaking on the first line.
1213

1314
Within this you can read (and write) variables,
1415
- Step-Next: to move to the next IR statement
@@ -21,12 +22,12 @@ Within this you can read (and write) variables,
2122

2223
- `set_breakpoint!([function|method])`: Set a breakpoint on call to the argument
2324
- `set_breakpoint!(filename, line number)`: Set a breakpoint on the given line in the given function
24-
- `set_nodebug!([function|module])`: Disable debugging in the given function/module
25+
- `set_uninstrumented!([function|module])`: Disable debugging in the given function/module
2526
- Not having debugging enabled for modules/functions you do not need to debug massively speeds up the running of your program.
2627
- However, debugging is fully disabled for those modules/functions, so if those functions would then call functions you do want to debug (say by using `map`) then that will also not be caught by the debugger.
27-
- `list_breakpoints()`, `list_nodebugs()`: list all the breakpoints/nodebugs
28-
- `rm_breakpoint!(arg...)`, `rm_nodebug!(args...)`: remove breakpoints/nodebugs. Takes same arguments as `set_...`.
29-
- `clear_breakpoints!()`, `clear_nodebugs!()`: remove all breakpoints/nodebugs.
28+
- `list_breakpoints()`, `list_uninstrumenteds()`: list all the breakpoints/uninstrumenteds
29+
- `rm_breakpoint!(arg...)`, `rm_uninstrumented!(args...)`: remove breakpoints/uninstrumenteds. Takes same arguments as `set_...`.
30+
- `clear_breakpoints!()`, `clear_uninstrumenteds!()`: remove all breakpoints/uninstrumenteds.
3031

3132

3233
[![asciicast](https://asciinema.org/a/DxgPaaLQQYVV5xXCMuwF5Aa36.svg)](https://asciinema.org/a/DxgPaaLQQYVV5xXCMuwF5Aa36)

src/MagneticReadHead.jl

+27-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using CodeTracking
99
using Revise: Revise
1010
using OrderedCollections
1111

12-
export @iron_debug
12+
export @run, @enter
1313

1414

1515
include("utils.jl")
@@ -29,20 +29,33 @@ include("breakpoints.jl")
2929

3030
struct UserAbortedException <: Exception end
3131

32-
33-
macro iron_debug(body)
34-
quote
35-
ctx = HandEvalCtx($(__module__), StepContinue)
36-
try
37-
return Cassette.recurse(ctx, ()->$(esc(body)))
38-
catch err
39-
err isa UserAbortedException || rethrow()
40-
nothing
41-
finally
42-
# Disable any stepping left-over
43-
ctx.metadata.stepping_mode = StepContinue
44-
end
32+
function iron_debug(body, _module, mode)
33+
ctx = HandEvalCtx(_module, mode)
34+
try
35+
return Cassette.recurse(ctx, body)
36+
catch err
37+
err isa UserAbortedException || rethrow()
38+
nothing
39+
finally
40+
# Disable any stepping left-over
41+
ctx.metadata.stepping_mode = StepContinue
4542
end
4643
end
4744

45+
"""
46+
@run the_code
47+
Run until the_code until a breakpoint is hit.
48+
"""
49+
macro run(body)
50+
:(iron_debug(()->$(esc(body)), $(__module__), StepContinue))
51+
end
52+
53+
"""
54+
@enter the_code
55+
Begin debugging and break on the start of the_code.
56+
"""
57+
macro enter(body)
58+
:(iron_debug(()->$(esc(body)), $(__module__), StepContinue))
59+
end
60+
4861
end # module

src/breakpoints.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ function set_breakpoint!(the_rules::BreakpointRules, args...)
2525
return append!(the_rules.breakon_rules, rules(args...))
2626
end
2727

28-
function set_nodebug!(the_rules::BreakpointRules, arg::T) where T
28+
function set_uninstrumented!(the_rules::BreakpointRules, arg::T) where T
2929
T !== Method || throw(ArgumentError("Disabling instrumentation per method, is not supported."))
3030
return push!(the_rules.no_instrument_rules, Rule(arg))
3131
end
3232

33-
for (name, list) in ((:breakpoint, :breakon_rules), (:nodebug, :no_instrument_rules))
33+
for (name, list) in ((:breakpoint, :breakon_rules), (:uninstrumented, :no_instrument_rules))
3434
set! = Symbol(:set_, name, :!)
3535
@eval export $(set!)
3636
@eval $(set!)(args...) = $(set!)(GLOBAL_BREAKPOINT_RULES, args...)
@@ -47,7 +47,7 @@ for (name, list) in ((:breakpoint, :breakon_rules), (:nodebug, :no_instrument_ru
4747
end
4848
return the_rules.$list
4949
end
50-
50+
5151
list_all = Symbol(:list_, name,:s)
5252
@eval export $(list_all)
5353
@eval $(list_all)()=$(list_all)(GLOBAL_BREAKPOINT_RULES)

src/inner_repl.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ end
1818
###############
1919

2020
function get_user_input(io=stdin)
21-
printstyled("iron>"; color=:light_red)
22-
21+
printstyled("debug> "; color=:light_red)
22+
2323
ast = nothing
2424
line = ""
2525
while true

test/setup_ui_test_module.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function reset_patched_functions!()
6060
@eval MagneticReadHead function breakpoint_hit(meth, statement_ind)
6161
return nothing
6262
end
63-
63+
6464
@eval MagneticReadHead function better_readline(io)
6565
# This is not technically the same as the better_readline defined in utils
6666
# but we will only be doing automated tests so that doesn't matter.

test/test_behavour.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ end
1010

1111
@testset "Should not block throwing errors" begin
1212
foo() = throw(DemoException())
13-
@test_throws(DemoException, (@iron_debug foo()))
13+
@test_throws(DemoException, (@run foo()))
1414

1515

1616
bar() = map(_->foo(), 1:10)
17-
@test_throws(DemoException, (@iron_debug foo()))
17+
@test_throws(DemoException, (@run bar()))
1818
end

test/test_ui.jl

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
include("setup_ui_test_module.jl")
22

3-
clear_breakpoints!(); clear_nodebugs!()
3+
clear_breakpoints!(); clear_uninstrumenteds!()
44
#@testset "No breakpoints" begin
55
make_readline_patch([])
66
record = make_recording_breakpoint_hit_patch()
77

8-
@iron_debug eg1()
8+
@run eg1()
99
@test record == []
1010
#end
1111

@@ -15,96 +15,96 @@ clear_breakpoints!(); clear_nodebugs!()
1515
set_breakpoint!(eg2)
1616

1717
@show list_breakpoints()
18-
@iron_debug eg1()
18+
@run eg1()
1919
@test first(record).f == eg2
2020
#end
2121

22-
clear_breakpoints!(); clear_nodebugs!()
22+
clear_breakpoints!(); clear_uninstrumenteds!()
2323
#@testset "Two breakpoints" begin
2424
make_readline_patch(["CC", "CC"])
2525
record = make_recording_breakpoint_hit_patch()
2626
set_breakpoint!(eg2)
2727
set_breakpoint!(eg3)
28-
@iron_debug eg1()
28+
@run eg1()
2929
@test first.(record) == [eg2, eg3]
3030
#end
3131

3232
###################################################
33-
clear_breakpoints!(); clear_nodebugs!()
33+
clear_breakpoints!(); clear_uninstrumenteds!()
3434
#@testset "No breakpoints, With no instrumenting of Base" begin
3535
make_readline_patch([])
3636
record = make_recording_breakpoint_hit_patch()
37-
set_nodebug!(Base)
38-
@iron_debug eg1()
37+
set_uninstrumented!(Base)
38+
@run eg1()
3939
@test record == []
4040
#end
4141
###########################
4242

43-
clear_breakpoints!(); clear_nodebugs!()
43+
clear_breakpoints!(); clear_uninstrumenteds!()
4444
#@testset "breakpoint by file and linenum" begin
4545
make_readline_patch(["CC"])
4646
record = make_recording_breakpoint_hit_patch()
4747

4848
set_breakpoint!("demo.jl", 9)
4949
@test !isempty(list_breakpoints())
50-
@iron_debug eg1()
50+
@run eg1()
5151
@test first.(record) == [eg2]
5252
#end
5353

5454

5555
#########################################################
5656
# Stepping Mode
5757

58-
clear_breakpoints!(); clear_nodebugs!()
58+
clear_breakpoints!(); clear_uninstrumenteds!()
5959
#@testset "step in" begin
6060
make_readline_patch(["SI", "CC"])
6161
record = make_recording_breakpoint_hit_patch()
6262

6363
set_breakpoint!(eg2)
64-
@iron_debug eg1()
64+
@run eg1()
6565
@test first.(record) == [eg2, eg21]
6666
#end
6767

68-
clear_breakpoints!(); clear_nodebugs!()
68+
clear_breakpoints!(); clear_uninstrumenteds!()
6969
#@testset "step out" begin
7070
set_breakpoint!(eg2)
7171
make_readline_patch(["SO", "CC"])
7272
record = make_recording_breakpoint_hit_patch()
7373

74-
@iron_debug eg1()
74+
@run eg1()
7575
@test first.(record) == [eg2, eg1]
7676
#end
7777

7878

79-
clear_breakpoints!(); clear_nodebugs!()
79+
clear_breakpoints!(); clear_uninstrumenteds!()
8080
#@testset "step next" begin
8181
set_breakpoint!(eg2)
8282
make_readline_patch(["SN", "SN", "CC"])
8383
record = make_recording_breakpoint_hit_patch()
8484

85-
@iron_debug eg1()
85+
@run eg1()
8686
@test first.(record) == [eg2, eg2, eg2]
8787
#end
8888

8989

9090
###############################################
91-
clear_breakpoints!(); clear_nodebugs!()
91+
clear_breakpoints!(); clear_uninstrumenteds!()
9292
#@testset "Influence calling enviroment" begin
9393
global zzz = 10
9494
make_readline_patch(["zzz = 20", "CC"])
9595

9696
set_breakpoint!(eg2)
97-
@iron_debug eg1()
97+
@run eg1()
9898
@test zzz==20
9999
#end
100100

101101

102-
clear_breakpoints!(); clear_nodebugs!()
102+
clear_breakpoints!(); clear_uninstrumenteds!()
103103
#@testset "Abort" begin
104104
make_readline_patch(["XX"])
105105

106106
set_breakpoint!(eg2)
107-
@test nothing==@iron_debug eg1()
107+
@test nothing==@run eg1()
108108
#end
109109

110110
########################################
@@ -116,12 +116,12 @@ function var_demo1(x)
116116
z=1
117117
end
118118

119-
clear_breakpoints!(); clear_nodebugs!()
119+
clear_breakpoints!(); clear_uninstrumenteds!()
120120
#@testset "Variables stepping" begin
121121
set_breakpoint!(var_demo1)
122122
make_readline_patch(["SN", "SN", "SN", "CC"])
123123
record = make_recording_breakpoint_hit_patch()
124-
@iron_debug var_demo1(5)
124+
@run var_demo1(5)
125125

126126
@test record[1].variables == LittleDict(:x=>5)
127127
@test record[2].variables == LittleDict(:x=>5, :z=>10)

0 commit comments

Comments
 (0)