Skip to content

Commit ef0fd74

Browse files
authored
Fix file we look for source code in (#73)
* fix looking up the source file
1 parent 2155b61 commit ef0fd74

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

Manifest.toml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,25 @@
44
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
55

66
[[CodeTracking]]
7-
deps = ["Test", "UUIDs"]
8-
git-tree-sha1 = "12aa4d41c7926afd7a71af5af603a4d8b94292c2"
7+
deps = ["InteractiveUtils", "UUIDs"]
8+
git-tree-sha1 = "983f5f7a57c604322917ab8bc5b86ba914d3c345"
9+
repo-rev = "master"
10+
repo-url = "https://github.com/timholy/CodeTracking.jl.git"
911
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
10-
version = "0.3.1"
11-
12-
[[Distributed]]
13-
deps = ["Random", "Serialization", "Sockets"]
14-
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
12+
version = "0.3.2"
1513

1614
[[InteractiveUtils]]
1715
deps = ["Markdown"]
1816
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1917

2018
[[JuliaInterpreter]]
2119
deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
22-
git-tree-sha1 = "1057b64c82d57a1b87667995eac5809e15229f4f"
23-
repo-rev = "master"
20+
git-tree-sha1 = "96efbbccc646c629601c1ecd2ef855a85fb3f499"
21+
repo-rev = "b76bc3d3d36a0359ab08db511896fe17645af9fb"
2422
repo-url = "https://github.com/JuliaDebug/JuliaInterpreter.jl"
2523
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
2624
version = "0.1.1"
2725

28-
[[Logging]]
29-
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
30-
3126
[[Markdown]]
3227
deps = ["Base64"]
3328
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
@@ -49,10 +44,6 @@ uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
4944
[[Sockets]]
5045
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
5146

52-
[[Test]]
53-
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
54-
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
55-
5647
[[UUIDs]]
5748
deps = ["Random", "SHA"]
5849
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ authors = ["Kristoffer Carlsson <[email protected]>"]
44
version = "0.1.0"
55

66
[deps]
7+
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
78
JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
89
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
910
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

src/locationinfo.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ end
3535
function locinfo(frame::Frame)
3636
if frame.framecode.scope isa Method
3737
meth = frame.framecode.scope
38-
file, def_line = JuliaInterpreter.whereis(meth)
39-
_, current_line = JuliaInterpreter.whereis(frame)
40-
return loc_for_fname(file, current_line, def_line)
38+
def_file, def_line = JuliaInterpreter.whereis(meth)
39+
current_file, current_line = JuliaInterpreter.whereis(frame)
40+
if def_file != current_file || def_line > current_line
41+
def_line = 0 # We are not sure where the context start in cases like these, could be improved?
42+
end
43+
return loc_for_fname(current_file, current_line, def_line)
4144
else
4245
println("not yet implemented")
4346
end

test/misc.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ execute_command(state, Val{:so}(), "c")
4545

4646
@inline fnothing(x) = 1
4747
frame = @make_frame fnothing(0)
48-
io = IOBuffer()
49-
Debugger.print_next_expr(io, frame)
50-
@test chomp(String(take!(io))) == "About to run: return 1"
48+
@test chomp(sprint(Debugger.print_next_expr, frame)) == "About to run: return 1"
49+
50+
function f()
51+
x = 1 + 1
52+
@info "hello"
53+
end
54+
# https://github.com/JuliaDebug/Debugger.jl/issues/71
55+
frame = Debugger.@make_frame f()
56+
state = dummy_state(frame)
57+
execute_command(state, Val{:n}(), "n")
58+
loc = Debugger.locinfo(state.frame)
59+
@test isfile(loc.filepath)
60+
@test occursin("logging.jl", loc.filepath)

0 commit comments

Comments
 (0)