digitalmars.D.learn - implementing Ketmar's concept of a debugging console in D (Lua/PyD +
Laeeth Isharc <spamnolaeeth nospamlaeeth.com> writes:
Development environments are very personal, and perhaps it's just my age and not always wanting to learn what the kids are using today, but I personally find strategic writeflns more helpful than an IDE for debugging. Still, there comes a point when that isn't enough. Ketmar mentioned that he creates a debugging console that he telnets in to where he can inspect state and perhaps modify it. (And he shared the base version, which he put into public domain). http://forum.dlang.org/post/mailman.210.1412254777.9932.digitalmars-d puremagic.com "most of my reasonably complex software has well-hidden interactive console inside, so i can connect to it to inspect the internal state and execute some (sometimes alot ;-) of internal commands. and i must say that integrating such console in C projects was tiresome. with D i can do it almost automatically, skipping annoying "variable registration" and wrappers for functions." "some naming conventions and one mixin -- and all interesting variables and functions from the given module are automatically registered in command console. so i can inspect and change variables and fields, call free functions and class/struct member functions, even write simple scripts. it's really handy. and i connect to this console using telnet (if telnet support is activated). this also allows some forms of unified "automated testing" even for GUI apps, all without building special "debug versions", i.e. on production code." "it supports UDA annotations for getting help ('cmd ?'), variables and free functions. and please don't blame me, that was the first 'serious' code i did in D, learning D as i writting the module. ;-)" Ketmar - I just wanted to thank you for sharing this idea. Like so many creative insights it's obvious in hindsight and I was kind of getting there anyway via playing with Adam Ruppe's terminal emulator (and his Inspector app built on top of it) and John Colvin's work on putting D in the Jupyter notebook. But it made it much more vivid as to what it should look like. It may not be your cup of tea, but it seems to me that running Lua (or Python) inside a console can be a beautifully simple way to implement this without having to write lots of code for a custom inspector. Adam's work on terminal is quite nice - runs on Linux and Windows (maybe OSX) and it has mouse support and you can display images inline, which can be useful for some purposes. Command history and easy to add shortcuts. Since LuaD (or PyD + pretty PyD) automatically wrap D types, there is no need to do much more to be able to inspect what's going on (perhaps a pretty printer and some way for the script bit to interrupt your loop and get data within relevant scope if you haven't set a 'breakpoint' by calling the debugger from within your code - but you would need to do that anyway). I'm still learning Lua, and not yet very familiar with LuaD. At the moment it segfaults on Lua exceptions - possibly because I set the panic handler wrong, because of some incompatibility with LuaJit (which in theory is just a drop-in for Lua), or am doing something stupid. But the basic idea seems very handy, and you don't need to do anything to wrap most D types. Gist here - just my own proof of concept to convince myself, and it doesn't do much. (I commented out the mouse code for now, and the display of results from Lua is just on top line, which you may not want): https://gist.github.com/Laeeth/086419b7c67d2d6f29db If you type return(tests["date"]) at the command line then you will see the D struct value - no manual wrapping involved. and easy to call a D pretty printer etc - just add the function to the lua state (see examples). You can see how to make better use of the terminal by looking at Ruppe's JSON inspector (also a very useful project) here: https://github.com/adamdruppe/inspector/blob/master/inspect.d LuaD docs and code here: https://jakobovrum.github.io/LuaD/index.html http://github.com/JakobOvrum/LuaD Terminal code here: https://github.com/adamdruppe/terminal-emulator But perhaps some others may find this obvious in hindsight but very useful approach useful for debugging. Laeeth.
Oct 05 2015
Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 5 October 2015 at 19:57:21 UTC, Laeeth Isharc wrote:Adam's work on terminal is quite nice - runs on Linux and Windows (maybe OSX) and it has mouse support and you can display images inline, which can be useful for some purposes. Command history and easy to add shortcuts.The terminal.d works on Mac with limited support as of last weekend (well, full support (minus my extensions) if you install xterm, but limited in the MacOS Terminal because its feature set is poor), but my terminal emulator does not - again, unless you install X11, then it should, because simpledisplay's cocoa implementation is currently broken. But I got a loaner Mac this week and should have it for a while, so I'll port simpledisplay to cocoa sometime in the next month, and then terminalemulator should work fully there too.
Oct 05 2015