[lldb-dev] [PATCH] For SBDebugger::Create assertion failure

Matthew Gardiner mg11 at csr.com
Tue Oct 7 22:15:13 PDT 2014


On Tue, 2014-10-07 at 17:10 -0700, Greg Clayton wrote:
> It is quite common for shared libraries to have initialize and terminate calls. We have this in LLDB. 

Agreed. Lots of libraries have to initialise resource, then release the
resource upon terminate.

But why have an Initialise method when you _already_ have a Create
method? Likewise a Terminate method when you _already_ have a Destroy
method.

Surely when a "thing" is created that is also when it is initialised?

> 
> I would rather not have to look through all API calls that might require LLDB to be initialized and have to possibly manually call SBDebugger::Initialize() in there. The initialization does quite a bit and the assertion quickly should tell you that you must call SBDebugger::Initialize() first. If it isn't clear from the assertion, we can change the assertion to be more descriptive. But again, many other classes in the lldb::SB* API have functions that might be able to be used without having to start with a debugger, so I would rather not have to go through all of the API and add the "init the debugger if not already initialized".
> 
> This also allows you to use LLDB as a shared library and do:
> 
> SBDebugger::Initialize()
> // Do something that takes up a bunch of memory
> SBDebugger::Terminate()
> 

Agreed. But surely in between the invocations of Initialise and
Terminate, you have in some sense "created" an instance of an
SBDebugger?


> So I vote to leave things as is.
> 

To avoid rocking the boat, I reluctantly concede.

Matt




Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, www.youtube.com/user/CSRplc, Facebook, www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at www.twitter.com/CSR_plc.
New for 2014, you can now access the wide range of products powered by aptX at www.aptx.com.



More information about the lldb-dev mailing list