I am very new in crystal language. I would like to know if a debugger like Ruby's Pry exists in Crystal?
It means that you can put in code something like 'binding.pry' at program stop execution at this line and let you control of variables.
Pry is like IRB on steroids Both IRB and Pry use REPL commands: Read, Evaluate, Print, and Loop. But Pry allows you to go further when debugging. For example, Pry gives you color-coded syntax, which helps when you're trying to figure out what will happen when code is executed.
So when you place the line binding. pry in your code, that line will get interpreted at runtime (as your program is executed). When the interpreter hits that line, your program will actually freeze and your terminal will turn into a REPL that exists right in the middle of your program, wherever you added the binding.
Although very incomplete, there is support for LLDB.
You may add debugger
anywhere in your code to initiate a breakpoint for LLDB to stop at. You should (must?) build a binary with the -d
or --debug
flag, then run it using LLDB:
$ crystal build -d foo.cr
$ lldb ./foo
(lldb) run
See https://groups.google.com/forum/m/#!topic/crystal-lang/gRf-yDNdZ-Y for a more detailed example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With