Description
Feature or enhancement
Proposal:
gdb
has a command return
for users to immediately return from the function. It basically does two things:
- stop the execution of the function
- return an arbitrary value
In Python, 1. might not be that simple as we have all the references to the stack value (it should be doable, but may or may not worth it), but 2. should be pretty straightforward. We can allow the callback for PY_RETURN
function to return something specific (like sys.monitoring.RETURN, retval
) to replace the value we are about to return. It should only need to swap the value on the stack and the impact should be contained. Some of the instrumentation structure needs to be refactored a bit but I don't think it's too much work.
With this feature, we can "mock" the return value in the debugger. We can even expand our existing return
command - we may not able to return immediately, but we can run until it returns and secretly swap the return value, so we can call this command from anywhere.
Does this sound like a reasonable feature or I'm missing something? @markshannon
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response