<div dir="ltr">> <span style="font-size:12.8000001907349px">If you don't have debug info for that shared library (hence the suggestion to install debug info for the standard library - there are packages for it). </span><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Not if you're using a random Android device from vendor foo. =)</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">> I imagine at some point, the Googlers working on LLDB will ultimately want/need to implement this to keep our debug info size improvements on while being usable with LLDB, but I don't actually know their plans/goals/tradeoffs. </span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">It will be a long time before we get there. Until then, I'd like to have -fstandalone-debug default for all targets. I also think it's unintuitive to have different platforms silently behave differently for completely cross platform concepts.</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">> also, we tend to build everything statically, as I understand it - so shared library features aren't as valuable for our use cases</span><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">I'm working on tools for third-party (and Google) Android developers, who have very similar priorities as independent Linux developers, e.g. error-proof/easy-to-use is more important than smallest possible debug symbols.</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Sincerely,</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Vince</span></div><div><span style="font-size:12.8000001907349px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 27, 2015 at 1:28 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Fri, Feb 27, 2015 at 10:04 AM, Greg Clayton <span dir="ltr"><<a href="mailto:clayborg@gmail.com" target="_blank">clayborg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
> On Feb 27, 2015, at 9:40 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> On Fri, Feb 27, 2015 at 9:31 AM, Greg Clayton <<a href="mailto:clayborg@gmail.com" target="_blank">clayborg@gmail.com</a>> wrote:<br>
> I recommend telling the compiler to not do this using (set -no-fstandalone-debug in OTHER_CFLAGS) if you want to debug with LLDB. If you don't you can DWARF for the following code:<br>
><br>
><br>
> class A : public B<br>
> {<br>
> };<br>
><br>
> Where the compiler says "no one used 'B' so I am going to emit a forward declaration for 'B'.<br>
><br>
> That's not quite the logic used here. Certainly if you use A then you've used B. B may be emitted as a declaration if we know that some other CU will contain the definition (eg: using the vtable optimization - if B has virtual functions, we'll only emit the definition of B where the vtable goes (if B has a key function, this means the debug info definition of B goes in exactly one place: where the definition of the key function appears))<br>
<br>
</span>Sure, then only if B has a vtable this will happen.<br></blockquote></span><div><br>(or an explicit instantiation declaration (such as std::string) - or is only used in ways that don't require the complete type)<br> </div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span><br>
><br>
> Then LLDB tries to make class 'A' in a clang AST context and then we try to parse 'B' so we can have 'A' inherit from it and clang of course would assert and kill LLDB (if we actually try to give clang a class 'B' that is a forward declaration as a base class) so LLDB has to lie to keep clang from asserting and just say that 'B' class that contains nothing.<br>
><br>
> Shouldn't it go & find B in another file? The same way you would find the definition of foo if one file contained "struct foo; foo *f;" and the user executed the command "p f->bar"?<br>
<br>
</span>LLDB is designed to parse each shared library individually so that we can re-use shared libraries from between multiple runs. If liba.so doesn't changed, we don't need to re-parse anything in liba.so or its debug info file. If you recompile libb.so, we don't have any dependencies in liba.so on types like 'B' from elsewhere otherwise the types passed out by each shared library have dependencies and have to throw everything away when any dependent shared library is loaded.<br></blockquote></span><div><br>Ah, thanks for the architectural explanation - this is a detail I hadn't read about/understood before.<br> </div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">But in LLDB, when we have a process, _will_ find the real definition elsewhere when displaying things to you for things that can legally be forward declarations in sources (pointers and references). So we will have a variable of type "A" from liba.so and we will be displaying it and if it has an instance variable, whose type is "C *" and that 'C' is a forward declaration, we will search and find "C" elsewhere (in libb.so) for display purposed by switching over to using the type from 'libb.so'. But we can't do this for things that can't be forward declarations in sources, like base classes.<br></blockquote></span><div><br>OK, so you switch contexts to find the type (knowing where it is - with some index, etc).<br><br>It seems to me that to support this kind of optimized debug info with LLDB's architecture similar things could be done during AST building time - switching library context to find the definition elsewhere. The extra wrinkle being you'd want to keep track of the dependent libraries used in this case - and, yes, it'd come with some performance cost - if you had to reload the dependent library, you'd reload any libraries that depended upon it (or possibly only the specific types that were dependent)<br><br>I mean that's up to you guys/whoever's working on the project if it's important - I get that Google's needs for small debug info are somewhat more dire than other projects, but even before I started on debug info it seemed like size was a continuous concern/priority - so I'm still somewhat surprised/confused by the apparent priorities here, but we have a flag & the choice is easy enough to make.<br><br>I imagine at some point, the Googlers working on LLDB will ultimately want/need to implement this to keep our debug info size improvements on while being usable with LLDB, but I don't actually know their plans/goals/tradeoffs. (also, we tend to build everything statically, as I understand it - so shared library features aren't as valuable for our use cases)<span class="HOEnZb"><font color="#888888"><br><br>- David<br> </font></span></div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span><br>
><br>
> The idea was that someone will certainly declare 'B' somewhere in your current source base.<br>
><br>
> It's more robust than that - the vtable optimization, assuming you compile your whole program with debug info, is guaranteed by the C++ standard (odr use of the class means you have a definition of all the virtual members /somewhere/ in your program).<br>
<br>
</span>Yes, but this doesn't guarantee that this debug info is in the current shared library or executable. So if the other shared library doesn't have debug info, then you end up missing debug info. LLDB parses shared libraries individually because it can have multiple debug sessions running simultaneously, each using different combinations of shared libraries at the same time. So we can't take type 'B' from libb.so and copy it into type 'A' from liba.so because if libb.so changes and we restart a debug session, we would have to throw away all type info (or maintain dependency lists). Further we can't do it because process 123 might be still be using the old version of libb.so while process 124 restarted and is using the new version.<br>
<span><br>
> GCC has been doing this optimization for a while now, Clang was doing similar optimizations ("struct foo { }; foo *f;" - we'd only emit the declaration of 'foo' since it was never dereferenced) for a while too - I believe Eric implemented the first versions of that on a suggestion from Chris Lattner, FWIW.<br>
<br>
</span>Again, for places that can have forward declarations (for pointers and references), this is quite OK. Our variable display logic will find the right definition. It is just in the base class case where this falls down for LLDB.<br>
<span>><br>
> This mostly holds true, but if you have a header file from a shared library that has a C++ class that people might inherit from (like we do in Darwin Kernel Extensions),<br>
><br>
> If you don't have debug info for that shared library (hence the suggestion to install debug info for the standard library - there are packages for it). Granted I imagine it'll take some finagling to change the Darwin Kernel Extensions build system to build a partial debug info package (presumably you don't want to ship all the debug info for the implementation of that library - for size and privacy reasons).<br>
<br>
</span>We do have this issue and we won't be changing the default on MacOSX for this very reason.<br>
<br>
The performance and memory benefits we get in LLDB from having each shared library be independent are huge. Re-starting a debug session in Xcode for the same program (rerunning) is instant as we have a global cache of shared libraries that are all stand alone and have no dependencies. When we still used GDB, every restart was a new delay as it loaded all shared libraries and debug info for each run. Each debug session was a unique new instance of GDB running in a separate process so that GDB could hack its shared libraries up any way it chose to with no worries of dependencies because there was only 1 debug session going on at a time. If a shared library doesn't change in LLDB, we still have a live copy all pre-parsed and ready to go in our global cache.<br>
<div><div><br>
><br>
> we end up with a class we use for debugging that isn't allowed to see any ivars from "B", nor call any functions declared inside 'B' or any of its subclasses (because we told clang 'B' has no contents when creating the type in the clang AST. So we default to -no-fstandalone-debug for all of Darwin to avoid this.<br>
><br>
> Greg Clayton<br>
><br>
> > On Feb 26, 2015, at 4:35 PM, Ed Maste <<a href="mailto:emaste@freebsd.org" target="_blank">emaste@freebsd.org</a>> wrote:<br>
> ><br>
> > On 26 February 2015 at 17:28, Adrian Prantl <<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>> wrote:<br>
> >><br>
> >> The -fstandalone-debug option turns off these optimizations. This is useful when working with 3rd-party libraries that don't come with<br>
> >> debug information. This is the default on Darwin. Note that Clang will never emit type information for types that are not referenced at<br>
> >> all by the program.<br>
> ><br>
> > Note that this is also the default on FreeBSD. This might be an<br>
> > important point when comparing test results on FreeBSD and Linux since<br>
> > they otherwise share a lot of attributes.<br>
> ><br>
> > -Ed<br>
><br>
><br>
<br>
</div></div></blockquote></span></div><br></div></div>
<br>_______________________________________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><br><table cellspacing="0" cellpadding="0" style="font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Vince Harron |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Technical Lead Manager |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:vharron@google.com" target="_blank">vharron@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 858-442-0868</td></tr></tbody></table><br></div></div>
</div>