[lldb-dev] Is there a just-my-code like debugging mode for LLDB?
Greg Clayton via lldb-dev
lldb-dev at lists.llvm.org
Wed May 13 15:00:48 PDT 2020
So one idea is to improve the PlatformAndroid to use "adb" to copy all system libraries over and pre-cache all system libraries instead of letting it happen one by one.
Android is also very inefficient in loading shared libraries. It will load them one by one and each one involves 2 stops since the breakpoint we set gets hit once before the library is loaded and once again when it has been loaded. Each stop for shared libraries takes a few hundred milliseconds.
So it might be nice to have the PlatformAndroid grab all system libraries and populate the cache for a device in one large command and see if that improves things. To test this you can just download all system libraries to a single directory manually and then do set some settings:
(lldb) settings set target.exec-search-paths /path/to/cache
(lldb) settings set target.debug-file-search-paths /path/to/cache
So time the "adb" command that wildcard copies all libraries over, then set the settings, then run your debug sessions and see how much this helps. That will give you a good idea of sequentially grabbing each library is the cost.
If the cost is in parsing these libraries, we can look at parallelizing the loading of all the device shared libraries first (prior to debugging) and then launching when everything is pre-loaded.
Greg
> On May 8, 2020, at 9:07 AM, Emre Kultursay via lldb-dev <lldb-dev at lists.llvm.org> wrote:
>
> Hi lldb-dev,
>
> TL;DR: Has there been any efforts to introduce something like "Just My Code" debugging on LLDB? Debugging on Android would really benefit from this.
>
> Details:
>
> Native Android apps typically have a single .so file from the user, but load ~150 system libraries.
>
> When attaching LLDB remotely to an Android app, a significant amount of time is spent on loading modules for those system libraries, even with a warm LLDB cache that contains a copy of all these libraries.
>
> With a cold LLDB cache, things are much worse, because LLDB copies all those libraries from the device back to the host to populate its cache. While one might think this happens only once for a user, things are a bit worse for Android. There are just too many libraries to copy, making it very slow, there are new Android releases every year, and users typically use multiple devices (e.g., x86, x86_64 emulators, arm32, arm64 devices), and multiple hosts (work, home, laptop/desktop); thereby suffering from this issue more than necessary.
>
> If we can eliminate the latency of loading these modules, we can deliver a much faster debugging startup time. In essence, this can be considered as a form of Just My Code debugging.
>
> Prototype and Experiments
>
> I built a simple prototype that only loads a single user module, and totally avoids loading ~150 system modules. I ran it on my Windows host against an Android emulator to measure the end to end latency of "Connect + Attach + Resume + Hit 1st breakpoint immediately" .
> For warm LLDB cache:
> Without just-my-code: 23 seconds
> With just-my-code: 14 seconds
> For cold LLDB cache:
> Without just-my-code: 120 seconds
> With just-my-code: 16 seconds
>
> I want to solicit some feedback and gather thoughts around this idea. It would be great if there are any existing alternatives in LLDB to achieve my goal, but otherwise, I can implement this on LLDB and I'd appreciate it if anyone has any advice on how to implement such a feature.
>
> Thanks.
> -Emre
>
>
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20200513/d8c2d4e2/attachment.html>
More information about the lldb-dev
mailing list