[Lldb-commits] [PATCH] D91508: [LLDB/Lua] add support for one-liner breakpoint callback

Martin Storsjö via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 15 09:59:04 PDT 2021


mstorsjo added a comment.

FWIW, I had debugged the issue described here and posted about it on Discord, but never got around to posting it here. I think the MSVC build error above gets fixed by this patch:

  diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  index f14e2732f6eb..788072cffd87 100644
  --- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  +++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  @@ -24,6 +24,7 @@ using namespace lldb;
   #if _MSC_VER
   #pragma warning (push)
   #pragma warning (disable : 4190)
  +llvm::Expected<bool> unusedFuncForInstantiatingExpectedBool() { return true; }
   #endif
  
   extern "C" llvm::Expected<bool> LLDBSwigLuaBreakpointCallbackFunction(

Here's a minimal showcase of the root issue:

  $ cat cpp-ret-c.cpp 
  template<class T> class MyClass {
  public:
      T a;
  };
  extern "C" MyClass<int> unmangledFunction();
  $ cl -c cpp-ret-c.cpp 
  cpp-ret-c.cpp
  cpp-ret-c.cpp(5): error C2526: 'unmangledFunction': C linkage function cannot return C++ class 'MyClass<int>' 
  cpp-ret-c.cpp(5): note: see declaration of 'MyClass<int>'
  $ cat cpp-ret-c2.cpp 
  template<class T> class MyClass {
  public:
      T a;
  };
  MyClass<int> unusedFunc() { return MyClass<int>{0}; }
  extern "C" MyClass<int> unmangledFunction();
  $ cl -c cpp-ret-c2.cpp
  cpp-ret-c2.cpp

So this construct, in MSVC, requires that the problematic return type template already has been instantiated somewhere else first. The case in the python plugin works, but it has been copied to the Lua plugin too, where it fails.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91508/new/

https://reviews.llvm.org/D91508



More information about the lldb-commits mailing list