0

I'm new to Julia, version 1.39.1, and trying to debug a toy example function using the Juno IDE (Atom). I was able to get the example in this documentation working but could not figure out how to start the debugger on my Julia script or my function. This site seemed promising but the example image is broken. Related question.

I've tried using the Juno.@enter(outer_prod([1,2,3],[1,1,1])) to no avail.

How can I use the debugger on my script or on my function?

enter image description here

pproctor
  • 101
  • 1
  • 10
  • What version of Julia and Juno are you using? The `Juno` menu should have a `Debug Information` entry that should contain all relevant information. FWIW, your exact example (entering the debugger with `Juno.@enter` is correct) works fine for me. – pfitzseb Jan 13 '20 at 08:46
  • Julia(1.39.1), Juno(1.2.0-1). When I enter in the REPL `Juno.@enter(outer_prod([1, 2, 3],[1, 1, 1])) ERROR: UndefVarError: outer_prod not defined`. – pproctor Jan 14 '20 at 04:06
  • Ok I got it working now, I put `Juno.@enter(outer_prod(x,y))` at the end of my Julia script. Before I was trying to enter that command in REPL. I'll post what I've done as an answer and you can let me know if this is the correct way to use the debugger. – pproctor Jan 14 '20 at 04:13
  • 1
    `Juno.@enter` shouldn't be used in scripts. I suspect your code is in a module, but the REPL isn't set to that module. So either properly qualify `outer_prod` (e.g. `Juno.@enter(MyModule.outer_prod(x,y))` or set the REPL to the correct module (there's an indicator in the lower right). – pfitzseb Jan 14 '20 at 08:50
  • Ok great your suggestion to properly qualify the module worked, thank you. I thought the debugger might operate similarly to Matlab but it seems like only functions can be debugged – pproctor Jan 15 '20 at 05:06
  • Yes, but you can just step through top-level scripts with `Ctrl-Enter`, so there's not as much need for a debugger there. – pfitzseb Jan 15 '20 at 09:27

3 Answers3

0

If you want to learn debugging on Juno, start with something simple

function foo(x,y)
    z = x + y
    return z
end

step 1. Very important! Save the file in Juno

step 2. press the "stop" button to stop the existing Julia process

step 3. press the "play" button to run the file

step 4. type this on the REPL

Juno.@enter foo(2,3)

step 5. Use the debugger pane on Juno

Steven Siew
  • 843
  • 8
  • 11
0

As @pfitzseb suggested in the question comments, you must qualify your function with it's module (basically the script that the function is in) in order to start debugging with REPL. The current working module can be found in the lower right hand corner of the Juno IDE. The command to debug a function in a specific module is Juno.@enter(MyModule.func_name(args))

pproctor
  • 101
  • 1
  • 10
-1

@enter is not a function, but a macro. Simply remove the parenthesis after it and add a space: @enter foo() instead of @enter(foo()). In the debugger you can then get help of what to do by typing help.

Jakob Nissen
  • 1,981
  • 7
  • 7
  • 2
    Calling macros with parenthesis is completely valid: `Meta.parse("@foo(2)") == Meta.parse("@foo 2")` is true. In some cases it's also very useful because parens-less macro invocations are very whitespace-sensitive. – pfitzseb Jan 13 '20 at 08:43