Auto set the release stage

Set the release stage to dev if we are compiled with DEBUG on, or if the
debugger is attached - else default to production.
Its not useless...its just not obvious as the optimizer can move stuff around. I could try to find out what actual stack trace generated was and check it, but I didn't want to make the test too brittle.