[Lldb-commits] [PATCH] D44321: Support demangling for D symbols via dlopen

Timothee Cour via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 14 16:38:45 PDT 2018


timotheecour added inline comments.


================
Comment at: source/Plugins/Language/D/DLanguage.cpp:108
+
+    auto fun0=lib2->getFun<decltype(d_initialize)>("d_initialize");
+    (*fun0)();
----------------
johanengelen wrote:
> timotheecour wrote:
> > johanengelen wrote:
> > > Would it help to initialize druntime using a static module constructor in the lldbdplugin dll?
> > > (then you can also do de-init using a static module destructor)
> > I don't really like static module constructor because it adds cyclic dependencies, see for vibe.d moving away from it: https://forum.dlang.org/post/qtabwblpaqwpteystwft@forum.dlang.org
> > explicit calling `d_initialize` is simple enough.
> > 
> > 
> > 
> Module ctors don't add cyclic dependencies by themselves. There is also no danger of that here.
> How do you de-initialize druntime? (without de-init, there is a big mem leak)
> Module ctors don't add cyclic dependencies by themselves. There is also no danger of that here.

* We can have cyclic dependencies but not when Module ctors are involved; see previous argument I made with vibe.d, or other threads (eg https://forum.dlang.org/post/rrcshskphugsvksaonhq@forum.dlang.org).

* Also, current code allows for liblldbplugin.d to be imported from another module whereas it would cause complications if it contained a module ctor that would initialize druntime.

calling `d_initialize` as I'm doing works fine.



================
Comment at: source/Plugins/Language/D/DLanguage.cpp:108
+
+    auto fun0=lib2->getFun<decltype(d_initialize)>("d_initialize");
+    (*fun0)();
----------------
timotheecour wrote:
> johanengelen wrote:
> > timotheecour wrote:
> > > johanengelen wrote:
> > > > Would it help to initialize druntime using a static module constructor in the lldbdplugin dll?
> > > > (then you can also do de-init using a static module destructor)
> > > I don't really like static module constructor because it adds cyclic dependencies, see for vibe.d moving away from it: https://forum.dlang.org/post/qtabwblpaqwpteystwft@forum.dlang.org
> > > explicit calling `d_initialize` is simple enough.
> > > 
> > > 
> > > 
> > Module ctors don't add cyclic dependencies by themselves. There is also no danger of that here.
> > How do you de-initialize druntime? (without de-init, there is a big mem leak)
> > Module ctors don't add cyclic dependencies by themselves. There is also no danger of that here.
> 
> * We can have cyclic dependencies but not when Module ctors are involved; see previous argument I made with vibe.d, or other threads (eg https://forum.dlang.org/post/rrcshskphugsvksaonhq@forum.dlang.org).
> 
> * Also, current code allows for liblldbplugin.d to be imported from another module whereas it would cause complications if it contained a module ctor that would initialize druntime.
> 
> calling `d_initialize` as I'm doing works fine.
> 
> How do you de-initialize druntime? (without de-init, there is a big mem leak)

There is no memory leak because d_initialize once (using c++11 static initialization pattern) and is intended to last for duration of application; so druntime will be initialized only once, upon 1st use.

I've however added d_terminate in case a future PR wants to de-initialize druntime (eg in DLanguage::Terminate)


https://reviews.llvm.org/D44321





More information about the lldb-commits mailing list