This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c70a3d9178f: [lldb] Support CTF forward declarations 
(authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D156483?vs=544925&id=545324#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156483

Files:
  lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
  lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
  lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.h
  lldb/test/API/macosx/ctf/test.c

Index: lldb/test/API/macosx/ctf/test.c
===================================================================
--- lldb/test/API/macosx/ctf/test.c
+++ lldb/test/API/macosx/ctf/test.c
@@ -1,5 +1,7 @@
 #include <stdio.h>
 
+struct ForwardDecl;
+
 typedef int MyInt;
 
 void populate(MyInt i);
@@ -30,6 +32,7 @@
 } MyStructT;
 
 MyStructT foo;
+struct ForwardDecl *forward;
 
 void populate(MyInt i) {
   foo.n.i = i;
@@ -41,6 +44,7 @@
   foo.n.a[3] = 'd';
   foo.n.e = eOne;
   foo.f = NULL;
+  forward = NULL;
 }
 
 int main(int argc, char** argv) {
Index: lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.h
===================================================================
--- lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.h
+++ lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.h
@@ -225,6 +225,7 @@
   llvm::Expected<lldb::TypeSP> CreateEnum(const CTFEnum &ctf_enum);
   llvm::Expected<lldb::TypeSP> CreateFunction(const CTFFunction &ctf_function);
   llvm::Expected<lldb::TypeSP> CreateRecord(const CTFRecord &ctf_record);
+  llvm::Expected<lldb::TypeSP> CreateForward(const CTFForward &ctf_forward);
 
   llvm::StringRef ReadString(lldb::offset_t offset) const;
 
Index: lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -525,6 +525,17 @@
                   decl, record_type, lldb_private::Type::ResolveState::Full);
 }
 
+llvm::Expected<lldb::TypeSP>
+SymbolFileCTF::CreateForward(const CTFForward &ctf_forward) {
+  CompilerType forward_compiler_type = m_ast->CreateRecordType(
+      nullptr, OptionalClangModuleID(), eAccessPublic, ctf_forward.name,
+      clang::TTK_Struct, eLanguageTypeC);
+  Declaration decl;
+  return MakeType(ctf_forward.uid, ConstString(ctf_forward.name), 0, nullptr,
+                  LLDB_INVALID_UID, Type::eEncodingIsUID, decl,
+                  forward_compiler_type, Type::ResolveState::Forward);
+}
+
 llvm::Expected<TypeSP> SymbolFileCTF::CreateType(CTFType *ctf_type) {
   if (!ctf_type)
     return llvm::make_error<llvm::StringError>(
@@ -549,9 +560,10 @@
   case CTFType::Kind::eStruct:
   case CTFType::Kind::eUnion:
     return CreateRecord(*static_cast<CTFRecord *>(ctf_type));
+  case CTFType::Kind::eForward:
+    return CreateForward(*static_cast<CTFForward *>(ctf_type));
   case CTFType::Kind::eUnknown:
   case CTFType::Kind::eFloat:
-  case CTFType::Kind::eForward:
   case CTFType::Kind::eSlice:
     return llvm::make_error<llvm::StringError>(
         llvm::formatv("unsupported type (uid = {0}, name = {1}, kind = {2})",
@@ -637,11 +649,12 @@
     return std::make_unique<CTFRecord>(static_cast<CTFType::Kind>(kind), uid,
                                        name, variable_length, size, fields);
   }
+  case TypeKind::eForward:
+    return std::make_unique<CTFForward>(uid, name);
   case TypeKind::eUnknown:
     return std::make_unique<CTFType>(static_cast<CTFType::Kind>(kind), uid,
                                      name);
   case TypeKind::eFloat:
-  case TypeKind::eForward:
   case TypeKind::eSlice:
     offset += (variable_length * sizeof(uint32_t));
     break;
Index: lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
===================================================================
--- lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
+++ lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
@@ -163,6 +163,11 @@
       : CTFRecord(eUnion, uid, name, nfields, size, std::move(fields)){};
 };
 
+struct CTFForward : public CTFType {
+  CTFForward(lldb::user_id_t uid, llvm::StringRef name)
+      : CTFType(eForward, uid, name) {}
+};
+
 } // namespace lldb_private
 
 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_CTF_CTFTYPES_H
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to