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

Not proper syntax #274

Closed
DanielRivasMD opened this issue Oct 2, 2020 · 12 comments
Closed

Not proper syntax #274

DanielRivasMD opened this issue Oct 2, 2020 · 12 comments

Comments

@DanielRivasMD
Copy link

DanielRivasMD commented Oct 2, 2020

This is such an awesome tool. However, everytime that I try to use in a complex function (several lines of code, calling other functions or other elements) the synthax goes weird looking like low level code. Not entirely certain what could be the issue

@KristofferC
Copy link
Member

It could be that it fails to look up the source code. If you have an example when this happens we can try to fix it. Also, make sure you are on the latest versions of everything, specifically 1.0.3 of CodeTracking.jl because some bugs with this have been fixed.

@DanielRivasMD
Copy link
Author

DanielRivasMD commented Oct 2, 2020

Thanks for your response. I do have the latest versions of the packages (just checked). Here is the function I was working on now, but this has happened on other similar situations:

function extractChannelSignalBin(channel; binSize = 256, binOverlap = 8)
  # define variables
  stepSize = floor(Int32, binSize / binOverlap)
  signalSteps = 1:stepSize:(channel |> length)
  signalAr = Array{Float64}(undef, (signalSteps |> length), binSize)

  # iterate over signal bins
  for stepIx in 1:(signalSteps |> length)
    signalBoundry = signalSteps[stepIx] + binSize - 1
    # adjust last bin
    if signalBoundry > (channel |> length)
      signalBoundry = (channel |> length)
    end

    # extract signals
    signalAr[stepIx, :] = channel[signalSteps[stepIx]:signalBoundry]
  end
  return signalAr
end

When I enter debug mode where ch is just an array of integers:

julia> @enter x = extractChannelSignalBin(ch)
In ##thunk#374() at REPL[112]:1
>1  1 ─ %1 = (extractChannelSignalBin)(Main.ch)
 2  │        x = %1
 3  └──      return %1

About to run: <(extractChannelSignalBin)(Int16[-227, -367, -224, -352, -249, -140, -126, -72, -141, -214, -200, -144...>
1|debug>

I tried to use debugger on simpler functions, such as calculating the square of an integer, and it works fine.

@KristofferC
Copy link
Member

I put your function in file.jl and it seems to work fine for me:

julia> using Debugger

julia> include("file.jl")
extractChannelSignalBin (generic function with 1 method)

julia> @enter x = extractChannelSignalBin(rand(Int, 5))
In ##thunk#254() at REPL[7]:1
>1  @enter x = extractChannelSignalBin(rand(Int, 5)

About to run: (rand)(Int64, 5)
1|debug> se
In ##thunk#254() at REPL[7]:1
>1  @enter x = extractChannelSignalBin(rand(Int, 5)

About to run: <(extractChannelSignalBin)([-1349184094340749919, 755358142409396267, 2071403546006836726, -6111912452...>
1|debug> s
In #extractChannelSignalBin#2(binSize, binOverlap, , channel) at /home/kc/JuliaTests/file.jl:1
 1  function extractChannelSignalBin(channel; binSize = 256, binOverlap = 8)
 2    # define variables
>3    stepSize = floor(Int32, binSize / binOverlap)
 4    signalSteps = 1:stepSize:(channel |> length)
 5    signalAr = Array{Float64}(undef, (signalSteps |> length), binSize)
 6
 7    # iterate over signal bins

About to run: (/)(256, 8)

@DanielRivasMD
Copy link
Author

DanielRivasMD commented Oct 2, 2020

That is extremely odd. I started a fresh session with no other packages loaded and what you entered exactly. Still get the same result. Any suggestions? Thanks for your time anyway

@pfitzseb
Copy link
Member

pfitzseb commented Oct 2, 2020

What Julia version are you on?

@DanielRivasMD
Copy link
Author

DanielRivasMD commented Oct 2, 2020

julia version 1.5.2

In case this is useful:

  [c7e460c6] ArgParse v1.1.0
  [336ed68f] CSV v0.7.7
  [3895d2a7] CUDAapi v4.0.0
  [da1fd8a2] CodeTracking v1.0.3
  [a93c6f00] DataFrames v0.21.5
  [1313f7d8] DataFramesMeta v0.5.1
  [31a5f54b] Debugger v0.6.6
  [abce61dc] Decimals v0.4.1
  [ccffbfc1] EDF v0.4.2
  [7a1cc6ca] FFTW v1.2.2
  [587475ba] Flux v0.11.1
  [da1fdf0e] FreqTables v0.4.0
  [c27321d9] Glob v1.3.0
  [916415d5] Images v0.22.4
  [50d2b5c4] Lazy v0.15.1
  [eb30cadb] MLDatasets v0.5.2
  [ee78f7c6] Makie v0.11.1
  [5fb14364] OhMyREPL v0.5.5
  [d96e819e] Parameters v0.12.1
  [b98c9c47] Pipe v1.3.0
  [91a5bcdd] Plots v1.6.0
  [c3e4b0f8] Pluto v0.11.14
  [08abe8d2] PrettyTables v0.9.1
  [1a8c2f83] Query v0.12.2
  [612083be] Queryverse v0.6.1
  [6f49c342] RCall v0.13.7
  [b8865327] UnicodePlots v1.1.0
  [0ae4a718] VegaDatasets v2.1.0
  [112f6efa] VegaLite v2.3.0
  [fdbf4ff8] XLSX v0.7.3
  [ade2ca70] Dates

@DanielRivasMD
Copy link
Author

So it seems that Debugger got stuck on lower code. Typing L does not return the proper syntax.

@KristofferC
Copy link
Member

If it can't find the source files it prints lowered code instead. So for some reason, it can't find it on your machine.

@DanielRivasMD
Copy link
Author

Where should it be located? I am on OSX

@timholy
Copy link
Member

timholy commented Oct 5, 2020

It's hard to debug this remotely, so we might need you to poke at this a bit locally. The code to find your source file comes from CodeTracking, so you could test it directly and report back. Debugger's use of CodeTracking is encapsulated in

function locinfo(frame::Frame)
if frame.framecode.scope isa Method
meth = frame.framecode.scope
ret = JuliaInterpreter.whereis(meth)
ret === nothing && return nothing
deffile, _ = ret
ret = JuliaInterpreter.whereis(frame)
ret === nothing && return nothing
current_file, current_line = ret
local body, defline
try # https://github.com/timholy/CodeTracking.jl/issues/31
body, defline = CodeTracking.definition(String, meth)
catch
return nothing
end
if deffile != current_file || defline > current_line
isfile(current_file) || return nothing
body = read(current_file, String)
defline = 0 # We are not sure where the context start in cases like these, could be improved?
end
return defline, current_line, body
else
println("not yet implemented")
end
end

specifically on line 12.

You should also try with and without Revise loaded (before you load the source file you're trying to debug), and let us know which things fail under which conditions. (Most things work better in debugging if you're using Revise.)

@KristofferC
Copy link
Member

Need more info here to do anything.

@DanielRivasMD
Copy link
Author

Well, I tried last comment, but could not figure out how to make it work. Not certain what other information you would require.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants