In lldb, I need to break everytime I change module (e.g. the stack frame is in a dynamic library instead of the main binary).
How can I do that?
On most systems the stubs that orchestrate inter-library calls don't run through any common code that the debugger could observe. After they are resolved the first time, the loader generally writes the target instruction directly into the stub so you'd actually have to stop on the stub to observe the transition.
lldb doesn't consider stub symbols something users would want to break on, so there's no way from the command line to find and break on these. But you could certainly use the Python API's to find all the stub symbols in the binary you want to track "exit from" and put breakpoints on the stub addresses. That's the only way I can think of to track transitions OUT of a given library.
You can observe transitions INTO a particular library by setting a breakpoint on every function in that library:
(lldb) break set -r . -s
since you can only get into a library from an exported symbol, even if the binary is stripped that will still get all the entry points.