[Lldb-commits] [PATCH] Move full initialization to lldb/API

Zachary Turner zturner at google.com
Thu Mar 19 14:04:17 PDT 2015


Hi clayborg, ovyalov, vharron, flackr,

This patch builds on top of D4828.  The idea behind this change is to separate full initialization and LLGS initialization more strongly.  Because InitializeForLLGS is in the same source file (or even the same library) as Initialize(), the linker has to deal with all these extra symbols, increasing binary size.  In theory it can do dead code elimination, but it doesn't always do an optimal job (as the numbers later on show).  Furthermore, there is some duplicated logic with regards to checking the ref count, and making sure Debugger::Initialize() and Debugger::Terminate is called in the correct order.

This patch addresses all of these issues by introducing a class called SystemLifetimeManager which *only* deals with the interaction between the ref count, calling Debugger::Initialize / Terminate, and actually shutting down the complete set of system services.  In particular, it does *not* deal with the implementation details of what system services to initialize and shutdown.

This is accomplished by introducing an abstract base class called SystemInitializer with Initialize() and Terminate() methods.  A standard implementation called SystemInitializerCommon is provided in the Initialization library.  The functionality contained in here is identical to the functionality which used to be in InitializeForLLGS() and TerminateLLGS().

The full initialization implemetantion is now compiled directly into source/API via source/API/SystemInitializerFull.cpp, which provides an implementation built on top of SystemInitializerCommon (this is equivalent to the functionality that used to be in lldb_private::Initialize() / lldb_private::Terminate()

This all seems rather complicated, but using this approach the binary size of llgs is reduced quite a bit.  Here are some numbers:

Before Patch:
  Debug 738,065,786 bytes
  Release 27,333,622 bytes
  MinSizeRel 21,818,230 bytes
  MinSizeRel with stripped symbols 16,364,008 bytes

After Patch:
  Debug 475,575,879 bytes
  Release 24,120,433 bytes
  MinSizeRel 19,034,215 bytes
  MinSizeRel with stripped symbols 14,395,872 bytes

So I'm seeing an improvement of about 12% for a fully minimized binary.

Note I haven't updated the Xcode project yet.  I will do that now, but I wanted to put this up first for the high level idea.

http://reviews.llvm.org/D8462

Files:
  include/lldb/API/SystemInitializerFull.h
  include/lldb/Initialization/InitializeLLDB.h
  include/lldb/Initialization/SystemInitializer.h
  include/lldb/Initialization/SystemInitializerCommon.h
  include/lldb/Initialization/SystemLifetimeManager.h
  source/API/CMakeLists.txt
  source/API/SBDebugger.cpp
  source/API/SystemInitializerFull.cpp
  source/Core/Debugger.cpp
  source/Initialization/CMakeLists.txt
  source/Initialization/InitializeLLDB.cpp
  source/Initialization/SystemInitializer.cpp
  source/Initialization/SystemInitializerCommon.cpp
  source/Initialization/SystemLifetimeManager.cpp
  tools/lldb-server/lldb-server.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8462.22300.patch
Type: text/x-patch
Size: 44255 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150319/724858f8/attachment.bin>


More information about the lldb-commits mailing list