panifie / PingPong.jl

Cryptocurrency trading bot, and backtesting framework in julia
https://panifie.github.io/PingPong.jl/
GNU General Public License v3.0
36 stars 9 forks source link

[Help] How to debug(stepinto) in vscode? #51

Closed janckerchen closed 1 week ago

janckerchen commented 1 week ago

I tried debugging the code in VS Code, but I can't step into the code either by setting breakpoints or using the @enter macro. What configuration is needed? (The environment variables in .envrc can be inherited by launching VS Code from the terminal.)

using PingPong
using Data: Data as data
using SimMode: SimMode as sm

@environment!
s = st.strategy(:SimpleStrategy, exchange=:binance) 

# step into failed
@enter fetch_ohlcv(s, from=-1000) 
# step into failed
@enter load_ohlcv(s)
# step into failed
@enter sm.start!(s)
janckerchen commented 1 week ago

Removing julia.debuggerDefaultCompiled from settings.json of vscode and keeping the default configuration can resolve this issue. ALL_MODULES_EXCEPT_MAIN prevents the debugger from entering all modules except the main program.

"julia.debuggerDefaultCompiled": [    
        "ALL_MODULES_EXCEPT_MAIN",  
....
panbonker commented 1 week ago

it seems also that the logging wrapper prevents setting breakpoints inside the anon function https://github.com/panifie/PingPong.jl/blob/3326d57cc8b8fcaeb66e5fc8b2d1c6a5342837dd/SimMode/src/backtest.jl#L49

not sure what to do with this

janckerchen commented 1 week ago

@panbonker found the solution for

it seems also that the logging wrapper prevents setting breakpoints inside the anon function not sure what to do with this

  1. cmd+,, open vscode setting
  2. search julia.debuggerDefaultCompiled
  3. click Edit in settings.jon, vscode will open settings.json and auto append julia.debuggerDefaultCompiled and its default value.
  4. add -Base.CoreLogging as screenshot
image
  1. restart vscode(dont know why), now breakpoint is activated in the with_logger() wrapper
image