So with the current version of LLDB the source-before-file is worthless
for debugging a shared library? So this is acctually not a bug?
Two things here. First of all, up till very recently lldb didn't support setting breakpoints before you have a target. That was a known bug, which I fixed a short while ago (but there hasn't been a new release of the tools from Apple since that fix went in.) Sorry I didn't mention that, I assumed from the fact that you were building TOT lldb to test this that you knew that. That this didn't work up till now was clearly a bug, that's why I fixed it.
With TOT lldb, however this does work, as I showed in the example I sent. You sent another example, for which thanks, BTW. I explained that the reason that example didn't work was you were trying to set a breakpoint in code that ran before ANY shared libraries are mapped into the program. So while your example showed a small set of code for which "source-before-file" breakpoints don't work, that code is not in shared libraries, it is in the loader, and at such an early stage that nothing of any importance has happened in the program yet.
AND I said that was a bug, please file it. So this comment seems totally off base.
Is there a workaround to debug a shared library with the current version
of LLDB? Setting all breakpoints manually for each start is too much
work. If you must set the breakpoints manually the source-before-file is
worthless in my eyes. And even if I don't restart the LLDB itself and
only the program I would like to debug the breakpoints are again
unresolved after re-start.
"unresolved" means that though lldb knows what address the breakpoint should be at, it wasn't able to put the breakpoint there yet. After a restart, all breakpoints are expected to be unresolved - since the libraries in question haven't been mapped into the address space of the program, and will remain so till the relevant library gets mapped in.
What do you mean with
since it knows the world is going to change out from under it
? The addresses of a loaded library doesn't change from run to run.
That's actually not true. If ASLR is on, then libraries load in different orders from run to run. And even if you turn ASLR off - which the debugger does by default - though all the directly loaded shared libraries will end up in the same place from run to run, the addresses of any libraries that are loaded later on as a result of user actions (e.g. hit Print in some OS X application and a bunch of shared libraries will get loaded) depend on the order of those actions.
Anyway, that's interesting maybe, but not really the point. At the beginning of _dyld_start, none of the shared libraries are mapped into the address space of the program. Since we need to write traps into the breakpoint memory locations in order to set breakpoints, we're going to fail until dyld gets a chance to map them in. The only thing that's been mapped in is the loader itself.
Jim