I’ve been busy filling in stubs recently, but something didn’t feel right. The stubs all say Unimplemented() — and that was calling itself. I’d been working towards the short term goal of getting Unimplemented() to work when I discovered that what lay beneath Unimplemented() and assert() was the most complicated error handling and debugging system in the world.

First it scans the command line to see if you told it to ignore the particular error it’s trying to report. Then it prints a message to tell you the command line options to make it skip that particular error. Then it checks to see if this is the first error it’s seen, if any other threads are trying to report errors, if any other threads are trying to report this particular error, whether this particular error is being reported as the first error by another thread, and whether this error is being reported as a result of an error in the error reporting system. Then it prepares messages of varying detail to print to a file if possible and the screen if not. It creates and executes shell scripts (!) to do who knows what. Then it thinks about quitting.

This is great, except that all this wacky stack and thread stuff is calling unimplemented code, and filling in stubs that the error reporting system is calling was getting the error reporting system working — not the VM!

The error reporting system now looks like this:

fprintf(stderr, "error: %s: %s:%d\n", _message, _filename, _lineno);

Om Shanti.