Print stack only when debug is enabled