Hello internals
I've always found tooling to be one of the biggest accelerators for understanding what is going on in a codebase, assuming you know how to use them. If you've ever tried modifying the language AST and friends, you know this can be extremely tricky at times.
For those that want to hack on the languages itself, I've been working on an AST debugging tool running on top of GDB. This allows you to hack on the language, recompile, and see how it affects the PHP compilation. Under the hood, it is really just automated breakpoints and outputting usefulish details... it's not too special. Most of the complexity comes in outputting something that makes sense to a human.
Here's a brief animation of it working: https://asciinema.org/a/u9oOUvX5eoha93YJWJ5gX2gCb (yes, I'm manually stepping through the code, but this sped up)
There's still a long way to go here, but it really helps to see the yacc rules matching and being applied, or AST being skipped and causing a memory leak. You can even break into a normal gdb session at any point, if needed.
I plan to open this up on GitHub within the next couple of weeks. There are some parts that are still a mess that I want to clean up before sharing the code with the world (and a few bugs in the AST view), as well as adding opcodes output.
So, far, I've used it to hunt down my own bugs and grok newer features, like property hooks (you can see that one here: https://asciinema.org/a/OPZzW2oBr2o8AuOu9YbsBBGap).
Does anything like this exist currently? Would anyone else find this useful?
— Rob
Would anyone else find this useful?
— Rob
Anything that aids the developer experience is a big win!
One of the best things about PHP is Xdebug.
Keep going!
Cheers,
Bilge