1. A method for debugging in a computer system a function in an application upon function exit, the method comprising pausing execution of an application on entering a function, the function being part of the application under execution; determining a location of a variable stored in a stack, wherein the variable chosen can be read by a central processing unit before the function exits; inserting a watchpoint on the variable stored in the stack, wherein the watchpoint instructs the central processing unit to pause execution of an application on encountering the variable chosen on the stack; and resuming normal execution of the application.