See the Debugging FAQ at FAQ Section: Debugging for techniques you can apply to your proprietary app.