Skip to content

Commit 9eeb37e

Browse files
authored
improve breakpoint printing (#106)
1 parent dc02ebb commit 9eeb37e

File tree

4 files changed

+25
-35
lines changed

4 files changed

+25
-35
lines changed

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ julia> using Debugger, JuliaInterpreter
6868
julia> breakpoint(abs);
6969

7070
julia> @run sin(2.0)
71-
Hit breakpoint: abs(x::Float64) in Base at float.jl:522, line 522
72-
In abs(x) at float.jl:522
73-
522 abs(x::Float64) = abs_float(x)
74-
523
75-
524 """
71+
Hit breakpoint:
72+
In abs(x) at float.jl
73+
>522 abs(x::Float64) = abs_float(x)
74+
523
75+
524 """
76+
525 isnan(f) -> Bool
77+
526
7678
7779
About to run: (abs_float)(2.0)
7880
1|debug> bt
@@ -94,12 +96,15 @@ julia> break_on(:error)
9496
9597
julia> f() = "αβ"[2];
9698
97-
> @run f()
98-
Breaking on error: string_index_err(s::AbstractString, i::Integer) in Base at strings/string.jl:12, line 12, StringIndexError("αβ", 2)
99-
In string_index_err(s, i) at strings/string.jl:12
100-
12 @noinline string_index_err(s::AbstractString, i::Integer) =
101-
13 throw(StringIndexError(s, Int(i)))
102-
14
99+
julia> @run f()
100+
Breaking for error:
101+
ERROR: StringIndexError("αβ", 2)
102+
In string_index_err(s, i) at strings/string.jl
103+
>12 @noinline string_index_err(s::AbstractString, i::Integer) =
104+
13 throw(StringIndexError(s, Int(i)))
105+
14
106+
15 const ByteArray = Union{Vector{UInt8},Vector{Int8}}
107+
16
103108
104109
About to run: (throw)(StringIndexError("αβ", 2))
105110
1|debug> bt

src/commands.jl

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,12 @@ end
1414
function show_breakpoint(io::IO, bp::BreakpointRef)
1515
outbuf = IOContext(IOBuffer(), io)
1616
if bp.err === nothing
17-
print(outbuf, "Hit breakpoint: ")
17+
print(outbuf, "Hit breakpoint:\n")
1818
else
19-
print(outbuf, "Breaking on error: ")
20-
end
21-
code = bp.framecode
22-
if code.scope isa Method
23-
scope_str = sprint(locdesc, code)
24-
else
25-
scope_str = repr(code.scope)
26-
end
27-
if checkbounds(Bool, bp.framecode.breakpoints, bp.stmtidx)
28-
lineno = linenumber(bp.framecode, bp.stmtidx)
29-
print(outbuf, scope_str, ", line ", lineno)
30-
else
31-
print(outbuf, scope_str, ", %", bp.stmtidx)
32-
end
33-
if bp.err !== nothing
34-
print(outbuf, ", ", bp.err)
19+
print(outbuf, "Breaking for error:\n")
20+
Base.display_error(outbuf, bp.err, [])
3521
end
3622
print(io, String(take!(outbuf.io)))
37-
println(io)
3823
end
3924

4025
function execute_command(state::DebuggerState, ::Union{Val{:c},Val{:nc},Val{:n},Val{:se},Val{:s},Val{:si},Val{:sg},Val{:so}}, cmd::AbstractString)

test/ui.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ end
5353
using TerminalRegressionTests
5454

5555
function run_terminal_test(frame, commands, validation)
56-
#TerminalRegressionTests.automated_test(joinpath(@__DIR__, validation), commands) do emuterm
57-
TerminalRegressionTests.create_automated_test(joinpath(@__DIR__, validation), commands) do emuterm
56+
TerminalRegressionTests.automated_test(joinpath(@__DIR__, validation), commands) do emuterm
57+
#TerminalRegressionTests.create_automated_test(joinpath(@__DIR__, validation), commands) do emuterm
5858
repl = REPL.LineEditREPL(emuterm, true)
5959
repl.interface = REPL.setup_interface(repl)
6060
repl.specialdisplay = REPL.REPLDisplay(repl)

test/ui/history_gcd.multiout

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@
21052105
|
21062106
|About to run: (===)(20, 0)
21072107
|1|debug> c
2108-
|Hit breakpoint: my_gcd(a, b) at ui.jl:5, line 12
2108+
|Hit breakpoint:
21092109
|In my_gcd(a, b) at ui.jl:5
21102110
| 8 zb = trailing_zeros(b)
21112111
| 9 k = min(za, zb)
@@ -2217,7 +2217,7 @@
22172217
|
22182218
|AAAAAAAAAAAAAAAAAAAAAAAAAA
22192219
|EEEEEEEEEA
2220-
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2220+
|AAAAAAAAAAAAAAA
22212221
|AAAAAAAAAAAAAAAAAAAAAAAAAA
22222222
|AAAAAAAAAAAAAAAAAAAAAAAAAAA
22232223
|AAAAAAAAAAAAAAAAAAAA
@@ -2329,7 +2329,7 @@
23292329
|
23302330
|About to run: (===)(20, 0)
23312331
|1|debug> c
2332-
|Hit breakpoint: my_gcd(a, b) at ui.jl:5, line 12
2332+
|Hit breakpoint:
23332333
|In my_gcd(a, b) at ui.jl:5
23342334
| 8 zb = trailing_zeros(b)
23352335
| 9 k = min(za, zb)
@@ -2441,7 +2441,7 @@
24412441
|
24422442
|AAAAAAAAAAAAAAAAAAAAAAAAAA
24432443
|EEEEEEEEEA
2444-
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2444+
|AAAAAAAAAAAAAAA
24452445
|AAAAAAAAAAAAAAAAAAAAAAAAAA
24462446
|AAAAAAAAAAAAAAAAAAAAAAAAAAA
24472447
|AAAAAAAAAAAAAAAAAAAA

0 commit comments

Comments
 (0)