I am back in the game and want to ask some questions regarding debugging support:
What are your current pain points with debugging support?
Is anyone using VS Code with CodeLLDB for debugging, or do you prefer some other IDEs for Crystal?
I am trying to plan my time and help solve the most painful debugging issues before I retool myself for other parts of the project (it could be interpreter or IDE tooling for Crystal or native support for Crystal in LLDB).
Based on what I hear from conducting user interviews, the biggest issue is DX (developer experience), and debugging support, as well as Crystal plugins for popular IDEs, is one of them that may stall the adoption of Crystal by the wider community.
I pretty much use Emacs exclusively for an IDE, and would prefer to use GDB from the command line for a debugger instead of LLDB. But tbh, 95% of the time I just use puts and pp. The biggest issue I run into while debugging is build times vs a binary thatâs actually performant enough to use.
Debug: I debug in GDB directly (Linux). I also tried WinDBG on Windows to debug a segfault, and it just worked. I heard that the integration with the vscode debugger doesnât work (but maybe you need a plugin).
That being said the GDB command line is very powerful but the DX ainât intuitive (must learn all those commands); the SeerGDB GUI is nice but not as powerful as the CLI (of course).
Related: the addition of tracing is helping me a lot. Iâm wondering about adding an app section for anyone to add custom tracing (interleaved with gc, sched, evloop, âŚ).
Tooling: there are good things already, but I heard that Crystal tooling, such as LSP, is ages away from Rust tooling for example.
I used to use vi on the remote shells, but for the last twenty years, I have rarely used it. I use Midnight Commander most of the time, and mcedit is my main editor.
When I started working on Crystal debugging support, I used a lot of logging.
It generated nearly a gigabyte of logs and was nearly impossible to analyze.
When I finally got some working code, I started debugging the debugging support, which greatly sped development up. So, I have been programming for the last 41 years (since I was ten years old).
Debuggers are an important part of my life, so in 2019, I decided to spend the time and implement it to help myself use the Crystal at its full potential.
Usually, compile times are quite fast when compiling with debugging support, as it disables most optimizations.
I use macOS, so gdb does not work there (it hangs OS badly, so you will have to reboot ), so lldb works like a charm.
lldb supplied with macOS does not have Python scripting enabled by default, so you must build your version with enabled Python support.
After that, my scripts started showing Crystal strings and arrays quite properly.
As for tooling, I was planning to spend some time on debugging support improvement and then spend some time on LSP and IDE plugins around it.
Ok, I debug with pp, but if normal debugging would be possible it would be great. I tried to use CodeLLDB on Windows:
thread âmainâ panicked at âcalled Result::unwrap() on an Err value: âCould not load "c:\\Users\\\username\\.vscode\\extensions\\vadimcn.vscode-lldb-1.10.0\\lldb\\bin\\liblldb.dll" (err=0x0000007E)ââ
dll is present on this path and dependencies looks ok (lldb.exe in the same folder runs without error), but i guess something is wrong.
BTW, i followed this post, and tested on a lucky project recently. it works on my arch linux with lldb/llvm 18.1.18, crystal 1.13.2, codelldb plugin version 1.10.0 on code 1.93.1
@ComputerMage something I struggle with debug info is how to access globals, be they constants or class variables. There are no issues with local vars and args, but Iâm at a complete loss with inspecting globalsâŚ
Great to hear from you!
I did a brief investigation, and I can see that you can see some of the class/static variables, but not in the way you expect.
LLDB does not know how to parse Crystal syntax for the class:
(lldb) p String::CHAR_TO_DIGIT62:const_init
error: <user expression 105>:1:9: no member named 'CHAR_TO_DIGIT62' in 'String'
1 | String::CHAR_TO_DIGIT62:const_init
| ~~~~~~~~^
so I will investigate further if I can access it via python API.