JuliaDebug / JuliaDebug/Debugger.jl
Better printing of variables
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 514
- Forks
- 50
- Avg merge
- 9d 9h
- Merged PRs (30d)
- 1
Description
Problem
Consider the following example:
julia> using Debugger, Tensors
julia> function f(x, y)
x′ = norm(x); y′ = norm(y)
return x′ * y′
end
f (generic function with 1 method)
julia> x, y, Z = rand(Vec{2}), rand(Vec{2}), rand(Tensor{4,3});
and lets look at the output when we @enter f:
julia> @enter f(x, y)
In f(x, y) at REPL[2]:2
2 x′ = norm(x); y′ = norm(y)
3 return x′ * y′
4 end
About to run: (LinearAlgebra.norm)([0.3829578398362945, 0.21368249577032006])
and the output of @enter f(Z, y):
julia> @enter f(Z, y)
In f(x, y) at REPL[2]:2
2 x′ = norm(x); y′ = norm(y)
3 return x′ * y′
4 end
About to run: (LinearAlgebra.norm)(<suppressed 1602 bytes of output>)
IMO there are a couple of problems here:
- We don't know what type
[0.3829578398362945, 0.21368249577032006]is, but looks like a regularVector{Float64}, which it isn't. - We don't know which variable
[0.3829578398362945, 0.21368249577032006]corresponds to. - We don't know which
normcall we are about to run (line 2 is highligted though, not visible here but in the REPL). - For "long values", e.g. the second example, we get 0 information.
To answer the questions above we would have to run fr and then compare the values to identify which variable [0.3829578398362945, 0.21368249577032006] corresponds to and then match that to the correct norm call.
Possible solutions
1. Print just the variable
I think that instead of printing the value of the arguments we print the variables, e.g.
About to run: (LinearAlgebra.norm)(x)
which would solve 1, 3 and 4 above, and to find out the type (and value) of x one can use fr, or `x.
2. Print variable and type
In addition to 1. we could print the type of the variables:
About to run: (LinearAlgebra.norm)(x::Vec{3,Float64})
but this can be problematic sometimes since the type of parametric composite types can be very long.
3. Print variables and list values after
Basically 1. but print the variables to the call just after, e.g.
About to run: (LinearAlgebra.norm)(x)
x =
3-element Tensor{1,3,Float64,3}:
0.3827836791790604
0.6323433090863673
0.191605815252049
but again, this can be problematic for functions with many arguments, or if each argument takes up much space when printing.
I think I prefer 1 above. If one needs to investigate the values more carefully it is IMO better to use the ` command anyway.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the @enter f(x, y) and @enter f(Z, y) examples from the issue and inspect the current debugger output. Review the three proposed printing strategies, especially the author's preference, then confirm the chosen behavior for identifying variables, showing their types, and handling long values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100