[Lldb-commits] [PATCH] D44354: [lldb] Unbreak lldb builds due to r327219

2018-03-10 Thread Andrea Di Biagio via Phabricator via lldb-commits
andreadb added a comment.

If this patch is to unbreak the buildbots, then I think you should just commit 
it.
We don't want to leave the buildbots in a failing state for too long.

If instead you don't feel confortable about this fix, then you should revert 
r327219.


Repository:
  rL LLVM

https://reviews.llvm.org/D44354



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44354: [lldb] Unbreak lldb builds due to r327219

2018-03-10 Thread Mandeep Singh Grang via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327224: [lldb] Unbreak lldb builds due to r327219 (authored 
by mgrang, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44354?vs=137922&id=137923#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44354

Files:
  lldb/trunk/source/Breakpoint/Breakpoint.cpp


Index: lldb/trunk/source/Breakpoint/Breakpoint.cpp
===
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp
@@ -792,8 +792,8 @@
   // from both maps as we go.
 
   if (old_id_vec.size() == new_id_vec.size()) {
-sort(old_id_vec.begin(), old_id_vec.end());
-sort(new_id_vec.begin(), new_id_vec.end());
+llvm::sort(old_id_vec.begin(), old_id_vec.end());
+llvm::sort(new_id_vec.begin(), new_id_vec.end());
 size_t num_elements = old_id_vec.size();
 for (size_t idx = 0; idx < num_elements; idx++) {
   BreakpointLocationSP old_loc_sp =


Index: lldb/trunk/source/Breakpoint/Breakpoint.cpp
===
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp
@@ -792,8 +792,8 @@
   // from both maps as we go.
 
   if (old_id_vec.size() == new_id_vec.size()) {
-sort(old_id_vec.begin(), old_id_vec.end());
-sort(new_id_vec.begin(), new_id_vec.end());
+llvm::sort(old_id_vec.begin(), old_id_vec.end());
+llvm::sort(new_id_vec.begin(), new_id_vec.end());
 size_t num_elements = old_id_vec.size();
 for (size_t idx = 0; idx < num_elements; idx++) {
   BreakpointLocationSP old_loc_sp =
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2018-03-10 Thread Timothee Cour via Phabricator via lldb-commits
timotheecour updated this revision to Diff 137927.
timotheecour marked 4 inline comments as done.
timotheecour edited the summary of this revision.
timotheecour added a comment.

- format
- format
- fixup


https://reviews.llvm.org/D44321

Files:
  include/lldb/Core/Mangled.h
  source/Core/CMakeLists.txt
  source/Core/Mangled.cpp
  source/Plugins/Language/CMakeLists.txt
  source/Plugins/Language/D/CMakeLists.txt
  source/Plugins/Language/D/DLanguage.cpp
  source/Plugins/Language/D/DLanguage.h

Index: source/Plugins/Language/D/DLanguage.h
===
--- /dev/null
+++ source/Plugins/Language/D/DLanguage.h
@@ -0,0 +1,57 @@
+//===-- DLanguage.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_DLanguage_h_
+#define liblldb_DLanguage_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/Language.h"
+#include "lldb/lldb-private.h"
+
+namespace lldb_private {
+
+class DLanguage : public Language {
+public:
+  DLanguage() = default;
+
+  ~DLanguage() override = default;
+
+  lldb::LanguageType GetLanguageType() const override {
+return lldb::eLanguageTypeD;
+  }
+
+  //--
+  // Static Functions
+  //--
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb_private::Language *CreateInstance(lldb::LanguageType language);
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  static bool IsDMangledName(const char *name);
+  // TODO: not static?
+  static char *demangle(const ConstString &mangled);
+
+  //--
+  // PluginInterface protocol
+  //--
+  ConstString GetPluginName() override;
+
+  uint32_t GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_DLanguage_h_
Index: source/Plugins/Language/D/DLanguage.cpp
===
--- /dev/null
+++ source/Plugins/Language/D/DLanguage.cpp
@@ -0,0 +1,119 @@
+//===-- DLanguage.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DLanguage.h"
+
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Utility/ConstString.h"
+
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+// D Plugin will define these symbols. They're declared to use with decltype.
+extern "C"{
+  char *lldbd_demangle(size_t length, const char *mangled);
+  void d_initialize();
+}
+
+// TODO:MOVE
+struct SharedLib {
+  void *handle;
+  const char *libraryFile;
+  int flagDefault = RTLD_LOCAL | RTLD_LAZY;
+  SharedLib() {}
+
+  ~SharedLib() { release(); }
+
+  // Return true if `dlopen` succeeded
+  bool open(const char *libraryFile, int flag) {
+release();
+this->libraryFile = libraryFile;
+handle = dlopen(libraryFile, flag);
+if (handle)
+  return true;
+return false;
+  }
+
+  void release() {
+// if(handle) seems needed:
+// https://stackoverflow.com/questions/11412943is-it-safe-to-call-dlclosenull
+if (handle)
+  dlclose(handle);
+  }
+
+  template  Fun *getFun(const char *symbol) {
+assert(handle);
+return reinterpret_cast(dlsym(handle, symbol));
+  }
+};
+
+void DLanguage::Initialize() {
+  PluginManager::RegisterPlugin(GetPluginNameStatic(), "D Language",
+CreateInstance);
+}
+
+void DLanguage::Terminate() { PluginManager::UnregisterPlugin(CreateInstance); }
+
+lldb_private::ConstString DLanguage::GetPluginNameStatic() {
+  static ConstString g_name("D");
+  return g_name;
+}
+
+//--
+// PluginInterface protocol
+//--
+lldb_private::ConstString DLanguage::GetPluginName() {
+  return GetPluginNameStatic();
+}
+
+uint32_t DLanguage::GetPluginVersion() { return 1; }
+
+//--
+// Static Functions
+//--
+Language *DLanguage::CreateInstance(lldb::LanguageType language) {
+  switch (language) {
+  case lldb::eLanguageTypeD:
+return new DLanguage();
+  default:
+return nullptr;
+  }
+}

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

2018-03-10 Thread Timothee Cour via Phabricator via lldb-commits
timotheecour added inline comments.



Comment at: source/Plugins/Language/D/DLanguage.cpp:108
+
+auto fun0=lib2->getFun("d_initialize");
+(*fun0)();

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/qtabwblpaqwpteyst...@forum.dlang.org
explicit calling `d_initialize` is simple enough.





https://reviews.llvm.org/D44321



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2018-03-10 Thread Timothee Cour via Phabricator via lldb-commits
timotheecour updated this revision to Diff 137930.
timotheecour added a comment.

- use llvm::sys::DynamicLibrary
- format


https://reviews.llvm.org/D44321

Files:
  include/lldb/Core/Mangled.h
  source/Core/CMakeLists.txt
  source/Core/Mangled.cpp
  source/Plugins/Language/CMakeLists.txt
  source/Plugins/Language/D/CMakeLists.txt
  source/Plugins/Language/D/DLanguage.cpp
  source/Plugins/Language/D/DLanguage.h

Index: source/Plugins/Language/D/DLanguage.h
===
--- /dev/null
+++ source/Plugins/Language/D/DLanguage.h
@@ -0,0 +1,57 @@
+//===-- DLanguage.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_DLanguage_h_
+#define liblldb_DLanguage_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/Language.h"
+#include "lldb/lldb-private.h"
+
+namespace lldb_private {
+
+class DLanguage : public Language {
+public:
+  DLanguage() = default;
+
+  ~DLanguage() override = default;
+
+  lldb::LanguageType GetLanguageType() const override {
+return lldb::eLanguageTypeD;
+  }
+
+  //--
+  // Static Functions
+  //--
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb_private::Language *CreateInstance(lldb::LanguageType language);
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  static bool IsDMangledName(const char *name);
+  // Consider using non-static methods
+  static char *demangle(const ConstString &mangled);
+
+  //--
+  // PluginInterface protocol
+  //--
+  ConstString GetPluginName() override;
+
+  uint32_t GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_DLanguage_h_
Index: source/Plugins/Language/D/DLanguage.cpp
===
--- /dev/null
+++ source/Plugins/Language/D/DLanguage.cpp
@@ -0,0 +1,99 @@
+//===-- DLanguage.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DLanguage.h"
+
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Utility/ConstString.h"
+#include "llvm/Support/DynamicLibrary.h"
+
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+using llvm::sys::DynamicLibrary;
+
+template 
+Fun *getTypedSymbol(DynamicLibrary &lib, const char *symbol) {
+  return reinterpret_cast(lib.getAddressOfSymbol(symbol));
+}
+
+// D Plugin will define these symbols. They're declared to use with decltype.
+extern "C" {
+char *lldbd_demangle(size_t length, const char *mangled);
+void d_initialize();
+}
+
+void DLanguage::Initialize() {
+  PluginManager::RegisterPlugin(GetPluginNameStatic(), "D Language",
+CreateInstance);
+}
+
+void DLanguage::Terminate() { PluginManager::UnregisterPlugin(CreateInstance); }
+
+lldb_private::ConstString DLanguage::GetPluginNameStatic() {
+  static ConstString g_name("D");
+  return g_name;
+}
+
+//--
+// PluginInterface protocol
+//--
+lldb_private::ConstString DLanguage::GetPluginName() {
+  return GetPluginNameStatic();
+}
+
+uint32_t DLanguage::GetPluginVersion() { return 1; }
+
+//--
+// Static Functions
+//--
+Language *DLanguage::CreateInstance(lldb::LanguageType language) {
+  switch (language) {
+  case lldb::eLanguageTypeD:
+return new DLanguage();
+  default:
+return nullptr;
+  }
+}
+
+char *DLanguage::demangle(const ConstString &mangled) {
+  auto len = mangled.GetLength();
+  auto s = mangled.GetCString();
+  static auto fun = []() -> decltype(lldbd_demangle) * {
+// TODO: so vs dylib
+auto file = "liblldbdplugin.dylib";
+std::string errMsg;
+auto lib2 = DynamicLibrary::getPermanentLibrary(file, &errMsg);
+
+if (!lib2.isValid()) {
+  // Not dumping `errMsg` because would result in noise if user did not
+  // intend to call dlopen.
+  return nullptr;
+}
+
+auto fun0 = getTypedSymbol(lib2, "d_initialize");
+assert(fun0);

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

2018-03-10 Thread Timothee Cour via Phabricator via lldb-commits
timotheecour marked an inline comment as done.
timotheecour added inline comments.



Comment at: source/Plugins/Language/D/DLanguage.cpp:24
+// TODO:MOVE
+struct SharedLib{
+  void* handle;

johanengelen wrote:
> Did you look into using llvm/Support/DynamicLibrary.h ?
> That would make the code crossplatform (notably: Windows).
thx for tip! done, used llvm::sys::DynamicLibrary


https://reviews.llvm.org/D44321



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44354: [lldb] Unbreak lldb builds due to r327219

2018-03-10 Thread Simon Pilgrim via Phabricator via lldb-commits
RKSimon added a comment.

(post) LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D44354



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2018-03-10 Thread Timothee Cour via Phabricator via lldb-commits
timotheecour added a comment.

In https://reviews.llvm.org/D44321#1033325, @davide wrote:

> This patch has no testcase. It shouldn't be particularly hard to write one, 
> you can take inspiration from the one in `lit/`.
>
> Thanks!


5d29d3f0aa2f540c277a67eac5873feca8c62d51 (Support for OCaml native debugging) 
introduced a much larger change and had no test case either. If you really 
insist on a test case please provide more concrete guidance.


https://reviews.llvm.org/D44321



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2018-03-10 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

In https://reviews.llvm.org/D44321#1034043, @timotheecour wrote:

> In https://reviews.llvm.org/D44321#1033325, @davide wrote:
>
> > This patch has no testcase. It shouldn't be particularly hard to write one, 
> > you can take inspiration from the one in `lit/`.
> >
> > Thanks!
>
>
> 5d29d3f0aa2f540c277a67eac5873feca8c62d51 (Support for OCaml native debugging) 
> introduced a much larger change and had no test case either. If you really 
> insist on a test case please provide more concrete guidance.


That was a while ago. In fact, the OCaml support is going to be removed. New 
languages need to meet an high(er) bar to be included. One of the requirements 
is, e.g. being tested.
It's a little more complicated for D because it's an out-of-tree compiler so it 
poses interesting challenges.
Let me think about it a little more and I'll come back to you.

Thanks,

-

Davide


https://reviews.llvm.org/D44321



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2018-03-10 Thread Timothee Cour via Phabricator via lldb-commits
timotheecour updated this revision to Diff 137940.
timotheecour added a comment.

- format
- use llvm::sys::DynamicLibrary
- added DLanguageProperties


https://reviews.llvm.org/D44321

Files:
  include/lldb/Core/Mangled.h
  include/lldb/Core/PluginManager.h
  source/API/SystemInitializerFull.cpp
  source/Core/CMakeLists.txt
  source/Core/Mangled.cpp
  source/Core/PluginManager.cpp
  source/Plugins/Language/CMakeLists.txt
  source/Plugins/Language/D/CMakeLists.txt
  source/Plugins/Language/D/DLanguage.cpp
  source/Plugins/Language/D/DLanguage.h

Index: source/Plugins/Language/D/DLanguage.h
===
--- /dev/null
+++ source/Plugins/Language/D/DLanguage.h
@@ -0,0 +1,74 @@
+//===-- DLanguage.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_DLanguage_h_
+#define liblldb_DLanguage_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/Language.h"
+#include "lldb/lldb-private.h"
+
+namespace lldb_private {
+
+class DLanguageProperties : public Properties {
+public:
+  DLanguageProperties();
+
+  ~DLanguageProperties() override;
+
+  llvm::StringRef GetPluginfileDlang();
+};
+
+class DLanguage : public Language {
+public:
+  typedef std::shared_ptr DLanguagePropertiesSP;
+
+  DLanguage() = default;
+
+  ~DLanguage() override = default;
+
+  lldb::LanguageType GetLanguageType() const override {
+return lldb::eLanguageTypeD;
+  }
+
+  //--
+  // Static Functions
+  //--
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb_private::Language *CreateInstance(lldb::LanguageType language);
+
+  static void DebuggerInitialize(lldb_private::Debugger &debugger);
+
+  static DLanguage *Instance();
+
+  static const DLanguagePropertiesSP &GetGlobalProperties();
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  static bool IsDMangledName(const char *name);
+  // Consider using non-static methods
+  static char *demangle(const ConstString &mangled);
+
+  //--
+  // PluginInterface protocol
+  //--
+  ConstString GetPluginName() override;
+
+  uint32_t GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_DLanguage_h_
Index: source/Plugins/Language/D/DLanguage.cpp
===
--- /dev/null
+++ source/Plugins/Language/D/DLanguage.cpp
@@ -0,0 +1,151 @@
+//===-- DLanguage.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DLanguage.h"
+
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Interpreter/Property.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/Support/DynamicLibrary.h"
+
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+using llvm::sys::DynamicLibrary;
+
+namespace {
+
+template 
+Fun *getTypedSymbol(DynamicLibrary &lib, const char *symbol) {
+  return reinterpret_cast(lib.getAddressOfSymbol(symbol));
+}
+
+// D Plugin will define these symbols. They're declared to use with decltype.
+extern "C" {
+char *lldbd_demangle(size_t length, const char *mangled);
+void d_initialize();
+}
+
+static PropertyDefinition g_properties[] = {
+{"pluginfile", OptionValue::eTypeString, true,
+ OptionValueString::eOptionEncodeCharacterEscapeSequences, "", nullptr,
+ "The plugin shared library file to use for D language."},
+};
+
+enum {
+  ePropertyPluginfileDlang,
+};
+
+} // anonymous namespace
+
+// DLanguageProperties
+DLanguageProperties::~DLanguageProperties() = default;
+
+DLanguageProperties::DLanguageProperties() : Properties() {
+  m_collection_sp.reset(
+  new OptionValueProperties(DLanguage::GetPluginNameStatic()));
+  m_collection_sp->Initialize(g_properties);
+}
+
+// DLanguage
+llvm::StringRef DLanguageProperties::GetPluginfileDlang() {
+  const uint32_t idx = ePropertyPluginfileDlang;
+  assert(m_collection_sp);
+  return m_collection_sp->GetPropertyAtIndexAsString(
+  nullptr, idx, g_properties[idx].default_cstr_value);
+}
+
+void DLanguage::Initialize() 

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

2018-03-10 Thread Timothee Cour via Phabricator via lldb-commits
timotheecour added a comment.

update: we can now set lldbdplugin in .lldbinit via `settings set 
plugin.language.D.pluginfile` so this avoids hardcoding that file


https://reviews.llvm.org/D44321



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2018-03-10 Thread Timothee Cour via Phabricator via lldb-commits
timotheecour updated this revision to Diff 137942.
timotheecour added a comment.

- added doc


https://reviews.llvm.org/D44321

Files:
  include/lldb/Core/Mangled.h
  include/lldb/Core/PluginManager.h
  source/API/SystemInitializerFull.cpp
  source/Core/CMakeLists.txt
  source/Core/Mangled.cpp
  source/Core/PluginManager.cpp
  source/Plugins/Language/CMakeLists.txt
  source/Plugins/Language/D/CMakeLists.txt
  source/Plugins/Language/D/DLanguage.cpp
  source/Plugins/Language/D/DLanguage.h

Index: source/Plugins/Language/D/DLanguage.h
===
--- /dev/null
+++ source/Plugins/Language/D/DLanguage.h
@@ -0,0 +1,81 @@
+//===-- DLanguage.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+/*
+to use, add this to .lldbinit:
+settings set plugin.language.D.pluginfile "path/to/liblldbdplugin.dylib"
+example of such plugin:
+https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d
+*/
+
+#ifndef liblldb_DLanguage_h_
+#define liblldb_DLanguage_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/Language.h"
+#include "lldb/lldb-private.h"
+
+namespace lldb_private {
+
+class DLanguageProperties : public Properties {
+public:
+  DLanguageProperties();
+
+  ~DLanguageProperties() override;
+
+  llvm::StringRef GetPluginfileDlang();
+};
+
+class DLanguage : public Language {
+public:
+  typedef std::shared_ptr DLanguagePropertiesSP;
+
+  DLanguage() = default;
+
+  ~DLanguage() override = default;
+
+  lldb::LanguageType GetLanguageType() const override {
+return lldb::eLanguageTypeD;
+  }
+
+  //--
+  // Static Functions
+  //--
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb_private::Language *CreateInstance(lldb::LanguageType language);
+
+  static void DebuggerInitialize(lldb_private::Debugger &debugger);
+
+  static DLanguage *Instance();
+
+  static const DLanguagePropertiesSP &GetGlobalProperties();
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  static bool IsDMangledName(const char *name);
+  // Consider using non-static methods
+  static char *demangle(const ConstString &mangled);
+
+  //--
+  // PluginInterface protocol
+  //--
+  ConstString GetPluginName() override;
+
+  uint32_t GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_DLanguage_h_
Index: source/Plugins/Language/D/DLanguage.cpp
===
--- /dev/null
+++ source/Plugins/Language/D/DLanguage.cpp
@@ -0,0 +1,151 @@
+//===-- DLanguage.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DLanguage.h"
+
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Interpreter/Property.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/Support/DynamicLibrary.h"
+
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+using llvm::sys::DynamicLibrary;
+
+namespace {
+
+template 
+Fun *getTypedSymbol(DynamicLibrary &lib, const char *symbol) {
+  return reinterpret_cast(lib.getAddressOfSymbol(symbol));
+}
+
+// D Plugin will define these symbols. They're declared to use with decltype.
+extern "C" {
+char *lldbd_demangle(size_t length, const char *mangled);
+void d_initialize();
+}
+
+static PropertyDefinition g_properties[] = {
+{"pluginfile", OptionValue::eTypeString, true,
+ OptionValueString::eOptionEncodeCharacterEscapeSequences, "", nullptr,
+ "The plugin shared library file to use for D language."},
+};
+
+enum {
+  ePropertyPluginfileDlang,
+};
+
+} // anonymous namespace
+
+// DLanguageProperties
+DLanguageProperties::~DLanguageProperties() = default;
+
+DLanguageProperties::DLanguageProperties() : Properties() {
+  m_collection_sp.reset(
+  new OptionValueProperties(DLanguage::GetPluginNameStatic()));
+  m_collection_sp->Initialize(g_properties);
+}
+
+// DLanguage
+llvm::StringRef DLanguageProperties::GetPluginfileDlang() {
+  const uint32_t idx = ePropertyPluginfileDlang;
+  assert(m_collectio

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

2018-03-10 Thread Timothee Cour via Phabricator via lldb-commits
timotheecour added a comment.

> It's a little more complicated for D because it's an out-of-tree compiler so 
> it poses interesting challenges.

the demangling itself is thoroughly tested in 
https://github.com/dlang/druntime/blob/master/src/core/demangle.d


https://reviews.llvm.org/D44321



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2018-03-10 Thread Timothee Cour via Phabricator via lldb-commits
timotheecour added a comment.

Note that the D plugin is not loaded by default (so default behavior is not 
affected) ; it's only loaded if user adds to his .lldbinit:
settings set plugin.language.D.pluginfile "path_to/liblldbdplugin.dylib"


https://reviews.llvm.org/D44321



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits