When debugging an unfamiliar program with gdb, the program often unexpectedly exits after executing next. When that happens I'll typically set a break point, re-run the program and execute step instead of next to trace what's happening. However, sometimes it is difficult to know where to set the break point. Is there a technique set the break automatically? Something like:
define hook-next
break
end
define hookpost-next
# delete the previous break if the program is still running
end